@hackbuild/motion-views 0.1.0 → 0.1.2

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.
@@ -848,6 +848,7 @@ var HackbuildMotionViews = (function(exports, three) {
848
848
  if (x >= 1) return 1;
849
849
  return .5 - .5 * Math.cos(Math.PI * x);
850
850
  }
851
+ /** Timed visemes built from speech events and sampled with coarticulation. */
851
852
  var VisemeTimeline = class {
852
853
  keys = [];
853
854
  /** Keys of the last word that came without an end, open to rescaling. */
@@ -1040,6 +1041,7 @@ var HackbuildMotionViews = (function(exports, three) {
1040
1041
  ih: .3,
1041
1042
  ou: .25
1042
1043
  };
1044
+ /** The viseme driver: timed events first, the audio level when no timings cover the moment. */
1043
1045
  var LipSync = class {
1044
1046
  timeline = new VisemeTimeline();
1045
1047
  opts;
@@ -1071,6 +1073,7 @@ var HackbuildMotionViews = (function(exports, three) {
1071
1073
  ...opts
1072
1074
  };
1073
1075
  }
1076
+ /** Adds speech events to the timeline. */
1074
1077
  push(events) {
1075
1078
  this.timeline.push(events);
1076
1079
  }
@@ -9600,13 +9603,16 @@ var HackbuildMotionViews = (function(exports, three) {
9600
9603
  return ((t ^ t >>> 14) >>> 0) / 4294967296;
9601
9604
  };
9602
9605
  }
9606
+ /** A spring state at rest at `x` (default 0). */
9603
9607
  const springState = (x = 0) => ({
9604
9608
  x,
9605
9609
  v: 0,
9606
9610
  a: 0
9607
9611
  });
9608
9612
  const EPS = 1e-5;
9613
+ /** The damping constant for a half life in seconds, the time the spring takes to cover half the distance to its goal. */
9609
9614
  const halflifeToDamping = (halflife) => 4 * Math.LN2 / (halflife + EPS);
9615
+ /** A rational approximation of `exp(-x)` for x of 0 or more, used when `exact` is false. */
9610
9616
  const fastNegexp = (x) => 1 / (1 + x + .48 * x * x + .235 * x * x * x);
9611
9617
  const negexp = (x, exact) => exact ? Math.exp(-x) : fastNegexp(x);
9612
9618
  /** Critically damped spring toward `goal`. `exact` false uses the fast exp. */
@@ -9693,6 +9699,7 @@ var HackbuildMotionViews = (function(exports, three) {
9693
9699
  }
9694
9700
  };
9695
9701
  // ../avatar-host/dist/host.js
9702
+ /** Shows one source at a time through adapters: each show takes a ticket, a load that a later show overtook is discarded, and runtimes are shared or destroyed by key. */
9696
9703
  var AvatarHost = class {
9697
9704
  opts;
9698
9705
  slots = /* @__PURE__ */ new Map();
@@ -9770,6 +9777,7 @@ var HackbuildMotionViews = (function(exports, three) {
9770
9777
  }
9771
9778
  };
9772
9779
  // ../avatar-host/dist/loop.js
9780
+ /** The render loop of a stage: runs frames on the renderer's animation loop and stops while the page is hidden, off screen, covered, lost or paused. */
9773
9781
  var StageLoop = class {
9774
9782
  opts;
9775
9783
  /** Frames drawn since the loop was made. */
@@ -9969,8 +9977,11 @@ var HackbuildMotionViews = (function(exports, three) {
9969
9977
  return "the model did not load. its file may be damaged or of a kind the stage does not read.";
9970
9978
  }
9971
9979
  // ../presence/dist/angles.js
9980
+ /** Radians per degree. */
9972
9981
  const DEG = Math.PI / 180;
9982
+ /** Two pi, one full turn in radians. */
9973
9983
  const TAU = Math.PI * 2;
9984
+ /** Clamps a number to the range lo to hi. */
9974
9985
  const clamp = (x, lo, hi) => x < lo ? lo : x > hi ? hi : x;
9975
9986
  /** Wraps to (-pi, pi]. */
9976
9987
  function wrapAngle(a) {
@@ -10145,6 +10156,7 @@ var HackbuildMotionViews = (function(exports, three) {
10145
10156
  ]
10146
10157
  }
10147
10158
  };
10159
+ /** Where the eyes and head point each frame, with aversion episodes, saccades, head recruitment, clamped eye aim, blinks and a seam hold behind the body. */
10148
10160
  var GazeController = class {
10149
10161
  blinker;
10150
10162
  rng;
@@ -10372,7 +10384,9 @@ var HackbuildMotionViews = (function(exports, three) {
10372
10384
  const a = face.weights[i];
10373
10385
  return a + (face.weights[Math.min(n - 1, i + 1)] - a) * (f - i);
10374
10386
  }
10387
+ /** Length of a clip in seconds, from its frame count and rate. */
10375
10388
  const clipDuration = (c) => Math.max(0, c.frames - 1) / c.fps;
10389
+ /** A pose of the given bone count with every rotation at identity and the root at the origin. */
10376
10390
  function createPose(bones) {
10377
10391
  const rotations = new Float32Array(bones * 4);
10378
10392
  for (let i = 0; i < bones; i++) rotations[i * 4 + 3] = 1;
@@ -10381,6 +10395,7 @@ var HackbuildMotionViews = (function(exports, three) {
10381
10395
  root: /* @__PURE__ */ new Float32Array(3)
10382
10396
  };
10383
10397
  }
10398
+ /** Copies the rotations and root of one pose into another of the same size. */
10384
10399
  function copyPose(from, to) {
10385
10400
  to.rotations.set(from.rotations);
10386
10401
  to.root.set(from.root);
@@ -10405,6 +10420,7 @@ var HackbuildMotionViews = (function(exports, three) {
10405
10420
  }
10406
10421
  if (c.root) for (let k = 0; k < 3; k++) out.root[k] = c.root[i0 * 3 + k] * (1 - u) + c.root[i1 * 3 + k] * u;
10407
10422
  }
10423
+ /** How a loop wraps: the seam width in degrees, the blend window and the restart time. */
10408
10424
  function planLoop(c, opts = {}) {
10409
10425
  const seamDeg = seamDegrees(c);
10410
10426
  const d = clipDuration(c);
@@ -10467,6 +10483,7 @@ var HackbuildMotionViews = (function(exports, three) {
10467
10483
  }
10468
10484
  if (!mask) for (let k = 0; k < 3; k++) out.root[k] = a.root[k] + (b.root[k] - a.root[k]) * Math.min(1, w);
10469
10485
  }
10486
+ /** Layered clip player that writes every bone each frame: a base of idle and speed matched locomotion, a body layer and a masked upper body layer, with loop seams and idle handback. */
10470
10487
  var ClipPlayer = class {
10471
10488
  pose;
10472
10489
  /** This frame's expression weights from the clips' face tracks, each weighted by its layer weight; read after `update`. */
@@ -10740,12 +10757,13 @@ var HackbuildMotionViews = (function(exports, three) {
10740
10757
  }
10741
10758
  };
10742
10759
  // ../presence/dist/face.js
10743
- /** The weights a quiet face rests at (vendor, from earlier work). */
10760
+ /** The weights a quiet face rests at (vendor). */
10744
10761
  const RESTING_FACE = {
10745
10762
  happy: .25,
10746
10763
  relaxed: .3
10747
10764
  };
10748
10765
  const clamp01 = (x) => x < 0 ? 0 : x > 1 ? 1 : x;
10766
+ /** The face driver: eases moods toward their targets, rests at a slight smile, and writes lid, mouth and clip face weights to one expression sink. */
10749
10767
  var Face = class {
10750
10768
  sink;
10751
10769
  /** Mouth shapes from speech for this frame; call lipsync's `drive` on it before `update`. */
@@ -10974,6 +10992,7 @@ var HackbuildMotionViews = (function(exports, three) {
10974
10992
  init_bones();
10975
10993
  const UPPER = /^(spine|chest|upperChest|neck|head|left|right)(?!.*(Leg|Foot|Toes))/;
10976
10994
  const aligned = (o) => !o || o.getWorldQuaternion(new three.Quaternion()).angleTo(new three.Quaternion()) < .17;
10995
+ /** A loaded character driven in the presence frame order: clip player, gaze, lip sync and face, written to its bones each frame. */
10977
10996
  var Body = class {
10978
10997
  avatar;
10979
10998
  names = [];
@@ -11163,6 +11182,7 @@ var HackbuildMotionViews = (function(exports, three) {
11163
11182
  }
11164
11183
  };
11165
11184
  // ../avatar-host/dist/follow.js
11185
+ /** Keeps a body framed: eases toward a new framing with a dead zone, and leaves a distance or pan the person picked alone. */
11166
11186
  var FollowCamera = class {
11167
11187
  camera;
11168
11188
  target;
@@ -13140,6 +13160,7 @@ var HackbuildMotionViews = (function(exports, three) {
13140
13160
  const { loadEnvironment } = await Promise.resolve().then(() => (init_three(), three_exports));
13141
13161
  return loadEnvironment(req.preset, target.scene, target.renderer, req.resolve ? { resolve: req.resolve } : {});
13142
13162
  };
13163
+ /** Shows one lit scene at a time on a stage; a later request overtakes one still loading. */
13143
13164
  var EnvironmentSlot = class {
13144
13165
  target;
13145
13166
  load;
@@ -13196,9 +13217,11 @@ var HackbuildMotionViews = (function(exports, three) {
13196
13217
  init_three$1();
13197
13218
  init_load();
13198
13219
  init_placeholder();
13220
+ /** The line a stage shows when the browser drops its 3D context. */
13199
13221
  const LOST_COPY = "the 3d view was lost. press to restore.";
13200
13222
  /** Pointer moves count as attention for this long, seconds (vendor). */
13201
13223
  const POINTER_WINDOW = 2;
13224
+ /** A three.js stage in a container: renderer, camera, orbit controls, follow camera, loop, environment slot and the body it shows. */
13202
13225
  var AvatarStage = class {
13203
13226
  container;
13204
13227
  opts;
@@ -13934,6 +13957,7 @@ var HackbuildMotionViews = (function(exports, three) {
13934
13957
  };
13935
13958
  }
13936
13959
  // src/gestures.ts
13960
+ /** Every gesture `gestureClip` can make. */
13937
13961
  const GESTURES = [
13938
13962
  "wave",
13939
13963
  "nod",
@@ -15296,10 +15320,579 @@ var HackbuildMotionViews = (function(exports, three) {
15296
15320
  customElements.define("hb-clip-strip", Strip);
15297
15321
  }
15298
15322
  }
15323
+ // src/stage.ts
15324
+ /** A drag orbit on `el` for `camera`: horizontal drag turns, vertical drag tilts, the wheel moves in and out. */
15325
+ function stageOrbit(camera, el) {
15326
+ const target = new three.Vector3();
15327
+ const s = new three.Spherical();
15328
+ let drag = null;
15329
+ const turn = (dTheta, dPhi, scale = 1) => {
15330
+ s.setFromVector3(camera.position.clone().sub(target));
15331
+ s.theta += dTheta;
15332
+ s.phi = Math.min(Math.PI * .49, Math.max(.08, s.phi + dPhi));
15333
+ s.radius = Math.min(200, Math.max(.3, s.radius * scale));
15334
+ camera.position.setFromSpherical(s).add(target);
15335
+ };
15336
+ const down = (e) => {
15337
+ if (!orbit.enabled) return;
15338
+ drag = {
15339
+ x: e.clientX,
15340
+ y: e.clientY,
15341
+ id: e.pointerId
15342
+ };
15343
+ el.setPointerCapture?.(e.pointerId);
15344
+ };
15345
+ const move = (e) => {
15346
+ if (!drag || e.pointerId !== drag.id || !orbit.enabled) return;
15347
+ turn(-(e.clientX - drag.x) * .008, -(e.clientY - drag.y) * .008);
15348
+ drag.x = e.clientX;
15349
+ drag.y = e.clientY;
15350
+ };
15351
+ const up = () => drag = null;
15352
+ const wheel = (e) => {
15353
+ if (!orbit.enabled) return;
15354
+ e.preventDefault();
15355
+ turn(0, 0, Math.exp(e.deltaY * .001));
15356
+ };
15357
+ el.addEventListener("pointerdown", down);
15358
+ el.addEventListener("pointermove", move);
15359
+ el.addEventListener("pointerup", up);
15360
+ el.addEventListener("pointercancel", up);
15361
+ el.addEventListener("wheel", wheel, { passive: false });
15362
+ const orbit = {
15363
+ target,
15364
+ enabled: true,
15365
+ update: () => {
15366
+ if (orbit.enabled) camera.lookAt(target);
15367
+ },
15368
+ dispose() {
15369
+ el.removeEventListener("pointerdown", down);
15370
+ el.removeEventListener("pointermove", move);
15371
+ el.removeEventListener("pointerup", up);
15372
+ el.removeEventListener("pointercancel", up);
15373
+ el.removeEventListener("wheel", wheel);
15374
+ }
15375
+ };
15376
+ return orbit;
15377
+ }
15378
+ /** Frees the geometry and materials of every mesh under `root`. */
15379
+ function freeMeshes(root) {
15380
+ root.traverse((o) => {
15381
+ if (o instanceof three.Mesh) {
15382
+ o.geometry.dispose();
15383
+ for (const m of [o.material].flat()) m.dispose();
15384
+ }
15385
+ });
15386
+ }
15387
+ /**
15388
+ * A stage lit in paper light that fills `host`: it sizes with the host,
15389
+ * calls `tick(dt, t)` each frame (dt capped at 50 ms), draws, and on
15390
+ * dispose stops the loop and frees the renderer, the orbit and every mesh.
15391
+ */
15392
+ function threeStage(host, tick, opts = {}) {
15393
+ const renderer = opts.renderer ?? new three.WebGLRenderer({ antialias: true });
15394
+ renderer.setPixelRatio(Math.min(2, globalThis.devicePixelRatio || 1));
15395
+ renderer.domElement.style.cssText = "display:block;width:100%;height:100%;touch-action:none";
15396
+ host.append(renderer.domElement);
15397
+ const scene = new three.Scene();
15398
+ scene.background = new three.Color("#efe9db");
15399
+ const camera = new three.PerspectiveCamera(40, 1, .05, 200);
15400
+ camera.position.set(2.4, 1.6, 3.2);
15401
+ const orbit = stageOrbit(camera, renderer.domElement);
15402
+ orbit.target.set(0, .5, 0);
15403
+ scene.add(new three.AmbientLight("#ffffff", 1.1));
15404
+ const sun = new three.DirectionalLight("#ffffff", 1.6);
15405
+ sun.position.set(3, 6, 4);
15406
+ scene.add(sun);
15407
+ if (opts.ground !== false) {
15408
+ const g = new three.PlaneGeometry(40, 40);
15409
+ g.rotateX(-Math.PI / 2);
15410
+ scene.add(new three.Mesh(g, new three.MeshStandardMaterial({
15411
+ color: "#d9d0bd",
15412
+ roughness: 1
15413
+ })));
15414
+ }
15415
+ const fit = () => {
15416
+ const w = Math.max(1, host.clientWidth);
15417
+ const h = Math.max(1, host.clientHeight);
15418
+ renderer.setSize(w, h, false);
15419
+ camera.aspect = w / h;
15420
+ camera.updateProjectionMatrix();
15421
+ };
15422
+ const ro = typeof ResizeObserver === "function" ? new ResizeObserver(fit) : null;
15423
+ ro?.observe(host);
15424
+ fit();
15425
+ let raf = 0;
15426
+ let last = performance.now();
15427
+ let t = 0;
15428
+ const frame = (now) => {
15429
+ const dt = Math.min(.05, Math.max(0, (now - last) / 1e3));
15430
+ last = now;
15431
+ t += dt;
15432
+ tick(dt, t);
15433
+ orbit.update();
15434
+ renderer.render(scene, camera);
15435
+ raf = requestAnimationFrame(frame);
15436
+ };
15437
+ raf = requestAnimationFrame(frame);
15438
+ return {
15439
+ scene,
15440
+ camera,
15441
+ renderer,
15442
+ orbit,
15443
+ dispose() {
15444
+ cancelAnimationFrame(raf);
15445
+ ro?.disconnect();
15446
+ orbit.dispose();
15447
+ freeMeshes(scene);
15448
+ renderer.dispose();
15449
+ renderer.domElement.remove();
15450
+ }
15451
+ };
15452
+ }
15453
+ /**
15454
+ * A turntable that fills `host`: hemisphere light, drag to turn, one
15455
+ * object at a time, sized for a relief or a depth surface tens of units
15456
+ * across (the camera starts 80 units out, looking down at 30 degrees).
15457
+ */
15458
+ function meshTurntable(host, opts = {}) {
15459
+ const stage = threeStage(host, () => {}, {
15460
+ ground: false,
15461
+ renderer: opts.renderer ?? new three.WebGLRenderer({
15462
+ antialias: true,
15463
+ preserveDrawingBuffer: true
15464
+ })
15465
+ });
15466
+ stage.camera.position.set(0, -40, 70);
15467
+ stage.camera.near = .1;
15468
+ stage.camera.far = 1e3;
15469
+ stage.camera.updateProjectionMatrix();
15470
+ stage.orbit.target.set(0, 0, 0);
15471
+ stage.scene.add(new three.HemisphereLight(16777215, 9077104, 1.2));
15472
+ let shown = null;
15473
+ return {
15474
+ stage,
15475
+ show(o) {
15476
+ if (shown) {
15477
+ stage.scene.remove(shown);
15478
+ freeMeshes(shown);
15479
+ }
15480
+ shown = o;
15481
+ stage.scene.add(o);
15482
+ },
15483
+ dispose: () => stage.dispose()
15484
+ };
15485
+ }
15486
+ /** The bone names of `boxDog`, in the shape `@hackbuild/gait` reads (hips, spine, tail, four legs). */
15487
+ const BOX_DOG_BONES = {
15488
+ hips: "hips",
15489
+ spine: ["spine2", "chest"],
15490
+ tail: [
15491
+ "tail1",
15492
+ "tail3",
15493
+ "tail_03"
15494
+ ],
15495
+ legs: {
15496
+ LF: {
15497
+ up: "frontUpr.L",
15498
+ mid: "frontLeg.L_03",
15499
+ end: "frontHorselink.L",
15500
+ toes: ["frontToe.L"]
15501
+ },
15502
+ RF: {
15503
+ up: "frontUpr.R",
15504
+ mid: "frontLeg.R_03",
15505
+ end: "frontHorselink.R",
15506
+ toes: ["frontToe.R"]
15507
+ },
15508
+ LH: {
15509
+ up: "rearUpr.L",
15510
+ mid: "rearLwr.L",
15511
+ end: "rearHorselink.L",
15512
+ toes: ["rearFoot.L", "rearToe.L"]
15513
+ },
15514
+ RH: {
15515
+ up: "rearUpr.R",
15516
+ mid: "rearLwr.R",
15517
+ end: "rearHorselink.R",
15518
+ toes: ["rearFoot.R", "rearToe.R"]
15519
+ }
15520
+ }
15521
+ };
15522
+ /**
15523
+ * A dog of bones and boxes facing +z, about 0.78 m nose to tail with the
15524
+ * hips 0.38 m up; bone names are `BOX_DOG_BONES`. Each bone carries a box
15525
+ * to its child, so the legs show what a gait does to them.
15526
+ */
15527
+ function boxDog(color = "#c9a36b") {
15528
+ const root = new three.Group();
15529
+ const bone = (name, parent, p) => {
15530
+ const b = new three.Bone();
15531
+ b.name = name;
15532
+ b.position.set(...p);
15533
+ parent.add(b);
15534
+ return b;
15535
+ };
15536
+ const hips = bone("hips", root, [
15537
+ 0,
15538
+ .38,
15539
+ 0
15540
+ ]);
15541
+ const chest = bone("chest", bone("spine2", hips, [
15542
+ 0,
15543
+ 0,
15544
+ .1
15545
+ ]), [
15546
+ 0,
15547
+ 0,
15548
+ .12
15549
+ ]);
15550
+ const head = bone("head", bone("neck1", chest, [
15551
+ 0,
15552
+ .08,
15553
+ .05
15554
+ ]), [
15555
+ 0,
15556
+ .08,
15557
+ .06
15558
+ ]);
15559
+ for (const [s, x] of [["L", .09], ["R", -.09]]) {
15560
+ const fe = bone(`frontHorselink.${s}`, bone(`frontLeg.${s}_03`, bone(`frontUpr.${s}`, chest, [
15561
+ x,
15562
+ 0,
15563
+ 0
15564
+ ]), [
15565
+ 0,
15566
+ -.18,
15567
+ -.08
15568
+ ]), [
15569
+ 0,
15570
+ -.16,
15571
+ .08
15572
+ ]);
15573
+ bone(`frontToe.${s}`, fe, [
15574
+ 0,
15575
+ -.02,
15576
+ .03
15577
+ ]);
15578
+ const re = bone(`rearHorselink.${s}`, bone(`rearLwr.${s}`, bone(`rearUpr.${s}`, hips, [
15579
+ x,
15580
+ 0,
15581
+ -.2
15582
+ ]), [
15583
+ 0,
15584
+ -.17,
15585
+ .07
15586
+ ]), [
15587
+ 0,
15588
+ -.15,
15589
+ -.08
15590
+ ]);
15591
+ bone(`rearToe.${s}`, bone(`rearFoot.${s}`, re, [
15592
+ 0,
15593
+ -.02,
15594
+ .01
15595
+ ]), [
15596
+ 0,
15597
+ -.02,
15598
+ .03
15599
+ ]);
15600
+ }
15601
+ bone("tail_03", bone("tail3", bone("tail1", hips, [
15602
+ 0,
15603
+ .02,
15604
+ -.25
15605
+ ]), [
15606
+ 0,
15607
+ 0,
15608
+ -.08
15609
+ ]), [
15610
+ 0,
15611
+ 0,
15612
+ -.08
15613
+ ]);
15614
+ const mat = new three.MeshStandardMaterial({
15615
+ color,
15616
+ roughness: .7
15617
+ });
15618
+ const Z = new three.Vector3(0, 0, 1);
15619
+ const parts = [];
15620
+ root.traverse((o) => {
15621
+ if (!(o instanceof three.Bone)) return;
15622
+ for (const c of o.children) {
15623
+ if (!(c instanceof three.Bone) || c.position.length() < 1e-4) continue;
15624
+ const thick = c.name === "spine2" || c.name === "chest" ? .17 : /Upr/.test(c.name) ? .07 : /tail/.test(c.name) ? .03 : .045;
15625
+ const m = new three.Mesh(new three.BoxGeometry(thick, thick, c.position.length()), mat);
15626
+ m.position.copy(c.position).multiplyScalar(.5);
15627
+ m.quaternion.setFromUnitVectors(Z, c.position.clone().normalize());
15628
+ parts.push([o, m]);
15629
+ }
15630
+ });
15631
+ for (const [o, m] of parts) o.add(m);
15632
+ const skull = new three.Mesh(new three.BoxGeometry(.11, .1, .18), mat);
15633
+ skull.position.set(0, .02, .05);
15634
+ head.add(skull);
15635
+ return root;
15636
+ }
15637
+ /**
15638
+ * A two step walk loop as bvh text for a humanoid that is not ours: other
15639
+ * bone names (Hips, LeftUpLeg, RightForeArm and so on), centimetres, arms
15640
+ * down, ZXY channels. A retarget has real work to do on it.
15641
+ */
15642
+ function walkBvh(o = {}) {
15643
+ const { seconds = 2.4, fps = 30, swing = 1 } = o;
15644
+ const J = [
15645
+ [
15646
+ "Hips",
15647
+ -1,
15648
+ [
15649
+ 0,
15650
+ 0,
15651
+ 0
15652
+ ]
15653
+ ],
15654
+ [
15655
+ "Spine",
15656
+ 0,
15657
+ [
15658
+ 0,
15659
+ 12,
15660
+ 0
15661
+ ]
15662
+ ],
15663
+ [
15664
+ "Spine1",
15665
+ 1,
15666
+ [
15667
+ 0,
15668
+ 16,
15669
+ 0
15670
+ ]
15671
+ ],
15672
+ [
15673
+ "Neck",
15674
+ 2,
15675
+ [
15676
+ 0,
15677
+ 26,
15678
+ 0
15679
+ ]
15680
+ ],
15681
+ [
15682
+ "Head",
15683
+ 3,
15684
+ [
15685
+ 0,
15686
+ 11,
15687
+ 0
15688
+ ]
15689
+ ],
15690
+ [
15691
+ "LeftArm",
15692
+ 2,
15693
+ [
15694
+ 18,
15695
+ 22,
15696
+ 0
15697
+ ]
15698
+ ],
15699
+ [
15700
+ "LeftForeArm",
15701
+ 5,
15702
+ [
15703
+ 29,
15704
+ 0,
15705
+ 0
15706
+ ]
15707
+ ],
15708
+ [
15709
+ "LeftHand",
15710
+ 6,
15711
+ [
15712
+ 26,
15713
+ 0,
15714
+ 0
15715
+ ]
15716
+ ],
15717
+ [
15718
+ "RightArm",
15719
+ 2,
15720
+ [
15721
+ -18,
15722
+ 22,
15723
+ 0
15724
+ ]
15725
+ ],
15726
+ [
15727
+ "RightForeArm",
15728
+ 8,
15729
+ [
15730
+ -29,
15731
+ 0,
15732
+ 0
15733
+ ]
15734
+ ],
15735
+ [
15736
+ "RightHand",
15737
+ 9,
15738
+ [
15739
+ -26,
15740
+ 0,
15741
+ 0
15742
+ ]
15743
+ ],
15744
+ [
15745
+ "LeftUpLeg",
15746
+ 0,
15747
+ [
15748
+ 10,
15749
+ -6,
15750
+ 0
15751
+ ]
15752
+ ],
15753
+ [
15754
+ "LeftLeg",
15755
+ 11,
15756
+ [
15757
+ 0,
15758
+ -47,
15759
+ 0
15760
+ ]
15761
+ ],
15762
+ [
15763
+ "LeftFoot",
15764
+ 12,
15765
+ [
15766
+ 0,
15767
+ -45,
15768
+ 0
15769
+ ]
15770
+ ],
15771
+ [
15772
+ "LeftToeBase",
15773
+ 13,
15774
+ [
15775
+ 0,
15776
+ -8,
15777
+ 14
15778
+ ]
15779
+ ],
15780
+ [
15781
+ "RightUpLeg",
15782
+ 0,
15783
+ [
15784
+ -10,
15785
+ -6,
15786
+ 0
15787
+ ]
15788
+ ],
15789
+ [
15790
+ "RightLeg",
15791
+ 15,
15792
+ [
15793
+ 0,
15794
+ -47,
15795
+ 0
15796
+ ]
15797
+ ],
15798
+ [
15799
+ "RightFoot",
15800
+ 16,
15801
+ [
15802
+ 0,
15803
+ -45,
15804
+ 0
15805
+ ]
15806
+ ],
15807
+ [
15808
+ "RightToeBase",
15809
+ 17,
15810
+ [
15811
+ 0,
15812
+ -8,
15813
+ 14
15814
+ ]
15815
+ ]
15816
+ ];
15817
+ const kids = (i) => J.map((j, k) => [j, k]).filter(([j]) => j[1] === i).map(([, k]) => k);
15818
+ const order = [];
15819
+ const write = (i, pad) => {
15820
+ order.push(i);
15821
+ const [name, parent, off] = J[i];
15822
+ const ch = parent < 0 ? "CHANNELS 6 Xposition Yposition Zposition Zrotation Xrotation Yrotation" : "CHANNELS 3 Zrotation Xrotation Yrotation";
15823
+ const c = kids(i);
15824
+ 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`;
15825
+ return `${pad}${parent < 0 ? "ROOT" : "JOINT"} ${name}\n${pad}{\n${pad} OFFSET ${off.join(" ")}\n${pad} ${ch}\n${body}${pad}}\n`;
15826
+ };
15827
+ const tree = write(0, "");
15828
+ const n = Math.round(seconds * fps);
15829
+ const lines = [];
15830
+ for (let f = 0; f < n; f++) {
15831
+ const ph = f / fps * 2 * Math.PI * (1 / seconds) * 2;
15832
+ const s = Math.sin(ph) * swing;
15833
+ const rot = {
15834
+ LeftUpLeg: [
15835
+ 0,
15836
+ -28 * s,
15837
+ 0
15838
+ ],
15839
+ RightUpLeg: [
15840
+ 0,
15841
+ 28 * s,
15842
+ 0
15843
+ ],
15844
+ LeftLeg: [
15845
+ 0,
15846
+ 45 * Math.max(0, Math.sin(ph + 1.4)) * swing,
15847
+ 0
15848
+ ],
15849
+ RightLeg: [
15850
+ 0,
15851
+ 45 * Math.max(0, Math.sin(ph + 1.4 + Math.PI)) * swing,
15852
+ 0
15853
+ ],
15854
+ LeftArm: [
15855
+ -70,
15856
+ 22 * s,
15857
+ 0
15858
+ ],
15859
+ RightArm: [
15860
+ 70,
15861
+ -22 * s,
15862
+ 0
15863
+ ],
15864
+ LeftForeArm: [
15865
+ 0,
15866
+ 0,
15867
+ -15
15868
+ ],
15869
+ RightForeArm: [
15870
+ 0,
15871
+ 0,
15872
+ 15
15873
+ ]
15874
+ };
15875
+ lines.push(order.map((i) => (i === 0 ? [
15876
+ 0,
15877
+ 106 + 2.5 * Math.cos(2 * ph),
15878
+ 0,
15879
+ 2 * s,
15880
+ 0,
15881
+ 3 * s
15882
+ ] : rot[J[i][0]] ?? [
15883
+ 0,
15884
+ 0,
15885
+ 0
15886
+ ]).map((v) => v.toFixed(3)).join(" ")).join(" "));
15887
+ }
15888
+ return `HIERARCHY\n${tree}MOTION\nFrames: ${n}\nFrame Time: ${(1 / fps).toFixed(6)}\n${lines.join("\n")}\n`;
15889
+ }
15890
+ exports.BOX_DOG_BONES = BOX_DOG_BONES;
15299
15891
  exports.DEFAULT_VERBS = DEFAULT_VERBS;
15300
15892
  exports.GESTURES = GESTURES;
15301
15893
  exports.animationClipOf = animationClipOf;
15302
15894
  exports.avatarDrop = avatarDrop;
15895
+ exports.boxDog = boxDog;
15303
15896
  exports.bytesWord = bytesWord;
15304
15897
  exports.characterStage = characterStage;
15305
15898
  exports.clipFromFindings = clipFromFindings;
@@ -15309,12 +15902,17 @@ var HackbuildMotionViews = (function(exports, three) {
15309
15902
  exports.clipsFromPack = clipsFromPack;
15310
15903
  exports.defineMotionViews = defineMotionViews;
15311
15904
  exports.estimateSeconds = estimateSeconds;
15905
+ exports.freeMeshes = freeMeshes;
15312
15906
  exports.gestureClip = gestureClip;
15313
15907
  exports.licenceLine = licenceLine;
15908
+ exports.meshTurntable = meshTurntable;
15314
15909
  exports.nextClip = nextClip;
15315
15910
  exports.rigCheck = rigCheck;
15316
15911
  exports.secondsWord = secondsWord;
15317
15912
  exports.sizeLine = sizeLine;
15318
15913
  exports.speechEvents = speechEvents;
15914
+ exports.stageOrbit = stageOrbit;
15915
+ exports.threeStage = threeStage;
15916
+ exports.walkBvh = walkBvh;
15319
15917
  return exports;
15320
15918
  })({}, THREE);