@3driseai/3drise-viewer 0.1.42 → 0.1.44

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 (408) 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/utils/composerHostedPass.d.ts +74 -0
  370. package/dist/utils/composerHostedPass.d.ts.map +1 -0
  371. package/dist/utils/composerHostedPass.js +63 -0
  372. package/dist/utils/geometryScript.d.ts +17 -0
  373. package/dist/utils/geometryScript.d.ts.map +1 -0
  374. package/dist/utils/geometryScript.js +92 -0
  375. package/dist/utils/geometryScript.worker.d.ts +2 -0
  376. package/dist/utils/geometryScript.worker.d.ts.map +1 -0
  377. package/dist/utils/geometryScript.worker.js +42 -0
  378. package/dist/utils/groundRegistry.d.ts +11 -0
  379. package/dist/utils/groundRegistry.d.ts.map +1 -0
  380. package/dist/utils/groundRegistry.js +39 -0
  381. package/dist/utils/instancingSupport.d.ts +9 -0
  382. package/dist/utils/instancingSupport.d.ts.map +1 -0
  383. package/dist/utils/instancingSupport.js +13 -0
  384. package/dist/utils/landPatch.d.ts +26 -5
  385. package/dist/utils/landPatch.d.ts.map +1 -1
  386. package/dist/utils/landPatch.js +124 -9
  387. package/dist/utils/layoutPlacement.d.ts +30 -0
  388. package/dist/utils/layoutPlacement.d.ts.map +1 -0
  389. package/dist/utils/layoutPlacement.js +113 -0
  390. package/dist/utils/linkRegistry.d.ts +15 -0
  391. package/dist/utils/linkRegistry.d.ts.map +1 -0
  392. package/dist/utils/linkRegistry.js +11 -0
  393. package/dist/utils/shapes.d.ts +28 -2
  394. package/dist/utils/shapes.d.ts.map +1 -1
  395. package/dist/utils/shapes.js +32 -3
  396. package/dist/utils/sharedParts.d.ts +61 -0
  397. package/dist/utils/sharedParts.d.ts.map +1 -0
  398. package/dist/utils/sharedParts.js +268 -0
  399. package/dist/utils/svgAsset.d.ts +6 -0
  400. package/dist/utils/svgAsset.d.ts.map +1 -0
  401. package/dist/utils/svgAsset.js +46 -0
  402. package/dist/utils/waterLight.d.ts +29 -0
  403. package/dist/utils/waterLight.d.ts.map +1 -0
  404. package/dist/utils/waterLight.js +67 -0
  405. package/dist/utils/waterReflection.d.ts +185 -0
  406. package/dist/utils/waterReflection.d.ts.map +1 -0
  407. package/dist/utils/waterReflection.js +616 -0
  408. package/package.json +6 -4
@@ -0,0 +1,268 @@
1
+ // =============================================================================
2
+ // sharedParts — draw one master object at many places, sharing its geometry and material
3
+ // =============================================================================
4
+ //
5
+ // The machinery behind layouts (InstancedLayout) and linked instances (LinkedSource).
6
+ // A master is an object rendered once, as itself, so material application, material
7
+ // clips, model-part tracks and object effects keep working on it untouched. Its
8
+ // meshes stay in the graph but are taken off the render layers (layers.mask = 0).
9
+ //
10
+ // For each master mesh (a "part") the drawing is either
11
+ // - instanced: one InstancedMesh for every slot, sharing the part's geometry and
12
+ // material by reference (instance matrix = slot × the part's place in its master);
13
+ // - mirrors: one plain Mesh per slot sharing geometry, material and depth materials
14
+ // — for objects that instance their own insides (vegetation's leaves are
15
+ // InstancedBufferGeometry with per-leaf attributes) and cannot be instanced again.
16
+ // Every part of such a master is mirrored, so the parts of one slot stay together.
17
+ //
18
+ // Each frame `sync` copies over whatever the master swapped (material, geometry,
19
+ // visibility, shadow flags) and rewrites matrices only when a slot or a part moved.
20
+ // Drawn meshes carry __opFxHelper (effects act on the master; the copies show the
21
+ // result through the shared material). The draw root carries SELF_OWNED_MATERIAL_KEY
22
+ // (useMaterialApplication skips it: no material clones per copy).
23
+ import { Color, InstancedMesh, Matrix4, Mesh } from 'three';
24
+ import { SELF_OWNED_MATERIAL_KEY, traverseSkippingEdgesAndEffects } from '@3driseai/3drise-core';
25
+ import { instancingSupported } from './instancingSupport.js';
26
+ const _rel = new Matrix4();
27
+ const _inv = new Matrix4();
28
+ const _m = new Matrix4();
29
+ const ZERO = new Matrix4().makeScale(0, 0, 0);
30
+ const _c = new Color();
31
+ const _base = new Color();
32
+ const _hsl = { h: 0, s: 0, l: 0 };
33
+ export const sameMatrix = (a, b) => {
34
+ const x = a.elements, y = b.elements;
35
+ for (let i = 0; i < 16; i++)
36
+ if (Math.abs(x[i] - y[i]) > 1e-6)
37
+ return false;
38
+ return true;
39
+ };
40
+ /** Visibility of a part inside its master: its own flag and every ancestor up to the master. */
41
+ function partVisible(mesh, master) {
42
+ for (let o = mesh; o && o !== master; o = o.parent)
43
+ if (!o.visible)
44
+ return false;
45
+ return true;
46
+ }
47
+ const colorOf = (material) => {
48
+ const m = (Array.isArray(material) ? material.find((x) => x?.color?.isColor) : material);
49
+ return m?.color?.isColor ? m.color : null;
50
+ };
51
+ /** The meshes of a master, whether they must be mirrored, and why they cannot be shared (if they cannot). */
52
+ export function collectParts(master, forceMirrors) {
53
+ const meshes = [];
54
+ let reason;
55
+ traverseSkippingEdgesAndEffects(master, true, (c) => {
56
+ if (reason || c === master || c.userData?.__opFxHelper)
57
+ return;
58
+ if (c.isSkinnedMesh)
59
+ reason = 'a skinned (animated-rig) mesh';
60
+ else if (c.isPoints || c.isLine)
61
+ reason = 'a points / line part';
62
+ else if (c.isMesh && !c.isInstancedMesh && c.geometry?.attributes?.position)
63
+ meshes.push(c); // not an empty wrapper
64
+ });
65
+ // an object that instances its own insides is mirrored, whole
66
+ const mirrors = forceMirrors || meshes.some(m => m.geometry.isInstancedBufferGeometry);
67
+ if (!reason && !mirrors) {
68
+ for (const c of meshes) {
69
+ const mats = Array.isArray(c.material) ? c.material : [c.material];
70
+ if (mats.some((m) => m && !instancingSupported(m))) {
71
+ reason = `a shader material without instancing (${mats.map((m) => m?.type).join(', ')})`;
72
+ break;
73
+ }
74
+ }
75
+ }
76
+ return { meshes, mirrors, reason };
77
+ }
78
+ function syncMirror(m, source) {
79
+ if (m.material !== source.material)
80
+ m.material = source.material;
81
+ if (m.geometry !== source.geometry)
82
+ m.geometry = source.geometry;
83
+ m.customDepthMaterial = source.customDepthMaterial;
84
+ m.customDistanceMaterial = source.customDistanceMaterial;
85
+ m.castShadow = source.castShadow;
86
+ m.receiveShadow = source.receiveShadow;
87
+ m.frustumCulled = source.frustumCulled;
88
+ m.renderOrder = source.renderOrder;
89
+ // a part may install per-copy behaviour on each of its mirrors (vegetation detail levels: per-draw
90
+ // callbacks and a per-copy bounding sphere), once per mirror
91
+ const setup = source.userData.mirrorSetup;
92
+ if (setup && m.userData.mirrorSetupFor !== setup) {
93
+ setup(m);
94
+ m.userData.mirrorSetupFor = setup;
95
+ }
96
+ }
97
+ /** Draws one master at `count` slots under `drawRoot`. One per master (a layout's variant, a link source). */
98
+ export class SharedParts {
99
+ drawRoot;
100
+ tag;
101
+ forceMirrors;
102
+ parts = [];
103
+ /** Bumps when the part set changes (pick proxies rebuild on it). */
104
+ version = 0;
105
+ signature = '';
106
+ count = 0;
107
+ constructor(drawRoot,
108
+ /** tagged on every drawn mesh as userData.layoutVariant (picking maps a hit back to its slot) */
109
+ tag, forceMirrors = false) {
110
+ this.drawRoot = drawRoot;
111
+ this.tag = tag;
112
+ this.forceMirrors = forceMirrors;
113
+ drawRoot.userData[SELF_OWNED_MATERIAL_KEY] = true;
114
+ }
115
+ /** Draws the master at every slot. Returns why it cannot be shared (the caller falls back), or null. */
116
+ sync(master, input) {
117
+ let slotsDirty = input.slotsDirty;
118
+ if (input.checkParts || !this.signature || input.count !== this.count) {
119
+ const { meshes, mirrors, reason } = collectParts(master, this.forceMirrors);
120
+ if (reason) {
121
+ this.dispose();
122
+ return reason;
123
+ }
124
+ const sig = (mirrors ? 'm' : 'i') + input.count + '|' + meshes.map(m => m.uuid + ':' + m.geometry.uuid).join(';');
125
+ if (sig !== this.signature) {
126
+ this.signature = sig;
127
+ this.count = input.count;
128
+ this.rebuild(meshes, mirrors, input.count);
129
+ slotsDirty = true;
130
+ }
131
+ }
132
+ master.updateWorldMatrix(true, false);
133
+ _inv.copy(master.matrixWorld).invert();
134
+ for (const p of this.parts) {
135
+ const { source, inst, mirrors } = p;
136
+ if (source.layers.mask !== 0)
137
+ source.layers.disableAll(); // something re-enabled it
138
+ source.updateWorldMatrix(false, false);
139
+ _rel.multiplyMatrices(_inv, source.matrixWorld);
140
+ const relDirty = !p.relValid || !sameMatrix(_rel, p.rel);
141
+ if (relDirty) {
142
+ p.rel.copy(_rel);
143
+ p.relValid = true;
144
+ }
145
+ const vis = partVisible(source, master);
146
+ if (mirrors) {
147
+ for (let k = 0; k < mirrors.length; k++) {
148
+ const m = mirrors[k];
149
+ syncMirror(m, source);
150
+ const slot = input.slot(k);
151
+ m.visible = vis && !!slot;
152
+ if (slot && (relDirty || slotsDirty)) {
153
+ m.matrix.multiplyMatrices(slot, p.rel);
154
+ m.matrixWorldNeedsUpdate = true;
155
+ }
156
+ }
157
+ continue;
158
+ }
159
+ if (!inst)
160
+ continue;
161
+ if (inst.material !== source.material) {
162
+ inst.material = source.material;
163
+ p.tintFor = '';
164
+ }
165
+ if (inst.geometry !== source.geometry) {
166
+ inst.geometry = source.geometry;
167
+ inst.boundingSphere = null;
168
+ inst.boundingBox = null;
169
+ }
170
+ inst.visible = vis;
171
+ inst.castShadow = source.castShadow;
172
+ inst.receiveShadow = source.receiveShadow;
173
+ inst.customDepthMaterial = source.customDepthMaterial;
174
+ inst.customDistanceMaterial = source.customDistanceMaterial;
175
+ if (relDirty || slotsDirty) {
176
+ for (let k = 0; k < input.count; k++) {
177
+ const slot = input.slot(k);
178
+ inst.setMatrixAt(k, slot ? _m.multiplyMatrices(slot, p.rel) : ZERO);
179
+ }
180
+ inst.instanceMatrix.needsUpdate = true;
181
+ inst.boundingSphere = null; // frustum culling / picking recompute over the instances
182
+ inst.boundingBox = null;
183
+ }
184
+ this.writeTint(p, input);
185
+ }
186
+ return null;
187
+ }
188
+ rebuild(meshes, mirrored, count) {
189
+ this.disposeParts(false);
190
+ for (const source of meshes) {
191
+ if (mirrored) {
192
+ const list = [];
193
+ for (let k = 0; k < count; k++) {
194
+ const m = new Mesh(source.geometry, source.material);
195
+ m.name = `layout:${source.name || 'part'}#${k}`;
196
+ m.userData.__opFxHelper = true;
197
+ m.userData.layoutVariant = this.tag;
198
+ m.userData.layoutCopy = k;
199
+ m.matrixAutoUpdate = false;
200
+ syncMirror(m, source);
201
+ this.drawRoot.add(m);
202
+ list.push(m);
203
+ }
204
+ source.layers.disableAll();
205
+ this.parts.push({ source, inst: null, mirrors: list, rel: new Matrix4(), relValid: false, tintFor: '', tintKey: null });
206
+ continue;
207
+ }
208
+ const inst = new InstancedMesh(source.geometry, source.material, Math.max(1, count));
209
+ inst.count = count;
210
+ inst.name = `layout:${source.name || 'part'}`;
211
+ inst.userData.__opFxHelper = true;
212
+ inst.userData.layoutVariant = this.tag;
213
+ inst.castShadow = source.castShadow;
214
+ inst.receiveShadow = source.receiveShadow;
215
+ inst.renderOrder = source.renderOrder;
216
+ this.drawRoot.add(inst);
217
+ source.layers.disableAll();
218
+ this.parts.push({ source, inst, mirrors: null, rel: new Matrix4(), relValid: false, tintFor: '', tintKey: null });
219
+ }
220
+ this.version++;
221
+ }
222
+ writeTint(p, input) {
223
+ const inst = p.inst;
224
+ const tinted = !!input.tint?.amount;
225
+ const base = colorOf(inst.material);
226
+ const hex = tinted && base ? base.getHexString() : '-';
227
+ const key = input.tint?.key ?? null;
228
+ if (p.tintFor === hex && p.tintKey === key)
229
+ return;
230
+ p.tintFor = hex;
231
+ p.tintKey = key;
232
+ if (!tinted || !base) {
233
+ // no instanceColor at all: three switches the program back (USE_INSTANCING_COLOR off)
234
+ if (inst.instanceColor)
235
+ inst.instanceColor = null;
236
+ return;
237
+ }
238
+ _base.copy(base).getHSL(_hsl);
239
+ for (let k = 0; k < input.count; k++) {
240
+ const [dh, dl] = input.tint.of(k);
241
+ _c.setHSL((((_hsl.h + dh) % 1) + 1) % 1, _hsl.s, Math.min(1, Math.max(0, _hsl.l + dl)));
242
+ // instanceColor multiplies the material colour: store the ratio
243
+ _c.setRGB(_base.r > 1e-4 ? _c.r / _base.r : _c.r, _base.g > 1e-4 ? _c.g / _base.g : _c.g, _base.b > 1e-4 ? _c.b / _base.b : _c.b);
244
+ inst.setColorAt(k, _c);
245
+ }
246
+ if (inst.instanceColor)
247
+ inst.instanceColor.needsUpdate = true;
248
+ }
249
+ disposeParts(restore) {
250
+ for (const p of this.parts) {
251
+ if (p.inst) {
252
+ p.inst.removeFromParent();
253
+ p.inst.dispose();
254
+ } // instance buffers only: geometry / material are the master's
255
+ p.mirrors?.forEach(m => m.removeFromParent()); // share everything: nothing to dispose
256
+ if (restore)
257
+ p.source.layers.enableAll(); // back on the render layers
258
+ }
259
+ this.parts = [];
260
+ }
261
+ /** Takes the drawing down and puts the master's meshes back on the render layers. */
262
+ dispose() {
263
+ this.disposeParts(true);
264
+ this.signature = '';
265
+ this.count = 0;
266
+ this.version++;
267
+ }
268
+ }
@@ -0,0 +1,6 @@
1
+ /** The markup when it is already loaded, else null (and the fetch is started). */
2
+ export declare function svgAssetSync(url: string | undefined): string | null;
3
+ export declare const svgAssetError: (url: string | undefined) => string | undefined;
4
+ /** Loads (once) and caches an .svg file's markup. */
5
+ export declare function loadSvgAsset(url: string): Promise<string>;
6
+ //# sourceMappingURL=svgAsset.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"svgAsset.d.ts","sourceRoot":"","sources":["../../src/utils/svgAsset.ts"],"names":[],"mappings":"AAcA,kFAAkF;AAClF,wBAAgB,YAAY,CAAC,GAAG,EAAE,MAAM,GAAG,SAAS,GAAG,MAAM,GAAG,IAAI,CAMnE;AAED,eAAO,MAAM,aAAa,GAAI,KAAK,MAAM,GAAG,SAAS,KAAG,MAAM,GAAG,SAAgD,CAAC;AAElH,qDAAqD;AACrD,wBAAgB,YAAY,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC,CAiBzD"}
@@ -0,0 +1,46 @@
1
+ // =============================================================================
2
+ // SVG assets for the `svg` mesh shape — fetched once, read synchronously by the shape generator
3
+ // =============================================================================
4
+ //
5
+ // Shape generators are synchronous (utils/shapes.ts); an uploaded .svg is a URL, so its
6
+ // markup is cached here. The first build with an unloaded URL yields an empty geometry
7
+ // and starts the fetch; GeometryShape re-renders when it lands (useAsyncShapeTick).
8
+ //
9
+ import { toCdn } from '@3driseai/3drise-core';
10
+ const loaded = new Map();
11
+ const pending = new Map();
12
+ const failed = new Map();
13
+ /** The markup when it is already loaded, else null (and the fetch is started). */
14
+ export function svgAssetSync(url) {
15
+ if (!url)
16
+ return null;
17
+ const hit = loaded.get(url);
18
+ if (hit !== undefined)
19
+ return hit;
20
+ if (!failed.has(url))
21
+ void loadSvgAsset(url).catch(() => undefined);
22
+ return null;
23
+ }
24
+ export const svgAssetError = (url) => (url ? failed.get(url) : undefined);
25
+ /** Loads (once) and caches an .svg file's markup. */
26
+ export function loadSvgAsset(url) {
27
+ const hit = loaded.get(url);
28
+ if (hit !== undefined)
29
+ return Promise.resolve(hit);
30
+ let p = pending.get(url);
31
+ if (!p) {
32
+ p = fetch(toCdn(url)).then(async (r) => {
33
+ if (!r.ok)
34
+ throw new Error(`SVG file: HTTP ${r.status}`);
35
+ const text = await r.text();
36
+ if (!/<svg[\s>]/i.test(text))
37
+ throw new Error('The file is not an SVG.');
38
+ loaded.set(url, text);
39
+ failed.delete(url);
40
+ pending.delete(url);
41
+ return text;
42
+ }).catch((e) => { failed.set(url, e?.message ?? String(e)); pending.delete(url); throw e; });
43
+ pending.set(url, p);
44
+ }
45
+ return p;
46
+ }
@@ -0,0 +1,29 @@
1
+ import * as THREE from 'three';
2
+ import type { SkySettings, TimeSettings } from '@3driseai/3drise-core';
3
+ import type { CloudSunState } from '../hooks/useCloudSun';
4
+ import { type MoonState } from './skyMoon';
5
+ /** Moonlight on the water relative to the sun's (sunIntensity 1). The key light
6
+ * runs the moon at ~0.1 of the sun; the water gets a little more so the glitter
7
+ * path reads at night. Tuning knob. */
8
+ export declare const MOON_WATER_STRENGTH = 0.15;
9
+ export interface WaterLightScratch {
10
+ moon: MoonState;
11
+ }
12
+ export declare function createWaterLightScratch(): WaterLightScratch;
13
+ /**
14
+ * Light every water surface the same way: the scene sun (`useCloudSun`, so it
15
+ * follows the Environment clock — day, dusk, night) with the sky actually drawn
16
+ * as the ambient, and the moon's glitter path once the sun is down. Shared by
17
+ * the ocean surface and the `water` material family; a material that reads only
18
+ * some of these uniforms simply ignores the rest.
19
+ *
20
+ * Writes: u_sunDir, u_sunColor, u_sunIntensity, u_skyAmbient, u_groundAmbient
21
+ * (and the Preetham parameters, for shaders that draw the sky), u_skyBrightness,
22
+ * u_moonDir, u_moonColor.
23
+ *
24
+ * The two ambients and u_skyBrightness carry the sky dome's own brightness
25
+ * (skyBrightnessForSunElevation, what SkyMesh multiplies by): the analytic sky
26
+ * never darkens on its own after sunset, and water is mostly reflected sky.
27
+ */
28
+ export declare function applyWaterLight(material: THREE.ShaderMaterial, sun: CloudSunState, sunIntensity: number, timeSettings: TimeSettings | undefined, skySettings: SkySettings | undefined, scratch: WaterLightScratch): void;
29
+ //# sourceMappingURL=waterLight.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"waterLight.d.ts","sourceRoot":"","sources":["../../src/utils/waterLight.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAC/B,OAAO,KAAK,EAAE,WAAW,EAAE,YAAY,EAAE,MAAM,uBAAuB,CAAC;AAEvE,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,sBAAsB,CAAC;AAG1D,OAAO,EAAkD,KAAK,SAAS,EAAE,MAAM,WAAW,CAAC;AAE3F;;wCAEwC;AACxC,eAAO,MAAM,mBAAmB,OAAO,CAAC;AAWxC,MAAM,WAAW,iBAAiB;IAC9B,IAAI,EAAE,SAAS,CAAC;CACnB;AAED,wBAAgB,uBAAuB,IAAI,iBAAiB,CAE3D;AAED;;;;;;;;;;;;;;GAcG;AACH,wBAAgB,eAAe,CAC3B,QAAQ,EAAE,KAAK,CAAC,cAAc,EAC9B,GAAG,EAAE,aAAa,EAClB,YAAY,EAAE,MAAM,EACpB,YAAY,EAAE,YAAY,GAAG,SAAS,EACtC,WAAW,EAAE,WAAW,GAAG,SAAS,EACpC,OAAO,EAAE,iBAAiB,GAC3B,IAAI,CA0BN"}
@@ -0,0 +1,67 @@
1
+ import * as THREE from 'three';
2
+ import { skyBrightnessForSunElevation } from '@3driseai/3drise-core';
3
+ import { applySunUniforms } from './cloudUniforms.js';
4
+ import { applyTerrainAmbient } from './terrainUniforms.js';
5
+ import { resolveMoon, moonlightFactor, MOON_LIGHT_COLOR } from './skyMoon.js';
6
+ /** Moonlight on the water relative to the sun's (sunIntensity 1). The key light
7
+ * runs the moon at ~0.1 of the sun; the water gets a little more so the glitter
8
+ * path reads at night. Tuning knob. */
9
+ export const MOON_WATER_STRENGTH = 0.15;
10
+ /** Sun elevation (deg) over which direct sunlight on the water fades out — the
11
+ * same window SunLight uses for the key light. */
12
+ const SUN_FADE_START = -1;
13
+ const SUN_FADE_END = 4;
14
+ const smooth01 = (edge0, edge1, x) => {
15
+ const t = Math.max(0, Math.min(1, (x - edge0) / (edge1 - edge0)));
16
+ return t * t * (3 - 2 * t);
17
+ };
18
+ export function createWaterLightScratch() {
19
+ return { moon: { direction: new THREE.Vector3(), illumination: 0 } };
20
+ }
21
+ /**
22
+ * Light every water surface the same way: the scene sun (`useCloudSun`, so it
23
+ * follows the Environment clock — day, dusk, night) with the sky actually drawn
24
+ * as the ambient, and the moon's glitter path once the sun is down. Shared by
25
+ * the ocean surface and the `water` material family; a material that reads only
26
+ * some of these uniforms simply ignores the rest.
27
+ *
28
+ * Writes: u_sunDir, u_sunColor, u_sunIntensity, u_skyAmbient, u_groundAmbient
29
+ * (and the Preetham parameters, for shaders that draw the sky), u_skyBrightness,
30
+ * u_moonDir, u_moonColor.
31
+ *
32
+ * The two ambients and u_skyBrightness carry the sky dome's own brightness
33
+ * (skyBrightnessForSunElevation, what SkyMesh multiplies by): the analytic sky
34
+ * never darkens on its own after sunset, and water is mostly reflected sky.
35
+ */
36
+ export function applyWaterLight(material, sun, sunIntensity, timeSettings, skySettings, scratch) {
37
+ applySunUniforms(material, sun, sunIntensity);
38
+ // Overwrites the two ambient colours applySunUniforms just set. Those are
39
+ // the cloud curve, tuned for cloud interiors; water has to be lit by — and
40
+ // reflect — the sky actually being drawn behind it, or a sunset sea comes
41
+ // out black under a blazing sky.
42
+ applyTerrainAmbient(material, sun);
43
+ // The moon's glitter path and light on the water, from the same moon as the
44
+ // key light and the disc (resolveMoon), and the same strength curve
45
+ // (moonlightFactor), so all three appear and fade together.
46
+ const m = resolveMoon(timeSettings, sun.direction, scratch.moon);
47
+ const sunElevation = THREE.MathUtils.radToDeg(Math.asin(THREE.MathUtils.clamp(sun.direction.y, -1, 1)));
48
+ const k = MOON_WATER_STRENGTH * moonlightFactor(sunElevation, m) * (skySettings?.sunSystem?.moonIntensity ?? 1);
49
+ const u = material.uniforms;
50
+ // The sun's own light dies at the horizon, as the key light's does (SunLight
51
+ // fades over the same degrees): computeCloudSun's colour stays bright for a
52
+ // sun well below it, and a quarter of that lit every water body at midnight.
53
+ const sunUp = smooth01(SUN_FADE_START, SUN_FADE_END, sunElevation);
54
+ if (u.u_sunIntensity)
55
+ u.u_sunIntensity.value = sunIntensity * sunUp;
56
+ const bright = skyBrightnessForSunElevation(sunElevation);
57
+ if (u.u_skyBrightness)
58
+ u.u_skyBrightness.value = bright;
59
+ if (u.u_skyAmbient)
60
+ u.u_skyAmbient.value.multiplyScalar(bright);
61
+ if (u.u_groundAmbient)
62
+ u.u_groundAmbient.value.multiplyScalar(bright);
63
+ if (u.u_moonDir)
64
+ u.u_moonDir.value.copy(m.direction);
65
+ if (u.u_moonColor)
66
+ u.u_moonColor.value.setRGB(MOON_LIGHT_COLOR.r * k, MOON_LIGHT_COLOR.g * k, MOON_LIGHT_COLOR.b * k);
67
+ }
@@ -0,0 +1,185 @@
1
+ import * as THREE from 'three';
2
+ import type { RootState } from '@react-three/fiber';
3
+ /**
4
+ * One reflection for all the water in a scene.
5
+ *
6
+ * Every water surface — the world ocean, a placed body, a mesh plane with the
7
+ * `water` material family — used to render the whole scene again for its own
8
+ * reflection (a six-face cube camera per plane: ~6x the scene's draw calls each,
9
+ * five pools took a 60 fps city to 11). Now a surface ASKS for a reflection and
10
+ * at most one gets it per frame:
11
+ *
12
+ * - the world ocean, when it asks (`reflection: 'planar'`);
13
+ * - else the planar-mode body that covers the most screen — area over distance
14
+ * squared — as seen from the camera that frame;
15
+ * - every other surface shades its reflection from the sky it is drawn under
16
+ * (`'env'`), or from nothing (`'off'`).
17
+ *
18
+ * The winner renders ONE mirrored view of the scene into a half-resolution
19
+ * target from its mesh's `onBeforeRender` (never a positive-priority useFrame:
20
+ * the cloud pass owns the render loop, see the ocean plan §9), and samples it
21
+ * with a world-space texture matrix. The two water shaders read the same three
22
+ * uniforms (`applyWaterReflection`), so the legacy material and the ocean
23
+ * surface cannot drift apart on this.
24
+ */
25
+ export type WaterReflectionMode = 'planar' | 'baked' | 'env' | 'off';
26
+ /** 0 off, 1 the sky, 2 the planar target, 3 the baked probe. What the shaders switch on. */
27
+ export declare const WATER_REFLECTION_UNIFORM: Record<WaterReflectionMode, number>;
28
+ export interface WaterReflectionSurface {
29
+ id: string;
30
+ /** The world ocean: wins outright when it asks for planar. */
31
+ world?: boolean;
32
+ /** The surface's root. Its world position is the plane's point, its world
33
+ * scale sizes the area, and it is what the pass hides while it renders. */
34
+ object: THREE.Object3D;
35
+ /** Extent before the transform's scale, in local units (a body's `size`,
36
+ * a plane's geometry). Ignored for the world ocean. */
37
+ size: () => [number, number];
38
+ /** Read every frame, so a live drag of the knob takes effect at once. */
39
+ mode: () => WaterReflectionMode;
40
+ /** Whether any of the surface's pixels passed the depth test last frame
41
+ * (a WaterVisibility query). Absent = assumed visible (the world ocean). */
42
+ visible?: () => boolean;
43
+ }
44
+ export declare function noteWaterViewer(camera: THREE.Camera): void;
45
+ /** The view camera's position as last noted, or null before the first draw. */
46
+ export declare function waterViewerPosition(): THREE.Vector3 | null;
47
+ /** Register a surface for the per-frame election. Returns the unregister. */
48
+ export declare function registerWaterSurface(surface: WaterReflectionSurface): () => void;
49
+ /**
50
+ * Which surface owns the reflection this frame. Computed once per frame (keyed
51
+ * on the frame clock, which R3F advances once before any useFrame runs), so every
52
+ * surface asking in the same frame gets the same answer.
53
+ */
54
+ export declare function electedWaterSurface(state: RootState): string | null;
55
+ export declare function isWaterMirrorPass(): boolean;
56
+ /**
57
+ * A WebGL2 occlusion query around a water body's draw (begin at the end of its
58
+ * onBeforeRender, end in onAfterRender). The answer arrives a frame or two later
59
+ * and drives the election: a pond hidden behind the city is drawn (it is in the
60
+ * view frustum) but none of its pixels pass, so it gets no mirror. A body whose
61
+ * mesh was not drawn at all last frame (frustum-culled) is not visible either.
62
+ * WebGL1, or before the first answer: visible.
63
+ */
64
+ export declare class WaterVisibility {
65
+ private gl;
66
+ private active;
67
+ private readonly pending;
68
+ private readonly free;
69
+ private passed;
70
+ private frame;
71
+ private drawnAt;
72
+ /** Once per frame, before the render (useFrame). */
73
+ tick(): void;
74
+ /** Visible as of the latest answer, and drawn in the last frame or two. */
75
+ isVisible(): boolean;
76
+ begin(renderer: THREE.WebGLRenderer): void;
77
+ end(): void;
78
+ private poll;
79
+ dispose(): void;
80
+ }
81
+ /**
82
+ * Mirrors the camera about a horizontal plane and renders the scene into a
83
+ * target (the three.js Reflector construction: mirrored camera, oblique near
84
+ * plane so nothing under the water leaks into the mirror, bias matrix so the
85
+ * fragment shader can project a world position straight into the texture).
86
+ */
87
+ export declare class PlanarReflector {
88
+ readonly target: THREE.WebGLRenderTarget;
89
+ readonly textureMatrix: THREE.Matrix4;
90
+ private readonly camera;
91
+ private rendering;
92
+ /** Scratch for the outline clip (4 corners in, at most 8 points out). */
93
+ private readonly viewPts;
94
+ private readonly clipped;
95
+ /** True after a pass this frame actually drew; false when the camera was
96
+ * under the plane and the target holds nothing to sample. */
97
+ valid: boolean;
98
+ constructor();
99
+ dispose(): void;
100
+ /**
101
+ * @param hide the water mesh (or its root) — invisible while the mirror renders
102
+ * @param point a world point on the water plane (the body's root position)
103
+ * @param scale target size as a fraction of the drawing buffer (quality.reflectionScale)
104
+ * @param corners the water's outline on the plane, world space (a placed body's
105
+ * four corners). The mirror is then rendered only for the rectangle they
106
+ * cover in the mirror view — a sub-frustum (setViewOffset) and a target
107
+ * that size — so everything not reflected in THIS water is frustum-culled
108
+ * by the renderer and the target holds no unused pixels. null (the world
109
+ * ocean, which covers everything below the horizon) renders the full view.
110
+ */
111
+ render(renderer: THREE.WebGLRenderer, scene: THREE.Scene, camera: THREE.Camera, hide: THREE.Object3D, point: THREE.Vector3, scale: number, corners?: THREE.Vector3[] | null): boolean;
112
+ /**
113
+ * The rectangle the water's outline covers in the mirror view, as fractions
114
+ * of the frame [x, y (from the top), w, h], grown by RECT_MARGIN; null when it
115
+ * is most of the frame or a corner is behind the mirror camera (use the full
116
+ * view), 'offscreen' when none of it is in view.
117
+ */
118
+ private screenRect;
119
+ }
120
+ /**
121
+ * A reflection probe: the scene captured ONCE into a cubemap from just above
122
+ * the water, and sampled by the water every frame with a texture lookup.
123
+ *
124
+ * Why it is cheap: a planar mirror depends on where the camera is, so it must be
125
+ * re-rendered every frame the camera moves. The probe belongs to the WATER, not
126
+ * the view — the reflected ray from each fragment is looked up in it — so it
127
+ * stays valid while the camera moves and costs nothing per frame. It is
128
+ * re-captured only when it goes stale (the sun turned, the body moved, a slow
129
+ * refresh for scene edits), one cube face per frame so no frame pays for six.
130
+ *
131
+ * Why it is not exact: a cubemap is a picture from one point. The lookup is
132
+ * parallax-corrected against a sphere around the probe (`radius`), so the bank
133
+ * and the skyline sit roughly where they should across a large pond, but things
134
+ * close to the water and far from its centre are slightly off, and anything that
135
+ * moves is frozen until the next capture. Under ripples this reads the same as
136
+ * the mirror at a fraction of the cost; calm hero water seen close is what
137
+ * 'planar' is for. Every baked body has its own probe — no election.
138
+ */
139
+ export declare class WaterProbe {
140
+ readonly size: number;
141
+ readonly target: THREE.WebGLCubeRenderTarget;
142
+ private readonly cube;
143
+ /** Where the last COMPLETE capture was taken: the centre of the lookup. */
144
+ readonly position: THREE.Vector3;
145
+ /** Parallax sphere radius, metres; 0 = everything infinitely far (the world ocean). */
146
+ radius: number;
147
+ /** True once all six faces have been drawn; until then the water shows the sky. */
148
+ valid: boolean;
149
+ /** Next face to draw; 6 = up to date. */
150
+ private face;
151
+ private again;
152
+ private readonly pending;
153
+ private readonly lastPos;
154
+ private readonly lastSun;
155
+ private readonly sunScratch;
156
+ private lastAt;
157
+ constructor(size: number);
158
+ dispose(): void;
159
+ /**
160
+ * Once per frame: where the probe should be and what the sun is doing. Marks
161
+ * the capture stale when the probe moved more than `moveTolerance` metres,
162
+ * the sun turned more than ~0.5 degrees, or `refreshSec` passed since the last
163
+ * capture (scene edits). A request while a capture is in flight finishes that
164
+ * capture first, then starts again.
165
+ */
166
+ request(pos: THREE.Vector3, sun: THREE.Vector3 | null, moveTolerance: number, nowSec: number, refreshSec?: number): void;
167
+ /** True while faces are still to be drawn. */
168
+ get stale(): boolean;
169
+ /**
170
+ * Draw the next stale face (at most one per call; the host calls once per
171
+ * frame from onBeforeRender). `hide` is the water itself.
172
+ */
173
+ step(renderer: THREE.WebGLRenderer, scene: THREE.Scene, hide: THREE.Object3D, layers: number): void;
174
+ }
175
+ /** Cube face size for a reflection resolution (quality.reflectionScale): 0.5 -> 256. */
176
+ export declare function waterProbeSize(scale: number): number;
177
+ /**
178
+ * Push the reflection state into a water material. `mode` is what the surface
179
+ * asked for; the pass is only handed over when this surface won the election
180
+ * and its pass drew, otherwise planar falls back to the sky for this frame.
181
+ */
182
+ export declare function applyWaterReflection(uniforms: Record<string, THREE.IUniform>, mode: WaterReflectionMode, reflector: PlanarReflector | null, probe?: WaterProbe | null): void;
183
+ /** GLSL shared by both water shaders: the three uniforms and the projected sample. */
184
+ export declare const waterReflectionGlsl = "\nuniform int u_reflectionMode; // 0 off, 1 sky, 2 planar target, 3 baked probe\nuniform sampler2D u_reflectionMap;\nuniform mat4 u_reflectionMatrix;\nuniform samplerCube u_reflectionCube;\nuniform vec3 u_probePos;\nuniform float u_probeRadius; // parallax sphere; 0 = infinitely far\n\n/** The baked probe along the reflected ray. The normal is flattened by\n * 'distortion' (0 flat, 1 the full ripple) so the probe wobbles like the mirror\n * rather than like a physically rough sea. The lookup direction is corrected\n * against a sphere around the probe, so a fragment far from the probe still\n * sees the bank where it is. Only valid when u_reflectionMode == 3. */\nvec3 waterProbeReflection(vec3 worldPos, vec3 viewDir, vec3 n, float distortion){\n vec3 nb = normalize(vec3(n.x * distortion, max(n.y, 1e-3), n.z * distortion));\n vec3 r = reflect(viewDir, nb);\n r.y = max(r.y, 0.005);\n r = normalize(r);\n vec3 dir = r;\n if (u_probeRadius > 0.0) {\n vec3 o = worldPos - u_probePos;\n float b = dot(o, r);\n float c = dot(o, o) - u_probeRadius * u_probeRadius;\n dir = o + r * (-b + sqrt(max(b * b - c, 0.0)));\n }\n return textureCube(u_reflectionCube, dir).rgb;\n}\n\n/** The mirrored scene at a world point, with the surface normal bending the\n * lookup (the ripple distortion). Only valid when u_reflectionMode == 2. */\nvec3 waterPlanarReflection(vec3 worldPos, vec3 n, float distortion){\n vec4 rc = u_reflectionMatrix * vec4(worldPos, 1.0);\n vec2 uv = rc.xy / max(rc.w, 1e-4) + n.xz * distortion;\n uv = clamp(uv, vec2(0.002), vec2(0.998));\n return texture2D(u_reflectionMap, uv).rgb;\n}\n";
185
+ //# sourceMappingURL=waterReflection.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"waterReflection.d.ts","sourceRoot":"","sources":["../../src/utils/waterReflection.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAC/B,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,oBAAoB,CAAC;AAEpD;;;;;;;;;;;;;;;;;;;;;GAqBG;AAEH,MAAM,MAAM,mBAAmB,GAAG,QAAQ,GAAG,OAAO,GAAG,KAAK,GAAG,KAAK,CAAC;AAGrE,4FAA4F;AAC5F,eAAO,MAAM,wBAAwB,EAAE,MAAM,CAAC,mBAAmB,EAAE,MAAM,CAA2C,CAAC;AAErH,MAAM,WAAW,sBAAsB;IACnC,EAAE,EAAE,MAAM,CAAC;IACX,8DAA8D;IAC9D,KAAK,CAAC,EAAE,OAAO,CAAC;IAChB;gFAC4E;IAC5E,MAAM,EAAE,KAAK,CAAC,QAAQ,CAAC;IACvB;4DACwD;IACxD,IAAI,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IAC7B,yEAAyE;IACzE,IAAI,EAAE,MAAM,mBAAmB,CAAC;IAChC;iFAC6E;IAC7E,OAAO,CAAC,EAAE,MAAM,OAAO,CAAC;CAC3B;AAwBD,wBAAgB,eAAe,CAAC,MAAM,EAAE,KAAK,CAAC,MAAM,GAAG,IAAI,CAI1D;AACD,+EAA+E;AAC/E,wBAAgB,mBAAmB,IAAI,KAAK,CAAC,OAAO,GAAG,IAAI,CAE1D;AASD,6EAA6E;AAC7E,wBAAgB,oBAAoB,CAAC,OAAO,EAAE,sBAAsB,GAAG,MAAM,IAAI,CAMhF;AAED;;;;GAIG;AACH,wBAAgB,mBAAmB,CAAC,KAAK,EAAE,SAAS,GAAG,MAAM,GAAG,IAAI,CA4BnE;AAQD,wBAAgB,iBAAiB,IAAI,OAAO,CAAuB;AAEnE;;;;;;;GAOG;AACH,qBAAa,eAAe;IACxB,OAAO,CAAC,EAAE,CAAuC;IACjD,OAAO,CAAC,MAAM,CAA2B;IACzC,OAAO,CAAC,QAAQ,CAAC,OAAO,CAAoB;IAC5C,OAAO,CAAC,QAAQ,CAAC,IAAI,CAAoB;IACzC,OAAO,CAAC,MAAM,CAAQ;IACtB,OAAO,CAAC,KAAK,CAAK;IAClB,OAAO,CAAC,OAAO,CAAO;IAEtB,oDAAoD;IACpD,IAAI,IAAI,IAAI;IAEZ,2EAA2E;IAC3E,SAAS,IAAI,OAAO;IAEpB,KAAK,CAAC,QAAQ,EAAE,KAAK,CAAC,aAAa,GAAG,IAAI;IAc1C,GAAG,IAAI,IAAI;IAOX,OAAO,CAAC,IAAI;IAWZ,OAAO,IAAI,IAAI;CAOlB;AAyBD;;;;;GAKG;AACH,qBAAa,eAAe;IACxB,QAAQ,CAAC,MAAM,EAAE,KAAK,CAAC,iBAAiB,CAAC;IACzC,QAAQ,CAAC,aAAa,gBAAuB;IAC7C,OAAO,CAAC,QAAQ,CAAC,MAAM,CAAiC;IACxD,OAAO,CAAC,SAAS,CAAS;IAC1B,yEAAyE;IACzE,OAAO,CAAC,QAAQ,CAAC,OAAO,CAAwD;IAChF,OAAO,CAAC,QAAQ,CAAC,OAAO,CAAwD;IAChF;kEAC8D;IAC9D,KAAK,UAAS;;IAWd,OAAO,IAAI,IAAI;IAEf;;;;;;;;;;OAUG;IACH,MAAM,CACF,QAAQ,EAAE,KAAK,CAAC,aAAa,EAC7B,KAAK,EAAE,KAAK,CAAC,KAAK,EAClB,MAAM,EAAE,KAAK,CAAC,MAAM,EACpB,IAAI,EAAE,KAAK,CAAC,QAAQ,EACpB,KAAK,EAAE,KAAK,CAAC,OAAO,EACpB,KAAK,EAAE,MAAM,EACb,OAAO,GAAE,KAAK,CAAC,OAAO,EAAE,GAAG,IAAW,GACvC,OAAO;IAwHV;;;;;OAKG;IACH,OAAO,CAAC,UAAU;CAiCrB;AAMD;;;;;;;;;;;;;;;;;;GAkBG;AACH,qBAAa,UAAU;IAkBP,QAAQ,CAAC,IAAI,EAAE,MAAM;IAjBjC,QAAQ,CAAC,MAAM,EAAE,KAAK,CAAC,qBAAqB,CAAC;IAC7C,OAAO,CAAC,QAAQ,CAAC,IAAI,CAAmB;IACxC,2EAA2E;IAC3E,QAAQ,CAAC,QAAQ,gBAAuB;IACxC,uFAAuF;IACvF,MAAM,SAAK;IACX,mFAAmF;IACnF,KAAK,UAAS;IACd,yCAAyC;IACzC,OAAO,CAAC,IAAI,CAAK;IACjB,OAAO,CAAC,KAAK,CAAS;IACtB,OAAO,CAAC,QAAQ,CAAC,OAAO,CAAuB;IAC/C,OAAO,CAAC,QAAQ,CAAC,OAAO,CAAmD;IAC3E,OAAO,CAAC,QAAQ,CAAC,OAAO,CAAuB;IAC/C,OAAO,CAAC,QAAQ,CAAC,UAAU,CAAuB;IAClD,OAAO,CAAC,MAAM,CAAa;gBAEN,IAAI,EAAE,MAAM;IAUjC,OAAO,IAAI,IAAI;IAEf;;;;;;OAMG;IACH,OAAO,CAAC,GAAG,EAAE,KAAK,CAAC,OAAO,EAAE,GAAG,EAAE,KAAK,CAAC,OAAO,GAAG,IAAI,EAAE,aAAa,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,UAAU,SAAK,GAAG,IAAI;IAqBpH,8CAA8C;IAC9C,IAAI,KAAK,IAAI,OAAO,CAA0B;IAE9C;;;OAGG;IACH,IAAI,CAAC,QAAQ,EAAE,KAAK,CAAC,aAAa,EAAE,KAAK,EAAE,KAAK,CAAC,KAAK,EAAE,IAAI,EAAE,KAAK,CAAC,QAAQ,EAAE,MAAM,EAAE,MAAM,GAAG,IAAI;CAgDtG;AAOD,wFAAwF;AACxF,wBAAgB,cAAc,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM,CAGpD;AAED;;;;GAIG;AACH,wBAAgB,oBAAoB,CAChC,QAAQ,EAAE,MAAM,CAAC,MAAM,EAAE,KAAK,CAAC,QAAQ,CAAC,EACxC,IAAI,EAAE,mBAAmB,EACzB,SAAS,EAAE,eAAe,GAAG,IAAI,EACjC,KAAK,GAAE,UAAU,GAAG,IAAW,GAChC,IAAI,CAaN;AAED,sFAAsF;AACtF,eAAO,MAAM,mBAAmB,ynDAoC/B,CAAC"}