一般情況下,它看起來就像這樣:
var speed = 5; // units a second, the speed we want
var currentPoint = new THREE.Vector3(); // we will re-use it
// this part is in a function of event listener of, for example, a button
currentPoint.copy(cube.position); // cube is the object to move
var distance = currentPoint.distanceTo(destinationPoint.position)
var duration = (distance/speed) * 1000; // in milliseconds
new TWEEN.Tween(cube.position)
.to(destinationPoint.position, duration) // destinationPoint is the object of destination
.start();
jsfiddle例子。看看tweening()
函數。
你知道距離,你有期望的速度,所以時間就是距離/速度。您在哪裏以及如何設置補間的時間? – prisoner849
持續時間是tween.to的第二個參數(對象,持續時間) – Radio