Skip to content

Official Codebase of 3DCodeVerse

Python

texture pass: `3dcode texture pass` textures the picked round's own GLB, not the last build (B5)

gaoypengfc8b617434a3
diff --git a/harness/codeverse3d/cli/texture_cmd.py b/harness/codeverse3d/cli/texture_cmd.py
index cb545e6e..f80e3d78 100644
--- a/harness/codeverse3d/cli/texture_cmd.py
+++ b/harness/codeverse3d/cli/texture_cmd.py
@@ -14,7 +14,6 @@ import typer
from codeverse3d.cli import _common as C
from codeverse3d.cli._common import console, kv_table, warn
-from codeverse3d.contracts.common import Track
from codeverse3d.contracts.plan import ScenePlan
texture_app = typer.Typer(name="texture", help="Text-to-image texturing: object pass + scene texture pack.",
@@ -39,15 +38,26 @@ def pass_(
size: Annotated[int, typer.Option("--size", min=256, max=2048)] = 1024,
runs_dir: RunsDirOpt = None,
) -> None:
- """Texture the run's artifacts/object.glb → artifacts/object_textured.glb (+ textures/)."""
- ws = C.open_workspace(slug, runs_dir)
- spec = C.load_spec(ws)
- if spec.track not in (Track.STATIC_OBJECT, Track.ARTICULATED_OBJECT):
- raise C.CliError(f"texture pass is for object tracks; {spec.track.value} runs use `3dcode texture scene-pack`")
+ """Texture the picked round's object.glb (``addons.select``) → artifacts/object_textured.glb (+ textures/)."""
+ from codeverse3d.addons import select
from codeverse3d.cost.instrument import run_ledger
+ from codeverse3d.record.record import RecordError, load_record
from codeverse3d.spatial.tool_common import load_plan
- from codeverse3d.texturing.run import texture_pass
+ from codeverse3d.texturing.run import texture_pass, texture_supported
+ ws = C.open_workspace(slug, runs_dir)
+ spec = C.load_spec(ws)
+ if not texture_supported(spec.track):
+ raise C.CliError(f"texture pass is for object tracks; {spec.track.value} runs use `3dcode texture scene-pack`")
+ try:
+ rec = load_record(ws)
+ except RecordError as e:
+ raise C.CliError(str(e), code=2) from e
+ picked = select.summarise(ws.root, record=rec).picked_round
+ rnd = next((r for r in rec.rounds if r.index == picked), None)
+ if rnd is None or (glb := select.round_file(ws, rnd)) is None:
+ raise C.CliError(f"no picked round with its own object.glb to texture in {ws.root.name} (picked: {picked})")
+ sheet = ws.rebase(rnd.renders.contact_sheet) if rnd.renders is not None and rnd.renders.contact_sheet else None
plan = load_plan(ws.plan_path)
# a post-hoc pass joins the run's ledger when it has one, else the per-process log;
@@ -56,7 +66,7 @@ def pass_(
run_ledger(ws.root, run=ws.root.name, create=False)):
rep = texture_pass(ws, spec, plan, model_id=model or spec.backends.planner,
image_model=_image_model(image_model), judge=judge,
- judge_model_id=judge_model, size=size)
+ judge_model_id=judge_model, size=size, glb_in=glb, sheet=sheet)
_print_report(rep, ws)
diff --git a/harness/tests/flywheel_cli/test_select.py b/harness/tests/flywheel_cli/test_select.py
index c42db0e5..05eb57b2 100644
--- a/harness/tests/flywheel_cli/test_select.py
+++ b/harness/tests/flywheel_cli/test_select.py
@@ -301,3 +301,18 @@ def test_round_outputs_are_the_rounds_own_never_the_last_builds(tmp_path: Path):
assert select.round_file(ws, rec.rounds[0]) is None
assert select.round_file(ws, rec.rounds[1]) == ws.artifacts / "object.glb"
assert select.round_complexity_block(ws, rec.rounds[1]) == {"index": 0.9}
+
+
+def test_cli_texture_pass_textures_the_picked_round_not_the_last_build(tmp_path: Path, monkeypatch):
+ """`3dcode texture pass` handed texture_pass no GLB, so it textured artifacts/object.glb — the
+ LAST round's since D80 — whichever round the run hands over."""
+ ws, _ = make_fake_run(tmp_path / "runs", "chair", scores=(0.90, 0.50)) # r00 is picked, r01 built last
+ seen: dict = {}
+ monkeypatch.setattr("codeverse3d.texturing.run.texture_pass", lambda *a, **kw: seen.update(kw))
+ monkeypatch.setattr("codeverse3d.cli.texture_cmd._print_report", lambda rep, ws: None)
+ monkeypatch.setattr("codeverse3d.cli.texture_cmd._image_model", lambda name: None)
+ monkeypatch.setattr("codeverse3d.spatial.tool_common.load_plan", lambda path: None)
+ r = runner.invoke(app, ["texture", "pass", "chair", "--runs-dir", str(tmp_path / "runs"), "--no-judge"])
+ assert r.exit_code == 0, r.output
+ assert seen["glb_in"] == ws.round_artifacts(0) / "object.glb"
+ assert seen["sheet"] is not None and seen["sheet"].is_relative_to(ws.renders_dir(0))