|
| 1 | +# 3DTilesRendererJS - Claude Code Guide |
| 2 | + |
| 3 | +## Project Overview |
| 4 | + |
| 5 | +**3DTilesRendererJS** is a Three.js renderer implementation for the [3D Tiles specification](https://github.com/CesiumGS/3d-tiles), an OGC standard for streaming massive geospatial 3D datasets. This NASA-AMMOS project supports rendering geographic and geometric tile data including Mars terrain, Google Photorealistic Tiles, and various map tile formats. |
| 6 | + |
| 7 | +- **Package**: `3d-tiles-renderer` (npm) |
| 8 | +- **License**: Apache-2.0 |
| 9 | + |
| 10 | +## Build Commands |
| 11 | + |
| 12 | +```bash |
| 13 | +npm install # Install dependencies |
| 14 | +npm start # Dev server at http://localhost:5173 |
| 15 | +npm run build-lib # Build library to /build |
| 16 | +npm test # TypeScript check + Vitest |
| 17 | +npm run lint # ESLint + TypeScript |
| 18 | +``` |
| 19 | + |
| 20 | +## Directory Structure |
| 21 | + |
| 22 | +``` |
| 23 | +src/ |
| 24 | +├── core/ # Framework-agnostic implementations |
| 25 | +│ ├── plugins/ # Base plugin classes |
| 26 | +│ └── renderer/ |
| 27 | +│ ├── loaders/ # Format loaders: B3DM, I3DM, PNTS, CMPT, MVT |
| 28 | +│ ├── tiles/ # Tile traversal algorithms |
| 29 | +│ └── utilities/ # BatchTable, PriorityQueue, LRUCache |
| 30 | +├── three/ # Three.js-specific implementations |
| 31 | +│ ├── plugins/ # Three.js plugins |
| 32 | +│ │ ├── images/ # Image overlay plugins (TMS, XYZ, WMTS, WMS, MVT, PMTiles) |
| 33 | +│ │ │ └── sources/ # Image source implementations |
| 34 | +│ │ ├── gltf/ # GLTF extensions & metadata |
| 35 | +│ │ └── batched/ # Batched rendering optimization |
| 36 | +│ └── renderer/ |
| 37 | +│ ├── loaders/ # Three.js tile format loaders |
| 38 | +│ ├── tiles/ # TilesRenderer & TilesGroup |
| 39 | +│ ├── controls/ # GlobeControls, EnvironmentControls |
| 40 | +│ └── math/ # Ellipsoid, OBB, GeoUtils |
| 41 | +├── r3f/ # React Three Fiber components |
| 42 | +└── plugins.js # Plugin re-exports |
| 43 | +
|
| 44 | +example/ # Three.js and R3F examples |
| 45 | +test/ # Vitest unit tests |
| 46 | +``` |
| 47 | + |
| 48 | +## Architecture |
| 49 | + |
| 50 | +### Main Classes |
| 51 | + |
| 52 | +- **TilesRenderer** (`src/three/renderer/tiles/TilesRenderer.js`) - Main Three.js rendering class |
| 53 | +- **TilesRendererBase** (`src/core/renderer/tiles/TilesRendererBase.js`) - Framework-agnostic core |
| 54 | + |
| 55 | +### Plugin System |
| 56 | + |
| 57 | +Plugins extend functionality through lifecycle hooks: |
| 58 | + |
| 59 | +```javascript |
| 60 | +class MyPlugin extends TilesPlugin { |
| 61 | + constructor() { |
| 62 | + super(); |
| 63 | + this.name = 'MY_PLUGIN'; |
| 64 | + } |
| 65 | + preprocessURL( url ) { } |
| 66 | + postProcess( tile ) { } |
| 67 | + onLoadModel( { scene, tile } ) { } |
| 68 | + onDisposeModel( { scene, tile } ) { } |
| 69 | +} |
| 70 | +``` |
| 71 | + |
| 72 | +### Tile Formats Supported |
| 73 | + |
| 74 | +- **B3DM** - Batched 3D Model |
| 75 | +- **I3DM** - Instanced 3D Model |
| 76 | +- **PNTS** - Point Cloud |
| 77 | +- **CMPT** - Composite |
| 78 | +- **MVT** - Mapbox Vector Tiles (in development) |
| 79 | +- **Quantized Mesh** - Terrain mesh |
| 80 | + |
| 81 | +## Code Style |
| 82 | + |
| 83 | +- **Indentation**: Tabs |
| 84 | +- **Quotes**: Single quotes |
| 85 | +- **Semicolons**: Always |
| 86 | +- **Naming**: Long descriptive names preferred (`isHierarchicallyVisible` not `isVis`) |
| 87 | +- **Private members**: Underscore prefix (`this._internalState`) |
| 88 | +- **Comments**: Explain WHY, not WHAT |
| 89 | + |
| 90 | +## Key Technologies |
| 91 | + |
| 92 | +- **three**: ^0.170.0 (required peer dependency) |
| 93 | +- **vite**: Build tool |
| 94 | +- **vitest**: Test runner |
| 95 | +- **typescript**: Type checking (JSDoc-based) |
| 96 | + |
| 97 | +## Module Exports |
| 98 | + |
| 99 | +- `3d-tiles-renderer` - Full library |
| 100 | +- `3d-tiles-renderer/core` - Core only |
| 101 | +- `3d-tiles-renderer/three` - Three.js implementation |
| 102 | +- `3d-tiles-renderer/r3f` - React Three Fiber |
| 103 | +- `3d-tiles-renderer/three/plugins` - Three.js plugins |
0 commit comments