GL Matrix swept sphere triangle collision
This code is is a reproduction of a gist from the creator of gl-matrix. This code implements a ellipsoid space swepth sphere collision detction algoritim from the paper "Improved Collision detection and Response" by Kasper Fauerby
npm install gl-swept-sphere-triangle
;var traceInfo = ;var startPoint = -10 0 0;var endPoint = 10 0 0;var radius = 05;// Tracing a 0.5 radius sphere moving from X:-10 to X:10traceInfo;// You really need to do a good broadphase triangle set reduction (ie: octree)// to reduce the number of triangles you're colliding against. This is not a cheap// test!fori in sceneTrianglestri = sceneTrianglesi;;iftraceInfocollision// This will get the position of the sphere when it collided with the closest triangletraceInfo;// This is the point on the triangle where the sphere collided.traceInfointersectPoint;// You can use the above two values to generate an appropriate collision response.
The original gist uses a really old version of gl-matrix 1.3.8. Later versions of gl-matrix had non-backwards compatible API changes. This has old copy of gl-matrix has been hard coded in the code base. This was to evaluate if the gist code actually worked. Future iterations of this module will work to bring the dependencies up to speed and review potential performance gains.
This module has been updated to a modern version of
gl-matrix future road map will be purely optimization.