Skip to content

Access of physicallybased.info materials still not possible #313

Closed

Description

@bernhard-42

Unfortunately I can't reopen #288
I still can't dowwnload physicallybased material info, despite #288 being closed

In [1]: from importlib.metadata import version

In [2]: version("mat-vis-client"), version("py-materials")
Out[2]: ('0.6.4', '3.10.0')

...

In [10]: v = Vis("physicallybased", "Aluminum")

In [11]: v.to_threejs()
---------------------------------------------------------------------------
MaterialNotStagedError                    Traceback (most recent call last)
Cell In[11], line 1
----> 1 v.to_threejs()

File ~/Development/CAD/build123d-fork/.venv/lib/python3.13/site-packages/pymat/vis/_model.py:576, in Vis.to_threejs(self)
    567 """Shorthand for ``pymat.vis.to_threejs(material)`` — method form.
    568 
    569 Same output as the module-level adapter. Use this when you have
   (...)    572 that's explicitly function-composition oriented.
    573 """
    574 from pymat.vis.adapters import to_threejs
--> 576 return to_threejs(self)

File ~/Development/CAD/build123d-fork/.venv/lib/python3.13/site-packages/pymat/vis/adapters.py:86, in to_threejs(obj)
     79 def to_threejs(obj: MaterialOrVis) -> dict[str, Any]:
     80     """Format as a Three.js MeshPhysicalMaterial-compatible dict.
     81 
     82     Accepts either a ``Material`` or a standalone ``Vis``. Reads PBR
     83     scalars and texture maps from ``obj.vis`` (or from ``obj`` itself
     84     if it's a Vis). Delegates to mat-vis's generic adapter.
     85     """
---> 86     return _to_threejs(_extract_scalars(obj), _extract_textures(obj))

File ~/Development/CAD/build123d-fork/.venv/lib/python3.13/site-packages/pymat/vis/adapters.py:76, in _extract_textures(obj)
     74 if not vis.has_mapping:
     75     return {}
---> 76 return vis.textures

File ~/Development/CAD/build123d-fork/.venv/lib/python3.13/site-packages/pymat/vis/_model.py:531, in Vis.textures(self)
    528     return {}
    530 if not self._fetched:
--> 531     self._fetch()
    533 return self._textures

File ~/Development/CAD/build123d-fork/.venv/lib/python3.13/site-packages/pymat/vis/_model.py:644, in Vis._fetch(self)
    642 # Thin delegate — matches the ADR-0002 principle.
    643 src, mid, tier = self._identity_args()
--> 644 textures = self.client.fetch_all_textures(src, mid, tier=tier)
    645 # Write via super() so we don't trip the identity-invalidation
    646 # guard (`_textures` and `_fetched` aren't identity fields, so
    647 # direct assignment would work too; using super() documents that
    648 # we're explicitly bypassing the cache-invalidation side effect).
    649 super().__setattr__("_textures", textures)

File ~/Development/CAD/build123d-fork/.venv/lib/python3.13/site-packages/mat_vis_client/client.py:1343, in MatVisClient.fetch_all_textures(self, source, material_id, tier, tag)
   1341 if tag is not None and tag != self._tag:
   1342     return self.at(tag).fetch_all_textures(source, material_id, tier)
-> 1343 resolved = self._resolve_material_id(source, material_id, tier)
   1344 chs = self.channels(source, resolved, tier)
   1345 return {ch: self.fetch_texture(source, resolved, ch, tier) for ch in chs}

File ~/Development/CAD/build123d-fork/.venv/lib/python3.13/site-packages/mat_vis_client/client.py:1289, in MatVisClient._resolve_material_id(self, source, material_id, tier)
   1286         return resolved
   1287     # #280: the user passed a name; carry it through so the
   1288     # error message names *which* material in their batch broke.
-> 1289     raise MaterialNotStagedError(
   1290         source=source,
   1291         material_id=resolved,
   1292         tier=tier,
   1293         original_name=material_id,
   1294     )
   1296 # Build the "available materials at this tier" hint from the
   1297 # catalog. #286: prefer human names over UUIDs and surface
   1298 # close-matches before the full list.
   1299 staged_names = sorted(
   1300     _display_name(e) for e in idx if isinstance(e, dict) and _is_staged(e) and e.get("id")
   1301 )

MaterialNotStagedError: material 'Aluminum' (resolved id 'aluminum') exists in 'physicallybased' index but is not staged for tier '1k'. Needs a re-bake.

Activity

  1. gerchowl commented on May 7, 2026

    @gerchowl
    Contributor

    Cascade fix: needs both sides to land for your repro to pass:

    Both required + the mat-vis fix needs to be on the substrate the client reads (DEFAULT_TAG-pinned). Forward-verify acceptance on both children explicitly requires re-running your repro through pymat — no closing on unit tests alone.

  2. gerchowl commented on May 11, 2026

    @gerchowl
    Contributor

    Fixed by the combination of #379 (commit 8c73865 — baker emits available_tiers=["scalar"] for physicallybased entries) and #371 (commit fcc9e27 — resolver accepts tier="scalar"). Live verified on gerchowl/[email protected]: VisAsset("physicallybased", "Aluminum").scalars yields the full PBR dict; fetch_all_textures(..., tier="scalar") returns {} cleanly. End-to-end coverage in bake/preview/tests/layered/test_layered_isolation.py.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions