RoomStructure Class
A room object. More info can be found in the Wanaplan Wiki.
Constructor
RoomStructure
()
Item Index
Methods
- add
- addFloorOnOvertures
- copy
- createFromCycle
- createWallPanes
- deserialize
- dispatchMaterials
- eql
- getBoundingBox
- getCenter
- getDefaultLabel
- getElementByName
- getFloor
- getLikelihood
- getOverlappingRectArea
- getRoomArea
- getWallPanes
- initialize
- isPointIn
- orientedArea
- processRoomArea
- reversePath
- serialize
- setColor
- setColorFromType
- setType
- toVec2Array
- update
- updatePaneMaterial
- updateReferences
Methods
add
-
propertyName
-
value
Returns:
addFloorOnOvertures
()
private
Adds floor on doors, or overtures that hit the ground, so there is no hole in the connection between 2 rooms.
copy
-
room
Copies a room.
WARNING: Beware of shared materials !
Parameters:
-
room
RoomStructureThe room to copy.
createFromCycle
-
cycle
Creates a room from a closed cycle of points.
Parameters:
-
cycle
PointStructure[]The cycle of points.
Returns:
The resulting room.
createWallPanes
()
WallPane3D[]
private
Creates the wall panes for the room. Basically, one side of the room polygon = 1 wall pane.
Returns:
The wall panes.
deserialize
-
hybrid
Deserializes the object.
Parameters:
-
hybrid
StringAn object issued from a serialization.
dispatchMaterials
()
private
Dispatches the materials to the wall panes. Takes the panesMaterials list, and finds out on which pane which material is most likely to be. The likelihood score is determined by the center and normal of the wallPane.
eql
-
room
Equal operator for 2 rooms. Compares the points of 2 rooms.
Parameters:
-
room
RoomStructureThe other room to compare with.
Returns:
True if this room points are the same as the points of the room in parameter (not necessarily in the same order).
getBoundingBox
()
BABYLON.BoundingBox
Returns the 2D not oriented Bounding Box.
Returns:
The Bounding Box.
getCenter
()
BABYLON.Vector2
Returns the center of the room.
Returns:
The 2D center of gravity of the room's polygon.
getDefaultLabel
()
Get the default label for a room based on type
getElementByName
-
name
-
collection
Parameters:
Returns:
getFloor
()
FloorStructure
Gets the floor referencing this object.
Returns:
The floor containing this structure, -1 if the object has not been added to any floor collection.
getLikelihood
-
room
Gives a score of likelihood between 2 rooms.
Parameters:
-
room
RoomStructureThe other room to compare with.
Returns:
An arbitrary number, usually less than 10. The higher it is, the more alike the rooms look.
getOverlappingRectArea
-
room
Determines the overlapping area of 2 rooms' bounding boxes.
Parameters:
-
room
RoomStructureThe other room to compare with.
Returns:
The overlapping area of bounding boxes.
getRoomArea
-
force
Returns the area of the room.
Parameters:
-
force
BooleanForces a recomputing of the room area.
Returns:
The room area.
getWallPanes
()
WallPane3D[]
Gets the Wall Panes (see Wanaplan API wiki for more info).
Returns:
The Wall Panes of the room.
initialize
()
private
isPointIn
-
vector
Determines if a point is in the room.
Parameters:
-
vector
BABYLON.Vector2The point in plan coordinates.
Returns:
True if the point is in the room.
orientedArea
()
Number
Returns the oriented area of the room.
Returns:
The room area, negative if the room is counterclockwise.
reversePath
()
Flips a room. If it was counterclockwise, it becomes clockwise.
serialize
()
Object
Returns:
setColor
-
The
Sets the color of a room.
Parameters:
-
The
Stringhexadecimal representation of the color.
setColorFromType
()
Automatically maps the color of the room based on its type.
toVec2Array
()
BABYLON.Vector2
Returns a BABYLON.Vector2 array of the room points.
Returns:
The array of points.
update
()
updatePaneMaterial
-
pane
-
material
Updates a wallPane with a new material and refreshes its center and normal. This function must be called after dispatchMaterials, if there was a 2D -> 3D switch.
Parameters:
-
pane
WallPane3DThe pane to update.
-
material
BABYLON.MaterialThe new material.
updateReferences
-
structure
Parameters:
-
structure
wnp.StructureFloor Structure to work with
Properties
areaPosition
BABYLON.Vector2
Where to display the room's area label on the screen (2D).
habitable
Number
Habitable flag: 0 means not habitable 1 means habitable 2 means "let the algorithm choose".
holes
BABYLON.Vector2[]
Potential holes in the room's polygon. Array of 2D vectors describing the holes.
isExternal
Boolean
Indicates if the room is external (see Wiki for more info about internal and external rooms).
materials
Object
Room's materials. Contains two fields : materials['ceiling'] and materials['floor'].
panes
WallPanes3D
Array of wall panes. See the wanaplan wiki for more info about wall panes.
panesMaterials
BABYLON.Material
private
Room panes materials. For serialization purposes, has to be modified in the future.
parentWallSides
BABYLON.Vector2
Array of normal vectors to walls referenced in the "walls" property. These vectors are normal to the walls, and point towards the inside of the room polygon. Index sync : given i an index, parentWallSides[i] is normal to walls[i].
points
BABYLON.Vector2
2D vectors building the room's flat polygon.
type
Number
Type flag: 0 means normal room 1 means garden 2 means technical room. 3 means out of zone room 4 means terraces & driveways