@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,33 @@
|
|
|
1
|
+
#!/usr/bin/env python3
|
|
2
|
+
"""Pine Hollow birds (round 16), step 4: the contact sheet — each reference beside its mesh (textured side / top / 3/4 +
|
|
3
|
+
the pivot check).
|
|
4
|
+
|
|
5
|
+
python3 scripts/img2mesh/birds/birds_sheet.py <refs dir> <render dir> <seg dir> <out.jpg>
|
|
6
|
+
"""
|
|
7
|
+
import sys
|
|
8
|
+
|
|
9
|
+
from PIL import Image, ImageDraw, ImageFont
|
|
10
|
+
|
|
11
|
+
refs, rend, seg, out = sys.argv[1:5]
|
|
12
|
+
ROWS = [("raven_perch", "raven-perch"), ("raven_fly", "raven-fly"), ("owl_perch", "owl-perch"),
|
|
13
|
+
("owl_fly", "owl-fly"), ("wood_perch", "woodpecker-perch"), ("wood_fly", "woodpecker-fly")]
|
|
14
|
+
T, HDR = 240, 22
|
|
15
|
+
cols = ["reference", "side", "top", "3/4", "pivots (side)", "pivots (top)"]
|
|
16
|
+
W = T * len(cols)
|
|
17
|
+
sheet = Image.new("RGB", (W, HDR + len(ROWS) * (T + HDR)), (236, 236, 236))
|
|
18
|
+
d = ImageDraw.Draw(sheet)
|
|
19
|
+
try:
|
|
20
|
+
font = ImageFont.truetype("/System/Library/Fonts/Helvetica.ttc", 15)
|
|
21
|
+
except OSError:
|
|
22
|
+
font = ImageFont.load_default()
|
|
23
|
+
for j, c in enumerate(cols):
|
|
24
|
+
d.text((j * T + 6, 3), c, fill=(40, 40, 40), font=font)
|
|
25
|
+
for i, (mesh, ref) in enumerate(ROWS):
|
|
26
|
+
y = HDR + i * (T + HDR)
|
|
27
|
+
d.text((6, y + 3), f"{mesh} (ref-{ref}.jpg)", fill=(150, 20, 20), font=font)
|
|
28
|
+
ims = [Image.open(f"{refs}/ref-{ref}.jpg")] + [Image.open(f"{rend}/{mesh}.{v}.png") for v in ("side", "top", "q34")] \
|
|
29
|
+
+ [Image.open(f"{seg}/{mesh}.{v}.png") for v in ("side", "top")]
|
|
30
|
+
for j, im in enumerate(ims):
|
|
31
|
+
sheet.paste(im.convert("RGB").resize((T, T), Image.LANCZOS), (j * T, y + HDR))
|
|
32
|
+
sheet.save(out, quality=82, optimize=True)
|
|
33
|
+
print(out, sheet.size)
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
"""Diagnostic ortho views of a generated bird (textured, Workbench): side (beak → right), top (beak ↑), front.
|
|
2
|
+
|
|
3
|
+
blender -b -P scripts/img2mesh/birds/birds_view.py -- <in.glb> <out.png> [--rot rx,ry,rz] [--size 384]
|
|
4
|
+
|
|
5
|
+
--rot is the Blender-space Euler XYZ (degrees) applied after import, the same value birds.json's "rot" takes. The views
|
|
6
|
+
assume the target frame (Blender: beak −Y, up +Z, right wing +X = glTF/three: beak +Z, up +Y, right wing +X).
|
|
7
|
+
"""
|
|
8
|
+
import math
|
|
9
|
+
import sys
|
|
10
|
+
|
|
11
|
+
import bpy
|
|
12
|
+
from mathutils import Euler, Vector
|
|
13
|
+
|
|
14
|
+
argv = sys.argv[sys.argv.index("--") + 1:]
|
|
15
|
+
src, out = argv[0], argv[1]
|
|
16
|
+
rot = [float(v) for v in argv[argv.index("--rot") + 1].split(",")] if "--rot" in argv else [0, 0, 0]
|
|
17
|
+
size = int(argv[argv.index("--size") + 1]) if "--size" in argv else 384
|
|
18
|
+
|
|
19
|
+
bpy.ops.wm.read_factory_settings(use_empty=True)
|
|
20
|
+
bpy.ops.import_scene.gltf(filepath=src)
|
|
21
|
+
meshes = [o for o in bpy.context.scene.objects if o.type == "MESH"]
|
|
22
|
+
R = Euler([math.radians(v) for v in rot], "XYZ").to_matrix().to_4x4()
|
|
23
|
+
for o in bpy.context.scene.objects:
|
|
24
|
+
if o.parent is None:
|
|
25
|
+
o.matrix_world = R @ o.matrix_world
|
|
26
|
+
bpy.context.view_layer.update()
|
|
27
|
+
pts = [o.matrix_world @ Vector(c) for o in meshes for c in o.bound_box]
|
|
28
|
+
lo = Vector([min(p[i] for p in pts) for i in range(3)])
|
|
29
|
+
hi = Vector([max(p[i] for p in pts) for i in range(3)])
|
|
30
|
+
c = (lo + hi) / 2
|
|
31
|
+
r = max((hi - lo)) * 0.6
|
|
32
|
+
|
|
33
|
+
sc = bpy.context.scene
|
|
34
|
+
sc.render.engine = "BLENDER_WORKBENCH"
|
|
35
|
+
sc.display.shading.light = "FLAT"
|
|
36
|
+
sc.display.shading.color_type = "TEXTURE"
|
|
37
|
+
sc.render.resolution_x = sc.render.resolution_y = size
|
|
38
|
+
sc.view_settings.view_transform = "Standard"
|
|
39
|
+
sc.world = bpy.data.worlds.new("w")
|
|
40
|
+
sc.world.color = (0.8, 0.8, 0.8)
|
|
41
|
+
cam = bpy.data.objects.new("cam", bpy.data.cameras.new("cam"))
|
|
42
|
+
cam.data.type = "ORTHO"
|
|
43
|
+
cam.data.ortho_scale = 2 * r
|
|
44
|
+
sc.collection.objects.link(cam)
|
|
45
|
+
sc.camera = cam
|
|
46
|
+
views = { # name: (camera offset, euler)
|
|
47
|
+
"side": (Vector((-3 * r, 0, 0)), (math.pi / 2, 0, -math.pi / 2)), # from −X (left): −Y (beak) → image right
|
|
48
|
+
"top": (Vector((0, 0, 3 * r)), (0, 0, math.pi)), # from +Z: beak (−Y) → image up
|
|
49
|
+
"front": (Vector((0, -3 * r, 0)), (math.pi / 2, 0, 0)), # from the beak side, looking back
|
|
50
|
+
"under": (Vector((0, 0, -3 * r)), (math.pi, 0, 0)),
|
|
51
|
+
}
|
|
52
|
+
import os
|
|
53
|
+
tmp = []
|
|
54
|
+
for name, (off, eu) in views.items():
|
|
55
|
+
cam.location = c + off
|
|
56
|
+
cam.rotation_euler = eu
|
|
57
|
+
sc.render.filepath = out + f".{name}.png"
|
|
58
|
+
bpy.ops.render.render(write_still=True)
|
|
59
|
+
tmp.append(sc.render.filepath)
|
|
60
|
+
print("dims (blender x,y,z):", tuple(round(v, 4) for v in (hi - lo)), "views:", tmp)
|
|
@@ -0,0 +1,100 @@
|
|
|
1
|
+
"""Compose the Driftwood hero-prop comparison board: per prop, concept-art crop | the image-to-3D reference |
|
|
2
|
+
the new hero asset (Blender still) | the current in-game procedural model (Model Explorer capture).
|
|
3
|
+
|
|
4
|
+
python scripts/img2mesh/board.py <hero-stills dir> <live-captures dir> art/driftwood-isle/round-8-assets/board.jpg
|
|
5
|
+
|
|
6
|
+
<hero-stills dir>/hero-<row>.png come from render_still.py; <live-captures dir>/live-<catalog id>.png are 1280x900
|
|
7
|
+
screenshots of `?explore=model&model=<id>` (the HUD is cropped away here).
|
|
8
|
+
"""
|
|
9
|
+
import os
|
|
10
|
+
import sys
|
|
11
|
+
|
|
12
|
+
from PIL import Image, ImageDraw, ImageFont
|
|
13
|
+
|
|
14
|
+
REPO = os.path.abspath(os.path.join(os.path.dirname(__file__), "..", ".."))
|
|
15
|
+
ART = os.path.join(REPO, "art")
|
|
16
|
+
HERO, LIVE, OUT = sys.argv[1], sys.argv[2], sys.argv[3]
|
|
17
|
+
SPAWN = "driftwood-fp-spawn.png"
|
|
18
|
+
LEFT = "driftwood-isle/round-4-remaster/mockup-2-fp-left.jpg"
|
|
19
|
+
WRECK = "driftwood-fp-poi-2-wreck-cove.png"
|
|
20
|
+
SHRINE = "driftwood-fp-poi-3-shrine.png"
|
|
21
|
+
LIVE_BOX = (250, 150, 1030, 740) # the turntable, without the Model Explorer's HUD
|
|
22
|
+
|
|
23
|
+
# row: label, concept (file, box), reference, hero still, live capture (or None), note
|
|
24
|
+
ROWS = [
|
|
25
|
+
("PALMS a · b · c · frond", (SPAWN, (360, 160, 730, 440)), "ref-palm-a.jpg", "palms", "palm",
|
|
26
|
+
"palm-a 1991 · palm-b 1968 · palm-c 1583 · frond-b 410 tris"),
|
|
27
|
+
("BOULDERS ×5", (LEFT, (740, 850, 1024, 1050)), "ref-boulders.jpg", "boulders", "boulder",
|
|
28
|
+
"220–600 tris each, 1.7 m max"),
|
|
29
|
+
("DRIFTWOOD ×4", (LEFT, (40, 950, 430, 1100)), "ref-driftwood.jpg", "driftwood", None,
|
|
30
|
+
"380–520 tris each · in game: Props.ts logs (not in the catalog)"),
|
|
31
|
+
("PIER PILING + ROPE", (SPAWN, (190, 700, 330, 1000)), "ref-piling.jpg", "piling", "pier",
|
|
32
|
+
"700 tris, 2.6 m · in game: the pier (its pilings)"),
|
|
33
|
+
("SAILBOAT", (SPAWN, (0, 120, 250, 1020)), "ref-sailboat.jpg", "sailboat", "boat", "2505 tris, 6.5 m"),
|
|
34
|
+
("THATCHED HUT", (SPAWN, (230, 270, 490, 470)), "ref-hut.jpg", "hut", "hut", "2992 tris, 5.6 m"),
|
|
35
|
+
("SHIPWRECK LOD0 · LOD1", (WRECK, (350, 200, 900, 730)), "ref-wreck.jpg", "wreck", "wreck",
|
|
36
|
+
"2989 + 1420 tris, 14 m (remeshed plank shells)"),
|
|
37
|
+
("RING SHRINE", (SHRINE, (280, 80, 660, 700)), "ref-shrine.jpg", "shrine", "shrine",
|
|
38
|
+
"2173 tris, 5.5 m · shown: .tex.glb (512² atlas keeps the rune)"),
|
|
39
|
+
("SHELLS + STARFISH", (LEFT, (140, 1060, 350, 1250)), "ref-clutter.jpg", "clutter", None,
|
|
40
|
+
"139–238 tris each · in game: ground-cover scatter"),
|
|
41
|
+
("COCONUTS", (SPAWN, (560, 190, 700, 320)), "ref-coco.jpg", "coco", None, "cluster 360 · nut 159 · half 178 tris"),
|
|
42
|
+
]
|
|
43
|
+
COLS = ["CONCEPT ART", "REFERENCE (codex image_gen)", "NEW: TRELLIS.2 → BLENDER", "CURRENT: IN-GAME PROCEDURAL"]
|
|
44
|
+
C = 360 # cell
|
|
45
|
+
LW = 250 # label column
|
|
46
|
+
HEAD = 96
|
|
47
|
+
W = LW + 4 * C
|
|
48
|
+
H = HEAD + len(ROWS) * C
|
|
49
|
+
BG, FG, MUTED, LINE, ACCENT = (13, 27, 38), (230, 238, 244), (140, 170, 190), (40, 70, 90), (143, 227, 255)
|
|
50
|
+
|
|
51
|
+
|
|
52
|
+
def font(size):
|
|
53
|
+
for f in ("/System/Library/Fonts/SFNSMono.ttf", "/System/Library/Fonts/Menlo.ttc", "/Library/Fonts/Arial.ttf"):
|
|
54
|
+
if os.path.exists(f):
|
|
55
|
+
return ImageFont.truetype(f, size)
|
|
56
|
+
return ImageFont.load_default()
|
|
57
|
+
|
|
58
|
+
|
|
59
|
+
def fit(im, box_w, box_h, bg):
|
|
60
|
+
im = im.convert("RGB")
|
|
61
|
+
im.thumbnail((box_w, box_h), Image.LANCZOS)
|
|
62
|
+
c = Image.new("RGB", (box_w, box_h), bg)
|
|
63
|
+
c.paste(im, ((box_w - im.width) // 2, (box_h - im.height) // 2))
|
|
64
|
+
return c
|
|
65
|
+
|
|
66
|
+
|
|
67
|
+
board = Image.new("RGB", (W, H), BG)
|
|
68
|
+
d = ImageDraw.Draw(board)
|
|
69
|
+
d.text((16, 14), "DRIFTWOOD ISLE · HERO PROPS · ROUND 8", font=font(26), fill=ACCENT)
|
|
70
|
+
d.text((16, 50), "concept crop · clean reference · new asset (Eevee, same sun, flat-shaded, vertex colour + AO) · "
|
|
71
|
+
"current procedural model (Model Explorer, live build)", font=font(14), fill=MUTED)
|
|
72
|
+
for i, t in enumerate(COLS):
|
|
73
|
+
d.text((LW + i * C + 10, HEAD - 24), t, font=font(13), fill=ACCENT)
|
|
74
|
+
for r, (label, (cfile, cbox), ref, hero, live, note) in enumerate(ROWS):
|
|
75
|
+
y = HEAD + r * C
|
|
76
|
+
d.line([(0, y), (W, y)], fill=LINE, width=1)
|
|
77
|
+
d.text((14, y + 14), label, font=font(16), fill=FG)
|
|
78
|
+
words, line, ly = note.split(" "), "", y + 46
|
|
79
|
+
for w in words: # wrap the note into the label column
|
|
80
|
+
if len(line) + len(w) > 26:
|
|
81
|
+
d.text((14, ly), line, font=font(12), fill=MUTED)
|
|
82
|
+
ly += 17
|
|
83
|
+
line = ""
|
|
84
|
+
line += w + " "
|
|
85
|
+
d.text((14, ly), line, font=font(12), fill=MUTED)
|
|
86
|
+
cells = [
|
|
87
|
+
Image.open(os.path.join(ART, cfile)).crop(cbox),
|
|
88
|
+
Image.open(os.path.join(ART, "driftwood-isle/round-8-assets", ref)),
|
|
89
|
+
Image.open(os.path.join(HERO, f"hero-{hero}.png")),
|
|
90
|
+
Image.open(os.path.join(LIVE, f"live-{live}.png")).crop(LIVE_BOX) if live else None,
|
|
91
|
+
]
|
|
92
|
+
for i, im in enumerate(cells):
|
|
93
|
+
x = LW + i * C
|
|
94
|
+
if im is None:
|
|
95
|
+
d.rectangle([x + 6, y + 6, x + C - 6, y + C - 6], outline=LINE)
|
|
96
|
+
d.text((x + 24, y + C // 2 - 8), "not in the Model Explorer", font=font(13), fill=MUTED)
|
|
97
|
+
continue
|
|
98
|
+
board.paste(fit(im, C - 12, C - 12, (220, 225, 230) if i == 2 else (255, 255, 255)), (x + 6, y + 6))
|
|
99
|
+
board.save(OUT, quality=80, optimize=True, progressive=True)
|
|
100
|
+
print(OUT, board.size, os.path.getsize(OUT) // 1024, "KB")
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
#!/bin/bash
|
|
2
|
+
# The CC0 complement: kit models from ~/models/cc0 (scripts/img2mesh/CC0.md) recoloured to the Driftwood palette and
|
|
3
|
+
# meshopt-compressed into public/assets/models/driftwood-cc0/<name>/<name>.glb (+ .json with source + licence).
|
|
4
|
+
# bash scripts/img2mesh/build_cc0.sh [name ...]
|
|
5
|
+
set -euo pipefail
|
|
6
|
+
REPO=$(cd "$(dirname "$0")/../.." && pwd)
|
|
7
|
+
CC0=${CC0:-$HOME/models/cc0}
|
|
8
|
+
STAGE=${STAGE:-$HOME/ml/img2mesh/out/driftwood-cc0}
|
|
9
|
+
DEST=$REPO/public/assets/models/driftwood-cc0
|
|
10
|
+
BLENDER=${BLENDER:-/opt/homebrew/bin/blender}
|
|
11
|
+
mkdir -p "$STAGE" "$DEST"
|
|
12
|
+
|
|
13
|
+
# name | source (relative to ~/models/cc0) | fit | metres | palette family (optional)
|
|
14
|
+
LIST=$(cat <<'EOF'
|
|
15
|
+
cc0-palm-tall|quaternius/pirate-kit/glTF/Environment_PalmTree_1.gltf|height|8
|
|
16
|
+
cc0-palm-bent|quaternius/pirate-kit/glTF/Environment_PalmTree_3.gltf|height|7
|
|
17
|
+
cc0-palm-young|poly-pizza/palm/Quaternius-Palm-Tree_A6cKJYFsIb.glb|height|5
|
|
18
|
+
cc0-rock-a|quaternius/pirate-kit/glTF/Environment_Rock_2.gltf|height|1.4|rock
|
|
19
|
+
cc0-rock-formation|poly-pizza/rock/Kenney-Rock-Formation_pRY9BCFbmQ.glb|height|3|rock
|
|
20
|
+
cc0-rock-large|poly-pizza/rock/Quaternius-Rock-Large_54jZKTAt5p.glb|height|2.4|rock
|
|
21
|
+
cc0-rocks-small|poly-pizza/rock/Quaternius-Rocks_gYhoEOKItJ.glb|length|1.6|rock
|
|
22
|
+
cc0-rowboat|kenney/pirate-kit/Models/GLB format/boat-row-small.glb|length|3.6
|
|
23
|
+
cc0-sailboat|poly-pizza/boat/Quaternius-Sail-Boat_BgSZXwmm7k.glb|length|6
|
|
24
|
+
cc0-shipwreck|kenney/pirate-kit/Models/GLB format/ship-wreck.glb|length|12
|
|
25
|
+
cc0-dock|quaternius/pirate-kit/glTF/Environment_Dock.gltf|length|6
|
|
26
|
+
cc0-dock-broken|quaternius/pirate-kit/glTF/Environment_Dock_Broken.gltf|length|6
|
|
27
|
+
cc0-hut|poly-pizza/hut/Quaternius-Hut_4MJWbyd6vw.glb|height|4.5
|
|
28
|
+
cc0-barrel|quaternius/pirate-kit/glTF/Prop_Barrel.gltf|height|1
|
|
29
|
+
cc0-crate|kenney/pirate-kit/Models/GLB format/crate.glb|height|0.8
|
|
30
|
+
cc0-chest-gold|quaternius/pirate-kit/glTF/Prop_Chest_Gold.gltf|length|0.9
|
|
31
|
+
cc0-coconut-half|poly-pizza/beach/Kenney-Coconut-Half_ufT2tXnLFc.glb|length|0.22
|
|
32
|
+
cc0-mussel|poly-pizza/beach/Kenney-Mussel-Open_eWHAc3Pq8z.glb|length|0.12
|
|
33
|
+
cc0-log|poly-pizza/driftwood/Quaternius-Wood-Log_L4E32Wee6C.glb|length|2.2|bleach
|
|
34
|
+
cc0-deadtree|poly-pizza/driftwood/Kay-Lousberg-Dead-tree_k80NkrvY2f.glb|height|3|bleach
|
|
35
|
+
cc0-arch|poly-pizza/ruin/Quaternius-Arch-Round_B9QABewqLv.glb|height|4
|
|
36
|
+
cc0-monolith|kenney/nature-kit/Models/GLTF format/stone_tallA.glb|height|3|rock
|
|
37
|
+
cc0-whale-bones|quaternius/pirate-kit/glTF/Environment_LargeBones.gltf|length|6|bleach
|
|
38
|
+
EOF
|
|
39
|
+
)
|
|
40
|
+
|
|
41
|
+
want() { [ $# -le 1 ] && return 0; for w in "${@:2}"; do [ "$w" = "$1" ] && return 0; done; return 1; }
|
|
42
|
+
while IFS='|' read -r name src fit size family; do
|
|
43
|
+
[ -z "$name" ] && continue
|
|
44
|
+
want "$name" ${1+"$@"} || continue
|
|
45
|
+
[ -f "$CC0/$src" ] || { echo "skip $name: no $CC0/$src"; continue; }
|
|
46
|
+
"$BLENDER" -b -P "$REPO/scripts/img2mesh/cc0_export.py" -- --in "$CC0/$src" --name "$name" --out "$STAGE" \
|
|
47
|
+
--fit "$fit" --size "$size" --family "${family:-}" 2>&1 | grep -E '^CC0_EXPORT|Error|Traceback' || true
|
|
48
|
+
[ -f "$STAGE/$name/$name.glb" ] || continue
|
|
49
|
+
mkdir -p "$DEST/$name"
|
|
50
|
+
npx --prefix "$REPO" gltf-transform meshopt "$STAGE/$name/$name.glb" "$DEST/$name/$name.glb" --level medium > /dev/null
|
|
51
|
+
cp "$STAGE/$name/$name.json" "$DEST/$name/$name.json"
|
|
52
|
+
done <<< "$LIST"
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
#!/bin/bash
|
|
2
|
+
# Driftwood hero props: TRELLIS.2 generations (~/ml/img2mesh/out/driftwood/<ref>.glb) -> faceted game assets in
|
|
3
|
+
# public/assets/models/driftwood-hero/<asset>/<asset>.glb (+ .tex.glb with a WebP atlas where listed) + <asset>.json.
|
|
4
|
+
# bash scripts/img2mesh/build_driftwood.sh # every prop
|
|
5
|
+
# bash scripts/img2mesh/build_driftwood.sh hut wreck # just these refs
|
|
6
|
+
# The prop list (every size, budget and option) is src/shards/driftwood-isle/art/hero-props.json; the build is the
|
|
7
|
+
# shard-agnostic scripts/img2mesh/build_props.py (PH-0.3): step 1 (driftwood_post.py, Blender) writes to a staging
|
|
8
|
+
# folder, step 2 meshopt-compresses the glbs into the repo with gltf-transform. Env GEN / STAGE / BLENDER override.
|
|
9
|
+
set -euo pipefail
|
|
10
|
+
REPO=$(cd "$(dirname "$0")/../.." && pwd)
|
|
11
|
+
exec python3 "$REPO/scripts/img2mesh/build_props.py" "$REPO/src/shards/driftwood-isle/art/hero-props.json" \
|
|
12
|
+
"$REPO/public/assets/models/driftwood-hero" "$@"
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
#!/usr/bin/env bash
|
|
2
|
+
# build_faces.sh — NALATI-FINISH B5 / E302: the camp people's face variants → public/assets/nalati/models/people/faces-<v>/
|
|
3
|
+
#
|
|
4
|
+
# scripts/img2mesh/build_faces.sh <sharp|hunyuan|trellis|painted|paint> [person …]
|
|
5
|
+
# (paint, E339 D: the Hunyuan3D-2 bust as its own multi-view paint made it, no portrait projected)
|
|
6
|
+
#
|
|
7
|
+
# Per person (scripts/img2mesh/faces.json): the SHIPPED body (people/<person>.gen.glb, colour-matched, decoded by
|
|
8
|
+
# scripts/nalati-faces-decode.mjs) → Blender face_remaster.py (head-first re-UV + re-bake; hunyuan / trellis graft the
|
|
9
|
+
# generated bust from ~/ml/img2mesh/out/e302-faces/{hy,t512}/<person>.glb; painted paints the readable face) →
|
|
10
|
+
# gltf-transform: <person>.gen.glb (1024² WebP) + <person>.gen.phone.glb (512² WebP), meshopt — the sizes of today's files.
|
|
11
|
+
# CPU / Blender only (no model load, no lock). The busts come from the locked batch ~/ml/img2mesh/out/e302-faces/job.sh
|
|
12
|
+
# (codex front portraits art/nalati-grasslands/round-12-faces/portrait-*.jpg → cutout → TRELLIS.2 512 / Hunyuan3D-2 full).
|
|
13
|
+
set -euo pipefail
|
|
14
|
+
V=${1:?usage: build_faces.sh <sharp|hunyuan|trellis|painted> [person …]}; shift
|
|
15
|
+
REPO=$(cd "$(dirname "${BASH_SOURCE[0]}")/../.." && pwd)
|
|
16
|
+
W=$HOME/ml/img2mesh/out/e302-faces
|
|
17
|
+
GT=$REPO/node_modules/.bin/gltf-transform
|
|
18
|
+
OUT=$REPO/public/assets/nalati/models/people/faces-$V
|
|
19
|
+
PEOPLE=("$@"); [ ${#PEOPLE[@]} -gt 0 ] || PEOPLE=(elder herder-dauren herder-erlan child cook)
|
|
20
|
+
mkdir -p "$W/body" "$W/final/$V" "$OUT"
|
|
21
|
+
for n in "${PEOPLE[@]}"; do
|
|
22
|
+
[ -f "$W/body/$n.glb" ] || node "$REPO/scripts/nalati-faces-decode.mjs" "$REPO/public/assets/nalati/models/people/$n.gen.glb" "$W/body/$n.glb"
|
|
23
|
+
mapfile -t A < <(python3 - "$REPO/scripts/img2mesh/faces.json" "$n" "$V" "$W" <<'PY'
|
|
24
|
+
import json, sys
|
|
25
|
+
cfg, n, v, w = json.load(open(sys.argv[1]))["people"][sys.argv[2]], sys.argv[2], sys.argv[3], sys.argv[4]
|
|
26
|
+
out = ["--neck", str(cfg["neck"])]
|
|
27
|
+
if v == "painted":
|
|
28
|
+
out += ["--paint", json.dumps(cfg["paint"]), "--smooth-face", str(cfg.get("smooth_face", 0.85))]
|
|
29
|
+
elif v in ("hunyuan", "trellis", "paint"): # paint (E339 D): the Hunyuan bust with its own paint, no portrait
|
|
30
|
+
g = dict(cfg.get("graft", {}), **cfg.get("graft_" + v, {}))
|
|
31
|
+
out += ["--graft", f"{w}/{'t512' if v == 'trellis' else 'hy'}/{n}.glb", "--bust-neck", str(g.get("neck", 0.5)),
|
|
32
|
+
"--bust-clip", str(g.get("clip", 0.03)), "--bust-grow", str(g.get("grow", 1.0)), "--bust-dz", str(g.get("dz", 0.0)),
|
|
33
|
+
"--bust-dy", str(g.get("dy", 0.0)), "--head-tris", str(g.get("tris", 4000))]
|
|
34
|
+
out += ["--smooth-face", str(g.get("smooth_face", 0.8))]
|
|
35
|
+
if v == "trellis":
|
|
36
|
+
out += ["--no-weld"]
|
|
37
|
+
else: # E339 graft fix: the bust cut at its own neck (dipping under the jaw), the ring blended, fragments dropped
|
|
38
|
+
out += ["--graft-v2"] + ([] if g.get("neck_auto") is False else ["--bust-neck-auto", "0.45", "0.8"])
|
|
39
|
+
if "beard" in g:
|
|
40
|
+
out += ["--bust-beard", str(g["beard"][0]), str(g["beard"][1])]
|
|
41
|
+
if g.get("project", True) and v != "paint":
|
|
42
|
+
out += ["--bust-image", f"{w}/cut/{n}.png"]
|
|
43
|
+
print("\n".join(out))
|
|
44
|
+
PY
|
|
45
|
+
)
|
|
46
|
+
raw=$W/final/$V/$n.raw.glb
|
|
47
|
+
/opt/homebrew/bin/blender -b -P "$REPO/scripts/img2mesh/face_remaster.py" -- --body "$W/body/$n.glb" --out "$raw" \
|
|
48
|
+
--front "$W/final/$V/$n.front.png" "${A[@]}" 2>&1 | grep -E '^\[face\]|Error|Traceback' || true
|
|
49
|
+
[ -f "$raw" ] || { echo "face_remaster failed for $n ($V)"; exit 1; }
|
|
50
|
+
"$GT" optimize "$raw" "$OUT/$n.gen.glb" --compress meshopt --texture-compress webp --texture-size 1024 --simplify false --instance false > /dev/null
|
|
51
|
+
"$GT" optimize "$raw" "$OUT/$n.gen.phone.glb" --compress meshopt --texture-compress webp --texture-size 512 --simplify false --instance false > /dev/null
|
|
52
|
+
echo "[faces] $V/$n: $(stat -f %z "$OUT/$n.gen.glb") B desktop, $(stat -f %z "$OUT/$n.gen.phone.glb") B phone"
|
|
53
|
+
done
|
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
#!/usr/bin/env python3
|
|
2
|
+
"""build_props.py <props.json> <out dir> [ref ...] — image-to-3D generations → game props, for any shard (PH-0.3).
|
|
3
|
+
|
|
4
|
+
python3 scripts/img2mesh/build_props.py src/shards/driftwood-isle/art/hero-props.json public/assets/models/driftwood-hero
|
|
5
|
+
python3 scripts/img2mesh/build_props.py <pine-hollow props>.json public/assets/models/<dir> lantern # just these refs
|
|
6
|
+
|
|
7
|
+
The prop list JSON: {"gen": dir of <ref>.glb generations, "stage": staging dir, "args": [driftwood_post.py args for
|
|
8
|
+
every prop, e.g. "--keep-texture" for a photoreal shard], "props": [{"ref", "args": "driftwood_post.py args"}]}
|
|
9
|
+
(env GEN / STAGE / BLENDER override). Step 1 runs scripts/img2mesh/driftwood_post.py (Blender, headless) per prop into
|
|
10
|
+
the staging folder; step 2 meshopt-compresses every staged asset (only the named refs' when refs are given) into
|
|
11
|
+
<out dir>/<asset>/ with gltf-transform (EXT_meshopt_compression + quantization: the loader needs setMeshoptDecoder),
|
|
12
|
+
plus its <asset>.json. build_driftwood.sh is this with Driftwood's list; its outputs are byte-for-byte as before.
|
|
13
|
+
|
|
14
|
+
Hi3D (HI3D-REFINE, E494): a list key "refine": {"dir", "res"} (or env REFINE / REFINE_RES) passes driftwood_post.py
|
|
15
|
+
--geo <dir>/<ref>.hi3d<res>.obj, made by scripts/img2mesh/hi3d_refine.py; a prop with "refine": false keeps its own
|
|
16
|
+
geometry. A prop whose refined mesh is missing is skipped, never built unrefined.
|
|
17
|
+
"""
|
|
18
|
+
import glob
|
|
19
|
+
import json
|
|
20
|
+
import os
|
|
21
|
+
import re
|
|
22
|
+
import shlex
|
|
23
|
+
import shutil
|
|
24
|
+
import subprocess
|
|
25
|
+
import sys
|
|
26
|
+
|
|
27
|
+
REPO = os.path.abspath(os.path.join(os.path.dirname(os.path.abspath(__file__)), '..', '..'))
|
|
28
|
+
POST = os.path.join(REPO, 'scripts', 'img2mesh', 'driftwood_post.py')
|
|
29
|
+
|
|
30
|
+
if len(sys.argv) < 3:
|
|
31
|
+
sys.exit(__doc__)
|
|
32
|
+
spec = json.load(open(sys.argv[1]))
|
|
33
|
+
DEST = os.path.abspath(sys.argv[2])
|
|
34
|
+
refs = sys.argv[3:]
|
|
35
|
+
GEN = os.environ.get('GEN') or os.path.expanduser(spec['gen'])
|
|
36
|
+
STAGE = os.environ.get('STAGE') or os.path.expanduser(spec['stage'])
|
|
37
|
+
BLENDER = os.environ.get('BLENDER') or '/opt/homebrew/bin/blender'
|
|
38
|
+
common = [str(x) for x in spec.get('args', [])]
|
|
39
|
+
REFINE = os.environ.get('REFINE') or os.path.expanduser(spec.get('refine', {}).get('dir', ''))
|
|
40
|
+
REFINE_RES = os.environ.get('REFINE_RES') or str(spec.get('refine', {}).get('res', 1024))
|
|
41
|
+
os.makedirs(STAGE, exist_ok=True)
|
|
42
|
+
os.makedirs(DEST, exist_ok=True)
|
|
43
|
+
|
|
44
|
+
SHOW = re.compile(r'^DRIFTWOOD_POST|Error|Traceback')
|
|
45
|
+
for prop in spec['props']:
|
|
46
|
+
ref = prop['ref']
|
|
47
|
+
if refs and ref not in refs:
|
|
48
|
+
continue
|
|
49
|
+
src = os.path.join(GEN, ref + '.glb')
|
|
50
|
+
if not os.path.isfile(src):
|
|
51
|
+
print(f'skip {ref}: no {src}')
|
|
52
|
+
continue
|
|
53
|
+
geo = []
|
|
54
|
+
if REFINE and prop.get('refine', True) is not False:
|
|
55
|
+
obj = os.path.join(REFINE, f'{ref}.hi3d{REFINE_RES}.obj')
|
|
56
|
+
if not os.path.isfile(obj):
|
|
57
|
+
print(f'skip {ref}: no {obj} (run hi3d_refine.py)')
|
|
58
|
+
continue
|
|
59
|
+
geo = ['--geo', obj]
|
|
60
|
+
run = subprocess.run([BLENDER, '-b', '-P', POST, '--', '--in', src, '--out', STAGE, *common, *geo, *shlex.split(prop['args'])],
|
|
61
|
+
stdout=subprocess.PIPE, stderr=subprocess.STDOUT, text=True, errors='replace', check=False)
|
|
62
|
+
for line in run.stdout.splitlines():
|
|
63
|
+
if SHOW.search(line):
|
|
64
|
+
print(line)
|
|
65
|
+
|
|
66
|
+
# meshopt every staged asset of this run into the out dir
|
|
67
|
+
for d in sorted(glob.glob(os.path.join(STAGE, '*', ''))):
|
|
68
|
+
a = os.path.basename(os.path.normpath(d))
|
|
69
|
+
meta = os.path.join(d, a + '.json')
|
|
70
|
+
if not os.path.isfile(meta):
|
|
71
|
+
continue
|
|
72
|
+
info = json.load(open(meta))
|
|
73
|
+
if refs and re.sub(r'\.glb$', '', info.get('source', '')) not in refs:
|
|
74
|
+
continue
|
|
75
|
+
os.makedirs(os.path.join(DEST, a), exist_ok=True)
|
|
76
|
+
for g in sorted(glob.glob(os.path.join(d, '*.glb'))):
|
|
77
|
+
subprocess.run(['npx', '--prefix', REPO, 'gltf-transform', 'meshopt', g, os.path.join(DEST, a, os.path.basename(g)),
|
|
78
|
+
'--level', 'medium'], stdout=subprocess.DEVNULL, check=True)
|
|
79
|
+
shutil.copyfile(meta, os.path.join(DEST, a, a + '.json'))
|
|
80
|
+
sizes = ' '.join(f'./{os.path.basename(g)} {os.path.getsize(g)} B' for g in sorted(glob.glob(os.path.join(DEST, a, '*.glb'))))
|
|
81
|
+
print(f"{a:<22} {info.get('tris', ''):>6} tris {sizes}")
|
|
@@ -0,0 +1,186 @@
|
|
|
1
|
+
"""Export a CC0 kit model (Kenney / Quaternius / KayKit / Poly Pizza) as a Driftwood asset: one mesh, faceted, every
|
|
2
|
+
face's colour snapped to the Driftwood palette, metres, pivot at the base, vertex colours only (no textures).
|
|
3
|
+
|
|
4
|
+
blender -b -P scripts/img2mesh/cc0_export.py -- --in ~/models/cc0/kenney/pirate-kit/Models/GLB\ format/crate.glb \
|
|
5
|
+
--name cc0-crate --out ~/ml/img2mesh/out/driftwood-cc0 --size 0.9 [--fit height|length] [--keep-hue]
|
|
6
|
+
|
|
7
|
+
Face colour = the material's base colour factor x its base-colour texture at the face centre (Kenney's colormap atlas),
|
|
8
|
+
then snapped to the nearest PALETTE colour in CIELAB (the colours the procedural Driftwood models use: `src/shards/driftwood-isle/world/Palms.ts`, Pier.ts and Boulders.ts,
|
|
9
|
+
plus `src/client/engine/world/lowpolyKit.ts`), so a kit asset sits in the same world as the hero props.
|
|
10
|
+
"""
|
|
11
|
+
import argparse
|
|
12
|
+
import json
|
|
13
|
+
import os
|
|
14
|
+
import sys
|
|
15
|
+
|
|
16
|
+
import bmesh
|
|
17
|
+
import bpy
|
|
18
|
+
import numpy as np
|
|
19
|
+
from mathutils import Vector
|
|
20
|
+
|
|
21
|
+
PALETTE = {
|
|
22
|
+
# wood (Pier.ts, Palms.ts trunk)
|
|
23
|
+
"plank": "#9a7a56", "plankLight": "#b08d64", "plankDark": "#7c6244", "post": "#6f5638", "postTop": "#8a6d48",
|
|
24
|
+
"trunk": "#8a6a48", "ring": "#6d5238", "woodDeep": "#4a3826",
|
|
25
|
+
# rope / straw / sail / bleached driftwood
|
|
26
|
+
"rope": "#d8c48a", "ropeDark": "#b59e6a", "straw": "#e0b860", "sail": "#efe6d2", "bleach": "#d9cdb8", "bleachDark": "#b8a88e",
|
|
27
|
+
# foliage (lowpolyKit.ts PAL, Palms.ts)
|
|
28
|
+
"leaf": "#4f8f34", "leafB": "#63a63c", "leafDark": "#3c7430", "leafLight": "#7fbf4a", "frond": "#4f9a3a", "frondLight": "#72b94c",
|
|
29
|
+
"nut": "#6b5a2e", "nutGreen": "#7f9a3a",
|
|
30
|
+
# rock (Boulders.ts)
|
|
31
|
+
"rock": "#7a7e84", "rockLight": "#9da1a7", "rockDark": "#565a60", "moss": "#6f8f3a",
|
|
32
|
+
# sand, accents
|
|
33
|
+
"sand": "#e8cf9a", "sandDark": "#c9a970", "hibiscus": "#e2372c", "coral": "#f0543a", "gold": "#ffd24a", "flag": "#2f5bd0",
|
|
34
|
+
"iron": "#5a5d63", "white": "#f4f0ea", "black": "#2a2622", "teal": "#3fb6b0",
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
argv = sys.argv[sys.argv.index("--") + 1:] if "--" in sys.argv else []
|
|
38
|
+
ap = argparse.ArgumentParser()
|
|
39
|
+
ap.add_argument("--in", dest="src", required=True)
|
|
40
|
+
ap.add_argument("--name", required=True)
|
|
41
|
+
ap.add_argument("--out", required=True)
|
|
42
|
+
ap.add_argument("--size", type=float, required=True)
|
|
43
|
+
ap.add_argument("--fit", choices=["height", "length"], default="height")
|
|
44
|
+
ap.add_argument("--family", default="", help="snap only onto these palette entries (rock | bleach | wood | a,b,c keys)")
|
|
45
|
+
ap.add_argument("--keep-hue", action="store_true", help="snap lightness only: keep the kit colour, pull it toward the palette")
|
|
46
|
+
a = ap.parse_args(argv)
|
|
47
|
+
|
|
48
|
+
|
|
49
|
+
def srgb_to_lab(c):
|
|
50
|
+
c = np.asarray(c, dtype=np.float64)
|
|
51
|
+
lin = np.where(c <= 0.04045, c / 12.92, ((c + 0.055) / 1.055) ** 2.4)
|
|
52
|
+
m = np.array([[0.4124, 0.3576, 0.1805], [0.2126, 0.7152, 0.0722], [0.0193, 0.1192, 0.9505]])
|
|
53
|
+
xyz = lin @ m.T / np.array([0.95047, 1.0, 1.08883])
|
|
54
|
+
f = np.where(xyz > 216 / 24389, np.cbrt(xyz), (24389 / 27 * xyz + 16) / 116)
|
|
55
|
+
return np.stack([116 * f[..., 1] - 16, 500 * (f[..., 0] - f[..., 1]), 200 * (f[..., 1] - f[..., 2])], -1)
|
|
56
|
+
|
|
57
|
+
|
|
58
|
+
FAMILIES = {
|
|
59
|
+
"rock": ["rock", "rockLight", "rockDark"],
|
|
60
|
+
"bleach": ["bleach", "bleachDark", "sail", "ropeDark"],
|
|
61
|
+
"wood": ["plank", "plankLight", "plankDark", "post", "postTop", "trunk", "ring", "woodDeep"],
|
|
62
|
+
}
|
|
63
|
+
KEYS = [k for f in a.family.split(",") if f for k in FAMILIES.get(f, [f])] or list(PALETTE)
|
|
64
|
+
PAL = np.array([[int(PALETTE[k][i:i + 2], 16) / 255 for i in (1, 3, 5)] for k in KEYS])
|
|
65
|
+
PAL_LAB = srgb_to_lab(PAL)
|
|
66
|
+
|
|
67
|
+
bpy.ops.wm.read_factory_settings(use_empty=True)
|
|
68
|
+
src = os.path.expanduser(a.src)
|
|
69
|
+
if src.endswith((".glb", ".gltf")):
|
|
70
|
+
bpy.ops.import_scene.gltf(filepath=src)
|
|
71
|
+
elif src.endswith(".fbx"):
|
|
72
|
+
bpy.ops.import_scene.fbx(filepath=src)
|
|
73
|
+
else:
|
|
74
|
+
bpy.ops.wm.obj_import(filepath=src)
|
|
75
|
+
meshes = [o for o in bpy.context.scene.objects if o.type == "MESH"]
|
|
76
|
+
for o in bpy.context.scene.objects:
|
|
77
|
+
o.select_set(o.type == "MESH")
|
|
78
|
+
bpy.context.view_layer.objects.active = meshes[0]
|
|
79
|
+
bpy.ops.object.convert(target="MESH") # bake any modifiers
|
|
80
|
+
if len(meshes) > 1:
|
|
81
|
+
bpy.ops.object.join()
|
|
82
|
+
ob = bpy.context.view_layer.objects.active
|
|
83
|
+
bpy.ops.object.parent_clear(type="CLEAR_KEEP_TRANSFORM")
|
|
84
|
+
bpy.ops.object.transform_apply(location=True, rotation=True, scale=True)
|
|
85
|
+
|
|
86
|
+
|
|
87
|
+
def mat_colour_fn(m):
|
|
88
|
+
"""-> f(uv) giving the sRGB base colour of material m (factor x texture)."""
|
|
89
|
+
if m is None or not m.node_tree:
|
|
90
|
+
return lambda uv: np.array([0.7, 0.7, 0.7])
|
|
91
|
+
bsdf = next((n for n in m.node_tree.nodes if n.type == "BSDF_PRINCIPLED"), None)
|
|
92
|
+
if bsdf is None:
|
|
93
|
+
return lambda uv: np.array([0.7, 0.7, 0.7])
|
|
94
|
+
inp = bsdf.inputs["Base Color"]
|
|
95
|
+
fac = np.array(inp.default_value[:3])
|
|
96
|
+
fac = np.where(fac <= 0.0031308, fac * 12.92, 1.055 * np.power(np.maximum(fac, 0), 1 / 2.4) - 0.055)
|
|
97
|
+
node = inp.links[0].from_node if inp.links else None
|
|
98
|
+
while node is not None and node.type != "TEX_IMAGE": # through a multiply / vertex colour mix
|
|
99
|
+
nxt = [l.from_node for i in node.inputs for l in i.links]
|
|
100
|
+
node = nxt[0] if nxt else None
|
|
101
|
+
if node is None or node.image is None:
|
|
102
|
+
return lambda uv: fac
|
|
103
|
+
im = node.image
|
|
104
|
+
w, h = im.size
|
|
105
|
+
px = np.empty(w * h * 4, dtype=np.float32)
|
|
106
|
+
im.pixels.foreach_get(px)
|
|
107
|
+
px = px.reshape(h, w, 4)[..., :3]
|
|
108
|
+
if im.colorspace_settings.name != "sRGB":
|
|
109
|
+
px = np.where(px <= 0.0031308, px * 12.92, 1.055 * np.power(np.maximum(px, 0), 1 / 2.4) - 0.055)
|
|
110
|
+
if inp.links and inp.links[0].from_node.type == "TEX_IMAGE":
|
|
111
|
+
fac = np.ones(3) # a linked texture replaces the factor in Blender's import
|
|
112
|
+
return lambda uv: fac * px[int(np.clip(uv[1] % 1, 0, 0.9999) * h), int(np.clip(uv[0] % 1, 0, 0.9999) * w)]
|
|
113
|
+
|
|
114
|
+
|
|
115
|
+
fns = [mat_colour_fn(s.material) for s in ob.material_slots] or [mat_colour_fn(None)]
|
|
116
|
+
bm = bmesh.new()
|
|
117
|
+
bm.from_mesh(ob.data)
|
|
118
|
+
bmesh.ops.triangulate(bm, faces=bm.faces[:])
|
|
119
|
+
uvl = bm.loops.layers.uv.active
|
|
120
|
+
cols = []
|
|
121
|
+
for f in bm.faces:
|
|
122
|
+
uv = np.mean([l[uvl].uv[:] for l in f.loops], 0) if uvl else np.zeros(2)
|
|
123
|
+
cols.append(fns[min(f.material_index, len(fns) - 1)](uv))
|
|
124
|
+
cols = np.clip(np.array(cols), 0, 1)
|
|
125
|
+
lab = srgb_to_lab(cols)
|
|
126
|
+
if a.family: # a family snap goes by lightness rank, so a light kit rock still spans light..dark rock
|
|
127
|
+
lab = lab.copy()
|
|
128
|
+
lo, hi = np.percentile(lab[:, 0], 5), np.percentile(lab[:, 0], 95)
|
|
129
|
+
plo, phi = PAL_LAB[:, 0].min(), PAL_LAB[:, 0].max()
|
|
130
|
+
t = (lab[:, 0] - lo) / (hi - lo) if hi - lo > 8 else 0.5 + (lab[:, 0] - lo) / 16 # one-tone kit: centre it
|
|
131
|
+
lab[:, 0] = plo + np.clip(t, 0, 1) * (phi - plo)
|
|
132
|
+
lab[:, 1:] *= 0.3
|
|
133
|
+
if a.keep_hue: # halfway to the nearest palette colour
|
|
134
|
+
idx = ((lab[:, None, :] - PAL_LAB[None]) ** 2).sum(2).argmin(1)
|
|
135
|
+
snapped = 0.5 * cols + 0.5 * PAL[idx]
|
|
136
|
+
else:
|
|
137
|
+
idx = ((lab[:, None, :] - PAL_LAB[None]) ** 2).sum(2).argmin(1)
|
|
138
|
+
snapped = PAL[idx]
|
|
139
|
+
bm.to_mesh(ob.data)
|
|
140
|
+
bm.free()
|
|
141
|
+
me = ob.data
|
|
142
|
+
for uv in list(me.uv_layers):
|
|
143
|
+
me.uv_layers.remove(uv)
|
|
144
|
+
for p in me.polygons:
|
|
145
|
+
p.use_smooth = False
|
|
146
|
+
attr = me.color_attributes.new("Color", "FLOAT_COLOR", "CORNER")
|
|
147
|
+
for p, c in zip(me.polygons, snapped):
|
|
148
|
+
for li in p.loop_indices:
|
|
149
|
+
attr.data[li].color_srgb = (float(c[0]), float(c[1]), float(c[2]), 1.0)
|
|
150
|
+
me.color_attributes.active_color = attr
|
|
151
|
+
|
|
152
|
+
d = ob.dimensions
|
|
153
|
+
ref = d.z if a.fit == "height" else max(d.x, d.y)
|
|
154
|
+
s = a.size / max(ref, 1e-6)
|
|
155
|
+
ob.scale = (s, s, s)
|
|
156
|
+
bpy.ops.object.transform_apply(scale=True)
|
|
157
|
+
co = np.array([v.co[:] for v in me.vertices])
|
|
158
|
+
zmin = co[:, 2].min()
|
|
159
|
+
pivot = np.array([(co[:, 0].min() + co[:, 0].max()) / 2, (co[:, 1].min() + co[:, 1].max()) / 2, zmin])
|
|
160
|
+
for v in me.vertices:
|
|
161
|
+
v.co = Vector(np.array(v.co[:]) - pivot)
|
|
162
|
+
|
|
163
|
+
mat = bpy.data.materials.new("driftwood-cc0")
|
|
164
|
+
mat.use_nodes = True
|
|
165
|
+
nt = mat.node_tree
|
|
166
|
+
bsdf = nt.nodes["Principled BSDF"]
|
|
167
|
+
vc = nt.nodes.new("ShaderNodeVertexColor")
|
|
168
|
+
vc.layer_name = "Color"
|
|
169
|
+
nt.links.new(vc.outputs["Color"], bsdf.inputs["Base Color"])
|
|
170
|
+
bsdf.inputs["Roughness"].default_value = 0.9
|
|
171
|
+
me.materials.clear()
|
|
172
|
+
me.materials.append(mat)
|
|
173
|
+
ob.name = a.name
|
|
174
|
+
folder = os.path.join(os.path.expanduser(a.out), a.name)
|
|
175
|
+
os.makedirs(folder, exist_ok=True)
|
|
176
|
+
bpy.ops.object.select_all(action="DESELECT")
|
|
177
|
+
ob.select_set(True)
|
|
178
|
+
bpy.ops.export_scene.gltf(filepath=os.path.join(folder, a.name + ".glb"), export_format="GLB", use_selection=True,
|
|
179
|
+
export_yup=True, export_vertex_color="ACTIVE", export_all_vertex_colors=False,
|
|
180
|
+
export_image_format="NONE")
|
|
181
|
+
used = sorted({KEYS[i] for i in np.unique(idx)})
|
|
182
|
+
info = {"name": a.name, "source": src.replace(os.path.expanduser("~"), "~"), "licence": "CC0 1.0 (see scripts/img2mesh/CC0.md)",
|
|
183
|
+
"tris": len(me.polygons), "size_m": [round(v, 2) for v in ob.dimensions], "palette": used,
|
|
184
|
+
"vertex_colour": "COLOR_0 rgb = Driftwood palette albedo, a = 1"}
|
|
185
|
+
json.dump(info, open(os.path.join(folder, a.name + ".json"), "w"), indent=1)
|
|
186
|
+
print("CC0_EXPORT " + json.dumps({k: info[k] for k in ("name", "tris", "size_m")}))
|