@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
|
@@ -9,23 +9,30 @@ export declare class DigitalHuman {
|
|
|
9
9
|
items: DigitalModelPlayerItem[];
|
|
10
10
|
effects: DigitalModelPlayerEffect[];
|
|
11
11
|
digitalPlayground: any;
|
|
12
|
-
private mixer;
|
|
13
|
-
private action;
|
|
14
12
|
state: {
|
|
15
13
|
currentTime: number;
|
|
16
14
|
currentAnimation: THREE.AnimationClip | null;
|
|
15
|
+
currentAnimationRepeat: boolean;
|
|
17
16
|
playing: boolean;
|
|
18
17
|
};
|
|
19
18
|
animationFrameId: number | null;
|
|
20
|
-
private itemMatrixMap;
|
|
21
|
-
private trace;
|
|
22
19
|
curveLine: THREE.Line;
|
|
23
20
|
effectsGroup: THREE.Group;
|
|
24
21
|
effectObjects: Map<string, THREE.Mesh>;
|
|
25
22
|
container: THREE.Group;
|
|
23
|
+
private mixer;
|
|
24
|
+
private action;
|
|
25
|
+
private itemMatrixMap;
|
|
26
|
+
private trace;
|
|
26
27
|
private processedNeedRenderKeyframeIndices;
|
|
28
|
+
private attachedItems;
|
|
29
|
+
private rightHandBone;
|
|
27
30
|
constructor(model: GLTFObject, digitalPlayground: any);
|
|
28
|
-
playAnimation(animation
|
|
31
|
+
playAnimation({ animation, repeat, switchDuration }: {
|
|
32
|
+
animation: THREE.AnimationClip;
|
|
33
|
+
repeat: boolean;
|
|
34
|
+
switchDuration: number;
|
|
35
|
+
}): void;
|
|
29
36
|
pauseAnimation(): void;
|
|
30
37
|
stopAnimation(): void;
|
|
31
38
|
continueAnimation(): void;
|
|
@@ -39,7 +46,10 @@ export declare class DigitalHuman {
|
|
|
39
46
|
}): Promise<boolean>;
|
|
40
47
|
traceUpDate(): void;
|
|
41
48
|
clearTrace(): void;
|
|
49
|
+
clearProcessedNeedRenderKeyframeIndices(): void;
|
|
42
50
|
private hasProcessedNeedRenderForTimestamp;
|
|
43
51
|
private markNeedRenderProcessedForTimestamp;
|
|
44
|
-
|
|
52
|
+
private getRightHandBone;
|
|
53
|
+
private updateKeyframeItems;
|
|
54
|
+
private detachAllKeyframeItems;
|
|
45
55
|
}
|
|
@@ -1,57 +1,62 @@
|
|
|
1
|
-
var
|
|
2
|
-
var
|
|
3
|
-
var n = (
|
|
4
|
-
var M = (
|
|
5
|
-
var
|
|
1
|
+
var B = Object.defineProperty;
|
|
2
|
+
var x = (p, e, t) => e in p ? B(p, e, { enumerable: !0, configurable: !0, writable: !0, value: t }) : p[e] = t;
|
|
3
|
+
var n = (p, e, t) => (x(p, typeof e != "symbol" ? e + "" : e, t), t);
|
|
4
|
+
var M = (p, e, t) => new Promise((l, o) => {
|
|
5
|
+
var s = (d) => {
|
|
6
6
|
try {
|
|
7
|
-
|
|
7
|
+
y(t.next(d));
|
|
8
8
|
} catch (F) {
|
|
9
|
-
|
|
9
|
+
o(F);
|
|
10
10
|
}
|
|
11
|
-
},
|
|
11
|
+
}, I = (d) => {
|
|
12
12
|
try {
|
|
13
|
-
|
|
13
|
+
y(t.throw(d));
|
|
14
14
|
} catch (F) {
|
|
15
|
-
|
|
15
|
+
o(F);
|
|
16
16
|
}
|
|
17
|
-
},
|
|
18
|
-
|
|
17
|
+
}, y = (d) => d.done ? l(d.value) : Promise.resolve(d.value).then(s, I);
|
|
18
|
+
y((t = t.apply(p, e)).next());
|
|
19
19
|
});
|
|
20
|
-
import * as
|
|
21
|
-
import { DigitalStateMachine as
|
|
22
|
-
import { Trace as
|
|
23
|
-
const
|
|
24
|
-
class
|
|
25
|
-
constructor(e,
|
|
20
|
+
import * as i from "three";
|
|
21
|
+
import { DigitalStateMachine as L } from "./DigitalStateMachine.js";
|
|
22
|
+
import { Trace as S } from "./Trace.js";
|
|
23
|
+
const q = 300;
|
|
24
|
+
class D {
|
|
25
|
+
constructor(e, t) {
|
|
26
26
|
n(this, "model");
|
|
27
27
|
n(this, "keyframesManager");
|
|
28
28
|
n(this, "keyframes");
|
|
29
29
|
n(this, "items");
|
|
30
30
|
n(this, "effects");
|
|
31
31
|
n(this, "digitalPlayground");
|
|
32
|
-
n(this, "mixer");
|
|
33
|
-
n(this, "action");
|
|
34
32
|
n(this, "state");
|
|
35
33
|
n(this, "animationFrameId");
|
|
36
|
-
n(this, "itemMatrixMap");
|
|
37
|
-
n(this, "trace");
|
|
38
34
|
n(this, "curveLine");
|
|
39
35
|
n(this, "effectsGroup");
|
|
40
36
|
n(this, "effectObjects");
|
|
41
37
|
n(this, "container");
|
|
38
|
+
n(this, "mixer");
|
|
39
|
+
n(this, "action");
|
|
40
|
+
n(this, "itemMatrixMap");
|
|
41
|
+
n(this, "trace");
|
|
42
42
|
// 用于跟踪已处理的needRender keyframeIndex
|
|
43
43
|
n(this, "processedNeedRenderKeyframeIndices", /* @__PURE__ */ new Set());
|
|
44
|
-
|
|
44
|
+
// 跟踪已绑定到骨骼的 keyframe 道具(key: itemKey, value: item object)
|
|
45
|
+
n(this, "attachedItems", /* @__PURE__ */ new Map());
|
|
46
|
+
// 缓存 RightHand 骨骼
|
|
47
|
+
n(this, "rightHandBone", null);
|
|
48
|
+
this.model = e, this.model.visible = !1, this.model.mixer = null, this.mixer = new i.AnimationMixer(this.model), this.action = null, this.keyframesManager = new L(), this.keyframes = [], this.items = [], this.effects = [], this.digitalPlayground = t, this.state = {
|
|
45
49
|
currentTime: 0,
|
|
46
50
|
currentAnimation: null,
|
|
51
|
+
currentAnimationRepeat: !1,
|
|
47
52
|
playing: !1
|
|
48
|
-
}, this.animationFrameId = null, this.itemMatrixMap = /* @__PURE__ */ new Map(), this.trace = new
|
|
53
|
+
}, this.animationFrameId = null, this.itemMatrixMap = /* @__PURE__ */ new Map(), this.trace = new S(), this.curveLine = new i.Line(), this.curveLine.material = new i.LineBasicMaterial({ color: 14467195, linewidth: 5 }), this.effectsGroup = new i.Group(), this.effectObjects = /* @__PURE__ */ new Map(), this.container = new i.Group(), this.container.add(this.model), this.container.add(this.curveLine), this.container.add(this.effectsGroup);
|
|
49
54
|
}
|
|
50
|
-
playAnimation(e,
|
|
51
|
-
const
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
},
|
|
55
|
+
playAnimation({ animation: e, repeat: t, switchDuration: l }) {
|
|
56
|
+
const o = this.action, s = this.mixer.clipAction(e);
|
|
57
|
+
s.reset(), t ? (s.setLoop(i.LoopRepeat, 1 / 0), s.clampWhenFinished = !1) : (s.setLoop(i.LoopOnce, 1), s.clampWhenFinished = !0), o && (s.enabled = !0, s.setEffectiveTimeScale(1), s.crossFadeFrom(o, l / 1e3, !0)), s.play(), o && o !== s && setTimeout(() => {
|
|
58
|
+
o.stop();
|
|
59
|
+
}, l), this.action = s;
|
|
55
60
|
}
|
|
56
61
|
pauseAnimation() {
|
|
57
62
|
this.action && (this.action.paused = !0), this.animationFrameId && (cancelAnimationFrame(this.animationFrameId), this.animationFrameId = null), this.state.playing = !1;
|
|
@@ -65,93 +70,86 @@ class O {
|
|
|
65
70
|
attachItem() {
|
|
66
71
|
}
|
|
67
72
|
init() {
|
|
68
|
-
this.state.currentTime = 0, this.model.position.copy(new
|
|
73
|
+
this.state.currentTime = 0, this.model.position.copy(new i.Vector3().fromArray(this.keyframes[0].position)), this.model.quaternion.copy(new i.Quaternion().fromArray(this.keyframes[0].quaternion)), this.model.visible = this.keyframes[0].visible;
|
|
69
74
|
}
|
|
70
75
|
reset() {
|
|
71
|
-
this.state.currentTime = 0, this.keyframes && this.keyframes.length > 0 && (this.model.position.copy(new
|
|
76
|
+
this.state.currentTime = 0, this.keyframes && this.keyframes.length > 0 && (this.model.position.copy(new i.Vector3().fromArray(this.keyframes[0].position)), this.model.quaternion.copy(new i.Quaternion().fromArray(this.keyframes[0].quaternion))), this.model.visible = !1, this.container.visible = !1, this.animationFrameId && cancelAnimationFrame(this.animationFrameId), this.stopAnimation(), this.clearTrace(), this.detachAllKeyframeItems(), this.state.playing = !1;
|
|
72
77
|
}
|
|
73
78
|
play(e) {
|
|
74
79
|
return M(this, null, function* () {
|
|
75
80
|
this.clearProcessedNeedRenderKeyframeIndices();
|
|
76
|
-
const { keyframes:
|
|
77
|
-
return this.keyframes =
|
|
81
|
+
const { keyframes: t, items: l, effects: o } = e || {};
|
|
82
|
+
return this.keyframes = t || this.keyframes, this.items = l || this.items, this.effects = o || this.effects, this.state.currentAnimation = null, this.state.currentAnimationRepeat = !1, this.state.playing = !0, new Promise((s, I) => {
|
|
78
83
|
this.state.currentTime || this.init();
|
|
79
|
-
let
|
|
80
|
-
for (let
|
|
81
|
-
const
|
|
82
|
-
if (
|
|
83
|
-
let
|
|
84
|
-
const
|
|
85
|
-
if (!
|
|
84
|
+
let y = null;
|
|
85
|
+
for (let c = 0; c < this.items.length; c++) {
|
|
86
|
+
const h = this.digitalPlayground.getDigitalItem(this.items[c].model);
|
|
87
|
+
if (h) {
|
|
88
|
+
let a = null;
|
|
89
|
+
const u = this.model.children[0].children.find((f) => f instanceof i.Bone), g = this.model.children[0].children.find((f) => f instanceof i.SkinnedMesh);
|
|
90
|
+
if (!u || !g)
|
|
86
91
|
throw new Error("模型骨骼缺失");
|
|
87
92
|
if (this.model.children[0].children[2].traverse((f) => {
|
|
88
|
-
f instanceof
|
|
89
|
-
}), !
|
|
93
|
+
f instanceof i.Bone && f.name === "RightHand" && (a = f);
|
|
94
|
+
}), !a)
|
|
90
95
|
throw new Error("没有找到绑定的骨骼");
|
|
91
|
-
|
|
92
|
-
const
|
|
93
|
-
new
|
|
96
|
+
a.add(h);
|
|
97
|
+
const w = new i.Vector3(), r = new i.Quaternion(), m = new i.Vector3();
|
|
98
|
+
new i.Matrix4().fromArray(this.items[c].initialMatrix).decompose(w, r, m), h.position.copy(w), h.quaternion.copy(r), h.scale.copy(m), h.updateMatrixWorld(!0);
|
|
94
99
|
}
|
|
95
100
|
}
|
|
96
|
-
const
|
|
97
|
-
for (let
|
|
98
|
-
const
|
|
99
|
-
if (
|
|
100
|
-
const
|
|
101
|
-
for (let
|
|
102
|
-
F.load(
|
|
103
|
-
|
|
101
|
+
const d = /* @__PURE__ */ new Map(), F = new i.TextureLoader();
|
|
102
|
+
for (let c = 0; c < this.effects.length; c++) {
|
|
103
|
+
const h = this.effects[c];
|
|
104
|
+
if (h.type === "frameSequence") {
|
|
105
|
+
const a = h.keyframes;
|
|
106
|
+
for (let u = 0; u < a.length; u++)
|
|
107
|
+
F.load(a[u].image, (g) => {
|
|
108
|
+
g.name = a[u].image, d.set(a[u].image, g);
|
|
104
109
|
});
|
|
105
110
|
}
|
|
106
111
|
}
|
|
107
|
-
const
|
|
108
|
-
var
|
|
109
|
-
|
|
110
|
-
const
|
|
111
|
-
|
|
112
|
-
const
|
|
113
|
-
this.trace.addPoint(
|
|
114
|
-
const
|
|
115
|
-
if (this.curveLine.geometry =
|
|
116
|
-
this.model.visible = !1, this.container.visible = !1, this.stopAnimation(), this.model.needsRender = !0,
|
|
112
|
+
const v = (c) => {
|
|
113
|
+
var g, w;
|
|
114
|
+
y === null && (y = c);
|
|
115
|
+
const h = c - y;
|
|
116
|
+
y = c, this.state.currentTime += h;
|
|
117
|
+
const a = this.keyframesManager.getStateByTime(this.state.currentTime, this.keyframes, "model");
|
|
118
|
+
this.trace.addPoint(a.translation);
|
|
119
|
+
const u = new i.BufferGeometry().setFromPoints(this.trace.tracePoints);
|
|
120
|
+
if (this.curveLine.geometry = u, this.model.position.copy(a.translation), this.model.quaternion.copy(a.quaternion), this.model.scale.copy(a.scale), this.model.visible = a.visible, a.isFinal) {
|
|
121
|
+
this.model.visible = !1, this.container.visible = !1, this.stopAnimation(), this.model.needsRender = !0, s(!0), this.animationFrameId !== null && (cancelAnimationFrame(this.animationFrameId), this.animationFrameId = null);
|
|
117
122
|
return;
|
|
118
|
-
} else if (
|
|
119
|
-
const
|
|
120
|
-
(
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
(
|
|
124
|
-
)), this.mixer.update(
|
|
123
|
+
} else if (a.animation) {
|
|
124
|
+
const r = this.digitalPlayground.getAnimation(a.animation.url), m = a.animation.needRender, A = a.animation.repeat !== this.state.currentAnimationRepeat;
|
|
125
|
+
(r !== this.state.currentAnimation || A || m && !this.hasProcessedNeedRenderForTimestamp(a.keyframeIndex)) && (m && r === this.state.currentAnimation && this.markNeedRenderProcessedForTimestamp(a.keyframeIndex), this.state.currentAnimation = r, this.state.currentAnimationRepeat = a.animation.repeat, this.playAnimation({
|
|
126
|
+
animation: r,
|
|
127
|
+
repeat: a.animation.repeat,
|
|
128
|
+
switchDuration: (g = a.animation.switchDuration) != null ? g : q
|
|
129
|
+
})), this.mixer.update(h / 1e3), a.animation.isOver === !0 && (this.action.paused = !0, this.action.time = this.state.currentAnimation.duration, this.mixer.update(0));
|
|
125
130
|
}
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
this.items[a].keyframes,
|
|
131
|
-
"item"
|
|
132
|
-
).visible === !0 ? o.visible = !0 : o.visible = !1);
|
|
131
|
+
this.updateKeyframeItems((w = a.animation) == null ? void 0 : w.item);
|
|
132
|
+
for (let r = 0; r < this.items.length; r++) {
|
|
133
|
+
const m = this.digitalPlayground.getDigitalItem(this.items[r].model);
|
|
134
|
+
m && (this.keyframesManager.getStateByTime(this.state.currentTime, this.items[r].keyframes, "item").visible === !0 ? m.visible = !0 : m.visible = !1);
|
|
133
135
|
}
|
|
134
|
-
for (let
|
|
135
|
-
const
|
|
136
|
-
if (
|
|
137
|
-
const
|
|
138
|
-
if (!this.effectObjects.has(
|
|
139
|
-
const
|
|
136
|
+
for (let r = 0; r < this.effects.length; r++) {
|
|
137
|
+
const m = this.effects[r];
|
|
138
|
+
if (m.type === "frameSequence") {
|
|
139
|
+
const A = m.type + r;
|
|
140
|
+
if (!this.effectObjects.has(A)) {
|
|
141
|
+
const R = new i.PlaneGeometry(1, 1), b = new i.MeshBasicMaterial({
|
|
140
142
|
transparent: !0
|
|
141
|
-
}),
|
|
142
|
-
|
|
143
|
+
}), k = new i.Mesh(R, b);
|
|
144
|
+
k.rotateX(-Math.PI / 2), k.position.copy(new i.Vector3().fromArray(m.position)), this.effectObjects.set(A, k), this.effectsGroup.add(k);
|
|
143
145
|
}
|
|
144
|
-
const
|
|
145
|
-
|
|
146
|
-
this.effects[a].keyframes,
|
|
147
|
-
"effect"
|
|
148
|
-
), v = l.get(f.image);
|
|
149
|
-
I.material.map = v, I.visible = f.visible;
|
|
146
|
+
const f = this.effectObjects.get(A), T = this.keyframesManager.getStateByTime(this.state.currentTime, this.effects[r].keyframes, "effect"), P = d.get(T.image);
|
|
147
|
+
f.material.map = P, f.visible = T.visible;
|
|
150
148
|
}
|
|
151
149
|
}
|
|
152
|
-
this.model.needsRender = !0, this.animationFrameId = requestAnimationFrame(
|
|
150
|
+
this.model.needsRender = !0, this.animationFrameId = requestAnimationFrame(v);
|
|
153
151
|
};
|
|
154
|
-
this.animationFrameId && (cancelAnimationFrame(this.animationFrameId), this.animationFrameId = null), this.animationFrameId = requestAnimationFrame(
|
|
152
|
+
this.animationFrameId && (cancelAnimationFrame(this.animationFrameId), this.animationFrameId = null), this.animationFrameId = requestAnimationFrame(v);
|
|
155
153
|
});
|
|
156
154
|
});
|
|
157
155
|
}
|
|
@@ -159,18 +157,22 @@ class O {
|
|
|
159
157
|
traceUpDate() {
|
|
160
158
|
this.trace.clear();
|
|
161
159
|
for (let e = 0; e <= this.state.currentTime; e += 100) {
|
|
162
|
-
const
|
|
163
|
-
this.trace.addPoint(
|
|
164
|
-
const
|
|
165
|
-
this.curveLine.geometry =
|
|
160
|
+
const t = this.keyframesManager.getStateByTime(e, this.keyframes, "model");
|
|
161
|
+
this.trace.addPoint(t.translation);
|
|
162
|
+
const l = new i.BufferGeometry().setFromPoints(this.trace.tracePoints);
|
|
163
|
+
this.curveLine.geometry = l;
|
|
166
164
|
}
|
|
167
165
|
}
|
|
168
166
|
// 清楚轨迹
|
|
169
167
|
clearTrace() {
|
|
170
168
|
this.trace.clear();
|
|
171
|
-
const e = new
|
|
169
|
+
const e = new i.BufferGeometry().setFromPoints(this.trace.tracePoints);
|
|
172
170
|
this.curveLine.geometry = e;
|
|
173
171
|
}
|
|
172
|
+
// 清理已处理的keyframeIndex记录(可选,在适当的时候调用)
|
|
173
|
+
clearProcessedNeedRenderKeyframeIndices() {
|
|
174
|
+
this.processedNeedRenderKeyframeIndices.clear();
|
|
175
|
+
}
|
|
174
176
|
// 检查指定keyframeIndex的needRender是否已经处理过
|
|
175
177
|
hasProcessedNeedRenderForTimestamp(e) {
|
|
176
178
|
return this.processedNeedRenderKeyframeIndices.has(e);
|
|
@@ -179,11 +181,35 @@ class O {
|
|
|
179
181
|
markNeedRenderProcessedForTimestamp(e) {
|
|
180
182
|
this.processedNeedRenderKeyframeIndices.add(e);
|
|
181
183
|
}
|
|
182
|
-
//
|
|
183
|
-
|
|
184
|
-
|
|
184
|
+
// 获取并缓存 RightHand 骨骼
|
|
185
|
+
getRightHandBone() {
|
|
186
|
+
var e;
|
|
187
|
+
return this.rightHandBone ? this.rightHandBone : ((e = this.model.children[0].children.find((t) => t instanceof i.Bone)) == null || e.traverse((t) => {
|
|
188
|
+
t instanceof i.Bone && t.name === "RightHand" && (this.rightHandBone = t);
|
|
189
|
+
}), this.rightHandBone);
|
|
190
|
+
}
|
|
191
|
+
// 根据当前帧的 items 动态绑定/解绑道具
|
|
192
|
+
updateKeyframeItems(e) {
|
|
193
|
+
var o;
|
|
194
|
+
const t = (e == null ? void 0 : e.url) || null;
|
|
195
|
+
for (const [s, I] of this.attachedItems)
|
|
196
|
+
t !== s && ((o = I.parent) == null || o.remove(I), this.attachedItems.delete(s));
|
|
197
|
+
if (!t)
|
|
198
|
+
return;
|
|
199
|
+
const l = this.getRightHandBone();
|
|
200
|
+
if (l && !this.attachedItems.has(t)) {
|
|
201
|
+
const s = this.digitalPlayground.getDigitalItem(t);
|
|
202
|
+
s && (l.add(s), this.attachedItems.set(t, s));
|
|
203
|
+
}
|
|
204
|
+
}
|
|
205
|
+
// 解绑所有 keyframe 道具
|
|
206
|
+
detachAllKeyframeItems() {
|
|
207
|
+
var e;
|
|
208
|
+
for (const [, t] of this.attachedItems)
|
|
209
|
+
(e = t.parent) == null || e.remove(t);
|
|
210
|
+
this.attachedItems.clear();
|
|
185
211
|
}
|
|
186
212
|
}
|
|
187
213
|
export {
|
|
188
|
-
|
|
214
|
+
D as DigitalHuman
|
|
189
215
|
};
|
|
@@ -4,14 +4,13 @@ import { DigitalHuman } from './DigitalHuman';
|
|
|
4
4
|
import type { DigitalScript, DigitalChapter } from './DigitalStateMachine';
|
|
5
5
|
export declare class DigitalPlayground {
|
|
6
6
|
gltfLoader: GLTFLoader;
|
|
7
|
+
script: DigitalScript | null;
|
|
8
|
+
currentChapter: DigitalChapter | null;
|
|
7
9
|
private digitalHumanMap;
|
|
8
10
|
private digitalItemMap;
|
|
9
11
|
private skeletalAnimationMap;
|
|
10
|
-
script: DigitalScript | null;
|
|
11
|
-
currentChapter: DigitalChapter | null;
|
|
12
12
|
private debugMode;
|
|
13
13
|
constructor(debugMode?: boolean);
|
|
14
|
-
private loadGLTF;
|
|
15
14
|
setScript(script: DigitalScript): void;
|
|
16
15
|
loadModel(url: string, id?: string): Promise<DigitalHuman>;
|
|
17
16
|
loadModels(urls: string[], ids?: string[]): Promise<DigitalHuman[]>;
|
|
@@ -20,8 +19,14 @@ export declare class DigitalPlayground {
|
|
|
20
19
|
getAnimation(url: string): THREE.AnimationClip | null;
|
|
21
20
|
getDigitalHuman(url: string, id?: string): DigitalHuman | null;
|
|
22
21
|
playByChapter(chapter: DigitalChapter): Promise<any[]>;
|
|
23
|
-
loadItems(urls: string[]
|
|
24
|
-
|
|
22
|
+
loadItems(urls: string[], offsets?: Map<string, {
|
|
23
|
+
position: number[];
|
|
24
|
+
rotation: number[];
|
|
25
|
+
}>): Promise<any[]>;
|
|
26
|
+
loadItem(url: string, offset?: {
|
|
27
|
+
position: number[];
|
|
28
|
+
rotation: number[];
|
|
29
|
+
}): Promise<any>;
|
|
25
30
|
getDigitalItem(url: string): any | null;
|
|
26
31
|
pause(): void;
|
|
27
32
|
continue(): void;
|
|
@@ -31,4 +36,5 @@ export declare class DigitalPlayground {
|
|
|
31
36
|
* 销毁 playground
|
|
32
37
|
*/
|
|
33
38
|
dispose(): void;
|
|
39
|
+
private loadGLTF;
|
|
34
40
|
}
|
|
@@ -1,127 +1,131 @@
|
|
|
1
|
-
var
|
|
2
|
-
var
|
|
3
|
-
var m = (o, t,
|
|
4
|
-
var
|
|
5
|
-
var
|
|
1
|
+
var g = Object.defineProperty;
|
|
2
|
+
var u = (o, t, i) => t in o ? g(o, t, { enumerable: !0, configurable: !0, writable: !0, value: i }) : o[t] = i;
|
|
3
|
+
var m = (o, t, i) => (u(o, typeof t != "symbol" ? t + "" : t, i), i);
|
|
4
|
+
var p = (o, t, i) => new Promise((e, a) => {
|
|
5
|
+
var r = (l) => {
|
|
6
6
|
try {
|
|
7
|
-
|
|
8
|
-
} catch (
|
|
9
|
-
|
|
7
|
+
s(i.next(l));
|
|
8
|
+
} catch (h) {
|
|
9
|
+
a(h);
|
|
10
10
|
}
|
|
11
|
-
},
|
|
11
|
+
}, n = (l) => {
|
|
12
12
|
try {
|
|
13
|
-
|
|
14
|
-
} catch (
|
|
15
|
-
|
|
13
|
+
s(i.throw(l));
|
|
14
|
+
} catch (h) {
|
|
15
|
+
a(h);
|
|
16
16
|
}
|
|
17
|
-
},
|
|
18
|
-
|
|
17
|
+
}, s = (l) => l.done ? e(l.value) : Promise.resolve(l.value).then(r, n);
|
|
18
|
+
s((i = i.apply(o, t)).next());
|
|
19
19
|
});
|
|
20
|
-
import
|
|
21
|
-
import {
|
|
22
|
-
import {
|
|
23
|
-
import "
|
|
20
|
+
import * as d from "three";
|
|
21
|
+
import { GLTFLoader as M } from "@realsee/five/gltf-loader";
|
|
22
|
+
import { DigitalHuman as y } from "./DigitalHuman.js";
|
|
23
|
+
import { loadGltf as A } from "@realsee/five";
|
|
24
24
|
import "./DigitalStateMachine.js";
|
|
25
25
|
import "./Trace.js";
|
|
26
|
-
class
|
|
26
|
+
class T {
|
|
27
27
|
constructor(t = !1) {
|
|
28
28
|
m(this, "gltfLoader");
|
|
29
|
+
m(this, "script");
|
|
30
|
+
m(this, "currentChapter");
|
|
29
31
|
m(this, "digitalHumanMap");
|
|
30
32
|
m(this, "digitalItemMap");
|
|
31
33
|
m(this, "skeletalAnimationMap");
|
|
32
|
-
m(this, "script");
|
|
33
|
-
m(this, "currentChapter");
|
|
34
34
|
m(this, "debugMode");
|
|
35
|
-
this.gltfLoader = new
|
|
36
|
-
}
|
|
37
|
-
loadGLTF(t) {
|
|
38
|
-
return M(t).then((e) => {
|
|
39
|
-
const a = e == null ? void 0 : e.upAxis;
|
|
40
|
-
return e && a === "Z" && e.scene && (e.scene.rotateX(-Math.PI / 2), e.scene.updateMatrixWorld(!0)), e;
|
|
41
|
-
});
|
|
35
|
+
this.gltfLoader = new M(), this.digitalHumanMap = /* @__PURE__ */ new Map(), this.digitalItemMap = /* @__PURE__ */ new Map(), this.skeletalAnimationMap = /* @__PURE__ */ new Map(), this.script = null, this.currentChapter = null, this.debugMode = t;
|
|
42
36
|
}
|
|
43
37
|
setScript(t) {
|
|
44
38
|
this.script = t;
|
|
45
39
|
}
|
|
46
|
-
loadModel(t,
|
|
47
|
-
return
|
|
48
|
-
const
|
|
49
|
-
if (this.digitalHumanMap.has(
|
|
50
|
-
const
|
|
51
|
-
return Promise.resolve(
|
|
40
|
+
loadModel(t, i) {
|
|
41
|
+
return p(this, null, function* () {
|
|
42
|
+
const e = i ? `${t}_${i}` : t;
|
|
43
|
+
if (this.digitalHumanMap.has(e)) {
|
|
44
|
+
const a = this.digitalHumanMap.get(e);
|
|
45
|
+
return Promise.resolve(a);
|
|
52
46
|
} else
|
|
53
|
-
return new Promise((
|
|
54
|
-
t.endsWith(".gltf") || t.endsWith(".glb") ? this.loadGLTF(t).then((
|
|
55
|
-
const
|
|
56
|
-
this.digitalHumanMap.set(
|
|
57
|
-
}) :
|
|
47
|
+
return new Promise((a, r) => {
|
|
48
|
+
t.endsWith(".gltf") || t.endsWith(".glb") ? this.loadGLTF(t).then((n) => {
|
|
49
|
+
const s = n.scene, l = new y(s, this);
|
|
50
|
+
this.digitalHumanMap.set(e, l), a(l);
|
|
51
|
+
}) : r(new Error("不支持的模型格式"));
|
|
58
52
|
});
|
|
59
53
|
});
|
|
60
54
|
}
|
|
61
|
-
loadModels(t,
|
|
62
|
-
return
|
|
63
|
-
return
|
|
55
|
+
loadModels(t, i) {
|
|
56
|
+
return p(this, null, function* () {
|
|
57
|
+
return i && i.length === t.length ? Promise.all(t.map((e, a) => this.loadModel(e, i[a]))) : Promise.all(t.map((e) => this.loadModel(e)));
|
|
64
58
|
});
|
|
65
59
|
}
|
|
66
60
|
// 加载骨骼动画,暂且认为一个glb只包含一个骨骼动画
|
|
67
61
|
loadAnimation(t) {
|
|
68
|
-
return
|
|
62
|
+
return p(this, null, function* () {
|
|
69
63
|
if (this.skeletalAnimationMap.has(t)) {
|
|
70
|
-
const
|
|
71
|
-
return Promise.resolve(
|
|
64
|
+
const i = this.skeletalAnimationMap.get(t);
|
|
65
|
+
return Promise.resolve(i);
|
|
72
66
|
} else
|
|
73
|
-
return new Promise((
|
|
74
|
-
this.loadGLTF(t).then((
|
|
75
|
-
const
|
|
76
|
-
this.skeletalAnimationMap.set(t,
|
|
67
|
+
return new Promise((i, e) => {
|
|
68
|
+
this.loadGLTF(t).then((a) => {
|
|
69
|
+
const n = a.animations[0];
|
|
70
|
+
this.skeletalAnimationMap.set(t, n), i(n);
|
|
77
71
|
});
|
|
78
72
|
});
|
|
79
73
|
});
|
|
80
74
|
}
|
|
81
75
|
loadAnimations(t) {
|
|
82
|
-
return
|
|
83
|
-
return Promise.all(t.map((
|
|
76
|
+
return p(this, null, function* () {
|
|
77
|
+
return Promise.all(t.map((i) => this.loadAnimation(i)));
|
|
84
78
|
});
|
|
85
79
|
}
|
|
86
80
|
getAnimation(t) {
|
|
87
81
|
return this.skeletalAnimationMap.get(t) || null;
|
|
88
82
|
}
|
|
89
|
-
getDigitalHuman(t,
|
|
90
|
-
const
|
|
91
|
-
return this.digitalHumanMap.get(
|
|
83
|
+
getDigitalHuman(t, i) {
|
|
84
|
+
const e = i ? `${t}_${i}` : t;
|
|
85
|
+
return this.digitalHumanMap.get(e) || null;
|
|
92
86
|
}
|
|
93
87
|
playByChapter(t) {
|
|
94
|
-
return
|
|
88
|
+
return p(this, null, function* () {
|
|
95
89
|
if (!t || !Array.isArray(t.players))
|
|
96
90
|
throw new Error("Invalid chapter: chapter or chapter.players is undefined");
|
|
97
91
|
this.currentChapter = t;
|
|
98
|
-
const
|
|
99
|
-
this.digitalHumanMap.forEach((
|
|
100
|
-
|
|
92
|
+
const i = t.players.filter((a) => a.type === "model");
|
|
93
|
+
this.digitalHumanMap.forEach((a) => {
|
|
94
|
+
a.model.visible = !1, a.container.visible = !1;
|
|
101
95
|
});
|
|
102
|
-
const
|
|
103
|
-
for (let
|
|
104
|
-
const
|
|
105
|
-
|
|
96
|
+
const e = [];
|
|
97
|
+
for (let a = 0; a < i.length; a++) {
|
|
98
|
+
const r = i[a], n = `${r.model}_${r.id}`, s = this.digitalHumanMap.get(n);
|
|
99
|
+
s && (s.model.visible = !0, s.container.visible = !0, e.push(s.play({ keyframes: r.keyframes, items: [], effects: [] })));
|
|
106
100
|
}
|
|
107
|
-
return Promise.all(
|
|
101
|
+
return Promise.all(e);
|
|
108
102
|
});
|
|
109
103
|
}
|
|
110
|
-
loadItems(t) {
|
|
111
|
-
return
|
|
112
|
-
return Promise.all(t.map((e) => this.loadItem(e)));
|
|
104
|
+
loadItems(t, i) {
|
|
105
|
+
return p(this, null, function* () {
|
|
106
|
+
return Promise.all(t.map((e) => this.loadItem(e, i == null ? void 0 : i.get(e))));
|
|
113
107
|
});
|
|
114
108
|
}
|
|
115
|
-
loadItem(t) {
|
|
116
|
-
return
|
|
109
|
+
loadItem(t, i) {
|
|
110
|
+
return p(this, null, function* () {
|
|
117
111
|
if (this.digitalItemMap.has(t)) {
|
|
118
112
|
const e = this.digitalItemMap.get(t);
|
|
119
113
|
return Promise.resolve(e);
|
|
120
114
|
} else
|
|
121
115
|
return new Promise((e, a) => {
|
|
122
|
-
t.endsWith(".gltf") || t.endsWith(".glb") ? this.loadGLTF(t).then((
|
|
123
|
-
const
|
|
124
|
-
|
|
116
|
+
t.endsWith(".gltf") || t.endsWith(".glb") ? this.loadGLTF(t).then((r) => {
|
|
117
|
+
const n = r.scene;
|
|
118
|
+
if (i && (i != null && i.position) && (i != null && i.rotation)) {
|
|
119
|
+
const [s, l, h] = i.position;
|
|
120
|
+
n.position.set(s * 0.01, -l * 0.01, -h * 0.01);
|
|
121
|
+
const c = new d.Euler(
|
|
122
|
+
d.MathUtils.degToRad(i.rotation[0]),
|
|
123
|
+
d.MathUtils.degToRad(i.rotation[1]),
|
|
124
|
+
d.MathUtils.degToRad(i.rotation[2])
|
|
125
|
+
);
|
|
126
|
+
n.quaternion.setFromEuler(c);
|
|
127
|
+
}
|
|
128
|
+
this.digitalItemMap.set(t, n), e(n);
|
|
125
129
|
}) : a(new Error("不支持的模型格式"));
|
|
126
130
|
});
|
|
127
131
|
});
|
|
@@ -145,8 +149,8 @@ class w {
|
|
|
145
149
|
});
|
|
146
150
|
}
|
|
147
151
|
setTimelineTo(t) {
|
|
148
|
-
this.digitalHumanMap.forEach((
|
|
149
|
-
|
|
152
|
+
this.digitalHumanMap.forEach((i) => {
|
|
153
|
+
i.state.currentTime = t;
|
|
150
154
|
});
|
|
151
155
|
}
|
|
152
156
|
/**
|
|
@@ -157,7 +161,13 @@ class w {
|
|
|
157
161
|
t.reset();
|
|
158
162
|
}), this.digitalHumanMap.clear(), this.digitalItemMap.clear(), this.skeletalAnimationMap.clear();
|
|
159
163
|
}
|
|
164
|
+
loadGLTF(t) {
|
|
165
|
+
return A(t).then((i) => {
|
|
166
|
+
const e = i == null ? void 0 : i.upAxis;
|
|
167
|
+
return i && e === "Z" && i.scene && (i.scene.rotateX(-Math.PI / 2), i.scene.updateMatrixWorld(!0)), i;
|
|
168
|
+
});
|
|
169
|
+
}
|
|
160
170
|
}
|
|
161
171
|
export {
|
|
162
|
-
|
|
172
|
+
T as DigitalPlayground
|
|
163
173
|
};
|