WanaPlan

API Docs for: 2.7.0
Show:

RoomComponent2D

Extends BaseComponent2D
Module: Component
Parent Module: Wanaplan

Summary

Rooms in 2D.

Constructor

RoomComponent2D

Syntax

RoomComponent2D

(
  • core
)

Summary

Parameters:

  • core Core

    The main engine.

Methods

computeRooms

Syntax

computeRooms

(
  • [structure=CurrentStructure]
  • [cycles]
)
private

Summary

Computes the rooms from the 2D geometry of the house. Based on the polygonMerger method.

Parameters:

  • [structure=CurrentStructure] FloorStructure optional

    The related floor. If not specified, the current active floor will be used.

  • [cycles] Cycles optional

    Optional parameter to specify pre-computed cycles (usually from the cache), in order to speed up the process.

destroy

Inherited from BaseComponent2D:

Syntax

destroy

()

Summary

Method called when the component is destroyed

disable

Inherited from BaseComponent2D:

Syntax

disable

()

Summary

Disables the component

dispatchRooms

Syntax

dispatchRooms

(
  • collection
  • structure
)
private

Summary

Copies the properties of another room collection to the current room collection.

Parameters:

  • collection String

    Can be either "internalRooms", or "externalRooms".

  • structure FloorStructure

    The related floor.

drawRoom

Syntax

drawRoom

(
  • room
  • ctx
  • translation
  • zoom
)

Summary

Draws a room.

Parameters:

  • room RoomStructure

    The room to draw.

  • ctx CanvasRenderingContext2D

    Canvas 2D context.

  • translation BABYLON.Vector2

    Canvas 2D translation.

  • zoom Number

    Canvas 2D zoom.

drawRooms

Syntax

drawRooms

(
  • ctx
  • translation
  • zoom
)

Summary

Draws all rooms for the current active floor.

Parameters:

  • ctx CanvasRenderingContext2D

    Canvas 2D context.

  • translation BABYLON.Vector2

    Canvas 2D translation.

  • zoom Number

    Canvas 2D zoom.

enable

Inherited from BaseComponent2D:

Syntax

enable

()

Summary

Enables the component

getAllSubSlopes

Syntax

getAllSubSlopes

(
  • structure
)
private

Summary

Returns a subslope list based on the rooms. Warning : the subslopes returned are not usable as is, they must be processed by "getSubSlope" from subSlopeComponent2D !

Parameters:

  • structure FloorStructure

    The related floor. If not specified, the current active floor will be used.

getElevationOfPoint

Syntax

getElevationOfPoint

(
  • vector
)
Number

Summary

Returns the height of the floor (=thickness+elevation) of the room in which the point is (0 if outside all rooms).

Parameters:

  • vector BABYLON.Vector2

    The point to test.

Returns:

Number:

The elevation of the floor in this point.

getInternalRooms

Syntax

getInternalRooms

() RoomStructure[] private

Summary

Returns the current computed internal rooms.

Returns:

RoomStructure[]:

The current internal rooms.

getInternalRooms

Syntax

getInternalRooms

() RoomStructure[] private

Summary

Returns the current computed external rooms.

Returns:

RoomStructure[]:

The current external rooms.

getTargeted

Inherited from BaseComponent2D:

Syntax

getTargeted

(
  • vector
)
Object

Summary

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.

identifyRooms

Syntax

identifyRooms

(
  • rooms0
  • rooms1
)
RoomStructure[]

Summary

Matches two sets of RoomStructure to pair those which look alike the most. This uses a custom (yet perfectible) matching algorithm based on overlapping areas.

Parameters:

Returns:

RoomStructure[]:

An array T such as T[i] = roomj implies : The room i in the smaller set is the most alike to the roomj in the bigger set. Length of T is : min(rooms0.length, rooms1.length) Example case : rooms0.length is smaller than rooms1.length : if T[i] = roomj, then the image of rooms0[i] is roomj, and roomj is taken from rooms1.

initialize

Inherited from BaseComponent2D:

Syntax

initialize

()

Summary

Method called when Wanaplan is initialized. You don't need to call this method manually.

isPointInRooms

Syntax

isPointInRooms

(
  • vector
)
RoomStructure

Summary

Determines if a point is inside the polygon of one of the currently displayed rooms.

Parameters:

  • vector BABYLON.Vector2

    The point to test.

Returns:

RoomStructure:

The room in which the point is located, or null if it is outside every room.

onContextChanged

Inherited from BaseComponent2D:

Syntax

onContextChanged

(
  • context
)

Summary

Method called when the context is switched (2D -> 3D or 3D -> 2D)

Parameters:

  • context String
    The new context

startListening

Inherited from BaseComponent2D:

Syntax

startListening

()

Summary

Calls all the event listeners.

stopListening

Inherited from BaseComponent2D:

Syntax

stopListening

()

Summary

Removes all the event listeners.

update

Inherited from BaseComponent2D:

Syntax

update

()

Summary

Generic update method, called on every frame

Properties

displayRoomMesure

Syntax

displayRoomMesure

Boolean

Summary

Flag to display/hide room measures.

Default: true

displayRoomName

Syntax

displayRoomName

Boolean

Summary

Flag to display/hide room names.

Default: true

externalRooms

Syntax

externalRooms

RoomStructure[] private

Summary

Temporary storage of the 2D external rooms.

internalRooms

Syntax

internalRooms

RoomStructure[] private

Summary

Temporary storage of the 2D internal rooms.

name

Inherited from BaseComponent2D:

Syntax

name

String

Summary

Component name

priority

Inherited from BaseComponent2D

Syntax

priority

Number private

Summary

Priority of the component for update callbacks.

Default: 9

rooms

Syntax

rooms

RoomStructure[] private

Summary

Temporary storage of the 2D computed rooms.

structure

Inherited from BaseComponent2D:

Syntax

structure

wnp.Structure

Summary

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

useCache

Syntax

useCache

Boolean private

Summary

Flag signaling if we can use the previously computed rooms stored in the cache. For speed up purposes.