@hackbuild/motion-views 0.1.1 → 0.1.3

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.
@@ -13650,14 +13650,14 @@ var HackbuildMotionViews = (function(exports, three) {
13650
13650
  }
13651
13651
  };
13652
13652
  // ../../node_modules/@virgilvox/hackbuild-ui/dist/vanilla.js
13653
- const Yt = "M2 12c3-5 6.5-7 10-7s7 2 10 7c-3 5-6.5 7-10 7s-7-2-10-7zM9 12a3 3 0 1 0 6 0a3 3 0 1 0 -6 0";
13654
- const Xt = "M9 3h6v11H9zM5 11v1a7 7 0 0 0 14 0v-1M12 19v3";
13655
- const Gt = "M3 6h12v12H3zM15 10l6-3v10l-6-3";
13656
- const Je = "M3 12h16M13 6l6 6-6 6";
13657
- const Qe = "M20 12a8 8 0 1 1-3-6.2M20 4v5h-5";
13658
- const Mt = {
13659
- send: { d: Je },
13660
- microphone: { d: Xt },
13653
+ const Zt = "M2 12c3-5 6.5-7 10-7s7 2 10 7c-3 5-6.5 7-10 7s-7-2-10-7zM9 12a3 3 0 1 0 6 0a3 3 0 1 0 -6 0";
13654
+ const en = "M9 3h6v11H9zM5 11v1a7 7 0 0 0 14 0v-1M12 19v3";
13655
+ const tn = "M3 6h12v12H3zM15 10l6-3v10l-6-3";
13656
+ const et = "M3 12h16M13 6l6 6-6 6";
13657
+ const tt = "M20 12a8 8 0 1 1-3-6.2M20 4v5h-5";
13658
+ const Lt = {
13659
+ send: { d: et },
13660
+ microphone: { d: en },
13661
13661
  stop: { d: "M6 6h12v12H6z" },
13662
13662
  volume: { d: "M4 9v6h4l5 4V5L8 9zM17 8a5 5 0 0 1 0 8" },
13663
13663
  mute: { d: "M4 9v6h4l5 4V5L8 9zM17 9l4 6M21 9l-4 6" },
@@ -13669,11 +13669,11 @@ var HackbuildMotionViews = (function(exports, three) {
13669
13669
  upload: { d: "M12 16V4M7 9l5-5 5 5M4 20h16" },
13670
13670
  download: { d: "M12 4v11M7 11l5 5 5-5M5 20h14" },
13671
13671
  play: { d: "M7 5l11 7-11 7z" },
13672
- redo: { d: Qe },
13672
+ redo: { d: tt },
13673
13673
  trash: { d: "M4 7h16M9 7V4h6v3M6 7l1 13h10l1-13M10 11v6M14 11v6" },
13674
13674
  sun: { d: "M8 12a4 4 0 1 0 8 0a4 4 0 1 0 -8 0M12 2v3M12 19v3M2 12h3M19 12h3" },
13675
- "paper-plane": { d: Je },
13676
- refresh: { d: Qe },
13675
+ "paper-plane": { d: et },
13676
+ refresh: { d: tt },
13677
13677
  undo: { d: "M4 12a8 8 0 1 0 3-6.2M4 4v5h5" },
13678
13678
  plus: { d: "M12 5v14M5 12h14" },
13679
13679
  minus: { d: "M5 12h14" },
@@ -13686,7 +13686,7 @@ var HackbuildMotionViews = (function(exports, three) {
13686
13686
  link: { d: "M9 15l6-6M11 6l2-2a4 4 0 0 1 6 6l-2 2M13 18l-2 2a4 4 0 0 1-6-6l2-2" },
13687
13687
  copy: { d: "M8 8h12v12H8zM16 8V4H4v12h4" },
13688
13688
  pen: { d: "M4 20v-4L15 5l4 4L8 20zM12 8l4 4" },
13689
- eye: { d: Yt },
13689
+ eye: { d: Zt },
13690
13690
  "eye-slash": { d: "M2 12c3-5 6.5-7 10-7s7 2 10 7c-3 5-6.5 7-10 7s-7-2-10-7zM9 12a3 3 0 1 0 6 0a3 3 0 1 0 -6 0M4 4l16 16" },
13691
13691
  thumbtack: { d: "M8 3h8M10 3v6l-4 5h12l-4-5V3M12 14v7" },
13692
13692
  search: { d: "M4 10a6 6 0 1 0 12 0a6 6 0 1 0 -12 0M15 15l6 6" },
@@ -13714,7 +13714,7 @@ var HackbuildMotionViews = (function(exports, three) {
13714
13714
  wave: { d: "M2 12h3l2-4 3 9 3-13 3 13 2-5h4" },
13715
13715
  "microphone-slash": { d: "M9 3h6v11H9zM5 11v1a7 7 0 0 0 14 0v-1M12 19v3M3 3l18 18" },
13716
13716
  camera: { d: "M3 7h4l2-3h6l2 3h4v13H3zM8.5 13a3.5 3.5 0 1 0 7 0a3.5 3.5 0 1 0 -7 0" },
13717
- video: { d: Gt },
13717
+ video: { d: tn },
13718
13718
  "video-slash": { d: "M3 6h12v12H3zM15 10l6-3v10l-6-3M3 3l18 18" },
13719
13719
  image: { d: "M3 4h18v16H3zM3 16l5-5 4 4 3-3 6 6M15 8v.5" },
13720
13720
  crosshairs: { d: "M5 12a7 7 0 1 0 14 0a7 7 0 1 0 -14 0M12 2v5M12 17v5M2 12h5M17 12h5" },
@@ -13744,15 +13744,15 @@ var HackbuildMotionViews = (function(exports, three) {
13744
13744
  bucket: { d: "M5 11l7-7 7 7-7 7zM5 11h14M20 15c0 1.5-1 3-1 3s-1-1.5-1-3a1 1 0 0 1 2 0z" },
13745
13745
  hand: { d: "M8 12V5a1.5 1.5 0 0 1 3 0v6M11 10V3.5a1.5 1.5 0 0 1 3 0V10M14 10V5a1.5 1.5 0 0 1 3 0v7c0 5-3 8-7 8c-3 0-4-2-6-5l-1.5-2.5a1.5 1.5 0 0 1 2.5-1.6L8 14" }
13746
13746
  };
13747
- function Jt(e) {
13748
- return Mt[e];
13747
+ function nn(e) {
13748
+ return Lt[e];
13749
13749
  }
13750
- const Ze = (e) => e.replace(/&/g, "&amp;").replace(/"/g, "&quot;").replace(/</g, "&lt;");
13751
- function Qt(e, t = {}) {
13752
- const r = Jt(e);
13750
+ const nt = (e) => e.replace(/&/g, "&amp;").replace(/"/g, "&quot;").replace(/</g, "&lt;");
13751
+ function rn(e, t = {}) {
13752
+ const r = nn(e);
13753
13753
  if (!r) return "";
13754
13754
  const n = t.size ?? 16;
13755
- return `<svg class="${"hb-icon is-stroke" + (t.className ? " " + Ze(t.className) : "")}" width="${n}" height="${n}" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="square" stroke-linejoin="miter" ${t.label ? `role="img" aria-label="${Ze(t.label)}"` : "aria-hidden=\"true\""}><path d="${r.d}"/></svg>`;
13755
+ return `<svg class="${"hb-icon is-stroke" + (t.className ? " " + nt(t.className) : "")}" width="${n}" height="${n}" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="square" stroke-linejoin="miter" ${t.label ? `role="img" aria-label="${nt(t.label)}"` : "aria-hidden=\"true\""}><path d="${r.d}"/></svg>`;
13756
13756
  }
13757
13757
  [
13758
13758
  "a[href]",
@@ -13763,15 +13763,15 @@ var HackbuildMotionViews = (function(exports, three) {
13763
13763
  "[tabindex]",
13764
13764
  "[contenteditable=\"true\"]"
13765
13765
  ].join(",");
13766
- function Et(e) {
13766
+ function Ct(e) {
13767
13767
  return (Array.isArray(e) ? e : e.split(",")).map((t) => t.trim().toLowerCase()).filter(Boolean);
13768
13768
  }
13769
- function et(e, t) {
13769
+ function rt(e, t) {
13770
13770
  if (typeof e == "function") return e(t);
13771
13771
  const r = t.name.toLowerCase(), n = t.type.toLowerCase();
13772
- return Et(e).some((o) => o.startsWith(".") ? r.endsWith(o) : o.endsWith("/*") ? n.startsWith(o.slice(0, -1)) : n === o);
13772
+ return Ct(e).some((o) => o.startsWith(".") ? r.endsWith(o) : o.endsWith("/*") ? n.startsWith(o.slice(0, -1)) : n === o);
13773
13773
  }
13774
- async function Lt(e, t) {
13774
+ async function Tt(e, t) {
13775
13775
  if (e.isFile && e.file) {
13776
13776
  t.push(await new Promise((n, o) => e.file(n, o)));
13777
13777
  return;
@@ -13781,10 +13781,10 @@ var HackbuildMotionViews = (function(exports, three) {
13781
13781
  for (;;) {
13782
13782
  const n = await new Promise((o, i) => r.readEntries(o, i));
13783
13783
  if (!n.length) return;
13784
- for (const o of n) await Lt(o, t);
13784
+ for (const o of n) await Tt(o, t);
13785
13785
  }
13786
13786
  }
13787
- function sn(e) {
13787
+ function fn(e) {
13788
13788
  var n;
13789
13789
  const r = [...((n = e.dataTransfer) == null ? void 0 : n.items) ?? []].filter((o) => o.kind === "file").map((o) => {
13790
13790
  var i;
@@ -13792,11 +13792,11 @@ var HackbuildMotionViews = (function(exports, three) {
13792
13792
  });
13793
13793
  return r.some((o) => o == null ? void 0 : o.isDirectory) ? r.filter((o) => !!o) : null;
13794
13794
  }
13795
- function ae(e) {
13795
+ function fe(e) {
13796
13796
  var t;
13797
13797
  return [...((t = e.dataTransfer) == null ? void 0 : t.types) ?? []].includes("Files");
13798
13798
  }
13799
- function Pr(e, t, r = {}) {
13799
+ function _r(e, t, r = {}) {
13800
13800
  let n = 0, o = {
13801
13801
  over: !1,
13802
13802
  route: null,
@@ -13804,29 +13804,29 @@ var HackbuildMotionViews = (function(exports, three) {
13804
13804
  count: 0
13805
13805
  };
13806
13806
  function i(p) {
13807
- var b;
13807
+ var v;
13808
13808
  const d = p.over === o.over && p.route === o.route && p.rejected === o.rejected && p.count === o.count;
13809
13809
  if (o = p, d) return;
13810
13810
  const u = r.overlay;
13811
- u && (u.classList.toggle("is-over", p.over), u.classList.toggle("is-reject", p.rejected), p.route ? u.dataset.route = p.route : delete u.dataset.route), (b = r.onState) == null || b.call(r, p);
13811
+ u && (u.classList.toggle("is-over", p.over), u.classList.toggle("is-reject", p.rejected), p.route ? u.dataset.route = p.route : delete u.dataset.route), (v = r.onState) == null || v.call(r, p);
13812
13812
  }
13813
13813
  function s(p) {
13814
- var v;
13815
- const d = [...((v = p.dataTransfer) == null ? void 0 : v.items) ?? []].filter((E) => E.kind === "file"), u = d.map((E) => E.type);
13816
- if (!u.length || u.some((E) => !E)) return {
13814
+ var b;
13815
+ const d = [...((b = p.dataTransfer) == null ? void 0 : b.items) ?? []].filter((x) => x.kind === "file"), u = d.map((x) => x.type);
13816
+ if (!u.length || u.some((x) => !x)) return {
13817
13817
  over: !0,
13818
13818
  route: null,
13819
13819
  rejected: !1,
13820
13820
  count: d.length
13821
13821
  };
13822
- const b = u.map((E) => t.find(($) => typeof $.accept != "function" && et($.accept, {
13822
+ const v = u.map((x) => t.find((T) => typeof T.accept != "function" && rt(T.accept, {
13823
13823
  name: "",
13824
- type: E
13825
- }))), w = new Set(b.map((E) => (E == null ? void 0 : E.name) ?? null)), x = b.every((E) => !E) && t.every((E) => typeof E.accept != "function" && Et(E.accept).every(($) => !$.startsWith(".")));
13824
+ type: x
13825
+ }))), w = new Set(v.map((x) => (x == null ? void 0 : x.name) ?? null)), k = v.every((x) => !x) && t.every((x) => typeof x.accept != "function" && Ct(x.accept).every((T) => !T.startsWith(".")));
13826
13826
  return {
13827
13827
  over: !0,
13828
13828
  route: w.size === 1 ? [...w][0] : null,
13829
- rejected: x,
13829
+ rejected: k,
13830
13830
  count: d.length
13831
13831
  };
13832
13832
  }
@@ -13836,51 +13836,51 @@ var HackbuildMotionViews = (function(exports, three) {
13836
13836
  };
13837
13837
  function a(p) {
13838
13838
  const d = p;
13839
- !c() || !ae(d) || (d.preventDefault(), n++, i(s(d)));
13839
+ !c() || !fe(d) || (d.preventDefault(), n++, i(s(d)));
13840
13840
  }
13841
- function g(p) {
13841
+ function h(p) {
13842
13842
  const d = p;
13843
- !c() || !ae(d) || (d.preventDefault(), o.over || i(s(d)));
13843
+ !c() || !fe(d) || (d.preventDefault(), o.over || i(s(d)));
13844
13844
  }
13845
13845
  function y(p) {
13846
- !ae(p) || n === 0 || (n--, n === 0 && i({
13846
+ !fe(p) || n === 0 || (n--, n === 0 && i({
13847
13847
  over: !1,
13848
13848
  route: null,
13849
13849
  rejected: !1,
13850
13850
  count: 0
13851
13851
  }));
13852
13852
  }
13853
- function h(p) {
13854
- var b;
13853
+ function f(p) {
13854
+ var v;
13855
13855
  const d = p;
13856
- if (!ae(d) || (d.preventDefault(), n = 0, i({
13856
+ if (!fe(d) || (d.preventDefault(), n = 0, i({
13857
13857
  over: !1,
13858
13858
  route: null,
13859
13859
  rejected: !1,
13860
13860
  count: 0
13861
13861
  }), !c())) return;
13862
- const u = r.folders !== !1 ? sn(d) : null;
13862
+ const u = r.folders !== !1 ? fn(d) : null;
13863
13863
  if (u) {
13864
13864
  "tagName" in e && d.stopPropagation();
13865
13865
  const w = [];
13866
- Promise.all(u.map((x) => Lt(x, w))).then(() => m(w, d), () => m(w, d));
13866
+ Promise.all(u.map((k) => Tt(k, w))).then(() => m(w, d), () => m(w, d));
13867
13867
  return;
13868
13868
  }
13869
- m([...((b = d.dataTransfer) == null ? void 0 : b.files) ?? []], d) && "tagName" in e && d.stopPropagation();
13869
+ m([...((v = d.dataTransfer) == null ? void 0 : v.files) ?? []], d) && "tagName" in e && d.stopPropagation();
13870
13870
  }
13871
13871
  function m(p, d) {
13872
13872
  var w;
13873
- const u = /* @__PURE__ */ new Map(), b = [];
13874
- for (const x of p) {
13875
- const v = t.find((E) => et(E.accept, x));
13876
- v ? u.set(v, [...u.get(v) ?? [], x]) : b.push(x);
13873
+ const u = /* @__PURE__ */ new Map(), v = [];
13874
+ for (const k of p) {
13875
+ const b = t.find((x) => rt(x.accept, k));
13876
+ b ? u.set(b, [...u.get(b) ?? [], k]) : v.push(k);
13877
13877
  }
13878
- for (const [x, v] of u) x.on(v, d);
13879
- return b.length && ((w = r.onReject) == null || w.call(r, b, d)), u.size > 0;
13878
+ for (const [k, b] of u) k.on(b, d);
13879
+ return v.length && ((w = r.onReject) == null || w.call(r, v, d)), u.size > 0;
13880
13880
  }
13881
- function f(p) {
13882
- var b;
13883
- const d = p, u = [...((b = d.clipboardData) == null ? void 0 : b.files) ?? []];
13881
+ function g(p) {
13882
+ var v;
13883
+ const d = p, u = [...((v = d.clipboardData) == null ? void 0 : v.files) ?? []];
13884
13884
  !u.length || !c() || (d.preventDefault(), m(u, d));
13885
13885
  }
13886
13886
  function l() {
@@ -13891,17 +13891,17 @@ var HackbuildMotionViews = (function(exports, three) {
13891
13891
  count: 0
13892
13892
  });
13893
13893
  }
13894
- return e.addEventListener("dragenter", a), e.addEventListener("dragover", g), e.addEventListener("dragleave", y), e.addEventListener("drop", h), e.addEventListener("dragend", l), r.paste && e.addEventListener("paste", f), {
13894
+ return e.addEventListener("dragenter", a), e.addEventListener("dragover", h), e.addEventListener("dragleave", y), e.addEventListener("drop", f), e.addEventListener("dragend", l), r.paste && e.addEventListener("paste", g), {
13895
13895
  get state() {
13896
13896
  return o;
13897
13897
  },
13898
13898
  dispose() {
13899
- e.removeEventListener("dragenter", a), e.removeEventListener("dragover", g), e.removeEventListener("dragleave", y), e.removeEventListener("drop", h), e.removeEventListener("dragend", l), e.removeEventListener("paste", f), l();
13899
+ e.removeEventListener("dragenter", a), e.removeEventListener("dragover", h), e.removeEventListener("dragleave", y), e.removeEventListener("drop", f), e.removeEventListener("dragend", l), e.removeEventListener("paste", g), l();
13900
13900
  }
13901
13901
  };
13902
13902
  }
13903
- W("wand", "add"), W("brush", "add"), W("eraser", "add"), W("lasso", "add"), W("polygon", "add"), W("rect", "add"), W("ellipse", "add"), W("flood", "add"), W("pan", "add");
13904
- function W(e, t) {
13903
+ Y("wand", "add"), Y("brush", "add"), Y("eraser", "add"), Y("lasso", "add"), Y("polygon", "add"), Y("rect", "add"), Y("ellipse", "add"), Y("flood", "add"), Y("pan", "add");
13904
+ function Y(e, t) {
13905
13905
  const r = t === "add", n = `x swaps to ${r ? "erase" : "add"}`;
13906
13906
  return e === "wand" ? `tap a colour to ${r ? "add" : "cut"} it. shift ${r ? "cuts" : "adds"}, ${n}` : e === "brush" ? `paint to ${r ? "add" : "erase"}. [ and ] size, ${n}` : e === "eraser" ? "paint to erase. shift adds, [ and ] size" : e === "polygon" ? `press corner by corner, enter or the first corner ${r ? "fills" : "cuts"}. backspace drops a corner, esc all` : e === "rect" || e === "ellipse" ? `drag a ${e === "rect" ? "box" : "ring"} to ${r ? "add" : "cut"} it. shift ${r ? "cuts" : "adds"}, ${n}` : e === "flood" ? `tap to fill the patch of one colour. shift ${r ? "cuts" : "adds"}, ${n}` : e === "pan" ? "drag to move the picture. space pans from any tool" : `drag around a shape, lift to ${r ? "fill" : "cut"}. esc drops it, ${n}`;
13907
13907
  }
@@ -13930,7 +13930,7 @@ var HackbuildMotionViews = (function(exports, three) {
13930
13930
  title: label,
13931
13931
  ...attrs
13932
13932
  });
13933
- b.innerHTML = Qt(icon, { size: 18 });
13933
+ b.innerHTML = rn(icon, { size: 18 });
13934
13934
  return b;
13935
13935
  }
13936
13936
  /** A light button, or the one pink action when `go`. */
@@ -14039,6 +14039,170 @@ var HackbuildMotionViews = (function(exports, three) {
14039
14039
  });
14040
14040
  return new three.AnimationClip(clip.name, (clip.frames - 1) / clip.fps, tracks);
14041
14041
  }
14042
+ const ss = (a, b, x) => {
14043
+ const t = Math.min(1, Math.max(0, (x - a) / (b - a)));
14044
+ return t * t * (3 - 2 * t);
14045
+ };
14046
+ /** Seconds each rig gesture runs. */
14047
+ const RIG_SECONDS = {
14048
+ wave: 2.6,
14049
+ nod: 1.2,
14050
+ shake: 1.4,
14051
+ bow: 2
14052
+ };
14053
+ /**
14054
+ * A gesture as a presence clip built on the rig itself: each bone is aimed
14055
+ * or turned in world space, in the body's own frame (forward, left and up
14056
+ * from its shoulders), then read back as local rotations. Works on any
14057
+ * humanoid rig, whatever its bone axes. The arm eases up, waves and eases
14058
+ * down; nod, shake and bow ease in and out. `bones` and `names` are the
14059
+ * body's bone order; the pose they hold now is the base. Returns null when
14060
+ * the rig lacks the gesture's bones.
14061
+ */
14062
+ function rigGestureClip(id, bones, names, fps = 30) {
14063
+ const at = (n) => {
14064
+ const i = names.indexOf(n);
14065
+ return i < 0 ? null : bones[i];
14066
+ };
14067
+ const lu = at("leftUpperArm"), ru = at("rightUpperArm"), rl = at("rightLowerArm"), rh = at("rightHand"), head = at("head");
14068
+ const spine = at("spine"), chest = at("chest");
14069
+ if (!lu || !ru) return null;
14070
+ if (id === "wave" && (!rl || !rh)) return null;
14071
+ if ((id === "nod" || id === "shake") && !head) return null;
14072
+ if (id === "bow" && !spine) return null;
14073
+ const n = bones.length;
14074
+ const base = bones.map((b) => b.quaternion.clone());
14075
+ const top = bones[0].parent ?? bones[0];
14076
+ top.updateMatrixWorld(true);
14077
+ const wp = (o, v = new three.Vector3()) => o.getWorldPosition(v);
14078
+ const up = new three.Vector3(0, 1, 0);
14079
+ const L = wp(lu).sub(wp(ru)).setY(0).normalize();
14080
+ const F = new three.Vector3().crossVectors(L, up).normalize();
14081
+ const R = L.clone().negate();
14082
+ const pq = new three.Quaternion(), bq = new three.Quaternion(), rq = new three.Quaternion();
14083
+ const turnWorld = (b, rw) => {
14084
+ b.parent.getWorldQuaternion(pq);
14085
+ b.getWorldQuaternion(bq);
14086
+ b.quaternion.copy(pq.invert().multiply(rw).multiply(bq));
14087
+ b.updateMatrixWorld(true);
14088
+ };
14089
+ const aim = (b, child, dir, w) => {
14090
+ const cur = wp(child).sub(wp(b)).normalize();
14091
+ const want = cur.clone().lerp(dir, w).normalize();
14092
+ turnWorld(b, rq.setFromUnitVectors(cur, want));
14093
+ };
14094
+ const seconds = RIG_SECONDS[id];
14095
+ const frames = Math.round(seconds * fps) + 1;
14096
+ const rotations = new Float32Array(frames * n * 4);
14097
+ const armUp = R.clone().multiplyScalar(.55).addScaledVector(up, .8).addScaledVector(F, .22).normalize();
14098
+ for (let f = 0; f < frames; f++) {
14099
+ const t = f / (frames - 1);
14100
+ bones.forEach((b, i) => b.quaternion.copy(base[i]));
14101
+ top.updateMatrixWorld(true);
14102
+ if (id === "wave") {
14103
+ const e = ss(0, .22, t) * (1 - ss(.8, 1, t));
14104
+ aim(ru, rl, armUp, e);
14105
+ const osc = .42 * Math.sin(2 * Math.PI * 3 * ss(.18, .84, t)) * ss(.12, .3, t) * (1 - ss(.74, .86, t));
14106
+ aim(rl, rh, up.clone().addScaledVector(F, .12).addScaledVector(R, .08).applyAxisAngle(F, -osc).normalize(), e);
14107
+ } else if (id === "nod") turnWorld(head, rq.setFromAxisAngle(L, .24 * Math.sin(2 * Math.PI * t) ** 2 * (1 - ss(.85, 1, t))));
14108
+ else if (id === "shake") turnWorld(head, rq.setFromAxisAngle(up, .32 * Math.sin(4 * Math.PI * t) * Math.sin(Math.PI * t)));
14109
+ else {
14110
+ const e = ss(0, .35, t) * (1 - ss(.65, 1, t));
14111
+ turnWorld(spine, rq.setFromAxisAngle(L, .32 * e));
14112
+ if (chest) turnWorld(chest, rq.setFromAxisAngle(L, .18 * e));
14113
+ if (head) turnWorld(head, rq.setFromAxisAngle(L, -.12 * e));
14114
+ }
14115
+ bones.forEach((b, i) => b.quaternion.toArray(rotations, (f * n + i) * 4));
14116
+ }
14117
+ bones.forEach((b, i) => b.quaternion.copy(base[i]));
14118
+ top.updateMatrixWorld(true);
14119
+ return {
14120
+ name: id,
14121
+ fps,
14122
+ frames,
14123
+ bones: n,
14124
+ loop: false,
14125
+ rotations
14126
+ };
14127
+ }
14128
+ // src/clip-pack.ts
14129
+ const ROLE = {
14130
+ hips: "hips",
14131
+ spine: "spine",
14132
+ chest: "chest",
14133
+ upperChest: "upperChest",
14134
+ neck: "neck",
14135
+ head: "head",
14136
+ shoulderL: "leftShoulder",
14137
+ upperArmL: "leftUpperArm",
14138
+ lowerArmL: "leftLowerArm",
14139
+ handL: "leftHand",
14140
+ shoulderR: "rightShoulder",
14141
+ upperArmR: "rightUpperArm",
14142
+ lowerArmR: "rightLowerArm",
14143
+ handR: "rightHand",
14144
+ upperLegL: "leftUpperLeg",
14145
+ lowerLegL: "leftLowerLeg",
14146
+ footL: "leftFoot",
14147
+ upperLegR: "rightUpperLeg",
14148
+ lowerLegR: "rightLowerLeg",
14149
+ footR: "rightFoot"
14150
+ };
14151
+ function int16(b64) {
14152
+ const s = atob(b64);
14153
+ const u = new Uint8Array(s.length);
14154
+ for (let i = 0; i < s.length; i++) u[i] = s.charCodeAt(i);
14155
+ return new Int16Array(u.buffer);
14156
+ }
14157
+ /** How many of the pack's roles land on one of `names`. */
14158
+ function packCoverage(pack, names) {
14159
+ return pack.roles.filter((r) => ROLE[r] && names.includes(ROLE[r])).length;
14160
+ }
14161
+ /**
14162
+ * The pack's clips as presence clips over `names` (the body's bone order).
14163
+ * `base` holds bones times 4 local rotations for the bones the pack does
14164
+ * not move (fingers, eyes), usually the pose when the body loaded.
14165
+ */
14166
+ function packClips(pack, names, base) {
14167
+ const R = pack.roles.length;
14168
+ const n = names.length;
14169
+ const slot = pack.roles.map((r) => ROLE[r] ? names.indexOf(ROLE[r]) : -1);
14170
+ const out = {};
14171
+ for (const [name, c] of Object.entries(pack.clips)) {
14172
+ const q = int16(c.q);
14173
+ const frames = c.n;
14174
+ const rotations = new Float32Array(frames * n * 4);
14175
+ for (let f = 0; f < frames; f++) {
14176
+ rotations.set(Array.prototype.slice.call(base, 0, n * 4), f * n * 4);
14177
+ for (let r = 0; r < R; r++) {
14178
+ const i = slot[r];
14179
+ if (i < 0) continue;
14180
+ const a = (f * R + r) * 4;
14181
+ let x = q[a] / 32767, y = q[a + 1] / 32767, z = q[a + 2] / 32767, w = q[a + 3] / 32767;
14182
+ const len = Math.hypot(x, y, z, w) || 1;
14183
+ x /= len;
14184
+ y /= len;
14185
+ z /= len;
14186
+ w /= len;
14187
+ rotations.set([
14188
+ x,
14189
+ y,
14190
+ z,
14191
+ w
14192
+ ], (f * n + i) * 4);
14193
+ }
14194
+ }
14195
+ out[name] = {
14196
+ name,
14197
+ fps: pack.fps,
14198
+ frames,
14199
+ bones: n,
14200
+ loop: c.loop,
14201
+ rotations
14202
+ };
14203
+ }
14204
+ return out;
14205
+ }
14042
14206
  // src/character-stage.ts
14043
14207
  init_three$1();
14044
14208
  /** The verbs a stage shows by default: say hello is the next thing to do. */
@@ -14082,6 +14246,7 @@ var HackbuildMotionViews = (function(exports, three) {
14082
14246
  const turnBtn = iconButton(doc, "flip", "turn around");
14083
14247
  const frameBtn = iconButton(doc, "frame", "full body", { "aria-pressed": "false" });
14084
14248
  const tag = el(doc, "div", "hb-stage-tag", {}, [nameEl, doingEl]);
14249
+ if (!opts.plate) tag.style.display = "none";
14085
14250
  const tagCorner = el(doc, "div", "hb-ov hb-ov-tl");
14086
14251
  const corner = el(doc, "div", "hb-ov hb-ov-tr", {}, [turnBtn, frameBtn]);
14087
14252
  const stage = new AvatarStage(subject, opts);
@@ -14116,6 +14281,8 @@ var HackbuildMotionViews = (function(exports, three) {
14116
14281
  if (!opts.name) nameEl.textContent = e.placeholder ? "stand-in" : e.name;
14117
14282
  applyFraming();
14118
14283
  setDoing("idle");
14284
+ packed = null;
14285
+ if (!e.placeholder) usePack();
14119
14286
  emit({
14120
14287
  type: "loaded",
14121
14288
  name: e.name,
@@ -14127,6 +14294,28 @@ var HackbuildMotionViews = (function(exports, three) {
14127
14294
  type: "failed",
14128
14295
  message: e.message
14129
14296
  })));
14297
+ let packed = null;
14298
+ let packFile = null;
14299
+ async function usePack() {
14300
+ const body = stage.body;
14301
+ if (!opts.clips || !body) return;
14302
+ packFile ??= typeof opts.clips === "string" ? fetch(opts.clips).then((r) => r.ok ? r.json() : null).catch(() => null) : Promise.resolve(opts.clips);
14303
+ const pack = await packFile;
14304
+ if (!pack || stage.body !== body || packCoverage(pack, body.names) < 12) return;
14305
+ const base = new Float32Array(body.bones.length * 4);
14306
+ body.bones.forEach((b, i) => b.quaternion.toArray(base, i * 4));
14307
+ packed = packClips(pack, body.names, base);
14308
+ idleLoop(.4);
14309
+ }
14310
+ function idleLoop(fade, talking = false) {
14311
+ const c = packed?.[talking ? "Idle_Talking_Loop" : "Idle_Loop"] ?? packed?.Idle_Loop;
14312
+ if (c && stage.body) stage.body.play(c, {
14313
+ layer: "body",
14314
+ loop: true,
14315
+ background: true,
14316
+ fade
14317
+ });
14318
+ }
14130
14319
  function applyFraming() {
14131
14320
  const body = stage.body;
14132
14321
  frameBtn.setAttribute("aria-pressed", String(framing === "full"));
@@ -14195,9 +14384,12 @@ var HackbuildMotionViews = (function(exports, three) {
14195
14384
  function gesture(id) {
14196
14385
  const body = stage.body;
14197
14386
  if (!body) return false;
14198
- const base = new Float32Array(body.bones.length * 4);
14199
- body.bones.forEach((b, i) => b.quaternion.toArray(base, i * 4));
14200
- const clip = gestureClip(id, body.names, base);
14387
+ let clip = rigGestureClip(id, body.bones, body.names);
14388
+ if (!clip) {
14389
+ const base = new Float32Array(body.bones.length * 4);
14390
+ body.bones.forEach((b, i) => b.quaternion.toArray(base, i * 4));
14391
+ clip = gestureClip(id, body.names, base);
14392
+ }
14201
14393
  if (!clip) return false;
14202
14394
  return play(clip, { layer: id === "bow" ? "body" : "upper" }) >= 0;
14203
14395
  }
@@ -14265,6 +14457,7 @@ var HackbuildMotionViews = (function(exports, three) {
14265
14457
  body.lip.push(events);
14266
14458
  body.setGazeMode("talk");
14267
14459
  setDoing("talking");
14460
+ idleLoop(.5, true);
14268
14461
  stage.loop.sync();
14269
14462
  start?.();
14270
14463
  if (analyser && audioCtx) {
@@ -14290,6 +14483,7 @@ var HackbuildMotionViews = (function(exports, three) {
14290
14483
  analyser?.disconnect();
14291
14484
  stage.body?.lip.setLevel(0);
14292
14485
  stage.body?.setGazeMode("listen");
14486
+ idleLoop(.6);
14293
14487
  if (doing === "talking") setDoing("idle");
14294
14488
  }
14295
14489
  function look() {
@@ -14325,7 +14519,7 @@ var HackbuildMotionViews = (function(exports, three) {
14325
14519
  frameBtn.addEventListener("click", () => frame(framing === "bust" ? "full" : "bust"), { signal: ac.signal });
14326
14520
  const ro = new ResizeObserver(() => framing === "bust" && applyFraming());
14327
14521
  ro.observe(subject);
14328
- const drop = opts.drop === false ? null : Pr(subject, [{
14522
+ const drop = opts.drop === false ? null : _r(subject, [{
14329
14523
  name: "model",
14330
14524
  accept: () => true,
14331
14525
  on: (files) => void show(files)
@@ -14621,7 +14815,7 @@ var HackbuildMotionViews = (function(exports, three) {
14621
14815
  input.value = "";
14622
14816
  if (list.length) take(list);
14623
14817
  }, { signal: ac.signal });
14624
- const drop = Pr(zone, [{
14818
+ const drop = _r(zone, [{
14625
14819
  name: "avatar",
14626
14820
  accept: () => true,
14627
14821
  on: (files) => void take(files)
@@ -15320,10 +15514,579 @@ var HackbuildMotionViews = (function(exports, three) {
15320
15514
  customElements.define("hb-clip-strip", Strip);
15321
15515
  }
15322
15516
  }
15517
+ // src/stage.ts
15518
+ /** A drag orbit on `el` for `camera`: horizontal drag turns, vertical drag tilts, the wheel moves in and out. */
15519
+ function stageOrbit(camera, el) {
15520
+ const target = new three.Vector3();
15521
+ const s = new three.Spherical();
15522
+ let drag = null;
15523
+ const turn = (dTheta, dPhi, scale = 1) => {
15524
+ s.setFromVector3(camera.position.clone().sub(target));
15525
+ s.theta += dTheta;
15526
+ s.phi = Math.min(Math.PI * .49, Math.max(.08, s.phi + dPhi));
15527
+ s.radius = Math.min(200, Math.max(.3, s.radius * scale));
15528
+ camera.position.setFromSpherical(s).add(target);
15529
+ };
15530
+ const down = (e) => {
15531
+ if (!orbit.enabled) return;
15532
+ drag = {
15533
+ x: e.clientX,
15534
+ y: e.clientY,
15535
+ id: e.pointerId
15536
+ };
15537
+ el.setPointerCapture?.(e.pointerId);
15538
+ };
15539
+ const move = (e) => {
15540
+ if (!drag || e.pointerId !== drag.id || !orbit.enabled) return;
15541
+ turn(-(e.clientX - drag.x) * .008, -(e.clientY - drag.y) * .008);
15542
+ drag.x = e.clientX;
15543
+ drag.y = e.clientY;
15544
+ };
15545
+ const up = () => drag = null;
15546
+ const wheel = (e) => {
15547
+ if (!orbit.enabled) return;
15548
+ e.preventDefault();
15549
+ turn(0, 0, Math.exp(e.deltaY * .001));
15550
+ };
15551
+ el.addEventListener("pointerdown", down);
15552
+ el.addEventListener("pointermove", move);
15553
+ el.addEventListener("pointerup", up);
15554
+ el.addEventListener("pointercancel", up);
15555
+ el.addEventListener("wheel", wheel, { passive: false });
15556
+ const orbit = {
15557
+ target,
15558
+ enabled: true,
15559
+ update: () => {
15560
+ if (orbit.enabled) camera.lookAt(target);
15561
+ },
15562
+ dispose() {
15563
+ el.removeEventListener("pointerdown", down);
15564
+ el.removeEventListener("pointermove", move);
15565
+ el.removeEventListener("pointerup", up);
15566
+ el.removeEventListener("pointercancel", up);
15567
+ el.removeEventListener("wheel", wheel);
15568
+ }
15569
+ };
15570
+ return orbit;
15571
+ }
15572
+ /** Frees the geometry and materials of every mesh under `root`. */
15573
+ function freeMeshes(root) {
15574
+ root.traverse((o) => {
15575
+ if (o instanceof three.Mesh) {
15576
+ o.geometry.dispose();
15577
+ for (const m of [o.material].flat()) m.dispose();
15578
+ }
15579
+ });
15580
+ }
15581
+ /**
15582
+ * A stage lit in paper light that fills `host`: it sizes with the host,
15583
+ * calls `tick(dt, t)` each frame (dt capped at 50 ms), draws, and on
15584
+ * dispose stops the loop and frees the renderer, the orbit and every mesh.
15585
+ */
15586
+ function threeStage(host, tick, opts = {}) {
15587
+ const renderer = opts.renderer ?? new three.WebGLRenderer({ antialias: true });
15588
+ renderer.setPixelRatio(Math.min(2, globalThis.devicePixelRatio || 1));
15589
+ renderer.domElement.style.cssText = "display:block;width:100%;height:100%;touch-action:none";
15590
+ host.append(renderer.domElement);
15591
+ const scene = new three.Scene();
15592
+ scene.background = new three.Color("#efe9db");
15593
+ const camera = new three.PerspectiveCamera(40, 1, .05, 200);
15594
+ camera.position.set(2.4, 1.6, 3.2);
15595
+ const orbit = stageOrbit(camera, renderer.domElement);
15596
+ orbit.target.set(0, .5, 0);
15597
+ scene.add(new three.AmbientLight("#ffffff", 1.1));
15598
+ const sun = new three.DirectionalLight("#ffffff", 1.6);
15599
+ sun.position.set(3, 6, 4);
15600
+ scene.add(sun);
15601
+ if (opts.ground !== false) {
15602
+ const g = new three.PlaneGeometry(40, 40);
15603
+ g.rotateX(-Math.PI / 2);
15604
+ scene.add(new three.Mesh(g, new three.MeshStandardMaterial({
15605
+ color: "#d9d0bd",
15606
+ roughness: 1
15607
+ })));
15608
+ }
15609
+ const fit = () => {
15610
+ const w = Math.max(1, host.clientWidth);
15611
+ const h = Math.max(1, host.clientHeight);
15612
+ renderer.setSize(w, h, false);
15613
+ camera.aspect = w / h;
15614
+ camera.updateProjectionMatrix();
15615
+ };
15616
+ const ro = typeof ResizeObserver === "function" ? new ResizeObserver(fit) : null;
15617
+ ro?.observe(host);
15618
+ fit();
15619
+ let raf = 0;
15620
+ let last = performance.now();
15621
+ let t = 0;
15622
+ const frame = (now) => {
15623
+ const dt = Math.min(.05, Math.max(0, (now - last) / 1e3));
15624
+ last = now;
15625
+ t += dt;
15626
+ tick(dt, t);
15627
+ orbit.update();
15628
+ renderer.render(scene, camera);
15629
+ raf = requestAnimationFrame(frame);
15630
+ };
15631
+ raf = requestAnimationFrame(frame);
15632
+ return {
15633
+ scene,
15634
+ camera,
15635
+ renderer,
15636
+ orbit,
15637
+ dispose() {
15638
+ cancelAnimationFrame(raf);
15639
+ ro?.disconnect();
15640
+ orbit.dispose();
15641
+ freeMeshes(scene);
15642
+ renderer.dispose();
15643
+ renderer.domElement.remove();
15644
+ }
15645
+ };
15646
+ }
15647
+ /**
15648
+ * A turntable that fills `host`: hemisphere light, drag to turn, one
15649
+ * object at a time, sized for a relief or a depth surface tens of units
15650
+ * across (the camera starts 80 units out, looking down at 30 degrees).
15651
+ */
15652
+ function meshTurntable(host, opts = {}) {
15653
+ const stage = threeStage(host, () => {}, {
15654
+ ground: false,
15655
+ renderer: opts.renderer ?? new three.WebGLRenderer({
15656
+ antialias: true,
15657
+ preserveDrawingBuffer: true
15658
+ })
15659
+ });
15660
+ stage.camera.position.set(0, -40, 70);
15661
+ stage.camera.near = .1;
15662
+ stage.camera.far = 1e3;
15663
+ stage.camera.updateProjectionMatrix();
15664
+ stage.orbit.target.set(0, 0, 0);
15665
+ stage.scene.add(new three.HemisphereLight(16777215, 9077104, 1.2));
15666
+ let shown = null;
15667
+ return {
15668
+ stage,
15669
+ show(o) {
15670
+ if (shown) {
15671
+ stage.scene.remove(shown);
15672
+ freeMeshes(shown);
15673
+ }
15674
+ shown = o;
15675
+ stage.scene.add(o);
15676
+ },
15677
+ dispose: () => stage.dispose()
15678
+ };
15679
+ }
15680
+ /** The bone names of `boxDog`, in the shape `@hackbuild/gait` reads (hips, spine, tail, four legs). */
15681
+ const BOX_DOG_BONES = {
15682
+ hips: "hips",
15683
+ spine: ["spine2", "chest"],
15684
+ tail: [
15685
+ "tail1",
15686
+ "tail3",
15687
+ "tail_03"
15688
+ ],
15689
+ legs: {
15690
+ LF: {
15691
+ up: "frontUpr.L",
15692
+ mid: "frontLeg.L_03",
15693
+ end: "frontHorselink.L",
15694
+ toes: ["frontToe.L"]
15695
+ },
15696
+ RF: {
15697
+ up: "frontUpr.R",
15698
+ mid: "frontLeg.R_03",
15699
+ end: "frontHorselink.R",
15700
+ toes: ["frontToe.R"]
15701
+ },
15702
+ LH: {
15703
+ up: "rearUpr.L",
15704
+ mid: "rearLwr.L",
15705
+ end: "rearHorselink.L",
15706
+ toes: ["rearFoot.L", "rearToe.L"]
15707
+ },
15708
+ RH: {
15709
+ up: "rearUpr.R",
15710
+ mid: "rearLwr.R",
15711
+ end: "rearHorselink.R",
15712
+ toes: ["rearFoot.R", "rearToe.R"]
15713
+ }
15714
+ }
15715
+ };
15716
+ /**
15717
+ * A dog of bones and boxes facing +z, about 0.78 m nose to tail with the
15718
+ * hips 0.38 m up; bone names are `BOX_DOG_BONES`. Each bone carries a box
15719
+ * to its child, so the legs show what a gait does to them.
15720
+ */
15721
+ function boxDog(color = "#c9a36b") {
15722
+ const root = new three.Group();
15723
+ const bone = (name, parent, p) => {
15724
+ const b = new three.Bone();
15725
+ b.name = name;
15726
+ b.position.set(...p);
15727
+ parent.add(b);
15728
+ return b;
15729
+ };
15730
+ const hips = bone("hips", root, [
15731
+ 0,
15732
+ .38,
15733
+ 0
15734
+ ]);
15735
+ const chest = bone("chest", bone("spine2", hips, [
15736
+ 0,
15737
+ 0,
15738
+ .1
15739
+ ]), [
15740
+ 0,
15741
+ 0,
15742
+ .12
15743
+ ]);
15744
+ const head = bone("head", bone("neck1", chest, [
15745
+ 0,
15746
+ .08,
15747
+ .05
15748
+ ]), [
15749
+ 0,
15750
+ .08,
15751
+ .06
15752
+ ]);
15753
+ for (const [s, x] of [["L", .09], ["R", -.09]]) {
15754
+ const fe = bone(`frontHorselink.${s}`, bone(`frontLeg.${s}_03`, bone(`frontUpr.${s}`, chest, [
15755
+ x,
15756
+ 0,
15757
+ 0
15758
+ ]), [
15759
+ 0,
15760
+ -.18,
15761
+ -.08
15762
+ ]), [
15763
+ 0,
15764
+ -.16,
15765
+ .08
15766
+ ]);
15767
+ bone(`frontToe.${s}`, fe, [
15768
+ 0,
15769
+ -.02,
15770
+ .03
15771
+ ]);
15772
+ const re = bone(`rearHorselink.${s}`, bone(`rearLwr.${s}`, bone(`rearUpr.${s}`, hips, [
15773
+ x,
15774
+ 0,
15775
+ -.2
15776
+ ]), [
15777
+ 0,
15778
+ -.17,
15779
+ .07
15780
+ ]), [
15781
+ 0,
15782
+ -.15,
15783
+ -.08
15784
+ ]);
15785
+ bone(`rearToe.${s}`, bone(`rearFoot.${s}`, re, [
15786
+ 0,
15787
+ -.02,
15788
+ .01
15789
+ ]), [
15790
+ 0,
15791
+ -.02,
15792
+ .03
15793
+ ]);
15794
+ }
15795
+ bone("tail_03", bone("tail3", bone("tail1", hips, [
15796
+ 0,
15797
+ .02,
15798
+ -.25
15799
+ ]), [
15800
+ 0,
15801
+ 0,
15802
+ -.08
15803
+ ]), [
15804
+ 0,
15805
+ 0,
15806
+ -.08
15807
+ ]);
15808
+ const mat = new three.MeshStandardMaterial({
15809
+ color,
15810
+ roughness: .7
15811
+ });
15812
+ const Z = new three.Vector3(0, 0, 1);
15813
+ const parts = [];
15814
+ root.traverse((o) => {
15815
+ if (!(o instanceof three.Bone)) return;
15816
+ for (const c of o.children) {
15817
+ if (!(c instanceof three.Bone) || c.position.length() < 1e-4) continue;
15818
+ const thick = c.name === "spine2" || c.name === "chest" ? .17 : /Upr/.test(c.name) ? .07 : /tail/.test(c.name) ? .03 : .045;
15819
+ const m = new three.Mesh(new three.BoxGeometry(thick, thick, c.position.length()), mat);
15820
+ m.position.copy(c.position).multiplyScalar(.5);
15821
+ m.quaternion.setFromUnitVectors(Z, c.position.clone().normalize());
15822
+ parts.push([o, m]);
15823
+ }
15824
+ });
15825
+ for (const [o, m] of parts) o.add(m);
15826
+ const skull = new three.Mesh(new three.BoxGeometry(.11, .1, .18), mat);
15827
+ skull.position.set(0, .02, .05);
15828
+ head.add(skull);
15829
+ return root;
15830
+ }
15831
+ /**
15832
+ * A two step walk loop as bvh text for a humanoid that is not ours: other
15833
+ * bone names (Hips, LeftUpLeg, RightForeArm and so on), centimetres, arms
15834
+ * down, ZXY channels. A retarget has real work to do on it.
15835
+ */
15836
+ function walkBvh(o = {}) {
15837
+ const { seconds = 2.4, fps = 30, swing = 1 } = o;
15838
+ const J = [
15839
+ [
15840
+ "Hips",
15841
+ -1,
15842
+ [
15843
+ 0,
15844
+ 0,
15845
+ 0
15846
+ ]
15847
+ ],
15848
+ [
15849
+ "Spine",
15850
+ 0,
15851
+ [
15852
+ 0,
15853
+ 12,
15854
+ 0
15855
+ ]
15856
+ ],
15857
+ [
15858
+ "Spine1",
15859
+ 1,
15860
+ [
15861
+ 0,
15862
+ 16,
15863
+ 0
15864
+ ]
15865
+ ],
15866
+ [
15867
+ "Neck",
15868
+ 2,
15869
+ [
15870
+ 0,
15871
+ 26,
15872
+ 0
15873
+ ]
15874
+ ],
15875
+ [
15876
+ "Head",
15877
+ 3,
15878
+ [
15879
+ 0,
15880
+ 11,
15881
+ 0
15882
+ ]
15883
+ ],
15884
+ [
15885
+ "LeftArm",
15886
+ 2,
15887
+ [
15888
+ 18,
15889
+ 22,
15890
+ 0
15891
+ ]
15892
+ ],
15893
+ [
15894
+ "LeftForeArm",
15895
+ 5,
15896
+ [
15897
+ 29,
15898
+ 0,
15899
+ 0
15900
+ ]
15901
+ ],
15902
+ [
15903
+ "LeftHand",
15904
+ 6,
15905
+ [
15906
+ 26,
15907
+ 0,
15908
+ 0
15909
+ ]
15910
+ ],
15911
+ [
15912
+ "RightArm",
15913
+ 2,
15914
+ [
15915
+ -18,
15916
+ 22,
15917
+ 0
15918
+ ]
15919
+ ],
15920
+ [
15921
+ "RightForeArm",
15922
+ 8,
15923
+ [
15924
+ -29,
15925
+ 0,
15926
+ 0
15927
+ ]
15928
+ ],
15929
+ [
15930
+ "RightHand",
15931
+ 9,
15932
+ [
15933
+ -26,
15934
+ 0,
15935
+ 0
15936
+ ]
15937
+ ],
15938
+ [
15939
+ "LeftUpLeg",
15940
+ 0,
15941
+ [
15942
+ 10,
15943
+ -6,
15944
+ 0
15945
+ ]
15946
+ ],
15947
+ [
15948
+ "LeftLeg",
15949
+ 11,
15950
+ [
15951
+ 0,
15952
+ -47,
15953
+ 0
15954
+ ]
15955
+ ],
15956
+ [
15957
+ "LeftFoot",
15958
+ 12,
15959
+ [
15960
+ 0,
15961
+ -45,
15962
+ 0
15963
+ ]
15964
+ ],
15965
+ [
15966
+ "LeftToeBase",
15967
+ 13,
15968
+ [
15969
+ 0,
15970
+ -8,
15971
+ 14
15972
+ ]
15973
+ ],
15974
+ [
15975
+ "RightUpLeg",
15976
+ 0,
15977
+ [
15978
+ -10,
15979
+ -6,
15980
+ 0
15981
+ ]
15982
+ ],
15983
+ [
15984
+ "RightLeg",
15985
+ 15,
15986
+ [
15987
+ 0,
15988
+ -47,
15989
+ 0
15990
+ ]
15991
+ ],
15992
+ [
15993
+ "RightFoot",
15994
+ 16,
15995
+ [
15996
+ 0,
15997
+ -45,
15998
+ 0
15999
+ ]
16000
+ ],
16001
+ [
16002
+ "RightToeBase",
16003
+ 17,
16004
+ [
16005
+ 0,
16006
+ -8,
16007
+ 14
16008
+ ]
16009
+ ]
16010
+ ];
16011
+ const kids = (i) => J.map((j, k) => [j, k]).filter(([j]) => j[1] === i).map(([, k]) => k);
16012
+ const order = [];
16013
+ const write = (i, pad) => {
16014
+ order.push(i);
16015
+ const [name, parent, off] = J[i];
16016
+ const ch = parent < 0 ? "CHANNELS 6 Xposition Yposition Zposition Zrotation Xrotation Yrotation" : "CHANNELS 3 Zrotation Xrotation Yrotation";
16017
+ const c = kids(i);
16018
+ const body = c.length ? c.map((k) => write(k, pad + " ")).join("") : `${pad} End Site\n${pad} {\n${pad} OFFSET 0 6 0\n${pad} }\n`;
16019
+ return `${pad}${parent < 0 ? "ROOT" : "JOINT"} ${name}\n${pad}{\n${pad} OFFSET ${off.join(" ")}\n${pad} ${ch}\n${body}${pad}}\n`;
16020
+ };
16021
+ const tree = write(0, "");
16022
+ const n = Math.round(seconds * fps);
16023
+ const lines = [];
16024
+ for (let f = 0; f < n; f++) {
16025
+ const ph = f / fps * 2 * Math.PI * (1 / seconds) * 2;
16026
+ const s = Math.sin(ph) * swing;
16027
+ const rot = {
16028
+ LeftUpLeg: [
16029
+ 0,
16030
+ -28 * s,
16031
+ 0
16032
+ ],
16033
+ RightUpLeg: [
16034
+ 0,
16035
+ 28 * s,
16036
+ 0
16037
+ ],
16038
+ LeftLeg: [
16039
+ 0,
16040
+ 45 * Math.max(0, Math.sin(ph + 1.4)) * swing,
16041
+ 0
16042
+ ],
16043
+ RightLeg: [
16044
+ 0,
16045
+ 45 * Math.max(0, Math.sin(ph + 1.4 + Math.PI)) * swing,
16046
+ 0
16047
+ ],
16048
+ LeftArm: [
16049
+ -70,
16050
+ 22 * s,
16051
+ 0
16052
+ ],
16053
+ RightArm: [
16054
+ 70,
16055
+ -22 * s,
16056
+ 0
16057
+ ],
16058
+ LeftForeArm: [
16059
+ 0,
16060
+ 0,
16061
+ -15
16062
+ ],
16063
+ RightForeArm: [
16064
+ 0,
16065
+ 0,
16066
+ 15
16067
+ ]
16068
+ };
16069
+ lines.push(order.map((i) => (i === 0 ? [
16070
+ 0,
16071
+ 106 + 2.5 * Math.cos(2 * ph),
16072
+ 0,
16073
+ 2 * s,
16074
+ 0,
16075
+ 3 * s
16076
+ ] : rot[J[i][0]] ?? [
16077
+ 0,
16078
+ 0,
16079
+ 0
16080
+ ]).map((v) => v.toFixed(3)).join(" ")).join(" "));
16081
+ }
16082
+ return `HIERARCHY\n${tree}MOTION\nFrames: ${n}\nFrame Time: ${(1 / fps).toFixed(6)}\n${lines.join("\n")}\n`;
16083
+ }
16084
+ exports.BOX_DOG_BONES = BOX_DOG_BONES;
15323
16085
  exports.DEFAULT_VERBS = DEFAULT_VERBS;
15324
16086
  exports.GESTURES = GESTURES;
15325
16087
  exports.animationClipOf = animationClipOf;
15326
16088
  exports.avatarDrop = avatarDrop;
16089
+ exports.boxDog = boxDog;
15327
16090
  exports.bytesWord = bytesWord;
15328
16091
  exports.characterStage = characterStage;
15329
16092
  exports.clipFromFindings = clipFromFindings;
@@ -15333,12 +16096,20 @@ var HackbuildMotionViews = (function(exports, three) {
15333
16096
  exports.clipsFromPack = clipsFromPack;
15334
16097
  exports.defineMotionViews = defineMotionViews;
15335
16098
  exports.estimateSeconds = estimateSeconds;
16099
+ exports.freeMeshes = freeMeshes;
15336
16100
  exports.gestureClip = gestureClip;
15337
16101
  exports.licenceLine = licenceLine;
16102
+ exports.meshTurntable = meshTurntable;
15338
16103
  exports.nextClip = nextClip;
16104
+ exports.packClips = packClips;
16105
+ exports.packCoverage = packCoverage;
15339
16106
  exports.rigCheck = rigCheck;
16107
+ exports.rigGestureClip = rigGestureClip;
15340
16108
  exports.secondsWord = secondsWord;
15341
16109
  exports.sizeLine = sizeLine;
15342
16110
  exports.speechEvents = speechEvents;
16111
+ exports.stageOrbit = stageOrbit;
16112
+ exports.threeStage = threeStage;
16113
+ exports.walkBvh = walkBvh;
15343
16114
  return exports;
15344
16115
  })({}, THREE);