Frage

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.

War es hilfreich?

Lösung

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;
    }
  }
Lizenziert unter: CC-BY-SA mit Zuschreibung
Nicht verbunden mit StackOverflow
scroll top