leaflet-city-mapper 0.0.1 → 0.0.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +61 -13
- package/cucumber.mjs +4 -0
- package/dist/leaflet-city-mapper.js +3 -1
- package/dist/leaflet-city-mapper.js.map +4 -4
- package/package.json +3 -4
- package/src/archives/decodeDirectory.js +32 -0
- package/src/archives/decodeHeader.js +19 -0
- package/src/archives/decompress.js +5 -0
- package/src/archives/getHeader.js +9 -0
- package/src/archives/getZxy.js +75 -0
- package/src/archives/loadDirectory.js +7 -0
- package/src/archives/loadSource.js +17 -0
- package/src/archives/read.js +29 -0
- package/src/archives/tileId.js +19 -0
- package/src/archives/varint.js +15 -0
- package/src/camera/angles.js +6 -0
- package/src/camera/animationPoint.js +8 -0
- package/src/camera/cameraMapReady.js +8 -0
- package/src/camera/cancelCameraAnimation.js +11 -0
- package/src/camera/cleanupCameraMap.js +11 -0
- package/src/camera/constrainCameraToBounds.js +3 -0
- package/src/camera/displayPoint.js +3 -0
- package/src/camera/fitCameraBounds.js +48 -0
- package/src/camera/groundBounds.js +11 -0
- package/src/camera/initializeCameraMap.js +25 -0
- package/src/camera/mapAnimateCamera.js +17 -0
- package/src/camera/mapCamera.js +123 -0
- package/src/camera/mapContainerPointToLayerPoint.js +7 -0
- package/src/camera/mapGetBearing.js +1 -0
- package/src/camera/mapGetBounds.js +14 -0
- package/src/camera/mapGetBoundsCenterZoom.js +7 -0
- package/src/camera/mapGetBoundsZoom.js +14 -0
- package/src/camera/mapGetCenterLayerPoint.js +5 -0
- package/src/camera/mapGetPitch.js +1 -0
- package/src/camera/mapLayerPointToContainerPoint.js +7 -0
- package/src/camera/mapLimitCenter.js +12 -0
- package/src/camera/mapLimitOffset.js +10 -0
- package/src/camera/mapPanBy.js +9 -0
- package/src/camera/mapPanInside.js +14 -0
- package/src/camera/mapResetNorth.js +1 -0
- package/src/camera/mapResetNorthPitch.js +1 -0
- package/src/camera/mapSetBearing.js +1 -0
- package/src/camera/mapSetPitch.js +1 -0
- package/src/camera/mapSetPitchAndBearing.js +14 -0
- package/src/camera/mapSetZoomAround.js +11 -0
- package/src/camera/mapStopPitchBearingAnimation.js +6 -0
- package/src/camera/mapTryAnimatedPan.js +9 -0
- package/src/camera/mapUpdateCameraOverlays.js +7 -0
- package/src/camera/pointOf.js +3 -0
- package/src/camera/project.js +20 -0
- package/src/camera/runCameraAnimations.js +28 -0
- package/src/camera/scheduleCameraAnimation.js +8 -0
- package/src/camera/updateSky.js +16 -0
- package/src/camera/verticalGroundY.js +4 -0
- package/src/collision/collectMeshes.js +5 -0
- package/src/collision/collider.js +63 -0
- package/src/collision/horizontalRay.js +12 -0
- package/src/collision/intersectMeshes.js +133 -0
- package/src/collision/sortHits.js +23 -0
- package/src/constants/CELL.js +4 -0
- package/src/constants/Compass.js +7 -0
- package/src/constants/ContainerResize.js +7 -0
- package/src/constants/HEIGHT.js +1 -0
- package/src/constants/PitchDrag.js +7 -0
- package/src/constants/ShiftRotate.js +7 -0
- package/src/constants/TILE_RADIUS.js +1 -0
- package/src/constants/TILE_SIZE.js +1 -0
- package/src/constants/TouchMode.js +6 -0
- package/src/constants/accessorSizes.js +1 -0
- package/src/constants/accessorTypes.js +8 -0
- package/src/constants/attachState.js +1 -0
- package/src/constants/cameraControlsState.js +1 -0
- package/src/constants/cityMapper.js +6 -0
- package/src/constants/colliders.js +2 -0
- package/src/constants/dark.js +1 -0
- package/src/constants/elevationWGSL.js +27 -0
- package/src/constants/glass.js +1 -0
- package/src/constants/headlight.js +1 -0
- package/src/constants/hull.js +1 -0
- package/src/constants/indexState.js +1 -0
- package/src/constants/limbs.js +9 -0
- package/src/constants/mapCameraState.js +1 -0
- package/src/constants/moves.js +11 -0
- package/src/constants/nativeEventMaps.js +1 -0
- package/src/constants/nativeLayerState.js +1 -0
- package/src/constants/nativeMethodHandlers.js +31 -0
- package/src/constants/onMapChangeState.js +1 -0
- package/src/constants/onZoomAnimState.js +1 -0
- package/src/constants/paints.js +10 -0
- package/src/constants/parts.js +19 -0
- package/src/constants/pendingUpdates.js +1 -0
- package/src/constants/pumpState.js +1 -0
- package/src/constants/renderers.js +2 -0
- package/src/constants/ringDirections.js +10 -0
- package/src/constants/roundProfile.js +1 -0
- package/src/constants/shirt.js +1 -0
- package/src/constants/skin.js +2 -0
- package/src/constants/speed.js +3 -0
- package/src/constants/taillight.js +1 -0
- package/src/constants/trafficShader.js +49 -0
- package/src/constants/trousers.js +1 -0
- package/src/constants/tyre.js +1 -0
- package/src/constants/underEntryState.js +1 -0
- package/src/constants/vehicles.js +40 -0
- package/src/constants/white.js +1 -0
- package/src/controls/acceptPitchDrag.js +4 -0
- package/src/controls/acceptRotateDrag.js +3 -0
- package/src/controls/adjustCameraDrag.js +10 -0
- package/src/controls/cameraControls.js +60 -0
- package/src/controls/cameraDragClick.js +9 -0
- package/src/controls/cameraDragContextMenu.js +8 -0
- package/src/controls/cameraDragDown.js +20 -0
- package/src/controls/cameraDragEnd.js +6 -0
- package/src/controls/cameraDragMove.js +23 -0
- package/src/controls/changeCameraTouch.js +14 -0
- package/src/controls/cleanupCameraTouch.js +24 -0
- package/src/controls/compassAddHooks.js +15 -0
- package/src/controls/compassOrientation.js +6 -0
- package/src/controls/compassRemoveHooks.js +5 -0
- package/src/controls/containerResizeAddHooks.js +8 -0
- package/src/controls/containerResizeRemoveHooks.js +5 -0
- package/src/controls/dragCamera.js +22 -0
- package/src/controls/editable.js +3 -0
- package/src/controls/endAllCameraDrags.js +7 -0
- package/src/controls/endAllCameraTouches.js +7 -0
- package/src/controls/endCameraTouch.js +11 -0
- package/src/controls/endCameraTouchEvent.js +5 -0
- package/src/controls/finishCameraDrag.js +9 -0
- package/src/controls/finishCompassPermission.js +16 -0
- package/src/controls/loadCameraControls.js +9 -0
- package/src/controls/moveCameraTouch.js +22 -0
- package/src/controls/notifyCameraTouchChange.js +1 -0
- package/src/controls/pitchDragAddHooks.js +6 -0
- package/src/controls/pitchDragRemoveHooks.js +5 -0
- package/src/controls/refreshRotateControl.js +7 -0
- package/src/controls/refreshRotateFocus.js +5 -0
- package/src/controls/removeCameraDrag.js +23 -0
- package/src/controls/resizeMap.js +3 -0
- package/src/controls/rotateButtonClick.js +7 -0
- package/src/controls/rotateButtonKeydown.js +11 -0
- package/src/controls/rotateControl.js +3 -0
- package/src/controls/rotateOnAdd.js +38 -0
- package/src/controls/rotateOnRemove.js +6 -0
- package/src/controls/shiftRotateAddHooks.js +8 -0
- package/src/controls/shiftRotateRemoveHooks.js +5 -0
- package/src/controls/shiftRotateWheel.js +9 -0
- package/src/controls/startCameraTouch.js +23 -0
- package/src/core/addImageState.js +7 -0
- package/src/core/addRasterImage.js +10 -0
- package/src/core/adjustCameraMarkerPan.js +22 -0
- package/src/core/beforeNativeRender.js +10 -0
- package/src/core/boundsQuad.js +11 -0
- package/src/core/bringNativeLayerToBack.js +3 -0
- package/src/core/bringNativeLayerToFront.js +3 -0
- package/src/core/cameraCircleBounds.js +6 -0
- package/src/core/cameraMarkerDrag.js +18 -0
- package/src/core/cameraMarkerOnDrag.js +8 -0
- package/src/core/cancelGridFade.js +10 -0
- package/src/core/closestCameraLayerPoint.js +7 -0
- package/src/core/compareNativeHits.js +3 -0
- package/src/core/current.js +3 -0
- package/src/core/disposeNativeLayer.js +35 -0
- package/src/core/fireRasterLoad.js +5 -0
- package/src/core/forwardNativeError.js +3 -0
- package/src/core/gridlayerGetEvents.js +7 -0
- package/src/core/gridlayerGetTiledPixelBounds.js +8 -0
- package/src/core/handleNativeMapEvent.js +47 -0
- package/src/core/hideTargets.js +16 -0
- package/src/core/initNativeGPU.js +21 -0
- package/src/core/initializeGridContainer.js +6 -0
- package/src/core/initializeNativeLayer.js +42 -0
- package/src/core/localPixel.js +5 -0
- package/src/core/localPixelForGeometry.js +6 -0
- package/src/core/localPosition.js +6 -0
- package/src/core/markerCameraIconPoint.js +9 -0
- package/src/core/markerGetEvents.js +5 -0
- package/src/core/markerInitInteraction.js +8 -0
- package/src/core/markerQuadCorners.js +31 -0
- package/src/core/markerSetIcon.js +9 -0
- package/src/core/markerSetPos.js +14 -0
- package/src/core/markerSetRotation.js +7 -0
- package/src/core/markerUpdateZIndex.js +8 -0
- package/src/core/nativeAddLatLng.js +3 -0
- package/src/core/nativeBringToBack.js +3 -0
- package/src/core/nativeBringToFront.js +3 -0
- package/src/core/nativeEvents.js +26 -0
- package/src/core/nativeImageError.js +8 -0
- package/src/core/nativeImageRefresh.js +7 -0
- package/src/core/nativeLayer.js +97 -0
- package/src/core/nativeLayerMethod.js +21 -0
- package/src/core/nativeRedraw.js +3 -0
- package/src/core/nativeSetBounds.js +3 -0
- package/src/core/nativeSetIcon.js +3 -0
- package/src/core/nativeSetLatLng.js +3 -0
- package/src/core/nativeSetLatLngs.js +3 -0
- package/src/core/nativeSetOpacity.js +3 -0
- package/src/core/nativeSetRadius.js +3 -0
- package/src/core/nativeSetStyle.js +3 -0
- package/src/core/nativeSetUrl.js +3 -0
- package/src/core/nativeSetZIndex.js +3 -0
- package/src/core/nativeSetZIndexOffset.js +3 -0
- package/src/core/popupAdjustPan.js +23 -0
- package/src/core/popupGetEvents.js +5 -0
- package/src/core/popupUpdatePosition.js +14 -0
- package/src/core/putNativeMesh.js +33 -0
- package/src/core/quadNativeMesh.js +15 -0
- package/src/core/readyNativeGPU.js +6 -0
- package/src/core/refreshNativeEvent.js +5 -0
- package/src/core/refreshNativeLayer.js +29 -0
- package/src/core/refreshNativeLayerContract.js +3 -0
- package/src/core/rejectNativeReady.js +3 -0
- package/src/core/removeImageState.js +8 -0
- package/src/core/removeNativeEvents.js +16 -0
- package/src/core/removeTargets.js +8 -0
- package/src/core/reorderNativeLayer.js +6 -0
- package/src/core/resolveNativeReady.js +3 -0
- package/src/core/restoreNativeEvents.js +6 -0
- package/src/core/runGridFades.js +14 -0
- package/src/core/runMarkerPanFrame.js +12 -0
- package/src/core/scheduleGridFade.js +9 -0
- package/src/core/scheduleMarkerPan.js +8 -0
- package/src/core/styleNativeMesh.js +10 -0
- package/src/core/syncGridLayer.js +22 -0
- package/src/core/syncImageOverlay.js +9 -0
- package/src/core/syncMarker.js +12 -0
- package/src/core/syncVectorLayer.js +26 -0
- package/src/core/synchronizeNativeLayer.js +35 -0
- package/src/core/textureFor.js +48 -0
- package/src/core/tooltipGetEvents.js +5 -0
- package/src/core/tooltipSetPosition.js +8 -0
- package/src/core/updateGridOpacity.js +23 -0
- package/src/core/updateNativeLayerView.js +6 -0
- package/src/core/uploadCanvasTexture.js +19 -0
- package/src/geometry/addBridges.js +88 -0
- package/src/geometry/below.js +3 -0
- package/src/geometry/box.js +3 -0
- package/src/geometry/bridgeElevation.js +19 -0
- package/src/geometry/bridgeLocal.js +4 -0
- package/src/geometry/build.js +19 -0
- package/src/geometry/circleAt.js +5 -0
- package/src/geometry/clipLine.js +23 -0
- package/src/geometry/clipSegment.js +19 -0
- package/src/geometry/computeBounds.js +33 -0
- package/src/geometry/conformModelToTerrain.js +67 -0
- package/src/geometry/cross.js +3 -0
- package/src/geometry/disk.js +11 -0
- package/src/geometry/diskAt.js +4 -0
- package/src/geometry/dot.js +6 -0
- package/src/geometry/emitter.js +8 -0
- package/src/geometry/lampPostGeometry.js +24 -0
- package/src/geometry/lampRing.js +11 -0
- package/src/geometry/lightGeometry.js +15 -0
- package/src/geometry/line.js +54 -0
- package/src/geometry/nativeGeometry.js +55 -0
- package/src/geometry/nativeTriangle.js +3 -0
- package/src/geometry/polygon.js +22 -0
- package/src/geometry/push.js +3 -0
- package/src/geometry/quad.js +4 -0
- package/src/geometry/roofCoverage.js +52 -0
- package/src/geometry/samePoint.js +3 -0
- package/src/geometry/segment.js +21 -0
- package/src/geometry/setVertexColor.js +15 -0
- package/src/geometry/sub.js +6 -0
- package/src/geometry/surface.js +17 -0
- package/src/geometry/treeGeometry.js +31 -0
- package/src/geometry/treeRing.js +14 -0
- package/src/geometry/triangle.js +12 -0
- package/src/geometry/vertexNormals.js +32 -0
- package/src/geometry/visit.js +9 -0
- package/src/index.js +98 -65
- package/src/lighting/cacheLightGrid.js +23 -0
- package/src/lighting/collectLightMeshes.js +6 -0
- package/src/lighting/lightGrid.js +42 -0
- package/src/lighting/updatePointLights.js +34 -0
- package/src/lighting/visitCells.js +15 -0
- package/src/lighting/worldLights.js +27 -0
- package/src/models/decodeModel.js +45 -0
- package/src/models/hasUnsupportedPrimitives.js +10 -0
- package/src/models/loadBuffer.js +6 -0
- package/src/models/loadImage.js +15 -0
- package/src/models/loadModel.js +69 -0
- package/src/models/materialFor.js +21 -0
- package/src/models/modelNode.js +93 -0
- package/src/models/nodeMatrix.js +22 -0
- package/src/models/readAccessor.js +53 -0
- package/src/models/readAccessorValues.js +16 -0
- package/src/models/textureFor.js +35 -0
- package/src/models/textureSampler.js +10 -0
- package/src/picking/collectVisibleMesh.js +4 -0
- package/src/picking/findFeature.js +49 -0
- package/src/picking/hit.js +23 -0
- package/src/picking/hitMesh.js +30 -0
- package/src/picking/onClick.js +13 -0
- package/src/picking/onPointerLeave.js +11 -0
- package/src/picking/onPointerMove.js +15 -0
- package/src/picking/pointerClick.js +5 -0
- package/src/picking/pointerLeave.js +5 -0
- package/src/picking/pointerMove.js +5 -0
- package/src/picking/raycast.js +59 -0
- package/src/picking/setHighlight.js +13 -0
- package/src/picking/shouldSkipOther.js +3 -0
- package/src/picking/showFeature.js +34 -0
- package/src/raster/addRasterTile.js +114 -0
- package/src/raster/comparePendingTiles.js +5 -0
- package/src/raster/createGeometry.js +22 -0
- package/src/raster/createRasterMesh.js +47 -0
- package/src/raster/finishAttachment.js +11 -0
- package/src/raster/finishRasterTile.js +47 -0
- package/src/raster/getRasterEvents.js +6 -0
- package/src/raster/getRasterTileSize.js +5 -0
- package/src/raster/initRaster.js +38 -0
- package/src/raster/isLoading.js +5 -0
- package/src/raster/loadRasterTile.js +10 -0
- package/src/raster/onPMTileAdd.js +10 -0
- package/src/raster/onPMTileRemove.js +8 -0
- package/src/raster/pruneRasterTiles.js +37 -0
- package/src/raster/pumpRasterTiles.js +22 -0
- package/src/raster/readyRaster.js +13 -0
- package/src/raster/registerTerrainTile.js +12 -0
- package/src/raster/releaseRasterTile.js +18 -0
- package/src/raster/releaseRasterTiles.js +15 -0
- package/src/raster/removeRasterTile.js +13 -0
- package/src/raster/reportError.js +6 -0
- package/src/raster/setPMTileOpacity.js +7 -0
- package/src/raster/setPMTileZIndex.js +7 -0
- package/src/raster/setRasterOpacity.js +11 -0
- package/src/raster/setRasterTerrain.js +21 -0
- package/src/raster/setRasterZIndex.js +11 -0
- package/src/raster/updateAttachedTiles.js +10 -0
- package/src/raster/updateRasterTiles.js +59 -0
- package/src/rendering/collectFrameMeshes.js +31 -0
- package/src/rendering/collectMeshes.js +36 -0
- package/src/rendering/compareMeshes.js +10 -0
- package/src/rendering/compareRoofTiles.js +4 -0
- package/src/rendering/composeRoofAtlas.js +52 -0
- package/src/rendering/createMesh.js +33 -0
- package/src/rendering/createProgram.js +92 -0
- package/src/rendering/destroyAfterSubmission.js +8 -0
- package/src/rendering/destroyTexture.js +6 -0
- package/src/rendering/disposeMesh.js +14 -0
- package/src/rendering/drawGeometry.js +129 -0
- package/src/rendering/drawSceneMeshes.js +51 -0
- package/src/rendering/ensureRoofBlit.js +40 -0
- package/src/rendering/prepareFrameMeshes.js +42 -0
- package/src/rendering/prepareFrameUniforms.js +49 -0
- package/src/rendering/rebuildRoofAtlas.js +67 -0
- package/src/rendering/render.js +57 -0
- package/src/rendering/reportCompilation.js +17 -0
- package/src/rendering/resizeRenderer.js +19 -0
- package/src/rendering/sortMeshes.js +6 -0
- package/src/rendering/synchronizeZoomView.js +34 -0
- package/src/rendering/textureBinding.js +7 -0
- package/src/rendering/updateMapCamera.js +32 -0
- package/src/rendering/updateRoofRaster.js +32 -0
- package/src/scene/attach.js +161 -0
- package/src/scene/attachLayer.js +10 -0
- package/src/scene/cancelUpdate.js +10 -0
- package/src/scene/emptyEvents.js +3 -0
- package/src/scene/emptyNode.js +11 -0
- package/src/scene/endZoom.js +16 -0
- package/src/scene/failAttachment.js +9 -0
- package/src/scene/get3DEvents.js +13 -0
- package/src/scene/init3D.js +30 -0
- package/src/scene/initializeLayer.js +16 -0
- package/src/scene/initializerFor.js +14 -0
- package/src/scene/layerInitialize.js +38 -0
- package/src/scene/layerLayerAdd.js +21 -0
- package/src/scene/onAdd3DLayer.js +35 -0
- package/src/scene/onMapChange.js +16 -0
- package/src/scene/onRemove3DLayer.js +69 -0
- package/src/scene/onZoomAnim.js +16 -0
- package/src/scene/placeEntry.js +11 -0
- package/src/scene/placeUnderEntry.js +8 -0
- package/src/scene/ready3D.js +25 -0
- package/src/scene/releaseRenderer.js +14 -0
- package/src/scene/removeEntry.js +6 -0
- package/src/scene/renderPendingMapChange.js +11 -0
- package/src/scene/renderPendingUpdates.js +19 -0
- package/src/scene/renderPendingZoomAnimation.js +7 -0
- package/src/scene/rendererDeviceError.js +10 -0
- package/src/scene/rendererDeviceLost.js +11 -0
- package/src/scene/replaceEntry.js +7 -0
- package/src/scene/reportError.js +3 -0
- package/src/scene/requestAdapter.js +12 -0
- package/src/scene/requestDevice.js +9 -0
- package/src/scene/resolveNextInitialization.js +12 -0
- package/src/scene/restoreObject.js +71 -0
- package/src/scene/runPlacements.js +7 -0
- package/src/scene/setParent.js +7 -0
- package/src/scene/showWebGPUWarning.js +16 -0
- package/src/scene/startZoom.js +5 -0
- package/src/scene/traverse.js +7 -0
- package/src/scene/underEntry.js +17 -0
- package/src/scene/update.js +19 -0
- package/src/scene/updateCamera.js +34 -0
- package/src/scene/updateWorldMatrix.js +48 -0
- package/src/{utils/shaders.js → shaders/materialShaders.js} +246 -237
- package/src/shadows/bindSunlight.js +12 -0
- package/src/shadows/drawShadowMeshes.js +48 -0
- package/src/shadows/ensureShadowPipeline.js +53 -0
- package/src/shadows/renderSunlight.js +46 -0
- package/src/shadows/resizeSunlight.js +15 -0
- package/src/shadows/shadowBounds.js +32 -0
- package/src/shadows/shadowCacheMatches.js +23 -0
- package/src/shadows/shadowMatrix.js +39 -0
- package/src/sources/addGeneratedTriangle.js +6 -0
- package/src/sources/addTriangle.js +17 -0
- package/src/sources/attachAreaMesh.js +58 -0
- package/src/sources/buildArea.js +42 -0
- package/src/sources/buildAreaFeature.js +41 -0
- package/src/sources/buildAreaPoint.js +25 -0
- package/src/sources/buildAreaPolygon.js +29 -0
- package/src/sources/compareAreaDistance.js +4 -0
- package/src/sources/generateTreeGeometry.js +11 -0
- package/src/sources/groundOffset.js +3 -0
- package/src/sources/initializeGeoJSON.js +8 -0
- package/src/sources/instanceAreaGeometry.js +29 -0
- package/src/sources/projectRing.js +20 -0
- package/src/sources/projectedTree.js +13 -0
- package/src/sources/pump.js +54 -0
- package/src/sources/releaseArea.js +22 -0
- package/src/sources/setGeoJSONData.js +12 -0
- package/src/sources/setGeoJSONLayerData.js +5 -0
- package/src/sources/sourceAreaContext.js +9 -0
- package/src/sources/updateArea.js +45 -0
- package/src/sources/updateStatus.js +12 -0
- package/src/sunlight/addTimeLayer.js +3 -0
- package/src/sunlight/addTo.js +10 -0
- package/src/sunlight/atmosphere.js +28 -0
- package/src/sunlight/horizontalPosition.js +16 -0
- package/src/sunlight/initSunlight.js +14 -0
- package/src/sunlight/initialize.js +11 -0
- package/src/sunlight/mix.js +6 -0
- package/src/sunlight/moonPosition.js +17 -0
- package/src/sunlight/onAdd.js +5 -0
- package/src/sunlight/onAddSun.js +66 -0
- package/src/sunlight/projectCelestialBody.js +13 -0
- package/src/sunlight/remove.js +7 -0
- package/src/sunlight/removeSun.js +15 -0
- package/src/sunlight/removeTimeLayer.js +3 -0
- package/src/sunlight/render.js +7 -0
- package/src/sunlight/rgb.js +6 -0
- package/src/sunlight/solarPosition.js +17 -0
- package/src/sunlight/styleTimeControl.js +7 -0
- package/src/sunlight/tickSun.js +5 -0
- package/src/sunlight/updateSky.js +20 -0
- package/src/sunlight/updateSun.js +34 -0
- package/src/sunlight/useLiveTime.js +6 -0
- package/src/sunlight/useSelectedTime.js +20 -0
- package/src/terrain/clearLayerTerrain.js +5 -0
- package/src/terrain/getElevation.js +10 -0
- package/src/terrain/initTerrain.js +20 -0
- package/src/terrain/loadReadyTerrain.js +5 -0
- package/src/terrain/loadTerrain.js +63 -0
- package/src/terrain/loadTerrainTiles.js +13 -0
- package/src/terrain/onTerrainAdd.js +21 -0
- package/src/terrain/onTerrainChange.js +14 -0
- package/src/terrain/onTerrainRemove.js +41 -0
- package/src/terrain/readBridges.js +4 -0
- package/src/terrain/sample.js +7 -0
- package/src/terrain/setLayerTerrain.js +5 -0
- package/src/terrain/setTerrainHeight.js +10 -0
- package/src/terrain/terrainAtlas.js +23 -0
- package/src/terrain/terrainElevation.js +20 -0
- package/src/terrain/terrainGrid.js +24 -0
- package/src/traffic/addTraffic.js +7 -0
- package/src/traffic/along.js +14 -0
- package/src/traffic/clockMinutes.js +6 -0
- package/src/traffic/compareDepartures.js +5 -0
- package/src/traffic/createTrafficMesh.js +7 -0
- package/src/traffic/destroyTrafficGpu.js +5 -0
- package/src/traffic/disposeTrafficObject.js +13 -0
- package/src/traffic/drawTrafficRoute.js +6 -0
- package/src/traffic/failTraffic.js +6 -0
- package/src/traffic/failedTrafficLoad.js +5 -0
- package/src/traffic/fetchTrafficLanes.js +10 -0
- package/src/traffic/groundTraffic.js +15 -0
- package/src/traffic/initTraffic.js +54 -0
- package/src/traffic/loadTraffic.js +15 -0
- package/src/traffic/loadedTrafficLanes.js +16 -0
- package/src/traffic/locateTraffic.js +9 -0
- package/src/traffic/moveTraffic.js +15 -0
- package/src/traffic/placeTraffic.js +21 -0
- package/src/traffic/prepareTraffic.js +25 -0
- package/src/traffic/readyTraffic.js +6 -0
- package/src/traffic/rebaseTraffic.js +58 -0
- package/src/traffic/rebuildTrafficMesh.js +28 -0
- package/src/traffic/removeTraffic.js +17 -0
- package/src/traffic/routeColor.js +6 -0
- package/src/traffic/routeGeometry.js +31 -0
- package/src/traffic/scheduledTrips.js +40 -0
- package/src/traffic/startTraffic.js +8 -0
- package/src/traffic/tickTraffic.js +57 -0
- package/src/traffic/toLanes.js +16 -0
- package/src/traffic/tooltip.js +11 -0
- package/src/traffic/trafficBounds.js +17 -0
- package/src/traffic/trafficNow.js +4 -0
- package/src/traffic/trafficStorage.js +5 -0
- package/src/traffic/tripsAt.js +27 -0
- package/src/traffic/updateTraffic.js +8 -0
- package/src/traffic/updateTrafficTerrain.js +12 -0
- package/src/traffic/vehicleOffsets.js +11 -0
- package/src/triangulation/area.js +9 -0
- package/src/triangulation/clean.js +18 -0
- package/src/triangulation/containsVertex.js +11 -0
- package/src/triangulation/cross.js +3 -0
- package/src/triangulation/crossesBoundary.js +8 -0
- package/src/triangulation/crossesRing.js +9 -0
- package/src/triangulation/equal.js +3 -0
- package/src/triangulation/inside.js +10 -0
- package/src/triangulation/insideHole.js +7 -0
- package/src/triangulation/intersects.js +11 -0
- package/src/triangulation/isClockWise.js +13 -0
- package/src/triangulation/minimumX.js +6 -0
- package/src/triangulation/on.js +4 -0
- package/src/triangulation/sortHoles.js +26 -0
- package/src/triangulation/triangulate.js +86 -0
- package/src/utils/channel.js +4 -0
- package/src/utils/compareDistance.js +3 -0
- package/src/utils/noOperation.js +1 -0
- package/src/utils/parseColor.js +42 -0
- package/src/utils/toSRGB.js +3 -0
- package/src/utils/wrap.js +3 -0
- package/src/vehicles/bicycleModel.js +23 -0
- package/src/vehicles/boatBenches.js +8 -0
- package/src/vehicles/boatModel.js +27 -0
- package/src/vehicles/busModel.js +6 -0
- package/src/vehicles/carModel.js +22 -0
- package/src/vehicles/carriage.js +19 -0
- package/src/vehicles/metroModel.js +9 -0
- package/src/vehicles/mirror.js +8 -0
- package/src/vehicles/pedestrianModel.js +17 -0
- package/src/vehicles/tramModel.js +9 -0
- package/src/walk/blocked.js +6 -0
- package/src/walk/createWalk.js +60 -0
- package/src/walk/initWalk.js +18 -0
- package/src/walk/initialize.js +6 -0
- package/src/walk/local.js +10 -0
- package/src/walk/onAdd.js +4 -0
- package/src/walk/onBlur.js +3 -0
- package/src/walk/onKey.js +12 -0
- package/src/walk/onPointer.js +13 -0
- package/src/walk/onRemove.js +4 -0
- package/src/walk/onTerrain.js +5 -0
- package/src/walk/place.js +18 -0
- package/src/walk/start.js +37 -0
- package/src/walk/step.js +53 -0
- package/src/walk/stop.js +27 -0
- package/src/walk/toggle.js +6 -0
- package/dist/scene/gpu.js +0 -3
- package/dist/scene/gpu.js.map +0 -7
- package/dist/scene/lighting.js +0 -9
- package/dist/scene/lighting.js.map +0 -7
- package/dist/scene/model.js +0 -2
- package/dist/scene/model.js.map +0 -7
- package/dist/scene/picking.js +0 -2
- package/dist/scene/picking.js.map +0 -7
- package/dist/scene/pmtiles.js +0 -2
- package/dist/scene/pmtiles.js.map +0 -7
- package/dist/scene/render.js +0 -15
- package/dist/scene/render.js.map +0 -7
- package/dist/scene/sources.js +0 -2
- package/dist/scene/sources.js.map +0 -7
- package/dist/types/3d.js +0 -2
- package/dist/types/3d.js.map +0 -7
- package/dist/types/geojson.js +0 -2
- package/dist/types/geojson.js.map +0 -7
- package/dist/types/pmtiles.js +0 -2
- package/dist/types/pmtiles.js.map +0 -7
- package/dist/types/sunlight.js +0 -2
- package/dist/types/sunlight.js.map +0 -7
- package/dist/types/terrain.js +0 -24
- package/dist/types/terrain.js.map +0 -7
- package/dist/types/traffic.js +0 -41
- package/dist/types/traffic.js.map +0 -7
- package/dist/types/walk.js +0 -2
- package/dist/types/walk.js.map +0 -7
- package/dist/utils/control.js +0 -2
- package/dist/utils/control.js.map +0 -7
- package/dist/utils/geometry.js +0 -2
- package/dist/utils/geometry.js.map +0 -7
- package/dist/utils/lighting.js +0 -2
- package/dist/utils/lighting.js.map +0 -7
- package/dist/utils/model.js +0 -2
- package/dist/utils/model.js.map +0 -7
- package/dist/utils/picking.js +0 -2
- package/dist/utils/picking.js.map +0 -7
- package/dist/utils/pmtiles.js +0 -2
- package/dist/utils/pmtiles.js.map +0 -7
- package/dist/utils/scene.js +0 -2
- package/dist/utils/scene.js.map +0 -7
- package/dist/utils/shaders.js +0 -203
- package/dist/utils/shaders.js.map +0 -7
- package/dist/utils/sun.js +0 -2
- package/dist/utils/sun.js.map +0 -7
- package/dist/utils/terrain.js +0 -2
- package/dist/utils/terrain.js.map +0 -7
- package/dist/utils/traffic.js +0 -2
- package/dist/utils/traffic.js.map +0 -7
- package/dist/utils/vehicles.js +0 -2
- package/dist/utils/vehicles.js.map +0 -7
- package/dist/utils/walk.js +0 -2
- package/dist/utils/walk.js.map +0 -7
- package/src/scene/gpu.js +0 -438
- package/src/scene/lighting.js +0 -193
- package/src/scene/model.js +0 -204
- package/src/scene/picking.js +0 -150
- package/src/scene/pmtiles.js +0 -94
- package/src/scene/render.js +0 -467
- package/src/scene/sources.js +0 -265
- package/src/types/3d.js +0 -337
- package/src/types/geojson.js +0 -42
- package/src/types/pmtiles.js +0 -143
- package/src/types/sunlight.js +0 -142
- package/src/types/terrain.js +0 -331
- package/src/types/traffic.js +0 -356
- package/src/types/walk.js +0 -219
- package/src/utils/control.js +0 -18
- package/src/utils/geometry.js +0 -256
- package/src/utils/lighting.js +0 -51
- package/src/utils/model.js +0 -178
- package/src/utils/picking.js +0 -119
- package/src/utils/pmtiles.js +0 -79
- package/src/utils/scene.js +0 -102
- package/src/utils/sun.js +0 -71
- package/src/utils/terrain.js +0 -78
- package/src/utils/traffic.js +0 -90
- package/src/utils/vehicles.js +0 -69
- package/src/utils/walk.js +0 -72
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
// GeoJSON (Multi)LineStrings become lanes ({latlngs, properties, elevation?}); prepare() adds `points` ([x, z, ground]),
|
|
2
|
+
// `lengths` and `length` in layer-local metres.
|
|
3
|
+
|
|
4
|
+
export function toLanes({ features = [] }) {
|
|
5
|
+
const lanes = [];
|
|
6
|
+
let geometry, properties, lines, line, latlngs, lng, lat;
|
|
7
|
+
for ({ geometry, properties } of features) {
|
|
8
|
+
lines = geometry?.type === 'LineString' ? [geometry.coordinates] : geometry?.type === 'MultiLineString' ? geometry.coordinates : [];
|
|
9
|
+
for (line of lines) {
|
|
10
|
+
latlngs = [];
|
|
11
|
+
for ([lng, lat] of line) latlngs.push([lat, lng]);
|
|
12
|
+
lanes.push({ latlngs, properties: properties ?? {}, elevation: properties?.elevation });
|
|
13
|
+
}
|
|
14
|
+
}
|
|
15
|
+
return lanes;
|
|
16
|
+
}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
export function tooltip({ properties: p }) {
|
|
2
|
+
const content = document.createElement('div');
|
|
3
|
+
content.style.whiteSpace = 'pre-line';
|
|
4
|
+
const lines = [];
|
|
5
|
+
let line;
|
|
6
|
+
for (line of [p.name, p.departure && `Departure ${p.departure} ${p.timetable.timeZone}`, p.description]) {
|
|
7
|
+
if (line) lines.push(line);
|
|
8
|
+
}
|
|
9
|
+
content.textContent = lines.join('\n');
|
|
10
|
+
return content;
|
|
11
|
+
}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { computeBounds } from '../geometry/computeBounds.js';
|
|
2
|
+
|
|
3
|
+
export function trafficBounds(state) {
|
|
4
|
+
let radius = 20, height = 5;
|
|
5
|
+
let i, lane, x, z, y;
|
|
6
|
+
for (i = 0; i < state.template.position.length; i += 3) {
|
|
7
|
+
radius = Math.max(radius, Math.hypot(state.template.position[i], state.template.position[i + 2]) + Math.abs(state.side));
|
|
8
|
+
height = Math.max(height, state.template.position[i + 1]);
|
|
9
|
+
}
|
|
10
|
+
const data = [];
|
|
11
|
+
for (lane of state.lanes) {
|
|
12
|
+
for ([x, z, y] of lane.points) data.push(x - radius, y, z - radius, x + radius, y + height, z + radius);
|
|
13
|
+
}
|
|
14
|
+
const extent = { attributes: { position: { data } } };
|
|
15
|
+
computeBounds(extent);
|
|
16
|
+
state.mesh.geometry.bounds = extent.bounds;
|
|
17
|
+
}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import { vehicleOffsets } from "./vehicleOffsets.js";
|
|
2
|
+
import { scheduledTrips } from "./scheduledTrips.js";
|
|
3
|
+
|
|
4
|
+
// A lane with a `timetable` runs scheduled trips end to end; one with a `flow` (vehicles/h) loops evenly spaced vehicles.
|
|
5
|
+
|
|
6
|
+
export function tripsAt(time, lanes, velocity) {
|
|
7
|
+
const trips = [];
|
|
8
|
+
let l, lane, timetable, flow, trip, travelled, offsets, k;
|
|
9
|
+
for (l = 0; l < lanes.length; l++) {
|
|
10
|
+
lane = lanes[l];
|
|
11
|
+
({ timetable, flow = 0 } = lane.properties);
|
|
12
|
+
if (!lane.length) continue;
|
|
13
|
+
if (timetable) {
|
|
14
|
+
for (trip of scheduledTrips(time, timetable)) trips.push({
|
|
15
|
+
id: `${l}-${trip.id}`, lane, distance: trip.progress * lane.length, speed: lane.length / (timetable.duration * 60),
|
|
16
|
+
properties: { ...lane.properties, departure: trip.departure },
|
|
17
|
+
});
|
|
18
|
+
} else {
|
|
19
|
+
travelled = time / 1000 * velocity;
|
|
20
|
+
offsets = lane.offsets ||= vehicleOffsets(lane.length, flow, velocity);
|
|
21
|
+
for (k = 0; k < offsets.length; k++) trips.push({
|
|
22
|
+
id: `${l}-${k}`, lane, distance: (offsets[k] + travelled) % lane.length, speed: velocity, properties: lane.properties,
|
|
23
|
+
});
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
return trips;
|
|
27
|
+
}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { disposeTrafficObject } from './disposeTrafficObject.js';
|
|
2
|
+
import { groundTraffic } from './groundTraffic.js';
|
|
3
|
+
import { trafficBounds } from './trafficBounds.js';
|
|
4
|
+
|
|
5
|
+
export function updateTrafficTerrain(state) {
|
|
6
|
+
if (!state.lanes.length) return;
|
|
7
|
+
groundTraffic(state);
|
|
8
|
+
disposeTrafficObject(state, state.route);
|
|
9
|
+
state.route = null;
|
|
10
|
+
if (state.mesh) trafficBounds(state);
|
|
11
|
+
if (!state.frame) state.tick();
|
|
12
|
+
}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { speed } from "../constants/speed.js";
|
|
2
|
+
|
|
3
|
+
/** Evenly spaced starting offsets (metres) for `flow` vehicles/h moving at `velocity` m/s on a `length` metres lane. */
|
|
4
|
+
|
|
5
|
+
export function vehicleOffsets(length, flow, velocity = speed) {
|
|
6
|
+
const count = Math.round(length * flow / 3600 / velocity);
|
|
7
|
+
const offsets = Array.from({ length: count });
|
|
8
|
+
let i;
|
|
9
|
+
for (i = 0; i < offsets.length; i++) offsets[i] = (i + 0.5) * length / count;
|
|
10
|
+
return offsets;
|
|
11
|
+
}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { cross } from './cross.js';
|
|
2
|
+
import { equal } from './equal.js';
|
|
3
|
+
|
|
4
|
+
export function clean(ring) {
|
|
5
|
+
let changed = true;
|
|
6
|
+
let i, a, b, c;
|
|
7
|
+
while (changed && ring.length > 3) {
|
|
8
|
+
changed = false;
|
|
9
|
+
for (i = 0; i < ring.length; i++) {
|
|
10
|
+
a = ring[(i + ring.length - 1) % ring.length], b = ring[i], c = ring[(i + 1) % ring.length];
|
|
11
|
+
if (equal(a, b) || Math.abs(cross(a, b, c)) < 1e-10) {
|
|
12
|
+
ring.splice(i, 1); changed = true; break;
|
|
13
|
+
}
|
|
14
|
+
}
|
|
15
|
+
}
|
|
16
|
+
if (ring.length < 3) throw new Error('Degenerate polygon ring');
|
|
17
|
+
return ring;
|
|
18
|
+
}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { equal } from './equal.js';
|
|
2
|
+
import { cross } from './cross.js';
|
|
3
|
+
|
|
4
|
+
export function containsVertex(polygon, a, b, c) {
|
|
5
|
+
let p;
|
|
6
|
+
for (p of polygon) {
|
|
7
|
+
if (!equal(p, a) && !equal(p, b) && !equal(p, c) &&
|
|
8
|
+
cross(a, b, p) >= 0 && cross(b, c, p) >= 0 && cross(c, a, p) >= 0) return true;
|
|
9
|
+
}
|
|
10
|
+
return false;
|
|
11
|
+
}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { crossesRing } from './crossesRing.js';
|
|
2
|
+
|
|
3
|
+
export function crossesBoundary(a, b, polygon, rings) {
|
|
4
|
+
if (crossesRing(a, b, polygon)) return true;
|
|
5
|
+
let i;
|
|
6
|
+
for (i = 1; i < rings.length; i++) if (crossesRing(a, b, rings[i])) return true;
|
|
7
|
+
return false;
|
|
8
|
+
}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
export function inside(point, ring) {
|
|
2
|
+
let result = false;
|
|
3
|
+
let i, j, a, b;
|
|
4
|
+
for (i = 0, j = ring.length - 1; i < ring.length; j = i++) {
|
|
5
|
+
a = ring[i], b = ring[j];
|
|
6
|
+
if ((a.y > point.y) !== (b.y > point.y) &&
|
|
7
|
+
point.x < (b.x - a.x) * (point.y - a.y) / (b.y - a.y) + a.x) result = !result;
|
|
8
|
+
}
|
|
9
|
+
return result;
|
|
10
|
+
}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { equal } from './equal.js';
|
|
2
|
+
import { cross } from './cross.js';
|
|
3
|
+
import { on } from './on.js';
|
|
4
|
+
|
|
5
|
+
export function intersects(a, b, c, d) {
|
|
6
|
+
if (equal(a, c) || equal(a, d) || equal(b, c) || equal(b, d)) return false;
|
|
7
|
+
const abC = cross(a, b, c), abD = cross(a, b, d), cdA = cross(c, d, a), cdB = cross(c, d, b);
|
|
8
|
+
return abC * abD < 0 && cdA * cdB < 0 ||
|
|
9
|
+
abC === 0 && on(a, b, c) || abD === 0 && on(a, b, d) ||
|
|
10
|
+
cdA === 0 && on(c, d, a) || cdB === 0 && on(c, d, b);
|
|
11
|
+
}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @returns {boolean} Whether the `{x, y}` points are in clockwise order.
|
|
3
|
+
*/
|
|
4
|
+
|
|
5
|
+
export function isClockWise(points) {
|
|
6
|
+
let area = 0;
|
|
7
|
+
let i, a, b;
|
|
8
|
+
for (i = 0; i < points.length; i++) {
|
|
9
|
+
a = points[i], b = points[(i + 1) % points.length];
|
|
10
|
+
area += a.x * b.y - b.x * a.y;
|
|
11
|
+
}
|
|
12
|
+
return area < 0;
|
|
13
|
+
}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import { minimumX } from './minimumX.js';
|
|
2
|
+
|
|
3
|
+
export function sortHoles(holes) {
|
|
4
|
+
const buffer = new Array(holes.length), entries = [];
|
|
5
|
+
let ring, width, start, middle, end, left, right, output, previous, i;
|
|
6
|
+
for (ring of holes) entries.push({ ring, x: minimumX(ring) });
|
|
7
|
+
let source = entries, target = buffer;
|
|
8
|
+
for (width = 1; width < entries.length; width *= 2) {
|
|
9
|
+
for (start = 0; start < entries.length; start += width * 2) {
|
|
10
|
+
middle = Math.min(start + width, entries.length), end = Math.min(start + width * 2, entries.length);
|
|
11
|
+
left = start, right = middle;
|
|
12
|
+
for (output = start; output < end; output++) {
|
|
13
|
+
if (left < middle && (right >= end || source[left].x <= source[right].x)) {
|
|
14
|
+
target[output] = source[left++];
|
|
15
|
+
} else {
|
|
16
|
+
target[output] = source[right++];
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
previous = source;
|
|
21
|
+
source = target;
|
|
22
|
+
target = previous;
|
|
23
|
+
}
|
|
24
|
+
for (i = 0; i < holes.length; i++) holes[i] = source[i].ring;
|
|
25
|
+
return holes;
|
|
26
|
+
}
|
|
@@ -0,0 +1,86 @@
|
|
|
1
|
+
import { isClockWise } from "./isClockWise.js";
|
|
2
|
+
import { cross } from './cross.js';
|
|
3
|
+
import { clean } from './clean.js';
|
|
4
|
+
import { inside } from './inside.js';
|
|
5
|
+
import { insideHole } from './insideHole.js';
|
|
6
|
+
import { crossesBoundary } from './crossesBoundary.js';
|
|
7
|
+
import { containsVertex } from './containsVertex.js';
|
|
8
|
+
import { area } from './area.js';
|
|
9
|
+
import { sortHoles } from './sortHoles.js';
|
|
10
|
+
|
|
11
|
+
/**
|
|
12
|
+
* Triangulates a polygon given as `{x, y}` points.
|
|
13
|
+
* Rings omit the repeated closing point; winding is normalized internally.
|
|
14
|
+
* Vertex indices remain relative to the original inputs after duplicate/collinear
|
|
15
|
+
* cleanup. Hole bridges duplicate endpoints, not source vertices.
|
|
16
|
+
* @param {Object[]} contour Outer boundary.
|
|
17
|
+
* @param {Object[][]} [holes] Interior boundaries.
|
|
18
|
+
*
|
|
19
|
+
* @returns {number[][]} Triangles as indices in `[...contour, ...holes.flat()]`.
|
|
20
|
+
*/
|
|
21
|
+
|
|
22
|
+
export function triangulate(contour, holes = []) {
|
|
23
|
+
const points = [contour, ...holes].flat();
|
|
24
|
+
let p, index, path, ring, hole, bridge, distance, h, a, b, d, mid, h2, p2, clipped, i, c, triangle2;
|
|
25
|
+
for (p of points) {
|
|
26
|
+
if (!Number.isFinite(p.x) || !Number.isFinite(p.y)) throw new Error('Invalid polygon coordinates');
|
|
27
|
+
}
|
|
28
|
+
// Translate near the origin to avoid cancellation with geographic coordinates.
|
|
29
|
+
const vertices = [];
|
|
30
|
+
for (index = 0; index < points.length; index++) {
|
|
31
|
+
p = points[index];
|
|
32
|
+
vertices.push({ x: p.x - contour[0].x, y: p.y - contour[0].y, index });
|
|
33
|
+
}
|
|
34
|
+
// Remove zero-area corners before connecting holes; keep original vertex indices.
|
|
35
|
+
let offset = 0;
|
|
36
|
+
const rings = [], paths = [contour, ...holes];
|
|
37
|
+
for (index = 0; index < paths.length; index++) {
|
|
38
|
+
path = paths[index];
|
|
39
|
+
ring = clean(vertices.slice(offset, offset += path.length));
|
|
40
|
+
if (isClockWise(ring) !== Boolean(index)) ring.reverse();
|
|
41
|
+
rings.push(ring);
|
|
42
|
+
}
|
|
43
|
+
let polygon = rings[0].slice();
|
|
44
|
+
// A bridge must stay inside the outer boundary, outside every hole, and cross no edge.
|
|
45
|
+
// ponytail: quadratic ear clipping for building footprints; use spatial indexing for large rings.
|
|
46
|
+
const holesToConnect = sortHoles(rings.slice(1));
|
|
47
|
+
for (hole of holesToConnect) {
|
|
48
|
+
bridge = void 0, distance = Infinity;
|
|
49
|
+
for (h = 0; h < hole.length; h++) for (p = 0; p < polygon.length; p++) {
|
|
50
|
+
a = hole[h], b = polygon[p], d = (a.x - b.x) ** 2 + (a.y - b.y) ** 2;
|
|
51
|
+
if (d >= distance) continue;
|
|
52
|
+
mid = { x: (a.x + b.x) / 2, y: (a.y + b.y) / 2 };
|
|
53
|
+
if (!inside(mid, rings[0]) || insideHole(mid, rings)) continue;
|
|
54
|
+
if (crossesBoundary(a, b, polygon, rings)) continue;
|
|
55
|
+
bridge = [h, p]; distance = d;
|
|
56
|
+
}
|
|
57
|
+
if (!bridge) throw new Error('Unable to connect polygon hole');
|
|
58
|
+
[h2, p2] = bridge;
|
|
59
|
+
polygon = [...polygon.slice(0, p2 + 1), ...hole.slice(h2), ...hole.slice(0, h2 + 1),
|
|
60
|
+
polygon[p2], ...polygon.slice(p2 + 1)];
|
|
61
|
+
}
|
|
62
|
+
// Clip a convex corner only when no other vertex is inside/on its triangle.
|
|
63
|
+
const result = [];
|
|
64
|
+
while (polygon.length > 3) {
|
|
65
|
+
clipped = false;
|
|
66
|
+
for (i = 0; i < polygon.length; i++) {
|
|
67
|
+
a = polygon[(i + polygon.length - 1) % polygon.length], b = polygon[i], c = polygon[(i + 1) % polygon.length];
|
|
68
|
+
if (cross(a, b, c) <= 1e-10) continue;
|
|
69
|
+
if (containsVertex(polygon, a, b, c)) continue;
|
|
70
|
+
result.push([a.index, b.index, c.index]); polygon.splice(i, 1); clipped = true; break;
|
|
71
|
+
}
|
|
72
|
+
if (!clipped) throw new Error('Unable to triangulate polygon: invalid or self-intersecting rings');
|
|
73
|
+
}
|
|
74
|
+
if (cross(...polygon) > 1e-10) {
|
|
75
|
+
const triangle = [];
|
|
76
|
+
for (p of polygon) triangle.push(p.index);
|
|
77
|
+
result.push(triangle);
|
|
78
|
+
}
|
|
79
|
+
// Reject incomplete coverage instead of silently emitting a partial roof.
|
|
80
|
+
let holeArea = 0, actual = 0;
|
|
81
|
+
for (i = 1; i < rings.length; i++) holeArea += area(rings[i]);
|
|
82
|
+
const expected = area(rings[0]) - holeArea;
|
|
83
|
+
for (triangle2 of result) actual += cross(vertices[triangle2[0]], vertices[triangle2[1]], vertices[triangle2[2]]) / 2;
|
|
84
|
+
if (expected <= 0 || Math.abs(actual - expected) > Math.max(1e-7, expected * 1e-8)) throw new Error('Polygon triangulation area mismatch');
|
|
85
|
+
return result;
|
|
86
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export function noOperation() {}
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
import { toSRGB } from "./toSRGB.js";
|
|
2
|
+
import { channel } from "./channel.js";
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* HSL inputs are linear-space to preserve the original building styling.
|
|
6
|
+
* Numeric/CSS/RGB inputs are already sRGB; CSS alpha is not used for extrusion.
|
|
7
|
+
* @param {number|string|Object} value 0xRRGGBB, CSS color, {r,g,b}, or {h,s,l} in 0..1.
|
|
8
|
+
* @returns {Object} sRGB {r,g,b} components in 0..1.
|
|
9
|
+
*/
|
|
10
|
+
|
|
11
|
+
export function parseColor(value) {
|
|
12
|
+
if (value && typeof value === 'object' && 'h' in value) {
|
|
13
|
+
const a = value.s * Math.min(value.l, 1 - value.l);
|
|
14
|
+
return {
|
|
15
|
+
r: toSRGB(channel(0, value.h, value.l, a)),
|
|
16
|
+
g: toSRGB(channel(8, value.h, value.l, a)),
|
|
17
|
+
b: toSRGB(channel(4, value.h, value.l, a))
|
|
18
|
+
};
|
|
19
|
+
}
|
|
20
|
+
if (value && typeof value === 'object' && 'r' in value) {
|
|
21
|
+
return value;
|
|
22
|
+
}
|
|
23
|
+
if (typeof value === 'number') {
|
|
24
|
+
return {
|
|
25
|
+
r: (value >> 16 & 255) / 255,
|
|
26
|
+
g: (value >> 8 & 255) / 255,
|
|
27
|
+
b: (value & 255) / 255,
|
|
28
|
+
};
|
|
29
|
+
}
|
|
30
|
+
if (typeof value !== 'string' || !CSS.supports('color', value)) {
|
|
31
|
+
throw new Error('Invalid 3D color');
|
|
32
|
+
}
|
|
33
|
+
const context = document.createElement('canvas').getContext('2d');
|
|
34
|
+
context.fillStyle = value;
|
|
35
|
+
context.fillRect(0, 0, 1, 1);
|
|
36
|
+
const [r, g, b] = context.getImageData(0, 0, 1, 1).data;
|
|
37
|
+
return {
|
|
38
|
+
r: r / 255,
|
|
39
|
+
g: g / 255,
|
|
40
|
+
b: b / 255
|
|
41
|
+
};
|
|
42
|
+
}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { box } from '../geometry/box.js';
|
|
2
|
+
import { skin } from '../constants/skin.js';
|
|
3
|
+
import { trousers } from '../constants/trousers.js';
|
|
4
|
+
import { dark } from '../constants/dark.js';
|
|
5
|
+
import { paints } from '../constants/paints.js';
|
|
6
|
+
|
|
7
|
+
export function bicycleModel(index) {
|
|
8
|
+
const paint = paints[index % paints.length];
|
|
9
|
+
return [
|
|
10
|
+
[box(-0.045, 0.045, -0.85, -0.25), 0.02, 0.62, dark],
|
|
11
|
+
[box(-0.045, 0.045, 0.25, 0.85), 0.02, 0.62, dark],
|
|
12
|
+
[box(-0.06, 0.06, -0.5, 0.5), 0.4, 0.65, paint],
|
|
13
|
+
[box(-0.32, 0.32, -0.58, -0.5), 0.95, 1.02, dark],
|
|
14
|
+
[box(-0.1, 0.1, 0.15, 0.4), 0.85, 0.92, dark],
|
|
15
|
+
[box(-0.18, 0.18, -0.12, 0.28), 1, 1.5, paint],
|
|
16
|
+
[box(-0.11, 0.11, -0.22, 0), 1.5, 1.72, skin],
|
|
17
|
+
[box(-0.13, 0.13, -0.23, 0.01), 1.72, 1.8, paint],
|
|
18
|
+
[box(-0.25, -0.15, -0.5, -0.05), 1, 1.25, skin],
|
|
19
|
+
[box(0.15, 0.25, -0.5, -0.05), 1, 1.25, skin],
|
|
20
|
+
[box(-0.2, -0.08, 0, 0.32), 0.3, 1, trousers],
|
|
21
|
+
[box(0.08, 0.2, -0.25, 0.07), 0.3, 1, trousers],
|
|
22
|
+
];
|
|
23
|
+
}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import { hull } from '../constants/hull.js';
|
|
2
|
+
import { box } from '../geometry/box.js';
|
|
3
|
+
import { glass } from '../constants/glass.js';
|
|
4
|
+
import { mirror } from './mirror.js';
|
|
5
|
+
import { white } from '../constants/white.js';
|
|
6
|
+
import { boatBenches } from './boatBenches.js';
|
|
7
|
+
|
|
8
|
+
// Panoramic river cruiser, about 60 x 11 m.
|
|
9
|
+
export function boatModel() {
|
|
10
|
+
return [
|
|
11
|
+
[hull, 0, 0.8, [0.1, 0.16, 0.26]],
|
|
12
|
+
[hull, 0.8, 1.4, white],
|
|
13
|
+
[box(-5, 5, -18, 26), 1.4, 3.7, glass, box(-4.6, 4.6, -17.4, 25.6)],
|
|
14
|
+
...mirror(4.64, 4.74, -17, 25, 3.25, 3.45, [1.6, 1.25, 0.8]),
|
|
15
|
+
[box(-4.8, 4.8, -17.8, 25.8), 3.7, 3.9, white],
|
|
16
|
+
...boatBenches(),
|
|
17
|
+
...mirror(4.65, 4.8, -13.6, 25.8, 3.9, 4.8, white),
|
|
18
|
+
[box(-4.8, 4.8, 25.65, 25.8), 3.9, 4.8, white],
|
|
19
|
+
[box(-2.2, 2.2, -17.6, -14), 3.9, 4.7, white],
|
|
20
|
+
[box(-2.2, 2.2, -17.6, -14), 4.7, 5.5, glass],
|
|
21
|
+
[box(-2.5, 2.5, -18, -13.6), 5.5, 5.7, white],
|
|
22
|
+
[box(-2.45, -2.2, -16.2, -15.8), 5, 5.3, [2, 0.15, 0.1]],
|
|
23
|
+
[box(2.2, 2.45, -16.2, -15.8), 5, 5.3, [0.1, 2, 0.4]],
|
|
24
|
+
[box(-0.1, 0.1, -15.9, -15.7), 5.7, 6.6, white],
|
|
25
|
+
[box(-0.15, 0.15, -15.95, -15.65), 6.6, 6.8, [2, 2, 1.9]],
|
|
26
|
+
];
|
|
27
|
+
}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { box } from '../geometry/box.js';
|
|
2
|
+
import { glass } from '../constants/glass.js';
|
|
3
|
+
import { tyre } from '../constants/tyre.js';
|
|
4
|
+
import { mirror } from './mirror.js';
|
|
5
|
+
import { paints } from '../constants/paints.js';
|
|
6
|
+
import { headlight } from '../constants/headlight.js';
|
|
7
|
+
import { taillight } from '../constants/taillight.js';
|
|
8
|
+
|
|
9
|
+
export function carModel(i) {
|
|
10
|
+
const paint = paints[i % paints.length];
|
|
11
|
+
return [
|
|
12
|
+
...mirror(0.7, 0.92, -1.68, -1.02, 0, 0.64, tyre),
|
|
13
|
+
...mirror(0.7, 0.92, 1.02, 1.68, 0, 0.64, tyre),
|
|
14
|
+
[[[-0.9, -1.95], [-0.72, -2.25], [0.72, -2.25], [0.9, -1.95], [0.9, 2.05], [0.76, 2.25], [-0.76, 2.25], [-0.9, 2.05]],
|
|
15
|
+
0.28, 0.82, paint],
|
|
16
|
+
// Greenhouse: the windscreen leans back, the rear window less.
|
|
17
|
+
[box(-0.84, 0.84, -0.75, 1.6), 0.82, 1.38, glass, box(-0.7, 0.7, -0.05, 1.3)],
|
|
18
|
+
[box(-0.71, 0.71, -0.06, 1.31), 1.38, 1.46, paint],
|
|
19
|
+
...mirror(0.38, 0.8, -2.3, -2.16, 0.56, 0.76, headlight),
|
|
20
|
+
[box(-0.78, 0.78, 2.16, 2.3), 0.6, 0.76, taillight],
|
|
21
|
+
];
|
|
22
|
+
}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { box } from '../geometry/box.js';
|
|
2
|
+
import { glass } from '../constants/glass.js';
|
|
3
|
+
import { tyre } from '../constants/tyre.js';
|
|
4
|
+
import { white } from '../constants/white.js';
|
|
5
|
+
import { headlight } from '../constants/headlight.js';
|
|
6
|
+
import { taillight } from '../constants/taillight.js';
|
|
7
|
+
|
|
8
|
+
export function carriage(center, length, color) {
|
|
9
|
+
const front = center - length / 2, rear = center + length / 2;
|
|
10
|
+
return [
|
|
11
|
+
[box(-1.25, 1.25, front, rear), 0.45, 1.25, color],
|
|
12
|
+
[box(-1.2, 1.2, front + 0.15, rear - 0.15), 1.25, 2.65, glass],
|
|
13
|
+
[box(-1.25, 1.25, front, rear), 2.65, 3.1, white],
|
|
14
|
+
[box(-1.15, -0.85, front + 1, front + 2), 0, 0.7, tyre],
|
|
15
|
+
[box(0.85, 1.15, rear - 2, rear - 1), 0, 0.7, tyre],
|
|
16
|
+
[box(-0.9, 0.9, front - 0.03, front), 0.8, 1.05, headlight],
|
|
17
|
+
[box(-0.9, 0.9, rear, rear + 0.03), 0.8, 1.05, taillight],
|
|
18
|
+
];
|
|
19
|
+
}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { routeColor } from '../traffic/routeColor.js';
|
|
2
|
+
import { carriage } from './carriage.js';
|
|
3
|
+
|
|
4
|
+
export function metroModel(index, properties) {
|
|
5
|
+
const color = routeColor(properties), parts = [];
|
|
6
|
+
let car;
|
|
7
|
+
for (car = 0; car < 5; car++) parts.push(...carriage((car - 2) * 15, 14, color));
|
|
8
|
+
return parts;
|
|
9
|
+
}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { box } from '../geometry/box.js';
|
|
2
|
+
import { parts } from '../constants/parts.js';
|
|
3
|
+
import { skin } from '../constants/skin.js';
|
|
4
|
+
import { trousers } from '../constants/trousers.js';
|
|
5
|
+
import { paints } from '../constants/paints.js';
|
|
6
|
+
|
|
7
|
+
export function pedestrianModel(index) {
|
|
8
|
+
const model = parts.body.slice();
|
|
9
|
+
model[1] = [model[1][0], model[1][1], model[1][2], paints[index % paints.length]];
|
|
10
|
+
model.push(
|
|
11
|
+
[box(-0.16, -0.02, -0.07, 0.07), 0.08, 0.9, trousers],
|
|
12
|
+
[box(0.02, 0.16, -0.07, 0.07), 0.08, 0.9, trousers],
|
|
13
|
+
[box(-0.3, -0.2, -0.05, 0.05), 0.76, 1.42, skin],
|
|
14
|
+
[box(0.2, 0.3, -0.05, 0.05), 0.76, 1.42, skin],
|
|
15
|
+
);
|
|
16
|
+
return model;
|
|
17
|
+
}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { routeColor } from '../traffic/routeColor.js';
|
|
2
|
+
import { carriage } from './carriage.js';
|
|
3
|
+
|
|
4
|
+
export function tramModel(index, properties) {
|
|
5
|
+
const color = routeColor(properties), parts = [];
|
|
6
|
+
let car;
|
|
7
|
+
for (car = 0; car < 5; car++) parts.push(...carriage((car - 2) * 6.5, 6, color));
|
|
8
|
+
return parts;
|
|
9
|
+
}
|