API Docs for: 2.7.3
Show:

SubSlopeComponent2D Class

Extends BaseComponent2D
Module: Component
Parent Module: Wanaplan

Creates and draws subslopes in 2D.

Constructor

SubSlopeComponent2D

(
  • core
)

Parameters:

  • core wnp.Core

    Wanaplan core.

Methods

destroy

()

Inherited from BaseComponent2D:

Method called when the component is destroyed

disable

()

Inherited from BaseComponent2D:

Disables the component

draw

(
  • ctx
  • translation
  • zoom
)

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

(
  • ctx
  • translation
  • zoom
  • subSlope
)

Draws a single subslope.

Parameters:

enable

()

Inherited from BaseComponent2D:

Enables the component

getSubSlopes

(
  • force
  • [structure]
)
SubSlopeStructure[]

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

(
  • 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.

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

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

(
  • event
  • target
  • mstate
  • data
)
private

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

(
  • event
  • target
  • mstate
  • data
)
private

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

(
  • event
  • target
  • mstate
  • data
)
private

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

(
  • ctx
  • translation
  • zoom
  • data
)

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

() private

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

(
  • event
  • target
  • mstate
  • data
)
private

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

(
  • event
  • target
  • mstate
  • data
)
private

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

(
  • ctx
  • translation
  • zoom
  • data
)

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

(
  • sSS
  • dSS
)

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

Parameters:

startListening

()

Inherited from BaseComponent2D:

Calls all the event listeners.

stopListening

()

Inherited from BaseComponent2D:

Removes all the event listeners.

subslope-end

() private

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

update

()

Inherited from BaseComponent2D:

Generic update method, called on every frame

updateSubslopeFromRoof

(
  • roof
)

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

Parameters:

wnp.engine2d.onModeSubSlopeEnd

() private

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

Properties

_applyHeightToAll

Boolean private

Flag for height settings

_default

SubSlopeStructure private

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

_HANDLERADIUS

Number

2D display style (radius).

Default: 10

_HANDLESTATICSTYLE

String

2D display style (static color).

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

_HANDLESTYLE

String

2D display style (current handle style).

dragging

Boolean

Flags when a subslope is being dragged

hovered

SubSlopeStructure private

Subslope structure hovered by the mouse

name

String

Inherited from BaseComponent2D:

Component name

needsUpdate

Boolean

Internal update flag

priority

Number private

Inherited from BaseComponent2D

Priority of the component for update callbacks.

Default: 100

structure

wnp.Structure

Inherited from BaseComponent2D:

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

subSlopes

SubSlopeStructure[] private

Currently computed subSlopes for caching purposes.

Events

wnp.subslope.drag-end

Fired when the user stops dragging the subslope.