gpt4 book ai didi

Three.js SceneUtils 没有 traverseHierarchy!!!它在哪里?

转载 作者:行者123 更新时间:2023-12-05 08:59:16 24 4
gpt4 key购买 nike

我没有更新我系统中的 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]);
}
}
}
}

我需要做什么样的改变?谢谢。

最佳答案

您应该将 scene.traverse(scene, function (child) { 替换为 scene.traverse(function (child) {(我无法添加评论,所以我创建了一个答案)。

关于Three.js SceneUtils 没有 traverseHierarchy!!!它在哪里?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/15583974/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com