@omrips/viewstl 2.0.0-rc.4 → 2.0.0-rc.6

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 (50) hide show
  1. package/README.md +19 -173
  2. package/build/chunks/archive-QK7XZSVT.js +1 -0
  3. package/build/{v2/chunks/cad-VY42CMP4.js → chunks/cad-QGVO6UGR.js} +1 -1
  4. package/build/chunks/chunk-6AW5U52H.js +1 -0
  5. package/build/{v2/chunks/chunk-R3HNTB5A.js → chunks/chunk-CVGQTUJ5.js} +2 -2
  6. package/build/chunks/chunk-FUXP2W57.js +1 -0
  7. package/build/chunks/chunk-LFTKNL2V.js +1 -0
  8. package/build/{v2/chunks/chunk-ZMK3UZZE.js → chunks/chunk-T6PPRDOE.js} +1 -1
  9. package/build/chunks/chunk-V6KYGP62.js +1 -0
  10. package/build/{v2/chunks/export-7OP4ZGGJ.js → chunks/export-2CFMTPJ3.js} +3 -3
  11. package/build/{v2/chunks/export-cad-QPBT756V.js → chunks/export-cad-XOXIE726.js} +1 -1
  12. package/build/{v2/chunks/export-zip-EDCWH5PX.js → chunks/export-zip-I2ADLFJI.js} +1 -1
  13. package/build/chunks/measure-3LDALPCN.js +1 -0
  14. package/build/chunks/print-check-WWHTT5PW.js +1 -0
  15. package/build/{v2/chunks/scene-export-KQBS7VRJ.js → chunks/scene-export-FPPL466I.js} +1 -1
  16. package/build/chunks/scene-reader-WXTRELY3.js +1 -0
  17. package/build/{v2/node → node}/analysis-worker.js +13 -12
  18. package/build/{v2/node → node}/index.cjs +7 -7
  19. package/build/{v2/node → node}/index.js +6 -6
  20. package/build/stl_viewer.min.js +51 -0
  21. package/build/{v2/viewstl.cjs → viewstl.cjs} +1641 -272
  22. package/build/{v2/viewstl.d.cts → viewstl.d.cts} +98 -0
  23. package/build/{v2/viewstl.d.ts → viewstl.d.ts} +98 -0
  24. package/build/{v2/viewstl.js → viewstl.js} +1641 -272
  25. package/build/viewstl.min.js +51 -0
  26. package/build/viewstl.worker.js +1 -0
  27. package/docs/releases/2.0.0-rc.6.md +7 -0
  28. package/docs/v2-compatibility.md +5 -5
  29. package/docs/v2-usage.md +152 -21
  30. package/docs/v2-verification.md +169 -0
  31. package/legacy/README.md +14 -8
  32. package/package.json +18 -35
  33. package/build/v2/README.md +0 -15
  34. package/build/v2/chunks/archive-VGS4J4Z7.js +0 -1
  35. package/build/v2/chunks/chunk-JH3H3JWA.js +0 -1
  36. package/build/v2/chunks/chunk-U33KANV7.js +0 -1
  37. package/build/v2/chunks/print-check-2PU7CSL3.js +0 -1
  38. package/build/v2/chunks/scene-reader-APUJOPUR.js +0 -1
  39. package/build/v2/stl_viewer.min.js +0 -51
  40. package/build/v2/viewstl.min.js +0 -51
  41. package/build/v2/viewstl.worker.js +0 -1
  42. /package/build/{v2/THIRD-PARTY-NOTICES.txt → THIRD-PARTY-NOTICES.txt} +0 -0
  43. /package/build/{v2/cad → cad}/occt-import-js.js +0 -0
  44. /package/build/{v2/cad → cad}/occt-import-js.source.txt +0 -0
  45. /package/build/{v2/cad → cad}/occt-import-js.wasm +0 -0
  46. /package/build/{v2/cad → cad}/prepare-cad.source.txt +0 -0
  47. /package/build/{v2/chunks/chunk-JS56KC3I.js → chunks/chunk-W5KVLGVR.js} +0 -0
  48. /package/build/{v2/chunks → chunks}/chunk-ZSV4PTIA.js +0 -0
  49. /package/build/{v2/node → node}/index.d.cts +0 -0
  50. /package/build/{v2/node → node}/index.d.ts +0 -0
@@ -88,17 +88,71 @@ export interface SceneExportResult {
88
88
  }
89
89
  export interface AnimationTrack extends Transform {
90
90
  msec?: number;
91
+ /** Continuous accumulation; applies to delta only. */
91
92
  loop?: boolean;
92
93
  }
93
94
  export interface Animation {
94
95
  delta?: AnimationTrack;
95
96
  exact?: AnimationTrack;
96
97
  }
98
+ export interface AnimationPlaybackState {
99
+ status: "idle" | "running" | "paused" | "stopped" | "completed";
100
+ elapsed_ms: number;
101
+ /** Temporarily suspended by a hidden document or lost graphics context. */
102
+ suspended: boolean;
103
+ tracks: Array<{
104
+ mode: "delta" | "exact";
105
+ msec: number;
106
+ loop: boolean;
107
+ progress: number;
108
+ }>;
109
+ }
110
+ export type AnimationStateReason =
111
+ | "started"
112
+ | "restored"
113
+ | "replaced"
114
+ | "paused"
115
+ | "resumed"
116
+ | "completed"
117
+ | "stopped"
118
+ | "manual"
119
+ | "removed"
120
+ | "clean"
121
+ | "error";
122
+ /** Serialized scene playback. Normally created by get_vsj/export_scene. */
123
+ export interface SavedAnimationState {
124
+ version: 1;
125
+ elapsed_ms: number;
126
+ paused: boolean;
127
+ origin: Required<Omit<Transform, "scale">>;
128
+ center: [number, number, number];
129
+ }
97
130
  export interface GeometryData {
98
131
  positions: Float32Array | number[];
99
132
  colors?: Float32Array | number[] | null;
100
133
  }
134
+ export interface ModelSize {
135
+ version: 1;
136
+ baseline_mm: [number, number, number];
137
+ unit_factor?: number;
138
+ file_units: Units;
139
+ editable: boolean;
140
+ dimensions_mm: [number, number, number];
141
+ }
142
+ export interface CameraBookmark {
143
+ name: string;
144
+ camera: CameraState;
145
+ }
146
+ export interface ModelMeasurements {
147
+ area_mm2: number;
148
+ volume_mm3: number | null;
149
+ volume_valid: boolean;
150
+ volume_reason: string;
151
+ }
101
152
  export interface ModelOptions extends Transform {
153
+ /** Display label; filename remains the source reference for VSJ. */
154
+ display_name?: string;
155
+ size_state?: Omit<ModelSize, "dimensions_mm">;
102
156
  id?: number;
103
157
  filename?: string;
104
158
  /** Retrieve a public URL through the explicitly configured same-origin relay. */
@@ -116,6 +170,7 @@ export interface ModelOptions extends Transform {
116
170
  view_edges?: boolean;
117
171
  units?: Units;
118
172
  animation?: Animation | null;
173
+ animation_state?: SavedAnimationState | null;
119
174
  }
120
175
  export type ModelClick = (
121
176
  id: number | null,
@@ -173,6 +228,15 @@ export interface ViewerOptions {
173
228
  on_model_drop?: (filename: string) => void;
174
229
  on_model_mouseclick?: ModelClick;
175
230
  on_model_mousedown?: ModelClick;
231
+ animation_state_callback?: (
232
+ id: number,
233
+ state: AnimationPlaybackState,
234
+ reason: AnimationStateReason,
235
+ ) => void;
236
+ animation_complete_callback?: (
237
+ id: number,
238
+ state: AnimationPlaybackState,
239
+ ) => void;
176
240
  }
177
241
  export interface ModelInfo {
178
242
  name: string;
@@ -204,6 +268,8 @@ export interface Scene {
204
268
  auto_rotate: boolean;
205
269
  mouse_zoom: boolean;
206
270
  auto_resize: boolean;
271
+ camera_bookmarks?: CameraBookmark[];
272
+ display_units?: Units;
207
273
  center_models: boolean;
208
274
  grid?: boolean;
209
275
  infinite_grid?: { spacing: number; height: number };
@@ -281,6 +347,31 @@ export class StlViewer {
281
347
  set_camera_state(state: Partial<CameraState>): void;
282
348
  set_camera(x?: number, y?: number, z?: number): void;
283
349
  get_model_info(id: number): ModelInfo | null;
350
+ get_model_info(
351
+ id: number,
352
+ options: { measurements: false },
353
+ ): (Omit<ModelInfo, "area" | "volume"> & { area: null; volume: null }) | null;
354
+ get_model_size(id: number): ModelSize;
355
+ /** Multiplicative XYZ factors about the world-space center. Throws on invalid input. */
356
+ resize_model(id: number, factors: [number, number, number]): ModelSize;
357
+ set_file_units(id: number, units: Units): ModelSize;
358
+ reset_model_size(id: number): ModelSize;
359
+ duplicate_model(id: number): number;
360
+ display_units: Units;
361
+ set_display_units(units: Units): void;
362
+ set_camera_view(
363
+ name: "front" | "back" | "left" | "right" | "top" | "bottom" | "isometric",
364
+ ): void;
365
+ get_camera_bookmarks(): CameraBookmark[];
366
+ set_camera_bookmarks(bookmarks: CameraBookmark[]): void;
367
+ measure_model(
368
+ id: number,
369
+ options?: {
370
+ signal?: AbortSignal;
371
+ max_time_ms?: number;
372
+ on_progress?: (progress: { phase: string; elapsed_ms: number }) => void;
373
+ },
374
+ ): Promise<ModelMeasurements>;
284
375
  get_model_data(id: number): GeometryData | null;
285
376
  get_model_mesh(id: number): unknown;
286
377
  get_stl_bin(id: number): ArrayBuffer | null;
@@ -328,11 +419,17 @@ export class StlViewer {
328
419
  download_vsb(filename?: string): Promise<void | null>;
329
420
  load_vsb(source: string | File | Blob): void;
330
421
  animate_model(id: number, animation: Animation | null): void;
422
+ pause_model_animation(id: number): void;
423
+ resume_model_animation(id: number): void;
424
+ get_model_animation_state(id: number): AnimationPlaybackState | null;
331
425
  get_image_blob(type?: string): Promise<Blob>;
332
426
  }
333
427
  export default StlViewer;
334
428
 
335
429
  export interface ViewstlAppOptions {
430
+ /** Composed with the app's own playback controls and reduced-motion policy. */
431
+ animation_state_callback?: ViewerOptions["animation_state_callback"];
432
+ animation_complete_callback?: ViewerOptions["animation_complete_callback"];
336
433
  url_import_endpoint?: string;
337
434
  worker_url?: string | URL;
338
435
  worker_factory?: () => Worker;
@@ -357,6 +454,7 @@ export interface ViewstlAppState {
357
454
  /** Euler XYZ angles in degrees, about the model's own center. */
358
455
  rotation: Vector3;
359
456
  color: string | null;
457
+ animation: AnimationPlaybackState;
360
458
  }>;
361
459
  }
362
460
  export interface ViewstlApp {
@@ -88,17 +88,71 @@ export interface SceneExportResult {
88
88
  }
89
89
  export interface AnimationTrack extends Transform {
90
90
  msec?: number;
91
+ /** Continuous accumulation; applies to delta only. */
91
92
  loop?: boolean;
92
93
  }
93
94
  export interface Animation {
94
95
  delta?: AnimationTrack;
95
96
  exact?: AnimationTrack;
96
97
  }
98
+ export interface AnimationPlaybackState {
99
+ status: "idle" | "running" | "paused" | "stopped" | "completed";
100
+ elapsed_ms: number;
101
+ /** Temporarily suspended by a hidden document or lost graphics context. */
102
+ suspended: boolean;
103
+ tracks: Array<{
104
+ mode: "delta" | "exact";
105
+ msec: number;
106
+ loop: boolean;
107
+ progress: number;
108
+ }>;
109
+ }
110
+ export type AnimationStateReason =
111
+ | "started"
112
+ | "restored"
113
+ | "replaced"
114
+ | "paused"
115
+ | "resumed"
116
+ | "completed"
117
+ | "stopped"
118
+ | "manual"
119
+ | "removed"
120
+ | "clean"
121
+ | "error";
122
+ /** Serialized scene playback. Normally created by get_vsj/export_scene. */
123
+ export interface SavedAnimationState {
124
+ version: 1;
125
+ elapsed_ms: number;
126
+ paused: boolean;
127
+ origin: Required<Omit<Transform, "scale">>;
128
+ center: [number, number, number];
129
+ }
97
130
  export interface GeometryData {
98
131
  positions: Float32Array | number[];
99
132
  colors?: Float32Array | number[] | null;
100
133
  }
134
+ export interface ModelSize {
135
+ version: 1;
136
+ baseline_mm: [number, number, number];
137
+ unit_factor?: number;
138
+ file_units: Units;
139
+ editable: boolean;
140
+ dimensions_mm: [number, number, number];
141
+ }
142
+ export interface CameraBookmark {
143
+ name: string;
144
+ camera: CameraState;
145
+ }
146
+ export interface ModelMeasurements {
147
+ area_mm2: number;
148
+ volume_mm3: number | null;
149
+ volume_valid: boolean;
150
+ volume_reason: string;
151
+ }
101
152
  export interface ModelOptions extends Transform {
153
+ /** Display label; filename remains the source reference for VSJ. */
154
+ display_name?: string;
155
+ size_state?: Omit<ModelSize, "dimensions_mm">;
102
156
  id?: number;
103
157
  filename?: string;
104
158
  /** Retrieve a public URL through the explicitly configured same-origin relay. */
@@ -116,6 +170,7 @@ export interface ModelOptions extends Transform {
116
170
  view_edges?: boolean;
117
171
  units?: Units;
118
172
  animation?: Animation | null;
173
+ animation_state?: SavedAnimationState | null;
119
174
  }
120
175
  export type ModelClick = (
121
176
  id: number | null,
@@ -173,6 +228,15 @@ export interface ViewerOptions {
173
228
  on_model_drop?: (filename: string) => void;
174
229
  on_model_mouseclick?: ModelClick;
175
230
  on_model_mousedown?: ModelClick;
231
+ animation_state_callback?: (
232
+ id: number,
233
+ state: AnimationPlaybackState,
234
+ reason: AnimationStateReason,
235
+ ) => void;
236
+ animation_complete_callback?: (
237
+ id: number,
238
+ state: AnimationPlaybackState,
239
+ ) => void;
176
240
  }
177
241
  export interface ModelInfo {
178
242
  name: string;
@@ -204,6 +268,8 @@ export interface Scene {
204
268
  auto_rotate: boolean;
205
269
  mouse_zoom: boolean;
206
270
  auto_resize: boolean;
271
+ camera_bookmarks?: CameraBookmark[];
272
+ display_units?: Units;
207
273
  center_models: boolean;
208
274
  grid?: boolean;
209
275
  infinite_grid?: { spacing: number; height: number };
@@ -281,6 +347,31 @@ export class StlViewer {
281
347
  set_camera_state(state: Partial<CameraState>): void;
282
348
  set_camera(x?: number, y?: number, z?: number): void;
283
349
  get_model_info(id: number): ModelInfo | null;
350
+ get_model_info(
351
+ id: number,
352
+ options: { measurements: false },
353
+ ): (Omit<ModelInfo, "area" | "volume"> & { area: null; volume: null }) | null;
354
+ get_model_size(id: number): ModelSize;
355
+ /** Multiplicative XYZ factors about the world-space center. Throws on invalid input. */
356
+ resize_model(id: number, factors: [number, number, number]): ModelSize;
357
+ set_file_units(id: number, units: Units): ModelSize;
358
+ reset_model_size(id: number): ModelSize;
359
+ duplicate_model(id: number): number;
360
+ display_units: Units;
361
+ set_display_units(units: Units): void;
362
+ set_camera_view(
363
+ name: "front" | "back" | "left" | "right" | "top" | "bottom" | "isometric",
364
+ ): void;
365
+ get_camera_bookmarks(): CameraBookmark[];
366
+ set_camera_bookmarks(bookmarks: CameraBookmark[]): void;
367
+ measure_model(
368
+ id: number,
369
+ options?: {
370
+ signal?: AbortSignal;
371
+ max_time_ms?: number;
372
+ on_progress?: (progress: { phase: string; elapsed_ms: number }) => void;
373
+ },
374
+ ): Promise<ModelMeasurements>;
284
375
  get_model_data(id: number): GeometryData | null;
285
376
  get_model_mesh(id: number): unknown;
286
377
  get_stl_bin(id: number): ArrayBuffer | null;
@@ -328,11 +419,17 @@ export class StlViewer {
328
419
  download_vsb(filename?: string): Promise<void | null>;
329
420
  load_vsb(source: string | File | Blob): void;
330
421
  animate_model(id: number, animation: Animation | null): void;
422
+ pause_model_animation(id: number): void;
423
+ resume_model_animation(id: number): void;
424
+ get_model_animation_state(id: number): AnimationPlaybackState | null;
331
425
  get_image_blob(type?: string): Promise<Blob>;
332
426
  }
333
427
  export default StlViewer;
334
428
 
335
429
  export interface ViewstlAppOptions {
430
+ /** Composed with the app's own playback controls and reduced-motion policy. */
431
+ animation_state_callback?: ViewerOptions["animation_state_callback"];
432
+ animation_complete_callback?: ViewerOptions["animation_complete_callback"];
336
433
  url_import_endpoint?: string;
337
434
  worker_url?: string | URL;
338
435
  worker_factory?: () => Worker;
@@ -357,6 +454,7 @@ export interface ViewstlAppState {
357
454
  /** Euler XYZ angles in degrees, about the model's own center. */
358
455
  rotation: Vector3;
359
456
  color: string | null;
457
+ animation: AnimationPlaybackState;
360
458
  }>;
361
459
  }
362
460
  export interface ViewstlApp {