leaflet-city-mapper 0.0.4 → 0.0.6
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 +23 -11
- package/cucumber.mjs +9 -9
- package/dist/leaflet-city-mapper-src.js +3546 -2493
- package/dist/leaflet-city-mapper-src.js.map +4 -4
- package/dist/leaflet-city-mapper-worker-src.js +955 -0
- package/dist/leaflet-city-mapper-worker-src.js.map +7 -0
- package/dist/leaflet-city-mapper-worker.js +2 -0
- package/dist/leaflet-city-mapper-worker.js.map +7 -0
- package/dist/leaflet-city-mapper.js +3 -3
- package/dist/leaflet-city-mapper.js.map +4 -4
- package/libs/leaflet-lens.js +15 -3
- package/libs/leaflet.js +1 -1
- package/package.json +3 -2
- package/src/{camera → animations}/cancelCameraAnimation.js +5 -3
- package/src/{core → animations}/cancelGridFade.js +3 -2
- package/src/animations/endZoom.js +27 -0
- package/src/{camera → animations}/mapAnimateCamera.js +7 -5
- package/src/{scene → animations}/onZoomAnim.js +5 -4
- package/src/{scene → animations}/renderPendingZoomAnimation.js +4 -2
- package/src/{camera → animations}/runCameraAnimations.js +8 -6
- package/src/{core → animations}/runGridFades.js +4 -3
- package/src/{camera → animations}/scheduleCameraAnimation.js +3 -2
- package/src/animations/scheduleGridFade.js +16 -0
- package/src/{scene → animations}/startZoom.js +3 -2
- package/src/{rendering → animations}/synchronizeZoomView.js +10 -8
- package/src/{rendering → animations}/updateZoomCamera.js +11 -8
- package/src/archives/decodeDirectory.js +1 -1
- package/src/archives/findTile.js +3 -3
- package/src/archives/getDirectoryEntries.js +5 -4
- package/src/archives/getHeader.js +10 -6
- package/src/archives/getTileData.js +3 -3
- package/src/archives/getZxy.js +8 -7
- package/src/archives/loadDirectory.js +3 -3
- package/src/archives/loadSource.js +3 -2
- package/src/archives/{read.js → readArchiveRange.js} +7 -5
- package/src/camera/cameraMapReady.js +3 -2
- package/src/camera/cleanupCameraMap.js +8 -6
- package/src/camera/fitCameraBounds.js +3 -3
- package/src/camera/initializeCameraMap.js +6 -4
- package/src/camera/mapCamera.js +1 -1
- package/src/camera/mapContainerPointToLayerPoint.js +2 -2
- package/src/camera/mapGetBearing.js +3 -2
- package/src/camera/mapGetBounds.js +2 -2
- package/src/camera/mapGetBoundsZoom.js +2 -2
- package/src/camera/mapGetPitch.js +3 -2
- package/src/camera/mapLayerPointToContainerPoint.js +2 -2
- package/src/camera/mapLimitCenter.js +1 -1
- package/src/camera/mapLimitOffset.js +1 -1
- package/src/camera/mapPanBy.js +2 -2
- package/src/camera/mapPanInside.js +1 -1
- package/src/camera/mapResetNorthPitch.js +1 -1
- package/src/camera/mapSetBearing.js +1 -1
- package/src/camera/mapSetPitch.js +1 -1
- package/src/camera/mapSetPitchAndBearing.js +5 -3
- package/src/{rendering → camera}/updateMapCamera.js +19 -15
- package/src/{scene/updateCamera.js → camera/updateSceneCamera.js} +1 -1
- package/src/camera/updateSky.js +10 -9
- package/src/collision/collectIntersections.js +16 -0
- package/src/collision/collider.js +24 -9
- package/src/collision/countCrossings.js +15 -0
- package/src/collision/insideMesh.js +33 -0
- package/src/collision/insideWalker.js +46 -0
- package/src/collision/readTriangle.js +7 -4
- package/src/collision/setTrafficNormal.js +9 -0
- package/src/collision/trafficCollision.js +55 -0
- package/src/collision/vertexCount.js +3 -0
- package/src/{utils → colors}/parseColor.js +1 -1
- package/src/controls/addCameraHandler.js +5 -3
- package/src/controls/adjustCameraDrag.js +4 -3
- package/src/controls/cameraControls.js +14 -5
- package/src/controls/cameraDragClick.js +7 -7
- package/src/controls/cameraDragContextMenu.js +1 -1
- package/src/controls/cameraDragDown.js +2 -2
- package/src/controls/cameraDragEnd.js +1 -1
- package/src/controls/cameraDragMove.js +2 -2
- package/src/controls/changeCameraTouch.js +6 -3
- package/src/controls/cleanupCameraTouch.js +7 -5
- package/src/controls/dragCamera.js +1 -1
- package/src/controls/endCameraTouchEvent.js +1 -1
- package/src/controls/moveCameraTouch.js +5 -3
- package/src/controls/removeCameraDrag.js +1 -1
- package/src/controls/shiftRotateWheel.js +1 -1
- package/src/controls/startCameraTouch.js +6 -4
- package/src/core/adjustCameraMarkerPan.js +3 -3
- package/src/core/cameraCircleBounds.js +1 -1
- package/src/core/cameraMarkerDrag.js +1 -1
- package/src/core/cameraMarkerOnDrag.js +1 -1
- package/src/core/closestCameraLayerPoint.js +1 -1
- package/src/core/initializeGridContainer.js +1 -1
- package/src/core/initializeNativeLayer.js +9 -8
- package/src/core/layerCallInitHooks.js +4 -3
- package/src/core/markerSetIcon.js +1 -1
- package/src/core/markerSetPos.js +2 -2
- package/src/core/markerSetRotation.js +1 -1
- package/src/core/markerUpdateZIndex.js +5 -4
- package/src/core/popupAdjustPan.js +1 -1
- package/src/core/popupUpdatePosition.js +1 -1
- package/src/core/redrawPath.js +1 -1
- package/src/core/removeLayer.js +4 -3
- package/src/core/tooltipSetPosition.js +1 -1
- package/src/core/updateGridOpacity.js +3 -3
- package/src/core/whenReady.js +11 -0
- package/src/geometry/addBridges.js +13 -8
- package/src/{sources → geometry}/addGeneratedTriangle.js +1 -1
- package/src/{sources/addTriangle.js → geometry/appendAreaTriangle.js} +5 -5
- package/src/geometry/assembleAreaGeometry.js +41 -0
- package/src/{core → geometry}/boundsQuad.js +1 -1
- package/src/geometry/bridgePolygon.js +3 -3
- package/src/geometry/buildExtrudedPolygon.js +10 -0
- package/src/geometry/buildProjectedPoint.js +21 -0
- package/src/{sources/buildAreaPolygon.js → geometry/buildProjectedPolygon.js} +25 -29
- package/src/geometry/circleGeometry.js +1 -1
- package/src/geometry/computeBounds.js +19 -8
- package/src/geometry/conformModelToTerrain.js +17 -11
- package/src/{models → geometry}/createModelGeometry.js +5 -4
- package/src/geometry/disk.js +1 -1
- package/src/geometry/indexBridge.js +5 -4
- package/src/geometry/lampPostGeometry.js +2 -2
- package/src/geometry/lightGeometry.js +1 -1
- package/src/geometry/lineJoin.js +1 -1
- package/src/{core → geometry}/markerQuadCorners.js +9 -6
- package/src/geometry/nativeGeometry.js +1 -1
- package/src/geometry/polygon.js +1 -1
- package/src/geometry/roofCoverage.js +11 -8
- package/src/geometry/roofFootprint.js +13 -10
- package/src/geometry/segment.js +1 -1
- package/src/{shadows → geometry}/shadowBounds.js +1 -1
- package/src/geometry/surface.js +1 -1
- package/src/{terrain → geometry}/terrainBuffers.js +7 -5
- package/src/geometry/terrainTileGeometry.js +19 -0
- package/src/geometry/treeGeometry.js +2 -2
- package/src/globals/geometryWorkerUrl.js +3 -0
- package/src/globals/nativeMethodHandlers.js +14 -14
- package/src/{scene → gpu}/initializeRendererResources.js +10 -9
- package/src/gpu/initializeSharedRenderer.js +52 -0
- package/src/gpu/mountRenderer.js +26 -0
- package/src/{scene → gpu}/releaseRenderer.js +2 -2
- package/src/gpu/rendererDeviceError.js +16 -0
- package/src/gpu/rendererDeviceLost.js +16 -0
- package/src/{rendering/reportCompilation.js → gpu/reportShaderCompilation.js} +3 -3
- package/src/gpu/requestAdapter.js +12 -0
- package/src/gpu/requestDevice.js +9 -0
- package/src/index.js +8 -13
- package/src/layer-controls/layerCountTitle.js +6 -0
- package/src/layer-controls/renderLayerCount.js +20 -0
- package/src/{scene → layer-controls}/updateLayerCount.js +24 -22
- package/src/lighting/lightGrid.js +1 -1
- package/src/lighting/updatePointLights.js +13 -10
- package/src/{rendering → materials}/createProgram.js +13 -12
- package/src/{models/materialFor.js → materials/modelMaterialFor.js} +3 -3
- package/src/materials/terrainRasterProgram.js +58 -0
- package/src/models/applyModelTransform.js +8 -7
- package/src/models/createModelContext.js +3 -3
- package/src/models/loadModel.js +17 -12
- package/src/models/loadModelResources.js +7 -6
- package/src/models/modelNode.js +4 -5
- package/src/{core → native}/disposeNativeLayer.js +10 -10
- package/src/{core → native}/handleNativeMapEvent.js +5 -4
- package/src/{core → native}/initNativeGPU.js +9 -6
- package/src/native/isCurrentNativeLayer.js +7 -0
- package/src/{core → native}/nativeEventSource.js +3 -3
- package/src/{core → native}/nativeEvents.js +1 -1
- package/src/{core → native}/nativeLayer.js +16 -37
- package/src/{core → native}/nativeLayerMethod.js +14 -5
- package/src/{core → native}/pruneNativeResources.js +5 -5
- package/src/{core → native}/putNativeMesh.js +3 -3
- package/src/{core → native}/quadNativeMesh.js +1 -1
- package/src/native/readyNativeGPU.js +10 -0
- package/src/{core → native}/refreshNativeLayer.js +8 -7
- package/src/{core → native}/refreshNativeLayerContract.js +3 -2
- package/src/{core → native}/removeNativeEvents.js +1 -1
- package/src/{core → native}/removeTargets.js +3 -2
- package/src/native/reorderNativeLayer.js +17 -0
- package/src/{core → native}/styleNativeMesh.js +3 -2
- package/src/{core → native}/syncGridLayer.js +1 -1
- package/src/{core → native}/syncImageOverlay.js +1 -1
- package/src/{core → native}/syncMarker.js +1 -1
- package/src/{core → native}/syncVectorLayer.js +2 -2
- package/src/{core → native}/synchronizeNativeLayer.js +4 -3
- package/src/native/updateNativeLayerView.js +10 -0
- package/src/picking/findFeature.js +13 -9
- package/src/picking/hit.js +16 -8
- package/src/picking/onClick.js +3 -2
- package/src/picking/onPointerLeave.js +3 -2
- package/src/picking/onPointerMove.js +12 -6
- package/src/picking/raycast.js +29 -24
- package/src/picking/setHighlight.js +9 -8
- package/src/picking/shouldSkipOther.js +3 -2
- package/src/picking/showFeature.js +19 -14
- package/src/{camera/angles.js → projections/cameraAngles.js} +2 -2
- package/src/{camera → projections}/groundBounds.js +2 -2
- package/src/projections/localPosition.js +11 -0
- package/src/{camera/project.js → projections/projectCameraPoint.js} +2 -2
- package/src/{sources → projections}/projectRing.js +8 -9
- package/src/projections/projectTreePoint.js +17 -0
- package/src/{camera/animationPoint.js → projections/transformZoomAnimationPoint.js} +3 -2
- package/src/projections/walkerLocalPosition.js +18 -0
- package/src/raster/addRasterTile.js +38 -28
- package/src/raster/createRasterMesh.js +24 -19
- package/src/raster/finishRasterAttachment.js +17 -0
- package/src/raster/finishRasterTile.js +22 -19
- package/src/raster/initRaster.js +24 -15
- package/src/raster/isRasterLoading.js +8 -0
- package/src/raster/loadRasterTile.js +8 -7
- package/src/raster/onPMTileAdd.js +9 -8
- package/src/raster/onPMTileRemove.js +6 -5
- package/src/raster/pruneRasterTiles.js +19 -13
- package/src/raster/pumpRasterTiles.js +8 -6
- package/src/raster/readyRaster.js +3 -2
- package/src/raster/registerTerrainTile.js +8 -6
- package/src/raster/releaseRasterTile.js +14 -11
- package/src/raster/releaseRasterTiles.js +13 -10
- package/src/raster/removeRasterTile.js +8 -6
- package/src/raster/retainRasterTiles.js +5 -4
- package/src/raster/setPMTileOpacity.js +4 -4
- package/src/raster/setPMTileZIndex.js +4 -4
- package/src/raster/setRasterOpacity.js +8 -6
- package/src/raster/setRasterTerrain.js +12 -9
- package/src/raster/setRasterZIndex.js +8 -6
- package/src/raster/updateAttachedTiles.js +6 -5
- package/src/raster/updateRasterTiles.js +20 -15
- package/src/rendering/collectFrameMeshes.js +16 -9
- package/src/rendering/collectVisibleMesh.js +18 -9
- package/src/rendering/createMesh.js +11 -9
- package/src/rendering/disposeMesh.js +3 -3
- package/src/rendering/drawGeometry.js +9 -7
- package/src/rendering/drawSceneMeshes.js +9 -7
- package/src/rendering/prepareFrameBuffer.js +6 -5
- package/src/rendering/prepareFrameMeshes.js +9 -6
- package/src/rendering/prepareFrameUniforms.js +9 -6
- package/src/rendering/prepareMeshUniforms.js +1 -1
- package/src/rendering/render.js +39 -32
- package/src/rendering/resizeRenderer.js +17 -15
- package/src/rendering/revealRoofMesh.js +25 -6
- package/src/scene/{layerLayerAdd.js → addRegisteredLayer.js} +13 -9
- package/src/scene/addSceneLayer.js +4 -3
- package/src/scene/attachLayer.js +7 -6
- package/src/scene/attachSharedScene.js +69 -0
- package/src/scene/callLayer.js +7 -5
- package/src/scene/cancelUpdate.js +6 -5
- package/src/scene/failAttachment.js +6 -5
- package/src/scene/get3DEvents.js +5 -3
- package/src/scene/getLocation.js +3 -2
- package/src/scene/init3D.js +28 -26
- package/src/scene/initializeLayer.js +6 -4
- package/src/scene/isNativeLayer.js +3 -2
- package/src/scene/layerInitialize.js +11 -6
- package/src/scene/onAdd3DLayer.js +30 -24
- package/src/scene/onMapChange.js +5 -4
- package/src/scene/onRemove3DLayer.js +53 -35
- package/src/scene/ready3D.js +22 -13
- package/src/scene/releaseSharedScene.js +31 -25
- package/src/scene/removeLayerEvents.js +12 -9
- package/src/scene/removeSceneLayer.js +3 -2
- package/src/scene/renderPendingMapChange.js +7 -4
- package/src/scene/renderPendingUpdates.js +9 -6
- package/src/scene/restoreObject.js +15 -13
- package/src/scene/scheduleSceneUpdate.js +25 -0
- package/src/shaders/materialShaders.js +2 -2
- package/src/shadows/bindSunlight.js +4 -3
- package/src/shadows/drawShadowMeshes.js +4 -3
- package/src/shadows/renderSunlight.js +6 -5
- package/src/shadows/resizeSunlight.js +7 -6
- package/src/shadows/shadowMatrix.js +2 -2
- package/src/sources/attachAreaMesh.js +25 -20
- package/src/sources/buildArea.js +21 -22
- package/src/sources/buildAreaFeature.js +16 -10
- package/src/sources/buildAreaFeatures.js +14 -0
- package/src/sources/buildAreaPoint.js +3 -21
- package/src/sources/extrusionStyle.js +2 -2
- package/src/sources/initializeGeoJSON.js +3 -2
- package/src/sources/matchesAreaTile.js +7 -0
- package/src/sources/pendingSourceAreas.js +3 -2
- package/src/sources/prepareAreaGeometryJob.js +24 -0
- package/src/sources/projectAreaPolygons.js +15 -0
- package/src/sources/pumpSourceAreas.js +37 -0
- package/src/sources/releaseArea.js +10 -8
- package/src/sources/setGeoJSONData.js +4 -3
- package/src/sources/sourceAreaContext.js +18 -17
- package/src/sources/updateArea.js +25 -21
- package/src/sources/{updateStatus.js → updateSourceStatus.js} +5 -4
- package/src/sunlight/{addTo.js → addTimeControlToMap.js} +1 -1
- package/src/sunlight/addTimeLayer.js +3 -2
- package/src/sunlight/atmosphere.js +2 -2
- package/src/sunlight/initSunlight.js +5 -5
- package/src/sunlight/{initialize.js → initializeTimeControl.js} +5 -3
- package/src/sunlight/onAddSun.js +5 -4
- package/src/sunlight/onRemoveSun.js +1 -1
- package/src/sunlight/removeSun.js +7 -5
- package/src/sunlight/removeTimeLayer.js +3 -2
- package/src/sunlight/requestSunlightRender.js +9 -0
- package/src/sunlight/updateCelestialDisc.js +1 -1
- package/src/sunlight/updateSky.js +4 -2
- package/src/sunlight/updateSun.js +8 -6
- package/src/sunlight/useSelectedTime.js +4 -3
- package/src/terrain/applyTerrain.js +16 -13
- package/src/terrain/clearLayerTerrain.js +3 -2
- package/src/terrain/getElevation.js +9 -5
- package/src/terrain/initTerrain.js +11 -6
- package/src/terrain/loadTerrain.js +29 -20
- package/src/terrain/loadTerrainTiles.js +4 -3
- package/src/terrain/mapElevationOf.js +7 -0
- package/src/terrain/onTerrainAdd.js +14 -10
- package/src/terrain/onTerrainChange.js +4 -3
- package/src/terrain/onTerrainRemove.js +35 -21
- package/src/terrain/readyTerrainOf.js +7 -0
- package/src/terrain/setLayerTerrain.js +3 -2
- package/src/terrain/setTerrainHeight.js +19 -14
- package/src/terrain/terrainElevation.js +1 -1
- package/src/terrain/terrainTileQueue.js +11 -9
- package/src/{core → textures}/addImageState.js +1 -1
- package/src/{core/addRasterImage.js → textures/attachRasterImage.js} +1 -1
- package/src/{rendering → textures}/collectRoofTiles.js +3 -2
- package/src/{rendering → textures}/composeRoofAtlas.js +9 -7
- package/src/textures/destroyTexture.js +10 -0
- package/src/{models/textureFor.js → textures/modelTextureFor.js} +5 -4
- package/src/{core → textures}/nativeImageError.js +1 -1
- package/src/{core → textures}/nativeImageRefresh.js +2 -2
- package/src/{core/textureFor.js → textures/nativeTextureFor.js} +7 -6
- package/src/{rendering → textures}/rebuildRoofAtlas.js +12 -9
- package/src/{core → textures}/removeImageState.js +1 -1
- package/src/{rendering → textures}/resizeRoofTexture.js +5 -4
- package/src/textures/updateRoofAtlas.js +23 -0
- package/src/textures/updateRoofRaster.js +29 -0
- package/src/{core → textures}/uploadCanvasTexture.js +2 -2
- package/src/traffic/addTraffic.js +1 -1
- package/src/traffic/disposeTrafficObject.js +5 -3
- package/src/traffic/drawTrafficRoute.js +1 -1
- package/src/traffic/groundTraffic.js +6 -6
- package/src/traffic/initTraffic.js +3 -3
- package/src/traffic/loadedTrafficLanes.js +1 -1
- package/src/traffic/locateTraffic.js +3 -3
- package/src/traffic/placeTraffic.js +2 -1
- package/src/traffic/prepareTraffic.js +4 -3
- package/src/traffic/rebaseTraffic.js +3 -2
- package/src/traffic/rebuildTrafficMesh.js +1 -1
- package/src/traffic/removeTraffic.js +1 -1
- package/src/traffic/startTraffic.js +1 -1
- package/src/traffic/tickTraffic.js +4 -3
- package/src/traffic/trafficNow.js +3 -2
- package/src/traffic/updateTraffic.js +3 -2
- package/src/traffic/updateTrafficLights.js +4 -2
- package/src/vehicles/boatBenches.js +1 -1
- package/src/vehicles/boatModel.js +1 -1
- package/src/vehicles/busModel.js +1 -1
- package/src/vehicles/carModel.js +1 -1
- package/src/vehicles/metroModel.js +1 -1
- package/src/vehicles/tramModel.js +1 -1
- package/src/walk/{step.js → animateWalker.js} +15 -19
- package/src/walk/createWalk.js +15 -11
- package/src/walk/initWalk.js +4 -4
- package/src/walk/landWalker.js +38 -0
- package/src/walk/moveWalker.js +5 -4
- package/src/walk/{onAdd.js → onAddWalkControl.js} +3 -1
- package/src/walk/{onRemove.js → onRemoveWalkControl.js} +1 -1
- package/src/walk/{onKey.js → onWalkKey.js} +1 -1
- package/src/walk/{onTerrain.js → onWalkTerrain.js} +1 -1
- package/src/walk/{place.js → placeWalker.js} +2 -2
- package/src/walk/resolveWalkerPosition.js +28 -0
- package/src/walk/{start.js → startWalking.js} +8 -5
- package/src/walk/{stop.js → stopWalking.js} +4 -4
- package/src/walk/{toggle.js → toggleWalking.js} +2 -2
- package/src/walk/updateWalkerFrame.js +19 -0
- package/src/weakmaps/addedByLayer.js +1 -0
- package/src/weakmaps/archiveHeaderByLayer.js +1 -0
- package/src/weakmaps/areasByLayer.js +1 -0
- package/src/weakmaps/bridgeMeshByLayer.js +1 -0
- package/src/weakmaps/bridgesByLayer.js +1 -0
- package/src/weakmaps/cameraAnimationByMap.js +1 -0
- package/src/weakmaps/cameraBearingByMap.js +1 -0
- package/src/weakmaps/cameraByLayer.js +1 -0
- package/src/weakmaps/cameraDraggableByMap.js +1 -0
- package/src/weakmaps/cameraFields.js +37 -0
- package/src/weakmaps/cameraFrameByMap.js +1 -0
- package/src/weakmaps/cameraHandlersByMap.js +1 -0
- package/src/weakmaps/cameraMaps.js +1 -0
- package/src/weakmaps/cameraPitchByMap.js +1 -0
- package/src/weakmaps/cameraReadyByMap.js +1 -0
- package/src/weakmaps/cameraTouchStateByMap.js +1 -0
- package/src/weakmaps/cameraViewByMap.js +1 -0
- package/src/weakmaps/cameraZIndexOffsetByLayer.js +1 -0
- package/src/weakmaps/containerByLayer.js +1 -0
- package/src/weakmaps/controlByLayer.js +1 -0
- package/src/weakmaps/countStatusByLayer.js +1 -0
- package/src/weakmaps/cursorByLayer.js +1 -0
- package/src/weakmaps/demByLayer.js +1 -0
- package/src/weakmaps/directoriesByLayer.js +1 -0
- package/src/weakmaps/etagByLayer.js +1 -0
- package/src/weakmaps/eventMapByLayer.js +1 -0
- package/src/weakmaps/eventsByLayer.js +1 -0
- package/src/weakmaps/fadeFrameByLayer.js +1 -0
- package/src/weakmaps/fadeVersionByLayer.js +1 -0
- package/src/weakmaps/frameByLayer.js +1 -0
- package/src/weakmaps/geojsonByLayer.js +1 -0
- package/src/weakmaps/geometryWorkersByMap.js +1 -0
- package/src/weakmaps/groupByLayer.js +1 -0
- package/src/weakmaps/headerByLayer.js +1 -0
- package/src/weakmaps/highlightedFeatureByLayer.js +1 -0
- package/src/weakmaps/hoveredFeatureByLayer.js +1 -0
- package/src/weakmaps/inflightByLayer.js +1 -0
- package/src/weakmaps/kindByLayer.js +1 -0
- package/src/weakmaps/layersByLayer.js +1 -0
- package/src/weakmaps/loadingTilesByLayer.js +1 -0
- package/src/weakmaps/locationByLayer.js +1 -0
- package/src/weakmaps/modelByLayer.js +1 -0
- package/src/weakmaps/modelUrlByLayer.js +1 -0
- package/src/weakmaps/nativeGPUBackByMap.js +1 -0
- package/src/weakmaps/nativeGPUByLayer.js +1 -0
- package/src/weakmaps/nativeGPUOrderByMap.js +1 -0
- package/src/weakmaps/pitchSkyByMap.js +1 -0
- package/src/weakmaps/pointerEventsByLayer.js +1 -0
- package/src/weakmaps/pruneAfterByLayer.js +1 -0
- package/src/weakmaps/pruneVersionByLayer.js +1 -0
- package/src/weakmaps/pruneWantedByLayer.js +1 -0
- package/src/weakmaps/queuedByLayer.js +1 -0
- package/src/weakmaps/rasterGeometryByLayer.js +1 -0
- package/src/weakmaps/rasterProgramByLayer.js +1 -0
- package/src/weakmaps/rasterTilesByLayer.js +1 -0
- package/src/weakmaps/rasterVersionByLayer.js +1 -0
- package/src/weakmaps/raycasterByLayer.js +1 -0
- package/src/weakmaps/readyByLayer.js +1 -0
- package/src/weakmaps/rendererByLayer.js +1 -0
- package/src/weakmaps/rendererReadyByLayer.js +1 -0
- package/src/weakmaps/roofRasterByLayer.js +1 -0
- package/src/weakmaps/roofRastersByLayer.js +1 -0
- package/src/weakmaps/rootByLayer.js +1 -0
- package/src/weakmaps/rotateControlByMap.js +1 -0
- package/src/weakmaps/sceneFields.js +159 -0
- package/src/weakmaps/sceneLayers.js +1 -0
- package/src/weakmaps/sceneOriginByLayer.js +1 -0
- package/src/weakmaps/shadowMeshesByLayer.js +1 -0
- package/src/weakmaps/sharedByLayer.js +1 -0
- package/src/weakmaps/sizeByLayer.js +1 -0
- package/src/weakmaps/state3dByLayer.js +1 -0
- package/src/weakmaps/sunlightByMap.js +1 -0
- package/src/weakmaps/terrain3DByLayer.js +1 -0
- package/src/weakmaps/terrain3DByMap.js +1 -0
- package/src/weakmaps/terrainArchiveByLayer.js +1 -0
- package/src/weakmaps/terrainBaseYByLayer.js +1 -0
- package/src/weakmaps/terrainBoundsByLayer.js +1 -0
- package/src/weakmaps/terrainControllerByLayer.js +1 -0
- package/src/weakmaps/terrainGridsByLayer.js +1 -0
- package/src/weakmaps/terrainLoadingByLayer.js +1 -0
- package/src/weakmaps/terrainOriginElevationByLayer.js +1 -0
- package/src/weakmaps/terrainPromiseByLayer.js +1 -0
- package/src/weakmaps/terrainReadyByLayer.js +1 -0
- package/src/weakmaps/terrainRequestByLayer.js +1 -0
- package/src/weakmaps/terrainSourceByLayer.js +1 -0
- package/src/weakmaps/terrainTilesByLayer.js +1 -0
- package/src/weakmaps/terrainZoomByLayer.js +1 -0
- package/src/weakmaps/tileZoomByLayer.js +1 -0
- package/src/weakmaps/timeControlByMap.js +1 -0
- package/src/weakmaps/tooltipByLayer.js +1 -0
- package/src/weakmaps/touchPitchByMap.js +1 -0
- package/src/weakmaps/touchRotateByMap.js +1 -0
- package/src/weakmaps/typeByLayer.js +1 -0
- package/src/weakmaps/urlByLayer.js +1 -0
- package/src/weakmaps/visibleMeshesByLayer.js +1 -0
- package/src/weakmaps/walkerByLayer.js +1 -0
- package/src/weakmaps/wantedRasterTilesByLayer.js +1 -0
- package/src/weakmaps/zoomLevelByLayer.js +1 -0
- package/src/weakmaps/zoomTransitionsByLayer.js +1 -0
- package/src/weakmaps/zoomViewByLayer.js +1 -0
- package/src/workers/acquireGeometryWorker.js +29 -0
- package/src/workers/buildAreaInWorker.js +40 -0
- package/src/workers/closeGeometryWorkers.js +11 -0
- package/src/workers/createGeometryWorker.js +19 -0
- package/src/workers/geometryWorker.js +14 -0
- package/src/workers/settleGeometryWorker.js +10 -0
- package/src/workers/startGeometryWorker.js +16 -0
- package/src/core/bringNativeLayerToBack.js +0 -8
- package/src/core/bringNativeLayerToFront.js +0 -8
- package/src/core/current.js +0 -6
- package/src/core/localPosition.js +0 -10
- package/src/core/readyNativeGPU.js +0 -9
- package/src/core/reorderNativeLayer.js +0 -9
- package/src/core/scheduleGridFade.js +0 -14
- package/src/core/updateNativeLayerView.js +0 -9
- package/src/geometry/dot.js +0 -6
- package/src/geometry/push.js +0 -3
- package/src/globals/cameraByMap.js +0 -1
- package/src/raster/finishAttachment.js +0 -15
- package/src/raster/isLoading.js +0 -7
- package/src/raster/terrainTileGeometry.js +0 -16
- package/src/rendering/destroyTexture.js +0 -9
- package/src/rendering/sortMeshes.js +0 -6
- package/src/rendering/updateRoofAtlas.js +0 -20
- package/src/rendering/updateRoofRaster.js +0 -25
- package/src/scene/attach.js +0 -54
- package/src/scene/endZoom.js +0 -23
- package/src/scene/initializeSharedRenderer.js +0 -45
- package/src/scene/layerCountTitle.js +0 -4
- package/src/scene/mountRenderer.js +0 -25
- package/src/scene/ready.js +0 -9
- package/src/scene/renderLayerCount.js +0 -13
- package/src/scene/rendererDeviceError.js +0 -14
- package/src/scene/rendererDeviceLost.js +0 -14
- package/src/scene/requestAdapter.js +0 -12
- package/src/scene/requestDevice.js +0 -9
- package/src/scene/update.js +0 -23
- package/src/sources/projectedTree.js +0 -19
- package/src/sources/pump.js +0 -44
- package/src/sunlight/render.js +0 -9
- package/src/terrain/rasterProgram.js +0 -51
- package/src/walk/land.js +0 -32
- package/src/walk/local.js +0 -18
- /package/src/{camera → animations}/mapStopPitchBearingAnimation.js +0 -0
- /package/src/{core → animations}/runMarkerPanFrame.js +0 -0
- /package/src/{core → animations}/scheduleMarkerPan.js +0 -0
- /package/src/archives/{varint.js → readVarint.js} +0 -0
- /package/src/{sunlight → astronomy}/horizontalPosition.js +0 -0
- /package/src/{sunlight → astronomy}/moonPosition.js +0 -0
- /package/src/{sunlight → astronomy}/solarPosition.js +0 -0
- /package/src/{sunlight → astronomy}/solarTime.js +0 -0
- /package/src/{scene → camera}/createSceneCamera.js +0 -0
- /package/src/{sunlight/rgb.js → colors/formatRGB.js} +0 -0
- /package/src/{utils/channel.js → colors/hslChannel.js} +0 -0
- /package/src/{sunlight/mix.js → colors/mixColor.js} +0 -0
- /package/src/{utils → colors}/toSRGB.js +0 -0
- /package/src/controls/{editable.js → isEditableTarget.js} +0 -0
- /package/src/geometry/{nativeTriangle.js → appendNativeTriangle.js} +0 -0
- /package/src/{traffic → geometry}/appendRouteDash.js +0 -0
- /package/src/{traffic → geometry}/appendRouteSegment.js +0 -0
- /package/src/geometry/{build.js → buildGeometryParts.js} +0 -0
- /package/src/geometry/{lampRing.js → createLampRing.js} +0 -0
- /package/src/{raster/createGeometry.js → geometry/createRasterQuadGeometry.js} +0 -0
- /package/src/geometry/{treeRing.js → createTreeRing.js} +0 -0
- /package/src/geometry/{cross.js → crossVector.js} +0 -0
- /package/src/{sources → geometry}/generateTreeGeometry.js +0 -0
- /package/src/{sources → geometry}/instanceAreaGeometry.js +0 -0
- /package/src/{traffic/along.js → geometry/interpolateRoute.js} +0 -0
- /package/src/{core → geometry}/markerImageBounds.js +0 -0
- /package/src/{shadows → geometry}/meshShadowBounds.js +0 -0
- /package/src/geometry/{below.js → offsetBelowGround.js} +0 -0
- /package/src/{scene → geometry}/restoreGeometry.js +0 -0
- /package/src/{traffic → geometry}/routeGeometry.js +0 -0
- /package/src/geometry/{sub.js → subtractVector.js} +0 -0
- /package/src/{terrain → geometry}/terrainGrid.js +0 -0
- /package/src/geometry/{visit.js → visitNativeCoordinates.js} +0 -0
- /package/src/{scene → gpu}/showWebGPUWarning.js +0 -0
- /package/src/{scene → layer-controls}/placeEntry.js +0 -0
- /package/src/{scene → layer-controls}/placeEntryElement.js +0 -0
- /package/src/{scene → layer-controls}/placeUnderEntry.js +0 -0
- /package/src/{scene → layer-controls}/removeEntry.js +0 -0
- /package/src/{scene → layer-controls}/replaceEntry.js +0 -0
- /package/src/{scene → layer-controls}/runPlacements.js +0 -0
- /package/src/{scene → layer-controls}/underEntry.js +0 -0
- /package/src/lighting/{visitCells.js → visitLightGridCells.js} +0 -0
- /package/src/{rendering → materials}/createProgramLayout.js +0 -0
- /package/src/{rendering → materials}/createProgramUniforms.js +0 -0
- /package/src/{rendering → materials}/prepareMeshCutout.js +0 -0
- /package/src/{shaders → materials}/validateRoofMaterial.js +0 -0
- /package/src/{core → native}/beforeNativeRender.js +0 -0
- /package/src/{core → native}/bypassNativeEvent.js +0 -0
- /package/src/{core → native}/compareNativeHits.js +0 -0
- /package/src/{core → native}/forwardNativeError.js +0 -0
- /package/src/{core → native}/hideTargets.js +0 -0
- /package/src/{core → native}/nativeAddLatLng.js +0 -0
- /package/src/{core → native}/nativeBringToBack.js +0 -0
- /package/src/{core → native}/nativeBringToFront.js +0 -0
- /package/src/{core → native}/nativeRedraw.js +0 -0
- /package/src/{core → native}/nativeSetBounds.js +0 -0
- /package/src/{core → native}/nativeSetIcon.js +0 -0
- /package/src/{core → native}/nativeSetLatLng.js +0 -0
- /package/src/{core → native}/nativeSetLatLngs.js +0 -0
- /package/src/{core → native}/nativeSetOpacity.js +0 -0
- /package/src/{core → native}/nativeSetRadius.js +0 -0
- /package/src/{core → native}/nativeSetStyle.js +0 -0
- /package/src/{core → native}/nativeSetUrl.js +0 -0
- /package/src/{core → native}/nativeSetZIndex.js +0 -0
- /package/src/{core → native}/nativeSetZIndexOffset.js +0 -0
- /package/src/{core → native}/refreshNativeEvent.js +0 -0
- /package/src/{core → native}/rejectNativeReady.js +0 -0
- /package/src/{core → native}/resolveNativeReady.js +0 -0
- /package/src/{core → native}/restoreNativeEvents.js +0 -0
- /package/src/{core → native}/updateNativeHover.js +0 -0
- /package/src/{camera/displayPoint.js → projections/displayContainerPoint.js} +0 -0
- /package/src/{core → projections}/localPixel.js +0 -0
- /package/src/{core → projections}/localPixelForGeometry.js +0 -0
- /package/src/{core → projections}/markerCameraIconPoint.js +0 -0
- /package/src/{geometry/bridgeLocal.js → projections/projectBridgePoint.js} +0 -0
- /package/src/{sunlight → projections}/projectCelestialBody.js +0 -0
- /package/src/{camera/pointOf.js → projections/toPoint.js} +0 -0
- /package/src/{camera → projections}/verticalGroundY.js +0 -0
- /package/src/raster/{reportError.js → reportRasterError.js} +0 -0
- /package/src/scene/{emptyNode.js → createSceneNode.js} +0 -0
- /package/src/scene/{reportError.js → reportLayerError.js} +0 -0
- /package/src/sunlight/{onAdd.js → onAddTimeControl.js} +0 -0
- /package/src/sunlight/{remove.js → removeTimeControl.js} +0 -0
- /package/src/terrain/{sample.js → sampleTerrainTile.js} +0 -0
- /package/src/{rendering → textures}/bindMeshTextures.js +0 -0
- /package/src/{rendering → textures}/compareRoofTiles.js +0 -0
- /package/src/{rendering/destroyAfterSubmission.js → textures/destroyTextureAfterSubmission.js} +0 -0
- /package/src/{rendering → textures}/ensureRoofBlit.js +0 -0
- /package/src/{models/loadImage.js → textures/loadModelImage.js} +0 -0
- /package/src/{models/textureSampler.js → textures/modelTextureSampler.js} +0 -0
- /package/src/{rendering → textures}/prepareMeshTextures.js +0 -0
- /package/src/{scene → textures}/restoreMaterialTextures.js +0 -0
- /package/src/{rendering → textures}/textureBinding.js +0 -0
- /package/src/{rendering → textures}/uploadMeshTexture.js +0 -0
- /package/src/{core → textures}/uploadNativeImage.js +0 -0
- /package/src/{rendering → textures}/uploadRoofTile.js +0 -0
- /package/src/traffic/{toLanes.js → featuresToTrafficLanes.js} +0 -0
- /package/src/traffic/{tooltip.js → trafficTooltip.js} +0 -0
- /package/src/{scene → transforms}/composeLocalTransform.js +0 -0
- /package/src/{models/nodeMatrix.js → transforms/modelNodeMatrix.js} +0 -0
- /package/src/{core → transforms}/transformNativePoint.js +0 -0
- /package/src/{scene → transforms}/updateWorldMatrix.js +0 -0
- /package/src/{scene → transforms}/worldMatrixChanged.js +0 -0
- /package/src/vehicles/{carriage.js → buildCarriage.js} +0 -0
- /package/src/vehicles/{mirror.js → mirrorVehiclePart.js} +0 -0
- /package/src/walk/{initialize.js → initializeWalkControl.js} +0 -0
- /package/src/walk/{blocked.js → isWalkBlocked.js} +0 -0
- /package/src/walk/{onBlur.js → onWalkBlur.js} +0 -0
- /package/src/walk/{onPointer.js → onWalkPointer.js} +0 -0
- /package/src/{globals → weakmaps}/boundsMethods.js +0 -0
- /package/src/{globals → weakmaps}/closestMethods.js +0 -0
- /package/src/{globals → weakmaps}/colliders.js +0 -0
- /package/src/{globals → weakmaps}/dragByHandler.js +0 -0
- /package/src/{globals → weakmaps}/dragStates.js +0 -0
- /package/src/{globals → weakmaps}/gridInitializers.js +0 -0
- /package/src/{globals → weakmaps}/imageStates.js +0 -0
- /package/src/{globals → weakmaps}/nativeEventMaps.js +0 -0
- /package/src/{globals → weakmaps}/nativeRenderByLayer.js +0 -0
- /package/src/{globals → weakmaps}/rendererDevices.js +0 -0
- /package/src/{globals → weakmaps}/renderers.js +0 -0
- /package/src/{globals → weakmaps}/sceneByLayer.js +0 -0
- /package/src/{globals → weakmaps}/sunByMap.js +0 -0
- /package/src/{globals → weakmaps}/sunlightByControl.js +0 -0
- /package/src/{globals → weakmaps}/touchByContainer.js +0 -0
- /package/src/{globals → weakmaps}/trafficByLayer.js +0 -0
- /package/src/{globals → weakmaps}/walkByMap.js +0 -0
|
@@ -1,4 +1,6 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { cameraMaps } from '../weakmaps/cameraMaps.js';
|
|
2
|
+
import { cameraReadyByMap } from '../weakmaps/cameraReadyByMap.js';
|
|
3
|
+
|
|
2
4
|
|
|
3
5
|
import { mapSetPitchAndBearing } from './mapSetPitchAndBearing.js';
|
|
4
6
|
|
|
@@ -10,7 +12,7 @@ import { loadCameraControls } from '../controls/loadCameraControls.js';
|
|
|
10
12
|
import { noOperation } from '../utils/noOperation.js';
|
|
11
13
|
|
|
12
14
|
export function initializeCameraMap() {
|
|
13
|
-
|
|
15
|
+
cameraMaps.add(this);
|
|
14
16
|
if (!document.getElementById('leaflet-camera-zoom-style')) {
|
|
15
17
|
const style = document.createElement('style');
|
|
16
18
|
style.id = 'leaflet-camera-zoom-style';
|
|
@@ -24,7 +26,7 @@ export function initializeCameraMap() {
|
|
|
24
26
|
this.once('unload', cleanupCameraMap, this);
|
|
25
27
|
this.whenReady(cameraMapReady, this);
|
|
26
28
|
if (this.options.rotate || this.options.trackContainerMutation) {
|
|
27
|
-
|
|
28
|
-
|
|
29
|
+
cameraReadyByMap.set(this, loadCameraControls(this));
|
|
30
|
+
cameraReadyByMap.get(this).catch(noOperation);
|
|
29
31
|
}
|
|
30
32
|
}
|
package/src/camera/mapCamera.js
CHANGED
|
@@ -9,7 +9,7 @@ import { tooltipPosition } from '../globals/tooltipPosition.js';
|
|
|
9
9
|
import { tiledBounds } from '../globals/tiledBounds.js';
|
|
10
10
|
import { gridEvents } from '../globals/gridEvents.js';
|
|
11
11
|
|
|
12
|
-
import { initNativeGPU } from '../
|
|
12
|
+
import { initNativeGPU } from '../native/initNativeGPU.js';
|
|
13
13
|
|
|
14
14
|
import { mapLayerPointToContainerPoint } from './mapLayerPointToContainerPoint.js';
|
|
15
15
|
import { mapContainerPointToLayerPoint } from './mapContainerPointToLayerPoint.js';
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { mapMethods } from '../globals/mapMethods.js';
|
|
2
2
|
|
|
3
3
|
|
|
4
|
-
import { animationPoint } from '
|
|
5
|
-
import { project } from '
|
|
4
|
+
import { animationPoint } from '../projections/transformZoomAnimationPoint.js';
|
|
5
|
+
import { project } from '../projections/projectCameraPoint.js';
|
|
6
6
|
|
|
7
7
|
export function mapContainerPointToLayerPoint(point) {
|
|
8
8
|
return mapMethods.value.containerPointToLayerPoint.call(this, animationPoint(this, project(this, point, true), true));
|
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { cameraBearingByMap } from '../weakmaps/cameraBearingByMap.js';
|
|
2
2
|
|
|
3
3
|
|
|
4
|
-
|
|
4
|
+
|
|
5
|
+
export function mapGetBearing(map) { return cameraBearingByMap.get(map) ?? 0; }
|
|
@@ -4,8 +4,8 @@ import { mapMethods } from '../globals/mapMethods.js';
|
|
|
4
4
|
import { mapGetPitch } from './mapGetPitch.js';
|
|
5
5
|
import { mapGetBearing } from './mapGetBearing.js';
|
|
6
6
|
|
|
7
|
-
import { groundBounds } from '
|
|
8
|
-
import { animationPoint } from '
|
|
7
|
+
import { groundBounds } from '../projections/groundBounds.js';
|
|
8
|
+
import { animationPoint } from '../projections/transformZoomAnimationPoint.js';
|
|
9
9
|
|
|
10
10
|
export function mapGetBounds() {
|
|
11
11
|
if (!mapGetPitch(this) && !mapGetBearing(this)) return mapMethods.value.getBounds.call(this);
|
|
@@ -6,8 +6,8 @@ import { mapGetPitch } from './mapGetPitch.js';
|
|
|
6
6
|
import { mapGetBearing } from './mapGetBearing.js';
|
|
7
7
|
|
|
8
8
|
import { fitCameraBounds } from './fitCameraBounds.js';
|
|
9
|
-
import { pointOf } from '
|
|
10
|
-
import { groundBounds } from '
|
|
9
|
+
import { pointOf } from '../projections/toPoint.js';
|
|
10
|
+
import { groundBounds } from '../projections/groundBounds.js';
|
|
11
11
|
|
|
12
12
|
export function mapGetBoundsZoom(bounds, inside, padding) {
|
|
13
13
|
if (!mapGetPitch(this) && !mapGetBearing(this)) return mapMethods.value.getBoundsZoom.call(this, bounds, inside, padding);
|
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { cameraPitchByMap } from '../weakmaps/cameraPitchByMap.js';
|
|
2
2
|
|
|
3
3
|
|
|
4
|
-
|
|
4
|
+
|
|
5
|
+
export function mapGetPitch(map) { return cameraPitchByMap.get(map) ?? 0; }
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { mapMethods } from '../globals/mapMethods.js';
|
|
2
2
|
|
|
3
|
-
import { project } from '
|
|
4
|
-
import { animationPoint } from '
|
|
3
|
+
import { project } from '../projections/projectCameraPoint.js';
|
|
4
|
+
import { animationPoint } from '../projections/transformZoomAnimationPoint.js';
|
|
5
5
|
|
|
6
6
|
export function mapLayerPointToContainerPoint(point) {
|
|
7
7
|
return project(this, animationPoint(this, mapMethods.value.layerPointToContainerPoint.call(this, point)));
|
|
@@ -4,7 +4,7 @@ import { mapMethods } from '../globals/mapMethods.js';
|
|
|
4
4
|
import { mapGetPitch } from './mapGetPitch.js';
|
|
5
5
|
import { mapGetBearing } from './mapGetBearing.js';
|
|
6
6
|
|
|
7
|
-
import { groundBounds } from '
|
|
7
|
+
import { groundBounds } from '../projections/groundBounds.js';
|
|
8
8
|
|
|
9
9
|
export function mapLimitCenter(center, zoom, bounds) {
|
|
10
10
|
if (!bounds || !this._loaded || !mapGetPitch(this) && !mapGetBearing(this)) {
|
|
@@ -3,7 +3,7 @@ import { mapMethods } from '../globals/mapMethods.js';
|
|
|
3
3
|
import { mapGetPitch } from './mapGetPitch.js';
|
|
4
4
|
import { mapGetBearing } from './mapGetBearing.js';
|
|
5
5
|
|
|
6
|
-
import { project } from '
|
|
6
|
+
import { project } from '../projections/projectCameraPoint.js';
|
|
7
7
|
|
|
8
8
|
export function mapLimitOffset(offset, bounds) {
|
|
9
9
|
if (!bounds || !mapGetPitch(this) && !mapGetBearing(this)) return mapMethods.value._limitOffset.call(this, offset, bounds);
|
package/src/camera/mapPanBy.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { mapMethods } from '../globals/mapMethods.js';
|
|
2
2
|
|
|
3
|
-
import { project } from '
|
|
4
|
-
import { pointOf } from '
|
|
3
|
+
import { project } from '../projections/projectCameraPoint.js';
|
|
4
|
+
import { pointOf } from '../projections/toPoint.js';
|
|
5
5
|
|
|
6
6
|
export function mapPanBy(offset, options) {
|
|
7
7
|
const half = this.getSize().divideBy(2);
|
|
@@ -4,7 +4,7 @@ import { cameraZeroPadding } from '../globals/cameraZeroPadding.js';
|
|
|
4
4
|
import { mapGetPitch } from './mapGetPitch.js';
|
|
5
5
|
import { mapGetBearing } from './mapGetBearing.js';
|
|
6
6
|
|
|
7
|
-
import { pointOf } from '
|
|
7
|
+
import { pointOf } from '../projections/toPoint.js';
|
|
8
8
|
|
|
9
9
|
export function mapPanInside(latlng, options = /* alloc */ {}) {
|
|
10
10
|
if (!mapGetPitch(this) && !mapGetBearing(this)) return mapMethods.value.panInside.call(this, latlng, options);
|
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
import { cameraAnimatedOptions } from '../globals/cameraAnimatedOptions.js';
|
|
2
|
-
import { mapAnimateCamera } from '
|
|
2
|
+
import { mapAnimateCamera } from '../animations/mapAnimateCamera.js';
|
|
3
3
|
|
|
4
4
|
export function mapResetNorthPitch(map, options = cameraAnimatedOptions) { return mapAnimateCamera(map, 0, 0, options); }
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import { mapAnimateCamera } from '
|
|
1
|
+
import { mapAnimateCamera } from '../animations/mapAnimateCamera.js';
|
|
2
2
|
import { mapGetPitch } from './mapGetPitch.js';
|
|
3
3
|
export function mapSetBearing(map, bearing, options) { return mapAnimateCamera(map, mapGetPitch(map), bearing, options); }
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import { mapAnimateCamera } from '
|
|
1
|
+
import { mapAnimateCamera } from '../animations/mapAnimateCamera.js';
|
|
2
2
|
import { mapGetBearing } from './mapGetBearing.js';
|
|
3
3
|
export function mapSetPitch(map, pitch, options) { return mapAnimateCamera(map, pitch, mapGetBearing(map), options); }
|
|
@@ -1,4 +1,6 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { cameraBearingByMap } from '../weakmaps/cameraBearingByMap.js';
|
|
2
|
+
import { cameraPitchByMap } from '../weakmaps/cameraPitchByMap.js';
|
|
3
|
+
|
|
2
4
|
|
|
3
5
|
import { mapGetPitch } from './mapGetPitch.js';
|
|
4
6
|
import { mapGetBearing } from './mapGetBearing.js';
|
|
@@ -11,8 +13,8 @@ export function mapSetPitchAndBearing(map, pitch, bearing) {
|
|
|
11
13
|
throw /* alloc */ new TypeError('maxPitch must be between 0 and 180 degrees');
|
|
12
14
|
}
|
|
13
15
|
const previousPitch = mapGetPitch(map), previousBearing = mapGetBearing(map);
|
|
14
|
-
|
|
15
|
-
|
|
16
|
+
cameraPitchByMap.set(map, Math.max(0, Math.min(map.options.maxPitch, pitch)));
|
|
17
|
+
cameraBearingByMap.set(map, ((bearing % 360) + 360) % 360);
|
|
16
18
|
if (map._loaded) {
|
|
17
19
|
updateSky.call(map);
|
|
18
20
|
if (previousBearing !== mapGetBearing(map)) map.fire('rotate', /* alloc */ { bearing: mapGetBearing(map) });
|
|
@@ -1,35 +1,39 @@
|
|
|
1
|
+
import { cameraByLayer } from '../weakmaps/cameraByLayer.js';
|
|
2
|
+
import { sceneOriginByLayer } from '../weakmaps/sceneOriginByLayer.js';
|
|
3
|
+
import { cameraViewByMap } from '../weakmaps/cameraViewByMap.js';
|
|
4
|
+
|
|
5
|
+
|
|
1
6
|
import { radians } from '../globals/radians.js';
|
|
2
7
|
import { cameraFov } from '../globals/cameraFov.js';
|
|
3
8
|
import { earthCirc } from '../globals/earthCirc.js';
|
|
4
|
-
import {
|
|
5
|
-
import { sceneByLayer } from '../globals/sceneByLayer.js';
|
|
9
|
+
import { mapElevationOf } from '../terrain/mapElevationOf.js';
|
|
6
10
|
import { mapMethods } from '../globals/mapMethods.js';
|
|
7
|
-
import { walkByMap } from '../
|
|
8
|
-
import { mapGetPitch } from '
|
|
9
|
-
import { mapGetBearing } from '
|
|
11
|
+
import { walkByMap } from '../weakmaps/walkByMap.js';
|
|
12
|
+
import { mapGetPitch } from './mapGetPitch.js';
|
|
13
|
+
import { mapGetBearing } from './mapGetBearing.js';
|
|
10
14
|
|
|
11
|
-
import { updateCamera } from "
|
|
12
|
-
import { getElevation } from "../terrain/getElevation.js";
|
|
15
|
+
import { updateCamera } from "./updateSceneCamera.js";
|
|
13
16
|
|
|
14
|
-
import { animationPoint } from '../
|
|
17
|
+
import { animationPoint } from '../projections/transformZoomAnimationPoint.js';
|
|
15
18
|
|
|
16
|
-
export function updateMapCamera(
|
|
17
|
-
const map =
|
|
19
|
+
export function updateMapCamera(layer, size) {
|
|
20
|
+
const map = layer._map;
|
|
18
21
|
// Match the map's perspective, including the intermediate view of an animated zoom.
|
|
19
|
-
const zoom =
|
|
20
|
-
const pixelsPerMeter = map.options.crs.scale(zoom) /
|
|
22
|
+
const zoom = cameraViewByMap.get(map)?.zoom ?? map.getZoom();
|
|
23
|
+
const pixelsPerMeter = map.options.crs.scale(zoom) /
|
|
24
|
+
(earthCirc * Math.cos(sceneOriginByLayer.get(layer).lat * radians));
|
|
21
25
|
const origin = animationPoint(map, mapMethods.value.layerPointToContainerPoint.call(map,
|
|
22
|
-
map.project(
|
|
26
|
+
map.project(sceneOriginByLayer.get(layer)).subtract(map.getPixelOrigin())));
|
|
23
27
|
const distance = size.y * 1.5 / pixelsPerMeter;
|
|
24
28
|
const targetX = (size.x / 2 - origin.x) / pixelsPerMeter;
|
|
25
29
|
// CSS zoom keeps the logical view's ground plane until zoomend.
|
|
26
30
|
const walker = walkByMap.get(map)?.control?._walk;
|
|
27
|
-
const targetY = ((
|
|
31
|
+
const targetY = (mapElevationOf(map, map.getCenter()) ?? 0) +
|
|
28
32
|
(walker?.saved ? walker.state.height : 0);
|
|
29
33
|
const targetZ = (size.y / 2 - origin.y) / pixelsPerMeter;
|
|
30
34
|
const pitch = mapGetPitch(map) * radians;
|
|
31
35
|
const bearing = mapGetBearing(map) * radians;
|
|
32
|
-
const camera =
|
|
36
|
+
const camera = cameraByLayer.get(layer);
|
|
33
37
|
camera.fov = cameraFov;
|
|
34
38
|
camera.aspect = size.x / size.y;
|
|
35
39
|
camera.near = Math.max(0.1, distance / 10000);
|
|
@@ -9,7 +9,7 @@ export function updateCamera(camera) {
|
|
|
9
9
|
camera.projectionTransform ||= /* alloc */ new DOMMatrix();
|
|
10
10
|
camera.projectionViewTransform ||= /* alloc */ new DOMMatrix();
|
|
11
11
|
const { position, target, up, x, y, z, viewMatrix, projectionMatrix, projectionViewMatrix } = camera;
|
|
12
|
-
let
|
|
12
|
+
let value;
|
|
13
13
|
z[0] = position[0] - target[0], z[1] = position[1] - target[1], z[2] = position[2] - target[2];
|
|
14
14
|
const zLength = Math.hypot(z[0], z[1], z[2]) || 1;
|
|
15
15
|
z[0] /= zLength, z[1] /= zLength, z[2] /= zLength;
|
package/src/camera/updateSky.js
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
|
+
import { pitchSkyByMap } from '../weakmaps/pitchSkyByMap.js';
|
|
2
|
+
|
|
1
3
|
import { L } from '../globals/L.js';
|
|
2
4
|
import { radians } from '../globals/radians.js';
|
|
3
|
-
import { cameraByMap } from '../globals/cameraByMap.js';
|
|
4
5
|
|
|
5
6
|
import { mapGetPitch } from './mapGetPitch.js';
|
|
6
7
|
|
|
@@ -9,14 +10,14 @@ export function updateSky() {
|
|
|
9
10
|
const height = this.getSize().y, pitch = mapGetPitch(this) * radians;
|
|
10
11
|
const far = height * this.options.pitchMaxDistance, distance = height * 1.5;
|
|
11
12
|
const top = height / 2 - far * Math.abs(Math.cos(pitch)) * distance / (distance + Math.sin(pitch) * far);
|
|
12
|
-
if (top > 0 && !
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
13
|
+
if (top > 0 && !pitchSkyByMap.get(this)) {
|
|
14
|
+
pitchSkyByMap.set(this, L.DomUtil.create('div', 'leaflet-pitch-sky', this.getContainer()));
|
|
15
|
+
pitchSkyByMap.get(this).setAttribute('aria-hidden', 'true');
|
|
16
|
+
pitchSkyByMap.get(this).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))';
|
|
16
17
|
}
|
|
17
|
-
if (
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
18
|
+
if (pitchSkyByMap.get(this)) {
|
|
19
|
+
pitchSkyByMap.get(this).style.inset = pitch > Math.PI / 2 ? 'auto 0 0' : '0 0 auto';
|
|
20
|
+
pitchSkyByMap.get(this).style.height = `${Math.max(0, Math.ceil(top))}px`;
|
|
21
|
+
pitchSkyByMap.get(this).style.display = top > 0 ? '' : 'none';
|
|
21
22
|
}
|
|
22
23
|
}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { CELL } from '../globals/CELL.js';
|
|
2
|
+
import { horizontalRay } from './horizontalRay.js';
|
|
3
|
+
|
|
4
|
+
export function collectIntersections(shape, x, y, z, seen, hits, end, iz) {
|
|
5
|
+
let ix, cell, triangle, distance;
|
|
6
|
+
for (ix = Math.floor(x / CELL); ix <= end; ix++) {
|
|
7
|
+
cell = shape.cells.get(`${ix},${iz}`);
|
|
8
|
+
if (!cell) continue;
|
|
9
|
+
for (triangle of cell) {
|
|
10
|
+
if (seen.has(triangle)) continue;
|
|
11
|
+
seen.add(triangle);
|
|
12
|
+
distance = horizontalRay(shape.tri, triangle, x, y, z, 1, 0);
|
|
13
|
+
if (distance > 1e-4) hits.push(distance);
|
|
14
|
+
}
|
|
15
|
+
}
|
|
16
|
+
}
|
|
@@ -1,27 +1,39 @@
|
|
|
1
|
-
import { colliders } from '../
|
|
2
|
-
import { transformTriangle } from './transformTriangle.js';
|
|
1
|
+
import { colliders } from '../weakmaps/colliders.js';
|
|
3
2
|
import { indexTriangle } from './indexTriangle.js';
|
|
3
|
+
import { readTriangle } from './readTriangle.js';
|
|
4
|
+
import { vertexCount } from './vertexCount.js';
|
|
4
5
|
|
|
5
6
|
|
|
6
7
|
export function collider(mesh) {
|
|
7
8
|
let c = colliders.get(mesh.geometry);
|
|
8
9
|
if (c) return c;
|
|
9
|
-
const m = mesh.worldMatrix, { position
|
|
10
|
+
const m = mesh.worldMatrix, { position, index, normal, uv, instanceOffset } = mesh.geometry.attributes;
|
|
10
11
|
|
|
11
|
-
const
|
|
12
|
+
const vertices = vertexCount(position, index);
|
|
13
|
+
const count = vertices * (instanceOffset?.count ?? 1);
|
|
12
14
|
const tri = /* alloc */ [];
|
|
13
15
|
const nrm = /* alloc */ [];
|
|
14
16
|
const cells = /* alloc */ new Map();
|
|
17
|
+
const a = /* alloc */ [0, 0, 0], b = /* alloc */ [0, 0, 0], d = /* alloc */ [0, 0, 0];
|
|
15
18
|
const v = /* alloc */ [];
|
|
16
19
|
|
|
17
|
-
let i, first, j, ex, ey, ez, fx, fy, fz, nx, nz, ny, length,
|
|
20
|
+
let i, first, j, ex, ey, ez, fx, fy, fz, nx, nz, ny, length, h, t, maxX = -Infinity;
|
|
18
21
|
for (i = 0; i < count; i += 3) {
|
|
19
|
-
first = index ? index.data[i] : i;
|
|
22
|
+
first = index ? index.data[i % vertices] : i % vertices;
|
|
20
23
|
// Streetlight halos (uv.x <= 2, see scene/picking.js) are light, not matter.
|
|
21
24
|
if (mesh.program.nightLight && uv && uv.data[first * 2] <= 2) {
|
|
22
25
|
continue;
|
|
23
26
|
}
|
|
24
|
-
|
|
27
|
+
readTriangle(mesh, i, a, b, d);
|
|
28
|
+
v[0] = m[0] * a[0] + m[4] * a[1] + m[8] * a[2] + m[12];
|
|
29
|
+
v[1] = m[1] * a[0] + m[5] * a[1] + m[9] * a[2] + m[13];
|
|
30
|
+
v[2] = m[2] * a[0] + m[6] * a[1] + m[10] * a[2] + m[14];
|
|
31
|
+
v[3] = m[0] * b[0] + m[4] * b[1] + m[8] * b[2] + m[12];
|
|
32
|
+
v[4] = m[1] * b[0] + m[5] * b[1] + m[9] * b[2] + m[13];
|
|
33
|
+
v[5] = m[2] * b[0] + m[6] * b[1] + m[10] * b[2] + m[14];
|
|
34
|
+
v[6] = m[0] * d[0] + m[4] * d[1] + m[8] * d[2] + m[12];
|
|
35
|
+
v[7] = m[1] * d[0] + m[5] * d[1] + m[9] * d[2] + m[13];
|
|
36
|
+
v[8] = m[2] * d[0] + m[6] * d[1] + m[10] * d[2] + m[14];
|
|
25
37
|
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
38
|
|
|
27
39
|
nx = ey * fz - ez * fy, nz = ex * fy - ey * fx;
|
|
@@ -34,13 +46,15 @@ export function collider(mesh) {
|
|
|
34
46
|
|
|
35
47
|
if (normal) {
|
|
36
48
|
// The stored normal tells the outside, whatever the winding.
|
|
37
|
-
j = first * 3
|
|
38
|
-
if ((m[0] *
|
|
49
|
+
j = first * 3;
|
|
50
|
+
if ((m[0] * normal.data[j] + m[4] * normal.data[j + 1] + m[8] * normal.data[j + 2]) * nx +
|
|
51
|
+
(m[2] * normal.data[j] + m[6] * normal.data[j + 1] + m[10] * normal.data[j + 2]) * nz < 0) { nx = -nx; nz = -nz; }
|
|
39
52
|
}
|
|
40
53
|
|
|
41
54
|
h = Math.hypot(nx, nz), t = nrm.length / 2;
|
|
42
55
|
|
|
43
56
|
tri.push(...v);
|
|
57
|
+
maxX = Math.max(maxX, v[0], v[3], v[6]);
|
|
44
58
|
nrm.push(nx / h, nz / h);
|
|
45
59
|
|
|
46
60
|
indexTriangle(cells, v, t);
|
|
@@ -49,6 +63,7 @@ export function collider(mesh) {
|
|
|
49
63
|
tri: Float32Array.from(tri),
|
|
50
64
|
nrm: Float32Array.from(nrm),
|
|
51
65
|
cells,
|
|
66
|
+
maxX,
|
|
52
67
|
origin: /* alloc */ [m[12], m[13], m[14]]
|
|
53
68
|
};
|
|
54
69
|
colliders.set(mesh.geometry, c);
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
export function countCrossings(hits) {
|
|
2
|
+
let ix, j, distance;
|
|
3
|
+
for (ix = 1; ix < hits.length; ix++) {
|
|
4
|
+
distance = hits[ix];
|
|
5
|
+
j = ix - 1;
|
|
6
|
+
while (j >= 0 && hits[j] > distance) hits[j + 1] = hits[j--];
|
|
7
|
+
hits[j + 1] = distance;
|
|
8
|
+
}
|
|
9
|
+
let crossings = 0, previous = -Infinity;
|
|
10
|
+
for (distance of hits) {
|
|
11
|
+
if (distance - previous > 1e-4) crossings++;
|
|
12
|
+
previous = distance;
|
|
13
|
+
}
|
|
14
|
+
return crossings;
|
|
15
|
+
}
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import { CELL } from '../globals/CELL.js';
|
|
2
|
+
|
|
3
|
+
import { collider } from './collider.js';
|
|
4
|
+
import { computeBounds } from '../geometry/computeBounds.js';
|
|
5
|
+
import { collectIntersections } from './collectIntersections.js';
|
|
6
|
+
import { countCrossings } from './countCrossings.js';
|
|
7
|
+
|
|
8
|
+
export function insideMesh(mesh, x, y, z, seen, intersections) {
|
|
9
|
+
const geometry = mesh.geometry;
|
|
10
|
+
if (!mesh.visible || !geometry?.attributes?.position?.data || mesh.program?.depthTest === false) return false;
|
|
11
|
+
if (!geometry.bounds) computeBounds(geometry);
|
|
12
|
+
const bounds = geometry.bounds;
|
|
13
|
+
const world = mesh.worldMatrix;
|
|
14
|
+
const center = bounds.center;
|
|
15
|
+
const cx = world[0] * center[0] + world[4] * center[1] + world[8] * center[2] + world[12];
|
|
16
|
+
const cy = world[1] * center[0] + world[5] * center[1] + world[9] * center[2] + world[13];
|
|
17
|
+
const cz = world[2] * center[0] + world[6] * center[1] + world[10] * center[2] + world[14];
|
|
18
|
+
const radius = bounds.radius * Math.max(
|
|
19
|
+
Math.hypot(world[0], world[1], world[2]),
|
|
20
|
+
Math.hypot(world[4], world[5], world[6]),
|
|
21
|
+
Math.hypot(world[8], world[9], world[10])
|
|
22
|
+
);
|
|
23
|
+
if (Math.hypot(cx - x, cy - y, cz - z) > radius) return false;
|
|
24
|
+
const shape = collider(mesh);
|
|
25
|
+
const end = Math.floor(shape.maxX / CELL);
|
|
26
|
+
if (x >= shape.maxX) return false;
|
|
27
|
+
const iz = Math.floor(z / CELL);
|
|
28
|
+
const hits = intersections;
|
|
29
|
+
hits.length = 0;
|
|
30
|
+
seen.clear();
|
|
31
|
+
collectIntersections(shape, x, y, z, seen, hits, end, iz);
|
|
32
|
+
return countCrossings(hits) % 2 === 1;
|
|
33
|
+
}
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
import { kindByLayer } from '../weakmaps/kindByLayer.js';
|
|
2
|
+
import { layersByLayer } from '../weakmaps/layersByLayer.js';
|
|
3
|
+
import { rootByLayer } from '../weakmaps/rootByLayer.js';
|
|
4
|
+
import { sceneByLayer } from '../weakmaps/sceneByLayer.js';
|
|
5
|
+
import { sharedByLayer } from '../weakmaps/sharedByLayer.js';
|
|
6
|
+
|
|
7
|
+
import { updateWorldMatrix } from '../transforms/updateWorldMatrix.js';
|
|
8
|
+
import { insideMesh } from './insideMesh.js';
|
|
9
|
+
import { trafficCollision } from './trafficCollision.js';
|
|
10
|
+
import { local } from '../projections/walkerLocalPosition.js';
|
|
11
|
+
|
|
12
|
+
export function insideWalker(context) {
|
|
13
|
+
const { layer, local: localBuffer, hitData } = context;
|
|
14
|
+
const shared = sharedByLayer.get(layer);
|
|
15
|
+
if (!shared || !layersByLayer.get(shared)) return false;
|
|
16
|
+
updateWorldMatrix(sceneByLayer.get(layer));
|
|
17
|
+
const root = rootByLayer.get(layer);
|
|
18
|
+
const feet = local.call(context, localBuffer);
|
|
19
|
+
const x = root.position[0] + feet[0] * root.scale[0];
|
|
20
|
+
const y = root.position[1] + feet[1] * root.scale[1];
|
|
21
|
+
const z = root.position[2] + feet[2] * root.scale[2];
|
|
22
|
+
const layers = layersByLayer.get(shared);
|
|
23
|
+
let other, node, child, nodes;
|
|
24
|
+
for (other of layers) {
|
|
25
|
+
if (other === layer || kindByLayer.get(other) === 'terrain') continue;
|
|
26
|
+
if (kindByLayer.get(other) === 'traffic') {
|
|
27
|
+
hitData.best = 0;
|
|
28
|
+
hitData.found = false;
|
|
29
|
+
if (trafficCollision(other, x, y, z, 0, 0, 0, hitData)) return true;
|
|
30
|
+
continue;
|
|
31
|
+
}
|
|
32
|
+
nodes = hitData.nodes;
|
|
33
|
+
nodes.length = 0;
|
|
34
|
+
if (rootByLayer.get(other)) nodes.push(rootByLayer.get(other));
|
|
35
|
+
while (nodes.length) {
|
|
36
|
+
node = nodes.pop();
|
|
37
|
+
if (!node.visible) continue;
|
|
38
|
+
if (node.geometry && (
|
|
39
|
+
insideMesh(node, x, y + 0.45 * root.scale[1], z, hitData.seen, hitData.intersections) ||
|
|
40
|
+
insideMesh(node, x, y + 1.35 * root.scale[1], z, hitData.seen, hitData.intersections)
|
|
41
|
+
)) return true;
|
|
42
|
+
for (child of node.children) nodes.push(child);
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
return false;
|
|
46
|
+
}
|
|
@@ -1,14 +1,17 @@
|
|
|
1
|
+
import { vertexCount } from './vertexCount.js';
|
|
2
|
+
|
|
1
3
|
export function readTriangle(mesh, i, a, b, c) {
|
|
2
4
|
const { position, index, instanceOffset } = mesh.geometry.attributes;
|
|
3
|
-
const
|
|
5
|
+
const size = position.size ?? 3;
|
|
6
|
+
const vertices = vertexCount(position, index);
|
|
4
7
|
const vertex = instanceOffset ? i % vertices : i;
|
|
5
8
|
const offset = instanceOffset ? Math.floor(i / vertices) * instanceOffset.size : 0;
|
|
6
9
|
const x = instanceOffset?.data[offset] ?? 0;
|
|
7
10
|
const y = instanceOffset?.data[offset + 1] ?? 0;
|
|
8
11
|
const z = instanceOffset?.data[offset + 2] ?? 0;
|
|
9
|
-
const ai = (index ? index.data[vertex] : vertex) *
|
|
10
|
-
const bi = (index ? index.data[vertex + 1] : vertex + 1) *
|
|
11
|
-
const ci = (index ? index.data[vertex + 2] : vertex + 2) *
|
|
12
|
+
const ai = (index ? index.data[vertex] : vertex) * size;
|
|
13
|
+
const bi = (index ? index.data[vertex + 1] : vertex + 1) * size;
|
|
14
|
+
const ci = (index ? index.data[vertex + 2] : vertex + 2) * size;
|
|
12
15
|
a[0] = position.data[ai]; a[1] = position.data[ai + 1]; a[2] = position.data[ai + 2];
|
|
13
16
|
b[0] = position.data[bi]; b[1] = position.data[bi + 1]; b[2] = position.data[bi + 2];
|
|
14
17
|
c[0] = position.data[ci]; c[1] = position.data[ci + 1]; c[2] = position.data[ci + 2];
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
import { rootByLayer } from '../weakmaps/rootByLayer.js';
|
|
2
|
+
import { trafficByLayer } from '../weakmaps/trafficByLayer.js';
|
|
3
|
+
|
|
4
|
+
import { locateTraffic } from '../traffic/locateTraffic.js';
|
|
5
|
+
import { setTrafficNormal } from './setTrafficNormal.js';
|
|
6
|
+
|
|
7
|
+
export function trafficCollision(layer, x, y, z, dx, dz, reach, data) {
|
|
8
|
+
const state = trafficByLayer.get(layer);
|
|
9
|
+
if (!state?.mesh || !state.trips.length) return false;
|
|
10
|
+
let bounds = state.collisionBounds;
|
|
11
|
+
if (!bounds) {
|
|
12
|
+
bounds = state.collisionBounds = /* alloc */ { radius: 0, minY: Infinity, maxY: -Infinity };
|
|
13
|
+
let i, px, py, pz;
|
|
14
|
+
for (i = 0; i < state.template.position.length; i += 3) {
|
|
15
|
+
px = state.template.position[i];
|
|
16
|
+
py = state.template.position[i + 1];
|
|
17
|
+
pz = state.template.position[i + 2];
|
|
18
|
+
bounds.radius = Math.max(bounds.radius, Math.hypot(px, pz));
|
|
19
|
+
bounds.minY = Math.min(bounds.minY, py);
|
|
20
|
+
bounds.maxY = Math.max(bounds.maxY, py);
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
const root = rootByLayer.get(layer), position = state.position ||= /* alloc */ {};
|
|
24
|
+
const scale = Math.max(root.scale[0], root.scale[1], root.scale[2]);
|
|
25
|
+
const radius = bounds.radius * scale + 0.35;
|
|
26
|
+
let trip, projection, closest, rx, rz, perpendicular, entry, distance, bottom, top, px, pz;
|
|
27
|
+
for (trip of state.trips) {
|
|
28
|
+
({ x: px, y: bottom, z: pz } = locateTraffic(state, trip, position));
|
|
29
|
+
bottom = root.position[1] + (bottom + bounds.minY) * root.scale[1];
|
|
30
|
+
top = root.position[1] + (position.y + bounds.maxY) * root.scale[1];
|
|
31
|
+
if (bottom > y + 1.7 * scale || top < y + 0.2 * scale) continue;
|
|
32
|
+
px = root.position[0] + px * root.scale[0];
|
|
33
|
+
pz = root.position[2] + pz * root.scale[2];
|
|
34
|
+
projection = (px - x) * dx + (pz - z) * dz;
|
|
35
|
+
closest = Math.max(0, Math.min(reach, projection));
|
|
36
|
+
rx = x + closest * dx - px;
|
|
37
|
+
rz = z + closest * dz - pz;
|
|
38
|
+
perpendicular = rx * rx + rz * rz;
|
|
39
|
+
if (perpendicular >= radius * radius) continue;
|
|
40
|
+
if (reach === 0) {
|
|
41
|
+
data.found = true;
|
|
42
|
+
distance = Math.hypot(x - px, z - pz);
|
|
43
|
+
data.normal[0] = distance ? (x - px) / distance : 0;
|
|
44
|
+
data.normal[1] = distance ? (z - pz) / distance : 0;
|
|
45
|
+
continue;
|
|
46
|
+
}
|
|
47
|
+
entry = Math.max(0, projection - Math.sqrt(radius * radius - perpendicular));
|
|
48
|
+
if (entry > reach || entry >= data.best) continue;
|
|
49
|
+
data.best = entry;
|
|
50
|
+
data.found = true;
|
|
51
|
+
distance = Math.hypot(x + entry * dx - px, z + entry * dz - pz);
|
|
52
|
+
setTrafficNormal(data, x + entry * dx - px, z + entry * dz - pz, distance, dx, dz);
|
|
53
|
+
}
|
|
54
|
+
return data.found;
|
|
55
|
+
}
|
|
@@ -1,9 +1,11 @@
|
|
|
1
|
-
import { cameraByMap } from '../globals/cameraByMap.js';
|
|
2
|
-
|
|
3
1
|
|
|
2
|
+
import { cameraHandlersByMap } from '../weakmaps/cameraHandlersByMap.js';
|
|
4
3
|
|
|
5
4
|
export function addCameraHandler(map, name, Type) {
|
|
6
|
-
|
|
5
|
+
let handlers = cameraHandlersByMap.get(map);
|
|
6
|
+
if (!handlers) cameraHandlersByMap.set(map, handlers = /* alloc */ new Map());
|
|
7
|
+
const handler = /* alloc */ new Type(map);
|
|
8
|
+
handlers.set(name, handler);
|
|
7
9
|
map._handlers.push(handler);
|
|
8
10
|
if (map.options[name]) handler.enable();
|
|
9
11
|
}
|
|
@@ -1,13 +1,14 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { cameraDraggableByMap } from '../weakmaps/cameraDraggableByMap.js';
|
|
2
|
+
|
|
2
3
|
|
|
3
4
|
import { mapGetPitch } from '../camera/mapGetPitch.js';
|
|
4
5
|
import { mapGetBearing } from '../camera/mapGetBearing.js';
|
|
5
6
|
|
|
6
|
-
import { project } from '../
|
|
7
|
+
import { project } from '../projections/projectCameraPoint.js';
|
|
7
8
|
|
|
8
9
|
export function adjustCameraDrag() {
|
|
9
10
|
const map = this;
|
|
10
|
-
const draggable =
|
|
11
|
+
const draggable = cameraDraggableByMap.get(map);
|
|
11
12
|
if (!mapGetPitch(map) && !mapGetBearing(map)) return;
|
|
12
13
|
const half = map.getSize().divideBy(2), delta = draggable._newPos.subtract(draggable._startPos);
|
|
13
14
|
const ground = half.subtract(project(map, half.subtract(delta), true));
|