feat: release v0.4 with textured Microban visuals

This commit is contained in:
2026-10-29 15:55:17 +08:00
parent 1965281004
commit f85f0c1237
37 changed files with 911 additions and 15 deletions
+57
View File
@@ -0,0 +1,57 @@
#!/usr/bin/env python3
"""Import the user-supplied, self-contained Microban visual GLBs only.
Usage: python3 app/scripts/import-microban-visuals.py /path/to/microban2.zip
Does not modify MJCF, policies or the reviewed body transforms in robot.json.
"""
import hashlib
import json
from pathlib import Path
import struct
import sys
import zipfile
def import_visuals(archive):
target = Path(__file__).resolve().parents[1] / "public/robots/microban"
links = ["BASE", *(f"LINK{i}" for i in range(1, 20))]
names = [f"{link}__visual_0__{link}.glb" for link in links]
with zipfile.ZipFile(archive) as source:
if sorted(source.namelist()) != sorted(names):
raise ValueError("Expected exactly BASE and LINK1..LINK19 GLBs")
files = {name: source.read(name) for name in names}
# Validate everything before copying any file. Never extract ZIP paths.
for name, data in files.items():
magic, version, length, json_length, chunk_type = struct.unpack_from(
"<5I", data
)
if (magic, version, length, chunk_type) != (
0x46546C67, 2, len(data), 0x4E4F534A
):
raise ValueError(f"{name}: invalid GLB")
gltf = json.loads(data[20:20 + json_length])
for asset in [*gltf.get("buffers", []), *gltf.get("images", [])]:
if "uri" in asset and not asset["uri"].startswith("data:"):
raise ValueError(f"{name}: external buffer/image is unsupported")
(target / "visuals").mkdir(exist_ok=True)
records = []
for name, data in files.items():
(target / "visuals" / name).write_bytes(data)
records.append({
"file": f"visuals/{name}",
"sha256": hashlib.sha256(data).hexdigest(),
})
manifest = {
"source": f"User-provided {archive.name} (textured visual replacement)",
"archive_sha256": hashlib.sha256(archive.read_bytes()).hexdigest(),
"license": "Not supplied in the archive; confirm redistribution rights with the asset owner.",
"files": records,
}
(target / "visual-source-manifest.json").write_text(
json.dumps(manifest, indent=2) + "\n"
)
print(f"Imported {len(records)} visual GLBs; physics/policy files unchanged")
if __name__ == "__main__":
import_visuals(Path(sys.argv[1]))
+22 -10
View File
@@ -8,6 +8,7 @@ import {
} from "../src/platform/loader/SchemaValidator.js";
import { resolveWorldId } from "../src/platform/worlds/arena.js";
import { JointMotionReference } from "../src/platform/policy/JointMotionReference.js";
import { validateBodyGlb } from "../src/platform/render/BodyVisuals.js";
const root = fileURLToPath(new URL("../public/robots/", import.meta.url));
const entries = JSON.parse(await readFile(resolve(root, "index.json"), "utf8"));
for (const entry of entries) {
@@ -18,6 +19,7 @@ for (const entry of entries) {
const paths = [
config.model,
...config.assets.map((a) => a.path),
...(config.render.body_visuals ?? []).map((v) => v.path),
...config.skills
.filter((s) => s.controller.type === "onnx" && s.available !== false)
.map((s) => s.controller.policy),
@@ -39,6 +41,12 @@ for (const entry of entries) {
paths.push(skill.reference, spec.data);
}
for (const path of paths) await access(resolve(dirname(file), path));
for (const visual of config.render.body_visuals ?? []) {
const bytes = await readFile(resolve(dirname(file), visual.path));
validateBodyGlb(
bytes.buffer.slice(bytes.byteOffset, bytes.byteOffset + bytes.byteLength),
);
}
validateWorld(
JSON.parse(
await readFile(
@@ -47,15 +55,18 @@ for (const entry of entries) {
),
),
);
let provenance;
try {
provenance = JSON.parse(
await readFile(resolve(dirname(file), "source-manifest.json"), "utf8"),
);
} catch (error) {
if (error.code !== "ENOENT") throw error;
}
if (provenance)
let hasProvenance = false;
for (const name of ["source-manifest.json", "visual-source-manifest.json"]) {
let provenance;
try {
provenance = JSON.parse(
await readFile(resolve(dirname(file), name), "utf8"),
);
} catch (error) {
if (error.code !== "ENOENT") throw error;
continue;
}
hasProvenance = true;
for (const record of [
...provenance.files,
...(provenance.additionalNotices ?? []),
@@ -68,7 +79,8 @@ for (const entry of entries) {
`${entry.id}/${record.file}: source SHA-256 mismatch (check git lfs pull or document asset changes)`,
);
}
}
console.log(
`${config.id}: schema, World, ${paths.length} resource paths${provenance ? " and source hashes" : ""} OK`,
`${config.id}: schema, World, ${paths.length} resource paths${hasProvenance ? " and source hashes" : ""} OK`,
);
}