@call-me-sensei/toonlab 0.3.0 → 0.4.19
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/README.md +549 -184
- package/agents/README.md +59 -0
- package/agents/references/anime-art-direction.md +24 -0
- package/agents/references/asset-sourcing-policy.md +23 -0
- package/agents/references/custom-gap-report.md +16 -0
- package/agents/references/geology-playbook.md +118 -0
- package/agents/references/mcp-asset-discovery.md +104 -0
- package/agents/references/runtime-entry-points.md +174 -0
- package/agents/references/style-bundles.md +71 -0
- package/agents/skills/claude/asset-sourcing/SKILL.md +275 -0
- package/agents/skills/claude/environment/SKILL.md +59 -0
- package/agents/skills/claude/game-dev/SKILL.md +100 -0
- package/agents/skills/claude/karst-cliff-construction/SKILL.md +258 -0
- package/agents/skills/claude/outdoor-world/SKILL.md +492 -0
- package/agents/skills/claude/outdoor-world/references/coastal-landform-formation.md +100 -0
- package/agents/skills/claude/post-processing/SKILL.md +44 -0
- package/agents/skills/claude/rock-ground-shaders/SKILL.md +118 -0
- package/agents/skills/claude/rockgen/SKILL.md +30 -0
- package/agents/skills/claude/scene-style-application/SKILL.md +74 -0
- package/agents/skills/claude/style-presets/SKILL.md +101 -0
- package/agents/skills/claude/toon-shading/SKILL.md +44 -0
- package/agents/skills/claude/vegetation-sky/SKILL.md +167 -0
- package/agents/skills/claude/visual-verification/SKILL.md +136 -0
- package/agents/skills/claude/water/SKILL.md +105 -0
- package/agents/skills/codex/asset-sourcing/SKILL.md +275 -0
- package/agents/skills/codex/environment/SKILL.md +59 -0
- package/agents/skills/codex/game-dev/SKILL.md +100 -0
- package/agents/skills/codex/karst-cliff-construction/SKILL.md +258 -0
- package/agents/skills/codex/outdoor-world/SKILL.md +492 -0
- package/agents/skills/codex/outdoor-world/references/coastal-landform-formation.md +100 -0
- package/agents/skills/codex/post-processing/SKILL.md +44 -0
- package/agents/skills/codex/rock-ground-shaders/SKILL.md +118 -0
- package/agents/skills/codex/rockgen/SKILL.md +30 -0
- package/agents/skills/codex/scene-style-application/SKILL.md +74 -0
- package/agents/skills/codex/style-presets/SKILL.md +101 -0
- package/agents/skills/codex/toon-shading/SKILL.md +44 -0
- package/agents/skills/codex/vegetation-sky/SKILL.md +167 -0
- package/agents/skills/codex/visual-verification/SKILL.md +136 -0
- package/agents/skills/codex/water/SKILL.md +105 -0
- package/cli/toonlab.mjs +52 -0
- package/compose.yaml +20 -0
- package/database/apply-sql.mjs +141 -0
- package/database/client.mjs +39 -0
- package/database/creation-tags.mjs +23 -0
- package/database/env.mjs +16 -0
- package/database/generation-service.mjs +314 -0
- package/database/migrations/0001_local_workspace.sql +120 -0
- package/database/migrations/0002_file_ownership.sql +11 -0
- package/database/migrations/0003_remove_autosaves_from_library.sql +7 -0
- package/database/migrations/0004_catalog_asset_packs.sql +39 -0
- package/database/migrations/0005_creation_tag_discovery.sql +1 -0
- package/database/migrations/0006_normalize_creation_tags.sql +28 -0
- package/database/providers.mjs +465 -0
- package/database/repository.mjs +625 -0
- package/database/seeds/catalog/0001_empty_official_catalog.sql +4 -0
- package/database/seeds/catalog/0002_2026-08.sql +19454 -0
- package/mcp/lab-management.mjs +629 -0
- package/mcp/public-catalog.mjs +168 -0
- package/mcp/server.mjs +1026 -63
- package/mcp/vite-plugin.mjs +443 -26
- package/mcp/workspace.mjs +26 -1
- package/package.json +312 -45
- package/scripts/generate-catalog-seed.mjs +297 -0
- package/scripts/setup-local.mjs +128 -0
- package/src/agents/index.js +7 -0
- package/src/agents/sceneStyleOperations.js +169 -0
- package/src/asset-policy/catalogLicenses.js +44 -0
- package/src/asset-policy/index.js +315 -0
- package/src/assetlib/assetRef.js +1 -1
- package/src/assetlib/galleryMaterialFamily.js +165 -0
- package/src/assetlib/index.js +6 -2
- package/src/assetlib/plateau.js +188 -0
- package/src/assetlib/plateauLandmarks.js +144 -0
- package/src/assetlib/plateauViewer.js +348 -0
- package/src/assetlib/sources.js +16 -2
- package/src/catalog/manifest.js +11 -1
- package/src/catalog/officialCatalog.js +4 -0
- package/src/catalog/officialCatalogAssetRuntime.js +313 -0
- package/src/catalog/officialCatalogLod.js +150 -0
- package/src/catalog/officialCatalogPlacement.js +228 -0
- package/src/catalog/officialCatalogProvider.js +334 -0
- package/src/character/animationRetarget.js +1082 -0
- package/src/character/characterRuntime.js +376 -0
- package/src/character/groundStabilizer.js +137 -0
- package/src/character/index.js +8 -0
- package/src/character/locomotionActions.js +74 -0
- package/src/character/locomotionStateMachine.js +241 -0
- package/src/character/mannequinAsset.js +15 -0
- package/src/character/mannequinAssetUrl.browser.js +4 -0
- package/src/character/mannequinAssetUrl.node.js +3 -0
- package/src/character/modelLoader.js +92 -12
- package/src/character/walkableCharacterRuntime.js +284 -0
- package/src/character/waterInteractionController.js +217 -0
- package/src/cloud/ambientSkyBaker.js +248 -0
- package/src/cloud/cloudLighting.js +1114 -0
- package/src/cloud/cloudParams.js +819 -0
- package/src/cloud/cloudReprojection.js +563 -0
- package/src/cloud/cloudStyle.js +780 -0
- package/src/cloud/cloudStyleSnapshots.js +387 -0
- package/src/cloud/cloudVolume.js +1903 -0
- package/src/cloud/heroCloudRecipe.js +404 -0
- package/src/cloud/index.js +42 -0
- package/src/cloud/noise/baseShapeVolume.js +331 -0
- package/src/cloud/noise/cirrusMap.js +131 -0
- package/src/cloud/noise/curlNoise.js +289 -0
- package/src/cloud/noise/erosionVolume.js +188 -0
- package/src/cloud/noise/noiseVolume.js +202 -0
- package/src/cloud/noise/periodicNoise3.js +295 -0
- package/src/cloud/noise/weatherMap.js +470 -0
- package/src/cloud/paramSchema.js +458 -0
- package/src/collisionMetadata.js +320 -0
- package/src/core/systemStylePolicy.js +32 -0
- package/src/environment/dayCurves.js +146 -0
- package/src/environment/environmentGroundFieldPass.js +354 -0
- package/src/environment/environmentMaterialAdapter.js +114 -6
- package/src/environment/environmentPresets.js +396 -90
- package/src/environment/environmentRigs.js +17 -2
- package/src/environment/environmentSettings.js +37 -1
- package/src/environment/environmentShaderMaterials.js +37 -6
- package/src/environment/environmentState.js +133 -0
- package/src/environment/environmentSunShadowPass.js +357 -6
- package/src/environment/environmentTextureResolver.js +7 -0
- package/src/environment/index.js +51 -0
- package/src/environment/manufacturedMaterialContract.js +837 -0
- package/src/environment/manufacturedReflectionProvider.js +114 -0
- package/src/environment/scanAssetStylize.js +4 -4
- package/src/environment/surfaceMaterialModes.js +71 -0
- package/src/environment/toonLabEnvironmentMaterials.js +353 -0
- package/src/environment/toonLabMaterialPassCoupling.js +347 -0
- package/src/environment/toonLabNormalIntegration.js +171 -0
- package/src/environment/toonLabRockMaterialResolver.js +592 -0
- package/src/environment/toonLabSourceDefaultLit.js +444 -0
- package/src/environment/toonLabSourceLibrary.js +762 -0
- package/src/environment/toonLabSourceMaterials.js +3718 -0
- package/src/environment/toonLabSourceSubsurfaceLighting.js +415 -0
- package/src/environment/toonLabSourceTemporal.js +717 -0
- package/src/environment/toonLabSurfaceLighting.js +364 -0
- package/src/environment/toonLabTextureReadiness.js +105 -0
- package/src/environment/toonLabTreeMaterials.js +450 -0
- package/src/environment/transparentMaterialProfile.js +87 -0
- package/src/environment/urbanPropMaterial.js +2874 -0
- package/src/ground-shader/groundPrintLayer.js +375 -0
- package/src/ground-shader/groundShaderMaterial.js +851 -0
- package/src/ground-shader/groundShaderSettings.js +468 -0
- package/src/ground-shader/index.js +3 -0
- package/src/index.js +52 -22
- package/src/lighting/callMeSenseiLightingContract.js +163 -0
- package/src/lighting/index.js +14 -7
- package/src/lighting/lightingCapabilities.js +2 -2
- package/src/lighting/lightingPresets.js +6 -3
- package/src/lighting/lightingStyle.js +41 -6
- package/src/lighting/lightingSystem.js +140 -1
- package/src/lighting/{unrealExport.js → toonLabExport.js} +40 -41
- package/src/post/postProcessing.js +71 -12
- package/src/react/index.js +66 -0
- package/src/renderer/index.js +9 -0
- package/src/renderer/rendererConfiguration.js +250 -0
- package/src/rock-shader/index.js +3 -0
- package/src/rock-shader/rockMaterial.js +1843 -0
- package/src/rock-shader/rockShaderRuntime.js +494 -0
- package/src/rock-shader/rockShaderSettings.js +869 -0
- package/src/rockgen/export/glbExport.js +104 -14
- package/src/rockgen/index.js +4 -3
- package/src/rockgen/lod/index.js +6 -0
- package/src/rockgen/lod/rockLodMetrics.js +168 -0
- package/src/rockgen/lod/rockLodPlanner.js +372 -0
- package/src/rockgen/lod/rockLodPolicy.js +235 -0
- package/src/rockgen/lod/rockLodRuntime.js +124 -0
- package/src/rockgen/lod/rockLodSimplifier.js +173 -0
- package/src/rockgen/lod/rockLodValidation.js +113 -0
- package/src/rockgen/mesh/meshAttributes.js +17 -0
- package/src/rockgen/mesh/meshDocument.js +6 -0
- package/src/rockgen/rockDocument.js +352 -9
- package/src/rockgen/rockgenPresets.js +114 -13
- package/src/rockgen/rockgenSettings.js +62 -11
- package/src/runtime/index.js +14 -0
- package/src/runtime/sceneCollisionRuntime.js +317 -0
- package/src/runtime/sceneSurfaceRuntime.js +451 -0
- package/src/runtime/sceneUpdateScheduler.js +203 -0
- package/src/shaders-tsl/anime.js +9 -2
- package/src/shaders-tsl/chunks/environment-ground-field.js +174 -0
- package/src/shaders-tsl/chunks/environment-state.js +79 -0
- package/src/shaders-tsl/chunks/environment-sun-shadow.js +99 -32
- package/src/shaders-tsl/chunks/normalized-hue.js +41 -0
- package/src/shaders-tsl/chunks/pass-depth-color.js +4 -2
- package/src/shaders-tsl/chunks/scene-depth-color-pass.js +273 -0
- package/src/shaders-tsl/chunks/vegetation-style.js +116 -8
- package/src/shaders-tsl/chunks/water-color.js +19 -5
- package/src/shaders-tsl/chunks/water-shore-state.js +8 -1
- package/src/shaders-tsl/chunks/world-noise.js +30 -0
- package/src/shaders-tsl/environment.js +123 -17
- package/src/shaders-tsl/flower.js +51 -8
- package/src/shaders-tsl/grass.js +194 -29
- package/src/shaders-tsl/post-composite.js +83 -2
- package/src/shaders-tsl/tree-leaf.js +107 -16
- package/src/shaders-tsl/water-breaker.js +18 -4
- package/src/shaders-tsl/water.js +43 -3
- package/src/shaders-tsl/woody-surface.js +59 -7
- package/src/sky/atmosphereDome.js +193 -0
- package/src/sky/atmosphereParams.js +396 -0
- package/src/sky/atmosphereScattering.js +593 -0
- package/src/sky/atmosphereSky.js +371 -0
- package/src/sky/cloudShadow.js +355 -0
- package/src/sky/godRays.js +257 -0
- package/src/sky/index.js +55 -1
- package/src/sky/nightSky.js +1190 -0
- package/src/sky/renderLayers.js +120 -0
- package/src/sky/skyColor.js +582 -0
- package/src/sky/skyDayCycle.js +244 -0
- package/src/sky/skyParams.js +661 -0
- package/src/sky/skyPresets.js +772 -0
- package/src/sky/skyQualityTiers.js +383 -0
- package/src/sky/skyShaderSettings.js +699 -0
- package/src/sky/skyStyleSnapshots.js +211 -0
- package/src/sky/skySystem.js +1438 -0
- package/src/sky/skyTimeKeyframes.js +361 -0
- package/src/sky/stylizedSky.js +405 -116
- package/src/sky/sunDriver.js +499 -0
- package/src/sky/timeOfDay.js +335 -0
- package/src/styles/animeGameProfile.js +44 -0
- package/src/styles/index.js +134 -0
- package/src/styles/manufacturedStyleLabeling.js +204 -0
- package/src/styles/sceneLayerDocuments.js +185 -0
- package/src/styles/sceneLookComposition.js +156 -0
- package/src/styles/sceneQualityApplication.js +152 -0
- package/src/styles/sceneQualityProfiles.js +268 -0
- package/src/styles/sceneStyleAudit.js +512 -0
- package/src/styles/sceneStyleRuntime.js +876 -0
- package/src/styles/styleAdapters.js +166 -0
- package/src/styles/styleApplication.js +369 -0
- package/src/styles/styleBundle.js +444 -91
- package/src/styles/styleBundleProvider.js +83 -0
- package/src/styles/styleDomains.js +21 -0
- package/src/styles/styleInspector.js +262 -0
- package/src/styles/styleMaterialContract.js +375 -0
- package/src/styles/styleMetadata.js +73 -0
- package/src/styles/styleTargetDiscovery.js +162 -0
- package/src/styles/styleTargetLabels.js +206 -0
- package/src/styles/styleTargetMaterialCoverage.js +137 -0
- package/src/styles/styleTransaction.js +272 -0
- package/src/texgen/textureGenerators.js +21 -5
- package/src/toon/toonSettings.js +4 -0
- package/src/vegetation/branchTree.js +302 -0
- package/src/vegetation/callMeSenseiGrass.js +183 -0
- package/src/vegetation/compiledTree.js +506 -0
- package/src/vegetation/contactShadowField.js +107 -0
- package/src/vegetation/flowerSpecies.js +10 -2
- package/src/vegetation/grass.js +13 -0
- package/src/vegetation/grassClump.js +1179 -0
- package/src/vegetation/importedVegetationMaterial.js +183 -0
- package/src/vegetation/index.js +15 -1
- package/src/vegetation/legacyTreePresets.js +120 -0
- package/src/vegetation/scatter.js +322 -3
- package/src/vegetation/stylizedBush.js +14 -0
- package/src/vegetation/stylizedFlower.js +31 -0
- package/src/vegetation/stylizedFlowers.js +59 -7
- package/src/vegetation/stylizedForest.js +455 -147
- package/src/vegetation/stylizedGrass.js +188 -24
- package/src/vegetation/stylizedTree.js +378 -46
- package/src/vegetation/stylizedTreeFoliage.js +889 -38
- package/src/vegetation/stylizedUnderstory.js +230 -0
- package/src/vegetation/treeExport.js +262 -47
- package/src/vegetation/treeSurfaceTextures.js +337 -0
- package/src/vegetation/vegetationShaders.js +617 -28
- package/src/version.js +3 -0
- package/src/water/water.js +2 -0
- package/src/water/waterBreakerSystem.js +2 -0
- package/src/water/waterCurrentField.js +1 -0
- package/src/water/waterMaterial.js +3 -0
- package/src/water/waterRain.js +2 -0
- package/src/water/waterScenePasses.js +170 -7
- package/src/water/waterSettings.js +235 -43
- package/src/water/waterShoreMaterial.js +16 -2
- package/src/water/waterShoreStateField.js +1 -1
- package/src/water/waterSplashSystem.js +2 -0
- package/src/water/waterStageSettings.js +60 -0
- package/src/water/waterSurface.js +144 -4
- package/src/water/waterUnderwaterAtmosphere.js +288 -0
- package/src/water/waterVegetation.js +20 -4
- package/src/worldCollision.js +64 -9
- package/types/agents/index.d.ts +1 -0
- package/types/agents/sceneStyleOperations.d.ts +484 -0
- package/types/asset-policy/catalogLicenses.d.ts +5 -0
- package/types/asset-policy/index.d.ts +18 -0
- package/types/assetlib/ambientcg.d.ts +81 -0
- package/types/assetlib/assetRef.d.ts +26 -0
- package/types/assetlib/galleryMaterialFamily.d.ts +13 -0
- package/types/assetlib/importedEntry.d.ts +18 -0
- package/types/assetlib/index.d.ts +16 -0
- package/types/assetlib/kaykit.d.ts +112 -0
- package/types/assetlib/kaykitStaticIndex.d.ts +38 -0
- package/types/assetlib/loadImported.d.ts +54 -0
- package/types/assetlib/opensource3d.d.ts +55 -0
- package/types/assetlib/plateau.d.ts +67 -0
- package/types/assetlib/plateauLandmarks.d.ts +238 -0
- package/types/assetlib/plateauViewer.d.ts +3 -0
- package/types/assetlib/polyhaven.d.ts +90 -0
- package/types/assetlib/polypizza.d.ts +10 -0
- package/types/assetlib/smithsonian.d.ts +9 -0
- package/types/assetlib/sources.d.ts +22 -0
- package/types/assetlib/zip.d.ts +8 -0
- package/types/catalog/manifest.d.ts +26 -0
- package/types/catalog/officialCatalog.d.ts +4 -0
- package/types/catalog/officialCatalogAssetRuntime.d.ts +2 -0
- package/types/catalog/officialCatalogLod.d.ts +5 -0
- package/types/catalog/officialCatalogPlacement.d.ts +49 -0
- package/types/catalog/officialCatalogProvider.d.ts +7 -0
- package/types/character/animationRetarget.d.ts +20 -0
- package/types/character/characterRig.d.ts +28 -0
- package/types/character/characterRuntime.d.ts +4 -0
- package/types/character/freestyleSwimClip.d.ts +5 -0
- package/types/character/groundStabilizer.d.ts +55 -0
- package/types/character/index.d.ts +10 -0
- package/types/character/locomotionActions.d.ts +4 -0
- package/types/character/locomotionStateMachine.d.ts +62 -0
- package/types/character/mannequinAsset.d.ts +12 -0
- package/types/character/mannequinAssetUrl.node.d.ts +1 -0
- package/types/character/modelLoader.d.ts +7 -0
- package/types/character/walkableCharacterRuntime.d.ts +343 -0
- package/types/character/waterInteractionController.d.ts +114 -0
- package/types/cloud/ambientSkyBaker.d.ts +18 -0
- package/types/cloud/cloudLighting.d.ts +38 -0
- package/types/cloud/cloudParams.d.ts +18 -0
- package/types/cloud/cloudReprojection.d.ts +15 -0
- package/types/cloud/cloudStyle.d.ts +1380 -0
- package/types/cloud/cloudStyleSnapshots.d.ts +10 -0
- package/types/cloud/cloudVolume.d.ts +43 -0
- package/types/cloud/heroCloudRecipe.d.ts +167 -0
- package/types/cloud/index.d.ts +12 -0
- package/types/cloud/noise/baseShapeVolume.d.ts +86 -0
- package/types/cloud/noise/cirrusMap.d.ts +24 -0
- package/types/cloud/noise/curlNoise.d.ts +106 -0
- package/types/cloud/noise/erosionVolume.d.ts +58 -0
- package/types/cloud/noise/noiseVolume.d.ts +63 -0
- package/types/cloud/noise/periodicNoise3.d.ts +75 -0
- package/types/cloud/noise/weatherMap.d.ts +227 -0
- package/types/cloud/paramSchema.d.ts +142 -0
- package/types/collisionMetadata.d.ts +11 -0
- package/types/core/generation.d.ts +95 -0
- package/types/core/materialRoles.d.ts +102 -0
- package/types/core/presetDocuments.d.ts +25 -0
- package/types/core/systemStylePolicy.d.ts +4 -0
- package/types/environment/dayCurves.d.ts +47 -0
- package/types/environment/environmentAmbientProbe.d.ts +2 -0
- package/types/environment/environmentGroundFieldPass.d.ts +2 -0
- package/types/environment/environmentMaterialAdapter.d.ts +42 -0
- package/types/environment/environmentMaterialClassifier.d.ts +26 -0
- package/types/environment/environmentPlanarReflection.d.ts +3 -0
- package/types/environment/environmentPresets.d.ts +171 -0
- package/types/environment/environmentRigs.d.ts +13 -0
- package/types/environment/environmentSettings.d.ts +161 -0
- package/types/environment/environmentShaderMaterials.d.ts +14 -0
- package/types/environment/environmentState.d.ts +6 -0
- package/types/environment/environmentSunShadowPass.d.ts +2 -0
- package/types/environment/environmentTextureResolver.d.ts +30 -0
- package/types/environment/environmentTimeOfDay.d.ts +25 -0
- package/types/environment/environmentVertexAo.d.ts +18 -0
- package/types/environment/index.d.ts +27 -0
- package/types/environment/manufacturedMaterialContract.d.ts +129 -0
- package/types/environment/manufacturedReflectionProvider.d.ts +3 -0
- package/types/environment/scanAssetStylize.d.ts +43 -0
- package/types/environment/surfaceMaterialModes.d.ts +14 -0
- package/types/environment/toonLabEnvironmentMaterials.d.ts +139 -0
- package/types/environment/toonLabMaterialPassCoupling.d.ts +7 -0
- package/types/environment/toonLabNormalIntegration.d.ts +29 -0
- package/types/environment/toonLabRockMaterialResolver.d.ts +270 -0
- package/types/environment/toonLabSourceDefaultLit.d.ts +136 -0
- package/types/environment/toonLabSourceLibrary.d.ts +19 -0
- package/types/environment/toonLabSourceMaterials.d.ts +14 -0
- package/types/environment/toonLabSourceSubsurfaceLighting.d.ts +85 -0
- package/types/environment/toonLabSourceTemporal.d.ts +20 -0
- package/types/environment/toonLabSurfaceLighting.d.ts +136 -0
- package/types/environment/toonLabTextureReadiness.d.ts +8 -0
- package/types/environment/toonLabTreeMaterials.d.ts +7 -0
- package/types/environment/transparentMaterialProfile.d.ts +76 -0
- package/types/environment/urbanPropMaterial.d.ts +25 -0
- package/types/ground-shader/groundPrintLayer.d.ts +4 -0
- package/types/ground-shader/groundShaderMaterial.d.ts +11 -0
- package/types/ground-shader/groundShaderSettings.d.ts +90 -0
- package/types/ground-shader/index.d.ts +3 -0
- package/types/index.d.ts +1502 -0
- package/types/lighting/callMeSenseiLightingContract.d.ts +14 -0
- package/types/lighting/colorIntensity.d.ts +44 -0
- package/types/lighting/index.d.ts +12 -0
- package/types/lighting/lightDescriptors.d.ts +803 -0
- package/types/lighting/lightingCapabilities.d.ts +85 -0
- package/types/lighting/lightingDocuments.d.ts +140 -0
- package/types/lighting/lightingFixtures.d.ts +171 -0
- package/types/lighting/lightingGenerator.d.ts +403 -0
- package/types/lighting/lightingPresets.d.ts +264 -0
- package/types/lighting/lightingRuntime.d.ts +401 -0
- package/types/lighting/lightingStyle.d.ts +156 -0
- package/types/lighting/lightingSystem.d.ts +433 -0
- package/types/lighting/toonLabExport.d.ts +46 -0
- package/types/lighting/utils.d.ts +18 -0
- package/types/loaders/index.d.ts +1 -0
- package/types/post/index.d.ts +2 -0
- package/types/post/postGenerator.d.ts +282 -0
- package/types/post/postProcessing.d.ts +16 -0
- package/types/react/index.d.ts +1765 -0
- package/types/renderer/index.d.ts +1 -0
- package/types/renderer/rendererConfiguration.d.ts +8 -0
- package/types/rock-shader/index.d.ts +3 -0
- package/types/rock-shader/rockMaterial.d.ts +18 -0
- package/types/rock-shader/rockShaderRuntime.d.ts +8 -0
- package/types/rock-shader/rockShaderSettings.d.ts +170 -0
- package/types/rockgen/export/glbExport.d.ts +58 -0
- package/types/rockgen/heightfield/heightfieldErosion.d.ts +10 -0
- package/types/rockgen/heightfield/heightfieldPatch.d.ts +15 -0
- package/types/rockgen/heightfield/stylizedErosionSim.d.ts +41 -0
- package/types/rockgen/index.d.ts +11 -0
- package/types/rockgen/lod/index.d.ts +6 -0
- package/types/rockgen/lod/rockLodMetrics.d.ts +62 -0
- package/types/rockgen/lod/rockLodPlanner.d.ts +86 -0
- package/types/rockgen/lod/rockLodPolicy.d.ts +76 -0
- package/types/rockgen/lod/rockLodRuntime.d.ts +95 -0
- package/types/rockgen/lod/rockLodSimplifier.d.ts +15 -0
- package/types/rockgen/lod/rockLodValidation.d.ts +16 -0
- package/types/rockgen/mesh/meshAttributes.d.ts +32 -0
- package/types/rockgen/mesh/meshDocument.d.ts +40 -0
- package/types/rockgen/mesh/surfaceNets.d.ts +42 -0
- package/types/rockgen/noise/cellularNoise3.d.ts +24 -0
- package/types/rockgen/noise/prng.d.ts +16 -0
- package/types/rockgen/noise/simplexNoise3.d.ts +2 -0
- package/types/rockgen/noise/valueNoise3.d.ts +12 -0
- package/types/rockgen/rockDocument.d.ts +215 -0
- package/types/rockgen/rockHelpers.d.ts +2 -0
- package/types/rockgen/rockgenPresets.d.ts +10 -0
- package/types/rockgen/rockgenSettings.d.ts +531 -0
- package/types/rockgen/sdf/fieldCompiler.d.ts +20 -0
- package/types/rockgen/sdf/sculptEdits.d.ts +30 -0
- package/types/rockgen/sdf/sdfModifiers.d.ts +19 -0
- package/types/rockgen/sdf/sdfOps.d.ts +8 -0
- package/types/rockgen/sdf/sdfPrimitives.d.ts +22 -0
- package/types/runtime/index.d.ts +3 -0
- package/types/runtime/sceneCollisionRuntime.d.ts +94 -0
- package/types/runtime/sceneSurfaceRuntime.d.ts +90 -0
- package/types/runtime/sceneUpdateScheduler.d.ts +28 -0
- package/types/shaders-tsl/anime.d.ts +9 -0
- package/types/shaders-tsl/chunks/character-color.d.ts +6 -0
- package/types/shaders-tsl/chunks/character-highlights.d.ts +12 -0
- package/types/shaders-tsl/chunks/character-lighting.d.ts +20 -0
- package/types/shaders-tsl/chunks/character-material-maps.d.ts +18 -0
- package/types/shaders-tsl/chunks/character-roles.d.ts +21 -0
- package/types/shaders-tsl/chunks/character-scene-lights.d.ts +48 -0
- package/types/shaders-tsl/chunks/character-shadow-color.d.ts +5 -0
- package/types/shaders-tsl/chunks/character-skinning.d.ts +23 -0
- package/types/shaders-tsl/chunks/environment-color.d.ts +9 -0
- package/types/shaders-tsl/chunks/environment-debug.d.ts +24 -0
- package/types/shaders-tsl/chunks/environment-ground-field.d.ts +40 -0
- package/types/shaders-tsl/chunks/environment-lighting.d.ts +22 -0
- package/types/shaders-tsl/chunks/environment-state.d.ts +42 -0
- package/types/shaders-tsl/chunks/environment-sun-shadow.d.ts +19 -0
- package/types/shaders-tsl/chunks/foliage-fog.d.ts +21 -0
- package/types/shaders-tsl/chunks/normalized-hue.d.ts +1 -0
- package/types/shaders-tsl/chunks/pass-depth-color.d.ts +20 -0
- package/types/shaders-tsl/chunks/projected-water-caustics.d.ts +24 -0
- package/types/shaders-tsl/chunks/scene-depth-color-pass.d.ts +39 -0
- package/types/shaders-tsl/chunks/stylized-cloud-shadow.d.ts +9 -0
- package/types/shaders-tsl/chunks/vegetation-style.d.ts +60 -0
- package/types/shaders-tsl/chunks/water-color.d.ts +15 -0
- package/types/shaders-tsl/chunks/water-common.d.ts +9 -0
- package/types/shaders-tsl/chunks/water-foam.d.ts +8 -0
- package/types/shaders-tsl/chunks/water-lighting.d.ts +9 -0
- package/types/shaders-tsl/chunks/water-ripple.d.ts +8 -0
- package/types/shaders-tsl/chunks/water-shore-state.d.ts +7 -0
- package/types/shaders-tsl/chunks/water-waves.d.ts +18 -0
- package/types/shaders-tsl/chunks/world-noise.d.ts +4 -0
- package/types/shaders-tsl/environment-ao-overlay.d.ts +5 -0
- package/types/shaders-tsl/environment.d.ts +34 -0
- package/types/shaders-tsl/flower.d.ts +6 -0
- package/types/shaders-tsl/grass.d.ts +4 -0
- package/types/shaders-tsl/post-composite.d.ts +25 -0
- package/types/shaders-tsl/sky.d.ts +4 -0
- package/types/shaders-tsl/tree-leaf.d.ts +2 -0
- package/types/shaders-tsl/water-breaker.d.ts +15 -0
- package/types/shaders-tsl/water-kelp.d.ts +5 -0
- package/types/shaders-tsl/water-rain.d.ts +10 -0
- package/types/shaders-tsl/water-shore-state-simulation.d.ts +12 -0
- package/types/shaders-tsl/water-simulation.d.ts +5 -0
- package/types/shaders-tsl/water-splash.d.ts +12 -0
- package/types/shaders-tsl/water.d.ts +22 -0
- package/types/shaders-tsl/woody-surface.d.ts +3 -0
- package/types/sky/atmosphereDome.d.ts +2 -0
- package/types/sky/atmosphereParams.d.ts +185 -0
- package/types/sky/atmosphereScattering.d.ts +11 -0
- package/types/sky/atmosphereSky.d.ts +2 -0
- package/types/sky/cloudShadow.d.ts +68 -0
- package/types/sky/godRays.d.ts +5 -0
- package/types/sky/index.d.ts +18 -0
- package/types/sky/nightSky.d.ts +22 -0
- package/types/sky/renderLayers.d.ts +59 -0
- package/types/sky/sceneOverrideLayers.d.ts +10 -0
- package/types/sky/skyColor.d.ts +704 -0
- package/types/sky/skyDayCycle.d.ts +86 -0
- package/types/sky/skyParams.d.ts +3407 -0
- package/types/sky/skyPresets.d.ts +160 -0
- package/types/sky/skyQuality.d.ts +21 -0
- package/types/sky/skyQualityTiers.d.ts +223 -0
- package/types/sky/skyShaderSettings.d.ts +152 -0
- package/types/sky/skyStyleSnapshots.d.ts +11 -0
- package/types/sky/skySystem.d.ts +3 -0
- package/types/sky/skyTimeKeyframes.d.ts +230 -0
- package/types/sky/stylizedSky.d.ts +341 -0
- package/types/sky/sunDriver.d.ts +15 -0
- package/types/sky/timeOfDay.d.ts +145 -0
- package/types/styles/animeGameProfile.d.ts +27 -0
- package/types/styles/index.d.ts +17 -0
- package/types/styles/manufacturedStyleLabeling.d.ts +119 -0
- package/types/styles/sceneLayerDocuments.d.ts +145 -0
- package/types/styles/sceneLookComposition.d.ts +53 -0
- package/types/styles/sceneQualityApplication.d.ts +34 -0
- package/types/styles/sceneQualityProfiles.d.ts +13 -0
- package/types/styles/sceneStyleAudit.d.ts +80 -0
- package/types/styles/sceneStyleRuntime.d.ts +1782 -0
- package/types/styles/styleAdapters.d.ts +14 -0
- package/types/styles/styleApplication.d.ts +47 -0
- package/types/styles/styleBundle.d.ts +19 -0
- package/types/styles/styleBundleProvider.d.ts +44 -0
- package/types/styles/styleDomains.d.ts +18 -0
- package/types/styles/styleInspector.d.ts +59 -0
- package/types/styles/styleMaterialContract.d.ts +46 -0
- package/types/styles/styleMetadata.d.ts +11 -0
- package/types/styles/styleTargetDiscovery.d.ts +48 -0
- package/types/styles/styleTargetLabels.d.ts +32 -0
- package/types/styles/styleTargetMaterialCoverage.d.ts +20 -0
- package/types/styles/styleTransaction.d.ts +10 -0
- package/types/styles/styleTypes.d.ts +66 -0
- package/types/texgen/evaluateTexture.d.ts +40 -0
- package/types/texgen/index.d.ts +7 -0
- package/types/texgen/noise2.d.ts +46 -0
- package/types/texgen/textureAi.d.ts +6 -0
- package/types/texgen/textureGenerators.d.ts +261 -0
- package/types/texgen/texturePresets.d.ts +45 -0
- package/types/texgen/textureSettings.d.ts +121 -0
- package/types/texgen/textureThree.d.ts +13 -0
- package/types/toon/characterRenderPasses.d.ts +3 -0
- package/types/toon/index.d.ts +3 -0
- package/types/toon/settings/alphaSettings.d.ts +125 -0
- package/types/toon/settings/averageShadowSettings.d.ts +39 -0
- package/types/toon/settings/baseTextureSettings.d.ts +39 -0
- package/types/toon/settings/celShadeSettings.d.ts +37 -0
- package/types/toon/settings/contactShadowSettings.d.ts +30 -0
- package/types/toon/settings/eyeHighlightSettings.d.ts +55 -0
- package/types/toon/settings/faceLightingSettings.d.ts +32 -0
- package/types/toon/settings/furSettings.d.ts +23 -0
- package/types/toon/settings/glitterSettings.d.ts +43 -0
- package/types/toon/settings/hairHighlightSettings.d.ts +89 -0
- package/types/toon/settings/indirectLightSettings.d.ts +43 -0
- package/types/toon/settings/localLightSettings.d.ts +46 -0
- package/types/toon/settings/materialMapSettings.d.ts +86 -0
- package/types/toon/settings/outlineSettings.d.ts +125 -0
- package/types/toon/settings/perspectiveRemovalSettings.d.ts +14 -0
- package/types/toon/settings/rimLightSettings.d.ts +79 -0
- package/types/toon/settings/sceneShadowSettings.d.ts +32 -0
- package/types/toon/settings/selfShadowSettings.d.ts +44 -0
- package/types/toon/settings/shadowColorSettings.d.ts +77 -0
- package/types/toon/settings/skinToneSettings.d.ts +30 -0
- package/types/toon/settings/specularSettings.d.ts +96 -0
- package/types/toon/settings/stickerSettings.d.ts +40 -0
- package/types/toon/toonMaterialAdapter.d.ts +883 -0
- package/types/toon/toonSettings.d.ts +1182 -0
- package/types/vegetation/branchTree.d.ts +10 -0
- package/types/vegetation/callMeSenseiGrass.d.ts +8 -0
- package/types/vegetation/compiledTree.d.ts +75 -0
- package/types/vegetation/contactShadowField.d.ts +26 -0
- package/types/vegetation/flowerSpecies.d.ts +107 -0
- package/types/vegetation/grass.d.ts +4 -0
- package/types/vegetation/grassClump.d.ts +7 -0
- package/types/vegetation/grassPalettes.d.ts +29 -0
- package/types/vegetation/importedVegetationMaterial.d.ts +13 -0
- package/types/vegetation/index.d.ts +216 -0
- package/types/vegetation/legacyTreePresets.d.ts +22 -0
- package/types/vegetation/scatter.d.ts +12 -0
- package/types/vegetation/stylizedBush.d.ts +2 -0
- package/types/vegetation/stylizedFlower.d.ts +2 -0
- package/types/vegetation/stylizedFlowers.d.ts +8 -0
- package/types/vegetation/stylizedForest.d.ts +3 -0
- package/types/vegetation/stylizedGrass.d.ts +21 -0
- package/types/vegetation/stylizedTree.d.ts +19 -0
- package/types/vegetation/stylizedTreeFoliage.d.ts +18 -0
- package/types/vegetation/stylizedUnderstory.d.ts +50 -0
- package/types/vegetation/treeExport.d.ts +6 -0
- package/types/vegetation/treeSurfaceTextures.d.ts +72 -0
- package/types/vegetation/vegetationShaders.d.ts +74 -0
- package/types/version.d.ts +1 -0
- package/types/water/index.d.ts +1 -0
- package/types/water/sceneOverrideLayers.d.ts +16 -0
- package/types/water/water.d.ts +17 -0
- package/types/water/waterBreakerSystem.d.ts +46 -0
- package/types/water/waterCurrentField.d.ts +115 -0
- package/types/water/waterInteraction.d.ts +21 -0
- package/types/water/waterMaterial.d.ts +60 -0
- package/types/water/waterNearshorePhase.d.ts +5 -0
- package/types/water/waterRain.d.ts +17 -0
- package/types/water/waterRippleSimulation.d.ts +52 -0
- package/types/water/waterScenePasses.d.ts +70 -0
- package/types/water/waterSettings.d.ts +648 -0
- package/types/water/waterShoreMaterial.d.ts +3 -0
- package/types/water/waterShoreStateField.d.ts +2 -0
- package/types/water/waterSplashSystem.d.ts +2 -0
- package/types/water/waterStageSettings.d.ts +9 -0
- package/types/water/waterSurface.d.ts +2 -0
- package/types/water/waterUnderwaterAtmosphere.d.ts +103 -0
- package/types/water/waterVegetation.d.ts +16 -0
- package/types/worldCollision.d.ts +22 -0
- package/AGENTS.md +0 -254
- package/ATTRIBUTION.md +0 -78
- package/docs/characters.md +0 -144
- package/docs/debug-panel.md +0 -126
- package/docs/docs.css +0 -589
- package/docs/environment.md +0 -186
- package/docs/getting-started.md +0 -180
- package/docs/index.html +0 -14
- package/docs/lab-architecture.md +0 -100
- package/docs/lighting.md +0 -825
- package/docs/main.jsx +0 -739
- package/docs/mcp.md +0 -97
- package/docs/post-processing.md +0 -98
- package/docs/settings-reference.md +0 -1878
- package/docs/shader-constants.md +0 -77
- package/docs/sky.md +0 -182
- package/docs/style-labs.md +0 -309
- package/docs/texture-lab.md +0 -135
- package/docs/toon-shading.md +0 -183
- package/docs/tsl-conventions.md +0 -167
- package/docs/vegetation-sky.md +0 -275
- package/docs/water.md +0 -430
- package/docs/weather.md +0 -200
- package/docs/world-scale.md +0 -111
- package/mcp/style-lab-tools.mjs +0 -371
- package/src/ambientfx/INTEGRATION.md +0 -164
- package/src/ambientfx/ambientFxPresets.js +0 -83
- package/src/ambientfx/ambientFxSettings.js +0 -368
- package/src/ambientfx/emitters.js +0 -169
- package/src/ambientfx/index.js +0 -5
- package/src/ambientfx/particleBackbone.js +0 -493
- package/src/ambientfx/stylizedAmbientFx.js +0 -450
- package/src/biome/biomeGenerator.js +0 -385
- package/src/biome/biomeRuntime.js +0 -299
- package/src/biome/index.js +0 -2
- package/src/buildinggen/buildingAsset.js +0 -44
- package/src/buildinggen/buildingGrammar.js +0 -311
- package/src/buildinggen/buildingMesh.js +0 -451
- package/src/buildinggen/buildingPresets.js +0 -46
- package/src/buildinggen/buildingRecipe.js +0 -100
- package/src/buildinggen/buildingSettings.js +0 -238
- package/src/buildinggen/index.js +0 -6
- package/src/camera/cameraDirector.js +0 -157
- package/src/camera/cameraGenerator.js +0 -367
- package/src/camera/cameraRig.js +0 -570
- package/src/camera/cameraSettings.js +0 -236
- package/src/camera/index.js +0 -7
- package/src/catalog/builtinEntries.js +0 -245
- package/src/catalog/catalog.js +0 -210
- package/src/catalog/index.js +0 -3
- package/src/core/shaderBackend.js +0 -24
- package/src/debrisgen/debrisFields.js +0 -544
- package/src/debrisgen/debrisGenerator.js +0 -1929
- package/src/debrisgen/debrisPalettes.js +0 -71
- package/src/debrisgen/debrisPhysics.js +0 -198
- package/src/debrisgen/debrisPresets.js +0 -162
- package/src/debrisgen/debrisSettings.js +0 -333
- package/src/debrisgen/debrisTextures.js +0 -380
- package/src/debrisgen/index.js +0 -5
- package/src/debug/fieldValues.js +0 -95
- package/src/debug/index.js +0 -7
- package/src/debug/settingsPanel.js +0 -170
- package/src/fauna/INTEGRATION.md +0 -174
- package/src/fauna/boids.js +0 -861
- package/src/fauna/faunaBodies.js +0 -492
- package/src/fauna/faunaPresets.js +0 -52
- package/src/fauna/faunaSettings.js +0 -525
- package/src/fauna/index.js +0 -5
- package/src/fauna/stylizedFauna.js +0 -395
- package/src/game-feel/gameFeelGenerator.js +0 -402
- package/src/game-feel/gameFeelRuntime.js +0 -549
- package/src/game-feel/index.js +0 -2
- package/src/motion/index.js +0 -5
- package/src/motion/motionClip.js +0 -441
- package/src/motion/motionController.js +0 -628
- package/src/motion/motionDocuments.js +0 -225
- package/src/motion/motionGraph.js +0 -307
- package/src/motion/motionSettings.js +0 -222
- package/src/pathgen/index.js +0 -7
- package/src/pathgen/pathBridge.js +0 -232
- package/src/pathgen/pathPresets.js +0 -35
- package/src/pathgen/pathRibbon.js +0 -410
- package/src/pathgen/pathRouter.js +0 -380
- package/src/pathgen/pathSettings.js +0 -335
- package/src/pathgen/pathTextures.js +0 -123
- package/src/pathgen/stylizedPaths.js +0 -453
- package/src/propgen/generatorsWave1.js +0 -379
- package/src/propgen/generatorsWave2.js +0 -462
- package/src/propgen/index.js +0 -5
- package/src/propgen/propAsset.js +0 -323
- package/src/propgen/propParts.js +0 -170
- package/src/propgen/propPlacement.js +0 -459
- package/src/propgen/propPresets.js +0 -82
- package/src/propgen/propSettings.js +0 -395
- package/src/soundscape/index.js +0 -4
- package/src/soundscape/soundscapeGenerator.js +0 -179
- package/src/soundscape/soundscapeRuntime.js +0 -806
- package/src/soundscape/soundscapeSettings.js +0 -292
- package/src/stylizedTerrain.js +0 -631
- package/src/stylizedWorld.js +0 -903
- package/src/vegetation/treeRecipe.js +0 -647
- package/src/vfxgen/INTEGRATION.md +0 -145
- package/src/vfxgen/core/burstBackbone.js +0 -380
- package/src/vfxgen/core/projectileCore.js +0 -92
- package/src/vfxgen/core/spriteShapes.js +0 -98
- package/src/vfxgen/core/trailRibbon.js +0 -272
- package/src/vfxgen/core/vfxRandom.js +0 -29
- package/src/vfxgen/effects/emitHelpers.js +0 -37
- package/src/vfxgen/effects/magicEffects.js +0 -162
- package/src/vfxgen/effects/movementEffects.js +0 -87
- package/src/vfxgen/effects/weaponEffects.js +0 -118
- package/src/vfxgen/index.js +0 -18
- package/src/vfxgen/moves/moveController.js +0 -146
- package/src/vfxgen/moves/moveLibrary.js +0 -335
- package/src/vfxgen/vfxPresets.js +0 -98
- package/src/vfxgen/vfxSettings.js +0 -384
- package/src/vfxgen/vfxSystem.js +0 -449
- package/src/vfxgen/weapons/stylizedWeapons.js +0 -137
- package/src/villagegen/index.js +0 -4
- package/src/villagegen/stylizedVillage.js +0 -490
- package/src/villagegen/villageArchetypes.js +0 -160
- package/src/villagegen/villageNames.js +0 -40
- package/src/villagegen/villageSites.js +0 -105
- package/src/weather/index.js +0 -6
- package/src/weather/weatherPrecipitation.js +0 -221
- package/src/weather/weatherPresets.js +0 -258
- package/src/weather/weatherSettings.js +0 -269
- package/src/weather/weatherSystem.js +0 -871
- package/src/worldMinimap.js +0 -214
- package/src/worldPresets.js +0 -125
|
@@ -1,380 +0,0 @@
|
|
|
1
|
-
// Procedural detail textures for debris materials. Each debris type gets
|
|
2
|
-
// a tileable 256x256 DataTexture (no canvas/DOM — works headless and in
|
|
3
|
-
// workers) built from the same hash-based value noise rockgen uses, so
|
|
4
|
-
// results are deterministic per seed. Textures are near-white detail maps
|
|
5
|
-
// that MULTIPLY the baked vertex colors: the palette still comes from the
|
|
6
|
-
// generator's color slots; the map adds material read (wood grain, bone
|
|
7
|
-
// porosity, mineral speckle, brushed metal, leaf veins, ash powder) that
|
|
8
|
-
// survives the environment toon conversion (the adapter resolves
|
|
9
|
-
// `material.map` into its stylized albedo).
|
|
10
|
-
|
|
11
|
-
import * as THREE from 'three';
|
|
12
|
-
|
|
13
|
-
import { hashCombine } from '../rockgen/noise/prng.js';
|
|
14
|
-
import { fbm3, valueNoise3 } from '../rockgen/noise/valueNoise3.js';
|
|
15
|
-
|
|
16
|
-
const SIZE = 256;
|
|
17
|
-
const CACHE_LIMIT = 24;
|
|
18
|
-
const cache = new Map();
|
|
19
|
-
|
|
20
|
-
const clamp01 = (value) => Math.min(Math.max(value, 0), 1);
|
|
21
|
-
|
|
22
|
-
/**
|
|
23
|
-
* Fills a texture from `shade(u, v) -> [r, g, b]` with u/v in [0, 1).
|
|
24
|
-
* Sampling wraps because every noise call below uses u/v scaled by whole
|
|
25
|
-
* numbers, keeping the tile seamless.
|
|
26
|
-
*/
|
|
27
|
-
function bakeTexture(shade) {
|
|
28
|
-
const data = new Uint8Array(SIZE * SIZE * 4);
|
|
29
|
-
for (let y = 0; y < SIZE; y += 1) {
|
|
30
|
-
for (let x = 0; x < SIZE; x += 1) {
|
|
31
|
-
const [r, g, b] = shade(x / SIZE, y / SIZE);
|
|
32
|
-
const offset = (y * SIZE + x) * 4;
|
|
33
|
-
data[offset] = Math.round(clamp01(r) * 255);
|
|
34
|
-
data[offset + 1] = Math.round(clamp01(g) * 255);
|
|
35
|
-
data[offset + 2] = Math.round(clamp01(b) * 255);
|
|
36
|
-
data[offset + 3] = 255;
|
|
37
|
-
}
|
|
38
|
-
}
|
|
39
|
-
const texture = new THREE.DataTexture(data, SIZE, SIZE, THREE.RGBAFormat);
|
|
40
|
-
texture.colorSpace = THREE.SRGBColorSpace;
|
|
41
|
-
texture.wrapS = THREE.RepeatWrapping;
|
|
42
|
-
texture.wrapT = THREE.RepeatWrapping;
|
|
43
|
-
texture.generateMipmaps = true;
|
|
44
|
-
texture.minFilter = THREE.LinearMipmapLinearFilter;
|
|
45
|
-
texture.magFilter = THREE.LinearFilter;
|
|
46
|
-
texture.needsUpdate = true;
|
|
47
|
-
return texture;
|
|
48
|
-
}
|
|
49
|
-
|
|
50
|
-
// Tileable fbm: sample on a torus via two phase-shifted reads (cheap and
|
|
51
|
-
// good enough for detail maps — exact periodic noise is overkill here).
|
|
52
|
-
function tileNoise(seed, u, v, scaleU, scaleV, octaves = 3) {
|
|
53
|
-
const a = fbm3(seed, u * scaleU, v * scaleV, 0.37, octaves, 2, 0.5);
|
|
54
|
-
const b = fbm3(seed, (u - 1) * scaleU, v * scaleV, 0.37, octaves, 2, 0.5);
|
|
55
|
-
const c = fbm3(seed, u * scaleU, (v - 1) * scaleV, 0.37, octaves, 2, 0.5);
|
|
56
|
-
const d = fbm3(seed, (u - 1) * scaleU, (v - 1) * scaleV, 0.37, octaves, 2, 0.5);
|
|
57
|
-
return a * (1 - u) * (1 - v) + b * u * (1 - v) + c * (1 - u) * v + d * u * v;
|
|
58
|
-
}
|
|
59
|
-
|
|
60
|
-
const gray = (value) => [value, value, value];
|
|
61
|
-
|
|
62
|
-
// Wood: grain streaks running along V — noise compressed 12x across so
|
|
63
|
-
// bands read as fibers, plus sparse darker growth lines.
|
|
64
|
-
function shadeWood(seed) {
|
|
65
|
-
return (u, v) => {
|
|
66
|
-
const wobble = 0.06 * tileNoise(hashCombine(seed, 2), u, v, 3, 3, 2);
|
|
67
|
-
const grain = tileNoise(seed, u + wobble, v, 24, 2, 3);
|
|
68
|
-
const line = valueNoise3(hashCombine(seed, 3), (u + wobble) * 48, v * 3, 0.7);
|
|
69
|
-
let value = 0.88 + grain * 0.1;
|
|
70
|
-
if (line > 0.55) value -= (line - 0.55) * 0.5;
|
|
71
|
-
return [value, value * 0.97, value * 0.92];
|
|
72
|
-
};
|
|
73
|
-
}
|
|
74
|
-
|
|
75
|
-
// Bone: fine porous speckle with sparse darker pits and a faint mottle.
|
|
76
|
-
function shadeBone(seed) {
|
|
77
|
-
return (u, v) => {
|
|
78
|
-
const mottle = tileNoise(seed, u, v, 4, 4, 2);
|
|
79
|
-
const pore = valueNoise3(hashCombine(seed, 5), u * 60, v * 60, 0.3);
|
|
80
|
-
let value = 0.92 + mottle * 0.07;
|
|
81
|
-
if (pore > 0.62) value -= (pore - 0.62) * 0.9;
|
|
82
|
-
return [value, value, value * 0.97];
|
|
83
|
-
};
|
|
84
|
-
}
|
|
85
|
-
|
|
86
|
-
// Stone / masonry: mineral speckle over a broad mottle.
|
|
87
|
-
function shadeStone(seed) {
|
|
88
|
-
return (u, v) => {
|
|
89
|
-
const mottle = tileNoise(seed, u, v, 5, 5, 3);
|
|
90
|
-
const speck = valueNoise3(hashCombine(seed, 7), u * 90, v * 90, 0.2);
|
|
91
|
-
let value = 0.9 + mottle * 0.08;
|
|
92
|
-
if (speck > 0.7) value += (speck - 0.7) * 0.5;
|
|
93
|
-
if (speck < -0.7) value += (speck + 0.7) * 0.4;
|
|
94
|
-
return gray(value);
|
|
95
|
-
};
|
|
96
|
-
}
|
|
97
|
-
|
|
98
|
-
// Metal: brushed streaks along U plus broad patchy tarnish.
|
|
99
|
-
function shadeMetal(seed) {
|
|
100
|
-
return (u, v) => {
|
|
101
|
-
const brush = tileNoise(seed, u, v, 2, 40, 2);
|
|
102
|
-
const patch = tileNoise(hashCombine(seed, 11), u, v, 3, 3, 2);
|
|
103
|
-
const value = 0.9 + brush * 0.06 + patch * 0.08;
|
|
104
|
-
return [value, value, value * 1.02];
|
|
105
|
-
};
|
|
106
|
-
}
|
|
107
|
-
|
|
108
|
-
// Leaf: mid vein at u=0.5 with angled side veins, over papery fibers.
|
|
109
|
-
// Leaf geometry UVs put u across the blade and v stem->tip.
|
|
110
|
-
function shadeLeaf(seed) {
|
|
111
|
-
return (u, v) => {
|
|
112
|
-
const paper = tileNoise(seed, u, v, 8, 8, 2);
|
|
113
|
-
let value = 0.92 + paper * 0.06;
|
|
114
|
-
const acrossMid = Math.abs(u - 0.5);
|
|
115
|
-
if (acrossMid < 0.02) value -= (1 - acrossMid / 0.02) * 0.18;
|
|
116
|
-
// Side veins: diagonal lines every ~0.14 of blade length.
|
|
117
|
-
const veinPhase = (v * 7 + acrossMid * 4.2) % 1;
|
|
118
|
-
if (veinPhase < 0.07 && acrossMid > 0.02 && acrossMid < 0.42) {
|
|
119
|
-
value -= (1 - veinPhase / 0.07) * 0.1;
|
|
120
|
-
}
|
|
121
|
-
return [value * 0.99, value, value * 0.95];
|
|
122
|
-
};
|
|
123
|
-
}
|
|
124
|
-
|
|
125
|
-
// Ash: fine powder with soft clumps.
|
|
126
|
-
function shadeAsh(seed) {
|
|
127
|
-
return (u, v) => {
|
|
128
|
-
const clump = tileNoise(seed, u, v, 6, 6, 3);
|
|
129
|
-
const dust = valueNoise3(hashCombine(seed, 13), u * 110, v * 110, 0.2);
|
|
130
|
-
return gray(0.92 + clump * 0.06 + dust * 0.04);
|
|
131
|
-
};
|
|
132
|
-
}
|
|
133
|
-
|
|
134
|
-
// Fibrous radial detail for cones, shells, and other organic solids.
|
|
135
|
-
function shadeFiber(seed) {
|
|
136
|
-
return (u, v) => {
|
|
137
|
-
const fiber = tileNoise(seed, u, v, 24, 4, 2);
|
|
138
|
-
const mottle = tileNoise(hashCombine(seed, 17), u, v, 3, 3, 2);
|
|
139
|
-
return gray(0.9 + fiber * 0.07 + mottle * 0.05);
|
|
140
|
-
};
|
|
141
|
-
}
|
|
142
|
-
|
|
143
|
-
// Bark: deep lengthwise ridge streaks with dark furrows.
|
|
144
|
-
function shadeBark(seed) {
|
|
145
|
-
return (u, v) => {
|
|
146
|
-
const wobble = 0.08 * tileNoise(hashCombine(seed, 2), u, v, 3, 3, 2);
|
|
147
|
-
const ridge = tileNoise(seed, u + wobble, v, 16, 2, 3);
|
|
148
|
-
const furrow = valueNoise3(hashCombine(seed, 4), (u + wobble) * 26, v * 2.2, 0.5);
|
|
149
|
-
let value = 0.82 + ridge * 0.14;
|
|
150
|
-
if (furrow > 0.35) value -= (furrow - 0.35) * 0.55;
|
|
151
|
-
return [value, value * 0.94, value * 0.88];
|
|
152
|
-
};
|
|
153
|
-
}
|
|
154
|
-
|
|
155
|
-
// Cracked wood: grain plus crossing check-crack lines.
|
|
156
|
-
function shadeCrackedWood(seed) {
|
|
157
|
-
const grain = shadeWood(seed);
|
|
158
|
-
return (u, v) => {
|
|
159
|
-
const color = grain(u, v);
|
|
160
|
-
const crack = valueNoise3(hashCombine(seed, 9), u * 9, v * 34, 0.4);
|
|
161
|
-
if (crack > 0.66) {
|
|
162
|
-
const depth = Math.min((crack - 0.66) * 2.4, 0.5);
|
|
163
|
-
return [color[0] - depth, color[1] - depth, color[2] - depth];
|
|
164
|
-
}
|
|
165
|
-
return color;
|
|
166
|
-
};
|
|
167
|
-
}
|
|
168
|
-
|
|
169
|
-
// Bleached bone: smoother and brighter than porous, faint sutures.
|
|
170
|
-
function shadeBleachedBone(seed) {
|
|
171
|
-
return (u, v) => {
|
|
172
|
-
const mottle = tileNoise(seed, u, v, 3, 3, 2);
|
|
173
|
-
const suture = valueNoise3(hashCombine(seed, 6), u * 14, v * 14, 0.6);
|
|
174
|
-
let value = 0.96 + mottle * 0.04;
|
|
175
|
-
if (suture > 0.74) value -= (suture - 0.74) * 0.35;
|
|
176
|
-
return [value, value, value * 0.98];
|
|
177
|
-
};
|
|
178
|
-
}
|
|
179
|
-
|
|
180
|
-
// Veined stone: thin bright mineral veins over mottle.
|
|
181
|
-
function shadeVeinedStone(seed) {
|
|
182
|
-
return (u, v) => {
|
|
183
|
-
const mottle = tileNoise(seed, u, v, 4, 4, 3);
|
|
184
|
-
const vein = Math.abs(tileNoise(hashCombine(seed, 8), u, v, 6, 6, 3));
|
|
185
|
-
let value = 0.88 + mottle * 0.07;
|
|
186
|
-
if (vein < 0.05) value += (1 - vein / 0.05) * 0.18;
|
|
187
|
-
return gray(value);
|
|
188
|
-
};
|
|
189
|
-
}
|
|
190
|
-
|
|
191
|
-
// Porous stone (lava/limestone): dark pit holes.
|
|
192
|
-
function shadePorousStone(seed) {
|
|
193
|
-
return (u, v) => {
|
|
194
|
-
const mottle = tileNoise(seed, u, v, 5, 5, 2);
|
|
195
|
-
const pore = valueNoise3(hashCombine(seed, 10), u * 70, v * 70, 0.25);
|
|
196
|
-
let value = 0.9 + mottle * 0.06;
|
|
197
|
-
if (pore > 0.55) value -= (pore - 0.55) * 1;
|
|
198
|
-
return gray(value);
|
|
199
|
-
};
|
|
200
|
-
}
|
|
201
|
-
|
|
202
|
-
// Galvanized metal: crystalline spangle patches.
|
|
203
|
-
function shadeGalvanized(seed) {
|
|
204
|
-
return (u, v) => {
|
|
205
|
-
const patch = valueNoise3(hashCombine(seed, 12), u * 9, v * 9, 0.9);
|
|
206
|
-
const grainy = tileNoise(seed, u, v, 30, 30, 1);
|
|
207
|
-
const facet = (Math.round(patch * 5) / 5 - 0.5) * 0.14;
|
|
208
|
-
const value = 0.92 + facet + grainy * 0.03;
|
|
209
|
-
return [value, value, value * 1.03];
|
|
210
|
-
};
|
|
211
|
-
}
|
|
212
|
-
|
|
213
|
-
// Painted metal: flat color with chipped scratches to bare metal.
|
|
214
|
-
function shadePaintedMetal(seed) {
|
|
215
|
-
return (u, v) => {
|
|
216
|
-
const chip = valueNoise3(hashCombine(seed, 14), u * 22, v * 22, 0.35);
|
|
217
|
-
const scratch = tileNoise(seed, u, v, 2, 46, 1);
|
|
218
|
-
let value = 0.95 + scratch * 0.02;
|
|
219
|
-
if (chip > 0.62) value -= (chip - 0.62) * 0.85;
|
|
220
|
-
return [value, value * 0.99, value * 0.97];
|
|
221
|
-
};
|
|
222
|
-
}
|
|
223
|
-
|
|
224
|
-
// Style registry per material kind; the first entry is the 'auto' pick
|
|
225
|
-
// unless debrisTextureAuto overrides by variant.
|
|
226
|
-
export const DEBRIS_TEXTURE_STYLES = Object.freeze({
|
|
227
|
-
ash: Object.freeze([Object.freeze({ id: 'powder', label: 'Powder' })]),
|
|
228
|
-
bone: Object.freeze([
|
|
229
|
-
Object.freeze({ id: 'porous', label: 'Porous' }),
|
|
230
|
-
Object.freeze({ id: 'bleached', label: 'Bleached' }),
|
|
231
|
-
]),
|
|
232
|
-
leaf: Object.freeze([Object.freeze({ id: 'veins', label: 'Leaf veins' })]),
|
|
233
|
-
metal: Object.freeze([
|
|
234
|
-
Object.freeze({ id: 'brushed', label: 'Brushed' }),
|
|
235
|
-
Object.freeze({ id: 'galvanized', label: 'Galvanized' }),
|
|
236
|
-
Object.freeze({ id: 'painted', label: 'Painted & chipped' }),
|
|
237
|
-
]),
|
|
238
|
-
organicFiber: Object.freeze([Object.freeze({ id: 'fiber', label: 'Fiber' })]),
|
|
239
|
-
stone: Object.freeze([
|
|
240
|
-
Object.freeze({ id: 'speckle', label: 'Speckled' }),
|
|
241
|
-
Object.freeze({ id: 'veined', label: 'Veined' }),
|
|
242
|
-
Object.freeze({ id: 'porous', label: 'Porous' }),
|
|
243
|
-
]),
|
|
244
|
-
wood: Object.freeze([
|
|
245
|
-
Object.freeze({ id: 'grain', label: 'Plain grain' }),
|
|
246
|
-
Object.freeze({ id: 'bark', label: 'Bark' }),
|
|
247
|
-
Object.freeze({ id: 'cracked', label: 'Cracked' }),
|
|
248
|
-
]),
|
|
249
|
-
});
|
|
250
|
-
|
|
251
|
-
const STYLE_SHADERS = {
|
|
252
|
-
'ash:powder': shadeAsh,
|
|
253
|
-
'bone:bleached': shadeBleachedBone,
|
|
254
|
-
'bone:porous': shadeBone,
|
|
255
|
-
'leaf:veins': shadeLeaf,
|
|
256
|
-
'metal:brushed': shadeMetal,
|
|
257
|
-
'metal:galvanized': shadeGalvanized,
|
|
258
|
-
'metal:painted': shadePaintedMetal,
|
|
259
|
-
'organicFiber:fiber': shadeFiber,
|
|
260
|
-
'stone:porous': shadePorousStone,
|
|
261
|
-
'stone:speckle': shadeStone,
|
|
262
|
-
'stone:veined': shadeVeinedStone,
|
|
263
|
-
'wood:bark': shadeBark,
|
|
264
|
-
'wood:cracked': shadeCrackedWood,
|
|
265
|
-
'wood:grain': shadeWood,
|
|
266
|
-
};
|
|
267
|
-
|
|
268
|
-
/**
|
|
269
|
-
* Returns the cached detail texture for a material kind + style at a
|
|
270
|
-
* tiling scale. Textures are owned by this cache (evicted LRU, disposed
|
|
271
|
-
* on eviction) — asset disposal must NOT dispose `material.map`.
|
|
272
|
-
*/
|
|
273
|
-
export function getDebrisDetailTexture(kind, seed, style = 'auto', scale = 1) {
|
|
274
|
-
const styles = DEBRIS_TEXTURE_STYLES[kind] ?? DEBRIS_TEXTURE_STYLES.stone;
|
|
275
|
-
const resolved = styles.some((entry) => entry.id === style) ? style : styles[0].id;
|
|
276
|
-
const shader = STYLE_SHADERS[`${kind}:${resolved}`] ?? shadeStone;
|
|
277
|
-
const scaleKey = Math.round(scale * 10) / 10;
|
|
278
|
-
const key = `${kind}:${resolved}:${seed >>> 0}:${scaleKey}`;
|
|
279
|
-
const hit = cache.get(key);
|
|
280
|
-
if (hit) {
|
|
281
|
-
cache.delete(key);
|
|
282
|
-
cache.set(key, hit);
|
|
283
|
-
return hit;
|
|
284
|
-
}
|
|
285
|
-
const texture = bakeTexture(shader(hashCombine(seed >>> 0, kind.length * 37 + resolved.length)));
|
|
286
|
-
texture.repeat.set(scaleKey, scaleKey);
|
|
287
|
-
texture.name = `Debris detail ${key}`;
|
|
288
|
-
cache.set(key, texture);
|
|
289
|
-
if (cache.size > CACHE_LIMIT) {
|
|
290
|
-
const [oldestKey, oldest] = cache.entries().next().value;
|
|
291
|
-
cache.delete(oldestKey);
|
|
292
|
-
oldest.dispose();
|
|
293
|
-
}
|
|
294
|
-
return texture;
|
|
295
|
-
}
|
|
296
|
-
|
|
297
|
-
// User-uploaded textures, cached by data URL. Browser only (Image
|
|
298
|
-
// decode); headless generation skips custom maps.
|
|
299
|
-
const customCache = new Map();
|
|
300
|
-
|
|
301
|
-
export function getCustomDebrisTexture(customTexture, scale = 1) {
|
|
302
|
-
if (!customTexture?.dataUrl || typeof document === 'undefined') return null;
|
|
303
|
-
const scaleKey = Math.round(scale * 10) / 10;
|
|
304
|
-
const key = `${customTexture.dataUrl.length}:${customTexture.dataUrl.slice(-40)}:${scaleKey}`;
|
|
305
|
-
const hit = customCache.get(key);
|
|
306
|
-
if (hit) return hit;
|
|
307
|
-
const texture = new THREE.TextureLoader().load(customTexture.dataUrl);
|
|
308
|
-
texture.colorSpace = THREE.SRGBColorSpace;
|
|
309
|
-
texture.wrapS = THREE.RepeatWrapping;
|
|
310
|
-
texture.wrapT = THREE.RepeatWrapping;
|
|
311
|
-
texture.repeat.set(scaleKey, scaleKey);
|
|
312
|
-
texture.name = `Debris custom ${customTexture.name ?? 'texture'}`;
|
|
313
|
-
customCache.set(key, texture);
|
|
314
|
-
if (customCache.size > 8) {
|
|
315
|
-
const [oldestKey, oldest] = customCache.entries().next().value;
|
|
316
|
-
customCache.delete(oldestKey);
|
|
317
|
-
oldest.dispose();
|
|
318
|
-
}
|
|
319
|
-
return texture;
|
|
320
|
-
}
|
|
321
|
-
|
|
322
|
-
/**
|
|
323
|
-
* Material kind + auto style per debris type/variant. Logs, root stumps,
|
|
324
|
-
* and bark chips default to bark; everything else takes its kind's first
|
|
325
|
-
* style.
|
|
326
|
-
*/
|
|
327
|
-
export function debrisTextureAuto(type, variant) {
|
|
328
|
-
if (type === 'wood') {
|
|
329
|
-
const bark = variant === 'logs' || variant === 'rootStump' || variant === 'barkChips';
|
|
330
|
-
return { kind: 'wood', style: bark ? 'bark' : 'grain' };
|
|
331
|
-
}
|
|
332
|
-
if (type === 'bone') return { kind: 'bone', style: 'porous' };
|
|
333
|
-
if (type === 'stone') return { kind: 'stone', style: 'speckle' };
|
|
334
|
-
if (type === 'metal') return { kind: 'metal', style: 'brushed' };
|
|
335
|
-
if (type === 'ash') return { kind: 'ash', style: 'powder' };
|
|
336
|
-
return variant === 'leafLitter'
|
|
337
|
-
? { kind: 'leaf', style: 'veins' }
|
|
338
|
-
: { kind: 'organicFiber', style: 'fiber' };
|
|
339
|
-
}
|
|
340
|
-
|
|
341
|
-
/** @deprecated kept for callers that only need the kind. */
|
|
342
|
-
export function debrisTextureKind(type, variant) {
|
|
343
|
-
return debrisTextureAuto(type, variant).kind;
|
|
344
|
-
}
|
|
345
|
-
|
|
346
|
-
/**
|
|
347
|
-
* Ensures UVs exist for texture sampling. Geometry without UVs (surface
|
|
348
|
-
* nets output, custom slabs) gets a dominant-axis box projection scaled so
|
|
349
|
-
* the tile repeats ~repeat times across the mesh — plenty for detail maps,
|
|
350
|
-
* and seam-free enough at toon contrast.
|
|
351
|
-
*/
|
|
352
|
-
export function ensureDebrisUvs(geometry, repeat = 2) {
|
|
353
|
-
if (geometry.attributes.uv) return;
|
|
354
|
-
const position = geometry.attributes.position;
|
|
355
|
-
const normal = geometry.attributes.normal;
|
|
356
|
-
if (!position) return;
|
|
357
|
-
geometry.computeBoundingSphere();
|
|
358
|
-
const scale = repeat / Math.max(geometry.boundingSphere?.radius ?? 1, 1e-4) / 2;
|
|
359
|
-
const uvs = new Float32Array(position.count * 2);
|
|
360
|
-
for (let i = 0; i < position.count; i += 1) {
|
|
361
|
-
const nx = normal ? Math.abs(normal.getX(i)) : 0;
|
|
362
|
-
const ny = normal ? Math.abs(normal.getY(i)) : 1;
|
|
363
|
-
const nz = normal ? Math.abs(normal.getZ(i)) : 0;
|
|
364
|
-
let u;
|
|
365
|
-
let v;
|
|
366
|
-
if (nx >= ny && nx >= nz) {
|
|
367
|
-
u = position.getZ(i);
|
|
368
|
-
v = position.getY(i);
|
|
369
|
-
} else if (ny >= nz) {
|
|
370
|
-
u = position.getX(i);
|
|
371
|
-
v = position.getZ(i);
|
|
372
|
-
} else {
|
|
373
|
-
u = position.getX(i);
|
|
374
|
-
v = position.getY(i);
|
|
375
|
-
}
|
|
376
|
-
uvs[i * 2] = u * scale + 0.5;
|
|
377
|
-
uvs[i * 2 + 1] = v * scale + 0.5;
|
|
378
|
-
}
|
|
379
|
-
geometry.setAttribute('uv', new THREE.BufferAttribute(uvs, 2));
|
|
380
|
-
}
|
package/src/debrisgen/index.js
DELETED
package/src/debug/fieldValues.js
DELETED
|
@@ -1,95 +0,0 @@
|
|
|
1
|
-
// Generic value coercion between settings-schema fields and DOM controls.
|
|
2
|
-
// Field metadata comes from the settings modules' *_SETTING_FIELD_SCHEMA
|
|
3
|
-
// exports (type, range, options, optionLabels, defaultValue).
|
|
4
|
-
|
|
5
|
-
function clamp01(value) {
|
|
6
|
-
return Math.min(1, Math.max(0, Number(value) || 0));
|
|
7
|
-
}
|
|
8
|
-
|
|
9
|
-
function toHexChannel(value) {
|
|
10
|
-
return Math.round(clamp01(value) * 255)
|
|
11
|
-
.toString(16)
|
|
12
|
-
.padStart(2, '0');
|
|
13
|
-
}
|
|
14
|
-
|
|
15
|
-
export function colorToHex(value) {
|
|
16
|
-
if (value?.isColor) return `#${toHexChannel(value.r)}${toHexChannel(value.g)}${toHexChannel(value.b)}`;
|
|
17
|
-
if (Array.isArray(value) && value.length >= 3) {
|
|
18
|
-
return `#${toHexChannel(value[0])}${toHexChannel(value[1])}${toHexChannel(value[2])}`;
|
|
19
|
-
}
|
|
20
|
-
return '#ffffff';
|
|
21
|
-
}
|
|
22
|
-
|
|
23
|
-
export function hexToColorArray(value, fallback = [1, 1, 1]) {
|
|
24
|
-
const normalized = String(value ?? '').trim().replace(/^#/, '');
|
|
25
|
-
if (!/^[0-9a-f]{6}$/i.test(normalized)) return fallback;
|
|
26
|
-
return [
|
|
27
|
-
parseInt(normalized.slice(0, 2), 16) / 255,
|
|
28
|
-
parseInt(normalized.slice(2, 4), 16) / 255,
|
|
29
|
-
parseInt(normalized.slice(4, 6), 16) / 255,
|
|
30
|
-
];
|
|
31
|
-
}
|
|
32
|
-
|
|
33
|
-
export function vectorToArray(value, fallback = []) {
|
|
34
|
-
if (value?.isVector2) return [value.x, value.y];
|
|
35
|
-
if (value?.isVector3) return [value.x, value.y, value.z];
|
|
36
|
-
if (value?.isVector4) return [value.x, value.y, value.z, value.w];
|
|
37
|
-
if (Array.isArray(value)) return [...value];
|
|
38
|
-
if (value && typeof value === 'object') {
|
|
39
|
-
return [value.x, value.y, value.z, value.w].filter((entry) => entry !== undefined);
|
|
40
|
-
}
|
|
41
|
-
return [...fallback];
|
|
42
|
-
}
|
|
43
|
-
|
|
44
|
-
export function formatFieldValue(value, field) {
|
|
45
|
-
if (field.type === 'boolean') return value ? 'On' : 'Off';
|
|
46
|
-
if (field.type === 'select') return field.optionLabels?.[String(value)] ?? String(value ?? '');
|
|
47
|
-
if (field.type === 'number') {
|
|
48
|
-
const number = Number(value);
|
|
49
|
-
return Number.isFinite(number) ? number.toFixed(field.range?.step < 0.01 ? 3 : 2) : String(value);
|
|
50
|
-
}
|
|
51
|
-
if (field.type === 'color') return colorToHex(value);
|
|
52
|
-
if (field.type.startsWith('vector')) {
|
|
53
|
-
return vectorToArray(value, field.defaultValue)
|
|
54
|
-
.map((entry) => Number(entry).toFixed(2))
|
|
55
|
-
.join(', ');
|
|
56
|
-
}
|
|
57
|
-
return String(value ?? '');
|
|
58
|
-
}
|
|
59
|
-
|
|
60
|
-
export function readFieldValueFromSettings(settings, field) {
|
|
61
|
-
const group = settings?.[field.group] ?? {};
|
|
62
|
-
return group[field.key] ?? field.defaultValue;
|
|
63
|
-
}
|
|
64
|
-
|
|
65
|
-
export function readFieldValueFromControl(control, field) {
|
|
66
|
-
if (field.type === 'boolean') return Boolean(control.checked);
|
|
67
|
-
if (field.type === 'number') return Number(control.value);
|
|
68
|
-
if (field.type === 'color') return hexToColorArray(control.value, field.defaultValue);
|
|
69
|
-
if (field.type.startsWith('vector')) {
|
|
70
|
-
const size = Number(field.type.replace('vector', '')) || field.defaultValue?.length || 2;
|
|
71
|
-
const parts = String(control.value)
|
|
72
|
-
.split(',')
|
|
73
|
-
.map((entry) => Number(entry.trim()));
|
|
74
|
-
return Array.from({ length: size }, (_, index) => (
|
|
75
|
-
Number.isFinite(parts[index]) ? parts[index] : field.defaultValue[index] ?? 0
|
|
76
|
-
));
|
|
77
|
-
}
|
|
78
|
-
if (field.type === 'select' && typeof field.defaultValue === 'number') return Number(control.value);
|
|
79
|
-
return control.value;
|
|
80
|
-
}
|
|
81
|
-
|
|
82
|
-
export function writeFieldControlValue(control, output, field, value, formatValue = formatFieldValue) {
|
|
83
|
-
if (field.type === 'boolean') {
|
|
84
|
-
control.checked = Boolean(value);
|
|
85
|
-
} else if (field.type === 'color') {
|
|
86
|
-
control.value = colorToHex(value);
|
|
87
|
-
} else if (field.type.startsWith('vector')) {
|
|
88
|
-
control.value = vectorToArray(value, field.defaultValue)
|
|
89
|
-
.map((entry) => Number(entry).toFixed(3))
|
|
90
|
-
.join(', ');
|
|
91
|
-
} else {
|
|
92
|
-
control.value = String(value ?? field.defaultValue ?? '');
|
|
93
|
-
}
|
|
94
|
-
if (output) output.textContent = formatValue(value, field);
|
|
95
|
-
}
|
package/src/debug/index.js
DELETED
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
// Debug/tuning UI barrel. Import from '@call-me-sensei/toonlab/debug'.
|
|
2
|
-
//
|
|
3
|
-
// Optional, DOM-dependent tooling: a schema-driven settings panel that turns
|
|
4
|
-
// any settings module's group/field schema into live controls. The labs use
|
|
5
|
-
// it for their HUD; games can ship it behind a debug flag or not at all.
|
|
6
|
-
export * from './fieldValues.js';
|
|
7
|
-
export * from './settingsPanel.js';
|
|
@@ -1,170 +0,0 @@
|
|
|
1
|
-
// Schema-driven settings panel: renders the setting groups exported by the
|
|
2
|
-
// settings modules (TOON_SETTING_GROUPS / TOON_SETTING_FIELD_SCHEMA and
|
|
3
|
-
// friends) as collapsible groups of typed controls, without knowing anything
|
|
4
|
-
// about what the settings do.
|
|
5
|
-
//
|
|
6
|
-
// const panel = createSettingsPanel({
|
|
7
|
-
// container: document.getElementById('toonSettingGroups'),
|
|
8
|
-
// groups: TOON_SETTING_GROUPS,
|
|
9
|
-
// fieldSchema: TOON_SETTING_FIELD_SCHEMA,
|
|
10
|
-
// getValue: (field) => readFieldValueFromSettings(settings, field),
|
|
11
|
-
// onChange: (field, value) => applyOverride(field, value),
|
|
12
|
-
// });
|
|
13
|
-
// panel.refresh(); // re-pull every control value via getValue
|
|
14
|
-
//
|
|
15
|
-
// The host owns the settings state; the panel only reads through getValue and
|
|
16
|
-
// reports edits through onChange (after echoing the value back into the
|
|
17
|
-
// control and its <output>).
|
|
18
|
-
|
|
19
|
-
import { formatFieldValue, readFieldValueFromControl, writeFieldControlValue } from './fieldValues.js';
|
|
20
|
-
|
|
21
|
-
function createFieldControl(field, options) {
|
|
22
|
-
const {
|
|
23
|
-
dataAttribute, idPrefix, rowClassName, getValue, onChange, isDisabled, formatValue,
|
|
24
|
-
} = options;
|
|
25
|
-
|
|
26
|
-
const row = document.createElement('div');
|
|
27
|
-
row.className = rowClassName;
|
|
28
|
-
row.dataset[dataAttribute] = field.id;
|
|
29
|
-
|
|
30
|
-
const controlId = `${idPrefix}_${field.group}_${field.key}`.replace(/[^a-z0-9_]/gi, '_');
|
|
31
|
-
const label = document.createElement('label');
|
|
32
|
-
label.htmlFor = controlId;
|
|
33
|
-
label.textContent = field.label;
|
|
34
|
-
label.title = field.description;
|
|
35
|
-
|
|
36
|
-
let control;
|
|
37
|
-
if (field.type === 'boolean') {
|
|
38
|
-
control = document.createElement('input');
|
|
39
|
-
control.type = 'checkbox';
|
|
40
|
-
} else if (field.type === 'select') {
|
|
41
|
-
control = document.createElement('select');
|
|
42
|
-
for (const option of field.options ?? []) {
|
|
43
|
-
const element = document.createElement('option');
|
|
44
|
-
element.value = String(option);
|
|
45
|
-
element.textContent = field.optionLabels?.[String(option)] ?? String(option);
|
|
46
|
-
control.append(element);
|
|
47
|
-
}
|
|
48
|
-
} else if (field.type === 'color') {
|
|
49
|
-
control = document.createElement('input');
|
|
50
|
-
control.type = 'color';
|
|
51
|
-
} else if (field.type === 'number') {
|
|
52
|
-
control = document.createElement('input');
|
|
53
|
-
control.type = 'range';
|
|
54
|
-
control.min = String(field.range?.min ?? 0);
|
|
55
|
-
control.max = String(field.range?.max ?? 1);
|
|
56
|
-
control.step = String(field.range?.step ?? 0.01);
|
|
57
|
-
} else {
|
|
58
|
-
control = document.createElement('input');
|
|
59
|
-
control.type = 'text';
|
|
60
|
-
}
|
|
61
|
-
control.id = controlId;
|
|
62
|
-
control.title = field.description;
|
|
63
|
-
control.disabled = Boolean(isDisabled(field));
|
|
64
|
-
|
|
65
|
-
const output = document.createElement('output');
|
|
66
|
-
output.id = `${controlId}Value`;
|
|
67
|
-
output.htmlFor = controlId;
|
|
68
|
-
|
|
69
|
-
const eventName = field.type === 'number' || field.type === 'color' ? 'input' : 'change';
|
|
70
|
-
control.addEventListener(eventName, () => {
|
|
71
|
-
const value = readFieldValueFromControl(control, field);
|
|
72
|
-
writeFieldControlValue(control, output, field, value, formatValue);
|
|
73
|
-
onChange(field, value);
|
|
74
|
-
});
|
|
75
|
-
|
|
76
|
-
row.append(label, control, output);
|
|
77
|
-
return row;
|
|
78
|
-
}
|
|
79
|
-
|
|
80
|
-
export function createSettingsPanel({
|
|
81
|
-
container,
|
|
82
|
-
groups,
|
|
83
|
-
fieldSchema,
|
|
84
|
-
getValue,
|
|
85
|
-
onChange,
|
|
86
|
-
fieldFilter = () => true,
|
|
87
|
-
isDisabled = () => false,
|
|
88
|
-
formatValue = formatFieldValue,
|
|
89
|
-
dataAttribute = 'settingsField',
|
|
90
|
-
idPrefix = 'setting',
|
|
91
|
-
rowClassName = 'hud-control settings-field-control',
|
|
92
|
-
groupClassName = 'toon-setting-group',
|
|
93
|
-
fieldsClassName = 'toon-setting-fields',
|
|
94
|
-
isGroupOpen = () => false,
|
|
95
|
-
prepend = [],
|
|
96
|
-
}) {
|
|
97
|
-
const fieldRows = [];
|
|
98
|
-
const controlOptions = { dataAttribute, idPrefix, rowClassName, getValue, onChange, isDisabled, formatValue };
|
|
99
|
-
|
|
100
|
-
function refresh() {
|
|
101
|
-
for (const { field, control, output } of fieldRows) {
|
|
102
|
-
control.disabled = Boolean(isDisabled(field));
|
|
103
|
-
writeFieldControlValue(control, output, field, getValue(field), formatValue);
|
|
104
|
-
}
|
|
105
|
-
}
|
|
106
|
-
|
|
107
|
-
if (container && container.childElementCount === 0) {
|
|
108
|
-
for (const node of prepend) container.append(node);
|
|
109
|
-
|
|
110
|
-
for (const group of groups) {
|
|
111
|
-
const fields = Object.values(fieldSchema[group.id] ?? {}).filter(fieldFilter);
|
|
112
|
-
if (fields.length === 0) continue;
|
|
113
|
-
|
|
114
|
-
const details = document.createElement('details');
|
|
115
|
-
details.className = groupClassName;
|
|
116
|
-
details.dataset.settingsGroup = group.id;
|
|
117
|
-
details.open = Boolean(isGroupOpen(group));
|
|
118
|
-
|
|
119
|
-
const summary = document.createElement('summary');
|
|
120
|
-
summary.textContent = group.label;
|
|
121
|
-
summary.title = group.description;
|
|
122
|
-
|
|
123
|
-
const fieldList = document.createElement('div');
|
|
124
|
-
fieldList.className = fieldsClassName;
|
|
125
|
-
for (const field of fields) {
|
|
126
|
-
const row = createFieldControl(field, controlOptions);
|
|
127
|
-
fieldList.append(row);
|
|
128
|
-
fieldRows.push({
|
|
129
|
-
control: row.querySelector('input, select'),
|
|
130
|
-
field,
|
|
131
|
-
output: row.querySelector('output'),
|
|
132
|
-
});
|
|
133
|
-
}
|
|
134
|
-
|
|
135
|
-
details.append(summary, fieldList);
|
|
136
|
-
container.append(details);
|
|
137
|
-
}
|
|
138
|
-
|
|
139
|
-
refresh();
|
|
140
|
-
}
|
|
141
|
-
|
|
142
|
-
return { container, refresh };
|
|
143
|
-
}
|
|
144
|
-
|
|
145
|
-
// A plain labelled <select> row for panel headers (preset pickers, debug view
|
|
146
|
-
// selectors) that live alongside the schema-generated groups.
|
|
147
|
-
export function createSelectRow({ id, label, title, options, value, onChange, rowClassName = 'hud-control' }) {
|
|
148
|
-
const row = document.createElement('div');
|
|
149
|
-
row.className = rowClassName;
|
|
150
|
-
|
|
151
|
-
const labelEl = document.createElement('label');
|
|
152
|
-
labelEl.htmlFor = id;
|
|
153
|
-
labelEl.textContent = label;
|
|
154
|
-
labelEl.title = title;
|
|
155
|
-
|
|
156
|
-
const select = document.createElement('select');
|
|
157
|
-
select.id = id;
|
|
158
|
-
select.title = title;
|
|
159
|
-
for (const option of options) {
|
|
160
|
-
const el = document.createElement('option');
|
|
161
|
-
el.value = option.value;
|
|
162
|
-
el.textContent = option.label;
|
|
163
|
-
if (option.value === value) el.selected = true;
|
|
164
|
-
select.append(el);
|
|
165
|
-
}
|
|
166
|
-
select.addEventListener('change', () => onChange(select.value));
|
|
167
|
-
|
|
168
|
-
row.append(labelEl, select);
|
|
169
|
-
return row;
|
|
170
|
-
}
|