这颗精灵的粒子云应该位于x轴的右侧和y轴的上方。然而,正如你在fiddle所看到的那样,它神秘地悬挂在y轴下方,尽管我编辑和重新排列,但无法弄清楚这里发生了什么。我很欣赏一双新鲜的眼睛来帮助我。谢谢!
Here是我在椭圆云中数学的基础。
function pointInEllipticalCloud(radiusA, radiusB, pZ) {
var pX = Math.random() * (radiusA * 2);
var rightBisector = Math.abs( radiusA - pX );
var chord = (2 * radiusB) * Math.sqrt(1 - Math.pow((rightBisector / radiusA), 2));
var pY = (Math.random() * chord) + ((radiusB - chord) / 2);
return new THREE.Vector3(pX, pY, pZ);
}
var pZ = 1;
var particleGroup = new THREE.Object3D();
for( var i = 0; i < 300; i++ ) {
var radiusA = 200;
var radiusB = 50;
var particle = new THREE.Sprite( spriteMaterial );
particle.scale.set( 20, 20, 1 );
var spritePoint = pointInEllipticalCloud(radiusA, radiusB, pZ);
// *** Why the resulting form hanging below the y axis?
particle.position = spritePoint ;
particleGroup.add( particle );
pZ += 0.1;
}
particleGroup.position.set(0,0,0);
scene.add( particleGroup );
答案 0 :(得分:0)
啊!找到了。该错误是pointInEllipticalCloud()
计算的一部分。 pY
应该等于:
var pY = (Math.random() * chord) + (((radiusB * 2) - chord) / 2);
...其中radiusB
乘以2使其成为椭圆的垂直直径。