py-materials 3.0.0__tar.gz → 3.2.0__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- {py_materials-3.0.0 → py_materials-3.2.0}/.gitignore +6 -0
- {py_materials-3.0.0 → py_materials-3.2.0}/PKG-INFO +7 -4
- {py_materials-3.0.0 → py_materials-3.2.0}/README.md +5 -2
- {py_materials-3.0.0 → py_materials-3.2.0}/pyproject.toml +2 -2
- {py_materials-3.0.0 → py_materials-3.2.0}/src/pymat/__init__.py +1 -1
- {py_materials-3.0.0 → py_materials-3.2.0}/src/pymat/core.py +32 -10
- {py_materials-3.0.0 → py_materials-3.2.0}/src/pymat/data/ceramics.toml +10 -10
- {py_materials-3.0.0 → py_materials-3.2.0}/src/pymat/data/electronics.toml +4 -4
- {py_materials-3.0.0 → py_materials-3.2.0}/src/pymat/data/metals.toml +15 -15
- {py_materials-3.0.0 → py_materials-3.2.0}/src/pymat/data/plastics.toml +28 -28
- {py_materials-3.0.0 → py_materials-3.2.0}/src/pymat/data/scintillators.toml +1 -1
- {py_materials-3.0.0 → py_materials-3.2.0}/src/pymat/vis/__init__.py +48 -21
- py_materials-3.2.0/src/pymat/vis/_model.py +549 -0
- {py_materials-3.0.0 → py_materials-3.2.0}/src/pymat/vis/adapters.py +1 -1
- py_materials-3.2.0/tests/_visual_compare.py +133 -0
- py_materials-3.2.0/tests/baselines/README.md +59 -0
- {py_materials-3.0.0 → py_materials-3.2.0}/tests/test_adapters.py +5 -1
- {py_materials-3.0.0 → py_materials-3.2.0}/tests/test_e2e_vis.py +91 -28
- {py_materials-3.0.0 → py_materials-3.2.0}/tests/test_toml_integrity.py +24 -8
- py_materials-3.2.0/tests/test_vis.py +932 -0
- py_materials-3.2.0/tests/test_visual_compare.py +130 -0
- {py_materials-3.0.0 → py_materials-3.2.0}/tests/test_visual_regression.py +14 -1
- py_materials-3.0.0/src/pymat/vis/_model.py +0 -264
- py_materials-3.0.0/tests/test_vis.py +0 -456
- {py_materials-3.0.0 → py_materials-3.2.0}/LICENSE +0 -0
- {py_materials-3.0.0 → py_materials-3.2.0}/docs/catalog/README.md +0 -0
- {py_materials-3.0.0 → py_materials-3.2.0}/docs/catalog/ceramics/README.md +0 -0
- {py_materials-3.0.0 → py_materials-3.2.0}/docs/catalog/electronics/README.md +0 -0
- {py_materials-3.0.0 → py_materials-3.2.0}/docs/catalog/gases/README.md +0 -0
- {py_materials-3.0.0 → py_materials-3.2.0}/docs/catalog/liquids/README.md +0 -0
- {py_materials-3.0.0 → py_materials-3.2.0}/docs/catalog/metals/README.md +0 -0
- {py_materials-3.0.0 → py_materials-3.2.0}/docs/catalog/plastics/README.md +0 -0
- {py_materials-3.0.0 → py_materials-3.2.0}/docs/catalog/scintillators/README.md +0 -0
- {py_materials-3.0.0 → py_materials-3.2.0}/docs/decisions/README.md +0 -0
- {py_materials-3.0.0 → py_materials-3.2.0}/mat-rs/data/README.md +0 -0
- {py_materials-3.0.0 → py_materials-3.2.0}/src/pymat/data/gases.toml +0 -0
- {py_materials-3.0.0 → py_materials-3.2.0}/src/pymat/data/liquids.toml +0 -0
- {py_materials-3.0.0 → py_materials-3.2.0}/src/pymat/elements.py +0 -0
- {py_materials-3.0.0 → py_materials-3.2.0}/src/pymat/enrichers.py +0 -0
- {py_materials-3.0.0 → py_materials-3.2.0}/src/pymat/factories.py +0 -0
- {py_materials-3.0.0 → py_materials-3.2.0}/src/pymat/loader.py +0 -0
- {py_materials-3.0.0 → py_materials-3.2.0}/src/pymat/properties.py +0 -0
- {py_materials-3.0.0 → py_materials-3.2.0}/src/pymat/registry.py +0 -0
- {py_materials-3.0.0 → py_materials-3.2.0}/src/pymat/units.py +0 -0
- {py_materials-3.0.0 → py_materials-3.2.0}/tests/__init__.py +0 -0
- {py_materials-3.0.0 → py_materials-3.2.0}/tests/conftest.py +0 -0
- {py_materials-3.0.0 → py_materials-3.2.0}/tests/material_preview.html +0 -0
- {py_materials-3.0.0 → py_materials-3.2.0}/tests/test_apply_to.py +0 -0
- {py_materials-3.0.0 → py_materials-3.2.0}/tests/test_catalog.py +0 -0
- {py_materials-3.0.0 → py_materials-3.2.0}/tests/test_core.py +0 -0
- {py_materials-3.0.0 → py_materials-3.2.0}/tests/test_enrichers.py +0 -0
- {py_materials-3.0.0 → py_materials-3.2.0}/tests/test_integration.py +0 -0
- {py_materials-3.0.0 → py_materials-3.2.0}/tests/test_loader.py +0 -0
- {py_materials-3.0.0 → py_materials-3.2.0}/tests/test_properties.py +0 -0
- {py_materials-3.0.0 → py_materials-3.2.0}/tests/test_readme_examples.py +0 -0
- {py_materials-3.0.0 → py_materials-3.2.0}/tests/test_uncertainties.py +0 -0
- {py_materials-3.0.0 → py_materials-3.2.0}/tests/visual_render.html +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: py-materials
|
|
3
|
-
Version: 3.
|
|
3
|
+
Version: 3.2.0
|
|
4
4
|
Summary: Hierarchical material library for CAD applications with build123d integration
|
|
5
5
|
Project-URL: Homepage, https://github.com/MorePet/py-mat
|
|
6
6
|
Project-URL: Repository, https://github.com/MorePet/py-mat
|
|
@@ -21,7 +21,7 @@ Classifier: Programming Language :: Python :: 3.13
|
|
|
21
21
|
Classifier: Topic :: Scientific/Engineering
|
|
22
22
|
Classifier: Topic :: Scientific/Engineering :: Physics
|
|
23
23
|
Requires-Python: >=3.10
|
|
24
|
-
Requires-Dist: mat-vis-client>=0.
|
|
24
|
+
Requires-Dist: mat-vis-client>=0.5.0
|
|
25
25
|
Requires-Dist: periodictable>=1.6.0
|
|
26
26
|
Requires-Dist: pint>=0.20
|
|
27
27
|
Requires-Dist: tomli>=1.0.0; python_version == '3.10'
|
|
@@ -592,8 +592,11 @@ assert alumina.density is None # use enrich_from_matproj for compounds
|
|
|
592
592
|
- `transmission`: how transparent it LOOKS in renders
|
|
593
593
|
- `metallic`: surface finish appearance
|
|
594
594
|
- `roughness`: surface roughness appearance
|
|
595
|
-
- `
|
|
596
|
-
- `
|
|
595
|
+
- `source` + `material_id` + `tier`: mat-vis appearance identity (since 3.1; the three fields match mat-vis-client's positional-arg signature — see [ADR-0002](docs/decisions/0002-vis-owns-identity-client-exposed.md))
|
|
596
|
+
- `textures`: PBR texture maps (lazy-fetched from mat-vis once `source` + `material_id` are set)
|
|
597
|
+
- `finishes`: named alternate looks (e.g. `brushed` / `polished` / `oxidized`) — each entry is an inline `{source, id}` table
|
|
598
|
+
- `mtlx` (property): MaterialX document accessor (`.xml`, `.export(path)`, `.original`)
|
|
599
|
+
- `client` (property): escape hatch to the shared `MatVisClient` singleton — for any operation not material-keyed
|
|
597
600
|
|
|
598
601
|
These can differ intentionally! A material might be physically transparent (95% optical transmission) but rendered opaque (0% vis.transmission) for CAD clarity.
|
|
599
602
|
|
|
@@ -558,8 +558,11 @@ assert alumina.density is None # use enrich_from_matproj for compounds
|
|
|
558
558
|
- `transmission`: how transparent it LOOKS in renders
|
|
559
559
|
- `metallic`: surface finish appearance
|
|
560
560
|
- `roughness`: surface roughness appearance
|
|
561
|
-
- `
|
|
562
|
-
- `
|
|
561
|
+
- `source` + `material_id` + `tier`: mat-vis appearance identity (since 3.1; the three fields match mat-vis-client's positional-arg signature — see [ADR-0002](docs/decisions/0002-vis-owns-identity-client-exposed.md))
|
|
562
|
+
- `textures`: PBR texture maps (lazy-fetched from mat-vis once `source` + `material_id` are set)
|
|
563
|
+
- `finishes`: named alternate looks (e.g. `brushed` / `polished` / `oxidized`) — each entry is an inline `{source, id}` table
|
|
564
|
+
- `mtlx` (property): MaterialX document accessor (`.xml`, `.export(path)`, `.original`)
|
|
565
|
+
- `client` (property): escape hatch to the shared `MatVisClient` singleton — for any operation not material-keyed
|
|
563
566
|
|
|
564
567
|
These can differ intentionally! A material might be physically transparent (95% optical transmission) but rendered opaque (0% vis.transmission) for CAD clarity.
|
|
565
568
|
|
|
@@ -4,7 +4,7 @@ build-backend = "hatchling.build"
|
|
|
4
4
|
|
|
5
5
|
[project]
|
|
6
6
|
name = "py-materials"
|
|
7
|
-
version = "3.
|
|
7
|
+
version = "3.2.0"
|
|
8
8
|
description = "Hierarchical material library for CAD applications with build123d integration"
|
|
9
9
|
readme = "README.md"
|
|
10
10
|
license = "MIT"
|
|
@@ -31,7 +31,7 @@ dependencies = [
|
|
|
31
31
|
"pint>=0.20",
|
|
32
32
|
"periodictable>=1.6.0",
|
|
33
33
|
"uncertainties>=3.2",
|
|
34
|
-
"mat-vis-client>=0.
|
|
34
|
+
"mat-vis-client>=0.5.0",
|
|
35
35
|
"tomli>=1.0.0; python_version == '3.10'",
|
|
36
36
|
]
|
|
37
37
|
|
|
@@ -69,9 +69,17 @@ def _make_material(
|
|
|
69
69
|
)
|
|
70
70
|
|
|
71
71
|
# vis={} kwarg — apply after internal init so we write through the
|
|
72
|
-
# public .vis accessor (which sets _vis lazily).
|
|
72
|
+
# public .vis accessor (which sets _vis lazily). Identity keys are
|
|
73
|
+
# batched through set_identity so construction never exposes a
|
|
74
|
+
# half-assigned (source-but-no-material_id) state.
|
|
73
75
|
if vis:
|
|
76
|
+
_IDENTITY_KEYS = {"source", "material_id", "tier"}
|
|
77
|
+
identity_kwargs = {k: vis[k] for k in _IDENTITY_KEYS if k in vis}
|
|
78
|
+
if identity_kwargs:
|
|
79
|
+
mat.vis.set_identity(**identity_kwargs)
|
|
74
80
|
for key, value in vis.items():
|
|
81
|
+
if key in _IDENTITY_KEYS:
|
|
82
|
+
continue
|
|
75
83
|
setattr(mat.vis, key, value)
|
|
76
84
|
|
|
77
85
|
# Apply density convenience param
|
|
@@ -188,17 +196,23 @@ class _MaterialInternal:
|
|
|
188
196
|
|
|
189
197
|
@property
|
|
190
198
|
def vis(self):
|
|
191
|
-
"""Visual representation —
|
|
199
|
+
"""Visual representation — identity, PBR scalars, textures, finishes.
|
|
192
200
|
|
|
193
201
|
Always returns a Vis instance (never None). Starts with
|
|
194
|
-
|
|
195
|
-
from TOML [vis] section for registered materials.
|
|
202
|
+
``source=None`` for materials without mat-vis data. Populated
|
|
203
|
+
from TOML ``[vis]`` section for registered materials.
|
|
196
204
|
|
|
197
|
-
Usage
|
|
198
|
-
|
|
199
|
-
steel.vis.
|
|
200
|
-
steel.vis.
|
|
201
|
-
steel.vis.
|
|
205
|
+
Usage::
|
|
206
|
+
|
|
207
|
+
steel.vis.source # "ambientcg"
|
|
208
|
+
steel.vis.material_id # "Metal012"
|
|
209
|
+
steel.vis.textures["color"] # PNG bytes (lazy-fetched)
|
|
210
|
+
steel.vis.finishes # {"brushed": {"source": ..., "id": ...}}
|
|
211
|
+
steel.vis.finish = "polished" # switch appearance
|
|
212
|
+
steel.vis.mtlx.xml() # MaterialX document (method since mat-vis-client 0.5)
|
|
213
|
+
|
|
214
|
+
See ADR-0002 and ``pymat.vis._model.Vis`` for the full surface.
|
|
215
|
+
External renderers consume via ``pymat.vis.to_threejs(material)``.
|
|
202
216
|
"""
|
|
203
217
|
if self._vis is None:
|
|
204
218
|
from pymat.vis._model import Vis
|
|
@@ -581,7 +595,15 @@ class Material(_MaterialInternal):
|
|
|
581
595
|
if density is not None:
|
|
582
596
|
self.properties.mechanical.density = density
|
|
583
597
|
|
|
584
|
-
# Apply vis={} kwarg — writes through the public .vis accessor
|
|
598
|
+
# Apply vis={} kwarg — writes through the public .vis accessor.
|
|
599
|
+
# Identity keys batch through set_identity (single invalidation,
|
|
600
|
+
# no half-assigned intermediate state).
|
|
585
601
|
if vis:
|
|
602
|
+
_IDENTITY_KEYS = {"source", "material_id", "tier"}
|
|
603
|
+
identity_kwargs = {k: vis[k] for k in _IDENTITY_KEYS if k in vis}
|
|
604
|
+
if identity_kwargs:
|
|
605
|
+
self.vis.set_identity(**identity_kwargs)
|
|
586
606
|
for key, value in vis.items():
|
|
607
|
+
if key in _IDENTITY_KEYS:
|
|
608
|
+
continue
|
|
587
609
|
setattr(self.vis, key, value)
|
|
@@ -37,8 +37,8 @@ metallic = 0.0
|
|
|
37
37
|
roughness = 0.5
|
|
38
38
|
|
|
39
39
|
[alumina.vis.finishes]
|
|
40
|
-
white = "ambientcg
|
|
41
|
-
smear = "ambientcg
|
|
40
|
+
white = { source = "ambientcg", id = "Porcelain001" }
|
|
41
|
+
smear = { source = "ambientcg", id = "Porcelain002" }
|
|
42
42
|
|
|
43
43
|
[alumina.manufacturing]
|
|
44
44
|
machinability = 30
|
|
@@ -94,8 +94,8 @@ metallic = 0.0
|
|
|
94
94
|
roughness = 0.4
|
|
95
95
|
|
|
96
96
|
[zirconia.vis.finishes]
|
|
97
|
-
white = "ambientcg
|
|
98
|
-
black = "ambientcg
|
|
97
|
+
white = { source = "ambientcg", id = "Porcelain001" }
|
|
98
|
+
black = { source = "ambientcg", id = "Porcelain003" }
|
|
99
99
|
|
|
100
100
|
|
|
101
101
|
# ============================================================================
|
|
@@ -130,7 +130,7 @@ metallic = 0.0
|
|
|
130
130
|
roughness = 0.6
|
|
131
131
|
|
|
132
132
|
[sic.vis.finishes]
|
|
133
|
-
dark = "ambientcg
|
|
133
|
+
dark = { source = "ambientcg", id = "Porcelain003" }
|
|
134
134
|
|
|
135
135
|
|
|
136
136
|
# ============================================================================
|
|
@@ -166,7 +166,7 @@ metallic = 0.0
|
|
|
166
166
|
roughness = 0.4
|
|
167
167
|
|
|
168
168
|
[macor.vis.finishes]
|
|
169
|
-
white = "ambientcg
|
|
169
|
+
white = { source = "ambientcg", id = "Porcelain001" }
|
|
170
170
|
|
|
171
171
|
[macor.manufacturing]
|
|
172
172
|
machinability = 100
|
|
@@ -198,8 +198,8 @@ metallic = 0.0
|
|
|
198
198
|
roughness = 0.5
|
|
199
199
|
|
|
200
200
|
[shapal.vis.finishes]
|
|
201
|
-
white = "ambientcg
|
|
202
|
-
smear = "ambientcg
|
|
201
|
+
white = { source = "ambientcg", id = "Porcelain001" }
|
|
202
|
+
smear = { source = "ambientcg", id = "Porcelain002" }
|
|
203
203
|
|
|
204
204
|
[shapal.manufacturing]
|
|
205
205
|
machinability = 80
|
|
@@ -311,7 +311,7 @@ metallic = 0.0
|
|
|
311
311
|
roughness = 0.3
|
|
312
312
|
|
|
313
313
|
[beryllia.vis.finishes]
|
|
314
|
-
white = "ambientcg
|
|
314
|
+
white = { source = "ambientcg", id = "Porcelain001" }
|
|
315
315
|
|
|
316
316
|
[beryllia.compliance]
|
|
317
317
|
toxic = true
|
|
@@ -347,4 +347,4 @@ metallic = 0.0
|
|
|
347
347
|
roughness = 0.4
|
|
348
348
|
|
|
349
349
|
[yttria.vis.finishes]
|
|
350
|
-
white = "ambientcg
|
|
350
|
+
white = { source = "ambientcg", id = "Porcelain001" }
|
|
@@ -140,8 +140,8 @@ roughness = 0.35
|
|
|
140
140
|
transmission = 0.0
|
|
141
141
|
|
|
142
142
|
[copper_pcb.vis.finishes]
|
|
143
|
-
clean = "ambientcg
|
|
144
|
-
oxidized = "ambientcg
|
|
143
|
+
clean = { source = "ambientcg", id = "Metal043A" }
|
|
144
|
+
oxidized = { source = "ambientcg", id = "Metal043B" }
|
|
145
145
|
|
|
146
146
|
# 1 oz Copper (35 µm)
|
|
147
147
|
[copper_pcb.oz1]
|
|
@@ -187,8 +187,8 @@ roughness = 0.4
|
|
|
187
187
|
transmission = 0.0
|
|
188
188
|
|
|
189
189
|
[solder.vis.finishes]
|
|
190
|
-
matte = "ambientcg
|
|
191
|
-
reflowed = "ambientcg
|
|
190
|
+
matte = { source = "ambientcg", id = "Metal030" }
|
|
191
|
+
reflowed = { source = "ambientcg", id = "Metal031" }
|
|
192
192
|
|
|
193
193
|
# Sn63Pb37 (traditional, leaded)
|
|
194
194
|
[solder.Sn63Pb37]
|
|
@@ -31,9 +31,9 @@ transmission = 0.0
|
|
|
31
31
|
default = "brushed"
|
|
32
32
|
|
|
33
33
|
[stainless.vis.finishes]
|
|
34
|
-
brushed = "ambientcg
|
|
35
|
-
polished = "ambientcg
|
|
36
|
-
dirty = "ambientcg
|
|
34
|
+
brushed = { source = "ambientcg", id = "Metal012" }
|
|
35
|
+
polished = { source = "ambientcg", id = "Metal049A" }
|
|
36
|
+
dirty = { source = "ambientcg", id = "Metal049B" }
|
|
37
37
|
|
|
38
38
|
# Stainless Steel 304
|
|
39
39
|
[stainless.s304]
|
|
@@ -150,8 +150,8 @@ transmission = 0.0
|
|
|
150
150
|
default = "smooth"
|
|
151
151
|
|
|
152
152
|
[aluminum.vis.finishes]
|
|
153
|
-
smooth = "ambientcg
|
|
154
|
-
machined = "ambientcg
|
|
153
|
+
smooth = { source = "ambientcg", id = "Metal049A" }
|
|
154
|
+
machined = { source = "ambientcg", id = "Metal055A" }
|
|
155
155
|
|
|
156
156
|
# Aluminum 6061-T6
|
|
157
157
|
[aluminum.a6061]
|
|
@@ -288,9 +288,9 @@ transmission = 0.0
|
|
|
288
288
|
default = "polished"
|
|
289
289
|
|
|
290
290
|
[copper.vis.finishes]
|
|
291
|
-
polished = "ambientcg
|
|
292
|
-
oxidized = "ambientcg
|
|
293
|
-
aged = "ambientcg
|
|
291
|
+
polished = { source = "ambientcg", id = "Metal043A" }
|
|
292
|
+
oxidized = { source = "ambientcg", id = "Metal043B" }
|
|
293
|
+
aged = { source = "ambientcg", id = "Metal026" }
|
|
294
294
|
|
|
295
295
|
[copper.OFHC]
|
|
296
296
|
name = "OFHC Copper (Oxygen-Free High Conductivity)"
|
|
@@ -336,8 +336,8 @@ roughness = 0.4
|
|
|
336
336
|
transmission = 0.0
|
|
337
337
|
|
|
338
338
|
[tungsten.vis.finishes]
|
|
339
|
-
polished = "ambientcg
|
|
340
|
-
raw = "ambientcg
|
|
339
|
+
polished = { source = "ambientcg", id = "Metal014" }
|
|
340
|
+
raw = { source = "ambientcg", id = "Metal030" }
|
|
341
341
|
|
|
342
342
|
[tungsten.pure]
|
|
343
343
|
name = "Tungsten 99.95%"
|
|
@@ -387,8 +387,8 @@ roughness = 0.5
|
|
|
387
387
|
transmission = 0.0
|
|
388
388
|
|
|
389
389
|
[lead.vis.finishes]
|
|
390
|
-
dull = "ambientcg
|
|
391
|
-
oxidized = "ambientcg
|
|
390
|
+
dull = { source = "ambientcg", id = "Metal030" }
|
|
391
|
+
oxidized = { source = "ambientcg", id = "Metal031" }
|
|
392
392
|
|
|
393
393
|
|
|
394
394
|
# ============================================================================
|
|
@@ -423,7 +423,7 @@ transmission = 0.0
|
|
|
423
423
|
default = "smooth"
|
|
424
424
|
|
|
425
425
|
[titanium.vis.finishes]
|
|
426
|
-
smooth = "ambientcg
|
|
426
|
+
smooth = { source = "ambientcg", id = "Metal049A" }
|
|
427
427
|
|
|
428
428
|
|
|
429
429
|
# ============================================================================
|
|
@@ -454,8 +454,8 @@ transmission = 0.0
|
|
|
454
454
|
default = "polished"
|
|
455
455
|
|
|
456
456
|
[brass.vis.finishes]
|
|
457
|
-
polished = "ambientcg
|
|
458
|
-
oxidized = "ambientcg
|
|
457
|
+
polished = { source = "ambientcg", id = "Metal008" }
|
|
458
|
+
oxidized = { source = "ambientcg", id = "Metal035" }
|
|
459
459
|
|
|
460
460
|
|
|
461
461
|
# ============================================================================
|
|
@@ -41,8 +41,8 @@ metallic = 0.0
|
|
|
41
41
|
roughness = 0.5
|
|
42
42
|
|
|
43
43
|
[peek.vis.finishes]
|
|
44
|
-
natural = "ambientcg
|
|
45
|
-
dark = "ambientcg
|
|
44
|
+
natural = { source = "ambientcg", id = "Plastic004" }
|
|
45
|
+
dark = { source = "ambientcg", id = "Plastic003" }
|
|
46
46
|
|
|
47
47
|
[peek.manufacturing]
|
|
48
48
|
printable_fdm = true
|
|
@@ -137,8 +137,8 @@ metallic = 0.0
|
|
|
137
137
|
roughness = 0.6
|
|
138
138
|
|
|
139
139
|
[delrin.vis.finishes]
|
|
140
|
-
white = "ambientcg
|
|
141
|
-
black = "ambientcg
|
|
140
|
+
white = { source = "ambientcg", id = "Plastic010" }
|
|
141
|
+
black = { source = "ambientcg", id = "Plastic006" }
|
|
142
142
|
|
|
143
143
|
[delrin.manufacturing]
|
|
144
144
|
machinability = 80
|
|
@@ -183,7 +183,7 @@ metallic = 0.0
|
|
|
183
183
|
roughness = 0.5
|
|
184
184
|
|
|
185
185
|
[ultem.vis.finishes]
|
|
186
|
-
amber = "ambientcg
|
|
186
|
+
amber = { source = "ambientcg", id = "Plastic003" }
|
|
187
187
|
|
|
188
188
|
[ultem.manufacturing]
|
|
189
189
|
printable_fdm = true
|
|
@@ -227,7 +227,7 @@ metallic = 0.0
|
|
|
227
227
|
roughness = 0.3
|
|
228
228
|
|
|
229
229
|
[ptfe.vis.finishes]
|
|
230
|
-
white = "ambientcg
|
|
230
|
+
white = { source = "ambientcg", id = "Plastic010" }
|
|
231
231
|
|
|
232
232
|
[ptfe.compliance]
|
|
233
233
|
food_safe = true
|
|
@@ -278,7 +278,7 @@ roughness = 0.1
|
|
|
278
278
|
# ESR is a specular-reflector film — roughness stays low (scalars dominate).
|
|
279
279
|
# The finish is mostly a semantic tag so it appears in the catalog.
|
|
280
280
|
[esr.vis.finishes]
|
|
281
|
-
reflective = "ambientcg
|
|
281
|
+
reflective = { source = "ambientcg", id = "Plastic010" }
|
|
282
282
|
|
|
283
283
|
[esr.compliance]
|
|
284
284
|
radiation_resistant = true
|
|
@@ -313,8 +313,8 @@ metallic = 0.0
|
|
|
313
313
|
roughness = 0.6
|
|
314
314
|
|
|
315
315
|
[nylon.vis.finishes]
|
|
316
|
-
natural = "ambientcg
|
|
317
|
-
white = "ambientcg
|
|
316
|
+
natural = { source = "ambientcg", id = "Plastic013A" }
|
|
317
|
+
white = { source = "ambientcg", id = "Plastic010" }
|
|
318
318
|
|
|
319
319
|
[nylon.manufacturing]
|
|
320
320
|
printable_fdm = true
|
|
@@ -353,11 +353,11 @@ metallic = 0.0
|
|
|
353
353
|
roughness = 0.6
|
|
354
354
|
|
|
355
355
|
[pla.vis.finishes]
|
|
356
|
-
white = "ambientcg
|
|
357
|
-
black = "ambientcg
|
|
358
|
-
red = "ambientcg
|
|
359
|
-
blue = "ambientcg
|
|
360
|
-
green = "ambientcg
|
|
356
|
+
white = { source = "ambientcg", id = "Plastic010" }
|
|
357
|
+
black = { source = "ambientcg", id = "Plastic006" }
|
|
358
|
+
red = { source = "ambientcg", id = "Plastic007" }
|
|
359
|
+
blue = { source = "ambientcg", id = "Plastic008" }
|
|
360
|
+
green = { source = "ambientcg", id = "Plastic009" }
|
|
361
361
|
|
|
362
362
|
[pla.manufacturing]
|
|
363
363
|
printable_fdm = true
|
|
@@ -392,9 +392,9 @@ metallic = 0.0
|
|
|
392
392
|
roughness = 0.6
|
|
393
393
|
|
|
394
394
|
[abs.vis.finishes]
|
|
395
|
-
black = "ambientcg
|
|
396
|
-
white = "ambientcg
|
|
397
|
-
red = "ambientcg
|
|
395
|
+
black = { source = "ambientcg", id = "Plastic006" }
|
|
396
|
+
white = { source = "ambientcg", id = "Plastic010" }
|
|
397
|
+
red = { source = "ambientcg", id = "Plastic007" }
|
|
398
398
|
|
|
399
399
|
[abs.manufacturing]
|
|
400
400
|
printable_fdm = true
|
|
@@ -426,8 +426,8 @@ metallic = 0.0
|
|
|
426
426
|
roughness = 0.5
|
|
427
427
|
|
|
428
428
|
[petg.vis.finishes]
|
|
429
|
-
clear = "ambientcg
|
|
430
|
-
black = "ambientcg
|
|
429
|
+
clear = { source = "ambientcg", id = "Plastic005" }
|
|
430
|
+
black = { source = "ambientcg", id = "Plastic006" }
|
|
431
431
|
|
|
432
432
|
[petg.manufacturing]
|
|
433
433
|
printable_fdm = true
|
|
@@ -451,8 +451,8 @@ metallic = 0.0
|
|
|
451
451
|
roughness = 0.7
|
|
452
452
|
|
|
453
453
|
[tpu.vis.finishes]
|
|
454
|
-
black = "ambientcg
|
|
455
|
-
white = "ambientcg
|
|
454
|
+
black = { source = "ambientcg", id = "Plastic006" }
|
|
455
|
+
white = { source = "ambientcg", id = "Plastic010" }
|
|
456
456
|
|
|
457
457
|
[tpu.manufacturing]
|
|
458
458
|
printable_fdm = true
|
|
@@ -486,7 +486,7 @@ metallic = 0.0
|
|
|
486
486
|
roughness = 0.5
|
|
487
487
|
|
|
488
488
|
[vespel.vis.finishes]
|
|
489
|
-
dark = "ambientcg
|
|
489
|
+
dark = { source = "ambientcg", id = "Plastic003" }
|
|
490
490
|
|
|
491
491
|
|
|
492
492
|
[torlon]
|
|
@@ -511,7 +511,7 @@ metallic = 0.0
|
|
|
511
511
|
roughness = 0.5
|
|
512
512
|
|
|
513
513
|
[torlon.vis.finishes]
|
|
514
|
-
amber = "ambientcg
|
|
514
|
+
amber = { source = "ambientcg", id = "Plastic004" }
|
|
515
515
|
|
|
516
516
|
|
|
517
517
|
[pctfe]
|
|
@@ -534,7 +534,7 @@ metallic = 0.0
|
|
|
534
534
|
roughness = 0.4
|
|
535
535
|
|
|
536
536
|
[pctfe.vis.finishes]
|
|
537
|
-
white = "ambientcg
|
|
537
|
+
white = { source = "ambientcg", id = "Plastic010" }
|
|
538
538
|
|
|
539
539
|
|
|
540
540
|
# ============================================================================
|
|
@@ -583,7 +583,7 @@ ior = 1.49
|
|
|
583
583
|
|
|
584
584
|
# pmma is transparent — finishes are secondary, PBR scalars dominate
|
|
585
585
|
[pmma.vis.finishes]
|
|
586
|
-
clear = "ambientcg
|
|
586
|
+
clear = { source = "ambientcg", id = "Plastic005" }
|
|
587
587
|
|
|
588
588
|
[pmma.manufacturing]
|
|
589
589
|
machinability = 90
|
|
@@ -631,8 +631,8 @@ metallic = 0.0
|
|
|
631
631
|
roughness = 0.6
|
|
632
632
|
|
|
633
633
|
[pe.vis.finishes]
|
|
634
|
-
natural = "ambientcg
|
|
635
|
-
white = "ambientcg
|
|
634
|
+
natural = { source = "ambientcg", id = "Plastic013A" }
|
|
635
|
+
white = { source = "ambientcg", id = "Plastic010" }
|
|
636
636
|
|
|
637
637
|
[pe.compliance]
|
|
638
638
|
food_safe = true
|
|
@@ -747,7 +747,7 @@ transmission = 0.85
|
|
|
747
747
|
ior = 1.58
|
|
748
748
|
|
|
749
749
|
[pc.vis.finishes]
|
|
750
|
-
clear = "ambientcg
|
|
750
|
+
clear = { source = "ambientcg", id = "Plastic005" }
|
|
751
751
|
|
|
752
752
|
[pc.manufacturing]
|
|
753
753
|
machinability = 85
|
|
@@ -270,7 +270,7 @@ transmission = 0.85
|
|
|
270
270
|
# Plastic scintillators are translucent — PBR scalars (transmission=0.85)
|
|
271
271
|
# dominate. The finish tag is for catalog completeness.
|
|
272
272
|
[plastic_scint.vis.finishes]
|
|
273
|
-
clear = "ambientcg
|
|
273
|
+
clear = { source = "ambientcg", id = "Plastic010" }
|
|
274
274
|
|
|
275
275
|
# BC-400
|
|
276
276
|
[plastic_scint.BC400]
|
|
@@ -1,33 +1,54 @@
|
|
|
1
1
|
"""
|
|
2
2
|
Visual material data from mat-vis.
|
|
3
3
|
|
|
4
|
-
Public API — all functions importable from
|
|
4
|
+
Public API — all functions importable from ``pymat.vis`` directly::
|
|
5
5
|
|
|
6
6
|
from pymat import vis
|
|
7
7
|
|
|
8
|
-
|
|
8
|
+
# Discovery
|
|
9
|
+
vis.search(category="metal", tags=["brushed", "silver"])
|
|
10
|
+
|
|
11
|
+
# Raw fetch (usually you want material.vis.textures instead)
|
|
9
12
|
vis.fetch("ambientcg", "Metal032", tier="1k")
|
|
10
13
|
vis.prefetch("ambientcg", tier="1k")
|
|
11
14
|
vis.get_manifest()
|
|
12
15
|
vis.rowmap_entry("ambientcg", "Metal032", tier="1k")
|
|
13
16
|
|
|
14
|
-
|
|
15
|
-
|
|
17
|
+
# Adapters — Material → external format
|
|
18
|
+
vis.to_threejs(material) # MeshPhysicalMaterial init dict
|
|
19
|
+
vis.to_gltf(material) # glTF 2.0 material
|
|
20
|
+
vis.export_mtlx(material, "./out")
|
|
21
|
+
|
|
22
|
+
# Escape hatch — the shared MatVisClient
|
|
23
|
+
vis.client().tiers()
|
|
24
|
+
|
|
25
|
+
Powered by ``mat-vis-client`` (separate PyPI package). ``Material.vis``
|
|
26
|
+
wires into this module for lazy texture loading; see ADR-0002.
|
|
16
27
|
"""
|
|
17
28
|
|
|
18
29
|
from typing import Any
|
|
19
30
|
|
|
20
|
-
# Re-export the full adapters module so new adapters (e.g. to_ktx2)
|
|
21
|
-
# are available as soon as mat-vis-client ships them
|
|
22
31
|
from mat_vis_client import (
|
|
23
32
|
MatVisClient,
|
|
24
|
-
adapters, # noqa: F401
|
|
25
33
|
get_manifest,
|
|
26
34
|
prefetch,
|
|
27
35
|
rowmap_entry,
|
|
28
36
|
seed_indexes,
|
|
29
37
|
)
|
|
30
38
|
|
|
39
|
+
# Shared-singleton accessor: ``get_client`` became public in
|
|
40
|
+
# mat-vis-client 0.5.0 (see mat-vis#84). Pinned in pyproject.toml.
|
|
41
|
+
from mat_vis_client import get_client as _shared_client
|
|
42
|
+
|
|
43
|
+
# Material-accepting adapters: Three.js / glTF / MaterialX.
|
|
44
|
+
# Re-exported at top level so ``from pymat.vis import to_threejs`` works
|
|
45
|
+
# and tab completion on ``pymat.vis.`` surfaces the main cross-tool
|
|
46
|
+
# handoff. Note: ``pymat.vis.adapters`` resolves to the local submodule
|
|
47
|
+
# (Material signatures). Users who want mat-vis-client's primitive-
|
|
48
|
+
# signature adapters (``(scalars_dict, textures_dict)``) should import
|
|
49
|
+
# them explicitly: ``from mat_vis_client import adapters``.
|
|
50
|
+
from pymat.vis.adapters import export_mtlx, to_gltf, to_threejs
|
|
51
|
+
|
|
31
52
|
|
|
32
53
|
def fetch(
|
|
33
54
|
source: str, material_id: str, *, tier: str = "1k", tag: str | None = None
|
|
@@ -39,9 +60,7 @@ def fetch(
|
|
|
39
60
|
was removed upstream after 2026.4.x in favor of explicit-client
|
|
40
61
|
style — see mat-vis __init__.py docstring).
|
|
41
62
|
"""
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
client = MatVisClient(tag=tag) if tag else _get_client()
|
|
63
|
+
client = MatVisClient(tag=tag) if tag else _shared_client()
|
|
45
64
|
return client.fetch_all_textures(source, material_id, tier=tier)
|
|
46
65
|
|
|
47
66
|
|
|
@@ -66,9 +85,7 @@ def search(
|
|
|
66
85
|
Does NOT filter by tier — search is for finding materials,
|
|
67
86
|
tier is a fetch-time concern.
|
|
68
87
|
"""
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
client = _get_client()
|
|
88
|
+
client = _shared_client()
|
|
72
89
|
|
|
73
90
|
roughness_range = None
|
|
74
91
|
if roughness is not None:
|
|
@@ -119,20 +136,26 @@ def search(
|
|
|
119
136
|
|
|
120
137
|
|
|
121
138
|
def client() -> MatVisClient:
|
|
122
|
-
"""Get the shared MatVisClient
|
|
139
|
+
"""Get the shared ``MatVisClient`` singleton (lazy-initialized).
|
|
123
140
|
|
|
124
|
-
|
|
125
|
-
|
|
141
|
+
Module-level entry point for operations that don't have a material
|
|
142
|
+
in hand yet — tier enumeration, cache management, discovery before
|
|
143
|
+
a material is picked::
|
|
126
144
|
|
|
127
145
|
c = vis.client()
|
|
128
|
-
c.tiers() #
|
|
129
|
-
c.sources("1k") #
|
|
146
|
+
c.tiers() # ["128", "256", "1k", "ktx2-1k", "mtlx", ...]
|
|
147
|
+
c.sources("1k") # ["ambientcg", "polyhaven", ...]
|
|
130
148
|
c.search("metal") # search by category
|
|
131
149
|
c.fetch_all_textures("ambientcg", "Metal032", tier="1k")
|
|
132
|
-
"""
|
|
133
|
-
from mat_vis_client import _get_client
|
|
134
150
|
|
|
135
|
-
|
|
151
|
+
**Note:** if you already have a ``Material``, use
|
|
152
|
+
``material.vis.client`` — it's the same singleton without the
|
|
153
|
+
parens, and the property exists on every ``Vis`` by ADR-0002.
|
|
154
|
+
|
|
155
|
+
Future-proof: any new method ``mat-vis-client`` adds is callable
|
|
156
|
+
immediately without a py-mat release.
|
|
157
|
+
"""
|
|
158
|
+
return _shared_client()
|
|
136
159
|
|
|
137
160
|
|
|
138
161
|
__all__ = [
|
|
@@ -146,6 +169,10 @@ __all__ = [
|
|
|
146
169
|
"get_manifest",
|
|
147
170
|
"seed_indexes",
|
|
148
171
|
"MatVisClient",
|
|
172
|
+
# Material → external-format adapters (the main cross-tool handoff)
|
|
173
|
+
"to_threejs",
|
|
174
|
+
"to_gltf",
|
|
175
|
+
"export_mtlx",
|
|
149
176
|
# Adapters module — new adapters auto-available
|
|
150
177
|
"adapters",
|
|
151
178
|
]
|