@giszhc/three-model-viewer 1.0.0 → 1.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.
@@ -5,29 +5,78 @@ export interface ManagedMeshMaterial {
5
5
  originalMaterial: THREE.Material | THREE.Material[];
6
6
  plainMaterial: THREE.Material;
7
7
  }
8
+ export interface ModelLoaderOptions {
9
+ dracoDecoderPath?: string;
10
+ ktx2TranscoderPath?: string;
11
+ renderer?: THREE.WebGLRenderer;
12
+ }
8
13
  export declare class ModelLoader {
9
14
  private currentZipContent;
15
+ private customBlobUrls;
10
16
  private managedMaterials;
11
17
  private isTextureEnabled;
12
18
  private displayStyle;
13
19
  private plainColor;
14
20
  private currentClippingPlanes;
21
+ private dracoDecoderPath;
22
+ private dracoLoader;
23
+ private ktx2TranscoderPath;
24
+ private ktx2Loader;
25
+ private renderer;
26
+ constructor(optionsOrDracoPath?: string | ModelLoaderOptions, renderer?: THREE.WebGLRenderer);
27
+ /**
28
+ * Set WebGLRenderer instance to allow KTX2Loader to query supported compressed texture formats
29
+ */
30
+ setRenderer(renderer: THREE.WebGLRenderer): void;
31
+ /**
32
+ * Set custom Draco decoder directory URL
33
+ */
34
+ setDracoDecoderPath(path: string): void;
35
+ /**
36
+ * Set custom KTX2 / Basis transcoder directory URL
37
+ */
38
+ setKTX2TranscoderPath(path: string): void;
39
+ /**
40
+ * Internal helper to create or retrieve cached DRACOLoader
41
+ */
42
+ private getDracoLoader;
43
+ /**
44
+ * Internal helper to create or retrieve cached KTX2Loader
45
+ */
46
+ private getKTX2Loader;
15
47
  /**
16
- * Load model from a ZIP file containing .obj, .mtl, and image textures
48
+ * Internal helper to construct configured GLTFLoader
49
+ */
50
+ private createGLTFLoader;
51
+ /**
52
+ * Load model from a ZIP file containing .glb, .gltf, or .obj + textures
17
53
  */
18
54
  loadZip(source: File | Blob | ArrayBuffer | string, onProgress?: (percent: number, message: string) => void): Promise<ModelLoadResult>;
55
+ /**
56
+ * Load GLTF / GLB model from URL or ArrayBuffer
57
+ */
58
+ loadGLTF(source: string | ArrayBuffer, loadingManager?: THREE.LoadingManager, onProgress?: (percent: number, message: string) => void): Promise<ModelLoadResult>;
59
+ /**
60
+ * Load standalone GLB binary model from File, Blob, ArrayBuffer, or online URL
61
+ */
62
+ loadGLB(source: string | ArrayBuffer | Blob | File, onProgress?: (percent: number, message: string) => void): Promise<ModelLoadResult>;
19
63
  /**
20
64
  * Load model directly from OBJ and optional MTL URLs
21
65
  */
22
- loadOBJ(objUrl: string, mtlUrl?: string, onProgress?: (percent: number, message: string) => void): Promise<ModelLoadResult>;
66
+ loadOBJ(objUrl: string, mtlUrl?: string, loadingManager?: THREE.LoadingManager, onProgress?: (percent: number, message: string) => void): Promise<ModelLoadResult>;
67
+ /**
68
+ * Intelligently load multiple user-selected files or drag-dropped files
69
+ * (Supports .zip, .glb, .gltf + companion .bin / textures, .obj + .mtl / textures)
70
+ */
71
+ loadFiles(fileList: FileList | File[], onProgress?: (percent: number, message: string) => void): Promise<ModelLoadResult>;
23
72
  /**
24
73
  * Post-process loaded model:
25
74
  * - Build BVH acceleration trees on all meshes
26
75
  * - Count vertices & faces
27
76
  * - Cache original materials and prepare clay/white-model materials
28
- * - Calculate bounding box and center
77
+ * - Center model without breaking hierarchy/animations via a root group
29
78
  */
30
- postProcessModel(group: THREE.Group): ModelLoadResult;
79
+ postProcessModel(group: THREE.Group, animations?: THREE.AnimationClip[], format?: 'obj' | 'gltf' | 'glb' | 'sample'): ModelLoadResult;
31
80
  /**
32
81
  * Internal helper to apply display style (solid/wireframe) to a managed mesh
33
82
  */
@@ -66,4 +115,8 @@ export declare class ModelLoader {
66
115
  * Clean up resources
67
116
  */
68
117
  cleanup(): void;
118
+ /**
119
+ * Complete destruction of loader and transcoders
120
+ */
121
+ destroy(): void;
69
122
  }
@@ -1,9 +1,12 @@
1
1
  import * as THREE from 'three';
2
2
  export interface ExtractedZipContent {
3
- objContent: string | ArrayBuffer;
4
- objFileName: string;
5
- mtlContent: string | null;
6
- mtlFileName: string | null;
3
+ format: 'obj' | 'gltf' | 'glb';
4
+ objContent?: string | ArrayBuffer;
5
+ objFileName?: string;
6
+ mtlContent?: string | null;
7
+ mtlFileName?: string | null;
8
+ gltfContent?: string | ArrayBuffer;
9
+ gltfFileName?: string;
7
10
  blobUrls: Map<string, string>;
8
11
  loadingManager: THREE.LoadingManager;
9
12
  dispose: () => void;
@@ -22,6 +22,8 @@ export interface ViewerOptions {
22
22
  showBoundingBox?: boolean;
23
23
  unit?: string;
24
24
  controlsType?: 'trackball' | 'orbit';
25
+ dracoDecoderPath?: string;
26
+ ktx2TranscoderPath?: string;
25
27
  }
26
28
  export interface ModelLoadResult {
27
29
  model: THREE.Group;
@@ -30,6 +32,8 @@ export interface ModelLoadResult {
30
32
  center: THREE.Vector3;
31
33
  vertexCount: number;
32
34
  faceCount: number;
35
+ animations?: THREE.AnimationClip[];
36
+ format?: 'obj' | 'gltf' | 'glb' | 'sample';
33
37
  }
34
38
  export interface MeasurementResult {
35
39
  id: string;
@@ -118,4 +122,8 @@ export type ViewerEvents = {
118
122
  'axislock:change': (lockedAxis: RotationLockAxis) => void;
119
123
  'style:change': (style: ModelDisplayStyle) => void;
120
124
  'pointsize:change'?: (size: number) => void;
125
+ 'animation:play'?: (name: string) => void;
126
+ 'animation:pause'?: () => void;
127
+ 'animation:stop'?: () => void;
128
+ 'animation:speed'?: (speed: number) => void;
121
129
  };
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@giszhc/three-model-viewer",
3
- "version": "1.0.0",
4
- "description": "A modern, professional 3D model inspector and viewer SDK for Web applications. Features OBJ/MTL/ZIP loading, 3D measurements, dynamic dimensional bounding box, plane slicing, and high-res export.",
3
+ "version": "1.1.0",
4
+ "description": "A modern, professional 3D model inspector and viewer SDK for Web applications. Features GLTF/GLB/OBJ/ZIP loading, animation playback, 3D measurements, dynamic dimensional bounding box, plane slicing, and high-res export.",
5
5
  "main": "./dist/index.cjs",
6
6
  "module": "./dist/index.js",
7
7
  "types": "./dist/index.d.ts",
@@ -21,10 +21,18 @@
21
21
  "README.md",
22
22
  "LICENSE"
23
23
  ],
24
+ "publishConfig": {
25
+ "access": "public",
26
+ "registry": "https://registry.npmjs.org/"
27
+ },
24
28
  "keywords": [
25
29
  "three",
26
30
  "threejs",
27
31
  "model-viewer",
32
+ "gltf",
33
+ "glb",
34
+ "draco",
35
+ "animation",
28
36
  "obj",
29
37
  "mtl",
30
38
  "zip",