leaflet-city-mapper 0.0.1 → 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/README.md +15 -13
- package/cucumber.mjs +4 -0
- package/dist/leaflet-city-mapper.js +1 -1
- package/dist/leaflet-city-mapper.js.map +4 -4
- 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 +0 -1
- package/dist/utils/geometry.js.map +4 -4
- 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/{shaders.js → materialShaders.js} +16 -8
- 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 +1 -1
- package/dist/utils/traffic.js.map +3 -3
- 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 +1 -1
- package/dist/utils/vehicles.js.map +3 -3
- package/dist/utils/vertexNormals.js +2 -0
- package/dist/utils/vertexNormals.js.map +7 -0
- package/dist/utils/walk.js +1 -1
- package/dist/utils/walk.js.map +3 -3
- 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 +2 -4
- package/src/index.js +365 -50
- 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 +0 -254
- 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/{picking.js → intersectMeshes.js} +121 -119
- package/src/utils/isClockWise.js +12 -0
- package/src/utils/lampPostGeometry.js +26 -0
- package/src/utils/lightGeometry.js +22 -0
- package/src/utils/{lighting.js → lightGrid.js} +50 -51
- package/src/utils/limbs.js +9 -0
- package/src/{scene/model.js → utils/loadModel.js} +37 -24
- package/src/utils/loadSource.js +17 -0
- package/src/utils/loadTerrain.js +65 -0
- package/src/utils/mapCamera.js +432 -0
- package/src/utils/{shaders.js → materialShaders.js} +243 -237
- 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/{scene/sources.js → utils/pump.js} +59 -98
- 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/{scene → utils}/render.js +112 -173
- 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 +310 -85
- 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/{control.js → underEntry.js} +1 -2
- 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 -69
- package/src/utils/vertexNormals.js +30 -0
- package/src/utils/walk.js +181 -66
- package/src/utils/white.js +1 -0
- package/src/utils/worldLights.js +25 -0
- package/src/utils/wrap.js +1 -0
- package/dist/scene/gpu.js +0 -3
- package/dist/scene/gpu.js.map +0 -7
- package/dist/scene/lighting.js +0 -9
- package/dist/scene/lighting.js.map +0 -7
- package/dist/scene/model.js +0 -2
- package/dist/scene/model.js.map +0 -7
- package/dist/scene/picking.js +0 -2
- package/dist/scene/picking.js.map +0 -7
- package/dist/scene/pmtiles.js +0 -2
- package/dist/scene/pmtiles.js.map +0 -7
- package/dist/scene/render.js +0 -15
- package/dist/scene/render.js.map +0 -7
- package/dist/scene/sources.js +0 -2
- package/dist/scene/sources.js.map +0 -7
- package/dist/types/3d.js +0 -2
- package/dist/types/3d.js.map +0 -7
- package/dist/types/geojson.js +0 -2
- package/dist/types/geojson.js.map +0 -7
- package/dist/types/pmtiles.js +0 -2
- package/dist/types/pmtiles.js.map +0 -7
- package/dist/types/sunlight.js +0 -2
- package/dist/types/sunlight.js.map +0 -7
- package/dist/types/terrain.js +0 -24
- package/dist/types/terrain.js.map +0 -7
- package/dist/types/traffic.js +0 -41
- package/dist/types/traffic.js.map +0 -7
- package/dist/types/walk.js +0 -2
- package/dist/types/walk.js.map +0 -7
- package/dist/utils/control.js +0 -2
- package/dist/utils/control.js.map +0 -7
- package/dist/utils/lighting.js +0 -2
- package/dist/utils/lighting.js.map +0 -7
- package/dist/utils/model.js +0 -2
- package/dist/utils/model.js.map +0 -7
- package/dist/utils/picking.js +0 -2
- package/dist/utils/picking.js.map +0 -7
- package/dist/utils/pmtiles.js +0 -2
- package/dist/utils/pmtiles.js.map +0 -7
- package/dist/utils/scene.js +0 -2
- package/dist/utils/scene.js.map +0 -7
- package/dist/utils/shaders.js.map +0 -7
- package/dist/utils/sun.js +0 -2
- package/dist/utils/sun.js.map +0 -7
- package/dist/utils/terrain.js +0 -2
- package/dist/utils/terrain.js.map +0 -7
- package/src/scene/gpu.js +0 -438
- package/src/scene/lighting.js +0 -193
- package/src/scene/picking.js +0 -150
- package/src/scene/pmtiles.js +0 -94
- package/src/types/3d.js +0 -337
- package/src/types/geojson.js +0 -42
- package/src/types/pmtiles.js +0 -143
- package/src/types/sunlight.js +0 -142
- package/src/types/terrain.js +0 -331
- package/src/types/traffic.js +0 -356
- package/src/types/walk.js +0 -219
- package/src/utils/model.js +0 -178
- package/src/utils/pmtiles.js +0 -79
- package/src/utils/scene.js +0 -102
- package/src/utils/sun.js +0 -71
- package/src/utils/terrain.js +0 -78
|
@@ -1,237 +1,243 @@
|
|
|
1
|
-
/** Material WGSL and texture bindings, without a GPU device or Leaflet layer. */
|
|
2
|
-
export function materialShaders(material = {}, sparkle = false, elevationWGSL = '') {
|
|
3
|
-
const hasBase = Boolean(material.baseTexture);
|
|
4
|
-
const hasMetal = Boolean(material.metalTexture);
|
|
5
|
-
const hasEmissive = Boolean(material.emissiveTexture);
|
|
6
|
-
const hasOcclusion = Boolean(material.occlusionTexture);
|
|
7
|
-
const hasRoof = Boolean(material.roofTexture);
|
|
8
|
-
const hasTerrain = Boolean(material.terrain);
|
|
9
|
-
const textured = hasBase || hasMetal || hasEmissive || hasOcclusion || material.nightLight;
|
|
10
|
-
const vertex = `
|
|
11
|
-
struct Mesh {
|
|
12
|
-
worldMatrix: mat4x4<f32>,
|
|
13
|
-
baseColor: vec4<f32>,
|
|
14
|
-
material: vec4<f32>,
|
|
15
|
-
emissive: vec4<f32>,
|
|
16
|
-
terrain: vec4<f32>,
|
|
17
|
-
highlight: vec4<f32>,
|
|
18
|
-
};
|
|
19
|
-
struct Frame {
|
|
20
|
-
viewMatrix: mat4x4<f32>,
|
|
21
|
-
projectionMatrix: mat4x4<f32>,
|
|
22
|
-
roofMatrix: mat4x4<f32>,
|
|
23
|
-
lightDirection: vec4<f32>,
|
|
24
|
-
skyDirection: vec4<f32>,
|
|
25
|
-
atmosphereTint: vec4<f32>,
|
|
26
|
-
};
|
|
27
|
-
@group(0) @binding(0) var<uniform> u: Mesh;
|
|
28
|
-
@group(0) @binding(1) var<uniform> frame: Frame;
|
|
29
|
-
struct Solar { matrix: mat4x4<f32>, params: vec4<f32> };
|
|
30
|
-
@group(1) @binding(0) var<uniform> solar: Solar;
|
|
31
|
-
${hasTerrain ? `@group(0) @binding(2) var dem: texture_2d<f32>;${elevationWGSL}` : ''}
|
|
32
|
-
struct VertexInput {
|
|
33
|
-
@location(0) position: vec3<f32>,
|
|
34
|
-
@location(1) normal: vec3<f32>,
|
|
35
|
-
${material.vertexColors ? '@location(2) color: vec3<f32>,' : ''}
|
|
36
|
-
${textured ? '@location(3) uv: vec2<f32>,' : ''}
|
|
37
|
-
};
|
|
38
|
-
struct VertexOutput {
|
|
39
|
-
@builtin(position) position: vec4<f32>,
|
|
40
|
-
@location(0) color: vec3<f32>,
|
|
41
|
-
@location(1) normal: vec3<f32>,
|
|
42
|
-
@location(2) viewPosition: vec3<f32>,
|
|
43
|
-
@location(6) shadowPosition: vec4<f32>,
|
|
44
|
-
@location(7) worldPosition: vec3<f32>,
|
|
45
|
-
${sparkle ? '@location(8) localPosition: vec3<f32>,' : ''}
|
|
46
|
-
${textured ? '@location(3) uv: vec2<f32>,' : ''}
|
|
47
|
-
${hasRoof ? '@location(4) roofUv: vec2<f32>, @location(5) roof: f32,' : ''}
|
|
48
|
-
};
|
|
49
|
-
@vertex fn vertexMain(input: VertexInput, @builtin(vertex_index) vertexIndex: u32) -> VertexOutput {
|
|
50
|
-
var output: VertexOutput;
|
|
51
|
-
var position = input.position;
|
|
52
|
-
${hasTerrain ? 'position.y = elevation(u.terrain.xy + input.uv * u.terrain.z, u.terrain.w) - u.terrain.w;' : ''}
|
|
53
|
-
let highlighted = f32(vertexIndex) >= u.highlight.x && f32(vertexIndex) < u.highlight.y;
|
|
54
|
-
output.color = ${material.vertexColors
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
// Inverse-transpose from cofactors; the camera view matrix is orthonormal.
|
|
58
|
-
let m = mat3x3<f32>(u.worldMatrix[0].xyz, u.worldMatrix[1].xyz, u.worldMatrix[2].xyz);
|
|
59
|
-
let normal = (cross(m[1], m[2]) * input.normal.x + cross(m[2], m[0]) * input.normal.y +
|
|
60
|
-
cross(m[0], m[1]) * input.normal.z) / determinant(m);
|
|
61
|
-
output.normal = (frame.viewMatrix * vec4<f32>(normal, 0.0)).xyz;
|
|
62
|
-
let world = u.worldMatrix * vec4<f32>(position, 1.0);
|
|
63
|
-
output.shadowPosition = solar.matrix * world;
|
|
64
|
-
output.worldPosition = world.xyz / world.w;
|
|
65
|
-
${sparkle ? 'output.localPosition = input.position;' : ''}
|
|
66
|
-
let viewPosition = frame.viewMatrix * world;
|
|
67
|
-
output.viewPosition = viewPosition.xyz;
|
|
68
|
-
${textured ? 'output.uv = input.uv;' : ''}
|
|
69
|
-
${hasRoof ? `
|
|
70
|
-
output.roofUv = (frame.roofMatrix * world).xz;
|
|
71
|
-
output.roof = select(0.0, 1.0, input.normal.y >= 0.5 && !highlighted);
|
|
72
|
-
` : ''}
|
|
73
|
-
output.position = frame.projectionMatrix * viewPosition;
|
|
74
|
-
return output;
|
|
75
|
-
}
|
|
76
|
-
`;
|
|
77
|
-
const bindings = [];
|
|
78
|
-
let binding = 3;
|
|
79
|
-
const textureBinding = (name, enabled) => {
|
|
80
|
-
if (!enabled) return '';
|
|
81
|
-
bindings.push({ name, texture: binding, sampler: binding + 1 });
|
|
82
|
-
const current = binding;
|
|
83
|
-
binding += 2;
|
|
84
|
-
return `@group(0) @binding(${current}) var ${name}: texture_2d<f32>;
|
|
85
|
-
@group(0) @binding(${current + 1}) var ${name}Sampler: sampler;`;
|
|
86
|
-
};
|
|
87
|
-
const baseBinding = textureBinding('baseTexture', hasBase);
|
|
88
|
-
const metalBinding = textureBinding('metalTexture', hasMetal);
|
|
89
|
-
const emissiveBinding = textureBinding('emissiveTexture', hasEmissive);
|
|
90
|
-
const occlusionBinding = textureBinding('occlusionTexture', hasOcclusion);
|
|
91
|
-
const roofBinding = textureBinding('roofTexture', hasRoof);
|
|
92
|
-
const fragment = `
|
|
93
|
-
struct Mesh {
|
|
94
|
-
worldMatrix: mat4x4<f32>,
|
|
95
|
-
baseColor: vec4<f32>,
|
|
96
|
-
material: vec4<f32>,
|
|
97
|
-
emissive: vec4<f32>,
|
|
98
|
-
terrain: vec4<f32>,
|
|
99
|
-
highlight: vec4<f32>,
|
|
100
|
-
};
|
|
101
|
-
struct Frame {
|
|
102
|
-
viewMatrix: mat4x4<f32>,
|
|
103
|
-
projectionMatrix: mat4x4<f32>,
|
|
104
|
-
roofMatrix: mat4x4<f32>,
|
|
105
|
-
lightDirection: vec4<f32>,
|
|
106
|
-
skyDirection: vec4<f32>,
|
|
107
|
-
atmosphereTint: vec4<f32>,
|
|
108
|
-
};
|
|
109
|
-
struct Solar {
|
|
110
|
-
matrix: mat4x4<f32>,
|
|
111
|
-
params: vec4<f32>,
|
|
112
|
-
};
|
|
113
|
-
@group(0) @binding(0) var<uniform> u: Mesh;
|
|
114
|
-
@group(0) @binding(1) var<uniform> frame: Frame;
|
|
115
|
-
@group(1) @binding(0) var<uniform> solar: Solar;
|
|
116
|
-
@group(1) @binding(1) var shadowTexture: texture_depth_2d;
|
|
117
|
-
@group(1) @binding(2) var shadowSampler: sampler_comparison;
|
|
118
|
-
@group(1) @binding(3) var<storage, read> lightGrid: array<vec4<f32>>;
|
|
119
|
-
${baseBinding}${metalBinding}${emissiveBinding}${occlusionBinding}${roofBinding}
|
|
120
|
-
struct FragmentInput {
|
|
121
|
-
@
|
|
122
|
-
@location(
|
|
123
|
-
@location(
|
|
124
|
-
@location(
|
|
125
|
-
@location(
|
|
126
|
-
|
|
127
|
-
${
|
|
128
|
-
${
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
let
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
let
|
|
156
|
-
let
|
|
157
|
-
let
|
|
158
|
-
let
|
|
159
|
-
let
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
` :
|
|
180
|
-
|
|
181
|
-
let
|
|
182
|
-
let
|
|
183
|
-
${material.
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
let
|
|
202
|
-
let
|
|
203
|
-
let
|
|
204
|
-
let
|
|
205
|
-
let
|
|
206
|
-
let
|
|
207
|
-
let
|
|
208
|
-
let
|
|
209
|
-
let
|
|
210
|
-
let
|
|
211
|
-
let
|
|
212
|
-
let
|
|
213
|
-
let
|
|
214
|
-
let
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
let
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
}
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
1
|
+
/** Material WGSL and texture bindings, without a GPU device or Leaflet layer. */
|
|
2
|
+
export function materialShaders(material = {}, sparkle = false, elevationWGSL = '') {
|
|
3
|
+
const hasBase = Boolean(material.baseTexture);
|
|
4
|
+
const hasMetal = Boolean(material.metalTexture);
|
|
5
|
+
const hasEmissive = Boolean(material.emissiveTexture);
|
|
6
|
+
const hasOcclusion = Boolean(material.occlusionTexture);
|
|
7
|
+
const hasRoof = Boolean(material.roofTexture);
|
|
8
|
+
const hasTerrain = Boolean(material.terrain);
|
|
9
|
+
const textured = hasBase || hasMetal || hasEmissive || hasOcclusion || material.nightLight;
|
|
10
|
+
const vertex = `
|
|
11
|
+
struct Mesh {
|
|
12
|
+
worldMatrix: mat4x4<f32>,
|
|
13
|
+
baseColor: vec4<f32>,
|
|
14
|
+
material: vec4<f32>,
|
|
15
|
+
emissive: vec4<f32>,
|
|
16
|
+
terrain: vec4<f32>,
|
|
17
|
+
highlight: vec4<f32>,
|
|
18
|
+
};
|
|
19
|
+
struct Frame {
|
|
20
|
+
viewMatrix: mat4x4<f32>,
|
|
21
|
+
projectionMatrix: mat4x4<f32>,
|
|
22
|
+
roofMatrix: mat4x4<f32>,
|
|
23
|
+
lightDirection: vec4<f32>,
|
|
24
|
+
skyDirection: vec4<f32>,
|
|
25
|
+
atmosphereTint: vec4<f32>,
|
|
26
|
+
};
|
|
27
|
+
@group(0) @binding(0) var<uniform> u: Mesh;
|
|
28
|
+
@group(0) @binding(1) var<uniform> frame: Frame;
|
|
29
|
+
struct Solar { matrix: mat4x4<f32>, params: vec4<f32> };
|
|
30
|
+
@group(1) @binding(0) var<uniform> solar: Solar;
|
|
31
|
+
${hasTerrain ? `@group(0) @binding(2) var dem: texture_2d<f32>;${elevationWGSL}` : ''}
|
|
32
|
+
struct VertexInput {
|
|
33
|
+
@location(0) position: vec3<f32>,
|
|
34
|
+
@location(1) normal: vec3<f32>,
|
|
35
|
+
${material.vertexColors ? '@location(2) color: vec3<f32>,' : ''}
|
|
36
|
+
${textured ? '@location(3) uv: vec2<f32>,' : ''}
|
|
37
|
+
};
|
|
38
|
+
struct VertexOutput {
|
|
39
|
+
@builtin(position) position: vec4<f32>,
|
|
40
|
+
@location(0) color: vec3<f32>,
|
|
41
|
+
@location(1) normal: vec3<f32>,
|
|
42
|
+
@location(2) viewPosition: vec3<f32>,
|
|
43
|
+
@location(6) shadowPosition: vec4<f32>,
|
|
44
|
+
@location(7) worldPosition: vec3<f32>,
|
|
45
|
+
${sparkle ? '@location(8) localPosition: vec3<f32>,' : ''}
|
|
46
|
+
${textured ? '@location(3) uv: vec2<f32>,' : ''}
|
|
47
|
+
${hasRoof ? '@location(4) roofUv: vec2<f32>, @location(5) roof: f32,' : ''}
|
|
48
|
+
};
|
|
49
|
+
@vertex fn vertexMain(input: VertexInput, @builtin(vertex_index) vertexIndex: u32) -> VertexOutput {
|
|
50
|
+
var output: VertexOutput;
|
|
51
|
+
var position = input.position;
|
|
52
|
+
${hasTerrain ? 'position.y = elevation(u.terrain.xy + input.uv * u.terrain.z, u.terrain.w) - u.terrain.w;' : ''}
|
|
53
|
+
let highlighted = f32(vertexIndex) >= u.highlight.x && f32(vertexIndex) < u.highlight.y;
|
|
54
|
+
output.color = ${material.vertexColors
|
|
55
|
+
? 'select(input.color, vec3<f32>(72.0 / 255.0, 217.0 / 255.0, 1.0), highlighted)'
|
|
56
|
+
: 'u.baseColor.rgb'};
|
|
57
|
+
// Inverse-transpose from cofactors; the camera view matrix is orthonormal.
|
|
58
|
+
let m = mat3x3<f32>(u.worldMatrix[0].xyz, u.worldMatrix[1].xyz, u.worldMatrix[2].xyz);
|
|
59
|
+
let normal = (cross(m[1], m[2]) * input.normal.x + cross(m[2], m[0]) * input.normal.y +
|
|
60
|
+
cross(m[0], m[1]) * input.normal.z) / determinant(m);
|
|
61
|
+
output.normal = (frame.viewMatrix * vec4<f32>(normal, 0.0)).xyz;
|
|
62
|
+
let world = u.worldMatrix * vec4<f32>(position, 1.0);
|
|
63
|
+
output.shadowPosition = solar.matrix * world;
|
|
64
|
+
output.worldPosition = world.xyz / world.w;
|
|
65
|
+
${sparkle ? 'output.localPosition = input.position;' : ''}
|
|
66
|
+
let viewPosition = frame.viewMatrix * world;
|
|
67
|
+
output.viewPosition = viewPosition.xyz;
|
|
68
|
+
${textured ? 'output.uv = input.uv;' : ''}
|
|
69
|
+
${hasRoof ? `
|
|
70
|
+
output.roofUv = (frame.roofMatrix * world).xz;
|
|
71
|
+
output.roof = select(0.0, 1.0, input.normal.y >= 0.5 && !highlighted);
|
|
72
|
+
` : ''}
|
|
73
|
+
output.position = frame.projectionMatrix * viewPosition;
|
|
74
|
+
return output;
|
|
75
|
+
}
|
|
76
|
+
`;
|
|
77
|
+
const bindings = [];
|
|
78
|
+
let binding = 3;
|
|
79
|
+
const textureBinding = (name, enabled) => {
|
|
80
|
+
if (!enabled) return '';
|
|
81
|
+
bindings.push({ name, texture: binding, sampler: binding + 1 });
|
|
82
|
+
const current = binding;
|
|
83
|
+
binding += 2;
|
|
84
|
+
return `@group(0) @binding(${current}) var ${name}: texture_2d<f32>;
|
|
85
|
+
@group(0) @binding(${current + 1}) var ${name}Sampler: sampler;`;
|
|
86
|
+
};
|
|
87
|
+
const baseBinding = textureBinding('baseTexture', hasBase);
|
|
88
|
+
const metalBinding = textureBinding('metalTexture', hasMetal);
|
|
89
|
+
const emissiveBinding = textureBinding('emissiveTexture', hasEmissive);
|
|
90
|
+
const occlusionBinding = textureBinding('occlusionTexture', hasOcclusion);
|
|
91
|
+
const roofBinding = textureBinding('roofTexture', hasRoof);
|
|
92
|
+
const fragment = `
|
|
93
|
+
struct Mesh {
|
|
94
|
+
worldMatrix: mat4x4<f32>,
|
|
95
|
+
baseColor: vec4<f32>,
|
|
96
|
+
material: vec4<f32>,
|
|
97
|
+
emissive: vec4<f32>,
|
|
98
|
+
terrain: vec4<f32>,
|
|
99
|
+
highlight: vec4<f32>,
|
|
100
|
+
};
|
|
101
|
+
struct Frame {
|
|
102
|
+
viewMatrix: mat4x4<f32>,
|
|
103
|
+
projectionMatrix: mat4x4<f32>,
|
|
104
|
+
roofMatrix: mat4x4<f32>,
|
|
105
|
+
lightDirection: vec4<f32>,
|
|
106
|
+
skyDirection: vec4<f32>,
|
|
107
|
+
atmosphereTint: vec4<f32>,
|
|
108
|
+
};
|
|
109
|
+
struct Solar {
|
|
110
|
+
matrix: mat4x4<f32>,
|
|
111
|
+
params: vec4<f32>,
|
|
112
|
+
};
|
|
113
|
+
@group(0) @binding(0) var<uniform> u: Mesh;
|
|
114
|
+
@group(0) @binding(1) var<uniform> frame: Frame;
|
|
115
|
+
@group(1) @binding(0) var<uniform> solar: Solar;
|
|
116
|
+
@group(1) @binding(1) var shadowTexture: texture_depth_2d;
|
|
117
|
+
@group(1) @binding(2) var shadowSampler: sampler_comparison;
|
|
118
|
+
@group(1) @binding(3) var<storage, read> lightGrid: array<vec4<f32>>;
|
|
119
|
+
${baseBinding}${metalBinding}${emissiveBinding}${occlusionBinding}${roofBinding}
|
|
120
|
+
struct FragmentInput {
|
|
121
|
+
@builtin(position) position: vec4<f32>,
|
|
122
|
+
@location(0) color: vec3<f32>,
|
|
123
|
+
@location(1) normal: vec3<f32>,
|
|
124
|
+
@location(2) viewPosition: vec3<f32>,
|
|
125
|
+
@location(6) shadowPosition: vec4<f32>,
|
|
126
|
+
@location(7) worldPosition: vec3<f32>,
|
|
127
|
+
${sparkle ? '@location(8) localPosition: vec3<f32>,' : ''}
|
|
128
|
+
${textured ? '@location(3) uv: vec2<f32>,' : ''}
|
|
129
|
+
${hasRoof ? '@location(4) roofUv: vec2<f32>, @location(5) roof: f32,' : ''}
|
|
130
|
+
};
|
|
131
|
+
const PI: f32 = 3.14159265;
|
|
132
|
+
fn toLinear(c: vec3<f32>) -> vec3<f32> {
|
|
133
|
+
return select(c / 12.92, pow((c + vec3<f32>(0.055)) / 1.055, vec3<f32>(2.4)), c >= vec3<f32>(0.04045));
|
|
134
|
+
}
|
|
135
|
+
fn toSRGB(c: vec3<f32>) -> vec3<f32> {
|
|
136
|
+
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));
|
|
137
|
+
}
|
|
138
|
+
fn sunVisibility(position: vec4<f32>) -> f32 {
|
|
139
|
+
let p = position.xyz / position.w;
|
|
140
|
+
let uv = vec2<f32>(p.x * 0.5 + 0.5, 0.5 - p.y * 0.5);
|
|
141
|
+
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) {
|
|
142
|
+
return 1.0;
|
|
143
|
+
}
|
|
144
|
+
return textureSampleCompareLevel(shadowTexture, shadowSampler, uv, p.z - 0.0003);
|
|
145
|
+
}
|
|
146
|
+
fn localLighting(position: vec3<f32>, normal: vec3<f32>) -> vec3<f32> {
|
|
147
|
+
if (frame.skyDirection.w <= 0.0 || lightGrid[0].w < 1.0) { return vec3<f32>(0.0); }
|
|
148
|
+
let cell = vec2<i32>(floor((position.xz - lightGrid[0].xy) / lightGrid[0].z));
|
|
149
|
+
if (any(cell < vec2<i32>(0)) || cell.x >= i32(lightGrid[0].w) || cell.y >= i32(lightGrid[1].x)) {
|
|
150
|
+
return vec3<f32>(0.0);
|
|
151
|
+
}
|
|
152
|
+
let header = lightGrid[2u + u32(cell.y) * u32(lightGrid[0].w) + u32(cell.x)];
|
|
153
|
+
var light = vec3<f32>(0.0);
|
|
154
|
+
for (var i = 0u; i < u32(header.y); i++) {
|
|
155
|
+
let source = lightGrid[u32(header.x) + i * 2u];
|
|
156
|
+
let colour = lightGrid[u32(header.x) + i * 2u + 1u];
|
|
157
|
+
let delta = source.xyz - position;
|
|
158
|
+
let distance2 = max(dot(delta, delta), 1.0);
|
|
159
|
+
let falloff = max(0.0, 1.0 - distance2 / (source.w * source.w));
|
|
160
|
+
let lambert = max(0.0, dot(normal, delta / sqrt(distance2)));
|
|
161
|
+
light += toLinear(colour.rgb) * colour.w * lambert * falloff * falloff / distance2;
|
|
162
|
+
}
|
|
163
|
+
return light * frame.skyDirection.w;
|
|
164
|
+
}
|
|
165
|
+
fn appearance(position: vec2<f32>) {
|
|
166
|
+
// Screen-door dissolve keeps opaque depth writes and avoids sorting whole buildings as glass.
|
|
167
|
+
let noise = fract(52.9829189 * fract(dot(floor(position), vec2<f32>(0.06711056, 0.00583715))));
|
|
168
|
+
if (u.highlight.w < 1.0 && noise >= u.highlight.w) { discard; }
|
|
169
|
+
}
|
|
170
|
+
@fragment fn fragmentMain(input: FragmentInput, @builtin(front_facing) frontFacing: bool) -> @location(0) vec4<f32> {
|
|
171
|
+
${material.nightLight ? `
|
|
172
|
+
if (input.uv.x <= 2.0) {
|
|
173
|
+
let radial = max(0.0, 1.0 - dot(input.uv, input.uv));
|
|
174
|
+
let alpha = radial * radial * frame.skyDirection.w * 0.65;
|
|
175
|
+
if (alpha < 0.005) { discard; }
|
|
176
|
+
appearance(input.position.xy);
|
|
177
|
+
return vec4<f32>(input.color, alpha);
|
|
178
|
+
}
|
|
179
|
+
` : ''}
|
|
180
|
+
let sunlight = sunVisibility(input.shadowPosition);
|
|
181
|
+
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);
|
|
182
|
+
let artificial = localLighting(input.worldPosition, worldNormal);
|
|
183
|
+
${material.unlit ? `
|
|
184
|
+
let rasterTexel = ${hasBase ? 'textureSample(baseTexture, baseTextureSampler, input.uv)' : 'vec4<f32>(input.color, 1.0)'};
|
|
185
|
+
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'});
|
|
186
|
+
` : `
|
|
187
|
+
var normal = normalize(input.normal) * select(-1.0, 1.0, frontFacing);
|
|
188
|
+
let texel = ${hasBase ? 'textureSample(baseTexture, baseTextureSampler, input.uv)' : 'vec4<f32>(1.0)'};
|
|
189
|
+
let alpha = u.material.z * texel.a;
|
|
190
|
+
${material.alphaMode === 'MASK' ? 'if (alpha < u.material.w) { discard; }' : ''}
|
|
191
|
+
${material.alphaMode === 'BLEND' ? 'if (alpha < 0.01) { discard; }' : ''}
|
|
192
|
+
var base = ${material.vertexColors ? 'toLinear(min(input.color, vec3<f32>(1.0)))' : 'input.color'} *
|
|
193
|
+
${material.baseTexture?.srgb ? 'texel.rgb' : 'toLinear(texel.rgb)'};
|
|
194
|
+
${hasRoof ? `
|
|
195
|
+
if (input.roof > 0.5 && all(input.roofUv >= vec2<f32>(0.0)) &&
|
|
196
|
+
all(input.roofUv <= vec2<f32>(1.0))) {
|
|
197
|
+
let roof = textureSampleLevel(roofTexture, roofTextureSampler, input.roofUv, 0.0);
|
|
198
|
+
base = mix(base, toLinear(roof.rgb), roof.a);
|
|
199
|
+
}
|
|
200
|
+
` : ''}
|
|
201
|
+
let mr = ${hasMetal ? 'textureSample(metalTexture, metalTextureSampler, input.uv)' : 'vec4<f32>(1.0)'};
|
|
202
|
+
let metal = clamp(u.material.x * mr.b, 0.0, 1.0);
|
|
203
|
+
let rough = clamp(u.material.y * mr.g, 0.08, 1.0);
|
|
204
|
+
let view = normalize(-input.viewPosition);
|
|
205
|
+
let halfVector = normalize(view + frame.lightDirection.xyz);
|
|
206
|
+
let nl = max(dot(normal, frame.lightDirection.xyz), 0.0) * frame.lightDirection.w * sunlight;
|
|
207
|
+
let nv = max(dot(normal, view), 0.001);
|
|
208
|
+
let nh = max(dot(normal, halfVector), 0.0);
|
|
209
|
+
let vh = max(dot(view, halfVector), 0.0);
|
|
210
|
+
let a2 = pow(rough, 4.0);
|
|
211
|
+
let d = a2 / max(PI * pow(nh * nh * (a2 - 1.0) + 1.0, 2.0), 0.0001);
|
|
212
|
+
let gv = nl * sqrt(nv * nv * (1.0 - a2) + a2);
|
|
213
|
+
let gl = nv * sqrt(nl * nl * (1.0 - a2) + a2);
|
|
214
|
+
let visibility = 0.5 / max(gv + gl, 0.0001);
|
|
215
|
+
let f0 = mix(vec3<f32>(0.04), base, metal);
|
|
216
|
+
let fresnel = f0 + (1.0 - f0) * pow(1.0 - vh, 5.0);
|
|
217
|
+
let specular = d * visibility * fresnel;
|
|
218
|
+
let diffuse = (1.0 - metal) * base / PI;
|
|
219
|
+
let sky = dot(normal, frame.skyDirection.xyz) * 0.5 + 0.5;
|
|
220
|
+
let ambient = mix(toLinear(vec3<f32>(0.455, 0.412, 0.322)), vec3<f32>(1.0), sky) * (2.0 / PI);
|
|
221
|
+
let ao = ${hasOcclusion ? 'mix(1.0, textureSample(occlusionTexture, occlusionTextureSampler, input.uv).r, u.emissive.w)' : '1.0'};
|
|
222
|
+
${sparkle ? `
|
|
223
|
+
let lattice = (fract(input.localPosition / 2.5) - 0.5) * 2.5;
|
|
224
|
+
let pointGlow = (1.0 - smoothstep(0.16, 0.42, length(lattice))) * u.highlight.z;
|
|
225
|
+
` : ''}
|
|
226
|
+
// Vertex colour components above 1 are self-lit (e.g. vehicle lamps): dim by day, bright at night.
|
|
227
|
+
let glow = ${sparkle ? 'vec3<f32>(3.0, 2.6, 1.8) * pointGlow +' : ''}${material.vertexColors
|
|
228
|
+
? ' max(input.color - vec3<f32>(1.0), vec3<f32>(0.0)) * (0.3 + 5.0 * frame.skyDirection.w) +' : ''} u.emissive.rgb * ${hasEmissive
|
|
229
|
+
? material.emissiveTexture.srgb
|
|
230
|
+
? 'textureSample(emissiveTexture, emissiveTextureSampler, input.uv).rgb'
|
|
231
|
+
: 'toLinear(textureSample(emissiveTexture, emissiveTextureSampler, input.uv).rgb)'
|
|
232
|
+
: 'vec3<f32>(1.0)'};
|
|
233
|
+
var color = ambient * base * (1.0 - metal) * ao +
|
|
234
|
+
(diffuse + specular) * nl * toLinear(vec3<f32>(1.0, 0.937, 0.835)) * 3.0 + glow;
|
|
235
|
+
${material.vertexColors ? 'color = base * (ambient + toLinear(vec3<f32>(1.0, 0.937, 0.835)) * (3.0 / PI) * nl) + glow;' : ''}
|
|
236
|
+
color = (color - glow) * frame.atmosphereTint.rgb + base * artificial * (1.0 - metal * 0.5) + glow;
|
|
237
|
+
appearance(input.position.xy);
|
|
238
|
+
return vec4<f32>(toSRGB(color), ${material.alphaMode === 'BLEND' ? 'alpha' : '1.0'});
|
|
239
|
+
`}
|
|
240
|
+
}
|
|
241
|
+
`;
|
|
242
|
+
return { vertex, fragment, bindings, textured, hasTerrain };
|
|
243
|
+
}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { solarPosition } from "./solarPosition.js";
|
|
2
|
+
import { horizontalPosition } from "./horizontalPosition.js";
|
|
3
|
+
|
|
4
|
+
// Low-precision geocentric lunar orbit; no parallax or atmospheric refraction.
|
|
5
|
+
|
|
6
|
+
export function moonPosition(date, lat, lng) {
|
|
7
|
+
solarPosition(date, lat, lng);
|
|
8
|
+
const rad = Math.PI / 180, d = new Date(date).getTime() / 86400000 - 10957.5;
|
|
9
|
+
const anomaly = (134.963 + 13.064993 * d) * rad;
|
|
10
|
+
const longitude = (218.316 + 13.176396 * d + 6.289 * Math.sin(anomaly)) * rad;
|
|
11
|
+
const latitude = 5.128 * Math.sin((93.272 + 13.229350 * d) * rad) * rad;
|
|
12
|
+
const obliquity = 23.4397 * rad;
|
|
13
|
+
const x = Math.cos(latitude) * Math.cos(longitude);
|
|
14
|
+
const y = Math.cos(latitude) * Math.sin(longitude) * Math.cos(obliquity) - Math.sin(latitude) * Math.sin(obliquity);
|
|
15
|
+
const z = Math.cos(latitude) * Math.sin(longitude) * Math.sin(obliquity) + Math.sin(latitude) * Math.cos(obliquity);
|
|
16
|
+
return horizontalPosition(d, lat, lng, Math.atan2(y, x), Math.asin(z));
|
|
17
|
+
}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
// W/S (↑/↓) run forward/back along the heading, A/D (←/→) turn: [forward, turn].
|
|
2
|
+
export const moves = {
|
|
3
|
+
KeyW: [1, 0],
|
|
4
|
+
ArrowUp: [1, 0],
|
|
5
|
+
KeyS: [-1, 0],
|
|
6
|
+
ArrowDown: [-1, 0],
|
|
7
|
+
KeyD: [0, 1],
|
|
8
|
+
ArrowRight: [0, 1],
|
|
9
|
+
KeyA: [0, -1],
|
|
10
|
+
ArrowLeft: [0, -1]
|
|
11
|
+
};
|
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
import { raycast } from './raycast.js';
|
|
2
|
+
|
|
3
|
+
const maps = new WeakMap();
|
|
4
|
+
|
|
5
|
+
/** One GPU hit test per map event, rather than one invisible SVG path per feature. */
|
|
6
|
+
export function nativeEvents(state) {
|
|
7
|
+
const { map } = state;
|
|
8
|
+
let context = maps.get(map);
|
|
9
|
+
if (!context) {
|
|
10
|
+
context = { states: new Set(), hovered: null };
|
|
11
|
+
const pointer = L.version.startsWith('2');
|
|
12
|
+
const move = pointer ? 'pointermove' : 'mousemove', out = pointer ? 'pointerout' : 'mouseout';
|
|
13
|
+
const over = pointer ? 'pointerover' : 'mouseover';
|
|
14
|
+
const descriptor = Object.getOwnPropertyDescriptor(map, '_fireDOMEvent');
|
|
15
|
+
const fireDOMEvent = map._fireDOMEvent;
|
|
16
|
+
const handle = function (event, type = event.type, targets) {
|
|
17
|
+
const owner = L.Layer._renderers.get(map);
|
|
18
|
+
if (!owner?.renderer || targets || !['click', 'preclick', 'dblclick', 'contextmenu',
|
|
19
|
+
'mousedown', 'mouseup', 'mousemove', 'mouseover', 'mouseout',
|
|
20
|
+
'pointerdown', 'pointerup', 'pointermove', 'pointerover', 'pointerout'].includes(type)) {
|
|
21
|
+
return fireDOMEvent.call(this, event, type, targets);
|
|
22
|
+
}
|
|
23
|
+
const target = event.target;
|
|
24
|
+
const dom = target instanceof Element &&
|
|
25
|
+
target.closest('.leaflet-marker-icon,.leaflet-popup,.leaflet-tooltip,.leaflet-control');
|
|
26
|
+
if (dom && context.hovered && (type === move || type === out)) {
|
|
27
|
+
fireDOMEvent.call(map, event, out, [context.hovered]);
|
|
28
|
+
context.hovered = null;
|
|
29
|
+
map.getContainer().style.cursor = '';
|
|
30
|
+
}
|
|
31
|
+
if (dom || type === move && (map.dragging?.moving() || map._animatingZoom)) {
|
|
32
|
+
return fireDOMEvent.call(this, event, type, targets);
|
|
33
|
+
}
|
|
34
|
+
const meshes = [];
|
|
35
|
+
if (type !== out) {
|
|
36
|
+
for (const candidate of context.states) {
|
|
37
|
+
const { source } = candidate;
|
|
38
|
+
if (source instanceof L.Marker || source.options.interactive === false ||
|
|
39
|
+
!(source instanceof L.Path) && !source.options.interactive) continue;
|
|
40
|
+
meshes.push(...candidate.meshes.values());
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
const hits = meshes.length ? raycast(owner, event, meshes, false) : [];
|
|
44
|
+
hits.sort((a, b) => b.object.renderOrder - a.object.renderOrder || a.distance - b.distance);
|
|
45
|
+
let source = hits[0]?.object._nativeSource || null;
|
|
46
|
+
if ((type === 'click' || type === 'preclick') && source && map._draggableMoved(source)) source = null;
|
|
47
|
+
if (type === move || type === out) {
|
|
48
|
+
if (context.hovered !== source) {
|
|
49
|
+
if (context.hovered) fireDOMEvent.call(map, event, out, [context.hovered]);
|
|
50
|
+
context.hovered = source;
|
|
51
|
+
if (source) fireDOMEvent.call(map, event, over, [source]);
|
|
52
|
+
map.getContainer().style.cursor = source ? 'pointer' : '';
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
return fireDOMEvent.call(this, event, type, source ? [source] : undefined);
|
|
56
|
+
};
|
|
57
|
+
context.handle = handle;
|
|
58
|
+
context.restore = () => {
|
|
59
|
+
if (map._fireDOMEvent !== handle) return;
|
|
60
|
+
if (descriptor) Object.defineProperty(map, '_fireDOMEvent', descriptor);
|
|
61
|
+
else delete map._fireDOMEvent;
|
|
62
|
+
};
|
|
63
|
+
maps.set(map, context);
|
|
64
|
+
map._fireDOMEvent = handle;
|
|
65
|
+
}
|
|
66
|
+
context.states.add(state);
|
|
67
|
+
return () => {
|
|
68
|
+
context.states.delete(state);
|
|
69
|
+
if (context.hovered === state.source) {
|
|
70
|
+
context.hovered = null;
|
|
71
|
+
map.getContainer().style.cursor = '';
|
|
72
|
+
}
|
|
73
|
+
if (context.states.size) return;
|
|
74
|
+
context.restore();
|
|
75
|
+
maps.delete(map);
|
|
76
|
+
};
|
|
77
|
+
}
|