API.e2D Class
API for wanaplan's 2D engine.
Constructor
API.e2D
()
Item Index
Methods
getColorConstants
()
Object
Returns a set of colors used to display several things in 2D.
Returns:
Set of labeled colors
getDynamicCanvas
()
HTMLCanvasElement
Gets the 2D dynamic canvas
.
Returns:
the dynamic canvas.
getMousePos
()
BABYLON.Vector2
Returns the mouse position in the 2D plan coordinates. It will give you unexploitable results in 3D.
Returns:
The mouse position
getNearestWallFromMousePos
-
structure
Returns the nearest wall from the mouse position.
Parameters:
-
structure
FloorStructureThe floor for which to consider the walls
Returns:
The nearest wall among those of the chosen floor
getStaticCanvas
()
HTMLCanvasElement
Gets the 2D static canvas
.
Returns:
the static canvas.
getSymbols2D
()
Object
Returns the symbols2D class for drawing things on the canvas.
Returns:
The symbols2D class
getTranslation
()
BABYLON.Vector2
Returns the translation applied to the canvas.
Returns:
The translation (x, y).
getZoom
()
Number
Returns the level of zoom currently applied to the canvas.
Returns:
The zoom, also called scale.
registerEventCb
-
id
-
priority
-
evName
-
mode
-
objType
-
callback
-
[data]
Registers a callback for a specific event.
Parameters:
-
id
StringA unique identifier for this event (ex: "coreComponentWallClick").
-
priority
NumberThe priority for this event (defines callback call order).
-
evName
StringThe event name associated to the callback.
-
mode
NumberMode in which the event will be active (ex:
Core.MODE_NORMAL|Core.MODE_DRAG
). -
objType
ObjectThe type of object that must be targeted, or
null
. -
callback
FunctionThe function to call.
-
[data]
Object optionalData 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
FloatThe new precision (in radians)
setTranslation
-
translation
Sets the translation to apply to the canvas.
Parameters:
-
translation
BABYLON.Vector2The translation (x, y).
setZoom
-
zoom
Sets the zoom to apply to the canvas.
Parameters:
-
zoom
NumberThe zoom, also called scale.
toRealCoord
-
vector
-
[translation]
-
[zoom]
Transforms a vector from 2D plan coordinates to canvas coordinates.
Parameters:
-
vector
BABYLON.Vector2Plan coordinates.
-
[translation]
BABYLON.Vector2 optionalTranslation applied on the canvas.
-
[zoom]
BABYLON.Vector2 optionalZoom applied on the canvas.
Returns:
The vector transformed to canvas coordinates.
unregisterEventCb
-
id
Unregisters a callback for a specific event.
Parameters:
-
id
StringThe unique identifier of the callback to remove.