@navaramap/three 0.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +8 -0
- package/dist/assets/atmosphere/README.md +1 -0
- package/dist/assets/atmosphere/higher_order_scattering.bin +0 -0
- package/dist/assets/atmosphere/higher_order_scattering.exr +0 -0
- package/dist/assets/atmosphere/irradiance.bin +0 -0
- package/dist/assets/atmosphere/irradiance.exr +0 -0
- package/dist/assets/atmosphere/scattering.bin +0 -0
- package/dist/assets/atmosphere/scattering.exr +0 -0
- package/dist/assets/atmosphere/single_mie_scattering.bin +0 -0
- package/dist/assets/atmosphere/single_mie_scattering.exr +0 -0
- package/dist/assets/atmosphere/stars.bin +0 -0
- package/dist/assets/atmosphere/transmittance.bin +0 -0
- package/dist/assets/atmosphere/transmittance.exr +0 -0
- package/dist/assets/cloud/README.md +1 -0
- package/dist/assets/cloud/local_weather.png +0 -0
- package/dist/assets/cloud/shape.bin +1 -0
- package/dist/assets/cloud/shape_detail.bin +1 -0
- package/dist/assets/cloud/turbulence.png +0 -0
- package/dist/assets/fontWorker-CEJEfRpb.js +2 -0
- package/dist/assets/fontWorker-CEJEfRpb.js.map +1 -0
- package/dist/assets/index-BUB-ijMO.js +12 -0
- package/dist/assets/index-BUB-ijMO.js.map +1 -0
- package/dist/assets/navara_wasm_font_worker_bg-665OLxjy.wasm +0 -0
- package/dist/assets/navara_wasm_worker_bg-BXhKC5bE.wasm +0 -0
- package/dist/assets/noise/README.md +1 -0
- package/dist/assets/noise/stbn.bin +0 -0
- package/dist/assets/water/README.md +3 -0
- package/dist/assets/water/waternormals.jpg +0 -0
- package/dist/index.d.ts +10114 -0
- package/dist/index.js +34481 -0
- package/dist/index.js.map +1 -0
- package/dist/index.umd.cjs +6345 -0
- package/dist/index.umd.cjs.map +1 -0
- package/package.json +95 -0
- package/src/Color.ts +111 -0
- package/src/ShadowMapViewers.ts +49 -0
- package/src/atmosphere.test.ts +76 -0
- package/src/atmosphere.ts +364 -0
- package/src/bufferView.ts +90 -0
- package/src/camera.ts +182 -0
- package/src/concurrency.ts +15 -0
- package/src/constants/assets.ts +30 -0
- package/src/constants/decoder.ts +7 -0
- package/src/constants/index.ts +2 -0
- package/src/core/BaseDesc.ts +142 -0
- package/src/core/BaseHandle.ts +126 -0
- package/src/core/DescRegistry.ts +88 -0
- package/src/core/EffectDesc.ts +343 -0
- package/src/core/EffectDescRegistry.ts +31 -0
- package/src/core/InstancedMeshDesc.ts +413 -0
- package/src/core/LightDesc.ts +216 -0
- package/src/core/LightDescRegistry.ts +32 -0
- package/src/core/MeshDesc.ts +457 -0
- package/src/core/MeshDescRegistry.ts +32 -0
- package/src/core/MeshDescWithSelectiveEffect.ts +129 -0
- package/src/core/Registries.ts +59 -0
- package/src/core/SelectiveEffectRegistry.ts +90 -0
- package/src/core/ViewContext.ts +235 -0
- package/src/core/errors.ts +16 -0
- package/src/core/index.ts +50 -0
- package/src/device.ts +414 -0
- package/src/effects/CustomEffectPass.ts +28 -0
- package/src/effects/copy.ts +10 -0
- package/src/effects/effect.ts +87 -0
- package/src/effects/index.ts +4 -0
- package/src/effects/render.ts +10 -0
- package/src/evaluations/FeatureEvaluator.ts +529 -0
- package/src/evaluations/index.ts +1 -0
- package/src/event/HillshadeContext.test.ts +232 -0
- package/src/event/HillshadeContext.ts +299 -0
- package/src/event/context.ts +279 -0
- package/src/event/feature.ts +357 -0
- package/src/event/featureEvent.ts +81 -0
- package/src/event/features/billboard.ts +30 -0
- package/src/event/features/model.ts +192 -0
- package/src/event/features/modelGpuBytes.test.ts +69 -0
- package/src/event/features/modelGpuBytes.ts +87 -0
- package/src/event/features/point.ts +25 -0
- package/src/event/features/polygon.ts +23 -0
- package/src/event/features/polygonOutline.ts +19 -0
- package/src/event/features/polyline.ts +19 -0
- package/src/event/features/text.ts +71 -0
- package/src/event/hillshade.test.ts +842 -0
- package/src/event/hillshade.ts +588 -0
- package/src/event/index.ts +700 -0
- package/src/event/loaders.ts +53 -0
- package/src/event/tile.ts +19 -0
- package/src/event/worker.ts +999 -0
- package/src/event/workerTaskSettlement.test.ts +243 -0
- package/src/event/workerTaskSettlement.ts +128 -0
- package/src/inMemoryBufferStore.test.ts +60 -0
- package/src/inMemoryBufferStore.ts +67 -0
- package/src/index.iife.ts +11 -0
- package/src/index.ts +2556 -0
- package/src/input.ts +144 -0
- package/src/layer.ts +183 -0
- package/src/layers/effect/FinalCopyEffectDesc.ts +29 -0
- package/src/layers/effect/MRTPassEffectDesc.ts +105 -0
- package/src/layers/effect/README.md +9 -0
- package/src/layers/effect/SelectiveEffectDesc.ts +113 -0
- package/src/layers/effect/SkyEnvMapEffectDesc.ts +58 -0
- package/src/layers/effect/TransparentPassEffectDesc.ts +62 -0
- package/src/layers/effect/index.ts +5 -0
- package/src/layers/index.ts +1 -0
- package/src/layersManager.ts +63 -0
- package/src/light.ts +15 -0
- package/src/loaders/AbortableImageLoader.ts +203 -0
- package/src/loaders/AbortableTextureLoader.ts +74 -0
- package/src/loaders/index.ts +5 -0
- package/src/material/enhancer/DESIGN.md +300 -0
- package/src/material/enhancer/MaterialEnhancer.ts +112 -0
- package/src/material/enhancer/ShaderReplacer.test.ts +114 -0
- package/src/material/enhancer/ShaderReplacer.ts +97 -0
- package/src/material/enhancer/batchTexture.ts +8 -0
- package/src/material/enhancer/index.ts +46 -0
- package/src/material/enhancer/instancedSprite/index.ts +7 -0
- package/src/material/enhancer/instancedSprite/instancedSpriteBaseEnhancer/index.test.ts +214 -0
- package/src/material/enhancer/instancedSprite/instancedSpriteBaseEnhancer/index.ts +134 -0
- package/src/material/enhancer/instancedSprite/instancedSpriteBaseEnhancer/markers.ts +21 -0
- package/src/material/enhancer/instancedSprite/instancedSpriteBaseEnhancer/material.ts +32 -0
- package/src/material/enhancer/instancedSprite/instancedSpriteBaseEnhancer/mutates.test.ts +277 -0
- package/src/material/enhancer/instancedSprite/instancedSpriteBaseEnhancer/mutates.ts +151 -0
- package/src/material/enhancer/instancedSprite/instancedSpriteBaseEnhancer/shader.test.ts +114 -0
- package/src/material/enhancer/instancedSprite/instancedSpriteBaseEnhancer/shader.ts +49 -0
- package/src/material/enhancer/instancedSprite/instancedSpriteBaseEnhancer/state.test.ts +82 -0
- package/src/material/enhancer/instancedSprite/instancedSpriteBaseEnhancer/state.ts +80 -0
- package/src/material/enhancer/instancedSprite/instancedSpriteBaseEnhancer/types.ts +146 -0
- package/src/material/enhancer/instancedSprite/instancedSpriteMaterialEnhancer.ts +105 -0
- package/src/material/enhancer/model/index.ts +25 -0
- package/src/material/enhancer/model/modelBaseEnhancer/index.test.ts +74 -0
- package/src/material/enhancer/model/modelBaseEnhancer/index.ts +110 -0
- package/src/material/enhancer/model/modelBaseEnhancer/markers.ts +27 -0
- package/src/material/enhancer/model/modelBaseEnhancer/material.test.ts +66 -0
- package/src/material/enhancer/model/modelBaseEnhancer/material.ts +44 -0
- package/src/material/enhancer/model/modelBaseEnhancer/mutates.test.ts +84 -0
- package/src/material/enhancer/model/modelBaseEnhancer/mutates.ts +47 -0
- package/src/material/enhancer/model/modelBaseEnhancer/shader.test.ts +24 -0
- package/src/material/enhancer/model/modelBaseEnhancer/shader.ts +162 -0
- package/src/material/enhancer/model/modelBaseEnhancer/state.test.ts +103 -0
- package/src/material/enhancer/model/modelBaseEnhancer/state.ts +52 -0
- package/src/material/enhancer/model/modelBaseEnhancer/types.ts +89 -0
- package/src/material/enhancer/model/modelMaterialEnhancer.ts +91 -0
- package/src/material/enhancer/model/modelWaterEnhancer/index.test.ts +71 -0
- package/src/material/enhancer/model/modelWaterEnhancer/index.ts +175 -0
- package/src/material/enhancer/model/modelWaterEnhancer/material.test.ts +48 -0
- package/src/material/enhancer/model/modelWaterEnhancer/material.ts +25 -0
- package/src/material/enhancer/model/modelWaterEnhancer/mutates.test.ts +89 -0
- package/src/material/enhancer/model/modelWaterEnhancer/mutates.ts +89 -0
- package/src/material/enhancer/model/modelWaterEnhancer/shader.test.ts +34 -0
- package/src/material/enhancer/model/modelWaterEnhancer/shader.ts +111 -0
- package/src/material/enhancer/model/modelWaterEnhancer/state.test.ts +105 -0
- package/src/material/enhancer/model/modelWaterEnhancer/state.ts +59 -0
- package/src/material/enhancer/model/modelWaterEnhancer/types.ts +141 -0
- package/src/material/enhancer/model/pntsEnhancer/index.test.ts +96 -0
- package/src/material/enhancer/model/pntsEnhancer/index.ts +82 -0
- package/src/material/enhancer/model/pntsEnhancer/markers.ts +6 -0
- package/src/material/enhancer/model/pntsEnhancer/material.test.ts +37 -0
- package/src/material/enhancer/model/pntsEnhancer/material.ts +21 -0
- package/src/material/enhancer/model/pntsEnhancer/mutates.test.ts +80 -0
- package/src/material/enhancer/model/pntsEnhancer/mutates.ts +29 -0
- package/src/material/enhancer/model/pntsEnhancer/shader.test.ts +32 -0
- package/src/material/enhancer/model/pntsEnhancer/shader.ts +56 -0
- package/src/material/enhancer/model/pntsEnhancer/state.test.ts +87 -0
- package/src/material/enhancer/model/pntsEnhancer/state.ts +29 -0
- package/src/material/enhancer/model/pntsEnhancer/types.ts +38 -0
- package/src/material/enhancer/polygon/index.ts +22 -0
- package/src/material/enhancer/polygon/polygonBaseEnhancer/index.test.ts +101 -0
- package/src/material/enhancer/polygon/polygonBaseEnhancer/index.ts +130 -0
- package/src/material/enhancer/polygon/polygonBaseEnhancer/markers.ts +23 -0
- package/src/material/enhancer/polygon/polygonBaseEnhancer/material.test.ts +19 -0
- package/src/material/enhancer/polygon/polygonBaseEnhancer/material.ts +38 -0
- package/src/material/enhancer/polygon/polygonBaseEnhancer/mutates.test.ts +75 -0
- package/src/material/enhancer/polygon/polygonBaseEnhancer/mutates.ts +122 -0
- package/src/material/enhancer/polygon/polygonBaseEnhancer/shader.test.ts +25 -0
- package/src/material/enhancer/polygon/polygonBaseEnhancer/shader.ts +249 -0
- package/src/material/enhancer/polygon/polygonBaseEnhancer/state.test.ts +102 -0
- package/src/material/enhancer/polygon/polygonBaseEnhancer/state.ts +92 -0
- package/src/material/enhancer/polygon/polygonBaseEnhancer/types.ts +150 -0
- package/src/material/enhancer/polygon/polygonMaterialEnhancer.ts +97 -0
- package/src/material/enhancer/polygon/polygonWaterEnhancer/index.test.ts +72 -0
- package/src/material/enhancer/polygon/polygonWaterEnhancer/index.ts +164 -0
- package/src/material/enhancer/polygon/polygonWaterEnhancer/material.test.ts +48 -0
- package/src/material/enhancer/polygon/polygonWaterEnhancer/material.ts +35 -0
- package/src/material/enhancer/polygon/polygonWaterEnhancer/mutates.ts +61 -0
- package/src/material/enhancer/polygon/polygonWaterEnhancer/shader.test.ts +34 -0
- package/src/material/enhancer/polygon/polygonWaterEnhancer/shader.ts +96 -0
- package/src/material/enhancer/polygon/polygonWaterEnhancer/state.test.ts +98 -0
- package/src/material/enhancer/polygon/polygonWaterEnhancer/state.ts +57 -0
- package/src/material/enhancer/polygon/polygonWaterEnhancer/types.ts +115 -0
- package/src/material/enhancer/polyline/index.ts +7 -0
- package/src/material/enhancer/polyline/polylineBaseEnhancer/index.test.ts +157 -0
- package/src/material/enhancer/polyline/polylineBaseEnhancer/index.ts +154 -0
- package/src/material/enhancer/polyline/polylineBaseEnhancer/markers.ts +19 -0
- package/src/material/enhancer/polyline/polylineBaseEnhancer/material.test.ts +42 -0
- package/src/material/enhancer/polyline/polylineBaseEnhancer/material.ts +38 -0
- package/src/material/enhancer/polyline/polylineBaseEnhancer/mutates.test.ts +120 -0
- package/src/material/enhancer/polyline/polylineBaseEnhancer/mutates.ts +169 -0
- package/src/material/enhancer/polyline/polylineBaseEnhancer/shader.test.ts +67 -0
- package/src/material/enhancer/polyline/polylineBaseEnhancer/shader.ts +75 -0
- package/src/material/enhancer/polyline/polylineBaseEnhancer/state.test.ts +55 -0
- package/src/material/enhancer/polyline/polylineBaseEnhancer/state.ts +91 -0
- package/src/material/enhancer/polyline/polylineBaseEnhancer/types.ts +170 -0
- package/src/material/enhancer/polyline/polylineMaterialEnhancer.ts +102 -0
- package/src/material/enhancer/sdfText/index.ts +7 -0
- package/src/material/enhancer/sdfText/sdfTextBaseEnhancer/index.ts +125 -0
- package/src/material/enhancer/sdfText/sdfTextBaseEnhancer/markers.ts +19 -0
- package/src/material/enhancer/sdfText/sdfTextBaseEnhancer/material.test.ts +35 -0
- package/src/material/enhancer/sdfText/sdfTextBaseEnhancer/material.ts +32 -0
- package/src/material/enhancer/sdfText/sdfTextBaseEnhancer/mutates.test.ts +381 -0
- package/src/material/enhancer/sdfText/sdfTextBaseEnhancer/mutates.ts +232 -0
- package/src/material/enhancer/sdfText/sdfTextBaseEnhancer/shader.ts +36 -0
- package/src/material/enhancer/sdfText/sdfTextBaseEnhancer/state.test.ts +118 -0
- package/src/material/enhancer/sdfText/sdfTextBaseEnhancer/state.ts +107 -0
- package/src/material/enhancer/sdfText/sdfTextBaseEnhancer/types.ts +184 -0
- package/src/material/enhancer/sdfText/sdfTextMaterialEnhancer.ts +100 -0
- package/src/material/enhancer/shadowMap/index.ts +7 -0
- package/src/material/enhancer/shadowMap/shadowMapDepthEnhancer/index.ts +97 -0
- package/src/material/enhancer/shadowMap/shadowMapDepthEnhancer/markers.ts +10 -0
- package/src/material/enhancer/shadowMap/shadowMapDepthEnhancer/material.ts +31 -0
- package/src/material/enhancer/shadowMap/shadowMapDepthEnhancer/mutates.ts +8 -0
- package/src/material/enhancer/shadowMap/shadowMapDepthEnhancer/shader.test.ts +17 -0
- package/src/material/enhancer/shadowMap/shadowMapDepthEnhancer/shader.ts +53 -0
- package/src/material/enhancer/shadowMap/shadowMapDepthEnhancer/state.ts +17 -0
- package/src/material/enhancer/shadowMap/shadowMapDepthEnhancer/types.ts +26 -0
- package/src/material/enhancer/test-utils/shaderCompatibility.ts +124 -0
- package/src/material/enhancer/tileComposite/compose.test.ts +95 -0
- package/src/material/enhancer/tileComposite/compose.ts +112 -0
- package/src/material/enhancer/tileComposite/index.ts +23 -0
- package/src/material/enhancer/tileComposite/tileCompositeBaseEnhancer/index.ts +11 -0
- package/src/material/enhancer/tileComposite/tileCompositeBaseEnhancer/mutates.ts +132 -0
- package/src/material/enhancer/tileComposite/tileCompositeBaseEnhancer/shader.ts +245 -0
- package/src/material/enhancer/tileComposite/tileCompositeBaseEnhancer/types.ts +43 -0
- package/src/material/enhancer/tileComposite/tileElevationHeatmapEnhancer/index.ts +29 -0
- package/src/material/enhancer/tileComposite/tileElevationHeatmapEnhancer/mutates.ts +68 -0
- package/src/material/enhancer/tileComposite/tileElevationHeatmapEnhancer/shader.ts +24 -0
- package/src/material/enhancer/tileComposite/tileHillshadeEnhancer/index.ts +29 -0
- package/src/material/enhancer/tileComposite/tileHillshadeEnhancer/mutates.ts +34 -0
- package/src/material/enhancer/tileComposite/tileHillshadeEnhancer/shader.ts +36 -0
- package/src/material/enhancer/tileComposite/tileWaterEnhancer/index.ts +23 -0
- package/src/material/enhancer/tileComposite/tileWaterEnhancer/mutates.ts +23 -0
- package/src/material/enhancer/tileComposite/tileWaterEnhancer/shader.ts +8 -0
- package/src/material/enhancer/tileComposite/tileWatermaskEnhancer/index.ts +23 -0
- package/src/material/enhancer/tileComposite/tileWatermaskEnhancer/mutates.ts +34 -0
- package/src/material/enhancer/tileComposite/tileWatermaskEnhancer/shader.ts +13 -0
- package/src/material/enhancer/tileComposite/types.ts +58 -0
- package/src/material/index.ts +3 -0
- package/src/material/macro/index.ts +1 -0
- package/src/material/macro/tileShader.test.ts +136 -0
- package/src/material/macro/tileShader.ts +287 -0
- package/src/material/overrideMaterialsForMRT.ts +439 -0
- package/src/material/selectiveEffectMaterialSetup.test.ts +52 -0
- package/src/material/selectiveEffectMaterialSetup.ts +53 -0
- package/src/material/types/index.ts +1 -0
- package/src/material/types/uniform.ts +1 -0
- package/src/mesh/DrapedMesh.ts +101 -0
- package/src/mesh/batchTexture.test.ts +646 -0
- package/src/mesh/batchTexture.ts +437 -0
- package/src/mesh/batchedFeature.ts +186 -0
- package/src/mesh/batchedSdfText.ts +484 -0
- package/src/mesh/featureMesh.ts +43 -0
- package/src/mesh/index.ts +16 -0
- package/src/mesh/instanced.ts +117 -0
- package/src/mesh/model.ts +483 -0
- package/src/mesh/pickableMesh.ts +55 -0
- package/src/mesh/pickableMeshWrapper.ts +529 -0
- package/src/mesh/polygon.ts +699 -0
- package/src/mesh/polygonOutline.ts +393 -0
- package/src/mesh/polyline.ts +523 -0
- package/src/mesh/releaseGeometryArrays.ts +57 -0
- package/src/mesh/rtcRteHelper.ts +211 -0
- package/src/mesh/sdfText.test.ts +200 -0
- package/src/mesh/sdfText.ts +1019 -0
- package/src/mesh/sprite/billboardAtlas.test.ts +177 -0
- package/src/mesh/sprite/billboardAtlas.ts +210 -0
- package/src/mesh/sprite/billboardAtlasImageLoader.ts +29 -0
- package/src/mesh/sprite/index.ts +1 -0
- package/src/mesh/sprite/instancedSprite.ts +694 -0
- package/src/mesh/tile.test.ts +393 -0
- package/src/mesh/tile.ts +1790 -0
- package/src/object3DEvent.ts +6 -0
- package/src/orchestrators/RenderPassOrchestrator.ts +147 -0
- package/src/orchestrators/index.ts +1 -0
- package/src/passes/AllDepthCopyPass.ts +165 -0
- package/src/passes/CustomRenderPass.ts +279 -0
- package/src/passes/NormalCopyPass.ts +125 -0
- package/src/passes/RenderTargetCopyPass.ts +91 -0
- package/src/passes/SkyEnvMapPass.ts +58 -0
- package/src/passes/index.ts +5 -0
- package/src/pick/pickHelper.ts +273 -0
- package/src/pick/pickTerrain.ts +254 -0
- package/src/plugins/AttributionPlugin/AttributionPlugin.test.ts +210 -0
- package/src/plugins/AttributionPlugin/attribution.test.ts +225 -0
- package/src/plugins/AttributionPlugin/attribution.ts +355 -0
- package/src/plugins/AttributionPlugin/attributionStyles.ts +163 -0
- package/src/plugins/AttributionPlugin/index.ts +702 -0
- package/src/plugins/index.ts +1 -0
- package/src/quality.ts +1 -0
- package/src/renderOrder.ts +3 -0
- package/src/scene.test.ts +164 -0
- package/src/scene.ts +127 -0
- package/src/shaders/index.ts +1 -0
- package/src/solar.test.ts +81 -0
- package/src/solar.ts +101 -0
- package/src/source.ts +80 -0
- package/src/stats.ts +102 -0
- package/src/tasks/computeVertexNormalsAsync.ts +15 -0
- package/src/tasks/constructPolygonBatchedFeature.ts +34 -0
- package/src/tasks/constructPolylineBatchedFeature.ts +27 -0
- package/src/tasks/constructQuantizedMeshTerrainMesh.ts +24 -0
- package/src/tasks/constructTerrainMesh.ts +25 -0
- package/src/tasks/getImageDataFromBlob.ts +13 -0
- package/src/tasks/getImageDataFromImageBitmap.ts +12 -0
- package/src/tasks/parseMvtTile.ts +22 -0
- package/src/tasks/queueTask.ts +19 -0
- package/src/tasks/toCreasedNormalsAsync.ts +18 -0
- package/src/tasks/upsampleQuantizedMeshTerrainMesh.ts +44 -0
- package/src/tasks/upsampleTerrainMesh.ts +39 -0
- package/src/texture.ts +19 -0
- package/src/textures.ts +13 -0
- package/src/tileTexture/CompositeShader.snapshot.test.ts +59 -0
- package/src/tileTexture/CompositeShader.test.ts +168 -0
- package/src/tileTexture/CompositeShader.ts +53 -0
- package/src/tileTexture/SlotPlanner.test.ts +105 -0
- package/src/tileTexture/SlotPlanner.ts +102 -0
- package/src/tileTexture/TileTextureCache.test.ts +227 -0
- package/src/tileTexture/TileTextureCache.ts +192 -0
- package/src/tileTexture/TileTextureCompositor.test.ts +260 -0
- package/src/tileTexture/TileTextureCompositor.ts +421 -0
- package/src/tileTexture/__snapshots__/CompositeShader.snapshot.test.ts.snap +2649 -0
- package/src/tileTexture/index.ts +8 -0
- package/src/tileTexture/types.ts +150 -0
- package/src/type/index.ts +261 -0
- package/src/uniforms.ts +20 -0
- package/src/utils/arraysEqual.ts +9 -0
- package/src/utils/blendModes.ts +80 -0
- package/src/utils/geometry.ts +53 -0
- package/src/utils/hillshadeNormalMapGenerator.ts +193 -0
- package/src/utils/index.ts +8 -0
- package/src/utils/object.test.ts +14 -0
- package/src/utils/object.ts +7 -0
- package/src/utils/replacer.test.ts +42 -0
- package/src/utils/replacer.ts +89 -0
- package/src/utils/screen.ts +29 -0
- package/src/utils/textureFragmentIndex.test.ts +224 -0
- package/src/utils/textureFragmentIndex.ts +97 -0
- package/src/utils/worker.ts +3 -0
- package/src/vite-env.d.ts +2 -0
- package/src/worker/index.ts +13 -0
- package/src/worker/tasks/computeVertexNormals.ts +15 -0
- package/src/worker/tasks/toCreasedNormals.ts +22 -0
|
@@ -0,0 +1,150 @@
|
|
|
1
|
+
import type { TileHandle } from "@navaramap/core";
|
|
2
|
+
import type {
|
|
3
|
+
Color,
|
|
4
|
+
Texture,
|
|
5
|
+
Vector2,
|
|
6
|
+
Vector3,
|
|
7
|
+
Vector4,
|
|
8
|
+
WebGLRenderTarget,
|
|
9
|
+
} from "three";
|
|
10
|
+
|
|
11
|
+
/**
|
|
12
|
+
* Why a tile's composite atlas needs to be re-rendered.
|
|
13
|
+
* Aggregated per-handle so a single composite pass services multiple updates.
|
|
14
|
+
*/
|
|
15
|
+
export type DirtyReason =
|
|
16
|
+
| "material"
|
|
17
|
+
| "texture-binding"
|
|
18
|
+
| "vector-revision"
|
|
19
|
+
| "hillshade";
|
|
20
|
+
|
|
21
|
+
/**
|
|
22
|
+
* A composite atlas is a single MRT render target (count=3) with three named
|
|
23
|
+
* attachments:
|
|
24
|
+
* - color: composited diffuse (sRGB)
|
|
25
|
+
* - attr: packed per-pixel material attributes (water flag/scale/speed, …)
|
|
26
|
+
* - normal: hillshade normal map in [0,1] (neutral 0.5,0.5,1 when no hillshade)
|
|
27
|
+
*
|
|
28
|
+
* One draw call writes all three; the main TileMesh shader samples them
|
|
29
|
+
* independently as Textures.
|
|
30
|
+
*/
|
|
31
|
+
export type CompositeAtlas = {
|
|
32
|
+
readonly target: WebGLRenderTarget;
|
|
33
|
+
readonly color: Texture;
|
|
34
|
+
readonly attr: Texture;
|
|
35
|
+
readonly normal: Texture;
|
|
36
|
+
dispose: () => void;
|
|
37
|
+
};
|
|
38
|
+
|
|
39
|
+
/** Creates the per-tile MRT trio. Injected so tests can supply fakes. */
|
|
40
|
+
export type AtlasFactory = (size: number) => CompositeAtlas;
|
|
41
|
+
|
|
42
|
+
/**
|
|
43
|
+
* View on the atlas suitable for binding as TileMesh uniforms.
|
|
44
|
+
* Same Textures live across the atlas's lifetime; only `needsUpdate` flips.
|
|
45
|
+
*/
|
|
46
|
+
export type CompositeOutputs = {
|
|
47
|
+
color: Texture;
|
|
48
|
+
attr: Texture;
|
|
49
|
+
normal: Texture;
|
|
50
|
+
};
|
|
51
|
+
|
|
52
|
+
/** Features detected from the Rust material — drives CPU shader branch elision. */
|
|
53
|
+
export type CompositeFeatures = {
|
|
54
|
+
hasHillshade: boolean;
|
|
55
|
+
hasWater: boolean;
|
|
56
|
+
hasElevationHeatmap: boolean;
|
|
57
|
+
/**
|
|
58
|
+
* Quantized-mesh watermask is present. Sampled once after the slot loop
|
|
59
|
+
* and OR'd into `isWater` so it takes priority even when no per-slot
|
|
60
|
+
* `uWaters[k]` is set. Independent of `hasWater` (per-slot flag path).
|
|
61
|
+
*/
|
|
62
|
+
hasWatermask: boolean;
|
|
63
|
+
};
|
|
64
|
+
|
|
65
|
+
/** A handle's cache entry. Public surface is via TileTextureCache methods. */
|
|
66
|
+
export type CacheEntry = {
|
|
67
|
+
readonly handle: TileHandle;
|
|
68
|
+
readonly atlas: CompositeAtlas;
|
|
69
|
+
refCount: number;
|
|
70
|
+
dirty: Set<DirtyReason>;
|
|
71
|
+
};
|
|
72
|
+
|
|
73
|
+
// ---------------------------------------------------------------------------
|
|
74
|
+
// Composite domain model
|
|
75
|
+
//
|
|
76
|
+
// Typed replacement for the parallel-array bridge (shows[]/colors[]/
|
|
77
|
+
// isHillshades[]/… read out of material.userData). Each active layer is one
|
|
78
|
+
// self-describing record; the SlotPlanner flattens them into compact slots and
|
|
79
|
+
// the composite layer enhancers consume them. `region` keeps the existing
|
|
80
|
+
// raster/vector split (the compact-slot space skips the gap between them) and
|
|
81
|
+
// drives the compile-time `isTexturized` constant.
|
|
82
|
+
// ---------------------------------------------------------------------------
|
|
83
|
+
|
|
84
|
+
/** Which compact-slot region a layer lives in (raster low indices vs vector). */
|
|
85
|
+
export type CompositeLayerRegion = "raster" | "vector";
|
|
86
|
+
|
|
87
|
+
type CompositeLayerBase = {
|
|
88
|
+
/**
|
|
89
|
+
* Absolute slot index into the TileMesh main shader's per-slot uniform
|
|
90
|
+
* arrays. Baked into the atlas as the winning slot so the main shader can
|
|
91
|
+
* look the layer's precision-sensitive attrs back up.
|
|
92
|
+
*/
|
|
93
|
+
absSlot: number;
|
|
94
|
+
region: CompositeLayerRegion;
|
|
95
|
+
texture: Texture | null;
|
|
96
|
+
uvOffset: Vector2;
|
|
97
|
+
uvScale: Vector2;
|
|
98
|
+
};
|
|
99
|
+
|
|
100
|
+
/** A sampled color layer — a raster tile or a texturized vector scene. */
|
|
101
|
+
export type RasterCompositeLayer = CompositeLayerBase & {
|
|
102
|
+
kind: "raster";
|
|
103
|
+
color: Color;
|
|
104
|
+
opacity: number;
|
|
105
|
+
water: boolean;
|
|
106
|
+
/**
|
|
107
|
+
* `[south, north]` latitude (radians) of the terrain tile when this slot is a
|
|
108
|
+
* WebMercator raster draped on Geographic terrain — the composite shader uses
|
|
109
|
+
* it to reproject the latitude axis (Mercator). `undefined` for same-scheme
|
|
110
|
+
* drapes (no reprojection).
|
|
111
|
+
*/
|
|
112
|
+
reproject?: [number, number];
|
|
113
|
+
};
|
|
114
|
+
|
|
115
|
+
/** A DEM-derived normal map; contributes no color, only a hillshade normal. */
|
|
116
|
+
export type HillshadeCompositeLayer = CompositeLayerBase & {
|
|
117
|
+
kind: "hillshade";
|
|
118
|
+
};
|
|
119
|
+
|
|
120
|
+
/** A DEM elevation raster colorized through the shared colormap. */
|
|
121
|
+
export type ElevationHeatmapCompositeLayer = CompositeLayerBase & {
|
|
122
|
+
kind: "elevationHeatmap";
|
|
123
|
+
opacity: number;
|
|
124
|
+
};
|
|
125
|
+
|
|
126
|
+
export type CompositeLayer =
|
|
127
|
+
| RasterCompositeLayer
|
|
128
|
+
| HillshadeCompositeLayer
|
|
129
|
+
| ElevationHeatmapCompositeLayer;
|
|
130
|
+
|
|
131
|
+
/**
|
|
132
|
+
* Tile-wide inputs that are not per-slot. Kept separate from CompositeLayer so
|
|
133
|
+
* adding a new per-layer expression doesn't bloat a shared struct (and vice
|
|
134
|
+
* versa). Consumed by the layer enhancers that own slot-independent uniforms.
|
|
135
|
+
*/
|
|
136
|
+
export type CompositeGlobals = {
|
|
137
|
+
/** Hillshade normal exaggeration (shared across hillshade layers). */
|
|
138
|
+
hillshadeExaggeration: number;
|
|
139
|
+
/** Quantized-mesh watermask (1×1 uniform or 256×256), or null. */
|
|
140
|
+
watermask: Texture | null;
|
|
141
|
+
/** Elevation heatmap colormap ramp, or null. */
|
|
142
|
+
colorMapTexture: Texture | null;
|
|
143
|
+
/** Elevation heatmap shared decoder params. */
|
|
144
|
+
elevationRGBScaler: Vector3;
|
|
145
|
+
elevationMinMaxHeightAndBoundary: Vector3;
|
|
146
|
+
elevationMinMaxOffsetAndEpsilonAndOffset: Vector4;
|
|
147
|
+
logarithmic: boolean;
|
|
148
|
+
logBase: number;
|
|
149
|
+
logBoundary: number;
|
|
150
|
+
};
|
|
@@ -0,0 +1,261 @@
|
|
|
1
|
+
import type { NormalizeWASMClass, TileHandle } from "@navaramap/core";
|
|
2
|
+
import type {
|
|
3
|
+
B3dmLayerDescription,
|
|
4
|
+
PntsLayerDescription,
|
|
5
|
+
Cesium3dTilesLayerDescription,
|
|
6
|
+
GeoJsonLayerDescription,
|
|
7
|
+
TerrainLayerDescription,
|
|
8
|
+
TileLayerDescription,
|
|
9
|
+
MvtLayerDescription,
|
|
10
|
+
VectorLayerDescription,
|
|
11
|
+
RasterLayerDescription,
|
|
12
|
+
TerrainSourceLayerDescription,
|
|
13
|
+
Tiles3dLayerDescription,
|
|
14
|
+
GeoJsonSourceDescription,
|
|
15
|
+
VectorTileSourceDescription,
|
|
16
|
+
RasterTileSourceDescription,
|
|
17
|
+
RasterDemSourceDescription,
|
|
18
|
+
QuantizedMeshSourceDescription,
|
|
19
|
+
Tiles3dSourceDescription,
|
|
20
|
+
SourceDescription as SourceDescriptionImpl,
|
|
21
|
+
} from "@navaramap/engine";
|
|
22
|
+
import type { Promise as WorkerPoolPromise } from "@navaramap/worker";
|
|
23
|
+
import type { Feature, FeatureCollection, Geometry } from "geojson";
|
|
24
|
+
import type { Mesh, Sprite, Object3D } from "three";
|
|
25
|
+
|
|
26
|
+
import type { Color } from "../Color";
|
|
27
|
+
import type { FeatureInfo } from "../evaluations";
|
|
28
|
+
import type {
|
|
29
|
+
FinalCopyPassConfig,
|
|
30
|
+
MRTPassConfig,
|
|
31
|
+
SkyEnvMapPassConfig,
|
|
32
|
+
TransparentPassConfig,
|
|
33
|
+
} from "../layers/effect";
|
|
34
|
+
import type { TileMesh } from "../mesh";
|
|
35
|
+
import type { Source } from "../source";
|
|
36
|
+
|
|
37
|
+
export type { Promise as WorkerPoolPromise } from "@navaramap/worker";
|
|
38
|
+
|
|
39
|
+
export type Descriptions = {
|
|
40
|
+
mesh?: object;
|
|
41
|
+
light?: object;
|
|
42
|
+
effect?: object;
|
|
43
|
+
};
|
|
44
|
+
|
|
45
|
+
export type EmptyDescriptions = {
|
|
46
|
+
mesh: undefined;
|
|
47
|
+
light: undefined;
|
|
48
|
+
effect: undefined;
|
|
49
|
+
};
|
|
50
|
+
|
|
51
|
+
export type OmitType<T> = T extends unknown ? Omit<T, "type"> : never;
|
|
52
|
+
|
|
53
|
+
export type BuiltInEffectDescription =
|
|
54
|
+
| FinalCopyPassConfig
|
|
55
|
+
| MRTPassConfig
|
|
56
|
+
| SkyEnvMapPassConfig
|
|
57
|
+
| TransparentPassConfig;
|
|
58
|
+
|
|
59
|
+
// export type MVTLayer = {
|
|
60
|
+
// type: "mvt";
|
|
61
|
+
// zoom: number;
|
|
62
|
+
// layers?: string[];
|
|
63
|
+
// height?: number;
|
|
64
|
+
// extent?: Extent;
|
|
65
|
+
// url: string;
|
|
66
|
+
// color?: number;
|
|
67
|
+
// };
|
|
68
|
+
|
|
69
|
+
type Layer<LD> = NormalizeWASMClass<LD>;
|
|
70
|
+
|
|
71
|
+
/**
|
|
72
|
+
* Helper type to add Navara Color object support to color-related number fields.
|
|
73
|
+
* This recursively transforms any field named 'color' or ending with 'Color'
|
|
74
|
+
* to accept both number and Navara Color objects.
|
|
75
|
+
*/
|
|
76
|
+
type ConvertColorFields<T> = {
|
|
77
|
+
[K in keyof T]: K extends `${string}Color` | "color"
|
|
78
|
+
? T[K] extends number | undefined
|
|
79
|
+
? Color | undefined
|
|
80
|
+
: T[K] extends number
|
|
81
|
+
? Color
|
|
82
|
+
: T[K]
|
|
83
|
+
: T[K] extends object | undefined
|
|
84
|
+
? ConvertColorFields<T[K]> | Extract<T[K], undefined>
|
|
85
|
+
: T[K];
|
|
86
|
+
};
|
|
87
|
+
|
|
88
|
+
/**
|
|
89
|
+
* Helper type to enable Navara Color objects in all color-related fields.
|
|
90
|
+
* This applies to model, point, billboard, text, polyline, polygon, rasterTile, etc.
|
|
91
|
+
* Both number and Navara Color objects are accepted for backward compatibility.
|
|
92
|
+
*/
|
|
93
|
+
type WithColorSupport<T> = ConvertColorFields<T>;
|
|
94
|
+
|
|
95
|
+
export type TilesLayer = WithColorSupport<
|
|
96
|
+
Layer<TileLayerDescription & { type: "tiles" }>
|
|
97
|
+
>;
|
|
98
|
+
export type TerrainLayer = Layer<TerrainLayerDescription & { type: "terrain" }>;
|
|
99
|
+
export type GeoJsonLayer = WithColorSupport<
|
|
100
|
+
Layer<GeoJsonLayerDescription & { type: "geojson" }>
|
|
101
|
+
>;
|
|
102
|
+
export type B3dmLayer = WithColorSupport<
|
|
103
|
+
Layer<B3dmLayerDescription & { type: "b3dm" }>
|
|
104
|
+
>;
|
|
105
|
+
export type PntsLayer = WithColorSupport<
|
|
106
|
+
Layer<PntsLayerDescription & { type: "pnts" }>
|
|
107
|
+
>;
|
|
108
|
+
export type Cesium3dTilesLayer = WithColorSupport<
|
|
109
|
+
Layer<Cesium3dTilesLayerDescription & { type: "cesium3dtiles" }>
|
|
110
|
+
>;
|
|
111
|
+
export type MvtLayer = WithColorSupport<
|
|
112
|
+
Layer<MvtLayerDescription & { type: "mvt" }>
|
|
113
|
+
>;
|
|
114
|
+
|
|
115
|
+
/**
|
|
116
|
+
* A reference to a {@link Source}: either the source handle returned by
|
|
117
|
+
* `addSource`, or its `id` string.
|
|
118
|
+
*/
|
|
119
|
+
export type SourceRef = string | Source;
|
|
120
|
+
|
|
121
|
+
export type SourceLayerBase<Layer extends { source?: string | undefined }> =
|
|
122
|
+
Omit<Layer, "source"> & {
|
|
123
|
+
source?: SourceRef;
|
|
124
|
+
};
|
|
125
|
+
|
|
126
|
+
type VectorLayerBase = WithColorSupport<
|
|
127
|
+
Layer<VectorLayerDescription & { type: "vector" }>
|
|
128
|
+
>;
|
|
129
|
+
|
|
130
|
+
/**
|
|
131
|
+
* A `vector` layer renders a `geojson` or `vector-tile` source as points,
|
|
132
|
+
* lines, polygons, text and billboards.
|
|
133
|
+
*/
|
|
134
|
+
export type VectorLayer = SourceLayerBase<VectorLayerBase>;
|
|
135
|
+
|
|
136
|
+
type RasterLayerBase = WithColorSupport<
|
|
137
|
+
Layer<RasterLayerDescription & { type: "raster" }>
|
|
138
|
+
>;
|
|
139
|
+
|
|
140
|
+
/** A `raster` layer renders a `raster-tile` (imagery) or `raster-dem` source. */
|
|
141
|
+
export type RasterLayer = SourceLayerBase<RasterLayerBase>;
|
|
142
|
+
|
|
143
|
+
type TerrainSourceLayerBase = WithColorSupport<
|
|
144
|
+
Layer<TerrainSourceLayerDescription & { type: "terrain" }>
|
|
145
|
+
>;
|
|
146
|
+
|
|
147
|
+
/**
|
|
148
|
+
* A `terrain` layer renders a `raster-dem` or `quantized-mesh` source as the globe surface.
|
|
149
|
+
*/
|
|
150
|
+
export type TerrainSourceLayer = SourceLayerBase<TerrainSourceLayerBase>;
|
|
151
|
+
|
|
152
|
+
type Tiles3dLayerBase = WithColorSupport<
|
|
153
|
+
Layer<Tiles3dLayerDescription & { type: "3d-tiles" }>
|
|
154
|
+
>;
|
|
155
|
+
|
|
156
|
+
/** A `3d-tiles` layer renders a `3d-tiles`, `b3dm`, or `pnts` source. */
|
|
157
|
+
export type Tiles3dLayer = SourceLayerBase<Tiles3dLayerBase>;
|
|
158
|
+
|
|
159
|
+
export type LayerDescription =
|
|
160
|
+
| TilesLayer
|
|
161
|
+
| TerrainLayer
|
|
162
|
+
| GeoJsonLayer
|
|
163
|
+
| B3dmLayer
|
|
164
|
+
| PntsLayer
|
|
165
|
+
| Cesium3dTilesLayer
|
|
166
|
+
| MvtLayer
|
|
167
|
+
| VectorLayer
|
|
168
|
+
| RasterLayer
|
|
169
|
+
| TerrainSourceLayer
|
|
170
|
+
| Tiles3dLayer;
|
|
171
|
+
|
|
172
|
+
/**
|
|
173
|
+
* Fields common to every source, independent of its `type`.
|
|
174
|
+
*
|
|
175
|
+
* An optional `id` may be given; when omitted a random id is generated. Adding a
|
|
176
|
+
* source with an existing id overrides it (later definition wins). Combined with
|
|
177
|
+
* referencing a source by its id string from a layer, this enables defining the
|
|
178
|
+
* whole map declaratively (MapLibre-style) from JSON.
|
|
179
|
+
*/
|
|
180
|
+
export type SourceBase = Omit<
|
|
181
|
+
NormalizeWASMClass<SourceDescriptionImpl>,
|
|
182
|
+
"type"
|
|
183
|
+
>;
|
|
184
|
+
|
|
185
|
+
/** A `geojson` source: inline GeoJSON, or GeoJSON fetched from a `url`. */
|
|
186
|
+
export type GeoJsonSource = SourceBase &
|
|
187
|
+
Omit<
|
|
188
|
+
WithColorSupport<Layer<GeoJsonSourceDescription & { type: "geojson" }>>,
|
|
189
|
+
"data"
|
|
190
|
+
> & {
|
|
191
|
+
/** Inline GeoJSON. Use `url` instead to fetch from a URL. */
|
|
192
|
+
data?: FeatureCollection | Feature | Geometry;
|
|
193
|
+
};
|
|
194
|
+
|
|
195
|
+
/** A `vector-tile` source: Mapbox Vector Tiles fetched from a `url` template. */
|
|
196
|
+
export type VectorTileSource = SourceBase &
|
|
197
|
+
WithColorSupport<
|
|
198
|
+
Layer<VectorTileSourceDescription & { type: "vector-tile" }>
|
|
199
|
+
>;
|
|
200
|
+
|
|
201
|
+
/** A `raster-tile` source: raster imagery tiles fetched from a `url` template. */
|
|
202
|
+
export type RasterTileSource = SourceBase &
|
|
203
|
+
WithColorSupport<
|
|
204
|
+
Layer<RasterTileSourceDescription & { type: "raster-tile" }>
|
|
205
|
+
>;
|
|
206
|
+
|
|
207
|
+
/** A `raster-dem` source: RGB-encoded elevation tiles fetched from a `url` template. */
|
|
208
|
+
export type RasterDemSource = SourceBase &
|
|
209
|
+
WithColorSupport<Layer<RasterDemSourceDescription & { type: "raster-dem" }>>;
|
|
210
|
+
|
|
211
|
+
/** A `quantized-mesh` source: Cesium quantized-mesh terrain tiles. */
|
|
212
|
+
export type QuantizedMeshSource = SourceBase &
|
|
213
|
+
WithColorSupport<
|
|
214
|
+
Layer<QuantizedMeshSourceDescription & { type: "quantized-mesh" }>
|
|
215
|
+
>;
|
|
216
|
+
|
|
217
|
+
/** A `3d-tiles` source: a 3D Tiles tileset (`tileset.json`). */
|
|
218
|
+
export type Tiles3dSource = SourceBase &
|
|
219
|
+
WithColorSupport<Layer<Tiles3dSourceDescription & { type: "3d-tiles" }>>;
|
|
220
|
+
|
|
221
|
+
/** A `b3dm` source: a single Batched 3D Model tile. */
|
|
222
|
+
export type B3dmSource = SourceBase &
|
|
223
|
+
WithColorSupport<Layer<Tiles3dSourceDescription & { type: "b3dm" }>>;
|
|
224
|
+
|
|
225
|
+
/** A `pnts` source: a single Point Cloud tile. */
|
|
226
|
+
export type PntsSource = SourceBase &
|
|
227
|
+
WithColorSupport<Layer<Tiles3dSourceDescription & { type: "pnts" }>>;
|
|
228
|
+
|
|
229
|
+
/**
|
|
230
|
+
* A source describes where data comes from and how it is fetched/decoded.
|
|
231
|
+
* Register one with `addSource` and reference it from layers by handle or id.
|
|
232
|
+
*
|
|
233
|
+
* This is the discriminated union of every per-type source description
|
|
234
|
+
* ({@link GeoJsonSource}, {@link QuantizedMeshSource}, ...); use an individual
|
|
235
|
+
* member type when you only accept one source type.
|
|
236
|
+
*/
|
|
237
|
+
export type SourceDescription =
|
|
238
|
+
| GeoJsonSource
|
|
239
|
+
| VectorTileSource
|
|
240
|
+
| RasterTileSource
|
|
241
|
+
| RasterDemSource
|
|
242
|
+
| QuantizedMeshSource
|
|
243
|
+
| Tiles3dSource
|
|
244
|
+
| B3dmSource
|
|
245
|
+
| PntsSource;
|
|
246
|
+
|
|
247
|
+
export type MeshCache = Map<string, Mesh | Sprite | Object3D>;
|
|
248
|
+
|
|
249
|
+
// Make a reference of TileMesh by TileHandle.
|
|
250
|
+
export type TileMapByHandle = Map<TileHandle, TileMesh>;
|
|
251
|
+
|
|
252
|
+
export type AbortControllers = Map<string, AbortController>;
|
|
253
|
+
|
|
254
|
+
export type WorkerPoolPromises = Map<string, WorkerPoolPromise<unknown>>;
|
|
255
|
+
|
|
256
|
+
export type PickedFeature = FeatureInfo;
|
|
257
|
+
|
|
258
|
+
export type RenderFlag = {
|
|
259
|
+
forceUpdate: boolean;
|
|
260
|
+
animation: boolean;
|
|
261
|
+
};
|
package/src/uniforms.ts
ADDED
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import type { Matrix4, Texture } from "three";
|
|
2
|
+
|
|
3
|
+
type Ref<K extends string, T> = Record<K, T | undefined | null>;
|
|
4
|
+
type RefThree<T> = Ref<"value", T>;
|
|
5
|
+
|
|
6
|
+
// TODO: Separate as individual library
|
|
7
|
+
export type CommonUniforms = {
|
|
8
|
+
viewportAndPixelRatio: RefThree<[x: number, y: number, z: number]>;
|
|
9
|
+
frustumRatio: RefThree<[x: number, y: number, z: number, w: number]>;
|
|
10
|
+
frustumNearFar: RefThree<[x: number, y: number]>;
|
|
11
|
+
tGlobeDepth: RefThree<Texture>;
|
|
12
|
+
tGlobeNormal: RefThree<Texture>;
|
|
13
|
+
tSkyEnvMap: RefThree<Texture>;
|
|
14
|
+
inverseProjectionMatrix: RefThree<Matrix4>;
|
|
15
|
+
fov: RefThree<number>;
|
|
16
|
+
screenHeightPx: RefThree<number>;
|
|
17
|
+
time: RefThree<number>;
|
|
18
|
+
colorMapTexture: RefThree<Texture>;
|
|
19
|
+
waterTexture: RefThree<Texture>;
|
|
20
|
+
};
|
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
import { BlendFunction } from "postprocessing";
|
|
2
|
+
|
|
3
|
+
export type BlendMode =
|
|
4
|
+
| "skip"
|
|
5
|
+
| "set"
|
|
6
|
+
| "add"
|
|
7
|
+
| "alpha"
|
|
8
|
+
| "average"
|
|
9
|
+
| "color"
|
|
10
|
+
| "colorBurn"
|
|
11
|
+
| "colorDodge"
|
|
12
|
+
| "darken"
|
|
13
|
+
| "difference"
|
|
14
|
+
| "divide"
|
|
15
|
+
| "dst"
|
|
16
|
+
| "exclusion"
|
|
17
|
+
| "hardLight"
|
|
18
|
+
| "hardMix"
|
|
19
|
+
| "hue"
|
|
20
|
+
| "invert"
|
|
21
|
+
| "invertRgb"
|
|
22
|
+
| "lighten"
|
|
23
|
+
| "linearBurn"
|
|
24
|
+
| "linearDodge"
|
|
25
|
+
| "linearLight"
|
|
26
|
+
| "luminosity"
|
|
27
|
+
| "multiply"
|
|
28
|
+
| "negation"
|
|
29
|
+
| "normal"
|
|
30
|
+
| "overlay"
|
|
31
|
+
| "pinLight"
|
|
32
|
+
| "reflect"
|
|
33
|
+
| "saturation"
|
|
34
|
+
| "screen"
|
|
35
|
+
| "softLight"
|
|
36
|
+
| "src"
|
|
37
|
+
| "subtract"
|
|
38
|
+
| "vividLight";
|
|
39
|
+
|
|
40
|
+
const BLEND_MAP: Record<BlendMode, BlendFunction> = {
|
|
41
|
+
skip: BlendFunction.SKIP,
|
|
42
|
+
set: BlendFunction.SET,
|
|
43
|
+
add: BlendFunction.ADD,
|
|
44
|
+
alpha: BlendFunction.ALPHA,
|
|
45
|
+
average: BlendFunction.AVERAGE,
|
|
46
|
+
color: BlendFunction.COLOR,
|
|
47
|
+
colorBurn: BlendFunction.COLOR_BURN,
|
|
48
|
+
colorDodge: BlendFunction.COLOR_DODGE,
|
|
49
|
+
darken: BlendFunction.DARKEN,
|
|
50
|
+
difference: BlendFunction.DIFFERENCE,
|
|
51
|
+
divide: BlendFunction.DIVIDE,
|
|
52
|
+
dst: BlendFunction.DST,
|
|
53
|
+
exclusion: BlendFunction.EXCLUSION,
|
|
54
|
+
hardLight: BlendFunction.HARD_LIGHT,
|
|
55
|
+
hardMix: BlendFunction.HARD_MIX,
|
|
56
|
+
hue: BlendFunction.HUE,
|
|
57
|
+
invert: BlendFunction.INVERT,
|
|
58
|
+
invertRgb: BlendFunction.INVERT_RGB,
|
|
59
|
+
lighten: BlendFunction.LIGHTEN,
|
|
60
|
+
linearBurn: BlendFunction.LINEAR_BURN,
|
|
61
|
+
linearDodge: BlendFunction.LINEAR_DODGE,
|
|
62
|
+
linearLight: BlendFunction.LINEAR_LIGHT,
|
|
63
|
+
luminosity: BlendFunction.LUMINOSITY,
|
|
64
|
+
multiply: BlendFunction.MULTIPLY,
|
|
65
|
+
negation: BlendFunction.NEGATION,
|
|
66
|
+
normal: BlendFunction.NORMAL,
|
|
67
|
+
overlay: BlendFunction.OVERLAY,
|
|
68
|
+
pinLight: BlendFunction.PIN_LIGHT,
|
|
69
|
+
reflect: BlendFunction.REFLECT,
|
|
70
|
+
saturation: BlendFunction.SATURATION,
|
|
71
|
+
screen: BlendFunction.SCREEN,
|
|
72
|
+
softLight: BlendFunction.SOFT_LIGHT,
|
|
73
|
+
src: BlendFunction.SRC,
|
|
74
|
+
subtract: BlendFunction.SUBTRACT,
|
|
75
|
+
vividLight: BlendFunction.VIVID_LIGHT,
|
|
76
|
+
};
|
|
77
|
+
|
|
78
|
+
export function blendFunction(mode: BlendMode): BlendFunction {
|
|
79
|
+
return BLEND_MAP[mode] ?? BlendFunction.SRC;
|
|
80
|
+
}
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
// Ref: https://github.com/takram-design-engineering/geovanni/blob/ee91f675ba2558ee3099f635dfa30bbe3adfe103/libs/core/src/utils.ts
|
|
2
|
+
|
|
3
|
+
import { isNotNullish } from "@navaramap/core";
|
|
4
|
+
import { pick } from "lodash-es";
|
|
5
|
+
import { BufferAttribute, BufferGeometry } from "three";
|
|
6
|
+
|
|
7
|
+
export type BufferGeometryLike = Pick<
|
|
8
|
+
BufferGeometry,
|
|
9
|
+
"attributes" | "index" | "boundingBox" | "boundingSphere"
|
|
10
|
+
>;
|
|
11
|
+
|
|
12
|
+
export function toBufferGeometryLike(
|
|
13
|
+
geometry: BufferGeometry,
|
|
14
|
+
): [BufferGeometryLike, ArrayBuffer[]] {
|
|
15
|
+
return [
|
|
16
|
+
pick(geometry, ["attributes", "index", "boundingBox", "boundingSphere"]),
|
|
17
|
+
(
|
|
18
|
+
[
|
|
19
|
+
...Object.values(geometry.attributes).map(
|
|
20
|
+
(attribute) => attribute.array.buffer,
|
|
21
|
+
),
|
|
22
|
+
geometry.index?.array.buffer,
|
|
23
|
+
] as ArrayBuffer[]
|
|
24
|
+
).filter(isNotNullish),
|
|
25
|
+
];
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
export function fromBufferGeometryLike(
|
|
29
|
+
input: BufferGeometryLike,
|
|
30
|
+
result = new BufferGeometry(),
|
|
31
|
+
): BufferGeometry {
|
|
32
|
+
for (const [name, attribute] of Object.entries(input.attributes)) {
|
|
33
|
+
result.setAttribute(
|
|
34
|
+
name,
|
|
35
|
+
new BufferAttribute(
|
|
36
|
+
attribute.array,
|
|
37
|
+
attribute.itemSize,
|
|
38
|
+
attribute.normalized,
|
|
39
|
+
),
|
|
40
|
+
);
|
|
41
|
+
}
|
|
42
|
+
result.index =
|
|
43
|
+
input.index != null
|
|
44
|
+
? new BufferAttribute(
|
|
45
|
+
input.index.array,
|
|
46
|
+
input.index.itemSize,
|
|
47
|
+
input.index.normalized,
|
|
48
|
+
)
|
|
49
|
+
: null;
|
|
50
|
+
result.boundingBox = input.boundingBox;
|
|
51
|
+
result.boundingSphere = input.boundingSphere;
|
|
52
|
+
return result;
|
|
53
|
+
}
|