leaflet-city-mapper 0.0.2 → 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 +49 -3
- package/cucumber.mjs +1 -1
- package/dist/leaflet-city-mapper.js +3 -1
- package/dist/leaflet-city-mapper.js.map +4 -4
- package/package.json +2 -1
- package/src/archives/decodeDirectory.js +32 -0
- package/src/archives/decodeHeader.js +19 -0
- package/src/archives/getZxy.js +75 -0
- package/src/archives/loadDirectory.js +7 -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/intersectMeshes.js +133 -0
- package/src/collision/sortHits.js +23 -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/attachState.js +1 -0
- package/src/constants/cameraControlsState.js +1 -0
- package/src/constants/cityMapper.js +6 -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/indexState.js +1 -0
- package/src/constants/mapCameraState.js +1 -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/parts.js +19 -0
- package/src/constants/pendingUpdates.js +1 -0
- package/src/constants/pumpState.js +1 -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/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/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 +41 -323
- 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/readAccessor.js +53 -0
- package/src/models/readAccessorValues.js +16 -0
- package/src/models/textureFor.js +35 -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/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/showWebGPUWarning.js +16 -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/shaders/materialShaders.js +246 -0
- 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/initSunlight.js +14 -0
- package/src/sunlight/initialize.js +11 -0
- package/src/sunlight/mix.js +6 -0
- package/src/sunlight/onAdd.js +5 -0
- package/src/sunlight/onAddSun.js +66 -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/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/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 +2 -2
- package/src/utils/compareDistance.js +3 -0
- package/src/utils/noOperation.js +1 -0
- package/src/utils/toSRGB.js +3 -1
- package/src/utils/wrap.js +3 -1
- 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/utils/CELL.js +0 -2
- package/dist/utils/CELL.js.map +0 -7
- package/dist/utils/addBridges.js +0 -2
- package/dist/utils/addBridges.js.map +0 -7
- package/dist/utils/addRasterTile.js +0 -2
- package/dist/utils/addRasterTile.js.map +0 -7
- package/dist/utils/along.js +0 -2
- package/dist/utils/along.js.map +0 -7
- package/dist/utils/atmosphere.js +0 -2
- package/dist/utils/atmosphere.js.map +0 -7
- package/dist/utils/attach.js +0 -2
- package/dist/utils/attach.js.map +0 -7
- package/dist/utils/bindSunlight.js +0 -2
- package/dist/utils/bindSunlight.js.map +0 -7
- package/dist/utils/box.js +0 -2
- package/dist/utils/box.js.map +0 -7
- package/dist/utils/bridgeElevation.js +0 -2
- package/dist/utils/bridgeElevation.js.map +0 -7
- package/dist/utils/build.js +0 -2
- package/dist/utils/build.js.map +0 -7
- package/dist/utils/cameraControls.js +0 -2
- package/dist/utils/cameraControls.js.map +0 -7
- package/dist/utils/channel.js +0 -2
- package/dist/utils/channel.js.map +0 -7
- package/dist/utils/collider.js +0 -2
- package/dist/utils/collider.js.map +0 -7
- package/dist/utils/colliders.js +0 -2
- package/dist/utils/colliders.js.map +0 -7
- package/dist/utils/computeBounds.js +0 -2
- package/dist/utils/computeBounds.js.map +0 -7
- package/dist/utils/conformModelToTerrain.js +0 -2
- package/dist/utils/conformModelToTerrain.js.map +0 -7
- package/dist/utils/createMesh.js +0 -2
- package/dist/utils/createMesh.js.map +0 -7
- package/dist/utils/createProgram.js +0 -3
- package/dist/utils/createProgram.js.map +0 -7
- package/dist/utils/decodeDirectory.js +0 -2
- package/dist/utils/decodeDirectory.js.map +0 -7
- package/dist/utils/decodeHeader.js +0 -2
- package/dist/utils/decodeHeader.js.map +0 -7
- package/dist/utils/decodeModel.js +0 -2
- package/dist/utils/decodeModel.js.map +0 -7
- package/dist/utils/decompress.js +0 -2
- package/dist/utils/decompress.js.map +0 -7
- package/dist/utils/destroyTexture.js +0 -2
- package/dist/utils/destroyTexture.js.map +0 -7
- package/dist/utils/disposeMesh.js +0 -2
- package/dist/utils/disposeMesh.js.map +0 -7
- package/dist/utils/drawGeometry.js +0 -2
- package/dist/utils/drawGeometry.js.map +0 -7
- package/dist/utils/elevationWGSL.js +0 -24
- package/dist/utils/elevationWGSL.js.map +0 -7
- package/dist/utils/emptyNode.js +0 -2
- package/dist/utils/emptyNode.js.map +0 -7
- package/dist/utils/endZoom.js +0 -2
- package/dist/utils/endZoom.js.map +0 -7
- package/dist/utils/findFeature.js +0 -2
- package/dist/utils/findFeature.js.map +0 -7
- package/dist/utils/geometry.js +0 -1
- package/dist/utils/geometry.js.map +0 -7
- package/dist/utils/getElevation.js +0 -2
- package/dist/utils/getElevation.js.map +0 -7
- package/dist/utils/getHeader.js +0 -2
- package/dist/utils/getHeader.js.map +0 -7
- package/dist/utils/getZxy.js +0 -2
- package/dist/utils/getZxy.js.map +0 -7
- package/dist/utils/glass.js +0 -2
- package/dist/utils/glass.js.map +0 -7
- package/dist/utils/headlight.js +0 -2
- package/dist/utils/headlight.js.map +0 -7
- package/dist/utils/hit.js +0 -2
- package/dist/utils/hit.js.map +0 -7
- package/dist/utils/horizontalPosition.js +0 -2
- package/dist/utils/horizontalPosition.js.map +0 -7
- package/dist/utils/horizontalRay.js +0 -2
- package/dist/utils/horizontalRay.js.map +0 -7
- package/dist/utils/hull.js +0 -2
- package/dist/utils/hull.js.map +0 -7
- package/dist/utils/initSunlight.js +0 -2
- package/dist/utils/initSunlight.js.map +0 -7
- package/dist/utils/initTerrain.js +0 -2
- package/dist/utils/initTerrain.js.map +0 -7
- package/dist/utils/initTraffic.js +0 -40
- package/dist/utils/initTraffic.js.map +0 -7
- package/dist/utils/initWalk.js +0 -2
- package/dist/utils/initWalk.js.map +0 -7
- package/dist/utils/intersectMeshes.js +0 -2
- package/dist/utils/intersectMeshes.js.map +0 -7
- package/dist/utils/isClockWise.js +0 -2
- package/dist/utils/isClockWise.js.map +0 -7
- package/dist/utils/lampPostGeometry.js +0 -2
- package/dist/utils/lampPostGeometry.js.map +0 -7
- package/dist/utils/lightGeometry.js +0 -2
- package/dist/utils/lightGeometry.js.map +0 -7
- package/dist/utils/lightGrid.js +0 -2
- package/dist/utils/lightGrid.js.map +0 -7
- package/dist/utils/limbs.js +0 -2
- package/dist/utils/limbs.js.map +0 -7
- package/dist/utils/loadModel.js +0 -2
- package/dist/utils/loadModel.js.map +0 -7
- package/dist/utils/loadSource.js +0 -2
- package/dist/utils/loadSource.js.map +0 -7
- package/dist/utils/loadTerrain.js +0 -2
- package/dist/utils/loadTerrain.js.map +0 -7
- package/dist/utils/mapCamera.js +0 -2
- package/dist/utils/mapCamera.js.map +0 -7
- package/dist/utils/materialShaders.js +0 -211
- package/dist/utils/materialShaders.js.map +0 -7
- package/dist/utils/mirror.js +0 -2
- package/dist/utils/mirror.js.map +0 -7
- package/dist/utils/moonPosition.js +0 -2
- package/dist/utils/moonPosition.js.map +0 -7
- package/dist/utils/moves.js +0 -2
- package/dist/utils/moves.js.map +0 -7
- package/dist/utils/nativeEvents.js +0 -2
- package/dist/utils/nativeEvents.js.map +0 -7
- package/dist/utils/nativeGeometry.js +0 -2
- package/dist/utils/nativeGeometry.js.map +0 -7
- package/dist/utils/nativeLayer.js +0 -2
- package/dist/utils/nativeLayer.js.map +0 -7
- package/dist/utils/nodeMatrix.js +0 -2
- package/dist/utils/nodeMatrix.js.map +0 -7
- package/dist/utils/onAdd3DLayer.js +0 -2
- package/dist/utils/onAdd3DLayer.js.map +0 -7
- package/dist/utils/onAddSun.js +0 -2
- package/dist/utils/onAddSun.js.map +0 -7
- package/dist/utils/onClick.js +0 -2
- package/dist/utils/onClick.js.map +0 -7
- package/dist/utils/onMapChange.js +0 -2
- package/dist/utils/onMapChange.js.map +0 -7
- package/dist/utils/onPMTileAdd.js +0 -2
- package/dist/utils/onPMTileAdd.js.map +0 -7
- package/dist/utils/onPMTileRemove.js +0 -2
- package/dist/utils/onPMTileRemove.js.map +0 -7
- package/dist/utils/onPointerLeave.js +0 -2
- package/dist/utils/onPointerLeave.js.map +0 -7
- package/dist/utils/onPointerMove.js +0 -2
- package/dist/utils/onPointerMove.js.map +0 -7
- package/dist/utils/onRemove3DLayer.js +0 -2
- package/dist/utils/onRemove3DLayer.js.map +0 -7
- package/dist/utils/onRemoveSun.js +0 -2
- package/dist/utils/onRemoveSun.js.map +0 -7
- package/dist/utils/onTerrainAdd.js +0 -2
- package/dist/utils/onTerrainAdd.js.map +0 -7
- package/dist/utils/onTerrainChange.js +0 -2
- package/dist/utils/onTerrainChange.js.map +0 -7
- package/dist/utils/onTerrainRemove.js +0 -2
- package/dist/utils/onTerrainRemove.js.map +0 -7
- package/dist/utils/onZoomAnim.js +0 -2
- package/dist/utils/onZoomAnim.js.map +0 -7
- package/dist/utils/paints.js +0 -2
- package/dist/utils/paints.js.map +0 -7
- package/dist/utils/parseColor.js +0 -2
- package/dist/utils/parseColor.js.map +0 -7
- package/dist/utils/parts.js +0 -2
- package/dist/utils/parts.js.map +0 -7
- package/dist/utils/projectCelestialBody.js +0 -2
- package/dist/utils/projectCelestialBody.js.map +0 -7
- package/dist/utils/pump.js +0 -2
- package/dist/utils/pump.js.map +0 -7
- package/dist/utils/rasterTiles.js +0 -2
- package/dist/utils/rasterTiles.js.map +0 -7
- package/dist/utils/raycast.js +0 -2
- package/dist/utils/raycast.js.map +0 -7
- package/dist/utils/read.js +0 -2
- package/dist/utils/read.js.map +0 -7
- package/dist/utils/readAccessor.js +0 -2
- package/dist/utils/readAccessor.js.map +0 -7
- package/dist/utils/releaseArea.js +0 -2
- package/dist/utils/releaseArea.js.map +0 -7
- package/dist/utils/removeRasterTile.js +0 -2
- package/dist/utils/removeRasterTile.js.map +0 -7
- package/dist/utils/render.js +0 -15
- package/dist/utils/render.js.map +0 -7
- package/dist/utils/renderSunlight.js +0 -13
- package/dist/utils/renderSunlight.js.map +0 -7
- package/dist/utils/renderers.js +0 -2
- package/dist/utils/renderers.js.map +0 -7
- package/dist/utils/resizeSunlight.js +0 -2
- package/dist/utils/resizeSunlight.js.map +0 -7
- package/dist/utils/roofCoverage.js +0 -2
- package/dist/utils/roofCoverage.js.map +0 -7
- package/dist/utils/routeGeometry.js +0 -2
- package/dist/utils/routeGeometry.js.map +0 -7
- package/dist/utils/scheduledTrips.js +0 -2
- package/dist/utils/scheduledTrips.js.map +0 -7
- package/dist/utils/setGeoJSONData.js +0 -2
- package/dist/utils/setGeoJSONData.js.map +0 -7
- package/dist/utils/setHighlight.js +0 -2
- package/dist/utils/setHighlight.js.map +0 -7
- package/dist/utils/setPMTileOpacity.js +0 -2
- package/dist/utils/setPMTileOpacity.js.map +0 -7
- package/dist/utils/setPMTileZIndex.js +0 -2
- package/dist/utils/setPMTileZIndex.js.map +0 -7
- package/dist/utils/setParent.js +0 -2
- package/dist/utils/setParent.js.map +0 -7
- package/dist/utils/setTerrainHeight.js +0 -2
- package/dist/utils/setTerrainHeight.js.map +0 -7
- package/dist/utils/setVertexColor.js +0 -2
- package/dist/utils/setVertexColor.js.map +0 -7
- package/dist/utils/showFeature.js +0 -2
- package/dist/utils/showFeature.js.map +0 -7
- package/dist/utils/sizes.js +0 -2
- package/dist/utils/sizes.js.map +0 -7
- package/dist/utils/skin.js +0 -2
- package/dist/utils/skin.js.map +0 -7
- package/dist/utils/solarPosition.js +0 -2
- package/dist/utils/solarPosition.js.map +0 -7
- package/dist/utils/sortMeshes.js +0 -2
- package/dist/utils/sortMeshes.js.map +0 -7
- package/dist/utils/speed.js +0 -2
- package/dist/utils/speed.js.map +0 -7
- package/dist/utils/startZoom.js +0 -2
- package/dist/utils/startZoom.js.map +0 -7
- package/dist/utils/taillight.js +0 -2
- package/dist/utils/taillight.js.map +0 -7
- package/dist/utils/terrainAtlas.js +0 -2
- package/dist/utils/terrainAtlas.js.map +0 -7
- package/dist/utils/terrainElevation.js +0 -2
- package/dist/utils/terrainElevation.js.map +0 -7
- package/dist/utils/terrainGrid.js +0 -2
- package/dist/utils/terrainGrid.js.map +0 -7
- package/dist/utils/textureSampler.js +0 -2
- package/dist/utils/textureSampler.js.map +0 -7
- package/dist/utils/tileId.js +0 -2
- package/dist/utils/tileId.js.map +0 -7
- package/dist/utils/toLanes.js +0 -2
- package/dist/utils/toLanes.js.map +0 -7
- package/dist/utils/toSRGB.js +0 -2
- package/dist/utils/toSRGB.js.map +0 -7
- package/dist/utils/tooltip.js +0 -3
- package/dist/utils/tooltip.js.map +0 -7
- package/dist/utils/traffic.js +0 -2
- package/dist/utils/traffic.js.map +0 -7
- package/dist/utils/traverse.js +0 -2
- package/dist/utils/traverse.js.map +0 -7
- package/dist/utils/treeGeometry.js +0 -2
- package/dist/utils/treeGeometry.js.map +0 -7
- package/dist/utils/triangulate.js +0 -2
- package/dist/utils/triangulate.js.map +0 -7
- package/dist/utils/tripsAt.js +0 -2
- package/dist/utils/tripsAt.js.map +0 -7
- package/dist/utils/types.js +0 -2
- package/dist/utils/types.js.map +0 -7
- package/dist/utils/underEntry.js +0 -2
- package/dist/utils/underEntry.js.map +0 -7
- package/dist/utils/update.js +0 -2
- package/dist/utils/update.js.map +0 -7
- package/dist/utils/updateArea.js +0 -2
- package/dist/utils/updateArea.js.map +0 -7
- package/dist/utils/updateCamera.js +0 -2
- package/dist/utils/updateCamera.js.map +0 -7
- package/dist/utils/updatePointLights.js +0 -2
- package/dist/utils/updatePointLights.js.map +0 -7
- package/dist/utils/updateWorldMatrix.js +0 -2
- package/dist/utils/updateWorldMatrix.js.map +0 -7
- package/dist/utils/vehicleOffsets.js +0 -2
- package/dist/utils/vehicleOffsets.js.map +0 -7
- package/dist/utils/vehicles.js +0 -2
- package/dist/utils/vehicles.js.map +0 -7
- package/dist/utils/vertexNormals.js +0 -2
- package/dist/utils/vertexNormals.js.map +0 -7
- package/dist/utils/walk.js +0 -2
- package/dist/utils/walk.js.map +0 -7
- package/dist/utils/white.js +0 -2
- package/dist/utils/white.js.map +0 -7
- package/dist/utils/worldLights.js +0 -2
- package/dist/utils/worldLights.js.map +0 -7
- package/dist/utils/wrap.js +0 -2
- package/dist/utils/wrap.js.map +0 -7
- package/src/utils/addBridges.js +0 -66
- package/src/utils/addRasterTile.js +0 -112
- package/src/utils/along.js +0 -9
- package/src/utils/atmosphere.js +0 -20
- package/src/utils/attach.js +0 -255
- package/src/utils/bindSunlight.js +0 -12
- package/src/utils/box.js +0 -1
- package/src/utils/bridgeElevation.js +0 -18
- package/src/utils/build.js +0 -20
- package/src/utils/cameraControls.js +0 -287
- package/src/utils/collider.js +0 -62
- package/src/utils/computeBounds.js +0 -17
- package/src/utils/conformModelToTerrain.js +0 -69
- package/src/utils/createMesh.js +0 -31
- package/src/utils/createProgram.js +0 -92
- package/src/utils/decodeDirectory.js +0 -40
- package/src/utils/decodeHeader.js +0 -15
- package/src/utils/decodeModel.js +0 -43
- package/src/utils/destroyTexture.js +0 -7
- package/src/utils/disposeMesh.js +0 -13
- package/src/utils/drawGeometry.js +0 -122
- package/src/utils/elevationWGSL.js +0 -27
- package/src/utils/emptyNode.js +0 -9
- package/src/utils/endZoom.js +0 -15
- package/src/utils/findFeature.js +0 -49
- package/src/utils/geometry.js +0 -2
- package/src/utils/getElevation.js +0 -10
- package/src/utils/getZxy.js +0 -76
- package/src/utils/glass.js +0 -1
- package/src/utils/hit.js +0 -41
- package/src/utils/initSunlight.js +0 -9
- package/src/utils/initTerrain.js +0 -19
- package/src/utils/initTraffic.js +0 -93
- package/src/utils/initWalk.js +0 -72
- package/src/utils/intersectMeshes.js +0 -121
- package/src/utils/isClockWise.js +0 -12
- package/src/utils/lampPostGeometry.js +0 -26
- package/src/utils/lightGeometry.js +0 -22
- package/src/utils/lightGrid.js +0 -50
- package/src/utils/loadModel.js +0 -217
- package/src/utils/loadTerrain.js +0 -65
- package/src/utils/mapCamera.js +0 -432
- package/src/utils/materialShaders.js +0 -243
- package/src/utils/mirror.js +0 -6
- package/src/utils/nativeEvents.js +0 -77
- package/src/utils/nativeGeometry.js +0 -131
- package/src/utils/nativeLayer.js +0 -317
- package/src/utils/onAdd3DLayer.js +0 -31
- package/src/utils/onAddSun.js +0 -147
- package/src/utils/onMapChange.js +0 -16
- package/src/utils/onPMTileAdd.js +0 -15
- package/src/utils/onPMTileRemove.js +0 -8
- package/src/utils/onRemove3DLayer.js +0 -78
- package/src/utils/onRemoveSun.js +0 -3
- package/src/utils/onTerrainAdd.js +0 -18
- package/src/utils/onTerrainChange.js +0 -13
- package/src/utils/onTerrainRemove.js +0 -40
- package/src/utils/onZoomAnim.js +0 -14
- package/src/utils/parts.js +0 -16
- package/src/utils/pump.js +0 -226
- package/src/utils/rasterTiles.js +0 -285
- package/src/utils/raycast.js +0 -60
- package/src/utils/readAccessor.js +0 -68
- package/src/utils/releaseArea.js +0 -34
- package/src/utils/removeRasterTile.js +0 -13
- package/src/utils/render.js +0 -406
- package/src/utils/renderSunlight.js +0 -170
- package/src/utils/resizeSunlight.js +0 -15
- package/src/utils/roofCoverage.js +0 -47
- package/src/utils/routeGeometry.js +0 -22
- package/src/utils/scheduledTrips.js +0 -29
- package/src/utils/setGeoJSONData.js +0 -11
- package/src/utils/setHighlight.js +0 -13
- package/src/utils/setPMTileOpacity.js +0 -7
- package/src/utils/setPMTileZIndex.js +0 -7
- package/src/utils/setVertexColor.js +0 -14
- package/src/utils/showFeature.js +0 -27
- package/src/utils/skin.js +0 -2
- package/src/utils/sortMeshes.js +0 -12
- package/src/utils/terrainAtlas.js +0 -21
- package/src/utils/terrainElevation.js +0 -20
- package/src/utils/terrainGrid.js +0 -23
- package/src/utils/tileId.js +0 -18
- package/src/utils/toLanes.js +0 -7
- package/src/utils/tooltip.js +0 -6
- package/src/utils/traffic.js +0 -315
- package/src/utils/traverse.js +0 -6
- package/src/utils/treeGeometry.js +0 -45
- package/src/utils/triangulate.js +0 -100
- package/src/utils/tripsAt.js +0 -16
- package/src/utils/underEntry.js +0 -17
- package/src/utils/update.js +0 -18
- package/src/utils/updateArea.js +0 -40
- package/src/utils/updateCamera.js +0 -32
- package/src/utils/updatePointLights.js +0 -38
- package/src/utils/updateWorldMatrix.js +0 -47
- package/src/utils/vehicleOffsets.js +0 -8
- package/src/utils/vehicles.js +0 -65
- package/src/utils/vertexNormals.js +0 -30
- package/src/utils/walk.js +0 -187
- package/src/utils/worldLights.js +0 -25
- /package/src/{utils → archives}/decompress.js +0 -0
- /package/src/{utils → archives}/getHeader.js +0 -0
- /package/src/{utils → archives}/loadSource.js +0 -0
- /package/src/{utils → archives}/read.js +0 -0
- /package/src/{utils → collision}/horizontalRay.js +0 -0
- /package/src/{utils → constants}/CELL.js +0 -0
- /package/src/{utils/sizes.js → constants/accessorSizes.js} +0 -0
- /package/src/{utils/types.js → constants/accessorTypes.js} +0 -0
- /package/src/{utils → constants}/colliders.js +0 -0
- /package/src/{utils → constants}/headlight.js +0 -0
- /package/src/{utils → constants}/hull.js +0 -0
- /package/src/{utils → constants}/limbs.js +0 -0
- /package/src/{utils → constants}/moves.js +0 -0
- /package/src/{utils → constants}/paints.js +0 -0
- /package/src/{utils → constants}/renderers.js +0 -0
- /package/src/{utils → constants}/speed.js +0 -0
- /package/src/{utils → constants}/taillight.js +0 -0
- /package/src/{utils → constants}/white.js +0 -0
- /package/src/{utils → models}/nodeMatrix.js +0 -0
- /package/src/{utils → models}/textureSampler.js +0 -0
- /package/src/{utils → picking}/onClick.js +0 -0
- /package/src/{utils → picking}/onPointerLeave.js +0 -0
- /package/src/{utils → picking}/onPointerMove.js +0 -0
- /package/src/{utils → scene}/setParent.js +0 -0
- /package/src/{utils → scene}/startZoom.js +0 -0
- /package/src/{utils → sunlight}/horizontalPosition.js +0 -0
- /package/src/{utils → sunlight}/moonPosition.js +0 -0
- /package/src/{utils → sunlight}/projectCelestialBody.js +0 -0
- /package/src/{utils → sunlight}/solarPosition.js +0 -0
- /package/src/{utils → terrain}/setTerrainHeight.js +0 -0
package/src/utils/mapCamera.js
DELETED
|
@@ -1,432 +0,0 @@
|
|
|
1
|
-
const mapMethods = Object.defineProperties({}, Object.getOwnPropertyDescriptors(L.Map.prototype));
|
|
2
|
-
const radians = Math.PI / 180;
|
|
3
|
-
const pointOf = point => Array.isArray(point) ? new L.Point(point[0], point[1]) : new L.Point(point.x, point.y);
|
|
4
|
-
|
|
5
|
-
L.Map.mergeOptions({
|
|
6
|
-
rotate: true, bearing: 0, pitch: 0, pitchMaxDistance: 3,
|
|
7
|
-
rotateControl: true, shiftKeyRotate: true, pitchDrag: true,
|
|
8
|
-
touchRotate: false, touchPitch: false, compassBearing: false,
|
|
9
|
-
});
|
|
10
|
-
|
|
11
|
-
function angles(map) {
|
|
12
|
-
const bearing = map.getBearing() * radians, pitch = map.getPitch() * radians;
|
|
13
|
-
return [Math.cos(bearing), Math.sin(bearing), Math.cos(pitch), Math.sin(pitch)];
|
|
14
|
-
}
|
|
15
|
-
|
|
16
|
-
// Ground coordinates only: the GPU camera handles elevated geometry, never CSS transforms.
|
|
17
|
-
function project(map, point, inverse = false, limit = false) {
|
|
18
|
-
const half = map.getSize().divideBy(2), distance = map.getSize().y * 1.5;
|
|
19
|
-
if (!distance) return pointOf(point);
|
|
20
|
-
const [cos, sin, tilt, rise] = angles(map);
|
|
21
|
-
const p = pointOf(point).subtract(half);
|
|
22
|
-
if (inverse) {
|
|
23
|
-
const far = map.getSize().y * map.options.pitchMaxDistance;
|
|
24
|
-
const denominator = tilt * distance + rise * p.y;
|
|
25
|
-
let v = denominator > 0 ? p.y * distance / denominator : -far;
|
|
26
|
-
if (limit) v = Math.max(-far, Math.min(far, v));
|
|
27
|
-
const u = p.x * (distance - rise * v) / distance;
|
|
28
|
-
return new L.Point(cos * u + sin * v, -sin * u + cos * v).add(half);
|
|
29
|
-
}
|
|
30
|
-
const u = cos * p.x - sin * p.y, v = sin * p.x + cos * p.y;
|
|
31
|
-
const scale = distance / (distance - rise * v);
|
|
32
|
-
return new L.Point(u * scale, tilt * v * scale).add(half);
|
|
33
|
-
}
|
|
34
|
-
|
|
35
|
-
function displayPoint(map, point) {
|
|
36
|
-
return map.layerPointToContainerPoint(point).subtract(map._getMapPanePos());
|
|
37
|
-
}
|
|
38
|
-
|
|
39
|
-
function animationPoint(map, point, inverse = false) {
|
|
40
|
-
const view = map._cameraView;
|
|
41
|
-
if (!view) return point;
|
|
42
|
-
const half = map.getSize().divideBy(2), scale = map.getZoomScale(view.zoom);
|
|
43
|
-
const shift = map.project(map.getCenter(), view.zoom).subtract(map.project(view.center, view.zoom));
|
|
44
|
-
return inverse ? point.subtract(half).subtract(shift).divideBy(scale).add(half) :
|
|
45
|
-
point.subtract(half).multiplyBy(scale).add(shift).add(half);
|
|
46
|
-
}
|
|
47
|
-
|
|
48
|
-
function groundBounds(map, padding = [0, 0]) {
|
|
49
|
-
const min = pointOf(padding).divideBy(2), max = map.getSize().subtract(min);
|
|
50
|
-
return new L.Bounds([[min.x, min.y], [max.x, min.y], [min.x, max.y], [max.x, max.y]]
|
|
51
|
-
.map(point => project(map, point, true, true)));
|
|
52
|
-
}
|
|
53
|
-
|
|
54
|
-
function fitCameraBounds(map, bounds, options = {}) {
|
|
55
|
-
bounds = bounds.getBounds ? bounds.getBounds() : bounds instanceof L.LatLngBounds ? bounds : new L.LatLngBounds(bounds);
|
|
56
|
-
const zoom = map.getZoom() ?? 0, half = map.getSize().divideBy(2), distance = map.getSize().y * 1.5;
|
|
57
|
-
const min = pointOf(options.paddingTopLeft || options.padding || [0, 0]).subtract(half);
|
|
58
|
-
const max = half.subtract(pointOf(options.paddingBottomRight || options.padding || [0, 0]));
|
|
59
|
-
const [cos, sin, tilt, rise] = angles(map);
|
|
60
|
-
const far = map.getSize().y * map.options.pitchMaxDistance;
|
|
61
|
-
const vertical = y => tilt * distance + rise * y > 0
|
|
62
|
-
? Math.max(-far, Math.min(far, y * distance / (tilt * distance + rise * y))) : -far;
|
|
63
|
-
const top = vertical(min.y), bottom = vertical(max.y);
|
|
64
|
-
const origin = map.project(bounds.getNorthWest(), zoom).add(map.project(bounds.getSouthEast(), zoom)).divideBy(2);
|
|
65
|
-
const points = [bounds.getNorthWest(), bounds.getNorthEast(), bounds.getSouthWest(), bounds.getSouthEast()]
|
|
66
|
-
.map(latlng => {
|
|
67
|
-
const p = map.project(latlng, zoom).subtract(origin);
|
|
68
|
-
return new L.Point(cos * p.x - sin * p.y, sin * p.x + cos * p.y);
|
|
69
|
-
});
|
|
70
|
-
const low = Math.min(...points.map(p => p.y)), high = Math.max(...points.map(p => p.y));
|
|
71
|
-
const leftSlope = min.x * rise / distance, rightSlope = max.x * rise / distance;
|
|
72
|
-
const slope = rightSlope - leftSlope;
|
|
73
|
-
const left = Math.min(...points.map(p => p.x + leftSlope * p.y));
|
|
74
|
-
const right = Math.max(...points.map(p => p.x + rightSlope * p.y));
|
|
75
|
-
// Perspective viewport edges are straight lines on the ground: fit all four corners, not their screen midpoint.
|
|
76
|
-
const scale = Math.min((bottom - top) / (high - low),
|
|
77
|
-
(max.x - min.x - slope * top) / (right - left - slope * low));
|
|
78
|
-
let target = map.getScaleZoom(scale, zoom);
|
|
79
|
-
const snap = map.options.zoomSnap;
|
|
80
|
-
if (snap) target = Math.floor(Math.round(target / (snap / 100)) / 100) * snap;
|
|
81
|
-
target = Math.max(map.getMinZoom(), Math.min(map.getMaxZoom(), options.maxZoom ?? Infinity, target));
|
|
82
|
-
if (!Number.isFinite(target)) return { center: bounds.getCenter(), zoom: target };
|
|
83
|
-
const actual = map.getZoomScale(target, zoom);
|
|
84
|
-
const vMin = high * actual - bottom, vMax = low * actual - top;
|
|
85
|
-
const v = Math.max(vMin, slope ? (actual * (right - left) - max.x + min.x) / slope : vMin);
|
|
86
|
-
const centerY = (Math.min(vMax, v) + vMax) / 2;
|
|
87
|
-
const centerX = (actual * (left + right) - min.x - max.x - (leftSlope + rightSlope) * centerY) / 2;
|
|
88
|
-
const center = origin.add(new L.Point(cos * centerX + sin * centerY, -sin * centerX + cos * centerY).divideBy(actual));
|
|
89
|
-
return { center: map.unproject(center, zoom), zoom: target };
|
|
90
|
-
}
|
|
91
|
-
|
|
92
|
-
function updateSky() {
|
|
93
|
-
const height = this.getSize().y, pitch = this.getPitch() * radians;
|
|
94
|
-
const far = height * this.options.pitchMaxDistance, distance = height * 1.5;
|
|
95
|
-
const top = height / 2 - far * Math.cos(pitch) * distance / (distance + Math.sin(pitch) * far);
|
|
96
|
-
if (top > 0 && !this._pitchSky) {
|
|
97
|
-
this._pitchSky = L.DomUtil.create('div', 'leaflet-pitch-sky', this.getContainer());
|
|
98
|
-
this._pitchSky.setAttribute('aria-hidden', 'true');
|
|
99
|
-
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))';
|
|
100
|
-
}
|
|
101
|
-
if (this._pitchSky) {
|
|
102
|
-
this._pitchSky.style.height = `${Math.max(0, Math.ceil(top))}px`;
|
|
103
|
-
this._pitchSky.style.display = top > 0 ? '' : 'none';
|
|
104
|
-
}
|
|
105
|
-
}
|
|
106
|
-
|
|
107
|
-
L.Map.include({
|
|
108
|
-
getBearing() { return this._cameraBearing ?? 0; },
|
|
109
|
-
getPitch() { return this._cameraPitch ?? 0; },
|
|
110
|
-
_stopPitchBearingAnimation() {
|
|
111
|
-
cancelAnimationFrame(this._cameraFrame);
|
|
112
|
-
this._cameraFrame = null;
|
|
113
|
-
return this;
|
|
114
|
-
},
|
|
115
|
-
_setPitchAndBearing(pitch, bearing) {
|
|
116
|
-
if (!Number.isFinite(pitch) || !Number.isFinite(bearing)) throw new TypeError('Camera angles must be finite numbers');
|
|
117
|
-
const previousPitch = this.getPitch(), previousBearing = this.getBearing();
|
|
118
|
-
this._cameraPitch = Math.max(0, Math.min(85, pitch));
|
|
119
|
-
this._cameraBearing = ((bearing % 360) + 360) % 360;
|
|
120
|
-
if (this._loaded) {
|
|
121
|
-
updateSky.call(this);
|
|
122
|
-
if (previousBearing !== this.getBearing()) this.fire('rotate', { bearing: this.getBearing() });
|
|
123
|
-
if (previousPitch !== this.getPitch()) this.fire('pitch', { pitch: this.getPitch() });
|
|
124
|
-
}
|
|
125
|
-
return this;
|
|
126
|
-
},
|
|
127
|
-
_animateCamera(pitch, bearing, options = {}) {
|
|
128
|
-
cancelAnimationFrame(this._cameraFrame);
|
|
129
|
-
if (!Number.isFinite(pitch) || !Number.isFinite(bearing)) throw new TypeError('Camera angles must be finite numbers');
|
|
130
|
-
if (!options.animate || matchMedia('(prefers-reduced-motion: reduce)').matches) {
|
|
131
|
-
return this._setPitchAndBearing(pitch, bearing);
|
|
132
|
-
}
|
|
133
|
-
const duration = options.duration ?? 0.3;
|
|
134
|
-
if (!Number.isFinite(duration) || duration < 0) throw new TypeError('Camera duration must be nonnegative');
|
|
135
|
-
const start = performance.now(), fromPitch = this.getPitch(), fromBearing = this.getBearing();
|
|
136
|
-
const delta = ((bearing - fromBearing) % 360 + 540) % 360 - 180;
|
|
137
|
-
const frame = now => {
|
|
138
|
-
const progress = duration ? Math.min(1, (now - start) / (duration * 1000)) : 1;
|
|
139
|
-
const eased = 1 - (1 - progress) ** 3;
|
|
140
|
-
this._setPitchAndBearing(fromPitch + (Math.max(0, Math.min(85, pitch)) - fromPitch) * eased,
|
|
141
|
-
fromBearing + delta * eased);
|
|
142
|
-
if (progress < 1) this._cameraFrame = requestAnimationFrame(frame);
|
|
143
|
-
};
|
|
144
|
-
this._cameraFrame = requestAnimationFrame(frame);
|
|
145
|
-
return this;
|
|
146
|
-
},
|
|
147
|
-
setBearing(bearing, options) { return this._animateCamera(this.getPitch(), bearing, options); },
|
|
148
|
-
setPitch(pitch, options) { return this._animateCamera(pitch, this.getBearing(), options); },
|
|
149
|
-
resetNorth(options = { animate: true }) { return this.setBearing(0, options); },
|
|
150
|
-
resetNorthPitch(options = { animate: true }) { return this._animateCamera(0, 0, options); },
|
|
151
|
-
layerPointToContainerPoint(point) {
|
|
152
|
-
return project(this, animationPoint(this, mapMethods.layerPointToContainerPoint.call(this, point)));
|
|
153
|
-
},
|
|
154
|
-
containerPointToLayerPoint(point) {
|
|
155
|
-
return mapMethods.containerPointToLayerPoint.call(this, animationPoint(this, project(this, point, true), true));
|
|
156
|
-
},
|
|
157
|
-
_getCenterLayerPoint() {
|
|
158
|
-
return mapMethods.containerPointToLayerPoint.call(this, this.getSize().divideBy(2));
|
|
159
|
-
},
|
|
160
|
-
_updateCameraOverlays() {
|
|
161
|
-
for (const layer of Object.values(this._layers)) {
|
|
162
|
-
if (layer instanceof L.Marker) layer.update();
|
|
163
|
-
else if (layer instanceof L.Popup || layer instanceof L.Tooltip) layer._updatePosition();
|
|
164
|
-
}
|
|
165
|
-
},
|
|
166
|
-
panBy(offset, options) {
|
|
167
|
-
const half = this.getSize().divideBy(2);
|
|
168
|
-
const ground = half.subtract(project(this, half.subtract(pointOf(offset)), true));
|
|
169
|
-
return mapMethods.panBy.call(this, ground, options);
|
|
170
|
-
},
|
|
171
|
-
setZoomAround(latlng, zoom, options) {
|
|
172
|
-
if (!this.getPitch() && !this.getBearing()) return mapMethods.setZoomAround.call(this, latlng, zoom, options);
|
|
173
|
-
zoom = this._limitZoom(zoom);
|
|
174
|
-
const scale = this.getZoomScale(zoom), half = this.getSize().divideBy(2);
|
|
175
|
-
const screen = latlng instanceof L.Point ? latlng : this.latLngToContainerPoint(latlng);
|
|
176
|
-
const center = this.containerPointToLayerPoint(half), anchor = this.containerPointToLayerPoint(screen);
|
|
177
|
-
const next = center.add(anchor.subtract(center).multiplyBy(1 - 1 / scale));
|
|
178
|
-
return this.setView(this.layerPointToLatLng(next), zoom, { zoom: options });
|
|
179
|
-
},
|
|
180
|
-
panInside(latlng, options = {}) {
|
|
181
|
-
if (!this.getPitch() && !this.getBearing()) return mapMethods.panInside.call(this, latlng, options);
|
|
182
|
-
const min = pointOf(options.paddingTopLeft || options.padding || [0, 0]);
|
|
183
|
-
const max = this.getSize().subtract(pointOf(options.paddingBottomRight || options.padding || [0, 0]));
|
|
184
|
-
const screen = this.latLngToContainerPoint(latlng);
|
|
185
|
-
const safe = new L.Point(Math.max(min.x, Math.min(max.x, screen.x)),
|
|
186
|
-
Math.max(min.y, Math.min(max.y, screen.y)));
|
|
187
|
-
if (safe.equals(screen)) return this;
|
|
188
|
-
const delta = this.latLngToLayerPoint(latlng).subtract(this.containerPointToLayerPoint(safe));
|
|
189
|
-
return this.panTo(this.unproject(this.project(this.getCenter()).add(delta)), options);
|
|
190
|
-
},
|
|
191
|
-
_limitCenter(center, zoom, bounds) {
|
|
192
|
-
if (!bounds || !this._loaded || !this.getPitch() && !this.getBearing()) {
|
|
193
|
-
return mapMethods._limitCenter.call(this, center, zoom, bounds);
|
|
194
|
-
}
|
|
195
|
-
const half = this.getSize().divideBy(2), footprint = groundBounds(this), point = this.project(center, zoom);
|
|
196
|
-
const view = new L.Bounds(point.add(footprint.min.subtract(half)), point.add(footprint.max.subtract(half)));
|
|
197
|
-
const offset = this._getBoundsOffset(view, bounds, zoom);
|
|
198
|
-
return Math.abs(offset.x) <= 1 && Math.abs(offset.y) <= 1 ? center : this.unproject(point.add(offset), zoom);
|
|
199
|
-
},
|
|
200
|
-
_limitOffset(offset, bounds) {
|
|
201
|
-
if (!bounds || !this.getPitch() && !this.getBearing()) return mapMethods._limitOffset.call(this, offset, bounds);
|
|
202
|
-
const half = this.getSize().divideBy(2), ground = half.subtract(project(this, half.subtract(offset), true));
|
|
203
|
-
const center = this.project(this.getCenter());
|
|
204
|
-
const limited = this.project(this._limitCenter(this.unproject(center.add(ground)), this.getZoom(), bounds));
|
|
205
|
-
return half.subtract(project(this, half.subtract(limited.subtract(center))));
|
|
206
|
-
},
|
|
207
|
-
_getBoundsCenterZoom(bounds, options) {
|
|
208
|
-
return this.getPitch() || this.getBearing() ? fitCameraBounds(this, bounds, options) :
|
|
209
|
-
mapMethods._getBoundsCenterZoom.call(this, bounds, options);
|
|
210
|
-
},
|
|
211
|
-
getBoundsZoom(bounds, inside, padding) {
|
|
212
|
-
if (!this.getPitch() && !this.getBearing()) return mapMethods.getBoundsZoom.call(this, bounds, inside, padding);
|
|
213
|
-
if (!inside) return fitCameraBounds(this, bounds, { padding: pointOf(padding || [0, 0]).divideBy(2) }).zoom;
|
|
214
|
-
bounds = bounds instanceof L.LatLngBounds ? bounds : new L.LatLngBounds(bounds);
|
|
215
|
-
const footprint = groundBounds(this, padding).getSize(), size = this.project(bounds.getSouthEast()).subtract(this.project(bounds.getNorthWest()));
|
|
216
|
-
const zoom = this.getScaleZoom(Math.max(footprint.x / size.x, footprint.y / size.y));
|
|
217
|
-
const snap = this.options.zoomSnap;
|
|
218
|
-
return Math.max(this.getMinZoom(), Math.min(this.getMaxZoom(), snap ? Math.ceil(zoom / snap) * snap : zoom));
|
|
219
|
-
},
|
|
220
|
-
_tryAnimatedPan(center, options) {
|
|
221
|
-
// Leaflet's geographic recentering already supplies ground pixels, not screen pixels.
|
|
222
|
-
const offset = this._getCenterOffset(center)._trunc();
|
|
223
|
-
if (options?.animate !== true && !this.getSize().contains(offset)) return false;
|
|
224
|
-
mapMethods.panBy.call(this, offset, options);
|
|
225
|
-
return true;
|
|
226
|
-
},
|
|
227
|
-
getBounds() {
|
|
228
|
-
if (!this.getPitch() && !this.getBearing()) return mapMethods.getBounds.call(this);
|
|
229
|
-
const footprint = groundBounds(this), bounds = new L.LatLngBounds();
|
|
230
|
-
for (const point of [footprint.min, footprint.max]) {
|
|
231
|
-
const raw = mapMethods.containerPointToLayerPoint.call(this, animationPoint(this, point, true));
|
|
232
|
-
bounds.extend(this.layerPointToLatLng(raw));
|
|
233
|
-
}
|
|
234
|
-
return bounds;
|
|
235
|
-
},
|
|
236
|
-
});
|
|
237
|
-
|
|
238
|
-
L.Map.addInitHook(function () {
|
|
239
|
-
if (!document.getElementById('leaflet-camera-zoom-style')) {
|
|
240
|
-
const style = document.createElement('style');
|
|
241
|
-
style.id = 'leaflet-camera-zoom-style';
|
|
242
|
-
style.textContent = ['.leaflet-marker-icon', '.leaflet-marker-shadow', '.leaflet-popup', '.leaflet-tooltip']
|
|
243
|
-
.map(selector => `.leaflet-camera-zoom ${selector}`).join(',') + '{transition:none!important}';
|
|
244
|
-
document.head.append(style);
|
|
245
|
-
}
|
|
246
|
-
this._setPitchAndBearing(this.options.pitch, this.options.bearing);
|
|
247
|
-
this.on('load resize pitch', updateSky);
|
|
248
|
-
this.on('rotate pitch', () => {
|
|
249
|
-
if (this.options.maxBounds) this._panInsideMaxBounds();
|
|
250
|
-
});
|
|
251
|
-
this.once('unload', () => {
|
|
252
|
-
cancelAnimationFrame(this._cameraFrame);
|
|
253
|
-
this._pitchSky?.remove();
|
|
254
|
-
});
|
|
255
|
-
this.whenReady(() => {
|
|
256
|
-
const draggable = this.dragging?._draggable;
|
|
257
|
-
if (!draggable) return;
|
|
258
|
-
const pan = () => {
|
|
259
|
-
if (!this.getPitch() && !this.getBearing()) return;
|
|
260
|
-
const half = this.getSize().divideBy(2), delta = draggable._newPos.subtract(draggable._startPos);
|
|
261
|
-
const ground = half.subtract(project(this, half.subtract(delta), true));
|
|
262
|
-
draggable._newPos = draggable._startPos.add(ground);
|
|
263
|
-
};
|
|
264
|
-
draggable.on('predrag', pan);
|
|
265
|
-
this.once('unload', () => draggable.off('predrag', pan));
|
|
266
|
-
});
|
|
267
|
-
if (this.options.rotate || this.options.trackContainerMutation) {
|
|
268
|
-
this.cameraReady = import('./cameraControls.js').then(({ cameraControls }) => {
|
|
269
|
-
if (!this._container?._leaflet_id) return;
|
|
270
|
-
cameraControls(this);
|
|
271
|
-
});
|
|
272
|
-
this.cameraReady.catch(error => this.fire('error', { error }));
|
|
273
|
-
}
|
|
274
|
-
});
|
|
275
|
-
|
|
276
|
-
const markerMethods = Object.defineProperties({}, Object.getOwnPropertyDescriptors(L.Marker.prototype));
|
|
277
|
-
L.Marker.mergeOptions({ rotation: 0, rotateWithView: false, keepUpright: false, scale: 1 });
|
|
278
|
-
L.Marker.include({
|
|
279
|
-
setIcon(icon) {
|
|
280
|
-
if (!(icon instanceof L.DivIcon)) icon.options.crossOrigin ||= true;
|
|
281
|
-
const result = markerMethods.setIcon.call(this, icon);
|
|
282
|
-
if (this._map && !(icon instanceof L.DivIcon)) this._initNativeGPU(this._map);
|
|
283
|
-
return result;
|
|
284
|
-
},
|
|
285
|
-
setRotation(rotation) {
|
|
286
|
-
if (!Number.isFinite(rotation)) throw new TypeError('Marker rotation must be finite');
|
|
287
|
-
this.options.rotation = rotation;
|
|
288
|
-
this.update();
|
|
289
|
-
this._nativeGPU?.refresh?.();
|
|
290
|
-
return this;
|
|
291
|
-
},
|
|
292
|
-
_cameraIconPoint(x, y) {
|
|
293
|
-
let rotation = this.options.rotation + (this.options.rotateWithView ? this._map.getBearing() * radians : 0);
|
|
294
|
-
if (this.options.keepUpright && Math.cos(rotation) < 0) rotation += Math.PI;
|
|
295
|
-
const scale = this.options.scale;
|
|
296
|
-
return new L.Point((x * Math.cos(rotation) - y * Math.sin(rotation)) * scale,
|
|
297
|
-
(x * Math.sin(rotation) + y * Math.cos(rotation)) * scale);
|
|
298
|
-
},
|
|
299
|
-
getEvents() {
|
|
300
|
-
return { ...markerMethods.getEvents.call(this), rotate: this.update, pitch: this.update, move: this.update };
|
|
301
|
-
},
|
|
302
|
-
_setPos(point) {
|
|
303
|
-
markerMethods._setPos.call(this, displayPoint(this._map, point));
|
|
304
|
-
for (const [element, key] of [[this._icon, 'iconAnchor'], [this._shadow, 'shadowAnchor']]) {
|
|
305
|
-
if (!element) continue;
|
|
306
|
-
const direction = this._cameraIconPoint(1, 0), options = this.options.icon.options;
|
|
307
|
-
const anchor = options[key] || options.iconAnchor;
|
|
308
|
-
element.style.transformOrigin = anchor ? `${anchor.x ?? anchor[0]}px ${anchor.y ?? anchor[1]}px` : 'center';
|
|
309
|
-
element.style.transform += ` rotate(${Math.atan2(direction.y, direction.x)}rad) scale(${this.options.scale})`;
|
|
310
|
-
}
|
|
311
|
-
},
|
|
312
|
-
_updateZIndex(offset) {
|
|
313
|
-
markerMethods._updateZIndex.call(this, offset);
|
|
314
|
-
const changed = this._cameraZIndexOffset !== offset;
|
|
315
|
-
this._cameraZIndexOffset = offset;
|
|
316
|
-
if (changed) this._nativeGPU?.refresh?.();
|
|
317
|
-
},
|
|
318
|
-
_initInteraction() {
|
|
319
|
-
const result = markerMethods._initInteraction.call(this);
|
|
320
|
-
cameraMarkerDrag.call(this);
|
|
321
|
-
return result;
|
|
322
|
-
},
|
|
323
|
-
});
|
|
324
|
-
|
|
325
|
-
// Keep Leaflet's focusable marker and its drag events; only translate its screen position back to ground.
|
|
326
|
-
function cameraMarkerDrag() {
|
|
327
|
-
if (!this.dragging || this.dragging._cameraDrag) return;
|
|
328
|
-
const drag = this.dragging, original = drag._onDrag, adjustPan = drag._adjustPan;
|
|
329
|
-
drag._onDrag = function (event) {
|
|
330
|
-
const map = this._marker._map;
|
|
331
|
-
const screen = L.DomUtil.getPosition(this._marker._icon).add(map._getMapPanePos());
|
|
332
|
-
const point = map.containerPointToLayerPoint(screen);
|
|
333
|
-
const icon = this._marker._icon;
|
|
334
|
-
L.DomUtil.setPosition(icon, point);
|
|
335
|
-
original.call(this, event);
|
|
336
|
-
this._marker._setPos(point);
|
|
337
|
-
};
|
|
338
|
-
drag._adjustPan = function (event) {
|
|
339
|
-
const marker = this._marker, map = marker._map;
|
|
340
|
-
if (!map.getPitch() && !map.getBearing()) return adjustPan.call(this, event);
|
|
341
|
-
const screen = L.DomUtil.getPosition(marker._icon).add(map._getMapPanePos());
|
|
342
|
-
const size = map.getSize(), padding = pointOf(marker.options.autoPanPadding);
|
|
343
|
-
const speed = marker.options.autoPanSpeed;
|
|
344
|
-
const movement = new L.Point(
|
|
345
|
-
(Math.max(0, screen.x - size.x + padding.x) - Math.max(0, padding.x - screen.x)) / Math.max(1, padding.x) * speed,
|
|
346
|
-
(Math.max(0, screen.y - size.y + padding.y) - Math.max(0, padding.y - screen.y)) / Math.max(1, padding.y) * speed);
|
|
347
|
-
if (!movement.x && !movement.y) return;
|
|
348
|
-
const pane = map._getMapPanePos();
|
|
349
|
-
map.panBy(movement, { animate: false });
|
|
350
|
-
const shift = pane.subtract(map._getMapPanePos());
|
|
351
|
-
this._draggable._newPos._add(shift);
|
|
352
|
-
this._draggable._startPos._add(shift);
|
|
353
|
-
L.DomUtil.setPosition(marker._icon, this._draggable._newPos);
|
|
354
|
-
this._onDrag(event);
|
|
355
|
-
this._panRequest = requestAnimationFrame(() => this._adjustPan(event));
|
|
356
|
-
};
|
|
357
|
-
// The handler may already be enabled and listening with its original method.
|
|
358
|
-
const enabled = drag.enabled();
|
|
359
|
-
if (enabled) {
|
|
360
|
-
drag._draggable.off('drag', original, drag);
|
|
361
|
-
drag._draggable.on('drag', drag._onDrag, drag);
|
|
362
|
-
}
|
|
363
|
-
drag._cameraDrag = true;
|
|
364
|
-
}
|
|
365
|
-
|
|
366
|
-
for (const Class of [L.Popup, L.Tooltip]) {
|
|
367
|
-
const events = Class.prototype.getEvents;
|
|
368
|
-
Class.include({
|
|
369
|
-
getEvents() {
|
|
370
|
-
return { ...events.call(this), rotate: this._updatePosition, pitch: this._updatePosition, move: this._updatePosition };
|
|
371
|
-
},
|
|
372
|
-
});
|
|
373
|
-
}
|
|
374
|
-
const popupPosition = L.Popup.prototype._updatePosition;
|
|
375
|
-
const popupPan = L.Popup.prototype._adjustPan;
|
|
376
|
-
L.Popup.include({
|
|
377
|
-
_adjustPan() {
|
|
378
|
-
const map = this._map;
|
|
379
|
-
if (!map.getPitch() && !map.getBearing()) return popupPan.call(this);
|
|
380
|
-
if (!this.options.autoPan) return;
|
|
381
|
-
if (map._panAnim) map._panAnim.stop();
|
|
382
|
-
if (this._autopanning) { this._autopanning = false; return; }
|
|
383
|
-
const rect = this._container.getBoundingClientRect(), container = map.getContainer().getBoundingClientRect();
|
|
384
|
-
const min = pointOf(this.options.autoPanPaddingTopLeft || this.options.autoPanPadding);
|
|
385
|
-
const max = map.getSize().subtract(pointOf(this.options.autoPanPaddingBottomRight || this.options.autoPanPadding));
|
|
386
|
-
const left = rect.left - container.left, top = rect.top - container.top;
|
|
387
|
-
const right = rect.right - container.left, bottom = rect.bottom - container.top;
|
|
388
|
-
const dx = Math.min(0, left - min.x) || Math.max(0, right - max.x);
|
|
389
|
-
const dy = Math.min(0, top - min.y) || Math.max(0, bottom - max.y);
|
|
390
|
-
if (!dx && !dy) return;
|
|
391
|
-
if (this.options.keepInView) this._autopanning = true;
|
|
392
|
-
const screen = map.latLngToContainerPoint(this._latlng).subtract(new L.Point(dx, dy));
|
|
393
|
-
const delta = map.latLngToLayerPoint(this._latlng).subtract(map.containerPointToLayerPoint(screen));
|
|
394
|
-
map.fire('autopanstart');
|
|
395
|
-
map.panTo(map.unproject(map.project(map.getCenter()).add(delta)));
|
|
396
|
-
},
|
|
397
|
-
_updatePosition() {
|
|
398
|
-
popupPosition.call(this);
|
|
399
|
-
if (!this._map) return;
|
|
400
|
-
const point = this._map.latLngToLayerPoint(this._latlng), delta = displayPoint(this._map, point).subtract(point);
|
|
401
|
-
if (this._zoomAnimated) {
|
|
402
|
-
L.DomUtil.setPosition(this._container, L.DomUtil.getPosition(this._container).add(delta));
|
|
403
|
-
} else {
|
|
404
|
-
this._container.style.left = `${this._containerLeft + delta.x}px`;
|
|
405
|
-
this._container.style.bottom = `${this._containerBottom - delta.y}px`;
|
|
406
|
-
}
|
|
407
|
-
},
|
|
408
|
-
});
|
|
409
|
-
const tooltipPosition = L.Tooltip.prototype._setPosition;
|
|
410
|
-
L.Tooltip.include({
|
|
411
|
-
_setPosition(point) {
|
|
412
|
-
tooltipPosition.call(this, point);
|
|
413
|
-
const delta = displayPoint(this._map, point).subtract(point);
|
|
414
|
-
L.DomUtil.setPosition(this._container, L.DomUtil.getPosition(this._container).add(delta));
|
|
415
|
-
},
|
|
416
|
-
});
|
|
417
|
-
|
|
418
|
-
const tiledBounds = L.GridLayer.prototype._getTiledPixelBounds;
|
|
419
|
-
const gridEvents = L.GridLayer.prototype.getEvents;
|
|
420
|
-
L.GridLayer.include({
|
|
421
|
-
getEvents() {
|
|
422
|
-
const events = gridEvents.call(this);
|
|
423
|
-
this._cameraGridUpdate ||= L.Util.throttle(this._onMoveEnd, this.options.updateInterval, this);
|
|
424
|
-
return { ...events, rotate: this._cameraGridUpdate, pitch: this._cameraGridUpdate };
|
|
425
|
-
},
|
|
426
|
-
_getTiledPixelBounds(center) {
|
|
427
|
-
if (!this._map.getBearing() && !this._map.getPitch()) return tiledBounds.call(this, center);
|
|
428
|
-
const bounds = this._map.getBounds();
|
|
429
|
-
return new L.Bounds(this._map.project(bounds.getNorthWest(), this._tileZoom),
|
|
430
|
-
this._map.project(bounds.getSouthEast(), this._tileZoom));
|
|
431
|
-
},
|
|
432
|
-
});
|
|
@@ -1,243 +0,0 @@
|
|
|
1
|
-
/** Material WGSL and texture bindings, without a GPU device or Leaflet layer. */
|
|
2
|
-
export function materialShaders(material = {}, sparkle = false, elevationWGSL = '') {
|
|
3
|
-
const hasBase = Boolean(material.baseTexture);
|
|
4
|
-
const hasMetal = Boolean(material.metalTexture);
|
|
5
|
-
const hasEmissive = Boolean(material.emissiveTexture);
|
|
6
|
-
const hasOcclusion = Boolean(material.occlusionTexture);
|
|
7
|
-
const hasRoof = Boolean(material.roofTexture);
|
|
8
|
-
const hasTerrain = Boolean(material.terrain);
|
|
9
|
-
const textured = hasBase || hasMetal || hasEmissive || hasOcclusion || material.nightLight;
|
|
10
|
-
const vertex = `
|
|
11
|
-
struct Mesh {
|
|
12
|
-
worldMatrix: mat4x4<f32>,
|
|
13
|
-
baseColor: vec4<f32>,
|
|
14
|
-
material: vec4<f32>,
|
|
15
|
-
emissive: vec4<f32>,
|
|
16
|
-
terrain: vec4<f32>,
|
|
17
|
-
highlight: vec4<f32>,
|
|
18
|
-
};
|
|
19
|
-
struct Frame {
|
|
20
|
-
viewMatrix: mat4x4<f32>,
|
|
21
|
-
projectionMatrix: mat4x4<f32>,
|
|
22
|
-
roofMatrix: mat4x4<f32>,
|
|
23
|
-
lightDirection: vec4<f32>,
|
|
24
|
-
skyDirection: vec4<f32>,
|
|
25
|
-
atmosphereTint: vec4<f32>,
|
|
26
|
-
};
|
|
27
|
-
@group(0) @binding(0) var<uniform> u: Mesh;
|
|
28
|
-
@group(0) @binding(1) var<uniform> frame: Frame;
|
|
29
|
-
struct Solar { matrix: mat4x4<f32>, params: vec4<f32> };
|
|
30
|
-
@group(1) @binding(0) var<uniform> solar: Solar;
|
|
31
|
-
${hasTerrain ? `@group(0) @binding(2) var dem: texture_2d<f32>;${elevationWGSL}` : ''}
|
|
32
|
-
struct VertexInput {
|
|
33
|
-
@location(0) position: vec3<f32>,
|
|
34
|
-
@location(1) normal: vec3<f32>,
|
|
35
|
-
${material.vertexColors ? '@location(2) color: vec3<f32>,' : ''}
|
|
36
|
-
${textured ? '@location(3) uv: vec2<f32>,' : ''}
|
|
37
|
-
};
|
|
38
|
-
struct VertexOutput {
|
|
39
|
-
@builtin(position) position: vec4<f32>,
|
|
40
|
-
@location(0) color: vec3<f32>,
|
|
41
|
-
@location(1) normal: vec3<f32>,
|
|
42
|
-
@location(2) viewPosition: vec3<f32>,
|
|
43
|
-
@location(6) shadowPosition: vec4<f32>,
|
|
44
|
-
@location(7) worldPosition: vec3<f32>,
|
|
45
|
-
${sparkle ? '@location(8) localPosition: vec3<f32>,' : ''}
|
|
46
|
-
${textured ? '@location(3) uv: vec2<f32>,' : ''}
|
|
47
|
-
${hasRoof ? '@location(4) roofUv: vec2<f32>, @location(5) roof: f32,' : ''}
|
|
48
|
-
};
|
|
49
|
-
@vertex fn vertexMain(input: VertexInput, @builtin(vertex_index) vertexIndex: u32) -> VertexOutput {
|
|
50
|
-
var output: VertexOutput;
|
|
51
|
-
var position = input.position;
|
|
52
|
-
${hasTerrain ? 'position.y = elevation(u.terrain.xy + input.uv * u.terrain.z, u.terrain.w) - u.terrain.w;' : ''}
|
|
53
|
-
let highlighted = f32(vertexIndex) >= u.highlight.x && f32(vertexIndex) < u.highlight.y;
|
|
54
|
-
output.color = ${material.vertexColors
|
|
55
|
-
? 'select(input.color, vec3<f32>(72.0 / 255.0, 217.0 / 255.0, 1.0), highlighted)'
|
|
56
|
-
: 'u.baseColor.rgb'};
|
|
57
|
-
// Inverse-transpose from cofactors; the camera view matrix is orthonormal.
|
|
58
|
-
let m = mat3x3<f32>(u.worldMatrix[0].xyz, u.worldMatrix[1].xyz, u.worldMatrix[2].xyz);
|
|
59
|
-
let normal = (cross(m[1], m[2]) * input.normal.x + cross(m[2], m[0]) * input.normal.y +
|
|
60
|
-
cross(m[0], m[1]) * input.normal.z) / determinant(m);
|
|
61
|
-
output.normal = (frame.viewMatrix * vec4<f32>(normal, 0.0)).xyz;
|
|
62
|
-
let world = u.worldMatrix * vec4<f32>(position, 1.0);
|
|
63
|
-
output.shadowPosition = solar.matrix * world;
|
|
64
|
-
output.worldPosition = world.xyz / world.w;
|
|
65
|
-
${sparkle ? 'output.localPosition = input.position;' : ''}
|
|
66
|
-
let viewPosition = frame.viewMatrix * world;
|
|
67
|
-
output.viewPosition = viewPosition.xyz;
|
|
68
|
-
${textured ? 'output.uv = input.uv;' : ''}
|
|
69
|
-
${hasRoof ? `
|
|
70
|
-
output.roofUv = (frame.roofMatrix * world).xz;
|
|
71
|
-
output.roof = select(0.0, 1.0, input.normal.y >= 0.5 && !highlighted);
|
|
72
|
-
` : ''}
|
|
73
|
-
output.position = frame.projectionMatrix * viewPosition;
|
|
74
|
-
return output;
|
|
75
|
-
}
|
|
76
|
-
`;
|
|
77
|
-
const bindings = [];
|
|
78
|
-
let binding = 3;
|
|
79
|
-
const textureBinding = (name, enabled) => {
|
|
80
|
-
if (!enabled) return '';
|
|
81
|
-
bindings.push({ name, texture: binding, sampler: binding + 1 });
|
|
82
|
-
const current = binding;
|
|
83
|
-
binding += 2;
|
|
84
|
-
return `@group(0) @binding(${current}) var ${name}: texture_2d<f32>;
|
|
85
|
-
@group(0) @binding(${current + 1}) var ${name}Sampler: sampler;`;
|
|
86
|
-
};
|
|
87
|
-
const baseBinding = textureBinding('baseTexture', hasBase);
|
|
88
|
-
const metalBinding = textureBinding('metalTexture', hasMetal);
|
|
89
|
-
const emissiveBinding = textureBinding('emissiveTexture', hasEmissive);
|
|
90
|
-
const occlusionBinding = textureBinding('occlusionTexture', hasOcclusion);
|
|
91
|
-
const roofBinding = textureBinding('roofTexture', hasRoof);
|
|
92
|
-
const fragment = `
|
|
93
|
-
struct Mesh {
|
|
94
|
-
worldMatrix: mat4x4<f32>,
|
|
95
|
-
baseColor: vec4<f32>,
|
|
96
|
-
material: vec4<f32>,
|
|
97
|
-
emissive: vec4<f32>,
|
|
98
|
-
terrain: vec4<f32>,
|
|
99
|
-
highlight: vec4<f32>,
|
|
100
|
-
};
|
|
101
|
-
struct Frame {
|
|
102
|
-
viewMatrix: mat4x4<f32>,
|
|
103
|
-
projectionMatrix: mat4x4<f32>,
|
|
104
|
-
roofMatrix: mat4x4<f32>,
|
|
105
|
-
lightDirection: vec4<f32>,
|
|
106
|
-
skyDirection: vec4<f32>,
|
|
107
|
-
atmosphereTint: vec4<f32>,
|
|
108
|
-
};
|
|
109
|
-
struct Solar {
|
|
110
|
-
matrix: mat4x4<f32>,
|
|
111
|
-
params: vec4<f32>,
|
|
112
|
-
};
|
|
113
|
-
@group(0) @binding(0) var<uniform> u: Mesh;
|
|
114
|
-
@group(0) @binding(1) var<uniform> frame: Frame;
|
|
115
|
-
@group(1) @binding(0) var<uniform> solar: Solar;
|
|
116
|
-
@group(1) @binding(1) var shadowTexture: texture_depth_2d;
|
|
117
|
-
@group(1) @binding(2) var shadowSampler: sampler_comparison;
|
|
118
|
-
@group(1) @binding(3) var<storage, read> lightGrid: array<vec4<f32>>;
|
|
119
|
-
${baseBinding}${metalBinding}${emissiveBinding}${occlusionBinding}${roofBinding}
|
|
120
|
-
struct FragmentInput {
|
|
121
|
-
@builtin(position) position: vec4<f32>,
|
|
122
|
-
@location(0) color: vec3<f32>,
|
|
123
|
-
@location(1) normal: vec3<f32>,
|
|
124
|
-
@location(2) viewPosition: vec3<f32>,
|
|
125
|
-
@location(6) shadowPosition: vec4<f32>,
|
|
126
|
-
@location(7) worldPosition: vec3<f32>,
|
|
127
|
-
${sparkle ? '@location(8) localPosition: vec3<f32>,' : ''}
|
|
128
|
-
${textured ? '@location(3) uv: vec2<f32>,' : ''}
|
|
129
|
-
${hasRoof ? '@location(4) roofUv: vec2<f32>, @location(5) roof: f32,' : ''}
|
|
130
|
-
};
|
|
131
|
-
const PI: f32 = 3.14159265;
|
|
132
|
-
fn toLinear(c: vec3<f32>) -> vec3<f32> {
|
|
133
|
-
return select(c / 12.92, pow((c + vec3<f32>(0.055)) / 1.055, vec3<f32>(2.4)), c >= vec3<f32>(0.04045));
|
|
134
|
-
}
|
|
135
|
-
fn toSRGB(c: vec3<f32>) -> vec3<f32> {
|
|
136
|
-
return select(c * 12.92, 1.055 * pow(max(c, vec3<f32>(0.0)), vec3<f32>(1.0 / 2.4)) - vec3<f32>(0.055), c >= vec3<f32>(0.0031308));
|
|
137
|
-
}
|
|
138
|
-
fn sunVisibility(position: vec4<f32>) -> f32 {
|
|
139
|
-
let p = position.xyz / position.w;
|
|
140
|
-
let uv = vec2<f32>(p.x * 0.5 + 0.5, 0.5 - p.y * 0.5);
|
|
141
|
-
if (solar.params.x < 0.5 || any(uv < vec2<f32>(0.0)) || any(uv > vec2<f32>(1.0)) || p.z < 0.0 || p.z > 1.0) {
|
|
142
|
-
return 1.0;
|
|
143
|
-
}
|
|
144
|
-
return textureSampleCompareLevel(shadowTexture, shadowSampler, uv, p.z - 0.0003);
|
|
145
|
-
}
|
|
146
|
-
fn localLighting(position: vec3<f32>, normal: vec3<f32>) -> vec3<f32> {
|
|
147
|
-
if (frame.skyDirection.w <= 0.0 || lightGrid[0].w < 1.0) { return vec3<f32>(0.0); }
|
|
148
|
-
let cell = vec2<i32>(floor((position.xz - lightGrid[0].xy) / lightGrid[0].z));
|
|
149
|
-
if (any(cell < vec2<i32>(0)) || cell.x >= i32(lightGrid[0].w) || cell.y >= i32(lightGrid[1].x)) {
|
|
150
|
-
return vec3<f32>(0.0);
|
|
151
|
-
}
|
|
152
|
-
let header = lightGrid[2u + u32(cell.y) * u32(lightGrid[0].w) + u32(cell.x)];
|
|
153
|
-
var light = vec3<f32>(0.0);
|
|
154
|
-
for (var i = 0u; i < u32(header.y); i++) {
|
|
155
|
-
let source = lightGrid[u32(header.x) + i * 2u];
|
|
156
|
-
let colour = lightGrid[u32(header.x) + i * 2u + 1u];
|
|
157
|
-
let delta = source.xyz - position;
|
|
158
|
-
let distance2 = max(dot(delta, delta), 1.0);
|
|
159
|
-
let falloff = max(0.0, 1.0 - distance2 / (source.w * source.w));
|
|
160
|
-
let lambert = max(0.0, dot(normal, delta / sqrt(distance2)));
|
|
161
|
-
light += toLinear(colour.rgb) * colour.w * lambert * falloff * falloff / distance2;
|
|
162
|
-
}
|
|
163
|
-
return light * frame.skyDirection.w;
|
|
164
|
-
}
|
|
165
|
-
fn appearance(position: vec2<f32>) {
|
|
166
|
-
// Screen-door dissolve keeps opaque depth writes and avoids sorting whole buildings as glass.
|
|
167
|
-
let noise = fract(52.9829189 * fract(dot(floor(position), vec2<f32>(0.06711056, 0.00583715))));
|
|
168
|
-
if (u.highlight.w < 1.0 && noise >= u.highlight.w) { discard; }
|
|
169
|
-
}
|
|
170
|
-
@fragment fn fragmentMain(input: FragmentInput, @builtin(front_facing) frontFacing: bool) -> @location(0) vec4<f32> {
|
|
171
|
-
${material.nightLight ? `
|
|
172
|
-
if (input.uv.x <= 2.0) {
|
|
173
|
-
let radial = max(0.0, 1.0 - dot(input.uv, input.uv));
|
|
174
|
-
let alpha = radial * radial * frame.skyDirection.w * 0.65;
|
|
175
|
-
if (alpha < 0.005) { discard; }
|
|
176
|
-
appearance(input.position.xy);
|
|
177
|
-
return vec4<f32>(input.color, alpha);
|
|
178
|
-
}
|
|
179
|
-
` : ''}
|
|
180
|
-
let sunlight = sunVisibility(input.shadowPosition);
|
|
181
|
-
let worldNormal = normalize(transpose(mat3x3<f32>(frame.viewMatrix[0].xyz, frame.viewMatrix[1].xyz, frame.viewMatrix[2].xyz)) * normalize(input.normal)) * select(-1.0, 1.0, frontFacing);
|
|
182
|
-
let artificial = localLighting(input.worldPosition, worldNormal);
|
|
183
|
-
${material.unlit ? `
|
|
184
|
-
let rasterTexel = ${hasBase ? 'textureSample(baseTexture, baseTextureSampler, input.uv)' : 'vec4<f32>(input.color, 1.0)'};
|
|
185
|
-
return vec4<f32>(toSRGB(toLinear(rasterTexel.rgb) * (frame.atmosphereTint.rgb * (0.55 + 0.45 * sunlight) + artificial)), ${material.alphaMode === 'BLEND' ? 'u.material.z * rasterTexel.a' : '1.0'});
|
|
186
|
-
` : `
|
|
187
|
-
var normal = normalize(input.normal) * select(-1.0, 1.0, frontFacing);
|
|
188
|
-
let texel = ${hasBase ? 'textureSample(baseTexture, baseTextureSampler, input.uv)' : 'vec4<f32>(1.0)'};
|
|
189
|
-
let alpha = u.material.z * texel.a;
|
|
190
|
-
${material.alphaMode === 'MASK' ? 'if (alpha < u.material.w) { discard; }' : ''}
|
|
191
|
-
${material.alphaMode === 'BLEND' ? 'if (alpha < 0.01) { discard; }' : ''}
|
|
192
|
-
var base = ${material.vertexColors ? 'toLinear(min(input.color, vec3<f32>(1.0)))' : 'input.color'} *
|
|
193
|
-
${material.baseTexture?.srgb ? 'texel.rgb' : 'toLinear(texel.rgb)'};
|
|
194
|
-
${hasRoof ? `
|
|
195
|
-
if (input.roof > 0.5 && all(input.roofUv >= vec2<f32>(0.0)) &&
|
|
196
|
-
all(input.roofUv <= vec2<f32>(1.0))) {
|
|
197
|
-
let roof = textureSampleLevel(roofTexture, roofTextureSampler, input.roofUv, 0.0);
|
|
198
|
-
base = mix(base, toLinear(roof.rgb), roof.a);
|
|
199
|
-
}
|
|
200
|
-
` : ''}
|
|
201
|
-
let mr = ${hasMetal ? 'textureSample(metalTexture, metalTextureSampler, input.uv)' : 'vec4<f32>(1.0)'};
|
|
202
|
-
let metal = clamp(u.material.x * mr.b, 0.0, 1.0);
|
|
203
|
-
let rough = clamp(u.material.y * mr.g, 0.08, 1.0);
|
|
204
|
-
let view = normalize(-input.viewPosition);
|
|
205
|
-
let halfVector = normalize(view + frame.lightDirection.xyz);
|
|
206
|
-
let nl = max(dot(normal, frame.lightDirection.xyz), 0.0) * frame.lightDirection.w * sunlight;
|
|
207
|
-
let nv = max(dot(normal, view), 0.001);
|
|
208
|
-
let nh = max(dot(normal, halfVector), 0.0);
|
|
209
|
-
let vh = max(dot(view, halfVector), 0.0);
|
|
210
|
-
let a2 = pow(rough, 4.0);
|
|
211
|
-
let d = a2 / max(PI * pow(nh * nh * (a2 - 1.0) + 1.0, 2.0), 0.0001);
|
|
212
|
-
let gv = nl * sqrt(nv * nv * (1.0 - a2) + a2);
|
|
213
|
-
let gl = nv * sqrt(nl * nl * (1.0 - a2) + a2);
|
|
214
|
-
let visibility = 0.5 / max(gv + gl, 0.0001);
|
|
215
|
-
let f0 = mix(vec3<f32>(0.04), base, metal);
|
|
216
|
-
let fresnel = f0 + (1.0 - f0) * pow(1.0 - vh, 5.0);
|
|
217
|
-
let specular = d * visibility * fresnel;
|
|
218
|
-
let diffuse = (1.0 - metal) * base / PI;
|
|
219
|
-
let sky = dot(normal, frame.skyDirection.xyz) * 0.5 + 0.5;
|
|
220
|
-
let ambient = mix(toLinear(vec3<f32>(0.455, 0.412, 0.322)), vec3<f32>(1.0), sky) * (2.0 / PI);
|
|
221
|
-
let ao = ${hasOcclusion ? 'mix(1.0, textureSample(occlusionTexture, occlusionTextureSampler, input.uv).r, u.emissive.w)' : '1.0'};
|
|
222
|
-
${sparkle ? `
|
|
223
|
-
let lattice = (fract(input.localPosition / 2.5) - 0.5) * 2.5;
|
|
224
|
-
let pointGlow = (1.0 - smoothstep(0.16, 0.42, length(lattice))) * u.highlight.z;
|
|
225
|
-
` : ''}
|
|
226
|
-
// Vertex colour components above 1 are self-lit (e.g. vehicle lamps): dim by day, bright at night.
|
|
227
|
-
let glow = ${sparkle ? 'vec3<f32>(3.0, 2.6, 1.8) * pointGlow +' : ''}${material.vertexColors
|
|
228
|
-
? ' max(input.color - vec3<f32>(1.0), vec3<f32>(0.0)) * (0.3 + 5.0 * frame.skyDirection.w) +' : ''} u.emissive.rgb * ${hasEmissive
|
|
229
|
-
? material.emissiveTexture.srgb
|
|
230
|
-
? 'textureSample(emissiveTexture, emissiveTextureSampler, input.uv).rgb'
|
|
231
|
-
: 'toLinear(textureSample(emissiveTexture, emissiveTextureSampler, input.uv).rgb)'
|
|
232
|
-
: 'vec3<f32>(1.0)'};
|
|
233
|
-
var color = ambient * base * (1.0 - metal) * ao +
|
|
234
|
-
(diffuse + specular) * nl * toLinear(vec3<f32>(1.0, 0.937, 0.835)) * 3.0 + glow;
|
|
235
|
-
${material.vertexColors ? 'color = base * (ambient + toLinear(vec3<f32>(1.0, 0.937, 0.835)) * (3.0 / PI) * nl) + glow;' : ''}
|
|
236
|
-
color = (color - glow) * frame.atmosphereTint.rgb + base * artificial * (1.0 - metal * 0.5) + glow;
|
|
237
|
-
appearance(input.position.xy);
|
|
238
|
-
return vec4<f32>(toSRGB(color), ${material.alphaMode === 'BLEND' ? 'alpha' : '1.0'});
|
|
239
|
-
`}
|
|
240
|
-
}
|
|
241
|
-
`;
|
|
242
|
-
return { vertex, fragment, bindings, textured, hasTerrain };
|
|
243
|
-
}
|