Creates a new ThreeRoot.
Sets Root#child, Root#pointerStyleHandler, transformAlgorithm and Root#child's Widget#inheritedTheme | inherited theme.
Optional
properties: ThreeRootPropertiesProtected
_currentThe actual current pointer style.
For internal use only.
See Root#pointerStyle
Protected
_enabledIs the Root enabled? For internal use only.
See Root#enabled
Protected
_fociCurrent component foci (event targets for each focus type).
For internal use only.
See Root#requestFocus, Root#dropFocus, Root#clearFocus and Root#getFocus
Protected
_fociLast capturer of each component focus (event targets for each focus type).
For internal use only.
See Root#getFocusCapturer
Protected
_mobileIs the mobile-friendly text input in use?
For internal use only.
See Root#hasMobileTextInput, Root#usingMobileTextInput and Root#getTextInput
Protected
driversThe list of drivers registered to this root
Readonly
meshThe mesh used for rendering the canvas. Saved so that its scale can be changed later.
Private
meshThe material used for the mesh. Saved so that its texture can be changed later.
Readonly
objectAn object that contains the canvas' mesh which can be added to a scene. Not actually a Mesh, but an Object3D which contains a mesh, so that the mesh can be resized without interfering with the transformAlgorithm.
The pointer style this root wants. Will be set on Root#postLayoutUpdate by Root#pointerStyleHandler
Pointer style handler, decides how to show the given pointer style. Normally a function which sets the CSS cursor style of the Root's canvas
Handler for mobile-friendly text input. If not null, widgets that need text may call this to get a string.
See Root#hasMobileTextInput, Root#usingMobileTextInput and Root#getTextInput
Private
textureThe texture with the canvas data. Will re replaced with a new texture instance when the canvas dimensions (not layout) change.
Transform algorithm; decides how to position the canvas' mesh in the world. Can be changed later and is called on update.
Protected
viewportThe internal viewport. Manages drawing
The Root#viewport's CanvasViewport#canvas | canvas
The Root#viewport's CanvasViewport#canvasDimensions | canvasDimensions
The Root#viewport's Viewport#constraints | constraints
The Root#child's Widget#dimensions | dimensions
Get the scale used for the Root#viewport. The horizontal and/or vertical scale may not be 1 if Root#maxCanvasWidth or Root#maxCanvasHeight are exceeded.
Note that this is only valid after resolving Root#child's layout.
Equivalent to getting Viewport#effectiveScale on Root#viewport.
Can Root#getTextInput be called? True if Root#textInputHandler is not null and Root#usingMobileTextInput is false.
Shortcut for Root#viewport's CanvasViewport#maxCanvasHeight property
Shortcut for Root#viewport's CanvasViewport#maxCanvasWidth property
Shortcut for Root#viewport's CanvasViewport#preventBleeding property.
Shortcut for Root#viewport's CanvasViewport#resolution property.
Note that, although the resolution is part of the CanvasViewport API, widgets will treat the resolution property as being per-Root, not per-Viewport (hence the lack of a Viewport.resolution property). The resolution property is part of the CanvasViewport class so that CanvasViewport is not circularly dependent on the Root class.
Is Root#getTextInput in use?
See Root#_mobileTextInUse.
Cleans up resources used by the Root.
It's the user's responsibility that the object is removed from all scenes. canvas-ui-three has no knowledge about the available scenes.
the Root#destroy documentation for more details
Dispatches an Event to this root's Root#child by calling Widget#dispatchEvent. Updates Root#_fociCapturers | foci capturers and notifies Root#drivers by calling Driver#onFocusCapturerChanged if the capturer changes. Does nothing if root is disabled.
Note that if an event with a focus is dispatched and no widget captures the event due to the widget not existing anymore or being disabled, the focus type of the event will be cleared in the root with Root#clearFocus.
Returns true if the event was captured
Get text input from the user. Used for mobile where keyboard events are hard to get.
If this is already in use (Root#usingMobileTextInput), returns null, else, returns a string typed by the user.
Optional
initialInput: stringCalls Root#pointerStyleHandler if the Root#pointerStyle has changed (checked by comparing with Root#_currentPointerStyle). Also updates Root#_currentPointerStyle. Can also be optionally supplied a new pointer style.
Optional
newStyle: null | stringGenerated using TypeDoc
A Root that also manages a three.js Mesh so that it can be added to a Scene.