Abyss Posted August 23, 2016 Share Posted August 23, 2016 Hi, babylon js developers! Please help me :). I want to detect particle collision with camera elipsoid, and when particle will collide - destroy this particle. Can i make this in particle system update function or how? Babylon js can make this for me? Quote Link to comment Share on other sites More sharing options...
Abyss Posted August 23, 2016 Author Share Posted August 23, 2016 If somebody interested, i found one method. In particle system update function i create BABYLON.path3D() between particle position and camera position, now i can calculate distance between this points, and if distance lower then need, just remove this particle. This method not bad, but in my case, i have to many particles, and performance are very bad. Maybe i should optimize particles, will keep trying. Quote Link to comment Share on other sites More sharing options...
GameMonetize Posted August 25, 2016 Share Posted August 25, 2016 Pinging our physic engine god @RaananW Quote Link to comment Share on other sites More sharing options...
jerome Posted August 25, 2016 Share Posted August 25, 2016 creating a Path3D object for each particle test is a little overkill The fastest way would be, imho, to compute in turn the (squared) distance from each particle to the cam ant to compare it to the wanted (squared) distance. http://doc.babylonjs.com/classes/2.4/Vector3#lengthsquared-rarr-number something like : var limit = 10; // your value var squLimit = limit * limit; var squDist = 0; // current squared distance var vector = BABYLON.Vector3.Zero(); // current particle-cam vector // loop for each particle ... particle.position.subtractToRef(camera.position, vector); squDist = vector.lenghtSquared(); if (squDist < squLimit) { // recylce your particle } Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.