@playdrop/playdrop-cli 0.16.12 → 0.17.0
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/config/client-meta.json +4 -4
- package/dist/apiClient.d.ts +1 -2
- package/dist/apiClient.js +1 -16
- package/dist/appUrls.js +4 -0
- package/dist/apps/build.d.ts +12 -4
- package/dist/apps/build.js +55 -22
- package/dist/apps/index.d.ts +2 -1
- package/dist/apps/index.js +4 -1
- package/dist/apps/loadCheck.d.ts +5 -1
- package/dist/apps/loadCheck.js +52 -18
- package/dist/apps/serverBuild.d.ts +17 -0
- package/dist/apps/serverBuild.js +155 -0
- package/dist/apps/staticHtml.d.ts +1 -0
- package/dist/apps/staticHtml.js +19 -10
- package/dist/apps/upload.d.ts +12 -2
- package/dist/apps/upload.js +127 -46
- package/dist/catalogue.d.ts +23 -1
- package/dist/catalogue.js +126 -100
- package/dist/commandContext.d.ts +6 -3
- package/dist/commandContext.js +108 -18
- package/dist/commands/build.js +0 -7
- package/dist/commands/captureListing.d.ts +3 -0
- package/dist/commands/captureListing.js +48 -4
- package/dist/commands/chat.d.ts +4 -7
- package/dist/commands/chat.js +165 -77
- package/dist/commands/check.js +34 -1
- package/dist/commands/create.js +30 -263
- package/dist/commands/dev.js +37 -3
- package/dist/commands/devBrowser.js +2 -2
- package/dist/commands/devGameServer.d.ts +16 -0
- package/dist/commands/devGameServer.js +237 -0
- package/dist/commands/devRuntimeAssets.d.ts +1 -0
- package/dist/commands/devRuntimeAssets.js +2 -0
- package/dist/commands/devServer.d.ts +3 -0
- package/dist/commands/devServer.js +111 -5
- package/dist/commands/generation.d.ts +33 -4
- package/dist/commands/generation.js +304 -115
- package/dist/commands/login.js +23 -7
- package/dist/commands/review.d.ts +1 -1
- package/dist/commands/review.js +68 -95
- package/dist/commands/source.d.ts +19 -0
- package/dist/commands/source.js +142 -0
- package/dist/commands/tweaks.js +5 -11
- package/dist/commands/upload-content.d.ts +1 -1
- package/dist/commands/upload-content.js +16 -12
- package/dist/commands/upload.d.ts +17 -1
- package/dist/commands/upload.js +47 -10
- package/dist/commands/worker/archive-staging.d.ts +1 -0
- package/dist/commands/worker/archive-staging.js +13 -2
- package/dist/commands/worker/e2e-fixtures.d.ts +32 -0
- package/dist/commands/worker/e2e-fixtures.js +466 -0
- package/dist/commands/worker/game-server-infra.d.ts +80 -0
- package/dist/commands/worker/game-server-infra.js +595 -0
- package/dist/commands/worker/game-source-git.d.ts +126 -0
- package/dist/commands/worker/game-source-git.js +780 -0
- package/dist/commands/worker/generation.d.ts +94 -0
- package/dist/commands/worker/generation.js +1458 -0
- package/dist/commands/worker/provider-telemetry.js +1 -1
- package/dist/commands/worker/runtime.d.ts +8 -10
- package/dist/commands/worker/runtime.js +53 -48
- package/dist/commands/worker.d.ts +79 -19
- package/dist/commands/worker.js +1796 -419
- package/dist/config.d.ts +2 -0
- package/dist/config.js +16 -3
- package/dist/environment.d.ts +0 -1
- package/dist/environment.js +0 -8
- package/dist/index.js +92 -22
- package/dist/workerAppProject.d.ts +1 -1
- package/dist/workerAppProject.js +15 -2
- package/node_modules/@playdrop/api-client/dist/client.d.ts +143 -39
- package/node_modules/@playdrop/api-client/dist/client.d.ts.map +1 -1
- package/node_modules/@playdrop/api-client/dist/client.js +33 -0
- package/node_modules/@playdrop/api-client/dist/core/request.d.ts +1 -0
- package/node_modules/@playdrop/api-client/dist/core/request.d.ts.map +1 -1
- package/node_modules/@playdrop/api-client/dist/core/request.js +17 -11
- package/node_modules/@playdrop/api-client/dist/domains/agent-tasks.d.ts +51 -6
- package/node_modules/@playdrop/api-client/dist/domains/agent-tasks.d.ts.map +1 -1
- package/node_modules/@playdrop/api-client/dist/domains/agent-tasks.js +338 -41
- package/node_modules/@playdrop/api-client/dist/domains/ai.d.ts +24 -1
- package/node_modules/@playdrop/api-client/dist/domains/ai.d.ts.map +1 -1
- package/node_modules/@playdrop/api-client/dist/domains/ai.js +20 -0
- package/node_modules/@playdrop/api-client/dist/domains/apps.d.ts +13 -8
- package/node_modules/@playdrop/api-client/dist/domains/apps.d.ts.map +1 -1
- package/node_modules/@playdrop/api-client/dist/domains/apps.js +158 -90
- package/node_modules/@playdrop/api-client/dist/domains/assets.d.ts +4 -0
- package/node_modules/@playdrop/api-client/dist/domains/assets.d.ts.map +1 -1
- package/node_modules/@playdrop/api-client/dist/domains/assets.js +27 -0
- package/node_modules/@playdrop/api-client/dist/domains/chat.d.ts +152 -21
- package/node_modules/@playdrop/api-client/dist/domains/chat.d.ts.map +1 -1
- package/node_modules/@playdrop/api-client/dist/domains/chat.js +477 -100
- package/node_modules/@playdrop/api-client/dist/domains/player-meta.d.ts +2 -1
- package/node_modules/@playdrop/api-client/dist/domains/player-meta.d.ts.map +1 -1
- package/node_modules/@playdrop/api-client/dist/domains/player-meta.js +9 -0
- package/node_modules/@playdrop/api-client/dist/domains/playtrade.d.ts +1 -2
- package/node_modules/@playdrop/api-client/dist/domains/playtrade.d.ts.map +1 -1
- package/node_modules/@playdrop/api-client/dist/domains/playtrade.js +0 -11
- package/node_modules/@playdrop/api-client/dist/domains/social.d.ts +29 -0
- package/node_modules/@playdrop/api-client/dist/domains/social.d.ts.map +1 -0
- package/node_modules/@playdrop/api-client/dist/domains/social.js +79 -0
- package/node_modules/@playdrop/api-client/dist/index.d.ts +81 -30
- package/node_modules/@playdrop/api-client/dist/index.d.ts.map +1 -1
- package/node_modules/@playdrop/api-client/dist/index.js +217 -56
- package/node_modules/@playdrop/api-client/dist/runtime.d.ts +18 -0
- package/node_modules/@playdrop/api-client/dist/runtime.d.ts.map +1 -0
- package/node_modules/@playdrop/api-client/dist/runtime.js +54 -0
- package/node_modules/@playdrop/api-client/package.json +7 -0
- package/node_modules/@playdrop/config/client-meta.json +4 -4
- package/node_modules/@playdrop/config/dist/src/creator-plans.d.ts +11 -0
- package/node_modules/@playdrop/config/dist/src/creator-plans.d.ts.map +1 -1
- package/node_modules/@playdrop/config/dist/src/creator-plans.js +13 -1
- package/node_modules/@playdrop/config/dist/src/deployment.d.ts +0 -1
- package/node_modules/@playdrop/config/dist/src/deployment.d.ts.map +1 -1
- package/node_modules/@playdrop/config/dist/src/deployment.js +0 -8
- package/node_modules/@playdrop/config/dist/src/public-deployment.d.ts +0 -1
- package/node_modules/@playdrop/config/dist/src/public-deployment.d.ts.map +1 -1
- package/node_modules/@playdrop/config/dist/src/public-deployment.js +0 -8
- package/node_modules/@playdrop/config/dist/src/runtime-service-origins.d.ts +1 -1
- package/node_modules/@playdrop/config/dist/src/runtime-service-origins.js +2 -2
- package/node_modules/@playdrop/config/dist/src/server/logging.d.ts.map +1 -1
- package/node_modules/@playdrop/config/dist/src/server/logging.js +31 -2
- package/node_modules/@playdrop/config/dist/test/creator-plans.test.js +10 -0
- package/node_modules/@playdrop/config/dist/test/deployment.test.js +0 -4
- package/node_modules/@playdrop/config/dist/test/runtime-service-origins.test.js +2 -0
- package/node_modules/@playdrop/config/dist/tsconfig.tsbuildinfo +1 -1
- package/node_modules/@playdrop/config/package.json +6 -0
- package/node_modules/@playdrop/game-source-git/dist/src/archive.d.ts +9 -0
- package/node_modules/@playdrop/game-source-git/dist/src/archive.d.ts.map +1 -0
- package/node_modules/@playdrop/game-source-git/dist/src/archive.js +107 -0
- package/node_modules/@playdrop/game-source-git/dist/src/bundle-storage.d.ts +29 -0
- package/node_modules/@playdrop/game-source-git/dist/src/bundle-storage.d.ts.map +1 -0
- package/node_modules/@playdrop/game-source-git/dist/src/bundle-storage.js +64 -0
- package/node_modules/@playdrop/game-source-git/dist/src/export.d.ts +8 -0
- package/node_modules/@playdrop/game-source-git/dist/src/export.d.ts.map +1 -0
- package/node_modules/@playdrop/game-source-git/dist/src/export.js +25 -0
- package/node_modules/@playdrop/game-source-git/dist/src/git.d.ts +39 -0
- package/node_modules/@playdrop/game-source-git/dist/src/git.d.ts.map +1 -0
- package/node_modules/@playdrop/game-source-git/dist/src/git.js +195 -0
- package/node_modules/@playdrop/game-source-git/dist/src/ignore.d.ts +6 -0
- package/node_modules/@playdrop/game-source-git/dist/src/ignore.d.ts.map +1 -0
- package/node_modules/@playdrop/game-source-git/dist/src/ignore.js +51 -0
- package/node_modules/@playdrop/game-source-git/dist/src/index.d.ts +10 -0
- package/node_modules/@playdrop/game-source-git/dist/src/index.d.ts.map +1 -0
- package/node_modules/@playdrop/{boxel-core/dist/src/humanoid/r15 → game-source-git/dist/src}/index.js +9 -4
- package/node_modules/@playdrop/game-source-git/dist/src/lock.d.ts +17 -0
- package/node_modules/@playdrop/game-source-git/dist/src/lock.d.ts.map +1 -0
- package/node_modules/@playdrop/game-source-git/dist/src/lock.js +72 -0
- package/node_modules/@playdrop/game-source-git/dist/src/materialize.d.ts +10 -0
- package/node_modules/@playdrop/game-source-git/dist/src/materialize.d.ts.map +1 -0
- package/node_modules/@playdrop/game-source-git/dist/src/materialize.js +99 -0
- package/node_modules/@playdrop/game-source-git/dist/src/paths.d.ts +24 -0
- package/node_modules/@playdrop/game-source-git/dist/src/paths.d.ts.map +1 -0
- package/node_modules/@playdrop/game-source-git/dist/src/paths.js +207 -0
- package/node_modules/@playdrop/game-source-git/dist/src/repository.d.ts +66 -0
- package/node_modules/@playdrop/game-source-git/dist/src/repository.d.ts.map +1 -0
- package/node_modules/@playdrop/game-source-git/dist/src/repository.js +213 -0
- package/node_modules/@playdrop/game-source-git/dist/test/core.test.d.ts +2 -0
- package/node_modules/@playdrop/game-source-git/dist/test/core.test.d.ts.map +1 -0
- package/node_modules/@playdrop/game-source-git/dist/test/core.test.js +441 -0
- package/node_modules/@playdrop/game-source-git/dist/tsconfig.tsbuildinfo +1 -0
- package/node_modules/@playdrop/game-source-git/package.json +28 -0
- package/node_modules/@playdrop/types/dist/agent-task-terminal.d.ts +2 -2
- package/node_modules/@playdrop/types/dist/agent-task-terminal.d.ts.map +1 -1
- package/node_modules/@playdrop/types/dist/agent-task-terminal.js +15 -9
- package/node_modules/@playdrop/types/dist/api.d.ts +730 -166
- package/node_modules/@playdrop/types/dist/api.d.ts.map +1 -1
- package/node_modules/@playdrop/types/dist/api.js +65 -18
- package/node_modules/@playdrop/types/dist/asset-pack.d.ts +2 -0
- package/node_modules/@playdrop/types/dist/asset-pack.d.ts.map +1 -1
- package/node_modules/@playdrop/types/dist/asset.d.ts +22 -8
- package/node_modules/@playdrop/types/dist/asset.d.ts.map +1 -1
- package/node_modules/@playdrop/types/dist/asset.js +26 -26
- package/node_modules/@playdrop/types/dist/chat.d.ts +273 -31
- package/node_modules/@playdrop/types/dist/chat.d.ts.map +1 -1
- package/node_modules/@playdrop/types/dist/chat.js +38 -4
- package/node_modules/@playdrop/types/dist/index.d.ts +3 -0
- package/node_modules/@playdrop/types/dist/index.d.ts.map +1 -1
- package/node_modules/@playdrop/types/dist/index.js +7 -1
- package/node_modules/@playdrop/types/dist/public-cache-tags.d.ts +11 -0
- package/node_modules/@playdrop/types/dist/public-cache-tags.d.ts.map +1 -0
- package/node_modules/@playdrop/types/dist/public-cache-tags.js +78 -0
- package/node_modules/@playdrop/types/dist/realtime.d.ts +3 -15
- package/node_modules/@playdrop/types/dist/realtime.d.ts.map +1 -1
- package/node_modules/@playdrop/types/dist/social.d.ts +64 -0
- package/node_modules/@playdrop/types/dist/social.d.ts.map +1 -0
- package/node_modules/@playdrop/{boxel-three/dist/src/types.js → types/dist/social.js} +14 -2
- package/node_modules/@playdrop/types/dist/spritesheet.d.ts +51 -0
- package/node_modules/@playdrop/types/dist/spritesheet.d.ts.map +1 -0
- package/node_modules/@playdrop/types/dist/spritesheet.js +73 -0
- package/node_modules/@playdrop/types/dist/version.d.ts +86 -58
- package/node_modules/@playdrop/types/dist/version.d.ts.map +1 -1
- package/node_modules/@playdrop/types/dist/version.js +111 -0
- package/node_modules/@playdrop/types/package.json +14 -0
- package/node_modules/@playdrop/vox-three/dist/src/index.d.ts +1 -1
- package/node_modules/@playdrop/vox-three/dist/src/index.js +1 -1
- package/node_modules/@playdrop/vox-three/dist/src/index.js.map +1 -1
- package/node_modules/@playdrop/vox-three/dist/src/vox.d.ts +0 -3
- package/node_modules/@playdrop/vox-three/dist/src/vox.js +0 -110
- package/node_modules/@playdrop/vox-three/dist/src/vox.js.map +1 -1
- package/node_modules/@playdrop/vox-three/dist/test/vox.test.js +0 -18
- package/node_modules/@playdrop/vox-three/dist/test/vox.test.js.map +1 -1
- package/node_modules/@playdrop/vox-three/package.json +8 -4
- package/package.json +9 -11
- package/dist/assets/model-artifacts.d.ts +0 -8
- package/dist/assets/model-artifacts.js +0 -382
- package/dist/assets/model-worker.d.ts +0 -22
- package/dist/assets/model-worker.js +0 -123
- package/node_modules/@playdrop/ai-client/dist/index.d.ts +0 -441
- package/node_modules/@playdrop/ai-client/dist/index.d.ts.map +0 -1
- package/node_modules/@playdrop/ai-client/dist/index.js +0 -499
- package/node_modules/@playdrop/ai-client/package.json +0 -22
- package/node_modules/@playdrop/boxel-core/dist/src/entity-cleaner.d.ts +0 -13
- package/node_modules/@playdrop/boxel-core/dist/src/entity-cleaner.js +0 -141
- package/node_modules/@playdrop/boxel-core/dist/src/entity-cleaner.js.map +0 -1
- package/node_modules/@playdrop/boxel-core/dist/src/entity-utils.d.ts +0 -47
- package/node_modules/@playdrop/boxel-core/dist/src/entity-utils.js +0 -313
- package/node_modules/@playdrop/boxel-core/dist/src/entity-utils.js.map +0 -1
- package/node_modules/@playdrop/boxel-core/dist/src/format-utils.d.ts +0 -3
- package/node_modules/@playdrop/boxel-core/dist/src/format-utils.js +0 -36
- package/node_modules/@playdrop/boxel-core/dist/src/format-utils.js.map +0 -1
- package/node_modules/@playdrop/boxel-core/dist/src/humanoid/geometry.d.ts +0 -23
- package/node_modules/@playdrop/boxel-core/dist/src/humanoid/geometry.js +0 -11
- package/node_modules/@playdrop/boxel-core/dist/src/humanoid/geometry.js.map +0 -1
- package/node_modules/@playdrop/boxel-core/dist/src/humanoid/index.d.ts +0 -4
- package/node_modules/@playdrop/boxel-core/dist/src/humanoid/index.js +0 -21
- package/node_modules/@playdrop/boxel-core/dist/src/humanoid/index.js.map +0 -1
- package/node_modules/@playdrop/boxel-core/dist/src/humanoid/r15/common.d.ts +0 -4
- package/node_modules/@playdrop/boxel-core/dist/src/humanoid/r15/common.js +0 -24
- package/node_modules/@playdrop/boxel-core/dist/src/humanoid/r15/common.js.map +0 -1
- package/node_modules/@playdrop/boxel-core/dist/src/humanoid/r15/index.d.ts +0 -3
- package/node_modules/@playdrop/boxel-core/dist/src/humanoid/r15/index.js.map +0 -1
- package/node_modules/@playdrop/boxel-core/dist/src/humanoid/r15/textured-builder.d.ts +0 -3
- package/node_modules/@playdrop/boxel-core/dist/src/humanoid/r15/textured-builder.js +0 -387
- package/node_modules/@playdrop/boxel-core/dist/src/humanoid/r15/textured-builder.js.map +0 -1
- package/node_modules/@playdrop/boxel-core/dist/src/humanoid/r15/types.d.ts +0 -6
- package/node_modules/@playdrop/boxel-core/dist/src/humanoid/r15/types.js +0 -3
- package/node_modules/@playdrop/boxel-core/dist/src/humanoid/r15/types.js.map +0 -1
- package/node_modules/@playdrop/boxel-core/dist/src/humanoid/r15/voxel-builder.d.ts +0 -3
- package/node_modules/@playdrop/boxel-core/dist/src/humanoid/r15/voxel-builder.js +0 -373
- package/node_modules/@playdrop/boxel-core/dist/src/humanoid/r15/voxel-builder.js.map +0 -1
- package/node_modules/@playdrop/boxel-core/dist/src/humanoid/r6/builder.d.ts +0 -12
- package/node_modules/@playdrop/boxel-core/dist/src/humanoid/r6/builder.js +0 -215
- package/node_modules/@playdrop/boxel-core/dist/src/humanoid/r6/builder.js.map +0 -1
- package/node_modules/@playdrop/boxel-core/dist/src/humanoid/r6/index.d.ts +0 -4
- package/node_modules/@playdrop/boxel-core/dist/src/humanoid/r6/index.js +0 -18
- package/node_modules/@playdrop/boxel-core/dist/src/humanoid/r6/index.js.map +0 -1
- package/node_modules/@playdrop/boxel-core/dist/src/humanoid/r6/scanner.d.ts +0 -42
- package/node_modules/@playdrop/boxel-core/dist/src/humanoid/r6/scanner.js +0 -145
- package/node_modules/@playdrop/boxel-core/dist/src/humanoid/r6/scanner.js.map +0 -1
- package/node_modules/@playdrop/boxel-core/dist/src/humanoid/r6/textures/artifacts.d.ts +0 -26
- package/node_modules/@playdrop/boxel-core/dist/src/humanoid/r6/textures/artifacts.js +0 -65
- package/node_modules/@playdrop/boxel-core/dist/src/humanoid/r6/textures/artifacts.js.map +0 -1
- package/node_modules/@playdrop/boxel-core/dist/src/humanoid/r6/textures/face-map.d.ts +0 -33
- package/node_modules/@playdrop/boxel-core/dist/src/humanoid/r6/textures/face-map.js +0 -175
- package/node_modules/@playdrop/boxel-core/dist/src/humanoid/r6/textures/face-map.js.map +0 -1
- package/node_modules/@playdrop/boxel-core/dist/src/humanoid/templates/humanoid_r15.json +0 -1517
- package/node_modules/@playdrop/boxel-core/dist/src/humanoid/templates/humanoid_r6.json +0 -61
- package/node_modules/@playdrop/boxel-core/dist/src/humanoid/templates/index.d.ts +0 -10
- package/node_modules/@playdrop/boxel-core/dist/src/humanoid/templates/index.js +0 -23
- package/node_modules/@playdrop/boxel-core/dist/src/humanoid/templates/index.js.map +0 -1
- package/node_modules/@playdrop/boxel-core/dist/src/index.d.ts +0 -19
- package/node_modules/@playdrop/boxel-core/dist/src/index.js +0 -36
- package/node_modules/@playdrop/boxel-core/dist/src/index.js.map +0 -1
- package/node_modules/@playdrop/boxel-core/dist/src/materials.d.ts +0 -26
- package/node_modules/@playdrop/boxel-core/dist/src/materials.js +0 -184
- package/node_modules/@playdrop/boxel-core/dist/src/materials.js.map +0 -1
- package/node_modules/@playdrop/boxel-core/dist/src/palette_tools.d.ts +0 -68
- package/node_modules/@playdrop/boxel-core/dist/src/palette_tools.js +0 -488
- package/node_modules/@playdrop/boxel-core/dist/src/palette_tools.js.map +0 -1
- package/node_modules/@playdrop/boxel-core/dist/src/serialization.d.ts +0 -4
- package/node_modules/@playdrop/boxel-core/dist/src/serialization.js +0 -380
- package/node_modules/@playdrop/boxel-core/dist/src/serialization.js.map +0 -1
- package/node_modules/@playdrop/boxel-core/dist/src/textures.d.ts +0 -29
- package/node_modules/@playdrop/boxel-core/dist/src/textures.js +0 -208
- package/node_modules/@playdrop/boxel-core/dist/src/textures.js.map +0 -1
- package/node_modules/@playdrop/boxel-core/dist/src/transforms/textured-boxes/infer-face.d.ts +0 -9
- package/node_modules/@playdrop/boxel-core/dist/src/transforms/textured-boxes/infer-face.js +0 -312
- package/node_modules/@playdrop/boxel-core/dist/src/transforms/textured-boxes/infer-face.js.map +0 -1
- package/node_modules/@playdrop/boxel-core/dist/src/transforms/textured-boxes/layer-mode.d.ts +0 -9
- package/node_modules/@playdrop/boxel-core/dist/src/transforms/textured-boxes/layer-mode.js +0 -154
- package/node_modules/@playdrop/boxel-core/dist/src/transforms/textured-boxes/layer-mode.js.map +0 -1
- package/node_modules/@playdrop/boxel-core/dist/src/transforms/textured-boxes/merge-overlay.d.ts +0 -2
- package/node_modules/@playdrop/boxel-core/dist/src/transforms/textured-boxes/merge-overlay.js +0 -121
- package/node_modules/@playdrop/boxel-core/dist/src/transforms/textured-boxes/merge-overlay.js.map +0 -1
- package/node_modules/@playdrop/boxel-core/dist/src/transforms/textured-boxes/slice.d.ts +0 -20
- package/node_modules/@playdrop/boxel-core/dist/src/transforms/textured-boxes/slice.js +0 -389
- package/node_modules/@playdrop/boxel-core/dist/src/transforms/textured-boxes/slice.js.map +0 -1
- package/node_modules/@playdrop/boxel-core/dist/src/transforms/upscale.d.ts +0 -3
- package/node_modules/@playdrop/boxel-core/dist/src/transforms/upscale.js +0 -206
- package/node_modules/@playdrop/boxel-core/dist/src/transforms/upscale.js.map +0 -1
- package/node_modules/@playdrop/boxel-core/dist/src/transforms/voxels/slice.d.ts +0 -12
- package/node_modules/@playdrop/boxel-core/dist/src/transforms/voxels/slice.js +0 -81
- package/node_modules/@playdrop/boxel-core/dist/src/transforms/voxels/slice.js.map +0 -1
- package/node_modules/@playdrop/boxel-core/dist/src/transforms/voxels/textured-to-voxel.d.ts +0 -12
- package/node_modules/@playdrop/boxel-core/dist/src/transforms/voxels/textured-to-voxel.js +0 -318
- package/node_modules/@playdrop/boxel-core/dist/src/transforms/voxels/textured-to-voxel.js.map +0 -1
- package/node_modules/@playdrop/boxel-core/dist/src/types.d.ts +0 -168
- package/node_modules/@playdrop/boxel-core/dist/src/types.js +0 -3
- package/node_modules/@playdrop/boxel-core/dist/src/types.js.map +0 -1
- package/node_modules/@playdrop/boxel-core/dist/src/validation.d.ts +0 -24
- package/node_modules/@playdrop/boxel-core/dist/src/validation.js +0 -620
- package/node_modules/@playdrop/boxel-core/dist/src/validation.js.map +0 -1
- package/node_modules/@playdrop/boxel-core/dist/src/voxels/greedy-mesher.d.ts +0 -11
- package/node_modules/@playdrop/boxel-core/dist/src/voxels/greedy-mesher.js +0 -135
- package/node_modules/@playdrop/boxel-core/dist/src/voxels/greedy-mesher.js.map +0 -1
- package/node_modules/@playdrop/boxel-core/dist/src/voxels.d.ts +0 -23
- package/node_modules/@playdrop/boxel-core/dist/src/voxels.js +0 -52
- package/node_modules/@playdrop/boxel-core/dist/src/voxels.js.map +0 -1
- package/node_modules/@playdrop/boxel-core/package.json +0 -19
- package/node_modules/@playdrop/boxel-three/dist/src/animations.d.ts +0 -4
- package/node_modules/@playdrop/boxel-three/dist/src/animations.js +0 -92
- package/node_modules/@playdrop/boxel-three/dist/src/builders.d.ts +0 -8
- package/node_modules/@playdrop/boxel-three/dist/src/builders.js +0 -363
- package/node_modules/@playdrop/boxel-three/dist/src/context.d.ts +0 -24
- package/node_modules/@playdrop/boxel-three/dist/src/context.js +0 -58
- package/node_modules/@playdrop/boxel-three/dist/src/exporters/glb.d.ts +0 -100
- package/node_modules/@playdrop/boxel-three/dist/src/exporters/glb.js +0 -927
- package/node_modules/@playdrop/boxel-three/dist/src/exporters/image.d.ts +0 -18
- package/node_modules/@playdrop/boxel-three/dist/src/exporters/image.js +0 -294
- package/node_modules/@playdrop/boxel-three/dist/src/index.d.ts +0 -17
- package/node_modules/@playdrop/boxel-three/dist/src/index.js +0 -64
- package/node_modules/@playdrop/boxel-three/dist/src/instantiate.d.ts +0 -40
- package/node_modules/@playdrop/boxel-three/dist/src/instantiate.js +0 -96
- package/node_modules/@playdrop/boxel-three/dist/src/nodes.d.ts +0 -8
- package/node_modules/@playdrop/boxel-three/dist/src/nodes.js +0 -88
- package/node_modules/@playdrop/boxel-three/dist/src/overlays.d.ts +0 -7
- package/node_modules/@playdrop/boxel-three/dist/src/overlays.js +0 -123
- package/node_modules/@playdrop/boxel-three/dist/src/primitives.d.ts +0 -4
- package/node_modules/@playdrop/boxel-three/dist/src/primitives.js +0 -48
- package/node_modules/@playdrop/boxel-three/dist/src/scene.d.ts +0 -3
- package/node_modules/@playdrop/boxel-three/dist/src/scene.js +0 -168
- package/node_modules/@playdrop/boxel-three/dist/src/skinned-mesh.d.ts +0 -29
- package/node_modules/@playdrop/boxel-three/dist/src/skinned-mesh.js +0 -623
- package/node_modules/@playdrop/boxel-three/dist/src/texture-atlas.d.ts +0 -13
- package/node_modules/@playdrop/boxel-three/dist/src/texture-atlas.js +0 -133
- package/node_modules/@playdrop/boxel-three/dist/src/textures.d.ts +0 -17
- package/node_modules/@playdrop/boxel-three/dist/src/textures.js +0 -216
- package/node_modules/@playdrop/boxel-three/dist/src/types.d.ts +0 -112
- package/node_modules/@playdrop/boxel-three/dist/src/voxels/faces.d.ts +0 -28
- package/node_modules/@playdrop/boxel-three/dist/src/voxels/faces.js +0 -344
- package/node_modules/@playdrop/boxel-three/dist/src/voxels/mesher.d.ts +0 -24
- package/node_modules/@playdrop/boxel-three/dist/src/voxels/mesher.js +0 -113
- package/node_modules/@playdrop/boxel-three/dist/test/export-image.playwright.test.d.ts +0 -1
- package/node_modules/@playdrop/boxel-three/dist/test/export-image.playwright.test.js +0 -137
- package/node_modules/@playdrop/boxel-three/dist/test/fixtures/render-worker.d.ts +0 -20
- package/node_modules/@playdrop/boxel-three/dist/test/fixtures/render-worker.js +0 -85
- package/node_modules/@playdrop/boxel-three/dist/test/glb-skinned.test.d.ts +0 -1
- package/node_modules/@playdrop/boxel-three/dist/test/glb-skinned.test.js +0 -104
- package/node_modules/@playdrop/boxel-three/dist/test/index.test.d.ts +0 -1
- package/node_modules/@playdrop/boxel-three/dist/test/index.test.js +0 -30
- package/node_modules/@playdrop/boxel-three/dist/test/instantiate.test.d.ts +0 -1
- package/node_modules/@playdrop/boxel-three/dist/test/instantiate.test.js +0 -88
- package/node_modules/@playdrop/boxel-three/dist/test/overlays.test.d.ts +0 -1
- package/node_modules/@playdrop/boxel-three/dist/test/overlays.test.js +0 -42
- package/node_modules/@playdrop/boxel-three/dist/test/scene-filter.test.d.ts +0 -1
- package/node_modules/@playdrop/boxel-three/dist/test/scene-filter.test.js +0 -73
- package/node_modules/@playdrop/boxel-three/dist/test/scene-smoke.test.d.ts +0 -1
- package/node_modules/@playdrop/boxel-three/dist/test/scene-smoke.test.js +0 -85
- package/node_modules/@playdrop/boxel-three/dist/test/skinned-mesh.test.d.ts +0 -1
- package/node_modules/@playdrop/boxel-three/dist/test/skinned-mesh.test.js +0 -73
- package/node_modules/@playdrop/boxel-three/dist/test/textured-overlay.test.d.ts +0 -1
- package/node_modules/@playdrop/boxel-three/dist/test/textured-overlay.test.js +0 -136
- package/node_modules/@playdrop/boxel-three/dist/test/voxels.test.d.ts +0 -1
- package/node_modules/@playdrop/boxel-three/dist/test/voxels.test.js +0 -42
- package/node_modules/@playdrop/boxel-three/package.json +0 -28
|
@@ -1,206 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.upscaleEntity = upscaleEntity;
|
|
4
|
-
exports.upscaleEntityGeometry = upscaleEntityGeometry;
|
|
5
|
-
const entity_utils_1 = require("../entity-utils");
|
|
6
|
-
const validation_1 = require("../validation");
|
|
7
|
-
const DEFAULT_SCALE = [1, 1, 1];
|
|
8
|
-
const EPSILON = 1e-6;
|
|
9
|
-
const toNumber = (value) => {
|
|
10
|
-
const result = Number(value);
|
|
11
|
-
return Number.isFinite(result) ? result : 0;
|
|
12
|
-
};
|
|
13
|
-
const round = (value) => Math.round(value * 1e6) / 1e6;
|
|
14
|
-
const scaleVec = (input, factor) => {
|
|
15
|
-
if (!Array.isArray(input)) {
|
|
16
|
-
return undefined;
|
|
17
|
-
}
|
|
18
|
-
return [round(toNumber(input[0]) * factor), round(toNumber(input[1]) * factor), round(toNumber(input[2]) * factor)];
|
|
19
|
-
};
|
|
20
|
-
const divideVec = (input, factor) => {
|
|
21
|
-
const source = Array.isArray(input) ? input : DEFAULT_SCALE;
|
|
22
|
-
return [
|
|
23
|
-
round(toNumber(source[0]) / factor),
|
|
24
|
-
round(toNumber(source[1]) / factor),
|
|
25
|
-
round(toNumber(source[2]) / factor),
|
|
26
|
-
];
|
|
27
|
-
};
|
|
28
|
-
const upscalePatternInPlace = (pattern, factor) => {
|
|
29
|
-
const width = Math.max(1, Math.round(toNumber(pattern.size?.[0])));
|
|
30
|
-
const height = Math.max(1, Math.round(toNumber(pattern.size?.[1])));
|
|
31
|
-
const source = Array.isArray(pattern.data) ? pattern.data.slice() : [];
|
|
32
|
-
const scaledWidth = width * factor;
|
|
33
|
-
const scaledHeight = height * factor;
|
|
34
|
-
const scaled = new Array(scaledWidth * scaledHeight).fill(0);
|
|
35
|
-
for (let y = 0; y < height; y += 1) {
|
|
36
|
-
for (let x = 0; x < width; x += 1) {
|
|
37
|
-
const value = source[y * width + x] ?? 0;
|
|
38
|
-
for (let dy = 0; dy < factor; dy += 1) {
|
|
39
|
-
for (let dx = 0; dx < factor; dx += 1) {
|
|
40
|
-
const targetX = x * factor + dx;
|
|
41
|
-
const targetY = y * factor + dy;
|
|
42
|
-
scaled[targetY * scaledWidth + targetX] = value;
|
|
43
|
-
}
|
|
44
|
-
}
|
|
45
|
-
}
|
|
46
|
-
}
|
|
47
|
-
pattern.size = [scaledWidth, scaledHeight];
|
|
48
|
-
pattern.data = scaled;
|
|
49
|
-
};
|
|
50
|
-
const upscaleVoxelInPlace = (voxel, factor) => {
|
|
51
|
-
const [sx, sy, sz] = voxel.size;
|
|
52
|
-
const nx = Math.max(1, Math.round(sx * factor));
|
|
53
|
-
const ny = Math.max(1, Math.round(sy * factor));
|
|
54
|
-
const nz = Math.max(1, Math.round(sz * factor));
|
|
55
|
-
const source = voxel.voxels ?? [];
|
|
56
|
-
const result = new Array(nx * ny * nz).fill(0);
|
|
57
|
-
const sourceIndex = (x, y, z) => x + sx * (y + sy * z);
|
|
58
|
-
const targetIndex = (x, y, z) => x + nx * (y + ny * z);
|
|
59
|
-
for (let z = 0; z < sz; z += 1) {
|
|
60
|
-
for (let y = 0; y < sy; y += 1) {
|
|
61
|
-
for (let x = 0; x < sx; x += 1) {
|
|
62
|
-
const value = source[sourceIndex(x, y, z)] ?? 0;
|
|
63
|
-
if (value === 0)
|
|
64
|
-
continue;
|
|
65
|
-
for (let dz = 0; dz < factor; dz += 1) {
|
|
66
|
-
for (let dy = 0; dy < factor; dy += 1) {
|
|
67
|
-
for (let dx = 0; dx < factor; dx += 1) {
|
|
68
|
-
const tx = x * factor + dx;
|
|
69
|
-
const ty = y * factor + dy;
|
|
70
|
-
const tz = z * factor + dz;
|
|
71
|
-
result[targetIndex(tx, ty, tz)] = value;
|
|
72
|
-
}
|
|
73
|
-
}
|
|
74
|
-
}
|
|
75
|
-
}
|
|
76
|
-
}
|
|
77
|
-
}
|
|
78
|
-
voxel.size = [nx, ny, nz];
|
|
79
|
-
voxel.voxels = result;
|
|
80
|
-
};
|
|
81
|
-
const upscalePrimitive = (primitive, factor) => {
|
|
82
|
-
switch (primitive.kind) {
|
|
83
|
-
case "plain_box": {
|
|
84
|
-
const box = primitive;
|
|
85
|
-
box.size = box.size.map((value) => round(toNumber(value) * factor));
|
|
86
|
-
break;
|
|
87
|
-
}
|
|
88
|
-
case "textured_box": {
|
|
89
|
-
const box = primitive;
|
|
90
|
-
if (Array.isArray(box.size)) {
|
|
91
|
-
box.size = box.size.map((value) => round(toNumber(value) * factor));
|
|
92
|
-
}
|
|
93
|
-
break;
|
|
94
|
-
}
|
|
95
|
-
case "voxel_box": {
|
|
96
|
-
upscaleVoxelInPlace(primitive, factor);
|
|
97
|
-
break;
|
|
98
|
-
}
|
|
99
|
-
case "combo_box": {
|
|
100
|
-
const combo = primitive;
|
|
101
|
-
if (Array.isArray(combo.size)) {
|
|
102
|
-
combo.size = combo.size.map((value) => round(toNumber(value) * factor));
|
|
103
|
-
}
|
|
104
|
-
combo.slots.forEach((slot) => {
|
|
105
|
-
slot.offset = slot.offset.map((value) => round(toNumber(value) * factor));
|
|
106
|
-
});
|
|
107
|
-
break;
|
|
108
|
-
}
|
|
109
|
-
default:
|
|
110
|
-
break;
|
|
111
|
-
}
|
|
112
|
-
};
|
|
113
|
-
const scalePrimitiveSizes = (entity, factor) => {
|
|
114
|
-
if (Math.abs(Math.round(factor) - factor) > EPSILON) {
|
|
115
|
-
throw new Error("Upscale factor must be an integer for primitive scaling");
|
|
116
|
-
}
|
|
117
|
-
const intFactor = Math.max(1, Math.round(factor));
|
|
118
|
-
if (intFactor === 1) {
|
|
119
|
-
return;
|
|
120
|
-
}
|
|
121
|
-
entity.primitives.forEach((primitive) => {
|
|
122
|
-
upscalePrimitive(primitive, intFactor);
|
|
123
|
-
});
|
|
124
|
-
};
|
|
125
|
-
const upscaleEntityPrimitives = (entity, factor) => {
|
|
126
|
-
if (Math.abs(Math.round(factor) - factor) > EPSILON) {
|
|
127
|
-
throw new Error("Upscale factor must be an integer for primitive scaling");
|
|
128
|
-
}
|
|
129
|
-
const intFactor = Math.max(1, Math.round(factor));
|
|
130
|
-
if (intFactor === 1) {
|
|
131
|
-
return;
|
|
132
|
-
}
|
|
133
|
-
entity.patterns.forEach((pattern) => {
|
|
134
|
-
upscalePatternInPlace(pattern, intFactor);
|
|
135
|
-
});
|
|
136
|
-
scalePrimitiveSizes(entity, factor);
|
|
137
|
-
};
|
|
138
|
-
const scaleNode = (node, factor) => {
|
|
139
|
-
if (node.position) {
|
|
140
|
-
node.position = scaleVec(node.position, factor) ?? node.position;
|
|
141
|
-
}
|
|
142
|
-
if (node.center) {
|
|
143
|
-
node.center = scaleVec(node.center, factor) ?? node.center;
|
|
144
|
-
}
|
|
145
|
-
if (node.size) {
|
|
146
|
-
node.size = scaleVec(node.size, factor) ?? node.size;
|
|
147
|
-
}
|
|
148
|
-
node.children?.forEach((child) => scaleNode(child, factor));
|
|
149
|
-
};
|
|
150
|
-
const scaleAnimationPositions = (entity, factor) => {
|
|
151
|
-
entity.animations?.forEach((animation) => {
|
|
152
|
-
animation.channels?.forEach((channel) => {
|
|
153
|
-
if (channel.property !== "position") {
|
|
154
|
-
return;
|
|
155
|
-
}
|
|
156
|
-
channel.keyframes?.forEach((keyframe) => {
|
|
157
|
-
const value = keyframe.value;
|
|
158
|
-
if (!Array.isArray(value)) {
|
|
159
|
-
return;
|
|
160
|
-
}
|
|
161
|
-
keyframe.value = [
|
|
162
|
-
round(toNumber(value[0]) * factor),
|
|
163
|
-
round(toNumber(value[1]) * factor),
|
|
164
|
-
round(toNumber(value[2]) * factor),
|
|
165
|
-
];
|
|
166
|
-
});
|
|
167
|
-
});
|
|
168
|
-
});
|
|
169
|
-
};
|
|
170
|
-
function upscaleEntityInternal(entity, factor = 2, options) {
|
|
171
|
-
if (factor <= EPSILON) {
|
|
172
|
-
throw new Error("Scale factor must be greater than zero");
|
|
173
|
-
}
|
|
174
|
-
const clone = (0, entity_utils_1.cloneEntity)(entity);
|
|
175
|
-
if (!clone.geometry?.root) {
|
|
176
|
-
return clone;
|
|
177
|
-
}
|
|
178
|
-
if (!clone.geometry.root.scale || !Array.isArray(clone.geometry.root.scale)) {
|
|
179
|
-
clone.geometry.root.scale = [...DEFAULT_SCALE];
|
|
180
|
-
}
|
|
181
|
-
clone.geometry.root.scale = divideVec(clone.geometry.root.scale, factor);
|
|
182
|
-
scaleNode(clone.geometry.root, factor);
|
|
183
|
-
scaleAnimationPositions(clone, factor);
|
|
184
|
-
if (options.scaleTextures) {
|
|
185
|
-
upscaleEntityPrimitives(clone, factor);
|
|
186
|
-
}
|
|
187
|
-
else {
|
|
188
|
-
scalePrimitiveSizes(clone, factor);
|
|
189
|
-
}
|
|
190
|
-
const { issues } = (0, validation_1.validateBoxel)(clone);
|
|
191
|
-
if (issues.length > 0) {
|
|
192
|
-
const summary = issues
|
|
193
|
-
.slice(0, 3)
|
|
194
|
-
.map((issue) => `${issue.path}: ${issue.message}`)
|
|
195
|
-
.join("; ");
|
|
196
|
-
throw new Error(`Upscaled entity failed validation — ${summary}`);
|
|
197
|
-
}
|
|
198
|
-
return clone;
|
|
199
|
-
}
|
|
200
|
-
function upscaleEntity(entity, factor = 2) {
|
|
201
|
-
return upscaleEntityInternal(entity, factor, { scaleTextures: true });
|
|
202
|
-
}
|
|
203
|
-
function upscaleEntityGeometry(entity, factor = 2) {
|
|
204
|
-
return upscaleEntityInternal(entity, factor, { scaleTextures: false });
|
|
205
|
-
}
|
|
206
|
-
//# sourceMappingURL=upscale.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"upscale.js","sourceRoot":"","sources":["../../../src/transforms/upscale.ts"],"names":[],"mappings":";;AA2OA,sCAEC;AAED,sDAEC;AAjPD,kDAA8C;AAY9C,8CAA8C;AAE9C,MAAM,aAAa,GAAS,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC,CAAC;AACtC,MAAM,OAAO,GAAG,IAAI,CAAC;AAErB,MAAM,QAAQ,GAAG,CAAC,KAAc,EAAU,EAAE;IAC1C,MAAM,MAAM,GAAG,MAAM,CAAC,KAAK,CAAC,CAAC;IAC7B,OAAO,MAAM,CAAC,QAAQ,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,CAAC;AAC9C,CAAC,CAAC;AAEF,MAAM,KAAK,GAAG,CAAC,KAAa,EAAU,EAAE,CAAC,IAAI,CAAC,KAAK,CAAC,KAAK,GAAG,GAAG,CAAC,GAAG,GAAG,CAAC;AAEvE,MAAM,QAAQ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AC;IACzC,CAAC;SAAM,CAAC;QACN,mBAAmB,CAAC,KAAK,EAAE,MAAM,CAAC,CAAC;IACrC,CAAC;IAED,MAAM,EAAE,MAAM,EAAE,GAAG,IAAA,0BAAa,EAAC,KAAK,CAAC,CAAC;IACxC,IAAI,MAAM,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;QACtB,MAAM,OAAO,GAAG,MAAM;aACnB,KAAK,CAAC,CAAC,EAAE,CAAC,CAAC;aACX,GAAG,CAAC,CAAC,KAAK,EAAE,EAAE,CAAC,GAAG,KAAK,CAAC,IAAI,KAAK,KAAK,CAAC,OAAO,EAAE,CAAC;aACjD,IAAI,CAAC,IAAI,CAAC,CAAC;QACd,MAAM,IAAI,KAAK,CAAC,uCAAuC,OAAO,EAAE,CAAC,CAAC;IACpE,CAAC;IAED,OAAO,KAAK,CAAC;AACf,CAAC;AAED,SAAgB,aAAa,CAAC,MAAuB,EAAE,MAAM,GAAG,CAAC;IAC/D,OAAO,qBAAqB,CAAC,MAAM,EAAE,MAAM,EAAE,EAAE,aAAa,EAAE,IAAI,EAAE,CAAC,CAAC;AACxE,CAAC;AAED,SAAgB,qBAAqB,CAAC,MAAuB,EAAE,MAAM,GAAG,CAAC;IACvE,OAAO,qBAAqB,CAAC,MAAM,EAAE,MAAM,EAAE,EAAE,aAAa,EAAE,KAAK,EAAE,CAAC,CAAC;AACzE,CAAC"}
|
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
import type { BoxelDefinition, VoxelBox } from "../../types";
|
|
2
|
-
export type SplitAxis = "x" | "y" | "z";
|
|
3
|
-
export interface SplitVoxelBoxResult {
|
|
4
|
-
first: VoxelBox;
|
|
5
|
-
second: VoxelBox;
|
|
6
|
-
}
|
|
7
|
-
export interface SplitVoxelResult {
|
|
8
|
-
firstId: string;
|
|
9
|
-
secondId: string;
|
|
10
|
-
}
|
|
11
|
-
export declare function splitVoxelPrimitive(entity: BoxelDefinition, primitiveId: string, axis: SplitAxis, plane: number): SplitVoxelResult;
|
|
12
|
-
export declare function splitVoxelBoxClone(primitive: VoxelBox, axis: SplitAxis, plane: number): SplitVoxelBoxResult;
|
|
@@ -1,81 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.splitVoxelPrimitive = splitVoxelPrimitive;
|
|
4
|
-
exports.splitVoxelBoxClone = splitVoxelBoxClone;
|
|
5
|
-
const axisIndex = { x: 0, y: 1, z: 2 };
|
|
6
|
-
function splitVoxelBoxInternal(primitive, axis, plane) {
|
|
7
|
-
const axisIdx = axisIndex[axis];
|
|
8
|
-
const extent = Math.round(primitive.size[axisIdx]);
|
|
9
|
-
const splitIndex = Math.round(plane);
|
|
10
|
-
if (splitIndex <= 0 || splitIndex >= extent) {
|
|
11
|
-
throw new Error(`Split plane ${splitIndex} must be within (0, ${extent}) for axis ${axis}`);
|
|
12
|
-
}
|
|
13
|
-
const leftSize = [...primitive.size];
|
|
14
|
-
const rightSize = [...primitive.size];
|
|
15
|
-
leftSize[axisIdx] = splitIndex;
|
|
16
|
-
rightSize[axisIdx] = extent - splitIndex;
|
|
17
|
-
const leftVoxels = new Array(leftSize[0] * leftSize[1] * leftSize[2]).fill(0);
|
|
18
|
-
const rightVoxels = new Array(rightSize[0] * rightSize[1] * rightSize[2]).fill(0);
|
|
19
|
-
const voxels = primitive.voxels ?? [];
|
|
20
|
-
const [sx, sy, sz] = primitive.size;
|
|
21
|
-
const stride = (x, y, z) => x + sx * (y + sy * z);
|
|
22
|
-
for (let z = 0; z < sz; z += 1) {
|
|
23
|
-
for (let y = 0; y < sy; y += 1) {
|
|
24
|
-
for (let x = 0; x < sx; x += 1) {
|
|
25
|
-
const value = voxels[stride(x, y, z)] ?? 0;
|
|
26
|
-
if (value === 0) {
|
|
27
|
-
continue;
|
|
28
|
-
}
|
|
29
|
-
if ((axis === "x" && x < splitIndex) || (axis === "y" && y < splitIndex) || (axis === "z" && z < splitIndex)) {
|
|
30
|
-
const li = x + leftSize[0] * (y + leftSize[1] * z);
|
|
31
|
-
leftVoxels[li] = value;
|
|
32
|
-
}
|
|
33
|
-
else {
|
|
34
|
-
const rx = axis === "x" ? x - splitIndex : x;
|
|
35
|
-
const ry = axis === "y" ? y - splitIndex : y;
|
|
36
|
-
const rz = axis === "z" ? z - splitIndex : z;
|
|
37
|
-
const ri = rx + rightSize[0] * (ry + rightSize[1] * rz);
|
|
38
|
-
rightVoxels[ri] = value;
|
|
39
|
-
}
|
|
40
|
-
}
|
|
41
|
-
}
|
|
42
|
-
}
|
|
43
|
-
const paletteClone = primitive.palette ? primitive.palette.slice() : [];
|
|
44
|
-
const left = {
|
|
45
|
-
id: `${primitive.id}_part_a`,
|
|
46
|
-
kind: "voxel_box",
|
|
47
|
-
size: leftSize,
|
|
48
|
-
voxels: leftVoxels,
|
|
49
|
-
palette: paletteClone,
|
|
50
|
-
};
|
|
51
|
-
const right = {
|
|
52
|
-
id: `${primitive.id}_part_b`,
|
|
53
|
-
kind: "voxel_box",
|
|
54
|
-
size: rightSize,
|
|
55
|
-
voxels: rightVoxels,
|
|
56
|
-
palette: paletteClone,
|
|
57
|
-
};
|
|
58
|
-
return { result: { first: left, second: right }, splitIndex, extent };
|
|
59
|
-
}
|
|
60
|
-
function splitVoxelPrimitive(entity, primitiveId, axis, plane) {
|
|
61
|
-
const primitiveIndex = entity.primitives.findIndex((primitive) => primitive.id === primitiveId);
|
|
62
|
-
if (primitiveIndex === -1) {
|
|
63
|
-
throw new Error(`Primitive ${primitiveId} not found`);
|
|
64
|
-
}
|
|
65
|
-
const primitive = entity.primitives[primitiveIndex];
|
|
66
|
-
if (primitive.kind !== "voxel_box") {
|
|
67
|
-
throw new Error(`Primitive ${primitiveId} is not a voxel box`);
|
|
68
|
-
}
|
|
69
|
-
const { result } = splitVoxelBoxInternal(primitive, axis, plane);
|
|
70
|
-
entity.primitives.splice(primitiveIndex, 1, result.first, result.second);
|
|
71
|
-
return { firstId: result.first.id, secondId: result.second.id };
|
|
72
|
-
}
|
|
73
|
-
function splitVoxelBoxClone(primitive, axis, plane) {
|
|
74
|
-
const copy = JSON.parse(JSON.stringify(primitive));
|
|
75
|
-
const { result } = splitVoxelBoxInternal(copy, axis, plane);
|
|
76
|
-
return {
|
|
77
|
-
first: { ...result.first, id: result.first.id },
|
|
78
|
-
second: { ...result.second, id: result.second.id },
|
|
79
|
-
};
|
|
80
|
-
}
|
|
81
|
-
//# sourceMappingURL=slice.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"slice.js","sourceRoot":"","sources":["../../../../src/transforms/voxels/slice.ts"],"names":[],"mappings":";;AAmFA,kDAoBC;AAED,gDAOC;AA5GD,MAAM,SAAS,GAA8B,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC;AAOlE,SAAS,qBAAqB,CAC5B,SAAmB,EACnB,IAAe,EACf,KAAa;IAEb,MAAM,OAAO,GAAG,SAAS,CAAC,IAAI,CAAC,CAAC;IAChC,MAAM,MAAM,GAAG,IAAI,CAAC,KAAK,CAAC,SAAS,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC,CAAC;IACnD,MAAM,UAAU,GAAG,IAAI,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC;IACrC,IAAI,UAAU,IAAI,CAAC,IAAI,UAAU,IAAI,MAAM,EAAE,CAAC;QAC5C,MAAM,IAAI,KAAK,CAAC,eAAe,UAAU,uBAAuB,MAAM,cAAc,IAAI,EAAE,CAAC,CAAC;IAC9F,CAAC;IAED,MAAM,QAAQ,GAA6B,CAAC,GAAG,SAAS,CAAC,IAAI,CAA6B,CAAC;IAC3F,MAAM,SAAS,GAA6B,CAAC,GAAG,SAAS,CAAC,IAAI,CAA6B,CAAC;IAC5F,QAAQ,CAAC,OAAO,CAAC,GAAG,UAAU,CAAC;IAC/B,SAAS,CAAC,OAAO,CAAC,GAAG,MAAM,GAAG,UAAU,CAAC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AC,SAAS,CAAC,CAAa,CAAC;IAC/D,MAAM,EAAE,MAAM,EAAE,GAAG,qBAAqB,CAAC,IAAI,EAAE,IAAI,EAAE,KAAK,CAAC,CAAC;IAC5D,OAAO;QACL,KAAK,EAAE,EAAE,GAAG,MAAM,CAAC,KAAK,EAAE,EAAE,EAAE,MAAM,CAAC,KAAK,CAAC,EAAE,EAAE;QAC/C,MAAM,EAAE,EAAE,GAAG,MAAM,CAAC,MAAM,EAAE,EAAE,EAAE,MAAM,CAAC,MAAM,CAAC,EAAE,EAAE;KACnD,CAAC;AACJ,CAAC"}
|
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
import type { Material, Pattern, TexturedBox, Texture, VoxelBox } from "../../types";
|
|
2
|
-
export type OverlayVoxelMode = "outer_wrap" | "overlay_overwrite" | "base_inset";
|
|
3
|
-
export interface TexturedToVoxelOptions {
|
|
4
|
-
base: TexturedBox;
|
|
5
|
-
overlay?: TexturedBox | undefined;
|
|
6
|
-
textureLookup: Map<string, Texture>;
|
|
7
|
-
patternLookup: Map<string, Pattern>;
|
|
8
|
-
materialLookup: Map<string, Material>;
|
|
9
|
-
mode?: OverlayVoxelMode | undefined;
|
|
10
|
-
targetId?: string | undefined;
|
|
11
|
-
}
|
|
12
|
-
export declare function convertTexturedBoxesToVoxel(options: TexturedToVoxelOptions): VoxelBox;
|
|
@@ -1,318 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.convertTexturedBoxesToVoxel = convertTexturedBoxesToVoxel;
|
|
4
|
-
const textures_1 = require("../../textures");
|
|
5
|
-
const FACE_ORDER = ["north", "south", "east", "west", "top", "bottom"];
|
|
6
|
-
const EPSILON = 1e-6;
|
|
7
|
-
const toNumber = (value) => {
|
|
8
|
-
const num = Number(value);
|
|
9
|
-
return Number.isFinite(num) ? num : 0;
|
|
10
|
-
};
|
|
11
|
-
const round = (value) => Math.round(value * 1e6) / 1e6;
|
|
12
|
-
const FACE_DIMENSIONS = {
|
|
13
|
-
north: { widthAxis: "x", heightAxis: "y" },
|
|
14
|
-
south: { widthAxis: "x", heightAxis: "y" },
|
|
15
|
-
east: { widthAxis: "z", heightAxis: "y" },
|
|
16
|
-
west: { widthAxis: "z", heightAxis: "y" },
|
|
17
|
-
top: { widthAxis: "x", heightAxis: "z" },
|
|
18
|
-
bottom: { widthAxis: "x", heightAxis: "z" },
|
|
19
|
-
};
|
|
20
|
-
const mapFaceCoordinate = (face, u, v, dims, offsets) => {
|
|
21
|
-
switch (face) {
|
|
22
|
-
case "north":
|
|
23
|
-
return [offsets.x + u, dims.y - 1 - offsets.y - v, dims.z - 1];
|
|
24
|
-
case "south":
|
|
25
|
-
return [dims.x - 1 - offsets.x - u, dims.y - 1 - offsets.y - v, 0];
|
|
26
|
-
case "east":
|
|
27
|
-
return [dims.x - 1, dims.y - 1 - offsets.y - v, dims.z - 1 - offsets.z - u];
|
|
28
|
-
case "west":
|
|
29
|
-
return [0, dims.y - 1 - offsets.y - v, offsets.z + u];
|
|
30
|
-
case "top":
|
|
31
|
-
return [offsets.x + u, dims.y - 1, offsets.z + v];
|
|
32
|
-
case "bottom":
|
|
33
|
-
return [offsets.x + u, 0, dims.z - 1 - offsets.z - v];
|
|
34
|
-
default:
|
|
35
|
-
return null;
|
|
36
|
-
}
|
|
37
|
-
};
|
|
38
|
-
const isTransparent = (material) => {
|
|
39
|
-
if (!material) {
|
|
40
|
-
return true;
|
|
41
|
-
}
|
|
42
|
-
const opacity = material.opacity === undefined ? 1 : material.opacity;
|
|
43
|
-
return Number(opacity) <= EPSILON;
|
|
44
|
-
};
|
|
45
|
-
const gatherPaletteIndex = (materialId, paletteIndex, palette) => {
|
|
46
|
-
let index = paletteIndex.get(materialId);
|
|
47
|
-
if (index === undefined) {
|
|
48
|
-
index = palette.length;
|
|
49
|
-
paletteIndex.set(materialId, index);
|
|
50
|
-
palette.push(materialId);
|
|
51
|
-
}
|
|
52
|
-
return index;
|
|
53
|
-
};
|
|
54
|
-
const createVoxelVolume = (dims) => {
|
|
55
|
-
const total = dims.x * dims.y * dims.z;
|
|
56
|
-
return {
|
|
57
|
-
dims,
|
|
58
|
-
voxels: new Array(total).fill(0),
|
|
59
|
-
palette: [],
|
|
60
|
-
paletteIndex: new Map(),
|
|
61
|
-
};
|
|
62
|
-
};
|
|
63
|
-
const paintPrimitiveIntoVolume = (primitive, textureLookup, patternLookup, materialLookup, patternDims, offsets, volume, translation = { x: 0, y: 0, z: 0 }, sampleOffset = { u: 0, v: 0 }) => {
|
|
64
|
-
FACE_ORDER.forEach((face) => {
|
|
65
|
-
const textureId = (0, textures_1.resolveFaceTextureId)(primitive, face);
|
|
66
|
-
if (!textureId) {
|
|
67
|
-
return;
|
|
68
|
-
}
|
|
69
|
-
const texture = textureLookup.get(textureId);
|
|
70
|
-
if (!texture) {
|
|
71
|
-
return;
|
|
72
|
-
}
|
|
73
|
-
const pattern = patternLookup.get(texture.pattern);
|
|
74
|
-
if (!pattern || !Array.isArray(pattern.data)) {
|
|
75
|
-
return;
|
|
76
|
-
}
|
|
77
|
-
const patternWidth = Math.max(1, Math.round(toNumber(pattern.size?.[0])));
|
|
78
|
-
const patternHeight = Math.max(1, Math.round(toNumber(pattern.size?.[1])));
|
|
79
|
-
const widthAxis = FACE_DIMENSIONS[face].widthAxis;
|
|
80
|
-
const heightAxis = FACE_DIMENSIONS[face].heightAxis;
|
|
81
|
-
const width = Math.max(1, Math.round(patternDims[widthAxis] - offsets[widthAxis] * 2));
|
|
82
|
-
const height = Math.max(1, Math.round(patternDims[heightAxis] - offsets[heightAxis] * 2));
|
|
83
|
-
if (patternWidth < width + sampleOffset.u || patternHeight < height + sampleOffset.v) {
|
|
84
|
-
throw new Error(`Pattern ${pattern.id} for face ${face} has size ${patternWidth}x${patternHeight} but expected at least ${width + sampleOffset.u}x${height + sampleOffset.v}`);
|
|
85
|
-
}
|
|
86
|
-
for (let v = 0; v < height; v += 1) {
|
|
87
|
-
for (let u = 0; u < width; u += 1) {
|
|
88
|
-
const sampleU = u + sampleOffset.u;
|
|
89
|
-
const sampleV = v + sampleOffset.v;
|
|
90
|
-
const patternIndex = sampleV * patternWidth + sampleU;
|
|
91
|
-
const paletteRef = pattern.data[patternIndex] ?? 0;
|
|
92
|
-
const materialId = texture.materials[paletteRef];
|
|
93
|
-
if (!materialId) {
|
|
94
|
-
continue;
|
|
95
|
-
}
|
|
96
|
-
const material = materialLookup.get(materialId);
|
|
97
|
-
if (isTransparent(material)) {
|
|
98
|
-
continue;
|
|
99
|
-
}
|
|
100
|
-
const coords = mapFaceCoordinate(face, u, v, patternDims, offsets);
|
|
101
|
-
if (!coords) {
|
|
102
|
-
continue;
|
|
103
|
-
}
|
|
104
|
-
const x = coords[0] + translation.x;
|
|
105
|
-
const y = coords[1] + translation.y;
|
|
106
|
-
const z = coords[2] + translation.z;
|
|
107
|
-
if (x < 0 || x >= volume.dims.x || y < 0 || y >= volume.dims.y || z < 0 || z >= volume.dims.z) {
|
|
108
|
-
continue;
|
|
109
|
-
}
|
|
110
|
-
const voxelIndex = x + volume.dims.x * (y + volume.dims.y * z);
|
|
111
|
-
if (volume.voxels[voxelIndex] !== 0) {
|
|
112
|
-
continue;
|
|
113
|
-
}
|
|
114
|
-
const index = gatherPaletteIndex(materialId, volume.paletteIndex, volume.palette);
|
|
115
|
-
volume.voxels[voxelIndex] = index + 1;
|
|
116
|
-
}
|
|
117
|
-
}
|
|
118
|
-
});
|
|
119
|
-
};
|
|
120
|
-
const computeTargetSize = (source, expansion) => {
|
|
121
|
-
const base = [
|
|
122
|
-
round(toNumber(source?.[0])),
|
|
123
|
-
round(toNumber(source?.[1])),
|
|
124
|
-
round(toNumber(source?.[2])),
|
|
125
|
-
];
|
|
126
|
-
return [
|
|
127
|
-
Math.max(1, Math.round(base[0] + expansion)),
|
|
128
|
-
Math.max(1, Math.round(base[1] + expansion)),
|
|
129
|
-
Math.max(1, Math.round(base[2] + expansion)),
|
|
130
|
-
];
|
|
131
|
-
};
|
|
132
|
-
const axisDimsFromSize = (size) => ({
|
|
133
|
-
x: Math.max(1, Math.round(toNumber(size?.[0]))),
|
|
134
|
-
y: Math.max(1, Math.round(toNumber(size?.[1]))),
|
|
135
|
-
z: Math.max(1, Math.round(toNumber(size?.[2]))),
|
|
136
|
-
});
|
|
137
|
-
const clampOffsetsToDims = (offsets, dims) => ({
|
|
138
|
-
x: Math.min(Math.max(offsets.x, 0), dims.x),
|
|
139
|
-
y: Math.min(Math.max(offsets.y, 0), dims.y),
|
|
140
|
-
z: Math.min(Math.max(offsets.z, 0), dims.z),
|
|
141
|
-
});
|
|
142
|
-
const neighborOffsets = [
|
|
143
|
-
[1, 0, 0],
|
|
144
|
-
[-1, 0, 0],
|
|
145
|
-
[0, 1, 0],
|
|
146
|
-
[0, -1, 0],
|
|
147
|
-
[0, 0, 1],
|
|
148
|
-
[0, 0, -1],
|
|
149
|
-
];
|
|
150
|
-
const indexFromCoords = (x, y, z, dims) => x + dims.x * (y + dims.y * z);
|
|
151
|
-
const fillInteriorVoxels = (volume) => {
|
|
152
|
-
const { dims, voxels } = volume;
|
|
153
|
-
const total = voxels.length;
|
|
154
|
-
if (total === 0) {
|
|
155
|
-
return;
|
|
156
|
-
}
|
|
157
|
-
const exterior = new Uint8Array(total);
|
|
158
|
-
const queue = [];
|
|
159
|
-
const pushExterior = (x, y, z) => {
|
|
160
|
-
if (x < 0 || y < 0 || z < 0 || x >= dims.x || y >= dims.y || z >= dims.z) {
|
|
161
|
-
return;
|
|
162
|
-
}
|
|
163
|
-
const idx = indexFromCoords(x, y, z, dims);
|
|
164
|
-
if (exterior[idx] !== 0 || voxels[idx] !== 0) {
|
|
165
|
-
return;
|
|
166
|
-
}
|
|
167
|
-
exterior[idx] = 1;
|
|
168
|
-
queue.push(idx);
|
|
169
|
-
};
|
|
170
|
-
for (let x = 0; x < dims.x; x += 1) {
|
|
171
|
-
for (let y = 0; y < dims.y; y += 1) {
|
|
172
|
-
pushExterior(x, y, 0);
|
|
173
|
-
pushExterior(x, y, dims.z - 1);
|
|
174
|
-
}
|
|
175
|
-
}
|
|
176
|
-
for (let x = 0; x < dims.x; x += 1) {
|
|
177
|
-
for (let z = 0; z < dims.z; z += 1) {
|
|
178
|
-
pushExterior(x, 0, z);
|
|
179
|
-
pushExterior(x, dims.y - 1, z);
|
|
180
|
-
}
|
|
181
|
-
}
|
|
182
|
-
for (let y = 0; y < dims.y; y += 1) {
|
|
183
|
-
for (let z = 0; z < dims.z; z += 1) {
|
|
184
|
-
pushExterior(0, y, z);
|
|
185
|
-
pushExterior(dims.x - 1, y, z);
|
|
186
|
-
}
|
|
187
|
-
}
|
|
188
|
-
while (queue.length > 0) {
|
|
189
|
-
const idx = queue.shift();
|
|
190
|
-
const x = idx % dims.x;
|
|
191
|
-
const yz = (idx - x) / dims.x;
|
|
192
|
-
const y = yz % dims.y;
|
|
193
|
-
const z = Math.floor(yz / dims.y);
|
|
194
|
-
for (const [dx, dy, dz] of neighborOffsets) {
|
|
195
|
-
pushExterior(x + dx, y + dy, z + dz);
|
|
196
|
-
}
|
|
197
|
-
}
|
|
198
|
-
const fillQueue = [];
|
|
199
|
-
for (let idx = 0; idx < total; idx += 1) {
|
|
200
|
-
if (voxels[idx] !== 0) {
|
|
201
|
-
fillQueue.push(idx);
|
|
202
|
-
}
|
|
203
|
-
}
|
|
204
|
-
while (fillQueue.length > 0) {
|
|
205
|
-
const idx = fillQueue.shift();
|
|
206
|
-
const value = voxels[idx];
|
|
207
|
-
const x = idx % dims.x;
|
|
208
|
-
const yz = (idx - x) / dims.x;
|
|
209
|
-
const y = yz % dims.y;
|
|
210
|
-
const z = Math.floor(yz / dims.y);
|
|
211
|
-
for (const [dx, dy, dz] of neighborOffsets) {
|
|
212
|
-
const nx = x + dx;
|
|
213
|
-
const ny = y + dy;
|
|
214
|
-
const nz = z + dz;
|
|
215
|
-
if (nx < 0 || ny < 0 || nz < 0 || nx >= dims.x || ny >= dims.y || nz >= dims.z) {
|
|
216
|
-
continue;
|
|
217
|
-
}
|
|
218
|
-
const nIdx = indexFromCoords(nx, ny, nz, dims);
|
|
219
|
-
if (exterior[nIdx] !== 0) {
|
|
220
|
-
continue;
|
|
221
|
-
}
|
|
222
|
-
if (voxels[nIdx] !== 0) {
|
|
223
|
-
continue;
|
|
224
|
-
}
|
|
225
|
-
voxels[nIdx] = value;
|
|
226
|
-
fillQueue.push(nIdx);
|
|
227
|
-
}
|
|
228
|
-
}
|
|
229
|
-
};
|
|
230
|
-
const convertSinglePrimitive = (primitive, textureLookup, patternLookup, materialLookup, expansion) => {
|
|
231
|
-
const targetSize = computeTargetSize(primitive.size, expansion);
|
|
232
|
-
const dims = axisDimsFromSize(targetSize);
|
|
233
|
-
const volume = createVoxelVolume(dims);
|
|
234
|
-
const offsets = expansion > 0 ? { x: expansion / 2, y: expansion / 2, z: expansion / 2 } : { x: 0, y: 0, z: 0 };
|
|
235
|
-
paintPrimitiveIntoVolume(primitive, textureLookup, patternLookup, materialLookup, dims, offsets, volume);
|
|
236
|
-
fillInteriorVoxels(volume);
|
|
237
|
-
return volume;
|
|
238
|
-
};
|
|
239
|
-
function convertTexturedBoxesToVoxel(options) {
|
|
240
|
-
const { base, overlay, textureLookup, patternLookup, materialLookup } = options;
|
|
241
|
-
const targetId = options.targetId ?? base.id;
|
|
242
|
-
const mode = options.mode ?? "outer_wrap";
|
|
243
|
-
if (!overlay) {
|
|
244
|
-
const volume = convertSinglePrimitive(base, textureLookup, patternLookup, materialLookup, 0);
|
|
245
|
-
fillInteriorVoxels(volume);
|
|
246
|
-
return {
|
|
247
|
-
id: targetId,
|
|
248
|
-
kind: "voxel_box",
|
|
249
|
-
size: [volume.dims.x, volume.dims.y, volume.dims.z],
|
|
250
|
-
voxels: volume.voxels,
|
|
251
|
-
palette: volume.palette,
|
|
252
|
-
};
|
|
253
|
-
}
|
|
254
|
-
switch (mode) {
|
|
255
|
-
case "overlay_overwrite": {
|
|
256
|
-
const dims = axisDimsFromSize(base.size);
|
|
257
|
-
const volume = createVoxelVolume(dims);
|
|
258
|
-
paintPrimitiveIntoVolume(base, textureLookup, patternLookup, materialLookup, dims, { x: 0, y: 0, z: 0 }, volume);
|
|
259
|
-
paintPrimitiveIntoVolume(overlay, textureLookup, patternLookup, materialLookup, dims, { x: 0, y: 0, z: 0 }, volume);
|
|
260
|
-
fillInteriorVoxels(volume);
|
|
261
|
-
return {
|
|
262
|
-
id: targetId,
|
|
263
|
-
kind: "voxel_box",
|
|
264
|
-
size: [volume.dims.x, volume.dims.y, volume.dims.z],
|
|
265
|
-
voxels: volume.voxels,
|
|
266
|
-
palette: volume.palette,
|
|
267
|
-
};
|
|
268
|
-
}
|
|
269
|
-
case "base_inset": {
|
|
270
|
-
const overlayDims = axisDimsFromSize(overlay.size);
|
|
271
|
-
const volume = createVoxelVolume(overlayDims);
|
|
272
|
-
paintPrimitiveIntoVolume(overlay, textureLookup, patternLookup, materialLookup, overlayDims, { x: 0, y: 0, z: 0 }, volume);
|
|
273
|
-
const insetDims = {
|
|
274
|
-
x: Math.max(1, overlayDims.x - 2),
|
|
275
|
-
y: Math.max(1, overlayDims.y - 2),
|
|
276
|
-
z: Math.max(1, overlayDims.z - 2),
|
|
277
|
-
};
|
|
278
|
-
const insetOffsets = { x: 1, y: 1, z: 1 };
|
|
279
|
-
paintPrimitiveIntoVolume(base, textureLookup, patternLookup, materialLookup, insetDims, { x: 0, y: 0, z: 0 }, volume, clampOffsetsToDims(insetOffsets, overlayDims), { u: 1, v: 1 });
|
|
280
|
-
fillInteriorVoxels(volume);
|
|
281
|
-
return {
|
|
282
|
-
id: targetId,
|
|
283
|
-
kind: "voxel_box",
|
|
284
|
-
size: [volume.dims.x, volume.dims.y, volume.dims.z],
|
|
285
|
-
voxels: volume.voxels,
|
|
286
|
-
palette: volume.palette,
|
|
287
|
-
};
|
|
288
|
-
}
|
|
289
|
-
case "outer_wrap":
|
|
290
|
-
default: {
|
|
291
|
-
const innerSize = [
|
|
292
|
-
round(toNumber(base.size?.[0])),
|
|
293
|
-
round(toNumber(base.size?.[1])),
|
|
294
|
-
round(toNumber(base.size?.[2])),
|
|
295
|
-
];
|
|
296
|
-
const outerSize = computeTargetSize(overlay.size, 2);
|
|
297
|
-
const innerDims = axisDimsFromSize(innerSize);
|
|
298
|
-
const outerDims = axisDimsFromSize(outerSize);
|
|
299
|
-
const volume = createVoxelVolume(outerDims);
|
|
300
|
-
paintPrimitiveIntoVolume(overlay, textureLookup, patternLookup, materialLookup, outerDims, { x: 1, y: 1, z: 1 }, volume);
|
|
301
|
-
const innerTranslation = {
|
|
302
|
-
x: Math.floor((outerDims.x - innerDims.x) / 2),
|
|
303
|
-
y: Math.floor((outerDims.y - innerDims.y) / 2),
|
|
304
|
-
z: Math.floor((outerDims.z - innerDims.z) / 2),
|
|
305
|
-
};
|
|
306
|
-
paintPrimitiveIntoVolume(base, textureLookup, patternLookup, materialLookup, innerDims, { x: 0, y: 0, z: 0 }, volume, clampOffsetsToDims(innerTranslation, outerDims));
|
|
307
|
-
fillInteriorVoxels(volume);
|
|
308
|
-
return {
|
|
309
|
-
id: targetId,
|
|
310
|
-
kind: "voxel_box",
|
|
311
|
-
size: [volume.dims.x, volume.dims.y, volume.dims.z],
|
|
312
|
-
voxels: volume.voxels,
|
|
313
|
-
palette: volume.palette,
|
|
314
|
-
};
|
|
315
|
-
}
|
|
316
|
-
}
|
|
317
|
-
}
|
|
318
|
-
//# sourceMappingURL=textured-to-voxel.js.map
|