[英]Create particles animation with three.js
I am new to three.js, I have created a simple particle app with three.js, but the flow of particles is moving from centre.我是 three.js 的新手,我用 three.js 创建了一个简单的粒子应用程序,但粒子流从中心移动。 I want move particles something like displayed in the attached screenshot (top right corner to bottom left corner).我想移动粒子,例如在附加的屏幕截图中显示的东西(右上角到左下角)。 working code is at https://jseditor.io/?key=ee98d51a9b4111eab74e00224d6bfcd5 .工作代码位于https://jseditor.io/?key=ee98d51a9b4111eab74e00224d6bfcd5 。 any reference will be very helpful.任何参考都会非常有帮助。 Thank you.谢谢你。
Your updateParticles
function is only changing the particles' z position:您的updateParticles
function 仅更改粒子的 z position:
particle.position.z += mouseY * 0.1;
if(particle.position.z>1000) particle.position.z-=2000;
If you want to move them vertically and horizontally, you're going to have to update the x and y positions as well.如果要垂直和水平移动它们,则还必须更新 x 和 y 位置。
particle.position.x -= mouseY * 0.1;
particle.position.y -= mouseY * 0.1;
if(particle.position.x<-500) particle.position.x+=1000;
if(particle.position.y<-500) particle.position.y+=1000;
I don't know the size of your scene, so you might need to adjust the numbers accordingly.我不知道您的场景的大小,因此您可能需要相应地调整数字。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.