我目前正在 P5.js 中編寫 boids 算法的 3D 實現,但我無法根據 boids 的方向(速度)來確定 boids 的方向。旋轉僅限于 RotateX()、RotateY() 和 RotateZ()。我認為應該有效的最簡單的解決方案是這樣的:push();translate(this.pos);?rotateZ(createVector(this.vel.x, this.vel.y).heading());rotateY(createVector(this.vel.x, this.vel.z).heading());beginShape();// Draw Boid Vertices..endShape();pop();但事實并非如此。我編寫了一個小得多的程序版本,其中僅包含隨機生成的沿單一方向運動的粒子的方向。非常感謝,我已經被這個問題困擾了半天了
在 p5js 中使用速度和位置向量進行 3D 定向粒子
米脂
2023-11-12 22:12:49