向场景添加THREE.Points:THREE.Object3D.add:对象不是THREE.Object3D(Javascript)的实例

时间:2017-12-17 11:44:21

标签: javascript three.js

我试图添加一个系统粒子,一个THREE.Points到场景,但我有这个错误:

" THREE.Object3D.add:object不是THREE.Object3D的实例。未定义"

代码:

var backCount = 1800;
var particlesG = new THREE.Geometry();

for (var p = 0; p < backCount; p++) {
    var backgroundP = new THREE.Vector3();
    backgroundP.x = Math.random() * 3000 - 1500;
    backgroundP.y = Math.random() * 3000 - 1500;
    backgroundP.z = Math.random() * 3000 - 1500;
    particlesG.vertices.push(backgroundP);
}

var pMaterial = new THREE.PointsMaterial({color: 0xFFFFFF});

var particleSystemS = THREE.Points(particlesG, pMaterial);


scene.add(particleSystemS);

由于

1 个答案:

答案 0 :(得分:2)

THREE.Points之前添加新内容。

var particleSystemS = new THREE.Points(particlesG, pMaterial);