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,760 @@
|
|
|
1
|
+
const SVG_NS = "http://www.w3.org/2000/svg";
|
|
2
|
+
|
|
3
|
+
function svgNode(name, attributes = {}) {
|
|
4
|
+
const node = document.createElementNS(SVG_NS, name);
|
|
5
|
+
for (const [key, value] of Object.entries(attributes)) {
|
|
6
|
+
node.setAttribute(key, String(value));
|
|
7
|
+
}
|
|
8
|
+
return node;
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
function clamp(value, minimum, maximum) {
|
|
12
|
+
return Math.max(minimum, Math.min(maximum, value));
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
function smoothStep(value) {
|
|
16
|
+
const t = clamp(value, 0, 1);
|
|
17
|
+
return t * t * (3 - 2 * t);
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
function polygonPoints(radius, sides, rotation = -Math.PI / 2) {
|
|
21
|
+
const points = [];
|
|
22
|
+
for (let index = 0; index < sides; index += 1) {
|
|
23
|
+
const angle = rotation + (index / sides) * Math.PI * 2;
|
|
24
|
+
points.push(
|
|
25
|
+
`${(Math.cos(angle) * radius).toFixed(2)},${(Math.sin(angle) * radius).toFixed(2)}`
|
|
26
|
+
);
|
|
27
|
+
}
|
|
28
|
+
return points.join(" ");
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
function addRadialGradient(defs, id, stops) {
|
|
32
|
+
const gradient = svgNode("radialGradient", {
|
|
33
|
+
id,
|
|
34
|
+
cx: "31%",
|
|
35
|
+
cy: "24%",
|
|
36
|
+
r: "76%"
|
|
37
|
+
});
|
|
38
|
+
for (const stop of stops) gradient.appendChild(svgNode("stop", stop));
|
|
39
|
+
defs.appendChild(gradient);
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
function createBallShell(body, defs, idBase, stops) {
|
|
43
|
+
const group = svgNode("g", {
|
|
44
|
+
class: `oa-ball oa-ball-${body.kind}`,
|
|
45
|
+
"data-body-id": body.id
|
|
46
|
+
});
|
|
47
|
+
const clipId = `${idBase}-clip`;
|
|
48
|
+
const fillId = `${idBase}-fill`;
|
|
49
|
+
const clip = svgNode("clipPath", { id: clipId });
|
|
50
|
+
clip.appendChild(svgNode("circle", { r: body.radius }));
|
|
51
|
+
defs.appendChild(clip);
|
|
52
|
+
addRadialGradient(defs, fillId, stops);
|
|
53
|
+
|
|
54
|
+
group.appendChild(
|
|
55
|
+
svgNode("circle", {
|
|
56
|
+
r: body.radius,
|
|
57
|
+
fill: `url(#${fillId})`
|
|
58
|
+
})
|
|
59
|
+
);
|
|
60
|
+
const details = svgNode("g", {
|
|
61
|
+
class: "oa-ball-surface",
|
|
62
|
+
"clip-path": `url(#${clipId})`
|
|
63
|
+
});
|
|
64
|
+
group.appendChild(details);
|
|
65
|
+
return { group, details };
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
function finishBall(group, body) {
|
|
69
|
+
group.append(
|
|
70
|
+
svgNode("circle", {
|
|
71
|
+
r: body.radius,
|
|
72
|
+
fill: "none",
|
|
73
|
+
stroke: "#20201d",
|
|
74
|
+
"stroke-width": Math.max(1.8, body.radius * 0.05)
|
|
75
|
+
}),
|
|
76
|
+
svgNode("ellipse", {
|
|
77
|
+
cx: -body.radius * 0.27,
|
|
78
|
+
cy: -body.radius * 0.35,
|
|
79
|
+
rx: body.radius * 0.22,
|
|
80
|
+
ry: body.radius * 0.11,
|
|
81
|
+
transform: "rotate(-28)",
|
|
82
|
+
fill: "rgba(255,255,255,0.28)"
|
|
83
|
+
}),
|
|
84
|
+
svgNode("path", {
|
|
85
|
+
d: `M ${body.radius * 0.55} ${body.radius * 0.22} Q ${body.radius * 0.48} ${body.radius * 0.58} ${body.radius * 0.18} ${body.radius * 0.72}`,
|
|
86
|
+
fill: "none",
|
|
87
|
+
stroke: "rgba(28,25,21,0.16)",
|
|
88
|
+
"stroke-width": Math.max(1, body.radius * 0.045),
|
|
89
|
+
"stroke-linecap": "round"
|
|
90
|
+
})
|
|
91
|
+
);
|
|
92
|
+
return group;
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
function createBaseball(body, defs, idBase) {
|
|
96
|
+
const { group, details } = createBallShell(body, defs, idBase, [
|
|
97
|
+
{ offset: "0%", "stop-color": "#fffdf5" },
|
|
98
|
+
{ offset: "58%", "stop-color": "#eee7d8" },
|
|
99
|
+
{ offset: "100%", "stop-color": "#c4b7a2" }
|
|
100
|
+
]);
|
|
101
|
+
const r = body.radius;
|
|
102
|
+
|
|
103
|
+
for (let index = 0; index < 24; index += 1) {
|
|
104
|
+
const angle = index * 2.399963;
|
|
105
|
+
const distance = r * (0.16 + ((index * 37) % 71) / 100);
|
|
106
|
+
details.appendChild(
|
|
107
|
+
svgNode("circle", {
|
|
108
|
+
cx: (Math.cos(angle) * distance).toFixed(2),
|
|
109
|
+
cy: (Math.sin(angle) * distance).toFixed(2),
|
|
110
|
+
r: index % 4 === 0 ? 0.8 : 0.5,
|
|
111
|
+
fill: index % 5 === 0 ? "#a59378" : "#6b6254",
|
|
112
|
+
opacity: index % 4 === 0 ? "0.16" : "0.08"
|
|
113
|
+
})
|
|
114
|
+
);
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
const leftSeam = `M ${-r * 0.58} ${-r * 0.92} C ${-r * 0.16} ${-r * 0.54} ${-r * 0.16} ${r * 0.54} ${-r * 0.58} ${r * 0.92}`;
|
|
118
|
+
const rightSeam = `M ${r * 0.58} ${-r * 0.92} C ${r * 0.16} ${-r * 0.54} ${r * 0.16} ${r * 0.54} ${r * 0.58} ${r * 0.92}`;
|
|
119
|
+
details.append(
|
|
120
|
+
svgNode("path", {
|
|
121
|
+
d: leftSeam,
|
|
122
|
+
fill: "none",
|
|
123
|
+
stroke: "#c63f35",
|
|
124
|
+
"stroke-width": "1.45"
|
|
125
|
+
}),
|
|
126
|
+
svgNode("path", {
|
|
127
|
+
d: rightSeam,
|
|
128
|
+
fill: "none",
|
|
129
|
+
stroke: "#c63f35",
|
|
130
|
+
"stroke-width": "1.45"
|
|
131
|
+
})
|
|
132
|
+
);
|
|
133
|
+
|
|
134
|
+
for (const side of [-1, 1]) {
|
|
135
|
+
for (let index = 0; index < 9; index += 1) {
|
|
136
|
+
const normalizedY = -0.72 + index * 0.18;
|
|
137
|
+
const y = normalizedY * r;
|
|
138
|
+
const x = side * r * (0.27 + Math.abs(normalizedY) * 0.23);
|
|
139
|
+
const slant = side * (index < 4 ? -1 : 1);
|
|
140
|
+
details.appendChild(
|
|
141
|
+
svgNode("path", {
|
|
142
|
+
d: `M ${(x - side * r * 0.09).toFixed(2)} ${(y - slant * r * 0.055).toFixed(2)} L ${(x + side * r * 0.075).toFixed(2)} ${(y + slant * r * 0.055).toFixed(2)}`,
|
|
143
|
+
stroke: "#d64a3e",
|
|
144
|
+
"stroke-width": "1.5",
|
|
145
|
+
"stroke-linecap": "round"
|
|
146
|
+
})
|
|
147
|
+
);
|
|
148
|
+
}
|
|
149
|
+
}
|
|
150
|
+
|
|
151
|
+
details.appendChild(
|
|
152
|
+
svgNode("path", {
|
|
153
|
+
d: `M ${-r * 0.12} ${r * 0.42} q ${r * 0.2} ${r * 0.06} ${r * 0.31} ${-r * 0.04}`,
|
|
154
|
+
stroke: "rgba(92,76,56,0.18)",
|
|
155
|
+
"stroke-width": "1.2",
|
|
156
|
+
fill: "none"
|
|
157
|
+
})
|
|
158
|
+
);
|
|
159
|
+
return finishBall(group, body);
|
|
160
|
+
}
|
|
161
|
+
|
|
162
|
+
function createBasketball(body, defs, idBase) {
|
|
163
|
+
const { group, details } = createBallShell(body, defs, idBase, [
|
|
164
|
+
{ offset: "0%", "stop-color": "#ff9a52" },
|
|
165
|
+
{ offset: "48%", "stop-color": "#e66b2d" },
|
|
166
|
+
{ offset: "100%", "stop-color": "#9d3519" }
|
|
167
|
+
]);
|
|
168
|
+
const r = body.radius;
|
|
169
|
+
const dotSpacing = Math.max(4.6, r * 0.105);
|
|
170
|
+
for (let y = -r; y <= r; y += dotSpacing) {
|
|
171
|
+
for (let x = -r; x <= r; x += dotSpacing) {
|
|
172
|
+
const offsetX = (Math.round(y / dotSpacing) % 2) * dotSpacing * 0.48;
|
|
173
|
+
details.appendChild(
|
|
174
|
+
svgNode("circle", {
|
|
175
|
+
cx: (x + offsetX).toFixed(2),
|
|
176
|
+
cy: y.toFixed(2),
|
|
177
|
+
r: Math.max(0.48, r * 0.012),
|
|
178
|
+
fill: "#4d2115",
|
|
179
|
+
opacity: "0.28"
|
|
180
|
+
})
|
|
181
|
+
);
|
|
182
|
+
}
|
|
183
|
+
}
|
|
184
|
+
const seams = [
|
|
185
|
+
`M ${-r} 0 H ${r}`,
|
|
186
|
+
`M 0 ${-r} V ${r}`,
|
|
187
|
+
`M ${-r * 0.83} ${-r * 0.64} C ${-r * 0.24} ${-r * 0.3} ${-r * 0.24} ${r * 0.3} ${-r * 0.83} ${r * 0.64}`,
|
|
188
|
+
`M ${r * 0.83} ${-r * 0.64} C ${r * 0.24} ${-r * 0.3} ${r * 0.24} ${r * 0.3} ${r * 0.83} ${r * 0.64}`
|
|
189
|
+
];
|
|
190
|
+
for (const d of seams) {
|
|
191
|
+
details.append(
|
|
192
|
+
svgNode("path", {
|
|
193
|
+
d,
|
|
194
|
+
fill: "none",
|
|
195
|
+
stroke: "#221d19",
|
|
196
|
+
"stroke-width": Math.max(2.2, r * 0.065),
|
|
197
|
+
"stroke-linecap": "round"
|
|
198
|
+
}),
|
|
199
|
+
svgNode("path", {
|
|
200
|
+
d,
|
|
201
|
+
fill: "none",
|
|
202
|
+
stroke: "rgba(255,165,95,0.22)",
|
|
203
|
+
"stroke-width": Math.max(0.55, r * 0.014),
|
|
204
|
+
transform: "translate(-0.7 -0.7)"
|
|
205
|
+
})
|
|
206
|
+
);
|
|
207
|
+
}
|
|
208
|
+
details.append(
|
|
209
|
+
svgNode("circle", {
|
|
210
|
+
cx: r * 0.23,
|
|
211
|
+
cy: r * 0.2,
|
|
212
|
+
r: r * 0.035,
|
|
213
|
+
fill: "#1f1b18"
|
|
214
|
+
}),
|
|
215
|
+
svgNode("circle", {
|
|
216
|
+
cx: r * 0.23,
|
|
217
|
+
cy: r * 0.2,
|
|
218
|
+
r: r * 0.014,
|
|
219
|
+
fill: "#9b5d3c"
|
|
220
|
+
})
|
|
221
|
+
);
|
|
222
|
+
return finishBall(group, body);
|
|
223
|
+
}
|
|
224
|
+
|
|
225
|
+
function createFootball(body, defs, idBase) {
|
|
226
|
+
const { group, details } = createBallShell(body, defs, idBase, [
|
|
227
|
+
{ offset: "0%", "stop-color": "#fffef7" },
|
|
228
|
+
{ offset: "63%", "stop-color": "#eeeade" },
|
|
229
|
+
{ offset: "100%", "stop-color": "#a9a89f" }
|
|
230
|
+
]);
|
|
231
|
+
const r = body.radius;
|
|
232
|
+
const centralRadius = r * 0.265;
|
|
233
|
+
const outerRadius = r * 0.175;
|
|
234
|
+
|
|
235
|
+
details.append(
|
|
236
|
+
svgNode("polygon", {
|
|
237
|
+
points: polygonPoints(centralRadius, 5, -Math.PI / 2),
|
|
238
|
+
fill: "#171816",
|
|
239
|
+
stroke: "#090a09",
|
|
240
|
+
"stroke-width": "0.8"
|
|
241
|
+
})
|
|
242
|
+
);
|
|
243
|
+
for (let index = 0; index < 5; index += 1) {
|
|
244
|
+
const angle = -Math.PI / 2 + (index / 5) * Math.PI * 2;
|
|
245
|
+
const x = Math.cos(angle) * r * 0.69;
|
|
246
|
+
const y = Math.sin(angle) * r * 0.69;
|
|
247
|
+
const innerX = Math.cos(angle) * centralRadius;
|
|
248
|
+
const innerY = Math.sin(angle) * centralRadius;
|
|
249
|
+
details.append(
|
|
250
|
+
svgNode("polygon", {
|
|
251
|
+
points: polygonPoints(outerRadius, 5, angle + Math.PI),
|
|
252
|
+
transform: `translate(${x.toFixed(2)} ${y.toFixed(2)})`,
|
|
253
|
+
fill: "#1b1c19",
|
|
254
|
+
stroke: "#090a09",
|
|
255
|
+
"stroke-width": "0.65"
|
|
256
|
+
}),
|
|
257
|
+
svgNode("path", {
|
|
258
|
+
d: `M ${innerX.toFixed(2)} ${innerY.toFixed(2)} L ${(x - Math.cos(angle) * outerRadius).toFixed(2)} ${(y - Math.sin(angle) * outerRadius).toFixed(2)}`,
|
|
259
|
+
stroke: "#62615b",
|
|
260
|
+
"stroke-width": "1.05",
|
|
261
|
+
fill: "none"
|
|
262
|
+
})
|
|
263
|
+
);
|
|
264
|
+
const nextAngle = -Math.PI / 2 + ((index + 1) / 5) * Math.PI * 2;
|
|
265
|
+
const midAngle = (angle + nextAngle) * 0.5;
|
|
266
|
+
details.appendChild(
|
|
267
|
+
svgNode("path", {
|
|
268
|
+
d: `M ${(Math.cos(angle + 0.46) * centralRadius).toFixed(2)} ${(Math.sin(angle + 0.46) * centralRadius).toFixed(2)} Q ${(Math.cos(midAngle) * r * 0.55).toFixed(2)} ${(Math.sin(midAngle) * r * 0.55).toFixed(2)} ${(Math.cos(nextAngle - 0.46) * centralRadius).toFixed(2)} ${(Math.sin(nextAngle - 0.46) * centralRadius).toFixed(2)}`,
|
|
269
|
+
fill: "none",
|
|
270
|
+
stroke: "#77766f",
|
|
271
|
+
"stroke-width": "0.8"
|
|
272
|
+
})
|
|
273
|
+
);
|
|
274
|
+
}
|
|
275
|
+
details.append(
|
|
276
|
+
svgNode("path", {
|
|
277
|
+
d: `M ${-r * 0.76} ${r * 0.35} q ${r * 0.16} ${r * 0.09} ${r * 0.3} ${r * 0.02}`,
|
|
278
|
+
stroke: "rgba(86,72,53,0.25)",
|
|
279
|
+
"stroke-width": "1.3",
|
|
280
|
+
fill: "none"
|
|
281
|
+
}),
|
|
282
|
+
svgNode("path", {
|
|
283
|
+
d: `M ${r * 0.24} ${-r * 0.79} q ${r * 0.12} ${r * 0.08} ${r * 0.23} ${r * 0.02}`,
|
|
284
|
+
stroke: "rgba(86,72,53,0.18)",
|
|
285
|
+
"stroke-width": "1.1",
|
|
286
|
+
fill: "none"
|
|
287
|
+
})
|
|
288
|
+
);
|
|
289
|
+
return finishBall(group, body);
|
|
290
|
+
}
|
|
291
|
+
|
|
292
|
+
function createGenericBall(body, defs, idBase) {
|
|
293
|
+
const { group } = createBallShell(body, defs, idBase, [
|
|
294
|
+
{ offset: "0%", "stop-color": "#ffffff" },
|
|
295
|
+
{ offset: "55%", "stop-color": body.color },
|
|
296
|
+
{ offset: "100%", "stop-color": "#55534c" }
|
|
297
|
+
]);
|
|
298
|
+
return finishBall(group, body);
|
|
299
|
+
}
|
|
300
|
+
|
|
301
|
+
function createPhotoBall(body, href) {
|
|
302
|
+
const scaleByKind = {
|
|
303
|
+
baseball: 2.78,
|
|
304
|
+
basketball: 2.45,
|
|
305
|
+
football: 2.46
|
|
306
|
+
};
|
|
307
|
+
const size = body.radius * (scaleByKind[body.kind] ?? 2.5);
|
|
308
|
+
const group = svgNode("g", {
|
|
309
|
+
class: `oa-ball oa-ball-${body.kind} oa-ball-photo`,
|
|
310
|
+
"data-body-id": body.id
|
|
311
|
+
});
|
|
312
|
+
group.appendChild(
|
|
313
|
+
svgNode("image", {
|
|
314
|
+
href,
|
|
315
|
+
x: (-size * 0.5).toFixed(2),
|
|
316
|
+
y: (-size * 0.5).toFixed(2),
|
|
317
|
+
width: size.toFixed(2),
|
|
318
|
+
height: size.toFixed(2),
|
|
319
|
+
preserveAspectRatio: "xMidYMid meet",
|
|
320
|
+
decoding: "sync"
|
|
321
|
+
})
|
|
322
|
+
);
|
|
323
|
+
return group;
|
|
324
|
+
}
|
|
325
|
+
|
|
326
|
+
function createBall(body, defs, idBase, photoHref) {
|
|
327
|
+
if (photoHref) return createPhotoBall(body, photoHref);
|
|
328
|
+
if (body.kind === "baseball") return createBaseball(body, defs, idBase);
|
|
329
|
+
if (body.kind === "basketball") return createBasketball(body, defs, idBase);
|
|
330
|
+
if (body.kind === "football") return createFootball(body, defs, idBase);
|
|
331
|
+
return createGenericBall(body, defs, idBase);
|
|
332
|
+
}
|
|
333
|
+
|
|
334
|
+
function createLabBackground(scene) {
|
|
335
|
+
const background = svgNode("g", { class: "oa-lab-background" });
|
|
336
|
+
background.append(
|
|
337
|
+
svgNode("rect", {
|
|
338
|
+
x: scene.world.left,
|
|
339
|
+
y: scene.world.floorY + 1,
|
|
340
|
+
width: scene.world.right - scene.world.left,
|
|
341
|
+
height: scene.canvas.height - scene.world.floorY,
|
|
342
|
+
fill: "#d8c39b",
|
|
343
|
+
opacity: "0.52"
|
|
344
|
+
}),
|
|
345
|
+
svgNode("path", {
|
|
346
|
+
d: `M ${scene.world.left} ${scene.world.floorY} H ${scene.world.right}`,
|
|
347
|
+
stroke: "#26241f",
|
|
348
|
+
"stroke-width": "4",
|
|
349
|
+
"stroke-linecap": "round"
|
|
350
|
+
}),
|
|
351
|
+
svgNode("path", {
|
|
352
|
+
d: `M ${scene.world.left} ${scene.world.floorY + 6} H ${scene.world.right}`,
|
|
353
|
+
stroke: "rgba(255,255,255,0.62)",
|
|
354
|
+
"stroke-width": "1.2"
|
|
355
|
+
})
|
|
356
|
+
);
|
|
357
|
+
for (let x = scene.world.left + 85; x < scene.world.right; x += 118) {
|
|
358
|
+
background.appendChild(
|
|
359
|
+
svgNode("path", {
|
|
360
|
+
d: `M ${x} ${scene.world.floorY + 2} l -24 ${scene.canvas.height - scene.world.floorY}`,
|
|
361
|
+
stroke: "rgba(95,67,34,0.16)",
|
|
362
|
+
"stroke-width": "1"
|
|
363
|
+
})
|
|
364
|
+
);
|
|
365
|
+
}
|
|
366
|
+
return background;
|
|
367
|
+
}
|
|
368
|
+
|
|
369
|
+
function createKickBackground(scene, defs) {
|
|
370
|
+
const sky = svgNode("linearGradient", {
|
|
371
|
+
id: "oa-kick-sky",
|
|
372
|
+
x1: "0%",
|
|
373
|
+
y1: "0%",
|
|
374
|
+
x2: "0%",
|
|
375
|
+
y2: "100%"
|
|
376
|
+
});
|
|
377
|
+
sky.append(
|
|
378
|
+
svgNode("stop", { offset: "0%", "stop-color": "#1f5550" }),
|
|
379
|
+
svgNode("stop", { offset: "62%", "stop-color": "#4d8275" }),
|
|
380
|
+
svgNode("stop", { offset: "100%", "stop-color": "#b9b58d" })
|
|
381
|
+
);
|
|
382
|
+
const grass = svgNode("linearGradient", {
|
|
383
|
+
id: "oa-kick-grass",
|
|
384
|
+
x1: "0%",
|
|
385
|
+
y1: "0%",
|
|
386
|
+
x2: "0%",
|
|
387
|
+
y2: "100%"
|
|
388
|
+
});
|
|
389
|
+
grass.append(
|
|
390
|
+
svgNode("stop", { offset: "0%", "stop-color": "#6f984d" }),
|
|
391
|
+
svgNode("stop", { offset: "100%", "stop-color": "#315e2e" })
|
|
392
|
+
);
|
|
393
|
+
defs.append(sky, grass);
|
|
394
|
+
|
|
395
|
+
const background = svgNode("g", { class: "oa-kick-background" });
|
|
396
|
+
background.append(
|
|
397
|
+
svgNode("rect", {
|
|
398
|
+
x: 0,
|
|
399
|
+
y: 0,
|
|
400
|
+
width: scene.canvas.width,
|
|
401
|
+
height: scene.world.floorY,
|
|
402
|
+
fill: "url(#oa-kick-sky)"
|
|
403
|
+
}),
|
|
404
|
+
svgNode("path", {
|
|
405
|
+
d: "M 0 296 Q 180 270 338 294 T 660 286 T 960 278 V 340 H 0 Z",
|
|
406
|
+
fill: "#173d38",
|
|
407
|
+
opacity: "0.62"
|
|
408
|
+
}),
|
|
409
|
+
svgNode("path", {
|
|
410
|
+
d: "M 0 318 Q 210 294 420 315 T 960 304 V 356 H 0 Z",
|
|
411
|
+
fill: "#142d2a",
|
|
412
|
+
opacity: "0.52"
|
|
413
|
+
}),
|
|
414
|
+
svgNode("rect", {
|
|
415
|
+
x: 0,
|
|
416
|
+
y: 330,
|
|
417
|
+
width: scene.canvas.width,
|
|
418
|
+
height: scene.canvas.height - 330,
|
|
419
|
+
fill: "url(#oa-kick-grass)"
|
|
420
|
+
})
|
|
421
|
+
);
|
|
422
|
+
|
|
423
|
+
for (let index = 0; index < 10; index += 1) {
|
|
424
|
+
const x0 = index * 96;
|
|
425
|
+
background.appendChild(
|
|
426
|
+
svgNode("path", {
|
|
427
|
+
d: `M ${x0} ${scene.canvas.height} L ${430 + (x0 - 480) * 0.28} 330 L ${526 + (x0 - 480) * 0.28} 330 L ${x0 + 96} ${scene.canvas.height} Z`,
|
|
428
|
+
fill: index % 2 === 0 ? "rgba(173,207,105,0.08)" : "rgba(15,58,25,0.08)"
|
|
429
|
+
})
|
|
430
|
+
);
|
|
431
|
+
}
|
|
432
|
+
|
|
433
|
+
background.append(
|
|
434
|
+
svgNode("path", {
|
|
435
|
+
d: `M 0 ${scene.world.floorY} H ${scene.canvas.width}`,
|
|
436
|
+
stroke: "#f1eedc",
|
|
437
|
+
"stroke-width": "4"
|
|
438
|
+
}),
|
|
439
|
+
svgNode("path", {
|
|
440
|
+
d: "M 78 540 L 265 330 M 884 540 L 704 330",
|
|
441
|
+
stroke: "rgba(241,238,220,0.58)",
|
|
442
|
+
"stroke-width": "2.3",
|
|
443
|
+
fill: "none"
|
|
444
|
+
}),
|
|
445
|
+
svgNode("ellipse", {
|
|
446
|
+
cx: 480,
|
|
447
|
+
cy: 330,
|
|
448
|
+
rx: 88,
|
|
449
|
+
ry: 21,
|
|
450
|
+
fill: "none",
|
|
451
|
+
stroke: "rgba(241,238,220,0.38)",
|
|
452
|
+
"stroke-width": "2"
|
|
453
|
+
})
|
|
454
|
+
);
|
|
455
|
+
|
|
456
|
+
const net = svgNode("g", { class: "oa-goal-net" });
|
|
457
|
+
const netMesh = svgNode("g", { class: "oa-goal-mesh" });
|
|
458
|
+
const netLines = [];
|
|
459
|
+
net.append(
|
|
460
|
+
svgNode("path", {
|
|
461
|
+
d: "M 735 430 V 164 H 894 V 430 M 894 164 L 924 186 V 430 H 735",
|
|
462
|
+
stroke: "#f5f1dd",
|
|
463
|
+
"stroke-width": "6.5",
|
|
464
|
+
fill: "none",
|
|
465
|
+
"stroke-linejoin": "round"
|
|
466
|
+
}),
|
|
467
|
+
svgNode("path", {
|
|
468
|
+
d: "M 735 164 L 763 188 H 924",
|
|
469
|
+
stroke: "#ddd9c8",
|
|
470
|
+
"stroke-width": "2.2",
|
|
471
|
+
fill: "none"
|
|
472
|
+
})
|
|
473
|
+
);
|
|
474
|
+
for (let x = 754; x <= 914; x += 20) {
|
|
475
|
+
const topX = 735 + (x - 735) * 0.84;
|
|
476
|
+
const node = svgNode("path", {
|
|
477
|
+
d: `M ${topX.toFixed(1)} 166 L ${x} 430`,
|
|
478
|
+
stroke: "rgba(245,241,221,0.56)",
|
|
479
|
+
"stroke-width": "0.9",
|
|
480
|
+
fill: "none"
|
|
481
|
+
});
|
|
482
|
+
netMesh.appendChild(node);
|
|
483
|
+
netLines.push({ kind: "vertical", node, topX, bottomX: x });
|
|
484
|
+
}
|
|
485
|
+
for (let y = 190; y <= 416; y += 23) {
|
|
486
|
+
const leftX = 735 + (y - 164) * 0.015;
|
|
487
|
+
const rightX = 924 - (430 - y) * 0.035;
|
|
488
|
+
const node = svgNode("path", {
|
|
489
|
+
d: `M ${leftX.toFixed(1)} ${y} L ${rightX.toFixed(1)} ${y}`,
|
|
490
|
+
stroke: "rgba(245,241,221,0.56)",
|
|
491
|
+
"stroke-width": "0.9",
|
|
492
|
+
fill: "none"
|
|
493
|
+
});
|
|
494
|
+
netMesh.appendChild(node);
|
|
495
|
+
netLines.push({ kind: "horizontal", node, leftX, rightX, y });
|
|
496
|
+
}
|
|
497
|
+
net.appendChild(netMesh);
|
|
498
|
+
background.appendChild(net);
|
|
499
|
+
return { node: background, netLines };
|
|
500
|
+
}
|
|
501
|
+
|
|
502
|
+
function createKickActor(photoHref) {
|
|
503
|
+
const group = svgNode("g", {
|
|
504
|
+
class: "oa-kick-actor",
|
|
505
|
+
opacity: "0"
|
|
506
|
+
});
|
|
507
|
+
if (photoHref) {
|
|
508
|
+
group.appendChild(
|
|
509
|
+
svgNode("image", {
|
|
510
|
+
href: photoHref,
|
|
511
|
+
x: "-157",
|
|
512
|
+
y: "-75",
|
|
513
|
+
width: "220",
|
|
514
|
+
height: "147",
|
|
515
|
+
preserveAspectRatio: "xMidYMid meet",
|
|
516
|
+
decoding: "sync",
|
|
517
|
+
style: "filter:drop-shadow(2px 5px 3px rgba(10,24,14,0.35))"
|
|
518
|
+
})
|
|
519
|
+
);
|
|
520
|
+
return group;
|
|
521
|
+
}
|
|
522
|
+
group.append(
|
|
523
|
+
svgNode("path", {
|
|
524
|
+
d: "M -66 -102 L -25 -98 L -18 -18 Q -30 -7 -48 -12 Z",
|
|
525
|
+
fill: "#f2efdf",
|
|
526
|
+
stroke: "#20201d",
|
|
527
|
+
"stroke-width": "2.2"
|
|
528
|
+
}),
|
|
529
|
+
svgNode("path", {
|
|
530
|
+
d: "M -66 -28 L -20 -25 L -14 -12 L 18 -3 Q 42 4 50 18 Q 38 28 10 27 L -55 22 Q -76 14 -76 -4 Z",
|
|
531
|
+
fill: "#d9d1bc",
|
|
532
|
+
stroke: "#20201d",
|
|
533
|
+
"stroke-width": "2.4",
|
|
534
|
+
"stroke-linejoin": "round"
|
|
535
|
+
}),
|
|
536
|
+
svgNode("path", {
|
|
537
|
+
d: "M -68 7 Q -20 18 48 13 L 52 22 Q 7 36 -58 24 Z",
|
|
538
|
+
fill: "#252622",
|
|
539
|
+
stroke: "#11120f",
|
|
540
|
+
"stroke-width": "1.4"
|
|
541
|
+
}),
|
|
542
|
+
svgNode("path", {
|
|
543
|
+
d: "M -48 -11 L 8 7 M -36 -19 L 18 3 M -24 -23 L 28 0",
|
|
544
|
+
stroke: "#a34b32",
|
|
545
|
+
"stroke-width": "2",
|
|
546
|
+
fill: "none"
|
|
547
|
+
}),
|
|
548
|
+
svgNode("circle", { cx: -44, cy: -12, r: 2.1, fill: "#20201d" }),
|
|
549
|
+
svgNode("circle", { cx: -29, cy: -16, r: 2.1, fill: "#20201d" }),
|
|
550
|
+
svgNode("circle", { cx: -14, cy: -14, r: 2.1, fill: "#20201d" })
|
|
551
|
+
);
|
|
552
|
+
return group;
|
|
553
|
+
}
|
|
554
|
+
|
|
555
|
+
export function createRigidBallRenderer(svg, simulation, options = {}) {
|
|
556
|
+
const { scene, frames } = simulation;
|
|
557
|
+
if (!frames) {
|
|
558
|
+
throw new TypeError("The rigid renderer requires simulation frames.");
|
|
559
|
+
}
|
|
560
|
+
const mode = options.mode ?? "lab";
|
|
561
|
+
const root = svgNode("g", { class: `oa-rigid-scene oa-mode-${mode}` });
|
|
562
|
+
const defs = svgNode("defs");
|
|
563
|
+
const shadowFilter = svgNode("filter", {
|
|
564
|
+
id: `oa-rigid-shadow-${mode}`,
|
|
565
|
+
x: "-50%",
|
|
566
|
+
y: "-90%",
|
|
567
|
+
width: "200%",
|
|
568
|
+
height: "280%"
|
|
569
|
+
});
|
|
570
|
+
shadowFilter.appendChild(svgNode("feGaussianBlur", { stdDeviation: "4.8" }));
|
|
571
|
+
defs.appendChild(shadowFilter);
|
|
572
|
+
root.appendChild(defs);
|
|
573
|
+
|
|
574
|
+
const kickBackground =
|
|
575
|
+
mode === "kick" ? createKickBackground(scene, defs) : null;
|
|
576
|
+
const background =
|
|
577
|
+
kickBackground?.node ?? createLabBackground(scene);
|
|
578
|
+
root.appendChild(background);
|
|
579
|
+
|
|
580
|
+
const shadowGroup = svgNode("g", {
|
|
581
|
+
class: "oa-rigid-shadows",
|
|
582
|
+
filter: `url(#oa-rigid-shadow-${mode})`
|
|
583
|
+
});
|
|
584
|
+
const kickActor =
|
|
585
|
+
mode === "kick" ? createKickActor(options.kickActorHref) : null;
|
|
586
|
+
const kickDebris = mode === "kick"
|
|
587
|
+
? svgNode("g", { class: "oa-kick-debris", opacity: "0" })
|
|
588
|
+
: null;
|
|
589
|
+
if (kickDebris) {
|
|
590
|
+
for (let index = 0; index < 11; index += 1) {
|
|
591
|
+
kickDebris.appendChild(
|
|
592
|
+
svgNode(index % 3 === 0 ? "path" : "circle", index % 3 === 0
|
|
593
|
+
? {
|
|
594
|
+
d: "M -2 3 L 0 -4 L 2 3 Z",
|
|
595
|
+
fill: index % 2 === 0 ? "#c5d78b" : "#466f38"
|
|
596
|
+
}
|
|
597
|
+
: {
|
|
598
|
+
r: index % 2 === 0 ? 1.8 : 1.2,
|
|
599
|
+
fill: index % 2 === 0 ? "#d6d0a2" : "#395f31"
|
|
600
|
+
})
|
|
601
|
+
);
|
|
602
|
+
}
|
|
603
|
+
}
|
|
604
|
+
|
|
605
|
+
const bodyGroup = svgNode("g", { class: "oa-rigid-bodies" });
|
|
606
|
+
const labelGroup = svgNode("g", {
|
|
607
|
+
class: "oa-rigid-labels",
|
|
608
|
+
"font-family": "ui-monospace, SFMono-Regular, Menlo, monospace",
|
|
609
|
+
"font-size": "10",
|
|
610
|
+
"font-weight": "700",
|
|
611
|
+
"letter-spacing": "1.5",
|
|
612
|
+
"text-anchor": "middle",
|
|
613
|
+
fill: mode === "kick" ? "#f3efdf" : "#514a3f"
|
|
614
|
+
});
|
|
615
|
+
root.appendChild(shadowGroup);
|
|
616
|
+
if (kickActor) root.appendChild(kickActor);
|
|
617
|
+
if (kickDebris) root.appendChild(kickDebris);
|
|
618
|
+
root.append(bodyGroup, labelGroup);
|
|
619
|
+
svg.appendChild(root);
|
|
620
|
+
|
|
621
|
+
const bodyNodes = [];
|
|
622
|
+
const shadows = [];
|
|
623
|
+
scene.bodies.forEach((body, index) => {
|
|
624
|
+
const shadow = svgNode("ellipse", {
|
|
625
|
+
cx: body.x,
|
|
626
|
+
cy: scene.world.floorY - 1,
|
|
627
|
+
rx: body.radius * 0.78,
|
|
628
|
+
ry: Math.max(4, body.radius * 0.13),
|
|
629
|
+
fill: mode === "kick" ? "rgba(8,24,12,0.48)" : "rgba(54,37,20,0.3)"
|
|
630
|
+
});
|
|
631
|
+
shadowGroup.appendChild(shadow);
|
|
632
|
+
shadows.push(shadow);
|
|
633
|
+
|
|
634
|
+
const bodyNode = createBall(
|
|
635
|
+
body,
|
|
636
|
+
defs,
|
|
637
|
+
`oa-${mode}-${index}`,
|
|
638
|
+
options.ballAssets?.[body.kind]
|
|
639
|
+
);
|
|
640
|
+
bodyGroup.appendChild(bodyNode);
|
|
641
|
+
bodyNodes.push(bodyNode);
|
|
642
|
+
|
|
643
|
+
if (options.labels !== false) {
|
|
644
|
+
const label = svgNode("text", {
|
|
645
|
+
x: body.x,
|
|
646
|
+
y: scene.world.floorY + 32
|
|
647
|
+
});
|
|
648
|
+
label.textContent = body.label ?? body.id.toUpperCase();
|
|
649
|
+
labelGroup.appendChild(label);
|
|
650
|
+
}
|
|
651
|
+
});
|
|
652
|
+
|
|
653
|
+
function renderKickDetails(frameIndex) {
|
|
654
|
+
if (!kickActor || !kickDebris) return;
|
|
655
|
+
const time = frameIndex / scene.timing.fps;
|
|
656
|
+
const contactTime = scene.impulses[0]?.time ?? 0.62;
|
|
657
|
+
if (time < 0.08 || time > 1.12) {
|
|
658
|
+
kickActor.setAttribute("opacity", "0");
|
|
659
|
+
} else {
|
|
660
|
+
const approach = smoothStep((time - 0.08) / Math.max(0.01, contactTime - 0.08));
|
|
661
|
+
const follow = clamp((time - contactTime) / 0.5, 0, 1);
|
|
662
|
+
const x = 5 + approach * 85 + follow * 24;
|
|
663
|
+
const y = 402 - Math.sin(approach * Math.PI) * 18 + follow * 5;
|
|
664
|
+
const rotation = -17 + approach * 14 + follow * 7;
|
|
665
|
+
const opacity = time <= contactTime + 0.24
|
|
666
|
+
? 1
|
|
667
|
+
: 1 - (time - contactTime - 0.24) / 0.26;
|
|
668
|
+
kickActor.setAttribute("opacity", clamp(opacity, 0, 1).toFixed(2));
|
|
669
|
+
kickActor.setAttribute(
|
|
670
|
+
"transform",
|
|
671
|
+
`translate(${x.toFixed(2)} ${y.toFixed(2)}) rotate(${rotation.toFixed(2)})`
|
|
672
|
+
);
|
|
673
|
+
}
|
|
674
|
+
|
|
675
|
+
const debrisAge = time - contactTime;
|
|
676
|
+
const debrisOpacity = debrisAge >= 0 && debrisAge <= 0.82
|
|
677
|
+
? Math.sin((debrisAge / 0.82) * Math.PI)
|
|
678
|
+
: 0;
|
|
679
|
+
kickDebris.setAttribute("opacity", debrisOpacity.toFixed(2));
|
|
680
|
+
[...kickDebris.children].forEach((node, index) => {
|
|
681
|
+
const spread = (index - 5) * 6.8;
|
|
682
|
+
const lift = 28 + (index % 4) * 11;
|
|
683
|
+
const x = 143 + spread * debrisAge * 2.2;
|
|
684
|
+
const y = scene.world.floorY - lift * debrisAge + 54 * debrisAge * debrisAge;
|
|
685
|
+
node.setAttribute(
|
|
686
|
+
"transform",
|
|
687
|
+
`translate(${x.toFixed(2)} ${y.toFixed(2)}) rotate(${(index * 31 + debrisAge * 180).toFixed(2)})`
|
|
688
|
+
);
|
|
689
|
+
});
|
|
690
|
+
|
|
691
|
+
const ballX = frames[frameIndex].x[0];
|
|
692
|
+
const ballY = frames[frameIndex].y[0];
|
|
693
|
+
const insideGoal =
|
|
694
|
+
clamp((ballX - 690) / 150, 0, 1) *
|
|
695
|
+
clamp((944 - ballX) / 42, 0, 1) *
|
|
696
|
+
clamp((ballY - 122) / 50, 0, 1) *
|
|
697
|
+
clamp((454 - ballY) / 42, 0, 1);
|
|
698
|
+
const pocket = smoothStep(insideGoal) * 31;
|
|
699
|
+
for (const line of kickBackground.netLines) {
|
|
700
|
+
if (line.kind === "vertical") {
|
|
701
|
+
const mix = clamp((ballY - 166) / (430 - 166), 0, 1);
|
|
702
|
+
const baseX = line.topX + (line.bottomX - line.topX) * mix;
|
|
703
|
+
const falloff = Math.exp(-Math.pow((baseX - ballX) / 74, 2));
|
|
704
|
+
const shift = pocket * falloff;
|
|
705
|
+
line.node.setAttribute(
|
|
706
|
+
"d",
|
|
707
|
+
`M ${line.topX.toFixed(1)} 166 C ${line.topX.toFixed(1)} ${(ballY - 68).toFixed(1)} ${(baseX + shift).toFixed(1)} ${(ballY - 25).toFixed(1)} ${(baseX + shift).toFixed(1)} ${ballY.toFixed(1)} C ${(baseX + shift).toFixed(1)} ${(ballY + 28).toFixed(1)} ${line.bottomX.toFixed(1)} ${(ballY + 72).toFixed(1)} ${line.bottomX.toFixed(1)} 430`
|
|
708
|
+
);
|
|
709
|
+
} else {
|
|
710
|
+
const falloff = Math.exp(-Math.pow((line.y - ballY) / 66, 2));
|
|
711
|
+
const direction = line.y < ballY ? -1 : 1;
|
|
712
|
+
const offsetY = direction * pocket * 0.22 * falloff;
|
|
713
|
+
const middleX = (line.leftX + line.rightX) * 0.5;
|
|
714
|
+
line.node.setAttribute(
|
|
715
|
+
"d",
|
|
716
|
+
`M ${line.leftX.toFixed(1)} ${line.y} Q ${(middleX + pocket * falloff).toFixed(1)} ${(line.y + offsetY).toFixed(1)} ${line.rightX.toFixed(1)} ${line.y}`
|
|
717
|
+
);
|
|
718
|
+
}
|
|
719
|
+
}
|
|
720
|
+
}
|
|
721
|
+
|
|
722
|
+
function renderFrame(frameIndex) {
|
|
723
|
+
const safeIndex = Math.max(0, Math.min(frames.length - 1, frameIndex));
|
|
724
|
+
const frame = frames[safeIndex];
|
|
725
|
+
const previous = frames[Math.max(0, safeIndex - 1)];
|
|
726
|
+
const next = frames[Math.min(frames.length - 1, safeIndex + 1)];
|
|
727
|
+
|
|
728
|
+
scene.bodies.forEach((body, index) => {
|
|
729
|
+
const altitude = Math.max(
|
|
730
|
+
0,
|
|
731
|
+
scene.world.floorY - (frame.y[index] + body.radius)
|
|
732
|
+
);
|
|
733
|
+
const verticalTravel = Math.abs(next.y[index] - previous.y[index]);
|
|
734
|
+
const contact = clamp(1 - altitude / 3.2, 0, 1);
|
|
735
|
+
const squash = contact * clamp(verticalTravel * 0.012, 0, 0.085);
|
|
736
|
+
bodyNodes[index].setAttribute(
|
|
737
|
+
"transform",
|
|
738
|
+
`translate(${frame.x[index].toFixed(2)} ${(frame.y[index] + squash * body.radius * 0.55).toFixed(2)}) rotate(${frame.angle[index].toFixed(2)}) scale(${(1 + squash).toFixed(4)} ${(1 - squash).toFixed(4)})`
|
|
739
|
+
);
|
|
740
|
+
|
|
741
|
+
const proximity = Math.max(0.06, 1 - altitude / 280);
|
|
742
|
+
shadows[index].setAttribute("cx", frame.x[index].toFixed(2));
|
|
743
|
+
shadows[index].setAttribute(
|
|
744
|
+
"rx",
|
|
745
|
+
(body.radius * (0.38 + proximity * 0.48 + squash * 0.8)).toFixed(2)
|
|
746
|
+
);
|
|
747
|
+
shadows[index].setAttribute(
|
|
748
|
+
"ry",
|
|
749
|
+
(Math.max(3.5, body.radius * (0.07 + proximity * 0.065))).toFixed(2)
|
|
750
|
+
);
|
|
751
|
+
shadows[index].setAttribute(
|
|
752
|
+
"opacity",
|
|
753
|
+
(0.16 + proximity * 0.84).toFixed(2)
|
|
754
|
+
);
|
|
755
|
+
});
|
|
756
|
+
renderKickDetails(safeIndex);
|
|
757
|
+
}
|
|
758
|
+
|
|
759
|
+
return { renderFrame };
|
|
760
|
+
}
|