2

Three.jsで粒子のサイズをどのように見つけますか?

ジオメトリを使用すると、バウンディングボックス/球を使用して、three.js単位でそのサイズを計算できます。しかし、パーティクルには境界ボックスがなく、そのサイズを計算する方法がわかりません。

誰か提案はありますか?

4

1 に答える 1

3

それはあなたが扱っている「粒子」の意味に依存します。aWebGLRendererを使用すると、の頂点を参照することになりますが、を使用すると、 (Canvasのみ)を意味ParticleSystemします。パーティクルシステムに関しては、それを構築するために使用されるマテリアルは、通常の例のようにサイズがあります。geometry= new THREE.Geometry();CanvasRendererParticle

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;

forキャンバスを作成している場合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
于 2012-07-19T23:11:47.063 に答える