three.js:可以在同一个场景中渲染THREE.Points和THREE.Mesh吗?

时间:2016-05-10 16:25:20

标签: three.js

我尝试将Points Object和Mesh Object添加到同一场景中。但是一旦我添加网格,点就会消失。当我删除网格时,点会再次出现。三个.js是否可以同时在场景中同时使用?我现在正在使用r76。以前在Threejs r63中使用Three.ParticleSystem。这是一个错误还是错过了r63和r76之间的概念?

同样的行为似乎是Three.Line和Three.Points,我不能一起渲染。

有关于此的任何想法?提前谢谢。

1 个答案:

答案 0 :(得分:1)

好吧,我咬了(你没有任何代码) -

的错误
// - - - - points
  geometry = new THREE.Geometry();
  material = new THREE.PointsMaterial( { size:.1 } );
  for (i1=1; i1<=10; i1+=1) {
    var x1 = Math.random()*2-1;
    var y1 = Math.random()*2-1;
    var z1 = Math.random()*2-1;
    geometry.vertices.push(new THREE.Vector3(x1,y1,z1));
  }
  object3d = new THREE.Points(geometry, material);
  scene.add(object3d);
// - - - - line
  geometry = new THREE.Geometry();
  geometry.vertices = [ new THREE.Vector3(-1,1,0), new THREE.Vector3(0,-1,0), new THREE.Vector3(1,1,0) ];
  material = new THREE.LineBasicMaterial( { color:0xffffff } );
  object3d = new THREE.Line(geometry, material);
  scene.add(object3d);
// - - - - sphere
  geometry = new THREE.SphereGeometry(.5);
  material = new THREE.MeshPhongMaterial( {color:0xffffff} );
  mesh = new THREE.Mesh(geometry, material);
  mesh.scale.x = 2;
  mesh.position.set(0, 1, 0);
  scene.add(mesh);