Skip to main content

Class: VideoStream<T>

Defined in: src/video/VideoStream.ts:80

The base class for handling video streams (from camera or file), managing the underlying

Extends

Extended by

Type Parameters

T

T extends VideoStreamDetails = VideoStreamDetails

Constructors

Constructor

new VideoStream<T>(options): VideoStream<T>

Defined in: src/video/VideoStream.ts:104

Parameters

options

VideoStreamOptions = {}

The configuration options.

Returns

VideoStream<T>

Overrides

Script.constructor

Properties

aspectRatio?

optional aspectRatio: number

Defined in: src/video/VideoStream.ts:86


height?

optional height: number

Defined in: src/video/VideoStream.ts:85


isXRScript

isXRScript: boolean = true

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

Inherited from

Script.isXRScript


loaded

loaded: boolean = false

Defined in: src/video/VideoStream.ts:83


state

state: StreamState = StreamState.IDLE

Defined in: src/video/VideoStream.ts:88


stream_

protected stream_: null | MediaStream = null

Defined in: src/video/VideoStream.ts:90


texture

texture: Texture

Defined in: src/video/VideoStream.ts:87


ux

ux: UX

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

Inherited from

Script.ux


video_

protected video_: HTMLVideoElement

Defined in: src/video/VideoStream.ts:91


width?

optional width: number

Defined in: src/video/VideoStream.ts:84

Accessors

video

Get Signature

get video(): HTMLVideoElement

Defined in: src/video/VideoStream.ts:92

Returns

HTMLVideoElement

Methods

dispose()

dispose(): void

Defined in: src/video/VideoStream.ts:284

Disposes of all resources used by this stream.

Returns

void

Overrides

Script.dispose


getSnapshot()

Call Signature

getSnapshot(_): ImageData

Defined in: src/video/VideoStream.ts:187

Captures the current video frame.

Parameters
_

VideoStreamGetSnapshotImageDataOptions

Returns

ImageData

The captured data.

Call Signature

getSnapshot(_): Promise<null | string>

Defined in: src/video/VideoStream.ts:188

Captures the current video frame.

Parameters
_

VideoStreamGetSnapshotBase64Options

Returns

Promise<null | string>

The captured data.

Call Signature

getSnapshot(_): Texture

Defined in: src/video/VideoStream.ts:189

Captures the current video frame.

Parameters
_

VideoStreamGetSnapshotTextureOptions

Returns

Texture

The captured data.

Call Signature

getSnapshot(_): Promise<null | Blob>

Defined in: src/video/VideoStream.ts:190

Captures the current video frame.

Parameters
_

VideoStreamGetSnapshotBlobOptions

Returns

Promise<null | Blob>

The captured data.


handleVideoStreamLoadedMetadata()

protected handleVideoStreamLoadedMetadata(resolve, reject, allowRetry): void

Defined in: src/video/VideoStream.ts:153

Processes video metadata, sets dimensions, and resolves a promise.

Parameters

resolve

() => void

The resolve function of the wrapping Promise.

reject

(_) => void

The reject function of the wrapping Promise.

allowRetry

boolean = false

Whether to allow a retry attempt on failure.

Returns

void


init()

init(_?): void | Promise<void>

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

Initializes an instance with XR controllers, grips, hands, raycaster, 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

_?

object

Returns

void | Promise<void>

Inherited from

Script.init


initPhysics()

initPhysics(_physics): void | Promise<void>

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

Enables depth-aware interactions with physics. See /demos/ballpit

Parameters

_physics

Physics

Returns

void | Promise<void>

Inherited from

Script.initPhysics


onHoverEnter()

onHoverEnter(_controller): boolean | void

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

Called when the controller starts hovering over this object with reticle.

Parameters

_controller

Object3D

An XR controller.

Returns

boolean | void

Whether the event was handled. If true, the event will not bubble up.

Inherited from

Script.onHoverEnter


onHoverExit()

onHoverExit(_controller): boolean | void

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

Called when the controller hovers over this object with reticle.

Parameters

_controller

Object3D

An XR controller.

Returns

boolean | void

Whether the event was handled. If true, the event will not bubble up.

Inherited from

Script.onHoverExit


onHovering()

onHovering(_controller): boolean | void

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

Called when the controller hovers over this object with reticle.

Parameters

_controller

Object3D

An XR controller.

Returns

boolean | void

Whether the event was handled. If true, the event will not bubble up.

Inherited from

Script.onHovering


onKeyDown()

onKeyDown(_event): void

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

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:111

Parameters

_event

KeyEvent

Returns

void

Inherited from

Script.onKeyUp


onObjectGrabbing()

onObjectGrabbing(_event): void

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

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:191

Called when a hand stops grabbing this object.

Parameters

_event

ObjectGrabEvent

Returns

void

Inherited from

Script.onObjectGrabEnd


onObjectGrabStart()

onObjectGrabStart(_event): void

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

Called when a hand starts grabbing this object (touching + pinching).

Parameters

_event

ObjectGrabEvent

Returns

void

Inherited from

Script.onObjectGrabStart


onObjectSelectEnd()

onObjectSelectEnd(_event): boolean | void

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

Called when the controller stops selecting this object the script represents, e.g. View, ModelView.

Parameters

_event

SelectEvent

event.target holds its controller.

Returns

boolean | void

Whether the event was handled. If true, the event will not bubble up.

Inherited from

Script.onObjectSelectEnd


onObjectSelectStart()

onObjectSelectStart(_event): boolean | void

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

Called when the controller starts selecting this object the script represents, e.g. View, ModelView.

Parameters

_event

SelectEvent

event.target holds its controller.

Returns

boolean | void

Whether the event was handled. If true, the event will not bubble up.

Inherited from

Script.onObjectSelectStart


onObjectTouchEnd()

onObjectTouchEnd(_event): void

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

Called when a hand's index finger stops touching this object.

Parameters

_event

ObjectTouchEvent

Returns

void

Inherited from

Script.onObjectTouchEnd


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

ObjectTouchEvent

Returns

void

Inherited from

Script.onObjectTouching


onObjectTouchStart()

onObjectTouchStart(_event): void

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

Called when a hand's index finger starts touching this object.

Parameters

_event

ObjectTouchEvent

Returns

void

Inherited from

Script.onObjectTouchStart


onSelect()

onSelect(_event): void

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

Called whenever pinch / mouse click successfully completes, globally.

Parameters

_event

SelectEvent

event.target holds its controller.

Returns

void

Inherited from

Script.onSelect


onSelectEnd()

onSelectEnd(_event): void

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

Called whenever pinch / mouse click discontinues, globally.

Parameters

_event

SelectEvent

event.target holds its controller

Returns

void

Inherited from

Script.onSelectEnd


onSelecting()

onSelecting(_event): void

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

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:87

Called whenever pinch / mouse click starts, globally.

Parameters

_event

SelectEvent

event.target holds its controller

Returns

void

Inherited from

Script.onSelectStart


onSimulatorStarted()

onSimulatorStarted(): void

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

Returns

void

Inherited from

Script.onSimulatorStarted


onSqueeze()

onSqueeze(_event): void

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

Called whenever gamepad trigger successfully completes, globally.

Parameters

_event

SelectEvent

event.target holds its controller.

Returns

void

Inherited from

Script.onSqueeze


onSqueezeEnd()

onSqueezeEnd(_event): void

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

Called whenever gamepad trigger stops, globally.

Parameters

_event

SelectEvent

event.target holds its controller.

Returns

void

Inherited from

Script.onSqueezeEnd


onSqueezeStart()

onSqueezeStart(_event): void

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

Called whenever gamepad trigger starts, globally.

Parameters

_event

SelectEvent

event.target holds its controller.

Returns

void

Inherited from

Script.onSqueezeStart


onSqueezing()

onSqueezing(_event): void

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

Called whenever gamepad is being triggered, globally.

Parameters

_event

SelectEvent

Returns

void

Inherited from

Script.onSqueezing


onXRSessionEnded()

onXRSessionEnded(): void

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

Returns

void

Inherited from

Script.onXRSessionEnded


onXRSessionStarted()

onXRSessionStarted(_session?): void

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

Parameters

_session?

XRSession

Returns

void

Inherited from

Script.onXRSessionStarted


physicsStep()

physicsStep(): void

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

Returns

void

Inherited from

Script.physicsStep


setState_()

protected setState_(state, details): void

Defined in: src/video/VideoStream.ts:134

Sets the stream's state and dispatches a 'statechange' event.

Parameters

state

StreamState

The new state.

details

Additional data for the event payload.

VideoStreamDetails | T

Returns

void


stop_()

protected stop_(): void

Defined in: src/video/VideoStream.ts:265

Stops the current video stream tracks.

Returns

void


update()

update(_time?, _frame?): void

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

Runs per frame.

Parameters

_time?

number

_frame?

XRFrame

Returns

void

Inherited from

Script.update