MCPcopy
hub / github.com/htdt/godogen / cmd_glb

Function cmd_glb

asset-gen/tools/asset_gen.py:272–317  ·  view source on GitHub ↗
(args)

Source from the content-addressed store, hash-verified

270
271
272def cmd_glb(args):
273 image_path = Path(args.image)
274 if not image_path.exists():
275 result_json(False, error=f"Image not found: {image_path}")
276 sys.exit(1)
277
278 preset = _resolve_preset(args.quality)
279
280 face_limit = args.face_limit if args.quality == "default" else preset["face_limit"]
281
282 output = Path(args.output)
283 output.parent.mkdir(parents=True, exist_ok=True)
284
285 print(f"Generating GLB (quality={args.quality}, pbr={args.pbr}, face_limit={face_limit})...", file=sys.stderr)
286
287 sidecar = {
288 "kind": "mesh",
289 "preset": args.quality,
290 "pbr": args.pbr,
291 "status": "pending",
292 }
293 try:
294 task_id = create_image_to_model_task(
295 image_path,
296 face_limit=face_limit,
297 pbr=args.pbr,
298 geometry_quality=preset["geometry_quality"],
299 texture_quality=preset["texture_quality"],
300 )
301 print(f" image_to_model: {task_id}", file=sys.stderr)
302 sidecar["image_to_model_task_id"] = task_id
303 _write_sidecar(output, sidecar)
304
305 result = poll_task(task_id)
306 download_model(result, output)
307 except TimeoutError as e:
308 result_json(False, error=f"{e}. {_resume_hint(output)}", cost_cents=preset["cost_cents"])
309 sys.exit(1)
310 except Exception as e:
311 result_json(False, error=str(e))
312 sys.exit(1)
313
314 sidecar["status"] = "complete"
315 _write_sidecar(output, sidecar)
316 print(f"Saved: {output}", file=sys.stderr)
317 result_json(True, path=str(output), cost_cents=preset["cost_cents"])
318
319
320def cmd_rig(args):

Callers

nothing calls this directly

Calls 7

poll_taskFunction · 0.90
download_modelFunction · 0.90
result_jsonFunction · 0.85
_resolve_presetFunction · 0.85
_write_sidecarFunction · 0.85
_resume_hintFunction · 0.85

Tested by

no test coverage detected