简体   繁体   中英

THREE.js Using MeshPhongMaterial As Particle Material and Setting Size

I am trying to create particles that have the properties of a Phong material (react to light), to achieve this I have used the "createMultiMaterialObject", this has worked on the most part other than ignoring the particle size, for some reason the particles seems to be weird triangle shapes, see below:

在此输入图像描述

This is the code I am using:

var ringGeometry = new THREE.TorusGeometry( rad, ringSize, 1, 200, Math.PI * 2);
materials = [
p2paterial = new THREE.MeshPhongMaterial({shading: THREE.SmoothShading, blending:     THREE.AdditiveBlending, transparent: true, color: ringColour, ambient: 0x000000, specular:     0xffffff, shininess: 1, vertexColors: false  } ),
pmaterial = new THREE.ParticleBasicMaterial( { size: 1, transparent: true,     vertexColors: true  } )
        ];
singleRing = new THREE.SceneUtils.createMultiMaterialObject(ringGeometry, materials);

Can anyone point me in the direction of how I can achieve the last bit, making the particles size 1 each - I'm so close to getting what I want that I suspect it's just an option I need to tweak somewhere.

Try this instead:

var geometry = new THREE.TorusGeometry( rad, ringSize, 1, 200, Math.PI * 2);

var material = new THREE.MeshPhongMaterial({shading: THREE.SmoothShading, blending:     THREE.AdditiveBlending, transparent: true, color: ringColour, ambient: 0x000000, specular:     0xffffff, shininess: 1, vertexColors: false  } );
var mesh = new THREE.Mesh( geometry, material );
scene.add( mesh );

var material = new THREE.ParticleBasicMaterial( { size: 1, transparent: true,     vertexColors: true  } );
var particles = new THREE.ParticleSystem( geometry, material );
scene.add( particles );

I have never worked with three.js, but I was messing around with your fiddle and I got something that looks more like particles by adjusting the value of RadialSegments in your TorusGeometry declaration....

var geometry = new THREE.TorusGeometry( 10, 10, .5, 200, Math.PI * 2);

http://jsfiddle.net/sJZeH/

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM