我没有更新系统中的 three.js 库。今天更新了three.js文件。但是我遇到了这个错误:“Uncaught TypeError: Object # has no method 'traverseHierarchy'”。
我用它来检测交叉点:在线代码在这里:https ://dl.dropbox.com/u/44791710/test/simple2.html
function Intersect(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, 1);
var toIntersect = [];
THREE.SceneUtils.traverseHierarchy(scene, function (child) {
if (child instanceof THREE.Mesh) {
toIntersect.push(child);
}
});
var projector = new THREE.Projector();
projector.unprojectVector(vector, camera);
var ray = new THREE.Raycaster(camera.position,vector.sub(camera.position).normalize());
var intersects = ray.intersectObjects(toIntersect);
if (intersects.length > 0) {
for (var j = 0; j < intersects.length ; j++){
target = intersects[j].object;
console.log('Intersects at ' + mouse.x + '/' + mouse.y + ':');
for(var i = 0, m = intersects.length; i<m; i++){
console.log(intersects[i].object.id, intersects[i]);
}
}
}
}
我需要做什么样的改变?谢谢。