@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,211 @@
|
|
|
1
|
+
import type { Transform } from "@navaramap/engine";
|
|
2
|
+
import { calcCameraPosition, calcModelMatrixRTE } from "@navaramap/three_api";
|
|
3
|
+
import { Camera, Matrix4, Object3D, Vector3 } from "three";
|
|
4
|
+
|
|
5
|
+
import { setTransform } from "../event";
|
|
6
|
+
|
|
7
|
+
/**
|
|
8
|
+
* Type for the updateRteUniforms mutation function
|
|
9
|
+
*/
|
|
10
|
+
export type UpdateRteUniformsFn = (
|
|
11
|
+
modelViewMatrixRTE: Matrix4,
|
|
12
|
+
cameraPositionHigh: Vector3,
|
|
13
|
+
cameraPositionLow: Vector3,
|
|
14
|
+
) => void;
|
|
15
|
+
|
|
16
|
+
// Temporary objects for RTE calculations to avoid allocations
|
|
17
|
+
const _tempModelViewMatrix = new Matrix4();
|
|
18
|
+
const _tempCameraHigh = new Vector3();
|
|
19
|
+
const _tempCameraLow = new Vector3();
|
|
20
|
+
|
|
21
|
+
/**
|
|
22
|
+
* Setup onBeforeRender/onBeforeShadow callback for RTE rendering using mutates()
|
|
23
|
+
*
|
|
24
|
+
* @param mesh - The mesh object to setup
|
|
25
|
+
* @param updateRteUniforms - The mutation function from enhancer.mutates()
|
|
26
|
+
* @param modelMatrix - Optional model matrix for calcModelMatrixRTE.
|
|
27
|
+
* - Use identity matrix for GLTF models where world position is in RTE uniforms
|
|
28
|
+
* - Use mesh.matrixWorld for objects with actual positions (default)
|
|
29
|
+
* @param cameraPosMatrix - Optional matrix for calcCameraPosition. If not specified, uses modelMatrix.
|
|
30
|
+
* - Point/Billboard/Text/Model: use identity matrix (world space camera position)
|
|
31
|
+
* - Polygon: use mesh.matrixWorld (same as modelMatrix)
|
|
32
|
+
* @returns A callback function that works for both onBeforeRender and onBeforeShadow
|
|
33
|
+
*/
|
|
34
|
+
export function setupRTECallback(
|
|
35
|
+
mesh: Object3D,
|
|
36
|
+
updateRteUniforms: UpdateRteUniformsFn,
|
|
37
|
+
modelMatrix?: Matrix4,
|
|
38
|
+
cameraPosMatrix?: Matrix4,
|
|
39
|
+
): Object3D["onBeforeRender"] & Object3D["onBeforeShadow"] {
|
|
40
|
+
const modelMatrixToUse =
|
|
41
|
+
modelMatrix !== undefined ? modelMatrix : mesh.matrixWorld;
|
|
42
|
+
const cameraPosMatrixToUse =
|
|
43
|
+
cameraPosMatrix !== undefined ? cameraPosMatrix : modelMatrixToUse;
|
|
44
|
+
|
|
45
|
+
return (_renderer, _scene, camera, shadowCameraOrGeometry) => {
|
|
46
|
+
// If 4th parameter is a Camera, this is onBeforeShadow, use shadowCamera
|
|
47
|
+
// Otherwise this is onBeforeRender, use camera
|
|
48
|
+
const actualCamera =
|
|
49
|
+
shadowCameraOrGeometry instanceof Camera
|
|
50
|
+
? shadowCameraOrGeometry
|
|
51
|
+
: camera;
|
|
52
|
+
|
|
53
|
+
// Calculate RTE model-view matrix
|
|
54
|
+
calcModelMatrixRTE(
|
|
55
|
+
modelMatrixToUse,
|
|
56
|
+
actualCamera.matrixWorldInverse,
|
|
57
|
+
_tempModelViewMatrix,
|
|
58
|
+
);
|
|
59
|
+
|
|
60
|
+
// Calculate camera position in high/low precision
|
|
61
|
+
const result = calcCameraPosition(
|
|
62
|
+
actualCamera.position,
|
|
63
|
+
cameraPosMatrixToUse,
|
|
64
|
+
);
|
|
65
|
+
_tempCameraHigh.copy(result.high);
|
|
66
|
+
_tempCameraLow.copy(result.low);
|
|
67
|
+
|
|
68
|
+
// Update uniforms via mutation function
|
|
69
|
+
updateRteUniforms(_tempModelViewMatrix, _tempCameraHigh, _tempCameraLow);
|
|
70
|
+
};
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
/**
|
|
74
|
+
* Interface for objects that need RTE (Relative-To-Eye) rendering support
|
|
75
|
+
*/
|
|
76
|
+
export type RTEUserData = {
|
|
77
|
+
modelViewMatrixRTE?: { value: Matrix4 };
|
|
78
|
+
cameraPositionHigh?: { value: Vector3 };
|
|
79
|
+
cameraPositionLow?: { value: Vector3 };
|
|
80
|
+
};
|
|
81
|
+
|
|
82
|
+
/**
|
|
83
|
+
* Setup onBeforeRender/onBeforeShadow callback for RTE rendering
|
|
84
|
+
*
|
|
85
|
+
* @param mesh - The mesh object to setup
|
|
86
|
+
* @param userData - RTE user data containing uniforms
|
|
87
|
+
* @param modelMatrix - Optional model matrix for calcModelMatrixRTE.
|
|
88
|
+
* - Use identity matrix for GLTF models where world position is in RTE uniforms
|
|
89
|
+
* - Use mesh.matrixWorld for objects with actual positions (default)
|
|
90
|
+
* @param cameraPosMatrix - Optional matrix for calcCameraPosition. If not specified, uses modelMatrix.
|
|
91
|
+
* - Point/Billboard/Text/Model: use identity matrix (world space camera position)
|
|
92
|
+
* - Polygon: use mesh.matrixWorld (same as modelMatrix)
|
|
93
|
+
* @returns A callback function that works for both onBeforeRender and onBeforeShadow
|
|
94
|
+
* @deprecated Use setupRTECallback with mutates() instead
|
|
95
|
+
*/
|
|
96
|
+
export function setupRTEBeforeRender(
|
|
97
|
+
mesh: Object3D,
|
|
98
|
+
userData: RTEUserData,
|
|
99
|
+
modelMatrix?: Matrix4,
|
|
100
|
+
cameraPosMatrix?: Matrix4,
|
|
101
|
+
): (Object3D["onBeforeRender"] & Object3D["onBeforeShadow"]) | null {
|
|
102
|
+
const modelMatrixToUse =
|
|
103
|
+
modelMatrix !== undefined ? modelMatrix : mesh.matrixWorld;
|
|
104
|
+
const cameraPosMatrixToUse =
|
|
105
|
+
cameraPosMatrix !== undefined ? cameraPosMatrix : modelMatrixToUse;
|
|
106
|
+
|
|
107
|
+
return (_renderer, _scene, camera, shadowCameraOrGeometry) => {
|
|
108
|
+
if (
|
|
109
|
+
!userData.modelViewMatrixRTE ||
|
|
110
|
+
!userData.cameraPositionHigh ||
|
|
111
|
+
!userData.cameraPositionLow
|
|
112
|
+
) {
|
|
113
|
+
return;
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
// If 4th parameter is a Camera, this is onBeforeShadow, use shadowCamera
|
|
117
|
+
// Otherwise this is onBeforeRender, use camera
|
|
118
|
+
const actualCamera =
|
|
119
|
+
shadowCameraOrGeometry instanceof Camera
|
|
120
|
+
? shadowCameraOrGeometry
|
|
121
|
+
: camera;
|
|
122
|
+
|
|
123
|
+
calcModelMatrixRTE(
|
|
124
|
+
modelMatrixToUse,
|
|
125
|
+
actualCamera.matrixWorldInverse,
|
|
126
|
+
userData.modelViewMatrixRTE.value,
|
|
127
|
+
);
|
|
128
|
+
|
|
129
|
+
// Use cameraPosMatrix for camera position calculation
|
|
130
|
+
const result = calcCameraPosition(
|
|
131
|
+
actualCamera.position,
|
|
132
|
+
cameraPosMatrixToUse,
|
|
133
|
+
);
|
|
134
|
+
userData.cameraPositionHigh.value = result.high;
|
|
135
|
+
userData.cameraPositionLow.value = result.low;
|
|
136
|
+
};
|
|
137
|
+
}
|
|
138
|
+
|
|
139
|
+
/**
|
|
140
|
+
* Set position using RTE (Relative-To-Eye) encoding
|
|
141
|
+
*
|
|
142
|
+
* RTE mode stores position in high/low precision uniforms and keeps
|
|
143
|
+
* the mesh at origin (0,0,0). Only scale is applied to control sprite size.
|
|
144
|
+
* Rotation/quaternion would affect matrixWorld and break RTE calculations.
|
|
145
|
+
*
|
|
146
|
+
* @param mesh - The mesh to position (Sprite or Group)
|
|
147
|
+
* @param positionHigh - High precision component array
|
|
148
|
+
* @param positionLow - Low precision component array
|
|
149
|
+
* @param posIdx - Index in the position arrays
|
|
150
|
+
* @param transform - Transform data containing scale
|
|
151
|
+
*/
|
|
152
|
+
export function setRTEPosition<T extends Object3D>(
|
|
153
|
+
mesh: T,
|
|
154
|
+
positionHigh: Float32Array<ArrayBufferLike> | null | undefined,
|
|
155
|
+
positionLow: Float32Array<ArrayBufferLike> | null | undefined,
|
|
156
|
+
posIdx: number,
|
|
157
|
+
transform: Transform,
|
|
158
|
+
): void {
|
|
159
|
+
// RTE: Only set scale (for sprite size), not position/rotation
|
|
160
|
+
// Position is encoded in rtePosHigh/Low (absolute world coordinates)
|
|
161
|
+
// Rotation/quaternion would affect matrixWorld and break RTE calculations
|
|
162
|
+
mesh.scale.set(transform.sx, transform.sy, transform.sz);
|
|
163
|
+
|
|
164
|
+
if (
|
|
165
|
+
positionHigh &&
|
|
166
|
+
positionLow &&
|
|
167
|
+
mesh.userData.rtePosHigh &&
|
|
168
|
+
mesh.userData.rtePosLow
|
|
169
|
+
) {
|
|
170
|
+
// Set high and low components separately - shader will combine
|
|
171
|
+
mesh.userData.rtePosHigh.value.set(
|
|
172
|
+
positionHigh[posIdx],
|
|
173
|
+
positionHigh[posIdx + 1],
|
|
174
|
+
positionHigh[posIdx + 2],
|
|
175
|
+
);
|
|
176
|
+
mesh.userData.rtePosLow.value.set(
|
|
177
|
+
positionLow[posIdx],
|
|
178
|
+
positionLow[posIdx + 1],
|
|
179
|
+
positionLow[posIdx + 2],
|
|
180
|
+
);
|
|
181
|
+
}
|
|
182
|
+
}
|
|
183
|
+
|
|
184
|
+
/**
|
|
185
|
+
* Set position using RTC (Relative-To-Center) encoding
|
|
186
|
+
*
|
|
187
|
+
* RTC mode sets the mesh position/rotation/scale to the tile center transform,
|
|
188
|
+
* and stores the relative offset in a uniform.
|
|
189
|
+
*
|
|
190
|
+
* @param mesh - The mesh to position (Sprite or Group)
|
|
191
|
+
* @param position - Position array (relative to tile center)
|
|
192
|
+
* @param posIdx - Index in the position array
|
|
193
|
+
* @param transform - Transform data (position, rotation, scale)
|
|
194
|
+
*/
|
|
195
|
+
export function setRTCPosition<T extends Object3D>(
|
|
196
|
+
mesh: T,
|
|
197
|
+
position: Float32Array<ArrayBufferLike> | null | undefined,
|
|
198
|
+
posIdx: number,
|
|
199
|
+
transform: Transform,
|
|
200
|
+
): void {
|
|
201
|
+
// RTC: Set mesh position to tile center, store relative offset in uniform
|
|
202
|
+
setTransform(mesh, transform);
|
|
203
|
+
|
|
204
|
+
if (position && mesh.userData.rtcPos) {
|
|
205
|
+
mesh.userData.rtcPos.value.set(
|
|
206
|
+
position[posIdx],
|
|
207
|
+
position[posIdx + 1],
|
|
208
|
+
position[posIdx + 2],
|
|
209
|
+
);
|
|
210
|
+
}
|
|
211
|
+
}
|
|
@@ -0,0 +1,200 @@
|
|
|
1
|
+
import { GlyphCharClass, type ShapedGlyph } from "@navaramap/font";
|
|
2
|
+
import { describe, expect, it } from "vitest";
|
|
3
|
+
|
|
4
|
+
import { breakLines, isRtlText, lineWidthFu } from "./sdfText";
|
|
5
|
+
|
|
6
|
+
/** Build a glyph run from a compact spec: one entry per glyph. */
|
|
7
|
+
function glyphs(
|
|
8
|
+
spec: { advance?: number; cls?: number }[],
|
|
9
|
+
defaultAdvance = 100,
|
|
10
|
+
): ShapedGlyph[] {
|
|
11
|
+
return spec.map((s, i) => ({
|
|
12
|
+
glyphId: i + 1,
|
|
13
|
+
fontIndex: 0,
|
|
14
|
+
compositeKey: BigInt(i + 1),
|
|
15
|
+
xAdvance: s.advance ?? defaultAdvance,
|
|
16
|
+
yAdvance: 0,
|
|
17
|
+
xOffset: 0,
|
|
18
|
+
yOffset: 0,
|
|
19
|
+
charClass: s.cls ?? GlyphCharClass.Normal,
|
|
20
|
+
}));
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
/** "ab cd" style shorthand: space → whitespace, "\n" → newline marker,
|
|
24
|
+
* "国" (any non-ASCII) → ideographic; everything else normal. */
|
|
25
|
+
function fromText(text: string, advance = 100): ShapedGlyph[] {
|
|
26
|
+
return glyphs(
|
|
27
|
+
[...text].map((ch) => ({
|
|
28
|
+
advance: ch === "\n" ? 0 : advance,
|
|
29
|
+
cls:
|
|
30
|
+
ch === "\n"
|
|
31
|
+
? GlyphCharClass.Newline
|
|
32
|
+
: ch === " "
|
|
33
|
+
? GlyphCharClass.Whitespace
|
|
34
|
+
: ch.charCodeAt(0) > 127
|
|
35
|
+
? GlyphCharClass.Ideographic
|
|
36
|
+
: GlyphCharClass.Normal,
|
|
37
|
+
})),
|
|
38
|
+
);
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
describe("breakLines", () => {
|
|
42
|
+
it("keeps a run without breaks on a single line", () => {
|
|
43
|
+
const lines = breakLines(fromText("abc"), 0);
|
|
44
|
+
expect(lines.length).toBe(1);
|
|
45
|
+
expect(lines[0].length).toBe(3);
|
|
46
|
+
});
|
|
47
|
+
|
|
48
|
+
it("splits at newline markers and drops the marker glyph", () => {
|
|
49
|
+
const lines = breakLines(fromText("ab\ncd\nef"), 0);
|
|
50
|
+
expect(lines.map((l) => l.length)).toEqual([2, 2, 2]);
|
|
51
|
+
for (const line of lines) {
|
|
52
|
+
expect(line.every((g) => g.charClass !== GlyphCharClass.Newline)).toBe(
|
|
53
|
+
true,
|
|
54
|
+
);
|
|
55
|
+
}
|
|
56
|
+
});
|
|
57
|
+
|
|
58
|
+
it("preserves empty lines from consecutive newlines", () => {
|
|
59
|
+
const lines = breakLines(fromText("a\n\nb"), 0);
|
|
60
|
+
expect(lines.map((l) => l.length)).toEqual([1, 0, 1]);
|
|
61
|
+
});
|
|
62
|
+
|
|
63
|
+
it("does not wrap when maxWidth is 0", () => {
|
|
64
|
+
const lines = breakLines(fromText("aa bb cc dd"), 0);
|
|
65
|
+
expect(lines.length).toBe(1);
|
|
66
|
+
});
|
|
67
|
+
|
|
68
|
+
it("wraps at whitespace when a line exceeds maxWidth", () => {
|
|
69
|
+
// Each glyph is 100 wide; "aa bb" fits in 500 but "aa bb cc" does not.
|
|
70
|
+
const lines = breakLines(fromText("aa bb cc"), 500);
|
|
71
|
+
expect(lines.length).toBe(2);
|
|
72
|
+
// The wrap point's whitespace is dropped from both line ends.
|
|
73
|
+
expect(lines[0].length).toBe(5); // "aa bb"
|
|
74
|
+
expect(lines[1].length).toBe(2); // "cc"
|
|
75
|
+
});
|
|
76
|
+
|
|
77
|
+
it("drops the whitespace glyph at the wrap point", () => {
|
|
78
|
+
const lines = breakLines(fromText("aa bb"), 300);
|
|
79
|
+
expect(lines.length).toBe(2);
|
|
80
|
+
expect(
|
|
81
|
+
lines.flat().every((g) => g.charClass !== GlyphCharClass.Whitespace),
|
|
82
|
+
).toBe(true);
|
|
83
|
+
});
|
|
84
|
+
|
|
85
|
+
it("lets a word longer than maxWidth overflow instead of breaking mid-word", () => {
|
|
86
|
+
const lines = breakLines(fromText("aaaaaa"), 300);
|
|
87
|
+
expect(lines.length).toBe(1);
|
|
88
|
+
expect(lines[0].length).toBe(6);
|
|
89
|
+
});
|
|
90
|
+
|
|
91
|
+
it("wraps after ideographic glyphs without whitespace", () => {
|
|
92
|
+
const lines = breakLines(fromText("国国国国"), 250);
|
|
93
|
+
expect(lines.length).toBe(2);
|
|
94
|
+
expect(lines.map((l) => l.length)).toEqual([2, 2]);
|
|
95
|
+
});
|
|
96
|
+
|
|
97
|
+
it("combines hard breaks with soft wrapping", () => {
|
|
98
|
+
const lines = breakLines(fromText("aa bb\ncc"), 300);
|
|
99
|
+
expect(lines.map((l) => l.length)).toEqual([2, 2, 2]);
|
|
100
|
+
});
|
|
101
|
+
|
|
102
|
+
describe("rtl", () => {
|
|
103
|
+
/** RTL glyph runs arrive in visual order = reversed logical order.
|
|
104
|
+
* Build from logical text, then reverse (per hard-break segment). */
|
|
105
|
+
function rtlFromText(text: string, advance = 100): ShapedGlyph[] {
|
|
106
|
+
const out: ShapedGlyph[] = [];
|
|
107
|
+
let segment: ShapedGlyph[] = [];
|
|
108
|
+
for (const g of fromText(text, advance)) {
|
|
109
|
+
if (g.charClass === GlyphCharClass.Newline) {
|
|
110
|
+
out.push(...segment.reverse(), g);
|
|
111
|
+
segment = [];
|
|
112
|
+
} else {
|
|
113
|
+
segment.push(g);
|
|
114
|
+
}
|
|
115
|
+
}
|
|
116
|
+
out.push(...segment.reverse());
|
|
117
|
+
return out;
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
it("stacks wrapped lines in logical (reading) order, top to bottom", () => {
|
|
121
|
+
// Logical "aa bb cc" with glyphIds 1..8; visual stream is reversed.
|
|
122
|
+
const lines = breakLines(rtlFromText("aa bb cc"), 500, true);
|
|
123
|
+
expect(lines.length).toBe(2);
|
|
124
|
+
// Top line holds the logical start ("aa bb"), in visual order.
|
|
125
|
+
expect(lines[0].map((g) => g.glyphId)).toEqual([5, 4, 3, 2, 1]);
|
|
126
|
+
expect(lines[1].map((g) => g.glyphId)).toEqual([8, 7]);
|
|
127
|
+
});
|
|
128
|
+
|
|
129
|
+
it("fills lines greedily from the logical start", () => {
|
|
130
|
+
// Five words, two per line: 2-2-1, not 1-2-2.
|
|
131
|
+
const lines = breakLines(rtlFromText("a b c d e"), 300, true);
|
|
132
|
+
expect(lines.map((l) => l.length)).toEqual([3, 3, 1]);
|
|
133
|
+
expect(lines[2].map((g) => g.glyphId)).toEqual([9]); // logical last word
|
|
134
|
+
});
|
|
135
|
+
|
|
136
|
+
it("keeps hard-break segments in logical order", () => {
|
|
137
|
+
const lines = breakLines(rtlFromText("aa\nbb"), 0, true);
|
|
138
|
+
expect(lines.map((l) => l.map((g) => g.glyphId))).toEqual([
|
|
139
|
+
[2, 1],
|
|
140
|
+
[5, 4],
|
|
141
|
+
]);
|
|
142
|
+
});
|
|
143
|
+
|
|
144
|
+
it("matches LTR output for a single unwrapped line", () => {
|
|
145
|
+
const lines = breakLines(rtlFromText("abc"), 0, true);
|
|
146
|
+
expect(lines.length).toBe(1);
|
|
147
|
+
expect(lines[0].map((g) => g.glyphId)).toEqual([3, 2, 1]);
|
|
148
|
+
});
|
|
149
|
+
});
|
|
150
|
+
});
|
|
151
|
+
|
|
152
|
+
describe("isRtlText", () => {
|
|
153
|
+
it("detects Arabic", () => {
|
|
154
|
+
expect(isRtlText("شارع الملك")).toBe(true);
|
|
155
|
+
});
|
|
156
|
+
|
|
157
|
+
it("detects Hebrew", () => {
|
|
158
|
+
expect(isRtlText("רחוב")).toBe(true);
|
|
159
|
+
});
|
|
160
|
+
|
|
161
|
+
it("is false for Latin", () => {
|
|
162
|
+
expect(isRtlText("Main St")).toBe(false);
|
|
163
|
+
});
|
|
164
|
+
|
|
165
|
+
it("is false for CJK", () => {
|
|
166
|
+
expect(isRtlText("東京都")).toBe(false);
|
|
167
|
+
});
|
|
168
|
+
|
|
169
|
+
it("uses the first strong character in mixed text", () => {
|
|
170
|
+
expect(isRtlText("Cafe شارع")).toBe(false);
|
|
171
|
+
expect(isRtlText("شارع Cafe")).toBe(true);
|
|
172
|
+
});
|
|
173
|
+
|
|
174
|
+
it("skips leading digits and punctuation", () => {
|
|
175
|
+
expect(isRtlText("12 - شارع")).toBe(true);
|
|
176
|
+
});
|
|
177
|
+
|
|
178
|
+
it("is false for empty or neutral-only text", () => {
|
|
179
|
+
expect(isRtlText("")).toBe(false);
|
|
180
|
+
expect(isRtlText("123 !?")).toBe(false);
|
|
181
|
+
});
|
|
182
|
+
});
|
|
183
|
+
|
|
184
|
+
describe("lineWidthFu", () => {
|
|
185
|
+
it("sums advances", () => {
|
|
186
|
+
expect(lineWidthFu(fromText("abc"))).toBe(300);
|
|
187
|
+
});
|
|
188
|
+
|
|
189
|
+
it("ignores trailing whitespace", () => {
|
|
190
|
+
expect(lineWidthFu(fromText("ab "))).toBe(200);
|
|
191
|
+
});
|
|
192
|
+
|
|
193
|
+
it("counts interior whitespace", () => {
|
|
194
|
+
expect(lineWidthFu(fromText("a b"))).toBe(300);
|
|
195
|
+
});
|
|
196
|
+
|
|
197
|
+
it("is 0 for an empty line", () => {
|
|
198
|
+
expect(lineWidthFu([])).toBe(0);
|
|
199
|
+
});
|
|
200
|
+
});
|