1

为什么下面的尖端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 问题导致了不准确性)。

4

1 回答 1

1

这是three.js r.58 在处理箭头近似“向上”或“向下”的情况时的精度问题。

我想你会发现它在其他情况下也能正常工作。

三.js r.58

于 2013-05-28T22:46:25.057 回答