Pryme8 Posted April 20, 2018 Share Posted April 20, 2018 So would there be any benefits or cons to doing something like this: var time = 0; engine.runRenderLoop(function(){ scene.render(); var d = engine._deltaTime; time+=d*0.0001; shader.setFloat('time', time); }); as opposed to: var time = 0; engine.runRenderLoop(function(){ scene.render(); time+=0.01; shader.setFloat('time', time); }); Is there a way to guarantee clients will get the same time 'coordinates' on a shader even with different io speeds? Quote Link to comment Share on other sites More sharing options...
Guest Posted April 20, 2018 Share Posted April 20, 2018 you should use scene.getAnimationRatio() * TheOffsetIWantToUse to get a value synchronized with timing Pryme8 1 Quote Link to comment Share on other sites More sharing options...
Pryme8 Posted April 20, 2018 Author Share Posted April 20, 2018 Ok cool, the other one I was thinking about was doing like: var start = Date.now(); var time = 0; loop{ var now = Date.now(); time = now - start; setTime... } but if the getAnimationRatio works then Ill go with that! Quote Link to comment Share on other sites More sharing options...
Pryme8 Posted April 20, 2018 Author Share Posted April 20, 2018 http://www.babylonjs-playground.com/#BC4W77 comparing the two methods. GameMonetize 1 Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.