@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
|
@@ -0,0 +1,1190 @@
|
|
|
1
|
+
// The night sky: the star panorama, the phase-shaded moon disc, and the ambient
|
|
2
|
+
// lift the moon puts on the sky.
|
|
3
|
+
//
|
|
4
|
+
// This module owns the `nightSky` param group of SkyParams, and per the spec's
|
|
5
|
+
// module-ownership table (docs/sky-cloud-parameters.md, "Module ownership") it
|
|
6
|
+
// is the sole definition of it. Anything that needs that default imports it from
|
|
7
|
+
// here. The group is declared ahead of the effect for the same reason as
|
|
8
|
+
// sky/godRays.js: the SkyParams envelope has to compose a `nightSky` block, and
|
|
9
|
+
// letting the envelope declare the group inline is how a second copy of a
|
|
10
|
+
// default gets created later, which is what breaks `export *` barrels.
|
|
11
|
+
//
|
|
12
|
+
// The star texture is supplied by the HOST, not bundled: omit it and the
|
|
13
|
+
// panorama renders black, which is documented behaviour rather than an error.
|
|
14
|
+
// `intensity` is calibrated for atmosphere.exposure 1.0.
|
|
15
|
+
//
|
|
16
|
+
// The moon's own parameters are NOT here. `moon.phase`, `intensity`,
|
|
17
|
+
// `discBrightness`, `angularSize`, `color` and `ambient` are the nested `moon`
|
|
18
|
+
// block of the `time` group and belong to sky/timeOfDay.js, which drives the
|
|
19
|
+
// moon's direction and its phase illumination. This module consumes them.
|
|
20
|
+
//
|
|
21
|
+
// Composition. Both the stars and the moon are radiance ADDED to the sky, so the
|
|
22
|
+
// mesh is a blended backdrop (RenderLayer.backgroundOverlay) rather than an
|
|
23
|
+
// opaque one: sky/atmosphereDome.js draws the whole sphere opaquely in
|
|
24
|
+
// RenderLayer.background, so a night sky placed *under* it could never be seen.
|
|
25
|
+
// `radianceNode` is the same graph as a callable node function, for the env-map
|
|
26
|
+
// bake and for water reflections, which the reference documents as including the
|
|
27
|
+
// stars, the moon disc and the ambient lift.
|
|
28
|
+
//
|
|
29
|
+
// Everything here is linear HDR in the same unit as `sun.intensity`. No exposure
|
|
30
|
+
// and no tonemap: the post chain owns both, exactly as the sky dome leaves them.
|
|
31
|
+
//
|
|
32
|
+
// Sampling convention. The panorama is read with three.js' own equirect
|
|
33
|
+
// background mapping (see three/src/nodes/utils/EquirectUV.js) applied in the
|
|
34
|
+
// celestial frame, so a texture that looks right as `scene.background` looks
|
|
35
|
+
// right here — the same longitude handedness, the same poles at the top and
|
|
36
|
+
// bottom edges, only turned by the clock. The one deliberate difference is a
|
|
37
|
+
// quarter-turn shift of u, which puts the driver's celestial longitude 0 — where
|
|
38
|
+
// `sunDriver.starRotationAt` anchors the midnight moon — at u 0.5, the middle of
|
|
39
|
+
// the panorama.
|
|
40
|
+
|
|
41
|
+
import * as THREE from 'three';
|
|
42
|
+
import { MeshBasicNodeMaterial } from 'three/webgpu';
|
|
43
|
+
import {
|
|
44
|
+
Fn,
|
|
45
|
+
cameraPosition,
|
|
46
|
+
cross,
|
|
47
|
+
dot,
|
|
48
|
+
float,
|
|
49
|
+
max,
|
|
50
|
+
mix,
|
|
51
|
+
normalize,
|
|
52
|
+
positionWorld,
|
|
53
|
+
saturate,
|
|
54
|
+
smoothstep,
|
|
55
|
+
sqrt,
|
|
56
|
+
step,
|
|
57
|
+
texture,
|
|
58
|
+
uniform,
|
|
59
|
+
vec2,
|
|
60
|
+
vec3,
|
|
61
|
+
vec4,
|
|
62
|
+
} from 'three/tsl';
|
|
63
|
+
|
|
64
|
+
import { encodeUnorm8 } from '../cloud/noise/noiseVolume.js';
|
|
65
|
+
import { finiteNumber } from '../cloud/paramSchema.js';
|
|
66
|
+
import { hashCombine } from '../rockgen/noise/prng.js';
|
|
67
|
+
import { createRandom } from '../rockgen/noise/prng.js';
|
|
68
|
+
import { fbm3 } from '../rockgen/noise/valueNoise3.js';
|
|
69
|
+
import { placeInLayer, RenderLayer } from './renderLayers.js';
|
|
70
|
+
import { DEFAULT_MOON_PARAMS } from './timeOfDay.js';
|
|
71
|
+
|
|
72
|
+
const TAU = Math.PI * 2;
|
|
73
|
+
|
|
74
|
+
export const NIGHT_SKY_PARAM_SCHEMA = Object.freeze({
|
|
75
|
+
intensity: Object.freeze({
|
|
76
|
+
description: 'Star panorama brightness, calibrated for exposure 1.0. The star texture itself is supplied by the host; without one the night sky is black.',
|
|
77
|
+
label: 'Star Intensity',
|
|
78
|
+
range: Object.freeze({ max: 3, min: 0, step: 0.01 }),
|
|
79
|
+
type: 'number',
|
|
80
|
+
unit: '',
|
|
81
|
+
value: 0.3,
|
|
82
|
+
}),
|
|
83
|
+
});
|
|
84
|
+
|
|
85
|
+
export const NIGHT_SKY_PARAM_KEYS = Object.freeze(Object.keys(NIGHT_SKY_PARAM_SCHEMA));
|
|
86
|
+
|
|
87
|
+
export const DEFAULT_NIGHT_SKY_PARAMS = Object.freeze(
|
|
88
|
+
Object.fromEntries(NIGHT_SKY_PARAM_KEYS.map((key) => [key, NIGHT_SKY_PARAM_SCHEMA[key].value])),
|
|
89
|
+
);
|
|
90
|
+
|
|
91
|
+
/** Star sphere radius in world units, from the reference's `nightSky.radius`. */
|
|
92
|
+
export const NIGHT_SKY_DEFAULT_RADIUS = 100_000;
|
|
93
|
+
|
|
94
|
+
// ---------------------------------------------------------------------------
|
|
95
|
+
// Procedural lunar albedo
|
|
96
|
+
// ---------------------------------------------------------------------------
|
|
97
|
+
//
|
|
98
|
+
// The reference bundles a lunar surface texture and exposes it as a data URL. We
|
|
99
|
+
// have no access to theirs, so this bakes one: maria, a power-law crater field
|
|
100
|
+
// and two ray systems, all from the repo's seeded PRNG. A texture rather than an
|
|
101
|
+
// analytic disc because the drawn moon is not small — `moonAngularSize` 0.0003 is
|
|
102
|
+
// an angular radius of 1.403 degrees, so a disc 2.81 degrees wide: 45 pixels
|
|
103
|
+
// across at 720p and a 45-degree vertical field (measured, not estimated — the GPU
|
|
104
|
+
// probe reads a 25324-pixel footprint at a 4-degree field over 256 pixels), and an
|
|
105
|
+
// author raising it for a cinematic moon gets far more. At those sizes the maria
|
|
106
|
+
// are the feature that reads as "moon"; a
|
|
107
|
+
// smooth shaded ball reads as a planet or a lamp, and no photometric function
|
|
108
|
+
// can put a Mare Imbrium on it.
|
|
109
|
+
//
|
|
110
|
+
// The map is an EQUIRECT map of the lunar sphere, longitude 0 at the centre of
|
|
111
|
+
// the near side and latitude 0 across the middle — the same layout as published
|
|
112
|
+
// lunar albedo maps (NASA's CGI Moon Kit and friends), so one of those can be
|
|
113
|
+
// dropped in through `setMoonTexture` without a reprojection. Foreshortening at
|
|
114
|
+
// the limb therefore falls out of the disc-space normal the shader reconstructs,
|
|
115
|
+
// which is what makes the disc read as a sphere rather than a sticker.
|
|
116
|
+
//
|
|
117
|
+
// Values are RELATIVE albedo in linear space, normalised so the mean over the
|
|
118
|
+
// visible disc is exactly `MOON_ALBEDO_DISC_MEAN`. The Moon's real geometric
|
|
119
|
+
// albedo is about 0.12, which as an absolute number would make the disc a dark
|
|
120
|
+
// grey smudge; the absolute level belongs to `moon.discBrightness`, and pinning
|
|
121
|
+
// the map's mean is what makes that dial's default of 9.0 mean something.
|
|
122
|
+
|
|
123
|
+
export const MOON_ALBEDO_SCHEMA_VERSION = 1;
|
|
124
|
+
|
|
125
|
+
export const MOON_ALBEDO_PLAN = Object.freeze({
|
|
126
|
+
height: 128,
|
|
127
|
+
seed: 1,
|
|
128
|
+
width: 256,
|
|
129
|
+
});
|
|
130
|
+
|
|
131
|
+
/**
|
|
132
|
+
* Disc-area mean of the generated map, which the disc shading divides back out.
|
|
133
|
+
*
|
|
134
|
+
* Under a half rather than a half, so the brightest ray systems have byte
|
|
135
|
+
* headroom: the map is normalised TO this mean, and a bright crater ray inside
|
|
136
|
+
* another crater's ejecta runs a little over twice it. Measured across seeds 1,
|
|
137
|
+
* 2, 3, 7, 11, 42 and 1337 the realised peak lands between 0.80 and 0.94 of the
|
|
138
|
+
* byte range, and `createMoonAlbedoData` reports it so a bake that would clip
|
|
139
|
+
* says so instead of quietly flattening its rays.
|
|
140
|
+
*/
|
|
141
|
+
export const MOON_ALBEDO_DISC_MEAN = 0.42;
|
|
142
|
+
|
|
143
|
+
/**
|
|
144
|
+
* Seed namespace for the lunar bake.
|
|
145
|
+
*
|
|
146
|
+
* Every noise field in this project seeds its bands by a namespace so two fields
|
|
147
|
+
* asked for the same frequency under the same document seed are not the same
|
|
148
|
+
* field (see CLOUD_EROSION_SEED_NAMESPACE — sharing one namespace once carved a
|
|
149
|
+
* cloud with a copy of its own basis).
|
|
150
|
+
*/
|
|
151
|
+
export const MOON_ALBEDO_SEED_NAMESPACE = 0x6d6f6f6e;
|
|
152
|
+
|
|
153
|
+
/** Scales an RGB tint to a mean of exactly 1, so it carries no brightness. */
|
|
154
|
+
function unitMeanTint(channels) {
|
|
155
|
+
const mean = (channels[0] + channels[1] + channels[2]) / 3;
|
|
156
|
+
return Object.freeze(channels.map((channel) => channel / mean));
|
|
157
|
+
}
|
|
158
|
+
|
|
159
|
+
// Relative to the mean, before normalisation. Highlands and maria differ by
|
|
160
|
+
// about 2x in reality; the tints are the small colour difference between
|
|
161
|
+
// feldspathic highland and titanium-rich basalt, which survives as a hint of
|
|
162
|
+
// warm/cool structure once `moon.color` has tinted the whole disc.
|
|
163
|
+
const MOON_HIGHLAND_ALBEDO = 0.13;
|
|
164
|
+
const MOON_MARE_ALBEDO = 0.068;
|
|
165
|
+
// Normalised to a mean of exactly 1 so a tint carries chroma and no brightness:
|
|
166
|
+
// otherwise the disc-mean calibration below would be off by the tints' own mean,
|
|
167
|
+
// and `moon.discBrightness` would stop meaning what it says.
|
|
168
|
+
const MOON_HIGHLAND_TINT = unitMeanTint([1, 0.985, 0.955]);
|
|
169
|
+
const MOON_MARE_TINT = unitMeanTint([0.955, 0.975, 1]);
|
|
170
|
+
|
|
171
|
+
// Maria are a near-side phenomenon — the far side has almost none — so their
|
|
172
|
+
// centres are drawn from a band around the sub-Earth point, wide enough to run
|
|
173
|
+
// together into one connected dark system the way Imbrium, Serenitatis and
|
|
174
|
+
// Tranquillitatis do.
|
|
175
|
+
const MOON_MARE_COUNT = 7;
|
|
176
|
+
const MOON_MARE_MIN_RADIUS = 0.22;
|
|
177
|
+
const MOON_MARE_MAX_RADIUS = 0.58;
|
|
178
|
+
const MOON_MARE_LONGITUDE_SPREAD = 1.25;
|
|
179
|
+
const MOON_MARE_LATITUDE_SPREAD = 0.8;
|
|
180
|
+
const MOON_MARE_WARP = 0.34;
|
|
181
|
+
// Maria are flood basalt over older ground, so the craters they buried are gone.
|
|
182
|
+
// That contrast — dark and smooth against light and cratered — is the thing that
|
|
183
|
+
// reads as the Moon rather than as an asteroid, so only this fraction of a
|
|
184
|
+
// crater's relief survives inside one.
|
|
185
|
+
const MOON_MARE_CRATER_SURVIVAL = 0.16;
|
|
186
|
+
|
|
187
|
+
// Radii are arc radians; the Moon's radius is 1737 km, so 0.006 is a 10 km
|
|
188
|
+
// crater and 0.13 a 226 km basin. The cubic draw below is a stand-in for the
|
|
189
|
+
// observed size-frequency power law: many small, few large.
|
|
190
|
+
const MOON_CRATER_COUNT = 900;
|
|
191
|
+
const MOON_CRATER_MIN_RADIUS = 0.005;
|
|
192
|
+
const MOON_CRATER_MAX_RADIUS = 0.13;
|
|
193
|
+
const MOON_CRATER_EJECTA_REACH = 2;
|
|
194
|
+
const MOON_CRATER_PEAK_RADIUS = 0.035;
|
|
195
|
+
|
|
196
|
+
// The bright ray systems of the youngest large craters (Tycho, Copernicus) are
|
|
197
|
+
// the most recognisable thing on the near side after the maria, and at 45-odd
|
|
198
|
+
// pixels they survive where a single crater rim does not.
|
|
199
|
+
const MOON_RAY_CRATERS = 2;
|
|
200
|
+
const MOON_RAY_REACH = 5;
|
|
201
|
+
const MOON_RAY_STRENGTH = 0.42;
|
|
202
|
+
|
|
203
|
+
// Overlapping craters multiply, and three coincident rims inside a ray system
|
|
204
|
+
// multiply to nearly 3x the surrounding albedo — brighter than any real lunar
|
|
205
|
+
// unit, and past what a byte-encoded map normalised to a mean of
|
|
206
|
+
// MOON_ALBEDO_DISC_MEAN can carry. The window is the physical range: no unit on
|
|
207
|
+
// the Moon is much under half or over 1.6x its surroundings.
|
|
208
|
+
const MOON_FEATURE_FLOOR = 0.6;
|
|
209
|
+
const MOON_FEATURE_CEILING = 1.6;
|
|
210
|
+
|
|
211
|
+
const clamp01 = (value) => (value < 0 ? 0 : value > 1 ? 1 : value);
|
|
212
|
+
|
|
213
|
+
/** Hermite ramp on [0, 1], clamped outside it. */
|
|
214
|
+
function smoothRamp(t) {
|
|
215
|
+
const x = clamp01(t);
|
|
216
|
+
return x * x * (3 - 2 * x);
|
|
217
|
+
}
|
|
218
|
+
|
|
219
|
+
/** Parabolic bump: 1 at 0, 0 at |t| >= 1. */
|
|
220
|
+
function bump(t) {
|
|
221
|
+
const a = t < 0 ? -t : t;
|
|
222
|
+
return a >= 1 ? 0 : 1 - a * a;
|
|
223
|
+
}
|
|
224
|
+
|
|
225
|
+
function directionFromLonLat(lon, lat, target = { x: 0, y: 0, z: 0 }) {
|
|
226
|
+
const cosLat = Math.cos(lat);
|
|
227
|
+
target.x = cosLat * Math.sin(lon);
|
|
228
|
+
target.y = Math.sin(lat);
|
|
229
|
+
target.z = cosLat * Math.cos(lon);
|
|
230
|
+
return target;
|
|
231
|
+
}
|
|
232
|
+
|
|
233
|
+
/**
|
|
234
|
+
* Multiplicative albedo factor of one crater at `t` = angular distance / radius.
|
|
235
|
+
*
|
|
236
|
+
* A dark flat floor, a bright rim crest, and an ejecta blanket fading out to
|
|
237
|
+
* `MOON_CRATER_EJECTA_REACH`. Large craters also get a central peak. The
|
|
238
|
+
* numbers are a legibility choice, not a measurement: what matters at 45 pixels
|
|
239
|
+
* is that rims read bright against floors, which is the contrast the eye uses to
|
|
240
|
+
* call a round patch a crater.
|
|
241
|
+
*/
|
|
242
|
+
function craterFactor(t, radiusRad) {
|
|
243
|
+
if (t >= MOON_CRATER_EJECTA_REACH) return 1;
|
|
244
|
+
const floorMask = 1 - smoothRamp((t - 0.52) / 0.34);
|
|
245
|
+
const rimMask = bump((t - 0.97) / 0.15);
|
|
246
|
+
const ejectaMask = smoothRamp((t - 0.9) / 0.15)
|
|
247
|
+
* (1 - smoothRamp((t - 1.05) / (MOON_CRATER_EJECTA_REACH - 1.05)));
|
|
248
|
+
const peak = radiusRad > MOON_CRATER_PEAK_RADIUS ? 0.3 * bump(t / 0.18) : 0;
|
|
249
|
+
return 1 - 0.22 * floorMask + 0.26 * rimMask + 0.07 * ejectaMask + peak;
|
|
250
|
+
}
|
|
251
|
+
|
|
252
|
+
/**
|
|
253
|
+
* Visits every texel of an equirect map within `reach` radians of `centre`.
|
|
254
|
+
*
|
|
255
|
+
* A spherical-cap rasteriser rather than a per-texel loop over every feature:
|
|
256
|
+
* 900 craters against 32768 texels is 29 million distance tests, where splatting
|
|
257
|
+
* each feature over its own cap is a few hundred thousand. The longitude span of
|
|
258
|
+
* a cap at a given latitude is exact (the spherical law of cosines), so no
|
|
259
|
+
* feature is clipped, and the callback still gets the true angular distance.
|
|
260
|
+
*/
|
|
261
|
+
function splatCap({ centre, directions, height, lat, lon, reach, visit, width }) {
|
|
262
|
+
const cosReach = Math.cos(reach);
|
|
263
|
+
const cosCentreLat = Math.cos(lat);
|
|
264
|
+
const jMin = Math.max(0, Math.floor((((lat - reach) / Math.PI) + 0.5) * height));
|
|
265
|
+
const jMax = Math.min(height - 1, Math.ceil((((lat + reach) / Math.PI) + 0.5) * height));
|
|
266
|
+
for (let j = jMin; j <= jMax; j += 1) {
|
|
267
|
+
const rowLat = (((j + 0.5) / height) - 0.5) * Math.PI;
|
|
268
|
+
const cosRowLat = Math.cos(rowLat);
|
|
269
|
+
let halfSpan;
|
|
270
|
+
if (cosRowLat <= 1e-6 || cosCentreLat <= 1e-6) {
|
|
271
|
+
halfSpan = Math.PI;
|
|
272
|
+
} else {
|
|
273
|
+
const cosDelta = (cosReach - (Math.sin(rowLat) * Math.sin(lat)))
|
|
274
|
+
/ (cosRowLat * cosCentreLat);
|
|
275
|
+
if (cosDelta >= 1) continue;
|
|
276
|
+
halfSpan = cosDelta <= -1 ? Math.PI : Math.acos(cosDelta);
|
|
277
|
+
}
|
|
278
|
+
const halfTexels = ((halfSpan / TAU) * width) + 1;
|
|
279
|
+
const wholeRow = halfTexels * 2 >= width;
|
|
280
|
+
const iCentre = (((lon / TAU) + 0.5) * width) - 0.5;
|
|
281
|
+
const from = wholeRow ? 0 : Math.floor(iCentre - halfTexels);
|
|
282
|
+
const to = wholeRow ? width - 1 : Math.ceil(iCentre + halfTexels);
|
|
283
|
+
for (let k = from; k <= to; k += 1) {
|
|
284
|
+
const i = wholeRow ? k : (((k % width) + width) % width);
|
|
285
|
+
const index = (j * width) + i;
|
|
286
|
+
const base = index * 3;
|
|
287
|
+
const cosAngle = (directions[base] * centre.x)
|
|
288
|
+
+ (directions[base + 1] * centre.y)
|
|
289
|
+
+ (directions[base + 2] * centre.z);
|
|
290
|
+
const angle = Math.acos(cosAngle < -1 ? -1 : cosAngle > 1 ? 1 : cosAngle);
|
|
291
|
+
if (angle > reach) continue;
|
|
292
|
+
visit(index, angle, directions[base], directions[base + 1], directions[base + 2]);
|
|
293
|
+
}
|
|
294
|
+
}
|
|
295
|
+
}
|
|
296
|
+
|
|
297
|
+
/**
|
|
298
|
+
* Bakes the lunar albedo map. Deterministic in `seed`: the same seed produces
|
|
299
|
+
* byte-identical output, which is what lets the verification treat the moon as a
|
|
300
|
+
* fixture rather than a variable.
|
|
301
|
+
*
|
|
302
|
+
* Returns the encoded RGBA bytes plus the measurements the caller needs to trust
|
|
303
|
+
* them: `discMean` is the projected-area mean the map was normalised FROM, and
|
|
304
|
+
* `peak` the largest normalised channel, so a bake that would have clipped
|
|
305
|
+
* against the byte range says so instead of quietly flattening its ray systems.
|
|
306
|
+
*/
|
|
307
|
+
export function createMoonAlbedoData({
|
|
308
|
+
height = MOON_ALBEDO_PLAN.height,
|
|
309
|
+
seed = MOON_ALBEDO_PLAN.seed,
|
|
310
|
+
width = MOON_ALBEDO_PLAN.width,
|
|
311
|
+
} = {}) {
|
|
312
|
+
const mapWidth = Math.max(8, Math.round(finiteNumber(width) ?? MOON_ALBEDO_PLAN.width));
|
|
313
|
+
const mapHeight = Math.max(4, Math.round(finiteNumber(height) ?? MOON_ALBEDO_PLAN.height));
|
|
314
|
+
const seedValue = (finiteNumber(seed) ?? MOON_ALBEDO_PLAN.seed) >>> 0;
|
|
315
|
+
const namespace = hashCombine(seedValue, MOON_ALBEDO_SEED_NAMESPACE);
|
|
316
|
+
const random = createRandom(namespace);
|
|
317
|
+
const texels = mapWidth * mapHeight;
|
|
318
|
+
|
|
319
|
+
// The surface normal of every texel, once. Both the feature splats and the
|
|
320
|
+
// noise fields need it, and recomputing two transcendentals per feature per
|
|
321
|
+
// texel is the only expensive thing in this bake.
|
|
322
|
+
const directions = new Float32Array(texels * 3);
|
|
323
|
+
for (let j = 0; j < mapHeight; j += 1) {
|
|
324
|
+
const lat = (((j + 0.5) / mapHeight) - 0.5) * Math.PI;
|
|
325
|
+
const cosLat = Math.cos(lat);
|
|
326
|
+
const sinLat = Math.sin(lat);
|
|
327
|
+
for (let i = 0; i < mapWidth; i += 1) {
|
|
328
|
+
const lon = (((i + 0.5) / mapWidth) - 0.5) * TAU;
|
|
329
|
+
const base = (((j * mapWidth) + i) * 3);
|
|
330
|
+
directions[base] = cosLat * Math.sin(lon);
|
|
331
|
+
directions[base + 1] = sinLat;
|
|
332
|
+
directions[base + 2] = cosLat * Math.cos(lon);
|
|
333
|
+
}
|
|
334
|
+
}
|
|
335
|
+
|
|
336
|
+
// Every feature is drawn before any is rasterised, so the field evaluation
|
|
337
|
+
// order cannot move the PRNG and the bake stays reproducible if the splat
|
|
338
|
+
// loops are ever reordered for speed.
|
|
339
|
+
const maria = [];
|
|
340
|
+
for (let index = 0; index < MOON_MARE_COUNT; index += 1) {
|
|
341
|
+
const lon = ((random() * 2) - 1) * MOON_MARE_LONGITUDE_SPREAD;
|
|
342
|
+
const lat = ((random() * 2) - 1) * MOON_MARE_LATITUDE_SPREAD;
|
|
343
|
+
const radius = MOON_MARE_MIN_RADIUS
|
|
344
|
+
+ ((MOON_MARE_MAX_RADIUS - MOON_MARE_MIN_RADIUS) * random() * random());
|
|
345
|
+
maria.push({
|
|
346
|
+
centre: directionFromLonLat(lon, lat),
|
|
347
|
+
lat,
|
|
348
|
+
lon,
|
|
349
|
+
radius,
|
|
350
|
+
warpSeed: hashCombine(namespace, 0x4d415245 + index),
|
|
351
|
+
});
|
|
352
|
+
}
|
|
353
|
+
|
|
354
|
+
const craters = [];
|
|
355
|
+
for (let index = 0; index < MOON_CRATER_COUNT; index += 1) {
|
|
356
|
+
const lat = Math.asin((random() * 2) - 1);
|
|
357
|
+
const lon = ((random() * 2) - 1) * Math.PI;
|
|
358
|
+
const size = random();
|
|
359
|
+
const radius = MOON_CRATER_MIN_RADIUS
|
|
360
|
+
+ ((MOON_CRATER_MAX_RADIUS - MOON_CRATER_MIN_RADIUS) * size * size * size * size);
|
|
361
|
+
craters.push({
|
|
362
|
+
centre: directionFromLonLat(lon, lat), lat, lon, radius,
|
|
363
|
+
});
|
|
364
|
+
}
|
|
365
|
+
// The ray systems go on the largest craters, which is where they are in
|
|
366
|
+
// reality: a small crater's rays are gone long before its rim is.
|
|
367
|
+
const rayCraters = craters
|
|
368
|
+
.map((crater, index) => ({ index, radius: crater.radius }))
|
|
369
|
+
.sort((a, b) => b.radius - a.radius)
|
|
370
|
+
.slice(0, MOON_RAY_CRATERS)
|
|
371
|
+
.map(({ index }) => ({
|
|
372
|
+
...craters[index],
|
|
373
|
+
lobes: 5 + Math.floor(random() * 7),
|
|
374
|
+
phase: random() * TAU,
|
|
375
|
+
}));
|
|
376
|
+
|
|
377
|
+
const mare = new Float32Array(texels);
|
|
378
|
+
const factor = new Float32Array(texels).fill(1);
|
|
379
|
+
|
|
380
|
+
for (const basin of maria) {
|
|
381
|
+
splatCap({
|
|
382
|
+
centre: basin.centre,
|
|
383
|
+
directions,
|
|
384
|
+
height: mapHeight,
|
|
385
|
+
lat: basin.lat,
|
|
386
|
+
lon: basin.lon,
|
|
387
|
+
reach: Math.min(basin.radius * (1 + MOON_MARE_WARP) * 1.05, Math.PI),
|
|
388
|
+
visit(index, angle, nx, ny, nz) {
|
|
389
|
+
const warp = fbm3(basin.warpSeed, nx * 3, ny * 3, nz * 3, 3);
|
|
390
|
+
const radius = basin.radius * (1 + (MOON_MARE_WARP * warp));
|
|
391
|
+
// A sharp edge, because a mare boundary is where the basalt stopped, not
|
|
392
|
+
// a gradient. Wide enough only to stay smooth at one texel per 1.4 deg.
|
|
393
|
+
const mask = 1 - smoothRamp(((angle / radius) - 0.86) / 0.16);
|
|
394
|
+
if (mask > mare[index]) mare[index] = mask;
|
|
395
|
+
},
|
|
396
|
+
width: mapWidth,
|
|
397
|
+
});
|
|
398
|
+
}
|
|
399
|
+
|
|
400
|
+
for (const crater of craters) {
|
|
401
|
+
splatCap({
|
|
402
|
+
centre: crater.centre,
|
|
403
|
+
directions,
|
|
404
|
+
height: mapHeight,
|
|
405
|
+
lat: crater.lat,
|
|
406
|
+
lon: crater.lon,
|
|
407
|
+
reach: Math.min(crater.radius * MOON_CRATER_EJECTA_REACH, Math.PI),
|
|
408
|
+
visit(index, angle) {
|
|
409
|
+
const relief = craterFactor(angle / crater.radius, crater.radius) - 1;
|
|
410
|
+
// Buried by the basalt wherever a mare covers it. The maria are splatted
|
|
411
|
+
// first for exactly this reason.
|
|
412
|
+
const survival = 1 - ((1 - MOON_MARE_CRATER_SURVIVAL) * clamp01(mare[index]));
|
|
413
|
+
factor[index] *= 1 + (relief * survival);
|
|
414
|
+
},
|
|
415
|
+
width: mapWidth,
|
|
416
|
+
});
|
|
417
|
+
}
|
|
418
|
+
|
|
419
|
+
for (const crater of rayCraters) {
|
|
420
|
+
// Azimuth basis for the streaks. `cross(pole, centre)` degenerates only for
|
|
421
|
+
// a crater exactly at a lunar pole, where the fallback is still a tangent.
|
|
422
|
+
let tx = -crater.centre.z;
|
|
423
|
+
let tz = crater.centre.x;
|
|
424
|
+
const tLength = Math.hypot(tx, tz);
|
|
425
|
+
let ty = 0;
|
|
426
|
+
if (tLength < 1e-6) {
|
|
427
|
+
tx = 1;
|
|
428
|
+
tz = 0;
|
|
429
|
+
} else {
|
|
430
|
+
tx /= tLength;
|
|
431
|
+
tz /= tLength;
|
|
432
|
+
}
|
|
433
|
+
const ux = (crater.centre.y * tz) - (crater.centre.z * ty);
|
|
434
|
+
const uy = (crater.centre.z * tx) - (crater.centre.x * tz);
|
|
435
|
+
const uz = (crater.centre.x * ty) - (crater.centre.y * tx);
|
|
436
|
+
splatCap({
|
|
437
|
+
centre: crater.centre,
|
|
438
|
+
directions,
|
|
439
|
+
height: mapHeight,
|
|
440
|
+
lat: crater.lat,
|
|
441
|
+
lon: crater.lon,
|
|
442
|
+
reach: Math.min(crater.radius * MOON_RAY_REACH, Math.PI),
|
|
443
|
+
visit(index, angle, nx, ny, nz) {
|
|
444
|
+
const t = angle / crater.radius;
|
|
445
|
+
if (t <= 1.05) return;
|
|
446
|
+
const radial = 1 - smoothRamp((t - 1.05) / (MOON_RAY_REACH - 1.05));
|
|
447
|
+
const phi = Math.atan2(
|
|
448
|
+
(nx * ux) + (ny * uy) + (nz * uz),
|
|
449
|
+
(nx * tx) + (ny * ty) + (nz * tz),
|
|
450
|
+
);
|
|
451
|
+
const streak = 0.5 + (0.5 * Math.cos((crater.lobes * phi) + crater.phase));
|
|
452
|
+
factor[index] *= 1 + (MOON_RAY_STRENGTH * radial * (streak ** 2.5));
|
|
453
|
+
},
|
|
454
|
+
width: mapWidth,
|
|
455
|
+
});
|
|
456
|
+
}
|
|
457
|
+
|
|
458
|
+
// Scalar albedo, its tint, and the projected-area mean over the visible disc.
|
|
459
|
+
// The weight is the Jacobian of (longitude, latitude) -> the orthographic disc
|
|
460
|
+
// coordinates, cos^2(lat) * cos(lon), so `discMean` really is the mean of what
|
|
461
|
+
// a viewer sees rather than the mean of the map's texels.
|
|
462
|
+
const scalar = new Float32Array(texels);
|
|
463
|
+
const tint = new Float32Array(texels * 3);
|
|
464
|
+
let weightedSum = 0;
|
|
465
|
+
let weightTotal = 0;
|
|
466
|
+
for (let index = 0; index < texels; index += 1) {
|
|
467
|
+
const base = index * 3;
|
|
468
|
+
const nx = directions[base];
|
|
469
|
+
const ny = directions[base + 1];
|
|
470
|
+
const nz = directions[base + 2];
|
|
471
|
+
const highland = MOON_HIGHLAND_ALBEDO
|
|
472
|
+
* (1 + (0.16 * fbm3(namespace + 1, nx * 2.5, ny * 2.5, nz * 2.5, 3)));
|
|
473
|
+
const basalt = MOON_MARE_ALBEDO
|
|
474
|
+
* (1 + (0.2 * fbm3(namespace + 2, nx * 4.5, ny * 4.5, nz * 4.5, 2)));
|
|
475
|
+
const mask = clamp01(mare[index]);
|
|
476
|
+
const relief = Math.min(Math.max(factor[index], MOON_FEATURE_FLOOR), MOON_FEATURE_CEILING);
|
|
477
|
+
const value = Math.max(((highland * (1 - mask)) + (basalt * mask)) * relief, 0);
|
|
478
|
+
scalar[index] = value;
|
|
479
|
+
for (let channel = 0; channel < 3; channel += 1) {
|
|
480
|
+
tint[base + channel] = MOON_HIGHLAND_TINT[channel]
|
|
481
|
+
+ ((MOON_MARE_TINT[channel] - MOON_HIGHLAND_TINT[channel]) * mask);
|
|
482
|
+
}
|
|
483
|
+
// cos(lon) > 0 is the near side; cos^2(lat) is the rest of the Jacobian.
|
|
484
|
+
const cosLatSquared = 1 - (ny * ny);
|
|
485
|
+
const cosLon = cosLatSquared <= 1e-9 ? 0 : nz / Math.sqrt(cosLatSquared);
|
|
486
|
+
if (cosLon > 0) {
|
|
487
|
+
const weight = cosLatSquared * cosLon;
|
|
488
|
+
weightedSum += value * weight;
|
|
489
|
+
weightTotal += weight;
|
|
490
|
+
}
|
|
491
|
+
}
|
|
492
|
+
|
|
493
|
+
const discMean = weightTotal > 0 ? weightedSum / weightTotal : 0;
|
|
494
|
+
const scale = discMean > 0 ? MOON_ALBEDO_DISC_MEAN / discMean : 0;
|
|
495
|
+
const data = new Uint8Array(texels * 4);
|
|
496
|
+
let peak = 0;
|
|
497
|
+
for (let index = 0; index < texels; index += 1) {
|
|
498
|
+
const base = index * 3;
|
|
499
|
+
const target = index * 4;
|
|
500
|
+
for (let channel = 0; channel < 3; channel += 1) {
|
|
501
|
+
const value = scalar[index] * scale * tint[base + channel];
|
|
502
|
+
if (value > peak) peak = value;
|
|
503
|
+
data[target + channel] = encodeUnorm8(value);
|
|
504
|
+
}
|
|
505
|
+
data[target + 3] = 255;
|
|
506
|
+
}
|
|
507
|
+
|
|
508
|
+
return { data, discMean, height: mapHeight, peak, seed: seedValue, width: mapWidth };
|
|
509
|
+
}
|
|
510
|
+
|
|
511
|
+
/**
|
|
512
|
+
* The lunar albedo map as a texture.
|
|
513
|
+
*
|
|
514
|
+
* `NoColorSpace` and linear values: this is a generated albedo field, not an
|
|
515
|
+
* sRGB photograph, so nothing decodes it. `wrapS` repeats because longitude
|
|
516
|
+
* wraps; `wrapT` clamps because latitude does not — a repeat there would fold
|
|
517
|
+
* the north pole onto the south one.
|
|
518
|
+
*/
|
|
519
|
+
export function createMoonAlbedoTexture(options = {}) {
|
|
520
|
+
const baked = createMoonAlbedoData(options);
|
|
521
|
+
const map = new THREE.DataTexture(
|
|
522
|
+
baked.data,
|
|
523
|
+
baked.width,
|
|
524
|
+
baked.height,
|
|
525
|
+
THREE.RGBAFormat,
|
|
526
|
+
THREE.UnsignedByteType,
|
|
527
|
+
);
|
|
528
|
+
map.name = `ToonLabMoonAlbedo${baked.width}x${baked.height}`;
|
|
529
|
+
map.colorSpace = THREE.NoColorSpace;
|
|
530
|
+
map.wrapS = THREE.RepeatWrapping;
|
|
531
|
+
map.wrapT = THREE.ClampToEdgeWrapping;
|
|
532
|
+
// Both filters are Linear because a DataTexture defaults to Nearest, which the
|
|
533
|
+
// node builders classify as unfilterable: the tap would compile to a
|
|
534
|
+
// `textureLoad` with no sampler, and swapping a filtered map in later cannot
|
|
535
|
+
// rebuild the program (a TextureNode carries no cache key). The same trap the
|
|
536
|
+
// cloud cirrus deck documents.
|
|
537
|
+
map.magFilter = THREE.LinearFilter;
|
|
538
|
+
map.minFilter = THREE.LinearFilter;
|
|
539
|
+
map.generateMipmaps = false;
|
|
540
|
+
map.unpackAlignment = 1;
|
|
541
|
+
map.needsUpdate = true;
|
|
542
|
+
map.userData.toonlabMoonAlbedo = {
|
|
543
|
+
discMean: baked.discMean,
|
|
544
|
+
height: baked.height,
|
|
545
|
+
kind: 'moon-albedo',
|
|
546
|
+
normalisedDiscMean: MOON_ALBEDO_DISC_MEAN,
|
|
547
|
+
peak: baked.peak,
|
|
548
|
+
seed: baked.seed,
|
|
549
|
+
version: MOON_ALBEDO_SCHEMA_VERSION,
|
|
550
|
+
width: baked.width,
|
|
551
|
+
};
|
|
552
|
+
return map;
|
|
553
|
+
}
|
|
554
|
+
|
|
555
|
+
const moonAlbedoCache = new Map();
|
|
556
|
+
|
|
557
|
+
/**
|
|
558
|
+
* Cached lunar albedo, keyed by size and seed. The on-screen night sky and an
|
|
559
|
+
* env-map bake share one map instead of baking two identical ones, which is why
|
|
560
|
+
* `createNightSky` never disposes it — `disposeMoonAlbedoTextures()` does, the
|
|
561
|
+
* same contract as the cloud noise volumes.
|
|
562
|
+
*/
|
|
563
|
+
export function getMoonAlbedoTexture(options = {}) {
|
|
564
|
+
const width = Math.max(8, Math.round(finiteNumber(options.width) ?? MOON_ALBEDO_PLAN.width));
|
|
565
|
+
const height = Math.max(4, Math.round(finiteNumber(options.height) ?? MOON_ALBEDO_PLAN.height));
|
|
566
|
+
const seed = (finiteNumber(options.seed) ?? MOON_ALBEDO_PLAN.seed) >>> 0;
|
|
567
|
+
const key = `${width}x${height}:${seed}`;
|
|
568
|
+
const cached = moonAlbedoCache.get(key);
|
|
569
|
+
if (cached) return cached;
|
|
570
|
+
const map = createMoonAlbedoTexture({ height, seed, width });
|
|
571
|
+
moonAlbedoCache.set(key, map);
|
|
572
|
+
return map;
|
|
573
|
+
}
|
|
574
|
+
|
|
575
|
+
/** Releases every cached lunar albedo map. */
|
|
576
|
+
export function disposeMoonAlbedoTextures() {
|
|
577
|
+
for (const map of moonAlbedoCache.values()) map.dispose();
|
|
578
|
+
moonAlbedoCache.clear();
|
|
579
|
+
}
|
|
580
|
+
|
|
581
|
+
// ---------------------------------------------------------------------------
|
|
582
|
+
// Shading nodes
|
|
583
|
+
// ---------------------------------------------------------------------------
|
|
584
|
+
|
|
585
|
+
// The drawn disc's rim needs a few pixels of falloff or it aliases into a
|
|
586
|
+
// polygon at 45-odd pixels across. Fraction of the squared radius it spans.
|
|
587
|
+
const MOON_RIM_FADE = 0.12;
|
|
588
|
+
|
|
589
|
+
// Lommel-Seeliger at zero phase. Incidence equals emission when the light is
|
|
590
|
+
// behind the viewer, so mu0 / (mu0 + mu) is exactly one half everywhere on the
|
|
591
|
+
// disc — which is the analytic statement of the thing everyone notices about a
|
|
592
|
+
// full moon: it is flat, not a shaded ball.
|
|
593
|
+
export const LOMMEL_SEELIGER_AT_FULL = 0.5;
|
|
594
|
+
|
|
595
|
+
/** Rim falloff in normalised squared radius, 1 at the centre, 0 at the edge. */
|
|
596
|
+
function moonRimProfile(radiusSquared) {
|
|
597
|
+
const rho2 = clamp01(radiusSquared);
|
|
598
|
+
return 1 - smoothRamp((rho2 - (1 - MOON_RIM_FADE)) / MOON_RIM_FADE);
|
|
599
|
+
}
|
|
600
|
+
|
|
601
|
+
/**
|
|
602
|
+
* Mean disc radiance of a full moon at the documented default moon block, in
|
|
603
|
+
* multiples of `moonColor`.
|
|
604
|
+
*
|
|
605
|
+
* Calibrated so the default moon keeps visible texture after ACES tone mapping.
|
|
606
|
+
* The map's peak-to-mean ratio over the disc is about 1.8, so a mean radiance
|
|
607
|
+
* near 0.3 preserves highlight headroom.
|
|
608
|
+
*
|
|
609
|
+
* The alternative reading of `moon.discBrightness` — that 9.0 IS the disc's
|
|
610
|
+
* radiance — is ruled out by the same frame: 9 tone maps to 0.977, a clipped
|
|
611
|
+
* white circle with every feature erased.
|
|
612
|
+
*/
|
|
613
|
+
export const MOON_DISC_FULL_MEAN_RADIANCE = 0.3;
|
|
614
|
+
|
|
615
|
+
/**
|
|
616
|
+
* Scale that lands a full moon's mean disc radiance on
|
|
617
|
+
* `moonColor * moonIntensity * (moonDiscBrightness / 9) *
|
|
618
|
+
* MOON_DISC_FULL_MEAN_RADIANCE`.
|
|
619
|
+
*
|
|
620
|
+
* Uniform samples in squared radius are uniform in disc area, so the arithmetic
|
|
621
|
+
* mean of the profile is its area average — the same normalisation the sky dome
|
|
622
|
+
* applies to the sun's limb profile. Dividing the profile, the map's mean and the
|
|
623
|
+
* default brightness back out is what makes `moon.discBrightness` a dial whose
|
|
624
|
+
* default means something and whose doubling doubles the disc.
|
|
625
|
+
*/
|
|
626
|
+
export const MOON_DISC_NORMALISATION = (() => {
|
|
627
|
+
const samples = 4096;
|
|
628
|
+
let total = 0;
|
|
629
|
+
for (let i = 0; i < samples; i += 1) {
|
|
630
|
+
total += LOMMEL_SEELIGER_AT_FULL * moonRimProfile((i + 0.5) / samples);
|
|
631
|
+
}
|
|
632
|
+
const profileMean = total / samples;
|
|
633
|
+
return MOON_DISC_FULL_MEAN_RADIANCE
|
|
634
|
+
/ (profileMean * MOON_ALBEDO_DISC_MEAN * DEFAULT_MOON_PARAMS.discBrightness);
|
|
635
|
+
})();
|
|
636
|
+
|
|
637
|
+
/**
|
|
638
|
+
* Panorama UV for a direction in the celestial frame.
|
|
639
|
+
*
|
|
640
|
+
* three.js' `equirectUV` with u turned a quarter of a revolution, so celestial
|
|
641
|
+
* longitude 0 — the frame's +Z, where `starRotationAt` parks the midnight moon —
|
|
642
|
+
* lands at the middle of the map. u leaves [0, 1] either side of that, which is
|
|
643
|
+
* why the panorama is forced to `RepeatWrapping` in S; v is clamped at the poles,
|
|
644
|
+
* which is the top and bottom edge of the image.
|
|
645
|
+
*/
|
|
646
|
+
export function starPanoramaUVNode(celestialDir) {
|
|
647
|
+
const direction = normalize(celestialDir);
|
|
648
|
+
const u = direction.z.atan(direction.x).mul(1 / TAU).add(0.25);
|
|
649
|
+
const v = direction.y.clamp(-1, 1).asin().mul(1 / Math.PI).add(0.5);
|
|
650
|
+
return vec2(u, v);
|
|
651
|
+
}
|
|
652
|
+
|
|
653
|
+
/**
|
|
654
|
+
* Lunar-surface UV for a disc-space normal.
|
|
655
|
+
*
|
|
656
|
+
* Longitude 0 is the sub-observer point (disc-space +z, straight at the viewer)
|
|
657
|
+
* and latitude runs to the celestial pole, so a published lunar map's centre
|
|
658
|
+
* lands at the centre of the disc. Lunar east is to the viewer's right, matching
|
|
659
|
+
* the IAU convention for how the Moon appears from Earth.
|
|
660
|
+
*/
|
|
661
|
+
export function moonSurfaceUVNode(normal) {
|
|
662
|
+
const u = normal.x.atan(normal.z).mul(1 / TAU).add(0.5);
|
|
663
|
+
const v = normal.y.clamp(-1, 1).asin().mul(1 / Math.PI).add(0.5);
|
|
664
|
+
return vec2(u, v);
|
|
665
|
+
}
|
|
666
|
+
|
|
667
|
+
/**
|
|
668
|
+
* Star radiance for one panorama sample.
|
|
669
|
+
*
|
|
670
|
+
* `nightFactor` is the clock's `skyDarkness`, which is what fades the field in
|
|
671
|
+
* across twilight: 0 while the sun is up, 1 once it is 12 degrees down.
|
|
672
|
+
*/
|
|
673
|
+
export function starRadianceNode({
|
|
674
|
+
intensity, nightFactor, panorama, style = null, uvNode,
|
|
675
|
+
}) {
|
|
676
|
+
const source = panorama.sample(uvNode).rgb.toVar();
|
|
677
|
+
const starField = style?.starField;
|
|
678
|
+
const styled = starField
|
|
679
|
+
? (() => {
|
|
680
|
+
const luminance = dot(source, vec3(0.2126, 0.7152, 0.0722)).toVar();
|
|
681
|
+
const threshold = max(starField.pointThreshold, 0).toVar();
|
|
682
|
+
const pointMask = smoothstep(
|
|
683
|
+
threshold,
|
|
684
|
+
threshold.add(max(starField.pointSoftness, 0.005)),
|
|
685
|
+
luminance,
|
|
686
|
+
).toVar();
|
|
687
|
+
const pointCore = pointMask.mul(pointMask).toVar();
|
|
688
|
+
const shaped = source.mul(mix(
|
|
689
|
+
max(starField.diffuseStrength, 0),
|
|
690
|
+
max(starField.pointBrightness, 0),
|
|
691
|
+
pointCore,
|
|
692
|
+
)).toVar();
|
|
693
|
+
const amount = saturate(
|
|
694
|
+
style.enabled
|
|
695
|
+
.mul(starField.enabled)
|
|
696
|
+
.mul(style.amount)
|
|
697
|
+
.mul(starField.amount),
|
|
698
|
+
);
|
|
699
|
+
return mix(source, shaped, amount);
|
|
700
|
+
})()
|
|
701
|
+
: source;
|
|
702
|
+
return styled
|
|
703
|
+
.mul(max(float(intensity), 0))
|
|
704
|
+
.mul(saturate(float(nightFactor)));
|
|
705
|
+
}
|
|
706
|
+
|
|
707
|
+
/**
|
|
708
|
+
* The moon disc's radiance along one view direction, in the celestial frame.
|
|
709
|
+
*
|
|
710
|
+
* Geometry. `moonAngularSize` is an angular radius as `1 - cos(theta)`, the same
|
|
711
|
+
* convention as `sun.discSize`, so the disc's edge is at
|
|
712
|
+
* `sin(theta) = sqrt(size * (2 - size))`. The view direction's component
|
|
713
|
+
* perpendicular to the moon, divided by that, is the point's offset across the
|
|
714
|
+
* disc in units of lunar radii — which is the orthographic projection of the
|
|
715
|
+
* lunar sphere, exact to the half percent at 400000 km, so the sphere normal is
|
|
716
|
+
* just `(x, y, sqrt(1 - x^2 - y^2))`.
|
|
717
|
+
*
|
|
718
|
+
* The disc frame has +z at the viewer, +x along the celestial equator and +y at
|
|
719
|
+
* the north celestial pole. The moon rides declination 0 in this system, so that
|
|
720
|
+
* +x is always well defined, and the frame turns with the sky: the face and the
|
|
721
|
+
* terminator rotate through the night the way a real moon's do.
|
|
722
|
+
*
|
|
723
|
+
* Phase. `moonPhaseTrig` is (sin, cos) of the phase angle, which the clock hands
|
|
724
|
+
* over as the sub-solar direction `vec3(sin, 0, cos)` in exactly this frame, so
|
|
725
|
+
* the terminator is a plane through the disc's centre and phase never moves the
|
|
726
|
+
* moon. Brightness across the lit part is Lommel-Seeliger, `mu0 / (mu0 + mu)` —
|
|
727
|
+
* the standard first-order lunar photometric law, and the reason a gibbous moon
|
|
728
|
+
* stays bright to its limb where a Lambert ball would fall off.
|
|
729
|
+
*
|
|
730
|
+
* The whole term also scales by the lit fraction, per the reference's rule that
|
|
731
|
+
* all three moonshine terms do. That is not double-counting the terminator: the
|
|
732
|
+
* real Moon's flux falls off far faster than its lit fraction (a quarter moon is
|
|
733
|
+
* about a twelfth of a full one, not a half), and Lommel-Seeliger alone only
|
|
734
|
+
* accounts for part of that gap.
|
|
735
|
+
*
|
|
736
|
+
* Returns `vec4(radiance, coverage)`. The coverage is the disc's own opacity —
|
|
737
|
+
* 1 inside it, 0 outside, rim fade included — and it is not decoration: the moon
|
|
738
|
+
* is a rock, so whatever the panorama has behind it has to be occluded. Without
|
|
739
|
+
* that the unlit half of a crescent is transparent and stars shine through it.
|
|
740
|
+
*
|
|
741
|
+
* `bodyOpacity` scales that coverage, and the composer passes `moonIntensity`
|
|
742
|
+
* into it for one reason: the parameter surface has no "moon off" flag, so
|
|
743
|
+
* `moonIntensity = 0` is how a host removes the moon, and the body has to go with
|
|
744
|
+
* the light. Leaving the coverage at 1 there would punch a black disc out of the
|
|
745
|
+
* star field with nothing drawn in it.
|
|
746
|
+
*/
|
|
747
|
+
export function moonDiscRadianceNode({
|
|
748
|
+
albedo,
|
|
749
|
+
angularSize,
|
|
750
|
+
bodyOpacity = 1,
|
|
751
|
+
celestialMoon,
|
|
752
|
+
celestialView,
|
|
753
|
+
discBrightness,
|
|
754
|
+
illumination,
|
|
755
|
+
moonRadiance,
|
|
756
|
+
phaseTrig,
|
|
757
|
+
}) {
|
|
758
|
+
const moonDir = normalize(celestialMoon).toVar();
|
|
759
|
+
const viewDir = normalize(celestialView).toVar();
|
|
760
|
+
|
|
761
|
+
// +z at the viewer. +x from the celestial pole, which is (0, 1, 0) here
|
|
762
|
+
// because this frame is the one `starRotation` maps into. The alternate
|
|
763
|
+
// tangent covers a moon parked exactly on the pole — unreachable on a
|
|
764
|
+
// declination-0 arc, but a NaN there would take the whole frame with it.
|
|
765
|
+
const discZ = moonDir.negate().toVar();
|
|
766
|
+
const poleTangent = cross(vec3(0, 1, 0), discZ).toVar();
|
|
767
|
+
const alternate = cross(vec3(0, 0, 1), discZ);
|
|
768
|
+
const degenerate = smoothstep(1e-3, 1e-2, poleTangent.length()).oneMinus();
|
|
769
|
+
const discX = normalize(poleTangent.mul(degenerate.oneMinus()).add(alternate.mul(degenerate)))
|
|
770
|
+
.toVar();
|
|
771
|
+
const discY = cross(discZ, discX).toVar();
|
|
772
|
+
|
|
773
|
+
const size = max(float(angularSize), 1e-7).toVar();
|
|
774
|
+
const sinEdge = sqrt(size.mul(float(2).sub(size))).toVar();
|
|
775
|
+
const cosMoon = dot(viewDir, moonDir).toVar();
|
|
776
|
+
const offset = viewDir.sub(moonDir.mul(cosMoon)).toVar();
|
|
777
|
+
const planar = vec2(
|
|
778
|
+
dot(offset, discX).div(sinEdge),
|
|
779
|
+
dot(offset, discY).div(sinEdge),
|
|
780
|
+
).toVar();
|
|
781
|
+
const radiusSquared = dot(planar, planar).toVar();
|
|
782
|
+
const surface = vec3(planar, sqrt(saturate(radiusSquared.oneMinus()))).toVar();
|
|
783
|
+
|
|
784
|
+
// Lommel-Seeliger. The epsilon only guards the limb, where incidence and
|
|
785
|
+
// emission both vanish; the rim fade has already reached zero there.
|
|
786
|
+
const sunward = vec3(phaseTrig.x, 0, phaseTrig.y);
|
|
787
|
+
const incidence = saturate(dot(surface, sunward)).toVar();
|
|
788
|
+
const emission = surface.z.toVar();
|
|
789
|
+
const photometric = incidence.div(incidence.add(emission).add(1e-4));
|
|
790
|
+
|
|
791
|
+
// rho^2 keeps growing outside the disc, so the fade reaching 0 at 1 is most of
|
|
792
|
+
// the mask — nothing leaks in from the sky around the moon.
|
|
793
|
+
//
|
|
794
|
+
// The hemisphere gate is the rest of it, and it is not optional: the tangential
|
|
795
|
+
// offset is symmetric under `viewDir -> -viewDir`, so rho^2 returns to 0 at the
|
|
796
|
+
// moon's ANTIPODE as well. Without this the module drew a second, fully lit moon
|
|
797
|
+
// exactly where the sun is — which the GPU probe found by measuring the frame
|
|
798
|
+
// pointed away from the moon and reading back a full disc.
|
|
799
|
+
const facing = step(float(0), cosMoon);
|
|
800
|
+
const rim = smoothstep(1 - MOON_RIM_FADE, 1, radiusSquared).oneMinus().mul(facing).toVar();
|
|
801
|
+
|
|
802
|
+
const radiance = moonRadiance
|
|
803
|
+
.mul(max(float(discBrightness), 0))
|
|
804
|
+
.mul(albedo.sample(moonSurfaceUVNode(surface)).rgb)
|
|
805
|
+
.mul(photometric.mul(MOON_DISC_NORMALISATION))
|
|
806
|
+
.mul(saturate(float(illumination)))
|
|
807
|
+
.mul(rim);
|
|
808
|
+
return vec4(radiance, rim.mul(saturate(float(bodyOpacity))));
|
|
809
|
+
}
|
|
810
|
+
|
|
811
|
+
/**
|
|
812
|
+
* The ambient lift the moon puts on the whole sky — what keeps a clear night
|
|
813
|
+
* from going pitch black.
|
|
814
|
+
*
|
|
815
|
+
* Flat across the sphere by design: it stands in for moonlight already scattered
|
|
816
|
+
* by the whole atmosphere, which is the one part of the night sky that has no
|
|
817
|
+
* direction left in it. Scales by the lit fraction and by how night it is, so it
|
|
818
|
+
* is gone by day and a sliver moon lifts far less than a full one.
|
|
819
|
+
*/
|
|
820
|
+
export function moonAmbientRadianceNode({
|
|
821
|
+
illumination, moonAmbient, moonRadiance, nightFactor,
|
|
822
|
+
}) {
|
|
823
|
+
return moonRadiance
|
|
824
|
+
.mul(saturate(float(moonAmbient)))
|
|
825
|
+
.mul(saturate(float(illumination)))
|
|
826
|
+
.mul(saturate(float(nightFactor)));
|
|
827
|
+
}
|
|
828
|
+
|
|
829
|
+
// ---------------------------------------------------------------------------
|
|
830
|
+
// The night sky
|
|
831
|
+
// ---------------------------------------------------------------------------
|
|
832
|
+
|
|
833
|
+
/**
|
|
834
|
+
* Adopts a host panorama, correcting what the documented format requires.
|
|
835
|
+
*
|
|
836
|
+
* A texture straight out of `THREE.TextureLoader` arrives unlabelled and clamped
|
|
837
|
+
* on both axes, which for an equirect panorama means an sRGB JPEG read as linear
|
|
838
|
+
* and a visible seam at longitude 0. Those two are set silently because the
|
|
839
|
+
* format states them ("sRGB-encoded", "X = longitude 0..2pi"); a point-sampled
|
|
840
|
+
* map warns as well as being fixed, because the shader was compiled against a
|
|
841
|
+
* filterable texture and cannot be rebuilt for a swap.
|
|
842
|
+
*/
|
|
843
|
+
function adoptPanorama(map, label) {
|
|
844
|
+
if (!map?.isTexture) return map;
|
|
845
|
+
if (map.colorSpace === THREE.NoColorSpace) {
|
|
846
|
+
map.colorSpace = THREE.SRGBColorSpace;
|
|
847
|
+
map.needsUpdate = true;
|
|
848
|
+
}
|
|
849
|
+
if (map.wrapS !== THREE.RepeatWrapping) {
|
|
850
|
+
map.wrapS = THREE.RepeatWrapping;
|
|
851
|
+
map.needsUpdate = true;
|
|
852
|
+
}
|
|
853
|
+
if (map.wrapT !== THREE.ClampToEdgeWrapping) {
|
|
854
|
+
map.wrapT = THREE.ClampToEdgeWrapping;
|
|
855
|
+
map.needsUpdate = true;
|
|
856
|
+
}
|
|
857
|
+
if (map.magFilter === THREE.NearestFilter || map.minFilter === THREE.NearestFilter) {
|
|
858
|
+
console.warn(
|
|
859
|
+
`[nightSky] ${label} "${map.name || 'unnamed'}" was point-sampled; filters were set to `
|
|
860
|
+
+ 'LinearFilter so the panorama matches the compiled shader.',
|
|
861
|
+
);
|
|
862
|
+
map.magFilter = THREE.LinearFilter;
|
|
863
|
+
map.minFilter = map.generateMipmaps ? THREE.LinearMipmapLinearFilter : THREE.LinearFilter;
|
|
864
|
+
map.needsUpdate = true;
|
|
865
|
+
}
|
|
866
|
+
return map;
|
|
867
|
+
}
|
|
868
|
+
|
|
869
|
+
/**
|
|
870
|
+
* A swappable texture binding that remembers whether it may dispose what it
|
|
871
|
+
* holds. Both panoramas need the same three rules — never dispose a host's
|
|
872
|
+
* texture, always dispose one handed over, never dispose the fallback — and one
|
|
873
|
+
* copy of them is one copy of the bug.
|
|
874
|
+
*/
|
|
875
|
+
function createTextureSlot({ adopt, fallback, label }) {
|
|
876
|
+
const node = texture(fallback);
|
|
877
|
+
let current = null;
|
|
878
|
+
let owned = false;
|
|
879
|
+
return {
|
|
880
|
+
node,
|
|
881
|
+
get current() {
|
|
882
|
+
return current;
|
|
883
|
+
},
|
|
884
|
+
get owned() {
|
|
885
|
+
return owned;
|
|
886
|
+
},
|
|
887
|
+
set(next, ownsNext = false) {
|
|
888
|
+
const map = next?.isTexture ? next : null;
|
|
889
|
+
if (map === current) {
|
|
890
|
+
// Re-declaring ownership of the texture already held must not dispose
|
|
891
|
+
// the thing it is declaring ownership of.
|
|
892
|
+
owned = owned || Boolean(ownsNext);
|
|
893
|
+
return current;
|
|
894
|
+
}
|
|
895
|
+
const previous = current;
|
|
896
|
+
const previouslyOwned = owned;
|
|
897
|
+
current = map;
|
|
898
|
+
owned = Boolean(map && ownsNext);
|
|
899
|
+
node.value = map ? adopt(map, label) : fallback;
|
|
900
|
+
if (previous && previouslyOwned) previous.dispose();
|
|
901
|
+
return current;
|
|
902
|
+
},
|
|
903
|
+
dispose() {
|
|
904
|
+
if (current && owned) current.dispose();
|
|
905
|
+
current = null;
|
|
906
|
+
owned = false;
|
|
907
|
+
node.value = fallback;
|
|
908
|
+
},
|
|
909
|
+
};
|
|
910
|
+
}
|
|
911
|
+
|
|
912
|
+
/**
|
|
913
|
+
* Builds the night sky.
|
|
914
|
+
*
|
|
915
|
+
* `timeOfDay` is required: every celestial term here reads the clock's driven
|
|
916
|
+
* uniforms (`starRotation`, `skyDarkness`, `moonDirection`, `moonPhaseTrig`,
|
|
917
|
+
* `moonPhaseIllumination`) and its moon block, and a night sky with no clock
|
|
918
|
+
* would be a night sky that cannot know what time it is.
|
|
919
|
+
*
|
|
920
|
+
* `texture` is the star panorama, which is NOT bundled. Without one the panorama
|
|
921
|
+
* samples a 1x1 black stand-in and the star term is exactly zero — the
|
|
922
|
+
* documented "omit it and the night sky renders black", as a no-op rather than an
|
|
923
|
+
* error. The moon does not depend on it: the disc and the ambient lift come from
|
|
924
|
+
* the clock, so a host with no starmap still gets a moon rather than an empty sky
|
|
925
|
+
* with a moon-shaped hole in it.
|
|
926
|
+
*
|
|
927
|
+
* The option names follow the reference's `nightSky` option bag — `texture`,
|
|
928
|
+
* `moonTexture`, `radius`, `intensity` — so a SkySystem can pass one straight
|
|
929
|
+
* through. `params` is the serialized `nightSky` block instead, and `intensity`
|
|
930
|
+
* wins over it because it is the more specific of the two.
|
|
931
|
+
*/
|
|
932
|
+
export function createNightSky({
|
|
933
|
+
intensity: initialIntensity = undefined,
|
|
934
|
+
moonAlbedoOptions = MOON_ALBEDO_PLAN,
|
|
935
|
+
moonTexture = null,
|
|
936
|
+
name = 'ToonLabNightSky',
|
|
937
|
+
ownsMoonTexture = false,
|
|
938
|
+
ownsTexture = false,
|
|
939
|
+
params = {},
|
|
940
|
+
radius = NIGHT_SKY_DEFAULT_RADIUS,
|
|
941
|
+
style = null,
|
|
942
|
+
texture: starTexture = null,
|
|
943
|
+
timeOfDay,
|
|
944
|
+
} = {}) {
|
|
945
|
+
if (!timeOfDay?.starRotation || !timeOfDay?.moonDirection || !timeOfDay?.moonPhaseTrig) {
|
|
946
|
+
throw new TypeError('createNightSky needs a TimeOfDay clock.');
|
|
947
|
+
}
|
|
948
|
+
|
|
949
|
+
const intensity = uniform(DEFAULT_NIGHT_SKY_PARAMS.intensity);
|
|
950
|
+
|
|
951
|
+
// 1x1 black, so an absent panorama contributes exactly nothing while the graph
|
|
952
|
+
// stays the shape it compiled as. Filterable for the same reason the moon map
|
|
953
|
+
// is: an unfilterable stand-in would compile a `textureLoad` that a later swap
|
|
954
|
+
// could not undo.
|
|
955
|
+
const starFallback = new THREE.DataTexture(
|
|
956
|
+
new Uint8Array([0, 0, 0, 255]),
|
|
957
|
+
1,
|
|
958
|
+
1,
|
|
959
|
+
THREE.RGBAFormat,
|
|
960
|
+
THREE.UnsignedByteType,
|
|
961
|
+
);
|
|
962
|
+
starFallback.name = `${name}StarFallback`;
|
|
963
|
+
starFallback.colorSpace = THREE.NoColorSpace;
|
|
964
|
+
starFallback.wrapS = THREE.RepeatWrapping;
|
|
965
|
+
starFallback.wrapT = THREE.ClampToEdgeWrapping;
|
|
966
|
+
starFallback.magFilter = THREE.LinearFilter;
|
|
967
|
+
starFallback.minFilter = THREE.LinearFilter;
|
|
968
|
+
starFallback.generateMipmaps = false;
|
|
969
|
+
starFallback.unpackAlignment = 1;
|
|
970
|
+
starFallback.needsUpdate = true;
|
|
971
|
+
|
|
972
|
+
const stars = createTextureSlot({
|
|
973
|
+
adopt: adoptPanorama,
|
|
974
|
+
fallback: starFallback,
|
|
975
|
+
label: 'Star panorama',
|
|
976
|
+
});
|
|
977
|
+
stars.set(starTexture, ownsTexture);
|
|
978
|
+
|
|
979
|
+
// The generated map is the fallback rather than a slot value, so it is the
|
|
980
|
+
// shared cached bake and `dispose()` leaves it alone; a host override goes
|
|
981
|
+
// through the slot and follows the ownership flag it was handed.
|
|
982
|
+
const bakedMoon = getMoonAlbedoTexture(moonAlbedoOptions);
|
|
983
|
+
const moon = createTextureSlot({
|
|
984
|
+
adopt: adoptPanorama,
|
|
985
|
+
fallback: bakedMoon,
|
|
986
|
+
label: 'Moon albedo',
|
|
987
|
+
});
|
|
988
|
+
moon.set(moonTexture, ownsMoonTexture);
|
|
989
|
+
|
|
990
|
+
/**
|
|
991
|
+
* Linear HDR radiance the night sky ADDS along a world-space view direction.
|
|
992
|
+
*
|
|
993
|
+
* Exported on the returned object so the env-map bake and water reflections
|
|
994
|
+
* compose one definition of "what the night sky looks like this frame" instead
|
|
995
|
+
* of a second one that drifts, the same arrangement as the dome's
|
|
996
|
+
* `skyRadiance`.
|
|
997
|
+
*/
|
|
998
|
+
const radianceNode = Fn(([viewDir]) => {
|
|
999
|
+
const direction = normalize(viewDir).toVar();
|
|
1000
|
+
// The panorama is a sky, not a world-space sphere painted through the
|
|
1001
|
+
// ground. Fade every night term out just below the real horizon so stars,
|
|
1002
|
+
// the moon, and ambient night lift cannot appear under the scene floor.
|
|
1003
|
+
const skyMask = smoothstep(-0.02, 0.03, direction.y).toVar();
|
|
1004
|
+
// One rotation, then everything celestial is in one frame: the panorama's
|
|
1005
|
+
// longitude, the pole the disc's frame is built from, and the moon. A
|
|
1006
|
+
// rotation preserves dot products, so the disc's angular mask is the same as
|
|
1007
|
+
// it would be in world space.
|
|
1008
|
+
const celestialView = timeOfDay.starRotation.mul(direction).toVar();
|
|
1009
|
+
const celestialMoon = timeOfDay.starRotation.mul(timeOfDay.moonDirection).toVar();
|
|
1010
|
+
const night = saturate(timeOfDay.skyDarkness).toVar();
|
|
1011
|
+
const illumination = saturate(timeOfDay.moonPhaseIllumination).toVar();
|
|
1012
|
+
const moonRadiance = timeOfDay.moonColor.mul(max(timeOfDay.moonIntensity, 0)).toVar();
|
|
1013
|
+
|
|
1014
|
+
// Not faded by `skyDarkness`: the disc is an object, not a night term. A moon
|
|
1015
|
+
// a few degrees up in civil twilight is plainly visible, and the atmosphere's
|
|
1016
|
+
// own radiance is what washes it out when the sun is higher.
|
|
1017
|
+
const disc = moonDiscRadianceNode({
|
|
1018
|
+
albedo: moon.node,
|
|
1019
|
+
angularSize: timeOfDay.moonAngularSize,
|
|
1020
|
+
bodyOpacity: timeOfDay.moonIntensity,
|
|
1021
|
+
celestialMoon,
|
|
1022
|
+
celestialView,
|
|
1023
|
+
discBrightness: timeOfDay.moonDiscBrightness,
|
|
1024
|
+
illumination,
|
|
1025
|
+
moonRadiance,
|
|
1026
|
+
phaseTrig: timeOfDay.moonPhaseTrig,
|
|
1027
|
+
}).toVar();
|
|
1028
|
+
|
|
1029
|
+
// The moon occludes the panorama behind it — `disc.a` is its coverage. The
|
|
1030
|
+
// ambient lift does not get occluded: it stands for moonlight already
|
|
1031
|
+
// scattered in the air between the viewer and the moon, which is in front.
|
|
1032
|
+
const starStyle = style?.timePalette;
|
|
1033
|
+
const starStyleAmount = starStyle
|
|
1034
|
+
? saturate(style.enabled.mul(starStyle.enabled).mul(starStyle.nightEnabled))
|
|
1035
|
+
: float(0);
|
|
1036
|
+
const starBrightness = starStyle
|
|
1037
|
+
? mix(float(1), max(starStyle.nightStars, 0), starStyleAmount)
|
|
1038
|
+
: float(1);
|
|
1039
|
+
const starTerm = starRadianceNode({
|
|
1040
|
+
intensity,
|
|
1041
|
+
nightFactor: night,
|
|
1042
|
+
panorama: stars.node,
|
|
1043
|
+
style,
|
|
1044
|
+
uvNode: starPanoramaUVNode(celestialView),
|
|
1045
|
+
}).mul(disc.a.oneMinus()).mul(starBrightness);
|
|
1046
|
+
|
|
1047
|
+
const ambientTerm = moonAmbientRadianceNode({
|
|
1048
|
+
illumination,
|
|
1049
|
+
moonAmbient: timeOfDay.moonAmbient,
|
|
1050
|
+
moonRadiance,
|
|
1051
|
+
nightFactor: night,
|
|
1052
|
+
});
|
|
1053
|
+
|
|
1054
|
+
return max(starTerm.add(disc.rgb).add(ambientTerm), vec3(0)).mul(skyMask);
|
|
1055
|
+
});
|
|
1056
|
+
|
|
1057
|
+
// Additive, because this is radiance on top of the atmosphere rather than a
|
|
1058
|
+
// replacement for it. `depthTest: false` keeps the sphere off the depth
|
|
1059
|
+
// buffer, while the host camera must still include `radius` inside its far
|
|
1060
|
+
// plane because clip-space clipping happens first. The render layer holds it
|
|
1061
|
+
// behind the scene.
|
|
1062
|
+
const material = new MeshBasicNodeMaterial({
|
|
1063
|
+
blending: THREE.AdditiveBlending,
|
|
1064
|
+
depthTest: false,
|
|
1065
|
+
depthWrite: false,
|
|
1066
|
+
side: THREE.BackSide,
|
|
1067
|
+
toneMapped: false,
|
|
1068
|
+
transparent: true,
|
|
1069
|
+
});
|
|
1070
|
+
material.name = name;
|
|
1071
|
+
material.fog = false;
|
|
1072
|
+
// Alpha 1 with three's AdditiveBlending (SrcAlpha, One) is a plain add.
|
|
1073
|
+
material.colorNode = Fn(() => vec4(radianceNode(positionWorld.sub(cameraPosition)), 1))();
|
|
1074
|
+
|
|
1075
|
+
const mesh = new THREE.Mesh(new THREE.SphereGeometry(1, 64, 32), material);
|
|
1076
|
+
mesh.name = name;
|
|
1077
|
+
mesh.frustumCulled = false;
|
|
1078
|
+
mesh.matrixAutoUpdate = false;
|
|
1079
|
+
|
|
1080
|
+
const group = new THREE.Group();
|
|
1081
|
+
group.name = `${name}Root`;
|
|
1082
|
+
group.frustumCulled = false;
|
|
1083
|
+
group.add(mesh);
|
|
1084
|
+
|
|
1085
|
+
// `backgroundOverlay`, the one layer that is both blended and behind every
|
|
1086
|
+
// piece of scene content. `background` is the opaque sky dome's, and an
|
|
1087
|
+
// additive sphere placed there would sort into the wrong draw list — three
|
|
1088
|
+
// separates the lists before it ever looks at an order, which is why
|
|
1089
|
+
// placeInLayer warns about the mismatch instead of silently misplacing it.
|
|
1090
|
+
//
|
|
1091
|
+
// The Group is placed, not the mesh: r185 takes an enclosing Group's
|
|
1092
|
+
// renderOrder as the PRIMARY sort key (projectObject sets groupOrder from it,
|
|
1093
|
+
// and painterSortStable compares groupOrder before renderOrder), so an order on
|
|
1094
|
+
// the mesh alone lets host content inside a group of its own draw behind the
|
|
1095
|
+
// stars.
|
|
1096
|
+
placeInLayer(group, RenderLayer.backgroundOverlay);
|
|
1097
|
+
|
|
1098
|
+
let currentRadius = NIGHT_SKY_DEFAULT_RADIUS;
|
|
1099
|
+
|
|
1100
|
+
const nightSky = {
|
|
1101
|
+
group,
|
|
1102
|
+
material,
|
|
1103
|
+
mesh,
|
|
1104
|
+
timeOfDay,
|
|
1105
|
+
|
|
1106
|
+
/** Star panorama brightness, calibrated for exposure 1.0. */
|
|
1107
|
+
intensity,
|
|
1108
|
+
|
|
1109
|
+
/** Linear HDR radiance the night sky adds along a world-space direction. */
|
|
1110
|
+
radianceNode,
|
|
1111
|
+
|
|
1112
|
+
/** The star panorama, or null when the host has supplied none. */
|
|
1113
|
+
get texture() {
|
|
1114
|
+
return stars.current;
|
|
1115
|
+
},
|
|
1116
|
+
|
|
1117
|
+
/** The lunar albedo map actually bound — the generated bake unless overridden. */
|
|
1118
|
+
get moonTexture() {
|
|
1119
|
+
return moon.current ?? bakedMoon;
|
|
1120
|
+
},
|
|
1121
|
+
|
|
1122
|
+
/** Sphere radius in world units. */
|
|
1123
|
+
get radius() {
|
|
1124
|
+
return currentRadius;
|
|
1125
|
+
},
|
|
1126
|
+
set radius(value) {
|
|
1127
|
+
const next = finiteNumber(value);
|
|
1128
|
+
if (next === null) return;
|
|
1129
|
+
currentRadius = Math.max(1, next);
|
|
1130
|
+
mesh.scale.setScalar(currentRadius);
|
|
1131
|
+
mesh.updateMatrix();
|
|
1132
|
+
},
|
|
1133
|
+
|
|
1134
|
+
/**
|
|
1135
|
+
* Swaps the star panorama at runtime. `ownsNewTexture` hands its disposal
|
|
1136
|
+
* over; without it the host keeps it and this module never disposes it.
|
|
1137
|
+
* `null` returns to the black stand-in, which turns the stars off.
|
|
1138
|
+
*/
|
|
1139
|
+
setTexture(next, ownsNewTexture = false) {
|
|
1140
|
+
return stars.set(next, ownsNewTexture);
|
|
1141
|
+
},
|
|
1142
|
+
|
|
1143
|
+
/**
|
|
1144
|
+
* Overrides the lunar albedo map. The map must be an equirect lunar surface
|
|
1145
|
+
* with longitude 0 at the centre of the near side and a disc-area mean of
|
|
1146
|
+
* MOON_ALBEDO_DISC_MEAN, which is what the disc's brightness calibration
|
|
1147
|
+
* assumes; `null` returns to the generated bake.
|
|
1148
|
+
*/
|
|
1149
|
+
setMoonTexture(next, ownsNewTexture = false) {
|
|
1150
|
+
return moon.set(next, ownsNewTexture);
|
|
1151
|
+
},
|
|
1152
|
+
|
|
1153
|
+
applyParams(next = {}) {
|
|
1154
|
+
if (next.intensity !== undefined) {
|
|
1155
|
+
const value = finiteNumber(next.intensity);
|
|
1156
|
+
if (value !== null) {
|
|
1157
|
+
// The owner clamps to its own published range, so the live object and
|
|
1158
|
+
// the document layer (which adopts this range as its hard limit)
|
|
1159
|
+
// cannot disagree about what round-trips.
|
|
1160
|
+
const { max: limit, min } = NIGHT_SKY_PARAM_SCHEMA.intensity.range;
|
|
1161
|
+
intensity.value = THREE.MathUtils.clamp(value, min, limit);
|
|
1162
|
+
}
|
|
1163
|
+
}
|
|
1164
|
+
},
|
|
1165
|
+
|
|
1166
|
+
toParams() {
|
|
1167
|
+
return { intensity: intensity.value };
|
|
1168
|
+
},
|
|
1169
|
+
|
|
1170
|
+
/** Re-centres the sphere on the camera. Safe every frame. */
|
|
1171
|
+
update(_delta, camera) {
|
|
1172
|
+
if (camera?.position) group.position.copy(camera.position);
|
|
1173
|
+
return group;
|
|
1174
|
+
},
|
|
1175
|
+
|
|
1176
|
+
dispose() {
|
|
1177
|
+
stars.dispose();
|
|
1178
|
+
moon.dispose();
|
|
1179
|
+
starFallback.dispose();
|
|
1180
|
+
mesh.geometry.dispose();
|
|
1181
|
+
material.dispose();
|
|
1182
|
+
group.removeFromParent();
|
|
1183
|
+
},
|
|
1184
|
+
};
|
|
1185
|
+
|
|
1186
|
+
nightSky.radius = radius;
|
|
1187
|
+
nightSky.applyParams({ ...DEFAULT_NIGHT_SKY_PARAMS, ...params });
|
|
1188
|
+
if (initialIntensity !== undefined) nightSky.applyParams({ intensity: initialIntensity });
|
|
1189
|
+
return nightSky;
|
|
1190
|
+
}
|