API Docs for: 2.7.3
Show:

SubSlopeStructure Class

Extends BaseStructure
Module: Component
Parent Module: Wanaplan

A subslope object. More info can be found in the Wanaplan Wiki.

Constructor

SubSlopeStructure

()

Methods

add

(
  • propertyName
  • value
)
private

Inherited from BaseStructure:

Adds an element to the collection in parameter.

Parameters:

  • propertyName String
    Name of the dictionnary.
  • value Object
    Value to distribute.

Returns:

Returns true if the value is added else returns false.

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
)
BABYLON.Vector3 private

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 Boolean

    is the subslope a triangle or not (point 2 and 3 very close)

Returns:

BABYLON.Vector3:

computePolygonPoints

(
  • force
)

Computes the polygon points (subslope is strictly inside, does not include walls)

Parameters:

  • force Boolean

    Force to update the polygon points.

deserialize

(
  • hybrid
)
Object

Inherited from BaseStructure:

Deserializes the object (from JSON).

Parameters:

  • hybrid Object

    JSON describing the object, built with the method serialize.

Returns:

Object:

The Structure object built from the deserialization

distanceFrom

(
  • ss
)
Number

Returns the distance between 2 subslopes.

Parameters:

Returns:

Number:

The distance.

findNeighborSubslope2D

(
  • index
)
SubSlopeStructure

Returns the neighbor subslope on the side of points[index] if it exists

Parameters:

  • index Number

    the index of the side where to find the neighbor (0 or 1)

Returns:

SubSlopeStructure:

the neighboring subslope on side index

findNeighborSubslope3D

(
  • index
)
SubSlopeStructure

Returns the neighbor subslope on the side of point[index] in 3D if it exists

Parameters:

  • index Number

    the index of the side where to find the neighbor (0 or 1)

Returns:

SubSlopeStructure:

the neighboring subslope on side index

findOppositeSubslope

(
  • subslopes
)
SubSlopeStructure

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:

Returns:

SubSlopeStructure:

opposite subslope

getElementByName

(
  • name
  • collection
)
Object private

Inherited from BaseStructure:

Gets an element of the collection by its name.

Parameters:

  • name String
    The name of the element to search.
  • collection String
    The name of the collection in which we want to search. If this parameter is not defined, the search is done in all the collection of type array.

Returns:

Object: Returns the needed element if it exists, else returns null.

getFloor

(
  • collection
)
FloorStructure

Inherited from BaseStructure:

Gets the floor referencing this object

Parameters:

  • collection String

    Collection to search within.

Returns:

FloorStructure:

The floor containing this structure, -1 if the object has not been added to any floor collection.

getNearestSubSlope

(
  • vector
  • structure
)
SubSlopeStructure

Gets the nearest subslope from a given position.

Parameters:

  • vector BABYLON.Vector2

    Input position.

  • structure FloorStructure

    The floor structure where the subslope belongs.

Returns:

SubSlopeStructure:

The nearest subslope.

getVector

() BABYLON.Vector2

Returns a vector going from the base point 0 to the base point 1 of the subslope.

Returns:

BABYLON.Vector2:

The final vector.

indexClosest

(
  • points
)
Number

Searches the closest point of the carrying wall and returns the index in the array.

Parameters:

  • points BABYLON.Vector2

    The points of the wall carrying the subslope.

Returns:

Number:

The index of the closest point.

initialize

() private

Inherited from BaseStructure:

Method called after the loading of the component

isPointIn

(
  • pt
)
Boolean

Tests if a point is inside the subslope 2D polygon.

Parameters:

  • pt BABYLON.Vector2

    The point we want to test.

Returns:

Boolean:

true if the point is inside the subslope polygon.

isSameSide

(
  • points
)
Boolean

Checks if the points are on the same side of the wall.

Parameters:

  • points BABYLON.Vector2

    The points of the wall of the subslope.

Returns:

Boolean:

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:

BABYLON.Vector3:

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:

BABYLON.Vector3:

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:

BABYLON.Vector2:

projectInSubslope

(
  • pt
)
BABYLON.Vector2

Projects a point on the contour of the subslope polygon

Parameters:

  • pt BABYLON.Vector2

    The point to project.

Returns:

BABYLON.Vector2:

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:

Boolean:

true is there is a non null roof

serialize

() Object

Inherited from BaseStructure:

Serializes the object (to JSON)

Returns:

Object: The serialization result, null if nothing is serialized

update

()

Inherited from BaseStructure:

Generic update method, must be overridden.

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.

Parameters:

  • newOffset Number

    new offset we would like for this subslope

  • symmetry Boolean

    update opposite offset symmetrically or not

updateReferences

(
  • structure
)

Inherited from BaseStructure:

Generic method for rebuilding references after the deserialization. For example : restoring the link between a PointStructure and its parent WallStructure

Parameters:

  • structure wnp.Structure

    Floor Structure to work with

Properties

_opposite

SubSlopeStructure private

Opposite subslope (inverse normal and in front)

hasRoof

Boolean

True if we want a roof on top of the subslope

hiHeight

Number

The high height of the subslope (ceiling height).

Default: 250

id

Number

Inherited from BaseStructure:

Unique ID for the structure set up automatically

lowHeight

Number

The low height of the subslope (base wall height).

Default: 100

materials

Object

Dictionary of materials for the subslopes.

name

String

Inherited from BaseStructure:

Structure name

needsUpdate

Boolean

Update flag for the structure. Set to true if your subslope needs to be recomputed.

neighbors

PolygonWall[]

The walls adjacent to the subslope.

offset

Number

The distance between the 2 side of the subslope

Default: 0

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.

roof

RoofStructure

The roof structure associated with the subslope.

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.

wall

PolygonWall

The wall structure associated with the subslope.