SpecsInteractionModule.CastHit
ClassHit 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
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
readonlycollider:ColliderComponent
SPECS
The collider that was hit. Null if the collider has been destroyed.
Since
Lens Scripting Version 375
distance
readonlydistance: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
readonlynormal:vec3
SPECS
Surface normal on the collider at the point of intersection.
Since
Lens Scripting Version 375
position
readonlyposition:vec3
SPECS
World-space position at the point of intersection.
Since
Lens Scripting Version 375
t
readonlyt:number
SPECS
Interpolant along the cast from start to end, in the range [0, 1].
Since
Lens Scripting Version 375
triangle
readonlytriangle: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()
staticgetTypeName():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
getTypeName()
getTypeName():
string
Returns the name of this object's type.
Returns
string
Inherited from
isOfType()
isOfType(
type):boolean
Returns true if the object matches or derives from the passed in type.
Parameters
| Parameter | Type |
|---|---|
type | string |
Returns
boolean
Inherited from
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
| Parameter | Type |
|---|---|
other | ScriptObject |
Returns
boolean