New Open Source Library: Enhanced Cesium.js Utilities
Hi Cesium community!
I’ve been working with Cesium for a while and noticed some common challenges that kept coming up in projects. I created a utility library to address these and wanted to share it with the community.
Problems This Solves
Multiple Terrain Sources
Ever needed to combine high-res terrain for a specific area with global terrain? Cesium only supports one terrain provider at a time.
Collection Management
Managing thousands of instances without built-in tagging or filtering gets unwieldy fast.
Visual Highlighting
No built-in way to highlight selected entities with silhouettes or surface effects.
Solutions
Hybrid terrain sources:
import { HybridTerrainProvider } from "@juun-roh/cesium-utils";
const provider = TerrainProvider.fromUrl("your-terrain-url");
const tiles: HybridTerrainProvider.TerrainRegion["tiles"] = new Map();
// set custom region from zoom level and tile coordinates
// Level 13, tiles covering specific geographic area
tiles.set(13, {
x: [13963, 13967], // Tile X coordinates (west to east)
y: [2389, 2393], // Tile Y coordinates (north to south)
});
const region: HybridTerrainProvider.TerrainRegion = {
provider,
tiles,
};
const terrainProvider = new HybridTerrainProvider({
regions: [
// multiple regions
region,
],
defaultProvider: worldTerrain
});
viewer.terrainProvider = terrainProvider;
This works as:
worldTerrain
as the default provider- Custom regions override specific tile coordinates at defined zoom levels of default provider.
- Fallback to ellipsoid terrain where tile data is unavailable.
mixed terrain (ellipsoid + world)
You can see other API examples on GitHub.
What I’m Looking For
- Feedback on the API design
- Real-world use cases I might have missed
- Community input on the roadmap
- Contributors interested in expanding functionality
The library is MIT licensed and designed to be lightweight with tree-shaking support.
Documentation
NPM Package
GitHub Repository
Would love to hear your thoughts and experiences with these kinds of challenges!