@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.
- package/CHANGELOG.md +20 -11
- package/dist/DigitalPerformancePlugin/controller/index.d.ts +224 -0
- package/dist/DigitalPerformancePlugin/core/DigitalHuman.d.ts +55 -0
- package/dist/DigitalPerformancePlugin/core/DigitalPlayground.d.ts +40 -0
- package/dist/DigitalPerformancePlugin/core/DigitalStateMachine.d.ts +150 -0
- package/dist/DigitalPerformancePlugin/core/Trace.d.ts +9 -0
- package/dist/DigitalPerformancePlugin/index.d.ts +11 -0
- package/dist/DigitalPerformancePlugin/mock.d.ts +76 -0
- package/dist/DigitalPerformancePlugin/typings/index.d.ts +79 -0
- package/dist/PanoTagPlugin/controller/Tag/BaseTag.d.ts +5 -1
- package/dist/PanoTagPlugin/controller/Tag/BoxTag.d.ts +119 -0
- package/dist/PanoTagPlugin/controller/Tag/MaskTag.d.ts +257 -0
- package/dist/PanoTagPlugin/controller/Tag/MaskTag.shaders.d.ts +10 -0
- package/dist/PanoTagPlugin/controller/Tag/PolygonTag.d.ts +112 -0
- package/dist/PanoTagPlugin/controller/TagRender.d.ts +1 -1
- package/dist/PanoTagPlugin/controller/index.d.ts +55 -2
- package/dist/PanoTagPlugin/typings/controller.d.ts +10 -0
- package/dist/PanoTagPlugin/typings/tag/Tag.d.ts +8 -3
- package/dist/PanoTagPlugin/typings/tag/Utils.d.ts +50 -1
- package/dist/PanoTagPlugin/utils/sculptDataToBoxPosition.d.ts +6 -0
- package/dist/PanoTagPlugin/utils/tag/tagCheck.d.ts +6 -0
- package/dist/PanoTagPlugin/utils/tagPosition.d.ts +12 -3
- package/dist/index.cjs.js +188 -92
- package/dist/index.d.ts +1 -0
- package/dist/index.js +17508 -14249
- package/dist/index.umd.js +184 -88
- package/libs/CruisePlugin/Move.js +7 -2
- package/libs/CruisePlugin/Work.js +7 -2
- package/libs/CruisePlugin/index.js +11 -6
- package/libs/DigitalPerformancePlugin/controller/index.d.ts +2 -2
- package/libs/DigitalPerformancePlugin/controller/index.js +164 -173
- package/libs/DigitalPerformancePlugin/core/DigitalHuman.d.ts +16 -6
- package/libs/DigitalPerformancePlugin/core/DigitalHuman.js +128 -102
- package/libs/DigitalPerformancePlugin/core/DigitalPlayground.d.ts +11 -5
- package/libs/DigitalPerformancePlugin/core/DigitalPlayground.js +84 -74
- package/libs/DigitalPerformancePlugin/core/DigitalStateMachine.d.ts +7 -0
- package/libs/DigitalPerformancePlugin/mock.d.ts +6 -0
- package/libs/DigitalPerformancePlugin/mock.js +272 -274
- package/libs/GuideLinePlugin/Controller.js +9 -4
- package/libs/GuideLinePlugin/GuideLineItem.js +7 -2
- package/libs/GuideLinePlugin/GuideLineModeItem.js +7 -2
- package/libs/GuideLinePlugin/index.js +11 -6
- package/libs/PanoTagPlugin/Components/TagItem.js +122 -122
- package/libs/PanoTagPlugin/controller/Tag/BaseTag.d.ts +5 -1
- package/libs/PanoTagPlugin/controller/Tag/BaseTag.js +320 -289
- package/libs/PanoTagPlugin/controller/Tag/BoxTag.d.ts +119 -0
- package/libs/PanoTagPlugin/controller/Tag/BoxTag.js +515 -0
- package/libs/PanoTagPlugin/controller/Tag/MaskTag.d.ts +257 -0
- package/libs/PanoTagPlugin/controller/Tag/MaskTag.js +815 -0
- package/libs/PanoTagPlugin/controller/Tag/MaskTag.shaders.d.ts +10 -0
- package/libs/PanoTagPlugin/controller/Tag/MaskTag.shaders.js +94 -0
- package/libs/PanoTagPlugin/controller/Tag/PolygonTag.d.ts +112 -0
- package/libs/PanoTagPlugin/controller/Tag/PolygonTag.js +478 -0
- package/libs/PanoTagPlugin/controller/TagRender.d.ts +1 -1
- package/libs/PanoTagPlugin/controller/TagUtil.js +19 -17
- package/libs/PanoTagPlugin/controller/index.d.ts +55 -2
- package/libs/PanoTagPlugin/controller/index.js +261 -148
- package/libs/PanoTagPlugin/index.js +16 -11
- package/libs/PanoTagPlugin/typings/controller.d.ts +10 -0
- package/libs/PanoTagPlugin/typings/tag/Tag.d.ts +8 -3
- package/libs/PanoTagPlugin/typings/tag/Utils.d.ts +50 -1
- package/libs/PanoTagPlugin/utils/addDebugPoints.js +27 -13
- package/libs/PanoTagPlugin/utils/index.js +29 -26
- package/libs/PanoTagPlugin/utils/sculptDataToBoxPosition.d.ts +6 -0
- package/libs/PanoTagPlugin/utils/sculptDataToBoxPosition.js +18 -0
- package/libs/PanoTagPlugin/utils/tag/tagCheck.d.ts +6 -0
- package/libs/PanoTagPlugin/utils/tag/tagCheck.js +26 -14
- package/libs/PanoTagPlugin/utils/tagPosition.d.ts +12 -3
- package/libs/PanoTagPlugin/utils/tagPosition.js +49 -16
- package/libs/base/BasePlugin.js +1 -1
- package/libs/index.d.ts +1 -0
- package/libs/index.js +166 -150
- package/libs/shared-utils/logger.js +1 -1
- package/package.json +2 -2
|
@@ -1,373 +1,371 @@
|
|
|
1
|
-
import * as
|
|
2
|
-
function
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
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 +
|
|
9
|
-
position:
|
|
10
|
-
quaternion:
|
|
11
|
-
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:
|
|
57
|
+
name: t.name || "默认角色",
|
|
16
58
|
type: "model",
|
|
17
|
-
model:
|
|
59
|
+
model: t.modelUrl,
|
|
18
60
|
keyframes: n
|
|
19
61
|
};
|
|
20
62
|
}
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
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
|
|
73
|
-
const
|
|
74
|
-
if (
|
|
75
|
-
let
|
|
76
|
-
for (const n of
|
|
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
|
|
79
|
-
|
|
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:
|
|
82
|
-
position:
|
|
83
|
-
quaternion:
|
|
84
|
-
scale:
|
|
77
|
+
timeStamp: i,
|
|
78
|
+
position: o.position,
|
|
79
|
+
quaternion: l,
|
|
80
|
+
scale: o.scale,
|
|
85
81
|
animation: {
|
|
86
|
-
url:
|
|
87
|
-
repeat: !
|
|
88
|
-
needRender:
|
|
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
|
-
}),
|
|
87
|
+
}), i += n.duration * 1e3;
|
|
91
88
|
}
|
|
92
|
-
if (!
|
|
93
|
-
const n =
|
|
94
|
-
|
|
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
|
|
101
|
-
var
|
|
102
|
-
|
|
103
|
-
const n =
|
|
104
|
-
n !== -1 ? ((
|
|
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
|
-
|
|
101
|
+
u({
|
|
107
102
|
visible: !0,
|
|
108
103
|
timeStamp: 0,
|
|
109
|
-
position:
|
|
110
|
-
quaternion:
|
|
111
|
-
scale:
|
|
104
|
+
position: o.position,
|
|
105
|
+
quaternion: l,
|
|
106
|
+
scale: o.scale,
|
|
112
107
|
animation: {
|
|
113
|
-
url:
|
|
114
|
-
repeat:
|
|
108
|
+
url: x,
|
|
109
|
+
repeat: h
|
|
115
110
|
}
|
|
116
111
|
});
|
|
117
|
-
let
|
|
118
|
-
if (
|
|
119
|
-
let
|
|
120
|
-
for (const n of
|
|
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
|
|
125
|
-
|
|
119
|
+
const a = W(n.rotation);
|
|
120
|
+
a && (l = D(l, a));
|
|
126
121
|
}
|
|
127
|
-
|
|
122
|
+
i += n.duration * 1e3, z += n.duration * 1e3, u({
|
|
128
123
|
visible: !0,
|
|
129
|
-
timeStamp:
|
|
130
|
-
position:
|
|
131
|
-
quaternion:
|
|
132
|
-
scale:
|
|
124
|
+
timeStamp: i,
|
|
125
|
+
position: o.position,
|
|
126
|
+
quaternion: l,
|
|
127
|
+
scale: o.scale,
|
|
133
128
|
animation: {
|
|
134
|
-
url:
|
|
129
|
+
url: t.animationUrl,
|
|
135
130
|
// 恢复默认移动动画
|
|
136
|
-
repeat:
|
|
131
|
+
repeat: t.repeat === "loop"
|
|
137
132
|
}
|
|
138
133
|
});
|
|
139
134
|
}
|
|
140
|
-
console.log(`初始action point处理完成,总延迟: ${
|
|
135
|
+
console.log(`初始action point处理完成,总延迟: ${z}ms`);
|
|
141
136
|
}
|
|
142
|
-
function
|
|
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
|
|
148
|
-
const
|
|
149
|
-
for (let
|
|
150
|
-
const n =
|
|
151
|
-
|
|
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
|
|
146
|
+
const E = q / t.track.duration;
|
|
154
147
|
console.log(`路径分析:
|
|
155
|
-
- 总距离: ${
|
|
156
|
-
- 移动时间: ${
|
|
157
|
-
- 移动速度: ${
|
|
158
|
-
- 路径段距离: [${
|
|
159
|
-
|
|
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
|
|
162
|
-
const n =
|
|
163
|
-
|
|
164
|
-
const
|
|
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
|
-
`路径段${
|
|
167
|
-
|
|
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:
|
|
174
|
+
timeStamp: U,
|
|
170
175
|
position: [n.x, n.y, n.z],
|
|
171
|
-
quaternion:
|
|
172
|
-
scale:
|
|
176
|
+
quaternion: l,
|
|
177
|
+
scale: o.scale,
|
|
173
178
|
animation: {
|
|
174
|
-
url:
|
|
179
|
+
url: t.animationUrl,
|
|
175
180
|
// 默认移动动画
|
|
176
|
-
repeat:
|
|
181
|
+
repeat: t.repeat === "loop"
|
|
177
182
|
}
|
|
178
183
|
});
|
|
179
|
-
for (const
|
|
180
|
-
if (
|
|
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
|
|
185
|
-
if (C.has(
|
|
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 (
|
|
192
|
-
const
|
|
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点: 位置[${
|
|
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
|
|
197
|
-
const
|
|
198
|
-
|
|
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:
|
|
203
|
-
position: [
|
|
204
|
-
quaternion:
|
|
205
|
-
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:
|
|
208
|
-
|
|
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
|
|
212
|
-
for (const
|
|
213
|
-
if (
|
|
214
|
-
if (
|
|
215
|
-
|
|
216
|
-
const
|
|
217
|
-
|
|
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
|
|
220
|
-
|
|
224
|
+
const B = c.animationUrl !== "none" && c.animationUrl !== "x_turn";
|
|
225
|
+
u({
|
|
221
226
|
visible: !0,
|
|
222
|
-
timeStamp:
|
|
223
|
-
position: [
|
|
224
|
-
quaternion:
|
|
225
|
-
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:
|
|
228
|
-
repeat: !
|
|
229
|
-
needRender:
|
|
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
|
-
}),
|
|
238
|
+
}), P += c.duration * 1e3, K += c.duration * 1e3, u({
|
|
232
239
|
visible: !0,
|
|
233
|
-
timeStamp:
|
|
234
|
-
position: [
|
|
235
|
-
quaternion:
|
|
236
|
-
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:
|
|
239
|
-
repeat:
|
|
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
|
-
|
|
244
|
-
`点位处理完成,已标记为已处理: [${
|
|
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 (
|
|
249
|
-
const
|
|
250
|
-
|
|
258
|
+
if (i === t.track.path.length - 2) {
|
|
259
|
+
const s = $ + S;
|
|
260
|
+
u({
|
|
251
261
|
visible: !0,
|
|
252
|
-
timeStamp:
|
|
253
|
-
position: [
|
|
254
|
-
quaternion:
|
|
255
|
-
scale:
|
|
262
|
+
timeStamp: s,
|
|
263
|
+
position: [a.x, a.y, a.z],
|
|
264
|
+
quaternion: l,
|
|
265
|
+
scale: o.scale,
|
|
256
266
|
animation: {
|
|
257
|
-
url:
|
|
258
|
-
repeat:
|
|
267
|
+
url: t.animationUrl,
|
|
268
|
+
repeat: t.repeat === "loop"
|
|
259
269
|
}
|
|
260
270
|
});
|
|
261
271
|
}
|
|
262
272
|
}
|
|
263
|
-
function
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
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
|
|
276
|
-
const
|
|
277
|
-
if (
|
|
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
|
|
280
|
-
return Math.max(0, Math.min(1,
|
|
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
|
-
|
|
283
|
-
const
|
|
284
|
-
for (let
|
|
285
|
-
const n =
|
|
286
|
-
if (Math.abs(n.position[0] -
|
|
287
|
-
console.log(`找到连续的不同位置关键帧: ${
|
|
288
|
-
const
|
|
289
|
-
n.position[0],
|
|
290
|
-
n.position[1],
|
|
291
|
-
n.position[2]
|
|
292
|
-
),
|
|
293
|
-
|
|
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:
|
|
302
|
+
{ x: a.position[0], y: a.position[1], z: a.position[2] }
|
|
300
303
|
);
|
|
301
|
-
const
|
|
304
|
+
const T = {
|
|
302
305
|
visible: !0,
|
|
303
|
-
timeStamp: n.timeStamp +
|
|
306
|
+
timeStamp: n.timeStamp + r,
|
|
304
307
|
// 加上旋转走路的时间
|
|
305
|
-
position: [
|
|
308
|
+
position: [g.x, g.y, g.z],
|
|
306
309
|
// 使用计算后的位置
|
|
307
|
-
quaternion:
|
|
310
|
+
quaternion: s,
|
|
308
311
|
// 使用路径方向的quaternion
|
|
309
|
-
scale:
|
|
312
|
+
scale: o.scale
|
|
310
313
|
};
|
|
311
|
-
|
|
312
|
-
url:
|
|
313
|
-
repeat:
|
|
314
|
-
}),
|
|
315
|
-
for (let
|
|
316
|
-
if (d
|
|
317
|
-
if (Math.abs(d
|
|
318
|
-
if (
|
|
319
|
-
const
|
|
320
|
-
if (Math.abs(
|
|
321
|
-
d
|
|
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
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
),
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
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
|
|
342
|
+
e[d].quaternion = s.slice(), console.log(`最后一个关键帧${d}设置为路径方向`);
|
|
345
343
|
else
|
|
346
344
|
break;
|
|
347
|
-
console.log(`添加旋转动作帧,时间戳: ${n.timeStamp +
|
|
345
|
+
console.log(`添加旋转动作帧,时间戳: ${n.timeStamp + r}ms`);
|
|
348
346
|
}
|
|
349
347
|
}
|
|
350
|
-
|
|
351
|
-
const
|
|
352
|
-
(
|
|
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
|
-
- 路径总距离: ${
|
|
356
|
-
- 基础移动时间: ${
|
|
357
|
-
- 移动速度: ${
|
|
358
|
-
- 动作延迟时间: ${
|
|
359
|
-
- 计算总时间: ${
|
|
360
|
-
- 实际最后时间戳: ${
|
|
361
|
-
- 关键帧数量: ${
|
|
362
|
-
- 初始位置关键帧数量: ${
|
|
363
|
-
- 速度一致性: ${(((
|
|
364
|
-
id:
|
|
365
|
-
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:
|
|
368
|
-
keyframes:
|
|
365
|
+
model: t.modelUrl,
|
|
366
|
+
keyframes: e
|
|
369
367
|
};
|
|
370
368
|
}
|
|
371
369
|
export {
|
|
372
|
-
|
|
370
|
+
st as convertMockToPlayer
|
|
373
371
|
};
|