storysplat-viewer 2.7.18 → 2.9.0

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.
package/README.md CHANGED
@@ -13,6 +13,8 @@ A powerful npm package for embedding and interacting with 3D Gaussian Splatting
13
13
  - [API Reference](#api-reference)
14
14
  - [Controlling the Viewer](#controlling-the-viewer)
15
15
  - [Configuration Options](#configuration-options)
16
+ - [Viewer Theme Customization](#viewer-theme-customization)
17
+ - [Splat Relighting](#splat-relighting)
16
18
  - [Internationalization (i18n)](#internationalization-i18n)
17
19
  - [Events](#events)
18
20
  - [React Integration](#react-integration)
@@ -129,7 +131,11 @@ When using `createViewer()` with self-hosted JSON, the scene data should match t
129
131
  | `customMeshes` | `array` | Imported 3D models |
130
132
  | `uiColor` | `string` | Accent color for UI controls |
131
133
  | `uiOptions` | `object` | UI visibility toggles and button labels |
134
+ | `uiOptions.viewerTheme` | `ViewerTheme` | Custom viewer theme overrides (colors, fonts, radii) |
132
135
  | `defaultCameraMode` | `string` | Initial camera mode: `'tour'`, `'explore'`, or `'walk'` |
136
+ | `revealStyle` | `string` | Reveal animation style: `'bloom'` or `'radial'` |
137
+ | `doubleTapMoveSpeed` | `number` | Auto-forward speed on double-tap in explore mode (default: 1.0) |
138
+ | `splatRelighting` | `object` | Splat relighting config (enabled, ambientColor, ambientIntensity, allowViewerToggle, viewerDefaultOn) |
133
139
 
134
140
  The viewer's transform layer normalizes all field variations automatically, so JSON exported from any version of the editor will work.
135
141
 
@@ -164,6 +170,7 @@ interface ViewerFromSceneIdOptions {
164
170
  showUI?: boolean;
165
171
  backgroundColor?: string;
166
172
  revealEffect?: 'fast' | 'medium' | 'slow' | 'none';
173
+ revealStyle?: 'bloom' | 'radial';
167
174
  lazyLoad?: boolean;
168
175
  lazyLoadThumbnail?: string;
169
176
  lazyLoadButtonText?: string;
@@ -290,6 +297,7 @@ interface ViewerOptions {
290
297
 
291
298
  // Loading animation
292
299
  revealEffect?: 'fast' | 'medium' | 'slow' | 'none';
300
+ revealStyle?: 'bloom' | 'radial'; // 'bloom' = burst with overshoot, 'radial' = classic dot wave
293
301
 
294
302
  // Lazy loading
295
303
  lazyLoad?: boolean;
@@ -317,10 +325,85 @@ Control how the splat appears when loaded:
317
325
 
318
326
  ```javascript
319
327
  const viewer = createViewer(container, sceneData, {
320
- revealEffect: 'medium' // 'fast' | 'medium' | 'slow' | 'none'
328
+ revealEffect: 'medium', // 'fast' | 'medium' | 'slow' | 'none'
329
+ revealStyle: 'bloom' // 'bloom' (burst with overshoot) | 'radial' (classic dot wave)
321
330
  });
322
331
  ```
323
332
 
333
+ ## Viewer Theme Customization
334
+
335
+ The viewer supports deep CSS customization via the `ViewerTheme` interface. You can override colors, font sizes, border radii, and more — either via scene data or programmatically.
336
+
337
+ ### Setting a Theme via Scene Data
338
+
339
+ ```javascript
340
+ const sceneData = await fetch('/scene.json').then(r => r.json());
341
+
342
+ sceneData.uiOptions = {
343
+ ...sceneData.uiOptions,
344
+ viewerTheme: {
345
+ buttonBg: 'rgba(20, 20, 40, 0.9)',
346
+ buttonTextColor: '#e0e0ff',
347
+ popupBg: 'rgba(10, 10, 30, 0.95)',
348
+ popupTextColor: '#ffffff',
349
+ preloaderBg: '#0a0a1e',
350
+ joystickBaseColor: 'rgba(100, 100, 255, 0.3)',
351
+ joystickThumbColor: 'rgba(150, 150, 255, 0.6)',
352
+ buttonBorderRadius: '12px',
353
+ buttonFontSize: '13px',
354
+ fontFamily: '"Inter", sans-serif',
355
+ }
356
+ };
357
+
358
+ const viewer = createViewer(container, sceneData);
359
+ ```
360
+
361
+ ### Available Theme Properties
362
+
363
+ | Category | Properties |
364
+ |----------|-----------|
365
+ | **Colors** (19) | `buttonBg`, `buttonHoverBg`, `buttonTextColor`, `popupBg`, `popupTextColor`, `popupCloseBtnColor`, `popupLinkBtnColor`, `preloaderBg`, `preloaderTextColor`, `infoBannerBg`, `dropdownBg`, `watermarkBg`, `helpPanelBg`, `errorPopupBg`, `errorTitleColor`, `lazyLoadBg`, `joystickBaseColor`, `joystickThumbColor`, `portalPopupBg` |
366
+ | **Typography** (8) | `fontFamily`, `buttonFontSize`, `popupTitleFontSize`, `popupContentFontSize`, `infoBannerTitleFontSize`, `infoBannerContentFontSize`, `progressFontSize`, `modeBtnFontSize`, `watermarkFontSize` |
367
+ | **Border Radii** (6) | `buttonBorderRadius`, `popupBorderRadius`, `dropdownBorderRadius`, `helpPanelBorderRadius`, `errorPopupBorderRadius`, `lazyLoadBtnBorderRadius` |
368
+ | **Other** (3) | `dropdownBlur`, `progressBarHeight`, `preloaderBarHeight` |
369
+
370
+ All properties are optional — unspecified values fall back to built-in defaults.
371
+
372
+ ### Generating Styles Programmatically
373
+
374
+ ```javascript
375
+ import { generateViewerStyles } from 'storysplat-viewer';
376
+
377
+ const css = generateViewerStyles({
378
+ buttonBg: 'rgba(0, 0, 0, 0.8)',
379
+ buttonTextColor: '#fff',
380
+ });
381
+
382
+ // Inject into your page
383
+ const style = document.createElement('style');
384
+ style.textContent = css;
385
+ document.head.appendChild(style);
386
+ ```
387
+
388
+ ## Splat Relighting
389
+
390
+ Scene lights can dynamically illuminate Gaussian Splats for dramatic lighting effects. Configure relighting in scene data:
391
+
392
+ ```javascript
393
+ const sceneData = {
394
+ // ... other scene config ...
395
+ splatRelighting: {
396
+ enabled: true,
397
+ ambientColor: '#ffffff', // Ambient light color for unlit areas
398
+ ambientIntensity: 0.8, // 0-1, ambient fill strength
399
+ allowViewerToggle: true, // Show toggle button in viewer UI
400
+ viewerDefaultOn: false, // Start with relighting off for end users
401
+ }
402
+ };
403
+ ```
404
+
405
+ When `allowViewerToggle` is `true`, end users see a toggle button in the viewer to switch relighting on/off.
406
+
324
407
  ## Internationalization (i18n)
325
408
 
326
409
  All user-facing UI text can be customized via `ButtonLabels`. This enables full translation or label renaming.
@@ -401,6 +484,22 @@ viewer.setButtonLabels({ next: 'Suivant', previous: 'Pr\u00e9c\u00e9dent' });
401
484
  | `helpTourDesc` | `"Follow predefined path"` | Help tour description |
402
485
  | `helpExploreDesc` | `"Free movement"` | Help explore description |
403
486
  | `helpWalkDesc` | `"First-person walking"` | Help walk description |
487
+ | `helpTourControls` | `"Controls:"` | Help panel - tour controls heading |
488
+ | `helpTourScroll` | `"Scroll to navigate"` | Help panel - tour scroll instruction |
489
+ | `helpTourDrag` | `"Drag to look around"` | Help panel - tour drag instruction |
490
+ | `helpExploreControls` | `"Controls:"` | Help panel - explore controls heading |
491
+ | `helpExploreLMB` | `"Left click + drag to orbit"` | Help panel - explore LMB |
492
+ | `helpExploreRMB` | `"Right click + drag to pan"` | Help panel - explore RMB |
493
+ | `helpExploreWASD` | `"WASD to move"` | Help panel - explore WASD |
494
+ | `helpExploreShift` | `"Shift to speed up"` | Help panel - explore shift |
495
+ | `helpExploreScroll` | `"Scroll to zoom"` | Help panel - explore scroll |
496
+ | `helpExploreDblClick` | `"Double-click to auto-move"` | Help panel - explore double-click |
497
+ | `helpWalkControls` | `"Controls:"` | Help panel - walk controls heading |
498
+ | `helpWalkClick` | `"Click to start"` | Help panel - walk click |
499
+ | `helpWalkWASD` | `"WASD to walk"` | Help panel - walk WASD |
500
+ | `helpWalkMouse` | `"Mouse to look"` | Help panel - walk mouse |
501
+ | `helpWalkShift` | `"Shift to run"` | Help panel - walk shift |
502
+ | `helpWalkSpace` | `"Space to jump"` | Help panel - walk space |
404
503
  | `errorWebGLTitle` | `"Unable to Initialize 3D Graphics"` | WebGL error heading |
405
504
  | `errorWebGLMessage` | `"Your browser or device..."` | WebGL error body |
406
505
  | `percentageFormat` | `"{n}%"` | Progress percentage format |
@@ -1085,6 +1184,46 @@ loadScene('campervan');
1085
1184
 
1086
1185
  The viewer itself has no "base path" concept - splat file paths in your scene JSON should be absolute URLs or relative to your HTML page, not to the viewer JS file.
1087
1186
 
1187
+ ## Exports
1188
+
1189
+ The package exports the following types and utilities:
1190
+
1191
+ ```typescript
1192
+ // Core viewer functions
1193
+ import {
1194
+ createViewer,
1195
+ createViewerFromSceneId,
1196
+ createViewerFromUrl,
1197
+ fetchSceneMeta,
1198
+ generateHTML,
1199
+ generateHTMLFromUrl,
1200
+ } from 'storysplat-viewer';
1201
+
1202
+ // Types
1203
+ import type {
1204
+ ViewerInstance,
1205
+ ViewerOptions,
1206
+ SceneData,
1207
+ ButtonLabels,
1208
+ ViewerTheme,
1209
+ SplatRelightingConfig,
1210
+ RevealPreset,
1211
+ RevealPresetConfig,
1212
+ } from 'storysplat-viewer';
1213
+
1214
+ // Utilities
1215
+ import {
1216
+ DEFAULT_BUTTON_LABELS,
1217
+ generateViewerStyles,
1218
+ REVEAL_PRESETS,
1219
+ getRevealPreset,
1220
+ GsplatRelighting,
1221
+ getGsplatRelightingClass,
1222
+ SceneNotFoundError,
1223
+ SceneApiError,
1224
+ } from 'storysplat-viewer';
1225
+ ```
1226
+
1088
1227
  ## Support
1089
1228
 
1090
1229
  - GitHub Issues: [github.com/SonnyC56/storysplat-viewer/issues](https://github.com/SonnyC56/storysplat-viewer/issues)