将向量的长度等同于 three.js 中的某个值
equate the length of a vector to a certain value in three.js
我一直在阅读 documentation & source 以尝试找到一种方法来计算向量的长度,然后将其设置为定义的值。
我的代码:
if (viewerPosition !== null && placementPosition !== null) {
var vectorDiff = placementPosition.sub(viewerPosition);
placementPosition.setY(0);
placementPosition.multiplyScalar(100000);
console.log(placementPosition)
日志returns:
Object { x: -23.658385352970377, y: 0, z: 9.121675219786463 }
我试过添加以下行:
placementPosition.length (32);
看看这是否会将向量的长度更改为 32m,但不幸的是,这没有用。
如有任何建议,我们将不胜感激。谢谢
// make the length of the vector 1.0
placementPosition.normalize();
// make the length of the vector 32
placementPosition.multiplyScalar(32);
我一直在阅读 documentation & source 以尝试找到一种方法来计算向量的长度,然后将其设置为定义的值。
我的代码:
if (viewerPosition !== null && placementPosition !== null) {
var vectorDiff = placementPosition.sub(viewerPosition);
placementPosition.setY(0);
placementPosition.multiplyScalar(100000);
console.log(placementPosition)
日志returns:
Object { x: -23.658385352970377, y: 0, z: 9.121675219786463 }
我试过添加以下行:
placementPosition.length (32);
看看这是否会将向量的长度更改为 32m,但不幸的是,这没有用。
如有任何建议,我们将不胜感激。谢谢
// make the length of the vector 1.0
placementPosition.normalize();
// make the length of the vector 32
placementPosition.multiplyScalar(32);