Add files using upload-large-folder tool
Browse files- data/assets/assets-00000.tar +3 -0
- data/assets/assets-00001.tar +3 -0
- data/assets/assets-00002.tar +3 -0
- data/assets/assets-00003.tar +3 -0
- data/assets/assets-00006.tar +3 -0
- data/assets/assets-00007.tar +3 -0
- data/assets/assets-00010.tar +3 -0
- data/assets/assets-00012.tar +3 -0
- data/assets/assets-00013.tar +3 -0
- data/assets/assets-00014.tar +3 -0
- data/assets/assets-00015.tar +3 -0
- data/assets/assets-00016.tar +3 -0
- data/assets/assets-00017.tar +3 -0
- data/assets/assets-00028.tar +3 -0
- data/assets/assets-00029.tar +3 -0
- data/assets/assets-00038.tar +3 -0
- data/assets/assets-00048.tar +3 -0
- data/assets/assets-00049.tar +3 -0
- data/assets/assets-00058.tar +3 -0
- data/assets/assets-00059.tar +3 -0
- data/assets/assets-00060.tar +3 -0
- data/assets/assets-00061.tar +3 -0
- data/assets/assets-00062.tar +3 -0
- data/assets/assets-00063.tar +3 -0
- data/assets/assets-00064.tar +3 -0
- data/assets/assets-00065.tar +3 -0
- data/assets/assets-00066.tar +3 -0
- data/assets/assets-00067.tar +3 -0
- data/front_room_layout_build.py +1233 -0
- data/rooms/rooms-00018.tar +3 -0
- data/rooms/rooms-00019.tar +3 -0
- data/rooms/rooms-00024.tar +3 -0
- data/rooms/rooms-00025.tar +3 -0
- data/rooms/rooms-00030.tar +3 -0
- data/rooms/rooms-00031.tar +3 -0
- data/rooms/rooms-00144.tar +3 -0
- data/rooms/rooms-00145.tar +3 -0
- data/rooms/rooms-00150.tar +3 -0
- data/rooms/rooms-00151.tar +3 -0
- data/rooms/rooms-00178.tar +3 -0
- data/rooms/rooms-00179.tar +3 -0
- data/rooms/rooms-00186.tar +3 -0
- data/rooms/rooms-00187.tar +3 -0
- data/rooms/rooms-00192.tar +3 -0
- data/rooms/rooms-00193.tar +3 -0
- release_manifest.json +36 -0
data/assets/assets-00000.tar
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:50a7d78f924e5f46418bde6c942424d551381e6e5bbf69079cbdebfcb300a52b
|
| 3 |
+
size 1133056000
|
data/assets/assets-00001.tar
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:f58c1dc99ce68712a1e39850bbd3ad48172a07a5fd58d975b1880da25a20460a
|
| 3 |
+
size 1123573760
|
data/assets/assets-00002.tar
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:e174d344d61aedbbccec92b6e10b1b67acabb1cddf79a8b3e6ce884fd176e883
|
| 3 |
+
size 1174036480
|
data/assets/assets-00003.tar
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:12aa5ba6b5b7f8c74b9b84bd082b1fa8e9622a8e4a1ed14c226de09b17ee55c8
|
| 3 |
+
size 1006878720
|
data/assets/assets-00006.tar
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:427b4dcb6fabf6c918862fff0d396ec5a61cde01a536a47d6dc0c914ad573940
|
| 3 |
+
size 691957760
|
data/assets/assets-00007.tar
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:37ed9df54e45557884228036144eae4950a810e800ba7a639de3b84d71446cfe
|
| 3 |
+
size 697221120
|
data/assets/assets-00010.tar
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:5f5f807321f4412b2a40536fdb38b2d6b755295632505d14711c1dcc0faf1564
|
| 3 |
+
size 665692160
|
data/assets/assets-00012.tar
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:9d8359dbfdb4c1e6c1561eaaa768c4dbf6e0bdb380df2bcff256cfedf24720ca
|
| 3 |
+
size 650639360
|
data/assets/assets-00013.tar
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:43851552b0b5a7eb3711ed9eaee24da5a7a8e640b8103cc4fa51e803e445f08c
|
| 3 |
+
size 661063680
|
data/assets/assets-00014.tar
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:2e6cfdc3a5d7f7887b4e885a5de09d33ee5091b59f3f40ba4bcaf63cb0114ef5
|
| 3 |
+
size 655360000
|
data/assets/assets-00015.tar
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:d7a158b0f4be49c5a7fbd9973959098eb2fbb99542dbb92228e17f9cfbf6d235
|
| 3 |
+
size 690739200
|
data/assets/assets-00016.tar
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:f4a5d104de82b0d3cc5ec9b3d6d4778dbad796c88c47ffc27d6335bbeda8ca4c
|
| 3 |
+
size 713410560
|
data/assets/assets-00017.tar
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:2a356f2166136ce49d10681029ce5982219cfa35e8099ccc9d600bff2b4f6af1
|
| 3 |
+
size 672102400
|
data/assets/assets-00028.tar
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:9c84babc8072bbabae04e76a0f1f2f7990ad1feb54b68466cebea41d01e6e38f
|
| 3 |
+
size 746301440
|
data/assets/assets-00029.tar
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:ba1cfb6f32409c0f8525a03e340b82270942e7adee01ace7d292cd62554dd719
|
| 3 |
+
size 706375680
|
data/assets/assets-00038.tar
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:60d567ffb5f4084312e9e8a17e7cbecec9099fb78ea8fc7b4d173d3ce51aade2
|
| 3 |
+
size 878254080
|
data/assets/assets-00048.tar
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:9c7fc0082ae8b0d50ea736db4b23ea2679500c96ba6114e3884cb96aa0025458
|
| 3 |
+
size 993310720
|
data/assets/assets-00049.tar
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:4c070e7808453fea39c0ead7dc384f03e834105d3cd3e1582595aed1914fae61
|
| 3 |
+
size 942254080
|
data/assets/assets-00058.tar
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:da7a023a1a4436bbff93a67f9a65496c7ace0de7cd720646a0cd7a7ff78e69df
|
| 3 |
+
size 869539840
|
data/assets/assets-00059.tar
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:a0372fe9fa0d1f6ec14d05c22411220e513596e560a8471b239db25a06c71f10
|
| 3 |
+
size 961331200
|
data/assets/assets-00060.tar
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:cebc412967ca3b0ae826a9ffc7acf36c565167f96e62408ea9a3071727f79c51
|
| 3 |
+
size 935301120
|
data/assets/assets-00061.tar
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:ec86c45f351c20f08055e9ab9a501f5ef9900e21680882d4e652d3486a4b1d88
|
| 3 |
+
size 863539200
|
data/assets/assets-00062.tar
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:f77f02f4a5b7c15fe18a6c389d1b33432a028d76d3147c84e3b1e65529e22ff2
|
| 3 |
+
size 912271360
|
data/assets/assets-00063.tar
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:995942eea2cb424f11a191103c915ef0f9d7a2376f87f0eb27a8920d2bc37477
|
| 3 |
+
size 906014720
|
data/assets/assets-00064.tar
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:999d84c813ad57f23126c5eefe3a74f9c2d8d83f26fa2364fdcbfff2450207d5
|
| 3 |
+
size 774932480
|
data/assets/assets-00065.tar
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:083ab84b3143593d71b6a5445a159daec630fea999f89d25afda5f899dd697ad
|
| 3 |
+
size 600442880
|
data/assets/assets-00066.tar
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:218f9a5647bad4db3047e74300a7956de211ebef8d8def8ce6e5dfa90c3ef717
|
| 3 |
+
size 578457600
|
data/assets/assets-00067.tar
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:97194392bb16a6c04bd30b2abb8afc7b7102def7e9662305741aaa53ba01065d
|
| 3 |
+
size 616130560
|
data/front_room_layout_build.py
ADDED
|
@@ -0,0 +1,1233 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|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
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
"""Build a room-level furniture layout from 3D-FRONT component GLBs and object code.
|
| 2 |
+
|
| 3 |
+
This is the first room-stage bridge for the front object-code harness:
|
| 4 |
+
- use the non-full room GLB as source layout evidence
|
| 5 |
+
- use component GLB bounds as initial room-space placement targets
|
| 6 |
+
- instantiate each asset's selected v1-v4 best/object.py under a room-level transform
|
| 7 |
+
- render source/code five-view sheets for layout checking
|
| 8 |
+
"""
|
| 9 |
+
from __future__ import annotations
|
| 10 |
+
|
| 11 |
+
import argparse
|
| 12 |
+
import hashlib
|
| 13 |
+
import json
|
| 14 |
+
import math
|
| 15 |
+
import os
|
| 16 |
+
import shutil
|
| 17 |
+
import subprocess
|
| 18 |
+
import sys
|
| 19 |
+
from pathlib import Path
|
| 20 |
+
|
| 21 |
+
|
| 22 |
+
ROOT = Path(__file__).resolve().parents[1]
|
| 23 |
+
DATA = ROOT / "data"
|
| 24 |
+
FRONT_OBJECT_ROOT = DATA / "front_object_code"
|
| 25 |
+
COMPONENT_INDEX = FRONT_OBJECT_ROOT / "index" / "component_manifest.jsonl"
|
| 26 |
+
SCENE_ROOT = ROOT / "external" / "datasets" / "3D-Front_full" / "extracted" / "3D-FRONT-SCENE"
|
| 27 |
+
|
| 28 |
+
VIEW_SPECS = [
|
| 29 |
+
("topdown", "topdown", 0.0, 90.0),
|
| 30 |
+
("east", "persp", 90.0, 30.0),
|
| 31 |
+
("south", "persp", 0.0, 30.0),
|
| 32 |
+
("west", "persp", -90.0, 30.0),
|
| 33 |
+
("north", "persp", 180.0, 30.0),
|
| 34 |
+
]
|
| 35 |
+
|
| 36 |
+
try:
|
| 37 |
+
import bpy # noqa: F401
|
| 38 |
+
IN_BLENDER = True
|
| 39 |
+
except Exception:
|
| 40 |
+
IN_BLENDER = False
|
| 41 |
+
|
| 42 |
+
|
| 43 |
+
def repo_rel(path: Path | str) -> str:
|
| 44 |
+
value = Path(path)
|
| 45 |
+
try:
|
| 46 |
+
return str(value.relative_to(ROOT)) if value.is_absolute() else str(value)
|
| 47 |
+
except ValueError:
|
| 48 |
+
try:
|
| 49 |
+
return str(value.resolve().relative_to(ROOT))
|
| 50 |
+
except ValueError:
|
| 51 |
+
return str(value)
|
| 52 |
+
|
| 53 |
+
|
| 54 |
+
def resolve_repo(path: Path | str) -> Path:
|
| 55 |
+
value = Path(path)
|
| 56 |
+
return value if value.is_absolute() else ROOT / value
|
| 57 |
+
|
| 58 |
+
|
| 59 |
+
def write_json(path: Path, data) -> None:
|
| 60 |
+
path.parent.mkdir(parents=True, exist_ok=True)
|
| 61 |
+
path.write_text(json.dumps(data, indent=2, ensure_ascii=False), encoding="utf-8")
|
| 62 |
+
|
| 63 |
+
|
| 64 |
+
def load_json(path: Path):
|
| 65 |
+
return json.loads(path.read_text(encoding="utf-8"))
|
| 66 |
+
|
| 67 |
+
|
| 68 |
+
def image_extension(config: dict) -> str:
|
| 69 |
+
return ".jpg" if str(config.get("image_format", "jpeg")).lower() in {"jpg", "jpeg"} else ".png"
|
| 70 |
+
|
| 71 |
+
|
| 72 |
+
def slug_identifier(text: str, *, max_len: int = 96) -> str:
|
| 73 |
+
out = []
|
| 74 |
+
for ch in text.lower():
|
| 75 |
+
out.append(ch if ch.isalnum() else "_")
|
| 76 |
+
value = "".join(out).strip("_")
|
| 77 |
+
while "__" in value:
|
| 78 |
+
value = value.replace("__", "_")
|
| 79 |
+
return (value or "component")[:max_len].strip("_") or "component"
|
| 80 |
+
|
| 81 |
+
|
| 82 |
+
def load_room_components(house_id: str, room_id: str, *, index_path: Path = COMPONENT_INDEX) -> list[dict]:
|
| 83 |
+
rows: list[dict] = []
|
| 84 |
+
with index_path.open("r", encoding="utf-8") as handle:
|
| 85 |
+
for line in handle:
|
| 86 |
+
if not line.strip():
|
| 87 |
+
continue
|
| 88 |
+
row = json.loads(line)
|
| 89 |
+
if row.get("house_id") == house_id and row.get("room_id") == room_id:
|
| 90 |
+
rows.append(row)
|
| 91 |
+
rows.sort(key=lambda row: (row.get("category_slug") or "", int(row.get("instance_index") or 0), row.get("component_id") or ""))
|
| 92 |
+
return rows
|
| 93 |
+
|
| 94 |
+
|
| 95 |
+
def best_object_py(row: dict, asset_version: str = "v2") -> Path:
|
| 96 |
+
asset_dir = resolve_repo(row["asset_dir"])
|
| 97 |
+
return asset_dir / asset_version / "best" / "object.py"
|
| 98 |
+
|
| 99 |
+
|
| 100 |
+
def build_config(args: argparse.Namespace) -> Path:
|
| 101 |
+
input_manifest_path = resolve_repo(args.input_manifest) if args.input_manifest else None
|
| 102 |
+
input_manifest = load_json(input_manifest_path) if input_manifest_path else None
|
| 103 |
+
house_id = args.house or (input_manifest or {}).get("house_id")
|
| 104 |
+
room_id = args.room or (input_manifest or {}).get("room_id")
|
| 105 |
+
if not house_id or not room_id:
|
| 106 |
+
raise SystemExit("provide --house/--room or --input-manifest with house_id/room_id")
|
| 107 |
+
|
| 108 |
+
if input_manifest is None:
|
| 109 |
+
rows = load_room_components(house_id, room_id)
|
| 110 |
+
if args.max_components > 0:
|
| 111 |
+
rows = rows[: args.max_components]
|
| 112 |
+
if not rows and not args.source_only:
|
| 113 |
+
raise SystemExit(f"no component rows for {house_id}/{room_id}")
|
| 114 |
+
else:
|
| 115 |
+
rows = []
|
| 116 |
+
|
| 117 |
+
out_dir = args.out_dir or (input_manifest_path.parent if input_manifest_path else FRONT_OBJECT_ROOT / "by_room" / house_id / room_id)
|
| 118 |
+
out_dir = resolve_repo(out_dir)
|
| 119 |
+
render_dir = out_dir / "renders"
|
| 120 |
+
out_dir.mkdir(parents=True, exist_ok=True)
|
| 121 |
+
render_dir.mkdir(parents=True, exist_ok=True)
|
| 122 |
+
|
| 123 |
+
room_glb_value = args.room_glb or (input_manifest or {}).get("source_room_glb") or SCENE_ROOT / house_id / f"{room_id}.glb"
|
| 124 |
+
room_glb = room_glb_value
|
| 125 |
+
room_glb = resolve_repo(room_glb)
|
| 126 |
+
if not room_glb.exists() and not (input_manifest is not None and args.reuse_source):
|
| 127 |
+
raise FileNotFoundError(room_glb)
|
| 128 |
+
|
| 129 |
+
asset_version = args.asset_version
|
| 130 |
+
components = []
|
| 131 |
+
if input_manifest is not None:
|
| 132 |
+
components = [dict(component) for component in input_manifest.get("components", [])]
|
| 133 |
+
for component in components:
|
| 134 |
+
asset_dir_value = component.get("asset_dir")
|
| 135 |
+
if asset_dir_value:
|
| 136 |
+
object_py = resolve_repo(asset_dir_value) / asset_version / "best" / "object.py"
|
| 137 |
+
else:
|
| 138 |
+
current_object_py = resolve_repo(component["object_py"])
|
| 139 |
+
object_py = current_object_py.parents[2] / asset_version / "best" / "object.py"
|
| 140 |
+
component["object_py"] = repo_rel(object_py)
|
| 141 |
+
component["object_py_exists"] = object_py.exists()
|
| 142 |
+
else:
|
| 143 |
+
for row in rows:
|
| 144 |
+
object_py = best_object_py(row, asset_version)
|
| 145 |
+
source_glb = resolve_repo(row["source_glb"])
|
| 146 |
+
components.append({
|
| 147 |
+
"component_id": row["component_id"],
|
| 148 |
+
"object_id": row["object_id"],
|
| 149 |
+
"category": row.get("category"),
|
| 150 |
+
"category_slug": row.get("category_slug"),
|
| 151 |
+
"asset_id": row.get("asset_id"),
|
| 152 |
+
"instance_index": row.get("instance_index"),
|
| 153 |
+
"asset_dir": repo_rel(row["asset_dir"]),
|
| 154 |
+
"source_glb": repo_rel(source_glb),
|
| 155 |
+
"object_py": repo_rel(object_py),
|
| 156 |
+
"reference_grid": row.get("reference_grid"),
|
| 157 |
+
"object_py_exists": object_py.exists(),
|
| 158 |
+
"source_glb_exists": source_glb.exists(),
|
| 159 |
+
})
|
| 160 |
+
|
| 161 |
+
missing_object_code = [component["object_py"] for component in components if not component.get("object_py_exists")]
|
| 162 |
+
if missing_object_code and not args.source_only:
|
| 163 |
+
preview = "\n ".join(missing_object_code[:10])
|
| 164 |
+
suffix = f"\n ... and {len(missing_object_code) - 10} more" if len(missing_object_code) > 10 else ""
|
| 165 |
+
raise FileNotFoundError(f"missing {asset_version} object code:\n {preview}{suffix}")
|
| 166 |
+
|
| 167 |
+
config = {
|
| 168 |
+
"house_id": house_id,
|
| 169 |
+
"room_id": room_id,
|
| 170 |
+
"out_dir": repo_rel(out_dir),
|
| 171 |
+
"render_dir": repo_rel(render_dir),
|
| 172 |
+
"source_room_glb": repo_rel(room_glb),
|
| 173 |
+
"input_manifest": repo_rel(input_manifest_path) if input_manifest_path else None,
|
| 174 |
+
"asset_version": asset_version,
|
| 175 |
+
"components": components,
|
| 176 |
+
"render_res": args.render_res,
|
| 177 |
+
"samples": args.samples,
|
| 178 |
+
"denoise": args.denoise,
|
| 179 |
+
"image_format": args.image_format,
|
| 180 |
+
"jpeg_quality": args.jpeg_quality,
|
| 181 |
+
"world_strength": args.world_strength,
|
| 182 |
+
"sun_energy": args.sun_energy,
|
| 183 |
+
"fill_energy": args.fill_energy,
|
| 184 |
+
"exposure": args.exposure,
|
| 185 |
+
"source_sun_energy": args.source_sun_energy,
|
| 186 |
+
"source_fill_energy": args.source_fill_energy,
|
| 187 |
+
"source_exposure": args.source_exposure,
|
| 188 |
+
"source_material_lift": args.source_material_lift,
|
| 189 |
+
"source_foreground_lift": args.source_foreground_lift,
|
| 190 |
+
"source_key_energy": args.source_key_energy,
|
| 191 |
+
"film_transparent": True,
|
| 192 |
+
"render_engine": args.render_engine,
|
| 193 |
+
"scale_mode": args.scale_mode,
|
| 194 |
+
"source_view_yaw_offset_deg": args.source_view_yaw_offset,
|
| 195 |
+
"code_view_yaw_offset_deg": args.code_view_yaw_offset,
|
| 196 |
+
"source_topdown_roll_deg": args.source_topdown_roll,
|
| 197 |
+
"code_topdown_roll_deg": args.code_topdown_roll,
|
| 198 |
+
"source_only": args.source_only,
|
| 199 |
+
"reuse_source": args.reuse_source,
|
| 200 |
+
}
|
| 201 |
+
config_path = out_dir / "layout_build_config.json"
|
| 202 |
+
write_json(config_path, config)
|
| 203 |
+
write_room_layout_py(out_dir)
|
| 204 |
+
return config_path
|
| 205 |
+
|
| 206 |
+
|
| 207 |
+
def write_room_layout_py(out_dir: Path) -> None:
|
| 208 |
+
text = '''"""Generated room-level furniture layout entry point.
|
| 209 |
+
|
| 210 |
+
Run inside Blender from the repository root, or regenerate/render through:
|
| 211 |
+
python data/front_room_layout_build.py --house <house_id> --room <room_id>
|
| 212 |
+
"""
|
| 213 |
+
from pathlib import Path
|
| 214 |
+
import sys
|
| 215 |
+
|
| 216 |
+
|
| 217 |
+
def _repo_root() -> Path:
|
| 218 |
+
path = Path(__file__).resolve()
|
| 219 |
+
for parent in path.parents:
|
| 220 |
+
if (parent / "data" / "front_room_layout_build.py").exists():
|
| 221 |
+
return parent
|
| 222 |
+
raise RuntimeError("could not find repo root")
|
| 223 |
+
|
| 224 |
+
|
| 225 |
+
ROOT = _repo_root()
|
| 226 |
+
if str(ROOT / "data") not in sys.path:
|
| 227 |
+
sys.path.insert(0, str(ROOT / "data"))
|
| 228 |
+
|
| 229 |
+
from front_room_layout_build import build_room_from_manifest # noqa: E402
|
| 230 |
+
|
| 231 |
+
|
| 232 |
+
def build_room():
|
| 233 |
+
return build_room_from_manifest(Path(__file__).with_name("layout_manifest.json"))
|
| 234 |
+
|
| 235 |
+
|
| 236 |
+
if __name__ == "__main__":
|
| 237 |
+
build_room()
|
| 238 |
+
'''
|
| 239 |
+
(out_dir / "room_layout.py").write_text(text, encoding="utf-8")
|
| 240 |
+
|
| 241 |
+
|
| 242 |
+
def run_blender(config_path: Path, args: argparse.Namespace) -> dict:
|
| 243 |
+
blender = args.blender_bin or os.environ.get("BLENDER_BIN") or shutil.which("blender") or "/usr/bin/blender"
|
| 244 |
+
cmd = [blender, "--background", "--factory-startup", "-noaudio", "-t", str(args.blender_threads), "--python", str(Path(__file__).resolve()), "--", "--config", str(config_path)]
|
| 245 |
+
if args.xvfb and shutil.which("xvfb-run"):
|
| 246 |
+
cmd = ["xvfb-run", "-a", *cmd]
|
| 247 |
+
proc = subprocess.run(cmd, cwd=ROOT, capture_output=True, text=True, timeout=args.timeout)
|
| 248 |
+
tail = "\n".join((proc.stdout + "\n" + proc.stderr).strip().splitlines()[-80:])
|
| 249 |
+
return {"ok": proc.returncode == 0 and "Traceback" not in tail, "returncode": proc.returncode, "stdout_stderr_tail": tail}
|
| 250 |
+
|
| 251 |
+
|
| 252 |
+
def stage_reused_source_views(input_manifest_path: Path | None, out_dir: Path) -> None:
|
| 253 |
+
if input_manifest_path is None:
|
| 254 |
+
return
|
| 255 |
+
source_dir = input_manifest_path.parent / "renders" / "source"
|
| 256 |
+
target_dir = out_dir / "renders" / "source"
|
| 257 |
+
if source_dir.resolve() == target_dir.resolve() or not source_dir.exists():
|
| 258 |
+
return
|
| 259 |
+
target_dir.mkdir(parents=True, exist_ok=True)
|
| 260 |
+
for index in range(len(VIEW_SPECS)):
|
| 261 |
+
candidates = [source_dir / f"view_{index:02d}{extension}" for extension in (".png", ".jpg", ".jpeg")]
|
| 262 |
+
source = next((path for path in candidates if path.exists()), None)
|
| 263 |
+
if source is None:
|
| 264 |
+
continue
|
| 265 |
+
for stale in target_dir.glob(f"view_{index:02d}.*"):
|
| 266 |
+
stale.unlink()
|
| 267 |
+
shutil.copy2(source, target_dir / source.name)
|
| 268 |
+
|
| 269 |
+
|
| 270 |
+
def make_comparison(out_dir: Path, config: dict) -> Path | None:
|
| 271 |
+
try:
|
| 272 |
+
from PIL import Image, ImageDraw
|
| 273 |
+
except Exception:
|
| 274 |
+
return None
|
| 275 |
+
extension = image_extension(config)
|
| 276 |
+
source = out_dir / "renders" / f"source_sheet{extension}"
|
| 277 |
+
code = out_dir / "renders" / f"code_layout_sheet{extension}"
|
| 278 |
+
if not source.exists() or not code.exists():
|
| 279 |
+
return None
|
| 280 |
+
rows = [("source non-full room GLB", source), ("code layout", code)]
|
| 281 |
+
images = [Image.open(path).convert("RGB") for _, path in rows]
|
| 282 |
+
width = max(image.width for image in images)
|
| 283 |
+
label_h = 28
|
| 284 |
+
pad = 8
|
| 285 |
+
height = sum(image.height + label_h + pad for image in images) + pad
|
| 286 |
+
background = tuple(config.get("canvas_background_rgb", (245, 246, 248)))
|
| 287 |
+
canvas = Image.new("RGB", (width + pad * 2, height), background)
|
| 288 |
+
draw = ImageDraw.Draw(canvas)
|
| 289 |
+
y = pad
|
| 290 |
+
for (label, _path), image in zip(rows, images):
|
| 291 |
+
draw.text((pad, y), label, fill=(20, 20, 20))
|
| 292 |
+
y += label_h
|
| 293 |
+
canvas.paste(image, (pad, y))
|
| 294 |
+
y += image.height + pad
|
| 295 |
+
out = out_dir / "renders" / f"layout_comparison{extension}"
|
| 296 |
+
save_image(canvas, out, config)
|
| 297 |
+
return out
|
| 298 |
+
|
| 299 |
+
|
| 300 |
+
def save_image(image, path: Path, config: dict) -> None:
|
| 301 |
+
if path.suffix.lower() in {".jpg", ".jpeg"}:
|
| 302 |
+
image.convert("RGB").save(path, format="JPEG", quality=int(config.get("jpeg_quality", 85)), optimize=True)
|
| 303 |
+
else:
|
| 304 |
+
image.save(path, format="PNG")
|
| 305 |
+
|
| 306 |
+
|
| 307 |
+
def make_view_sheet(view_dir: Path, sheet_path: Path, config: dict) -> Path | None:
|
| 308 |
+
try:
|
| 309 |
+
from PIL import Image, ImageDraw
|
| 310 |
+
except Exception:
|
| 311 |
+
return None
|
| 312 |
+
extension = image_extension(config)
|
| 313 |
+
view_paths = [view_dir / f"view_{idx:02d}{extension}" for idx in range(len(VIEW_SPECS))]
|
| 314 |
+
if not all(path.exists() for path in view_paths):
|
| 315 |
+
return None
|
| 316 |
+
thumb = max(max(Image.open(path).size) for path in view_paths)
|
| 317 |
+
pad = 8
|
| 318 |
+
header = 28
|
| 319 |
+
images = []
|
| 320 |
+
for (label, _kind, _az, _el), path in zip(VIEW_SPECS, view_paths):
|
| 321 |
+
image = Image.open(path).convert("RGB")
|
| 322 |
+
image.thumbnail((thumb, thumb))
|
| 323 |
+
images.append((label, image))
|
| 324 |
+
background = tuple(config.get("canvas_background_rgb", (245, 246, 248)))
|
| 325 |
+
canvas = Image.new("RGB", (len(images) * thumb + (len(images) + 1) * pad, thumb + header + pad * 2), background)
|
| 326 |
+
draw = ImageDraw.Draw(canvas)
|
| 327 |
+
for index, (label, image) in enumerate(images):
|
| 328 |
+
x = pad + index * (thumb + pad)
|
| 329 |
+
y = header + pad
|
| 330 |
+
canvas.paste(image, (x + (thumb - image.width) // 2, y + (thumb - image.height) // 2))
|
| 331 |
+
draw.text((x + 6, 8), label, fill=(20, 20, 20))
|
| 332 |
+
sheet_path.parent.mkdir(parents=True, exist_ok=True)
|
| 333 |
+
save_image(canvas, sheet_path, config)
|
| 334 |
+
return sheet_path
|
| 335 |
+
|
| 336 |
+
|
| 337 |
+
def postprocess_source_views(view_dir: Path, foreground_lift: float) -> None:
|
| 338 |
+
if foreground_lift <= 1.0001:
|
| 339 |
+
return
|
| 340 |
+
try:
|
| 341 |
+
from PIL import Image, ImageChops
|
| 342 |
+
except Exception:
|
| 343 |
+
return
|
| 344 |
+
for path in sorted(view_dir.glob("view_*.*")):
|
| 345 |
+
image = Image.open(path).convert("RGB")
|
| 346 |
+
corners = [
|
| 347 |
+
image.getpixel((0, 0)),
|
| 348 |
+
image.getpixel((image.width - 1, 0)),
|
| 349 |
+
image.getpixel((0, image.height - 1)),
|
| 350 |
+
image.getpixel((image.width - 1, image.height - 1)),
|
| 351 |
+
]
|
| 352 |
+
bg = tuple(round(sum(color[channel] for color in corners) / 4) for channel in range(3))
|
| 353 |
+
diff = ImageChops.difference(image, Image.new("RGB", image.size, bg)).convert("L")
|
| 354 |
+
mask = diff.point(lambda value: 255 if value > 8 else 0)
|
| 355 |
+
pixels = image.load()
|
| 356 |
+
mask_pixels = mask.load()
|
| 357 |
+
for y in range(image.height):
|
| 358 |
+
for x in range(image.width):
|
| 359 |
+
if mask_pixels[x, y]:
|
| 360 |
+
r, g, b = pixels[x, y]
|
| 361 |
+
pixels[x, y] = (
|
| 362 |
+
min(255, int(r * foreground_lift)),
|
| 363 |
+
min(255, int(g * foreground_lift)),
|
| 364 |
+
min(255, int(b * foreground_lift)),
|
| 365 |
+
)
|
| 366 |
+
if path.suffix.lower() in {".jpg", ".jpeg"}:
|
| 367 |
+
image.save(path, format="JPEG", quality=85, optimize=True)
|
| 368 |
+
else:
|
| 369 |
+
image.save(path)
|
| 370 |
+
|
| 371 |
+
|
| 372 |
+
def composite_views_on_background(view_dir: Path, background: tuple[int, int, int] = (245, 246, 248)) -> None:
|
| 373 |
+
try:
|
| 374 |
+
from PIL import Image
|
| 375 |
+
except Exception:
|
| 376 |
+
return
|
| 377 |
+
if not view_dir.exists():
|
| 378 |
+
return
|
| 379 |
+
for path in sorted(view_dir.glob("view_*.*")):
|
| 380 |
+
image = Image.open(path)
|
| 381 |
+
if image.mode != "RGBA":
|
| 382 |
+
if image.mode != "RGB":
|
| 383 |
+
image.convert("RGB").save(path)
|
| 384 |
+
continue
|
| 385 |
+
bg = Image.new("RGBA", image.size, (*background, 255))
|
| 386 |
+
composited = Image.alpha_composite(bg, image).convert("RGB")
|
| 387 |
+
if path.suffix.lower() in {".jpg", ".jpeg"}:
|
| 388 |
+
composited.save(path, format="JPEG", quality=85, optimize=True)
|
| 389 |
+
else:
|
| 390 |
+
composited.save(path)
|
| 391 |
+
|
| 392 |
+
|
| 393 |
+
def finalize_view_format(view_dir: Path, config: dict) -> None:
|
| 394 |
+
if image_extension(config) != ".jpg" or not view_dir.exists():
|
| 395 |
+
return
|
| 396 |
+
try:
|
| 397 |
+
from PIL import Image
|
| 398 |
+
except Exception:
|
| 399 |
+
return
|
| 400 |
+
quality = int(config.get("jpeg_quality", 85))
|
| 401 |
+
for source in sorted(view_dir.glob("view_*.png")):
|
| 402 |
+
target = source.with_suffix(".jpg")
|
| 403 |
+
Image.open(source).convert("RGB").save(target, format="JPEG", quality=quality, optimize=True)
|
| 404 |
+
source.unlink()
|
| 405 |
+
|
| 406 |
+
|
| 407 |
+
def validate_rendered_views(view_dir: Path, config: dict) -> list[str]:
|
| 408 |
+
try:
|
| 409 |
+
from PIL import Image, ImageStat
|
| 410 |
+
except Exception:
|
| 411 |
+
return []
|
| 412 |
+
extension = image_extension(config)
|
| 413 |
+
errors = []
|
| 414 |
+
for index in range(len(VIEW_SPECS)):
|
| 415 |
+
path = view_dir / f"view_{index:02d}{extension}"
|
| 416 |
+
if not path.exists():
|
| 417 |
+
errors.append(f"missing:{repo_rel(path)}")
|
| 418 |
+
continue
|
| 419 |
+
stats = ImageStat.Stat(Image.open(path).convert("RGB"))
|
| 420 |
+
if max(stats.mean) < 3.0 or max(high for _low, high in stats.extrema) < 8:
|
| 421 |
+
errors.append(f"blank_or_black:{repo_rel(path)}")
|
| 422 |
+
return errors
|
| 423 |
+
|
| 424 |
+
|
| 425 |
+
def summarize_layout_quality(manifest_path: Path) -> dict:
|
| 426 |
+
if not manifest_path.exists():
|
| 427 |
+
return {"usable_components": 0, "warnings": ["missing_layout_manifest"]}
|
| 428 |
+
data = load_json(manifest_path)
|
| 429 |
+
warnings = []
|
| 430 |
+
usable = 0
|
| 431 |
+
max_center = 0.0
|
| 432 |
+
max_size = 0.0
|
| 433 |
+
for component in data.get("components", []):
|
| 434 |
+
if not component.get("usable"):
|
| 435 |
+
warnings.append({
|
| 436 |
+
"component_id": component.get("component_id"),
|
| 437 |
+
"object_id": component.get("object_id"),
|
| 438 |
+
"reason": component.get("skip_reason", "not_usable"),
|
| 439 |
+
})
|
| 440 |
+
continue
|
| 441 |
+
usable += 1
|
| 442 |
+
error = component.get("alignment_error") or {}
|
| 443 |
+
center_l2 = float(error.get("center_l2") or 0.0)
|
| 444 |
+
size_l2 = float(error.get("size_l2") or 0.0)
|
| 445 |
+
max_center = max(max_center, center_l2)
|
| 446 |
+
max_size = max(max_size, size_l2)
|
| 447 |
+
source_size = component.get("source_bounds", {}).get("size") or []
|
| 448 |
+
source_diag = sum(float(v) ** 2 for v in source_size) ** 0.5 if source_size else 1.0
|
| 449 |
+
relative_size = size_l2 / max(source_diag, 1e-6)
|
| 450 |
+
if center_l2 > 0.05 or relative_size > 0.15:
|
| 451 |
+
warnings.append({
|
| 452 |
+
"component_id": component.get("component_id"),
|
| 453 |
+
"object_id": component.get("object_id"),
|
| 454 |
+
"category_slug": component.get("category_slug"),
|
| 455 |
+
"center_l2": center_l2,
|
| 456 |
+
"size_l2": size_l2,
|
| 457 |
+
"relative_size_l2": relative_size,
|
| 458 |
+
})
|
| 459 |
+
return {
|
| 460 |
+
"usable_components": usable,
|
| 461 |
+
"max_center_l2": max_center,
|
| 462 |
+
"max_size_l2": max_size,
|
| 463 |
+
"warning_count": len(warnings),
|
| 464 |
+
"warnings": warnings[:20],
|
| 465 |
+
}
|
| 466 |
+
|
| 467 |
+
|
| 468 |
+
def main() -> None:
|
| 469 |
+
parser = argparse.ArgumentParser(description=__doc__)
|
| 470 |
+
parser.add_argument("--house")
|
| 471 |
+
parser.add_argument("--room")
|
| 472 |
+
parser.add_argument("--room-glb", type=Path)
|
| 473 |
+
parser.add_argument("--out-dir", type=Path)
|
| 474 |
+
parser.add_argument("--input-manifest", type=Path, help="Render code layout from an existing manifest, preserving any layout_override entries.")
|
| 475 |
+
parser.add_argument("--asset-version", choices=("v1", "v2", "v3", "v4"), default="v2", help="Asset object-code version to instantiate (default: v2).")
|
| 476 |
+
parser.add_argument("--max-components", type=int, default=0)
|
| 477 |
+
parser.add_argument("--render-res", type=int, default=1024)
|
| 478 |
+
parser.add_argument("--samples", type=int, default=128)
|
| 479 |
+
parser.add_argument("--denoise", action=argparse.BooleanOptionalAction, default=False, help="Enable Cycles render denoising (disabled by default because some headless builds emit black output).")
|
| 480 |
+
parser.add_argument("--image-format", choices=("jpeg", "png"), default="jpeg", help="Format for views, sheets, and comparison (default: jpeg).")
|
| 481 |
+
parser.add_argument("--jpeg-quality", type=int, choices=range(1, 101), default=85, metavar="1-100")
|
| 482 |
+
parser.add_argument("--render-engine", choices=("eevee", "cycles", "workbench"), default=os.environ.get("FRONT_ROOM_RENDER_ENGINE", "cycles"))
|
| 483 |
+
parser.add_argument("--scale-mode", choices=("bbox", "uniform"), default="bbox")
|
| 484 |
+
parser.add_argument("--source-view-yaw-offset", type=float, default=0.0)
|
| 485 |
+
parser.add_argument("--code-view-yaw-offset", type=float, default=0.0)
|
| 486 |
+
parser.add_argument("--source-topdown-roll", type=float, default=0.0)
|
| 487 |
+
parser.add_argument("--code-topdown-roll", type=float, default=0.0)
|
| 488 |
+
parser.add_argument("--source-only", action="store_true", help="Only render source room views/sheet; skip code layout rebuild/render.")
|
| 489 |
+
parser.add_argument("--reuse-source", action="store_true", help="Reuse existing source views/sheet; render code layout/comparison only.")
|
| 490 |
+
parser.add_argument("--world-strength", type=float, default=0.8)
|
| 491 |
+
parser.add_argument("--sun-energy", type=float, default=1.4)
|
| 492 |
+
parser.add_argument("--fill-energy", type=float, default=125.0)
|
| 493 |
+
parser.add_argument("--exposure", type=float, default=-0.15)
|
| 494 |
+
parser.add_argument("--source-sun-energy", type=float, default=2.0)
|
| 495 |
+
parser.add_argument("--source-fill-energy", type=float, default=180.0)
|
| 496 |
+
parser.add_argument("--source-exposure", type=float, default=0.15)
|
| 497 |
+
parser.add_argument("--source-material-lift", type=float, default=1.8)
|
| 498 |
+
parser.add_argument("--source-foreground-lift", type=float, default=1.35)
|
| 499 |
+
parser.add_argument("--source-key-energy", type=float, default=650.0)
|
| 500 |
+
parser.add_argument("--timeout", type=int, default=900)
|
| 501 |
+
parser.add_argument("--blender-threads", type=int, default=5)
|
| 502 |
+
parser.add_argument("--blender-bin")
|
| 503 |
+
parser.add_argument("--no-xvfb", dest="xvfb", action="store_false")
|
| 504 |
+
parser.add_argument("--config", type=Path, help="Internal Blender-side config path.")
|
| 505 |
+
parser.set_defaults(xvfb=True)
|
| 506 |
+
argv = sys.argv[sys.argv.index("--") + 1:] if IN_BLENDER and "--" in sys.argv else None
|
| 507 |
+
args = parser.parse_args(argv)
|
| 508 |
+
|
| 509 |
+
if IN_BLENDER:
|
| 510 |
+
if not args.config:
|
| 511 |
+
raise SystemExit("Blender mode requires --config")
|
| 512 |
+
_run_in_blender(resolve_repo(args.config))
|
| 513 |
+
return
|
| 514 |
+
|
| 515 |
+
if not args.input_manifest and (not args.house or not args.room):
|
| 516 |
+
raise SystemExit("provide --house and --room, or --input-manifest")
|
| 517 |
+
config_path = build_config(args)
|
| 518 |
+
out_dir = resolve_repo(load_json(config_path)["out_dir"])
|
| 519 |
+
config = load_json(config_path)
|
| 520 |
+
if config.get("reuse_source"):
|
| 521 |
+
input_manifest_path = resolve_repo(config["input_manifest"]) if config.get("input_manifest") else None
|
| 522 |
+
stage_reused_source_views(input_manifest_path, out_dir)
|
| 523 |
+
result = run_blender(config_path, args)
|
| 524 |
+
extension = image_extension(config)
|
| 525 |
+
composite_views_on_background(out_dir / "renders" / "source")
|
| 526 |
+
composite_views_on_background(out_dir / "renders" / "code_layout")
|
| 527 |
+
if not config.get("reuse_source"):
|
| 528 |
+
postprocess_source_views(out_dir / "renders" / "source", float(config.get("source_foreground_lift", 1.35)))
|
| 529 |
+
finalize_view_format(out_dir / "renders" / "source", config)
|
| 530 |
+
finalize_view_format(out_dir / "renders" / "code_layout", config)
|
| 531 |
+
source_only = bool(config.get("source_only"))
|
| 532 |
+
render_errors = validate_rendered_views(out_dir / "renders" / "source", config)
|
| 533 |
+
if not source_only:
|
| 534 |
+
render_errors.extend(validate_rendered_views(out_dir / "renders" / "code_layout", config))
|
| 535 |
+
source_sheet = make_view_sheet(out_dir / "renders" / "source", out_dir / "renders" / f"source_sheet{extension}", config)
|
| 536 |
+
code_sheet = None if source_only else make_view_sheet(out_dir / "renders" / "code_layout", out_dir / "renders" / f"code_layout_sheet{extension}", config)
|
| 537 |
+
comparison = None if source_only else make_comparison(out_dir, config)
|
| 538 |
+
quality = summarize_layout_quality(out_dir / "layout_manifest.json")
|
| 539 |
+
status = {
|
| 540 |
+
"ok": bool(result.get("ok")) and not render_errors and (out_dir / "layout_manifest.json").exists() and source_sheet is not None and (source_only or code_sheet is not None),
|
| 541 |
+
"source_only": source_only,
|
| 542 |
+
"config": repo_rel(config_path),
|
| 543 |
+
"layout_manifest": repo_rel(out_dir / "layout_manifest.json"),
|
| 544 |
+
"room_layout_py": repo_rel(out_dir / "room_layout.py"),
|
| 545 |
+
"source_sheet": repo_rel(source_sheet) if source_sheet else None,
|
| 546 |
+
"code_layout_sheet": repo_rel(code_sheet) if code_sheet else None,
|
| 547 |
+
"comparison": repo_rel(comparison) if comparison else None,
|
| 548 |
+
"render_validation_errors": render_errors,
|
| 549 |
+
"quality": quality,
|
| 550 |
+
"blender": result,
|
| 551 |
+
}
|
| 552 |
+
write_json(out_dir / "layout_build_status.json", status)
|
| 553 |
+
print(json.dumps(status, indent=2, ensure_ascii=False))
|
| 554 |
+
if not status["ok"]:
|
| 555 |
+
raise SystemExit(1)
|
| 556 |
+
|
| 557 |
+
|
| 558 |
+
def _run_in_blender(config_path: Path) -> None:
|
| 559 |
+
config = load_json(config_path)
|
| 560 |
+
out_dir = resolve_repo(config["out_dir"])
|
| 561 |
+
render_dir = resolve_repo(config["render_dir"])
|
| 562 |
+
render_dir.mkdir(parents=True, exist_ok=True)
|
| 563 |
+
|
| 564 |
+
source_room_glb = resolve_repo(config["source_room_glb"])
|
| 565 |
+
if config.get("input_manifest"):
|
| 566 |
+
manifest = load_json(resolve_repo(config["input_manifest"]))
|
| 567 |
+
manifest["components"] = [dict(component) for component in config["components"]]
|
| 568 |
+
manifest["house_id"] = config["house_id"]
|
| 569 |
+
manifest["room_id"] = config["room_id"]
|
| 570 |
+
manifest["source_room_glb"] = config["source_room_glb"]
|
| 571 |
+
manifest["asset_version"] = config.get("asset_version", "v2")
|
| 572 |
+
manifest["scale_mode"] = config.get("scale_mode", manifest.get("scale_mode", "bbox"))
|
| 573 |
+
manifest.setdefault("coordinate_source", "component_glb_world_bounds")
|
| 574 |
+
manifest.setdefault("transform_rule", "XY PCA yaw delta plus bbox or uniform scale from component/code bounds; translate transformed code bbox center to component bbox center")
|
| 575 |
+
else:
|
| 576 |
+
components = []
|
| 577 |
+
for item in config["components"]:
|
| 578 |
+
component = dict(item)
|
| 579 |
+
if not component.get("source_glb_exists") or not component.get("object_py_exists"):
|
| 580 |
+
component["usable"] = False
|
| 581 |
+
component["skip_reason"] = "missing_source_or_object_py"
|
| 582 |
+
components.append(component)
|
| 583 |
+
continue
|
| 584 |
+
bounds = measure_glb_bounds(resolve_repo(component["source_glb"]))
|
| 585 |
+
component["source_bounds"] = bounds
|
| 586 |
+
component["usable"] = True
|
| 587 |
+
components.append(component)
|
| 588 |
+
|
| 589 |
+
manifest = {
|
| 590 |
+
"house_id": config["house_id"],
|
| 591 |
+
"room_id": config["room_id"],
|
| 592 |
+
"source_room_glb": config["source_room_glb"],
|
| 593 |
+
"asset_version": config.get("asset_version", "v2"),
|
| 594 |
+
"coordinate_source": "component_glb_world_bounds",
|
| 595 |
+
"scale_mode": config.get("scale_mode", "bbox"),
|
| 596 |
+
"camera_alignment": {
|
| 597 |
+
"source_view_yaw_offset_deg": config.get("source_view_yaw_offset_deg", 0.0),
|
| 598 |
+
"code_view_yaw_offset_deg": config.get("code_view_yaw_offset_deg", 0.0),
|
| 599 |
+
"source_topdown_roll_deg": config.get("source_topdown_roll_deg", 0.0),
|
| 600 |
+
"code_topdown_roll_deg": config.get("code_topdown_roll_deg", 0.0),
|
| 601 |
+
},
|
| 602 |
+
"transform_rule": "XY PCA yaw delta plus bbox or uniform scale from component/code bounds; translate transformed code bbox center to component bbox center",
|
| 603 |
+
"components": components,
|
| 604 |
+
}
|
| 605 |
+
write_json(out_dir / "layout_manifest.json", manifest)
|
| 606 |
+
|
| 607 |
+
if not config.get("reuse_source"):
|
| 608 |
+
clear_scene()
|
| 609 |
+
import_glb(source_room_glb)
|
| 610 |
+
lift_scene_materials(float(config.get("source_material_lift", 1.3)))
|
| 611 |
+
render_five_views(
|
| 612 |
+
render_dir / "source",
|
| 613 |
+
render_dir / "source_sheet.png",
|
| 614 |
+
source_render_config(config),
|
| 615 |
+
view_yaw_offset_deg=float(config.get("source_view_yaw_offset_deg", 0.0)),
|
| 616 |
+
topdown_roll_deg=float(config.get("source_topdown_roll_deg", 0.0)),
|
| 617 |
+
)
|
| 618 |
+
if config.get("source_only"):
|
| 619 |
+
print(json.dumps({"ok": True, "source_only": True, "layout_manifest": repo_rel(out_dir / "layout_manifest.json")}, indent=2))
|
| 620 |
+
return
|
| 621 |
+
|
| 622 |
+
clear_scene()
|
| 623 |
+
build_room_from_data(manifest)
|
| 624 |
+
write_json(out_dir / "layout_manifest.json", manifest)
|
| 625 |
+
render_five_views(
|
| 626 |
+
render_dir / "code_layout",
|
| 627 |
+
render_dir / "code_layout_sheet.png",
|
| 628 |
+
config,
|
| 629 |
+
view_yaw_offset_deg=float(config.get("code_view_yaw_offset_deg", 0.0)),
|
| 630 |
+
topdown_roll_deg=float(config.get("code_topdown_roll_deg", 0.0)),
|
| 631 |
+
)
|
| 632 |
+
print(json.dumps({"ok": True, "layout_manifest": repo_rel(out_dir / "layout_manifest.json")}, indent=2))
|
| 633 |
+
|
| 634 |
+
|
| 635 |
+
def clear_scene() -> None:
|
| 636 |
+
import bpy
|
| 637 |
+
bpy.ops.object.select_all(action="SELECT")
|
| 638 |
+
bpy.ops.object.delete()
|
| 639 |
+
|
| 640 |
+
|
| 641 |
+
def import_glb(path: Path) -> list:
|
| 642 |
+
import bpy
|
| 643 |
+
before = set(bpy.data.objects)
|
| 644 |
+
bpy.ops.import_scene.gltf(filepath=str(path))
|
| 645 |
+
return [obj for obj in bpy.data.objects if obj not in before]
|
| 646 |
+
|
| 647 |
+
|
| 648 |
+
def scene_bounds(objects) -> dict:
|
| 649 |
+
import mathutils
|
| 650 |
+
meshes = [obj for obj in objects if obj.type == "MESH"]
|
| 651 |
+
if not meshes:
|
| 652 |
+
raise RuntimeError("no mesh objects for bounds")
|
| 653 |
+
mn = mathutils.Vector((1e9, 1e9, 1e9))
|
| 654 |
+
mx = mathutils.Vector((-1e9, -1e9, -1e9))
|
| 655 |
+
for obj in meshes:
|
| 656 |
+
for corner in obj.bound_box:
|
| 657 |
+
world = obj.matrix_world @ mathutils.Vector(corner)
|
| 658 |
+
for axis in range(3):
|
| 659 |
+
mn[axis] = min(mn[axis], world[axis])
|
| 660 |
+
mx[axis] = max(mx[axis], world[axis])
|
| 661 |
+
center = (mn + mx) * 0.5
|
| 662 |
+
size = mx - mn
|
| 663 |
+
return {
|
| 664 |
+
"min": [float(v) for v in mn],
|
| 665 |
+
"max": [float(v) for v in mx],
|
| 666 |
+
"center": [float(v) for v in center],
|
| 667 |
+
"size": [float(v) for v in size],
|
| 668 |
+
}
|
| 669 |
+
|
| 670 |
+
|
| 671 |
+
def xy_principal_axis(objects) -> dict:
|
| 672 |
+
import math
|
| 673 |
+
import mathutils
|
| 674 |
+
points: list[tuple[float, float]] = []
|
| 675 |
+
for obj in objects:
|
| 676 |
+
if obj.type != "MESH":
|
| 677 |
+
continue
|
| 678 |
+
for vertex in obj.data.vertices:
|
| 679 |
+
world = obj.matrix_world @ vertex.co
|
| 680 |
+
points.append((float(world.x), float(world.y)))
|
| 681 |
+
if len(points) < 3:
|
| 682 |
+
return {"yaw_deg": 0.0, "anisotropy": 1.0, "reliable": False, "point_count": len(points)}
|
| 683 |
+
mean_x = sum(point[0] for point in points) / len(points)
|
| 684 |
+
mean_y = sum(point[1] for point in points) / len(points)
|
| 685 |
+
cxx = sum((point[0] - mean_x) ** 2 for point in points) / len(points)
|
| 686 |
+
cyy = sum((point[1] - mean_y) ** 2 for point in points) / len(points)
|
| 687 |
+
cxy = sum((point[0] - mean_x) * (point[1] - mean_y) for point in points) / len(points)
|
| 688 |
+
angle = 0.5 * math.atan2(2.0 * cxy, cxx - cyy)
|
| 689 |
+
trace = cxx + cyy
|
| 690 |
+
delta = math.sqrt(max((cxx - cyy) ** 2 + 4.0 * cxy * cxy, 0.0))
|
| 691 |
+
major = max((trace + delta) * 0.5, 1e-12)
|
| 692 |
+
minor = max((trace - delta) * 0.5, 1e-12)
|
| 693 |
+
anisotropy = math.sqrt(major / minor)
|
| 694 |
+
reliable = anisotropy >= 1.15
|
| 695 |
+
if not reliable:
|
| 696 |
+
angle = 0.0
|
| 697 |
+
return {
|
| 698 |
+
"yaw_deg": math.degrees(angle),
|
| 699 |
+
"anisotropy": float(anisotropy),
|
| 700 |
+
"reliable": reliable,
|
| 701 |
+
"point_count": len(points),
|
| 702 |
+
}
|
| 703 |
+
|
| 704 |
+
|
| 705 |
+
def measure_glb_bounds(path: Path) -> dict:
|
| 706 |
+
clear_scene()
|
| 707 |
+
objects = import_glb(path)
|
| 708 |
+
bounds = scene_bounds(objects)
|
| 709 |
+
bounds["xy_principal_axis"] = xy_principal_axis(objects)
|
| 710 |
+
bounds["mesh_count"] = len([obj for obj in objects if obj.type == "MESH"])
|
| 711 |
+
clear_scene()
|
| 712 |
+
return bounds
|
| 713 |
+
|
| 714 |
+
|
| 715 |
+
def build_room_from_manifest(manifest_path: Path):
|
| 716 |
+
manifest = load_json(resolve_repo(manifest_path))
|
| 717 |
+
return build_room_from_data(manifest)
|
| 718 |
+
|
| 719 |
+
|
| 720 |
+
def build_room_from_data(manifest: dict):
|
| 721 |
+
created_roots = []
|
| 722 |
+
for index, component in enumerate(manifest.get("components", []), start=1):
|
| 723 |
+
if not component.get("usable"):
|
| 724 |
+
continue
|
| 725 |
+
root = instantiate_component(component, index=index, scale_mode=manifest.get("scale_mode", "bbox"))
|
| 726 |
+
created_roots.append(root)
|
| 727 |
+
return created_roots
|
| 728 |
+
|
| 729 |
+
|
| 730 |
+
def _set_generated_socket_default(socket, value) -> None:
|
| 731 |
+
current = socket.default_value
|
| 732 |
+
if isinstance(value, (int, float)) and not isinstance(current, (int, float, bool)):
|
| 733 |
+
try:
|
| 734 |
+
length = len(current)
|
| 735 |
+
except TypeError:
|
| 736 |
+
length = 0
|
| 737 |
+
if length == 4:
|
| 738 |
+
value = (value, value, value, 1.0)
|
| 739 |
+
elif length > 1:
|
| 740 |
+
value = tuple(value for _ in range(length))
|
| 741 |
+
socket.default_value = value
|
| 742 |
+
|
| 743 |
+
|
| 744 |
+
def instantiate_component(component: dict, *, index: int, scale_mode: str = "bbox"):
|
| 745 |
+
import bpy
|
| 746 |
+
import mathutils
|
| 747 |
+
|
| 748 |
+
object_py = resolve_repo(component["object_py"])
|
| 749 |
+
prefix = slug_identifier(component.get("component_id") or f"component_{index}", max_len=80)
|
| 750 |
+
source_bounds = component["source_bounds"]
|
| 751 |
+
source_center = mathutils.Vector(source_bounds["center"])
|
| 752 |
+
source_size = mathutils.Vector(source_bounds["size"])
|
| 753 |
+
|
| 754 |
+
before = set(bpy.data.objects)
|
| 755 |
+
namespace = {
|
| 756 |
+
"__file__": str(object_py),
|
| 757 |
+
"_roomscript_set_socket_default": _set_generated_socket_default,
|
| 758 |
+
}
|
| 759 |
+
code_text = object_py.read_text(encoding="utf-8").replace(".amount =", ".width =")
|
| 760 |
+
code_text = code_text.replace(
|
| 761 |
+
"node.inputs[input_name].default_value = value",
|
| 762 |
+
"_roomscript_set_socket_default(node.inputs[input_name], value)",
|
| 763 |
+
)
|
| 764 |
+
exec(compile(code_text, str(object_py), "exec"), namespace)
|
| 765 |
+
if not callable(namespace.get("build_object")):
|
| 766 |
+
raise RuntimeError(f"missing build_object in {object_py}")
|
| 767 |
+
namespace["build_object"]()
|
| 768 |
+
created = [obj for obj in bpy.data.objects if obj not in before]
|
| 769 |
+
meshes = [obj for obj in created if obj.type == "MESH"]
|
| 770 |
+
if not meshes:
|
| 771 |
+
raise RuntimeError(f"object code produced no meshes: {object_py}")
|
| 772 |
+
|
| 773 |
+
code_bounds = scene_bounds(created)
|
| 774 |
+
code_axis = xy_principal_axis(created)
|
| 775 |
+
code_center = mathutils.Vector(code_bounds["center"])
|
| 776 |
+
code_size = mathutils.Vector(code_bounds["size"])
|
| 777 |
+
ratios = [float(source_size[i] / code_size[i]) for i in range(3) if abs(code_size[i]) > 1e-6 and abs(source_size[i]) > 1e-6]
|
| 778 |
+
ratios.sort()
|
| 779 |
+
uniform_scale = ratios[len(ratios) // 2] if ratios else 1.0
|
| 780 |
+
source_axis = source_bounds.get("xy_principal_axis") or {}
|
| 781 |
+
source_yaw = math.radians(float(source_axis.get("yaw_deg", 0.0))) if source_axis.get("reliable") else 0.0
|
| 782 |
+
code_yaw = math.radians(float(code_axis.get("yaw_deg", 0.0))) if code_axis.get("reliable") else 0.0
|
| 783 |
+
yaw_delta = source_yaw - code_yaw
|
| 784 |
+
|
| 785 |
+
root = bpy.data.objects.new(f"inst__{prefix}", None)
|
| 786 |
+
root.empty_display_type = "CUBE"
|
| 787 |
+
root.empty_display_size = max(max(source_size), 0.2)
|
| 788 |
+
bpy.context.collection.objects.link(root)
|
| 789 |
+
created_set = set(created)
|
| 790 |
+
for obj in created:
|
| 791 |
+
obj.name = f"{prefix}__{obj.name}"
|
| 792 |
+
if obj.type == "MESH":
|
| 793 |
+
obj.data.name = f"{prefix}__{obj.data.name}"
|
| 794 |
+
isolate_materials(obj, prefix)
|
| 795 |
+
obj["room_component_id"] = component.get("component_id") or ""
|
| 796 |
+
obj["room_object_id"] = component.get("object_id") or ""
|
| 797 |
+
if obj.parent not in created_set:
|
| 798 |
+
obj.parent = root
|
| 799 |
+
obj.matrix_parent_inverse = root.matrix_world.inverted()
|
| 800 |
+
|
| 801 |
+
root.rotation_euler = (0.0, 0.0, yaw_delta)
|
| 802 |
+
root.location = (0.0, 0.0, 0.0)
|
| 803 |
+
root.scale = (1.0, 1.0, 1.0)
|
| 804 |
+
bpy.context.view_layer.update()
|
| 805 |
+
rotated_bounds = scene_bounds(created)
|
| 806 |
+
rotated_center = mathutils.Vector(rotated_bounds["center"])
|
| 807 |
+
rotated_size = mathutils.Vector(rotated_bounds["size"])
|
| 808 |
+
|
| 809 |
+
scale_xyz = [float(source_size[i] / rotated_size[i]) if abs(rotated_size[i]) > 1e-6 else uniform_scale for i in range(3)]
|
| 810 |
+
if scale_mode == "uniform":
|
| 811 |
+
valid = [value for value in scale_xyz if value > 0]
|
| 812 |
+
uniform_scale = sorted(valid)[len(valid) // 2] if valid else uniform_scale
|
| 813 |
+
scale_vector = mathutils.Vector((uniform_scale, uniform_scale, uniform_scale))
|
| 814 |
+
else:
|
| 815 |
+
scale_vector = mathutils.Vector(scale_xyz)
|
| 816 |
+
root.scale = tuple(scale_vector)
|
| 817 |
+
bpy.context.view_layer.update()
|
| 818 |
+
scaled_bounds = scene_bounds(created)
|
| 819 |
+
scaled_center = mathutils.Vector(scaled_bounds["center"])
|
| 820 |
+
root.location += source_center - scaled_center
|
| 821 |
+
bpy.context.view_layer.update()
|
| 822 |
+
fit_corrections = []
|
| 823 |
+
if scale_mode == "bbox":
|
| 824 |
+
def current_error():
|
| 825 |
+
bounds = scene_bounds(created)
|
| 826 |
+
center = mathutils.Vector(bounds["center"])
|
| 827 |
+
size = mathutils.Vector(bounds["size"])
|
| 828 |
+
center_delta = center - source_center
|
| 829 |
+
size_delta = size - source_size
|
| 830 |
+
return float(center_delta.length + size_delta.length), bounds
|
| 831 |
+
|
| 832 |
+
best_score, best_bounds = current_error()
|
| 833 |
+
best_scale = tuple(root.scale)
|
| 834 |
+
best_location = root.location.copy()
|
| 835 |
+
for _iteration in range(2):
|
| 836 |
+
interim_bounds = scene_bounds(created)
|
| 837 |
+
interim_center = mathutils.Vector(interim_bounds["center"])
|
| 838 |
+
interim_size = mathutils.Vector(interim_bounds["size"])
|
| 839 |
+
correction = mathutils.Vector((
|
| 840 |
+
float(source_size.x / interim_size.x) if abs(interim_size.x) > 1e-6 else 1.0,
|
| 841 |
+
float(source_size.y / interim_size.y) if abs(interim_size.y) > 1e-6 else 1.0,
|
| 842 |
+
float(source_size.z / interim_size.z) if abs(interim_size.z) > 1e-6 else 1.0,
|
| 843 |
+
))
|
| 844 |
+
if max(abs(correction.x - 1.0), abs(correction.y - 1.0), abs(correction.z - 1.0)) < 0.01:
|
| 845 |
+
root.location += source_center - interim_center
|
| 846 |
+
bpy.context.view_layer.update()
|
| 847 |
+
score, bounds = current_error()
|
| 848 |
+
if score < best_score:
|
| 849 |
+
best_score, best_bounds = score, bounds
|
| 850 |
+
best_scale = tuple(root.scale)
|
| 851 |
+
best_location = root.location.copy()
|
| 852 |
+
break
|
| 853 |
+
root.scale = (
|
| 854 |
+
root.scale.x * correction.x,
|
| 855 |
+
root.scale.y * correction.y,
|
| 856 |
+
root.scale.z * correction.z,
|
| 857 |
+
)
|
| 858 |
+
bpy.context.view_layer.update()
|
| 859 |
+
adjusted_bounds = scene_bounds(created)
|
| 860 |
+
adjusted_center = mathutils.Vector(adjusted_bounds["center"])
|
| 861 |
+
root.location += source_center - adjusted_center
|
| 862 |
+
bpy.context.view_layer.update()
|
| 863 |
+
score, bounds = current_error()
|
| 864 |
+
accepted = score <= best_score
|
| 865 |
+
fit_corrections.append([float(correction.x), float(correction.y), float(correction.z), bool(accepted)])
|
| 866 |
+
if accepted:
|
| 867 |
+
best_score, best_bounds = score, bounds
|
| 868 |
+
best_scale = tuple(root.scale)
|
| 869 |
+
best_location = root.location.copy()
|
| 870 |
+
else:
|
| 871 |
+
break
|
| 872 |
+
root.scale = best_scale
|
| 873 |
+
root.location = best_location
|
| 874 |
+
bpy.context.view_layer.update()
|
| 875 |
+
applied_override = apply_layout_override(root, created, source_center, component)
|
| 876 |
+
final_bounds = scene_bounds(created)
|
| 877 |
+
final_center = mathutils.Vector(final_bounds["center"])
|
| 878 |
+
final_size = mathutils.Vector(final_bounds["size"])
|
| 879 |
+
center_error = final_center - source_center
|
| 880 |
+
size_error = final_size - source_size
|
| 881 |
+
component["code_bounds"] = code_bounds
|
| 882 |
+
component["code_bounds"]["xy_principal_axis"] = code_axis
|
| 883 |
+
component["final_world_bounds"] = final_bounds
|
| 884 |
+
component["alignment_error"] = {
|
| 885 |
+
"center_delta": [float(v) for v in center_error],
|
| 886 |
+
"center_l2": float(center_error.length),
|
| 887 |
+
"size_delta": [float(v) for v in size_error],
|
| 888 |
+
"size_l2": float(size_error.length),
|
| 889 |
+
}
|
| 890 |
+
component["room_transform"] = {
|
| 891 |
+
"root_name": root.name,
|
| 892 |
+
"location": [float(v) for v in root.location],
|
| 893 |
+
"rotation_euler": [float(v) for v in root.rotation_euler],
|
| 894 |
+
"yaw_delta_deg": math.degrees(yaw_delta),
|
| 895 |
+
"scale_mode": scale_mode,
|
| 896 |
+
"scale_xyz": [float(v) for v in scale_vector],
|
| 897 |
+
"fit_corrections": fit_corrections,
|
| 898 |
+
"final_scale_xyz": [float(root.scale.x), float(root.scale.y), float(root.scale.z)],
|
| 899 |
+
"uniform_scale": float(uniform_scale),
|
| 900 |
+
}
|
| 901 |
+
if applied_override is not None:
|
| 902 |
+
component["applied_layout_override"] = applied_override
|
| 903 |
+
component["scale_ratios_xyz"] = ratios
|
| 904 |
+
return root
|
| 905 |
+
|
| 906 |
+
|
| 907 |
+
def _float_list(value, *, length: int, default: list[float]) -> list[float]:
|
| 908 |
+
if not isinstance(value, (list, tuple)):
|
| 909 |
+
return list(default)
|
| 910 |
+
out = []
|
| 911 |
+
for item in list(value)[:length]:
|
| 912 |
+
try:
|
| 913 |
+
out.append(float(item))
|
| 914 |
+
except Exception:
|
| 915 |
+
out.append(0.0)
|
| 916 |
+
while len(out) < length:
|
| 917 |
+
out.append(float(default[len(out)]))
|
| 918 |
+
return out
|
| 919 |
+
|
| 920 |
+
|
| 921 |
+
def apply_layout_override(root, created, source_center, component: dict) -> dict | None:
|
| 922 |
+
override = component.get("layout_override") or component.get("repair_override")
|
| 923 |
+
if not isinstance(override, dict) or override.get("enabled", True) is False:
|
| 924 |
+
return None
|
| 925 |
+
import bpy
|
| 926 |
+
import mathutils
|
| 927 |
+
|
| 928 |
+
translation = _float_list(
|
| 929 |
+
override.get("translation_delta_world", override.get("translation_delta", override.get("translation_delta_xyz"))),
|
| 930 |
+
length=3,
|
| 931 |
+
default=[0.0, 0.0, 0.0],
|
| 932 |
+
)
|
| 933 |
+
if isinstance(override.get("translation_delta_xy"), (list, tuple)):
|
| 934 |
+
xy = _float_list(override.get("translation_delta_xy"), length=2, default=[0.0, 0.0])
|
| 935 |
+
translation[0], translation[1] = xy
|
| 936 |
+
try:
|
| 937 |
+
translation[2] += float(override.get("z_delta", 0.0) or 0.0)
|
| 938 |
+
except Exception:
|
| 939 |
+
pass
|
| 940 |
+
scale_multiplier = _float_list(override.get("scale_multiplier_xyz"), length=3, default=[1.0, 1.0, 1.0])
|
| 941 |
+
try:
|
| 942 |
+
yaw_delta_deg = float(override.get("yaw_delta_deg", 0.0) or 0.0)
|
| 943 |
+
except Exception:
|
| 944 |
+
yaw_delta_deg = 0.0
|
| 945 |
+
|
| 946 |
+
root.rotation_euler[2] += math.radians(yaw_delta_deg)
|
| 947 |
+
root.scale = (
|
| 948 |
+
root.scale.x * scale_multiplier[0],
|
| 949 |
+
root.scale.y * scale_multiplier[1],
|
| 950 |
+
root.scale.z * scale_multiplier[2],
|
| 951 |
+
)
|
| 952 |
+
bpy.context.view_layer.update()
|
| 953 |
+
|
| 954 |
+
absolute_center = override.get("absolute_center")
|
| 955 |
+
if isinstance(absolute_center, (list, tuple)):
|
| 956 |
+
target_center = mathutils.Vector(_float_list(absolute_center, length=3, default=[source_center.x, source_center.y, source_center.z]))
|
| 957 |
+
else:
|
| 958 |
+
target_center = source_center + mathutils.Vector(translation)
|
| 959 |
+
bounds = scene_bounds(created)
|
| 960 |
+
current_center = mathutils.Vector(bounds["center"])
|
| 961 |
+
root.location += target_center - current_center
|
| 962 |
+
bpy.context.view_layer.update()
|
| 963 |
+
return {
|
| 964 |
+
"enabled": True,
|
| 965 |
+
"translation_delta_world": translation,
|
| 966 |
+
"yaw_delta_deg": yaw_delta_deg,
|
| 967 |
+
"scale_multiplier_xyz": scale_multiplier,
|
| 968 |
+
"target_center": [float(v) for v in target_center],
|
| 969 |
+
"summary": override.get("summary") or override.get("why"),
|
| 970 |
+
}
|
| 971 |
+
|
| 972 |
+
|
| 973 |
+
def isolate_materials(obj, prefix: str) -> None:
|
| 974 |
+
for index, material in enumerate(list(obj.data.materials)):
|
| 975 |
+
if material is None:
|
| 976 |
+
continue
|
| 977 |
+
copied = material.copy()
|
| 978 |
+
copied.name = f"{prefix}__{material.name}"
|
| 979 |
+
obj.data.materials[index] = copied
|
| 980 |
+
|
| 981 |
+
|
| 982 |
+
def lift_scene_materials(scale: float) -> None:
|
| 983 |
+
if scale <= 1.0001:
|
| 984 |
+
return
|
| 985 |
+
import bpy
|
| 986 |
+
for material in bpy.data.materials:
|
| 987 |
+
color = list(getattr(material, "diffuse_color", (1.0, 1.0, 1.0, 1.0)))
|
| 988 |
+
lifted = [min(float(channel) * scale, 1.0) for channel in color[:3]] + [color[3] if len(color) > 3 else 1.0]
|
| 989 |
+
material.diffuse_color = lifted
|
| 990 |
+
if material.use_nodes and material.node_tree:
|
| 991 |
+
bsdf = material.node_tree.nodes.get("Principled BSDF")
|
| 992 |
+
if bsdf and "Base Color" in bsdf.inputs:
|
| 993 |
+
base = list(bsdf.inputs["Base Color"].default_value)
|
| 994 |
+
bsdf.inputs["Base Color"].default_value = [min(float(channel) * scale, 1.0) for channel in base[:3]] + [base[3] if len(base) > 3 else 1.0]
|
| 995 |
+
|
| 996 |
+
|
| 997 |
+
def source_render_config(config: dict) -> dict:
|
| 998 |
+
out = dict(config)
|
| 999 |
+
out["sun_energy"] = float(config.get("source_sun_energy", 2.0))
|
| 1000 |
+
out["fill_energy"] = float(config.get("source_fill_energy", 180.0))
|
| 1001 |
+
out["exposure"] = float(config.get("source_exposure", 0.15))
|
| 1002 |
+
out["key_energy"] = float(config.get("source_key_energy", 650.0))
|
| 1003 |
+
return out
|
| 1004 |
+
|
| 1005 |
+
|
| 1006 |
+
def setup_light(config: dict, center, span: float) -> None:
|
| 1007 |
+
import bpy
|
| 1008 |
+
import math
|
| 1009 |
+
world = bpy.data.worlds.get("World") or bpy.data.worlds.new("World")
|
| 1010 |
+
bpy.context.scene.world = world
|
| 1011 |
+
world.use_nodes = True
|
| 1012 |
+
bg = world.node_tree.nodes.get("Background")
|
| 1013 |
+
if bg:
|
| 1014 |
+
bg.inputs[0].default_value = (0.95, 0.96, 0.98, 1.0)
|
| 1015 |
+
bg.inputs[1].default_value = float(config.get("world_strength", 0.8))
|
| 1016 |
+
sun_data = bpy.data.lights.new("Sun", type="SUN")
|
| 1017 |
+
sun_data.energy = float(config.get("sun_energy", 1.65))
|
| 1018 |
+
sun = bpy.data.objects.new("Sun", sun_data)
|
| 1019 |
+
bpy.context.collection.objects.link(sun)
|
| 1020 |
+
sun.rotation_euler = (math.radians(50), math.radians(10), math.radians(35))
|
| 1021 |
+
fill_data = bpy.data.lights.new("Fill", type="AREA")
|
| 1022 |
+
fill_data.energy = float(config.get("fill_energy", 145.0))
|
| 1023 |
+
fill_data.size = max(span * 2.5, 4.0)
|
| 1024 |
+
fill = bpy.data.objects.new("Fill", fill_data)
|
| 1025 |
+
bpy.context.collection.objects.link(fill)
|
| 1026 |
+
offset = max(span * 2.8, 2.8)
|
| 1027 |
+
fill.location = (center.x + offset, center.y - offset, center.z + max(span * 3.0, 3.0))
|
| 1028 |
+
key_energy = float(config.get("key_energy", 0.0))
|
| 1029 |
+
if key_energy > 0.0:
|
| 1030 |
+
key_data = bpy.data.lights.new("SourceKey", type="AREA")
|
| 1031 |
+
key_data.energy = key_energy
|
| 1032 |
+
key_data.size = max(span * 3.5, 4.0)
|
| 1033 |
+
key = bpy.data.objects.new("SourceKey", key_data)
|
| 1034 |
+
bpy.context.collection.objects.link(key)
|
| 1035 |
+
key.location = (center.x, center.y - max(span * 1.8, 2.2), center.z + max(span * 1.6, 2.0))
|
| 1036 |
+
direction = center - key.location
|
| 1037 |
+
key.rotation_euler = direction.to_track_quat("-Z", "Y").to_euler()
|
| 1038 |
+
|
| 1039 |
+
|
| 1040 |
+
def render_five_views(view_dir: Path, sheet_path: Path, config: dict, *,
|
| 1041 |
+
view_yaw_offset_deg: float = 0.0,
|
| 1042 |
+
topdown_roll_deg: float = 0.0,
|
| 1043 |
+
camera_bounds: dict | None = None) -> None:
|
| 1044 |
+
import bpy
|
| 1045 |
+
import mathutils
|
| 1046 |
+
from math import cos, radians, sin
|
| 1047 |
+
|
| 1048 |
+
view_dir.mkdir(parents=True, exist_ok=True)
|
| 1049 |
+
meshes = [obj for obj in bpy.data.objects if obj.type == "MESH"]
|
| 1050 |
+
scene_content_bounds = scene_bounds(meshes)
|
| 1051 |
+
bounds = camera_bounds or scene_content_bounds
|
| 1052 |
+
mn = mathutils.Vector(bounds["min"])
|
| 1053 |
+
mx = mathutils.Vector(bounds["max"])
|
| 1054 |
+
center = mathutils.Vector(bounds["center"])
|
| 1055 |
+
size = mx - mn
|
| 1056 |
+
span = max(size.x, size.y, size.z, 0.5)
|
| 1057 |
+
radius = max(size.length * 0.5, 0.5)
|
| 1058 |
+
|
| 1059 |
+
setup_light(config, center, span)
|
| 1060 |
+
cam_data = bpy.data.cameras.new("Camera")
|
| 1061 |
+
cam = bpy.data.objects.new("Camera", cam_data)
|
| 1062 |
+
bpy.context.collection.objects.link(cam)
|
| 1063 |
+
bpy.context.scene.camera = cam
|
| 1064 |
+
scene = bpy.context.scene
|
| 1065 |
+
scene.render.resolution_x = int(config.get("render_res", 1024))
|
| 1066 |
+
scene.render.resolution_y = int(config.get("render_res", 1024))
|
| 1067 |
+
extension = image_extension(config)
|
| 1068 |
+
if extension == ".jpg":
|
| 1069 |
+
scene.render.image_settings.file_format = "JPEG"
|
| 1070 |
+
scene.render.image_settings.color_mode = "RGB"
|
| 1071 |
+
scene.render.image_settings.quality = int(config.get("jpeg_quality", 85))
|
| 1072 |
+
else:
|
| 1073 |
+
scene.render.image_settings.file_format = "PNG"
|
| 1074 |
+
scene.render.image_settings.color_mode = "RGBA"
|
| 1075 |
+
composite_background = config.get("alpha_composite_background_rgb")
|
| 1076 |
+
if composite_background is not None:
|
| 1077 |
+
def _srgb_to_linear(value: int) -> float:
|
| 1078 |
+
channel = float(value) / 255.0
|
| 1079 |
+
return channel / 12.92 if channel <= 0.04045 else ((channel + 0.055) / 1.055) ** 2.4
|
| 1080 |
+
|
| 1081 |
+
color = [_srgb_to_linear(int(value)) for value in composite_background]
|
| 1082 |
+
scene.render.film_transparent = True
|
| 1083 |
+
scene.view_settings.view_transform = "Standard"
|
| 1084 |
+
scene.view_settings.look = "None"
|
| 1085 |
+
scene.view_settings.exposure = 0.0
|
| 1086 |
+
scene.view_settings.gamma = 1.0
|
| 1087 |
+
if hasattr(scene, "compositing_node_group"):
|
| 1088 |
+
compositor = bpy.data.node_groups.new("StrictAlphaComposite", "CompositorNodeTree")
|
| 1089 |
+
scene.compositing_node_group = compositor
|
| 1090 |
+
else:
|
| 1091 |
+
scene.use_nodes = True
|
| 1092 |
+
compositor = scene.node_tree
|
| 1093 |
+
nodes = compositor.nodes
|
| 1094 |
+
nodes.clear()
|
| 1095 |
+
render_layers = nodes.new("CompositorNodeRLayers")
|
| 1096 |
+
background = nodes.new("CompositorNodeRGB")
|
| 1097 |
+
background.outputs[0].default_value = (*color, 1.0)
|
| 1098 |
+
alpha_over = nodes.new("CompositorNodeAlphaOver")
|
| 1099 |
+
factor_input = next(socket for socket in alpha_over.inputs if socket.name in {"Factor", "Fac"})
|
| 1100 |
+
background_input = next(socket for socket in alpha_over.inputs if socket.name in {"Background", "Image"})
|
| 1101 |
+
foreground_input = next(
|
| 1102 |
+
socket for socket in alpha_over.inputs
|
| 1103 |
+
if socket.name in {"Foreground", "Image"} and socket != background_input
|
| 1104 |
+
)
|
| 1105 |
+
factor_input.default_value = 1.0
|
| 1106 |
+
compositor.links.new(background.outputs[0], background_input)
|
| 1107 |
+
compositor.links.new(render_layers.outputs["Image"], foreground_input)
|
| 1108 |
+
if hasattr(scene, "compositing_node_group"):
|
| 1109 |
+
compositor.interface.new_socket(name="Image", in_out="OUTPUT", socket_type="NodeSocketColor")
|
| 1110 |
+
composite = nodes.new("NodeGroupOutput")
|
| 1111 |
+
else:
|
| 1112 |
+
composite = nodes.new("CompositorNodeComposite")
|
| 1113 |
+
compositor.links.new(alpha_over.outputs[0], composite.inputs["Image"])
|
| 1114 |
+
else:
|
| 1115 |
+
try:
|
| 1116 |
+
scene.render.film_transparent = bool(config.get("film_transparent", True))
|
| 1117 |
+
except Exception:
|
| 1118 |
+
pass
|
| 1119 |
+
if composite_background is None:
|
| 1120 |
+
try:
|
| 1121 |
+
scene.view_settings.exposure = float(config.get("exposure", -0.15))
|
| 1122 |
+
except Exception:
|
| 1123 |
+
pass
|
| 1124 |
+
render_engine = str(config.get("render_engine", "cycles")).lower()
|
| 1125 |
+
if render_engine == "cycles":
|
| 1126 |
+
scene.render.engine = "CYCLES"
|
| 1127 |
+
try:
|
| 1128 |
+
scene.cycles.device = "CPU"
|
| 1129 |
+
scene.cycles.samples = int(config.get("samples", 64))
|
| 1130 |
+
scene.cycles.use_denoising = bool(config.get("denoise", True))
|
| 1131 |
+
except Exception:
|
| 1132 |
+
pass
|
| 1133 |
+
elif render_engine == "workbench":
|
| 1134 |
+
scene.render.engine = "BLENDER_WORKBENCH"
|
| 1135 |
+
else:
|
| 1136 |
+
for engine in ("BLENDER_EEVEE_NEXT", "BLENDER_EEVEE"):
|
| 1137 |
+
try:
|
| 1138 |
+
scene.render.engine = engine
|
| 1139 |
+
break
|
| 1140 |
+
except Exception:
|
| 1141 |
+
continue
|
| 1142 |
+
try:
|
| 1143 |
+
scene.eevee.taa_render_samples = int(config.get("samples", 4))
|
| 1144 |
+
scene.eevee.use_gtao = True
|
| 1145 |
+
scene.eevee.gtao_distance = 3.0
|
| 1146 |
+
scene.eevee.gtao_factor = 1.2
|
| 1147 |
+
except Exception:
|
| 1148 |
+
pass
|
| 1149 |
+
|
| 1150 |
+
if render_engine == "cycles":
|
| 1151 |
+
effective_samples = int(scene.cycles.samples)
|
| 1152 |
+
elif render_engine == "workbench":
|
| 1153 |
+
effective_samples = None
|
| 1154 |
+
else:
|
| 1155 |
+
effective_samples = int(scene.eevee.taa_render_samples)
|
| 1156 |
+
|
| 1157 |
+
def look_at(target, *, roll_deg: float = 0.0):
|
| 1158 |
+
direction = mathutils.Vector(target) - cam.location
|
| 1159 |
+
quat = direction.to_track_quat("-Z", "Y")
|
| 1160 |
+
if abs(roll_deg) > 1e-6:
|
| 1161 |
+
quat = quat @ mathutils.Quaternion((0.0, 0.0, 1.0), radians(roll_deg))
|
| 1162 |
+
cam.rotation_euler = quat.to_euler()
|
| 1163 |
+
|
| 1164 |
+
rendered = []
|
| 1165 |
+
for idx, (label, kind, az_deg, el_deg) in enumerate(VIEW_SPECS):
|
| 1166 |
+
actual_az_deg = az_deg + view_yaw_offset_deg
|
| 1167 |
+
if kind == "topdown":
|
| 1168 |
+
cam_data.type = "ORTHO"
|
| 1169 |
+
cam_data.ortho_scale = max(size.x, size.y, 0.5) * 1.12
|
| 1170 |
+
cam.location = (center.x, center.y, mx.z + span * 2.5)
|
| 1171 |
+
look_at((center.x, center.y, center.z), roll_deg=topdown_roll_deg)
|
| 1172 |
+
else:
|
| 1173 |
+
cam_data.type = "PERSP"
|
| 1174 |
+
cam_data.lens = 50
|
| 1175 |
+
az = radians(actual_az_deg)
|
| 1176 |
+
perspective_el_deg = float(config.get("perspective_elevation_deg", el_deg))
|
| 1177 |
+
el = radians(perspective_el_deg)
|
| 1178 |
+
dist = radius * float(config.get("perspective_distance_scale", 3.0))
|
| 1179 |
+
target_z = mn.z + size.z * float(config.get("perspective_target_z_fraction", 0.5))
|
| 1180 |
+
cam.location = (
|
| 1181 |
+
center.x + sin(az) * cos(el) * dist,
|
| 1182 |
+
center.y - cos(az) * cos(el) * dist,
|
| 1183 |
+
center.z + sin(el) * dist,
|
| 1184 |
+
)
|
| 1185 |
+
look_at((center.x, center.y, target_z))
|
| 1186 |
+
out_path = view_dir / f"view_{idx:02d}{extension}"
|
| 1187 |
+
render_path = out_path
|
| 1188 |
+
scene.render.filepath = str(render_path)
|
| 1189 |
+
bpy.ops.render.render(write_still=True)
|
| 1190 |
+
rendered.append({
|
| 1191 |
+
"view": idx,
|
| 1192 |
+
"label": label,
|
| 1193 |
+
"kind": kind,
|
| 1194 |
+
"base_azimuth": az_deg,
|
| 1195 |
+
"azimuth": actual_az_deg if kind != "topdown" else az_deg,
|
| 1196 |
+
"elevation": perspective_el_deg if kind != "topdown" else 90.0,
|
| 1197 |
+
"view_yaw_offset_deg": view_yaw_offset_deg,
|
| 1198 |
+
"topdown_roll_deg": topdown_roll_deg if kind == "topdown" else 0.0,
|
| 1199 |
+
"file": repo_rel(out_path),
|
| 1200 |
+
})
|
| 1201 |
+
camera_contract = {
|
| 1202 |
+
"bounds": bounds,
|
| 1203 |
+
"view_yaw_offset_deg": view_yaw_offset_deg,
|
| 1204 |
+
"topdown_roll_deg": topdown_roll_deg,
|
| 1205 |
+
"perspective_elevation_deg": float(config.get("perspective_elevation_deg", 30.0)),
|
| 1206 |
+
"perspective_target_z_fraction": float(config.get("perspective_target_z_fraction", 0.5)),
|
| 1207 |
+
"perspective_distance_scale": float(config.get("perspective_distance_scale", 3.0)),
|
| 1208 |
+
"resolution": [scene.render.resolution_x, scene.render.resolution_y],
|
| 1209 |
+
"render_engine": scene.render.engine,
|
| 1210 |
+
"effective_samples": effective_samples,
|
| 1211 |
+
"view_transform": scene.view_settings.view_transform,
|
| 1212 |
+
"look": scene.view_settings.look,
|
| 1213 |
+
"exposure": scene.view_settings.exposure,
|
| 1214 |
+
"gamma": scene.view_settings.gamma,
|
| 1215 |
+
}
|
| 1216 |
+
camera_contract_hash = hashlib.sha256(
|
| 1217 |
+
json.dumps(camera_contract, sort_keys=True, separators=(",", ":")).encode("utf-8")
|
| 1218 |
+
).hexdigest()
|
| 1219 |
+
write_json(view_dir / "manifest.json", {
|
| 1220 |
+
"views": rendered,
|
| 1221 |
+
"bounds": scene_content_bounds,
|
| 1222 |
+
"camera_contract": camera_contract,
|
| 1223 |
+
"camera_contract_hash": camera_contract_hash,
|
| 1224 |
+
"camera_bounds_shared": camera_bounds is not None,
|
| 1225 |
+
"alpha_composite": "blender_compositor_alpha_over" if composite_background is not None else None,
|
| 1226 |
+
"composite_background_rgb": composite_background,
|
| 1227 |
+
"view_yaw_offset_deg": view_yaw_offset_deg,
|
| 1228 |
+
"topdown_roll_deg": topdown_roll_deg,
|
| 1229 |
+
})
|
| 1230 |
+
|
| 1231 |
+
|
| 1232 |
+
if __name__ == "__main__":
|
| 1233 |
+
main()
|
data/rooms/rooms-00018.tar
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:9e90f334f78d57c69355467174cc9d3813f534101073fa2ae0cdf2b81bc83c52
|
| 3 |
+
size 144332800
|
data/rooms/rooms-00019.tar
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:cd475642e4cd614508849949fda24b8821d8630ed92b3e5c16596769b11b7a92
|
| 3 |
+
size 147722240
|
data/rooms/rooms-00024.tar
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:a875808f2b67b70aee62aeddca9c8ee944edbdb18b0ed25d4d3aef3cd883edc2
|
| 3 |
+
size 144465920
|
data/rooms/rooms-00025.tar
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:942f4b4245e7ef88291ea58263b435ba76691df4616ee54ebd9ed85882499d5e
|
| 3 |
+
size 144609280
|
data/rooms/rooms-00030.tar
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:572dadbbb289e580027d791b38310d8de065c7187b55191c49d1a6c489ee0448
|
| 3 |
+
size 139345920
|
data/rooms/rooms-00031.tar
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:08a3dfb1f9571b91fa22f39a265871929249ac0d7decf2c1e3a3c828d7c43244
|
| 3 |
+
size 151173120
|
data/rooms/rooms-00144.tar
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:8fb932f81deb3859e89d470dcc44a21669a9113c1fbcb369533ef5571b2018ca
|
| 3 |
+
size 140042240
|
data/rooms/rooms-00145.tar
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:c80653f3b12337c8f9cd55963c78fc7b4d3b222f49033831531977e55c259a6c
|
| 3 |
+
size 142858240
|
data/rooms/rooms-00150.tar
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:8cae5fba10af79c36bb061e65ff77d883e9a0774e16cc65994c1e6237e35b4f7
|
| 3 |
+
size 152821760
|
data/rooms/rooms-00151.tar
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:8b843559ec5df6d8ae7cf7b7dfb155b3f4e1b8872c79679517919f9a9a196ce3
|
| 3 |
+
size 150425600
|
data/rooms/rooms-00178.tar
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:f01e9e1d621bd4f06623fc5ac8deed75964eb1b8a6c5389e7612991cdce6897b
|
| 3 |
+
size 141240320
|
data/rooms/rooms-00179.tar
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:420cae25dd6e87fabf9144514d54f80b7cbd3d3581ad724067b4f11258ac9759
|
| 3 |
+
size 141762560
|
data/rooms/rooms-00186.tar
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:dfe6b55d11fb4df3e3cecb8b1b1a859951971ba782a07a30e2b7b9acd634d0d2
|
| 3 |
+
size 146667520
|
data/rooms/rooms-00187.tar
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:8bfd17fb46028e5595d4d9229619975f96194d0296fb6ef66d4e6cb6e7d0e815
|
| 3 |
+
size 142981120
|
data/rooms/rooms-00192.tar
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:7ea240552723d25a65d08183e4962e05a330bcf6f50a24e0b9a7c9c5a70c3e36
|
| 3 |
+
size 147200000
|
data/rooms/rooms-00193.tar
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:84a65501105dd661d0ab618b002c37897a7002da8c62a402d0afaf584c7357e7
|
| 3 |
+
size 140564480
|
release_manifest.json
ADDED
|
@@ -0,0 +1,36 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{
|
| 2 |
+
"asset_count": 13917,
|
| 3 |
+
"asset_selected_bytes": 55119087917,
|
| 4 |
+
"assets_per_shard": 200,
|
| 5 |
+
"dataset_name": "3D-Front-Code",
|
| 6 |
+
"filters": {
|
| 7 |
+
"exclude": [
|
| 8 |
+
"files outside selected trees",
|
| 9 |
+
"attempts",
|
| 10 |
+
"v4_wall renders",
|
| 11 |
+
"room Blend",
|
| 12 |
+
"batch logs",
|
| 13 |
+
"source GLBs",
|
| 14 |
+
"PNG duplicates",
|
| 15 |
+
"caches",
|
| 16 |
+
"credentials"
|
| 17 |
+
],
|
| 18 |
+
"keep": [
|
| 19 |
+
"asset reference",
|
| 20 |
+
"asset v4/best",
|
| 21 |
+
"asset render",
|
| 22 |
+
"asset object.blend",
|
| 23 |
+
"room v4/best",
|
| 24 |
+
"room v4 renders",
|
| 25 |
+
"room v4_wall code and audits"
|
| 26 |
+
]
|
| 27 |
+
},
|
| 28 |
+
"format_version": "1.0",
|
| 29 |
+
"image_format": "jpeg",
|
| 30 |
+
"jpeg_quality": 85,
|
| 31 |
+
"room_count": 21202,
|
| 32 |
+
"room_selected_bytes": 29712559077,
|
| 33 |
+
"rooms_per_shard": 100,
|
| 34 |
+
"selected_content_bytes": 84831646994,
|
| 35 |
+
"source_glb_included": false
|
| 36 |
+
}
|