API Docs for: 2.7.3
Show:

StairwayComponent2D Class

Extends BaseComponent2D
Module: Component
Parent Module: Wanaplan

Stairway Component 2D.

Constructor

StairwayComponent2D

(
  • core
)

Parameters:

  • core wnp.Core

    Wanaplan.

Methods

destroy

()

Inherited from BaseComponent2D:

Method called when the component is destroyed

disable

()

Inherited from BaseComponent2D:

Disables the component

draw

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

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

(
  • stairway
  • ctx
  • translation
  • zoom
)
private

Draw a stairway.

Parameters:

drawTargetSpiral

(
  • stairway
  • ctx
  • translation
  • zoom
)
private

Draw a spiral stairway.

Parameters:

enable

()

Inherited from BaseComponent2D:

Enables the component

finalizeTmpStairway

() private

Finalizes to build the stairway, and creates the hopper.

getTargeted

(
  • vector
)
Object

Inherited from BaseComponent2D:

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:

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

onAddStairway

(
  • event
)
private

Add a stairway.

Parameters:

  • event Event

    The event receive with the basics data.

onAddStairwayClick

(
  • event
  • target
  • mstate
  • data
)
private

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

(
  • context
)

Inherited from BaseComponent2D:

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

Parameters:

  • context String
    The new context

onContextMenu

(
  • event
  • target
  • mstate
  • data
)
private

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

(
  • event
  • target
  • value
)
private

When a value is changed.

Parameters:

onContextMenuRemove

(
  • target
)
private

When the user remove the context menu.

Parameters:

onDoubleClick

(
  • event
  • target
  • mstate
  • data
)
private

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

(
  • event
  • target
  • mstate
  • data
)
private

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

(
  • event
  • target
  • mstate
  • data
)
private

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

(
  • event
  • target
  • mstate
  • data
)
private

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

(
  • event
  • target
  • mstate
  • data
)
private

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

(
  • event
  • target
  • mstate
  • data
)
private

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

(
  • event
  • target
  • mstate
  • data
)
private

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

(
  • ctx
  • translation
  • zoom
  • data
)
private

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

(
  • event
)
private

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

(
  • event
  • target
  • mstate
  • data
)
private

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

(
  • ctx
  • translation
  • zoom
  • data
)
private

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

(
  • event
  • target
  • mstate
  • data
)
private

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

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

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

(
  • event
  • target
  • mstate
  • data
)
private

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

(
  • origin
  • stairway
)
private

Add the magnetism on the stairway.

Parameters:

  • origin BABYLON.Vector2

    The origin of the point.

  • stairway BABYLON.stairwayStructure

    The stairway structure.

onStaticDraw

(
  • ctx
  • translation
  • zoom
  • data
)
private

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

() private

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

startListening

()

Inherited from BaseComponent2D:

Calls all the event listeners.

stopListening

()

Inherited from BaseComponent2D:

Removes all the event listeners.

update

()

Inherited from BaseComponent2D:

Generic update method, called on every frame

Properties

name

String

Inherited from BaseComponent2D:

Component name

priority

Number

Inherited from BaseComponent2D:

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

structure

wnp.Structure

Inherited from BaseComponent2D:

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

Events

wnp.engine2d.onAddStairway

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.