简体   繁体   English

Three.js粒子形成形状

[英]Three.js particles to form a shape

I've been following this tutorial ( http://creativejs.com/tutorials/three-js-part-1-make-a-star-field/ ) and everything is going fine, but I'd like to know how I can modify the script so then there's some form of callback when the particle reaches the end. 我一直在关注本教程( http://creativejs.com/tutorials/three-js-part-1-make-a-star-field/ ),一切都很好,但是我想知道如何可以修改脚本,因此当粒子到达末尾时会有某种形式的回调。 I've modified the code in the tutorial so it's reversed the way the particles are moving. 我已经修改了本教程中的代码,因此颠倒了粒子移动的方式。

What I'm wanting to try and create is a load of particles coming together to form a square, is it possible from using the code in the tutorial as a start and build on top of that or should I look elsewhere and start over? 我想尝试创建的是一堆粒子,它们在一起形成一个正方形,是否可以将本教程中的代码用作起点并以此为基础进行构建,还是应该在其他地方重新开始?

Thanks in advance. 提前致谢。

Wouldn't it be easy if you create the same amount of particles as the model's amount of vertices, and move the particles towards the vertices' position? 如果创建的粒子数量与模型的顶点数量相同,然后将粒子移到顶点位置,会不会很容易?

var p = emitter.geometry.vertices;  // the vertices (particles) of your particle emitter
var m = model.geometry.vertices;    // the vertices of the target model

for(var i in p) {
    p[i].x = (p[i].x + m[i].x) / 2;
    p[i].y = (p[i].y + m[i].y) / 2;
    p[i].z = (p[i].z + m[i].z) / 2;
}

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM