Skip to main content

Class: WorldSensingDirector

Defined in: webxr-environment/src/world-sensing-director.ts:84

Constructors

Constructor

new WorldSensingDirector(port: WorldSensingPort, options?: WorldSensingDirectorOptions): WorldSensingDirector;

Defined in: webxr-environment/src/world-sensing-director.ts:99

Parameters

ParameterType
portWorldSensingPort
optionsWorldSensingDirectorOptions

Returns

WorldSensingDirector

Accessors

detection

Get Signature

get detection():
| ResolvedWorldDetection
| null;

Defined in: webxr-environment/src/world-sensing-director.ts:107

What is being detected, or null when nothing was asked for.

Returns

| ResolvedWorldDetection | null

Methods

anchors()

anchors(): readonly WorldAnchor[];

Defined in: webxr-environment/src/world-sensing-director.ts:152

Returns

readonly WorldAnchor[]


createAnchor()

createAnchor(pose: WorldPose): Promise<string | null>;

Defined in: webxr-environment/src/world-sensing-director.ts:213

Ask the runtime to remember a point in the room.

Resolves to the new anchor's id, or null when the host cannot - which is a normal answer, not an error: anchors are refused when tracking is poor, and an app that treats that as a crash is an app that crashes in a dark room.

Parameters

ParameterType
poseWorldPose

Returns

Promise<string | null>


dispose()

dispose(): void;

Defined in: webxr-environment/src/world-sensing-director.ts:268

Returns

void


getSensing()

getSensing(feature: "planes" | "meshes" | "anchors" | "hitTest"): SensingReport;

Defined in: webxr-environment/src/world-sensing-director.ts:244

The last thing the adapter said about a world feature.

Parameters

ParameterType
feature"planes" | "meshes" | "anchors" | "hitTest"

Returns

SensingReport


hits()

hits(sourceId?: string): readonly WorldHit[];

Defined in: webxr-environment/src/world-sensing-director.ts:178

The latest answers for a standing request, or every answer with no id.

Parameters

ParameterType
sourceId?string

Returns

readonly WorldHit[]


meshes()

meshes(): readonly WorldMesh[];

Defined in: webxr-environment/src/world-sensing-director.ts:148

Returns

readonly WorldMesh[]


meshesLabelled()

meshesLabelled(label: string): readonly WorldMesh[];

Defined in: webxr-environment/src/world-sensing-director.ts:172

The same for meshes, and not a nicety: a wall arrives as a detected MESH as often as a plane, so an app looking for one needs both. Having the helper on one side only would also hide that the matching is case-insensitive, and a hand-written === "Wall" returns an empty array with nothing to explain it.

Parameters

ParameterType
labelstring

Returns

readonly WorldMesh[]


onChange()

onChange(listener: WorldChangeListener): () => void;

Defined in: webxr-environment/src/world-sensing-director.ts:256

Subscribe to what appeared, moved and went away. Returns the unsubscribe.

Parameters

ParameterType
listenerWorldChangeListener

Returns

() => void


onSensing()

onSensing(listener: SensingListener): () => void;

Defined in: webxr-environment/src/world-sensing-director.ts:248

Parameters

ParameterType
listenerSensingListener

Returns

() => void


planes()

planes(): readonly WorldPlane[];

Defined in: webxr-environment/src/world-sensing-director.ts:144

Returns

readonly WorldPlane[]


planesLabelled()

planesLabelled(label: string): readonly WorldPlane[];

Defined in: webxr-environment/src/world-sensing-director.ts:160

Planes carrying a label, matched without case. The host's vocabulary, not ours: an unknown label is a string to log, not an error.

Parameters

ParameterType
labelstring

Returns

readonly WorldPlane[]


removeAnchor()

removeAnchor(id: string): void;

Defined in: webxr-environment/src/world-sensing-director.ts:238

Parameters

ParameterType
idstring

Returns

void


setDetection()

setDetection(detection:
| boolean
| WorldDetectionSpec
| null): void;

Defined in: webxr-environment/src/world-sensing-director.ts:118

Ask for detection. true turns everything on, false or null stops.

Turning a feature off drops what was found through it, and the change event says so - an app that spawned content on those planes gets told to clean it up rather than being left holding ids nothing will ever update.

Parameters

ParameterType
detection| boolean | WorldDetectionSpec | null

Returns

void


startHitTest()

startHitTest(request: HitTestRequest): void;

Defined in: webxr-environment/src/world-sensing-director.ts:187

Start a standing hit test. Repeating an id replaces the request, which is what an app aiming from a moving hand wants: one source, not one per frame.

Parameters

ParameterType
requestHitTestRequest

Returns

void


stopHitTest()

stopHitTest(id: string): void;

Defined in: webxr-environment/src/world-sensing-director.ts:198

Parameters

ParameterType
idstring

Returns

void


update()

update(deltaMs: number): void;

Defined in: webxr-environment/src/world-sensing-director.ts:263

Parameters

ParameterType
deltaMsnumber

Returns

void