WanaPlan

API Docs for: 2.7.0
Show:

SubSlopeStructure

Extends BaseStructure
Module: Component
Parent Module: Wanaplan

Summary

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

Constructor

SubSlopeStructure

Syntax

SubSlopeStructure

()

Summary

Methods

add

Inherited from BaseStructure:

Syntax

add

(
  • propertyName
  • value
)
private

Summary

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

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

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 Boolean

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

Returns:

BABYLON.Vector3:

computePolygonPoints

Syntax

computePolygonPoints

(
  • force
)

Summary

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

Parameters:

  • force Boolean

    Force to update the polygon points.

deserialize

Inherited from BaseStructure:

Syntax

deserialize

(
  • hybrid
)
Object

Summary

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

Syntax

distanceFrom

(
  • ss
)
Number

Summary

Returns the distance between 2 subslopes.

Parameters:

Returns:

Number:

The distance.

findNeighborSubslope2D

Syntax

findNeighborSubslope2D

(
  • index
)
SubSlopeStructure

Summary

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

Syntax

findNeighborSubslope3D

(
  • index
)
SubSlopeStructure

Summary

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

Syntax

findOppositeSubslope

(
  • subslopes
)
SubSlopeStructure

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:

Returns:

SubSlopeStructure:

opposite subslope

getElementByName

Inherited from BaseStructure:

Syntax

getElementByName

(
  • name
  • collection
)
Object private

Summary

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

Inherited from BaseStructure:

Syntax

getFloor

(
  • collection
)
FloorStructure

Summary

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

Syntax

getNearestSubSlope

(
  • vector
  • structure
)
SubSlopeStructure

Summary

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

Syntax

getVector

() BABYLON.Vector2

Summary

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

Returns:

BABYLON.Vector2:

The final vector.

indexClosest

Syntax

indexClosest

(
  • points
)
Number

Summary

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

Inherited from BaseStructure:

Syntax

initialize

() private

Summary

Method called after the loading of the component

isPointIn

Syntax

isPointIn

(
  • pt
)
Boolean

Summary

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

Syntax

isSameSide

(
  • points
)
Boolean

Summary

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

Syntax

plane

() BABYLON.Vector3

Summary

Returns the 4 points defining the plane of the subslope in 3D.

Returns:

BABYLON.Vector3:

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:

BABYLON.Vector3:

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:

BABYLON.Vector2:

projectInSubslope

Syntax

projectInSubslope

(
  • pt
)
BABYLON.Vector2

Summary

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

Syntax

remove

()

Summary

Resets the subslope to default values.

roofExists

Syntax

roofExists

() Boolean private

Summary

Checks if subslope has a roof and offset is not zero

Returns:

Boolean:

true is there is a non null roof

serialize

Inherited from BaseStructure:

Syntax

serialize

() Object

Summary

Serializes the object (to JSON)

Returns:

Object:
The serialization result, null if nothing is serialized

update

Inherited from BaseStructure:

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.

Parameters:

  • newOffset Number

    new offset we would like for this subslope

  • symmetry Boolean

    update opposite offset symmetrically or not

updateReferences

Inherited from BaseStructure:

Syntax

updateReferences

(
  • structure
)

Summary

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

Syntax

_opposite

SubSlopeStructure private

Summary

Opposite subslope (inverse normal and in front)

hasRoof

Syntax

hasRoof

Boolean

Summary

True if we want a roof on top of the subslope

hiHeight

Syntax

hiHeight

Number

Summary

The high height of the subslope (ceiling height).

Default: 250

id

Inherited from BaseStructure:

Syntax

id

Number

Summary

Unique ID for the structure set up automatically

lowHeight

Syntax

lowHeight

Number

Summary

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

Default: 100

materials

Syntax

materials

Object

Summary

Dictionary of materials for the subslopes.

name

Inherited from BaseStructure:

Syntax

name

String

Summary

Structure name

needsUpdate

Syntax

needsUpdate

Boolean

Summary

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

neighbors

Syntax

neighbors

PolygonWall[]

Summary

The walls adjacent to the subslope.

offset

Syntax

offset

Number

Summary

The distance between the 2 side of the subslope

Default: 0

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.

roof

Syntax

Summary

The roof structure associated with the subslope.

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.

wall

Syntax

Summary

The wall structure associated with the subslope.