Comments (3)
Time of day is calculated by glfwGetTime()
http://www.glfw.org/docs/latest/group__input.html#gaa6cf4e7a77158a3b8fd00328b1720a4a (which "measures time elapsed since GLFW was initialized"):
float time_of_day() {
if (g->day_length <= 0) {
return 0.5;
}
float t;
t = glfwGetTime();
t = t / g->day_length;
t = t - (int)t;
return t;
}
so at startup, it'll be near 0
Some tests:
- glfwGetTime(): -7am
- +g->day_length/4: -2am
- +g->day_length/2: 4am
- +g->day_length: 4pm
- +g->day_length/1.5: 8am
Note future enhancement, would require changing how time works: #11 Add /time command to change/freeze time of day, nighttime/daytime
from netcraft.
glfwSetTime() to day_length/3 should set to about 8am (8 / 24 = 0.3'), works on native not emscripten, so maybe emscripten bug? library_glfw.js:
glfwGetTime: function() {
return GLFW.getTime() - GLFW.initialTime;
},
glfwSetTime: function(time) {
GLFW.initialTime = GLFW.getTime() + time;
},
GLFW.getTime() returns _emscripten_get_now() / 1000. Is glfwSetTime() wrong, why doesn't it set directly to the time
parameter not + GLFW.getTime()
? This is glfw3 time:
GLFWAPI double glfwGetTime(void)
{
_GLFW_REQUIRE_INIT_OR_RETURN(0.0);
return (double) (_glfwPlatformGetTimerValue() - _glfw.timer.offset) /
_glfwPlatformGetTimerFrequency();
}
GLFWAPI void glfwSetTime(double time)
{
_GLFW_REQUIRE_INIT();
if (time != time || time < 0.0 || time > 18446744073.0)
{
_glfwInputError(GLFW_INVALID_VALUE, "Invalid time %f", time);
return;
}
_glfw.timer.offset = _glfwPlatformGetTimerValue() -
(uint64_t) (time * _glfwPlatformGetTimerFrequency());
}
Confirmed, fixing emscripten fixes it. Opened pull request: emscripten-core/emscripten#5304
from netcraft.
Patching in #194
from netcraft.
Related Issues (20)
- Cookie to save login session?
- Screenshots look brighter than they are - saving alpha channel? HOT 1
- Liquids should target block underneath when mining HOT 2
- Crouching with shift should allow sliding along edges
- Crouching while falling but not flying allows hovering midair
- [VR] Use window size as vr size, allow resizing by retoggling to reinitialize
- Touch controls should allow full game interaction
- Use only terrain from server, remove local generation when online
- Update glfw to fix build and runtime warnings HOT 1
- Touch events not received on initial page load
- /list command to list player names and count online
- [VR] Google Cardboard support
- [Touch] Block should mine only when touching in same place without moving
- Showing chunk boundary borders
- View bobbing when walking HOT 1
- Rendered arm of player in first person HOT 1
- Crafting HOT 1
- Try out "Voxelus"? HOT 1
- Texture Management Change
- Build failing on Linux when building LLVM from source HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from netcraft.