gpt4 book ai didi

javascript - ThreeJS - 未捕获的 TypeError : b[c]. 调用不是函数 - Orbit Controls

转载 作者:行者123 更新时间:2023-12-05 06:23:08 31 4
gpt4 key购买 nike

所以我正在做一个 three.js 项目。我的轨道控制开始工作了。它们正常工作,但对于我用鼠标移动的每个像素,我都会收到以下错误:

Uncaught TypeError: b[c].call is not a function
at THREE.OrbitControls.dispatchEvent (three.min.js:343)
at THREE.OrbitControls.update (OrbitControls.js:230)
at handleMouseMoveRotate (OrbitControls.js:493)
at HTMLDocument.onMouseMove (OrbitControls.js:901)

这是我的代码:

        function initial() {
scene = new THREE.Scene();
camera = new THREE.PerspectiveCamera(90, window.innerWidth / window.innerHeight, 45, 30000);
camera.position.set(-100, 0, -1200);
renderer = new THREE.WebGLRenderer({
antialias: true
});
renderer.setSize(window.innerWidth, window.innerHeight);
document.body.appendChild(renderer.domElement);
let controls = new THREE.OrbitControls(camera, renderer.domElement);
controls.addEventListener('change', renderer);
controls.minDistance = 500;
controls.maxDistance = 1500;
controls.dampingFactor = 0.25; // friction
controls.rotateSpeed = 0.5; // mouse sensitivity

let materialArray = [];
let texture_ft = new THREE.TextureLoader().load('./assets/px.jpg');
let texture_bk = new THREE.TextureLoader().load('./assets/nx.jpg');

let texture_up = new THREE.TextureLoader().load('./assets/py.jpg');
let texture_dn = new THREE.TextureLoader().load('./assets/ny.jpg');

let texture_rt = new THREE.TextureLoader().load('./assets/pz.jpg');
let texture_lf = new THREE.TextureLoader().load('./assets/nz.jpg');

materialArray.push(new THREE.MeshBasicMaterial({
map: texture_ft
}));
materialArray.push(new THREE.MeshBasicMaterial({
map: texture_bk
}));
materialArray.push(new THREE.MeshBasicMaterial({
map: texture_up
}));
materialArray.push(new THREE.MeshBasicMaterial({
map: texture_dn
}));
materialArray.push(new THREE.MeshBasicMaterial({
map: texture_rt
}));
materialArray.push(new THREE.MeshBasicMaterial({
map: texture_lf
}));

for (let i = 0; i < 6; i++)
materialArray[i].side = THREE.BackSide;

let skyboxGeo = new THREE.BoxGeometry(10000, 10000, 10000);
let skybox = new THREE.Mesh(skyboxGeo, materialArray);
scene.add(skybox);

animate();
}


function animate() {
renderer.render(scene,camera);
requestAnimationFrame(animate);
}
initial();

我已经用谷歌搜索了这个错误,但找不到解决方案。有人知道如何解决这个问题吗?

最佳答案

你不需要controls.addEventListener('change', renderer);,你可以使用controls.update()。

同样的错误出现在我身上,但当我停止为 three.js 使用 three.min.js 时它解决了。

关于javascript - ThreeJS - 未捕获的 TypeError : b[c]. 调用不是函数 - Orbit Controls,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/58626623/

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