@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
package/README.md
CHANGED
|
@@ -1,231 +1,228 @@
|
|
|
1
1
|
# three-model-render
|
|
2
2
|
|
|
3
|
-
> 🚀
|
|
3
|
+
> 🚀 专业级 Three.js 模型可视化与交互工具库
|
|
4
4
|
|
|
5
|
-
|
|
5
|
+
[English](./README_EN.md) | 中文
|
|
6
6
|
|
|
7
|
-
|
|
7
|
+
一个高性能、TypeScript 优先的工具库,提供 14 个经过优化的实用工具,专注于解决 Three.js 模型可视化与交互中的常见问题。
|
|
8
8
|
|
|
9
|
-
[
|
|
9
|
+
> 🌟 **[在线体验 Demo](https://happycolour.github.io/)**
|
|
10
|
+
|
|
11
|
+
[](https://github.com/HappyColour/three-model-render)
|
|
10
12
|
[](./LICENSE)
|
|
11
13
|
[](https://www.typescriptlang.org/)
|
|
12
14
|
|
|
13
|
-
## ✨
|
|
15
|
+
## ✨ 核心特性
|
|
14
16
|
|
|
15
|
-
- 🎯 **14
|
|
16
|
-
- 📦
|
|
17
|
-
- 🔷 **TypeScript
|
|
18
|
-
- ⚡
|
|
19
|
-
- 🎨
|
|
20
|
-
- 📝
|
|
17
|
+
- 🎯 **14 个高性能工具** - 覆盖从加载、展示到交互的全流程
|
|
18
|
+
- 📦 **支持 Tree-Shaking** - 按需引入,体积更小
|
|
19
|
+
- 🔷 **TypeScript 优先** - 完整的类型定义与智能提示
|
|
20
|
+
- ⚡ **性能优化** - 相比原生实现,闲置 CPU 占用降低 55%,内存占用降低 33%
|
|
21
|
+
- 🎨 **无缝集成** - 完美支持 Vue 3, React 及原生 JavaScript
|
|
22
|
+
- 📝 **完善文档** - 提供最佳实践指引与完整示例
|
|
21
23
|
|
|
22
24
|
---
|
|
23
25
|
|
|
24
|
-
## 📦
|
|
26
|
+
## 📦 安装
|
|
25
27
|
|
|
26
28
|
```bash
|
|
27
|
-
npm install @chocozhang/three-model-render
|
|
28
|
-
#
|
|
29
|
-
|
|
30
|
-
#
|
|
31
|
-
|
|
29
|
+
npm install @chocozhang/three-model-render@latest
|
|
30
|
+
# 或
|
|
31
|
+
pnpm add @chocozhang/three-model-render@latest
|
|
32
|
+
# 或
|
|
33
|
+
yarn add @chocozhang/three-model-render@latest
|
|
32
34
|
```
|
|
33
35
|
|
|
34
|
-
|
|
36
|
+
**对等依赖 (Peer Dependencies):**
|
|
37
|
+
请确保你的项目中安装了 `three`:
|
|
35
38
|
```bash
|
|
36
39
|
npm install three@^0.160.0
|
|
37
40
|
```
|
|
38
41
|
|
|
39
42
|
---
|
|
40
43
|
|
|
41
|
-
## 🚀 Best Practice Workflow
|
|
44
|
+
## 🚀 最佳实践工作流 (Best Practice Workflow)
|
|
42
45
|
|
|
43
|
-
|
|
46
|
+
为了构建专业、高性能的 3D 查看器,我们建议遵循以下集成模式。此工作流经过生产环境验证,能确保最佳的视觉效果与性能表现。
|
|
44
47
|
|
|
45
|
-
### 1.
|
|
46
|
-
|
|
48
|
+
### 1. 基础环境与模型加载
|
|
49
|
+
使用我们优化过的加载器初始化场景。它会自动处理 GLTF/GLB/FBX/OBJ 格式,并内置了 Draco 解码器配置。
|
|
47
50
|
|
|
48
51
|
```typescript
|
|
49
52
|
import { loadModelByUrl } from '@chocozhang/three-model-render';
|
|
50
53
|
|
|
51
|
-
// 1.
|
|
54
|
+
// 1. 初始化基础场景
|
|
52
55
|
const scene = new THREE.Scene();
|
|
53
56
|
const camera = new THREE.PerspectiveCamera(45, window.innerWidth / window.innerHeight, 0.1, 1000);
|
|
54
|
-
const renderer = new THREE.WebGLRenderer();
|
|
57
|
+
const renderer = new THREE.WebGLRenderer({ antialias: true, alpha: true });
|
|
55
58
|
const controls = new OrbitControls(camera, renderer.domElement);
|
|
56
59
|
|
|
57
|
-
// 2.
|
|
60
|
+
// 2. 加载模型 (支持进度回调)
|
|
58
61
|
const model = await loadModelByUrl('path/to/model.glb', {
|
|
59
|
-
manager: new THREE.LoadingManager(() => console.log('
|
|
62
|
+
manager: new THREE.LoadingManager(() => console.log('加载完成'))
|
|
60
63
|
});
|
|
61
64
|
scene.add(model);
|
|
62
65
|
```
|
|
63
66
|
|
|
64
|
-
### 2.
|
|
65
|
-
|
|
67
|
+
### 2. 自动场景配置 (关键步骤)
|
|
68
|
+
根据模型的包围盒大小,自动计算最佳相机距离、近裁剪面(Near)和远裁剪面(Far),并设置影棚级光照。
|
|
66
69
|
|
|
67
70
|
```typescript
|
|
68
71
|
import { autoSetupCameraAndLight } from '@chocozhang/three-model-render/setup';
|
|
69
72
|
|
|
70
|
-
//
|
|
71
|
-
autoSetupCameraAndLight(camera, scene, model
|
|
73
|
+
// 一键配置相机与灯光
|
|
74
|
+
const lightHandles = autoSetupCameraAndLight(camera, scene, model, {
|
|
75
|
+
enableShadows: true, // 开启阴影
|
|
76
|
+
intensity: 1.5 // 光照强度
|
|
77
|
+
});
|
|
72
78
|
```
|
|
73
79
|
|
|
74
|
-
### 3.
|
|
75
|
-
|
|
80
|
+
### 3. 电影级入场动画
|
|
81
|
+
模型加载后,使用平滑的运镜动画将视角聚焦到模型正面。
|
|
76
82
|
|
|
77
83
|
```typescript
|
|
78
84
|
import { followModels, FOLLOW_ANGLES } from '@chocozhang/three-model-render';
|
|
79
85
|
|
|
80
86
|
followModels(camera, model, {
|
|
81
|
-
...FOLLOW_ANGLES.FRONT,
|
|
82
|
-
duration: 1500,
|
|
83
|
-
padding: 0.
|
|
84
|
-
controls,
|
|
85
|
-
easing: 'easeInOut'
|
|
87
|
+
...FOLLOW_ANGLES.FRONT, // 使用预设角度
|
|
88
|
+
duration: 1500, // 动画时长 1.5s
|
|
89
|
+
padding: 0.8, // 留白比例
|
|
90
|
+
controls, // 绑定控制器以同步状态
|
|
91
|
+
easing: 'easeInOut' // 缓动函数
|
|
86
92
|
});
|
|
87
93
|
```
|
|
88
94
|
|
|
89
|
-
### 4.
|
|
90
|
-
|
|
95
|
+
### 4. 后期处理与呼吸光效
|
|
96
|
+
启用高性能后期处理管线和智能呼吸光效(闲置时自动降低帧率以节省电量)。
|
|
91
97
|
|
|
92
98
|
```typescript
|
|
93
99
|
import { initPostProcessing, enableHoverBreath } from '@chocozhang/three-model-render';
|
|
94
100
|
|
|
95
|
-
// 1.
|
|
101
|
+
// 1. 初始化后期处理管理器
|
|
96
102
|
const ppManager = initPostProcessing(renderer, scene, camera, {
|
|
97
|
-
resolutionScale: 0.8, //
|
|
98
|
-
edgeStrength: 4,
|
|
99
|
-
visibleEdgeColor: '#ffee00'
|
|
103
|
+
resolutionScale: 0.8, // 降低分辨率以提升性能
|
|
104
|
+
edgeStrength: 4, // 描边强度
|
|
105
|
+
visibleEdgeColor: '#ffee00' // 描边颜色
|
|
100
106
|
});
|
|
101
107
|
|
|
102
|
-
// 2.
|
|
108
|
+
// 2. 启用智能悬停效果
|
|
103
109
|
const hoverController = enableHoverBreath({
|
|
104
110
|
camera,
|
|
105
111
|
scene,
|
|
106
112
|
renderer,
|
|
107
113
|
outlinePass: ppManager.outlinePass,
|
|
108
|
-
throttleDelay: 16,
|
|
109
|
-
minStrength: 2,
|
|
110
|
-
maxStrength: 8,
|
|
111
|
-
speed: 3
|
|
114
|
+
throttleDelay: 16, // 60fps 节流
|
|
115
|
+
minStrength: 2, // 呼吸最小强度
|
|
116
|
+
maxStrength: 8, // 呼吸最大强度
|
|
117
|
+
speed: 3 // 呼吸速度
|
|
112
118
|
});
|
|
113
119
|
|
|
114
|
-
//
|
|
120
|
+
// 重要: 在动画循环中调用 render
|
|
115
121
|
function animate() {
|
|
116
|
-
|
|
122
|
+
requestAnimationFrame(animate);
|
|
123
|
+
// 使用 composer 替代 renderer.render
|
|
117
124
|
ppManager.composer.render();
|
|
118
125
|
}
|
|
119
126
|
```
|
|
120
127
|
|
|
121
|
-
### 5.
|
|
122
|
-
|
|
128
|
+
### 5. 交互处理系统的集成
|
|
129
|
+
添加智能点击事件,支持自动聚焦到被点击的组件。
|
|
123
130
|
|
|
124
131
|
```typescript
|
|
125
132
|
import { createModelClickHandler } from '@chocozhang/three-model-render';
|
|
126
133
|
|
|
134
|
+
// 创建点击处理器 (返回销毁函数)
|
|
127
135
|
const disposeClickHandler = createModelClickHandler(
|
|
128
136
|
camera,
|
|
129
137
|
scene,
|
|
130
138
|
renderer,
|
|
131
139
|
ppManager.outlinePass,
|
|
132
140
|
(object, info) => {
|
|
133
|
-
console.log('
|
|
141
|
+
console.log('点击了:', info);
|
|
134
142
|
|
|
135
|
-
//
|
|
143
|
+
// 聚焦到被点击的部件
|
|
136
144
|
followModels(camera, object, {
|
|
137
145
|
...FOLLOW_ANGLES.ISOMETRIC,
|
|
138
|
-
duration:
|
|
146
|
+
duration: 1000
|
|
139
147
|
});
|
|
140
148
|
}
|
|
141
149
|
);
|
|
142
150
|
```
|
|
143
151
|
|
|
144
|
-
### 6.
|
|
145
|
-
|
|
152
|
+
### 6. 高级特效:爆炸分解
|
|
153
|
+
无需复杂计算,一行代码实现模型的爆炸分解视图。
|
|
146
154
|
|
|
147
155
|
```typescript
|
|
148
156
|
import { GroupExploder } from '@chocozhang/three-model-render';
|
|
149
157
|
|
|
150
|
-
//
|
|
158
|
+
// 初始化爆炸控制器
|
|
151
159
|
const exploder = new GroupExploder(scene, camera, controls);
|
|
152
160
|
exploder.init();
|
|
153
161
|
|
|
154
|
-
//
|
|
162
|
+
// 设置需要爆炸的网格集合
|
|
155
163
|
exploder.setMeshes(targetMeshes);
|
|
156
164
|
|
|
157
|
-
//
|
|
165
|
+
// 执行爆炸 (Grid 模式)
|
|
158
166
|
exploder.explode({
|
|
159
|
-
mode: 'grid',
|
|
160
|
-
spacing: 2.8,
|
|
161
|
-
dimOthers: { enabled: true, opacity: 0.1 }
|
|
167
|
+
mode: 'grid', // 排列模式: 'ring' | 'spiral' | 'grid' | 'radial'
|
|
168
|
+
spacing: 2.8, // 间距
|
|
169
|
+
dimOthers: { enabled: true, opacity: 0.1 } // 使其他物体透明
|
|
162
170
|
});
|
|
163
171
|
|
|
164
|
-
//
|
|
172
|
+
// 还原
|
|
165
173
|
exploder.restore(600);
|
|
166
174
|
```
|
|
167
175
|
|
|
168
|
-
### 7.
|
|
169
|
-
|
|
176
|
+
### 7. 视角快速切换
|
|
177
|
+
提供标准的工程视角切换功能。
|
|
170
178
|
|
|
171
179
|
```typescript
|
|
172
180
|
import { setView } from '@chocozhang/three-model-render';
|
|
173
181
|
|
|
174
|
-
//
|
|
182
|
+
// 切换到顶视图
|
|
175
183
|
setView(camera, controls, model, 'top');
|
|
176
|
-
|
|
184
|
+
|
|
185
|
+
// 切换到等轴测视图 (ISO)
|
|
177
186
|
setView(camera, controls, model, 'iso');
|
|
178
187
|
```
|
|
179
188
|
|
|
180
189
|
---
|
|
181
190
|
|
|
182
|
-
## 📚 Module Overview
|
|
191
|
+
## 📚 模块总览 (Module Overview)
|
|
183
192
|
|
|
184
193
|
### **Core (`/core`)**
|
|
185
|
-
- `initPostProcessing`:
|
|
186
|
-
- `enableHoverBreath`:
|
|
187
|
-
- `addChildModelLabels`: 3D
|
|
194
|
+
- `initPostProcessing`: 高性能后期处理管理器,内置 OutlinePass。
|
|
195
|
+
- `enableHoverBreath`: 智能呼吸光效,支持性能自适应。
|
|
196
|
+
- `addChildModelLabels`: 3D 标签系统,自动跟随模型运动。
|
|
188
197
|
|
|
189
198
|
### **Camera (`/camera`)**
|
|
190
|
-
- `followModels`:
|
|
191
|
-
- `setView`:
|
|
199
|
+
- `followModels`: 智能相机跟随与聚焦。
|
|
200
|
+
- `setView`: 预设视角切换 (Top, Front, Iso, etc.)。
|
|
192
201
|
|
|
193
202
|
### **Loader (`/loader`)**
|
|
194
|
-
- `loadModelByUrl`:
|
|
195
|
-
- `BlueSky`:
|
|
203
|
+
- `loadModelByUrl`: 统一模型加载器,支持多种格式。
|
|
204
|
+
- `BlueSky`: 快速创建天空盒环境。
|
|
196
205
|
|
|
197
206
|
### **Interaction (`/interaction`)**
|
|
198
|
-
- `createModelClickHandler`:
|
|
207
|
+
- `createModelClickHandler`: 射线检测点击处理器。
|
|
199
208
|
|
|
200
209
|
### **Effect (`/effect`)**
|
|
201
|
-
- `GroupExploder`:
|
|
210
|
+
- `GroupExploder`: 模型爆炸/拆解动画控制器。
|
|
202
211
|
|
|
203
212
|
### **Setup (`/setup`)**
|
|
204
|
-
- `autoSetupCameraAndLight`:
|
|
213
|
+
- `autoSetupCameraAndLight`: 一键自动化场景配置大师。
|
|
205
214
|
|
|
206
215
|
---
|
|
207
216
|
|
|
208
|
-
## 🎨
|
|
209
|
-
|
|
210
|
-
For a complete, deployable HTML/Vue 3 example demonstrating all these features, check `examples/html-best-practice/`.
|
|
217
|
+
## 🎨 示例项目
|
|
211
218
|
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
## ⚙️ TypeScript Support
|
|
219
|
+
我们提供了一个完整的、可部署的示例项目,展示了所有功能的集成方式:
|
|
215
220
|
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
{
|
|
219
|
-
"compilerOptions": {
|
|
220
|
-
"lib": ["ES2015", "DOM"],
|
|
221
|
-
"target": "ES2015",
|
|
222
|
-
"module": "ESNext"
|
|
223
|
-
}
|
|
224
|
-
}
|
|
225
|
-
```
|
|
221
|
+
- 👉 **[Vue 3 示例 (推荐)](https://github.com/HappyColour/three-model-render/tree/main/examples/vue-example)** - 完整的 Vue 3 + TypeScript 集成最佳实践
|
|
222
|
+
- 👉 **[HTML 原生示例](https://github.com/HappyColour/three-model-render/tree/main/examples/html-example)** - 适合原生 JavaScript / jQuery 项目
|
|
226
223
|
|
|
227
224
|
---
|
|
228
225
|
|
|
229
|
-
## 📄
|
|
226
|
+
## 📄 开源协议
|
|
230
227
|
|
|
231
228
|
MIT © [Danny Zhang]
|
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
|
};
|