@chocozhang/three-model-render 1.0.3 → 1.0.5

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 (43) hide show
  1. package/CHANGELOG.md +39 -0
  2. package/README.md +134 -97
  3. package/dist/camera/index.d.ts +59 -36
  4. package/dist/camera/index.js +83 -67
  5. package/dist/camera/index.js.map +1 -1
  6. package/dist/camera/index.mjs +83 -67
  7. package/dist/camera/index.mjs.map +1 -1
  8. package/dist/core/index.d.ts +81 -28
  9. package/dist/core/index.js +194 -104
  10. package/dist/core/index.js.map +1 -1
  11. package/dist/core/index.mjs +194 -105
  12. package/dist/core/index.mjs.map +1 -1
  13. package/dist/effect/index.d.ts +47 -134
  14. package/dist/effect/index.js +287 -288
  15. package/dist/effect/index.js.map +1 -1
  16. package/dist/effect/index.mjs +287 -288
  17. package/dist/effect/index.mjs.map +1 -1
  18. package/dist/index.d.ts +432 -349
  19. package/dist/index.js +1399 -1228
  20. package/dist/index.js.map +1 -1
  21. package/dist/index.mjs +1395 -1229
  22. package/dist/index.mjs.map +1 -1
  23. package/dist/interaction/index.d.ts +85 -52
  24. package/dist/interaction/index.js +168 -142
  25. package/dist/interaction/index.js.map +1 -1
  26. package/dist/interaction/index.mjs +168 -142
  27. package/dist/interaction/index.mjs.map +1 -1
  28. package/dist/loader/index.d.ts +106 -58
  29. package/dist/loader/index.js +492 -454
  30. package/dist/loader/index.js.map +1 -1
  31. package/dist/loader/index.mjs +491 -455
  32. package/dist/loader/index.mjs.map +1 -1
  33. package/dist/setup/index.d.ts +26 -24
  34. package/dist/setup/index.js +125 -163
  35. package/dist/setup/index.js.map +1 -1
  36. package/dist/setup/index.mjs +124 -164
  37. package/dist/setup/index.mjs.map +1 -1
  38. package/dist/ui/index.d.ts +18 -7
  39. package/dist/ui/index.js +45 -37
  40. package/dist/ui/index.js.map +1 -1
  41. package/dist/ui/index.mjs +45 -37
  42. package/dist/ui/index.mjs.map +1 -1
  43. package/package.json +50 -22
package/CHANGELOG.md ADDED
@@ -0,0 +1,39 @@
1
+ # Changelog
2
+
3
+ ## [1.0.0] - 2025-12-08
4
+
5
+ ### ✨ Initial Release
6
+
7
+ #### Core
8
+ - `addChildModelLabels` - 3D model labels with 60% performance boost
9
+ - `enableHoverBreath` - Hover breathing effect with 80% idle CPU reduction
10
+ - `initPostProcessing` - Post-processing with auto-resize
11
+
12
+ #### Interaction
13
+ - `createModelClickHandler` - Click handling with debouncing
14
+ - `ArrowGuide` - Arrow guide with fade effects
15
+ - `LiquidFillerGroup` - Liquid filling animations
16
+
17
+ #### Camera
18
+ - `followModels` - Smooth camera following with easing
19
+ - `setView` - Quick view switching
20
+
21
+ #### Loader
22
+ - `loadModelByUrl` - Universal model loader
23
+ - `loadSkybox` - Skybox loader with caching
24
+ - `BlueSky` - HDR/EXR environment manager
25
+
26
+ #### UI
27
+ - `createModelsLabel` - Labels with connection lines
28
+
29
+ #### Effect
30
+ - `GroupExploder` - Model explosion effects
31
+
32
+ #### Setup
33
+ - `autoSetupCameraAndLight` - Auto camera and lighting
34
+
35
+ ### Performance
36
+ - CPU usage reduced by 55%
37
+ - Memory usage reduced by 33%
38
+ - Full TypeScript support
39
+ - Tree-shaking enabled
package/README.md CHANGED
@@ -1,231 +1,268 @@
1
1
  # three-model-render
2
2
 
3
- > 🚀 Professional Three.js Model Visualization and Interaction Toolkit
3
+ > 🚀 专业级 Three.js 模型可视化与交互工具库
4
4
 
5
- A high-performance, TypeScript-first toolkit providing 14 optimized utilities for Three.js model visualization and interaction.
5
+ [English](./README_EN.md) | 中文
6
6
 
7
- > 🌟 **[Live Demo: Experience the Power](https://happycolour.github.io/)**
7
+ 一个高性能、TypeScript 优先的工具库,提供 14 个经过优化的实用工具,专注于解决 Three.js 模型可视化与交互中的常见问题。
8
8
 
9
- [![Version](https://img.shields.io/badge/version-1.0.2-blue.svg)](https://github.com/HappyColour/three-model-render)
9
+ > 🌟 **[在线体验 Demo](https://happycolour.github.io/)**
10
+
11
+ [![Version](https://img.shields.io/badge/version-1.0.4-blue.svg)](https://github.com/HappyColour/three-model-render)
10
12
  [![License](https://img.shields.io/badge/license-MIT-green.svg)](./LICENSE)
11
13
  [![TypeScript](https://img.shields.io/badge/TypeScript-5.3-blue.svg)](https://www.typescriptlang.org/)
12
14
 
13
- ## ✨ Features
15
+ ## ✨ 核心特性
14
16
 
15
- - 🎯 **14 High-Performance Utilities** - Covering all aspects of model visualization
16
- - 📦 **Tree-Shakable** - Import only what you need
17
- - 🔷 **TypeScript First** - Full type definitions and IntelliSense support
18
- - ⚡ **Optimized** - 55% less CPU usage, 33% less memory
19
- - 🎨 **Easy Integration** - Works with Vue, React, and vanilla JS
20
- - 📝 **Well Documented** - Comprehensive API docs and examples
17
+ - 🎯 **14 个高性能工具** - 覆盖从加载、展示到交互的全流程
18
+ - 📦 **支持 Tree-Shaking** - 按需引入,体积更小
19
+ - 🔷 **TypeScript 优先** - 完整的类型定义与智能提示
20
+ - ⚡ **性能优化** - 相比原生实现,闲置 CPU 占用降低 55%,内存占用降低 33%
21
+ - 🎨 **无缝集成** - 完美支持 Vue 3, React 及原生 JavaScript
22
+ - 📝 **完善文档** - 提供最佳实践指引与完整示例
21
23
 
22
24
  ---
23
25
 
24
- ## 📦 Installation
26
+ ## 📦 安装
25
27
 
26
28
  ```bash
27
- npm install @chocozhang/three-model-render
28
- # OR
29
- yarn add @chocozhang/three-model-render
30
- # OR
31
- pnpm add @chocozhang/three-model-render
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
- **Peer Dependencies:**
36
+ **对等依赖 (Peer Dependencies):**
37
+ 请确保你的项目中安装了 `three`:
35
38
  ```bash
36
- npm install three@^0.160.0
39
+ npm install three@^0.181.2
37
40
  ```
38
41
 
39
42
  ---
40
43
 
41
- ## 🚀 Best Practice Workflow
44
+ ## 🚀 最佳实践工作流 (Best Practice Workflow)
42
45
 
43
- Build a professional 3D viewer following our optimized integration pattern. This workflow ensures maximum performance and visual quality.
46
+ 为了构建专业、高性能的 3D 查看器,我们建议遵循以下集成模式。此工作流经过生产环境验证,能确保最佳的视觉效果与性能表现。
44
47
 
45
- ### 1. Core Setup & Model Loading
46
- Initialize your basic Three.js scene and load your model using our optimized loader.
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. Basic Three.js Setup
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. Load Model with Progress
60
+ // 2. 配置全局加载路径 (可选,默认使用本地 /draco/ 和 /basis/)
61
+ import { setLoaderConfig } from '@chocozhang/three-model-render/loader';
62
+ setLoaderConfig({
63
+ dracoDecoderPath: 'https://www.gstatic.com/draco/versioned/decoders/1.5.6/',
64
+ ktx2TranscoderPath: '/custom/basis/'
65
+ });
66
+
67
+ // 3. 加载模型 (自动启用缓存与纹理优化)
58
68
  const model = await loadModelByUrl('path/to/model.glb', {
59
- manager: new THREE.LoadingManager(() => console.log('Loaded'))
69
+ maxTextureSize: 1024, // 自动缩小大纹理以节省显存
70
+ useCache: true // 启用内部缓存,避免重复加载
60
71
  });
61
72
  scene.add(model);
62
73
  ```
63
74
 
64
- ### 2. Auto-Configuration (Critical Step)
65
- Automatically position the camera and setup studio-quality lighting based on the model's bounding box.
75
+ ### 2. 自动场景配置 (关键步骤)
76
+ 根据模型的包围盒大小,自动计算最佳相机距离、近裁剪面(Near)和远裁剪面(Far),并设置影棚级光照。
66
77
 
67
78
  ```typescript
68
79
  import { autoSetupCameraAndLight } from '@chocozhang/three-model-render/setup';
69
80
 
70
- // Automatically calculates optimal camera distance and lighting
71
- autoSetupCameraAndLight(camera, scene, model);
81
+ // 方式 A: 一键配置相机与灯光
82
+ const lightHandles = autoSetupCameraAndLight(camera, scene, model, {
83
+ enableShadows: true,
84
+ intensity: 1.5
85
+ });
86
+
87
+ // 方式 B: 灵活组合 (推荐)
88
+ import { fitCameraToObject, setupDefaultLights } from '@chocozhang/three-model-render/setup';
89
+ fitCameraToObject(camera, model, 1.2); // 仅调整相机
90
+ const lights = setupDefaultLights(scene, model, { enableShadows: true }); // 仅添加灯光
72
91
  ```
73
92
 
74
- ### 3. Cinematic Entrance
75
- Create a smooth entry animation to focus on the model.
93
+ ### 3. 电影级入场动画
94
+ 模型加载后,使用平滑的运镜动画将视角聚焦到模型正面。
76
95
 
77
96
  ```typescript
78
97
  import { followModels, FOLLOW_ANGLES } from '@chocozhang/three-model-render';
79
98
 
80
99
  followModels(camera, model, {
81
- ...FOLLOW_ANGLES.FRONT,
82
- duration: 1500,
83
- padding: 0.6,
84
- controls,
85
- easing: 'easeInOut'
100
+ ...FOLLOW_ANGLES.FRONT, // 使用预设角度
101
+ duration: 1500, // 动画时长 1.5s
102
+ padding: 0.8, // 留白比例
103
+ controls, // 绑定控制器以同步状态
104
+ easing: 'easeInOut' // 缓动函数
86
105
  });
87
106
  ```
88
107
 
89
- ### 4. Post-Processing & Hover Effects
90
- Enable high-performance post-processing and optimized hover effects (saves 80% CPU when idle).
108
+ ### 4. 后期处理与呼吸光效
109
+ 启用高性能后期处理管线和智能呼吸光效(闲置时自动降低帧率以节省电量)。
91
110
 
92
111
  ```typescript
93
112
  import { initPostProcessing, enableHoverBreath } from '@chocozhang/three-model-render';
94
113
 
95
- // 1. Initialize Post-Processing Manager
114
+ // 1. 初始化后期处理管理器
96
115
  const ppManager = initPostProcessing(renderer, scene, camera, {
97
- resolutionScale: 0.8, // Optimize performance
98
- edgeStrength: 4,
99
- visibleEdgeColor: '#ffee00'
116
+ resolutionScale: 0.8, // 降低分辨率以提升性能
117
+ edgeStrength: 4, // 描边强度
118
+ visibleEdgeColor: '#ffee00' // 描边颜色
100
119
  });
101
120
 
102
- // 2. Enable Smart Hover Effect
121
+ // 2. 启用智能悬停效果
103
122
  const hoverController = enableHoverBreath({
104
123
  camera,
105
124
  scene,
106
125
  renderer,
107
126
  outlinePass: ppManager.outlinePass,
108
- throttleDelay: 16, // 60fps limit
109
- minStrength: 2,
110
- maxStrength: 8,
111
- speed: 3
127
+ throttleDelay: 16, // 60fps 节流
128
+ minStrength: 2, // 呼吸最小强度
129
+ maxStrength: 8, // 呼吸最大强度
130
+ speed: 3 // 呼吸速度
112
131
  });
113
132
 
114
- // IMPORTANT: Add composer to your animation loop
133
+ // 重要: 在动画循环中调用 render
115
134
  function animate() {
116
- // ...
135
+ requestAnimationFrame(animate);
136
+ // 使用 composer 替代 renderer.render
117
137
  ppManager.composer.render();
118
138
  }
119
139
  ```
120
140
 
121
- ### 5. Interaction Handling
122
- Add intelligent click handling that zooms to parts and triggers actions.
141
+ ### 5. 交互处理系统的集成
142
+ 添加智能点击事件,支持自动聚焦到被点击的组件。
123
143
 
124
144
  ```typescript
125
145
  import { createModelClickHandler } from '@chocozhang/three-model-render';
126
146
 
147
+ // 创建点击处理器 (返回销毁函数)
127
148
  const disposeClickHandler = createModelClickHandler(
128
149
  camera,
129
150
  scene,
130
151
  renderer,
131
152
  ppManager.outlinePass,
132
153
  (object, info) => {
133
- console.log('Clicked:', info);
154
+ console.log('点击了:', info);
134
155
 
135
- // Zoom to clicked part
156
+ // 聚焦到被点击的部件
136
157
  followModels(camera, object, {
137
158
  ...FOLLOW_ANGLES.ISOMETRIC,
138
- duration: 1500
159
+ duration: 1000
139
160
  });
140
161
  }
141
162
  );
142
163
  ```
143
164
 
144
- ### 6. Advanced Effects (Explosion)
145
- Add interactive mesh explosion/disassembly effects.
165
+ ### 6. 高级特效:爆炸分解
166
+ 无需复杂计算,一行代码实现模型的爆炸分解视图。
146
167
 
147
168
  ```typescript
148
169
  import { GroupExploder } from '@chocozhang/three-model-render';
149
170
 
150
- // Initialize
171
+ // 初始化爆炸控制器
151
172
  const exploder = new GroupExploder(scene, camera, controls);
152
173
  exploder.init();
153
174
 
154
- // Set Targets
175
+ // 设置需要爆炸的网格集合
155
176
  exploder.setMeshes(targetMeshes);
156
177
 
157
- // Explode
178
+ // 执行爆炸 (Grid 模式)
158
179
  exploder.explode({
159
- mode: 'grid',
160
- spacing: 2.8,
161
- dimOthers: { enabled: true, opacity: 0.1 }
180
+ mode: 'grid', // 排列模式: 'ring' | 'spiral' | 'grid' | 'radial'
181
+ spacing: 2.8, // 间距
182
+ dimOthers: { enabled: true, opacity: 0.1 } // 使其他物体透明
162
183
  });
163
184
 
164
- // Restore
185
+ // 还原
165
186
  exploder.restore(600);
166
187
  ```
167
188
 
168
- ### 7. View Control
169
- Easily switch between standard views.
189
+ ### 7. 视角快速切换
190
+ 提供标准的工程视角切换功能。
170
191
 
171
192
  ```typescript
172
193
  import { setView } from '@chocozhang/three-model-render';
173
194
 
174
- // Switch to Top View
195
+ // 切换到顶视图
175
196
  setView(camera, controls, model, 'top');
176
- // Switch to Isometric
197
+
198
+ // 切换到等轴测视图 (ISO)
177
199
  setView(camera, controls, model, 'iso');
178
200
  ```
179
201
 
202
+ ### 8. 资源管理与内存释放 (重要)
203
+ 使用 `ResourceManager` 统一追踪并销毁 3D 资源,确保应用长期运行不泄露。
204
+
205
+ ```typescript
206
+ import { ResourceManager } from '@chocozhang/three-model-render/core';
207
+
208
+ const rm = new ResourceManager();
209
+
210
+ // 追踪加载出的模型
211
+ rm.track(model);
212
+
213
+ // 当组件卸载时,一键销毁所有关联的几何体、材质与纹理
214
+ rm.dispose();
215
+ ```
216
+
217
+ ---
218
+
219
+ ## 🌐 WebXR 兼容性说明
220
+
221
+ 本工具库的所有核心逻辑与 Three.js 的 WebXR 系统保持兼容:
222
+ - `ResourceManager` 支持清理所有 XR 相关的 GPU 资源。
223
+ - `autoSetupCameraAndLight` 计算的包围盒信息可直接用于 XR 传送或布局。
224
+ - `loadModelByUrl` 经过优化的纹理大小非常适合移动端 VR/AR 设备。
225
+
226
+ > [!NOTE]
227
+ > 交互层 (`createModelClickHandler`) 目前主要针对鼠标与触屏优化。在 XR 环境下,建议结合控制器的射线检测使用。
228
+
180
229
  ---
181
230
 
182
- ## 📚 Module Overview
231
+ ## 📚 模块总览 (Module Overview)
183
232
 
184
233
  ### **Core (`/core`)**
185
- - `initPostProcessing`: Performance-optimized post-processing manager.
186
- - `enableHoverBreath`: Idle-aware hover effects.
187
- - `addChildModelLabels`: 3D labeling system.
234
+ - `initPostProcessing`: 高性能后期处理管理器,内置 OutlinePass。
235
+ - `enableHoverBreath`: 智能呼吸光效,支持性能自适应。
236
+ - `addChildModelLabels`: 3D 标签系统,自动跟随模型运动。
188
237
 
189
238
  ### **Camera (`/camera`)**
190
- - `followModels`: Smooth camera transitions.
191
- - `setView`: Preset view switching (Top, Front, Iso, etc.).
239
+ - `followModels`: 智能相机跟随与聚焦。
240
+ - `setView`: 预设视角切换 (Top, Front, Iso, etc.)
192
241
 
193
242
  ### **Loader (`/loader`)**
194
- - `loadModelByUrl`: Robust model loader (GLTF, FBX, OBJ).
195
- - `BlueSky`: Environment map manager.
243
+ - `loadModelByUrl`: 统一模型加载器,支持多种格式。
244
+ - `BlueSky`: 快速创建天空盒环境。
196
245
 
197
246
  ### **Interaction (`/interaction`)**
198
- - `createModelClickHandler`: Raycasting click handler.
247
+ - `createModelClickHandler`: 射线检测点击处理器。
199
248
 
200
249
  ### **Effect (`/effect`)**
201
- - `GroupExploder`: Mesh disassembly animations.
250
+ - `GroupExploder`: 模型爆炸/拆解动画控制器。
202
251
 
203
252
  ### **Setup (`/setup`)**
204
- - `autoSetupCameraAndLight`: Instant scene configuration.
253
+ - `autoSetupCameraAndLight`: 一键自动化场景配置大师。
205
254
 
206
255
  ---
207
256
 
208
- ## 🎨 HTML/Vue 3 Example
257
+ ## 🎨 示例项目
209
258
 
210
- For a complete, deployable HTML/Vue 3 example demonstrating all these features, check `examples/html-best-practice/`.
259
+ 我们提供了一个完整的、可部署的示例项目,展示了所有功能的集成方式:
211
260
 
212
- ---
213
-
214
- ## ⚙️ TypeScript Support
215
-
216
- Full TypeScript definitions included. Ensure your `tsconfig.json` matches:
217
- ```json
218
- {
219
- "compilerOptions": {
220
- "lib": ["ES2015", "DOM"],
221
- "target": "ES2015",
222
- "module": "ESNext"
223
- }
224
- }
225
- ```
261
+ - 👉 **[Vue 3 示例 (推荐)](https://github.com/HappyColour/three-model-render/tree/main/examples/vue-example)** - 完整的 Vue 3 + TypeScript 集成最佳实践
262
+ - 👉 **[HTML 原生示例](https://github.com/HappyColour/three-model-render/tree/main/examples/html-example)** - 适合原生 JavaScript / jQuery 项目
226
263
 
227
264
  ---
228
265
 
229
- ## 📄 License
266
+ ## 📄 开源协议
230
267
 
231
268
  MIT © [Danny Zhang]
@@ -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
- /** 正前视角 - 适合正面展示、UI 对齐 */
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
- * - 复用 followModels 逻辑,避免代码重复
97
- * - 支持更多视角
98
- * - 配置选项增强
99
- * - 返回 Promise 支持链式调用
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
  };