new Object2D()
Base 2D object class, implements all the object positioning and scalling features.
- Source:
Members
beingDragged
Flag to indicate if the object is currently being dragged.
- Source:
children
List of children objects attached to the object.
- Source:
draggable
Indicates if its possible to drag the object around.
If true the onPointerDrag callback is used to update the state of the object.
- Source:
globalMatrix
Global transformation matrix multiplied by the parent matrix.
Used to transform the object before projecting into screen coordinates.
- Source:
inverseGlobalMatrix
Inverse of the global matrix.
Used to convert pointer input points into object coordinates.
- Source:
layer
Layer of this object, objects are sorted by layer value.
Lower layer value is draw first.
- Source:
matrix
Local transformation matrix applied to the object.
- Source:
matrixNeedsUpdate
If true the matrix is updated before rendering the object.
- Source:
onButtonDown
Callback method called when the pointer button is pressed down (single time).
- Source:
onButtonPressed
Callback method called while the pointer button is pressed.
Receives (pointer, viewport) as arguments.
- Source:
onButtonUp
Callback method called when the pointer button is released (single time).
- Source:
onPointerDrag
Callback method while the object is being dragged across the screen.
Receives (pointer, viewport, delta) as arguments. Delta is the movement of the pointer already translated into local object coordinates.
- Source:
onPointerEnter
Callback method called when the pointer enters the object.
Receives (pointer, viewport) as arguments.
- Source:
onPointerLeave
Callback method called when the was inside of the object and leaves the object.
Receives (pointer, viewport) as arguments.
- Source:
onPointerOver
Callback method while the pointer is over (inside) of the object.
Receives (pointer, viewport) as arguments.
- Source:
onUpdate
Callback method called every time before the object is draw into the canvas.
Can be used to run preparation code, move the object, etc.
- Source:
parent
Parent object, the object position is affected by its parent position.
- Source:
pointerInside
Flag indicating if the pointer is inside of the element.
Used to control object event.
- Source:
position
Position of the object.
- Source:
rotation
Rotation of the object relative to its center.
- Source:
scale
Scale of the object.
- Source:
uuid
UUID of the object.
- Source:
visible
Indicates if the object is visible.
- Source:
Methods
add(object)
Attach a children to the object.
Parameters:
| Name | Type | Description |
|---|---|---|
object |
Object to attach to this object. |
- Source:
draw(context)
Draw the object into the canvas.
Has to be implemented by underlying classes.
Parameters:
| Name | Type | Description |
|---|---|---|
context |
Canvas 2d drawing context. |
- Source:
isInside()
Check if a point is inside of the object.
- Source:
remove(object)
Remove object from the children list.
Parameters:
| Name | Type | Description |
|---|---|---|
object |
Object to be removed. |
- Source:
traverse(callback)
Traverse the object tree and run a function for all objects.
Parameters:
| Name | Type | Description |
|---|---|---|
callback |
Callback function that receives the object as parameter. |
- Source:
updateMatrix()
Update the transformation matrix of the object.
- Source: