我正在尝试确定光线是否与 three.js 中的对象相交
我的场景设置和显示很好。
我点击我创建的球体,如下所示:
var intersect_objects = [];
//Initialize scene and object and events
scene = new THREE.Scene();
group = new THREE.Object3D();
sphere = new THREE.SphereGeometry(23.8, 60, 60);
//Add meshes and textures etc..
intersect_objects.push(group);
function onDocumentMouseUp(event) {
event.preventDefault();
var mouseX = (event.clientX / window.innerWidth)*2-1;
var mouseY = -(event.clientY /window.innerHeight)*2+1;
var vector = new THREE.Vector3(mouseX, mouseY, 0.5);
projector.unprojectVector(vector, camera);
var ray = new THREE.Raycaster(camera.position, vector.sub(camera.position).normalize());
var intersects = ray.intersectObjects(intersect_objects);
console.log(intersects.length); //Aways 0
}
但 intersects.length 始终为 0。它肯定与球体相交吗?