0
閱讀外觀極好問題關於隨機填充一個球體的表面與顆粒:How to make a sphere made out of random particles in three.js。我如何用隨機生成的粒子填充球體的總體積?我試試看:如何填補隨機粒子的球體在three.js所
var particleCount = 1800,
particles = new THREE.Geometry(),
pMaterial = new THREE.PointCloudMaterial({
color: 0xFFFFFF,
size: 20,
map: THREE.ImageUtils.loadTexture(
"images/particle.png"
),
blending: THREE.AdditiveBlending,
transparent: true
});
for (var t = 0; t < particleCount; t++) {
var angle3 = Math.random() * Math.PI * 2;
var radius3 = Math.random() * 350 + 1;
var pX1 = Math.cos(angle3) * radius3,
pY1 = Math.random() * 70 - 35,
pZ1 = Math.sin(angle3) * radius3,
skparticle11 = new THREE.Vector3(pX1, pY1, pZ1);
particles.vertices.push(skparticle11);
}
var particleSystem = new THREE.PointCloud(
particles,
pMaterial);
// add it to the scene
scene.add(particleSystem);
但我只是得到一個磁盤。如何使球體充滿粒子?
您是否需要將粒子均勻分佈? – andars
[在球形體積內採樣均勻分佈的隨機點]可能的重複(http://stackoverflow.com/questions/5408276/sampling-uniformly-distributed-random-points-inside-a-spherical-volume) –
我是現在去讀它 –