0
votes

I have a particle system using sprites which is an Object3D similar to the "interactive / points" example from three.js and a basic sphere mesh which follows my cursor.

https://threejs.org/examples/?q=point#webgl_interactive_points

mesh intersection

What's the best way to determine when two of these objects intersect? I want to be able to push the particles with the sphere, but first I need an array of the points which are "inside the sphere". Thanks!

1
I know there's isPointInPath for 2d canvas. Not finding something similar for 3d, but just wanted to share.Raphael Rafatpanah
Sphere has center and radius, you can check the condidtion if the distance from a point to the sphere's center is less than sphere's radius, then the point is inside the sphere.prisoner849

1 Answers

1
votes

To know if a point is inside or outside the sphere, you can cast a ray from the point in a given direction. Then count the ray intesection with the sphere geometry's triangles. If the count is odd, the point is inside, else it's outside.

Some demo showing particles injection into a mesh is available here (same principle) https://github.com/heroncendre/Volpar