@heliguy-xyz/splat-viewer 1.0.0-rc.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (131) hide show
  1. package/CHANGELOG.md +76 -0
  2. package/README.md +343 -0
  3. package/dist/web-component/CameraModeManager.d.ts +22 -0
  4. package/dist/web-component/CameraModeManager.d.ts.map +1 -0
  5. package/dist/web-component/FlyCameraScript.d.ts +2 -0
  6. package/dist/web-component/FlyCameraScript.d.ts.map +1 -0
  7. package/dist/web-component/ModelManager.d.ts +96 -0
  8. package/dist/web-component/ModelManager.d.ts.map +1 -0
  9. package/dist/web-component/NavigationCubeController.d.ts +216 -0
  10. package/dist/web-component/NavigationCubeController.d.ts.map +1 -0
  11. package/dist/web-component/OrbitCameraScript.d.ts +2 -0
  12. package/dist/web-component/OrbitCameraScript.d.ts.map +1 -0
  13. package/dist/web-component/SceneConfigManager.d.ts +21 -0
  14. package/dist/web-component/SceneConfigManager.d.ts.map +1 -0
  15. package/dist/web-component/SplatViewerCore.d.ts +141 -0
  16. package/dist/web-component/SplatViewerCore.d.ts.map +1 -0
  17. package/dist/web-component/SplatViewerElement.d.ts +249 -0
  18. package/dist/web-component/SplatViewerElement.d.ts.map +1 -0
  19. package/dist/web-component/TransformSystem.d.ts +86 -0
  20. package/dist/web-component/TransformSystem.d.ts.map +1 -0
  21. package/dist/web-component/loader/index.d.ts +18 -0
  22. package/dist/web-component/loader/index.d.ts.map +1 -0
  23. package/dist/web-component/loader/loadExtendedFormat.d.ts +7 -0
  24. package/dist/web-component/loader/loadExtendedFormat.d.ts.map +1 -0
  25. package/dist/web-component/loader/utils/loadGsplatEntity.d.ts +7 -0
  26. package/dist/web-component/loader/utils/loadGsplatEntity.d.ts.map +1 -0
  27. package/dist/web-component/navigation-cube/CameraTransitionController.d.ts +223 -0
  28. package/dist/web-component/navigation-cube/CameraTransitionController.d.ts.map +1 -0
  29. package/dist/web-component/navigation-cube/ControlPointManager.d.ts +225 -0
  30. package/dist/web-component/navigation-cube/ControlPointManager.d.ts.map +1 -0
  31. package/dist/web-component/navigation-cube/CubeRenderer.d.ts +274 -0
  32. package/dist/web-component/navigation-cube/CubeRenderer.d.ts.map +1 -0
  33. package/dist/web-component/navigation-cube/ThreeJsCubeRenderer.d.ts +217 -0
  34. package/dist/web-component/navigation-cube/ThreeJsCubeRenderer.d.ts.map +1 -0
  35. package/dist/web-component/splat-viewer.esm.js +139985 -0
  36. package/dist/web-component/splat-viewer.esm.min.js +6 -0
  37. package/dist/web-component/splat-viewer.js +139997 -0
  38. package/dist/web-component/splat-viewer.min.js +6 -0
  39. package/dist/web-component/types/CameraModeManager.d.ts +22 -0
  40. package/dist/web-component/types/CameraModeManager.d.ts.map +1 -0
  41. package/dist/web-component/types/FlyCameraScript.d.ts +2 -0
  42. package/dist/web-component/types/FlyCameraScript.d.ts.map +1 -0
  43. package/dist/web-component/types/ModelManager.d.ts +96 -0
  44. package/dist/web-component/types/ModelManager.d.ts.map +1 -0
  45. package/dist/web-component/types/NavigationCubeController.d.ts +216 -0
  46. package/dist/web-component/types/NavigationCubeController.d.ts.map +1 -0
  47. package/dist/web-component/types/OrbitCameraScript.d.ts +2 -0
  48. package/dist/web-component/types/OrbitCameraScript.d.ts.map +1 -0
  49. package/dist/web-component/types/SceneConfigManager.d.ts +21 -0
  50. package/dist/web-component/types/SceneConfigManager.d.ts.map +1 -0
  51. package/dist/web-component/types/SplatViewerCore.d.ts +141 -0
  52. package/dist/web-component/types/SplatViewerCore.d.ts.map +1 -0
  53. package/dist/web-component/types/SplatViewerElement.d.ts +249 -0
  54. package/dist/web-component/types/SplatViewerElement.d.ts.map +1 -0
  55. package/dist/web-component/types/TransformSystem.d.ts +86 -0
  56. package/dist/web-component/types/TransformSystem.d.ts.map +1 -0
  57. package/dist/web-component/types/attributes.d.ts +69 -0
  58. package/dist/web-component/types/attributes.d.ts.map +1 -0
  59. package/dist/web-component/types/core.d.ts +254 -0
  60. package/dist/web-component/types/core.d.ts.map +1 -0
  61. package/dist/web-component/types/enhanced-viewer.d.ts +597 -0
  62. package/dist/web-component/types/enhanced-viewer.d.ts.map +1 -0
  63. package/dist/web-component/types/events.d.ts +172 -0
  64. package/dist/web-component/types/events.d.ts.map +1 -0
  65. package/dist/web-component/types/index.d.ts +6 -0
  66. package/dist/web-component/types/index.d.ts.map +1 -0
  67. package/dist/web-component/types/loader/index.d.ts +18 -0
  68. package/dist/web-component/types/loader/index.d.ts.map +1 -0
  69. package/dist/web-component/types/loader/loadExtendedFormat.d.ts +7 -0
  70. package/dist/web-component/types/loader/loadExtendedFormat.d.ts.map +1 -0
  71. package/dist/web-component/types/loader/utils/loadGsplatEntity.d.ts +7 -0
  72. package/dist/web-component/types/loader/utils/loadGsplatEntity.d.ts.map +1 -0
  73. package/dist/web-component/types/loader.d.ts +39 -0
  74. package/dist/web-component/types/loader.d.ts.map +1 -0
  75. package/dist/web-component/types/navigation-cube/CameraTransitionController.d.ts +223 -0
  76. package/dist/web-component/types/navigation-cube/CameraTransitionController.d.ts.map +1 -0
  77. package/dist/web-component/types/navigation-cube/ControlPointManager.d.ts +225 -0
  78. package/dist/web-component/types/navigation-cube/ControlPointManager.d.ts.map +1 -0
  79. package/dist/web-component/types/navigation-cube/CubeRenderer.d.ts +274 -0
  80. package/dist/web-component/types/navigation-cube/CubeRenderer.d.ts.map +1 -0
  81. package/dist/web-component/types/navigation-cube/ThreeJsCubeRenderer.d.ts +217 -0
  82. package/dist/web-component/types/navigation-cube/ThreeJsCubeRenderer.d.ts.map +1 -0
  83. package/dist/web-component/types/types/attributes.d.ts +69 -0
  84. package/dist/web-component/types/types/attributes.d.ts.map +1 -0
  85. package/dist/web-component/types/types/core.d.ts +254 -0
  86. package/dist/web-component/types/types/core.d.ts.map +1 -0
  87. package/dist/web-component/types/types/enhanced-viewer.d.ts +597 -0
  88. package/dist/web-component/types/types/enhanced-viewer.d.ts.map +1 -0
  89. package/dist/web-component/types/types/events.d.ts +172 -0
  90. package/dist/web-component/types/types/events.d.ts.map +1 -0
  91. package/dist/web-component/types/types/index.d.ts +6 -0
  92. package/dist/web-component/types/types/index.d.ts.map +1 -0
  93. package/dist/web-component/types/types/loader.d.ts +39 -0
  94. package/dist/web-component/types/types/loader.d.ts.map +1 -0
  95. package/dist/web-component/types/utils/config.d.ts +30 -0
  96. package/dist/web-component/types/utils/config.d.ts.map +1 -0
  97. package/dist/web-component/types/utils/errorHandler.d.ts +245 -0
  98. package/dist/web-component/types/utils/errorHandler.d.ts.map +1 -0
  99. package/dist/web-component/types/utils/errorRecovery.d.ts +134 -0
  100. package/dist/web-component/types/utils/errorRecovery.d.ts.map +1 -0
  101. package/dist/web-component/types/utils/errorTesting.d.ts +105 -0
  102. package/dist/web-component/types/utils/errorTesting.d.ts.map +1 -0
  103. package/dist/web-component/types/utils/events.d.ts +35 -0
  104. package/dist/web-component/types/utils/events.d.ts.map +1 -0
  105. package/dist/web-component/types/utils/lazyLoader.d.ts +138 -0
  106. package/dist/web-component/types/utils/lazyLoader.d.ts.map +1 -0
  107. package/dist/web-component/types/utils/memoryOptimizer.d.ts +112 -0
  108. package/dist/web-component/types/utils/memoryOptimizer.d.ts.map +1 -0
  109. package/dist/web-component/types/utils/performanceBenchmark.d.ts +128 -0
  110. package/dist/web-component/types/utils/performanceBenchmark.d.ts.map +1 -0
  111. package/dist/web-component/types/utils/performanceMonitor.d.ts +171 -0
  112. package/dist/web-component/types/utils/performanceMonitor.d.ts.map +1 -0
  113. package/dist/web-component/utils/config.d.ts +30 -0
  114. package/dist/web-component/utils/config.d.ts.map +1 -0
  115. package/dist/web-component/utils/errorHandler.d.ts +245 -0
  116. package/dist/web-component/utils/errorHandler.d.ts.map +1 -0
  117. package/dist/web-component/utils/errorRecovery.d.ts +134 -0
  118. package/dist/web-component/utils/errorRecovery.d.ts.map +1 -0
  119. package/dist/web-component/utils/errorTesting.d.ts +105 -0
  120. package/dist/web-component/utils/errorTesting.d.ts.map +1 -0
  121. package/dist/web-component/utils/events.d.ts +35 -0
  122. package/dist/web-component/utils/events.d.ts.map +1 -0
  123. package/dist/web-component/utils/lazyLoader.d.ts +138 -0
  124. package/dist/web-component/utils/lazyLoader.d.ts.map +1 -0
  125. package/dist/web-component/utils/memoryOptimizer.d.ts +112 -0
  126. package/dist/web-component/utils/memoryOptimizer.d.ts.map +1 -0
  127. package/dist/web-component/utils/performanceBenchmark.d.ts +128 -0
  128. package/dist/web-component/utils/performanceBenchmark.d.ts.map +1 -0
  129. package/dist/web-component/utils/performanceMonitor.d.ts +171 -0
  130. package/dist/web-component/utils/performanceMonitor.d.ts.map +1 -0
  131. package/package.json +121 -0
package/CHANGELOG.md ADDED
@@ -0,0 +1,76 @@
1
+ # Changelog
2
+
3
+ All notable changes to this project will be documented in this file.
4
+
5
+ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
6
+ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
7
+
8
+ ## [1.0.0] - 2025-01-XX
9
+
10
+ ### Added
11
+
12
+ #### Multi-Model Support
13
+ - Add multiple models to the same scene with `addModel()`
14
+ - Remove models individually with `removeModel()`
15
+ - Query all loaded models with `getModels()`
16
+ - Get per-model statistics with `getModelStats()`
17
+ - Get scene-wide statistics with `getSceneStats()`
18
+ - Events: `model-added`, `model-removed`, `scene-cleared`
19
+
20
+ #### Transform System
21
+ - Apply 4x4 transformation matrices to models
22
+ - Set/get position, rotation, and scale independently
23
+ - Reset transforms to identity
24
+ - Event: `model-transform-changed`
25
+
26
+ #### Fly Camera Mode
27
+ - Switch between orbit and fly camera modes with `setCameraMode()`
28
+ - First-person WASD + mouse-look navigation with pointer lock
29
+ - Configurable movement speed, sensitivity, and key bindings
30
+ - Speed modifiers (Shift for fast, Ctrl for slow)
31
+ - Height constraints and collision detection options
32
+ - Events: `camera-mode-changed`, `fly-camera-move`, `fly-camera-look`
33
+
34
+ #### Scene Configuration
35
+ - Set and animate camera FOV with `setCameraFOV()` and `animateCameraFOV()`
36
+ - Set and animate background color with `setBackgroundColor()` and `animateBackgroundColor()`
37
+ - Support for multiple color formats (hex, RGB, RGBA, named colors)
38
+ - Events: `camera-fov-changed`, `background-color-changed`
39
+
40
+ #### TypeScript Support
41
+ - Full type definitions for all public APIs
42
+ - Export types for models, transforms, camera, and scene config
43
+ - IntrinsicElements declaration support for React/JSX
44
+
45
+ #### Documentation
46
+ - Comprehensive integration guide for frontend developers
47
+ - API quick reference
48
+ - Migration guide
49
+ - React/Next.js integration examples
50
+
51
+ ### Changed
52
+ - Package name changed to `@heliguy/web-viewer` (scoped package)
53
+ - Made package public for npm publishing
54
+ - Updated README with npm installation instructions
55
+ - Enhanced event system with more granular events
56
+
57
+ ### Fixed
58
+ - Improved type safety across all APIs
59
+ - Better error handling for model operations
60
+ - Consistent event emission patterns
61
+
62
+ ## [0.1.0] - 2024-XX-XX
63
+
64
+ ### Added
65
+ - Initial release
66
+ - Basic 3D Gaussian Splat viewer web component
67
+ - Support for .splat, .ply, .ply.compressed, and .sog formats
68
+ - PlayCanvas-based rendering engine
69
+ - Orbit camera controls
70
+ - Navigation cube for camera orientation
71
+ - Performance monitoring
72
+ - Loading states and error handling
73
+ - Self-contained bundle with zero external dependencies
74
+
75
+ [1.0.0]: https://github.com/Heliguy-com/3d-web-viewer/releases/tag/v1.0.0
76
+ [0.1.0]: https://github.com/Heliguy-com/3d-web-viewer/releases/tag/v0.1.0
package/README.md ADDED
@@ -0,0 +1,343 @@
1
+ # Heliguy Web Viewer
2
+
3
+ A self-contained 3D Gaussian Splat viewer web component built with PlayCanvas for high-performance
4
+ rendering of point cloud data. Framework-agnostic and embeddable in any web application with zero
5
+ external dependencies.
6
+
7
+ ## Features
8
+
9
+ - 🎯 **Gaussian Splat Rendering**: Native support for `.splat` files using PlayCanvas
10
+ - 📊 **PLY Support**: Traditional point cloud rendering for `.ply` and `.ply.compressed` formats
11
+ - 📦 **SOG Support**: Native support for `.sog` (Spatially Ordered Gaussians) files
12
+ - 🎮 **Interactive Controls**: Smooth camera navigation and manipulation
13
+ - 🧭 **Navigation Cube**: Interactive 3D cube for quick camera orientation control
14
+ - 📈 **Performance Monitoring**: Real-time rendering statistics
15
+ - ⚡ **High Performance**: WebGL2-powered rendering with PlayCanvas engine
16
+ - 📱 **Responsive Design**: Full-screen immersive viewing experience
17
+ - 🔧 **Self-Contained**: Single file with bundled PlayCanvas engine (2MB)
18
+ - 🎨 **Built-in Loading**: Professional loading spinner with orange/black theme
19
+ - 🚀 **Zero Dependencies**: No external scripts required
20
+
21
+ ### Enhanced Features (v1.0.0)
22
+
23
+ - 🎭 **Multi-Model Support**: Load and manage multiple models in the same scene
24
+ - 🔄 **Transform System**: Programmatically position, rotate, and scale models
25
+ - 🎥 **Fly Camera Mode**: First-person WASD + mouse-look navigation with configurable controls
26
+ - 🎨 **Scene Configuration**: Adjust FOV and background color with smooth animations
27
+ - 📡 **Comprehensive Events**: React to model lifecycle, transforms, camera changes, and more
28
+ - 📘 **TypeScript Support**: Full type definitions for all APIs
29
+
30
+ ## Quick Start
31
+
32
+ ### Installation
33
+
34
+ #### Via npm (Recommended)
35
+
36
+ ```bash
37
+ npm install @heliguy/web-viewer
38
+ ```
39
+
40
+ #### Via CDN
41
+
42
+ ```html
43
+ <!-- UMD Bundle -->
44
+ <script src="https://unpkg.com/@heliguy/web-viewer@1.0.0/dist/web-component/splat-viewer.min.js"></script>
45
+
46
+ <!-- ESM Bundle -->
47
+ <script type="module">
48
+ import '@heliguy/web-viewer/esm'
49
+ </script>
50
+ ```
51
+
52
+ ### Prerequisites
53
+
54
+ - Modern browser with WebGL2 support
55
+ - Node.js ≥18.0.0 (for development only)
56
+
57
+ ### Usage
58
+
59
+ #### Vanilla HTML
60
+
61
+ ```html
62
+ <!DOCTYPE html>
63
+ <html>
64
+ <head>
65
+ <title>3D Splat Viewer</title>
66
+ </head>
67
+ <body>
68
+ <splat-viewer
69
+ id="viewer"
70
+ width="100%"
71
+ height="600px"
72
+ auto-focus
73
+ enable-navigation-cube
74
+ ></splat-viewer>
75
+
76
+ <!-- Import from npm package -->
77
+ <script src="node_modules/@heliguy/web-viewer/dist/web-component/splat-viewer.min.js"></script>
78
+
79
+ <script>
80
+ const viewer = document.getElementById('viewer')
81
+ viewer.addEventListener('ready', () => {
82
+ viewer.load('path/to/model.splat')
83
+ })
84
+ </script>
85
+ </body>
86
+ </html>
87
+ ```
88
+
89
+ #### Embed via iframe
90
+
91
+ Use the provided `viewer.html` page that reads query parameters and configures the web component.
92
+ Host `viewer.html` alongside `dist/web-component/splat-viewer.min.js`.
93
+
94
+ Supported query params:
95
+
96
+ - `src` (required): URL to your model (encode it!)
97
+ - `width` (optional): CSS width (e.g. `100%`, `800px`)
98
+ - `height` (optional): CSS height (e.g. `100vh`, `600px`)
99
+ - `autoFocus` (optional): `true` | `false` (default: `true`)
100
+ - `stats` (optional): `true` | `false`
101
+
102
+ Example:
103
+
104
+ ```html
105
+ <iframe
106
+ src="https://your-domain.com/viewer.html?src=https%3A%2F%2Fcdn.yourdomain.com%2Fmodels%2FRyhope.ply&width=100%25&height=100vh&autoFocus=true"
107
+ width="100%"
108
+ height="600"
109
+ style="border:0; background:#000"
110
+ allowfullscreen
111
+ ></iframe>
112
+ ```
113
+
114
+ Notes:
115
+
116
+ - Ensure CORS allows the viewer origin to fetch the model (`Access-Control-Allow-Origin`).
117
+ - Prefer hosting `viewer.html`, the bundle, and models on the same domain to avoid CORS.
118
+ - URL-encode the `src` value.
119
+
120
+ #### React / Next.js
121
+
122
+ ```tsx
123
+ import { useEffect, useRef } from 'react'
124
+ import '@heliguy/web-viewer'
125
+
126
+ function App() {
127
+ const viewerRef = useRef<any>(null)
128
+
129
+ useEffect(() => {
130
+ const viewer = viewerRef.current
131
+ if (!viewer) return
132
+
133
+ const handleReady = () => {
134
+ viewer.load('/models/scene.splat')
135
+ }
136
+
137
+ viewer.addEventListener('ready', handleReady)
138
+ return () => viewer.removeEventListener('ready', handleReady)
139
+ }, [])
140
+
141
+ return (
142
+ <splat-viewer
143
+ ref={viewerRef}
144
+ width="100%"
145
+ height="600px"
146
+ auto-focus
147
+ />
148
+ )
149
+ }
150
+ ```
151
+
152
+ **TypeScript:** Add to your `global.d.ts`:
153
+ ```typescript
154
+ declare namespace JSX {
155
+ interface IntrinsicElements {
156
+ 'splat-viewer': React.DetailedHTMLProps<
157
+ React.HTMLAttributes<HTMLElement> & {
158
+ ref?: React.Ref<any>
159
+ src?: string
160
+ width?: string
161
+ height?: string
162
+ 'auto-focus'?: boolean
163
+ 'enable-stats'?: boolean
164
+ },
165
+ HTMLElement
166
+ >
167
+ }
168
+ }
169
+ ```
170
+
171
+ #### Vue 3
172
+
173
+ ```vue
174
+ <template>
175
+ <splat-viewer
176
+ ref="viewerRef"
177
+ width="100%"
178
+ height="600px"
179
+ auto-focus
180
+ />
181
+ </template>
182
+
183
+ <script setup>
184
+ import { ref, onMounted } from 'vue'
185
+ import '@heliguy/web-viewer'
186
+
187
+ const viewerRef = ref(null)
188
+
189
+ onMounted(() => {
190
+ const viewer = viewerRef.value
191
+ const handleReady = () => {
192
+ viewer.load('/models/scene.splat')
193
+ }
194
+ viewer.addEventListener('ready', handleReady)
195
+ })
196
+ </script>
197
+ ```
198
+
199
+ ## Commands
200
+
201
+ | Command | Description |
202
+ | ----------------------------- | ---------------------------------- |
203
+ | `npm run web-component:serve` | Start development server |
204
+ | `npm run web-component:build` | Build self-contained web component |
205
+ | `npm run web-component:clean` | Clean build artifacts |
206
+ | `npm run lint` | Check code quality with ESLint |
207
+ | `npm run lint:fix` | Fix linting issues automatically |
208
+ | `npm run format` | Format code with Prettier |
209
+ | `npm run format:check` | Check code formatting |
210
+
211
+ ## Web Component API
212
+
213
+ ### Attributes
214
+
215
+ #### Basic Configuration
216
+
217
+ - `src` - Model file path or URL
218
+ - `width` - Canvas width (default: "100%")
219
+ - `height` - Canvas height (default: "400px")
220
+ - `auto-focus` - Auto-focus on load (default: true)
221
+ - `enable-stats` - Show performance stats (default: false)
222
+ - `max-splats` - Maximum splat count (default: 2000000)
223
+
224
+ #### Camera Controls
225
+
226
+ - `orbit-sensitivity` - Mouse orbit sensitivity (default: 0.3)
227
+ - `pan-sensitivity` - Mouse pan sensitivity (default: 0.5)
228
+ - `zoom-sensitivity` - Mouse zoom sensitivity (default: 0.1)
229
+ - `min-distance` - Minimum camera distance (default: 1)
230
+ - `max-distance` - Maximum camera distance (default: 100)
231
+
232
+ #### Navigation Cube
233
+
234
+ - `enable-navigation-cube` - Show interactive navigation cube (default: false)
235
+ - `navigation-cube-size` - Cube size in pixels (default: 120)
236
+ - `navigation-cube-transition` - Camera transition duration in ms (default: 800)
237
+
238
+ ### Events
239
+
240
+ #### Core Events
241
+ - `ready` - Component initialized
242
+ - `loading-start` - Model loading started
243
+ - `loading-progress` - Model loading progress update
244
+ - `loaded` - Model loaded successfully
245
+ - `error` - Loading error occurred
246
+ - `stats-update` - Performance statistics update
247
+ - `camera-change` - Camera position/target changed
248
+ - `interaction-start` / `interaction-end` - User interaction with orbit controls
249
+
250
+ #### Multi-Model Events (v1.0.0)
251
+ - `model-added` - Model added to scene
252
+ - `model-removed` - Model removed from scene
253
+ - `scene-cleared` - All models cleared
254
+
255
+ #### Transform Events (v1.0.0)
256
+ - `model-transform-changed` - Model transform updated
257
+
258
+ #### Camera Events (v1.0.0)
259
+ - `camera-mode-changed` - Camera mode switched (orbit/fly)
260
+ - `fly-camera-move` - Fly camera position changed
261
+ - `fly-camera-look` - Fly camera rotation changed
262
+
263
+ #### Scene Config Events (v1.0.0)
264
+ - `camera-fov-changed` - Camera FOV changed
265
+ - `background-color-changed` - Background color changed
266
+
267
+ ## Project Structure
268
+
269
+ ```
270
+ src/
271
+ ├── web-component/ # Main web component implementation
272
+ │ ├── SplatViewerElement.ts # Web component class
273
+ │ ├── SplatViewerCore.ts # Core rendering engine
274
+ │ ├── NavigationCubeController.ts # Navigation cube controller
275
+ │ ├── OrbitCameraScript.ts # Camera controls
276
+ │ ├── navigation-cube/ # Navigation cube modules
277
+ │ │ ├── CubeRenderer.ts # 3D cube visual rendering
278
+ │ │ ├── ControlPointManager.ts # Control point UI elements
279
+ │ │ └── CameraTransitionController.ts # Camera animations
280
+ │ ├── types/ # TypeScript definitions
281
+ │ ├── loader/ # File loading system (.ply, .sog, .splat)
282
+ │ └── utils/ # Utility functions
283
+ ├── build/ # Build configuration
284
+ ├── dist/web-component/ # Built self-contained web component
285
+ │ └── splat-viewer.min.js # Single 2MB file with PlayCanvas
286
+ ├── test-web-component.html # Basic test page
287
+ └── test-navigation-cube.html # Navigation cube test page
288
+
289
+ assets/ # 3D model assets for testing
290
+ docs/ # Documentation
291
+ ```
292
+
293
+ ## Supported File Formats
294
+
295
+ - **.sog** - Spatially Ordered Gaussians (PlayCanvas native support)
296
+ - **.splat** - Gaussian Splat files (PlayCanvas native support)
297
+ - **.ply** - Point cloud files (standard format)
298
+ - **.ply.compressed** - Compressed PLY files (gzip/deflate)
299
+
300
+ ## Self-Contained Bundle
301
+
302
+ The web component is distributed as a single 2MB file (`splat-viewer.min.js`) that includes:
303
+
304
+ - Complete PlayCanvas engine (v2.11.8)
305
+ - Web component implementation
306
+ - File format loaders
307
+ - Performance monitoring
308
+ - Interactive controls
309
+
310
+ **Benefits:**
311
+
312
+ - Zero external dependencies
313
+ - Version consistency guaranteed
314
+ - Easy embedding in any web application
315
+ - Offline functionality
316
+
317
+ ## Development
318
+
319
+ ```bash
320
+ # Start development server
321
+ npm run web-component:serve
322
+
323
+ # Build for production
324
+ npm run web-component:build
325
+
326
+ # Clean build artifacts
327
+ npm run web-component:clean
328
+ ```
329
+
330
+ ## Deployment
331
+
332
+ ### Netlify
333
+
334
+ - Publish directory: `dist`
335
+ - Build command: `npm run build`
336
+ - Node version: 18 (configured in `netlify.toml`)
337
+
338
+ The build emits `dist/index.html` from `viewer.html` using a small zero-dependency Node script
339
+ (`build/copy-viewer-to-index.mjs`). Rollup uses an ESM config at `build/rollup.config.mjs`.
340
+
341
+ ## License
342
+
343
+ MIT License - see LICENSE file for details.
@@ -0,0 +1,22 @@
1
+ import type { CameraMode, FlyCameraConfig, FlyCameraState, OrbitCameraScript, PlayCanvasApplication, PlayCanvasEntity } from './types';
2
+ type EmitFn = (eventType: string, detail?: any) => void;
3
+ export declare class CameraModeManager {
4
+ private app;
5
+ private camera;
6
+ private orbit;
7
+ private fly;
8
+ private mode;
9
+ private emit;
10
+ constructor(app: PlayCanvasApplication, camera: PlayCanvasEntity, orbit: OrbitCameraScript | null, fly: any | null, emit: EmitFn, initialMode?: CameraMode);
11
+ getMode(): CameraMode;
12
+ setMode(nextMode: CameraMode): void;
13
+ setFlyConfig(config: Partial<FlyCameraConfig>): void;
14
+ getFlyConfig(): FlyCameraConfig | null;
15
+ getFlyState(): FlyCameraState | null;
16
+ private activateOrbitMode;
17
+ private deactivateOrbitMode;
18
+ private activateFlyMode;
19
+ private deactivateFlyMode;
20
+ }
21
+ export {};
22
+ //# sourceMappingURL=CameraModeManager.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"CameraModeManager.d.ts","sourceRoot":"","sources":["../../src/web-component/CameraModeManager.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EACV,UAAU,EACV,eAAe,EACf,cAAc,EACd,iBAAiB,EACjB,qBAAqB,EACrB,gBAAgB,EACjB,MAAM,SAAS,CAAA;AAEhB,KAAK,MAAM,GAAG,CAAC,SAAS,EAAE,MAAM,EAAE,MAAM,CAAC,EAAE,GAAG,KAAK,IAAI,CAAA;AAEvD,qBAAa,iBAAiB;IAC5B,OAAO,CAAC,GAAG,CAAuB;IAClC,OAAO,CAAC,MAAM,CAAkB;IAChC,OAAO,CAAC,KAAK,CAA0B;IACvC,OAAO,CAAC,GAAG,CAAY;IACvB,OAAO,CAAC,IAAI,CAAY;IACxB,OAAO,CAAC,IAAI,CAAQ;gBAGlB,GAAG,EAAE,qBAAqB,EAC1B,MAAM,EAAE,gBAAgB,EACxB,KAAK,EAAE,iBAAiB,GAAG,IAAI,EAC/B,GAAG,EAAE,GAAG,GAAG,IAAI,EACf,IAAI,EAAE,MAAM,EACZ,WAAW,GAAE,UAAkC;IAmB1C,OAAO,IAAI,UAAU;IAIrB,OAAO,CAAC,QAAQ,EAAE,UAAU,GAAG,IAAI;IA0BnC,YAAY,CAAC,MAAM,EAAE,OAAO,CAAC,eAAe,CAAC,GAAG,IAAI;IAMpD,YAAY,IAAI,eAAe,GAAG,IAAI;IAmBtC,WAAW,IAAI,cAAc,GAAG,IAAI;IAe3C,OAAO,CAAC,iBAAiB;IA+BzB,OAAO,CAAC,mBAAmB;IA4B3B,OAAO,CAAC,eAAe;IAKvB,OAAO,CAAC,iBAAiB;CAI1B"}
@@ -0,0 +1,2 @@
1
+ export declare function registerFlyCameraScript(): void;
2
+ //# sourceMappingURL=FlyCameraScript.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"FlyCameraScript.d.ts","sourceRoot":"","sources":["../../src/web-component/FlyCameraScript.ts"],"names":[],"mappings":"AAsEA,wBAAgB,uBAAuB,IAAI,IAAI,CA0X9C"}
@@ -0,0 +1,96 @@
1
+ /**
2
+ * ModelManager - Manages multiple 3D models in a single scene
3
+ *
4
+ * This class provides functionality to:
5
+ * - Add/remove models with unique IDs
6
+ * - Track model metadata and statistics
7
+ * - Extract model information (splat count, bounding box, memory usage)
8
+ * - Provide aggregate scene statistics
9
+ */
10
+ import type { AddModelOptions, ModelInfo, ModelMetadata, PlayCanvasApplication, SceneMetadata, TransformData } from './types';
11
+ export declare class ModelManager {
12
+ private models;
13
+ private app;
14
+ private _eventEmitter;
15
+ constructor(app: PlayCanvasApplication, eventEmitter?: (eventType: string, detail: any) => void);
16
+ /**
17
+ * Generate a unique model ID
18
+ */
19
+ private generateModelId;
20
+ /**
21
+ * Extract a human-readable model name from the source
22
+ */
23
+ private extractModelName;
24
+ /**
25
+ * Extract metadata from a loaded model
26
+ */
27
+ private extractMetadata;
28
+ /**
29
+ * Extract splat count from entity/asset
30
+ */
31
+ private extractSplatCount;
32
+ /**
33
+ * Calculate bounding box for an entity
34
+ */
35
+ private calculateBoundingBox;
36
+ /**
37
+ * Estimate GPU memory usage based on splat count
38
+ * Formula: ~64 bytes per splat (approximate)
39
+ */
40
+ private estimateMemoryUsage;
41
+ /**
42
+ * Get current transform data from an entity
43
+ */
44
+ private getEntityTransform;
45
+ /**
46
+ * Add a model to the scene
47
+ * @param source URL, File, or Blob containing the model data
48
+ * @param options Configuration options for the model
49
+ * @returns Promise resolving to model information
50
+ */
51
+ addModel(source: string | File | Blob, options?: AddModelOptions): Promise<ModelInfo>;
52
+ /**
53
+ * Remove a specific model from the scene
54
+ * @param modelId ID of the model to remove
55
+ */
56
+ removeModel(modelId: string): void;
57
+ /**
58
+ * Get information about all loaded models
59
+ * @returns Array of model information objects
60
+ */
61
+ getModels(): ModelInfo[];
62
+ /**
63
+ * Get information about a specific model
64
+ * @param modelId ID of the model
65
+ * @returns Model information or undefined if not found
66
+ */
67
+ getModelById(modelId: string): ModelInfo | undefined;
68
+ /**
69
+ * Get statistics for a specific model
70
+ * @param modelId ID of the model
71
+ * @returns Model metadata and statistics
72
+ */
73
+ getModelStats(modelId: string): ModelMetadata;
74
+ /**
75
+ * Get statistics for all models
76
+ * @returns Map of model IDs to metadata
77
+ */
78
+ getAllModelStats(): Record<string, ModelMetadata>;
79
+ /**
80
+ * Get aggregate scene statistics
81
+ * @returns Scene-wide metadata
82
+ */
83
+ getSceneStats(): SceneMetadata;
84
+ /**
85
+ * Clear all models from the scene
86
+ */
87
+ clear(): void;
88
+ /**
89
+ * Update transform for a model
90
+ * @param modelId ID of the model
91
+ * @param transform New transform data
92
+ */
93
+ updateModelTransform(modelId: string, transform: TransformData): void;
94
+ }
95
+ export default ModelManager;
96
+ //# sourceMappingURL=ModelManager.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ModelManager.d.ts","sourceRoot":"","sources":["../../src/web-component/ModelManager.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAMH,OAAO,KAAK,EACV,eAAe,EAGf,SAAS,EACT,aAAa,EACb,qBAAqB,EAGrB,aAAa,EACb,aAAa,EAEd,MAAM,SAAS,CAAA;AAUhB,qBAAa,YAAY;IACvB,OAAO,CAAC,MAAM,CAA4C;IAC1D,OAAO,CAAC,GAAG,CAAuB;IAClC,OAAO,CAAC,aAAa,CAAwD;gBAG3E,GAAG,EAAE,qBAAqB,EAC1B,YAAY,CAAC,EAAE,CAAC,SAAS,EAAE,MAAM,EAAE,MAAM,EAAE,GAAG,KAAK,IAAI;IAMzD;;OAEG;IACH,OAAO,CAAC,eAAe;IASvB;;OAEG;IACH,OAAO,CAAC,gBAAgB;IAiBxB;;OAEG;IACH,OAAO,CAAC,eAAe;IA2DvB;;OAEG;IACH,OAAO,CAAC,iBAAiB;IA2BzB;;OAEG;IACH,OAAO,CAAC,oBAAoB;IAmD5B;;;OAGG;IACH,OAAO,CAAC,mBAAmB;IAI3B;;OAEG;IACH,OAAO,CAAC,kBAAkB;IAkC1B;;;;;OAKG;IACU,QAAQ,CACnB,MAAM,EAAE,MAAM,GAAG,IAAI,GAAG,IAAI,EAC5B,OAAO,GAAE,eAAoB,GAC5B,OAAO,CAAC,SAAS,CAAC;IAiKrB;;;OAGG;IACI,WAAW,CAAC,OAAO,EAAE,MAAM,GAAG,IAAI;IAgCzC;;;OAGG;IACI,SAAS,IAAI,SAAS,EAAE;IAW/B;;;;OAIG;IACI,YAAY,CAAC,OAAO,EAAE,MAAM,GAAG,SAAS,GAAG,SAAS;IAgB3D;;;;OAIG;IACI,aAAa,CAAC,OAAO,EAAE,MAAM,GAAG,aAAa;IAUpD;;;OAGG;IACI,gBAAgB,IAAI,MAAM,CAAC,MAAM,EAAE,aAAa,CAAC;IAUxD;;;OAGG;IACI,aAAa,IAAI,aAAa;IA4DrC;;OAEG;IACI,KAAK,IAAI,IAAI;IAapB;;;;OAIG;IACI,oBAAoB,CAAC,OAAO,EAAE,MAAM,EAAE,SAAS,EAAE,aAAa,GAAG,IAAI;CAW7E;AAED,eAAe,YAAY,CAAA"}