pixelkiln 0.134.0 → 0.136.0

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.
@@ -315,6 +315,22 @@ The example file was imported into Godot 4.7.2 with no errors: one skeleton of
315
315
  `hiddenBy` list in its node metadata. Godot drops a trailing `_Loop` from
316
316
  animation names, so the library's `Walk_Loop` arrives as `Walk`.
317
317
 
318
+ The motions are made in place. For an engine that moves a character by its
319
+ animation, run this last:
320
+
321
+ ```
322
+ python3 research/scripts/rootmotion.py <animated.glb> <with-root-motion.glb>
323
+ ```
324
+
325
+ It adds a `Root` bone under the hips and keys it forward in every walk, run and
326
+ advance, at the pace the planted foot goes back. In Godot, set the animation
327
+ player's `root_motion_track` to that bone. The report gives each motion's
328
+ speed and how far a foot still slides at it; the walk and the advance are
329
+ good, the jog and sprint rough. `Great_Attack_Fwd` and `Spear_Thrust_Fwd` are
330
+ the cut and the thrust ending where the step landed; they only make sense
331
+ with root motion, and `SKIP=_Fwd` on `wield.py` leaves them out. Keep the file without it for anything that
332
+ plays animations plainly, where the character would walk off and jump back.
333
+
318
334
  Not tried: Unity and Unreal, Godot's retargeting onto its own humanoid rest
319
335
  pose, and how the model looks drawn in any engine but three.js.
320
336
 
@@ -64,6 +64,8 @@ Last updated 17 November 2026.
64
64
  | 54 | The spear's rear elbow | Our scripts | The rear arm's elbow moved from back and up to out at the side, found by trying 37 places for it on both bodies | Keep. The second body's rear wrist went from 82 to 86 degrees down to 8 to 19, the first body's from 47 to 72 down to 15 to 20. |
65
65
  | 55 | A side-on spear stance | Our scripts | The spear motions rewritten with the hips turned (45 degrees standing, 28 walking, 14 jogging), the feet split and the head looking along the shaft | Keep. Both bodies hold it with wrists under 36 degrees and both feet on the ground. The walk's legs still walk straight under turned hips. |
66
66
  | 56 | A spear advance | Our scripts | A forward step written as footwork: the leading foot steps, the other follows, neither passes the other, the hips stay turned 45 degrees | Keep. Both bodies advance in the stance with the stance's wrists and both feet reaching. Made in place; not seen in a game. |
67
+ | 57 | Root motion | Our scripts | A `Root` bone under the hips, keyed forward at the pace the planted foot goes back, for every walk, run and the advance | Keep for walks and the advance: Godot moves the character by the measured distance to the millimetre. The jog's and sprint's speeds are rough. |
68
+ | 58 | An attack and a thrust that carry forward | Our scripts | `Great_Attack_Fwd` and `Spear_Thrust_Fwd`: the stepping foot stays where it lands and the other follows, with the travel written as root motion | Keep. The measured travel is within 5 mm of what was written and a planted foot moves 8 mm at most. |
67
69
 
68
70
  **How the percentages are measured.** The model is projected back to each of the eight camera positions and its outline is compared with the sprite's outline. The score is the area the two share divided by the area either covers, averaged over the views. 100% means the model casts exactly the sprite's shadow from every side. It measures shape only, not colour. It also favours carving, which is built from those same outlines.
69
71
 
@@ -1576,6 +1578,67 @@ Not checked: the rebuilt model's picture in the site viewer, any moment but the
1576
1578
 
1577
1579
  **Verdict.** Keep. A character in the stance can now close distance without turning out of it.
1578
1580
 
1581
+ ## 57. Root motion
1582
+
1583
+ **Question.** Every walk and run in the file is made in place, and step 56's advance only reports how far the ground goes by. Can the file itself say how far each travelling motion carries the character, so a game does not guess a speed?
1584
+
1585
+ **Setup.** A new script, [`scripts/rootmotion.py`](../research/scripts/rootmotion.py), run last.
1586
+
1587
+ - *A bone to carry it.* The skeleton's top bone was the hips. The script adds a bone named `Root` on the ground as their parent, joined to the skin last so no mesh's joint numbers change. Godot's humanoid profile expects that bone under that name.
1588
+ - *The pace, from the feet.* For each travelling motion the ankles and the balls of both feet are followed. Whichever is lowest, while within 2 cm of as low as it gets, is on the ground, and how fast it goes back under the body is how fast the ground goes by. A foot just landing is slower than the ground, so the pace kept is the middle one of the faster half of those moments.
1589
+ - *The track.* `Root` is keyed forward at that pace for the motion's length. The motion's own bones are untouched. `PLANT=1` moves `Root` at the planted foot's own pace moment by moment instead, which takes the slide away and makes the pace uneven.
1590
+ - *A fault from step 56, found here.* The advance stepped along the way the idle's hips point, which is 13 degrees off the way the character faces, so it measured 0.98 m forward and 0.23 m sideways a loop. It now steps the way the character faces. The standing stance still sets its feet along the idle's hips, so the feet shift a little between standing and advancing, and on the first body the advance's rear foot is 1 mm short of its mark at its furthest.
1591
+
1592
+ **Result.** Steady pace, both bodies:
1593
+
1594
+ | Motion | First body, m/s | Foot slide, cm | Second body, m/s | Foot slide, cm |
1595
+ |---|---|---|---|---|
1596
+ | `Walk_Loop`, `Spear_Walk` | 1.02 | 5.4 | 0.90 | 5.7 |
1597
+ | `Jog_Fwd_Loop`, `Spear_Jog` | 5.95 | 8.4 | 5.15 | 7.2 |
1598
+ | `Sprint_Loop` | 8.96 | 59 | 8.08 | 54 |
1599
+ | `Spear_Advance` | 0.41 | 0.6 | 0.35 | 0.5 |
1600
+
1601
+ - **Godot moves the character by what was written.** With `root_motion_track` set to the `Root` bone, two loops of each motion, stepped at 60 a second, moved it twice the measured distance to the millimetre on both bodies (the walk 2.728 m and 2.410 m, the advance 2.034 m and 1.730 m), with no sideways or upward movement, and the `Root` bone itself stayed at the origin. The other motions moved it nowhere.
1602
+ - **The advance measures as it was written:** 1.017 m a loop against the 1.006 m its footwork was made for, and no sideways drift.
1603
+ - **The jog is fast.** Its planted foot sweeps 0.9 m in a sixth of a second, between long flights, so feet that do not slide mean nearly 6 m/s. A game that wants a slower jog must slow the motion or accept the slide.
1604
+ - **The sprint's figure is weak.** Only three moments of each step have a foot truly down, and the foot hangs at ground height for two moments before it. Those count as slide, which is why its slide reads 59 cm. Treat its speed as rough.
1605
+ - **Both files validate with no errors or warnings,** Godot finds all 17 required bones and no bone under the wrong parent, and the skeleton has one more bone.
1606
+ - **Not done:** the attack and the thrust still return to where they started; carrying them forward needs the rear foot to follow, which is footwork not yet written. Turning motions and the roll are not measured. Nothing was watched in a running game: Godot's numbers were read headless. The site's viewer does not read root motion, so its model is built without it.
1607
+
1608
+ **Verdict.** Keep, for walks and the advance. Use the jog's and sprint's figures as a starting speed, not a fact.
1609
+
1610
+ ## 58. An attack and a thrust that carry forward
1611
+
1612
+ **Question.** The two-handed cut and the spear thrust step out and come back to where they started. Can each end where its step landed, with the travel written as root motion?
1613
+
1614
+ **What was tried.** Two new motions beside the old ones, and one more number in a row of footwork.
1615
+
1616
+ - *Travel.* A row of `feet` in `wield.py` gains a ninth number: how far the character has gone forward. With it, the row's hips and feet are places over the ground, and the script takes the travel off each to get the animation, which is still held from where the character is.
1617
+ - *`Spear_Thrust_Fwd`.* The thrust as before until it lands. Then the leading foot stays where it is and the rear foot lifts and follows into the stance again, 0.38 leg lengths on.
1618
+ - *`Great_Attack_Fwd`.* The cut as before until it lands. Then the other foot comes up beside the one that stepped, 0.45 leg lengths on.
1619
+ - *Feet that hold.* The curve through a motion's footwork now rests at a moment where a value stops or turns back, so a foot written at the same place twice running stays there and does not swing past. The older motions' reports are the same to the degree and the millimetre.
1620
+ - *One front for the spear.* Step 57 found the advance stepping 13 degrees off the way the character faces. All the spear motions now set their feet the way he faces, so the stance, the advance and both thrusts agree.
1621
+ - *Root motion for a motion that plays once.* `rootmotion.py` takes these (names ending `_Fwd`) differently from a loop: `Root` follows the planted foot moment by moment and stays put when no foot is down, and the travel is the sum.
1622
+ - *Leaving them out.* Played plainly, a carried motion slides back at its end. `SKIP=_Fwd` makes a file without them; the site's models are built that way.
1623
+
1624
+ **Result.**
1625
+
1626
+ ![The carried thrust on both bodies and the carried cut, at the start, the landing, the other foot following, and the end, with the travel applied](../website/public/research/3d/carried-attacks.png)
1627
+
1628
+ | | Written, m | Measured from the feet, m | A planted foot moves at most |
1629
+ |---|---|---|---|
1630
+ | `Spear_Thrust_Fwd`, first body | 0.333 | 0.328 | 7 mm |
1631
+ | `Spear_Thrust_Fwd`, second body | 0.280 | 0.281 | 6 mm |
1632
+ | `Great_Attack_Fwd`, first body | 0.388 | 0.386 | 8 mm |
1633
+
1634
+ - **Each foot stays where it is while it is down.** With the travel applied, each ankle was followed over the ground through every stretch it spent down: none moved more than 8 mm forward or back, or 6 mm sideways.
1635
+ - **The arms are the old motions' arms:** wrist bend at most 26 and 29 degrees for the carried thrust on the first body, 34 and 29 on the second, 42 and 35 for the carried cut. Both feet reach and nothing is pulled in.
1636
+ - **All files validate with no errors or warnings,** with and without root motion.
1637
+ - **Godot moves the character by the measured travel.** Read headless with `root_motion_track` on the `Root` bone, two plays of the carried thrust moved it 0.655 m on the first body and 0.563 m on the second, and two of the carried cut 0.772 m, each twice the measured figure to within a millimetre and straight ahead. All 17 required bones are found on each file, none under the wrong parent.
1638
+ - **Not done:** the greatsword exists on the first body only, so the carried cut was made once. The rear foot comes forward flat, with no roll. The travel is fixed by the motion; a game cannot shorten it. Nothing was watched in a running game.
1639
+
1640
+ **Verdict.** Keep. An attack can now move the character, and the file says by how much.
1641
+
1579
1642
  ## What has not worked, in one place
1580
1643
 
1581
1644
  So nobody repeats them:
@@ -1610,7 +1673,7 @@ Two bugs worth remembering, because both produced plausible wrong pictures: glTF
1610
1673
  - **Sixteen directions and lighting for the sprite cards** (step 31): the in-between views of step 13, and normals from the hidden mesh.
1611
1674
  - **More directions, and animation.** Step 13 gives sixteen directions. Thirty-two would spin smoothly, and the same trick on a walk cycle would give walks in the in-between directions, which the generator does not offer.
1612
1675
  - **Fix the squat proportions.** Carve at a finer grid, or let the redraw see a true neighbour at full height (the guide sheet does this and kept proportions better on the bare character).
1613
- - **Held items.** Steps 47 to 51 put a sword in either hand, open or drawn as a fist, a shield on a forearm, and a greatsword in both hands with four motions of its own. Step 52 gave the attack a step and step 53 added a spear with the hands apart, step 54 moved its rear elbow so both bodies hold it with easy wrists, step 55 turned the spear motions side-on, and step 56 added an advance that keeps the stance. Still to do: a handle sized to the hand, root motion, and motions made for a shield or a left-handed sword.
1676
+ - **Held items.** Steps 47 to 51 put a sword in either hand, open or drawn as a fist, a shield on a forearm, and a greatsword in both hands with four motions of its own. Step 52 gave the attack a step and step 53 added a spear with the hands apart, step 54 moved its rear elbow so both bodies hold it with easy wrists, step 55 turned the spear motions side-on, step 56 added an advance that keeps the stance, step 57 wrote root motion for the walks, runs and the advance, and step 58 added a cut and a thrust that carry the character forward. Still to do: a handle sized to the hand, and motions made for a shield or a left-handed sword.
1614
1677
  - **A score that sees cleanliness.** Colour error against one drawing cannot tell a clean redraw from a torn render.
1615
1678
  - **Fewer, larger pieces in the unwrap.** The chest unwraps into a few large pieces, but the character comes out in hundreds of small ones, which is fine for a program and poor for a person or an image model to paint on. One piece per view, like a folded paper model, would make the texture a sprite sheet.
1616
1679
  - **Carve at a finer grid** than one voxel per pixel, so thin objects survive.
@@ -1779,6 +1842,9 @@ python3 research/scripts/retarget.py <character.glb> <library.glb> <out.glb>
1779
1842
  CHAINS="Cape=3x4" ITEMS="Cape=<cape.glb>:Hips,Spine,Chest:loose" python3 research/scripts/rig.py <body.glb> <body.rig.json> - - <character.glb>
1780
1843
  python3 research/scripts/sway.py <animated.glb> <out.glb>
1781
1844
 
1845
+ # Write root motion for the walks, runs and the spear advance (step 57). Run it last.
1846
+ python3 research/scripts/rootmotion.py <animated.glb> <with-root-motion.glb>
1847
+
1782
1848
  # Reshape an item made on one body for another (step 46). The skin files come from rig.py with SKIN=<file>.
1783
1849
  ONLY=Head python3 research/scripts/refit.py <helm.glb> <first.skin.npz> <second.skin.npz> <helm-for-second.glb>
1784
1850
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "pixelkiln",
3
- "version": "0.134.0",
3
+ "version": "0.136.0",
4
4
  "description": "Manifest-driven pixel-art generation, review, recovery, and packaging with deterministic provenance.",
5
5
  "type": "module",
6
6
  "sideEffects": false,