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,48 @@
|
|
|
1
|
+
import { disposeMesh } from '../rendering/disposeMesh.js';
|
|
2
|
+
import { destroyTexture } from '../rendering/destroyTexture.js';
|
|
3
|
+
import { uploadCanvasTexture } from './uploadCanvasTexture.js';
|
|
4
|
+
|
|
5
|
+
export function textureFor(state, key, image) {
|
|
6
|
+
if (!(image instanceof HTMLImageElement) && !(image instanceof HTMLCanvasElement)) {
|
|
7
|
+
throw new Error('WebGPU native raster layers require image or canvas tiles');
|
|
8
|
+
}
|
|
9
|
+
const { backend, textures, meshes } = state;
|
|
10
|
+
let texture = textures.get(key);
|
|
11
|
+
const url = image.currentSrc || image.src;
|
|
12
|
+
if (!texture || texture.image !== image || texture.url !== url) {
|
|
13
|
+
if (texture) {
|
|
14
|
+
const mesh = meshes.get(key);
|
|
15
|
+
if (mesh) disposeMesh(backend, mesh);
|
|
16
|
+
meshes.delete(key);
|
|
17
|
+
destroyTexture(backend, texture.texture);
|
|
18
|
+
textures.delete(key);
|
|
19
|
+
}
|
|
20
|
+
const width = image.naturalWidth || image.width, height = image.naturalHeight || image.height;
|
|
21
|
+
if (!width || !height) return;
|
|
22
|
+
const { device } = backend.renderer;
|
|
23
|
+
texture = {
|
|
24
|
+
device, image, url, format: 'rgba8unorm', uploaded: null,
|
|
25
|
+
texture: device.createTexture({
|
|
26
|
+
size: [width, height], format: 'rgba8unorm',
|
|
27
|
+
usage: GPUTextureUsage.TEXTURE_BINDING | GPUTextureUsage.COPY_DST | GPUTextureUsage.RENDER_ATTACHMENT,
|
|
28
|
+
}),
|
|
29
|
+
sampler: device.createSampler({ minFilter: 'linear', magFilter: 'linear' }),
|
|
30
|
+
};
|
|
31
|
+
textures.set(key, texture);
|
|
32
|
+
if (image instanceof HTMLCanvasElement) {
|
|
33
|
+
texture.pending = true;
|
|
34
|
+
uploadCanvasTexture(state, key, texture, image, device, width, height);
|
|
35
|
+
} else {
|
|
36
|
+
try {
|
|
37
|
+
device.queue.copyExternalImageToTexture({ source: image }, { texture: texture.texture }, [width, height]);
|
|
38
|
+
} catch (error) {
|
|
39
|
+
texture.texture.destroy();
|
|
40
|
+
textures.delete(key);
|
|
41
|
+
throw error;
|
|
42
|
+
}
|
|
43
|
+
texture.uploaded = image;
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
texture.used = true;
|
|
47
|
+
return texture.uploaded === image ? texture : undefined;
|
|
48
|
+
}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { mapCameraState } from '../constants/mapCameraState.js';
|
|
2
|
+
import { displayPoint } from '../camera/displayPoint.js';
|
|
3
|
+
|
|
4
|
+
export function tooltipSetPosition(point) {
|
|
5
|
+
mapCameraState.tooltipPosition.call(this, point);
|
|
6
|
+
const delta = displayPoint(this._map, point).subtract(point);
|
|
7
|
+
L.DomUtil.setPosition(this._container, L.DomUtil.getPosition(this._container).add(delta));
|
|
8
|
+
}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { cancelGridFade } from './cancelGridFade.js';
|
|
2
|
+
import { scheduleGridFade } from './scheduleGridFade.js';
|
|
3
|
+
|
|
4
|
+
export function updateGridOpacity() {
|
|
5
|
+
if (!this._map) return;
|
|
6
|
+
const layer = this, now = Date.now();
|
|
7
|
+
let fading = false, prune = false;
|
|
8
|
+
let tile;
|
|
9
|
+
for (tile of Object.values(this._tiles || {})) {
|
|
10
|
+
if (!tile.current || !tile.loaded) continue;
|
|
11
|
+
tile._gpuOpacity = this._map._fadeAnimated ? Math.min(1, (now - tile.loaded) / 200) : 1;
|
|
12
|
+
if (tile._gpuOpacity < 1) fading = true;
|
|
13
|
+
else if (!tile.active) {
|
|
14
|
+
this._onOpaqueTile(tile);
|
|
15
|
+
tile.active = true;
|
|
16
|
+
prune = true;
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
if (prune && !this._noPrune) this._pruneTiles();
|
|
20
|
+
this._nativeGPU?.refresh?.();
|
|
21
|
+
cancelGridFade(layer);
|
|
22
|
+
if (fading) scheduleGridFade(layer);
|
|
23
|
+
}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { current } from './current.js';
|
|
2
|
+
import { refreshNativeLayer } from './refreshNativeLayer.js';
|
|
3
|
+
|
|
4
|
+
export async function uploadCanvasTexture(state, key, texture, image, device, width, height) {
|
|
5
|
+
let bitmap;
|
|
6
|
+
try {
|
|
7
|
+
bitmap = await createImageBitmap(image);
|
|
8
|
+
if (!current(state) || state.textures.get(key) !== texture) return;
|
|
9
|
+
device.queue.copyExternalImageToTexture({ source: bitmap }, { texture: texture.texture }, [width, height]);
|
|
10
|
+
texture.uploaded = image;
|
|
11
|
+
texture.pending = false;
|
|
12
|
+
refreshNativeLayer(state);
|
|
13
|
+
} catch (error) {
|
|
14
|
+
state.failed = true;
|
|
15
|
+
state.source.fire('error', { error });
|
|
16
|
+
} finally {
|
|
17
|
+
bitmap?.close();
|
|
18
|
+
}
|
|
19
|
+
}
|
|
@@ -0,0 +1,88 @@
|
|
|
1
|
+
import { createMesh } from '../rendering/createMesh.js';
|
|
2
|
+
import { triangulate } from '../triangulation/triangulate.js';
|
|
3
|
+
import { local } from './bridgeLocal.js';
|
|
4
|
+
import { push } from './push.js';
|
|
5
|
+
import { below } from './below.js';
|
|
6
|
+
|
|
7
|
+
/**
|
|
8
|
+
* Bare-earth DEMs drop bridges: `getElevation` returns the deck height inside these polygons (GeoJSON
|
|
9
|
+
* Polygon/MultiPolygon with Z, e.g. IGN BD TOPO), and one mesh draws the 1.2 m thick decks.
|
|
10
|
+
* ponytail: anything under a deck (quays, boats asking `getElevation`) also gets the deck height.
|
|
11
|
+
*/
|
|
12
|
+
|
|
13
|
+
export function addBridges(backend, geojson) {
|
|
14
|
+
const map = backend._map, crs = map.options.crs, zoom = backend._terrainZoom;
|
|
15
|
+
const origin = crs.project(backend.location), metres = Math.cos(backend.location.lat * Math.PI / 180);
|
|
16
|
+
const base = backend.root.position[1], position = [], normal = [], color = [];
|
|
17
|
+
backend._bridges = new Map();
|
|
18
|
+
let geometry, polygons, polygon, rings, ring, path, pixels, points, lng, lat, z, p, coordinate;
|
|
19
|
+
let triangles, paths, start, i, contour, holes, bridgeTriangles, xs, ys, t, triangle, bridge, x, y;
|
|
20
|
+
let key, a, b, c, pa, pb, pc, start2, q, length, n, corner;
|
|
21
|
+
for ({ geometry } of geojson.features) {
|
|
22
|
+
polygons = geometry.type === 'Polygon' ? [geometry.coordinates] : geometry.type === 'MultiPolygon' ? geometry.coordinates : [];
|
|
23
|
+
for (polygon of polygons) {
|
|
24
|
+
rings = [];
|
|
25
|
+
for (ring of polygon) {
|
|
26
|
+
path = ring.slice(0, -1);
|
|
27
|
+
if (path.length >= 3) rings.push(path);
|
|
28
|
+
}
|
|
29
|
+
if (!rings.length) continue;
|
|
30
|
+
pixels = [], points = [];
|
|
31
|
+
for (ring of rings) for ([lng, lat, z] of ring) {
|
|
32
|
+
p = map.project([lat, lng], zoom);
|
|
33
|
+
pixels.push([p.x, p.y, z]);
|
|
34
|
+
}
|
|
35
|
+
for (ring of rings) for (coordinate of ring) points.push(local(coordinate, crs, origin, metres, base));
|
|
36
|
+
triangles = void 0;
|
|
37
|
+
try {
|
|
38
|
+
paths = [];
|
|
39
|
+
start = 0;
|
|
40
|
+
for (ring of rings) {
|
|
41
|
+
path = [];
|
|
42
|
+
for (i = 0; i < ring.length; i++) path.push({ x: pixels[start + i][0], y: pixels[start + i][1] });
|
|
43
|
+
paths.push(path);
|
|
44
|
+
start += ring.length;
|
|
45
|
+
}
|
|
46
|
+
[contour, ...holes] = paths;
|
|
47
|
+
triangles = triangulate(contour, holes);
|
|
48
|
+
} catch { continue; }
|
|
49
|
+
bridgeTriangles = [], xs = [], ys = [];
|
|
50
|
+
for (t of triangles) {
|
|
51
|
+
triangle = [];
|
|
52
|
+
for (i of t) triangle.push(pixels[i]);
|
|
53
|
+
bridgeTriangles.push(triangle);
|
|
54
|
+
}
|
|
55
|
+
for (p of pixels) { xs.push(p[0]); ys.push(p[1]); }
|
|
56
|
+
bridge = {
|
|
57
|
+
triangles: bridgeTriangles,
|
|
58
|
+
min: [Math.min(...xs), Math.min(...ys)],
|
|
59
|
+
max: [Math.max(...xs), Math.max(...ys)],
|
|
60
|
+
};
|
|
61
|
+
for (x = Math.floor(bridge.min[0] / 64); x <= Math.floor(bridge.max[0] / 64); x++) {
|
|
62
|
+
for (y = Math.floor(bridge.min[1] / 64); y <= Math.floor(bridge.max[1] / 64); y++) {
|
|
63
|
+
key = `${x}/${y}`;
|
|
64
|
+
backend._bridges.set(key, [...backend._bridges.get(key) || [], bridge]);
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
for ([a, b, c] of triangles) {
|
|
68
|
+
// Counter-clockwise seen from above, so double-sided shading keeps the top lit.
|
|
69
|
+
[pa, pb, pc] = [points[a], points[b], points[c]];
|
|
70
|
+
if ((pb[2] - pa[2]) * (pc[0] - pa[0]) - (pb[0] - pa[0]) * (pc[2] - pa[2]) < 0) [b, c] = [c, b];
|
|
71
|
+
for (i of [a, b, c]) push(position, normal, color, points[i], [0, 1, 0]);
|
|
72
|
+
for (i of [a, c, b]) push(position, normal, color, below(points[i]), [0, -1, 0]);
|
|
73
|
+
}
|
|
74
|
+
start2 = 0;
|
|
75
|
+
for (ring of rings) {
|
|
76
|
+
for (i = 0; i < ring.length; i++) {
|
|
77
|
+
p = points[start2 + i], q = points[start2 + (i + 1) % ring.length];
|
|
78
|
+
length = Math.hypot(q[0] - p[0], q[2] - p[2]) || 1, n = [(q[2] - p[2]) / length, 0, -(q[0] - p[0]) / length];
|
|
79
|
+
for (corner of [p, q, below(q), p, below(q), below(p)]) push(position, normal, color, corner, n);
|
|
80
|
+
}
|
|
81
|
+
start2 += ring.length;
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
}
|
|
85
|
+
if (position.length) {
|
|
86
|
+
backend._bridgeMesh = createMesh(backend, { position, normal, color });
|
|
87
|
+
}
|
|
88
|
+
}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
/** Height inside a bridge deck, or null outside its triangles. */
|
|
2
|
+
export function bridgeElevation(point, bridges) {
|
|
3
|
+
// Bridges bucketed by 64 DEM pixels.
|
|
4
|
+
let bridge, a, b, c, d, u, v;
|
|
5
|
+
for (bridge of bridges?.get(`${Math.floor(point.x / 64)}/${Math.floor(point.y / 64)}`) || []) {
|
|
6
|
+
if (point.x < bridge.min[0] || point.x > bridge.max[0] || point.y < bridge.min[1] || point.y > bridge.max[1]) {
|
|
7
|
+
continue;
|
|
8
|
+
}
|
|
9
|
+
for ([a, b, c] of bridge.triangles) {
|
|
10
|
+
d = (b[1] - c[1]) * (a[0] - c[0]) + (c[0] - b[0]) * (a[1] - c[1]);
|
|
11
|
+
u = ((b[1] - c[1]) * (point.x - c[0]) + (c[0] - b[0]) * (point.y - c[1])) / d;
|
|
12
|
+
v = ((c[1] - a[1]) * (point.x - c[0]) + (a[0] - c[0]) * (point.y - c[1])) / d;
|
|
13
|
+
if (u >= 0 && v >= 0 && u + v <= 1) {
|
|
14
|
+
return u * a[2] + v * b[2] + (1 - u - v) * c[2];
|
|
15
|
+
}
|
|
16
|
+
}
|
|
17
|
+
}
|
|
18
|
+
return null;
|
|
19
|
+
}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { triangle } from './triangle.js';
|
|
2
|
+
|
|
3
|
+
export function build(parts) {
|
|
4
|
+
const position = [], normal = [], color = [];
|
|
5
|
+
let ring, bottom, top, tint, topRing, low, high, x, z, i, j;
|
|
6
|
+
for ([ring, bottom, top, tint, topRing = ring] of parts) {
|
|
7
|
+
low = [], high = [];
|
|
8
|
+
for ([x, z] of ring) low.push([x, bottom, z]);
|
|
9
|
+
for ([x, z] of topRing) high.push([x, top, z]);
|
|
10
|
+
for (i = 0; i < ring.length; i++) {
|
|
11
|
+
j = (i + 1) % ring.length;
|
|
12
|
+
triangle(position, normal, color, low[i], low[j], high[j], tint); triangle(position, normal, color, low[i], high[j], high[i], tint);
|
|
13
|
+
}
|
|
14
|
+
for (i = 1; i < ring.length - 1; i++) {
|
|
15
|
+
triangle(position, normal, color, high[0], high[i], high[i + 1], tint); triangle(position, normal, color, low[0], low[i + 1], low[i], tint);
|
|
16
|
+
}
|
|
17
|
+
}
|
|
18
|
+
return { position, normal, color };
|
|
19
|
+
}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { samePoint } from './samePoint.js';
|
|
2
|
+
import { clipSegment } from './clipSegment.js';
|
|
3
|
+
|
|
4
|
+
/** Clip a geographic line to [west, south, east, north] without joining disjoint pieces. */
|
|
5
|
+
export function clipLine(line, bounds) {
|
|
6
|
+
const pieces = [];
|
|
7
|
+
let current;
|
|
8
|
+
let i, segment;
|
|
9
|
+
for (i = 1; i < line.length; i++) {
|
|
10
|
+
if (samePoint(line[i - 1], line[i])) continue;
|
|
11
|
+
segment = clipSegment(line[i - 1], line[i], bounds);
|
|
12
|
+
if (!segment) {
|
|
13
|
+
current = null;
|
|
14
|
+
continue;
|
|
15
|
+
}
|
|
16
|
+
if (current && samePoint(current.at(-1), segment[0])) current.push(segment[1]);
|
|
17
|
+
else {
|
|
18
|
+
current = segment;
|
|
19
|
+
pieces.push(current);
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
return pieces;
|
|
23
|
+
}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
export function clipSegment(a, b, bounds) {
|
|
2
|
+
const [west, south, east, north] = bounds;
|
|
3
|
+
const dx = b[0] - a[0], dy = b[1] - a[1];
|
|
4
|
+
const p = [-dx, dx, -dy, dy], q = [a[0] - west, east - a[0], a[1] - south, north - a[1]];
|
|
5
|
+
let start = 0, end = 1;
|
|
6
|
+
let i, t;
|
|
7
|
+
for (i = 0; i < 4; i++) {
|
|
8
|
+
if (p[i] === 0) {
|
|
9
|
+
if (q[i] < 0) return null;
|
|
10
|
+
} else {
|
|
11
|
+
t = q[i] / p[i];
|
|
12
|
+
if (p[i] < 0) start = Math.max(start, t);
|
|
13
|
+
else end = Math.min(end, t);
|
|
14
|
+
if (start > end) return null;
|
|
15
|
+
}
|
|
16
|
+
}
|
|
17
|
+
if (start === end || dx === 0 && dy === 0) return null;
|
|
18
|
+
return [[a[0] + start * dx, a[1] + start * dy], [a[0] + end * dx, a[1] + end * dy]];
|
|
19
|
+
}
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
/** Cache local AABB and center for ray picking and transparent mesh sorting. */
|
|
2
|
+
|
|
3
|
+
export function computeBounds(geometry) {
|
|
4
|
+
const min = [Infinity, Infinity, Infinity], max = [-Infinity, -Infinity, -Infinity], data = geometry.attributes.position.data;
|
|
5
|
+
let i;
|
|
6
|
+
for (i = 0; i < data.length; i++) {
|
|
7
|
+
min[i % 3] = Math.min(min[i % 3], data[i]);
|
|
8
|
+
max[i % 3] = Math.max(max[i % 3], data[i]);
|
|
9
|
+
}
|
|
10
|
+
const instances = geometry.attributes.instanceOffset;
|
|
11
|
+
if (instances) {
|
|
12
|
+
let axis, offset, low, high;
|
|
13
|
+
for (axis = 0; axis < 3; axis++) {
|
|
14
|
+
low = Infinity;
|
|
15
|
+
high = -Infinity;
|
|
16
|
+
for (offset = axis; offset < instances.data.length; offset += instances.size) {
|
|
17
|
+
low = Math.min(low, instances.data[offset]);
|
|
18
|
+
high = Math.max(high, instances.data[offset]);
|
|
19
|
+
}
|
|
20
|
+
min[axis] = Math.fround(min[axis] + low);
|
|
21
|
+
max[axis] = Math.fround(max[axis] + high);
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
const center = [];
|
|
25
|
+
for (i = 0; i < min.length; i++) center.push((min[i] + max[i]) / 2);
|
|
26
|
+
let radius = instances ? Math.hypot(max[0] - min[0], max[1] - min[1], max[2] - min[2]) / 2 : 0;
|
|
27
|
+
for (i = 0; !instances && i < data.length; i += 3) {
|
|
28
|
+
radius = Math.max(radius, Math.hypot(
|
|
29
|
+
data[i] - center[0], data[i + 1] - center[1], data[i + 2] - center[2]
|
|
30
|
+
));
|
|
31
|
+
}
|
|
32
|
+
geometry.bounds = { min, max, center, radius };
|
|
33
|
+
}
|
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
import { computeBounds } from './computeBounds.js';
|
|
2
|
+
import { getElevation } from '../terrain/getElevation.js';
|
|
3
|
+
import { update } from '../scene/update.js';
|
|
4
|
+
import { updateWorldMatrix } from '../scene/updateWorldMatrix.js';
|
|
5
|
+
import { vertexNormals } from './vertexNormals.js';
|
|
6
|
+
import { collectMeshes } from '../collision/collectMeshes.js';
|
|
7
|
+
import { HEIGHT } from '../constants/HEIGHT.js';
|
|
8
|
+
|
|
9
|
+
export function conformModelToTerrain(layer, terrain) {
|
|
10
|
+
if (!layer.model) return;
|
|
11
|
+
const meshes = [];
|
|
12
|
+
collectMeshes(layer.model, meshes);
|
|
13
|
+
let mesh, positions, geometry, position, normals, attribute, normal, world, inverse, i, x, y, z;
|
|
14
|
+
let worldY, weight, worldX, worldZ, point, elevation, offset;
|
|
15
|
+
if (!terrain?._terrainReady || !layer.options.terrainConform) {
|
|
16
|
+
for (mesh of meshes) {
|
|
17
|
+
positions = mesh.geometry._terrainBasePositions;
|
|
18
|
+
if (!positions) continue;
|
|
19
|
+
geometry = mesh.geometry, position = geometry.attributes.position;
|
|
20
|
+
position.data.set(positions);
|
|
21
|
+
mesh.device.queue.writeBuffer(position.buffer, 0, positions);
|
|
22
|
+
normals = geometry._terrainBaseNormals;
|
|
23
|
+
if (normals) {
|
|
24
|
+
geometry.attributes.normal.data.set(normals);
|
|
25
|
+
mesh.device.queue.writeBuffer(geometry.attributes.normal.buffer, 0, normals);
|
|
26
|
+
}
|
|
27
|
+
computeBounds(geometry);
|
|
28
|
+
}
|
|
29
|
+
return;
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
updateWorldMatrix(layer.root);
|
|
33
|
+
const map = layer._map, crs = map.options.crs;
|
|
34
|
+
const origin = crs.project(layer._shared._sceneOrigin);
|
|
35
|
+
const metres = Math.cos(layer._shared._sceneOrigin.lat * Math.PI / 180);
|
|
36
|
+
const pixelScale = crs.scale(terrain._terrainZoom);
|
|
37
|
+
|
|
38
|
+
for (mesh of meshes) {
|
|
39
|
+
geometry = mesh.geometry, attribute = geometry.attributes.position;
|
|
40
|
+
geometry._terrainBasePositions ||= attribute.data.slice();
|
|
41
|
+
normal = geometry.attributes.normal;
|
|
42
|
+
geometry._terrainBaseNormals ||= normal.data.slice();
|
|
43
|
+
attribute.data.set(geometry._terrainBasePositions);
|
|
44
|
+
world = mesh.worldMatrix, inverse = new DOMMatrix(world).inverse().toFloat64Array();
|
|
45
|
+
for (i = 0; i < attribute.data.length; i += 3) {
|
|
46
|
+
x = attribute.data[i], y = attribute.data[i + 1], z = attribute.data[i + 2];
|
|
47
|
+
worldY = world[1] * x + world[5] * y + world[9] * z + world[13];
|
|
48
|
+
weight = Math.max(0, Math.min(1, 1 - (worldY - layer.root.position[1]) / HEIGHT));
|
|
49
|
+
if (!weight) continue;
|
|
50
|
+
worldX = world[0] * x + world[4] * y + world[8] * z + world[12];
|
|
51
|
+
worldZ = world[2] * x + world[6] * y + world[10] * z + world[14];
|
|
52
|
+
point = crs.transformation.transform(new L.Point(
|
|
53
|
+
origin.x + worldX / metres, origin.y - worldZ / metres), pixelScale);
|
|
54
|
+
elevation = getElevation(terrain, point);
|
|
55
|
+
if (!Number.isFinite(elevation)) continue;
|
|
56
|
+
offset = (elevation - worldY) * weight;
|
|
57
|
+
attribute.data[i] += inverse[4] * offset;
|
|
58
|
+
attribute.data[i + 1] += inverse[5] * offset;
|
|
59
|
+
attribute.data[i + 2] += inverse[6] * offset;
|
|
60
|
+
}
|
|
61
|
+
mesh.device.queue.writeBuffer(attribute.buffer, 0, attribute.data);
|
|
62
|
+
normal.data.set(vertexNormals(attribute.data, geometry.attributes.index?.data));
|
|
63
|
+
mesh.device.queue.writeBuffer(normal.buffer, 0, normal.data);
|
|
64
|
+
computeBounds(geometry);
|
|
65
|
+
}
|
|
66
|
+
update(layer);
|
|
67
|
+
}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { triangle } from './nativeTriangle.js';
|
|
2
|
+
import { diskAt } from './diskAt.js';
|
|
3
|
+
|
|
4
|
+
export function disk(point, center, radius, target, radiusY = radius) {
|
|
5
|
+
if (!(radius > 0) || !(radiusY > 0)) return;
|
|
6
|
+
const count = Math.max(12, Math.min(128, Math.ceil(Math.PI * Math.sqrt(radius))));
|
|
7
|
+
let i;
|
|
8
|
+
for (i = 0; i < count; i++) {
|
|
9
|
+
triangle(point, target, center, diskAt(center, radius, radiusY, count, i), diskAt(center, radius, radiusY, count, i + 1));
|
|
10
|
+
}
|
|
11
|
+
}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { parseColor } from "../utils/parseColor.js";
|
|
2
|
+
import { ring } from './lampRing.js';
|
|
3
|
+
|
|
4
|
+
/** Schematic support and lamp head; wall-mounted fixtures do not get an invented pole. */
|
|
5
|
+
|
|
6
|
+
export function lampPostGeometry(point, style, addTriangle) {
|
|
7
|
+
const color = parseColor(0x50565a), radius = style.poleRadius;
|
|
8
|
+
if (!Number.isFinite(radius) || radius <= 0) {
|
|
9
|
+
throw new Error('Invalid lamp pole radius');
|
|
10
|
+
}
|
|
11
|
+
const center = { ...point, uv: [3, 3] };
|
|
12
|
+
let r, low, high, points, i, a, b, angle, nx, nz;
|
|
13
|
+
for ([r, low, high] of [[radius, 0, style.top], [radius * 2.5, style.top - 0.25, style.top + 0.15]]) {
|
|
14
|
+
points = ring(point, r);
|
|
15
|
+
for (i = 0; i < 6; i++) {
|
|
16
|
+
a = points[i], b = points[(i + 1) % 6], angle = (i + 0.5) * Math.PI / 3;
|
|
17
|
+
nx = Math.cos(angle), nz = -Math.sin(angle);
|
|
18
|
+
addTriangle(a, low, b, low, b, high, nx, 0, nz, color);
|
|
19
|
+
addTriangle(a, low, b, high, a, high, nx, 0, nz, color);
|
|
20
|
+
addTriangle(center, high, a, high, b, high, 0, 1, 0, color);
|
|
21
|
+
addTriangle(center, low, b, low, a, low, 0, -1, 0, color);
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
export function ring(point, radius) {
|
|
2
|
+
const points = [];
|
|
3
|
+
let i;
|
|
4
|
+
for (i = 0; i < 6; i++) {
|
|
5
|
+
points.push({
|
|
6
|
+
x: point.x + Math.cos(i * Math.PI / 3) * radius,
|
|
7
|
+
y: point.y + Math.sin(i * Math.PI / 3) * radius, ground: point.ground, uv: [3, 3],
|
|
8
|
+
});
|
|
9
|
+
}
|
|
10
|
+
return points;
|
|
11
|
+
}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { parseColor } from "../utils/parseColor.js";
|
|
2
|
+
import { quad } from './quad.js';
|
|
3
|
+
import { emitter } from './emitter.js';
|
|
4
|
+
|
|
5
|
+
/** Three crossed emitter discs; illumination itself is evaluated on receiving surfaces. */
|
|
6
|
+
|
|
7
|
+
export function lightGeometry(point, style, addTriangle) {
|
|
8
|
+
if (!Number.isFinite(style.lightRadius) || style.lightRadius <= 0) throw new Error('Invalid light radius');
|
|
9
|
+
const color = parseColor(style.color);
|
|
10
|
+
let axis;
|
|
11
|
+
for (axis = 0; axis < 3; axis++) {
|
|
12
|
+
quad(addTriangle, color, emitter(point, -1, -1, axis), emitter(point, 1, -1, axis), emitter(point, 1, 1, axis), emitter(point, -1, 1, axis),
|
|
13
|
+
style.top, axis === 0 ? [0, 1, 0] : axis === 1 ? [0, 0, 1] : [1, 0, 0]);
|
|
14
|
+
}
|
|
15
|
+
}
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
import { triangle } from './nativeTriangle.js';
|
|
2
|
+
import { disk } from './disk.js';
|
|
3
|
+
import { segment } from './segment.js';
|
|
4
|
+
|
|
5
|
+
export function line(context, points, closed) {
|
|
6
|
+
const { options, width, dash, stroke, point } = context;
|
|
7
|
+
if (!options.stroke || width <= 0 || points.length < 2) return;
|
|
8
|
+
const radius = width / 2;
|
|
9
|
+
let distance = Number(options.dashOffset) || 0;
|
|
10
|
+
let period = 0;
|
|
11
|
+
let value, i, a, b, length, previous, previousLength, incoming, outgoing, side, n1, n2, from, to;
|
|
12
|
+
let denominator, miter, offset, phase, index, end, delta;
|
|
13
|
+
for (value of dash) period += value;
|
|
14
|
+
for (i = 0; i < points.length - (closed ? 0 : 1); i++) {
|
|
15
|
+
a = points[i], b = points[(i + 1) % points.length], length = a.distanceTo(b);
|
|
16
|
+
if (!dash.length) {
|
|
17
|
+
segment(context, a, b, !closed && i === 0, !closed && i === points.length - 2);
|
|
18
|
+
if (closed || i > 0) {
|
|
19
|
+
if (options.lineJoin === 'round') disk(point, a, radius, stroke);
|
|
20
|
+
else {
|
|
21
|
+
previous = a.subtract(points[(i + points.length - 1) % points.length]);
|
|
22
|
+
previousLength = Math.hypot(previous.x, previous.y);
|
|
23
|
+
if (previousLength && length) {
|
|
24
|
+
incoming = previous.divideBy(previousLength);
|
|
25
|
+
outgoing = b.subtract(a).divideBy(length);
|
|
26
|
+
side = incoming.x * outgoing.y - incoming.y * outgoing.x > 0 ? -1 : 1;
|
|
27
|
+
n1 = new L.Point(-incoming.y * side, incoming.x * side);
|
|
28
|
+
n2 = new L.Point(-outgoing.y * side, outgoing.x * side);
|
|
29
|
+
from = a.add(n1.multiplyBy(radius)), to = a.add(n2.multiplyBy(radius));
|
|
30
|
+
denominator = 1 + n1.x * n2.x + n1.y * n2.y;
|
|
31
|
+
miter = denominator > 0 ? n1.add(n2).multiplyBy(radius / denominator) : null;
|
|
32
|
+
triangle(point, stroke, from, a, to);
|
|
33
|
+
if (options.lineJoin === 'miter' && miter && Math.hypot(miter.x, miter.y) <= radius * 4) {
|
|
34
|
+
triangle(point, stroke, from, a.add(miter), to);
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
} else {
|
|
40
|
+
offset = 0;
|
|
41
|
+
while (offset < length) {
|
|
42
|
+
phase = ((distance + offset) % period + period) % period, index = 0;
|
|
43
|
+
while (phase >= dash[index]) phase -= dash[index++];
|
|
44
|
+
end = Math.min(length, offset + dash[index] - phase);
|
|
45
|
+
if (index % 2 === 0) {
|
|
46
|
+
delta = b.subtract(a).divideBy(length);
|
|
47
|
+
segment(context, a.add(delta.multiplyBy(offset)), a.add(delta.multiplyBy(end)), true, true);
|
|
48
|
+
}
|
|
49
|
+
offset = end;
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
distance += length;
|
|
53
|
+
}
|
|
54
|
+
}
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
import { triangulate } from '../triangulation/triangulate.js';
|
|
2
|
+
import { disk } from './disk.js';
|
|
3
|
+
import { circleAt } from './circleAt.js';
|
|
4
|
+
import { line } from './line.js';
|
|
5
|
+
import { visit } from './visit.js';
|
|
6
|
+
|
|
7
|
+
/** Leaflet paths become flat triangles; pixel-sized strokes are rebuilt on zoom. */
|
|
8
|
+
export function nativeGeometry(source, map, point) {
|
|
9
|
+
const fill = [], stroke = [], options = source.options;
|
|
10
|
+
const width = Number(options.weight) || 0;
|
|
11
|
+
const values = Array.isArray(options.dashArray) ? options.dashArray :
|
|
12
|
+
String(options.dashArray || '').trim().split(/[ ,]+/);
|
|
13
|
+
const dash = [];
|
|
14
|
+
let value, index, i;
|
|
15
|
+
for (value of values) dash.push(Number(value));
|
|
16
|
+
let allZero = true;
|
|
17
|
+
for (value of dash) {
|
|
18
|
+
if (!Number.isFinite(value) || value < 0) throw new Error('Invalid Leaflet dashArray');
|
|
19
|
+
if (value !== 0) allZero = false;
|
|
20
|
+
}
|
|
21
|
+
if (allZero) dash.length = 0;
|
|
22
|
+
if (dash.length % 2) dash.push(...dash);
|
|
23
|
+
const context = { fill, stroke, options, width, dash, point, map };
|
|
24
|
+
if (source instanceof L.CircleMarker) {
|
|
25
|
+
const center = map.project(source.getLatLng());
|
|
26
|
+
let radius = source.getRadius(), radiusY = radius;
|
|
27
|
+
if (source instanceof L.Circle) {
|
|
28
|
+
source._project();
|
|
29
|
+
const projected = source._point.add(map.getPixelOrigin());
|
|
30
|
+
center.x = projected.x;
|
|
31
|
+
center.y = projected.y;
|
|
32
|
+
radius = source._radius;
|
|
33
|
+
radiusY = source._radiusY || radius;
|
|
34
|
+
}
|
|
35
|
+
if (options.fill) disk(point, center, radius, fill, radiusY);
|
|
36
|
+
const count = Math.max(12, Math.min(128, Math.ceil(Math.PI * Math.sqrt(Math.max(radius, radiusY)))));
|
|
37
|
+
if (dash.length) {
|
|
38
|
+
const points = [];
|
|
39
|
+
for (index = 0; index < count; index++) points.push(circleAt(center, radius, radiusY, count, index));
|
|
40
|
+
line(context, points, true);
|
|
41
|
+
}
|
|
42
|
+
else if (options.stroke && width > 0) {
|
|
43
|
+
for (i = 0; i < count; i++) {
|
|
44
|
+
triangle(point, stroke, circleAt(center, radius, radiusY, count, i, width / 2),
|
|
45
|
+
circleAt(center, radius, radiusY, count, i, -width / 2), circleAt(center, radius, radiusY, count, i + 1, width / 2));
|
|
46
|
+
triangle(point, stroke, circleAt(center, radius, radiusY, count, i + 1, width / 2),
|
|
47
|
+
circleAt(center, radius, radiusY, count, i, -width / 2), circleAt(center, radius, radiusY, count, i + 1, -width / 2));
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
} else {
|
|
51
|
+
const closed = source instanceof L.Polygon;
|
|
52
|
+
visit(context, source.getLatLngs(), closed);
|
|
53
|
+
}
|
|
54
|
+
return { fill, stroke };
|
|
55
|
+
}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { triangle } from './nativeTriangle.js';
|
|
2
|
+
import { line } from './line.js';
|
|
3
|
+
import { triangulate } from '../triangulation/triangulate.js';
|
|
4
|
+
|
|
5
|
+
export function polygon(context, rings, closed) {
|
|
6
|
+
const { options, fill, point, map } = context, projected = [];
|
|
7
|
+
let ring, path, latlng, indices;
|
|
8
|
+
for (ring of rings) {
|
|
9
|
+
path = [];
|
|
10
|
+
for (latlng of ring) path.push(map.project(latlng));
|
|
11
|
+
projected.push(path);
|
|
12
|
+
}
|
|
13
|
+
if (closed && options.fill && projected[0]?.length >= 3) {
|
|
14
|
+
const valid = [];
|
|
15
|
+
for (ring of projected) if (ring.length >= 3) valid.push(ring);
|
|
16
|
+
const vertices = valid.flat();
|
|
17
|
+
for (indices of triangulate(valid[0], valid.slice(1))) {
|
|
18
|
+
triangle(point, fill, vertices[indices[0]], vertices[indices[1]], vertices[indices[2]]);
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
for (ring of projected) line(context, ring, closed);
|
|
22
|
+
}
|