RoomComponent2D Class
Rooms in 2D.
Constructor
RoomComponent2D
-
core
Parameters:
-
core
CoreThe main engine.
Item Index
Methods
Methods
computeRooms
-
[structure=CurrentStructure]
-
[cycles]
Computes the rooms from the 2D geometry of the house.
Based on the polygonMerger
method.
Parameters:
-
[structure=CurrentStructure]
FloorStructure optionalThe related floor. If not specified, the current active floor will be used.
-
[cycles]
Cycles optionalOptional parameter to specify pre-computed cycles (usually from the cache), in order to speed up the process.
destroy
()
disable
()
dispatchRooms
-
collection
-
structure
Copies the properties of another room collection to the current room collection.
Parameters:
-
collection
StringCan be either "internalRooms", or "externalRooms".
-
structure
FloorStructureThe related floor.
drawRoom
-
room
-
ctx
-
translation
-
zoom
Draws a room.
Parameters:
-
room
RoomStructureThe room to draw.
-
ctx
CanvasRenderingContext2DCanvas 2D context.
-
translation
BABYLON.Vector2Canvas 2D translation.
-
zoom
NumberCanvas 2D zoom.
drawRooms
-
ctx
-
translation
-
zoom
Draws all rooms for the current active floor.
Parameters:
-
ctx
CanvasRenderingContext2DCanvas 2D context.
-
translation
BABYLON.Vector2Canvas 2D translation.
-
zoom
NumberCanvas 2D zoom.
enable
()
getAllSubSlopes
-
structure
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
FloorStructureThe related floor. If not specified, the current active floor will be used.
getElevationOfPoint
-
vector
Returns the height of the floor (=thickness+elevation) of the room in which the point is (0 if outside all rooms).
Parameters:
-
vector
BABYLON.Vector2The point to test.
Returns:
The elevation of the floor in this point.
getInternalRooms
()
RoomStructure[]
private
Returns the current computed internal rooms.
Returns:
The current internal rooms.
getInternalRooms
()
RoomStructure[]
private
Returns the current computed external rooms.
Returns:
The current external rooms.
getTargeted
-
vector
Parameters:
-
vector
VectorA position, usually the cursor's one.
Returns:
The targeted element, or null if nothing is found.
identifyRooms
-
rooms0
-
rooms1
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:
-
rooms0
RoomStructure[]Set 0.
-
rooms1
RoomStructure[]Set 1.
Returns:
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
()
isPointInRooms
-
vector
Determines if a point is inside the polygon of one of the currently displayed rooms.
Parameters:
-
vector
BABYLON.Vector2The point to test.
Returns:
The room in which the point is located, or null if it is outside every room.
onContextChanged
-
context
Parameters:
-
context
StringThe new context
startListening
()
stopListening
()
update
()
Properties
structure
wnp.Structure
useCache
Boolean
private
Flag signaling if we can use the previously computed rooms stored in the cache. For speed up purposes.