Three.js中THREE.PlaneBufferGeometry不是构造函数错误求助
解决THREE.PlaneBufferGeometry is not a constructor错误
这个报错的核心原因是Three.js版本兼容性问题:从r125版本开始,官方移除了PlaneBufferGeometry,将其功能合并到了PlaneGeometry中——现在的PlaneGeometry默认就是缓冲几何体(BufferGeometry)的实现,不再需要单独使用带Buffer后缀的类。
修复步骤
直接把代码里所有的THREE.PlaneBufferGeometry替换为THREE.PlaneGeometry即可,其他逻辑不需要改动。
修改后的代码
function particleSetup() { let loader = new THREE.TextureLoader(); loader.load("smoke.png", function (texture){ portalGeo = new THREE.PlaneGeometry(350, 350); portalMaterial = new THREE.MeshStandardMaterial({ map: texture, transparent: true }); smokeGeo = new THREE.PlaneGeometry(1000,1000); smokeMaterial = new THREE.MeshStandardMaterial ({ map: texture, transparent: true }); for (let p=880;p>250;p--) { let particle = new THREE.Mesh(portalGeo,portalMaterial); particle.position.set ( 0.5 * p * Math.cos ( (4 * p * Math.PI) / 180), 0.5 * p * Math.sin ( (4 * p * Math.PI) / 180), 0.1 * p ); particle.rotation.z = Math.random() *360; portalParticles.push(particle); scene.add(particle); } for (let p=0;p<40;p++) { let particle = new THREE.Mesh (smokeGeo, smokeMaterial); particle.position.set ( Math.random () * 1000-500, Math.random () * 400-200, 25 ); particle.rotation.z = Math.random () *360; particle.material.opacity = 0.6; portalParticles.push (particle); scene.add (particle); } clock = new THREE.Clock (); animate ( ); }); }
内容的提问来源于stack exchange,提问作者Patrizio Valente
相关产品推荐
相关产品推荐

