Skip to main content

Interface: Simulator

Defined in: src/simulator/Simulator.ts:46

Extends​

Properties​

controls​

controls: SimulatorControls

Defined in: src/simulator/Simulator.ts:76


depth​

depth: SimulatorDepth

Defined in: src/simulator/Simulator.ts:67


editorIcon​

editorIcon: string = 'simulation'

Defined in: src/simulator/Simulator.ts:59


hands​

hands: SimulatorHands

Defined in: src/simulator/Simulator.ts:70


isXRScript​

isXRScript: boolean = true

Defined in: src/core/Script.ts:99

Inherited from​

Script.isXRScript


mainCamera​

mainCamera: Camera

Defined in: src/simulator/Simulator.ts:89


mainScene​

mainScene: Scene

Defined in: src/simulator/Simulator.ts:90


objects​

objects: SimulatorObjects

Defined in: src/simulator/Simulator.ts:64


options​

options: SimulatorOptions

Defined in: src/simulator/Simulator.ts:88


renderDepthPass​

renderDepthPass: boolean = false

Defined in: src/simulator/Simulator.ts:83


renderer?​

optional renderer: WebGLOrWebGPURenderer

Defined in: src/simulator/Simulator.ts:104


renderMode​

renderMode: SimulatorRenderMode = SimulatorRenderMode.DEFAULT

Defined in: src/simulator/Simulator.ts:84


simulatorCamera?​

optional simulatorCamera: SimulatorCamera

Defined in: src/simulator/Simulator.ts:87


simulatorControllerState​

simulatorControllerState: SimulatorControllerState

Defined in: src/simulator/Simulator.ts:69


simulatorScene​

simulatorScene: SimulatorScene

Defined in: src/simulator/Simulator.ts:60


simulatorUser​

simulatorUser: SimulatorUser

Defined in: src/simulator/Simulator.ts:74


simulatorWorld​

simulatorWorld: SimulatorWorld

Defined in: src/simulator/Simulator.ts:61


stereoCameras​

stereoCameras: Camera[] = []

Defined in: src/simulator/Simulator.ts:85


userInterface​

userInterface: SimulatorInterface

Defined in: src/simulator/Simulator.ts:75


xb?​

optional xb: XBObjectOptions

Defined in: src/interaction/InteractionTypes.ts:34

Inherited from​

Script.xb

Accessors​

activeEnvironment​

Get Signature​

get activeEnvironment(): SimulatorEnvironment | undefined

Defined in: src/simulator/Simulator.ts:293

Returns​

SimulatorEnvironment | undefined


activeEnvironmentManifest​

Get Signature​

get activeEnvironmentManifest(): ResolvedSimulatorSceneManifest | undefined

Defined in: src/simulator/Simulator.ts:297

Returns​

ResolvedSimulatorSceneManifest | undefined


dayNightEnabled​

Get Signature​

get dayNightEnabled(): boolean

Defined in: src/simulator/Simulator.ts:338

True when day/night lighting is enabled for the active environment.

Returns​

boolean


userMovementConstrained​

Get Signature​

get userMovementConstrained(): boolean

Defined in: src/simulator/Simulator.ts:111

Returns​

boolean

Methods​

dispose()​

dispose(): void

Defined in: src/simulator/Simulator.ts:363

Called when the script is removed from the scene. Opposite of init.

Returns​

void

Overrides​

Script.dispose


findRandomUserPath()​

findRandomUserPath(): SimulatorUserPath | null

Defined in: src/simulator/Simulator.ts:119

Returns​

SimulatorUserPath | null


getLocations()​

getLocations(): SimulatorLocations

Defined in: src/simulator/Simulator.ts:302

Returns the named world-space locations for the active environment.

Returns​

SimulatorLocations


getRenderCamera()​

getRenderCamera(): Camera

Defined in: src/simulator/Simulator.ts:445

Returns​

Camera


init()​

init(__namedParameters): Promise<void>

Defined in: src/simulator/Simulator.ts:123

Initializes an instance with XR controllers, grips, hands, and default options. We allow all scripts to quickly access its user (e.g., user.isSelecting(), user.hands), world (e.g., physical depth mesh, lighting estimation, and recognized objects), and scene (the root of three.js's scene graph). If this returns a promise, we will wait for it.

Parameters​

__namedParameters​
camera​

Camera

depth​

Depth

input​

Input

interaction​

Interaction

options​

Options

registry​

Registry

scene​

Scene

simulatorOptions​

SimulatorOptions

timer​

Timer

world​

World

Returns​

Promise<void>

Overrides​

Script.init


initPhysics()​

initPhysics(_physics): void | Promise<void>

Defined in: src/core/Script.ts:118

Enables depth-aware interactions with physics. See /samples/advanced/ballpit

Parameters​

_physics​

Physics

Returns​

void | Promise<void>

Inherited from​

Script.initPhysics


moveUser()​

moveUser(desiredCameraPosition): void

Defined in: src/simulator/Simulator.ts:115

Parameters​

desiredCameraPosition​

Vector3

Returns​

void


onHoverEnter()​

onHoverEnter(_event): void

Defined in: src/core/Script.ts:215

Called when a source starts hovering over this object.

Parameters​

_event​

HoverEvent

The hover source, target, surface, and intersection. Call event.stopPropagation() to stop bubbling to ancestor Scripts.

Returns​

void

Inherited from​

Script.onHoverEnter


onHoverExit()​

onHoverExit(_event): void

Defined in: src/core/Script.ts:221

Called when a source stops hovering over this object.

Parameters​

_event​

HoverEvent

The hover source, target, surface, and intersection. Call event.stopPropagation() to stop bubbling to ancestor Scripts.

Returns​

void

Inherited from​

Script.onHoverExit


onHovering()​

onHovering(_event): void

Defined in: src/core/Script.ts:227

Called while a source hovers over this object.

Parameters​

_event​

HoverEvent

The hover source, target, surface, and intersection. Call event.stopPropagation() to stop bubbling to ancestor Scripts.

Returns​

void

Inherited from​

Script.onHovering


onKeyDown()​

onKeyDown(_event): void

Defined in: src/core/Script.ts:158

Called on keyboard keypress.

Parameters​

_event​

KeyEvent

Event containing .code to read the keyboard key.

Returns​

void

Inherited from​

Script.onKeyDown


onKeyUp()​

onKeyUp(_event): void

Defined in: src/core/Script.ts:159

Parameters​

_event​

KeyEvent

Returns​

void

Inherited from​

Script.onKeyUp


onLongSelect()​

onLongSelect(_event): void

Defined in: src/core/Script.ts:152

Called when an object selection reaches the long-select delay.

Parameters​

_event​

LongSelectEvent

Returns​

void

Inherited from​

Script.onLongSelect


onObjectGrabbing()​

onObjectGrabbing(_event): void

Defined in: src/core/Script.ts:253

Called every frame a hand is grabbing this object.

Parameters​

_event​

ObjectGrabEvent

Returns​

void

Inherited from​

Script.onObjectGrabbing


onObjectGrabEnd()​

onObjectGrabEnd(_event): void

Defined in: src/core/Script.ts:258

Called when a hand stops grabbing this object. This ends built-in direct-touch manipulation without ending contact.

Parameters​

_event​

ObjectGrabEvent

Returns​

void

Inherited from​

Script.onObjectGrabEnd


onObjectGrabStart()​

onObjectGrabStart(_event): void

Defined in: src/core/Script.ts:249

Called when a hand starts grabbing this object (touching + pinching). A grab starts built-in direct-touch manipulation when enabled.

Parameters​

_event​

ObjectGrabEvent

Returns​

void

Inherited from​

Script.onObjectGrabStart


onObjectLongSelect()​

onObjectLongSelect(_event): void

Defined in: src/core/Script.ts:203

Called once when a captured selection is held for the long-select delay. Manipulation captures do not emit this callback.

Parameters​

_event​

LongSelectEvent

The controller and completed hold duration. Call event.stopPropagation() to stop bubbling to ancestor Scripts.

Returns​

void

Inherited from​

Script.onObjectLongSelect


onObjectManipulate()​

onObjectManipulate(_event): void

Defined in: src/core/Script.ts:209

Called for each phase of an automatic object manipulation. Call event.stopPropagation() to stop bubbling. Calling preventDefault() on a start event suppresses the automatic action.

Parameters​

_event​

ManipulationEvent

Returns​

void

Inherited from​

Script.onObjectManipulate


onObjectSelectEnd()​

onObjectSelectEnd(_event): void

Defined in: src/core/Script.ts:196

Called when a source stops selecting the object this Script represents.

Parameters​

_event​

SelectEndEvent

The completed state and end reason. Call event.stopPropagation() to stop bubbling to ancestor Scripts.

Returns​

void

Inherited from​

Script.onObjectSelectEnd


onObjectSelectStart()​

onObjectSelectStart(_event): void

Defined in: src/core/Script.ts:190

Called when a source starts selecting the object this Script represents.

Parameters​

_event​

SelectEvent

event.target is the logical object and event.source.controller identifies the controller. Call event.stopPropagation() to stop bubbling to ancestor Scripts.

Returns​

void

Inherited from​

Script.onObjectSelectStart


onObjectTouchEnd()​

onObjectTouchEnd(_event): void

Defined in: src/core/Script.ts:244

Called when a hand's index finger stops touching this object. This ends the default selection lifecycle after the touch callback.

Parameters​

_event​

ObjectTouchEvent

Returns​

void

Inherited from​

Script.onObjectTouchEnd


onObjectTouching()​

onObjectTouching(_event): void

Defined in: src/core/Script.ts:239

Called every frame that a hand's index finger is touching this object. The object remains selected during these frames unless touch selection was prevented when contact started.

Parameters​

_event​

ObjectTouchEvent

Returns​

void

Inherited from​

Script.onObjectTouching


onObjectTouchStart()​

onObjectTouchStart(_event): void

Defined in: src/core/Script.ts:233

Called when a hand's index finger starts touching this object. Direct touch starts the object's selection lifecycle by default. Call event.preventDefault() to handle contact without selecting.

Parameters​

_event​

ObjectTouchStartEvent

Returns​

void

Inherited from​

Script.onObjectTouchStart


onSelect()​

onSelect(_event): void

Defined in: src/core/Script.ts:144

Called whenever pinch / mouse click successfully completes, globally.

Parameters​

_event​

SelectEvent

The interaction source and completed target.

Returns​

void

Inherited from​

Script.onSelect


onSelectEnd()​

onSelectEnd(_event): void

Defined in: src/core/Script.ts:138

Called whenever pinch / mouse click discontinues, globally.

Parameters​

_event​

SelectEndEvent

The completed state and end reason.

Returns​

void

Inherited from​

Script.onSelectEnd


onSelecting()​

onSelecting(_event): void

Defined in: src/core/Script.ts:149

Called whenever pinch / mouse click is happening, globally.

Parameters​

_event​

SelectEvent

Returns​

void

Inherited from​

Script.onSelecting


onSelectStart()​

onSelectStart(_event): void

Defined in: src/core/Script.ts:132

Called whenever pinch / mouse click starts, globally.

Parameters​

_event​

SelectEvent

The interaction source and optional captured target.

Returns​

void

Inherited from​

Script.onSelectStart


onSimulatorStarted()​

onSimulatorStarted(): void

Defined in: src/core/Script.ts:124

Returns​

void

Inherited from​

Script.onSimulatorStarted


onSqueeze()​

onSqueeze(_event): void

Defined in: src/core/Script.ts:181

Called whenever gamepad trigger successfully completes, globally.

Parameters​

_event​

SelectEvent

event.source.controller identifies the controller.

Returns​

void

Inherited from​

Script.onSqueeze


onSqueezeEnd()​

onSqueezeEnd(_event): void

Defined in: src/core/Script.ts:170

Called whenever gamepad trigger stops, globally.

Parameters​

_event​

SelectEvent

event.source.controller identifies the controller.

Returns​

void

Inherited from​

Script.onSqueezeEnd


onSqueezeStart()​

onSqueezeStart(_event): void

Defined in: src/core/Script.ts:165

Called whenever gamepad trigger starts, globally.

Parameters​

_event​

SelectEvent

event.source.controller identifies the controller.

Returns​

void

Inherited from​

Script.onSqueezeStart


onSqueezing()​

onSqueezing(_event): void

Defined in: src/core/Script.ts:175

Called whenever gamepad is being triggered, globally.

Parameters​

_event​

SelectEvent

Returns​

void

Inherited from​

Script.onSqueezing


onXRSessionEnded()​

onXRSessionEnded(): void

Defined in: src/simulator/Simulator.ts:355

Returns​

void

Overrides​

Script.onXRSessionEnded


onXRSessionStarted()​

onXRSessionStarted(): void

Defined in: src/simulator/Simulator.ts:347

Returns​

void

Overrides​

Script.onXRSessionStarted


physicsStep()​

physicsStep(): void

Defined in: src/simulator/Simulator.ts:342

Returns​

void

Overrides​

Script.physicsStep


preloadDayNight()​

preloadDayNight(): Promise<void>

Defined in: src/simulator/Simulator.ts:322

Fetches the active environment's night bake ahead of first use so the day/night lighting can start without a visible delay. No-op when the active environment declares no day/night lighting.

Returns​

Promise<void>


renderFrame()​

renderFrame(): void

Defined in: src/simulator/Simulator.ts:457

Renders one complete simulator frame (physical environment + virtual scene) to the default framebuffer. Called by Core when the simulator is running.

Returns​

void


setDayNightEnabled()​

setDayNightEnabled(enabled): Promise<void>

Defined in: src/simulator/Simulator.ts:332

Enables or disables day/night lighting for the active environment. The DayNightCycle chunk and the night bake are only fetched on first enable, never at environment load. No-op when the active environment declares no day/night lighting.

Parameters​

enabled​

boolean

Returns​

Promise<void>


setEnvironment()​

Call Signature​

setEnvironment(manifestPath): Promise<void>

Defined in: src/simulator/Simulator.ts:269

Loads and activates a simulator environment at runtime.

Parameters​
manifestPath​

string

Returns​

Promise<void>

Call Signature​

setEnvironment(name, manifestPath): Promise<void>

Defined in: src/simulator/Simulator.ts:270

Loads and activates a simulator environment at runtime.

Parameters​
name​

string

manifestPath​

string

Returns​

Promise<void>


setStereoRenderMode()​

setStereoRenderMode(mode): void

Defined in: src/simulator/Simulator.ts:421

Parameters​

mode​

SimulatorRenderMode

Returns​

void


setTimeOfDay()​

setTimeOfDay(t): Promise<void>

Defined in: src/simulator/Simulator.ts:312

Sets the time of day for the active environment's day/night lighting (0 = day endpoint, 1 = night endpoint). Initializes the lighting lazily on first use. No-op when the active environment declares no day/night lighting.

Parameters​

t​

number

Returns​

Promise<void>


setupStereoCameras()​

setupStereoCameras(camera): void

Defined in: src/simulator/Simulator.ts:426

Parameters​

camera​

Camera

Returns​

void


simulatorUpdate()​

simulatorUpdate(): void

Defined in: src/simulator/Simulator.ts:412

Returns​

void


update()​

update(_time?, _frame?): void

Defined in: src/core/Script.ts:113

Runs per frame.

Parameters​

_time?​

number

_frame?​

XRFrame

Returns​

void

Inherited from​

Script.update