我想成倍增加:
vectorDiff = placementPosition.sub(viewerPosition);
10,所以当"模型"被移动:
moveModel(vectorDiff, "GPS");
它的移动速度是目前的10倍。我该怎么做呢;即时通讯新手javascript任何帮助将不胜感激。以下是上面的代码块:
if ( viewerPosition !== null && placementPosition!== null) {
vectorDiff = placementPosition.sub(viewerPosition);
rotationSum = new THREE.Vector3().addVectors(placementRotation, viewerRotation)
//rotationSum.setY(rotationSum.y+180);
moveModel(vectorDiff, "GPS");
//rotateModel(rotationSum, "GPS");
答案 0 :(得分:0)
Three.js载体是可变的;当您致电v1.sub(v2)
时,v1
包含结果:
var v1 = new THREE.Vector3(2,3,4);
var v2 = new THREE.Vector3(1,0,3);
v1.sub(v2);
console.log(v1.toArray())
// [1, 3, 1]
因此"从另一个值中减去一个值的结果"只是"第一个矢量"。您需要一种方法将该向量乘以一个数字,或标量。
该方法为multiplyScalar
:
v1.multiplyScalar(10);
console.log(v1.toArray());
// [4, 12, 4]