@chocozhang/three-model-render 1.0.2 → 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 +149 -530
- 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 +1 -1
package/dist/camera/index.d.ts
CHANGED
|
@@ -1,6 +1,18 @@
|
|
|
1
1
|
import * as THREE from 'three';
|
|
2
2
|
import { OrbitControls } from 'three/examples/jsm/controls/OrbitControls';
|
|
3
3
|
|
|
4
|
+
/**
|
|
5
|
+
* @file followModels.ts
|
|
6
|
+
* @description
|
|
7
|
+
* Camera utility to automatically follow and focus on 3D models.
|
|
8
|
+
* It smoothly moves the camera to an optimal viewing position relative to the target object(s).
|
|
9
|
+
*
|
|
10
|
+
* @best-practice
|
|
11
|
+
* - Use `followModels` to focus on a newly selected object.
|
|
12
|
+
* - Call `cancelFollow` before starting a new manual camera interaction if needed.
|
|
13
|
+
* - Adjust `padding` to control how tight the camera framing is.
|
|
14
|
+
*/
|
|
15
|
+
|
|
4
16
|
interface FollowOptions {
|
|
5
17
|
duration?: number;
|
|
6
18
|
padding?: number;
|
|
@@ -16,72 +28,83 @@ interface FollowOptions {
|
|
|
16
28
|
onProgress?: (progress: number) => void;
|
|
17
29
|
}
|
|
18
30
|
/**
|
|
19
|
-
*
|
|
31
|
+
* Recommended camera angles for quick selection of common views
|
|
20
32
|
*/
|
|
21
33
|
declare const FOLLOW_ANGLES: {
|
|
22
|
-
/**
|
|
34
|
+
/** Isometric view (default) - suitable for architecture, mechanical equipment */
|
|
23
35
|
readonly ISOMETRIC: {
|
|
24
36
|
readonly azimuth: number;
|
|
25
37
|
readonly elevation: number;
|
|
26
38
|
};
|
|
27
|
-
/**
|
|
39
|
+
/** Front view - suitable for frontal display, UI alignment */
|
|
28
40
|
readonly FRONT: {
|
|
29
41
|
readonly azimuth: 0;
|
|
30
42
|
readonly elevation: 0;
|
|
31
43
|
};
|
|
32
|
-
/**
|
|
44
|
+
/** Right view - suitable for mechanical sections, side inspection */
|
|
33
45
|
readonly RIGHT: {
|
|
34
46
|
readonly azimuth: number;
|
|
35
47
|
readonly elevation: 0;
|
|
36
48
|
};
|
|
37
|
-
/**
|
|
49
|
+
/** Left view */
|
|
38
50
|
readonly LEFT: {
|
|
39
51
|
readonly azimuth: number;
|
|
40
52
|
readonly elevation: 0;
|
|
41
53
|
};
|
|
42
|
-
/**
|
|
54
|
+
/** Back view */
|
|
43
55
|
readonly BACK: {
|
|
44
56
|
readonly azimuth: number;
|
|
45
57
|
readonly elevation: 0;
|
|
46
58
|
};
|
|
47
|
-
/**
|
|
59
|
+
/** Top view - suitable for maps, layout display */
|
|
48
60
|
readonly TOP: {
|
|
49
61
|
readonly azimuth: 0;
|
|
50
62
|
readonly elevation: number;
|
|
51
63
|
};
|
|
52
|
-
/**
|
|
64
|
+
/** Low angle view - suitable for vehicles, characters near the ground */
|
|
53
65
|
readonly LOW_ANGLE: {
|
|
54
66
|
readonly azimuth: number;
|
|
55
67
|
readonly elevation: number;
|
|
56
68
|
};
|
|
57
|
-
/**
|
|
69
|
+
/** High angle view - suitable for bird's eye view, panoramic browsing */
|
|
58
70
|
readonly HIGH_ANGLE: {
|
|
59
71
|
readonly azimuth: number;
|
|
60
72
|
readonly elevation: number;
|
|
61
73
|
};
|
|
62
74
|
};
|
|
63
75
|
/**
|
|
64
|
-
*
|
|
76
|
+
* Automatically moves the camera to a diagonal position relative to the target,
|
|
77
|
+
* ensuring the target is within the field of view (smooth transition).
|
|
65
78
|
*
|
|
66
|
-
*
|
|
67
|
-
* -
|
|
68
|
-
* -
|
|
69
|
-
* -
|
|
70
|
-
* - WeakMap
|
|
71
|
-
* -
|
|
79
|
+
* Features:
|
|
80
|
+
* - Supports multiple easing functions
|
|
81
|
+
* - Adds progress callback
|
|
82
|
+
* - Supports animation cancellation
|
|
83
|
+
* - Uses WeakMap to track and prevent memory leaks
|
|
84
|
+
* - Robust error handling
|
|
72
85
|
*/
|
|
73
86
|
declare function followModels(camera: THREE.Camera, targets: THREE.Object3D | THREE.Object3D[] | null | undefined, options?: FollowOptions): Promise<void>;
|
|
74
87
|
/**
|
|
75
|
-
*
|
|
88
|
+
* Cancel the camera follow animation
|
|
76
89
|
*/
|
|
77
90
|
declare function cancelFollow(camera: THREE.Camera): void;
|
|
78
91
|
|
|
79
92
|
/**
|
|
80
|
-
*
|
|
93
|
+
* @file setView.ts
|
|
94
|
+
* @description
|
|
95
|
+
* Utility to smoothly transition the camera to preset views (Front, Back, Top, Isometric, etc.).
|
|
96
|
+
*
|
|
97
|
+
* @best-practice
|
|
98
|
+
* - Use `setView` for UI buttons that switch camera angles.
|
|
99
|
+
* - Leverage `ViewPresets` for readable code when using standard views.
|
|
100
|
+
*/
|
|
101
|
+
|
|
102
|
+
/**
|
|
103
|
+
* View types
|
|
81
104
|
*/
|
|
82
105
|
type ViewPosition = 'front' | 'back' | 'left' | 'right' | 'top' | 'bottom' | 'iso';
|
|
83
106
|
/**
|
|
84
|
-
*
|
|
107
|
+
* View configuration options
|
|
85
108
|
*/
|
|
86
109
|
interface SetViewOptions {
|
|
87
110
|
distanceFactor?: number;
|
|
@@ -90,41 +113,41 @@ interface SetViewOptions {
|
|
|
90
113
|
onProgress?: (progress: number) => void;
|
|
91
114
|
}
|
|
92
115
|
/**
|
|
93
|
-
*
|
|
116
|
+
* Smoothly switches the camera to the optimal angle for the model.
|
|
94
117
|
*
|
|
95
|
-
*
|
|
96
|
-
* -
|
|
97
|
-
* -
|
|
98
|
-
* -
|
|
99
|
-
* -
|
|
100
|
-
* -
|
|
118
|
+
* Features:
|
|
119
|
+
* - Reuses followModels logic to avoid code duplication
|
|
120
|
+
* - Supports more angles
|
|
121
|
+
* - Enhanced configuration options
|
|
122
|
+
* - Returns Promise to support chaining
|
|
123
|
+
* - Supports animation cancellation
|
|
101
124
|
*
|
|
102
|
-
* @param camera THREE.PerspectiveCamera
|
|
103
|
-
* @param controls OrbitControls
|
|
104
|
-
* @param targetObj THREE.Object3D
|
|
105
|
-
* @param position
|
|
106
|
-
* @param options
|
|
125
|
+
* @param camera THREE.PerspectiveCamera instance
|
|
126
|
+
* @param controls OrbitControls instance
|
|
127
|
+
* @param targetObj THREE.Object3D model object
|
|
128
|
+
* @param position View position
|
|
129
|
+
* @param options Configuration options
|
|
107
130
|
* @returns Promise<void>
|
|
108
131
|
*/
|
|
109
132
|
declare function setView(camera: THREE.PerspectiveCamera, controls: OrbitControls, targetObj: THREE.Object3D, position?: ViewPosition, options?: SetViewOptions): Promise<void>;
|
|
110
133
|
/**
|
|
111
|
-
*
|
|
134
|
+
* Cancel view switch animation
|
|
112
135
|
*/
|
|
113
136
|
declare function cancelSetView(camera: THREE.PerspectiveCamera): void;
|
|
114
137
|
/**
|
|
115
|
-
*
|
|
138
|
+
* Preset view shortcut methods
|
|
116
139
|
*/
|
|
117
140
|
declare const ViewPresets: {
|
|
118
141
|
/**
|
|
119
|
-
*
|
|
142
|
+
* Front View
|
|
120
143
|
*/
|
|
121
144
|
front: (camera: THREE.PerspectiveCamera, controls: OrbitControls, target: THREE.Object3D, options?: SetViewOptions) => Promise<void>;
|
|
122
145
|
/**
|
|
123
|
-
*
|
|
146
|
+
* Isometric View
|
|
124
147
|
*/
|
|
125
148
|
isometric: (camera: THREE.PerspectiveCamera, controls: OrbitControls, target: THREE.Object3D, options?: SetViewOptions) => Promise<void>;
|
|
126
149
|
/**
|
|
127
|
-
*
|
|
150
|
+
* Top View
|
|
128
151
|
*/
|
|
129
152
|
top: (camera: THREE.PerspectiveCamera, controls: OrbitControls, target: THREE.Object3D, options?: SetViewOptions) => Promise<void>;
|
|
130
153
|
};
|
package/dist/camera/index.js
CHANGED
|
@@ -21,32 +21,42 @@ function _interopNamespaceDefault(e) {
|
|
|
21
21
|
|
|
22
22
|
var THREE__namespace = /*#__PURE__*/_interopNamespaceDefault(THREE);
|
|
23
23
|
|
|
24
|
-
|
|
25
|
-
|
|
24
|
+
/**
|
|
25
|
+
* @file followModels.ts
|
|
26
|
+
* @description
|
|
27
|
+
* Camera utility to automatically follow and focus on 3D models.
|
|
28
|
+
* It smoothly moves the camera to an optimal viewing position relative to the target object(s).
|
|
29
|
+
*
|
|
30
|
+
* @best-practice
|
|
31
|
+
* - Use `followModels` to focus on a newly selected object.
|
|
32
|
+
* - Call `cancelFollow` before starting a new manual camera interaction if needed.
|
|
33
|
+
* - Adjust `padding` to control how tight the camera framing is.
|
|
34
|
+
*/
|
|
35
|
+
// Use WeakMap to track animations, allowing for cancellation
|
|
26
36
|
const _animationMap = new WeakMap();
|
|
27
37
|
/**
|
|
28
|
-
*
|
|
38
|
+
* Recommended camera angles for quick selection of common views
|
|
29
39
|
*/
|
|
30
40
|
const FOLLOW_ANGLES = {
|
|
31
|
-
/**
|
|
41
|
+
/** Isometric view (default) - suitable for architecture, mechanical equipment */
|
|
32
42
|
ISOMETRIC: { azimuth: Math.PI / 4, elevation: Math.PI / 4 },
|
|
33
|
-
/**
|
|
43
|
+
/** Front view - suitable for frontal display, UI alignment */
|
|
34
44
|
FRONT: { azimuth: 0, elevation: 0 },
|
|
35
|
-
/**
|
|
45
|
+
/** Right view - suitable for mechanical sections, side inspection */
|
|
36
46
|
RIGHT: { azimuth: Math.PI / 2, elevation: 0 },
|
|
37
|
-
/**
|
|
47
|
+
/** Left view */
|
|
38
48
|
LEFT: { azimuth: -Math.PI / 2, elevation: 0 },
|
|
39
|
-
/**
|
|
49
|
+
/** Back view */
|
|
40
50
|
BACK: { azimuth: Math.PI, elevation: 0 },
|
|
41
|
-
/**
|
|
51
|
+
/** Top view - suitable for maps, layout display */
|
|
42
52
|
TOP: { azimuth: 0, elevation: Math.PI / 2 },
|
|
43
|
-
/**
|
|
53
|
+
/** Low angle view - suitable for vehicles, characters near the ground */
|
|
44
54
|
LOW_ANGLE: { azimuth: Math.PI / 4, elevation: Math.PI / 6 },
|
|
45
|
-
/**
|
|
55
|
+
/** High angle view - suitable for bird's eye view, panoramic browsing */
|
|
46
56
|
HIGH_ANGLE: { azimuth: Math.PI / 4, elevation: Math.PI / 3 }
|
|
47
57
|
};
|
|
48
58
|
/**
|
|
49
|
-
*
|
|
59
|
+
* Collection of easing functions
|
|
50
60
|
*/
|
|
51
61
|
const EASING_FUNCTIONS = {
|
|
52
62
|
linear: (t) => t,
|
|
@@ -55,20 +65,21 @@ const EASING_FUNCTIONS = {
|
|
|
55
65
|
easeIn: (t) => t * t * t
|
|
56
66
|
};
|
|
57
67
|
/**
|
|
58
|
-
*
|
|
68
|
+
* Automatically moves the camera to a diagonal position relative to the target,
|
|
69
|
+
* ensuring the target is within the field of view (smooth transition).
|
|
59
70
|
*
|
|
60
|
-
*
|
|
61
|
-
* -
|
|
62
|
-
* -
|
|
63
|
-
* -
|
|
64
|
-
* - WeakMap
|
|
65
|
-
* -
|
|
71
|
+
* Features:
|
|
72
|
+
* - Supports multiple easing functions
|
|
73
|
+
* - Adds progress callback
|
|
74
|
+
* - Supports animation cancellation
|
|
75
|
+
* - Uses WeakMap to track and prevent memory leaks
|
|
76
|
+
* - Robust error handling
|
|
66
77
|
*/
|
|
67
78
|
function followModels(camera, targets, options = {}) {
|
|
68
79
|
var _a, _b, _c, _d, _e, _f;
|
|
69
|
-
//
|
|
80
|
+
// Cancel previous animation
|
|
70
81
|
cancelFollow(camera);
|
|
71
|
-
//
|
|
82
|
+
// Boundary check
|
|
72
83
|
const arr = [];
|
|
73
84
|
if (!targets)
|
|
74
85
|
return Promise.resolve();
|
|
@@ -77,15 +88,15 @@ function followModels(camera, targets, options = {}) {
|
|
|
77
88
|
else
|
|
78
89
|
arr.push(targets);
|
|
79
90
|
if (arr.length === 0) {
|
|
80
|
-
console.warn('followModels:
|
|
91
|
+
console.warn('followModels: Target object is empty');
|
|
81
92
|
return Promise.resolve();
|
|
82
93
|
}
|
|
83
94
|
try {
|
|
84
95
|
const box = new THREE__namespace.Box3();
|
|
85
96
|
arr.forEach((o) => box.expandByObject(o));
|
|
86
|
-
//
|
|
97
|
+
// Check bounding box validity
|
|
87
98
|
if (!isFinite(box.min.x) || !isFinite(box.max.x)) {
|
|
88
|
-
console.warn('followModels:
|
|
99
|
+
console.warn('followModels: Failed to calculate bounding box');
|
|
89
100
|
return Promise.resolve();
|
|
90
101
|
}
|
|
91
102
|
const sphere = new THREE__namespace.Sphere();
|
|
@@ -101,7 +112,7 @@ function followModels(camera, targets, options = {}) {
|
|
|
101
112
|
const elevation = (_e = options.elevation) !== null && _e !== void 0 ? _e : Math.PI / 4;
|
|
102
113
|
const easing = (_f = options.easing) !== null && _f !== void 0 ? _f : 'easeOut';
|
|
103
114
|
const onProgress = options.onProgress;
|
|
104
|
-
//
|
|
115
|
+
// Get easing function
|
|
105
116
|
const easingFn = EASING_FUNCTIONS[easing] || EASING_FUNCTIONS.easeOut;
|
|
106
117
|
let distance = 10;
|
|
107
118
|
if (camera.isPerspectiveCamera) {
|
|
@@ -121,7 +132,7 @@ function followModels(camera, targets, options = {}) {
|
|
|
121
132
|
else {
|
|
122
133
|
distance = camera.position.distanceTo(center);
|
|
123
134
|
}
|
|
124
|
-
//
|
|
135
|
+
// Calculate direction based on azimuth / elevation
|
|
125
136
|
const hx = Math.sin(azimuth);
|
|
126
137
|
const hz = Math.cos(azimuth);
|
|
127
138
|
const dir = new THREE__namespace.Vector3(hx * Math.cos(elevation), Math.sin(elevation), hz * Math.cos(elevation)).normalize();
|
|
@@ -134,7 +145,6 @@ function followModels(camera, targets, options = {}) {
|
|
|
134
145
|
const startTime = performance.now();
|
|
135
146
|
return new Promise((resolve) => {
|
|
136
147
|
const step = (now) => {
|
|
137
|
-
var _a;
|
|
138
148
|
const elapsed = now - startTime;
|
|
139
149
|
const t = Math.min(1, duration > 0 ? elapsed / duration : 1);
|
|
140
150
|
const k = easingFn(t);
|
|
@@ -148,14 +158,16 @@ function followModels(camera, targets, options = {}) {
|
|
|
148
158
|
else {
|
|
149
159
|
camera.lookAt(endTarget);
|
|
150
160
|
}
|
|
151
|
-
(
|
|
152
|
-
|
|
161
|
+
if (camera.updateProjectionMatrix) {
|
|
162
|
+
camera.updateProjectionMatrix();
|
|
163
|
+
}
|
|
164
|
+
// Call progress callback
|
|
153
165
|
if (onProgress) {
|
|
154
166
|
try {
|
|
155
167
|
onProgress(t);
|
|
156
168
|
}
|
|
157
169
|
catch (error) {
|
|
158
|
-
console.error('followModels:
|
|
170
|
+
console.error('followModels: Progress callback error', error);
|
|
159
171
|
}
|
|
160
172
|
}
|
|
161
173
|
if (t < 1) {
|
|
@@ -181,12 +193,12 @@ function followModels(camera, targets, options = {}) {
|
|
|
181
193
|
});
|
|
182
194
|
}
|
|
183
195
|
catch (error) {
|
|
184
|
-
console.error('followModels:
|
|
196
|
+
console.error('followModels: Execution failed', error);
|
|
185
197
|
return Promise.reject(error);
|
|
186
198
|
}
|
|
187
199
|
}
|
|
188
200
|
/**
|
|
189
|
-
*
|
|
201
|
+
* Cancel the camera follow animation
|
|
190
202
|
*/
|
|
191
203
|
function cancelFollow(camera) {
|
|
192
204
|
const rafId = _animationMap.get(camera);
|
|
@@ -196,42 +208,50 @@ function cancelFollow(camera) {
|
|
|
196
208
|
}
|
|
197
209
|
}
|
|
198
210
|
|
|
199
|
-
// src/utils/setView.ts - 优化版
|
|
200
211
|
/**
|
|
201
|
-
*
|
|
212
|
+
* @file setView.ts
|
|
213
|
+
* @description
|
|
214
|
+
* Utility to smoothly transition the camera to preset views (Front, Back, Top, Isometric, etc.).
|
|
215
|
+
*
|
|
216
|
+
* @best-practice
|
|
217
|
+
* - Use `setView` for UI buttons that switch camera angles.
|
|
218
|
+
* - Leverage `ViewPresets` for readable code when using standard views.
|
|
219
|
+
*/
|
|
220
|
+
/**
|
|
221
|
+
* Smoothly switches the camera to the optimal angle for the model.
|
|
202
222
|
*
|
|
203
|
-
*
|
|
204
|
-
* -
|
|
205
|
-
* -
|
|
206
|
-
* -
|
|
207
|
-
* -
|
|
208
|
-
* -
|
|
223
|
+
* Features:
|
|
224
|
+
* - Reuses followModels logic to avoid code duplication
|
|
225
|
+
* - Supports more angles
|
|
226
|
+
* - Enhanced configuration options
|
|
227
|
+
* - Returns Promise to support chaining
|
|
228
|
+
* - Supports animation cancellation
|
|
209
229
|
*
|
|
210
|
-
* @param camera THREE.PerspectiveCamera
|
|
211
|
-
* @param controls OrbitControls
|
|
212
|
-
* @param targetObj THREE.Object3D
|
|
213
|
-
* @param position
|
|
214
|
-
* @param options
|
|
230
|
+
* @param camera THREE.PerspectiveCamera instance
|
|
231
|
+
* @param controls OrbitControls instance
|
|
232
|
+
* @param targetObj THREE.Object3D model object
|
|
233
|
+
* @param position View position
|
|
234
|
+
* @param options Configuration options
|
|
215
235
|
* @returns Promise<void>
|
|
216
236
|
*/
|
|
217
237
|
function setView(camera, controls, targetObj, position = 'front', options = {}) {
|
|
218
238
|
const { distanceFactor = 0.8, duration = 1000, easing = 'easeInOut', onProgress } = options;
|
|
219
|
-
//
|
|
239
|
+
// Boundary check
|
|
220
240
|
if (!targetObj) {
|
|
221
|
-
console.warn('setView:
|
|
241
|
+
console.warn('setView: Target object is empty');
|
|
222
242
|
return Promise.reject(new Error('Target object is required'));
|
|
223
243
|
}
|
|
224
244
|
try {
|
|
225
|
-
//
|
|
245
|
+
// Calculate bounding box
|
|
226
246
|
const box = new THREE__namespace.Box3().setFromObject(targetObj);
|
|
227
247
|
if (!isFinite(box.min.x)) {
|
|
228
|
-
console.warn('setView:
|
|
248
|
+
console.warn('setView: Failed to calculate bounding box');
|
|
229
249
|
return Promise.reject(new Error('Invalid bounding box'));
|
|
230
250
|
}
|
|
231
251
|
const center = box.getCenter(new THREE__namespace.Vector3());
|
|
232
252
|
const size = box.getSize(new THREE__namespace.Vector3());
|
|
233
253
|
const maxSize = Math.max(size.x, size.y, size.z);
|
|
234
|
-
//
|
|
254
|
+
// Use mapping table for creating view angles
|
|
235
255
|
const viewAngles = {
|
|
236
256
|
'front': { azimuth: 0, elevation: 0 },
|
|
237
257
|
'back': { azimuth: Math.PI, elevation: 0 },
|
|
@@ -242,7 +262,7 @@ function setView(camera, controls, targetObj, position = 'front', options = {})
|
|
|
242
262
|
'iso': { azimuth: Math.PI / 4, elevation: Math.PI / 4 }
|
|
243
263
|
};
|
|
244
264
|
const angle = viewAngles[position] || viewAngles.front;
|
|
245
|
-
//
|
|
265
|
+
// Reuse followModels to avoid code duplication
|
|
246
266
|
return followModels(camera, targetObj, {
|
|
247
267
|
duration,
|
|
248
268
|
padding: distanceFactor,
|
|
@@ -254,30 +274,30 @@ function setView(camera, controls, targetObj, position = 'front', options = {})
|
|
|
254
274
|
});
|
|
255
275
|
}
|
|
256
276
|
catch (error) {
|
|
257
|
-
console.error('setView:
|
|
277
|
+
console.error('setView: Execution failed', error);
|
|
258
278
|
return Promise.reject(error);
|
|
259
279
|
}
|
|
260
280
|
}
|
|
261
281
|
/**
|
|
262
|
-
*
|
|
282
|
+
* Cancel view switch animation
|
|
263
283
|
*/
|
|
264
284
|
function cancelSetView(camera) {
|
|
265
285
|
cancelFollow(camera);
|
|
266
286
|
}
|
|
267
287
|
/**
|
|
268
|
-
*
|
|
288
|
+
* Preset view shortcut methods
|
|
269
289
|
*/
|
|
270
290
|
const ViewPresets = {
|
|
271
291
|
/**
|
|
272
|
-
*
|
|
292
|
+
* Front View
|
|
273
293
|
*/
|
|
274
294
|
front: (camera, controls, target, options) => setView(camera, controls, target, 'front', options),
|
|
275
295
|
/**
|
|
276
|
-
*
|
|
296
|
+
* Isometric View
|
|
277
297
|
*/
|
|
278
298
|
isometric: (camera, controls, target, options) => setView(camera, controls, target, 'iso', options),
|
|
279
299
|
/**
|
|
280
|
-
*
|
|
300
|
+
* Top View
|
|
281
301
|
*/
|
|
282
302
|
top: (camera, controls, target, options) => setView(camera, controls, target, 'top', options)
|
|
283
303
|
};
|
package/dist/camera/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sources":["../../src/camera/followModels.ts","../../src/camera/setView.ts"],"sourcesContent":[null,null],"names":["THREE"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;AAAA;
|
|
1
|
+
{"version":3,"file":"index.js","sources":["../../src/camera/followModels.ts","../../src/camera/setView.ts"],"sourcesContent":[null,null],"names":["THREE"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;AAAA;;;;;;;;;;AAUG;AAIH;AACA,MAAM,aAAa,GAAG,IAAI,OAAO,EAAwB;AAczD;;AAEG;AACI,MAAM,aAAa,GAAG;;AAE3B,IAAA,SAAS,EAAE,EAAE,OAAO,EAAE,IAAI,CAAC,EAAE,GA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