@realsee/dnalogel 3.80.3 → 3.80.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.
@@ -1,53 +1,54 @@
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 };
1
+ import * as N from "three";
2
+ const ot = 300;
3
+ function W(t) {
4
+ const u = [t[12], t[13], t[14]], a = t[0], o = t[4], r = t[8], l = t[1], x = t[5], $ = t[9], e = t[2], h = t[6], m = t[10], S = Math.sqrt(a * a + l * l + e * e), A = Math.sqrt(o * o + x * x + h * h), b = Math.sqrt(r * r + $ * $ + m * m), E = [S, A, b], j = [a / S, o / A, r / b, l / S, x / A, $ / b, e / S, h / A, m / b], O = et(j);
5
+ return { position: u, quaternion: O, scale: E };
5
6
  }
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;
7
+ function et(t) {
8
+ const u = t[0] + t[4] + t[8];
9
+ let a, o = [0, 0, 0, 0];
10
+ return u > 0 ? (a = Math.sqrt(u + 1) * 2, o[3] = 0.25 * a, o[0] = (t[7] - t[5]) / a, o[1] = (t[2] - t[6]) / a, o[2] = (t[3] - t[1]) / a) : t[0] > t[4] && t[0] > t[8] ? (a = Math.sqrt(1 + t[0] - t[4] - t[8]) * 2, o[3] = (t[7] - t[5]) / a, o[0] = 0.25 * a, o[1] = (t[1] + t[3]) / a, o[2] = (t[2] + t[6]) / a) : t[4] > t[8] ? (a = Math.sqrt(1 + t[4] - t[0] - t[8]) * 2, o[3] = (t[2] - t[6]) / a, o[0] = (t[1] + t[3]) / a, o[1] = 0.25 * a, o[2] = (t[5] + t[7]) / a) : (a = Math.sqrt(1 + t[8] - t[0] - t[4]) * 2, o[3] = (t[3] - t[1]) / a, o[0] = (t[2] + t[6]) / a, o[1] = (t[5] + t[7]) / a, o[2] = 0.25 * a), o;
10
11
  }
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;
12
+ function st({ x: t, y: u, z: a, order: o = "XYZ" }) {
13
+ const r = Math.cos(t / 2), l = Math.cos(u / 2), x = Math.cos(a / 2), $ = Math.sin(t / 2), e = Math.sin(u / 2), h = Math.sin(a / 2);
14
+ let m, S, A, b;
14
15
  switch (o) {
15
16
  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
+ m = $ * l * x + r * e * h, S = r * e * x - $ * l * h, A = r * l * h + $ * e * x, b = r * l * x - $ * e * h;
17
18
  break;
18
19
  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
+ m = $ * l * x + r * e * h, S = r * e * x - $ * l * h, A = r * l * h + $ * e * x, b = r * l * x - $ * e * h;
20
21
  }
21
- return [z, w, q, F];
22
+ return [m, S, A, b];
22
23
  }
23
- function W(t) {
24
+ function k(t) {
24
25
  if (typeof t == "string" && !isNaN(Number(t)))
25
26
  return [0, -(Number(t) * Math.PI) / 180, 0];
26
27
  if (Array.isArray(t) && t.length === 3)
27
28
  return [t[0], -t[1], t[2]];
28
29
  }
29
- function D(t, m) {
30
- if (!m)
30
+ function D(t, u) {
31
+ if (!u)
31
32
  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
+ const a = st({ x: u[0], y: u[1], z: u[2] }), [o, r, l, x] = a, [$, e, h, m] = t;
33
34
  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
35
+ x * $ + o * m + r * h - l * e,
36
+ x * e - o * h + r * m + l * $,
37
+ x * h + o * e - r * $ + l * m,
38
+ x * m - o * $ - r * e - l * h
38
39
  ];
39
40
  }
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];
41
+ function at(t, u) {
42
+ const a = new N.Vector3(u.x - t.x, u.y - t.y, u.z - t.z).normalize(), o = new N.Vector3(0, 0, 1), r = new N.Quaternion();
43
+ return r.setFromUnitVectors(o, a), [r.x, r.y, r.z, r.w];
43
44
  }
44
- function st(t, m = 0, r = 300) {
45
- var H, L, O, V;
45
+ function rt(t, u = 0, a = 300) {
46
+ var H, L, V, J;
46
47
  if (!((H = t.track) != null && H.path) || t.track.path.length === 0) {
47
- const i = J(t.matrix), n = [
48
+ const i = W(t.matrix), n = [
48
49
  {
49
50
  visible: !0,
50
- timeStamp: 0 + m,
51
+ timeStamp: 0 + u,
51
52
  position: i.position,
52
53
  quaternion: i.quaternion,
53
54
  scale: i.scale
@@ -60,70 +61,70 @@ function st(t, m = 0, r = 300) {
60
61
  keyframes: n
61
62
  };
62
63
  }
63
- const o = J(t.matrix);
64
- let l = o.quaternion.slice();
65
- const p = t.track.points.find(
64
+ const o = W(t.matrix);
65
+ let r = o.quaternion.slice();
66
+ const l = t.track.points.find(
66
67
  (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
67
68
  );
68
- let x = t.animationUrl, h = t.repeat === "loop";
69
- const e = [];
70
- if (p) {
69
+ let x = t.animationUrl, $ = t.repeat === "loop";
70
+ const e = [], h = [];
71
+ if (l) {
71
72
  let i = 0;
72
- for (const n of p.actions)
73
+ for (const n of l.actions)
73
74
  if (n.duration > 0) {
74
- const a = typeof n.animationUrl == "string" && n.animationUrl && n.animationUrl.trim() && n.animationUrl !== "none" && n.animationUrl !== "x_turn";
75
- u({
75
+ const s = typeof n.animationUrl == "string" && n.animationUrl && n.animationUrl.trim() && n.animationUrl !== "none" && n.animationUrl !== "x_turn";
76
+ m({
76
77
  visible: !0,
77
78
  timeStamp: i,
78
79
  position: o.position,
79
- quaternion: l,
80
+ quaternion: r,
80
81
  scale: o.scale,
81
82
  animation: {
82
- url: a ? n.animationUrl : t.animationUrl,
83
- repeat: !a || (n == null ? void 0 : n.repeat),
84
- needRender: a,
83
+ url: s ? n.animationUrl : t.animationUrl,
84
+ repeat: !s || (n == null ? void 0 : n.repeat),
85
+ needRender: s,
85
86
  item: (L = n.subAction) != null && L.url ? n.subAction : void 0
86
87
  }
87
88
  }), i += n.duration * 1e3;
88
89
  }
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重合,但没有有效动作,使用默认动画");
90
+ if (!l.actions.some((n) => n.duration > 0)) {
91
+ const n = l.actions.find((s) => s.duration > 0 && s.animationUrl !== "none");
92
+ n ? (x = n.animationUrl, $ = !1, console.log(`初始位置与action point重合,使用动作动画: ${x}`)) : console.log("初始位置与action point重合,但没有有效动作,使用默认动画");
92
93
  }
93
94
  } else
94
95
  console.log("初始位置独立,使用默认移动动画");
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);
96
+ function m(i) {
97
+ var s, y, d;
98
+ i.timeStamp += u, i.animation.url === "none" && delete i.animation;
99
+ const n = e.findIndex((M) => M.timeStamp === i.timeStamp);
100
+ n !== -1 ? ((s = e[n].animation) == null ? void 0 : s.url) !== ((y = i.animation) == null ? void 0 : y.url) && i.animation && ((d = i.animation) == null ? void 0 : d.url) !== t.animationUrl && (e[n] = i) : e.push(i);
100
101
  }
101
- u({
102
+ m({
102
103
  visible: !0,
103
104
  timeStamp: 0,
104
105
  position: o.position,
105
- quaternion: l,
106
+ quaternion: r,
106
107
  scale: o.scale,
107
108
  animation: {
108
109
  url: x,
109
- repeat: h
110
+ repeat: $
110
111
  }
111
112
  });
112
- let z = 0;
113
- if (p) {
113
+ let S = 0;
114
+ if (l) {
114
115
  let i = 0;
115
- for (const n of p.actions)
116
+ for (const n of l.actions)
116
117
  if (n.duration > 0 || n.animationUrl === "x_turn") {
117
118
  if (n.animationUrl === "x_turn") {
118
119
  n.duration = 1;
119
- const a = W(n.rotation);
120
- a && (l = D(l, a));
120
+ const s = k(n.rotation);
121
+ s && (r = D(r, s));
121
122
  }
122
- i += n.duration * 1e3, z += n.duration * 1e3, u({
123
+ i += n.duration * 1e3, S += n.duration * 1e3, m({
123
124
  visible: !0,
124
125
  timeStamp: i,
125
126
  position: o.position,
126
- quaternion: l,
127
+ quaternion: r,
127
128
  scale: o.scale,
128
129
  animation: {
129
130
  url: t.animationUrl,
@@ -132,48 +133,48 @@ function st(t, m = 0, r = 300) {
132
133
  }
133
134
  });
134
135
  }
135
- console.log(`初始action point处理完成,总延迟: ${z}ms`);
136
+ i > 0 && h.push({ start: 0 + u, end: i + u }), console.log(`初始action point处理完成,总延迟: ${S}ms`);
136
137
  }
137
- function w(i, n) {
138
+ function A(i, n) {
138
139
  return Math.sqrt(Math.pow(n.x - i.x, 2) + Math.pow(n.y - i.y, 2) + Math.pow(n.z - i.z, 2));
139
140
  }
140
- let q = 0;
141
- const F = [];
141
+ let b = 0;
142
+ const E = [];
142
143
  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;
144
+ const n = A(t.track.path[i], t.track.path[i + 1]);
145
+ E.push(n), b += n;
145
146
  }
146
- const E = q / t.track.duration;
147
+ const j = b / t.track.duration;
147
148
  console.log(`路径分析:
148
- - 总距离: ${q.toFixed(2)}
149
+ - 总距离: ${b.toFixed(2)}
149
150
  - 移动时间: ${t.track.duration}s
150
- - 移动速度: ${E.toFixed(2)} 单位/秒
151
- - 路径段距离: [${F.map((i) => i.toFixed(2)).join(", ")}]`);
152
- const N = /* @__PURE__ */ new Map();
151
+ - 移动速度: ${j.toFixed(2)} 单位/秒
152
+ - 路径段距离: [${E.map((i) => i.toFixed(2)).join(", ")}]`);
153
+ const O = /* @__PURE__ */ new Map();
153
154
  for (const i of t.track.points) {
154
155
  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);
156
+ let s = 1 / 0, y = 0;
157
+ for (let d = 0; d < t.track.path.length - 1; d++) {
158
+ const M = tt(i.point, t.track.path[d], t.track.path[d + 1]);
159
+ M < s && (s = M, y = d);
159
160
  }
160
- N.set(n, y);
161
+ O.set(n, y);
161
162
  }
162
- let S = z, j = 0;
163
- const C = /* @__PURE__ */ new Set();
163
+ let _ = S, B = 0;
164
+ const G = /* @__PURE__ */ new Set();
164
165
  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;
166
+ const n = t.track.path[i], s = t.track.path[i + 1], y = E[i], d = B / b * t.track.duration * 1e3;
167
+ B += y;
168
+ const M = B / b * t.track.duration * 1e3, w = d + _, Q = M + _;
168
169
  console.log(
169
- `路径段${i}: 距离${y.toFixed(2)}, 基础时间${f.toFixed(0)}-${$.toFixed(
170
+ `路径段${i}: 距离${y.toFixed(2)}, 基础时间${d.toFixed(0)}-${M.toFixed(
170
171
  0
171
- )}ms, 实际时间${U.toFixed(0)}-${g.toFixed(0)}ms`
172
- ), u({
172
+ )}ms, 实际时间${w.toFixed(0)}-${Q.toFixed(0)}ms`
173
+ ), m({
173
174
  visible: !0,
174
- timeStamp: U,
175
+ timeStamp: w,
175
176
  position: [n.x, n.y, n.z],
176
- quaternion: l,
177
+ quaternion: r,
177
178
  scale: o.scale,
178
179
  animation: {
179
180
  url: t.animationUrl,
@@ -181,87 +182,87 @@ function st(t, m = 0, r = 300) {
181
182
  repeat: t.repeat === "loop"
182
183
  }
183
184
  });
184
- for (const s of t.track.points) {
185
- if (p && s === p && i === 0) {
185
+ for (const c of t.track.points) {
186
+ if (l && c === l && i === 0) {
186
187
  console.log("跳过初始action point,已在初始关键帧中处理");
187
188
  continue;
188
189
  }
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)}]`);
190
+ const T = `${c.point.x.toFixed(3)}_${c.point.y.toFixed(3)}_${c.point.z.toFixed(3)}`;
191
+ if (G.has(T)) {
192
+ console.log(`跳过已处理的点位: [${c.point.x.toFixed(2)}, ${c.point.y.toFixed(2)}, ${c.point.z.toFixed(2)}]`);
192
193
  continue;
193
194
  }
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;
195
+ if (O.get(T) === i) {
196
+ const z = nt(c.point, n, s), g = B - y + y * z, F = g / b * t.track.duration * 1e3 + _;
196
197
  console.log(
197
- `Action点: 位置[${s.point.x.toFixed(2)}, ${s.point.y.toFixed(2)}, ${s.point.z.toFixed(
198
+ `Action点: 位置[${c.point.x.toFixed(2)}, ${c.point.y.toFixed(2)}, ${c.point.z.toFixed(
198
199
  2
199
- )}], 距离${M.toFixed(2)}, 到达时间${R.toFixed(0)}ms`
200
+ )}], 距离${g.toFixed(2)}, 到达时间${F.toFixed(0)}ms`
200
201
  );
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({
202
+ let U = t.animationUrl;
203
+ const q = c.actions.find((p) => p.duration > 0 && p.animationUrl !== "none"), P = q == null ? void 0 : q.subAction;
204
+ q ? (U = q.animationUrl, q.duration > 2, console.log(`到达动作点,使用该点的动画: ${U}`)) : console.log("动作点没有有效动作,使用默认移动动画"), m({
204
205
  visible: !0,
205
- timeStamp: R,
206
- position: [s.point.x, s.point.y, s.point.z],
207
- quaternion: l,
206
+ timeStamp: F,
207
+ position: [c.point.x, c.point.y, c.point.z],
208
+ quaternion: r,
208
209
  scale: o.scale,
209
210
  animation: {
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
211
+ url: U,
212
+ item: P != null && P.url ? P : void 0,
213
+ repeat: q == null ? void 0 : q.repeat,
214
+ duration: q == null ? void 0 : q.duration
214
215
  }
215
216
  });
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));
217
+ let I = F, K = 0;
218
+ for (const p of c.actions)
219
+ if (p.duration > 0 || p.animationUrl === "x_turn") {
220
+ if (p.animationUrl === "x_turn") {
221
+ p.duration = 1;
222
+ const v = k(p.rotation);
223
+ v && (r = D(r, v));
223
224
  }
224
- const B = c.animationUrl !== "none" && c.animationUrl !== "x_turn";
225
- u({
225
+ const C = p.animationUrl !== "none" && p.animationUrl !== "x_turn";
226
+ m({
226
227
  visible: !0,
227
- timeStamp: P,
228
- position: [s.point.x, s.point.y, s.point.z],
229
- quaternion: l,
228
+ timeStamp: I,
229
+ position: [c.point.x, c.point.y, c.point.z],
230
+ quaternion: r,
230
231
  scale: o.scale,
231
232
  animation: {
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
233
+ url: C ? p.animationUrl : t.animationUrl,
234
+ repeat: !C || (p == null ? void 0 : p.repeat),
235
+ needRender: C,
236
+ item: (V = p.subAction) != null && V.url ? p.subAction : void 0,
237
+ duration: p == null ? void 0 : p.duration
237
238
  }
238
- }), P += c.duration * 1e3, K += c.duration * 1e3, u({
239
+ }), I += p.duration * 1e3, K += p.duration * 1e3, m({
239
240
  visible: !0,
240
- timeStamp: P,
241
- position: [s.point.x, s.point.y, s.point.z],
242
- quaternion: l,
241
+ timeStamp: I,
242
+ position: [c.point.x, c.point.y, c.point.z],
243
+ quaternion: r,
243
244
  scale: o.scale,
244
245
  animation: {
245
246
  url: t.animationUrl,
246
247
  repeat: t.repeat === "loop",
247
- item: (V = c.subAction) != null && V.url ? c.subAction : void 0
248
+ item: (J = p.subAction) != null && J.url ? p.subAction : void 0
248
249
  }
249
250
  });
250
251
  }
251
- S += K, C.add(T), console.log(
252
- `点位处理完成,已标记为已处理: [${s.point.x.toFixed(2)}, ${s.point.y.toFixed(2)}, ${s.point.z.toFixed(
252
+ _ += K, K > 0 && h.push({ start: F + u, end: I + u }), G.add(T), console.log(
253
+ `点位处理完成,已标记为已处理: [${c.point.x.toFixed(2)}, ${c.point.y.toFixed(2)}, ${c.point.z.toFixed(
253
254
  2
254
255
  )}]`
255
256
  );
256
257
  }
257
258
  }
258
259
  if (i === t.track.path.length - 2) {
259
- const s = $ + S;
260
- u({
260
+ const c = M + _;
261
+ m({
261
262
  visible: !0,
262
- timeStamp: s,
263
- position: [a.x, a.y, a.z],
264
- quaternion: l,
263
+ timeStamp: c,
264
+ position: [s.x, s.y, s.z],
265
+ quaternion: r,
265
266
  scale: o.scale,
266
267
  animation: {
267
268
  url: t.animationUrl,
@@ -270,95 +271,102 @@ function st(t, m = 0, r = 300) {
270
271
  });
271
272
  }
272
273
  }
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
+ function tt(i, n, s) {
275
+ const y = i.x - n.x, d = i.y - n.y, M = i.z - n.z, w = s.x - n.x, Q = s.y - n.y, c = s.z - n.z, T = y * w + d * Q + M * c, z = w * w + Q * Q + c * c;
276
+ if (z === 0)
277
+ return Math.sqrt(y * y + d * d + M * M);
278
+ let g = T / z;
279
+ g < 0 ? g = 0 : g > 1 && (g = 1);
280
+ const f = n.x + g * w, F = n.y + g * Q, U = n.z + g * c, q = i.x - f, P = i.y - F, I = i.z - U;
281
+ return Math.sqrt(q * q + P * P + I * I);
281
282
  }
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)
283
+ function nt(i, n, s) {
284
+ const y = s.x - n.x, d = s.y - n.y, M = s.z - n.z, w = y * y + d * d + M * M;
285
+ if (w === 0)
285
286
  return 0;
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));
287
+ const Q = i.x - n.x, c = i.y - n.y, T = i.z - n.z, z = Q * y + c * d + T * M;
288
+ return Math.max(0, Math.min(1, z / w));
288
289
  }
289
290
  e.sort((i, n) => i.timeStamp - n.timeStamp);
290
291
  const X = [];
291
292
  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) {
293
+ const n = e[i], s = e[i + 1];
294
+ if (Math.abs(n.position[0] - s.position[0]) + Math.abs(n.position[1] - s.position[1]) + Math.abs(n.position[2] - s.position[2]) > 1e-3) {
295
+ const d = n.timeStamp + a;
296
+ if (h.some(
297
+ (f) => d > f.start - ot && d < f.end
298
+ )) {
299
+ console.log(`旋转帧时刻 ${d}ms 落入动作窗口,跳过插入以保护停顿动作`);
300
+ continue;
301
+ }
294
302
  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(
303
+ const w = j * (a / 1e3), Q = new N.Vector3(n.position[0], n.position[1], n.position[2]), c = new N.Vector3(
304
+ s.position[0] - n.position[0],
305
+ s.position[1] - n.position[1],
306
+ s.position[2] - n.position[2]
307
+ ).normalize(), T = Q.clone().add(c.multiplyScalar(w));
308
+ let z = at(
301
309
  { x: n.position[0], y: n.position[1], z: n.position[2] },
302
- { x: a.position[0], y: a.position[1], z: a.position[2] }
310
+ { x: s.position[0], y: s.position[1], z: s.position[2] }
303
311
  );
304
- const T = {
312
+ const g = {
305
313
  visible: !0,
306
- timeStamp: n.timeStamp + r,
314
+ timeStamp: n.timeStamp + a,
307
315
  // 加上旋转走路的时间
308
- position: [g.x, g.y, g.z],
316
+ position: [T.x, T.y, T.z],
309
317
  // 使用计算后的位置
310
- quaternion: s,
318
+ quaternion: z,
311
319
  // 使用路径方向的quaternion
312
320
  scale: o.scale
313
321
  };
314
- t.animationUrl !== "none" && (T.animation = {
322
+ t.animationUrl !== "none" && (g.animation = {
315
323
  url: t.animationUrl,
316
324
  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}没有旋转,设置为路径方向`);
325
+ }), X.push(g);
326
+ for (let f = 0; f < e.length; f++)
327
+ if (e[f].timeStamp > n.timeStamp + a)
328
+ if (Math.abs(e[f].position[0] - s.position[0]) < 1e-3 && Math.abs(e[f].position[1] - s.position[1]) < 1e-3 && Math.abs(e[f].position[2] - s.position[2]) < 1e-3)
329
+ if (f < e.length - 1) {
330
+ const F = e[f].quaternion, U = e[f + 1].quaternion;
331
+ if (Math.abs(F[0] - U[0]) + Math.abs(F[1] - U[1]) + Math.abs(F[2] - U[2]) + Math.abs(F[3] - U[3]) < 1e-3)
332
+ e[f].quaternion = z.slice(), console.log(`关键帧${f}没有旋转,设置为路径方向`);
325
333
  else {
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++;
334
+ const P = new N.Quaternion(), I = new N.Quaternion(
335
+ F[0],
336
+ F[1],
337
+ F[2],
338
+ F[3]
339
+ ), K = new N.Quaternion(U[0], U[1], U[2], U[3]), p = I.clone();
340
+ p.conjugate(), P.copy(K).multiply(p), e[f].quaternion = z.slice();
341
+ const v = new N.Quaternion(
342
+ z[0],
343
+ z[1],
344
+ z[2],
345
+ z[3]
346
+ ).clone().multiply(P);
347
+ e[f + 1].quaternion = [v.x, v.y, v.z, v.w], z = [v.x, v.y, v.z, v.w], console.log(`关键帧${f}发生旋转,当前帧设置为路径方向,下一帧设置为路径方向+旋转角度,更新路径方向`), f++;
340
348
  }
341
349
  } else
342
- e[d].quaternion = s.slice(), console.log(`最后一个关键帧${d}设置为路径方向`);
350
+ e[f].quaternion = z.slice(), console.log(`最后一个关键帧${f}设置为路径方向`);
343
351
  else
344
352
  break;
345
- console.log(`添加旋转动作帧,时间戳: ${n.timeStamp + r}ms`);
353
+ console.log(`添加旋转动作帧,时间戳: ${n.timeStamp + a}ms`);
346
354
  }
347
355
  }
348
356
  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(
357
+ const Y = t.track.duration * 1e3, Z = Y + _, R = e[e.length - 1], it = e.filter(
350
358
  (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
351
359
  );
352
360
  return console.log(`动画转换完成:
353
- - 路径总距离: ${q.toFixed(2)} 单位
361
+ - 路径总距离: ${b.toFixed(2)} 单位
354
362
  - 基础移动时间: ${Y}ms (${t.track.duration}s)
355
- - 移动速度: ${E.toFixed(2)} 单位/秒
356
- - 动作延迟时间: ${S}ms (${(S / 1e3).toFixed(2)}s)
363
+ - 移动速度: ${j.toFixed(2)} 单位/秒
364
+ - 动作延迟时间: ${_}ms (${(_ / 1e3).toFixed(2)}s)
357
365
  - 计算总时间: ${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)
366
+ - 实际最后时间戳: ${R == null ? void 0 : R.timeStamp}ms (${((R == null ? void 0 : R.timeStamp) / 1e3).toFixed(2)}s)
359
367
  - 关键帧数量: ${e.length}
360
- - 初始位置关键帧数量: ${nt.length}
361
- - 速度一致性: ${(((Q == null ? void 0 : Q.timeStamp) - S) / 1e3 / t.track.duration * 100).toFixed(1)}% (100%为完全一致)`), {
368
+ - 初始位置关键帧数量: ${it.length}
369
+ - 速度一致性: ${(((R == null ? void 0 : R.timeStamp) - _) / 1e3 / t.track.duration * 100).toFixed(1)}% (100%为完全一致)`), {
362
370
  id: t.id,
363
371
  name: t.name || "默认角色",
364
372
  type: "model",
@@ -367,5 +375,5 @@ function st(t, m = 0, r = 300) {
367
375
  };
368
376
  }
369
377
  export {
370
- st as convertMockToPlayer
378
+ rt as convertMockToPlayer
371
379
  };
@@ -23,7 +23,7 @@ let I = class {
23
23
  /**
24
24
  * @realsee/dnalogel 版本号
25
25
  */
26
- r(this, "VERSION", "3.80.3");
26
+ r(this, "VERSION", "3.80.5");
27
27
  r(this, "NAME");
28
28
  r(this, "five");
29
29
  r(this, "workUtil");
@@ -1,6 +1,6 @@
1
1
  function A() {
2
2
  console.debug(
3
- "%c %c@realsee/dnalogel %cv3.80.3",
3
+ "%c %c@realsee/dnalogel %cv3.80.5",
4
4
  [
5
5
  "background: url('data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAkAAAAMCAMAAACHgmeRAAAABGdBTUEAALGPC/xhBQAAACBjSFJNAAB6JgAAgIQAAPoAAACA6AAAdTAAAOpgAAA6mAAAF3CculE8AAABLFBMVEUAAAAapPoap/oaqvkbrfkbr/gZnfwZoPsaqfnD4v/E4/8Ylv0clPm93/+/4P/B4f8Yj/683/8Wif+33P8Uhv+x2f8ShP+s1v8Pgf+n0/8Nf/+h0f8Lff8Lff8Nf/9dl/+czv8KfP8KfP+Lxf+Uyv+Xy/+Hwv+Jw/+Mxf+Oxv+RyP8aovsapfoap/oZmfwZm/wZnvsYnPsYkf4YlP0NePsDYfgYcfi43f+63v8Xiv8Xjf4EWfwCV/sWZ/qz2v+02/8Vh/8WiP8EUf8CTf4WXv2u1/+v2P8Thf8Thv8ETf8CR/8VV/+o1f+q1f8Qgv8Rg/8DSv8BRf8UVP+j0v+k0v8OgP8Pgf8DR/8DQv9Nhf+dzv+fz/+Kv/+Vyv+Xy/+azf+Oxv+Qx/+SyP////8MUhLdAAAAK3RSTlMACEWQ2bd98uQECPXxqO7c+Pb49vj2+Pb49vj23Oul8fMHA+TwerXXjEIG2P+bHgAAAAFiS0dEY1y+LaoAAAB+SURBVAjXY2BgZGJmYWVgYGBgY9fW0eVg4ORi4NbTNzDk4eXjZxAwMjYxNTO3EGQQsrSytrG1sxdmEHFwdHJ2cXUTZRBz9/D08vbxFWeQ8PMPCAwKDpFkkAoNC4+IjIqWZpCRlZOPiY2LV2BQVGJQTkhMUlEFWaOmrqGpxQAAyg0S9Dq+VPYAAAAASUVORK5CYII=')",
6
6
  "background-repeat: no-repeat",
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@realsee/dnalogel",
3
- "version": "3.80.3",
3
+ "version": "3.80.5",
4
4
  "main": "./dist/index.js",
5
5
  "module": "./libs/index.js",
6
6
  "types": "./libs/index.d.ts",