@pinkaphant/kolmo 0.2.3 → 0.4.0

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 (381) hide show
  1. package/LICENSE +1 -1
  2. package/README.md +36 -36
  3. package/bin/kolmo.mjs +12 -6
  4. package/dist/engine/causewayBridge.d.ts +14 -0
  5. package/dist/engine/causewayBridge.js +166 -0
  6. package/dist/engine/causewayBridge.js.map +1 -0
  7. package/dist/engine/index.d.ts +6 -4
  8. package/dist/engine/index.js +19 -12
  9. package/dist/engine/index.js.map +1 -0
  10. package/dist/engine/islandSettlementMesh.d.ts +26 -0
  11. package/dist/engine/islandSettlementMesh.js +166 -0
  12. package/dist/engine/islandSettlementMesh.js.map +1 -0
  13. package/dist/engine/kolmoActions.d.ts +23 -0
  14. package/dist/engine/kolmoActions.js +164 -0
  15. package/dist/engine/kolmoActions.js.map +1 -0
  16. package/dist/engine/kolmoActor.js +242 -165
  17. package/dist/engine/kolmoActor.js.map +1 -0
  18. package/dist/engine/kolmoFloatingOrigin.d.ts +17 -0
  19. package/dist/engine/kolmoFloatingOrigin.js +98 -0
  20. package/dist/engine/kolmoFloatingOrigin.js.map +1 -0
  21. package/dist/engine/kolmoGame.d.ts +27 -0
  22. package/dist/engine/kolmoGame.js +80 -0
  23. package/dist/engine/kolmoGame.js.map +1 -0
  24. package/dist/engine/kolmoHud.d.ts +23 -0
  25. package/dist/engine/kolmoHud.js +195 -0
  26. package/dist/engine/kolmoHud.js.map +1 -0
  27. package/dist/engine/kolmoInput.d.ts +1 -1
  28. package/dist/engine/kolmoInput.js +57 -30
  29. package/dist/engine/kolmoInput.js.map +1 -0
  30. package/dist/engine/kolmoIsland.d.ts +5 -10
  31. package/dist/engine/kolmoIsland.js +182 -250
  32. package/dist/engine/kolmoIsland.js.map +1 -0
  33. package/dist/engine/kolmoLongDrive.d.ts +3 -4
  34. package/dist/engine/kolmoLongDrive.js +140 -205
  35. package/dist/engine/kolmoLongDrive.js.map +1 -0
  36. package/dist/engine/kolmoPilotMesh.d.ts +2 -0
  37. package/dist/engine/kolmoPilotMesh.js +64 -0
  38. package/dist/engine/kolmoPilotMesh.js.map +1 -0
  39. package/dist/engine/kolmoProcedural.d.ts +13 -0
  40. package/dist/engine/kolmoProcedural.js +101 -0
  41. package/dist/engine/kolmoProcedural.js.map +1 -0
  42. package/dist/engine/kolmoRigs.d.ts +1 -1
  43. package/dist/engine/kolmoRigs.js +88 -47
  44. package/dist/engine/kolmoRigs.js.map +1 -0
  45. package/dist/engine/kolmoStore.d.ts +3 -100
  46. package/dist/engine/kolmoSurface.d.ts +2 -2
  47. package/dist/engine/kolmoSurface.js +150 -134
  48. package/dist/engine/kolmoSurface.js.map +1 -0
  49. package/dist/engine/kolmoTraits.d.ts +128 -0
  50. package/dist/engine/kolmoTraits.js +140 -0
  51. package/dist/engine/kolmoTraits.js.map +1 -0
  52. package/dist/engine/kolmoVehicle.d.ts +3 -33
  53. package/dist/engine/kolmoVehicle.js +66 -240
  54. package/dist/engine/kolmoVehicle.js.map +1 -0
  55. package/dist/engine/kolmoVehicleConfig.d.ts +54 -0
  56. package/dist/engine/kolmoVehicleConfig.js +80 -0
  57. package/dist/engine/kolmoVehicleConfig.js.map +1 -0
  58. package/dist/engine/kolmoVehicleDriver.d.ts +4 -1
  59. package/dist/engine/kolmoVehicleDriver.js +116 -22
  60. package/dist/engine/kolmoVehicleDriver.js.map +1 -0
  61. package/dist/engine/kolmoVehicleInner.d.ts +7 -0
  62. package/dist/engine/kolmoVehicleInner.js +261 -0
  63. package/dist/engine/kolmoVehicleInner.js.map +1 -0
  64. package/dist/engine/kolmoWorld.d.ts +6 -4
  65. package/dist/engine/kolmoWorld.js +134 -116
  66. package/dist/engine/kolmoWorld.js.map +1 -0
  67. package/dist/engine/longDriveKit.d.ts +5 -12
  68. package/dist/engine/longDriveKit.js +121 -233
  69. package/dist/engine/longDriveKit.js.map +1 -0
  70. package/dist/engine/longDriveRoadside.d.ts +16 -0
  71. package/dist/engine/longDriveRoadside.js +171 -0
  72. package/dist/engine/longDriveRoadside.js.map +1 -0
  73. package/dist/engine/macroCellBuilder.d.ts +34 -0
  74. package/dist/engine/macroCellBuilder.js +145 -0
  75. package/dist/engine/macroCellBuilder.js.map +1 -0
  76. package/dist/engine/mainlandMacroCell.d.ts +2 -2
  77. package/dist/engine/mainlandMacroCell.js +77 -165
  78. package/dist/engine/mainlandMacroCell.js.map +1 -0
  79. package/dist/engine/shiftedFixedBody.d.ts +1 -1
  80. package/dist/engine/shiftedFixedBody.js +55 -28
  81. package/dist/engine/shiftedFixedBody.js.map +1 -0
  82. package/dist/importer/ChopShopPanel.d.ts +9 -1
  83. package/dist/importer/ChopShopPanel.js +303 -359
  84. package/dist/importer/ChopShopPanel.js.map +1 -0
  85. package/dist/importer/DomainWorkshopPanel.d.ts +2 -1
  86. package/dist/importer/DomainWorkshopPanel.js +172 -242
  87. package/dist/importer/DomainWorkshopPanel.js.map +1 -0
  88. package/dist/importer/GateHudBar.d.ts +8 -0
  89. package/dist/importer/GateHudBar.js +290 -279
  90. package/dist/importer/GateHudBar.js.map +1 -0
  91. package/dist/importer/GlbImportGate.d.ts +2 -1
  92. package/dist/importer/GlbImportGate.js +252 -225
  93. package/dist/importer/GlbImportGate.js.map +1 -0
  94. package/dist/importer/ImperativeVehicleRig.d.ts +2 -2
  95. package/dist/importer/ImperativeVehicleRig.js +223 -284
  96. package/dist/importer/ImperativeVehicleRig.js.map +1 -0
  97. package/dist/importer/LiveDrivePads.d.ts +20 -0
  98. package/dist/importer/LiveDrivePads.js +169 -0
  99. package/dist/importer/LiveDrivePads.js.map +1 -0
  100. package/dist/importer/PaperShellDebrisRig.d.ts +25 -0
  101. package/dist/importer/PaperShellDebrisRig.js +143 -0
  102. package/dist/importer/PaperShellDebrisRig.js.map +1 -0
  103. package/dist/importer/R2VaultDrawer.d.ts +12 -0
  104. package/dist/importer/R2VaultDrawer.js +90 -0
  105. package/dist/importer/R2VaultDrawer.js.map +1 -0
  106. package/dist/importer/Step1CalibrationPlinth.d.ts +23 -5
  107. package/dist/importer/Step1CalibrationPlinth.js +180 -251
  108. package/dist/importer/Step1CalibrationPlinth.js.map +1 -0
  109. package/dist/importer/Step1ExplodedIslands.d.ts +31 -0
  110. package/dist/importer/Step1ExplodedIslands.js +144 -0
  111. package/dist/importer/Step1ExplodedIslands.js.map +1 -0
  112. package/dist/importer/Step2UniversalPad.d.ts +7 -7
  113. package/dist/importer/Step2UniversalPad.js +49 -170
  114. package/dist/importer/Step2UniversalPad.js.map +1 -0
  115. package/dist/importer/VfxEmitterPool.js +59 -86
  116. package/dist/importer/VfxEmitterPool.js.map +1 -0
  117. package/dist/importer/WheelRingHandles3D.d.ts +11 -0
  118. package/dist/importer/WheelRingHandles3D.js +318 -0
  119. package/dist/importer/WheelRingHandles3D.js.map +1 -0
  120. package/dist/importer/archLinerGeom.d.ts +2 -0
  121. package/dist/importer/archLinerGeom.js +51 -0
  122. package/dist/importer/archLinerGeom.js.map +1 -0
  123. package/dist/importer/{vehiclePanelAnim.d.ts → chopHingeHelpers.d.ts} +0 -10
  124. package/dist/importer/chopHingeHelpers.js +193 -0
  125. package/dist/importer/chopHingeHelpers.js.map +1 -0
  126. package/dist/importer/chopShopActions.d.ts +20 -26
  127. package/dist/importer/chopShopActions.js +135 -210
  128. package/dist/importer/chopShopActions.js.map +1 -0
  129. package/dist/importer/chopShopHandlers.d.ts +26 -0
  130. package/dist/importer/chopShopHandlers.js +276 -0
  131. package/dist/importer/chopShopHandlers.js.map +1 -0
  132. package/dist/importer/chopShopIoActions.d.ts +15 -0
  133. package/dist/importer/chopShopIoActions.js +137 -0
  134. package/dist/importer/chopShopIoActions.js.map +1 -0
  135. package/dist/importer/chopShopMcpAction.d.ts +18 -0
  136. package/dist/importer/chopShopMcpAction.js +58 -0
  137. package/dist/importer/chopShopMcpAction.js.map +1 -0
  138. package/dist/importer/cylinderBooleanSlice.d.ts +14 -0
  139. package/dist/importer/cylinderBooleanSlice.js +110 -0
  140. package/dist/importer/cylinderBooleanSlice.js.map +1 -0
  141. package/dist/importer/cylinderSliceMath.d.ts +14 -0
  142. package/dist/importer/cylinderSliceMath.js +251 -0
  143. package/dist/importer/cylinderSliceMath.js.map +1 -0
  144. package/dist/importer/fusedWheelDetect.d.ts +4 -0
  145. package/dist/importer/fusedWheelDetect.js +175 -0
  146. package/dist/importer/fusedWheelDetect.js.map +1 -0
  147. package/dist/importer/fusedWheelFit.d.ts +13 -0
  148. package/dist/importer/fusedWheelFit.js +138 -0
  149. package/dist/importer/fusedWheelFit.js.map +1 -0
  150. package/dist/importer/gateStore.d.ts +1 -1
  151. package/dist/importer/gateStore.js +36 -27
  152. package/dist/importer/gateStore.js.map +1 -0
  153. package/dist/importer/glbNormalizer.js +118 -79
  154. package/dist/importer/glbNormalizer.js.map +1 -0
  155. package/dist/importer/importerWebMcp.d.ts +4 -3
  156. package/dist/importer/importerWebMcp.js +41 -336
  157. package/dist/importer/importerWebMcp.js.map +1 -0
  158. package/dist/importer/importerWebMcpTools.d.ts +2 -0
  159. package/dist/importer/importerWebMcpTools.js +340 -0
  160. package/dist/importer/importerWebMcpTools.js.map +1 -0
  161. package/dist/importer/index.d.ts +4 -0
  162. package/dist/importer/index.js +32 -22
  163. package/dist/importer/index.js.map +1 -0
  164. package/dist/importer/khrCarPlanHelpers.d.ts +28 -0
  165. package/dist/importer/khrCarPlanHelpers.js +221 -0
  166. package/dist/importer/khrCarPlanHelpers.js.map +1 -0
  167. package/dist/importer/khrCarPlanner.d.ts +7 -0
  168. package/dist/importer/khrCarPlanner.js +279 -0
  169. package/dist/importer/khrCarPlanner.js.map +1 -0
  170. package/dist/importer/khrCompiler.d.ts +4 -22
  171. package/dist/importer/khrCompiler.js +56 -424
  172. package/dist/importer/khrCompiler.js.map +1 -0
  173. package/dist/importer/khrCraftPropCompiler.d.ts +40 -0
  174. package/dist/importer/khrCraftPropCompiler.js +250 -0
  175. package/dist/importer/khrCraftPropCompiler.js.map +1 -0
  176. package/dist/importer/launcherBake.js +76 -35
  177. package/dist/importer/launcherBake.js.map +1 -0
  178. package/dist/importer/meshIslands.d.ts +4 -46
  179. package/dist/importer/meshIslands.js +84 -283
  180. package/dist/importer/meshIslands.js.map +1 -0
  181. package/dist/importer/meshSliceBuffers.d.ts +15 -0
  182. package/dist/importer/meshSliceBuffers.js +159 -0
  183. package/dist/importer/meshSliceBuffers.js.map +1 -0
  184. package/dist/importer/polygonEarClipYZ.d.ts +3 -0
  185. package/dist/importer/polygonEarClipYZ.js +67 -0
  186. package/dist/importer/polygonEarClipYZ.js.map +1 -0
  187. package/dist/importer/sceneSiNormalize.d.ts +19 -0
  188. package/dist/importer/sceneSiNormalize.js +138 -0
  189. package/dist/importer/sceneSiNormalize.js.map +1 -0
  190. package/dist/importer/starterScene.d.ts +3 -0
  191. package/dist/importer/starterScene.js +76 -0
  192. package/dist/importer/starterScene.js.map +1 -0
  193. package/dist/importer/surfaceCutter.d.ts +4 -15
  194. package/dist/importer/surfaceCutter.js +69 -240
  195. package/dist/importer/surfaceCutter.js.map +1 -0
  196. package/dist/importer/surfaceGeodesic.d.ts +7 -0
  197. package/dist/importer/surfaceGeodesic.js +130 -0
  198. package/dist/importer/surfaceGeodesic.js.map +1 -0
  199. package/dist/importer/surfaceLoopRefine.d.ts +6 -0
  200. package/dist/importer/surfaceLoopRefine.js +171 -0
  201. package/dist/importer/surfaceLoopRefine.js.map +1 -0
  202. package/dist/importer/surfacePeel.d.ts +11 -0
  203. package/dist/importer/surfacePeel.js +119 -0
  204. package/dist/importer/surfacePeel.js.map +1 -0
  205. package/dist/importer/surfaceTopology.d.ts +2 -6
  206. package/dist/importer/surfaceTopology.js +93 -133
  207. package/dist/importer/surfaceTopology.js.map +1 -0
  208. package/dist/importer/universalGateBake.d.ts +7 -3
  209. package/dist/importer/universalGateBake.js +104 -106
  210. package/dist/importer/universalGateBake.js.map +1 -0
  211. package/dist/importer/usdPhysicsSpecs.d.ts +3 -0
  212. package/dist/importer/usdPhysicsSpecs.js +245 -0
  213. package/dist/importer/usdPhysicsSpecs.js.map +1 -0
  214. package/dist/importer/usdTextParse.d.ts +12 -0
  215. package/dist/importer/usdTextParse.js +118 -0
  216. package/dist/importer/usdTextParse.js.map +1 -0
  217. package/dist/importer/usdToGlb.d.ts +3 -2
  218. package/dist/importer/usdToGlb.js +80 -280
  219. package/dist/importer/usdToGlb.js.map +1 -0
  220. package/dist/importer/useChopShopController.d.ts +50 -47
  221. package/dist/importer/useChopShopController.js +156 -338
  222. package/dist/importer/useChopShopController.js.map +1 -0
  223. package/dist/importer/useChopShopState.d.ts +103 -0
  224. package/dist/importer/useChopShopState.js +319 -0
  225. package/dist/importer/useChopShopState.js.map +1 -0
  226. package/dist/importer/useWasdKeyRef.d.ts +9 -0
  227. package/dist/importer/useWasdKeyRef.js +35 -0
  228. package/dist/importer/useWasdKeyRef.js.map +1 -0
  229. package/dist/importer/vehiclePartSplit.d.ts +33 -0
  230. package/dist/importer/vehiclePartSplit.js +178 -0
  231. package/dist/importer/vehiclePartSplit.js.map +1 -0
  232. package/dist/importer/wheelAxlePairing.js +106 -70
  233. package/dist/importer/wheelAxlePairing.js.map +1 -0
  234. package/dist/importer/wheelCutterHelpers.d.ts +42 -0
  235. package/dist/importer/wheelCutterHelpers.js +178 -0
  236. package/dist/importer/wheelCutterHelpers.js.map +1 -0
  237. package/dist/importer/wheelRingHandleMath.d.ts +20 -0
  238. package/dist/importer/wheelRingHandleMath.js +66 -0
  239. package/dist/importer/wheelRingHandleMath.js.map +1 -0
  240. package/dist/index.d.ts +3 -2
  241. package/dist/index.js +90 -66
  242. package/dist/index.js.map +1 -0
  243. package/dist/junk/DestructibleTarget.d.ts +3 -3
  244. package/dist/junk/DestructibleTarget.js +177 -114
  245. package/dist/junk/DestructibleTarget.js.map +1 -0
  246. package/dist/junk/KolmoJunk.js +55 -44
  247. package/dist/junk/KolmoJunk.js.map +1 -0
  248. package/dist/junk/ShardPieces.d.ts +2 -1
  249. package/dist/junk/ShardPieces.js +80 -61
  250. package/dist/junk/ShardPieces.js.map +1 -0
  251. package/dist/junk/TargetDecals.d.ts +6 -15
  252. package/dist/junk/TargetDecals.js +66 -40
  253. package/dist/junk/TargetDecals.js.map +1 -0
  254. package/dist/junk/bvhShatter.d.ts +2 -6
  255. package/dist/junk/bvhShatter.js +89 -43
  256. package/dist/junk/bvhShatter.js.map +1 -0
  257. package/dist/junk/bvhTriCollector.d.ts +2 -6
  258. package/dist/junk/bvhTriCollector.js +111 -62
  259. package/dist/junk/bvhTriCollector.js.map +1 -0
  260. package/dist/junk/index.d.ts +2 -2
  261. package/dist/junk/index.js +11 -11
  262. package/dist/junk/index.js.map +1 -0
  263. package/dist/junk/junkGeometry.d.ts +5 -26
  264. package/dist/junk/junkGeometry.js +61 -43
  265. package/dist/junk/junkGeometry.js.map +1 -0
  266. package/dist/junk/junkImportSanitize.d.ts +4 -5
  267. package/dist/junk/junkImportSanitize.js +57 -37
  268. package/dist/junk/junkImportSanitize.js.map +1 -0
  269. package/dist/junk/junkImporter.d.ts +2 -13
  270. package/dist/junk/junkImporter.js +105 -76
  271. package/dist/junk/junkImporter.js.map +1 -0
  272. package/dist/junk/junkLabelCanvas.d.ts +1 -6
  273. package/dist/junk/junkLabelCanvas.js +147 -29
  274. package/dist/junk/junkLabelCanvas.js.map +1 -0
  275. package/dist/junk/junkLabels.d.ts +4 -26
  276. package/dist/junk/junkLabels.js +42 -28
  277. package/dist/junk/junkLabels.js.map +1 -0
  278. package/dist/junk/targetHelpers.d.ts +3 -4
  279. package/dist/junk/targetHelpers.js +121 -67
  280. package/dist/junk/targetHelpers.js.map +1 -0
  281. package/dist/junk/targetHitLogic.d.ts +8 -8
  282. package/dist/junk/targetHitLogic.js +131 -95
  283. package/dist/junk/targetHitLogic.js.map +1 -0
  284. package/dist/junk/useTargetAssets.d.ts +9 -14
  285. package/dist/junk/useTargetAssets.js +113 -85
  286. package/dist/junk/useTargetAssets.js.map +1 -0
  287. package/dist/physics/index.d.ts +1 -1
  288. package/dist/physics/index.js +79 -58
  289. package/dist/physics/index.js.map +1 -0
  290. package/dist/schema/kolmoSchema.d.ts +3 -64
  291. package/dist/schema/kolmoSchema.js +75 -149
  292. package/dist/schema/kolmoSchema.js.map +1 -0
  293. package/dist/schema/kolmoStamp.d.ts +6 -0
  294. package/dist/schema/kolmoStamp.js +71 -0
  295. package/dist/schema/kolmoStamp.js.map +1 -0
  296. package/dist/schema/kolmoTypes.d.ts +63 -0
  297. package/dist/schema/kolmoTypes.js +66 -0
  298. package/dist/schema/kolmoTypes.js.map +1 -0
  299. package/dist/shaders/celestialBackdrop.d.ts +2 -10
  300. package/dist/shaders/celestialBackdrop.js +128 -291
  301. package/dist/shaders/celestialBackdrop.js.map +1 -0
  302. package/dist/shaders/emitterShaders.d.ts +9 -0
  303. package/dist/shaders/emitterShaders.js +114 -0
  304. package/dist/shaders/emitterShaders.js.map +1 -0
  305. package/dist/shaders/index.d.ts +1 -1
  306. package/dist/shaders/index.js +12 -9
  307. package/dist/shaders/index.js.map +1 -0
  308. package/dist/shaders/plumeAndSparkle.d.ts +2 -4
  309. package/dist/shaders/plumeAndSparkle.js +152 -191
  310. package/dist/shaders/plumeAndSparkle.js.map +1 -0
  311. package/dist/shaders/ps2GlslShared.js +29 -2
  312. package/dist/shaders/ps2GlslShared.js.map +1 -0
  313. package/dist/shaders/ps2MaterialsTSL.js +132 -51
  314. package/dist/shaders/ps2MaterialsTSL.js.map +1 -0
  315. package/dist/shaders/ps2MaterialsWebGL.js +45 -28
  316. package/dist/shaders/ps2MaterialsWebGL.js.map +1 -0
  317. package/dist/shaders/ps2RoadWebGL.js +69 -32
  318. package/dist/shaders/ps2RoadWebGL.js.map +1 -0
  319. package/dist/shaders/ps2TerrainWebGL.js +107 -30
  320. package/dist/shaders/ps2TerrainWebGL.js.map +1 -0
  321. package/dist/shaders/ps2Textures.d.ts +1 -1
  322. package/dist/shaders/ps2Textures.js +116 -41
  323. package/dist/shaders/ps2Textures.js.map +1 -0
  324. package/dist/shaders/retroPalettes.d.ts +1 -1
  325. package/dist/shaders/retroPalettes.js +90 -57
  326. package/dist/shaders/retroPalettes.js.map +1 -0
  327. package/dist/shaders/retroShader.d.ts +2 -86
  328. package/dist/shaders/retroShader.js +65 -196
  329. package/dist/shaders/retroShader.js.map +1 -0
  330. package/dist/shaders/retroUniforms.d.ts +60 -0
  331. package/dist/shaders/retroUniforms.js +215 -0
  332. package/dist/shaders/retroUniforms.js.map +1 -0
  333. package/dist/shaders/skyboxShaders.d.ts +16 -0
  334. package/dist/shaders/skyboxShaders.js +266 -0
  335. package/dist/shaders/skyboxShaders.js.map +1 -0
  336. package/dist/shaders/tsl.d.ts +1 -1
  337. package/dist/shaders/tsl.js.map +1 -0
  338. package/dist/vite/index.js +39 -23
  339. package/dist/vite/index.js.map +1 -0
  340. package/dist/world/frontage.js +25 -21
  341. package/dist/world/frontage.js.map +1 -0
  342. package/dist/world/index.d.ts +4 -4
  343. package/dist/world/index.js +12 -11
  344. package/dist/world/index.js.map +1 -0
  345. package/dist/world/infiniteWorld2D.d.ts +0 -5
  346. package/dist/world/infiniteWorld2D.js +175 -200
  347. package/dist/world/infiniteWorld2D.js.map +1 -0
  348. package/dist/world/island.js +81 -166
  349. package/dist/world/island.js.map +1 -0
  350. package/dist/world/islandPathing.d.ts +6 -0
  351. package/dist/world/islandPathing.js +166 -0
  352. package/dist/world/islandPathing.js.map +1 -0
  353. package/dist/world/macroCellSchema.js +15 -8
  354. package/dist/world/macroCellSchema.js.map +1 -0
  355. package/dist/world/macroKnightAStar.js +140 -71
  356. package/dist/world/macroKnightAStar.js.map +1 -0
  357. package/dist/world/macroSettlementZones.d.ts +9 -0
  358. package/dist/world/macroSettlementZones.js +108 -0
  359. package/dist/world/macroSettlementZones.js.map +1 -0
  360. package/dist/world/random.js +50 -24
  361. package/dist/world/random.js.map +1 -0
  362. package/dist/world/road.js +152 -90
  363. package/dist/world/road.js.map +1 -0
  364. package/dist/world/roadRibbon.d.ts +4 -19
  365. package/dist/world/roadRibbon.js +129 -124
  366. package/dist/world/roadRibbon.js.map +1 -0
  367. package/dist/world/terrain.d.ts +1 -1
  368. package/dist/world/terrain.js +111 -65
  369. package/dist/world/terrain.js.map +1 -0
  370. package/dist/world/terrainGeometry.d.ts +14 -0
  371. package/dist/world/terrainGeometry.js +76 -0
  372. package/dist/world/terrainGeometry.js.map +1 -0
  373. package/dist/world/worldTypes.d.ts +3 -3
  374. package/dist/world/worldTypes.js +133 -67
  375. package/dist/world/worldTypes.js.map +1 -0
  376. package/docs/api-reference.md +187 -0
  377. package/package.json +58 -32
  378. package/dist/engine/kolmoStore.js +0 -211
  379. package/dist/importer/ImporterPlinthUikitTags.d.ts +0 -19
  380. package/dist/importer/ImporterPlinthUikitTags.js +0 -112
  381. package/dist/importer/vehiclePanelAnim.js +0 -214
@@ -1,191 +1,104 @@
1
- import { childSeed as e, fbm2 as t } from "./random.js";
2
- import { closedRoadFromPoints as n } from "./road.js";
3
- import { makeTerrain as r } from "./terrain.js";
1
+ import { astarRingSegment, pickRingWaypoints } from "./islandPathing.js";
2
+ import { childSeed, fbm2 } from "./random.js";
3
+ import { closedRoadFromPoints } from "./road.js";
4
+ import { makeTerrain } from "./terrain.js";
4
5
  // src/world/island.ts
5
- function i(n, r, i) {
6
- let a = e(n, "island-coast"), o = e(n, "island-hills"), s = e(n, "island-ridge"), c = r * .41;
7
- return (e, n) => {
8
- let l = t(a, e, n, {
9
- wavelength: r * .34,
6
+ function makeIslandHeightfn(seed, size, peakHeight) {
7
+ const coastSeed = childSeed(seed, "island-coast");
8
+ const hillsSeed = childSeed(seed, "island-hills");
9
+ const ridgeSeed = childSeed(seed, "island-ridge");
10
+ const radius = size * .41;
11
+ return (x, z) => {
12
+ const coastVar = fbm2(coastSeed, x, z, {
13
+ wavelength: size * .34,
10
14
  octaves: 3,
11
15
  gain: .5,
12
16
  lacunarity: 2
13
- }), u = c * (1 + .16 * l), d = Math.hypot(e, n) / Math.max(1, u);
14
- if (d >= 1) return -12 * Math.min(1, (d - 1) * 3);
15
- let f = (1 - d * d) ** 1.35, p = .5 + .5 * t(o, e, n, {
16
- wavelength: r * .22,
17
+ });
18
+ const effRadius = radius * (1 + .16 * coastVar);
19
+ const norm = Math.hypot(x, z) / Math.max(1, effRadius);
20
+ if (norm >= 1) return -12 * Math.min(1, (norm - 1) * 3);
21
+ const falloff = (1 - norm * norm) ** 1.35;
22
+ const hills = .5 + .5 * fbm2(hillsSeed, x, z, {
23
+ wavelength: size * .22,
17
24
  octaves: 4,
18
25
  gain: .5,
19
26
  lacunarity: 2.05
20
- }), m = 1 - Math.abs(t(s, e, n, {
21
- wavelength: r * .28,
27
+ });
28
+ const ridge = 1 - Math.abs(fbm2(ridgeSeed, x, z, {
29
+ wavelength: size * .28,
22
30
  octaves: 3,
23
31
  gain: .5,
24
32
  lacunarity: 2.1
25
33
  }));
26
- return 1.8 * Math.min(1, (1 - d) * 5) + i * f * (.45 * p + .55 * m * m);
34
+ return 1.8 * Math.min(1, (1 - norm) * 5) + peakHeight * falloff * (.45 * hills + .55 * ridge * ridge);
27
35
  };
28
36
  }
29
- function a(e, t, n, r, i, a) {
30
- let o = t * t, s = new Float64Array(o).fill(Infinity), c = new Int32Array(o).fill(-1), l = new Uint8Array(o), u = [i], d = [0];
31
- s[i] = 0;
32
- let f = a % t, p = a / t | 0, m = (e, t) => {
33
- let n = u.length;
34
- for (u.push(e), d.push(t); n > 0;) {
35
- let e = n - 1 >> 1;
36
- if (d[e] <= t) break;
37
- u[n] = u[e], d[n] = d[e], n = e;
38
- }
39
- u[n] = e, d[n] = t;
40
- }, h = () => {
41
- let e = u[0], t = u.pop(), n = d.pop();
42
- if (u.length > 0) {
43
- let e = 0, r = u.length;
44
- for (;;) {
45
- let t = e, i = e * 2 + 1, a = i + 1;
46
- if (i < r && d[i] < (e === t ? n : d[t]) && (t = i), a < r && d[a] < (t === e ? n : d[t]) && (t = a), t === e) break;
47
- u[e] = u[t], d[e] = d[t], e = t;
48
- }
49
- u[e] = t, d[e] = n;
50
- }
51
- return e;
52
- }, g = [
53
- [
54
- 1,
55
- 0,
56
- 1
57
- ],
58
- [
59
- -1,
60
- 0,
61
- 1
62
- ],
63
- [
64
- 0,
65
- 1,
66
- 1
67
- ],
68
- [
69
- 0,
70
- -1,
71
- 1
72
- ],
73
- [
74
- 1,
75
- 1,
76
- Math.SQRT2
77
- ],
78
- [
79
- 1,
80
- -1,
81
- Math.SQRT2
82
- ],
83
- [
84
- -1,
85
- 1,
86
- Math.SQRT2
87
- ],
88
- [
89
- -1,
90
- -1,
91
- Math.SQRT2
92
- ]
93
- ];
94
- for (; u.length > 0;) {
95
- let i = h();
96
- if (i === a) break;
97
- if (l[i]) continue;
98
- l[i] = 1;
99
- let o = i % t, u = i / t | 0, d = e[i];
100
- for (let [a, h, _] of g) {
101
- let g = o + a, v = u + h;
102
- if (g < 1 || g >= t - 1 || v < 1 || v >= t - 1) continue;
103
- let y = v * t + g;
104
- if (l[y]) continue;
105
- let b = e[y], x = _ * n, S = Math.abs(b - d) / x, C = b < r + .8 ? 55 * (r + 1.2 - b) : 0, w = Math.max(0, b - 22) * .35, T = S > .32 ? 260 * (S - .32) : 0, E = x * (1 + 52 * S * S + C + w + T), D = s[i] + E;
106
- D < s[y] && (s[y] = D, c[y] = i, m(y, D + Math.hypot(g - f, v - p) * n));
107
- }
108
- }
109
- let _ = [];
110
- for (let e = a; e !== -1 && e !== i; e = c[e]) _.push(e);
111
- return _.push(i), _.reverse(), _;
112
- }
113
- function o(e, t = {}) {
114
- let o = t.size ?? 960, s = t.peakHeight ?? 56, c = t.waterLevel ?? 0, l = t.halfWidth ?? 4.5, u = Math.max(5, t.waypointCount ?? 8), d = Math.max(48, t.pathGrid ?? 96), f = t.maxGrade ?? .08, p = i(e, o, s), m = o * .5, h = o / (d - 1), g = new Float32Array(d * d);
115
- for (let e = 0; e < d; e++) for (let t = 0; t < d; t++) g[e * d + t] = p(-m + t * h, -m + e * h);
116
- let _ = [], v = [];
117
- for (let e = 0; e < u; e++) {
118
- let t = e / u * Math.PI * 2, n = (d >> 1) * d + (d >> 1), r = Infinity;
119
- for (let e of [
120
- 0,
121
- -.1,
122
- .1,
123
- -.2,
124
- .2
125
- ]) {
126
- let i = t + e;
127
- for (let e = .22; e <= .37; e += .025) {
128
- let t = Math.cos(i) * o * e, a = Math.sin(i) * o * e, s = Math.min(d - 3, Math.max(2, Math.round((t + m) / h))), l = Math.min(d - 3, Math.max(2, Math.round((a + m) / h))) * d + s, u = g[l];
129
- if (u < c + 1.4) continue;
130
- let f = Math.hypot(g[l + 1] - g[l - 1], g[l + d] - g[l - d]) / (2 * h), p = u * .9 + f * 40 + Math.abs(e - .29) * 35;
131
- p < r && (r = p, n = l);
132
- }
133
- }
134
- _.push(n);
135
- let i = n % d, a = n / d | 0;
136
- v.push([
137
- -m + i * h,
138
- g[n],
139
- -m + a * h
140
- ]);
141
- }
142
- let y = [];
143
- for (let e = 0; e < u; e++) {
144
- let t = a(g, d, h, c, _[e], _[(e + 1) % u]);
145
- for (let e = 0; e < t.length - 1; e++) y.push(t[e]);
37
+ function planIslandWorld(seed, opts = {}) {
38
+ const size = opts.size ?? 960;
39
+ const peakHeight = opts.peakHeight ?? 56;
40
+ const waterLevel = opts.waterLevel ?? 0;
41
+ const halfWidth = opts.halfWidth ?? 4.5;
42
+ const waypointCount = Math.max(5, opts.waypointCount ?? 8);
43
+ const res = Math.max(48, opts.pathGrid ?? 96);
44
+ const maxRoadGrade = opts.maxGrade ?? .08;
45
+ const baseHeight = makeIslandHeightfn(seed, size, peakHeight);
46
+ const half = size * .5, cellM = size / (res - 1);
47
+ const grid = new Float32Array(res * res);
48
+ for (let row = 0; row < res; row++) for (let col = 0; col < res; col++) grid[row * res + col] = baseHeight(-half + col * cellM, -half + row * cellM);
49
+ const { waypointIds, waypoints } = pickRingWaypoints(grid, res, size, cellM, waterLevel, waypointCount);
50
+ const ringNodes = [];
51
+ for (let i = 0; i < waypointCount; i++) {
52
+ const seg = astarRingSegment(grid, res, cellM, waterLevel, waypointIds[i], waypointIds[(i + 1) % waypointCount]);
53
+ for (let k = 0; k < seg.length - 1; k++) ringNodes.push(seg[k]);
146
54
  }
147
- let b = Math.max(2, Math.round(22 / h)), x = [];
148
- for (let e = 0; e < y.length; e += b) {
149
- let t = y[e], n = t % d, r = t / d | 0, i = -m + n * h, a = -m + r * h;
150
- x.push([
151
- i,
152
- Math.max(c + 1.5, p(i, a) + .2),
153
- a
55
+ const sampleStride = Math.max(2, Math.round(22 / cellM));
56
+ let pts = [];
57
+ for (let i = 0; i < ringNodes.length; i += sampleStride) {
58
+ const id = ringNodes[i], gx = id % res, gz = id / res | 0;
59
+ const wx = -half + gx * cellM, wz = -half + gz * cellM;
60
+ pts.push([
61
+ wx,
62
+ Math.max(waterLevel + 1.5, baseHeight(wx, wz) + .2),
63
+ wz
154
64
  ]);
155
65
  }
156
- x.length < 6 && (x = [...v]);
157
- let S = x.length;
158
- for (let e = 0; e < 4; e++) x = x.map((e, t) => {
159
- let n = x[(t - 1 + S) % S], r = x[(t + 1) % S], i = .5 * e[0] + .25 * (n[0] + r[0]), a = .5 * e[2] + .25 * (n[2] + r[2]);
66
+ if (pts.length < 6) pts = [...waypoints];
67
+ const nPts = pts.length;
68
+ for (let pass = 0; pass < 4; pass++) pts = pts.map((p, i) => {
69
+ const prev = pts[(i - 1 + nPts) % nPts], next = pts[(i + 1) % nPts];
70
+ const x = .5 * p[0] + .25 * (prev[0] + next[0]), z = .5 * p[2] + .25 * (prev[2] + next[2]);
160
71
  return [
161
- i,
162
- Math.max(c + 1.5, p(i, a) + .2),
163
- a
72
+ x,
73
+ Math.max(waterLevel + 1.5, baseHeight(x, z) + .2),
74
+ z
164
75
  ];
165
76
  });
166
- for (let e = 0; e < 8; e++) {
167
- let e = x.map((e, t) => .4 * e[1] + .3 * (x[(t - 1 + S) % S][1] + x[(t + 1) % S][1]));
168
- for (let t = 0; t < S; t++) {
169
- let n = x[(t - 1 + S) % S], r = x[t], i = f * Math.max(1, Math.hypot(r[0] - n[0], r[2] - n[2])), a = Math.max(c + 1.4, Math.max(n[1] - i, Math.min(n[1] + i, e[t])));
170
- x[t] = [
171
- r[0],
172
- a,
173
- r[2]
77
+ for (let pass = 0; pass < 8; pass++) {
78
+ const smoothedY = pts.map((p, i) => .4 * p[1] + .3 * (pts[(i - 1 + nPts) % nPts][1] + pts[(i + 1) % nPts][1]));
79
+ for (let i = 0; i < nPts; i++) {
80
+ const prev = pts[(i - 1 + nPts) % nPts], cur = pts[i];
81
+ const maxDy = maxRoadGrade * Math.max(1, Math.hypot(cur[0] - prev[0], cur[2] - prev[2]));
82
+ const clampedY = Math.max(waterLevel + 1.4, Math.max(prev[1] - maxDy, Math.min(prev[1] + maxDy, smoothedY[i])));
83
+ pts[i] = [
84
+ cur[0],
85
+ clampedY,
86
+ cur[2]
174
87
  ];
175
88
  }
176
89
  }
177
- let C = n(x, l, 2);
90
+ const road = closedRoadFromPoints(pts, halfWidth, 2);
178
91
  return {
179
- seed: e,
180
- size: o,
181
- waterLevel: c,
182
- baseHeight: p,
183
- waypoints: v,
184
- road: C,
185
- terrain: r(e, C, {
186
- amplitude: s,
92
+ seed,
93
+ size,
94
+ waterLevel,
95
+ baseHeight,
96
+ waypoints,
97
+ road,
98
+ terrain: makeTerrain(seed, road, {
99
+ amplitude: peakHeight,
187
100
  noise: {
188
- wavelength: o * .25,
101
+ wavelength: size * .25,
189
102
  octaves: 4,
190
103
  gain: .5,
191
104
  lacunarity: 2
@@ -193,9 +106,11 @@ function o(e, t = {}) {
193
106
  maxSlope: .56,
194
107
  minShoulder: 7.5,
195
108
  verge: 3.5,
196
- baseHeight: p,
109
+ baseHeight,
197
110
  maxCutFill: 14
198
111
  })
199
112
  };
200
113
  }
201
- export { i as makeIslandHeightfn, o as planIslandWorld };
114
+ export { makeIslandHeightfn, planIslandWorld };
115
+
116
+ //# sourceMappingURL=island.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"island.js","names":[],"sources":["../../src/world/island.ts"],"sourcesContent":["import { astarRingSegment, pickRingWaypoints } from \"./islandPathing.js\";\nimport { childSeed, fbm2 } from \"./random.js\";\nimport { closedRoadFromPoints, type Road, type V3 } from \"./road.js\";\nimport { makeTerrain, type Terrain } from \"./terrain.js\";\n\nexport interface IslandOptions {\n /** Square world extent in metres (default `960`, supports `512..4096`). */\n readonly size?: number;\n /** Peak interior mountain elevation in metres (default `56`). */\n readonly peakHeight?: number;\n /** Sea level in metres (default `0`). */\n readonly waterLevel?: number;\n /** Road half-width in metres (default `4.5` -> `9 m` two-lane highway). */\n readonly halfWidth?: number;\n /** Number of ring A* waypoints around the island (default `8`). */\n readonly waypointCount?: number;\n /** Coarse pathfinding grid resolution per side (default `96`). */\n readonly pathGrid?: number;\n /** Maximum target longitudinal grade after smoothing (default `0.08`). */\n readonly maxGrade?: number;\n}\n\nexport interface IslandWorldPlan {\n readonly seed: number;\n readonly size: number;\n readonly waterLevel: number;\n readonly baseHeight: (x: number, z: number) => number;\n readonly waypoints: readonly V3[];\n readonly road: Road;\n readonly terrain: Terrain;\n}\n\nexport function makeIslandHeightfn(seed: number, size: number, peakHeight: number): (x: number, z: number) => number {\n const coastSeed = childSeed(seed, \"island-coast\");\n const hillsSeed = childSeed(seed, \"island-hills\");\n const ridgeSeed = childSeed(seed, \"island-ridge\");\n const radius = size * 0.41;\n\n return (x: number, z: number): number => {\n const coastVar = fbm2(coastSeed, x, z, { wavelength: size * 0.34, octaves: 3, gain: 0.5, lacunarity: 2 });\n const effRadius = radius * (1 + 0.16 * coastVar);\n const norm = Math.hypot(x, z) / Math.max(1, effRadius);\n if (norm >= 1) return -12 * Math.min(1, (norm - 1) * 3);\n const falloff = (1 - norm * norm) ** 1.35;\n const hills = 0.5 + 0.5 * fbm2(hillsSeed, x, z, { wavelength: size * 0.22, octaves: 4, gain: 0.5, lacunarity: 2.05 });\n const ridge = 1 - Math.abs(fbm2(ridgeSeed, x, z, { wavelength: size * 0.28, octaves: 3, gain: 0.5, lacunarity: 2.1 }));\n return 1.8 * Math.min(1, (1 - norm) * 5) + peakHeight * falloff * (0.45 * hills + 0.55 * ridge * ridge);\n };\n}\n\nexport function planIslandWorld(seed: number, opts: IslandOptions = {}): IslandWorldPlan {\n const size = opts.size ?? 960;\n const peakHeight = opts.peakHeight ?? 56;\n const waterLevel = opts.waterLevel ?? 0;\n const halfWidth = opts.halfWidth ?? 4.5;\n const waypointCount = Math.max(5, opts.waypointCount ?? 8);\n const res = Math.max(48, opts.pathGrid ?? 96);\n const maxRoadGrade = opts.maxGrade ?? 0.08;\n\n const baseHeight = makeIslandHeightfn(seed, size, peakHeight);\n const half = size * 0.5, cellM = size / (res - 1);\n const grid = new Float32Array(res * res);\n for (let row = 0; row < res; row++) {\n for (let col = 0; col < res; col++) grid[row * res + col] = baseHeight(-half + col * cellM, -half + row * cellM);\n }\n\n const { waypointIds, waypoints } = pickRingWaypoints(grid, res, size, cellM, waterLevel, waypointCount);\n const ringNodes: number[] = [];\n for (let i = 0; i < waypointCount; i++) {\n const seg = astarRingSegment(grid, res, cellM, waterLevel, waypointIds[i], waypointIds[(i + 1) % waypointCount]);\n for (let k = 0; k < seg.length - 1; k++) ringNodes.push(seg[k]);\n }\n\n const sampleStride = Math.max(2, Math.round(22 / cellM));\n let pts: V3[] = [];\n for (let i = 0; i < ringNodes.length; i += sampleStride) {\n const id = ringNodes[i], gx = id % res, gz = (id / res) | 0;\n const wx = -half + gx * cellM, wz = -half + gz * cellM;\n pts.push([wx, Math.max(waterLevel + 1.5, baseHeight(wx, wz) + 0.2), wz]);\n }\n if (pts.length < 6) pts = [...waypoints];\n\n const nPts = pts.length;\n for (let pass = 0; pass < 4; pass++) {\n pts = pts.map((p, i) => {\n const prev = pts[(i - 1 + nPts) % nPts], next = pts[(i + 1) % nPts];\n const x = 0.5 * p[0] + 0.25 * (prev[0] + next[0]), z = 0.5 * p[2] + 0.25 * (prev[2] + next[2]);\n return [x, Math.max(waterLevel + 1.5, baseHeight(x, z) + 0.2), z];\n });\n }\n\n for (let pass = 0; pass < 8; pass++) {\n const smoothedY = pts.map((p, i) => 0.4 * p[1] + 0.3 * (pts[(i - 1 + nPts) % nPts][1] + pts[(i + 1) % nPts][1]));\n for (let i = 0; i < nPts; i++) {\n const prev = pts[(i - 1 + nPts) % nPts], cur = pts[i];\n const maxDy = maxRoadGrade * Math.max(1, Math.hypot(cur[0] - prev[0], cur[2] - prev[2]));\n const clampedY = Math.max(waterLevel + 1.4, Math.max(prev[1] - maxDy, Math.min(prev[1] + maxDy, smoothedY[i])));\n pts[i] = [cur[0], clampedY, cur[2]];\n }\n }\n\n const road = closedRoadFromPoints(pts, halfWidth, 2);\n return {\n seed, size, waterLevel, baseHeight, waypoints, road,\n terrain: makeTerrain(seed, road, {\n amplitude: peakHeight,\n noise: { wavelength: size * 0.25, octaves: 4, gain: 0.5, lacunarity: 2 },\n maxSlope: 0.56, minShoulder: 7.5, verge: 3.5, baseHeight, maxCutFill: 14,\n }),\n };\n}\n"],"mappings":";;;;;AAgCA,SAAgB,mBAAmB,MAAc,MAAc,YAAsD;CACjH,MAAM,YAAY,UAAU,MAAM,cAAc;CAChD,MAAM,YAAY,UAAU,MAAM,cAAc;CAChD,MAAM,YAAY,UAAU,MAAM,cAAc;CAChD,MAAM,SAAS,OAAO;CAEtB,QAAQ,GAAW,MAAsB;EACrC,MAAM,WAAW,KAAK,WAAW,GAAG,GAAG;GAAE,YAAY,OAAO;GAAM,SAAS;GAAG,MAAM;GAAK,YAAY;EAAE,CAAC;EACxG,MAAM,YAAY,UAAU,IAAI,MAAO;EACvC,MAAM,OAAO,KAAK,MAAM,GAAG,CAAC,IAAI,KAAK,IAAI,GAAG,SAAS;EACrD,IAAI,QAAQ,GAAG,OAAO,MAAM,KAAK,IAAI,IAAI,OAAO,KAAK,CAAC;EACtD,MAAM,WAAW,IAAI,OAAO,SAAS;EACrC,MAAM,QAAQ,KAAM,KAAM,KAAK,WAAW,GAAG,GAAG;GAAE,YAAY,OAAO;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K,KAAK,IAAI,IAAI,KAAK,KAAK,EAAE,CAAC;GACvF,MAAM,WAAW,KAAK,IAAI,aAAa,KAAK,KAAK,IAAI,KAAK,KAAK,OAAO,KAAK,IAAI,KAAK,KAAK,OAAO,UAAU,EAAE,CAAC,CAAC;GAC9G,IAAI,KAAK;IAAC,IAAI;IAAI;IAAU,IAAI;GAAE;EACtC;CACJ;CAEA,MAAM,OAAO,qBAAqB,KAAK,WAAW,CAAC;CACnD,OAAO;EACH;EAAM;EAAM;EAAY;EAAY;EAAW;EAC/C,SAAS,YAAY,MAAM,MAAM;GAC7B,WAAW;GACX,OAAO;IAAE,YAAY,OAAO;IAAM,SAAS;IAAG,MAAM;IAAK,YAAY;GAAE;GACvE,UAAU;GAAM,aAAa;GAAK,OAAO;GAAK;GAAY,YAAY;EAC1E,CAAC;CACL;AACJ"}
@@ -0,0 +1,6 @@
1
+ import type { V3 } from "./road.js";
2
+ export declare function astarRingSegment(grid: Float32Array, res: number, cellM: number, waterLevel: number, startIdx: number, goalIdx: number): number[];
3
+ export declare function pickRingWaypoints(grid: Float32Array, res: number, size: number, cellM: number, waterLevel: number, waypointCount: number): {
4
+ waypointIds: number[];
5
+ waypoints: V3[];
6
+ };
@@ -0,0 +1,166 @@
1
+ // src/world/islandPathing.ts
2
+ function astarRingSegment(grid, res, cellM, waterLevel, startIdx, goalIdx) {
3
+ const total = res * res;
4
+ const gScore = new Float64Array(total).fill(Infinity);
5
+ const parent = new Int32Array(total).fill(-1);
6
+ const closed = new Uint8Array(total);
7
+ const heapNodes = [startIdx], heapScores = [0];
8
+ gScore[startIdx] = 0;
9
+ const goalX = goalIdx % res, goalZ = goalIdx / res | 0;
10
+ const push = (node, score) => {
11
+ let i = heapNodes.length;
12
+ heapNodes.push(node);
13
+ heapScores.push(score);
14
+ while (i > 0) {
15
+ const p = i - 1 >> 1;
16
+ if (heapScores[p] <= score) break;
17
+ heapNodes[i] = heapNodes[p];
18
+ heapScores[i] = heapScores[p];
19
+ i = p;
20
+ }
21
+ heapNodes[i] = node;
22
+ heapScores[i] = score;
23
+ };
24
+ const pop = () => {
25
+ const top = heapNodes[0];
26
+ const lastNode = heapNodes.pop();
27
+ const lastScore = heapScores.pop();
28
+ if (heapNodes.length > 0) {
29
+ let idx = 0;
30
+ const len = heapNodes.length;
31
+ for (;;) {
32
+ let smallest = idx, smallestScore = lastScore;
33
+ const l = idx * 2 + 1, r = l + 1;
34
+ if (l < len && heapScores[l] < smallestScore) {
35
+ smallest = l;
36
+ smallestScore = heapScores[l];
37
+ }
38
+ if (r < len && heapScores[r] < smallestScore) {
39
+ smallest = r;
40
+ smallestScore = heapScores[r];
41
+ }
42
+ if (smallest === idx) break;
43
+ heapNodes[idx] = heapNodes[smallest];
44
+ heapScores[idx] = heapScores[smallest];
45
+ idx = smallest;
46
+ }
47
+ heapNodes[idx] = lastNode;
48
+ heapScores[idx] = lastScore;
49
+ }
50
+ return top;
51
+ };
52
+ const dirs = [
53
+ [
54
+ 1,
55
+ 0,
56
+ 1
57
+ ],
58
+ [
59
+ -1,
60
+ 0,
61
+ 1
62
+ ],
63
+ [
64
+ 0,
65
+ 1,
66
+ 1
67
+ ],
68
+ [
69
+ 0,
70
+ -1,
71
+ 1
72
+ ],
73
+ [
74
+ 1,
75
+ 1,
76
+ Math.SQRT2
77
+ ],
78
+ [
79
+ 1,
80
+ -1,
81
+ Math.SQRT2
82
+ ],
83
+ [
84
+ -1,
85
+ 1,
86
+ Math.SQRT2
87
+ ],
88
+ [
89
+ -1,
90
+ -1,
91
+ Math.SQRT2
92
+ ]
93
+ ];
94
+ while (heapNodes.length > 0) {
95
+ const cur = pop();
96
+ if (cur === goalIdx) break;
97
+ if (closed[cur]) continue;
98
+ closed[cur] = 1;
99
+ const cx = cur % res, cz = cur / res | 0, hCur = grid[cur];
100
+ for (const [dx, dz, stepMult] of dirs) {
101
+ const nx = cx + dx, nz = cz + dz;
102
+ if (nx < 1 || nx >= res - 1 || nz < 1 || nz >= res - 1) continue;
103
+ const next = nz * res + nx;
104
+ if (closed[next]) continue;
105
+ const hNext = grid[next], dist = stepMult * cellM, grade = Math.abs(hNext - hCur) / dist;
106
+ const waterPenalty = hNext < waterLevel + .8 ? 55 * (waterLevel + 1.2 - hNext) : 0;
107
+ const altPenalty = Math.max(0, hNext - 22) * .35;
108
+ const steepPenalty = grade > .32 ? 260 * (grade - .32) : 0;
109
+ const gCand = gScore[cur] + dist * (1 + 52 * grade * grade + waterPenalty + altPenalty + steepPenalty);
110
+ if (gCand < gScore[next]) {
111
+ gScore[next] = gCand;
112
+ parent[next] = cur;
113
+ push(next, gCand + Math.hypot(nx - goalX, nz - goalZ) * cellM);
114
+ }
115
+ }
116
+ }
117
+ const path = [];
118
+ for (let cur = goalIdx; cur !== -1 && cur !== startIdx; cur = parent[cur]) path.push(cur);
119
+ path.push(startIdx);
120
+ path.reverse();
121
+ return path;
122
+ }
123
+ function pickRingWaypoints(grid, res, size, cellM, waterLevel, waypointCount) {
124
+ const half = size * .5;
125
+ const waypointIds = [];
126
+ const waypoints = [];
127
+ for (let i = 0; i < waypointCount; i++) {
128
+ const theta0 = i / waypointCount * Math.PI * 2;
129
+ let bestIdx = (res >> 1) * res + (res >> 1), bestCost = Infinity;
130
+ for (const dTheta of [
131
+ 0,
132
+ -.1,
133
+ .1,
134
+ -.2,
135
+ .2
136
+ ]) {
137
+ const ang = theta0 + dTheta;
138
+ for (let frac = .22; frac <= .37; frac += .025) {
139
+ const wx = Math.cos(ang) * size * frac, wz = Math.sin(ang) * size * frac;
140
+ const gx = Math.min(res - 3, Math.max(2, Math.round((wx + half) / cellM)));
141
+ const idx = Math.min(res - 3, Math.max(2, Math.round((wz + half) / cellM))) * res + gx, h = grid[idx];
142
+ if (h < waterLevel + 1.4) continue;
143
+ const slope = Math.hypot(grid[idx + 1] - grid[idx - 1], grid[idx + res] - grid[idx - res]) / (2 * cellM);
144
+ const cost = h * .9 + slope * 40 + Math.abs(frac - .29) * 35;
145
+ if (cost < bestCost) {
146
+ bestCost = cost;
147
+ bestIdx = idx;
148
+ }
149
+ }
150
+ }
151
+ waypointIds.push(bestIdx);
152
+ const ix = bestIdx % res, iz = bestIdx / res | 0;
153
+ waypoints.push([
154
+ -half + ix * cellM,
155
+ grid[bestIdx],
156
+ -half + iz * cellM
157
+ ]);
158
+ }
159
+ return {
160
+ waypointIds,
161
+ waypoints
162
+ };
163
+ }
164
+ export { astarRingSegment, pickRingWaypoints };
165
+
166
+ //# sourceMappingURL=islandPathing.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"islandPathing.js","names":[],"sources":["../../src/world/islandPathing.ts"],"sourcesContent":["import type { V3 } from \"./road.js\";\n\nexport function astarRingSegment(\n grid: Float32Array,\n res: number,\n cellM: number,\n waterLevel: number,\n startIdx: number,\n goalIdx: number,\n): number[] {\n const total = res * res;\n const gScore = new Float64Array(total).fill(Infinity);\n const parent = new Int32Array(total).fill(-1);\n const closed = new Uint8Array(total);\n const heapNodes = [startIdx], heapScores = [0];\n gScore[startIdx] = 0;\n const goalX = goalIdx % res, goalZ = (goalIdx / res) | 0;\n\n const push = (node: number, score: number): void => {\n let i = heapNodes.length;\n heapNodes.push(node);\n heapScores.push(score);\n while (i > 0) {\n const p = (i - 1) >> 1;\n if (heapScores[p] <= score) break;\n heapNodes[i] = heapNodes[p];\n heapScores[i] = heapScores[p];\n i = p;\n }\n heapNodes[i] = node;\n heapScores[i] = score;\n };\n\n const pop = (): number => {\n const top = heapNodes[0];\n const lastNode = heapNodes.pop()!;\n const lastScore = heapScores.pop()!;\n if (heapNodes.length > 0) {\n let idx = 0;\n const len = heapNodes.length;\n for (;;) {\n let smallest = idx, smallestScore = lastScore;\n const l = idx * 2 + 1, r = l + 1;\n if (l < len && heapScores[l] < smallestScore) { smallest = l; smallestScore = heapScores[l]; }\n if (r < len && heapScores[r] < smallestScore) { smallest = r; smallestScore = heapScores[r]; }\n if (smallest === idx) break;\n heapNodes[idx] = heapNodes[smallest];\n heapScores[idx] = heapScores[smallest];\n idx = smallest;\n }\n heapNodes[idx] = lastNode;\n heapScores[idx] = lastScore;\n }\n return top;\n };\n\n const dirs: ReadonlyArray<[number, number, number]> = [\n [1, 0, 1], [-1, 0, 1], [0, 1, 1], [0, -1, 1],\n [1, 1, Math.SQRT2], [1, -1, Math.SQRT2], [-1, 1, Math.SQRT2], [-1, -1, Math.SQRT2],\n ];\n\n while (heapNodes.length > 0) {\n const cur = pop();\n if (cur === goalIdx) break;\n if (closed[cur]) continue;\n closed[cur] = 1;\n const cx = cur % res, cz = (cur / res) | 0, hCur = grid[cur];\n\n for (const [dx, dz, stepMult] of dirs) {\n const nx = cx + dx, nz = cz + dz;\n if (nx < 1 || nx >= res - 1 || nz < 1 || nz >= res - 1) continue;\n const next = nz * res + nx;\n if (closed[next]) continue;\n const hNext = grid[next], dist = stepMult * cellM, grade = Math.abs(hNext - hCur) / dist;\n const waterPenalty = hNext < waterLevel + 0.8 ? 55 * (waterLevel + 1.2 - hNext) : 0;\n const altPenalty = Math.max(0, hNext - 22) * 0.35;\n const steepPenalty = grade > 0.32 ? 260 * (grade - 0.32) : 0;\n const gCand = gScore[cur] + dist * (1 + 52 * grade * grade + waterPenalty + altPenalty + steepPenalty);\n if (gCand < gScore[next]) {\n gScore[next] = gCand;\n parent[next] = cur;\n push(next, gCand + Math.hypot(nx - goalX, nz - goalZ) * cellM);\n }\n }\n }\n\n const path: number[] = [];\n for (let cur = goalIdx; cur !== -1 && cur !== startIdx; cur = parent[cur]) path.push(cur);\n path.push(startIdx);\n path.reverse();\n return path;\n}\n\nexport function pickRingWaypoints(\n grid: Float32Array,\n res: number,\n size: number,\n cellM: number,\n waterLevel: number,\n waypointCount: number,\n): { waypointIds: number[]; waypoints: V3[] } {\n const half = size * 0.5;\n const waypointIds: number[] = [];\n const waypoints: V3[] = [];\n for (let i = 0; i < waypointCount; i++) {\n const theta0 = (i / waypointCount) * Math.PI * 2;\n let bestIdx = (res >> 1) * res + (res >> 1), bestCost = Infinity;\n for (const dTheta of [0, -0.1, 0.1, -0.2, 0.2]) {\n const ang = theta0 + dTheta;\n for (let frac = 0.22; frac <= 0.37; frac += 0.025) {\n const wx = Math.cos(ang) * size * frac, wz = Math.sin(ang) * size * frac;\n const gx = Math.min(res - 3, Math.max(2, Math.round((wx + half) / cellM)));\n const gz = Math.min(res - 3, Math.max(2, Math.round((wz + half) / cellM)));\n const idx = gz * res + gx, h = grid[idx];\n if (h < waterLevel + 1.4) continue;\n const slope = Math.hypot(grid[idx + 1] - grid[idx - 1], grid[idx + res] - grid[idx - res]) / (2 * cellM);\n const cost = h * 0.9 + slope * 40 + Math.abs(frac - 0.29) * 35;\n if (cost < bestCost) { bestCost = cost; bestIdx = idx; }\n }\n }\n waypointIds.push(bestIdx);\n const ix = bestIdx % res, iz = (bestIdx / res) | 0;\n waypoints.push([-half + ix * cellM, grid[bestIdx], -half + iz * cellM]);\n }\n return { waypointIds, waypoints };\n}\n"],"mappings":";AAEA,SAAgB,iBACZ,MACA,KACA,OACA,YACA,UACA,SACQ;CACR,MAAM,QAAQ,MAAM;CACpB,MAAM,SAAS,IAAI,aAAa,KAAK,CAAC,CAAC,KAAK,QAAQ;CACpD,MAAM,SAAS,IAAI,WAAW,KAAK,CAAC,CAAC,KAAK,EAAE;CAC5C,MAAM,SAAS,IAAI,WAAW,KAAK;CACnC,MAAM,YAAY,CAAC,QAAQ,GAAG,aAAa,CAAC,CAAC;CAC7C,OAAO,YAAY;CACnB,MAAM,QAAQ,UAAU,KAAK,QAAS,UAAU,MAAO;CAEvD,MAAM,QAAQ,MAAc,UAAwB;EAChD,IAAI,IAAI,UAAU;EAClB,UAAU,KAAK,IAAI;EACnB,WAAW,KAAK,KAAK;EACrB,OAAO,IAAI,GAAG;GACV,MAAM,IAAK,IAAI,KAAM;GACrB,IAAI,WAAW,MAAM,OAAO;GAC5B,UAAU,KAAK,UAAU;GACzB,WAAW,KAAK,WAAW;GAC3B,IAAI;EACR;EACA,UAAU,KAAK;EACf,WAAW,KAAK;CACpB;CAE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E,MAAM,KAAK,KAAK,IAAI,MAAM,GAAG,KAAK,IAAI,GAAG,KAAK,OAAO,KAAK,QAAQ,KAAK,CAAC,CAAC;IAEzE,MAAM,MADK,KAAK,IAAI,MAAM,GAAG,KAAK,IAAI,GAAG,KAAK,OAAO,KAAK,QAAQ,KAAK,CAAC,CAC5D,IAAK,MAAM,IAAI,IAAI,KAAK;IACpC,IAAI,IAAI,aAAa,KAAK;IAC1B,MAAM,QAAQ,KAAK,MAAM,KAAK,MAAM,KAAK,KAAK,MAAM,IAAI,KAAK,MAAM,OAAO,KAAK,MAAM,IAAI,KAAK,IAAI;IAClG,MAAM,OAAO,IAAI,KAAM,QAAQ,KAAK,KAAK,IAAI,OAAO,GAAI,IAAI;IAC5D,IAAI,OAAO,UAAU;KAAE,WAAW;KAAM,UAAU;IAAK;GAC3D;EACJ;EACA,YAAY,KAAK,OAAO;EACxB,MAAM,KAAK,UAAU,KAAK,KAAM,UAAU,MAAO;EACjD,UAAU,KAAK;GAAC,CAAC,OAAO,KAAK;GAAO,KAAK;GAAU,CAAC,OAAO,KAAK;EAAK,CAAC;CAC1E;CACA,OAAO;EAAE;EAAa;CAAU;AACpC"}
@@ -1,5 +1,9 @@
1
1
  // src/world/macroCellSchema.ts
2
- var e = 2304, t = 3, n = 768, r = 192, i = {
2
+ var MACRO_SIZE_M = 2304;
3
+ var C12_TILE_M = 3;
4
+ var TILES_PER_MACRO = 768;
5
+ var FLOATING_ORIGIN_STEP_M = 192;
6
+ var C12TileKind = {
3
7
  EMPTY: 0,
4
8
  ROAD_LANE: 1,
5
9
  CROSSWALK: 2,
@@ -15,13 +19,16 @@ var e = 2304, t = 3, n = 768, r = 192, i = {
15
19
  ZONE_INDUSTRIAL: 12,
16
20
  ZONE_ROADSIDE_STOP: 13
17
21
  };
18
- function a(e, t) {
19
- let n = Math.round(e / 192) * 192, r = Math.round(t / 192) * 192;
22
+ function quantizeFloatingOrigin192(worldX, worldZ) {
23
+ const chunkOriginX = Math.round(worldX / 192) * 192;
24
+ const chunkOriginZ = Math.round(worldZ / 192) * 192;
20
25
  return {
21
- chunkOriginX: n,
22
- chunkOriginZ: r,
23
- localX: e - n,
24
- localZ: t - r
26
+ chunkOriginX,
27
+ chunkOriginZ,
28
+ localX: worldX - chunkOriginX,
29
+ localZ: worldZ - chunkOriginZ
25
30
  };
26
31
  }
27
- export { i as C12TileKind, t as C12_TILE_M, r as FLOATING_ORIGIN_STEP_M, e as MACRO_SIZE_M, n as TILES_PER_MACRO, a as quantizeFloatingOrigin192 };
32
+ export { C12TileKind, C12_TILE_M, FLOATING_ORIGIN_STEP_M, MACRO_SIZE_M, TILES_PER_MACRO, quantizeFloatingOrigin192 };
33
+
34
+ //# sourceMappingURL=macroCellSchema.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"macroCellSchema.js","names":[],"sources":["../../src/world/macroCellSchema.ts"],"sourcesContent":["import type { InstanceBatch } from \"@khr3/c12\";\n\nexport const MACRO_SIZE_M = 2304;\nexport const C12_TILE_M = 3;\nexport const TILES_PER_MACRO = 768;\nexport const FLOATING_ORIGIN_STEP_M = 192;\n\nexport type MacroSettlementTier =\n | \"ISLAND_RING\"\n | \"NONE_HIGHWAY\"\n | \"VILLAGE\"\n | \"SMALL_TOWN\"\n | \"SUBURBS_BIG_TOWN\"\n | \"CITY\"\n | \"METROPOLIS\";\n\nexport type RoadsideStopKind = \"GAS_STATION\" | \"REST_STOP\";\n\nexport const C12TileKind = {\n EMPTY: 0,\n ROAD_LANE: 1,\n CROSSWALK: 2,\n INTERSECTION_BOX: 3,\n CURB_STRAIGHT: 4,\n CURB_RAMP_CORNER: 5,\n CURB_DRIVEWAY: 6,\n BOULEVARD_MEDIAN: 7,\n C12_BOULEVARD_30: 8,\n C12_PLAZA_HUB: 9,\n ZONE_RESIDENTIAL: 10,\n ZONE_COMMERCIAL: 11,\n ZONE_INDUSTRIAL: 12,\n ZONE_ROADSIDE_STOP: 13,\n} as const;\n\nexport type C12TileKind = (typeof C12TileKind)[keyof typeof C12TileKind];\n\nexport interface SharedBorderPortal {\n readonly exists: boolean;\n readonly isBridgeCauseway: boolean;\n readonly offsetMeters: number;\n}\n\nexport interface RoadsideStop2D {\n readonly kind: RoadsideStopKind;\n readonly worldX: number;\n readonly worldZ: number;\n readonly yaw: number;\n readonly widthMeters: number;\n readonly depthMeters: number;\n}\n\nexport interface ZonedParcel2D {\n readonly zone: \"RESIDENTIAL\" | \"COMMERCIAL\" | \"INDUSTRIAL\";\n readonly minX: number;\n readonly minZ: number;\n readonly width: number;\n readonly depth: number;\n readonly yaw: number;\n}\n\nexport interface MacroCellPlan2D {\n readonly mx: number;\n readonly mz: number;\n readonly originWorldX: number;\n readonly originWorldZ: number;\n readonly tier: MacroSettlementTier;\n readonly hubX: number;\n readonly hubZ: number;\n readonly settlementRadiusM: number;\n readonly portals: {\n readonly north: SharedBorderPortal;\n readonly south: SharedBorderPortal;\n readonly west: SharedBorderPortal;\n readonly east: SharedBorderPortal;\n };\n readonly highwayPolylines: ReadonlyArray<ReadonlyArray<readonly [number, number]>>;\n readonly roadsideStops: readonly RoadsideStop2D[];\n readonly parcels: readonly ZonedParcel2D[];\n readonly civicHubBatches: readonly InstanceBatch[];\n}\n\nexport interface FloatingOriginFrame {\n readonly chunkOriginX: number;\n readonly chunkOriginZ: number;\n readonly localX: number;\n readonly localZ: number;\n}\n\nexport function quantizeFloatingOrigin192(worldX: number, worldZ: number): FloatingOriginFrame {\n const chunkOriginX = Math.round(worldX / FLOATING_ORIGIN_STEP_M) * FLOATING_ORIGIN_STEP_M;\n const chunkOriginZ = Math.round(worldZ / FLOATING_ORIGIN_STEP_M) * FLOATING_ORIGIN_STEP_M;\n return {\n chunkOriginX,\n chunkOriginZ,\n localX: worldX - chunkOriginX,\n localZ: worldZ - chunkOriginZ,\n };\n}\n"],"mappings":";AAEA,IAAa,eAAe;AAC5B,IAAa,aAAa;AAC1B,IAAa,kBAAkB;AAC/B,IAAa,yBAAyB;AAatC,IAAa,cAAc;CACvB,OAAO;CACP,WAAW;CACX,WAAW;CACX,kBAAkB;CAClB,eAAe;CACf,kBAAkB;CAClB,eAAe;CACf,kBAAkB;CAClB,kBAAkB;CAClB,eAAe;CACf,kBAAkB;CAClB,iBAAiB;CACjB,iBAAiB;CACjB,oBAAoB;AACxB;AAwDA,SAAgB,0BAA0B,QAAgB,QAAqC;CAC3F,MAAM,eAAe,KAAK,MAAM,SAAA,GAA+B,IAAA;CAC/D,MAAM,eAAe,KAAK,MAAM,SAAA,GAA+B,IAAA;CAC/D,OAAO;EACH;EACA;EACA,QAAQ,SAAS;EACjB,QAAQ,SAAS;CACrB;AACJ"}