Rebuild core around render graph AST and shared memory

Amp-Thread-ID: https://ampcode.com/threads/T-01a01380-b478-77d0-84a0-102880a5c5ae
Co-authored-by: Heaust Azure <heaust.azure@gmail.com>
This commit is contained in:
Amp
2026-08-18 11:58:31 +00:00
co-authored by heaust
parent a23ef37b4d
commit 0e44917f9e
101 changed files with 4409 additions and 2610 deletions
+28
View File
@@ -0,0 +1,28 @@
import { writeSharedUpload } from "./shared-upload.js";
const downloads = new Map();
addEventListener("message", async ({ data: message }) => {
const request = message?.request;
try {
if (message?.type === "load") {
const response = await fetch(message.url);
if (!response.ok) throw new Error(`HTTP_${response.status}`);
const bytes = new Uint8Array(await response.arrayBuffer());
if (!bytes.byteLength) throw new Error("GLTF_EMPTY");
downloads.set(request, bytes);
postMessage({ type: "allocate", request, byteLength: bytes.byteLength });
return;
}
if (message?.type === "storage") {
const bytes = downloads.get(request);
if (!bytes) throw new Error("GLTF_REQUEST_UNKNOWN");
writeSharedUpload(message.buffer, message.descriptor, bytes);
downloads.delete(request);
postMessage({ type: "ready", request, byteLength: bytes.byteLength });
}
} catch (error) {
downloads.delete(request);
postMessage({ type: "error", request, code: error?.message || "GLTF_IMPORT_FAILED" });
}
});