Domanda

I-m working on a demo, it's very similar a one example in this page (http://chandlerprall.github.io/Physijs/examples/body.html ). It's just a box falling down. But I want to calculate the time taken since the box starts falling until it gets to the ground so I can calculate the velocity. Is there a way to do that?? Please help.

È stato utile?

Soluzione

Here's an algorithm:

  Animate : function (cb) {
  //the above is whatever your initial animation function is      
  THREE.Clock.startTime = (new Date()).getMilliseconds();

    if (objects touch ground) {
      var now = (new Date()).getMilliseconds();
      THREE.Clock.duration = now - THREE.Clock.startTime;
    }
  }
Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a StackOverflow
scroll top