WanaPlan

API Docs for: 2.7.0
Show:

StairwayComponent2D

Extends BaseComponent2D
Module: Component
Parent Module: Wanaplan

Summary

Stairway Component 2D.

Constructor

StairwayComponent2D

Syntax

StairwayComponent2D

(
  • core
)

Summary

Parameters:

  • core wnp.Core

    Wanaplan.

Methods

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

(
  • stairway
  • ctx
  • translation
  • zoom
  • tmpPoint
)
private

Summary

Draws a stairway.

Parameters:

  • stairway StairwayStructure

    The stairway structure.

  • ctx CanvasRenderingContext2D

    Context 2D of the canvas.

  • translation BABYLON.Vector2

    The translation on the canvas.

  • zoom Number

    The current zoom of the canvas.

  • tmpPoint BABYLON.Vector2

    The tamporary point.

drawTargetSpiral

Syntax

drawTargetSpiral

(
  • stairway
  • ctx
  • translation
  • zoom
)
private

Summary

Draw a stairway.

Parameters:

  • stairway StairwayStructure

    The stairway structure.

  • ctx CanvasRenderingContext2D

    Context 2D of the canvas.

  • translation BABYLON.Vector2

    The translation on the canvas.

  • zoom Number

    The current zoom of the canvas.

drawTargetSpiral

Syntax

drawTargetSpiral

(
  • stairway
  • ctx
  • translation
  • zoom
)
private

Summary

Draw a spiral stairway.

Parameters:

  • stairway StairwayStructure

    The stairway structure.

  • ctx CanvasRenderingContext2D

    Context 2D of the canvas.

  • translation BABYLON.Vector2

    The translation on the canvas.

  • zoom Number

    The current zoom of the canvas.

enable

Inherited from BaseComponent2D:

Syntax

enable

()

Summary

Enables the component

finalizeTmpStairway

Syntax

finalizeTmpStairway

() private

Summary

Finalizes to build the stairway, and creates the hopper.

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.

onAddStairway

Syntax

onAddStairway

(
  • event
)
private

Summary

Add a stairway.

Parameters:

  • event Event

    The event receive with the basics data.

onAddStairwayClick

Syntax

onAddStairwayClick

(
  • event
  • target
  • mstate
  • data
)
private

Summary

When the user add a point on the stairway with a simple click.

Parameters:

  • event Event

    The event catch.

  • target BABYLON.stairwayStructure

    The stairway structure.

  • mstate Object

    The state of the current move.

  • data Object

    Important data used for the 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
)
private

Summary

Handle all the item of the context menu.

Parameters:

  • event Event

    The event catch.

  • target BABYLON.stairwayStructure

    The stairway structure.

  • mstate Object

    The state of the current move.

  • data Object

    Important data used for the draw (null).

onContextMenuPropertyChanged

Syntax

onContextMenuPropertyChanged

(
  • event
  • target
  • value
)
private

Summary

When a value is changed.

Parameters:

onContextMenuRemove

Syntax

onContextMenuRemove

(
  • target
)
private

Summary

When the user remove the context menu.

Parameters:

onDoubleClick

Syntax

onDoubleClick

(
  • event
  • target
  • mstate
  • data
)
private

Summary

When the user double-clicks on the stairway, adds a new point.

Parameters:

  • event Event

    The event catch.

  • target BABYLON.stairwayStructure

    The stairway structure.

  • mstate Object

    The state of the current move.

  • data Object

    Important data used for the draw.

onDragEnd

Syntax

onDragEnd

(
  • event
  • target
  • mstate
  • data
)
private

Summary

When the user finish to drag the stairway.

Parameters:

  • event Event

    The event catch.

  • target BABYLON.stairwayStructure

    The stairway structure dragged.

  • mstate Object

    The state of the current move.

  • data Object

    Important data used for the draw.

onDragStair

Syntax

onDragStair

(
  • event
  • target
  • mstate
  • data
)
private

Summary

When the user drag a spiral stair.

Parameters:

  • event Event

    The event catch.

  • target BABYLON.stairwayStructure

    The spiral stairway structure dragged.

  • mstate Object

    The state of the current move.

  • data Object

    Important data used for the draw.

onDragStairSpiral

Syntax

onDragStairSpiral

(
  • event
  • target
  • mstate
  • data
)
private

Summary

When the user drag a spiral stair.

Parameters:

  • event Event

    The event catch.

  • target BABYLON.stairwayStructure

    The spiral stairway structure dragged.

  • mstate Object

    The state of the current move.

  • data Object

    Important data used for the draw.

onDragStart

Syntax

onDragStart

(
  • event
  • target
  • mstate
  • data
)
private

Summary

When the user start to drag the stair.

Parameters:

  • event Event

    The event catch.

  • target BABYLON.stairwayStructure

    The stairway structure leaved.

  • mstate Object

    The state of the current move.

  • data Object

    Important data used for the draw.

onDrawDragging

Syntax

onDrawDragging

(
  • event
  • target
  • mstate
  • data
)
private

Summary

Draws the stair when the user drag the stairway.

Parameters:

  • event Event

    The event catch.

  • target BABYLON.stairwayStructure

    The stairway structure dragged.

  • mstate Object

    The state of the current move.

  • data Object

    Important data used for the draw.

onDrawDragStart

Syntax

onDrawDragStart

(
  • event
  • target
  • mstate
  • data
)
private

Summary

Method call only on the drag start when the user draw, it allow to simulate a pen to draw the stairway.

Parameters:

  • event Event

    The event catch.

  • target BABYLON.stairwayStructure

    The stairway structure dragged.

  • mstate Object

    The state of the current move.

  • data Object

    Important data used for the draw.

onDynamicDraw

Syntax

onDynamicDraw

(
  • ctx
  • translation
  • zoom
  • data
)
private

Summary

Dynamic draw.

Parameters:

  • ctx CanvasRenderingContext2D

    Context 2D of the canvas.

  • translation BABYLON.Vector2

    The translation on the canvas.

  • zoom Number

    The current zoom of the canvas.

  • data Object

    Important data used for the draw (null).

onFloorAdded

Syntax

onFloorAdded

(
  • event
)
private

Summary

When the user adds a floor, the engine looks for the stairway in floor below and computes the hopper.

Parameters:

  • event Event

    The associated event.

onHover

Syntax

onHover

(
  • event
  • target
  • mstate
  • data
)
private

Summary

When hover.

Parameters:

  • event Event

    The event catch.

  • target BABYLON.stairwayStructure

    The stairway structure hovered.

  • mstate Object

    The state of the current move.

  • data Object

    Important data used for the draw.

onHoverStair

Syntax

onHoverStair

(
  • ctx
  • translation
  • zoom
  • data
)
private

Summary

When the user hovers the stairway.

Parameters:

  • ctx CanvasRenderingContext2D

    Context 2D of the canvas.

  • translation BABYLON.Vector2

    The translation on the canvas.

  • zoom Number

    The current zoom of the canvas.

  • data Object

    Important data used for the draw (null).

onHoverStairMouseMove

Syntax

onHoverStairMouseMove

(
  • event
  • target
  • mstate
  • data
)
private

Summary

When the user hover the stairway with the cursor.

Parameters:

  • event Event

    The event catch.

  • target BABYLON.stairwayStructure

    The stairway structure hovered.

  • mstate Object

    The state of the current move.

  • data Object

    Important data used for the draw.

onLeave

Syntax

onLeave

(
  • event
  • target
  • mstate
  • data
)
Boolean private

Summary

When the user leaves the stairway.

Parameters:

  • event Event

    The event catch.

  • target BABYLON.stairwayStructure

    The stairway structure leaved.

  • mstate Object

    The state of the current move.

  • data Object

    Important data used for the draw.

Returns:

Boolean:

false

onMouseMove

Syntax

onMouseMove

(
  • event
  • target
  • mstate
  • data
)
private

Summary

On the mousemove, in draw state, we create the temporary point (perpendicular to the last segment).

Parameters:

  • event Event

    The event catch.

  • target BABYLON.stairwayStructure

    The stairway structure.

  • mstate Object

    The state of the current move.

  • data Object

    Important data used for the draw.

onMouseMove

Syntax

onMouseMove

(
  • origin
  • stairway
)
private

Summary

Add the magnetism on the stairway.

Parameters:

  • origin BABYLON.Vector2

    The origin of the point.

  • stairway BABYLON.stairwayStructure

    The stairway structure.

onStaticDraw

Syntax

onStaticDraw

(
  • ctx
  • translation
  • zoom
  • data
)
private

Summary

Static draw.

Parameters:

  • ctx CanvasRenderingContext2D

    Context 2D of the canvas.

  • translation BABYLON.Vector2

    The translation on the canvas.

  • zoom Number

    The current zoom of the canvas.

  • data Object

    Important data used for the draw (null).

onStructureLoaded

Syntax

onStructureLoaded

() private

Summary

When the structure is loaded, we check the coherency of the structure.

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

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

Events

wnp.engine2d.onAddStairway

Syntax

wnp.engine2d.onAddStairway

Summary

Fired when the user requests the add of a stairway in the menu.

Event Payload:

  • stairwayType String

    Type of the stairway. Can be 'straight' or 'spiral'.

  • bearing Boolean

    Activates the bearing on the geometry.