Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/three.js/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript 二十面体粒子系统与3.js?只是得到正方形?_Javascript_Three.js - Fatal编程技术网

Javascript 二十面体粒子系统与3.js?只是得到正方形?

Javascript 二十面体粒子系统与3.js?只是得到正方形?,javascript,three.js,Javascript,Three.js,我是three.js的新手,正在构建一个太阳系,我需要一个粒子系统,粒子是二十面体。我使用以下函数从教程中创建了一个粒子系统: function createParticleSystem() { // The number of particles in a particle system is not easily changed. var particleCount = 2000; // Particles are just individual vertices

我是three.js的新手,正在构建一个太阳系,我需要一个粒子系统,粒子是二十面体。我使用以下函数从教程中创建了一个粒子系统:

function createParticleSystem() {

    // The number of particles in a particle system is not easily changed.
    var particleCount = 2000;

    // Particles are just individual vertices in a geometry
    // Create the geometry that will hold all of the vertices
    var particles = new THREE.IcosahedronGeometry(1, 0);

    // Create the vertices and add them to the particles geometry
    for (var p = 0; p < particleCount; p++) {

        // This will create all the vertices in a range of -200 to 200 in all directions
        var x = Math.random() * 400 - 200;
        var y = Math.random() * 400 - 200;
        var z = Math.random() * 400 - 200;

        // Create the vertex
        var particle = new THREE.Vector3(x, y, z);

        // Add the vertex to the geometry
        particles.vertices.push(particle);
    }

    // Create the material that will be used to render each vertex of the geometry
    var particleMaterial = new THREE.PointsMaterial(
            {color: 0xffffff, 
             size: 4,
             shading: THREE.FlatShading,
             blending: THREE.AdditiveBlending,
             transparent: true,
            });

    var partMaterial2 = new THREE.MeshPhongMaterial({ color: 0xffffff, shading: THREE.FlatShading, vertexColors: THREE.VertexColors, shininess: 0   } );

    // Create the particle system
    particleSystem = new THREE.Points(particles, particleMaterial);

    return particleSystem;  
}
函数createParticleSystem(){
//粒子系统中的粒子数不容易更改。
var particleCount=2000;
//粒子只是几何体中的单个顶点
//创建将容纳所有顶点的几何体
var粒子=新的三个。二十面体几何(1,0);
//创建顶点并将其添加到粒子几何体
对于(var p=0;p
这会在不同的位置创建粒子,尽管我将几何设置为三。二十面体几何并试图改变材质,但我唯一能创建的是白色的正方形。如果像前面使用的那样将材质更改为
MeshPhongMaterial
,则我的场景将不会渲染

如何生成二十面体粒子?

(我意识到这太晚了。)二十面体几何有顶点,但通常不单独设置它们。设置点和线的顶点。我认为其他一切都是网状的。(我希望其他人有更好的措辞。)

注意事项:

geometry = new THREE.Geometry(); 
material = new THREE.PointsMaterial( { color:0xffffff, size:1 } );
geometry.vertices.push( // your points get pushed
var object3d = new THREE.Points(geometry, material);
scene.add(object3d);
要执行直线段,请执行以下操作:

geometry = new THREE.Geometry();
geometry.vertices.push( // your line ends get pushed
material = new THREE.LineBasicMaterial( { color:0xffffff } );
object3d = new THREE.Line(geometry, material);
scene.add(object3d);
要生成二十面体或任何网格,请执行以下操作:

for (var i1=0; i1<N; i1+=1) { 
  geometry = new THREE.IcosahedronGeometry(1); 
  material = new THREE.MeshPhongMaterial( { color:0xffffff, shading:THREE.FlatShading } );
  material.side = THREE.DoubleSide;
  mesh= new THREE.Mesh(geometry, material);
  mesh.position.set(x, y, z);
  scene.add(mesh);
}
for(var i1=0;i1(我意识到这已经晚了。)二十面体几何有顶点,但通常不单独设置它们。你设置点和线的顶点。我认为其他所有东西都是网格。(我希望其他人有更好的措辞。)

注意事项:

geometry = new THREE.Geometry(); 
material = new THREE.PointsMaterial( { color:0xffffff, size:1 } );
geometry.vertices.push( // your points get pushed
var object3d = new THREE.Points(geometry, material);
scene.add(object3d);
要执行直线段,请执行以下操作:

geometry = new THREE.Geometry();
geometry.vertices.push( // your line ends get pushed
material = new THREE.LineBasicMaterial( { color:0xffffff } );
object3d = new THREE.Line(geometry, material);
scene.add(object3d);
要生成二十面体或任何网格,请执行以下操作:

for (var i1=0; i1<N; i1+=1) { 
  geometry = new THREE.IcosahedronGeometry(1); 
  material = new THREE.MeshPhongMaterial( { color:0xffffff, shading:THREE.FlatShading } );
  material.side = THREE.DoubleSide;
  mesh= new THREE.Mesh(geometry, material);
  mesh.position.set(x, y, z);
  scene.add(mesh);
}

for(var i1=0;i1粒子是正方形。如果你想要二十面体,那么就做
map:THREE.ImageUtils.loadTexture(“images/Icosahedron.png”),
阅读关于粒子的内容:你走错了方向particles@TreizeCinq“ParticleSystem”是否已弃用?链接给出“404-未找到”@dcromley不,看看这里:@Treize Cinq我从第一个例子中找不到任何东西-没有错误-没有输出。我会处理它。谢谢。粒子是正方形的。如果你想要二十面体,就做
map:THREE.ImageUtils.loadTexture(“images/Icosahedron.png”),
阅读关于粒子的文章:你走错了方向particles@TreizeCinq“ParticleSystem”是否已弃用?链接给出“404-未找到”@dcromley Nope,看看这里:@Treize Cinq我从第一个例子中得不到任何东西——没有错误——没有输出。我会努力的。谢谢。二十面体总是使用meshphongmaterial吗?@skyguy我很确定可以使用其他材料。我必须进行实验,看看什么不能使用。二十面体总是使用meshphongmaterial吗材料?@skyguy我很确定其他材料可以使用。我必须进行实验,看看哪些材料不能使用。