@ntalmagor/3drize-viewer 0.1.2

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 (337) hide show
  1. package/dist/components/AnimatedObject.d.ts +22 -0
  2. package/dist/components/AnimatedObject.d.ts.map +1 -0
  3. package/dist/components/AnimatedObject.js +121 -0
  4. package/dist/components/CameraController.d.ts +16 -0
  5. package/dist/components/CameraController.d.ts.map +1 -0
  6. package/dist/components/CameraController.js +132 -0
  7. package/dist/components/Clouds.d.ts +14 -0
  8. package/dist/components/Clouds.d.ts.map +1 -0
  9. package/dist/components/Clouds.js +97 -0
  10. package/dist/components/CreatedObject.d.ts +12 -0
  11. package/dist/components/CreatedObject.d.ts.map +1 -0
  12. package/dist/components/CreatedObject.js +139 -0
  13. package/dist/components/CustomPrimitive.d.ts +12 -0
  14. package/dist/components/CustomPrimitive.d.ts.map +1 -0
  15. package/dist/components/CustomPrimitive.js +80 -0
  16. package/dist/components/EffectsGenerator.d.ts +10 -0
  17. package/dist/components/EffectsGenerator.d.ts.map +1 -0
  18. package/dist/components/EffectsGenerator.js +59 -0
  19. package/dist/components/EffectsGroup.d.ts +8 -0
  20. package/dist/components/EffectsGroup.d.ts.map +1 -0
  21. package/dist/components/EffectsGroup.js +8 -0
  22. package/dist/components/EnvironmentManager.d.ts +9 -0
  23. package/dist/components/EnvironmentManager.d.ts.map +1 -0
  24. package/dist/components/EnvironmentManager.js +47 -0
  25. package/dist/components/Frame.d.ts +26 -0
  26. package/dist/components/Frame.d.ts.map +1 -0
  27. package/dist/components/Frame.js +50 -0
  28. package/dist/components/FrameGeometry.d.ts +10 -0
  29. package/dist/components/FrameGeometry.d.ts.map +1 -0
  30. package/dist/components/FrameGeometry.js +17 -0
  31. package/dist/components/FrameImage.d.ts +14 -0
  32. package/dist/components/FrameImage.d.ts.map +1 -0
  33. package/dist/components/FrameImage.js +15 -0
  34. package/dist/components/Galaxy.d.ts +8 -0
  35. package/dist/components/Galaxy.d.ts.map +1 -0
  36. package/dist/components/Galaxy.js +9 -0
  37. package/dist/components/GalleryLayout.d.ts +10 -0
  38. package/dist/components/GalleryLayout.d.ts.map +1 -0
  39. package/dist/components/GalleryLayout.js +18 -0
  40. package/dist/components/GridHelper.d.ts +23 -0
  41. package/dist/components/GridHelper.d.ts.map +1 -0
  42. package/dist/components/GridHelper.js +38 -0
  43. package/dist/components/ImageGeometry.d.ts +14 -0
  44. package/dist/components/ImageGeometry.d.ts.map +1 -0
  45. package/dist/components/ImageGeometry.js +62 -0
  46. package/dist/components/Lensflare.d.ts +12 -0
  47. package/dist/components/Lensflare.d.ts.map +1 -0
  48. package/dist/components/Lensflare.js +66 -0
  49. package/dist/components/Letter.d.ts +20 -0
  50. package/dist/components/Letter.d.ts.map +1 -0
  51. package/dist/components/Letter.js +83 -0
  52. package/dist/components/Letters.d.ts +16 -0
  53. package/dist/components/Letters.d.ts.map +1 -0
  54. package/dist/components/Letters.js +18 -0
  55. package/dist/components/LightsManager.d.ts +9 -0
  56. package/dist/components/LightsManager.d.ts.map +1 -0
  57. package/dist/components/LightsManager.js +121 -0
  58. package/dist/components/Lines.d.ts +9 -0
  59. package/dist/components/Lines.d.ts.map +1 -0
  60. package/dist/components/Lines.js +19 -0
  61. package/dist/components/LoadingIndicator.d.ts +10 -0
  62. package/dist/components/LoadingIndicator.d.ts.map +1 -0
  63. package/dist/components/LoadingIndicator.js +143 -0
  64. package/dist/components/MaterialLibrary.d.ts +9 -0
  65. package/dist/components/MaterialLibrary.d.ts.map +1 -0
  66. package/dist/components/MaterialLibrary.js +57 -0
  67. package/dist/components/Moon.d.ts +13 -0
  68. package/dist/components/Moon.d.ts.map +1 -0
  69. package/dist/components/Moon.js +52 -0
  70. package/dist/components/ObjectNode.d.ts +11 -0
  71. package/dist/components/ObjectNode.d.ts.map +1 -0
  72. package/dist/components/ObjectNode.js +61 -0
  73. package/dist/components/ObjectsRenderer.d.ts +11 -0
  74. package/dist/components/ObjectsRenderer.d.ts.map +1 -0
  75. package/dist/components/ObjectsRenderer.js +19 -0
  76. package/dist/components/Ocean.d.ts +8 -0
  77. package/dist/components/Ocean.d.ts.map +1 -0
  78. package/dist/components/Ocean.js +111 -0
  79. package/dist/components/ParticlesR3f.d.ts +16 -0
  80. package/dist/components/ParticlesR3f.d.ts.map +1 -0
  81. package/dist/components/ParticlesR3f.js +66 -0
  82. package/dist/components/Path.d.ts +13 -0
  83. package/dist/components/Path.d.ts.map +1 -0
  84. package/dist/components/Path.js +41 -0
  85. package/dist/components/PathGeometry.d.ts +11 -0
  86. package/dist/components/PathGeometry.d.ts.map +1 -0
  87. package/dist/components/PathGeometry.js +109 -0
  88. package/dist/components/PathRenderer.d.ts +14 -0
  89. package/dist/components/PathRenderer.d.ts.map +1 -0
  90. package/dist/components/PathRenderer.js +33 -0
  91. package/dist/components/ProductionScene.d.ts +29 -0
  92. package/dist/components/ProductionScene.d.ts.map +1 -0
  93. package/dist/components/ProductionScene.js +18 -0
  94. package/dist/components/ProjectLoader.d.ts +14 -0
  95. package/dist/components/ProjectLoader.d.ts.map +1 -0
  96. package/dist/components/ProjectLoader.js +76 -0
  97. package/dist/components/Rain.d.ts +8 -0
  98. package/dist/components/Rain.d.ts.map +1 -0
  99. package/dist/components/Rain.js +133 -0
  100. package/dist/components/SceneBuilder.d.ts +5 -0
  101. package/dist/components/SceneBuilder.d.ts.map +1 -0
  102. package/dist/components/SceneBuilder.js +104 -0
  103. package/dist/components/SceneFog.d.ts +8 -0
  104. package/dist/components/SceneFog.d.ts.map +1 -0
  105. package/dist/components/SceneFog.js +19 -0
  106. package/dist/components/ShootingStar.d.ts +16 -0
  107. package/dist/components/ShootingStar.d.ts.map +1 -0
  108. package/dist/components/ShootingStar.js +92 -0
  109. package/dist/components/ShootingStars.d.ts +8 -0
  110. package/dist/components/ShootingStars.d.ts.map +1 -0
  111. package/dist/components/ShootingStars.js +40 -0
  112. package/dist/components/SkyController.d.ts +10 -0
  113. package/dist/components/SkyController.d.ts.map +1 -0
  114. package/dist/components/SkyController.js +159 -0
  115. package/dist/components/SkyMesh.d.ts +11 -0
  116. package/dist/components/SkyMesh.d.ts.map +1 -0
  117. package/dist/components/SkyMesh.js +36 -0
  118. package/dist/components/SkySystem.d.ts +34 -0
  119. package/dist/components/SkySystem.d.ts.map +1 -0
  120. package/dist/components/SkySystem.js +47 -0
  121. package/dist/components/Skybox.d.ts +12 -0
  122. package/dist/components/Skybox.d.ts.map +1 -0
  123. package/dist/components/Skybox.js +79 -0
  124. package/dist/components/Stars.d.ts +14 -0
  125. package/dist/components/Stars.d.ts.map +1 -0
  126. package/dist/components/Stars.js +165 -0
  127. package/dist/components/SunLight.d.ts +15 -0
  128. package/dist/components/SunLight.d.ts.map +1 -0
  129. package/dist/components/SunLight.js +57 -0
  130. package/dist/components/Text2D.d.ts +9 -0
  131. package/dist/components/Text2D.d.ts.map +1 -0
  132. package/dist/components/Text2D.js +56 -0
  133. package/dist/components/Text3D.d.ts +10 -0
  134. package/dist/components/Text3D.d.ts.map +1 -0
  135. package/dist/components/Text3D.js +8 -0
  136. package/dist/components/effects/AuraEffect.d.ts +10 -0
  137. package/dist/components/effects/AuraEffect.d.ts.map +1 -0
  138. package/dist/components/effects/AuraEffect.js +127 -0
  139. package/dist/components/effects/AuroraEffect.d.ts +10 -0
  140. package/dist/components/effects/AuroraEffect.d.ts.map +1 -0
  141. package/dist/components/effects/AuroraEffect.js +112 -0
  142. package/dist/components/effects/BlackHoleEffect.d.ts +10 -0
  143. package/dist/components/effects/BlackHoleEffect.d.ts.map +1 -0
  144. package/dist/components/effects/BlackHoleEffect.js +193 -0
  145. package/dist/components/effects/ConstellationEffect.d.ts +10 -0
  146. package/dist/components/effects/ConstellationEffect.d.ts.map +1 -0
  147. package/dist/components/effects/ConstellationEffect.js +189 -0
  148. package/dist/components/effects/DataStreamEffect.d.ts +10 -0
  149. package/dist/components/effects/DataStreamEffect.d.ts.map +1 -0
  150. package/dist/components/effects/DataStreamEffect.js +138 -0
  151. package/dist/components/effects/DnaHelixEffect.d.ts +10 -0
  152. package/dist/components/effects/DnaHelixEffect.d.ts.map +1 -0
  153. package/dist/components/effects/DnaHelixEffect.js +311 -0
  154. package/dist/components/effects/FireEffect.d.ts +10 -0
  155. package/dist/components/effects/FireEffect.d.ts.map +1 -0
  156. package/dist/components/effects/FireEffect.js +194 -0
  157. package/dist/components/effects/ForcefieldEffect.d.ts +10 -0
  158. package/dist/components/effects/ForcefieldEffect.d.ts.map +1 -0
  159. package/dist/components/effects/ForcefieldEffect.js +132 -0
  160. package/dist/components/effects/HologramEffect.d.ts +10 -0
  161. package/dist/components/effects/HologramEffect.d.ts.map +1 -0
  162. package/dist/components/effects/HologramEffect.js +143 -0
  163. package/dist/components/effects/IceCrystalsEffect.d.ts +10 -0
  164. package/dist/components/effects/IceCrystalsEffect.d.ts.map +1 -0
  165. package/dist/components/effects/IceCrystalsEffect.js +190 -0
  166. package/dist/components/effects/LightningEffect.d.ts +10 -0
  167. package/dist/components/effects/LightningEffect.d.ts.map +1 -0
  168. package/dist/components/effects/LightningEffect.js +240 -0
  169. package/dist/components/effects/MoleculesEffect.d.ts +10 -0
  170. package/dist/components/effects/MoleculesEffect.d.ts.map +1 -0
  171. package/dist/components/effects/MoleculesEffect.js +179 -0
  172. package/dist/components/effects/NeuralNetworkEffect.d.ts +10 -0
  173. package/dist/components/effects/NeuralNetworkEffect.d.ts.map +1 -0
  174. package/dist/components/effects/NeuralNetworkEffect.js +188 -0
  175. package/dist/components/effects/OrbEffect.d.ts +10 -0
  176. package/dist/components/effects/OrbEffect.d.ts.map +1 -0
  177. package/dist/components/effects/OrbEffect.js +291 -0
  178. package/dist/components/effects/PortalEffect.d.ts +10 -0
  179. package/dist/components/effects/PortalEffect.d.ts.map +1 -0
  180. package/dist/components/effects/PortalEffect.js +191 -0
  181. package/dist/components/effects/ShockwaveEffect.d.ts +10 -0
  182. package/dist/components/effects/ShockwaveEffect.d.ts.map +1 -0
  183. package/dist/components/effects/ShockwaveEffect.js +159 -0
  184. package/dist/components/effects/SmokePlumeEffect.d.ts +10 -0
  185. package/dist/components/effects/SmokePlumeEffect.d.ts.map +1 -0
  186. package/dist/components/effects/SmokePlumeEffect.js +141 -0
  187. package/dist/components/effects/SmokeRingEffect.d.ts +10 -0
  188. package/dist/components/effects/SmokeRingEffect.d.ts.map +1 -0
  189. package/dist/components/effects/SmokeRingEffect.js +158 -0
  190. package/dist/components/effects/VolumetricFogEffect.d.ts +10 -0
  191. package/dist/components/effects/VolumetricFogEffect.d.ts.map +1 -0
  192. package/dist/components/effects/VolumetricFogEffect.js +111 -0
  193. package/dist/constants.d.ts +2 -0
  194. package/dist/constants.d.ts.map +1 -0
  195. package/dist/constants.js +1 -0
  196. package/dist/hooks/index.d.ts +1 -0
  197. package/dist/hooks/index.d.ts.map +1 -0
  198. package/dist/hooks/index.js +1 -0
  199. package/dist/hooks/useAnimationEvents.d.ts +10 -0
  200. package/dist/hooks/useAnimationEvents.d.ts.map +1 -0
  201. package/dist/hooks/useAnimationEvents.js +28 -0
  202. package/dist/hooks/useCameraAnimation.d.ts +35 -0
  203. package/dist/hooks/useCameraAnimation.d.ts.map +1 -0
  204. package/dist/hooks/useCameraAnimation.js +268 -0
  205. package/dist/hooks/useContinuousEffects.d.ts +15 -0
  206. package/dist/hooks/useContinuousEffects.d.ts.map +1 -0
  207. package/dist/hooks/useContinuousEffects.js +173 -0
  208. package/dist/hooks/useCubeCamera.d.ts +19 -0
  209. package/dist/hooks/useCubeCamera.d.ts.map +1 -0
  210. package/dist/hooks/useCubeCamera.js +73 -0
  211. package/dist/hooks/useEnvironmentEffects.d.ts +12 -0
  212. package/dist/hooks/useEnvironmentEffects.d.ts.map +1 -0
  213. package/dist/hooks/useEnvironmentEffects.js +22 -0
  214. package/dist/hooks/useFrameEffects.d.ts +6 -0
  215. package/dist/hooks/useFrameEffects.d.ts.map +1 -0
  216. package/dist/hooks/useFrameEffects.js +19 -0
  217. package/dist/hooks/useInteractionEffects.d.ts +11 -0
  218. package/dist/hooks/useInteractionEffects.d.ts.map +1 -0
  219. package/dist/hooks/useInteractionEffects.js +35 -0
  220. package/dist/hooks/useKey.d.ts +26 -0
  221. package/dist/hooks/useKey.d.ts.map +1 -0
  222. package/dist/hooks/useKey.js +73 -0
  223. package/dist/hooks/useLightHandlers.d.ts +14 -0
  224. package/dist/hooks/useLightHandlers.d.ts.map +1 -0
  225. package/dist/hooks/useLightHandlers.js +116 -0
  226. package/dist/hooks/useMaterialApplication.d.ts +9 -0
  227. package/dist/hooks/useMaterialApplication.d.ts.map +1 -0
  228. package/dist/hooks/useMaterialApplication.js +113 -0
  229. package/dist/hooks/useMaterialOptions.d.ts +13 -0
  230. package/dist/hooks/useMaterialOptions.d.ts.map +1 -0
  231. package/dist/hooks/useMaterialOptions.js +110 -0
  232. package/dist/hooks/useMaterialUniforms.d.ts +18 -0
  233. package/dist/hooks/useMaterialUniforms.d.ts.map +1 -0
  234. package/dist/hooks/useMaterialUniforms.js +96 -0
  235. package/dist/hooks/useMeshController.d.ts +3 -0
  236. package/dist/hooks/useMeshController.d.ts.map +1 -0
  237. package/dist/hooks/useMeshController.js +152 -0
  238. package/dist/hooks/useMouseHandlers.d.ts +8 -0
  239. package/dist/hooks/useMouseHandlers.d.ts.map +1 -0
  240. package/dist/hooks/useMouseHandlers.js +47 -0
  241. package/dist/hooks/useObjectAnimation.d.ts +13 -0
  242. package/dist/hooks/useObjectAnimation.d.ts.map +1 -0
  243. package/dist/hooks/useObjectAnimation.js +11 -0
  244. package/dist/hooks/useObjectEdges.d.ts +4 -0
  245. package/dist/hooks/useObjectEdges.d.ts.map +1 -0
  246. package/dist/hooks/useObjectEdges.js +199 -0
  247. package/dist/hooks/useOrbitControls.d.ts +7 -0
  248. package/dist/hooks/useOrbitControls.d.ts.map +1 -0
  249. package/dist/hooks/useOrbitControls.js +9 -0
  250. package/dist/hooks/useParticlePositions.d.ts +19 -0
  251. package/dist/hooks/useParticlePositions.d.ts.map +1 -0
  252. package/dist/hooks/useParticlePositions.js +56 -0
  253. package/dist/hooks/useParticlesColors.d.ts +14 -0
  254. package/dist/hooks/useParticlesColors.d.ts.map +1 -0
  255. package/dist/hooks/useParticlesColors.js +27 -0
  256. package/dist/hooks/useParticlesTextures.d.ts +10 -0
  257. package/dist/hooks/useParticlesTextures.d.ts.map +1 -0
  258. package/dist/hooks/useParticlesTextures.js +23 -0
  259. package/dist/hooks/usePathAnimation.d.ts +26 -0
  260. package/dist/hooks/usePathAnimation.d.ts.map +1 -0
  261. package/dist/hooks/usePathAnimation.js +120 -0
  262. package/dist/hooks/useSkyAnimation.d.ts +14 -0
  263. package/dist/hooks/useSkyAnimation.d.ts.map +1 -0
  264. package/dist/hooks/useSkyAnimation.js +46 -0
  265. package/dist/hooks/useSkySystem.d.ts +26 -0
  266. package/dist/hooks/useSkySystem.d.ts.map +1 -0
  267. package/dist/hooks/useSkySystem.js +57 -0
  268. package/dist/hooks/useSkyUniforms.d.ts +18 -0
  269. package/dist/hooks/useSkyUniforms.d.ts.map +1 -0
  270. package/dist/hooks/useSkyUniforms.js +59 -0
  271. package/dist/hooks/useTransformControls.d.ts +6 -0
  272. package/dist/hooks/useTransformControls.d.ts.map +1 -0
  273. package/dist/hooks/useTransformControls.js +111 -0
  274. package/dist/hooks/useWaterEnvironment.d.ts +5 -0
  275. package/dist/hooks/useWaterEnvironment.d.ts.map +1 -0
  276. package/dist/hooks/useWaterEnvironment.js +27 -0
  277. package/dist/hooks/useWaterReflections.d.ts +17 -0
  278. package/dist/hooks/useWaterReflections.d.ts.map +1 -0
  279. package/dist/hooks/useWaterReflections.js +77 -0
  280. package/dist/index.d.ts +140 -0
  281. package/dist/index.d.ts.map +1 -0
  282. package/dist/index.js +109 -0
  283. package/dist/services/AnimationsManager.d.ts +33 -0
  284. package/dist/services/AnimationsManager.d.ts.map +1 -0
  285. package/dist/services/AnimationsManager.js +58 -0
  286. package/dist/services/FontManager.d.ts +32 -0
  287. package/dist/services/FontManager.d.ts.map +1 -0
  288. package/dist/services/FontManager.js +76 -0
  289. package/dist/services/TexturesManager.d.ts +17 -0
  290. package/dist/services/TexturesManager.d.ts.map +1 -0
  291. package/dist/services/TexturesManager.js +48 -0
  292. package/dist/shaders/RainMaterial.d.ts +34 -0
  293. package/dist/shaders/RainMaterial.d.ts.map +1 -0
  294. package/dist/shaders/RainMaterial.js +56 -0
  295. package/dist/shaders/ShaderEffectsMaterial.d.ts +279 -0
  296. package/dist/shaders/ShaderEffectsMaterial.d.ts.map +1 -0
  297. package/dist/shaders/ShaderEffectsMaterial.js +257 -0
  298. package/dist/shaders/ShootingStarMaterial.d.ts +14 -0
  299. package/dist/shaders/ShootingStarMaterial.d.ts.map +1 -0
  300. package/dist/shaders/ShootingStarMaterial.js +33 -0
  301. package/dist/shaders/SkyboxMaterial.d.ts +38 -0
  302. package/dist/shaders/SkyboxMaterial.d.ts.map +1 -0
  303. package/dist/shaders/SkyboxMaterial.js +57 -0
  304. package/dist/shaders/effects/EffectsVertexFunctions.glsl.d.ts +2 -0
  305. package/dist/shaders/effects/EffectsVertexFunctions.glsl.d.ts.map +1 -0
  306. package/dist/shaders/effects/EffectsVertexFunctions.glsl.js +167 -0
  307. package/dist/utils/CameraSingleton.d.ts +35 -0
  308. package/dist/utils/CameraSingleton.d.ts.map +1 -0
  309. package/dist/utils/CameraSingleton.js +178 -0
  310. package/dist/utils/anchorUtils.d.ts +10 -0
  311. package/dist/utils/anchorUtils.d.ts.map +1 -0
  312. package/dist/utils/anchorUtils.js +13 -0
  313. package/dist/utils/frameAnimations.d.ts +49 -0
  314. package/dist/utils/frameAnimations.d.ts.map +1 -0
  315. package/dist/utils/frameAnimations.js +213 -0
  316. package/dist/utils/handleGenerativeEffectsAnimations.d.ts +5 -0
  317. package/dist/utils/handleGenerativeEffectsAnimations.d.ts.map +1 -0
  318. package/dist/utils/handleGenerativeEffectsAnimations.js +268 -0
  319. package/dist/utils/hasHoverAnimation.d.ts +3 -0
  320. package/dist/utils/hasHoverAnimation.d.ts.map +1 -0
  321. package/dist/utils/hasHoverAnimation.js +15 -0
  322. package/dist/utils/particleAnimations.d.ts +3 -0
  323. package/dist/utils/particleAnimations.d.ts.map +1 -0
  324. package/dist/utils/particleAnimations.js +17 -0
  325. package/dist/utils/sceneQuery.d.ts +9 -0
  326. package/dist/utils/sceneQuery.d.ts.map +1 -0
  327. package/dist/utils/sceneQuery.js +22 -0
  328. package/dist/utils/shaderUtils.d.ts +6 -0
  329. package/dist/utils/shaderUtils.d.ts.map +1 -0
  330. package/dist/utils/shaderUtils.js +145 -0
  331. package/dist/utils/textEffects.d.ts +31 -0
  332. package/dist/utils/textEffects.d.ts.map +1 -0
  333. package/dist/utils/textEffects.js +61 -0
  334. package/dist/utils/utils3d.d.ts +7 -0
  335. package/dist/utils/utils3d.d.ts.map +1 -0
  336. package/dist/utils/utils3d.js +34 -0
  337. package/package.json +43 -0
@@ -0,0 +1,199 @@
1
+ import { useEffect, useMemo, useRef } from 'react';
2
+ import { BoxGeometry, BufferGeometry, CylinderGeometry, EdgesGeometry, Group, LineSegments, Mesh, MeshBasicMaterial, Points, PointsMaterial, Quaternion, Vector3, Float32BufferAttribute, } from 'three';
3
+ import { useFrame } from '@react-three/fiber';
4
+ import { collectMeshes, computeThreshold, buildSubdividedEdgeGeometry, EDGES_GROUP_KEY, animateUniforms, cacheChildrenWithMaterials } from '@ntalmagor/3drize-core';
5
+ import { useMaterialApplication } from './useMaterialApplication';
6
+ ;
7
+ // import { animateUniforms, cacheChildrenWithMaterials } from "~/utils/materialUtils";
8
+ const DEFAULT_TUBE_RADIUS = 0.01;
9
+ const DEFAULT_CUBE_SIZE = 0.02;
10
+ // ─── Builders ────────────────────────────────────────────────────────────────
11
+ function edgesGeoToQuadMesh(edgesGeo, thickness = 0.008) {
12
+ const src = edgesGeo.attributes.position;
13
+ const segCount = src.count / 2; // each segment = 2 vertices
14
+ const positions = [];
15
+ const uvs = [];
16
+ const indices = [];
17
+ const start = new Vector3();
18
+ const end = new Vector3();
19
+ const dir = new Vector3();
20
+ const up = new Vector3(0, 1, 0);
21
+ const right = new Vector3();
22
+ for (let i = 0; i < segCount; i++) {
23
+ start.fromBufferAttribute(src, i * 2);
24
+ end.fromBufferAttribute(src, i * 2 + 1);
25
+ dir.subVectors(end, start).normalize();
26
+ // Perpendicular axis — fallback to X if segment is vertical
27
+ right.crossVectors(dir, up).normalize();
28
+ if (right.lengthSq() < 0.0001) {
29
+ right.set(1, 0, 0);
30
+ }
31
+ const rx = right.x * thickness;
32
+ const ry = right.y * thickness;
33
+ const rz = right.z * thickness;
34
+ const base = i * 4;
35
+ // v0 start-bottom uv(0,0)
36
+ positions.push(start.x - rx, start.y - ry, start.z - rz);
37
+ uvs.push(0, 0);
38
+ // v1 end-bottom uv(1,0)
39
+ positions.push(end.x - rx, end.y - ry, end.z - rz);
40
+ uvs.push(1, 0);
41
+ // v2 start-top uv(0,1)
42
+ positions.push(start.x + rx, start.y + ry, start.z + rz);
43
+ uvs.push(0, 1);
44
+ // v3 end-top uv(1,1)
45
+ positions.push(end.x + rx, end.y + ry, end.z + rz);
46
+ uvs.push(1, 1);
47
+ indices.push(base, base + 1, base + 2);
48
+ indices.push(base + 1, base + 3, base + 2);
49
+ }
50
+ const geo = new BufferGeometry();
51
+ geo.setAttribute("position", new Float32BufferAttribute(positions, 3));
52
+ geo.setAttribute("uv", new Float32BufferAttribute(uvs, 2));
53
+ geo.setIndex(indices);
54
+ geo.computeVertexNormals();
55
+ return new Mesh(geo);
56
+ }
57
+ function buildLineGroup(object, localParent) {
58
+ const g = new Group();
59
+ for (const { mesh, matrixRelativeToRoot } of collectMeshes(object, localParent)) {
60
+ const threshold = computeThreshold(mesh.geometry);
61
+ const edgesGeo = new EdgesGeometry(mesh.geometry, threshold);
62
+ const position = new Vector3();
63
+ const quaternion = new Quaternion();
64
+ const scale = new Vector3();
65
+ matrixRelativeToRoot.decompose(position, quaternion, scale);
66
+ const quadMesh = edgesGeoToQuadMesh(edgesGeo);
67
+ quadMesh.position.copy(position);
68
+ quadMesh.quaternion.copy(quaternion);
69
+ quadMesh.scale.copy(scale);
70
+ quadMesh.renderOrder = 1;
71
+ g.add(quadMesh);
72
+ }
73
+ return g;
74
+ }
75
+ function buildSegmentMeshGroup(object, localParent, geoFn) {
76
+ const g = new Group();
77
+ for (const { mesh, matrixRelativeToRoot } of collectMeshes(object, localParent)) {
78
+ const threshold = computeThreshold(mesh.geometry);
79
+ const edgesGeo = new EdgesGeometry(mesh.geometry, threshold);
80
+ const posAttr = edgesGeo.attributes.position;
81
+ const subGroup = new Group();
82
+ const position = new Vector3();
83
+ const quaternion = new Quaternion();
84
+ const scale = new Vector3();
85
+ matrixRelativeToRoot.decompose(position, quaternion, scale);
86
+ subGroup.position.copy(position);
87
+ subGroup.quaternion.copy(quaternion);
88
+ subGroup.scale.copy(scale);
89
+ for (let i = 0; i < posAttr.count; i += 2) {
90
+ const start = new Vector3(posAttr.getX(i), posAttr.getY(i), posAttr.getZ(i));
91
+ const end = new Vector3(posAttr.getX(i + 1), posAttr.getY(i + 1), posAttr.getZ(i + 1));
92
+ const dir = end.clone().sub(start);
93
+ const length = dir.length();
94
+ if (length < 0.0001)
95
+ continue;
96
+ const midpoint = start.clone().add(end).multiplyScalar(0.5);
97
+ const segQuat = new Quaternion().setFromUnitVectors(new Vector3(0, 1, 0), dir.normalize());
98
+ const m = new Mesh(geoFn(length), new MeshBasicMaterial());
99
+ m.position.copy(midpoint);
100
+ m.quaternion.copy(segQuat);
101
+ m.renderOrder = 1;
102
+ subGroup.add(m);
103
+ }
104
+ g.add(subGroup);
105
+ edgesGeo.dispose();
106
+ }
107
+ return g;
108
+ }
109
+ function buildTubeGroup(object, localParent, tubeRadius) {
110
+ return buildSegmentMeshGroup(object, localParent, (length) => new CylinderGeometry(tubeRadius, tubeRadius, length, 4));
111
+ }
112
+ function buildCubeGroup(object, localParent, cubeSize) {
113
+ return buildSegmentMeshGroup(object, localParent, (length) => new BoxGeometry(cubeSize, length, cubeSize));
114
+ }
115
+ function buildParticlesGroup(object, localParent) {
116
+ const g = new Group();
117
+ const geo = buildSubdividedEdgeGeometry(object, 30, localParent);
118
+ const points = new Points(geo, new PointsMaterial({ size: 0.02 }));
119
+ points.renderOrder = 1;
120
+ g.add(points);
121
+ return g;
122
+ }
123
+ function buildEdgesGroup(object, edgesSettings) {
124
+ // Compute the inverse of the object's current local matrix so that
125
+ // collectMeshes results are in object-local space. Without this, the
126
+ // transforms include the object's own matrix and get double-applied when
127
+ // the edges group is added as a child of the object.
128
+ object.updateMatrix();
129
+ const localParent = object.matrix.clone().invert();
130
+ const tubeRadius = edgesSettings.tubeRadius ?? DEFAULT_TUBE_RADIUS;
131
+ const cubeSize = edgesSettings.cubeSize ?? DEFAULT_CUBE_SIZE;
132
+ let g;
133
+ switch (edgesSettings.type) {
134
+ case 'tube':
135
+ g = buildTubeGroup(object, localParent, tubeRadius);
136
+ break;
137
+ case 'cube':
138
+ g = buildCubeGroup(object, localParent, cubeSize);
139
+ break;
140
+ case 'particles':
141
+ g = buildParticlesGroup(object, localParent);
142
+ break;
143
+ default: g = buildLineGroup(object, localParent);
144
+ }
145
+ g.userData[EDGES_GROUP_KEY] = true;
146
+ return g;
147
+ }
148
+ // ─── Cleanup ─────────────────────────────────────────────────────────────────
149
+ function disposeGroup(group) {
150
+ if (!group)
151
+ return;
152
+ group.traverse((child) => {
153
+ if (child instanceof Mesh || child instanceof LineSegments || child instanceof Points) {
154
+ child.geometry.dispose();
155
+ if (Array.isArray(child.material)) {
156
+ child.material.forEach((m) => m.dispose());
157
+ }
158
+ else {
159
+ child.material.dispose?.();
160
+ }
161
+ }
162
+ });
163
+ }
164
+ // ─── Hook ─────────────────────────────────────────────────────────────────────
165
+ export function useObjectEdges(object, edgesSettings) {
166
+ const childrenWithMaterialsRef = useRef([]);
167
+ const edgesGroup = useMemo(() => {
168
+ // console.log(object)
169
+ if (!object || !edgesSettings.enabled)
170
+ return null;
171
+ return buildEdgesGroup(object, edgesSettings);
172
+ // Rebuild when geometry-affecting settings change
173
+ // eslint-disable-next-line react-hooks/exhaustive-deps
174
+ }, [object, edgesSettings.type, edgesSettings.enabled, edgesSettings.tubeRadius, edgesSettings.cubeSize]);
175
+ // Attach edges to the live object so they move with it
176
+ useEffect(() => {
177
+ if (!object || !edgesGroup)
178
+ return;
179
+ object.add(edgesGroup);
180
+ return () => { object.remove(edgesGroup); };
181
+ }, [object, edgesGroup]);
182
+ // Dispose Three.js resources when group is rebuilt or hook unmounts
183
+ useEffect(() => {
184
+ return () => { disposeGroup(edgesGroup); };
185
+ }, [edgesGroup]);
186
+ // Cache edge meshes after the group is attached so useFrame has them on first frame
187
+ useEffect(() => {
188
+ childrenWithMaterialsRef.current = edgesGroup ? cacheChildrenWithMaterials(edgesGroup) : [];
189
+ }, [edgesGroup]);
190
+ useFrame((state, delta) => {
191
+ if (!edgesGroup)
192
+ return;
193
+ const time = state.clock.getElapsedTime();
194
+ const mouse = state.pointer;
195
+ animateUniforms(childrenWithMaterialsRef.current, time, mouse, state.camera.position);
196
+ });
197
+ // Apply material reactively — works for all three types since each child has .material
198
+ useMaterialApplication(edgesGroup, edgesSettings.materialSettings, edgesSettings.enabled);
199
+ }
@@ -0,0 +1,7 @@
1
+ import { OrbitControls as OrbitControlsImpl } from 'three-stdlib';
2
+ /**
3
+ * Hook to access OrbitControls from any component within the R3F Canvas
4
+ * Returns the OrbitControls instance with proper typing, or null if not available
5
+ */
6
+ export declare function useOrbitControls(): OrbitControlsImpl | null;
7
+ //# sourceMappingURL=useOrbitControls.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"useOrbitControls.d.ts","sourceRoot":"","sources":["../../src/hooks/useOrbitControls.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,aAAa,IAAI,iBAAiB,EAAE,MAAM,cAAc,CAAC;AAElE;;;GAGG;AACH,wBAAgB,gBAAgB,IAEX,iBAAiB,GAAG,IAAI,CAC5C"}
@@ -0,0 +1,9 @@
1
+ import { useThree } from '@react-three/fiber';
2
+ /**
3
+ * Hook to access OrbitControls from any component within the R3F Canvas
4
+ * Returns the OrbitControls instance with proper typing, or null if not available
5
+ */
6
+ export function useOrbitControls() {
7
+ const { controls } = useThree();
8
+ return controls;
9
+ }
@@ -0,0 +1,19 @@
1
+ import type { PositionShape } from '@ntalmagor/3drize-core';
2
+ import type { Points } from 'three';
3
+ interface UseParticlePositionsProps {
4
+ shapeType: string;
5
+ targetShape: PositionShape | undefined;
6
+ count: number;
7
+ outlines: boolean;
8
+ targetOutLines: boolean | undefined;
9
+ pointsRef: React.RefObject<Points | null>;
10
+ }
11
+ export declare const useParticlePositions: ({ shapeType, targetShape, count, outlines, targetOutLines, pointsRef, }: UseParticlePositionsProps) => {
12
+ basePositions: import("react").RefObject<Float32Array<ArrayBufferLike> | null>;
13
+ targetPositions: import("react").RefObject<Float32Array<ArrayBufferLike> | null>;
14
+ animationProgress: import("react").RefObject<number>;
15
+ positionsVersion: number;
16
+ uvs: Float32Array<ArrayBufferLike> | null;
17
+ };
18
+ export {};
19
+ //# sourceMappingURL=useParticlePositions.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"useParticlePositions.d.ts","sourceRoot":"","sources":["../../src/hooks/useParticlePositions.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,aAAa,EAAe,MAAM,wBAAwB,CAAC;AACzE,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,OAAO,CAAC;AAEpC,UAAU,yBAAyB;IACjC,SAAS,EAAE,MAAM,CAAC;IAClB,WAAW,EAAE,aAAa,GAAG,SAAS,CAAC;IACvC,KAAK,EAAE,MAAM,CAAC;IACd,QAAQ,EAAE,OAAO,CAAC;IAClB,cAAc,EAAE,OAAO,GAAG,SAAS,CAAC;IACpC,SAAS,EAAE,KAAK,CAAC,SAAS,CAAC,MAAM,GAAG,IAAI,CAAC,CAAC;CAC3C;AAsBD,eAAO,MAAM,oBAAoB,GAAI,yEAOlC,yBAAyB;;;;;;CAoC3B,CAAC"}
@@ -0,0 +1,56 @@
1
+ import { useEffect, useRef, useState } from 'react';
2
+ import { PositionsCreator, shapeConfig } from '@ntalmagor/3drize-core';
3
+ function generateUVsFromPositions(positions) {
4
+ const count = positions.length / 3;
5
+ let minX = Infinity, maxX = -Infinity, minY = Infinity, maxY = -Infinity;
6
+ for (let i = 0; i < positions.length; i += 3) {
7
+ minX = Math.min(minX, positions[i]);
8
+ maxX = Math.max(maxX, positions[i]);
9
+ minY = Math.min(minY, positions[i + 1]);
10
+ maxY = Math.max(maxY, positions[i + 1]);
11
+ }
12
+ const rangeX = maxX - minX || 1;
13
+ const rangeY = maxY - minY || 1;
14
+ const uvs = new Float32Array(count * 2);
15
+ for (let i = 0; i < positions.length; i += 3) {
16
+ const idx = (i / 3) * 2;
17
+ uvs[idx] = (positions[i] - minX) / rangeX;
18
+ uvs[idx + 1] = (positions[i + 1] - minY) / rangeY;
19
+ }
20
+ return uvs;
21
+ }
22
+ export const useParticlePositions = ({ shapeType, targetShape, count, outlines, targetOutLines, pointsRef, }) => {
23
+ const basePositions = useRef(null);
24
+ const targetPositions = useRef(null);
25
+ const animationProgress = useRef(0);
26
+ const uvs = useRef(null);
27
+ const [positionsVersion, setPositionsVersion] = useState(0);
28
+ useEffect(() => {
29
+ const shapeParams = {
30
+ length: count,
31
+ name: shapeType,
32
+ outlines,
33
+ ...(shapeConfig[shapeType] || {}),
34
+ };
35
+ const newPositions = PositionsCreator.generatePositions(shapeParams);
36
+ basePositions.current = newPositions;
37
+ uvs.current = generateUVsFromPositions(newPositions);
38
+ setPositionsVersion(v => v + 1);
39
+ }, [shapeType, count, outlines]);
40
+ useEffect(() => {
41
+ if (!targetShape || targetShape === 'none') {
42
+ targetPositions.current = null;
43
+ }
44
+ else {
45
+ const shapeParams = {
46
+ length: count,
47
+ name: targetShape,
48
+ outlines: targetOutLines,
49
+ ...(shapeConfig[targetShape] || {}),
50
+ };
51
+ targetPositions.current = PositionsCreator.generatePositions(shapeParams);
52
+ animationProgress.current = 0;
53
+ }
54
+ }, [targetShape, count, targetOutLines]);
55
+ return { basePositions, targetPositions, animationProgress, positionsVersion, uvs: uvs.current };
56
+ };
@@ -0,0 +1,14 @@
1
+ import { Color } from 'three';
2
+ interface UseParticlesColorsProps {
3
+ color: string;
4
+ targetColor?: string;
5
+ }
6
+ export declare const useParticlesColors: ({ color, targetColor }: UseParticlesColorsProps) => {
7
+ baseColorRef: import("react").RefObject<Color>;
8
+ targetColorRef: import("react").RefObject<Color>;
9
+ colorAnimationProgress: import("react").RefObject<number>;
10
+ currentColorRef: import("react").RefObject<Color>;
11
+ handleColorsAnimation: (materialRef: React.RefObject<any>, delta: number, speed: number) => void;
12
+ };
13
+ export {};
14
+ //# sourceMappingURL=useParticlesColors.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"useParticlesColors.d.ts","sourceRoot":"","sources":["../../src/hooks/useParticlesColors.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,KAAK,EAAE,MAAM,OAAO,CAAC;AAE9B,UAAU,uBAAuB;IAC/B,KAAK,EAAE,MAAM,CAAC;IACd,WAAW,CAAC,EAAE,MAAM,CAAC;CACtB;AAED,eAAO,MAAM,kBAAkB,GAAI,wBAAwB,uBAAuB;;;;;yCAgBhE,KAAK,CAAC,SAAS,CAAC,GAAG,CAAC,SAAS,MAAM,SAAS,MAAM;CAcnE,CAAC"}
@@ -0,0 +1,27 @@
1
+ import { useRef, useEffect, useCallback } from 'react';
2
+ import { Color } from 'three';
3
+ export const useParticlesColors = ({ color, targetColor }) => {
4
+ const baseColorRef = useRef(new Color(color));
5
+ const colorAnimationProgress = useRef(0);
6
+ const currentColorRef = useRef(new Color());
7
+ const targetColorRef = useRef(targetColor ? new Color(targetColor) : new Color(color));
8
+ useEffect(() => { baseColorRef.current.set(color); }, [color]);
9
+ useEffect(() => {
10
+ if (targetColor) {
11
+ colorAnimationProgress.current = 0;
12
+ targetColorRef.current.set(targetColor);
13
+ }
14
+ }, [targetColor]);
15
+ const handleColorsAnimation = useCallback((materialRef, delta, speed) => {
16
+ if (!materialRef.current)
17
+ return;
18
+ if (!targetColor || targetColor === color) {
19
+ colorAnimationProgress.current = 0;
20
+ return;
21
+ }
22
+ colorAnimationProgress.current = Math.min(colorAnimationProgress.current + delta * speed, 1);
23
+ currentColorRef.current.lerpColors(baseColorRef.current, targetColorRef.current, colorAnimationProgress.current);
24
+ materialRef.current.uniforms.uColor.value = currentColorRef.current;
25
+ }, [color, targetColor]);
26
+ return { baseColorRef, targetColorRef, colorAnimationProgress, currentColorRef, handleColorsAnimation };
27
+ };
@@ -0,0 +1,10 @@
1
+ import type { Texture } from 'three';
2
+ export declare const useParticlesTextures: () => {
3
+ currentTexture: import("react").RefObject<Texture | null>;
4
+ prevTexture: import("react").RefObject<Texture | null>;
5
+ loadTexture: (url: string) => Promise<Texture | null>;
6
+ clearPreviousTexture: () => void;
7
+ textureProgress: import("react").RefObject<number>;
8
+ handleTextureAnimation: (materialRef: React.RefObject<any>, delta: number, speed: number) => void;
9
+ };
10
+ //# sourceMappingURL=useParticlesTextures.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"useParticlesTextures.d.ts","sourceRoot":"","sources":["../../src/hooks/useParticlesTextures.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,OAAO,CAAC;AAGrC,eAAO,MAAM,oBAAoB;;;uBAKC,MAAM,KAAG,OAAO,CAAC,OAAO,GAAG,IAAI,CAAC;;;0CAUhD,KAAK,CAAC,SAAS,CAAC,GAAG,CAAC,SAAS,MAAM,SAAS,MAAM;CASnE,CAAC"}
@@ -0,0 +1,23 @@
1
+ import { useRef, useCallback } from 'react';
2
+ import texturesManager from '../../../core/src/services/TexturesManager';
3
+ export const useParticlesTextures = () => {
4
+ const currentTexture = useRef(null);
5
+ const prevTexture = useRef(null);
6
+ const textureProgress = useRef(0);
7
+ const loadTexture = async (url) => {
8
+ if (currentTexture.current)
9
+ prevTexture.current = currentTexture.current;
10
+ const tex = await texturesManager.loadTexture(`image-${url}`, url, 'images');
11
+ if (tex)
12
+ currentTexture.current = tex;
13
+ return tex;
14
+ };
15
+ const clearPreviousTexture = () => { prevTexture.current = null; };
16
+ const handleTextureAnimation = useCallback((materialRef, delta, speed) => {
17
+ if (!materialRef.current || !currentTexture.current)
18
+ return;
19
+ textureProgress.current = Math.min(textureProgress.current + delta * speed, 1);
20
+ materialRef.current.uniforms.uMorphProgress.value = textureProgress.current;
21
+ }, []);
22
+ return { currentTexture, prevTexture, loadTexture, clearPreviousTexture, textureProgress, handleTextureAnimation };
23
+ };
@@ -0,0 +1,26 @@
1
+ import * as THREE from 'three';
2
+ import type { Object3D } from 'three';
3
+ import type { Vector3Array } from '@ntalmagor/3drize-core';
4
+ export interface PathAnimationOptions {
5
+ ease?: string;
6
+ loop?: boolean;
7
+ yoyo?: boolean;
8
+ speed?: number;
9
+ faceDirection?: boolean;
10
+ applyRotation?: boolean;
11
+ offset?: Vector3Array;
12
+ keepOriginalTransform?: boolean;
13
+ onComplete?: () => void;
14
+ }
15
+ export declare const usePathAnimation: () => {
16
+ startPathAnimation: (pathId: string, duration: number, options?: PathAnimationOptions) => boolean;
17
+ stopPathAnimation: () => void;
18
+ updatePathAnimation: (delta: number, object: Object3D) => boolean;
19
+ isAnimating: () => boolean;
20
+ getPositionAt: (t: number) => {
21
+ position: THREE.Vector3;
22
+ direction: THREE.Vector3;
23
+ };
24
+ };
25
+ export default usePathAnimation;
26
+ //# sourceMappingURL=usePathAnimation.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"usePathAnimation.d.ts","sourceRoot":"","sources":["../../src/hooks/usePathAnimation.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAC/B,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAC;AACtC,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,wBAAwB,CAAC;AAI3D,MAAM,WAAW,oBAAoB;IACnC,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,IAAI,CAAC,EAAE,OAAO,CAAC;IACf,IAAI,CAAC,EAAE,OAAO,CAAC;IACf,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,aAAa,CAAC,EAAE,OAAO,CAAC;IACxB,aAAa,CAAC,EAAE,OAAO,CAAC;IACxB,MAAM,CAAC,EAAE,YAAY,CAAC;IACtB,qBAAqB,CAAC,EAAE,OAAO,CAAC;IAChC,UAAU,CAAC,EAAE,MAAM,IAAI,CAAC;CACzB;AAED,eAAO,MAAM,gBAAgB;iCAoBjB,MAAM,YACJ,MAAM,YACP,oBAAoB,KAC5B,OAAO;;iCA0DsC,MAAM,UAAU,QAAQ,KAAG,OAAO;;uBAtB5C,MAAM,KAAG;QAAE,QAAQ,EAAE,KAAK,CAAC,OAAO,CAAC;QAAC,SAAS,EAAE,KAAK,CAAC,OAAO,CAAA;KAAE;CA6ErG,CAAC;AAEF,eAAe,gBAAgB,CAAC"}
@@ -0,0 +1,120 @@
1
+ import { useRef, useCallback, useEffect } from 'react';
2
+ import * as THREE from 'three';
3
+ import { smoothPathCorners, createPathSpline, applyEasing, resolveEasing } from '@ntalmagor/3drize-core';
4
+ import AnimationsManager from '../../../core/src/services/AnimationsManager';
5
+ export const usePathAnimation = () => {
6
+ const pointsRef = useRef([]);
7
+ const progressRef = useRef(0);
8
+ const durationRef = useRef(1);
9
+ const splineRef = useRef(null);
10
+ const activeRef = useRef(false);
11
+ const directionRef = useRef(1);
12
+ const easeRef = useRef(null);
13
+ const loopRef = useRef(false);
14
+ const yoyoRef = useRef(false);
15
+ const speedRef = useRef(1);
16
+ const faceRef = useRef(true);
17
+ const applyRotRef = useRef(true);
18
+ const offsetRef = useRef(null);
19
+ const onCompleteRef = useRef(null);
20
+ const targetQuatRef = useRef(new THREE.Quaternion());
21
+ useEffect(() => () => { splineRef.current = null; }, []);
22
+ const startPathAnimation = useCallback((pathId, duration, options = {}) => {
23
+ const cfg = AnimationsManager.getPath(pathId);
24
+ if (!cfg || cfg.points.length < 2)
25
+ return false;
26
+ const smooth = cfg.smoothCorners ?? 0;
27
+ const pts = smooth > 0 && cfg.points.length >= 3
28
+ ? smoothPathCorners(cfg.points, smooth)
29
+ : cfg.points;
30
+ pointsRef.current = pts;
31
+ progressRef.current = 0;
32
+ durationRef.current = duration;
33
+ activeRef.current = true;
34
+ directionRef.current = 1;
35
+ easeRef.current = options.ease ?? null;
36
+ loopRef.current = options.loop ?? false;
37
+ yoyoRef.current = options.yoyo ?? false;
38
+ speedRef.current = options.speed ?? 1;
39
+ faceRef.current = options.faceDirection ?? true;
40
+ applyRotRef.current = options.applyRotation ?? cfg.applyRotation ?? true;
41
+ offsetRef.current = options.offset ?? cfg.offset ?? null;
42
+ onCompleteRef.current = options.onComplete ?? null;
43
+ const curve = cfg.curve ?? 1;
44
+ splineRef.current = createPathSpline(pts, curve);
45
+ return true;
46
+ }, []);
47
+ const stopPathAnimation = useCallback(() => {
48
+ activeRef.current = false;
49
+ splineRef.current = null;
50
+ progressRef.current = 0;
51
+ directionRef.current = 1;
52
+ }, []);
53
+ const getPositionAt = useCallback((t) => {
54
+ const pts = pointsRef.current;
55
+ const spline = splineRef.current;
56
+ const clamped = Math.max(0, Math.min(1, t));
57
+ if (spline) {
58
+ return {
59
+ position: spline.getPointAt(clamped),
60
+ direction: spline.getTangentAt(clamped).normalize(),
61
+ };
62
+ }
63
+ const segs = pts.length - 1;
64
+ const idx = Math.min(Math.floor(clamped * segs), segs - 1);
65
+ const sp = clamped * segs - idx;
66
+ const a = pts[idx], b = pts[idx + 1];
67
+ return {
68
+ position: new THREE.Vector3(a[0] + (b[0] - a[0]) * sp, a[1] + (b[1] - a[1]) * sp, a[2] + (b[2] - a[2]) * sp),
69
+ direction: new THREE.Vector3(b[0] - a[0], b[1] - a[1], b[2] - a[2]).normalize(),
70
+ };
71
+ }, []);
72
+ const updatePathAnimation = useCallback((delta, object) => {
73
+ if (!activeRef.current)
74
+ return false;
75
+ progressRef.current += (delta / durationRef.current) * speedRef.current * directionRef.current;
76
+ let p = progressRef.current;
77
+ if (p >= 1 || p <= 0) {
78
+ if (yoyoRef.current) {
79
+ directionRef.current *= -1;
80
+ p = Math.max(0, Math.min(1, p));
81
+ progressRef.current = p;
82
+ if (!loopRef.current && directionRef.current === 1 && p <= 0) {
83
+ activeRef.current = false;
84
+ onCompleteRef.current?.();
85
+ return false;
86
+ }
87
+ }
88
+ else if (loopRef.current) {
89
+ progressRef.current = ((p % 1) + 1) % 1;
90
+ p = progressRef.current;
91
+ }
92
+ else {
93
+ progressRef.current = Math.max(0, Math.min(1, p));
94
+ activeRef.current = false;
95
+ onCompleteRef.current?.();
96
+ return false;
97
+ }
98
+ }
99
+ const eased = easeRef.current ? applyEasing(resolveEasing(easeRef.current), p) : p;
100
+ const { position, direction } = getPositionAt(eased);
101
+ if (offsetRef.current) {
102
+ position.x += offsetRef.current[0];
103
+ position.y += offsetRef.current[1];
104
+ position.z += offsetRef.current[2];
105
+ }
106
+ object.position.copy(position);
107
+ if (applyRotRef.current && faceRef.current && direction.lengthSq() > 0.0001) {
108
+ const up = new THREE.Vector3(0, 1, 0);
109
+ const mat = new THREE.Matrix4();
110
+ mat.lookAt(position, new THREE.Vector3().copy(position).add(direction), up);
111
+ targetQuatRef.current.setFromRotationMatrix(mat);
112
+ targetQuatRef.current.multiply(new THREE.Quaternion().setFromAxisAngle(new THREE.Vector3(0, 1, 0), Math.PI));
113
+ object.quaternion.slerp(targetQuatRef.current, 1);
114
+ }
115
+ return true;
116
+ }, [getPositionAt]);
117
+ const isAnimating = useCallback(() => activeRef.current, []);
118
+ return { startPathAnimation, stopPathAnimation, updatePathAnimation, isAnimating, getPositionAt };
119
+ };
120
+ export default usePathAnimation;
@@ -0,0 +1,14 @@
1
+ import type { SkySettings } from '@ntalmagor/3drize-core';
2
+ interface SkyAnimValues {
3
+ turbidity: number;
4
+ rayleigh: number;
5
+ mieCoefficient: number;
6
+ mieDirectionalG: number;
7
+ elevation: number;
8
+ azimuth: number;
9
+ }
10
+ export declare function useSkyAnimation(): {
11
+ animateSkyTransition: (currentValues: SkyAnimValues, targetSettings: SkySettings, onUpdate: (s: SkySettings) => void, onComplete: (s: SkySettings) => void, duration?: number) => void;
12
+ };
13
+ export {};
14
+ //# sourceMappingURL=useSkyAnimation.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"useSkyAnimation.d.ts","sourceRoot":"","sources":["../../src/hooks/useSkyAnimation.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,wBAAwB,CAAC;AAE1D,UAAU,aAAa;IACrB,SAAS,EAAE,MAAM,CAAC;IAClB,QAAQ,EAAE,MAAM,CAAC;IACjB,cAAc,EAAE,MAAM,CAAC;IACvB,eAAe,EAAE,MAAM,CAAC;IACxB,SAAS,EAAE,MAAM,CAAC;IAClB,OAAO,EAAE,MAAM,CAAC;CACjB;AAYD,wBAAgB,eAAe;0CA6BZ,aAAa,kBACZ,WAAW,YACjB,CAAC,CAAC,EAAE,WAAW,KAAK,IAAI,cACtB,CAAC,CAAC,EAAE,WAAW,KAAK,IAAI;EAsBvC"}
@@ -0,0 +1,46 @@
1
+ import { useRef, useCallback } from 'react';
2
+ import { useFrame } from '@react-three/fiber';
3
+ export function useSkyAnimation() {
4
+ const animRef = useRef(null);
5
+ useFrame((_, delta) => {
6
+ if (!animRef.current)
7
+ return;
8
+ const anim = animRef.current;
9
+ anim.elapsed += delta;
10
+ const t = Math.min(1, anim.elapsed / anim.duration);
11
+ const st = t * t * (3 - 2 * t); // smoothstep
12
+ const lerp = (a, b) => a + (b - a) * st;
13
+ const vals = {
14
+ turbidity: lerp(anim.from.turbidity, anim.to.turbidity),
15
+ rayleigh: lerp(anim.from.rayleigh, anim.to.rayleigh),
16
+ mieCoefficient: lerp(anim.from.mieCoefficient, anim.to.mieCoefficient),
17
+ mieDirectionalG: lerp(anim.from.mieDirectionalG, anim.to.mieDirectionalG),
18
+ elevation: lerp(anim.from.elevation, anim.to.elevation),
19
+ azimuth: lerp(anim.from.azimuth, anim.to.azimuth),
20
+ };
21
+ anim.onUpdate({ ...anim.targetSettings, ...vals });
22
+ if (t >= 1) {
23
+ anim.onComplete({ ...anim.targetSettings, ...anim.to });
24
+ animRef.current = null;
25
+ }
26
+ });
27
+ const animateSkyTransition = useCallback((currentValues, targetSettings, onUpdate, onComplete, duration = 3) => {
28
+ animRef.current = {
29
+ from: { ...currentValues },
30
+ to: {
31
+ turbidity: targetSettings.turbidity,
32
+ rayleigh: targetSettings.rayleigh,
33
+ mieCoefficient: targetSettings.mieCoefficient,
34
+ mieDirectionalG: targetSettings.mieDirectionalG,
35
+ elevation: targetSettings.elevation,
36
+ azimuth: targetSettings.azimuth,
37
+ },
38
+ duration,
39
+ elapsed: 0,
40
+ targetSettings,
41
+ onUpdate,
42
+ onComplete,
43
+ };
44
+ }, []);
45
+ return { animateSkyTransition };
46
+ }
@@ -0,0 +1,26 @@
1
+ import * as THREE from 'three';
2
+ import type { SkyTimeState, TimeOfDayLabel } from '../../../core/src/services/SkySystemManager';
3
+ import type { TimeSettings } from '../../../core/src/types/scene3d';
4
+ export type { SkyTimeState, TimeOfDayLabel };
5
+ export interface UseSkySystemOptions {
6
+ timeSettings: TimeSettings;
7
+ onTimeUpdate?: (state: SkyTimeState) => void;
8
+ onTimeOfDayChange?: (timeOfDay: string, elapsedTime: number) => void;
9
+ enabled?: boolean;
10
+ }
11
+ export interface UseSkySystemReturn {
12
+ timeInHours: number;
13
+ normalizedTime: number;
14
+ isDaytime: boolean;
15
+ timeOfDay: string;
16
+ sunElevation: number;
17
+ sunAzimuth: number;
18
+ sunDirection: THREE.Vector3;
19
+ setTime: (hours: number, minutes?: number) => void;
20
+ getTime: () => Date;
21
+ getTimeOfDay: () => string;
22
+ getSunDirection: () => THREE.Vector3;
23
+ }
24
+ export declare function useSkySystem(options: UseSkySystemOptions): UseSkySystemReturn;
25
+ export default useSkySystem;
26
+ //# sourceMappingURL=useSkySystem.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"useSkySystem.d.ts","sourceRoot":"","sources":["../../src/hooks/useSkySystem.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAG/B,OAAO,KAAK,EAAE,YAAY,EAAE,cAAc,EAAE,MAAM,6CAA6C,CAAC;AAChG,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,iCAAiC,CAAC;AAEpE,YAAY,EAAE,YAAY,EAAE,cAAc,EAAE,CAAC;AAE7C,MAAM,WAAW,mBAAmB;IAClC,YAAY,EAAE,YAAY,CAAC;IAC3B,YAAY,CAAC,EAAE,CAAC,KAAK,EAAE,YAAY,KAAK,IAAI,CAAC;IAC7C,iBAAiB,CAAC,EAAE,CAAC,SAAS,EAAE,MAAM,EAAE,WAAW,EAAE,MAAM,KAAK,IAAI,CAAC;IACrE,OAAO,CAAC,EAAE,OAAO,CAAC;CACnB;AAED,MAAM,WAAW,kBAAkB;IACjC,WAAW,EAAE,MAAM,CAAC;IACpB,cAAc,EAAE,MAAM,CAAC;IACvB,SAAS,EAAE,OAAO,CAAC;IACnB,SAAS,EAAE,MAAM,CAAC;IAClB,YAAY,EAAE,MAAM,CAAC;IACrB,UAAU,EAAE,MAAM,CAAC;IACnB,YAAY,EAAE,KAAK,CAAC,OAAO,CAAC;IAC5B,OAAO,EAAE,CAAC,KAAK,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,MAAM,KAAK,IAAI,CAAC;IACnD,OAAO,EAAE,MAAM,IAAI,CAAC;IACpB,YAAY,EAAE,MAAM,MAAM,CAAC;IAC3B,eAAe,EAAE,MAAM,KAAK,CAAC,OAAO,CAAC;CACtC;AAED,wBAAgB,YAAY,CAAC,OAAO,EAAE,mBAAmB,GAAG,kBAAkB,CA+D7E;AAED,eAAe,YAAY,CAAC"}