Skip to main content

SpecsInteractionModule.OverlapProbe

Class

An edge-triggered overlap probe.

  • 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

An edge-triggered overlap probe. Follows a SceneObject and reports, at most once per frame, the colliders that entered or left a volume around it, via OverlapProbe#onOverlapEnter and OverlapProbe#onOverlapExit. The volume's shape is fixed at creation: a SpecsInteractionModule.SphereOverlapProbe (see SpecsInteractionModule#createSphereOverlapProbe) or a SpecsInteractionModule.BoxOverlapProbe (see SpecsInteractionModule#createBoxOverlapProbe).

The enter and exit volumes give hysteresis: a collider enters when it intersects the enter volume and leaves when it exits the exit volume, which is at least as large. If the two are the same size there is no hysteresis, so a collider enters and leaves at the same boundary. A collider from another Lens is never reported, even while it overlaps the volume.

The probe runs for as long as you hold a reference to it, so store it somewhere that outlives the frame. Dropping your last reference collects the probe together with its handlers, so it stops without a final OverlapProbe#onOverlapExit — nothing is left to receive one. Call OverlapProbe#destroy on a probe you still hold to stop it and get that last exit batch. Destroying its SceneObject also stops the probe and delivers that final batch, with no OverlapProbe#destroy call needed.

Index

Example

const queryMask = LayerSet.all();
const probe = interaction.createSphereOverlapProbe(script.getSceneObject(), 5, 6, queryMask);
probe.onOverlapEnter.add(function (args) {
print(args.enteredOverlaps.length + " entered");
});
// when done: probe.destroy();

Extends

Extended by

Properties

onOverlapEnter

readonly onOverlapEnter: event1<OverlapEnterEventArgs, void>

SPECS

Signals at most once per frame with the colliders that entered the probe's enter volume that frame, delivered as the OverlapEnterEventArgs#enteredOverlaps batch. When a frame has both enters and exits, onOverlapEnter fires before OverlapProbe#onOverlapExit. Delivered after Update, prior to LateUpdate.

Since

Lens Scripting Version 375


onOverlapExit

readonly onOverlapExit: event1<OverlapExitEventArgs, void>

SPECS

Signals at most once per frame with the colliders that left the probe's exit volume that frame, whose collider was removed while a member, or that were still inside when the probe itself was removed, delivered as the OverlapExitEventArgs#exitedOverlaps batch. Delivered after Update, prior to LateUpdate.

Since

Lens Scripting Version 375


queryMask

readonly queryMask: LayerSet

SPECS

The layers this probe matches against. A collider joins only when its Interactable's layerMask shares a layer with this set. Only layers 0-63 are supported, so this reads back without any layers above that range the probe was created with.

Since

Lens Scripting Version 375

Methods

destroy()

destroy(): void

SPECS

Stops the probe and drops it from active tracking. Any colliders still inside fire one final OverlapProbe#onOverlapExit shortly after. No further events follow. Idempotent.

Returns

void

Since

Lens Scripting Version 375


getTypeName()

static getTypeName(): TypeName<OverlapProbe>

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<OverlapProbe>

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