我不知道问题出在哪里,但在控制台上显示此错误:
THREE.PlaneBufferGeometry 不是构造函数
这就是代码
function particleSetup() {
let loader = new THREE.TextureLoader() ;
loader. load("smoke.png", function (texture){
portalGeo = new THREE.PlaneBufferGeometry(350, 350);
portalMaterial = new THREE.MeshStandardMaterial({
map: texture,
transparent: true
});
smokeGeo = new THREE.PlaneBufferGeometry(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 ( );
});
}
这是我对 Three.js 的第一次测试,我到处搜索,但我不明白问题所在,我认为是 PlaneBufferGeometry 的问题
最佳答案
几何生成器的 BufferGeometry
别名已在 r145
中弃用,现已在最新的 Three.js
版本中删除。使用 PlaneGeometry
而不是 PlaneBufferGeometry
。
关于javascript - 错误 : THREE. PlaneBufferGeometry 不是构造函数,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/77130600/