Create a new WLRoot. Note that the properties object can also contain optional parameters for the canvas-ui Root constructor, and will be passed to it.
If texture bleeding prevention is not specified, then it will be enabled by default.
If a pointer style handler is not specified, then a default pointer style handler that changes the cursor style of the Wonderland Engine canvas will be used.
The object where the mesh will be added.
The material to use for this root's mesh. The material will be cloned.
The root's child widget.
Optional
properties: WLRootPropertiesProtected
_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
Private
downProtected
driversThe list of drivers registered to this root
Private
keydownPrivate
keyupPrivate
moveThe 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
unPrivate
upProtected
validProtected
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.
Is this root enabled? If not enabled, painting, updating or resolving layout will do nothing. Root#drivers | Drivers will also be notified by calling Driver#onEnable or Driver#onDisable, pointer style will be reset (Root#updatePointerStyle called with 'default') and all Root#_foci | foci will be cleared (Root#clearFocus).
See Root#_enabled
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.
Static
keyboardThe shared DOMKeyboardDriver instance. Getter only. The DOMKeyboardDriver will only be created when needed. Used for keyboard input.
Static
pointerThe shared PointerDriver instance. Getter only. The PointerDriver will only be created when needed. Used for pointer (mouse & XR controller) input.
Static
pointerIDsA Map mapping each cursor component to a PointerDriver's pointer ID.
Private
_setupDispatches 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: stringPaint this root's next frame if needed. Does nothing if root is disabled.
Calls Root#viewport's Viewport#paint with Root#child.
Call this after calling Root#postLayoutUpdate.
Returns whether the child was dirty or not. Use this to tell an external 3D library whether to update a mesh's texture or not.
Resolve the layout of this root. Does nothing if root is disabled.
Calls Root#viewport's Viewport#resolveLayout with Root#child
Call this before calling Root#postLayoutUpdate and after calling Root#preLayoutUpdate
Returns true if the viewport was resized or re-scaled
Calls 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 | stringStatic
getGenerated using TypeDoc
A canvas-ui Root which automatically manages a mesh and input. For an example on how to use this in a component, see example-components/test-ui-root.js
Alias
module:WLRoot