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,53 @@
|
|
|
1
|
+
export function ensureShadowPipeline(device, sun, instanced = false) {
|
|
2
|
+
const key = instanced ? 'instancePipeline' : 'pipeline';
|
|
3
|
+
if (!sun[key]) {
|
|
4
|
+
if (!sun.meshLayout) {
|
|
5
|
+
sun.meshLayout = device.createBindGroupLayout({
|
|
6
|
+
entries: [
|
|
7
|
+
{ binding: 0, visibility: GPUShaderStage.VERTEX | GPUShaderStage.FRAGMENT, buffer: { type: 'uniform', hasDynamicOffset: true } },
|
|
8
|
+
]
|
|
9
|
+
});
|
|
10
|
+
// Do not bind the sampled depth texture while it is a render attachment.
|
|
11
|
+
sun.depthLayout = device.createBindGroupLayout({
|
|
12
|
+
entries: [
|
|
13
|
+
{ binding: 0, visibility: GPUShaderStage.VERTEX, buffer: { type: 'uniform' } },
|
|
14
|
+
]
|
|
15
|
+
});
|
|
16
|
+
sun.depthBindGroup = device.createBindGroup({
|
|
17
|
+
layout: sun.depthLayout, entries: [{ binding: 0, resource: { buffer: sun.buffer } }],
|
|
18
|
+
});
|
|
19
|
+
}
|
|
20
|
+
const shader = device.createShaderModule({
|
|
21
|
+
code: /* wgsl */ `
|
|
22
|
+
struct Mesh { world: mat4x4<f32>, padding: array<vec4<f32>, 4>, highlight: vec4<f32> };
|
|
23
|
+
@group(0) @binding(0) var<uniform> mesh: Mesh;
|
|
24
|
+
@group(1) @binding(0) var<uniform> matrix: mat4x4<f32>;
|
|
25
|
+
@vertex fn main(@location(0) position: vec3<f32>${instanced ? ', @location(4) offset: vec4<f32>' : ''}) -> @builtin(position) vec4<f32> {
|
|
26
|
+
return matrix * mesh.world * vec4<f32>(position${instanced ? ' + offset.xyz' : ''}, 1.0);
|
|
27
|
+
}
|
|
28
|
+
@fragment fn fragmentMain(@builtin(position) position: vec4<f32>) {
|
|
29
|
+
let noise = fract(52.9829189 * fract(dot(floor(position.xy), vec2<f32>(0.06711056, 0.00583715))));
|
|
30
|
+
if (mesh.highlight.w < 1.0 && noise >= mesh.highlight.w) { discard; }
|
|
31
|
+
}
|
|
32
|
+
` });
|
|
33
|
+
const buffers = [
|
|
34
|
+
{ arrayStride: 12, attributes: [{ shaderLocation: 0, offset: 0, format: 'float32x3' }] },
|
|
35
|
+
];
|
|
36
|
+
if (instanced) buffers.push({
|
|
37
|
+
arrayStride: 16, stepMode: 'instance',
|
|
38
|
+
attributes: [{ shaderLocation: 4, offset: 0, format: 'float32x4' }],
|
|
39
|
+
});
|
|
40
|
+
sun[key] = device.createRenderPipeline({
|
|
41
|
+
layout: device.createPipelineLayout({ bindGroupLayouts: [sun.meshLayout, sun.depthLayout] }),
|
|
42
|
+
vertex: {
|
|
43
|
+
module: shader, entryPoint: 'main', buffers
|
|
44
|
+
},
|
|
45
|
+
fragment: { module: shader, entryPoint: 'fragmentMain', targets: [] },
|
|
46
|
+
primitive: { topology: 'triangle-list', cullMode: 'none' },
|
|
47
|
+
depthStencil: {
|
|
48
|
+
format: 'depth32float', depthWriteEnabled: true, depthCompare: 'less',
|
|
49
|
+
depthBias: 2, depthBiasSlopeScale: 2
|
|
50
|
+
},
|
|
51
|
+
});
|
|
52
|
+
}
|
|
53
|
+
}
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
import { shadowCacheMatches } from './shadowCacheMatches.js';
|
|
2
|
+
import { shadowMatrix } from './shadowMatrix.js';
|
|
3
|
+
import { ensureShadowPipeline } from './ensureShadowPipeline.js';
|
|
4
|
+
import { drawShadowMeshes } from './drawShadowMeshes.js';
|
|
5
|
+
import { resizeSunlight } from './resizeSunlight.js';
|
|
6
|
+
|
|
7
|
+
/** One shared directional depth map. Off-screen but loaded geometry can cast shadows. */
|
|
8
|
+
|
|
9
|
+
export function renderSunlight(backend, encoder, meshes, sunlight) {
|
|
10
|
+
const renderer = backend.renderer, device = renderer.device, sun = renderer.sunlight;
|
|
11
|
+
if (!meshes.length || !sunlight || sunlight.altitude < 3) {
|
|
12
|
+
if (!sun.enabled) return;
|
|
13
|
+
const values = new Float32Array(20);
|
|
14
|
+
values.set([1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1]);
|
|
15
|
+
device.queue.writeBuffer(sun.buffer, 0, values);
|
|
16
|
+
sun.enabled = false;
|
|
17
|
+
sun.cache = null;
|
|
18
|
+
return;
|
|
19
|
+
}
|
|
20
|
+
if (shadowCacheMatches(sun, meshes, sunlight)) return;
|
|
21
|
+
const values = new Float32Array(20);
|
|
22
|
+
sun.enabled = true;
|
|
23
|
+
resizeSunlight(backend, Math.min(2048, device.limits.maxTextureDimension2D));
|
|
24
|
+
values.set(shadowMatrix(meshes, sunlight));
|
|
25
|
+
values[16] = 1;
|
|
26
|
+
device.queue.writeBuffer(sun.buffer, 0, values);
|
|
27
|
+
ensureShadowPipeline(device, sun);
|
|
28
|
+
let mesh;
|
|
29
|
+
for (mesh of meshes) {
|
|
30
|
+
if (mesh.geometry.attributes.instanceOffset) {
|
|
31
|
+
ensureShadowPipeline(device, sun, true);
|
|
32
|
+
break;
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
drawShadowMeshes(backend, encoder, meshes);
|
|
36
|
+
const snapshots = new Map();
|
|
37
|
+
let mesh2;
|
|
38
|
+
for (mesh2 of meshes) {
|
|
39
|
+
snapshots.set(mesh2, {
|
|
40
|
+
world: mesh2._worldMatrixVersion, geometry: mesh2.geometry,
|
|
41
|
+
start: mesh2.geometry.drawRange.start, count: mesh2.geometry.drawRange.count,
|
|
42
|
+
appearance: mesh2._appearance ?? 1,
|
|
43
|
+
});
|
|
44
|
+
}
|
|
45
|
+
sun.cache = { direction: [...sunlight.direction], meshes: snapshots };
|
|
46
|
+
}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { bindSunlight } from './bindSunlight.js';
|
|
2
|
+
import { destroyTexture } from '../rendering/destroyTexture.js';
|
|
3
|
+
|
|
4
|
+
|
|
5
|
+
export function resizeSunlight(backend, size) {
|
|
6
|
+
const device = backend.renderer.device, sun = backend.renderer.sunlight;
|
|
7
|
+
if (sun.size === size) return;
|
|
8
|
+
if (sun.texture) destroyTexture(backend, sun.texture);
|
|
9
|
+
sun.size = size;
|
|
10
|
+
sun.texture = device.createTexture({
|
|
11
|
+
size: [size, size], format: 'depth32float',
|
|
12
|
+
usage: GPUTextureUsage.RENDER_ATTACHMENT | GPUTextureUsage.TEXTURE_BINDING | GPUTextureUsage.COPY_SRC,
|
|
13
|
+
});
|
|
14
|
+
bindSunlight(backend);
|
|
15
|
+
}
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import { computeBounds } from '../geometry/computeBounds.js';
|
|
2
|
+
|
|
3
|
+
export function shadowBounds(meshes) {
|
|
4
|
+
const min = [Infinity, Infinity, Infinity], max = [-Infinity, -Infinity, -Infinity];
|
|
5
|
+
let mesh, bounds, matrix, cached, i, x, y, z, w, axis, value;
|
|
6
|
+
for (mesh of meshes) {
|
|
7
|
+
if (!mesh.geometry.bounds || mesh.geometry.attributes.position.needsUpdate) computeBounds(mesh.geometry);
|
|
8
|
+
bounds = mesh.geometry.bounds, matrix = mesh.worldMatrix;
|
|
9
|
+
cached = mesh._shadowBounds;
|
|
10
|
+
if (!cached || cached.version !== mesh._worldMatrixVersion || cached.bounds !== bounds) {
|
|
11
|
+
cached = mesh._shadowBounds = { version: mesh._worldMatrixVersion, bounds,
|
|
12
|
+
min: [Infinity, Infinity, Infinity], max: [-Infinity, -Infinity, -Infinity] };
|
|
13
|
+
for (i = 0; i < 8; i++) {
|
|
14
|
+
x = i & 1 ? bounds.max[0] : bounds.min[0], y = i & 2 ? bounds.max[1] : bounds.min[1];
|
|
15
|
+
z = i & 4 ? bounds.max[2] : bounds.min[2];
|
|
16
|
+
w = matrix[3] * x + matrix[7] * y + matrix[11] * z + matrix[15];
|
|
17
|
+
for (axis = 0; axis < 3; axis++) {
|
|
18
|
+
value = (matrix[axis] * x + matrix[axis + 4] * y + matrix[axis + 8] * z + matrix[axis + 12]) / w;
|
|
19
|
+
cached.min[axis] = Math.min(cached.min[axis], value);
|
|
20
|
+
cached.max[axis] = Math.max(cached.max[axis], value);
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
for (axis = 0; axis < 3; axis++) {
|
|
25
|
+
min[axis] = Math.min(min[axis], cached.min[axis]);
|
|
26
|
+
max[axis] = Math.max(max[axis], cached.max[axis]);
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
// Include ground receivers below/around the loaded buildings and trees.
|
|
30
|
+
min[1] = Math.min(0, min[1]);
|
|
31
|
+
return { min, max };
|
|
32
|
+
}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
export function shadowCacheMatches(sun, meshes, sunlight) {
|
|
2
|
+
const cache = sun.cache;
|
|
3
|
+
let unchanged = sun.enabled && cache?.meshes.size === meshes.length;
|
|
4
|
+
let i, mesh, previous, range, attribute;
|
|
5
|
+
if (unchanged) {
|
|
6
|
+
for (i = 0; i < sunlight.direction.length; i++) {
|
|
7
|
+
if (sunlight.direction[i] !== cache.direction[i]) { unchanged = false; break; }
|
|
8
|
+
}
|
|
9
|
+
}
|
|
10
|
+
if (unchanged) {
|
|
11
|
+
for (mesh of meshes) {
|
|
12
|
+
previous = cache.meshes.get(mesh), range = mesh.geometry.drawRange;
|
|
13
|
+
if (!(previous && previous.world === mesh._worldMatrixVersion && previous.geometry === mesh.geometry &&
|
|
14
|
+
previous.start === range.start && previous.count === range.count &&
|
|
15
|
+
previous.appearance === (mesh._appearance ?? 1))) { unchanged = false; break; }
|
|
16
|
+
for (attribute of Object.values(mesh.geometry.attributes)) {
|
|
17
|
+
if (attribute.needsUpdate) { unchanged = false; break; }
|
|
18
|
+
}
|
|
19
|
+
if (!unchanged) break;
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
return unchanged;
|
|
23
|
+
}
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import { shadowBounds } from './shadowBounds.js';
|
|
2
|
+
import { updateCamera } from '../scene/updateCamera.js';
|
|
3
|
+
|
|
4
|
+
export function shadowMatrix(meshes, sunlight) {
|
|
5
|
+
const { min, max } = shadowBounds(meshes);
|
|
6
|
+
const span = [], center = [], position = [];
|
|
7
|
+
let i, corner, axis, point, coordinates, value;
|
|
8
|
+
for (i = 0; i < 3; i++) {
|
|
9
|
+
span[i] = max[i] - min[i];
|
|
10
|
+
center[i] = (min[i] + max[i]) / 2;
|
|
11
|
+
}
|
|
12
|
+
const radius = Math.max(100, Math.hypot(...span));
|
|
13
|
+
for (i = 0; i < 3; i++) position[i] = center[i] + sunlight.direction[i] * radius * 2;
|
|
14
|
+
const lightCamera = {
|
|
15
|
+
position,
|
|
16
|
+
target: center, up: [0, 0, -1], fov: 45, aspect: 1, near: 1, far: radius * 5,
|
|
17
|
+
viewMatrix: [], projectionMatrix: [], projectionViewMatrix: [],
|
|
18
|
+
};
|
|
19
|
+
updateCamera(lightCamera);
|
|
20
|
+
const view = new DOMMatrix(lightCamera.viewMatrix);
|
|
21
|
+
const low = [Infinity, Infinity, Infinity], high = [-Infinity, -Infinity, -Infinity];
|
|
22
|
+
for (i = 0; i < 8; i++) {
|
|
23
|
+
corner = [];
|
|
24
|
+
for (axis = 0; axis < 3; axis++) corner[axis] = i & (1 << axis) ? max[axis] : min[axis];
|
|
25
|
+
point = new DOMPoint(...corner, 1).matrixTransform(view);
|
|
26
|
+
coordinates = [point.x, point.y, point.z];
|
|
27
|
+
for (axis = 0; axis < 3; axis++) {
|
|
28
|
+
value = coordinates[axis];
|
|
29
|
+
low[axis] = Math.min(low[axis], value - 20);
|
|
30
|
+
high[axis] = Math.max(high[axis], value + 20);
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
for (i = 0; i < 3; i++) span[i] = high[i] - low[i];
|
|
34
|
+
const projection = new DOMMatrix([
|
|
35
|
+
2 / span[0], 0, 0, 0, 0, 2 / span[1], 0, 0, 0, 0, -1 / span[2], 0,
|
|
36
|
+
-(high[0] + low[0]) / span[0], -(high[1] + low[1]) / span[1], high[2] / span[2], 1,
|
|
37
|
+
]);
|
|
38
|
+
return projection.multiply(view).toFloat32Array();
|
|
39
|
+
}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { groundOffset } from './groundOffset.js';
|
|
2
|
+
|
|
3
|
+
export function addTriangle(context, a, ah, b, bh, c, ch, nx, ny, nz, color) {
|
|
4
|
+
const { backend, positions, normals, colors, uvs } = context;
|
|
5
|
+
const ux = b.x - a.x, uy = bh - ah, uz = a.y - b.y;
|
|
6
|
+
const vx = c.x - a.x, vy = ch - ah, vz = a.y - c.y;
|
|
7
|
+
if ((uy * vz - uz * vy) * nx + (uz * vx - ux * vz) * ny + (ux * vy - uy * vx) * nz < 0) {
|
|
8
|
+
const point = b, height = bh;
|
|
9
|
+
b = c; bh = ch; c = point; ch = height;
|
|
10
|
+
}
|
|
11
|
+
positions.push(a.x, ah + groundOffset(a), -a.y,
|
|
12
|
+
b.x, bh + groundOffset(b), -b.y,
|
|
13
|
+
c.x, ch + groundOffset(c), -c.y);
|
|
14
|
+
normals.push(nx, ny, nz, nx, ny, nz, nx, ny, nz);
|
|
15
|
+
colors.push(color.r, color.g, color.b, color.r, color.g, color.b, color.r, color.g, color.b);
|
|
16
|
+
if (backend.options.nightLight) uvs.push(...a.uv, ...b.uv, ...c.uv);
|
|
17
|
+
}
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
import { emptyNode } from '../scene/emptyNode.js';
|
|
2
|
+
import { createProgram } from '../rendering/createProgram.js';
|
|
3
|
+
import { cityMapper } from '../constants/cityMapper.js';
|
|
4
|
+
import { setParent } from '../scene/setParent.js';
|
|
5
|
+
import { update } from '../scene/update.js';
|
|
6
|
+
import { instanceAreaGeometry } from './instanceAreaGeometry.js';
|
|
7
|
+
|
|
8
|
+
export function attachAreaMesh(context) {
|
|
9
|
+
const { backend, area } = context;
|
|
10
|
+
if (!context.positions.length) {
|
|
11
|
+
Object.assign(area, { mesh: null, buildings: 0, skipped: context.skipped, done: true });
|
|
12
|
+
return;
|
|
13
|
+
}
|
|
14
|
+
const device = backend.renderer.device;
|
|
15
|
+
const data = instanceAreaGeometry(context);
|
|
16
|
+
const attributes = {
|
|
17
|
+
position: { size: 3, data: new Float32Array(data.positions) },
|
|
18
|
+
normal: { size: 3, data: new Float32Array(data.normals) },
|
|
19
|
+
color: { size: 3, data: new Float32Array(data.colors) },
|
|
20
|
+
};
|
|
21
|
+
if (data.instanceOffsets) attributes.instanceOffset = { size: 4, data: data.instanceOffsets };
|
|
22
|
+
if (backend.options.nightLight) attributes.uv = { size: 2, data: new Float32Array(context.uvs) };
|
|
23
|
+
let name, attribute;
|
|
24
|
+
for ([name, attribute] of Object.entries(attributes)) {
|
|
25
|
+
attribute.count = attribute.data.length / attribute.size;
|
|
26
|
+
attribute.buffer = device.createBuffer({
|
|
27
|
+
size: Math.max(4, attribute.data.byteLength),
|
|
28
|
+
usage: GPUBufferUsage.VERTEX | GPUBufferUsage.COPY_DST,
|
|
29
|
+
});
|
|
30
|
+
device.queue.writeBuffer(attribute.buffer, 0, attribute.data);
|
|
31
|
+
}
|
|
32
|
+
const meshGeometry = {
|
|
33
|
+
device,
|
|
34
|
+
attributes,
|
|
35
|
+
drawRange: { start: 0, count: attributes.position.count },
|
|
36
|
+
};
|
|
37
|
+
Object.assign(area, {
|
|
38
|
+
mesh: {
|
|
39
|
+
...emptyNode(),
|
|
40
|
+
device,
|
|
41
|
+
geometry: meshGeometry,
|
|
42
|
+
program: createProgram(backend, {
|
|
43
|
+
instanced: Boolean(data.instanceOffsets),
|
|
44
|
+
vertexColors: true, roofTexture: Boolean(backend.options.roofTexture),
|
|
45
|
+
...(backend.options.nightLight ? { nightLight: true, alphaMode: 'BLEND', doubleSided: true } : {}),
|
|
46
|
+
}),
|
|
47
|
+
id: cityMapper.nextId++,
|
|
48
|
+
renderOrder: 0,
|
|
49
|
+
fadeDuration: 250,
|
|
50
|
+
extras: { featureFaces: context.featureFaces, lights: context.lights },
|
|
51
|
+
},
|
|
52
|
+
buildings: context.featureFaces.length,
|
|
53
|
+
skipped: context.skipped,
|
|
54
|
+
done: true,
|
|
55
|
+
});
|
|
56
|
+
setParent(area.mesh, backend.root);
|
|
57
|
+
update(backend);
|
|
58
|
+
}
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
import { buildAreaFeature } from './buildAreaFeature.js';
|
|
2
|
+
import { attachAreaMesh } from './attachAreaMesh.js';
|
|
3
|
+
import { loadSource } from '../archives/loadSource.js';
|
|
4
|
+
import { sourceAreaContext } from './sourceAreaContext.js';
|
|
5
|
+
import { pump } from './pump.js';
|
|
6
|
+
|
|
7
|
+
export async function buildArea(backend, area, map) {
|
|
8
|
+
let feature;
|
|
9
|
+
try {
|
|
10
|
+
await new Promise(requestAnimationFrame);
|
|
11
|
+
await map._terrain3D?._terrainPromise;
|
|
12
|
+
if (area.request.signal.aborted) return;
|
|
13
|
+
const data = await loadSource(backend, area);
|
|
14
|
+
if (area.request.signal.aborted) return;
|
|
15
|
+
if (data?.type !== 'FeatureCollection' || !Array.isArray(data.features)) {
|
|
16
|
+
throw new Error('Invalid GeoJSON response');
|
|
17
|
+
}
|
|
18
|
+
if (backend._geojson && typeof backend.options.style !== 'function') {
|
|
19
|
+
throw new Error('style must be a function');
|
|
20
|
+
}
|
|
21
|
+
const context = sourceAreaContext(backend, area, map);
|
|
22
|
+
let deadline = performance.now() + 4;
|
|
23
|
+
for (feature of data.features) {
|
|
24
|
+
if (area.request.signal.aborted) return;
|
|
25
|
+
if (performance.now() >= deadline) {
|
|
26
|
+
await new Promise(requestAnimationFrame);
|
|
27
|
+
if (area.request.signal.aborted) return;
|
|
28
|
+
deadline = performance.now() + 4;
|
|
29
|
+
}
|
|
30
|
+
buildAreaFeature(context, feature);
|
|
31
|
+
}
|
|
32
|
+
attachAreaMesh(context);
|
|
33
|
+
} catch (error) {
|
|
34
|
+
if (!area.request.signal.aborted) {
|
|
35
|
+
area.error = error.message;
|
|
36
|
+
backend.fire('error', { error });
|
|
37
|
+
}
|
|
38
|
+
} finally {
|
|
39
|
+
backend._inflight--;
|
|
40
|
+
pump(backend, map);
|
|
41
|
+
}
|
|
42
|
+
}
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
import { buildAreaPoint } from './buildAreaPoint.js';
|
|
2
|
+
import { buildAreaPolygon } from './buildAreaPolygon.js';
|
|
3
|
+
import { parseColor } from '../utils/parseColor.js';
|
|
4
|
+
|
|
5
|
+
export function buildAreaFeature(context, feature) {
|
|
6
|
+
const { backend, area, map } = context;
|
|
7
|
+
const coords = area.coords;
|
|
8
|
+
const geometry = feature?.geometry;
|
|
9
|
+
const isTree = geometry?.type === 'Point';
|
|
10
|
+
if (backend.options.nightLight && !isTree) throw new Error('Night lights require Point geometry');
|
|
11
|
+
const polygons = geometry?.type === 'Polygon' ? [geometry.coordinates] :
|
|
12
|
+
geometry?.type === 'MultiPolygon' ? geometry.coordinates : null;
|
|
13
|
+
if (!polygons && !isTree) throw new Error('Unsupported GeoJSON geometry');
|
|
14
|
+
const [lon, lat] = (isTree ? geometry.coordinates : polygons[0]?.[0]?.[0]) ?? [];
|
|
15
|
+
if (!Number.isFinite(lon) || !Number.isFinite(lat)) throw new Error('Invalid GeoJSON coordinates');
|
|
16
|
+
if (coords) {
|
|
17
|
+
const anchor = map.project(new L.LatLng(lat, lon), coords.z);
|
|
18
|
+
if (Math.floor(anchor.x / 256) !== coords.x || Math.floor(anchor.y / 256) !== coords.y) return;
|
|
19
|
+
}
|
|
20
|
+
const style = backend.options.style(feature);
|
|
21
|
+
if (style === null) {
|
|
22
|
+
context.skipped++;
|
|
23
|
+
return;
|
|
24
|
+
}
|
|
25
|
+
if (!style || typeof style !== 'object') throw new Error('style must return an extrusion style or null');
|
|
26
|
+
const { top, bottom = 0, color = 0xd9b38c } = style;
|
|
27
|
+
if (!Number.isFinite(top) || !Number.isFinite(bottom) || bottom < 0 || top <= bottom) {
|
|
28
|
+
throw new Error('Invalid extrusion heights: expected top > bottom >= 0');
|
|
29
|
+
}
|
|
30
|
+
const baseColor = parseColor(color);
|
|
31
|
+
const vertexStart = context.positions.length / 3;
|
|
32
|
+
if (isTree) buildAreaPoint(context, feature, lon, lat, style, baseColor);
|
|
33
|
+
let rings;
|
|
34
|
+
for (rings of polygons || []) buildAreaPolygon(context, rings, top, bottom, baseColor);
|
|
35
|
+
const vertexEnd = context.positions.length / 3;
|
|
36
|
+
context.featureFaces.push({
|
|
37
|
+
id: feature.id ?? feature.properties?.objectid ?? JSON.stringify(geometry),
|
|
38
|
+
properties: feature.properties, baseColor,
|
|
39
|
+
faceStart: vertexStart / 3, faceEnd: vertexEnd / 3, vertexStart, vertexEnd,
|
|
40
|
+
});
|
|
41
|
+
}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import { projectedTree } from './projectedTree.js';
|
|
2
|
+
import { generateTreeGeometry } from './generateTreeGeometry.js';
|
|
3
|
+
import { lampPostGeometry } from '../geometry/lampPostGeometry.js';
|
|
4
|
+
import { lightGeometry } from '../geometry/lightGeometry.js';
|
|
5
|
+
import { treeGeometry } from '../geometry/treeGeometry.js';
|
|
6
|
+
|
|
7
|
+
export function buildAreaPoint(context, feature, lon, lat, style, baseColor) {
|
|
8
|
+
const { backend } = context;
|
|
9
|
+
const { top } = style;
|
|
10
|
+
const projected = projectedTree(context, lon, lat);
|
|
11
|
+
if (backend.options.nightLight) {
|
|
12
|
+
if (!Number.isFinite(style.lightFlux) || style.lightFlux <= 0) throw new Error('Invalid light flux');
|
|
13
|
+
const support = feature.properties?.cod_ouvrag || `${lon},${lat}`;
|
|
14
|
+
if (style.poleRadius > 0 && !context.supports.has(support)) {
|
|
15
|
+
generateTreeGeometry(context, lampPostGeometry, projected, style);
|
|
16
|
+
context.supports.add(support);
|
|
17
|
+
}
|
|
18
|
+
generateTreeGeometry(context, lightGeometry, projected, style);
|
|
19
|
+
context.lights.push({
|
|
20
|
+
position: [projected.x, projected.ground + top, -projected.y],
|
|
21
|
+
radius: Math.hypot(top, style.lightRadius), color: [baseColor.r, baseColor.g, baseColor.b],
|
|
22
|
+
flux: style.lightFlux,
|
|
23
|
+
});
|
|
24
|
+
} else generateTreeGeometry(context, treeGeometry, projected, style);
|
|
25
|
+
}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import { projectRing } from './projectRing.js';
|
|
2
|
+
import { triangulate } from '../triangulation/triangulate.js';
|
|
3
|
+
import { addTriangle } from './addTriangle.js';
|
|
4
|
+
import { isClockWise } from '../triangulation/isClockWise.js';
|
|
5
|
+
|
|
6
|
+
export function buildAreaPolygon(context, rings, top, bottom, baseColor) {
|
|
7
|
+
if (!rings.length) throw new Error('Empty GeoJSON polygon');
|
|
8
|
+
const paths = [];
|
|
9
|
+
let ring, path, point, a, b, c, index, sign, i, length, nx, nz;
|
|
10
|
+
for (ring of rings) paths.push(projectRing(context, ring));
|
|
11
|
+
const points = [];
|
|
12
|
+
for (path of paths) for (point of path) points.push(point);
|
|
13
|
+
for ([a, b, c] of triangulate(paths[0], paths.slice(1))) {
|
|
14
|
+
addTriangle(context, points[a], top, points[b], top, points[c], top, 0, 1, 0, baseColor);
|
|
15
|
+
if (bottom > 0) addTriangle(context, points[a], bottom, points[b], bottom, points[c], bottom, 0, -1, 0, baseColor);
|
|
16
|
+
}
|
|
17
|
+
for (index = 0; index < paths.length; index++) {
|
|
18
|
+
path = paths[index];
|
|
19
|
+
sign = isClockWise(path) === (index === 0) ? -1 : 1;
|
|
20
|
+
for (i = 0; i < path.length; i++) {
|
|
21
|
+
a = path[i], b = path[(i + 1) % path.length];
|
|
22
|
+
length = Math.hypot(b.x - a.x, b.y - a.y);
|
|
23
|
+
if (!length) continue;
|
|
24
|
+
nx = sign * (b.y - a.y) / length, nz = sign * (b.x - a.x) / length;
|
|
25
|
+
addTriangle(context, a, bottom, b, bottom, b, top, nx, 0, nz, baseColor);
|
|
26
|
+
addTriangle(context, a, bottom, b, top, a, top, nx, 0, nz, baseColor);
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { pumpState } from '../constants/pumpState.js';
|
|
2
|
+
import { addGeneratedTriangle } from './addGeneratedTriangle.js';
|
|
3
|
+
|
|
4
|
+
export function generateTreeGeometry(context, generator, point, style) {
|
|
5
|
+
pumpState.triangleContexts.push(context);
|
|
6
|
+
try {
|
|
7
|
+
generator(point, style, addGeneratedTriangle);
|
|
8
|
+
} finally {
|
|
9
|
+
pumpState.triangleContexts.pop();
|
|
10
|
+
}
|
|
11
|
+
}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
/** Compact repeated features only when reconstructed float32 positions compare equal. */
|
|
2
|
+
export function instanceAreaGeometry(context) {
|
|
3
|
+
const { positions, normals, colors, featureFaces } = context;
|
|
4
|
+
if (context.backend.options.nightLight || featureFaces.length < 2) return context;
|
|
5
|
+
const vertices = featureFaces[0].vertexEnd;
|
|
6
|
+
const length = vertices * 3;
|
|
7
|
+
if (!vertices || positions.length !== length * featureFaces.length) return context;
|
|
8
|
+
const origin = [Math.trunc(positions[0]), Math.trunc(positions[1]), Math.trunc(positions[2])];
|
|
9
|
+
const template = new Float32Array(length);
|
|
10
|
+
let i, instance, axis, face, start;
|
|
11
|
+
for (i = 0; i < length; i++) template[i] = positions[i] - origin[i % 3];
|
|
12
|
+
const offsets = new Float32Array(featureFaces.length * 4);
|
|
13
|
+
for (instance = 0; instance < featureFaces.length; instance++) {
|
|
14
|
+
face = featureFaces[instance];
|
|
15
|
+
start = instance * length;
|
|
16
|
+
if (face.vertexStart !== instance * vertices || face.vertexEnd !== (instance + 1) * vertices) return context;
|
|
17
|
+
for (axis = 0; axis < 3; axis++) offsets[instance * 4 + axis] = origin[axis] + positions[start + axis] - positions[axis];
|
|
18
|
+
offsets[instance * 4 + 3] = instance * vertices;
|
|
19
|
+
for (i = 0; i < length; i++) {
|
|
20
|
+
if (Math.fround(template[i] + offsets[instance * 4 + i % 3]) !== Math.fround(positions[start + i]) ||
|
|
21
|
+
Math.fround(normals[i]) !== Math.fround(normals[start + i]) ||
|
|
22
|
+
Math.fround(colors[i]) !== Math.fround(colors[start + i])) return context;
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
return {
|
|
26
|
+
positions: template, normals: normals.slice(0, length), colors: colors.slice(0, length),
|
|
27
|
+
instanceOffsets: offsets,
|
|
28
|
+
};
|
|
29
|
+
}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { getElevation } from '../terrain/getElevation.js';
|
|
2
|
+
|
|
3
|
+
export function projectRing(context, ring) {
|
|
4
|
+
const { backend, crs, origin, metres, map } = context;
|
|
5
|
+
if (ring.length < 4) throw new Error('Invalid GeoJSON polygon ring');
|
|
6
|
+
const path = [];
|
|
7
|
+
let lng, lat, point, elevation;
|
|
8
|
+
for ([lng, lat] of ring.slice(0, -1)) {
|
|
9
|
+
if (!Number.isFinite(lng) || !Number.isFinite(lat)) throw new Error('Invalid GeoJSON coordinates');
|
|
10
|
+
point = crs.project(new L.LatLng(lat, lng));
|
|
11
|
+
elevation = map._terrain3D ? getElevation(map._terrain3D, [lat, lng]) : undefined;
|
|
12
|
+
path.push({
|
|
13
|
+
x: (point.x - origin.x) * metres,
|
|
14
|
+
y: (point.y - origin.y) * metres,
|
|
15
|
+
ground: Number.isFinite(elevation) && Number.isFinite(backend.root.position[1])
|
|
16
|
+
? elevation - backend.root.position[1] : 0,
|
|
17
|
+
});
|
|
18
|
+
}
|
|
19
|
+
return path;
|
|
20
|
+
}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { getElevation } from '../terrain/getElevation.js';
|
|
2
|
+
|
|
3
|
+
export function projectedTree(context, lon, lat) {
|
|
4
|
+
const { backend, crs, origin, metres, map } = context;
|
|
5
|
+
const point = crs.project(new L.LatLng(lat, lon));
|
|
6
|
+
const elevation = map._terrain3D ? getElevation(map._terrain3D, [lat, lon]) : undefined;
|
|
7
|
+
return {
|
|
8
|
+
x: (point.x - origin.x) * metres,
|
|
9
|
+
y: (point.y - origin.y) * metres,
|
|
10
|
+
ground: Number.isFinite(elevation) && Number.isFinite(backend.root.position[1])
|
|
11
|
+
? elevation - backend.root.position[1] : 0,
|
|
12
|
+
};
|
|
13
|
+
}
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
import { cityMapper } from '../constants/cityMapper.js';
|
|
2
|
+
import { emptyNode } from "../scene/emptyNode.js";
|
|
3
|
+
import { isClockWise } from "../triangulation/isClockWise.js";
|
|
4
|
+
import { lampPostGeometry } from "../geometry/lampPostGeometry.js";
|
|
5
|
+
import { lightGeometry } from "../geometry/lightGeometry.js";
|
|
6
|
+
import { parseColor } from "../utils/parseColor.js";
|
|
7
|
+
import { treeGeometry } from "../geometry/treeGeometry.js";
|
|
8
|
+
import { triangulate } from "../triangulation/triangulate.js";
|
|
9
|
+
import { createProgram } from '../rendering/createProgram.js';
|
|
10
|
+
import { updateStatus } from './updateStatus.js';
|
|
11
|
+
import { loadSource } from '../archives/loadSource.js';
|
|
12
|
+
import { setParent } from '../scene/setParent.js';
|
|
13
|
+
import { update } from '../scene/update.js';
|
|
14
|
+
import { getElevation } from "../terrain/getElevation.js";
|
|
15
|
+
import { pumpState } from '../constants/pumpState.js';
|
|
16
|
+
import { compareDistance } from '../utils/compareDistance.js';
|
|
17
|
+
import { buildArea } from './buildArea.js';
|
|
18
|
+
|
|
19
|
+
pumpState.triangleContexts = [];
|
|
20
|
+
|
|
21
|
+
/** Share four load/build slots across source layers, nearest ground blocks first. */
|
|
22
|
+
export function pump(backend, map = backend._map) {
|
|
23
|
+
const shared = map && cityMapper.renderers.get(map);
|
|
24
|
+
if (!shared) return;
|
|
25
|
+
const layers = [];
|
|
26
|
+
let layer, area, center, areaBackend;
|
|
27
|
+
for (layer of shared._layers) {
|
|
28
|
+
if (Number.isFinite(layer._inflight) && layer._areas && (layer.url || layer._geojson)) layers.push(layer);
|
|
29
|
+
}
|
|
30
|
+
const pending = [];
|
|
31
|
+
for (layer of layers) {
|
|
32
|
+
for (area of layer._areas.values()) {
|
|
33
|
+
if (area.started || area.request.signal.aborted) continue;
|
|
34
|
+
center = area.coords && map.project(map.getCenter(), area.coords.z).divideBy(256);
|
|
35
|
+
pending.push({
|
|
36
|
+
layer, area,
|
|
37
|
+
distance: center
|
|
38
|
+
? Math.hypot(area.coords.x + 0.5 - center.x, area.coords.y + 0.5 - center.y) / 2 ** area.coords.z : 0,
|
|
39
|
+
});
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
pending.sort(compareDistance);
|
|
43
|
+
let inflight = 0;
|
|
44
|
+
for (layer of layers) inflight += layer._inflight;
|
|
45
|
+
for ({ layer: areaBackend, area } of pending) {
|
|
46
|
+
if (inflight >= 4) break;
|
|
47
|
+
if (areaBackend._inflight >= 2) continue;
|
|
48
|
+
area.started = true;
|
|
49
|
+
areaBackend._inflight++;
|
|
50
|
+
inflight++;
|
|
51
|
+
buildArea(areaBackend, area, map);
|
|
52
|
+
}
|
|
53
|
+
for (layer of layers) updateStatus(layer);
|
|
54
|
+
}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { setHighlight } from '../picking/setHighlight.js';
|
|
2
|
+
import { showFeature } from '../picking/showFeature.js';
|
|
3
|
+
import { setParent } from '../scene/setParent.js';
|
|
4
|
+
import { update } from '../scene/update.js';
|
|
5
|
+
|
|
6
|
+
/** Cancel pending work and dispose this block's GPU data, including any hover highlight. */
|
|
7
|
+
export function releaseArea(backend, area) {
|
|
8
|
+
area.request.abort();
|
|
9
|
+
let attribute;
|
|
10
|
+
if (area.mesh) {
|
|
11
|
+
if (backend.highlightedFeature?.mesh === area.mesh) {
|
|
12
|
+
setHighlight(backend, null);
|
|
13
|
+
backend.hoveredFeature = null;
|
|
14
|
+
showFeature(backend, null);
|
|
15
|
+
}
|
|
16
|
+
setParent(area.mesh, null);
|
|
17
|
+
update(backend);
|
|
18
|
+
const geometry = area.mesh.geometry;
|
|
19
|
+
for (attribute of Object.values(geometry.attributes)) attribute.buffer.destroy();
|
|
20
|
+
area.mesh.program.pipelineCache.clear();
|
|
21
|
+
}
|
|
22
|
+
}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { releaseArea } from './releaseArea.js';
|
|
2
|
+
import { updateArea } from './updateArea.js';
|
|
3
|
+
|
|
4
|
+
export function setGeoJSONData(layer, data) {
|
|
5
|
+
layer.options.data = data;
|
|
6
|
+
delete layer.options.url;
|
|
7
|
+
let area;
|
|
8
|
+
for (area of layer._areas.values()) releaseArea(layer, area);
|
|
9
|
+
layer._areas.clear();
|
|
10
|
+
updateArea(layer);
|
|
11
|
+
return layer;
|
|
12
|
+
}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
export function sourceAreaContext(backend, area, map) {
|
|
2
|
+
const crs = map.options.crs, origin = crs.project(backend.location);
|
|
3
|
+
return {
|
|
4
|
+
backend, area, map, crs, origin,
|
|
5
|
+
metres: Math.cos(backend.location.lat * Math.PI / 180),
|
|
6
|
+
positions: [], normals: [], colors: [], uvs: [], featureFaces: [], lights: [],
|
|
7
|
+
supports: new Set(), skipped: 0,
|
|
8
|
+
};
|
|
9
|
+
}
|