我想使用 collada 对象中的射线检测相交,three.js r58 但是
var intersects = target.intersectObjects(ai);
不为我工作任何人解决这个问题?是 Ray 不支持 r58 中的 intersectObjects() 方法还是代码中有任何错误?那么什么是替代而不是Raycasting?
var sphereMaterial = new t.MeshBasicMaterial({color: 0x333333});
var sphereGeo = new t.SphereGeometry(2, 6, 6);
var target;
function createBullet(obj) {
if (obj === undefined) {
obj = cam;
}
var sphere = new t.Mesh(sphereGeo, sphereMaterial);
sphere.position.set(obj.position.x, obj.position.y * 0.8, obj.position.z);
if (obj instanceof t.Camera) {
var vector = new t.Vector3(mouse.x, mouse.y, 1);
projector.unprojectVector(vector, obj);
target=new t.Ray(obj.position, vector.sub(obj.position).normalize());
sphere.ray= target;
}
else {
var vector = cam.position.clone();
target=new t.Ray(obj.position, vector.sub( obj.position ).normalize());
sphere.ray= target;
}
sphere.owner = obj;
bullets.push(sphere);
scene.add(sphere);
return sphere;
}