Last active
August 2, 2020 22:52
-
-
Save BlueMagnificent/8f789228ead2d16f487ee794dcc4bc03 to your computer and use it in GitHub Desktop.
Javascript 3D Physics Tut 3 Detect Collision
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function detectCollision(){ | |
let dispatcher = physicsWorld.getDispatcher(); | |
let numManifolds = dispatcher.getNumManifolds(); | |
for ( let i = 0; i < numManifolds; i ++ ) { | |
let contactManifold = dispatcher.getManifoldByIndexInternal( i ); | |
let numContacts = contactManifold.getNumContacts(); | |
for ( let j = 0; j < numContacts; j++ ) { | |
let contactPoint = contactManifold.getContactPoint( j ); | |
let distance = contactPoint.getDistance(); | |
console.log({manifoldIndex: i, contactIndex: j, distance: distance}); | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment