leaflet-city-mapper 0.1.0 → 0.1.1
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 +1 -1
- package/dist/leaflet-city-mapper-src.js.map +1 -1
- package/dist/leaflet-city-mapper-worker-src.js.map +1 -1
- package/dist/leaflet-city-mapper-worker.js.map +1 -1
- package/dist/leaflet-city-mapper.js.map +1 -1
- package/libs/leaflet-lens.js +151 -151
- package/libs/leaflet.js +3 -3
- package/libs/openlayers-bindings.js +1129 -1129
- package/libs/openlayers-bindings.min.js.map +1 -1
- package/package.json +2 -4
- package/src/animations/cancelCameraAnimation.js +19 -19
- package/src/animations/mapStopPitchBearingAnimation.js +10 -10
- package/src/animations/scheduleCameraAnimation.js +15 -15
- package/src/animations/scheduleMarkerPan.js +14 -14
- package/src/animations/updateZoomCamera.js +25 -25
- package/src/archives/findDirectoryEntry.js +17 -17
- package/src/archives/findTile.js +45 -45
- package/src/archives/getDirectoryEntries.js +30 -30
- package/src/archives/getTileData.js +26 -26
- package/src/archives/readArchiveRange.js +48 -48
- package/src/astronomy/solarTime.js +21 -21
- package/src/camera/cameraMapReady.js +9 -9
- package/src/camera/cleanupCameraMap.js +13 -13
- package/src/camera/constrainCameraToBounds.js +3 -3
- package/src/camera/createSceneCamera.js +25 -25
- package/src/camera/getBearing.js +10 -10
- package/src/camera/getPitch.js +10 -10
- package/src/camera/mapGetBoundsCenterZoom.js +14 -14
- package/src/camera/mapLimitOffset.js +17 -17
- package/src/camera/mapPanBy.js +14 -14
- package/src/camera/setBearing.js +13 -13
- package/src/camera/setPitch.js +13 -13
- package/src/cog/decodeCogTile.js +37 -37
- package/src/cog/finiteCogValues.js +12 -12
- package/src/cog/getCogAssetEntry.js +26 -26
- package/src/cog/getCogBase.js +22 -22
- package/src/cog/getCogHeader.js +10 -10
- package/src/cog/getCogProfile.js +25 -25
- package/src/cog/getCogTile.js +25 -25
- package/src/cog/getColorTile.js +38 -38
- package/src/cog/getElevationTile.js +29 -29
- package/src/cog/hasCogProjection.js +16 -16
- package/src/cog/initCog.js +13 -13
- package/src/cog/invalidCogFullResponse.js +10 -10
- package/src/cog/openCog.js +40 -40
- package/src/cog/openCogAsset.js +22 -22
- package/src/cog/readCog.js +39 -39
- package/src/cog/readCogBlock.js +19 -19
- package/src/cog/readCogBody.js +30 -30
- package/src/cog/readCogDirectories.js +32 -32
- package/src/cog/readCogDirectory.js +34 -34
- package/src/cog/readCogLevel.js +36 -36
- package/src/cog/readCogTag.js +28 -28
- package/src/cog/validCogDimensions.js +15 -15
- package/src/cog/validCogEncoding.js +18 -18
- package/src/cog/validCogGeoArrays.js +17 -17
- package/src/cog/validCogGrid.js +22 -22
- package/src/cog/validCogTileCoordinates.js +13 -13
- package/src/cog/validateCogContainer.js +17 -17
- package/src/cog/validateCogContentRange.js +18 -18
- package/src/cog/validateCogOffsets.js +19 -19
- package/src/cog/validateCogRange.js +16 -16
- package/src/cog/validateCogResponse.js +26 -26
- package/src/collision/collectIntersections.js +41 -41
- package/src/collision/hiddenLightHit.js +19 -19
- package/src/collision/indexTriangle.js +18 -18
- package/src/collision/insideMesh.js +47 -47
- package/src/collision/insideWalker.js +52 -52
- package/src/collision/intersectMeshes.js +40 -40
- package/src/collision/localRay.js +31 -31
- package/src/collision/mergeHits.js +19 -19
- package/src/collision/rayBounds.js +28 -28
- package/src/collision/readTriangle.js +32 -32
- package/src/collision/trafficCollision.js +23 -23
- package/src/collision/transformTriangle.js +18 -18
- package/src/collision/triangleDistance.js +34 -34
- package/src/collision/vertexCount.js +11 -11
- package/src/collision/worldHit.js +30 -30
- package/src/controls/acceptPitchDrag.js +10 -10
- package/src/controls/acceptRotateDrag.js +9 -9
- package/src/controls/addCameraHandler.js +18 -18
- package/src/controls/adjustCameraDrag.js +13 -13
- package/src/controls/cameraDragContextMenu.js +12 -12
- package/src/controls/cameraDragEnd.js +10 -10
- package/src/controls/cameraDragMove.js +31 -31
- package/src/controls/changeCameraTouch.js +17 -17
- package/src/controls/compassOrientation.js +12 -12
- package/src/controls/compassRemoveHooks.js +2 -2
- package/src/controls/containerResizeRemoveHooks.js +2 -2
- package/src/controls/endCameraTouch.js +18 -18
- package/src/controls/failCompassPermission.js +10 -10
- package/src/controls/finishCameraDrag.js +14 -14
- package/src/controls/finishCompassPermission.js +24 -24
- package/src/controls/isEditableTarget.js +9 -9
- package/src/controls/loadCameraControls.js +18 -18
- package/src/controls/moveCameraTouch.js +34 -34
- package/src/controls/refreshRotateFocus.js +5 -5
- package/src/controls/removeCameraDrag.js +28 -28
- package/src/controls/resizeMap.js +7 -7
- package/src/controls/rotateButtonClick.js +16 -16
- package/src/controls/rotateButtonKeydown.js +20 -20
- package/src/controls/rotateControl.js +12 -12
- package/src/controls/shiftRotateRemoveHooks.js +2 -2
- package/src/controls/shiftRotateWheel.js +15 -15
- package/src/core/cameraMarkerOnDrag.js +16 -16
- package/src/core/constructLayer.js +16 -16
- package/src/core/extendLeafletClass.js +12 -12
- package/src/core/extendTerrainPixelBounds.js +41 -41
- package/src/core/layerAddInitHook.js +12 -12
- package/src/core/layerMergeOptions.js +14 -14
- package/src/core/markerInitInteraction.js +10 -10
- package/src/core/markerSetIcon.js +14 -14
- package/src/core/markerSetRotation.js +19 -19
- package/src/core/projectNativePath.js +30 -30
- package/src/core/redrawPath.js +11 -11
- package/src/core/removeLayer.js +26 -26
- package/src/core/setRotation.js +12 -12
- package/src/core/whenReady.js +14 -14
- package/src/geometry/addBridges.js +36 -36
- package/src/geometry/addGeneratedTriangle.js +10 -10
- package/src/geometry/appendAreaTriangle.js +32 -32
- package/src/geometry/appendNativeTriangle.js +17 -17
- package/src/geometry/appendRouteDash.js +33 -33
- package/src/geometry/appendRouteSegment.js +28 -28
- package/src/geometry/assembleAreaGeometry.js +48 -48
- package/src/geometry/bridgeEdge.js +18 -18
- package/src/geometry/bridgeFaces.js +22 -22
- package/src/geometry/bridgePaths.js +19 -19
- package/src/geometry/bridgePolygon.js +37 -37
- package/src/geometry/bridgeSides.js +18 -18
- package/src/geometry/buildProjectedPoint.js +32 -32
- package/src/geometry/buildProjectedPolygon.js +34 -34
- package/src/geometry/circleAt.js +20 -20
- package/src/geometry/circleGeometry.js +41 -41
- package/src/geometry/createModelGeometry.js +44 -44
- package/src/geometry/crossVector.js +15 -15
- package/src/geometry/dashValues.js +23 -23
- package/src/geometry/dashedSegment.js +33 -33
- package/src/geometry/diskAt.js +18 -18
- package/src/geometry/emitter.js +18 -18
- package/src/geometry/fillNativePolygon.js +28 -28
- package/src/geometry/generateTreeGeometry.js +18 -18
- package/src/geometry/indexBridge.js +36 -36
- package/src/geometry/instanceAreaGeometry.js +37 -37
- package/src/geometry/line.js +28 -28
- package/src/geometry/lineJoin.js +35 -35
- package/src/geometry/markerImageBounds.js +20 -20
- package/src/geometry/meshShadowBounds.js +33 -33
- package/src/geometry/offsetBelowGround.js +10 -10
- package/src/geometry/quad.js +23 -23
- package/src/geometry/restoreGeometry.js +29 -29
- package/src/geometry/roofCoverage.js +33 -33
- package/src/geometry/roofFootprint.js +40 -40
- package/src/geometry/samePoint.js +11 -11
- package/src/geometry/segment.js +32 -32
- package/src/geometry/subtractRoofTile.js +28 -28
- package/src/geometry/terrainBuffers.js +36 -36
- package/src/geometry/terrainTileGeometry.js +28 -28
- package/src/geometry/validateTree.js +19 -19
- package/src/globals/L.js +6 -6
- package/src/globals/cameraFov.js +8 -8
- package/src/globals/cogTags.js +6 -6
- package/src/globals/colorTexture.js +11 -11
- package/src/globals/cosObliquity.js +8 -8
- package/src/globals/degrees.js +6 -6
- package/src/globals/earthCirc.js +6 -6
- package/src/globals/geometryWorkerUrl.js +8 -8
- package/src/globals/halfRadians.js +6 -6
- package/src/globals/lampDirections.js +13 -13
- package/src/globals/layerControlAddItem.js +8 -8
- package/src/globals/leafletLayer.js +8 -8
- package/src/globals/lightScale.js +6 -6
- package/src/globals/mvtTextDecoder.js +6 -6
- package/src/globals/nativeScalableStyleKeys.js +6 -6
- package/src/globals/sinObliquity.js +8 -8
- package/src/globals/tau.js +6 -6
- package/src/globals/vectorStyleNamedColors.js +13 -13
- package/src/globals/vectorTileEvents.js +6 -6
- package/src/globals/workerCogSource.js +6 -6
- package/src/gpu/initializeRendererResources.js +39 -39
- package/src/gpu/initializeSharedRenderer.js +59 -59
- package/src/gpu/mountRenderer.js +25 -25
- package/src/layer-controls/layerControlInputId.js +18 -18
- package/src/layer-controls/layerCountTitle.js +16 -16
- package/src/layer-controls/placeEntryElement.js +29 -29
- package/src/layer-controls/renderLayerCount.js +28 -28
- package/src/lighting/visitLightCells.js +26 -26
- package/src/lighting/writeLightCell.js +14 -14
- package/src/materials/createProgramLayout.js +44 -44
- package/src/materials/createProgramUniforms.js +25 -25
- package/src/materials/modelMaterialFor.js +29 -29
- package/src/materials/prepareMeshCutout.js +21 -21
- package/src/materials/terrainRasterProgram.js +65 -65
- package/src/materials/validateRoofMaterial.js +17 -17
- package/src/models/applyModelTransform.js +18 -18
- package/src/models/buildModelNodes.js +24 -24
- package/src/models/createModelContext.js +24 -24
- package/src/models/loadBuffer.js +16 -16
- package/src/models/loadModelResources.js +22 -22
- package/src/models/normalizeAccessor.js +21 -21
- package/src/models/prepareModel.js +29 -29
- package/src/models/prepareModelGeometry.js +35 -35
- package/src/models/prepareModelPrimitive.js +25 -25
- package/src/models/readAccessorValue.js +16 -16
- package/src/models/readModelAttributes.js +32 -32
- package/src/models/readModelIndices.js +28 -28
- package/src/models/readSparseAccessor.js +31 -31
- package/src/models/releaseModelResources.js +15 -15
- package/src/mvt/addMvtCrossings.js +23 -23
- package/src/mvt/appendMvtBandTriangles.js +42 -42
- package/src/mvt/appendMvtCoordinates.js +20 -20
- package/src/mvt/appendMvtPolygonTriangles.js +29 -29
- package/src/mvt/beginMvtPath.js +19 -19
- package/src/mvt/closeMvtPath.js +16 -16
- package/src/mvt/collectMvtEdges.js +29 -29
- package/src/mvt/createMvtReader.js +14 -14
- package/src/mvt/decodeVectorTile.js +39 -39
- package/src/mvt/expectMvtWire.js +11 -11
- package/src/mvt/finishMvtPath.js +14 -14
- package/src/mvt/finiteMvtCoordinate.js +14 -14
- package/src/mvt/groupMvtPolygons.js +35 -35
- package/src/mvt/isMvtFallbackError.js +13 -13
- package/src/mvt/mergeMvtActiveEdges.js +18 -18
- package/src/mvt/mvtEdgeX.js +12 -12
- package/src/mvt/mvtPathsVertices.js +15 -15
- package/src/mvt/mvtPolygonPaths.js +19 -19
- package/src/mvt/numericMvtValue.js +11 -11
- package/src/mvt/readMvtFeature.js +46 -46
- package/src/mvt/readMvtField.js +17 -17
- package/src/mvt/readMvtGeometry.js +42 -42
- package/src/mvt/readMvtInteger.js +22 -22
- package/src/mvt/readMvtKnownValue.js +30 -30
- package/src/mvt/readMvtLayer.js +40 -40
- package/src/mvt/readMvtMessage.js +18 -18
- package/src/mvt/readMvtNumber.js +18 -18
- package/src/mvt/readMvtNumbers.js +18 -18
- package/src/mvt/readMvtString.js +14 -14
- package/src/mvt/readMvtValue.js +29 -29
- package/src/mvt/skipMvtField.js +22 -22
- package/src/mvt/sortMvtActiveEdges.js +20 -20
- package/src/mvt/sortedMvtLevels.js +29 -29
- package/src/mvt/takeMvtBytes.js +18 -18
- package/src/mvt/tessellateVectorRings.js +26 -26
- package/src/mvt/triangulateVectorRings.js +23 -23
- package/src/native/beforeNativeRender.js +21 -21
- package/src/native/bypassNativeEvent.js +21 -21
- package/src/native/canScaleNativeStyle.js +26 -26
- package/src/native/compareNativeHits.js +10 -10
- package/src/native/createNativeMesh.js +46 -46
- package/src/native/forwardNativeError.js +8 -8
- package/src/native/getGridTerrainTile.js +47 -47
- package/src/native/gridTerrainElevation.js +34 -34
- package/src/native/isCurrentNativeLayer.js +11 -11
- package/src/native/loadGridTerrain.js +36 -36
- package/src/native/nativeEventSource.js +27 -27
- package/src/native/nativeProgram.js +28 -28
- package/src/native/nativeTerrainElevation.js +27 -27
- package/src/native/nativeVectorGeometry.js +30 -30
- package/src/native/orderNativeGridLayer.js +20 -20
- package/src/native/prepareGridTerrainRequests.js +23 -23
- package/src/native/pruneNativeResources.js +25 -25
- package/src/native/readyNativeGPU.js +13 -13
- package/src/native/rejectNativeReady.js +2 -2
- package/src/native/removeNativeEvents.js +20 -20
- package/src/native/resolveNativeReady.js +2 -2
- package/src/native/restoreNativeEvents.js +8 -8
- package/src/native/retainGridTerrain.js +15 -15
- package/src/native/styleNativeMesh.js +20 -20
- package/src/native/syncGridTile.js +28 -28
- package/src/native/syncImageOverlay.js +13 -13
- package/src/native/syncNativeStrokeAnchors.js +18 -18
- package/src/native/syncNativeStrokeZoom.js +34 -34
- package/src/native/syncTerrainGridTile.js +38 -38
- package/src/native/terrainGridMesh.js +47 -47
- package/src/native/updateNativeHover.js +15 -15
- package/src/native/updateNativeStrokeRadius.js +14 -14
- package/src/picking/hitColliderCell.js +29 -29
- package/src/picking/validateCameraInverse.js +15 -15
- package/src/projections/displayContainerPoint.js +32 -32
- package/src/projections/projectBridgePoint.js +17 -17
- package/src/projections/toPoint.js +13 -13
- package/src/projections/transformZoomAnimationPoint.js +8 -8
- package/src/projections/verticalGroundY.js +14 -14
- package/src/raster/rasterTileRange.js +32 -32
- package/src/raster/retainRasterTiles.js +21 -21
- package/src/rendering/collectVisibleMesh.js +48 -48
- package/src/rendering/compareMeshDepth.js +14 -14
- package/src/rendering/drawPipeline.js +44 -44
- package/src/rendering/nativeStrokeExpansion.js +11 -11
- package/src/rendering/prepareFrameBuffer.js +24 -24
- package/src/rendering/prepareMeshUniforms.js +36 -36
- package/src/rendering/revealRoofMesh.js +43 -43
- package/src/scene/addSceneLayer.js +24 -24
- package/src/scene/callLayer.js +34 -34
- package/src/scene/createLayer.js +13 -13
- package/src/scene/getLocation.js +12 -12
- package/src/scene/isNativeLayer.js +19 -19
- package/src/scene/removeSceneLayer.js +22 -22
- package/src/scene/reportLayerError.js +9 -9
- package/src/shaders/materialBaseShader.js +26 -26
- package/src/shaders/materialSurfaceShader.js +60 -60
- package/src/shaders/materialVertexShader.js +89 -89
- package/src/shaders/nativeStrokeShader.js +13 -13
- package/src/shaders/roofVertexShader.js +16 -16
- package/src/shadows/shadowMeshMatches.js +19 -19
- package/src/sources/buildAreaFeatures.js +23 -23
- package/src/sources/extrusionStyle.js +21 -21
- package/src/sources/featureAnchor.js +21 -21
- package/src/sources/groundOffset.js +9 -9
- package/src/sources/initVectorTiles.js +21 -21
- package/src/sources/isVectorTileSource.js +11 -11
- package/src/sources/matchesAreaTile.js +17 -17
- package/src/sources/pendingSourceAreas.js +28 -28
- package/src/sources/prepareAreaGeometryJob.js +34 -34
- package/src/sources/projectAreaPolygons.js +25 -25
- package/src/sources/readyVectorTiles.js +17 -17
- package/src/sunlight/addTimeControlToMap.js +18 -18
- package/src/sunlight/addTimeLayer.js +12 -12
- package/src/sunlight/initializeTimeControl.js +18 -18
- package/src/sunlight/onAddSun.js +37 -37
- package/src/sunlight/onAddTimeControl.js +12 -12
- package/src/sunlight/onRemoveSun.js +10 -10
- package/src/sunlight/removeSun.js +25 -25
- package/src/sunlight/removeTimeControl.js +14 -14
- package/src/sunlight/removeTimeLayer.js +11 -11
- package/src/sunlight/requestSunlightRender.js +12 -12
- package/src/sunlight/styleTimeControl.js +13 -13
- package/src/sunlight/tickSun.js +10 -10
- package/src/sunlight/updateCelestialDisc.js +23 -23
- package/src/sunlight/updateSun.js +44 -44
- package/src/sunlight/useLiveTime.js +11 -11
- package/src/sunlight/useSelectedTime.js +26 -26
- package/src/terrain/applyTerrain.js +30 -30
- package/src/terrain/copyTerrainTile.js +20 -20
- package/src/terrain/loadReadyTerrain.js +6 -6
- package/src/terrain/mapElevationOf.js +19 -19
- package/src/terrain/readBridges.js +13 -13
- package/src/terrain/readyTerrainOf.js +14 -14
- package/src/terrain/sampleTerrainTile.js +16 -16
- package/src/terrain/terrainTileQueue.js +34 -34
- package/src/textures/addImageState.js +13 -13
- package/src/textures/bindMeshTextures.js +57 -57
- package/src/textures/collectRoofTiles.js +23 -23
- package/src/textures/loadModelImage.js +29 -29
- package/src/textures/modelTextureFor.js +47 -47
- package/src/textures/prepareMeshTextures.js +31 -31
- package/src/textures/removeImageState.js +13 -13
- package/src/textures/resizeRoofTexture.js +32 -32
- package/src/textures/restoreMaterialTextures.js +22 -22
- package/src/textures/updateRoofAtlas.js +29 -29
- package/src/textures/uploadMeshTexture.js +32 -32
- package/src/textures/uploadNativeImage.js +26 -26
- package/src/textures/uploadRoofTile.js +29 -29
- package/src/traffic/createTrafficMesh.js +17 -17
- package/src/traffic/disposeTrafficObject.js +19 -19
- package/src/traffic/failTraffic.js +12 -12
- package/src/traffic/failedTrafficLoad.js +10 -10
- package/src/traffic/fetchTrafficLanes.js +21 -21
- package/src/traffic/loadedTrafficLanes.js +21 -21
- package/src/traffic/locateTraffic.js +20 -20
- package/src/traffic/moveTraffic.js +21 -21
- package/src/traffic/readyTraffic.js +10 -10
- package/src/traffic/refreshTrafficTrips.js +42 -42
- package/src/traffic/routeColor.js +13 -13
- package/src/traffic/startTraffic.js +12 -12
- package/src/traffic/trafficNow.js +15 -15
- package/src/traffic/trafficStatusText.js +13 -13
- package/src/traffic/trafficStorage.js +13 -13
- package/src/traffic/updateTraffic.js +13 -13
- package/src/traffic/updateTrafficLights.js +23 -23
- package/src/traffic/updateTrafficPose.js +15 -15
- package/src/traffic/updateTrafficTerrain.js +15 -15
- package/src/traffic/uploadTrafficLanes.js +27 -27
- package/src/transforms/composeLocalTransform.js +23 -23
- package/src/transforms/transformNativePoint.js +19 -19
- package/src/transforms/worldMatrixChanged.js +26 -26
- package/src/triangulation/clipEars.js +32 -32
- package/src/triangulation/connectHole.js +30 -30
- package/src/triangulation/cross.js +12 -12
- package/src/triangulation/equal.js +11 -11
- package/src/triangulation/intersects.js +21 -21
- package/src/triangulation/mergeHoles.js +19 -19
- package/src/triangulation/on.js +13 -13
- package/src/triangulation/polygonRings.js +22 -22
- package/src/triangulation/validateArea.js +19 -19
- package/src/utils/compareDistance.js +11 -11
- package/src/utils/yieldTask.js +12 -12
- package/src/vector-style/appendQuotedStyleCharacter.js +30 -30
- package/src/vector-style/arrayContainsRange.js +18 -18
- package/src/vector-style/evaluateBoolean.js +31 -31
- package/src/vector-style/evaluateCoalesceOrCase.js +34 -34
- package/src/vector-style/evaluateComparison.js +29 -29
- package/src/vector-style/evaluateIExpression.js +21 -21
- package/src/vector-style/evaluateInput.js +16 -16
- package/src/vector-style/evaluateInterpolate.js +36 -36
- package/src/vector-style/evaluateMatch.js +21 -21
- package/src/vector-style/evaluateMath.js +26 -26
- package/src/vector-style/evaluateMembership.js +29 -29
- package/src/vector-style/evaluateNegation.js +26 -26
- package/src/vector-style/evaluatePrimitive.js +21 -21
- package/src/vector-style/evaluateStep.js +20 -20
- package/src/vector-style/evaluateStyle.js +43 -43
- package/src/vector-style/evaluateToExpression.js +27 -27
- package/src/vector-style/fillVectorPaint.js +26 -26
- package/src/vector-style/lineVectorPaint.js +31 -31
- package/src/vector-style/parseFunctionalColor.js +23 -23
- package/src/vector-style/parseHexColor.js +20 -20
- package/src/vector-style/parseVectorStyle.js +20 -20
- package/src/vector-style/readPaintValue.js +17 -17
- package/src/vector-style/removeTrailingCommas.js +19 -19
- package/src/vector-style/scaleDashArray.js +25 -25
- package/src/vector-style/skipStyleComment.js +20 -20
- package/src/vector-style/stripStyleComments.js +28 -28
- package/src/vector-style/styleColor.js +18 -18
- package/src/vector-style/validateVectorLayers.js +18 -18
- package/src/vector-style/vectorPaint.js +17 -17
- package/src/vector-style/visibleStyle.js +16 -16
- package/src/vector-tiles/appendVectorBatch.js +34 -34
- package/src/vector-tiles/attachVectorTileBatch.js +25 -25
- package/src/vector-tiles/attachVectorTileBatches.js +26 -26
- package/src/vector-tiles/compareVectorLabelPriority.js +11 -11
- package/src/vector-tiles/compareVectorTileDistance.js +11 -11
- package/src/vector-tiles/createVectorLabel.js +37 -37
- package/src/vector-tiles/forwardVectorTileError.js +10 -10
- package/src/vector-tiles/loadVectorSprite.js +14 -14
- package/src/vector-tiles/loadVectorTile.js +45 -45
- package/src/vector-tiles/onVectorTileAdd.js +44 -44
- package/src/vector-tiles/onVectorTileMessage.js +15 -15
- package/src/vector-tiles/onVectorTileRemove.js +25 -25
- package/src/vector-tiles/onVectorTileWorkerError.js +16 -16
- package/src/vector-tiles/paintVectorTileBatch.js +18 -18
- package/src/vector-tiles/prepareVectorLabel.js +34 -34
- package/src/vector-tiles/prepareVectorStyleLayer.js +38 -38
- package/src/vector-tiles/prepareVectorTile.js +29 -29
- package/src/vector-tiles/projectVectorPaths.js +25 -25
- package/src/vector-tiles/projectVectorPoint.js +15 -15
- package/src/vector-tiles/projectVectorTriangles.js +28 -28
- package/src/vector-tiles/pruneVectorTiles.js +14 -14
- package/src/vector-tiles/pumpVectorTiles.js +21 -21
- package/src/vector-tiles/readTileJSON.js +27 -27
- package/src/vector-tiles/readVectorStyle.js +28 -28
- package/src/vector-tiles/refreshVectorTiles.js +8 -8
- package/src/vector-tiles/reserveVectorLabelCells.js +14 -14
- package/src/vector-tiles/retireVectorTileGroup.js +20 -20
- package/src/vector-tiles/revokeVectorWorkerUrl.js +14 -14
- package/src/vector-tiles/rotateVectorLabel.js +19 -19
- package/src/vector-tiles/rotateVectorLabels.js +9 -9
- package/src/vector-tiles/simplifyVectorPath.js +29 -29
- package/src/vector-tiles/updateVectorLabelMarker.js +36 -36
- package/src/vector-tiles/updateVectorLabelStyle.js +14 -14
- package/src/vector-tiles/updateVectorTileLabels.js +33 -33
- package/src/vector-tiles/updateVectorTilePaint.js +25 -25
- package/src/vector-tiles/updateVectorTiles.js +32 -32
- package/src/vector-tiles/validateVectorTileZooms.js +15 -15
- package/src/vector-tiles/vectorFeaturePaint.js +25 -25
- package/src/vector-tiles/vectorFeaturePaths.js +26 -26
- package/src/vector-tiles/vectorFeatureZoom.js +18 -18
- package/src/vector-tiles/vectorLabelAnchors.js +31 -31
- package/src/vector-tiles/vectorLabelCandidates.js +18 -18
- package/src/vector-tiles/vectorLabelCells.js +32 -32
- package/src/vector-tiles/vectorLabelIcon.js +38 -38
- package/src/vector-tiles/vectorLabelProperty.js +12 -12
- package/src/vector-tiles/vectorLabelText.js +19 -19
- package/src/vector-tiles/vectorSpriteIcon.js +19 -19
- package/src/vector-tiles/vectorStraightRun.js +23 -23
- package/src/vector-tiles/vectorStyleDependencies.js +22 -22
- package/src/vector-tiles/vectorStyleValue.js +16 -16
- package/src/vector-tiles/vectorStyleZoom.js +12 -12
- package/src/vector-tiles/vectorTileAwaited.js +17 -17
- package/src/vector-tiles/vectorTileOverlaps.js +12 -12
- package/src/vector-tiles/vectorTilePaint.js +18 -18
- package/src/vector-tiles/vectorTileSettings.js +27 -27
- package/src/vector-tiles/vectorTilesIdle.js +11 -11
- package/src/vector-tiles/vectorTolerance.js +11 -11
- package/src/vector-tiles/wrapVectorLabel.js +17 -17
- package/src/vehicles/boatModel.js +35 -35
- package/src/vehicles/busModel.js +13 -13
- package/src/vehicles/carModel.js +39 -39
- package/src/walk/initializeWalkControl.js +12 -12
- package/src/walk/isWalkBlocked.js +15 -15
- package/src/walk/landWalker.js +41 -41
- package/src/walk/moveWalker.js +37 -37
- package/src/walk/onAddWalkControl.js +40 -40
- package/src/walk/onRemoveWalkControl.js +17 -17
- package/src/walk/onWalkBlur.js +3 -3
- package/src/walk/onWalkTerrain.js +3 -3
- package/src/walk/resolveWalkerPosition.js +33 -33
- package/src/walk/stepWalkerHeight.js +18 -18
- package/src/walk/toggleWalking.js +4 -4
- package/src/walk/updateWalkerFrame.js +29 -29
- package/src/walk/updateWalkerView.js +31 -31
- package/src/weakmaps/cameraHandlersByMap.js +6 -6
- package/src/weakmaps/geometryWorkersByMap.js +6 -6
- package/src/weakmaps/nativeProgramsByRenderer.js +6 -6
- package/src/weakmaps/pathProjectionByMap.js +6 -6
- package/src/weakmaps/streamTerrainByLayer.js +6 -6
- package/src/weakmaps/streamTerrainByMap.js +6 -6
- package/src/weakmaps/sunByMap.js +6 -6
- package/src/weakmaps/vectorTileOptionsByLayer.js +6 -6
- package/src/weakmaps/vectorWorkerByLayer.js +6 -6
- package/src/weakmaps/walkByMap.js +6 -6
- package/src/weakmaps/workerMapByLayer.js +6 -6
- package/src/workers/acquireGeometryWorker.js +39 -39
- package/src/workers/buildAreaInWorker.js +24 -24
- package/src/workers/closeGeometryWorkers.js +16 -16
- package/src/workers/cogWorker.js +27 -27
- package/src/workers/createGeometryWorker.js +30 -30
- package/src/workers/geometryWorker.js +34 -34
- package/src/workers/getCogInWorker.js +18 -18
- package/src/workers/modelWorker.js +17 -17
- package/src/workers/openCogInWorker.js +22 -22
- package/src/workers/runSourceWorker.js +44 -44
- package/src/workers/settleGeometryWorker.js +16 -16
- package/src/workers/startGeometryWorker.js +23 -23
- package/src/workers/vectorTileWorker.js +15 -15
|
@@ -1,26 +1,26 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Generate fragment code for base color, alpha and optional roof texture.
|
|
3
|
-
*
|
|
4
|
-
* @param {Object} material Material settings.
|
|
5
|
-
* @param {boolean} hasBase Whether a base texture is bound.
|
|
6
|
-
* @param {boolean} hasRoof Whether a roof texture is bound.
|
|
7
|
-
*
|
|
8
|
-
* @returns {string} WGSL fragment code.
|
|
9
|
-
*/
|
|
10
|
-
export function materialBaseShader(material, hasBase, hasRoof) {
|
|
11
|
-
return /* wgsl */ `
|
|
12
|
-
var normal = normalize(input.normal) * select(-1.0, 1.0, frontFacing);
|
|
13
|
-
let texel = ${hasBase ? 'textureSample(baseTexture, baseTextureSampler, input.uv)' : 'vec4<f32>(1.0)'};
|
|
14
|
-
let alpha = u.material.z * texel.a;
|
|
15
|
-
${material.alphaMode === 'MASK' ? 'if (alpha < u.material.w) { discard; }' : ''}
|
|
16
|
-
${material.alphaMode === 'BLEND' ? 'if (alpha < 0.01) { discard; }' : ''}
|
|
17
|
-
var base = ${material.vertexColors ? 'toLinear(min(input.color, vec3<f32>(1.0)))' : 'input.color'} *
|
|
18
|
-
${material.baseTexture?.srgb ? 'texel.rgb' : 'toLinear(texel.rgb)'};
|
|
19
|
-
${hasRoof ? /* wgsl */ `
|
|
20
|
-
if (input.roof > 0.0 && all(input.roofUv >= vec2<f32>(0.0)) &&
|
|
21
|
-
all(input.roofUv <= vec2<f32>(1.0))) {
|
|
22
|
-
let roof = textureSampleLevel(roofTexture, roofTextureSampler, input.roofUv, 0.0);
|
|
23
|
-
base = mix(base, toLinear(roof.rgb), roof.a * input.roof);
|
|
24
|
-
}
|
|
25
|
-
` : ''}`;
|
|
26
|
-
}
|
|
1
|
+
/**
|
|
2
|
+
* Generate fragment code for base color, alpha and optional roof texture.
|
|
3
|
+
*
|
|
4
|
+
* @param {Object} material Material settings.
|
|
5
|
+
* @param {boolean} hasBase Whether a base texture is bound.
|
|
6
|
+
* @param {boolean} hasRoof Whether a roof texture is bound.
|
|
7
|
+
*
|
|
8
|
+
* @returns {string} WGSL fragment code.
|
|
9
|
+
*/
|
|
10
|
+
export function materialBaseShader(material, hasBase, hasRoof) {
|
|
11
|
+
return /* wgsl */ `
|
|
12
|
+
var normal = normalize(input.normal) * select(-1.0, 1.0, frontFacing);
|
|
13
|
+
let texel = ${hasBase ? 'textureSample(baseTexture, baseTextureSampler, input.uv)' : 'vec4<f32>(1.0)'};
|
|
14
|
+
let alpha = u.material.z * texel.a;
|
|
15
|
+
${material.alphaMode === 'MASK' ? 'if (alpha < u.material.w) { discard; }' : ''}
|
|
16
|
+
${material.alphaMode === 'BLEND' ? 'if (alpha < 0.01) { discard; }' : ''}
|
|
17
|
+
var base = ${material.vertexColors ? 'toLinear(min(input.color, vec3<f32>(1.0)))' : 'input.color'} *
|
|
18
|
+
${material.baseTexture?.srgb ? 'texel.rgb' : 'toLinear(texel.rgb)'};
|
|
19
|
+
${hasRoof ? /* wgsl */ `
|
|
20
|
+
if (input.roof > 0.0 && all(input.roofUv >= vec2<f32>(0.0)) &&
|
|
21
|
+
all(input.roofUv <= vec2<f32>(1.0))) {
|
|
22
|
+
let roof = textureSampleLevel(roofTexture, roofTextureSampler, input.roofUv, 0.0);
|
|
23
|
+
base = mix(base, toLinear(roof.rgb), roof.a * input.roof);
|
|
24
|
+
}
|
|
25
|
+
` : ''}`;
|
|
26
|
+
}
|
|
@@ -1,60 +1,60 @@
|
|
|
1
|
-
import { materialBaseShader } from './materialBaseShader.js';
|
|
2
|
-
|
|
3
|
-
/**
|
|
4
|
-
* Generate lit or unlit material fragment code for the available textures.
|
|
5
|
-
*
|
|
6
|
-
* @param {Object} material Material settings.
|
|
7
|
-
* @param {boolean} sparkle Whether to include sparkle shading.
|
|
8
|
-
* @param {boolean} hasBase Whether a base texture is bound.
|
|
9
|
-
* @param {boolean} hasMetal Whether a metallic-roughness texture is bound.
|
|
10
|
-
* @param {boolean} hasEmissive Whether an emissive texture is bound.
|
|
11
|
-
* @param {boolean} hasOcclusion Whether an occlusion texture is bound.
|
|
12
|
-
* @param {boolean} hasRoof Whether a roof texture is bound.
|
|
13
|
-
*
|
|
14
|
-
* @returns {string} WGSL fragment code.
|
|
15
|
-
*/
|
|
16
|
-
export function materialSurfaceShader(material, sparkle, hasBase, hasMetal, hasEmissive, hasOcclusion, hasRoof) {
|
|
17
|
-
return material.unlit ? /* wgsl */ `
|
|
18
|
-
let rasterTexel = ${hasBase ? 'textureSample(baseTexture, baseTextureSampler, input.uv)' : 'vec4<f32>(input.color, 1.0)'};
|
|
19
|
-
return vec4<f32>(toSRGB(toLinear(rasterTexel.rgb) * (frame.atmosphereTint.rgb * (0.55 + 0.45 * sunlight) + artificial)), ${material.alphaMode === 'BLEND' ? 'u.material.z * rasterTexel.a' : '1.0'});
|
|
20
|
-
` : /* wgsl */ `${materialBaseShader(material, hasBase, hasRoof)}
|
|
21
|
-
let mr = ${hasMetal ? 'textureSample(metalTexture, metalTextureSampler, input.uv)' : 'vec4<f32>(1.0)'};
|
|
22
|
-
let metal = clamp(u.material.x * mr.b, 0.0, 1.0);
|
|
23
|
-
let rough = clamp(u.material.y * mr.g, 0.08, 1.0);
|
|
24
|
-
let view = normalize(-input.viewPosition);
|
|
25
|
-
let halfVector = normalize(view + frame.lightDirection.xyz);
|
|
26
|
-
let nl = max(dot(normal, frame.lightDirection.xyz), 0.0) * frame.lightDirection.w * sunlight;
|
|
27
|
-
let nv = max(dot(normal, view), 0.001);
|
|
28
|
-
let nh = max(dot(normal, halfVector), 0.0);
|
|
29
|
-
let vh = max(dot(view, halfVector), 0.0);
|
|
30
|
-
let a2 = pow(rough, 4.0);
|
|
31
|
-
let d = a2 / max(PI * pow(nh * nh * (a2 - 1.0) + 1.0, 2.0), 0.0001);
|
|
32
|
-
let gv = nl * sqrt(nv * nv * (1.0 - a2) + a2);
|
|
33
|
-
let gl = nv * sqrt(nl * nl * (1.0 - a2) + a2);
|
|
34
|
-
let visibility = 0.5 / max(gv + gl, 0.0001);
|
|
35
|
-
let f0 = mix(vec3<f32>(0.04), base, metal);
|
|
36
|
-
let fresnel = f0 + (1.0 - f0) * pow(1.0 - vh, 5.0);
|
|
37
|
-
let specular = d * visibility * fresnel;
|
|
38
|
-
let diffuse = (1.0 - metal) * base / PI;
|
|
39
|
-
let sky = dot(normal, frame.skyDirection.xyz) * 0.5 + 0.5;
|
|
40
|
-
let ambient = mix(toLinear(vec3<f32>(0.455, 0.412, 0.322)), vec3<f32>(1.0), sky) * (2.0 / PI);
|
|
41
|
-
let ao = ${hasOcclusion ? 'mix(1.0, textureSample(occlusionTexture, occlusionTextureSampler, input.uv).r, u.emissive.w)' : '1.0'};
|
|
42
|
-
${sparkle ? /* wgsl */ `
|
|
43
|
-
let lattice = (fract(input.localPosition / 2.5) - 0.5) * 2.5;
|
|
44
|
-
let pointGlow = (1.0 - smoothstep(0.16, 0.42, length(lattice))) * u.highlight.z;
|
|
45
|
-
` : ''}
|
|
46
|
-
// Vertex colour components above 1 are self-lit (e.g. vehicle lamps): dim by day, bright at night.
|
|
47
|
-
let glow = ${sparkle ? 'vec3<f32>(3.0, 2.6, 1.8) * pointGlow +' : ''}${material.vertexColors
|
|
48
|
-
? ' max(input.color - vec3<f32>(1.0), vec3<f32>(0.0)) * (0.3 + 5.0 * frame.skyDirection.w) +' : ''} u.emissive.rgb * ${hasEmissive
|
|
49
|
-
? material.emissiveTexture.srgb
|
|
50
|
-
? 'textureSample(emissiveTexture, emissiveTextureSampler, input.uv).rgb'
|
|
51
|
-
: 'toLinear(textureSample(emissiveTexture, emissiveTextureSampler, input.uv).rgb)'
|
|
52
|
-
: 'vec3<f32>(1.0)'};
|
|
53
|
-
var color = ambient * base * (1.0 - metal) * ao +
|
|
54
|
-
(diffuse + specular) * nl * toLinear(vec3<f32>(1.0, 0.937, 0.835)) * 3.0 + glow;
|
|
55
|
-
${material.vertexColors ? 'color = base * (ambient + toLinear(vec3<f32>(1.0, 0.937, 0.835)) * (3.0 / PI) * nl) + glow;' : ''}
|
|
56
|
-
color = (color - glow) * frame.atmosphereTint.rgb + base * artificial * (1.0 - metal * 0.5) + glow;
|
|
57
|
-
appearance(input.position.xy);
|
|
58
|
-
return vec4<f32>(toSRGB(color), ${material.alphaMode === 'BLEND' ? 'alpha' : '1.0'});
|
|
59
|
-
`;
|
|
60
|
-
}
|
|
1
|
+
import { materialBaseShader } from './materialBaseShader.js';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Generate lit or unlit material fragment code for the available textures.
|
|
5
|
+
*
|
|
6
|
+
* @param {Object} material Material settings.
|
|
7
|
+
* @param {boolean} sparkle Whether to include sparkle shading.
|
|
8
|
+
* @param {boolean} hasBase Whether a base texture is bound.
|
|
9
|
+
* @param {boolean} hasMetal Whether a metallic-roughness texture is bound.
|
|
10
|
+
* @param {boolean} hasEmissive Whether an emissive texture is bound.
|
|
11
|
+
* @param {boolean} hasOcclusion Whether an occlusion texture is bound.
|
|
12
|
+
* @param {boolean} hasRoof Whether a roof texture is bound.
|
|
13
|
+
*
|
|
14
|
+
* @returns {string} WGSL fragment code.
|
|
15
|
+
*/
|
|
16
|
+
export function materialSurfaceShader(material, sparkle, hasBase, hasMetal, hasEmissive, hasOcclusion, hasRoof) {
|
|
17
|
+
return material.unlit ? /* wgsl */ `
|
|
18
|
+
let rasterTexel = ${hasBase ? 'textureSample(baseTexture, baseTextureSampler, input.uv)' : 'vec4<f32>(input.color, 1.0)'};
|
|
19
|
+
return vec4<f32>(toSRGB(toLinear(rasterTexel.rgb) * (frame.atmosphereTint.rgb * (0.55 + 0.45 * sunlight) + artificial)), ${material.alphaMode === 'BLEND' ? 'u.material.z * rasterTexel.a' : '1.0'});
|
|
20
|
+
` : /* wgsl */ `${materialBaseShader(material, hasBase, hasRoof)}
|
|
21
|
+
let mr = ${hasMetal ? 'textureSample(metalTexture, metalTextureSampler, input.uv)' : 'vec4<f32>(1.0)'};
|
|
22
|
+
let metal = clamp(u.material.x * mr.b, 0.0, 1.0);
|
|
23
|
+
let rough = clamp(u.material.y * mr.g, 0.08, 1.0);
|
|
24
|
+
let view = normalize(-input.viewPosition);
|
|
25
|
+
let halfVector = normalize(view + frame.lightDirection.xyz);
|
|
26
|
+
let nl = max(dot(normal, frame.lightDirection.xyz), 0.0) * frame.lightDirection.w * sunlight;
|
|
27
|
+
let nv = max(dot(normal, view), 0.001);
|
|
28
|
+
let nh = max(dot(normal, halfVector), 0.0);
|
|
29
|
+
let vh = max(dot(view, halfVector), 0.0);
|
|
30
|
+
let a2 = pow(rough, 4.0);
|
|
31
|
+
let d = a2 / max(PI * pow(nh * nh * (a2 - 1.0) + 1.0, 2.0), 0.0001);
|
|
32
|
+
let gv = nl * sqrt(nv * nv * (1.0 - a2) + a2);
|
|
33
|
+
let gl = nv * sqrt(nl * nl * (1.0 - a2) + a2);
|
|
34
|
+
let visibility = 0.5 / max(gv + gl, 0.0001);
|
|
35
|
+
let f0 = mix(vec3<f32>(0.04), base, metal);
|
|
36
|
+
let fresnel = f0 + (1.0 - f0) * pow(1.0 - vh, 5.0);
|
|
37
|
+
let specular = d * visibility * fresnel;
|
|
38
|
+
let diffuse = (1.0 - metal) * base / PI;
|
|
39
|
+
let sky = dot(normal, frame.skyDirection.xyz) * 0.5 + 0.5;
|
|
40
|
+
let ambient = mix(toLinear(vec3<f32>(0.455, 0.412, 0.322)), vec3<f32>(1.0), sky) * (2.0 / PI);
|
|
41
|
+
let ao = ${hasOcclusion ? 'mix(1.0, textureSample(occlusionTexture, occlusionTextureSampler, input.uv).r, u.emissive.w)' : '1.0'};
|
|
42
|
+
${sparkle ? /* wgsl */ `
|
|
43
|
+
let lattice = (fract(input.localPosition / 2.5) - 0.5) * 2.5;
|
|
44
|
+
let pointGlow = (1.0 - smoothstep(0.16, 0.42, length(lattice))) * u.highlight.z;
|
|
45
|
+
` : ''}
|
|
46
|
+
// Vertex colour components above 1 are self-lit (e.g. vehicle lamps): dim by day, bright at night.
|
|
47
|
+
let glow = ${sparkle ? 'vec3<f32>(3.0, 2.6, 1.8) * pointGlow +' : ''}${material.vertexColors
|
|
48
|
+
? ' max(input.color - vec3<f32>(1.0), vec3<f32>(0.0)) * (0.3 + 5.0 * frame.skyDirection.w) +' : ''} u.emissive.rgb * ${hasEmissive
|
|
49
|
+
? material.emissiveTexture.srgb
|
|
50
|
+
? 'textureSample(emissiveTexture, emissiveTextureSampler, input.uv).rgb'
|
|
51
|
+
: 'toLinear(textureSample(emissiveTexture, emissiveTextureSampler, input.uv).rgb)'
|
|
52
|
+
: 'vec3<f32>(1.0)'};
|
|
53
|
+
var color = ambient * base * (1.0 - metal) * ao +
|
|
54
|
+
(diffuse + specular) * nl * toLinear(vec3<f32>(1.0, 0.937, 0.835)) * 3.0 + glow;
|
|
55
|
+
${material.vertexColors ? 'color = base * (ambient + toLinear(vec3<f32>(1.0, 0.937, 0.835)) * (3.0 / PI) * nl) + glow;' : ''}
|
|
56
|
+
color = (color - glow) * frame.atmosphereTint.rgb + base * artificial * (1.0 - metal * 0.5) + glow;
|
|
57
|
+
appearance(input.position.xy);
|
|
58
|
+
return vec4<f32>(toSRGB(color), ${material.alphaMode === 'BLEND' ? 'alpha' : '1.0'});
|
|
59
|
+
`;
|
|
60
|
+
}
|
|
@@ -1,89 +1,89 @@
|
|
|
1
|
-
import { roofVertexShader } from './roofVertexShader.js';
|
|
2
|
-
import { nativeStrokeShader } from './nativeStrokeShader.js';
|
|
3
|
-
|
|
4
|
-
/**
|
|
5
|
-
* Generate a vertex shader for the material and its enabled rendering features.
|
|
6
|
-
*
|
|
7
|
-
* @param {Object} material Material settings.
|
|
8
|
-
* @param {boolean} sparkle Whether to output local sparkle coordinates.
|
|
9
|
-
* @param {string} elevationWGSL Terrain elevation WGSL functions.
|
|
10
|
-
* @param {boolean} hasTerrain Whether terrain elevation is enabled.
|
|
11
|
-
* @param {boolean} textured Whether texture coordinates are needed.
|
|
12
|
-
* @param {boolean} hasRoof Whether roof texture coordinates are needed.
|
|
13
|
-
*
|
|
14
|
-
* @returns {string} WGSL vertex shader.
|
|
15
|
-
*/
|
|
16
|
-
export function materialVertexShader(material, sparkle, elevationWGSL, hasTerrain, textured, hasRoof) {
|
|
17
|
-
const instanceOffset = material.instanced ? ' + input.instanceOffset.xyz' : '';
|
|
18
|
-
const stroke = nativeStrokeShader(material);
|
|
19
|
-
return /* wgsl */ `
|
|
20
|
-
struct Mesh {
|
|
21
|
-
worldMatrix: mat4x4<f32>,
|
|
22
|
-
baseColor: vec4<f32>,
|
|
23
|
-
material: vec4<f32>,
|
|
24
|
-
emissive: vec4<f32>,
|
|
25
|
-
terrain: vec4<f32>,
|
|
26
|
-
highlight: vec4<f32>,
|
|
27
|
-
cutout: vec4<f32>,
|
|
28
|
-
nativeStroke: vec4<f32>,
|
|
29
|
-
};
|
|
30
|
-
struct Frame {
|
|
31
|
-
viewMatrix: mat4x4<f32>,
|
|
32
|
-
projectionMatrix: mat4x4<f32>,
|
|
33
|
-
roofMatrix: mat4x4<f32>,
|
|
34
|
-
lightDirection: vec4<f32>,
|
|
35
|
-
skyDirection: vec4<f32>,
|
|
36
|
-
atmosphereTint: vec4<f32>,
|
|
37
|
-
};
|
|
38
|
-
struct Solar {
|
|
39
|
-
matrix: mat4x4<f32>,
|
|
40
|
-
params: vec4<f32>
|
|
41
|
-
};
|
|
42
|
-
struct VertexInput {
|
|
43
|
-
@location(0) position: vec3<f32>,
|
|
44
|
-
@location(1) normal: vec3<f32>,
|
|
45
|
-
${material.instanced ? '@location(4) instanceOffset: vec4<f32>,' : ''}
|
|
46
|
-
${material.vertexColors ? '@location(2) color: vec3<f32>,' : ''}
|
|
47
|
-
${textured ? '@location(3) uv: vec2<f32>,' : ''}
|
|
48
|
-
};
|
|
49
|
-
struct VertexOutput {
|
|
50
|
-
@builtin(position) position: vec4<f32>,
|
|
51
|
-
@location(0) color: vec3<f32>,
|
|
52
|
-
@location(1) normal: vec3<f32>,
|
|
53
|
-
@location(2) viewPosition: vec3<f32>,
|
|
54
|
-
@location(6) shadowPosition: vec4<f32>,
|
|
55
|
-
@location(7) worldPosition: vec3<f32>,
|
|
56
|
-
${sparkle ? '@location(8) localPosition: vec3<f32>,' : ''}
|
|
57
|
-
${textured ? '@location(3) uv: vec2<f32>,' : ''}
|
|
58
|
-
${hasRoof ? '@location(4) roofUv: vec2<f32>, @location(5) roof: f32,' : ''}
|
|
59
|
-
};
|
|
60
|
-
@group(0) @binding(0) var<uniform> u: Mesh;
|
|
61
|
-
@group(0) @binding(1) var<uniform> frame: Frame;
|
|
62
|
-
@group(1) @binding(0) var<uniform> solar: Solar;
|
|
63
|
-
${hasTerrain ? /* wgsl */ `@group(0) @binding(2) var dem: texture_2d<f32>;${elevationWGSL}` : ''}
|
|
64
|
-
@vertex fn vertexMain(input: VertexInput, @builtin(vertex_index) vertexIndex: u32) -> VertexOutput {
|
|
65
|
-
var output: VertexOutput;
|
|
66
|
-
var position = input.position${instanceOffset};
|
|
67
|
-
${stroke.position}
|
|
68
|
-
${hasTerrain ? 'position.y = elevation(u.terrain.xy + input.uv * u.terrain.z, u.terrain.w) - u.terrain.w;' : ''}
|
|
69
|
-
let featureVertex = f32(vertexIndex)${material.instanced ? ' + input.instanceOffset.w' : ''};
|
|
70
|
-
let highlighted = featureVertex >= u.highlight.x && featureVertex < u.highlight.y;
|
|
71
|
-
output.color = ${material.vertexColors ? 'select(input.color, vec3<f32>(72.0 / 255.0, 217.0 / 255.0, 1.0), highlighted)' : 'u.baseColor.rgb'};
|
|
72
|
-
// Inverse-transpose from cofactors; the camera view matrix is orthonormal.
|
|
73
|
-
let m = mat3x3<f32>(u.worldMatrix[0].xyz, u.worldMatrix[1].xyz, u.worldMatrix[2].xyz);
|
|
74
|
-
${stroke.normal}
|
|
75
|
-
let normal = (cross(m[1], m[2]) * sourceNormal.x + cross(m[2], m[0]) * sourceNormal.y + cross(m[0], m[1]) * sourceNormal.z) / determinant(m);
|
|
76
|
-
output.normal = (frame.viewMatrix * vec4<f32>(normal, 0.0)).xyz;
|
|
77
|
-
let world = u.worldMatrix * vec4<f32>(position, 1.0);
|
|
78
|
-
output.shadowPosition = solar.matrix * world;
|
|
79
|
-
output.worldPosition = world.xyz / world.w;
|
|
80
|
-
${sparkle ? `output.localPosition = input.position${instanceOffset};` : ''}
|
|
81
|
-
let viewPosition = frame.viewMatrix * world;
|
|
82
|
-
output.viewPosition = viewPosition.xyz;
|
|
83
|
-
${textured ? 'output.uv = input.uv;' : ''}
|
|
84
|
-
${hasRoof ? roofVertexShader(material) : ''}
|
|
85
|
-
output.position = frame.projectionMatrix * viewPosition;
|
|
86
|
-
return output;
|
|
87
|
-
}
|
|
88
|
-
`;
|
|
89
|
-
}
|
|
1
|
+
import { roofVertexShader } from './roofVertexShader.js';
|
|
2
|
+
import { nativeStrokeShader } from './nativeStrokeShader.js';
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* Generate a vertex shader for the material and its enabled rendering features.
|
|
6
|
+
*
|
|
7
|
+
* @param {Object} material Material settings.
|
|
8
|
+
* @param {boolean} sparkle Whether to output local sparkle coordinates.
|
|
9
|
+
* @param {string} elevationWGSL Terrain elevation WGSL functions.
|
|
10
|
+
* @param {boolean} hasTerrain Whether terrain elevation is enabled.
|
|
11
|
+
* @param {boolean} textured Whether texture coordinates are needed.
|
|
12
|
+
* @param {boolean} hasRoof Whether roof texture coordinates are needed.
|
|
13
|
+
*
|
|
14
|
+
* @returns {string} WGSL vertex shader.
|
|
15
|
+
*/
|
|
16
|
+
export function materialVertexShader(material, sparkle, elevationWGSL, hasTerrain, textured, hasRoof) {
|
|
17
|
+
const instanceOffset = material.instanced ? ' + input.instanceOffset.xyz' : '';
|
|
18
|
+
const stroke = nativeStrokeShader(material);
|
|
19
|
+
return /* wgsl */ `
|
|
20
|
+
struct Mesh {
|
|
21
|
+
worldMatrix: mat4x4<f32>,
|
|
22
|
+
baseColor: vec4<f32>,
|
|
23
|
+
material: vec4<f32>,
|
|
24
|
+
emissive: vec4<f32>,
|
|
25
|
+
terrain: vec4<f32>,
|
|
26
|
+
highlight: vec4<f32>,
|
|
27
|
+
cutout: vec4<f32>,
|
|
28
|
+
nativeStroke: vec4<f32>,
|
|
29
|
+
};
|
|
30
|
+
struct Frame {
|
|
31
|
+
viewMatrix: mat4x4<f32>,
|
|
32
|
+
projectionMatrix: mat4x4<f32>,
|
|
33
|
+
roofMatrix: mat4x4<f32>,
|
|
34
|
+
lightDirection: vec4<f32>,
|
|
35
|
+
skyDirection: vec4<f32>,
|
|
36
|
+
atmosphereTint: vec4<f32>,
|
|
37
|
+
};
|
|
38
|
+
struct Solar {
|
|
39
|
+
matrix: mat4x4<f32>,
|
|
40
|
+
params: vec4<f32>
|
|
41
|
+
};
|
|
42
|
+
struct VertexInput {
|
|
43
|
+
@location(0) position: vec3<f32>,
|
|
44
|
+
@location(1) normal: vec3<f32>,
|
|
45
|
+
${material.instanced ? '@location(4) instanceOffset: vec4<f32>,' : ''}
|
|
46
|
+
${material.vertexColors ? '@location(2) color: vec3<f32>,' : ''}
|
|
47
|
+
${textured ? '@location(3) uv: vec2<f32>,' : ''}
|
|
48
|
+
};
|
|
49
|
+
struct VertexOutput {
|
|
50
|
+
@builtin(position) position: vec4<f32>,
|
|
51
|
+
@location(0) color: vec3<f32>,
|
|
52
|
+
@location(1) normal: vec3<f32>,
|
|
53
|
+
@location(2) viewPosition: vec3<f32>,
|
|
54
|
+
@location(6) shadowPosition: vec4<f32>,
|
|
55
|
+
@location(7) worldPosition: vec3<f32>,
|
|
56
|
+
${sparkle ? '@location(8) localPosition: vec3<f32>,' : ''}
|
|
57
|
+
${textured ? '@location(3) uv: vec2<f32>,' : ''}
|
|
58
|
+
${hasRoof ? '@location(4) roofUv: vec2<f32>, @location(5) roof: f32,' : ''}
|
|
59
|
+
};
|
|
60
|
+
@group(0) @binding(0) var<uniform> u: Mesh;
|
|
61
|
+
@group(0) @binding(1) var<uniform> frame: Frame;
|
|
62
|
+
@group(1) @binding(0) var<uniform> solar: Solar;
|
|
63
|
+
${hasTerrain ? /* wgsl */ `@group(0) @binding(2) var dem: texture_2d<f32>;${elevationWGSL}` : ''}
|
|
64
|
+
@vertex fn vertexMain(input: VertexInput, @builtin(vertex_index) vertexIndex: u32) -> VertexOutput {
|
|
65
|
+
var output: VertexOutput;
|
|
66
|
+
var position = input.position${instanceOffset};
|
|
67
|
+
${stroke.position}
|
|
68
|
+
${hasTerrain ? 'position.y = elevation(u.terrain.xy + input.uv * u.terrain.z, u.terrain.w) - u.terrain.w;' : ''}
|
|
69
|
+
let featureVertex = f32(vertexIndex)${material.instanced ? ' + input.instanceOffset.w' : ''};
|
|
70
|
+
let highlighted = featureVertex >= u.highlight.x && featureVertex < u.highlight.y;
|
|
71
|
+
output.color = ${material.vertexColors ? 'select(input.color, vec3<f32>(72.0 / 255.0, 217.0 / 255.0, 1.0), highlighted)' : 'u.baseColor.rgb'};
|
|
72
|
+
// Inverse-transpose from cofactors; the camera view matrix is orthonormal.
|
|
73
|
+
let m = mat3x3<f32>(u.worldMatrix[0].xyz, u.worldMatrix[1].xyz, u.worldMatrix[2].xyz);
|
|
74
|
+
${stroke.normal}
|
|
75
|
+
let normal = (cross(m[1], m[2]) * sourceNormal.x + cross(m[2], m[0]) * sourceNormal.y + cross(m[0], m[1]) * sourceNormal.z) / determinant(m);
|
|
76
|
+
output.normal = (frame.viewMatrix * vec4<f32>(normal, 0.0)).xyz;
|
|
77
|
+
let world = u.worldMatrix * vec4<f32>(position, 1.0);
|
|
78
|
+
output.shadowPosition = solar.matrix * world;
|
|
79
|
+
output.worldPosition = world.xyz / world.w;
|
|
80
|
+
${sparkle ? `output.localPosition = input.position${instanceOffset};` : ''}
|
|
81
|
+
let viewPosition = frame.viewMatrix * world;
|
|
82
|
+
output.viewPosition = viewPosition.xyz;
|
|
83
|
+
${textured ? 'output.uv = input.uv;' : ''}
|
|
84
|
+
${hasRoof ? roofVertexShader(material) : ''}
|
|
85
|
+
output.position = frame.projectionMatrix * viewPosition;
|
|
86
|
+
return output;
|
|
87
|
+
}
|
|
88
|
+
`;
|
|
89
|
+
}
|
|
@@ -1,13 +1,13 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Generate optional native-stroke position and normal vertex snippets.
|
|
3
|
-
*
|
|
4
|
-
* @param {Object} material Material settings.
|
|
5
|
-
*
|
|
6
|
-
* @returns {Object} WGSL position and normal snippets.
|
|
7
|
-
*/
|
|
8
|
-
export function nativeStrokeShader(material) {
|
|
9
|
-
return /* alloc */ {
|
|
10
|
-
position: material.nativeStroke ? 'position = input.normal + (input.position - input.normal) * u.nativeStroke.x;' : '',
|
|
11
|
-
normal: material.nativeStroke ? 'let sourceNormal = vec3<f32>(0.0, 1.0, 0.0);' : 'let sourceNormal = input.normal;',
|
|
12
|
-
};
|
|
13
|
-
}
|
|
1
|
+
/**
|
|
2
|
+
* Generate optional native-stroke position and normal vertex snippets.
|
|
3
|
+
*
|
|
4
|
+
* @param {Object} material Material settings.
|
|
5
|
+
*
|
|
6
|
+
* @returns {Object} WGSL position and normal snippets.
|
|
7
|
+
*/
|
|
8
|
+
export function nativeStrokeShader(material) {
|
|
9
|
+
return /* alloc */ {
|
|
10
|
+
position: material.nativeStroke ? 'position = input.normal + (input.position - input.normal) * u.nativeStroke.x;' : '',
|
|
11
|
+
normal: material.nativeStroke ? 'let sourceNormal = vec3<f32>(0.0, 1.0, 0.0);' : 'let sourceNormal = input.normal;',
|
|
12
|
+
};
|
|
13
|
+
}
|
|
@@ -1,16 +1,16 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Generate vertex code for roof and wall texture coordinates and opacity.
|
|
3
|
-
*
|
|
4
|
-
* @param {Object} material Roof and wall texture settings.
|
|
5
|
-
*
|
|
6
|
-
* @returns {string} WGSL vertex code.
|
|
7
|
-
*/
|
|
8
|
-
export function roofVertexShader(material) {
|
|
9
|
-
const roofOpacity = Number(material.roofTexture ?? 0);
|
|
10
|
-
const wallOpacity = Number(material.wallTexture ?? 0);
|
|
11
|
-
return /* wgsl */ `
|
|
12
|
-
output.roofUv = (frame.roofMatrix * world).xz;
|
|
13
|
-
output.roof = select(0.0, select(${wallOpacity.toFixed(8)}, ${roofOpacity.toFixed(8)}, input.normal.y >= 0.5), ((${Boolean(material.roofTexture)} && input.normal.y >= 0.5) ||
|
|
14
|
-
(${Boolean(material.wallTexture)} && abs(input.normal.y) < 0.5)) && !highlighted);
|
|
15
|
-
`;
|
|
16
|
-
}
|
|
1
|
+
/**
|
|
2
|
+
* Generate vertex code for roof and wall texture coordinates and opacity.
|
|
3
|
+
*
|
|
4
|
+
* @param {Object} material Roof and wall texture settings.
|
|
5
|
+
*
|
|
6
|
+
* @returns {string} WGSL vertex code.
|
|
7
|
+
*/
|
|
8
|
+
export function roofVertexShader(material) {
|
|
9
|
+
const roofOpacity = Number(material.roofTexture ?? 0);
|
|
10
|
+
const wallOpacity = Number(material.wallTexture ?? 0);
|
|
11
|
+
return /* wgsl */ `
|
|
12
|
+
output.roofUv = (frame.roofMatrix * world).xz;
|
|
13
|
+
output.roof = select(0.0, select(${wallOpacity.toFixed(8)}, ${roofOpacity.toFixed(8)}, input.normal.y >= 0.5), ((${Boolean(material.roofTexture)} && input.normal.y >= 0.5) ||
|
|
14
|
+
(${Boolean(material.wallTexture)} && abs(input.normal.y) < 0.5)) && !highlighted);
|
|
15
|
+
`;
|
|
16
|
+
}
|
|
@@ -1,19 +1,19 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Check a mesh against its cached shadow state and pending attribute updates.
|
|
3
|
-
*
|
|
4
|
-
* @param {Object} cache Shadow cache containing mesh snapshots.
|
|
5
|
-
* @param {Object} mesh Mesh to compare.
|
|
6
|
-
*
|
|
7
|
-
* @returns {boolean} Whether the mesh still matches its snapshot.
|
|
8
|
-
*/
|
|
9
|
-
export function shadowMeshMatches(cache, mesh) {
|
|
10
|
-
const previous = cache.meshes.get(mesh), range = mesh.geometry.drawRange;
|
|
11
|
-
if (!(previous && previous.world === mesh._worldMatrixVersion && previous.geometry === mesh.geometry &&
|
|
12
|
-
previous.start === range.start && previous.count === range.count &&
|
|
13
|
-
previous.appearance === (mesh._appearance ?? 1))) return false;
|
|
14
|
-
let attribute;
|
|
15
|
-
for (attribute of Object.values(mesh.geometry.attributes)) {
|
|
16
|
-
if (attribute.needsUpdate) return false;
|
|
17
|
-
}
|
|
18
|
-
return true;
|
|
19
|
-
}
|
|
1
|
+
/**
|
|
2
|
+
* Check a mesh against its cached shadow state and pending attribute updates.
|
|
3
|
+
*
|
|
4
|
+
* @param {Object} cache Shadow cache containing mesh snapshots.
|
|
5
|
+
* @param {Object} mesh Mesh to compare.
|
|
6
|
+
*
|
|
7
|
+
* @returns {boolean} Whether the mesh still matches its snapshot.
|
|
8
|
+
*/
|
|
9
|
+
export function shadowMeshMatches(cache, mesh) {
|
|
10
|
+
const previous = cache.meshes.get(mesh), range = mesh.geometry.drawRange;
|
|
11
|
+
if (!(previous && previous.world === mesh._worldMatrixVersion && previous.geometry === mesh.geometry &&
|
|
12
|
+
previous.start === range.start && previous.count === range.count &&
|
|
13
|
+
previous.appearance === (mesh._appearance ?? 1))) return false;
|
|
14
|
+
let attribute;
|
|
15
|
+
for (attribute of Object.values(mesh.geometry.attributes)) {
|
|
16
|
+
if (attribute.needsUpdate) return false;
|
|
17
|
+
}
|
|
18
|
+
return true;
|
|
19
|
+
}
|
|
@@ -1,23 +1,23 @@
|
|
|
1
|
-
import { buildAreaFeature } from './buildAreaFeature.js';
|
|
2
|
-
|
|
3
|
-
/**
|
|
4
|
-
* Process features in time-limited batches, stopping if the area request is aborted.
|
|
5
|
-
*
|
|
6
|
-
* @param {Object} context Area build context.
|
|
7
|
-
* @param {Object} area Area state and abort controller.
|
|
8
|
-
* @param {Array<Object>} features GeoJSON features to process.
|
|
9
|
-
*
|
|
10
|
-
* @returns {Promise<void>} Completion of feature processing.
|
|
11
|
-
*/
|
|
12
|
-
export async function buildAreaFeatures(context, area, features) {
|
|
13
|
-
let deadline = performance.now() + 4, feature;
|
|
14
|
-
for (feature of features) {
|
|
15
|
-
if (area.request.signal.aborted) return;
|
|
16
|
-
if (performance.now() >= deadline) {
|
|
17
|
-
await /* alloc */ new Promise(requestAnimationFrame);
|
|
18
|
-
if (area.request.signal.aborted) return;
|
|
19
|
-
deadline = performance.now() + 4;
|
|
20
|
-
}
|
|
21
|
-
buildAreaFeature(context, feature);
|
|
22
|
-
}
|
|
23
|
-
}
|
|
1
|
+
import { buildAreaFeature } from './buildAreaFeature.js';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Process features in time-limited batches, stopping if the area request is aborted.
|
|
5
|
+
*
|
|
6
|
+
* @param {Object} context Area build context.
|
|
7
|
+
* @param {Object} area Area state and abort controller.
|
|
8
|
+
* @param {Array<Object>} features GeoJSON features to process.
|
|
9
|
+
*
|
|
10
|
+
* @returns {Promise<void>} Completion of feature processing.
|
|
11
|
+
*/
|
|
12
|
+
export async function buildAreaFeatures(context, area, features) {
|
|
13
|
+
let deadline = performance.now() + 4, feature;
|
|
14
|
+
for (feature of features) {
|
|
15
|
+
if (area.request.signal.aborted) return;
|
|
16
|
+
if (performance.now() >= deadline) {
|
|
17
|
+
await /* alloc */ new Promise(requestAnimationFrame);
|
|
18
|
+
if (area.request.signal.aborted) return;
|
|
19
|
+
deadline = performance.now() + 4;
|
|
20
|
+
}
|
|
21
|
+
buildAreaFeature(context, feature);
|
|
22
|
+
}
|
|
23
|
+
}
|
|
@@ -1,21 +1,21 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Evaluate and validate a feature's extrusion style.
|
|
3
|
-
*
|
|
4
|
-
* @param {L.Layer} layer Source layer with a style function.
|
|
5
|
-
* @param {Object} feature GeoJSON feature.
|
|
6
|
-
*
|
|
7
|
-
* @returns {Object|null} Valid style, or null to skip the feature.
|
|
8
|
-
*
|
|
9
|
-
* @throws {Error} If the style is neither an object nor null.
|
|
10
|
-
* @throws {Error} If extrusion heights do not satisfy top > bottom >= 0.
|
|
11
|
-
*/
|
|
12
|
-
export function extrusionStyle(layer, feature) {
|
|
13
|
-
const style = layer.options.style(feature);
|
|
14
|
-
if (style === null) return null;
|
|
15
|
-
if (!style || typeof style !== 'object') throw /* alloc */ new Error('style must return an extrusion style or null');
|
|
16
|
-
const { top, bottom = 0 } = style;
|
|
17
|
-
if (!Number.isFinite(top) || !Number.isFinite(bottom) || bottom < 0 || top <= bottom) {
|
|
18
|
-
throw /* alloc */ new Error('Invalid extrusion heights: expected top > bottom >= 0');
|
|
19
|
-
}
|
|
20
|
-
return style;
|
|
21
|
-
}
|
|
1
|
+
/**
|
|
2
|
+
* Evaluate and validate a feature's extrusion style.
|
|
3
|
+
*
|
|
4
|
+
* @param {L.Layer} layer Source layer with a style function.
|
|
5
|
+
* @param {Object} feature GeoJSON feature.
|
|
6
|
+
*
|
|
7
|
+
* @returns {Object|null} Valid style, or null to skip the feature.
|
|
8
|
+
*
|
|
9
|
+
* @throws {Error} If the style is neither an object nor null.
|
|
10
|
+
* @throws {Error} If extrusion heights do not satisfy top > bottom >= 0.
|
|
11
|
+
*/
|
|
12
|
+
export function extrusionStyle(layer, feature) {
|
|
13
|
+
const style = layer.options.style(feature);
|
|
14
|
+
if (style === null) return null;
|
|
15
|
+
if (!style || typeof style !== 'object') throw /* alloc */ new Error('style must return an extrusion style or null');
|
|
16
|
+
const { top, bottom = 0 } = style;
|
|
17
|
+
if (!Number.isFinite(top) || !Number.isFinite(bottom) || bottom < 0 || top <= bottom) {
|
|
18
|
+
throw /* alloc */ new Error('Invalid extrusion heights: expected top > bottom >= 0');
|
|
19
|
+
}
|
|
20
|
+
return style;
|
|
21
|
+
}
|
|
@@ -1,21 +1,21 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Return the point or first polygon coordinate used to assign a feature to an area.
|
|
3
|
-
*
|
|
4
|
-
* @param {Object} feature GeoJSON feature.
|
|
5
|
-
* @param {boolean} nightLight Whether point geometry is required for a night light.
|
|
6
|
-
*
|
|
7
|
-
* @returns {Array<number>} Anchor coordinates in longitude, latitude order.
|
|
8
|
-
*
|
|
9
|
-
* @throws {Error} If a night-light feature is not a point.
|
|
10
|
-
* @throws {Error} If the geometry type is unsupported.
|
|
11
|
-
* @throws {Error} If anchor coordinates are not finite.
|
|
12
|
-
*/
|
|
13
|
-
export function featureAnchor(feature, nightLight) {
|
|
14
|
-
const geometry = feature?.geometry, point = geometry?.type === 'Point';
|
|
15
|
-
if (nightLight && !point) throw /* alloc */ new Error('Night lights require Point geometry');
|
|
16
|
-
if (geometry?.type !== 'Polygon' && geometry?.type !== 'MultiPolygon' && !point) throw /* alloc */ new Error('Unsupported GeoJSON geometry');
|
|
17
|
-
const coordinates = point ? geometry.coordinates :
|
|
18
|
-
geometry.type === 'Polygon' ? geometry.coordinates[0]?.[0] : geometry.coordinates[0]?.[0]?.[0];
|
|
19
|
-
if (!Number.isFinite(coordinates?.[0]) || !Number.isFinite(coordinates?.[1])) throw /* alloc */ new Error('Invalid GeoJSON coordinates');
|
|
20
|
-
return coordinates;
|
|
21
|
-
}
|
|
1
|
+
/**
|
|
2
|
+
* Return the point or first polygon coordinate used to assign a feature to an area.
|
|
3
|
+
*
|
|
4
|
+
* @param {Object} feature GeoJSON feature.
|
|
5
|
+
* @param {boolean} nightLight Whether point geometry is required for a night light.
|
|
6
|
+
*
|
|
7
|
+
* @returns {Array<number>} Anchor coordinates in longitude, latitude order.
|
|
8
|
+
*
|
|
9
|
+
* @throws {Error} If a night-light feature is not a point.
|
|
10
|
+
* @throws {Error} If the geometry type is unsupported.
|
|
11
|
+
* @throws {Error} If anchor coordinates are not finite.
|
|
12
|
+
*/
|
|
13
|
+
export function featureAnchor(feature, nightLight) {
|
|
14
|
+
const geometry = feature?.geometry, point = geometry?.type === 'Point';
|
|
15
|
+
if (nightLight && !point) throw /* alloc */ new Error('Night lights require Point geometry');
|
|
16
|
+
if (geometry?.type !== 'Polygon' && geometry?.type !== 'MultiPolygon' && !point) throw /* alloc */ new Error('Unsupported GeoJSON geometry');
|
|
17
|
+
const coordinates = point ? geometry.coordinates :
|
|
18
|
+
geometry.type === 'Polygon' ? geometry.coordinates[0]?.[0] : geometry.coordinates[0]?.[0]?.[0];
|
|
19
|
+
if (!Number.isFinite(coordinates?.[0]) || !Number.isFinite(coordinates?.[1])) throw /* alloc */ new Error('Invalid GeoJSON coordinates');
|
|
20
|
+
return coordinates;
|
|
21
|
+
}
|
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Read the projected point's ground offset, defaulting to zero.
|
|
3
|
-
*
|
|
4
|
-
* @param {Object} point Projected point.
|
|
5
|
-
*
|
|
6
|
-
* @returns {number} Ground offset.
|
|
7
|
-
*/
|
|
8
|
-
export function groundOffset(point) {
|
|
9
|
-
return point.ground || 0;
|
|
1
|
+
/**
|
|
2
|
+
* Read the projected point's ground offset, defaulting to zero.
|
|
3
|
+
*
|
|
4
|
+
* @param {Object} point Projected point.
|
|
5
|
+
*
|
|
6
|
+
* @returns {number} Ground offset.
|
|
7
|
+
*/
|
|
8
|
+
export function groundOffset(point) {
|
|
9
|
+
return point.ground || 0;
|
|
10
10
|
}
|