@maucwerk/glimmer 0.0.0-stage → 1.0.13

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 (58) hide show
  1. package/LICENSE +43 -0
  2. package/README.md +884 -2
  3. package/dist/components/__edge_decorator.d.ts +36 -0
  4. package/dist/components/conditional_lines/conditional_edges_geometry.d.ts +7 -0
  5. package/dist/components/conditional_lines/conditional_line_segments_geometry.d.ts +24 -0
  6. package/dist/components/conditional_lines/outside_edges_geometry.d.ts +7 -0
  7. package/dist/components/glimmer_viewer.d.ts +9 -0
  8. package/dist/environment/environment.d.ts +42 -0
  9. package/dist/environment/index.d.ts +2 -0
  10. package/dist/environment/sun.d.ts +21 -0
  11. package/dist/gizmos/index.d.ts +4 -0
  12. package/dist/gizmos/move_gizmo.d.ts +89 -0
  13. package/dist/gizmos/rotate_gizmo.d.ts +86 -0
  14. package/dist/gizmos/section_box_gizmo.d.ts +91 -0
  15. package/dist/gizmos/section_box_manager.d.ts +82 -0
  16. package/dist/glimmer.d.ts +26 -0
  17. package/dist/index.d.ts +13 -0
  18. package/dist/main.d.ts +1 -0
  19. package/dist/model/index.d.ts +3 -0
  20. package/dist/model/model.d.ts +88 -0
  21. package/dist/model/model_loader.d.ts +9 -0
  22. package/dist/model/model_manager.d.ts +55 -0
  23. package/dist/outline/index.d.ts +2 -0
  24. package/dist/outline/outline_material.d.ts +13 -0
  25. package/dist/outline/outline_mesh.d.ts +10 -0
  26. package/dist/section/index.d.ts +3 -0
  27. package/dist/section/plane_handle.d.ts +39 -0
  28. package/dist/section/section_box.d.ts +78 -0
  29. package/dist/section/section_cap.d.ts +15 -0
  30. package/dist/settings/index.d.ts +2 -0
  31. package/dist/settings/schema.d.ts +353 -0
  32. package/dist/settings/settings.d.ts +20 -0
  33. package/dist/shaders/colored_shadow_material.d.ts +7 -0
  34. package/dist/shaders/conditional_edges_shader.d.ts +16 -0
  35. package/dist/shaders/conditional_line_material.d.ts +16 -0
  36. package/dist/story/anchor_marker.d.ts +74 -0
  37. package/dist/story/anchor_marker_manager.d.ts +102 -0
  38. package/dist/story/annotation_2d_renderer.d.ts +24 -0
  39. package/dist/story/annotation_3d_renderer.d.ts +29 -0
  40. package/dist/story/annotation_renderer.d.ts +35 -0
  41. package/dist/story/index.d.ts +7 -0
  42. package/dist/story/schema.d.ts +1154 -0
  43. package/dist/story/slide_transition_manager.d.ts +30 -0
  44. package/dist/story/story_manager.d.ts +170 -0
  45. package/dist/story/trigger_manager.d.ts +43 -0
  46. package/dist/utils/constants.d.ts +6 -0
  47. package/dist/utils/cursor_3d.d.ts +48 -0
  48. package/dist/utils/error.d.ts +54 -0
  49. package/dist/utils/index.d.ts +4 -0
  50. package/dist/utils/log.d.ts +8 -0
  51. package/dist/utils/utils.d.ts +2 -0
  52. package/dist/viewer/index.d.ts +1 -0
  53. package/dist/viewer/orbit_controller.d.ts +62 -0
  54. package/dist/viewer/raycast_helper.d.ts +37 -0
  55. package/dist/viewer/viewer.d.ts +141 -0
  56. package/dist/vite/glimmer.mjs +11522 -0
  57. package/dist/vite/glimmer.umd.js +914 -0
  58. package/package.json +64 -4
@@ -0,0 +1,30 @@
1
+ import type { Camera, Vector3 } from 'three';
2
+ import type { StorySlideType } from './schema';
3
+ /**
4
+ * SlideTransitionManager
5
+ *
6
+ * Manages slide transitions for StoryManager, handling camera movements
7
+ * and coordinating the overall transition process.
8
+ *
9
+ * Current implementation: Instant camera cuts (MVP)
10
+ * Future enhancement: Smooth animated transitions with duration/easing
11
+ */
12
+ export declare class SlideTransitionManager extends EventTarget {
13
+ private camera;
14
+ private controls;
15
+ constructor(camera: Camera, controls: {
16
+ target: Vector3;
17
+ update: () => void;
18
+ });
19
+ /**
20
+ * Set camera position and target from slide configuration
21
+ * @param camera_config Camera position and target from slide
22
+ */
23
+ set_camera(camera_config: StorySlideType['camera']): void;
24
+ /**
25
+ * Transition to a new slide
26
+ * Currently performs instant camera cut; future versions will support smooth animations
27
+ * @param slide The target slide to transition to
28
+ */
29
+ transition_to_slide(slide: StorySlideType): void;
30
+ }
@@ -0,0 +1,170 @@
1
+ import type { Glimmer } from '../glimmer';
2
+ import { type StoryType, type StorySlideType, type AnnotationType } from './schema';
3
+ /**
4
+ * StoryManager orchestrates state-based 3D scene transitions for narrative experiences.
5
+ * Integrates with Glimmer's reactive Settings system to create slide-based presentations.
6
+ *
7
+ * Events:
8
+ * - 'slidechange': Fired when navigating to a new slide
9
+ * detail: { index: number, prev_index: number, slide: StorySlideType, total: number }
10
+ * - 'storychange': Fired when story structure changes (add/delete/reorder slides)
11
+ * detail: { action: 'add'|'update'|'delete'|'reorder', slides: StorySlideType[], affected_index?: number }
12
+ */
13
+ export declare class StoryManager extends EventTarget {
14
+ private glimmer;
15
+ private story;
16
+ private current_index;
17
+ private annotation_container;
18
+ private annotation_2d_renderer;
19
+ private annotation_3d_renderer;
20
+ private trigger_manager;
21
+ private transition_manager;
22
+ private section_box_manager;
23
+ /**
24
+ * Create a new StoryManager instance
25
+ * @param glimmer The Glimmer instance to control
26
+ * @param story Story object or JSON string
27
+ */
28
+ constructor(glimmer: Glimmer, story: StoryType | string);
29
+ /**
30
+ * Navigate to the next slide
31
+ */
32
+ next(): void;
33
+ /**
34
+ * Navigate to the previous slide
35
+ */
36
+ prev(): void;
37
+ /**
38
+ * Navigate to the first slide (home)
39
+ */
40
+ home(): void;
41
+ /**
42
+ * Navigate to a specific slide by index
43
+ * @param index The slide index (0-based)
44
+ */
45
+ goto(index: number): void;
46
+ /**
47
+ * Register a trigger for forward navigation
48
+ * @param trigger DOM element or custom event name
49
+ */
50
+ register_forward(trigger: HTMLElement | string): void;
51
+ /**
52
+ * Register a trigger for backward navigation
53
+ * @param trigger DOM element or custom event name
54
+ */
55
+ register_backward(trigger: HTMLElement | string): void;
56
+ /**
57
+ * Register a trigger for home navigation
58
+ * @param trigger DOM element or custom event name
59
+ */
60
+ register_home(trigger: HTMLElement | string): void;
61
+ /**
62
+ * Get the current slide index
63
+ */
64
+ get current_slide_index(): number;
65
+ /**
66
+ * Get the current slide
67
+ */
68
+ get current_slide(): StorySlideType;
69
+ /**
70
+ * Get the total number of slides
71
+ */
72
+ get total_slides(): number;
73
+ /**
74
+ * Get the story metadata
75
+ */
76
+ get story_info(): Pick<StoryType, 'version' | 'title' | 'description'>;
77
+ /**
78
+ * Capture the current viewer state as a new slide
79
+ * @param id Unique identifier for the slide
80
+ * @param title Optional title
81
+ * @returns A new StorySlide object
82
+ */
83
+ capture_current_state(id: string, title?: string): StorySlideType;
84
+ /**
85
+ * Export the story as JSON
86
+ */
87
+ export_story(): string;
88
+ /**
89
+ * Add a new slide to the story
90
+ * @param slide The slide to add (or use captured state)
91
+ * @param index Optional index to insert at (default: append to end)
92
+ * @returns The index where the slide was added
93
+ */
94
+ add_slide(slide: StorySlideType, index?: number): number;
95
+ /**
96
+ * Update an existing slide
97
+ * @param index The index of the slide to update
98
+ * @param updates Partial slide data to merge
99
+ */
100
+ update_slide(index: number, updates: Partial<StorySlideType>): void;
101
+ /**
102
+ * Delete a slide from the story
103
+ * @param index The index of the slide to delete
104
+ */
105
+ delete_slide(index: number): void;
106
+ /**
107
+ * Reorder slides by moving a slide from one position to another
108
+ * @param from_index Source index
109
+ * @param to_index Destination index
110
+ */
111
+ reorder_slides(from_index: number, to_index: number): void;
112
+ /**
113
+ * Replace the entire story with new data
114
+ * @param story New story object or JSON string
115
+ */
116
+ replace_story(story: StoryType | string): void;
117
+ /**
118
+ * Add an anchor to an annotation in the current slide
119
+ * @param annotation_index - Index of annotation in current slide
120
+ * @param model_url - URL of the model to anchor to
121
+ * @param local_position - Position in model's local coordinate space
122
+ */
123
+ add_annotation_anchor(annotation_index: number, model_url: string, local_position: [number, number, number]): void;
124
+ /**
125
+ * Remove anchor from an annotation in the current slide
126
+ * @param annotation_index - Index of annotation in current slide
127
+ */
128
+ remove_annotation_anchor(annotation_index: number): void;
129
+ /**
130
+ * Get all anchored annotations in the current slide
131
+ * @returns Array of anchored annotations with their indices
132
+ */
133
+ get_anchored_annotations(): Array<{
134
+ index: number;
135
+ annotation: AnnotationType;
136
+ }>;
137
+ /**
138
+ * Enters section box edit mode for the current slide
139
+ * Allows interactive adjustment of section box bounds
140
+ */
141
+ enter_section_box_edit_mode(): void;
142
+ /**
143
+ * Exits section box edit mode and saves bounds to current slide
144
+ */
145
+ exit_section_box_edit_mode(): void;
146
+ /**
147
+ * Clears section box from current slide
148
+ */
149
+ clear_section_box(): void;
150
+ /**
151
+ * Dispose and cleanup resources
152
+ */
153
+ dispose(): void;
154
+ /**
155
+ * Applies section box to the current slide
156
+ */
157
+ private _apply_section_box;
158
+ /**
159
+ * Render annotations for the current slide
160
+ */
161
+ private _render_annotations;
162
+ /**
163
+ * Create the 2D annotation overlay container
164
+ */
165
+ private _create_annotation_container;
166
+ /**
167
+ * Emit a storychange event
168
+ */
169
+ private _emit_story_change;
170
+ }
@@ -0,0 +1,43 @@
1
+ /**
2
+ * Manages event triggers for story navigation.
3
+ * Handles binding/unbinding of DOM elements and custom window events.
4
+ */
5
+ export declare class TriggerManager {
6
+ private triggers;
7
+ private handlers;
8
+ /**
9
+ * Register a trigger with a handler
10
+ * @param type - Trigger type (e.g., 'forward', 'backward', 'home')
11
+ * @param trigger - DOM element or custom event name
12
+ * @param handler - Handler function to execute
13
+ */
14
+ register(type: string, trigger: HTMLElement | string, handler: () => void): void;
15
+ /**
16
+ * Unregister a specific trigger
17
+ * @param trigger - DOM element or custom event name
18
+ */
19
+ unregister(trigger: HTMLElement | string): void;
20
+ /**
21
+ * Unregister all triggers of a specific type
22
+ * @param type - Trigger type (e.g., 'forward', 'backward', 'home')
23
+ */
24
+ unregister_type(type: string): void;
25
+ /**
26
+ * Unregister all triggers and clean up
27
+ */
28
+ dispose(): void;
29
+ /**
30
+ * Get all triggers of a specific type
31
+ * @param type - Trigger type
32
+ * @returns Set of triggers for this type
33
+ */
34
+ get_triggers(type: string): Set<HTMLElement | string>;
35
+ /**
36
+ * Bind a trigger (DOM element click or custom window event)
37
+ */
38
+ private _bind;
39
+ /**
40
+ * Unbind a trigger
41
+ */
42
+ private _unbind;
43
+ }
@@ -0,0 +1,6 @@
1
+ export declare const SHADOW_BASE_RESOLUTION = 512;
2
+ export declare const SHADOW_SCALE_DIVISOR = 100;
3
+ export declare const SHADOW_CAMERA_PADDING = 30;
4
+ export declare const SHADOW_BIAS = -0.001;
5
+ export declare const SHADOW_RADIUS = 3;
6
+ export declare const SHADOW_BLUR_SAMPLES = 16;
@@ -0,0 +1,48 @@
1
+ import * as THREE from 'three';
2
+ /**
3
+ * Cursor3D - Visual indicator for 3D surface positions
4
+ *
5
+ * Displays a sphere and arrow (normal) at the raycast hit position.
6
+ * Color feedback:
7
+ * - Green (0x00ff00): Ready to place
8
+ * - Yellow (0xffff00): Near existing anchor
9
+ * - Red (0xff0000): Invalid placement
10
+ */
11
+ export declare class Cursor3D {
12
+ private group;
13
+ private sphere;
14
+ private arrow;
15
+ private scene;
16
+ private is_enabled;
17
+ private readonly SPHERE_RADIUS;
18
+ private readonly ARROW_LENGTH;
19
+ private readonly ARROW_HEAD_LENGTH;
20
+ private readonly ARROW_HEAD_WIDTH;
21
+ constructor(scene: THREE.Scene);
22
+ /**
23
+ * Enable the 3D cursor (make it visible)
24
+ */
25
+ enable(): void;
26
+ /**
27
+ * Disable the 3D cursor (hide it)
28
+ */
29
+ disable(): void;
30
+ /**
31
+ * Check if cursor is enabled
32
+ */
33
+ get enabled(): boolean;
34
+ /**
35
+ * Update cursor position and normal from raycaster intersection
36
+ * @param intersection - Three.js Intersection object from raycaster
37
+ */
38
+ update(intersection: THREE.Intersection | null): void;
39
+ /**
40
+ * Set cursor color for visual feedback
41
+ * @param color - Color (0x00ff00 = green/ready, 0xffff00 = yellow/warning, 0xff0000 = red/invalid)
42
+ */
43
+ set_color(color: number): void;
44
+ /**
45
+ * Dispose of cursor resources
46
+ */
47
+ dispose(): void;
48
+ }
@@ -0,0 +1,54 @@
1
+ /**
2
+ * Custom error class for Glimmer errors
3
+ * Provides structured error information including component, code, and optional details
4
+ */
5
+ export declare class GlimmerError extends Error {
6
+ component: string;
7
+ code: string;
8
+ details?: any | undefined;
9
+ /**
10
+ * Create a new GlimmerError
11
+ * @param message Human-readable error message
12
+ * @param component Component where the error occurred (e.g., 'Environment', 'ModelLoader')
13
+ * @param code Error code for programmatic handling (e.g., 'HDR_LOAD_FAILED', 'INVALID_MODEL')
14
+ * @param details Optional additional context (e.g., URL, error object)
15
+ */
16
+ constructor(message: string, component: string, code: string, details?: any | undefined);
17
+ /**
18
+ * Serialize error to JSON for logging or transmission
19
+ */
20
+ toJSON(): object;
21
+ /**
22
+ * Format error as a readable string
23
+ */
24
+ toString(): string;
25
+ }
26
+ /**
27
+ * Error codes for common Glimmer errors
28
+ */
29
+ export declare const ERROR_CODES: {
30
+ readonly RENDERER_INIT_FAILED: "RENDERER_INIT_FAILED";
31
+ readonly WEBGL_NOT_SUPPORTED: "WEBGL_NOT_SUPPORTED";
32
+ readonly INITIALIZATION_FAILED: "INITIALIZATION_FAILED";
33
+ readonly HDR_LOAD_FAILED: "HDR_LOAD_FAILED";
34
+ readonly HDR_COMPILE_FAILED: "HDR_COMPILE_FAILED";
35
+ readonly PMREM_INIT_FAILED: "PMREM_INIT_FAILED";
36
+ readonly ENVIRONMENT_UPDATE_FAILED: "ENVIRONMENT_UPDATE_FAILED";
37
+ readonly MISSING_URL: "MISSING_URL";
38
+ readonly MODEL_LOAD_FAILED: "MODEL_LOAD_FAILED";
39
+ readonly MODEL_NOT_FOUND: "MODEL_NOT_FOUND";
40
+ readonly INVALID_MODEL_FORMAT: "INVALID_MODEL_FORMAT";
41
+ readonly GLTF_PARSE_FAILED: "GLTF_PARSE_FAILED";
42
+ readonly INVALID_MODEL_URL: "INVALID_MODEL_URL";
43
+ readonly INVALID_STORY_JSON: "INVALID_STORY_JSON";
44
+ readonly INVALID_SLIDE_INDEX: "INVALID_SLIDE_INDEX";
45
+ readonly STORY_PARSE_FAILED: "STORY_PARSE_FAILED";
46
+ readonly ANNOTATION_RENDER_FAILED: "ANNOTATION_RENDER_FAILED";
47
+ readonly INVALID_SETTINGS: "INVALID_SETTINGS";
48
+ readonly VALIDATION_FAILED: "VALIDATION_FAILED";
49
+ readonly SETTINGS_MERGE_FAILED: "SETTINGS_MERGE_FAILED";
50
+ readonly DISPOSED_INSTANCE: "DISPOSED_INSTANCE";
51
+ readonly INVALID_STATE: "INVALID_STATE";
52
+ readonly OPERATION_FAILED: "OPERATION_FAILED";
53
+ };
54
+ export type ErrorCode = (typeof ERROR_CODES)[keyof typeof ERROR_CODES];
@@ -0,0 +1,4 @@
1
+ export * from './utils';
2
+ export * from './constants';
3
+ export * from './error';
4
+ export * from './cursor_3d';
@@ -0,0 +1,8 @@
1
+ export type LogLevel = 'silent' | 'error' | 'warn' | 'info' | 'debug';
2
+ export declare function set_log_level(level: LogLevel): void;
3
+ export declare const log: {
4
+ error: (...args: any[]) => false | void;
5
+ warn: (...args: any[]) => false | void;
6
+ info: (...args: any[]) => false | void;
7
+ debug: (...args: any[]) => false | void;
8
+ };
@@ -0,0 +1,2 @@
1
+ import * as THREE from 'three';
2
+ export declare function get_max_dim(fit_object: THREE.Object3D): number;
@@ -0,0 +1 @@
1
+ export { Viewer } from './viewer';
@@ -0,0 +1,62 @@
1
+ import * as THREE from 'three';
2
+ import type { OrbitControls } from 'three/examples/jsm/controls/OrbitControls';
3
+ /**
4
+ * Manages smooth camera orbit animation around a target point.
5
+ *
6
+ * Events:
7
+ * - 'orbitstart': Fired when orbit animation starts
8
+ * detail: {}
9
+ * - 'orbitstop': Fired when orbit animation stops
10
+ * detail: {}
11
+ *
12
+ * Usage:
13
+ * ```typescript
14
+ * const controller = new OrbitController(camera, controls, renderer, scene);
15
+ * controller.start_animation(30, true); // 30s clockwise
16
+ * controller.setup_user_override(); // Stop on user interaction
17
+ * ```
18
+ */
19
+ export declare class OrbitController extends EventTarget {
20
+ private camera;
21
+ private controls;
22
+ private renderer;
23
+ private scene;
24
+ private _orbit_animation_id?;
25
+ private _orbit_restart_timeout_id?;
26
+ private _orbit_duration_seconds;
27
+ private _orbit_clockwise;
28
+ private _auto_restart_enabled;
29
+ constructor(camera: THREE.PerspectiveCamera, controls: OrbitControls, renderer: THREE.WebGLRenderer, scene: THREE.Scene);
30
+ /**
31
+ * Starts a smooth camera orbit animation around the controls target.
32
+ * @param duration_seconds The duration (in seconds) for one full revolution.
33
+ * @param clockwise Whether to orbit clockwise (true) or counterclockwise (false).
34
+ * @param ease_in_seconds How long (in seconds) to ease-in at the start (default 1).
35
+ */
36
+ start_animation(duration_seconds?: number, clockwise?: boolean, ease_in_seconds?: number): void;
37
+ /**
38
+ * Stops any ongoing camera orbit animation.
39
+ */
40
+ stop_animation(): void;
41
+ /**
42
+ * Schedule the camera orbit animation to restart after a given timeout.
43
+ * @param timeout_ms Timeout in milliseconds (default: 5000ms).
44
+ */
45
+ schedule_restart(timeout_ms?: number): void;
46
+ /**
47
+ * Enable or disable automatic orbit restart after user interaction
48
+ * @param enabled Whether to enable auto-restart (default: true)
49
+ */
50
+ set_auto_restart(enabled: boolean): void;
51
+ /**
52
+ * Handles user interactions with OrbitControls:
53
+ * - Stops camera orbit animation while user is interacting.
54
+ * - Schedules restart after user ends interaction.
55
+ * - Emits orbitstart/orbitstop events
56
+ */
57
+ setup_user_override(): void;
58
+ /**
59
+ * Clean up resources.
60
+ */
61
+ dispose(): void;
62
+ }
@@ -0,0 +1,37 @@
1
+ import * as THREE from 'three';
2
+ /**
3
+ * Helper utility for performing raycasts from mouse events.
4
+ * Converts mouse coordinates to normalized device coordinates and performs raycasting.
5
+ *
6
+ * Usage:
7
+ * ```typescript
8
+ * const helper = new RaycastHelper(camera, renderer.domElement, scene.children);
9
+ * const intersection = helper.raycast_from_event(mouseEvent);
10
+ * ```
11
+ */
12
+ export declare class RaycastHelper {
13
+ private raycaster;
14
+ private camera;
15
+ private canvas;
16
+ private default_targets;
17
+ /**
18
+ * Create a new RaycastHelper.
19
+ * @param camera - The camera to raycast from
20
+ * @param canvas - The canvas element (for coordinate conversion)
21
+ * @param default_targets - Default objects to raycast against
22
+ */
23
+ constructor(camera: THREE.Camera, canvas: HTMLElement, default_targets: THREE.Object3D[]);
24
+ /**
25
+ * Perform a raycast from a mouse event to intersect scene objects.
26
+ * @param event - Mouse event (click, mousemove, etc.)
27
+ * @param objects - Optional array of objects to raycast against (defaults to constructor targets)
28
+ * @param filter_meshes - Whether to filter results to only mesh objects (default: true)
29
+ * @returns First intersection result, or null if no hit
30
+ */
31
+ raycast_from_event(event: MouseEvent, objects?: THREE.Object3D[], filter_meshes?: boolean): THREE.Intersection | null;
32
+ /**
33
+ * Get the underlying raycaster for advanced use cases.
34
+ * @returns The THREE.Raycaster instance
35
+ */
36
+ get_raycaster(): THREE.Raycaster;
37
+ }
@@ -0,0 +1,141 @@
1
+ import * as THREE from 'three';
2
+ import type { LineSegments2 } from 'three/examples/jsm/lines/LineSegments2';
3
+ import { OrbitControls } from 'three/examples/jsm/controls/OrbitControls';
4
+ import { Settings } from '../settings';
5
+ import { Cursor3D } from '../utils/cursor_3d';
6
+ export type AnimationCallback = (delta: number) => void;
7
+ /**
8
+ * Structure representing a model loaded into the scene, with optional edge decorations.
9
+ */
10
+ export interface LoadedModel {
11
+ /** The root THREE.Group of the loaded model. */
12
+ model: THREE.Group;
13
+ /** The threshold and conditional edge lines, or null if edges were not created. */
14
+ edges: [LineSegments2, LineSegments2] | null;
15
+ }
16
+ /**
17
+ * A 3D viewer for loading and interacting with glTF models using Three.js.
18
+ *
19
+ * Events:
20
+ * - 'resize': Fired when viewport resizes
21
+ * detail: { width: number, height: number }
22
+ * - 'camerachange': Fired when camera position/target changes
23
+ * detail: { position: THREE.Vector3, target: THREE.Vector3 }
24
+ * - 'orbitstart': Fired when user starts orbiting
25
+ * detail: {}
26
+ * - 'orbitstop': Fired when user stops orbiting
27
+ * detail: {}
28
+ *
29
+ * Usage:
30
+ * ```typescript
31
+ * const viewer = new Viewer(containerElement, { backgroundColor: 0x222222 });
32
+ * const loaded = await viewer.add_gltf("/path/to/model.glb", true);
33
+ * viewer.frame_object(loaded.model);
34
+ * ```
35
+ */
36
+ export declare class Viewer extends EventTarget {
37
+ settings: Settings;
38
+ scene: THREE.Scene;
39
+ camera: THREE.PerspectiveCamera;
40
+ renderer: THREE.WebGLRenderer;
41
+ controls: OrbitControls;
42
+ private container;
43
+ private orbit_controller;
44
+ private raycast_helper;
45
+ private _resize_handler;
46
+ private clock;
47
+ private animation_callbacks;
48
+ private animation_mixers;
49
+ private cursor_3d?;
50
+ private _cursor_3d_mouse_handler?;
51
+ /**
52
+ * Create a new Viewer instance.
53
+ * @param container The HTML element where the viewer will be rendered.
54
+ * @param options Optional viewer configuration.
55
+ */
56
+ constructor(container: HTMLElement, settings: Settings);
57
+ register_animation_mixer(mixer: THREE.AnimationMixer): void;
58
+ unregister_animation_mixer(mixer: THREE.AnimationMixer): void;
59
+ update_animation_mixers(delta: number): void;
60
+ register_animation_callback(callback: AnimationCallback): void;
61
+ unregister_animation_callback(callback: AnimationCallback): void;
62
+ execute_animation_callbacks(delta: number): void;
63
+ /**
64
+ * Handle resizing of the renderer and camera when the window or container changes size.
65
+ */
66
+ private onWindowResize;
67
+ /**
68
+ * Main render loop. Updates controls and renders the scene.
69
+ * Also ensures LineSegments2 materials have the correct resolution each frame.
70
+ * @private
71
+ */
72
+ private _resolution_materials;
73
+ register_resolution_material(mat: any): void;
74
+ unregister_resolution_material(mat: any): void;
75
+ animate: () => void;
76
+ /**
77
+ * Frames the camera and controls around a given object, fitting it within the view.
78
+ * @param object The object to frame.
79
+ * @param fitOffset Controls how much empty space to leave around the object (default 1.2).
80
+ */
81
+ frame_object(object: THREE.Object3D, fit_offset?: number, height_offset?: number): void;
82
+ /**
83
+ * Starts a smooth camera orbit animation around the controls target.
84
+ * @param duration_seconds The duration (in seconds) for one full revolution.
85
+ * @param clockwise Whether to orbit clockwise (true) or counterclockwise (false).
86
+ * @param ease_in_seconds How long (in seconds) to ease-in at the start (default 1).
87
+ */
88
+ start_camera_orbit_animation(duration_seconds?: number, clockwise?: boolean, ease_in_seconds?: number): void;
89
+ /**
90
+ * Stops any ongoing camera orbit animation.
91
+ */
92
+ stop_camera_orbit_animation(): void;
93
+ /**
94
+ * Enable or disable automatic orbit restart after user interaction.
95
+ * When enabled, camera will automatically start orbiting after 5 seconds of inactivity.
96
+ * @param enabled Whether to enable auto-restart (default: true)
97
+ */
98
+ set_auto_orbit(enabled: boolean): void;
99
+ /**
100
+ * Schedule the camera orbit animation to restart after a given timeout.
101
+ * @param timeout_ms Timeout in milliseconds (default: 5000ms).
102
+ */
103
+ schedule_camera_orbit_restart(timeout_ms?: number): void;
104
+ /**
105
+ * Handles user interactions with OrbitControls:
106
+ * - Stops camera orbit animation while user is interacting.
107
+ * - Schedules restart after user ends interaction.
108
+ * @private
109
+ */
110
+ private _setup_orbit_animation_user_override;
111
+ /**
112
+ * Perform a raycast from a mouse event to intersect scene objects.
113
+ * @param event - Mouse event (click, mousemove, etc.)
114
+ * @param objects - Optional array of objects to raycast against (defaults to all scene children)
115
+ * @returns First intersection result, or null if no hit
116
+ */
117
+ raycast_from_event(event: MouseEvent, objects?: THREE.Object3D[]): THREE.Intersection | null;
118
+ /**
119
+ * Enable the 3D cursor for visualizing raycast positions.
120
+ * The cursor will update on mouse movement over the canvas.
121
+ * @param objects - Optional array of objects to raycast against
122
+ */
123
+ enable_3d_cursor(objects?: THREE.Object3D[]): void;
124
+ /**
125
+ * Disable the 3D cursor.
126
+ */
127
+ disable_3d_cursor(): void;
128
+ /**
129
+ * Manually update the 3D cursor position from a mouse event.
130
+ * Only works if cursor is enabled.
131
+ * @param event - Mouse event
132
+ * @param objects - Optional array of objects to raycast against
133
+ */
134
+ update_3d_cursor(event: MouseEvent, objects?: THREE.Object3D[]): void;
135
+ /**
136
+ * Get the 3D cursor instance for direct access (e.g., to change color).
137
+ * @returns Cursor3D instance or undefined if not created
138
+ */
139
+ get_3d_cursor(): Cursor3D | undefined;
140
+ dispose(): void;
141
+ }