@3driseai/3drise-viewer 0.1.41 → 0.1.43

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 (414) hide show
  1. package/dist/animationsV2/ClipsRuntime.d.ts +16 -1
  2. package/dist/animationsV2/ClipsRuntime.d.ts.map +1 -1
  3. package/dist/animationsV2/ClipsRuntime.js +144 -25
  4. package/dist/animationsV2/appliers.d.ts +9 -0
  5. package/dist/animationsV2/appliers.d.ts.map +1 -1
  6. package/dist/animationsV2/appliers.js +62 -2
  7. package/dist/animationsV2/clipUtils.d.ts +30 -0
  8. package/dist/animationsV2/clipUtils.d.ts.map +1 -1
  9. package/dist/animationsV2/clipUtils.js +163 -17
  10. package/dist/animationsV2/elementSettings.d.ts +5 -0
  11. package/dist/animationsV2/elementSettings.d.ts.map +1 -1
  12. package/dist/animationsV2/elementSettings.js +6 -3
  13. package/dist/animationsV2/sequenceUtils.js +4 -4
  14. package/dist/animationsV2/types.d.ts +23 -0
  15. package/dist/animationsV2/types.d.ts.map +1 -1
  16. package/dist/api/sceneHandle.js +2 -2
  17. package/dist/components/CreatedObject.d.ts +3 -0
  18. package/dist/components/CreatedObject.d.ts.map +1 -1
  19. package/dist/components/CreatedObject.js +6 -2
  20. package/dist/components/CustomPrimitive.d.ts.map +1 -1
  21. package/dist/components/CustomPrimitive.js +1 -10
  22. package/dist/components/EnvironmentManager.d.ts.map +1 -1
  23. package/dist/components/EnvironmentManager.js +11 -5
  24. package/dist/components/GeometryShape.d.ts +5 -2
  25. package/dist/components/GeometryShape.d.ts.map +1 -1
  26. package/dist/components/GeometryShape.js +71 -10
  27. package/dist/components/LandObject.d.ts.map +1 -1
  28. package/dist/components/LandObject.js +1 -1
  29. package/dist/components/LayoutInstances.d.ts +2 -1
  30. package/dist/components/LayoutInstances.d.ts.map +1 -1
  31. package/dist/components/LayoutInstances.js +39 -6
  32. package/dist/components/LightObject.d.ts.map +1 -1
  33. package/dist/components/LightObject.js +3 -0
  34. package/dist/components/ObjectNode.d.ts.map +1 -1
  35. package/dist/components/ObjectNode.js +62 -13
  36. package/dist/components/OceanBuilder.d.ts +2 -0
  37. package/dist/components/OceanBuilder.d.ts.map +1 -1
  38. package/dist/components/OceanBuilder.js +2 -1
  39. package/dist/components/RenderEffects.d.ts +8 -0
  40. package/dist/components/RenderEffects.d.ts.map +1 -0
  41. package/dist/components/RenderEffects.js +120 -0
  42. package/dist/components/SceneBuilder.d.ts.map +1 -1
  43. package/dist/components/SceneBuilder.js +18 -9
  44. package/dist/components/SportsObject.d.ts +9 -0
  45. package/dist/components/SportsObject.d.ts.map +1 -0
  46. package/dist/components/SportsObject.js +20 -0
  47. package/dist/components/UrbanObject.d.ts +9 -0
  48. package/dist/components/UrbanObject.d.ts.map +1 -0
  49. package/dist/components/UrbanObject.js +28 -0
  50. package/dist/components/VegetationObject.d.ts +9 -0
  51. package/dist/components/VegetationObject.d.ts.map +1 -0
  52. package/dist/components/VegetationObject.js +26 -0
  53. package/dist/components/WaterObject.d.ts +15 -0
  54. package/dist/components/WaterObject.d.ts.map +1 -0
  55. package/dist/components/WaterObject.js +29 -0
  56. package/dist/components/index.d.ts +7 -2
  57. package/dist/components/index.d.ts.map +1 -1
  58. package/dist/components/index.js +6 -1
  59. package/dist/components/land/LandPatch.d.ts +3 -1
  60. package/dist/components/land/LandPatch.d.ts.map +1 -1
  61. package/dist/components/land/LandPatch.js +80 -7
  62. package/dist/components/layout/InstancedLayout.d.ts +19 -0
  63. package/dist/components/layout/InstancedLayout.d.ts.map +1 -0
  64. package/dist/components/layout/InstancedLayout.js +154 -0
  65. package/dist/components/layout/LayoutGrounds.d.ts +19 -0
  66. package/dist/components/layout/LayoutGrounds.d.ts.map +1 -0
  67. package/dist/components/layout/LayoutGrounds.js +104 -0
  68. package/dist/components/layout/LinkProxies.d.ts +5 -0
  69. package/dist/components/layout/LinkProxies.d.ts.map +1 -0
  70. package/dist/components/layout/LinkProxies.js +51 -0
  71. package/dist/components/layout/LinkedSource.d.ts +14 -0
  72. package/dist/components/layout/LinkedSource.d.ts.map +1 -0
  73. package/dist/components/layout/LinkedSource.js +129 -0
  74. package/dist/components/projector/Projector.d.ts +14 -0
  75. package/dist/components/projector/Projector.d.ts.map +1 -0
  76. package/dist/components/projector/Projector.js +44 -0
  77. package/dist/components/projector/index.d.ts +4 -0
  78. package/dist/components/projector/index.d.ts.map +1 -0
  79. package/dist/components/projector/index.js +2 -0
  80. package/dist/components/projector/projectorCore.d.ts +19 -0
  81. package/dist/components/projector/projectorCore.d.ts.map +1 -0
  82. package/dist/components/projector/projectorCore.js +545 -0
  83. package/dist/components/sports/SportsBall.d.ts +9 -0
  84. package/dist/components/sports/SportsBall.d.ts.map +1 -0
  85. package/dist/components/sports/SportsBall.js +23 -0
  86. package/dist/components/sports/SportsCourt.d.ts +9 -0
  87. package/dist/components/sports/SportsCourt.d.ts.map +1 -0
  88. package/dist/components/sports/SportsCourt.js +23 -0
  89. package/dist/components/sports/SportsEquipment.d.ts +9 -0
  90. package/dist/components/sports/SportsEquipment.d.ts.map +1 -0
  91. package/dist/components/sports/SportsEquipment.js +23 -0
  92. package/dist/components/sports/SportsGoal.d.ts +9 -0
  93. package/dist/components/sports/SportsGoal.d.ts.map +1 -0
  94. package/dist/components/sports/SportsGoal.js +23 -0
  95. package/dist/components/sports/core/ball.d.ts +166 -0
  96. package/dist/components/sports/core/ball.d.ts.map +1 -0
  97. package/dist/components/sports/core/ball.js +402 -0
  98. package/dist/components/sports/core/court.d.ts +442 -0
  99. package/dist/components/sports/core/court.d.ts.map +1 -0
  100. package/dist/components/sports/core/court.js +658 -0
  101. package/dist/components/sports/core/equipment.d.ts +103 -0
  102. package/dist/components/sports/core/equipment.d.ts.map +1 -0
  103. package/dist/components/sports/core/equipment.js +403 -0
  104. package/dist/components/sports/core/goal.d.ts +98 -0
  105. package/dist/components/sports/core/goal.d.ts.map +1 -0
  106. package/dist/components/sports/core/goal.js +44 -0
  107. package/dist/components/sports/index.d.ts +11 -0
  108. package/dist/components/sports/index.d.ts.map +1 -0
  109. package/dist/components/sports/index.js +8 -0
  110. package/dist/components/sports/sportsCore.d.ts +195 -0
  111. package/dist/components/sports/sportsCore.d.ts.map +1 -0
  112. package/dist/components/sports/sportsCore.js +758 -0
  113. package/dist/components/sports/useSportsInstance.d.ts +35 -0
  114. package/dist/components/sports/useSportsInstance.d.ts.map +1 -0
  115. package/dist/components/sports/useSportsInstance.js +47 -0
  116. package/dist/components/terrain/TerrainSurface.d.ts.map +1 -1
  117. package/dist/components/terrain/TerrainSurface.js +14 -0
  118. package/dist/components/urban/UrbanBlock.d.ts +9 -0
  119. package/dist/components/urban/UrbanBlock.d.ts.map +1 -0
  120. package/dist/components/urban/UrbanBlock.js +23 -0
  121. package/dist/components/urban/UrbanBuilding.d.ts +9 -0
  122. package/dist/components/urban/UrbanBuilding.d.ts.map +1 -0
  123. package/dist/components/urban/UrbanBuilding.js +23 -0
  124. package/dist/components/urban/UrbanJunction.d.ts +9 -0
  125. package/dist/components/urban/UrbanJunction.d.ts.map +1 -0
  126. package/dist/components/urban/UrbanJunction.js +23 -0
  127. package/dist/components/urban/UrbanPark.d.ts +9 -0
  128. package/dist/components/urban/UrbanPark.d.ts.map +1 -0
  129. package/dist/components/urban/UrbanPark.js +23 -0
  130. package/dist/components/urban/UrbanParkingLot.d.ts +9 -0
  131. package/dist/components/urban/UrbanParkingLot.d.ts.map +1 -0
  132. package/dist/components/urban/UrbanParkingLot.js +23 -0
  133. package/dist/components/urban/UrbanPlaza.d.ts +9 -0
  134. package/dist/components/urban/UrbanPlaza.d.ts.map +1 -0
  135. package/dist/components/urban/UrbanPlaza.js +23 -0
  136. package/dist/components/urban/UrbanRoad.d.ts +9 -0
  137. package/dist/components/urban/UrbanRoad.d.ts.map +1 -0
  138. package/dist/components/urban/UrbanRoad.js +23 -0
  139. package/dist/components/urban/UrbanSignage.d.ts +9 -0
  140. package/dist/components/urban/UrbanSignage.d.ts.map +1 -0
  141. package/dist/components/urban/UrbanSignage.js +23 -0
  142. package/dist/components/urban/UrbanSkyline.d.ts +9 -0
  143. package/dist/components/urban/UrbanSkyline.d.ts.map +1 -0
  144. package/dist/components/urban/UrbanSkyline.js +23 -0
  145. package/dist/components/urban/UrbanStreetFurniture.d.ts +9 -0
  146. package/dist/components/urban/UrbanStreetFurniture.d.ts.map +1 -0
  147. package/dist/components/urban/UrbanStreetFurniture.js +23 -0
  148. package/dist/components/urban/UrbanStreetGrid.d.ts +9 -0
  149. package/dist/components/urban/UrbanStreetGrid.d.ts.map +1 -0
  150. package/dist/components/urban/UrbanStreetGrid.js +34 -0
  151. package/dist/components/urban/UrbanTraffic.d.ts +9 -0
  152. package/dist/components/urban/UrbanTraffic.d.ts.map +1 -0
  153. package/dist/components/urban/UrbanTraffic.js +23 -0
  154. package/dist/components/urban/core/block.d.ts +119 -0
  155. package/dist/components/urban/core/block.d.ts.map +1 -0
  156. package/dist/components/urban/core/block.js +266 -0
  157. package/dist/components/urban/core/building.d.ts +128 -0
  158. package/dist/components/urban/core/building.d.ts.map +1 -0
  159. package/dist/components/urban/core/building.js +741 -0
  160. package/dist/components/urban/core/junction.d.ts +152 -0
  161. package/dist/components/urban/core/junction.d.ts.map +1 -0
  162. package/dist/components/urban/core/junction.js +617 -0
  163. package/dist/components/urban/core/park.d.ts +67 -0
  164. package/dist/components/urban/core/park.d.ts.map +1 -0
  165. package/dist/components/urban/core/park.js +176 -0
  166. package/dist/components/urban/core/parkingLot.d.ts +82 -0
  167. package/dist/components/urban/core/parkingLot.d.ts.map +1 -0
  168. package/dist/components/urban/core/parkingLot.js +284 -0
  169. package/dist/components/urban/core/plaza.d.ts +24 -0
  170. package/dist/components/urban/core/plaza.d.ts.map +1 -0
  171. package/dist/components/urban/core/plaza.js +243 -0
  172. package/dist/components/urban/core/road.d.ts +113 -0
  173. package/dist/components/urban/core/road.d.ts.map +1 -0
  174. package/dist/components/urban/core/road.js +347 -0
  175. package/dist/components/urban/core/signage.d.ts +83 -0
  176. package/dist/components/urban/core/signage.d.ts.map +1 -0
  177. package/dist/components/urban/core/signage.js +209 -0
  178. package/dist/components/urban/core/skyline.d.ts +100 -0
  179. package/dist/components/urban/core/skyline.d.ts.map +1 -0
  180. package/dist/components/urban/core/skyline.js +89 -0
  181. package/dist/components/urban/core/streetFurniture.d.ts +75 -0
  182. package/dist/components/urban/core/streetFurniture.d.ts.map +1 -0
  183. package/dist/components/urban/core/streetFurniture.js +193 -0
  184. package/dist/components/urban/core/streetGrid.d.ts +134 -0
  185. package/dist/components/urban/core/streetGrid.d.ts.map +1 -0
  186. package/dist/components/urban/core/streetGrid.js +422 -0
  187. package/dist/components/urban/core/traffic.d.ts +125 -0
  188. package/dist/components/urban/core/traffic.d.ts.map +1 -0
  189. package/dist/components/urban/core/traffic.js +305 -0
  190. package/dist/components/urban/index.d.ts +29 -0
  191. package/dist/components/urban/index.d.ts.map +1 -0
  192. package/dist/components/urban/index.js +16 -0
  193. package/dist/components/urban/textureSetResolver.d.ts +8 -0
  194. package/dist/components/urban/textureSetResolver.d.ts.map +1 -0
  195. package/dist/components/urban/textureSetResolver.js +16 -0
  196. package/dist/components/urban/urbanCore.d.ts +262 -0
  197. package/dist/components/urban/urbanCore.d.ts.map +1 -0
  198. package/dist/components/urban/urbanCore.js +928 -0
  199. package/dist/components/urban/useUrbanInstance.d.ts +53 -0
  200. package/dist/components/urban/useUrbanInstance.d.ts.map +1 -0
  201. package/dist/components/urban/useUrbanInstance.js +100 -0
  202. package/dist/components/vegetation/VegetationBush.d.ts +9 -0
  203. package/dist/components/vegetation/VegetationBush.d.ts.map +1 -0
  204. package/dist/components/vegetation/VegetationBush.js +23 -0
  205. package/dist/components/vegetation/VegetationCrops.d.ts +9 -0
  206. package/dist/components/vegetation/VegetationCrops.d.ts.map +1 -0
  207. package/dist/components/vegetation/VegetationCrops.js +23 -0
  208. package/dist/components/vegetation/VegetationFlowers.d.ts +9 -0
  209. package/dist/components/vegetation/VegetationFlowers.d.ts.map +1 -0
  210. package/dist/components/vegetation/VegetationFlowers.js +23 -0
  211. package/dist/components/vegetation/VegetationForest.d.ts +9 -0
  212. package/dist/components/vegetation/VegetationForest.d.ts.map +1 -0
  213. package/dist/components/vegetation/VegetationForest.js +23 -0
  214. package/dist/components/vegetation/VegetationFruit.d.ts +9 -0
  215. package/dist/components/vegetation/VegetationFruit.d.ts.map +1 -0
  216. package/dist/components/vegetation/VegetationFruit.js +23 -0
  217. package/dist/components/vegetation/VegetationGrass.d.ts +9 -0
  218. package/dist/components/vegetation/VegetationGrass.d.ts.map +1 -0
  219. package/dist/components/vegetation/VegetationGrass.js +23 -0
  220. package/dist/components/vegetation/VegetationHedge.d.ts +9 -0
  221. package/dist/components/vegetation/VegetationHedge.d.ts.map +1 -0
  222. package/dist/components/vegetation/VegetationHedge.js +23 -0
  223. package/dist/components/vegetation/VegetationIvy.d.ts +9 -0
  224. package/dist/components/vegetation/VegetationIvy.d.ts.map +1 -0
  225. package/dist/components/vegetation/VegetationIvy.js +23 -0
  226. package/dist/components/vegetation/VegetationTree.d.ts +9 -0
  227. package/dist/components/vegetation/VegetationTree.d.ts.map +1 -0
  228. package/dist/components/vegetation/VegetationTree.js +23 -0
  229. package/dist/components/vegetation/VegetationVegetable.d.ts +9 -0
  230. package/dist/components/vegetation/VegetationVegetable.d.ts.map +1 -0
  231. package/dist/components/vegetation/VegetationVegetable.js +23 -0
  232. package/dist/components/vegetation/core/bush.d.ts +1256 -0
  233. package/dist/components/vegetation/core/bush.d.ts.map +1 -0
  234. package/dist/components/vegetation/core/bush.js +376 -0
  235. package/dist/components/vegetation/core/crops.d.ts +1033 -0
  236. package/dist/components/vegetation/core/crops.d.ts.map +1 -0
  237. package/dist/components/vegetation/core/crops.js +378 -0
  238. package/dist/components/vegetation/core/flowers.d.ts +648 -0
  239. package/dist/components/vegetation/core/flowers.d.ts.map +1 -0
  240. package/dist/components/vegetation/core/flowers.js +225 -0
  241. package/dist/components/vegetation/core/forest.d.ts +138 -0
  242. package/dist/components/vegetation/core/forest.d.ts.map +1 -0
  243. package/dist/components/vegetation/core/forest.js +310 -0
  244. package/dist/components/vegetation/core/fruit.d.ts +99 -0
  245. package/dist/components/vegetation/core/fruit.d.ts.map +1 -0
  246. package/dist/components/vegetation/core/fruit.js +77 -0
  247. package/dist/components/vegetation/core/grass.d.ts +103 -0
  248. package/dist/components/vegetation/core/grass.d.ts.map +1 -0
  249. package/dist/components/vegetation/core/grass.js +102 -0
  250. package/dist/components/vegetation/core/hedge.d.ts +193 -0
  251. package/dist/components/vegetation/core/hedge.d.ts.map +1 -0
  252. package/dist/components/vegetation/core/hedge.js +243 -0
  253. package/dist/components/vegetation/core/ivy.d.ts +213 -0
  254. package/dist/components/vegetation/core/ivy.d.ts.map +1 -0
  255. package/dist/components/vegetation/core/ivy.js +173 -0
  256. package/dist/components/vegetation/core/tree.d.ts +1117 -0
  257. package/dist/components/vegetation/core/tree.d.ts.map +1 -0
  258. package/dist/components/vegetation/core/tree.js +408 -0
  259. package/dist/components/vegetation/core/vegetable.d.ts +99 -0
  260. package/dist/components/vegetation/core/vegetable.d.ts.map +1 -0
  261. package/dist/components/vegetation/core/vegetable.js +76 -0
  262. package/dist/components/vegetation/index.d.ts +23 -0
  263. package/dist/components/vegetation/index.d.ts.map +1 -0
  264. package/dist/components/vegetation/index.js +14 -0
  265. package/dist/components/vegetation/produceCore.d.ts +929 -0
  266. package/dist/components/vegetation/produceCore.d.ts.map +1 -0
  267. package/dist/components/vegetation/produceCore.js +723 -0
  268. package/dist/components/vegetation/useVegetationInstance.d.ts +39 -0
  269. package/dist/components/vegetation/useVegetationInstance.d.ts.map +1 -0
  270. package/dist/components/vegetation/useVegetationInstance.js +45 -0
  271. package/dist/components/vegetation/vegetationCore.d.ts +412 -0
  272. package/dist/components/vegetation/vegetationCore.d.ts.map +1 -0
  273. package/dist/components/vegetation/vegetationCore.js +1728 -0
  274. package/dist/components/volumetricClouds/VolumetricCloudsPass.d.ts +5 -0
  275. package/dist/components/volumetricClouds/VolumetricCloudsPass.d.ts.map +1 -1
  276. package/dist/components/volumetricClouds/VolumetricCloudsPass.js +39 -13
  277. package/dist/components/water/OceanSurface.d.ts.map +1 -1
  278. package/dist/components/water/OceanSurface.js +3 -2
  279. package/dist/components/water/WaterBody.d.ts.map +1 -1
  280. package/dist/components/water/WaterBody.js +31 -10
  281. package/dist/components/water/WaterFountain.d.ts +9 -0
  282. package/dist/components/water/WaterFountain.d.ts.map +1 -0
  283. package/dist/components/water/WaterFountain.js +24 -0
  284. package/dist/components/water/WaterStream.d.ts +9 -0
  285. package/dist/components/water/WaterStream.d.ts.map +1 -0
  286. package/dist/components/water/WaterStream.js +24 -0
  287. package/dist/components/water/WaterWaterfall.d.ts +9 -0
  288. package/dist/components/water/WaterWaterfall.d.ts.map +1 -0
  289. package/dist/components/water/WaterWaterfall.js +24 -0
  290. package/dist/components/water/core/fountain.d.ts +70 -0
  291. package/dist/components/water/core/fountain.d.ts.map +1 -0
  292. package/dist/components/water/core/fountain.js +619 -0
  293. package/dist/components/water/core/stream.d.ts +72 -0
  294. package/dist/components/water/core/stream.d.ts.map +1 -0
  295. package/dist/components/water/core/stream.js +167 -0
  296. package/dist/components/water/core/waterfall.d.ts +78 -0
  297. package/dist/components/water/core/waterfall.d.ts.map +1 -0
  298. package/dist/components/water/core/waterfall.js +325 -0
  299. package/dist/components/water/index.d.ts +8 -0
  300. package/dist/components/water/index.d.ts.map +1 -1
  301. package/dist/components/water/index.js +7 -0
  302. package/dist/components/water/types.d.ts +3 -0
  303. package/dist/components/water/types.d.ts.map +1 -1
  304. package/dist/components/water/useWaterInstance.d.ts +43 -0
  305. package/dist/components/water/useWaterInstance.d.ts.map +1 -0
  306. package/dist/components/water/useWaterInstance.js +89 -0
  307. package/dist/components/water/waterCore.d.ts +179 -0
  308. package/dist/components/water/waterCore.d.ts.map +1 -0
  309. package/dist/components/water/waterCore.js +516 -0
  310. package/dist/constants.d.ts.map +1 -1
  311. package/dist/constants.js +9 -1
  312. package/dist/hooks/index.d.ts +7 -2
  313. package/dist/hooks/index.d.ts.map +1 -1
  314. package/dist/hooks/index.js +5 -2
  315. package/dist/hooks/useActionPatch.d.ts +23 -0
  316. package/dist/hooks/useActionPatch.d.ts.map +1 -0
  317. package/dist/hooks/useActionPatch.js +38 -0
  318. package/dist/hooks/useCloudSun.d.ts.map +1 -1
  319. package/dist/hooks/useCloudSun.js +3 -2
  320. package/dist/hooks/useCommittedInstance.d.ts +6 -0
  321. package/dist/hooks/useCommittedInstance.d.ts.map +1 -0
  322. package/dist/hooks/useCommittedInstance.js +42 -0
  323. package/dist/hooks/useConfigLive.d.ts +1 -1
  324. package/dist/hooks/useConfigLive.d.ts.map +1 -1
  325. package/dist/hooks/useContinuousEffects.d.ts.map +1 -1
  326. package/dist/hooks/useContinuousEffects.js +36 -20
  327. package/dist/hooks/useGridLayout.d.ts +7 -0
  328. package/dist/hooks/useGridLayout.d.ts.map +1 -0
  329. package/dist/hooks/useGridLayout.js +10 -0
  330. package/dist/hooks/useInteractionEffects.d.ts.map +1 -1
  331. package/dist/hooks/useInteractionEffects.js +48 -9
  332. package/dist/hooks/useLightLive.d.ts.map +1 -1
  333. package/dist/hooks/useLightLive.js +2 -0
  334. package/dist/hooks/useLinkStatus.d.ts +7 -0
  335. package/dist/hooks/useLinkStatus.d.ts.map +1 -0
  336. package/dist/hooks/useLinkStatus.js +20 -0
  337. package/dist/hooks/useMaterialApplication.d.ts +6 -1
  338. package/dist/hooks/useMaterialApplication.d.ts.map +1 -1
  339. package/dist/hooks/useMaterialApplication.js +7 -2
  340. package/dist/hooks/useOceanMaterial.d.ts +11 -1
  341. package/dist/hooks/useOceanMaterial.d.ts.map +1 -1
  342. package/dist/hooks/useOceanMaterial.js +185 -27
  343. package/dist/hooks/usePathAnimation.d.ts +8 -0
  344. package/dist/hooks/usePathAnimation.d.ts.map +1 -1
  345. package/dist/hooks/usePathAnimation.js +140 -59
  346. package/dist/hooks/useResolvedLayout.d.ts +10 -0
  347. package/dist/hooks/useResolvedLayout.d.ts.map +1 -0
  348. package/dist/hooks/useResolvedLayout.js +17 -0
  349. package/dist/hooks/useTimeLighting.d.ts +36 -0
  350. package/dist/hooks/useTimeLighting.d.ts.map +1 -0
  351. package/dist/hooks/useTimeLighting.js +67 -0
  352. package/dist/index.d.ts +4 -0
  353. package/dist/index.d.ts.map +1 -1
  354. package/dist/index.js +4 -0
  355. package/dist/operations/catalogue/shaderLayers.d.ts.map +1 -1
  356. package/dist/operations/catalogue/shaderLayers.js +26 -3
  357. package/dist/render/renderLive.d.ts +11 -0
  358. package/dist/render/renderLive.d.ts.map +1 -0
  359. package/dist/render/renderLive.js +57 -0
  360. package/dist/shaders/glsl/oceanCore.glsl.d.ts +2 -2
  361. package/dist/shaders/glsl/oceanCore.glsl.d.ts.map +1 -1
  362. package/dist/shaders/glsl/oceanCore.glsl.js +35 -5
  363. package/dist/shaders/ocean/OceanSurfaceMaterial.d.ts +12 -0
  364. package/dist/shaders/ocean/OceanSurfaceMaterial.d.ts.map +1 -1
  365. package/dist/shaders/ocean/OceanSurfaceMaterial.js +55 -7
  366. package/dist/shaders/terrain/TerrainMaterial.d.ts.map +1 -1
  367. package/dist/shaders/terrain/TerrainMaterial.js +28 -0
  368. package/dist/triggers/kinds/change.js +1 -1
  369. package/dist/ui/UiLayers.d.ts +17 -1
  370. package/dist/ui/UiLayers.d.ts.map +1 -1
  371. package/dist/ui/UiLayers.js +76 -3
  372. package/dist/ui/index.d.ts +2 -2
  373. package/dist/ui/index.d.ts.map +1 -1
  374. package/dist/ui/index.js +1 -1
  375. package/dist/utils/composerHostedPass.d.ts +74 -0
  376. package/dist/utils/composerHostedPass.d.ts.map +1 -0
  377. package/dist/utils/composerHostedPass.js +63 -0
  378. package/dist/utils/geometryScript.d.ts +17 -0
  379. package/dist/utils/geometryScript.d.ts.map +1 -0
  380. package/dist/utils/geometryScript.js +92 -0
  381. package/dist/utils/geometryScript.worker.d.ts +2 -0
  382. package/dist/utils/geometryScript.worker.d.ts.map +1 -0
  383. package/dist/utils/geometryScript.worker.js +42 -0
  384. package/dist/utils/groundRegistry.d.ts +11 -0
  385. package/dist/utils/groundRegistry.d.ts.map +1 -0
  386. package/dist/utils/groundRegistry.js +39 -0
  387. package/dist/utils/instancingSupport.d.ts +9 -0
  388. package/dist/utils/instancingSupport.d.ts.map +1 -0
  389. package/dist/utils/instancingSupport.js +13 -0
  390. package/dist/utils/landPatch.d.ts +26 -5
  391. package/dist/utils/landPatch.d.ts.map +1 -1
  392. package/dist/utils/landPatch.js +124 -9
  393. package/dist/utils/layoutPlacement.d.ts +30 -0
  394. package/dist/utils/layoutPlacement.d.ts.map +1 -0
  395. package/dist/utils/layoutPlacement.js +113 -0
  396. package/dist/utils/linkRegistry.d.ts +15 -0
  397. package/dist/utils/linkRegistry.d.ts.map +1 -0
  398. package/dist/utils/linkRegistry.js +11 -0
  399. package/dist/utils/shapes.d.ts +28 -2
  400. package/dist/utils/shapes.d.ts.map +1 -1
  401. package/dist/utils/shapes.js +32 -3
  402. package/dist/utils/sharedParts.d.ts +61 -0
  403. package/dist/utils/sharedParts.d.ts.map +1 -0
  404. package/dist/utils/sharedParts.js +268 -0
  405. package/dist/utils/svgAsset.d.ts +6 -0
  406. package/dist/utils/svgAsset.d.ts.map +1 -0
  407. package/dist/utils/svgAsset.js +46 -0
  408. package/dist/utils/waterLight.d.ts +29 -0
  409. package/dist/utils/waterLight.d.ts.map +1 -0
  410. package/dist/utils/waterLight.js +67 -0
  411. package/dist/utils/waterReflection.d.ts +185 -0
  412. package/dist/utils/waterReflection.d.ts.map +1 -0
  413. package/dist/utils/waterReflection.js +616 -0
  414. package/package.json +4 -3
@@ -0,0 +1,422 @@
1
+ // Emitted from Claude outputs/urban-lab/streetGrid.mjs by emit_object.mjs — edit the lab module and re-emit.
2
+ // =============================================================================
3
+ // urban/streetGrid — a whole street grid in one object: junctions, roads, lamps, traffic
4
+ // =============================================================================
5
+ // A layout preset over `road`, `junction` and `traffic`, the way `block` is one over
6
+ // `building`: columns x rows of nodes `pitch` metres apart; every inner node a cross
7
+ // junction, the edge nodes tees facing in and the corners rounded roads (edge 'loop'), or
8
+ // crosses everywhere with short stub arms (edge 'open'); a road between every pair of
9
+ // neighbouring nodes, ending at the junction arms so nothing overlaps; traffic along every
10
+ // avenue and street. The pieces are the road / junction / traffic cores themselves (their
11
+ // shaders, their lamp registration, their chunks), built as children of one group, so one
12
+ // grid is ONE object in the scene tree and a block fills each cell. The road, junction and
13
+ // traffic objects stay for one-off streets (a boulevard, a single T).
14
+ import * as THREE from 'three';
15
+ import * as ROAD from './road.js';
16
+ import * as JUNCTION from './junction.js';
17
+ import { junctionReach } from './junction.js';
18
+ import * as TRAFFIC from './traffic.js';
19
+ import { mergeByMaterial, createLampField, attachLampField, createPavingUniforms, createPavingMaterial, loadTextureSet, applyTextureSet } from '../urbanCore.js';
20
+ import { validateGridLayout, gridLayoutPlan, gridStreetPoints, gridCornerPoints, gridRoundaboutRadius, gridGroundPolygons } from '@3driseai/3drise-core';
21
+ export const EDGES = ['loop', 'open'];
22
+ export const LIGHTING = ['auto', 'day', 'night'];
23
+ export const STRUCTURAL = ['layout', 'groundTexture', 'groundTextures', 'lanes', 'laneWidth', 'armLength', 'cornerRadius', 'signals', 'texture', 'sidewalk', 'kerbHeight', 'sidewalkTexture', 'lamps', 'lampSpacing', 'lampHeight', 'traffic', 'showCars', 'seed'];
24
+ // ---------------------------------------------------------------------------- the child configs
25
+ /** The road knobs of a grid config (points added per segment). */
26
+ function roadCfg(c, points, curve = 0) {
27
+ // Every knob the road core reads, so no defaults table is needed here (the repo copy has none).
28
+ return {
29
+ type: 'road', enabled: true, points, curve, lanes: c.lanes, laneWidth: c.laneWidth,
30
+ markings: 'dashed', laneLines: true, edgeLines: true, crosswalks: false, lampSide: 'alternate',
31
+ markingColor: c.markingColor, asphaltColor: c.asphaltColor, wear: c.wear, texture: c.texture,
32
+ sidewalk: c.sidewalk, kerbHeight: c.kerbHeight, sidewalkColor: c.sidewalkColor, sidewalkTexture: c.sidewalkTexture,
33
+ lampSpacing: c.lamps ? c.lampSpacing : 0, lampHeight: c.lampHeight, lampPaint: c.lampPaint, lampColor: c.lampColor, lampRadius: c.lampRadius, lampIntensity: c.lampIntensity,
34
+ lighting: c.lighting, seed: c.seed,
35
+ };
36
+ }
37
+ function junctionCfg(c, shape, islandRadius = 10) {
38
+ return {
39
+ type: 'junction', enabled: true, shape, islandRadius, signalHeight: 4.5, lanes: c.lanes, laneWidth: c.laneWidth, armLength: c.armLength, cornerRadius: c.cornerRadius, crossings: c.crossings,
40
+ markingColor: c.markingColor, asphaltColor: c.asphaltColor, wear: c.wear, texture: c.texture,
41
+ sidewalk: c.sidewalk > 0.05, kerbHeight: c.kerbHeight, sidewalkColor: c.sidewalkColor, sidewalkTexture: c.sidewalkTexture,
42
+ signals: c.signals, signalCycle: c.signalCycle, signalPaint: c.signalPaint,
43
+ lamps: c.lamps, lampHeight: c.lampHeight, lampPaint: c.lampPaint, lampColor: c.lampColor, lampRadius: c.lampRadius, lampIntensity: c.lampIntensity,
44
+ lighting: c.lighting, seed: c.seed,
45
+ };
46
+ }
47
+ function trafficCfg(c, points, curve = 0, lanes = c.lanes) {
48
+ return { type: 'traffic', enabled: true, points, curve, lanes, laneWidth: c.laneWidth, density: c.traffic, speed: c.speed, jitter: 0.5, headlightColor: '#fff2d6', taillightColor: '#ff2a1a', intensity: 1, size: 1, showCars: c.showCars, lighting: c.lighting, seed: c.seed };
49
+ }
50
+ /**
51
+ * The pieces of the grid from its layout (config.layout, the GridLayout that `layoutId` names —
52
+ * the component resolves it; none yet = nothing to build): { junctions: [{ x, z, shape, ry }],
53
+ * roads: [{ points, curve }], traffic: [{ points, curve }], grounds (core gridGroundPolygons), extent }. Where a street is comes from core's gridLayoutPlan
54
+ * (the same function the GridCreator editor draws with); this only decides how to build it:
55
+ * - a node where 3 or 4 streets meet is a junction (a T turns its missing arm away);
56
+ * - streets chain through nodes where 2 meet: straight on, or round a corner (a smooth turn
57
+ * of up to 60 m radius), and a road runs from junction arm end to junction arm end;
58
+ * - a street's bend bulges only between the arm ends, so the junction arms stay straight;
59
+ * - traffic runs straight through junctions and round corners (the outer loop is one stream).
60
+ * In 'open' mode a border node also has a stub arm pointing out of the grid — core's plan gives it (GridNode.stubs, in arms / degree).
61
+ */
62
+ export function gridPlan(c) {
63
+ const layout = c.layout ? validateGridLayout(c.layout).layout : null;
64
+ if (!layout)
65
+ return { junctions: [], roads: [], traffic: [], grounds: [], extent: { w: 0, d: 0 }, layout: null };
66
+ const P = gridLayoutPlan(layout);
67
+ const nc = layout.columns.length, nr = layout.rows.length;
68
+ const A = (Math.max(1, Math.round(c.lanes)) * c.laneWidth) / 2 + c.armLength; // junction arm end from its centre
69
+ const junctions = [], roads = [], traffic = [];
70
+ // Streets by node and side.
71
+ const side = new Map();
72
+ const at = (id) => { let v = side.get(id); if (!v)
73
+ side.set(id, (v = {})); return v; };
74
+ for (const st of P.streets) {
75
+ at(st.from)[st.axis === 'x' ? 'e' : 's'] = st;
76
+ at(st.to)[st.axis === 'x' ? 'w' : 'n'] = st;
77
+ }
78
+ const nodeOf = new Map(P.nodes.map((n) => [n.id, n]));
79
+ // node id -> how far its junction reaches along each arm (a crossing: A; a roundabout: island + ring + arm)
80
+ const reach = new Map(), roundabouts = [], cornerR = new Map();
81
+ for (const n of P.nodes) {
82
+ if (n.degree === 0)
83
+ continue;
84
+ const arms = { ...n.arms };
85
+ const k = (arms.n ? 1 : 0) + (arms.s ? 1 : 0) + (arms.e ? 1 : 0) + (arms.w ? 1 : 0);
86
+ if (k >= 3) {
87
+ // Tee default: bar along x, stem +z, no -z arm; turn the missing arm to where nothing comes in.
88
+ const ry = k === 4 ? 0 : !arms.n ? 0 : !arms.s ? Math.PI : !arms.e ? -Math.PI / 2 : Math.PI / 2;
89
+ const round = n.junction && n.junction.kind === 'roundabout';
90
+ const island = round ? gridRoundaboutRadius(n.junction) : 10;
91
+ const shape = round ? (k === 4 ? 'roundabout' : 'roundabout3') : (k === 4 ? 'cross' : 'tee');
92
+ junctions.push({ x: n.x, z: n.z, shape, ry, island });
93
+ reach.set(n.id, junctionReach(junctionCfg(c, shape, island)));
94
+ if (round)
95
+ roundabouts.push({ x: n.x, z: n.z, island });
96
+ }
97
+ else if (n.turn)
98
+ cornerR.set(n.id, n.cornerRadius); // core decides the radius (layout.corners or automatic)
99
+ }
100
+ const isJunction = { has: (id) => reach.has(id) };
101
+ const isRoundabout = new Set(roundabouts.map((r) => `${r.x},${r.z}`));
102
+ const roundAt = (id) => { const n = nodeOf.get(id); return isRoundabout.has(`${n.x},${n.z}`); };
103
+ const trim = (id) => reach.get(id) ?? cornerR.get(id) ?? 0;
104
+ const passes = (id) => !isJunction.has(id) && nodeOf.get(id).degree === 2;
105
+ // A street's points from node `fromId` (reversed when it runs the other way).
106
+ const pts = (st, fromId) => {
107
+ const p = gridStreetPoints(st, trim(st.from), trim(st.to));
108
+ return st.from === fromId ? p : p.reverse();
109
+ };
110
+ const other = (st, id) => (st.from === id ? st.to : st.from);
111
+ // Walk from street `st` leaving node `id`, following `next(node, cameFrom)`; returns [{ st, from }] and whether it closed.
112
+ const walk = (st0, id0, next, seen) => {
113
+ const list = [{ st: st0, from: id0 }];
114
+ seen.add(st0.id);
115
+ let st = st0, id = other(st0, id0);
116
+ for (;;) {
117
+ if (id === id0)
118
+ return { list, closed: true };
119
+ const nx = next(id, st);
120
+ if (!nx || seen.has(nx.id))
121
+ return { list, closed: false };
122
+ seen.add(nx.id);
123
+ list.push({ st: nx, from: id });
124
+ st = nx;
125
+ id = other(nx, id);
126
+ }
127
+ };
128
+ const chainPoints = (list, closed, keepNodes) => {
129
+ const out = [];
130
+ const push = (q) => { const l = out[out.length - 1]; if (!l || Math.hypot(l[0] - q[0], l[1] - q[1]) > 0.05)
131
+ out.push(q); };
132
+ for (let k = 0; k < list.length; k++) {
133
+ const { st, from } = list[k];
134
+ const p = pts(st, from), to = other(st, from);
135
+ // Drop the node points where the street is trimmed (junction arm / corner), unless traffic keeps the centre.
136
+ // Traffic keeps a crossing's centre (it drives straight through) but not a roundabout's (it goes round).
137
+ const cutStart = trim(from) > 0 && !(keepNodes && isJunction.has(from) && !roundAt(from));
138
+ const cutEnd = trim(to) > 0 && !(keepNodes && isJunction.has(to) && !roundAt(to));
139
+ const body = p.slice(cutStart ? 1 : 0, cutEnd ? p.length - 1 : p.length);
140
+ for (const q of body)
141
+ push(q);
142
+ // A corner after this street (a chain or loop continues): a quadratic turn through the node.
143
+ const nextItem = list[k + 1] || (closed ? list[0] : null);
144
+ if (nextItem && cornerR.has(to)) {
145
+ // the curving API's corner round (core curveCornerPoints, 10 steps on grids)
146
+ const n = nodeOf.get(to), q0 = out[out.length - 1], q2 = pts(nextItem.st, to)[1];
147
+ const round = gridCornerPoints(q0, [n.x, n.z], q2);
148
+ for (let t = 1; t < round.length - 1; t++)
149
+ push(round[t]);
150
+ }
151
+ }
152
+ if (closed && out.length > 1)
153
+ push(out[0]);
154
+ return out;
155
+ };
156
+ // Roads: chains between junctions / dead ends, through straight and corner nodes.
157
+ const seenR = new Set();
158
+ for (const st of P.streets) {
159
+ if (seenR.has(st.id))
160
+ continue;
161
+ const nextR = (id, came) => { const v = side.get(id); return passes(id) ? [v.n, v.s, v.e, v.w].find((s2) => s2 && s2 !== came) : null; };
162
+ const fwd = walk(st, st.from, nextR, seenR);
163
+ let list = fwd.list, closed = fwd.closed;
164
+ if (!closed) {
165
+ const back = walk(st, st.to, nextR, new Set([...seenR].filter((id) => id !== st.id)));
166
+ for (const b of back.list)
167
+ seenR.add(b.st.id);
168
+ // back runs st -> backwards; flip it to come before st (each street then runs the other way).
169
+ const before = back.list.slice(1).reverse().map(({ st: s2, from }) => ({ st: s2, from: other(s2, from) }));
170
+ list = [...before, ...list];
171
+ }
172
+ const points = chainPoints(list, closed, false);
173
+ let len = 0;
174
+ for (let k = 1; k < points.length; k++)
175
+ len += Math.hypot(points[k][0] - points[k - 1][0], points[k][1] - points[k - 1][1]);
176
+ if (len > 2)
177
+ roads.push({ points, curve: 0 });
178
+ }
179
+ // Traffic: straight through junctions, round corners.
180
+ if (c.traffic > 0.01) {
181
+ const seenT = new Set();
182
+ const straight = (id, came) => {
183
+ if (roundAt(id))
184
+ return null; // a stream ends at a roundabout's arm; the ring has its own stream
185
+ const v = side.get(id) || {};
186
+ const ahead = came.axis === 'x' ? (v.e === came ? v.w : v.e) : (v.s === came ? v.n : v.s);
187
+ if (ahead)
188
+ return ahead;
189
+ return passes(id) ? [v.n, v.s, v.e, v.w].find((s2) => s2 && s2 !== came) : null;
190
+ };
191
+ for (const st of P.streets) {
192
+ if (seenT.has(st.id))
193
+ continue;
194
+ const fwd = walk(st, st.from, straight, seenT);
195
+ let list = fwd.list, closed = fwd.closed;
196
+ if (!closed) {
197
+ const back = walk(st, st.to, straight, new Set([...seenT].filter((id) => id !== st.id)));
198
+ for (const b of back.list)
199
+ seenT.add(b.st.id);
200
+ const before = back.list.slice(1).reverse().map(({ st: s2, from }) => ({ st: s2, from: other(s2, from) }));
201
+ list = [...before, ...list];
202
+ }
203
+ const points = chainPoints(list, closed, true);
204
+ if (closed && points.length > 2)
205
+ points.push(points[1]); // close the loop for the stream (as the old ring did)
206
+ if (points.length > 1)
207
+ traffic.push({ points, curve: 0 });
208
+ }
209
+ // Each roundabout: one lane of traffic going round (anticlockwise seen from above: the path runs
210
+ // clockwise, a single-lane stream drives it backwards — see traffic.carInstances).
211
+ for (const r of roundabouts) {
212
+ const rc = r.island + (Math.max(1, Math.round(c.lanes)) * c.laneWidth) / 2, n = 48, points = [];
213
+ for (let k = 0; k <= n + 1; k++) {
214
+ const a = (k / n) * Math.PI * 2;
215
+ points.push([r.x + Math.cos(a) * rc, r.z + Math.sin(a) * rc]);
216
+ }
217
+ traffic.push({ points, curve: 0, lanes: 1 });
218
+ }
219
+ }
220
+ return { junctions, roads, traffic, grounds: gridGroundPolygons(P), extent: { w: P.width, d: P.depth }, layout };
221
+ }
222
+ // ---------------------------------------------------------------------------- grounds
223
+ /** How far a ground sits under the street surface (metres), so the asphalt and pavements cover it. */
224
+ const GROUND_DROP = 0.04;
225
+ const insideXZ = (ring, p) => {
226
+ let inside = false;
227
+ for (let k = 0, l = ring.length - 1; k < ring.length; l = k++) {
228
+ const a = ring[k], b = ring[l];
229
+ if ((a[2] > p[2]) !== (b[2] > p[2]) && p[0] < ((b[0] - a[0]) * (p[2] - a[2])) / (b[2] - a[2]) + a[0])
230
+ inside = !inside;
231
+ }
232
+ return inside;
233
+ };
234
+ /**
235
+ * A ground's plane from its outlines (core gridGroundPolygons): each outline triangulated seen
236
+ * from above with the holes inside it, at the outline's heights; aUV = metres (the paving material).
237
+ */
238
+ export function groundGeometry(shape) {
239
+ const outers = shape.outlines.filter((o) => !o.hole), holes = shape.outlines.filter((o) => o.hole);
240
+ const pos = [], uv = [], idx = [];
241
+ for (const o of outers) {
242
+ const rings = [o.points, ...holes.filter((h) => insideXZ(o.points, h.points[0])).map((h) => h.points)];
243
+ const v2 = rings.map((r) => r.map((p) => new THREE.Vector2(p[0], p[2])));
244
+ const tris = THREE.ShapeUtils.triangulateShape(v2[0], v2.slice(1));
245
+ const base = pos.length / 3;
246
+ for (const r of rings)
247
+ for (const p of r) {
248
+ pos.push(p[0], p[1] - GROUND_DROP, p[2]);
249
+ uv.push(p[0], p[2]);
250
+ }
251
+ for (const t of tris)
252
+ idx.push(base + t[0], base + t[1], base + t[2]);
253
+ }
254
+ const g = new THREE.BufferGeometry();
255
+ g.setAttribute('position', new THREE.Float32BufferAttribute(pos, 3));
256
+ g.setAttribute('aUV', new THREE.Float32BufferAttribute(uv, 2));
257
+ // face up: ShapeUtils winds by the 2D (x, z) frame, which is upside down seen from +y
258
+ if (idx.length >= 3) {
259
+ const P = (i) => new THREE.Vector3(pos[i * 3], pos[i * 3 + 1], pos[i * 3 + 2]);
260
+ const n = new THREE.Vector3().subVectors(P(idx[1]), P(idx[0])).cross(new THREE.Vector3().subVectors(P(idx[2]), P(idx[0])));
261
+ if (n.y < 0)
262
+ for (let k = 0; k < idx.length; k += 3) {
263
+ const t = idx[k + 1];
264
+ idx[k + 1] = idx[k + 2];
265
+ idx[k + 2] = t;
266
+ }
267
+ }
268
+ g.setIndex(idx);
269
+ g.computeVertexNormals();
270
+ return g;
271
+ }
272
+ /** One ground as a piece of the grid: its own paving material (its texture set in its own colours, or a lawn in groundColor), lit by the grid's lamp field. */
273
+ function buildGround(shape, cfg, field) {
274
+ const u = createPavingUniforms(), mat = createPavingMaterial(u);
275
+ const ref = (cfg.groundTextures && cfg.groundTextures[shape.id]) || cfg.groundTexture;
276
+ const maps = ref && ref.maps;
277
+ const lawn = !(maps && maps.color);
278
+ u.uGrassMix.value = lawn ? 1 : 0;
279
+ if (lawn && cfg.groundColor !== undefined)
280
+ u.uPavColor.value.set(cfg.groundColor);
281
+ let alive = true;
282
+ // a texture shows in its own colours (the colour is its mean: albedo = colour × texture / mean)
283
+ if (!lawn)
284
+ loadTextureSet(maps).ready.then((t) => { if (!alive)
285
+ return; applyTextureSet(u, 'uPav', t, ref.tileSize, 0.8); u.uPavColor.value.copy(t.mean); });
286
+ attachLampField(u, field);
287
+ const mesh = new THREE.Mesh(groundGeometry(shape), mat);
288
+ mesh.receiveShadow = true;
289
+ mesh.name = `ground ${shape.id}`;
290
+ return {
291
+ object: mesh, materials: [mat], uniformSets: [u],
292
+ apply(live) { if (lawn && live.groundColor !== undefined)
293
+ u.uPavColor.value.set(live.groundColor); },
294
+ update() { },
295
+ bounds() { mesh.geometry.computeBoundingBox(); return mesh.geometry.boundingBox.clone(); },
296
+ dispose() { alive = false; mesh.geometry.dispose(); mat.dispose(); },
297
+ };
298
+ }
299
+ export function createUniforms() { return ROAD.createUniforms(); }
300
+ export function applyConfig(u, c, tex = undefined) { ROAD.applyConfig(u, roadCfg(c, [[0, 0], [1, 0]]), tex); }
301
+ // ---------------------------------------------------------------------------- lab build
302
+ export function build(u, c) {
303
+ const group = new THREE.Group();
304
+ const uJ = JUNCTION.createUniforms();
305
+ const uT = TRAFFIC.createUniforms();
306
+ let kids = []; // { inst, kind, pos }
307
+ // The pieces are built by the road / junction cores, then MERGED by material: every junction
308
+ // asphalt into one mesh, every pavement into one, every lamp into one InstancedMesh… (≈ 215
309
+ // meshes -> ≈ 12). A merged mesh draws with the first piece's material; the pieces' knob
310
+ // uniforms all receive the same config, so any piece's material stands for all of them
311
+ // (a per-piece difference must live in a vertex attribute — the junction's aTee). The merged
312
+ // surfaces are lit by one baked lamp field (common.mjs) instead of 48-lamp lists per piece.
313
+ // The pieces' own objects stay in the group, empty, so their lamp registry entries follow
314
+ // the grid's transform as before.
315
+ const field = createLampField();
316
+ attachLampField(uT, field); // the traffic's cars are lit by the grid's lamps too
317
+ let merged = [];
318
+ const unmerge = () => { for (const m of merged) {
319
+ group.remove(m);
320
+ m.geometry.dispose();
321
+ } merged = []; };
322
+ const clear = () => { unmerge(); for (const k of kids) {
323
+ group.remove(k.inst.object);
324
+ k.inst.dispose();
325
+ } kids = []; };
326
+ // grounds stay out of the merge: each has its own texture (a merged mesh draws with ONE material)
327
+ const merge = () => { unmerge(); merged = mergeByMaterial(group, kids.filter((k) => k.kind !== 'traffic' && k.kind !== 'ground').map((k) => k.inst.object), field); };
328
+ const rebuild = (cfg) => {
329
+ clear();
330
+ const plan = gridPlan(cfg);
331
+ for (const j of plan.junctions) {
332
+ const inst = JUNCTION.build(uJ, junctionCfg(cfg, j.shape, j.island));
333
+ inst.object.position.set(j.x, 0, j.z);
334
+ inst.object.rotation.y = j.ry;
335
+ group.add(inst.object);
336
+ kids.push({ inst, kind: 'junction', pos: new THREE.Vector3(j.x, 0, j.z), ry: j.ry });
337
+ }
338
+ for (const r of plan.roads) {
339
+ const inst = ROAD.build(u, roadCfg(cfg, r.points, r.curve));
340
+ group.add(inst.object);
341
+ kids.push({ inst, kind: 'road', pos: new THREE.Vector3(), ry: 0 });
342
+ }
343
+ for (const t of plan.traffic) {
344
+ const inst = TRAFFIC.build(uT, trafficCfg(cfg, t.points, t.curve, t.lanes ?? cfg.lanes));
345
+ group.add(inst.object);
346
+ kids.push({ inst, kind: 'traffic', pos: new THREE.Vector3(), ry: 0 });
347
+ }
348
+ for (const g of plan.grounds) {
349
+ if (!g.outlines.length)
350
+ continue;
351
+ const inst = buildGround(g, cfg, field);
352
+ group.add(inst.object);
353
+ kids.push({ inst, kind: 'ground', pos: new THREE.Vector3(), ry: 0 });
354
+ }
355
+ merge();
356
+ };
357
+ const apply = (cfg) => {
358
+ // The per-frame knobs, handed to every child as a partial config (each child applies the keys it knows).
359
+ const live = Object.create(null);
360
+ if (cfg.asphaltColor !== undefined)
361
+ live.asphaltColor = cfg.asphaltColor;
362
+ if (cfg.groundColor !== undefined)
363
+ live.groundColor = cfg.groundColor;
364
+ if (cfg.markingColor !== undefined)
365
+ live.markingColor = cfg.markingColor;
366
+ if (cfg.wear !== undefined)
367
+ live.wear = cfg.wear;
368
+ if (cfg.crossings !== undefined)
369
+ live.crossings = cfg.crossings;
370
+ if (cfg.sidewalkColor !== undefined)
371
+ live.sidewalkColor = cfg.sidewalkColor;
372
+ if (cfg.signalPaint !== undefined)
373
+ live.signalPaint = cfg.signalPaint;
374
+ if (cfg.signalCycle !== undefined)
375
+ live.signalCycle = cfg.signalCycle;
376
+ if (cfg.lampPaint !== undefined)
377
+ live.lampPaint = cfg.lampPaint;
378
+ if (cfg.lampColor !== undefined)
379
+ live.lampColor = cfg.lampColor;
380
+ if (cfg.lampRadius !== undefined)
381
+ live.lampRadius = cfg.lampRadius;
382
+ if (cfg.lampIntensity !== undefined)
383
+ live.lampIntensity = cfg.lampIntensity;
384
+ if (cfg.speed !== undefined)
385
+ live.speed = cfg.speed;
386
+ for (const k of kids)
387
+ k.inst.apply(live);
388
+ };
389
+ rebuild(c);
390
+ apply(c);
391
+ const _m = new THREE.Matrix4();
392
+ return {
393
+ object: group,
394
+ get materials() { const out = []; for (const k of kids)
395
+ out.push(...(k.inst.materials || [])); return out; },
396
+ get uniformSets() { const out = [u, uJ, uT]; for (const k of kids)
397
+ for (const s of k.inst.uniformSets || [])
398
+ if (!out.includes(s))
399
+ out.push(s); return out; },
400
+ /** One lamp target: the baked field over the whole grid (bounds in the grid's own space). */
401
+ lampTargets() { return [{ field, bounds: this.bounds() }]; },
402
+ apply,
403
+ rebuild(cfg) { rebuild(cfg); apply(cfg); },
404
+ bounds() { const b = new THREE.Box3(); for (const k of kids) {
405
+ _m.makeRotationY(k.ry).setPosition(k.pos);
406
+ b.union(k.inst.bounds().applyMatrix4(_m));
407
+ } return b; },
408
+ update(dt, camera, renderer = undefined) {
409
+ // The traffic streams share one uniform set (uTime): tick it once, not once per street.
410
+ let ticked = false;
411
+ for (const k of kids) {
412
+ if (k.kind === 'traffic') {
413
+ if (ticked)
414
+ continue;
415
+ ticked = true;
416
+ }
417
+ k.inst.update(dt, camera, renderer);
418
+ }
419
+ },
420
+ dispose() { clear(); field.texture.dispose(); },
421
+ };
422
+ }
@@ -0,0 +1,125 @@
1
+ import * as THREE from 'three';
2
+ export declare const LIGHTING: string[];
3
+ export declare const STRUCTURAL: string[];
4
+ export declare function createUniforms(): {
5
+ uSunDir: {
6
+ value: THREE.Vector3;
7
+ };
8
+ uSunColor: {
9
+ value: THREE.Color;
10
+ };
11
+ uSkyAmbient: {
12
+ value: THREE.Color;
13
+ };
14
+ uGroundAmbient: {
15
+ value: THREE.Color;
16
+ };
17
+ uNight: {
18
+ value: number;
19
+ };
20
+ } & {
21
+ uLamps: {
22
+ value: any[];
23
+ };
24
+ uLampColors: {
25
+ value: any[];
26
+ };
27
+ uLampAims: {
28
+ value: any[];
29
+ };
30
+ uLampCount: {
31
+ value: number;
32
+ };
33
+ uLampTop: {
34
+ value: number;
35
+ };
36
+ uLampField: {
37
+ value: any;
38
+ };
39
+ uLampFieldRect: {
40
+ value: THREE.Vector4;
41
+ };
42
+ uLampFieldOn: {
43
+ value: number;
44
+ };
45
+ } & {
46
+ uPaint: {
47
+ value: THREE.Color;
48
+ };
49
+ uAccent: {
50
+ value: THREE.Color;
51
+ };
52
+ uLampColor: {
53
+ value: THREE.Color;
54
+ };
55
+ uLampGlow: {
56
+ value: number;
57
+ };
58
+ uRough: {
59
+ value: number;
60
+ };
61
+ uPath: {
62
+ value: any;
63
+ };
64
+ uPathLength: {
65
+ value: number;
66
+ };
67
+ uTime: {
68
+ value: number;
69
+ };
70
+ uSpeed: {
71
+ value: number;
72
+ };
73
+ uLaneWidth: {
74
+ value: number;
75
+ };
76
+ uWidth: {
77
+ value: number;
78
+ };
79
+ uHead: {
80
+ value: THREE.Color;
81
+ };
82
+ uTail: {
83
+ value: THREE.Color;
84
+ };
85
+ uIntensity: {
86
+ value: number;
87
+ };
88
+ uSize: {
89
+ value: number;
90
+ };
91
+ };
92
+ export declare function applyConfig(u: any, c: any): void;
93
+ export declare const VERT = "\nattribute vec2 corner; // quad corner -1..1\nattribute float aLane; // lane centre offset across the road (metres, signed)\nattribute float aDir; // +1 along the path, -1 against\nattribute float aPhase; // 0..1 the car's start along the path\nattribute float aKind; // 0 head, 1 tail\nattribute float aSide; // -1 left lamp, +1 right lamp\nuniform float uSize; uniform float uNight;\nvarying vec2 vUv; varying float vKind;\n#include <fog_pars_vertex>\n\nuniform sampler2D uPath; uniform float uPathLength; uniform float uTime; uniform float uSpeed;\nconst float CAR_HALF = 2.3;\nvec3 pathAt(float s, float lane) {\n float f = clamp(s / uPathLength, 0.0, 1.0);\n vec3 p = texture2D(uPath, vec2(f, 0.25)).xyz;\n vec3 t = normalize(texture2D(uPath, vec2(f, 0.75)).xyz);\n return p + vec3(-t.z, 0.0, t.x) * lane; // to the lane: right of the path's +s direction\n}\nbool carFrame(float phase, float dir, float lane, out vec3 head, out vec3 tail) {\n float c = phase * uPathLength + dir * uSpeed * uTime;\n c = mod(mod(c, uPathLength) + uPathLength, uPathLength);\n if (c < CAR_HALF || c > uPathLength - CAR_HALF) return false;\n vec3 centre = pathAt(c, lane);\n vec3 t = texture2D(uPath, vec2(clamp(c / uPathLength, 0.0, 1.0), 0.75)).xyz;\n vec3 fx = normalize(vec3(t.x, 0.0, t.z) * dir); // the car's forward (flat)\n head = centre + fx * CAR_HALF;\n tail = centre - fx * CAR_HALF;\n return true;\n}\nvoid main() {\n vUv = corner; vKind = aKind;\n vec3 head, tail;\n if (!carFrame(aPhase, aDir, aLane, head, tail)) { gl_Position = vec4(0.0, 0.0, 2.0, 1.0); return; } // past the path's end: clipped\n // the lamp pair at the car's end, 0.75 m either side of its axis, at lamp height\n vec3 fx = normalize(vec3(head.x - tail.x, 0.0, head.z - tail.z));\n vec3 fz = vec3(-fx.z, 0.0, fx.x);\n vec3 p = (aKind < 0.5 ? head : tail) + fz * (aSide * 0.75) + vec3(0.0, 0.65, 0.0);\n vec4 mvPosition = modelViewMatrix * vec4(p, 1.0);\n // Camera-facing quad with a constant size on screen: px pixels on a 900 px tall viewport\n // (bigger for head lamps). projectionMatrix[1][1] is 1 / tan(fov / 2), so the half-size in\n // view space at depth d is px / 900 * d / P11. Clamped below so a close lamp stays a lamp.\n // The floor scales with the object (a city scaled down keeps its lamps lamp-sized).\n float sc = length(modelMatrix[0].xyz);\n float px = (aKind < 0.5 ? 11.0 : 7.0) * uSize;\n float d = max(-mvPosition.z, 0.5 * sc);\n float h = max(px / 900.0 * d / projectionMatrix[1][1], 0.09 * sc);\n mvPosition.xy += corner * h;\n gl_Position = projectionMatrix * mvPosition;\n #include <fog_vertex>\n}";
94
+ export declare const FRAG = "\nprecision highp float;\nuniform vec3 uHead; uniform vec3 uTail; uniform float uIntensity; uniform float uNight;\nvarying vec2 vUv; varying float vKind;\n#include <fog_pars_fragment>\nvoid main() {\n float r = length(vUv);\n if (r > 1.0) discard;\n // A hot core with a soft halo; premultiplied, so it adds light without a square.\n float core = 1.0 / exp(r * r * 9.0);\n float halo = 1.0 / exp(r * 2.2) * 0.35;\n float a = clamp(core + halo, 0.0, 1.0);\n vec3 c = mix(uHead, uTail, vKind) * (vKind < 0.5 ? 2.4 : 1.6) * uIntensity * uNight;\n vec3 col = c * (core * 1.0 + halo);\n gl_FragColor = vec4(col, a * uNight);\n #include <tonemapping_fragment>\n #include <colorspace_fragment>\n #include <fog_fragment>\n}";
95
+ export declare const CAR_VERT = "\nattribute float aEmissive; attribute float aAccent;\nattribute float aLane; attribute float aDir; attribute float aPhase; attribute vec3 aPaint;\nvarying vec3 vN; varying vec3 vP; varying float vE; varying float vA; varying vec3 vIC;\n#include <fog_pars_vertex>\n\nuniform sampler2D uPath; uniform float uPathLength; uniform float uTime; uniform float uSpeed;\nconst float CAR_HALF = 2.3;\nvec3 pathAt(float s, float lane) {\n float f = clamp(s / uPathLength, 0.0, 1.0);\n vec3 p = texture2D(uPath, vec2(f, 0.25)).xyz;\n vec3 t = normalize(texture2D(uPath, vec2(f, 0.75)).xyz);\n return p + vec3(-t.z, 0.0, t.x) * lane; // to the lane: right of the path's +s direction\n}\nbool carFrame(float phase, float dir, float lane, out vec3 head, out vec3 tail) {\n float c = phase * uPathLength + dir * uSpeed * uTime;\n c = mod(mod(c, uPathLength) + uPathLength, uPathLength);\n if (c < CAR_HALF || c > uPathLength - CAR_HALF) return false;\n vec3 centre = pathAt(c, lane);\n vec3 t = texture2D(uPath, vec2(clamp(c / uPathLength, 0.0, 1.0), 0.75)).xyz;\n vec3 fx = normalize(vec3(t.x, 0.0, t.z) * dir); // the car's forward (flat)\n head = centre + fx * CAR_HALF;\n tail = centre - fx * CAR_HALF;\n return true;\n}\nvoid main() {\n vE = aEmissive; vA = aAccent; vIC = aPaint; vN = vec3(0.0, 1.0, 0.0); vP = vec3(0.0);\n vec3 head, tail;\n if (!carFrame(aPhase, aDir, aLane, head, tail)) { gl_Position = vec4(0.0, 0.0, 2.0, 1.0); return; } // past the path's end: clipped\n // the body between its lamps: centred on them, facing from tail to head (so a turn bends both alike)\n vec3 fx = normalize(vec3(head.x - tail.x, 0.0, head.z - tail.z));\n vec3 fz = vec3(-fx.z, 0.0, fx.x);\n vec3 c = (head + tail) * 0.5;\n vec3 local = fx * position.x + vec3(0.0, position.y, 0.0) + fz * position.z;\n vec4 wp = modelMatrix * vec4(c + local, 1.0);\n vP = wp.xyz;\n vN = normalize(mat3(modelMatrix) * (fx * normal.x + vec3(0.0, normal.y, 0.0) + fz * normal.z));\n vec4 mvPosition = viewMatrix * wp;\n gl_Position = projectionMatrix * mvPosition;\n #include <fog_vertex>\n}";
96
+ export declare function createCarMaterial(u: any): THREE.ShaderMaterial;
97
+ export declare function createMaterial(u: any): THREE.ShaderMaterial;
98
+ /** The path as a 2-row float texture: positions and tangents sampled uniformly over the arc length. */
99
+ export declare function pathTexture(samples: any): THREE.DataTexture;
100
+ /** The cars as instance attributes: per lane, density x length / 100 cars with jittered spacing; 4 sprites each. */
101
+ export declare function carInstances(c: any, length: any): {
102
+ lane: any[];
103
+ dir: any[];
104
+ phase: any[];
105
+ kind: any[];
106
+ side: any[];
107
+ count: number;
108
+ car: {
109
+ lane: any[];
110
+ dir: any[];
111
+ phase: any[];
112
+ paint: any[];
113
+ };
114
+ };
115
+ export declare function build(u: any, c: any): {
116
+ object: THREE.Group<THREE.Object3DEventMap>;
117
+ materials: THREE.ShaderMaterial[];
118
+ uniformSets: any[];
119
+ apply(cfg: any): void;
120
+ rebuild(cfg: any): void;
121
+ bounds(): any;
122
+ update(dt: any): void;
123
+ dispose(): void;
124
+ };
125
+ //# sourceMappingURL=traffic.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"traffic.d.ts","sourceRoot":"","sources":["../../../../src/components/urban/core/traffic.ts"],"names":[],"mappings":"AAoBA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAG/B,eAAO,MAAM,QAAQ,UAA2B,CAAC;AAEjD,eAAO,MAAM,UAAU,UAAqF,CAAC;AAE7G,wBAAgB,cAAc;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAmB7B;AAED,wBAAgB,WAAW,CAAC,CAAC,KAAA,EAAE,CAAC,KAAA,QAO/B;AA6BD,eAAO,MAAM,IAAI,wsFA+Bf,CAAC;AAEH,eAAO,MAAM,IAAI,ovBAkBf,CAAC;AAGH,eAAO,MAAM,QAAQ,mnEAqBnB,CAAC;AACH,wBAAgB,iBAAiB,CAAC,CAAC,KAAA,wBAElC;AAED,wBAAgB,cAAc,CAAC,CAAC,KAAA,wBAK/B;AAED,uGAAuG;AACvG,wBAAgB,WAAW,CAAC,OAAO,KAAA,qBAalC;AAED,oHAAoH;AACpH,wBAAgB,YAAY,CAAC,CAAC,KAAA,EAAE,MAAM,KAAA;;;;;;;;;;;;;EAmBrC;AAED,wBAAgB,KAAK,CAAC,CAAC,KAAA,EAAE,CAAC,KAAA;;;;;;;;;EAiEzB"}