WanaPlan

API Docs for: 2.7.0
Show:

SubSlopeComponent2D

Extends BaseComponent2D
Module: Component
Parent Module: Wanaplan

Summary

Creates and draws subslopes in 2D.

Constructor

SubSlopeComponent2D

Syntax

SubSlopeComponent2D

(
  • core
)

Summary

Parameters:

  • core wnp.Core

    Wanaplan core.

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

(
  • ctx
  • translation
  • zoom
)

Summary

Draws all the subslopes for the current floor on the canvas.

Parameters:

  • ctx CanvasRenderingContext2D

    Context 2D of the canvas.

  • translation BABYLON.Vector2

    The translation on the canvas.

  • zoom Number

    The current zoom of the canvas.

drawOnWall

Syntax

drawOnWall

(
  • ctx
  • translation
  • zoom
  • subSlope
)

Summary

Draws a single subslope.

Parameters:

  • ctx CanvasRenderingContext2D

    Context 2D of the canvas.

  • translation BABYLON.Vector2

    The translation on the canvas.

  • zoom Number

    The current zoom of the canvas.

  • subSlope SubSlopeStructure

    Concerned SubSlopeStructure.

enable

Inherited from BaseComponent2D:

Syntax

enable

()

Summary

Enables the component

getSubSlopes

Syntax

getSubSlopes

(
  • force
  • [structure]
)
SubSlopeStructure[]

Summary

Gets the list of subslopes for a given floor.

Parameters:

  • force Boolean

    Forces the subslopes to be updated.

  • [structure] FloorStructure optional

    The related floor. Currently selected floor by default.

Returns:

SubSlopeStructure[]:

The computed subslopes.

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.

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

When the popup of the roof has to be opened.

Parameters:

  • event Event

    The JS event.

  • target SubSlopeStructure

    The subslope structure hovered by the mouse.

  • mstate Object

    The state of the mouse.

  • data Object

    Data used for the drawing. Can be null or something else if you wish to override the function.

onDragEnd

Syntax

onDragEnd

(
  • event
  • target
  • mstate
  • data
)
private

Summary

When the mouse stops dragging the subslope.

Parameters:

  • event Event

    The JS event.

  • target SubSlopeStructure

    The subslope structure.

  • mstate Object

    The state of the mouse.

  • data Object

    Data used for the drawing. Can be null or something else if you wish to override the function.

onDragging

Syntax

onDragging

(
  • event
  • target
  • mstate
  • data
)
private

Summary

When the mouse is dragging the subslope.

Parameters:

  • event Event

    The JS event.

  • target SubSlopeStructure

    The subslope structure dragging by the mouse.

  • mstate Object

    The state of the mouse.

  • data Object

    Data used for the drawing. Can be null or something else if you wish to override the function.

onDragStart

Syntax

onDragStart

(
  • event
  • target
  • mstate
  • data
)
private

Summary

When the mouse begins to drag the subslope.

Parameters:

  • event Event

    The JS event.

  • target SubSlopeStructure

    The subslope structure dragged by the mouse.

  • mstate Object

    The state of the mouse.

  • data Object

    Data used for the drawing. Can be null or something else if you wish to override the function.

onDynamicDraw

Syntax

onDynamicDraw

(
  • ctx
  • translation
  • zoom
  • data
)

Summary

Triggered on dynamic canvas draw request

Parameters:

  • ctx CanvasRenderingContext2D

    2D Context of the canvas.

  • translation BABYLON.Vector2

    The translation on the canvas.

  • zoom Number

    The current zoom of the canvas.

  • data Object

    Data used for the drawing. Can be null or something else if you wish to override the function.

onEditSubSlope

Syntax

onEditSubSlope

() private

Summary

Function called when the user clicks on the subslope button and is in MODE_SUBSLOPE in the engine2D. Triggered on event wnp.engine2d.onEditSubSlope.

onHover

Syntax

onHover

(
  • event
  • target
  • mstate
  • data
)
private

Summary

When the mouse hovers over the subslope.

Parameters:

  • event Event

    The JS event.

  • target SubSlopeStructure

    The subslope structure hovered by the mouse.

  • mstate Object

    The state of the mouse.

  • data Object

    Data used for the drawing. Can be null or something else if you wish to override the function.

onLeave

Syntax

onLeave

(
  • event
  • target
  • mstate
  • data
)
private

Summary

When the mouse leaves the subslope.

Parameters:

  • event Event

    The JS event.

  • target SubSlopeStructure

    The subslope structure left by the mouse.

  • mstate Object

    The state of the mouse.

  • data Object

    Data used for the drawing. Can be null or something else if you wish to override the function.

onStaticDraw

Syntax

onStaticDraw

(
  • ctx
  • translation
  • zoom
  • data
)

Summary

Triggered on static canvas draw request

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).

splitSubSlope

Syntax

splitSubSlope

(
  • sSS
  • dSS
)

Summary

Splits a subslope into two subslopes, with the help of a subslope divider.

Parameters:

startListening

Inherited from BaseComponent2D:

Syntax

startListening

()

Summary

Calls all the event listeners.

stopListening

Inherited from BaseComponent2D:

Syntax

stopListening

()

Summary

Removes all the event listeners.

subslope-end

Syntax

subslope-end

() private

Summary

Function called when the user goes back to normal mode and skips the drawing of the subslope.

update

Inherited from BaseComponent2D:

Syntax

update

()

Summary

Generic update method, called on every frame

updateSubslopeFromRoof

Syntax

updateSubslopeFromRoof

(
  • roof
)

Summary

Copies the settings of the subslope contained in a roof to its parent subslope.

Parameters:

wnp.engine2d.onModeSubSlopeEnd

Syntax

wnp.engine2d.onModeSubSlopeEnd

() private

Summary

Function called when the user goes back to the MODE_NORMAL. Triggered on event wnp.engine2d.onModeSubSlopeEnd.

Properties

_applyHeightToAll

Syntax

_applyHeightToAll

Boolean private

Summary

Flag for height settings

_default

Syntax

_default

SubSlopeStructure private

Summary

Stores the properties that the user wants applied to all roofs (copied when creating a new subslope on a wall)

_HANDLERADIUS

Syntax

_HANDLERADIUS

Number

Summary

2D display style (radius).

Default: 10

_HANDLESTATICSTYLE

Syntax

_HANDLESTATICSTYLE

String

Summary

2D display style (static color).

Default: 'rgba(60,82,129,0.8)'

_HANDLESTYLE

Syntax

_HANDLESTYLE

String

Summary

2D display style (current handle style).

dragging

Syntax

dragging

Boolean

Summary

Flags when a subslope is being dragged

hovered

Syntax

hovered

SubSlopeStructure private

Summary

Subslope structure hovered by the mouse

name

Inherited from BaseComponent2D:

Syntax

name

String

Summary

Component name

needsUpdate

Syntax

needsUpdate

Boolean

Summary

Internal update flag

priority

Inherited from BaseComponent2D

Syntax

priority

Number private

Summary

Priority of the component for update callbacks.

Default: 100

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

subSlopes

Syntax

subSlopes

SubSlopeStructure[] private

Summary

Currently computed subSlopes for caching purposes.

Events

wnp.subslope.drag-end

Syntax

wnp.subslope.drag-end

Summary

Fired when the user stops dragging the subslope.