@physion/app / Exports / SpringNode
Class: SpringNode
IMPORTANT: x, y and angle properties don't make sense for SpringNode.
Hierarchy
-
↳
SpringNode
Constructors
constructor
• new SpringNode(bodyNodeAid?, bodyNodeBid?, anchorA?, anchorB?, length?): SpringNode
Parameters
| Name | Type | Default value |
|---|---|---|
bodyNodeAid | string | defaultBodyNodeId |
bodyNodeBid | string | defaultBodyNodeId |
anchorA | IPoint | undefined |
anchorB | IPoint | undefined |
length | number | defaultLength |
Returns
Overrides
Properties
userData
• userData: Record<string, unknown>
Inherited from
EVT_CHILD_ADDED
▪ Static Readonly EVT_CHILD_ADDED: "childAdded"
The name of the event that is emitted whenever a child is added to this node.
The argument supplied is the child that was just added to this node.
Inherited from
EVT_CHILD_REMOVED
▪ Static Readonly EVT_CHILD_REMOVED: "childRemoved"
The name of the event that is emitted whenever a child is removed from this node.
The argument supplied is the child that was just removed from this node.
Inherited from
GraphicsNode.EVT_CHILD_REMOVED
EVT_CHILD_REORDERED
▪ Static Readonly EVT_CHILD_REORDERED: "childReordered"
The name of the event that is emitted whenever a child of this node is reordered.
The arguments supplied are: (1) The child that was just reordered (2) the old index of the child and (3) the new index of the child.
Inherited from
GraphicsNode.EVT_CHILD_REORDERED
EVT_NAME_CHANGED
▪ Static Readonly EVT_NAME_CHANGED: "nameChanged"
The name of the event that is emitted whenever the name of this object changes.
The argument suplied is the new CoreObject.name of the object.
Inherited from
EVT_PROPERTY_CHANGED
▪ Static Readonly EVT_PROPERTY_CHANGED: "propertyChanged"
The name of the event that is emitted whenever a property of this object changes.
The arguments supplied are: (1) The name of the property that has changed and (2) the new value of that property.
Inherited from
GraphicsNode.EVT_PROPERTY_CHANGED
EVT_TRANSFORM_CHANGED
▪ Static Readonly EVT_TRANSFORM_CHANGED: "transformChanged"
The name of the event that is emitted whenever the x, y or angle properties of this Node are changed.
Note that this event is not emitted when x, y or angle properties are changed as a result of
an update().
Inherited from
GraphicsNode.EVT_TRANSFORM_CHANGED
ID_LENGTH
▪ Static Readonly ID_LENGTH: 12
Inherited from
MAX_NAME_LENGTH
▪ Static Readonly MAX_NAME_LENGTH: 128
Inherited from
Accessors
alpha
• get alpha(): number
Node's alpha
This value is between 0 (transparent) and 1.0 (opaque). This property can be considered as the "master" opacity of the node. Defaults to 1 (fully opaque)
Returns
number
Inherited from
GraphicsNode.alpha
• set alpha(v): void
Parameters
| Name | Type |
|---|---|
v | number |
Returns
void
Inherited from
GraphicsNode.alpha
anchorA
• get anchorA(): IPoint
Returns
IPoint
• set anchorA(v): void
Parameters
| Name | Type |
|---|---|
v | IPoint |
Returns
void
anchorB
• get anchorB(): IPoint
Returns
IPoint
• set anchorB(v): void
Parameters
| Name | Type |
|---|---|
v | IPoint |
Returns
void
angle
• get angle(): number
Node's angle (in degrees)
Returns
number
Overrides
GraphicsNode.angle
• set angle(v): void
Parameters
| Name | Type |
|---|---|
v | number |
Returns
void
Overrides
GraphicsNode.angle
blendMode
• get blendMode(): BLEND_MODES
Returns
BLEND_MODES
Inherited from
GraphicsNode.blendMode
• set blendMode(v): void
Parameters
| Name | Type |
|---|---|
v | BLEND_MODES |
Returns
void
Inherited from
GraphicsNode.blendMode
bodyNodeA
• get bodyNodeA(): undefined | BodyNode
Returns
undefined | BodyNode
bodyNodeAid
• get bodyNodeAid(): string
Returns
string
• set bodyNodeAid(v): void
Parameters
| Name | Type |
|---|---|
v | string |
Returns
void
bodyNodeB
• get bodyNodeB(): undefined | BodyNode
Returns
undefined | BodyNode
bodyNodeBid
• get bodyNodeBid(): string
Returns
string
• set bodyNodeBid(v): void
Parameters
| Name | Type |
|---|---|
v | string |
Returns
void
childCount
• get childCount(): number
Returns the number of children this node contains.
Returns
number
Inherited from
GraphicsNode.childCount
children
• get children(): Node[]
Returns the children of this node.
Returns
Node[]
Inherited from
GraphicsNode.children
damping
• get damping(): number
Returns
number
• set damping(v): void
Parameters
| Name | Type |
|---|---|
v | number |
Returns
void
fillAlpha
• get fillAlpha(): number
Returns
number
Inherited from
GraphicsNode.fillAlpha
• set fillAlpha(v): void
Parameters
| Name | Type |
|---|---|
v | number |
Returns
void
Inherited from
GraphicsNode.fillAlpha
fillColor
• get fillColor(): number
Returns
number
Inherited from
GraphicsNode.fillColor
• set fillColor(v): void
Parameters
| Name | Type |
|---|---|
v | number |
Returns
void
Inherited from
GraphicsNode.fillColor
fillMatrix
• get fillMatrix(): IMatrix
Returns
IMatrix
Inherited from
GraphicsNode.fillMatrix
• set fillMatrix(v): void
Parameters
| Name | Type |
|---|---|
v | IMatrix |
Returns
void
Inherited from
GraphicsNode.fillMatrix
fillStyle
• get fillStyle(): FillStyle
Returns
FillStyle
Inherited from
GraphicsNode.fillStyle
fillTexture
• get fillTexture(): string
Returns
string
Inherited from
GraphicsNode.fillTexture
• set fillTexture(v): void
Parameters
| Name | Type |
|---|---|
v | string |
Returns
void
Inherited from
GraphicsNode.fillTexture
flags
• get flags(): CoreObjectFlags
Returns
CoreObjectFlags
Inherited from
GraphicsNode.flags
graphics
• get graphics(): Graphics
Returns
Graphics
Inherited from
GraphicsNode.graphics
id
• get id(): string
Object's (unique) id
Note that the id of the object cannot be set (it is automatically assigned upon construction)
Returns
string
Inherited from
GraphicsNode.id
k
• get k(): number
Returns
number
• set k(v): void
Parameters
| Name | Type |
|---|---|
v | number |
Returns
void
length
• get length(): number
Returns
number
• set length(v): void
Parameters
| Name | Type |
|---|---|
v | number |
Returns
void
lineAlignment
• get lineAlignment(): number
Returns
number
Inherited from
GraphicsNode.lineAlignment
• set lineAlignment(v): void
Parameters
| Name | Type |
|---|---|
v | number |
Returns
void
Inherited from
GraphicsNode.lineAlignment
lineAlpha
• get lineAlpha(): number
The line alpha used when drawing the graphics.
Returns
number
Inherited from
GraphicsNode.lineAlpha
• set lineAlpha(v): void
Parameters
| Name | Type |
|---|---|
v | number |
Returns
void
Inherited from
GraphicsNode.lineAlpha
lineColor
• get lineColor(): number
The line color used when drawing the graphics.
Returns
number
Inherited from
GraphicsNode.lineColor
• set lineColor(v): void
Parameters
| Name | Type |
|---|---|
v | number |
Returns
void
Inherited from
GraphicsNode.lineColor
lineNative
• get lineNative(): boolean
Returns
boolean
Inherited from
GraphicsNode.lineNative
• set lineNative(v): void
Parameters
| Name | Type |
|---|---|
v | boolean |
Returns
void
Inherited from
GraphicsNode.lineNative
lineStyle
• get lineStyle(): LineStyle
Returns
LineStyle
Inherited from
GraphicsNode.lineStyle
lineWidth
• get lineWidth(): number
The line width used when drawing the graphics.
Returns
number
Inherited from
GraphicsNode.lineWidth
• set lineWidth(v): void
Parameters
| Name | Type |
|---|---|
v | number |
Returns
void
Inherited from
GraphicsNode.lineWidth
metaObject
• get metaObject(): MetaObject
Returns the MetaObject that describes this class
Returns
Overrides
GraphicsNode.metaObject
name
• get name(): string
The object's name
The object's name is a free text value which defaults to an empty string.
Note that when the name of the object changes, the CoreObject.EVT_NAME_CHANGED signal will be emitted.
Returns
string
Inherited from
GraphicsNode.name
• set name(v): void
Parameters
| Name | Type |
|---|---|
v | string |
Returns
void
Inherited from
GraphicsNode.name
parent
• get parent(): undefined | Node
Returns the parent of this node (or undefined if this node has no parent).
Returns
undefined | Node
Inherited from
GraphicsNode.parent
scene
• get scene(): undefined | Scene
Returns
undefined | Scene
scripts
• get scripts(): IScript[]
Returns
IScript[]
Inherited from
GraphicsNode.scripts
• set scripts(v): void
Parameters
| Name | Type |
|---|---|
v | IScript[] |
Returns
void
Inherited from
GraphicsNode.scripts
ttl
• get ttl(): number
Node's time-to-live, in milliseconds.
A value of -1 (the default) means this node has no ttl and will never be automatically removed. Any other value counts down while the simulation is running; once it reaches 0 the node (and any nodes that depend on it) is removed from the Scene.
Has no effect on the Scene node itself, which never counts down or gets removed via ttl.
Returns
number
Inherited from
GraphicsNode.ttl
• set ttl(v): void
Parameters
| Name | Type |
|---|---|
v | number |
Returns
void
Inherited from
GraphicsNode.ttl
visualFilters
• get visualFilters(): IVisualFilters
The visual effects drawn over this node and its children, keyed by types.VisualFilterKey. See VisualFiltersMixin.
Returns
IVisualFilters
Inherited from
GraphicsNode.visualFilters
• set visualFilters(v): void
Parameters
| Name | Type |
|---|---|
v | IVisualFilters |
Returns
void
Inherited from
GraphicsNode.visualFilters
width
• get width(): number
Returns
number
• set width(v): void
Parameters
| Name | Type |
|---|---|
v | number |
Returns
void
x
• get x(): number
Node's x position (in meters)
Returns
number
Overrides
GraphicsNode.x
• set x(v): void
Parameters
| Name | Type |
|---|---|
v | number |
Returns
void
Overrides
GraphicsNode.x
y
• get y(): number
Node's y position (in meters)
Returns
number
Overrides
GraphicsNode.y
• set y(v): void
Parameters
| Name | Type |
|---|---|
v | number |
Returns
void
Overrides
GraphicsNode.y
Methods
addChild
▸ addChild(child): boolean
Adds the given child to this node.
If the given child is already contained in this node or it already has a Node.parent then this method will fail (false will be returned).
Otherwise the child will be added to this node and the Node.EVT_CHILD_ADDED signal will be emitted.
Parameters
| Name | Type | Description |
|---|---|---|
child | Node | The child to be added to this node. |
Returns
boolean
True on success otherwise false.
Inherited from
addChildren
▸ addChildren(children): void
Convenience method for adding multiple children to this node.
Parameters
| Name | Type |
|---|---|
children | Node[] |
Returns
void
Inherited from
addScript
▸ addScript(assetId, params?): undefined | IScript
Adds a new script to this node.
Convenience wrapper around the scripts property, which validates the entry and rejects it if
malformed. An entry whose asset is not available yet stays inert until it is.
Parameters
| Name | Type | Description |
|---|---|---|
assetId | string | The id of the script's TextAsset. |
params | ScriptParams | Initial values for the script's editable properties. |
Returns
undefined | IScript
A copy of the added script entry, or undefined if it was rejected.
Use its id with getNodeScript() or removeScript().
Inherited from
autoAdjustFillTexture
▸ autoAdjustFillTexture(): Promise<void>
Returns
Promise<void>
Inherited from
GraphicsNode.autoAdjustFillTexture
callMethodForAllNodeScripts
▸ callMethodForAllNodeScripts<T>(methodName, ...args): void
Type parameters
| Name | Type |
|---|---|
T | extends NodeScriptMethodName |
Parameters
| Name | Type |
|---|---|
methodName | T |
...args | Parameters<NonNullable<INodeScriptValue[T]>> |
Returns
void
Inherited from
GraphicsNode.callMethodForAllNodeScripts
canAddChild
▸ canAddChild(child): boolean
Returns true if the given child can be added to this node
Parameters
| Name | Type |
|---|---|
child | Node |
Returns
boolean
Inherited from
canRemoveChild
▸ canRemoveChild(child): boolean
Returns true if the given child can be removed from this node
Parameters
| Name | Type |
|---|---|
child | Node |
Returns
boolean
Inherited from
childIndex
▸ childIndex(child): number
Returns the index of the given child (or -1 if child is not contained in thie node).
Parameters
| Name | Type |
|---|---|
child | Node |
Returns
number
Inherited from
clone
▸ clone(): SpringNode
Creates and returns a clone of this node.
The clone returned will have the same property values as this node except from its CoreObject.id.
Returns
A clone of this node.
Inherited from
containsChild
▸ containsChild(child): boolean
Returns true if this node contains the given child
Parameters
| Name | Type |
|---|---|
child | Node |
Returns
boolean
Inherited from
copyFillTextureFrom
▸ copyFillTextureFrom(source): void
Copies the source's already-resolved texture directly, instead of just the fillTexture id (which would force a fresh async reload and flash the default white fill in the meantime).
Note: this node may not be attached to a scene yet, so don't call updateFillTexture() here to "double check" - it can't find its asset without a scene and would reset us back to white. onEnterScene() re-resolves the texture once the node actually gets attached.
Parameters
| Name | Type |
|---|---|
source | GraphicsNode |
Returns
void
Inherited from
GraphicsNode.copyFillTextureFrom
destroy
▸ destroy(): void
Returns
void
Inherited from
findAncestorByClassName
▸ findAncestorByClassName(className): undefined | Node
Parameters
| Name | Type |
|---|---|
className | string |
Returns
undefined | Node
Inherited from
GraphicsNode.findAncestorByClassName
findChildById
▸ findChildById(id): undefined | Node
Finds and returns the child with the given id.
Parameters
| Name | Type | Description |
|---|---|---|
id | string | The CoreObject.id of the child to search for. |
Returns
undefined | Node
The child with the given id or undefined if no such child exists.
Inherited from
findChildByName
▸ findChildByName(name): undefined | Node
Finds and returns the first child node with the given name.
Parameters
| Name | Type | Description |
|---|---|---|
name | string | The CoreObject.name of the child to search for. |
Returns
undefined | Node
The first child with the given name or undefined if no such child exists.
Inherited from
findDescendantById
▸ findDescendantById(id): undefined | Node
Finds and returns the descendant with the given id.
Parameters
| Name | Type | Description |
|---|---|---|
id | string | The CoreObject.id of the descendant to search for. |
Returns
undefined | Node
The descendant with the given id or undefined if no such descendant exists.
Inherited from
GraphicsNode.findDescendantById
findSceneAssetById
▸ findSceneAssetById(id): undefined | Asset
Finds and returns the asset specified by the given id. Note that the node needs to be parented to a Scene for this method to work.
Parameters
| Name | Type | Description |
|---|---|---|
id | string | The id of the asset to search for. |
Returns
undefined | Asset
The matched Asset of undefined if no such asset exists in the scene.
Inherited from
GraphicsNode.findSceneAssetById
findSceneAssetByName
▸ findSceneAssetByName(name): undefined | Asset
Finds and returns the asset specified by the given name. Note that the node needs to be parented to a Scene for this method to work. Asset names are not unique, so if more than one asset shares the given name the first match is returned.
Parameters
| Name | Type | Description |
|---|---|---|
name | string | The name of the asset to search for. |
Returns
undefined | Asset
The matched Asset or undefined if no such asset exists in the scene.
Inherited from
GraphicsNode.findSceneAssetByName
findSceneNode
▸ findSceneNode(): undefined | Node
Uses the Node.findAncestorByClassName to find the Scene that this node is added to. If this node has not yet been added to a scene then this method will return undefined.
Returns
undefined | Node
Inherited from
fromScreen
▸ fromScreen(position, from?, skipUpdate?): IPointData
Parameters
| Name | Type |
|---|---|
position | IPoint |
from? | Node |
skipUpdate? | boolean |
Returns
IPointData
Inherited from
getAncestors
▸ getAncestors(): Node[]
Returns the ancestors of this node
Returns
Node[]
Inherited from
getAssetIds
▸ getAssetIds(): string[]
Returns the ids of the assets that are used by this Node.
Returns
string[]
The ids of the assets that are used by this Node.
Inherited from
getBoundingRect
▸ getBoundingRect(): Rectangle
Returns the bounding rectangle of this node in local coordinates.
The default implementation returns the local bounds of the underlying PIXI container but subclasses can re-implement this method to return their custom bounding rectangle.
Returns
Rectangle
Inherited from
getDependencies
▸ getDependencies(): Node[]
Returns the nodes this node depends on. If this node is not added to a [[Scene]] then an empty array will be returned.
Returns
Node[]
Array of nodes this node depends on.
Inherited from
getDependencyIds
▸ getDependencyIds(): string[]
Returns the IDs of all nodes this node depends on. Subclasses that have dependencies (e.g. JointNode) should re-implement this method and return the IDs of the nodes that they depend on. The default implementation returns an empty array.
Returns
string[]
Array of node IDs this node depends on.
Overrides
getDependents
▸ getDependents(): Node[]
Returns all Nodes that depend on this node. If this node is not added to a [[Scene]] then an empty array will be returned.
Returns
Node[]
Array of Nodes that have this node as a dependency
Inherited from
getDescendants
▸ getDescendants(reversed?): Node[]
Returns the descendants of this node.
A descendant is node that has this node as an ancestor. Consider for example the following tree of nodes:
- NodeA
- NodeB
- NodeD
- NodeE
- NodeC
- NodeB
If we ask for the descendants of NodeA we'll get back: [NodeB, NodeD, NodeE, NodeC]
If reversed is set to true then this method will return the reversed descendants. For the example above, that would be: [NodeC, NodeE, NodeD, NodeB, NodeA]. Note that the first item of the reversed descendants has the highest z-index.
Parameters
| Name | Type | Default value |
|---|---|---|
reversed | boolean | false |
Returns
Node[]
A list of this node's descendants
Inherited from
getDescendantsMap
▸ getDescendantsMap(): Map<string, Node>
Returns a map of all descendants keyed by their IDs.
This provides efficient lookup of any descendant node by its ID without having to traverse the tree multiple times.
Returns
Map<string, Node>
A Map where keys are node IDs and values are the corresponding Node objects
Inherited from
GraphicsNode.getDescendantsMap