我正在进行一个演示,它与此页面中的一个示例(http://chandlerprall.github.io/Physijs/examples/body.html)非常相似。这只是一个盒子掉下来。但是我想计算自盒子开始下落以来它到达地面所花费的时间,这样我就可以计算出速度。有没有办法做到这一点??请帮忙。
答案 0 :(得分:0)
这是一个算法:
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;
}
}