Skip to main content

Class: ExitButton

Defined in: src/ui/components/ExitButton.ts:12

A specialized IconButton that provides a simple, single-click way for users to end the current WebXR session.

It inherits the visual and interactive properties of IconButton and adds the specific logic for session termination.

Extends

Constructors

Constructor

new ExitButton(options): ExitButton

Defined in: src/ui/components/ExitButton.ts:37

Parameters

options

IconButtonOptions = {}

Configuration options to override the button's default appearance.

Returns

ExitButton

Overrides

IconButton.constructor

Properties

anchorX

anchorX: number | "left" | "right" | "center" | `${number}%` = 'center'

Defined in: src/ui/components/TextView.ts:103

Horizontal anchor point ('left', 'center', 'right').

Inherited from

IconButton.anchorX


anchorY

anchorY: number | `${number}%` | "top" | "top-baseline" | "top-cap" | "top-ex" | "middle" | "bottom-baseline" | "bottom" = 'middle'

Defined in: src/ui/components/TextView.ts:105

Vertical anchor point ('top', 'middle', 'bottom').

Inherited from

IconButton.anchorY


aspectRatio

aspectRatio: number = 1.0

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

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

Inherited from

IconButton.aspectRatio


backgroundColor

backgroundColor: number = 0xffffff

Defined in: src/ui/components/ExitButton.ts:28

The background color of the button's circular shape.


canvas?

optional canvas: HTMLCanvasElement

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

Fallback HTML canvas to render legacy text.

Inherited from

IconButton.canvas


ctx?

optional ctx: CanvasRenderingContext2D

Defined in: src/ui/components/TextView.ts:128

Fallback HTML canvas context to render legacy text.

Inherited from

IconButton.ctx


defaultOpacity

defaultOpacity: number = 0.2

Defined in: src/ui/components/ExitButton.ts:24

The base opacity when the button is not being interacted with.

Overrides

IconButton.defaultOpacity


font

font: string = MATERIAL_ICONS_FONT_FILE

Defined in: src/ui/components/IconButton.ts:35

The icon font file to use. Defaults to Material Icons.

Inherited from

IconButton.font


fontColor

fontColor: string | number = 0xFFFFFF

Defined in: src/ui/components/TextView.ts:93

The color of the font.

Inherited from

IconButton.fontColor


fontSize

fontSize: number = 0.8

Defined in: src/ui/components/ExitButton.ts:22

The size of the 'close' icon font.

Overrides

IconButton.fontSize


fontSizeDp?

optional fontSizeDp: number

Defined in: src/ui/components/TextView.ts:91

Inherited from

IconButton.fontSizeDp


height

height: number = 1

Defined in: src/ui/components/TextView.ts:123

Relative local height.

Inherited from

IconButton.height


hoverColor

hoverColor: number = 0xaaaaaa

Defined in: src/ui/components/IconButton.ts:28

The background color when a reticle hovers over the button.

Inherited from

IconButton.hoverColor


hoverOpacity

hoverOpacity: number = 0.8

Defined in: src/ui/components/ExitButton.ts:26

The opacity when a controller's reticle hovers over the button.

Overrides

IconButton.hoverOpacity


imageOffsetX

imageOffsetX: number = 0

Defined in: src/ui/components/TextView.ts:112

The horizontal offset for the imageOverlay texture.

Inherited from

IconButton.imageOffsetX


imageOffsetY

imageOffsetY: number = 0

Defined in: src/ui/components/TextView.ts:114

The vertical offset for the imageOverlay texture.

Inherited from

IconButton.imageOffsetY


imageOverlay?

optional imageOverlay: string

Defined in: src/ui/components/TextView.ts:110

An optional image URL to use as an overlay texture on the text.

Inherited from

IconButton.imageOverlay


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

IconButton.isQuad


isRoot

isRoot: boolean = false

Defined in: src/ui/components/TextView.ts:81

TextView resides in a panel by default.

Inherited from

IconButton.isRoot


isView

isView: boolean = true

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

Type identifier for easy checking with instanceof.

Inherited from

IconButton.isView


isXRScript

isXRScript: boolean = true

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

Inherited from

IconButton.isXRScript


lineCount

lineCount: number = 0

Defined in: src/ui/components/TextView.ts:132

The total number of lines after text wrapping.

Inherited from

IconButton.lineCount


lineHeight

lineHeight: number = 0

Defined in: src/ui/components/TextView.ts:130

The calculated height of a single line of text.

Inherited from

IconButton.lineHeight


maxWidth

maxWidth: number = 1.0

Defined in: src/ui/components/TextView.ts:99

The maximum width the text can occupy before wrapping. To fit a long TextView within a container, this value should be its container's height / width to avoid it getting rendered outside.

Inherited from

IconButton.maxWidth


mesh

mesh: Mesh<PlaneGeometry, MeshBasicMaterial>

Defined in: src/ui/components/IconButton.ts:37

The underlying mesh for the button's background.

Inherited from

IconButton.mesh


mode

mode: string = 'fitWidth'

Defined in: src/ui/components/TextView.ts:101

Layout mode. 'fitWidth' scales text to fit the view's width.

Inherited from

IconButton.mode


name

name: string = 'TextView'

Defined in: src/ui/components/TextView.ts:83

Default description of this view in Three.js DevTools.

Inherited from

IconButton.name


opacity

opacity: number = 1.0

Defined in: src/ui/components/IconButton.ts:24

The overall opacity when the button is not being interacted with.

Inherited from

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

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

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

IconButton.paddingZ


selectable

selectable: boolean = true

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

Determines if this view can be targeted by user input.

Inherited from

IconButton.selectable


selectedOpacity

selectedOpacity: number = 0.4

Defined in: src/ui/components/IconButton.ts:32

The background opacity when the button is actively being pressed.

Inherited from

IconButton.selectedOpacity


textAlign

textAlign: string = 'center'

Defined in: src/ui/components/TextView.ts:108

Horizontal alignment ('left', 'center', 'right').

Inherited from

IconButton.textAlign


textObj?

optional textObj: Mesh<BufferGeometry<NormalBufferAttributes, BufferGeometryEventMap>, Material | Material[], Object3DEventMap> | Text

Defined in: src/ui/components/TextView.ts:86

The underlying renderable object (either a Troika Text or a Plane.

Inherited from

IconButton.textObj


useSDFText

useSDFText: boolean = true

Defined in: src/ui/components/TextView.ts:79

Determines which rendering backend to use. Defaults to SDF text.

Inherited from

IconButton.useSDFText


ux

ux: UX

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

Inherited from

IconButton.ux


weight

weight: number = 0.5

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

Proportional size used in layouts like Row or Col.

Inherited from

IconButton.weight


width

width: number = 1

Defined in: src/ui/components/TextView.ts:121

Relative local width.

Inherited from

IconButton.width


x

x: number = 0

Defined in: src/ui/components/TextView.ts:117

Relative local offset in X.

Inherited from

IconButton.x


y

y: number = 0

Defined in: src/ui/components/TextView.ts:119

Relative local offset in Y.

Inherited from

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

IconButton.z


dependencies

static dependencies: object

Defined in: src/ui/components/ExitButton.ts:17

Declares the dependencies required by this script, which will be injected by the core engine during initialization.

renderer

renderer: typeof WebGLRenderer = THREE.WebGLRenderer

Accessors

rangeX

Get Signature

get rangeX(): number

Defined in: src/ui/components/IconButton.ts:43

Overrides the parent rangeX to ensure the circular shape is not affected by panel aspect ratio.

Returns

number

Inherited from

IconButton.rangeX


rangeY

Get Signature

get rangeY(): number

Defined in: src/ui/components/IconButton.ts:51

Overrides the parent rangeY to ensure the circular shape is not affected by panel aspect ratio.

Returns

number

Inherited from

IconButton.rangeY


text

Get Signature

get text(): string

Defined in: src/ui/components/TextView.ts:146

Returns

string

Set Signature

set text(text): void

Defined in: src/ui/components/TextView.ts:136

Parameters
text

string

Returns

void

Inherited from

IconButton.text

Methods

_initializeText()

protected _initializeText(): void

Defined in: src/ui/components/IconButton.ts:133

Overrides the parent's private initialization method. This is called by the parent's init() method after the Troika module is confirmed to be loaded.

Returns

void

Inherited from

IconButton._initializeText


add()

add(...children): ExitButton

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

ExitButton

Inherited from

IconButton.add


createTextSDF()

protected createTextSDF(): void

Defined in: src/ui/components/TextView.ts:220

Creates the text object using Troika Three Text for SDF rendering. This method should only be called from _initializeText() when useSDFText is true and the troika-three-text module has been successfully imported.

Returns

void

Inherited from

IconButton.createTextSDF


dispose()

dispose(): void

Defined in: src/ui/components/TextView.ts:383

Disposes of resources used by the TextView, such as event listeners.

Returns

void

Inherited from

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

IconButton.dpToLocalUnits


hide()

hide(): void

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

Makes the view and all its descendants invisible.

Returns

void

Inherited from

IconButton.hide


init()

init(dependencies): Promise<void>

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

Initializes the component and stores the injected renderer dependency.

Parameters

dependencies

The injected dependencies.

renderer

WebGLRenderer

Returns

Promise<void>

Overrides

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

IconButton.initPhysics


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

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

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

IconButton.onHovering


onHoverOut()

onHoverOut(): void

Defined in: src/ui/components/IconButton.ts:110

Handles behavior when the cursor moves off the button.

Returns

void

Inherited from

IconButton.onHoverOut


onHoverOver()

onHoverOver(): void

Defined in: src/ui/components/IconButton.ts:102

/**

  • Handles behavior when the cursor hovers over the button.

Returns

void

Inherited from

IconButton.onHoverOver


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

IconButton.onKeyDown


onKeyUp()

onKeyUp(_event): void

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

Parameters

_event

KeyEvent

Returns

void

Inherited from

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

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

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

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

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

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

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

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

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

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

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

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

IconButton.onSelectStart


onSimulatorStarted()

onSimulatorStarted(): void

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

Returns

void

Inherited from

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

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

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

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

IconButton.onSqueezing


onSyncComplete()

onSyncComplete(): void

Defined in: src/ui/components/TextView.ts:301

Callback executed when Troika's text sync is complete. It captures layout data like total height and line count.

Returns

void

Inherited from

IconButton.onSyncComplete


onTriggered()

onTriggered(): void

Defined in: src/ui/components/ExitButton.ts:57

This method is triggered when the button is successfully selected (e.g., clicked). It finds the active WebXR session and requests to end it.

Returns

void

Overrides

IconButton.onTriggered


onXRSessionEnded()

onXRSessionEnded(): void

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

Returns

void

Inherited from

IconButton.onXRSessionEnded


onXRSessionStarted()

onXRSessionStarted(_session?): void

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

Parameters

_session?

XRSession

Returns

void

Inherited from

IconButton.onXRSessionStarted


physicsStep()

physicsStep(): void

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

Returns

void

Inherited from

IconButton.physicsStep


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

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

IconButton.resetLayouts


setText()

setText(text): void

Defined in: src/ui/components/TextView.ts:191

Sets the text content of the view.

Parameters

text

string

The text to be displayed.

Returns

void

Inherited from

IconButton.setText


setTextColor()

protected setTextColor(color): void

Defined in: src/ui/components/TextView.ts:374

Parameters

color

number

Returns

void

Inherited from

IconButton.setTextColor


show()

show(): void

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

Makes the view and all its descendants visible.

Returns

void

Inherited from

IconButton.show


syncTextObj()

protected syncTextObj(): void

Defined in: src/ui/components/TextView.ts:368

Returns

void

Inherited from

IconButton.syncTextObj


update()

update(): void

Defined in: src/ui/components/IconButton.ts:118

Updates the button's visual state based on hover and selection status.

Returns

void

Inherited from

IconButton.update


updateLayout()

updateLayout(): void

Defined in: src/ui/components/TextView.ts:198

Updates the layout of the text object, such as its render order.

Returns

void

Inherited from

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

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

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

IconButton.dpToMeters