@chocozhang/three-model-render 1.0.3 → 1.0.4
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/README.md +93 -96
- package/dist/camera/index.d.ts +59 -36
- package/dist/camera/index.js +77 -57
- package/dist/camera/index.js.map +1 -1
- package/dist/camera/index.mjs +77 -57
- package/dist/camera/index.mjs.map +1 -1
- package/dist/core/index.d.ts +60 -27
- package/dist/core/index.js +124 -95
- package/dist/core/index.js.map +1 -1
- package/dist/core/index.mjs +124 -95
- package/dist/core/index.mjs.map +1 -1
- package/dist/effect/index.d.ts +47 -134
- package/dist/effect/index.js +109 -65
- package/dist/effect/index.js.map +1 -1
- package/dist/effect/index.mjs +109 -65
- package/dist/effect/index.mjs.map +1 -1
- package/dist/index.d.ts +397 -341
- package/dist/index.js +651 -472
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +651 -472
- package/dist/index.mjs.map +1 -1
- package/dist/interaction/index.d.ts +85 -52
- package/dist/interaction/index.js +161 -133
- package/dist/interaction/index.js.map +1 -1
- package/dist/interaction/index.mjs +161 -133
- package/dist/interaction/index.mjs.map +1 -1
- package/dist/loader/index.d.ts +89 -56
- package/dist/loader/index.js +115 -76
- package/dist/loader/index.js.map +1 -1
- package/dist/loader/index.mjs +115 -76
- package/dist/loader/index.mjs.map +1 -1
- package/dist/setup/index.d.ts +28 -18
- package/dist/setup/index.js +33 -24
- package/dist/setup/index.js.map +1 -1
- package/dist/setup/index.mjs +33 -24
- package/dist/setup/index.mjs.map +1 -1
- package/dist/ui/index.d.ts +18 -7
- package/dist/ui/index.js +32 -22
- package/dist/ui/index.js.map +1 -1
- package/dist/ui/index.mjs +32 -22
- package/dist/ui/index.mjs.map +1 -1
- package/package.json +2 -2
|
@@ -2,7 +2,18 @@ import * as THREE from 'three';
|
|
|
2
2
|
import { OutlinePass } from 'three/examples/jsm/postprocessing/OutlinePass';
|
|
3
3
|
|
|
4
4
|
/**
|
|
5
|
-
*
|
|
5
|
+
* @file clickHandler.ts
|
|
6
|
+
* @description
|
|
7
|
+
* Tool for handling model clicks and highlighting (OutlinePass version).
|
|
8
|
+
*
|
|
9
|
+
* @best-practice
|
|
10
|
+
* - Use `createModelClickHandler` to setup interaction.
|
|
11
|
+
* - Handles debouncing and click threshold automatically.
|
|
12
|
+
* - Cleanup using the returned dispose function.
|
|
13
|
+
*/
|
|
14
|
+
|
|
15
|
+
/**
|
|
16
|
+
* Click Handler Options
|
|
6
17
|
*/
|
|
7
18
|
interface ClickHandlerOptions {
|
|
8
19
|
clickThreshold?: number;
|
|
@@ -17,21 +28,21 @@ interface ClickHandlerOptions {
|
|
|
17
28
|
maxThickness?: number;
|
|
18
29
|
}
|
|
19
30
|
/**
|
|
20
|
-
*
|
|
31
|
+
* Create Model Click Highlight Tool (OutlinePass Version) - Optimized
|
|
21
32
|
*
|
|
22
|
-
*
|
|
23
|
-
* -
|
|
24
|
-
* -
|
|
25
|
-
* -
|
|
26
|
-
* -
|
|
33
|
+
* Features:
|
|
34
|
+
* - Uses AbortController to unify event lifecycle management
|
|
35
|
+
* - Supports debounce to avoid frequent triggering
|
|
36
|
+
* - Customizable Raycaster parameters
|
|
37
|
+
* - Dynamically adjusts outline thickness based on camera distance
|
|
27
38
|
*
|
|
28
|
-
* @param camera
|
|
29
|
-
* @param scene
|
|
30
|
-
* @param renderer
|
|
31
|
-
* @param outlinePass
|
|
32
|
-
* @param onClick
|
|
33
|
-
* @param options
|
|
34
|
-
* @returns
|
|
39
|
+
* @param camera Camera
|
|
40
|
+
* @param scene Scene
|
|
41
|
+
* @param renderer Renderer
|
|
42
|
+
* @param outlinePass Initialized OutlinePass
|
|
43
|
+
* @param onClick Click callback
|
|
44
|
+
* @param options Optional configuration
|
|
45
|
+
* @returns Dispose function, used to clean up events and resources
|
|
35
46
|
*/
|
|
36
47
|
declare function createModelClickHandler(camera: THREE.Camera, scene: THREE.Scene, renderer: THREE.WebGLRenderer, outlinePass: OutlinePass, onClick: (object: THREE.Object3D | null, info?: {
|
|
37
48
|
name?: string;
|
|
@@ -39,17 +50,28 @@ declare function createModelClickHandler(camera: THREE.Camera, scene: THREE.Scen
|
|
|
39
50
|
uuid?: string;
|
|
40
51
|
}) => void, options?: ClickHandlerOptions): () => void;
|
|
41
52
|
|
|
53
|
+
/**
|
|
54
|
+
* @file arrowGuide.ts
|
|
55
|
+
* @description
|
|
56
|
+
* Arrow guide effect tool, supports highlighting models and fading other objects.
|
|
57
|
+
*
|
|
58
|
+
* @best-practice
|
|
59
|
+
* - Use `highlight` to focus on specific models.
|
|
60
|
+
* - Automatically manages materials and memory using WeakMap.
|
|
61
|
+
* - Call `dispose` when component unmounts.
|
|
62
|
+
*/
|
|
63
|
+
|
|
42
64
|
type FilterFn = (obj: THREE.Object3D) => boolean;
|
|
43
65
|
/**
|
|
44
|
-
* ArrowGuide -
|
|
45
|
-
*
|
|
66
|
+
* ArrowGuide - Optimized Version
|
|
67
|
+
* Arrow guide effect tool, supports highlighting models and fading other objects.
|
|
46
68
|
*
|
|
47
|
-
*
|
|
48
|
-
* -
|
|
49
|
-
* -
|
|
50
|
-
* -
|
|
51
|
-
* -
|
|
52
|
-
* -
|
|
69
|
+
* Features:
|
|
70
|
+
* - Uses WeakMap for automatic material recycling, preventing memory leaks
|
|
71
|
+
* - Uses AbortController to manage event lifecycle
|
|
72
|
+
* - Adds material reuse mechanism to reuse materials
|
|
73
|
+
* - Improved dispose logic ensuring complete resource release
|
|
74
|
+
* - Adds error handling and boundary checks
|
|
53
75
|
*/
|
|
54
76
|
declare class ArrowGuide {
|
|
55
77
|
private renderer;
|
|
@@ -78,44 +100,55 @@ declare class ArrowGuide {
|
|
|
78
100
|
private makeFadedClone;
|
|
79
101
|
private createFadedMaterialFrom;
|
|
80
102
|
/**
|
|
81
|
-
*
|
|
103
|
+
* Set Arrow Mesh
|
|
82
104
|
*/
|
|
83
105
|
setArrowMesh(mesh: THREE.Mesh): void;
|
|
84
106
|
/**
|
|
85
|
-
*
|
|
107
|
+
* Highlight specified models
|
|
86
108
|
*/
|
|
87
109
|
highlight(models: THREE.Object3D[]): void;
|
|
88
110
|
private applyHighlight;
|
|
89
111
|
restore(): void;
|
|
90
112
|
/**
|
|
91
|
-
*
|
|
113
|
+
* Animation update (called every frame)
|
|
92
114
|
*/
|
|
93
115
|
animate(): void;
|
|
94
116
|
/**
|
|
95
|
-
*
|
|
117
|
+
* Initialize event listeners
|
|
96
118
|
*/
|
|
97
119
|
private initEvents;
|
|
98
120
|
/**
|
|
99
|
-
*
|
|
121
|
+
* Dispose all resources
|
|
100
122
|
*/
|
|
101
123
|
dispose(): void;
|
|
102
124
|
}
|
|
103
125
|
|
|
126
|
+
/**
|
|
127
|
+
* @file liquidFiller.ts
|
|
128
|
+
* @description
|
|
129
|
+
* Liquid filling effect for single or multiple models using local clipping planes.
|
|
130
|
+
*
|
|
131
|
+
* @best-practice
|
|
132
|
+
* - Use `fillTo` to animate liquid level.
|
|
133
|
+
* - Supports multiple independent liquid levels.
|
|
134
|
+
* - Call `dispose` to clean up resources and event listeners.
|
|
135
|
+
*/
|
|
136
|
+
|
|
104
137
|
interface LiquidFillerOptions {
|
|
105
138
|
color?: number;
|
|
106
139
|
opacity?: number;
|
|
107
140
|
speed?: number;
|
|
108
141
|
}
|
|
109
142
|
/**
|
|
110
|
-
* LiquidFillerGroup -
|
|
111
|
-
*
|
|
143
|
+
* LiquidFillerGroup - Optimized
|
|
144
|
+
* Supports single or multi-model liquid level animation with independent color control.
|
|
112
145
|
*
|
|
113
|
-
*
|
|
114
|
-
* -
|
|
115
|
-
* -
|
|
116
|
-
* -
|
|
117
|
-
* -
|
|
118
|
-
* -
|
|
146
|
+
* Features:
|
|
147
|
+
* - Uses renderer.domElement instead of window events
|
|
148
|
+
* - Uses AbortController to manage event lifecycle
|
|
149
|
+
* - Adds error handling and boundary checks
|
|
150
|
+
* - Optimized animation management to prevent memory leaks
|
|
151
|
+
* - Comprehensive resource disposal logic
|
|
119
152
|
*/
|
|
120
153
|
declare class LiquidFillerGroup {
|
|
121
154
|
private items;
|
|
@@ -127,32 +160,32 @@ declare class LiquidFillerGroup {
|
|
|
127
160
|
private clickThreshold;
|
|
128
161
|
private abortController;
|
|
129
162
|
/**
|
|
130
|
-
*
|
|
131
|
-
* @param models
|
|
132
|
-
* @param scene
|
|
133
|
-
* @param camera
|
|
134
|
-
* @param renderer
|
|
135
|
-
* @param defaultOptions
|
|
136
|
-
* @param clickThreshold
|
|
163
|
+
* Constructor
|
|
164
|
+
* @param models Single or multiple THREE.Object3D
|
|
165
|
+
* @param scene Scene
|
|
166
|
+
* @param camera Camera
|
|
167
|
+
* @param renderer Renderer
|
|
168
|
+
* @param defaultOptions Default liquid options
|
|
169
|
+
* @param clickThreshold Click threshold in pixels
|
|
137
170
|
*/
|
|
138
171
|
constructor(models: THREE.Object3D | THREE.Object3D[], scene: THREE.Scene, camera: THREE.Camera, renderer: THREE.WebGLRenderer, defaultOptions?: LiquidFillerOptions, clickThreshold?: number);
|
|
139
|
-
/** pointerdown
|
|
172
|
+
/** pointerdown record position */
|
|
140
173
|
private handlePointerDown;
|
|
141
|
-
/** pointerup
|
|
174
|
+
/** pointerup check click blank, restore original material */
|
|
142
175
|
private handlePointerUp;
|
|
143
176
|
/**
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
177
|
+
* Set liquid level
|
|
178
|
+
* @param models Single model or array of models
|
|
179
|
+
* @param percent Liquid level percentage 0~1
|
|
180
|
+
*/
|
|
148
181
|
fillTo(models: THREE.Object3D | THREE.Object3D[], percent: number): void;
|
|
149
|
-
/**
|
|
182
|
+
/** Set multiple model levels, percentList corresponds to items order */
|
|
150
183
|
fillToAll(percentList: number[]): void;
|
|
151
|
-
/**
|
|
184
|
+
/** Restore single model original material and remove liquid */
|
|
152
185
|
restore(model: THREE.Object3D): void;
|
|
153
|
-
/**
|
|
186
|
+
/** Restore all models */
|
|
154
187
|
restoreAll(): void;
|
|
155
|
-
/**
|
|
188
|
+
/** Dispose method, release events and resources */
|
|
156
189
|
dispose(): void;
|
|
157
190
|
}
|
|
158
191
|
|