2
如何在Three.js中找到粒子的大小?如何在Three.js中找到粒子的大小?
使用幾何圖形,您可以使用邊界框/球體以three.js爲單位計算其大小。但是一個粒子沒有邊界框,我也無法看到它的大小。
有沒有人有任何建議?
如何在Three.js中找到粒子的大小?如何在Three.js中找到粒子的大小?
使用幾何圖形,您可以使用邊界框/球體以three.js爲單位計算其大小。但是一個粒子沒有邊界框,我也無法看到它的大小。
有沒有人有任何建議?
這取決於你正在處理的'粒子'的含義。使用WebGLRenderer
時,您將指ParticleSystem
中的頂點,但CanvasRenderer
表示Particle
(僅限Canvas)。就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