Spaces:
Running
Running
Shared: load sprite sheets resiliently (curated Space subset may 404 some shadows)
Browse filessetCharacter used Promise.all, so one missing shadow/companion PNG threw and the
sprite was never created on the Space (curated assets omit some _Shadows sheets).
Load each sheet independently and skip failures — degrade gracefully (no shadow)
instead of breaking the character. React (full assets) is unaffected.
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
- web/scene.js +9 -6
web/scene.js
CHANGED
|
@@ -328,16 +328,19 @@ function createSpriteScene(pixi, host, opts = {}) {
|
|
| 328 |
e.shadow ? { gridKey: "shd:x:" + e.key, url: e.shadow, type: "body" } : null
|
| 329 |
].filter(Boolean))
|
| 330 |
];
|
| 331 |
-
const texs = await Promise.all(sheets.map((s) => Assets.load(urlFor(s.url))));
|
| 332 |
if (!app) return;
|
| 333 |
-
const grids = {};
|
| 334 |
const idleIdx = sheets.findIndex((s) => s.gridKey === "idle");
|
|
|
|
|
|
|
| 335 |
const cell = cellOf(texs[idleIdx].source.height);
|
| 336 |
sheets.forEach((s, i) => {
|
| 337 |
-
texs[i]
|
| 338 |
-
if (
|
| 339 |
-
|
| 340 |
-
|
|
|
|
|
|
|
| 341 |
});
|
| 342 |
frames = grids;
|
| 343 |
extras = active.extras ?? [];
|
|
|
|
| 328 |
e.shadow ? { gridKey: "shd:x:" + e.key, url: e.shadow, type: "body" } : null
|
| 329 |
].filter(Boolean))
|
| 330 |
];
|
| 331 |
+
const texs = await Promise.all(sheets.map((s) => Assets.load(urlFor(s.url)).then((t) => t, () => null)));
|
| 332 |
if (!app) return;
|
|
|
|
| 333 |
const idleIdx = sheets.findIndex((s) => s.gridKey === "idle");
|
| 334 |
+
if (idleIdx < 0 || !texs[idleIdx]) return;
|
| 335 |
+
const grids = {};
|
| 336 |
const cell = cellOf(texs[idleIdx].source.height);
|
| 337 |
sheets.forEach((s, i) => {
|
| 338 |
+
const t = texs[i];
|
| 339 |
+
if (!t) return;
|
| 340 |
+
t.source.scaleMode = "nearest";
|
| 341 |
+
if (s.type === "proj") grids[s.gridKey] = sliceGrid(t, Math.max(1, Math.round(t.source.height / ROWS)));
|
| 342 |
+
else if (s.type === "imp") grids[s.gridKey] = sliceGrid(t, Math.max(1, t.source.height));
|
| 343 |
+
else grids[s.gridKey] = sliceGrid(t, cell);
|
| 344 |
});
|
| 345 |
frames = grids;
|
| 346 |
extras = active.extras ?? [];
|