Class Layer3D

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.

 const layer3D = new Layer3D("layer-id");
 map.addLayer(layer3D);

 layer3D.setAmbientLight({ intensity: 2 });
 layer3D.addPointLight("point-light", { intensity: 30 });
 layer3D.modifyPointLight("point-light", { intensity: 100 });

 await layer3D.addMeshFromURL("duck", "./models/Duck.glb", {
   ...state,
   sourceOrientation: SourceOrientation.Y_UP,
 });

Implements

  • Layer3DInternalAPIInterface
Index

Constructors

Properties

clock: Clock = ...

The three.js clock instance of the layer. Used internally for animations.

id: string

The id of the layer, this is used to identify the layer in the map

maxZoom: number

The maximum zoom of the layer

minZoom: number

The minimum zoom of the layer

renderingMode: "2d" | "3d" = "3d"

The rendering mode of the layer, this is used to identify the layer in the map

type: "custom"

The type of the layer, this is used to identify the layer in the map

Methods

  • Internal

    Handle the click event for a mesh This is used to trigger the click event for the item by WebGLRenderManager.

    Parameters

    • event: Layer3DInternalApiEvent

      The event data

    Returns void

  • Add 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

  • Adding a point light. The default options are mimicking the sun: lngLat: [0, 0] (null island) altitude: 2_000_000 meters altitudeReference: AltitudeReference.MEAN_SEA_LEVEL color: 0xffffff (white) intensity: 75 decay: 0.2

    Parameters

    • id: string

      The ID of the point light

    • options: PointLightOptions = {}

      The options to add the point light with

    Returns Layer3D

    The layer

  • 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

  • Get the map instance of the layer.

    Returns Map

    The map instance

  • Automatically called when the layer is added. (should not be called manually)

    Parameters

    • map: Map
    • gl: WebGL2RenderingContext

    Returns void

  • Automatically called when the layer is removed. (should not be called manually)

    Parameters

    • _map: Map
    • _gl: WebGL2RenderingContext | WebGLRenderingContext

    Returns void

  • Remove a mesh from the scene using its ID.

    Parameters

    • id: string

      The ID of the mesh to remove

    Returns Layer3D

    The layer

  • 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 WebGLManagerLayer to render the layer and return null.

    Returns null

    • where all the calculations for the layer are done.
  • 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

Was this helpful?