@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,159 @@
1
+ import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from "react/jsx-runtime";
2
+ import { useRef, useEffect, useCallback, useState } from 'react';
3
+ import { useFrame } from '@react-three/fiber';
4
+ import { useAnimationEvents } from '../hooks/useAnimationEvents';
5
+ import { useSkyUniforms } from '../hooks/useSkyUniforms';
6
+ import { useSkyAnimation } from '../hooks/useSkyAnimation';
7
+ import { useSkySystem } from '../hooks/useSkySystem';
8
+ import { findById } from '../utils/sceneQuery';
9
+ import SkyMesh from './SkyMesh';
10
+ function SkyController({ settings, timeSettings, scale = 1000, onSettingsChange, }) {
11
+ const skyRef = useRef(null);
12
+ const sunLightRef = useRef(null);
13
+ const [isAnimating, setIsAnimating] = useState(false);
14
+ const previousSettings = useRef(null);
15
+ const { updateUniforms, getCurrentValues } = useSkyUniforms();
16
+ const { animateSkyTransition } = useSkyAnimation();
17
+ useEffect(() => {
18
+ return () => {
19
+ sunLightRef.current?.shadow?.map?.dispose();
20
+ };
21
+ }, []);
22
+ useEffect(() => {
23
+ handleSettings(settings);
24
+ }, [settings]);
25
+ useAnimationEvents({
26
+ onStepStart: (event) => {
27
+ if (!event.step?.transitions)
28
+ return;
29
+ event.step.transitions.forEach((transition) => {
30
+ if (transition.state === 'sky' && skyRef.current) {
31
+ skyRef.current.visible = true;
32
+ setIsAnimating(true);
33
+ animateSkyTransition(transition.properties.from, transition.properties.to, updateUniforms, handleCompletedUniforms, event.step?.duration);
34
+ }
35
+ });
36
+ },
37
+ });
38
+ const handleTimeUpdate = useCallback((state) => {
39
+ const { sunAzimuth, sunElevation, timeInHours } = state;
40
+ const atmosphericParams = calculateSkyParamsForTime(timeInHours);
41
+ const newSettings = {
42
+ ...settings,
43
+ elevation: sunElevation,
44
+ azimuth: sunAzimuth,
45
+ ...atmosphericParams,
46
+ };
47
+ handleSettings(newSettings);
48
+ if (!state.autoAnimate) {
49
+ onSettingsChange?.(newSettings);
50
+ }
51
+ }, [settings, onSettingsChange]);
52
+ useSkySystem({
53
+ timeSettings,
54
+ onTimeUpdate: handleTimeUpdate,
55
+ enabled: settings.visible && timeSettings.enabled,
56
+ });
57
+ const handleMeshReady = useCallback((mesh) => {
58
+ skyRef.current = mesh;
59
+ updateUniforms(settings);
60
+ previousSettings.current = { ...settings };
61
+ }, [settings, updateUniforms]);
62
+ const updateSun = useCallback(() => {
63
+ if (!skyRef.current?.material || !sunLightRef.current)
64
+ return;
65
+ const uniforms = skyRef.current.material.uniforms;
66
+ if (!uniforms?.sunPosition)
67
+ return;
68
+ const distance = 100;
69
+ const sp = uniforms.sunPosition.value;
70
+ sunLightRef.current.position.set(sp.x * distance, sp.y * distance, sp.z * distance);
71
+ sunLightRef.current.shadow.camera.updateProjectionMatrix();
72
+ const moon = findById('3drise-moon');
73
+ if (moon)
74
+ moon.position.set(sp.x * scale, sp.y * scale, sp.z * scale);
75
+ }, [scale]);
76
+ const hasActualChanges = useCallback((next, prev) => {
77
+ if (!prev)
78
+ return true;
79
+ return (next.visible !== prev.visible ||
80
+ Math.abs(next.turbidity - prev.turbidity) > 0.01 ||
81
+ Math.abs(next.rayleigh - prev.rayleigh) > 0.01 ||
82
+ Math.abs(next.mieCoefficient - prev.mieCoefficient) > 0.001 ||
83
+ Math.abs(next.mieDirectionalG - prev.mieDirectionalG) > 0.001 ||
84
+ Math.abs(next.elevation - prev.elevation) > 0.1 ||
85
+ Math.abs(next.azimuth - prev.azimuth) > 0.1);
86
+ }, []);
87
+ const handleCompletedUniforms = (s) => {
88
+ previousSettings.current = { ...s };
89
+ setIsAnimating(false);
90
+ };
91
+ const handleSettings = (newSettings) => {
92
+ if (!skyRef.current || isAnimating || !newSettings)
93
+ return;
94
+ if (!hasActualChanges(newSettings, previousSettings.current))
95
+ return;
96
+ if (sunLightRef.current)
97
+ sunLightRef.current.visible = newSettings.visible;
98
+ updateUniforms(newSettings);
99
+ updateSun();
100
+ previousSettings.current = { ...newSettings };
101
+ };
102
+ const handleMouseMove = (mouse) => {
103
+ const handlers = settings.handlers;
104
+ if (!handlers || isAnimating || !skyRef.current)
105
+ return;
106
+ if (!handlers.onMouseMove?.enabled)
107
+ return;
108
+ let updated = { ...settings };
109
+ handlers.onMouseMove.properties.forEach((propConfig) => {
110
+ const { property } = propConfig;
111
+ const { sensitivity, min: minVal, max: maxVal, axis } = propConfig.propertySettings;
112
+ let movement = axis === 'x' ? mouse.x * sensitivity
113
+ : axis === 'y' ? mouse.y * sensitivity
114
+ : (mouse.x + mouse.y) * 0.5 * sensitivity;
115
+ if (movement !== 0) {
116
+ let newVal = updated[property] + movement;
117
+ if (typeof minVal === 'number')
118
+ newVal = Math.max(newVal, minVal);
119
+ if (typeof maxVal === 'number')
120
+ newVal = Math.min(newVal, maxVal);
121
+ updated[property] = newVal;
122
+ }
123
+ });
124
+ handleSettings(updated);
125
+ };
126
+ useFrame((state) => {
127
+ handleMouseMove({ x: state.pointer.x, y: state.pointer.y });
128
+ });
129
+ return (_jsxs(_Fragment, { children: [_jsx(SkyMesh, { ref: skyRef, settings: settings, scale: scale, onMeshReady: handleMeshReady }), _jsx("directionalLight", { ref: sunLightRef, color: "#ffffff", intensity: 1, castShadow: true })] }));
130
+ }
131
+ // ─── Atmospheric parameter calculation ───────────────────────────────────────
132
+ function calculateSkyParamsForTime(timeInHours) {
133
+ const nightParams = { turbidity: 0.5, rayleigh: 0.1, mieCoefficient: 0.001, mieDirectionalG: 0.8 };
134
+ const sunriseParams = { turbidity: 4, rayleigh: 3, mieCoefficient: 0.01, mieDirectionalG: 0.9 };
135
+ const dayParams = { turbidity: 0.7, rayleigh: 0.54, mieCoefficient: 0.005, mieDirectionalG: 0.7 };
136
+ const sunsetParams = { turbidity: 4.5, rayleigh: 3.5, mieCoefficient: 0.012, mieDirectionalG: 0.92 };
137
+ const lerp = (a, b, t) => a + (b - a) * Math.max(0, Math.min(1, t));
138
+ const ss = (t) => t * t * (3 - 2 * t);
139
+ const lerpP = (from, to, t) => ({
140
+ turbidity: lerp(from.turbidity, to.turbidity, ss(t)),
141
+ rayleigh: lerp(from.rayleigh, to.rayleigh, ss(t)),
142
+ mieCoefficient: lerp(from.mieCoefficient, to.mieCoefficient, ss(t)),
143
+ mieDirectionalG: lerp(from.mieDirectionalG, to.mieDirectionalG, ss(t)),
144
+ });
145
+ if (timeInHours < 5)
146
+ return nightParams;
147
+ if (timeInHours < 6.5)
148
+ return lerpP(nightParams, sunriseParams, (timeInHours - 5) / 1.5);
149
+ if (timeInHours < 8)
150
+ return lerpP(sunriseParams, dayParams, (timeInHours - 6.5) / 1.5);
151
+ if (timeInHours < 17)
152
+ return dayParams;
153
+ if (timeInHours < 19)
154
+ return lerpP(dayParams, sunsetParams, (timeInHours - 17) / 2);
155
+ if (timeInHours < 21)
156
+ return lerpP(sunsetParams, nightParams, (timeInHours - 19) / 2);
157
+ return nightParams;
158
+ }
159
+ export default SkyController;
@@ -0,0 +1,11 @@
1
+ import React from 'react';
2
+ import { Mesh } from 'three';
3
+ import type { SkySettings } from '@ntalmagor/3drize-core';
4
+ export interface SkyMeshProps {
5
+ settings: SkySettings;
6
+ scale?: number;
7
+ onMeshReady?: (mesh: Mesh) => void;
8
+ }
9
+ declare const SkyMesh: React.ForwardRefExoticComponent<SkyMeshProps & React.RefAttributes<Mesh<import("three").BufferGeometry<import("three").NormalBufferAttributes, import("three").BufferGeometryEventMap>, import("three").Material | import("three").Material[], import("three").Object3DEventMap>>>;
10
+ export default SkyMesh;
11
+ //# sourceMappingURL=SkyMesh.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"SkyMesh.d.ts","sourceRoot":"","sources":["../../src/components/SkyMesh.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAqC,MAAM,OAAO,CAAC;AAE1D,OAAO,EAAE,IAAI,EAAE,MAAM,OAAO,CAAC;AAC7B,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,wBAAwB,CAAC;AAE1D,MAAM,WAAW,YAAY;IAC3B,QAAQ,EAAE,WAAW,CAAC;IACtB,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,WAAW,CAAC,EAAE,CAAC,IAAI,EAAE,IAAI,KAAK,IAAI,CAAC;CACpC;AAED,QAAA,MAAM,OAAO,oRAuCX,CAAC;AAGH,eAAe,OAAO,CAAC"}
@@ -0,0 +1,36 @@
1
+ import { jsx as _jsx } from "react/jsx-runtime";
2
+ import React, { useRef, useMemo, useEffect } from 'react';
3
+ import { Sky } from 'three/examples/jsm/objects/Sky.js';
4
+ const SkyMesh = React.forwardRef(({ settings, scale = 1000, onMeshReady }, ref) => {
5
+ const meshRef = useRef(null);
6
+ const skyObject = useMemo(() => {
7
+ const sky = new Sky();
8
+ sky.scale.setScalar(10000);
9
+ return sky;
10
+ }, []);
11
+ useEffect(() => {
12
+ return () => {
13
+ skyObject.geometry?.dispose();
14
+ if (Array.isArray(skyObject.material)) {
15
+ skyObject.material.forEach(m => m.dispose());
16
+ }
17
+ else {
18
+ skyObject.material?.dispose();
19
+ }
20
+ };
21
+ }, [skyObject]);
22
+ useEffect(() => {
23
+ if (meshRef.current && onMeshReady)
24
+ onMeshReady(meshRef.current);
25
+ }, [onMeshReady]);
26
+ const combinedRef = (node) => {
27
+ meshRef.current = node;
28
+ if (typeof ref === 'function')
29
+ ref(node);
30
+ else if (ref)
31
+ ref.current = node;
32
+ };
33
+ return (_jsx("primitive", { ref: combinedRef, object: skyObject, visible: true, scale: scale, userData: { id: '3drise-sky' } }));
34
+ });
35
+ SkyMesh.displayName = 'SkyMesh';
36
+ export default SkyMesh;
@@ -0,0 +1,34 @@
1
+ import React from 'react';
2
+ import * as THREE from 'three';
3
+ import type { TimeSettings } from '../../../core/src/types/scene3d';
4
+ import type { StarsSettings, CloudsSettings, SkySettings, RainSettings, FogSettings } from '../../../core/src/types/environment';
5
+ import type { MaterialSettings } from '../../../core/src/types/materials';
6
+ export interface SkySystemRef {
7
+ setTime: (hours: number, minutes?: number) => void;
8
+ getTime: () => Date;
9
+ getTimeOfDay: () => string;
10
+ getSunDirection: () => THREE.Vector3;
11
+ }
12
+ export interface SkySystemProps {
13
+ timeSettings: TimeSettings;
14
+ visible?: boolean;
15
+ sunSystemVisible?: boolean;
16
+ sunSize?: number;
17
+ moonSize?: number;
18
+ skyboxScale?: number;
19
+ sunIntensity?: number;
20
+ castShadow?: boolean;
21
+ shadowMapSize?: number;
22
+ playerPosition?: THREE.Vector3;
23
+ starsSettings?: StarsSettings;
24
+ cloudsSettings?: CloudsSettings;
25
+ cloudsMaterialSettings?: MaterialSettings;
26
+ skyControllerSettings?: SkySettings;
27
+ rainSettings?: RainSettings;
28
+ fogSettings?: FogSettings;
29
+ onTimeOfDayChange?: (timeOfDay: string, elapsedTime: number) => void;
30
+ onTimeUpdate?: (timeOfDay: number) => void;
31
+ }
32
+ declare const SkySystem: React.ForwardRefExoticComponent<SkySystemProps & React.RefAttributes<SkySystemRef>>;
33
+ export default SkySystem;
34
+ //# sourceMappingURL=SkySystem.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"SkySystem.d.ts","sourceRoot":"","sources":["../../src/components/SkySystem.tsx"],"names":[],"mappings":"AAAA,OAAO,KAA6D,MAAM,OAAO,CAAC;AAClF,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAW/B,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,iCAAiC,CAAC;AACpE,OAAO,KAAK,EAAE,aAAa,EAAE,cAAc,EAAE,WAAW,EAAE,YAAY,EAAE,WAAW,EAAE,MAAM,qCAAqC,CAAC;AACjI,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,mCAAmC,CAAC;AAE1E,MAAM,WAAW,YAAY;IAC3B,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,MAAM,WAAW,cAAc;IAC7B,YAAY,EAAE,YAAY,CAAC;IAC3B,OAAO,CAAC,EAAE,OAAO,CAAC;IAClB,gBAAgB,CAAC,EAAE,OAAO,CAAC;IAC3B,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,UAAU,CAAC,EAAE,OAAO,CAAC;IACrB,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB,cAAc,CAAC,EAAE,KAAK,CAAC,OAAO,CAAC;IAC/B,aAAa,CAAC,EAAE,aAAa,CAAC;IAC9B,cAAc,CAAC,EAAE,cAAc,CAAC;IAChC,sBAAsB,CAAC,EAAE,gBAAgB,CAAC;IAC1C,qBAAqB,CAAC,EAAE,WAAW,CAAC;IACpC,YAAY,CAAC,EAAE,YAAY,CAAC;IAC5B,WAAW,CAAC,EAAE,WAAW,CAAC;IAC1B,iBAAiB,CAAC,EAAE,CAAC,SAAS,EAAE,MAAM,EAAE,WAAW,EAAE,MAAM,KAAK,IAAI,CAAC;IACrE,YAAY,CAAC,EAAE,CAAC,SAAS,EAAE,MAAM,KAAK,IAAI,CAAC;CAC5C;AAED,QAAA,MAAM,SAAS,qFA0Gb,CAAC;AAIH,eAAe,SAAS,CAAC"}
@@ -0,0 +1,47 @@
1
+ import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from "react/jsx-runtime";
2
+ import { useEffect, useRef, forwardRef, useImperativeHandle } from 'react';
3
+ import * as THREE from 'three';
4
+ import { useFrame } from '@react-three/fiber';
5
+ import { skySystemManager } from '../../../core/src/services/SkySystemManager';
6
+ import Skybox from './Skybox';
7
+ import Lensflare from './Lensflare';
8
+ import SunLight from './SunLight';
9
+ import Clouds from './Clouds';
10
+ import Galaxy from './Galaxy';
11
+ import SkyController from './SkyController';
12
+ import Rain from './Rain';
13
+ import SceneFog from './SceneFog';
14
+ const SkySystem = forwardRef(({ timeSettings, visible = true, sunSystemVisible = false, sunSize = 1, moonSize = 1, skyboxScale = 100000, sunIntensity = 1, castShadow = true, shadowMapSize = 2048, playerPosition = new THREE.Vector3(0, 0, 0), starsSettings, cloudsSettings, cloudsMaterialSettings, skyControllerSettings, rainSettings, fogSettings, onTimeOfDayChange, onTimeUpdate, }, ref) => {
15
+ const previousTimeOfDayRef = useRef(null);
16
+ useImperativeHandle(ref, () => ({
17
+ setTime: (h, m) => skySystemManager.setTime(h, m),
18
+ getTime: () => skySystemManager.getTime(),
19
+ getTimeOfDay: () => skySystemManager.getTimeOfDay(),
20
+ getSunDirection: () => skySystemManager.getSunDirection(),
21
+ }));
22
+ useEffect(() => {
23
+ skySystemManager.setTimeSettings(timeSettings);
24
+ }, [timeSettings]);
25
+ useEffect(() => {
26
+ if (!onTimeUpdate)
27
+ return;
28
+ skySystemManager.setOnTimeSync(onTimeUpdate);
29
+ return () => { skySystemManager.setOnTimeSync(null); };
30
+ }, [onTimeUpdate]);
31
+ useFrame((_, delta) => {
32
+ if (!timeSettings.enabled || !timeSettings.autoAnimate)
33
+ return;
34
+ skySystemManager.tick(delta);
35
+ const current = skySystemManager.getTimeOfDay();
36
+ if (previousTimeOfDayRef.current !== null && previousTimeOfDayRef.current !== current) {
37
+ const state = skySystemManager.getState();
38
+ onTimeOfDayChange?.(current, state.elapsedTime);
39
+ }
40
+ previousTimeOfDayRef.current = current;
41
+ });
42
+ if (!visible)
43
+ return null;
44
+ return (_jsxs("group", { children: [skyControllerSettings && !sunSystemVisible && (_jsx(SkyController, { settings: skyControllerSettings, timeSettings: timeSettings })), sunSystemVisible && (_jsxs(_Fragment, { children: [_jsx(Skybox, { visible: true, scale: skyboxScale, sunSize: sunSize, moonSize: moonSize, timeSettings: timeSettings }), _jsx(Lensflare, { visible: true, intensity: sunIntensity, timeSettings: timeSettings }), _jsx(SunLight, { visible: true, timeSettings: timeSettings, targetPosition: playerPosition, intensity: sunIntensity, castShadow: castShadow, shadowMapSize: shadowMapSize })] })), cloudsSettings?.visible && (_jsx(Clouds, { visible: true, scale: cloudsSettings.scale, height: cloudsSettings.position?.[1] ?? 400, speed: cloudsSettings.speed, materialSettings: cloudsMaterialSettings, timeSettings: timeSettings })), starsSettings && (_jsx(Galaxy, { settings: starsSettings })), rainSettings?.visible && (_jsx(Rain, { settings: rainSettings })), fogSettings && (_jsx(SceneFog, { fog: fogSettings }))] }));
45
+ });
46
+ SkySystem.displayName = 'SkySystem';
47
+ export default SkySystem;
@@ -0,0 +1,12 @@
1
+ import React from 'react';
2
+ import type { TimeSettings } from '../../../core/src/types/scene3d';
3
+ export interface SkyboxProps {
4
+ visible?: boolean;
5
+ scale?: number;
6
+ sunSize?: number;
7
+ moonSize?: number;
8
+ timeSettings: TimeSettings;
9
+ }
10
+ declare const Skybox: React.FC<SkyboxProps>;
11
+ export default Skybox;
12
+ //# sourceMappingURL=Skybox.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Skybox.d.ts","sourceRoot":"","sources":["../../src/components/Skybox.tsx"],"names":[],"mappings":"AAAA,OAAO,KAA8B,MAAM,OAAO,CAAC;AAInD,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,iCAAiC,CAAC;AAwBpE,MAAM,WAAW,WAAW;IAC1B,OAAO,CAAC,EAAE,OAAO,CAAC;IAClB,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,YAAY,EAAE,YAAY,CAAC;CAC5B;AAED,QAAA,MAAM,MAAM,EAAE,KAAK,CAAC,EAAE,CAAC,WAAW,CAiFjC,CAAC;AAEF,eAAe,MAAM,CAAC"}
@@ -0,0 +1,79 @@
1
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
+ import { useRef, useCallback } from 'react';
3
+ import * as THREE from 'three';
4
+ import { SkyboxMaterial } from '../shaders/SkyboxMaterial';
5
+ import { useSkySystem } from '../hooks/useSkySystem';
6
+ // Extend R3F with skyboxMaterial
7
+ import { extend } from '@react-three/fiber';
8
+ extend({ SkyboxMaterial });
9
+ const COLORS = {
10
+ white: new THREE.Color(0xffffff),
11
+ orange: new THREE.Color(0xff4500),
12
+ yellow: new THREE.Color(0xffd700),
13
+ red: new THREE.Color(0xff6347),
14
+ darkRed: new THREE.Color(0xd32f2f),
15
+ skyBlue: new THREE.Color(0x87ceeb),
16
+ darkSky: new THREE.Color(0x0d1321),
17
+ nightSky: new THREE.Color(0x1c2331),
18
+ moon: new THREE.Color(0xe6e8fa),
19
+ };
20
+ const MAX_ELEVATION = 42;
21
+ const DARKNESS_START = 20.42;
22
+ const DARKNESS_END = 6.58;
23
+ const SUNRISE = 6;
24
+ const SUNSET = 21;
25
+ const Skybox = ({ visible = true, scale = 100000, sunSize = 1, moonSize = 1, timeSettings, }) => {
26
+ const materialRef = useRef(null);
27
+ const sunColorRef = useRef(new THREE.Color(0xffe5b0));
28
+ const skyColorLowRef = useRef(new THREE.Color(0x6fa2ef));
29
+ const skyColorHighRef = useRef(new THREE.Color(0x2053ff));
30
+ const targetSunColorRef = useRef(new THREE.Color(0xffe5b0));
31
+ const targetSkyColorLowRef = useRef(new THREE.Color(0x6fa2ef));
32
+ const targetSkyColorHighRef = useRef(new THREE.Color(0x2053ff));
33
+ const handleTimeUpdate = useCallback((state) => {
34
+ const { timeInHours, normalizedTime, isDaytime, timeOfDay, sunElevation, sunAzimuth, delta } = state;
35
+ const isInDarkTransition = (timeInHours >= DARKNESS_START && timeInHours <= SUNSET) ||
36
+ (timeInHours >= SUNRISE && timeInHours <= DARKNESS_END);
37
+ void isInDarkTransition;
38
+ if (isDaytime) {
39
+ const normalizedElevation = Math.min(sunElevation / MAX_ELEVATION, 1);
40
+ const t = Math.pow(1 - normalizedElevation, 3);
41
+ targetSunColorRef.current.lerpColors(COLORS.white, COLORS.orange, t);
42
+ let horizonColor = COLORS.skyBlue.clone();
43
+ if (timeOfDay === 'Sunrise') {
44
+ horizonColor = COLORS.yellow.clone().lerp(COLORS.red, normalizedTime / 0.25);
45
+ }
46
+ else if (timeOfDay === 'Sunset') {
47
+ horizonColor = COLORS.red.clone().lerp(COLORS.darkRed, (normalizedTime - 0.75) / 0.25);
48
+ }
49
+ targetSkyColorLowRef.current.copy(horizonColor);
50
+ targetSkyColorHighRef.current.lerpColors(COLORS.skyBlue, COLORS.darkSky, t);
51
+ }
52
+ else {
53
+ targetSunColorRef.current.copy(COLORS.moon).multiplyScalar(1.8);
54
+ targetSkyColorLowRef.current.copy(COLORS.darkSky);
55
+ targetSkyColorHighRef.current.copy(COLORS.nightSky);
56
+ }
57
+ const colorLerpSpeed = Math.min(1, 2.0 * (delta !== 0 ? delta : 1));
58
+ sunColorRef.current.lerp(targetSunColorRef.current, colorLerpSpeed);
59
+ skyColorLowRef.current.lerp(targetSkyColorLowRef.current, colorLerpSpeed);
60
+ skyColorHighRef.current.lerp(targetSkyColorHighRef.current, colorLerpSpeed);
61
+ if (materialRef.current) {
62
+ materialRef.current.uSunAzimuth = sunAzimuth;
63
+ materialRef.current.uSunElevation = sunElevation;
64
+ materialRef.current.uSunColor = sunColorRef.current;
65
+ materialRef.current.uSkyColorLow = skyColorLowRef.current;
66
+ materialRef.current.uSkyColorHigh = skyColorHighRef.current;
67
+ materialRef.current.uSunSize = isDaytime ? sunSize : moonSize;
68
+ }
69
+ }, [sunSize, moonSize]);
70
+ useSkySystem({
71
+ timeSettings,
72
+ onTimeUpdate: handleTimeUpdate,
73
+ enabled: visible,
74
+ });
75
+ if (!visible)
76
+ return null;
77
+ return (_jsxs("mesh", { scale: scale, children: [_jsx("boxGeometry", { args: [1, 1, 1] }), _jsx("skyboxMaterial", { ref: materialRef, side: THREE.BackSide, depthWrite: false, fog: false })] }));
78
+ };
79
+ export default Skybox;
@@ -0,0 +1,14 @@
1
+ import React from 'react';
2
+ import * as THREE from 'three';
3
+ import '../../../core/src/shaders/StarsMaterial';
4
+ import type { StarsSettings } from '../../../core/src/types/environment';
5
+ import type { TimeSettings } from '../../../core/src/types/scene3d';
6
+ export declare function generateStarsGeometry(count: number): THREE.BufferGeometry;
7
+ export interface StarsProps {
8
+ settings: StarsSettings;
9
+ timeSettings?: TimeSettings;
10
+ sunSystemEnabled?: boolean;
11
+ }
12
+ declare const Stars: React.FC<StarsProps>;
13
+ export default Stars;
14
+ //# sourceMappingURL=Stars.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Stars.d.ts","sourceRoot":"","sources":["../../src/components/Stars.tsx"],"names":[],"mappings":"AAAA,OAAO,KAA4D,MAAM,OAAO,CAAC;AACjF,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAE/B,OAAO,yCAAyC,CAAC;AAIjD,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,qCAAqC,CAAC;AAEzE,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,iCAAiC,CAAC;AAEpE,wBAAgB,qBAAqB,CAAC,KAAK,EAAE,MAAM,GAAG,KAAK,CAAC,cAAc,CA6DzE;AAED,MAAM,WAAW,UAAU;IACzB,QAAQ,EAAE,aAAa,CAAC;IACxB,YAAY,CAAC,EAAE,YAAY,CAAC;IAC5B,gBAAgB,CAAC,EAAE,OAAO,CAAC;CAC5B;AAED,QAAA,MAAM,KAAK,EAAE,KAAK,CAAC,EAAE,CAAC,UAAU,CAqI/B,CAAC;AAEF,eAAe,KAAK,CAAC"}
@@ -0,0 +1,165 @@
1
+ import { jsx as _jsx } from "react/jsx-runtime";
2
+ import { useRef, useMemo, useCallback, useState, useEffect } from 'react';
3
+ import * as THREE from 'three';
4
+ import { useFrame } from '@react-three/fiber';
5
+ import '../../../core/src/shaders/StarsMaterial';
6
+ import { useSkySystem } from '../hooks/useSkySystem';
7
+ import { useParticlesColors } from '../hooks/useParticlesColors';
8
+ import { useAnimationEvents } from '../hooks/useAnimationEvents';
9
+ export function generateStarsGeometry(count) {
10
+ const halfCount = Math.floor(count / 2);
11
+ const geometry = new THREE.BufferGeometry();
12
+ const topPositions = new Float32Array(halfCount * 3);
13
+ for (let i = 0; i < halfCount; i++) {
14
+ const u = Math.random();
15
+ const v = Math.random() * 0.5 + 0.5;
16
+ const theta = 2 * Math.PI * u;
17
+ const phi = Math.acos(2 * v - 1);
18
+ topPositions.set([
19
+ Math.sin(phi) * Math.cos(theta),
20
+ Math.cos(phi),
21
+ Math.sin(phi) * Math.sin(theta),
22
+ ], i * 3);
23
+ }
24
+ const positions = new Float32Array(halfCount * 6);
25
+ positions.set(topPositions, 0);
26
+ for (let i = 0; i < halfCount; i++) {
27
+ positions.set([topPositions[i * 3], -topPositions[i * 3 + 1], topPositions[i * 3 + 2]], (i + halfCount) * 3);
28
+ }
29
+ const colors = new Float32Array(halfCount * 3);
30
+ for (let i = 0; i < halfCount; i++) {
31
+ const v = Math.random();
32
+ const c = v < 0.15 ? [0.8, 0.85, 1.0] : v < 0.3 ? [1.0, 0.95, 0.8] : [1.0, 1.0, 1.0];
33
+ colors.set(c, i * 3);
34
+ }
35
+ const mirroredColors = new Float32Array(halfCount * 6);
36
+ mirroredColors.set(colors, 0);
37
+ mirroredColors.set(colors, colors.length);
38
+ const sizes = new Float32Array(halfCount);
39
+ for (let i = 0; i < halfCount; i++) {
40
+ const v = Math.random();
41
+ sizes[i] = v < 0.01 ? 40 + Math.random() * 20 : v < 0.05 ? 25 + Math.random() * 15 : v < 0.2 ? 15 + Math.random() * 10 : 5 + Math.random() * 5;
42
+ }
43
+ const mirroredSizes = new Float32Array(halfCount * 2);
44
+ mirroredSizes.set(sizes, 0);
45
+ mirroredSizes.set(sizes, sizes.length);
46
+ const phases = new Float32Array(halfCount);
47
+ for (let i = 0; i < halfCount; i++)
48
+ phases[i] = Math.random() * Math.PI * 2;
49
+ const mirroredPhases = new Float32Array(halfCount * 2);
50
+ mirroredPhases.set(phases, 0);
51
+ mirroredPhases.set(phases, phases.length);
52
+ const freqs = new Float32Array(halfCount);
53
+ for (let i = 0; i < halfCount; i++)
54
+ freqs[i] = 1.0 + Math.random() * 2.0;
55
+ const mirroredFreqs = new Float32Array(halfCount * 2);
56
+ mirroredFreqs.set(freqs, 0);
57
+ mirroredFreqs.set(freqs, freqs.length);
58
+ geometry.setAttribute('position', new THREE.BufferAttribute(positions, 3));
59
+ geometry.setAttribute('color', new THREE.BufferAttribute(mirroredColors, 3));
60
+ geometry.setAttribute('size', new THREE.BufferAttribute(mirroredSizes, 1));
61
+ geometry.setAttribute('phase', new THREE.BufferAttribute(mirroredPhases, 1));
62
+ geometry.setAttribute('freq', new THREE.BufferAttribute(mirroredFreqs, 1));
63
+ return geometry;
64
+ }
65
+ const Stars = ({ settings, timeSettings, sunSystemEnabled = false }) => {
66
+ const pointsRef = useRef(null);
67
+ const materialRef = useRef(null);
68
+ const { visible, position, rotation, scale, rotateSpeed, count, color } = settings;
69
+ const opacityRef = useRef(1);
70
+ const targetOpacityRef = useRef(1);
71
+ const [isVisible, setIsVisible] = useState(true);
72
+ const [animatedTransform, setAnimatedTransform] = useState({
73
+ position, rotation, scale, targetPosition: position, targetRotation: rotation, targetScale: scale,
74
+ });
75
+ const [duration, setDuration] = useState(1);
76
+ const [colors, setColors] = useState({ baseColor: color, targetColor: color });
77
+ const { baseColorRef, targetColorRef, colorAnimationProgress } = useParticlesColors({
78
+ color: colors.baseColor,
79
+ targetColor: colors.targetColor,
80
+ });
81
+ const geometry = useMemo(() => generateStarsGeometry(count), [count]);
82
+ useEffect(() => () => { geometry.dispose(); }, [geometry]);
83
+ useEffect(() => {
84
+ setAnimatedTransform({ position, rotation, scale });
85
+ }, [position, rotation, scale]);
86
+ useEffect(() => {
87
+ setColors(prev => ({ ...prev, baseColor: color, targetColor: color }));
88
+ }, [color]);
89
+ useEffect(() => {
90
+ if (!sunSystemEnabled) {
91
+ setIsVisible(true);
92
+ opacityRef.current = 1;
93
+ targetOpacityRef.current = 1;
94
+ }
95
+ }, [sunSystemEnabled]);
96
+ useAnimationEvents({
97
+ onStepStart: (event) => {
98
+ if (!event.step?.transitions)
99
+ return;
100
+ for (let i = 0; i < event.step.transitions.length; i++) {
101
+ const transition = event.step.transitions[i];
102
+ const last = i > 0 ? event.step.transitions[event.step.transitions.length - 1] : null;
103
+ if (transition.state === 'stars' && event.sequenceId) {
104
+ setDuration(event.step.duration);
105
+ setColors({
106
+ baseColor: transition.properties.from?.color || last?.properties.to.color || colors.baseColor,
107
+ targetColor: transition.properties.to.color,
108
+ });
109
+ }
110
+ }
111
+ },
112
+ });
113
+ const handleTimeUpdate = useCallback((state) => {
114
+ const { normalizedTime, isDaytime, elapsedTime, delta, autoAnimate } = state;
115
+ if (!autoAnimate || !sunSystemEnabled)
116
+ return;
117
+ if (!isDaytime) {
118
+ targetOpacityRef.current = 1;
119
+ }
120
+ else {
121
+ const sunriseEnd = 0.15;
122
+ const sunsetStart = 0.85;
123
+ if (normalizedTime <= sunriseEnd) {
124
+ targetOpacityRef.current = 1 - normalizedTime / sunriseEnd;
125
+ }
126
+ else if (normalizedTime >= sunsetStart) {
127
+ targetOpacityRef.current = (normalizedTime - sunsetStart) / (1 - sunsetStart);
128
+ }
129
+ else {
130
+ targetOpacityRef.current = 0;
131
+ }
132
+ }
133
+ const opacityLerpSpeed = Math.min(1, 1.5 * (delta !== 0 ? delta : 1));
134
+ opacityRef.current += (targetOpacityRef.current - opacityRef.current) * opacityLerpSpeed;
135
+ const shouldBeVisible = opacityRef.current > 0.01;
136
+ if (shouldBeVisible !== isVisible)
137
+ setIsVisible(shouldBeVisible);
138
+ if (materialRef.current) {
139
+ materialRef.current.time = elapsedTime;
140
+ materialRef.current.opacity = opacityRef.current;
141
+ }
142
+ }, [isVisible, sunSystemEnabled]);
143
+ const defaultTimeSettings = { enabled: false, timeOfDay: 12, timescale: 60, autoAnimate: false, syncWithRealTime: false };
144
+ useSkySystem({
145
+ timeSettings: timeSettings ?? defaultTimeSettings,
146
+ onTimeUpdate: handleTimeUpdate,
147
+ enabled: sunSystemEnabled && !!timeSettings,
148
+ });
149
+ const speed = 1 / duration;
150
+ useFrame((_, delta) => {
151
+ if (!visible || !pointsRef.current)
152
+ return;
153
+ pointsRef.current.rotation.y += rotateSpeed * 0.01;
154
+ if (materialRef.current && colors.targetColor !== colors.baseColor) {
155
+ colorAnimationProgress.current = Math.min(1, colorAnimationProgress.current + (delta || 1) * speed);
156
+ materialRef.current.colorMix = colorAnimationProgress.current;
157
+ materialRef.current.uColor = baseColorRef.current;
158
+ materialRef.current.targetColor = targetColorRef.current;
159
+ }
160
+ });
161
+ if (!visible || !isVisible)
162
+ return null;
163
+ return (_jsx("points", { ref: pointsRef, geometry: geometry, scale: typeof scale === 'number' ? scale : scale[0], renderOrder: -1, frustumCulled: false, userData: { id: '3drise-stars' }, children: _jsx("starsMaterial", { ref: materialRef, transparent: true, depthWrite: false, depthTest: true, blending: THREE.AdditiveBlending, uColor: new THREE.Color(color), targetColor: new THREE.Color(colors.targetColor), colorMix: 0 }) }));
164
+ };
165
+ export default Stars;
@@ -0,0 +1,15 @@
1
+ import React from 'react';
2
+ import * as THREE from 'three';
3
+ import type { TimeSettings } from '../../../core/src/types/scene3d';
4
+ export interface SunLightProps {
5
+ visible?: boolean;
6
+ timeSettings: TimeSettings;
7
+ targetPosition?: THREE.Vector3;
8
+ shadowDistance?: number;
9
+ intensity?: number;
10
+ castShadow?: boolean;
11
+ shadowMapSize?: number;
12
+ }
13
+ declare const SunLight: React.FC<SunLightProps>;
14
+ export default SunLight;
15
+ //# sourceMappingURL=SunLight.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"SunLight.d.ts","sourceRoot":"","sources":["../../src/components/SunLight.tsx"],"names":[],"mappings":"AAAA,OAAO,KAA8B,MAAM,OAAO,CAAC;AACnD,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAE/B,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,iCAAiC,CAAC;AAcpE,MAAM,WAAW,aAAa;IAC5B,OAAO,CAAC,EAAE,OAAO,CAAC;IAClB,YAAY,EAAE,YAAY,CAAC;IAC3B,cAAc,CAAC,EAAE,KAAK,CAAC,OAAO,CAAC;IAC/B,cAAc,CAAC,EAAE,MAAM,CAAC;IACxB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,UAAU,CAAC,EAAE,OAAO,CAAC;IACrB,aAAa,CAAC,EAAE,MAAM,CAAC;CACxB;AAED,QAAA,MAAM,QAAQ,EAAE,KAAK,CAAC,EAAE,CAAC,aAAa,CA6ErC,CAAC;AAEF,eAAe,QAAQ,CAAC"}
@@ -0,0 +1,57 @@
1
+ import { jsx as _jsx } from "react/jsx-runtime";
2
+ import { useRef, useCallback } from 'react';
3
+ import * as THREE from 'three';
4
+ import { useSkySystem } from '../hooks/useSkySystem';
5
+ const COLORS = {
6
+ white: new THREE.Color(0xffffff),
7
+ orange: new THREE.Color(0xff4500),
8
+ moon: new THREE.Color(0xe6e8fa),
9
+ };
10
+ const MAX_ELEVATION = 42;
11
+ const SUNRISE = 6;
12
+ const SUNSET = 21;
13
+ const DARKNESS_START = 20.42;
14
+ const DARKNESS_END = 6.58;
15
+ const SunLight = ({ visible = true, timeSettings, targetPosition = new THREE.Vector3(0, 0, 0), shadowDistance = 300, intensity: intensityMultiplier = 1, castShadow = true, shadowMapSize = 2048, }) => {
16
+ const lightRef = useRef(null);
17
+ const colorRef = useRef(new THREE.Color(0xffe5b0));
18
+ const targetColorRef = useRef(new THREE.Color(0xffe5b0));
19
+ const intensityRef = useRef(1);
20
+ const targetIntensityRef = useRef(1);
21
+ const handleTimeUpdate = useCallback((state) => {
22
+ const { timeInHours, normalizedTime, isDaytime, sunDirection, sunElevation } = state;
23
+ const isInDarkTransition = (timeInHours >= DARKNESS_START && timeInHours <= SUNSET) ||
24
+ (timeInHours >= SUNRISE && timeInHours <= DARKNESS_END);
25
+ if (isDaytime) {
26
+ const normalizedElevation = Math.min(sunElevation / MAX_ELEVATION, 1);
27
+ const t = Math.pow(1 - normalizedElevation, 3);
28
+ targetColorRef.current.lerpColors(COLORS.white, COLORS.orange, t);
29
+ targetIntensityRef.current = isInDarkTransition
30
+ ? 0.1
31
+ : Math.min(40, Math.pow(normalizedElevation, 1.2) * 4);
32
+ }
33
+ else {
34
+ targetColorRef.current.copy(COLORS.moon).multiplyScalar(1.8);
35
+ targetIntensityRef.current = 0.5;
36
+ }
37
+ const lerpSpeed = Math.min(1, 2.0 * (state.delta || 1));
38
+ colorRef.current.lerp(targetColorRef.current, lerpSpeed);
39
+ intensityRef.current += (targetIntensityRef.current - intensityRef.current) * lerpSpeed;
40
+ if (lightRef.current) {
41
+ lightRef.current.position.set(targetPosition.x + sunDirection.x * shadowDistance, targetPosition.y + sunDirection.y * shadowDistance, targetPosition.z + sunDirection.z * shadowDistance);
42
+ lightRef.current.target.position.copy(targetPosition);
43
+ lightRef.current.target.updateMatrixWorld();
44
+ lightRef.current.intensity = intensityRef.current * intensityMultiplier;
45
+ lightRef.current.color.copy(colorRef.current);
46
+ }
47
+ }, [targetPosition, shadowDistance, intensityMultiplier]);
48
+ useSkySystem({
49
+ timeSettings,
50
+ onTimeUpdate: handleTimeUpdate,
51
+ enabled: visible,
52
+ });
53
+ if (!visible)
54
+ return null;
55
+ return (_jsx("directionalLight", { ref: lightRef, castShadow: castShadow, "shadow-mapSize-width": shadowMapSize, "shadow-mapSize-height": shadowMapSize, "shadow-camera-left": -50, "shadow-camera-right": 50, "shadow-camera-top": 50, "shadow-camera-bottom": -50, "shadow-camera-near": 0.5, "shadow-camera-far": 1000, "shadow-normalBias": 0.02, "shadow-bias": 0.000002, "shadow-radius": 2 }));
56
+ };
57
+ export default SunLight;