fenomas / noa

Experimental voxel game engine.
MIT License
612 stars 87 forks source link

Fix camera movement and make development cross-platform #51

Closed ghost closed 5 years ago

ghost commented 5 years ago

Development is pretty much cross-platform after a few script modifications (no issues when building and whatnot) and the input is done each render, rather than each tick, to ensure a smooth movement with the camera. The examples were updated to reflect the code change. Webpack was also updated in the process because I couldn't live to see it outdated.

fenomas commented 5 years ago

Hi, thanks for the PR but I'm a little unclear what it's doing. Camera movements and zooming should already be happening smoothly on render (hereabouts). It looks like this PR changes how often rendering.zoomDistance is updated, but that just changes the position the camera is zooming towards, it shouldn't affect how smoothly the zooming takes place.

Are the changes in this PR perceptibly affecting camera movement for you?

fenomas commented 5 years ago

I should add, the build-related changes look fine, I just need to pull them down locally and test.

ghost commented 5 years ago

The main issue with the original behavior was that input was being collected each tick. So, on tick intervals lower than the rendering rate the camera seemed to move in a rough fashion. You could probably fix it with interpolation as well, but this PR could help with input latency as well. If you ran the test of both branches side by side, there would be a noticeable change when you rotated the camera. The zoomDistance change was done just to be synchronized with what I changed inside the engine.

fenomas commented 5 years ago

Hi,

Perhaps I'm missing something, but for me the camera rotation from mouse inputs already happens on render. E.g. if I run the test world with the tick rate set to 1000ms, the camera rotates normally rather than once per second.

Is that not what you're seeing? You can set the tick rate by adding tickRate: 1000, to the options object here.

For reference, camera rotation (consuming mouse dx/dy input) starts here, in the render function.

ghost commented 5 years ago

Ah... perhaps I initially misunderstood what tickRate really was. I thought it was the number of times the tick function was being called per second, not the amount of time in ms spent each tick call... Yeah, it's probably just my imagination or my computer making me believe that the camera was choppy. Should the change be reverted?

fenomas commented 5 years ago

Thanks for confirming, in that case I'll go ahead and close this PR, as I think consuming input events on tick is the right thing to do. The intent here is that client "gameplay" code should be running on tick rather than render, but if the engine consumed scroll events on render then gameplay code listening to tick would miss events.

You're certainly welcome to send build-related stuff as separate PRs; it would be great if they could be relatively atomic (e.g. one PR to fix paths in the build script, a different one to up the webpack dependency, etc.)

Thanks!