SubSlopeStructure Class
A subslope object. More info can be found in the Wanaplan Wiki.
Constructor
SubSlopeStructure
()
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
-
propertyName
-
value
Returns:
checkCoherence
()
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
-
isTriangle
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
-
force
Computes the polygon points (subslope is strictly inside, does not include walls)
Parameters:
-
force
BooleanForce to update the polygon points.
deserialize
-
hybrid
Parameters:
-
hybrid
ObjectJSON describing the object, built with the method serialize.
Returns:
The Structure object built from the deserialization
distanceFrom
-
ss
Returns the distance between 2 subslopes.
Parameters:
-
ss
SubSlopeStructureThe subslope.
Returns:
The distance.
findNeighborSubslope2D
-
index
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
-
index
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
-
subslopes
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
-
name
-
collection
Parameters:
Returns:
getFloor
-
collection
Parameters:
-
collection
StringCollection to search within.
Returns:
The floor containing this structure, -1 if the object has not been added to any floor collection.
getNearestSubSlope
-
vector
-
structure
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
()
BABYLON.Vector2
Returns a vector going from the base point 0 to the base point 1 of the subslope.
Returns:
The final vector.
indexClosest
-
points
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
()
private
isPointIn
-
pt
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
-
points
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
()
BABYLON.Vector3
Returns the 4 points defining the plane of the subslope in 3D.
Returns:
The 4 points of the plane.
planeExtended
()
BABYLON.Vector3
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
()
BABYLON.Vector2
Returns the polygon points of the subslope, extended to the exterior of the surrounding walls.
Returns:
projectInSubslope
-
pt
Projects a point on the contour of the subslope polygon
Parameters:
-
pt
BABYLON.Vector2The point to project.
Returns:
the projected point
remove
()
Resets the subslope to default values.
roofExists
()
Boolean
private
Checks if subslope has a roof and offset is not zero
Returns:
true is there is a non null roof
serialize
()
Object
Returns:
update
()
updateOffsetWithoutOverlap
-
newOffset
-
symmetry
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
-
structure
Parameters:
-
structure
wnp.StructureFloor Structure to work with
Properties
needsUpdate
Boolean
Update flag for the structure. Set to true if your subslope needs to be recomputed.
overtures
SubSlopesOvertureStructure
The overtures on the subslope.
points
BABYLON.Vector2
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
BABYLON.Vector2
The 2D polygon vertices of the subslope. The length of this array is always 4 at all times.
side
BABYLON.Vector2
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.