Viewer

Table of Contents


Viewer Class

Viewer is the core class for the 3D map viewer, providing map display, camera control, layer management, scene rendering, and other capabilities.

Constructor

constructor(containerId: string, options?: ViewerOptions)

Parameters:

  • containerId (string): ID of the container DOM element
  • options (ViewerOptions, optional): Initialization configuration options

Example:

const viewer = new Viewer('map-container', {
  proj4: '+proj=utm +zone=50 +datum=WGS84 +units=m +no_defs',
  sunLight: true,
  baseMapUrls: 'https://your-domain.com/tiles/{z}/{x}/{y}.png',
  terrainUrl: 'https://your-domain.com/terrain'
});

Properties

Runtime Properties

Property Name Type Description
app ViewerApp ViewerApp instance
container HTMLDivElement Scene container DOM element
renderer object Renderer object, containing domElement (HTMLCanvasElement)
Property Name Type Description
viewMode "2D" | "3D" View mode
viewInfo object Current view info (heading, pitch, position)
projectedViewRange object Projected view range, containing coordinate array
fov number Field of View
proj4 string Proj4 projection string
userDefinedProj4 string? User-defined Proj4 string

Camera Properties

Property Name Type Description
camera object Camera object, containing position, rotation, fov, aspect, type
controlMode number Control mode
viewCollision boolean Scroll zoom collision prevention

Scene Rendering

Property Name Type Description
sunLight boolean Whether sun light is enabled
isSunShadow boolean? Whether sun shadows are enabled
sunFlare boolean Sun flare effect
sunIntensity number Sun light intensity
envLightIntensity number Environment light intensity
useAdditionalEnvLight boolean Whether to use additional environment light
sceneDate Date Scene date and time
useSceneDate boolean Whether to use scene date

Post-processing Effects

Property Name Type Description
postProcessingManager object Post-processing manager, see below for details
lut string? Deprecated, replaced by postProcessingManager

postProcessingManager Object:

Property Name Type Description
lut string? LUT color lookup table
lutIntensity number LUT intensity
brightness number Brightness
contrast number Contrast
saturation number Saturation
hue number Hue
ACESFilmicToneMapping boolean ACES tone mapping
blooming boolean Bloom effect
bloomingStrength number Bloom strength
bloomingThreshold number Bloom threshold
colorTemperature number Color temperature adjustment
ao boolean Ambient Occlusion
on function Event listener, e.g., on('LUTLoad', callback)
Property Name Type Description
terrainTransparency number Terrain transparency (0-1)

Contour Settings

Property Name Type Description
contourSetting object Contour configuration object
contourSetting.enabled boolean Whether contours are enabled
contourSetting.color number Contour color
contourSetting.lineWidth number Line width
contourSetting.contourInterval number Contour interval
contourSetting.minHeight number Minimum height
contourSetting.maxHeight number Maximum height
Property Name Type Description
identifyDrawing boolean Whether to identify drawing objects
identifyFeature boolean Whether to identify features
rotationBoxControl boolean Whether to show rotation control box
rotationBoxLocale LocaleName Rotation control box language

Map Display Area

Property Name Type Description
enableMapDisplayArea boolean Whether to enable map display area restriction
mapDisplayArea object Map display area configuration
mapDisplayArea.coords [number, number] Top-left and bottom-right coordinates
mapDisplayArea.fromEPSG number | string Coordinate system EPSG code

Clouds and Sky

Property Name Type Description
cloudBox CloudBoxSetting? Cloud box settings (getter/setter)
cloud SceneCloudSetting? Scene cloud settings (getter/setter)
volumetricLighting VolumetricLightingSetting? Volumetric lighting settings (getter/setter)

Basemap and Terrain

Property Name Type Description
baseMapUrls BaseMapUrl | BaseMapUrl[] Basemap URL configuration (setter)
baseMapUrls Array<{uuid, wrapper}> Basemap list (getter)
terrainUrl string | string[]? Terrain URL (setter)
terrainUrl string? Terrain URL (getter)
basemapScreenSpaceError number Basemap screen space error (LOD control)

Others

Property Name Type Description
animations Record<string, any> Animation collection
locale LocaleName Language settings

Methods

Camera Control

zoomTo(options: CameraPose): void

Instantly jumps to specified camera position (no animation).

Parameters:

  • options (CameraPose): Camera pose configuration
viewer.zoomTo({
  x: 500000,
  y: 3000000,
  z: 1000,
  heading: 0,
  pitch: -45
});
flyTo(options: CameraPose): void

Flies to specified camera position (with animation).

Parameters:

  • options (CameraPose): Camera pose configuration
flyToLookAt(options): void

Flies to and looks at a specified position.

Parameters:

{
  x: number,
  y: number,
  z: number,
  distance?: number  // Camera distance from target point
}

Point Cloud Layers

addPointcloudLayer(options: PointCloudLayerOptions): Promise<{id, layer}>

Adds a point cloud layer.

Returns: Promise containing layer ID and layer object

flyToPointcloudById(id: number | string): void

Flies to specified point cloud layer.

setPointcloudOpacityById(id: number | string, opacity: number): void

Sets point cloud opacity.

Parameters:

  • opacity: Decimal between 0-1
setPointcloudPointSizeById(id: number | string, size: number): void

Sets point cloud point size.

setPointCloudColorScheme(id: number | string, scheme: PointCloudColorScheme): void

Sets point cloud color scheme.

setPointCloudHeightRange(id: number | string, minHeight: number, maxHeight: number): void

Sets point cloud height range filter.

setPointCloudIntensityRange(id: number | string, minIntensity: number, maxIntensity: number): void

Sets point cloud intensity range filter.

3D Tiles Layers

add3DTilesLayer(options: Tiles3DLayerOptions): Promise<{id, layer}>

Adds a 3D Tiles layer.

Returns: Promise containing layer ID and layer object

flyTo3DTilesById(id: number | string, options?): void

Flies to specified 3D Tiles layer.

Parameters:

options?: {
  heading?: number,
  pitch?: number
}
set3DTilesOpacityById(id: number | string, opacity: number): void

Sets 3D Tiles opacity (0-1).

set3DTilesVisibleById(id: number | string, visible: boolean): void

Sets 3D Tiles visibility.

set3DTilesFeatureVisibleById(layerId: number | string, features: number[]): void

Sets visibility of specified features in 3D Tiles.

set3DTilesNoFlattening(layerIds: (number | string)[], isNoFlatten: boolean): void

Sets whether 3D Tiles should not be flattened.

getIs3DTilesNoFlatteningById(layerId: number | string): boolean

Gets whether a specified layer has no-flattening enabled.

getNoFlatteningList(): (number | string)[]

Gets list of all no-flattening layer IDs.

get3DTilesFeatureTree(layerId: number | string): any

Gets 3D Tiles feature tree structure.

setIs3DTilesRawFeatureTypesVisible(layerId, featureKeys, boolean): void

Sets visibility of 3D Tiles raw feature types.

flyTo3DTilesBBox(layerId: number | string, bbox: any): void

Flies to 3D Tiles bounding box.

clear3DTilesFeatureColorById(layerId: number): void

Clears 3D Tiles feature colors.

set3DTilesDefaultColorById(layerId: number, color: number, alpha: number): void

Sets 3D Tiles default color.

set3DTilesFeatureColorById(layerId: number, featureIds: number[], color: number, alpha: number): void

Sets color for specified features in 3D Tiles.

getIs3DTilesWireframeById(layerId: number | string): boolean

Gets whether wireframe mode is enabled.

setIs3DTilesWireframeById(layerId: number | string, isWireframe: boolean): void

Sets 3D Tiles wireframe mode.

setIs3DTilesUseEnvMap(layerId: number | string, isUseEnvMap: boolean): void

Sets whether 3D Tiles use environment map.

set3DTilesLoadStartEvent(layerId: number | string, callback: () => void): void

Sets 3D Tiles load start event callback.

set3DTilesLoadEvent(layerId: number | string, callback: () => void): void

Sets 3D Tiles load complete event callback.

set3DTilesErrorTarget(layerId: number | string, val: number): void

Sets 3D Tiles error target value (LOD control).

Basemap Management

addBaseMapLayer(value: BaseMapUrl, index: number): void

Adds a basemap layer at specified index position.

removeBaseMapLayer(index: number): void

Removes basemap layer at specified index.

moveUp(index: number): void

Moves tile map order up.

moveDown(index: number): void

Moves tile map order down.

getTileMap(): object | undefined

Gets tile map object.

Returns:

{
  buffGeometryLayers: {
    highlightById: (options: { idArray: number[] }) => void
  },
  updateStyleByIndex: (index: number, baseMap: BaseMapUrl) => void
} | undefined
updateTile(id, originalGeoJSON, modifiedGeoJSON, originalProj4, currentProj4): void

Updates tile data.

Screenshot and Recording

getScreenCaptureRaw(): Promise<Blob>

Gets raw screenshot data.

Returns: Promise

getScreenCapture(pictureName: string): void

Saves screenshot to file.

startVideoRecord(): void

Starts video recording.

stopVideoRecord(videoName: string): void

Stops video recording and saves.

Animation

playOrbitAnimation(config?: Partial<OrbitAnimationConfig>): void

Plays orbit animation.

Parameters:

{
  duration?: number,           // Total duration
  lookAt?: Position3D,        // Look-at point
  isCounterClockwise?: boolean, // Whether counter-clockwise
  heading?: number,           // Heading angle
  pitch?: number,             // Pitch angle
  distance?: number,          // Distance
  circleDuration?: number     // Single circle duration
}
stopOrbitAnimation(): void

Stops orbit animation.

Gaussian Splatting

setSplatting(path, positionInfo, cb?): void

Sets Gaussian splatting model.

Parameters:

path: string,
positionInfo: {
  position: Position3D,
  heading: number,
  pitch: number,
  roll: number,
  scale: number
},
cb?: () => void
flyToSplatting(): void

Flies to Gaussian splatting model.

Weather and Scene

setWeather(weather: Weather): void

Sets weather effect.

Parameters:

  • weather: "SUNNY" | "RAINY" | "FOGGY" | "SNOWY"

Position Information

getScale(): number

Gets current scale.

getPositionLocal(): {x, y, z}

Gets current local coordinate position.

getCartographic(): [longitude, latitude]

Gets current longitude and latitude coordinates.

Rotation Control Box

setRotationBoxTopRight(config: {top?, right?}): void

Sets rotation control box position.


Events

Use the on method to listen for events:

viewer.on(eventName, callback);

Event List

identify

Feature identification event.

Callback Parameter: IdentifyData

viewer.on('identify', (featureInfo) => {
  console.log('Identified feature:', featureInfo);
});
bimFeatureTypeLoad

BIM feature type load complete event.

Callback Parameters:

  • json: Record<string, number[]> - Feature type mapping
  • id: number - Layer ID
cameramove

Camera move event (normal precision).

Callback Parameters:

{
  x: number,
  y: number,
  z: number,
  heading: number,
  pitch: number
}
cameramoveprecise

Camera move event (high precision).

Callback Parameters: CameraPose

click

Mouse click event.

Callback Parameters:

(
  position: { x: number, y: number, z: number },
  obj: any,
  event: MouseEvent
)
move

Mouse move event.

Callback Parameters:

(
  position: { x: number, y: number, z: number },
  obj: any,
  event: MouseEvent
)

Configuration Options

ViewerOptions

Configuration options for the Viewer constructor.

Parameter Type Required Default Description
far number No - Camera far clipping plane distance
proj4 string No - Proj4 projection string
sunLight boolean No - Whether sun light is enabled
baseMapUrls BaseMapUrl | BaseMapUrl[] No - Basemap configuration
terrainUrl string No - Terrain service URL
isWebGL2 boolean No - Whether to use WebGL2
mapMaximumLevel number No - Map maximum level
licensingServiceUrl string No - Licensing service URL
basemapScreenSpaceError number No - Basemap screen space error (LOD)
viewCollision boolean No - Scroll zoom collision prevention
useSceneDate boolean No - Whether to use scene date

Basemap Configuration BaseMapUrl

Basemap supports multiple service types, can be a string URL or configuration object.

1. String Template URL

type BaseMapUrl = string;

Use tile URL template directly:

viewer.baseMapUrls = 'https://your-domain.com/tiles/{z}/{x}/{y}.png';

2. TEMPLATE Type

Type: TEMPLATEOptions

Field Type Required Description
type "TEMPLATE" Yes Service type
url string Yes Tile URL template
opacity number No Opacity (0-1)
{
  type: "TEMPLATE",
  url: "https://your-domain.com/{z}/{x}/{y}.png",
  opacity: 0.8
}

3. WMS Service

Type: WMSOptions

WMS (Web Map Service) standard service configuration.

Field Type Required Default Description
type "WMS" Yes - Service type
url string Yes - WMS service base URL
version string Yes "1.3.0" WMS version number
layers string Yes "0" Layer names (comma-separated)
format string Yes "image/png" Image format
styles string Yes "" Layer styles
key string Yes "" API key/token
opacity number No - Opacity (0-1)

Example:

{
  type: "WMS",
  url: "https://your-domain.com/wms",
  version: "1.3.0",
  layers: "layer1,layer2",
  format: "image/png",
  styles: "",
  key: "your-api-key"
}

4. ArcGIS MapServer

Type: ArcGisMapServerOptions

ArcGIS map service configuration.

Field Type Required Description
type "ArcGIS_MapService" Yes Service type
url string Yes ArcGIS MapServer URL
format string Yes Image format (default "png8")
epsg string Yes Coordinate system EPSG code
key string Yes API key

Example:

{
  type: "ArcGIS_MapService",
  url: "https://services.arcgis.com/xxx/arcgis/rest/services/xxx/MapServer",
  format: "png8",
  epsg: "EPSG:4326",
  key: "your-api-key"
}

5. ArcGIS FeatureServer

Type: ArcGisFeatureServerOptions

ArcGIS feature service configuration (supports vector rendering).

Inherits from: TileMapStyle

Field Type Required Description
type "ArcGIS_FeatureService" Yes Service type
url string Yes ArcGIS FeatureServer URL
epsg string No Coordinate system EPSG code
pointColor string No Point color
pointSize number No Point size (pixels)
lineColor string No Line color
lineWidth number No Line width (pixels)
fillColor string No Fill color

Example:

{
  type: "ArcGIS_FeatureService",
  url: "https://services.arcgis.com/xxx/arcgis/rest/services/xxx/FeatureServer/0",
  epsg: "EPSG:4326",
  pointColor: "#FF0000",
  pointSize: 5,
  lineColor: "#0000FF",
  lineWidth: 2,
  fillColor: "#00FF0080"
}

6. WFS Service

Type: WFSOptions

WFS (Web Feature Service) standard service configuration.

Inherits from: TileMapStyle

Field Type Required Default Description
type "WFS" Yes - Service type
uuid string No - Unique identifier
url string Yes - WFS service URL
version string Yes - WFS version number
typeName string Yes - Layer type name
outputFormat string Yes "GeoJSON" Output format
key string No - API key
rule any No - Style rules
SLD SldObj No - SLD style object
fields string[] No - Field list
text object No - Text style configuration
opacity number No - Opacity (0-1)

Text Style:

text?: {
  color?: string,              // Text color
  fontSize?: number,           // Font size
  property?: string,           // Property field name
  scaleDenominator?: {         // Scale range
    min: number | null,
    max: number | null
  }
}

Example:

{
  type: "WFS",
  url: "https://your-domain.com/geoserver/wfs",
  version: "2.0.0",
  typeName: "workspace:layer",
  outputFormat: "application/json",
  pointColor: "#FF0000",
  lineColor: "#0000FF",
  lineWidth: 2
}

7. GeoTwin FeatureTileService (Editable Layer)

Type: GeoTwinFeatureTileServiceOptions

GeoTwin's proprietary vector tile service supporting high-performance rendering and complex styling.

Field Type Required Default Description
type "GeoTwin_FeatureTileService" Yes - Service type
uuid string No - Unique identifier
url string Yes - Service URL (without /{z}/{x}/{y})
token string No - Access token
format string | boolean No true Response format (true=binary, recommended)
count number No - Max features per request
fields string[] Yes - Field list (recommended to specify explicitly)
rule GtFeatureTileStyleRule No - Style rules (migrating to SLD)
SLD SldObj No - SLD style object
params Record<string, string|boolean> No - Custom request parameters
TEXTLAYER_OPTIONS object No - Text label configuration
clampToModel boolean No - Whether to clamp to model
highlight Highlight No - Highlight configuration
opacity number No - Opacity (0-1)

TEXTLAYER_OPTIONS:

{
  clustering: boolean  // Whether to enable text clustering
}

Highlight Configuration:

highlight?: {
  idArray: number[],
  style: {
    lineColor?: string,
    lineWidth?: number,
    fillColor?: string
  }
}

Example:

{
  type: "GeoTwin_FeatureTileService",
  url: "https://api.your-domain.com/tiles/layer1",
  token: "your-token",
  fields: ["ogc_fid", "name", "type"],
  rule: {
    type: "classification",
    property: "type",
    styles: [
      {
        value: "residential",
        fillColor: "#FFD700",
        lineColor: "#FF4500",
        lineWidth: 2
      }
    ]
  }
}

TileMapStyle (Tile Map Style)

Basic style configuration for vector layers.

Field Type Description
pointColor string Point color (6-digit hex or rgba string)
pointSize number Point size (pixels)
lineColor string Line color
lineWidth number Line width (pixels)
fillColor string Fill color
graphicFill any Graphic fill
dashArray number[] Dash pattern

GtFeatureTileStyleRule (Style Rule)

Advanced style rules for GeoTwin FeatureTileService.

Rule Types

type GtFeatureTileStyleRuleType = "classification" | "range" | "gradient" | "histogram3D";
  • classification: Classification rule, sets styles based on different values of a field
  • range: Range rule, sets styles based on field value ranges
  • gradient: Gradient rule, sets gradient colors based on field values
  • histogram3D: 3D bar chart

Rule Configuration

Field Type Description
type GtFeatureTileStyleRuleType Rule type
property string Property field name
material string Material
baseHeight string | number Base height
topHeight string | number Top height
styles GtFeatureTileStyleRuleStyle[] Style array
sideTexture SideTexture Side texture
style object Style configuration (for gradients, etc.)

Style Configuration (GtFeatureTileStyleRuleStyle)

Supports very rich style options, including:

Point Styles:

  • pointColor: Point color
  • pointRadius: Point radius
  • text: Text style
  • IconMarker: Icon marker
  • TextMarker: Text marker
  • GLTFModelJson: 3D model
  • SectorScanJson: Sector scan effect

Line Styles:

  • lineColor: Line color
  • lineWidth: Line width
  • lineJoin: Join style ("round" | "bevel" | "miter")
  • lineCap: Cap style ("round" | "butt" | "square")
  • dashArray: Dash array
  • GlowLineJson: Glow line
  • TraceLineJson: Trace line
  • HorizontalDynamicFenceJson: Horizontal dynamic fence

Polygon Styles:

  • fillColor: Fill color
  • graphicFill: Graphic fill (supports line fill, etc.)
  • GenericDrawPolygon: Generic polygon drawing

Example: Classification Style

{
  type: "classification",
  property: "building_type",
  styles: [
    {
      value: "residential",
      fillColor: "#FFD700",
      lineColor: "#FF4500",
      lineWidth: 2,
      text: {
        color: "#000000",
        fontSize: 14,
        property: "name"
      }
    },
    {
      value: "commercial",
      fillColor: "#87CEEB",
      lineColor: "#4169E1",
      lineWidth: 2
    }
  ]
}

Example: Gradient Style

{
  type: "gradient",
  property: "population",
  style: {
    from: 0,
    to: 100000,
    styles: [
      { value: 0, fillColor: "#FFFFE0" },
      { value: 50000, fillColor: "#FFA500" },
      { value: 100000, fillColor: "#FF0000" }
    ]
  }
}

Example: 3D Bar Chart

{
  type: "histogram3D",
  property: "value",
  baseHeight: 0,
  topHeight: "value", // Use field value as height
  material: "basic",
  styles: [
    {
      fillColor: "#4169E1",
      lineColor: "#000000",
      lineWidth: 1
    }
  ]
}

Example: Icon Marker

{
  IconMarker: {
    icon: "/assets/marker.png",
    offset: 0,
    size: { x: 32, y: 32 },
    center: { x: 0.5, y: 1 }
  }
}

Example: 3D Model Marker

{
  GLTFModelJson: {
    path: "/models/tree.glb",
    coordinateSystem: "EPSG:4326",
    pitch: 0,
    heading: 0,
    roll: 0,
    scaleX: 1,
    scaleY: 1,
    scaleZ: 1
  }
}

Example: Glow Line

{
  GlowLineJson: {
    color: "#00FFFF",
    lineWidth: 3,
    glowWidth: 10,
    brightness: 2,
    renderOnTop: true
  }
}

Type Definitions

CameraPose

interface CameraPose extends Position3D, Rotation {
  epsg?: string;
  roll?: number;
}

Contains:

  • x, y, z: Position coordinates
  • heading: Heading angle (degrees)
  • pitch: Pitch angle (degrees)
  • roll: Roll angle (degrees, optional)
  • epsg: Coordinate system (optional)

Position3D / Position2D

interface Position3D {
  x: number;
  y: number;
  z: number;
}

interface Position2D {
  x: number;
  y: number;
}

Rotation

interface Rotation {
  heading: number;  // Heading angle (degrees)
  pitch: number;    // Pitch angle (degrees)
}

Weather

type Weather = "SUNNY" | "RAINY" | "FOGGY" | "SNOWY";

CloudBoxSetting

interface CloudBoxSetting {
  visible: boolean;      // Whether visible
  coverage: number;      // Coverage
  shadow: number;        // Shadow
  thickness: number;     // Thickness
  steps: number;         // Steps
  noise: number;         // Noise
  windSpeed: number;     // Wind speed
}

SceneCloudSetting

interface SceneCloudSetting {
  visible: boolean;      // Whether visible
  topLevel: number;      // Top level height
  baseLevel: number;     // Base level height
  range: number;         // Range
  flowSpeed: number;     // Flow speed
  steps: number;         // Steps
  coverage: number;      // Coverage
  cloudType: number;     // Cloud type
}

VolumetricLightingSetting

interface VolumetricLightingSetting {
  filterLen: number;     // Filter length
  intensity: number;     // Intensity
}

IdentifyData

Data types returned by identification events, can be one of the following:

IdentifyBimData

interface IdentifyBimData {
  layerId: number | string;
  featureId: number | undefined;
  attributes: AnyOptions | undefined;
  position: { x: number; y: number; z: number };
}

IdentifyPointCloudData

interface IdentifyPointCloudData {
  layerId: number | string;
  featureId: null;
  pointAttributes: {
    position: { x: number; y: number; z: number };
    color: [r: number, g: number, b: number, a: number];
    intensity: number;
    classification: number;
  };
}

IdentifyMapData

type IdentifyMapData = IdentifyMapSuccessData | IdentifyMapFailureData;

interface IdentifyMapSuccessData {
  layerId: string;
  position: Position2D;
  type: "GeoTwin_FeatureTileService" | "WFS";
  attributes: Record<string, string | number | boolean | null>;
  geometry?: Geometry;  // GeoJSON Geometry
}

interface IdentifyMapFailureData {
  error: string;
  layerId: undefined;
  position: Position2D;
  type: string;
}

Usage Examples

Basic Initialization

import { Viewer } from './Viewer3D';

const viewer = new Viewer('map-container', {
  proj4: '+proj=utm +zone=50 +datum=WGS84 +units=m +no_defs',
  sunLight: true,
  baseMapUrls: [
    'https://server.arcgisonline.com/ArcGIS/rest/services/World_Imagery/MapServer/tile/{z}/{y}/{x}',
    {
      type: "GeoTwin_FeatureTileService",
      url: "https://api.your-domain.com/tiles/roads",
      token: "your-token",
      fields: ["ogc_fid", "name", "road_type"],
      rule: {
        type: "classification",
        property: "road_type",
        styles: [
          {
            value: "highway",
            lineColor: "#FF0000",
            lineWidth: 4
          },
          {
            value: "local",
            lineColor: "#FFFFFF",
            lineWidth: 2
          }
        ]
      }
    }
  ],
  terrainUrl: 'https://your-domain.com/terrain'
});

Event Listening

// Camera move event
viewer.on('cameramove', (pos) => {
  console.log('Camera position:', pos);
});

// Feature identification event
viewer.on('identify', (data) => {
  if ('layerId' in data && 'attributes' in data) {
    console.log('Identified feature:', data.attributes);
  }
});

// Click event
viewer.on('click', (position, obj, event) => {
  console.log('Click position:', position);
});

Camera Control

// Fly to specified position
viewer.flyTo({
  x: 500000,
  y: 3000000,
  z: 1000,
  heading: 0,
  pitch: -45
});

// Orbit animation
viewer.playOrbitAnimation({
  lookAt: { x: 500000, y: 3000000, z: 0 },
  distance: 2000,
  circleDuration: 30000,
  pitch: -30
});

Adding Layers

// Add 3D Tiles
const { id, layer } = await viewer.add3DTilesLayer({
  url: 'https://your-domain.com/tileset.json',
  name: 'Building Model'
});

// Add point cloud
await viewer.addPointcloudLayer({
  url: 'https://your-domain.com/pointcloud/metadata.json',
  name: 'Point Cloud Data'
});

Post-processing Effects

// Enable bloom effect
viewer.postProcessingManager.blooming = true;
viewer.postProcessingManager.bloomingStrength = 1.5;
viewer.postProcessingManager.bloomingThreshold = 0.8;

// Color adjustment
viewer.postProcessingManager.brightness = 0.1;
viewer.postProcessingManager.contrast = 1.2;
viewer.postProcessingManager.saturation = 1.1;

// Load LUT
viewer.postProcessingManager.lut = '/assets/luts/cinematic.cube';
viewer.postProcessingManager.lutIntensity = 0.8;

Weather Effects

// Set weather
viewer.setWeather('RAINY');

// Cloud box configuration
viewer.cloudBox = {
  visible: true,
  coverage: 0.6,
  shadow: 0.5,
  thickness: 50,
  steps: 100,
  noise: 0.3,
  windSpeed: 10
};

Notes

  1. Basemap Order: In the baseMapUrls array, basemaps earlier in the array are at lower levels (underneath)
  2. LUT Deprecated: Using viewer.lut directly is deprecated, please use viewer.postProcessingManager.lut
  3. Coordinate System: Ensure all layers and camera positions use a consistent coordinate system (configured via proj4)
  4. Performance Optimization: Use basemapScreenSpaceError and set3DTilesErrorTarget to control LOD, balancing performance and quality
  5. GeoTwin FeatureTileService:
    • Recommend using binary format (format: true) for best performance
    • Explicitly specify fields list to avoid missing or loading unnecessary data
    • Style rules rule will gradually migrate to SLD object
  6. Event Listening: When using TypeScript, event callbacks will automatically infer correct types