oddlyalive 0.2.0-alpha.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +45 -0
- package/CONTRIBUTING.md +62 -0
- package/LICENSE +21 -0
- package/README.md +158 -0
- package/SECURITY.md +29 -0
- package/assets/photoreal/PROVENANCE.md +19 -0
- package/assets/photoreal/baseball.png +0 -0
- package/assets/photoreal/basketball.png +0 -0
- package/assets/photoreal/crystal.png +0 -0
- package/assets/photoreal/kicking-cleat.png +0 -0
- package/assets/photoreal/letter-charm-square.png +0 -0
- package/assets/photoreal/letter-charm.png +0 -0
- package/assets/photoreal/sneaker.png +0 -0
- package/assets/photoreal/soccer-ball.png +0 -0
- package/bin/oddlyalive.js +283 -0
- package/docs/ARCHITECTURE.md +55 -0
- package/docs/DEMO-VIDEOS.md +122 -0
- package/docs/QUICKSTART.md +115 -0
- package/docs/ROADMAP.md +33 -0
- package/examples/ball-lab/PROVENANCE.md +4 -0
- package/examples/ball-lab/app.js +33 -0
- package/examples/ball-lab/index.html +56 -0
- package/examples/ball-lab/scene.json +68 -0
- package/examples/crystal-mobile/PROVENANCE.md +4 -0
- package/examples/crystal-mobile/app.js +26 -0
- package/examples/crystal-mobile/index.html +56 -0
- package/examples/crystal-mobile/scene.json +69 -0
- package/examples/football-kick/PROVENANCE.md +4 -0
- package/examples/football-kick/app.js +33 -0
- package/examples/football-kick/index.html +56 -0
- package/examples/football-kick/scene.json +44 -0
- package/examples/gallery.css +379 -0
- package/examples/index.html +109 -0
- package/examples/shared/example.css +320 -0
- package/examples/shared/player.js +85 -0
- package/examples/shoe-splash/PROVENANCE.md +4 -0
- package/examples/shoe-splash/app.js +26 -0
- package/examples/shoe-splash/index.html +56 -0
- package/examples/shoe-splash/scene.json +38 -0
- package/examples/string-touch/PROVENANCE.md +11 -0
- package/examples/string-touch/app.js +79 -0
- package/examples/string-touch/index.html +70 -0
- package/examples/string-touch/scene.json +73 -0
- package/examples/string-touch/styles.css +273 -0
- package/package.json +82 -0
- package/schemas/scene.schema.json +336 -0
- package/scripts/render-demo-videos.sh +77 -0
- package/scripts/serve.js +88 -0
- package/scripts/update-visual-fixtures.mjs +60 -0
- package/scripts/verify-demo-videos.mjs +138 -0
- package/skills/oddlyalive/SKILL.md +68 -0
- package/skills/oddlyalive/agents/openai.yaml +4 -0
- package/skills/oddlyalive/references/object-models.md +25 -0
- package/skills/oddlyalive/references/recipes.md +27 -0
- package/skills/oddlyalive/references/scene-schema.md +84 -0
- package/src/crystal-renderer.js +338 -0
- package/src/gesture.js +58 -0
- package/src/index.js +44 -0
- package/src/rigid-balls.js +304 -0
- package/src/rigid-renderer.js +760 -0
- package/src/rigid-scene.js +223 -0
- package/src/scene-registry.js +17 -0
- package/src/scene.js +206 -0
- package/src/state-hash.js +17 -0
- package/src/strands.js +773 -0
- package/src/surface-wave.js +209 -0
- package/src/svg-renderer.js +348 -0
- package/src/wave-renderer.js +463 -0
- package/src/wave-scene.js +163 -0
- package/tests/cli.test.js +101 -0
- package/tests/determinism.test.js +57 -0
- package/tests/fixtures/visual-baselines.json +27 -0
- package/tests/rigid-balls.test.js +77 -0
- package/tests/scene.test.js +78 -0
- package/tests/surface-wave.test.js +39 -0
- package/tests/visual-fixtures.test.js +43 -0
- package/videos/oddlyalive-demos/BRIEF.md +40 -0
- package/videos/oddlyalive-demos/DEMO-PLAN.md +13 -0
- package/videos/oddlyalive-demos/README.md +45 -0
- package/videos/oddlyalive-demos/app.js +212 -0
- package/videos/oddlyalive-demos/hyperframes.json +9 -0
- package/videos/oddlyalive-demos/index.html +246 -0
- package/videos/oddlyalive-demos/meta.json +5 -0
- package/videos/oddlyalive-demos/package-lock.json +506 -0
- package/videos/oddlyalive-demos/package.json +19 -0
- package/videos/oddlyalive-demos/prepare-assets.mjs +16 -0
|
@@ -0,0 +1,336 @@
|
|
|
1
|
+
{
|
|
2
|
+
"$schema": "https://json-schema.org/draft/2020-12/schema",
|
|
3
|
+
"$id": "https://oddlyalive.dev/schemas/scene.schema.json",
|
|
4
|
+
"title": "OddlyAlive scene",
|
|
5
|
+
"oneOf": [
|
|
6
|
+
{ "$ref": "#/$defs/strandScene" },
|
|
7
|
+
{ "$ref": "#/$defs/rigidScene" },
|
|
8
|
+
{ "$ref": "#/$defs/waveScene" }
|
|
9
|
+
],
|
|
10
|
+
"$defs": {
|
|
11
|
+
"schemaProperty": { "type": "string" },
|
|
12
|
+
"version": { "const": 1 },
|
|
13
|
+
"name": { "type": "string", "minLength": 1 },
|
|
14
|
+
"seed": { "type": "number" },
|
|
15
|
+
"canvas": {
|
|
16
|
+
"type": "object",
|
|
17
|
+
"required": ["width", "height"],
|
|
18
|
+
"properties": {
|
|
19
|
+
"width": { "type": "number", "minimum": 64 },
|
|
20
|
+
"height": { "type": "number", "minimum": 64 }
|
|
21
|
+
},
|
|
22
|
+
"additionalProperties": false
|
|
23
|
+
},
|
|
24
|
+
"timing": {
|
|
25
|
+
"type": "object",
|
|
26
|
+
"required": ["duration", "fps", "substeps", "preRoll"],
|
|
27
|
+
"properties": {
|
|
28
|
+
"duration": { "type": "number", "minimum": 0.1, "maximum": 60 },
|
|
29
|
+
"fps": { "type": "integer", "minimum": 1, "maximum": 240 },
|
|
30
|
+
"substeps": { "type": "integer", "minimum": 1, "maximum": 16 },
|
|
31
|
+
"preRoll": { "type": "number", "minimum": 0, "maximum": 30 }
|
|
32
|
+
},
|
|
33
|
+
"additionalProperties": false
|
|
34
|
+
},
|
|
35
|
+
"strandScene": {
|
|
36
|
+
"type": "object",
|
|
37
|
+
"required": [
|
|
38
|
+
"version",
|
|
39
|
+
"type",
|
|
40
|
+
"seed",
|
|
41
|
+
"canvas",
|
|
42
|
+
"timing",
|
|
43
|
+
"field",
|
|
44
|
+
"material",
|
|
45
|
+
"contact",
|
|
46
|
+
"gesture",
|
|
47
|
+
"payload"
|
|
48
|
+
],
|
|
49
|
+
"properties": {
|
|
50
|
+
"$schema": { "$ref": "#/$defs/schemaProperty" },
|
|
51
|
+
"version": { "$ref": "#/$defs/version" },
|
|
52
|
+
"type": { "const": "strand-field" },
|
|
53
|
+
"name": { "$ref": "#/$defs/name" },
|
|
54
|
+
"seed": { "$ref": "#/$defs/seed" },
|
|
55
|
+
"canvas": { "$ref": "#/$defs/canvas" },
|
|
56
|
+
"timing": { "$ref": "#/$defs/timing" },
|
|
57
|
+
"field": {
|
|
58
|
+
"type": "object",
|
|
59
|
+
"required": [
|
|
60
|
+
"columns",
|
|
61
|
+
"rows",
|
|
62
|
+
"originX",
|
|
63
|
+
"originY",
|
|
64
|
+
"spacingX",
|
|
65
|
+
"spacingY"
|
|
66
|
+
],
|
|
67
|
+
"properties": {
|
|
68
|
+
"columns": { "type": "integer", "minimum": 1, "maximum": 128 },
|
|
69
|
+
"rows": { "type": "integer", "minimum": 3, "maximum": 128 },
|
|
70
|
+
"originX": { "type": "number" },
|
|
71
|
+
"originY": { "type": "number" },
|
|
72
|
+
"spacingX": { "type": "number", "exclusiveMinimum": 0 },
|
|
73
|
+
"spacingY": { "type": "number", "exclusiveMinimum": 0 }
|
|
74
|
+
},
|
|
75
|
+
"additionalProperties": false
|
|
76
|
+
},
|
|
77
|
+
"material": {
|
|
78
|
+
"type": "object",
|
|
79
|
+
"required": [
|
|
80
|
+
"gravity",
|
|
81
|
+
"linearDrag",
|
|
82
|
+
"quadraticDrag",
|
|
83
|
+
"lengthCompliance",
|
|
84
|
+
"compressionCompliance",
|
|
85
|
+
"bendCompliance",
|
|
86
|
+
"maxStretch"
|
|
87
|
+
],
|
|
88
|
+
"properties": {
|
|
89
|
+
"gravity": { "type": "number" },
|
|
90
|
+
"linearDrag": { "type": "number", "minimum": 0 },
|
|
91
|
+
"quadraticDrag": { "type": "number", "minimum": 0 },
|
|
92
|
+
"lengthCompliance": { "type": "number", "minimum": 0 },
|
|
93
|
+
"compressionCompliance": { "type": "number", "minimum": 0 },
|
|
94
|
+
"bendCompliance": { "type": "number", "minimum": 0 },
|
|
95
|
+
"maxStretch": { "type": "number", "minimum": 1, "maximum": 1.5 }
|
|
96
|
+
},
|
|
97
|
+
"additionalProperties": false
|
|
98
|
+
},
|
|
99
|
+
"contact": {
|
|
100
|
+
"type": "object",
|
|
101
|
+
"required": [
|
|
102
|
+
"radiusX",
|
|
103
|
+
"radiusY",
|
|
104
|
+
"maxStaticGrip",
|
|
105
|
+
"captureStartRow",
|
|
106
|
+
"captureEndRow"
|
|
107
|
+
],
|
|
108
|
+
"properties": {
|
|
109
|
+
"radiusX": { "type": "number", "exclusiveMinimum": 0 },
|
|
110
|
+
"radiusY": { "type": "number", "exclusiveMinimum": 0 },
|
|
111
|
+
"maxStaticGrip": { "type": "integer", "minimum": 1 },
|
|
112
|
+
"captureStartRow": { "type": "integer", "minimum": 0 },
|
|
113
|
+
"captureEndRow": { "type": "integer", "minimum": 0 }
|
|
114
|
+
},
|
|
115
|
+
"additionalProperties": false
|
|
116
|
+
},
|
|
117
|
+
"gesture": {
|
|
118
|
+
"type": "object",
|
|
119
|
+
"required": ["type", "points"],
|
|
120
|
+
"properties": {
|
|
121
|
+
"type": { "const": "touch-path" },
|
|
122
|
+
"points": {
|
|
123
|
+
"type": "array",
|
|
124
|
+
"minItems": 2,
|
|
125
|
+
"items": {
|
|
126
|
+
"type": "object",
|
|
127
|
+
"required": ["time", "x", "y", "pressure"],
|
|
128
|
+
"properties": {
|
|
129
|
+
"time": { "type": "number" },
|
|
130
|
+
"x": { "type": "number" },
|
|
131
|
+
"y": { "type": "number" },
|
|
132
|
+
"pressure": { "type": "number", "minimum": 0, "maximum": 1 }
|
|
133
|
+
},
|
|
134
|
+
"additionalProperties": false
|
|
135
|
+
}
|
|
136
|
+
}
|
|
137
|
+
},
|
|
138
|
+
"additionalProperties": false
|
|
139
|
+
},
|
|
140
|
+
"payload": {
|
|
141
|
+
"type": "object",
|
|
142
|
+
"required": ["text", "fontFamily", "fontSize"],
|
|
143
|
+
"properties": {
|
|
144
|
+
"text": { "type": "string", "minLength": 1 },
|
|
145
|
+
"fontFamily": { "type": "string", "minLength": 1 },
|
|
146
|
+
"fontSize": { "type": "number", "exclusiveMinimum": 0 },
|
|
147
|
+
"terminalMass": { "type": "number", "minimum": 0.1, "maximum": 50 }
|
|
148
|
+
},
|
|
149
|
+
"additionalProperties": false
|
|
150
|
+
},
|
|
151
|
+
"render": {
|
|
152
|
+
"type": "object",
|
|
153
|
+
"properties": {
|
|
154
|
+
"background": { "type": "string" },
|
|
155
|
+
"ink": { "type": "string" },
|
|
156
|
+
"accent": { "type": "string" },
|
|
157
|
+
"filament": { "type": "string" }
|
|
158
|
+
},
|
|
159
|
+
"additionalProperties": false
|
|
160
|
+
}
|
|
161
|
+
},
|
|
162
|
+
"additionalProperties": false
|
|
163
|
+
},
|
|
164
|
+
"rigidScene": {
|
|
165
|
+
"type": "object",
|
|
166
|
+
"required": [
|
|
167
|
+
"version",
|
|
168
|
+
"type",
|
|
169
|
+
"seed",
|
|
170
|
+
"canvas",
|
|
171
|
+
"timing",
|
|
172
|
+
"world",
|
|
173
|
+
"bodies",
|
|
174
|
+
"impulses"
|
|
175
|
+
],
|
|
176
|
+
"properties": {
|
|
177
|
+
"$schema": { "$ref": "#/$defs/schemaProperty" },
|
|
178
|
+
"version": { "$ref": "#/$defs/version" },
|
|
179
|
+
"type": { "const": "rigid-balls" },
|
|
180
|
+
"name": { "$ref": "#/$defs/name" },
|
|
181
|
+
"seed": { "$ref": "#/$defs/seed" },
|
|
182
|
+
"canvas": { "$ref": "#/$defs/canvas" },
|
|
183
|
+
"timing": { "$ref": "#/$defs/timing" },
|
|
184
|
+
"world": {
|
|
185
|
+
"type": "object",
|
|
186
|
+
"required": ["gravity", "airDrag", "floorY", "left", "right", "groundFriction"],
|
|
187
|
+
"properties": {
|
|
188
|
+
"gravity": { "type": "number" },
|
|
189
|
+
"airDrag": { "type": "number", "minimum": 0 },
|
|
190
|
+
"floorY": { "type": "number" },
|
|
191
|
+
"left": { "type": "number" },
|
|
192
|
+
"right": { "type": "number" },
|
|
193
|
+
"groundFriction": { "type": "number", "minimum": 0 }
|
|
194
|
+
},
|
|
195
|
+
"additionalProperties": false
|
|
196
|
+
},
|
|
197
|
+
"bodies": {
|
|
198
|
+
"type": "array",
|
|
199
|
+
"minItems": 1,
|
|
200
|
+
"maxItems": 64,
|
|
201
|
+
"items": {
|
|
202
|
+
"type": "object",
|
|
203
|
+
"required": [
|
|
204
|
+
"id",
|
|
205
|
+
"kind",
|
|
206
|
+
"x",
|
|
207
|
+
"y",
|
|
208
|
+
"radius",
|
|
209
|
+
"mass",
|
|
210
|
+
"restitution",
|
|
211
|
+
"friction",
|
|
212
|
+
"vx",
|
|
213
|
+
"vy",
|
|
214
|
+
"angle",
|
|
215
|
+
"angularVelocity",
|
|
216
|
+
"color"
|
|
217
|
+
],
|
|
218
|
+
"properties": {
|
|
219
|
+
"id": { "type": "string", "minLength": 1 },
|
|
220
|
+
"kind": { "type": "string", "minLength": 1 },
|
|
221
|
+
"label": { "type": "string" },
|
|
222
|
+
"x": { "type": "number" },
|
|
223
|
+
"y": { "type": "number" },
|
|
224
|
+
"radius": { "type": "number", "exclusiveMinimum": 0 },
|
|
225
|
+
"mass": { "type": "number", "exclusiveMinimum": 0 },
|
|
226
|
+
"restitution": { "type": "number", "minimum": 0, "maximum": 1 },
|
|
227
|
+
"friction": { "type": "number", "minimum": 0, "maximum": 1 },
|
|
228
|
+
"vx": { "type": "number" },
|
|
229
|
+
"vy": { "type": "number" },
|
|
230
|
+
"angle": { "type": "number" },
|
|
231
|
+
"angularVelocity": { "type": "number" },
|
|
232
|
+
"color": { "type": "string" }
|
|
233
|
+
},
|
|
234
|
+
"additionalProperties": false
|
|
235
|
+
}
|
|
236
|
+
},
|
|
237
|
+
"impulses": {
|
|
238
|
+
"type": "array",
|
|
239
|
+
"items": {
|
|
240
|
+
"type": "object",
|
|
241
|
+
"required": ["time", "body", "impulseX", "impulseY"],
|
|
242
|
+
"properties": {
|
|
243
|
+
"time": { "type": "number", "minimum": 0 },
|
|
244
|
+
"body": { "type": "string", "minLength": 1 },
|
|
245
|
+
"impulseX": { "type": "number" },
|
|
246
|
+
"impulseY": { "type": "number" },
|
|
247
|
+
"angularImpulse": { "type": "number" }
|
|
248
|
+
},
|
|
249
|
+
"additionalProperties": false
|
|
250
|
+
}
|
|
251
|
+
}
|
|
252
|
+
},
|
|
253
|
+
"additionalProperties": false
|
|
254
|
+
},
|
|
255
|
+
"waveScene": {
|
|
256
|
+
"type": "object",
|
|
257
|
+
"required": [
|
|
258
|
+
"version",
|
|
259
|
+
"type",
|
|
260
|
+
"seed",
|
|
261
|
+
"canvas",
|
|
262
|
+
"timing",
|
|
263
|
+
"surface",
|
|
264
|
+
"world",
|
|
265
|
+
"body"
|
|
266
|
+
],
|
|
267
|
+
"properties": {
|
|
268
|
+
"$schema": { "$ref": "#/$defs/schemaProperty" },
|
|
269
|
+
"version": { "$ref": "#/$defs/version" },
|
|
270
|
+
"type": { "const": "surface-wave" },
|
|
271
|
+
"name": { "$ref": "#/$defs/name" },
|
|
272
|
+
"seed": { "$ref": "#/$defs/seed" },
|
|
273
|
+
"canvas": { "$ref": "#/$defs/canvas" },
|
|
274
|
+
"timing": { "$ref": "#/$defs/timing" },
|
|
275
|
+
"surface": {
|
|
276
|
+
"type": "object",
|
|
277
|
+
"required": ["x", "width", "restY", "samples", "waveSpeed", "damping", "coupling"],
|
|
278
|
+
"properties": {
|
|
279
|
+
"x": { "type": "number" },
|
|
280
|
+
"width": { "type": "number", "exclusiveMinimum": 0 },
|
|
281
|
+
"restY": { "type": "number" },
|
|
282
|
+
"samples": { "type": "integer", "minimum": 16, "maximum": 1024 },
|
|
283
|
+
"waveSpeed": { "type": "number", "exclusiveMinimum": 0 },
|
|
284
|
+
"damping": { "type": "number", "minimum": 0 },
|
|
285
|
+
"coupling": { "type": "number", "minimum": 0 }
|
|
286
|
+
},
|
|
287
|
+
"additionalProperties": false
|
|
288
|
+
},
|
|
289
|
+
"world": {
|
|
290
|
+
"type": "object",
|
|
291
|
+
"required": ["gravity", "airDrag", "waterDrag", "buoyancy"],
|
|
292
|
+
"properties": {
|
|
293
|
+
"gravity": { "type": "number" },
|
|
294
|
+
"airDrag": { "type": "number", "minimum": 0 },
|
|
295
|
+
"waterDrag": { "type": "number", "minimum": 0 },
|
|
296
|
+
"buoyancy": { "type": "number", "minimum": 0 }
|
|
297
|
+
},
|
|
298
|
+
"additionalProperties": false
|
|
299
|
+
},
|
|
300
|
+
"body": {
|
|
301
|
+
"type": "object",
|
|
302
|
+
"required": [
|
|
303
|
+
"id",
|
|
304
|
+
"kind",
|
|
305
|
+
"x",
|
|
306
|
+
"y",
|
|
307
|
+
"width",
|
|
308
|
+
"height",
|
|
309
|
+
"mass",
|
|
310
|
+
"vx",
|
|
311
|
+
"vy",
|
|
312
|
+
"angle",
|
|
313
|
+
"angularVelocity",
|
|
314
|
+
"restitution"
|
|
315
|
+
],
|
|
316
|
+
"properties": {
|
|
317
|
+
"id": { "type": "string", "minLength": 1 },
|
|
318
|
+
"kind": { "type": "string", "minLength": 1 },
|
|
319
|
+
"x": { "type": "number" },
|
|
320
|
+
"y": { "type": "number" },
|
|
321
|
+
"width": { "type": "number", "exclusiveMinimum": 0 },
|
|
322
|
+
"height": { "type": "number", "exclusiveMinimum": 0 },
|
|
323
|
+
"mass": { "type": "number", "exclusiveMinimum": 0 },
|
|
324
|
+
"vx": { "type": "number" },
|
|
325
|
+
"vy": { "type": "number" },
|
|
326
|
+
"angle": { "type": "number" },
|
|
327
|
+
"angularVelocity": { "type": "number" },
|
|
328
|
+
"restitution": { "type": "number", "minimum": 0, "maximum": 1 }
|
|
329
|
+
},
|
|
330
|
+
"additionalProperties": false
|
|
331
|
+
}
|
|
332
|
+
},
|
|
333
|
+
"additionalProperties": false
|
|
334
|
+
}
|
|
335
|
+
}
|
|
336
|
+
}
|
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
#!/bin/sh
|
|
2
|
+
|
|
3
|
+
set -eu
|
|
4
|
+
|
|
5
|
+
ROOT_DIR=$(CDPATH= cd -- "$(dirname "$0")/.." && pwd)
|
|
6
|
+
PROJECT_DIR="$ROOT_DIR/videos/oddlyalive-demos"
|
|
7
|
+
MASTER="$PROJECT_DIR/renders/oddlyalive-demos-overview.mp4"
|
|
8
|
+
CLIPS_DIR="$PROJECT_DIR/renders/demos"
|
|
9
|
+
WORKERS="${HF_WORKERS:-2}"
|
|
10
|
+
|
|
11
|
+
command -v node >/dev/null 2>&1 || {
|
|
12
|
+
echo "Node.js 20+ is required." >&2
|
|
13
|
+
exit 1
|
|
14
|
+
}
|
|
15
|
+
command -v npm >/dev/null 2>&1 || {
|
|
16
|
+
echo "npm is required." >&2
|
|
17
|
+
exit 1
|
|
18
|
+
}
|
|
19
|
+
command -v ffmpeg >/dev/null 2>&1 || {
|
|
20
|
+
echo "FFmpeg is required." >&2
|
|
21
|
+
exit 1
|
|
22
|
+
}
|
|
23
|
+
command -v ffprobe >/dev/null 2>&1 || {
|
|
24
|
+
echo "ffprobe is required." >&2
|
|
25
|
+
exit 1
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
cd "$PROJECT_DIR"
|
|
29
|
+
npm ci
|
|
30
|
+
npm run build:bundle
|
|
31
|
+
npx --yes hyperframes@0.7.66 check
|
|
32
|
+
mkdir -p "$CLIPS_DIR"
|
|
33
|
+
npx --yes hyperframes@0.7.66 render \
|
|
34
|
+
-o "$MASTER" \
|
|
35
|
+
--fps 60 \
|
|
36
|
+
--quality high \
|
|
37
|
+
--workers "$WORKERS" \
|
|
38
|
+
--skill general-video \
|
|
39
|
+
--strict
|
|
40
|
+
|
|
41
|
+
cut_clip() {
|
|
42
|
+
start="$1"
|
|
43
|
+
output="$2"
|
|
44
|
+
ffmpeg -hide_banner -loglevel error -y \
|
|
45
|
+
-ss "$start" \
|
|
46
|
+
-i "$MASTER" \
|
|
47
|
+
-t 6.4 \
|
|
48
|
+
-an \
|
|
49
|
+
-c:v libx264 \
|
|
50
|
+
-preset slow \
|
|
51
|
+
-crf 18 \
|
|
52
|
+
-pix_fmt yuv420p \
|
|
53
|
+
-profile:v high \
|
|
54
|
+
-movflags +faststart \
|
|
55
|
+
"$CLIPS_DIR/$output"
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
cut_clip 0 "01-string-touch.mp4"
|
|
59
|
+
cut_clip 6.4 "02-crystal-mobile.mp4"
|
|
60
|
+
cut_clip 12.8 "03-ball-lab.mp4"
|
|
61
|
+
cut_clip 19.2 "04-football-kick.mp4"
|
|
62
|
+
cut_clip 25.6 "05-shoe-splash.mp4"
|
|
63
|
+
|
|
64
|
+
mkdir -p "$ROOT_DIR/docs/assets"
|
|
65
|
+
ffmpeg -hide_banner -loglevel error -y \
|
|
66
|
+
-i "$CLIPS_DIR/01-string-touch.mp4" \
|
|
67
|
+
-filter_complex \
|
|
68
|
+
"[0:v]fps=12,scale=720:-1:flags=lanczos,split[s0][s1];[s0]palettegen=max_colors=96[p];[s1][p]paletteuse=dither=sierra2_4a" \
|
|
69
|
+
-loop 0 \
|
|
70
|
+
"$ROOT_DIR/docs/assets/oddlyalive-string-touch.gif"
|
|
71
|
+
|
|
72
|
+
cd "$ROOT_DIR"
|
|
73
|
+
npm run demos:verify
|
|
74
|
+
|
|
75
|
+
echo
|
|
76
|
+
echo "Demo package is ready for local review."
|
|
77
|
+
echo "No Git, GitHub, release, or npm state was changed."
|
package/scripts/serve.js
ADDED
|
@@ -0,0 +1,88 @@
|
|
|
1
|
+
import { createReadStream, existsSync, statSync } from "node:fs";
|
|
2
|
+
import { createServer } from "node:http";
|
|
3
|
+
import { extname, join, normalize, resolve } from "node:path";
|
|
4
|
+
import { fileURLToPath } from "node:url";
|
|
5
|
+
import { spawn } from "node:child_process";
|
|
6
|
+
|
|
7
|
+
const MIME_TYPES = {
|
|
8
|
+
".css": "text/css; charset=utf-8",
|
|
9
|
+
".html": "text/html; charset=utf-8",
|
|
10
|
+
".gif": "image/gif",
|
|
11
|
+
".js": "text/javascript; charset=utf-8",
|
|
12
|
+
".json": "application/json; charset=utf-8",
|
|
13
|
+
".png": "image/png",
|
|
14
|
+
".webp": "image/webp",
|
|
15
|
+
".svg": "image/svg+xml"
|
|
16
|
+
};
|
|
17
|
+
|
|
18
|
+
function openBrowser(url) {
|
|
19
|
+
const command =
|
|
20
|
+
process.platform === "darwin"
|
|
21
|
+
? ["open", [url]]
|
|
22
|
+
: process.platform === "win32"
|
|
23
|
+
? ["cmd", ["/c", "start", "", url]]
|
|
24
|
+
: ["xdg-open", [url]];
|
|
25
|
+
const child = spawn(command[0], command[1], {
|
|
26
|
+
detached: true,
|
|
27
|
+
stdio: "ignore"
|
|
28
|
+
});
|
|
29
|
+
child.unref();
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
export function startServer({
|
|
33
|
+
root = process.cwd(),
|
|
34
|
+
port = 4173,
|
|
35
|
+
pathname = "/examples/string-touch/",
|
|
36
|
+
shouldOpen = true
|
|
37
|
+
} = {}) {
|
|
38
|
+
const absoluteRoot = resolve(root);
|
|
39
|
+
const server = createServer((request, response) => {
|
|
40
|
+
const requestUrl = new URL(request.url ?? "/", "http://localhost");
|
|
41
|
+
const decodedPath = decodeURIComponent(requestUrl.pathname);
|
|
42
|
+
let safePath = normalize(decodedPath).replace(/^(\.\.[/\\])+/, "");
|
|
43
|
+
if (safePath.endsWith("/")) safePath += "index.html";
|
|
44
|
+
const filePath = join(absoluteRoot, safePath);
|
|
45
|
+
|
|
46
|
+
if (
|
|
47
|
+
!filePath.startsWith(absoluteRoot) ||
|
|
48
|
+
!existsSync(filePath) ||
|
|
49
|
+
!statSync(filePath).isFile()
|
|
50
|
+
) {
|
|
51
|
+
response.writeHead(404, { "content-type": "text/plain; charset=utf-8" });
|
|
52
|
+
response.end("Not found");
|
|
53
|
+
return;
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
response.writeHead(200, {
|
|
57
|
+
"cache-control": "no-store",
|
|
58
|
+
"content-type":
|
|
59
|
+
MIME_TYPES[extname(filePath)] ?? "application/octet-stream"
|
|
60
|
+
});
|
|
61
|
+
createReadStream(filePath).pipe(response);
|
|
62
|
+
});
|
|
63
|
+
|
|
64
|
+
return new Promise((resolvePromise, reject) => {
|
|
65
|
+
server.once("error", reject);
|
|
66
|
+
server.listen(port, "127.0.0.1", () => {
|
|
67
|
+
const url = `http://127.0.0.1:${port}${pathname}`;
|
|
68
|
+
console.log(`OddlyAlive is playing at ${url}`);
|
|
69
|
+
if (shouldOpen) openBrowser(url);
|
|
70
|
+
resolvePromise({ server, url });
|
|
71
|
+
});
|
|
72
|
+
});
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
const isDirect =
|
|
76
|
+
process.argv[1] &&
|
|
77
|
+
resolve(process.argv[1]) === resolve(fileURLToPath(import.meta.url));
|
|
78
|
+
|
|
79
|
+
if (isDirect) {
|
|
80
|
+
const portIndex = process.argv.indexOf("--port");
|
|
81
|
+
const pathIndex = process.argv.indexOf("--path");
|
|
82
|
+
await startServer({
|
|
83
|
+
port: portIndex === -1 ? 4173 : Number(process.argv[portIndex + 1]),
|
|
84
|
+
pathname:
|
|
85
|
+
pathIndex === -1 ? "/examples/string-touch/" : process.argv[pathIndex + 1],
|
|
86
|
+
shouldOpen: !process.argv.includes("--no-open")
|
|
87
|
+
});
|
|
88
|
+
}
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
import { createHash } from "node:crypto";
|
|
2
|
+
import { readFile, writeFile } from "node:fs/promises";
|
|
3
|
+
import { dirname, resolve } from "node:path";
|
|
4
|
+
import { fileURLToPath } from "node:url";
|
|
5
|
+
|
|
6
|
+
import { simulateScene, validateScene } from "../src/index.js";
|
|
7
|
+
|
|
8
|
+
const root = resolve(dirname(fileURLToPath(import.meta.url)), "..");
|
|
9
|
+
const sceneNames = [
|
|
10
|
+
"string-touch",
|
|
11
|
+
"crystal-mobile",
|
|
12
|
+
"ball-lab",
|
|
13
|
+
"football-kick",
|
|
14
|
+
"shoe-splash"
|
|
15
|
+
];
|
|
16
|
+
const visualFiles = [
|
|
17
|
+
"assets/photoreal/baseball.png",
|
|
18
|
+
"assets/photoreal/basketball.png",
|
|
19
|
+
"assets/photoreal/crystal.png",
|
|
20
|
+
"assets/photoreal/kicking-cleat.png",
|
|
21
|
+
"assets/photoreal/letter-charm-square.png",
|
|
22
|
+
"assets/photoreal/letter-charm.png",
|
|
23
|
+
"assets/photoreal/sneaker.png",
|
|
24
|
+
"assets/photoreal/soccer-ball.png",
|
|
25
|
+
"src/crystal-renderer.js",
|
|
26
|
+
"src/rigid-renderer.js",
|
|
27
|
+
"src/svg-renderer.js",
|
|
28
|
+
"src/wave-renderer.js",
|
|
29
|
+
"videos/oddlyalive-demos/app.js",
|
|
30
|
+
"videos/oddlyalive-demos/index.html"
|
|
31
|
+
];
|
|
32
|
+
|
|
33
|
+
const sceneFingerprints = {};
|
|
34
|
+
for (const name of sceneNames) {
|
|
35
|
+
const scene = validateScene(
|
|
36
|
+
JSON.parse(await readFile(resolve(root, `examples/${name}/scene.json`), "utf8"))
|
|
37
|
+
);
|
|
38
|
+
sceneFingerprints[name] = simulateScene(scene, {
|
|
39
|
+
includeFrames: false
|
|
40
|
+
}).fingerprint;
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
const fileSha256 = {};
|
|
44
|
+
for (const path of visualFiles) {
|
|
45
|
+
fileSha256[path] = createHash("sha256")
|
|
46
|
+
.update(await readFile(resolve(root, path)))
|
|
47
|
+
.digest("hex");
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
const output = {
|
|
51
|
+
version: 1,
|
|
52
|
+
description:
|
|
53
|
+
"Approved deterministic motion and visual-source baselines. Update only after visual review.",
|
|
54
|
+
sceneFingerprints,
|
|
55
|
+
fileSha256
|
|
56
|
+
};
|
|
57
|
+
|
|
58
|
+
const outputPath = resolve(root, "tests/fixtures/visual-baselines.json");
|
|
59
|
+
await writeFile(outputPath, `${JSON.stringify(output, null, 2)}\n`);
|
|
60
|
+
console.log(`Updated ${outputPath}`);
|