New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

gl-swept-sphere-triangle

Package Overview
Dependencies
Maintainers
1
Versions
6
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

gl-swept-sphere-triangle

gl swept spehere triangle collision

  • 1.3.0
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
2
decreased by-66.67%
Maintainers
1
Weekly downloads
 
Created
Source

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

Install

npm install gl-swept-sphere-triangle

Example

import { traceSphereTriangle, TraceInfo } from 'gl-swept-sphere-triangle';
var traceInfo = new TraceInfo();
var startPoint = [-10, 0, 0];
var endPoint = [10, 0, 0];
var radius = 0.5;
// Tracing a 0.5 radius sphere moving from X:-10 to X:10
traceInfo.resetTrace(startPoint, endPoint, radius);
// 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!
for(i in sceneTriangles) {
  tri = sceneTriangles[i];
  traceSphereTriangle(tri.verts[0], tri.verts[1], tri.verts[2], traceInfo);
}

if(traceInfo.collision) {
  // This will get the position of the sphere when it collided with the closest triangle
  traceInfo.getTraceEndpoint(endPoint);

  // This is the point on the triangle where the sphere collided.
  traceInfo.intersectPoint;
  // You can use the above two values to generate an appropriate collision response.
}

Development roadmap

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.

FAQs

Package last updated on 08 Apr 2020

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc