storysplat-viewer 0.1.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.
Files changed (41) hide show
  1. package/README.md +659 -0
  2. package/dist/esm/dist/styles/viewer.css +2 -0
  3. package/dist/esm/dist/styles/viewer.css.map +1 -0
  4. package/dist/esm/index.js +187107 -0
  5. package/dist/esm/index.js.map +1 -0
  6. package/dist/types/core/cameraManager.d.ts +35 -0
  7. package/dist/types/core/lightingManager.d.ts +9 -0
  8. package/dist/types/core/renderLoopManager.d.ts +24 -0
  9. package/dist/types/core/sceneManager.d.ts +19 -0
  10. package/dist/types/core/splatLoader.d.ts +12 -0
  11. package/dist/types/features/analyticsManager.d.ts +102 -0
  12. package/dist/types/features/animatedGifTexture.d.ts +37 -0
  13. package/dist/types/features/audioManager.d.ts +72 -0
  14. package/dist/types/features/collisionManager.d.ts +51 -0
  15. package/dist/types/features/customMeshManager.d.ts +15 -0
  16. package/dist/types/features/hotspotManager.d.ts +16 -0
  17. package/dist/types/features/navigationManager.d.ts +142 -0
  18. package/dist/types/features/particleManager.d.ts +14 -0
  19. package/dist/types/features/sceneFeatures.d.ts +14 -0
  20. package/dist/types/features/skyboxManager.d.ts +8 -0
  21. package/dist/types/features/splatSwapManager.d.ts +87 -0
  22. package/dist/types/features/xrManager.d.ts +12 -0
  23. package/dist/types/index.d.ts +55 -0
  24. package/dist/types/types/dataTypes.d.ts +248 -0
  25. package/dist/types/types/hotspotTypes.d.ts +82 -0
  26. package/dist/types/types/index.d.ts +6 -0
  27. package/dist/types/types/interactionTypes.d.ts +43 -0
  28. package/dist/types/types/navigationTypes.d.ts +41 -0
  29. package/dist/types/types/sceneFeatures.d.ts +186 -0
  30. package/dist/types/types/viewerOptions.d.ts +245 -0
  31. package/dist/types/types.d.ts +106 -0
  32. package/dist/types/ui/helpPanel.d.ts +32 -0
  33. package/dist/types/ui/muteButton.d.ts +30 -0
  34. package/dist/types/ui/preloader.d.ts +40 -0
  35. package/dist/types/ui/startButton.d.ts +29 -0
  36. package/dist/types/ui/uiManager.d.ts +97 -0
  37. package/dist/types/ui/watermark.d.ts +18 -0
  38. package/dist/types/utils/helpers.d.ts +81 -0
  39. package/dist/types/viewer-simple.d.ts +30 -0
  40. package/dist/types/viewer.d.ts +105 -0
  41. package/package.json +47 -0
@@ -0,0 +1,245 @@
1
+ import { UIType } from "./dataTypes";
2
+ import { Waypoint } from "./navigationTypes";
3
+ import { SceneLightConfig, ParticleSystemConfig, CustomMeshConfig } from "./sceneFeatures";
4
+ /** Defines the available camera control modes. */
5
+ export type CameraMode = 'explore' | 'walk' | 'tour' | 'hybrid';
6
+ /** Defines the available XR modes. */
7
+ export type XRMode = 'none' | 'ar' | 'vr';
8
+ /** Placeholder for AR specific options. Define based on src/types/SceneTypes.ts if needed. */
9
+ export interface AROptions {
10
+ enableHitTest?: boolean;
11
+ enablePlaneDetection?: boolean;
12
+ enableAnchors?: boolean;
13
+ enableBackgroundRemoval?: boolean;
14
+ }
15
+ /** Configuration for background audio. */
16
+ export interface BackgroundAudioConfig {
17
+ /** Unique identifier for the background audio track. */
18
+ id?: string;
19
+ /** URL of the audio file. */
20
+ url: string;
21
+ /** Volume level (0.0 to 1.0). Defaults to 1. */
22
+ volume?: number;
23
+ /** Whether the audio should loop. Defaults to true. */
24
+ loop?: boolean;
25
+ }
26
+ /** Configuration options related to audio playback. */
27
+ export interface AudioOptions {
28
+ /** Configuration for the background audio track. */
29
+ backgroundAudio?: BackgroundAudioConfig;
30
+ /** Show the mute/unmute button in the UI. Defaults to false. */
31
+ showMuteButton?: boolean;
32
+ }
33
+ /** Defines the UI configuration options. */
34
+ export interface UIOptions {
35
+ /** Position of waypoint information display ('popup' or 'controls'). */
36
+ infoPosition?: 'popup' | 'controls';
37
+ /** Layout of scroll buttons ('inline' or 'below'). */
38
+ buttonPosition?: "inline" | "below";
39
+ /** Show a 'Start Experience' button before loading. */
40
+ showStartExperience?: boolean;
41
+ /** Enable Babylon.js debug layer (Ctrl+I). */
42
+ debugMode?: boolean;
43
+ /** Overall UI theme/layout. */
44
+ uiType?: UIType | string;
45
+ /** Hide the StorySplat watermark. */
46
+ hideWatermark?: boolean;
47
+ /** Custom text for the watermark. */
48
+ watermarkText?: string;
49
+ /** Custom link URL for the watermark. */
50
+ watermarkLink?: string;
51
+ }
52
+ /** Configuration options for the preloader UI element. */
53
+ export interface PreloaderConfig {
54
+ /** URL for a custom image logo in the preloader. */
55
+ imageUrl?: string;
56
+ /** URL for a custom Lottie animation JSON in the preloader. */
57
+ lottieUrl?: string;
58
+ /** Override the default UI color specifically for the preloader elements (e.g., progress bar). Defaults to the main `uiColor` option if not set. */
59
+ uiColor?: string;
60
+ /** Set to false to completely disable the preloader UI. Defaults to true. */
61
+ enabled?: boolean;
62
+ }
63
+ /**
64
+ * Configuration options for the analytics tracking system.
65
+ */
66
+ export interface ViewerAnalyticsOptions {
67
+ /** Enable or disable analytics tracking. Defaults to false. */
68
+ enabled?: boolean;
69
+ /**
70
+ * Callback function invoked for each tracked event.
71
+ * The consuming application should implement this to send data to their analytics backend.
72
+ * @param {string} eventName - The name of the event (e.g., 'waypoint_reached').
73
+ * @param {Record<string, any>} eventData - An object containing event details and metadata.
74
+ */
75
+ onTrackEvent?: (eventName: string, eventData: Record<string, any>) => void;
76
+ /** Optional identifier for the scene being viewed. */
77
+ sceneId?: string;
78
+ /** Optional name for the scene being viewed. */
79
+ sceneName?: string;
80
+ /** Optional identifier for the current user. */
81
+ userId?: string;
82
+ /** Optional name of the scene creator. */
83
+ creatorName?: string;
84
+ }
85
+ export interface ViewerOptions {
86
+ /** Configuration for the preloader UI. */
87
+ preloaderConfig?: PreloaderConfig;
88
+ /** Show the help button and panel. Defaults to false. */
89
+ showHelpButton?: boolean;
90
+ /** Show the "Start Experience" button overlay. Defaults to false. */
91
+ showStartExperience?: boolean;
92
+ /** Override the default background color of the scene. */
93
+ backgroundColor?: {
94
+ r: number;
95
+ g: number;
96
+ b: number;
97
+ a?: number;
98
+ };
99
+ /** The initial camera mode when the viewer loads. Defaults to 'explore'. */
100
+ defaultCameraMode?: CameraMode;
101
+ /** An array of camera modes the user is allowed to switch between. If undefined or empty, all modes defined in the data/defaults are potentially usable. */
102
+ allowedCameraModes?: CameraMode[];
103
+ /** Enable or disable camera controls entirely (overrides mode settings). Defaults to true. */
104
+ cameraControls?: boolean;
105
+ /** Enable keyboard controls (WASD/Arrows) for Explore/Walk modes. Defaults to true if cameraControls is true. */
106
+ enableKeyboardControls?: boolean;
107
+ /** Enable mouse/touch look controls for Explore/Walk modes. Defaults to true if cameraControls is true. */
108
+ enableMouseControls?: boolean;
109
+ /** Enable the mobile joystick UI for Explore/Walk modes. Defaults to false. */
110
+ enableMobileJoystick?: boolean;
111
+ /** Override default camera movement speed (units per second). */
112
+ cameraSpeed?: number;
113
+ /** Override default camera rotation inertia (0-1, higher means more smoothing). */
114
+ cameraInertia?: number;
115
+ /** Override default camera mouse rotation sensitivity. Higher is slower. */
116
+ cameraAngularSensibility?: number;
117
+ /** Override default camera touch rotation sensitivity. Higher is slower. */
118
+ cameraTouchAngularSensibility?: number;
119
+ /** Override default camera mouse wheel zoom speed percentage. Affects how much camera.radius changes per wheel event. */
120
+ cameraWheelDeltaPercentage?: number;
121
+ /** Override default camera minimum Z distance (near clipping plane). */
122
+ cameraMinZ?: number;
123
+ /** Override default camera maximum Z distance (far clipping plane). */
124
+ cameraMaxZ?: number;
125
+ /** Override the default gravity strength applied in 'walk' mode (negative value for downward gravity). */
126
+ gravity?: number;
127
+ /** Override the default camera collision ellipsoid dimensions {x, y, z}. */
128
+ cameraEllipsoid?: {
129
+ x: number;
130
+ y: number;
131
+ z: number;
132
+ };
133
+ /** Enable collisions in 'explore' mode. Defaults to false. */
134
+ exploreCollisions?: boolean;
135
+ /** Enable collisions in 'walk' mode. Defaults to true. */
136
+ walkCollisions?: boolean;
137
+ /** Apply gravity in 'walk' mode. Defaults to true. */
138
+ walkApplyGravity?: boolean;
139
+ /** Array of mesh names to enable collision against in 'walk' mode (and optionally 'explore' if exploreCollisions is true). */
140
+ collisionMeshesData?: string[];
141
+ /** Speed factor for scroll-based navigation in 'hybrid' or 'tour' mode. (Currently handled by next/prev waypoint logic). */
142
+ scrollSpeed?: number;
143
+ /** Multiplier affecting how much the camera moves per scroll wheel event in tour/hybrid modes. Higher values mean faster scrolling. Defaults to 0.001. */
144
+ scrollSpeedFactor?: number;
145
+ /** Default duration (in milliseconds) for camera transitions between waypoints. Also used as a speed factor in the render loop (higher = faster interpolation). */
146
+ transitionSpeed?: number;
147
+ /** Enable or disable hotspot functionality. Defaults to true if hotspots exist in data. */
148
+ enableHotspots?: boolean;
149
+ /** Enable or disable waypoint navigation functionality. Defaults to true if waypoints exist in data. */
150
+ enableNavigation?: boolean;
151
+ /** Enable or disable particle systems. Defaults to true if particle systems exist in data. */
152
+ enableParticles?: boolean;
153
+ /** Custom class name to add to the viewer's container element. */
154
+ className?: string;
155
+ /** Force disable WebGPU and use WebGL2. Defaults to false. */
156
+ disableWebGPU?: boolean;
157
+ /** Primary UI color (e.g., for buttons, progress bar). Hex string like "#FF0000". */
158
+ uiColor?: string;
159
+ /** Determines the behavior of next/previous scroll buttons ('percentage' or 'waypoint'). */
160
+ scrollButtonMode?: "percentage" | "waypoint";
161
+ /** The amount to scroll when using 'percentage' mode (0-100). */
162
+ scrollAmount?: number;
163
+ /** Whether the waypoint tour should loop back to the start after reaching the end. */
164
+ loopMode?: boolean;
165
+ /** Enable automatic progression through waypoints. */
166
+ autoPlayEnabled?: boolean;
167
+ /** Speed factor for autoplay (1 is normal speed). */
168
+ autoPlaySpeed?: number;
169
+ /** Invert the camera's rotation controls (useful for some control schemes). */
170
+ invertCameraRotation?: boolean;
171
+ /** Height of the camera in 'walk' mode (in meters). */
172
+ playerHeight?: number;
173
+ /** UI specific configuration options. */
174
+ uiOptions?: UIOptions;
175
+ /** Configuration for WebXR (AR/VR) features. */
176
+ xr?: {
177
+ /** Enable WebXR functionality. Requires HTTPS. Defaults to false. */
178
+ enabled: boolean;
179
+ /** Default XR mode to attempt initialization ('AR' or 'VR'). */
180
+ mode: 'AR' | 'VR';
181
+ /** Specific options for AR mode. */
182
+ arOptions?: AROptions;
183
+ /** Show the default "Enter XR" button provided by Babylon.js. Defaults to true if enabled. */
184
+ showEnterXRButton?: boolean;
185
+ };
186
+ /** URL of the cube texture file (.env, .dds, or pre-filtered .babylon) for the scene skybox. */
187
+ activeSkyboxUrl?: string | null;
188
+ /** Array of light configurations to add to the scene. */
189
+ lights?: SceneLightConfig[];
190
+ /** Array of particle system configurations to create in the scene. */
191
+ particleSystems?: ParticleSystemConfig[];
192
+ /** Array of custom mesh configurations to load into the scene. */
193
+ customMeshes?: CustomMeshConfig[];
194
+ /** Array of waypoints defining the navigation path. */
195
+ waypoints?: Waypoint[];
196
+ /** Default navigation mode if waypoints exist ('tour', 'hybrid'). */
197
+ /** Speed factor for camera transitions between waypoints. */
198
+ /** Smoothing factor for camera movement during navigation (0-1). */
199
+ cameraDampening?: number;
200
+ /** Multiplier for scroll-based navigation speed. */
201
+ /** Behavior of next/previous buttons ('percentage' or 'waypoint'). */
202
+ /** Amount to scroll in 'percentage' mode (0-1). */
203
+ /** Whether the waypoint tour loops. */
204
+ /** Enable automatic playback of the tour. */
205
+ /** Speed factor for automatic playback. */
206
+ /** Show the navigation progress bar UI element. */
207
+ showProgressBar?: boolean;
208
+ /** Show the previous/next navigation button UI elements. */
209
+ showNavButtons?: boolean;
210
+ /** Show UI buttons for switching between all allowed camera modes. Defaults to true if multiple modes are allowed. */
211
+ showCameraModeToggle?: boolean;
212
+ /** Show UI buttons specifically for toggling between 'Explore' (Drone) and 'Walk' modes. Defaults to true if both are allowed. */
213
+ showWalkExploreToggle?: boolean;
214
+ onSceneReady?: (scene: import("@babylonjs/core/scene").Scene) => void;
215
+ /** Callback function triggered when a hotspot mesh is clicked or activated. */
216
+ onHotspotClicked?: (hotspotId: string | number, hotspotData: import("./hotspotTypes").Hotspot) => void;
217
+ /** Callback function triggered when the pointer enters a hotspot mesh (if hover interactions are enabled). */
218
+ onHotspotHover?: (hotspotId: string | number, hotspotData: import("./hotspotTypes").Hotspot) => void;
219
+ /** Callback function triggered when the pointer leaves a hotspot mesh (if hover interactions are enabled). */
220
+ onHotspotLeave?: (hotspotId: string | number, hotspotData: import("./hotspotTypes").Hotspot) => void;
221
+ onWaypointReached?: (waypointName: string, index: number) => void;
222
+ onCameraModeChanged?: (newMode: CameraMode) => void;
223
+ /** Configuration for audio features. */
224
+ audio?: AudioOptions;
225
+ /** @deprecated Use cameraAngularSensibility instead. */
226
+ cameraAngularSensibilityX?: number;
227
+ /** @deprecated Use cameraAngularSensibility instead. */
228
+ cameraAngularSensibilityY?: number;
229
+ /** @deprecated ArcRotateCamera specific, not used by UniversalCamera. */
230
+ cameraLowerRadiusLimit?: number | null;
231
+ /** @deprecated ArcRotateCamera specific, not used by UniversalCamera. */
232
+ cameraUpperRadiusLimit?: number | null;
233
+ /** @deprecated ArcRotateCamera specific, not used by UniversalCamera. */
234
+ cameraLowerBetaLimit?: number;
235
+ /** @deprecated ArcRotateCamera specific, not used by UniversalCamera. */
236
+ cameraUpperBetaLimit?: number;
237
+ /** @deprecated ArcRotateCamera specific, not used by UniversalCamera. */
238
+ cameraPanningSensibility?: number;
239
+ /** @deprecated Use cameraWheelDeltaPercentage instead. */
240
+ cameraWheelPrecision?: number;
241
+ /** @deprecated Use cameraTouchAngularSensibility instead. */
242
+ cameraTouchMoveSensibility?: number;
243
+ /** Configuration for the analytics tracking system. */
244
+ analytics?: ViewerAnalyticsOptions;
245
+ }
@@ -0,0 +1,106 @@
1
+ export interface Vector3 {
2
+ x: number;
3
+ y: number;
4
+ z: number;
5
+ }
6
+ export interface Quaternion {
7
+ x: number;
8
+ y: number;
9
+ z: number;
10
+ w: number;
11
+ }
12
+ export interface WaypointInteraction {
13
+ id: string;
14
+ type: string;
15
+ data: any;
16
+ }
17
+ export interface Waypoint {
18
+ x: number;
19
+ y: number;
20
+ z: number;
21
+ rotation: {
22
+ x: number;
23
+ y: number;
24
+ z: number;
25
+ w: number;
26
+ };
27
+ name?: string;
28
+ interactions?: WaypointInteraction[];
29
+ triggerDistance?: number;
30
+ }
31
+ export type NavigationMode = 'tour' | 'hybrid' | 'explore' | 'walk';
32
+ export type CameraMode = 'explore' | 'walk' | 'tour' | 'hybrid';
33
+ export interface CameraState {
34
+ position: Vector3;
35
+ rotation: Quaternion;
36
+ }
37
+ export interface ViewerOptions {
38
+ splatUrl?: string;
39
+ containerId?: string;
40
+ initialCameraPosition?: Vector3;
41
+ initialCameraRotation?: Quaternion;
42
+ backgroundColor?: {
43
+ r: number;
44
+ g: number;
45
+ b: number;
46
+ a?: number;
47
+ };
48
+ fov?: number;
49
+ minClipPlane?: number;
50
+ maxClipPlane?: number;
51
+ invertCameraRotation?: boolean;
52
+ invertXScale?: boolean;
53
+ invertYScale?: boolean;
54
+ splatScale?: number;
55
+ showStartExperience?: boolean;
56
+ showHelpButton?: boolean;
57
+ enableMobileJoystick?: boolean;
58
+ uiColor?: string;
59
+ waypoints?: Waypoint[];
60
+ allowedCameraModes?: CameraMode[];
61
+ enableNavigation?: boolean;
62
+ defaultMode?: NavigationMode;
63
+ allowedModes?: NavigationMode[];
64
+ transitionSpeed?: number;
65
+ cameraDampening?: number;
66
+ scrollSpeed?: number;
67
+ scrollButtonMode?: 'percentage' | 'waypoint';
68
+ scrollAmount?: number;
69
+ loopMode?: boolean;
70
+ autoPlayEnabled?: boolean;
71
+ autoPlaySpeed?: number;
72
+ showProgressBar?: boolean;
73
+ showNavButtons?: boolean;
74
+ onWaypointReached?: (waypointName: string, index: number) => void;
75
+ uiOptions?: UIOptions;
76
+ }
77
+ /** Defines the UI configuration options. */
78
+ export interface UIOptions {
79
+ /** Position of waypoint information display ('popup' or 'controls'). */
80
+ infoPosition?: 'popup' | 'controls';
81
+ /** Layout of scroll buttons ('inline' or 'below'). */
82
+ buttonPosition?: "inline" | "below";
83
+ /** Show a 'Start Experience' button before loading. */
84
+ showStartExperience?: boolean;
85
+ /** Enable Babylon.js debug layer (Ctrl+I). */
86
+ debugMode?: boolean;
87
+ /** Overall UI theme/layout type (e.g., 'default', 'minimal'). */
88
+ uiType?: string;
89
+ /** Hide the StorySplat watermark. */
90
+ hideWatermark?: boolean;
91
+ /** Custom text for the watermark. */
92
+ watermarkText?: string;
93
+ /** Custom link URL for the watermark. */
94
+ watermarkLink?: string;
95
+ }
96
+ /** Configuration options for the preloader UI element. */
97
+ export interface PreloaderConfig {
98
+ /** URL for a custom image logo in the preloader. */
99
+ imageUrl?: string;
100
+ /** URL for a custom Lottie animation JSON in the preloader. */
101
+ lottieUrl?: string;
102
+ /** Override the default UI color specifically for the preloader elements (e.g., progress bar). Defaults to the main `uiColor` option if not set. */
103
+ uiColor?: string;
104
+ /** Set to false to completely disable the preloader UI. Defaults to true. */
105
+ enabled?: boolean;
106
+ }
@@ -0,0 +1,32 @@
1
+ import { ViewerOptions } from "../types";
2
+ /**
3
+ * Manages the Help Button and Panel UI.
4
+ */
5
+ export declare class HelpPanelUI {
6
+ private container;
7
+ private options;
8
+ private helpButton?;
9
+ private helpPanel?;
10
+ private isVisible;
11
+ constructor(container: HTMLElement, options: ViewerOptions);
12
+ /**
13
+ * Creates the help button and panel if the option is enabled.
14
+ */
15
+ create(): void;
16
+ /**
17
+ * Populates the help panel's innerHTML based on viewer options.
18
+ */
19
+ private populateHelpContent;
20
+ /**
21
+ * Toggles the visibility of the help panel.
22
+ */
23
+ private toggleHelp;
24
+ /**
25
+ * Closes the help panel if a click occurs outside of it.
26
+ */
27
+ private handleOutsideClick;
28
+ /**
29
+ * Removes elements and event listeners.
30
+ */
31
+ dispose(): void;
32
+ }
@@ -0,0 +1,30 @@
1
+ import { ViewerOptions } from '../types/viewerOptions';
2
+ import { AudioManager } from '../features/audioManager';
3
+ /**
4
+ * Manages the creation and interaction of the Mute/Unmute button UI element.
5
+ */
6
+ export declare class MuteButtonUI {
7
+ private targetElement;
8
+ private options;
9
+ private audioManager;
10
+ private buttonElement;
11
+ constructor(targetElement: HTMLElement, options: ViewerOptions, audioManager: AudioManager);
12
+ /**
13
+ * Creates the mute button element and adds it to the target container.
14
+ */
15
+ create(): void;
16
+ /**
17
+ * Handles the click event on the mute button.
18
+ */
19
+ private handleMuteToggle;
20
+ /**
21
+ * Updates the button's text/icon based on the mute state.
22
+ * This method is bound and potentially called by AudioManager.
23
+ * @param isMuted The current mute state.
24
+ */
25
+ updateButtonState(isMuted: boolean): void;
26
+ /**
27
+ * Removes the mute button element and cleans up event listeners.
28
+ */
29
+ dispose(): void;
30
+ }
@@ -0,0 +1,40 @@
1
+ import { PreloaderConfig } from "../types";
2
+ /**
3
+ * Manages the preloader UI element.
4
+ */
5
+ export declare class PreloaderUI {
6
+ private container;
7
+ private config;
8
+ private preloaderElement?;
9
+ private progressBarElement?;
10
+ private progressTextElement?;
11
+ private logoElement?;
12
+ constructor(container: HTMLElement, config: PreloaderConfig);
13
+ /**
14
+ * Creates and appends the preloader HTML structure to the container.
15
+ */
16
+ create(): void;
17
+ /**
18
+ * Updates the progress bar percentage and the accompanying text.
19
+ * @param percentage - The progress percentage (0-100).
20
+ * @param text - Optional text to display (e.g., "Loading assets..."). Defaults to "Loading... X%".
21
+ */
22
+ updateProgress(percentage: number, text?: string): void;
23
+ /**
24
+ * Shows the preloader element. If it doesn't exist (e.g., after being hidden/disposed),
25
+ * it recreates it.
26
+ */
27
+ show(): void;
28
+ /**
29
+ * Hides the preloader with a fade-out animation and removes it from the DOM.
30
+ */
31
+ hide(): void;
32
+ /**
33
+ * Removes the preloader element from the DOM immediately.
34
+ */
35
+ dispose(): void;
36
+ /**
37
+ * Ensures the lottie-player script is loaded for lottie animations
38
+ */
39
+ private ensureLottiePlayerScript;
40
+ }
@@ -0,0 +1,29 @@
1
+ import { ViewerOptions } from "../types";
2
+ /**
3
+ * Manages the "Start Experience" button overlay UI.
4
+ */
5
+ export declare class StartButtonUI {
6
+ private container;
7
+ private options;
8
+ private startButtonContainer?;
9
+ private startButton?;
10
+ private onStartCallback?;
11
+ constructor(container: HTMLElement, options: ViewerOptions, onStartCallback?: () => void);
12
+ /**
13
+ * Creates and appends the start button overlay if the option is enabled.
14
+ */
15
+ create(): void;
16
+ /**
17
+ * Handles the click event on the start button.
18
+ * Hides the overlay and triggers the callback.
19
+ */
20
+ private handleStartClick;
21
+ /**
22
+ * Hides the start button overlay with a fade-out animation and removes it.
23
+ */
24
+ hide(): void;
25
+ /**
26
+ * Removes the start button elements from the DOM immediately.
27
+ */
28
+ dispose(): void;
29
+ }
@@ -0,0 +1,97 @@
1
+ import { Scene } from "@babylonjs/core/scene";
2
+ import { ViewerOptions } from "../types/viewerOptions";
3
+ import { Interaction } from "../types/dataTypes";
4
+ import { CameraManager } from "../core/cameraManager";
5
+ import { NavigationManager } from "../features/navigationManager";
6
+ import { AudioManager } from "../features/audioManager";
7
+ import { StorySplatData, Waypoint } from "../types/dataTypes";
8
+ /**
9
+ * Manages the creation, update, and interaction of HTML UI elements
10
+ * for the StorySplat viewer, based on the provided UIOptions.
11
+ */
12
+ export declare class UIManager {
13
+ private targetElement;
14
+ private canvas;
15
+ private scene;
16
+ private options;
17
+ private data;
18
+ private uiOptions;
19
+ private cameraManager;
20
+ private navigationManager;
21
+ private audioManager;
22
+ private preloaderContainer?;
23
+ private startButtonContainer?;
24
+ private startButton?;
25
+ private fullscreenButton?;
26
+ private expandIcon?;
27
+ private compressIcon?;
28
+ private scrollControlsContainer?;
29
+ private scrollControlsContent?;
30
+ private scrollPercentageDisplay?;
31
+ private progressBarContainer?;
32
+ private progressBar?;
33
+ private scrollButtonsContainer?;
34
+ private prevButton?;
35
+ private nextButton?;
36
+ private playPauseButton?;
37
+ private waypointInfoDisplay?;
38
+ private modeToggleContainer?;
39
+ private modeToggleButtonGroup?;
40
+ private exploreToggleContainer?;
41
+ private droneToggleButton?;
42
+ private walkToggleButton?;
43
+ private muteButton?;
44
+ private helpButton?;
45
+ private helpPanel?;
46
+ private watermarkElement?;
47
+ private isMuted;
48
+ private helpVisible;
49
+ constructor(targetElement: HTMLElement, canvas: HTMLCanvasElement, scene: Scene, options: ViewerOptions, data: StorySplatData, cameraManager: CameraManager, navigationManager: NavigationManager | null, audioManager: AudioManager | null);
50
+ /** Creates the core UI elements based on options. */
51
+ private createBaseUI;
52
+ /** Sets up event listeners for UI interactions. */
53
+ private setupEventListeners;
54
+ private createFullscreenButton;
55
+ private createPreloader;
56
+ private createStartButton;
57
+ private createScrollControls;
58
+ private _styleScrollButton;
59
+ private _styleAutoplayButton;
60
+ private createModeToggles;
61
+ private createExploreWalkToggles;
62
+ private _styleExploreWalkButton;
63
+ private createMuteButton;
64
+ private createHelpButtonAndPanel;
65
+ private createWatermark;
66
+ private handlePrevWaypoint;
67
+ private handleNextWaypoint;
68
+ private handleModeChange;
69
+ private handleDroneToggle;
70
+ private handleWalkToggle;
71
+ private handleStartExperience;
72
+ private toggleFullscreen;
73
+ private handleMuteToggle;
74
+ private handleHelpToggle;
75
+ private handleDocumentClickForHelp;
76
+ /** Updates the preloader progress display. */
77
+ updateProgress(percentage: number, text?: string): void;
78
+ /** Hides the preloader element. */
79
+ hidePreloader(): void;
80
+ /** Updates the fullscreen button icons based on the current state. */
81
+ updateFullscreenIcons: () => void;
82
+ /** Cleans up UI elements and event listeners. */
83
+ dispose(): void;
84
+ /** Updates the visual state of the mode toggle buttons. */
85
+ updateModeToggleButtons(): void;
86
+ /** Updates the visual state of the explore/walk toggle buttons. */
87
+ updateExploreWalkToggleButtons(): void;
88
+ /** Shows or hides the scroll controls based on the current camera mode. */
89
+ updateScrollControlsVisibility(): void;
90
+ /** Updates the scroll progress bar and percentage display. */
91
+ updateScrollProgress(percentage: number): void;
92
+ /** Displays information about the current waypoint. */
93
+ showWaypointInfo(waypoint: Waypoint | null): void;
94
+ /** Displays information from a triggered interaction. */
95
+ showInteractionInfo(interaction: Interaction | null): void;
96
+ private _applyBasicStyles;
97
+ }
@@ -0,0 +1,18 @@
1
+ import { ViewerOptions } from "../types";
2
+ /**
3
+ * Manages the watermark UI element.
4
+ */
5
+ export declare class WatermarkUI {
6
+ private container;
7
+ private options;
8
+ private watermarkElement?;
9
+ constructor(container: HTMLElement, options: ViewerOptions);
10
+ /**
11
+ * Creates and appends the watermark element if not hidden in options.
12
+ */
13
+ create(): void;
14
+ /**
15
+ * Removes the watermark element from the DOM.
16
+ */
17
+ dispose(): void;
18
+ }
@@ -0,0 +1,81 @@
1
+ import { Quaternion } from "@babylonjs/core/Maths/math.vector";
2
+ import { Color3, Color4, Vector3 } from "@babylonjs/core/Maths/math";
3
+ /**
4
+ * Adjusts the brightness of a hex color string.
5
+ * @param color - The hex color string (e.g., "#RRGGBB").
6
+ * @param percent - The percentage to adjust brightness by (positive for lighter, negative for darker).
7
+ * @returns The adjusted hex color string.
8
+ */
9
+ export declare const adjustColorBrightness: (color: string, percent: number) => string;
10
+ /**
11
+ * Basic check if the current environment appears to be a mobile device based on user agent.
12
+ * Note: User agent sniffing is generally unreliable; consider feature detection instead if possible.
13
+ * This function might return false positives or negatives.
14
+ * @returns True if the user agent string matches common mobile patterns, false otherwise.
15
+ */
16
+ export declare const isMobileDevice: () => boolean;
17
+ /**
18
+ * Converts a simple {r, g, b} object to a BabylonJS Color3 object.
19
+ * Handles potential undefined input.
20
+ * @param colorObj - The color object { r, g, b } (values 0-1).
21
+ * @param defaultColor - The default Color3 to return if input is invalid.
22
+ * @returns A BabylonJS Color3 object.
23
+ */
24
+ export declare const toColor3: (colorObj?: {
25
+ r: number;
26
+ g: number;
27
+ b: number;
28
+ }, defaultColor?: Color3) => Color3;
29
+ /**
30
+ * Converts a simple {r, g, b, a} object to a BabylonJS Color4 object.
31
+ * Handles potential undefined input. Alpha defaults to 1 if not provided.
32
+ * @param colorObj - The color object { r, g, b, a? } (values 0-1).
33
+ * @param defaultColor - The default Color4 to return if input is invalid.
34
+ * @returns A BabylonJS Color4 object.
35
+ */
36
+ export declare const toColor4: (colorObj?: {
37
+ r: number;
38
+ g: number;
39
+ b: number;
40
+ a?: number;
41
+ }, defaultColor?: Color4) => Color4;
42
+ /**
43
+ * Converts a simple {x, y, z} object to a BabylonJS Vector3 object.
44
+ * Handles potential undefined input.
45
+ * @param vecObj - The vector object { x, y, z }.
46
+ * @param defaultVector - The default Vector3 to return if input is invalid.
47
+ * @returns A BabylonJS Vector3 object.
48
+ */
49
+ export declare const toVector3: (vecObj?: {
50
+ x: number;
51
+ y: number;
52
+ z: number;
53
+ }, defaultVector?: Vector3) => Vector3;
54
+ /**
55
+ * Converts a simple {_x, _y, _z, _w} object to a BabylonJS Quaternion object.
56
+ * Handles potential undefined input.
57
+ * @param quatObj - The quaternion object { _x, _y, _z, _w }.
58
+ * @param defaultQuaternion - The default Quaternion to return if input is invalid.
59
+ * @returns A BabylonJS Quaternion object.
60
+ */
61
+ export declare const toQuaternion: (quatObj?: {
62
+ _x: number;
63
+ _y: number;
64
+ _z: number;
65
+ _w: number;
66
+ }, defaultQuaternion?: Quaternion) => Quaternion;
67
+ /**
68
+ * Converts a hex color string (e.g., "#RRGGBB") to a BabylonJS Color3 object.
69
+ * Handles potential undefined or invalid input.
70
+ * @param hex - The hex color string.
71
+ * @param defaultColor - The default Color3 to return if input is invalid.
72
+ * @returns A BabylonJS Color3 object.
73
+ */
74
+ export declare const hexToColor3: (hex?: string, defaultColor?: Color3) => Color3;
75
+ /**
76
+ * Applies opacity to a mesh and its children's materials.
77
+ * Handles StandardMaterial and potentially PBRMaterial alpha/transparencyMode.
78
+ * @param mesh - The root mesh to apply opacity to.
79
+ * @param opacity - The opacity value (0-1).
80
+ */
81
+ export declare function applyOpacityToMeshAndChildren(mesh: import("@babylonjs/core/Meshes/abstractMesh").AbstractMesh | null, opacity: number): void;