@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,52 @@
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 { useFrame } from '@react-three/fiber';
5
+ import { useTexture } from '@react-three/drei';
6
+ export { defaultMoonSettings } from '@ntalmagor/3drize-core';
7
+ const MOON_TEXTURE_URL = 'https://images-wixmp-ed30a86b8c4ca887773594c2.wixmp.com/i/06a094a4-7bd7-4bb9-b998-6c1e17f66c08/dbcju0k-b9b333e1-dd8d-4657-90db-7d3e7e179843.png';
8
+ const Moon = ({ settings, sunPosition, onMeshReady }) => {
9
+ const meshRef = useRef(null);
10
+ const lightRef = useRef(null);
11
+ const targetRef = useRef(null);
12
+ const texture = useTexture(MOON_TEXTURE_URL);
13
+ const s = settings ?? {
14
+ visible: true,
15
+ position: [0, 5, 0],
16
+ scale: 3,
17
+ rotation: [0, 0, 0.5],
18
+ emissiveIntensity: 0.3,
19
+ orbitRadius: 250,
20
+ enableOrbit: false,
21
+ orbitSpeed: 0.1,
22
+ };
23
+ const handleMeshRef = useCallback((mesh) => {
24
+ if (mesh) {
25
+ meshRef.current = mesh;
26
+ onMeshReady?.(mesh);
27
+ }
28
+ }, [onMeshReady]);
29
+ useFrame((state) => {
30
+ const moonPos = sunPosition ?? s.position;
31
+ if (meshRef.current && s.enableOrbit) {
32
+ const time = state.clock.getElapsedTime();
33
+ const speed = s.orbitSpeed ?? 0.1;
34
+ const radius = s.orbitRadius ?? 250;
35
+ meshRef.current.position.x = Math.cos(time * speed) * radius;
36
+ meshRef.current.position.z = Math.sin(time * speed) * radius;
37
+ meshRef.current.rotation.y += 0.001;
38
+ }
39
+ if (lightRef.current && targetRef.current) {
40
+ const cameraPos = state.camera.position;
41
+ const moonPosition = meshRef.current?.position ?? new THREE.Vector3(...moonPos);
42
+ const dirToMoon = new THREE.Vector3().subVectors(moonPosition, cameraPos).normalize();
43
+ const dist = cameraPos.distanceTo(moonPosition) * 0.2;
44
+ lightRef.current.position.copy(cameraPos).addScaledVector(dirToMoon, dist);
45
+ targetRef.current.position.copy(moonPosition);
46
+ }
47
+ });
48
+ const moonPos = sunPosition ?? s.position;
49
+ return (_jsxs("group", { userData: { id: '3drise-moon' }, children: [_jsx("object3D", { ref: targetRef, position: moonPos }), _jsx("directionalLight", { ref: lightRef, intensity: 2, color: 0xffffff, target: targetRef.current ?? undefined }), _jsxs("mesh", { ref: handleMeshRef, position: moonPos, rotation: s.rotation, scale: s.scale, visible: s.visible, children: [_jsx("sphereGeometry", { args: [10, 22, 22] }), _jsx("meshPhongMaterial", { color: 0xb2b2b2, normalMap: texture, shininess: 0 })] })] }));
50
+ };
51
+ Moon.displayName = 'Moon';
52
+ export default Moon;
@@ -0,0 +1,11 @@
1
+ import React from "react";
2
+ import { Object3D } from "three";
3
+ import type { CameraState, CreatedObjectSettings, ObjectTreeNode } from "@ntalmagor/3drize-core";
4
+ type ObjectNodeProps = {
5
+ node: ObjectTreeNode;
6
+ cameraSettings: CameraState;
7
+ onObjectReady?: (object: CreatedObjectSettings, ref: Object3D) => void;
8
+ };
9
+ declare const ObjectNode: React.FC<ObjectNodeProps>;
10
+ export default ObjectNode;
11
+ //# sourceMappingURL=ObjectNode.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ObjectNode.d.ts","sourceRoot":"","sources":["../../src/components/ObjectNode.tsx"],"names":[],"mappings":"AAAA,OAAO,KAA+B,MAAM,OAAO,CAAC;AACpD,OAAO,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAC;AACjC,OAAO,KAAK,EAAE,WAAW,EAAE,qBAAqB,EAA6D,cAAc,EAA0B,MAAM,wBAAwB,CAAC;AASpL,KAAK,eAAe,GAAG;IACnB,IAAI,EAAE,cAAc,CAAC;IACrB,cAAc,EAAE,WAAW,CAAC;IAC5B,aAAa,CAAC,EAAE,CAAC,MAAM,EAAE,qBAAqB,EAAE,GAAG,EAAE,QAAQ,KAAK,IAAI,CAAC;CAC1E,CAAC;AA0JF,QAAA,MAAM,UAAU,EAAE,KAAK,CAAC,EAAE,CAAC,eAAe,CAqCzC,CAAC;AAEF,eAAe,UAAU,CAAC"}
@@ -0,0 +1,61 @@
1
+ import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
2
+ import { useCallback } from "react";
3
+ import CustomPrimitive from "./CustomPrimitive";
4
+ import CreatedObject from "./CreatedObject.js";
5
+ import { Text3D, Text2D, PathRenderer, GalleryLayout, EffectsGenerator } from "@ntalmagor/3drize-viewer";
6
+ import ParticlesR3f from "./ParticlesR3f.js";
7
+ import Lines from "./Lines.js";
8
+ import GridHelper from "./GridHelper";
9
+ // Specialized renderers for each object type
10
+ const renderers = {
11
+ group: () => null,
12
+ mesh: (obj, cameraSettings, onObjectReady) => (_jsx(CustomPrimitive, { createdObject: obj, cameraSettings: cameraSettings, onObjectReady: onObjectReady }, obj.id)),
13
+ model: (obj, cameraSettings, onObjectReady) => (_jsx(CustomPrimitive, { createdObject: obj, cameraSettings: cameraSettings, onObjectReady: onObjectReady }, obj.id)),
14
+ custom_primitive: (obj, cameraSettings, onObjectReady) => (_jsx(CustomPrimitive, { createdObject: obj, cameraSettings: cameraSettings, onObjectReady: onObjectReady }, obj.id)),
15
+ text: (obj, cameraSettings, onObjectReady) => {
16
+ const renderMode = obj.config?.renderMode ?? 'bitmap';
17
+ return (_jsx(CreatedObject, { createdObject: obj, onObjectReady: onObjectReady, children: renderMode === 'text3d'
18
+ ? _jsx(Text3D, { textSettings: obj })
19
+ : _jsx(Text2D, { textSettings: obj }) }, obj.id));
20
+ },
21
+ particles: (obj, cameraSettings, onObjectReady) => {
22
+ const particlesSettings = obj;
23
+ return (_jsxs(CreatedObject, { createdObject: obj, onObjectReady: onObjectReady, children: [particlesSettings.config?.particles && (_jsx(ParticlesR3f, { particlesSettings: particlesSettings, cameraFov: cameraSettings.fov, duration: 1, transitionSettings: particlesSettings.meshSettings })), particlesSettings.config?.paths && (_jsx(Lines, { createdObject: particlesSettings }))] }, obj.id));
24
+ },
25
+ path: (obj, cameraSettings, onObjectReady) => (_jsx(CreatedObject, { createdObject: obj, onObjectReady: onObjectReady, children: _jsx(PathRenderer, { pathSettings: obj.config, showCurve: false, showLine: false, showPoints: false }, obj.id) }, obj.id)),
26
+ grid: (obj, cameraSettings, onObjectReady) => (_jsx(CreatedObject, { createdObject: obj, onObjectReady: onObjectReady, children: _jsx(GridHelper, { ...obj.config }) }, obj.id)),
27
+ effect: (obj) => (_jsx(EffectsGenerator, { settings: {
28
+ enabled: true,
29
+ config: obj.config,
30
+ } }, obj.id)),
31
+ gallery: (obj, cameraSettings, onObjectReady) => (_jsx(CreatedObject, { createdObject: obj, shouldApply3driseMaterial: true, children: _jsx(GalleryLayout, { createdObject: obj }) }, obj.id)),
32
+ };
33
+ const EffectsLayer = ({ effects }) => effects?.length ? (_jsx(_Fragment, { children: effects.map((effect, index) => (_jsx(EffectsGenerator, { settings: effect }, index))) })) : null;
34
+ const GroupWithChildren = ({ createdObject, children, cameraSettings, onObjectReady, renderObject }) => {
35
+ const meshSettings = createdObject.meshSettings;
36
+ const isGroup = createdObject.type === 'group';
37
+ const hasChildren = children.length > 0;
38
+ return (_jsxs("group", { position: meshSettings.position, rotation: meshSettings.rotation, scale: meshSettings.scale, visible: meshSettings.visible, name: createdObject.name, userData: { id: createdObject.id, type: createdObject.type }, children: [!isGroup && renderObject(createdObject), children.map(childNode => (_jsx(ObjectNode, { node: childNode, cameraSettings: cameraSettings, onObjectReady: onObjectReady }, childNode.objectId))), _jsx(EffectsLayer, { effects: createdObject.effects })] }, createdObject.id));
39
+ };
40
+ const ObjectNode = ({ node, cameraSettings, onObjectReady }) => {
41
+ // console.log(node)
42
+ const { children, createdObject } = node;
43
+ if (!createdObject) {
44
+ console.warn(`createdObject not found.`);
45
+ return null;
46
+ }
47
+ const meshSettings = createdObject.meshSettings;
48
+ const hasChildren = children.length > 0;
49
+ const shouldRenderAsGroup = hasChildren || createdObject.type === 'group' || createdObject.type === 'effect';
50
+ const renderObject = useCallback((obj) => {
51
+ const renderer = renderers[obj.type];
52
+ return renderer?.(obj, cameraSettings, onObjectReady) ?? null;
53
+ }, [cameraSettings, onObjectReady]);
54
+ const renderedObject = shouldRenderAsGroup
55
+ ? _jsx(GroupWithChildren, { createdObject: createdObject, children: children, cameraSettings: cameraSettings, onObjectReady: onObjectReady, renderObject: renderObject })
56
+ : createdObject.effects
57
+ ? _jsxs(_Fragment, { children: [renderObject(createdObject), _jsx(EffectsLayer, { effects: createdObject.effects })] })
58
+ : renderObject(createdObject);
59
+ return renderedObject;
60
+ };
61
+ export default ObjectNode;
@@ -0,0 +1,11 @@
1
+ import React from 'react';
2
+ import { GeneralObjectSettings, type CameraState, type CreatedObjectSettings } from '@ntalmagor/3drize-core';
3
+ interface ObjectsRendererProps {
4
+ cameraSettings: CameraState;
5
+ generalObjectSettings: GeneralObjectSettings;
6
+ createdObjects: CreatedObjectSettings[];
7
+ onObjectsReady?: () => void;
8
+ }
9
+ declare const ObjectsRenderer: React.FC<ObjectsRendererProps>;
10
+ export default ObjectsRenderer;
11
+ //# sourceMappingURL=ObjectsRenderer.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ObjectsRenderer.d.ts","sourceRoot":"","sources":["../../src/components/ObjectsRenderer.tsx"],"names":[],"mappings":"AAAA,OAAO,KAA6C,MAAM,OAAO,CAAC;AAGlE,OAAO,EAAmB,qBAAqB,EAAE,KAAK,WAAW,EAAE,KAAK,qBAAqB,EAAE,MAAM,wBAAwB,CAAC;AAO9H,UAAU,oBAAoB;IAC5B,cAAc,EAAE,WAAW,CAAC;IAC5B,qBAAqB,EAAE,qBAAqB,CAAC;IAC7C,cAAc,EAAE,qBAAqB,EAAE,CAAC;IACxC,cAAc,CAAC,EAAE,MAAM,IAAI,CAAC;CAC7B;AAED,QAAA,MAAM,eAAe,EAAE,KAAK,CAAC,EAAE,CAAC,oBAAoB,CA+BlD,CAAC;AAIH,eAAe,eAAe,CAAC"}
@@ -0,0 +1,19 @@
1
+ import { jsx as _jsx } from "react/jsx-runtime";
2
+ import { memo, useRef, useCallback, useMemo } from 'react';
3
+ import { buildObjectTree } from '@ntalmagor/3drize-core';
4
+ import ObjectNode from './ObjectNode';
5
+ const ObjectsRenderer = memo(({ cameraSettings, createdObjects, generalObjectSettings, onObjectsReady }) => {
6
+ const groupRef = useRef(null);
7
+ const objectsTree = useMemo(() => buildObjectTree(createdObjects), [createdObjects]);
8
+ const readyObjectsCount = useRef(0);
9
+ const onObjectReady = useCallback((object, ref) => {
10
+ readyObjectsCount.current += 1;
11
+ if (readyObjectsCount.current === objectsTree.length) {
12
+ console.log("All objects are ready!");
13
+ onObjectsReady && onObjectsReady();
14
+ }
15
+ }, [objectsTree.length, onObjectsReady]);
16
+ return (_jsx("group", { ref: groupRef, name: "main-objects", position: generalObjectSettings.meshSettings.position, rotation: generalObjectSettings.meshSettings.rotation, scale: generalObjectSettings.meshSettings.scale, children: objectsTree.map(node => (_jsx(ObjectNode, { node: node, cameraSettings: cameraSettings, onObjectReady: onObjectReady }, node.objectId))) }));
17
+ });
18
+ ObjectsRenderer.displayName = 'ObjectsRenderer';
19
+ export default ObjectsRenderer;
@@ -0,0 +1,8 @@
1
+ import React from 'react';
2
+ import type { OceanSettings } from '@ntalmagor/3drize-core';
3
+ export interface OceanProps {
4
+ settings: OceanSettings;
5
+ }
6
+ declare const Ocean: React.FC<OceanProps>;
7
+ export default Ocean;
8
+ //# sourceMappingURL=Ocean.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Ocean.d.ts","sourceRoot":"","sources":["../../src/components/Ocean.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAiB,MAAM,OAAO,CAAC;AAQtC,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,wBAAwB,CAAC;AAE5D,MAAM,WAAW,UAAU;IACzB,QAAQ,EAAE,aAAa,CAAC;CACzB;AA+CD,QAAA,MAAM,KAAK,EAAE,KAAK,CAAC,EAAE,CAAC,UAAU,CA4E/B,CAAC;AAEF,eAAe,KAAK,CAAC"}
@@ -0,0 +1,111 @@
1
+ import { jsx as _jsx } from "react/jsx-runtime";
2
+ import { useRef } from 'react';
3
+ import * as THREE from 'three';
4
+ import { useFrame } from '@react-three/fiber';
5
+ import { useMaterialApplication } from '../hooks/useMaterialApplication';
6
+ import { useWaterEnvironment } from '../hooks/useWaterEnvironment';
7
+ import { useWaterReflections } from '../hooks/useWaterReflections';
8
+ import { update3driseShaderUniforms } from '../utils/shaderUtils';
9
+ import { useMouseHandlers } from '../hooks/useMouseHandlers';
10
+ function getValueType(property, value) {
11
+ if (Array.isArray(value)) {
12
+ if (value.length === 3)
13
+ return 'vector3';
14
+ if (value.length === 2)
15
+ return 'vector2';
16
+ if (value.length === 4)
17
+ return 'vector4';
18
+ }
19
+ if (value instanceof THREE.Color || (typeof value === 'string' && value.startsWith('#')))
20
+ return 'color';
21
+ if (typeof value === 'number')
22
+ return 'number';
23
+ if (typeof value === 'boolean')
24
+ return 'boolean';
25
+ return 'unknown';
26
+ }
27
+ function applyMaterialValue(mesh, property, value, valueType) {
28
+ const material = mesh.material;
29
+ if (!material)
30
+ return;
31
+ switch (valueType) {
32
+ case 'vector3':
33
+ if (material[property]?.isVector3) {
34
+ material[property].set(value[0], value[1], value[2]);
35
+ }
36
+ else if (material.uniforms?.[property]) {
37
+ material.uniforms[property].value.set(value[0], value[1], value[2]);
38
+ }
39
+ break;
40
+ case 'color':
41
+ if (material[property]?.isColor) {
42
+ material[property].set(value);
43
+ }
44
+ else if (material.uniforms?.[property]) {
45
+ material.uniforms[property].value = new THREE.Color(value);
46
+ }
47
+ break;
48
+ default:
49
+ if (material[property] !== undefined) {
50
+ material[property] = value;
51
+ }
52
+ else if (material.uniforms?.[property]) {
53
+ material.uniforms[property].value = value;
54
+ }
55
+ }
56
+ }
57
+ const Ocean = ({ settings }) => {
58
+ const meshRef = useRef(null);
59
+ const planeSize = settings.planeSize || [10000, 10000];
60
+ const planeSegments = settings.planeSegments || 64;
61
+ const position = settings.position || [0, -1, 0];
62
+ const rotation = settings.rotation || [-Math.PI / 2, 0, 0];
63
+ const handlers = settings.handlers || {};
64
+ const { interpolateProperty } = useMouseHandlers();
65
+ useMaterialApplication(meshRef.current, settings.materialSettings);
66
+ useWaterEnvironment(settings.visible ? meshRef : { current: null });
67
+ useWaterReflections(settings.visible ? meshRef : { current: null }, {
68
+ waterPosition: new THREE.Vector3(...position),
69
+ resolution: 256,
70
+ updateFrequency: 1,
71
+ enabled: settings.visible,
72
+ });
73
+ useFrame((state) => {
74
+ if (!meshRef.current?.material || !settings.visible)
75
+ return;
76
+ const material = meshRef.current.material;
77
+ const uniforms = material?.uniforms;
78
+ if (!uniforms)
79
+ return;
80
+ const u_time = state.clock.getElapsedTime();
81
+ const mouse = state.pointer;
82
+ if (uniforms.u_time)
83
+ uniforms.u_time.value = u_time;
84
+ if (uniforms.u_cameraPosition)
85
+ uniforms.u_cameraPosition.value.copy(state.camera.position);
86
+ if (uniforms.u_resolution)
87
+ uniforms.u_resolution.value.set(window.innerWidth, window.innerHeight);
88
+ if (uniforms.u_mouse)
89
+ uniforms.u_mouse.value.set(mouse.x, mouse.y);
90
+ if (settings.effects) {
91
+ update3driseShaderUniforms(uniforms, settings.effects, u_time, mouse);
92
+ }
93
+ // Mouse-move property handlers
94
+ if (handlers?.onMouseMove?.enabled && handlers.onMouseMove.properties.length && meshRef.current) {
95
+ handlers.onMouseMove.properties.forEach((props) => {
96
+ const { property, propertySettings } = props;
97
+ const { min: minValue, max: maxValue, axis, sensitivity = 1, inverted = false } = propertySettings;
98
+ const baseValue = settings.materialSettings[property];
99
+ if (!baseValue)
100
+ return;
101
+ const interpolatedValue = interpolateProperty(baseValue, minValue, maxValue, mouse, axis, sensitivity, inverted);
102
+ const valueType = getValueType(property, interpolatedValue);
103
+ if (meshRef.current) {
104
+ applyMaterialValue(meshRef.current, property, interpolatedValue, valueType);
105
+ }
106
+ });
107
+ }
108
+ });
109
+ return (_jsx("mesh", { ref: meshRef, name: "Ocean", position: position, rotation: rotation, visible: settings.visible, userData: { id: '3drise-water' }, children: _jsx("planeGeometry", { args: [planeSize[0], planeSize[1], planeSegments, planeSegments] }) }));
110
+ };
111
+ export default Ocean;
@@ -0,0 +1,16 @@
1
+ import React from 'react';
2
+ import type { ParticlesSettings } from '@ntalmagor/3drize-core';
3
+ declare module '@react-three/fiber' {
4
+ interface ThreeElements {
5
+ shaderEffectsMaterial: any;
6
+ }
7
+ }
8
+ interface ParticlesR3fProps {
9
+ particlesSettings: ParticlesSettings;
10
+ cameraFov?: number;
11
+ duration?: number;
12
+ transitionSettings?: Record<string, unknown>;
13
+ }
14
+ declare const ParticlesR3f: React.FC<ParticlesR3fProps>;
15
+ export default ParticlesR3f;
16
+ //# sourceMappingURL=ParticlesR3f.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ParticlesR3f.d.ts","sourceRoot":"","sources":["../../src/components/ParticlesR3f.tsx"],"names":[],"mappings":"AAAA,OAAO,KAA4B,MAAM,OAAO,CAAC;AAEjD,OAAO,KAAK,EAAE,iBAAiB,EAAiB,MAAM,wBAAwB,CAAC;AAU/E,OAAO,QAAQ,oBAAoB,CAAC;IAClC,UAAU,aAAa;QACrB,qBAAqB,EAAE,GAAG,CAAC;KAC5B;CACF;AAED,UAAU,iBAAiB;IACzB,iBAAiB,EAAE,iBAAiB,CAAC;IACrC,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,kBAAkB,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;CAC9C;AAED,QAAA,MAAM,YAAY,EAAE,KAAK,CAAC,EAAE,CAAC,iBAAiB,CAqG7C,CAAC;AAEF,eAAe,YAAY,CAAC"}
@@ -0,0 +1,66 @@
1
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
+ import { useEffect, useRef } from 'react';
3
+ import { extend, useFrame } from '@react-three/fiber';
4
+ import { Color } from 'three';
5
+ import { ShaderEffectsMaterial } from '../shaders/ShaderEffectsMaterial';
6
+ import { useParticlePositions } from '../hooks/useParticlePositions';
7
+ import { useParticlesColors } from '../hooks/useParticlesColors';
8
+ import { useParticlesTextures } from '../hooks/useParticlesTextures';
9
+ import { handleShapeAnimation } from '../../../core/src/utils/particleAnimations';
10
+ extend({ ShaderEffectsMaterial });
11
+ const ParticlesR3f = ({ particlesSettings, duration = 1, transitionSettings, }) => {
12
+ const materialRef = useRef(null);
13
+ const pointsRef = useRef(null);
14
+ const { name, config, meshSettings } = particlesSettings;
15
+ const { count, shapeType, outlines, texture } = config;
16
+ const color = particlesSettings.materialSettings && 'color' in particlesSettings.materialSettings
17
+ ? particlesSettings.materialSettings.color
18
+ : '#ffffff';
19
+ const opacity = particlesSettings.materialSettings && 'opacity' in particlesSettings.materialSettings
20
+ ? particlesSettings.materialSettings.opacity
21
+ : 1.0;
22
+ const targetShape = (transitionSettings?.shapeType && typeof transitionSettings.shapeType === 'string')
23
+ ? transitionSettings.shapeType
24
+ : shapeType;
25
+ const targetOutLines = transitionSettings?.outlines !== undefined
26
+ ? transitionSettings.outlines
27
+ : outlines || false;
28
+ const targetColor = transitionSettings?.color || color;
29
+ const aspectRatio = 16 / 9;
30
+ const nbLines = Math.round(Math.sqrt(count / 3 / aspectRatio));
31
+ const nbColumns = Math.round(aspectRatio * nbLines);
32
+ const { basePositions, targetPositions, animationProgress, uvs } = useParticlePositions({
33
+ shapeType,
34
+ targetShape,
35
+ count,
36
+ outlines: outlines || false,
37
+ targetOutLines,
38
+ pointsRef,
39
+ });
40
+ const { handleColorsAnimation } = useParticlesColors({ color, targetColor });
41
+ const { currentTexture, prevTexture, loadTexture, textureProgress, handleTextureAnimation } = useParticlesTextures();
42
+ useEffect(() => {
43
+ if (texture && texture.trim() !== '') {
44
+ textureProgress.current = 0;
45
+ loadTexture(texture);
46
+ }
47
+ }, [texture, loadTexture]);
48
+ const speed = 1 / duration;
49
+ useFrame((_, delta) => {
50
+ if (!materialRef.current || !pointsRef.current || !basePositions.current)
51
+ return;
52
+ if (meshSettings.visible) {
53
+ handleShapeAnimation(delta, speed, animationProgress, pointsRef, basePositions, targetPositions);
54
+ handleColorsAnimation(materialRef, delta, speed);
55
+ }
56
+ if (prevTexture.current)
57
+ materialRef.current.uniforms.uTexture.value = prevTexture.current;
58
+ if (currentTexture.current)
59
+ materialRef.current.uniforms.uTargetTexture.value = currentTexture.current;
60
+ handleTextureAnimation(materialRef, delta, speed);
61
+ });
62
+ if (!basePositions.current)
63
+ return null;
64
+ return (_jsxs("points", { name: name, ref: pointsRef, position: [0, 0, 0], rotation: [0, 0, 0], scale: [1, 1, 1], children: [_jsxs("bufferGeometry", { children: [_jsx("bufferAttribute", { attach: "attributes-position", count: basePositions.current.length / 3, array: basePositions.current, itemSize: 3, args: [basePositions.current, 3] }), uvs && (_jsx("bufferAttribute", { attach: "attributes-aUV", count: uvs.length / 2, array: uvs, itemSize: 2, args: [uvs, 2] }))] }), _jsx("shaderEffectsMaterial", { ref: materialRef, uTexture: prevTexture.current || currentTexture.current, uTargetTexture: currentTexture.current, uHasTexture: !!currentTexture.current, uColor: new Color(color || '#ffffff'), uOpacity: opacity, uPointSize: 5.0, uParticleUVScale: 1.0 / Math.max(nbColumns, nbLines), depthTest: true, depthWrite: false, transparent: true })] }));
65
+ };
66
+ export default ParticlesR3f;
@@ -0,0 +1,13 @@
1
+ import React from 'react';
2
+ import type { CatmullRomCurve3 } from 'three';
3
+ interface PathProps {
4
+ curve: CatmullRomCurve3;
5
+ targetCurve: CatmullRomCurve3;
6
+ duration?: number;
7
+ color?: string;
8
+ opacity?: number;
9
+ tubeRadius?: number;
10
+ }
11
+ declare const Path: React.FC<PathProps>;
12
+ export default Path;
13
+ //# sourceMappingURL=Path.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Path.d.ts","sourceRoot":"","sources":["../../src/components/Path.tsx"],"names":[],"mappings":"AAAA,OAAO,KAA4B,MAAM,OAAO,CAAC;AAEjD,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,OAAO,CAAC;AAG9C,UAAU,SAAS;IACjB,KAAK,EAAE,gBAAgB,CAAC;IACxB,WAAW,EAAE,gBAAgB,CAAC;IAC9B,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,UAAU,CAAC,EAAE,MAAM,CAAC;CACrB;AAED,QAAA,MAAM,IAAI,EAAE,KAAK,CAAC,EAAE,CAAC,SAAS,CA2D7B,CAAC;AAEF,eAAe,IAAI,CAAC"}
@@ -0,0 +1,41 @@
1
+ import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
2
+ import { useRef, useEffect } from 'react';
3
+ import { useFrame } from '@react-three/fiber';
4
+ const Path = ({ curve, targetCurve, duration = 1, color = '#4c00ff', opacity = 1, tubeRadius = 0.001, }) => {
5
+ const tubeRef = useRef(null);
6
+ const targetTubeRef = useRef(null);
7
+ const meshRef = useRef(null);
8
+ const animationProgress = useRef(0);
9
+ const basePositions = useRef(null);
10
+ const speed = 1 / duration;
11
+ useEffect(() => {
12
+ if (tubeRef.current) {
13
+ basePositions.current = new Float32Array(tubeRef.current.attributes.position.array);
14
+ }
15
+ animationProgress.current = 0;
16
+ }, [curve, targetCurve]);
17
+ useEffect(() => {
18
+ return () => {
19
+ tubeRef.current?.dispose();
20
+ targetTubeRef.current?.dispose();
21
+ };
22
+ }, []);
23
+ useFrame((_, delta) => {
24
+ if (!meshRef.current || !tubeRef.current || !targetTubeRef.current || !basePositions.current)
25
+ return;
26
+ const progress = Math.min(animationProgress.current + delta * speed, 1);
27
+ const currentGeom = tubeRef.current;
28
+ const targetPositions = targetTubeRef.current.attributes.position.array;
29
+ const currentPosAttr = currentGeom.attributes.position;
30
+ const length = Math.min(basePositions.current.length, targetPositions.length);
31
+ for (let i = 0; i < length; i += 3) {
32
+ currentPosAttr.array[i] = basePositions.current[i] + (targetPositions[i] - basePositions.current[i]) * progress;
33
+ currentPosAttr.array[i + 1] = basePositions.current[i + 1] + (targetPositions[i + 1] - basePositions.current[i + 1]) * progress;
34
+ currentPosAttr.array[i + 2] = basePositions.current[i + 2] + (targetPositions[i + 2] - basePositions.current[i + 2]) * progress;
35
+ }
36
+ animationProgress.current = progress;
37
+ currentPosAttr.needsUpdate = true;
38
+ });
39
+ return (_jsxs(_Fragment, { children: [_jsxs("mesh", { ref: meshRef, children: [_jsx("tubeGeometry", { ref: tubeRef, args: [curve, 64, tubeRadius, 8, false] }), _jsx("meshBasicMaterial", { color: color, transparent: opacity < 1, opacity: opacity })] }), _jsx("mesh", { position: [0, -1000, 0], children: _jsx("tubeGeometry", { ref: targetTubeRef, args: [targetCurve, 64, tubeRadius, 8, false] }) })] }));
40
+ };
41
+ export default Path;
@@ -0,0 +1,11 @@
1
+ import React from 'react';
2
+ import type { PathGeometrySettings, Vector3Array } from '@ntalmagor/3drize-core';
3
+ interface PathGeometryProps {
4
+ points: Vector3Array[];
5
+ curve: number;
6
+ smoothCorners?: number;
7
+ geometry: PathGeometrySettings;
8
+ }
9
+ declare const PathGeometry: React.FC<PathGeometryProps>;
10
+ export default PathGeometry;
11
+ //# sourceMappingURL=PathGeometry.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"PathGeometry.d.ts","sourceRoot":"","sources":["../../src/components/PathGeometry.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAkB,MAAM,OAAO,CAAC;AAGvC,OAAO,KAAK,EAAE,oBAAoB,EAAE,YAAY,EAAE,MAAM,wBAAwB,CAAC;AAGjF,UAAU,iBAAiB;IACzB,MAAM,EAAE,YAAY,EAAE,CAAC;IACvB,KAAK,EAAE,MAAM,CAAC;IACd,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB,QAAQ,EAAE,oBAAoB,CAAC;CAChC;AAED,QAAA,MAAM,YAAY,EAAE,KAAK,CAAC,EAAE,CAAC,iBAAiB,CAwJ7C,CAAC;AAEF,eAAe,YAAY,CAAC"}
@@ -0,0 +1,109 @@
1
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
+ import { useMemo } from 'react';
3
+ import * as THREE from 'three';
4
+ import { Line } from '@react-three/drei';
5
+ import { smoothPathCorners, createPathSpline } from '@ntalmagor/3drize-core';
6
+ const PathGeometry = ({ points, curve, smoothCorners = 0, geometry, }) => {
7
+ const { type, width = 2, radius = 0.5, segments = 8, numLanes = 0, color = '#555555', dividerColor = '#ffffff' } = geometry;
8
+ const smoothedPoints = useMemo(() => smoothPathCorners(points, smoothCorners), [points, smoothCorners]);
9
+ const spline = useMemo(() => {
10
+ if (smoothedPoints.length < 2)
11
+ return null;
12
+ return createPathSpline(smoothedPoints, curve);
13
+ }, [smoothedPoints, curve]);
14
+ const tubeGeometry = useMemo(() => {
15
+ if (!spline || type !== 'tube')
16
+ return null;
17
+ return new THREE.TubeGeometry(spline, points.length * 10, radius, segments, false);
18
+ }, [spline, type, radius, segments, points.length]);
19
+ const roadGeometry = useMemo(() => {
20
+ if (!spline || type !== 'road')
21
+ return null;
22
+ const divisions = Math.max(points.length * 20, 100);
23
+ const vertices = [];
24
+ const indices = [];
25
+ const uvs = [];
26
+ const halfWidth = width / 2;
27
+ const up = new THREE.Vector3(0, 1, 0);
28
+ for (let i = 0; i <= divisions; i++) {
29
+ const t = i / divisions;
30
+ const point = spline.getPointAt(t);
31
+ const perp = new THREE.Vector3().crossVectors(spline.getTangentAt(t).normalize(), up).normalize();
32
+ const left = new THREE.Vector3().copy(point).addScaledVector(perp, -halfWidth);
33
+ const right = new THREE.Vector3().copy(point).addScaledVector(perp, halfWidth);
34
+ left.y += 0.01;
35
+ right.y += 0.01;
36
+ vertices.push(left.x, left.y, left.z, right.x, right.y, right.z);
37
+ uvs.push(0, t, 1, t);
38
+ if (i < divisions) {
39
+ const b = i * 2;
40
+ indices.push(b, b + 1, b + 2, b + 1, b + 3, b + 2);
41
+ }
42
+ }
43
+ const geo = new THREE.BufferGeometry();
44
+ geo.setAttribute('position', new THREE.Float32BufferAttribute(vertices, 3));
45
+ geo.setAttribute('uv', new THREE.Float32BufferAttribute(uvs, 2));
46
+ geo.setIndex(indices);
47
+ geo.computeVertexNormals();
48
+ return geo;
49
+ }, [spline, type, width, points.length]);
50
+ const wallsGeometry = useMemo(() => {
51
+ if (!spline || type !== 'walls')
52
+ return null;
53
+ const divisions = Math.max(points.length * 20, 100);
54
+ const wallHeight = 2;
55
+ const halfWidth = width / 2;
56
+ const vertices = [];
57
+ const indices = [];
58
+ const uvs = [];
59
+ const up = new THREE.Vector3(0, 1, 0);
60
+ for (let i = 0; i <= divisions; i++) {
61
+ const t = i / divisions;
62
+ const point = spline.getPointAt(t);
63
+ const perp = new THREE.Vector3().crossVectors(spline.getTangentAt(t).normalize(), up).normalize();
64
+ const lb = new THREE.Vector3().copy(point).addScaledVector(perp, -halfWidth);
65
+ const lt = lb.clone().setY(lb.y + wallHeight);
66
+ const rb = new THREE.Vector3().copy(point).addScaledVector(perp, halfWidth);
67
+ const rt = rb.clone().setY(rb.y + wallHeight);
68
+ vertices.push(lb.x, lb.y, lb.z, lt.x, lt.y, lt.z, rb.x, rb.y, rb.z, rt.x, rt.y, rt.z);
69
+ uvs.push(0, t, 0, t, 1, t, 1, t);
70
+ if (i < divisions) {
71
+ const b = i * 4, n = (i + 1) * 4;
72
+ indices.push(b, b + 1, n, b + 1, n + 1, n, b + 2, n + 2, b + 3, b + 3, n + 2, n + 3, b + 1, b + 3, n + 1, b + 3, n + 3, n + 1, b, n, b + 2, b + 2, n, n + 2);
73
+ }
74
+ }
75
+ const geo = new THREE.BufferGeometry();
76
+ geo.setAttribute('position', new THREE.Float32BufferAttribute(vertices, 3));
77
+ geo.setAttribute('uv', new THREE.Float32BufferAttribute(uvs, 2));
78
+ geo.setIndex(indices);
79
+ geo.computeVertexNormals();
80
+ return geo;
81
+ }, [spline, type, width, points.length]);
82
+ const laneDividerLines = useMemo(() => {
83
+ if (!spline || type !== 'road' || numLanes <= 0)
84
+ return null;
85
+ const divisions = Math.max(points.length * 20, 100);
86
+ const laneWidth = width / (numLanes * 2);
87
+ const offsets = [0];
88
+ for (let lane = 1; lane < numLanes; lane++) {
89
+ offsets.push(-lane * laneWidth, lane * laneWidth);
90
+ }
91
+ const up = new THREE.Vector3(0, 1, 0);
92
+ return offsets.map(offset => {
93
+ const line = [];
94
+ for (let i = 0; i <= divisions; i++) {
95
+ const t = i / divisions;
96
+ const point = spline.getPointAt(t);
97
+ const perp = new THREE.Vector3().crossVectors(spline.getTangentAt(t).normalize(), up).normalize();
98
+ const dp = new THREE.Vector3().copy(point).addScaledVector(perp, offset);
99
+ dp.y += 0.02;
100
+ line.push([dp.x, dp.y, dp.z]);
101
+ }
102
+ return line;
103
+ });
104
+ }, [spline, type, width, numLanes, points.length]);
105
+ if (!spline || type === 'none')
106
+ return null;
107
+ return (_jsxs("group", { children: [type === 'tube' && tubeGeometry && (_jsx("mesh", { geometry: tubeGeometry, children: _jsx("meshStandardMaterial", { color: color, side: THREE.DoubleSide }) })), type === 'road' && roadGeometry && (_jsx("mesh", { geometry: roadGeometry, children: _jsx("meshStandardMaterial", { color: color, side: THREE.DoubleSide }) })), type === 'road' && laneDividerLines?.map((line, index) => (_jsx(Line, { points: line, color: dividerColor, lineWidth: 2, dashed: index !== 0, dashSize: 0.5, gapSize: 0.3, raycast: () => null }, `lane-${index}`))), type === 'walls' && wallsGeometry && (_jsx("mesh", { geometry: wallsGeometry, children: _jsx("meshStandardMaterial", { color: color, side: THREE.DoubleSide }) }))] }));
108
+ };
109
+ export default PathGeometry;
@@ -0,0 +1,14 @@
1
+ import React from 'react';
2
+ import type { PathConfig } from '@ntalmagor/3drize-core';
3
+ export interface PathRendererProps {
4
+ pathSettings: PathConfig;
5
+ color?: string;
6
+ showPoints?: boolean;
7
+ showLine?: boolean;
8
+ showCurve?: boolean;
9
+ pointSize?: number;
10
+ lineWidth?: number;
11
+ }
12
+ declare const PathRenderer: React.FC<PathRendererProps>;
13
+ export default PathRenderer;
14
+ //# sourceMappingURL=PathRenderer.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"PathRenderer.d.ts","sourceRoot":"","sources":["../../src/components/PathRenderer.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAkB,MAAM,OAAO,CAAC;AAGvC,OAAO,KAAK,EAAE,UAAU,EAAgB,MAAM,wBAAwB,CAAC;AAIvE,MAAM,WAAW,iBAAiB;IAChC,YAAY,EAAE,UAAU,CAAC;IACzB,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,UAAU,CAAC,EAAE,OAAO,CAAC;IACrB,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,SAAS,CAAC,EAAE,OAAO,CAAC;IACpB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,SAAS,CAAC,EAAE,MAAM,CAAC;CACpB;AAED,QAAA,MAAM,YAAY,EAAE,KAAK,CAAC,EAAE,CAAC,iBAAiB,CAoE7C,CAAC;AAEF,eAAe,YAAY,CAAC"}
@@ -0,0 +1,33 @@
1
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
+ import { useMemo } from 'react';
3
+ import { Sphere, Line } from '@react-three/drei';
4
+ import { smoothPathCorners, createPathSpline, sampleSplinePoints } from '@ntalmagor/3drize-core';
5
+ import PathGeometry from './PathGeometry';
6
+ const PathRenderer = ({ pathSettings, color = '#ffa500', showPoints = true, showLine = true, showCurve = true, pointSize = 0.15, lineWidth = 2, }) => {
7
+ const points = pathSettings?.points || [];
8
+ const curve = pathSettings?.curve ?? 1;
9
+ const smoothCorners = pathSettings?.smoothCorners ?? 0;
10
+ const geometry = pathSettings?.geometry;
11
+ const hasCurve = curve > 1;
12
+ const hasSmoothCorners = smoothCorners > 0;
13
+ const smoothedPoints = useMemo(() => {
14
+ if (!hasSmoothCorners || points.length < 3)
15
+ return points;
16
+ return smoothPathCorners(points, smoothCorners);
17
+ }, [points, smoothCorners, hasSmoothCorners]);
18
+ const curvePoints = useMemo(() => {
19
+ if (!showCurve || points.length < 2)
20
+ return null;
21
+ if (!hasCurve && !hasSmoothCorners)
22
+ return null;
23
+ const basePoints = hasSmoothCorners ? smoothedPoints : points;
24
+ const spline = createPathSpline(basePoints, curve);
25
+ if (!spline)
26
+ return null;
27
+ return sampleSplinePoints(spline, basePoints.length);
28
+ }, [points, smoothedPoints, curve, smoothCorners, showCurve, hasCurve, hasSmoothCorners]);
29
+ if (points.length === 0)
30
+ return null;
31
+ return (_jsxs("group", { children: [showPoints && points.map((point, index) => (_jsxs("group", { position: point, children: [_jsx(Sphere, { args: [pointSize, 16, 16], children: _jsx("meshStandardMaterial", { color: color, emissive: color, emissiveIntensity: 0.5, toneMapped: false }) }), _jsx(Sphere, { args: [pointSize * 0.33, 8, 8], position: [0, pointSize * 1.67, 0], children: _jsx("meshBasicMaterial", { color: "#ffffff" }) })] }, `path-point-${index}`))), showLine && points.length > 1 && !hasCurve && !hasSmoothCorners && (_jsx(Line, { points: points, color: color, lineWidth: lineWidth, raycast: () => null })), showCurve && curvePoints && curvePoints.length > 1 && (_jsx(Line, { points: curvePoints, color: color, lineWidth: lineWidth, raycast: () => null })), showLine && showCurve && (hasCurve || hasSmoothCorners) && points.length > 1 && (_jsx(Line, { points: points, color: color, lineWidth: 1, dashed: true, dashSize: 0.1, gapSize: 0.1, raycast: () => null })), geometry && geometry.type !== 'none' && points.length >= 2 && (_jsx(PathGeometry, { points: points, curve: curve, smoothCorners: smoothCorners, geometry: geometry }))] }));
32
+ };
33
+ export default PathRenderer;