@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.
- package/LICENSE +43 -0
- package/README.md +884 -2
- package/dist/components/__edge_decorator.d.ts +36 -0
- package/dist/components/conditional_lines/conditional_edges_geometry.d.ts +7 -0
- package/dist/components/conditional_lines/conditional_line_segments_geometry.d.ts +24 -0
- package/dist/components/conditional_lines/outside_edges_geometry.d.ts +7 -0
- package/dist/components/glimmer_viewer.d.ts +9 -0
- package/dist/environment/environment.d.ts +42 -0
- package/dist/environment/index.d.ts +2 -0
- package/dist/environment/sun.d.ts +21 -0
- package/dist/gizmos/index.d.ts +4 -0
- package/dist/gizmos/move_gizmo.d.ts +89 -0
- package/dist/gizmos/rotate_gizmo.d.ts +86 -0
- package/dist/gizmos/section_box_gizmo.d.ts +91 -0
- package/dist/gizmos/section_box_manager.d.ts +82 -0
- package/dist/glimmer.d.ts +26 -0
- package/dist/index.d.ts +13 -0
- package/dist/main.d.ts +1 -0
- package/dist/model/index.d.ts +3 -0
- package/dist/model/model.d.ts +88 -0
- package/dist/model/model_loader.d.ts +9 -0
- package/dist/model/model_manager.d.ts +55 -0
- package/dist/outline/index.d.ts +2 -0
- package/dist/outline/outline_material.d.ts +13 -0
- package/dist/outline/outline_mesh.d.ts +10 -0
- package/dist/section/index.d.ts +3 -0
- package/dist/section/plane_handle.d.ts +39 -0
- package/dist/section/section_box.d.ts +78 -0
- package/dist/section/section_cap.d.ts +15 -0
- package/dist/settings/index.d.ts +2 -0
- package/dist/settings/schema.d.ts +353 -0
- package/dist/settings/settings.d.ts +20 -0
- package/dist/shaders/colored_shadow_material.d.ts +7 -0
- package/dist/shaders/conditional_edges_shader.d.ts +16 -0
- package/dist/shaders/conditional_line_material.d.ts +16 -0
- package/dist/story/anchor_marker.d.ts +74 -0
- package/dist/story/anchor_marker_manager.d.ts +102 -0
- package/dist/story/annotation_2d_renderer.d.ts +24 -0
- package/dist/story/annotation_3d_renderer.d.ts +29 -0
- package/dist/story/annotation_renderer.d.ts +35 -0
- package/dist/story/index.d.ts +7 -0
- package/dist/story/schema.d.ts +1154 -0
- package/dist/story/slide_transition_manager.d.ts +30 -0
- package/dist/story/story_manager.d.ts +170 -0
- package/dist/story/trigger_manager.d.ts +43 -0
- package/dist/utils/constants.d.ts +6 -0
- package/dist/utils/cursor_3d.d.ts +48 -0
- package/dist/utils/error.d.ts +54 -0
- package/dist/utils/index.d.ts +4 -0
- package/dist/utils/log.d.ts +8 -0
- package/dist/utils/utils.d.ts +2 -0
- package/dist/viewer/index.d.ts +1 -0
- package/dist/viewer/orbit_controller.d.ts +62 -0
- package/dist/viewer/raycast_helper.d.ts +37 -0
- package/dist/viewer/viewer.d.ts +141 -0
- package/dist/vite/glimmer.mjs +11522 -0
- package/dist/vite/glimmer.umd.js +914 -0
- package/package.json +64 -4
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import * as THREE from 'three';
|
|
2
|
+
import { LineSegments2 } from 'three/examples/jsm/lines/LineSegments2';
|
|
3
|
+
/**
|
|
4
|
+
* EdgeDecorator
|
|
5
|
+
*
|
|
6
|
+
* Utility class for generating enhanced edge renderings for THREE.Mesh objects.
|
|
7
|
+
* Supports both threshold-based "classic" edges and custom shader-based "conditional" edges.
|
|
8
|
+
*/
|
|
9
|
+
export declare class EdgeDecorator {
|
|
10
|
+
/**
|
|
11
|
+
* Create thick threshold‑based edges for a mesh.
|
|
12
|
+
*
|
|
13
|
+
* @param mesh - The mesh whose edges to extract.
|
|
14
|
+
* @param thresholdAngle - Angle in degrees; edges between faces with normals >= this angle are shown.
|
|
15
|
+
* @param color - Edge line color.
|
|
16
|
+
* @param linewidth - Edge line width.
|
|
17
|
+
* @returns LineSegments2 object representing the thick edges.
|
|
18
|
+
*
|
|
19
|
+
* Note: This uses Three.js's EdgesGeometry and fat line support (LineSegments2/LineMaterial).
|
|
20
|
+
*/
|
|
21
|
+
static thresholdEdges(mesh: THREE.Mesh, thresholdAngle: number, color: THREE.Color | string | number, linewidth?: number): LineSegments2;
|
|
22
|
+
/**
|
|
23
|
+
* Create conditional-shader edges for a mesh.
|
|
24
|
+
*
|
|
25
|
+
* This produces a group containing both thin (shader) and thick (fat line) edge renderings,
|
|
26
|
+
* using custom conditional edge logic.
|
|
27
|
+
*
|
|
28
|
+
* @param mesh - The mesh whose conditional edges to compute.
|
|
29
|
+
* @param color - Edge color.
|
|
30
|
+
* @param linewidth - Edge line width for the thick line (default: 1).
|
|
31
|
+
* @returns THREE.Group containing both thin (LineSegments) and thick (LineSegments2) edge objects.
|
|
32
|
+
*
|
|
33
|
+
* Note: Due to Three.js's typing limitations, type assertions are used when passing custom geometry/materials.
|
|
34
|
+
*/
|
|
35
|
+
static conditionalEdges(mesh: THREE.Mesh, color: THREE.Color | string | number, linewidth?: number, tresholdAngle?: number): THREE.Object3D;
|
|
36
|
+
}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import * as THREE from 'three';
|
|
2
|
+
/**
|
|
3
|
+
* ConditionalEdgesGeometry - A custom geometry class to identify edges based on conditions.
|
|
4
|
+
*/
|
|
5
|
+
export declare class ConditionalEdgesGeometry extends THREE.BufferGeometry {
|
|
6
|
+
constructor(geometry: THREE.BufferGeometry, thresholdAngle?: number);
|
|
7
|
+
}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import * as THREE from 'three';
|
|
2
|
+
import { LineSegmentsGeometry } from 'three/examples/jsm/lines/LineSegmentsGeometry.js';
|
|
3
|
+
/**
|
|
4
|
+
* ConditionalLineSegmentsGeometry
|
|
5
|
+
*
|
|
6
|
+
* Extends LineSegmentsGeometry to support additional attributes for conditional lines.
|
|
7
|
+
* Use fromConditionalEdgesGeometry to populate this geometry from a compatible BufferGeometry.
|
|
8
|
+
*/
|
|
9
|
+
export declare class ConditionalLineSegmentsGeometry extends LineSegmentsGeometry {
|
|
10
|
+
/**
|
|
11
|
+
* Populates this geometry from a ConditionalEdgesGeometry (or any BufferGeometry
|
|
12
|
+
* whose attributes include `direction`, `control0`, and `control1`).
|
|
13
|
+
*
|
|
14
|
+
* @param geometry BufferGeometry with custom attributes.
|
|
15
|
+
* @returns this
|
|
16
|
+
*/
|
|
17
|
+
from_conditional_edges_geometry(geometry: THREE.BufferGeometry & {
|
|
18
|
+
attributes: {
|
|
19
|
+
direction: THREE.BufferAttribute;
|
|
20
|
+
control0: THREE.BufferAttribute;
|
|
21
|
+
control1: THREE.BufferAttribute;
|
|
22
|
+
};
|
|
23
|
+
}): this;
|
|
24
|
+
}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import * as THREE from 'three';
|
|
2
|
+
/**
|
|
3
|
+
* OutsideEdgesGeometry - A custom geometry class to detect and process outer edges of a geometry.
|
|
4
|
+
*/
|
|
5
|
+
export declare class OutsideEdgesGeometry extends THREE.BufferGeometry {
|
|
6
|
+
constructor(geometry: THREE.BufferGeometry);
|
|
7
|
+
}
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
import * as THREE from 'three';
|
|
2
|
+
import { Sun } from './sun';
|
|
3
|
+
import { Sky } from 'three/examples/jsm/objects/Sky.js';
|
|
4
|
+
import { RoomEnvironment } from 'three/examples/jsm/environments/RoomEnvironment.js';
|
|
5
|
+
import { Settings } from '../settings';
|
|
6
|
+
import { Viewer } from '../viewer';
|
|
7
|
+
/**
|
|
8
|
+
* Environment manages scene backgrounds and lighting.
|
|
9
|
+
*
|
|
10
|
+
* Events:
|
|
11
|
+
* - 'loading': Fired when starting to load HDR/environment
|
|
12
|
+
* detail: { type: string, url?: string }
|
|
13
|
+
* - 'loaded': Fired when environment successfully loaded
|
|
14
|
+
* detail: { type: string, url?: string, texture?: THREE.Texture }
|
|
15
|
+
* - 'error': Fired when environment loading fails
|
|
16
|
+
* detail: { error: GlimmerError }
|
|
17
|
+
*/
|
|
18
|
+
export declare class Environment extends EventTarget {
|
|
19
|
+
private settings;
|
|
20
|
+
private renderer;
|
|
21
|
+
private scene;
|
|
22
|
+
private viewer;
|
|
23
|
+
ready: Promise<void>;
|
|
24
|
+
texture: THREE.Texture | null;
|
|
25
|
+
ambient: THREE.AmbientLight | null;
|
|
26
|
+
room: RoomEnvironment | null;
|
|
27
|
+
env_map: THREE.Texture | null;
|
|
28
|
+
sky: Sky | null;
|
|
29
|
+
Sun: Sun | null;
|
|
30
|
+
constructor(viewer: Viewer, settings: Settings);
|
|
31
|
+
update(environment_settings: {
|
|
32
|
+
type: string;
|
|
33
|
+
url?: string;
|
|
34
|
+
}): Promise<void>;
|
|
35
|
+
clear_environment(): void;
|
|
36
|
+
set_sky_environment(): void;
|
|
37
|
+
set_room_environment(): void;
|
|
38
|
+
set_color_environment(color?: number): void;
|
|
39
|
+
set_hdr_environment(url: string, ultra?: boolean): Promise<void>;
|
|
40
|
+
set_ambient_lighting(color?: number, intensity?: number): void;
|
|
41
|
+
dispose(): void;
|
|
42
|
+
}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import * as THREE from 'three';
|
|
2
|
+
import { Viewer } from '../viewer';
|
|
3
|
+
import { Settings } from '../settings';
|
|
4
|
+
import { Environment } from './environment';
|
|
5
|
+
import { ModelManager } from '../model';
|
|
6
|
+
export declare class Sun {
|
|
7
|
+
private viewer;
|
|
8
|
+
private scene;
|
|
9
|
+
private settings;
|
|
10
|
+
private sun_settings;
|
|
11
|
+
private model_manager;
|
|
12
|
+
sun: THREE.DirectionalLight | null;
|
|
13
|
+
private environment;
|
|
14
|
+
constructor(viewer: Viewer, settings: Settings, environment: Environment, model_manager: ModelManager);
|
|
15
|
+
update(): void;
|
|
16
|
+
sun_fit_object(fit_object?: THREE.Object3D): void;
|
|
17
|
+
sun_fit_shadow(): void;
|
|
18
|
+
sun_create(): void;
|
|
19
|
+
private _infer_sun_position_from_env_map;
|
|
20
|
+
dispose(): void;
|
|
21
|
+
}
|
|
@@ -0,0 +1,89 @@
|
|
|
1
|
+
import * as THREE from 'three';
|
|
2
|
+
/**
|
|
3
|
+
* MoveGizmo - Interactive 3D translation gizmo
|
|
4
|
+
*
|
|
5
|
+
* Provides visual arrows for moving objects along X, Y, Z axes.
|
|
6
|
+
* Emits 'move' events during dragging.
|
|
7
|
+
*
|
|
8
|
+
* Events:
|
|
9
|
+
* - 'movestart': Fired when drag starts
|
|
10
|
+
* detail: { object: THREE.Object3D, axis: 'x' | 'y' | 'z' }
|
|
11
|
+
* - 'move': Fired during dragging
|
|
12
|
+
* detail: { object: THREE.Object3D, position: THREE.Vector3, delta: THREE.Vector3 }
|
|
13
|
+
* - 'moveend': Fired when drag ends
|
|
14
|
+
* detail: { object: THREE.Object3D, position: THREE.Vector3 }
|
|
15
|
+
*
|
|
16
|
+
* Usage:
|
|
17
|
+
* ```typescript
|
|
18
|
+
* const gizmo = new MoveGizmo()
|
|
19
|
+
* gizmo.attach(object)
|
|
20
|
+
* gizmo.enable(scene, camera, domElement)
|
|
21
|
+
*
|
|
22
|
+
* gizmo.addEventListener('move', (e) => {
|
|
23
|
+
* console.log('New position:', e.detail.position)
|
|
24
|
+
* })
|
|
25
|
+
* ```
|
|
26
|
+
*/
|
|
27
|
+
export declare class MoveGizmo extends EventTarget {
|
|
28
|
+
private target_object?;
|
|
29
|
+
private gizmo_group;
|
|
30
|
+
private axis_arrows;
|
|
31
|
+
private enabled;
|
|
32
|
+
private active_axis?;
|
|
33
|
+
private drag_start_position;
|
|
34
|
+
private drag_start_intersection;
|
|
35
|
+
private drag_start_mouse;
|
|
36
|
+
private camera?;
|
|
37
|
+
private dom_element?;
|
|
38
|
+
private plane_normal;
|
|
39
|
+
private plane;
|
|
40
|
+
private raycaster;
|
|
41
|
+
private orbit_controls?;
|
|
42
|
+
private event_listeners;
|
|
43
|
+
private static AXIS_COLORS;
|
|
44
|
+
constructor();
|
|
45
|
+
/**
|
|
46
|
+
* Create the visual gizmo (3 arrows for X, Y, Z)
|
|
47
|
+
*/
|
|
48
|
+
private create_gizmo;
|
|
49
|
+
/**
|
|
50
|
+
* Attach gizmo to target object
|
|
51
|
+
*/
|
|
52
|
+
attach(object: THREE.Object3D): void;
|
|
53
|
+
/**
|
|
54
|
+
* Detach gizmo from current object
|
|
55
|
+
*/
|
|
56
|
+
detach(): void;
|
|
57
|
+
/**
|
|
58
|
+
* Enable gizmo interactions
|
|
59
|
+
*/
|
|
60
|
+
enable(scene: THREE.Scene, camera: THREE.Camera, domElement: HTMLElement, orbitControls?: any): void;
|
|
61
|
+
/**
|
|
62
|
+
* Disable gizmo interactions and remove from scene
|
|
63
|
+
*/
|
|
64
|
+
disable(scene: THREE.Scene): void;
|
|
65
|
+
/**
|
|
66
|
+
* Update gizmo position to match target object
|
|
67
|
+
*/
|
|
68
|
+
update(): void;
|
|
69
|
+
/**
|
|
70
|
+
* Mouse down handler - detect axis selection
|
|
71
|
+
*/
|
|
72
|
+
private on_mouse_down;
|
|
73
|
+
/**
|
|
74
|
+
* Setup drag plane based on active axis
|
|
75
|
+
*/
|
|
76
|
+
private setup_drag_plane;
|
|
77
|
+
/**
|
|
78
|
+
* Mouse move handler - perform drag
|
|
79
|
+
*/
|
|
80
|
+
private on_mouse_move;
|
|
81
|
+
/**
|
|
82
|
+
* Mouse up handler - end drag
|
|
83
|
+
*/
|
|
84
|
+
private on_mouse_up;
|
|
85
|
+
/**
|
|
86
|
+
* Dispose resources
|
|
87
|
+
*/
|
|
88
|
+
dispose(): void;
|
|
89
|
+
}
|
|
@@ -0,0 +1,86 @@
|
|
|
1
|
+
import * as THREE from 'three';
|
|
2
|
+
/**
|
|
3
|
+
* RotateGizmo - Interactive 3D rotation gizmo
|
|
4
|
+
*
|
|
5
|
+
* Provides visual rings for rotating objects around X, Y, Z axes.
|
|
6
|
+
* Emits 'rotate' events during dragging.
|
|
7
|
+
*
|
|
8
|
+
* Events:
|
|
9
|
+
* - 'rotatestart': Fired when drag starts
|
|
10
|
+
* detail: { object: THREE.Object3D, axis: 'x' | 'y' | 'z' }
|
|
11
|
+
* - 'rotate': Fired during dragging
|
|
12
|
+
* detail: { object: THREE.Object3D, rotation: THREE.Euler, delta: number }
|
|
13
|
+
* - 'rotateend': Fired when drag ends
|
|
14
|
+
* detail: { object: THREE.Object3D, rotation: THREE.Euler }
|
|
15
|
+
*
|
|
16
|
+
* Usage:
|
|
17
|
+
* ```typescript
|
|
18
|
+
* const gizmo = new RotateGizmo()
|
|
19
|
+
* gizmo.attach(object)
|
|
20
|
+
* gizmo.enable(scene, camera, domElement)
|
|
21
|
+
*
|
|
22
|
+
* gizmo.addEventListener('rotate', (e) => {
|
|
23
|
+
* console.log('New rotation:', e.detail.rotation)
|
|
24
|
+
* })
|
|
25
|
+
* ```
|
|
26
|
+
*/
|
|
27
|
+
export declare class RotateGizmo extends EventTarget {
|
|
28
|
+
private target_object?;
|
|
29
|
+
private gizmo_group;
|
|
30
|
+
private axis_rings;
|
|
31
|
+
private enabled;
|
|
32
|
+
private active_axis?;
|
|
33
|
+
private drag_start_rotation;
|
|
34
|
+
private drag_start_angle;
|
|
35
|
+
private camera?;
|
|
36
|
+
private dom_element?;
|
|
37
|
+
private raycaster;
|
|
38
|
+
private orbit_controls?;
|
|
39
|
+
private event_listeners;
|
|
40
|
+
private static AXIS_COLORS;
|
|
41
|
+
constructor();
|
|
42
|
+
/**
|
|
43
|
+
* Create the visual gizmo (3 rotation rings for X, Y, Z)
|
|
44
|
+
*/
|
|
45
|
+
private create_gizmo;
|
|
46
|
+
/**
|
|
47
|
+
* Attach gizmo to target object
|
|
48
|
+
*/
|
|
49
|
+
attach(object: THREE.Object3D): void;
|
|
50
|
+
/**
|
|
51
|
+
* Detach gizmo from current object
|
|
52
|
+
*/
|
|
53
|
+
detach(): void;
|
|
54
|
+
/**
|
|
55
|
+
* Enable gizmo interactions
|
|
56
|
+
*/
|
|
57
|
+
enable(scene: THREE.Scene, camera: THREE.Camera, domElement: HTMLElement, orbitControls?: any): void;
|
|
58
|
+
/**
|
|
59
|
+
* Disable gizmo interactions and remove from scene
|
|
60
|
+
*/
|
|
61
|
+
disable(scene: THREE.Scene): void;
|
|
62
|
+
/**
|
|
63
|
+
* Update gizmo position to match target object
|
|
64
|
+
*/
|
|
65
|
+
update(): void;
|
|
66
|
+
/**
|
|
67
|
+
* Mouse down handler - detect ring selection
|
|
68
|
+
*/
|
|
69
|
+
private on_mouse_down;
|
|
70
|
+
/**
|
|
71
|
+
* Get angle of mouse position around rotation axis
|
|
72
|
+
*/
|
|
73
|
+
private get_mouse_angle;
|
|
74
|
+
/**
|
|
75
|
+
* Mouse move handler - perform rotation
|
|
76
|
+
*/
|
|
77
|
+
private on_mouse_move;
|
|
78
|
+
/**
|
|
79
|
+
* Mouse up handler - end rotation
|
|
80
|
+
*/
|
|
81
|
+
private on_mouse_up;
|
|
82
|
+
/**
|
|
83
|
+
* Dispose resources
|
|
84
|
+
*/
|
|
85
|
+
dispose(): void;
|
|
86
|
+
}
|
|
@@ -0,0 +1,91 @@
|
|
|
1
|
+
import * as THREE from 'three';
|
|
2
|
+
import type { SectionBoxBounds } from '../section/section_box';
|
|
3
|
+
/**
|
|
4
|
+
* SectionBoxGizmo - Interactive 3D editor for section box bounds
|
|
5
|
+
*
|
|
6
|
+
* Provides visual handles and mouse interactions for editing section box.
|
|
7
|
+
* Emits 'boundschanged' events during editing.
|
|
8
|
+
*
|
|
9
|
+
* Events:
|
|
10
|
+
* - 'boundschanged': Fired when bounds are modified
|
|
11
|
+
* detail: { bounds: SectionBoxBounds }
|
|
12
|
+
*
|
|
13
|
+
* Usage:
|
|
14
|
+
* ```typescript
|
|
15
|
+
* const gizmo = new SectionBoxGizmo()
|
|
16
|
+
* gizmo.fit_to_model(model)
|
|
17
|
+
* gizmo.enter_edit_mode(scene, camera, domElement)
|
|
18
|
+
*
|
|
19
|
+
* gizmo.addEventListener('boundschanged', (e) => {
|
|
20
|
+
* console.log('New bounds:', e.detail.bounds)
|
|
21
|
+
* })
|
|
22
|
+
*
|
|
23
|
+
* // Later:
|
|
24
|
+
* const finalBounds = gizmo.finalize(scene)
|
|
25
|
+
* ```
|
|
26
|
+
*/
|
|
27
|
+
export declare class SectionBoxGizmo extends EventTarget {
|
|
28
|
+
private bounds;
|
|
29
|
+
private box_helper?;
|
|
30
|
+
private plane_handles;
|
|
31
|
+
private edit_mode;
|
|
32
|
+
private active_handle?;
|
|
33
|
+
private drag_start_value;
|
|
34
|
+
private drag_start_mouse;
|
|
35
|
+
private orbit_controls?;
|
|
36
|
+
private event_listeners;
|
|
37
|
+
constructor(initial_bounds?: SectionBoxBounds | THREE.Box3);
|
|
38
|
+
/**
|
|
39
|
+
* Auto-fit bounds to model's bounding box
|
|
40
|
+
*/
|
|
41
|
+
fit_to_model(model: THREE.Group | THREE.Mesh): void;
|
|
42
|
+
/**
|
|
43
|
+
* Auto-fit bounds to array of objects
|
|
44
|
+
*/
|
|
45
|
+
fit_to_objects(objects: THREE.Object3D[]): void;
|
|
46
|
+
/**
|
|
47
|
+
* Finalize edit mode and return bounds (convenience method)
|
|
48
|
+
* Exits edit mode and returns current bounds
|
|
49
|
+
*/
|
|
50
|
+
finalize(scene: THREE.Scene): SectionBoxBounds;
|
|
51
|
+
/**
|
|
52
|
+
* Enter edit mode: show visual helpers and enable interactions
|
|
53
|
+
*/
|
|
54
|
+
enter_edit_mode(scene: THREE.Scene, camera: THREE.Camera, domElement: HTMLElement, orbitControls?: any): void;
|
|
55
|
+
/**
|
|
56
|
+
* Exit edit mode: hide and cleanup all helpers
|
|
57
|
+
*/
|
|
58
|
+
exit_edit_mode(scene: THREE.Scene): void;
|
|
59
|
+
/**
|
|
60
|
+
* Get current bounds in serializable format
|
|
61
|
+
*/
|
|
62
|
+
get_bounds(): SectionBoxBounds;
|
|
63
|
+
/**
|
|
64
|
+
* Set bounds programmatically
|
|
65
|
+
*/
|
|
66
|
+
set_bounds(bounds: SectionBoxBounds): void;
|
|
67
|
+
/**
|
|
68
|
+
* Get bounds as THREE.Box3 (for clipping operations)
|
|
69
|
+
*/
|
|
70
|
+
get_box3(): THREE.Box3;
|
|
71
|
+
/**
|
|
72
|
+
* Check if currently in edit mode
|
|
73
|
+
*/
|
|
74
|
+
get is_editing(): boolean;
|
|
75
|
+
/**
|
|
76
|
+
* Setup mouse interaction handlers for dragging handles
|
|
77
|
+
*/
|
|
78
|
+
private setup_interactions;
|
|
79
|
+
/**
|
|
80
|
+
* Update visual helpers (box and handles) to match current bounds
|
|
81
|
+
*/
|
|
82
|
+
private update_helpers;
|
|
83
|
+
/**
|
|
84
|
+
* Emit boundschanged event
|
|
85
|
+
*/
|
|
86
|
+
private emit_bounds_changed;
|
|
87
|
+
/**
|
|
88
|
+
* Dispose gizmo resources
|
|
89
|
+
*/
|
|
90
|
+
dispose(): void;
|
|
91
|
+
}
|
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
import type { SectionBoxBounds } from '../section/section_box';
|
|
2
|
+
import type { Viewer } from '../viewer';
|
|
3
|
+
import type { Model } from '../model';
|
|
4
|
+
/**
|
|
5
|
+
* SectionBoxManager - High-level manager for section box feature
|
|
6
|
+
*
|
|
7
|
+
* Combines:
|
|
8
|
+
* - SectionBoxGizmo (interactive editing)
|
|
9
|
+
* - SectionBox (live clipping planes + earcut caps, no CSG)
|
|
10
|
+
*
|
|
11
|
+
* Events:
|
|
12
|
+
* - 'editstart': Fired when entering edit mode
|
|
13
|
+
* detail: { bounds: SectionBoxBounds }
|
|
14
|
+
* - 'boundschanged': Fired when bounds are modified during editing
|
|
15
|
+
* detail: { bounds: SectionBoxBounds }
|
|
16
|
+
* - 'editend': Fired when exiting edit mode
|
|
17
|
+
* detail: { bounds: SectionBoxBounds }
|
|
18
|
+
* - 'applied': Fired when the section is applied to a model
|
|
19
|
+
* detail: { bounds: SectionBoxBounds }
|
|
20
|
+
*
|
|
21
|
+
* Usage:
|
|
22
|
+
* ```typescript
|
|
23
|
+
* const manager = new SectionBoxManager(viewer)
|
|
24
|
+
*
|
|
25
|
+
* // Start interactive editing
|
|
26
|
+
* manager.create_for_model(model)
|
|
27
|
+
*
|
|
28
|
+
* // Apply clipping section
|
|
29
|
+
* manager.apply_to_model(model)
|
|
30
|
+
*
|
|
31
|
+
* // Finalize and get bounds
|
|
32
|
+
* const bounds = manager.finalize()
|
|
33
|
+
*
|
|
34
|
+
* // Clean up
|
|
35
|
+
* manager.clear_result()
|
|
36
|
+
* ```
|
|
37
|
+
*/
|
|
38
|
+
export declare class SectionBoxManager extends EventTarget {
|
|
39
|
+
private viewer;
|
|
40
|
+
private gizmo?;
|
|
41
|
+
private section_box;
|
|
42
|
+
private sectioned_model?;
|
|
43
|
+
constructor(viewer: Viewer);
|
|
44
|
+
/**
|
|
45
|
+
* Create gizmo and enter interactive edit mode
|
|
46
|
+
* @param model - Model to fit the section box to
|
|
47
|
+
*/
|
|
48
|
+
create_for_model(model: Model): void;
|
|
49
|
+
/**
|
|
50
|
+
* Apply live clipping-plane section to a model.
|
|
51
|
+
* The original model stays in the scene; its materials are clipped and
|
|
52
|
+
* solid caps are added. No geometry is duplicated (CSG backend removed).
|
|
53
|
+
* @param model - Model to section
|
|
54
|
+
* @param bounds - Optional bounds (uses gizmo bounds if not provided)
|
|
55
|
+
*/
|
|
56
|
+
apply_to_model(model: Model, bounds?: SectionBoxBounds): void;
|
|
57
|
+
/**
|
|
58
|
+
* Exit edit mode and finalize bounds
|
|
59
|
+
* @returns Final bounds or null if no gizmo active
|
|
60
|
+
*/
|
|
61
|
+
finalize(): SectionBoxBounds | null;
|
|
62
|
+
/**
|
|
63
|
+
* Clear section: remove caps, restore material clipping
|
|
64
|
+
*/
|
|
65
|
+
clear_result(): void;
|
|
66
|
+
/**
|
|
67
|
+
* Get current bounds (if gizmo exists)
|
|
68
|
+
*/
|
|
69
|
+
get_bounds(): SectionBoxBounds | null;
|
|
70
|
+
/**
|
|
71
|
+
* Check if currently in edit mode
|
|
72
|
+
*/
|
|
73
|
+
get is_editing(): boolean;
|
|
74
|
+
/**
|
|
75
|
+
* Dispose all resources
|
|
76
|
+
*/
|
|
77
|
+
dispose(): void;
|
|
78
|
+
/**
|
|
79
|
+
* Internal: dispose gizmo
|
|
80
|
+
*/
|
|
81
|
+
private dispose_gizmo;
|
|
82
|
+
}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import { Settings } from './settings';
|
|
2
|
+
import { Viewer } from './viewer';
|
|
3
|
+
import { Sun, Environment } from './environment';
|
|
4
|
+
import { ModelManager } from './model';
|
|
5
|
+
import { SettingsType } from './settings/schema';
|
|
6
|
+
/**
|
|
7
|
+
* Glimmer - Main facade for the 3D viewer system
|
|
8
|
+
*
|
|
9
|
+
* Events:
|
|
10
|
+
* - 'ready': Fired when initialization completes successfully
|
|
11
|
+
* detail: {}
|
|
12
|
+
* - 'error': Fired when an error occurs during initialization
|
|
13
|
+
* detail: { error: GlimmerError }
|
|
14
|
+
* - 'dispose': Fired when the viewer is disposed
|
|
15
|
+
* detail: {}
|
|
16
|
+
*/
|
|
17
|
+
export declare class Glimmer extends EventTarget {
|
|
18
|
+
settings: Settings;
|
|
19
|
+
viewer: Viewer;
|
|
20
|
+
environment: Environment;
|
|
21
|
+
sun: Sun;
|
|
22
|
+
model_manager: ModelManager;
|
|
23
|
+
constructor(container: HTMLElement, initialSettings: Partial<SettingsType>);
|
|
24
|
+
initialize(): Promise<void>;
|
|
25
|
+
dispose(): void;
|
|
26
|
+
}
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import './style/main.scss';
|
|
2
|
+
export { Glimmer } from './glimmer';
|
|
3
|
+
export { Settings } from './settings';
|
|
4
|
+
export { Viewer } from './viewer';
|
|
5
|
+
export { Environment, Sun } from './environment';
|
|
6
|
+
export { ModelManager, Model } from './model';
|
|
7
|
+
export { StoryManager } from './story';
|
|
8
|
+
export { SectionBox, PlaneHandle } from './section';
|
|
9
|
+
export type { SectionBoxBounds, SectionCapOptions, Segment } from './section';
|
|
10
|
+
export { OutlineMesh, OutlineMaterial } from './outline';
|
|
11
|
+
export { SectionBoxGizmo, SectionBoxManager, MoveGizmo, RotateGizmo } from './gizmos';
|
|
12
|
+
export type { SettingsType, ModelSettingsType, EnvironmentType, SunSettingsType } from './settings/schema';
|
|
13
|
+
export type { StoryType, StorySlideType, AnnotationType, TransitionType } from './story/schema';
|
package/dist/main.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import './style/main.scss';
|
|
@@ -0,0 +1,88 @@
|
|
|
1
|
+
import * as THREE from 'three';
|
|
2
|
+
import { ModelLoader } from './model_loader';
|
|
3
|
+
import { Viewer } from '../viewer';
|
|
4
|
+
import type { ModelSettingsType } from '../settings/schema';
|
|
5
|
+
export declare class Model {
|
|
6
|
+
group: THREE.Group;
|
|
7
|
+
private loader;
|
|
8
|
+
private viewer;
|
|
9
|
+
private scene;
|
|
10
|
+
settings: ModelSettingsType;
|
|
11
|
+
constructor(viewer: Viewer, loader: ModelLoader, modelsettings: ModelSettingsType, name?: string);
|
|
12
|
+
/**
|
|
13
|
+
* Load the model from the settings URL and add it to the scene.
|
|
14
|
+
* This method will also handle animations, edges, and other settings.
|
|
15
|
+
*/
|
|
16
|
+
load(): Promise<this>;
|
|
17
|
+
add_threshold_edges(angle_degrees?: number, color?: number, line_width?: number): void;
|
|
18
|
+
add_conditional_edges(color?: number, line_width?: number, threshold_angle?: number): void;
|
|
19
|
+
set_color(color: THREE.ColorRepresentation): void;
|
|
20
|
+
/**
|
|
21
|
+
* Set the visibility of the model.
|
|
22
|
+
* @param visible - Whether the model should be visible.
|
|
23
|
+
*/
|
|
24
|
+
set_visible(visible: boolean): void;
|
|
25
|
+
/**
|
|
26
|
+
* Set the transform (position, rotation, scale) of the model.
|
|
27
|
+
* @param transform - Object containing optional position, rotation, and scale.
|
|
28
|
+
*/
|
|
29
|
+
set_transform(transform: {
|
|
30
|
+
position?: [number, number, number];
|
|
31
|
+
rotation?: [number, number, number];
|
|
32
|
+
scale?: number | [number, number, number];
|
|
33
|
+
}): void;
|
|
34
|
+
/**
|
|
35
|
+
* Get the current transform (position, rotation, scale) of the model.
|
|
36
|
+
* @returns Object containing position, rotation, and scale arrays.
|
|
37
|
+
*/
|
|
38
|
+
get_transform(): {
|
|
39
|
+
position: [number, number, number];
|
|
40
|
+
rotation: [number, number, number];
|
|
41
|
+
scale: [number, number, number];
|
|
42
|
+
};
|
|
43
|
+
set_threshold_edge_line_width(width: number): void;
|
|
44
|
+
set_conditional_edge_line_width(width: number): void;
|
|
45
|
+
/**
|
|
46
|
+
* Remove model and its edge decorations from the scene,
|
|
47
|
+
* and dispose all geometries, materials, and textures.
|
|
48
|
+
*/
|
|
49
|
+
remove(): void;
|
|
50
|
+
/**
|
|
51
|
+
* Helper to dispose all geometry, material, and textures in a group recursively.
|
|
52
|
+
*/
|
|
53
|
+
private _dispose_group;
|
|
54
|
+
private _remove_group_by_user_data;
|
|
55
|
+
private _bake_mesh;
|
|
56
|
+
/**
|
|
57
|
+
* Helper to dispose a material and its textures.
|
|
58
|
+
*/
|
|
59
|
+
private _dispose_material;
|
|
60
|
+
/**
|
|
61
|
+
* Create threshold‑based edges for a mesh.
|
|
62
|
+
*
|
|
63
|
+
* @param mesh - The mesh whose edges to extract.
|
|
64
|
+
* @param thresholdAngle - Angle in degrees; edges between faces with normals >= this angle are shown.
|
|
65
|
+
* @param color - Edge line color.
|
|
66
|
+
* @param linewidth - Edge line width.
|
|
67
|
+
* @returns LineSegments2 object representing the thick edges.
|
|
68
|
+
*
|
|
69
|
+
* Note: This uses Three.js's EdgesGeometry and fat line support (LineSegments2/LineMaterial).
|
|
70
|
+
*/
|
|
71
|
+
private _generate_threshold_edges;
|
|
72
|
+
/**
|
|
73
|
+
* Create conditional-shader edges for a mesh.
|
|
74
|
+
*
|
|
75
|
+
* This produces a group containing both thin (shader) and thick (fat line) edge renderings,
|
|
76
|
+
* using custom conditional edge logic.
|
|
77
|
+
*
|
|
78
|
+
* @param mesh - The mesh whose conditional edges to compute.
|
|
79
|
+
* @param color - Edge color.
|
|
80
|
+
* @param linewidth - Edge line width for the thick line (default: 1).
|
|
81
|
+
* @returns THREE.Group containing both thin (LineSegments) and thick (LineSegments2) edge objects.
|
|
82
|
+
*
|
|
83
|
+
* Note: Due to Three.js's typing limitations, type assertions are used when passing custom geometry/materials.
|
|
84
|
+
*/
|
|
85
|
+
private _generate_conditional_thick_edges;
|
|
86
|
+
private _generate_conditional_thin_edges;
|
|
87
|
+
dispose(): void;
|
|
88
|
+
}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import type { GLTF } from 'three/examples/jsm/loaders/GLTFLoader';
|
|
2
|
+
export declare class ModelLoader {
|
|
3
|
+
private gltf_loader;
|
|
4
|
+
constructor(dracoDecoderPath?: string);
|
|
5
|
+
/**
|
|
6
|
+
* Loads a GLTF/GLB and returns a THREE.Group
|
|
7
|
+
*/
|
|
8
|
+
load_gltf(url: string): Promise<GLTF>;
|
|
9
|
+
}
|