3D-City Model
    Preparing search index...

    Class Layer

    Layer – Unified wrapper for a wide variety of Cesium scene layers (3D tiles, meshes, imagery, terrain, geojson, etc).

    Encapsulates both configuration and runtime state, custom shaders/styling/visibility, and offers utility methods for feature/content/visibility management, tagging, and hierarchy. Layer types can be easily checked via Layer.LayerTypes (B3DM, POINTS, MESH, etc).

    Cesium Viewer instance.

    Unique ID (auto-generated if not provided).

    Display name for UI and legends.

    One of Layer.LayerTypes, stringly-typed.

    Tags for grouping and filtering.

    The Cesium primitive/entity/object managed by this layer.

    Source or configuration URL.

    Initial visibility state.

    Can this layer be removed by the user?

    Parent/collection this layer belongs to.

    (Imagery) Layer index/hierarchy, if used.

    Custom shader for Cesium rendering (if set).

    Style configuration object for displayed features.

    Tiling/detail threshold.

    Whether adaptive error is enabled.

    Optional reference for managing thematic styling/feature visibility.

    Callback for when 'show' value changes.

    addContent(content) - Add/merge a content primitive or object.

    removeContent() - Remove its Cesium scene primitive/data source/imagery layer.

    toggleVisibility(show, ids) - Show/hide if id matches (for bulk ops).

    toggleAllVisibilityExcept(show, excludeIds) - Show/hide unless excluded by id.

    const meshLayer = new Layer(viewer, {type: Layer.LayerTypes.MESH, content: meshData, show: true});
    meshLayer.show = false;
    meshLayer.customShader = myShader;
    meshLayer.tags.push("building");

    Hierarchy (View Summary)

    Index

    Constructors

    • Parameters

      • viewer: any

        The active Cesium Viewer instance.

      • Optionaloptions: {
            content?: any;
            customShader?: CustomShader;
            deletable?: boolean;
            dynamicScreenSpaceError?: boolean;
            dynamicScreenSpaceErrorDensity?: number;
            dynamicScreenSpaceErrorFactor?: number;
            dynamicScreenSpaceErrorHeightFalloff?: number;
            id?: string;
            imageryIndex?: null | number;
            maximumScreenSpaceError?: number;
            name?: string;
            onShowChange?: (arg0: boolean) => void;
            parent?: null | Layer;
            show?: boolean;
            style?: any;
            styleManager?: any;
            tags?: string | string[];
            type?: null | string;
            url?: string;
        } = {}
        • Optionalcontent?: any

          Cesium primitive/entity/data/imagery/etc. managed by this layer.

        • OptionalcustomShader?: CustomShader

          Custom shader override for rendering.

        • Optionaldeletable?: boolean

          If false, prevents user from deleting/removing this layer.

        • OptionaldynamicScreenSpaceError?: boolean

          Enable adaptive (distance-based) detail for tiles.

        • OptionaldynamicScreenSpaceErrorDensity?: number

          Density parameter for adaptive LOD.

        • OptionaldynamicScreenSpaceErrorFactor?: number

          Factor parameter for adaptive LOD.

        • OptionaldynamicScreenSpaceErrorHeightFalloff?: number

          Height falloff for LOD optimization.

        • Optionalid?: string

          Unique layer ID (uuid generated if omitted).

        • OptionalimageryIndex?: null | number

          Optional imagery stacking/render order.

        • OptionalmaximumScreenSpaceError?: number

          Max error for LOD/tiling.

        • Optionalname?: string

          Human-readable display name (optional).

        • OptionalonShowChange?: (arg0: boolean) => void

          Callback, triggered whenever layer.visible ('show') changes.

        • Optionalparent?: null | Layer

          Parent/aggregate layer (if any).

        • Optionalshow?: boolean

          Initial visible state.

        • Optionalstyle?: any

          Style/appearance configuration for features/primitives/etc.

        • OptionalstyleManager?: any

          Style manager/controller (handles coloring/visibility in groups).

        • Optionaltags?: string | string[]

          Tags for grouping, styling, filtering layers.

        • Optionaltype?: null | string

          Layer type (see Layer.LayerTypes).

        • Optionalurl?: string

          Data source or config source URL.

      Returns Layer

      const terrainLayer = new Layer(viewer, {
      name: 'Digital Terrain',
      type: Layer.LayerTypes.TERRAIN,
      url: 'https://myserver/DEM',
      show: true
      });

      terrainLayer.show = false; // hides layer
      terrainLayer.customShader = myShader;

    Properties

    _clippingPolygons: any
    _customShader: CustomShader
    _dynamicScreenSpaceError: boolean
    _dynamicScreenSpaceErrorDensity: number
    _dynamicScreenSpaceErrorFactor: number
    _dynamicScreenSpaceErrorHeightFalloff: number
    _maximumScreenSpaceError: number
    _opaque: boolean
    _parent: null | Layer
    _show: boolean
    _style: any
    content: any

    Cesium primitive/entity/imagery/terrain object.

    deletable: boolean

    Is the layer removable?

    id: string

    Unique ID for this layer.

    imageryIndex: null | number
    name: string

    Display/UI name.

    onShowChange: (arg0: boolean) => void
    originalShader: CustomShader
    originalTranslucencyMode: any
    resolved: boolean
    styleManager: any
    tags: string[]

    Layer grouping/filter tags.

    type: null | string

    Layer type (matches Layer.LayerTypes string values).

    url: string

    Configuration/source URL.

    viewer: any
    LayerTypes: {
        B3DM: string;
        BASELAYER: string;
        COLLECTION: string;
        FEATURE: string;
        GEOJSON: string;
        GEOJSON3D: string;
        GLTF: string;
        IMAGERY: string;
        MESH: string;
        PARTICLE_SYSTEM: string;
        POINTS: string;
        TERRAIN: string;
    } = ...

    Enum of string layer types (B3DM, POINTS, ...).

    Accessors

    • get boundingSphere(): undefined | BoundingSphere

      Returns the bounding sphere of the layer, for spatial queries and UI zoom-to-fit. The implementation is type-dependent:

      • For tile/mesh/point clouds: directly returns content.boundingSphere.
      • For (Geo)JSON: computes bounding sphere from all polygon and polyline points.
      • For imagery: computes from imagery rectangle.
      • For terrain/default: returns undefined.

      Returns undefined | BoundingSphere

      The bounding sphere, or undefined if not computable.

    • get clippingPolygons(): any

      Get or set clipping polygons for this layer (used in 3D terrain/model clipping). Setter will propagate to the underlying Cesium content.

      Returns any

    • set clippingPolygons(value: any): void

      Parameters

      • value: any

      Returns void

    • set color(c: Color): void

      Set the global color for all grouped features (handled externally). For mesh types, this may be handled elsewhere.

      Parameters

      • c: Color

      Returns void

    • get customShader(): null | CustomShader

      Returns null | CustomShader

      • Current assigned CustomShader, if any.
    • set customShader(cs: null | CustomShader): void

      Assigns a new custom shader to this layer (or disables if falsy). For non-GEOJSON layer types, handles full reconstruction (with translucency mode handling). For GEOJSON and GEOJSON3D, directly updates polygon or polyline material alpha.

      Parameters

      • cs: null | CustomShader

        Shader instance or null to disable.

      Returns void

    • get dynamicScreenSpaceErrorDensity(): number

      Returns number

    • set dynamicScreenSpaceErrorDensity(value: number): void

      Parameters

      • value: number

      Returns void

    • get dynamicScreenSpaceErrorFactor(): number

      Returns number

    • set dynamicScreenSpaceErrorFactor(value: number): void

      Parameters

      • value: number

      Returns void

    • get dynamicScreenSpaceErrorHeightFalloff(): number

      Returns number

    • set dynamicScreenSpaceErrorHeightFalloff(value: number): void

      Parameters

      • value: number

      Returns void

    • get opaque(): boolean

      Whether this layer is currently set as opaque. Triggers shader/mode update when changed.

      Returns boolean

    • set opaque(value: boolean): void

      Parameters

      • value: boolean

      Returns void

    • get parent(): null | Layer

      Returns null | Layer

      • Current parent assigned, or null.
    • set parent(p: null | Layer): void

      Sets or gets the parent collection/group layer (if present). Use to build hierarchies or nested layer collections.

      Parameters

      • p: null | Layer

        Parent layer to assign.

      Returns void

    • get show(): boolean

      Returns boolean

      • Returns current "show" state.
    • set show(v: boolean): void

      Show or hide this Layer. Deeply propagates the visible state to underlying Cesium content. If the layer is of type FEATURE, it also updates the style manager’s feature visibility and hideIDs. Triggers the onShowChange callback.

      Parameters

      • v: boolean

        True to show, false to hide.

      Returns void

    • get style(): any

      Returns any

    • set style(s: any): void

      Sets or retrieves styling for the layer (e.g. for GeoJSON/tiles/features). For mesh types, style setting is usually not allowed.

      Parameters

      • s: any

        Style object.

      Returns void

    Methods

    • Iterator protocol implementation for Layer. For Layer collections/objects, allows use in for...of loops. Always returns the Layer instance itself (not a collection).

      Returns Layer

    • Sets the content of this Layer, and assigns this layer as its parent. Will throw if content is not a Layer.

      Parameters

      • content: Layer

        The Layer to add as content.

      Returns void

      If content is not a valid Layer.

    • Returns the current "content" object assigned to this layer.

      Returns any

      The Cesium or sublayer content object.

    • Returns this Layer if any of its tags are in the provided tags array.

      Parameters

      • tags: string[]

        Tags to check against.

      Returns null | Layer

    • Returns this Layer if its type matches the given type, else null. Typically used for gathering/iterating matching content.

      Parameters

      • type: string

        Type string to check.

      Returns null | Layer

    • Returns this layer's ID if any of its tags are in the provided tags array.

      Parameters

      • tags: string[]

        Tags to check against.

      Returns null | string

      ID if a tag matches, else null.

    • Returns this layer's ID if its type matches the given type, else null.

      Parameters

      • type: string

        Type string to check.

      Returns null | string

      ID if match, else null.

    • Checks if a given object is a valid Layer: Must be truthy, have an 'id' property, and be an actual Layer instance.

      Parameters

      • layer: any

        The object to check.

      Returns boolean

      True if the object is a valid Layer instance.

    • Removes the Cesium primitive/entity/etc. for this layer from the scene and severs parent links. Handles resource de-allocation by layer type (removes primitive, data source, imagery, or terrain).

      Returns void

    • Removes a layer (and its content), unlinks its parent, and disables its content link. Used for structured layer collections.

      Parameters

      • layer: Layer

        The layer instance to remove.

      Returns void

    • Shows the layer unless its ID or its content's UUID is present in the excludeIds array, otherwise hides it. Useful for toggling all layers except given ones.

      Parameters

      • show: boolean
      • excludeIds: string[]

      Returns void

    • Shows/hides the Layer if its ID is in layerIds (or if layerIds unspecified). Batch operation interface for toggling by ID sets.

      Parameters

      • show: boolean

        Target visible state.

      • layerIds: string | string[]

        ID or array of IDs to show/hide.

      Returns void