为什么下面的尖端ArrowHelper
不直接击中目标球体?它只是有点想念它。下面的方向计算不够精确吗?
var geometry = new THREE.SphereGeometry(1, 16, 16);
var material = new THREE.MeshNormalMaterial();
var mesh = new THREE.Mesh(geometry, material);
mesh.type = "node";
mesh.position.set(30, -87, -11);
scene.add(mesh);
geometry = new THREE.SphereGeometry(1, 16, 16);
material = new THREE.MeshNormalMaterial();
mesh = new THREE.Mesh(geometry, material);
mesh.type = "node";
mesh.position.set(28, 44, -14);
scene.add(mesh);
var sourcePos = new THREE.Vector3(30, -87, -11);
var targetPos = new THREE.Vector3(28, 44, -14);
var direction = new THREE.Vector3().subVectors(targetPos, sourcePos);
var arrow = new THREE.ArrowHelper(direction.clone().normalize(), sourcePos, direction.length(), 0xff0000);
scene.add(arrow);
这是此问题的直接后续问题(我将其保持打开状态,因为可能有更好的算法没有ArrowHelper
,但似乎这里描述的 ArrowHelper 问题导致了不准确性)。