PerlinElevationLayer

An elevation layer that generates on the fly elevation using a mixture of noise techniques

Constructor

new PerlinElevationLayer(properties)

Base constructor for elevation layers.
Parameters:
NameTypeDescription
propertiesObject
Properties
NameTypeAttributesDefaultDescription
idString | Numberlayer id should be unique
nameStringthe name can be anything you want and is intended for labeling
minHeightNumbermin terrain height relative to sea level
maxHeightNumbermax terrain height relative to sea level
boundsArray.<Number><optional>
[-180, -90, 180, 90]min longitude, min latitude, max longitude, max latitude in degrees
visibleBoolean<optional>
truelayer will be rendered if true (true by default)

Extends

Methods

_simpleMeshFromElevation(bounds, width, height, extendedElevation, geometry, skirtGeometry) → {Promise(THREE.Vector3)}

A default mesh generation function given some elevation.
Parameters:
NameTypeDescription
boundsTHREE.Box2
widthNumber
heightNumber
extendedElevationArray.<Number>elevation array extended by 1 in all directions (for correct normals on the edges)
geometryTHREE.BufferGeometry
skirtGeometryTHREE.BufferGeometry
Returns:
the shift to apply to the tile (for numerical stability)
Type: 
Promise(THREE.Vector3)

_simpleMeshFromElevationAsync(bounds, width, height, extendedElevation, geometry, skirtGeometry) → {Promise(THREE.Vector3)}

A default mesh generation function given some elevation using web workers.
Parameters:
NameTypeDescription
boundsTHREE.Box2
widthNumber
heightNumber
extendedElevationArray.<Number>elevation array extended by 1 in all directions (for correct normals on the edges)
geometryTHREE.BufferGeometry
skirtGeometryTHREE.BufferGeometry
Returns:
the shift to apply to the tile (for numerical stability)
Type: 
Promise(THREE.Vector3)

_trimEdges(arr, width, height)

Trims the edges of an elevation array by 1 on all sides
Parameters:
NameTypeDescription
arr*elevation array width+2 height+2
width*the desired width
height*the desired height
Returns:
the trimmed array

addListener(key, listener)

Adds a listener for layer events
Parameters:
NameTypeDescription
key*can be anything but should be unique
listenerfunctiona function : (layer, eventType)=>{}

dispose()

disposes of any resources used by this layer

getBounds() → {THREE.Box2}

Returns:
bounds in longitude latitude (degrees)
Type: 
THREE.Box2

getCenter(sfct) → {THREE.Vector3}

Moves a given point to this layer's center in degree longitude/latitude
Parameters:
NameTypeDescription
sfctTHREE.Vector3a point to move
Returns:
the input point
Type: 
THREE.Vector3

getElevation(bounds, width, height, geometry, skirtGeometry) → {Promise}

Returns a 2D elevation array and populates a tile's geometry and skirtGeometry. The generated geometry does not have to match the elevation array exactly. It can represent overhanging features for example but the elevation array is expected to correspond at least roughly to the geometry's highest points.
Parameters:
NameTypeDescription
boundsTHREE.Box2
widthNumberwidth resolution for the elevation
heightNumberheight resolution for the elevation
geometryTHREE.BufferGeometry | undefineda tile's buffer geometry to be filled with actual geometry
skirtGeometryTHREE.BufferGeometry | undefineda skirt geometry to be filled with actual skirts
Returns:
a promise for an elevation array
Type: 
Promise

getID()

Returns:
layer id

getName()

Returns:
layer name

getSelectableObjects()

Get all the selectable objects of this layer.
Returns:
an array of ray-castable objects with a property "layer" pointing to this layer.

removeListener(key)

Removes the listener associated to the given key
Parameters:
NameTypeDescription
key*can be anything but should be unique

select(objectsToSelect) → {Boolean}

selects an object from this layer
Parameters:
NameTypeDescription
objectsToSelectObject
Returns:
true if the object was selected, false otherwise
Type: 
Boolean

setName(name)

change the layer name
Parameters:
NameTypeDescription
nameString

setVisible(visible)

Modifies the layer visibility
Parameters:
NameTypeDescription
visibleBoolean

unselect(objectsToUnselect) → {Boolean}

un-selects an object from this layer
Parameters:
NameTypeDescription
objectsToUnselectObject
Returns:
true if the object was un-selected, false otherwise
Type: 
Boolean