@realsee/dnalogel 3.77.4 → 3.77.6

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 (74) hide show
  1. package/CHANGELOG.md +20 -11
  2. package/dist/DigitalPerformancePlugin/controller/index.d.ts +224 -0
  3. package/dist/DigitalPerformancePlugin/core/DigitalHuman.d.ts +55 -0
  4. package/dist/DigitalPerformancePlugin/core/DigitalPlayground.d.ts +40 -0
  5. package/dist/DigitalPerformancePlugin/core/DigitalStateMachine.d.ts +150 -0
  6. package/dist/DigitalPerformancePlugin/core/Trace.d.ts +9 -0
  7. package/dist/DigitalPerformancePlugin/index.d.ts +11 -0
  8. package/dist/DigitalPerformancePlugin/mock.d.ts +76 -0
  9. package/dist/DigitalPerformancePlugin/typings/index.d.ts +79 -0
  10. package/dist/PanoTagPlugin/controller/Tag/BaseTag.d.ts +5 -1
  11. package/dist/PanoTagPlugin/controller/Tag/BoxTag.d.ts +119 -0
  12. package/dist/PanoTagPlugin/controller/Tag/MaskTag.d.ts +257 -0
  13. package/dist/PanoTagPlugin/controller/Tag/MaskTag.shaders.d.ts +10 -0
  14. package/dist/PanoTagPlugin/controller/Tag/PolygonTag.d.ts +112 -0
  15. package/dist/PanoTagPlugin/controller/TagRender.d.ts +1 -1
  16. package/dist/PanoTagPlugin/controller/index.d.ts +55 -2
  17. package/dist/PanoTagPlugin/typings/controller.d.ts +10 -0
  18. package/dist/PanoTagPlugin/typings/tag/Tag.d.ts +8 -3
  19. package/dist/PanoTagPlugin/typings/tag/Utils.d.ts +50 -1
  20. package/dist/PanoTagPlugin/utils/sculptDataToBoxPosition.d.ts +6 -0
  21. package/dist/PanoTagPlugin/utils/tag/tagCheck.d.ts +6 -0
  22. package/dist/PanoTagPlugin/utils/tagPosition.d.ts +12 -3
  23. package/dist/index.cjs.js +188 -92
  24. package/dist/index.d.ts +1 -0
  25. package/dist/index.js +17508 -14249
  26. package/dist/index.umd.js +184 -88
  27. package/libs/CruisePlugin/Move.js +7 -2
  28. package/libs/CruisePlugin/Work.js +7 -2
  29. package/libs/CruisePlugin/index.js +11 -6
  30. package/libs/DigitalPerformancePlugin/controller/index.d.ts +2 -2
  31. package/libs/DigitalPerformancePlugin/controller/index.js +164 -173
  32. package/libs/DigitalPerformancePlugin/core/DigitalHuman.d.ts +16 -6
  33. package/libs/DigitalPerformancePlugin/core/DigitalHuman.js +128 -102
  34. package/libs/DigitalPerformancePlugin/core/DigitalPlayground.d.ts +11 -5
  35. package/libs/DigitalPerformancePlugin/core/DigitalPlayground.js +84 -74
  36. package/libs/DigitalPerformancePlugin/core/DigitalStateMachine.d.ts +7 -0
  37. package/libs/DigitalPerformancePlugin/mock.d.ts +6 -0
  38. package/libs/DigitalPerformancePlugin/mock.js +272 -274
  39. package/libs/GuideLinePlugin/Controller.js +9 -4
  40. package/libs/GuideLinePlugin/GuideLineItem.js +7 -2
  41. package/libs/GuideLinePlugin/GuideLineModeItem.js +7 -2
  42. package/libs/GuideLinePlugin/index.js +11 -6
  43. package/libs/PanoTagPlugin/Components/TagItem.js +122 -122
  44. package/libs/PanoTagPlugin/controller/Tag/BaseTag.d.ts +5 -1
  45. package/libs/PanoTagPlugin/controller/Tag/BaseTag.js +320 -289
  46. package/libs/PanoTagPlugin/controller/Tag/BoxTag.d.ts +119 -0
  47. package/libs/PanoTagPlugin/controller/Tag/BoxTag.js +515 -0
  48. package/libs/PanoTagPlugin/controller/Tag/MaskTag.d.ts +257 -0
  49. package/libs/PanoTagPlugin/controller/Tag/MaskTag.js +815 -0
  50. package/libs/PanoTagPlugin/controller/Tag/MaskTag.shaders.d.ts +10 -0
  51. package/libs/PanoTagPlugin/controller/Tag/MaskTag.shaders.js +94 -0
  52. package/libs/PanoTagPlugin/controller/Tag/PolygonTag.d.ts +112 -0
  53. package/libs/PanoTagPlugin/controller/Tag/PolygonTag.js +478 -0
  54. package/libs/PanoTagPlugin/controller/TagRender.d.ts +1 -1
  55. package/libs/PanoTagPlugin/controller/TagUtil.js +19 -17
  56. package/libs/PanoTagPlugin/controller/index.d.ts +55 -2
  57. package/libs/PanoTagPlugin/controller/index.js +261 -148
  58. package/libs/PanoTagPlugin/index.js +16 -11
  59. package/libs/PanoTagPlugin/typings/controller.d.ts +10 -0
  60. package/libs/PanoTagPlugin/typings/tag/Tag.d.ts +8 -3
  61. package/libs/PanoTagPlugin/typings/tag/Utils.d.ts +50 -1
  62. package/libs/PanoTagPlugin/utils/addDebugPoints.js +27 -13
  63. package/libs/PanoTagPlugin/utils/index.js +29 -26
  64. package/libs/PanoTagPlugin/utils/sculptDataToBoxPosition.d.ts +6 -0
  65. package/libs/PanoTagPlugin/utils/sculptDataToBoxPosition.js +18 -0
  66. package/libs/PanoTagPlugin/utils/tag/tagCheck.d.ts +6 -0
  67. package/libs/PanoTagPlugin/utils/tag/tagCheck.js +26 -14
  68. package/libs/PanoTagPlugin/utils/tagPosition.d.ts +12 -3
  69. package/libs/PanoTagPlugin/utils/tagPosition.js +49 -16
  70. package/libs/base/BasePlugin.js +1 -1
  71. package/libs/index.d.ts +1 -0
  72. package/libs/index.js +166 -150
  73. package/libs/shared-utils/logger.js +1 -1
  74. package/package.json +2 -2
@@ -1,373 +1,371 @@
1
- import * as F from "three";
2
- function nt(s, E = 0, v = 300) {
3
- var Y;
4
- if (!((Y = s.track) != null && Y.path) || s.track.path.length === 0) {
5
- const t = I(s.matrix), n = [
1
+ import * as _ from "three";
2
+ function J(t) {
3
+ const m = [t[12], t[13], t[14]], r = t[0], o = t[4], l = t[8], p = t[1], x = t[5], h = t[9], e = t[2], u = t[6], z = t[10], w = Math.sqrt(r * r + p * p + e * e), q = Math.sqrt(o * o + x * x + u * u), F = Math.sqrt(l * l + h * h + z * z), E = [w, q, F], N = [r / w, o / q, l / F, p / w, x / q, h / F, e / w, u / q, z / F], S = it(N);
4
+ return { position: m, quaternion: S, scale: E };
5
+ }
6
+ function it(t) {
7
+ const m = t[0] + t[4] + t[8];
8
+ let r, o = [0, 0, 0, 0];
9
+ return m > 0 ? (r = Math.sqrt(m + 1) * 2, o[3] = 0.25 * r, o[0] = (t[7] - t[5]) / r, o[1] = (t[2] - t[6]) / r, o[2] = (t[3] - t[1]) / r) : t[0] > t[4] && t[0] > t[8] ? (r = Math.sqrt(1 + t[0] - t[4] - t[8]) * 2, o[3] = (t[7] - t[5]) / r, o[0] = 0.25 * r, o[1] = (t[1] + t[3]) / r, o[2] = (t[2] + t[6]) / r) : t[4] > t[8] ? (r = Math.sqrt(1 + t[4] - t[0] - t[8]) * 2, o[3] = (t[2] - t[6]) / r, o[0] = (t[1] + t[3]) / r, o[1] = 0.25 * r, o[2] = (t[5] + t[7]) / r) : (r = Math.sqrt(1 + t[8] - t[0] - t[4]) * 2, o[3] = (t[3] - t[1]) / r, o[0] = (t[2] + t[6]) / r, o[1] = (t[5] + t[7]) / r, o[2] = 0.25 * r), o;
10
+ }
11
+ function ot({ x: t, y: m, z: r, order: o = "XYZ" }) {
12
+ const l = Math.cos(t / 2), p = Math.cos(m / 2), x = Math.cos(r / 2), h = Math.sin(t / 2), e = Math.sin(m / 2), u = Math.sin(r / 2);
13
+ let z, w, q, F;
14
+ switch (o) {
15
+ case "XYZ":
16
+ z = h * p * x + l * e * u, w = l * e * x - h * p * u, q = l * p * u + h * e * x, F = l * p * x - h * e * u;
17
+ break;
18
+ default:
19
+ z = h * p * x + l * e * u, w = l * e * x - h * p * u, q = l * p * u + h * e * x, F = l * p * x - h * e * u;
20
+ }
21
+ return [z, w, q, F];
22
+ }
23
+ function W(t) {
24
+ if (typeof t == "string" && !isNaN(Number(t)))
25
+ return [0, -(Number(t) * Math.PI) / 180, 0];
26
+ if (Array.isArray(t) && t.length === 3)
27
+ return [t[0], -t[1], t[2]];
28
+ }
29
+ function D(t, m) {
30
+ if (!m)
31
+ return t;
32
+ const r = ot({ x: m[0], y: m[1], z: m[2] }), [o, l, p, x] = r, [h, e, u, z] = t;
33
+ return [
34
+ x * h + o * z + l * u - p * e,
35
+ x * e - o * u + l * z + p * h,
36
+ x * u + o * e - l * h + p * z,
37
+ x * z - o * h - l * e - p * u
38
+ ];
39
+ }
40
+ function et(t, m) {
41
+ const r = new _.Vector3(m.x - t.x, m.y - t.y, m.z - t.z).normalize(), o = new _.Vector3(0, 0, 1), l = new _.Quaternion();
42
+ return l.setFromUnitVectors(o, r), [l.x, l.y, l.z, l.w];
43
+ }
44
+ function st(t, m = 0, r = 300) {
45
+ var H, L, O, V;
46
+ if (!((H = t.track) != null && H.path) || t.track.path.length === 0) {
47
+ const i = J(t.matrix), n = [
6
48
  {
7
49
  visible: !0,
8
- timeStamp: 0 + E,
9
- position: t.position,
10
- quaternion: t.quaternion,
11
- scale: t.scale
50
+ timeStamp: 0 + m,
51
+ position: i.position,
52
+ quaternion: i.quaternion,
53
+ scale: i.scale
12
54
  }
13
55
  ];
14
56
  return {
15
- name: s.name || "默认角色",
57
+ name: t.name || "默认角色",
16
58
  type: "model",
17
- model: s.modelUrl,
59
+ model: t.modelUrl,
18
60
  keyframes: n
19
61
  };
20
62
  }
21
- function I(t) {
22
- const n = [t[12], t[13], t[14]], i = t[0], e = t[4], a = t[8], c = t[1], l = t[5], p = t[9], o = t[2], f = t[6], r = t[10], u = Math.sqrt(i * i + c * c + o * o), x = Math.sqrt(e * e + l * l + f * f), m = Math.sqrt(a * a + p * p + r * r), z = [u, x, m], q = [i / u, e / x, a / m, c / u, l / x, p / m, o / u, f / x, r / m], b = H(q);
23
- return { position: n, quaternion: b, scale: z };
24
- }
25
- function H(t) {
26
- const n = t[0] + t[4] + t[8];
27
- let i, e = [0, 0, 0, 0];
28
- return n > 0 ? (i = Math.sqrt(n + 1) * 2, e[3] = 0.25 * i, e[0] = (t[7] - t[5]) / i, e[1] = (t[2] - t[6]) / i, e[2] = (t[3] - t[1]) / i) : t[0] > t[4] && t[0] > t[8] ? (i = Math.sqrt(1 + t[0] - t[4] - t[8]) * 2, e[3] = (t[7] - t[5]) / i, e[0] = 0.25 * i, e[1] = (t[1] + t[3]) / i, e[2] = (t[2] + t[6]) / i) : t[4] > t[8] ? (i = Math.sqrt(1 + t[4] - t[0] - t[8]) * 2, e[3] = (t[2] - t[6]) / i, e[0] = (t[1] + t[3]) / i, e[1] = 0.25 * i, e[2] = (t[5] + t[7]) / i) : (i = Math.sqrt(1 + t[8] - t[0] - t[4]) * 2, e[3] = (t[3] - t[1]) / i, e[0] = (t[2] + t[6]) / i, e[1] = (t[5] + t[7]) / i, e[2] = 0.25 * i), e;
29
- }
30
- function L(t, n, i, e = "XYZ") {
31
- const a = Math.cos(t / 2), c = Math.cos(n / 2), l = Math.cos(i / 2), p = Math.sin(t / 2), o = Math.sin(n / 2), f = Math.sin(i / 2);
32
- let r, u, x, m;
33
- switch (e) {
34
- case "XYZ":
35
- r = p * c * l + a * o * f, u = a * o * l - p * c * f, x = a * c * f + p * o * l, m = a * c * l - p * o * f;
36
- break;
37
- default:
38
- r = p * c * l + a * o * f, u = a * o * l - p * c * f, x = a * c * f + p * o * l, m = a * c * l - p * o * f;
39
- }
40
- return [r, u, x, m];
41
- }
42
- function G(t, n) {
43
- const i = new F.Vector3(
44
- n.x - t.x,
45
- n.y - t.y,
46
- n.z - t.z
47
- ).normalize(), e = new F.Vector3(0, 0, 1), a = new F.Quaternion();
48
- return a.setFromUnitVectors(e, i), [a.x, a.y, a.z, a.w];
49
- }
50
- function N(t) {
51
- if (typeof t == "string" && !isNaN(Number(t)))
52
- return [0, -(Number(t) * Math.PI) / 180, 0];
53
- if (Array.isArray(t) && t.length === 3)
54
- return [t[0], -t[1], t[2]];
55
- }
56
- function j(t, n) {
57
- if (!n)
58
- return t;
59
- const i = L(n[0], n[1], n[2]), [e, a, c, l] = i, [p, o, f, r] = t;
60
- return [
61
- l * p + e * r + a * f - c * o,
62
- l * o - e * f + a * r + c * p,
63
- l * f + e * o - a * p + c * r,
64
- l * r - e * p - a * o - c * f
65
- ];
66
- }
67
- const h = I(s.matrix);
68
- let $ = h.quaternion.slice();
69
- const S = s.track.points.find(
70
- (t) => Math.abs(t.point.x - h.position[0]) < 1e-3 && Math.abs(t.point.y - h.position[1]) < 1e-3 && Math.abs(t.point.z - h.position[2]) < 1e-3
63
+ const o = J(t.matrix);
64
+ let l = o.quaternion.slice();
65
+ const p = t.track.points.find(
66
+ (i) => Math.abs(i.point.x - o.position[0]) < 1e-3 && Math.abs(i.point.y - o.position[1]) < 1e-3 && Math.abs(i.point.z - o.position[2]) < 1e-3
71
67
  );
72
- let P = s.animationUrl, B = s.repeat === "loop";
73
- const d = [];
74
- if (S) {
75
- let t = 0;
76
- for (const n of S.actions)
68
+ let x = t.animationUrl, h = t.repeat === "loop";
69
+ const e = [];
70
+ if (p) {
71
+ let i = 0;
72
+ for (const n of p.actions)
77
73
  if (n.duration > 0) {
78
- const i = typeof n.animationUrl == "string" && n.animationUrl && n.animationUrl.trim() && n.animationUrl !== "none" && n.animationUrl !== "x_turn";
79
- T({
74
+ const a = typeof n.animationUrl == "string" && n.animationUrl && n.animationUrl.trim() && n.animationUrl !== "none" && n.animationUrl !== "x_turn";
75
+ u({
80
76
  visible: !0,
81
- timeStamp: t,
82
- position: h.position,
83
- quaternion: $,
84
- scale: h.scale,
77
+ timeStamp: i,
78
+ position: o.position,
79
+ quaternion: l,
80
+ scale: o.scale,
85
81
  animation: {
86
- url: i ? n.animationUrl : s.animationUrl,
87
- repeat: !i,
88
- needRender: i
82
+ url: a ? n.animationUrl : t.animationUrl,
83
+ repeat: !a || (n == null ? void 0 : n.repeat),
84
+ needRender: a,
85
+ item: (L = n.subAction) != null && L.url ? n.subAction : void 0
89
86
  }
90
- }), t += n.duration * 1e3;
87
+ }), i += n.duration * 1e3;
91
88
  }
92
- if (!S.actions.some((n) => n.duration > 0)) {
93
- const n = S.actions.find(
94
- (i) => i.duration > 0 && i.animationUrl !== "none"
95
- );
96
- n ? (P = n.animationUrl, B = !1, console.log(`初始位置与action point重合,使用动作动画: ${P}`)) : console.log("初始位置与action point重合,但没有有效动作,使用默认动画");
89
+ if (!p.actions.some((n) => n.duration > 0)) {
90
+ const n = p.actions.find((a) => a.duration > 0 && a.animationUrl !== "none");
91
+ n ? (x = n.animationUrl, h = !1, console.log(`初始位置与action point重合,使用动作动画: ${x}`)) : console.log("初始位置与action point重合,但没有有效动作,使用默认动画");
97
92
  }
98
93
  } else
99
94
  console.log("初始位置独立,使用默认移动动画");
100
- function T(t) {
101
- var i, e, a;
102
- t.timeStamp += E, t.animation.url === "none" && delete t.animation;
103
- const n = d.findIndex((c) => c.timeStamp === t.timeStamp);
104
- n !== -1 ? ((i = d[n].animation) == null ? void 0 : i.url) !== ((e = t.animation) == null ? void 0 : e.url) && t.animation && ((a = t.animation) == null ? void 0 : a.url) !== s.animationUrl && (d[n] = t) : d.push(t);
95
+ function u(i) {
96
+ var a, y, f;
97
+ i.timeStamp += m, i.animation.url === "none" && delete i.animation;
98
+ const n = e.findIndex(($) => $.timeStamp === i.timeStamp);
99
+ n !== -1 ? ((a = e[n].animation) == null ? void 0 : a.url) !== ((y = i.animation) == null ? void 0 : y.url) && i.animation && ((f = i.animation) == null ? void 0 : f.url) !== t.animationUrl && (e[n] = i) : e.push(i);
105
100
  }
106
- T({
101
+ u({
107
102
  visible: !0,
108
103
  timeStamp: 0,
109
- position: h.position,
110
- quaternion: $,
111
- scale: h.scale,
104
+ position: o.position,
105
+ quaternion: l,
106
+ scale: o.scale,
112
107
  animation: {
113
- url: P,
114
- repeat: B
108
+ url: x,
109
+ repeat: h
115
110
  }
116
111
  });
117
- let _ = 0;
118
- if (S) {
119
- let t = 0;
120
- for (const n of S.actions)
112
+ let z = 0;
113
+ if (p) {
114
+ let i = 0;
115
+ for (const n of p.actions)
121
116
  if (n.duration > 0 || n.animationUrl === "x_turn") {
122
117
  if (n.animationUrl === "x_turn") {
123
118
  n.duration = 1;
124
- const i = N(n.rotation);
125
- i && ($ = j($, i));
119
+ const a = W(n.rotation);
120
+ a && (l = D(l, a));
126
121
  }
127
- t += n.duration * 1e3, _ += n.duration * 1e3, T({
122
+ i += n.duration * 1e3, z += n.duration * 1e3, u({
128
123
  visible: !0,
129
- timeStamp: t,
130
- position: h.position,
131
- quaternion: $,
132
- scale: h.scale,
124
+ timeStamp: i,
125
+ position: o.position,
126
+ quaternion: l,
127
+ scale: o.scale,
133
128
  animation: {
134
- url: s.animationUrl,
129
+ url: t.animationUrl,
135
130
  // 恢复默认移动动画
136
- repeat: s.repeat === "loop"
131
+ repeat: t.repeat === "loop"
137
132
  }
138
133
  });
139
134
  }
140
- console.log(`初始action point处理完成,总延迟: ${_}ms`);
135
+ console.log(`初始action point处理完成,总延迟: ${z}ms`);
141
136
  }
142
- function J(t, n) {
143
- return Math.sqrt(
144
- Math.pow(n.x - t.x, 2) + Math.pow(n.y - t.y, 2) + Math.pow(n.z - t.z, 2)
145
- );
137
+ function w(i, n) {
138
+ return Math.sqrt(Math.pow(n.x - i.x, 2) + Math.pow(n.y - i.y, 2) + Math.pow(n.z - i.z, 2));
146
139
  }
147
- let Q = 0;
148
- const V = [];
149
- for (let t = 0; t < s.track.path.length - 1; t++) {
150
- const n = J(s.track.path[t], s.track.path[t + 1]);
151
- V.push(n), Q += n;
140
+ let q = 0;
141
+ const F = [];
142
+ for (let i = 0; i < t.track.path.length - 1; i++) {
143
+ const n = w(t.track.path[i], t.track.path[i + 1]);
144
+ F.push(n), q += n;
152
145
  }
153
- const R = Q / s.track.duration;
146
+ const E = q / t.track.duration;
154
147
  console.log(`路径分析:
155
- - 总距离: ${Q.toFixed(2)}
156
- - 移动时间: ${s.track.duration}s
157
- - 移动速度: ${R.toFixed(2)} 单位/秒
158
- - 路径段距离: [${V.map((t) => t.toFixed(2)).join(", ")}]`);
159
- let U = _, A = 0;
148
+ - 总距离: ${q.toFixed(2)}
149
+ - 移动时间: ${t.track.duration}s
150
+ - 移动速度: ${E.toFixed(2)} 单位/秒
151
+ - 路径段距离: [${F.map((i) => i.toFixed(2)).join(", ")}]`);
152
+ const N = /* @__PURE__ */ new Map();
153
+ for (const i of t.track.points) {
154
+ const n = `${i.point.x.toFixed(3)}_${i.point.y.toFixed(3)}_${i.point.z.toFixed(3)}`;
155
+ let a = 1 / 0, y = 0;
156
+ for (let f = 0; f < t.track.path.length - 1; f++) {
157
+ const $ = k(i.point, t.track.path[f], t.track.path[f + 1]);
158
+ $ < a && (a = $, y = f);
159
+ }
160
+ N.set(n, y);
161
+ }
162
+ let S = z, j = 0;
160
163
  const C = /* @__PURE__ */ new Set();
161
- for (let t = 0; t < s.track.path.length - 1; t++) {
162
- const n = s.track.path[t], i = s.track.path[t + 1], e = V[t], a = A / Q * s.track.duration * 1e3;
163
- A += e;
164
- const c = A / Q * s.track.duration * 1e3, l = a + U, p = c + U;
164
+ for (let i = 0; i < t.track.path.length - 1; i++) {
165
+ const n = t.track.path[i], a = t.track.path[i + 1], y = F[i], f = j / q * t.track.duration * 1e3;
166
+ j += y;
167
+ const $ = j / q * t.track.duration * 1e3, U = f + S, g = $ + S;
165
168
  console.log(
166
- `路径段${t}: 距离${e.toFixed(2)}, 基础时间${a.toFixed(0)}-${c.toFixed(0)}ms, 实际时间${l.toFixed(0)}-${p.toFixed(0)}ms`
167
- ), T({
169
+ `路径段${i}: 距离${y.toFixed(2)}, 基础时间${f.toFixed(0)}-${$.toFixed(
170
+ 0
171
+ )}ms, 实际时间${U.toFixed(0)}-${g.toFixed(0)}ms`
172
+ ), u({
168
173
  visible: !0,
169
- timeStamp: l,
174
+ timeStamp: U,
170
175
  position: [n.x, n.y, n.z],
171
- quaternion: $,
172
- scale: h.scale,
176
+ quaternion: l,
177
+ scale: o.scale,
173
178
  animation: {
174
- url: s.animationUrl,
179
+ url: t.animationUrl,
175
180
  // 默认移动动画
176
- repeat: s.repeat === "loop"
181
+ repeat: t.repeat === "loop"
177
182
  }
178
183
  });
179
- for (const o of s.track.points) {
180
- if (S && o === S && t === 0) {
184
+ for (const s of t.track.points) {
185
+ if (p && s === p && i === 0) {
181
186
  console.log("跳过初始action point,已在初始关键帧中处理");
182
187
  continue;
183
188
  }
184
- const f = `${o.point.x.toFixed(3)}_${o.point.y.toFixed(3)}_${o.point.z.toFixed(3)}`;
185
- if (C.has(f)) {
186
- console.log(
187
- `跳过已处理的点位: [${o.point.x.toFixed(2)}, ${o.point.y.toFixed(2)}, ${o.point.z.toFixed(2)}]`
188
- );
189
+ const T = `${s.point.x.toFixed(3)}_${s.point.y.toFixed(3)}_${s.point.z.toFixed(3)}`;
190
+ if (C.has(T)) {
191
+ console.log(`跳过已处理的点位: [${s.point.x.toFixed(2)}, ${s.point.y.toFixed(2)}, ${s.point.z.toFixed(2)}]`);
189
192
  continue;
190
193
  }
191
- if (W(o.point, n, i)) {
192
- const r = k(o.point, n, i), u = A - e + e * r, m = u / Q * s.track.duration * 1e3 + U;
194
+ if (N.get(T) === i) {
195
+ const d = tt(s.point, n, a), M = j - y + y * d, R = M / q * t.track.duration * 1e3 + S;
193
196
  console.log(
194
- `Action点: 位置[${o.point.x.toFixed(2)}, ${o.point.y.toFixed(2)}, ${o.point.z.toFixed(2)}], 距离${u.toFixed(2)}, 到达时间${m.toFixed(0)}ms`
197
+ `Action点: 位置[${s.point.x.toFixed(2)}, ${s.point.y.toFixed(2)}, ${s.point.z.toFixed(
198
+ 2
199
+ )}], 距离${M.toFixed(2)}, 到达时间${R.toFixed(0)}ms`
195
200
  );
196
- let z = s.animationUrl;
197
- const q = o.actions.find(
198
- (y) => y.duration > 0 && y.animationUrl !== "none"
199
- );
200
- q ? (z = q.animationUrl, q.duration > 2, console.log(`到达动作点,使用该点的动画: ${z}`)) : console.log("动作点没有有效动作,使用默认移动动画"), T({
201
+ let I = t.animationUrl;
202
+ const b = s.actions.find((c) => c.duration > 0 && c.animationUrl !== "none"), A = b == null ? void 0 : b.subAction;
203
+ b ? (I = b.animationUrl, b.duration > 2, console.log(`到达动作点,使用该点的动画: ${I}`)) : console.log("动作点没有有效动作,使用默认移动动画"), u({
201
204
  visible: !0,
202
- timeStamp: m,
203
- position: [o.point.x, o.point.y, o.point.z],
204
- quaternion: $,
205
- scale: h.scale,
205
+ timeStamp: R,
206
+ position: [s.point.x, s.point.y, s.point.z],
207
+ quaternion: l,
208
+ scale: o.scale,
206
209
  animation: {
207
- url: z,
208
- repeat: !1
210
+ url: I,
211
+ item: A != null && A.url ? A : void 0,
212
+ repeat: b == null ? void 0 : b.repeat,
213
+ duration: b == null ? void 0 : b.duration
209
214
  }
210
215
  });
211
- let b = m, w = 0;
212
- for (const y of o.actions)
213
- if (y.duration > 0 || y.animationUrl === "x_turn") {
214
- if (y.animationUrl === "x_turn") {
215
- y.duration = 1;
216
- const Z = N(y.rotation);
217
- Z && ($ = j($, Z));
216
+ let P = R, K = 0;
217
+ for (const c of s.actions)
218
+ if (c.duration > 0 || c.animationUrl === "x_turn") {
219
+ if (c.animationUrl === "x_turn") {
220
+ c.duration = 1;
221
+ const G = W(c.rotation);
222
+ G && (l = D(l, G));
218
223
  }
219
- const M = y.animationUrl !== "none" && y.animationUrl !== "x_turn";
220
- T({
224
+ const B = c.animationUrl !== "none" && c.animationUrl !== "x_turn";
225
+ u({
221
226
  visible: !0,
222
- timeStamp: b,
223
- position: [o.point.x, o.point.y, o.point.z],
224
- quaternion: $,
225
- scale: h.scale,
227
+ timeStamp: P,
228
+ position: [s.point.x, s.point.y, s.point.z],
229
+ quaternion: l,
230
+ scale: o.scale,
226
231
  animation: {
227
- url: M ? y.animationUrl : s.animationUrl,
228
- repeat: !M,
229
- needRender: M
232
+ url: B ? c.animationUrl : t.animationUrl,
233
+ repeat: !B || (c == null ? void 0 : c.repeat),
234
+ needRender: B,
235
+ item: (O = c.subAction) != null && O.url ? c.subAction : void 0,
236
+ duration: c == null ? void 0 : c.duration
230
237
  }
231
- }), b += y.duration * 1e3, w += y.duration * 1e3, T({
238
+ }), P += c.duration * 1e3, K += c.duration * 1e3, u({
232
239
  visible: !0,
233
- timeStamp: b,
234
- position: [o.point.x, o.point.y, o.point.z],
235
- quaternion: $,
236
- scale: h.scale,
240
+ timeStamp: P,
241
+ position: [s.point.x, s.point.y, s.point.z],
242
+ quaternion: l,
243
+ scale: o.scale,
237
244
  animation: {
238
- url: s.animationUrl,
239
- repeat: s.repeat === "loop"
245
+ url: t.animationUrl,
246
+ repeat: t.repeat === "loop",
247
+ item: (V = c.subAction) != null && V.url ? c.subAction : void 0
240
248
  }
241
249
  });
242
250
  }
243
- U += w, C.add(f), console.log(
244
- `点位处理完成,已标记为已处理: [${o.point.x.toFixed(2)}, ${o.point.y.toFixed(2)}, ${o.point.z.toFixed(2)}]`
251
+ S += K, C.add(T), console.log(
252
+ `点位处理完成,已标记为已处理: [${s.point.x.toFixed(2)}, ${s.point.y.toFixed(2)}, ${s.point.z.toFixed(
253
+ 2
254
+ )}]`
245
255
  );
246
256
  }
247
257
  }
248
- if (t === s.track.path.length - 2) {
249
- const o = c + U;
250
- T({
258
+ if (i === t.track.path.length - 2) {
259
+ const s = $ + S;
260
+ u({
251
261
  visible: !0,
252
- timeStamp: o,
253
- position: [i.x, i.y, i.z],
254
- quaternion: $,
255
- scale: h.scale,
262
+ timeStamp: s,
263
+ position: [a.x, a.y, a.z],
264
+ quaternion: l,
265
+ scale: o.scale,
256
266
  animation: {
257
- url: s.animationUrl,
258
- repeat: s.repeat === "loop"
267
+ url: t.animationUrl,
268
+ repeat: t.repeat === "loop"
259
269
  }
260
270
  });
261
271
  }
262
272
  }
263
- function W(t, n, i, e = 0.5) {
264
- return D(t, n, i) <= e;
265
- }
266
- function D(t, n, i) {
267
- const e = t.x - n.x, a = t.y - n.y, c = t.z - n.z, l = i.x - n.x, p = i.y - n.y, o = i.z - n.z, f = e * l + a * p + c * o, r = l * l + p * p + o * o;
268
- if (r === 0)
269
- return Math.sqrt(e * e + a * a + c * c);
270
- let u = f / r;
271
- u < 0 ? u = 0 : u > 1 && (u = 1);
272
- const x = n.x + u * l, m = n.y + u * p, z = n.z + u * o, q = t.x - x, b = t.y - m, w = t.z - z;
273
- return Math.sqrt(q * q + b * b + w * w);
273
+ function k(i, n, a) {
274
+ const y = i.x - n.x, f = i.y - n.y, $ = i.z - n.z, U = a.x - n.x, g = a.y - n.y, s = a.z - n.z, T = y * U + f * g + $ * s, d = U * U + g * g + s * s;
275
+ if (d === 0)
276
+ return Math.sqrt(y * y + f * f + $ * $);
277
+ let M = T / d;
278
+ M < 0 ? M = 0 : M > 1 && (M = 1);
279
+ const v = n.x + M * U, R = n.y + M * g, I = n.z + M * s, b = i.x - v, A = i.y - R, P = i.z - I;
280
+ return Math.sqrt(b * b + A * A + P * P);
274
281
  }
275
- function k(t, n, i) {
276
- const e = i.x - n.x, a = i.y - n.y, c = i.z - n.z, l = e * e + a * a + c * c;
277
- if (l === 0)
282
+ function tt(i, n, a) {
283
+ const y = a.x - n.x, f = a.y - n.y, $ = a.z - n.z, U = y * y + f * f + $ * $;
284
+ if (U === 0)
278
285
  return 0;
279
- const p = t.x - n.x, o = t.y - n.y, f = t.z - n.z, r = p * e + o * a + f * c;
280
- return Math.max(0, Math.min(1, r / l));
286
+ const g = i.x - n.x, s = i.y - n.y, T = i.z - n.z, d = g * y + s * f + T * $;
287
+ return Math.max(0, Math.min(1, d / U));
281
288
  }
282
- d.sort((t, n) => t.timeStamp - n.timeStamp);
283
- const K = [];
284
- for (let t = 0; t < d.length - 1; t++) {
285
- const n = d[t], i = d[t + 1];
286
- if (Math.abs(n.position[0] - i.position[0]) + Math.abs(n.position[1] - i.position[1]) + Math.abs(n.position[2] - i.position[2]) > 1e-3) {
287
- console.log(`找到连续的不同位置关键帧: ${t} -> ${t + 1}`);
288
- const a = R * (v / 1e3), c = new F.Vector3(
289
- n.position[0],
290
- n.position[1],
291
- n.position[2]
292
- ), l = new F.Vector3(
293
- i.position[0] - n.position[0],
294
- i.position[1] - n.position[1],
295
- i.position[2] - n.position[2]
296
- ).normalize(), p = c.clone().add(l.multiplyScalar(a));
297
- let o = G(
289
+ e.sort((i, n) => i.timeStamp - n.timeStamp);
290
+ const X = [];
291
+ for (let i = 0; i < e.length - 1; i++) {
292
+ const n = e[i], a = e[i + 1];
293
+ if (Math.abs(n.position[0] - a.position[0]) + Math.abs(n.position[1] - a.position[1]) + Math.abs(n.position[2] - a.position[2]) > 1e-3) {
294
+ console.log(`找到连续的不同位置关键帧: ${i} -> ${i + 1}`);
295
+ const f = E * (r / 1e3), $ = new _.Vector3(n.position[0], n.position[1], n.position[2]), U = new _.Vector3(
296
+ a.position[0] - n.position[0],
297
+ a.position[1] - n.position[1],
298
+ a.position[2] - n.position[2]
299
+ ).normalize(), g = $.clone().add(U.multiplyScalar(f));
300
+ let s = et(
298
301
  { x: n.position[0], y: n.position[1], z: n.position[2] },
299
- { x: i.position[0], y: i.position[1], z: i.position[2] }
302
+ { x: a.position[0], y: a.position[1], z: a.position[2] }
300
303
  );
301
- const f = {
304
+ const T = {
302
305
  visible: !0,
303
- timeStamp: n.timeStamp + v,
306
+ timeStamp: n.timeStamp + r,
304
307
  // 加上旋转走路的时间
305
- position: [p.x, p.y, p.z],
308
+ position: [g.x, g.y, g.z],
306
309
  // 使用计算后的位置
307
- quaternion: o,
310
+ quaternion: s,
308
311
  // 使用路径方向的quaternion
309
- scale: h.scale
312
+ scale: o.scale
310
313
  };
311
- s.animationUrl !== "none" && (f.animation = {
312
- url: s.animationUrl,
313
- repeat: s.repeat === "loop"
314
- }), K.push(f);
315
- for (let r = 0; r < d.length; r++)
316
- if (d[r].timeStamp > n.timeStamp + v)
317
- if (Math.abs(d[r].position[0] - i.position[0]) < 1e-3 && Math.abs(d[r].position[1] - i.position[1]) < 1e-3 && Math.abs(d[r].position[2] - i.position[2]) < 1e-3)
318
- if (r < d.length - 1) {
319
- const u = d[r].quaternion, x = d[r + 1].quaternion;
320
- if (Math.abs(u[0] - x[0]) + Math.abs(u[1] - x[1]) + Math.abs(u[2] - x[2]) + Math.abs(u[3] - x[3]) < 1e-3)
321
- d[r].quaternion = o.slice(), console.log(`关键帧${r}没有旋转,设置为路径方向`);
314
+ t.animationUrl !== "none" && (T.animation = {
315
+ url: t.animationUrl,
316
+ repeat: t.repeat === "loop"
317
+ }), X.push(T);
318
+ for (let d = 0; d < e.length; d++)
319
+ if (e[d].timeStamp > n.timeStamp + r)
320
+ if (Math.abs(e[d].position[0] - a.position[0]) < 1e-3 && Math.abs(e[d].position[1] - a.position[1]) < 1e-3 && Math.abs(e[d].position[2] - a.position[2]) < 1e-3)
321
+ if (d < e.length - 1) {
322
+ const M = e[d].quaternion, v = e[d + 1].quaternion;
323
+ if (Math.abs(M[0] - v[0]) + Math.abs(M[1] - v[1]) + Math.abs(M[2] - v[2]) + Math.abs(M[3] - v[3]) < 1e-3)
324
+ e[d].quaternion = s.slice(), console.log(`关键帧${d}没有旋转,设置为路径方向`);
322
325
  else {
323
- const z = new F.Quaternion(), q = new F.Quaternion(
324
- u[0],
325
- u[1],
326
- u[2],
327
- u[3]
328
- ), b = new F.Quaternion(
329
- x[0],
330
- x[1],
331
- x[2],
332
- x[3]
333
- ), w = q.clone();
334
- w.conjugate(), z.copy(b).multiply(w), d[r].quaternion = o.slice();
335
- const M = new F.Quaternion(
336
- o[0],
337
- o[1],
338
- o[2],
339
- o[3]
340
- ).clone().multiply(z);
341
- d[r + 1].quaternion = [M.x, M.y, M.z, M.w], o = [M.x, M.y, M.z, M.w], console.log(`关键帧${r}发生旋转,当前帧设置为路径方向,下一帧设置为路径方向+旋转角度,更新路径方向`), r++;
326
+ const I = new _.Quaternion(), b = new _.Quaternion(
327
+ M[0],
328
+ M[1],
329
+ M[2],
330
+ M[3]
331
+ ), A = new _.Quaternion(v[0], v[1], v[2], v[3]), P = b.clone();
332
+ P.conjugate(), I.copy(A).multiply(P), e[d].quaternion = s.slice();
333
+ const c = new _.Quaternion(
334
+ s[0],
335
+ s[1],
336
+ s[2],
337
+ s[3]
338
+ ).clone().multiply(I);
339
+ e[d + 1].quaternion = [c.x, c.y, c.z, c.w], s = [c.x, c.y, c.z, c.w], console.log(`关键帧${d}发生旋转,当前帧设置为路径方向,下一帧设置为路径方向+旋转角度,更新路径方向`), d++;
342
340
  }
343
341
  } else
344
- d[r].quaternion = o.slice(), console.log(`最后一个关键帧${r}设置为路径方向`);
342
+ e[d].quaternion = s.slice(), console.log(`最后一个关键帧${d}设置为路径方向`);
345
343
  else
346
344
  break;
347
- console.log(`添加旋转动作帧,时间戳: ${n.timeStamp + v}ms`);
345
+ console.log(`添加旋转动作帧,时间戳: ${n.timeStamp + r}ms`);
348
346
  }
349
347
  }
350
- d.push(...K), d.sort((t, n) => t.timeStamp - n.timeStamp);
351
- const O = s.track.duration * 1e3, X = O + U, g = d[d.length - 1], tt = d.filter(
352
- (t) => t.timeStamp === 0 && Math.abs(t.position[0] - h.position[0]) < 1e-3 && Math.abs(t.position[1] - h.position[1]) < 1e-3 && Math.abs(t.position[2] - h.position[2]) < 1e-3
348
+ e.push(...X), e.sort((i, n) => i.timeStamp - n.timeStamp);
349
+ const Y = t.track.duration * 1e3, Z = Y + S, Q = e[e.length - 1], nt = e.filter(
350
+ (i) => i.timeStamp === 0 && Math.abs(i.position[0] - o.position[0]) < 1e-3 && Math.abs(i.position[1] - o.position[1]) < 1e-3 && Math.abs(i.position[2] - o.position[2]) < 1e-3
353
351
  );
354
352
  return console.log(`动画转换完成:
355
- - 路径总距离: ${Q.toFixed(2)} 单位
356
- - 基础移动时间: ${O}ms (${s.track.duration}s)
357
- - 移动速度: ${R.toFixed(2)} 单位/秒
358
- - 动作延迟时间: ${U}ms (${(U / 1e3).toFixed(2)}s)
359
- - 计算总时间: ${X}ms (${(X / 1e3).toFixed(2)}s)
360
- - 实际最后时间戳: ${g == null ? void 0 : g.timeStamp}ms (${((g == null ? void 0 : g.timeStamp) / 1e3).toFixed(2)}s)
361
- - 关键帧数量: ${d.length}
362
- - 初始位置关键帧数量: ${tt.length}
363
- - 速度一致性: ${(((g == null ? void 0 : g.timeStamp) - U) / 1e3 / s.track.duration * 100).toFixed(1)}% (100%为完全一致)`), {
364
- id: s.id,
365
- name: s.name || "默认角色",
353
+ - 路径总距离: ${q.toFixed(2)} 单位
354
+ - 基础移动时间: ${Y}ms (${t.track.duration}s)
355
+ - 移动速度: ${E.toFixed(2)} 单位/秒
356
+ - 动作延迟时间: ${S}ms (${(S / 1e3).toFixed(2)}s)
357
+ - 计算总时间: ${Z}ms (${(Z / 1e3).toFixed(2)}s)
358
+ - 实际最后时间戳: ${Q == null ? void 0 : Q.timeStamp}ms (${((Q == null ? void 0 : Q.timeStamp) / 1e3).toFixed(2)}s)
359
+ - 关键帧数量: ${e.length}
360
+ - 初始位置关键帧数量: ${nt.length}
361
+ - 速度一致性: ${(((Q == null ? void 0 : Q.timeStamp) - S) / 1e3 / t.track.duration * 100).toFixed(1)}% (100%为完全一致)`), {
362
+ id: t.id,
363
+ name: t.name || "默认角色",
366
364
  type: "model",
367
- model: s.modelUrl,
368
- keyframes: d
365
+ model: t.modelUrl,
366
+ keyframes: e
369
367
  };
370
368
  }
371
369
  export {
372
- nt as convertMockToPlayer
370
+ st as convertMockToPlayer
373
371
  };