PolygonWall Class
Polygonal walls. Represents the standard wanaplan wall, which is a closed polygon of N points.
Constructor
PolygonWall
()
Item Index
Methods
- add
- addToStructure
- checkCoherence
- computeDefault
- computeStrong
- computeWeak
- deserialize
- distanceFrom
- distanceFromRect
- draw
- getAllPoints
- getAxis
- getBoundingBox
- getElementByName
- getFloor
- getIntersections
- getLength
- getNearestPoint
- getNearestPointOnAxe
- getNearestPointOnPolygon
- getNearestPointOnRect
- getNormalVector
- getPoints
- getPolygon
- getWallVector
- initialize
- isExternal
- isPointInPolygon
- isPointOn
- isTargeted
- parallelTo
- remove
- reorganizeOnSplit
- serialize
- setPoints
- sortAttached
- splitAtIntersections
- translate
- tryMerge
- update
- updateAttachedPoints
- updateOvertures
- updateReferences
- vectorTo
- weakToStrong
Methods
add
(
private
-
propertyName
-
value
Adds an element to the collection in parameter.
Returns:
Returns true if the value is added else returns false.
addToStructure
(
-
structure
Adds a wall and its points to a structure.
Parameters:
-
structure
FloorStructureThe floor structure containing the wall.
checkCoherence
(
-
structure
Checks if the object structure contains errors, if so, removes it from the plan.
Parameters:
-
structure
FloorStructureThe floor where the object belongs.
computeDefault
(
-
pointIndex
Computes a flat polygon ending, typically for unconnected walls.
See Wanaplan API wiki for more info on wall connection.
Parameters:
-
pointIndex
NumberThe index of the ending point, 0 or 1.
computeStrong
(
-
pointIndex
Computes a polygon ending for two-way connected walls.
See Wanaplan API wiki for more info on wall connection.
Parameters:
-
pointIndex
NumberThe index of the ending point, 0 or 1.
computeWeak
(
-
pointIndex
Computes a polygon ending for one-way connected walls.
See Wanaplan API wiki for more info on wall connection.
Parameters:
-
pointIndex
NumberThe index of the ending point, 0 or 1.
deserialize
(
Object
-
hybrid
Deserializes the object (from JSON).
Parameters:
-
hybrid
ObjectJSON describing the object, built with the method serialize.
Returns:
Object:
The Structure object built from the deserialization
distanceFrom
(
Number
-
vector
Returns the distance from a wall to a point.
Parameters:
-
vector
BABYLON.Vector2Involved point.
Returns:
Number:
Distance to this wall.
distanceFromRect
(
Number
-
vector
-
[margin=0]
-
structure
Returns the distance from the given vector to the wall bounding rectangle.
Parameters:
-
vector
BABYLON.Vector2Involved point. -
[margin=0]
Number optionalThe margin we take outside the endings of the wall. -
structure
FloorStructureThe floor structure containing the wall.
Returns:
Number:
The distance.
draw
(
-
ctx
Draws the wall on a canvas.
Parameters:
-
ctx
CanvasRenderingContext2D2D canvas context.
getAllPoints
(
PointStructure[]
-
inOrder
Returns all the points of the wall (endings and attached points) in a specific order.
Parameters:
-
inOrder
BooleanOrder (-1 = from ending 0 to 1, 1 = from ending 1 to 0).
Returns:
PointStructure[]:
Array of all the points.
getAxis
()
BABYLON.Vector2[]
Returns the 2 segments connecting the sides of the polygons of the wall. These segments are parallel to the wall vector.
Returns:
BABYLON.Vector2[]:
2x2 Array containing the 2 connecting segments.
getElementByName
(
Object
private
-
name
-
collection
Gets an element of the collection by its name.
Parameters:
Returns:
Object:
Returns the needed element if it exists, else returns null.
getFloor
()
FloorStructure
Gets the floor referencing this object.
Returns:
FloorStructure:
The floor containing this structure, -1 if the object has not been added to any floor collection yet.
getIntersections
(
PointStructure[]
-
structure
Returns a list of intersections with the other walls in the same floor.
The extremities of the walls are not considered as intersections.
The array is returned after sorting the elements by distance from the point 0 of the wall.
Parameters:
-
structure
FloorStructureThe floor structure.
Returns:
PointStructure[]:
The intersections as an array of PointStructure.
getNearestPoint
(
BABYLON.Vector2
-
vector
-
[margin=0]
Returns the projection of the given vector on the wall segment.
Parameters:
-
vector
BABYLON.Vector2Involved point. -
[margin=0]
Number optionalThe margin we take outside the endings of the wall.
Returns:
BABYLON.Vector2:
Projected point.
getNearestPointOnAxe
(
BABYLON.Vector2
-
vector
Returns the projection of the given vector on the wall axe.
Parameters:
-
vector
BABYLON.Vector2Involved point.
Returns:
BABYLON.Vector2:
Projected point.
getNearestPointOnPolygon
(
BABYLON.Vector2
-
vector
Returns the projection of the given vector on the wall polygon.
Parameters:
-
vector
BABYLON.Vector2Involved point.
Returns:
BABYLON.Vector2:
Projected point.
getNearestPointOnRect
(
BABYLON.Vector2
-
vector
-
[margin=0]
-
structure
Returns the projection of the given vector on the wall bounding rectangle.
Parameters:
-
vector
BABYLON.Vector2Involved point. -
[margin=0]
Number optionalThe margin we take outside the endings of the wall. -
structure
FloorStructureThe floor structure containing the wall.
Returns:
BABYLON.Vector2:
Projected point.
getNormalVector
(
BABYLON.Vector2
-
[norm=1]
Returns an orthogonal vector.
Parameters:
-
[norm=1]
Number optionalThe requested norm.
Returns:
BABYLON.Vector2:
Orthogonal vector.
getPoints
(
BABYLON.Vector2 | BABYLON.Vector22
-
[index]
Gets the endings of the wall.
Parameters:
-
[index]
Number optionalIndex of the point.
Returns:
BABYLON.Vector2 | BABYLON.Vector22:
If an index is provided, returns the point of that index.
Else returns an array containing the 2 points.
getPolygon
()
BABYLON.Vector2
Returns the polygon of the wall.
Returns:
BABYLON.Vector2:
The wall as a polygon (array of vertices).
getWallVector
()
BABYLON.Vector2
Computes the vector representing the wall.
Starts from its point 0, and ends on its point 1.
Returns:
BABYLON.Vector2:
Vector carrying the wall.
initialize
()
private
Method called after the loading of the component
isExternal
(
Boolean
-
[structure]
Checks if the wall is part of an external room.
Parameters:
-
[structure]
FloorStructure optionalThe floor structure containing the wall
Returns:
Boolean:
True if the wall is external.
isPointInPolygon
(
Boolean
-
vector
Returns true if the point is inside the polygon of the wall.
Parameters:
-
vector
BABYLON.Vector2Involved point.
Returns:
Boolean:
True if the point is inside the polygon.
isPointOn
(
Boolean
-
vector
-
[delta=1e-5]
Checks if a point is on a wall, within a
delta
incertitude.
Parameters:
-
vector
BABYLON.Vector2Involved point. -
[delta=1e-5]
Number optionalIncertitude.
Returns:
Boolean:
True if the point is on the wall.
isTargeted
(
Boolean
-
vector
Checks if the wall is targeted by the cursor.
Parameters:
-
vector
BABYLON.Vector2The cursor position.
Returns:
Boolean:
True if targeted.
parallelTo
(
Boolean
-
wall
Checks if the wall is parallel to another wall.
Parameters:
-
wall
WallStructureOther wall.
Returns:
Boolean:
True if the walls are parallel.
remove
(
-
structure
Deletes a wall.
Parameters:
-
structure
FloorStructureThe floor structure containing the wall.
reorganizeOnSplit
(
-
structure
-
wallList
Reorganizes the attached walls and the overtures when the wall is splitted into several pieces.
Parameters:
-
structure
FloorStructureThe floor structure containing the wall. -
wallList
WallStructure[]The resulting pieces of the split.
serialize
()
Object
Serializes the object (to JSON)
Returns:
Object:
The serialization result, null if nothing is serialized
setPoints
(
-
points
-
[index]
Changes the points composing the wall.
Parameters:
-
points
PointStructure[]Array composed of instances ofPointStructure
. OR aPointStructure
if the parameterindex
is provided. -
[index]
Number optionalIndex of the point (0 or 1).
sortAttached
()
Sorts the list of the attached points (point 0 to point 1).
splitAtIntersections
(
-
structure
Splits the wall, taking other walls as splitters.
Parameters:
-
structure
FloorStructureThe floor structure containing the wall.
translate
(
-
vector
-
[structure]
Translates the wall.
Parameters:
-
vector
BABYLON.Vector2Translation vector. -
[structure]
FloorStructure optionalFloor structure containing the wall.
tryMerge
(
WallStructure
-
structure
Tries to merge the wall with other walls in the same floor.
Parameters:
-
structure
FloorStructureThe floor structure containing the wall.
Returns:
WallStructure:
The resulting wall. Returns the unchanged wall if the method does not manage to merge with something.
update
()
Generic update method, must be overridden.
updateAttachedPoints
(
-
structure
Updates the position of the attached points.
Parameters:
-
structure
FloorStructureThe floor structure containing the wall.
updateOvertures
(
-
structure
Updates the position of the overtures on the wall.
Parameters:
-
structure
FloorStructureThe floor structure containing the wall.
updateReferences
(
-
structure
Updates the wall after deserialization.
Parameters:
-
structure
FloorStructureThe floorStructure where the object belong.
vectorTo
(
BABYLON.Vector2
-
vector
Returns the vector from the projected point on the wall, to the given point.
Direction : wall -> point.
Parameters:
-
vector
BABYLON.Vector2Involved point.
Returns:
BABYLON.Vector2:
The vector.
weakToStrong
(
-
point
-
structure
Upgrades the connection from weak (attached) to strong (connected).
Parameters:
-
point
PointStructureThe weak point that becomes strong. -
structure
wnp.FloorStructureThe floor structure containing the wall.
Properties
_edgePolygons
BABYLON.Vector2[2]
The two polygons surrounding the ends.
attachedPoints
PointStructure[]
Attached points. See Wanaplan Wiki for more info about the connections between walls.
considerForElevation
Boolean
Consider or not when computing this floor's height (and therefore top floor elevation).
Allows to have overlapping floors (useful for roofs)
Default: true
instance
String
Class type of the wall.
e.g. : 'polygon' for polygonal walls, which are most used in wanaplan.
polygonPoints
BABYLON.Vector2
The 2D polygon shape of the wall.
type
Number
Type of the wall.
Can be TYPE_NORMAL or TYPE_SEPARATOR.
TODO : Must be deleted in future version,
this has to be replaced by a class "SeparatorWall" that has its own behaviour.
Default: TYPE_NORMAL