LS.Physics Class
Physics is in charge of all physics testing methods Right now is mostly used for testing collisions with rays agains the colliders in the scene
Constructor
LS.Physics
()
Item Index
Methods
Methods
raycast
-
origin -
direction -
options
Cast a ray that traverses the scene checking for collisions with Colliders
Parameters:
-
originVec3in world space
-
directionVec3in world space
-
optionsObject( max_dist maxium distance, layers which layers to check, scene, first_collision )
Returns:
Array of Collision objects containing all the nodes that collided with the ray or null in the form [SceneNode, Collider, collision point, distance]
raycastRenderInstances
-
origin -
direction -
options
Cast a ray that traverses the scene checking for collisions with RenderInstances instead of colliders Similar to Physics.raycast but using the RenderInstances (if options.triangle_collision it builds Octrees for the RIs whose OOBB collides with the ray)
Parameters:
-
originVec3in world space
-
directionVec3in world space
-
optionsObject( triangle_collision: true if you want to test against triangles, max_distance: maxium ray distance, layers, scene, max_distance, first_collision : returns the first collision (which could be not the closest one) )
Returns:
array containing all the RenderInstances that collided with the ray in the form [SceneNode, RenderInstance, collision point, distance]
testSphere
-
origin -
radius -
options
Test if a sphere collides with any of the colliders in the scene
Parameters:
-
originVec3in world space
-
radiusRadius -
optionsObjectlayers, colliders, scene
Returns:
the first PhysicsObject that collided with, otherwise null
