@realsee/dnalogel 3.80.3 → 3.80.4

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,27 +1,27 @@
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) => {
1
+ var b = Object.defineProperty;
2
+ var B = (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) => (B(p, typeof e != "symbol" ? e + "" : e, t), t);
4
+ var T = (p, e, t) => new Promise((c, o) => {
5
5
  var s = (d) => {
6
6
  try {
7
- y(t.next(d));
8
- } catch (F) {
9
- o(F);
7
+ g(t.next(d));
8
+ } catch (A) {
9
+ o(A);
10
10
  }
11
- }, I = (d) => {
11
+ }, f = (d) => {
12
12
  try {
13
- y(t.throw(d));
14
- } catch (F) {
15
- o(F);
13
+ g(t.throw(d));
14
+ } catch (A) {
15
+ o(A);
16
16
  }
17
- }, y = (d) => d.done ? l(d.value) : Promise.resolve(d.value).then(s, I);
18
- y((t = t.apply(p, e)).next());
17
+ }, g = (d) => d.done ? c(d.value) : Promise.resolve(d.value).then(s, f);
18
+ g((t = t.apply(p, e)).next());
19
19
  });
20
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 {
21
+ import { DigitalStateMachine as x } from "./DigitalStateMachine.js";
22
+ import { Trace as L } from "./Trace.js";
23
+ const S = 300;
24
+ class G {
25
25
  constructor(e, t) {
26
26
  n(this, "model");
27
27
  n(this, "keyframesManager");
@@ -45,18 +45,18 @@ class D {
45
45
  n(this, "attachedItems", /* @__PURE__ */ new Map());
46
46
  // 缓存 RightHand 骨骼
47
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 = {
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 x(), this.keyframes = [], this.items = [], this.effects = [], this.digitalPlayground = t, this.state = {
49
49
  currentTime: 0,
50
50
  currentAnimation: null,
51
51
  currentAnimationRepeat: !1,
52
52
  playing: !1
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);
53
+ }, this.animationFrameId = null, this.itemMatrixMap = /* @__PURE__ */ new Map(), this.trace = new L(), 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);
54
54
  }
55
- playAnimation({ animation: e, repeat: t, switchDuration: l }) {
55
+ playAnimation({ animation: e, repeat: t, switchDuration: c }) {
56
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;
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, c / 1e3, !0)), s.play(), o && o !== s && setTimeout(() => {
58
+ o !== this.action && o.stop();
59
+ }, c), this.action = s;
60
60
  }
61
61
  pauseAnimation() {
62
62
  this.action && (this.action.paused = !0), this.animationFrameId && (cancelAnimationFrame(this.animationFrameId), this.animationFrameId = null), this.state.playing = !1;
@@ -76,80 +76,78 @@ class D {
76
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;
77
77
  }
78
78
  play(e) {
79
- return M(this, null, function* () {
79
+ return T(this, null, function* () {
80
80
  this.clearProcessedNeedRenderKeyframeIndices();
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) => {
81
+ const { keyframes: t, items: c, effects: o } = e || {};
82
+ return this.keyframes = t || this.keyframes, this.items = c || this.items, this.effects = o || this.effects, this.state.currentAnimation = null, this.state.currentAnimationRepeat = !1, this.state.playing = !0, new Promise((s) => {
83
83
  this.state.currentTime || this.init();
84
- let y = null;
85
- for (let c = 0; c < this.items.length; c++) {
86
- const h = this.digitalPlayground.getDigitalItem(this.items[c].model);
84
+ let f = null;
85
+ for (const u of this.items) {
86
+ const h = this.digitalPlayground.getDigitalItem(u.model);
87
87
  if (h) {
88
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)
89
+ const I = this.model.children[0].children.find((l) => l instanceof i.Bone), w = this.model.children[0].children.find((l) => l instanceof i.SkinnedMesh);
90
+ if (!I || !w)
91
91
  throw new Error("模型骨骼缺失");
92
- if (this.model.children[0].children[2].traverse((f) => {
93
- f instanceof i.Bone && f.name === "RightHand" && (a = f);
92
+ if (this.model.children[0].children[2].traverse((l) => {
93
+ l instanceof i.Bone && l.name === "RightHand" && (a = l);
94
94
  }), !a)
95
95
  throw new Error("没有找到绑定的骨骼");
96
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);
97
+ const F = new i.Vector3(), r = new i.Quaternion(), m = new i.Vector3();
98
+ new i.Matrix4().fromArray(u.initialMatrix).decompose(F, r, m), h.position.copy(F), h.quaternion.copy(r), h.scale.copy(m), h.updateMatrixWorld(!0);
99
99
  }
100
100
  }
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);
101
+ const g = /* @__PURE__ */ new Map(), d = new i.TextureLoader();
102
+ for (const u of this.effects)
103
+ if (u.type === "frameSequence") {
104
+ const h = u.keyframes;
105
+ for (const a of h)
106
+ d.load(a.image, (I) => {
107
+ I.name = a.image, g.set(a.image, I);
109
108
  });
110
109
  }
111
- }
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;
110
+ const A = (u) => {
111
+ var w, F;
112
+ f === null && (f = u);
113
+ const h = u - f;
114
+ f = u, this.state.currentTime += h;
117
115
  const a = this.keyframesManager.getStateByTime(this.state.currentTime, this.keyframes, "model");
118
116
  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) {
117
+ const I = new i.BufferGeometry().setFromPoints(this.trace.tracePoints);
118
+ if (this.curveLine.geometry = I, 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
119
  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);
122
120
  return;
123
121
  } 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({
122
+ const r = this.digitalPlayground.getAnimation(a.animation.url), m = a.animation.needRender, y = a.animation.repeat !== this.state.currentAnimationRepeat;
123
+ (r !== this.state.currentAnimation || y || 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
124
  animation: r,
127
125
  repeat: a.animation.repeat,
128
- switchDuration: (g = a.animation.switchDuration) != null ? g : q
126
+ switchDuration: (w = a.animation.switchDuration) != null ? w : S
129
127
  })), this.mixer.update(h / 1e3), a.animation.isOver === !0 && (this.action.paused = !0, this.action.time = this.state.currentAnimation.duration, this.mixer.update(0));
130
128
  }
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);
129
+ this.updateKeyframeItems((F = a.animation) == null ? void 0 : F.item);
130
+ for (const r of this.items) {
131
+ const m = this.digitalPlayground.getDigitalItem(r.model);
132
+ m && (this.keyframesManager.getStateByTime(this.state.currentTime, r.keyframes, "item").visible === !0 ? m.visible = !0 : m.visible = !1);
135
133
  }
136
134
  for (let r = 0; r < this.effects.length; r++) {
137
135
  const m = this.effects[r];
138
136
  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({
137
+ const y = m.type + r;
138
+ if (!this.effectObjects.has(y)) {
139
+ const P = new i.PlaneGeometry(1, 1), R = new i.MeshBasicMaterial({
142
140
  transparent: !0
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);
141
+ }), k = new i.Mesh(P, R);
142
+ k.rotateX(-Math.PI / 2), k.position.copy(new i.Vector3().fromArray(m.position)), this.effectObjects.set(y, k), this.effectsGroup.add(k);
145
143
  }
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;
144
+ const l = this.effectObjects.get(y), v = this.keyframesManager.getStateByTime(this.state.currentTime, this.effects[r].keyframes, "effect"), M = g.get(v.image);
145
+ l.material.map = M, l.visible = v.visible;
148
146
  }
149
147
  }
150
- this.model.needsRender = !0, this.animationFrameId = requestAnimationFrame(v);
148
+ this.model.needsRender = !0, this.animationFrameId = requestAnimationFrame(A);
151
149
  };
152
- this.animationFrameId && (cancelAnimationFrame(this.animationFrameId), this.animationFrameId = null), this.animationFrameId = requestAnimationFrame(v);
150
+ this.animationFrameId && (cancelAnimationFrame(this.animationFrameId), this.animationFrameId = null), this.animationFrameId = requestAnimationFrame(A);
153
151
  });
154
152
  });
155
153
  }
@@ -159,8 +157,8 @@ class D {
159
157
  for (let e = 0; e <= this.state.currentTime; e += 100) {
160
158
  const t = this.keyframesManager.getStateByTime(e, this.keyframes, "model");
161
159
  this.trace.addPoint(t.translation);
162
- const l = new i.BufferGeometry().setFromPoints(this.trace.tracePoints);
163
- this.curveLine.geometry = l;
160
+ const c = new i.BufferGeometry().setFromPoints(this.trace.tracePoints);
161
+ this.curveLine.geometry = c;
164
162
  }
165
163
  }
166
164
  // 清楚轨迹
@@ -192,14 +190,14 @@ class D {
192
190
  updateKeyframeItems(e) {
193
191
  var o;
194
192
  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));
193
+ for (const [s, f] of this.attachedItems)
194
+ t !== s && ((o = f.parent) == null || o.remove(f), this.attachedItems.delete(s));
197
195
  if (!t)
198
196
  return;
199
- const l = this.getRightHandBone();
200
- if (l && !this.attachedItems.has(t)) {
197
+ const c = this.getRightHandBone();
198
+ if (c && !this.attachedItems.has(t)) {
201
199
  const s = this.digitalPlayground.getDigitalItem(t);
202
- s && (l.add(s), this.attachedItems.set(t, s));
200
+ s && (c.add(s), this.attachedItems.set(t, s));
203
201
  }
204
202
  }
205
203
  // 解绑所有 keyframe 道具
@@ -211,5 +209,5 @@ class D {
211
209
  }
212
210
  }
213
211
  export {
214
- D as DigitalHuman
212
+ G as DigitalHuman
215
213
  };
@@ -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.4");
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.4",
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.4",
4
4
  "main": "./dist/index.js",
5
5
  "module": "./libs/index.js",
6
6
  "types": "./libs/index.d.ts",