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,10 @@
|
|
|
1
|
+
import { mapCameraState } from '../constants/mapCameraState.js';
|
|
2
|
+
import { project } from './project.js';
|
|
3
|
+
|
|
4
|
+
export function mapLimitOffset(offset, bounds) {
|
|
5
|
+
if (!bounds || !this.getPitch() && !this.getBearing()) return mapCameraState.mapMethods._limitOffset.call(this, offset, bounds);
|
|
6
|
+
const half = this.getSize().divideBy(2), ground = half.subtract(project(this, half.subtract(offset), true));
|
|
7
|
+
const center = this.project(this.getCenter());
|
|
8
|
+
const limited = this.project(this._limitCenter(this.unproject(center.add(ground)), this.getZoom(), bounds));
|
|
9
|
+
return half.subtract(project(this, half.subtract(limited.subtract(center))));
|
|
10
|
+
}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { project } from './project.js';
|
|
2
|
+
import { pointOf } from './pointOf.js';
|
|
3
|
+
import { mapCameraState } from '../constants/mapCameraState.js';
|
|
4
|
+
|
|
5
|
+
export function mapPanBy(offset, options) {
|
|
6
|
+
const half = this.getSize().divideBy(2);
|
|
7
|
+
const ground = half.subtract(project(this, half.subtract(pointOf(offset)), true));
|
|
8
|
+
return mapCameraState.mapMethods.panBy.call(this, ground, options);
|
|
9
|
+
}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { mapCameraState } from '../constants/mapCameraState.js';
|
|
2
|
+
import { pointOf } from './pointOf.js';
|
|
3
|
+
|
|
4
|
+
export function mapPanInside(latlng, options = {}) {
|
|
5
|
+
if (!this.getPitch() && !this.getBearing()) return mapCameraState.mapMethods.panInside.call(this, latlng, options);
|
|
6
|
+
const min = pointOf(options.paddingTopLeft || options.padding || [0, 0]);
|
|
7
|
+
const max = this.getSize().subtract(pointOf(options.paddingBottomRight || options.padding || [0, 0]));
|
|
8
|
+
const screen = this.latLngToContainerPoint(latlng);
|
|
9
|
+
const safe = new L.Point(Math.max(min.x, Math.min(max.x, screen.x)),
|
|
10
|
+
Math.max(min.y, Math.min(max.y, screen.y)));
|
|
11
|
+
if (safe.equals(screen)) return this;
|
|
12
|
+
const delta = this.latLngToLayerPoint(latlng).subtract(this.containerPointToLayerPoint(safe));
|
|
13
|
+
return this.panTo(this.unproject(this.project(this.getCenter()).add(delta)), options);
|
|
14
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export function mapResetNorth(options = { animate: true }) { return this.setBearing(0, options); }
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export function mapResetNorthPitch(options = { animate: true }) { return this._animateCamera(0, 0, options); }
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export function mapSetBearing(bearing, options) { return this._animateCamera(this.getPitch(), bearing, options); }
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export function mapSetPitch(pitch, options) { return this._animateCamera(pitch, this.getBearing(), options); }
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { updateSky } from './updateSky.js';
|
|
2
|
+
|
|
3
|
+
export function mapSetPitchAndBearing(pitch, bearing) {
|
|
4
|
+
if (!Number.isFinite(pitch) || !Number.isFinite(bearing)) throw new TypeError('Camera angles must be finite numbers');
|
|
5
|
+
const previousPitch = this.getPitch(), previousBearing = this.getBearing();
|
|
6
|
+
this._cameraPitch = Math.max(0, Math.min(85, pitch));
|
|
7
|
+
this._cameraBearing = ((bearing % 360) + 360) % 360;
|
|
8
|
+
if (this._loaded) {
|
|
9
|
+
updateSky.call(this);
|
|
10
|
+
if (previousBearing !== this.getBearing()) this.fire('rotate', { bearing: this.getBearing() });
|
|
11
|
+
if (previousPitch !== this.getPitch()) this.fire('pitch', { pitch: this.getPitch() });
|
|
12
|
+
}
|
|
13
|
+
return this;
|
|
14
|
+
}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { mapCameraState } from '../constants/mapCameraState.js';
|
|
2
|
+
|
|
3
|
+
export function mapSetZoomAround(latlng, zoom, options) {
|
|
4
|
+
if (!this.getPitch() && !this.getBearing()) return mapCameraState.mapMethods.setZoomAround.call(this, latlng, zoom, options);
|
|
5
|
+
zoom = this._limitZoom(zoom);
|
|
6
|
+
const scale = this.getZoomScale(zoom), half = this.getSize().divideBy(2);
|
|
7
|
+
const screen = latlng instanceof L.Point ? latlng : this.latLngToContainerPoint(latlng);
|
|
8
|
+
const center = this.containerPointToLayerPoint(half), anchor = this.containerPointToLayerPoint(screen);
|
|
9
|
+
const next = center.add(anchor.subtract(center).multiplyBy(1 - 1 / scale));
|
|
10
|
+
return this.setView(this.layerPointToLatLng(next), zoom, { zoom: options });
|
|
11
|
+
}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { mapCameraState } from '../constants/mapCameraState.js';
|
|
2
|
+
|
|
3
|
+
export function mapTryAnimatedPan(center, options) {
|
|
4
|
+
// Leaflet's geographic recentering already supplies ground pixels, not screen pixels.
|
|
5
|
+
const offset = this._getCenterOffset(center)._trunc();
|
|
6
|
+
if (options?.animate !== true && !this.getSize().contains(offset)) return false;
|
|
7
|
+
mapCameraState.mapMethods.panBy.call(this, offset, options);
|
|
8
|
+
return true;
|
|
9
|
+
}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { pointOf } from './pointOf.js';
|
|
2
|
+
import { angles } from './angles.js';
|
|
3
|
+
|
|
4
|
+
export function project(map, point, inverse = false, limit = false) {
|
|
5
|
+
const half = map.getSize().divideBy(2), distance = map.getSize().y * 1.5;
|
|
6
|
+
if (!distance) return pointOf(point);
|
|
7
|
+
const [cos, sin, tilt, rise] = angles(map);
|
|
8
|
+
const p = pointOf(point).subtract(half);
|
|
9
|
+
if (inverse) {
|
|
10
|
+
const far = map.getSize().y * map.options.pitchMaxDistance;
|
|
11
|
+
const denominator = tilt * distance + rise * p.y;
|
|
12
|
+
let v = denominator > 0 ? p.y * distance / denominator : -far;
|
|
13
|
+
if (limit) v = Math.max(-far, Math.min(far, v));
|
|
14
|
+
const u = p.x * (distance - rise * v) / distance;
|
|
15
|
+
return new L.Point(cos * u + sin * v, -sin * u + cos * v).add(half);
|
|
16
|
+
}
|
|
17
|
+
const u = cos * p.x - sin * p.y, v = sin * p.x + cos * p.y;
|
|
18
|
+
const scale = distance / (distance - rise * v);
|
|
19
|
+
return new L.Point(u * scale, tilt * v * scale).add(half);
|
|
20
|
+
}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import { mapCameraState } from '../constants/mapCameraState.js';
|
|
2
|
+
import { scheduleCameraAnimation } from './scheduleCameraAnimation.js';
|
|
3
|
+
|
|
4
|
+
export function runCameraAnimations(now) {
|
|
5
|
+
mapCameraState.cameraAnimationFrame = null;
|
|
6
|
+
const pending = [...mapCameraState.cameraAnimations];
|
|
7
|
+
mapCameraState.cameraAnimations.clear();
|
|
8
|
+
let failure;
|
|
9
|
+
let map, animation, progress, eased;
|
|
10
|
+
for ([map, animation] of pending) {
|
|
11
|
+
map._cameraFrame = null;
|
|
12
|
+
if (map._cameraAnimation !== animation) continue;
|
|
13
|
+
progress = animation.duration
|
|
14
|
+
? Math.min(1, (now - animation.start) / (animation.duration * 1000)) : 1;
|
|
15
|
+
eased = 1 - (1 - progress) ** 3;
|
|
16
|
+
try {
|
|
17
|
+
map._setPitchAndBearing(
|
|
18
|
+
animation.fromPitch + (Math.max(0, Math.min(85, animation.pitch)) - animation.fromPitch) * eased,
|
|
19
|
+
animation.fromBearing + animation.delta * eased,
|
|
20
|
+
);
|
|
21
|
+
if (progress < 1 && map._cameraAnimation === animation) scheduleCameraAnimation(map, animation);
|
|
22
|
+
else if (map._cameraAnimation === animation) map._cameraAnimation = null;
|
|
23
|
+
} catch (error) {
|
|
24
|
+
failure ||= error;
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
if (failure) throw failure;
|
|
28
|
+
}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { mapCameraState } from '../constants/mapCameraState.js';
|
|
2
|
+
import { runCameraAnimations } from './runCameraAnimations.js';
|
|
3
|
+
|
|
4
|
+
export function scheduleCameraAnimation(map, animation) {
|
|
5
|
+
mapCameraState.cameraAnimations.set(map, animation);
|
|
6
|
+
if (mapCameraState.cameraAnimationFrame === null) mapCameraState.cameraAnimationFrame = requestAnimationFrame(runCameraAnimations);
|
|
7
|
+
map._cameraFrame = mapCameraState.cameraAnimationFrame;
|
|
8
|
+
}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { mapCameraState } from '../constants/mapCameraState.js';
|
|
2
|
+
|
|
3
|
+
export function updateSky() {
|
|
4
|
+
const height = this.getSize().y, pitch = this.getPitch() * mapCameraState.radians;
|
|
5
|
+
const far = height * this.options.pitchMaxDistance, distance = height * 1.5;
|
|
6
|
+
const top = height / 2 - far * Math.cos(pitch) * distance / (distance + Math.sin(pitch) * far);
|
|
7
|
+
if (top > 0 && !this._pitchSky) {
|
|
8
|
+
this._pitchSky = L.DomUtil.create('div', 'leaflet-pitch-sky', this.getContainer());
|
|
9
|
+
this._pitchSky.setAttribute('aria-hidden', 'true');
|
|
10
|
+
this._pitchSky.style.cssText = 'position:absolute;inset:0 0 auto;height:0;z-index:0;pointer-events:none;background:var(--leaflet-sky-background,linear-gradient(#9ec5e8,#dfe9f0))';
|
|
11
|
+
}
|
|
12
|
+
if (this._pitchSky) {
|
|
13
|
+
this._pitchSky.style.height = `${Math.max(0, Math.ceil(top))}px`;
|
|
14
|
+
this._pitchSky.style.display = top > 0 ? '' : 'none';
|
|
15
|
+
}
|
|
16
|
+
}
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
import { CELL } from '../constants/CELL.js';
|
|
2
|
+
import { colliders } from '../constants/colliders.js';
|
|
3
|
+
|
|
4
|
+
|
|
5
|
+
export function collider(mesh) {
|
|
6
|
+
let c = colliders.get(mesh.geometry);
|
|
7
|
+
if (c) return c;
|
|
8
|
+
const m = mesh.worldMatrix, { position: { data: p }, index, normal, uv } = mesh.geometry.attributes;
|
|
9
|
+
|
|
10
|
+
const count = index ? index.count : p.length / 3, tri = [], nrm = [], cells = new Map(), v = [];
|
|
11
|
+
|
|
12
|
+
let i, first, k, j, x, y, z, ex, ey, ez, fx, fy, fz, nx, nz, ny, length, a, h, t, ix, iz, key;
|
|
13
|
+
for (i = 0; i < count; i += 3) {
|
|
14
|
+
first = index ? index.data[i] : i;
|
|
15
|
+
// Streetlight halos (uv.x <= 2, see scene/picking.js) are light, not matter.
|
|
16
|
+
if (mesh.program.nightLight && uv && uv.data[first * 2] <= 2) {
|
|
17
|
+
continue;
|
|
18
|
+
}
|
|
19
|
+
for (k = 0; k < 3; k++) {
|
|
20
|
+
j = (index ? index.data[i + k] : i + k) * 3, x = p[j], y = p[j + 1], z = p[j + 2];
|
|
21
|
+
v[k * 3] = m[0] * x + m[4] * y + m[8] * z + m[12];
|
|
22
|
+
v[k * 3 + 1] = m[1] * x + m[5] * y + m[9] * z + m[13];
|
|
23
|
+
v[k * 3 + 2] = m[2] * x + m[6] * y + m[10] * z + m[14];
|
|
24
|
+
}
|
|
25
|
+
ex = v[3] - v[0], ey = v[4] - v[1], ez = v[5] - v[2], fx = v[6] - v[0], fy = v[7] - v[1], fz = v[8] - v[2];
|
|
26
|
+
|
|
27
|
+
nx = ey * fz - ez * fy, nz = ex * fy - ey * fx;
|
|
28
|
+
|
|
29
|
+
ny = ez * fx - ex * fz, length = Math.hypot(nx, ny, nz);
|
|
30
|
+
|
|
31
|
+
if (!length || Math.abs(ny) > 0.9 * length) {
|
|
32
|
+
continue;
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
if (normal) {
|
|
36
|
+
// The stored normal tells the outside, whatever the winding.
|
|
37
|
+
j = first * 3, a = normal.data;
|
|
38
|
+
if ((m[0] * a[j] + m[4] * a[j + 1] + m[8] * a[j + 2]) * nx + (m[2] * a[j] + m[6] * a[j + 1] + m[10] * a[j + 2]) * nz < 0) { nx = -nx; nz = -nz; }
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
h = Math.hypot(nx, nz), t = nrm.length / 2;
|
|
42
|
+
|
|
43
|
+
tri.push(...v);
|
|
44
|
+
nrm.push(nx / h, nz / h);
|
|
45
|
+
|
|
46
|
+
for (ix = Math.floor(Math.min(v[0], v[3], v[6]) / CELL); ix <= Math.floor(Math.max(v[0], v[3], v[6]) / CELL); ix++)
|
|
47
|
+
for (iz = Math.floor(Math.min(v[2], v[5], v[8]) / CELL); iz <= Math.floor(Math.max(v[2], v[5], v[8]) / CELL); iz++) {
|
|
48
|
+
key = ix + ',' + iz;
|
|
49
|
+
if (!cells.has(key)) {
|
|
50
|
+
cells.set(key, []);
|
|
51
|
+
}
|
|
52
|
+
cells.get(key).push(t);
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
c = {
|
|
56
|
+
tri: Float32Array.from(tri),
|
|
57
|
+
nrm: Float32Array.from(nrm),
|
|
58
|
+
cells,
|
|
59
|
+
origin: [m[12], m[13], m[14]]
|
|
60
|
+
};
|
|
61
|
+
colliders.set(mesh.geometry, c);
|
|
62
|
+
return c;
|
|
63
|
+
}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
// Möller-Trumbore for the horizontal ray (ox, oy, oz) + d·(dx, 0, dz) against triangle t; returns d or -1.
|
|
2
|
+
export function horizontalRay(v, t, ox, oy, oz, dx, dz) {
|
|
3
|
+
const i = t * 9, ex = v[i + 3] - v[i], ey = v[i + 4] - v[i + 1], ez = v[i + 5] - v[i + 2];
|
|
4
|
+
const fx = v[i + 6] - v[i], fy = v[i + 7] - v[i + 1], fz = v[i + 8] - v[i + 2];
|
|
5
|
+
const px = -dz * fy, py = dz * fx - dx * fz, pz = dx * fy, det = ex * px + ey * py + ez * pz;
|
|
6
|
+
if (Math.abs(det) < 1e-9) return -1;
|
|
7
|
+
const tx = ox - v[i], ty = oy - v[i + 1], tz = oz - v[i + 2], u = (tx * px + ty * py + tz * pz) / det;
|
|
8
|
+
if (u < 0 || u > 1) return -1;
|
|
9
|
+
const qx = ty * ez - tz * ey, qy = tz * ex - tx * ez, qz = tx * ey - ty * ex, w = (dx * qx + dz * qz) / det;
|
|
10
|
+
if (w < 0 || u + w > 1) return -1;
|
|
11
|
+
return (fx * qx + fy * qy + fz * qz) / det;
|
|
12
|
+
}
|
|
@@ -0,0 +1,133 @@
|
|
|
1
|
+
import { computeBounds } from "../geometry/computeBounds.js";
|
|
2
|
+
import { sub } from '../geometry/sub.js';
|
|
3
|
+
import { cross } from '../geometry/cross.js';
|
|
4
|
+
import { dot } from '../geometry/dot.js';
|
|
5
|
+
import { sortHits } from './sortHits.js';
|
|
6
|
+
|
|
7
|
+
/** Nearest triangle hit per mesh, sorted by world-space distance. */
|
|
8
|
+
|
|
9
|
+
export function intersectMeshes(ray, meshes, night = 0) {
|
|
10
|
+
const hits = [],
|
|
11
|
+
a = [0, 0, 0],
|
|
12
|
+
b = [0, 0, 0],
|
|
13
|
+
c = [0, 0, 0];
|
|
14
|
+
let mesh, inverse, inverseValues, value, localOrigin, origin, localDirection, direction;
|
|
15
|
+
let directionLength, near, far, i, a2, b2, position, index, instanceOffset, vertices, closest;
|
|
16
|
+
let faceIndex, vertex, offset, x, y, z, ai, bi, ci, e, f, p, det, t, u, q, v, uv, ids, x2, y2;
|
|
17
|
+
let distance, point, worldPoint;
|
|
18
|
+
for (mesh of meshes) {
|
|
19
|
+
// Test in mesh-local space; compare distances only after returning to shared world space.
|
|
20
|
+
inverse = new DOMMatrix(mesh.worldMatrix).inverse();
|
|
21
|
+
inverseValues = inverse.toFloat64Array();
|
|
22
|
+
for (value of inverseValues) {
|
|
23
|
+
if (!Number.isFinite(value)) throw new Error('Singular 3D transform');
|
|
24
|
+
}
|
|
25
|
+
localOrigin = new DOMPoint(...ray.origin, 1).matrixTransform(inverse);
|
|
26
|
+
origin = [
|
|
27
|
+
localOrigin.x / localOrigin.w,
|
|
28
|
+
localOrigin.y / localOrigin.w,
|
|
29
|
+
localOrigin.z / localOrigin.w
|
|
30
|
+
];
|
|
31
|
+
localDirection = new DOMPoint(...ray.direction, 0).matrixTransform(inverse);
|
|
32
|
+
direction = [
|
|
33
|
+
localDirection.x,
|
|
34
|
+
localDirection.y,
|
|
35
|
+
localDirection.z
|
|
36
|
+
];
|
|
37
|
+
directionLength = Math.hypot(...direction) || 1;
|
|
38
|
+
direction[0] /= directionLength;
|
|
39
|
+
direction[1] /= directionLength;
|
|
40
|
+
direction[2] /= directionLength;
|
|
41
|
+
// AABB slab test reuses the same local ray as the triangle test.
|
|
42
|
+
if (!mesh.geometry.bounds) {
|
|
43
|
+
computeBounds(mesh.geometry);
|
|
44
|
+
}
|
|
45
|
+
near = 0, far = Infinity;
|
|
46
|
+
for (i = 0; i < 3; i++) {
|
|
47
|
+
if (Math.abs(direction[i]) < 1e-12) {
|
|
48
|
+
if (origin[i] < mesh.geometry.bounds.min[i] || origin[i] > mesh.geometry.bounds.max[i]) {
|
|
49
|
+
far = -Infinity;
|
|
50
|
+
break;
|
|
51
|
+
}
|
|
52
|
+
} else {
|
|
53
|
+
a2 = (mesh.geometry.bounds.min[i] - origin[i]) / direction[i], b2 = (mesh.geometry.bounds.max[i] - origin[i]) / direction[i];
|
|
54
|
+
near = Math.max(near, Math.min(a2, b2));
|
|
55
|
+
far = Math.min(far, Math.max(a2, b2));
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
if (far < near) {
|
|
59
|
+
continue;
|
|
60
|
+
}
|
|
61
|
+
({ position, index, instanceOffset } = mesh.geometry.attributes);
|
|
62
|
+
vertices = index?.count || position.count;
|
|
63
|
+
closest = Infinity, faceIndex = void 0;
|
|
64
|
+
for (i = 0; i < vertices * (instanceOffset?.count ?? 1); i += 3) {
|
|
65
|
+
vertex = instanceOffset ? i % vertices : i;
|
|
66
|
+
offset = instanceOffset ? Math.floor(i / vertices) * instanceOffset.size : 0;
|
|
67
|
+
x = instanceOffset?.data[offset] ?? 0;
|
|
68
|
+
y = instanceOffset?.data[offset + 1] ?? 0;
|
|
69
|
+
z = instanceOffset?.data[offset + 2] ?? 0;
|
|
70
|
+
ai = (index ? index.data[vertex] : vertex) * position.size;
|
|
71
|
+
bi = (index ? index.data[vertex + 1] : vertex + 1) * position.size;
|
|
72
|
+
ci = (index ? index.data[vertex + 2] : vertex + 2) * position.size;
|
|
73
|
+
a[0] = position.data[ai];
|
|
74
|
+
a[1] = position.data[ai + 1];
|
|
75
|
+
a[2] = position.data[ai + 2];
|
|
76
|
+
b[0] = position.data[bi];
|
|
77
|
+
b[1] = position.data[bi + 1];
|
|
78
|
+
b[2] = position.data[bi + 2];
|
|
79
|
+
c[0] = position.data[ci];
|
|
80
|
+
c[1] = position.data[ci + 1];
|
|
81
|
+
c[2] = position.data[ci + 2];
|
|
82
|
+
if (instanceOffset) {
|
|
83
|
+
a[0] = Math.fround(a[0] + x); a[1] = Math.fround(a[1] + y); a[2] = Math.fround(a[2] + z);
|
|
84
|
+
b[0] = Math.fround(b[0] + x); b[1] = Math.fround(b[1] + y); b[2] = Math.fround(b[2] + z);
|
|
85
|
+
c[0] = Math.fround(c[0] + x); c[1] = Math.fround(c[1] + y); c[2] = Math.fround(c[2] + z);
|
|
86
|
+
}
|
|
87
|
+
// Moller-Trumbore: barycentric triangle coordinates and local ray distance.
|
|
88
|
+
e = sub(b, a), f = sub(c, a), p = cross(direction, f), det = dot(e, p);
|
|
89
|
+
if (mesh.program.cullMode === 'none' || mesh.program.cullFace === null
|
|
90
|
+
? Math.abs(det) < 1e-9 : det < 1e-9) {
|
|
91
|
+
continue;
|
|
92
|
+
}
|
|
93
|
+
t = sub(origin, a), u = dot(t, p) / det;
|
|
94
|
+
if (u < 0 || u > 1) {
|
|
95
|
+
continue;
|
|
96
|
+
}
|
|
97
|
+
q = cross(t, e), v = dot(direction, q) / det;
|
|
98
|
+
if (v < 0 || u + v > 1) {
|
|
99
|
+
continue;
|
|
100
|
+
}
|
|
101
|
+
if (mesh.program.nightLight) {
|
|
102
|
+
uv = mesh.geometry.attributes.uv.data;
|
|
103
|
+
ids = index ? [index.data[i], index.data[i + 1], index.data[i + 2]] : [i, i + 1, i + 2];
|
|
104
|
+
x2 = uv[ids[0] * 2] * (1 - u - v) + uv[ids[1] * 2] * u + uv[ids[2] * 2] * v;
|
|
105
|
+
y2 = uv[ids[0] * 2 + 1] * (1 - u - v) + uv[ids[1] * 2 + 1] * u + uv[ids[2] * 2 + 1] * v;
|
|
106
|
+
if (x2 <= 2 && (!night || x2 * x2 + y2 * y2 > 0.9)) continue;
|
|
107
|
+
}
|
|
108
|
+
distance = dot(f, q) / det;
|
|
109
|
+
if (distance > 0 && distance < closest) {
|
|
110
|
+
closest = distance; faceIndex = i / 3;
|
|
111
|
+
}
|
|
112
|
+
}
|
|
113
|
+
if (faceIndex === undefined) continue;
|
|
114
|
+
point = new DOMPoint(
|
|
115
|
+
direction[0] * closest + origin[0],
|
|
116
|
+
direction[1] * closest + origin[1],
|
|
117
|
+
direction[2] * closest + origin[2],
|
|
118
|
+
1
|
|
119
|
+
).matrixTransform(new DOMMatrix(mesh.worldMatrix));
|
|
120
|
+
worldPoint = [point.x / point.w, point.y / point.w, point.z / point.w];
|
|
121
|
+
hits.push({
|
|
122
|
+
faceIndex,
|
|
123
|
+
object: mesh,
|
|
124
|
+
point: worldPoint,
|
|
125
|
+
distance: Math.hypot(
|
|
126
|
+
worldPoint[0] - ray.origin[0],
|
|
127
|
+
worldPoint[1] - ray.origin[1],
|
|
128
|
+
worldPoint[2] - ray.origin[2]
|
|
129
|
+
)
|
|
130
|
+
});
|
|
131
|
+
}
|
|
132
|
+
return sortHits(hits);
|
|
133
|
+
}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
export function sortHits(hits) {
|
|
2
|
+
const buffer = new Array(hits.length);
|
|
3
|
+
let source = hits, target = buffer;
|
|
4
|
+
let width, start, middle, end, left, right, output, previous, i;
|
|
5
|
+
for (width = 1; width < hits.length; width *= 2) {
|
|
6
|
+
for (start = 0; start < hits.length; start += width * 2) {
|
|
7
|
+
middle = Math.min(start + width, hits.length), end = Math.min(start + width * 2, hits.length);
|
|
8
|
+
left = start, right = middle;
|
|
9
|
+
for (output = start; output < end; output++) {
|
|
10
|
+
if (left < middle && (right >= end || !(source[right].distance < source[left].distance))) {
|
|
11
|
+
target[output] = source[left++];
|
|
12
|
+
} else {
|
|
13
|
+
target[output] = source[right++];
|
|
14
|
+
}
|
|
15
|
+
}
|
|
16
|
+
}
|
|
17
|
+
previous = source;
|
|
18
|
+
source = target;
|
|
19
|
+
target = previous;
|
|
20
|
+
}
|
|
21
|
+
if (source !== hits) for (i = 0; i < hits.length; i++) hits[i] = source[i];
|
|
22
|
+
return hits;
|
|
23
|
+
}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { containerResizeAddHooks } from '../controls/containerResizeAddHooks.js';
|
|
2
|
+
import { containerResizeRemoveHooks } from '../controls/containerResizeRemoveHooks.js';
|
|
3
|
+
|
|
4
|
+
export const ContainerResize = L.Handler.extend({
|
|
5
|
+
addHooks: containerResizeAddHooks,
|
|
6
|
+
removeHooks: containerResizeRemoveHooks,
|
|
7
|
+
});
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export const HEIGHT = 8;
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { pitchDragAddHooks } from '../controls/pitchDragAddHooks.js';
|
|
2
|
+
import { pitchDragRemoveHooks } from '../controls/pitchDragRemoveHooks.js';
|
|
3
|
+
|
|
4
|
+
export const PitchDrag = L.Handler.extend({
|
|
5
|
+
addHooks: pitchDragAddHooks,
|
|
6
|
+
removeHooks: pitchDragRemoveHooks,
|
|
7
|
+
});
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { shiftRotateAddHooks } from '../controls/shiftRotateAddHooks.js';
|
|
2
|
+
import { shiftRotateRemoveHooks } from '../controls/shiftRotateRemoveHooks.js';
|
|
3
|
+
|
|
4
|
+
export const ShiftRotate = L.Handler.extend({
|
|
5
|
+
addHooks: shiftRotateAddHooks,
|
|
6
|
+
removeHooks: shiftRotateRemoveHooks,
|
|
7
|
+
});
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export const TILE_RADIUS = 6;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export const TILE_SIZE = 256;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export const sizes = { SCALAR: 1, VEC2: 2, VEC3: 3, VEC4: 4 };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export const attachState = {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export const cameraControlsState = {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export const dark = [0.08, 0.07, 0.06];
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* WGSL twin of getElevation for the vertex shader: bilinear DEM pixels, or the first valid
|
|
3
|
+
* neighbour near no-data (stored as -1e9), else `base`. Expects `dem: texture_2d<f32>`.
|
|
4
|
+
*/
|
|
5
|
+
export const elevationWGSL = /* wgsl */ `
|
|
6
|
+
fn demSample(pixel: vec2<i32>) -> f32 {
|
|
7
|
+
if (any(pixel < vec2<i32>(0)) || any(pixel >= vec2<i32>(textureDimensions(dem)))) { return -1e9; }
|
|
8
|
+
return textureLoad(dem, pixel, 0).r;
|
|
9
|
+
}
|
|
10
|
+
fn elevation(pixel: vec2<f32>, base: f32) -> f32 {
|
|
11
|
+
let p = pixel - vec2<f32>(0.5);
|
|
12
|
+
let f = fract(p);
|
|
13
|
+
let i = vec2<i32>(floor(p));
|
|
14
|
+
let v00 = demSample(i);
|
|
15
|
+
let v10 = demSample(i + vec2<i32>(1, 0));
|
|
16
|
+
let v01 = demSample(i + vec2<i32>(0, 1));
|
|
17
|
+
let v11 = demSample(i + vec2<i32>(1, 1));
|
|
18
|
+
if (v00 > -1000.0 && v10 > -1000.0 && v01 > -1000.0 && v11 > -1000.0) {
|
|
19
|
+
return mix(mix(v00, v10, f.x), mix(v01, v11, f.x), f.y);
|
|
20
|
+
}
|
|
21
|
+
if (v00 > -1000.0) { return v00; }
|
|
22
|
+
if (v10 > -1000.0) { return v10; }
|
|
23
|
+
if (v01 > -1000.0) { return v01; }
|
|
24
|
+
if (v11 > -1000.0) { return v11; }
|
|
25
|
+
return base;
|
|
26
|
+
}
|
|
27
|
+
`;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export const glass = [0.12, 0.15, 0.18];
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export const headlight = [1.9, 1.85, 1.7];
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export const hull = [[-5.5, 30], [5.5, 30], [5.5, -20], [4, -26], [1.5, -30], [-1.5, -30], [-4, -26], [-5.5, -20]];
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export const indexState = {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export const mapCameraState = {};
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
// W/S (↑/↓) run forward/back along the heading, A/D (←/→) turn: [forward, turn].
|
|
2
|
+
export const moves = {
|
|
3
|
+
KeyW: [1, 0],
|
|
4
|
+
ArrowUp: [1, 0],
|
|
5
|
+
KeyS: [-1, 0],
|
|
6
|
+
ArrowDown: [-1, 0],
|
|
7
|
+
KeyD: [0, 1],
|
|
8
|
+
ArrowRight: [0, 1],
|
|
9
|
+
KeyA: [0, -1],
|
|
10
|
+
ArrowLeft: [0, -1]
|
|
11
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export const nativeEventMaps = new WeakMap();
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export const nativeLayerState = {};
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import { nativeSetLatLng } from '../core/nativeSetLatLng.js';
|
|
2
|
+
import { nativeSetLatLngs } from '../core/nativeSetLatLngs.js';
|
|
3
|
+
import { nativeAddLatLng } from '../core/nativeAddLatLng.js';
|
|
4
|
+
import { nativeSetRadius } from '../core/nativeSetRadius.js';
|
|
5
|
+
import { nativeSetStyle } from '../core/nativeSetStyle.js';
|
|
6
|
+
import { nativeRedraw } from '../core/nativeRedraw.js';
|
|
7
|
+
import { nativeSetIcon } from '../core/nativeSetIcon.js';
|
|
8
|
+
import { nativeSetUrl } from '../core/nativeSetUrl.js';
|
|
9
|
+
import { nativeSetBounds } from '../core/nativeSetBounds.js';
|
|
10
|
+
import { nativeSetOpacity } from '../core/nativeSetOpacity.js';
|
|
11
|
+
import { nativeSetZIndex } from '../core/nativeSetZIndex.js';
|
|
12
|
+
import { nativeSetZIndexOffset } from '../core/nativeSetZIndexOffset.js';
|
|
13
|
+
import { nativeBringToFront } from '../core/nativeBringToFront.js';
|
|
14
|
+
import { nativeBringToBack } from '../core/nativeBringToBack.js';
|
|
15
|
+
|
|
16
|
+
export const nativeMethodHandlers = {
|
|
17
|
+
setLatLng: nativeSetLatLng,
|
|
18
|
+
setLatLngs: nativeSetLatLngs,
|
|
19
|
+
addLatLng: nativeAddLatLng,
|
|
20
|
+
setRadius: nativeSetRadius,
|
|
21
|
+
setStyle: nativeSetStyle,
|
|
22
|
+
redraw: nativeRedraw,
|
|
23
|
+
setIcon: nativeSetIcon,
|
|
24
|
+
setUrl: nativeSetUrl,
|
|
25
|
+
setBounds: nativeSetBounds,
|
|
26
|
+
setOpacity: nativeSetOpacity,
|
|
27
|
+
setZIndex: nativeSetZIndex,
|
|
28
|
+
setZIndexOffset: nativeSetZIndexOffset,
|
|
29
|
+
bringToFront: nativeBringToFront,
|
|
30
|
+
bringToBack: nativeBringToBack,
|
|
31
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export const onMapChangeState = {};
|