@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.
- package/CHANGELOG.md +8 -0
- package/dist/index.cjs.js +55 -55
- package/dist/index.js +4443 -4437
- package/dist/index.umd.js +56 -56
- package/libs/DigitalPerformancePlugin/core/DigitalHuman.js +73 -75
- package/libs/DigitalPerformancePlugin/index.js +2 -2
- package/libs/DigitalPerformancePlugin/mock.js +201 -193
- package/libs/base/BasePlugin.js +1 -1
- package/libs/shared-utils/logger.js +1 -1
- package/package.json +1 -1
|
@@ -1,53 +1,54 @@
|
|
|
1
|
-
import * as
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
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
|
|
7
|
-
const
|
|
8
|
-
let
|
|
9
|
-
return
|
|
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
|
|
12
|
-
const
|
|
13
|
-
let
|
|
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
|
-
|
|
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
|
-
|
|
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 [
|
|
22
|
+
return [m, S, A, b];
|
|
22
23
|
}
|
|
23
|
-
function
|
|
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,
|
|
30
|
-
if (!
|
|
30
|
+
function D(t, u) {
|
|
31
|
+
if (!u)
|
|
31
32
|
return t;
|
|
32
|
-
const
|
|
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 *
|
|
35
|
-
x * e - o *
|
|
36
|
-
x *
|
|
37
|
-
x *
|
|
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
|
|
41
|
-
const
|
|
42
|
-
return
|
|
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
|
|
45
|
-
var H, L,
|
|
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 =
|
|
48
|
+
const i = W(t.matrix), n = [
|
|
48
49
|
{
|
|
49
50
|
visible: !0,
|
|
50
|
-
timeStamp: 0 +
|
|
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 =
|
|
64
|
-
let
|
|
65
|
-
const
|
|
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,
|
|
69
|
-
const e = [];
|
|
70
|
-
if (
|
|
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
|
|
73
|
+
for (const n of l.actions)
|
|
73
74
|
if (n.duration > 0) {
|
|
74
|
-
const
|
|
75
|
-
|
|
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:
|
|
80
|
+
quaternion: r,
|
|
80
81
|
scale: o.scale,
|
|
81
82
|
animation: {
|
|
82
|
-
url:
|
|
83
|
-
repeat: !
|
|
84
|
-
needRender:
|
|
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 (!
|
|
90
|
-
const n =
|
|
91
|
-
n ? (x = n.animationUrl,
|
|
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
|
|
96
|
-
var
|
|
97
|
-
i.timeStamp +=
|
|
98
|
-
const n = e.findIndex((
|
|
99
|
-
n !== -1 ? ((
|
|
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
|
-
|
|
102
|
+
m({
|
|
102
103
|
visible: !0,
|
|
103
104
|
timeStamp: 0,
|
|
104
105
|
position: o.position,
|
|
105
|
-
quaternion:
|
|
106
|
+
quaternion: r,
|
|
106
107
|
scale: o.scale,
|
|
107
108
|
animation: {
|
|
108
109
|
url: x,
|
|
109
|
-
repeat:
|
|
110
|
+
repeat: $
|
|
110
111
|
}
|
|
111
112
|
});
|
|
112
|
-
let
|
|
113
|
-
if (
|
|
113
|
+
let S = 0;
|
|
114
|
+
if (l) {
|
|
114
115
|
let i = 0;
|
|
115
|
-
for (const n of
|
|
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
|
|
120
|
-
|
|
120
|
+
const s = k(n.rotation);
|
|
121
|
+
s && (r = D(r, s));
|
|
121
122
|
}
|
|
122
|
-
i += n.duration * 1e3,
|
|
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:
|
|
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处理完成,总延迟: ${
|
|
136
|
+
i > 0 && h.push({ start: 0 + u, end: i + u }), console.log(`初始action point处理完成,总延迟: ${S}ms`);
|
|
136
137
|
}
|
|
137
|
-
function
|
|
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
|
|
141
|
-
const
|
|
141
|
+
let b = 0;
|
|
142
|
+
const E = [];
|
|
142
143
|
for (let i = 0; i < t.track.path.length - 1; i++) {
|
|
143
|
-
const n =
|
|
144
|
-
|
|
144
|
+
const n = A(t.track.path[i], t.track.path[i + 1]);
|
|
145
|
+
E.push(n), b += n;
|
|
145
146
|
}
|
|
146
|
-
const
|
|
147
|
+
const j = b / t.track.duration;
|
|
147
148
|
console.log(`路径分析:
|
|
148
|
-
- 总距离: ${
|
|
149
|
+
- 总距离: ${b.toFixed(2)}
|
|
149
150
|
- 移动时间: ${t.track.duration}s
|
|
150
|
-
- 移动速度: ${
|
|
151
|
-
- 路径段距离: [${
|
|
152
|
-
const
|
|
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
|
|
156
|
-
for (let
|
|
157
|
-
const
|
|
158
|
-
|
|
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
|
-
|
|
161
|
+
O.set(n, y);
|
|
161
162
|
}
|
|
162
|
-
let
|
|
163
|
-
const
|
|
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],
|
|
166
|
-
|
|
167
|
-
const
|
|
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)}, 基础时间${
|
|
170
|
+
`路径段${i}: 距离${y.toFixed(2)}, 基础时间${d.toFixed(0)}-${M.toFixed(
|
|
170
171
|
0
|
|
171
|
-
)}ms, 实际时间${
|
|
172
|
-
),
|
|
172
|
+
)}ms, 实际时间${w.toFixed(0)}-${Q.toFixed(0)}ms`
|
|
173
|
+
), m({
|
|
173
174
|
visible: !0,
|
|
174
|
-
timeStamp:
|
|
175
|
+
timeStamp: w,
|
|
175
176
|
position: [n.x, n.y, n.z],
|
|
176
|
-
quaternion:
|
|
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
|
|
185
|
-
if (
|
|
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 = `${
|
|
190
|
-
if (
|
|
191
|
-
console.log(`跳过已处理的点位: [${
|
|
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 (
|
|
195
|
-
const
|
|
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点: 位置[${
|
|
198
|
+
`Action点: 位置[${c.point.x.toFixed(2)}, ${c.point.y.toFixed(2)}, ${c.point.z.toFixed(
|
|
198
199
|
2
|
|
199
|
-
)}], 距离${
|
|
200
|
+
)}], 距离${g.toFixed(2)}, 到达时间${F.toFixed(0)}ms`
|
|
200
201
|
);
|
|
201
|
-
let
|
|
202
|
-
const
|
|
203
|
-
|
|
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:
|
|
206
|
-
position: [
|
|
207
|
-
quaternion:
|
|
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:
|
|
211
|
-
item:
|
|
212
|
-
repeat:
|
|
213
|
-
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
|
|
217
|
-
for (const
|
|
218
|
-
if (
|
|
219
|
-
if (
|
|
220
|
-
|
|
221
|
-
const
|
|
222
|
-
|
|
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
|
|
225
|
-
|
|
225
|
+
const C = p.animationUrl !== "none" && p.animationUrl !== "x_turn";
|
|
226
|
+
m({
|
|
226
227
|
visible: !0,
|
|
227
|
-
timeStamp:
|
|
228
|
-
position: [
|
|
229
|
-
quaternion:
|
|
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:
|
|
233
|
-
repeat: !
|
|
234
|
-
needRender:
|
|
235
|
-
item: (
|
|
236
|
-
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
|
-
}),
|
|
239
|
+
}), I += p.duration * 1e3, K += p.duration * 1e3, m({
|
|
239
240
|
visible: !0,
|
|
240
|
-
timeStamp:
|
|
241
|
-
position: [
|
|
242
|
-
quaternion:
|
|
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: (
|
|
248
|
+
item: (J = p.subAction) != null && J.url ? p.subAction : void 0
|
|
248
249
|
}
|
|
249
250
|
});
|
|
250
251
|
}
|
|
251
|
-
|
|
252
|
-
`点位处理完成,已标记为已处理: [${
|
|
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
|
|
260
|
-
|
|
260
|
+
const c = M + _;
|
|
261
|
+
m({
|
|
261
262
|
visible: !0,
|
|
262
|
-
timeStamp:
|
|
263
|
-
position: [
|
|
264
|
-
quaternion:
|
|
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
|
|
274
|
-
const y = i.x - n.x,
|
|
275
|
-
if (
|
|
276
|
-
return Math.sqrt(y * y +
|
|
277
|
-
let
|
|
278
|
-
|
|
279
|
-
const
|
|
280
|
-
return Math.sqrt(
|
|
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
|
|
283
|
-
const y =
|
|
284
|
-
if (
|
|
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
|
|
287
|
-
return Math.max(0, Math.min(1,
|
|
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],
|
|
293
|
-
if (Math.abs(n.position[0] -
|
|
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
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
).normalize(),
|
|
300
|
-
let
|
|
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:
|
|
310
|
+
{ x: s.position[0], y: s.position[1], z: s.position[2] }
|
|
303
311
|
);
|
|
304
|
-
const
|
|
312
|
+
const g = {
|
|
305
313
|
visible: !0,
|
|
306
|
-
timeStamp: n.timeStamp +
|
|
314
|
+
timeStamp: n.timeStamp + a,
|
|
307
315
|
// 加上旋转走路的时间
|
|
308
|
-
position: [
|
|
316
|
+
position: [T.x, T.y, T.z],
|
|
309
317
|
// 使用计算后的位置
|
|
310
|
-
quaternion:
|
|
318
|
+
quaternion: z,
|
|
311
319
|
// 使用路径方向的quaternion
|
|
312
320
|
scale: o.scale
|
|
313
321
|
};
|
|
314
|
-
t.animationUrl !== "none" && (
|
|
322
|
+
t.animationUrl !== "none" && (g.animation = {
|
|
315
323
|
url: t.animationUrl,
|
|
316
324
|
repeat: t.repeat === "loop"
|
|
317
|
-
}), X.push(
|
|
318
|
-
for (let
|
|
319
|
-
if (e[
|
|
320
|
-
if (Math.abs(e[
|
|
321
|
-
if (
|
|
322
|
-
const
|
|
323
|
-
if (Math.abs(
|
|
324
|
-
e[
|
|
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
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
),
|
|
332
|
-
|
|
333
|
-
const
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
).clone().multiply(
|
|
339
|
-
e[
|
|
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[
|
|
350
|
+
e[f].quaternion = z.slice(), console.log(`最后一个关键帧${f}设置为路径方向`);
|
|
343
351
|
else
|
|
344
352
|
break;
|
|
345
|
-
console.log(`添加旋转动作帧,时间戳: ${n.timeStamp +
|
|
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 +
|
|
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
|
-
- 路径总距离: ${
|
|
361
|
+
- 路径总距离: ${b.toFixed(2)} 单位
|
|
354
362
|
- 基础移动时间: ${Y}ms (${t.track.duration}s)
|
|
355
|
-
- 移动速度: ${
|
|
356
|
-
- 动作延迟时间: ${
|
|
363
|
+
- 移动速度: ${j.toFixed(2)} 单位/秒
|
|
364
|
+
- 动作延迟时间: ${_}ms (${(_ / 1e3).toFixed(2)}s)
|
|
357
365
|
- 计算总时间: ${Z}ms (${(Z / 1e3).toFixed(2)}s)
|
|
358
|
-
- 实际最后时间戳: ${
|
|
366
|
+
- 实际最后时间戳: ${R == null ? void 0 : R.timeStamp}ms (${((R == null ? void 0 : R.timeStamp) / 1e3).toFixed(2)}s)
|
|
359
367
|
- 关键帧数量: ${e.length}
|
|
360
|
-
- 初始位置关键帧数量: ${
|
|
361
|
-
- 速度一致性: ${(((
|
|
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
|
-
|
|
378
|
+
rt as convertMockToPlayer
|
|
371
379
|
};
|
package/libs/base/BasePlugin.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
function A() {
|
|
2
2
|
console.debug(
|
|
3
|
-
"%c %c@realsee/dnalogel %cv3.80.
|
|
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",
|