Node [constructor] 

Nodes define hierarchy and geometrical transformations. They can be moved (translated), scaled and rotated.

A Node is either mounted or unmounted. Unmounted nodes are detached from the scene graph. Unmounted nodes have no parent node, while each mounted node has exactly one parent. Nodes have an arbitrary number of children, which can be dynamically added using {@link Node#addChild}.

Each Node has an arbitrary number of components. Those components can send draw commands to the renderer or mutate the node itself, in which case they define behavior in the most explicit way. Components that send draw commands are considered renderables. From the node's perspective, there is no distinction between nodes that send draw commands and nodes that define behavior.

Because of the fact that Nodes themself are very unopinioted (they don't "render" to anything), they are often being subclassed in order to add e.g. components at initialization to them. Because of this flexibility, they might as well have been called Entities.

new Node()

Instance methods

._init()

Protected method. Initializes a node with a default Transform and Size component

._setParent(parent)

Protected method. Sets the parent of this node such that it can be looked up.

Parameters:

NameTypeDescription
parentNode

The node to set as the parent of this

._setMounted(mounted, path)

Protected method. Sets the mount state of the node. Should only be called by the dispatch

Parameters:

NameTypeDescription
mountedBoolean

whether or not the Node is mounted.

pathString

The path that the node will be mounted to

._setShown(shown)

Protected method, sets whether or not the Node is shown. Should only be called by the dispatch

Parameters:

NameTypeDescription
shownBoolean

whether or not the node is shown

._setUpdater(updater)

Protected method. Sets the updater of the node.

Parameters:

NameTypeDescription
updaterFamousEngine

the Updater of the node.

.getLocation()

Determine the node's location in the scene graph hierarchy. A location of body/0/1 can be interpreted as the following scene graph hierarchy (ignoring siblings of ancestors and additional child nodes):

Context:body -> Node:0 -> Node:1, where Node:1 is the node the getLocation method has been invoked on.

.emit(event, payload)

Dispatches the event using the Dispatch. All descendent nodes will receive the dispatched event.

Parameters:

NameTypeDescription
eventString

Event type.

payloadObject

Event object to be dispatched.

.sendDrawCommand()

.getValue()

Recursively serializes the Node, including all previously added components.

.getComputedValue()

Similar to {@link Node#getValue}, but returns the actual "computed" value. E.g. a proportional size of 0.5 might resolve into a "computed" size of 200px (assuming the parent has a width of 400px).

.getChildren()

Retrieves all children of the current node.

.getRawChildren()

Method used internally to retrieve the children of a node. Each index in the returned array represents a path fragment.

.getParent()

Retrieves the parent of the current node. Unmounted nodes do not have a parent node.

.requestUpdate(requester)

Schedules the {@link Node#update} function of the node to be invoked on the next frame (if no update during this frame has been scheduled already). If the node is currently being updated (which means one of the requesters invoked requestsUpdate while being updated itself), an update will be scheduled on the next frame.

Parameters:

NameTypeDescription
requesterObject

If the requester has an onUpdate method, it will be invoked during the next update phase of the node.

.requestUpdateOnNextTick(requester)

Schedules an update on the next tick. Similarily to {@link Node#requestUpdate}, requestUpdateOnNextTick schedules the node's onUpdate function to be invoked on the frame after the next invocation on the node's onUpdate function.

Parameters:

NameTypeDescription
requesterObject

If the requester has an onUpdate method, it will be invoked during the next update phase of the node.

.isMounted()

Checks if the node is mounted. Unmounted nodes are detached from the scene graph.

.isRendered()

Checks if the node is being rendered. A node is being rendererd when it is mounted to a parent node and shown.

.isShown()

Checks if the node is visible ("shown").

.getOpacity()

Determines the node's relative opacity. The opacity needs to be within [0, 1], where 0 indicates a completely transparent, therefore invisible node, whereas an opacity of 1 means the node is completely solid.

.getMountPoint()

Determines the node's previously set mount point.

.getAlign()

Determines the node's previously set align.

.getOrigin()

Determines the node's previously set origin.

.getPosition()

Determines the node's previously set position.

.getRotation()

Returns the node's current rotation

.getScale()

Returns the scale of the node

.getSizeMode()

Returns the current size mode of the node

.getProportionalSize()

Returns the current proportional size

.getDifferentialSize()

Returns the differential size of the node

.getAbsoluteSize()

Returns the absolute size of the node

.getRenderSize()

Returns the current Render Size of the node. Note that the render size is asynchronous (will always be one frame behind) and needs to be explicitely calculated by setting the proper size mode.

.getSize()

Returns the external size of the node

.getTransform()

Returns the current world transform of the node

.getUIEvents()

Get the list of the UI Events that are currently associated with this node

.addChild(child)

Adds a new child to this node. If this method is called with no argument it will create a new node, however it can also be called with an existing node which it will append to the node that this method is being called on. Returns the new or passed in node.

Parameters:

NameTypeDescription
childNode

the node to appended or no node to create a new node.

.removeChild(child)

Removes a child node from another node. The passed in node must be a child of the node that this method is called upon.

Parameters:

NameTypeDescription
childNode

node to be removed

.addComponent(component)

Each component can only be added once per node.

Parameters:

NameTypeDescription
componentObject

A component to be added.

.getComponent(index)

Parameters:

NameTypeDescription
indexNumber

Index at which the component has been registered (using Node#addComponent).

.removeComponent(component)

Removes a previously via {@link Node#addComponent} added component.

Parameters:

NameTypeDescription
componentObject

An component that has previously been added using {@link Node#addComponent}.

.removeUIEvent(eventName)

Removes a node's subscription to a particular UIEvent. All components on the node will have the opportunity to remove all listeners depending on this event.

Parameters:

NameTypeDescription
eventNameString

the name of the event

.addUIEvent(eventName)

Subscribes a node to a UI Event. All components on the node will have the opportunity to begin listening to that event and alerting the scene graph.

Parameters:

NameTypeDescription
eventNameString

the name of the event

._requestUpdate(force)

Private method for the Node to request an update for itself.

Parameters:

NameTypeDescription
forceBoolean

whether or not to force the update

._vecOptionalSet(vec, index, val)

Private method to set an optional value in an array, and request an update if this changes the value of the array.

Parameters:

NameTypeDescription
vecArray

the array to insert the value into

indexNumber

the index at which to insert the value

valAny

the value to potentially insert (if not null or undefined)

.show()

Shows the node, which is to say, calls onShow on all of the node's components. Renderable components can then issue the draw commands necessary to be shown.

.hide()

Hides the node, which is to say, calls onHide on all of the node's components. Renderable components can then issue the draw commands necessary to be hidden

.setAlign(x, y, z)

Sets the align value of the node. Will call onAlignChange on all of the Node's components.

Parameters:

NameTypeDescription
xNumber

Align value in the x dimension.

yNumber

Align value in the y dimension.

zNumber

Align value in the z dimension.

.setMountPoint(x, y, z)

Sets the mount point value of the node. Will call onMountPointChange on all of the node's components.

Parameters:

NameTypeDescription
xNumber

MountPoint value in x dimension

yNumber

MountPoint value in y dimension

zNumber

MountPoint value in z dimension

.setOrigin(x, y, z)

Sets the origin value of the node. Will call onOriginChange on all of the node's components.

Parameters:

NameTypeDescription
xNumber

Origin value in x dimension

yNumber

Origin value in y dimension

zNumber

Origin value in z dimension

.setPosition(x, y, z)

Sets the position of the node. Will call onPositionChange on all of the node's components.

Parameters:

NameTypeDescription
xNumber

Position in x

yNumber

Position in y

zNumber

Position in z

.setRotation(x, y, z, w)

Sets the rotation of the node. Will call onRotationChange on all of the node's components. This method takes either Euler angles or a quaternion. If the fourth argument is undefined Euler angles are assumed.

Parameters:

NameTypeDescription
xNumber

Either the rotation around the x axis or the magnitude in x of the axis of rotation.

yNumber

Either the rotation around the y axis or the magnitude in y of the axis of rotation.

zNumber

Either the rotation around the z axis or the magnitude in z of the axis of rotation.

wNumber

the amount of rotation around the axis of rotation, if a quaternion is specified.

.setScale(x, y, z)

Sets the scale of the node. The default value is 1 in all dimensions. The node's components will have onScaleChanged called on them.

Parameters:

NameTypeDescription
xNumber

Scale value in x

yNumber

Scale value in y

zNumber

Scale value in z

.setOpacity(val)

Sets the value of the opacity of this node. All of the node's components will have onOpacityChange called on them/

Parameters:

NameTypeDescription
valNumber

Value of the opacity. 1 is the default.

.setSizeMode(x, y, z)

Sets the size mode being used for determining the node's final width, height and depth. Size modes are a way to define the way the node's size is being calculated. Size modes are enums set on the {@link Size} constructor (and aliased on the Node).

Parameters:

NameTypeDescription
xSizeMode

The size mode being used for determining the size in x direction ("width").

ySizeMode

The size mode being used for determining the size in y direction ("height").

zSizeMode

The size mode being used for determining the size in z direction ("depth").

.setProportionalSize(x, y, z)

A proportional size defines the node's dimensions relative to its parents final size. Proportional sizes need to be within the range of [0, 1].

Parameters:

NameTypeDescription
xNumber

x-Size in pixels ("width").

yNumber

y-Size in pixels ("height").

zNumber

z-Size in pixels ("depth").

.setDifferentialSize(x, y, z)

Differential sizing can be used to add or subtract an absolute size from an otherwise proportionally sized node. E.g. a differential width of -10 and a proportional width of 0.5 is being interpreted as setting the node's size to 50% of its parent's width minus 10 pixels.

Parameters:

NameTypeDescription
xNumber

x-Size to be added to the relatively sized node in pixels ("width").

yNumber

y-Size to be added to the relatively sized node in pixels ("height").

zNumber

z-Size to be added to the relatively sized node in pixels ("depth").

.setAbsoluteSize(x, y, z)

Sets the node's size in pixels, independent of its parent.

Parameters:

NameTypeDescription
xNumber

x-Size in pixels ("width").

yNumber

y-Size in pixels ("height").

zNumber

z-Size in pixels ("depth").

.getFrame()

Method for getting the current frame. Will be deprecated.

.getComponents()

returns an array of the components currently attached to this node.

.update(time)

Enters the node's update phase while updating its own spec and updating its components.

Parameters:

NameTypeDescription
timeNumber

high-resolution timestamp, usually retrieved using requestAnimationFrame

.mount(path)

Mounts the node and therefore its subtree by setting it as a child of the passed in parent.

Parameters:

NameTypeDescription
pathString

unique path of node (e.g. body/0/1)

.dismount()

Dismounts (detaches) the node from the scene graph by removing it as a child of its parent.

Members

._requestingUpdate

No description provided.

._inUpdate

No description provided.

._mounted

No description provided.

._shown

No description provided.

._updater

No description provided.

._opacity

No description provided.

._UIEvents

No description provided.

._updateQueue

No description provided.

._nextUpdateQueue

No description provided.

._freedComponentIndicies

No description provided.

._components

No description provided.

._freedChildIndicies

No description provided.

._children

No description provided.

._fullChildren

No description provided.

._parent

No description provided.

._id

No description provided.

._transformID

No description provided.

._sizeID

No description provided.