我在检测与 THREE.js 的对象交叉点时遇到问题。我的对象是从 2D 几何体中挤出的,如下所示:
var geoShape = new THREE.Shape(vertexes);
var geometry = new THREE.ExtrudeGeometry(geoShape, { bevelEnabled: false, amount: 3 });
var mesh = THREE.SceneUtils.createMultiMaterialObject(geometry,
[new THREE.MeshLambertMaterial({ color: '#493D26' })]
);
scene.add(mesh);
然后我试图检测这样的交叉点:
container.mousedown(function (e) {
event.preventDefault();
var vector = new THREE.Vector3((e.clientX / window.innerWidth) * 2 - 1, -(e.clientY / window.innerHeight) * 2 + 1, 0.5);
projector.unprojectVector(vector, camera);
var raycaster = new THREE.Raycaster(camera.position, vector.sub(camera.position).normalize());
var intersects = raycaster.intersectObjects(scene.children);
console.log(intersects);
});
每次,我的 intersects 数组都是空的。如果我在场景中添加一个球体,我会得到交叉点,但前提是我放大到 z < 18。有什么建议吗?