@3driseai/3drise-viewer 0.1.25 → 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 (509) hide show
  1. package/dist/animationsV2/ClipPlayer.d.ts +16 -0
  2. package/dist/animationsV2/ClipPlayer.d.ts.map +1 -0
  3. package/dist/animationsV2/ClipPlayer.js +199 -0
  4. package/dist/animationsV2/ClipsRuntime.d.ts +150 -0
  5. package/dist/animationsV2/ClipsRuntime.d.ts.map +1 -0
  6. package/dist/animationsV2/ClipsRuntime.js +707 -0
  7. package/dist/animationsV2/appliers.d.ts +21 -0
  8. package/dist/animationsV2/appliers.d.ts.map +1 -0
  9. package/dist/animationsV2/appliers.js +222 -0
  10. package/dist/animationsV2/clipUtils.d.ts +33 -0
  11. package/dist/animationsV2/clipUtils.d.ts.map +1 -0
  12. package/dist/animationsV2/clipUtils.js +164 -0
  13. package/dist/animationsV2/elementSettings.d.ts +15 -0
  14. package/dist/animationsV2/elementSettings.d.ts.map +1 -0
  15. package/dist/animationsV2/elementSettings.js +16 -0
  16. package/dist/animationsV2/index.d.ts +16 -0
  17. package/dist/animationsV2/index.d.ts.map +1 -0
  18. package/dist/animationsV2/index.js +12 -0
  19. package/dist/animationsV2/nodeTracks.d.ts +13 -0
  20. package/dist/animationsV2/nodeTracks.d.ts.map +1 -0
  21. package/dist/animationsV2/nodeTracks.js +165 -0
  22. package/dist/animationsV2/normalize.d.ts +4 -0
  23. package/dist/animationsV2/normalize.d.ts.map +1 -0
  24. package/dist/animationsV2/normalize.js +60 -0
  25. package/dist/animationsV2/sequenceUtils.d.ts +98 -0
  26. package/dist/animationsV2/sequenceUtils.d.ts.map +1 -0
  27. package/dist/animationsV2/sequenceUtils.js +220 -0
  28. package/dist/animationsV2/types.d.ts +115 -0
  29. package/dist/animationsV2/types.d.ts.map +1 -0
  30. package/dist/animationsV2/types.js +8 -0
  31. package/dist/api/sceneHandle.d.ts +56 -17
  32. package/dist/api/sceneHandle.d.ts.map +1 -1
  33. package/dist/api/sceneHandle.js +154 -77
  34. package/dist/components/AdvancedGrid.d.ts +8 -2
  35. package/dist/components/AdvancedGrid.d.ts.map +1 -1
  36. package/dist/components/AdvancedGrid.js +31 -14
  37. package/dist/components/AnimatedObject.d.ts.map +1 -1
  38. package/dist/components/AnimatedObject.js +7 -5
  39. package/dist/components/Bubbles.d.ts +7 -1
  40. package/dist/components/Bubbles.d.ts.map +1 -1
  41. package/dist/components/Bubbles.js +42 -22
  42. package/dist/components/CameraController.d.ts.map +1 -1
  43. package/dist/components/CameraController.js +0 -44
  44. package/dist/components/ChladniGrid.d.ts +8 -4
  45. package/dist/components/ChladniGrid.d.ts.map +1 -1
  46. package/dist/components/ChladniGrid.js +31 -13
  47. package/dist/components/CircuitGrid.d.ts +8 -11
  48. package/dist/components/CircuitGrid.d.ts.map +1 -1
  49. package/dist/components/CircuitGrid.js +31 -13
  50. package/dist/components/Clouds.d.ts.map +1 -1
  51. package/dist/components/Clouds.js +0 -34
  52. package/dist/components/CloudsGenerator.d.ts +1 -1
  53. package/dist/components/CloudsGenerator.js +1 -1
  54. package/dist/components/ContourGrid.d.ts +8 -14
  55. package/dist/components/ContourGrid.d.ts.map +1 -1
  56. package/dist/components/ContourGrid.js +31 -13
  57. package/dist/components/CreatedObject.d.ts.map +1 -1
  58. package/dist/components/CreatedObject.js +19 -1
  59. package/dist/components/EffectsGenerator.d.ts +7 -1
  60. package/dist/components/EffectsGenerator.d.ts.map +1 -1
  61. package/dist/components/EffectsGenerator.js +39 -38
  62. package/dist/components/EnvironmentManager.d.ts +4 -4
  63. package/dist/components/EnvironmentManager.d.ts.map +1 -1
  64. package/dist/components/EnvironmentManager.js +1 -1
  65. package/dist/components/FlowNetGrid.d.ts +8 -4
  66. package/dist/components/FlowNetGrid.d.ts.map +1 -1
  67. package/dist/components/FlowNetGrid.js +31 -13
  68. package/dist/components/FractalGrid.d.ts +8 -12
  69. package/dist/components/FractalGrid.d.ts.map +1 -1
  70. package/dist/components/FractalGrid.js +31 -13
  71. package/dist/components/GirihGrid.d.ts +8 -1
  72. package/dist/components/GirihGrid.d.ts.map +1 -1
  73. package/dist/components/GirihGrid.js +31 -13
  74. package/dist/components/Glyphs.d.ts +7 -1
  75. package/dist/components/Glyphs.d.ts.map +1 -1
  76. package/dist/components/Glyphs.js +40 -34
  77. package/dist/components/GravWaveGrid.d.ts +8 -1
  78. package/dist/components/GravWaveGrid.d.ts.map +1 -1
  79. package/dist/components/GravWaveGrid.js +31 -13
  80. package/dist/components/GridsGenerator.d.ts +7 -1
  81. package/dist/components/GridsGenerator.d.ts.map +1 -1
  82. package/dist/components/GridsGenerator.js +20 -18
  83. package/dist/components/HexGrid.d.ts +8 -10
  84. package/dist/components/HexGrid.d.ts.map +1 -1
  85. package/dist/components/HexGrid.js +31 -13
  86. package/dist/components/HyperbolicGrid.d.ts +8 -4
  87. package/dist/components/HyperbolicGrid.d.ts.map +1 -1
  88. package/dist/components/HyperbolicGrid.js +31 -13
  89. package/dist/components/LandscapeBuilder.d.ts +1 -1
  90. package/dist/components/LandscapeBuilder.d.ts.map +1 -1
  91. package/dist/components/LandscapeBuilder.js +1 -1
  92. package/dist/components/LandscapeObject.d.ts +1 -1
  93. package/dist/components/LandscapeObject.d.ts.map +1 -1
  94. package/dist/components/LandscapeObject.js +1 -1
  95. package/dist/components/MoireGrid.d.ts +8 -12
  96. package/dist/components/MoireGrid.d.ts.map +1 -1
  97. package/dist/components/MoireGrid.js +31 -13
  98. package/dist/components/ObjectNode.d.ts.map +1 -1
  99. package/dist/components/ObjectNode.js +2 -2
  100. package/dist/components/ObjectsRenderer.d.ts +4 -1
  101. package/dist/components/ObjectsRenderer.d.ts.map +1 -1
  102. package/dist/components/ObjectsRenderer.js +57 -3
  103. package/dist/components/Ocean.d.ts.map +1 -1
  104. package/dist/components/Ocean.js +0 -63
  105. package/dist/components/OceanBuilder.d.ts +1 -1
  106. package/dist/components/OceanBuilder.js +1 -1
  107. package/dist/components/ParticlesGenerator.d.ts.map +1 -1
  108. package/dist/components/ParticlesGenerator.js +6 -0
  109. package/dist/components/QuasiGrid.d.ts +8 -11
  110. package/dist/components/QuasiGrid.d.ts.map +1 -1
  111. package/dist/components/QuasiGrid.js +31 -13
  112. package/dist/components/RadarGrid.d.ts +8 -13
  113. package/dist/components/RadarGrid.d.ts.map +1 -1
  114. package/dist/components/RadarGrid.js +31 -13
  115. package/dist/components/ReactionDiffusionGrid.d.ts +8 -1
  116. package/dist/components/ReactionDiffusionGrid.d.ts.map +1 -1
  117. package/dist/components/ReactionDiffusionGrid.js +33 -139
  118. package/dist/components/SceneBuilder.d.ts.map +1 -1
  119. package/dist/components/SceneBuilder.js +19 -4
  120. package/dist/components/SkyController.d.ts.map +1 -1
  121. package/dist/components/SkyController.js +0 -39
  122. package/dist/components/SkySystem.d.ts +1 -1
  123. package/dist/components/SparklesBurst.d.ts +7 -1
  124. package/dist/components/SparklesBurst.d.ts.map +1 -1
  125. package/dist/components/SparklesBurst.js +31 -28
  126. package/dist/components/Stars.d.ts.map +1 -1
  127. package/dist/components/Stars.js +3 -47
  128. package/dist/components/TerrainBuilder.d.ts +1 -1
  129. package/dist/components/TerrainBuilder.d.ts.map +1 -1
  130. package/dist/components/TerrainBuilder.js +1 -1
  131. package/dist/components/VoronoiGrid.d.ts +8 -10
  132. package/dist/components/VoronoiGrid.d.ts.map +1 -1
  133. package/dist/components/VoronoiGrid.js +31 -13
  134. package/dist/components/WallpaperGrid.d.ts +8 -1
  135. package/dist/components/WallpaperGrid.d.ts.map +1 -1
  136. package/dist/components/WallpaperGrid.js +33 -210
  137. package/dist/components/effects/AuraEffect.d.ts +8 -3
  138. package/dist/components/effects/AuraEffect.d.ts.map +1 -1
  139. package/dist/components/effects/AuraEffect.js +49 -24
  140. package/dist/components/effects/AuroraEffect.d.ts +8 -3
  141. package/dist/components/effects/AuroraEffect.d.ts.map +1 -1
  142. package/dist/components/effects/AuroraEffect.js +45 -25
  143. package/dist/components/effects/BlackHoleEffect.d.ts +8 -3
  144. package/dist/components/effects/BlackHoleEffect.d.ts.map +1 -1
  145. package/dist/components/effects/BlackHoleEffect.js +42 -21
  146. package/dist/components/effects/ConstellationEffect.d.ts +8 -3
  147. package/dist/components/effects/ConstellationEffect.d.ts.map +1 -1
  148. package/dist/components/effects/ConstellationEffect.js +49 -23
  149. package/dist/components/effects/DandelionSeedsEffect.d.ts +7 -2
  150. package/dist/components/effects/DandelionSeedsEffect.d.ts.map +1 -1
  151. package/dist/components/effects/DandelionSeedsEffect.js +19 -9
  152. package/dist/components/effects/DataStreamEffect.d.ts +8 -3
  153. package/dist/components/effects/DataStreamEffect.d.ts.map +1 -1
  154. package/dist/components/effects/DataStreamEffect.js +54 -26
  155. package/dist/components/effects/DnaHelixEffect.d.ts +8 -3
  156. package/dist/components/effects/DnaHelixEffect.d.ts.map +1 -1
  157. package/dist/components/effects/DnaHelixEffect.js +62 -30
  158. package/dist/components/effects/FallingLeavesEffect.d.ts +7 -2
  159. package/dist/components/effects/FallingLeavesEffect.d.ts.map +1 -1
  160. package/dist/components/effects/FallingLeavesEffect.js +19 -9
  161. package/dist/components/effects/FieldLinesEffect.d.ts +8 -3
  162. package/dist/components/effects/FieldLinesEffect.d.ts.map +1 -1
  163. package/dist/components/effects/FieldLinesEffect.js +30 -20
  164. package/dist/components/effects/Fire.d.ts +8 -3
  165. package/dist/components/effects/Fire.d.ts.map +1 -1
  166. package/dist/components/effects/Fire.js +47 -10
  167. package/dist/components/effects/FireflySwarmEffect.d.ts +7 -2
  168. package/dist/components/effects/FireflySwarmEffect.d.ts.map +1 -1
  169. package/dist/components/effects/FireflySwarmEffect.js +19 -9
  170. package/dist/components/effects/Flares.d.ts +10 -3
  171. package/dist/components/effects/Flares.d.ts.map +1 -1
  172. package/dist/components/effects/Flares.js +53 -56
  173. package/dist/components/effects/ForcefieldEffect.d.ts +8 -3
  174. package/dist/components/effects/ForcefieldEffect.d.ts.map +1 -1
  175. package/dist/components/effects/ForcefieldEffect.js +52 -33
  176. package/dist/components/effects/GalaxyEffect.d.ts +7 -2
  177. package/dist/components/effects/GalaxyEffect.d.ts.map +1 -1
  178. package/dist/components/effects/GalaxyEffect.js +19 -9
  179. package/dist/components/effects/HarmonicShellEffect.d.ts +8 -3
  180. package/dist/components/effects/HarmonicShellEffect.d.ts.map +1 -1
  181. package/dist/components/effects/HarmonicShellEffect.js +30 -22
  182. package/dist/components/effects/HologramEffect.d.ts +8 -3
  183. package/dist/components/effects/HologramEffect.d.ts.map +1 -1
  184. package/dist/components/effects/HologramEffect.js +52 -23
  185. package/dist/components/effects/IceCrystalsEffect.d.ts +8 -3
  186. package/dist/components/effects/IceCrystalsEffect.d.ts.map +1 -1
  187. package/dist/components/effects/IceCrystalsEffect.js +36 -21
  188. package/dist/components/effects/IceHaloEffect.d.ts +7 -2
  189. package/dist/components/effects/IceHaloEffect.d.ts.map +1 -1
  190. package/dist/components/effects/IceHaloEffect.js +19 -9
  191. package/dist/components/effects/LichtenbergEffect.d.ts +7 -2
  192. package/dist/components/effects/LichtenbergEffect.d.ts.map +1 -1
  193. package/dist/components/effects/LichtenbergEffect.js +19 -9
  194. package/dist/components/effects/LightningEffect.d.ts +8 -3
  195. package/dist/components/effects/LightningEffect.d.ts.map +1 -1
  196. package/dist/components/effects/LightningEffect.js +54 -32
  197. package/dist/components/effects/MoleculesEffect.d.ts +8 -3
  198. package/dist/components/effects/MoleculesEffect.d.ts.map +1 -1
  199. package/dist/components/effects/MoleculesEffect.js +31 -21
  200. package/dist/components/effects/MurmurationEffect.d.ts +7 -2
  201. package/dist/components/effects/MurmurationEffect.d.ts.map +1 -1
  202. package/dist/components/effects/MurmurationEffect.js +19 -9
  203. package/dist/components/effects/NeuralNetworkEffect.d.ts +8 -3
  204. package/dist/components/effects/NeuralNetworkEffect.d.ts.map +1 -1
  205. package/dist/components/effects/NeuralNetworkEffect.js +66 -33
  206. package/dist/components/effects/OrbEffect.d.ts +8 -3
  207. package/dist/components/effects/OrbEffect.d.ts.map +1 -1
  208. package/dist/components/effects/OrbEffect.js +89 -42
  209. package/dist/components/effects/PlanetaryRingsEffect.d.ts +7 -2
  210. package/dist/components/effects/PlanetaryRingsEffect.d.ts.map +1 -1
  211. package/dist/components/effects/PlanetaryRingsEffect.js +19 -9
  212. package/dist/components/effects/PortalEffect.d.ts +8 -3
  213. package/dist/components/effects/PortalEffect.d.ts.map +1 -1
  214. package/dist/components/effects/PortalEffect.js +41 -25
  215. package/dist/components/effects/ShockwaveEffect.d.ts +7 -2
  216. package/dist/components/effects/ShockwaveEffect.d.ts.map +1 -1
  217. package/dist/components/effects/ShockwaveEffect.js +19 -9
  218. package/dist/components/effects/SmokePlumeEffect.d.ts +8 -3
  219. package/dist/components/effects/SmokePlumeEffect.d.ts.map +1 -1
  220. package/dist/components/effects/SmokePlumeEffect.js +30 -20
  221. package/dist/components/effects/SmokeRibbon.d.ts +8 -2
  222. package/dist/components/effects/SmokeRibbon.d.ts.map +1 -1
  223. package/dist/components/effects/SmokeRibbon.js +34 -24
  224. package/dist/components/effects/SmokeRingEffect.d.ts +8 -3
  225. package/dist/components/effects/SmokeRingEffect.d.ts.map +1 -1
  226. package/dist/components/effects/SmokeRingEffect.js +33 -21
  227. package/dist/components/effects/StrangeAttractorEffect.d.ts +8 -3
  228. package/dist/components/effects/StrangeAttractorEffect.d.ts.map +1 -1
  229. package/dist/components/effects/StrangeAttractorEffect.js +30 -20
  230. package/dist/components/effects/VolumetricFogEffect.d.ts +8 -3
  231. package/dist/components/effects/VolumetricFogEffect.d.ts.map +1 -1
  232. package/dist/components/effects/VolumetricFogEffect.js +38 -20
  233. package/dist/components/effects/WaterCausticsEffect.d.ts +7 -2
  234. package/dist/components/effects/WaterCausticsEffect.d.ts.map +1 -1
  235. package/dist/components/effects/WaterCausticsEffect.js +19 -9
  236. package/dist/components/effects/index.d.ts +0 -1
  237. package/dist/components/effects/index.d.ts.map +1 -1
  238. package/dist/components/effects/index.js +0 -1
  239. package/dist/components/index.d.ts +0 -1
  240. package/dist/components/index.d.ts.map +1 -1
  241. package/dist/components/index.js +0 -1
  242. package/dist/components/landscape/LandscapeMesh.js +1 -1
  243. package/dist/components/landscape/types.d.ts +1 -1
  244. package/dist/components/landscape/types.d.ts.map +1 -1
  245. package/dist/components/particles/MagneticBottleParticles.d.ts +17 -0
  246. package/dist/components/particles/MagneticBottleParticles.d.ts.map +1 -0
  247. package/dist/components/particles/MagneticBottleParticles.js +618 -0
  248. package/dist/components/particles/ShapeBurstParticles.d.ts +17 -0
  249. package/dist/components/particles/ShapeBurstParticles.d.ts.map +1 -0
  250. package/dist/components/particles/ShapeBurstParticles.js +588 -0
  251. package/dist/components/particles/ShapeFlowParticles.d.ts +17 -0
  252. package/dist/components/particles/ShapeFlowParticles.d.ts.map +1 -0
  253. package/dist/components/particles/ShapeFlowParticles.js +755 -0
  254. package/dist/components/particles/index.d.ts +6 -0
  255. package/dist/components/particles/index.d.ts.map +1 -1
  256. package/dist/components/particles/index.js +3 -0
  257. package/dist/components/terrain/TerrainSurface.d.ts.map +1 -1
  258. package/dist/components/terrain/TerrainSurface.js +0 -5
  259. package/dist/components/terrain/types.d.ts +1 -1
  260. package/dist/components/terrain/types.d.ts.map +1 -1
  261. package/dist/components/volumetricClouds/VolumetricCloudsPass.d.ts +1 -1
  262. package/dist/components/volumetricClouds/VolumetricCloudsPass.d.ts.map +1 -1
  263. package/dist/components/volumetricClouds/VolumetricCloudsPass.js +0 -6
  264. package/dist/components/volumetricClouds/types.d.ts +1 -1
  265. package/dist/components/volumetricClouds/types.d.ts.map +1 -1
  266. package/dist/components/water/types.d.ts +1 -1
  267. package/dist/components/water/types.d.ts.map +1 -1
  268. package/dist/constants.d.ts +1 -1
  269. package/dist/constants.d.ts.map +1 -1
  270. package/dist/constants.js +1 -1
  271. package/dist/hooks/index.d.ts +2 -2
  272. package/dist/hooks/index.d.ts.map +1 -1
  273. package/dist/hooks/index.js +1 -2
  274. package/dist/hooks/useConfigDriver.d.ts +22 -0
  275. package/dist/hooks/useConfigDriver.d.ts.map +1 -0
  276. package/dist/hooks/useConfigDriver.js +43 -0
  277. package/dist/hooks/useConfigLive.d.ts +1 -1
  278. package/dist/hooks/useConfigLive.d.ts.map +1 -1
  279. package/dist/hooks/useInteraction.d.ts +6 -7
  280. package/dist/hooks/useInteraction.d.ts.map +1 -1
  281. package/dist/hooks/useInteraction.js +87 -268
  282. package/dist/hooks/useLandscapeMaps.d.ts +1 -1
  283. package/dist/hooks/useLandscapeMaps.d.ts.map +1 -1
  284. package/dist/hooks/useObjectAnimation.d.ts.map +1 -1
  285. package/dist/hooks/useObjectAnimation.js +0 -2
  286. package/dist/hooks/useOceanMaterial.d.ts +1 -1
  287. package/dist/hooks/useOceanMaterial.d.ts.map +1 -1
  288. package/dist/hooks/useOceanMaterial.js +0 -5
  289. package/dist/hooks/useRuntimeSettings.d.ts +1 -1
  290. package/dist/hooks/useRuntimeSettings.js +1 -1
  291. package/dist/hooks/useThunder.d.ts +1 -1
  292. package/dist/index.d.ts +6 -4
  293. package/dist/index.d.ts.map +1 -1
  294. package/dist/index.js +4 -2
  295. package/dist/interactions/index.d.ts +4 -0
  296. package/dist/interactions/index.d.ts.map +1 -0
  297. package/dist/interactions/index.js +1 -0
  298. package/dist/interactions/runner.d.ts +24 -0
  299. package/dist/interactions/runner.d.ts.map +1 -0
  300. package/dist/interactions/runner.js +46 -0
  301. package/dist/operations/catalogue/curlSmoke.d.ts +3 -0
  302. package/dist/operations/catalogue/curlSmoke.d.ts.map +1 -0
  303. package/dist/operations/catalogue/curlSmoke.js +178 -0
  304. package/dist/operations/catalogue/displayImage.d.ts +3 -0
  305. package/dist/operations/catalogue/displayImage.d.ts.map +1 -0
  306. package/dist/operations/catalogue/displayImage.js +40 -0
  307. package/dist/operations/catalogue/dissolve.d.ts +3 -0
  308. package/dist/operations/catalogue/dissolve.d.ts.map +1 -0
  309. package/dist/operations/catalogue/dissolve.js +57 -0
  310. package/dist/operations/catalogue/emberAsh.d.ts +3 -0
  311. package/dist/operations/catalogue/emberAsh.d.ts.map +1 -0
  312. package/dist/operations/catalogue/emberAsh.js +171 -0
  313. package/dist/operations/catalogue/fade.d.ts +3 -0
  314. package/dist/operations/catalogue/fade.d.ts.map +1 -0
  315. package/dist/operations/catalogue/fade.js +45 -0
  316. package/dist/operations/catalogue/flip.d.ts +3 -0
  317. package/dist/operations/catalogue/flip.d.ts.map +1 -0
  318. package/dist/operations/catalogue/flip.js +69 -0
  319. package/dist/operations/catalogue/flock.d.ts +3 -0
  320. package/dist/operations/catalogue/flock.d.ts.map +1 -0
  321. package/dist/operations/catalogue/flock.js +163 -0
  322. package/dist/operations/catalogue/focus.d.ts +3 -0
  323. package/dist/operations/catalogue/focus.d.ts.map +1 -0
  324. package/dist/operations/catalogue/focus.js +23 -0
  325. package/dist/operations/catalogue/frame.d.ts +3 -0
  326. package/dist/operations/catalogue/frame.d.ts.map +1 -0
  327. package/dist/operations/catalogue/frame.js +44 -0
  328. package/dist/operations/catalogue/frost.d.ts +3 -0
  329. package/dist/operations/catalogue/frost.d.ts.map +1 -0
  330. package/dist/operations/catalogue/frost.js +111 -0
  331. package/dist/operations/catalogue/fxInstances.d.ts +21 -0
  332. package/dist/operations/catalogue/fxInstances.d.ts.map +1 -0
  333. package/dist/operations/catalogue/fxInstances.js +47 -0
  334. package/dist/operations/catalogue/fxPoints.d.ts +22 -0
  335. package/dist/operations/catalogue/fxPoints.d.ts.map +1 -0
  336. package/dist/operations/catalogue/fxPoints.js +70 -0
  337. package/dist/operations/catalogue/glow.d.ts +3 -0
  338. package/dist/operations/catalogue/glow.d.ts.map +1 -0
  339. package/dist/operations/catalogue/glow.js +50 -0
  340. package/dist/operations/catalogue/heatCracks.d.ts +3 -0
  341. package/dist/operations/catalogue/heatCracks.d.ts.map +1 -0
  342. package/dist/operations/catalogue/heatCracks.js +134 -0
  343. package/dist/operations/catalogue/hologram.d.ts +3 -0
  344. package/dist/operations/catalogue/hologram.d.ts.map +1 -0
  345. package/dist/operations/catalogue/hologram.js +118 -0
  346. package/dist/operations/catalogue/inkBloom.d.ts +3 -0
  347. package/dist/operations/catalogue/inkBloom.d.ts.map +1 -0
  348. package/dist/operations/catalogue/inkBloom.js +156 -0
  349. package/dist/operations/catalogue/ivy.d.ts +13 -0
  350. package/dist/operations/catalogue/ivy.d.ts.map +1 -0
  351. package/dist/operations/catalogue/ivy.js +469 -0
  352. package/dist/operations/catalogue/jelly.d.ts +3 -0
  353. package/dist/operations/catalogue/jelly.d.ts.map +1 -0
  354. package/dist/operations/catalogue/jelly.js +50 -0
  355. package/dist/operations/catalogue/kintsugi.d.ts +3 -0
  356. package/dist/operations/catalogue/kintsugi.d.ts.map +1 -0
  357. package/dist/operations/catalogue/kintsugi.js +173 -0
  358. package/dist/operations/catalogue/lidarScan.d.ts +3 -0
  359. package/dist/operations/catalogue/lidarScan.d.ts.map +1 -0
  360. package/dist/operations/catalogue/lidarScan.js +240 -0
  361. package/dist/operations/catalogue/liquidMetal.d.ts +3 -0
  362. package/dist/operations/catalogue/liquidMetal.d.ts.map +1 -0
  363. package/dist/operations/catalogue/liquidMetal.js +122 -0
  364. package/dist/operations/catalogue/materialFx.d.ts +6 -0
  365. package/dist/operations/catalogue/materialFx.d.ts.map +1 -0
  366. package/dist/operations/catalogue/materialFx.js +13 -0
  367. package/dist/operations/catalogue/metalize.d.ts +3 -0
  368. package/dist/operations/catalogue/metalize.d.ts.map +1 -0
  369. package/dist/operations/catalogue/metalize.js +135 -0
  370. package/dist/operations/catalogue/moveToFront.d.ts +3 -0
  371. package/dist/operations/catalogue/moveToFront.d.ts.map +1 -0
  372. package/dist/operations/catalogue/moveToFront.js +26 -0
  373. package/dist/operations/catalogue/orbit.d.ts +3 -0
  374. package/dist/operations/catalogue/orbit.d.ts.map +1 -0
  375. package/dist/operations/catalogue/orbit.js +29 -0
  376. package/dist/operations/catalogue/particleSwarm.d.ts +3 -0
  377. package/dist/operations/catalogue/particleSwarm.d.ts.map +1 -0
  378. package/dist/operations/catalogue/particleSwarm.js +138 -0
  379. package/dist/operations/catalogue/petalPeel.d.ts +3 -0
  380. package/dist/operations/catalogue/petalPeel.d.ts.map +1 -0
  381. package/dist/operations/catalogue/petalPeel.js +137 -0
  382. package/dist/operations/catalogue/petrify.d.ts +3 -0
  383. package/dist/operations/catalogue/petrify.d.ts.map +1 -0
  384. package/dist/operations/catalogue/petrify.js +94 -0
  385. package/dist/operations/catalogue/portal.d.ts +3 -0
  386. package/dist/operations/catalogue/portal.d.ts.map +1 -0
  387. package/dist/operations/catalogue/portal.js +224 -0
  388. package/dist/operations/catalogue/print3d.d.ts +3 -0
  389. package/dist/operations/catalogue/print3d.d.ts.map +1 -0
  390. package/dist/operations/catalogue/print3d.js +275 -0
  391. package/dist/operations/catalogue/rainBeads.d.ts +3 -0
  392. package/dist/operations/catalogue/rainBeads.d.ts.map +1 -0
  393. package/dist/operations/catalogue/rainBeads.js +223 -0
  394. package/dist/operations/catalogue/restPose.d.ts +21 -0
  395. package/dist/operations/catalogue/restPose.d.ts.map +1 -0
  396. package/dist/operations/catalogue/restPose.js +55 -0
  397. package/dist/operations/catalogue/rimLight.d.ts +3 -0
  398. package/dist/operations/catalogue/rimLight.d.ts.map +1 -0
  399. package/dist/operations/catalogue/rimLight.js +72 -0
  400. package/dist/operations/catalogue/sandErosion.d.ts +3 -0
  401. package/dist/operations/catalogue/sandErosion.d.ts.map +1 -0
  402. package/dist/operations/catalogue/sandErosion.js +167 -0
  403. package/dist/operations/catalogue/shaderLayers.d.ts +74 -0
  404. package/dist/operations/catalogue/shaderLayers.d.ts.map +1 -0
  405. package/dist/operations/catalogue/shaderLayers.js +322 -0
  406. package/dist/operations/catalogue/shatter.d.ts +3 -0
  407. package/dist/operations/catalogue/shatter.d.ts.map +1 -0
  408. package/dist/operations/catalogue/shatter.js +267 -0
  409. package/dist/operations/catalogue/silkDrape.d.ts +3 -0
  410. package/dist/operations/catalogue/silkDrape.d.ts.map +1 -0
  411. package/dist/operations/catalogue/silkDrape.js +340 -0
  412. package/dist/operations/catalogue/spin.d.ts +3 -0
  413. package/dist/operations/catalogue/spin.d.ts.map +1 -0
  414. package/dist/operations/catalogue/spin.js +42 -0
  415. package/dist/operations/catalogue/surfaceSample.d.ts +17 -0
  416. package/dist/operations/catalogue/surfaceSample.d.ts.map +1 -0
  417. package/dist/operations/catalogue/surfaceSample.js +187 -0
  418. package/dist/operations/catalogue/swirl.d.ts +3 -0
  419. package/dist/operations/catalogue/swirl.d.ts.map +1 -0
  420. package/dist/operations/catalogue/swirl.js +69 -0
  421. package/dist/operations/catalogue/teleport.d.ts +3 -0
  422. package/dist/operations/catalogue/teleport.d.ts.map +1 -0
  423. package/dist/operations/catalogue/teleport.js +213 -0
  424. package/dist/operations/catalogue/transitionField.d.ts +124 -0
  425. package/dist/operations/catalogue/transitionField.d.ts.map +1 -0
  426. package/dist/operations/catalogue/transitionField.js +278 -0
  427. package/dist/operations/catalogue/unweave.d.ts +3 -0
  428. package/dist/operations/catalogue/unweave.d.ts.map +1 -0
  429. package/dist/operations/catalogue/unweave.js +233 -0
  430. package/dist/operations/catalogue/visibility.d.ts +3 -0
  431. package/dist/operations/catalogue/visibility.d.ts.map +1 -0
  432. package/dist/operations/catalogue/visibility.js +25 -0
  433. package/dist/operations/catalogue/voxelize.d.ts +3 -0
  434. package/dist/operations/catalogue/voxelize.d.ts.map +1 -0
  435. package/dist/operations/catalogue/voxelize.js +148 -0
  436. package/dist/operations/catalogue/warmup.d.ts +22 -0
  437. package/dist/operations/catalogue/warmup.d.ts.map +1 -0
  438. package/dist/operations/catalogue/warmup.js +106 -0
  439. package/dist/operations/catalogue/zoom.d.ts +3 -0
  440. package/dist/operations/catalogue/zoom.d.ts.map +1 -0
  441. package/dist/operations/catalogue/zoom.js +33 -0
  442. package/dist/operations/index.d.ts +7 -0
  443. package/dist/operations/index.d.ts.map +1 -0
  444. package/dist/operations/index.js +6 -0
  445. package/dist/operations/objectEffects.d.ts +46 -0
  446. package/dist/operations/objectEffects.d.ts.map +1 -0
  447. package/dist/operations/objectEffects.js +136 -0
  448. package/dist/operations/registry.d.ts +16 -0
  449. package/dist/operations/registry.d.ts.map +1 -0
  450. package/dist/operations/registry.js +63 -0
  451. package/dist/operations/runtime.d.ts +60 -0
  452. package/dist/operations/runtime.d.ts.map +1 -0
  453. package/dist/operations/runtime.js +317 -0
  454. package/dist/operations/types.d.ts +122 -0
  455. package/dist/operations/types.d.ts.map +1 -0
  456. package/dist/operations/types.js +9 -0
  457. package/dist/operations/useObjectEffectLayers.d.ts +4 -0
  458. package/dist/operations/useObjectEffectLayers.d.ts.map +1 -0
  459. package/dist/operations/useObjectEffectLayers.js +42 -0
  460. package/dist/operations/useOperationsRuntime.d.ts +3 -0
  461. package/dist/operations/useOperationsRuntime.d.ts.map +1 -0
  462. package/dist/operations/useOperationsRuntime.js +69 -0
  463. package/dist/presets/landscapePresets.d.ts +1 -1
  464. package/dist/presets/landscapePresets.d.ts.map +1 -1
  465. package/dist/presets/landscapePresets.js +1 -1
  466. package/dist/presets/landscapeTypes.d.ts +1 -1
  467. package/dist/presets/landscapeTypes.d.ts.map +1 -1
  468. package/dist/presets/landscapeTypes.js +1 -1
  469. package/dist/presets/oceanSurfacePresets.d.ts +1 -1
  470. package/dist/presets/terrainPresets.d.ts +1 -1
  471. package/dist/presets/terrainPresets.d.ts.map +1 -1
  472. package/dist/presets/volumetricCloudPresets.d.ts +1 -1
  473. package/dist/types/cloudConfigs.d.ts +2 -309
  474. package/dist/types/cloudConfigs.d.ts.map +1 -1
  475. package/dist/types/cloudConfigs.js +2 -339
  476. package/dist/types/index.d.ts +8 -8
  477. package/dist/types/index.d.ts.map +1 -1
  478. package/dist/types/index.js +4 -4
  479. package/dist/types/landscapeConfigs.d.ts +2 -217
  480. package/dist/types/landscapeConfigs.d.ts.map +1 -1
  481. package/dist/types/landscapeConfigs.js +2 -256
  482. package/dist/types/oceanConfigs.d.ts +2 -289
  483. package/dist/types/oceanConfigs.d.ts.map +1 -1
  484. package/dist/types/oceanConfigs.js +2 -380
  485. package/dist/types/terrainConfigs.d.ts +2 -250
  486. package/dist/types/terrainConfigs.d.ts.map +1 -1
  487. package/dist/types/terrainConfigs.js +2 -292
  488. package/dist/utils/cloudUniforms.d.ts +1 -1
  489. package/dist/utils/configAnimations.d.ts +6 -0
  490. package/dist/utils/configAnimations.d.ts.map +1 -1
  491. package/dist/utils/configAnimations.js +14 -0
  492. package/dist/utils/gridConfig.d.ts +19 -0
  493. package/dist/utils/gridConfig.d.ts.map +1 -0
  494. package/dist/utils/gridConfig.js +52 -0
  495. package/dist/utils/handleCloudsAnimations.d.ts +1 -1
  496. package/dist/utils/handleCloudsAnimations.js +1 -1
  497. package/dist/utils/hasHoverAnimation.d.ts.map +1 -1
  498. package/dist/utils/hasHoverAnimation.js +0 -2
  499. package/dist/utils/landscapeUniforms.d.ts +1 -1
  500. package/dist/utils/landscapeUniforms.d.ts.map +1 -1
  501. package/dist/utils/oceanUniforms.d.ts +1 -1
  502. package/dist/utils/particleShape.d.ts +33 -0
  503. package/dist/utils/particleShape.d.ts.map +1 -0
  504. package/dist/utils/particleShape.js +207 -0
  505. package/dist/utils/particleTrails.d.ts.map +1 -1
  506. package/dist/utils/particleTrails.js +29 -14
  507. package/dist/utils/terrainUniforms.d.ts +1 -1
  508. package/dist/utils/terrainUniforms.d.ts.map +1 -1
  509. package/package.json +2 -2
@@ -0,0 +1,707 @@
1
+ // =============================================================================
2
+ // ClipsRuntime — plays, poses and restores clips and sequences. Execution only.
3
+ // =============================================================================
4
+ //
5
+ // Data lives in Redux (animationClipsSlice, animationSequencesSlice); this holds
6
+ // runtime instances:
7
+ //
8
+ // clip instance — one clip on its own clock. Honours the clip's loop, yoyo
9
+ // and endMode.
10
+ // sequence instance — one clock over a resolved schedule (sequenceUtils). Each
11
+ // scheduled clip plays once, forward, at its own local time;
12
+ // loop / yoyo / reverse / endMode act on the whole sequence.
13
+ //
14
+ // Either kind is `playing` (time advances by frame delta × speed, not wall clock,
15
+ // so pause / seek / speed are exact) or posed (held at a time: the editor
16
+ // playhead, a finished 'hold', a seek).
17
+ //
18
+ // Each frame every active driver proposes a value per property; the proposals are
19
+ // merged in priority order (activation order; inside a sequence, schedule order)
20
+ // so the last one wins, and only a property whose WINNING value changed is
21
+ // written. Writing a material property every frame would flag it for recompile,
22
+ // and re-writing an unchanged camera would fight the user's orbit.
23
+ //
24
+ // A property that stops being driven (stop, a 'restore' end, a sequence entry
25
+ // scrubbed back before its start) is written back to its authored value.
26
+ //
27
+ // Sequence cues switch actions (SceneActions) by time: each tick a sequence works
28
+ // out which of its actions should be on at its current time and applies / reverts
29
+ // only what changed. It reverts only what it applied itself — an action already on
30
+ // (a click, the API) is left alone. Effects run while the sequence plays (or is
31
+ // driven); a posed sequence (the editor's scrub) applies patches only. Stopping
32
+ // the sequence reverts its actions; a 'hold' finish keeps them.
33
+ //
34
+ import { SceneActions } from '@3driseai/3drise-core';
35
+ import { getAtPath, sampleTrack } from './clipUtils.js';
36
+ import { applyValue, clearApplierCaches, isTargetMounted } from './appliers.js';
37
+ import { restoreNodeTrack } from './nodeTracks.js';
38
+ import { cueStatesAt, entryLocalTime, isEntryActive, resolveSequence, } from './sequenceUtils.js';
39
+ /** Longest an autoplaying sequence waits for its targets. */
40
+ const MAX_TARGET_WAIT_MS = 8000;
41
+ const targetKey = (state, node, path) => `${state}|${node ?? ''}|${path}`;
42
+ class ClipsRuntime {
43
+ clips = new Map();
44
+ sequences = new Map();
45
+ ctx = null;
46
+ order = 0;
47
+ version = 0;
48
+ listeners = new Set();
49
+ /** Coarse: play / pause / stop / start / end / reset / data edits — never per frame. */
50
+ stateVersion = 0;
51
+ stateListeners = new Set();
52
+ eventListeners = new Set();
53
+ /** tracks whose authored value must be written back on the next tick */
54
+ pendingRestore = [];
55
+ /** last written value per property (targetKey -> JSON) */
56
+ written = new Map();
57
+ // --- diagnostics ------------------------------------------------------------------
58
+ // On with `?animdebug=1` in the URL, or localStorage '3drise.animdebug' = '1'
59
+ // (ClipPlayer reads it). Logs every lifecycle call on sequences (with the caller's
60
+ // stack for the ones that stop / pose / pause), the target wait, progress once a
61
+ // second, and writes that don't land. Nothing changes behaviour.
62
+ debug = false;
63
+ logAt = new Map();
64
+ dlog(...args) {
65
+ if (this.debug)
66
+ console.log('%c[anim]', 'color:#a78bfa;font-weight:bold', `${(performance.now() / 1000).toFixed(2)}s`, ...args);
67
+ }
68
+ /** At most once per `ms` per key. */
69
+ dlogEvery(key, ms, ...args) {
70
+ if (!this.debug)
71
+ return;
72
+ const now = performance.now();
73
+ if (now - (this.logAt.get(key) ?? -Infinity) < ms)
74
+ return;
75
+ this.logAt.set(key, now);
76
+ this.dlog(...args);
77
+ }
78
+ caller() {
79
+ return (new Error().stack ?? '').split('\n').slice(3, 8).map(l => l.trim()).join(' ← ');
80
+ }
81
+ // --- wiring -------------------------------------------------------------------
82
+ setContext(ctx) {
83
+ this.dlog('setContext', ctx ? { camera: !!ctx.camera, controls: !!ctx.controls, getAction: !!ctx.getAction } : null);
84
+ this.ctx = ctx;
85
+ this.written.clear();
86
+ clearApplierCaches();
87
+ }
88
+ /**
89
+ * Every change, including each frame's time while anything plays. For UI that
90
+ * follows the playhead, write through refs in the listener — never re-render React
91
+ * per frame (the timeline panels would re-render ~60×/s on the render thread).
92
+ */
93
+ subscribe(listener) {
94
+ this.listeners.add(listener);
95
+ return () => this.listeners.delete(listener);
96
+ }
97
+ getVersion() { return this.version; }
98
+ /** State changes only (play / pause / stop / start / end / reset / edits) — safe for React. */
99
+ subscribeState(listener) {
100
+ this.stateListeners.add(listener);
101
+ return () => this.stateListeners.delete(listener);
102
+ }
103
+ getStateVersion() { return this.stateVersion; }
104
+ on(listener) {
105
+ this.eventListeners.add(listener);
106
+ return () => this.eventListeners.delete(listener);
107
+ }
108
+ /**
109
+ * Forget every instance without writing anything back — a new scene is loading
110
+ * (the singleton outlives a route change: whatever the studio was playing must not
111
+ * carry into the published view).
112
+ */
113
+ reset() {
114
+ this.dlog('reset', { clips: this.clips.size, sequences: [...this.sequences.values()].map(i => i.seq.name) }, this.caller());
115
+ this.clips.clear();
116
+ this.sequences.clear();
117
+ this.pendingRestore = [];
118
+ this.written.clear();
119
+ clearApplierCaches();
120
+ this.bumpState();
121
+ }
122
+ // --- clips ----------------------------------------------------------------------
123
+ play(clip, opts = {}) {
124
+ const existing = this.clips.get(clip.id);
125
+ const direction = opts.reverse ? -1 : 1;
126
+ let time = opts.from ?? existing?.time ?? 0;
127
+ // Restart from the edge when playing past the end.
128
+ if (direction === 1 && time >= clip.duration)
129
+ time = 0;
130
+ if (direction === -1 && time <= 0)
131
+ time = clip.duration;
132
+ this.clips.set(clip.id, { clip, time, speed: opts.speed ?? 1, direction, playing: true, order: ++this.order });
133
+ this.emit({ type: 'start', kind: 'clip', id: clip.id });
134
+ this.bumpState();
135
+ }
136
+ pause(clipId) {
137
+ const inst = this.clips.get(clipId);
138
+ if (!inst)
139
+ return;
140
+ inst.playing = false;
141
+ this.bumpState();
142
+ }
143
+ resume(clipId) {
144
+ const inst = this.clips.get(clipId);
145
+ if (!inst)
146
+ return;
147
+ inst.playing = true;
148
+ this.bumpState();
149
+ }
150
+ /** Stop and put the clip's properties back to their authored values. */
151
+ stop(clipId) {
152
+ const inst = this.clips.get(clipId);
153
+ if (!inst)
154
+ return;
155
+ this.clips.delete(clipId);
156
+ this.pendingRestore.push(...inst.clip.tracks);
157
+ this.bumpState();
158
+ }
159
+ /** Hold the clip at t (seconds) — the editor playhead, or seek() from outside. */
160
+ pose(clip, t) {
161
+ const inst = this.clips.get(clip.id);
162
+ const time = Math.min(clip.duration, Math.max(0, t));
163
+ if (inst) {
164
+ inst.clip = clip;
165
+ inst.time = time;
166
+ this.bump();
167
+ }
168
+ else {
169
+ this.clips.set(clip.id, { clip, time, speed: 1, direction: 1, playing: false, order: ++this.order });
170
+ this.bumpState();
171
+ }
172
+ }
173
+ /** The clip data changed (editor edit): keep time and play state, use the new tracks. */
174
+ updateClip(clip) {
175
+ const inst = this.clips.get(clip.id);
176
+ if (!inst)
177
+ return;
178
+ const removed = inst.clip.tracks.filter(t => !clip.tracks.some(n => n.id === t.id));
179
+ if (removed.length)
180
+ this.pendingRestore.push(...removed);
181
+ inst.clip = clip;
182
+ inst.time = Math.min(inst.time, clip.duration);
183
+ this.written.clear(); // values may have changed under the same time
184
+ this.bumpState();
185
+ }
186
+ getTime(clipId) { return this.clips.get(clipId)?.time ?? 0; }
187
+ isPlaying(clipId) { return !!this.clips.get(clipId)?.playing; }
188
+ isActive(clipId) { return this.clips.has(clipId); }
189
+ /** Value of a track at the clip's current time (the panel's value column). */
190
+ sampleAt(clip, track) {
191
+ return sampleTrack(track, this.getTime(clip.id));
192
+ }
193
+ // --- sequences ------------------------------------------------------------------
194
+ /**
195
+ * Play a sequence. `reverse` defaults to the sequence's own; `from` is sequence
196
+ * seconds (defaults to the current time, or the start edge of the run).
197
+ */
198
+ playSequence(seq, clips, opts = {}) {
199
+ const existing = this.sequences.get(seq.id);
200
+ const schedule = resolveSequence(seq, clips);
201
+ const direction = (opts.reverse ?? seq.reverse) ? -1 : 1;
202
+ const driven = isDriven(seq);
203
+ let time = opts.from ?? existing?.time ?? (direction === 1 ? 0 : schedule.duration);
204
+ // A played sequence restarts from its start edge; a driven one stays where it is.
205
+ if (!driven && direction === 1 && time >= schedule.duration)
206
+ time = 0;
207
+ if (!driven && direction === -1 && time <= 0)
208
+ time = schedule.duration;
209
+ this.sequences.set(seq.id, {
210
+ driven,
211
+ target: time,
212
+ seq,
213
+ schedule,
214
+ time,
215
+ speed: opts.speed ?? 1,
216
+ direction,
217
+ baseDirection: direction,
218
+ playing: true,
219
+ order: ++this.order,
220
+ active: existing?.active ?? new Set(),
221
+ cueState: existing?.cueState ?? new Map(),
222
+ owned: existing?.owned ?? new Set(),
223
+ waitUntil: opts.waitForTargets ? Date.now() + MAX_TARGET_WAIT_MS : undefined,
224
+ });
225
+ this.dlog('playSequence', seq.name, {
226
+ id: seq.id, driven, driver: seq.driver, time, duration: schedule.duration, entries: schedule.entries.length,
227
+ steps: seq.steps.length, cues: schedule.cues.length, waitForTargets: !!opts.waitForTargets, replaced: !!existing,
228
+ }, this.caller());
229
+ this.emit({ type: 'start', kind: 'sequence', id: seq.id });
230
+ this.bumpState();
231
+ }
232
+ // --- input drivers --------------------------------------------------------------
233
+ /** Driven sequences that are running — what the input layer (ClipPlayer) feeds. */
234
+ getDrivenSequences() {
235
+ const out = [];
236
+ for (const inst of this.sequences.values()) {
237
+ if (!inst.driven || !inst.playing)
238
+ continue;
239
+ out.push({ id: inst.seq.id, driver: inst.seq.driver, settings: inst.seq.driverSettings, progress: this.progressOf(inst, inst.target) });
240
+ }
241
+ return out;
242
+ }
243
+ /**
244
+ * Set a sequence's position, 0–1 along its own direction (reverse flips it). A
245
+ * driven sequence eases there (its smoothing); any other is posed there at once.
246
+ */
247
+ setSequenceProgress(seqId, progress) {
248
+ const inst = this.sequences.get(seqId);
249
+ if (!inst)
250
+ return false;
251
+ const T = this.timeOf(inst, progress);
252
+ inst.target = T;
253
+ if (!inst.driven)
254
+ inst.time = T;
255
+ this.bump();
256
+ return true;
257
+ }
258
+ /**
259
+ * Move a driven sequence's target by `delta` of its length (the wheel). Returns
260
+ * false when it is already at that end — the caller then lets the event through
261
+ * (page scroll), so a visitor is never trapped inside the canvas.
262
+ */
263
+ nudgeSequenceProgress(seqId, delta) {
264
+ const inst = this.sequences.get(seqId);
265
+ if (!inst)
266
+ return false;
267
+ const p = this.progressOf(inst, inst.target);
268
+ const next = Math.min(1, Math.max(0, p + delta));
269
+ if (Math.abs(next - p) < 1e-6)
270
+ return false;
271
+ inst.target = this.timeOf(inst, next);
272
+ this.bump();
273
+ return true;
274
+ }
275
+ getSequenceProgress(seqId) {
276
+ const inst = this.sequences.get(seqId);
277
+ return inst ? this.progressOf(inst, inst.time) : 0;
278
+ }
279
+ progressOf(inst, T) {
280
+ const total = inst.schedule.duration;
281
+ if (total <= 0)
282
+ return 0;
283
+ const p = Math.min(1, Math.max(0, T / total));
284
+ return inst.seq.reverse ? 1 - p : p;
285
+ }
286
+ timeOf(inst, progress) {
287
+ const p = Math.min(1, Math.max(0, Number.isFinite(progress) ? progress : 0));
288
+ return (inst.seq.reverse ? 1 - p : p) * inst.schedule.duration;
289
+ }
290
+ pauseSequence(seqId) {
291
+ const inst = this.sequences.get(seqId);
292
+ if (!inst)
293
+ return;
294
+ this.dlog('pauseSequence', inst.seq.name, this.caller());
295
+ inst.playing = false;
296
+ this.bumpState();
297
+ }
298
+ resumeSequence(seqId) {
299
+ const inst = this.sequences.get(seqId);
300
+ if (!inst)
301
+ return;
302
+ this.dlog('resumeSequence', inst.seq.name);
303
+ inst.playing = true;
304
+ this.bumpState();
305
+ }
306
+ /** Stop and put every property the sequence drove back to its authored value. */
307
+ stopSequence(seqId) {
308
+ const inst = this.sequences.get(seqId);
309
+ if (!inst)
310
+ return;
311
+ this.dlog('stopSequence', inst.seq.name, this.caller());
312
+ this.sequences.delete(seqId);
313
+ inst.schedule.entries.forEach(e => this.pendingRestore.push(...e.clip.tracks));
314
+ this.releaseActions(inst);
315
+ this.bumpState();
316
+ }
317
+ /** Hold the sequence at T (sequence seconds) — the panel's scrub, or seek(). */
318
+ poseSequence(seq, clips, T) {
319
+ const inst = this.sequences.get(seq.id);
320
+ this.dlog('poseSequence', seq.name, { T, existing: !!inst, wasPlaying: !!inst?.playing }, this.caller());
321
+ if (inst) {
322
+ // Edited data goes through the re-resolve path (restores what the old schedule drove).
323
+ if (inst.seq !== seq)
324
+ this.updateSequence(seq, clips);
325
+ inst.time = Math.min(inst.schedule.duration, Math.max(0, T));
326
+ inst.target = inst.time;
327
+ }
328
+ else {
329
+ const schedule = resolveSequence(seq, clips);
330
+ const time = Math.min(schedule.duration, Math.max(0, T));
331
+ this.sequences.set(seq.id, {
332
+ seq, schedule, time, target: time, driven: false,
333
+ speed: 1, direction: 1, baseDirection: 1, playing: false, order: ++this.order, active: new Set(),
334
+ cueState: new Map(), owned: new Set(),
335
+ });
336
+ this.bumpState();
337
+ return;
338
+ }
339
+ this.bump();
340
+ }
341
+ /** The sequence or one of its clips changed: re-resolve, keep time and play state. */
342
+ updateSequence(seq, clips) {
343
+ const inst = this.sequences.get(seq.id);
344
+ if (!inst)
345
+ return;
346
+ this.dlog('updateSequence', seq.name, { playing: inst.playing, time: inst.time }, this.caller());
347
+ // Restore everything the old schedule drove; whatever is still driven re-writes this frame.
348
+ inst.schedule.entries.forEach(e => this.pendingRestore.push(...e.clip.tracks));
349
+ inst.seq = seq;
350
+ inst.schedule = resolveSequence(seq, clips);
351
+ inst.time = Math.min(inst.time, inst.schedule.duration);
352
+ inst.target = Math.min(inst.target, inst.schedule.duration);
353
+ // The driver can change while it runs (editing): a running sequence switches mode.
354
+ if (inst.playing)
355
+ inst.driven = isDriven(seq);
356
+ inst.active = new Set();
357
+ this.bumpState();
358
+ }
359
+ /**
360
+ * Whether a PLAYING clip or sequence writes the camera right now. The player then
361
+ * holds OrbitControls off so its own update (damping, distance / angle limits,
362
+ * auto-rotate) doesn't fight the animation. A posed (paused) one doesn't count —
363
+ * in the editor you can still orbit around a held pose.
364
+ */
365
+ isDrivingCamera() {
366
+ const camera = (tracks) => tracks.some(t => t.state === 'camera' && !t.muted && t.keys.length > 0);
367
+ for (const inst of this.clips.values())
368
+ if (inst.playing && camera(inst.clip.tracks))
369
+ return true;
370
+ for (const inst of this.sequences.values()) {
371
+ if (!inst.playing)
372
+ continue;
373
+ for (const e of inst.schedule.entries)
374
+ if (inst.active.has(e.id) && camera(e.clip.tracks))
375
+ return true;
376
+ }
377
+ return false;
378
+ }
379
+ getSequenceTime(seqId) { return this.sequences.get(seqId)?.time ?? 0; }
380
+ getSequenceDuration(seqId) { return this.sequences.get(seqId)?.schedule.duration ?? 0; }
381
+ isSequencePlaying(seqId) { return !!this.sequences.get(seqId)?.playing; }
382
+ isSequenceActive(seqId) { return this.sequences.has(seqId); }
383
+ // --- frame ------------------------------------------------------------------
384
+ tick(delta) {
385
+ const ctx = this.ctx;
386
+ if (!ctx) {
387
+ if (this.sequences.size || this.clips.size)
388
+ this.dlogEvery('noctx', 1000, 'tick skipped: no context yet', { sequences: this.sequences.size });
389
+ return;
390
+ }
391
+ const dt = Math.min(delta, 0.1);
392
+ let anyPlaying = false;
393
+ for (const inst of this.clips.values()) {
394
+ if (!inst.playing)
395
+ continue;
396
+ anyPlaying = true;
397
+ this.advanceClip(inst, dt);
398
+ }
399
+ for (const inst of [...this.sequences.values()]) {
400
+ if (!inst.playing)
401
+ continue;
402
+ anyPlaying = true;
403
+ if (inst.waitUntil !== undefined) {
404
+ const missing = this.missingTargets(ctx, inst);
405
+ if (Date.now() < inst.waitUntil && missing.length) {
406
+ this.dlogEvery(`wait:${inst.seq.id}`, 1000, 'waiting for targets', inst.seq.name, missing);
407
+ continue; // hold at the start
408
+ }
409
+ this.dlog('wait over', inst.seq.name, missing.length ? { reason: 'timeout', stillMissing: missing } : { reason: 'all targets mounted' });
410
+ inst.waitUntil = undefined;
411
+ }
412
+ this.advanceSequence(inst, dt);
413
+ this.dlogEvery(`adv:${inst.seq.id}`, 1000, 'playing', inst.seq.name, {
414
+ time: round2(inst.time), duration: round2(inst.schedule.duration), driven: inst.driven,
415
+ ...(inst.driven ? { target: round2(inst.target) } : {}), delta: round2(delta),
416
+ });
417
+ }
418
+ // Sequence entries that stopped writing (scrubbed back before their start, or
419
+ // a 'restore' clip past its end) give their properties back.
420
+ for (const inst of this.sequences.values()) {
421
+ const now = new Set();
422
+ for (const e of inst.schedule.entries)
423
+ if (isEntryActive(e, inst.time))
424
+ now.add(e.id);
425
+ for (const id of inst.active) {
426
+ if (now.has(id))
427
+ continue;
428
+ const e = inst.schedule.entries.find(x => x.id === id);
429
+ if (e)
430
+ this.pendingRestore.push(...e.clip.tracks);
431
+ }
432
+ inst.active = now;
433
+ }
434
+ // Cued actions: patches land before this frame's restores and writes read them.
435
+ // A sequence still waiting for its targets doesn't fire its cues yet — their
436
+ // effects would run on objects that aren't there (and never run again).
437
+ for (const inst of this.sequences.values()) {
438
+ if (inst.waitUntil === undefined)
439
+ this.syncCues(ctx, inst);
440
+ }
441
+ if (this.pendingRestore.length)
442
+ this.runRestores(ctx);
443
+ // Proposals in priority order; the last one per property wins.
444
+ const winners = new Map();
445
+ for (const p of this.proposals())
446
+ winners.set(targetKey(p.state, p.node, p.path), p);
447
+ const failed = [];
448
+ for (const [key, p] of winners) {
449
+ const json = JSON.stringify(p.value);
450
+ if (this.written.get(key) === json)
451
+ continue;
452
+ // Recorded only when it landed: a target that is not mounted yet (a model still
453
+ // loading) is retried next frame instead of being skipped for good.
454
+ if (applyValue(ctx, p.state, p.path, p.value, p.node))
455
+ this.written.set(key, json);
456
+ else if (this.debug)
457
+ failed.push(key);
458
+ }
459
+ if (failed.length)
460
+ this.dlogEvery('failed', 1000, `writes not landed (${failed.length})`, failed.slice(0, 12));
461
+ if (anyPlaying)
462
+ this.bump();
463
+ }
464
+ /** Objects / nodes the sequence animates — or its cued actions touch — that aren't in the scene yet. */
465
+ missingTargets(ctx, inst) {
466
+ const missing = new Set();
467
+ for (const e of inst.schedule.entries) {
468
+ for (const t of e.clip.tracks) {
469
+ if (t.muted || !t.keys.length)
470
+ continue;
471
+ if (!isTargetMounted(ctx, t.state, t.node))
472
+ missing.add(t.node ? `${t.state} › ${t.node}` : t.state);
473
+ }
474
+ }
475
+ if (ctx.getAction) {
476
+ for (const sc of inst.schedule.cues) {
477
+ const action = ctx.getAction(sc.cue.actionId);
478
+ if (!action)
479
+ continue;
480
+ for (const t of action.targets ?? [])
481
+ if (!isTargetMounted(ctx, t.state))
482
+ missing.add(t.state);
483
+ for (const eff of action.effects ?? []) {
484
+ for (const id of eff.targets ?? [])
485
+ if (id !== 'self' && !isTargetMounted(ctx, id))
486
+ missing.add(id);
487
+ }
488
+ }
489
+ }
490
+ return [...missing];
491
+ }
492
+ /** Apply / revert the actions whose cue state changed since the last tick. */
493
+ syncCues(ctx, inst) {
494
+ if (!ctx.getAction)
495
+ return;
496
+ const wanted = cueStatesAt(inst.schedule, inst.time);
497
+ const ids = new Set([...wanted.keys(), ...inst.cueState.keys()]);
498
+ for (const id of ids) {
499
+ const on = wanted.get(id) ?? false; // a removed cue counts as off
500
+ if ((inst.cueState.get(id) ?? false) === on) {
501
+ if (!wanted.has(id))
502
+ inst.cueState.delete(id);
503
+ continue;
504
+ }
505
+ if (wanted.has(id))
506
+ inst.cueState.set(id, on);
507
+ else
508
+ inst.cueState.delete(id);
509
+ if (on) {
510
+ if (SceneActions.isActionApplied(id))
511
+ continue; // someone else's — leave it
512
+ const action = ctx.getAction(id);
513
+ if (!action)
514
+ continue;
515
+ SceneActions.applyAction(action, { effects: inst.playing });
516
+ inst.owned.add(id);
517
+ }
518
+ else if (inst.owned.has(id)) {
519
+ inst.owned.delete(id);
520
+ SceneActions.revertAction(id);
521
+ }
522
+ }
523
+ }
524
+ /** Revert every action the sequence applied (stop / close). */
525
+ releaseActions(inst) {
526
+ for (const id of inst.owned)
527
+ SceneActions.revertAction(id);
528
+ inst.owned.clear();
529
+ inst.cueState.clear();
530
+ }
531
+ /** Every driver's values for this frame, lowest priority first. */
532
+ *proposals() {
533
+ const drivers = [];
534
+ for (const inst of this.clips.values()) {
535
+ drivers.push({ order: inst.order, run: () => sampleTracks(inst.clip.tracks, inst.time) });
536
+ }
537
+ for (const inst of this.sequences.values()) {
538
+ drivers.push({
539
+ order: inst.order,
540
+ run: function* () {
541
+ for (const e of inst.schedule.entries) {
542
+ if (!inst.active.has(e.id))
543
+ continue;
544
+ yield* sampleTracks(e.clip.tracks, entryLocalTime(e, inst.time));
545
+ }
546
+ },
547
+ });
548
+ }
549
+ drivers.sort((a, b) => a.order - b.order);
550
+ for (const d of drivers)
551
+ yield* d.run();
552
+ }
553
+ runRestores(ctx) {
554
+ const tracks = this.pendingRestore;
555
+ this.pendingRestore = [];
556
+ const done = new Set();
557
+ for (const track of tracks) {
558
+ const key = targetKey(track.state, track.node, track.path);
559
+ if (done.has(key))
560
+ continue;
561
+ done.add(key);
562
+ this.written.delete(key);
563
+ if (track.node) {
564
+ // Node tracks restore their exact pre-animation snapshot (see nodeTracks).
565
+ const node = track.node;
566
+ restoreNodeTrack(track.state, node, track.path, (path) => this.isDriven(track.state, node, path));
567
+ continue;
568
+ }
569
+ // Another driver may still own this property; it re-writes this frame.
570
+ const authored = getAtPath(ctx.getSettings(track.state), track.path);
571
+ if (authored !== undefined)
572
+ applyValue(ctx, track.state, track.path, authored);
573
+ }
574
+ }
575
+ /** Whether any active driver still has a track on (state, node, path). */
576
+ isDriven(state, node, path) {
577
+ const hit = (t) => t.state === state && t.node === node && t.path === path && !t.muted;
578
+ for (const inst of this.clips.values())
579
+ if (inst.clip.tracks.some(hit))
580
+ return true;
581
+ for (const inst of this.sequences.values()) {
582
+ for (const e of inst.schedule.entries)
583
+ if (inst.active.has(e.id) && e.clip.tracks.some(hit))
584
+ return true;
585
+ }
586
+ return false;
587
+ }
588
+ advanceClip(inst, delta) {
589
+ const { clip } = inst;
590
+ inst.time += delta * inst.speed * inst.direction;
591
+ const atEnd = inst.direction === 1 ? inst.time >= clip.duration : inst.time <= 0;
592
+ if (!atEnd)
593
+ return;
594
+ if (clip.yoyo) {
595
+ // Bounce at either edge. Without loop, stop after the return leg.
596
+ const returning = inst.direction === -1;
597
+ inst.time = inst.direction === 1 ? clip.duration : 0;
598
+ if (returning && !clip.loop)
599
+ return this.finishClip(inst);
600
+ inst.direction = inst.direction === 1 ? -1 : 1;
601
+ if (returning)
602
+ this.emit({ type: 'loop', kind: 'clip', id: clip.id });
603
+ return;
604
+ }
605
+ if (clip.loop) {
606
+ inst.time = inst.direction === 1 ? inst.time - clip.duration : inst.time + clip.duration;
607
+ this.emit({ type: 'loop', kind: 'clip', id: clip.id });
608
+ return;
609
+ }
610
+ inst.time = inst.direction === 1 ? clip.duration : 0;
611
+ this.finishClip(inst);
612
+ }
613
+ finishClip(inst) {
614
+ inst.playing = false;
615
+ this.bumpState();
616
+ this.emit({ type: 'end', kind: 'clip', id: inst.clip.id });
617
+ if (inst.clip.endMode === 'restore')
618
+ this.stop(inst.clip.id);
619
+ }
620
+ /**
621
+ * Same edge rules as a clip, on the sequence clock. "Forward" is the run's base
622
+ * direction: a reversed run starts at the end and finishes at 0.
623
+ */
624
+ advanceSequence(inst, delta) {
625
+ const { seq } = inst;
626
+ const total = inst.schedule.duration;
627
+ if (inst.driven) {
628
+ // Ease toward the input's target. `smoothing` ≈ seconds to settle; 0 = exact.
629
+ const diff = inst.target - inst.time;
630
+ if (Math.abs(diff) < 1e-4) {
631
+ inst.time = inst.target;
632
+ return;
633
+ }
634
+ const smoothing = Math.max(0, seq.driverSettings?.smoothing ?? 0);
635
+ const k = smoothing <= 0 ? 1 : 1 - Math.exp(-delta * 4 / smoothing);
636
+ inst.time += diff * k;
637
+ return;
638
+ }
639
+ if (total <= 0) {
640
+ inst.time = 0;
641
+ return this.finishSequence(inst);
642
+ }
643
+ inst.time += delta * inst.speed * inst.direction;
644
+ const atEnd = inst.direction === 1 ? inst.time >= total : inst.time <= 0;
645
+ if (!atEnd)
646
+ return;
647
+ const edge = inst.direction === 1 ? total : 0;
648
+ const returning = inst.direction !== inst.baseDirection;
649
+ if (seq.yoyo) {
650
+ inst.time = edge;
651
+ if (returning && !seq.loop)
652
+ return this.finishSequence(inst);
653
+ inst.direction = inst.direction === 1 ? -1 : 1;
654
+ if (returning)
655
+ this.emit({ type: 'loop', kind: 'sequence', id: seq.id });
656
+ return;
657
+ }
658
+ if (seq.loop) {
659
+ // Jump back to the run's start edge. Entries past their window restore next tick.
660
+ inst.time = inst.direction === 1 ? inst.time - total : inst.time + total;
661
+ this.emit({ type: 'loop', kind: 'sequence', id: seq.id });
662
+ return;
663
+ }
664
+ inst.time = edge;
665
+ this.finishSequence(inst);
666
+ }
667
+ finishSequence(inst) {
668
+ this.dlog('finished', inst.seq.name, { time: inst.time, endMode: inst.seq.endMode });
669
+ inst.playing = false;
670
+ this.bumpState();
671
+ this.emit({ type: 'end', kind: 'sequence', id: inst.seq.id });
672
+ if (inst.seq.endMode === 'restore')
673
+ this.stopSequence(inst.seq.id);
674
+ }
675
+ emit(e) {
676
+ this.eventListeners.forEach(l => { try {
677
+ l(e);
678
+ }
679
+ catch (err) {
680
+ console.error('[ClipsRuntime] listener failed', err);
681
+ } });
682
+ }
683
+ bump() {
684
+ this.version += 1;
685
+ this.listeners.forEach(l => l());
686
+ }
687
+ /** A state change: notifies both kinds of subscribers. */
688
+ bumpState() {
689
+ this.stateVersion += 1;
690
+ this.stateListeners.forEach(l => l());
691
+ this.bump();
692
+ }
693
+ }
694
+ const round2 = (n) => Math.round(n * 100) / 100;
695
+ const isDriven = (seq) => !!seq.driver && seq.driver !== 'time';
696
+ function* sampleTracks(tracks, t) {
697
+ for (const track of tracks) {
698
+ if (track.muted || track.keys.length === 0)
699
+ continue;
700
+ const value = sampleTrack(track, t);
701
+ if (value === undefined)
702
+ continue;
703
+ yield { state: track.state, node: track.node, path: track.path, value };
704
+ }
705
+ }
706
+ const clipsRuntime = new ClipsRuntime();
707
+ export default clipsRuntime;