SubSlopeStructure
Summary
A subslope object. More info can be found in the Wanaplan Wiki.
Constructor
SubSlopeStructure
Syntax
SubSlopeStructure
()
Summary
Item Index
Methods
- add
- checkCoherence
- computeDisplacementTopPlane
- computePolygonPoints
- deserialize
- distanceFrom
- findNeighborSubslope2D
- findNeighborSubslope3D
- findOppositeSubslope
- getElementByName
- getFloor
- getNearestSubSlope
- getVector
- indexClosest
- initialize
- isPointIn
- isSameSide
- plane
- planeExtended
- polygonPointsExtended
- projectInSubslope
- remove
- roofExists
- serialize
- update
- updateOffsetWithoutOverlap
- updateReferences
Methods
add
Syntax
add
-
propertyName
-
value
Summary
Adds an element to the collection in parameter.Returns:
checkCoherence
Syntax
checkCoherence
()
Summary
Checks the coherency of the structure, for instance : - this.lowHeight < this.hiHeight - this.lowHeight > 0 - this.hiHeight < 4000
WARNING : This method automatically corrects incoherencies. So it may modify the parameters of the subslope.
computeDisplacementTopPlane
Syntax
computeDisplacementTopPlane
-
isTriangle
Summary
Returns a displacement vector for each of the 4 points of the roof 3D plane. Adding then to each point will produce a top plane at height 'roof.thickness' above, that fits with the opposite and neighbor roofs.
Parameters:
-
isTriangle
Booleanis the subslope a triangle or not (point 2 and 3 very close)
Returns:
computePolygonPoints
Syntax
computePolygonPoints
-
force
Summary
Computes the polygon points (subslope is strictly inside, does not include walls)
Parameters:
-
force
BooleanForce to update the polygon points.
deserialize
Syntax
Summary
Deserializes the object (from JSON).Parameters:
-
hybrid
ObjectJSON describing the object, built with the method serialize.
Returns:
The Structure object built from the deserialization
distanceFrom
Syntax
Summary
Returns the distance between 2 subslopes.
Parameters:
-
ss
SubSlopeStructureThe subslope.
Returns:
The distance.
findNeighborSubslope2D
Syntax
Summary
Returns the neighbor subslope on the side of points[index] if it exists
Parameters:
-
index
Numberthe index of the side where to find the neighbor (0 or 1)
Returns:
the neighboring subslope on side index
findNeighborSubslope3D
Syntax
Summary
Returns the neighbor subslope on the side of point[index] in 3D if it exists
Parameters:
-
index
Numberthe index of the side where to find the neighbor (0 or 1)
Returns:
the neighboring subslope on side index
findOppositeSubslope
Syntax
Summary
Finds opposite subslope (subslope in front with opposite normal and some overlap). If there are multiple candidates, favor closest distance. If user chose an opposite manually, keep it only if it is valid.
Parameters:
-
subslopes
SubSlopeStructure[]list of subslopes to search through
Returns:
opposite subslope
getElementByName
Syntax
Summary
Gets an element of the collection by its name.Parameters:
Returns:
getFloor
Syntax
Summary
Gets the floor referencing this objectParameters:
-
collection
StringCollection to search within.
Returns:
The floor containing this structure, -1 if the object has not been added to any floor collection.
getNearestSubSlope
Syntax
Summary
Gets the nearest subslope from a given position.
Parameters:
-
vector
BABYLON.Vector2Input position.
-
structure
FloorStructureThe floor structure where the subslope belongs.
Returns:
The nearest subslope.
getVector
Syntax
getVector
()
BABYLON.Vector2
Summary
Returns a vector going from the base point 0 to the base point 1 of the subslope.
Returns:
The final vector.
indexClosest
Syntax
Summary
Searches the closest point of the carrying wall and returns the index in the array.
Parameters:
-
points
BABYLON.Vector2The points of the wall carrying the subslope.
Returns:
The index of the closest point.
initialize
Syntax
initialize
()
private
Summary
Method called after the loading of the componentisPointIn
Syntax
Summary
Tests if a point is inside the subslope 2D polygon.
Parameters:
-
pt
BABYLON.Vector2The point we want to test.
Returns:
true if the point is inside the subslope polygon.
isSameSide
Syntax
Summary
Checks if the points are on the same side of the wall.
Parameters:
-
points
BABYLON.Vector2The points of the wall of the subslope.
Returns:
true if the points are on the same side.
plane
Syntax
plane
()
BABYLON.Vector3
Summary
Returns the 4 points defining the plane of the subslope in 3D.
Returns:
The 4 points of the plane.
planeExtended
Syntax
planeExtended
()
BABYLON.Vector3
Summary
Returns the 4 points defining the extended plane of the subslope in 3D (covers the surrounding walls, used to carve them).
Returns:
The 4 points of the plane.
polygonPointsExtended
Syntax
polygonPointsExtended
()
BABYLON.Vector2
Summary
Returns the polygon points of the subslope, extended to the exterior of the surrounding walls.
Returns:
projectInSubslope
Syntax
projectInSubslope
-
pt
Summary
Projects a point on the contour of the subslope polygon
Parameters:
-
pt
BABYLON.Vector2The point to project.
Returns:
the projected point
remove
Syntax
remove
()
Summary
Resets the subslope to default values.
roofExists
Syntax
Summary
Checks if subslope has a roof and offset is not zero
Returns:
true is there is a non null roof
serialize
Syntax
Summary
Serializes the object (to JSON)Returns:
update
Syntax
update
()
Summary
Generic update method, must be overridden.updateOffsetWithoutOverlap
Syntax
updateOffsetWithoutOverlap
-
newOffset
-
symmetry
Summary
Tries to update the offset to newOffset, but if it induces an overlap with the opposite subslope, it reduces the offset until the opposite subslopes only touch.
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
_opposite
Syntax
Summary
Opposite subslope (inverse normal and in front)
hiHeight
Syntax
hiHeight
Number
Summary
The high height of the subslope (ceiling height).
Default: 250
lowHeight
Syntax
lowHeight
Number
Summary
The low height of the subslope (base wall height).
Default: 100
needsUpdate
Syntax
needsUpdate
Boolean
Summary
Update flag for the structure. Set to true if your subslope needs to be recomputed.
overtures
Syntax
overtures
SubSlopesOvertureStructure
Summary
The overtures on the subslope.
points
Syntax
points
BABYLON.Vector2
Summary
The 2D base points of the subslope. There are always 2 base points on a subslope, and they lay on the side of a wall.
polygonPoints
Syntax
polygonPoints
BABYLON.Vector2
Summary
The 2D polygon vertices of the subslope. The length of this array is always 4 at all times.
side
Syntax
side
BABYLON.Vector2
Summary
Side of the wall (a wall can have several subslopes in both directions). Warning : This property is an array, but only the first element matters for now. this.side[0] is a vector normal to the wall, indicating in which direction the subslope lays.