API Docs for: 2.7.3
Show:

RoofComponent2D Class

Extends BaseComponent2D
Module: Component
Parent Module: Wanaplan

2D Roof Edition Component.

Constructor

RoofComponent2D

(
  • core
)

Parameters:

  • core Core

    The main engine.

Methods

adjustOverhangs

(
  • [ref]
)
private

Adjusts all overhangs so they fit with neighbors' overhangs

Parameters:

  • [ref] RoofStructure optional

    Reference roof with which all other overhangs must fit (default is roof with smallest overhang)

closeAllRoofCuts

() private

Close any open roof popups.

destroy

()

Inherited from BaseComponent2D:

Method called when the component is destroyed

disable

()

Inherited from BaseComponent2D:

Disables the component

drawMeasures

(
  • ctx
  • translation
  • zoom
  • roof
)
private

Draws measures of the roof overhangs.

Parameters:

  • ctx CanvasRenderingContext2D

    Context 2D of the canvas.

  • translation BABYLON.Vector2

    The translation on the canvas.

  • zoom Number

    The current zoom of the canvas.

  • roof RoofStructure

    the roof for which to draw the overhang measures.

drawRoof

(
  • ctx
  • translation
  • zoom
  • roof
)
private

Draws a roof as a polygon. If hovered by the mouse, enlarge line width on relevant overhang.

Parameters:

enable

()

Inherited from BaseComponent2D:

Enables the component

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.

insertRaccordPoints

(
  • origpoints
  • points
  • raccord
)
private

Inserts points of connection in parameter to roof points

Parameters:

  • origpoints BABYLON.Vector2

    array of points of the roof before computing connections.

  • points BABYLON.Vector2

    array of points of the roof (already with some connections).

  • raccord BABYLON.Vector2[]

    the connection to add to the points array.

joinAllRoofs

(
  • subSlopes
)

Compute roof offets so that opposite roofs extend to form a ridge

Parameters:

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 RoofStructure

    The roof 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 roof.

Parameters:

  • event Event

    The JS event.

  • target RoofStructure

    The roof 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 roof. Applies magnetism on overhangs.

Parameters:

  • event Event

    The JS event.

  • target RoofStructure

    The roof 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.

onDragStart

(
  • event
  • target
  • mstate
  • data
)
private

When the mouse begins to drag the roof.

Parameters:

  • event Event

    The JS event.

  • target RoofStructure

    The roof 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.

onHover

(
  • event
  • target
  • mstate
  • data
)
private

When the mouse hovers the roof (overhangs only because inside is managed by subslopeComponent).

Parameters:

  • event Event

    The JS event.

  • target RoofStructure

    The roof 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.

onLeave

(
  • event
  • target
  • mstate
  • data
)
private

When the mouse leaves the roof.

Parameters:

  • event Event

    The JS event.

  • target RoofStructure

    The roof 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.

onStaticDraw

(
  • ctx
  • translation
  • zoom
)
private

Draws the roofs.

Parameters:

  • ctx CanvasRenderingContext2D

    Context 2D of the canvas.

  • translation BABYLON.Vector2

    The translation on the canvas.

  • zoom Number

    The current zoom of the canvas.

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

displayInfo

Boolean private

If we want to display info on truss roofs or not

Default: true

dragging

Number private

Id of the roof being dragged (-1 if none)

hovered

RoofStructure private

Roof structure hovered by the mouse

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