我想问一下为什么THREE.js中与raycast相交的交点不能正常工作(即使我只是单击直线附近,它也可以检测到相交)。
我使用以下代码创建一行:
var material = new THREE.LineBasicMaterial({
color: 0x00ff00
});
var geometry = new THREE.Geometry();
geometry.vertices.push(new THREE.Vector3(-2, 0, 0));
geometry.vertices.push(new THREE.Vector3(2, 0, 0));
var line = new THREE.Line(geometry, material);
然后对于raycast部分,请执行以下操作:
mouse.x = (event.clientX / window.innerWidth) * 2 - 1;
mouse.y = -(event.clientY / window.innerHeight) * 2 + 1;
raycaster.setFromCamera(mouse, camera);
var intersects = raycaster.intersectObjects(scene.children);
即使我单击线,相交也会使我与线相交。