Three.jsで粒子のサイズをどのように見つけますか?
ジオメトリを使用すると、バウンディングボックス/球を使用して、three.js単位でそのサイズを計算できます。しかし、パーティクルには境界ボックスがなく、そのサイズを計算する方法がわかりません。
誰か提案はありますか?
Three.jsで粒子のサイズをどのように見つけますか?
ジオメトリを使用すると、バウンディングボックス/球を使用して、three.js単位でそのサイズを計算できます。しかし、パーティクルには境界ボックスがなく、そのサイズを計算する方法がわかりません。
誰か提案はありますか?
それはあなたが扱っている「粒子」の意味に依存します。aWebGLRenderer
を使用すると、の頂点を参照することになりますが、を使用すると、 (Canvasのみ)を意味ParticleSystem
します。パーティクルシステムに関しては、それを構築するために使用されるマテリアルは、通常の例のようにサイズがあります。geometry= new THREE.Geometry();CanvasRenderer
Particle
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