WanaPlan

API Docs for: 2.7.0
Show:

API.e2D

Module: API
Parent Module: Wanaplan

Summary

API for wanaplan's 2D engine.

Constructor

API.e2D

Syntax

API.e2D

()

Summary

Methods

getColorConstants

Syntax

getColorConstants

() Object

Summary

Returns a set of colors used to display several things in 2D.

Returns:

Object:

Set of labeled colors

getDynamicCanvas

Syntax

getDynamicCanvas

() HTMLCanvasElement

Summary

Gets the 2D dynamic canvas.

Returns:

HTMLCanvasElement:

the dynamic canvas.

getMousePos

Syntax

getMousePos

() BABYLON.Vector2

Summary

Returns the mouse position in the 2D plan coordinates. It will give you unexploitable results in 3D.

Returns:

BABYLON.Vector2:

The mouse position

getNearestWallFromMousePos

Syntax

getNearestWallFromMousePos

(
  • structure
)
WallStructure

Summary

Returns the nearest wall from the mouse position.

Parameters:

Returns:

WallStructure:

The nearest wall among those of the chosen floor

getStaticCanvas

Syntax

getStaticCanvas

() HTMLCanvasElement

Summary

Gets the 2D static canvas.

Returns:

HTMLCanvasElement:

the static canvas.

getSymbols2D

Syntax

getSymbols2D

() Object

Summary

Returns the symbols2D class for drawing things on the canvas.

Returns:

Object:

The symbols2D class

getTranslation

Syntax

getTranslation

() BABYLON.Vector2

Summary

Returns the translation applied to the canvas.

Returns:

BABYLON.Vector2:

The translation (x, y).

getZoom

Syntax

getZoom

() Number

Summary

Returns the level of zoom currently applied to the canvas.

Returns:

Number:

The zoom, also called scale.

registerEventCb

Syntax

registerEventCb

(
  • id
  • priority
  • evName
  • mode
  • objType
  • callback
  • [data]
)

Summary

Registers a callback for a specific event.

Parameters:

  • id String

    A unique identifier for this event (ex: "coreComponentWallClick").

  • priority Number

    The priority for this event (defines callback call order).

  • evName String

    The event name associated to the callback.

  • mode Number

    Mode in which the event will be active (ex: Core.MODE_NORMAL|Core.MODE_DRAG).

  • objType Object

    The type of object that must be targeted, or null.

  • callback Function

    The function to call.

  • [data] Object optional

    Data passed to the callback.

requestDynamicDraw

Syntax

requestDynamicDraw

()

Summary

Requests a redraw of the top "dynamic" canvas at the next frame. The top canvas is used to draw things that may need refreshing when the mouse moves. Typically, it is the symbols displayed when the mouse hovers something.

requestStaticDraw

Syntax

requestStaticDraw

()

Summary

Requests a redraw of the bottom "static" canvas at the next frame. The bottom canvas is used to draw things that don't usually need redrawing when the mouse moves, like the walls, the rooms, the grid etc... NB : The top "dynamic" canvas will also be redrawn

setMagnetismAnglePrecision

Syntax

setMagnetismAnglePrecision

(
  • precision
)

Summary

Changes the precision angle of the magnetism.

Parameters:

  • precision Float

    The new precision (in radians)

setTranslation

Syntax

setTranslation

(
  • translation
)

Summary

Sets the translation to apply to the canvas.

Parameters:

  • translation BABYLON.Vector2

    The translation (x, y).

setZoom

Syntax

setZoom

(
  • zoom
)

Summary

Sets the zoom to apply to the canvas.

Parameters:

  • zoom Number

    The zoom, also called scale.

toRealCoord

Syntax

toRealCoord

(
  • vector
  • [translation]
  • [zoom]
)
BABYLON.Vector2

Summary

Transforms a vector from 2D plan coordinates to canvas coordinates.

Parameters:

  • vector BABYLON.Vector2

    Plan coordinates.

  • [translation] BABYLON.Vector2 optional

    Translation applied on the canvas.

  • [zoom] BABYLON.Vector2 optional

    Zoom applied on the canvas.

Returns:

BABYLON.Vector2:

The vector transformed to canvas coordinates.

unregisterEventCb

Syntax

unregisterEventCb

(
  • id
)

Summary

Unregisters a callback for a specific event.

Parameters:

  • id String

    The unique identifier of the callback to remove.