Skip to content

This is a simple raycasting algorithm that is designed to work with Liabru's JavaScript based rigid body physics engine, MatterJS.

Notifications You must be signed in to change notification settings

Technostalgic/MatterJS_Raycast

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

9 Commits
 
 
 
 
 
 
 
 

Repository files navigation

MatterJS_Raycast

This is a simple raycasting algorithm that is designed to work with liabru's JavaScript based rigid body physics engine, matter.js.

Purpose

I created this algorithm because the current build of matter.js has raycasting, but the raycast doesn't return any collision points, only the bodies that it collides with. With this algorithm, I get the list of collided bodies and then test against each edge on the body for an intersection point and some other stuff to get more detailed information about the collision.

ray collision data

  • body - the body that the ray has collided with (Matter.Body object)
  • point - the ray's intersection point (2D Vector)
  • normal - the edge collision normal (2D Vector)
  • verts - the start and end points of the collided edge ( [2D Vector, 2D Vector] )

matter.js: https://github.com/liabru/matter-js/
matter.js website: http://brm.io/matter-js/

About

This is a simple raycasting algorithm that is designed to work with Liabru's JavaScript based rigid body physics engine, MatterJS.

Resources

Stars

Watchers

Forks

Packages

No packages published