Skip to main content

SpecsInteractionModule.CastHit

Class

Hit result returned by SpecsInteractionModule's cast queries.

  • Snapchat: not supported
  • SPECS: fully supported
  • Camera Kit Web: not supported
  • Camera Kit Mobile: not supported
  • SnapchatNot supported — Available on SPECS only
  • SPECSFully supported
  • Camera Kit WebNot supported — Available on SPECS only
  • Camera Kit MobileNot supported — Available on SPECS only

Platform details

  • Snapchat — Not supported — Available on SPECS only.

  • SPECS — Fully supported.

  • Camera Kit Web — Not supported — Available on SPECS only.

  • Camera Kit Mobile — Not supported — Available on SPECS only.

Since Lens Scripting v375

Hit result returned by SpecsInteractionModule's cast queries. See SpecsInteractionModule#rayCast, SpecsInteractionModule#rayCastAll, SpecsInteractionModule#sphereCast, and SpecsInteractionModule#sphereCastAll. For overlap detection, see OverlapProbe.

Index

Example

const ray = interactor.getTargetingRay();
if (ray) {
const queryMask = LayerSet.all();
const rayEnd = ray.origin.add(ray.direction.uniformScale(500));
interaction.rayCast(ray.origin, rayEnd, queryMask, function (hit) {
if (hit && hit.collider) {
print("hit " + hit.collider.getSceneObject().name + " at " + hit.distance + "cm");
}
});
}

Extends

Properties

collider

readonly collider: ColliderComponent

SPECS

The collider that was hit. Null if the collider has been destroyed.

Since

Lens Scripting Version 375


distance

readonly distance: number

SPECS

How far the cast travelled from its start before contact. For a sphere cast this is how far the sphere's center moved, so it can be up to one radius less than the distance to position.

Since

Lens Scripting Version 375


normal

readonly normal: vec3

SPECS

Surface normal on the collider at the point of intersection.

Since

Lens Scripting Version 375


position

readonly position: vec3

SPECS

World-space position at the point of intersection.

Since

Lens Scripting Version 375


t

readonly t: number

SPECS

Interpolant along the cast from start to end, in the range [0, 1].

Since

Lens Scripting Version 375


triangle

readonly triangle: TriangleHit

SPECS

The hit triangle, if it exists. This is set on intersection with mesh-based colliders, and null otherwise.

Since

Lens Scripting Version 375

Methods

getTypeName()

static getTypeName(): TypeName<CastHit>

SPECS

Returns the fully-qualified JavaScript type name for this class (for example, "Component.Camera"). This is a static accessor (no instance required) and returns the same value as the instance getTypeName().

Returns

TypeName<CastHit>

Since

Lens Scripting Version 375

Overrides

ScriptObject.getTypeName


getTypeName()

getTypeName(): string

Returns the name of this object's type.

Returns

string

Inherited from

ScriptObject.getTypeName


isOfType()

isOfType(type): boolean

Returns true if the object matches or derives from the passed in type.

Parameters

ParameterType
typestring

Returns

boolean

Inherited from

ScriptObject.isOfType


isSame()

isSame(other): boolean

Returns true if this object is the same as other. Useful for checking if two references point to the same thing.

Parameters

ParameterType
otherScriptObject

Returns

boolean

Inherited from

ScriptObject.isSame