@3driseai/3drise-viewer 0.1.26 → 0.1.27

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 (456) hide show
  1. package/dist/animationsV2/ClipPlayer.d.ts +3 -0
  2. package/dist/animationsV2/ClipPlayer.d.ts.map +1 -1
  3. package/dist/animationsV2/ClipPlayer.js +67 -8
  4. package/dist/animationsV2/ClipsRuntime.d.ts +39 -0
  5. package/dist/animationsV2/ClipsRuntime.d.ts.map +1 -1
  6. package/dist/animationsV2/ClipsRuntime.js +245 -14
  7. package/dist/animationsV2/appliers.d.ts +5 -0
  8. package/dist/animationsV2/appliers.d.ts.map +1 -1
  9. package/dist/animationsV2/appliers.js +25 -7
  10. package/dist/animationsV2/index.d.ts +1 -1
  11. package/dist/animationsV2/index.d.ts.map +1 -1
  12. package/dist/animationsV2/normalize.d.ts.map +1 -1
  13. package/dist/animationsV2/normalize.js +18 -7
  14. package/dist/animationsV2/sequenceUtils.d.ts +42 -1
  15. package/dist/animationsV2/sequenceUtils.d.ts.map +1 -1
  16. package/dist/animationsV2/sequenceUtils.js +103 -3
  17. package/dist/animationsV2/types.d.ts +20 -0
  18. package/dist/animationsV2/types.d.ts.map +1 -1
  19. package/dist/components/AdvancedGrid.d.ts +8 -2
  20. package/dist/components/AdvancedGrid.d.ts.map +1 -1
  21. package/dist/components/AdvancedGrid.js +31 -14
  22. package/dist/components/AnimatedObject.d.ts.map +1 -1
  23. package/dist/components/AnimatedObject.js +7 -5
  24. package/dist/components/Bubbles.d.ts +7 -1
  25. package/dist/components/Bubbles.d.ts.map +1 -1
  26. package/dist/components/Bubbles.js +42 -22
  27. package/dist/components/ChladniGrid.d.ts +8 -4
  28. package/dist/components/ChladniGrid.d.ts.map +1 -1
  29. package/dist/components/ChladniGrid.js +31 -13
  30. package/dist/components/CircuitGrid.d.ts +8 -11
  31. package/dist/components/CircuitGrid.d.ts.map +1 -1
  32. package/dist/components/CircuitGrid.js +31 -13
  33. package/dist/components/CloudsGenerator.d.ts +1 -1
  34. package/dist/components/CloudsGenerator.js +1 -1
  35. package/dist/components/ContourGrid.d.ts +8 -14
  36. package/dist/components/ContourGrid.d.ts.map +1 -1
  37. package/dist/components/ContourGrid.js +31 -13
  38. package/dist/components/EffectsGenerator.d.ts +7 -1
  39. package/dist/components/EffectsGenerator.d.ts.map +1 -1
  40. package/dist/components/EffectsGenerator.js +39 -38
  41. package/dist/components/EnvironmentManager.d.ts +4 -4
  42. package/dist/components/EnvironmentManager.d.ts.map +1 -1
  43. package/dist/components/FlowNetGrid.d.ts +8 -4
  44. package/dist/components/FlowNetGrid.d.ts.map +1 -1
  45. package/dist/components/FlowNetGrid.js +31 -13
  46. package/dist/components/FractalGrid.d.ts +8 -12
  47. package/dist/components/FractalGrid.d.ts.map +1 -1
  48. package/dist/components/FractalGrid.js +31 -13
  49. package/dist/components/GirihGrid.d.ts +8 -1
  50. package/dist/components/GirihGrid.d.ts.map +1 -1
  51. package/dist/components/GirihGrid.js +31 -13
  52. package/dist/components/Glyphs.d.ts +7 -1
  53. package/dist/components/Glyphs.d.ts.map +1 -1
  54. package/dist/components/Glyphs.js +40 -34
  55. package/dist/components/GravWaveGrid.d.ts +8 -1
  56. package/dist/components/GravWaveGrid.d.ts.map +1 -1
  57. package/dist/components/GravWaveGrid.js +31 -13
  58. package/dist/components/GridsGenerator.d.ts +7 -1
  59. package/dist/components/GridsGenerator.d.ts.map +1 -1
  60. package/dist/components/GridsGenerator.js +20 -18
  61. package/dist/components/HexGrid.d.ts +8 -10
  62. package/dist/components/HexGrid.d.ts.map +1 -1
  63. package/dist/components/HexGrid.js +31 -13
  64. package/dist/components/HyperbolicGrid.d.ts +8 -4
  65. package/dist/components/HyperbolicGrid.d.ts.map +1 -1
  66. package/dist/components/HyperbolicGrid.js +31 -13
  67. package/dist/components/LandscapeBuilder.d.ts +1 -1
  68. package/dist/components/LandscapeBuilder.d.ts.map +1 -1
  69. package/dist/components/LandscapeBuilder.js +1 -1
  70. package/dist/components/LandscapeObject.d.ts +1 -1
  71. package/dist/components/LandscapeObject.d.ts.map +1 -1
  72. package/dist/components/LandscapeObject.js +1 -1
  73. package/dist/components/MoireGrid.d.ts +8 -12
  74. package/dist/components/MoireGrid.d.ts.map +1 -1
  75. package/dist/components/MoireGrid.js +31 -13
  76. package/dist/components/ObjectNode.d.ts.map +1 -1
  77. package/dist/components/ObjectNode.js +2 -2
  78. package/dist/components/ObjectsRenderer.d.ts.map +1 -1
  79. package/dist/components/ObjectsRenderer.js +37 -3
  80. package/dist/components/OceanBuilder.d.ts +1 -1
  81. package/dist/components/OceanBuilder.js +1 -1
  82. package/dist/components/ParticlesGenerator.d.ts.map +1 -1
  83. package/dist/components/ParticlesGenerator.js +6 -0
  84. package/dist/components/QuasiGrid.d.ts +8 -11
  85. package/dist/components/QuasiGrid.d.ts.map +1 -1
  86. package/dist/components/QuasiGrid.js +31 -13
  87. package/dist/components/RadarGrid.d.ts +8 -13
  88. package/dist/components/RadarGrid.d.ts.map +1 -1
  89. package/dist/components/RadarGrid.js +31 -13
  90. package/dist/components/ReactionDiffusionGrid.d.ts +8 -1
  91. package/dist/components/ReactionDiffusionGrid.d.ts.map +1 -1
  92. package/dist/components/ReactionDiffusionGrid.js +33 -139
  93. package/dist/components/SceneBuilder.js +1 -1
  94. package/dist/components/SkySystem.d.ts +1 -1
  95. package/dist/components/SparklesBurst.d.ts +7 -1
  96. package/dist/components/SparklesBurst.d.ts.map +1 -1
  97. package/dist/components/SparklesBurst.js +31 -28
  98. package/dist/components/TerrainBuilder.d.ts +1 -1
  99. package/dist/components/TerrainBuilder.d.ts.map +1 -1
  100. package/dist/components/TerrainBuilder.js +1 -1
  101. package/dist/components/VoronoiGrid.d.ts +8 -10
  102. package/dist/components/VoronoiGrid.d.ts.map +1 -1
  103. package/dist/components/VoronoiGrid.js +31 -13
  104. package/dist/components/WallpaperGrid.d.ts +8 -1
  105. package/dist/components/WallpaperGrid.d.ts.map +1 -1
  106. package/dist/components/WallpaperGrid.js +33 -210
  107. package/dist/components/effects/AuraEffect.d.ts +8 -3
  108. package/dist/components/effects/AuraEffect.d.ts.map +1 -1
  109. package/dist/components/effects/AuraEffect.js +49 -24
  110. package/dist/components/effects/AuroraEffect.d.ts +8 -3
  111. package/dist/components/effects/AuroraEffect.d.ts.map +1 -1
  112. package/dist/components/effects/AuroraEffect.js +45 -25
  113. package/dist/components/effects/BlackHoleEffect.d.ts +8 -3
  114. package/dist/components/effects/BlackHoleEffect.d.ts.map +1 -1
  115. package/dist/components/effects/BlackHoleEffect.js +42 -21
  116. package/dist/components/effects/ConstellationEffect.d.ts +8 -3
  117. package/dist/components/effects/ConstellationEffect.d.ts.map +1 -1
  118. package/dist/components/effects/ConstellationEffect.js +49 -23
  119. package/dist/components/effects/DandelionSeedsEffect.d.ts +7 -2
  120. package/dist/components/effects/DandelionSeedsEffect.d.ts.map +1 -1
  121. package/dist/components/effects/DandelionSeedsEffect.js +19 -9
  122. package/dist/components/effects/DataStreamEffect.d.ts +8 -3
  123. package/dist/components/effects/DataStreamEffect.d.ts.map +1 -1
  124. package/dist/components/effects/DataStreamEffect.js +54 -26
  125. package/dist/components/effects/DnaHelixEffect.d.ts +8 -3
  126. package/dist/components/effects/DnaHelixEffect.d.ts.map +1 -1
  127. package/dist/components/effects/DnaHelixEffect.js +62 -30
  128. package/dist/components/effects/FallingLeavesEffect.d.ts +7 -2
  129. package/dist/components/effects/FallingLeavesEffect.d.ts.map +1 -1
  130. package/dist/components/effects/FallingLeavesEffect.js +19 -9
  131. package/dist/components/effects/FieldLinesEffect.d.ts +8 -3
  132. package/dist/components/effects/FieldLinesEffect.d.ts.map +1 -1
  133. package/dist/components/effects/FieldLinesEffect.js +30 -20
  134. package/dist/components/effects/Fire.d.ts +8 -3
  135. package/dist/components/effects/Fire.d.ts.map +1 -1
  136. package/dist/components/effects/Fire.js +47 -10
  137. package/dist/components/effects/FireflySwarmEffect.d.ts +7 -2
  138. package/dist/components/effects/FireflySwarmEffect.d.ts.map +1 -1
  139. package/dist/components/effects/FireflySwarmEffect.js +19 -9
  140. package/dist/components/effects/Flares.d.ts +10 -3
  141. package/dist/components/effects/Flares.d.ts.map +1 -1
  142. package/dist/components/effects/Flares.js +53 -56
  143. package/dist/components/effects/ForcefieldEffect.d.ts +8 -3
  144. package/dist/components/effects/ForcefieldEffect.d.ts.map +1 -1
  145. package/dist/components/effects/ForcefieldEffect.js +52 -33
  146. package/dist/components/effects/GalaxyEffect.d.ts +7 -2
  147. package/dist/components/effects/GalaxyEffect.d.ts.map +1 -1
  148. package/dist/components/effects/GalaxyEffect.js +19 -9
  149. package/dist/components/effects/HarmonicShellEffect.d.ts +8 -3
  150. package/dist/components/effects/HarmonicShellEffect.d.ts.map +1 -1
  151. package/dist/components/effects/HarmonicShellEffect.js +30 -22
  152. package/dist/components/effects/HologramEffect.d.ts +8 -3
  153. package/dist/components/effects/HologramEffect.d.ts.map +1 -1
  154. package/dist/components/effects/HologramEffect.js +52 -23
  155. package/dist/components/effects/IceCrystalsEffect.d.ts +8 -3
  156. package/dist/components/effects/IceCrystalsEffect.d.ts.map +1 -1
  157. package/dist/components/effects/IceCrystalsEffect.js +36 -21
  158. package/dist/components/effects/IceHaloEffect.d.ts +7 -2
  159. package/dist/components/effects/IceHaloEffect.d.ts.map +1 -1
  160. package/dist/components/effects/IceHaloEffect.js +19 -9
  161. package/dist/components/effects/LichtenbergEffect.d.ts +7 -2
  162. package/dist/components/effects/LichtenbergEffect.d.ts.map +1 -1
  163. package/dist/components/effects/LichtenbergEffect.js +19 -9
  164. package/dist/components/effects/LightningEffect.d.ts +8 -3
  165. package/dist/components/effects/LightningEffect.d.ts.map +1 -1
  166. package/dist/components/effects/LightningEffect.js +54 -32
  167. package/dist/components/effects/MoleculesEffect.d.ts +8 -3
  168. package/dist/components/effects/MoleculesEffect.d.ts.map +1 -1
  169. package/dist/components/effects/MoleculesEffect.js +31 -21
  170. package/dist/components/effects/MurmurationEffect.d.ts +7 -2
  171. package/dist/components/effects/MurmurationEffect.d.ts.map +1 -1
  172. package/dist/components/effects/MurmurationEffect.js +19 -9
  173. package/dist/components/effects/NeuralNetworkEffect.d.ts +8 -3
  174. package/dist/components/effects/NeuralNetworkEffect.d.ts.map +1 -1
  175. package/dist/components/effects/NeuralNetworkEffect.js +66 -33
  176. package/dist/components/effects/OrbEffect.d.ts +8 -3
  177. package/dist/components/effects/OrbEffect.d.ts.map +1 -1
  178. package/dist/components/effects/OrbEffect.js +89 -42
  179. package/dist/components/effects/PlanetaryRingsEffect.d.ts +7 -2
  180. package/dist/components/effects/PlanetaryRingsEffect.d.ts.map +1 -1
  181. package/dist/components/effects/PlanetaryRingsEffect.js +19 -9
  182. package/dist/components/effects/PortalEffect.d.ts +8 -3
  183. package/dist/components/effects/PortalEffect.d.ts.map +1 -1
  184. package/dist/components/effects/PortalEffect.js +41 -25
  185. package/dist/components/effects/ShockwaveEffect.d.ts +7 -2
  186. package/dist/components/effects/ShockwaveEffect.d.ts.map +1 -1
  187. package/dist/components/effects/ShockwaveEffect.js +19 -9
  188. package/dist/components/effects/SmokePlumeEffect.d.ts +8 -3
  189. package/dist/components/effects/SmokePlumeEffect.d.ts.map +1 -1
  190. package/dist/components/effects/SmokePlumeEffect.js +30 -20
  191. package/dist/components/effects/SmokeRibbon.d.ts +8 -2
  192. package/dist/components/effects/SmokeRibbon.d.ts.map +1 -1
  193. package/dist/components/effects/SmokeRibbon.js +34 -24
  194. package/dist/components/effects/SmokeRingEffect.d.ts +8 -3
  195. package/dist/components/effects/SmokeRingEffect.d.ts.map +1 -1
  196. package/dist/components/effects/SmokeRingEffect.js +33 -21
  197. package/dist/components/effects/StrangeAttractorEffect.d.ts +8 -3
  198. package/dist/components/effects/StrangeAttractorEffect.d.ts.map +1 -1
  199. package/dist/components/effects/StrangeAttractorEffect.js +30 -20
  200. package/dist/components/effects/VolumetricFogEffect.d.ts +8 -3
  201. package/dist/components/effects/VolumetricFogEffect.d.ts.map +1 -1
  202. package/dist/components/effects/VolumetricFogEffect.js +38 -20
  203. package/dist/components/effects/WaterCausticsEffect.d.ts +7 -2
  204. package/dist/components/effects/WaterCausticsEffect.d.ts.map +1 -1
  205. package/dist/components/effects/WaterCausticsEffect.js +19 -9
  206. package/dist/components/effects/index.d.ts +0 -1
  207. package/dist/components/effects/index.d.ts.map +1 -1
  208. package/dist/components/effects/index.js +0 -1
  209. package/dist/components/index.d.ts +0 -1
  210. package/dist/components/index.d.ts.map +1 -1
  211. package/dist/components/index.js +0 -1
  212. package/dist/components/landscape/LandscapeMesh.js +1 -1
  213. package/dist/components/landscape/types.d.ts +1 -1
  214. package/dist/components/landscape/types.d.ts.map +1 -1
  215. package/dist/components/particles/MagneticBottleParticles.d.ts +17 -0
  216. package/dist/components/particles/MagneticBottleParticles.d.ts.map +1 -0
  217. package/dist/components/particles/MagneticBottleParticles.js +618 -0
  218. package/dist/components/particles/ShapeBurstParticles.d.ts +17 -0
  219. package/dist/components/particles/ShapeBurstParticles.d.ts.map +1 -0
  220. package/dist/components/particles/ShapeBurstParticles.js +588 -0
  221. package/dist/components/particles/ShapeFlowParticles.d.ts +17 -0
  222. package/dist/components/particles/ShapeFlowParticles.d.ts.map +1 -0
  223. package/dist/components/particles/ShapeFlowParticles.js +755 -0
  224. package/dist/components/particles/index.d.ts +6 -0
  225. package/dist/components/particles/index.d.ts.map +1 -1
  226. package/dist/components/particles/index.js +3 -0
  227. package/dist/components/terrain/types.d.ts +1 -1
  228. package/dist/components/terrain/types.d.ts.map +1 -1
  229. package/dist/components/volumetricClouds/VolumetricCloudsPass.d.ts +1 -1
  230. package/dist/components/volumetricClouds/VolumetricCloudsPass.d.ts.map +1 -1
  231. package/dist/components/volumetricClouds/types.d.ts +1 -1
  232. package/dist/components/volumetricClouds/types.d.ts.map +1 -1
  233. package/dist/components/water/types.d.ts +1 -1
  234. package/dist/components/water/types.d.ts.map +1 -1
  235. package/dist/constants.d.ts +1 -1
  236. package/dist/constants.d.ts.map +1 -1
  237. package/dist/constants.js +1 -1
  238. package/dist/hooks/index.d.ts +2 -0
  239. package/dist/hooks/index.d.ts.map +1 -1
  240. package/dist/hooks/index.js +1 -0
  241. package/dist/hooks/useConfigDriver.d.ts +22 -0
  242. package/dist/hooks/useConfigDriver.d.ts.map +1 -0
  243. package/dist/hooks/useConfigDriver.js +43 -0
  244. package/dist/hooks/useConfigLive.d.ts +1 -1
  245. package/dist/hooks/useConfigLive.d.ts.map +1 -1
  246. package/dist/hooks/useLandscapeMaps.d.ts +1 -1
  247. package/dist/hooks/useLandscapeMaps.d.ts.map +1 -1
  248. package/dist/hooks/useOceanMaterial.d.ts +1 -1
  249. package/dist/hooks/useThunder.d.ts +1 -1
  250. package/dist/index.d.ts +1 -2
  251. package/dist/index.d.ts.map +1 -1
  252. package/dist/index.js +1 -2
  253. package/dist/interactions/index.d.ts +2 -1
  254. package/dist/interactions/index.d.ts.map +1 -1
  255. package/dist/interactions/index.js +1 -1
  256. package/dist/interactions/runner.d.ts +18 -3
  257. package/dist/interactions/runner.d.ts.map +1 -1
  258. package/dist/interactions/runner.js +25 -2
  259. package/dist/operations/catalogue/curlSmoke.d.ts +3 -0
  260. package/dist/operations/catalogue/curlSmoke.d.ts.map +1 -0
  261. package/dist/operations/catalogue/curlSmoke.js +178 -0
  262. package/dist/operations/catalogue/displayImage.d.ts.map +1 -1
  263. package/dist/operations/catalogue/displayImage.js +1 -0
  264. package/dist/operations/catalogue/dissolve.d.ts +3 -0
  265. package/dist/operations/catalogue/dissolve.d.ts.map +1 -0
  266. package/dist/operations/catalogue/dissolve.js +57 -0
  267. package/dist/operations/catalogue/emberAsh.d.ts +3 -0
  268. package/dist/operations/catalogue/emberAsh.d.ts.map +1 -0
  269. package/dist/operations/catalogue/emberAsh.js +171 -0
  270. package/dist/operations/catalogue/fade.d.ts.map +1 -1
  271. package/dist/operations/catalogue/fade.js +1 -0
  272. package/dist/operations/catalogue/flip.d.ts +3 -0
  273. package/dist/operations/catalogue/flip.d.ts.map +1 -0
  274. package/dist/operations/catalogue/flip.js +69 -0
  275. package/dist/operations/catalogue/flock.d.ts +3 -0
  276. package/dist/operations/catalogue/flock.d.ts.map +1 -0
  277. package/dist/operations/catalogue/flock.js +163 -0
  278. package/dist/operations/catalogue/focus.d.ts.map +1 -1
  279. package/dist/operations/catalogue/focus.js +1 -0
  280. package/dist/operations/catalogue/frame.d.ts +3 -0
  281. package/dist/operations/catalogue/frame.d.ts.map +1 -0
  282. package/dist/operations/catalogue/frame.js +44 -0
  283. package/dist/operations/catalogue/frost.d.ts +3 -0
  284. package/dist/operations/catalogue/frost.d.ts.map +1 -0
  285. package/dist/operations/catalogue/frost.js +111 -0
  286. package/dist/operations/catalogue/fxInstances.d.ts +21 -0
  287. package/dist/operations/catalogue/fxInstances.d.ts.map +1 -0
  288. package/dist/operations/catalogue/fxInstances.js +47 -0
  289. package/dist/operations/catalogue/fxPoints.d.ts +22 -0
  290. package/dist/operations/catalogue/fxPoints.d.ts.map +1 -0
  291. package/dist/operations/catalogue/fxPoints.js +70 -0
  292. package/dist/operations/catalogue/glow.d.ts.map +1 -1
  293. package/dist/operations/catalogue/glow.js +2 -1
  294. package/dist/operations/catalogue/heatCracks.d.ts +3 -0
  295. package/dist/operations/catalogue/heatCracks.d.ts.map +1 -0
  296. package/dist/operations/catalogue/heatCracks.js +134 -0
  297. package/dist/operations/catalogue/hologram.d.ts +3 -0
  298. package/dist/operations/catalogue/hologram.d.ts.map +1 -0
  299. package/dist/operations/catalogue/hologram.js +118 -0
  300. package/dist/operations/catalogue/inkBloom.d.ts +3 -0
  301. package/dist/operations/catalogue/inkBloom.d.ts.map +1 -0
  302. package/dist/operations/catalogue/inkBloom.js +156 -0
  303. package/dist/operations/catalogue/ivy.d.ts +13 -0
  304. package/dist/operations/catalogue/ivy.d.ts.map +1 -0
  305. package/dist/operations/catalogue/ivy.js +469 -0
  306. package/dist/operations/catalogue/jelly.d.ts +3 -0
  307. package/dist/operations/catalogue/jelly.d.ts.map +1 -0
  308. package/dist/operations/catalogue/jelly.js +50 -0
  309. package/dist/operations/catalogue/kintsugi.d.ts +3 -0
  310. package/dist/operations/catalogue/kintsugi.d.ts.map +1 -0
  311. package/dist/operations/catalogue/kintsugi.js +173 -0
  312. package/dist/operations/catalogue/lidarScan.d.ts +3 -0
  313. package/dist/operations/catalogue/lidarScan.d.ts.map +1 -0
  314. package/dist/operations/catalogue/lidarScan.js +240 -0
  315. package/dist/operations/catalogue/liquidMetal.d.ts +3 -0
  316. package/dist/operations/catalogue/liquidMetal.d.ts.map +1 -0
  317. package/dist/operations/catalogue/liquidMetal.js +122 -0
  318. package/dist/operations/catalogue/metalize.d.ts +3 -0
  319. package/dist/operations/catalogue/metalize.d.ts.map +1 -0
  320. package/dist/operations/catalogue/metalize.js +135 -0
  321. package/dist/operations/catalogue/moveToFront.d.ts.map +1 -1
  322. package/dist/operations/catalogue/moveToFront.js +1 -0
  323. package/dist/operations/catalogue/orbit.d.ts +3 -0
  324. package/dist/operations/catalogue/orbit.d.ts.map +1 -0
  325. package/dist/operations/catalogue/orbit.js +29 -0
  326. package/dist/operations/catalogue/particleSwarm.d.ts +3 -0
  327. package/dist/operations/catalogue/particleSwarm.d.ts.map +1 -0
  328. package/dist/operations/catalogue/particleSwarm.js +138 -0
  329. package/dist/operations/catalogue/petalPeel.d.ts +3 -0
  330. package/dist/operations/catalogue/petalPeel.d.ts.map +1 -0
  331. package/dist/operations/catalogue/petalPeel.js +137 -0
  332. package/dist/operations/catalogue/petrify.d.ts +3 -0
  333. package/dist/operations/catalogue/petrify.d.ts.map +1 -0
  334. package/dist/operations/catalogue/petrify.js +94 -0
  335. package/dist/operations/catalogue/portal.d.ts +3 -0
  336. package/dist/operations/catalogue/portal.d.ts.map +1 -0
  337. package/dist/operations/catalogue/portal.js +224 -0
  338. package/dist/operations/catalogue/print3d.d.ts +3 -0
  339. package/dist/operations/catalogue/print3d.d.ts.map +1 -0
  340. package/dist/operations/catalogue/print3d.js +275 -0
  341. package/dist/operations/catalogue/rainBeads.d.ts +3 -0
  342. package/dist/operations/catalogue/rainBeads.d.ts.map +1 -0
  343. package/dist/operations/catalogue/rainBeads.js +223 -0
  344. package/dist/operations/catalogue/restPose.d.ts +21 -0
  345. package/dist/operations/catalogue/restPose.d.ts.map +1 -0
  346. package/dist/operations/catalogue/restPose.js +55 -0
  347. package/dist/operations/catalogue/rimLight.d.ts +3 -0
  348. package/dist/operations/catalogue/rimLight.d.ts.map +1 -0
  349. package/dist/operations/catalogue/rimLight.js +72 -0
  350. package/dist/operations/catalogue/sandErosion.d.ts +3 -0
  351. package/dist/operations/catalogue/sandErosion.d.ts.map +1 -0
  352. package/dist/operations/catalogue/sandErosion.js +167 -0
  353. package/dist/operations/catalogue/shaderLayers.d.ts +74 -0
  354. package/dist/operations/catalogue/shaderLayers.d.ts.map +1 -0
  355. package/dist/operations/catalogue/shaderLayers.js +322 -0
  356. package/dist/operations/catalogue/shatter.d.ts +3 -0
  357. package/dist/operations/catalogue/shatter.d.ts.map +1 -0
  358. package/dist/operations/catalogue/shatter.js +267 -0
  359. package/dist/operations/catalogue/silkDrape.d.ts +3 -0
  360. package/dist/operations/catalogue/silkDrape.d.ts.map +1 -0
  361. package/dist/operations/catalogue/silkDrape.js +340 -0
  362. package/dist/operations/catalogue/spin.d.ts +3 -0
  363. package/dist/operations/catalogue/spin.d.ts.map +1 -0
  364. package/dist/operations/catalogue/spin.js +42 -0
  365. package/dist/operations/catalogue/surfaceSample.d.ts +17 -0
  366. package/dist/operations/catalogue/surfaceSample.d.ts.map +1 -0
  367. package/dist/operations/catalogue/surfaceSample.js +187 -0
  368. package/dist/operations/catalogue/swirl.d.ts +3 -0
  369. package/dist/operations/catalogue/swirl.d.ts.map +1 -0
  370. package/dist/operations/catalogue/swirl.js +69 -0
  371. package/dist/operations/catalogue/teleport.d.ts +3 -0
  372. package/dist/operations/catalogue/teleport.d.ts.map +1 -0
  373. package/dist/operations/catalogue/teleport.js +213 -0
  374. package/dist/operations/catalogue/transitionField.d.ts +124 -0
  375. package/dist/operations/catalogue/transitionField.d.ts.map +1 -0
  376. package/dist/operations/catalogue/transitionField.js +278 -0
  377. package/dist/operations/catalogue/unweave.d.ts +3 -0
  378. package/dist/operations/catalogue/unweave.d.ts.map +1 -0
  379. package/dist/operations/catalogue/unweave.js +233 -0
  380. package/dist/operations/catalogue/visibility.d.ts.map +1 -1
  381. package/dist/operations/catalogue/visibility.js +1 -0
  382. package/dist/operations/catalogue/voxelize.d.ts +3 -0
  383. package/dist/operations/catalogue/voxelize.d.ts.map +1 -0
  384. package/dist/operations/catalogue/voxelize.js +148 -0
  385. package/dist/operations/catalogue/warmup.d.ts +22 -0
  386. package/dist/operations/catalogue/warmup.d.ts.map +1 -0
  387. package/dist/operations/catalogue/warmup.js +106 -0
  388. package/dist/operations/catalogue/zoom.d.ts.map +1 -1
  389. package/dist/operations/catalogue/zoom.js +1 -0
  390. package/dist/operations/index.d.ts +4 -2
  391. package/dist/operations/index.d.ts.map +1 -1
  392. package/dist/operations/index.js +4 -2
  393. package/dist/operations/objectEffects.d.ts +46 -0
  394. package/dist/operations/objectEffects.d.ts.map +1 -0
  395. package/dist/operations/objectEffects.js +136 -0
  396. package/dist/operations/registry.d.ts +7 -2
  397. package/dist/operations/registry.d.ts.map +1 -1
  398. package/dist/operations/registry.js +45 -3
  399. package/dist/operations/runtime.d.ts +40 -2
  400. package/dist/operations/runtime.d.ts.map +1 -1
  401. package/dist/operations/runtime.js +164 -8
  402. package/dist/operations/types.d.ts +29 -3
  403. package/dist/operations/types.d.ts.map +1 -1
  404. package/dist/operations/types.js +6 -0
  405. package/dist/operations/useObjectEffectLayers.d.ts +4 -0
  406. package/dist/operations/useObjectEffectLayers.d.ts.map +1 -0
  407. package/dist/operations/useObjectEffectLayers.js +42 -0
  408. package/dist/operations/useOperationsRuntime.d.ts.map +1 -1
  409. package/dist/operations/useOperationsRuntime.js +42 -4
  410. package/dist/presets/landscapePresets.d.ts +1 -1
  411. package/dist/presets/landscapePresets.d.ts.map +1 -1
  412. package/dist/presets/landscapePresets.js +1 -1
  413. package/dist/presets/landscapeTypes.d.ts +1 -1
  414. package/dist/presets/landscapeTypes.d.ts.map +1 -1
  415. package/dist/presets/landscapeTypes.js +1 -1
  416. package/dist/presets/oceanSurfacePresets.d.ts +1 -1
  417. package/dist/presets/terrainPresets.d.ts +1 -1
  418. package/dist/presets/terrainPresets.d.ts.map +1 -1
  419. package/dist/presets/volumetricCloudPresets.d.ts +1 -1
  420. package/dist/types/cloudConfigs.d.ts +2 -309
  421. package/dist/types/cloudConfigs.d.ts.map +1 -1
  422. package/dist/types/cloudConfigs.js +2 -339
  423. package/dist/types/index.d.ts +8 -8
  424. package/dist/types/index.d.ts.map +1 -1
  425. package/dist/types/index.js +4 -4
  426. package/dist/types/landscapeConfigs.d.ts +2 -217
  427. package/dist/types/landscapeConfigs.d.ts.map +1 -1
  428. package/dist/types/landscapeConfigs.js +2 -256
  429. package/dist/types/oceanConfigs.d.ts +2 -289
  430. package/dist/types/oceanConfigs.d.ts.map +1 -1
  431. package/dist/types/oceanConfigs.js +2 -380
  432. package/dist/types/terrainConfigs.d.ts +2 -250
  433. package/dist/types/terrainConfigs.d.ts.map +1 -1
  434. package/dist/types/terrainConfigs.js +2 -292
  435. package/dist/utils/cloudUniforms.d.ts +1 -1
  436. package/dist/utils/configAnimations.d.ts +6 -0
  437. package/dist/utils/configAnimations.d.ts.map +1 -1
  438. package/dist/utils/configAnimations.js +14 -0
  439. package/dist/utils/gridConfig.d.ts +19 -0
  440. package/dist/utils/gridConfig.d.ts.map +1 -0
  441. package/dist/utils/gridConfig.js +52 -0
  442. package/dist/utils/handleCloudsAnimations.d.ts +1 -1
  443. package/dist/utils/handleCloudsAnimations.js +1 -1
  444. package/dist/utils/hasHoverAnimation.d.ts.map +1 -1
  445. package/dist/utils/hasHoverAnimation.js +0 -2
  446. package/dist/utils/landscapeUniforms.d.ts +1 -1
  447. package/dist/utils/landscapeUniforms.d.ts.map +1 -1
  448. package/dist/utils/oceanUniforms.d.ts +1 -1
  449. package/dist/utils/particleShape.d.ts +33 -0
  450. package/dist/utils/particleShape.d.ts.map +1 -0
  451. package/dist/utils/particleShape.js +207 -0
  452. package/dist/utils/particleTrails.d.ts.map +1 -1
  453. package/dist/utils/particleTrails.js +29 -14
  454. package/dist/utils/terrainUniforms.d.ts +1 -1
  455. package/dist/utils/terrainUniforms.d.ts.map +1 -1
  456. package/package.json +2 -2
@@ -0,0 +1,322 @@
1
+ // =============================================================================
2
+ // Shader layers — GLSL injected into whatever material an object already has.
3
+ // =============================================================================
4
+ //
5
+ // Visual operations that need a shader (rim light, dissolve…) never replace the
6
+ // material: glass stays glass, a textured model keeps its maps. A layer is a few
7
+ // uniforms plus GLSL chunks spliced into the built-in shader through
8
+ // `onBeforeCompile`. Several layers can sit on one material. With no layers the
9
+ // wrapper adds no GLSL and returns the material's own cache key, so a material
10
+ // at rest compiles to (and shares) its pristine program — it costs nothing.
11
+ //
12
+ // Anchors (three r170 built-in materials):
13
+ // vertex after `#include <begin_vertex>` (`transformed` = local position)
14
+ // fragment before `#include <opaque_fragment>` (`outgoingLight`, `diffuseColor`)
15
+ // A material without the anchors (custom ShaderMaterial) is left untouched —
16
+ // `addLayer` returns false and the operation skips it.
17
+ //
18
+ // Materials are changed in place, like glow / fade: a material shared by two
19
+ // objects gets the layer on both.
20
+ //
21
+ // Uniform binding (why the proxies): three keeps compiled programs per material,
22
+ // keyed by customProgramCacheKey, and calls onBeforeCompile only the FIRST time a
23
+ // key is compiled. Re-applying the same effect later (same key) reuses that
24
+ // program together with the uniform objects captured the first time — the new
25
+ // run's uniforms would never reach the GPU (effect frozen, then the object
26
+ // "vanishes" when the run ends). So the program is always given a stable proxy
27
+ // per material and uniform name, whose `value` reads through to the uniform
28
+ // object of the layer currently applied.
29
+ // Second half of the same trap: three keeps ONE uniform table per material — the
30
+ // one from its last compile — and uses it for every cached program of that
31
+ // material. Switching dissolve → hologram → dissolve reuses dissolve's program
32
+ // with hologram's table, so dissolve's uniforms would never upload. Every compile
33
+ // therefore registers ALL proxies the material has ever had, so whichever table
34
+ // three keeps covers every cached program.
35
+ //
36
+ import { Color, Group, InstancedMesh, Material as ThreeMaterial, Mesh, SkinnedMesh } from 'three';
37
+ import { compileInBackground, warmContext } from './warmup.js';
38
+ /** material → uniform name → the live uniform object of the current layer */
39
+ const liveUniforms = new WeakMap();
40
+ /** material → uniform name → the stable proxy handed to the compiled program */
41
+ const boundUniforms = new WeakMap();
42
+ function proxyFor(mat, name) {
43
+ let bound = boundUniforms.get(mat);
44
+ if (!bound) {
45
+ bound = new Map();
46
+ boundUniforms.set(mat, bound);
47
+ }
48
+ let proxy = bound.get(name);
49
+ if (!proxy) {
50
+ proxy = {
51
+ get value() { return liveUniforms.get(mat)?.get(name)?.value; },
52
+ set value(v) { const u = liveUniforms.get(mat)?.get(name); if (u)
53
+ u.value = v; },
54
+ };
55
+ bound.set(name, proxy);
56
+ }
57
+ return proxy;
58
+ }
59
+ const STATE = '__opShaderLayers';
60
+ const V_ANCHOR = '#include <begin_vertex>';
61
+ const N_ANCHOR = '#include <beginnormal_vertex>';
62
+ const D_ANCHOR = '#include <color_fragment>';
63
+ const M_ANCHOR = '#include <metalnessmap_fragment>';
64
+ const E_ANCHOR = '#include <emissivemap_fragment>';
65
+ const F_ANCHOR = '#include <opaque_fragment>';
66
+ /** Can this material take a layer? Built-in shaders only (checked by type, before compile). */
67
+ export const canLayer = (mat) => !mat.isShaderMaterial && !mat.isRawShaderMaterial && !mat.isPointsMaterial
68
+ && !mat.isLineBasicMaterial && !mat.isSpriteMaterial && !mat.isShadowMaterial;
69
+ // ---------------------------------------------------------------- staging (no freeze)
70
+ /** Layers waiting for their program to be compiled in the background, per live material. */
71
+ const pending = new Map();
72
+ /**
73
+ * Add a layer to a material. On a live scene the layer is STAGED: nothing changes
74
+ * on screen until commitPendingLayers() has compiled the new program in the
75
+ * background (runProgress does that before an effect starts). Pass
76
+ * `{ immediate: true }` for materials that are not on screen yet (an effect's own
77
+ * helpers), or when there is no renderer.
78
+ */
79
+ export function addLayer(mat, key, layer, opts) {
80
+ if (!canLayer(mat))
81
+ return false;
82
+ if (opts?.immediate || !warmContext())
83
+ return commitLayer(mat, key, layer);
84
+ let p = pending.get(mat);
85
+ if (!p) {
86
+ p = new Map();
87
+ pending.set(mat, p);
88
+ }
89
+ p.set(key, layer);
90
+ return true;
91
+ }
92
+ /** A clone for compiling in the background: same parameters and hooks → the same program cache key. */
93
+ function warmClone(mat) {
94
+ const c = mat.clone();
95
+ const hooks = ownHooks(mat);
96
+ c.onBeforeCompile = hooks.onBeforeCompile;
97
+ c.customProgramCacheKey = hooks.customProgramCacheKey;
98
+ c.userData = {};
99
+ c.visible = true;
100
+ return c;
101
+ }
102
+ /** A stand-in object of the same kind (instancing / skinning change the program). */
103
+ function standIn(mesh, mat) {
104
+ if (mesh.isBatchedMesh)
105
+ return null;
106
+ if (mesh.isInstancedMesh) {
107
+ const m = new InstancedMesh(mesh.geometry, mat, 1);
108
+ if (mesh.instanceColor)
109
+ m.setColorAt(0, new Color(1, 1, 1)); // instance colours change the program too
110
+ return m;
111
+ }
112
+ if (mesh.isSkinnedMesh) {
113
+ const m = new SkinnedMesh(mesh.geometry, mat);
114
+ if (mesh.skeleton)
115
+ m.bind(mesh.skeleton, mesh.bindMatrix);
116
+ return m;
117
+ }
118
+ return new Mesh(mesh.geometry, mat);
119
+ }
120
+ /**
121
+ * Compile, in the background, the programs that the staged layers of `root`'s
122
+ * materials will need, then commit the layers. three keys programs by their
123
+ * cache key, so when the live material switches to the layered code it finds the
124
+ * finished program and uses it straight away — no compile, no freeze.
125
+ */
126
+ export async function commitPendingLayers(root) {
127
+ const entries = [];
128
+ const seen = new Set();
129
+ root.traverse((c) => {
130
+ if (!c.isMesh || c.userData?.__opFxHelper)
131
+ return;
132
+ for (const m of (Array.isArray(c.material) ? c.material : [c.material])) {
133
+ if (m && pending.has(m) && !seen.has(m)) {
134
+ seen.add(m);
135
+ entries.push({ mesh: c, mat: m });
136
+ }
137
+ }
138
+ });
139
+ if (!entries.length)
140
+ return;
141
+ const ctx = warmContext();
142
+ const clones = [];
143
+ if (ctx) {
144
+ const group = new Group();
145
+ for (const { mesh, mat } of entries) {
146
+ const c = warmClone(mat);
147
+ // the clone carries the layers the live material will have: current + staged
148
+ const state = mat.userData[STATE];
149
+ for (const [k, l] of state?.layers ?? [])
150
+ commitLayer(c, k, l);
151
+ for (const [k, l] of pending.get(mat))
152
+ commitLayer(c, k, l);
153
+ const o = standIn(mesh, c);
154
+ if (o) {
155
+ group.add(o);
156
+ clones.push(c);
157
+ }
158
+ else
159
+ c.dispose();
160
+ }
161
+ await compileInBackground(group);
162
+ }
163
+ // commit (layers staged meanwhile by the same call are included; ones removed are gone)
164
+ for (const { mat } of entries) {
165
+ const p = pending.get(mat);
166
+ pending.delete(mat);
167
+ for (const [k, l] of p ?? [])
168
+ commitLayer(mat, k, l);
169
+ }
170
+ if (ctx) {
171
+ // let the live materials take the cached programs before the clones let go of them
172
+ try {
173
+ ctx.gl.compile(root, ctx.cam, ctx.scene);
174
+ }
175
+ catch { /* next frame will */ }
176
+ setTimeout(() => clones.forEach(c => c.dispose()), 1500);
177
+ }
178
+ }
179
+ function commitLayer(mat, key, layer) {
180
+ if (!canLayer(mat))
181
+ return false;
182
+ let state = mat.userData[STATE];
183
+ if (!state) {
184
+ state = { layers: new Map(), onBeforeCompile: mat.onBeforeCompile, customProgramCacheKey: mat.customProgramCacheKey };
185
+ mat.userData[STATE] = state;
186
+ const own = state;
187
+ mat.onBeforeCompile = function (shader, renderer) {
188
+ own.onBeforeCompile?.call(this, shader, renderer);
189
+ if (!shader.vertexShader.includes(V_ANCHOR) || !shader.fragmentShader.includes(F_ANCHOR))
190
+ return;
191
+ for (const l of own.layers.values())
192
+ for (const n of Object.keys(l.uniforms))
193
+ proxyFor(mat, n);
194
+ for (const [n, proxy] of boundUniforms.get(mat) ?? [])
195
+ shader.uniforms[n] = proxy;
196
+ for (const l of own.layers.values()) {
197
+ const decl = Object.keys(l.uniforms).map(n => uniformDecl(n, l.uniforms[n].value)).join('\n');
198
+ shader.vertexShader = shader.vertexShader
199
+ .replace('#include <common>', `#include <common>\n${decl}\n${l.common ?? ''}\n${l.vertexPars ?? ''}`)
200
+ .replace(N_ANCHOR, `${N_ANCHOR}\n${l.normal ?? ''}`)
201
+ .replace(V_ANCHOR, `${V_ANCHOR}\n${l.vertex ?? ''}`);
202
+ shader.fragmentShader = shader.fragmentShader
203
+ .replace('#include <common>', `#include <common>\n${decl}\n${l.common ?? ''}\n${l.fragmentPars ?? ''}`)
204
+ .replace(D_ANCHOR, `${D_ANCHOR}\n${l.diffuse ?? ''}`)
205
+ .replace(M_ANCHOR, `${M_ANCHOR}\n${l.material ?? ''}`)
206
+ .replace(E_ANCHOR, `${E_ANCHOR}\n${l.emissive ?? ''}`)
207
+ .replace(F_ANCHOR, `${l.fragment ?? ''}\n${F_ANCHOR}`);
208
+ }
209
+ };
210
+ mat.customProgramCacheKey = function () {
211
+ // three's default key is `onBeforeCompile.toString()` — use the ORIGINAL hook's, not this wrapper's
212
+ const base = own.customProgramCacheKey === ThreeMaterial.prototype.customProgramCacheKey
213
+ ? String(own.onBeforeCompile)
214
+ : own.customProgramCacheKey.call(this);
215
+ // no layers → the material's own key and GLSL, so at rest it shares its pristine program
216
+ return own.layers.size ? `${base}|fx:${[...own.layers.keys()].sort().join(',')}` : base;
217
+ };
218
+ }
219
+ state.layers.set(key, layer);
220
+ // point this material's proxies at this run's uniform objects (see "Uniform binding")
221
+ let live = liveUniforms.get(mat);
222
+ if (!live) {
223
+ live = new Map();
224
+ liveUniforms.set(mat, live);
225
+ }
226
+ for (const [n, u] of Object.entries(layer.uniforms))
227
+ live.set(n, u);
228
+ mat.needsUpdate = true;
229
+ return true;
230
+ }
231
+ /** The material's own shader hooks, before any layer (for cloning a layered material). */
232
+ export function ownHooks(mat) {
233
+ const state = mat.userData[STATE];
234
+ return state
235
+ ? { onBeforeCompile: state.onBeforeCompile, customProgramCacheKey: state.customProgramCacheKey }
236
+ : { onBeforeCompile: mat.onBeforeCompile, customProgramCacheKey: mat.customProgramCacheKey };
237
+ }
238
+ /**
239
+ * Take a layer off. The wrapper hooks stay installed (with no layers they add no
240
+ * GLSL and return the material's own cache key): any later recompile — new
241
+ * lights, a new effect — must still register every proxy, see "Uniform binding".
242
+ */
243
+ export function removeLayer(mat, key) {
244
+ const p = pending.get(mat);
245
+ if (p?.delete(key) && p.size === 0)
246
+ pending.delete(mat);
247
+ const state = mat.userData[STATE];
248
+ if (!state || !state.layers.delete(key))
249
+ return;
250
+ mat.needsUpdate = true;
251
+ }
252
+ /** Does the material carry any layer right now? */
253
+ export const hasLayers = (mat) => (mat.userData[STATE]?.layers.size ?? 0) > 0;
254
+ export const hasLayer = (mat, key) => !!mat.userData[STATE]?.layers.has(key);
255
+ /** Every mesh material under a root (points, lines and sprites have no surface to layer). */
256
+ export function forEachMeshMaterial(root, fn) {
257
+ root.traverse((child) => {
258
+ if (!child.isMesh)
259
+ return;
260
+ const mats = Array.isArray(child.material) ? child.material : [child.material];
261
+ mats.forEach((m) => m && fn(m, child));
262
+ });
263
+ }
264
+ /** `uniform <type> <name>;` from a uniform's current value. */
265
+ export function uniformDecl(name, v) {
266
+ const type = typeof v === 'number' ? 'float'
267
+ : v?.isColor ? 'vec3'
268
+ : v?.isVector3 ? 'vec3'
269
+ : v?.isVector2 ? 'vec2'
270
+ : v?.isVector4 ? 'vec4'
271
+ : v?.isMatrix4 ? 'mat4'
272
+ : v?.isTexture ? 'sampler2D'
273
+ : 'float';
274
+ return `uniform ${type} ${name};`;
275
+ }
276
+ /** Calm 3D value noise + 3-octave fBm (GLSL). */
277
+ export const GLSL_NOISE = /* glsl */ `
278
+ #ifndef FX_NOISE
279
+ #define FX_NOISE
280
+ float fxHash(vec3 p) { p = fract(p * 0.3183099 + 0.1); p *= 17.0; return fract(p.x * p.y * p.z * (p.x + p.y + p.z)); }
281
+ float fxNoise(vec3 x) {
282
+ vec3 i = floor(x); vec3 f = fract(x); f = f * f * (3.0 - 2.0 * f);
283
+ return mix(mix(mix(fxHash(i), fxHash(i + vec3(1,0,0)), f.x), mix(fxHash(i + vec3(0,1,0)), fxHash(i + vec3(1,1,0)), f.x), f.y),
284
+ mix(mix(fxHash(i + vec3(0,0,1)), fxHash(i + vec3(1,0,1)), f.x), mix(fxHash(i + vec3(0,1,1)), fxHash(i + vec3(1,1,1)), f.x), f.y), f.z);
285
+ }
286
+ float fxFbm(vec3 p) { float a = 0.5, s = 0.0; for (int i = 0; i < 3; i++) { s += a * fxNoise(p); p = p * 2.03 + 11.7; a *= 0.5; } return s / 0.875; }
287
+ #endif
288
+ `;
289
+ /** Rotation about a unit axis (GLSL), include-guarded. */
290
+ export const GLSL_ROT = /* glsl */ `
291
+ #ifndef FX_ROT
292
+ #define FX_ROT
293
+ mat3 fxRot(vec3 ax, float an) {
294
+ float s = sin(an), c = cos(an), oc = 1.0 - c;
295
+ return mat3(oc*ax.x*ax.x + c, oc*ax.x*ax.y + ax.z*s, oc*ax.z*ax.x - ax.y*s,
296
+ oc*ax.x*ax.y - ax.z*s, oc*ax.y*ax.y + c, oc*ax.y*ax.z + ax.x*s,
297
+ oc*ax.z*ax.x + ax.y*s, oc*ax.y*ax.z - ax.x*s, oc*ax.z*ax.z + c);
298
+ }
299
+ #endif
300
+ `;
301
+ /** 3D cellular noise (GLSL): returns vec3(F1, F2, cell hash) for p, include-guarded. */
302
+ export const GLSL_WORLEY = /* glsl */ `
303
+ #ifndef FX_WORLEY
304
+ #define FX_WORLEY
305
+ vec3 fxHash3(vec3 p) {
306
+ p = vec3(dot(p, vec3(127.1, 311.7, 74.7)), dot(p, vec3(269.5, 183.3, 246.1)), dot(p, vec3(113.5, 271.9, 124.6)));
307
+ return fract(sin(p) * 43758.5453123);
308
+ }
309
+ vec3 fxWorley(vec3 p) {
310
+ vec3 i = floor(p); vec3 f = fract(p);
311
+ float f1 = 8.0, f2 = 8.0; float id = 0.0;
312
+ for (int z = -1; z <= 1; z++) for (int y = -1; y <= 1; y++) for (int x = -1; x <= 1; x++) {
313
+ vec3 g = vec3(float(x), float(y), float(z));
314
+ vec3 h = fxHash3(i + g);
315
+ vec3 r = g + h - f;
316
+ float d = dot(r, r);
317
+ if (d < f1) { f2 = f1; f1 = d; id = h.x; } else if (d < f2) { f2 = d; }
318
+ }
319
+ return vec3(sqrt(f1), sqrt(f2), id);
320
+ }
321
+ #endif
322
+ `;
@@ -0,0 +1,3 @@
1
+ declare const _default: import("..").OperationDefinition;
2
+ export default _default;
3
+ //# sourceMappingURL=shatter.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"shatter.d.ts","sourceRoot":"","sources":["../../../src/operations/catalogue/shatter.ts"],"names":[],"mappings":";AAqKA,wBA4FG"}
@@ -0,0 +1,267 @@
1
+ // Shatter — the target cracks along the transition front (the cracks glow just
2
+ // before a piece lets go), then every triangle breaks off as a shard: it spins
3
+ // about its own centroid on a random axis, is thrown outward from the object's
4
+ // centre, falls under gravity and shrinks away. Reverting runs it backwards —
5
+ // the shards fly back and the surface seals.
6
+ //
7
+ // How: for the length of the effect each mesh gets a non-indexed copy of its
8
+ // geometry with a per-triangle centroid + random attribute, and its own clone of
9
+ // each material (so the shard attributes never touch another object sharing it).
10
+ // Both are swapped back when the object is whole again (materials disposed; the
11
+ // split geometry is cached for the next play and disposed with its source).
12
+ // Triangles are grouped into Voronoi cells around seeds sampled on the surface, so
13
+ // the object breaks into rigid chunks, not dust. Meshes over MAX_TRIS triangles are not split; they just hide when the front
14
+ // has passed half-way.
15
+ import { BufferAttribute, Group, Matrix4, Mesh, Vector3 } from 'three';
16
+ import { defineOperation } from '../types.js';
17
+ import { addLayer, ownHooks } from './shaderLayers.js';
18
+ import { DIRECTION_OPTIONS, createFieldState, fieldGlsl, fieldUniforms, runProgress, setFieldParams, } from './transitionField.js';
19
+ import { sampleSurfaceCached } from './surfaceSample.js';
20
+ import { compileInBackground, retainPrograms } from './warmup.js';
21
+ const P = 'Sht';
22
+ const KEY = 'shatter';
23
+ const STATE = '__opShatter';
24
+ const LIFE = 0.55;
25
+ const MAX_TRIS = 250_000;
26
+ /**
27
+ * Non-indexed copy of `geo` where every triangle carries the centroid and random of
28
+ * its Voronoi cell (nearest seed, in root space), so a cell moves as one rigid chunk.
29
+ * `m` maps mesh-local → root-local.
30
+ */
31
+ function splitGeometry(geo, m, seeds, cellRand) {
32
+ const g = geo.index ? geo.toNonIndexed() : geo.clone();
33
+ const pos = g.getAttribute('position');
34
+ const n = pos.count;
35
+ const nSeeds = seeds.length / 3;
36
+ const cellOf = new Int32Array(n / 3);
37
+ const sum = new Float64Array(nSeeds * 3);
38
+ const cnt = new Uint32Array(nSeeds);
39
+ const c = new Vector3();
40
+ for (let t = 0, f = 0; t < n; t += 3, f++) {
41
+ const cx = (pos.getX(t) + pos.getX(t + 1) + pos.getX(t + 2)) / 3;
42
+ const cy = (pos.getY(t) + pos.getY(t + 1) + pos.getY(t + 2)) / 3;
43
+ const cz = (pos.getZ(t) + pos.getZ(t + 1) + pos.getZ(t + 2)) / 3;
44
+ c.set(cx, cy, cz).applyMatrix4(m);
45
+ let best = 0, bd = Infinity;
46
+ for (let k = 0; k < nSeeds; k++) {
47
+ const dx = c.x - seeds[k * 3], dy = c.y - seeds[k * 3 + 1], dz = c.z - seeds[k * 3 + 2];
48
+ const d = dx * dx + dy * dy + dz * dz;
49
+ if (d < bd) {
50
+ bd = d;
51
+ best = k;
52
+ }
53
+ }
54
+ cellOf[f] = best;
55
+ sum[best * 3] += cx;
56
+ sum[best * 3 + 1] += cy;
57
+ sum[best * 3 + 2] += cz;
58
+ cnt[best]++;
59
+ }
60
+ const centroid = new Float32Array(n * 3);
61
+ const rand = new Float32Array(n * 4);
62
+ for (let t = 0, f = 0; t < n; t += 3, f++) {
63
+ const k = cellOf[f];
64
+ const inv = 1 / Math.max(1, cnt[k]);
65
+ for (let v = t; v < t + 3; v++) {
66
+ centroid[v * 3] = sum[k * 3] * inv;
67
+ centroid[v * 3 + 1] = sum[k * 3 + 1] * inv;
68
+ centroid[v * 3 + 2] = sum[k * 3 + 2] * inv;
69
+ rand[v * 4] = cellRand[k * 4];
70
+ rand[v * 4 + 1] = cellRand[k * 4 + 1];
71
+ rand[v * 4 + 2] = cellRand[k * 4 + 2];
72
+ rand[v * 4 + 3] = cellRand[k * 4 + 3];
73
+ }
74
+ }
75
+ g.setAttribute('aShtCentroid', new BufferAttribute(centroid, 3));
76
+ g.setAttribute('aShtRand', new BufferAttribute(rand, 4));
77
+ return g;
78
+ }
79
+ /**
80
+ * Split geometries are kept per source geometry (and seed set), so replaying a
81
+ * shatter reuses them; they are disposed with their source geometry.
82
+ */
83
+ const splitCache = new WeakMap();
84
+ function splitGeometryCached(geo, m, seeds, cellRand) {
85
+ const key = `${geo.attributes.position?.version ?? 0}|${seeds.length}|${seeds[0]}|${seeds[seeds.length - 1]}|${m.elements.map(e => e.toFixed(4)).join(',')}`;
86
+ const hit = splitCache.get(geo);
87
+ if (hit && hit.key === key)
88
+ return hit.geo;
89
+ hit?.geo.dispose();
90
+ const split = splitGeometry(geo, m, seeds, cellRand);
91
+ if (!hit)
92
+ geo.addEventListener('dispose', () => { splitCache.get(geo)?.geo.dispose(); splitCache.delete(geo); });
93
+ splitCache.set(geo, { key, geo: split });
94
+ return split;
95
+ }
96
+ function cloneMaterial(m) {
97
+ const c = m.clone();
98
+ // keep the material's own shader hooks (clone() does not copy them) — not another
99
+ // effect's layer wrapper, which is bound to the original material
100
+ const hooks = ownHooks(m);
101
+ c.onBeforeCompile = hooks.onBeforeCompile;
102
+ c.customProgramCacheKey = hooks.customProgramCacheKey;
103
+ c.userData = {};
104
+ return c;
105
+ }
106
+ function shardLayer(st) {
107
+ const shardFn = /* glsl */ `
108
+ attribute vec3 aShtCentroid;
109
+ attribute vec4 aShtRand;
110
+ varying float vShtA;
111
+ mat3 shtRot(vec3 ax, float an) {
112
+ float s = sin(an), c = cos(an), oc = 1.0 - c;
113
+ return mat3(oc*ax.x*ax.x + c, oc*ax.x*ax.y + ax.z*s, oc*ax.z*ax.x - ax.y*s,
114
+ oc*ax.x*ax.y - ax.z*s, oc*ax.y*ax.y + c, oc*ax.y*ax.z + ax.x*s,
115
+ oc*ax.z*ax.x + ax.y*s, oc*ax.y*ax.z - ax.x*s, oc*ax.z*ax.z + c);
116
+ }
117
+ float shtAmount() {
118
+ vec3 cr = (uShtRootInv * modelMatrix * vec4(aShtCentroid, 1.0)).xyz;
119
+ float birth = ShtBirthOf(ShtField(ShtNorm(cr)));
120
+ return clamp((uShtProgress - birth) / uShtLife, 0.0, 1.0);
121
+ }
122
+ vec3 shtAxis() { return normalize(aShtRand.xyz * 2.0 - 1.0 + vec3(1e-3, 2e-3, 3e-3)); }
123
+ float shtAngle(float a) { return a * (1.2 + 2.8 * aShtRand.w) * (aShtRand.x < 0.5 ? -1.0 : 1.0); }
124
+ `;
125
+ return {
126
+ uniforms: { ...fieldUniforms(P, st.field), uShtLife: st.life, uShtPush: st.push, uShtGravity: st.gravity, uShtCenterW: st.centerW },
127
+ common: `varying vec3 vShtQ;\n${fieldGlsl(P)}`,
128
+ vertexPars: shardFn,
129
+ normal: /* glsl */ `
130
+ { float a0 = shtAmount(); objectNormal = shtRot(shtAxis(), shtAngle(a0)) * objectNormal; }`,
131
+ vertex: /* glsl */ `
132
+ {
133
+ float a = shtAmount();
134
+ vShtA = a;
135
+ vShtQ = ShtNorm((uShtRootInv * modelMatrix * vec4(transformed, 1.0)).xyz);
136
+ float shrink = 1.0 - smoothstep(0.7, 1.0, a);
137
+ vec3 local = aShtCentroid + shtRot(shtAxis(), shtAngle(a)) * ((transformed - aShtCentroid) * shrink);
138
+ // thrown out from the object's centre, then gravity (world space)
139
+ vec3 cw = (modelMatrix * vec4(aShtCentroid, 1.0)).xyz;
140
+ vec3 outW = normalize(cw - uShtCenterW + vec3(1e-4));
141
+ float E = uShtExtent;
142
+ vec3 dispW = outW * (uShtPush * E * 0.35 * a * (0.5 + aShtRand.y))
143
+ + vec3(0.0, -1.0, 0.0) * (uShtGravity * E * 0.6 * a * a);
144
+ transformed = local + inverse(mat3(modelMatrix)) * dispW;
145
+ }`,
146
+ fragmentPars: 'varying float vShtA;',
147
+ fragment: /* glsl */ `
148
+ {
149
+ // cracks glow on the still-attached surface just ahead of the front…
150
+ float d = ShtField(vShtQ) - ShtThreshold();
151
+ float crack = (1.0 - smoothstep(0.0, uShtEdgeWidth, abs(d))) * step(0.0001, uShtProgress) * step(vShtA, 0.0001);
152
+ // …and a fresh shard's broken faces burn for a moment after it lets go
153
+ float fresh = step(0.0001, vShtA) * (1.0 - smoothstep(0.0, 0.4, vShtA));
154
+ outgoingLight += uShtEdgeColor * (crack * 2.5 + fresh * 0.7);
155
+ }`,
156
+ };
157
+ }
158
+ export default defineOperation({
159
+ value: 'shatter',
160
+ label: 'Shatter',
161
+ description: 'Crack the targets along a glowing front and break them into tumbling shards — reverting reassembles',
162
+ channel: 'visual',
163
+ multi: true,
164
+ toggles: true,
165
+ usableIn: ['interaction', 'action'],
166
+ params: {
167
+ direction: { type: 'select', label: 'Direction', default: 'outward', options: DIRECTION_OPTIONS },
168
+ edgeColor: { type: 'color', label: 'Crack colour', default: '#8fe3ff' },
169
+ push: { type: 'number', label: 'Force', default: 1, min: 0, max: 4, step: 0.05, unit: '×' },
170
+ gravity: { type: 'number', label: 'Gravity', default: 1, min: 0, max: 4, step: 0.05, unit: '×' },
171
+ pieces: { type: 'number', label: 'Pieces', default: 90, min: 8, max: 400, step: 1, hint: 'How many chunks it breaks into' },
172
+ scale: { type: 'number', label: 'Crack pattern', default: 2.5, min: 0.5, max: 12, step: 0.1 },
173
+ duration: { type: 'number', label: 'Duration', default: 2.4, min: 0.3, max: 12, step: 0.1, unit: 's' },
174
+ },
175
+ apply(target, p, ctx) {
176
+ let st = target.userData[STATE];
177
+ if (!st) {
178
+ const field = createFieldState(target);
179
+ field.edgeWidth.value = 0.04;
180
+ st = { field, life: { value: LIFE }, push: { value: 1 }, gravity: { value: 1 }, centerW: { value: new Vector3() }, swaps: [] };
181
+ const layer = shardLayer(st);
182
+ const own = st;
183
+ // Voronoi seeds on the surface (root space): each cell becomes one chunk
184
+ const seeds = sampleSurfaceCached(target, Math.max(4, Math.round(Number(p.pieces))), 5);
185
+ const cellRand = seeds.random;
186
+ target.updateWorldMatrix(true, true);
187
+ const rootInv = new Matrix4().copy(target.matrixWorld).invert();
188
+ target.traverse((c) => {
189
+ if (!c.isMesh || c.userData?.__opFxHelper || !c.geometry?.getAttribute('position'))
190
+ return;
191
+ const geo = c.geometry;
192
+ const tris = (geo.index ? geo.index.count : geo.getAttribute('position').count) / 3;
193
+ const split = tris <= MAX_TRIS;
194
+ const swap = { mesh: c, geometry: geo, material: c.material, split };
195
+ if (split) {
196
+ // prepared now, swapped in only once their shaders are compiled (no freeze)
197
+ swap.splitGeo = splitGeometryCached(geo, new Matrix4().multiplyMatrices(rootInv, c.matrixWorld), seeds.position.subarray(0, seeds.count * 3), cellRand);
198
+ const mats = Array.isArray(c.material) ? c.material.map(cloneMaterial) : cloneMaterial(c.material);
199
+ (Array.isArray(mats) ? mats : [mats]).forEach(m => addLayer(m, KEY, layer, { immediate: true }));
200
+ swap.splitMat = mats;
201
+ }
202
+ own.swaps.push(swap);
203
+ });
204
+ // compile the shard materials on stand-ins, then swap the pieces in
205
+ const stage = new Group();
206
+ for (const sw of own.swaps)
207
+ if (sw.split)
208
+ stage.add(new Mesh(sw.splitGeo, sw.splitMat));
209
+ own.ready = compileInBackground(stage).then(() => {
210
+ retainPrograms(stage);
211
+ if (target.userData[STATE] !== own)
212
+ return; // reverted meanwhile
213
+ for (const sw of own.swaps)
214
+ if (sw.split) {
215
+ sw.mesh.geometry = sw.splitGeo;
216
+ sw.mesh.material = sw.splitMat;
217
+ }
218
+ });
219
+ target.userData[STATE] = st;
220
+ }
221
+ const s = st;
222
+ setFieldParams(s.field, p, target, ctx);
223
+ s.push.value = Number(p.push);
224
+ s.gravity.value = Number(p.gravity);
225
+ const center = () => {
226
+ const b = s.field.boundsMin.value.clone().addScaledVector(s.field.boundsSize.value, 0.5);
227
+ s.centerW.value.copy(b.applyMatrix4(target.matrixWorld));
228
+ };
229
+ center();
230
+ return runProgress(target, s.field, 1 + LIFE, {
231
+ duration: Number(p.duration), ease: 'power1.in', ready: s.ready,
232
+ onUpdate: () => { center(); hideUnsplit(s, s.field.progress.value > 0.5); },
233
+ onComplete: () => { target.visible = false; },
234
+ });
235
+ },
236
+ revert(target, p) {
237
+ const s = target.userData[STATE];
238
+ if (!s)
239
+ return;
240
+ target.visible = true;
241
+ return runProgress(target, s.field, 0, {
242
+ duration: Number(p.duration), ease: 'power1.out',
243
+ onUpdate: () => {
244
+ const b = s.field.boundsMin.value.clone().addScaledVector(s.field.boundsSize.value, 0.5);
245
+ s.centerW.value.copy(b.applyMatrix4(target.matrixWorld));
246
+ hideUnsplit(s, s.field.progress.value > 0.5);
247
+ },
248
+ onComplete: () => {
249
+ for (const sw of s.swaps) {
250
+ if (!sw.split) {
251
+ sw.mesh.visible = true;
252
+ continue;
253
+ }
254
+ sw.mesh.geometry = sw.geometry;
255
+ sw.mesh.material = sw.material;
256
+ (Array.isArray(sw.splitMat) ? sw.splitMat : [sw.splitMat]).forEach(m => m.dispose());
257
+ }
258
+ delete target.userData[STATE];
259
+ },
260
+ });
261
+ },
262
+ });
263
+ function hideUnsplit(s, hidden) {
264
+ for (const sw of s.swaps)
265
+ if (!sw.split)
266
+ sw.mesh.visible = !hidden;
267
+ }
@@ -0,0 +1,3 @@
1
+ declare const _default: import("..").OperationDefinition;
2
+ export default _default;
3
+ //# sourceMappingURL=silkDrape.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"silkDrape.d.ts","sourceRoot":"","sources":["../../../src/operations/catalogue/silkDrape.ts"],"names":[],"mappings":";AA2MA,wBAwGG"}