Properties:
| Name | Type | Description |
|---|---|---|
children |
Array.<core.Object> | [readonly] The child objects. |
lifeCycleStatus |
string | [readonly] The current lifecycle status: |
objectId |
number | [readonly] The unique ID of the object for debugging purposes. |
objectLocation |
string | A string describing the object's location for debugging purposes. |
objectType |
string | A string describing the object's type for debugging purposes. |
parent |
core.Object | The parent object, or |
Methods
-
Aborts a named wait operation from core.Object#wait.
Name Type Description namestring The name of the wait operation.
-
Accumulates the given callback function associated with a name.
Only the most recent one of the accumulated functions under a name will be executed before the JavaScript engine finished executing its current code.
Name Type Description ffunction The function to invoke.
namestring The accumulation name.
-
Adds a child object to this object.
Name Type Description childcore.Object The child object.
-
Adds a custom external property of any type. The property is notifyable.
Name Type Description namestring The name of the property.
getterfunction A function returning the property's value.
setterfunction A function accepting the property's new value.
-
Waits for a shared resource identified by a key to become available. Once the resource is available, the given callback will be invoked. If this method returns
true, the shared resource must be created first (it does not exist and this object is the first one waiting).This method is useful for dealing with resources that are created asynchronously.
Name Type Description keystring The resource key.
callbackfunction The callback function.
Returns:
Type Description bool - Whether the resource needs to be created or not.
-
Cancels the given pending named callback before it gets executed.
Name Type Description namestring The name.
-
Changes the given property by applying a transition if specified. This is the prefered way to change a property's value as it takes potential transitioning into account.
If the value is a Promise object, it will be changed when the Promise resolves.
Name Type Description namestring The name of the property.
newValueany The property's new value.
- See:
-
Clears the given waiting queue.
Name Type Description qNamestring The name of the queue.
- See:
-
colorName (name)core.Color
-
Creates a color from a CSS color name.
Name Type Description namestring The color name.
Returns:
Type Description core.Color - The color.
-
Connects a handler to the given event. The handler gets disconnected automatically when the receiver object is discarded.
Name Type Description eventstring The event name.
receivercore.Object The receiver object that owns the handler.
handlerfunction The event handler.
-
Defers the execution of the given function associated with a name.
Only the most recent one of the defered functions under a name will be executed before the JavaScript engine finished executing its current code.
Name Type Description ffunction The function to invoke.
namestring The function name.
-
Disconnects an object from the given event.
Name Type Description eventstring The event name.
receivercore.Object The object to disconnect.
- See:
-
Frees a shared resource identified by a key. If this was the last user of the resource, it will be deleted using the supplied deleter function.
The deleter function may be omitted if there is no special action to be taken for deletion.
Name Type Description keystring The resource key.
deleterfunction optional The deleter function.
Example
this.freeSharedResource("mySharedResource", res => { res.cleanUp(); }); -
Returns whether the given event has handlers connected.
Name Type Description eventstring The name of the event.
- See:
Returns:
Type Description bool Whether the event has handlers connected. -
Imports a JavaScript or WASM module and returns a Promise that resolves to the module.
Name Type Description urlstring The address of the module.
Returns:
Type Description Promise The Promise object. -
Initializes this object. Call this method after creating the object and its children.
-
Tests if this object is an ancestor of the given object.
Name Type Description objcore.Object The object to test.
Returns:
Type Description bool Whether the object is an ancestor. -
Sends a log message to the parent element if there is one. Override this method to handle logging. By default, logging is not handled in any way.
Name Type Description domainstring The name of the logging domain.
levelstring The log level. One of
trace|debug|info|warning|error|fatalmessagestring The log message.
-
Wraps a callback function to give it a name handle by which it may be canceled before execution.
When setting multiple callbacks of the same name, only the last one will be executed.
Name Type Description callbackfunction The callback function.
namestring The name.
Returns:
Type Description function - The wrapped callback function.
-
Returns if the given named callback is currently pending.
Name Type Description namestring The name.
Returns:
Type Description bool trueif the callback is currently pending. -
Makes the given property notifyable. This adds a
<name>Changedevent to the object for watching the property for changes.Name Type Description namestring The name of the property.
- See:
-
Adds a reference to this object, which means that another object is holding a reference to this object from then on. Objects are not discarded while still being referenced.
The reference is removed automatically when the referencing object gets discarded.
Name Type Description whichcore.Object The referencing object.
- See:
-
Removes a reference from this object. When there are no references left, the object will be discarded automatically.
Name Type Description whichcore.Object The referencing object.
- See:
-
Registers the given event. If
connectionMonitoris specified, that callback will be invoked whenever a connection to the event is made.Name Type Description namestring The name of the event.
connectionMonitorfunction The callback to invoke after each new connection.
- See:
-
Releases this object from its parent at a later point when idle.
-
rgb (r, g, b)core.Color
-
Creates a color from RGB values.
Name Type Description rnumber The red value between 0.0 and 1.0.
gnumber The green value between 0.0 and 1.0.
bnumber The blue value between 0.0 and 1.0.
Returns:
Type Description core.Color - The color.
-
rgba (r, g, b, a)core.Color
-
Creates a color from RGBA values.
Name Type Description rnumber The red value between 0.0 and 1.0.
gnumber The green value between 0.0 and 1.0.
bnumber The blue value between 0.0 and 1.0.
anumber The alpha value between 0.0 and 1.0.
Returns:
Type Description core.Color - The color.
-
Wraps a callback function to be safe, i.e. it will only be invoked if a condition still holds. By default the condition checks if the object is still alive. This helps when working with asynchronous code.
Name Type Description callbackfunction The callback function.
conditionfunction An optional condition function that returns either
trueorfalse.Returns:
Type Description function - The safe-made callback function.
-
Retrieves a shared resource identified by a key. If the resource did not yet exist, it will be created using the supplied factory function.
The factory function may be omitted if you don't want to create the resource at this place. In this case, this method will return
nullif the resource did not exist.Name Type Description keystring The resource key.
factoryfunction optional The factory function.
Returns:
Type Description any The shared resource. Example
const res = this.sharedResource("mySharedResource", () => { return new BigResource(); }); -
Makes the given property transitionable by adding a property
<name>Transitionfor defining a transition animation.Name Type Description namestring The name of the property.
interpolatefunction An optional interpolation function.
- See:
-
Returns the role type of the given property. The type is
undefinedif the property does not exist.Name Type Description namestring The name of the property.
Returns:
Type Description string The type, one of property|method|event|eventhandler|undefined -
vec3 (x, y, z)core.Vec3
-
Creates a 3-component vector.
Name Type Description xnumber The X component.
ynumber The Y component.
znumber The Z component.
Returns:
Type Description core.Vec3 The vector. -
Visits this object and its decendants recursively with a custom function, while the function returns
true. If the function returnsfalse, children are not visited.Name Type Description ffunction The visitor function. Takes the visited object as parameter and returns a boolean value.
-
Returns a Promise that resolves after a given amount of milliseconds.
If the milliseconds are set to
0, the promise resolves immediately after the JavaScript engine finished executing its current code, without using a timer.If the wait operation is given a name, it is abortable via the core.Object#abortWait method. In this case, the promise resolves to
false.Name Type Description msnumber The amount of milliseconds to wait.
namestring An optional name for aborting via core.Object#abortWait.
Returns:
Type Description Promise The Promise object. -
Returns a Promise that resolves after there has been any event activity.
If the wait operation is given a name, it is abortable via the core.Object#abortWait method. In this case, the promise resolves to
false.Name Type Description namestring An optional name for aborting via core.Object#abortWait.
Returns:
Type Description Promise The Promise object. -
Waits in a named queue and returns a Promise that resolves to a
nextfunction when it's the caller's turn. After the caller has finished its turn, thatnextfunction must be invoked.Name Type Description qNamestring The name of the queue.
- See:
Returns:
Type Description Promise.<function()> The Promise object.
Events
-
Is triggered immediately before the object will be destroyed. The object is still intact at this place.
-
Is triggered after the object was initialized.
-
Is triggered after the object was destroyed. The object is not intact anymore at this place.