WanaPlan

API Docs for: 2.7.0
Show:

SwimmingPoolComponent2D

Extends BaseComponent2D
Module: Component
Parent Module: Wanaplan

Summary

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

Syntax

SwimmingPoolComponent2D

(
  • core
)

Summary

Parameters:

  • core Core

    Wanaplan Core.

Methods

changeAddStateSwimmingPool

Syntax

changeAddStateSwimmingPool

()

Summary

Change addstate when adding a temporary swimmingPool

compute

Syntax

compute

()

Summary

Computes all the swimmingPool structures.

computeSwimmingPool

Syntax

computeSwimmingPool

(
  • swimmingPool
)

Summary

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:

destroy

Inherited from BaseComponent2D:

Syntax

destroy

()

Summary

Method called when the component is destroyed

disable

Inherited from BaseComponent2D:

Syntax

disable

()

Summary

Disables the component

draw

Syntax

draw

(
  • swimmingPool
  • ctx
  • translation
  • zoom
  • selected
)

Summary

Draws the swimmingPool.

Parameters:

  • swimmingPool SwimmingPoolStructure

    The swimmingPool structure.

  • ctx Context2D

    The 2d context.

  • translation BABYLON.Vector2

    The translation of the canvas.

  • zoom Number

    The zoom level of the canvas.

  • selected Boolean

    True if the swimmingPool is currently selected, else false.

draw

Syntax

draw

(
  • swimmingPool
  • ctx
  • translation
  • zoom
  • selected
)

Summary

Draws the thickness of the swimmingPool.

Parameters:

  • swimmingPool SwimmingPoolStructure

    The swimmingPool structure.

  • ctx Context2D

    The 2d context.

  • translation BABYLON.Vector2

    The translation of the canvas.

  • zoom Number

    The zoom level of the canvas.

  • selected Boolean

    True if the swimmingPool is currently selected, else false.

drawTarget

Syntax

drawTarget

(
  • swimmingPool
  • ctx
  • zoom
)

Summary

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 SwimmingPoolStructure

    The swimmingPool structure.

  • ctx Context2D

    The 2d context.

  • zoom Number

    The zoom level of the canvas.

enable

Inherited from BaseComponent2D:

Syntax

enable

()

Summary

Enables the component

getTargeted

Inherited from BaseComponent2D:

Syntax

getTargeted

(
  • vector
)
Object

Summary

Finds out if the given position is over an element handled by the component

Parameters:

  • vector Vector

    A position, usually the cursor's one.

Returns:

Object:

The targeted element, or null if nothing is found.

initialize

Inherited from BaseComponent2D:

Syntax

initialize

()

Summary

Method called when Wanaplan is initialized. You don't need to call this method manually.

isPointInSwimmingPool

Syntax

isPointInSwimmingPool

(
  • vector
  • swimmingPool
)
Boolean

Summary

Tests the collision of a point with the area defined by the swimmingPool.

Parameters:

Returns:

Boolean:

True if the point collides, else false.

isPointInSwimmingPoolSide

Syntax

isPointInSwimmingPoolSide

(
  • vector
  • swimmingPool
)
Number | Boolean

Summary

Tests the collision of a point with the swimmingPool's edges.

Parameters:

Returns:

Number | Boolean:

False if the point does not collide with any of the swimmingPool's edges. Else the index of the side that collides.

onAddSwimmingPool

Syntax

onAddSwimmingPool

(
  • event
)

Summary

Create a new SwimmingPoolStructure

Parameters:

  • event Event

    The event caught.

onAddSwimmingPoolClick

Syntax

onAddSwimmingPoolClick

(
  • event
  • target
  • mstate
  • data
)

Summary

Adds a new swimmingPool on click. Triggered on event swimmingPoolComponent2D.add-swimmingPool.click

Parameters:

  • event Event

    The event caught.

  • target SwimmingPoolStructure

    The swimmingPool structure added.

  • mstate Object

    The current state of the pointer.

  • data Object

    Important data used to draw.

onContextChanged

Inherited from BaseComponent2D:

Syntax

onContextChanged

(
  • context
)

Summary

Method called when the context is switched (2D -> 3D or 3D -> 2D)

Parameters:

  • context String
    The new context

onContextMenu

Syntax

onContextMenu

(
  • event
  • target
  • mstate
  • data
)

Summary

Opens the context menu of the swimmingPool. Triggered on event swimmingPoolComponent2D.swimmingPool.click

Parameters:

  • event Event

    The event caught.

  • target SwimmingPoolStructure

    The swimmingPool structure.

  • mstate Object

    The current state of the pointer.

  • data Object

    Important data used to draw.

onContextMenuPropertyChanged

Syntax

onContextMenuPropertyChanged

(
  • target
  • property
  • value
)

Summary

Called when a value is changed in the context menu of the swimmingPool.

Parameters:

onContextMenuRemove

Syntax

onContextMenuRemove

(
  • target
)

Summary

Called when the user closes the context menu.

Parameters:

onDblClick

Syntax

onDblClick

(
  • event
  • target
  • mstate
  • data
)

Summary

Adds a point on the swimmingPool contour when the user double clicks on it. Triggered on event SwimmingPoolComponent2D.swimmingPool.dblclickswimmingPool

Parameters:

  • event Event

    The event caught.

  • target SwimmingPoolStructure

    The swimmingPool structure clicked.

  • mstate Object

    The current state of the pointer.

  • data Object

    Important data used to draw.

onDrag

Syntax

onDrag

(
  • event
  • target
  • mstate
  • data
)

Summary

Moves the swimmingPool when it is dragged. Triggered on event swimmingPoolComponent2D.swimmingPool.drag

Parameters:

  • event Event

    The event caught.

  • target SwimmingPoolStructure

    The swimmingPool structure dragged.

  • mstate Object

    The current state of the pointer.

  • data Object

    Important data used to draw.

onDragEnd

Syntax

onDragEnd

(
  • event
  • target
  • mstate
  • data
)

Summary

Calls computeSwimmingPool when the user stop dragging. Triggered on event swimmingPoolComponent2D.stair-swimmingPool.drag-end

Parameters:

  • event Event

    The event caught.

  • target SwimmingPoolStructure

    The swimmingPool structure dragged.

  • mstate Object

    The current state of the pointer.

  • data Object

    Important data used to draw.

onDragStart

Syntax

onDragStart

(
  • event
  • target
  • mstate
  • data
)

Summary

Adds new events callbacks when the dragging starts. Triggered on event swimmingPoolComponent2D.swimmingPool.drag-start

Parameters:

  • event Event

    The event caught.

  • target SwimmingPoolStructure

    The swimmingPool structure dragged.

  • mstate Object

    The current state of the pointer.

  • data Object

    Important data used to draw.

onHover

Syntax

onHover

(
  • event
  • target
  • mstate
  • data
)

Summary

Enables all the possible actions when the mouse hovers the swimmingPool. Triggered on event swimmingPoolComponent2D.swimmingPool.hover

Parameters:

  • event Event

    The event caught.

  • target SwimmingPoolStructure

    The swimmingPool structure hovered.

  • mstate Object

    The current state of the pointer.

  • data Object

    Important data used to draw.

onHoverSwimmingPool

Syntax

onHoverSwimmingPool

(
  • ctx
  • translation
  • zoom
  • data
)

Summary

Highlights the swimmingPool. Triggered on event swimmingPoolComponent2D.swimmingPool-hover.dynamic-draw

Parameters:

  • ctx CanvasRenderingContext2D

    2D context of the canvas.

  • translation BABYLON.Vector2

    The translation of the canvas.

  • zoom Number

    The current zoom of the canvas.

  • data Object

    Important data used to draw (null).

onLeave

Syntax

onLeave

(
  • event
  • target
  • mstate
  • data
)

Summary

Disables all the possible actions when the mouse leaves the swimmingPool. Triggered on event swimmingPoolComponent2D.swimmingPool.leave

Parameters:

  • event Event

    The event caught.

  • target SwimmingPoolStructure

    The swimmingPool structure leaved.

  • mstate Object

    The current state of the pointer.

  • data Object

    Important data used to draw.

onMouseMove

Syntax

onMouseMove

(
  • event
  • target
  • mstate
  • data
)

Summary

Moves the new swimmingPool to add when the mouse moves. Triggered on event swimmingPoolComponent2D.dynamic-stair.mouse-move

Parameters:

  • event Event

    The event caught.

  • target SwimmingPoolStructure

    The swimmingPool structure moved.

  • mstate Object

    The current state of the pointer.

  • data Object

    Important data used to draw.

startListening

Inherited from BaseComponent2D:

Syntax

startListening

()

Summary

Calls all the event listeners.

stopListening

Inherited from BaseComponent2D:

Syntax

stopListening

()

Summary

Removes all the event listeners.

update

Inherited from BaseComponent2D:

Syntax

update

()

Summary

Generic update method, called on every frame

updateElevation

Syntax

updateElevation

(
  • sp
)

Summary

Raises the elevation of the swimmingPool if necessary.

Parameters:

Properties

name

Inherited from BaseComponent2D:

Syntax

name

String

Summary

Component name

priority

Inherited from BaseComponent2D:

Syntax

priority

Number

Summary

Priority of the component in the "update" and "draw" routines

structure

Inherited from BaseComponent2D:

Syntax

structure

wnp.Structure

Summary

Structure file instance (shortcut to wanaplan.structure). This is the base object where the whole plan is saved