@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.
- package/dist/components/AnimatedObject.d.ts +22 -0
- package/dist/components/AnimatedObject.d.ts.map +1 -0
- package/dist/components/AnimatedObject.js +121 -0
- package/dist/components/CameraController.d.ts +16 -0
- package/dist/components/CameraController.d.ts.map +1 -0
- package/dist/components/CameraController.js +132 -0
- package/dist/components/Clouds.d.ts +14 -0
- package/dist/components/Clouds.d.ts.map +1 -0
- package/dist/components/Clouds.js +97 -0
- package/dist/components/CreatedObject.d.ts +12 -0
- package/dist/components/CreatedObject.d.ts.map +1 -0
- package/dist/components/CreatedObject.js +139 -0
- package/dist/components/CustomPrimitive.d.ts +12 -0
- package/dist/components/CustomPrimitive.d.ts.map +1 -0
- package/dist/components/CustomPrimitive.js +80 -0
- package/dist/components/EffectsGenerator.d.ts +10 -0
- package/dist/components/EffectsGenerator.d.ts.map +1 -0
- package/dist/components/EffectsGenerator.js +59 -0
- package/dist/components/EffectsGroup.d.ts +8 -0
- package/dist/components/EffectsGroup.d.ts.map +1 -0
- package/dist/components/EffectsGroup.js +8 -0
- package/dist/components/EnvironmentManager.d.ts +9 -0
- package/dist/components/EnvironmentManager.d.ts.map +1 -0
- package/dist/components/EnvironmentManager.js +47 -0
- package/dist/components/Frame.d.ts +26 -0
- package/dist/components/Frame.d.ts.map +1 -0
- package/dist/components/Frame.js +50 -0
- package/dist/components/FrameGeometry.d.ts +10 -0
- package/dist/components/FrameGeometry.d.ts.map +1 -0
- package/dist/components/FrameGeometry.js +17 -0
- package/dist/components/FrameImage.d.ts +14 -0
- package/dist/components/FrameImage.d.ts.map +1 -0
- package/dist/components/FrameImage.js +15 -0
- package/dist/components/Galaxy.d.ts +8 -0
- package/dist/components/Galaxy.d.ts.map +1 -0
- package/dist/components/Galaxy.js +9 -0
- package/dist/components/GalleryLayout.d.ts +10 -0
- package/dist/components/GalleryLayout.d.ts.map +1 -0
- package/dist/components/GalleryLayout.js +18 -0
- package/dist/components/GridHelper.d.ts +23 -0
- package/dist/components/GridHelper.d.ts.map +1 -0
- package/dist/components/GridHelper.js +38 -0
- package/dist/components/ImageGeometry.d.ts +14 -0
- package/dist/components/ImageGeometry.d.ts.map +1 -0
- package/dist/components/ImageGeometry.js +62 -0
- package/dist/components/Lensflare.d.ts +12 -0
- package/dist/components/Lensflare.d.ts.map +1 -0
- package/dist/components/Lensflare.js +66 -0
- package/dist/components/Letter.d.ts +20 -0
- package/dist/components/Letter.d.ts.map +1 -0
- package/dist/components/Letter.js +83 -0
- package/dist/components/Letters.d.ts +16 -0
- package/dist/components/Letters.d.ts.map +1 -0
- package/dist/components/Letters.js +18 -0
- package/dist/components/LightsManager.d.ts +9 -0
- package/dist/components/LightsManager.d.ts.map +1 -0
- package/dist/components/LightsManager.js +121 -0
- package/dist/components/Lines.d.ts +9 -0
- package/dist/components/Lines.d.ts.map +1 -0
- package/dist/components/Lines.js +19 -0
- package/dist/components/LoadingIndicator.d.ts +10 -0
- package/dist/components/LoadingIndicator.d.ts.map +1 -0
- package/dist/components/LoadingIndicator.js +143 -0
- package/dist/components/MaterialLibrary.d.ts +9 -0
- package/dist/components/MaterialLibrary.d.ts.map +1 -0
- package/dist/components/MaterialLibrary.js +57 -0
- package/dist/components/Moon.d.ts +13 -0
- package/dist/components/Moon.d.ts.map +1 -0
- package/dist/components/Moon.js +52 -0
- package/dist/components/ObjectNode.d.ts +11 -0
- package/dist/components/ObjectNode.d.ts.map +1 -0
- package/dist/components/ObjectNode.js +61 -0
- package/dist/components/ObjectsRenderer.d.ts +11 -0
- package/dist/components/ObjectsRenderer.d.ts.map +1 -0
- package/dist/components/ObjectsRenderer.js +19 -0
- package/dist/components/Ocean.d.ts +8 -0
- package/dist/components/Ocean.d.ts.map +1 -0
- package/dist/components/Ocean.js +111 -0
- package/dist/components/ParticlesR3f.d.ts +16 -0
- package/dist/components/ParticlesR3f.d.ts.map +1 -0
- package/dist/components/ParticlesR3f.js +66 -0
- package/dist/components/Path.d.ts +13 -0
- package/dist/components/Path.d.ts.map +1 -0
- package/dist/components/Path.js +41 -0
- package/dist/components/PathGeometry.d.ts +11 -0
- package/dist/components/PathGeometry.d.ts.map +1 -0
- package/dist/components/PathGeometry.js +109 -0
- package/dist/components/PathRenderer.d.ts +14 -0
- package/dist/components/PathRenderer.d.ts.map +1 -0
- package/dist/components/PathRenderer.js +33 -0
- package/dist/components/ProductionScene.d.ts +29 -0
- package/dist/components/ProductionScene.d.ts.map +1 -0
- package/dist/components/ProductionScene.js +18 -0
- package/dist/components/ProjectLoader.d.ts +14 -0
- package/dist/components/ProjectLoader.d.ts.map +1 -0
- package/dist/components/ProjectLoader.js +76 -0
- package/dist/components/Rain.d.ts +8 -0
- package/dist/components/Rain.d.ts.map +1 -0
- package/dist/components/Rain.js +133 -0
- package/dist/components/SceneBuilder.d.ts +5 -0
- package/dist/components/SceneBuilder.d.ts.map +1 -0
- package/dist/components/SceneBuilder.js +104 -0
- package/dist/components/SceneFog.d.ts +8 -0
- package/dist/components/SceneFog.d.ts.map +1 -0
- package/dist/components/SceneFog.js +19 -0
- package/dist/components/ShootingStar.d.ts +16 -0
- package/dist/components/ShootingStar.d.ts.map +1 -0
- package/dist/components/ShootingStar.js +92 -0
- package/dist/components/ShootingStars.d.ts +8 -0
- package/dist/components/ShootingStars.d.ts.map +1 -0
- package/dist/components/ShootingStars.js +40 -0
- package/dist/components/SkyController.d.ts +10 -0
- package/dist/components/SkyController.d.ts.map +1 -0
- package/dist/components/SkyController.js +159 -0
- package/dist/components/SkyMesh.d.ts +11 -0
- package/dist/components/SkyMesh.d.ts.map +1 -0
- package/dist/components/SkyMesh.js +36 -0
- package/dist/components/SkySystem.d.ts +34 -0
- package/dist/components/SkySystem.d.ts.map +1 -0
- package/dist/components/SkySystem.js +47 -0
- package/dist/components/Skybox.d.ts +12 -0
- package/dist/components/Skybox.d.ts.map +1 -0
- package/dist/components/Skybox.js +79 -0
- package/dist/components/Stars.d.ts +14 -0
- package/dist/components/Stars.d.ts.map +1 -0
- package/dist/components/Stars.js +165 -0
- package/dist/components/SunLight.d.ts +15 -0
- package/dist/components/SunLight.d.ts.map +1 -0
- package/dist/components/SunLight.js +57 -0
- package/dist/components/Text2D.d.ts +9 -0
- package/dist/components/Text2D.d.ts.map +1 -0
- package/dist/components/Text2D.js +56 -0
- package/dist/components/Text3D.d.ts +10 -0
- package/dist/components/Text3D.d.ts.map +1 -0
- package/dist/components/Text3D.js +8 -0
- package/dist/components/effects/AuraEffect.d.ts +10 -0
- package/dist/components/effects/AuraEffect.d.ts.map +1 -0
- package/dist/components/effects/AuraEffect.js +127 -0
- package/dist/components/effects/AuroraEffect.d.ts +10 -0
- package/dist/components/effects/AuroraEffect.d.ts.map +1 -0
- package/dist/components/effects/AuroraEffect.js +112 -0
- package/dist/components/effects/BlackHoleEffect.d.ts +10 -0
- package/dist/components/effects/BlackHoleEffect.d.ts.map +1 -0
- package/dist/components/effects/BlackHoleEffect.js +193 -0
- package/dist/components/effects/ConstellationEffect.d.ts +10 -0
- package/dist/components/effects/ConstellationEffect.d.ts.map +1 -0
- package/dist/components/effects/ConstellationEffect.js +189 -0
- package/dist/components/effects/DataStreamEffect.d.ts +10 -0
- package/dist/components/effects/DataStreamEffect.d.ts.map +1 -0
- package/dist/components/effects/DataStreamEffect.js +138 -0
- package/dist/components/effects/DnaHelixEffect.d.ts +10 -0
- package/dist/components/effects/DnaHelixEffect.d.ts.map +1 -0
- package/dist/components/effects/DnaHelixEffect.js +311 -0
- package/dist/components/effects/FireEffect.d.ts +10 -0
- package/dist/components/effects/FireEffect.d.ts.map +1 -0
- package/dist/components/effects/FireEffect.js +194 -0
- package/dist/components/effects/ForcefieldEffect.d.ts +10 -0
- package/dist/components/effects/ForcefieldEffect.d.ts.map +1 -0
- package/dist/components/effects/ForcefieldEffect.js +132 -0
- package/dist/components/effects/HologramEffect.d.ts +10 -0
- package/dist/components/effects/HologramEffect.d.ts.map +1 -0
- package/dist/components/effects/HologramEffect.js +143 -0
- package/dist/components/effects/IceCrystalsEffect.d.ts +10 -0
- package/dist/components/effects/IceCrystalsEffect.d.ts.map +1 -0
- package/dist/components/effects/IceCrystalsEffect.js +190 -0
- package/dist/components/effects/LightningEffect.d.ts +10 -0
- package/dist/components/effects/LightningEffect.d.ts.map +1 -0
- package/dist/components/effects/LightningEffect.js +240 -0
- package/dist/components/effects/MoleculesEffect.d.ts +10 -0
- package/dist/components/effects/MoleculesEffect.d.ts.map +1 -0
- package/dist/components/effects/MoleculesEffect.js +179 -0
- package/dist/components/effects/NeuralNetworkEffect.d.ts +10 -0
- package/dist/components/effects/NeuralNetworkEffect.d.ts.map +1 -0
- package/dist/components/effects/NeuralNetworkEffect.js +188 -0
- package/dist/components/effects/OrbEffect.d.ts +10 -0
- package/dist/components/effects/OrbEffect.d.ts.map +1 -0
- package/dist/components/effects/OrbEffect.js +291 -0
- package/dist/components/effects/PortalEffect.d.ts +10 -0
- package/dist/components/effects/PortalEffect.d.ts.map +1 -0
- package/dist/components/effects/PortalEffect.js +191 -0
- package/dist/components/effects/ShockwaveEffect.d.ts +10 -0
- package/dist/components/effects/ShockwaveEffect.d.ts.map +1 -0
- package/dist/components/effects/ShockwaveEffect.js +159 -0
- package/dist/components/effects/SmokePlumeEffect.d.ts +10 -0
- package/dist/components/effects/SmokePlumeEffect.d.ts.map +1 -0
- package/dist/components/effects/SmokePlumeEffect.js +141 -0
- package/dist/components/effects/SmokeRingEffect.d.ts +10 -0
- package/dist/components/effects/SmokeRingEffect.d.ts.map +1 -0
- package/dist/components/effects/SmokeRingEffect.js +158 -0
- package/dist/components/effects/VolumetricFogEffect.d.ts +10 -0
- package/dist/components/effects/VolumetricFogEffect.d.ts.map +1 -0
- package/dist/components/effects/VolumetricFogEffect.js +111 -0
- package/dist/constants.d.ts +2 -0
- package/dist/constants.d.ts.map +1 -0
- package/dist/constants.js +1 -0
- package/dist/hooks/index.d.ts +1 -0
- package/dist/hooks/index.d.ts.map +1 -0
- package/dist/hooks/index.js +1 -0
- package/dist/hooks/useAnimationEvents.d.ts +10 -0
- package/dist/hooks/useAnimationEvents.d.ts.map +1 -0
- package/dist/hooks/useAnimationEvents.js +28 -0
- package/dist/hooks/useCameraAnimation.d.ts +35 -0
- package/dist/hooks/useCameraAnimation.d.ts.map +1 -0
- package/dist/hooks/useCameraAnimation.js +268 -0
- package/dist/hooks/useContinuousEffects.d.ts +15 -0
- package/dist/hooks/useContinuousEffects.d.ts.map +1 -0
- package/dist/hooks/useContinuousEffects.js +173 -0
- package/dist/hooks/useCubeCamera.d.ts +19 -0
- package/dist/hooks/useCubeCamera.d.ts.map +1 -0
- package/dist/hooks/useCubeCamera.js +73 -0
- package/dist/hooks/useEnvironmentEffects.d.ts +12 -0
- package/dist/hooks/useEnvironmentEffects.d.ts.map +1 -0
- package/dist/hooks/useEnvironmentEffects.js +22 -0
- package/dist/hooks/useFrameEffects.d.ts +6 -0
- package/dist/hooks/useFrameEffects.d.ts.map +1 -0
- package/dist/hooks/useFrameEffects.js +19 -0
- package/dist/hooks/useInteractionEffects.d.ts +11 -0
- package/dist/hooks/useInteractionEffects.d.ts.map +1 -0
- package/dist/hooks/useInteractionEffects.js +35 -0
- package/dist/hooks/useKey.d.ts +26 -0
- package/dist/hooks/useKey.d.ts.map +1 -0
- package/dist/hooks/useKey.js +73 -0
- package/dist/hooks/useLightHandlers.d.ts +14 -0
- package/dist/hooks/useLightHandlers.d.ts.map +1 -0
- package/dist/hooks/useLightHandlers.js +116 -0
- package/dist/hooks/useMaterialApplication.d.ts +9 -0
- package/dist/hooks/useMaterialApplication.d.ts.map +1 -0
- package/dist/hooks/useMaterialApplication.js +113 -0
- package/dist/hooks/useMaterialOptions.d.ts +13 -0
- package/dist/hooks/useMaterialOptions.d.ts.map +1 -0
- package/dist/hooks/useMaterialOptions.js +110 -0
- package/dist/hooks/useMaterialUniforms.d.ts +18 -0
- package/dist/hooks/useMaterialUniforms.d.ts.map +1 -0
- package/dist/hooks/useMaterialUniforms.js +96 -0
- package/dist/hooks/useMeshController.d.ts +3 -0
- package/dist/hooks/useMeshController.d.ts.map +1 -0
- package/dist/hooks/useMeshController.js +152 -0
- package/dist/hooks/useMouseHandlers.d.ts +8 -0
- package/dist/hooks/useMouseHandlers.d.ts.map +1 -0
- package/dist/hooks/useMouseHandlers.js +47 -0
- package/dist/hooks/useObjectAnimation.d.ts +13 -0
- package/dist/hooks/useObjectAnimation.d.ts.map +1 -0
- package/dist/hooks/useObjectAnimation.js +11 -0
- package/dist/hooks/useObjectEdges.d.ts +4 -0
- package/dist/hooks/useObjectEdges.d.ts.map +1 -0
- package/dist/hooks/useObjectEdges.js +199 -0
- package/dist/hooks/useOrbitControls.d.ts +7 -0
- package/dist/hooks/useOrbitControls.d.ts.map +1 -0
- package/dist/hooks/useOrbitControls.js +9 -0
- package/dist/hooks/useParticlePositions.d.ts +19 -0
- package/dist/hooks/useParticlePositions.d.ts.map +1 -0
- package/dist/hooks/useParticlePositions.js +56 -0
- package/dist/hooks/useParticlesColors.d.ts +14 -0
- package/dist/hooks/useParticlesColors.d.ts.map +1 -0
- package/dist/hooks/useParticlesColors.js +27 -0
- package/dist/hooks/useParticlesTextures.d.ts +10 -0
- package/dist/hooks/useParticlesTextures.d.ts.map +1 -0
- package/dist/hooks/useParticlesTextures.js +23 -0
- package/dist/hooks/usePathAnimation.d.ts +26 -0
- package/dist/hooks/usePathAnimation.d.ts.map +1 -0
- package/dist/hooks/usePathAnimation.js +120 -0
- package/dist/hooks/useSkyAnimation.d.ts +14 -0
- package/dist/hooks/useSkyAnimation.d.ts.map +1 -0
- package/dist/hooks/useSkyAnimation.js +46 -0
- package/dist/hooks/useSkySystem.d.ts +26 -0
- package/dist/hooks/useSkySystem.d.ts.map +1 -0
- package/dist/hooks/useSkySystem.js +57 -0
- package/dist/hooks/useSkyUniforms.d.ts +18 -0
- package/dist/hooks/useSkyUniforms.d.ts.map +1 -0
- package/dist/hooks/useSkyUniforms.js +59 -0
- package/dist/hooks/useTransformControls.d.ts +6 -0
- package/dist/hooks/useTransformControls.d.ts.map +1 -0
- package/dist/hooks/useTransformControls.js +111 -0
- package/dist/hooks/useWaterEnvironment.d.ts +5 -0
- package/dist/hooks/useWaterEnvironment.d.ts.map +1 -0
- package/dist/hooks/useWaterEnvironment.js +27 -0
- package/dist/hooks/useWaterReflections.d.ts +17 -0
- package/dist/hooks/useWaterReflections.d.ts.map +1 -0
- package/dist/hooks/useWaterReflections.js +77 -0
- package/dist/index.d.ts +140 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +109 -0
- package/dist/services/AnimationsManager.d.ts +33 -0
- package/dist/services/AnimationsManager.d.ts.map +1 -0
- package/dist/services/AnimationsManager.js +58 -0
- package/dist/services/FontManager.d.ts +32 -0
- package/dist/services/FontManager.d.ts.map +1 -0
- package/dist/services/FontManager.js +76 -0
- package/dist/services/TexturesManager.d.ts +17 -0
- package/dist/services/TexturesManager.d.ts.map +1 -0
- package/dist/services/TexturesManager.js +48 -0
- package/dist/shaders/RainMaterial.d.ts +34 -0
- package/dist/shaders/RainMaterial.d.ts.map +1 -0
- package/dist/shaders/RainMaterial.js +56 -0
- package/dist/shaders/ShaderEffectsMaterial.d.ts +279 -0
- package/dist/shaders/ShaderEffectsMaterial.d.ts.map +1 -0
- package/dist/shaders/ShaderEffectsMaterial.js +257 -0
- package/dist/shaders/ShootingStarMaterial.d.ts +14 -0
- package/dist/shaders/ShootingStarMaterial.d.ts.map +1 -0
- package/dist/shaders/ShootingStarMaterial.js +33 -0
- package/dist/shaders/SkyboxMaterial.d.ts +38 -0
- package/dist/shaders/SkyboxMaterial.d.ts.map +1 -0
- package/dist/shaders/SkyboxMaterial.js +57 -0
- package/dist/shaders/effects/EffectsVertexFunctions.glsl.d.ts +2 -0
- package/dist/shaders/effects/EffectsVertexFunctions.glsl.d.ts.map +1 -0
- package/dist/shaders/effects/EffectsVertexFunctions.glsl.js +167 -0
- package/dist/utils/CameraSingleton.d.ts +35 -0
- package/dist/utils/CameraSingleton.d.ts.map +1 -0
- package/dist/utils/CameraSingleton.js +178 -0
- package/dist/utils/anchorUtils.d.ts +10 -0
- package/dist/utils/anchorUtils.d.ts.map +1 -0
- package/dist/utils/anchorUtils.js +13 -0
- package/dist/utils/frameAnimations.d.ts +49 -0
- package/dist/utils/frameAnimations.d.ts.map +1 -0
- package/dist/utils/frameAnimations.js +213 -0
- package/dist/utils/handleGenerativeEffectsAnimations.d.ts +5 -0
- package/dist/utils/handleGenerativeEffectsAnimations.d.ts.map +1 -0
- package/dist/utils/handleGenerativeEffectsAnimations.js +268 -0
- package/dist/utils/hasHoverAnimation.d.ts +3 -0
- package/dist/utils/hasHoverAnimation.d.ts.map +1 -0
- package/dist/utils/hasHoverAnimation.js +15 -0
- package/dist/utils/particleAnimations.d.ts +3 -0
- package/dist/utils/particleAnimations.d.ts.map +1 -0
- package/dist/utils/particleAnimations.js +17 -0
- package/dist/utils/sceneQuery.d.ts +9 -0
- package/dist/utils/sceneQuery.d.ts.map +1 -0
- package/dist/utils/sceneQuery.js +22 -0
- package/dist/utils/shaderUtils.d.ts +6 -0
- package/dist/utils/shaderUtils.d.ts.map +1 -0
- package/dist/utils/shaderUtils.js +145 -0
- package/dist/utils/textEffects.d.ts +31 -0
- package/dist/utils/textEffects.d.ts.map +1 -0
- package/dist/utils/textEffects.js +61 -0
- package/dist/utils/utils3d.d.ts +7 -0
- package/dist/utils/utils3d.d.ts.map +1 -0
- package/dist/utils/utils3d.js +34 -0
- package/package.json +43 -0
|
@@ -0,0 +1,158 @@
|
|
|
1
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
import { useRef, useMemo } from 'react';
|
|
3
|
+
import { useFrame } from '@react-three/fiber';
|
|
4
|
+
import * as THREE from 'three';
|
|
5
|
+
import { applyGenerativeAnimations } from '../../utils/handleGenerativeEffectsAnimations';
|
|
6
|
+
// ── Per-ring puff shader (one Points per ring — GPU computes torus positions) ──
|
|
7
|
+
const ringVert = /* glsl */ `
|
|
8
|
+
attribute float aAngle; // 0..TAU position around torus
|
|
9
|
+
attribute float aPuff; // sub-angle within tube cross-section 0..TAU
|
|
10
|
+
attribute float aPhase;
|
|
11
|
+
|
|
12
|
+
uniform float uProgress; // 0=born, 1=dead
|
|
13
|
+
uniform float uMaxRadius;
|
|
14
|
+
uniform float uThickness; // tube radius
|
|
15
|
+
uniform float uRiseSpeed; // Y lift per unit progress
|
|
16
|
+
uniform float uBaseY;
|
|
17
|
+
uniform float u_time;
|
|
18
|
+
|
|
19
|
+
varying float vAlpha;
|
|
20
|
+
|
|
21
|
+
void main() {
|
|
22
|
+
if (uProgress < 0.0 || uProgress > 1.0) {
|
|
23
|
+
gl_PointSize = 0.0;
|
|
24
|
+
gl_Position = vec4(0.0);
|
|
25
|
+
vAlpha = 0.0;
|
|
26
|
+
return;
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
float ringR = uMaxRadius * uProgress;
|
|
30
|
+
|
|
31
|
+
// Tube cross-section wiggles outward slightly as ring expands
|
|
32
|
+
float tubeR = uThickness * (0.8 + 0.4 * uProgress);
|
|
33
|
+
float tubePhi = aPuff + u_time * 0.4 + aPhase;
|
|
34
|
+
float offR = tubeR * cos(tubePhi);
|
|
35
|
+
float offY = tubeR * sin(tubePhi);
|
|
36
|
+
|
|
37
|
+
float r = ringR + offR;
|
|
38
|
+
float x = cos(aAngle) * r;
|
|
39
|
+
float z = sin(aAngle) * r;
|
|
40
|
+
float y = uBaseY + uProgress * uRiseSpeed + offY;
|
|
41
|
+
|
|
42
|
+
// Puff grows then fades
|
|
43
|
+
float lifeAlpha = smoothstep(0.0, 0.12, uProgress) * smoothstep(1.0, 0.65, uProgress);
|
|
44
|
+
vAlpha = lifeAlpha;
|
|
45
|
+
|
|
46
|
+
float puffSize = uThickness * 50.0 * lifeAlpha;
|
|
47
|
+
|
|
48
|
+
vec4 mv = modelViewMatrix * vec4(x, y, z, 1.0);
|
|
49
|
+
gl_PointSize = puffSize * (200.0 / -mv.z);
|
|
50
|
+
gl_Position = projectionMatrix * mv;
|
|
51
|
+
}
|
|
52
|
+
`;
|
|
53
|
+
const ringFrag = /* glsl */ `
|
|
54
|
+
uniform vec3 uSmokeColor;
|
|
55
|
+
uniform float uOpacity;
|
|
56
|
+
varying float vAlpha;
|
|
57
|
+
|
|
58
|
+
void main() {
|
|
59
|
+
if (vAlpha < 0.01) discard;
|
|
60
|
+
vec2 c = gl_PointCoord - 0.5;
|
|
61
|
+
float d = length(c);
|
|
62
|
+
if (d > 0.5) discard;
|
|
63
|
+
float g = exp(-d * d * 3.0);
|
|
64
|
+
gl_FragColor = vec4(uSmokeColor, g * vAlpha * uOpacity);
|
|
65
|
+
}
|
|
66
|
+
`;
|
|
67
|
+
const PUFFS_PER_RING = 120;
|
|
68
|
+
const SmokeRingEffect = ({ boundingRadius, config, animations }) => {
|
|
69
|
+
const { ringCount, expansionRadius, riseSpeed, intervalSeconds, smokeColor, thickness, opacity, speed, intensity } = config;
|
|
70
|
+
const startValuesCacheRef = useRef({});
|
|
71
|
+
const N = Math.max(1, Math.min(ringCount, 4));
|
|
72
|
+
// Ring states — one per slot
|
|
73
|
+
const ringStates = useRef([]);
|
|
74
|
+
const { geos, mats } = useMemo(() => {
|
|
75
|
+
const maxR = boundingRadius * expansionRadius;
|
|
76
|
+
const tubeR = boundingRadius * thickness;
|
|
77
|
+
const riseH = boundingRadius * riseSpeed;
|
|
78
|
+
const sc = new THREE.Color(smokeColor);
|
|
79
|
+
const scv = new THREE.Vector3(sc.r, sc.g, sc.b);
|
|
80
|
+
// Stagger initial timers so rings don't all fire together
|
|
81
|
+
ringStates.current = Array.from({ length: N }, (_, i) => ({
|
|
82
|
+
progress: 0,
|
|
83
|
+
timer: (i / N) * intervalSeconds,
|
|
84
|
+
active: false,
|
|
85
|
+
}));
|
|
86
|
+
const geos = [];
|
|
87
|
+
const mats = [];
|
|
88
|
+
for (let ri = 0; ri < N; ri++) {
|
|
89
|
+
const aAngle = new Float32Array(PUFFS_PER_RING);
|
|
90
|
+
const aPuff = new Float32Array(PUFFS_PER_RING);
|
|
91
|
+
const aPhase = new Float32Array(PUFFS_PER_RING);
|
|
92
|
+
for (let i = 0; i < PUFFS_PER_RING; i++) {
|
|
93
|
+
aAngle[i] = (i / PUFFS_PER_RING) * Math.PI * 2;
|
|
94
|
+
aPuff[i] = Math.random() * Math.PI * 2;
|
|
95
|
+
aPhase[i] = Math.random() * Math.PI * 2;
|
|
96
|
+
}
|
|
97
|
+
const geo = new THREE.BufferGeometry();
|
|
98
|
+
geo.setAttribute('position', new THREE.BufferAttribute(new Float32Array(PUFFS_PER_RING * 3), 3));
|
|
99
|
+
geo.setAttribute('aAngle', new THREE.BufferAttribute(aAngle, 1));
|
|
100
|
+
geo.setAttribute('aPuff', new THREE.BufferAttribute(aPuff, 1));
|
|
101
|
+
geo.setAttribute('aPhase', new THREE.BufferAttribute(aPhase, 1));
|
|
102
|
+
geo.frustumCulled = false;
|
|
103
|
+
const mat = new THREE.ShaderMaterial({
|
|
104
|
+
vertexShader: ringVert,
|
|
105
|
+
fragmentShader: ringFrag,
|
|
106
|
+
uniforms: {
|
|
107
|
+
uProgress: { value: -1 }, // -1 = hidden
|
|
108
|
+
uMaxRadius: { value: maxR },
|
|
109
|
+
uThickness: { value: tubeR * intensity },
|
|
110
|
+
uRiseSpeed: { value: riseH },
|
|
111
|
+
uBaseY: { value: -boundingRadius * 0.2 },
|
|
112
|
+
u_time: { value: 0 },
|
|
113
|
+
uSmokeColor: { value: scv },
|
|
114
|
+
uOpacity: { value: opacity },
|
|
115
|
+
},
|
|
116
|
+
transparent: true,
|
|
117
|
+
depthWrite: false,
|
|
118
|
+
blending: THREE.NormalBlending,
|
|
119
|
+
});
|
|
120
|
+
geos.push(geo);
|
|
121
|
+
mats.push(mat);
|
|
122
|
+
}
|
|
123
|
+
return { geos, mats };
|
|
124
|
+
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
125
|
+
}, [N, boundingRadius, expansionRadius, riseSpeed, intervalSeconds, smokeColor, thickness, opacity, intensity]);
|
|
126
|
+
useFrame((state, delta) => {
|
|
127
|
+
const t = state.clock.getElapsedTime();
|
|
128
|
+
const dt = delta * speed;
|
|
129
|
+
ringStates.current.forEach((ring, ri) => {
|
|
130
|
+
const mat = mats[ri];
|
|
131
|
+
mat.uniforms.u_time.value = t;
|
|
132
|
+
if (ring.active) {
|
|
133
|
+
ring.progress += dt * 0.32;
|
|
134
|
+
if (ring.progress >= 1) {
|
|
135
|
+
ring.active = false;
|
|
136
|
+
ring.progress = 0;
|
|
137
|
+
ring.timer = intervalSeconds / speed;
|
|
138
|
+
mat.uniforms.uProgress.value = -1;
|
|
139
|
+
}
|
|
140
|
+
else {
|
|
141
|
+
mat.uniforms.uProgress.value = ring.progress;
|
|
142
|
+
}
|
|
143
|
+
}
|
|
144
|
+
else {
|
|
145
|
+
ring.timer -= delta;
|
|
146
|
+
if (ring.timer <= 0) {
|
|
147
|
+
ring.active = true;
|
|
148
|
+
ring.progress = 0;
|
|
149
|
+
}
|
|
150
|
+
}
|
|
151
|
+
});
|
|
152
|
+
if (animations?.length) {
|
|
153
|
+
applyGenerativeAnimations(mats, animations, startValuesCacheRef.current, Date.now(), false);
|
|
154
|
+
}
|
|
155
|
+
});
|
|
156
|
+
return (_jsx("group", { children: geos.map((geo, i) => (_jsx("points", { geometry: geo, material: mats[i] }, i))) }));
|
|
157
|
+
};
|
|
158
|
+
export default SmokeRingEffect;
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import type { VolumetricFogConfig, AnimationOptions } from '@ntalmagor/3drize-core';
|
|
3
|
+
interface VolumetricFogEffectProps {
|
|
4
|
+
boundingRadius: number;
|
|
5
|
+
config: VolumetricFogConfig;
|
|
6
|
+
animations?: AnimationOptions[];
|
|
7
|
+
}
|
|
8
|
+
declare const VolumetricFogEffect: React.FC<VolumetricFogEffectProps>;
|
|
9
|
+
export default VolumetricFogEffect;
|
|
10
|
+
//# sourceMappingURL=VolumetricFogEffect.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"VolumetricFogEffect.d.ts","sourceRoot":"","sources":["../../../src/components/effects/VolumetricFogEffect.tsx"],"names":[],"mappings":"AAAA,OAAO,KAA0B,MAAM,OAAO,CAAC;AAG/C,OAAO,KAAK,EAAE,mBAAmB,EAAE,gBAAgB,EAAE,MAAM,wBAAwB,CAAC;AAIpF,UAAU,wBAAwB;IAChC,cAAc,EAAE,MAAM,CAAC;IACvB,MAAM,EAAE,mBAAmB,CAAC;IAC5B,UAAU,CAAC,EAAE,gBAAgB,EAAE,CAAC;CACjC;AAqDD,QAAA,MAAM,mBAAmB,EAAE,KAAK,CAAC,EAAE,CAAC,wBAAwB,CAmE3D,CAAC;AAEF,eAAe,mBAAmB,CAAC"}
|
|
@@ -0,0 +1,111 @@
|
|
|
1
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
import { useRef, useMemo } from 'react';
|
|
3
|
+
import { useFrame } from '@react-three/fiber';
|
|
4
|
+
import * as THREE from 'three';
|
|
5
|
+
import { applyGenerativeAnimations } from '../../utils/handleGenerativeEffectsAnimations';
|
|
6
|
+
// ── Billboard fog puff — drifts slowly, never rises far ───────────────────────
|
|
7
|
+
const fogVert = /* glsl */ `
|
|
8
|
+
attribute float aT; // stagger offset 0..1
|
|
9
|
+
attribute vec3 aCenter; // resting (x,y,z) position in fog layer
|
|
10
|
+
attribute float aPhase;
|
|
11
|
+
attribute float aSize;
|
|
12
|
+
|
|
13
|
+
uniform float u_time;
|
|
14
|
+
uniform float uDrift; // horizontal drift speed
|
|
15
|
+
uniform float uFogRadius;
|
|
16
|
+
|
|
17
|
+
varying float vAlpha;
|
|
18
|
+
|
|
19
|
+
void main() {
|
|
20
|
+
float t = fract(aT + u_time * 0.05); // very slow life cycle — fog is persistent
|
|
21
|
+
|
|
22
|
+
// Gentle horizontal drift — fog rolls around the base
|
|
23
|
+
float dx = sin(u_time * uDrift + aPhase) * uFogRadius * 0.18;
|
|
24
|
+
float dz = cos(u_time * uDrift * 0.7 + aPhase * 1.3) * uFogRadius * 0.14;
|
|
25
|
+
// Slow vertical bob
|
|
26
|
+
float dy = sin(u_time * 0.25 + aPhase) * uFogRadius * 0.06;
|
|
27
|
+
|
|
28
|
+
vec3 pos = aCenter + vec3(dx, dy, dz);
|
|
29
|
+
|
|
30
|
+
// Puff fades in/out with its own phase to prevent popping
|
|
31
|
+
float pulse = 0.55 + 0.45 * sin(u_time * 0.35 + aPhase * 2.1);
|
|
32
|
+
vAlpha = pulse;
|
|
33
|
+
|
|
34
|
+
vec4 mv = modelViewMatrix * vec4(pos, 1.0);
|
|
35
|
+
gl_PointSize = aSize * (220.0 / -mv.z);
|
|
36
|
+
gl_Position = projectionMatrix * mv;
|
|
37
|
+
}
|
|
38
|
+
`;
|
|
39
|
+
const fogFrag = /* glsl */ `
|
|
40
|
+
uniform vec3 uFogColor;
|
|
41
|
+
uniform float uDensity;
|
|
42
|
+
varying float vAlpha;
|
|
43
|
+
|
|
44
|
+
void main() {
|
|
45
|
+
vec2 c = gl_PointCoord - 0.5;
|
|
46
|
+
float d = length(c);
|
|
47
|
+
if (d > 0.5) discard;
|
|
48
|
+
|
|
49
|
+
// Very soft — almost no hard edge at all
|
|
50
|
+
float g = exp(-d * d * 2.2);
|
|
51
|
+
|
|
52
|
+
gl_FragColor = vec4(uFogColor, g * vAlpha * uDensity);
|
|
53
|
+
}
|
|
54
|
+
`;
|
|
55
|
+
const VolumetricFogEffect = ({ boundingRadius, config, animations }) => {
|
|
56
|
+
const { particleCount, fogRadius, driftSpeed, fogColor, density, opacity, intensity } = config;
|
|
57
|
+
const startValuesCacheRef = useRef({});
|
|
58
|
+
const r = boundingRadius * fogRadius;
|
|
59
|
+
const { geo, mat } = useMemo(() => {
|
|
60
|
+
const N = Math.max(20, Math.min(particleCount, 200));
|
|
61
|
+
const aT = new Float32Array(N);
|
|
62
|
+
const aCenter = new Float32Array(N * 3);
|
|
63
|
+
const aPhase = new Float32Array(N);
|
|
64
|
+
const aSize = new Float32Array(N);
|
|
65
|
+
for (let i = 0; i < N; i++) {
|
|
66
|
+
aT[i] = i / N;
|
|
67
|
+
// Distribute puffs in a disc with vertical variation at base level
|
|
68
|
+
const angle = Math.random() * Math.PI * 2;
|
|
69
|
+
const rad = Math.sqrt(Math.random()) * r;
|
|
70
|
+
const yOff = (Math.random() - 0.3) * boundingRadius * 0.35; // mostly at base, slight spread
|
|
71
|
+
aCenter[i * 3] = Math.cos(angle) * rad;
|
|
72
|
+
aCenter[i * 3 + 1] = yOff - boundingRadius * 0.3; // sit at/below object base
|
|
73
|
+
aCenter[i * 3 + 2] = Math.sin(angle) * rad;
|
|
74
|
+
aPhase[i] = Math.random() * Math.PI * 2;
|
|
75
|
+
// Large puffs — fog is billowy
|
|
76
|
+
aSize[i] = (50 + Math.random() * 70) * intensity;
|
|
77
|
+
}
|
|
78
|
+
const g = new THREE.BufferGeometry();
|
|
79
|
+
g.setAttribute('position', new THREE.BufferAttribute(new Float32Array(N * 3), 3));
|
|
80
|
+
g.setAttribute('aT', new THREE.BufferAttribute(aT, 1));
|
|
81
|
+
g.setAttribute('aCenter', new THREE.BufferAttribute(aCenter, 3));
|
|
82
|
+
g.setAttribute('aPhase', new THREE.BufferAttribute(aPhase, 1));
|
|
83
|
+
g.setAttribute('aSize', new THREE.BufferAttribute(aSize, 1));
|
|
84
|
+
g.frustumCulled = false;
|
|
85
|
+
const fc = new THREE.Color(fogColor);
|
|
86
|
+
const m = new THREE.ShaderMaterial({
|
|
87
|
+
vertexShader: fogVert,
|
|
88
|
+
fragmentShader: fogFrag,
|
|
89
|
+
uniforms: {
|
|
90
|
+
u_time: { value: 0 },
|
|
91
|
+
uDrift: { value: driftSpeed },
|
|
92
|
+
uFogRadius: { value: r },
|
|
93
|
+
uFogColor: { value: new THREE.Vector3(fc.r, fc.g, fc.b) },
|
|
94
|
+
uDensity: { value: density * opacity },
|
|
95
|
+
},
|
|
96
|
+
transparent: true,
|
|
97
|
+
depthWrite: false,
|
|
98
|
+
blending: THREE.NormalBlending,
|
|
99
|
+
});
|
|
100
|
+
return { geo: g, mat: m };
|
|
101
|
+
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
102
|
+
}, [particleCount, r, fogColor, density, driftSpeed, opacity, intensity, boundingRadius]);
|
|
103
|
+
useFrame((state) => {
|
|
104
|
+
mat.uniforms.u_time.value = state.clock.getElapsedTime();
|
|
105
|
+
if (animations?.length) {
|
|
106
|
+
applyGenerativeAnimations([mat], animations, startValuesCacheRef.current, Date.now(), false);
|
|
107
|
+
}
|
|
108
|
+
});
|
|
109
|
+
return _jsx("points", { geometry: geo, material: mat });
|
|
110
|
+
};
|
|
111
|
+
export default VolumetricFogEffect;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"constants.d.ts","sourceRoot":"","sources":["../src/constants.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,gBAAgB,kCAAkC,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export const dataCenterServer = 'https://3d-rise.com/api/data/';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/hooks/index.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { type AnimationEvent } from '../../../core/src/services/AnimationsManager';
|
|
2
|
+
interface AnimationEventHandlers {
|
|
3
|
+
onSequenceStart?: (event: AnimationEvent) => void;
|
|
4
|
+
onSequenceEnd?: (event: AnimationEvent) => void;
|
|
5
|
+
onStepStart?: (event: AnimationEvent) => void;
|
|
6
|
+
onStepEnd?: (event: AnimationEvent) => void;
|
|
7
|
+
}
|
|
8
|
+
export declare const useAnimationEvents: (handlers: AnimationEventHandlers) => void;
|
|
9
|
+
export {};
|
|
10
|
+
//# sourceMappingURL=useAnimationEvents.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useAnimationEvents.d.ts","sourceRoot":"","sources":["../../src/hooks/useAnimationEvents.ts"],"names":[],"mappings":"AACA,OAA0B,EAAE,KAAK,cAAc,EAAE,MAAM,8CAA8C,CAAC;AAEtG,UAAU,sBAAsB;IAC9B,eAAe,CAAC,EAAE,CAAC,KAAK,EAAE,cAAc,KAAK,IAAI,CAAC;IAClD,aAAa,CAAC,EAAI,CAAC,KAAK,EAAE,cAAc,KAAK,IAAI,CAAC;IAClD,WAAW,CAAC,EAAM,CAAC,KAAK,EAAE,cAAc,KAAK,IAAI,CAAC;IAClD,SAAS,CAAC,EAAQ,CAAC,KAAK,EAAE,cAAc,KAAK,IAAI,CAAC;CACnD;AAED,eAAO,MAAM,kBAAkB,GAAI,UAAU,sBAAsB,SA0BlE,CAAC"}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import { useEffect, useRef } from 'react';
|
|
2
|
+
import AnimationsManager from '../../../core/src/services/AnimationsManager';
|
|
3
|
+
export const useAnimationEvents = (handlers) => {
|
|
4
|
+
const ref = useRef(handlers);
|
|
5
|
+
ref.current = handlers;
|
|
6
|
+
useEffect(() => {
|
|
7
|
+
const wrap = (key) => (event) => ref.current[key]?.(event);
|
|
8
|
+
const ss = wrap('onSequenceStart');
|
|
9
|
+
const se = wrap('onSequenceEnd');
|
|
10
|
+
const ts = wrap('onStepStart');
|
|
11
|
+
const te = wrap('onStepEnd');
|
|
12
|
+
if (handlers.onSequenceStart)
|
|
13
|
+
AnimationsManager.on('sequenceStart', ss);
|
|
14
|
+
if (handlers.onSequenceEnd)
|
|
15
|
+
AnimationsManager.on('sequenceEnd', se);
|
|
16
|
+
if (handlers.onStepStart)
|
|
17
|
+
AnimationsManager.on('stepStart', ts);
|
|
18
|
+
if (handlers.onStepEnd)
|
|
19
|
+
AnimationsManager.on('stepEnd', te);
|
|
20
|
+
return () => {
|
|
21
|
+
AnimationsManager.off('sequenceStart', ss);
|
|
22
|
+
AnimationsManager.off('sequenceEnd', se);
|
|
23
|
+
AnimationsManager.off('stepStart', ts);
|
|
24
|
+
AnimationsManager.off('stepEnd', te);
|
|
25
|
+
};
|
|
26
|
+
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
27
|
+
}, []);
|
|
28
|
+
};
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import { PerspectiveCamera } from 'three';
|
|
2
|
+
import { type CameraState, type QuaternionArray, type Vector3Array } from '@ntalmagor/3drize-core';
|
|
3
|
+
interface UseCameraAnimationOptions {
|
|
4
|
+
autoAnimate?: boolean;
|
|
5
|
+
defaultDuration?: number;
|
|
6
|
+
defaultEase?: string;
|
|
7
|
+
onAnimationStart?: () => void;
|
|
8
|
+
onAnimationComplete?: () => void;
|
|
9
|
+
onAnimationUpdate?: () => void;
|
|
10
|
+
}
|
|
11
|
+
interface CameraAnimationTarget {
|
|
12
|
+
position?: Vector3Array;
|
|
13
|
+
orientation?: QuaternionArray | Vector3Array;
|
|
14
|
+
fov?: number;
|
|
15
|
+
near?: number;
|
|
16
|
+
far?: number;
|
|
17
|
+
}
|
|
18
|
+
export declare const useCameraAnimation: (options?: UseCameraAnimationOptions, cameraState?: CameraState) => {
|
|
19
|
+
cameraState: CameraState;
|
|
20
|
+
isAnimating: () => boolean;
|
|
21
|
+
animateHandlers: (pointer: {
|
|
22
|
+
x: number;
|
|
23
|
+
y: number;
|
|
24
|
+
}) => void;
|
|
25
|
+
animateCamera: (target: CameraAnimationTarget, duration?: number, ease?: string, lookAtTarget?: Vector3Array) => Promise<void>;
|
|
26
|
+
animateToPosition: (position: Vector3Array, duration?: number, ease?: string) => Promise<void>;
|
|
27
|
+
animateToOrientation: (orientation: QuaternionArray, duration?: number, ease?: string) => Promise<void>;
|
|
28
|
+
animateToFov: (fov: number, duration?: number, ease?: string) => Promise<void>;
|
|
29
|
+
lookAt: (target: Vector3Array, animated?: boolean, duration?: number, ease?: string) => Promise<void>;
|
|
30
|
+
orbitAroundTarget: (target: Vector3Array, radius: number, startAngle?: number, endAngle?: number, duration?: number, ease?: string) => Promise<void>;
|
|
31
|
+
killAnimation: () => void;
|
|
32
|
+
camera: PerspectiveCamera | null;
|
|
33
|
+
};
|
|
34
|
+
export default useCameraAnimation;
|
|
35
|
+
//# sourceMappingURL=useCameraAnimation.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useCameraAnimation.d.ts","sourceRoot":"","sources":["../../src/hooks/useCameraAnimation.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,iBAAiB,EAAc,MAAM,OAAO,CAAC;AAGtD,OAAO,EAAW,KAAK,WAAW,EAAE,KAAK,eAAe,EAAE,KAAK,YAAY,EAAE,MAAM,wBAAwB,CAAC;AAO5G,UAAU,yBAAyB;IACjC,WAAW,CAAC,EAAE,OAAO,CAAC;IACtB,eAAe,CAAC,EAAE,MAAM,CAAC;IACzB,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,gBAAgB,CAAC,EAAE,MAAM,IAAI,CAAC;IAC9B,mBAAmB,CAAC,EAAE,MAAM,IAAI,CAAC;IACjC,iBAAiB,CAAC,EAAE,MAAM,IAAI,CAAC;CAChC;AAED,UAAU,qBAAqB;IAC7B,QAAQ,CAAC,EAAE,YAAY,CAAC;IACxB,WAAW,CAAC,EAAE,eAAe,GAAG,YAAY,CAAC;IAC7C,GAAG,CAAC,EAAE,MAAM,CAAC;IACb,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,GAAG,CAAC,EAAE,MAAM,CAAC;CACd;AAED,eAAO,MAAM,kBAAkB,GAAI,UAAS,yBAA8B,EAAE,cAAa,WAA+B;;;+BAwMpF;QAAE,CAAC,EAAE,MAAM,CAAC;QAAC,CAAC,EAAE,MAAM,CAAA;KAAE;4BApKhD,qBAAqB,aACnB,MAAM,SACV,MAAM,iBACG,YAAY;kCAwHjB,YAAY,aACX,MAAM,SACV,MAAM;wCAgCA,eAAe,aACjB,MAAM,SACV,MAAM;wBAuCR,MAAM,aACA,MAAM,SACV,MAAM;qBAOL,YAAY,aACV,OAAO,aACN,MAAM,SACV,MAAM;gCA2BL,YAAY,UACZ,MAAM,eACF,MAAM,aACR,MAAM,aACL,MAAM,SACV,MAAM;;;CA4EhB,CAAC;AAEF,eAAe,kBAAkB,CAAC"}
|
|
@@ -0,0 +1,268 @@
|
|
|
1
|
+
import { useRef, useEffect } from 'react';
|
|
2
|
+
import { Quaternion } from 'three';
|
|
3
|
+
import gsap from 'gsap';
|
|
4
|
+
import { getType } from '@ntalmagor/3drize-core';
|
|
5
|
+
import { useMouseHandlers } from './useMouseHandlers';
|
|
6
|
+
import { useOrbitControls } from './useOrbitControls';
|
|
7
|
+
import cameraManager from '../utils/CameraSingleton';
|
|
8
|
+
export const useCameraAnimation = (options = {}, cameraState = {}) => {
|
|
9
|
+
const { autoAnimate = true, defaultDuration = 2, defaultEase = "power2.out", onAnimationStart, onAnimationComplete, onAnimationUpdate } = options;
|
|
10
|
+
// const cameraState = useAppSelector(selectCamera);
|
|
11
|
+
const { interpolateProperty } = useMouseHandlers();
|
|
12
|
+
const orbitControls = useOrbitControls();
|
|
13
|
+
const cameraRef = useRef(cameraManager.getCamera());
|
|
14
|
+
const animationRef = useRef(null);
|
|
15
|
+
const isAnimatingRef = useRef(false);
|
|
16
|
+
const handlers = cameraState.handlers;
|
|
17
|
+
// Update camera reference when Three.js camera changes
|
|
18
|
+
useEffect(() => {
|
|
19
|
+
if (!cameraRef.current) {
|
|
20
|
+
cameraRef.current = cameraManager.getCamera();
|
|
21
|
+
}
|
|
22
|
+
}, []);
|
|
23
|
+
// Kill any running animation
|
|
24
|
+
const killAnimation = () => {
|
|
25
|
+
if (animationRef.current) {
|
|
26
|
+
animationRef.current.kill();
|
|
27
|
+
animationRef.current = null;
|
|
28
|
+
}
|
|
29
|
+
isAnimatingRef.current = false;
|
|
30
|
+
};
|
|
31
|
+
// Animate camera to target values
|
|
32
|
+
const animateCamera = (target, duration = defaultDuration, ease = defaultEase, lookAtTarget) => {
|
|
33
|
+
const cam = cameraRef.current;
|
|
34
|
+
// console.log("animateCamera called with cam:", cam);
|
|
35
|
+
if (!cam)
|
|
36
|
+
return Promise.resolve();
|
|
37
|
+
// Kill any existing animation
|
|
38
|
+
killAnimation();
|
|
39
|
+
// console.log('animateCamera', duration, ease)
|
|
40
|
+
return new Promise((resolve) => {
|
|
41
|
+
// console.log("Animating camera with target:", target, "duration:", duration, "ease:", ease);
|
|
42
|
+
const timeline = gsap.timeline({
|
|
43
|
+
onStart: () => {
|
|
44
|
+
isAnimatingRef.current = true;
|
|
45
|
+
onAnimationStart?.();
|
|
46
|
+
},
|
|
47
|
+
onUpdate: () => {
|
|
48
|
+
// Update projection matrix if FOV changed
|
|
49
|
+
if (target.fov !== undefined || target.near !== undefined || target.far !== undefined) {
|
|
50
|
+
cam.updateProjectionMatrix();
|
|
51
|
+
}
|
|
52
|
+
onAnimationUpdate?.();
|
|
53
|
+
},
|
|
54
|
+
onComplete: () => {
|
|
55
|
+
isAnimatingRef.current = false;
|
|
56
|
+
animationRef.current = null;
|
|
57
|
+
onAnimationComplete?.();
|
|
58
|
+
resolve();
|
|
59
|
+
}
|
|
60
|
+
});
|
|
61
|
+
// Animate position
|
|
62
|
+
if (target.position) {
|
|
63
|
+
console.log("Animating camera to position:", target.position, duration, ease);
|
|
64
|
+
timeline.to(cam.position, {
|
|
65
|
+
x: target.position[0],
|
|
66
|
+
y: target.position[1],
|
|
67
|
+
z: target.position[2],
|
|
68
|
+
duration,
|
|
69
|
+
ease
|
|
70
|
+
}, 0);
|
|
71
|
+
}
|
|
72
|
+
// Animate orientation
|
|
73
|
+
if (target.orientation) {
|
|
74
|
+
if (target.orientation.length === 3) {
|
|
75
|
+
// Euler angles
|
|
76
|
+
timeline.to(cam.rotation, {
|
|
77
|
+
x: target.orientation[0],
|
|
78
|
+
y: target.orientation[1],
|
|
79
|
+
z: target.orientation[2],
|
|
80
|
+
duration,
|
|
81
|
+
ease
|
|
82
|
+
}, 0);
|
|
83
|
+
}
|
|
84
|
+
else if (target.orientation.length === 4) {
|
|
85
|
+
// Quaternion - convert to current quaternion and animate
|
|
86
|
+
const targetQuat = new Quaternion(target.orientation[0], target.orientation[1], target.orientation[2], target.orientation[3]);
|
|
87
|
+
const currentQuat = cam.quaternion.clone();
|
|
88
|
+
timeline.to({ t: 0 }, {
|
|
89
|
+
t: 1,
|
|
90
|
+
duration,
|
|
91
|
+
ease,
|
|
92
|
+
onUpdate: function () {
|
|
93
|
+
const t = this.targets()[0].t;
|
|
94
|
+
cam.quaternion.slerpQuaternions(currentQuat, targetQuat, t);
|
|
95
|
+
}
|
|
96
|
+
}, 0);
|
|
97
|
+
}
|
|
98
|
+
}
|
|
99
|
+
// Animate FOV
|
|
100
|
+
if (target.fov !== undefined) {
|
|
101
|
+
timeline.to(cam, {
|
|
102
|
+
fov: target.fov,
|
|
103
|
+
duration,
|
|
104
|
+
ease
|
|
105
|
+
}, 0);
|
|
106
|
+
}
|
|
107
|
+
// Animate clipping planes
|
|
108
|
+
if (target.near !== undefined) {
|
|
109
|
+
timeline.to(cam, {
|
|
110
|
+
near: target.near,
|
|
111
|
+
duration,
|
|
112
|
+
ease
|
|
113
|
+
}, 0);
|
|
114
|
+
}
|
|
115
|
+
if (target.far !== undefined) {
|
|
116
|
+
timeline.to(cam, {
|
|
117
|
+
far: target.far,
|
|
118
|
+
duration,
|
|
119
|
+
ease
|
|
120
|
+
}, 0);
|
|
121
|
+
}
|
|
122
|
+
// If lookAt target provided, animate the controls.target
|
|
123
|
+
// console.log("Animating camera with lookAtTarget:", lookAtTarget, orbitControls);
|
|
124
|
+
if (lookAtTarget && orbitControls) {
|
|
125
|
+
timeline.to(orbitControls.target, {
|
|
126
|
+
x: lookAtTarget[0],
|
|
127
|
+
y: lookAtTarget[1],
|
|
128
|
+
z: lookAtTarget[2],
|
|
129
|
+
duration,
|
|
130
|
+
ease
|
|
131
|
+
}, 0);
|
|
132
|
+
}
|
|
133
|
+
animationRef.current = timeline;
|
|
134
|
+
});
|
|
135
|
+
};
|
|
136
|
+
// Animate to position
|
|
137
|
+
const animateToPosition = (position, duration, ease) => {
|
|
138
|
+
return animateCamera({ position }, duration, ease);
|
|
139
|
+
};
|
|
140
|
+
const applyInterpolatedValue = (property, interpolatedValue, valueType) => {
|
|
141
|
+
switch (valueType) {
|
|
142
|
+
case 'vector3':
|
|
143
|
+
if (Array.isArray(interpolatedValue)) {
|
|
144
|
+
cameraRef.current[property].set(interpolatedValue[0], interpolatedValue[1], interpolatedValue[2]);
|
|
145
|
+
}
|
|
146
|
+
break;
|
|
147
|
+
case 'number':
|
|
148
|
+
cameraRef.current[property] = interpolatedValue;
|
|
149
|
+
break;
|
|
150
|
+
default:
|
|
151
|
+
break;
|
|
152
|
+
}
|
|
153
|
+
};
|
|
154
|
+
// Animate to orientation
|
|
155
|
+
const animateToOrientation = (orientation, duration, ease) => {
|
|
156
|
+
return animateCamera({ orientation }, duration, ease);
|
|
157
|
+
};
|
|
158
|
+
const animateHandlers = (pointer) => {
|
|
159
|
+
if (!handlers?.onMouseMove?.enabled || !handlers.onMouseMove.properties.length || !cameraRef.current) {
|
|
160
|
+
return;
|
|
161
|
+
}
|
|
162
|
+
handlers.onMouseMove.properties.forEach(props => {
|
|
163
|
+
const { property, propertySettings } = props;
|
|
164
|
+
const { min: minValue, max: maxValue, axis, sensitivity = 1, inverted = false } = propertySettings;
|
|
165
|
+
// Determine base value and property type
|
|
166
|
+
let baseValue = cameraState[property];
|
|
167
|
+
if (!baseValue)
|
|
168
|
+
return;
|
|
169
|
+
const interpolatedValue = interpolateProperty(baseValue, minValue, maxValue, pointer, axis, sensitivity, inverted);
|
|
170
|
+
const valueType = getType(property, interpolatedValue);
|
|
171
|
+
// Update cam directly
|
|
172
|
+
if (cameraRef.current[property] !== undefined) {
|
|
173
|
+
applyInterpolatedValue(property, interpolatedValue, valueType);
|
|
174
|
+
}
|
|
175
|
+
});
|
|
176
|
+
};
|
|
177
|
+
// Animate FOV
|
|
178
|
+
const animateToFov = (fov, duration, ease) => {
|
|
179
|
+
return animateCamera({ fov }, duration, ease);
|
|
180
|
+
};
|
|
181
|
+
// Look at target
|
|
182
|
+
const lookAt = (target, animated = autoAnimate, duration, ease) => {
|
|
183
|
+
const cam = cameraRef.current;
|
|
184
|
+
if (!cam)
|
|
185
|
+
return Promise.resolve();
|
|
186
|
+
if (!animated && target.length >= 3) {
|
|
187
|
+
cam.lookAt(target[0], target[1], target[2]);
|
|
188
|
+
return Promise.resolve();
|
|
189
|
+
}
|
|
190
|
+
// Calculate target rotation for animation
|
|
191
|
+
if (target.length < 3)
|
|
192
|
+
return Promise.resolve();
|
|
193
|
+
const tempCamera = cam.clone();
|
|
194
|
+
tempCamera.lookAt(target[0], target[1], target[2]);
|
|
195
|
+
const targetOrientation = [
|
|
196
|
+
tempCamera.rotation.x,
|
|
197
|
+
tempCamera.rotation.y,
|
|
198
|
+
tempCamera.rotation.z,
|
|
199
|
+
1
|
|
200
|
+
];
|
|
201
|
+
return animateToOrientation(targetOrientation, duration, ease);
|
|
202
|
+
};
|
|
203
|
+
// Orbit around target
|
|
204
|
+
const orbitAroundTarget = (target, radius, startAngle = 0, endAngle = Math.PI * 2, duration, ease) => {
|
|
205
|
+
const cam = cameraRef.current;
|
|
206
|
+
if (!cam)
|
|
207
|
+
return Promise.resolve();
|
|
208
|
+
killAnimation();
|
|
209
|
+
return new Promise((resolve) => {
|
|
210
|
+
const timeline = gsap.timeline({
|
|
211
|
+
onStart: () => {
|
|
212
|
+
isAnimatingRef.current = true;
|
|
213
|
+
onAnimationStart?.();
|
|
214
|
+
},
|
|
215
|
+
onComplete: () => {
|
|
216
|
+
isAnimatingRef.current = false;
|
|
217
|
+
animationRef.current = null;
|
|
218
|
+
onAnimationComplete?.();
|
|
219
|
+
resolve();
|
|
220
|
+
}
|
|
221
|
+
});
|
|
222
|
+
timeline.to({ angle: startAngle }, {
|
|
223
|
+
angle: endAngle,
|
|
224
|
+
duration: duration || defaultDuration,
|
|
225
|
+
ease: ease || defaultEase,
|
|
226
|
+
onUpdate: function () {
|
|
227
|
+
if (target.length < 3)
|
|
228
|
+
return;
|
|
229
|
+
const angle = this.targets()[0].angle;
|
|
230
|
+
const x = target[0] + Math.cos(angle) * radius;
|
|
231
|
+
const z = target[2] + Math.sin(angle) * radius;
|
|
232
|
+
cam.position.set(x, cam.position.y, z);
|
|
233
|
+
cam.lookAt(target[0], target[1], target[2]);
|
|
234
|
+
onAnimationUpdate?.();
|
|
235
|
+
}
|
|
236
|
+
});
|
|
237
|
+
animationRef.current = timeline;
|
|
238
|
+
});
|
|
239
|
+
};
|
|
240
|
+
// Check if camera is currently animating
|
|
241
|
+
const isAnimating = () => {
|
|
242
|
+
return isAnimatingRef.current;
|
|
243
|
+
};
|
|
244
|
+
// Cleanup on unmount
|
|
245
|
+
useEffect(() => {
|
|
246
|
+
return () => {
|
|
247
|
+
killAnimation();
|
|
248
|
+
};
|
|
249
|
+
}, []);
|
|
250
|
+
return {
|
|
251
|
+
// State
|
|
252
|
+
cameraState,
|
|
253
|
+
isAnimating,
|
|
254
|
+
animateHandlers,
|
|
255
|
+
// Animation methods
|
|
256
|
+
animateCamera,
|
|
257
|
+
animateToPosition,
|
|
258
|
+
animateToOrientation,
|
|
259
|
+
animateToFov,
|
|
260
|
+
lookAt,
|
|
261
|
+
orbitAroundTarget,
|
|
262
|
+
// Control methods
|
|
263
|
+
killAnimation,
|
|
264
|
+
// Camera reference
|
|
265
|
+
camera: cameraRef.current
|
|
266
|
+
};
|
|
267
|
+
};
|
|
268
|
+
export default useCameraAnimation;
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { Object3D } from "three";
|
|
2
|
+
import { type CreatedObjectSettings, type EffectState } from "@ntalmagor/3drize-core";
|
|
3
|
+
export declare const DEBUG_CONTINUOUS_EFFECTS = false;
|
|
4
|
+
export interface UseContinuousEffectsOptions {
|
|
5
|
+
enabled?: boolean;
|
|
6
|
+
animateMaterial?: boolean;
|
|
7
|
+
hovered?: boolean;
|
|
8
|
+
}
|
|
9
|
+
export interface UseContinuousEffectsResult {
|
|
10
|
+
isPathAnimating: () => boolean;
|
|
11
|
+
effectStateRef: React.MutableRefObject<EffectState | null>;
|
|
12
|
+
}
|
|
13
|
+
export declare const useContinuousEffects: (objectSettings: CreatedObjectSettings | null, options: UseContinuousEffectsOptions | undefined, object: Object3D) => UseContinuousEffectsResult;
|
|
14
|
+
export default useContinuousEffects;
|
|
15
|
+
//# sourceMappingURL=useContinuousEffects.d.ts.map
|