CannonCastRay Op

CannonCastRay

cast a ray and test intersection with physics bodies


Cast Ray allows you to pick 3d objects that are defined in your physics world (Ops.Physics.World).

One use case may be a 3D menu, where your buttons are cube meshes with physics cubes (Ops.Physics.Body.PhysicsCube_v2) placed in the same exact location.
With Cast Ray placed in your physics world, you will be able to test when a mouse cursor intersects with one of the cubes, allowing you to use the cube as a button.

When using a Mouse OP with CastRay to pick your physics objects, make sure to directly plug in your Mouse op X/Y into the CastRay op and turn on Normalize in the Mouse OP.


Edit Documentation
Full Name
  • Ops.Extension.CannonJs.CannonCastRay
Visibility
  •  Extension Op - Visible to all users
License
  • MIT
AuthorMaintained by TeamJavascript Libraries


Example Patch CastRay example interactive

Open In Editor

Youtube Video Tutorial

INPUT PORTS


Exec (Trigger)

Trigger in

Screen X (Number)

Position of the ray on the X axis 0.0 is the center of the screen

Screen Y (Number)

Position of the ray on the Y axis 0.0 is the center of the screen

Screen Z (Number)

Position of the ray on the Z axis 0.0 is the center of the screen

Change Cursor (Number:boolean )

OUTPUT PORTS


Next (Trigger)

Trigger out

Has Hit (Number)

if the ray intersects/hits a physics body then 1 is output

Hit X (Number)

Intersection position in world space on the X axis

Hit Y (Number)

Intersection position in world space on the Y axis

Hit Z (Number)

Intersection position in world space on the Z axis

Hit Normal X (Number)

which normal was picked on the object on X axis (-1,0,1)

Hit Normal Y (Number)

which normal was picked on the object on Y axis (-1,0,1)

Hit Normal Z (Number)

which normal was picked on the object on Z axis (-1,0,1)

Result (Object)

object containing all parameter information and some extras, inspect to see which ones are available to parse out

aabb x (Number)
aabb y (Number)
aabb z (Number)
aabb x2 (Number)
aabb y2 (Number)
aabb z2 (Number)
to x (Number)
to y (Number)
to z (Number)
from x (Number)
from y (Number)
from z (Number)
Body x (Number)

location of picked physics body on X axis

Body y (Number)

location of picked physics body on Y axis

Body z (Number)

location of picked physics body on Z axis

Name (String)

name and number of picked object - Name is set in a physics body operator and the number is assigned after it with a ".#" format


Patches using CannonCastRay

  • Examples
  • Public
  • My Patches

Changelog


created opuser avatarpandur - 2019-02-12 05:59
Ops.Exp.Gl.Physics.CastRay renamed to Ops.Physics.CastRayuser avatarpandur - 2020-07-30 09:17
Ops.Physics.CastRay renamed to Ops.Physics.Cannon.CannonCastRayuser avatarpandur - 2022-06-07 09:12
Ops.Physics.Cannon.CannonCastRay renamed to Ops.Deprecated.Physics.Cannon.CannonCastRayuser avatarpandur - 2022-12-14 09:47