Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/three.js/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Vector Aframe/threejs:计算一个点;“背后”;另一个因素_Vector_Three.js_3d_Aframe - Fatal编程技术网

Vector Aframe/threejs:计算一个点;“背后”;另一个因素

Vector Aframe/threejs:计算一个点;“背后”;另一个因素,vector,three.js,3d,aframe,Vector,Three.js,3d,Aframe,假设我们有两个元素,A和B,它们的位置都是已知的;我需要得到一个点的位置,它朝向a和B之间的方向,距离B有X米 我想我需要创建一条从a到B的“线”,再延伸X米,然后在线的末端得到点 如何将其转换为向量?可能是这样: const x = 2; const a = new THREE.Vector3(); const b = new THREE.Vector3( 0, 0, 1 ); const v = new THREE.Vector3(); // the result vector v.sub

假设我们有两个元素,A和B,它们的位置都是已知的;我需要得到一个点的位置,它朝向a和B之间的方向,距离B有X米

我想我需要创建一条从a到B的“线”,再延伸X米,然后在线的末端得到点

如何将其转换为向量?

可能是这样:

const x = 2;
const a = new THREE.Vector3();
const b = new THREE.Vector3( 0, 0, 1 );
const v = new THREE.Vector3(); // the result vector

v.subVectors( a, b );
v.normalize();
v.multiplyScalar( x );
v.add( b ); // v is now (0, 0, - 1)
完整工作示例: