leaflet-city-mapper 0.0.1 → 0.0.3
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 +61 -13
- package/cucumber.mjs +4 -0
- package/dist/leaflet-city-mapper.js +3 -1
- package/dist/leaflet-city-mapper.js.map +4 -4
- package/package.json +3 -4
- package/src/archives/decodeDirectory.js +32 -0
- package/src/archives/decodeHeader.js +19 -0
- package/src/archives/decompress.js +5 -0
- package/src/archives/getHeader.js +9 -0
- package/src/archives/getZxy.js +75 -0
- package/src/archives/loadDirectory.js +7 -0
- package/src/archives/loadSource.js +17 -0
- package/src/archives/read.js +29 -0
- package/src/archives/tileId.js +19 -0
- package/src/archives/varint.js +15 -0
- package/src/camera/angles.js +6 -0
- package/src/camera/animationPoint.js +8 -0
- package/src/camera/cameraMapReady.js +8 -0
- package/src/camera/cancelCameraAnimation.js +11 -0
- package/src/camera/cleanupCameraMap.js +11 -0
- package/src/camera/constrainCameraToBounds.js +3 -0
- package/src/camera/displayPoint.js +3 -0
- package/src/camera/fitCameraBounds.js +48 -0
- package/src/camera/groundBounds.js +11 -0
- package/src/camera/initializeCameraMap.js +25 -0
- package/src/camera/mapAnimateCamera.js +17 -0
- package/src/camera/mapCamera.js +123 -0
- package/src/camera/mapContainerPointToLayerPoint.js +7 -0
- package/src/camera/mapGetBearing.js +1 -0
- package/src/camera/mapGetBounds.js +14 -0
- package/src/camera/mapGetBoundsCenterZoom.js +7 -0
- package/src/camera/mapGetBoundsZoom.js +14 -0
- package/src/camera/mapGetCenterLayerPoint.js +5 -0
- package/src/camera/mapGetPitch.js +1 -0
- package/src/camera/mapLayerPointToContainerPoint.js +7 -0
- package/src/camera/mapLimitCenter.js +12 -0
- package/src/camera/mapLimitOffset.js +10 -0
- package/src/camera/mapPanBy.js +9 -0
- package/src/camera/mapPanInside.js +14 -0
- package/src/camera/mapResetNorth.js +1 -0
- package/src/camera/mapResetNorthPitch.js +1 -0
- package/src/camera/mapSetBearing.js +1 -0
- package/src/camera/mapSetPitch.js +1 -0
- package/src/camera/mapSetPitchAndBearing.js +14 -0
- package/src/camera/mapSetZoomAround.js +11 -0
- package/src/camera/mapStopPitchBearingAnimation.js +6 -0
- package/src/camera/mapTryAnimatedPan.js +9 -0
- package/src/camera/mapUpdateCameraOverlays.js +7 -0
- package/src/camera/pointOf.js +3 -0
- package/src/camera/project.js +20 -0
- package/src/camera/runCameraAnimations.js +28 -0
- package/src/camera/scheduleCameraAnimation.js +8 -0
- package/src/camera/updateSky.js +16 -0
- package/src/camera/verticalGroundY.js +4 -0
- package/src/collision/collectMeshes.js +5 -0
- package/src/collision/collider.js +63 -0
- package/src/collision/horizontalRay.js +12 -0
- package/src/collision/intersectMeshes.js +133 -0
- package/src/collision/sortHits.js +23 -0
- package/src/constants/CELL.js +4 -0
- package/src/constants/Compass.js +7 -0
- package/src/constants/ContainerResize.js +7 -0
- package/src/constants/HEIGHT.js +1 -0
- package/src/constants/PitchDrag.js +7 -0
- package/src/constants/ShiftRotate.js +7 -0
- package/src/constants/TILE_RADIUS.js +1 -0
- package/src/constants/TILE_SIZE.js +1 -0
- package/src/constants/TouchMode.js +6 -0
- package/src/constants/accessorSizes.js +1 -0
- package/src/constants/accessorTypes.js +8 -0
- package/src/constants/attachState.js +1 -0
- package/src/constants/cameraControlsState.js +1 -0
- package/src/constants/cityMapper.js +6 -0
- package/src/constants/colliders.js +2 -0
- package/src/constants/dark.js +1 -0
- package/src/constants/elevationWGSL.js +27 -0
- package/src/constants/glass.js +1 -0
- package/src/constants/headlight.js +1 -0
- package/src/constants/hull.js +1 -0
- package/src/constants/indexState.js +1 -0
- package/src/constants/limbs.js +9 -0
- package/src/constants/mapCameraState.js +1 -0
- package/src/constants/moves.js +11 -0
- package/src/constants/nativeEventMaps.js +1 -0
- package/src/constants/nativeLayerState.js +1 -0
- package/src/constants/nativeMethodHandlers.js +31 -0
- package/src/constants/onMapChangeState.js +1 -0
- package/src/constants/onZoomAnimState.js +1 -0
- package/src/constants/paints.js +10 -0
- package/src/constants/parts.js +19 -0
- package/src/constants/pendingUpdates.js +1 -0
- package/src/constants/pumpState.js +1 -0
- package/src/constants/renderers.js +2 -0
- package/src/constants/ringDirections.js +10 -0
- package/src/constants/roundProfile.js +1 -0
- package/src/constants/shirt.js +1 -0
- package/src/constants/skin.js +2 -0
- package/src/constants/speed.js +3 -0
- package/src/constants/taillight.js +1 -0
- package/src/constants/trafficShader.js +49 -0
- package/src/constants/trousers.js +1 -0
- package/src/constants/tyre.js +1 -0
- package/src/constants/underEntryState.js +1 -0
- package/src/constants/vehicles.js +40 -0
- package/src/constants/white.js +1 -0
- package/src/controls/acceptPitchDrag.js +4 -0
- package/src/controls/acceptRotateDrag.js +3 -0
- package/src/controls/adjustCameraDrag.js +10 -0
- package/src/controls/cameraControls.js +60 -0
- package/src/controls/cameraDragClick.js +9 -0
- package/src/controls/cameraDragContextMenu.js +8 -0
- package/src/controls/cameraDragDown.js +20 -0
- package/src/controls/cameraDragEnd.js +6 -0
- package/src/controls/cameraDragMove.js +23 -0
- package/src/controls/changeCameraTouch.js +14 -0
- package/src/controls/cleanupCameraTouch.js +24 -0
- package/src/controls/compassAddHooks.js +15 -0
- package/src/controls/compassOrientation.js +6 -0
- package/src/controls/compassRemoveHooks.js +5 -0
- package/src/controls/containerResizeAddHooks.js +8 -0
- package/src/controls/containerResizeRemoveHooks.js +5 -0
- package/src/controls/dragCamera.js +22 -0
- package/src/controls/editable.js +3 -0
- package/src/controls/endAllCameraDrags.js +7 -0
- package/src/controls/endAllCameraTouches.js +7 -0
- package/src/controls/endCameraTouch.js +11 -0
- package/src/controls/endCameraTouchEvent.js +5 -0
- package/src/controls/finishCameraDrag.js +9 -0
- package/src/controls/finishCompassPermission.js +16 -0
- package/src/controls/loadCameraControls.js +9 -0
- package/src/controls/moveCameraTouch.js +22 -0
- package/src/controls/notifyCameraTouchChange.js +1 -0
- package/src/controls/pitchDragAddHooks.js +6 -0
- package/src/controls/pitchDragRemoveHooks.js +5 -0
- package/src/controls/refreshRotateControl.js +7 -0
- package/src/controls/refreshRotateFocus.js +5 -0
- package/src/controls/removeCameraDrag.js +23 -0
- package/src/controls/resizeMap.js +3 -0
- package/src/controls/rotateButtonClick.js +7 -0
- package/src/controls/rotateButtonKeydown.js +11 -0
- package/src/controls/rotateControl.js +3 -0
- package/src/controls/rotateOnAdd.js +38 -0
- package/src/controls/rotateOnRemove.js +6 -0
- package/src/controls/shiftRotateAddHooks.js +8 -0
- package/src/controls/shiftRotateRemoveHooks.js +5 -0
- package/src/controls/shiftRotateWheel.js +9 -0
- package/src/controls/startCameraTouch.js +23 -0
- package/src/core/addImageState.js +7 -0
- package/src/core/addRasterImage.js +10 -0
- package/src/core/adjustCameraMarkerPan.js +22 -0
- package/src/core/beforeNativeRender.js +10 -0
- package/src/core/boundsQuad.js +11 -0
- package/src/core/bringNativeLayerToBack.js +3 -0
- package/src/core/bringNativeLayerToFront.js +3 -0
- package/src/core/cameraCircleBounds.js +6 -0
- package/src/core/cameraMarkerDrag.js +18 -0
- package/src/core/cameraMarkerOnDrag.js +8 -0
- package/src/core/cancelGridFade.js +10 -0
- package/src/core/closestCameraLayerPoint.js +7 -0
- package/src/core/compareNativeHits.js +3 -0
- package/src/core/current.js +3 -0
- package/src/core/disposeNativeLayer.js +35 -0
- package/src/core/fireRasterLoad.js +5 -0
- package/src/core/forwardNativeError.js +3 -0
- package/src/core/gridlayerGetEvents.js +7 -0
- package/src/core/gridlayerGetTiledPixelBounds.js +8 -0
- package/src/core/handleNativeMapEvent.js +47 -0
- package/src/core/hideTargets.js +16 -0
- package/src/core/initNativeGPU.js +21 -0
- package/src/core/initializeGridContainer.js +6 -0
- package/src/core/initializeNativeLayer.js +42 -0
- package/src/core/localPixel.js +5 -0
- package/src/core/localPixelForGeometry.js +6 -0
- package/src/core/localPosition.js +6 -0
- package/src/core/markerCameraIconPoint.js +9 -0
- package/src/core/markerGetEvents.js +5 -0
- package/src/core/markerInitInteraction.js +8 -0
- package/src/core/markerQuadCorners.js +31 -0
- package/src/core/markerSetIcon.js +9 -0
- package/src/core/markerSetPos.js +14 -0
- package/src/core/markerSetRotation.js +7 -0
- package/src/core/markerUpdateZIndex.js +8 -0
- package/src/core/nativeAddLatLng.js +3 -0
- package/src/core/nativeBringToBack.js +3 -0
- package/src/core/nativeBringToFront.js +3 -0
- package/src/core/nativeEvents.js +26 -0
- package/src/core/nativeImageError.js +8 -0
- package/src/core/nativeImageRefresh.js +7 -0
- package/src/core/nativeLayer.js +97 -0
- package/src/core/nativeLayerMethod.js +21 -0
- package/src/core/nativeRedraw.js +3 -0
- package/src/core/nativeSetBounds.js +3 -0
- package/src/core/nativeSetIcon.js +3 -0
- package/src/core/nativeSetLatLng.js +3 -0
- package/src/core/nativeSetLatLngs.js +3 -0
- package/src/core/nativeSetOpacity.js +3 -0
- package/src/core/nativeSetRadius.js +3 -0
- package/src/core/nativeSetStyle.js +3 -0
- package/src/core/nativeSetUrl.js +3 -0
- package/src/core/nativeSetZIndex.js +3 -0
- package/src/core/nativeSetZIndexOffset.js +3 -0
- package/src/core/popupAdjustPan.js +23 -0
- package/src/core/popupGetEvents.js +5 -0
- package/src/core/popupUpdatePosition.js +14 -0
- package/src/core/putNativeMesh.js +33 -0
- package/src/core/quadNativeMesh.js +15 -0
- package/src/core/readyNativeGPU.js +6 -0
- package/src/core/refreshNativeEvent.js +5 -0
- package/src/core/refreshNativeLayer.js +29 -0
- package/src/core/refreshNativeLayerContract.js +3 -0
- package/src/core/rejectNativeReady.js +3 -0
- package/src/core/removeImageState.js +8 -0
- package/src/core/removeNativeEvents.js +16 -0
- package/src/core/removeTargets.js +8 -0
- package/src/core/reorderNativeLayer.js +6 -0
- package/src/core/resolveNativeReady.js +3 -0
- package/src/core/restoreNativeEvents.js +6 -0
- package/src/core/runGridFades.js +14 -0
- package/src/core/runMarkerPanFrame.js +12 -0
- package/src/core/scheduleGridFade.js +9 -0
- package/src/core/scheduleMarkerPan.js +8 -0
- package/src/core/styleNativeMesh.js +10 -0
- package/src/core/syncGridLayer.js +22 -0
- package/src/core/syncImageOverlay.js +9 -0
- package/src/core/syncMarker.js +12 -0
- package/src/core/syncVectorLayer.js +26 -0
- package/src/core/synchronizeNativeLayer.js +35 -0
- package/src/core/textureFor.js +48 -0
- package/src/core/tooltipGetEvents.js +5 -0
- package/src/core/tooltipSetPosition.js +8 -0
- package/src/core/updateGridOpacity.js +23 -0
- package/src/core/updateNativeLayerView.js +6 -0
- package/src/core/uploadCanvasTexture.js +19 -0
- package/src/geometry/addBridges.js +88 -0
- package/src/geometry/below.js +3 -0
- package/src/geometry/box.js +3 -0
- package/src/geometry/bridgeElevation.js +19 -0
- package/src/geometry/bridgeLocal.js +4 -0
- package/src/geometry/build.js +19 -0
- package/src/geometry/circleAt.js +5 -0
- package/src/geometry/clipLine.js +23 -0
- package/src/geometry/clipSegment.js +19 -0
- package/src/geometry/computeBounds.js +33 -0
- package/src/geometry/conformModelToTerrain.js +67 -0
- package/src/geometry/cross.js +3 -0
- package/src/geometry/disk.js +11 -0
- package/src/geometry/diskAt.js +4 -0
- package/src/geometry/dot.js +6 -0
- package/src/geometry/emitter.js +8 -0
- package/src/geometry/lampPostGeometry.js +24 -0
- package/src/geometry/lampRing.js +11 -0
- package/src/geometry/lightGeometry.js +15 -0
- package/src/geometry/line.js +54 -0
- package/src/geometry/nativeGeometry.js +55 -0
- package/src/geometry/nativeTriangle.js +3 -0
- package/src/geometry/polygon.js +22 -0
- package/src/geometry/push.js +3 -0
- package/src/geometry/quad.js +4 -0
- package/src/geometry/roofCoverage.js +52 -0
- package/src/geometry/samePoint.js +3 -0
- package/src/geometry/segment.js +21 -0
- package/src/geometry/setVertexColor.js +15 -0
- package/src/geometry/sub.js +6 -0
- package/src/geometry/surface.js +17 -0
- package/src/geometry/treeGeometry.js +31 -0
- package/src/geometry/treeRing.js +14 -0
- package/src/geometry/triangle.js +12 -0
- package/src/geometry/vertexNormals.js +32 -0
- package/src/geometry/visit.js +9 -0
- package/src/index.js +98 -65
- package/src/lighting/cacheLightGrid.js +23 -0
- package/src/lighting/collectLightMeshes.js +6 -0
- package/src/lighting/lightGrid.js +42 -0
- package/src/lighting/updatePointLights.js +34 -0
- package/src/lighting/visitCells.js +15 -0
- package/src/lighting/worldLights.js +27 -0
- package/src/models/decodeModel.js +45 -0
- package/src/models/hasUnsupportedPrimitives.js +10 -0
- package/src/models/loadBuffer.js +6 -0
- package/src/models/loadImage.js +15 -0
- package/src/models/loadModel.js +69 -0
- package/src/models/materialFor.js +21 -0
- package/src/models/modelNode.js +93 -0
- package/src/models/nodeMatrix.js +22 -0
- package/src/models/readAccessor.js +53 -0
- package/src/models/readAccessorValues.js +16 -0
- package/src/models/textureFor.js +35 -0
- package/src/models/textureSampler.js +10 -0
- package/src/picking/collectVisibleMesh.js +4 -0
- package/src/picking/findFeature.js +49 -0
- package/src/picking/hit.js +23 -0
- package/src/picking/hitMesh.js +30 -0
- package/src/picking/onClick.js +13 -0
- package/src/picking/onPointerLeave.js +11 -0
- package/src/picking/onPointerMove.js +15 -0
- package/src/picking/pointerClick.js +5 -0
- package/src/picking/pointerLeave.js +5 -0
- package/src/picking/pointerMove.js +5 -0
- package/src/picking/raycast.js +59 -0
- package/src/picking/setHighlight.js +13 -0
- package/src/picking/shouldSkipOther.js +3 -0
- package/src/picking/showFeature.js +34 -0
- package/src/raster/addRasterTile.js +114 -0
- package/src/raster/comparePendingTiles.js +5 -0
- package/src/raster/createGeometry.js +22 -0
- package/src/raster/createRasterMesh.js +47 -0
- package/src/raster/finishAttachment.js +11 -0
- package/src/raster/finishRasterTile.js +47 -0
- package/src/raster/getRasterEvents.js +6 -0
- package/src/raster/getRasterTileSize.js +5 -0
- package/src/raster/initRaster.js +38 -0
- package/src/raster/isLoading.js +5 -0
- package/src/raster/loadRasterTile.js +10 -0
- package/src/raster/onPMTileAdd.js +10 -0
- package/src/raster/onPMTileRemove.js +8 -0
- package/src/raster/pruneRasterTiles.js +37 -0
- package/src/raster/pumpRasterTiles.js +22 -0
- package/src/raster/readyRaster.js +13 -0
- package/src/raster/registerTerrainTile.js +12 -0
- package/src/raster/releaseRasterTile.js +18 -0
- package/src/raster/releaseRasterTiles.js +15 -0
- package/src/raster/removeRasterTile.js +13 -0
- package/src/raster/reportError.js +6 -0
- package/src/raster/setPMTileOpacity.js +7 -0
- package/src/raster/setPMTileZIndex.js +7 -0
- package/src/raster/setRasterOpacity.js +11 -0
- package/src/raster/setRasterTerrain.js +21 -0
- package/src/raster/setRasterZIndex.js +11 -0
- package/src/raster/updateAttachedTiles.js +10 -0
- package/src/raster/updateRasterTiles.js +59 -0
- package/src/rendering/collectFrameMeshes.js +31 -0
- package/src/rendering/collectMeshes.js +36 -0
- package/src/rendering/compareMeshes.js +10 -0
- package/src/rendering/compareRoofTiles.js +4 -0
- package/src/rendering/composeRoofAtlas.js +52 -0
- package/src/rendering/createMesh.js +33 -0
- package/src/rendering/createProgram.js +92 -0
- package/src/rendering/destroyAfterSubmission.js +8 -0
- package/src/rendering/destroyTexture.js +6 -0
- package/src/rendering/disposeMesh.js +14 -0
- package/src/rendering/drawGeometry.js +129 -0
- package/src/rendering/drawSceneMeshes.js +51 -0
- package/src/rendering/ensureRoofBlit.js +40 -0
- package/src/rendering/prepareFrameMeshes.js +42 -0
- package/src/rendering/prepareFrameUniforms.js +49 -0
- package/src/rendering/rebuildRoofAtlas.js +67 -0
- package/src/rendering/render.js +57 -0
- package/src/rendering/reportCompilation.js +17 -0
- package/src/rendering/resizeRenderer.js +19 -0
- package/src/rendering/sortMeshes.js +6 -0
- package/src/rendering/synchronizeZoomView.js +34 -0
- package/src/rendering/textureBinding.js +7 -0
- package/src/rendering/updateMapCamera.js +32 -0
- package/src/rendering/updateRoofRaster.js +32 -0
- package/src/scene/attach.js +161 -0
- package/src/scene/attachLayer.js +10 -0
- package/src/scene/cancelUpdate.js +10 -0
- package/src/scene/emptyEvents.js +3 -0
- package/src/scene/emptyNode.js +11 -0
- package/src/scene/endZoom.js +16 -0
- package/src/scene/failAttachment.js +9 -0
- package/src/scene/get3DEvents.js +13 -0
- package/src/scene/init3D.js +30 -0
- package/src/scene/initializeLayer.js +16 -0
- package/src/scene/initializerFor.js +14 -0
- package/src/scene/layerInitialize.js +38 -0
- package/src/scene/layerLayerAdd.js +21 -0
- package/src/scene/onAdd3DLayer.js +35 -0
- package/src/scene/onMapChange.js +16 -0
- package/src/scene/onRemove3DLayer.js +69 -0
- package/src/scene/onZoomAnim.js +16 -0
- package/src/scene/placeEntry.js +11 -0
- package/src/scene/placeUnderEntry.js +8 -0
- package/src/scene/ready3D.js +25 -0
- package/src/scene/releaseRenderer.js +14 -0
- package/src/scene/removeEntry.js +6 -0
- package/src/scene/renderPendingMapChange.js +11 -0
- package/src/scene/renderPendingUpdates.js +19 -0
- package/src/scene/renderPendingZoomAnimation.js +7 -0
- package/src/scene/rendererDeviceError.js +10 -0
- package/src/scene/rendererDeviceLost.js +11 -0
- package/src/scene/replaceEntry.js +7 -0
- package/src/scene/reportError.js +3 -0
- package/src/scene/requestAdapter.js +12 -0
- package/src/scene/requestDevice.js +9 -0
- package/src/scene/resolveNextInitialization.js +12 -0
- package/src/scene/restoreObject.js +71 -0
- package/src/scene/runPlacements.js +7 -0
- package/src/scene/setParent.js +7 -0
- package/src/scene/showWebGPUWarning.js +16 -0
- package/src/scene/startZoom.js +5 -0
- package/src/scene/traverse.js +7 -0
- package/src/scene/underEntry.js +17 -0
- package/src/scene/update.js +19 -0
- package/src/scene/updateCamera.js +34 -0
- package/src/scene/updateWorldMatrix.js +48 -0
- package/src/{utils/shaders.js → shaders/materialShaders.js} +246 -237
- package/src/shadows/bindSunlight.js +12 -0
- package/src/shadows/drawShadowMeshes.js +48 -0
- package/src/shadows/ensureShadowPipeline.js +53 -0
- package/src/shadows/renderSunlight.js +46 -0
- package/src/shadows/resizeSunlight.js +15 -0
- package/src/shadows/shadowBounds.js +32 -0
- package/src/shadows/shadowCacheMatches.js +23 -0
- package/src/shadows/shadowMatrix.js +39 -0
- package/src/sources/addGeneratedTriangle.js +6 -0
- package/src/sources/addTriangle.js +17 -0
- package/src/sources/attachAreaMesh.js +58 -0
- package/src/sources/buildArea.js +42 -0
- package/src/sources/buildAreaFeature.js +41 -0
- package/src/sources/buildAreaPoint.js +25 -0
- package/src/sources/buildAreaPolygon.js +29 -0
- package/src/sources/compareAreaDistance.js +4 -0
- package/src/sources/generateTreeGeometry.js +11 -0
- package/src/sources/groundOffset.js +3 -0
- package/src/sources/initializeGeoJSON.js +8 -0
- package/src/sources/instanceAreaGeometry.js +29 -0
- package/src/sources/projectRing.js +20 -0
- package/src/sources/projectedTree.js +13 -0
- package/src/sources/pump.js +54 -0
- package/src/sources/releaseArea.js +22 -0
- package/src/sources/setGeoJSONData.js +12 -0
- package/src/sources/setGeoJSONLayerData.js +5 -0
- package/src/sources/sourceAreaContext.js +9 -0
- package/src/sources/updateArea.js +45 -0
- package/src/sources/updateStatus.js +12 -0
- package/src/sunlight/addTimeLayer.js +3 -0
- package/src/sunlight/addTo.js +10 -0
- package/src/sunlight/atmosphere.js +28 -0
- package/src/sunlight/horizontalPosition.js +16 -0
- package/src/sunlight/initSunlight.js +14 -0
- package/src/sunlight/initialize.js +11 -0
- package/src/sunlight/mix.js +6 -0
- package/src/sunlight/moonPosition.js +17 -0
- package/src/sunlight/onAdd.js +5 -0
- package/src/sunlight/onAddSun.js +66 -0
- package/src/sunlight/projectCelestialBody.js +13 -0
- package/src/sunlight/remove.js +7 -0
- package/src/sunlight/removeSun.js +15 -0
- package/src/sunlight/removeTimeLayer.js +3 -0
- package/src/sunlight/render.js +7 -0
- package/src/sunlight/rgb.js +6 -0
- package/src/sunlight/solarPosition.js +17 -0
- package/src/sunlight/styleTimeControl.js +7 -0
- package/src/sunlight/tickSun.js +5 -0
- package/src/sunlight/updateSky.js +20 -0
- package/src/sunlight/updateSun.js +34 -0
- package/src/sunlight/useLiveTime.js +6 -0
- package/src/sunlight/useSelectedTime.js +20 -0
- package/src/terrain/clearLayerTerrain.js +5 -0
- package/src/terrain/getElevation.js +10 -0
- package/src/terrain/initTerrain.js +20 -0
- package/src/terrain/loadReadyTerrain.js +5 -0
- package/src/terrain/loadTerrain.js +63 -0
- package/src/terrain/loadTerrainTiles.js +13 -0
- package/src/terrain/onTerrainAdd.js +21 -0
- package/src/terrain/onTerrainChange.js +14 -0
- package/src/terrain/onTerrainRemove.js +41 -0
- package/src/terrain/readBridges.js +4 -0
- package/src/terrain/sample.js +7 -0
- package/src/terrain/setLayerTerrain.js +5 -0
- package/src/terrain/setTerrainHeight.js +10 -0
- package/src/terrain/terrainAtlas.js +23 -0
- package/src/terrain/terrainElevation.js +20 -0
- package/src/terrain/terrainGrid.js +24 -0
- package/src/traffic/addTraffic.js +7 -0
- package/src/traffic/along.js +14 -0
- package/src/traffic/clockMinutes.js +6 -0
- package/src/traffic/compareDepartures.js +5 -0
- package/src/traffic/createTrafficMesh.js +7 -0
- package/src/traffic/destroyTrafficGpu.js +5 -0
- package/src/traffic/disposeTrafficObject.js +13 -0
- package/src/traffic/drawTrafficRoute.js +6 -0
- package/src/traffic/failTraffic.js +6 -0
- package/src/traffic/failedTrafficLoad.js +5 -0
- package/src/traffic/fetchTrafficLanes.js +10 -0
- package/src/traffic/groundTraffic.js +15 -0
- package/src/traffic/initTraffic.js +54 -0
- package/src/traffic/loadTraffic.js +15 -0
- package/src/traffic/loadedTrafficLanes.js +16 -0
- package/src/traffic/locateTraffic.js +9 -0
- package/src/traffic/moveTraffic.js +15 -0
- package/src/traffic/placeTraffic.js +21 -0
- package/src/traffic/prepareTraffic.js +25 -0
- package/src/traffic/readyTraffic.js +6 -0
- package/src/traffic/rebaseTraffic.js +58 -0
- package/src/traffic/rebuildTrafficMesh.js +28 -0
- package/src/traffic/removeTraffic.js +17 -0
- package/src/traffic/routeColor.js +6 -0
- package/src/traffic/routeGeometry.js +31 -0
- package/src/traffic/scheduledTrips.js +40 -0
- package/src/traffic/startTraffic.js +8 -0
- package/src/traffic/tickTraffic.js +57 -0
- package/src/traffic/toLanes.js +16 -0
- package/src/traffic/tooltip.js +11 -0
- package/src/traffic/trafficBounds.js +17 -0
- package/src/traffic/trafficNow.js +4 -0
- package/src/traffic/trafficStorage.js +5 -0
- package/src/traffic/tripsAt.js +27 -0
- package/src/traffic/updateTraffic.js +8 -0
- package/src/traffic/updateTrafficTerrain.js +12 -0
- package/src/traffic/vehicleOffsets.js +11 -0
- package/src/triangulation/area.js +9 -0
- package/src/triangulation/clean.js +18 -0
- package/src/triangulation/containsVertex.js +11 -0
- package/src/triangulation/cross.js +3 -0
- package/src/triangulation/crossesBoundary.js +8 -0
- package/src/triangulation/crossesRing.js +9 -0
- package/src/triangulation/equal.js +3 -0
- package/src/triangulation/inside.js +10 -0
- package/src/triangulation/insideHole.js +7 -0
- package/src/triangulation/intersects.js +11 -0
- package/src/triangulation/isClockWise.js +13 -0
- package/src/triangulation/minimumX.js +6 -0
- package/src/triangulation/on.js +4 -0
- package/src/triangulation/sortHoles.js +26 -0
- package/src/triangulation/triangulate.js +86 -0
- package/src/utils/channel.js +4 -0
- package/src/utils/compareDistance.js +3 -0
- package/src/utils/noOperation.js +1 -0
- package/src/utils/parseColor.js +42 -0
- package/src/utils/toSRGB.js +3 -0
- package/src/utils/wrap.js +3 -0
- package/src/vehicles/bicycleModel.js +23 -0
- package/src/vehicles/boatBenches.js +8 -0
- package/src/vehicles/boatModel.js +27 -0
- package/src/vehicles/busModel.js +6 -0
- package/src/vehicles/carModel.js +22 -0
- package/src/vehicles/carriage.js +19 -0
- package/src/vehicles/metroModel.js +9 -0
- package/src/vehicles/mirror.js +8 -0
- package/src/vehicles/pedestrianModel.js +17 -0
- package/src/vehicles/tramModel.js +9 -0
- package/src/walk/blocked.js +6 -0
- package/src/walk/createWalk.js +60 -0
- package/src/walk/initWalk.js +18 -0
- package/src/walk/initialize.js +6 -0
- package/src/walk/local.js +10 -0
- package/src/walk/onAdd.js +4 -0
- package/src/walk/onBlur.js +3 -0
- package/src/walk/onKey.js +12 -0
- package/src/walk/onPointer.js +13 -0
- package/src/walk/onRemove.js +4 -0
- package/src/walk/onTerrain.js +5 -0
- package/src/walk/place.js +18 -0
- package/src/walk/start.js +37 -0
- package/src/walk/step.js +53 -0
- package/src/walk/stop.js +27 -0
- package/src/walk/toggle.js +6 -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/geometry.js +0 -2
- package/dist/utils/geometry.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 +0 -203
- 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/dist/utils/traffic.js +0 -2
- package/dist/utils/traffic.js.map +0 -7
- package/dist/utils/vehicles.js +0 -2
- package/dist/utils/vehicles.js.map +0 -7
- package/dist/utils/walk.js +0 -2
- package/dist/utils/walk.js.map +0 -7
- package/src/scene/gpu.js +0 -438
- package/src/scene/lighting.js +0 -193
- package/src/scene/model.js +0 -204
- package/src/scene/picking.js +0 -150
- package/src/scene/pmtiles.js +0 -94
- package/src/scene/render.js +0 -467
- package/src/scene/sources.js +0 -265
- 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/control.js +0 -18
- package/src/utils/geometry.js +0 -256
- package/src/utils/lighting.js +0 -51
- package/src/utils/model.js +0 -178
- package/src/utils/picking.js +0 -119
- 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
- package/src/utils/traffic.js +0 -90
- package/src/utils/vehicles.js +0 -69
- package/src/utils/walk.js +0 -72
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
import { pump } from "./pump.js";
|
|
2
|
+
import { releaseArea } from './releaseArea.js';
|
|
3
|
+
import { compareAreaDistance } from './compareAreaDistance.js';
|
|
4
|
+
|
|
5
|
+
/** Cover the visible ground bounds and one bordering block, clipped to the archive. */
|
|
6
|
+
|
|
7
|
+
export function updateArea(backend) {
|
|
8
|
+
if (!backend._map || !backend._shared) return;
|
|
9
|
+
if (backend._geojson) {
|
|
10
|
+
if (!backend._areas.has('geojson')) {
|
|
11
|
+
backend._areas.set('geojson', { request: new AbortController() });
|
|
12
|
+
}
|
|
13
|
+
pump(backend);
|
|
14
|
+
return;
|
|
15
|
+
}
|
|
16
|
+
if (!backend.header) return;
|
|
17
|
+
const z = backend.header.minZoom;
|
|
18
|
+
const center = backend._map.project(backend._map.getCenter(), z).divideBy(256).floor();
|
|
19
|
+
const bounds = backend._map.getBounds();
|
|
20
|
+
const nw = backend._map.project(bounds.getNorthWest(), z).divideBy(256).floor();
|
|
21
|
+
const se = backend._map.project(bounds.getSouthEast(), z).divideBy(256).floor();
|
|
22
|
+
const archiveNW = backend._map.project([backend.header.maxLat, backend.header.minLon], z).divideBy(256).floor();
|
|
23
|
+
const archiveSE = backend._map.project([backend.header.minLat, backend.header.maxLon], z).divideBy(256).floor();
|
|
24
|
+
const wanted = new Map();
|
|
25
|
+
let x, y, key, area, coords;
|
|
26
|
+
for (x = Math.max(0, nw.x - 1, archiveNW.x); x <= Math.min(2 ** z - 1, se.x + 1, archiveSE.x); x++) {
|
|
27
|
+
for (y = Math.max(0, nw.y - 1, archiveNW.y); y <= Math.min(2 ** z - 1, se.y + 1, archiveSE.y); y++) {
|
|
28
|
+
wanted.set(`${x}/${y}`, { z, x, y });
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
for ([key, area] of backend._areas) {
|
|
32
|
+
if (!wanted.has(key)) {
|
|
33
|
+
releaseArea(backend, area);
|
|
34
|
+
backend._areas.delete(key);
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
// Load the nearest new blocks first without rebuilding retained geometry.
|
|
38
|
+
const areas = [];
|
|
39
|
+
for ([key, coords] of wanted) areas.push([key, coords, center]);
|
|
40
|
+
areas.sort(compareAreaDistance);
|
|
41
|
+
for ([key, coords] of areas) {
|
|
42
|
+
if (!backend._areas.has(key)) backend._areas.set(key, { coords, request: new AbortController() });
|
|
43
|
+
}
|
|
44
|
+
pump(backend);
|
|
45
|
+
}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
/** Emit a snapshot for consumers; ready does not wait for all neighborhood tasks. */
|
|
2
|
+
export function updateStatus(backend, enabled = true) {
|
|
3
|
+
const progress = { enabled, loaded: 0, skipped: 0, pending: 0, errors: [] };
|
|
4
|
+
let area;
|
|
5
|
+
for (area of backend._areas.values()) {
|
|
6
|
+
if (area.error) progress.errors.push(area.error);
|
|
7
|
+
else if (!area.done) progress.pending++;
|
|
8
|
+
progress.loaded += area.buildings ?? 0;
|
|
9
|
+
progress.skipped += area.skipped ?? 0;
|
|
10
|
+
}
|
|
11
|
+
backend.fire('progress', progress);
|
|
12
|
+
}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { underEntry } from '../scene/underEntry.js';
|
|
2
|
+
import { styleTimeControl } from './styleTimeControl.js';
|
|
3
|
+
|
|
4
|
+
export function addTo(map) {
|
|
5
|
+
L.Control.prototype.addTo.call(this, map);
|
|
6
|
+
const container = this.getContainer();
|
|
7
|
+
if (this.layer._map === map) underEntry(this.layer, container, styleTimeControl.bind(null, container));
|
|
8
|
+
else styleTimeControl(container, false);
|
|
9
|
+
return this;
|
|
10
|
+
}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
|
|
2
|
+
import { mix } from './mix.js';
|
|
3
|
+
import { rgb } from './rgb.js';
|
|
4
|
+
|
|
5
|
+
export function atmosphere(altitude) {
|
|
6
|
+
if (!Number.isFinite(altitude)) {
|
|
7
|
+
throw new Error('Invalid solar altitude');
|
|
8
|
+
}
|
|
9
|
+
const stops = [
|
|
10
|
+
[-18, [3, 7, 20], [17, 28, 54], [0.025, 0.04, 0.09]],
|
|
11
|
+
[-6, [37, 53, 84], [182, 106, 86], [0.12, 0.10, 0.14]],
|
|
12
|
+
[0, [101, 131, 171], [246, 170, 115], [0.38, 0.24, 0.18]],
|
|
13
|
+
[10, [74, 147, 208], [197, 221, 237], [0.80, 0.75, 0.68]],
|
|
14
|
+
[25, [53, 144, 213], [223, 238, 250], [1, 1, 1]],
|
|
15
|
+
];
|
|
16
|
+
let upper = -1;
|
|
17
|
+
let i;
|
|
18
|
+
for (i = 0; i < stops.length; i++) {
|
|
19
|
+
if (stops[i][0] >= altitude) { upper = i; break; }
|
|
20
|
+
}
|
|
21
|
+
const b = stops[upper < 0 ? stops.length - 1 : upper],
|
|
22
|
+
a = stops[Math.max(0, upper - 1)];
|
|
23
|
+
const t = a === b || upper < 0 ? 1 : (altitude - a[0]) / (b[0] - a[0]);
|
|
24
|
+
return {
|
|
25
|
+
background: `linear-gradient(${rgb(mix(a[1], b[1], t))}, ${rgb(mix(a[2], b[2], t))})`,
|
|
26
|
+
tint: mix(a[3], b[3], t),
|
|
27
|
+
};
|
|
28
|
+
}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
|
|
2
|
+
export function horizontalPosition(d, lat, lng, ascension, declination) {
|
|
3
|
+
const rad = Math.PI / 180;
|
|
4
|
+
const hourAngle = (280.16 + 360.9856235 * d + lng) * rad - ascension;
|
|
5
|
+
const latitude = lat * rad;
|
|
6
|
+
const altitude = Math.asin(Math.sin(latitude) * Math.sin(declination) +
|
|
7
|
+
Math.cos(latitude) * Math.cos(declination) * Math.cos(hourAngle));
|
|
8
|
+
const southAzimuth = Math.atan2(Math.sin(hourAngle),
|
|
9
|
+
Math.cos(hourAngle) * Math.sin(latitude) - Math.tan(declination) * Math.cos(latitude));
|
|
10
|
+
const azimuth = (southAzimuth / rad + 180 + 360) % 360;
|
|
11
|
+
return {
|
|
12
|
+
altitude: altitude / rad, azimuth,
|
|
13
|
+
direction: [Math.sin(azimuth * rad) * Math.cos(altitude), Math.sin(altitude),
|
|
14
|
+
-Math.cos(azimuth * rad) * Math.cos(altitude)]
|
|
15
|
+
};
|
|
16
|
+
}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { onAddSun } from './onAddSun.js';
|
|
2
|
+
import { underEntry } from '../scene/underEntry.js';
|
|
3
|
+
import { initialize } from './initialize.js';
|
|
4
|
+
import { onAdd } from './onAdd.js';
|
|
5
|
+
import { addTo } from './addTo.js';
|
|
6
|
+
import { remove } from './remove.js';
|
|
7
|
+
|
|
8
|
+
L.Control.Time = L.Control.extend({
|
|
9
|
+
options: { position: 'bottomright' },
|
|
10
|
+
initialize,
|
|
11
|
+
onAdd,
|
|
12
|
+
addTo,
|
|
13
|
+
remove,
|
|
14
|
+
});
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { addTimeLayer } from './addTimeLayer.js';
|
|
2
|
+
import { removeTimeLayer } from './removeTimeLayer.js';
|
|
3
|
+
|
|
4
|
+
export function initialize(options) {
|
|
5
|
+
L.Util.setOptions(this, options);
|
|
6
|
+
this.live = true;
|
|
7
|
+
this.layer = new L.Layer();
|
|
8
|
+
this.layer.control = this;
|
|
9
|
+
this.layer.onAdd = addTimeLayer;
|
|
10
|
+
this.layer.onRemove = removeTimeLayer;
|
|
11
|
+
}
|
|
@@ -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,66 @@
|
|
|
1
|
+
import { cityMapper } from '../constants/cityMapper.js';
|
|
2
|
+
import { update as updateScene } from '../scene/update.js';
|
|
3
|
+
import { atmosphere } from './atmosphere.js';
|
|
4
|
+
import { moonPosition } from './moonPosition.js';
|
|
5
|
+
import { projectCelestialBody } from './projectCelestialBody.js';
|
|
6
|
+
import { solarPosition } from './solarPosition.js';
|
|
7
|
+
import { updateSky } from './updateSky.js';
|
|
8
|
+
import { render } from './render.js';
|
|
9
|
+
import { updateSun } from './updateSun.js';
|
|
10
|
+
import { useLiveTime } from './useLiveTime.js';
|
|
11
|
+
import { useSelectedTime } from './useSelectedTime.js';
|
|
12
|
+
import { tickSun } from './tickSun.js';
|
|
13
|
+
import { removeSun } from './removeSun.js';
|
|
14
|
+
|
|
15
|
+
export function onAddSun(control, map) {
|
|
16
|
+
map._timeControl = control;
|
|
17
|
+
const originalSky = map.getContainer().style.getPropertyValue('--leaflet-sky-background');
|
|
18
|
+
const disc = 'position:absolute;width:18px;height:18px;border-radius:50%;transform:translate(-50%,-50%);pointer-events:none;';
|
|
19
|
+
const sunDisc = L.DomUtil.create('div', 'sunlight-sun');
|
|
20
|
+
const moonDisc = L.DomUtil.create('div', 'sunlight-moon');
|
|
21
|
+
sunDisc.style.cssText = disc + 'background:#fff3bd;box-shadow:0 0 18px 7px #ffd27699;';
|
|
22
|
+
moonDisc.style.cssText = disc + 'background:#dce5f2;box-shadow:0 0 10px 2px #cbdcff55;';
|
|
23
|
+
sunDisc.setAttribute('role', 'img'); sunDisc.setAttribute('aria-label', 'Sun');
|
|
24
|
+
moonDisc.setAttribute('role', 'img'); moonDisc.setAttribute('aria-label', 'Moon');
|
|
25
|
+
const container = L.DomUtil.create('div', 'sunlight-control');
|
|
26
|
+
container.style.cssText = 'color:#222;width:min(200px,calc(100vw - 60px));font:12px/1.4 sans-serif;';
|
|
27
|
+
const date = document.createElement('input');
|
|
28
|
+
date.type = 'date';
|
|
29
|
+
date.style.cssText = 'width:100%;box-sizing:border-box;';
|
|
30
|
+
date.setAttribute('aria-label', 'Solar date (UTC)');
|
|
31
|
+
const slider = document.createElement('input');
|
|
32
|
+
slider.type = 'range';
|
|
33
|
+
slider.style.cssText = 'width:100%;box-sizing:border-box;margin:10px 0 4px;cursor:pointer;';
|
|
34
|
+
slider.min = '0'; slider.max = '1439'; slider.step = '1';
|
|
35
|
+
slider.setAttribute('aria-label', 'Time of day (UTC)');
|
|
36
|
+
const output = document.createElement('output');
|
|
37
|
+
output.style.cssText = 'font-weight:bold;font-variant-numeric:tabular-nums;';
|
|
38
|
+
output.setAttribute('aria-live', 'off');
|
|
39
|
+
const now = document.createElement('button');
|
|
40
|
+
now.type = 'button'; now.textContent = 'Now';
|
|
41
|
+
const timeRow = document.createElement('div');
|
|
42
|
+
timeRow.className = 'sunlight-time';
|
|
43
|
+
timeRow.style.cssText = 'display:flex;justify-content:space-between;align-items:center;';
|
|
44
|
+
timeRow.append(output, now);
|
|
45
|
+
const status = document.createElement('div');
|
|
46
|
+
status.className = 'sunlight-status';
|
|
47
|
+
status.style.marginTop = '5px';
|
|
48
|
+
status.setAttribute('role', 'status');
|
|
49
|
+
const note = document.createElement('small');
|
|
50
|
+
note.style.color = '#555';
|
|
51
|
+
note.textContent = 'Indicative · loaded geometry only. Streetlight illumination is estimated, not measured lux.';
|
|
52
|
+
container.append(date, slider, timeRow, status, note);
|
|
53
|
+
const state = { control, map, originalSky, sunDisc, moonDisc, date, slider, output, status };
|
|
54
|
+
state.update = updateSun.bind(null, state);
|
|
55
|
+
state.updateSky = updateSky.bind(null, state);
|
|
56
|
+
now.onclick = useLiveTime.bind(null, state);
|
|
57
|
+
date.onchange = slider.oninput = useSelectedTime.bind(null, state);
|
|
58
|
+
L.DomEvent.disableClickPropagation(container);
|
|
59
|
+
L.DomEvent.disableScrollPropagation(container);
|
|
60
|
+
state.update();
|
|
61
|
+
state.timer = setInterval(tickSun, 60000, state);
|
|
62
|
+
map.on('moveend', state.update);
|
|
63
|
+
map.on('move rotate pitch resize', state.updateSky);
|
|
64
|
+
control.onRemove = removeSun.bind(null, state);
|
|
65
|
+
return container;
|
|
66
|
+
}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
/** Perspective projection of a celestial direction; null when behind the camera. */
|
|
2
|
+
|
|
3
|
+
export function projectCelestialBody(dir, size, pitch, bearing) {
|
|
4
|
+
const [x, y, z] = dir;
|
|
5
|
+
const forward = -x * Math.sin(bearing) * Math.sin(pitch) - y * Math.cos(pitch) - z * Math.cos(bearing) * Math.sin(pitch);
|
|
6
|
+
if (forward > 0) {
|
|
7
|
+
return {
|
|
8
|
+
left: size.x / 2 + size.y * 1.5 * (x * Math.cos(bearing) - z * Math.sin(bearing)) / forward,
|
|
9
|
+
top: size.y / 2 - size.y * 1.5 * (-x * Math.sin(bearing) * Math.cos(pitch) + y * Math.sin(pitch) - z * Math.cos(bearing) * Math.cos(pitch)) / forward
|
|
10
|
+
};
|
|
11
|
+
}
|
|
12
|
+
return null;
|
|
13
|
+
}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { render } from './render.js';
|
|
2
|
+
import { updateSky } from './updateSky.js';
|
|
3
|
+
|
|
4
|
+
export function removeSun(state) {
|
|
5
|
+
const { map, timer, sunDisc, moonDisc } = state;
|
|
6
|
+
clearInterval(timer);
|
|
7
|
+
delete map._timeControl;
|
|
8
|
+
map.fire('simulationtimechange', { time: null, live: false });
|
|
9
|
+
map.off('moveend', state.update);
|
|
10
|
+
map.off('move rotate pitch resize', state.updateSky);
|
|
11
|
+
delete map._sunlight;
|
|
12
|
+
updateSky(state);
|
|
13
|
+
sunDisc.remove(); moonDisc.remove();
|
|
14
|
+
render(map);
|
|
15
|
+
}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { horizontalPosition } from "./horizontalPosition.js";
|
|
2
|
+
|
|
3
|
+
// Solar centre, without atmospheric refraction.
|
|
4
|
+
|
|
5
|
+
export function solarPosition(date, lat, lng) {
|
|
6
|
+
const time = new Date(date).getTime();
|
|
7
|
+
if (!Number.isFinite(time) || !Number.isFinite(lat) || Math.abs(lat) > 90 ||
|
|
8
|
+
!Number.isFinite(lng) || Math.abs(lng) > 180) throw new Error('Invalid solar date or location');
|
|
9
|
+
const rad = Math.PI / 180, d = time / 86400000 - 10957.5;
|
|
10
|
+
const mean = (357.5291 + 0.98560028 * d) * rad;
|
|
11
|
+
const longitude = mean + (1.9148 * Math.sin(mean) + 0.02 * Math.sin(2 * mean) +
|
|
12
|
+
0.0003 * Math.sin(3 * mean) + 102.9372 + 180) * rad;
|
|
13
|
+
const obliquity = 23.4397 * rad;
|
|
14
|
+
const declination = Math.asin(Math.sin(longitude) * Math.sin(obliquity));
|
|
15
|
+
const ascension = Math.atan2(Math.sin(longitude) * Math.cos(obliquity), Math.cos(longitude));
|
|
16
|
+
return horizontalPosition(d, lat, lng, ascension, declination);
|
|
17
|
+
}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
export function styleTimeControl(container, nested) {
|
|
2
|
+
container.classList.toggle('leaflet-control', !nested);
|
|
3
|
+
container.classList.toggle('leaflet-bar', !nested);
|
|
4
|
+
Object.assign(container.style, nested
|
|
5
|
+
? { background: '', padding: '2px 0 6px 20px', margin: '0' }
|
|
6
|
+
: { background: '#fff', padding: '8px', margin: '' });
|
|
7
|
+
}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { projectCelestialBody } from './projectCelestialBody.js';
|
|
2
|
+
|
|
3
|
+
export function updateSky({ map, originalSky, sunDisc, moonDisc }) {
|
|
4
|
+
const sun = map._sunlight, sky = map._pitchSky;
|
|
5
|
+
if (sun) map.getContainer().style.setProperty('--leaflet-sky-background', sun.background);
|
|
6
|
+
else if (originalSky) map.getContainer().style.setProperty('--leaflet-sky-background', originalSky);
|
|
7
|
+
else map.getContainer().style.removeProperty('--leaflet-sky-background');
|
|
8
|
+
const size = map.getSize(), pitch = map.getPitch() * Math.PI / 180, bearing = map.getBearing() * Math.PI / 180;
|
|
9
|
+
let disc, body, point, left, top;
|
|
10
|
+
for ([disc, body] of [[sunDisc, sun], [moonDisc, sun?.moon]]) {
|
|
11
|
+
disc.hidden = true;
|
|
12
|
+
if (!sky || !body || body.altitude <= 0 || !sun) continue;
|
|
13
|
+
if (disc.parentNode !== sky) sky.append(disc);
|
|
14
|
+
point = projectCelestialBody(body.direction, size, pitch, bearing);
|
|
15
|
+
if (!point) continue;
|
|
16
|
+
({ left, top } = point);
|
|
17
|
+
disc.hidden = left < 0 || left > size.x || top < 0 || top > sky.clientHeight || sky.style.display === 'none';
|
|
18
|
+
disc.style.left = `${left}px`; disc.style.top = `${top}px`;
|
|
19
|
+
}
|
|
20
|
+
}
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import { atmosphere } from './atmosphere.js';
|
|
2
|
+
import { moonPosition } from './moonPosition.js';
|
|
3
|
+
import { solarPosition } from './solarPosition.js';
|
|
4
|
+
import { render } from './render.js';
|
|
5
|
+
import { updateSky } from './updateSky.js';
|
|
6
|
+
|
|
7
|
+
export function updateSun(state) {
|
|
8
|
+
const { control, map, date, slider, output, status } = state;
|
|
9
|
+
try {
|
|
10
|
+
if (control.live) control.time = new Date();
|
|
11
|
+
const time = control.time.toISOString();
|
|
12
|
+
date.value = time.slice(0, 10);
|
|
13
|
+
slider.value = String(control.time.getUTCHours() * 60 + control.time.getUTCMinutes());
|
|
14
|
+
output.textContent = `${time.slice(11, 16)} UTC${control.live ? ' · now' : ''}`;
|
|
15
|
+
const center = map.getCenter();
|
|
16
|
+
const sun = map._sunlight = solarPosition(control.time, center.lat, center.lng);
|
|
17
|
+
Object.assign(sun, atmosphere(sun.altitude));
|
|
18
|
+
sun.moon = moonPosition(control.time, center.lat, center.lng);
|
|
19
|
+
status.textContent = sun.altitude <= 0
|
|
20
|
+
? 'Night · no direct sunlight'
|
|
21
|
+
: sun.altitude < 3
|
|
22
|
+
? 'Low sun · shadows paused'
|
|
23
|
+
: `Sun altitude ${sun.altitude.toFixed(1)}°`;
|
|
24
|
+
map.fire('simulationtimechange', { time: new Date(control.time), live: control.live });
|
|
25
|
+
updateSky(state);
|
|
26
|
+
render(map);
|
|
27
|
+
} catch (error) {
|
|
28
|
+
delete map._sunlight;
|
|
29
|
+
updateSky(state);
|
|
30
|
+
render(map);
|
|
31
|
+
status.textContent = `Error: ${error.message}`;
|
|
32
|
+
console.error('Solar simulation', error);
|
|
33
|
+
}
|
|
34
|
+
}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { render } from './render.js';
|
|
2
|
+
import { updateSky } from './updateSky.js';
|
|
3
|
+
import { updateSun } from './updateSun.js';
|
|
4
|
+
|
|
5
|
+
export function useSelectedTime(state) {
|
|
6
|
+
const { control, map, date, slider, status } = state;
|
|
7
|
+
control.live = false;
|
|
8
|
+
if (!date.value || !date.validity.valid) {
|
|
9
|
+
control.time = new Date(NaN);
|
|
10
|
+
map.fire('simulationtimechange', { time: null, live: false });
|
|
11
|
+
delete map._sunlight;
|
|
12
|
+
updateSky(state);
|
|
13
|
+
render(map);
|
|
14
|
+
status.textContent = 'Error: choose a valid solar date';
|
|
15
|
+
return;
|
|
16
|
+
}
|
|
17
|
+
control.time = new Date(`${date.value}T00:00:00Z`);
|
|
18
|
+
control.time.setUTCMinutes(Number(slider.value));
|
|
19
|
+
updateSun(state);
|
|
20
|
+
}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { bridgeElevation } from '../geometry/bridgeElevation.js';
|
|
2
|
+
import { terrainElevation } from './terrainElevation.js';
|
|
3
|
+
|
|
4
|
+
/** @param {L.LatLng|L.Point} location LatLng, or a pixel point at the terrain zoom. */
|
|
5
|
+
|
|
6
|
+
export function getElevation(backend, location) {
|
|
7
|
+
if (!backend._map || !backend._terrainReady) return null;
|
|
8
|
+
const point = location instanceof L.Point ? location : backend._map.project(location, backend._terrainZoom);
|
|
9
|
+
return bridgeElevation(point, backend._bridges) ?? terrainElevation(point, backend._terrainTiles);
|
|
10
|
+
}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { onTerrainRemove } from './onTerrainRemove.js';
|
|
2
|
+
import { onTerrainAdd } from './onTerrainAdd.js';
|
|
3
|
+
import { init3D } from '../scene/init3D.js';
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* Renders IGN Float32 DEM tiles and PMTiles raster basemaps in the shared WebGPU scene.
|
|
7
|
+
* Source options: `url` (single-zoom Float32 PMTiles DEM); `bridges` (optional GeoJSON deck polygons with Z, see _addBridges).
|
|
8
|
+
*/
|
|
9
|
+
export function initTerrain(layer, options) {
|
|
10
|
+
const terrainSource = options.url;
|
|
11
|
+
const layerOptions = { ...options };
|
|
12
|
+
delete layerOptions.url;
|
|
13
|
+
init3D(layer, layerOptions);
|
|
14
|
+
layer.terrainSource = terrainSource;
|
|
15
|
+
layer._terrainTiles = new Map();
|
|
16
|
+
layer._rasterTiles = new Map();
|
|
17
|
+
layer._terrainReady = false;
|
|
18
|
+
layer.onAdd = onTerrainAdd.bind(null, layer);
|
|
19
|
+
layer.onRemove = onTerrainRemove.bind(null, layer);
|
|
20
|
+
}
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
import { addBridges } from '../geometry/addBridges.js';
|
|
2
|
+
import { conformModelToTerrain } from '../geometry/conformModelToTerrain.js';
|
|
3
|
+
import { getElevation } from './getElevation.js';
|
|
4
|
+
import { setTerrainHeight } from './setTerrainHeight.js';
|
|
5
|
+
import { update } from '../scene/update.js';
|
|
6
|
+
import { compareDistance } from '../utils/compareDistance.js';
|
|
7
|
+
import { loadTerrainTiles } from './loadTerrainTiles.js';
|
|
8
|
+
import { readBridges } from './readBridges.js';
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
export async function loadTerrain(backend) {
|
|
12
|
+
if (backend._terrainLoading || !backend._map) return;
|
|
13
|
+
backend._terrainLoading = true;
|
|
14
|
+
backend._terrainReady = false;
|
|
15
|
+
const controller = backend._terrainController = new AbortController();
|
|
16
|
+
let x, y, i, layer;
|
|
17
|
+
try {
|
|
18
|
+
if (!backend.terrainSource) throw new Error('Terrain layer requires a PMTiles elevation archive');
|
|
19
|
+
const archive = backend._terrainArchive = new L.Layer({ source: { type: 'pmtiles', url: backend.terrainSource } });
|
|
20
|
+
await archive.ready;
|
|
21
|
+
const header = archive.header;
|
|
22
|
+
if (header.tileType !== 0 || header.minZoom !== header.maxZoom) {
|
|
23
|
+
throw new Error('Expected a single-zoom Float32 PMTiles terrain archive');
|
|
24
|
+
}
|
|
25
|
+
backend._terrainZoom = header.maxZoom;
|
|
26
|
+
const map = backend._map;
|
|
27
|
+
const northwest = map.project([header.maxLat, header.minLon], backend._terrainZoom).divideBy(256).floor();
|
|
28
|
+
const southeast = map.project([header.minLat, header.maxLon], backend._terrainZoom).divideBy(256).floor();
|
|
29
|
+
backend._terrainBounds = new L.Bounds(northwest, southeast);
|
|
30
|
+
const tiles = [];
|
|
31
|
+
const center = map.project(map.getCenter(), backend._terrainZoom).divideBy(256);
|
|
32
|
+
for (x = northwest.x; x <= southeast.x; x++) {
|
|
33
|
+
for (y = northwest.y; y <= southeast.y; y++) {
|
|
34
|
+
tiles.push({ z: backend._terrainZoom, x, y, distance: Math.hypot(x + 0.5 - center.x, y + 0.5 - center.y) });
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
tiles.sort(compareDistance);
|
|
38
|
+
const state = { backend, archive, controller, tiles, next: 0 };
|
|
39
|
+
const workers = [];
|
|
40
|
+
for (i = 0; i < Math.min(4, tiles.length); i++) workers.push(loadTerrainTiles(state));
|
|
41
|
+
await Promise.all(workers);
|
|
42
|
+
const bridges = backend.options.bridges && await fetch(backend.options.bridges, { signal: controller.signal })
|
|
43
|
+
.then(readBridges);
|
|
44
|
+
if (controller.signal.aborted || backend._map !== map) return;
|
|
45
|
+
backend._terrainReady = true;
|
|
46
|
+
backend._terrainOriginElevation = getElevation(backend, backend.location) ?? 0;
|
|
47
|
+
for (layer of Object.values(map._layers)) {
|
|
48
|
+
setTerrainHeight(layer);
|
|
49
|
+
conformModelToTerrain(layer, backend);
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
if (bridges) addBridges(backend, bridges);
|
|
53
|
+
map.fire('terrainchange');
|
|
54
|
+
update(backend);
|
|
55
|
+
backend.fire('terrainready');
|
|
56
|
+
return true;
|
|
57
|
+
} catch (error) {
|
|
58
|
+
if (!controller.signal.aborted) backend.fire('error', { error });
|
|
59
|
+
return false;
|
|
60
|
+
} finally {
|
|
61
|
+
backend._terrainLoading = false;
|
|
62
|
+
}
|
|
63
|
+
}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
export async function loadTerrainTiles(state) {
|
|
2
|
+
const { backend, archive, controller, tiles } = state;
|
|
3
|
+
let coords, result;
|
|
4
|
+
while (state.next < tiles.length) {
|
|
5
|
+
controller.signal.throwIfAborted();
|
|
6
|
+
coords = tiles[state.next++];
|
|
7
|
+
result = await archive.getZxy(coords.z, coords.x, coords.y, controller.signal);
|
|
8
|
+
if (!result || result.data.byteLength !== 256 * 256 * 4) {
|
|
9
|
+
throw new Error(`Missing or invalid Float32 terrain tile ${coords.z}/${coords.x}/${coords.y}`);
|
|
10
|
+
}
|
|
11
|
+
backend._terrainTiles.set(`${coords.x}/${coords.y}`, new Float32Array(result.data));
|
|
12
|
+
}
|
|
13
|
+
}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { loadTerrain } from "./loadTerrain.js";
|
|
2
|
+
import { setRasterTerrain } from '../raster/setRasterTerrain.js';
|
|
3
|
+
import { onAdd3DLayer } from '../scene/onAdd3DLayer.js';
|
|
4
|
+
import { loadReadyTerrain } from './loadReadyTerrain.js';
|
|
5
|
+
import { setLayerTerrain } from './setLayerTerrain.js';
|
|
6
|
+
|
|
7
|
+
export function onTerrainAdd(backend, map) {
|
|
8
|
+
if (map._terrain3D && map._terrain3D !== backend) {
|
|
9
|
+
throw new Error('Only one terrain layer can be active per map');
|
|
10
|
+
}
|
|
11
|
+
map._terrain3D = backend;
|
|
12
|
+
onAdd3DLayer(backend, map);
|
|
13
|
+
if (backend.root) backend._terrainPromise = loadTerrain(backend);
|
|
14
|
+
else {
|
|
15
|
+
const pending = Promise.withResolvers();
|
|
16
|
+
backend._terrainPromise = pending.promise;
|
|
17
|
+
backend.once('ready', loadReadyTerrain, { backend, ...pending });
|
|
18
|
+
}
|
|
19
|
+
map.eachLayer(setLayerTerrain, backend);
|
|
20
|
+
map.fire('terrainchange');
|
|
21
|
+
}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { releaseArea } from '../sources/releaseArea.js';
|
|
2
|
+
import { updateArea } from "../sources/updateArea.js";
|
|
3
|
+
|
|
4
|
+
/** GeoJSON source areas: loading, building and releasing. */
|
|
5
|
+
|
|
6
|
+
export function onTerrainChange(layer) {
|
|
7
|
+
if (!layer._map) return;
|
|
8
|
+
let area;
|
|
9
|
+
for (area of layer._areas.values()) {
|
|
10
|
+
releaseArea(layer, area);
|
|
11
|
+
}
|
|
12
|
+
layer._areas.clear();
|
|
13
|
+
updateArea(layer);
|
|
14
|
+
}
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
import { destroyTexture } from '../rendering/destroyTexture.js';
|
|
2
|
+
import { conformModelToTerrain } from '../geometry/conformModelToTerrain.js';
|
|
3
|
+
import { disposeMesh } from '../rendering/disposeMesh.js';
|
|
4
|
+
import { setRasterTerrain } from '../raster/setRasterTerrain.js';
|
|
5
|
+
import { removeRasterTile } from '../raster/removeRasterTile.js';
|
|
6
|
+
import { setTerrainHeight } from './setTerrainHeight.js';
|
|
7
|
+
import { onRemove3DLayer } from '../scene/onRemove3DLayer.js';
|
|
8
|
+
import { clearLayerTerrain } from './clearLayerTerrain.js';
|
|
9
|
+
|
|
10
|
+
export function onTerrainRemove(layer, map) {
|
|
11
|
+
layer._terrainController?.abort();
|
|
12
|
+
layer._terrainLoading = false;
|
|
13
|
+
layer._terrainReady = false;
|
|
14
|
+
map.eachLayer(clearLayerTerrain);
|
|
15
|
+
let tile, l, grid, attribute;
|
|
16
|
+
for (tile of layer._rasterTiles.keys()) removeRasterTile(layer, tile);
|
|
17
|
+
if (map._terrain3D === layer) delete map._terrain3D;
|
|
18
|
+
for (l of Object.values(map._layers)) {
|
|
19
|
+
conformModelToTerrain(l, null);
|
|
20
|
+
setTerrainHeight(l);
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
map.fire('terrainchange');
|
|
24
|
+
layer._terrainTiles.clear();
|
|
25
|
+
layer._terrainOriginElevation = 0;
|
|
26
|
+
layer._terrainPromise = null;
|
|
27
|
+
if (layer._rasterProgram) {
|
|
28
|
+
layer._rasterProgram.pipelineCache.clear();
|
|
29
|
+
}
|
|
30
|
+
layer._rasterProgram = null;
|
|
31
|
+
if (layer._dem) destroyTexture(layer, layer._dem.texture);
|
|
32
|
+
layer._dem = null;
|
|
33
|
+
for (grid of layer._terrainGrids?.values() || []) {
|
|
34
|
+
for (attribute of Object.values(grid)) destroyTexture(layer, attribute.buffer);
|
|
35
|
+
}
|
|
36
|
+
layer._terrainGrids = null;
|
|
37
|
+
layer._bridges = null;
|
|
38
|
+
disposeMesh(layer, layer._bridgeMesh);
|
|
39
|
+
layer._bridgeMesh = null;
|
|
40
|
+
onRemove3DLayer(layer, map);
|
|
41
|
+
}
|