首页 > 建站教程 > WebGL教程 Threejs教程 >  threejs Cannot read properties of undefined (reading 'autoUpdate')报错正文

threejs Cannot read properties of undefined (reading 'autoUpdate')报错

threejs报下面的错误:
Uncaught TypeError: Cannot read properties of undefined (reading 'autoUpdate')
 
这个可能是因为render渲染时,camera, scene没有传:
renderer.render()
正确应该是:
renderer.render(scene, camera)
 
如果报下面的错误:
THREE.WebGLRenderer.render: camera is not an instance of THREE.Camera.
WebGLRenderer.render @ three.module.js:24175
 
可能是render的camera和scene传反了
renderer.render(camera, scene)
正确应该是:
renderer.render(scene, camera)
 
如果报下面的错:
Cannot read properties of undefined (reading 'center')

可能是网格模型的gmaterial和eometry传反了:
var mesh = new THREE.Mesh(geometry, material)
正确的应该是:
var mesh = new THREE.Mesh(material, geometry)