@ridp/threejs 1.5.0 → 1.5.2

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/dist/threejs.js CHANGED
@@ -1,13 +1,13 @@
1
- var A = Object.defineProperty;
2
- var P = (u, e, t) => e in u ? A(u, e, { enumerable: !0, configurable: !0, writable: !0, value: t }) : u[e] = t;
3
- var i = (u, e, t) => P(u, typeof e != "symbol" ? e + "" : e, t);
4
- import { i as oe, o as ie, c as ne, b as re, a as ae, u as le } from "./useBatchGLTFLoader-C1C8R5Ss.js";
5
- import { d as j, S as V, s as q, j as X } from "./PredictiveLoader-C9zJlZEQ.js";
6
- import { C as he, E as de, I as me, M as fe, P as pe, q as ue, R as xe, n as ge, h as Fe, g as Re, b as ze, c as be, a as we, e as Me, f as Ee, i as Le, l as Te, m as Oe, o as Ce, k as ye, p as ve, r as Se, u as De } from "./PredictiveLoader-C9zJlZEQ.js";
7
- import { I as He, c as Ae, a as Pe, g as je, b as Ve, d as qe, i as Xe } from "./objectQuery-BfHUGPET.js";
8
- import { ModelOptimizer as Be, modelOptimizer as Ze } from "./modelOptimizer-D6fRg-DF.js";
9
- import { MathUtils as F, Scene as Y, PerspectiveCamera as B, WebGLRenderer as Z, Box3 as _, Vector3 as a, Box3Helper as G } from "three";
10
- const N = "1.5.0", W = 50, k = 20, U = 20, v = {
1
+ var H = Object.defineProperty;
2
+ var P = (x, e, t) => e in x ? H(x, e, { enumerable: !0, configurable: !0, writable: !0, value: t }) : x[e] = t;
3
+ var o = (x, e, t) => P(x, typeof e != "symbol" ? e + "" : e, t);
4
+ import { i as oe, o as ie, c as ne, b as re, a as ae, u as le } from "./useBatchGLTFLoader-BtuzDyHn.js";
5
+ import { d as j, S as V, y as q, j as X } from "./PredictiveLoader-Ce8DXwbW.js";
6
+ import { C as he, E as de, I as me, M as fe, P as ue, x as pe, R as xe, t as ge, q as Fe, n as Re, h as we, g as be, b as ze, c as Me, a as Te, e as Ee, f as Le, i as Oe, l as Ce, m as ye, r as ve, p as Ie, o as Se, k as De, s as Ae, v as He, w as Pe, u as je } from "./PredictiveLoader-Ce8DXwbW.js";
7
+ import { I as qe, b as Xe, c as Ye, a as Be, g as Ze, d as Ge, e as We, i as _e, p as Ne, r as ke, t as Ue } from "./objectQuery-BcL0iGx1.js";
8
+ import { ModelOptimizer as Je, modelOptimizer as Ke } from "./modelOptimizer-B7zPcU53.js";
9
+ import { MathUtils as F, Scene as Y, PerspectiveCamera as B, WebGLRenderer as Z, Box3 as G, Vector3 as l, Box3Helper as W } from "three";
10
+ const _ = "1.5.2", N = 50, k = 20, U = 20, v = {
11
11
  TOP: "top",
12
12
  // 俯视(从上往下)
13
13
  RIGHT: "right",
@@ -39,21 +39,21 @@ class J {
39
39
  * @param {Object} [option.control.options={}] - 控制器选项
40
40
  */
41
41
  constructor(e, t) {
42
- i(this, "isReady", !1);
43
- i(this, "scene", null);
44
- i(this, "camera", null);
45
- i(this, "renderer", null);
46
- i(this, "control", null);
47
- i(this, "css3dRenderer", null);
48
- i(this, "el", null);
49
- i(this, "renderRequested", !1);
50
- i(this, "selector", null);
51
- i(this, "eventsListener", {});
52
- i(this, "stats", null);
53
- i(this, "isDispose", !1);
54
- i(this, "version", "0.0.0");
55
- i(this, "boxHelper", null);
56
- i(this, "initOpt", {
42
+ o(this, "isReady", !1);
43
+ o(this, "scene", null);
44
+ o(this, "camera", null);
45
+ o(this, "renderer", null);
46
+ o(this, "control", null);
47
+ o(this, "css3dRenderer", null);
48
+ o(this, "el", null);
49
+ o(this, "renderRequested", !1);
50
+ o(this, "selector", null);
51
+ o(this, "eventsListener", {});
52
+ o(this, "stats", null);
53
+ o(this, "isDispose", !1);
54
+ o(this, "version", "0.0.0");
55
+ o(this, "boxHelper", null);
56
+ o(this, "initOpt", {
57
57
  css3d: !1,
58
58
  stats: !1,
59
59
  renderType: "change",
@@ -70,20 +70,20 @@ class J {
70
70
  * 初始化场景
71
71
  * @param {string} selector - DOM 容器选择器
72
72
  */
73
- i(this, "setup", (e) => {
73
+ o(this, "setup", (e) => {
74
74
  if (this.isDispose = !1, this.selector = e, this.el = document.querySelector(e), !this.el) {
75
75
  console.error(`ThreeIns: 找不到元素 ${e}`);
76
76
  return;
77
77
  }
78
- const [t, h] = this.getTargetSize();
79
- if (this.updateCameraFOV(t, h), this.camera.position.set(0, 0, 0), this.camera.lookAt(0, 0, 0), this.camera.updateProjectionMatrix(), this.renderer.setPixelRatio(window.devicePixelRatio), this.renderer.setSize(t, h), this.el.appendChild(this.renderer.domElement), this.initOpt.control && this.initOpt.control.init) {
78
+ const [t, r] = this.getTargetSize();
79
+ if (this.updateCameraFOV(t, r), this.camera.position.set(0, 0, 0), this.camera.lookAt(0, 0, 0), this.camera.updateProjectionMatrix(), this.renderer.setPixelRatio(window.devicePixelRatio), this.renderer.setSize(t, r), this.el.appendChild(this.renderer.domElement), this.initOpt.control && this.initOpt.control.init) {
80
80
  this.control = j(this.camera, this.renderer.domElement);
81
81
  const s = Object.assign(
82
82
  $,
83
83
  this.initOpt.control.options || {}
84
84
  );
85
- Object.keys(s).forEach((x) => {
86
- this.control[x] = s[x];
85
+ Object.keys(s).forEach((f) => {
86
+ this.control[f] = s[f];
87
87
  });
88
88
  }
89
89
  setTimeout(() => {
@@ -97,14 +97,14 @@ class J {
97
97
  * WebGL 上下文丢失处理
98
98
  * @param {Event} e - 事件对象
99
99
  */
100
- i(this, "onContextLost", (e) => {
100
+ o(this, "onContextLost", (e) => {
101
101
  e.preventDefault(), this.animationFrameId && cancelAnimationFrame(this.animationFrameId);
102
102
  });
103
103
  /**
104
104
  * WebGL 上下文恢复处理
105
105
  * @param {Event} e - 事件对象
106
106
  */
107
- i(this, "onContextRestored", (e) => {
107
+ o(this, "onContextRestored", (e) => {
108
108
  e.preventDefault(), this.dispose(), setTimeout(() => {
109
109
  this.setup(this.selector);
110
110
  }, U);
@@ -112,7 +112,7 @@ class J {
112
112
  /**
113
113
  * 初始化事件监听器
114
114
  */
115
- i(this, "initListener", () => {
115
+ o(this, "initListener", () => {
116
116
  this.initOpt.initListener && window && window.addEventListener("resize", this.onResize, !1), this.renderer.domElement.addEventListener(
117
117
  "webglcontextlost",
118
118
  this.onContextLost,
@@ -126,7 +126,7 @@ class J {
126
126
  /**
127
127
  * 移除事件监听器
128
128
  */
129
- i(this, "removeListener", () => {
129
+ o(this, "removeListener", () => {
130
130
  window && window.removeEventListener("resize", this.onResize, !1), this.renderer && this.renderer.domElement && (this.renderer.domElement.removeEventListener(
131
131
  "webglcontextlost",
132
132
  this.onContextLost,
@@ -140,19 +140,35 @@ class J {
140
140
  /**
141
141
  * 渲染循环(loop 模式)
142
142
  */
143
- i(this, "animate", () => {
143
+ o(this, "animate", () => {
144
144
  this.isDispose || (this.initOpt.renderType === "loop" && this.onRender(), this.animationFrameId = requestAnimationFrame(this.animate));
145
145
  });
146
146
  /**
147
147
  * 执行渲染
148
148
  */
149
- i(this, "onRender", () => {
150
- this.isDispose || (this.renderRequested = !1, this.stats && this.stats.update(), this.control && this.control.update(), this.renderer.render(this.scene, this.camera), this.css3dRenderer && this.css3dRenderer.render(this.scene, this.camera), this.eventsListener.onRender && this.eventsListener.onRender.length && this.eventsListener.onRender.forEach((e) => e()));
149
+ o(this, "onRender", () => {
150
+ if (this.isDispose) return;
151
+ const e = this.debug ? performance.now() : 0;
152
+ this.renderRequested = !1, this.stats && this.stats.update(), this.control && this.control.update(), this.renderer.render(this.scene, this.camera), this.css3dRenderer && this.css3dRenderer.render(this.scene, this.camera);
153
+ const t = this.eventsListener.onRender;
154
+ if (t && t.length) {
155
+ const r = t.length;
156
+ for (let s = 0; s < r; s++)
157
+ try {
158
+ t[s]();
159
+ } catch (f) {
160
+ console.error("[ThreeIns] 渲染回调执行错误:", f);
161
+ }
162
+ }
163
+ if (this.debug) {
164
+ const r = performance.now() - e;
165
+ r > 50 && console.warn(`[ThreeIns] 帧耗时 ${r.toFixed(1)}ms,可能存在性能问题`);
166
+ }
151
167
  });
152
168
  /**
153
169
  * 请求渲染(如果尚未请求)
154
170
  */
155
- i(this, "requestRenderIfNotRequested", () => {
171
+ o(this, "requestRenderIfNotRequested", () => {
156
172
  this.renderRequested || (this.renderRequested = !0, requestAnimationFrame(() => {
157
173
  this.onRender();
158
174
  }));
@@ -160,11 +176,11 @@ class J {
160
176
  /**
161
177
  * 处理窗口大小变化(带防抖)
162
178
  */
163
- i(this, "onResize", () => {
179
+ o(this, "onResize", () => {
164
180
  this.resizeTimer && clearTimeout(this.resizeTimer), this.resizeTimer = setTimeout(() => {
165
181
  const [e, t] = this.getTargetSize();
166
182
  this.updateCameraFOV(e, t), this.camera.lookAt(this.scene.position), this.renderer.setSize(e, t), this.css3dRenderer && this.css3dRenderer.setSize(e, t), this.onRender();
167
- }, W);
183
+ }, N);
168
184
  });
169
185
  /**
170
186
  * @deprecated 此方法已弃用,请使用 setView() 方法代替
@@ -181,7 +197,7 @@ class J {
181
197
  * @param {number} [scale=0.8] - 缩放比例,1=占满画布,0.5=50%,2.0=200%
182
198
  * @returns {Object} 返回 setView 的结果
183
199
  */
184
- i(this, "frameArea", (e, t) => (console.warn(
200
+ o(this, "frameArea", (e, t) => (console.warn(
185
201
  `[ThreeIns] frameArea() 已弃用,建议使用 setView() 方法。
186
202
  旧用法: threeIns.frameArea(model, scale)
187
203
  新用法: threeIns.setView(model, ViewType.ISO, { scale })`
@@ -247,73 +263,73 @@ class J {
247
263
  * // 或者使用类静态属性(向后兼容)
248
264
  * threeIns.setView(model, ThreeIns.ViewType.TOP);
249
265
  */
250
- i(this, "setView", (e, t, h = {}) => {
251
- let s = h.scale || 0.8, x = h.offset || null, R = h.position || "center", z = h.showBox || !1, S = h.boxColor || 16776960, M = h.animate !== void 0 ? h.animate : !0, E = h.duration || 1e3;
252
- const g = new _().setFromObject(e);
253
- let c = g.getCenter(new a());
266
+ o(this, "setView", (e, t, r = {}) => {
267
+ let s = r.scale || 0.8, f = r.offset || null, R = r.position || "center", w = r.showBox || !1, I = r.boxColor || 16776960, M = r.animate !== void 0 ? r.animate : !0, T = r.duration || 1e3;
268
+ const g = new G().setFromObject(e);
269
+ let h = g.getCenter(new l());
254
270
  if (typeof R == "string") {
255
- const o = g.getSize(new a()), r = {
256
- center: new a(0, 0, 0),
257
- "top-left": new a(-o.x * 0.3, o.y * 0.3, o.z * 0.3),
258
- "top-right": new a(o.x * 0.3, o.y * 0.3, o.z * 0.3),
259
- "bottom-left": new a(-o.x * 0.3, -o.y * 0.3, o.z * 0.3),
260
- "bottom-right": new a(o.x * 0.3, -o.y * 0.3, o.z * 0.3)
261
- }, d = r[R] || r.center;
262
- t === "top" ? c.add(new a(d.x, 0, d.z)) : t === "right" || t === "left" ? c.add(new a(d.x, d.y, d.z)) : c.add(d);
263
- } else R instanceof a && c.add(R);
264
- x && c.add(x);
265
- const n = g.getSize(new a()), L = {
266
- top: new a(0, 1, 0),
271
+ const i = g.getSize(new l()), a = {
272
+ center: new l(0, 0, 0),
273
+ "top-left": new l(-i.x * 0.3, i.y * 0.3, i.z * 0.3),
274
+ "top-right": new l(i.x * 0.3, i.y * 0.3, i.z * 0.3),
275
+ "bottom-left": new l(-i.x * 0.3, -i.y * 0.3, i.z * 0.3),
276
+ "bottom-right": new l(i.x * 0.3, -i.y * 0.3, i.z * 0.3)
277
+ }, d = a[R] || a.center;
278
+ t === "top" ? h.add(new l(d.x, 0, d.z)) : t === "right" || t === "left" ? h.add(new l(0, d.y, d.z)) : h.add(d);
279
+ } else R instanceof l && h.add(R);
280
+ f && h.add(f);
281
+ const n = g.getSize(new l()), E = {
282
+ top: new l(0, 1, 0),
267
283
  // 从上往下:Y 轴正方向
268
- right: new a(1, 1, 1).normalize(),
284
+ right: new l(1, 1, 1).normalize(),
269
285
  // 从右往左:X 轴正方向
270
- left: new a(-1, 1, 1).normalize(),
286
+ left: new l(-1, 1, 1).normalize(),
271
287
  // 从左往右:X 轴负方向
272
- iso: new a(0, 1, 1).normalize()
288
+ iso: new l(0, 1, 1).normalize()
273
289
  // 等轴测:从对角线上方俯视
274
- }, b = L[t] || L.iso, T = this.camera.aspect, l = F.degToRad(this.camera.fov * 0.5), D = F.degToRad(80), m = Math.min(Math.atan(Math.tan(l) * T), D);
275
- let f;
290
+ }, b = E[t] || E.iso, L = this.camera.aspect, c = F.degToRad(this.camera.fov * 0.5), S = F.degToRad(80), m = Math.min(Math.atan(Math.tan(c) * L), S);
291
+ let u;
276
292
  if (t === "top") {
277
- const o = n.x * 0.5 / (Math.tan(m) * s), r = n.z * 0.5 / (Math.tan(l) * s);
278
- f = Math.max(o, r);
293
+ const i = n.x * 0.5 / (Math.tan(m) * s), a = n.z * 0.5 / (Math.tan(c) * s);
294
+ u = Math.max(i, a);
279
295
  } else if (t === "right" || t === "left") {
280
- const o = n.y * 0.5 / (Math.tan(l) * s), r = n.z * 0.5 / (Math.tan(l) * s);
281
- f = Math.max(o, r);
296
+ const i = n.y * 0.5 / (Math.tan(c) * s), a = n.z * 0.5 / (Math.tan(c) * s);
297
+ u = Math.max(i, a);
282
298
  } else {
283
- const o = n.x * 0.5 / (Math.tan(m) * s), r = n.y * 0.5 / (Math.tan(l) * s), d = n.z * 0.5 / (Math.tan(l) * s);
284
- f = Math.max(o, r, d);
299
+ const i = n.x * 0.5 / (Math.tan(m) * s), a = n.y * 0.5 / (Math.tan(c) * s), d = n.z * 0.5 / (Math.tan(c) * s);
300
+ u = Math.max(i, a, d);
285
301
  }
286
- const p = b.clone().multiplyScalar(f).add(c);
287
- if (z && (console.log("📍 相机位置验证:"), console.log(" - 方向向量:", b), console.log(" - 距离:", f.toFixed(2)), console.log(" - 包围盒中心:", c), console.log(" - 计算公式: direction * distance + boxCenter"), console.log(" - 目标位置:", p), console.log(" - 实际相机与中心的距离:", p.clone().sub(c).length().toFixed(2))), z ? (this.boxHelper && (this.scene.remove(this.boxHelper), this.boxHelper = null), this.boxHelper = new G(g, S), this.scene.add(this.boxHelper)) : this.boxHelper && (this.scene.remove(this.boxHelper), this.boxHelper = null), M) {
288
- const o = this.camera.position.clone(), r = this.control ? this.control.target.clone() : new a(0, 0, 0), d = c, I = Date.now(), O = () => {
289
- const H = Date.now() - I, C = Math.min(H / E, 1), y = 1 - Math.pow(1 - C, 3);
290
- if (this.camera.position.lerpVectors(o, p, y), this.control) {
291
- const w = new a();
292
- w.lerpVectors(r, d, y), this.control.target.copy(w), this.camera.lookAt(w);
302
+ const p = b.clone().multiplyScalar(u).add(h);
303
+ if (w && (console.log("📍 相机位置验证:"), console.log(" - 方向向量:", b), console.log(" - 距离:", u.toFixed(2)), console.log(" - 包围盒中心:", h), console.log(" - 计算公式: direction * distance + boxCenter"), console.log(" - 目标位置:", p), console.log(" - 实际相机与中心的距离:", p.clone().sub(h).length().toFixed(2))), w ? (this.boxHelper && (this.scene.remove(this.boxHelper), this.boxHelper = null), this.boxHelper = new W(g, I), this.scene.add(this.boxHelper)) : this.boxHelper && (this.scene.remove(this.boxHelper), this.boxHelper = null), M) {
304
+ const i = this.camera.position.clone(), a = this.control ? this.control.target.clone() : new l(0, 0, 0), d = h, D = Date.now(), O = () => {
305
+ const A = Date.now() - D, C = Math.min(A / T, 1), y = 1 - Math.pow(1 - C, 3);
306
+ if (this.camera.position.lerpVectors(i, p, y), this.control) {
307
+ const z = new l();
308
+ z.lerpVectors(a, d, y), this.control.target.copy(z), this.camera.lookAt(z);
293
309
  } else
294
- this.camera.lookAt(c);
295
- this.camera.updateProjectionMatrix(), C < 1 ? requestAnimationFrame(O) : (this.camera.position.copy(p), this.camera.lookAt(c), this.camera.updateProjectionMatrix(), this.control && (this.control.target.copy(c), this.control.update()), this.onRender());
310
+ this.camera.lookAt(h);
311
+ this.camera.updateProjectionMatrix(), C < 1 ? requestAnimationFrame(O) : (this.camera.position.copy(p), this.camera.lookAt(h), this.camera.updateProjectionMatrix(), this.control && (this.control.target.copy(h), this.control.update()), this.onRender());
296
312
  };
297
313
  O();
298
314
  } else
299
- this.camera.position.copy(p), this.camera.lookAt(c), this.camera.updateProjectionMatrix(), this.control && (this.control.target.copy(c), this.control.update()), this.onRender();
300
- if (z) {
301
- if (console.log("🎥 视角切换信息:"), console.log(" - 视角类型:", t), console.log(" - 相机位置:", p), console.log(" - 观察目标:", c), console.log(" - 方向向量:", b), console.log(" - 包围盒尺寸:", n), console.log(" - 包围盒中心:", g.getCenter(new a())), console.log(" - 水平 FOV:", F.radToDeg(m * 2).toFixed(2) + "°"), console.log(" - 垂直 FOV:", F.radToDeg(l * 2).toFixed(2) + "°"), console.log(" - 宽高比:", T.toFixed(4)), console.log(" - 模型宽度:", n.x.toFixed(2)), console.log(" - 模型高度:", n.y.toFixed(2)), console.log(" - 模型深度:", n.z.toFixed(2)), console.log(" - 传入的 scale 参数:", s), t === "top") {
302
- const o = n.x * 0.5 / (Math.tan(m) * s), r = n.z * 0.5 / (Math.tan(l) * s);
303
- console.log(" - 模型 X 尺寸 (宽度):", n.x.toFixed(2)), console.log(" - 模型 Z 尺寸 (深度):", n.z.toFixed(2)), console.log(" - tan(halfFovX):", Math.tan(m).toFixed(4)), console.log(" - tan(halfFovY):", Math.tan(l).toFixed(4)), console.log(" - X方向距离计算: (", (n.x * 0.5).toFixed(2), ") / (", Math.tan(m).toFixed(4), " *", s, ") =", o.toFixed(2)), console.log(" - Z方向距离计算: (", (n.z * 0.5).toFixed(2), ") / (", Math.tan(l).toFixed(4), " *", s, ") =", r.toFixed(2)), console.log(" - X方向距离 (scale=" + s + "):", o.toFixed(2)), console.log(" - Z方向距离 (scale=" + s + "):", r.toFixed(2));
315
+ this.camera.position.copy(p), this.camera.lookAt(h), this.camera.updateProjectionMatrix(), this.control && (this.control.target.copy(h), this.control.update()), this.onRender();
316
+ if (w) {
317
+ if (console.log("🎥 视角切换信息:"), console.log(" - 视角类型:", t), console.log(" - 相机位置:", p), console.log(" - 观察目标:", h), console.log(" - 方向向量:", b), console.log(" - 包围盒尺寸:", n), console.log(" - 包围盒中心:", g.getCenter(new l())), console.log(" - 水平 FOV:", F.radToDeg(m * 2).toFixed(2) + "°"), console.log(" - 垂直 FOV:", F.radToDeg(c * 2).toFixed(2) + "°"), console.log(" - 宽高比:", L.toFixed(4)), console.log(" - 模型宽度:", n.x.toFixed(2)), console.log(" - 模型高度:", n.y.toFixed(2)), console.log(" - 模型深度:", n.z.toFixed(2)), console.log(" - 传入的 scale 参数:", s), t === "top") {
318
+ const i = n.x * 0.5 / (Math.tan(m) * s), a = n.z * 0.5 / (Math.tan(c) * s);
319
+ console.log(" - 模型 X 尺寸 (宽度):", n.x.toFixed(2)), console.log(" - 模型 Z 尺寸 (深度):", n.z.toFixed(2)), console.log(" - tan(halfFovX):", Math.tan(m).toFixed(4)), console.log(" - tan(halfFovY):", Math.tan(c).toFixed(4)), console.log(" - X方向距离计算: (", (n.x * 0.5).toFixed(2), ") / (", Math.tan(m).toFixed(4), " *", s, ") =", i.toFixed(2)), console.log(" - Z方向距离计算: (", (n.z * 0.5).toFixed(2), ") / (", Math.tan(c).toFixed(4), " *", s, ") =", a.toFixed(2)), console.log(" - X方向距离 (scale=" + s + "):", i.toFixed(2)), console.log(" - Z方向距离 (scale=" + s + "):", a.toFixed(2));
304
320
  } else if (t === "right" || t === "left") {
305
- const o = n.y * 0.5 / (Math.tan(l) * s), r = n.z * 0.5 / (Math.tan(l) * s);
306
- console.log(" - Y方向距离 (scale=" + s + "):", o.toFixed(2)), console.log(" - Z方向距离 (scale=" + s + "):", r.toFixed(2));
321
+ const i = n.y * 0.5 / (Math.tan(c) * s), a = n.z * 0.5 / (Math.tan(c) * s);
322
+ console.log(" - Y方向距离 (scale=" + s + "):", i.toFixed(2)), console.log(" - Z方向距离 (scale=" + s + "):", a.toFixed(2));
307
323
  } else {
308
- const o = n.x * 0.5 / (Math.tan(m) * s), r = n.y * 0.5 / (Math.tan(l) * s), d = n.z * 0.5 / (Math.tan(l) * s);
309
- console.log(" - 模型 X 尺寸 (宽度):", n.x.toFixed(2)), console.log(" - 模型 Y 尺寸 (高度):", n.y.toFixed(2)), console.log(" - 模型 Z 尺寸 (深度):", n.z.toFixed(2)), console.log(" - tan(halfFovX):", Math.tan(m).toFixed(4)), console.log(" - tan(halfFovY):", Math.tan(l).toFixed(4)), console.log(" - X方向距离计算: (", (n.x * 0.5).toFixed(2), ") / (", Math.tan(m).toFixed(4), " *", s, ") =", o.toFixed(2)), console.log(" - Y方向距离计算: (", (n.y * 0.5).toFixed(2), ") / (", Math.tan(l).toFixed(4), " *", s, ") =", r.toFixed(2)), console.log(" - Z方向距离计算: (", (n.z * 0.5).toFixed(2), ") / (", Math.tan(l).toFixed(4), " *", s, ") =", d.toFixed(2)), console.log(" - X方向距离 (scale=" + s + "):", o.toFixed(2)), console.log(" - Y方向距离 (scale=" + s + "):", r.toFixed(2)), console.log(" - Z方向距离 (scale=" + s + "):", d.toFixed(2)), console.log(" - 最大距离 (Max):", Math.max(o, r, d).toFixed(2));
324
+ const i = n.x * 0.5 / (Math.tan(m) * s), a = n.y * 0.5 / (Math.tan(c) * s), d = n.z * 0.5 / (Math.tan(c) * s);
325
+ console.log(" - 模型 X 尺寸 (宽度):", n.x.toFixed(2)), console.log(" - 模型 Y 尺寸 (高度):", n.y.toFixed(2)), console.log(" - 模型 Z 尺寸 (深度):", n.z.toFixed(2)), console.log(" - tan(halfFovX):", Math.tan(m).toFixed(4)), console.log(" - tan(halfFovY):", Math.tan(c).toFixed(4)), console.log(" - X方向距离计算: (", (n.x * 0.5).toFixed(2), ") / (", Math.tan(m).toFixed(4), " *", s, ") =", i.toFixed(2)), console.log(" - Y方向距离计算: (", (n.y * 0.5).toFixed(2), ") / (", Math.tan(c).toFixed(4), " *", s, ") =", a.toFixed(2)), console.log(" - Z方向距离计算: (", (n.z * 0.5).toFixed(2), ") / (", Math.tan(c).toFixed(4), " *", s, ") =", d.toFixed(2)), console.log(" - X方向距离 (scale=" + s + "):", i.toFixed(2)), console.log(" - Y方向距离 (scale=" + s + "):", a.toFixed(2)), console.log(" - Z方向距离 (scale=" + s + "):", d.toFixed(2)), console.log(" - 最大距离 (Max):", Math.max(i, a, d).toFixed(2));
310
326
  }
311
- console.log(" - 最终距离:", f.toFixed(2)), console.log(" - 缩放比例:", s), console.log(" - 动画:", M ? "是 (" + E + "ms)" : "否");
327
+ console.log(" - 最终距离:", u.toFixed(2)), console.log(" - 缩放比例:", s), console.log(" - 动画:", M ? "是 (" + T + "ms)" : "否");
312
328
  }
313
329
  return {
314
330
  position: p,
315
- target: c,
316
- distance: f,
331
+ target: h,
332
+ distance: u,
317
333
  viewType: t
318
334
  };
319
335
  });
@@ -323,14 +339,32 @@ class J {
323
339
  * @param {Function} callback - 回调函数
324
340
  * @returns {Function} 返回取消监听的函数
325
341
  */
326
- i(this, "on", (e, t) => !e || !t || typeof t != "function" ? (console.warn("ThreeIns.on: 无效的参数"), () => {
342
+ o(this, "on", (e, t) => !e || !t || typeof t != "function" ? (console.warn("ThreeIns.on: 无效的参数"), () => {
327
343
  }) : (this.eventsListener[e] || (this.eventsListener[e] = []), this.eventsListener[e].push(t), () => this.off(e, t)));
344
+ /**
345
+ * 添加动画回调(推荐使用此方法注册动画回调)
346
+ * @param {Function} callback - 回调函数
347
+ * @returns {Function} 返回移除回调的函数
348
+ */
349
+ o(this, "addAnimate", (e) => !e || typeof e != "function" ? (console.warn("ThreeIns.addAnimate: 无效的回调函数"), () => {
350
+ }) : (this.eventsListener.onRender || (this.eventsListener.onRender = []), this.eventsListener.onRender.push(e), () => this.removeAnimate(e)));
351
+ /**
352
+ * 移除动画回调
353
+ * @param {Function} callback - 要移除的回调函数
354
+ */
355
+ o(this, "removeAnimate", (e) => {
356
+ if (!e) return;
357
+ const t = this.eventsListener.onRender;
358
+ if (!t) return;
359
+ const r = t.indexOf(e);
360
+ r > -1 && t.splice(r, 1);
361
+ });
328
362
  this.isReady = !1, this.scene = new Y({}), this.camera = new B(50, 1, 0.1, 2e3), this.renderer = new Z({
329
363
  antialias: !0,
330
364
  alpha: !0,
331
365
  precision: "mediump",
332
366
  logarithmicDepthBuffer: !0
333
- }), this.version = N, this.onContextLost = this.onContextLost.bind(this), this.onContextRestored = this.onContextRestored.bind(this), this.onResize = this.onResize.bind(this), this.animate = this.animate.bind(this), this.resizeTimer = null, this.animationFrameId = null, t && (this.initOpt = Object.assign(this.initOpt, t)), e && this.setup(e);
367
+ }), this.version = _, this.onContextLost = this.onContextLost.bind(this), this.onContextRestored = this.onContextRestored.bind(this), this.onResize = this.onResize.bind(this), this.animate = this.animate.bind(this), this.resizeTimer = null, this.animationFrameId = null, t && (this.initOpt = Object.assign(this.initOpt, t)), e && this.setup(e);
334
368
  }
335
369
  /**
336
370
  * 更新相机 FOV 以适应容器尺寸
@@ -339,7 +373,7 @@ class J {
339
373
  * @param {number} domH - 容器高度
340
374
  */
341
375
  updateCameraFOV(e, t) {
342
- const h = this.initOpt.initialFov || 50, s = Math.tan(Math.PI / 180 * h / 2);
376
+ const r = this.initOpt.initialFov || 50, s = Math.tan(Math.PI / 180 * r / 2);
343
377
  this.camera.aspect = e / t, this.camera.fov = 360 / Math.PI * Math.atan(s * (t / e)), this.camera.updateProjectionMatrix();
344
378
  }
345
379
  /**
@@ -374,7 +408,7 @@ class J {
374
408
  this.eventsListener = {};
375
409
  return;
376
410
  }
377
- this.eventsListener[e] && (t ? this.eventsListener[e] = this.eventsListener[e].filter((h) => h !== t) : this.eventsListener[e] = []);
411
+ this.eventsListener[e] && (t ? this.eventsListener[e] = this.eventsListener[e].filter((r) => r !== t) : this.eventsListener[e] = []);
378
412
  }
379
413
  /**
380
414
  * 清理所有资源
@@ -385,47 +419,56 @@ class J {
385
419
  }
386
420
  // 存储包围盒辅助器
387
421
  // 视角类型枚举(作为类静态属性引用,保持向后兼容)
388
- i(J, "ViewType", v);
422
+ o(J, "ViewType", v);
389
423
  export {
390
424
  he as CacheMonitor,
391
425
  de as ErrorType,
392
426
  me as IDBCache,
393
- He as ImageLoader,
427
+ qe as ImageLoader,
394
428
  fe as ModelLoadError,
395
- Be as ModelOptimizer,
396
- pe as PredictiveLoader,
397
- ue as ProgressiveSceneBuilder,
429
+ Je as ModelOptimizer,
430
+ ue as PredictiveLoader,
431
+ pe as ProgressiveSceneBuilder,
398
432
  xe as RetryHelper,
399
433
  J as ThreeIns,
400
434
  v as ViewType,
401
435
  ge as cacheMonitor,
402
- Fe as createArrowHelper,
403
- Re as createAxesHelper,
436
+ Xe as cancelIdleTask,
437
+ Fe as clearGeometryCache,
438
+ Re as clearMaterialCache,
439
+ we as createArrowHelper,
440
+ be as createAxesHelper,
404
441
  ze as createBox3Helper,
405
- be as createCameraHelper,
406
- we as createGridHelper,
407
- Ae as createInfoPlane,
408
- Me as createMapControls,
442
+ Me as createCameraHelper,
443
+ Te as createGridHelper,
444
+ Ye as createInfoPlane,
445
+ Ee as createMapControls,
409
446
  j as createOrbitControl,
410
- Ee as createRaycaster,
411
- Le as createStats,
412
- Pe as createTagPlane,
413
- Te as dataToObject3D,
414
- Oe as dataToObject3DSync,
447
+ Le as createRaycaster,
448
+ Oe as createStats,
449
+ Be as createTagPlane,
450
+ Ce as dataToObject3D,
451
+ ye as dataToObject3DSync,
415
452
  X as disposeThreeObject,
416
- je as getCommonParent,
417
- Ve as getObjectByUserData,
418
- qe as getRootObj,
419
- Xe as initEnvImage,
453
+ Ze as getCommonParent,
454
+ ve as getGeometryCacheStats,
455
+ Ie as getMaterialCacheStats,
456
+ Ge as getObjectByUserData,
457
+ We as getRootObj,
458
+ _e as initEnvImage,
420
459
  oe as intersectColor,
421
- Ze as modelOptimizer,
460
+ Ke as modelOptimizer,
422
461
  ie as obbObjects,
423
- Ce as object3DToData,
424
- ye as object3DToDataSync,
425
- ve as predictiveLoader,
426
- Se as rebuildScene,
462
+ Se as object3DToData,
463
+ De as object3DToDataSync,
464
+ Ae as object3DToTransferable,
465
+ He as predictiveLoader,
466
+ Ne as processInChunks,
467
+ Pe as rebuildScene,
468
+ ke as runWhenIdle,
469
+ Ue as throttle,
427
470
  ne as useBatchGLTFLoader,
428
- De as useGLTFLoader,
471
+ je as useGLTFLoader,
429
472
  re as useObb,
430
473
  ae as useRaycaster,
431
474
  le as useThreeJs