Skip to content

Commit dce7c29

Browse files
committed
Merge branch 'multi_object_vtk' of github.com:/aylward/physiomotion4d into multi_object_vtk
2 parents b7dacec + 0c001ce commit dce7c29

1 file changed

Lines changed: 17 additions & 1 deletion

File tree

src/physiomotion4d/cli/convert_vtk_to_usd.py

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -183,7 +183,23 @@ def main() -> int:
183183
solid_color = (0.8, 0.8, 0.8)
184184
if args.color:
185185
try:
186-
solid_color = _parse_color(args.color)
186+
# If argparse defined --color with nargs=3 and type=float, args.color will be a list of floats.
187+
# Handle that case directly by normalizing into [0, 1] and forming an RGB tuple.
188+
if isinstance(args.color, (list, tuple)):
189+
components = [float(v) for v in args.color]
190+
if len(components) != 3:
191+
raise ValueError("Color must have exactly three components (R G B).")
192+
# Interpret either as normalized [0, 1] or byte [0, 255] values, but do not mix scales.
193+
if all(0.0 <= v <= 1.0 for v in components):
194+
solid_color = tuple(components)
195+
elif all(0.0 <= v <= 255.0 for v in components):
196+
solid_color = tuple(v / 255.0 for v in components)
197+
else:
198+
raise ValueError(
199+
"Color values must all be in [0, 1] or all in [0, 255]."
200+
)
201+
else:
202+
solid_color = _parse_color(args.color)
187203
except ValueError as e:
188204
print(f"Error: {e}")
189205
return 1

0 commit comments

Comments
 (0)