Skip to content

@orillusion/core


Class: MeshRaycast ​

Defined in: src/io/raycast/MeshRaycast.ts:54

World-space ray queries against one geometry under a transform. Shared by Raycaster and MeshColliderShape, so both report the same hit data.

Constructors ​

Constructor ​

new MeshRaycast(): MeshRaycast

Returns ​

MeshRaycast

Methods ​

intersect() ​

static intersect(geometry, worldMatrix, ray, options, out): number

Defined in: src/io/raycast/MeshRaycast.ts:67

Intersect ray (world space) with geometry placed by worldMatrix and append the hits to out (closest only unless options.all). Hits are not sorted across calls; the ones added by one call are.

Parameters ​

geometry ​

GeometryBase

worldMatrix ​

Matrix4

ray ​

Ray

options ​

MeshRaycastOptions

out ​

RaycastHit[]

Returns ​

number

number of hits appended


intersectRenderer() ​

static intersectRenderer(renderer, ray, options, out): number

Defined in: src/io/raycast/MeshRaycast.ts:123

Intersect a renderer's mesh as it is drawn. Skinned and morph-target meshes are deformed on the CPU first (see MeshDeformer) unless options.deformation says otherwise; a deformed mesh is always queried through a (refit) BVH unless useBVH is 'never'. For skinned meshes localPoint is the hit expressed in the renderer's local space (the deformed surface, not the bind pose).

Parameters ​

renderer ​

MeshRenderer

ray ​

Ray

options ​

MeshRaycastOptions

out ​

RaycastHit[]

Returns ​

number

number of hits appended


transformNormal() ​

static transformNormal(invMatrix, n, out): Vector3

Defined in: src/io/raycast/MeshRaycast.ts:203

Transform a local-space normal to world space with the inverse transpose of the local → world matrix (normals stay perpendicular under non-uniform scale), then normalize.

Parameters ​

invMatrix ​

Matrix4

inverse of the local → world matrix

n ​

Vector3

local-space normal

out ​

Vector3

result (may alias n)

Returns ​

Vector3

Released under the MIT License