Skip to main content

Class: VideoView

Defined in: src/ui/components/VideoView.ts:23

A fundamental UI component for creating interactive user interfaces. It serves as a base class for other UI elements like Panels, Rows, and Columns, providing core layout logic, visibility control, and interaction hooks.

Each View is a THREE.Object3D and inherits lifecycle methods from Script.

Extends

Constructors

Constructor

new VideoView(options): VideoView

Defined in: src/ui/components/VideoView.ts:65

Parameters

options

VideoViewOptions = {}

Configuration options for the VideoView.

Returns

VideoView

Overrides

View.constructor

Properties

aspectRatio

aspectRatio: number = 1.0

Defined in: src/ui/core/View.ts:72

The calculated aspect ratio (width / height) of this view.

Inherited from

View.aspectRatio


autoplay

autoplay: boolean = true

Defined in: src/ui/components/VideoView.ts:40

If true, the video will attempt to play automatically. Default is true.


crossOrigin

crossOrigin: string = 'anonymous'

Defined in: src/ui/components/VideoView.ts:44

The cross-origin setting for the video element. Default is 'anonymous'.


height

height: number = 1

Defined in: src/ui/core/View.ts:42

The height of the view, as a 0-1 ratio of its parent's available space.

Inherited from

View.height


isQuad

isQuad: boolean = true

Defined in: src/ui/core/View.ts:27

Flag indicating View behaves as a 2D quad in layout calculations.

Inherited from

View.isQuad


isRoot

isRoot: boolean = false

Defined in: src/ui/components/VideoView.ts:33

VideoView resides in a panel by default.

Overrides

View.isRoot


isView

isView: boolean = true

Defined in: src/ui/core/View.ts:31

Type identifier for easy checking with instanceof.

Inherited from

View.isView


isXRScript

isXRScript: boolean = true

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

Inherited from

View.isXRScript


loop

loop: boolean = true

Defined in: src/ui/components/VideoView.ts:38

If true, the video will loop. Default is true.


material

material: MeshBasicMaterial

Defined in: src/ui/components/VideoView.ts:47

The material applied to the video plane.


mesh

mesh: Mesh<PlaneGeometry, MeshBasicMaterial>

Defined in: src/ui/components/VideoView.ts:49

The mesh that renders the video texture.

Overrides

View.mesh


mode

mode: "center" | "stretch" = 'center'

Defined in: src/ui/components/VideoView.ts:27

The display mode for the video ('center' preserves aspect ratio).


muted

muted: boolean = true

Defined in: src/ui/components/VideoView.ts:36

If true, the video will be muted. Default is true.


name

name: string = 'VideoView'

Defined in: src/ui/components/VideoView.ts:25

Default description of this view in Three.js DevTools.

Overrides

View.name


opacity

opacity: number = 1.0

Defined in: src/ui/core/View.ts:68

The overall opacity of the view and its children.

Inherited from

View.opacity


paddingX

paddingX: number = 0

Defined in: src/ui/core/View.ts:59

Horizontal padding, as a 0-1 ratio of the parent's width.

Inherited from

View.paddingX


paddingY

paddingY: number = 0

Defined in: src/ui/core/View.ts:61

Vertical padding, as a 0-1 ratio of the parent's height.

Inherited from

View.paddingY


paddingZ

paddingZ: number = 0

Defined in: src/ui/core/View.ts:63

Depth padding, for z-axis adjustment to prevent z-fighting.

Inherited from

View.paddingZ


playsInline

playsInline: boolean = true

Defined in: src/ui/components/VideoView.ts:42

If true, the video will play inline on mobile devices. Default is true.


selectable

selectable: boolean = true

Defined in: src/ui/core/View.ts:33

Determines if this view can be targeted by user input.

Inherited from

View.selectable


src?

optional src: string

Defined in: src/ui/components/VideoView.ts:31

The URL source of the video, if loaded from a URL.


ux

ux: UX

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

Inherited from

View.ux


video?

optional video: HTMLVideoElement

Defined in: src/ui/components/VideoView.ts:29

The underlying HTMLVideoElement being used for playback.


weight

weight: number = 0.5

Defined in: src/ui/core/View.ts:38

Proportional size used in layouts like Row or Col.

Inherited from

View.weight


width

width: number = 1

Defined in: src/ui/core/View.ts:40

The width of the view, as a 0-1 ratio of its parent's available space.

Inherited from

View.width


x

x: number = 0

Defined in: src/ui/core/View.ts:47

The local x-coordinate within the parent's layout, from -0.5 to 0.5. For root view (Panel), this will be addition to the global positioning.

Inherited from

View.x


y

y: number = 0

Defined in: src/ui/core/View.ts:52

The local y-coordinate within the parent's layout, from -0.5 to 0.5. For root view (Panel), this will be addition to the global positioning.

Inherited from

View.y


z

z: number = 0

Defined in: src/ui/core/View.ts:57

The local z-coordinate within the parent's layout. For root view (Panel), this will be addition to the global positioning.

Inherited from

View.z

Accessors

rangeX

Get Signature

get rangeX(): number

Defined in: src/ui/core/View.ts:79

Gets the effective horizontal range for child elements, normalized to 1.0 for the smaller dimension.

Returns

number

The horizontal layout range.

Inherited from

View.rangeX


rangeY

Get Signature

get rangeY(): number

Defined in: src/ui/core/View.ts:88

Gets the effective vertical range for child elements, normalized to 1.0 for the smaller dimension.

Returns

number

The vertical layout range.

Inherited from

View.rangeY

Methods

add()

add(...children): VideoView

Defined in: src/ui/core/View.ts:215

Overrides THREE.Object3D.add to automatically trigger a layout update when a new View is added as a child.

Parameters

children

...Object3D<Object3DEventMap>[]

Returns

VideoView

Inherited from

View.add


dispose()

dispose(): void

Defined in: src/ui/components/VideoView.ts:267

Cleans up resources, particularly the underlying video element and texture, to prevent memory leaks.

Returns

void

Overrides

View.dispose


dpToLocalUnits()

dpToLocalUnits(dp): number

Defined in: src/ui/core/View.ts:123

Converts a value from Density-Independent Pixels (DP) to local units.

Parameters

dp

number

The value in density-independent pixels.

Returns

number

The equivalent value in local units.

Inherited from

View.dpToLocalUnits


hide()

hide(): void

Defined in: src/ui/core/View.ts:137

Makes the view and all its descendants invisible.

Returns

void

Inherited from

View.hide


init()

init(): void

Defined in: src/ui/components/VideoView.ts:90

Initializes the component, loading from src if provided in options.

Returns

void

Overrides

View.init


initPhysics()

initPhysics(_physics): void | Promise<void>

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

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

Parameters

_physics

Physics

Returns

void | Promise<void>

Inherited from

View.initPhysics


load()

load(source): void

Defined in: src/ui/components/VideoView.ts:107

Loads a video from various source types. This is the main method for setting the video content.

Parameters

source

The video source (URL, HTMLVideoElement, VideoTexture, or VideoStream).

string | HTMLVideoElement | VideoTexture | VideoStream<VideoStreamDetails>

Returns

void


loadFromStream()

loadFromStream(stream): void

Defined in: src/ui/components/VideoView.ts:126

Loads video content from an VideoStream, handling the 'ready' event to correctly display the stream and set the aspect ratio.

Parameters

stream

VideoStream

The VideoStream instance.

Returns

void


loadFromURL()

loadFromURL(url): void

Defined in: src/ui/components/VideoView.ts:157

Creates a video element and loads content from a URL.

Parameters

url

string

The URL of the video file.

Returns

void


loadFromVideoElement()

loadFromVideoElement(videoElement): void

Defined in: src/ui/components/VideoView.ts:173

Configures the view to use an existing HTMLVideoElement.

Parameters

videoElement

HTMLVideoElement

The video element to use as the source.

Returns

void


loadFromVideoTexture()

loadFromVideoTexture(videoTextureInstance): void

Defined in: src/ui/components/VideoView.ts:212

Configures the view to use an existing THREE.VideoTexture.

Parameters

videoTextureInstance

VideoTexture

The texture to display.

Returns

void


onHoverEnter()

onHoverEnter(_controller): void

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

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

Parameters

_controller

Object3D

An XR controller.

Returns

void

Inherited from

View.onHoverEnter


onHoverExit()

onHoverExit(_controller): void

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

Called when the controller hovers over this object with reticle.

Parameters

_controller

Object3D

An XR controller.

Returns

void

Inherited from

View.onHoverExit


onHovering()

onHovering(_controller): 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

void

Inherited from

View.onHovering


onKeyDown()

onKeyDown(_event): void

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

Called on keyboard keypress.

Parameters

_event

KeyEvent

Event containing .code to read the keyboard key.

Returns

void

Inherited from

View.onKeyDown


onKeyUp()

onKeyUp(_event): void

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

Parameters

_event

KeyEvent

Returns

void

Inherited from

View.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

View.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

View.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

View.onObjectGrabStart


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

SelectEvent

event.target holds its controller.

Returns

boolean

Whether the event was handled

Inherited from

View.onObjectSelectEnd


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

SelectEvent

event.target holds its controller.

Returns

boolean

Whether the event was handled

Inherited from

View.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

View.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

View.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

View.onObjectTouchStart


onSelect()

onSelect(_event): void

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

Called whenever pinch / mouse click successfully completes, globally.

Parameters

_event

SelectEvent

event.target holds its controller.

Returns

void

Inherited from

View.onSelect


onSelectEnd()

onSelectEnd(_event): void

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

Called whenever pinch / mouse click discontinues, globally.

Parameters

_event

SelectEvent

event.target holds its controller

Returns

void

Inherited from

View.onSelectEnd


onSelecting()

onSelecting(_event): void

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

Called whenever pinch / mouse click is happening, globally.

Parameters

_event

SelectEvent

Returns

void

Inherited from

View.onSelecting


onSelectStart()

onSelectStart(_event): void

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

Called whenever pinch / mouse click starts, globally.

Parameters

_event

SelectEvent

event.target holds its controller

Returns

void

Inherited from

View.onSelectStart


onSimulatorStarted()

onSimulatorStarted(): void

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

Returns

void

Inherited from

View.onSimulatorStarted


onSqueeze()

onSqueeze(_event): void

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

Called whenever gamepad trigger successfully completes, globally.

Parameters

_event

SelectEvent

event.target holds its controller.

Returns

void

Inherited from

View.onSqueeze


onSqueezeEnd()

onSqueezeEnd(_event): void

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

Called whenever gamepad trigger stops, globally.

Parameters

_event

SelectEvent

event.target holds its controller.

Returns

void

Inherited from

View.onSqueezeEnd


onSqueezeStart()

onSqueezeStart(_event): void

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

Called whenever gamepad trigger starts, globally.

Parameters

_event

SelectEvent

event.target holds its controller.

Returns

void

Inherited from

View.onSqueezeStart


onSqueezing()

onSqueezing(_event): void

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

Called whenever gamepad is being triggered, globally.

Parameters

_event

SelectEvent

Returns

void

Inherited from

View.onSqueezing


onTriggered()

onTriggered(_id): void

Defined in: src/ui/core/View.ts:230

Hook called on a complete select action (e.g., a click) when this view is the target. Intended for override by subclasses.

Parameters

_id

number

The ID of the controller that triggered the action.

Returns

void

Inherited from

View.onTriggered


onXRSessionEnded()

onXRSessionEnded(): void

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

Returns

void

Inherited from

View.onXRSessionEnded


onXRSessionStarted()

onXRSessionStarted(_session?): void

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

Parameters

_session?

XRSession

Returns

void

Inherited from

View.onXRSessionStarted


pause()

pause(): void

Defined in: src/ui/components/VideoView.ts:248

Pauses video playback.

Returns

void


physicsStep()

physicsStep(): void

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

Returns

void

Inherited from

View.physicsStep


play()

play(): void

Defined in: src/ui/components/VideoView.ts:240

Starts video playback.

Returns

void


resetLayout()

resetLayout(): void

Defined in: src/ui/core/View.ts:195

Resets the layout state of this view. Intended for override by subclasses.

Returns

void

Inherited from

View.resetLayout


resetLayouts()

resetLayouts(): void

Defined in: src/ui/core/View.ts:198

Resets the layout state for this view and all its descendants.

Returns

void

Inherited from

View.resetLayouts


show()

show(): void

Defined in: src/ui/core/View.ts:129

Makes the view and all its descendants visible.

Returns

void

Inherited from

View.show


update()

update(_time?, _frame?): void

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

Runs per frame.

Parameters

_time?

number

_frame?

XRFrame

Returns

void

Inherited from

View.update


updateLayout()

updateLayout(): void

Defined in: src/ui/components/VideoView.ts:287

Updates the layout and scales the video plane to match its aspect ratio.

Returns

void

Overrides

View.updateLayout


updateLayouts()

updateLayouts(): void

Defined in: src/ui/core/View.ts:171

Triggers a layout update for this view and all its descendants.

Returns

void

Inherited from

View.updateLayouts


updateLayoutsBFS()

updateLayoutsBFS(): void

Defined in: src/ui/core/View.ts:179

Performs a Breadth-First Search (BFS) traversal to update the layout tree, ensuring parent layouts are calculated before their children.

Returns

void

Inherited from

View.updateLayoutsBFS


dpToMeters()

static dpToMeters(dp): number

Defined in: src/ui/core/View.ts:114

Converts a value from Density-Independent Pixels (DP) to meters.

Parameters

dp

number

The value in density-independent pixels.

Returns

number

The equivalent value in meters.

Inherited from

View.dpToMeters