How dvt3d/dc-sdk works
Project type and purpose
• DC-SDK is an open-source JavaScript/TypeScript SDK built on Cesium, designed to accelerate the development of 3D WebGIS applications.
• It provides a core “DC” namespace (DC.Viewer, DC.Layer, DC.Overlay, DC.Widget, etc.), dozens of feature modules (animation, chart, effect, event, imagery, material, math, measure, plot, terrain, weather, wind, etc.), theming (SCSS), CLI/build scripts, documentation site, and a gallery of HTML examples.
Top-level structure and build/deploy components
• Source: /src – organized by feature areas (modules/, global-api/, libs/, index.js).
• Themes: /src/themes – SCSS for UI widgets.
• Build scripts: gulpfile.js, server.js, package.json, .github/workflows/build.yml.
• Docs site: /docs – VitePress configuration and markdown.
• Examples: /examples – self-contained HTML/JS demos plus assets.
• Distribution: /dist via gulp/webpack/Vite – produces dc.min.js, dc.min.css, and /resources (Cesium assets).
Key runtime components (to represent
a. DC Core Loader
• DC.ready() – bootstrap, configures CESIUM_BASE_URL.
b. Viewer
• DC.Viewer – wraps Cesium.Viewer, manages scene, camera, globe, controls.
c. Module Registry
• Feature modules (animation, charts, effects, events, imagery, layers, overlays, material, math, measure, plot, terrain, weather, wind, widget) are lazy-loaded or initialized by Viewer.
d. Cesium Engine
• Core Cesium API (Scene, Entities, Primitives, Camera, DataSources, ImageryProviders, TilingSchemes, etc.)
• Static resources: Assets, Workers, ThirdParty (served from libs/dc-sdk/resources)
e. External Services / Data Providers
• AMap, Baidu, Google, ArcGIS, TDT, Tencent imagery providers
• Data formats: GeoJSON, KML, CZML, I3S, glTF/GLB, 3D Tiles, shapefiles, geojson, turf-based geometry transformations
f. UI Widgets
• Compass, ContextMenu, DistanceLegend, HawkeyeMap, LoadingMask, LocationBar, MapSwitch, Popup, SceneSplit, TilesetSplit, Tooltip, ZoomController
Interactions and data flow
1. Build Pipeline (Developer Machine)
• gulp/webpack/Vite compiles /src + SCSS → dc.min.js, dc.min.css
• Copy Cesium static resources → libs/dc-sdk/resources
• Publish to NPM and/or CDN
2. Consumer Application
• import '@dvgis/dc-sdk/dist/dc.min.css' & dc.min.js or install via NPM/Yarn
• Call DC.ready(config) → load Cesium assets from baseUrl
• Instantiate new DC.Viewer({…}) → triggers:
– Module initialization (global APIs, imagery, layers, overlays, etc.)
– Underlying Cesium.Viewer creation
3. Viewer Runtime
• DC modules translate calls to Cesium primitives/entities, shaders (GLSL under /modules/material/shader), data sources, and WebGL operations
• Scene rendered by Cesium’s engine in WebGL canvas
4. Optional interactions
• Events published by DC.Event module
• Widgets manipulate Cesium controls and DOM overlays
• External tile/imagery services fetched over HTTP
Architectural patterns and design principles
• Modular architecture – each feature lives in its own folder under /src/modules.
• Facade pattern – DC.Viewer abstracts away Cesium complexity.
• Plugin-style loading – DC.globalApi and DC.config allow extension/custom imagery providers, custom layers, custom materials.
• Separation of concerns – rendering (Cesium), business logic (DC modules), UI (widgets/themes), and documentation/examples.
– Clear, per-component labels (e.g., “DC.Viewer”, “Cesium Engine”, “ImageryProvider Plugin”).
• Blue for SDK internals
• Green for build/deploy infrastructure
• Orange for third-party/Cesium
• Purple for runtime services