Class: World
Defined in: src/world/World.ts:20
Manages all interactions with the real-world environment perceived by the XR
device. This class abstracts the complexity of various perception APIs
(Depth, Planes, Meshes, etc.) and provides a simple, event-driven interface
for developers to use this.world.depth.mesh
, this.world.planes
.
Extends
Constructors
Constructor
new World():
World
Defined in: node_modules/@types/three/src/core/Object3D.d.ts:95
This creates a new Object3D object.
Returns
World
Inherited from
Properties
isXRScript
isXRScript:
boolean
=true
Defined in: src/core/Script.ts:53
Inherited from
objects?
optional
objects:ObjectDetector
Defined in: src/world/World.ts:56
The object recognition module instance. Null if not enabled.
options
options:
WorldOptions
Defined in: src/world/World.ts:29
Configuration options for all world-sensing features.
planes?
optional
planes:PlaneDetector
Defined in: src/world/World.ts:45
The plane detection module instance. Null if not enabled. Not recommended for anchoring.
ux
ux:
UX
Defined in: src/core/Script.ts:52
Inherited from
dependencies
static
dependencies:object
Defined in: src/world/World.ts:21
camera
camera: typeof
Camera
=THREE.Camera
options
options: typeof
WorldOptions
=WorldOptions
Methods
anchorObjectAtReticle()
anchorObjectAtReticle(
_object
,_reticle
):void
Defined in: src/world/World.ts:109
Places an object at the reticle.
Parameters
_object
_reticle
Returns
void
dispose()
dispose():
void
Defined in: src/core/Script.ts:196
Called when the script is removed from the scene. Opposite of init.
Returns
void
Inherited from
init()
init(
__namedParameters
):Promise
<void
>
Defined in: src/world/World.ts:69
Initializes the world-sensing modules based on the provided configuration. This method is called automatically by the XRCore.
Parameters
__namedParameters
camera
options
Returns
Promise
<void
>
Overrides
initPhysics()
initPhysics(
_physics
):void
|Promise
<void
>
Defined in: src/core/Script.ts:72
Enables depth-aware interactions with physics. See /demos/ballpit
Parameters
_physics
Returns
void
| Promise
<void
>
Inherited from
onHoverEnter()
onHoverEnter(
_controller
):void
Defined in: src/core/Script.ts:157
Called when the controller starts hovering over this object with reticle.
Parameters
_controller
An XR controller.
Returns
void
Inherited from
onHoverExit()
onHoverExit(
_controller
):void
Defined in: src/core/Script.ts:162
Called when the controller hovers over this object with reticle.
Parameters
_controller
An XR controller.
Returns
void
Inherited from
onHovering()
onHovering(
_controller
):void
Defined in: src/core/Script.ts:167
Called when the controller hovers over this object with reticle.
Parameters
_controller
An XR controller.
Returns
void
Inherited from
onKeyDown()
onKeyDown(
_event
):void
Defined in: src/core/Script.ts:109
Called on keyboard keypress.
Parameters
_event
Event containing .code
to read the keyboard key.
Returns
void
Inherited from
onKeyUp()
onKeyUp(
_event
):void
Defined in: src/core/Script.ts:110
Parameters
_event
Returns
void
Inherited from
onObjectGrabbing()
onObjectGrabbing(
_event
):void
Defined in: src/core/Script.ts:187
Called every frame a hand is grabbing this object.
Parameters
_event
Returns
void
Inherited from
onObjectGrabEnd()
onObjectGrabEnd(
_event
):void
Defined in: src/core/Script.ts:191
Called when a hand stops grabbing this object.
Parameters
_event
Returns
void
Inherited from
onObjectGrabStart()
onObjectGrabStart(
_event
):void
Defined in: src/core/Script.ts:183
Called when a hand starts grabbing this object (touching + pinching).
Parameters
_event
Returns
void
Inherited from
onObjectSelectEnd()
onObjectSelectEnd(
_event
):boolean
Defined in: src/core/Script.ts:150
Called when the controller stops selecting this object the script represents, e.g. View, ModelView.
Parameters
_event
event.target holds its controller.
Returns
boolean
Whether the event was handled
Inherited from
onObjectSelectStart()
onObjectSelectStart(
_event
):boolean
Defined in: src/core/Script.ts:141
Called when the controller starts selecting this object the script represents, e.g. View, ModelView.
Parameters
_event
event.target holds its controller.
Returns
boolean
Whether the event was handled
Inherited from
onObjectTouchEnd()
onObjectTouchEnd(
_event
):void
Defined in: src/core/Script.ts:179
Called when a hand's index finger stops touching this object.
Parameters
_event
Returns
void
Inherited from
onObjectTouching()
onObjectTouching(
_event
):void
Defined in: src/core/Script.ts:175
Called every frame that a hand's index finger is touching this object.
Parameters
_event
Returns
void
Inherited from
onObjectTouchStart()
onObjectTouchStart(
_event
):void
Defined in: src/core/Script.ts:171
Called when a hand's index finger starts touching this object.
Parameters
_event
Returns
void
Inherited from
onSelect()
onSelect(
_event
):void
Defined in: src/core/Script.ts:98
Called whenever pinch / mouse click successfully completes, globally.
Parameters
_event
event.target holds its controller.
Returns
void
Inherited from
onSelectEnd()
onSelectEnd(
_event
):void
Defined in: src/core/Script.ts:92
Called whenever pinch / mouse click discontinues, globally.
Parameters
_event
event.target holds its controller
Returns
void
Inherited from
onSelecting()
onSelecting(
_event
):void
Defined in: src/core/Script.ts:103
Called whenever pinch / mouse click is happening, globally.
Parameters
_event
Returns
void
Inherited from
onSelectStart()
onSelectStart(
_event
):void
Defined in: src/core/Script.ts:86
Called whenever pinch / mouse click starts, globally.
Parameters
_event
event.target holds its controller
Returns
void
Inherited from
onSimulatorStarted()
onSimulatorStarted():
void
Defined in: src/core/Script.ts:78
Returns
void
Inherited from
onSqueeze()
onSqueeze(
_event
):void
Defined in: src/core/Script.ts:132
Called whenever gamepad trigger successfully completes, globally.
Parameters
_event
event.target holds its controller.
Returns
void
Inherited from
onSqueezeEnd()
onSqueezeEnd(
_event
):void
Defined in: src/core/Script.ts:121
Called whenever gamepad trigger stops, globally.
Parameters
_event
event.target holds its controller.
Returns
void
Inherited from
onSqueezeStart()
onSqueezeStart(
_event
):void
Defined in: src/core/Script.ts:116
Called whenever gamepad trigger starts, globally.
Parameters
_event
event.target holds its controller.
Returns
void
Inherited from
onSqueezing()
onSqueezing(
_event
):void
Defined in: src/core/Script.ts:126
Called whenever gamepad is being triggered, globally.
Parameters
_event
Returns
void
Inherited from
onXRSessionEnded()
onXRSessionEnded():
void
Defined in: src/core/Script.ts:76
Returns
void
Inherited from
onXRSessionStarted()
onXRSessionStarted(
_session?
):void
Defined in: src/core/Script.ts:75
Parameters
_session?
Returns
void
Inherited from
physicsStep()
physicsStep():
void
Defined in: src/core/Script.ts:73
Returns
void
Inherited from
placeOnSurface()
placeOnSurface(
objectToPlace
,controller
):boolean
Defined in: src/world/World.ts:151
Performs a raycast from a controller against detected real-world surfaces (currently planes) and places a 3D object at the intersection point, oriented to face the user.
We recommend using /templates/3_depth/ to anchor objects based on depth mesh for mixed reality experience for accuracy. This function is design for demonstration purposes.
Parameters
objectToPlace
The object to position in the world.
controller
The controller to use for raycasting.
Returns
boolean
True if the object was successfully placed, false otherwise.
showDebugVisualizations()
showDebugVisualizations(
visible
):void
Defined in: src/world/World.ts:180
Toggles the visibility of all debug visualizations for world features.
Parameters
visible
boolean
= true
Whether the visualizations should be visible.
Returns
void
update()
update(
_timestamp
,frame?
):void
Defined in: src/world/World.ts:121
Updates all active world-sensing modules with the latest XRFrame data. This method is called automatically by the XRCore on each frame.
Parameters
_timestamp
number
The timestamp for the current frame.
frame?
The current XRFrame, containing environmental data.
Returns
void