为什么以下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);
这是对此question的直接跟进问题(由于可能有更好的算法没有ArrowHelper
,所以我保持开放状态,但似乎这里描述的ArrowHelper问题引起的不准确)
答案 0 :(得分:1)
当处理箭头指向“直线向上”或“直线向下”的情况时,这是three.js r.58中的精度问题。
我认为你会发现它在其他情况下运行良好。
three.js r.58