Three.js 中的粒子 ID 和检索多个 ID
我正在尝试使用 Three.js 创建粒子,目前作为粒子系统。 该项目的目标是创建具有定义位置和唯一 ID 的粒子,并添加一个选项来选择多个粒子并检索其 ID。
我做了一些研究,但只找到了检测鼠标单击位置的方法。
所以,我正在寻找以下信息:
第一:是否有一个选项可以将 ID 分配给单个粒子(就像数字一样简单)? 第二:有没有办法选择多个粒子并在(弹出)窗口中查看它们的 ID?
感谢您的帮助!
PS:我发现,您可以将 ID 分配给 THREE.ParticleDOMMaterial (我不知道,这个函数的作用是什么!?)和 THREE.ParticleBasicMaterial (将 ID 分配给材质,但不能分配给粒子本身)。
I am trying to create particles with three.js, currently as a particle system.
The goal of the project is to create particles, with defined positions and unique IDs, and add an option to select multiple particles and retrieve their IDs.
I did some research, but found only ways to detect the position of a mouse-click.
So, I'm looking for the following information:
First: Is there an option to assign IDs to single particles (as simple as a number)?
Second: Is there a way to select multiple particles and view their IDs in a (popup) window?
Thanks for your Help!
PS: I found, that you can assign IDs to THREE.ParticleDOMMaterial (I don't know, what this function does!?) and THREE.ParticleBasicMaterial (Assign an ID to the material, but not to the particle itself).
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
默认情况下,所有
Object3D
实例在 Three.js 中都有一个唯一的 id,并且 Particle 继承了该 ID。另外,Object3D
有一个 name 属性(如果有帮助的话)。下面是一个小片段,说明了粒子的命名:
这是一个鼠标按下事件处理程序的示例,它在控制台中打印所单击粒子的名称和 ID:
祝你好运!
All
Object3D
instances have a unique id in three.js by default and Particle inherits that. AlsoObject3D
has a name property, if that helps.Here's a little snippet which illustrates naming particles:
and here's an example of a mouse down event handler which prints the name and id of the clicked particle in the console:
Goodluck!