SwimmingPoolComponent2D Class
SwimmingPool 2D. Component which handles :
- actions performed in 2D relatively to the SwimmingPool. Such as :
- adding a SwimmingPool
- displaying the SwimmingPool context menu
- translating the SwimmingPool
- modifying the shape of the SwimmingPool ( moving / adding / removing points / rotating )
- the 2D rendering of the SwimmingPool
Constructor
SwimmingPoolComponent2D
-
core
Parameters:
-
core
CoreWanaplan Core.
Item Index
Methods
- changeAddStateSwimmingPool
- compute
- computeSwimmingPool
- destroy
- disable
- draw
- draw
- drawTarget
- enable
- getTargeted
- initialize
- isPointInSwimmingPool
- isPointInSwimmingPoolSide
- onAddSwimmingPool
- onAddSwimmingPoolClick
- onContextChanged
- onContextMenu
- onContextMenuPropertyChanged
- onContextMenuRemove
- onDblClick
- onDrag
- onDragEnd
- onDragStart
- onHover
- onHoverSwimmingPool
- onLeave
- onMouseMove
- startListening
- stopListening
- update
- updateElevation
Methods
changeAddStateSwimmingPool
()
Change addstate when adding a temporary swimmingPool
compute
()
Computes all the swimmingPool structures.
computeSwimmingPool
-
swimmingPool
Checks the swimmingPool consistency and deletes it if the swimmingPool is no longer valid.
- merges vertices that are close enough.
- removes the swimmingPool if it has less than 3 vertices ( invalid swimmingPool ).
Parameters:
-
swimmingPool
SwimmingPoolStructureThe swimmingPool structure to compute.
destroy
()
disable
()
draw
-
swimmingPool
-
ctx
-
translation
-
zoom
-
selected
Draws the swimmingPool.
Parameters:
-
swimmingPool
SwimmingPoolStructureThe swimmingPool structure.
-
ctx
Context2DThe 2d context.
-
translation
BABYLON.Vector2The translation of the canvas.
-
zoom
NumberThe zoom level of the canvas.
-
selected
BooleanTrue if the swimmingPool is currently selected, else false.
draw
-
swimmingPool
-
ctx
-
translation
-
zoom
-
selected
Draws the thickness of the swimmingPool.
Parameters:
-
swimmingPool
SwimmingPoolStructureThe swimmingPool structure.
-
ctx
Context2DThe 2d context.
-
translation
BABYLON.Vector2The translation of the canvas.
-
zoom
NumberThe zoom level of the canvas.
-
selected
BooleanTrue if the swimmingPool is currently selected, else false.
drawTarget
-
swimmingPool
-
ctx
-
zoom
Draws the swimmingPool guide. It displays visual information on the swimmingPool, depending on the context. Basically, it draws a highlight when the mouse is hovering a swimmingPool element ( the whole swimmingPool, a side , a point, the rotation ring ).
Parameters:
-
swimmingPool
SwimmingPoolStructureThe swimmingPool structure.
-
ctx
Context2DThe 2d context.
-
zoom
NumberThe zoom level of the canvas.
enable
()
getTargeted
-
vector
Parameters:
-
vector
VectorA position, usually the cursor's one.
Returns:
The targeted element, or null if nothing is found.
initialize
()
isPointInSwimmingPool
-
vector
-
swimmingPool
Tests the collision of a point with the area defined by the swimmingPool.
Parameters:
-
vector
BABYLON.Vector2The point.
-
swimmingPool
SwimmingPoolStructureThe swimmingPool structure.
Returns:
True if the point collides, else false.
isPointInSwimmingPoolSide
-
vector
-
swimmingPool
Tests the collision of a point with the swimmingPool's edges.
Parameters:
-
vector
BABYLON.Vector2The point.
-
swimmingPool
SwimmingPoolStructureThe swimmingPool structure.
onAddSwimmingPool
-
event
Create a new SwimmingPoolStructure
Parameters:
-
event
EventThe event caught.
onAddSwimmingPoolClick
-
event
-
target
-
mstate
-
data
Adds a new swimmingPool on click.
Triggered on event swimmingPoolComponent2D.add-swimmingPool.click
Parameters:
-
event
EventThe event caught.
-
target
SwimmingPoolStructureThe swimmingPool structure added.
-
mstate
ObjectThe current state of the pointer.
-
data
ObjectImportant data used to draw.
onContextChanged
-
context
Parameters:
-
context
StringThe new context
onContextMenu
-
event
-
target
-
mstate
-
data
Opens the context menu of the swimmingPool.
Triggered on event swimmingPoolComponent2D.swimmingPool.click
Parameters:
-
event
EventThe event caught.
-
target
SwimmingPoolStructureThe swimmingPool structure.
-
mstate
ObjectThe current state of the pointer.
-
data
ObjectImportant data used to draw.
onContextMenuPropertyChanged
-
target
-
property
-
value
Called when a value is changed in the context menu of the swimmingPool.
Parameters:
-
target
SwimmingPoolStructureThe swimmingPool structure.
-
property
StringThe property changed.
-
value
Number | StringThe new value.
onContextMenuRemove
-
target
Called when the user closes the context menu.
Parameters:
-
target
SwimmingPoolStructureThe swimmingPool structure.
onDblClick
-
event
-
target
-
mstate
-
data
Adds a point on the swimmingPool contour when the user double clicks on it.
Triggered on event SwimmingPoolComponent2D.swimmingPool.dblclick
swimmingPool
Parameters:
-
event
EventThe event caught.
-
target
SwimmingPoolStructureThe swimmingPool structure clicked.
-
mstate
ObjectThe current state of the pointer.
-
data
ObjectImportant data used to draw.
onDrag
-
event
-
target
-
mstate
-
data
Moves the swimmingPool when it is dragged.
Triggered on event swimmingPoolComponent2D.swimmingPool.drag
Parameters:
-
event
EventThe event caught.
-
target
SwimmingPoolStructureThe swimmingPool structure dragged.
-
mstate
ObjectThe current state of the pointer.
-
data
ObjectImportant data used to draw.
onDragEnd
-
event
-
target
-
mstate
-
data
Calls computeSwimmingPool when the user stop dragging.
Triggered on event swimmingPoolComponent2D.stair-swimmingPool.drag-end
Parameters:
-
event
EventThe event caught.
-
target
SwimmingPoolStructureThe swimmingPool structure dragged.
-
mstate
ObjectThe current state of the pointer.
-
data
ObjectImportant data used to draw.
onDragStart
-
event
-
target
-
mstate
-
data
Adds new events callbacks when the dragging starts.
Triggered on event swimmingPoolComponent2D.swimmingPool.drag-start
Parameters:
-
event
EventThe event caught.
-
target
SwimmingPoolStructureThe swimmingPool structure dragged.
-
mstate
ObjectThe current state of the pointer.
-
data
ObjectImportant data used to draw.
onHover
-
event
-
target
-
mstate
-
data
Enables all the possible actions when the mouse hovers the swimmingPool.
Triggered on event swimmingPoolComponent2D.swimmingPool.hover
Parameters:
-
event
EventThe event caught.
-
target
SwimmingPoolStructureThe swimmingPool structure hovered.
-
mstate
ObjectThe current state of the pointer.
-
data
ObjectImportant data used to draw.
onHoverSwimmingPool
-
ctx
-
translation
-
zoom
-
data
Highlights the swimmingPool.
Triggered on event swimmingPoolComponent2D.swimmingPool-hover.dynamic-draw
Parameters:
-
ctx
CanvasRenderingContext2D2D context of the canvas.
-
translation
BABYLON.Vector2The translation of the canvas.
-
zoom
NumberThe current zoom of the canvas.
-
data
ObjectImportant data used to draw (null).
onLeave
-
event
-
target
-
mstate
-
data
Disables all the possible actions when the mouse leaves the swimmingPool.
Triggered on event swimmingPoolComponent2D.swimmingPool.leave
Parameters:
-
event
EventThe event caught.
-
target
SwimmingPoolStructureThe swimmingPool structure leaved.
-
mstate
ObjectThe current state of the pointer.
-
data
ObjectImportant data used to draw.
onMouseMove
-
event
-
target
-
mstate
-
data
Moves the new swimmingPool to add when the mouse moves.
Triggered on event swimmingPoolComponent2D.dynamic-stair.mouse-move
Parameters:
-
event
EventThe event caught.
-
target
SwimmingPoolStructureThe swimmingPool structure moved.
-
mstate
ObjectThe current state of the pointer.
-
data
ObjectImportant data used to draw.
startListening
()
stopListening
()
update
()
updateElevation
-
sp
Raises the elevation of the swimmingPool if necessary.
Parameters:
-
sp
SwimmingPoolStructureThe swimmingPool structure to update.