API Docs for: 2.7.3
Show:

API.e2D Class

Module: API
Parent Module: Wanaplan

API for wanaplan's 2D engine.

Constructor

API.e2D

()

Methods

getColorConstants

() Object

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

Returns:

Object:

Set of labeled colors

getDynamicCanvas

() HTMLCanvasElement

Gets the 2D dynamic canvas.

Returns:

HTMLCanvasElement:

the dynamic canvas.

getMousePos

() BABYLON.Vector2

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

Returns:

BABYLON.Vector2:

The mouse position

getNearestWallFromMousePos

(
  • structure
)
WallStructure

Returns the nearest wall from the mouse position.

Parameters:

Returns:

WallStructure:

The nearest wall among those of the chosen floor

getStaticCanvas

() HTMLCanvasElement

Gets the 2D static canvas.

Returns:

HTMLCanvasElement:

the static canvas.

getSymbols2D

() Object

Returns the symbols2D class for drawing things on the canvas.

Returns:

Object:

The symbols2D class

getTranslation

() BABYLON.Vector2

Returns the translation applied to the canvas.

Returns:

BABYLON.Vector2:

The translation (x, y).

getZoom

() Number

Returns the level of zoom currently applied to the canvas.

Returns:

Number:

The zoom, also called scale.

registerEventCb

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

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

()

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

()

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

(
  • precision
)

Changes the precision angle of the magnetism.

Parameters:

  • precision Float

    The new precision (in radians)

setTranslation

(
  • translation
)

Sets the translation to apply to the canvas.

Parameters:

  • translation BABYLON.Vector2

    The translation (x, y).

setZoom

(
  • zoom
)

Sets the zoom to apply to the canvas.

Parameters:

  • zoom Number

    The zoom, also called scale.

toRealCoord

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

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

(
  • id
)

Unregisters a callback for a specific event.

Parameters:

  • id String

    The unique identifier of the callback to remove.