Rebuild the object in a reference image as a code-only, procedural, quality-gated, animation-ready Three.js model. Token-efficient image-to-3D.
Python 3dai-agentsclaude-codecomputer-graphicsgenerativeimage-to-3dprocedural-generationthreejstypescriptwebgl
fix: detect a second BIN chunk after an empty one
kokorolxaa70269415b6
diff --git a/forge/_shared/glb_container.py b/forge/_shared/glb_container.pyindex 9e32d5a..bc43a53 100644--- a/forge/_shared/glb_container.py+++ b/forge/_shared/glb_container.py@@ -51,6 +51,7 @@ def parse_glb(path: Path) -> tuple[dict[str, Any], bytes, dict[str, Any]]:cursor = 12json_payload: bytes | None = Nonebin_payload = b""+ bin_seen = Falsechunks: list[dict[str, Any]] = []while cursor < len(data):if cursor + 8 > len(data):@@ -68,8 +69,11 @@ def parse_glb(path: Path) -> tuple[dict[str, Any], bytes, dict[str, Any]]:raise ValueError("GLB contains more than one JSON chunk")json_payload = payload.rstrip(b" \t\r\n\x00")elif chunk_type == BIN_CHUNK:- if bin_payload:+ # A seen-flag, not truthiness: a zero-length first BIN chunk is falsy, and truthiness+ # let a second BIN chunk slide through the duplicate check.+ if bin_seen:raise ValueError("GLB contains more than one BIN chunk")+ bin_seen = Truebin_payload = payloadif json_payload is None:diff --git a/forge/tests/test_glb_reference.py b/forge/tests/test_glb_reference.pyindex 7320813..ac97a9a 100644--- a/forge/tests/test_glb_reference.py+++ b/forge/tests/test_glb_reference.py@@ -151,5 +151,27 @@ class GlbReferenceProbeTest(unittest.TestCase):)+class GlbContainerRefusesDuplicateBinChunks(unittest.TestCase):+ """`parse_glb` promises to refuse more than one BIN chunk; the duplicate check must be a+ seen-flag, not payload truthiness -- a zero-length first BIN chunk is falsy and let a second+ one through."""++ def test_a_second_bin_chunk_after_an_empty_one_is_refused(self) -> None:+ from forge._shared.glb_container import parse_glb++ payload = json.dumps({"asset": {"version": "2.0"}}).encode("utf-8")+ payload += b" " * ((4 - len(payload) % 4) % 4)+ chunks = struct.pack("<II", len(payload), 0x4E4F534A) + payload+ chunks += struct.pack("<II", 0, 0x004E4942)+ chunks += struct.pack("<II", 4, 0x004E4942) + b"\x00\x00\x00\x00"+ blob = struct.pack("<4sII", b"glTF", 2, 12 + len(chunks)) + chunks+ with tempfile.TemporaryDirectory() as tmp:+ path = Path(tmp) / "double-bin.glb"+ path.write_bytes(blob)+ with self.assertRaises(ValueError) as ctx:+ parse_glb(path)+ self.assertIn("more than one BIN chunk", str(ctx.exception))++if __name__ == "__main__":unittest.main()