Class Layer3D
Implements
- Layer3DInternalAPIInterface
Constructors
constructor
Parameters
- id: string
- options: Layer3DOptions = {}
Returns Layer3D
Properties
Readonlyclock
The three.js clock instance of the layer. Used internally for animations.
Readonlyid
The id of the layer, this is used to identify the layer in the map
maxZoom
The maximum zoom of the layer
minZoom
The minimum zoom of the layer
ReadonlyrenderingMode
The rendering mode of the layer, this is used to identify the layer in the map
Readonlytype
The type of the layer, this is used to identify the layer in the map
Methods
[handleMeshClickMethodSymbol]
addMesh
- addMesh(
id: string,
mesh:
| Object3D<Object3DEventMap>
| Mesh<
BufferGeometry<NormalBufferAttributes>,
Material | Material[],
Object3DEventMap,
>
| Group<Object3DEventMap>,
options?: MeshOptions,
): Item3DAdd an existing mesh to the map
Parameters
- id: string
The ID of the mesh
- mesh:
| Object3D<Object3DEventMap>
| Mesh<
BufferGeometry<NormalBufferAttributes>,
Material | Material[],
Object3DEventMap,
>
| Group<Object3DEventMap> - options: MeshOptions = {}
The options to add the mesh with
Returns Item3D
The item
- id: string
addMeshFromURL
Load a GLTF file from its URL and add it to the map
Parameters
- id: string
The ID of the mesh
- url: string
- options: AddMeshFromURLOptions = {}
The options to add the mesh with
Returns Promise<Item3D>
- id: string
addPointLight
Adding a point light. The default options are mimicking the sun: lngLat:
[0, 0](null island) altitude:2_000_000meters altitudeReference:AltitudeReference.MEAN_SEA_LEVELcolor:0xffffff(white) intensity:75decay:0.2Parameters
- id: string
The ID of the point light
- options: PointLightOptions = {}
The options to add the point light with
Returns Layer3D
The layer
- id: string
clear
cloneMesh
Clone an existing mesh. Extra options can be provided to overwrite the clone configuration
Parameters
- sourceId: string
The ID of the mesh to clone
- id: string
The ID of the cloned mesh
- options: AddMeshFromURLOptions = {}
The options to clone the mesh with
Returns void
- sourceId: string
getItem3D
Parameters
- id: string
Returns null | Item3D
getMapInstance
Get the map instance of the layer.
Returns Map
The map instance
getRendererInstance
Get the renderer instance of the layer. This is internally for animations and batch rendering layers.
Returns WebGLRenderManager
The renderer instance
modifyPointLight
Modify a point light
Parameters
- id: string
The ID of the point light
- options: PointLightOptions
The options to modify the point light with
Returns undefined | Layer3D
- id: string
OptionalonAdd
Automatically called when the layer is added. (should not be called manually)
Parameters
- map: Map
- gl: WebGL2RenderingContext
Returns void
OptionalonRemove
Automatically called when the layer is removed. (should not be called manually)
Parameters
- _map: Map
- _gl: WebGL2RenderingContext | WebGLRenderingContext
Returns void
removeMesh
Remove a mesh from the scene using its ID.
Parameters
- id: string
The ID of the mesh to remove
Returns Layer3D
The layer
- id: string
render
Render the layer. Normally this method is called by the Map instance on every frame to calculate matrices and update the camera projection matrix. However, this would require a multiple instances of Three.js renderers, which is not optimal. So instead we use the
WebGLManagerLayerto render the layer and return null.Returns null
setAmbientLight
Adjust the settings of the ambient light
Parameters
- options: { color?: ColorRepresentation; intensity?: number } = {}
The options to set the ambient light with
Returns Layer3D
The layer
- options: { color?: ColorRepresentation; intensity?: number } = {}
The Layer3D class is the main class for the 3D layer. It is used to add meshes to the layer, and to manage the items in the layer.
Example