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
raycast
-
origin
-
direction
-
options
Cast a ray that traverses the scene checking for collisions with Colliders
Parameters:
-
origin
Vec3in world space
-
direction
Vec3in world space
-
options
Object( 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:
-
origin
Vec3in world space
-
direction
Vec3in world space
-
options
Object{ instances: array of instances, if not the scene will be used, 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]
raycastRenderInstances
-
origin
-
direction
-
node
-
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:
-
origin
Vec3in world space
-
direction
Vec3in world space
-
node
LS.SceneNode -
options
Object( 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:
-
origin
Vec3in world space
-
radius
Radius -
options
Objectlayers, colliders, scene
Returns:
the first PhysicsObject that collided with, otherwise null