2012-06-20 3 views
2

Three.js에서 입자 크기를 어떻게 알 수 있습니까?Three.js에서 입자의 크기를 어떻게 알 수 있습니까?

지오메트리를 사용하면 경계 상자/구를 사용하여 그 크기를 three.js 단위로 계산할 수 있습니다. 그러나 입자에는 경계 상자가 없으며 어쨌든 크기를 계산할 수 없습니다.

누구에게 의견이 있습니까?

답변

3

'입자'의 의미에 따라 달라집니다. WebGLRenderer을 사용하면 ParticleSystem의 꼭지점을 의미하지만 CanvasRendererParticle을 의미합니다 (캔버스 만 해당). ParticleSystem의 관점에서 보면, 구성하는 데 사용되는 재질은 일반적인 예와 같이 크기가 있습니다. geometry = new THREE.Geometry();

for (i = 0; i < 10000; i ++) { 
    var vertex = new THREE.Vector3(); // and set its location 
    geometry.vertices.push(vertex); 
} 

material = new THREE.ParticleBasicMaterial({ 
    size: 35, // This might be the size you are thinking of? 
    sizeAttenuation: false, 
    map: // Some THREE.Texture 
}); 

particles = new THREE.ParticleSystem(geometry, material); 

그럼 당신은 크기를 액세스 할 수 있으며

particles.material.size = newSize; 

당신이 캔버스에 대한 Particle를 작성하는 경우에 간단하게 수정, 그것은 매우 유사합니다

// Construct the particle with a material 
var material = new THREE.ParticleBasicMaterial({ 
    map: new THREE.Texture( canvas), 
    blending: THREE.AdditiveBlending 
}); 
particle = new THREE.Particle(textMaterial); 
// Just need to access the material to get the 'size' 
var size = particle.material.size 
관련 문제