A complete modular layer system for your CesiumJS globe with:
✅ CesiumGlobe Component - Refactored to support plugin-based layers
- Event bus for inter-layer communication
- Shared store for layer state
- Dependency resolution (topological sort)
- Lifecycle hooks:
onMount,onUnmount,onUpdate,onCameraChange - Backward compatible with legacy
locationsprop
✅ Type Definitions - Full TypeScript support
CesiumLayer- Layer protocol interfaceLayerContext- Context passed to each layerLayerEventBus- Event system for communicationLayerStore- Shared state managementCameraState- Camera position/orientationLayerFactory<T>- Factory function patternLayerConfig- Configuration object
✅ User Locations Layer
- Displays markers with labels on the globe
- Click handler with events
- Customizable marker size and colors
- Example usage:
{ factory: userLocationsLayer, options: { locations: [{ id: '1', name: 'Tokyo', latitude: 35.6762, longitude: 139.6503 }], onLocationClick: (location) => console.log(location), }, }
✅ Country Outlines Layer
- Renders country boundaries using Natural Earth GeoJSON data
- Customizable color, opacity, width
- Uses CDN for data (no bundling required)
- Example usage:
{ factory: countryOutlinesLayer, options: { color: '#ffffff', opacity: 0.5, width: 2 }, }
✅ H3 Hexagons Layer
- Displays H3 hexagonal grid on globe
- Configurable resolution (0-15)
- Click handler logs hexagon ID (ready for AD4M integration)
- Example usage:
{ factory: h3HexagonsLayer, options: { resolution: 0, // 122 global hexagons onHexagonClick: (h3Index) => console.log('Clicked:', h3Index), }, }
✅ README.md with usage examples ✅ EXAMPLES.tsx with code samples ✅ Quick start guide
packages/
├── design-system/5-widgets/
│ └── src/solid/widgets/cesium/
│ ├── CesiumGlobe.tsx (241 lines)
│ │ - SimpleEventBus implementation
│ │ - SimpleStore implementation
│ │ - sortLayersByDependencies function
│ │ - Layer mounting/unmounting logic
│ │ - Camera change listener
│ │ - Legacy location rendering
│ └── types.ts (92 lines)
│ - Complete type definitions for layer protocol
│
└── cesium-layers/
├── package.json
├── tsconfig.json
├── README.md
├── EXAMPLES.tsx
└── src/
├── index.ts (exports)
├── types.ts (re-exports from @we/widgets)
├── user-locations.ts (102 lines)
├── country-outlines.ts (61 lines)
└── h3-hexagons.ts (116 lines)
packages/cesium-layers/dist/
├── index.js + index.d.ts
├── types.js + types.d.ts
├── user-locations.js + user-locations.d.ts
├── country-outlines.js + country-outlines.d.ts
└── h3-hexagons.js + h3-hexagons.d.ts
- h3-js: ^4.1.0 (H3 geospatial indexing)
- @types/cesium: ^1.70.0 (TypeScript definitions)
- Cesium 1.136.0 (already loaded via CDN)
import { CesiumGlobe } from '@we/widgets/solid';
import { userLocationsLayer, countryOutlinesLayer, h3HexagonsLayer } from '@we/cesium-layers';
function MyGlobe() {
return (
<CesiumGlobe
ionAccessToken="your-token"
layers={[
{
factory: userLocationsLayer,
options: {
locations: [
{ id: '1', name: 'Home', latitude: 37.7749, longitude: -122.4194 },
],
},
},
{
factory: countryOutlinesLayer,
options: { color: '#ffffff', opacity: 0.5 },
},
{
factory: h3HexagonsLayer,
options: {
resolution: 0,
onHexagonClick: (h3Index) => {
console.log('Hexagon clicked:', h3Index);
// Future: navigateToSpace(h3Index);
},
},
},
]}
/>
);
}To test the implementation:
- Import the layers in your app
- Add CesiumGlobe with layer configs
- Verify user locations render correctly
- Click a location marker - should log to console
- Toggle country outlines - should show/hide borders
- Click an H3 hexagon - should log H3 index to console
- Test with different H3 resolutions (0, 1, 2, 3)
- Test layer toggling with
enabled: false
- Test in your actual application
- Add more user locations with real data
- Experiment with H3 resolutions
- Integrate H3 clicks with AD4M spaces
- Add event listeners in parent component
- Create custom layers for your use case
- Add layer visibility controls UI
- Add more layers (roads, buildings, etc.)
- Publish @we/cesium-layers to npm
- Community contributions
- Performance optimizations for high-resolution H3 grids
✨ Modular - Each layer is independent and reusable ✨ Type-safe - Full TypeScript support ✨ Event-driven - Layers communicate via events ✨ Extensible - Easy to create new layers ✨ Dependency management - Layers can depend on other layers ✨ Clean separation - Business logic in layers, rendering in CesiumGlobe ✨ npm-ready - Can publish for community use
- H3 Resolution 0: 122 hexagons (very fast)
- H3 Resolution 1: 842 hexagons (fast)
- H3 Resolution 2: 5,882 hexagons (moderate)
- H3 Resolution 3: 41,162 hexagons (slower, test first)
- Higher resolutions may need viewport-based rendering
Current events emitted:
location-clicked- When user location is clickedhexagon-clicked- When H3 hexagon is clickedcountry-outlines-loaded- When country data loadscountry-outlines-error- If country data fails to loadh3-hexagons-loaded- When hexagons finish rendering
Old code still works:
<CesiumGlobe
locations={[{ id: '1', name: 'Tokyo', latitude: 35.6762, longitude: 139.6503 }]}
/>This uses the legacy rendering path (no layers).
Status: ✅ READY TO USE
All packages built successfully. No compilation errors. Ready for integration into your application!