tosijs-3d 0.12.5 → 0.12.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.
Files changed (147) hide show
  1. package/CHANGELOG.md +2 -2
  2. package/changelog/v0.12.6.md +46 -0
  3. package/dist/body-export.d.ts +25 -0
  4. package/dist/body-export.d.ts.map +1 -1
  5. package/dist/body-export.js +57 -2
  6. package/dist/body-export.js.map +1 -1
  7. package/dist/body-sweep.d.ts +47 -0
  8. package/dist/body-sweep.d.ts.map +1 -0
  9. package/dist/body-sweep.js +468 -0
  10. package/dist/body-sweep.js.map +1 -0
  11. package/dist/bvh.d.ts +26 -0
  12. package/dist/bvh.d.ts.map +1 -0
  13. package/dist/bvh.js +415 -0
  14. package/dist/bvh.js.map +1 -0
  15. package/dist/character-builder.d.ts.map +1 -1
  16. package/dist/character-builder.js +129 -51
  17. package/dist/character-builder.js.map +1 -1
  18. package/dist/character-core.js +3 -3
  19. package/dist/character-file.d.ts +12 -0
  20. package/dist/character-file.d.ts.map +1 -1
  21. package/dist/character-file.js +27 -0
  22. package/dist/character-file.js.map +1 -1
  23. package/dist/character-sources.d.ts +4 -2
  24. package/dist/character-sources.d.ts.map +1 -1
  25. package/dist/character-sources.js +16 -4
  26. package/dist/character-sources.js.map +1 -1
  27. package/dist/character-store.d.ts +1 -1
  28. package/dist/character-store.d.ts.map +1 -1
  29. package/dist/character-store.js +15 -0
  30. package/dist/character-store.js.map +1 -1
  31. package/dist/character.d.ts +38 -4
  32. package/dist/character.d.ts.map +1 -1
  33. package/dist/character.js +346 -33
  34. package/dist/character.js.map +1 -1
  35. package/dist/clip-store.d.ts +17 -0
  36. package/dist/clip-store.d.ts.map +1 -0
  37. package/dist/clip-store.js +42 -0
  38. package/dist/clip-store.js.map +1 -0
  39. package/dist/cloth-bake.d.ts +23 -1
  40. package/dist/cloth-bake.d.ts.map +1 -1
  41. package/dist/cloth-bake.js +88 -0
  42. package/dist/cloth-bake.js.map +1 -1
  43. package/dist/eye-art.d.ts +19 -0
  44. package/dist/eye-art.d.ts.map +1 -1
  45. package/dist/eye-art.js +73 -0
  46. package/dist/eye-art.js.map +1 -1
  47. package/dist/garment-cut.d.ts.map +1 -1
  48. package/dist/garment-cut.js +4 -1
  49. package/dist/garment-cut.js.map +1 -1
  50. package/dist/garment-proxy.d.ts +28 -1
  51. package/dist/garment-proxy.d.ts.map +1 -1
  52. package/dist/garment-proxy.js +75 -10
  53. package/dist/garment-proxy.js.map +1 -1
  54. package/dist/glb-clips.d.ts +2 -0
  55. package/dist/glb-clips.d.ts.map +1 -1
  56. package/dist/glb-clips.js +4 -1
  57. package/dist/glb-clips.js.map +1 -1
  58. package/dist/glb-rig.d.ts +6 -0
  59. package/dist/glb-rig.d.ts.map +1 -1
  60. package/dist/glb-rig.js +17 -0
  61. package/dist/glb-rig.js.map +1 -1
  62. package/dist/hair-place.d.ts +29 -1
  63. package/dist/hair-place.d.ts.map +1 -1
  64. package/dist/hair-place.js +90 -1
  65. package/dist/hair-place.js.map +1 -1
  66. package/dist/human-face.d.ts.map +1 -1
  67. package/dist/human-face.js +7 -74
  68. package/dist/human-face.js.map +1 -1
  69. package/dist/human-hair.d.ts +1 -1
  70. package/dist/human-hair.d.ts.map +1 -1
  71. package/dist/human-hair.js +1 -1
  72. package/dist/human-hair.js.map +1 -1
  73. package/dist/index.d.ts +12 -3
  74. package/dist/index.d.ts.map +1 -1
  75. package/dist/index.js +8 -3
  76. package/dist/index.js.map +1 -1
  77. package/dist/jpeg.d.ts +6 -0
  78. package/dist/jpeg.d.ts.map +1 -0
  79. package/dist/jpeg.js +534 -0
  80. package/dist/jpeg.js.map +1 -0
  81. package/dist/outline-field.d.ts +9 -0
  82. package/dist/outline-field.d.ts.map +1 -1
  83. package/dist/outline-field.js +52 -0
  84. package/dist/outline-field.js.map +1 -1
  85. package/dist/panel-layer.d.ts.map +1 -1
  86. package/dist/panel-layer.js +2 -0
  87. package/dist/panel-layer.js.map +1 -1
  88. package/dist/png.d.ts +4 -3
  89. package/dist/png.d.ts.map +1 -1
  90. package/dist/png.js +12 -10
  91. package/dist/png.js.map +1 -1
  92. package/dist/popup-surface.d.ts +9 -0
  93. package/dist/popup-surface.d.ts.map +1 -1
  94. package/dist/popup-surface.js +75 -18
  95. package/dist/popup-surface.js.map +1 -1
  96. package/dist/remesh.js +2 -1
  97. package/dist/remesh.js.map +1 -1
  98. package/dist/retarget-babylon.d.ts +15 -0
  99. package/dist/retarget-babylon.d.ts.map +1 -1
  100. package/dist/retarget-babylon.js +29 -11
  101. package/dist/retarget-babylon.js.map +1 -1
  102. package/dist/retarget.d.ts +10 -0
  103. package/dist/retarget.d.ts.map +1 -1
  104. package/dist/retarget.js +164 -0
  105. package/dist/retarget.js.map +1 -1
  106. package/dist/rig-build.d.ts.map +1 -1
  107. package/dist/rig-build.js +23 -7
  108. package/dist/rig-build.js.map +1 -1
  109. package/dist/rig-fit.d.ts +21 -0
  110. package/dist/rig-fit.d.ts.map +1 -1
  111. package/dist/rig-fit.js +69 -2
  112. package/dist/rig-fit.js.map +1 -1
  113. package/dist/rig-recipe.d.ts +12 -1
  114. package/dist/rig-recipe.d.ts.map +1 -1
  115. package/dist/rig-recipe.js +26 -0
  116. package/dist/rig-recipe.js.map +1 -1
  117. package/dist/rig-tool.d.ts.map +1 -1
  118. package/dist/rig-tool.js +101 -17
  119. package/dist/rig-tool.js.map +1 -1
  120. package/dist/rigged-body-glb.d.ts +59 -0
  121. package/dist/rigged-body-glb.d.ts.map +1 -1
  122. package/dist/rigged-body-glb.js +153 -40
  123. package/dist/rigged-body-glb.js.map +1 -1
  124. package/dist/rigged-body.d.ts +3 -1
  125. package/dist/rigged-body.d.ts.map +1 -1
  126. package/dist/rigged-body.js +4 -0
  127. package/dist/rigged-body.js.map +1 -1
  128. package/dist/skin-paint.d.ts +15 -0
  129. package/dist/skin-paint.d.ts.map +1 -1
  130. package/dist/skin-paint.js +34 -0
  131. package/dist/skin-paint.js.map +1 -1
  132. package/dist/tailor-panel.d.ts.map +1 -1
  133. package/dist/tailor-panel.js +13 -5
  134. package/dist/tailor-panel.js.map +1 -1
  135. package/dist/tailor-recipe.d.ts +65 -0
  136. package/dist/tailor-recipe.d.ts.map +1 -0
  137. package/dist/tailor-recipe.js +260 -0
  138. package/dist/tailor-recipe.js.map +1 -0
  139. package/dist/tailor-tool.d.ts +2 -17
  140. package/dist/tailor-tool.d.ts.map +1 -1
  141. package/dist/tailor-tool.js +77 -129
  142. package/dist/tailor-tool.js.map +1 -1
  143. package/dist/widgets3d.d.ts +8 -0
  144. package/dist/widgets3d.d.ts.map +1 -1
  145. package/dist/widgets3d.js +16 -5
  146. package/dist/widgets3d.js.map +1 -1
  147. package/package.json +1 -1
package/CHANGELOG.md CHANGED
@@ -12,9 +12,9 @@ Upgrading across a minor? Start with [Migration](/Migration/).
12
12
 
13
13
  ## Unreleased
14
14
 
15
- ## 0.12.5
15
+ ## 0.12.6
16
16
 
17
- The latest release. Exported bodies carry clips, garments and held items; the cast's rigs are engine-free; the Babylon peers are optional (install them yourself); the character builder gets a Character menu, a hair manipulator and sub-sections. See [0.12.5](/v0.12.5/).
17
+ The latest release. BVH clips kept and carried in character files; MakeHuman's body exports dressed, with hair, skin and eyes; tailored garments fit any body; feet stay planted under retargeting; marker rigs place pelvis, neck and knees as the mannequins do. See [0.12.6](/v0.12.6/).
18
18
 
19
19
  ## Every version
20
20
 
@@ -0,0 +1,46 @@
1
+ # 0.12.6
2
+
3
+ <!--{ "parent": "CHANGELOG", "order": 9987994 }-->
4
+
5
+ For the character builder and the rig tool: clips from motion capture (BVH) kept in the browser and carried in character files, exports of MakeHuman's body in its clothes, hair, skin, eyes and lashes, a tailor's garment that fits any body, and retargeted feet that stay on the ground. Rigs from markers place the pelvis, neck and the AI cast's knees as UAL's mannequins have them.
6
+
7
+ Size: barrel (min, packages external) 1698.6 KB raw / 591.0 KB gz, up 43.5 KB / 17.5 KB gz (+2.6%) on 0.12.5.
8
+
9
+ ### Added
10
+
11
+ - Rig tool: drag a marker forward or back in a side view to set its joint's depth (the fit puts each at the middle of the body's thickness, and the mannequin's pelvis is well behind it). Kept in the rig recipe as `binding.depths`, an offset per marker from the fit's depth; `fitSkeleton`'s `depths`, `bodyFromMarkers`'s `depths` and `rigFromMarkers`'s sixth argument take it too.
12
+ - Rig tool: a **floor** slider (Motion) moves the body up or down from where its soles stand, for one that floats or sinks; kept in the rig recipe as `floor` (metres), and the character builder stands the body the same way. At rest the soles, not the mesh's lowest point, are put on the floor.
13
+ - Character builder: exporting MakeHuman's body writes the clothes it wears (MakeHuman's own and garments of your own made on it), fitted as drawn, with their pictures and looks. `character.exportGarments()` gives them for `riggedBodyGlb`'s `garments` on either kind of body; `onSkin` (`garment-proxy`) binds a piece made for MakeHuman's pack to the skin a body draws, and `packGarmentMaterial` gives a pack piece's material as data.
14
+ - The export of MakeHuman's body carries its eyelashes, drawn and faded as in the builder, following the head. The fade is a small ramp picture, so it needs no vertex alpha (`shortenLashes`, `lashAlpha`, `lashUvs`, `lashPicture` in `eye-art`).
15
+ - The export of MakeHuman's body carries its hair, beard, moustache and brows: Quaternius' pieces placed as the builder places them (scalp hair following the head, tucked under a hat), MakeHuman's own hair and brows bound like clothes, each picture coloured as the builder colours hair (`recolourHair`, `cloth-bake`). A garment may `follow` one joint wholly; `riggedBodyGlb` tucks the skin under clothes only. `readHairLibrary` now gives each part's uvs and material, and `readHairMaterials` the library's pictures.
16
+ - The export of MakeHuman's body carries its skin (its tone as the material, lips and stubble as vertex colours: `skinSurface`, `skin-paint`) and its eyes with Tonio's eye art in its iris colour (`riggedBodyGlb`'s `eyeTexture`, laid on by `gltfEyeUvs`). `character.exportCharacter()` gives the body, garments and eye picture together.
17
+ - Export (rig tool, character builder): **animation** puts the clip playing in the GLB, retargeted onto the skeleton as written, whether it is UAL's, a GLB of your own or a BVH capture. A host passes it as `clip` on the export target (`ExportClip`: the file and the clip's name); `exportClip` reads one into `riggedBodyGlb`'s `clips`.
18
+ - A character file carries the clip it plays when that is one of your own (`clips`: the BVH or GLB file, by name), so it plays on a page that has never seen the file; the builder reads and keeps it on load. `characterStore` keeps the bytes once, as it does garments.
19
+ - A garment's look goes out in its picture: `riggedBodyGlb` writes a recoloured cloth's texture recoloured, so any engine shows what the builder does (`bake: false` keeps the pictures as they came). `bakeClothLook(picture, look)` (`cloth-bake`) is the step on its own.
20
+ - `jpegDecode` and `decodeImage` (`tosijs-3d/jpeg`): JPEGs read with no engine or canvas (baseline and progressive, grey or colour, any chroma subsampling), as `pngDecode`'s `RgbaImage`; `decodeImage` reads either. `pngDecode` now reads grey PNGs too.
21
+ - Character builder: **clips from a file…** takes BVH motion captures as well as GLBs, and keeps them in this browser (`clipStore`, IndexedDB `tosijs-clips`), so they come back next visit; **forget** drops one. `retargetSourceClip` plays a clip held as data (a BVH, or a GLB read with `readGlbClips`) on a loaded skeleton, as `retargetClip` does a loaded one.
22
+ - `readBvh` and `writeBvh` (`tosijs-3d/bvh`): BVH motion capture files read as clips (any skeleton, any Euler order, units guessed or given) that `bakeClip` and `retargetClip` play on any body, and any clip written out as BVH.
23
+ - A tailor's garment fits any body (`tailor-recipe`): a cut records the joints of the body it was drawn on (`TailorCut.on`), and `recutGarment(body, cut)` makes it on another rigged body, its outlines carried by the joints so a hem drawn at the knee stays at the knee. In the tailor, outlines now follow the body when it is reshaped. `fitCut`, `warpOutline`, `outlineLandmarks` and `tailorBody` are the parts.
24
+ - `heldParts(joints, held, bases)` (`tosijs-3d/rigged-body-glb`): a held item for any skeleton at rest, as `riggedBodyGlb` writes one: the socket joint under the hand (local transform and inverse bind), and the item's mesh skinned to it with its materials and pictures. For a GLB writer whose skeleton `riggedBodyGlb` did not make; `riggedBodyGlb` now uses the same code.
25
+ - `loftGarment` (`body-sweep`): a garment lofted along a chain of bones, as rings round the hull of the body's slice plus thickness and an `ease` curve, with mitred or rounded (`steps`) bends and open, sealed or capped ends. It returns a `GarmentCut` binding, so it fits and bends like a tailor's cut. The first piece of the sweep core; no tool uses it yet.
26
+
27
+ ### Changed
28
+
29
+ - Rigs bound from markers put the pelvis behind the thigh joints by 0.028 of the body's height and below them by 0.008, as UAL's mannequins have it, not above them at the middle of the hips' thickness (a seat, a belly or armour moved it). Every marker rig changes, saved ones too: look at yours in a crouch. `fitSkeleton`'s `pelvis: 'middle'` gives the old placement.
30
+ - Rigs bound from markers put the neck joint at the top of the shoulders, an eighth of the way down from the head joint to the pelvis as on UAL's mannequins; on a body with its arms down it sat in the upper chest (5 to 9 cm low on the AI cast), so the head turned from there.
31
+ - Tailor: a new garment, or one with nothing drawn yet, is cut from the body's own triangles (**cloth mesh: as the body**), not draped: the cheapest and surest way. Saved garments keep how they were made.
32
+ - `loadCharacterAssets` no longer fetches Quaternius' hair library (13.9 MB) at start: a character fetches it the first time it wears one of its pieces, and offers the pieces by name before then (`QUATERNIUS_HAIR`). `CharacterAssets.hair` is null until then; `assets.loadHair()` loads it, and `loadCharacterAssets(scene, { hair: 'now' })` keeps the old behaviour.
33
+ - Character builder: the panel runs from the most basic, least changeable choices to the most: tabs Body, Skin, Eyes, Face, Hair, Clothes, Hold, Motion, Export; in the Body tab, shape (gender, age, height) then ancestry then figure (weight, muscle and the rest); in Hair, brows and the style before beard, moustache and stubble. Control paths that moved: `Body/figure/weight`, `Body/figure/muscle`.
34
+
35
+ ### Fixed
36
+
37
+ - Retargeted clips keep the feet on the ground on bodies whose thigh and shin are proportioned differently from the clip's (the rig tool's AI characters crouched with one foot in the air): a foot near the ground goes where the source's went and the leg bends to reach it; a foot in the air keeps the copied angles. On by default in `retargeter`, `retargetClip` and `bakeClip`; `footIk: false` turns it off.
38
+ - Rig tool: a recipe handed over through `api.recipe` with new markers now binds the mesh again (it kept the old binding).
39
+ - The African American female's and Eurasian male's knee joints sit higher (2.5 and 4.4 cm), at the hollow behind the knee rather than below it.
40
+ - Tailor: switching to a slot that wears something the body shown cannot (MakeHuman's shoes while another body is on show) opened as "(new garment)" but said there was no outline; it now starts a new garment.
41
+ - Tailor: undo and redo work while an outline is being clicked out, a point at a time (they did nothing until it was closed). `outlineField3d` gains `undoPoint`/`redoPoint`. A panel's tooltips stay inside its padding, so the undo button's is no longer cut off at the edge.
42
+ - `riggedBodyGlb` wrote a garment's uvs upside down (ours run up the image, glTF's down), so a textured garment's picture landed flipped on it in other engines.
43
+ - The tailor could not cut a large garment ("Maximum call stack size exceeded"): a big cut's triangle list was spread into a call. The same pattern is gone from `remesh` and `loadRigTriangles`.
44
+ - A body opened from the builder's own export GLB (`riggedBodyGlb`) is its skin and eyes only: `glbRigTriangles`, `loadRigTriangles` and `loadSkinnedBody` leave out the garments and the held item it also carries, which were merged into the body.
45
+ - A menu opened from a scene panel (a select's list) closes on a press anywhere else: outside it, or on its panel anywhere but the control that opened it, which still toggles it. `showLayer` takes `dismissOutside`, and `showPopup` (every menu) asks for it.
46
+ - A popup dropped with its title band off screen comes back on release until the band is reachable (its top on screen, 48 px of it across), as a frame panel's screen drag already does. It may still be slid partly off to see past it.
@@ -4,6 +4,7 @@ import type { GarmentProxy } from './garment-proxy.js';
4
4
  import { type RigNaming, type RigRestPose } from './rigged-body-glb.js';
5
5
  import type { RiggedBody } from './rigged-body.js';
6
6
  import type { RigRecipe } from './rig-recipe.js';
7
+ import type { ClipOut } from './rigged-body-glb.js';
7
8
  /** What an export writes: the body, its recipe, and the model it came from. */
8
9
  export interface BodyExportTarget {
9
10
  body: RiggedBody;
@@ -30,6 +31,26 @@ export interface BodyExportTarget {
30
31
  gripNode?: string;
31
32
  extras?: Record<string, unknown>;
32
33
  } | null;
34
+ /** The clip playing, for **animation**: its file and its name there. */
35
+ clip?: ExportClip | null;
36
+ /** The eyes' picture (see riggedBodyGlb's `eyeTexture`). */
37
+ eyeTexture?: {
38
+ bytes: Uint8Array;
39
+ mimeType: string;
40
+ } | null;
41
+ }
42
+ /** A clip as its file: a GLB's animation by name, or a BVH capture. */
43
+ export interface ExportClip {
44
+ /** Its name in the file (a BVH holds one, whatever it is called). */
45
+ name: string;
46
+ kind: 'glb' | 'bvh';
47
+ /** The file's bytes, or where to fetch them. */
48
+ bytes?: Uint8Array;
49
+ url?: string;
50
+ /** Spread the arms (the body's recipe's `armSpaceDeg`). */
51
+ armSpaceDeg?: number;
52
+ /** The animation's `extras`: its licence. */
53
+ extras?: Record<string, unknown>;
33
54
  }
34
55
  /** How the file is written (the panel's choices). */
35
56
  export interface BodyExportSettings {
@@ -37,7 +58,11 @@ export interface BodyExportSettings {
37
58
  restPose: RigRestPose;
38
59
  /** Metres, or 0 for the body's own height. */
39
60
  height: number;
61
+ /** Whether the clip playing goes in (default not). */
62
+ animation?: 'none' | 'playing';
40
63
  }
64
+ /** A clip from its file, as riggedBodyGlb's `clips` takes it (null: not in the file). */
65
+ export declare function exportClip(c: ExportClip): Promise<ClipOut | null>;
41
66
  /**
42
67
  * The body as GLB bytes, with the model's own materials where its file is a
43
68
  * GLB of the same mesh. `note` says what was left out.
@@ -1 +1 @@
1
- {"version":3,"file":"body-export.d.ts","sourceRoot":"","sources":["../src/body-export.ts"],"names":[],"mappings":"AAsBA,OAAO,EAA+B,KAAK,QAAQ,EAAE,MAAM,gBAAgB,CAAA;AAE3E,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,kBAAkB,CAAA;AAC5C,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAA;AACtD,OAAO,EAGL,KAAK,SAAS,EACd,KAAK,WAAW,EACjB,MAAM,sBAAsB,CAAA;AAC7B,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,kBAAkB,CAAA;AAClD,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAA;AAEhD,+EAA+E;AAC/E,MAAM,WAAW,gBAAgB;IAC/B,IAAI,EAAE,UAAU,CAAA;IAChB,MAAM,CAAC,EAAE,SAAS,GAAG,IAAI,CAAA;IACzB,+EAA+E;IAC/E,MAAM,CAAC,EAAE;QAAE,GAAG,CAAC,EAAE,MAAM,CAAC;QAAC,IAAI,CAAC,EAAE,IAA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a button that writes the body shown with
7
7
  [rigged-body-glb](/rigged-body-glb/) (its springs too, from the rig recipe)
8
8
  and downloads it. The file plays UAL's clips by name in three.js, Unity,
9
- Godot and Blender; a tail or a strand swings in any VRM loader.
9
+ Godot and Blender; a tail or a strand swings in any VRM loader. With
10
+ **animation** set to the clip playing, that clip goes in too, retargeted onto
11
+ the skeleton as written (from UAL's file, a GLB's animations or a BVH
12
+ capture: `clip` on the target says which).
10
13
 
11
14
  The body on screen was read through Babylon, so its materials are Babylon's.
12
15
  For the file, the model it came from is read again from its bytes
@@ -22,6 +25,8 @@ panel.push(...exportBodyRows(() => ({ body, recipe, source: { url } }), say))
22
25
  import { button3d, label3d, select3d } from './widgets3d.js';
23
26
  import { glbNodePosition, glbRigTriangles } from './glb-rig.js';
24
27
  import { riggedBodyGlb, } from './rigged-body-glb.js';
28
+ import { readGlbClips } from './glb-clips.js';
29
+ import { readBvh } from './bvh.js';
25
30
  const HEIGHTS = [
26
31
  'as made',
27
32
  '1.5 m',
@@ -41,6 +46,38 @@ async function sourceBytes(source) {
41
46
  : null;
42
47
  return buffer != null ? new Uint8Array(buffer) : null;
43
48
  }
49
+ // A clip library (UAL's is megabytes) is read once a page.
50
+ const clipSources = new Map();
51
+ /** A clip from its file, as riggedBodyGlb's `clips` takes it (null: not in the file). */
52
+ export async function exportClip(c) {
53
+ const read = async () => {
54
+ const bytes = c.bytes ?? new Uint8Array(await (await fetch(c.url)).arrayBuffer());
55
+ return c.kind === 'bvh'
56
+ ? readBvh(new TextDecoder().decode(bytes), { name: c.name })
57
+ : readGlbClips(bytes);
58
+ };
59
+ let from;
60
+ if (c.url != null && c.bytes == null) {
61
+ if (!clipSources.has(c.url))
62
+ clipSources.set(c.url, read());
63
+ from = await clipSources.get(c.url).catch((e) => {
64
+ clipSources.delete(c.url);
65
+ throw e;
66
+ });
67
+ }
68
+ else
69
+ from = await read();
70
+ const clip = c.kind === 'bvh' ? from.clips[0] : from.clips.find((k) => k.name === c.name);
71
+ if (clip == null)
72
+ return null;
73
+ return {
74
+ from,
75
+ clip,
76
+ name: c.name,
77
+ ...(c.armSpaceDeg ? { armSpaceDeg: c.armSpaceDeg } : {}),
78
+ ...(c.extras ? { extras: c.extras } : {}),
79
+ };
80
+ }
44
81
  /**
45
82
  * The body as GLB bytes, with the model's own materials where its file is a
46
83
  * GLB of the same mesh. `note` says what was left out.
@@ -66,7 +103,9 @@ export async function exportBody(target, settings) {
66
103
  body = { ...body, surfaces: tris.surfaces };
67
104
  else if (tris != null)
68
105
  note = 'its materials did not match the mesh: plain grey';
69
- else if (target.body.surfaces?.length)
106
+ else if (target.body.surfaces?.length &&
107
+ !target.body.surfaces.some((s) => Array.isArray(s.material?.baseColorFactor)))
108
+ // A body that brings its own glTF materials (MakeHuman's skin) keeps them.
70
109
  note = 'not from a GLB: plain grey';
71
110
  const held = target.held
72
111
  ? await heldItem(target.held).catch(() => {
@@ -79,8 +118,15 @@ export async function exportBody(target, settings) {
79
118
  return { grip: target.held.grip };
80
119
  })
81
120
  : undefined;
121
+ const clip = settings.animation === 'playing' && target.clip
122
+ ? await exportClip(target.clip).catch(() => null)
123
+ : null;
124
+ if (settings.animation === 'playing' && clip == null)
125
+ note = [note, 'no clip to put in'].filter(Boolean).join('; ');
82
126
  const out = riggedBodyGlb(body, {
83
127
  ...(held ? { held } : {}),
128
+ ...(clip ? { clips: [clip] } : {}),
129
+ ...(target.eyeTexture ? { eyeTexture: target.eyeTexture } : {}),
84
130
  ...(target.garments?.length ? { garments: target.garments } : {}),
85
131
  naming: settings.naming,
86
132
  restPose: settings.restPose,
@@ -114,6 +160,7 @@ const settings = {
114
160
  naming: 'ue',
115
161
  restPose: 't-pose',
116
162
  height: 0,
163
+ animation: 'none',
117
164
  };
118
165
  /**
119
166
  * An Export section: names, rest pose, height and the button. `target`
@@ -147,6 +194,14 @@ export function exportBodyRows(target, say) {
147
194
  settings.height = v === 'as made' ? 0 : parseFloat(String(v));
148
195
  },
149
196
  }),
197
+ select3d({
198
+ label: 'animation',
199
+ value: settings.animation === 'playing' ? 'the clip playing' : 'none',
200
+ options: ['none', 'the clip playing'],
201
+ handleChange: (v) => {
202
+ settings.animation = v === 'none' ? 'none' : 'playing';
203
+ },
204
+ }),
150
205
  button3d({
151
206
  label: 'export GLB',
152
207
  handleClick: () => {
@@ -1 +1 @@
1
- {"version":3,"file":"body-export.js","sourceRoot":"","sources":["../src/body-export.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;EAmBE;AACF,+CAA+C;AAE/C,OAAO,EAAE,QAAQ,EAAE,OAAO,EAAE,QAAQ,EAAiB,MAAM,gBAAgB,CAAA;AAC3E,OAAO,EAAE,eAAe,EAAE,eAAe,EAAE,MAAM,cAAc,CAAA;AAG/D,OAAO,EACL,aAAa,GAId,MAAM,sBAAsB,CAAA;AAoC7B,MAAM,OAAO,GAAG;IACd,SAAS;IACT,OAAO;IACP,OAAO;IACP,OAAO;IACP,OAAO;IACP,OAAO;IACP,OAAO;CACR,CAAA;AAED,KAAK,UAAU,WAAW,CACxB,MAAkC;IAElC,IAAI,MAAM,IAAI,IAAI;QAAE,OAAO,IAAI,CAAA;IAC/B,MAAM,MAAM,GACV,MAAM,CAAC,IAAI,IAAI,IAAI;QACjB,CAAC,CAAC,MAAM,MAAM,CAAC,IAAI,CAAC,WAAW,EAAE;QACjC,CAAC,CAAC,MAAM,CAAC,GAAG;YACZ,CAAC,CAAC,MAAM,CAAC,MAAM,KAAK,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC,CAAC,WAAW,EAAE;YAC/C,CAAC,CAAC,IAAI,CAAA;IACV,OAAO,MAAM,IAAI,IAAI,CAAC,CAAC,CAAC,IAAI,UAAU,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,IAAI,CAAA;AACvD,CAAC;AAED;;;GAGG;AACH,MAAM,CAAC,KAAK,UAAU,UAAU,CAC9B,MAAwB,EACxB,QAA4B;IAE5B,IAAI,IAAI,GAAG,MAAM,CAAC,IAAI,CAAA;I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AAS,CAAC,KAAK,CAAC,UAAU,GAAG,GAAG,CAAC,CAAC,OAAO,CACzD,CAAC,CACF,OAAO,IAAI,CAAC,CAAC,CAAC,KAAK,IAAI,EAAE,CAAC,CAAC,CAAC,EAAE,EAAE,CAClC,CAAA;oBACH,CAAC;oBAAC,OAAO,CAAC,EAAE,CAAC;wBACX,GAAG,CAAC,qBAAsB,CAAW,CAAC,OAAO,EAAE,CAAC,CAAA;oBAClD,CAAC;gBACH,CAAC,CAAC,EAAE,CAAA;YACN,CAAC;SACF,CAAC;KACH,CAAA;AACH,CAAC"}
@@ -0,0 +1,47 @@
1
+ import type { GarmentCut } from './garment-cut.js';
2
+ import type { RiggedBody } from './rigged-body.js';
3
+ /** A value along the sweep: a constant, or a function of 0..1 (start to end). */
4
+ export type SweepCurve = number | ((s: number) => number);
5
+ /** What an end of a sweep is. */
6
+ export type SweepEnd = 'open' | 'sealed' | 'cap';
7
+ export interface LoftOptions {
8
+ /**
9
+ * Joints, root to tip, that the path runs through (`thigh_l`, `calf_l`,
10
+ * `foot_l`, `ball_l`). Each but the last names the bone whose skin the
11
+ * stretch after it slices.
12
+ */
13
+ chain: string[];
14
+ /** Where the sweep starts and ends, as fractions of the chain's length. */
15
+ from?: number;
16
+ to?: number;
17
+ /** How far it carries on past `to` along the last bone, metres. Default 0. */
18
+ length?: number;
19
+ /** Standing off the hull everywhere, metres. Default 4 mm. */
20
+ thickness?: number;
21
+ /** More standing off, metres, along the sweep (0 at the start, 1 at the end). */
22
+ ease?: SweepCurve;
23
+ /** Distance between rings, metres. Default 2 cm. */
24
+ step?: number;
25
+ /** Points round each ring. Default 32. */
26
+ segments?: number;
27
+ /** Rings rounding each bend; 0 (the default) is a clean mitre. */
28
+ steps?: number;
29
+ /** The start and end: open, sealed or capped. Default open at both. */
30
+ ends?: [SweepEnd, SweepEnd];
31
+ /** Over how much of the sweep a sealed end fades the ease out, metres. Default 3 cm. */
32
+ seal?: number;
33
+ /** Which body vertices belong to the piece (non-zero). Default all. */
34
+ piece?: ArrayLike<number>;
35
+ /** UV scale: texture repeats per metre. Default 1. */
36
+ uvScale?: number;
37
+ }
38
+ /** A loft: a garment binding, and its rings (row indices, in order round). */
39
+ export interface Loft extends GarmentCut {
40
+ rings: number[][];
41
+ }
42
+ /**
43
+ * A loft along a chain of bones: rings round the hull of the body's slice,
44
+ * plus thickness and ease, as a garment binding.
45
+ */
46
+ export declare function loftGarment(body: RiggedBody, options: LoftOptions): Loft;
47
+ //# sourceMappingURL=body-sweep.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"body-sweep.d.ts","sourceRoot":"","sources":["../src/body-sweep.ts"],"names":[],"mappings":"AAsCA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,kBAAkB,CAAA;AAClD,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,kBAAkB,CAAA;AAKlD,iFAAiF;AACjF,MAAM,MAAM,UAAU,GAAG,MAAM,GAAG,CAAC,CAAC,CAAC,EAAE,MAAM,KAAK,MAAM,CAAC,CAAA;AAEzD,iCAAiC;AACjC,MAAM,MAAM,QAAQ,GAAG,MAAM,GAAG,QAAQ,GAAG,KAAK,CAAA;AAEhD,MAAM,WAAW,WAAW;IAC1B;;;;OAIG;IACH,KAAK,EAAE,MAAM,EAAE,CAAA;IACf,2EAA2E;IAC3E,IAAI,CAAC,EAAE,MAAM,CAAA;IACb,EAAE,CAAC,EAAE,MAAM,CAAA;IACX,8EAA8E;IAC9E,MAAM,CAAC,EAAE,MAAM,CAAA;IACf,8DAA8D;IAC9D,SAAS,CAAC,EAAE,MAAM,CAAA;IAClB,iFAAiF;IACjF,IAAI,CAAC,EAAE,UAAU,CAAA;IACjB,oDAAoD;IACpD,IAAI,CAAC,EAAE,MAAM,CAAA;IACb,0CAA0C;IAC1C,QAAQ,CAAC,EAAE,MAAM,CAAA;IACjB,kEAAkE;IAClE,KAAK,CAAC,EAAE,MAAM,CAAA;IACd,uEAAuE;IACvE,IAAI,CAAC,EAAE,CA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