@wildshard/sdk 0.0.1 → 0.2.4
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.
- package/GUIDE.md +895 -0
- package/README.md +13 -5
- package/bin/wildshard.mjs +38 -0
- package/lint/declaration-config.d.mts +2 -0
- package/lint/declaration-config.mjs +19 -0
- package/lint/engine-plugin.d.mts +2 -0
- package/lint/engine-plugin.mjs +40 -0
- package/lint/host-callbacks.d.mts +6 -0
- package/lint/host-callbacks.mjs +123 -0
- package/lint/host-files.d.mts +1 -0
- package/lint/host-files.mjs +7 -0
- package/lint/layer-exports.d.mts +2 -0
- package/lint/layer-exports.mjs +21 -0
- package/lint/legacy-line-basis.json +995 -0
- package/lint/nine-tiling-baseline.json +35 -0
- package/lint/ratchet.json +11 -0
- package/lint/runtime-files.d.mts +12 -0
- package/lint/runtime-files.json +16 -0
- package/lint/runtime-files.mjs +69 -0
- package/lint/runtime-performance.d.mts +6 -0
- package/lint/runtime-performance.mjs +184 -0
- package/lint/sdk-plugin.d.mts +4 -0
- package/lint/sdk-plugin.mjs +134 -0
- package/lint/shardfile-boundaries.d.mts +10 -0
- package/lint/shardfile-boundaries.mjs +122 -0
- package/lint/tile-bake-debt.json +556 -0
- package/package.json +365 -3
- package/scripts/agent-parity.mjs +1524 -0
- package/scripts/agent-sync.mjs +518 -0
- package/scripts/apfs-clone.mjs +67 -0
- package/scripts/assert-store-layout.mjs +23 -0
- package/scripts/astc6-phone-cap.d.mts +3 -0
- package/scripts/astc6-phone-cap.mjs +137 -0
- package/scripts/audit-assets.d.mts +10 -0
- package/scripts/audit-assets.mjs +151 -0
- package/scripts/bake/coatFiles.d.mts +6 -0
- package/scripts/bake/coatFiles.mjs +37 -0
- package/scripts/bake/environment.d.mts +2 -0
- package/scripts/bake/environment.mjs +58 -0
- package/scripts/bake/far-proxies.mjs +45 -0
- package/scripts/bake/keyed-sky.d.mts +4 -0
- package/scripts/bake/keyed-sky.mjs +34 -0
- package/scripts/bake/movers.mjs +56 -0
- package/scripts/bake/nativeWorld.d.mts +6 -0
- package/scripts/bake/nativeWorld.mjs +43 -0
- package/scripts/bake/navmeshGround.ts +22 -0
- package/scripts/bake/near-placeholder.mjs +331 -0
- package/scripts/bake/placeholderShards.mjs +41 -0
- package/scripts/bake/skins.mjs +15 -0
- package/scripts/bake/template-skins.mjs +33 -0
- package/scripts/bake/viewmodelBytes.ts +26 -0
- package/scripts/bake/viewmodelPage.ts +11 -0
- package/scripts/bake/worldHost.d.mts +35 -0
- package/scripts/bake/worldHost.mjs +110 -0
- package/scripts/bake-astc6.cache.json +80 -0
- package/scripts/bake-astc6.far-reach.cache.json +23 -0
- package/scripts/bake-astc6.list.json +111 -0
- package/scripts/bake-astc6.mjs +279 -0
- package/scripts/bake-astc6.nalati-grasslands.cache.json +42 -0
- package/scripts/bake-catalogue.mjs +44 -0
- package/scripts/bake-check.mjs +54 -0
- package/scripts/bake-chunk.mjs +124 -0
- package/scripts/bake-cloud-field.mjs +24 -0
- package/scripts/bake-coats.mjs +110 -0
- package/scripts/bake-data-maps.d.mts +24 -0
- package/scripts/bake-data-maps.mjs +72 -0
- package/scripts/bake-entry-programs.mjs +117 -0
- package/scripts/bake-geometry.mjs +106 -0
- package/scripts/bake-hybrid-tiles.mjs +28 -0
- package/scripts/bake-ktx2.cache.json +276 -0
- package/scripts/bake-ktx2.list.json +365 -0
- package/scripts/bake-ktx2.mjs +477 -0
- package/scripts/bake-map-glb.mjs +127 -0
- package/scripts/bake-map-rest.d.mts +7 -0
- package/scripts/bake-map-rest.mjs +50 -0
- package/scripts/bake-maps.mjs +200 -0
- package/scripts/bake-navmesh.mjs +259 -0
- package/scripts/bake-packs.mjs +129 -0
- package/scripts/bake-pickups.mjs +102 -0
- package/scripts/bake-query-terrain.mjs +64 -0
- package/scripts/bake-recurve-pool.mjs +16 -0
- package/scripts/bake-section-schemas.d.mts +3 -0
- package/scripts/bake-template-shardfile.mjs +32 -0
- package/scripts/bake-textures.mjs +80 -0
- package/scripts/bake-viewmodel-sets.json +45 -0
- package/scripts/bake-viewmodel-sets.mjs +137 -0
- package/scripts/bake-voxel-ao.mjs +119 -0
- package/scripts/bake-water-ripples.mjs +25 -0
- package/scripts/blender/README.md +129 -0
- package/scripts/blender/build.sh +166 -0
- package/scripts/blender/lib/export-scene.mjs +129 -0
- package/scripts/blender/lib/glb-digest.mjs +188 -0
- package/scripts/blender/lib/glb.py +68 -0
- package/scripts/blender/lib/save_blend.py +17 -0
- package/scripts/blender/lib/world_fixture.py +55 -0
- package/scripts/blender/targets.json +591 -0
- package/scripts/build-sdk.mjs +95 -0
- package/scripts/build-shardfiles.d.mts +7 -0
- package/scripts/build-shardfiles.mjs +206 -0
- package/scripts/capture-hero.mjs +137 -0
- package/scripts/check-lift-review.mjs +23 -0
- package/scripts/chromium-keychain-check.mjs +139 -0
- package/scripts/chromium-keychain.d.mts +1 -0
- package/scripts/chromium-keychain.mjs +5 -0
- package/scripts/compile-script.d.mts +3 -0
- package/scripts/compile-script.mjs +8 -0
- package/scripts/creature-color.mjs +255 -0
- package/scripts/decide/calibrate.py +127 -0
- package/scripts/decide/calibration/2026-10-03/labels-s1.tsv +281 -0
- package/scripts/decide/calibration/2026-10-03/labels-s2.tsv +97 -0
- package/scripts/decide/calibration/2026-10-03/labels-s3.tsv +48 -0
- package/scripts/decide/calibration/2026-10-03/labels-s3b.tsv +26 -0
- package/scripts/decide/calibration/2026-10-03/res-capture-status-v1.jsonl +376 -0
- package/scripts/decide/calibration/2026-10-03/res-text-garbled-strings.jsonl +48 -0
- package/scripts/decide/calibration/2026-10-03/res-text-garbled-v1.jsonl +73 -0
- package/scripts/decide/decide.py +262 -0
- package/scripts/decide/decide.sh +50 -0
- package/scripts/decide/layer-purity-pilot.mjs +41 -0
- package/scripts/decide/sets/capture-status.json +46 -0
- package/scripts/decide/sets/layer-purity.json +28 -0
- package/scripts/decide/sets/text-garbled.json +17 -0
- package/scripts/decide/test_decide.py +37 -0
- package/scripts/docs.mjs +15 -0
- package/scripts/entry-reads/crawl.ts +152 -0
- package/scripts/entry-reads/tsconfig.json +25 -0
- package/scripts/gen-format-schema.d.mts +2 -0
- package/scripts/gen-format-schema.mjs +21 -0
- package/scripts/gen-host-catalogue.d.mts +14 -0
- package/scripts/gen-host-catalogue.mjs +108 -0
- package/scripts/gen-shard-layout-doc.d.mts +4 -0
- package/scripts/gen-shard-layout-doc.mjs +55 -0
- package/scripts/gen-shards.d.mts +17 -0
- package/scripts/gen-shards.mjs +311 -0
- package/scripts/goldens/capture-inputs.d.mts +4 -0
- package/scripts/goldens/capture-inputs.mjs +34 -0
- package/scripts/goldens/colour_shift.py +27 -0
- package/scripts/goldens/native-residency.d.mts +10 -0
- package/scripts/goldens/native-residency.mjs +104 -0
- package/scripts/goldens/plot-inputs.d.mts +12 -0
- package/scripts/goldens/plot-inputs.mjs +46 -0
- package/scripts/gpu-texmem.mjs +98 -0
- package/scripts/horizon-matte/config.py +24 -0
- package/scripts/horizon-matte/encode.py +91 -0
- package/scripts/horizon-matte/key.py +141 -0
- package/scripts/horizon-matte/mkjobs.py +33 -0
- package/scripts/horizon-matte/mkjobs_day2.py +11 -0
- package/scripts/horizon-matte/overlap.py +80 -0
- package/scripts/horizon-matte/run_codex.py +57 -0
- package/scripts/horizon-matte/stitch.py +133 -0
- package/scripts/img2mesh/CC0.md +105 -0
- package/scripts/img2mesh/README.md +209 -0
- package/scripts/img2mesh/ab_board.py +102 -0
- package/scripts/img2mesh/birds/birds.json +255 -0
- package/scripts/img2mesh/birds/birds_atlas.py +150 -0
- package/scripts/img2mesh/birds/birds_fix_preview.mjs +103 -0
- package/scripts/img2mesh/birds/birds_fix_render.py +75 -0
- package/scripts/img2mesh/birds/birds_pack.py +110 -0
- package/scripts/img2mesh/birds/birds_phone_b.py +112 -0
- package/scripts/img2mesh/birds/birds_post.py +550 -0
- package/scripts/img2mesh/birds/birds_render.py +125 -0
- package/scripts/img2mesh/birds/birds_sheet.py +33 -0
- package/scripts/img2mesh/birds/birds_view.py +60 -0
- package/scripts/img2mesh/board.py +100 -0
- package/scripts/img2mesh/build_cc0.sh +52 -0
- package/scripts/img2mesh/build_driftwood.sh +12 -0
- package/scripts/img2mesh/build_faces.sh +53 -0
- package/scripts/img2mesh/build_props.py +81 -0
- package/scripts/img2mesh/cc0_export.py +186 -0
- package/scripts/img2mesh/driftwood_post.py +571 -0
- package/scripts/img2mesh/e304_faces.sh +67 -0
- package/scripts/img2mesh/face_remaster.py +911 -0
- package/scripts/img2mesh/face_views.py +95 -0
- package/scripts/img2mesh/faces-e304.json +9 -0
- package/scripts/img2mesh/faces.json +30 -0
- package/scripts/img2mesh/head_cut.py +100 -0
- package/scripts/img2mesh/hi3d_paint.py +94 -0
- package/scripts/img2mesh/hi3d_refine.py +161 -0
- package/scripts/img2mesh/hunyuan_cpu_rasterizer.sh +42 -0
- package/scripts/img2mesh/pine_hollow_phone.sh +13 -0
- package/scripts/img2mesh/props/coral-arch.json +32 -0
- package/scripts/img2mesh/props/ember-furnace.json +30 -0
- package/scripts/img2mesh/props/night-market-gate.json +10 -0
- package/scripts/img2mesh/render_still.py +86 -0
- package/scripts/img2mesh/rig_strip.mjs +46 -0
- package/scripts/img2mesh/rig_transfer.mjs +104 -0
- package/scripts/img2mesh/split_sheet.py +48 -0
- package/scripts/img2mesh/trellis_batch.py +110 -0
- package/scripts/img2mesh/versus_board.py +114 -0
- package/scripts/import-bundle.d.mts +2 -0
- package/scripts/import-bundle.mjs +20 -0
- package/scripts/ktx2-ab-board.py +133 -0
- package/scripts/ktx2-ab.mjs +111 -0
- package/scripts/ktx2-settings.mjs +18 -0
- package/scripts/land.d.mts +14 -0
- package/scripts/land.mjs +809 -0
- package/scripts/lint-dispatch.mjs +14 -0
- package/scripts/map-bake-frames.d.mts +4 -0
- package/scripts/map-bake-frames.mjs +23 -0
- package/scripts/map-geometry.d.mts +9 -0
- package/scripts/map-geometry.mjs +29 -0
- package/scripts/map-world.mjs +162 -0
- package/scripts/mockup-local.sh +46 -0
- package/scripts/music/export-midi.mjs +68 -0
- package/scripts/music/gen/analyze.py +308 -0
- package/scripts/music/gen/audio_jobs.py +46 -0
- package/scripts/music/gen/briefs.json +51 -0
- package/scripts/music/gen/build_page.py +334 -0
- package/scripts/music/gen/folk.json +3187 -0
- package/scripts/music/gen/gen_ace_step.py +156 -0
- package/scripts/music/gen/gen_heartmula.py +187 -0
- package/scripts/music/gen/gen_minimax.py +143 -0
- package/scripts/music/gen/gen_sao.py +122 -0
- package/scripts/music/gen/gen_sao_small.py +104 -0
- package/scripts/music/gen/gen_sfx.py +98 -0
- package/scripts/music/gen/gen_sfx_ezaudio.py +112 -0
- package/scripts/music/gen/gen_sfx_moss.py +112 -0
- package/scripts/music/gen/models.json +61 -0
- package/scripts/music/gen/nalati-jobs.json +104 -0
- package/scripts/music/gen/nalati-score-build.json +119 -0
- package/scripts/music/gen/nalati-score.json +3448 -0
- package/scripts/music/gen/ob7-fit-decisions.json +38 -0
- package/scripts/music/gen/ob7-score-jobs.json +152 -0
- package/scripts/music/gen/ob7-sfx-jobs.json +897 -0
- package/scripts/music/gen/ob7_build.py +469 -0
- package/scripts/music/gen/ob7_generate.py +67 -0
- package/scripts/music/gen/ob7_run.sh +42 -0
- package/scripts/music/gen/orchestral.json +3187 -0
- package/scripts/music/gen/own_score.py +486 -0
- package/scripts/music/gen/ph-jobs.json +27 -0
- package/scripts/music/gen/ph_page.py +222 -0
- package/scripts/music/gen/piano.json +3175 -0
- package/scripts/music/gen/rank_v3.py +248 -0
- package/scripts/music/gen/sfx-best.json +2486 -0
- package/scripts/music/gen/sfx-ezaudio.json +4082 -0
- package/scripts/music/gen/sfx-jobs.json +57 -0
- package/scripts/music/gen/sfx-minimax-jobs.json +16 -0
- package/scripts/music/gen/sfx-minimax.json +289 -0
- package/scripts/music/gen/sfx-moss.json +4082 -0
- package/scripts/music/gen/sfx-nalati-b3-jobs.json +17 -0
- package/scripts/music/gen/sfx-nalati-jobs.json +338 -0
- package/scripts/music/gen/sfx-nalati.json +11202 -0
- package/scripts/music/gen/sfx-nd-jobs.json +57 -0
- package/scripts/music/gen/sfx-nd-moss.json +2097 -0
- package/scripts/music/gen/sfx-nd-sa3-medium.json +2097 -0
- package/scripts/music/gen/sfx-nd-summary.json +38 -0
- package/scripts/music/gen/sfx-peaks.json +7 -0
- package/scripts/music/gen/sfx-ph-jobs.json +169 -0
- package/scripts/music/gen/sfx-ph-moss.json +6564 -0
- package/scripts/music/gen/sfx-ph-sa3-medium.json +7239 -0
- package/scripts/music/gen/sfx-ph-summary.json +63 -0
- package/scripts/music/gen/sfx-sa3-medium.json +4082 -0
- package/scripts/music/gen/sfx-sa3.json +4082 -0
- package/scripts/music/gen/sfx-summary.json +107 -0
- package/scripts/music/gen/sfx_build.py +332 -0
- package/scripts/music/gen/sfx_merge.py +255 -0
- package/scripts/music/gen/sfx_minimax.py +61 -0
- package/scripts/music/gen/sfx_nalati.py +331 -0
- package/scripts/music/gen/sfx_sprite.py +424 -0
- package/scripts/music/gen/stems.py +539 -0
- package/scripts/music/gen/test_loop_meter.py +29 -0
- package/scripts/music/gen/test_ob7_provenance.py +77 -0
- package/scripts/music/gen/v3-folk-build.json +148 -0
- package/scripts/music/gen/v3-folk.json +1818 -0
- package/scripts/music/gen/v3-jobs.json +145 -0
- package/scripts/music/gen/v3-orchestral-build.json +148 -0
- package/scripts/music/gen/v3-orchestral.json +1813 -0
- package/scripts/music/gen/v3-ph-folk-build.json +94 -0
- package/scripts/music/gen/v3-ph-folk.json +1806 -0
- package/scripts/music/gen/v3-ph-orchestral-build.json +94 -0
- package/scripts/music/gen/v3-ph-orchestral.json +1824 -0
- package/scripts/music/gen/v3-ph-piano-build.json +94 -0
- package/scripts/music/gen/v3-ph-piano.json +1818 -0
- package/scripts/music/gen/v3-piano-build.json +148 -0
- package/scripts/music/gen/v3-piano.json +1813 -0
- package/scripts/music/wildshard-theme.mid +0 -0
- package/scripts/music/wildshard-trailer30.mid +0 -0
- package/scripts/named-blob-output.d.mts +8 -0
- package/scripts/named-blob-output.mjs +48 -0
- package/scripts/pack-all.mjs +15 -0
- package/scripts/pid-lock.d.mts +1 -0
- package/scripts/pid-lock.mjs +63 -0
- package/scripts/practice/bake_dummy.py +53 -0
- package/scripts/practice/build_dummies.sh +43 -0
- package/scripts/practice/dummy_parts.py +568 -0
- package/scripts/practice/dummy_rig_gate.py +139 -0
- package/scripts/practice/gate_sheet.py +36 -0
- package/scripts/practice/generate_dummy_unimate.py +132 -0
- package/scripts/practice/pack_dummy.mjs +59 -0
- package/scripts/practice/repair_dummy_weights.mjs +68 -0
- package/scripts/practice/rig_dummy.py +828 -0
- package/scripts/practice/verify_unimate_skin.mjs +356 -0
- package/scripts/preparation-seed.mjs +15 -0
- package/scripts/prepare-basis-tool.mjs +6 -0
- package/scripts/prepare-product.d.mts +14 -0
- package/scripts/prepare-product.mjs +101 -0
- package/scripts/product-build-tools.d.mts +3 -0
- package/scripts/product-build-tools.json +3 -0
- package/scripts/product-build-tools.mjs +31 -0
- package/scripts/publish-public.mjs +7 -0
- package/scripts/push-tables.d.mts +1 -0
- package/scripts/push-tables.mjs +28 -0
- package/scripts/record-shard-mounts.mjs +133 -0
- package/scripts/sdk-externals.d.mts +2 -0
- package/scripts/sdk-externals.mjs +2 -0
- package/scripts/section-inventory.ts +209 -0
- package/scripts/select-candidate.mjs +15 -0
- package/scripts/shard-build-pool.d.mts +4 -0
- package/scripts/shard-build-pool.mjs +53 -0
- package/scripts/shard-line-baseline.json +17 -0
- package/scripts/shard-milestones.d.mts +15 -0
- package/scripts/shard-milestones.mjs +105 -0
- package/scripts/shard-output-report.d.mts +9 -0
- package/scripts/shard-output-report.mjs +85 -0
- package/scripts/shard-platform-cli.mjs +93 -0
- package/scripts/shard-progress.mjs +212 -0
- package/scripts/shard-timelapse.py +102 -0
- package/scripts/shardfile-cold-boot.mjs +79 -0
- package/scripts/shardfile-vite.d.mts +4 -0
- package/scripts/shardfile-vite.mjs +20 -0
- package/scripts/simplify-models.mjs +24 -0
- package/scripts/site-facts.mjs +88 -0
- package/scripts/test-template-gate.mjs +44 -0
- package/scripts/test_golden_compare.py +68 -0
- package/scripts/tex-tiers.cache.json +181 -0
- package/scripts/tex-tiers.mjs +240 -0
- package/scripts/texmem-probe.mjs +184 -0
- package/scripts/unused-assets.mjs +173 -0
- package/scripts/vite-tmp.d.mts +23 -0
- package/scripts/vite-tmp.mjs +157 -0
- package/scripts/wave-line-baselines.json +32 -0
- package/scripts/wildshard.d.mts +4 -0
- package/scripts/wildshard.mjs +105 -0
- package/scripts/witness-checkpoints.d.mts +10 -0
- package/scripts/witness-checkpoints.mjs +84 -0
- package/scripts/witness-generation.d.mts +10 -0
- package/scripts/witness-generation.mjs +45 -0
- package/scripts/witness-manifests.d.mts +8 -0
- package/scripts/witness-manifests.mjs +157 -0
- package/scripts/worktree-ignore.d.mts +4 -0
- package/scripts/worktree-ignore.mjs +36 -0
- package/scripts/worktree-reap.mjs +214 -0
- package/scripts/worktree.mjs +396 -0
- package/scripts/worldclaw/capture-front.sh +28 -0
- package/scripts/worldclaw/design-template.md +62 -0
- package/scripts/worldclaw/spec-map.py +92 -0
- package/scripts/worldclaw/spec.ts +96 -0
- package/skills/wildshard/SKILL.md +50 -0
- package/skills/wildshard-goldens/SKILL.md +54 -0
- package/skills/wildshard-mockup-to-model/SKILL.md +56 -0
- package/skills/wildshard-upgrade/SKILL.md +47 -0
- package/src/.oxfmtrc.json +50 -0
- package/src/.oxlintrc.json +173 -0
- package/src/cli/account/account.ts +199 -0
- package/src/cli/account/command.ts +193 -0
- package/src/cli/account/key.ts +154 -0
- package/src/cli/args.ts +97 -0
- package/src/cli/audio/audio.ts +39 -0
- package/src/cli/bin.mjs +8 -0
- package/src/cli/delete/delete.ts +258 -0
- package/src/cli/help.ts +204 -0
- package/src/cli/hero/adopt.ts +103 -0
- package/src/cli/hero/hero.ts +112 -0
- package/src/cli/hero/stamp.ts +298 -0
- package/src/cli/main.ts +291 -0
- package/src/cli/report.ts +20 -0
- package/src/cli/shardfile/command.ts +49 -0
- package/src/cli/shardfile/shardfile.ts +192 -0
- package/src/cli/upload/api.ts +246 -0
- package/src/cli/upload/compress.ts +55 -0
- package/src/cli/upload/hero.ts +62 -0
- package/src/cli/upload/placement.ts +115 -0
- package/src/cli/upload/provenance.ts +192 -0
- package/src/cli/upload/signature.ts +30 -0
- package/src/cli/upload/upload.ts +269 -0
- package/src/cli/upload/validate.ts +74 -0
- package/src/cli/upload/wire.ts +147 -0
- package/src/cli/version.ts +63 -0
- package/src/commons/bake/portableMath.ts +187 -0
- package/src/commons/catalogue.ts +10 -0
- package/src/commons/courseProgram.ts +32 -0
- package/src/commons/practiceCourse.ts +16 -0
- package/src/commons/scripts/abi.as +14 -0
- package/src/commons/scripts/bridge.as +14 -0
- package/src/commons/scripts/course.as +63 -0
- package/src/scripts/ask-new.sh +29 -0
- package/src/scripts/asks.mjs +141 -0
- package/src/scripts/herdr-prompt.sh +34 -0
- package/src/scripts/herdr-question-open.sh +67 -0
- package/src/scripts/md-wrap.mjs +229 -0
- package/src/server/app.ts +19 -0
- package/src/server/serve.ts +49 -0
- package/src/sharddev/admission.ts +7 -0
- package/src/sharddev/agentFiles.ts +127 -0
- package/src/sharddev/arenaView.ts +15 -0
- package/src/sharddev/as/groupBankV2.ts +36 -0
- package/src/sharddev/as/groupStepV2.ts +13 -0
- package/src/sharddev/as/ws.ts +30 -0
- package/src/sharddev/as/wsV2.ts +180 -0
- package/src/sharddev/assemblyscriptCompiler.d.mts +5 -0
- package/src/sharddev/assemblyscriptCompiler.mjs +14 -0
- package/src/sharddev/assetHandle.ts +84 -0
- package/src/sharddev/assetOwner.ts +70 -0
- package/src/sharddev/assetScope.ts +30 -0
- package/src/sharddev/assets.ts +21 -0
- package/src/sharddev/audio.ts +9 -0
- package/src/sharddev/audioEncode.ts +211 -0
- package/src/sharddev/author.ts +3 -0
- package/src/sharddev/authorError.ts +28 -0
- package/src/sharddev/authorManifest.ts +39 -0
- package/src/sharddev/bake/annulus.ts +19 -0
- package/src/sharddev/bake/assemblyscriptMemo.ts +76 -0
- package/src/sharddev/bake/assemblyscriptMemoPort.ts +4 -0
- package/src/sharddev/bake/authoredWorld.ts +201 -0
- package/src/sharddev/bake/basisEncoder.ts +95 -0
- package/src/sharddev/bake/basisGlb.ts +85 -0
- package/src/sharddev/bake/basisTool.ts +74 -0
- package/src/sharddev/bake/basisToolInputs.ts +476 -0
- package/src/sharddev/bake/byteCodec.ts +33 -0
- package/src/sharddev/bake/canvasAtlas.ts +406 -0
- package/src/sharddev/bake/coarseCopy.ts +59 -0
- package/src/sharddev/bake/colliders.ts +87 -0
- package/src/sharddev/bake/compactGlb.ts +224 -0
- package/src/sharddev/bake/compileScript.ts +119 -0
- package/src/sharddev/bake/compileScriptV2.ts +75 -0
- package/src/sharddev/bake/contactRows.ts +84 -0
- package/src/sharddev/bake/creaturePlacement.ts +117 -0
- package/src/sharddev/bake/export.ts +67 -0
- package/src/sharddev/bake/facetedGeometry.ts +379 -0
- package/src/sharddev/bake/farImpostor.ts +120 -0
- package/src/sharddev/bake/forest.ts +100 -0
- package/src/sharddev/bake/format-hook.mjs +2 -0
- package/src/sharddev/bake/generatorGlb.ts +23 -0
- package/src/sharddev/bake/geometryBounds.ts +77 -0
- package/src/sharddev/bake/geometryError.ts +48 -0
- package/src/sharddev/bake/glb.ts +355 -0
- package/src/sharddev/bake/glbCompression.ts +143 -0
- package/src/sharddev/bake/gltfSource.ts +59 -0
- package/src/sharddev/bake/groundMap.ts +142 -0
- package/src/sharddev/bake/image.ts +20 -0
- package/src/sharddev/bake/isleMap.ts +64 -0
- package/src/sharddev/bake/json.mjs +84 -0
- package/src/sharddev/bake/keyedSky.ts +47 -0
- package/src/sharddev/bake/keyedSkyMemo.ts +39 -0
- package/src/sharddev/bake/kinds.ts +137 -0
- package/src/sharddev/bake/lightSources.ts +31 -0
- package/src/sharddev/bake/mapAssembly.ts +84 -0
- package/src/sharddev/bake/mapRaster.ts +173 -0
- package/src/sharddev/bake/mapRest.ts +57 -0
- package/src/sharddev/bake/mapScenes.ts +234 -0
- package/src/sharddev/bake/materialGraph.ts +32 -0
- package/src/sharddev/bake/meadow.ts +27 -0
- package/src/sharddev/bake/meshoptChoiceMemo.ts +34 -0
- package/src/sharddev/bake/nativeInteractionFacts.ts +5 -0
- package/src/sharddev/bake/nativeLattice.ts +178 -0
- package/src/sharddev/bake/nativeRaster.ts +106 -0
- package/src/sharddev/bake/nativeTerrainField.ts +11 -0
- package/src/sharddev/bake/navigation-json.mjs +38 -0
- package/src/sharddev/bake/navigation.ts +113 -0
- package/src/sharddev/bake/navigationAsset.ts +18 -0
- package/src/sharddev/bake/nearPlaceholder.ts +206 -0
- package/src/sharddev/bake/normalizeRig.ts +80 -0
- package/src/sharddev/bake/phoneAstc.ts +93 -0
- package/src/sharddev/bake/placeholders.ts +581 -0
- package/src/sharddev/bake/placement.ts +80 -0
- package/src/sharddev/bake/portableBytes.ts +18 -0
- package/src/sharddev/bake/portableBytesMemo.ts +50 -0
- package/src/sharddev/bake/practiceCourse.ts +49 -0
- package/src/sharddev/bake/primitives.ts +96 -0
- package/src/sharddev/bake/props.ts +443 -0
- package/src/sharddev/bake/questPlacement.ts +98 -0
- package/src/sharddev/bake/rawTexture.ts +26 -0
- package/src/sharddev/bake/riderArms.ts +97 -0
- package/src/sharddev/bake/rig.ts +95 -0
- package/src/sharddev/bake/riggedHullRecipes.ts +40 -0
- package/src/sharddev/bake/signPlacements.ts +25 -0
- package/src/sharddev/bake/simplifier.ts +52 -0
- package/src/sharddev/bake/skinned.ts +312 -0
- package/src/sharddev/bake/slabChunks.ts +149 -0
- package/src/sharddev/bake/slabs.ts +263 -0
- package/src/sharddev/bake/source-loader.mjs +55 -0
- package/src/sharddev/bake/sourceMetadata.ts +54 -0
- package/src/sharddev/bake/species.ts +368 -0
- package/src/sharddev/bake/specimenCatalogue.ts +47 -0
- package/src/sharddev/bake/splatGround.ts +141 -0
- package/src/sharddev/bake/staticMaterials.ts +171 -0
- package/src/sharddev/bake/terrain.ts +195 -0
- package/src/sharddev/bake/texture.ts +33 -0
- package/src/sharddev/bake/textureWasm.ts +81 -0
- package/src/sharddev/bake/tileEncoder.ts +11 -0
- package/src/sharddev/bake/tileGrid.ts +62 -0
- package/src/sharddev/bake/v2Finite.ts +160 -0
- package/src/sharddev/bake/v2Fuel.ts +71 -0
- package/src/sharddev/bake/wholePartition.ts +74 -0
- package/src/sharddev/bake/wholePieceJoin.ts +147 -0
- package/src/sharddev/bake/world.ts +173 -0
- package/src/sharddev/bake/worldCollision.ts +128 -0
- package/src/sharddev/bake/worldGeometry.ts +237 -0
- package/src/sharddev/bake/worldGlb.ts +123 -0
- package/src/sharddev/bake/worldImage.ts +12 -0
- package/src/sharddev/bake/worldLod.ts +128 -0
- package/src/sharddev/bake/worldRows.ts +102 -0
- package/src/sharddev/bake/worldTextureMemo.ts +63 -0
- package/src/sharddev/bake/zstdBytesMemo.ts +52 -0
- package/src/sharddev/bake.ts +193 -0
- package/src/sharddev/bakePublication.ts +31 -0
- package/src/sharddev/behaviourSource.ts +94 -0
- package/src/sharddev/bin/wildshard.mjs +7 -0
- package/src/sharddev/blobBytes.ts +65 -0
- package/src/sharddev/blobs.ts +138 -0
- package/src/sharddev/bootInventory.ts +129 -0
- package/src/sharddev/bossProfiles.ts +18 -0
- package/src/sharddev/buildBehaviour.ts +77 -0
- package/src/sharddev/buildCacheMetrics.ts +17 -0
- package/src/sharddev/buildDecisionScripts.ts +122 -0
- package/src/sharddev/check.ts +118 -0
- package/src/sharddev/checkProject.ts +127 -0
- package/src/sharddev/cli.ts +200 -0
- package/src/sharddev/clientChannels.ts +169 -0
- package/src/sharddev/clientScripts.ts +10 -0
- package/src/sharddev/commons.ts +77 -0
- package/src/sharddev/commonsCosts.ts +11 -0
- package/src/sharddev/compileMovers.ts +11 -0
- package/src/sharddev/configBoundary.ts +6 -0
- package/src/sharddev/cookInput.ts +40 -0
- package/src/sharddev/crowds.ts +6 -0
- package/src/sharddev/decisionBindingMap.ts +11 -0
- package/src/sharddev/decisionScriptBindings.ts +117 -0
- package/src/sharddev/decisionScripts.ts +28 -0
- package/src/sharddev/decisionSource.ts +51 -0
- package/src/sharddev/dev.ts +113 -0
- package/src/sharddev/director.ts +26 -0
- package/src/sharddev/directorAbi.ts +77 -0
- package/src/sharddev/discoveryDocument.ts +97 -0
- package/src/sharddev/draft.ts +11 -0
- package/src/sharddev/eliteEntryRows.ts +29 -0
- package/src/sharddev/entries.ts +76 -0
- package/src/sharddev/entryReads.ts +73 -0
- package/src/sharddev/executeBundle.ts +55 -0
- package/src/sharddev/finds.ts +5 -0
- package/src/sharddev/formatJsonSchema.ts +3 -0
- package/src/sharddev/generationCache.ts +257 -0
- package/src/sharddev/generationRecipe.ts +94 -0
- package/src/sharddev/handwritten.ts +110 -0
- package/src/sharddev/immutable.ts +14 -0
- package/src/sharddev/interactions.ts +38 -0
- package/src/sharddev/kit/bakedGeometry.ts +16 -0
- package/src/sharddev/kit/geometryPack.ts +110 -0
- package/src/sharddev/ledger.ts +13 -0
- package/src/sharddev/looks/tileField.ts +67 -0
- package/src/sharddev/materialGraphFiles.ts +57 -0
- package/src/sharddev/materials.ts +574 -0
- package/src/sharddev/measure.ts +18 -0
- package/src/sharddev/modes.ts +115 -0
- package/src/sharddev/moverPrograms.ts +213 -0
- package/src/sharddev/movers.ts +75 -0
- package/src/sharddev/nativePopulationRows.ts +46 -0
- package/src/sharddev/newProject.ts +226 -0
- package/src/sharddev/noise.ts +54 -0
- package/src/sharddev/outputProduct.ts +188 -0
- package/src/sharddev/outputRuntime.ts +66 -0
- package/src/sharddev/performancePolicy.ts +29 -0
- package/src/sharddev/phasedBoss.ts +34 -0
- package/src/sharddev/physics.ts +194 -0
- package/src/sharddev/platformSections.ts +42 -0
- package/src/sharddev/plumbing.ts +8 -0
- package/src/sharddev/productOutput.ts +128 -0
- package/src/sharddev/project.ts +337 -0
- package/src/sharddev/projectCompilerIdentity.ts +94 -0
- package/src/sharddev/projectDecisions.ts +66 -0
- package/src/sharddev/projectEntryProof.ts +32 -0
- package/src/sharddev/projectGeneration.ts +219 -0
- package/src/sharddev/projectInputFiles.ts +47 -0
- package/src/sharddev/projectManifest.ts +108 -0
- package/src/sharddev/projectMap.ts +35 -0
- package/src/sharddev/projectOutput.ts +242 -0
- package/src/sharddev/projectPolicy.ts +17 -0
- package/src/sharddev/projectSections.ts +27 -0
- package/src/sharddev/questGraph.ts +25 -0
- package/src/sharddev/quests.ts +65 -0
- package/src/sharddev/random.ts +61 -0
- package/src/sharddev/refusals.ts +304 -0
- package/src/sharddev/reportCard.ts +13 -0
- package/src/sharddev/returnProjectionV2.ts +81 -0
- package/src/sharddev/rows.ts +192 -0
- package/src/sharddev/runtimeImports.ts +38 -0
- package/src/sharddev/runtimeMirrors.ts +39 -0
- package/src/sharddev/runtimePerformance.ts +38 -0
- package/src/sharddev/scene.ts +321 -0
- package/src/sharddev/sceneAnimation.ts +54 -0
- package/src/sharddev/sceneAudio.ts +64 -0
- package/src/sharddev/sceneDeclarations.ts +100 -0
- package/src/sharddev/sceneGraph.ts +139 -0
- package/src/sharddev/sceneTransform.ts +12 -0
- package/src/sharddev/schemaValidation.ts +61 -0
- package/src/sharddev/sections.ts +47 -0
- package/src/sharddev/shardSource.ts +59 -0
- package/src/sharddev/sourceReader.ts +26 -0
- package/src/sharddev/spawns.ts +38 -0
- package/src/sharddev/species/clips.ts +24 -0
- package/src/sharddev/species.ts +29 -0
- package/src/sharddev/speciesBrains.ts +19 -0
- package/src/sharddev/synth.ts +66 -0
- package/src/sharddev/test/compileDualScriptV2.ts +71 -0
- package/src/sharddev/test/compileSimV2.ts +21 -0
- package/src/sharddev/test/diskScriptScenario.ts +86 -0
- package/src/sharddev/test/scriptScenario.ts +249 -0
- package/src/sharddev/test/scriptSource.ts +12 -0
- package/src/sharddev/version.ts +4 -0
- package/src/sharddev/weapons/bowProfile.ts +20 -0
- package/src/sharddev/weapons/firearmRows.ts +11 -0
- package/src/sharddev/weapons/meleeProfile.ts +71 -0
- package/src/sharddev/weapons/thrownProfile.ts +10 -0
- package/src/sharddev/worldScenes.ts +308 -0
- package/src/sharddev/worldSource.ts +82 -0
- package/src/shards/_template/README.md +78 -0
- package/src/shards/_template/assets/2bf489fdb15f1734ddb4c4f32d500ec6da85c765ec7a4eb28dc6781160e7ec8c +0 -0
- package/src/shards/_template/assets/97ec4d8f75f5fa6239ee919444d6dc19fd35896bb305930c1f050ac6e0e0e6a6 +1 -0
- package/src/shards/_template/assets/a6a587a31327f936b1b04c05ade818c73fc8964260918662db43539465e27586 +0 -0
- package/src/shards/_template/assets/b4fbde0422e125b498c3dc8b9a5cc2516c8598f09e9d0e5f6b639b32f98179e6 +0 -0
- package/src/shards/_template/assets/bfa4dfc9c18979f904557ee8deab0058b8a399be10266f5fb1578b403f482fd4 +1 -0
- package/src/shards/_template/assets/ef3b7ff4fd22715771cb7d68a3977a903c5e7c3dc293542687d04b3ef3ace2cb +0 -0
- package/src/shards/_template/assets/f2db05998615ce1cb79ea96be32c168842eb6a2b34ec01feb86d36404603ee54 +0 -0
- package/src/shards/_template/assets/fef98ebb7fce6f66b26e78ac699e5c90f9bdcfaf8cabeb2b58125347eea8b4ab +0 -0
- package/src/shards/_template/behaviour/boss.as +39 -0
- package/src/shards/_template/behaviour/door.as +32 -0
- package/src/shards/_template/behaviour/hooks.json +129 -0
- package/src/shards/_template/behaviour/idle.as +75 -0
- package/src/shards/_template/behaviour/items.as +22 -0
- package/src/shards/_template/card/landscape.jpg +0 -0
- package/src/shards/_template/card/portrait.jpg +0 -0
- package/src/shards/_template/card/thumb.jpg +0 -0
- package/src/shards/_template/data/audio.json +45 -0
- package/src/shards/_template/data/bossDecision.json +83 -0
- package/src/shards/_template/data/budgets.json +70 -0
- package/src/shards/_template/data/card.json +281 -0
- package/src/shards/_template/data/clientScripts.json +987 -0
- package/src/shards/_template/data/creatures.json +65 -0
- package/src/shards/_template/data/director.json +39 -0
- package/src/shards/_template/data/encounters.json +96 -0
- package/src/shards/_template/data/items.json +172 -0
- package/src/shards/_template/data/layout.json +66 -0
- package/src/shards/_template/data/ledger.json +32 -0
- package/src/shards/_template/data/look.json +521 -0
- package/src/shards/_template/data/map.json +64 -0
- package/src/shards/_template/data/moves.json +16 -0
- package/src/shards/_template/data/placeholder.json +8 -0
- package/src/shards/_template/data/plumbing.json +32 -0
- package/src/shards/_template/data/quests.json +223 -0
- package/src/shards/_template/data/rows.json +423 -0
- package/src/shards/_template/data/skins.json +66 -0
- package/src/shards/_template/data/spawn.json +6 -0
- package/src/shards/_template/data/targets.json +150 -0
- package/src/shards/_template/data/text.json +12 -0
- package/src/shards/_template/data/ui.json +33 -0
- package/src/shards/_template/data/water.json +13 -0
- package/src/shards/_template/generators/behaviour.ts +34 -0
- package/src/shards/_template/generators/boss.ts +29 -0
- package/src/shards/_template/generators/buildOptions.ts +2 -0
- package/src/shards/_template/generators/cell.ts +224 -0
- package/src/shards/_template/generators/districts.ts +215 -0
- package/src/shards/_template/generators/farLook.ts +15 -0
- package/src/shards/_template/generators/generate.ts +27 -0
- package/src/shards/_template/generators/ground.ts +15 -0
- package/src/shards/_template/generators/kit.ts +69 -0
- package/src/shards/_template/generators/landscape.ts +59 -0
- package/src/shards/_template/generators/landscapeNoise.ts +62 -0
- package/src/shards/_template/generators/mapInputs.ts +10 -0
- package/src/shards/_template/generators/product.ts +100 -0
- package/src/shards/_template/generators/productOutput.ts +18 -0
- package/src/shards/_template/generators/props.ts +9 -0
- package/src/shards/_template/generators/templatePropsSource.ts +58 -0
- package/src/shards/_template/generators/terrain.ts +17 -0
- package/src/shards/_template/generators/world.ts +630 -0
- package/src/shards/_template/hero.json +10 -0
- package/src/shards/_template/look/entry-reads.json +20 -0
- package/src/shards/_template/manifest.json +281 -0
- package/src/shards/_template/shard.config.ts +10 -0
- package/src/shared/health.ts +10 -0
- package/src/tools/build-web.ts +59 -0
- package/src/tsconfig.json +30 -0
- package/src/web/app.tsx +53 -0
- package/src/web/index.html +12 -0
- package/src/web/main.tsx +10 -0
- package/src/web/tsconfig.json +13 -0
- package/tsconfig.author.json +23 -0
- package/tsconfig.commons.json +21 -0
- package/tsconfig.json +47 -0
- package/tsconfig.sharddev.json +20 -0
|
@@ -0,0 +1,86 @@
|
|
|
1
|
+
"""Render one model (glb / gltf / obj) as a 3/4 turntable still, the same light for every prop.
|
|
2
|
+
|
|
3
|
+
blender -b -P scripts/img2mesh/render_still.py -- <model>[,<model>…] <out.png> [--size 512] [--yaw 35] [--flat]
|
|
4
|
+
|
|
5
|
+
Several comma-separated models are laid out left to right in a row (a set: boulders, driftwood, shells).
|
|
6
|
+
|
|
7
|
+
Eevee, sun from the front-left + a soft sky fill, orthographic-ish framing (long lens) on a light-grey backdrop.
|
|
8
|
+
--flat forces flat shading on every mesh (to preview the faceted look of a raw generation).
|
|
9
|
+
"""
|
|
10
|
+
import math
|
|
11
|
+
import sys
|
|
12
|
+
|
|
13
|
+
import bpy
|
|
14
|
+
from mathutils import Vector
|
|
15
|
+
|
|
16
|
+
argv = sys.argv[sys.argv.index("--") + 1:]
|
|
17
|
+
src, out = argv[0], argv[1]
|
|
18
|
+
size = int(argv[argv.index("--size") + 1]) if "--size" in argv else 512
|
|
19
|
+
yaw = float(argv[argv.index("--yaw") + 1]) if "--yaw" in argv else 35.0
|
|
20
|
+
flat = "--flat" in argv
|
|
21
|
+
|
|
22
|
+
bpy.ops.wm.read_factory_settings(use_empty=True)
|
|
23
|
+
x = 0.0
|
|
24
|
+
for one in src.split(","):
|
|
25
|
+
before = set(bpy.context.scene.objects)
|
|
26
|
+
if one.endswith(".obj"):
|
|
27
|
+
bpy.ops.wm.obj_import(filepath=one)
|
|
28
|
+
else:
|
|
29
|
+
bpy.ops.import_scene.gltf(filepath=one)
|
|
30
|
+
new = [o for o in bpy.context.scene.objects if o not in before]
|
|
31
|
+
roots = [o for o in new if o.parent is None]
|
|
32
|
+
bpy.context.view_layer.update()
|
|
33
|
+
xs = [(o.matrix_world @ Vector(c)).x for o in new if o.type == "MESH" for c in o.bound_box]
|
|
34
|
+
lo_x, hi_x = min(xs), max(xs)
|
|
35
|
+
for r in roots:
|
|
36
|
+
r.location.x += x - lo_x
|
|
37
|
+
x += (hi_x - lo_x) * 1.15
|
|
38
|
+
|
|
39
|
+
bpy.context.view_layer.update()
|
|
40
|
+
meshes = [o for o in bpy.context.scene.objects if o.type == "MESH"]
|
|
41
|
+
if flat:
|
|
42
|
+
for o in meshes:
|
|
43
|
+
for p in o.data.polygons:
|
|
44
|
+
p.use_smooth = False
|
|
45
|
+
lo = Vector((1e9, 1e9, 1e9))
|
|
46
|
+
hi = Vector((-1e9, -1e9, -1e9))
|
|
47
|
+
for o in meshes:
|
|
48
|
+
for c in o.bound_box:
|
|
49
|
+
w = o.matrix_world @ Vector(c)
|
|
50
|
+
lo = Vector(map(min, lo, w))
|
|
51
|
+
hi = Vector(map(max, hi, w))
|
|
52
|
+
center = (lo + hi) / 2
|
|
53
|
+
radius = max((hi - lo).length / 2, 1e-3)
|
|
54
|
+
|
|
55
|
+
scene = bpy.context.scene
|
|
56
|
+
scene.render.engine = "BLENDER_EEVEE_NEXT" if "BLENDER_EEVEE_NEXT" in {e.identifier for e in bpy.types.RenderSettings.bl_rna.properties["engine"].enum_items} else "BLENDER_EEVEE"
|
|
57
|
+
scene.render.resolution_x = scene.render.resolution_y = size
|
|
58
|
+
scene.render.film_transparent = False
|
|
59
|
+
scene.view_settings.view_transform = "Standard"
|
|
60
|
+
|
|
61
|
+
world = bpy.data.worlds.new("w")
|
|
62
|
+
scene.world = world
|
|
63
|
+
world.use_nodes = True
|
|
64
|
+
bg = world.node_tree.nodes["Background"]
|
|
65
|
+
bg.inputs[0].default_value = (0.78, 0.82, 0.86, 1)
|
|
66
|
+
bg.inputs[1].default_value = 0.9
|
|
67
|
+
|
|
68
|
+
sun = bpy.data.objects.new("sun", bpy.data.lights.new("sun", "SUN"))
|
|
69
|
+
sun.data.energy = 3.2
|
|
70
|
+
sun.data.angle = math.radians(3)
|
|
71
|
+
sun.rotation_euler = (math.radians(50), 0, math.radians(yaw - 60))
|
|
72
|
+
scene.collection.objects.link(sun)
|
|
73
|
+
|
|
74
|
+
cam = bpy.data.objects.new("cam", bpy.data.cameras.new("cam"))
|
|
75
|
+
cam.data.lens = 85
|
|
76
|
+
scene.collection.objects.link(cam)
|
|
77
|
+
scene.camera = cam
|
|
78
|
+
el = math.radians(18)
|
|
79
|
+
az = math.radians(yaw)
|
|
80
|
+
dist = radius / math.tan(cam.data.angle / 2) * 0.95
|
|
81
|
+
cam.location = center + Vector((math.sin(az) * math.cos(el), -math.cos(az) * math.cos(el), math.sin(el))) * dist
|
|
82
|
+
cam.rotation_euler = (center - cam.location).to_track_quat("-Z", "Y").to_euler()
|
|
83
|
+
cam.data.clip_end = dist * 4
|
|
84
|
+
|
|
85
|
+
scene.render.filepath = out
|
|
86
|
+
bpy.ops.render.render(write_still=True)
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
// rig_strip.mjs — E304: a rigged game GLB (meshopt, WebP, a glTF skin) → a plain static GLB Blender's importer reads as
|
|
3
|
+
// one mesh in its bind pose (no skin, no meshopt, PNG textures). The face remaster (face_remaster.py) then grafts a new
|
|
4
|
+
// head on it, and rig_transfer.mjs puts the old skin back on the result.
|
|
5
|
+
//
|
|
6
|
+
// node scripts/img2mesh/rig_strip.mjs <in.rigged.glb> <out.glb>
|
|
7
|
+
import { createRequire } from 'node:module';
|
|
8
|
+
import { realpathSync } from 'node:fs';
|
|
9
|
+
import { resolve as resolvePath, join } from 'node:path';
|
|
10
|
+
|
|
11
|
+
const ROOT = resolvePath(new URL('../..', import.meta.url).pathname);
|
|
12
|
+
const req = createRequire(realpathSync(join(ROOT, 'node_modules/@gltf-transform/cli/package.json')));
|
|
13
|
+
const { NodeIO } = req('@gltf-transform/core');
|
|
14
|
+
const { ALL_EXTENSIONS } = req('@gltf-transform/extensions');
|
|
15
|
+
const { MeshoptDecoder } = req('meshoptimizer');
|
|
16
|
+
const sharp = req('sharp');
|
|
17
|
+
|
|
18
|
+
const [inp, out] = process.argv.slice(2);
|
|
19
|
+
if (!inp || !out) { console.error('usage: rig_strip.mjs <in.rigged.glb> <out.glb>'); process.exit(2); }
|
|
20
|
+
await MeshoptDecoder.ready;
|
|
21
|
+
const io = new NodeIO().registerExtensions(ALL_EXTENSIONS).registerDependencies({ 'meshopt.decoder': MeshoptDecoder });
|
|
22
|
+
const doc = await io.read(inp);
|
|
23
|
+
const root = doc.getRoot();
|
|
24
|
+
for (const ext of root.listExtensionsUsed()) {
|
|
25
|
+
const n = ext.extensionName;
|
|
26
|
+
if (n === 'EXT_meshopt_compression' || n === 'EXT_texture_webp') ext.dispose();
|
|
27
|
+
}
|
|
28
|
+
// the skinned mesh node, detached from the skeleton; the bones go (the mesh is in its bind pose: inverse binds = −bone)
|
|
29
|
+
const scene = root.listScenes()[0];
|
|
30
|
+
for (const node of root.listNodes()) {
|
|
31
|
+
if (node.getMesh()) {
|
|
32
|
+
node.setSkin(null);
|
|
33
|
+
for (const prim of node.getMesh().listPrimitives()) {
|
|
34
|
+
for (const k of ['JOINTS_0', 'WEIGHTS_0']) { const a = prim.getAttribute(k); if (a) { prim.setAttribute(k, null); a.dispose(); } }
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
for (const skin of root.listSkins()) skin.dispose();
|
|
39
|
+
for (const node of root.listNodes()) if (!node.getMesh()) node.dispose();
|
|
40
|
+
for (const node of root.listNodes()) if (!scene.listChildren().includes(node)) scene.addChild(node);
|
|
41
|
+
for (const tex of root.listTextures()) {
|
|
42
|
+
const img = tex.getImage();
|
|
43
|
+
if (img && tex.getMimeType() !== 'image/png') tex.setImage(new Uint8Array(await sharp(Buffer.from(img)).png().toBuffer())).setMimeType('image/png');
|
|
44
|
+
}
|
|
45
|
+
await io.write(out, doc);
|
|
46
|
+
console.log(`[strip] ${inp} -> ${out}`);
|
|
@@ -0,0 +1,104 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
// rig_transfer.mjs — E304: put a rigged GLB's skin back on its face-remastered mesh.
|
|
3
|
+
//
|
|
4
|
+
// The face remaster (rig_strip.mjs → face_remaster.py) keeps the body where it was — in the rig's bind pose — and grafts a
|
|
5
|
+
// new head on it. This copies the old file (its skeleton, its joints by name and order, its inverse binds, its material)
|
|
6
|
+
// and swaps in the new geometry and atlas; each new vertex takes the skin of its nearest old vertices (the 4 nearest,
|
|
7
|
+
// inverse-distance weighted, the 4 strongest joints kept). Above the neck cut a vertex looks only at old vertices above
|
|
8
|
+
// it, so the whole new head — its hood drape included — rides the head / crown bones as the old head did, never the
|
|
9
|
+
// chest or the cape.
|
|
10
|
+
//
|
|
11
|
+
// node scripts/img2mesh/rig_transfer.mjs <old.rigged.glb> <new.raw.glb> <out.rigged.glb> --neck-y <m> [--tex 1024]
|
|
12
|
+
import { createRequire } from 'node:module';
|
|
13
|
+
import { realpathSync, statSync } from 'node:fs';
|
|
14
|
+
import { resolve as resolvePath, join } from 'node:path';
|
|
15
|
+
|
|
16
|
+
const ROOT = resolvePath(new URL('../..', import.meta.url).pathname);
|
|
17
|
+
const req = createRequire(realpathSync(join(ROOT, 'node_modules/@gltf-transform/cli/package.json')));
|
|
18
|
+
const { NodeIO } = req('@gltf-transform/core');
|
|
19
|
+
const { ALL_EXTENSIONS } = req('@gltf-transform/extensions');
|
|
20
|
+
const { MeshoptDecoder, MeshoptEncoder } = req('meshoptimizer');
|
|
21
|
+
const sharp = req('sharp');
|
|
22
|
+
|
|
23
|
+
const args = process.argv.slice(2);
|
|
24
|
+
const opt = (k, d) => { const i = args.indexOf(k); return i !== -1 ? args[i + 1] : d; };
|
|
25
|
+
const [oldPath, newPath, outPath] = args.filter((a, i) => !a.startsWith('--') && !(i > 0 && args[i - 1]?.startsWith('--')));
|
|
26
|
+
const neckY = Number(opt('--neck-y', 'NaN'));
|
|
27
|
+
const texSize = Number(opt('--tex', '1024'));
|
|
28
|
+
if (!oldPath || !newPath || !outPath || !Number.isFinite(neckY)) {
|
|
29
|
+
console.error('usage: rig_transfer.mjs <old.rigged.glb> <new.raw.glb> <out.rigged.glb> --neck-y <m> [--tex 1024]');
|
|
30
|
+
process.exit(2);
|
|
31
|
+
}
|
|
32
|
+
await MeshoptDecoder.ready; await MeshoptEncoder.ready;
|
|
33
|
+
const io = new NodeIO().registerExtensions(ALL_EXTENSIONS).registerDependencies({ 'meshopt.decoder': MeshoptDecoder, 'meshopt.encoder': MeshoptEncoder });
|
|
34
|
+
|
|
35
|
+
const oldDoc = await io.read(oldPath);
|
|
36
|
+
const newDoc = await io.read(newPath);
|
|
37
|
+
const oprim = oldDoc.getRoot().listMeshes()[0].listPrimitives()[0];
|
|
38
|
+
const nprim = newDoc.getRoot().listMeshes()[0].listPrimitives()[0];
|
|
39
|
+
const floats = (a) => { const n = a.getCount(), k = a.getElementSize(), out = new Float32Array(n * k), el = []; for (let i = 0; i < n; i++) { a.getElement(i, el); for (let c = 0; c < k; c++) out[i * k + c] = el[c]; } return out; };
|
|
40
|
+
const OP = floats(oprim.getAttribute('POSITION')), OJ = floats(oprim.getAttribute('JOINTS_0')), OW = floats(oprim.getAttribute('WEIGHTS_0'));
|
|
41
|
+
const NP = floats(nprim.getAttribute('POSITION'));
|
|
42
|
+
const on = OP.length / 3, nn = NP.length / 3;
|
|
43
|
+
|
|
44
|
+
const joints = new Uint8Array(nn * 4), weights = new Float32Array(nn * 4);
|
|
45
|
+
const K = 4;
|
|
46
|
+
for (let i = 0; i < nn; i++) {
|
|
47
|
+
const x = NP[i * 3], y = NP[i * 3 + 1], z = NP[i * 3 + 2];
|
|
48
|
+
const head = y > neckY;
|
|
49
|
+
const bi = new Int32Array(K).fill(-1), bd = new Float64Array(K).fill(Infinity);
|
|
50
|
+
for (let j = 0; j < on; j++) {
|
|
51
|
+
if (head && OP[j * 3 + 1] <= neckY) continue;
|
|
52
|
+
const dx = OP[j * 3] - x, dy = OP[j * 3 + 1] - y, dz = OP[j * 3 + 2] - z, d = dx * dx + dy * dy + dz * dz;
|
|
53
|
+
if (d >= bd[K - 1]) continue;
|
|
54
|
+
let s = K - 1;
|
|
55
|
+
while (s > 0 && bd[s - 1] > d) { bd[s] = bd[s - 1]; bi[s] = bi[s - 1]; s--; }
|
|
56
|
+
bd[s] = d; bi[s] = j;
|
|
57
|
+
}
|
|
58
|
+
const acc = new Map();
|
|
59
|
+
for (let s = 0; s < K; s++) {
|
|
60
|
+
const j = bi[s];
|
|
61
|
+
if (j < 0) continue;
|
|
62
|
+
const w = 1 / (Math.sqrt(bd[s]) + 1e-4);
|
|
63
|
+
for (let c = 0; c < 4; c++) {
|
|
64
|
+
const jw = OW[j * 4 + c];
|
|
65
|
+
if (jw > 0) acc.set(OJ[j * 4 + c], (acc.get(OJ[j * 4 + c]) ?? 0) + w * jw);
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
const top = [...acc.entries()].sort((p, q) => q[1] - p[1]).slice(0, 4);
|
|
69
|
+
const sum = top.reduce((s, e) => s + e[1], 0) || 1;
|
|
70
|
+
top.forEach(([jn, w], c) => { joints[i * 4 + c] = jn; weights[i * 4 + c] = w / sum; });
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
// the new geometry into the old file's primitive
|
|
74
|
+
const buf = oldDoc.getRoot().listBuffers()[0];
|
|
75
|
+
const acc = (type, arr) => oldDoc.createAccessor().setType(type).setArray(arr).setBuffer(buf);
|
|
76
|
+
const set = (k, a) => { const prev = oprim.getAttribute(k); oprim.setAttribute(k, a); if (prev && prev.listParents().length <= 1) prev.dispose(); };
|
|
77
|
+
set('POSITION', acc('VEC3', NP));
|
|
78
|
+
// normals i8, uvs u16, weights u8 — normalized (three denormalizes them); positions stay float, as the rig bake wrote them
|
|
79
|
+
// (a quantized position needs a node transform, which a skinned mesh's bind pose would not see)
|
|
80
|
+
const q = (arr, T, max) => T.from(arr, (v) => Math.round(Math.max(T === Int8Array ? -1 : 0, Math.min(1, v)) * max));
|
|
81
|
+
const w8 = new Uint8Array(nn * 4);
|
|
82
|
+
for (let i = 0; i < nn; i++) { // weights to u8, the rounding error given to the strongest so each sums to 255
|
|
83
|
+
let s = 0;
|
|
84
|
+
for (let c = 1; c < 4; c++) { w8[i * 4 + c] = Math.round(weights[i * 4 + c] * 255); s += w8[i * 4 + c]; }
|
|
85
|
+
w8[i * 4] = 255 - s;
|
|
86
|
+
}
|
|
87
|
+
set('NORMAL', acc('VEC3', q(floats(nprim.getAttribute('NORMAL')), Int8Array, 127)).setNormalized(true));
|
|
88
|
+
set('TEXCOORD_0', acc('VEC2', q(floats(nprim.getAttribute('TEXCOORD_0')), Uint16Array, 65535)).setNormalized(true));
|
|
89
|
+
set('JOINTS_0', acc('VEC4', joints));
|
|
90
|
+
set('WEIGHTS_0', acc('VEC4', w8).setNormalized(true));
|
|
91
|
+
const ni = nprim.getIndices().getArray();
|
|
92
|
+
const prevIdx = oprim.getIndices();
|
|
93
|
+
oprim.setIndices(acc('SCALAR', nn > 65535 ? Uint32Array.from(ni) : Uint16Array.from(ni)));
|
|
94
|
+
prevIdx?.dispose();
|
|
95
|
+
// the new atlas, WebP at --tex
|
|
96
|
+
const ntex = newDoc.getRoot().listTextures()[0];
|
|
97
|
+
const otex = oldDoc.getRoot().listTextures()[0];
|
|
98
|
+
const webp = await sharp(Buffer.from(ntex.getImage())).resize(texSize, texSize, { kernel: 'lanczos3' }).webp({ quality: 88 }).toBuffer();
|
|
99
|
+
otex.setImage(new Uint8Array(webp)).setMimeType('image/webp');
|
|
100
|
+
const ex = oldDoc.getRoot().getAsset().extras ?? {};
|
|
101
|
+
oldDoc.getRoot().getAsset().extras = { ...ex, faceRemaster: { by: 'scripts/img2mesh/face_remaster.py + rig_transfer.mjs (E304)', neckY } };
|
|
102
|
+
await io.write(outPath, oldDoc);
|
|
103
|
+
const heads = (() => { let n = 0; for (let i = 0; i < nn; i++) if (NP[i * 3 + 1] > neckY) n++; return n; })();
|
|
104
|
+
console.log(`[transfer] ${outPath}: ${nn} verts (${heads} above the neck), ${ni.length / 3} tris, ${statSync(outPath).size} B`);
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
"""Split a reference sheet of separate objects on white into one square image per object (for image-to-3D: one
|
|
2
|
+
object per generation gets the whole voxel grid, a sheet of six shares it and packs them into a pile).
|
|
3
|
+
|
|
4
|
+
python scripts/img2mesh/split_sheet.py art/driftwood-isle/round-8-assets/ref-clutter.jpg OUTDIR [--min 0.004]
|
|
5
|
+
|
|
6
|
+
Writes OUTDIR/<stem>-<n>.png (RGBA: the white background keyed out, 12 % margin), numbered left to right, top to
|
|
7
|
+
bottom, and prints each crop's box. Needs numpy, pillow, scipy.
|
|
8
|
+
"""
|
|
9
|
+
import argparse
|
|
10
|
+
import os
|
|
11
|
+
|
|
12
|
+
import numpy as np
|
|
13
|
+
from PIL import Image
|
|
14
|
+
from scipy import ndimage
|
|
15
|
+
|
|
16
|
+
ap = argparse.ArgumentParser()
|
|
17
|
+
ap.add_argument("sheet")
|
|
18
|
+
ap.add_argument("out")
|
|
19
|
+
ap.add_argument("--min", type=float, default=0.004, help="drop blobs smaller than this share of the image")
|
|
20
|
+
ap.add_argument("--thresh", type=int, default=238, help="a pixel is background when all channels are above this")
|
|
21
|
+
a = ap.parse_args()
|
|
22
|
+
|
|
23
|
+
im = np.array(Image.open(a.sheet).convert("RGB"))
|
|
24
|
+
fg = ~(im > a.thresh).all(-1)
|
|
25
|
+
fg = ndimage.binary_closing(fg, iterations=3)
|
|
26
|
+
fg = ndimage.binary_fill_holes(fg)
|
|
27
|
+
lab, n = ndimage.label(fg)
|
|
28
|
+
boxes = ndimage.find_objects(lab)
|
|
29
|
+
H, W = fg.shape
|
|
30
|
+
items = []
|
|
31
|
+
for i, sl in enumerate(boxes):
|
|
32
|
+
area = (lab[sl] == i + 1).sum()
|
|
33
|
+
if area < a.min * H * W:
|
|
34
|
+
continue
|
|
35
|
+
items.append((sl[0].start, sl[1].start, sl[0].stop, sl[1].stop, i + 1))
|
|
36
|
+
items.sort(key=lambda b: (round(b[0] / (H / 3)), b[1]))
|
|
37
|
+
os.makedirs(a.out, exist_ok=True)
|
|
38
|
+
stem = os.path.splitext(os.path.basename(a.sheet))[0].removeprefix("ref-")
|
|
39
|
+
for k, (y0, x0, y1, x1, li) in enumerate(items, 1):
|
|
40
|
+
mask = lab[y0:y1, x0:x1] == li
|
|
41
|
+
rgba = np.dstack([im[y0:y1, x0:x1], (mask * 255).astype(np.uint8)])
|
|
42
|
+
h, w = mask.shape
|
|
43
|
+
side = int(max(h, w) * 1.24)
|
|
44
|
+
canvas = np.zeros((side, side, 4), dtype=np.uint8)
|
|
45
|
+
oy, ox = (side - h) // 2, (side - w) // 2
|
|
46
|
+
canvas[oy:oy + h, ox:ox + w] = rgba
|
|
47
|
+
Image.fromarray(canvas).resize((768, 768), Image.LANCZOS).save(os.path.join(a.out, f"{stem}-{k}.png"))
|
|
48
|
+
print(f"{stem}-{k}: box x{x0}-{x1} y{y0}-{y1}")
|
|
@@ -0,0 +1,110 @@
|
|
|
1
|
+
"""TRELLIS.2 (microsoft/TRELLIS.2-4B, MIT) image -> textured GLB on Apple Silicon (MPS), many images per process.
|
|
2
|
+
|
|
3
|
+
Runs in the trellis-mac venv (shivampkumar/trellis-mac + Pedro Naugusto's Metal backends; install recipe in
|
|
4
|
+
scripts/img2mesh/README.md). Loads the pipeline ONCE (~80 s), then per image writes into --out:
|
|
5
|
+
<stem>.glb decoder mesh decimated to --faces with a baked --tex PBR texture (base colour + MR)
|
|
6
|
+
<stem>.hi.obj the raw decoder mesh (0.3-3 M faces) for re-baking at a different budget
|
|
7
|
+
<stem>.json timings, counts, peak memory
|
|
8
|
+
Modelled on ~/projects/localai/bin/img2mesh/trellis_batch.py (the machine's shared runner).
|
|
9
|
+
|
|
10
|
+
Weights: --weights is a directory holding pipeline.json (default ~/ml/img2mesh/trellis-view, whose pipeline.json
|
|
11
|
+
points every model at ~/projects/weights/manual), or the hub id microsoft/TRELLIS.2-4B. Background removal is
|
|
12
|
+
ZhengPeng7/BiRefNet (MIT) instead of the gated, CC BY-NC briaai/RMBG-2.0; an RGBA input skips it.
|
|
13
|
+
|
|
14
|
+
The box is shared: launch through the machine-wide model lock, e.g.
|
|
15
|
+
~/projects/localai/bin/img2mesh/run-locked.sh ~/ml/img2mesh/logs/driftwood.log \
|
|
16
|
+
~/ml/img2mesh/trellis-mac/.venv/bin/python scripts/img2mesh/trellis_batch.py \
|
|
17
|
+
--out ~/ml/img2mesh/out/driftwood art/driftwood-isle/round-8-assets/ref-palm-a.jpg ...
|
|
18
|
+
"""
|
|
19
|
+
import os
|
|
20
|
+
import sys
|
|
21
|
+
|
|
22
|
+
os.environ.setdefault("PYTORCH_ENABLE_MPS_FALLBACK", "1")
|
|
23
|
+
os.environ.setdefault("ATTN_BACKEND", "sdpa")
|
|
24
|
+
os.environ.setdefault("SPARSE_ATTN_BACKEND", "sdpa")
|
|
25
|
+
try:
|
|
26
|
+
import flex_gemm # noqa: F401 (mtlgemm: Metal sparse conv)
|
|
27
|
+
os.environ.setdefault("SPARSE_CONV_BACKEND", "flex_gemm")
|
|
28
|
+
except (ImportError, RuntimeError):
|
|
29
|
+
os.environ.setdefault("SPARSE_CONV_BACKEND", "none")
|
|
30
|
+
|
|
31
|
+
TM = os.path.expanduser(os.environ.get("TRELLIS_MAC", "~/ml/img2mesh/trellis-mac"))
|
|
32
|
+
sys.path.insert(0, os.path.join(TM, "TRELLIS.2"))
|
|
33
|
+
sys.path.insert(0, TM)
|
|
34
|
+
sys.path.append(os.path.join(TM, "stubs"))
|
|
35
|
+
|
|
36
|
+
import argparse # noqa: E402
|
|
37
|
+
import json # noqa: E402
|
|
38
|
+
import resource # noqa: E402
|
|
39
|
+
import time # noqa: E402
|
|
40
|
+
|
|
41
|
+
import numpy as np # noqa: E402
|
|
42
|
+
import torch # noqa: E402
|
|
43
|
+
from PIL import Image # noqa: E402
|
|
44
|
+
|
|
45
|
+
|
|
46
|
+
def main():
|
|
47
|
+
ap = argparse.ArgumentParser()
|
|
48
|
+
ap.add_argument("images", nargs="+")
|
|
49
|
+
ap.add_argument("--out", required=True)
|
|
50
|
+
ap.add_argument("--weights", default=os.path.expanduser("~/ml/img2mesh/trellis-view"))
|
|
51
|
+
ap.add_argument("--pipeline", default="1024_cascade", help="512 | 1024 | 1024_cascade")
|
|
52
|
+
ap.add_argument("--faces", type=int, default=40000, help="face budget of the baked glb")
|
|
53
|
+
ap.add_argument("--tex", type=int, default=1024)
|
|
54
|
+
ap.add_argument("--seed", type=int, default=42)
|
|
55
|
+
a = ap.parse_args()
|
|
56
|
+
os.makedirs(a.out, exist_ok=True)
|
|
57
|
+
weights = a.weights if os.path.isdir(a.weights) else "microsoft/TRELLIS.2-4B"
|
|
58
|
+
|
|
59
|
+
t0 = time.time()
|
|
60
|
+
from trellis2.pipelines import rembg
|
|
61
|
+
from trellis2.pipelines.trellis2_image_to_3d import Trellis2ImageTo3DPipeline
|
|
62
|
+
|
|
63
|
+
if weights == "microsoft/TRELLIS.2-4B": # hub config names the gated RMBG-2.0: swap in MIT BiRefNet
|
|
64
|
+
init = rembg.BiRefNet.__init__
|
|
65
|
+
rembg.BiRefNet.__init__ = lambda self, model_name=None, **_: init(self, "ZhengPeng7/BiRefNet")
|
|
66
|
+
pipe = Trellis2ImageTo3DPipeline.from_pretrained(weights)
|
|
67
|
+
pipe.rembg_model.model.float() # BiRefNet's hub weights load as fp16; the pipeline feeds fp32
|
|
68
|
+
pipe.to(torch.device("mps"))
|
|
69
|
+
t_load = time.time() - t0
|
|
70
|
+
print(f"[trellis] pipeline loaded in {t_load:.0f}s", flush=True)
|
|
71
|
+
|
|
72
|
+
import fast_simplification
|
|
73
|
+
import o_voxel.postprocess as pp
|
|
74
|
+
|
|
75
|
+
for img_path in a.images:
|
|
76
|
+
stem = os.path.splitext(os.path.basename(img_path))[0].removeprefix("ref-")
|
|
77
|
+
rec = {"image": img_path, "pipeline": a.pipeline, "seed": a.seed, "load_s": round(t_load, 1)}
|
|
78
|
+
t1 = time.time()
|
|
79
|
+
out = pipe.run(Image.open(img_path), seed=a.seed, pipeline_type=a.pipeline)
|
|
80
|
+
m = out[0] if isinstance(out, list) else out
|
|
81
|
+
rec["gen_s"] = round(time.time() - t1, 1)
|
|
82
|
+
v = m.vertices.cpu().numpy()
|
|
83
|
+
f = m.faces.cpu().numpy()
|
|
84
|
+
rec["raw_verts"], rec["raw_faces"] = int(len(v)), int(len(f))
|
|
85
|
+
if len(f) == 0: # the macOS GPU watchdog killed a decoder kernel
|
|
86
|
+
rec["error"] = "empty mesh"
|
|
87
|
+
json.dump(rec, open(os.path.join(a.out, stem + ".json"), "w"), indent=1)
|
|
88
|
+
continue
|
|
89
|
+
with open(os.path.join(a.out, stem + ".hi.obj"), "w") as fh:
|
|
90
|
+
np.savetxt(fh, v, fmt="v %.5f %.5f %.5f")
|
|
91
|
+
np.savetxt(fh, f + 1, fmt="f %d %d %d")
|
|
92
|
+
t2 = time.time()
|
|
93
|
+
tgt = min(200000, len(f)) # the Metal BVH is unstable above ~800 k faces
|
|
94
|
+
sv, sf = fast_simplification.simplify(v, f, 1.0 - tgt / len(f)) if len(f) > tgt else (v, f)
|
|
95
|
+
glb = pp.to_glb(
|
|
96
|
+
vertices=torch.from_numpy(sv).float(), faces=torch.from_numpy(sf.astype("int32")),
|
|
97
|
+
attr_volume=m.attrs.cpu(), coords=m.coords.cpu(), attr_layout=m.layout,
|
|
98
|
+
voxel_size=m.voxel_size, aabb=[[-0.5, -0.5, -0.5], [0.5, 0.5, 0.5]],
|
|
99
|
+
decimation_target=a.faces, texture_size=a.tex, verbose=False)
|
|
100
|
+
glb.export(os.path.join(a.out, stem + ".glb"))
|
|
101
|
+
rec["bake_s"] = round(time.time() - t2, 1)
|
|
102
|
+
rec["peak_rss_gb"] = round(resource.getrusage(resource.RUSAGE_SELF).ru_maxrss / 1e9, 2)
|
|
103
|
+
rec["mps_driver_gb"] = round(torch.mps.driver_allocated_memory() / 1e9, 2)
|
|
104
|
+
json.dump(rec, open(os.path.join(a.out, stem + ".json"), "w"), indent=1)
|
|
105
|
+
print(f"[trellis] {stem}: {json.dumps(rec)}", flush=True)
|
|
106
|
+
torch.mps.empty_cache()
|
|
107
|
+
|
|
108
|
+
|
|
109
|
+
if __name__ == "__main__":
|
|
110
|
+
main()
|
|
@@ -0,0 +1,114 @@
|
|
|
1
|
+
"""TRELLIS.2 vs Hunyuan3D-2 side by side: per prop, the reference image | TRELLIS.2 render | Hunyuan3D-2 render.
|
|
2
|
+
|
|
3
|
+
python scripts/img2mesh/versus_board.py <trellis_dir> <hunyuan_dir> <renders_dir> <out.jpg> name=refpath [name=refpath …]
|
|
4
|
+
|
|
5
|
+
Both generations are rendered with scripts/img2mesh/render_still.py (same Eevee light, same 3/4 camera) into
|
|
6
|
+
<renders_dir>/<name>.trellis.png and <name>.hunyuan.png (skipped when they already exist). Triangle counts and
|
|
7
|
+
generation seconds come from each output's .json sidecar when present, else from the glb itself (tris only).
|
|
8
|
+
"""
|
|
9
|
+
import json
|
|
10
|
+
import os
|
|
11
|
+
import subprocess
|
|
12
|
+
import sys
|
|
13
|
+
|
|
14
|
+
from PIL import Image, ImageDraw, ImageFont
|
|
15
|
+
|
|
16
|
+
HERE = os.path.dirname(os.path.abspath(__file__))
|
|
17
|
+
BLENDER = "/opt/homebrew/bin/blender"
|
|
18
|
+
CELL = 440
|
|
19
|
+
LABEL = 64
|
|
20
|
+
|
|
21
|
+
|
|
22
|
+
def find(d, name):
|
|
23
|
+
for cand in (f"{name}.glb", f"ref-{name}.glb"):
|
|
24
|
+
p = os.path.join(d, cand)
|
|
25
|
+
if os.path.exists(p):
|
|
26
|
+
return p
|
|
27
|
+
return None
|
|
28
|
+
|
|
29
|
+
|
|
30
|
+
def sidecar(glb):
|
|
31
|
+
j = glb[:-4] + ".json"
|
|
32
|
+
if not os.path.exists(j):
|
|
33
|
+
return {}
|
|
34
|
+
try:
|
|
35
|
+
with open(j) as f:
|
|
36
|
+
return json.load(f)
|
|
37
|
+
except (OSError, ValueError):
|
|
38
|
+
return {}
|
|
39
|
+
|
|
40
|
+
|
|
41
|
+
def stat_line(meta):
|
|
42
|
+
tris = meta.get("tris") or meta.get("faces") or meta.get("triangles")
|
|
43
|
+
secs = meta.get("seconds") or meta.get("gen_s") or meta.get("time_s") or meta.get("elapsed")
|
|
44
|
+
if secs is None and isinstance(meta.get("shape_s"), (int, float)): # Hunyuan3D-2's hy3d_batch sidecar: shape + paint
|
|
45
|
+
secs = meta["shape_s"] + (meta.get("paint_s") or 0)
|
|
46
|
+
if isinstance(secs, dict):
|
|
47
|
+
secs = sum(v for v in secs.values() if isinstance(v, (int, float)))
|
|
48
|
+
bits = []
|
|
49
|
+
if tris:
|
|
50
|
+
bits.append(f"{int(tris):,} tris")
|
|
51
|
+
if isinstance(secs, (int, float)):
|
|
52
|
+
bits.append(f"{secs:.0f} s")
|
|
53
|
+
return " · ".join(bits)
|
|
54
|
+
|
|
55
|
+
|
|
56
|
+
def render(glb, png):
|
|
57
|
+
if os.path.exists(png):
|
|
58
|
+
return
|
|
59
|
+
subprocess.run([BLENDER, "-b", "-P", os.path.join(HERE, "render_still.py"), "--", glb, png, "--size", str(CELL)],
|
|
60
|
+
check=True, stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL)
|
|
61
|
+
|
|
62
|
+
|
|
63
|
+
def fit(img, w, h, bg):
|
|
64
|
+
img = img.convert("RGB")
|
|
65
|
+
img.thumbnail((w, h))
|
|
66
|
+
out = Image.new("RGB", (w, h), bg)
|
|
67
|
+
out.paste(img, ((w - img.width) // 2, (h - img.height) // 2))
|
|
68
|
+
return out
|
|
69
|
+
|
|
70
|
+
|
|
71
|
+
def main():
|
|
72
|
+
tdir, hdir, rdir, out = sys.argv[1:5]
|
|
73
|
+
pairs = [a.split("=", 1) for a in sys.argv[5:]]
|
|
74
|
+
os.makedirs(rdir, exist_ok=True)
|
|
75
|
+
try:
|
|
76
|
+
font = ImageFont.truetype("/System/Library/Fonts/Menlo.ttc", 20)
|
|
77
|
+
small = ImageFont.truetype("/System/Library/Fonts/Menlo.ttc", 16)
|
|
78
|
+
except OSError:
|
|
79
|
+
font = small = ImageFont.load_default()
|
|
80
|
+
bg, ink, dim = (14, 26, 36), (235, 242, 244), (150, 175, 186)
|
|
81
|
+
head = 56
|
|
82
|
+
rows = []
|
|
83
|
+
for name, ref in pairs:
|
|
84
|
+
t, h = find(tdir, name), find(hdir, name)
|
|
85
|
+
cells = [(fit(Image.open(ref), CELL, CELL, (200, 208, 214)), f"{name} · reference", "")]
|
|
86
|
+
for label, glb in (("TRELLIS.2", t), ("Hunyuan3D-2", h)):
|
|
87
|
+
if glb is None:
|
|
88
|
+
cells.append((Image.new("RGB", (CELL, CELL), (60, 30, 30)), f"{label}", "missing"))
|
|
89
|
+
continue
|
|
90
|
+
png = os.path.join(rdir, f"{name}.{label.split('.')[0].lower().replace('3d-2', '')}.png")
|
|
91
|
+
render(glb, png)
|
|
92
|
+
cells.append((fit(Image.open(png), CELL, CELL, (200, 208, 214)), label, stat_line(sidecar(glb))))
|
|
93
|
+
rows.append(cells)
|
|
94
|
+
W = CELL * 3 + 4 * 12
|
|
95
|
+
H = head + len(rows) * (CELL + LABEL + 12) + 12
|
|
96
|
+
sheet = Image.new("RGB", (W, H), bg)
|
|
97
|
+
d = ImageDraw.Draw(sheet)
|
|
98
|
+
d.text((12, 16), "TRELLIS.2 vs Hunyuan3D-2 · same reference, same light · raw textured generations", fill=ink, font=font)
|
|
99
|
+
y = head
|
|
100
|
+
for cells in rows:
|
|
101
|
+
x = 12
|
|
102
|
+
for img, title, stats in cells:
|
|
103
|
+
sheet.paste(img, (x, y))
|
|
104
|
+
d.text((x, y + CELL + 8), title, fill=ink, font=font)
|
|
105
|
+
if stats:
|
|
106
|
+
d.text((x, y + CELL + 34), stats, fill=dim, font=small)
|
|
107
|
+
x += CELL + 12
|
|
108
|
+
y += CELL + LABEL + 12
|
|
109
|
+
sheet.save(out, quality=82, optimize=True)
|
|
110
|
+
print(out, sheet.size)
|
|
111
|
+
|
|
112
|
+
|
|
113
|
+
if __name__ == "__main__":
|
|
114
|
+
main()
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { mkdir, mkdtemp, rm, writeFile } from 'node:fs/promises';
|
|
2
|
+
import { resolve } from 'node:path';
|
|
3
|
+
import { pathToFileURL } from 'node:url';
|
|
4
|
+
|
|
5
|
+
/** Execute one trusted, single-chunk Node bundle without a base64 copy.
|
|
6
|
+
* All non-builtin imports must already be absolute. The loaded module remains
|
|
7
|
+
* usable after its owned source file is removed, including absolute imports.
|
|
8
|
+
* @param {string} source @returns {Promise<unknown>} */
|
|
9
|
+
export async function importBundle(source) {
|
|
10
|
+
const scratch = resolve(process.cwd(), 'tmp'); // P4: never inside an installed package.
|
|
11
|
+
await mkdir(scratch, { recursive: true });
|
|
12
|
+
const directory = await mkdtemp(resolve(scratch, 'author-module-'));
|
|
13
|
+
try {
|
|
14
|
+
const file = resolve(directory, 'bundle.mjs');
|
|
15
|
+
await writeFile(file, source, 'utf8');
|
|
16
|
+
return await import(pathToFileURL(file).href);
|
|
17
|
+
} finally {
|
|
18
|
+
await rm(directory, { recursive: true, force: true });
|
|
19
|
+
}
|
|
20
|
+
}
|