ReadonlyactiveThe interactors currently available. Use this to handle interactors that already exist when your
script starts, then subscribe to SpecsInteractionModule#onInteractorAdded for later
arrivals. Read this and subscribe in the same synchronous block so an interactor that connects in
between is not missed. Each entry provides getTargetingRay, getCursor, and the lock APIs while
it is live.
The name of the Asset in Lens Studio.
ReadonlyonFires when an interactor becomes available (a hand starts tracking, a controller connects). Only future arrivals are delivered. Interactors already present when you subscribe are not replayed. To handle those, read SpecsInteractionModule#activeInteractors once before subscribing.
The handler receives the SpecsInteractionModule.Interactor. Retain it to read and control that interactor while it is live.
ReadonlyonFires when an interactor is removed: it disconnects, or interaction is disabled for it. This
is not the same as losing tracking
(a hand going out of view, for example), which only flips
SpecsInteractionModule.Interactor#isTracked and does not fire this event. The delivered
SpecsInteractionModule.Interactor has isValid === false; use it only to identify which
interactor was removed and tear down any state keyed on its id.
ReadonlyuniqueCreates an edge-triggered box overlap probe that follows sceneObject, tracking its world
position and rotation (uniform scale only). The probe reports colliders entering
or leaving the oriented box through its onOverlapEnter and onOverlapExit events, each fired
at most once per frame with a batch of that frame's changes. Subscribe immediately after
creating the probe, since colliders that enter before you subscribe are not replayed.
enterHalfExtents/exitHalfExtents (cm) give per-axis hysteresis. A collider enters at
enterHalfExtents and leaves at exitHalfExtents, which should be >= enterHalfExtents per
axis. Equal values disable hysteresis.
queryMask matches colliders whose layerMask shares a layer with it; pass
LayerSet.all() to match every supported layer. Only layers 0-63 are supported.
options (SpecsInteractionModule.OverlapProbeOptions, optional) configures the probe,
e.g. per-member distance tracking via trackDistances.
Store the returned probe: it runs only while you hold a reference to it, and dropping your
last one collects the probe along with its handlers. Call its destroy() to stop a probe you
still hold and get a final OverlapProbe#onOverlapExit for whatever is inside.
Optionaloptions: OverlapProbeOptionsCreates an edge-triggered sphere overlap probe that follows sceneObject, tracking its world
position. The probe reports colliders entering or leaving the sphere through its
onOverlapEnter and onOverlapExit events, each fired at most once per frame with a batch of
that frame's changes. Subscribe immediately after creating the probe, since colliders that
enter before you subscribe are not replayed.
enterRadius/exitRadius (cm) give hysteresis. A collider enters at enterRadius and leaves
at exitRadius, which should be >= enterRadius. Equal values disable hysteresis.
queryMask matches colliders whose layerMask shares a layer with it; pass
LayerSet.all() to match every supported layer. Only layers 0-63 are supported.
options (SpecsInteractionModule.OverlapProbeOptions, optional) configures the probe,
e.g. per-member distance tracking via trackDistances.
Store the returned probe: it runs only while you hold a reference to it, and dropping your
last one collects the probe along with its handlers. Call its destroy() to stop a probe you
still hold and get a final OverlapProbe#onOverlapExit for whatever is inside.
Optionaloptions: OverlapProbeOptionsStaticgetReturns the name of this object's type.
Returns true if the object matches or derives from the passed in type.
Returns true if this object is the same as other. Useful for checking if two references point to the same thing.
Returns (via callback) the nearest intersection across all registered colliders
whose layerMask shares a layer with queryMask.
Pass LayerSet.all() to match every supported layer. Only layers 0-63 are supported.
start and end are in world space, in centimeters.
A hit on an Interactable with SpecsInteractionModule.TargetingPriority.High wins
over a nearer Normal-priority hit; within the same priority, the nearest hit wins.
If there is no hit, the callback is called with a null hit argument.
Ray casts are performed after Update, prior to LateUpdate.
A cast can be blocked by a collider from another Lens, which is not returned as a hit.
Returns (via callback) all intersections across all registered colliders
whose layerMask shares a layer with queryMask.
Pass LayerSet.all() to match every supported layer. Only layers 0-63 are supported.
start and end are in world space, in centimeters.
The callback receives an array of hits ordered by targeting priority first
(Interactables with SpecsInteractionModule.TargetingPriority.High before
Normal-priority ones), then by distance, nearest to farthest, within each priority.
If there were no hits, the array length is 0.
Ray casts are performed after Update, prior to LateUpdate.
A cast can be blocked by a collider from another Lens, which is not returned as a hit.
Registers a SceneObject with a set of ColliderComponents as an Interactable. The colliders become interaction targets: they are targetable by interactors (driving the cursor per the options' targetingMode and targetingVisual) and are hit by SpecsInteractionModule's casts and overlap probes.
Colliders do not have to be on interactableSceneObject. Each is hit-tested where it sits in the
world, following its own SceneObject rather than interactableSceneObject. Disabling
interactableSceneObject suspends hit-testing for all of its colliders, re-enabling resumes, and
destroying it drops the registration. An individual collider that is disabled or destroyed drops out
of hit-testing while the registration lives on, and re-enabling it restores it.
Registering again for the same SceneObject replaces the previous registration, so call this whenever the colliders or options change.
options (SpecsInteractionModule.InteractableOptions, optional) configures the
Interactable, e.g. its targetingMode or layerMask; omitting it uses the defaults.
Optionaloptions: InteractableOptionsRegisters a SceneObject as an InteractionPlane, a zone that triggers near-field targeting logic for hand interactors. Add one to dense 2D UI, such as a menu of closely packed buttons, to stabilize targeting between neighbors. The options size its interaction zones and set the targeting visual shown while an interactor targets it.
Registering again for the same SceneObject replaces the previous registration, so call this whenever the options change.
Returns (via callback) the nearest intersection while sweeping a sphere from start to end across all registered
colliders whose layerMask shares a layer with queryMask.
Pass LayerSet.all() to match every supported layer. Only layers 0-63 are supported.
radius is in centimeters; start and end are in world space, in centimeters.
A hit on an Interactable with SpecsInteractionModule.TargetingPriority.High wins
over a nearer Normal-priority hit; within the same priority, the nearest hit wins.
If there is no hit, the callback is called with a null hit argument. Sphere casts are
performed after Update, prior to LateUpdate.
A cast can be blocked by a collider from another Lens, which is not returned as a hit.
Returns (via callback) all intersections while sweeping a sphere from start to end across all registered
colliders whose layerMask shares a layer with queryMask.
Pass LayerSet.all() to match every supported layer. Only layers 0-63 are supported.
radius is in centimeters; start and end are in world space, in centimeters.
The callback receives an array of hits ordered by targeting priority first
(Interactables with SpecsInteractionModule.TargetingPriority.High before
Normal-priority ones), then by distance, nearest to farthest, within each priority.
If there were no hits, the array length is 0. Sphere casts are performed after Update,
prior to LateUpdate.
A cast can be blocked by a collider from another Lens, which is not returned as a hit.
Unregisters an Interactable. Its colliders are no longer targetable by interactors or hit by SpecsInteractionModule's casts and overlap probes.
Unregisters an InteractionPlane, removing its near-field targeting zone from SpecsInteractionModule.
Entry point for the SPECS Interaction System.
Register a SceneObject as an Interactable to add its colliders to the interaction scene, or as an InteractionPlane to define a zone that triggers near-field targeting logic. Registered Interactable colliders drive the system's spatial queries and cursor positioning. Run ray casts, sphere casts, and overlap probes against those colliders. Read activeInteractors for the interactors present now, subscribe to onInteractorAdded and onInteractorRemoved for later changes, and read each interactor's targeting ray. The cursor is rendered for you: use the Interactor to set its visual state, lock it to a position or plane, hide it, or lock its field while an interaction is in progress.
Since
Lens Scripting Version 375
Snap OS
Example