@usemosio/cli-linux-x64 1.0.0-next.1 → 1.0.0-next.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/THIRD_PARTY_NOTICES.md +22 -0
- package/apps/studio/dist/assets/Workspace-Dr-hVeFd.js +34 -0
- package/apps/studio/dist/assets/{agent-panel-CqJuv5Sn.js → agent-panel-DMrVed-J.js} +5 -5
- package/apps/studio/dist/assets/{boundary-bK2S8z05.js → boundary-DL9veUlN.js} +1 -1
- package/apps/studio/dist/assets/{feedback-BqzXUdVd.js → feedback-x6ZumR_x.js} +1 -1
- package/apps/studio/dist/assets/index-C6juWzGV.js +1984 -0
- package/apps/studio/dist/assets/index-CjDBKmB_.css +2 -0
- package/apps/studio/dist/assets/inspector3d-sqergHSP.js +1 -0
- package/apps/studio/dist/index.html +4 -3
- package/apps/studio/dist-host/studio-host.mjs +262 -3
- package/bin/mosio +0 -0
- package/bin/mosio-agent +0 -0
- package/crates/mosio/src/adapters/mosio-three.js +112 -8
- package/crates/mosio/src/adapters/room-env-pmrem.json +1 -0
- package/crates/mosio/src/runtime.js +205 -6
- package/fixtures/camera-inspect/mosio.json +56 -0
- package/fixtures/camera-inspect/scenes/behind.html +22 -0
- package/fixtures/camera-inspect/scenes/cut.html +18 -0
- package/fixtures/camera-inspect/scenes/edges.html +18 -0
- package/fixtures/camera-inspect/scenes/good.html +23 -0
- package/fixtures/camera-inspect/scenes/read.html +22 -0
- package/fixtures/camera-inspect/scenes/shake.html +23 -0
- package/fixtures/camera-inspect/scenes/speed.html +18 -0
- package/fixtures/camera-inspect-vertical/mosio.json +31 -0
- package/fixtures/camera-inspect-vertical/scenes/good.html +20 -0
- package/fixtures/camera-inspect-vertical/scenes/safe.html +18 -0
- package/fixtures/cloudrun-gpu/audio/music.wav +0 -0
- package/fixtures/cloudrun-gpu/audio/vo.wav +0 -0
- package/fixtures/cloudrun-gpu/mosio.json +18 -0
- package/fixtures/cloudrun-gpu/scenes/cube.html +25 -0
- package/fixtures/direct-seek/mosio.json +4 -0
- package/fixtures/direct-seek/scenes/clock.html +9 -0
- package/fixtures/direct-seek/scenes/meta.html +11 -0
- package/fixtures/direct-seek/scenes/pure.html +11 -0
- package/fixtures/direct-seek/scenes/slow.html +11 -0
- package/fixtures/direct-seek-media/mosio.json +6 -0
- package/fixtures/direct-seek-media/scenes/pure.html +11 -0
- package/fixtures/gl-readback/mosio.json +16 -0
- package/fixtures/gl-readback/scenes/compositor.html +23 -0
- package/fixtures/gl-readback/scenes/readback.html +23 -0
- package/fixtures/inspect-physics/expect.json +18 -0
- package/fixtures/inspect-physics/mosio.json +29 -0
- package/fixtures/inspect-physics/scenes/calm.html +46 -0
- package/fixtures/inspect-physics/scenes/physics.html +47 -0
- package/package.json +1 -1
- package/primitives/README.md +23 -2
- package/primitives/example/shared/mosio-prims.js +349 -1
- package/primitives/impact-burst/golden/f030.png +0 -0
- package/primitives/impact-burst/golden/f032.png +0 -0
- package/primitives/impact-burst/golden/f036.png +0 -0
- package/primitives/impact-burst/impact-burst.js +51 -0
- package/primitives/impact-burst/primitive.json +130 -0
- package/primitives/impact-burst/scene.html +24 -0
- package/primitives/stick-figure/golden/f030.png +0 -0
- package/primitives/stick-figure/golden/f092.png +0 -0
- package/primitives/stick-figure/golden/f140.png +0 -0
- package/primitives/stick-figure/primitive.json +179 -0
- package/primitives/stick-figure/scene.html +40 -0
- package/primitives/stick-figure/stick-figure.js +297 -0
- package/primitives/zoom-through/primitive.json +7 -2
- package/primitives/zoom-through/zoom-through.js +6 -5
- package/scripts/3d-acceptance.sh +8 -1
- package/scripts/3d-attach-bench.mjs +119 -0
- package/scripts/3d-bake-room-env.mjs +74 -0
- package/scripts/3d-e2b-job.sh +1 -0
- package/scripts/3d-gen-heavy-fixture.py +65 -0
- package/scripts/3d-trace-summary.py +14 -0
- package/scripts/acceptance/camera-inspect.sh +49 -0
- package/scripts/acceptance/direct-seek.sh +68 -0
- package/scripts/acceptance/export.sh +5 -3
- package/scripts/acceptance/frames.sh +7 -2
- package/scripts/acceptance/hardening.sh +37 -6
- package/scripts/acceptance/hub.sh +208 -0
- package/scripts/acceptance/inspect.sh +21 -2
- package/scripts/acceptance/revisions-git.sh +137 -0
- package/scripts/acceptance/revisions-sync.sh +323 -0
- package/scripts/acceptance/revisions.sh +118 -4
- package/scripts/acceptance/segcache.sh +100 -0
- package/scripts/acceptance/split.sh +78 -0
- package/scripts/bootstrap.sh +20 -1
- package/scripts/check-error-codes.py +9 -1
- package/scripts/check-file-size.sh +45 -0
- package/scripts/ci.sh +4 -4
- package/scripts/dedupe-report.sh +47 -0
- package/scripts/e2b/template/provision.sh +1 -1
- package/scripts/fastpath/cdp.mjs +25 -0
- package/scripts/fastpath/dbg.mjs +11 -0
- package/scripts/fastpath/e2b.mjs +40 -0
- package/scripts/fastpath/features/gen.py +109 -0
- package/scripts/fastpath/features/mosio.json +100 -0
- package/scripts/fastpath/features/scenes/backdrop.html +11 -0
- package/scripts/fastpath/features/scenes/blend.html +11 -0
- package/scripts/fastpath/features/scenes/canvas2d.html +11 -0
- package/scripts/fastpath/features/scenes/filter.html +11 -0
- package/scripts/fastpath/features/scenes/gradient.html +11 -0
- package/scripts/fastpath/features/scenes/iframe.html +11 -0
- package/scripts/fastpath/features/scenes/image.html +11 -0
- package/scripts/fastpath/features/scenes/svg.html +11 -0
- package/scripts/fastpath/features/scenes/text.html +11 -0
- package/scripts/fastpath/features/scenes/typo.html +11 -0
- package/scripts/fastpath/features/scenes/video.html +11 -0
- package/scripts/fastpath/features/scenes/video2.html +11 -0
- package/scripts/fastpath/features-xfade/mosio.json +49 -0
- package/scripts/fastpath/features-xfade/scenes/image.html +11 -0
- package/scripts/fastpath/features-xfade/scenes/video.html +11 -0
- package/scripts/fastpath/fixtures/gen_layout.py +80 -0
- package/scripts/fastpath/fixtures/l12-no-reset/assets/img/photo-1015.jpg +0 -0
- package/scripts/fastpath/fixtures/l12-no-reset/mosio.json +34 -0
- package/scripts/fastpath/fixtures/l12-no-reset/scenes/main.html +20 -0
- package/scripts/fastpath/fp.mjs +91 -0
- package/scripts/fastpath/inpage.js +68 -0
- package/scripts/fastpath/recipes.py +49 -0
- package/scripts/fastpath/sandbox.sh +68 -0
- package/scripts/fastpath/sandbox10.sh +57 -0
- package/scripts/fastpath/sandbox11.sh +18 -0
- package/scripts/fastpath/sandbox12.sh +30 -0
- package/scripts/fastpath/sandbox13.sh +16 -0
- package/scripts/fastpath/sandbox14.sh +28 -0
- package/scripts/fastpath/sandbox15.sh +36 -0
- package/scripts/fastpath/sandbox16.sh +60 -0
- package/scripts/fastpath/sandbox17.sh +34 -0
- package/scripts/fastpath/sandbox18.sh +59 -0
- package/scripts/fastpath/sandbox19.sh +67 -0
- package/scripts/fastpath/sandbox2.sh +41 -0
- package/scripts/fastpath/sandbox20.sh +34 -0
- package/scripts/fastpath/sandbox21.sh +22 -0
- package/scripts/fastpath/sandbox22.sh +22 -0
- package/scripts/fastpath/sandbox23.sh +21 -0
- package/scripts/fastpath/sandbox3.sh +151 -0
- package/scripts/fastpath/sandbox4.sh +161 -0
- package/scripts/fastpath/sandbox5.sh +69 -0
- package/scripts/fastpath/sandbox6.sh +85 -0
- package/scripts/fastpath/sandbox7.sh +81 -0
- package/scripts/fastpath/sandbox8.sh +62 -0
- package/scripts/fastpath/sandbox9.sh +130 -0
- package/scripts/fastpath/srv.mjs +15 -0
- package/scripts/fastpath/www/probe.html +1 -0
- package/scripts/gen-media-fixtures.sh +1 -0
- package/scripts/gl-readback-check.sh +26 -0
- package/scripts/hpbench/make-bench-fixtures.sh +43 -0
- package/scripts/hpbench/render-cgroup.sh +56 -0
- package/scripts/install.sh +2 -1
- package/scripts/npm-clean-install-proof-win.sh +64 -0
- package/scripts/platform-smoke.sh +80 -0
- package/scripts/prim.mjs +31 -13
- package/scripts/user-journey.sh +68 -0
- package/skills/mosio-3d/SKILL.md +31 -3
- package/skills/mosio-brief/SKILL.md +80 -0
- package/skills/mosio-brief/references/brief.md +141 -0
- package/skills/mosio-brief/references/copy.md +99 -0
- package/skills/mosio-brief/references/narration.md +61 -0
- package/skills/mosio-brief/references/storyboard.md +98 -0
- package/skills/mosio-collab/SKILL.md +104 -0
- package/skills/mosio-collab/references/hub.md +62 -0
- package/skills/mosio-engine/SKILL.md +44 -13
- package/skills/mosio-engine/references/camera.md +12 -2
- package/skills/mosio-engine/references/character.md +88 -0
- package/skills/mosio-engine/references/checks.md +11 -4
- package/skills/mosio-engine/references/delivery.md +29 -2
- package/skills/mosio-engine/references/kit-primitives.md +8 -4
- package/skills/mosio-engine/references/layout.md +8 -0
- package/skills/mosio-engine/references/plan.md +3 -1
- package/skills/mosio-engine/references/project.md +15 -3
- package/skills/mosio-engine/references/publish.md +79 -0
- package/skills/mosio-engine/references/registry.md +27 -15
- package/skills/mosio-engine/references/timeline.md +19 -1
- package/skills/mosio-engine/references/timing.md +2 -1
- package/skills/mosio-import/SKILL.md +1 -1
- package/skills/mosio-import/references/from-hyperframes.md +1 -1
- package/skills/mosio-import/references/from-remotion.md +1 -1
- package/skills/mosio-media/SKILL.md +16 -4
- package/skills/mosio-media/references/audio.md +29 -11
- package/skills/mosio-media/references/captions.md +26 -5
- package/skills/mosio-media/references/editing.md +70 -0
- package/skills/mosio-media/references/footage.md +40 -8
- package/skills/mosio-media/references/voice.md +52 -7
- package/skills/mosio-replicate/references/mosio.md +1 -1
- package/toolchain.lock.json +151 -4
- package/apps/studio/dist/assets/Workspace-KSOFeEgc.js +0 -32
- package/apps/studio/dist/assets/index-B-uuTqe9.js +0 -1785
- package/apps/studio/dist/assets/index-CajSh04l.css +0 -2
- package/apps/studio/dist/assets/inspector3d-vDz97X99.js +0 -1
|
@@ -0,0 +1,179 @@
|
|
|
1
|
+
{
|
|
2
|
+
"schema": "mosio.primitive/1",
|
|
3
|
+
"id": "stick-figure",
|
|
4
|
+
"title": "Stick figure",
|
|
5
|
+
"kind": "character",
|
|
6
|
+
"version": "0.2.0",
|
|
7
|
+
"summary": "A rigged stickman that acts from a list of timed acts (run, jump, punch, kick, hit, block, roll, fall, poses, faces) with anticipation, overlap, squash and stretch, feet on the ground and a contact shadow built in.",
|
|
8
|
+
"api": "MosioPrims.stickFigure(tl, target, vars) -> { at, end, times, rig } (rig.jointAt(name, t) = [x, y] of a joint at time t, design px)",
|
|
9
|
+
"target": "One empty, positioned element covering the stage. The rig draws its own SVG inside it; all lengths are 1080p design px (the shorter side of the box is 1080), so the same acts fit any output size.",
|
|
10
|
+
"parts": [],
|
|
11
|
+
"vars": {
|
|
12
|
+
"at": {
|
|
13
|
+
"type": "number",
|
|
14
|
+
"default": 0,
|
|
15
|
+
"min": 0,
|
|
16
|
+
"description": "Start of the figure's first act, seconds."
|
|
17
|
+
},
|
|
18
|
+
"duration": {
|
|
19
|
+
"type": "number|null",
|
|
20
|
+
"default": null,
|
|
21
|
+
"description": "Unused by the rig (acts set their own times); kept for the common API."
|
|
22
|
+
},
|
|
23
|
+
"motion": {
|
|
24
|
+
"type": "number|null",
|
|
25
|
+
"default": null,
|
|
26
|
+
"description": "Unused by the rig; kept for the common API."
|
|
27
|
+
},
|
|
28
|
+
"exit": {
|
|
29
|
+
"type": "boolean",
|
|
30
|
+
"default": false,
|
|
31
|
+
"description": "Unused by the rig; kept for the common API."
|
|
32
|
+
},
|
|
33
|
+
"x": {
|
|
34
|
+
"type": "number",
|
|
35
|
+
"default": 540,
|
|
36
|
+
"description": "Start position: x of the hips, in 1080p design px (the shorter side of the target box is 1080; 1920 x 1080 landscape, 1080 x 1920 portrait)."
|
|
37
|
+
},
|
|
38
|
+
"ground": {
|
|
39
|
+
"type": "number",
|
|
40
|
+
"default": 1500,
|
|
41
|
+
"description": "y of the floor line, 1080p design px. The lower foot always stands on it unless the figure is in the air."
|
|
42
|
+
},
|
|
43
|
+
"facing": {
|
|
44
|
+
"type": "integer",
|
|
45
|
+
"default": 1,
|
|
46
|
+
"enum": [
|
|
47
|
+
1,
|
|
48
|
+
-1
|
|
49
|
+
],
|
|
50
|
+
"description": "1 faces right, -1 faces left. Runs turn the figure toward where it goes."
|
|
51
|
+
},
|
|
52
|
+
"scale": {
|
|
53
|
+
"type": "number",
|
|
54
|
+
"default": 1,
|
|
55
|
+
"min": 0.2,
|
|
56
|
+
"max": 4,
|
|
57
|
+
"description": "Size: 1 is about 400 px tall standing."
|
|
58
|
+
},
|
|
59
|
+
"pose": {
|
|
60
|
+
"type": "string|object",
|
|
61
|
+
"default": "idle",
|
|
62
|
+
"description": "Start pose: a name from the pose library or an object of joint angles."
|
|
63
|
+
},
|
|
64
|
+
"face": {
|
|
65
|
+
"type": "string",
|
|
66
|
+
"default": "calm",
|
|
67
|
+
"enum": [
|
|
68
|
+
"calm",
|
|
69
|
+
"happy",
|
|
70
|
+
"grin",
|
|
71
|
+
"angry",
|
|
72
|
+
"shock",
|
|
73
|
+
"hurt",
|
|
74
|
+
"sad",
|
|
75
|
+
"determined",
|
|
76
|
+
"smug",
|
|
77
|
+
"panic",
|
|
78
|
+
"dizzy",
|
|
79
|
+
"blink"
|
|
80
|
+
],
|
|
81
|
+
"description": "Start expression."
|
|
82
|
+
},
|
|
83
|
+
"color": {
|
|
84
|
+
"type": "string",
|
|
85
|
+
"default": "--text",
|
|
86
|
+
"description": "Line colour: a theme token (--text, --accent) or any CSS colour."
|
|
87
|
+
},
|
|
88
|
+
"far": {
|
|
89
|
+
"type": "number",
|
|
90
|
+
"default": 0.55,
|
|
91
|
+
"min": 0,
|
|
92
|
+
"max": 1,
|
|
93
|
+
"description": "Opacity of the far arm and leg (depth)."
|
|
94
|
+
},
|
|
95
|
+
"width": {
|
|
96
|
+
"type": "number",
|
|
97
|
+
"default": 14,
|
|
98
|
+
"min": 2,
|
|
99
|
+
"max": 40,
|
|
100
|
+
"description": "Line width at scale 1, px."
|
|
101
|
+
},
|
|
102
|
+
"head_fill": {
|
|
103
|
+
"type": "string|null",
|
|
104
|
+
"default": null,
|
|
105
|
+
"description": "Fill of the head (a token or colour), null for an outline head."
|
|
106
|
+
},
|
|
107
|
+
"shadow": {
|
|
108
|
+
"type": "boolean",
|
|
109
|
+
"default": true,
|
|
110
|
+
"description": "A contact shadow on the floor that shrinks while the figure is in the air."
|
|
111
|
+
},
|
|
112
|
+
"shadow_color": {
|
|
113
|
+
"type": "string|null",
|
|
114
|
+
"default": null,
|
|
115
|
+
"description": "Shadow colour; null = the ground colour darkened."
|
|
116
|
+
},
|
|
117
|
+
"overlap": {
|
|
118
|
+
"type": "integer",
|
|
119
|
+
"default": 2,
|
|
120
|
+
"min": 0,
|
|
121
|
+
"max": 6,
|
|
122
|
+
"description": "Frames the head and arms trail the body in a pose change (overlapping action); 0 moves everything together."
|
|
123
|
+
},
|
|
124
|
+
"acts": {
|
|
125
|
+
"type": "object[]",
|
|
126
|
+
"default": [],
|
|
127
|
+
"description": "What the figure does, in time order. Each act has `at` (seconds) and one of: pose (name or angles, `dur`, `ease`, optional `x`), run / walk ({to, until}), jump ({to, until, height, pose, end}: `at` = take-off, `until` = landing), strike ('punch' | 'kick' | 'uppercut', `at` = contact frame, optional `lunge` px, `wind` s, `hold` frames), hit / block ({power, face, stay}), roll ({to, until, end}: `end` = the pose it settles in, default the pose before), fall ({until, dir: 'back' | 'forward' | 'down', face}: 'down' collapses in place, for vertical frames), get_up ({dur}), face (an expression on its own or with another act), blink, facing. An act that starts within one frame of the previous act's end starts on that end."
|
|
128
|
+
},
|
|
129
|
+
"props": {
|
|
130
|
+
"type": "object[]",
|
|
131
|
+
"default": [],
|
|
132
|
+
"description": "Elements that follow a joint: [{el: selector, joint: 'hand1' | 'hand2' | 'head' | 'hip' | 'chest', dx, dy, rotate, mirror}] (the element gets a translate to the joint every frame, through the body's spin and squash; give it position:absolute; left:0; top:0). `rotate: true` turns it with the joint (head tilt, torso lean, a hand along its forearm); `mirror: true` flips it with `facing`. Both turn about the joint (the element's top-left corner)."
|
|
133
|
+
}
|
|
134
|
+
},
|
|
135
|
+
"timing": {
|
|
136
|
+
"natural_s": 0,
|
|
137
|
+
"elastic": true,
|
|
138
|
+
"rule": "Each act sets its own time: a strike's `at` is its contact frame (wind-up comes before it), a jump's `at` is take-off and `until` the landing, a run arrives at `until`. Put sounds and camera hits on those times. `times` in the result lists them."
|
|
139
|
+
},
|
|
140
|
+
"eases": "pose changes power2.inOut (body) and back.out(1.6) on trailing arms and head; strikes power4.in into contact; landings back.out(2) on the squash",
|
|
141
|
+
"tokens": [
|
|
142
|
+
"text",
|
|
143
|
+
"accent",
|
|
144
|
+
"bg"
|
|
145
|
+
],
|
|
146
|
+
"use_when": [
|
|
147
|
+
"a stickman or simple character that runs, fights, falls, cheers or reacts in a story",
|
|
148
|
+
"an explainer where a figure points at, carries or reacts to things",
|
|
149
|
+
"any character motion that needs anticipation, contact and weight instead of hand-typed joint keyframes"
|
|
150
|
+
],
|
|
151
|
+
"avoid_when": [
|
|
152
|
+
"a detailed or illustrated character (draw it yourself and animate its parts)",
|
|
153
|
+
"a crowd of many figures in one scene (keep it under about 6 rigs)"
|
|
154
|
+
],
|
|
155
|
+
"pairs_with": [
|
|
156
|
+
"sparks",
|
|
157
|
+
"smoke-puff",
|
|
158
|
+
"dust-drift"
|
|
159
|
+
],
|
|
160
|
+
"usage": "MosioPrims.stickFigure(tl, '#hero', { x: 200, ground: 1500, acts: [{ at: 0.2, run: { to: 700, until: 1.2 } }, { at: 1.6, strike: 'punch', lunge: 40 }] })",
|
|
161
|
+
"example": "scene.html",
|
|
162
|
+
"golden": {
|
|
163
|
+
"scene_frames": 180,
|
|
164
|
+
"frames": [
|
|
165
|
+
30,
|
|
166
|
+
92,
|
|
167
|
+
140
|
|
168
|
+
],
|
|
169
|
+
"size": [
|
|
170
|
+
640,
|
|
171
|
+
360
|
|
172
|
+
],
|
|
173
|
+
"tolerance": {
|
|
174
|
+
"mean_abs": 2.0,
|
|
175
|
+
"outlier_share": 0.005
|
|
176
|
+
}
|
|
177
|
+
},
|
|
178
|
+
"licence": "Own work; uses GSAP (pinned in the project libraries)."
|
|
179
|
+
}
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
<!doctype html>
|
|
2
|
+
<html lang="en">
|
|
3
|
+
<head>
|
|
4
|
+
<meta charset="utf-8">
|
|
5
|
+
<link rel="stylesheet" href="/shared/tokens.css">
|
|
6
|
+
<link rel="stylesheet" href="/shared/prim.css">
|
|
7
|
+
<script src="/_lib/gsap@3.15.1/gsap.min.js"></script>
|
|
8
|
+
<script src="/shared/mosio-prims.js"></script>
|
|
9
|
+
<style>
|
|
10
|
+
.stage { position: absolute; inset: 0; }
|
|
11
|
+
.floor { position: absolute; left: 0; right: 0; top: 860px; height: 4px; background: var(--text-dim); opacity: .4; }
|
|
12
|
+
</style>
|
|
13
|
+
</head>
|
|
14
|
+
<body>
|
|
15
|
+
<div class="mp-scene" data-mosio-id="stick/scene">
|
|
16
|
+
<div class="floor"></div>
|
|
17
|
+
<div class="stage" data-mosio-id="stick/hero"></div>
|
|
18
|
+
<div class="stage" data-mosio-id="stick/rival"></div>
|
|
19
|
+
</div>
|
|
20
|
+
<script>
|
|
21
|
+
const tl = gsap.timeline({ paused: true });
|
|
22
|
+
// hero runs in, jumps, then trades blows; `at` of a strike is its contact frame (the hit sound goes there)
|
|
23
|
+
MosioPrims.stickFigure(tl, '[data-mosio-id="stick/hero"]', { x: 160, ground: 860, scale: 1.1, face: "determined", acts: [
|
|
24
|
+
{ at: 0.1, run: { to: 620, until: 1.2 } },
|
|
25
|
+
{ at: 1.4, jump: { to: 860, until: 2.0, height: 180 } },
|
|
26
|
+
{ at: 2.5, pose: "guard", dur: 0.3 },
|
|
27
|
+
{ at: 3.0, strike: "punch", lunge: 40 },
|
|
28
|
+
{ at: 3.8, block: {} },
|
|
29
|
+
{ at: 4.4, strike: "kick" },
|
|
30
|
+
{ at: 5.2, pose: "cheer", dur: 0.4, face: "grin" },
|
|
31
|
+
] });
|
|
32
|
+
MosioPrims.stickFigure(tl, '[data-mosio-id="stick/rival"]', { x: 1300, ground: 860, scale: 1.1, facing: -1, pose: "guard", face: "angry", color: "--accent", acts: [
|
|
33
|
+
{ at: 3.0, hit: { power: 0.8 } },
|
|
34
|
+
{ at: 3.8, strike: "punch" },
|
|
35
|
+
{ at: 4.4, fall: { until: 4.9 }, face: "dizzy" },
|
|
36
|
+
] });
|
|
37
|
+
__mosio.timeline(tl);
|
|
38
|
+
</script>
|
|
39
|
+
</body>
|
|
40
|
+
</html>
|
|
@@ -0,0 +1,297 @@
|
|
|
1
|
+
(function (P) {
|
|
2
|
+
"use strict";
|
|
3
|
+
// A rigged stickman. Joint angles are plain numbers on `rig.state`, so GSAP tweens them like any other value and the
|
|
4
|
+
// figure is redrawn from that state on every seek: the same frame always gives the same pose. Acts (pose, run, jump,
|
|
5
|
+
// strike, hit, roll, fall) are scheduled at build time and carry the animation craft a hand-written rig forgets:
|
|
6
|
+
// anticipation before a strike or a jump, a fast contact on the given time, a hit-stop hold, overlap (arms and head
|
|
7
|
+
// trail the body by a frame or two), squash on landing, stretch on take-off, feet kept on the ground, and a shadow.
|
|
8
|
+
//
|
|
9
|
+
// Angles are degrees from hanging straight down; positive turns toward the way the figure faces. `1` limbs are the
|
|
10
|
+
// near ones (drawn in front, full colour), `2` the far ones (behind, dimmer): a stick figure reads in depth only so.
|
|
11
|
+
const FACES = ["calm", "happy", "grin", "angry", "shock", "hurt", "sad", "determined", "smug", "panic", "dizzy", "blink"];
|
|
12
|
+
const POSES = {
|
|
13
|
+
idle: { lean: 2, head: 0, a1s: 8, a1e: 12, a2s: -8, a2e: 14, l1h: 6, l1k: 4, l2h: -6, l2k: 4 },
|
|
14
|
+
stand: { lean: 0, head: 0, a1s: 4, a1e: 6, a2s: -4, a2e: 6, l1h: 3, l1k: 2, l2h: -3, l2k: 2 },
|
|
15
|
+
guard: { lean: 8, head: 4, a1s: 48, a1e: 96, a2s: 34, a2e: 108, l1h: 24, l1k: 22, l2h: -20, l2k: 16 },
|
|
16
|
+
punch_wind: { lean: -6, head: 2, a1s: 28, a1e: 135, a2s: 72, a2e: 100, l1h: 20, l1k: 26, l2h: -26, l2k: 20 },
|
|
17
|
+
punch: { lean: 20, head: 6, a1s: 90, a1e: 0, a2s: 18, a2e: 125, l1h: 34, l1k: 22, l2h: -32, l2k: 4 },
|
|
18
|
+
uppercut_wind: { lean: 26, head: 6, a1s: -10, a1e: 120, a2s: 60, a2e: 110, l1h: 44, l1k: 60, l2h: -10, l2k: 50 },
|
|
19
|
+
uppercut: { lean: -8, head: -10, a1s: 160, a1e: 25, a2s: 30, a2e: 110, l1h: 10, l1k: 6, l2h: -24, l2k: 8 },
|
|
20
|
+
kick_wind: { lean: -12, head: 0, a1s: 40, a1e: 80, a2s: -30, a2e: 40, l1h: 72, l1k: 115, l2h: -4, l2k: 12 },
|
|
21
|
+
kick: { lean: -26, head: -4, a1s: 62, a1e: 30, a2s: -52, a2e: 20, l1h: 96, l1k: 0, l2h: -8, l2k: 6 },
|
|
22
|
+
block: { lean: -6, head: -6, a1s: 118, a1e: 128, a2s: 98, a2e: 140, l1h: 18, l1k: 22, l2h: -24, l2k: 14 },
|
|
23
|
+
dodge: { lean: -30, head: -14, a1s: 50, a1e: 90, a2s: 20, a2e: 100, l1h: 10, l1k: 36, l2h: -40, l2k: 24 },
|
|
24
|
+
hurt: { lean: -24, head: -26, a1s: -34, a1e: 34, a2s: 44, a2e: 22, l1h: 16, l1k: 12, l2h: -22, l2k: 6 },
|
|
25
|
+
crouch: { lean: 28, head: -6, a1s: 26, a1e: 40, a2s: -14, a2e: 50, l1h: 74, l1k: 124, l2h: 44, l2k: 112 },
|
|
26
|
+
stretch: { lean: 4, head: -8, a1s: 168, a1e: 8, a2s: 158, a2e: 14, l1h: -6, l1k: 8, l2h: -16, l2k: 18 },
|
|
27
|
+
tuck: { lean: 24, head: 10, a1s: 64, a1e: 92, a2s: 52, a2e: 96, l1h: 104, l1k: 132, l2h: 84, l2k: 124 },
|
|
28
|
+
land: { lean: 22, head: 4, a1s: 54, a1e: 18, a2s: 76, a2e: 22, l1h: 58, l1k: 104, l2h: 26, l2k: 84 },
|
|
29
|
+
cheer: { lean: -4, head: -12, a1s: 166, a1e: 14, a2s: 156, a2e: 26, l1h: 6, l1k: 4, l2h: -8, l2k: 4 },
|
|
30
|
+
point: { lean: 4, head: 2, a1s: 86, a1e: 2, a2s: -6, a2e: 14, l1h: 8, l1k: 4, l2h: -8, l2k: 4 },
|
|
31
|
+
wave: { lean: 0, head: -4, a1s: 150, a1e: 44, a2s: -6, a2e: 14, l1h: 6, l1k: 4, l2h: -6, l2k: 4 },
|
|
32
|
+
think: { lean: 4, head: 12, a1s: 32, a1e: 150, a2s: 30, a2e: 96, l1h: 6, l1k: 4, l2h: -6, l2k: 4 },
|
|
33
|
+
shock: { lean: -12, head: -8, a1s: 122, a1e: 60, a2s: 112, a2e: 70, l1h: 10, l1k: 8, l2h: -12, l2k: 6 },
|
|
34
|
+
sad: { lean: 14, head: 26, a1s: 2, a1e: 4, a2s: -2, a2e: 6, l1h: 4, l1k: 6, l2h: -4, l2k: 6 },
|
|
35
|
+
stumble: { lean: 46, head: -18, a1s: 124, a1e: 20, a2s: -62, a2e: 30, l1h: 42, l1k: 30, l2h: -52, l2k: 62 },
|
|
36
|
+
carry: { lean: 6, head: 0, a1s: 70, a1e: 64, a2s: 64, a2e: 70, l1h: 6, l1k: 4, l2h: -6, l2k: 4 },
|
|
37
|
+
give: { lean: 10, head: 4, a1s: 80, a1e: 14, a2s: 74, a2e: 18, l1h: 10, l1k: 6, l2h: -8, l2k: 4 },
|
|
38
|
+
sit: { lean: 2, head: 0, a1s: 30, a1e: 50, a2s: 24, a2e: 56, l1h: 90, l1k: 90, l2h: 84, l2k: 90 },
|
|
39
|
+
lie: { lean: 0, head: -6, a1s: 150, a1e: 10, a2s: 30, a2e: 20, l1h: 8, l1k: 4, l2h: -14, l2k: 18 },
|
|
40
|
+
bow: { lean: 50, head: 10, a1s: 4, a1e: 6, a2s: -4, a2e: 6, l1h: 4, l1k: 2, l2h: -4, l2k: 2 },
|
|
41
|
+
sit_floor: { lean: 8, head: 6, a1s: 26, a1e: 30, a2s: 14, a2e: 40, l1h: 88, l1k: 6, l2h: 80, l2k: 30 },
|
|
42
|
+
slump: { lean: 38, head: 34, a1s: 6, a1e: 10, a2s: -4, a2e: 14, l1h: 86, l1k: 10, l2h: 76, l2k: 40 },
|
|
43
|
+
};
|
|
44
|
+
const JOINTS = ["hand1", "hand2", "head", "hip", "chest"];
|
|
45
|
+
const KEYS = ["lean", "head", "a1s", "a1e", "a2s", "a2e", "l1h", "l1k", "l2h", "l2k"];
|
|
46
|
+
const BODY = ["lean", "l1h", "l1k", "l2h", "l2k"], LIMBS = ["head", "a1s", "a1e", "a2s", "a2e"];
|
|
47
|
+
const STRIKES = { punch: "punch_wind", kick: "kick_wind", uppercut: "uppercut_wind" };
|
|
48
|
+
const rad = (d) => (d * Math.PI) / 180;
|
|
49
|
+
|
|
50
|
+
function poseOf(id, p) {
|
|
51
|
+
if (typeof p === "string") { if (!POSES[p]) throw new Error("E_PRIM_VAR " + id + ": unknown pose '" + p + "' (known: " + Object.keys(POSES).join(", ") + ")"); return POSES[p]; }
|
|
52
|
+
if (p && typeof p === "object") { for (const k of Object.keys(p)) if (KEYS.indexOf(k) < 0) throw new Error("E_PRIM_VAR " + id + ": pose key '" + k + "' (known: " + KEYS.join(", ") + ")"); return p; }
|
|
53
|
+
throw new Error("E_PRIM_VAR " + id + ": a pose is a name or an object of joint angles");
|
|
54
|
+
}
|
|
55
|
+
const pick = (o, ks) => { const r = {}; for (const k of ks) if (k in o) r[k] = o[k]; return r; };
|
|
56
|
+
|
|
57
|
+
P.define("stick-figure", Object.assign({}, P.COMMON_DEFAULTS, {
|
|
58
|
+
x: 540, ground: 1500, facing: 1, scale: 1, pose: "idle", face: "calm", color: "--text", far: 0.55, width: 14,
|
|
59
|
+
head_fill: null, shadow: true, shadow_color: null, overlap: 2, acts: [], props: [],
|
|
60
|
+
}), (tl, target, v) => {
|
|
61
|
+
const id = "stick-figure", root = P.one(target, id), F = P.frames;
|
|
62
|
+
P.num(id, "scale", v.scale, 0.2, 4); P.num(id, "width", v.width, 2, 40); P.num(id, "far", v.far, 0, 1);
|
|
63
|
+
P.int(id, "overlap", v.overlap, 0, 6); P.oneOf(id, "facing", v.facing, [1, -1]); P.oneOf(id, "face", v.face, FACES);
|
|
64
|
+
if (!Array.isArray(v.acts)) throw new Error("E_PRIM_VAR " + id + ": acts must be a list");
|
|
65
|
+
const col = (c) => (c && c.startsWith("--") ? "var(" + c + ")" : c);
|
|
66
|
+
const S = v.scale, L = { r: 34 * S, neck: 8 * S, torso: 112 * S, ua: 70 * S, fa: 66 * S, th: 88 * S, sh: 86 * S, foot: 22 * S };
|
|
67
|
+
|
|
68
|
+
// ---- drawing ----
|
|
69
|
+
if (getComputedStyle(root).position === "static") root.style.position = "absolute";
|
|
70
|
+
// lengths are 1080p design px: the shorter side of the box is 1080, so the same numbers fit any output size
|
|
71
|
+
const BW = root.offsetWidth || 1080, BH = root.offsetHeight || 1920, K = 1080 / Math.min(BW, BH), W = BW * K, H = BH * K;
|
|
72
|
+
const svg = P.svg("svg", { viewBox: "0 0 " + W.toFixed(2) + " " + H.toFixed(2), width: BW, height: BH, style: "position:absolute;left:0;top:0;overflow:visible" }, root);
|
|
73
|
+
const stroke = { fill: "none", stroke: col(v.color), "stroke-width": v.width * S, "stroke-linecap": "round", "stroke-linejoin": "round" };
|
|
74
|
+
const shadow = v.shadow ? P.svg("ellipse", { rx: 70 * S, ry: 12 * S, fill: v.shadow_color ? col(v.shadow_color) : "color-mix(in srgb, var(--bg), black 75%)", opacity: 0.22 }, svg) : null;
|
|
75
|
+
const body = P.svg("g", {}, svg);
|
|
76
|
+
const farG = P.svg("g", { opacity: v.far }, body);
|
|
77
|
+
const arm2 = P.svg("path", stroke, farG), leg2 = P.svg("path", stroke, farG);
|
|
78
|
+
const leg1 = P.svg("path", stroke, body), torso = P.svg("path", stroke, body);
|
|
79
|
+
const headG = P.svg("g", {}, body);
|
|
80
|
+
P.svg("circle", Object.assign({}, stroke, { r: L.r, fill: v.head_fill ? col(v.head_fill) : "none" }), headG);
|
|
81
|
+
const faceG = P.svg("g", { fill: "none", stroke: col(v.color), "stroke-width": 5 * S, "stroke-linecap": "round" }, headG);
|
|
82
|
+
const brow = P.svg("path", {}, faceG), eyes = P.svg("path", { "stroke-width": 9 * S }, faceG), mouth = P.svg("path", {}, faceG);
|
|
83
|
+
const arm1 = P.svg("path", stroke, body);
|
|
84
|
+
P.tagId(svg, root, "rig");
|
|
85
|
+
const props = (v.props || []).map((p) => {
|
|
86
|
+
const el = P.one(p.el, id + " props");
|
|
87
|
+
// a prop that turns or flips does so about the joint (its top-left corner sits on the joint)
|
|
88
|
+
if (p.rotate || p.mirror) el.style.transformOrigin = "0 0";
|
|
89
|
+
return { el, joint: P.oneOf(id, "props.joint", p.joint || "hand1", JOINTS), dx: p.dx || 0, dy: p.dy || 0, rotate: !!p.rotate, mirror: !!p.mirror };
|
|
90
|
+
});
|
|
91
|
+
|
|
92
|
+
// face shapes in head space (r = 34, facing right; mirrored for facing -1)
|
|
93
|
+
const FACE = {
|
|
94
|
+
calm: ["M2 -16 l12 0 M20 -16 l12 0", "M8 -4 l0 1 M26 -4 l0 1", "M10 14 q8 5 16 0"],
|
|
95
|
+
happy: ["M2 -18 q6 -4 12 0 M20 -18 q6 -4 12 0", "M8 -4 l0 1 M26 -4 l0 1", "M6 10 q11 14 24 0"],
|
|
96
|
+
grin: ["M2 -18 q6 -4 12 0 M20 -18 q6 -4 12 0", "M5 -4 q3 -4 6 0 M23 -4 q3 -4 6 0", "M4 9 q13 18 26 0 z"],
|
|
97
|
+
angry: ["M2 -20 l12 6 M32 -20 l-12 6", "M8 -4 l0 1 M26 -4 l0 1", "M8 16 q9 -6 18 0"],
|
|
98
|
+
shock: ["M2 -22 q6 -5 12 0 M20 -22 q6 -5 12 0", "M8 -6 l0 4 M26 -6 l0 4", "M12 12 q5 -6 10 0 q-5 8 -10 0"],
|
|
99
|
+
hurt: ["M2 -14 l12 -5 M32 -14 l-12 -5", "M4 -6 l8 6 M12 -6 l-8 6 M22 -6 l8 6 M30 -6 l-8 6", "M8 16 q4 -4 8 0 q4 4 8 0 q4 -4 8 0"],
|
|
100
|
+
sad: ["M2 -14 l12 -5 M32 -14 l-12 -5", "M8 -3 l0 1 M26 -3 l0 1", "M9 18 q9 -8 18 0"],
|
|
101
|
+
determined: ["M2 -18 l12 4 M32 -18 l-12 4", "M8 -4 l0 1 M26 -4 l0 1", "M9 14 l18 0"],
|
|
102
|
+
smug: ["M2 -16 l12 -2 M20 -20 l12 4", "M6 -4 l6 0 M24 -4 l6 0", "M8 12 q10 6 20 -4"],
|
|
103
|
+
panic: ["M2 -22 l12 -4 M32 -22 l-12 -4", "M8 -7 l0 5 M26 -7 l0 5", "M8 10 q10 12 20 0 q-10 -4 -20 0"],
|
|
104
|
+
dizzy: ["", "M4 -8 l8 8 M12 -8 l-8 8 M22 -8 l8 8 M30 -8 l-8 8", "M8 14 q5 4 10 0 q5 -4 10 0"],
|
|
105
|
+
blink: ["M2 -16 l12 0 M20 -16 l12 0", "M4 -3 l8 0 M22 -3 l8 0", "M10 14 q8 5 16 0"],
|
|
106
|
+
};
|
|
107
|
+
|
|
108
|
+
const st = Object.assign({ x: v.x, air: 0, rot: 0, pv: 1, sq: 1, facing: v.facing, loco: 0, phase: 0, gait: 0, face: v.face }, POSES.idle, poseOf(id, v.pose));
|
|
109
|
+
const fmt = (n) => n.toFixed(1);
|
|
110
|
+
const seg = (a, b, c) => "M" + fmt(a[0]) + " " + fmt(a[1]) + " L" + fmt(b[0]) + " " + fmt(b[1]) + " L" + fmt(c[0]) + " " + fmt(c[1]);
|
|
111
|
+
const at = (o, ang, len, f) => [o[0] + f * Math.sin(rad(ang)) * len, o[1] + Math.cos(rad(ang)) * len];
|
|
112
|
+
// locomotion cycle (run when gait = 1, walk when 0) at phase p, blended over the pose by `loco`
|
|
113
|
+
function cycle(p, gait) {
|
|
114
|
+
const th = 2 * Math.PI * p, A = 22 + 18 * gait, K = 10 + 70 * gait, s = Math.sin(th), c = Math.cos(th);
|
|
115
|
+
const kn = (cc) => 6 + K * Math.max(0, cc);
|
|
116
|
+
return { lean: 3 + 13 * gait, head: -2 * gait, l1h: A * s, l1k: kn(c), l2h: -A * s, l2k: kn(-c),
|
|
117
|
+
a1s: -(16 + 30 * gait) * s, a1e: 14 + 76 * gait, a2s: (16 + 30 * gait) * s, a2e: 14 + 76 * gait, bob: (4 + 10 * gait) * Math.abs(Math.cos(th)) };
|
|
118
|
+
}
|
|
119
|
+
let joints = null;
|
|
120
|
+
function draw() {
|
|
121
|
+
const f = st.facing, q = {};
|
|
122
|
+
const cy = st.loco > 0 ? cycle(st.phase, st.gait) : null;
|
|
123
|
+
for (const k of KEYS) q[k] = cy ? st[k] + (cy[k] - st[k]) * st.loco : st[k];
|
|
124
|
+
// the lower foot stands on the ground: hip height comes from the legs, so a crouch lowers the body by itself
|
|
125
|
+
const drop = Math.max(L.th * Math.cos(rad(q.l1h)) + L.sh * Math.cos(rad(q.l1h - q.l1k)), L.th * Math.cos(rad(q.l2h)) + L.sh * Math.cos(rad(q.l2h - q.l2k)));
|
|
126
|
+
const bob = cy ? cy.bob * st.loco : 0;
|
|
127
|
+
const hip = [st.x, v.ground - st.air - drop - bob];
|
|
128
|
+
const up = [f * Math.sin(rad(q.lean)), -Math.cos(rad(q.lean))];
|
|
129
|
+
const chest = [hip[0] + up[0] * L.torso, hip[1] + up[1] * L.torso];
|
|
130
|
+
const sho = [hip[0] + up[0] * (L.torso - 10 * S), hip[1] + up[1] * (L.torso - 10 * S)];
|
|
131
|
+
const hang = 180 + q.lean + q.head * 0.4;
|
|
132
|
+
const headC = [chest[0] + f * Math.sin(rad(q.lean + q.head * 0.4)) * (L.neck + L.r), chest[1] - Math.cos(rad(q.lean + q.head * 0.4)) * (L.neck + L.r)];
|
|
133
|
+
const limb = (o, a1, a2, l1, l2) => { const m = at(o, a1, l1, f), e = at(m, a2, l2, f); return [o, m, e]; };
|
|
134
|
+
const A1 = limb(sho, q.a1s + q.lean, q.a1s + q.lean + q.a1e, L.ua, L.fa), A2 = limb(sho, q.a2s + q.lean, q.a2s + q.lean + q.a2e, L.ua, L.fa);
|
|
135
|
+
const G1 = limb(hip, q.l1h, q.l1h - q.l1k, L.th, L.sh), G2 = limb(hip, q.l2h, q.l2h - q.l2k, L.th, L.sh);
|
|
136
|
+
const foot = (g) => " L" + fmt(g[2][0] + f * L.foot) + " " + fmt(g[2][1] + 2 * S);
|
|
137
|
+
arm1.setAttribute("d", seg(A1[0], A1[1], A1[2])); arm2.setAttribute("d", seg(A2[0], A2[1], A2[2]));
|
|
138
|
+
leg1.setAttribute("d", seg(G1[0], G1[1], G1[2]) + foot(G1)); leg2.setAttribute("d", seg(G2[0], G2[1], G2[2]) + foot(G2));
|
|
139
|
+
torso.setAttribute("d", "M" + fmt(hip[0]) + " " + fmt(hip[1]) + " L" + fmt(chest[0]) + " " + fmt(chest[1]));
|
|
140
|
+
headG.setAttribute("transform", "translate(" + fmt(headC[0]) + " " + fmt(headC[1]) + ") rotate(" + fmt(f * (q.lean * 0.5 + q.head)) + ")");
|
|
141
|
+
const fc = FACE[st.face] || FACE.calm;
|
|
142
|
+
faceG.setAttribute("transform", "scale(" + f * S + " " + S + ") translate(-12 0)");
|
|
143
|
+
brow.setAttribute("d", fc[0] || "M0 0"); eyes.setAttribute("d", fc[1]); mouth.setAttribute("d", fc[2]);
|
|
144
|
+
// squash and stretch about the feet, spin about the belly; volume is kept (x scales by 1 / sqrt(y))
|
|
145
|
+
const sy = st.sq, sx = 1 / Math.sqrt(sy), pivot = [hip[0], v.ground - st.air - (drop * 0.9 + bob) * st.pv];
|
|
146
|
+
body.setAttribute("transform", "rotate(" + fmt(f * st.rot) + " " + fmt(pivot[0]) + " " + fmt(pivot[1]) + ") translate(" + fmt(st.x) + " " + fmt(v.ground) + ") scale(" + sx.toFixed(4) + " " + sy.toFixed(4) + ") translate(" + fmt(-st.x) + " " + fmt(-v.ground) + ")");
|
|
147
|
+
if (shadow) { const k = Math.max(0.35, 1 - st.air / (400 * S)); shadow.setAttribute("cx", fmt(st.x)); shadow.setAttribute("cy", fmt(v.ground + 4 * S)); shadow.setAttribute("rx", fmt(70 * S * k * sx)); shadow.setAttribute("opacity", (0.22 * k).toFixed(3)); }
|
|
148
|
+
// joints where they are drawn: through the body's squash and spin, so a held prop stays in the hand in a roll
|
|
149
|
+
const ca = Math.cos(rad(f * st.rot)), sa = Math.sin(rad(f * st.rot));
|
|
150
|
+
const world = (p) => {
|
|
151
|
+
const x = st.x + (p[0] - st.x) * sx - pivot[0], y = v.ground + (p[1] - v.ground) * sy - pivot[1];
|
|
152
|
+
return [pivot[0] + x * ca - y * sa, pivot[1] + x * sa + y * ca];
|
|
153
|
+
};
|
|
154
|
+
const dir = (a, b) => (Math.atan2(b[1] - a[1], b[0] - a[0]) * 180) / Math.PI;
|
|
155
|
+
// the angle a prop turns by with its joint: the head's tilt, the torso's lean, a hand along its forearm
|
|
156
|
+
const turn = { head: f * (q.lean * 0.5 + q.head), hip: f * q.lean, chest: f * q.lean, hand1: dir(A1[1], A1[2]) - (f > 0 ? 0 : 180), hand2: dir(A2[1], A2[2]) - (f > 0 ? 0 : 180) };
|
|
157
|
+
joints = { hand1: world(A1[2]), hand2: world(A2[2]), head: world(headC), hip: world(hip), chest: world(chest) };
|
|
158
|
+
for (const p of props) {
|
|
159
|
+
const j = joints[p.joint];
|
|
160
|
+
if (!p.rotate && !p.mirror) { p.el.style.transform = "translate(" + fmt((j[0] + f * p.dx) / K) + "px," + fmt((j[1] + p.dy) / K) + "px)"; continue; }
|
|
161
|
+
const a = p.rotate ? turn[p.joint] + f * st.rot : 0, m = p.mirror ? f : 1, ox = p.mirror ? p.dx : f * p.dx;
|
|
162
|
+
p.el.style.transform = "translate(" + fmt(j[0] / K) + "px," + fmt(j[1] / K) + "px) rotate(" + fmt(a) + "deg) scale(" + m + ",1) translate(" + fmt(ox / K) + "px," + fmt(p.dy / K) + "px)";
|
|
163
|
+
}
|
|
164
|
+
}
|
|
165
|
+
|
|
166
|
+
// ---- acts ----
|
|
167
|
+
const cur = { x: v.x, facing: v.facing, pose: Object.assign({}, pick(st, KEYS)) };
|
|
168
|
+
const lag = F(v.overlap);
|
|
169
|
+
const set = (t, props) => { if (P.q(t) <= 0) Object.assign(st, props); else tl.set(st, props, P.tick(t)); };
|
|
170
|
+
// pose change with overlap: body first, head and arms trail by `overlap` frames and settle with a little follow-through
|
|
171
|
+
function poseTo(t, pose, dur, ease, follow) {
|
|
172
|
+
const target = Object.assign({}, cur.pose, pose);
|
|
173
|
+
const b = pick(target, BODY), l = pick(target, LIMBS);
|
|
174
|
+
tl.to(st, Object.assign(b, { duration: dur, ease: ease || P.EASE.move }), P.q(t));
|
|
175
|
+
tl.to(st, Object.assign(l, { duration: dur + lag, ease: follow ? "back.out(1.6)" : ease || P.EASE.move }), P.q(t + (follow ? lag : 0)));
|
|
176
|
+
cur.pose = target;
|
|
177
|
+
}
|
|
178
|
+
let end = P.q(v.at), times = [];
|
|
179
|
+
for (const a of v.acts) {
|
|
180
|
+
let t = P.q(a.at != null ? a.at : end);
|
|
181
|
+
// an act that starts within one frame of the previous end (times rounded to frames) starts on that end
|
|
182
|
+
if (t < end && t >= end - F(1) - 1e-6 && !a.face && !a.with) t = end;
|
|
183
|
+
if (t < end - 1e-6 && !a.face && !a.with) throw new Error("E_PRIM_VAR " + id + ": acts must be in time order (act at " + t + " starts before the previous ends at " + end + ")");
|
|
184
|
+
if (a.face) { P.oneOf(id, "face", a.face, FACES); set(t, { face: a.face }); if (Object.keys(a).length === 2) { times.push({ face: a.face, at: t }); continue; } }
|
|
185
|
+
if (a.facing) { P.oneOf(id, "facing", a.facing, [1, -1]); set(t, { facing: a.facing }); cur.facing = a.facing; }
|
|
186
|
+
if (a.pose) {
|
|
187
|
+
const d = a.dur != null ? a.dur : 0.3;
|
|
188
|
+
poseTo(t, poseOf(id, a.pose), d, a.ease, a.follow !== false);
|
|
189
|
+
if (a.x != null) { tl.fromTo(st, { x: cur.x }, { x: a.x, duration: d, ease: a.ease || P.EASE.move, immediateRender: false }, t); cur.x = a.x; }
|
|
190
|
+
end = P.q(t + d); times.push({ pose: a.pose, at: t, end }); continue;
|
|
191
|
+
}
|
|
192
|
+
if (a.run || a.walk) {
|
|
193
|
+
const o = a.run || a.walk, gait = a.run ? 1 : 0, until = P.q(P.num(id, "until", o.until, t + 0.1, 1e4));
|
|
194
|
+
const dx = o.to - cur.x, dir = dx < 0 ? -1 : 1, cyc = (gait ? 430 : 290) * S;
|
|
195
|
+
set(t, { facing: dir, gait }); cur.facing = dir;
|
|
196
|
+
const ph = { d: 0 }, x0 = cur.x;
|
|
197
|
+
tl.to(st, { loco: 1, duration: F(4), ease: "power1.out" }, t);
|
|
198
|
+
tl.fromTo(ph, { d: 0 }, { d: Math.abs(dx), duration: until - t, ease: o.ease || "power1.inOut", immediateRender: false, onUpdate: () => { st.x = x0 + dir * ph.d; st.phase = ph.d / cyc; } }, t);
|
|
199
|
+
tl.to(st, { loco: 0, duration: F(5), ease: "power2.out" }, until - F(3));
|
|
200
|
+
if (o.face) set(t, { face: o.face });
|
|
201
|
+
cur.x = o.to; end = until; times.push({ [gait ? "run" : "walk"]: o.to, at: t, arrive: until }); continue;
|
|
202
|
+
}
|
|
203
|
+
if (a.jump) {
|
|
204
|
+
// anticipation crouch before `at` (take-off), stretch on the way up, tuck at the top, land with a squash at `until`
|
|
205
|
+
const o = a.jump, until = P.q(P.num(id, "until", o.until, t + 0.2, 1e4)), h = (o.height != null ? o.height : 220) * S, to = o.to != null ? o.to : cur.x;
|
|
206
|
+
const pre = F(5), air = until - t, prev = Object.assign({}, cur.pose);
|
|
207
|
+
poseTo(t - pre, POSES.crouch, pre, "power2.out", false); tl.to(st, { sq: 0.86, duration: pre, ease: "power2.out" }, t - pre);
|
|
208
|
+
poseTo(t, POSES.stretch, F(4), "power3.out", false); tl.to(st, { sq: 1.12, duration: F(3), ease: "power2.out" }, t);
|
|
209
|
+
tl.to(st, { sq: 1, duration: F(5), ease: "power2.inOut" }, t + F(3));
|
|
210
|
+
poseTo(t + air * 0.3, a.jump.pose ? poseOf(id, a.jump.pose) : POSES.tuck, air * 0.4, "power2.inOut", true);
|
|
211
|
+
const ar = { u: 0 };
|
|
212
|
+
const jx = cur.x;
|
|
213
|
+
tl.fromTo(ar, { u: 0 }, { u: 1, duration: air, ease: "none", immediateRender: false, onUpdate: () => { st.air = 4 * h * ar.u * (1 - ar.u); st.x = jx + (to - jx) * ar.u; } }, t);
|
|
214
|
+
poseTo(until - F(3), POSES.land, F(3), "power2.in", false);
|
|
215
|
+
tl.to(st, { sq: 0.8, duration: F(2), ease: "power2.out" }, until); tl.to(st, { sq: 1, duration: F(8), ease: "back.out(2)" }, until + F(2));
|
|
216
|
+
poseTo(until + F(4), o.end ? poseOf(id, o.end) : prev, 0.3, "power2.out", true);
|
|
217
|
+
cur.x = to; end = P.q(until + F(4) + 0.3); times.push({ jump: to, takeoff: t, land: until }); continue;
|
|
218
|
+
}
|
|
219
|
+
if (a.strike) {
|
|
220
|
+
// `at` is the contact frame (put the hit sound there): wind-up before it, a 2-frame snap, a hold, recover to guard
|
|
221
|
+
const k = P.oneOf(id, "strike", a.strike, ["punch", "kick", "uppercut"]), wind = F(a.wind != null ? Math.round(a.wind * P.fps()) : 6), hold = F(a.hold != null ? a.hold : 3);
|
|
222
|
+
poseTo(t - wind - F(2), POSES[STRIKES[k]], wind, "power2.out", false);
|
|
223
|
+
poseTo(t - F(2), POSES[k], F(2), "power4.in", false);
|
|
224
|
+
if (a.lunge) { tl.fromTo(st, { x: cur.x }, { x: cur.x + cur.facing * a.lunge, duration: F(4), ease: "power3.out", immediateRender: false }, t - F(2)); cur.x += cur.facing * a.lunge; }
|
|
225
|
+
poseTo(t + hold, POSES.guard, 0.3, "power2.out", true);
|
|
226
|
+
end = P.q(t + hold + 0.3); times.push({ strike: k, contact: t }); continue;
|
|
227
|
+
}
|
|
228
|
+
if (a.hit || a.block) {
|
|
229
|
+
const o = a.hit || a.block, power = o.power != null ? o.power : 1;
|
|
230
|
+
const back = -cur.facing * (a.hit ? 70 : 24) * power * S, rec = a.hit ? 0.45 : 0.25;
|
|
231
|
+
poseTo(t, a.hit ? POSES.hurt : POSES.block, F(2), "power4.out", false);
|
|
232
|
+
tl.fromTo(st, { x: cur.x }, { x: cur.x + back, duration: 0.3, ease: "power3.out", immediateRender: false }, t); cur.x += back;
|
|
233
|
+
if (a.hit) set(t, { face: o.face || "hurt" });
|
|
234
|
+
if (!o.stay) poseTo(t + F(4), POSES.guard, rec, "power2.inOut", true);
|
|
235
|
+
end = P.q(t + (o.stay ? F(2) : F(4) + rec)); times.push({ [a.hit ? "hit" : "block"]: t }); continue;
|
|
236
|
+
}
|
|
237
|
+
if (a.roll) {
|
|
238
|
+
const o = a.roll, until = P.q(P.num(id, "until", o.until, t + 0.2, 1e4)), prev = Object.assign({}, cur.pose);
|
|
239
|
+
poseTo(t, POSES.tuck, F(4), "power2.out", false);
|
|
240
|
+
tl.to(st, { rot: "+=360", duration: until - t, ease: "power1.inOut" }, t);
|
|
241
|
+
tl.fromTo(st, { x: cur.x }, { x: o.to, duration: until - t, ease: "power1.inOut", immediateRender: false }, t);
|
|
242
|
+
poseTo(until - F(2), o.pose ? poseOf(id, o.pose) : POSES.land, F(3), "power2.out", false);
|
|
243
|
+
poseTo(until + F(3), o.end ? poseOf(id, o.end) : prev, 0.3, "power2.out", true);
|
|
244
|
+
cur.x = o.to; end = P.q(until + F(3) + 0.3); times.push({ roll: o.to, at: t, until }); continue;
|
|
245
|
+
}
|
|
246
|
+
if (a.fall) {
|
|
247
|
+
// fall flat: tip over the feet, hit the ground on `until` with a small bounce
|
|
248
|
+
const o = a.fall, until = P.q(P.num(id, "until", o.until, t + 0.15, 1e4));
|
|
249
|
+
P.oneOf(id, "fall.dir", o.dir || "back", ["back", "forward", "down"]);
|
|
250
|
+
if (o.dir === "down") {
|
|
251
|
+
// collapse in place (vertical frames): knees give, the hips reach the floor on `until`, a small settle
|
|
252
|
+
poseTo(t, POSES.crouch, (until - t) * 0.5, "power2.in", false);
|
|
253
|
+
poseTo(t + (until - t) * 0.5, POSES.slump, (until - t) * 0.5, "power2.in", true);
|
|
254
|
+
tl.to(st, { sq: 0.9, duration: F(2), ease: "power2.out" }, until); tl.to(st, { sq: 1, duration: F(6), ease: "power2.out" }, until + F(2));
|
|
255
|
+
if (o.face) set(t, { face: o.face });
|
|
256
|
+
end = P.q(until + F(8)); times.push({ fall: "down", land: until }); continue;
|
|
257
|
+
}
|
|
258
|
+
const dir = o.dir === "forward" ? 1 : -1;
|
|
259
|
+
set(t, { pv: 0 });
|
|
260
|
+
poseTo(t, dir > 0 ? POSES.stumble : POSES.hurt, (until - t) * 0.6, "power2.in", false);
|
|
261
|
+
poseTo(until - F(2), POSES.lie, F(6), "power2.out", true);
|
|
262
|
+
tl.to(st, { rot: dir * 84, duration: until - t, ease: "power2.in" }, t);
|
|
263
|
+
tl.to(st, { rot: dir * 78, duration: F(3), ease: "power2.out" }, until); tl.to(st, { rot: dir * 84, duration: F(4), ease: "power2.in" }, until + F(3));
|
|
264
|
+
if (o.face) set(t, { face: o.face });
|
|
265
|
+
end = P.q(until + F(7)); times.push({ fall: o.dir || "back", land: until }); continue;
|
|
266
|
+
}
|
|
267
|
+
if (a.get_up) {
|
|
268
|
+
const d = a.get_up.dur || 0.6;
|
|
269
|
+
tl.to(st, { rot: 0, duration: d, ease: "power2.inOut" }, t); set(t + d, { pv: 1 });
|
|
270
|
+
poseTo(t, POSES.crouch, d * 0.6, "power2.out", false); poseTo(t + d * 0.6, POSES.guard, d * 0.4, "power2.out", true);
|
|
271
|
+
end = P.q(t + d); times.push({ get_up: t }); continue;
|
|
272
|
+
}
|
|
273
|
+
if (a.blink) { set(t, { face: "blink" }); set(t + F(3), { face: a.blink === true ? st.face : a.blink }); continue; }
|
|
274
|
+
throw new Error("E_PRIM_VAR " + id + ": unknown act " + JSON.stringify(Object.keys(a)) + " (pose, run, walk, jump, strike, hit, block, roll, fall, get_up, face, blink)");
|
|
275
|
+
}
|
|
276
|
+
|
|
277
|
+
// redraw from state on every seek (and on GSAP updates outside Mosio, for the gallery)
|
|
278
|
+
if (P.q(end) > tl.duration()) tl.to({}, { duration: 0 }, P.q(end));
|
|
279
|
+
tl.eventCallback("onUpdate", ((prev) => function () { draw(); if (prev) prev.apply(this, arguments); })(tl.eventCallback("onUpdate")));
|
|
280
|
+
if (window.__mosio && typeof window.__mosio.onSeek === "function") window.__mosio.onSeek(() => draw()); else draw();
|
|
281
|
+
draw();
|
|
282
|
+
// where a joint is at time t, in 1080p design px (to throw a prop from the hand, aim a burst at a foot of a kick):
|
|
283
|
+
// seeks the timeline there and back, so call it after every act is scheduled and before playback
|
|
284
|
+
const jointAt = (name, t) => {
|
|
285
|
+
P.oneOf(id, "jointAt", name, JOINTS);
|
|
286
|
+
const was = tl.time();
|
|
287
|
+
// events on: a run moves x in its onUpdate, which a default (silent) seek skips
|
|
288
|
+
tl.seek(t, false); draw();
|
|
289
|
+
const j = joints[name].slice();
|
|
290
|
+
tl.seek(was, false); draw();
|
|
291
|
+
return j;
|
|
292
|
+
};
|
|
293
|
+
const rig = { state: st, poses: POSES, faces: FACES, draw, joints: () => joints, jointAt, poseTo };
|
|
294
|
+
return { at: P.q(v.at), end, entrance_end: P.q(v.at), exit_at: null, hold_s: 0, times, rig };
|
|
295
|
+
});
|
|
296
|
+
P.STICK_POSES = POSES;
|
|
297
|
+
})(window.MosioPrims);
|
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
"id": "zoom-through",
|
|
4
4
|
"title": "Zoom through",
|
|
5
5
|
"kind": "transition",
|
|
6
|
-
"version": "0.
|
|
6
|
+
"version": "0.2.0",
|
|
7
7
|
"summary": "The outgoing layer rushes toward the viewer and fades; the next settles from slightly small.",
|
|
8
8
|
"api": "MosioPrims.zoomThrough(tl, target, vars)",
|
|
9
9
|
"target": "Not used: pass null. Layers are `from` and `to` in vars.",
|
|
@@ -45,7 +45,7 @@
|
|
|
45
45
|
"out",
|
|
46
46
|
"in"
|
|
47
47
|
],
|
|
48
|
-
"description": "between = swap two layers in one scene; out = leave a scene (ends hidden/covered); in = start a scene (from hidden/covered). Out then in cover a hard cut between two scenes."
|
|
48
|
+
"description": "between = swap two layers in one scene; out = leave a scene (ends hidden/covered); in = start a scene (from hidden/covered). Out then in cover a hard cut between two scenes. Across a cut use fade: false, or the frame dips to the background for about 0.3 s."
|
|
49
49
|
},
|
|
50
50
|
"zoom": {
|
|
51
51
|
"type": "number",
|
|
@@ -53,6 +53,11 @@
|
|
|
53
53
|
"min": 1.2,
|
|
54
54
|
"max": 5,
|
|
55
55
|
"description": "Final scale of the outgoing layer."
|
|
56
|
+
},
|
|
57
|
+
"fade": {
|
|
58
|
+
"type": "boolean",
|
|
59
|
+
"default": true,
|
|
60
|
+
"description": "Modes out and in only (between always fades). true: the outgoing layer fades as it zooms and the incoming fades in. false: the layer stays opaque, so `out` then `in` across a hard cut goes from the zoomed frame straight to the arriving one with no dip to the background (put a solid background behind the incoming layer)."
|
|
56
61
|
}
|
|
57
62
|
},
|
|
58
63
|
"timing": {
|
|
@@ -2,15 +2,16 @@
|
|
|
2
2
|
"use strict";
|
|
3
3
|
const T = { at: 0, duration: null, motion: null };
|
|
4
4
|
const E = P.EASE;
|
|
5
|
-
// `from` zooms toward the viewer and fades (launch), `to` arrives from slightly small (land).
|
|
6
|
-
|
|
5
|
+
// `from` zooms toward the viewer and fades (launch), `to` arrives from slightly small (land). `fade: false` keeps the
|
|
6
|
+
// layer opaque in modes out and in (between always fades): across a hard cut (out, then in) the frame goes zoomed -> arriving with no dip to the background.
|
|
7
|
+
P.define("zoom-through", Object.assign({}, T, { from: null, to: null, mode: "between", zoom: 2.2, fade: true }), (tl, target, v) => {
|
|
7
8
|
const p = P.plan(v, 0.8, { noExit: true, hold: 0 });
|
|
8
9
|
const A = v.from ? P.one(v.from, "zoom-through from") : null, B = v.to ? P.one(v.to, "zoom-through to") : null;
|
|
9
10
|
if (v.mode !== "in" && !A) throw new Error("E_PRIM_VAR zoom-through: mode " + v.mode + " needs 'from'");
|
|
10
11
|
if (v.mode !== "out" && !B) throw new Error("E_PRIM_VAR zoom-through: mode " + v.mode + " needs 'to'");
|
|
11
|
-
const half = P.q(p.dur * 0.6), late = P.q(p.dur * 0.4);
|
|
12
|
-
if (A && v.mode !== "in") { A.style.zIndex = 2; tl.fromTo(A, { scale: 1, opacity: 1 }, { scale: v.zoom, opacity:
|
|
13
|
-
if (B && v.mode !== "out") { B.style.zIndex = 1; tl.fromTo(B, { scale: 0.6, opacity:
|
|
12
|
+
const half = P.q(p.dur * 0.6), late = P.q(p.dur * 0.4), keep = v.fade === false && v.mode !== "between" ? 1 : 0;
|
|
13
|
+
if (A && v.mode !== "in") { A.style.zIndex = 2; tl.fromTo(A, { scale: 1, opacity: 1 }, { scale: v.zoom, opacity: keep, duration: half, ease: E.launch }, p.at); }
|
|
14
|
+
if (B && v.mode !== "out") { B.style.zIndex = 1; tl.fromTo(B, { scale: 0.6, opacity: keep }, { scale: 1, opacity: 1, duration: P.q(p.dur - late), ease: E.land }, v.mode === "in" ? p.at : P.q(p.at + late)); }
|
|
14
15
|
return p.result;
|
|
15
16
|
});
|
|
16
17
|
})(window.MosioPrims);
|
package/scripts/3d-acceptance.sh
CHANGED
|
@@ -19,7 +19,7 @@ ok() { PASS=$((PASS + 1)); RESULTS+=("PASS $1"); echo "PASS $1"; }
|
|
|
19
19
|
bad() { FAILN=$((FAILN + 1)); RESULTS+=("FAIL $1: $2"); echo "FAIL $1: $2"; }
|
|
20
20
|
jq_() { python3 -c "import json,sys; d=json.load(open(sys.argv[1])); print(eval(sys.argv[2]))" "$@"; }
|
|
21
21
|
want() { [ $# -eq 0 ] || [[ " $STEPS " == *" $1 "* ]]; }
|
|
22
|
-
STEPS="${*:-caps assets fault three-det seek inspect webgpu export3d blender-det bscene bscene-check resume sandbox symlink lifecycle cancel inspect-render hybrid alpha c07}"
|
|
22
|
+
STEPS="${*:-caps assets fault env-bake three-det seek inspect webgpu export3d blender-det bscene bscene-check resume sandbox symlink lifecycle cancel inspect-render hybrid alpha c07}"
|
|
23
23
|
|
|
24
24
|
# two blender runs (renders JSON from `mosio renders`) -> {file_hashes_equal, pixels_equal, frames: [...]}
|
|
25
25
|
bdet_cmp() {
|
|
@@ -61,6 +61,13 @@ if want fault; then
|
|
|
61
61
|
[[ "$c1" == *E_ASSET_MISSING* && "$c2" == *E_ASSET_MISSING* && "$c3" == E_ASSET_MISSING ]] && ok fault-missing-texture || bad fault-missing-texture "check=$c1 assets3d=$c2 render=$c3"
|
|
62
62
|
fi
|
|
63
63
|
|
|
64
|
+
if want env-bake; then
|
|
65
|
+
# the baked RoomEnvironment cube equals a fresh live computation byte for byte, and the baked path is the one taken
|
|
66
|
+
if [ -d "$REPO/node_modules/playwright-core" ]; then
|
|
67
|
+
if U "cd $REPO && node --conditions=source --experimental-transform-types --no-warnings scripts/3d-bake-room-env.mjs --verify" > "$EVID/env-bake.json" 2> "$EVID/env-bake.err"; then ok env-bake; else bad env-bake "baked room-env-pmrem.json differs from the live PMREM or is not used (re-bake: scripts/3d-bake-room-env.mjs)"; fi
|
|
68
|
+
else known env-bake "needs the root npm workspace (npm ci: playwright-core)"; fi
|
|
69
|
+
fi
|
|
70
|
+
|
|
64
71
|
if want three-det; then
|
|
65
72
|
for p in ${THREE_DET:-t1-turntable t3-clips t3-clip-tweak}; do
|
|
66
73
|
U "mosio frames $F/$p --frames all --order seq --out $EVID/$p-seq.json" > "$EVID/$p-seq.run.json"
|