ObjectLayer

A layer for loading and geolocating a three.js Object3D. Note that disposing of resources is not done automatically as the meshes, materials and textures may be used elsewhere. It's up to the user to dispose of these resources after calling this layer's #dispose method.

Constructor

new ObjectLayer(properties)

Parameters:
NameTypeDescription
propertiesObject
Properties
NameTypeAttributesDefaultDescription
idString | Numberlayer id should be unique
nameStringthe name can be anything you want and is intended for labeling
objectTHREE.Object3D<optional>
a three.js object to add to the scene and georeference
longitudeNumber<optional>
0(optional) longitude of the model's center point in degrees.
latitudeNumber<optional>
0(optional) latitude of the model's center point in degrees.
heightNumber<optional>
0(optional) height in meters above sea level.
yawNumber<optional>
0(optional) a yaw means the original z axis points north. ccw rotation about the model's local y axis.
pitchNumber<optional>
0(optional) pitch rotates the model about it's local x axis. a pitch of 0 alligns it with the horizon, negative values tilts it downwards, positive values tilts it up.
rollNumber<optional>
0(optional) roll around the model's local z axis.
scaleXNumber<optional>
1(optional) scale on X axes.
scaleYNumber<optional>
1(optional) scale on Y axes. defaults to the scaleX property if defined.
scaleZNumber<optional>
1(optional) scale on Z axes. defaults to the scaleX property if defined.
visibleBoolean<optional>
truelayer will be rendered if true (true by default)

Extends

Methods

_updateMatrices()

Updates the object's local and world matrices.

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
Overrides

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

getID()

Overrides
Returns:
layer id

getName()

Overrides
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.

move(longitudeopt, latitudeopt, heightopt, yawopt, pitchopt, rollopt, scaleXopt, scaleYopt, scaleZopt)

Sets the object position and orientation based on Longitude, Latitude, Height, Yaw, Pitch, Roll
Parameters:
NameTypeAttributesDefaultDescription
longitudenumber<optional>
0a longitude in degrees
latitudenumber<optional>
0a latitude in degrees
heightnumber<optional>
0a height in meters above WGS 84 sea level
yawnumber<optional>
0Yaw angle in degrees. (0 points north ccw rotation)
pitchnumber<optional>
0Pitch angle in degrees (-90 to 90)
rollnumber<optional>
0Roll angle in degrees.
scaleXnumber<optional>
1scale on X axes.
scaleYnumber<optional>
1scale on Y axes. defaults to the scaleX property if defined.
scaleZnumber<optional>
1scale on Z axes. defaults to the scaleX property if defined.

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
Overrides
Returns:
true if the object was selected, false otherwise
Type: 
Boolean

setName(name)

change the layer name
Parameters:
NameTypeDescription
nameString
Overrides

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