RoomStructure
Summary
A room object. More info can be found in the Wanaplan Wiki.
Constructor
RoomStructure
Syntax
RoomStructure
()
Summary
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
Syntax
add
-
propertyName
-
value
Summary
Adds an element to the collection in parameter.Returns:
addFloorOnOvertures
Syntax
addFloorOnOvertures
()
private
Summary
Adds floor on doors, or overtures that hit the ground, so there is no hole in the connection between 2 rooms.
copy
Syntax
copy
-
room
Summary
Copies a room.
WARNING: Beware of shared materials !
Parameters:
-
room
RoomStructureThe room to copy.
createFromCycle
Syntax
Summary
Creates a room from a closed cycle of points.
Parameters:
-
cycle
PointStructure[]The cycle of points.
Returns:
The resulting room.
createWallPanes
Syntax
Summary
Creates the wall panes for the room. Basically, one side of the room polygon = 1 wall pane.
Returns:
The wall panes.
deserialize
Syntax
deserialize
-
hybrid
Summary
Deserializes the object.
Parameters:
-
hybrid
StringAn object issued from a serialization.
dispatchMaterials
Syntax
dispatchMaterials
()
private
Summary
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
Syntax
Summary
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
Syntax
getBoundingBox
()
BABYLON.BoundingBox
Summary
Returns the 2D not oriented Bounding Box.
Returns:
The Bounding Box.
getCenter
Syntax
getCenter
()
BABYLON.Vector2
Summary
Returns the center of the room.
Returns:
The 2D center of gravity of the room's polygon.
getDefaultLabel
Syntax
getDefaultLabel
()
Summary
Get the default label for a room based on type
getElementByName
Syntax
Summary
Gets an element of the collection by its name.Parameters:
Returns:
getFloor
Syntax
Summary
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
Syntax
Summary
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
Syntax
Summary
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
Syntax
Summary
Returns the area of the room.
Parameters:
-
force
BooleanForces a recomputing of the room area.
Returns:
The room area.
getWallPanes
Syntax
Summary
Gets the Wall Panes (see Wanaplan API wiki for more info).
Returns:
The Wall Panes of the room.
initialize
Syntax
initialize
()
private
Summary
Method called after the loading of the componentisPointIn
Syntax
Summary
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
Syntax
Summary
Returns the oriented area of the room.
Returns:
The room area, negative if the room is counterclockwise.
reversePath
Syntax
reversePath
()
Summary
Flips a room. If it was counterclockwise, it becomes clockwise.
serialize
Syntax
Summary
Serializes the object (to JSON)Returns:
setColor
Syntax
setColor
-
The
Summary
Sets the color of a room.
Parameters:
-
The
Stringhexadecimal representation of the color.
setColorFromType
Syntax
setColorFromType
()
Summary
Automatically maps the color of the room based on its type.
setType
Syntax
setType
-
The
Summary
Sets the type of a room.
Parameters:
-
The
Numbertype of the room.
toVec2Array
Syntax
toVec2Array
()
BABYLON.Vector2
Summary
Returns a BABYLON.Vector2 array of the room points.
Returns:
The array of points.
update
Syntax
update
()
Summary
Generic update method, must be overridden.updatePaneMaterial
Syntax
updatePaneMaterial
-
pane
-
material
Summary
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
Syntax
updateReferences
-
structure
Summary
Generic method for rebuilding references after the deserialization. For example : restoring the link between a PointStructure and its parent WallStructureParameters:
-
structure
wnp.StructureFloor Structure to work with
Properties
areaPosition
Syntax
areaPosition
BABYLON.Vector2
Summary
Where to display the room's area label on the screen (2D).
ceiling
Syntax
ceiling
Number
Summary
Ceiling flag: 0 means no ceiling 1 means ceiling 2 means "let the algorithm choose".
habitable
Syntax
habitable
Number
Summary
Habitable flag: 0 means not habitable 1 means habitable 2 means "let the algorithm choose".
holes
Syntax
holes
BABYLON.Vector2[]
Summary
Potential holes in the room's polygon. Array of 2D vectors describing the holes.
isExternal
Syntax
isExternal
Boolean
Summary
Indicates if the room is external (see Wiki for more info about internal and external rooms).
materials
Syntax
materials
Object
Summary
Room's materials. Contains two fields : materials['ceiling'] and materials['floor'].
panes
Syntax
panes
WallPanes3D
Summary
Array of wall panes. See the wanaplan wiki for more info about wall panes.
panesMaterials
Syntax
panesMaterials
BABYLON.Material
private
Summary
Room panes materials. For serialization purposes, has to be modified in the future.
parentWallSides
Syntax
parentWallSides
BABYLON.Vector2
Summary
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
Syntax
points
BABYLON.Vector2
Summary
2D vectors building the room's flat polygon.
type
Syntax
type
Number
Summary
Type flag: 0 means normal room 1 means garden 2 means technical room. 3 means out of zone room 4 means terraces & driveways