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 @@
|
|
|
1
|
+
export const onZoomAnimState = {};
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
// Built-in vehicles for the 'traffic' type. Models are [ring of [x, z], bottom, top, rgb, topRing?] convex prisms in metres;
|
|
2
|
+
// forward is -z, right is +x. `topRing` (same length as `ring`) tapers the prism; rgb components above 1 are self-lit lamps.
|
|
3
|
+
export const paints = [
|
|
4
|
+
[0.86, 0.86, 0.88],
|
|
5
|
+
[0.1, 0.1, 0.12],
|
|
6
|
+
[0.5, 0.53, 0.57],
|
|
7
|
+
[0.65, 0.1, 0.08],
|
|
8
|
+
[0.12, 0.25, 0.55],
|
|
9
|
+
[0.85, 0.7, 0.15]
|
|
10
|
+
];
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { box } from "../geometry/box.js";
|
|
2
|
+
import { trousers } from './trousers.js';
|
|
3
|
+
import { shirt } from './shirt.js';
|
|
4
|
+
import { skin } from './skin.js';
|
|
5
|
+
import { dark } from './dark.js';
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
export const parts = {
|
|
9
|
+
body: [
|
|
10
|
+
[box(-0.17, 0.17, -0.1, 0.1), 0.82, 0.95, trousers],
|
|
11
|
+
[box(-0.19, 0.19, -0.11, 0.11), 0.95, 1.44, shirt],
|
|
12
|
+
[box(-0.05, 0.05, -0.05, 0.05), 1.44, 1.5, skin],
|
|
13
|
+
[box(-0.1, 0.1, -0.11, 0.1), 1.5, 1.72, skin],
|
|
14
|
+
[box(-0.105, 0.105, -0.06, 0.115), 1.58, 1.77, dark],
|
|
15
|
+
[box(-0.105, 0.105, -0.115, -0.06), 1.7, 1.77, dark],
|
|
16
|
+
],
|
|
17
|
+
leg: [[box(-0.07, 0.07, -0.07, 0.07), -0.82, 0, trousers], [box(-0.07, 0.07, -0.17, 0.07), -0.9, -0.82, dark]],
|
|
18
|
+
arm: [[box(-0.05, 0.05, -0.05, 0.05), -0.55, 0, shirt], [box(-0.045, 0.045, -0.045, 0.045), -0.66, -0.55, skin]],
|
|
19
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export const pendingUpdates = new Set();
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export const pumpState = {};
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
export const ringDirections = [
|
|
2
|
+
{ x: Math.cos(0 * Math.PI / 4), y: Math.sin(0 * Math.PI / 4), nx: Math.cos((0 + 0.5) * Math.PI / 4), nz: -Math.sin((0 + 0.5) * Math.PI / 4) },
|
|
3
|
+
{ x: Math.cos(1 * Math.PI / 4), y: Math.sin(1 * Math.PI / 4), nx: Math.cos((1 + 0.5) * Math.PI / 4), nz: -Math.sin((1 + 0.5) * Math.PI / 4) },
|
|
4
|
+
{ x: Math.cos(2 * Math.PI / 4), y: Math.sin(2 * Math.PI / 4), nx: Math.cos((2 + 0.5) * Math.PI / 4), nz: -Math.sin((2 + 0.5) * Math.PI / 4) },
|
|
5
|
+
{ x: Math.cos(3 * Math.PI / 4), y: Math.sin(3 * Math.PI / 4), nx: Math.cos((3 + 0.5) * Math.PI / 4), nz: -Math.sin((3 + 0.5) * Math.PI / 4) },
|
|
6
|
+
{ x: Math.cos(4 * Math.PI / 4), y: Math.sin(4 * Math.PI / 4), nx: Math.cos((4 + 0.5) * Math.PI / 4), nz: -Math.sin((4 + 0.5) * Math.PI / 4) },
|
|
7
|
+
{ x: Math.cos(5 * Math.PI / 4), y: Math.sin(5 * Math.PI / 4), nx: Math.cos((5 + 0.5) * Math.PI / 4), nz: -Math.sin((5 + 0.5) * Math.PI / 4) },
|
|
8
|
+
{ x: Math.cos(6 * Math.PI / 4), y: Math.sin(6 * Math.PI / 4), nx: Math.cos((6 + 0.5) * Math.PI / 4), nz: -Math.sin((6 + 0.5) * Math.PI / 4) },
|
|
9
|
+
{ x: Math.cos(7 * Math.PI / 4), y: Math.sin(7 * Math.PI / 4), nx: Math.cos((7 + 0.5) * Math.PI / 4), nz: -Math.sin((7 + 0.5) * Math.PI / 4) },
|
|
10
|
+
];
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export const roundProfile = [[0, 0], [0.35, 0.8], [0.6, 1], [0.85, 0.7], [1, 0]];
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export const shirt = [0.75, 0.2, 0.15];
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export const taillight = [1.7, 0.06, 0.05];
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
// One workgroup per vehicle shares its lane lookup and pose across all model vertices.
|
|
2
|
+
export const trafficShader = /* wgsl */ `
|
|
3
|
+
struct Params { seconds: f32, side: f32, vertices: u32, total: u32 }
|
|
4
|
+
struct Vehicle { start: u32, count: u32, base: f32, speed: f32 }
|
|
5
|
+
@group(0) @binding(0) var<uniform> params: Params;
|
|
6
|
+
@group(0) @binding(1) var<storage, read> model: array<f32>;
|
|
7
|
+
@group(0) @binding(2) var<storage, read> points: array<vec4f>;
|
|
8
|
+
@group(0) @binding(3) var<storage, read> vehicles: array<Vehicle>;
|
|
9
|
+
@group(0) @binding(4) var<storage, read_write> position: array<f32>;
|
|
10
|
+
@group(0) @binding(5) var<storage, read_write> normal: array<f32>;
|
|
11
|
+
var<workgroup> center: vec3f;
|
|
12
|
+
var<workgroup> heading: vec2f;
|
|
13
|
+
@compute @workgroup_size(64)
|
|
14
|
+
fn main(@builtin(workgroup_id) group: vec3u, @builtin(local_invocation_index) thread: u32) {
|
|
15
|
+
let vehicleIndex = group.x;
|
|
16
|
+
if (thread == 0u) {
|
|
17
|
+
let vehicle = vehicles[vehicleIndex];
|
|
18
|
+
let last = vehicle.start + vehicle.count - 1u;
|
|
19
|
+
let length = points[last].w;
|
|
20
|
+
var s = vehicle.base + params.seconds * vehicle.speed;
|
|
21
|
+
s -= length * floor(s / length);
|
|
22
|
+
var i = vehicle.start + 1u;
|
|
23
|
+
var end = last;
|
|
24
|
+
while (i < end) {
|
|
25
|
+
let middle = i + (end - i) / 2u;
|
|
26
|
+
if (points[middle].w < s) { i = middle + 1u; }
|
|
27
|
+
else { end = middle; }
|
|
28
|
+
}
|
|
29
|
+
let a = points[i - 1u];
|
|
30
|
+
let b = points[i];
|
|
31
|
+
let d = select(b.w - a.w, 1.0, b.w == a.w);
|
|
32
|
+
let t = (s - a.w) / d;
|
|
33
|
+
heading = (b.xy - a.xy) / d;
|
|
34
|
+
center = vec3f(a.x + (b.x - a.x) * t - heading.y * params.side,
|
|
35
|
+
a.z + (b.z - a.z) * t, a.y + (b.y - a.y) * t + heading.x * params.side);
|
|
36
|
+
}
|
|
37
|
+
workgroupBarrier();
|
|
38
|
+
for (var vertex = thread; vertex < params.vertices; vertex += 64u) {
|
|
39
|
+
let k = vertex * 3u;
|
|
40
|
+
let n = params.vertices * 3u + k;
|
|
41
|
+
let o = (vehicleIndex * params.vertices + vertex) * 3u;
|
|
42
|
+
position[o] = center.x - model[k] * heading.y - model[k + 2u] * heading.x;
|
|
43
|
+
position[o + 1u] = center.y + model[k + 1u];
|
|
44
|
+
position[o + 2u] = center.z + model[k] * heading.x - model[k + 2u] * heading.y;
|
|
45
|
+
normal[o] = -model[n] * heading.y - model[n + 2u] * heading.x;
|
|
46
|
+
normal[o + 1u] = model[n + 1u];
|
|
47
|
+
normal[o + 2u] = model[n] * heading.x - model[n + 2u] * heading.y;
|
|
48
|
+
}
|
|
49
|
+
}`;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export const trousers = [0.16, 0.2, 0.32];
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export const tyre = [0.05, 0.05, 0.05];
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export const underEntryState = {};
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import { carModel } from '../vehicles/carModel.js';
|
|
2
|
+
import { boatModel } from '../vehicles/boatModel.js';
|
|
3
|
+
import { busModel } from '../vehicles/busModel.js';
|
|
4
|
+
import { tramModel } from '../vehicles/tramModel.js';
|
|
5
|
+
import { metroModel } from '../vehicles/metroModel.js';
|
|
6
|
+
import { bicycleModel } from '../vehicles/bicycleModel.js';
|
|
7
|
+
import { pedestrianModel } from '../vehicles/pedestrianModel.js';
|
|
8
|
+
|
|
9
|
+
/**
|
|
10
|
+
* `side`: default offset (metres) to the right of the lane centreline. `model(i)` gives the prisms of the i-th vehicle.
|
|
11
|
+
* `lights`: night point lights in model space (see the night lighting grid), e.g. the pool cast by the headlights.
|
|
12
|
+
*/
|
|
13
|
+
export const vehicles = {
|
|
14
|
+
bicycle: { side: 0.4, model: bicycleModel },
|
|
15
|
+
pedestrian: { side: 0.3, model: pedestrianModel },
|
|
16
|
+
bus: { side: 1.5, model: busModel },
|
|
17
|
+
tram: { side: 0, model: tramModel },
|
|
18
|
+
metro: { side: 0, model: metroModel },
|
|
19
|
+
car: {
|
|
20
|
+
side: 1.8,
|
|
21
|
+
model: carModel,
|
|
22
|
+
lights: [{
|
|
23
|
+
position: [0, 1.2, -6],
|
|
24
|
+
radius: 10,
|
|
25
|
+
color: [1, 0.94, 0.82],
|
|
26
|
+
flux: 800
|
|
27
|
+
}]
|
|
28
|
+
},
|
|
29
|
+
// Panoramic river cruiser, about 60 × 11 m: glass saloon, open upper deck with benches, wheelhouse forward.
|
|
30
|
+
boat: {
|
|
31
|
+
side: 0,
|
|
32
|
+
model: boatModel,
|
|
33
|
+
lights: [{
|
|
34
|
+
position: [0, 8, 4],
|
|
35
|
+
radius: 30,
|
|
36
|
+
color: [1, 0.8, 0.55],
|
|
37
|
+
flux: 20000
|
|
38
|
+
}]
|
|
39
|
+
},
|
|
40
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export const white = [0.92, 0.93, 0.92];
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { project } from '../camera/project.js';
|
|
2
|
+
|
|
3
|
+
export function adjustCameraDrag() {
|
|
4
|
+
const map = this;
|
|
5
|
+
const draggable = map._cameraDraggable;
|
|
6
|
+
if (!map.getPitch() && !map.getBearing()) return;
|
|
7
|
+
const half = map.getSize().divideBy(2), delta = draggable._newPos.subtract(draggable._startPos);
|
|
8
|
+
const ground = half.subtract(project(map, half.subtract(delta), true));
|
|
9
|
+
draggable._newPos = draggable._startPos.add(ground);
|
|
10
|
+
}
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
import { ShiftRotate } from '../constants/ShiftRotate.js';
|
|
2
|
+
import { PitchDrag } from '../constants/PitchDrag.js';
|
|
3
|
+
import { Compass } from '../constants/Compass.js';
|
|
4
|
+
import { ContainerResize } from '../constants/ContainerResize.js';
|
|
5
|
+
import { TouchMode } from '../constants/TouchMode.js';
|
|
6
|
+
import { cameraControlsState } from '../constants/cameraControlsState.js';
|
|
7
|
+
import { rotateOnAdd } from './rotateOnAdd.js';
|
|
8
|
+
import { rotateOnRemove } from './rotateOnRemove.js';
|
|
9
|
+
import { rotateControl } from './rotateControl.js';
|
|
10
|
+
import { shiftRotateAddHooks } from './shiftRotateAddHooks.js';
|
|
11
|
+
import { shiftRotateRemoveHooks } from './shiftRotateRemoveHooks.js';
|
|
12
|
+
import { pitchDragAddHooks } from './pitchDragAddHooks.js';
|
|
13
|
+
import { pitchDragRemoveHooks } from './pitchDragRemoveHooks.js';
|
|
14
|
+
import { compassAddHooks } from './compassAddHooks.js';
|
|
15
|
+
import { compassRemoveHooks } from './compassRemoveHooks.js';
|
|
16
|
+
import { containerResizeAddHooks } from './containerResizeAddHooks.js';
|
|
17
|
+
import { containerResizeRemoveHooks } from './containerResizeRemoveHooks.js';
|
|
18
|
+
import { startCameraTouch } from './startCameraTouch.js';
|
|
19
|
+
import { moveCameraTouch } from './moveCameraTouch.js';
|
|
20
|
+
import { endCameraTouchEvent } from './endCameraTouchEvent.js';
|
|
21
|
+
import { changeCameraTouch } from './changeCameraTouch.js';
|
|
22
|
+
import { cleanupCameraTouch } from './cleanupCameraTouch.js';
|
|
23
|
+
import { endAllCameraTouches } from './endAllCameraTouches.js';
|
|
24
|
+
|
|
25
|
+
cameraControlsState.cameraDrags = new Set();
|
|
26
|
+
cameraControlsState.dragStates = new WeakMap();
|
|
27
|
+
cameraControlsState.cameraTouchStates = new Set();
|
|
28
|
+
|
|
29
|
+
L.Control.Rotate = L.Control.extend({
|
|
30
|
+
options: { position: 'topleft', closeOnZeroBearing: true, visualizePitch: true },
|
|
31
|
+
onAdd: rotateOnAdd,
|
|
32
|
+
onRemove: rotateOnRemove,
|
|
33
|
+
});
|
|
34
|
+
|
|
35
|
+
if (L.control) L.control.rotate = rotateControl;
|
|
36
|
+
|
|
37
|
+
export function cameraControls(map) {
|
|
38
|
+
map.addHandler('trackContainerMutation', ContainerResize);
|
|
39
|
+
if (!map.options.rotate) return;
|
|
40
|
+
map.addHandler('shiftKeyRotate', ShiftRotate);
|
|
41
|
+
map.addHandler('pitchDrag', PitchDrag);
|
|
42
|
+
map.addHandler('compassBearing', Compass);
|
|
43
|
+
map.addHandler('touchRotate', TouchMode);
|
|
44
|
+
map.addHandler('touchPitch', TouchMode);
|
|
45
|
+
const container = map.getContainer();
|
|
46
|
+
const state = map._cameraTouchState = { map, container, touch: null, nativeZoom: undefined };
|
|
47
|
+
container._cameraTouchState = state;
|
|
48
|
+
cameraControlsState.cameraTouchStates.add(state);
|
|
49
|
+
container.addEventListener('touchstart', startCameraTouch, { capture: true, passive: false });
|
|
50
|
+
container.addEventListener('touchmove', moveCameraTouch, { capture: true, passive: false });
|
|
51
|
+
container.addEventListener('touchend', endCameraTouchEvent, true);
|
|
52
|
+
container.addEventListener('touchcancel', endCameraTouchEvent, true);
|
|
53
|
+
window.addEventListener('blur', endAllCameraTouches);
|
|
54
|
+
map.on('cameratouchchange', changeCameraTouch, map);
|
|
55
|
+
if (map.options.rotateControl) {
|
|
56
|
+
map.rotateControl = new L.Control.Rotate(typeof map.options.rotateControl === 'object' ? map.options.rotateControl : {});
|
|
57
|
+
map.rotateControl.addTo(map);
|
|
58
|
+
}
|
|
59
|
+
map.once('unload', cleanupCameraTouch, map);
|
|
60
|
+
}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { cameraControlsState } from '../constants/cameraControlsState.js';
|
|
2
|
+
|
|
3
|
+
export function cameraDragClick(event) {
|
|
4
|
+
const state = cameraControlsState.dragStates.get(this);
|
|
5
|
+
if (!state.moved) return;
|
|
6
|
+
event.preventDefault();
|
|
7
|
+
event.stopPropagation();
|
|
8
|
+
state.moved = false;
|
|
9
|
+
}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { cameraControlsState } from '../constants/cameraControlsState.js';
|
|
2
|
+
|
|
3
|
+
export function cameraDragContextMenu(event) {
|
|
4
|
+
const state = cameraControlsState.dragStates.get(this);
|
|
5
|
+
if (!state.drag && !state.moved) return;
|
|
6
|
+
event.preventDefault();
|
|
7
|
+
event.stopPropagation();
|
|
8
|
+
}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { cameraControlsState } from '../constants/cameraControlsState.js';
|
|
2
|
+
import { editable } from './editable.js';
|
|
3
|
+
|
|
4
|
+
export function cameraDragDown(event) {
|
|
5
|
+
const state = cameraControlsState.dragStates.get(this);
|
|
6
|
+
if (state.drag || !state.accept(event) || editable(event.target)) return;
|
|
7
|
+
event.preventDefault();
|
|
8
|
+
event.stopPropagation();
|
|
9
|
+
state.moved = false;
|
|
10
|
+
const rect = state.map.getContainer().getBoundingClientRect();
|
|
11
|
+
state.drag = {
|
|
12
|
+
id: event.pointerId, x: event.clientX, y: event.clientY, cursor: state.element.style.cursor,
|
|
13
|
+
cx: rect.left + rect.width / 2, cy: rect.top + rect.height / 2,
|
|
14
|
+
dragging: state.map.dragging?.enabled(),
|
|
15
|
+
};
|
|
16
|
+
state.map.dragging?.disable();
|
|
17
|
+
state.element.focus?.({ preventScroll: true });
|
|
18
|
+
state.element.setPointerCapture(event.pointerId);
|
|
19
|
+
state.element.style.cursor = 'grabbing';
|
|
20
|
+
}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { cameraControlsState } from '../constants/cameraControlsState.js';
|
|
2
|
+
|
|
3
|
+
export function cameraDragMove(event) {
|
|
4
|
+
const state = cameraControlsState.dragStates.get(this);
|
|
5
|
+
if (!state.drag || state.drag.id !== event.pointerId) return;
|
|
6
|
+
const x = event.clientX - state.drag.x, y = event.clientY - state.drag.y;
|
|
7
|
+
if (Math.hypot(x, y) < 3 && !state.moved) return;
|
|
8
|
+
state.map._stopPitchBearingAnimation();
|
|
9
|
+
state.moved = true;
|
|
10
|
+
event.preventDefault();
|
|
11
|
+
let bearing = x * state.sensitivity[0];
|
|
12
|
+
if (state.orbit) {
|
|
13
|
+
if (Math.abs(state.drag.cy - state.drag.y) > 100) {
|
|
14
|
+
const angle = Math.atan2(event.clientY - state.drag.cy, event.clientX - state.drag.cx) -
|
|
15
|
+
Math.atan2(event.clientY - state.drag.cy, state.drag.x - state.drag.cx);
|
|
16
|
+
bearing = Math.atan2(Math.sin(angle), Math.cos(angle)) * 180 / Math.PI;
|
|
17
|
+
} else bearing *= event.clientY < state.drag.cy ? 1 : -1;
|
|
18
|
+
}
|
|
19
|
+
state.map._setPitchAndBearing(state.map.getPitch() - y * state.sensitivity[1],
|
|
20
|
+
state.map.getBearing() + bearing);
|
|
21
|
+
state.drag.x = event.clientX;
|
|
22
|
+
state.drag.y = event.clientY;
|
|
23
|
+
}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { endCameraTouch } from './endCameraTouch.js';
|
|
2
|
+
|
|
3
|
+
export function changeCameraTouch() {
|
|
4
|
+
const state = this._cameraTouchState, { map, container } = state;
|
|
5
|
+
const active = map.touchRotate.enabled() || map.touchPitch.enabled();
|
|
6
|
+
if (active && state.nativeZoom === undefined) {
|
|
7
|
+
state.nativeZoom = map.touchZoom?.enabled();
|
|
8
|
+
map.touchZoom?.disable();
|
|
9
|
+
} else if (!active && state.nativeZoom !== undefined) {
|
|
10
|
+
endCameraTouch(state);
|
|
11
|
+
if (state.nativeZoom && container._leaflet_id) map.touchZoom.enable();
|
|
12
|
+
state.nativeZoom = undefined;
|
|
13
|
+
}
|
|
14
|
+
}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { endCameraTouch } from './endCameraTouch.js';
|
|
2
|
+
import { startCameraTouch } from './startCameraTouch.js';
|
|
3
|
+
import { moveCameraTouch } from './moveCameraTouch.js';
|
|
4
|
+
import { endCameraTouchEvent } from './endCameraTouchEvent.js';
|
|
5
|
+
import { cameraControlsState } from '../constants/cameraControlsState.js';
|
|
6
|
+
import { endAllCameraTouches } from './endAllCameraTouches.js';
|
|
7
|
+
import { changeCameraTouch } from './changeCameraTouch.js';
|
|
8
|
+
|
|
9
|
+
export function cleanupCameraTouch() {
|
|
10
|
+
const state = this._cameraTouchState;
|
|
11
|
+
if (!state) return;
|
|
12
|
+
const { container, map } = state;
|
|
13
|
+
endCameraTouch(state);
|
|
14
|
+
container.removeEventListener('touchstart', startCameraTouch, true);
|
|
15
|
+
container.removeEventListener('touchmove', moveCameraTouch, true);
|
|
16
|
+
container.removeEventListener('touchend', endCameraTouchEvent, true);
|
|
17
|
+
container.removeEventListener('touchcancel', endCameraTouchEvent, true);
|
|
18
|
+
cameraControlsState.cameraTouchStates.delete(state);
|
|
19
|
+
if (!cameraControlsState.cameraTouchStates.size) window.removeEventListener('blur', endAllCameraTouches);
|
|
20
|
+
map.off('cameratouchchange', changeCameraTouch, map);
|
|
21
|
+
map.rotateControl?.remove();
|
|
22
|
+
delete container._cameraTouchState;
|
|
23
|
+
delete map._cameraTouchState;
|
|
24
|
+
}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { compassOrientation } from './compassOrientation.js';
|
|
2
|
+
import { finishCompassPermission } from './finishCompassPermission.js';
|
|
3
|
+
|
|
4
|
+
export function compassAddHooks() {
|
|
5
|
+
this._compassGeneration = (this._generation = (this._generation || 0) + 1);
|
|
6
|
+
this._orientation = { handler: this, handleEvent: compassOrientation };
|
|
7
|
+
const permission = window.DeviceOrientationEvent?.requestPermission;
|
|
8
|
+
let request;
|
|
9
|
+
try {
|
|
10
|
+
request = permission ? permission.call(window.DeviceOrientationEvent) : 'granted';
|
|
11
|
+
} catch (error) {
|
|
12
|
+
request = Promise.reject(error);
|
|
13
|
+
}
|
|
14
|
+
Promise.allSettled([Promise.resolve({ handler: this, generation: this._generation }), request]).then(finishCompassPermission);
|
|
15
|
+
}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
export function compassOrientation(event) {
|
|
2
|
+
const handler = this.handler;
|
|
3
|
+
const bearing = Number.isFinite(event.webkitCompassHeading) ? -event.webkitCompassHeading : event.alpha;
|
|
4
|
+
const orientation = event.absolute ? 0 : (screen.orientation?.angle ?? window.orientation ?? 0);
|
|
5
|
+
if (Number.isFinite(bearing)) handler._map.setBearing(bearing - orientation);
|
|
6
|
+
}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { resizeMap } from './resizeMap.js';
|
|
2
|
+
|
|
3
|
+
export function containerResizeAddHooks() {
|
|
4
|
+
const container = this._map.getContainer();
|
|
5
|
+
container._containerResizeMap = this._map;
|
|
6
|
+
this._observer = new ResizeObserver(resizeMap);
|
|
7
|
+
this._observer.observe(container);
|
|
8
|
+
}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { cameraControlsState } from '../constants/cameraControlsState.js';
|
|
2
|
+
import { cameraDragDown } from './cameraDragDown.js';
|
|
3
|
+
import { cameraDragMove } from './cameraDragMove.js';
|
|
4
|
+
import { cameraDragEnd } from './cameraDragEnd.js';
|
|
5
|
+
import { cameraDragClick } from './cameraDragClick.js';
|
|
6
|
+
import { cameraDragContextMenu } from './cameraDragContextMenu.js';
|
|
7
|
+
import { endAllCameraDrags } from './endAllCameraDrags.js';
|
|
8
|
+
|
|
9
|
+
export function dragCamera(map, element, accept, sensitivity = [0.8, 0.5], orbit = false) {
|
|
10
|
+
const state = { map, element, accept, sensitivity, orbit, drag: null, moved: false };
|
|
11
|
+
cameraControlsState.dragStates.set(element, state);
|
|
12
|
+
cameraControlsState.cameraDrags.add(state);
|
|
13
|
+
element.addEventListener('pointerdown', cameraDragDown, true);
|
|
14
|
+
element.addEventListener('pointermove', cameraDragMove);
|
|
15
|
+
element.addEventListener('pointerup', cameraDragEnd);
|
|
16
|
+
element.addEventListener('pointercancel', cameraDragEnd);
|
|
17
|
+
element.addEventListener('lostpointercapture', cameraDragEnd);
|
|
18
|
+
element.addEventListener('click', cameraDragClick, true);
|
|
19
|
+
element.addEventListener('contextmenu', cameraDragContextMenu);
|
|
20
|
+
window.addEventListener('blur', endAllCameraDrags);
|
|
21
|
+
return state;
|
|
22
|
+
}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { cameraControlsState } from '../constants/cameraControlsState.js';
|
|
2
|
+
import { endCameraTouch } from './endCameraTouch.js';
|
|
3
|
+
|
|
4
|
+
export function endAllCameraTouches() {
|
|
5
|
+
let state;
|
|
6
|
+
for (state of cameraControlsState.cameraTouchStates) endCameraTouch(state);
|
|
7
|
+
}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
export function endCameraTouch(state, event) {
|
|
2
|
+
if (!state.touch) return;
|
|
3
|
+
if (event?.touches?.length >= 2) return;
|
|
4
|
+
const { map, container, touch } = state;
|
|
5
|
+
if (touch.dragging && container._leaflet_id) map.dragging.enable();
|
|
6
|
+
map.options.zoomSnap = touch.snap;
|
|
7
|
+
if (touch.zooming && touch.snap && container._leaflet_id) {
|
|
8
|
+
map.setZoom(Math.round(map.getZoom() / touch.snap) * touch.snap, { animate: false });
|
|
9
|
+
}
|
|
10
|
+
state.touch = null;
|
|
11
|
+
}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
export function finishCameraDrag(state, event) {
|
|
2
|
+
if (!state?.drag) return;
|
|
3
|
+
if (event?.pointerId !== undefined && event.pointerId !== state.drag.id) return;
|
|
4
|
+
const finished = state.drag;
|
|
5
|
+
state.drag = null;
|
|
6
|
+
if (state.element.hasPointerCapture?.(finished.id)) state.element.releasePointerCapture(finished.id);
|
|
7
|
+
if (finished.dragging && state.map.getContainer()._leaflet_id) state.map.dragging.enable();
|
|
8
|
+
state.element.style.cursor = finished.cursor;
|
|
9
|
+
}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
export function finishCompassPermission([handlerResult, permissionResult]) {
|
|
2
|
+
const { handler, generation } = handlerResult.value;
|
|
3
|
+
try {
|
|
4
|
+
if (!handler.enabled() || handler._generation !== generation) return;
|
|
5
|
+
if (!window.DeviceOrientationEvent || permissionResult.status !== 'fulfilled' ||
|
|
6
|
+
permissionResult.value !== 'granted') {
|
|
7
|
+
throw permissionResult.status === 'rejected' ? permissionResult.reason :
|
|
8
|
+
new Error('Device compass permission unavailable or denied');
|
|
9
|
+
}
|
|
10
|
+
window.addEventListener('deviceorientation', handler._orientation);
|
|
11
|
+
window.addEventListener('deviceorientationabsolute', handler._orientation);
|
|
12
|
+
} catch (error) {
|
|
13
|
+
handler.disable();
|
|
14
|
+
handler._map.fire('error', { error });
|
|
15
|
+
}
|
|
16
|
+
}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
export function moveCameraTouch(event) {
|
|
2
|
+
const state = this._cameraTouchState, { map, container, touch } = state;
|
|
3
|
+
if (!touch || event.touches.length !== 2) return;
|
|
4
|
+
const [a, b] = event.touches;
|
|
5
|
+
const angle = Math.atan2(b.clientY - a.clientY, b.clientX - a.clientX);
|
|
6
|
+
const middle = new L.Point((a.clientX + b.clientX) / 2, (a.clientY + b.clientY) / 2)
|
|
7
|
+
.subtract(new L.Point(container.getBoundingClientRect().left, container.getBoundingClientRect().top));
|
|
8
|
+
const delta = Math.atan2(Math.sin(angle - touch.angle), Math.cos(angle - touch.angle)) * 180 / Math.PI;
|
|
9
|
+
map._setPitchAndBearing(map.touchPitch.enabled() ? touch.pitch - (middle.y - touch.middle.y) * 0.25 : touch.pitch,
|
|
10
|
+
map.touchRotate.enabled() ? touch.bearing + delta : touch.bearing);
|
|
11
|
+
const distance = Math.hypot(b.clientX - a.clientX, b.clientY - a.clientY);
|
|
12
|
+
if (distance < 1) return;
|
|
13
|
+
const zoom = touch.zooming ? Math.max(map.getMinZoom(), Math.min(map.getMaxZoom(),
|
|
14
|
+
touch.zoom + Math.log2(distance / touch.distance))) : touch.zoom;
|
|
15
|
+
map.setView(map.getCenter(), zoom, { animate: false });
|
|
16
|
+
if (map.options.touchZoom !== 'center') {
|
|
17
|
+
const projected = map.project(touch.anchor).subtract(map.project(map.containerPointToLatLng(middle)));
|
|
18
|
+
map.setView(map.unproject(map.project(map.getCenter()).add(projected)), map.getZoom(), { animate: false });
|
|
19
|
+
}
|
|
20
|
+
event.preventDefault();
|
|
21
|
+
event.stopImmediatePropagation();
|
|
22
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export function notifyCameraTouchChange() { this._map.fire('cameratouchchange'); }
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
export function refreshRotateControl() {
|
|
2
|
+
const map = this._map, pitch = this.options.visualizePitch ? map.getPitch() : 0;
|
|
3
|
+
this._arrow.style.transform = `scale(${1 / Math.sqrt(Math.cos(pitch * Math.PI / 180))}) rotateX(${pitch}deg) rotate(${map.getBearing()}deg)`;
|
|
4
|
+
this._button.setAttribute('aria-description', `Bearing ${Math.round(map.getBearing())} degrees, pitch ${Math.round(map.getPitch())} degrees. Arrow keys adjust the camera; Home resets it.`);
|
|
5
|
+
this._container.style.display = this.options.closeOnZeroBearing && !map.getBearing() && !pitch &&
|
|
6
|
+
!this._container.contains(document.activeElement) ? 'none' : '';
|
|
7
|
+
}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { finishCameraDrag } from './finishCameraDrag.js';
|
|
2
|
+
import { cameraDragDown } from './cameraDragDown.js';
|
|
3
|
+
import { cameraDragMove } from './cameraDragMove.js';
|
|
4
|
+
import { cameraDragEnd } from './cameraDragEnd.js';
|
|
5
|
+
import { cameraDragClick } from './cameraDragClick.js';
|
|
6
|
+
import { cameraDragContextMenu } from './cameraDragContextMenu.js';
|
|
7
|
+
import { cameraControlsState } from '../constants/cameraControlsState.js';
|
|
8
|
+
import { endAllCameraDrags } from './endAllCameraDrags.js';
|
|
9
|
+
|
|
10
|
+
export function removeCameraDrag(state) {
|
|
11
|
+
finishCameraDrag(state);
|
|
12
|
+
const { element } = state;
|
|
13
|
+
element.removeEventListener('pointerdown', cameraDragDown, true);
|
|
14
|
+
element.removeEventListener('pointermove', cameraDragMove);
|
|
15
|
+
element.removeEventListener('pointerup', cameraDragEnd);
|
|
16
|
+
element.removeEventListener('pointercancel', cameraDragEnd);
|
|
17
|
+
element.removeEventListener('lostpointercapture', cameraDragEnd);
|
|
18
|
+
element.removeEventListener('click', cameraDragClick, true);
|
|
19
|
+
element.removeEventListener('contextmenu', cameraDragContextMenu);
|
|
20
|
+
cameraControlsState.dragStates.delete(element);
|
|
21
|
+
cameraControlsState.cameraDrags.delete(state);
|
|
22
|
+
if (!cameraControlsState.cameraDrags.size) window.removeEventListener('blur', endAllCameraDrags);
|
|
23
|
+
}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
export function rotateButtonClick(event) {
|
|
2
|
+
const control = this._rotateControl, map = control._map;
|
|
3
|
+
event.preventDefault();
|
|
4
|
+
if (control.options.visualizePitch) map.resetNorthPitch();
|
|
5
|
+
else map.resetNorth();
|
|
6
|
+
if (event.detail) map.getContainer().focus({ preventScroll: true });
|
|
7
|
+
}
|