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.
Files changed (919) hide show
  1. package/README.md +49 -3
  2. package/cucumber.mjs +1 -1
  3. package/dist/leaflet-city-mapper.js +3 -1
  4. package/dist/leaflet-city-mapper.js.map +4 -4
  5. package/package.json +2 -1
  6. package/src/archives/decodeDirectory.js +32 -0
  7. package/src/archives/decodeHeader.js +19 -0
  8. package/src/archives/getZxy.js +75 -0
  9. package/src/archives/loadDirectory.js +7 -0
  10. package/src/archives/tileId.js +19 -0
  11. package/src/archives/varint.js +15 -0
  12. package/src/camera/angles.js +6 -0
  13. package/src/camera/animationPoint.js +8 -0
  14. package/src/camera/cameraMapReady.js +8 -0
  15. package/src/camera/cancelCameraAnimation.js +11 -0
  16. package/src/camera/cleanupCameraMap.js +11 -0
  17. package/src/camera/constrainCameraToBounds.js +3 -0
  18. package/src/camera/displayPoint.js +3 -0
  19. package/src/camera/fitCameraBounds.js +48 -0
  20. package/src/camera/groundBounds.js +11 -0
  21. package/src/camera/initializeCameraMap.js +25 -0
  22. package/src/camera/mapAnimateCamera.js +17 -0
  23. package/src/camera/mapCamera.js +123 -0
  24. package/src/camera/mapContainerPointToLayerPoint.js +7 -0
  25. package/src/camera/mapGetBearing.js +1 -0
  26. package/src/camera/mapGetBounds.js +14 -0
  27. package/src/camera/mapGetBoundsCenterZoom.js +7 -0
  28. package/src/camera/mapGetBoundsZoom.js +14 -0
  29. package/src/camera/mapGetCenterLayerPoint.js +5 -0
  30. package/src/camera/mapGetPitch.js +1 -0
  31. package/src/camera/mapLayerPointToContainerPoint.js +7 -0
  32. package/src/camera/mapLimitCenter.js +12 -0
  33. package/src/camera/mapLimitOffset.js +10 -0
  34. package/src/camera/mapPanBy.js +9 -0
  35. package/src/camera/mapPanInside.js +14 -0
  36. package/src/camera/mapResetNorth.js +1 -0
  37. package/src/camera/mapResetNorthPitch.js +1 -0
  38. package/src/camera/mapSetBearing.js +1 -0
  39. package/src/camera/mapSetPitch.js +1 -0
  40. package/src/camera/mapSetPitchAndBearing.js +14 -0
  41. package/src/camera/mapSetZoomAround.js +11 -0
  42. package/src/camera/mapStopPitchBearingAnimation.js +6 -0
  43. package/src/camera/mapTryAnimatedPan.js +9 -0
  44. package/src/camera/mapUpdateCameraOverlays.js +7 -0
  45. package/src/camera/pointOf.js +3 -0
  46. package/src/camera/project.js +20 -0
  47. package/src/camera/runCameraAnimations.js +28 -0
  48. package/src/camera/scheduleCameraAnimation.js +8 -0
  49. package/src/camera/updateSky.js +16 -0
  50. package/src/camera/verticalGroundY.js +4 -0
  51. package/src/collision/collectMeshes.js +5 -0
  52. package/src/collision/collider.js +63 -0
  53. package/src/collision/intersectMeshes.js +133 -0
  54. package/src/collision/sortHits.js +23 -0
  55. package/src/constants/Compass.js +7 -0
  56. package/src/constants/ContainerResize.js +7 -0
  57. package/src/constants/HEIGHT.js +1 -0
  58. package/src/constants/PitchDrag.js +7 -0
  59. package/src/constants/ShiftRotate.js +7 -0
  60. package/src/constants/TILE_RADIUS.js +1 -0
  61. package/src/constants/TILE_SIZE.js +1 -0
  62. package/src/constants/TouchMode.js +6 -0
  63. package/src/constants/attachState.js +1 -0
  64. package/src/constants/cameraControlsState.js +1 -0
  65. package/src/constants/cityMapper.js +6 -0
  66. package/src/constants/dark.js +1 -0
  67. package/src/constants/elevationWGSL.js +27 -0
  68. package/src/constants/glass.js +1 -0
  69. package/src/constants/indexState.js +1 -0
  70. package/src/constants/mapCameraState.js +1 -0
  71. package/src/constants/nativeEventMaps.js +1 -0
  72. package/src/constants/nativeLayerState.js +1 -0
  73. package/src/constants/nativeMethodHandlers.js +31 -0
  74. package/src/constants/onMapChangeState.js +1 -0
  75. package/src/constants/onZoomAnimState.js +1 -0
  76. package/src/constants/parts.js +19 -0
  77. package/src/constants/pendingUpdates.js +1 -0
  78. package/src/constants/pumpState.js +1 -0
  79. package/src/constants/ringDirections.js +10 -0
  80. package/src/constants/roundProfile.js +1 -0
  81. package/src/constants/shirt.js +1 -0
  82. package/src/constants/skin.js +2 -0
  83. package/src/constants/trafficShader.js +49 -0
  84. package/src/constants/trousers.js +1 -0
  85. package/src/constants/tyre.js +1 -0
  86. package/src/constants/underEntryState.js +1 -0
  87. package/src/constants/vehicles.js +40 -0
  88. package/src/controls/acceptPitchDrag.js +4 -0
  89. package/src/controls/acceptRotateDrag.js +3 -0
  90. package/src/controls/adjustCameraDrag.js +10 -0
  91. package/src/controls/cameraControls.js +60 -0
  92. package/src/controls/cameraDragClick.js +9 -0
  93. package/src/controls/cameraDragContextMenu.js +8 -0
  94. package/src/controls/cameraDragDown.js +20 -0
  95. package/src/controls/cameraDragEnd.js +6 -0
  96. package/src/controls/cameraDragMove.js +23 -0
  97. package/src/controls/changeCameraTouch.js +14 -0
  98. package/src/controls/cleanupCameraTouch.js +24 -0
  99. package/src/controls/compassAddHooks.js +15 -0
  100. package/src/controls/compassOrientation.js +6 -0
  101. package/src/controls/compassRemoveHooks.js +5 -0
  102. package/src/controls/containerResizeAddHooks.js +8 -0
  103. package/src/controls/containerResizeRemoveHooks.js +5 -0
  104. package/src/controls/dragCamera.js +22 -0
  105. package/src/controls/editable.js +3 -0
  106. package/src/controls/endAllCameraDrags.js +7 -0
  107. package/src/controls/endAllCameraTouches.js +7 -0
  108. package/src/controls/endCameraTouch.js +11 -0
  109. package/src/controls/endCameraTouchEvent.js +5 -0
  110. package/src/controls/finishCameraDrag.js +9 -0
  111. package/src/controls/finishCompassPermission.js +16 -0
  112. package/src/controls/loadCameraControls.js +9 -0
  113. package/src/controls/moveCameraTouch.js +22 -0
  114. package/src/controls/notifyCameraTouchChange.js +1 -0
  115. package/src/controls/pitchDragAddHooks.js +6 -0
  116. package/src/controls/pitchDragRemoveHooks.js +5 -0
  117. package/src/controls/refreshRotateControl.js +7 -0
  118. package/src/controls/refreshRotateFocus.js +5 -0
  119. package/src/controls/removeCameraDrag.js +23 -0
  120. package/src/controls/resizeMap.js +3 -0
  121. package/src/controls/rotateButtonClick.js +7 -0
  122. package/src/controls/rotateButtonKeydown.js +11 -0
  123. package/src/controls/rotateControl.js +3 -0
  124. package/src/controls/rotateOnAdd.js +38 -0
  125. package/src/controls/rotateOnRemove.js +6 -0
  126. package/src/controls/shiftRotateAddHooks.js +8 -0
  127. package/src/controls/shiftRotateRemoveHooks.js +5 -0
  128. package/src/controls/shiftRotateWheel.js +9 -0
  129. package/src/controls/startCameraTouch.js +23 -0
  130. package/src/core/addImageState.js +7 -0
  131. package/src/core/addRasterImage.js +10 -0
  132. package/src/core/adjustCameraMarkerPan.js +22 -0
  133. package/src/core/beforeNativeRender.js +10 -0
  134. package/src/core/boundsQuad.js +11 -0
  135. package/src/core/bringNativeLayerToBack.js +3 -0
  136. package/src/core/bringNativeLayerToFront.js +3 -0
  137. package/src/core/cameraCircleBounds.js +6 -0
  138. package/src/core/cameraMarkerDrag.js +18 -0
  139. package/src/core/cameraMarkerOnDrag.js +8 -0
  140. package/src/core/cancelGridFade.js +10 -0
  141. package/src/core/closestCameraLayerPoint.js +7 -0
  142. package/src/core/compareNativeHits.js +3 -0
  143. package/src/core/current.js +3 -0
  144. package/src/core/disposeNativeLayer.js +35 -0
  145. package/src/core/fireRasterLoad.js +5 -0
  146. package/src/core/forwardNativeError.js +3 -0
  147. package/src/core/gridlayerGetEvents.js +7 -0
  148. package/src/core/gridlayerGetTiledPixelBounds.js +8 -0
  149. package/src/core/handleNativeMapEvent.js +47 -0
  150. package/src/core/hideTargets.js +16 -0
  151. package/src/core/initNativeGPU.js +21 -0
  152. package/src/core/initializeGridContainer.js +6 -0
  153. package/src/core/initializeNativeLayer.js +42 -0
  154. package/src/core/localPixel.js +5 -0
  155. package/src/core/localPixelForGeometry.js +6 -0
  156. package/src/core/localPosition.js +6 -0
  157. package/src/core/markerCameraIconPoint.js +9 -0
  158. package/src/core/markerGetEvents.js +5 -0
  159. package/src/core/markerInitInteraction.js +8 -0
  160. package/src/core/markerQuadCorners.js +31 -0
  161. package/src/core/markerSetIcon.js +9 -0
  162. package/src/core/markerSetPos.js +14 -0
  163. package/src/core/markerSetRotation.js +7 -0
  164. package/src/core/markerUpdateZIndex.js +8 -0
  165. package/src/core/nativeAddLatLng.js +3 -0
  166. package/src/core/nativeBringToBack.js +3 -0
  167. package/src/core/nativeBringToFront.js +3 -0
  168. package/src/core/nativeEvents.js +26 -0
  169. package/src/core/nativeImageError.js +8 -0
  170. package/src/core/nativeImageRefresh.js +7 -0
  171. package/src/core/nativeLayer.js +97 -0
  172. package/src/core/nativeLayerMethod.js +21 -0
  173. package/src/core/nativeRedraw.js +3 -0
  174. package/src/core/nativeSetBounds.js +3 -0
  175. package/src/core/nativeSetIcon.js +3 -0
  176. package/src/core/nativeSetLatLng.js +3 -0
  177. package/src/core/nativeSetLatLngs.js +3 -0
  178. package/src/core/nativeSetOpacity.js +3 -0
  179. package/src/core/nativeSetRadius.js +3 -0
  180. package/src/core/nativeSetStyle.js +3 -0
  181. package/src/core/nativeSetUrl.js +3 -0
  182. package/src/core/nativeSetZIndex.js +3 -0
  183. package/src/core/nativeSetZIndexOffset.js +3 -0
  184. package/src/core/popupAdjustPan.js +23 -0
  185. package/src/core/popupGetEvents.js +5 -0
  186. package/src/core/popupUpdatePosition.js +14 -0
  187. package/src/core/putNativeMesh.js +33 -0
  188. package/src/core/quadNativeMesh.js +15 -0
  189. package/src/core/readyNativeGPU.js +6 -0
  190. package/src/core/refreshNativeEvent.js +5 -0
  191. package/src/core/refreshNativeLayer.js +29 -0
  192. package/src/core/refreshNativeLayerContract.js +3 -0
  193. package/src/core/rejectNativeReady.js +3 -0
  194. package/src/core/removeImageState.js +8 -0
  195. package/src/core/removeNativeEvents.js +16 -0
  196. package/src/core/removeTargets.js +8 -0
  197. package/src/core/reorderNativeLayer.js +6 -0
  198. package/src/core/resolveNativeReady.js +3 -0
  199. package/src/core/restoreNativeEvents.js +6 -0
  200. package/src/core/runGridFades.js +14 -0
  201. package/src/core/runMarkerPanFrame.js +12 -0
  202. package/src/core/scheduleGridFade.js +9 -0
  203. package/src/core/scheduleMarkerPan.js +8 -0
  204. package/src/core/styleNativeMesh.js +10 -0
  205. package/src/core/syncGridLayer.js +22 -0
  206. package/src/core/syncImageOverlay.js +9 -0
  207. package/src/core/syncMarker.js +12 -0
  208. package/src/core/syncVectorLayer.js +26 -0
  209. package/src/core/synchronizeNativeLayer.js +35 -0
  210. package/src/core/textureFor.js +48 -0
  211. package/src/core/tooltipGetEvents.js +5 -0
  212. package/src/core/tooltipSetPosition.js +8 -0
  213. package/src/core/updateGridOpacity.js +23 -0
  214. package/src/core/updateNativeLayerView.js +6 -0
  215. package/src/core/uploadCanvasTexture.js +19 -0
  216. package/src/geometry/addBridges.js +88 -0
  217. package/src/geometry/below.js +3 -0
  218. package/src/geometry/box.js +3 -0
  219. package/src/geometry/bridgeElevation.js +19 -0
  220. package/src/geometry/bridgeLocal.js +4 -0
  221. package/src/geometry/build.js +19 -0
  222. package/src/geometry/circleAt.js +5 -0
  223. package/src/geometry/clipLine.js +23 -0
  224. package/src/geometry/clipSegment.js +19 -0
  225. package/src/geometry/computeBounds.js +33 -0
  226. package/src/geometry/conformModelToTerrain.js +67 -0
  227. package/src/geometry/cross.js +3 -0
  228. package/src/geometry/disk.js +11 -0
  229. package/src/geometry/diskAt.js +4 -0
  230. package/src/geometry/dot.js +6 -0
  231. package/src/geometry/emitter.js +8 -0
  232. package/src/geometry/lampPostGeometry.js +24 -0
  233. package/src/geometry/lampRing.js +11 -0
  234. package/src/geometry/lightGeometry.js +15 -0
  235. package/src/geometry/line.js +54 -0
  236. package/src/geometry/nativeGeometry.js +55 -0
  237. package/src/geometry/nativeTriangle.js +3 -0
  238. package/src/geometry/polygon.js +22 -0
  239. package/src/geometry/push.js +3 -0
  240. package/src/geometry/quad.js +4 -0
  241. package/src/geometry/roofCoverage.js +52 -0
  242. package/src/geometry/samePoint.js +3 -0
  243. package/src/geometry/segment.js +21 -0
  244. package/src/geometry/setVertexColor.js +15 -0
  245. package/src/geometry/sub.js +6 -0
  246. package/src/geometry/surface.js +17 -0
  247. package/src/geometry/treeGeometry.js +31 -0
  248. package/src/geometry/treeRing.js +14 -0
  249. package/src/geometry/triangle.js +12 -0
  250. package/src/geometry/vertexNormals.js +32 -0
  251. package/src/geometry/visit.js +9 -0
  252. package/src/index.js +41 -323
  253. package/src/lighting/cacheLightGrid.js +23 -0
  254. package/src/lighting/collectLightMeshes.js +6 -0
  255. package/src/lighting/lightGrid.js +42 -0
  256. package/src/lighting/updatePointLights.js +34 -0
  257. package/src/lighting/visitCells.js +15 -0
  258. package/src/lighting/worldLights.js +27 -0
  259. package/src/models/decodeModel.js +45 -0
  260. package/src/models/hasUnsupportedPrimitives.js +10 -0
  261. package/src/models/loadBuffer.js +6 -0
  262. package/src/models/loadImage.js +15 -0
  263. package/src/models/loadModel.js +69 -0
  264. package/src/models/materialFor.js +21 -0
  265. package/src/models/modelNode.js +93 -0
  266. package/src/models/readAccessor.js +53 -0
  267. package/src/models/readAccessorValues.js +16 -0
  268. package/src/models/textureFor.js +35 -0
  269. package/src/picking/collectVisibleMesh.js +4 -0
  270. package/src/picking/findFeature.js +49 -0
  271. package/src/picking/hit.js +23 -0
  272. package/src/picking/hitMesh.js +30 -0
  273. package/src/picking/pointerClick.js +5 -0
  274. package/src/picking/pointerLeave.js +5 -0
  275. package/src/picking/pointerMove.js +5 -0
  276. package/src/picking/raycast.js +59 -0
  277. package/src/picking/setHighlight.js +13 -0
  278. package/src/picking/shouldSkipOther.js +3 -0
  279. package/src/picking/showFeature.js +34 -0
  280. package/src/raster/addRasterTile.js +114 -0
  281. package/src/raster/comparePendingTiles.js +5 -0
  282. package/src/raster/createGeometry.js +22 -0
  283. package/src/raster/createRasterMesh.js +47 -0
  284. package/src/raster/finishAttachment.js +11 -0
  285. package/src/raster/finishRasterTile.js +47 -0
  286. package/src/raster/getRasterEvents.js +6 -0
  287. package/src/raster/getRasterTileSize.js +5 -0
  288. package/src/raster/initRaster.js +38 -0
  289. package/src/raster/isLoading.js +5 -0
  290. package/src/raster/loadRasterTile.js +10 -0
  291. package/src/raster/onPMTileAdd.js +10 -0
  292. package/src/raster/onPMTileRemove.js +8 -0
  293. package/src/raster/pruneRasterTiles.js +37 -0
  294. package/src/raster/pumpRasterTiles.js +22 -0
  295. package/src/raster/readyRaster.js +13 -0
  296. package/src/raster/registerTerrainTile.js +12 -0
  297. package/src/raster/releaseRasterTile.js +18 -0
  298. package/src/raster/releaseRasterTiles.js +15 -0
  299. package/src/raster/removeRasterTile.js +13 -0
  300. package/src/raster/reportError.js +6 -0
  301. package/src/raster/setPMTileOpacity.js +7 -0
  302. package/src/raster/setPMTileZIndex.js +7 -0
  303. package/src/raster/setRasterOpacity.js +11 -0
  304. package/src/raster/setRasterTerrain.js +21 -0
  305. package/src/raster/setRasterZIndex.js +11 -0
  306. package/src/raster/updateAttachedTiles.js +10 -0
  307. package/src/raster/updateRasterTiles.js +59 -0
  308. package/src/rendering/collectFrameMeshes.js +31 -0
  309. package/src/rendering/collectMeshes.js +36 -0
  310. package/src/rendering/compareMeshes.js +10 -0
  311. package/src/rendering/compareRoofTiles.js +4 -0
  312. package/src/rendering/composeRoofAtlas.js +52 -0
  313. package/src/rendering/createMesh.js +33 -0
  314. package/src/rendering/createProgram.js +92 -0
  315. package/src/rendering/destroyAfterSubmission.js +8 -0
  316. package/src/rendering/destroyTexture.js +6 -0
  317. package/src/rendering/disposeMesh.js +14 -0
  318. package/src/rendering/drawGeometry.js +129 -0
  319. package/src/rendering/drawSceneMeshes.js +51 -0
  320. package/src/rendering/ensureRoofBlit.js +40 -0
  321. package/src/rendering/prepareFrameMeshes.js +42 -0
  322. package/src/rendering/prepareFrameUniforms.js +49 -0
  323. package/src/rendering/rebuildRoofAtlas.js +67 -0
  324. package/src/rendering/render.js +57 -0
  325. package/src/rendering/reportCompilation.js +17 -0
  326. package/src/rendering/resizeRenderer.js +19 -0
  327. package/src/rendering/sortMeshes.js +6 -0
  328. package/src/rendering/synchronizeZoomView.js +34 -0
  329. package/src/rendering/textureBinding.js +7 -0
  330. package/src/rendering/updateMapCamera.js +32 -0
  331. package/src/rendering/updateRoofRaster.js +32 -0
  332. package/src/scene/attach.js +161 -0
  333. package/src/scene/attachLayer.js +10 -0
  334. package/src/scene/cancelUpdate.js +10 -0
  335. package/src/scene/emptyEvents.js +3 -0
  336. package/src/scene/emptyNode.js +11 -0
  337. package/src/scene/endZoom.js +16 -0
  338. package/src/scene/failAttachment.js +9 -0
  339. package/src/scene/get3DEvents.js +13 -0
  340. package/src/scene/init3D.js +30 -0
  341. package/src/scene/initializeLayer.js +16 -0
  342. package/src/scene/initializerFor.js +14 -0
  343. package/src/scene/layerInitialize.js +38 -0
  344. package/src/scene/layerLayerAdd.js +21 -0
  345. package/src/scene/onAdd3DLayer.js +35 -0
  346. package/src/scene/onMapChange.js +16 -0
  347. package/src/scene/onRemove3DLayer.js +69 -0
  348. package/src/scene/onZoomAnim.js +16 -0
  349. package/src/scene/placeEntry.js +11 -0
  350. package/src/scene/placeUnderEntry.js +8 -0
  351. package/src/scene/ready3D.js +25 -0
  352. package/src/scene/releaseRenderer.js +14 -0
  353. package/src/scene/removeEntry.js +6 -0
  354. package/src/scene/renderPendingMapChange.js +11 -0
  355. package/src/scene/renderPendingUpdates.js +19 -0
  356. package/src/scene/renderPendingZoomAnimation.js +7 -0
  357. package/src/scene/rendererDeviceError.js +10 -0
  358. package/src/scene/rendererDeviceLost.js +11 -0
  359. package/src/scene/replaceEntry.js +7 -0
  360. package/src/scene/reportError.js +3 -0
  361. package/src/scene/requestAdapter.js +12 -0
  362. package/src/scene/requestDevice.js +9 -0
  363. package/src/scene/resolveNextInitialization.js +12 -0
  364. package/src/scene/restoreObject.js +71 -0
  365. package/src/scene/runPlacements.js +7 -0
  366. package/src/scene/showWebGPUWarning.js +16 -0
  367. package/src/scene/traverse.js +7 -0
  368. package/src/scene/underEntry.js +17 -0
  369. package/src/scene/update.js +19 -0
  370. package/src/scene/updateCamera.js +34 -0
  371. package/src/scene/updateWorldMatrix.js +48 -0
  372. package/src/shaders/materialShaders.js +246 -0
  373. package/src/shadows/bindSunlight.js +12 -0
  374. package/src/shadows/drawShadowMeshes.js +48 -0
  375. package/src/shadows/ensureShadowPipeline.js +53 -0
  376. package/src/shadows/renderSunlight.js +46 -0
  377. package/src/shadows/resizeSunlight.js +15 -0
  378. package/src/shadows/shadowBounds.js +32 -0
  379. package/src/shadows/shadowCacheMatches.js +23 -0
  380. package/src/shadows/shadowMatrix.js +39 -0
  381. package/src/sources/addGeneratedTriangle.js +6 -0
  382. package/src/sources/addTriangle.js +17 -0
  383. package/src/sources/attachAreaMesh.js +58 -0
  384. package/src/sources/buildArea.js +42 -0
  385. package/src/sources/buildAreaFeature.js +41 -0
  386. package/src/sources/buildAreaPoint.js +25 -0
  387. package/src/sources/buildAreaPolygon.js +29 -0
  388. package/src/sources/compareAreaDistance.js +4 -0
  389. package/src/sources/generateTreeGeometry.js +11 -0
  390. package/src/sources/groundOffset.js +3 -0
  391. package/src/sources/initializeGeoJSON.js +8 -0
  392. package/src/sources/instanceAreaGeometry.js +29 -0
  393. package/src/sources/projectRing.js +20 -0
  394. package/src/sources/projectedTree.js +13 -0
  395. package/src/sources/pump.js +54 -0
  396. package/src/sources/releaseArea.js +22 -0
  397. package/src/sources/setGeoJSONData.js +12 -0
  398. package/src/sources/setGeoJSONLayerData.js +5 -0
  399. package/src/sources/sourceAreaContext.js +9 -0
  400. package/src/sources/updateArea.js +45 -0
  401. package/src/sources/updateStatus.js +12 -0
  402. package/src/sunlight/addTimeLayer.js +3 -0
  403. package/src/sunlight/addTo.js +10 -0
  404. package/src/sunlight/atmosphere.js +28 -0
  405. package/src/sunlight/initSunlight.js +14 -0
  406. package/src/sunlight/initialize.js +11 -0
  407. package/src/sunlight/mix.js +6 -0
  408. package/src/sunlight/onAdd.js +5 -0
  409. package/src/sunlight/onAddSun.js +66 -0
  410. package/src/sunlight/remove.js +7 -0
  411. package/src/sunlight/removeSun.js +15 -0
  412. package/src/sunlight/removeTimeLayer.js +3 -0
  413. package/src/sunlight/render.js +7 -0
  414. package/src/sunlight/rgb.js +6 -0
  415. package/src/sunlight/styleTimeControl.js +7 -0
  416. package/src/sunlight/tickSun.js +5 -0
  417. package/src/sunlight/updateSky.js +20 -0
  418. package/src/sunlight/updateSun.js +34 -0
  419. package/src/sunlight/useLiveTime.js +6 -0
  420. package/src/sunlight/useSelectedTime.js +20 -0
  421. package/src/terrain/clearLayerTerrain.js +5 -0
  422. package/src/terrain/getElevation.js +10 -0
  423. package/src/terrain/initTerrain.js +20 -0
  424. package/src/terrain/loadReadyTerrain.js +5 -0
  425. package/src/terrain/loadTerrain.js +63 -0
  426. package/src/terrain/loadTerrainTiles.js +13 -0
  427. package/src/terrain/onTerrainAdd.js +21 -0
  428. package/src/terrain/onTerrainChange.js +14 -0
  429. package/src/terrain/onTerrainRemove.js +41 -0
  430. package/src/terrain/readBridges.js +4 -0
  431. package/src/terrain/sample.js +7 -0
  432. package/src/terrain/setLayerTerrain.js +5 -0
  433. package/src/terrain/terrainAtlas.js +23 -0
  434. package/src/terrain/terrainElevation.js +20 -0
  435. package/src/terrain/terrainGrid.js +24 -0
  436. package/src/traffic/addTraffic.js +7 -0
  437. package/src/traffic/along.js +14 -0
  438. package/src/traffic/clockMinutes.js +6 -0
  439. package/src/traffic/compareDepartures.js +5 -0
  440. package/src/traffic/createTrafficMesh.js +7 -0
  441. package/src/traffic/destroyTrafficGpu.js +5 -0
  442. package/src/traffic/disposeTrafficObject.js +13 -0
  443. package/src/traffic/drawTrafficRoute.js +6 -0
  444. package/src/traffic/failTraffic.js +6 -0
  445. package/src/traffic/failedTrafficLoad.js +5 -0
  446. package/src/traffic/fetchTrafficLanes.js +10 -0
  447. package/src/traffic/groundTraffic.js +15 -0
  448. package/src/traffic/initTraffic.js +54 -0
  449. package/src/traffic/loadTraffic.js +15 -0
  450. package/src/traffic/loadedTrafficLanes.js +16 -0
  451. package/src/traffic/locateTraffic.js +9 -0
  452. package/src/traffic/moveTraffic.js +15 -0
  453. package/src/traffic/placeTraffic.js +21 -0
  454. package/src/traffic/prepareTraffic.js +25 -0
  455. package/src/traffic/readyTraffic.js +6 -0
  456. package/src/traffic/rebaseTraffic.js +58 -0
  457. package/src/traffic/rebuildTrafficMesh.js +28 -0
  458. package/src/traffic/removeTraffic.js +17 -0
  459. package/src/traffic/routeColor.js +6 -0
  460. package/src/traffic/routeGeometry.js +31 -0
  461. package/src/traffic/scheduledTrips.js +40 -0
  462. package/src/traffic/startTraffic.js +8 -0
  463. package/src/traffic/tickTraffic.js +57 -0
  464. package/src/traffic/toLanes.js +16 -0
  465. package/src/traffic/tooltip.js +11 -0
  466. package/src/traffic/trafficBounds.js +17 -0
  467. package/src/traffic/trafficNow.js +4 -0
  468. package/src/traffic/trafficStorage.js +5 -0
  469. package/src/traffic/tripsAt.js +27 -0
  470. package/src/traffic/updateTraffic.js +8 -0
  471. package/src/traffic/updateTrafficTerrain.js +12 -0
  472. package/src/traffic/vehicleOffsets.js +11 -0
  473. package/src/triangulation/area.js +9 -0
  474. package/src/triangulation/clean.js +18 -0
  475. package/src/triangulation/containsVertex.js +11 -0
  476. package/src/triangulation/cross.js +3 -0
  477. package/src/triangulation/crossesBoundary.js +8 -0
  478. package/src/triangulation/crossesRing.js +9 -0
  479. package/src/triangulation/equal.js +3 -0
  480. package/src/triangulation/inside.js +10 -0
  481. package/src/triangulation/insideHole.js +7 -0
  482. package/src/triangulation/intersects.js +11 -0
  483. package/src/triangulation/isClockWise.js +13 -0
  484. package/src/triangulation/minimumX.js +6 -0
  485. package/src/triangulation/on.js +4 -0
  486. package/src/triangulation/sortHoles.js +26 -0
  487. package/src/triangulation/triangulate.js +86 -0
  488. package/src/utils/channel.js +2 -2
  489. package/src/utils/compareDistance.js +3 -0
  490. package/src/utils/noOperation.js +1 -0
  491. package/src/utils/toSRGB.js +3 -1
  492. package/src/utils/wrap.js +3 -1
  493. package/src/vehicles/bicycleModel.js +23 -0
  494. package/src/vehicles/boatBenches.js +8 -0
  495. package/src/vehicles/boatModel.js +27 -0
  496. package/src/vehicles/busModel.js +6 -0
  497. package/src/vehicles/carModel.js +22 -0
  498. package/src/vehicles/carriage.js +19 -0
  499. package/src/vehicles/metroModel.js +9 -0
  500. package/src/vehicles/mirror.js +8 -0
  501. package/src/vehicles/pedestrianModel.js +17 -0
  502. package/src/vehicles/tramModel.js +9 -0
  503. package/src/walk/blocked.js +6 -0
  504. package/src/walk/createWalk.js +60 -0
  505. package/src/walk/initWalk.js +18 -0
  506. package/src/walk/initialize.js +6 -0
  507. package/src/walk/local.js +10 -0
  508. package/src/walk/onAdd.js +4 -0
  509. package/src/walk/onBlur.js +3 -0
  510. package/src/walk/onKey.js +12 -0
  511. package/src/walk/onPointer.js +13 -0
  512. package/src/walk/onRemove.js +4 -0
  513. package/src/walk/onTerrain.js +5 -0
  514. package/src/walk/place.js +18 -0
  515. package/src/walk/start.js +37 -0
  516. package/src/walk/step.js +53 -0
  517. package/src/walk/stop.js +27 -0
  518. package/src/walk/toggle.js +6 -0
  519. package/dist/utils/CELL.js +0 -2
  520. package/dist/utils/CELL.js.map +0 -7
  521. package/dist/utils/addBridges.js +0 -2
  522. package/dist/utils/addBridges.js.map +0 -7
  523. package/dist/utils/addRasterTile.js +0 -2
  524. package/dist/utils/addRasterTile.js.map +0 -7
  525. package/dist/utils/along.js +0 -2
  526. package/dist/utils/along.js.map +0 -7
  527. package/dist/utils/atmosphere.js +0 -2
  528. package/dist/utils/atmosphere.js.map +0 -7
  529. package/dist/utils/attach.js +0 -2
  530. package/dist/utils/attach.js.map +0 -7
  531. package/dist/utils/bindSunlight.js +0 -2
  532. package/dist/utils/bindSunlight.js.map +0 -7
  533. package/dist/utils/box.js +0 -2
  534. package/dist/utils/box.js.map +0 -7
  535. package/dist/utils/bridgeElevation.js +0 -2
  536. package/dist/utils/bridgeElevation.js.map +0 -7
  537. package/dist/utils/build.js +0 -2
  538. package/dist/utils/build.js.map +0 -7
  539. package/dist/utils/cameraControls.js +0 -2
  540. package/dist/utils/cameraControls.js.map +0 -7
  541. package/dist/utils/channel.js +0 -2
  542. package/dist/utils/channel.js.map +0 -7
  543. package/dist/utils/collider.js +0 -2
  544. package/dist/utils/collider.js.map +0 -7
  545. package/dist/utils/colliders.js +0 -2
  546. package/dist/utils/colliders.js.map +0 -7
  547. package/dist/utils/computeBounds.js +0 -2
  548. package/dist/utils/computeBounds.js.map +0 -7
  549. package/dist/utils/conformModelToTerrain.js +0 -2
  550. package/dist/utils/conformModelToTerrain.js.map +0 -7
  551. package/dist/utils/createMesh.js +0 -2
  552. package/dist/utils/createMesh.js.map +0 -7
  553. package/dist/utils/createProgram.js +0 -3
  554. package/dist/utils/createProgram.js.map +0 -7
  555. package/dist/utils/decodeDirectory.js +0 -2
  556. package/dist/utils/decodeDirectory.js.map +0 -7
  557. package/dist/utils/decodeHeader.js +0 -2
  558. package/dist/utils/decodeHeader.js.map +0 -7
  559. package/dist/utils/decodeModel.js +0 -2
  560. package/dist/utils/decodeModel.js.map +0 -7
  561. package/dist/utils/decompress.js +0 -2
  562. package/dist/utils/decompress.js.map +0 -7
  563. package/dist/utils/destroyTexture.js +0 -2
  564. package/dist/utils/destroyTexture.js.map +0 -7
  565. package/dist/utils/disposeMesh.js +0 -2
  566. package/dist/utils/disposeMesh.js.map +0 -7
  567. package/dist/utils/drawGeometry.js +0 -2
  568. package/dist/utils/drawGeometry.js.map +0 -7
  569. package/dist/utils/elevationWGSL.js +0 -24
  570. package/dist/utils/elevationWGSL.js.map +0 -7
  571. package/dist/utils/emptyNode.js +0 -2
  572. package/dist/utils/emptyNode.js.map +0 -7
  573. package/dist/utils/endZoom.js +0 -2
  574. package/dist/utils/endZoom.js.map +0 -7
  575. package/dist/utils/findFeature.js +0 -2
  576. package/dist/utils/findFeature.js.map +0 -7
  577. package/dist/utils/geometry.js +0 -1
  578. package/dist/utils/geometry.js.map +0 -7
  579. package/dist/utils/getElevation.js +0 -2
  580. package/dist/utils/getElevation.js.map +0 -7
  581. package/dist/utils/getHeader.js +0 -2
  582. package/dist/utils/getHeader.js.map +0 -7
  583. package/dist/utils/getZxy.js +0 -2
  584. package/dist/utils/getZxy.js.map +0 -7
  585. package/dist/utils/glass.js +0 -2
  586. package/dist/utils/glass.js.map +0 -7
  587. package/dist/utils/headlight.js +0 -2
  588. package/dist/utils/headlight.js.map +0 -7
  589. package/dist/utils/hit.js +0 -2
  590. package/dist/utils/hit.js.map +0 -7
  591. package/dist/utils/horizontalPosition.js +0 -2
  592. package/dist/utils/horizontalPosition.js.map +0 -7
  593. package/dist/utils/horizontalRay.js +0 -2
  594. package/dist/utils/horizontalRay.js.map +0 -7
  595. package/dist/utils/hull.js +0 -2
  596. package/dist/utils/hull.js.map +0 -7
  597. package/dist/utils/initSunlight.js +0 -2
  598. package/dist/utils/initSunlight.js.map +0 -7
  599. package/dist/utils/initTerrain.js +0 -2
  600. package/dist/utils/initTerrain.js.map +0 -7
  601. package/dist/utils/initTraffic.js +0 -40
  602. package/dist/utils/initTraffic.js.map +0 -7
  603. package/dist/utils/initWalk.js +0 -2
  604. package/dist/utils/initWalk.js.map +0 -7
  605. package/dist/utils/intersectMeshes.js +0 -2
  606. package/dist/utils/intersectMeshes.js.map +0 -7
  607. package/dist/utils/isClockWise.js +0 -2
  608. package/dist/utils/isClockWise.js.map +0 -7
  609. package/dist/utils/lampPostGeometry.js +0 -2
  610. package/dist/utils/lampPostGeometry.js.map +0 -7
  611. package/dist/utils/lightGeometry.js +0 -2
  612. package/dist/utils/lightGeometry.js.map +0 -7
  613. package/dist/utils/lightGrid.js +0 -2
  614. package/dist/utils/lightGrid.js.map +0 -7
  615. package/dist/utils/limbs.js +0 -2
  616. package/dist/utils/limbs.js.map +0 -7
  617. package/dist/utils/loadModel.js +0 -2
  618. package/dist/utils/loadModel.js.map +0 -7
  619. package/dist/utils/loadSource.js +0 -2
  620. package/dist/utils/loadSource.js.map +0 -7
  621. package/dist/utils/loadTerrain.js +0 -2
  622. package/dist/utils/loadTerrain.js.map +0 -7
  623. package/dist/utils/mapCamera.js +0 -2
  624. package/dist/utils/mapCamera.js.map +0 -7
  625. package/dist/utils/materialShaders.js +0 -211
  626. package/dist/utils/materialShaders.js.map +0 -7
  627. package/dist/utils/mirror.js +0 -2
  628. package/dist/utils/mirror.js.map +0 -7
  629. package/dist/utils/moonPosition.js +0 -2
  630. package/dist/utils/moonPosition.js.map +0 -7
  631. package/dist/utils/moves.js +0 -2
  632. package/dist/utils/moves.js.map +0 -7
  633. package/dist/utils/nativeEvents.js +0 -2
  634. package/dist/utils/nativeEvents.js.map +0 -7
  635. package/dist/utils/nativeGeometry.js +0 -2
  636. package/dist/utils/nativeGeometry.js.map +0 -7
  637. package/dist/utils/nativeLayer.js +0 -2
  638. package/dist/utils/nativeLayer.js.map +0 -7
  639. package/dist/utils/nodeMatrix.js +0 -2
  640. package/dist/utils/nodeMatrix.js.map +0 -7
  641. package/dist/utils/onAdd3DLayer.js +0 -2
  642. package/dist/utils/onAdd3DLayer.js.map +0 -7
  643. package/dist/utils/onAddSun.js +0 -2
  644. package/dist/utils/onAddSun.js.map +0 -7
  645. package/dist/utils/onClick.js +0 -2
  646. package/dist/utils/onClick.js.map +0 -7
  647. package/dist/utils/onMapChange.js +0 -2
  648. package/dist/utils/onMapChange.js.map +0 -7
  649. package/dist/utils/onPMTileAdd.js +0 -2
  650. package/dist/utils/onPMTileAdd.js.map +0 -7
  651. package/dist/utils/onPMTileRemove.js +0 -2
  652. package/dist/utils/onPMTileRemove.js.map +0 -7
  653. package/dist/utils/onPointerLeave.js +0 -2
  654. package/dist/utils/onPointerLeave.js.map +0 -7
  655. package/dist/utils/onPointerMove.js +0 -2
  656. package/dist/utils/onPointerMove.js.map +0 -7
  657. package/dist/utils/onRemove3DLayer.js +0 -2
  658. package/dist/utils/onRemove3DLayer.js.map +0 -7
  659. package/dist/utils/onRemoveSun.js +0 -2
  660. package/dist/utils/onRemoveSun.js.map +0 -7
  661. package/dist/utils/onTerrainAdd.js +0 -2
  662. package/dist/utils/onTerrainAdd.js.map +0 -7
  663. package/dist/utils/onTerrainChange.js +0 -2
  664. package/dist/utils/onTerrainChange.js.map +0 -7
  665. package/dist/utils/onTerrainRemove.js +0 -2
  666. package/dist/utils/onTerrainRemove.js.map +0 -7
  667. package/dist/utils/onZoomAnim.js +0 -2
  668. package/dist/utils/onZoomAnim.js.map +0 -7
  669. package/dist/utils/paints.js +0 -2
  670. package/dist/utils/paints.js.map +0 -7
  671. package/dist/utils/parseColor.js +0 -2
  672. package/dist/utils/parseColor.js.map +0 -7
  673. package/dist/utils/parts.js +0 -2
  674. package/dist/utils/parts.js.map +0 -7
  675. package/dist/utils/projectCelestialBody.js +0 -2
  676. package/dist/utils/projectCelestialBody.js.map +0 -7
  677. package/dist/utils/pump.js +0 -2
  678. package/dist/utils/pump.js.map +0 -7
  679. package/dist/utils/rasterTiles.js +0 -2
  680. package/dist/utils/rasterTiles.js.map +0 -7
  681. package/dist/utils/raycast.js +0 -2
  682. package/dist/utils/raycast.js.map +0 -7
  683. package/dist/utils/read.js +0 -2
  684. package/dist/utils/read.js.map +0 -7
  685. package/dist/utils/readAccessor.js +0 -2
  686. package/dist/utils/readAccessor.js.map +0 -7
  687. package/dist/utils/releaseArea.js +0 -2
  688. package/dist/utils/releaseArea.js.map +0 -7
  689. package/dist/utils/removeRasterTile.js +0 -2
  690. package/dist/utils/removeRasterTile.js.map +0 -7
  691. package/dist/utils/render.js +0 -15
  692. package/dist/utils/render.js.map +0 -7
  693. package/dist/utils/renderSunlight.js +0 -13
  694. package/dist/utils/renderSunlight.js.map +0 -7
  695. package/dist/utils/renderers.js +0 -2
  696. package/dist/utils/renderers.js.map +0 -7
  697. package/dist/utils/resizeSunlight.js +0 -2
  698. package/dist/utils/resizeSunlight.js.map +0 -7
  699. package/dist/utils/roofCoverage.js +0 -2
  700. package/dist/utils/roofCoverage.js.map +0 -7
  701. package/dist/utils/routeGeometry.js +0 -2
  702. package/dist/utils/routeGeometry.js.map +0 -7
  703. package/dist/utils/scheduledTrips.js +0 -2
  704. package/dist/utils/scheduledTrips.js.map +0 -7
  705. package/dist/utils/setGeoJSONData.js +0 -2
  706. package/dist/utils/setGeoJSONData.js.map +0 -7
  707. package/dist/utils/setHighlight.js +0 -2
  708. package/dist/utils/setHighlight.js.map +0 -7
  709. package/dist/utils/setPMTileOpacity.js +0 -2
  710. package/dist/utils/setPMTileOpacity.js.map +0 -7
  711. package/dist/utils/setPMTileZIndex.js +0 -2
  712. package/dist/utils/setPMTileZIndex.js.map +0 -7
  713. package/dist/utils/setParent.js +0 -2
  714. package/dist/utils/setParent.js.map +0 -7
  715. package/dist/utils/setTerrainHeight.js +0 -2
  716. package/dist/utils/setTerrainHeight.js.map +0 -7
  717. package/dist/utils/setVertexColor.js +0 -2
  718. package/dist/utils/setVertexColor.js.map +0 -7
  719. package/dist/utils/showFeature.js +0 -2
  720. package/dist/utils/showFeature.js.map +0 -7
  721. package/dist/utils/sizes.js +0 -2
  722. package/dist/utils/sizes.js.map +0 -7
  723. package/dist/utils/skin.js +0 -2
  724. package/dist/utils/skin.js.map +0 -7
  725. package/dist/utils/solarPosition.js +0 -2
  726. package/dist/utils/solarPosition.js.map +0 -7
  727. package/dist/utils/sortMeshes.js +0 -2
  728. package/dist/utils/sortMeshes.js.map +0 -7
  729. package/dist/utils/speed.js +0 -2
  730. package/dist/utils/speed.js.map +0 -7
  731. package/dist/utils/startZoom.js +0 -2
  732. package/dist/utils/startZoom.js.map +0 -7
  733. package/dist/utils/taillight.js +0 -2
  734. package/dist/utils/taillight.js.map +0 -7
  735. package/dist/utils/terrainAtlas.js +0 -2
  736. package/dist/utils/terrainAtlas.js.map +0 -7
  737. package/dist/utils/terrainElevation.js +0 -2
  738. package/dist/utils/terrainElevation.js.map +0 -7
  739. package/dist/utils/terrainGrid.js +0 -2
  740. package/dist/utils/terrainGrid.js.map +0 -7
  741. package/dist/utils/textureSampler.js +0 -2
  742. package/dist/utils/textureSampler.js.map +0 -7
  743. package/dist/utils/tileId.js +0 -2
  744. package/dist/utils/tileId.js.map +0 -7
  745. package/dist/utils/toLanes.js +0 -2
  746. package/dist/utils/toLanes.js.map +0 -7
  747. package/dist/utils/toSRGB.js +0 -2
  748. package/dist/utils/toSRGB.js.map +0 -7
  749. package/dist/utils/tooltip.js +0 -3
  750. package/dist/utils/tooltip.js.map +0 -7
  751. package/dist/utils/traffic.js +0 -2
  752. package/dist/utils/traffic.js.map +0 -7
  753. package/dist/utils/traverse.js +0 -2
  754. package/dist/utils/traverse.js.map +0 -7
  755. package/dist/utils/treeGeometry.js +0 -2
  756. package/dist/utils/treeGeometry.js.map +0 -7
  757. package/dist/utils/triangulate.js +0 -2
  758. package/dist/utils/triangulate.js.map +0 -7
  759. package/dist/utils/tripsAt.js +0 -2
  760. package/dist/utils/tripsAt.js.map +0 -7
  761. package/dist/utils/types.js +0 -2
  762. package/dist/utils/types.js.map +0 -7
  763. package/dist/utils/underEntry.js +0 -2
  764. package/dist/utils/underEntry.js.map +0 -7
  765. package/dist/utils/update.js +0 -2
  766. package/dist/utils/update.js.map +0 -7
  767. package/dist/utils/updateArea.js +0 -2
  768. package/dist/utils/updateArea.js.map +0 -7
  769. package/dist/utils/updateCamera.js +0 -2
  770. package/dist/utils/updateCamera.js.map +0 -7
  771. package/dist/utils/updatePointLights.js +0 -2
  772. package/dist/utils/updatePointLights.js.map +0 -7
  773. package/dist/utils/updateWorldMatrix.js +0 -2
  774. package/dist/utils/updateWorldMatrix.js.map +0 -7
  775. package/dist/utils/vehicleOffsets.js +0 -2
  776. package/dist/utils/vehicleOffsets.js.map +0 -7
  777. package/dist/utils/vehicles.js +0 -2
  778. package/dist/utils/vehicles.js.map +0 -7
  779. package/dist/utils/vertexNormals.js +0 -2
  780. package/dist/utils/vertexNormals.js.map +0 -7
  781. package/dist/utils/walk.js +0 -2
  782. package/dist/utils/walk.js.map +0 -7
  783. package/dist/utils/white.js +0 -2
  784. package/dist/utils/white.js.map +0 -7
  785. package/dist/utils/worldLights.js +0 -2
  786. package/dist/utils/worldLights.js.map +0 -7
  787. package/dist/utils/wrap.js +0 -2
  788. package/dist/utils/wrap.js.map +0 -7
  789. package/src/utils/addBridges.js +0 -66
  790. package/src/utils/addRasterTile.js +0 -112
  791. package/src/utils/along.js +0 -9
  792. package/src/utils/atmosphere.js +0 -20
  793. package/src/utils/attach.js +0 -255
  794. package/src/utils/bindSunlight.js +0 -12
  795. package/src/utils/box.js +0 -1
  796. package/src/utils/bridgeElevation.js +0 -18
  797. package/src/utils/build.js +0 -20
  798. package/src/utils/cameraControls.js +0 -287
  799. package/src/utils/collider.js +0 -62
  800. package/src/utils/computeBounds.js +0 -17
  801. package/src/utils/conformModelToTerrain.js +0 -69
  802. package/src/utils/createMesh.js +0 -31
  803. package/src/utils/createProgram.js +0 -92
  804. package/src/utils/decodeDirectory.js +0 -40
  805. package/src/utils/decodeHeader.js +0 -15
  806. package/src/utils/decodeModel.js +0 -43
  807. package/src/utils/destroyTexture.js +0 -7
  808. package/src/utils/disposeMesh.js +0 -13
  809. package/src/utils/drawGeometry.js +0 -122
  810. package/src/utils/elevationWGSL.js +0 -27
  811. package/src/utils/emptyNode.js +0 -9
  812. package/src/utils/endZoom.js +0 -15
  813. package/src/utils/findFeature.js +0 -49
  814. package/src/utils/geometry.js +0 -2
  815. package/src/utils/getElevation.js +0 -10
  816. package/src/utils/getZxy.js +0 -76
  817. package/src/utils/glass.js +0 -1
  818. package/src/utils/hit.js +0 -41
  819. package/src/utils/initSunlight.js +0 -9
  820. package/src/utils/initTerrain.js +0 -19
  821. package/src/utils/initTraffic.js +0 -93
  822. package/src/utils/initWalk.js +0 -72
  823. package/src/utils/intersectMeshes.js +0 -121
  824. package/src/utils/isClockWise.js +0 -12
  825. package/src/utils/lampPostGeometry.js +0 -26
  826. package/src/utils/lightGeometry.js +0 -22
  827. package/src/utils/lightGrid.js +0 -50
  828. package/src/utils/loadModel.js +0 -217
  829. package/src/utils/loadTerrain.js +0 -65
  830. package/src/utils/mapCamera.js +0 -432
  831. package/src/utils/materialShaders.js +0 -243
  832. package/src/utils/mirror.js +0 -6
  833. package/src/utils/nativeEvents.js +0 -77
  834. package/src/utils/nativeGeometry.js +0 -131
  835. package/src/utils/nativeLayer.js +0 -317
  836. package/src/utils/onAdd3DLayer.js +0 -31
  837. package/src/utils/onAddSun.js +0 -147
  838. package/src/utils/onMapChange.js +0 -16
  839. package/src/utils/onPMTileAdd.js +0 -15
  840. package/src/utils/onPMTileRemove.js +0 -8
  841. package/src/utils/onRemove3DLayer.js +0 -78
  842. package/src/utils/onRemoveSun.js +0 -3
  843. package/src/utils/onTerrainAdd.js +0 -18
  844. package/src/utils/onTerrainChange.js +0 -13
  845. package/src/utils/onTerrainRemove.js +0 -40
  846. package/src/utils/onZoomAnim.js +0 -14
  847. package/src/utils/parts.js +0 -16
  848. package/src/utils/pump.js +0 -226
  849. package/src/utils/rasterTiles.js +0 -285
  850. package/src/utils/raycast.js +0 -60
  851. package/src/utils/readAccessor.js +0 -68
  852. package/src/utils/releaseArea.js +0 -34
  853. package/src/utils/removeRasterTile.js +0 -13
  854. package/src/utils/render.js +0 -406
  855. package/src/utils/renderSunlight.js +0 -170
  856. package/src/utils/resizeSunlight.js +0 -15
  857. package/src/utils/roofCoverage.js +0 -47
  858. package/src/utils/routeGeometry.js +0 -22
  859. package/src/utils/scheduledTrips.js +0 -29
  860. package/src/utils/setGeoJSONData.js +0 -11
  861. package/src/utils/setHighlight.js +0 -13
  862. package/src/utils/setPMTileOpacity.js +0 -7
  863. package/src/utils/setPMTileZIndex.js +0 -7
  864. package/src/utils/setVertexColor.js +0 -14
  865. package/src/utils/showFeature.js +0 -27
  866. package/src/utils/skin.js +0 -2
  867. package/src/utils/sortMeshes.js +0 -12
  868. package/src/utils/terrainAtlas.js +0 -21
  869. package/src/utils/terrainElevation.js +0 -20
  870. package/src/utils/terrainGrid.js +0 -23
  871. package/src/utils/tileId.js +0 -18
  872. package/src/utils/toLanes.js +0 -7
  873. package/src/utils/tooltip.js +0 -6
  874. package/src/utils/traffic.js +0 -315
  875. package/src/utils/traverse.js +0 -6
  876. package/src/utils/treeGeometry.js +0 -45
  877. package/src/utils/triangulate.js +0 -100
  878. package/src/utils/tripsAt.js +0 -16
  879. package/src/utils/underEntry.js +0 -17
  880. package/src/utils/update.js +0 -18
  881. package/src/utils/updateArea.js +0 -40
  882. package/src/utils/updateCamera.js +0 -32
  883. package/src/utils/updatePointLights.js +0 -38
  884. package/src/utils/updateWorldMatrix.js +0 -47
  885. package/src/utils/vehicleOffsets.js +0 -8
  886. package/src/utils/vehicles.js +0 -65
  887. package/src/utils/vertexNormals.js +0 -30
  888. package/src/utils/walk.js +0 -187
  889. package/src/utils/worldLights.js +0 -25
  890. /package/src/{utils → archives}/decompress.js +0 -0
  891. /package/src/{utils → archives}/getHeader.js +0 -0
  892. /package/src/{utils → archives}/loadSource.js +0 -0
  893. /package/src/{utils → archives}/read.js +0 -0
  894. /package/src/{utils → collision}/horizontalRay.js +0 -0
  895. /package/src/{utils → constants}/CELL.js +0 -0
  896. /package/src/{utils/sizes.js → constants/accessorSizes.js} +0 -0
  897. /package/src/{utils/types.js → constants/accessorTypes.js} +0 -0
  898. /package/src/{utils → constants}/colliders.js +0 -0
  899. /package/src/{utils → constants}/headlight.js +0 -0
  900. /package/src/{utils → constants}/hull.js +0 -0
  901. /package/src/{utils → constants}/limbs.js +0 -0
  902. /package/src/{utils → constants}/moves.js +0 -0
  903. /package/src/{utils → constants}/paints.js +0 -0
  904. /package/src/{utils → constants}/renderers.js +0 -0
  905. /package/src/{utils → constants}/speed.js +0 -0
  906. /package/src/{utils → constants}/taillight.js +0 -0
  907. /package/src/{utils → constants}/white.js +0 -0
  908. /package/src/{utils → models}/nodeMatrix.js +0 -0
  909. /package/src/{utils → models}/textureSampler.js +0 -0
  910. /package/src/{utils → picking}/onClick.js +0 -0
  911. /package/src/{utils → picking}/onPointerLeave.js +0 -0
  912. /package/src/{utils → picking}/onPointerMove.js +0 -0
  913. /package/src/{utils → scene}/setParent.js +0 -0
  914. /package/src/{utils → scene}/startZoom.js +0 -0
  915. /package/src/{utils → sunlight}/horizontalPosition.js +0 -0
  916. /package/src/{utils → sunlight}/moonPosition.js +0 -0
  917. /package/src/{utils → sunlight}/projectCelestialBody.js +0 -0
  918. /package/src/{utils → sunlight}/solarPosition.js +0 -0
  919. /package/src/{utils → terrain}/setTerrainHeight.js +0 -0
@@ -0,0 +1,32 @@
1
+ /** Area-weighted vertex normals, for indexed or non-indexed triangles. */
2
+
3
+ export function vertexNormals(p, indices) {
4
+ // Accumulate area-weighted face normals for shared vertices, then normalize.
5
+ const normals = new Float32Array(p.length);
6
+ let i, a, b, c, u, v, j, n, index, length;
7
+ for (i = 0; i < (indices?.length || p.length / 3); i += 3) {
8
+ a = indices ? indices[i] : i, b = indices ? indices[i + 1] : i + 1, c = indices ? indices[i + 2] : i + 2;
9
+ u = [], v = [];
10
+ for (j = 0; j < 3; j++) {
11
+ u.push(p[b * 3 + j] - p[a * 3 + j]);
12
+ v.push(p[c * 3 + j] - p[a * 3 + j]);
13
+ }
14
+ n = [
15
+ u[1] * v[2] - u[2] * v[1],
16
+ u[2] * v[0] - u[0] * v[2],
17
+ u[0] * v[1] - u[1] * v[0]
18
+ ];
19
+ for (index of [a, b, c]) {
20
+ for (j = 0; j < 3; j++) {
21
+ normals[index * 3 + j] += n[j];
22
+ }
23
+ }
24
+ }
25
+ for (i = 0; i < normals.length; i += 3) {
26
+ length = Math.hypot(...normals.subarray(i, i + 3)) || 1;
27
+ for (j = 0; j < 3; j++) {
28
+ normals[i + j] /= length;
29
+ }
30
+ }
31
+ return normals;
32
+ }
@@ -0,0 +1,9 @@
1
+ import { polygon } from './polygon.js';
2
+
3
+ export function visit(context, coordinates, closed) {
4
+ if (!coordinates.length) return;
5
+ let child;
6
+ if (coordinates[0] instanceof L.LatLng) polygon(context, [coordinates], closed);
7
+ else if (closed && coordinates[0][0] instanceof L.LatLng) polygon(context, coordinates, closed);
8
+ else for (child of coordinates) visit(context, child, closed);
9
+ }
package/src/index.js CHANGED
@@ -1,19 +1,36 @@
1
- import './utils/mapCamera.js';
1
+ import './camera/mapCamera.js';
2
+ import { init3D } from './scene/init3D.js';
3
+ import { initNativeGPU } from './core/initNativeGPU.js';
4
+ import { initRaster } from './raster/initRaster.js';
5
+ import { setGeoJSONData } from './sources/setGeoJSONData.js';
6
+ import { initTerrain } from './terrain/initTerrain.js';
7
+ import './sunlight/initSunlight.js';
8
+ import { initTraffic } from './traffic/initTraffic.js';
9
+ import './walk/initWalk.js';
10
+ import { indexState } from './constants/indexState.js';
11
+ import { initializeNativeLayer } from './core/initializeNativeLayer.js';
12
+ import { layerLayerAdd } from './scene/layerLayerAdd.js';
13
+ import { layerInitialize } from './scene/layerInitialize.js';
2
14
 
3
15
  /**
4
16
  * `new L.Layer({ source: { type, url, ...settings }, pane, attribution })`: layers with a `source`
5
- * load their specialized utilities on first use. Native map layers also join the WebGPU scene.
17
+ * initialize their specialized behavior on first use. Native map layers also join the WebGPU scene.
6
18
  */
7
19
 
8
20
  /**
9
21
  * Router for `new L.Layer({ source: { type, url, ...settings }, pane, attribution })`.
10
- * It imports source utilities on demand and initializes the existing instance;
22
+ * It initializes the existing instance from the bundled source modules;
11
23
  * types receive flat options (`{ ...source, pane, attribution }`), so `layer.options.url` etc.
12
24
  *
13
25
  * Folder layout:
14
- * - Vector ('3d', 'geojson') and raster ('pmtiles') initialization lives here.
15
- * - utils/: lazy operations for rendering, archives, geometry and specialized layers:
16
- * terrain (Float32 DEM), sunlight (clock and lighting), traffic and walking.
26
+ * - scene/: source routing, lifecycle and graph; initializers live in their domain folders.
27
+ * - core/: Leaflet layer integration; camera/ and controls/: camera and interaction.
28
+ * - sources/ and picking/: source geometry and feature interaction.
29
+ * - rendering/, shaders/, shadows/ and lighting/: WebGPU drawing and illumination.
30
+ * - geometry/, triangulation/ and collision/: mesh operations and spatial queries.
31
+ * - models/, archives/ and raster/: glTF loading, archive access and raster tiles.
32
+ * - constants/ and state/: exported module-level const and let bindings.
33
+ * - terrain/, sunlight/, traffic/ and walk/: feature-specific operations.
17
34
  * Operations receive the layer explicitly, without subclasses or prototype replacement.
18
35
  * Dataset-specific code and data (routes, timetables, API loaders) belong to the application, e.g. misc/.
19
36
  *
@@ -21,19 +38,28 @@ import './utils/mapCamera.js';
21
38
  * 'pmtiles' and other sources use '3d'.
22
39
  */
23
40
 
24
- const layerProto = Object.defineProperties({}, Object.getOwnPropertyDescriptors(L.Layer.prototype));
41
+ indexState.layerProto = Object.defineProperties({}, Object.getOwnPropertyDescriptors(L.Layer.prototype));
25
42
 
26
- // One chain for every pending layer: they become real layers in creation order, whatever the import timing.
27
- let loading = Promise.resolve();
28
- let sceneModules, sceneLoading, rasterModules;
29
- let nativeLoading;
43
+ // One chain for every pending layer: they become real layers in creation order.
44
+ indexState.loading = Promise.resolve();
45
+
46
+ indexState.pendingInitializations = [];
47
+
48
+ indexState.closestMethods = new WeakMap();
49
+ indexState.boundsMethods = new WeakMap();
50
+ indexState.gridInitializers = new WeakMap();
51
+
52
+ indexState.pendingGridFades = new Map();
53
+ indexState.gridFadeFrame = null;
54
+
55
+ indexState.pendingRasterLoads = [];
30
56
 
31
57
  /**
32
58
  * The '3d' layer type: native WebGPU scene synchronized with the map camera.
33
59
  * Layers on one map share a canvas, scene and camera; each has its own root transform.
34
60
  *
35
61
  * @typedef {Object} Layer3DOptions Layer options; pane and attribution remain standard L.Layer options.
36
- * @property {string} [type] '3d', 'geojson', 'pmtiles', 'terrain', 'sunlight', 'traffic' or 'walk'.
62
+ * @property {string} [type] '3d', 'geojson', 'pmtiles', 'terrain' or 'traffic'.
37
63
  * @property {number[]} [center] Local origin [lat,lng]; defaults to the first map center.
38
64
  * @property {number} [terrainOffset=0] Vertical offset in metres when terrain is enabled.
39
65
  * @property {boolean} [terrainConform=false] Fit lower model geometry to local terrain elevation.
@@ -81,317 +107,9 @@ let nativeLoading;
81
107
  * @param {Layer3DOptions} [options] World origin comes from center or the first map centre.
82
108
  */
83
109
 
84
- L.Layer._renderers = new WeakMap();
85
- L.Layer._nextId = 0;
86
-
87
110
  L.Layer.include({
88
- _layerAdd(event) {
89
- const native = !this._3d && (
90
- this instanceof L.GridLayer ||
91
- this instanceof L.Polyline ||
92
- this instanceof L.CircleMarker ||
93
- this instanceof L.Marker && !(this.options.icon instanceof L.DivIcon) ||
94
- this instanceof L.ImageOverlay && !(this instanceof L.VideoOverlay) && !(this instanceof L.SVGOverlay)
95
- );
96
- if (native) {
97
- if (this instanceof L.GridLayer || this instanceof L.ImageOverlay) {
98
- this.options.crossOrigin ||= true;
99
- }
100
- if (this instanceof L.Marker) this.options.icon.options.crossOrigin ||= true;
101
- }
102
- layerProto._layerAdd.call(this, event);
103
- if (!native || !event.target.hasLayer(this)) return;
104
- this._initNativeGPU(event.target);
105
- },
106
- _initNativeGPU(map) {
107
- if (this._nativeGPU) return;
108
- if (!document.getElementById('leaflet-webgpu-targets')) {
109
- const style = document.createElement('style');
110
- style.id = 'leaflet-webgpu-targets';
111
- style.textContent = '.leaflet-webgpu-target{opacity:0!important}';
112
- document.head.append(style);
113
- }
114
- const state = this._nativeGPU = { source: this, map, hidden: new Set() };
115
- state.hide = () => {
116
- const htmlIcon = this instanceof L.Marker && this.options.icon instanceof L.DivIcon;
117
- const targets = [htmlIcon ? null : this._icon, htmlIcon ? null : this._shadow];
118
- for (const element of state.hidden) {
119
- if (targets.includes(element)) continue;
120
- element.classList.remove('leaflet-webgpu-target');
121
- state.hidden.delete(element);
122
- }
123
- for (const element of targets) {
124
- if (!element || state.hidden.has(element)) continue;
125
- element.classList.add('leaflet-webgpu-target');
126
- state.hidden.add(element);
127
- }
128
- };
129
- state.hide();
130
- this.once('remove', () => {
131
- if (this._nativeGPU === state) this._nativeGPU = null;
132
- state.dispose?.();
133
- for (const element of state.hidden) {
134
- element.classList.remove('leaflet-webgpu-target');
135
- }
136
- });
137
-
138
- nativeLoading ||= import('./utils/nativeLayer.js');
139
- this.ready = nativeLoading.then(({ nativeLayer }) => {
140
- if (this._nativeGPU !== state) return this;
141
- return nativeLayer(state);
142
- });
143
- this.ready.catch(error => this.fire('error', { error }));
144
- },
145
- _init3D(options = {}) {
146
- const layer = this;
147
- const ready = sceneLoading ||= Promise.all([
148
- import('./utils/onAdd3DLayer.js'),
149
- import('./utils/onRemove3DLayer.js'),
150
- import('./utils/updateArea.js'),
151
- import('./utils/onTerrainChange.js'),
152
- ]).then(([add, remove, update, terrain]) => sceneModules = { ...add, ...remove, ...update, ...terrain });
153
- layer._3d = true;
154
- L.Util.setOptions(layer, { ariaLabel: '3D scene', ...options });
155
- layer.onAdd = map => {
156
- if (sceneModules) return sceneModules.onAdd3DLayer(layer, map);
157
- ready.then(({ onAdd3DLayer }) => {
158
- if (layer._map === map) onAdd3DLayer(layer, map);
159
- }).catch(error => layer.fire('error', { error }));
160
- };
161
- layer.onRemove = map => {
162
- if (sceneModules) return sceneModules.onRemove3DLayer(layer, map);
163
- ready.then(({ onRemove3DLayer }) => onRemove3DLayer(layer, map))
164
- .catch(error => layer.fire('error', { error }));
165
- };
166
- layer.getEvents = () => {
167
- const events = {};
168
- if (layer.url) {
169
- events.moveend = events.zoomend = events.rotate = events.pitch = events.resize = () =>
170
- sceneModules ? sceneModules.updateArea(layer) : ready.then(({ updateArea }) => updateArea(layer));
171
- }
172
- if (layer._geojson || layer.url) {
173
- events.terrainchange = () => sceneModules
174
- ? sceneModules.onTerrainChange(layer)
175
- : ready.then(({ onTerrainChange }) => onTerrainChange(layer));
176
- }
177
- return events;
178
- };
179
- // ponytail: models are recognised by extension; extensionless model URLs need a .glb/.gltf suffix or query.
180
- const isModel = !layer._geojson && /\.(glb|gltf)(?:[?#]|$)/i.test(layer.options.url);
181
- layer.modelUrl = isModel ? layer.options.url : null;
182
- layer.url = layer.options.url && !isModel && !layer._geojson ? new URL(layer.options.url, document.baseURI).href : null;
183
- layer._directories = new Map();
184
- if (layer.options.center) {
185
- layer.location = new L.LatLng(layer.options.center[0], layer.options.center[1]);
186
- }
187
- /** @type {Map<string, SourceArea>} Keys are archive x/y, not screen tiles. */
188
- layer._areas = new Map();
189
- layer._inflight = 0;
190
- layer._added = Promise.withResolvers();
191
- queueMicrotask(async () => {
192
- try {
193
- await ready;
194
- layer.root = (await import('./utils/emptyNode.js')).emptyNode();
195
- layer.raycaster = { origin: [0, 0, 0], direction: [0, 0, 0] };
196
- if (layer.url || layer._geojson) {
197
- layer.group = layer.root;
198
- if (layer.url) layer.header = await (await import('./utils/getHeader.js')).getHeader(layer);
199
- }
200
- if (layer._map) {
201
- await (await import('./utils/attach.js')).attach(layer, layer._map);
202
- layer._added.resolve();
203
- }
204
- if (layer.modelUrl) await (await import('./utils/loadModel.js')).loadModel(layer);
205
- if (layer._shared) (await import('./utils/update.js')).update(layer);
206
- layer.fire('ready');
207
- } catch (error) {
208
- layer.fire('error', { error });
209
- }
210
- });
211
- },
212
- _initRaster(options) {
213
- const layer = this;
214
- const [{ read }, { getHeader }, { getZxy }, { onPMTileAdd }, { onPMTileRemove },
215
- { getRasterTileSize, updateRasterTiles }, { setPMTileOpacity }, { setPMTileZIndex }, { emptyNode }] = rasterModules;
216
- layer._read = (offset, length, signal) => read(layer, offset, length, signal);
217
- layer.getHeader = () => getHeader(layer);
218
- layer.getZxy = (z, x, y, signal) => getZxy(layer, z, x, y, signal);
219
- layer.getTileSize = () => getRasterTileSize();
220
- layer.isLoading = () => layer._loadingTiles > 0;
221
- layer.setOpacity = opacity => setPMTileOpacity(layer, opacity);
222
- layer.setZIndex = zIndex => setPMTileZIndex(layer, zIndex);
223
- layer.onAdd = map => onPMTileAdd(layer, map);
224
- layer.onRemove = map => onPMTileRemove(layer, map);
225
- const update = () => updateRasterTiles(layer);
226
- layer.getEvents = () => ({
227
- moveend: update,
228
- zoomend: update,
229
- rotate: update,
230
- pitch: update,
231
- resize: update,
232
- });
233
- options = { ariaLabel: 'PMTiles raster', maxZoom: 18, opacity: 1, zIndex: 0, ...options };
234
- L.Util.setOptions(layer, options);
235
- layer.root = emptyNode();
236
- layer._areas = new Map();
237
- layer._rasterTiles = new Map();
238
- layer._loadingTiles = 0;
239
- layer._added = Promise.withResolvers();
240
- layer.url = new URL(options.url, document.baseURI).href;
241
- layer._directories = new Map();
242
- layer.ready = Promise.resolve(layer.options.archive || layer).then(async archive => {
243
- const header = await archive.getHeader();
244
- layer.options.archive = archive;
245
- layer.header = header;
246
- if (layer.options.maxNativeZoom === undefined) {
247
- layer.options.maxNativeZoom = header.maxZoom;
248
- }
249
- layer.options.maxZoom = Math.max(layer.options.minZoom || 0, layer.options.maxZoom);
250
- layer.fire('ready');
251
- return layer;
252
- }).catch(error => {
253
- layer.fire('error', { error });
254
- throw error;
255
- });
256
- },
257
- initialize(options = {}) {
258
- if (Object.getPrototypeOf(this) !== L.Layer.prototype || !options.source) {
259
- if (layerProto.initialize) return layerProto.initialize.apply(this, arguments);
260
- L.Util.setOptions(this, options);
261
- return;
262
- }
263
- const {
264
- source: {
265
- type = options.source.data?.type === 'FeatureCollection'
266
- ? 'geojson'
267
- : /\.pmtiles(?:[?#]|$)/i.test(options.source.url) ? 'pmtiles' : '3d',
268
- ...source
269
- },
270
- ...core
271
- } = options;
272
- const settings = { ...source, ...core };
273
- L.Util.setOptions(this, core);
274
- this._type = type;
275
- if (type === '3d') {
276
- this._init3D(settings);
277
- return;
278
- }
279
- if (type === 'pmtiles' && rasterModules) {
280
- this._initRaster(settings);
281
- return;
282
- }
283
- this.onAdd = () => {};
284
- this.onRemove = () => {};
285
- // ponytail: type methods (setOpacity, add, ...) exist only once `ready` resolves.
286
- loading = loading.catch(() => {}).then(async () => {
287
- switch (type) {
288
- case 'geojson': {
289
- const { setGeoJSONData } = await import('./utils/setGeoJSONData.js');
290
- return (layer, options) => {
291
- layer._geojson = true;
292
- layer.setData = data => setGeoJSONData(layer, data);
293
- layer._init3D(options);
294
- };
295
- }
296
- case 'pmtiles': {
297
- rasterModules = await Promise.all([
298
- import('./utils/read.js'),
299
- import('./utils/getHeader.js'),
300
- import('./utils/getZxy.js'),
301
- import('./utils/onPMTileAdd.js'),
302
- import('./utils/onPMTileRemove.js'),
303
- import('./utils/rasterTiles.js'),
304
- import('./utils/setPMTileOpacity.js'),
305
- import('./utils/setPMTileZIndex.js'),
306
- import('./utils/emptyNode.js'),
307
- ]);
308
- return (layer, options) => layer._initRaster(options);
309
- }
310
- case 'terrain':
311
- return (await import('./utils/initTerrain.js')).initTerrain;
312
- case 'sunlight':
313
- return (await import('./utils/initSunlight.js')).initSunlight;
314
- case 'traffic':
315
- return (await import('./utils/initTraffic.js')).initTraffic;
316
- case 'walk':
317
- return (await import('./utils/initWalk.js')).initWalk;
318
- default:
319
- throw new Error(`Unknown layer type: ${type}`);
320
- }
321
- });
322
- const ready = this.ready = loading.then(initialize => {
323
- const map = this._map;
324
- map?.removeLayer(this);
325
- delete this.onAdd;
326
- delete this.onRemove;
327
- initialize(this, settings);
328
- map?.addLayer(this);
329
- return this.ready === ready ? this : this.ready;
330
- });
331
- ready.catch(error => this.fire('error', { error }));
332
- },
111
+ _layerAdd: layerLayerAdd,
112
+ initialize: layerInitialize,
333
113
  });
334
114
 
335
- L.Layer.addInitHook(function () {
336
- if (this instanceof L.Polyline || this instanceof L.CircleMarker) {
337
- const refresh = () => this._nativeGPU?.refresh?.();
338
- this.beforeAdd = this.onAdd = this.onRemove = this._updateBounds = () => {};
339
- this.getEvents = () => ({});
340
- // Leaflet mutators call this renderer contract, but no SVG/Canvas renderer is created.
341
- this._renderer = {
342
- options: { tolerance: 0 },
343
- _updatePath: refresh,
344
- _updateStyle: refresh,
345
- _bringToFront: () => this._nativeGPU?.reorder?.(true),
346
- _bringToBack: () => this._nativeGPU?.reorder?.(false),
347
- };
348
- if (this instanceof L.Polyline) {
349
- const closest = this.closestLayerPoint;
350
- this.closestLayerPoint = function (point) {
351
- this._project();
352
- this._parts = this._rings;
353
- return closest.call(this, point);
354
- };
355
- }
356
- if (this instanceof L.Circle) {
357
- const getBounds = this.getBounds;
358
- this.getBounds = function () {
359
- this._project();
360
- return getBounds.call(this);
361
- };
362
- }
363
- } else if (this instanceof L.GridLayer) {
364
- const initialize = this._initContainer;
365
- this._initContainer = function () {
366
- initialize.call(this);
367
- this._container.remove();
368
- };
369
- this._updateOpacity = function () {
370
- if (!this._map) return;
371
- const now = Date.now();
372
- let fading = false, prune = false;
373
- for (const tile of Object.values(this._tiles || {})) {
374
- if (!tile.current || !tile.loaded) continue;
375
- tile._gpuOpacity = this._map._fadeAnimated ? Math.min(1, (now - tile.loaded) / 200) : 1;
376
- if (tile._gpuOpacity < 1) fading = true;
377
- else if (!tile.active) {
378
- this._onOpaqueTile(tile);
379
- tile.active = true;
380
- prune = true;
381
- }
382
- }
383
- if (prune && !this._noPrune) this._pruneTiles();
384
- this._nativeGPU?.refresh?.();
385
- cancelAnimationFrame(this._fadeFrame);
386
- if (fading) this._fadeFrame = requestAnimationFrame(() => this._updateOpacity());
387
- };
388
- } else if (this instanceof L.ImageOverlay && !(this instanceof L.VideoOverlay) && !(this instanceof L.SVGOverlay)) {
389
- this.onAdd = function () {
390
- if (!this._image) this._initImage();
391
- if (this._image.complete && this._image.naturalWidth) queueMicrotask(() => this.fire('load'));
392
- };
393
- this.onRemove = () => {};
394
- this.getEvents = () => ({});
395
- this._reset = () => this._nativeGPU?.refresh?.();
396
- }
397
- });
115
+ L.Layer.addInitHook(initializeNativeLayer);
@@ -0,0 +1,23 @@
1
+ import { lightGrid } from './lightGrid.js';
2
+ import { worldLights } from './worldLights.js';
3
+
4
+ /** Keep fixed lamps cached when moving headlights change. */
5
+ export function cacheLightGrid(meshes, previous, maxBytes) {
6
+ let unchanged = previous?.meshes.length === meshes.length;
7
+ const packed = [], snapshots = [];
8
+ let i, mesh, matrix, lights, cache, sameMatrix, j;
9
+ for (i = 0; i < meshes.length; i++) {
10
+ mesh = meshes[i], matrix = mesh.worldMatrix, lights = mesh.extras.lights;
11
+ cache = mesh._worldLights;
12
+ sameMatrix = Boolean(cache);
13
+ for (j = 0; j < matrix.length && sameMatrix; j++) sameMatrix = matrix[j] === cache.matrix[j];
14
+ if (!sameMatrix || cache.lights !== lights) {
15
+ cache = mesh._worldLights = { lights, matrix: [...matrix], data: worldLights(lights, matrix) };
16
+ }
17
+ unchanged &&= previous.meshes[i].mesh === mesh && previous.meshes[i].cache === cache;
18
+ packed.push(cache.data);
19
+ snapshots.push({ mesh, cache });
20
+ }
21
+ if (unchanged) return previous;
22
+ return { ...lightGrid(packed, maxBytes), meshes: snapshots };
23
+ }
@@ -0,0 +1,6 @@
1
+ export function collectLightMeshes(node, fixed, moving) {
2
+ if (!node.visible) return;
3
+ if (node.extras?.lights) (node.extras.dynamicLights ? moving : fixed).push(node);
4
+ let child;
5
+ for (child of node.children || []) collectLightMeshes(child, fixed, moving);
6
+ }
@@ -0,0 +1,42 @@
1
+ import { visitCells } from './visitCells.js';
2
+
3
+ /** Pack world-space point lights into the shader's spatial grid. */
4
+ export function lightGrid(packed, maxBytes) {
5
+ let count = 0;
6
+ let values, i, value, key;
7
+ for (values of packed) count += values.length / 8;
8
+ const cellSize = 32;
9
+ let data = new Float32Array(8);
10
+ if (count) {
11
+ let minX = Infinity, minZ = Infinity, maxX = -Infinity, maxZ = -Infinity;
12
+ for (values of packed) for (i = 0; i < values.length; i += 8) {
13
+ minX = Math.min(minX, values[i] - values[i + 3]);
14
+ maxX = Math.max(maxX, values[i] + values[i + 3]);
15
+ minZ = Math.min(minZ, values[i + 2] - values[i + 3]);
16
+ maxZ = Math.max(maxZ, values[i + 2] + values[i + 3]);
17
+ }
18
+ const columns = Math.ceil((maxX - minX) / cellSize) + 1,
19
+ rows = Math.ceil((maxZ - minZ) / cellSize) + 1;
20
+ // Counting sort: count the lights of each cell, then fill each cell's slice.
21
+ const counts = new Uint32Array(columns * rows),
22
+ next = new Uint32Array(columns * rows);
23
+ visitCells(packed, minX, minZ, cellSize, columns, counts);
24
+ let entries = 0;
25
+ for (value of counts) entries += value;
26
+ const length = (2 + columns * rows + entries * 2) * 4;
27
+ if (length * 4 > maxBytes) {
28
+ throw new Error('Streetlight grid exceeds GPU storage limit');
29
+ }
30
+ data = new Float32Array(length);
31
+ data.set([minX, minZ, cellSize, columns, rows, count, 0, 0]);
32
+ let offset = 2 + columns * rows;
33
+ for (key = 0; key < counts.length; key++) if (counts[key]) {
34
+ data[(2 + key) * 4] = next[key] = offset;
35
+ data[(2 + key) * 4 + 1] = counts[key];
36
+ offset += counts[key] * 2;
37
+ }
38
+ visitCells(packed, minX, minZ, cellSize, columns, next, data);
39
+ }
40
+
41
+ return { data, count };
42
+ }
@@ -0,0 +1,34 @@
1
+ import { destroyTexture } from '../rendering/destroyTexture.js';
2
+ import { bindSunlight } from '../shadows/bindSunlight.js';
3
+ import { cacheLightGrid } from './cacheLightGrid.js';
4
+ import { collectLightMeshes } from './collectLightMeshes.js';
5
+
6
+ export function updatePointLights(backend) {
7
+ const { device, sunlight: sun } = backend.renderer;
8
+ const fixed = [], moving = [];
9
+ let layer;
10
+ for (layer of backend._layers) {
11
+ if (!layer.options.nightLight || !layer.root.visible) continue;
12
+ collectLightMeshes(layer.root, fixed, moving);
13
+ }
14
+ const maxBytes = device.limits.maxStorageBufferBindingSize;
15
+ const staticGrid = cacheLightGrid(fixed, sun.staticLightGrid, maxBytes);
16
+ const dynamicGrid = cacheLightGrid(moving, sun.dynamicLightGrid, maxBytes);
17
+ if (staticGrid === sun.staticLightGrid && dynamicGrid === sun.dynamicLightGrid) return;
18
+ const size = staticGrid.data.byteLength + dynamicGrid.data.byteLength;
19
+ if (size > maxBytes) throw new Error('Streetlight grid exceeds GPU storage limit');
20
+ let uploadStatic = staticGrid !== sun.staticLightGrid;
21
+ if (sun.lights.size < size) {
22
+ destroyTexture(backend, sun.lights);
23
+ sun.lights = device.createBuffer({ size, usage: GPUBufferUsage.STORAGE | GPUBufferUsage.COPY_DST });
24
+ bindSunlight(backend);
25
+ uploadStatic = true;
26
+ }
27
+ // The spare header component points to a second grid in the same storage binding.
28
+ staticGrid.data[6] = staticGrid.data.length / 4;
29
+ if (uploadStatic) device.queue.writeBuffer(sun.lights, 0, staticGrid.data);
30
+ device.queue.writeBuffer(sun.lights, staticGrid.data.byteLength, dynamicGrid.data);
31
+ sun.lightCount = staticGrid.count + dynamicGrid.count;
32
+ sun.staticLightGrid = staticGrid;
33
+ sun.dynamicLightGrid = dynamicGrid;
34
+ }
@@ -0,0 +1,15 @@
1
+ export function visitCells(packed, minX, minZ, cellSize, columns, offsets, data) {
2
+ let values, i, radius, x, z, y, c, key, j, o;
3
+ for (values of packed) for (i = 0; i < values.length; i += 8) {
4
+ radius = values[i + 3], x = values[i] - minX, z = values[i + 2] - minZ;
5
+ for (y = Math.floor((z - radius) / cellSize); y <= Math.floor((z + radius) / cellSize); y++) {
6
+ for (c = Math.floor((x - radius) / cellSize); c <= Math.floor((x + radius) / cellSize); c++) {
7
+ key = y * columns + c;
8
+ if (data) {
9
+ for (j = 0, o = offsets[key] * 4; j < 8; j++) data[o + j] = values[i + j];
10
+ offsets[key] += 2;
11
+ } else offsets[key]++;
12
+ }
13
+ }
14
+ }
15
+ }
@@ -0,0 +1,27 @@
1
+
2
+ /** World-space [x, y, z, radius, r, g, b, intensity] for one mesh's point lights. */
3
+ export function worldLights(lights, m) {
4
+ const values = new Float32Array(lights.length * 8);
5
+ let i, x, y, z, radius, color, flux, w;
6
+ for (i = 0; i < lights.length; i++) {
7
+ ({
8
+ position: [x, y, z],
9
+ radius,
10
+ color,
11
+ flux
12
+ } = lights[i]);
13
+ w = m[3] * x + m[7] * y + m[11] * z + m[15];
14
+ values.set(
15
+ [
16
+ (m[0] * x + m[4] * y + m[8] * z + m[12]) / w,
17
+ (m[1] * x + m[5] * y + m[9] * z + m[13]) / w,
18
+ (m[2] * x + m[6] * y + m[10] * z + m[14]) / w,
19
+ radius,
20
+ ...color,
21
+ flux / (4 * Math.PI) * 0.03
22
+ ],
23
+ i * 8
24
+ );
25
+ }
26
+ return values;
27
+ }
@@ -0,0 +1,45 @@
1
+ /** Decode a static glTF JSON document or GLB v2 container. */
2
+ import { hasUnsupportedPrimitives } from './hasUnsupportedPrimitives.js';
3
+
4
+ export function decodeModel(data) {
5
+ const view = new DataView(data), decoder = new TextDecoder();
6
+ let description;
7
+ let offset, length, type, chunk;
8
+ if (view.getUint32(0, true) === 0x46546c67) {
9
+ // Decode GLB v2 chunks; unknown types are skipped.
10
+ if (view.getUint32(4, true) !== 2 || view.getUint32(8, true) !== data.byteLength) {
11
+ throw new Error('Invalid GLB header');
12
+ }
13
+ let binary;
14
+ for (offset = 12; offset < data.byteLength;) {
15
+ if (offset + 8 > data.byteLength) {
16
+ throw new Error('Truncated GLB chunk');
17
+ }
18
+ length = view.getUint32(offset, true), type = view.getUint32(offset + 4, true);
19
+ offset += 8;
20
+ if (offset + length > data.byteLength) {
21
+ throw new Error('Truncated GLB data');
22
+ }
23
+ chunk = data.slice(offset, offset + length);
24
+ if (type === 0x4e4f534a) {
25
+ description = JSON.parse(decoder.decode(chunk));
26
+ }
27
+ if (type === 0x004e4942) {
28
+ binary = chunk;
29
+ }
30
+ offset += length;
31
+ }
32
+ if (!description) {
33
+ throw new Error('Missing GLB JSON');
34
+ }
35
+ if (binary) {
36
+ description.buffers[0].binary = binary;
37
+ }
38
+ } else {
39
+ description = JSON.parse(decoder.decode(data));
40
+ }
41
+ if (description.skins?.length || description.animations?.length || description.extensionsRequired?.length || hasUnsupportedPrimitives(description.meshes)) {
42
+ throw new Error('Layer3D supports static triangle glTF models without required extensions');
43
+ }
44
+ return description;
45
+ }
@@ -0,0 +1,10 @@
1
+ export function hasUnsupportedPrimitives(meshes) {
2
+ if (!meshes) return false;
3
+ let mesh, primitive;
4
+ for (mesh of meshes) {
5
+ for (primitive of mesh.primitives) {
6
+ if (primitive.targets || (primitive.mode !== undefined && primitive.mode !== 4)) return true;
7
+ }
8
+ }
9
+ return false;
10
+ }
@@ -0,0 +1,6 @@
1
+ export async function loadBuffer(buffer, directory) {
2
+ if (buffer.binary) return;
3
+ const response = await fetch(new URL(buffer.uri, directory).href);
4
+ if (!response.ok) throw new Error(`Unable to load model buffer: HTTP ${response.status}`);
5
+ buffer.binary = await response.arrayBuffer();
6
+ }