Navigation

  • Recent
  • Tags
  • Users
  • Search
  • Login
Colyseus
  • Login
  • Search
  • Recent
  • Tags
  • Users

Documentation GitHub

We're migrating to GitHub Discussions. This forum does not accept new registrations since April 6, 2023.
  1. Home
  2. RobinFalko
  3. Posts
  • Profile
  • More
    • Continue chat with RobinFalko
    • Flag Profile
    • Following
    • Followers
    • Topics
    • Posts
    • Best
    • Groups

Posts made by RobinFalko

RE: clock.setInterval deltaTime

Hi endel, thanks for your reply.
You're right but the delta time is computed for the tick of room.setSimulationInterval, not clock.setInterval if I understood that correctly.

e.g.

//clock.start() is called indirectly and ticking starts:
this.setSimulationInterval(deltaTime => {
            [...] //let's say deltaTime is about 15
        });

this.clock.setInterval(function() { 
    [...] 
    //the deltaTime of this closure should be about 2000
    //but instead this.clock.deltaTime is about 15 since it's computed at the tick of setSimulationInterval
}, 2000);

So each setInterval should have its own deltaTime since it has its own refresh rate.

posted in Questions & Help • 11 Nov 2018, 13:41
clock.setInterval deltaTime

Hi, I'm currently using this.clock.setInterval to compute some time based positions.
For that task I need the deltaTime within the interval scope (not the room.setSimulationInterval scope).

Right now I'm computing the deltaTime on my own:

var timestamp = this.clock.currentTime;
this.clock.setInterval(function() {
    const delta = this.clock.currentTime - timestamp;

    //event tough refresh rate is set to 2000, the deltaTime is between about 1983 and 2013 
    [...] //code

    timestamp = this.clock.currentTime;
}, 2000);

It would be nice to get the local deltaTime passed in by the setInterval closure just like in room.setSimulationInterval:

this.clock.setInterval(function(**deltaTime**) { 
    [...] //code
}, 2000);

Are there any other suggestions how to get the deltaTime within a local setInterval?

posted in Questions & Help • 10 Nov 2018, 16:53

© 2023 Endel Dreyer