Navigation

    Colyseus
    • Login
    • Search
    • Recent
    • Tags
    • Users
    1. Home
    2. RobinFalko
    RobinFalko

    RobinFalko

    @RobinFalko

    Chat Follow Unfollow
    0
    Reputation
    2
    Posts
    1065
    Profile views
    0
    Followers
    0
    Following
    Joined Last Online

    • Profile
    • More
      • Continue chat with RobinFalko
      • Flag Profile
      • Following
      • Followers
      • Topics
      • Posts
      • Best
      • Groups
    RobinFalko Follow

    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 •
    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 •