leaflet-city-mapper 0.0.0-stage → 0.0.2
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 +674 -0
- package/README.md +78 -2
- package/cucumber.mjs +9 -0
- package/dist/leaflet-city-mapper.js +2 -0
- package/dist/leaflet-city-mapper.js.map +7 -0
- package/dist/utils/CELL.js +2 -0
- package/dist/utils/CELL.js.map +7 -0
- package/dist/utils/addBridges.js +2 -0
- package/dist/utils/addBridges.js.map +7 -0
- package/dist/utils/addRasterTile.js +2 -0
- package/dist/utils/addRasterTile.js.map +7 -0
- package/dist/utils/along.js +2 -0
- package/dist/utils/along.js.map +7 -0
- package/dist/utils/atmosphere.js +2 -0
- package/dist/utils/atmosphere.js.map +7 -0
- package/dist/utils/attach.js +2 -0
- package/dist/utils/attach.js.map +7 -0
- package/dist/utils/bindSunlight.js +2 -0
- package/dist/utils/bindSunlight.js.map +7 -0
- package/dist/utils/box.js +2 -0
- package/dist/utils/box.js.map +7 -0
- package/dist/utils/bridgeElevation.js +2 -0
- package/dist/utils/bridgeElevation.js.map +7 -0
- package/dist/utils/build.js +2 -0
- package/dist/utils/build.js.map +7 -0
- package/dist/utils/cameraControls.js +2 -0
- package/dist/utils/cameraControls.js.map +7 -0
- package/dist/utils/channel.js +2 -0
- package/dist/utils/channel.js.map +7 -0
- package/dist/utils/collider.js +2 -0
- package/dist/utils/collider.js.map +7 -0
- package/dist/utils/colliders.js +2 -0
- package/dist/utils/colliders.js.map +7 -0
- package/dist/utils/computeBounds.js +2 -0
- package/dist/utils/computeBounds.js.map +7 -0
- package/dist/utils/conformModelToTerrain.js +2 -0
- package/dist/utils/conformModelToTerrain.js.map +7 -0
- package/dist/utils/createMesh.js +2 -0
- package/dist/utils/createMesh.js.map +7 -0
- package/dist/utils/createProgram.js +3 -0
- package/dist/utils/createProgram.js.map +7 -0
- package/dist/utils/decodeDirectory.js +2 -0
- package/dist/utils/decodeDirectory.js.map +7 -0
- package/dist/utils/decodeHeader.js +2 -0
- package/dist/utils/decodeHeader.js.map +7 -0
- package/dist/utils/decodeModel.js +2 -0
- package/dist/utils/decodeModel.js.map +7 -0
- package/dist/utils/decompress.js +2 -0
- package/dist/utils/decompress.js.map +7 -0
- package/dist/utils/destroyTexture.js +2 -0
- package/dist/utils/destroyTexture.js.map +7 -0
- package/dist/utils/disposeMesh.js +2 -0
- package/dist/utils/disposeMesh.js.map +7 -0
- package/dist/utils/drawGeometry.js +2 -0
- package/dist/utils/drawGeometry.js.map +7 -0
- package/dist/utils/elevationWGSL.js +24 -0
- package/dist/utils/elevationWGSL.js.map +7 -0
- package/dist/utils/emptyNode.js +2 -0
- package/dist/utils/emptyNode.js.map +7 -0
- package/dist/utils/endZoom.js +2 -0
- package/dist/utils/endZoom.js.map +7 -0
- package/dist/utils/findFeature.js +2 -0
- package/dist/utils/findFeature.js.map +7 -0
- package/dist/utils/geometry.js +1 -0
- package/dist/utils/geometry.js.map +7 -0
- package/dist/utils/getElevation.js +2 -0
- package/dist/utils/getElevation.js.map +7 -0
- package/dist/utils/getHeader.js +2 -0
- package/dist/utils/getHeader.js.map +7 -0
- package/dist/utils/getZxy.js +2 -0
- package/dist/utils/getZxy.js.map +7 -0
- package/dist/utils/glass.js +2 -0
- package/dist/utils/glass.js.map +7 -0
- package/dist/utils/headlight.js +2 -0
- package/dist/utils/headlight.js.map +7 -0
- package/dist/utils/hit.js +2 -0
- package/dist/utils/hit.js.map +7 -0
- package/dist/utils/horizontalPosition.js +2 -0
- package/dist/utils/horizontalPosition.js.map +7 -0
- package/dist/utils/horizontalRay.js +2 -0
- package/dist/utils/horizontalRay.js.map +7 -0
- package/dist/utils/hull.js +2 -0
- package/dist/utils/hull.js.map +7 -0
- package/dist/utils/initSunlight.js +2 -0
- package/dist/utils/initSunlight.js.map +7 -0
- package/dist/utils/initTerrain.js +2 -0
- package/dist/utils/initTerrain.js.map +7 -0
- package/dist/utils/initTraffic.js +40 -0
- package/dist/utils/initTraffic.js.map +7 -0
- package/dist/utils/initWalk.js +2 -0
- package/dist/utils/initWalk.js.map +7 -0
- package/dist/utils/intersectMeshes.js +2 -0
- package/dist/utils/intersectMeshes.js.map +7 -0
- package/dist/utils/isClockWise.js +2 -0
- package/dist/utils/isClockWise.js.map +7 -0
- package/dist/utils/lampPostGeometry.js +2 -0
- package/dist/utils/lampPostGeometry.js.map +7 -0
- package/dist/utils/lightGeometry.js +2 -0
- package/dist/utils/lightGeometry.js.map +7 -0
- package/dist/utils/lightGrid.js +2 -0
- package/dist/utils/lightGrid.js.map +7 -0
- package/dist/utils/limbs.js +2 -0
- package/dist/utils/limbs.js.map +7 -0
- package/dist/utils/loadModel.js +2 -0
- package/dist/utils/loadModel.js.map +7 -0
- package/dist/utils/loadSource.js +2 -0
- package/dist/utils/loadSource.js.map +7 -0
- package/dist/utils/loadTerrain.js +2 -0
- package/dist/utils/loadTerrain.js.map +7 -0
- package/dist/utils/mapCamera.js +2 -0
- package/dist/utils/mapCamera.js.map +7 -0
- package/dist/utils/materialShaders.js +211 -0
- package/dist/utils/materialShaders.js.map +7 -0
- package/dist/utils/mirror.js +2 -0
- package/dist/utils/mirror.js.map +7 -0
- package/dist/utils/moonPosition.js +2 -0
- package/dist/utils/moonPosition.js.map +7 -0
- package/dist/utils/moves.js +2 -0
- package/dist/utils/moves.js.map +7 -0
- package/dist/utils/nativeEvents.js +2 -0
- package/dist/utils/nativeEvents.js.map +7 -0
- package/dist/utils/nativeGeometry.js +2 -0
- package/dist/utils/nativeGeometry.js.map +7 -0
- package/dist/utils/nativeLayer.js +2 -0
- package/dist/utils/nativeLayer.js.map +7 -0
- package/dist/utils/nodeMatrix.js +2 -0
- package/dist/utils/nodeMatrix.js.map +7 -0
- package/dist/utils/onAdd3DLayer.js +2 -0
- package/dist/utils/onAdd3DLayer.js.map +7 -0
- package/dist/utils/onAddSun.js +2 -0
- package/dist/utils/onAddSun.js.map +7 -0
- package/dist/utils/onClick.js +2 -0
- package/dist/utils/onClick.js.map +7 -0
- package/dist/utils/onMapChange.js +2 -0
- package/dist/utils/onMapChange.js.map +7 -0
- package/dist/utils/onPMTileAdd.js +2 -0
- package/dist/utils/onPMTileAdd.js.map +7 -0
- package/dist/utils/onPMTileRemove.js +2 -0
- package/dist/utils/onPMTileRemove.js.map +7 -0
- package/dist/utils/onPointerLeave.js +2 -0
- package/dist/utils/onPointerLeave.js.map +7 -0
- package/dist/utils/onPointerMove.js +2 -0
- package/dist/utils/onPointerMove.js.map +7 -0
- package/dist/utils/onRemove3DLayer.js +2 -0
- package/dist/utils/onRemove3DLayer.js.map +7 -0
- package/dist/utils/onRemoveSun.js +2 -0
- package/dist/utils/onRemoveSun.js.map +7 -0
- package/dist/utils/onTerrainAdd.js +2 -0
- package/dist/utils/onTerrainAdd.js.map +7 -0
- package/dist/utils/onTerrainChange.js +2 -0
- package/dist/utils/onTerrainChange.js.map +7 -0
- package/dist/utils/onTerrainRemove.js +2 -0
- package/dist/utils/onTerrainRemove.js.map +7 -0
- package/dist/utils/onZoomAnim.js +2 -0
- package/dist/utils/onZoomAnim.js.map +7 -0
- package/dist/utils/paints.js +2 -0
- package/dist/utils/paints.js.map +7 -0
- package/dist/utils/parseColor.js +2 -0
- package/dist/utils/parseColor.js.map +7 -0
- package/dist/utils/parts.js +2 -0
- package/dist/utils/parts.js.map +7 -0
- package/dist/utils/projectCelestialBody.js +2 -0
- package/dist/utils/projectCelestialBody.js.map +7 -0
- package/dist/utils/pump.js +2 -0
- package/dist/utils/pump.js.map +7 -0
- package/dist/utils/rasterTiles.js +2 -0
- package/dist/utils/rasterTiles.js.map +7 -0
- package/dist/utils/raycast.js +2 -0
- package/dist/utils/raycast.js.map +7 -0
- package/dist/utils/read.js +2 -0
- package/dist/utils/read.js.map +7 -0
- package/dist/utils/readAccessor.js +2 -0
- package/dist/utils/readAccessor.js.map +7 -0
- package/dist/utils/releaseArea.js +2 -0
- package/dist/utils/releaseArea.js.map +7 -0
- package/dist/utils/removeRasterTile.js +2 -0
- package/dist/utils/removeRasterTile.js.map +7 -0
- package/dist/utils/render.js +15 -0
- package/dist/utils/render.js.map +7 -0
- package/dist/utils/renderSunlight.js +13 -0
- package/dist/utils/renderSunlight.js.map +7 -0
- package/dist/utils/renderers.js +2 -0
- package/dist/utils/renderers.js.map +7 -0
- package/dist/utils/resizeSunlight.js +2 -0
- package/dist/utils/resizeSunlight.js.map +7 -0
- package/dist/utils/roofCoverage.js +2 -0
- package/dist/utils/roofCoverage.js.map +7 -0
- package/dist/utils/routeGeometry.js +2 -0
- package/dist/utils/routeGeometry.js.map +7 -0
- package/dist/utils/scheduledTrips.js +2 -0
- package/dist/utils/scheduledTrips.js.map +7 -0
- package/dist/utils/setGeoJSONData.js +2 -0
- package/dist/utils/setGeoJSONData.js.map +7 -0
- package/dist/utils/setHighlight.js +2 -0
- package/dist/utils/setHighlight.js.map +7 -0
- package/dist/utils/setPMTileOpacity.js +2 -0
- package/dist/utils/setPMTileOpacity.js.map +7 -0
- package/dist/utils/setPMTileZIndex.js +2 -0
- package/dist/utils/setPMTileZIndex.js.map +7 -0
- package/dist/utils/setParent.js +2 -0
- package/dist/utils/setParent.js.map +7 -0
- package/dist/utils/setTerrainHeight.js +2 -0
- package/dist/utils/setTerrainHeight.js.map +7 -0
- package/dist/utils/setVertexColor.js +2 -0
- package/dist/utils/setVertexColor.js.map +7 -0
- package/dist/utils/showFeature.js +2 -0
- package/dist/utils/showFeature.js.map +7 -0
- package/dist/utils/sizes.js +2 -0
- package/dist/utils/sizes.js.map +7 -0
- package/dist/utils/skin.js +2 -0
- package/dist/utils/skin.js.map +7 -0
- package/dist/utils/solarPosition.js +2 -0
- package/dist/utils/solarPosition.js.map +7 -0
- package/dist/utils/sortMeshes.js +2 -0
- package/dist/utils/sortMeshes.js.map +7 -0
- package/dist/utils/speed.js +2 -0
- package/dist/utils/speed.js.map +7 -0
- package/dist/utils/startZoom.js +2 -0
- package/dist/utils/startZoom.js.map +7 -0
- package/dist/utils/taillight.js +2 -0
- package/dist/utils/taillight.js.map +7 -0
- package/dist/utils/terrainAtlas.js +2 -0
- package/dist/utils/terrainAtlas.js.map +7 -0
- package/dist/utils/terrainElevation.js +2 -0
- package/dist/utils/terrainElevation.js.map +7 -0
- package/dist/utils/terrainGrid.js +2 -0
- package/dist/utils/terrainGrid.js.map +7 -0
- package/dist/utils/textureSampler.js +2 -0
- package/dist/utils/textureSampler.js.map +7 -0
- package/dist/utils/tileId.js +2 -0
- package/dist/utils/tileId.js.map +7 -0
- package/dist/utils/toLanes.js +2 -0
- package/dist/utils/toLanes.js.map +7 -0
- package/dist/utils/toSRGB.js +2 -0
- package/dist/utils/toSRGB.js.map +7 -0
- package/dist/utils/tooltip.js +3 -0
- package/dist/utils/tooltip.js.map +7 -0
- package/dist/utils/traffic.js +2 -0
- package/dist/utils/traffic.js.map +7 -0
- package/dist/utils/traverse.js +2 -0
- package/dist/utils/traverse.js.map +7 -0
- package/dist/utils/treeGeometry.js +2 -0
- package/dist/utils/treeGeometry.js.map +7 -0
- package/dist/utils/triangulate.js +2 -0
- package/dist/utils/triangulate.js.map +7 -0
- package/dist/utils/tripsAt.js +2 -0
- package/dist/utils/tripsAt.js.map +7 -0
- package/dist/utils/types.js +2 -0
- package/dist/utils/types.js.map +7 -0
- package/dist/utils/underEntry.js +2 -0
- package/dist/utils/underEntry.js.map +7 -0
- package/dist/utils/update.js +2 -0
- package/dist/utils/update.js.map +7 -0
- package/dist/utils/updateArea.js +2 -0
- package/dist/utils/updateArea.js.map +7 -0
- package/dist/utils/updateCamera.js +2 -0
- package/dist/utils/updateCamera.js.map +7 -0
- package/dist/utils/updatePointLights.js +2 -0
- package/dist/utils/updatePointLights.js.map +7 -0
- package/dist/utils/updateWorldMatrix.js +2 -0
- package/dist/utils/updateWorldMatrix.js.map +7 -0
- package/dist/utils/vehicleOffsets.js +2 -0
- package/dist/utils/vehicleOffsets.js.map +7 -0
- package/dist/utils/vehicles.js +2 -0
- package/dist/utils/vehicles.js.map +7 -0
- package/dist/utils/vertexNormals.js +2 -0
- package/dist/utils/vertexNormals.js.map +7 -0
- package/dist/utils/walk.js +2 -0
- package/dist/utils/walk.js.map +7 -0
- package/dist/utils/white.js +2 -0
- package/dist/utils/white.js.map +7 -0
- package/dist/utils/worldLights.js +2 -0
- package/dist/utils/worldLights.js.map +7 -0
- package/dist/utils/wrap.js +2 -0
- package/dist/utils/wrap.js.map +7 -0
- package/package.json +43 -4
- package/src/index.js +397 -0
- package/src/utils/CELL.js +4 -0
- package/src/utils/addBridges.js +66 -0
- package/src/utils/addRasterTile.js +112 -0
- package/src/utils/along.js +9 -0
- package/src/utils/atmosphere.js +20 -0
- package/src/utils/attach.js +255 -0
- package/src/utils/bindSunlight.js +12 -0
- package/src/utils/box.js +1 -0
- package/src/utils/bridgeElevation.js +18 -0
- package/src/utils/build.js +20 -0
- package/src/utils/cameraControls.js +287 -0
- package/src/utils/channel.js +4 -0
- package/src/utils/collider.js +62 -0
- package/src/utils/colliders.js +2 -0
- package/src/utils/computeBounds.js +17 -0
- package/src/utils/conformModelToTerrain.js +69 -0
- package/src/utils/createMesh.js +31 -0
- package/src/utils/createProgram.js +92 -0
- package/src/utils/decodeDirectory.js +40 -0
- package/src/utils/decodeHeader.js +15 -0
- package/src/utils/decodeModel.js +43 -0
- package/src/utils/decompress.js +5 -0
- package/src/utils/destroyTexture.js +7 -0
- package/src/utils/disposeMesh.js +13 -0
- package/src/utils/drawGeometry.js +122 -0
- package/src/utils/elevationWGSL.js +27 -0
- package/src/utils/emptyNode.js +9 -0
- package/src/utils/endZoom.js +15 -0
- package/src/utils/findFeature.js +49 -0
- package/src/utils/geometry.js +2 -0
- package/src/utils/getElevation.js +10 -0
- package/src/utils/getHeader.js +9 -0
- package/src/utils/getZxy.js +76 -0
- package/src/utils/glass.js +1 -0
- package/src/utils/headlight.js +1 -0
- package/src/utils/hit.js +41 -0
- package/src/utils/horizontalPosition.js +16 -0
- package/src/utils/horizontalRay.js +12 -0
- package/src/utils/hull.js +1 -0
- package/src/utils/initSunlight.js +9 -0
- package/src/utils/initTerrain.js +19 -0
- package/src/utils/initTraffic.js +93 -0
- package/src/utils/initWalk.js +72 -0
- package/src/utils/intersectMeshes.js +121 -0
- package/src/utils/isClockWise.js +12 -0
- package/src/utils/lampPostGeometry.js +26 -0
- package/src/utils/lightGeometry.js +22 -0
- package/src/utils/lightGrid.js +50 -0
- package/src/utils/limbs.js +9 -0
- package/src/utils/loadModel.js +217 -0
- package/src/utils/loadSource.js +17 -0
- package/src/utils/loadTerrain.js +65 -0
- package/src/utils/mapCamera.js +432 -0
- package/src/utils/materialShaders.js +243 -0
- package/src/utils/mirror.js +6 -0
- package/src/utils/moonPosition.js +17 -0
- package/src/utils/moves.js +11 -0
- package/src/utils/nativeEvents.js +77 -0
- package/src/utils/nativeGeometry.js +131 -0
- package/src/utils/nativeLayer.js +317 -0
- package/src/utils/nodeMatrix.js +22 -0
- package/src/utils/onAdd3DLayer.js +31 -0
- package/src/utils/onAddSun.js +147 -0
- package/src/utils/onClick.js +13 -0
- package/src/utils/onMapChange.js +16 -0
- package/src/utils/onPMTileAdd.js +15 -0
- package/src/utils/onPMTileRemove.js +8 -0
- package/src/utils/onPointerLeave.js +11 -0
- package/src/utils/onPointerMove.js +15 -0
- package/src/utils/onRemove3DLayer.js +78 -0
- package/src/utils/onRemoveSun.js +3 -0
- package/src/utils/onTerrainAdd.js +18 -0
- package/src/utils/onTerrainChange.js +13 -0
- package/src/utils/onTerrainRemove.js +40 -0
- package/src/utils/onZoomAnim.js +14 -0
- package/src/utils/paints.js +10 -0
- package/src/utils/parseColor.js +42 -0
- package/src/utils/parts.js +16 -0
- package/src/utils/projectCelestialBody.js +13 -0
- package/src/utils/pump.js +226 -0
- package/src/utils/rasterTiles.js +285 -0
- package/src/utils/raycast.js +60 -0
- package/src/utils/read.js +29 -0
- package/src/utils/readAccessor.js +68 -0
- package/src/utils/releaseArea.js +34 -0
- package/src/utils/removeRasterTile.js +13 -0
- package/src/utils/render.js +406 -0
- package/src/utils/renderSunlight.js +170 -0
- package/src/utils/renderers.js +2 -0
- package/src/utils/resizeSunlight.js +15 -0
- package/src/utils/roofCoverage.js +47 -0
- package/src/utils/routeGeometry.js +22 -0
- package/src/utils/scheduledTrips.js +29 -0
- package/src/utils/setGeoJSONData.js +11 -0
- package/src/utils/setHighlight.js +13 -0
- package/src/utils/setPMTileOpacity.js +7 -0
- package/src/utils/setPMTileZIndex.js +7 -0
- package/src/utils/setParent.js +7 -0
- package/src/utils/setTerrainHeight.js +10 -0
- package/src/utils/setVertexColor.js +14 -0
- package/src/utils/showFeature.js +27 -0
- package/src/utils/sizes.js +1 -0
- package/src/utils/skin.js +2 -0
- package/src/utils/solarPosition.js +17 -0
- package/src/utils/sortMeshes.js +12 -0
- package/src/utils/speed.js +3 -0
- package/src/utils/startZoom.js +5 -0
- package/src/utils/taillight.js +1 -0
- package/src/utils/terrainAtlas.js +21 -0
- package/src/utils/terrainElevation.js +20 -0
- package/src/utils/terrainGrid.js +23 -0
- package/src/utils/textureSampler.js +10 -0
- package/src/utils/tileId.js +18 -0
- package/src/utils/toLanes.js +7 -0
- package/src/utils/toSRGB.js +1 -0
- package/src/utils/tooltip.js +6 -0
- package/src/utils/traffic.js +315 -0
- package/src/utils/traverse.js +6 -0
- package/src/utils/treeGeometry.js +45 -0
- package/src/utils/triangulate.js +100 -0
- package/src/utils/tripsAt.js +16 -0
- package/src/utils/types.js +8 -0
- package/src/utils/underEntry.js +17 -0
- package/src/utils/update.js +18 -0
- package/src/utils/updateArea.js +40 -0
- package/src/utils/updateCamera.js +32 -0
- package/src/utils/updatePointLights.js +38 -0
- package/src/utils/updateWorldMatrix.js +47 -0
- package/src/utils/vehicleOffsets.js +8 -0
- package/src/utils/vehicles.js +65 -0
- package/src/utils/vertexNormals.js +30 -0
- package/src/utils/walk.js +187 -0
- package/src/utils/white.js +1 -0
- package/src/utils/worldLights.js +25 -0
- package/src/utils/wrap.js +1 -0
|
@@ -0,0 +1,211 @@
|
|
|
1
|
+
function T(e={},t=!1,m=""){const a=!!e.baseTexture,l=!!e.metalTexture,c=!!e.emissiveTexture,u=!!e.occlusionTexture,o=!!e.roofTexture,s=!!e.terrain,i=a||l||c||u||e.nightLight,x=`
|
|
2
|
+
struct Mesh {
|
|
3
|
+
worldMatrix: mat4x4<f32>,
|
|
4
|
+
baseColor: vec4<f32>,
|
|
5
|
+
material: vec4<f32>,
|
|
6
|
+
emissive: vec4<f32>,
|
|
7
|
+
terrain: vec4<f32>,
|
|
8
|
+
highlight: vec4<f32>,
|
|
9
|
+
};
|
|
10
|
+
struct Frame {
|
|
11
|
+
viewMatrix: mat4x4<f32>,
|
|
12
|
+
projectionMatrix: mat4x4<f32>,
|
|
13
|
+
roofMatrix: mat4x4<f32>,
|
|
14
|
+
lightDirection: vec4<f32>,
|
|
15
|
+
skyDirection: vec4<f32>,
|
|
16
|
+
atmosphereTint: vec4<f32>,
|
|
17
|
+
};
|
|
18
|
+
@group(0) @binding(0) var<uniform> u: Mesh;
|
|
19
|
+
@group(0) @binding(1) var<uniform> frame: Frame;
|
|
20
|
+
struct Solar { matrix: mat4x4<f32>, params: vec4<f32> };
|
|
21
|
+
@group(1) @binding(0) var<uniform> solar: Solar;
|
|
22
|
+
${s?`@group(0) @binding(2) var dem: texture_2d<f32>;${m}`:""}
|
|
23
|
+
struct VertexInput {
|
|
24
|
+
@location(0) position: vec3<f32>,
|
|
25
|
+
@location(1) normal: vec3<f32>,
|
|
26
|
+
${e.vertexColors?"@location(2) color: vec3<f32>,":""}
|
|
27
|
+
${i?"@location(3) uv: vec2<f32>,":""}
|
|
28
|
+
};
|
|
29
|
+
struct VertexOutput {
|
|
30
|
+
@builtin(position) position: vec4<f32>,
|
|
31
|
+
@location(0) color: vec3<f32>,
|
|
32
|
+
@location(1) normal: vec3<f32>,
|
|
33
|
+
@location(2) viewPosition: vec3<f32>,
|
|
34
|
+
@location(6) shadowPosition: vec4<f32>,
|
|
35
|
+
@location(7) worldPosition: vec3<f32>,
|
|
36
|
+
${t?"@location(8) localPosition: vec3<f32>,":""}
|
|
37
|
+
${i?"@location(3) uv: vec2<f32>,":""}
|
|
38
|
+
${o?"@location(4) roofUv: vec2<f32>, @location(5) roof: f32,":""}
|
|
39
|
+
};
|
|
40
|
+
@vertex fn vertexMain(input: VertexInput, @builtin(vertex_index) vertexIndex: u32) -> VertexOutput {
|
|
41
|
+
var output: VertexOutput;
|
|
42
|
+
var position = input.position;
|
|
43
|
+
${s?"position.y = elevation(u.terrain.xy + input.uv * u.terrain.z, u.terrain.w) - u.terrain.w;":""}
|
|
44
|
+
let highlighted = f32(vertexIndex) >= u.highlight.x && f32(vertexIndex) < u.highlight.y;
|
|
45
|
+
output.color = ${e.vertexColors?"select(input.color, vec3<f32>(72.0 / 255.0, 217.0 / 255.0, 1.0), highlighted)":"u.baseColor.rgb"};
|
|
46
|
+
// Inverse-transpose from cofactors; the camera view matrix is orthonormal.
|
|
47
|
+
let m = mat3x3<f32>(u.worldMatrix[0].xyz, u.worldMatrix[1].xyz, u.worldMatrix[2].xyz);
|
|
48
|
+
let normal = (cross(m[1], m[2]) * input.normal.x + cross(m[2], m[0]) * input.normal.y +
|
|
49
|
+
cross(m[0], m[1]) * input.normal.z) / determinant(m);
|
|
50
|
+
output.normal = (frame.viewMatrix * vec4<f32>(normal, 0.0)).xyz;
|
|
51
|
+
let world = u.worldMatrix * vec4<f32>(position, 1.0);
|
|
52
|
+
output.shadowPosition = solar.matrix * world;
|
|
53
|
+
output.worldPosition = world.xyz / world.w;
|
|
54
|
+
${t?"output.localPosition = input.position;":""}
|
|
55
|
+
let viewPosition = frame.viewMatrix * world;
|
|
56
|
+
output.viewPosition = viewPosition.xyz;
|
|
57
|
+
${i?"output.uv = input.uv;":""}
|
|
58
|
+
${o?`
|
|
59
|
+
output.roofUv = (frame.roofMatrix * world).xz;
|
|
60
|
+
output.roof = select(0.0, 1.0, input.normal.y >= 0.5 && !highlighted);
|
|
61
|
+
`:""}
|
|
62
|
+
output.position = frame.projectionMatrix * viewPosition;
|
|
63
|
+
return output;
|
|
64
|
+
}
|
|
65
|
+
`,v=[];let n=3;const r=(f,$)=>{if(!$)return"";v.push({name:f,texture:n,sampler:n+1});const p=n;return n+=2,`@group(0) @binding(${p}) var ${f}: texture_2d<f32>;
|
|
66
|
+
@group(0) @binding(${p+1}) var ${f}Sampler: sampler;`},g=r("baseTexture",a),d=r("metalTexture",l),h=r("emissiveTexture",c),w=r("occlusionTexture",u),b=r("roofTexture",o),y=`
|
|
67
|
+
struct Mesh {
|
|
68
|
+
worldMatrix: mat4x4<f32>,
|
|
69
|
+
baseColor: vec4<f32>,
|
|
70
|
+
material: vec4<f32>,
|
|
71
|
+
emissive: vec4<f32>,
|
|
72
|
+
terrain: vec4<f32>,
|
|
73
|
+
highlight: vec4<f32>,
|
|
74
|
+
};
|
|
75
|
+
struct Frame {
|
|
76
|
+
viewMatrix: mat4x4<f32>,
|
|
77
|
+
projectionMatrix: mat4x4<f32>,
|
|
78
|
+
roofMatrix: mat4x4<f32>,
|
|
79
|
+
lightDirection: vec4<f32>,
|
|
80
|
+
skyDirection: vec4<f32>,
|
|
81
|
+
atmosphereTint: vec4<f32>,
|
|
82
|
+
};
|
|
83
|
+
struct Solar {
|
|
84
|
+
matrix: mat4x4<f32>,
|
|
85
|
+
params: vec4<f32>,
|
|
86
|
+
};
|
|
87
|
+
@group(0) @binding(0) var<uniform> u: Mesh;
|
|
88
|
+
@group(0) @binding(1) var<uniform> frame: Frame;
|
|
89
|
+
@group(1) @binding(0) var<uniform> solar: Solar;
|
|
90
|
+
@group(1) @binding(1) var shadowTexture: texture_depth_2d;
|
|
91
|
+
@group(1) @binding(2) var shadowSampler: sampler_comparison;
|
|
92
|
+
@group(1) @binding(3) var<storage, read> lightGrid: array<vec4<f32>>;
|
|
93
|
+
${g}${d}${h}${w}${b}
|
|
94
|
+
struct FragmentInput {
|
|
95
|
+
@builtin(position) position: vec4<f32>,
|
|
96
|
+
@location(0) color: vec3<f32>,
|
|
97
|
+
@location(1) normal: vec3<f32>,
|
|
98
|
+
@location(2) viewPosition: vec3<f32>,
|
|
99
|
+
@location(6) shadowPosition: vec4<f32>,
|
|
100
|
+
@location(7) worldPosition: vec3<f32>,
|
|
101
|
+
${t?"@location(8) localPosition: vec3<f32>,":""}
|
|
102
|
+
${i?"@location(3) uv: vec2<f32>,":""}
|
|
103
|
+
${o?"@location(4) roofUv: vec2<f32>, @location(5) roof: f32,":""}
|
|
104
|
+
};
|
|
105
|
+
const PI: f32 = 3.14159265;
|
|
106
|
+
fn toLinear(c: vec3<f32>) -> vec3<f32> {
|
|
107
|
+
return select(c / 12.92, pow((c + vec3<f32>(0.055)) / 1.055, vec3<f32>(2.4)), c >= vec3<f32>(0.04045));
|
|
108
|
+
}
|
|
109
|
+
fn toSRGB(c: vec3<f32>) -> vec3<f32> {
|
|
110
|
+
return select(c * 12.92, 1.055 * pow(max(c, vec3<f32>(0.0)), vec3<f32>(1.0 / 2.4)) - vec3<f32>(0.055), c >= vec3<f32>(0.0031308));
|
|
111
|
+
}
|
|
112
|
+
fn sunVisibility(position: vec4<f32>) -> f32 {
|
|
113
|
+
let p = position.xyz / position.w;
|
|
114
|
+
let uv = vec2<f32>(p.x * 0.5 + 0.5, 0.5 - p.y * 0.5);
|
|
115
|
+
if (solar.params.x < 0.5 || any(uv < vec2<f32>(0.0)) || any(uv > vec2<f32>(1.0)) || p.z < 0.0 || p.z > 1.0) {
|
|
116
|
+
return 1.0;
|
|
117
|
+
}
|
|
118
|
+
return textureSampleCompareLevel(shadowTexture, shadowSampler, uv, p.z - 0.0003);
|
|
119
|
+
}
|
|
120
|
+
fn localLighting(position: vec3<f32>, normal: vec3<f32>) -> vec3<f32> {
|
|
121
|
+
if (frame.skyDirection.w <= 0.0 || lightGrid[0].w < 1.0) { return vec3<f32>(0.0); }
|
|
122
|
+
let cell = vec2<i32>(floor((position.xz - lightGrid[0].xy) / lightGrid[0].z));
|
|
123
|
+
if (any(cell < vec2<i32>(0)) || cell.x >= i32(lightGrid[0].w) || cell.y >= i32(lightGrid[1].x)) {
|
|
124
|
+
return vec3<f32>(0.0);
|
|
125
|
+
}
|
|
126
|
+
let header = lightGrid[2u + u32(cell.y) * u32(lightGrid[0].w) + u32(cell.x)];
|
|
127
|
+
var light = vec3<f32>(0.0);
|
|
128
|
+
for (var i = 0u; i < u32(header.y); i++) {
|
|
129
|
+
let source = lightGrid[u32(header.x) + i * 2u];
|
|
130
|
+
let colour = lightGrid[u32(header.x) + i * 2u + 1u];
|
|
131
|
+
let delta = source.xyz - position;
|
|
132
|
+
let distance2 = max(dot(delta, delta), 1.0);
|
|
133
|
+
let falloff = max(0.0, 1.0 - distance2 / (source.w * source.w));
|
|
134
|
+
let lambert = max(0.0, dot(normal, delta / sqrt(distance2)));
|
|
135
|
+
light += toLinear(colour.rgb) * colour.w * lambert * falloff * falloff / distance2;
|
|
136
|
+
}
|
|
137
|
+
return light * frame.skyDirection.w;
|
|
138
|
+
}
|
|
139
|
+
fn appearance(position: vec2<f32>) {
|
|
140
|
+
// Screen-door dissolve keeps opaque depth writes and avoids sorting whole buildings as glass.
|
|
141
|
+
let noise = fract(52.9829189 * fract(dot(floor(position), vec2<f32>(0.06711056, 0.00583715))));
|
|
142
|
+
if (u.highlight.w < 1.0 && noise >= u.highlight.w) { discard; }
|
|
143
|
+
}
|
|
144
|
+
@fragment fn fragmentMain(input: FragmentInput, @builtin(front_facing) frontFacing: bool) -> @location(0) vec4<f32> {
|
|
145
|
+
${e.nightLight?`
|
|
146
|
+
if (input.uv.x <= 2.0) {
|
|
147
|
+
let radial = max(0.0, 1.0 - dot(input.uv, input.uv));
|
|
148
|
+
let alpha = radial * radial * frame.skyDirection.w * 0.65;
|
|
149
|
+
if (alpha < 0.005) { discard; }
|
|
150
|
+
appearance(input.position.xy);
|
|
151
|
+
return vec4<f32>(input.color, alpha);
|
|
152
|
+
}
|
|
153
|
+
`:""}
|
|
154
|
+
let sunlight = sunVisibility(input.shadowPosition);
|
|
155
|
+
let worldNormal = normalize(transpose(mat3x3<f32>(frame.viewMatrix[0].xyz, frame.viewMatrix[1].xyz, frame.viewMatrix[2].xyz)) * normalize(input.normal)) * select(-1.0, 1.0, frontFacing);
|
|
156
|
+
let artificial = localLighting(input.worldPosition, worldNormal);
|
|
157
|
+
${e.unlit?`
|
|
158
|
+
let rasterTexel = ${a?"textureSample(baseTexture, baseTextureSampler, input.uv)":"vec4<f32>(input.color, 1.0)"};
|
|
159
|
+
return vec4<f32>(toSRGB(toLinear(rasterTexel.rgb) * (frame.atmosphereTint.rgb * (0.55 + 0.45 * sunlight) + artificial)), ${e.alphaMode==="BLEND"?"u.material.z * rasterTexel.a":"1.0"});
|
|
160
|
+
`:`
|
|
161
|
+
var normal = normalize(input.normal) * select(-1.0, 1.0, frontFacing);
|
|
162
|
+
let texel = ${a?"textureSample(baseTexture, baseTextureSampler, input.uv)":"vec4<f32>(1.0)"};
|
|
163
|
+
let alpha = u.material.z * texel.a;
|
|
164
|
+
${e.alphaMode==="MASK"?"if (alpha < u.material.w) { discard; }":""}
|
|
165
|
+
${e.alphaMode==="BLEND"?"if (alpha < 0.01) { discard; }":""}
|
|
166
|
+
var base = ${e.vertexColors?"toLinear(min(input.color, vec3<f32>(1.0)))":"input.color"} *
|
|
167
|
+
${e.baseTexture?.srgb?"texel.rgb":"toLinear(texel.rgb)"};
|
|
168
|
+
${o?`
|
|
169
|
+
if (input.roof > 0.5 && all(input.roofUv >= vec2<f32>(0.0)) &&
|
|
170
|
+
all(input.roofUv <= vec2<f32>(1.0))) {
|
|
171
|
+
let roof = textureSampleLevel(roofTexture, roofTextureSampler, input.roofUv, 0.0);
|
|
172
|
+
base = mix(base, toLinear(roof.rgb), roof.a);
|
|
173
|
+
}
|
|
174
|
+
`:""}
|
|
175
|
+
let mr = ${l?"textureSample(metalTexture, metalTextureSampler, input.uv)":"vec4<f32>(1.0)"};
|
|
176
|
+
let metal = clamp(u.material.x * mr.b, 0.0, 1.0);
|
|
177
|
+
let rough = clamp(u.material.y * mr.g, 0.08, 1.0);
|
|
178
|
+
let view = normalize(-input.viewPosition);
|
|
179
|
+
let halfVector = normalize(view + frame.lightDirection.xyz);
|
|
180
|
+
let nl = max(dot(normal, frame.lightDirection.xyz), 0.0) * frame.lightDirection.w * sunlight;
|
|
181
|
+
let nv = max(dot(normal, view), 0.001);
|
|
182
|
+
let nh = max(dot(normal, halfVector), 0.0);
|
|
183
|
+
let vh = max(dot(view, halfVector), 0.0);
|
|
184
|
+
let a2 = pow(rough, 4.0);
|
|
185
|
+
let d = a2 / max(PI * pow(nh * nh * (a2 - 1.0) + 1.0, 2.0), 0.0001);
|
|
186
|
+
let gv = nl * sqrt(nv * nv * (1.0 - a2) + a2);
|
|
187
|
+
let gl = nv * sqrt(nl * nl * (1.0 - a2) + a2);
|
|
188
|
+
let visibility = 0.5 / max(gv + gl, 0.0001);
|
|
189
|
+
let f0 = mix(vec3<f32>(0.04), base, metal);
|
|
190
|
+
let fresnel = f0 + (1.0 - f0) * pow(1.0 - vh, 5.0);
|
|
191
|
+
let specular = d * visibility * fresnel;
|
|
192
|
+
let diffuse = (1.0 - metal) * base / PI;
|
|
193
|
+
let sky = dot(normal, frame.skyDirection.xyz) * 0.5 + 0.5;
|
|
194
|
+
let ambient = mix(toLinear(vec3<f32>(0.455, 0.412, 0.322)), vec3<f32>(1.0), sky) * (2.0 / PI);
|
|
195
|
+
let ao = ${u?"mix(1.0, textureSample(occlusionTexture, occlusionTextureSampler, input.uv).r, u.emissive.w)":"1.0"};
|
|
196
|
+
${t?`
|
|
197
|
+
let lattice = (fract(input.localPosition / 2.5) - 0.5) * 2.5;
|
|
198
|
+
let pointGlow = (1.0 - smoothstep(0.16, 0.42, length(lattice))) * u.highlight.z;
|
|
199
|
+
`:""}
|
|
200
|
+
// Vertex colour components above 1 are self-lit (e.g. vehicle lamps): dim by day, bright at night.
|
|
201
|
+
let glow = ${t?"vec3<f32>(3.0, 2.6, 1.8) * pointGlow +":""}${e.vertexColors?" max(input.color - vec3<f32>(1.0), vec3<f32>(0.0)) * (0.3 + 5.0 * frame.skyDirection.w) +":""} u.emissive.rgb * ${c?e.emissiveTexture.srgb?"textureSample(emissiveTexture, emissiveTextureSampler, input.uv).rgb":"toLinear(textureSample(emissiveTexture, emissiveTextureSampler, input.uv).rgb)":"vec3<f32>(1.0)"};
|
|
202
|
+
var color = ambient * base * (1.0 - metal) * ao +
|
|
203
|
+
(diffuse + specular) * nl * toLinear(vec3<f32>(1.0, 0.937, 0.835)) * 3.0 + glow;
|
|
204
|
+
${e.vertexColors?"color = base * (ambient + toLinear(vec3<f32>(1.0, 0.937, 0.835)) * (3.0 / PI) * nl) + glow;":""}
|
|
205
|
+
color = (color - glow) * frame.atmosphereTint.rgb + base * artificial * (1.0 - metal * 0.5) + glow;
|
|
206
|
+
appearance(input.position.xy);
|
|
207
|
+
return vec4<f32>(toSRGB(color), ${e.alphaMode==="BLEND"?"alpha":"1.0"});
|
|
208
|
+
`}
|
|
209
|
+
}
|
|
210
|
+
`;return{vertex:x,fragment:y,bindings:v,textured:i,hasTerrain:s}}export{T as materialShaders};
|
|
211
|
+
//# sourceMappingURL=materialShaders.js.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../src/utils/materialShaders.js"],
|
|
4
|
+
"sourcesContent": ["/** Material WGSL and texture bindings, without a GPU device or Leaflet layer. */\nexport function materialShaders(material = {}, sparkle = false, elevationWGSL = '') {\n const hasBase = Boolean(material.baseTexture);\n const hasMetal = Boolean(material.metalTexture);\n const hasEmissive = Boolean(material.emissiveTexture);\n const hasOcclusion = Boolean(material.occlusionTexture);\n const hasRoof = Boolean(material.roofTexture);\n const hasTerrain = Boolean(material.terrain);\n const textured = hasBase || hasMetal || hasEmissive || hasOcclusion || material.nightLight;\n const vertex = `\n struct Mesh {\n worldMatrix: mat4x4<f32>,\n baseColor: vec4<f32>,\n material: vec4<f32>,\n emissive: vec4<f32>,\n terrain: vec4<f32>,\n highlight: vec4<f32>,\n };\n struct Frame {\n viewMatrix: mat4x4<f32>,\n projectionMatrix: mat4x4<f32>,\n roofMatrix: mat4x4<f32>,\n lightDirection: vec4<f32>,\n skyDirection: vec4<f32>,\n atmosphereTint: vec4<f32>,\n };\n @group(0) @binding(0) var<uniform> u: Mesh;\n @group(0) @binding(1) var<uniform> frame: Frame;\n struct Solar { matrix: mat4x4<f32>, params: vec4<f32> };\n @group(1) @binding(0) var<uniform> solar: Solar;\n ${hasTerrain ? `@group(0) @binding(2) var dem: texture_2d<f32>;${elevationWGSL}` : ''}\n struct VertexInput {\n @location(0) position: vec3<f32>,\n @location(1) normal: vec3<f32>,\n ${material.vertexColors ? '@location(2) color: vec3<f32>,' : ''}\n ${textured ? '@location(3) uv: vec2<f32>,' : ''}\n };\n struct VertexOutput {\n @builtin(position) position: vec4<f32>,\n @location(0) color: vec3<f32>,\n @location(1) normal: vec3<f32>,\n @location(2) viewPosition: vec3<f32>,\n @location(6) shadowPosition: vec4<f32>,\n @location(7) worldPosition: vec3<f32>,\n ${sparkle ? '@location(8) localPosition: vec3<f32>,' : ''}\n ${textured ? '@location(3) uv: vec2<f32>,' : ''}\n ${hasRoof ? '@location(4) roofUv: vec2<f32>, @location(5) roof: f32,' : ''}\n };\n @vertex fn vertexMain(input: VertexInput, @builtin(vertex_index) vertexIndex: u32) -> VertexOutput {\n var output: VertexOutput;\n var position = input.position;\n ${hasTerrain ? 'position.y = elevation(u.terrain.xy + input.uv * u.terrain.z, u.terrain.w) - u.terrain.w;' : ''}\n let highlighted = f32(vertexIndex) >= u.highlight.x && f32(vertexIndex) < u.highlight.y;\n output.color = ${material.vertexColors\n ? 'select(input.color, vec3<f32>(72.0 / 255.0, 217.0 / 255.0, 1.0), highlighted)'\n : 'u.baseColor.rgb'};\n // Inverse-transpose from cofactors; the camera view matrix is orthonormal.\n let m = mat3x3<f32>(u.worldMatrix[0].xyz, u.worldMatrix[1].xyz, u.worldMatrix[2].xyz);\n let normal = (cross(m[1], m[2]) * input.normal.x + cross(m[2], m[0]) * input.normal.y +\n cross(m[0], m[1]) * input.normal.z) / determinant(m);\n output.normal = (frame.viewMatrix * vec4<f32>(normal, 0.0)).xyz;\n let world = u.worldMatrix * vec4<f32>(position, 1.0);\n output.shadowPosition = solar.matrix * world;\n output.worldPosition = world.xyz / world.w;\n ${sparkle ? 'output.localPosition = input.position;' : ''}\n let viewPosition = frame.viewMatrix * world;\n output.viewPosition = viewPosition.xyz;\n ${textured ? 'output.uv = input.uv;' : ''}\n ${hasRoof ? `\n output.roofUv = (frame.roofMatrix * world).xz;\n output.roof = select(0.0, 1.0, input.normal.y >= 0.5 && !highlighted);\n ` : ''}\n output.position = frame.projectionMatrix * viewPosition;\n return output;\n }\n `;\n const bindings = [];\n let binding = 3;\n const textureBinding = (name, enabled) => {\n if (!enabled) return '';\n bindings.push({ name, texture: binding, sampler: binding + 1 });\n const current = binding;\n binding += 2;\n return `@group(0) @binding(${current}) var ${name}: texture_2d<f32>;\n @group(0) @binding(${current + 1}) var ${name}Sampler: sampler;`;\n };\n const baseBinding = textureBinding('baseTexture', hasBase);\n const metalBinding = textureBinding('metalTexture', hasMetal);\n const emissiveBinding = textureBinding('emissiveTexture', hasEmissive);\n const occlusionBinding = textureBinding('occlusionTexture', hasOcclusion);\n const roofBinding = textureBinding('roofTexture', hasRoof);\n const fragment = `\n struct Mesh {\n worldMatrix: mat4x4<f32>,\n baseColor: vec4<f32>,\n material: vec4<f32>,\n emissive: vec4<f32>,\n terrain: vec4<f32>,\n highlight: vec4<f32>,\n };\n struct Frame {\n viewMatrix: mat4x4<f32>,\n projectionMatrix: mat4x4<f32>,\n roofMatrix: mat4x4<f32>,\n lightDirection: vec4<f32>,\n skyDirection: vec4<f32>,\n atmosphereTint: vec4<f32>,\n };\n struct Solar {\n matrix: mat4x4<f32>,\n params: vec4<f32>,\n };\n @group(0) @binding(0) var<uniform> u: Mesh;\n @group(0) @binding(1) var<uniform> frame: Frame;\n @group(1) @binding(0) var<uniform> solar: Solar;\n @group(1) @binding(1) var shadowTexture: texture_depth_2d;\n @group(1) @binding(2) var shadowSampler: sampler_comparison;\n @group(1) @binding(3) var<storage, read> lightGrid: array<vec4<f32>>;\n ${baseBinding}${metalBinding}${emissiveBinding}${occlusionBinding}${roofBinding}\n struct FragmentInput {\n @builtin(position) position: vec4<f32>,\n @location(0) color: vec3<f32>,\n @location(1) normal: vec3<f32>,\n @location(2) viewPosition: vec3<f32>,\n @location(6) shadowPosition: vec4<f32>,\n @location(7) worldPosition: vec3<f32>,\n ${sparkle ? '@location(8) localPosition: vec3<f32>,' : ''}\n ${textured ? '@location(3) uv: vec2<f32>,' : ''}\n ${hasRoof ? '@location(4) roofUv: vec2<f32>, @location(5) roof: f32,' : ''}\n };\n const PI: f32 = 3.14159265;\n fn toLinear(c: vec3<f32>) -> vec3<f32> {\n return select(c / 12.92, pow((c + vec3<f32>(0.055)) / 1.055, vec3<f32>(2.4)), c >= vec3<f32>(0.04045));\n }\n fn toSRGB(c: vec3<f32>) -> vec3<f32> {\n return select(c * 12.92, 1.055 * pow(max(c, vec3<f32>(0.0)), vec3<f32>(1.0 / 2.4)) - vec3<f32>(0.055), c >= vec3<f32>(0.0031308));\n }\n fn sunVisibility(position: vec4<f32>) -> f32 {\n let p = position.xyz / position.w;\n let uv = vec2<f32>(p.x * 0.5 + 0.5, 0.5 - p.y * 0.5);\n if (solar.params.x < 0.5 || any(uv < vec2<f32>(0.0)) || any(uv > vec2<f32>(1.0)) || p.z < 0.0 || p.z > 1.0) {\n return 1.0;\n }\n return textureSampleCompareLevel(shadowTexture, shadowSampler, uv, p.z - 0.0003);\n }\n fn localLighting(position: vec3<f32>, normal: vec3<f32>) -> vec3<f32> {\n if (frame.skyDirection.w <= 0.0 || lightGrid[0].w < 1.0) { return vec3<f32>(0.0); }\n let cell = vec2<i32>(floor((position.xz - lightGrid[0].xy) / lightGrid[0].z));\n if (any(cell < vec2<i32>(0)) || cell.x >= i32(lightGrid[0].w) || cell.y >= i32(lightGrid[1].x)) {\n return vec3<f32>(0.0);\n }\n let header = lightGrid[2u + u32(cell.y) * u32(lightGrid[0].w) + u32(cell.x)];\n var light = vec3<f32>(0.0);\n for (var i = 0u; i < u32(header.y); i++) {\n let source = lightGrid[u32(header.x) + i * 2u];\n let colour = lightGrid[u32(header.x) + i * 2u + 1u];\n let delta = source.xyz - position;\n let distance2 = max(dot(delta, delta), 1.0);\n let falloff = max(0.0, 1.0 - distance2 / (source.w * source.w));\n let lambert = max(0.0, dot(normal, delta / sqrt(distance2)));\n light += toLinear(colour.rgb) * colour.w * lambert * falloff * falloff / distance2;\n }\n return light * frame.skyDirection.w;\n }\n fn appearance(position: vec2<f32>) {\n // Screen-door dissolve keeps opaque depth writes and avoids sorting whole buildings as glass.\n let noise = fract(52.9829189 * fract(dot(floor(position), vec2<f32>(0.06711056, 0.00583715))));\n if (u.highlight.w < 1.0 && noise >= u.highlight.w) { discard; }\n }\n @fragment fn fragmentMain(input: FragmentInput, @builtin(front_facing) frontFacing: bool) -> @location(0) vec4<f32> {\n ${material.nightLight ? `\n if (input.uv.x <= 2.0) {\n let radial = max(0.0, 1.0 - dot(input.uv, input.uv));\n let alpha = radial * radial * frame.skyDirection.w * 0.65;\n if (alpha < 0.005) { discard; }\n appearance(input.position.xy);\n return vec4<f32>(input.color, alpha);\n }\n ` : ''}\n let sunlight = sunVisibility(input.shadowPosition);\n let worldNormal = normalize(transpose(mat3x3<f32>(frame.viewMatrix[0].xyz, frame.viewMatrix[1].xyz, frame.viewMatrix[2].xyz)) * normalize(input.normal)) * select(-1.0, 1.0, frontFacing);\n let artificial = localLighting(input.worldPosition, worldNormal);\n ${material.unlit ? `\n let rasterTexel = ${hasBase ? 'textureSample(baseTexture, baseTextureSampler, input.uv)' : 'vec4<f32>(input.color, 1.0)'};\n return vec4<f32>(toSRGB(toLinear(rasterTexel.rgb) * (frame.atmosphereTint.rgb * (0.55 + 0.45 * sunlight) + artificial)), ${material.alphaMode === 'BLEND' ? 'u.material.z * rasterTexel.a' : '1.0'});\n ` : `\n var normal = normalize(input.normal) * select(-1.0, 1.0, frontFacing);\n let texel = ${hasBase ? 'textureSample(baseTexture, baseTextureSampler, input.uv)' : 'vec4<f32>(1.0)'};\n let alpha = u.material.z * texel.a;\n ${material.alphaMode === 'MASK' ? 'if (alpha < u.material.w) { discard; }' : ''}\n ${material.alphaMode === 'BLEND' ? 'if (alpha < 0.01) { discard; }' : ''}\n var base = ${material.vertexColors ? 'toLinear(min(input.color, vec3<f32>(1.0)))' : 'input.color'} *\n ${material.baseTexture?.srgb ? 'texel.rgb' : 'toLinear(texel.rgb)'};\n ${hasRoof ? `\n if (input.roof > 0.5 && all(input.roofUv >= vec2<f32>(0.0)) &&\n all(input.roofUv <= vec2<f32>(1.0))) {\n let roof = textureSampleLevel(roofTexture, roofTextureSampler, input.roofUv, 0.0);\n base = mix(base, toLinear(roof.rgb), roof.a);\n }\n ` : ''}\n let mr = ${hasMetal ? 'textureSample(metalTexture, metalTextureSampler, input.uv)' : 'vec4<f32>(1.0)'};\n let metal = clamp(u.material.x * mr.b, 0.0, 1.0);\n let rough = clamp(u.material.y * mr.g, 0.08, 1.0);\n let view = normalize(-input.viewPosition);\n let halfVector = normalize(view + frame.lightDirection.xyz);\n let nl = max(dot(normal, frame.lightDirection.xyz), 0.0) * frame.lightDirection.w * sunlight;\n let nv = max(dot(normal, view), 0.001);\n let nh = max(dot(normal, halfVector), 0.0);\n let vh = max(dot(view, halfVector), 0.0);\n let a2 = pow(rough, 4.0);\n let d = a2 / max(PI * pow(nh * nh * (a2 - 1.0) + 1.0, 2.0), 0.0001);\n let gv = nl * sqrt(nv * nv * (1.0 - a2) + a2);\n let gl = nv * sqrt(nl * nl * (1.0 - a2) + a2);\n let visibility = 0.5 / max(gv + gl, 0.0001);\n let f0 = mix(vec3<f32>(0.04), base, metal);\n let fresnel = f0 + (1.0 - f0) * pow(1.0 - vh, 5.0);\n let specular = d * visibility * fresnel;\n let diffuse = (1.0 - metal) * base / PI;\n let sky = dot(normal, frame.skyDirection.xyz) * 0.5 + 0.5;\n let ambient = mix(toLinear(vec3<f32>(0.455, 0.412, 0.322)), vec3<f32>(1.0), sky) * (2.0 / PI);\n let ao = ${hasOcclusion ? 'mix(1.0, textureSample(occlusionTexture, occlusionTextureSampler, input.uv).r, u.emissive.w)' : '1.0'};\n ${sparkle ? `\n let lattice = (fract(input.localPosition / 2.5) - 0.5) * 2.5;\n let pointGlow = (1.0 - smoothstep(0.16, 0.42, length(lattice))) * u.highlight.z;\n ` : ''}\n // Vertex colour components above 1 are self-lit (e.g. vehicle lamps): dim by day, bright at night.\n let glow = ${sparkle ? 'vec3<f32>(3.0, 2.6, 1.8) * pointGlow +' : ''}${material.vertexColors\n ? ' max(input.color - vec3<f32>(1.0), vec3<f32>(0.0)) * (0.3 + 5.0 * frame.skyDirection.w) +' : ''} u.emissive.rgb * ${hasEmissive\n ? material.emissiveTexture.srgb\n ? 'textureSample(emissiveTexture, emissiveTextureSampler, input.uv).rgb'\n : 'toLinear(textureSample(emissiveTexture, emissiveTextureSampler, input.uv).rgb)'\n : 'vec3<f32>(1.0)'};\n var color = ambient * base * (1.0 - metal) * ao +\n (diffuse + specular) * nl * toLinear(vec3<f32>(1.0, 0.937, 0.835)) * 3.0 + glow;\n ${material.vertexColors ? 'color = base * (ambient + toLinear(vec3<f32>(1.0, 0.937, 0.835)) * (3.0 / PI) * nl) + glow;' : ''}\n color = (color - glow) * frame.atmosphereTint.rgb + base * artificial * (1.0 - metal * 0.5) + glow;\n appearance(input.position.xy);\n return vec4<f32>(toSRGB(color), ${material.alphaMode === 'BLEND' ? 'alpha' : '1.0'});\n `}\n }\n `;\n return { vertex, fragment, bindings, textured, hasTerrain };\n}\n"],
|
|
5
|
+
"mappings": "AACO,SAASA,EAAgBC,EAAW,CAAC,EAAGC,EAAU,GAAOC,EAAgB,GAAI,CAClF,MAAMC,EAAU,EAAQH,EAAS,YAC3BI,EAAW,EAAQJ,EAAS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AAa,KAAO,YAAc,qBAAqB;AAAA,QAClEO,EAAU;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,QAMR,EAAE;AAAA,iBACKH,EAAW,6DAA+D,gBAAgB;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,iBAoB1FE,EAAe,+FAAiG,KAAK;AAAA,QAC9HL,EAAU;AAAA;AAAA;AAAA,QAGR,EAAE;AAAA;AAAA,mBAEOA,EAAU,yCAA2C,EAAE,GAAGD,EAAS,aAC9E,4FAA8F,EAAE,qBAAqBK,EACrHL,EAAS,gBAAgB,KACvB,uEACA,iFACF,gBAAgB;AAAA;AAAA;AAAA,QAGhBA,EAAS,aAAe,8FAAgG,EAAE;AAAA;AAAA;AAAA,wCAG1FA,EAAS,YAAc,QAAU,QAAU,KAAK;AAAA,OACjF;AAAA;AAAA,IAGL,MAAO,CAAE,OAAAU,EAAQ,SAAAY,EAAU,SAAAX,EAAU,SAAAF,EAAU,WAAAD,CAAW,CAC5D",
|
|
6
|
+
"names": ["materialShaders", "material", "sparkle", "elevationWGSL", "hasBase", "hasMetal", "hasEmissive", "hasOcclusion", "hasRoof", "hasTerrain", "textured", "vertex", "bindings", "binding", "textureBinding", "name", "enabled", "current", "baseBinding", "metalBinding", "emissiveBinding", "occlusionBinding", "roofBinding", "fragment"]
|
|
7
|
+
}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../src/utils/mirror.js"],
|
|
4
|
+
"sourcesContent": ["import { box } from \"./box.js\";\n\nexport const mirror = (x0, x1, z0, z1, ...rest) => [\n [box(x0, x1, z0, z1), ...rest],\n [box(-x1, -x0, z0, z1), ...rest]\n];\n"],
|
|
5
|
+
"mappings": "AAAA,OAAS,OAAAA,MAAW,WAEb,MAAMC,EAAS,CAACC,EAAIC,EAAIC,EAAIC,KAAOC,IAAS,CACjD,CAACN,EAAIE,EAAIC,EAAIC,EAAIC,CAAE,EAAG,GAAGC,CAAI,EAC7B,CAACN,EAAI,CAACG,EAAI,CAACD,EAAIE,EAAIC,CAAE,EAAG,GAAGC,CAAI,CACjC",
|
|
6
|
+
"names": ["box", "mirror", "x0", "x1", "z0", "z1", "rest"]
|
|
7
|
+
}
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
import{solarPosition as u}from"./solarPosition.js";import{horizontalPosition as l}from"./horizontalPosition.js";function f(i,h,M){u(i,h,M);const t=Math.PI/180,n=new Date(i).getTime()/864e5-10957.5,c=(134.963+13.064993*n)*t,a=(218.316+13.176396*n+6.289*Math.sin(c))*t,o=5.128*Math.sin((93.272+13.22935*n)*t)*t,s=23.4397*t,r=Math.cos(o)*Math.cos(a),e=Math.cos(o)*Math.sin(a)*Math.cos(s)-Math.sin(o)*Math.sin(s),m=Math.cos(o)*Math.sin(a)*Math.sin(s)+Math.sin(o)*Math.cos(s);return l(n,h,M,Math.atan2(e,r),Math.asin(m))}export{f as moonPosition};
|
|
2
|
+
//# sourceMappingURL=moonPosition.js.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../src/utils/moonPosition.js"],
|
|
4
|
+
"sourcesContent": ["import { solarPosition } from \"./solarPosition.js\";\nimport { horizontalPosition } from \"./horizontalPosition.js\";\n\n// Low-precision geocentric lunar orbit; no parallax or atmospheric refraction.\n\nexport function moonPosition(date, lat, lng) {\n solarPosition(date, lat, lng);\n const rad = Math.PI / 180, d = new Date(date).getTime() / 86400000 - 10957.5;\n const anomaly = (134.963 + 13.064993 * d) * rad;\n const longitude = (218.316 + 13.176396 * d + 6.289 * Math.sin(anomaly)) * rad;\n const latitude = 5.128 * Math.sin((93.272 + 13.229350 * d) * rad) * rad;\n const obliquity = 23.4397 * rad;\n const x = Math.cos(latitude) * Math.cos(longitude);\n const y = Math.cos(latitude) * Math.sin(longitude) * Math.cos(obliquity) - Math.sin(latitude) * Math.sin(obliquity);\n const z = Math.cos(latitude) * Math.sin(longitude) * Math.sin(obliquity) + Math.sin(latitude) * Math.cos(obliquity);\n return horizontalPosition(d, lat, lng, Math.atan2(y, x), Math.asin(z));\n}\n"],
|
|
5
|
+
"mappings": "AAAA,OAAS,iBAAAA,MAAqB,qBAC9B,OAAS,sBAAAC,MAA0B,0BAI5B,SAASC,EAAaC,EAAMC,EAAKC,EAAK,CAC3CL,EAAcG,EAAMC,EAAKC,CAAG,EAC5B,MAAMC,EAAM,KAAK,GAAK,IAAKC,EAAI,IAAI,KAAKJ,CAAI,EAAE,QAAQ,EAAI,MAAW,QAC/DK,GAAW,QAAU,UAAYD,GAAKD,EACtCG,GAAa,QAAU,UAAYF,EAAI,MAAQ,KAAK,IAAIC,CAAO,GAAKF,EACpEI,EAAW,MAAQ,KAAK,KAAK,OAAS,SAAYH,GAAKD,CAAG,EAAIA,EAC9DK,EAAY,QAAUL,EACtBM,EAAI,KAAK,IAAIF,CAAQ,EAAI,KAAK,IAAID,CAAS,EAC3CI,EAAI,KAAK,IAAIH,CAAQ,EAAI,KAAK,IAAID,CAAS,EAAI,KAAK,IAAIE,CAAS,EAAI,KAAK,IAAID,CAAQ,EAAI,KAAK,IAAIC,CAAS,EAC5GG,EAAI,KAAK,IAAIJ,CAAQ,EAAI,KAAK,IAAID,CAAS,EAAI,KAAK,IAAIE,CAAS,EAAI,KAAK,IAAID,CAAQ,EAAI,KAAK,IAAIC,CAAS,EAClH,OAAOV,EAAmBM,EAAGH,EAAKC,EAAK,KAAK,MAAMQ,EAAGD,CAAC,EAAG,KAAK,KAAKE,CAAC,CAAC,CACvE",
|
|
6
|
+
"names": ["solarPosition", "horizontalPosition", "moonPosition", "date", "lat", "lng", "rad", "d", "anomaly", "longitude", "latitude", "obliquity", "x", "y", "z"]
|
|
7
|
+
}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../src/utils/moves.js"],
|
|
4
|
+
"sourcesContent": ["// W/S (\u2191/\u2193) run forward/back along the heading, A/D (\u2190/\u2192) turn: [forward, turn].\nexport const moves = {\n KeyW: [1, 0],\n ArrowUp: [1, 0],\n KeyS: [-1, 0],\n ArrowDown: [-1, 0],\n KeyD: [0, 1],\n ArrowRight: [0, 1],\n KeyA: [0, -1],\n ArrowLeft: [0, -1]\n};\n"],
|
|
5
|
+
"mappings": "AACO,MAAMA,EAAQ,CACnB,KAAM,CAAC,EAAG,CAAC,EACX,QAAS,CAAC,EAAG,CAAC,EACd,KAAM,CAAC,GAAI,CAAC,EACZ,UAAW,CAAC,GAAI,CAAC,EACjB,KAAM,CAAC,EAAG,CAAC,EACX,WAAY,CAAC,EAAG,CAAC,EACjB,KAAM,CAAC,EAAG,EAAE,EACZ,UAAW,CAAC,EAAG,EAAE,CACnB",
|
|
6
|
+
"names": ["moves"]
|
|
7
|
+
}
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
import{raycast as k}from"./raycast.js";const h=new WeakMap;function b(a){const{map:e}=a;let o=h.get(e);if(!o){o={states:new Set,hovered:null};const u=L.version.startsWith("2"),d=u?"pointermove":"mousemove",c=u?"pointerout":"mouseout",E=u?"pointerover":"mouseover",p=Object.getOwnPropertyDescriptor(e,"_fireDOMEvent"),s=e._fireDOMEvent,f=function(n,r=n.type,v){const g=L.Layer._renderers.get(e);if(!g?.renderer||v||!["click","preclick","dblclick","contextmenu","mousedown","mouseup","mousemove","mouseover","mouseout","pointerdown","pointerup","pointermove","pointerover","pointerout"].includes(r))return s.call(this,n,r,v);const O=n.target,M=O instanceof Element&&O.closest(".leaflet-marker-icon,.leaflet-popup,.leaflet-tooltip,.leaflet-control");if(M&&o.hovered&&(r===d||r===c)&&(s.call(e,n,c,[o.hovered]),o.hovered=null,e.getContainer().style.cursor=""),M||r===d&&(e.dragging?.moving()||e._animatingZoom))return s.call(this,n,r,v);const m=[];if(r!==c)for(const l of o.states){const{source:i}=l;i instanceof L.Marker||i.options.interactive===!1||!(i instanceof L.Path)&&!i.options.interactive||m.push(...l.meshes.values())}const _=m.length?k(g,n,m,!1):[];_.sort((l,i)=>i.object.renderOrder-l.object.renderOrder||l.distance-i.distance);let t=_[0]?.object._nativeSource||null;return(r==="click"||r==="preclick")&&t&&e._draggableMoved(t)&&(t=null),(r===d||r===c)&&o.hovered!==t&&(o.hovered&&s.call(e,n,c,[o.hovered]),o.hovered=t,t&&s.call(e,n,E,[t]),e.getContainer().style.cursor=t?"pointer":""),s.call(this,n,r,t?[t]:void 0)};o.handle=f,o.restore=()=>{e._fireDOMEvent===f&&(p?Object.defineProperty(e,"_fireDOMEvent",p):delete e._fireDOMEvent)},h.set(e,o),e._fireDOMEvent=f}return o.states.add(a),()=>{o.states.delete(a),o.hovered===a.source&&(o.hovered=null,e.getContainer().style.cursor=""),!o.states.size&&(o.restore(),h.delete(e))}}export{b as nativeEvents};
|
|
2
|
+
//# sourceMappingURL=nativeEvents.js.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../src/utils/nativeEvents.js"],
|
|
4
|
+
"sourcesContent": ["import { raycast } from './raycast.js';\r\n\r\nconst maps = new WeakMap();\r\n\r\n/** One GPU hit test per map event, rather than one invisible SVG path per feature. */\r\nexport function nativeEvents(state) {\r\n const { map } = state;\r\n let context = maps.get(map);\r\n if (!context) {\r\n context = { states: new Set(), hovered: null };\r\n const pointer = L.version.startsWith('2');\r\n const move = pointer ? 'pointermove' : 'mousemove', out = pointer ? 'pointerout' : 'mouseout';\r\n const over = pointer ? 'pointerover' : 'mouseover';\r\n const descriptor = Object.getOwnPropertyDescriptor(map, '_fireDOMEvent');\r\n const fireDOMEvent = map._fireDOMEvent;\r\n const handle = function (event, type = event.type, targets) {\r\n const owner = L.Layer._renderers.get(map);\r\n if (!owner?.renderer || targets || !['click', 'preclick', 'dblclick', 'contextmenu',\r\n 'mousedown', 'mouseup', 'mousemove', 'mouseover', 'mouseout',\r\n 'pointerdown', 'pointerup', 'pointermove', 'pointerover', 'pointerout'].includes(type)) {\r\n return fireDOMEvent.call(this, event, type, targets);\r\n }\r\n const target = event.target;\r\n const dom = target instanceof Element &&\r\n target.closest('.leaflet-marker-icon,.leaflet-popup,.leaflet-tooltip,.leaflet-control');\r\n if (dom && context.hovered && (type === move || type === out)) {\r\n fireDOMEvent.call(map, event, out, [context.hovered]);\r\n context.hovered = null;\r\n map.getContainer().style.cursor = '';\r\n }\r\n if (dom || type === move && (map.dragging?.moving() || map._animatingZoom)) {\r\n return fireDOMEvent.call(this, event, type, targets);\r\n }\r\n const meshes = [];\r\n if (type !== out) {\r\n for (const candidate of context.states) {\r\n const { source } = candidate;\r\n if (source instanceof L.Marker || source.options.interactive === false ||\r\n !(source instanceof L.Path) && !source.options.interactive) continue;\r\n meshes.push(...candidate.meshes.values());\r\n }\r\n }\r\n const hits = meshes.length ? raycast(owner, event, meshes, false) : [];\r\n hits.sort((a, b) => b.object.renderOrder - a.object.renderOrder || a.distance - b.distance);\r\n let source = hits[0]?.object._nativeSource || null;\r\n if ((type === 'click' || type === 'preclick') && source && map._draggableMoved(source)) source = null;\r\n if (type === move || type === out) {\r\n if (context.hovered !== source) {\r\n if (context.hovered) fireDOMEvent.call(map, event, out, [context.hovered]);\r\n context.hovered = source;\r\n if (source) fireDOMEvent.call(map, event, over, [source]);\r\n map.getContainer().style.cursor = source ? 'pointer' : '';\r\n }\r\n }\r\n return fireDOMEvent.call(this, event, type, source ? [source] : undefined);\r\n };\r\n context.handle = handle;\r\n context.restore = () => {\r\n if (map._fireDOMEvent !== handle) return;\r\n if (descriptor) Object.defineProperty(map, '_fireDOMEvent', descriptor);\r\n else delete map._fireDOMEvent;\r\n };\r\n maps.set(map, context);\r\n map._fireDOMEvent = handle;\r\n }\r\n context.states.add(state);\r\n return () => {\r\n context.states.delete(state);\r\n if (context.hovered === state.source) {\r\n context.hovered = null;\r\n map.getContainer().style.cursor = '';\r\n }\r\n if (context.states.size) return;\r\n context.restore();\r\n maps.delete(map);\r\n };\r\n}\r\n"],
|
|
5
|
+
"mappings": "AAAA,OAAS,WAAAA,MAAe,eAExB,MAAMC,EAAO,IAAI,QAGV,SAASC,EAAaC,EAAO,CAClC,KAAM,CAAE,IAAAC,CAAI,EAAID,EAChB,IAAIE,EAAUJ,EAAK,IAAIG,CAAG,EAC1B,GAAI,CAACC,EAAS,CACZA,EAAU,CAAE,OAAQ,IAAI,IAAO,QAAS,IAAK,EAC7C,MAAMC,EAAU,EAAE,QAAQ,WAAW,GAAG,EAClCC,EAAOD,EAAU,cAAgB,YAAaE,EAAMF,EAAU,aAAe,WAC7EG,EAAOH,EAAU,cAAgB,YACjCI,EAAa,OAAO,yBAAyBN,EAAK,eAAe,EACjEO,EAAeP,EAAI,cACnBQ,EAAS,SAAUC,EAAOC,EAAOD,EAAM,KAAME,EAAS,CAC1D,MAAMC,EAAQ,EAAE,MAAM,WAAW,IAAIZ,CAAG,EACxC,GAAI,CAACY,GAAO,UAAYD,GAAW,CAAC,CAAC,QAAS,WAAY,WAAY,cACpE,YAAa,UAAW,YAAa,YAAa,WAClD,cAAe,YAAa,cAAe,cAAe,YAAY,EAAE,SAASD,CAAI,EACrF,OAAOH,EAAa,KAAK,KAAME,EAAOC,EAAMC,CAAO,EAErD,MAAME,EAASJ,EAAM,OACfK,EAAMD,aAAkB,SAC5BA,EAAO,QAAQ,uEAAuE,EAMxF,GALIC,GAAOb,EAAQ,UAAYS,IAASP,GAAQO,IAASN,KACvDG,EAAa,KAAKP,EAAKS,EAAOL,EAAK,CAACH,EAAQ,OAAO,CAAC,EACpDA,EAAQ,QAAU,KAClBD,EAAI,aAAa,EAAE,MAAM,OAAS,IAEhCc,GAAOJ,IAASP,IAASH,EAAI,UAAU,OAAO,GAAKA,EAAI,gBACzD,OAAOO,EAAa,KAAK,KAAME,EAAOC,EAAMC,CAAO,EAErD,MAAMI,E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,UAAYF,EAAM,SAC5BE,EAAQ,QAAU,KAClBD,EAAI,aAAa,EAAE,MAAM,OAAS,IAEhC,CAAAC,EAAQ,OAAO,OACnBA,EAAQ,QAAQ,EAChBJ,EAAK,OAAOG,CAAG,EACjB,CACF",
|
|
6
|
+
"names": ["raycast", "maps", "nativeEvents", "state", "map", "context", "pointer", "move", "out", "over", "descriptor", "fireDOMEvent", "handle", "event", "type", "targets", "owner", "target", "dom", "meshes", "candidate", "source", "hits", "a", "b"]
|
|
7
|
+
}
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
import{triangulate as C}from"./triangulate.js";function O(d,b,I){const j=[],g=[],c=d.options,M=(e,o,a,r)=>e.push(...I(o),...I(a),...I(r)),v=(e,o,a,r=o)=>{if(!(o>0)||!(r>0))return;const l=Math.max(12,Math.min(128,Math.ceil(Math.PI*Math.sqrt(o))));for(let i=0;i<l;i++){const n=t=>new L.Point(e.x+o*Math.cos(t*2*Math.PI/l),e.y+r*Math.sin(t*2*Math.PI/l));M(a,e,n(i),n(i+1))}},m=Number(c.weight)||0,h=(Array.isArray(c.dashArray)?c.dashArray:String(c.dashArray||"").trim().split(/[ ,]+/)).map(Number);if(h.some(e=>!Number.isFinite(e)||e<0))throw new Error("Invalid Leaflet dashArray");h.every(e=>e===0)&&(h.length=0),h.length%2&&h.push(...h);const k=(e,o)=>{if(!c.stroke||m<=0||e.length<2)return;const a=m/2,r=(n,t,x,u)=>{const f=n.distanceTo(t);if(!f)return;const y=t.subtract(n).divideBy(f),s=new L.Point(-y.y*a,y.x*a);c.lineCap==="square"&&(x&&(n=n.subtract(y.multiplyBy(a))),u&&(t=t.add(y.multiplyBy(a)))),M(g,n.add(s),n.subtract(s),t.add(s)),M(g,t.add(s),n.subtract(s),t.subtract(s)),c.lineCap==="round"&&(x&&v(n,a,g),u&&v(t,a,g))};let l=Number(c.dashOffset)||0;const i=h.reduce((n,t)=>n+t,0);for(let n=0;n<e.length-(o?0:1);n++){const t=e[n],x=e[(n+1)%e.length],u=t.distanceTo(x);if(h.length){let f=0;for(;f<u;){let y=((l+f)%i+i)%i,s=0;for(;y>=h[s];)y-=h[s++];const p=Math.min(u,f+h[s]-y);if(s%2===0){const P=x.subtract(t).divideBy(u);r(t.add(P.multiplyBy(f)),t.add(P.multiplyBy(p)),!0,!0)}f=p}}else if(r(t,x,!o&&n===0,!o&&n===e.length-2),o||n>0)if(c.lineJoin==="round")v(t,a,g);else{const f=t.subtract(e[(n+e.length-1)%e.length]),y=Math.hypot(f.x,f.y);if(y&&u){const s=f.divideBy(y),p=x.subtract(t).divideBy(u),P=s.x*p.y-s.y*p.x>0?-1:1,w=new L.Point(-s.y*P,s.x*P),B=new L.Point(-p.y*P,p.x*P),_=t.add(w.multiplyBy(a)),N=t.add(B.multiplyBy(a)),q=1+w.x*B.x+w.y*B.y,A=q>0?w.add(B).multiplyBy(a/q):null;M(g,_,t,N),c.lineJoin==="miter"&&A&&Math.hypot(A.x,A.y)<=a*4&&M(g,_,t.add(A),N)}}l+=u}};if(d instanceof L.CircleMarker){const e=b.project(d.getLatLng());let o=d.getRadius(),a=o;if(d instanceof L.Circle){d._project();const i=d._point.add(b.getPixelOrigin());e.x=i.x,e.y=i.y,o=d._radius,a=d._radiusY||o}c.fill&&v(e,o,j,a);const r=Math.max(12,Math.min(128,Math.ceil(Math.PI*Math.sqrt(Math.max(o,a))))),l=(i,n=0)=>{const t=i*Math.PI*2/r;return new L.Point(e.x+Math.max(0,o+n)*Math.cos(t),e.y+Math.max(0,a+n)*Math.sin(t))};if(h.length)k(Array.from({length:r},(i,n)=>l(n)),!0);else if(c.stroke&&m>0)for(let i=0;i<r;i++)M(g,l(i,m/2),l(i,-m/2),l(i+1,m/2)),M(g,l(i+1,m/2),l(i,-m/2),l(i+1,-m/2))}else{const e=d instanceof L.Polygon,o=r=>{const l=r.map(i=>i.map(n=>b.project(n)));if(e&&c.fill&&l[0]?.length>=3){const i=l.filter(t=>t.length>=3),n=i.flat();for(const t of C(i[0],i.slice(1)))M(j,n[t[0]],n[t[1]],n[t[2]])}for(const i of l)k(i,e)},a=r=>{if(r.length)if(r[0]instanceof L.LatLng)o([r]);else if(e&&r[0][0]instanceof L.LatLng)o(r);else for(const l of r)a(l)};a(d.getLatLngs())}return{fill:j,stroke:g}}export{O as nativeGeometry};
|
|
2
|
+
//# sourceMappingURL=nativeGeometry.js.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../src/utils/nativeGeometry.js"],
|
|
4
|
+
"sourcesContent": ["import { triangulate } from './triangulate.js';\r\n\r\n/** Leaflet paths become flat triangles; pixel-sized strokes are rebuilt on zoom. */\r\nexport function nativeGeometry(source, map, point) {\r\n const fill = [], stroke = [], options = source.options;\r\n const triangle = (target, a, b, c) => target.push(...point(a), ...point(b), ...point(c));\r\n const disk = (center, radius, target, radiusY = radius) => {\r\n if (!(radius > 0) || !(radiusY > 0)) return;\r\n const count = Math.max(12, Math.min(128, Math.ceil(Math.PI * Math.sqrt(radius))));\r\n for (let i = 0; i < count; i++) {\r\n const at = index => new L.Point(center.x + radius * Math.cos(index * 2 * Math.PI / count),\r\n center.y + radiusY * Math.sin(index * 2 * Math.PI / count));\r\n triangle(target, center, at(i), at(i + 1));\r\n }\r\n };\r\n const width = Number(options.weight) || 0;\r\n const dash = (Array.isArray(options.dashArray) ? options.dashArray :\r\n String(options.dashArray || '').trim().split(/[ ,]+/)).map(Number);\r\n if (dash.some(value => !Number.isFinite(value) || value < 0)) throw new Error('Invalid Leaflet dashArray');\r\n if (dash.every(value => value === 0)) dash.length = 0;\r\n if (dash.length % 2) dash.push(...dash);\r\n const line = (points, closed) => {\r\n if (!options.stroke || width <= 0 || points.length < 2) return;\r\n const radius = width / 2;\r\n const segment = (a, b, startCap, endCap) => {\r\n const length = a.distanceTo(b);\r\n if (!length) return;\r\n const direction = b.subtract(a).divideBy(length);\r\n const normal = new L.Point(-direction.y * radius, direction.x * radius);\r\n if (options.lineCap === 'square') {\r\n if (startCap) a = a.subtract(direction.multiplyBy(radius));\r\n if (endCap) b = b.add(direction.multiplyBy(radius));\r\n }\r\n triangle(stroke, a.add(normal), a.subtract(normal), b.add(normal));\r\n triangle(stroke, b.add(normal), a.subtract(normal), b.subtract(normal));\r\n if (options.lineCap === 'round') {\r\n if (startCap) disk(a, radius, stroke);\r\n if (endCap) disk(b, radius, stroke);\r\n }\r\n };\r\n let distance = Number(options.dashOffset) || 0;\r\n const period = dash.reduce((sum, value) => sum + value, 0);\r\n for (let i = 0; i < points.length - (closed ? 0 : 1); i++) {\r\n const a = points[i], b = points[(i + 1) % points.length], length = a.distanceTo(b);\r\n if (!dash.length) {\r\n segment(a, b, !closed && i === 0, !closed && i === points.length - 2);\r\n if (closed || i > 0) {\r\n if (options.lineJoin === 'round') disk(a, radius, stroke);\r\n else {\r\n const previous = a.subtract(points[(i + points.length - 1) % points.length]);\r\n const previousLength = Math.hypot(previous.x, previous.y);\r\n if (previousLength && length) {\r\n const incoming = previous.divideBy(previousLength);\r\n const outgoing = b.subtract(a).divideBy(length);\r\n const side = incoming.x * outgoing.y - incoming.y * outgoing.x > 0 ? -1 : 1;\r\n const n1 = new L.Point(-incoming.y * side, incoming.x * side);\r\n const n2 = new L.Point(-outgoing.y * side, outgoing.x * side);\r\n const from = a.add(n1.multiplyBy(radius)), to = a.add(n2.multiplyBy(radius));\r\n const denominator = 1 + n1.x * n2.x + n1.y * n2.y;\r\n const miter = denominator > 0 ? n1.add(n2).multiplyBy(radius / denominator) : null;\r\n triangle(stroke, from, a, to);\r\n if (options.lineJoin === 'miter' && miter && Math.hypot(miter.x, miter.y) <= radius * 4) {\r\n triangle(stroke, from, a.add(miter), to);\r\n }\r\n }\r\n }\r\n }\r\n } else {\r\n let offset = 0;\r\n while (offset < length) {\r\n let phase = ((distance + offset) % period + period) % period, index = 0;\r\n while (phase >= dash[index]) phase -= dash[index++];\r\n const end = Math.min(length, offset + dash[index] - phase);\r\n if (index % 2 === 0) {\r\n const delta = b.subtract(a).divideBy(length);\r\n segment(a.add(delta.multiplyBy(offset)), a.add(delta.multiplyBy(end)), true, true);\r\n }\r\n offset = end;\r\n }\r\n }\r\n distance += length;\r\n }\r\n };\r\n if (source instanceof L.CircleMarker) {\r\n const center = map.project(source.getLatLng());\r\n let radius = source.getRadius(), radiusY = radius;\r\n if (source instanceof L.Circle) {\r\n source._project();\r\n const projected = source._point.add(map.getPixelOrigin());\r\n center.x = projected.x;\r\n center.y = projected.y;\r\n radius = source._radius;\r\n radiusY = source._radiusY || radius;\r\n }\r\n if (options.fill) disk(center, radius, fill, radiusY);\r\n const count = Math.max(12, Math.min(128, Math.ceil(Math.PI * Math.sqrt(Math.max(radius, radiusY)))));\r\n const at = (index, offset = 0) => {\r\n const angle = index * Math.PI * 2 / count;\r\n return new L.Point(center.x + Math.max(0, radius + offset) * Math.cos(angle),\r\n center.y + Math.max(0, radiusY + offset) * Math.sin(angle));\r\n };\r\n if (dash.length) line(Array.from({ length: count }, (_, index) => at(index)), true);\r\n else if (options.stroke && width > 0) {\r\n for (let i = 0; i < count; i++) {\r\n triangle(stroke, at(i, width / 2), at(i, -width / 2), at(i + 1, width / 2));\r\n triangle(stroke, at(i + 1, width / 2), at(i, -width / 2), at(i + 1, -width / 2));\r\n }\r\n }\r\n } else {\r\n const closed = source instanceof L.Polygon;\r\n const polygon = rings => {\r\n const projected = rings.map(ring => ring.map(latlng => map.project(latlng)));\r\n if (closed && options.fill && projected[0]?.length >= 3) {\r\n const valid = projected.filter(ring => ring.length >= 3);\r\n const vertices = valid.flat();\r\n for (const indices of triangulate(valid[0], valid.slice(1))) {\r\n triangle(fill, vertices[indices[0]], vertices[indices[1]], vertices[indices[2]]);\r\n }\r\n }\r\n for (const ring of projected) line(ring, closed);\r\n };\r\n const visit = coordinates => {\r\n if (!coordinates.length) return;\r\n if (coordinates[0] instanceof L.LatLng) polygon([coordinates]);\r\n else if (closed && coordinates[0][0] instanceof L.LatLng) polygon(coordin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W,CAAC,UACpDrC,GAAUqC,EAAY,CAAC,EAAE,CAAC,YAAa,EAAE,OAAQR,EAAQQ,CAAW,MACxE,WAAWC,KAASD,EAAaD,EAAME,CAAK,CACnD,EACAF,EAAM3D,EAAO,WAAW,CAAC,CAC3B,CACA,MAAO,CAAE,KAAAG,EAAM,OAAAC,CAAO,CACxB",
|
|
6
|
+
"names": ["triangulate", "nativeGeometry", "source", "map", "point", "fill", "stroke", "options", "triangle", "target", "a", "b", "c", "disk", "center", "radius", "radiusY", "count", "at", "index", "width", "dash", "value", "line", "points", "closed", "segment", "startCap", "endCap", "length", "direction", "normal", "distance", "period", "sum", "i", "offset", "phase", "end", "delta", "previous", "previousLength", "incoming", "outgoing", "side", "n1", "n2", "from", "to", "denominator", "miter", "projected", "angle", "_", "polygon", "rings", "ring", "latlng", "valid", "vertices", "indices", "visit", "coordinates", "child"]
|
|
7
|
+
}
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
import{createMesh as re}from"./createMesh.js";import{destroyTexture as P}from"./destroyTexture.js";import{disposeMesh as I}from"./disposeMesh.js";import{nativeGeometry as oe}from"./nativeGeometry.js";import{nativeEvents as ne}from"./nativeEvents.js";import{parseColor as se}from"./parseColor.js";import{update as k}from"./update.js";async function me(f){const{source:r,map:d}=f,s=f.backend=new L.Layer({source:{type:"3d"}}),p=f.meshes=new Map,u=new Map,H=new Map,v=new Set;d._nativeGPUOrder||=0,d._nativeGPUBack||=0;let U=!0,M=!0,T=!1,_=++d._nativeGPUOrder,F;const y=r instanceof L.Marker,Y=Number(getComputedStyle(r.getPane()).zIndex)||0,z=()=>r._nativeGPU===f&&d.hasLayer(r),m=()=>{U=!0,M=!0,T=!1,f.hide();const e=[r._icon,r._shadow,r._image];for(const t of v)e.includes(t)||(t.removeEventListener("load",m),t.removeEventListener("error",G),v.delete(t));for(const t of e)!(t instanceof HTMLImageElement)||v.has(t)||(v.add(t),t.addEventListener("load",m),t.addEventListener("error",G));s._shared&&k(s)},G=()=>r.fire("error",{error:new Error("Unable to load native layer image")});f.refresh=m,f.reorder=e=>{_=e?++d._nativeGPUOrder:--d._nativeGPUBack,m()};const W=()=>{M=!0,s._shared&&k(s)},R="load tileload tileunload move drag";r.on(R,m),d.on("zoomend",m),y&&d.on("move zoom rotate pitch resize viewreset",W);const J=ne(f);for(const e of["setLatLng","setLatLngs","addLatLng","setRadius","setStyle","redraw","setIcon","setUrl","setBounds","setOpacity","setZIndex","setZIndexOffset","bringToFront","bringToBack"]){if(typeof r[e]!="function")continue;const t=Object.getOwnPropertyDescriptor(r,e),o=r[e];H.set(e,t),r[e]=function(...i){const a=o.apply(this,i);if((e==="bringToFront"||e==="bringToBack")&&this instanceof L.GridLayer){const l=Object.values(d._layers).filter(c=>c!==this&&c instanceof L.GridLayer&&c.getPane()===this.getPane()).map(c=>c.options.zIndex||0),n=e==="bringToFront"?Math.max(...l)+1:Math.min(...l)-1;Number.isFinite(n)&&this.setZIndex(n)}return e==="bringToFront"&&(_=++d._nativeGPUOrder),e==="bringToBack"&&(_=--d._nativeGPUBack),m(),a}}f.dispose=()=>{r.off(R,m),d.off("zoomend",m),y&&d.off("move zoom rotate pitch resize viewreset",W),J(),f.refresh=f.reorder=null;for(const[e,t]of H)t?Object.defineProperty(r,e,t):delete r[e];for(const e of p.values())I(s,e);p.clear();for(const e of u.values())P(s,e.texture);u.clear();for(const e of v)e.removeEventListener("load",m),e.removeEventListener("error",G);s._beforeRender=null,s.remove()};const K=new Promise((e,t)=>{s.once("ready",e),s.once("error",({error:o})=>t(o))});if(s.on("error",({error:e})=>r.fire("error",{error:e})),m(),s.addTo(d),await K.catch(e=>{throw f.dispose(),e}),!z())return r;const S=e=>{const t=d.options.crs,o=t.project(s.location),i=t.project(e),a=Math.cos(s.location.lat*Math.PI/180);return[(i.x-o.x)*a,0,-(i.y-o.y)*a]},$=e=>S(d.unproject(e)),q=(e,t,o)=>{e.program.uniforms.baseColor.value=t,e.program.uniforms.opacity.value=o,r instanceof L.GridLayer&&(e.opacity=o);const i=y?r._zIndex+(r._cameraZIndexOffset||0):r.options.zIndex;e.renderOrder=Y*1e6+(i||0)*1e3+_,e._nativeSource=r,e._nativeUsed=!0},A=(e,t,o,i,a,l)=>{if(!t.length)return;let n=p.get(e);const c={position:t,normal:t.map((h,w)=>w%3===1?1:0),...l?{uv:l}:{}};if(!n||n.geometry.attributes.position.data.length!==t.length||n.program.uniforms.baseTexture?.value!==a)n&&I(s,n),n=re(s,c,{vertexColors:!1,color:o,opacity:i,unlit:!0,alphaMode:"BLEND",...a?{baseTexture:a}:{}},0,r instanceof L.GridLayer?F:void 0),r instanceof L.GridLayer&&(F||=n.program,n.texture=a),p.set(e,n);else{const h=n.geometry.attributes.position;h.data.set(t),h.needsUpdate=!0,n.geometry.bounds=null}return q(n,o,i),n},ee=(e,t)=>{if(!(t instanceof HTMLImageElement)&&!(t instanceof HTMLCanvasElement))throw new Error("WebGPU native raster layers require image or canvas tiles");let o=u.get(e);const i=t.currentSrc||t.src;if(!o||o.image!==t||o.url!==i){if(o){const c=p.get(e);c&&I(s,c),p.delete(e),P(s,o.texture),u.delete(e)}const a=t.naturalWidth||t.width,l=t.naturalHeight||t.height;if(!a||!l)return;const{device:n}=s.renderer;if(o={device:n,image:t,url:i,format:"rgba8unorm",uploaded:null,texture:n.createTexture({size:[a,l],format:"rgba8unorm",usage:GPUTextureUsage.TEXTURE_BINDING|GPUTextureUsage.COPY_DST|GPUTextureUsage.RENDER_ATTACHMENT}),sampler:n.createSampler({minFilter:"linear",magFilter:"linear"})},u.set(e,o),t instanceof HTMLCanvasElement)o.pending=!0,createImageBitmap(t).then(c=>{try{if(!z()||u.get(e)!==o)return;n.queue.copyExternalImageToTexture({source:c},{texture:o.texture},[a,l]),o.uploaded=t,o.pending=!1,m()}finally{c.close()}}).catch(c=>{T=!0,r.fire("error",{error:c})});else{try{n.queue.copyExternalImageToTexture({source:t},{texture:o.texture},[a,l])}catch(c){throw o.texture.destroy(),u.delete(e),c}o.uploaded=t}}return o.used=!0,o.uploaded===t?o:void 0},D=(e,t,o,i)=>{const a=ee(e,t);if(!a)return;const l=[0,2,1,1,2,3];return A(e,l.flatMap(n=>o[n]),[1,1,1],i,a,l.flatMap(n=>[[0,0],[1,0],[0,1],[1,1]][n]))},Z=e=>[e.getNorthWest(),e.getNorthEast(),e.getSouthWest(),e.getSouthEast()].map(S),V=()=>{if(!(!z()||!s.renderer||T)&&!(!U&&(!y||!M))){U=!1,M=!1;for(const e of p.values())e._nativeUsed=!1;for(const e of u.values())e.used=!1;if(r instanceof L.GridLayer)for(const[e,t]of Object.entries(r._tiles||{})){if(!t.loaded||t.el instanceof HTMLImageElement&&!t.el.naturalWidth)continue;const o=(r.options.opacity??1)*(t._gpuOpacity??1),i=u.get(e);let a=p.get(e);if(a&&i?.image===t.el&&i.url===(t.el.currentSrc||t.el.src))i.used=!0,q(a,[1,1,1],o);else{const[l,n]=r._tileCoordsToNwSe(t.coords);a=D(e,t.el,Z(new L.LatLngBounds(l,n)),o)}a&&(a.renderOrder+=t.coords.z/100)}else if(r instanceof L.ImageOverlay)r._image?.complete&&r._image.naturalWidth&&D("image",r._image,Z(r.getBounds()),r.options.opacity??1);else if(y)for(const[e,t]of[["shadow",r._shadow],["icon",r._icon]]){if(!(t instanceof HTMLImageElement)||!t.complete||!t.naturalWidth)continue;const i=new DOMPoint(...S(r.getLatLng()),1).matrixTransform(new DOMMatrix(s.root.worldMatrix)).matrixTransform(new DOMMatrix(s.camera.projectionViewMatrix)),a=new DOMMatrix(s.camera.projectionViewMatrix).inverse(),l=new DOMMatrix(s.root.worldMatrix).inverse(),n=r.options.icon.options,c=d.getSize(),h=n[e==="shadow"?"shadowSize":"iconSize"]||[t.naturalWidth,t.naturalHeight],w=h.x??h[0],B=h.y??h[1],E=e==="shadow"&&n.shadowAnchor||n.iconAnchor||[Math.floor(w/2),Math.floor(B/2)],g=new L.Point((i.x/i.w+1)*c.x/2,(1-i.y/i.w)*c.y/2),O=g.x-(E.x??E[0]),b=g.y-(E.y??E[1]),te=[[O,b],[O+w,b],[O,b+B],[O+w,b+B]].map(([C,N])=>{const X=r._cameraIconPoint(C-g.x,N-g.y);C=g.x+X.x,N=g.y+X.y;const x=new DOMPoint(C/c.x*2-1,1-N/c.y*2,i.z/i.w,1).matrixTransform(a),j=new DOMPoint(x.x/x.w,x.y/x.w,x.z/x.w,1).matrixTransform(l);return[j.x,j.y,j.z]}),Q=D(e,t,te,r.options.opacity??1);e==="shadow"&&Q&&(Q.renderOrder-=100*1e6)}else{const{fill:e,stroke:t}=oe(r,d,$);for(const[o,i,a,l]of[["fill",e,r.options.fillColor||r.options.color,r.options.fillOpacity],["stroke",t,r.options.color,r.options.opacity]]){if(!i.length)continue;const{r:n,g:c,b:h}=se(a);A(o,i,[n,c,h],l??1)}}for(const[e,t]of p){if(t._nativeUsed)continue;I(s,t),p.delete(e);const o=u.get(e);o&&P(s,o.texture),u.delete(e)}for(const[e,t]of u)t.used||(P(s,t.texture),u.delete(e))}};s._beforeRender=()=>{try{V()}catch(e){T=!0,r.fire("error",{error:e})}};try{V()}catch(e){throw f.dispose(),e}return k(s),r}export{me as nativeLayer};
|
|
2
|
+
//# sourceMappingURL=nativeLayer.js.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../src/utils/nativeLayer.js"],
|
|
4
|
+
"sourcesContent": ["import { createMesh } from './createMesh.js';\r\nimport { destroyTexture } from './destroyTexture.js';\r\nimport { disposeMesh } from './disposeMesh.js';\r\nimport { nativeGeometry } from './nativeGeometry.js';\r\nimport { nativeEvents } from './nativeEvents.js';\r\nimport { parseColor } from './parseColor.js';\r\nimport { update } from './update.js';\r\n\r\n/** Render from coordinates and detached raster sources; only accessible marker controls remain DOM. */\r\nexport async function nativeLayer(state) {\r\n const { source, map } = state;\r\n const backend = state.backend = new L.Layer({ source: { type: '3d' } });\r\n const meshes = state.meshes = new Map(), textures = new Map(), methods = new Map();\r\n const images = new Set();\r\n map._nativeGPUOrder ||= 0;\r\n map._nativeGPUBack ||= 0;\r\n let dirty = true, viewDirty = true, failed = false, order = ++map._nativeGPUOrder, rasterProgram;\r\n const marker = source instanceof L.Marker;\r\n const paneOrder = Number(getComputedStyle(source.getPane()).zIndex) || 0;\r\n const current = () => source._nativeGPU === state && map.hasLayer(source);\r\n const refresh = () => {\r\n dirty = true;\r\n viewDirty = true;\r\n failed = false;\r\n state.hide();\r\n const activeImages = [source._icon, source._shadow, source._image];\r\n for (const image of images) {\r\n if (activeImages.includes(image)) continue;\r\n image.removeEventListener('load', refresh);\r\n image.removeEventListener('error', imageError);\r\n images.delete(image);\r\n }\r\n for (const image of activeImages) {\r\n if (!(image instanceof HTMLImageElement) || images.has(image)) continue;\r\n images.add(image);\r\n image.addEventListener('load', refresh);\r\n image.addEventListener('error', imageError);\r\n }\r\n if (backend._shared) update(backend);\r\n };\r\n const imageError = () => source.fire('error', { error: new Error('Unable to load native layer image') });\r\n state.refresh = refresh;\r\n state.reorder = front => {\r\n order = front ? ++map._nativeGPUOrder : --map._nativeGPUBack;\r\n refresh();\r\n };\r\n const view = () => {\r\n viewDirty = true;\r\n if (backend._shared) update(backend);\r\n };\r\n const events = 'load tileload tileunload move drag';\r\n source.on(events, refresh);\r\n // Panning and camera changes never retriangulate paths or re-upload tile geometry.\r\n map.on('zoomend', refresh);\r\n if (marker) map.on('move zoom rotate pitch resize viewreset', view);\r\n const removeEvents = nativeEvents(state);\r\n for (const name of ['setLatLng', 'setLatLngs', 'addLatLng', 'setRadius', 'setStyle', 'redraw',\r\n 'setIcon', 'setUrl', 'setBounds', 'setOpacity', 'setZIndex', 'setZIndexOffset', 'bringToFront', 'bringToBack']) {\r\n if (typeof source[name] !== 'function') continue;\r\n const own = Object.getOwnPropertyDescriptor(source, name), original = source[name];\r\n methods.set(name, own);\r\n source[name] = function (...args) {\r\n const result = original.apply(this, args);\r\n if ((name === 'bringToFront' || name === 'bringToBack') && this instanceof L.GridLayer) {\r\n const indices = Object.values(map._layers).filter(layer => layer !== this &&\r\n layer instanceof L.GridLayer && layer.getPane() === this.getPane()).map(layer => layer.options.zIndex || 0);\r\n const edge = name === 'bringToFront' ? Math.max(...indices) + 1 : Math.min(...indices) - 1;\r\n if (Number.isFinite(edge)) this.setZIndex(edge);\r\n }\r\n if (name === 'bringToFront') order = ++map._nativeGPUOrder;\r\n if (name === 'bringToBack') order = --map._nativeGPUBack;\r\n refresh();\r\n return result;\r\n };\r\n }\r\n state.dispose = () => {\r\n source.off(events, refresh);\r\n map.off('zoomend', refresh);\r\n if (marker) map.off('move zoom rotate pitch resize viewreset', view);\r\n removeEvents();\r\n state.refresh = state.reorder = null;\r\n for (const [name, descriptor] of methods) {\r\n if (descriptor) Object.defineProperty(source, name, descriptor);\r\n else delete source[name];\r\n }\r\n for (const mesh of meshes.values()) disposeMesh(backend, mesh);\r\n meshes.clear();\r\n for (const texture of textures.values()) destroyTexture(backend, texture.texture);\r\n textures.clear();\r\n for (const image of images) {\r\n image.removeEventListener('load', refresh);\r\n image.removeEventListener('error', imageError);\r\n }\r\n backend._beforeRender = null;\r\n backend.remove();\r\n };\r\n const ready = new Promise((resolve, reject) => {\r\n backend.once('ready', resolve);\r\n backend.once('error', ({ error }) => reject(error));\r\n });\r\n backend.on('error', ({ error }) => source.fire('error', { error }));\r\n refresh();\r\n backend.addTo(map);\r\n await ready.catch(error => {\r\n state.dispose();\r\n throw error;\r\n });\r\n if (!current()) return source;\r\n\r\n const local = latlng => {\r\n const crs = map.options.crs, origin = crs.project(backend.location), p = crs.project(latlng);\r\n const metres = Math.cos(backend.location.lat * Math.PI / 180);\r\n return [(p.x - origin.x) * metres, 0, -(p.y - origin.y) * metres];\r\n };\r\n const pixel = p => local(map.unproject(p));\r\n const styleMesh = (mesh, color, opacity) => {\r\n mesh.program.uniforms.baseColor.value = color;\r\n mesh.program.uniforms.opacity.value = opacity;\r\n if (source instanceof L.GridLayer) mesh.opacity = opacity;\r\n const zIndex = marker ? source._zIndex + (source._cameraZIndexOffset || 0) : source.options.zIndex;\r\n mesh.renderOrder = paneOrder * 1e6 + (zIndex || 0) * 1000 + order;\r\n mesh._nativeSource = source;\r\n mesh._nativeUsed = true;\r\n };\r\n const put = (key, position, color, opacity, texture, uv) => {\r\n if (!position.length) return;\r\n let mesh = meshes.get(key);\r\n const data = {\r\n position, normal: position.map((_, index) => index % 3 === 1 ? 1 : 0),\r\n ...(uv ? { uv } : {}),\r\n };\r\n if (!mesh || mesh.geometry.attributes.position.data.length !== position.length ||\r\n mesh.program.uniforms.baseTexture?.value !== texture) {\r\n if (mesh) disposeMesh(backend, mesh);\r\n mesh = createMesh(backend, data, {\r\n vertexColors: false, color, opacity, unlit: true, alphaMode: 'BLEND',\r\n ...(texture ? { baseTexture: texture } : {}),\r\n }, 0, source instanceof L.GridLayer ? rasterProgram : undefined);\r\n if (source instanceof L.GridLayer) {\r\n rasterProgram ||= mesh.program;\r\n mesh.texture = texture;\r\n }\r\n meshes.set(key, mesh);\r\n } else {\r\n const attribute = mesh.geometry.attributes.position;\r\n attribute.data.set(position);\r\n attribute.needsUpdate = true;\r\n mesh.geometry.bounds = null;\r\n }\r\n styleMesh(mesh, color, opacity);\r\n return mesh;\r\n };\r\n const textureFor = (key, image) => {\r\n if (!(image instanceof HTMLImageElement) && !(image instanceof HTMLCanvasElement)) {\r\n throw new Error('WebGPU native raster layers require image or canvas tiles');\r\n }\r\n let texture = textures.get(key);\r\n const url = image.currentSrc || image.src;\r\n if (!texture || texture.image !== image || texture.url !== url) {\r\n if (texture) {\r\n const mesh = meshes.get(key);\r\n if (mesh) disposeMesh(backend, mesh);\r\n meshes.delete(key);\r\n destroyTexture(backend, texture.texture);\r\n textures.delete(key);\r\n }\r\n const width = image.naturalWidth || image.width, height = image.naturalHeight || image.height;\r\n if (!width || !height) return;\r\n const { device } = backend.renderer;\r\n texture = {\r\n device, image, url, format: 'rgba8unorm', uploaded: null,\r\n texture: device.createTexture({\r\n size: [width, height], format: 'rgba8unorm',\r\n usage: GPUTextureUsage.TEXTURE_BINDING | GPUTextureUsage.COPY_DST | GPUTextureUsage.RENDER_ATTACHMENT,\r\n }),\r\n sampler: device.createSampler({ minFilter: 'linear', magFilter: 'linear' }),\r\n };\r\n textures.set(key, texture);\r\n if (image instanceof HTMLCanvasElement) {\r\n texture.pending = true;\r\n // Snapshot asynchronously: copying a GPU-backed 2D canvas directly forces a blocking readback in Chromium.\r\n createImageBitmap(image).then(bitmap => {\r\n try {\r\n if (!current() || textures.get(key) !== texture) return;\r\n device.queue.copyExternalImageToTexture({ source: bitmap }, { texture: texture.texture }, [width, height]);\r\n texture.uploaded = image;\r\n texture.pending = false;\r\n refresh();\r\n } finally {\r\n bitmap.close();\r\n }\r\n }).catch(error => {\r\n failed = true;\r\n source.fire('error', { error });\r\n });\r\n } else {\r\n // CORS/security failures reject ready or emit error on the owning native layer.\r\n try {\r\n device.queue.copyExternalImageToTexture({ source: image }, { texture: texture.texture }, [width, height]);\r\n } catch (error) {\r\n texture.texture.destroy();\r\n textures.delete(key);\r\n throw error;\r\n }\r\n texture.uploaded = image;\r\n }\r\n }\r\n texture.used = true;\r\n return texture.uploaded === image ? texture : undefined;\r\n };\r\n const quad = (key, image, corners, opacity) => {\r\n const texture = textureFor(key, image);\r\n if (!texture) return;\r\n const indices = [0, 2, 1, 1, 2, 3];\r\n return put(key, indices.flatMap(i => corners[i]), [1, 1, 1], opacity, texture,\r\n indices.flatMap(i => [[0, 0], [1, 0], [0, 1], [1, 1]][i]));\r\n };\r\n const boundsQuad = bounds => [\r\n bounds.getNorthWest(), bounds.getNorthEast(), bounds.getSouthWest(), bounds.getSouthEast(),\r\n ].map(local);\r\n const synchronize = () => {\r\n if (!current() || !backend.renderer || failed) return;\r\n if (!dirty && (!marker || !viewDirty)) return;\r\n dirty = false;\r\n viewDirty = false;\r\n for (const mesh of meshes.values()) mesh._nativeUsed = false;\r\n for (const texture of textures.values()) texture.used = false;\r\n if (source instanceof L.GridLayer) {\r\n for (const [key, tile] of Object.entries(source._tiles || {})) {\r\n if (!tile.loaded || tile.el instanceof HTMLImageElement && !tile.el.naturalWidth) continue;\r\n const opacity = (source.options.opacity ?? 1) * (tile._gpuOpacity ?? 1);\r\n const retained = textures.get(key);\r\n let mesh = meshes.get(key);\r\n if (mesh && retained?.image === tile.el && retained.url === (tile.el.currentSrc || tile.el.src)) {\r\n retained.used = true;\r\n styleMesh(mesh, [1, 1, 1], opacity);\r\n } else {\r\n const [nw, se] = source._tileCoordsToNwSe(tile.coords);\r\n mesh = quad(key, tile.el, boundsQuad(new L.LatLngBounds(nw, se)), opacity);\r\n }\r\n if (mesh) mesh.renderOrder += tile.coords.z / 100;\r\n }\r\n } else if (source instanceof L.ImageOverlay) {\r\n if (source._image?.complete && source._image.naturalWidth) {\r\n quad('image', source._image, boundsQuad(source.getBounds()), source.options.opacity ?? 1);\r\n }\r\n } else if (marker) {\r\n for (const [key, image] of [['shadow', source._shadow], ['icon', source._icon]]) {\r\n if (!(image instanceof HTMLImageElement) || !image.complete || !image.naturalWidth) continue;\r\n const world = new DOMPoint(...local(source.getLatLng()), 1)\r\n .matrixTransform(new DOMMatrix(backend.root.worldMatrix));\r\n const clip = world.matrixTransform(new DOMMatrix(backend.camera.projectionViewMatrix));\r\n const inverse = new DOMMatrix(backend.camera.projectionViewMatrix).inverse();\r\n const toLocal = new DOMMatrix(backend.root.worldMatrix).inverse();\r\n const options = source.options.icon.options, size = map.getSize();\r\n const dimensions = options[key === 'shadow' ? 'shadowSize' : 'iconSize'] ||\r\n [image.naturalWidth, image.naturalHeight];\r\n const width = dimensions.x ?? dimensions[0], height = dimensions.y ?? dimensions[1];\r\n const anchor = (key === 'shadow' && options.shadowAnchor) ||\r\n options.iconAnchor || [Math.floor(width / 2), Math.floor(height / 2)];\r\n const center = new L.Point((clip.x / clip.w + 1) * size.x / 2, (1 - clip.y / clip.w) * size.y / 2);\r\n const left = center.x - (anchor.x ?? anchor[0]), top = center.y - (anchor.y ?? anchor[1]);\r\n const corners = [[left, top], [left + width, top],\r\n [left, top + height], [left + width, top + height]].map(([x, y]) => {\r\n const offset = source._cameraIconPoint(x - center.x, y - center.y);\r\n x = center.x + offset.x; y = center.y + offset.y;\r\n const p = new DOMPoint(x / size.x * 2 - 1,\r\n 1 - y / size.y * 2, clip.z / clip.w, 1).matrixTransform(inverse);\r\n const result = new DOMPoint(p.x / p.w, p.y / p.w, p.z / p.w, 1).matrixTransform(toLocal);\r\n return [result.x, result.y, result.z];\r\n });\r\n const mesh = quad(key, image, corners, source.options.opacity ?? 1);\r\n if (key === 'shadow' && mesh) mesh.renderOrder -= 100 * 1e6;\r\n }\r\n } else {\r\n const { fill, stroke } = nativeGeometry(source, map, pixel);\r\n for (const [key, positions, color, opacity] of [\r\n ['fill', fill, source.options.fillColor || source.options.color, source.options.fillOpacity],\r\n ['stroke', stroke, source.options.color, source.options.opacity],\r\n ]) {\r\n if (!positions.length) continue;\r\n const { r, g, b } = parseColor(color);\r\n put(key, positions, [r, g, b], opacity ?? 1);\r\n }\r\n }\r\n for (const [key, mesh] of meshes) {\r\n if (mesh._nativeUsed) continue;\r\n disposeMesh(backend, mesh);\r\n meshes.delete(key);\r\n const texture = textures.get(key);\r\n if (texture) destroyTexture(backend, texture.texture);\r\n textures.delete(key);\r\n }\r\n for (const [key, texture] of textures) {\r\n if (texture.used) continue;\r\n destroyTexture(backend, texture.texture);\r\n textures.delete(key);\r\n }\r\n };\r\n backend._beforeRender = () => {\r\n try {\r\n synchronize();\r\n } catch (error) {\r\n failed = true;\r\n source.fire('error', { error });\r\n }\r\n };\r\n // ponytail: tessellate pixel-width strokes on zoomend; use shader extrusion for continuous zoom at scale.\r\n try {\r\n synchronize();\r\n } catch (error) {\r\n state.dispose();\r\n throw error;\r\n }\r\n update(backend);\r\n return source;\r\n}\r\n"],
|
|
5
|
+
"mappings": "AAAA,OAAS,cAAAA,OAAkB,kBAC3B,OAAS,kBAAAC,MAAsB,sBAC/B,OAAS,eAAAC,MAAmB,mBAC5B,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C,EAAG,EAAAC,EAAG,EAAAC,CAAE,EAAI/F,GAAWkD,CAAK,EACpCG,EAAIC,EAAKsC,EAAW,CAACC,EAAGC,EAAGC,CAAC,EAAG5C,GAAW,CAAC,CAC7C,CACF,CACA,SAAW,CAACG,EAAKlB,CAAI,IAAK7B,EAAQ,CAChC,GAAI6B,EAAK,YAAa,SACtBvC,EAAYS,EAAS8B,CAAI,EACzB7B,EAAO,OAAO+C,CAAG,EACjB,MAAMjB,EAAU7B,EAAS,IAAI8C,CAAG,EAC5BjB,GAASzC,EAAeU,EAAS+B,EAAQ,OAAO,EACpD7B,EAAS,OAAO8C,CAAG,CACrB,CACA,SAAW,CAACA,EAAKjB,CAAO,IAAK7B,EACvB6B,EAAQ,OACZzC,EAAeU,EAAS+B,EAAQ,OAAO,EACvC7B,EAAS,OAAO8C,CAAG,GAEvB,EACAhD,EAAQ,cAAgB,IAAM,CAC5B,GAAI,CACFkE,EAAY,CACd,OAAS/B,EAAO,CACd5B,EAAS,GACTT,EAAO,KAAK,QAAS,CAAE,MAAAqC,CAAM,CAAC,CAChC,CACF,EAEA,GAAI,CACF+B,EAAY,CACd,OAAS/B,EAAO,CACd,MAAAtC,EAAM,QAAQ,EACRsC,CACR,CACA,OAAAxC,EAAOK,CAAO,EACPF,CACT",
|
|
6
|
+
"names": ["createMesh", "destroyTexture", "disposeMesh", "nativeGeometry", "nativeEvents", "parseColor", "update", "nativeLayer", "state", "source", "map", "backend", "meshes", "textures", "methods", "images", "dirty", "viewDirty", "failed", "order", "rasterProgram", "marker", "paneOrder", "current", "refresh", "activeImages", "image", "imageError", "front", "view", "events", "removeEvents", "name", "own", "original", "args", "result", "indices", "layer", "edge", "descriptor", "mesh", "texture", "ready", "resolve", "reject", "error", "local", "latlng", "crs", "origin", "p", "metres", "pixel", "styleMesh", "color", "opacity", "zIndex", "put", "key", "position", "uv", "data", "_", "index", "attribute", "textureFor", "url", "width", "height", "device", "bitmap", "quad", "corners", "i", "boundsQuad", "bounds", "synchronize", "tile", "retained", "nw", "se", "clip", "inverse", "toLocal", "options", "size", "dimensions", "anchor", "center", "left", "top", "x", "y", "offset", "fill", "stroke", "positions", "r", "g", "b"]
|
|
7
|
+
}
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
function m(o){if(o.matrix)return Array.from(o.matrix);const[r,t,n,a]=o.rotation||[0,0,0,1],[i,x,f]=o.scale||[1,1,1];return[(1-2*(t*t+n*n))*i,2*(r*t+n*a)*i,2*(r*n-t*a)*i,0,2*(r*t-n*a)*x,(1-2*(r*r+n*n))*x,2*(t*n+r*a)*x,0,2*(r*n+t*a)*f,2*(t*n-r*a)*f,(1-2*(r*r+t*t))*f,0,...o.translation||[0,0,0],1]}export{m as nodeMatrix};
|
|
2
|
+
//# sourceMappingURL=nodeMatrix.js.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../src/utils/nodeMatrix.js"],
|
|
4
|
+
"sourcesContent": ["/** glTF quaternion/translation/scale to a column-major matrix. */\n\nexport function nodeMatrix(spec) {\n if (spec.matrix) return Array.from(spec.matrix);\n // glTF stores quaternions [x,y,z,w]; convert directly to a scaled column-major matrix.\n const [x, y, z, w] = spec.rotation || [0, 0, 0, 1], [sx, sy, sz] = spec.scale || [1, 1, 1];\n return [\n (1 - 2 * (y * y + z * z)) * sx,\n 2 * (x * y + z * w) * sx,\n 2 * (x * z - y * w) * sx,\n 0,\n 2 * (x * y - z * w) * sy,\n (1 - 2 * (x * x + z * z)) * sy,\n 2 * (y * z + x * w) * sy, 0,\n 2 * (x * z + y * w) * sz,\n 2 * (y * z - x * w) * sz,\n (1 - 2 * (x * x + y * y)) * sz,\n 0,\n ...(spec.translation || [0, 0, 0]),\n 1,\n ];\n}\n"],
|
|
5
|
+
"mappings": "AAEO,SAASA,EAAWC,EAAM,CAC/B,GAAIA,EAAK,OAAQ,OAAO,MAAM,KAAKA,EAAK,MAAM,EAE9C,KAAM,CAACC,EAAGC,EAAGC,EAAGC,CAAC,EAAIJ,EAAK,UAAY,CAAC,EAAG,EAAG,EAAG,CAAC,EAAG,CAACK,EAAIC,EAAIC,CAAE,EAAIP,EAAK,OAAS,CAAC,EAAG,EAAG,CAAC,EACzF,MAAO,EACJ,EAAI,GAAKE,EAAIA,EAAIC,EAAIA,IAAME,EAC5B,GAAKJ,EAAIC,EAAIC,EAAIC,GAAKC,EACtB,GAAKJ,EAAIE,EAAID,EAAIE,GAAKC,EACtB,EACA,GAAKJ,EAAIC,EAAIC,EAAIC,GAAKE,GACrB,EAAI,GAAKL,EAAIA,EAAIE,EAAIA,IAAMG,EAC5B,GAAKJ,EAAIC,EAAIF,EAAIG,GAAKE,EAAI,EAC1B,GAAKL,EAAIE,EAAID,EAAIE,GAAKG,EACtB,GAAKL,EAAIC,EAAIF,EAAIG,GAAKG,GACrB,EAAI,GAAKN,EAAIA,EAAIC,EAAIA,IAAMK,EAC5B,EACA,GAAIP,EAAK,aAAe,CAAC,EAAG,EAAG,CAAC,EAChC,CACF,CACF",
|
|
6
|
+
"names": ["nodeMatrix", "spec", "x", "y", "z", "w", "sx", "sy", "sz"]
|
|
7
|
+
}
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
import*as r from"./attach.js";import*as e from"./onClick.js";import*as l from"./onPointerLeave.js";import*as p from"./onPointerMove.js";function n(o,i){if(!o.location){const t=i.getCenter();o.location=new L.LatLng(t.lat,t.lng)}(o.url||o._geojson||o.options.tooltip||o.modelUrl)&&(o.container=i.getContainer(),o._pointerEvents||={mousemove:t=>p.onPointerMove(o,t),click:t=>e.onClick(o,t),mouseleave:()=>l.onPointerLeave(o)},o.options.tooltip&&(o._tooltip=L.DomUtil.create("div","leaflet-3d-tooltip",o.container),o._tooltip.hidden=!0,o._tooltip.setAttribute("role","tooltip"),o._tooltip.setAttribute("aria-live","polite"),o._tooltip.style.cssText="position:absolute;z-index:600;max-width:220px;padding:10px 12px;border:1px solid #6b5140;border-radius:6px;background:#fffaf0;box-shadow:0 3px 12px #0005;color:#30251d;font:13px/1.45 sans-serif;pointer-events:none"),L.DomEvent.on(o.container,o._pointerEvents)),o.root&&r.attach(o,i).then(()=>o._added.resolve(),t=>o.fire("error",{error:t}))}export{n as onAdd3DLayer};
|
|
2
|
+
//# sourceMappingURL=onAdd3DLayer.js.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../src/utils/onAdd3DLayer.js"],
|
|
4
|
+
"sourcesContent": ["import * as attach from './attach.js';\nimport * as onClick from './onClick.js';\nimport * as onPointerLeave from './onPointerLeave.js';\nimport * as onPointerMove from './onPointerMove.js';\n\n/** Attach interaction immediately; initialization may finish before or after onAdd. */\nexport function onAdd3DLayer(backend, map) {\n if (!backend.location) {\n const center = map.getCenter();\n backend.location = new L.LatLng(center.lat, center.lng);\n }\n if (backend.url || backend._geojson || backend.options.tooltip || backend.modelUrl) {\n backend.container = map.getContainer();\n backend._pointerEvents ||= {\n mousemove: event => onPointerMove.onPointerMove(backend, event),\n click: event => onClick.onClick(backend, event),\n mouseleave: () => onPointerLeave.onPointerLeave(backend),\n };\n if (backend.options.tooltip) {\n backend._tooltip = L.DomUtil.create('div', 'leaflet-3d-tooltip', backend.container);\n backend._tooltip.hidden = true;\n backend._tooltip.setAttribute('role', 'tooltip');\n backend._tooltip.setAttribute('aria-live', 'polite');\n backend._tooltip.style.cssText = 'position:absolute;z-index:600;max-width:220px;padding:10px 12px;border:1px solid #6b5140;border-radius:6px;background:#fffaf0;box-shadow:0 3px 12px #0005;color:#30251d;font:13px/1.45 sans-serif;pointer-events:none';\n }\n L.DomEvent.on(backend.container, backend._pointerEvents);\n }\n if (backend.root) {\n attach.attach(backend, map).then(() => backend._added.resolve(), error => backend.fire('error', { error }));\n }\n}\n"],
|
|
5
|
+
"mappings": "AAAA,UAAYA,MAAY,cACxB,UAAYC,MAAa,eACzB,UAAYC,MAAoB,sBAChC,UAAYC,MAAmB,qBAGxB,SAASC,EAAaC,EAASC,EAAK,CACzC,GAAI,CAACD,EAAQ,SAAU,CACrB,MAAME,EAASD,EAAI,UAAU,EAC7BD,EAAQ,SAAW,IAAI,EAAE,OAAOE,EAAO,IAAKA,EAAO,GAAG,CACxD,EACIF,EAAQ,KAAOA,EAAQ,UAAYA,EAAQ,QAAQ,SAAWA,EAAQ,YACxEA,EAAQ,UAAYC,EAAI,aAAa,EACrCD,EAAQ,iBAAmB,CACzB,UAAWG,GAASL,EAAc,cAAcE,EAASG,CAAK,EAC9D,MAAOA,GAASP,EAAQ,QAAQI,EAASG,CAAK,EAC9C,WAAY,IAAMN,EAAe,eAAeG,CAAO,CACzD,EACIA,EAAQ,QAAQ,UAClBA,EAAQ,SAAW,EAAE,QAAQ,OAAO,MAAO,qBAAsBA,EAAQ,SAAS,EAClFA,EAAQ,SAAS,OAAS,GAC1BA,EAAQ,SAAS,aAAa,OAAQ,SAAS,EAC/CA,EAAQ,SAAS,aAAa,YAAa,QAAQ,EACnDA,EAAQ,SAAS,MAAM,QAAU,yNAEnC,EAAE,SAAS,GAAGA,EAAQ,UAAWA,EAAQ,cAAc,GAErDA,EAAQ,MACVL,EAAO,OAAOK,EAASC,CAAG,EAAE,KAAK,IAAMD,EAAQ,OAAO,QAAQ,EAAGI,GAASJ,EAAQ,KAAK,QAAS,CAAE,MAAAI,CAAM,CAAC,CAAC,CAE9G",
|
|
6
|
+
"names": ["attach", "onClick", "onPointerLeave", "onPointerMove", "onAdd3DLayer", "backend", "map", "center", "event", "error"]
|
|
7
|
+
}
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
import{underEntry as D}from"./underEntry.js";import{update as P}from"./update.js";import{atmosphere as A}from"./atmosphere.js";import{moonPosition as U}from"./moonPosition.js";import{projectCelestialBody as N}from"./projectCelestialBody.js";import{solarPosition as _}from"./solarPosition.js";function B(a,t){if(!a.control){const e=new L.Control({position:"bottomright"});e.live=!0;let r,s,g,l,w;const k=t.getContainer().style.getPropertyValue("--leaflet-sky-background"),T="position:absolute;width:18px;height:18px;border-radius:50%;transform:translate(-50%,-50%);pointer-events:none;",m=L.DomUtil.create("div","sunlight-sun"),f=L.DomUtil.create("div","sunlight-moon");m.style.cssText=T+"background:#fff3bd;box-shadow:0 0 18px 7px #ffd27699;",f.style.cssText=T+"background:#dce5f2;box-shadow:0 0 10px 2px #cbdcff55;",m.setAttribute("role","img"),m.setAttribute("aria-label","Sun"),f.setAttribute("role","img"),f.setAttribute("aria-label","Moon");const c=()=>{const o=t._sunlight,n=t._pitchSky;o?t.getContainer().style.setProperty("--leaflet-sky-background",o.background):k?t.getContainer().style.setProperty("--leaflet-sky-background",k):t.getContainer().style.removeProperty("--leaflet-sky-background");const i=t.getSize(),p=t.getPitch()*Math.PI/180,E=t.getBearing()*Math.PI/180;for(const[u,v]of[[m,o],[f,o?.moon]]){if(u.hidden=!0,!n||!v||v.altitude<=0||!o)continue;u.parentNode!==n&&n.append(u);const S=N(v.direction,i,p,E);if(!S)continue;const{left:y,top:C}=S;u.hidden=y<0||y>i.x||C<0||C>n.clientHeight||n.style.display==="none",u.style.left=`${y}px`,u.style.top=`${C}px`}},x=()=>{const o=L.Layer._renderers.get(t);o&&P(o)},d=()=>{try{e.live&&(e.time=new Date);const o=e.time.toISOString();r.value=o.slice(0,10),s.value=String(e.time.getUTCHours()*60+e.time.getUTCMinutes()),g.textContent=`${o.slice(11,16)} UTC${e.live?" \xB7 now":""}`;const n=t.getCenter(),i=t._sunlight=_(e.time,n.lat,n.lng);Object.assign(i,A(i.altitude)),i.moon=U(e.time,n.lat,n.lng),l.textContent=i.altitude<=0?"Night \xB7 no direct sunlight":i.altitude<3?"Low sun \xB7 shadows paused":`Sun altitude ${i.altitude.toFixed(1)}\xB0`,t.fire("simulationtimechange",{time:new Date(e.time),live:e.live}),c(),x()}catch(o){delete t._sunlight,c(),x(),l.textContent=`Error: ${o.message}`,console.error("Solar simulation",o)}};e.onAdd=()=>{const o=L.DomUtil.create("div","sunlight-control");o.style.cssText="color:#222;width:min(200px,calc(100vw - 60px));font:12px/1.4 sans-serif;",r=document.createElement("input"),r.type="date",r.style.cssText="width:100%;box-sizing:border-box;",r.setAttribute("aria-label","Solar date (UTC)"),s=document.createElement("input"),s.type="range",s.style.cssText="width:100%;box-sizing:border-box;margin:10px 0 4px;cursor:pointer;",s.min="0",s.max="1439",s.step="1",s.setAttribute("aria-label","Time of day (UTC)"),g=document.createElement("output"),g.style.cssText="font-weight:bold;font-variant-numeric:tabular-nums;",g.setAttribute("aria-live","off");const n=document.createElement("button");n.type="button",n.textContent="Now",n.onclick=()=>{e.live=!0,d()};const i=document.createElement("div");i.className="sunlight-time",i.style.cssText="display:flex;justify-content:space-between;align-items:center;",i.append(g,n),l=document.createElement("div"),l.className="sunlight-status",l.style.marginTop="5px",l.setAttribute("role","status");const p=document.createElement("small");return p.style.color="#555",p.textContent="Indicative \xB7 loaded geometry only. Streetlight illumination is estimated, not measured lux.",o.append(r,s,i,l,p),r.onchange=s.oninput=()=>{if(e.live=!1,!r.value||!r.validity.valid){e.time=new Date(NaN),t.fire("simulationtimechange",{time:null,live:!1}),delete t._sunlight,c(),x(),l.textContent="Error: choose a valid solar date";return}e.time=new Date(`${r.value}T00:00:00Z`),e.time.setUTCMinutes(Number(s.value)),d()},L.DomEvent.disableClickPropagation(o),L.DomEvent.disableScrollPropagation(o),d(),w=setInterval(()=>{e.live&&d()},6e4),t.on("moveend",d),t.on("move rotate pitch resize",c),o},e.onRemove=()=>{clearInterval(w),t.fire("simulationtimechange",{time:null,live:!1}),t.off("moveend",d),t.off("move rotate pitch resize",c),delete t._sunlight,c(),m.remove(),f.remove(),x()},a.control=e}a.control._map||a.control.addTo(t);const b=a.control.getContainer(),h=D(a,b);b.classList.toggle("leaflet-control",!h),b.classList.toggle("leaflet-bar",!h),Object.assign(b.style,h?{background:"",padding:"2px 0 6px 20px",margin:"0"}:{background:"#fff",padding:"8px",margin:""})}export{B as onAddSun};
|
|
2
|
+
//# sourceMappingURL=onAddSun.js.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../src/utils/onAddSun.js"],
|
|
4
|
+
"sourcesContent": ["import { underEntry } from './underEntry.js';\nimport { update as updateScene } from \"./update.js\";\nimport { atmosphere } from './atmosphere.js';\nimport { moonPosition } from './moonPosition.js';\nimport { projectCelestialBody } from './projectCelestialBody.js';\nimport { solarPosition } from './solarPosition.js';\n\nexport function onAddSun(layer, map) {\n if (!layer.control) {\n const control = new L.Control({ position: 'bottomright' });\n control.live = true;\n let date, slider, output, status, timer;\n const originalSky = map.getContainer().style.getPropertyValue('--leaflet-sky-background');\n const disc = 'position:absolute;width:18px;height:18px;border-radius:50%;transform:translate(-50%,-50%);pointer-events:none;';\n const sunDisc = L.DomUtil.create('div', 'sunlight-sun');\n const moonDisc = L.DomUtil.create('div', 'sunlight-moon');\n sunDisc.style.cssText = disc + 'background:#fff3bd;box-shadow:0 0 18px 7px #ffd27699;';\n moonDisc.style.cssText = disc + 'background:#dce5f2;box-shadow:0 0 10px 2px #cbdcff55;';\n sunDisc.setAttribute('role', 'img'); sunDisc.setAttribute('aria-label', 'Sun');\n moonDisc.setAttribute('role', 'img'); moonDisc.setAttribute('aria-label', 'Moon');\n const updateSky = () => {\n const sun = map._sunlight, sky = map._pitchSky;\n if (sun) map.getContainer().style.setProperty('--leaflet-sky-background', sun.background);\n else if (originalSky) map.getContainer().style.setProperty('--leaflet-sky-background', originalSky);\n else map.getContainer().style.removeProperty('--leaflet-sky-background');\n const size = map.getSize(), pitch = map.getPitch() * Math.PI / 180, bearing = map.getBearing() * Math.PI / 180;\n for (const [disc, body] of [[sunDisc, sun], [moonDisc, sun?.moon]]) {\n disc.hidden = true;\n if (!sky || !body || body.altitude <= 0 || !sun) continue;\n if (disc.parentNode !== sky) sky.append(disc);\n const point = projectCelestialBody(body.direction, size, pitch, bearing);\n if (!point) continue;\n const { left, top } = point;\n disc.hidden = left < 0 || left > size.x || top < 0 || top > sky.clientHeight || sky.style.display === 'none';\n disc.style.left = `${left}px`; disc.style.top = `${top}px`;\n }\n };\n const render = () => {\n const renderer = L.Layer._renderers.get(map);\n if (renderer) updateScene(renderer);\n };\n const update = () => {\n try {\n if (control.live) control.time = new Date();\n const time = control.time.toISOString();\n date.value = time.slice(0, 10);\n slider.value = String(control.time.getUTCHours() * 60 + control.time.getUTCMinutes());\n output.textContent = `${time.slice(11, 16)} UTC${control.live ? ' \u00B7 now' : ''}`;\n const center = map.getCenter();\n const sun = map._sunlight = solarPosition(control.time, center.lat, center.lng);\n Object.assign(sun, atmosphere(sun.altitude));\n sun.moon = moonPosition(control.time, center.lat, center.lng);\n status.textContent = sun.altitude <= 0\n ? 'Night \u00B7 no direct sunlight'\n : sun.altitude < 3\n ? 'Low sun \u00B7 shadows paused'\n : `Sun altitude ${sun.altitude.toFixed(1)}\u00B0`;\n map.fire('simulationtimechange', { time: new Date(control.time), live: control.live });\n updateSky();\n render();\n } catch (error) {\n delete map._sunlight;\n updateSky();\n render();\n status.textContent = `Error: ${error.message}`;\n console.error('Solar simulation', error);\n }\n };\n control.onAdd = () => {\n const container = L.DomUtil.create('div', 'sunlight-control');\n container.style.cssText = 'color:#222;width:min(200px,calc(100vw - 60px));font:12px/1.4 sans-serif;';\n date = document.createElement('input');\n date.type = 'date';\n date.style.cssText = 'width:100%;box-sizing:border-box;';\n date.setAttribute('aria-label', 'Solar date (UTC)');\n slider = document.createElement('input');\n slider.type = 'range';\n slider.style.cssText = 'width:100%;box-sizing:border-box;margin:10px 0 4px;cursor:pointer;';\n slider.min = '0'; slider.max = '1439'; slider.step = '1';\n slider.setAttribute('aria-label', 'Time of day (UTC)');\n output = document.createElement('output');\n output.style.cssText = 'font-weight:bold;font-variant-numeric:tabular-nums;';\n output.setAttribute('aria-live', 'off');\n const now = document.createElement('button');\n now.type = 'button'; now.textContent = 'Now';\n now.onclick = () => { control.live = true; update(); };\n const timeRow = document.createElement('div');\n timeRow.className = 'sunlight-time';\n timeRow.style.cssText = 'display:flex;justify-content:space-between;align-items:center;';\n timeRow.append(output, now);\n status = document.createElement('div');\n status.className = 'sunlight-status';\n status.style.marginTop = '5px';\n status.setAttribute('role', 'status');\n const note = document.createElement('small');\n note.style.color = '#555';\n note.textContent = 'Indicative \u00B7 loaded geometry only. Streetlight illumination is estimated, not measured lux.';\n container.append(date, slider, timeRow, status, note);\n date.onchange = slider.oninput = () => {\n control.live = false;\n if (!date.value || !date.validity.valid) {\n control.time = new Date(NaN);\n map.fire('simulationtimechange', { time: null, live: false });\n delete map._sunlight;\n updateSky();\n render();\n status.textContent = 'Error: choose a valid solar date';\n return;\n }\n control.time = new Date(`${date.value}T00:00:00Z`);\n control.time.setUTCMinutes(Number(slider.value));\n update();\n };\n L.DomEvent.disableClickPropagation(container);\n L.DomEvent.disableScrollPropagation(container);\n update();\n timer = setInterval(() => { if (control.live) update(); }, 60000);\n map.on('moveend', update);\n map.on('move rotate pitch resize', updateSky);\n return container;\n };\n control.onRemove = () => {\n clearInterval(timer);\n map.fire('simulationtimechange', { time: null, live: false });\n map.off('moveend', update);\n map.off('move rotate pitch resize', updateSky);\n delete map._sunlight;\n updateSky();\n sunDisc.remove(); moonDisc.remove();\n render();\n };\n layer.control = control;\n }\n if (!layer.control._map) {\n layer.control.addTo(map);\n }\n // Shown under this layer's entry in the layers control; a standalone control without one.\n const container = layer.control.getContainer(), nested = underEntry(layer, container);\n container.classList.toggle('leaflet-control', !nested);\n container.classList.toggle('leaflet-bar', !nested);\n Object.assign(\n container.style,\n nested\n ? { background: '', padding: '2px 0 6px 20px', margin: '0' }\n : { background: '#fff', padding: '8px', margin: '' }\n );\n}\n"],
|
|
5
|
+
"mappings": "AAAA,OAAS,cAAAA,MAAkB,kBAC3B,OAAS,UAAUC,MAAmB,cACtC,OAAS,cAAAC,MAAkB,kBAC3B,OAAS,gBAAAC,MAAoB,oBAC7B,OAAS,wBAAAC,MAA4B,4BACrC,OAAS,iBAA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|
6
|
+
"names": ["underEntry", "updateScene", "atmosphere", "moonPosition", "projectCelestialBody", "solarPosition", "onAddSun", "layer", "map", "control", "date", "slider", "output", "status", "timer", "originalSky", "disc", "sunDisc", "moonDisc", "updateSky", "sun", "sky", "size", "pitch", "bearing", "body", "point", "left", "top", "render", "renderer", "update", "time", "center", "error", "container", "now", "timeRow", "note", "nested"]
|
|
7
|
+
}
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
import{findFeature as r}from"./findFeature.js";import{setHighlight as e}from"./setHighlight.js";import{showFeature as f}from"./showFeature.js";function n(o,t){const i=r(o,t);o.hoveredFeature=i,e(o,i),f(o,i,t),o.fire("featureclick",{feature:i,originalEvent:t})}export{n as onClick};
|
|
2
|
+
//# sourceMappingURL=onClick.js.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../src/utils/onClick.js"],
|
|
4
|
+
"sourcesContent": ["import { findFeature } from './findFeature.js';\nimport { setHighlight } from './setHighlight.js';\nimport { showFeature } from './showFeature.js';\n\n/** Emit click without moving the map or pinning the tooltip. */\n\nexport function onClick(layer, event) {\n const feature = findFeature(layer, event);\n layer.hoveredFeature = feature;\n setHighlight(layer, feature);\n showFeature(layer, feature, event);\n layer.fire('featureclick', { feature, originalEvent: event });\n}\n"],
|
|
5
|
+
"mappings": "AAAA,OAAS,eAAAA,MAAmB,mBAC5B,OAAS,gBAAAC,MAAoB,oBAC7B,OAAS,eAAAC,MAAmB,mBAIrB,SAASC,EAAQC,EAAOC,EAAO,CACpC,MAAMC,EAAUN,EAAYI,EAAOC,CAAK,EACxCD,EAAM,eAAiBE,EACvBL,EAAaG,EAAOE,CAAO,EAC3BJ,EAAYE,EAAOE,EAASD,CAAK,EACjCD,EAAM,KAAK,eAAgB,CAAE,QAAAE,EAAS,cAAeD,CAAM,CAAC,CAC9D",
|
|
6
|
+
"names": ["findFeature", "setHighlight", "showFeature", "onClick", "layer", "event", "feature"]
|
|
7
|
+
}
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
import{update as r}from"./update.js";import{render as u}from"./render.js";function o(){const e=this;e._queued||(e._queued=!0,queueMicrotask(()=>{e._queued=!1,!(e._shared!==e||!e.renderer)&&(e._map._animatingZoom?r(e):u(e))}))}export{o as onMapChange};
|
|
2
|
+
//# sourceMappingURL=onMapChange.js.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../src/utils/onMapChange.js"],
|
|
4
|
+
"sourcesContent": ["import { update } from \"./update.js\";\nimport { render } from \"./render.js\";\n\n/** Map movement: render within the frame of Leaflet's CSS transforms, coalescing same-tick events. */\n\nexport function onMapChange() {\n const layer = this;\n if (layer._queued) return;\n layer._queued = true;\n queueMicrotask(() => {\n layer._queued = false;\n if (layer._shared !== layer || !layer.renderer) return;\n if (layer._map._animatingZoom) update(layer);\n else render(layer);\n });\n}\n"],
|
|
5
|
+
"mappings": "AAAA,OAAS,UAAAA,MAAc,cACvB,OAAS,UAAAC,MAAc,cAIhB,SAASC,GAAc,CAC5B,MAAMC,EAAQ,KACVA,EAAM,UACVA,EAAM,QAAU,GAChB,eAAe,IAAM,CACnBA,EAAM,QAAU,GACZ,EAAAA,EAAM,UAAYA,GAAS,CAACA,EAAM,YAClCA,EAAM,KAAK,eAAgBH,EAAOG,CAAK,EACtCF,EAAOE,CAAK,EACnB,CAAC,EACH",
|
|
6
|
+
"names": ["update", "render", "onMapChange", "layer"]
|
|
7
|
+
}
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
import{attach as i}from"./attach.js";import{setRasterTerrain as s,updateRasterTiles as f}from"./rasterTiles.js";function a(r,t){r.location||(r.location=t.getCenter());const e=i(r,t);e.then(()=>{r._added.resolve(),s(r,t._terrain3D)}).catch(o=>r.fire("error",{error:o})),Promise.all([e,r.ready]).then(()=>{r._map===t&&t.hasLayer(r)&&f(r)}).catch(o=>r.fire("error",{error:o}))}export{a as onPMTileAdd};
|
|
2
|
+
//# sourceMappingURL=onPMTileAdd.js.map
|