storysplat-viewer 2.4.7 → 2.4.8
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 +104 -35
- package/dist/index.esm.js +1 -1
- package/dist/index.esm.js.map +1 -1
- package/dist/index.js +1 -1
- package/dist/index.js.map +1 -1
- package/dist/storysplat-viewer.umd.js +1 -1
- package/dist/storysplat-viewer.umd.js.map +1 -1
- package/dist/types/editor/EditorCameraController.d.ts +46 -0
- package/dist/types/index.d.ts +4 -2
- package/dist/types/types/index.d.ts +65 -0
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -7,13 +7,14 @@ A powerful npm package for embedding and interacting with 3D Gaussian Splatting
|
|
|
7
7
|
- [Installation](#installation)
|
|
8
8
|
- [Quick Start](#quick-start)
|
|
9
9
|
- [Loading Scenes](#loading-scenes)
|
|
10
|
-
- [From Scene ID (
|
|
11
|
-
- [From JSON File (
|
|
12
|
-
- [From URL](#option-3-from-url)
|
|
10
|
+
- [From Scene ID (Recommended)](#option-1-from-scene-id-recommended)
|
|
11
|
+
- [From JSON File (Self-Hosted)](#option-2-from-json-file-self-hosted)
|
|
13
12
|
- [API Reference](#api-reference)
|
|
13
|
+
- [Controlling the Viewer](#controlling-the-viewer)
|
|
14
14
|
- [Configuration Options](#configuration-options)
|
|
15
15
|
- [Events](#events)
|
|
16
16
|
- [React Integration](#react-integration)
|
|
17
|
+
- [Analytics & Tracking](#analytics--tracking)
|
|
17
18
|
- [Troubleshooting](#troubleshooting)
|
|
18
19
|
|
|
19
20
|
## Installation
|
|
@@ -53,11 +54,11 @@ viewer.on('ready', () => console.log('Viewer ready!'));
|
|
|
53
54
|
|
|
54
55
|
## Loading Scenes
|
|
55
56
|
|
|
56
|
-
There are
|
|
57
|
+
There are two ways to load scenes into the viewer:
|
|
57
58
|
|
|
58
|
-
### Option 1: From Scene ID (
|
|
59
|
+
### Option 1: From Scene ID (Recommended)
|
|
59
60
|
|
|
60
|
-
Best for
|
|
61
|
+
**Best for:** Most use cases. Live content that updates when you edit in the StorySplat editor. Includes automatic view and bandwidth tracking.
|
|
61
62
|
|
|
62
63
|
```javascript
|
|
63
64
|
import { createViewerFromSceneId } from 'storysplat-viewer';
|
|
@@ -69,16 +70,16 @@ const viewer = await createViewerFromSceneId(
|
|
|
69
70
|
);
|
|
70
71
|
```
|
|
71
72
|
|
|
72
|
-
The scene is fetched from the StorySplat API and always reflects your latest changes.
|
|
73
|
+
The scene is fetched from the StorySplat API and always reflects your latest changes. Views and bandwidth are automatically tracked for analytics.
|
|
73
74
|
|
|
74
75
|
**Getting your Scene ID:**
|
|
75
76
|
1. Open your scene in the StorySplat editor
|
|
76
77
|
2. Click "Upload" or "Update"
|
|
77
78
|
3. Copy the Scene ID from the "Developer Export" section
|
|
78
79
|
|
|
79
|
-
### Option 2: From JSON File (
|
|
80
|
+
### Option 2: From JSON File (Self-Hosted)
|
|
80
81
|
|
|
81
|
-
Best for
|
|
82
|
+
**Best for:** Self-hosted scenes where you want full control over the scene data. No tracking.
|
|
82
83
|
|
|
83
84
|
```javascript
|
|
84
85
|
import { createViewer } from 'storysplat-viewer';
|
|
@@ -96,18 +97,7 @@ const viewer = createViewer(
|
|
|
96
97
|
3. In the "Developer Export" section, click "Download Scene JSON"
|
|
97
98
|
4. Save the file in your project
|
|
98
99
|
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
Load scene configuration from any URL:
|
|
102
|
-
|
|
103
|
-
```javascript
|
|
104
|
-
import { createViewerFromUrl } from 'storysplat-viewer';
|
|
105
|
-
|
|
106
|
-
const viewer = await createViewerFromUrl(
|
|
107
|
-
document.getElementById('viewer'),
|
|
108
|
-
'https://example.com/my-scene.json'
|
|
109
|
-
);
|
|
110
|
-
```
|
|
100
|
+
> **Note:** When using `createViewer` with self-hosted scenes, views and bandwidth are not tracked. Use `createViewerFromSceneId` for StorySplat-hosted scenes to get analytics.
|
|
111
101
|
|
|
112
102
|
## API Reference
|
|
113
103
|
|
|
@@ -148,7 +138,7 @@ interface ViewerFromSceneIdOptions {
|
|
|
148
138
|
|
|
149
139
|
### createViewer
|
|
150
140
|
|
|
151
|
-
Create a viewer from scene data object.
|
|
141
|
+
Create a viewer from scene data object. Use this for self-hosted scenes.
|
|
152
142
|
|
|
153
143
|
```typescript
|
|
154
144
|
function createViewer(
|
|
@@ -158,17 +148,7 @@ function createViewer(
|
|
|
158
148
|
): ViewerInstance
|
|
159
149
|
```
|
|
160
150
|
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
Create a viewer by fetching scene data from a URL.
|
|
164
|
-
|
|
165
|
-
```typescript
|
|
166
|
-
async function createViewerFromUrl(
|
|
167
|
-
container: HTMLElement,
|
|
168
|
-
url: string,
|
|
169
|
-
options?: ViewerOptions
|
|
170
|
-
): Promise<ViewerInstance>
|
|
171
|
-
```
|
|
151
|
+
> **Note:** `createViewer` does not track views or bandwidth. For StorySplat-hosted scenes, use `createViewerFromSceneId` instead.
|
|
172
152
|
|
|
173
153
|
### fetchSceneMeta
|
|
174
154
|
|
|
@@ -384,12 +364,101 @@ try {
|
|
|
384
364
|
}
|
|
385
365
|
```
|
|
386
366
|
|
|
367
|
+
## Controlling the Viewer
|
|
368
|
+
|
|
369
|
+
The viewer instance provides methods to control playback, navigation, and camera programmatically. This is useful for building custom UI controls outside the viewer.
|
|
370
|
+
|
|
371
|
+
### External Control Example
|
|
372
|
+
|
|
373
|
+
```html
|
|
374
|
+
<div id="viewer" style="width: 100%; height: 500px;"></div>
|
|
375
|
+
|
|
376
|
+
<div id="controls">
|
|
377
|
+
<button id="prev">Previous</button>
|
|
378
|
+
<button id="play">Play</button>
|
|
379
|
+
<button id="pause">Pause</button>
|
|
380
|
+
<button id="next">Next</button>
|
|
381
|
+
<span id="waypoint-info"></span>
|
|
382
|
+
</div>
|
|
383
|
+
|
|
384
|
+
<script type="module">
|
|
385
|
+
import { createViewerFromSceneId } from 'storysplat-viewer';
|
|
386
|
+
|
|
387
|
+
const viewer = await createViewerFromSceneId(
|
|
388
|
+
document.getElementById('viewer'),
|
|
389
|
+
'YOUR_SCENE_ID'
|
|
390
|
+
);
|
|
391
|
+
|
|
392
|
+
// Navigation
|
|
393
|
+
document.getElementById('prev').onclick = () => viewer.prevWaypoint();
|
|
394
|
+
document.getElementById('next').onclick = () => viewer.nextWaypoint();
|
|
395
|
+
|
|
396
|
+
// Playback
|
|
397
|
+
document.getElementById('play').onclick = () => viewer.play();
|
|
398
|
+
document.getElementById('pause').onclick = () => viewer.pause();
|
|
399
|
+
|
|
400
|
+
// Update waypoint display
|
|
401
|
+
viewer.on('waypointChange', ({ index }) => {
|
|
402
|
+
const total = viewer.getWaypointCount();
|
|
403
|
+
document.getElementById('waypoint-info').textContent =
|
|
404
|
+
`Waypoint ${index + 1} of ${total}`;
|
|
405
|
+
});
|
|
406
|
+
|
|
407
|
+
// Jump to specific waypoint
|
|
408
|
+
function goToWaypoint(index) {
|
|
409
|
+
viewer.goToWaypoint(index);
|
|
410
|
+
}
|
|
411
|
+
</script>
|
|
412
|
+
```
|
|
413
|
+
|
|
414
|
+
### Available Control Methods
|
|
415
|
+
|
|
416
|
+
| Method | Description |
|
|
417
|
+
|--------|-------------|
|
|
418
|
+
| `viewer.play()` | Start auto-playing through waypoints |
|
|
419
|
+
| `viewer.pause()` | Pause auto-play |
|
|
420
|
+
| `viewer.stop()` | Stop and reset to first waypoint |
|
|
421
|
+
| `viewer.isPlaying()` | Check if currently auto-playing |
|
|
422
|
+
| `viewer.nextWaypoint()` | Go to next waypoint |
|
|
423
|
+
| `viewer.prevWaypoint()` | Go to previous waypoint |
|
|
424
|
+
| `viewer.goToWaypoint(index)` | Jump to specific waypoint (0-indexed) |
|
|
425
|
+
| `viewer.getCurrentWaypointIndex()` | Get current waypoint index |
|
|
426
|
+
| `viewer.getWaypointCount()` | Get total number of waypoints |
|
|
427
|
+
| `viewer.setPosition(x, y, z)` | Set camera position |
|
|
428
|
+
| `viewer.setRotation(x, y, z)` | Set camera rotation (Euler angles) |
|
|
429
|
+
| `viewer.getPosition()` | Get current camera position |
|
|
430
|
+
| `viewer.getRotation()` | Get current camera rotation |
|
|
431
|
+
| `viewer.resize()` | Recalculate canvas size (call after container resize) |
|
|
432
|
+
| `viewer.destroy()` | Clean up and remove viewer |
|
|
433
|
+
|
|
434
|
+
## Analytics & Tracking
|
|
435
|
+
|
|
436
|
+
When using `createViewerFromSceneId`, the viewer automatically tracks:
|
|
437
|
+
|
|
438
|
+
- **Views**: Each time a scene is loaded
|
|
439
|
+
- **Bandwidth**: Data transferred when loading StorySplat-hosted files
|
|
440
|
+
|
|
441
|
+
This data appears in your StorySplat admin dashboard.
|
|
442
|
+
|
|
443
|
+
### What Gets Tracked
|
|
444
|
+
|
|
445
|
+
| Scenario | Views | Bandwidth |
|
|
446
|
+
|----------|-------|-----------|
|
|
447
|
+
| `createViewerFromSceneId` with StorySplat-hosted files | Yes | Yes |
|
|
448
|
+
| `createViewerFromSceneId` with self-hosted splat files | Yes | No |
|
|
449
|
+
| `createViewer` (self-hosted scenes) | No | No |
|
|
450
|
+
| iframe embed | Yes | Yes |
|
|
451
|
+
|
|
452
|
+
### Privacy Note
|
|
453
|
+
|
|
454
|
+
Tracking only occurs for scenes loaded via `createViewerFromSceneId`. If you use `createViewer` with your own scene data, no data is sent to StorySplat servers.
|
|
455
|
+
|
|
387
456
|
## Comparison: Scene ID vs JSON File
|
|
388
457
|
|
|
389
458
|
| Approach | Best For | Pros | Cons |
|
|
390
459
|
|----------|----------|------|------|
|
|
391
|
-
| **Scene ID** | Live content, CMS | Always latest, no redeploy | Needs internet, API dependency |
|
|
392
|
-
| **JSON File** |
|
|
460
|
+
| **Scene ID** | Live content, CMS | Always latest, automatic tracking, no redeploy | Needs internet, API dependency |
|
|
461
|
+
| **JSON File** | Self-hosted, offline | Full control, git-tracked, no external dependencies | Manual updates, no analytics |
|
|
393
462
|
|
|
394
463
|
## Troubleshooting
|
|
395
464
|
|