@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,190 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } 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
|
+
// ── Crystal spike shader ──────────────────────────────────────────────────────
|
|
7
|
+
const spikeVert = /* glsl */ `
|
|
8
|
+
varying vec3 vNormal;
|
|
9
|
+
varying vec3 vWorldPos;
|
|
10
|
+
void main() {
|
|
11
|
+
vNormal = normalize(normalMatrix * normal);
|
|
12
|
+
vWorldPos = (modelMatrix * vec4(position, 1.0)).xyz;
|
|
13
|
+
gl_Position = projectionMatrix * modelViewMatrix * vec4(position, 1.0);
|
|
14
|
+
}
|
|
15
|
+
`;
|
|
16
|
+
const spikeFrag = /* glsl */ `
|
|
17
|
+
uniform vec3 uIceColor;
|
|
18
|
+
uniform float uOpacity;
|
|
19
|
+
uniform float uIntensity;
|
|
20
|
+
varying vec3 vNormal;
|
|
21
|
+
varying vec3 vWorldPos;
|
|
22
|
+
|
|
23
|
+
void main() {
|
|
24
|
+
vec3 viewDir = normalize(cameraPosition - vWorldPos);
|
|
25
|
+
vec3 n = normalize(vNormal);
|
|
26
|
+
|
|
27
|
+
// Specular glint — sharp facet reflection
|
|
28
|
+
vec3 h = normalize(viewDir + vec3(0.6, 1.0, 0.4));
|
|
29
|
+
float spec = pow(max(dot(n, h), 0.0), 38.0) * 2.5;
|
|
30
|
+
|
|
31
|
+
// Fresnel edge glow
|
|
32
|
+
float fresnel = pow(1.0 - abs(dot(n, viewDir)), 2.0);
|
|
33
|
+
|
|
34
|
+
// Facet shading: vary brightness by normal orientation
|
|
35
|
+
float shade = 0.5 + 0.5 * abs(dot(n, normalize(vec3(1.0, 2.0, 0.5))));
|
|
36
|
+
|
|
37
|
+
vec3 col = uIceColor * shade + vec3(spec) + vec3(0.6, 0.9, 1.0) * fresnel * 0.5;
|
|
38
|
+
float alpha = (shade * 0.5 + fresnel * 0.35 + spec * 0.15) * uOpacity * uIntensity;
|
|
39
|
+
gl_FragColor = vec4(col, clamp(alpha, 0.0, 1.0));
|
|
40
|
+
}
|
|
41
|
+
`;
|
|
42
|
+
// ── Frost particle shader ─────────────────────────────────────────────────────
|
|
43
|
+
const frostVert = /* glsl */ `
|
|
44
|
+
attribute float aBaseY;
|
|
45
|
+
attribute float aSize;
|
|
46
|
+
attribute vec2 aXZ;
|
|
47
|
+
uniform float u_time;
|
|
48
|
+
uniform float uRange;
|
|
49
|
+
varying float vA;
|
|
50
|
+
void main() {
|
|
51
|
+
float y = mod(aBaseY - u_time * 0.35, uRange) - uRange * 0.5;
|
|
52
|
+
vec3 pos = vec3(aXZ.x, y, aXZ.y);
|
|
53
|
+
vA = 0.4 + 0.6 * smoothstep(-uRange * 0.5, -uRange * 0.3, y)
|
|
54
|
+
* smoothstep(uRange * 0.5, uRange * 0.3, y);
|
|
55
|
+
vec4 mv = modelViewMatrix * vec4(pos, 1.0);
|
|
56
|
+
gl_PointSize = aSize * (180.0 / -mv.z);
|
|
57
|
+
gl_Position = projectionMatrix * mv;
|
|
58
|
+
}
|
|
59
|
+
`;
|
|
60
|
+
const frostFrag = /* glsl */ `
|
|
61
|
+
uniform float uOpacity;
|
|
62
|
+
varying float vA;
|
|
63
|
+
void main() {
|
|
64
|
+
vec2 c = gl_PointCoord - 0.5;
|
|
65
|
+
if (length(c) > 0.5) discard;
|
|
66
|
+
float g = exp(-dot(c, c) * 6.0);
|
|
67
|
+
gl_FragColor = vec4(0.85, 0.95, 1.0, g * vA * uOpacity);
|
|
68
|
+
}
|
|
69
|
+
`;
|
|
70
|
+
const IceCrystalsEffect = ({ boundingRadius, config, animations }) => {
|
|
71
|
+
const { spikeCount, spikeLength, frostEnabled, iceColor, pulseSpeed, opacity, intensity } = config;
|
|
72
|
+
const startValuesCacheRef = useRef({});
|
|
73
|
+
const groupRef = useRef(null);
|
|
74
|
+
const timeRef = useRef(0);
|
|
75
|
+
const r = boundingRadius;
|
|
76
|
+
const N = Math.max(10, Math.min(spikeCount, 60));
|
|
77
|
+
const { spikeMesh, spikeMat, frostGeo, frostMat } = useMemo(() => {
|
|
78
|
+
const ic = new THREE.Color(iceColor);
|
|
79
|
+
// ── Spike instanced mesh ─────────────────────────────────────────────
|
|
80
|
+
const spikeLen = r * spikeLength * 0.55;
|
|
81
|
+
const spikeBase = r * 0.055 * intensity;
|
|
82
|
+
const spikeGeo = new THREE.ConeGeometry(spikeBase, spikeLen, 5);
|
|
83
|
+
// Shift cone so its base is at origin (tip points up in local space)
|
|
84
|
+
spikeGeo.translate(0, spikeLen / 2, 0);
|
|
85
|
+
const sMat = new THREE.ShaderMaterial({
|
|
86
|
+
vertexShader: spikeVert,
|
|
87
|
+
fragmentShader: spikeFrag,
|
|
88
|
+
uniforms: {
|
|
89
|
+
uIceColor: { value: new THREE.Vector3(ic.r, ic.g, ic.b) },
|
|
90
|
+
uOpacity: { value: opacity },
|
|
91
|
+
uIntensity: { value: intensity },
|
|
92
|
+
},
|
|
93
|
+
transparent: true,
|
|
94
|
+
depthWrite: false,
|
|
95
|
+
blending: THREE.AdditiveBlending,
|
|
96
|
+
side: THREE.DoubleSide,
|
|
97
|
+
});
|
|
98
|
+
const mesh = new THREE.InstancedMesh(spikeGeo, sMat, N);
|
|
99
|
+
mesh.instanceMatrix.setUsage(THREE.DynamicDrawUsage);
|
|
100
|
+
// Position spikes on Fibonacci sphere, pointing radially outward
|
|
101
|
+
const tmpPos = new THREE.Vector3();
|
|
102
|
+
const tmpQuat = new THREE.Quaternion();
|
|
103
|
+
const tmpMat = new THREE.Matrix4();
|
|
104
|
+
const UP = new THREE.Vector3(0, 1, 0);
|
|
105
|
+
const goldenAngle = Math.PI * (3 - Math.sqrt(5));
|
|
106
|
+
for (let i = 0; i < N; i++) {
|
|
107
|
+
const y = 1 - (i / (N - 1)) * 2;
|
|
108
|
+
const rad = Math.sqrt(1 - y * y) * r;
|
|
109
|
+
const phi = i * goldenAngle;
|
|
110
|
+
tmpPos.set(Math.cos(phi) * rad, y * r, Math.sin(phi) * rad);
|
|
111
|
+
// Quaternion: rotate Y-up to radial direction
|
|
112
|
+
const dir = tmpPos.clone().normalize();
|
|
113
|
+
tmpQuat.setFromUnitVectors(UP, dir);
|
|
114
|
+
// Scale Y randomly for variety
|
|
115
|
+
const scaleY = 0.6 + Math.random() * 0.8;
|
|
116
|
+
tmpMat.compose(tmpPos, tmpQuat, new THREE.Vector3(1, scaleY, 1));
|
|
117
|
+
mesh.setMatrixAt(i, tmpMat);
|
|
118
|
+
}
|
|
119
|
+
mesh.instanceMatrix.needsUpdate = true;
|
|
120
|
+
// ── Frost particles ──────────────────────────────────────────────────
|
|
121
|
+
const FN = 180;
|
|
122
|
+
const range = r * 2.5;
|
|
123
|
+
const fBaseY = new Float32Array(FN);
|
|
124
|
+
const fSize = new Float32Array(FN);
|
|
125
|
+
const fXZ = new Float32Array(FN * 2);
|
|
126
|
+
for (let i = 0; i < FN; i++) {
|
|
127
|
+
fBaseY[i] = Math.random() * range;
|
|
128
|
+
fSize[i] = 1.5 + Math.random() * 3.0;
|
|
129
|
+
const a = Math.random() * Math.PI * 2;
|
|
130
|
+
const fr = (0.9 + Math.random() * 0.8) * r;
|
|
131
|
+
fXZ[i * 2] = Math.cos(a) * fr;
|
|
132
|
+
fXZ[i * 2 + 1] = Math.sin(a) * fr;
|
|
133
|
+
}
|
|
134
|
+
const fGeo = new THREE.BufferGeometry();
|
|
135
|
+
fGeo.setAttribute('position', new THREE.BufferAttribute(new Float32Array(FN * 3), 3));
|
|
136
|
+
fGeo.setAttribute('aBaseY', new THREE.BufferAttribute(fBaseY, 1));
|
|
137
|
+
fGeo.setAttribute('aSize', new THREE.BufferAttribute(fSize, 1));
|
|
138
|
+
fGeo.setAttribute('aXZ', new THREE.BufferAttribute(fXZ, 2));
|
|
139
|
+
fGeo.frustumCulled = false;
|
|
140
|
+
const fMat = new THREE.ShaderMaterial({
|
|
141
|
+
vertexShader: frostVert,
|
|
142
|
+
fragmentShader: frostFrag,
|
|
143
|
+
uniforms: {
|
|
144
|
+
u_time: { value: 0 },
|
|
145
|
+
uRange: { value: range },
|
|
146
|
+
uOpacity: { value: opacity * 0.55 },
|
|
147
|
+
},
|
|
148
|
+
transparent: true, depthWrite: false, blending: THREE.AdditiveBlending,
|
|
149
|
+
});
|
|
150
|
+
return { spikeMesh: mesh, spikeMat: sMat, frostGeo: fGeo, frostMat: fMat };
|
|
151
|
+
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
152
|
+
}, [N, r, spikeLength, iceColor, opacity, intensity]);
|
|
153
|
+
// Pulse scale animation on spikes
|
|
154
|
+
const pulseMats = useRef([]);
|
|
155
|
+
useMemo(() => {
|
|
156
|
+
const tmpMat = new THREE.Matrix4();
|
|
157
|
+
const tmpPos = new THREE.Vector3();
|
|
158
|
+
const tmpQuat = new THREE.Quaternion();
|
|
159
|
+
const tmpScale = new THREE.Vector3();
|
|
160
|
+
pulseMats.current = Array.from({ length: N }, (_, i) => {
|
|
161
|
+
spikeMesh.getMatrixAt(i, tmpMat);
|
|
162
|
+
return tmpMat.clone();
|
|
163
|
+
});
|
|
164
|
+
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
165
|
+
}, [spikeMesh, N]);
|
|
166
|
+
useFrame((state, delta) => {
|
|
167
|
+
timeRef.current += delta;
|
|
168
|
+
const t = timeRef.current;
|
|
169
|
+
frostMat.uniforms.u_time.value = t;
|
|
170
|
+
// Subtle spike pulse: scale Y slightly up/down per spike
|
|
171
|
+
const tmpMat = new THREE.Matrix4();
|
|
172
|
+
const tmpPos = new THREE.Vector3();
|
|
173
|
+
const tmpQuat = new THREE.Quaternion();
|
|
174
|
+
const tmpScale = new THREE.Vector3();
|
|
175
|
+
for (let i = 0; i < N; i++) {
|
|
176
|
+
const base = pulseMats.current[i];
|
|
177
|
+
base.decompose(tmpPos, tmpQuat, tmpScale);
|
|
178
|
+
const pulse = 0.88 + 0.12 * Math.sin(t * pulseSpeed * 1.8 + i * 0.47);
|
|
179
|
+
tmpScale.y = pulse;
|
|
180
|
+
tmpMat.compose(tmpPos, tmpQuat, tmpScale);
|
|
181
|
+
spikeMesh.setMatrixAt(i, tmpMat);
|
|
182
|
+
}
|
|
183
|
+
spikeMesh.instanceMatrix.needsUpdate = true;
|
|
184
|
+
if (animations?.length) {
|
|
185
|
+
applyGenerativeAnimations([spikeMat, frostMat], animations, startValuesCacheRef.current, Date.now(), false);
|
|
186
|
+
}
|
|
187
|
+
});
|
|
188
|
+
return (_jsxs("group", { ref: groupRef, children: [_jsx("primitive", { object: spikeMesh }), frostEnabled && _jsx("points", { geometry: frostGeo, material: frostMat })] }));
|
|
189
|
+
};
|
|
190
|
+
export default IceCrystalsEffect;
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import type { LightningConfig, AnimationOptions } from '@ntalmagor/3drize-core';
|
|
3
|
+
interface LightningEffectProps {
|
|
4
|
+
boundingRadius: number;
|
|
5
|
+
config: LightningConfig;
|
|
6
|
+
animations?: AnimationOptions[];
|
|
7
|
+
}
|
|
8
|
+
declare const LightningEffect: React.FC<LightningEffectProps>;
|
|
9
|
+
export default LightningEffect;
|
|
10
|
+
//# sourceMappingURL=LightningEffect.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"LightningEffect.d.ts","sourceRoot":"","sources":["../../../src/components/effects/LightningEffect.tsx"],"names":[],"mappings":"AAAA,OAAO,KAA0B,MAAM,OAAO,CAAC;AAG/C,OAAO,KAAK,EAAE,eAAe,EAAE,gBAAgB,EAAE,MAAM,wBAAwB,CAAC;AAIhF,UAAU,oBAAoB;IAC5B,cAAc,EAAE,MAAM,CAAC;IACvB,MAAM,EAAE,eAAe,CAAC;IACxB,UAAU,CAAC,EAAE,gBAAgB,EAAE,CAAC;CACjC;AAgFD,QAAA,MAAM,eAAe,EAAE,KAAK,CAAC,EAAE,CAAC,oBAAoB,CAgOnD,CAAC;AAEF,eAAe,eAAe,CAAC"}
|
|
@@ -0,0 +1,240 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } 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
|
+
// ── Seeded LCG RNG — deterministic, no Math.random ───────────────────────────
|
|
7
|
+
function makeRng(seed) {
|
|
8
|
+
let s = (seed * 1664525 + 1013904223) >>> 0;
|
|
9
|
+
return () => { s = (s * 1664525 + 1013904223) >>> 0; return s / 0xffffffff; };
|
|
10
|
+
}
|
|
11
|
+
// ── Fractal midpoint displacement → ordered polyline ─────────────────────────
|
|
12
|
+
// Returns 2^depth + 1 points
|
|
13
|
+
function fractalPolyline(start, end, depth, rng) {
|
|
14
|
+
if (depth === 0)
|
|
15
|
+
return [start.clone(), end.clone()];
|
|
16
|
+
const mid = start.clone().lerp(end, 0.42 + rng() * 0.16);
|
|
17
|
+
const dir = end.clone().sub(start);
|
|
18
|
+
const len = dir.length();
|
|
19
|
+
dir.normalize();
|
|
20
|
+
let perp1 = new THREE.Vector3(dir.z, 0, -dir.x);
|
|
21
|
+
if (perp1.lengthSq() < 0.001)
|
|
22
|
+
perp1.set(0, dir.z, -dir.y);
|
|
23
|
+
perp1.normalize();
|
|
24
|
+
const perp2 = dir.clone().cross(perp1).normalize();
|
|
25
|
+
const spread = len * 0.38;
|
|
26
|
+
mid.addScaledVector(perp1, (rng() - 0.5) * 2 * spread);
|
|
27
|
+
mid.addScaledVector(perp2, (rng() - 0.5) * spread * 0.7);
|
|
28
|
+
const a = fractalPolyline(start, mid, depth - 1, rng);
|
|
29
|
+
const b = fractalPolyline(mid, end, depth - 1, rng);
|
|
30
|
+
return [...a.slice(0, -1), ...b]; // merge without duplicating midpoint
|
|
31
|
+
}
|
|
32
|
+
// ── Glow sprite shader ─────────────────────────────────────────────────────────
|
|
33
|
+
const glowVert = /* glsl */ `
|
|
34
|
+
attribute float aBrightness;
|
|
35
|
+
uniform float uPointSize;
|
|
36
|
+
varying float vB;
|
|
37
|
+
void main() {
|
|
38
|
+
vB = aBrightness;
|
|
39
|
+
vec4 mv = modelViewMatrix * vec4(position, 1.0);
|
|
40
|
+
gl_PointSize = uPointSize * aBrightness * (200.0 / -mv.z);
|
|
41
|
+
gl_Position = projectionMatrix * mv;
|
|
42
|
+
}
|
|
43
|
+
`;
|
|
44
|
+
const glowFrag = /* glsl */ `
|
|
45
|
+
uniform vec3 uColor;
|
|
46
|
+
uniform float uOpacity;
|
|
47
|
+
varying float vB;
|
|
48
|
+
void main() {
|
|
49
|
+
if (vB < 0.01) discard;
|
|
50
|
+
vec2 c = gl_PointCoord - 0.5;
|
|
51
|
+
if (length(c) > 0.5) discard;
|
|
52
|
+
float g = exp(-dot(c, c) * 5.5);
|
|
53
|
+
gl_FragColor = vec4(uColor, g * vB * uOpacity);
|
|
54
|
+
}
|
|
55
|
+
`;
|
|
56
|
+
const FADE_DUR = 0.22;
|
|
57
|
+
const LightningEffect = ({ boundingRadius, config, animations }) => {
|
|
58
|
+
const { boltCount, branchDepth, color, glowColor, opacity, speed, intensity, strikeRadius } = config;
|
|
59
|
+
const startValuesCacheRef = useRef({});
|
|
60
|
+
const depth = Math.min(Math.max(branchDepth, 2), 6);
|
|
61
|
+
const N = Math.pow(2, depth) + 1; // vertex count: 5, 9, 17, 33, 65
|
|
62
|
+
const coreCol = useMemo(() => new THREE.Color(color), [color]);
|
|
63
|
+
const glowCol = useMemo(() => new THREE.Color(glowColor), [glowColor]);
|
|
64
|
+
const glowVec = useMemo(() => new THREE.Vector3(glowCol.r, glowCol.g, glowCol.b), [glowCol]);
|
|
65
|
+
const sr = boundingRadius * strikeRadius;
|
|
66
|
+
// ── Compute origin/target for a bolt from a seed ───────────────────────────
|
|
67
|
+
function boltEndpoints(rng) {
|
|
68
|
+
const theta = rng() * Math.PI * 2;
|
|
69
|
+
const elev = 0.3 + rng() * 0.4; // horizontal spread of origin
|
|
70
|
+
return [
|
|
71
|
+
new THREE.Vector3(Math.cos(theta) * sr * elev, sr * (0.8 + rng() * 0.4), Math.sin(theta) * sr * elev),
|
|
72
|
+
new THREE.Vector3((rng() - 0.5) * boundingRadius * 0.4, (rng() - 0.5) * boundingRadius * 0.3, (rng() - 0.5) * boundingRadius * 0.4),
|
|
73
|
+
];
|
|
74
|
+
}
|
|
75
|
+
// ── Build line+point geometry from a point list ────────────────────────────
|
|
76
|
+
function makeGeos(pts, colBuf, brightBuf) {
|
|
77
|
+
const posArr = new Float32Array(N * 3);
|
|
78
|
+
for (let i = 0; i < pts.length && i < N; i++) {
|
|
79
|
+
posArr[i * 3] = pts[i].x;
|
|
80
|
+
posArr[i * 3 + 1] = pts[i].y;
|
|
81
|
+
posArr[i * 3 + 2] = pts[i].z;
|
|
82
|
+
}
|
|
83
|
+
const lineGeo = new THREE.BufferGeometry();
|
|
84
|
+
lineGeo.setAttribute('position', new THREE.BufferAttribute(posArr.slice(), 3));
|
|
85
|
+
lineGeo.setAttribute('color', new THREE.BufferAttribute(colBuf, 3));
|
|
86
|
+
const pointGeo = new THREE.BufferGeometry();
|
|
87
|
+
pointGeo.setAttribute('position', new THREE.BufferAttribute(posArr.slice(), 3));
|
|
88
|
+
pointGeo.setAttribute('aBrightness', new THREE.BufferAttribute(brightBuf, 1));
|
|
89
|
+
return { lineGeo, pointGeo };
|
|
90
|
+
}
|
|
91
|
+
// ── Initialise bolts ───────────────────────────────────────────────────────
|
|
92
|
+
const bolts = useMemo(() => {
|
|
93
|
+
return Array.from({ length: boltCount }, (_, bi) => {
|
|
94
|
+
const seed = bi * 997 + 1;
|
|
95
|
+
const rng = makeRng(seed);
|
|
96
|
+
const [o, t] = boltEndpoints(rng);
|
|
97
|
+
const pts = fractalPolyline(o, t, depth, rng);
|
|
98
|
+
const col = new Float32Array(N * 3);
|
|
99
|
+
const bri = new Float32Array(N);
|
|
100
|
+
const { lineGeo, pointGeo } = makeGeos(pts, col, bri);
|
|
101
|
+
return {
|
|
102
|
+
phase: 'wait', timer: (bi / boltCount) * 1.8,
|
|
103
|
+
progress: 0, seed, waitDur: 0.5 + rng() * 1.0,
|
|
104
|
+
points: pts, colBuf: col, brightBuf: bri, lineGeo, pointGeo,
|
|
105
|
+
};
|
|
106
|
+
});
|
|
107
|
+
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
108
|
+
}, [boltCount, depth, N]);
|
|
109
|
+
// ── Shared materials ───────────────────────────────────────────────────────
|
|
110
|
+
const lineMat = useMemo(() => new THREE.LineBasicMaterial({
|
|
111
|
+
vertexColors: true,
|
|
112
|
+
transparent: true,
|
|
113
|
+
depthWrite: false,
|
|
114
|
+
blending: THREE.AdditiveBlending,
|
|
115
|
+
}), []);
|
|
116
|
+
const glowMats = useMemo(() => bolts.map(() => new THREE.ShaderMaterial({
|
|
117
|
+
vertexShader: glowVert,
|
|
118
|
+
fragmentShader: glowFrag,
|
|
119
|
+
uniforms: {
|
|
120
|
+
uPointSize: { value: 6 * intensity },
|
|
121
|
+
uColor: { value: glowVec },
|
|
122
|
+
uOpacity: { value: opacity * 0.12 },
|
|
123
|
+
},
|
|
124
|
+
transparent: true,
|
|
125
|
+
depthWrite: false,
|
|
126
|
+
blending: THREE.AdditiveBlending,
|
|
127
|
+
})),
|
|
128
|
+
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
129
|
+
[bolts, intensity, glowVec, opacity]);
|
|
130
|
+
// ── Recompute vertex colors from current progress ──────────────────────────
|
|
131
|
+
function refreshColors(bolt, overallScale) {
|
|
132
|
+
const { progress, points, colBuf, brightBuf, lineGeo, pointGeo } = bolt;
|
|
133
|
+
const n = points.length;
|
|
134
|
+
for (let i = 0; i < n; i++) {
|
|
135
|
+
const t = i / (n - 1);
|
|
136
|
+
if (t > progress + 0.001) {
|
|
137
|
+
// Not yet reached — keep black (invisible with additive blend)
|
|
138
|
+
colBuf[i * 3] = colBuf[i * 3 + 1] = colBuf[i * 3 + 2] = 0;
|
|
139
|
+
brightBuf[i] = 0;
|
|
140
|
+
continue;
|
|
141
|
+
}
|
|
142
|
+
const behind = progress - t; // 0 = at head
|
|
143
|
+
// Exponential trail: bright near head, fades behind
|
|
144
|
+
const trail = Math.exp(-behind * 7.0);
|
|
145
|
+
// Build-up: whole bolt intensifies as progress moves from 0→1
|
|
146
|
+
const buildUp = 0.3 + 0.7 * progress;
|
|
147
|
+
// Extra corona right at the head
|
|
148
|
+
const corona = Math.exp(-behind * behind * 220) * 3.0;
|
|
149
|
+
const totalBri = (trail * buildUp + corona) * intensity * overallScale;
|
|
150
|
+
// Color: glow color in body → core (white-ish) at head corona
|
|
151
|
+
const headMix = Math.min(1, corona * 0.5);
|
|
152
|
+
colBuf[i * 3] = (glowCol.r + (coreCol.r - glowCol.r) * headMix) * totalBri;
|
|
153
|
+
colBuf[i * 3 + 1] = (glowCol.g + (coreCol.g - glowCol.g) * headMix) * totalBri;
|
|
154
|
+
colBuf[i * 3 + 2] = (glowCol.b + (coreCol.b - glowCol.b) * headMix) * totalBri;
|
|
155
|
+
brightBuf[i] = Math.min(1, (trail * buildUp * 0.5 + corona * 0.3) * overallScale);
|
|
156
|
+
}
|
|
157
|
+
lineGeo.attributes.color.needsUpdate = true;
|
|
158
|
+
pointGeo.attributes.aBrightness.needsUpdate = true;
|
|
159
|
+
}
|
|
160
|
+
// ── Rebuild bolt shape with fresh fractal ─────────────────────────────────
|
|
161
|
+
function rebuildShape(bolt) {
|
|
162
|
+
bolt.seed++;
|
|
163
|
+
const rng = makeRng(bolt.seed);
|
|
164
|
+
const [o, t] = boltEndpoints(rng);
|
|
165
|
+
bolt.points = fractalPolyline(o, t, depth, rng);
|
|
166
|
+
bolt.waitDur = 0.3 + rng() * 1.3;
|
|
167
|
+
bolt.progress = 0;
|
|
168
|
+
const pts = bolt.points;
|
|
169
|
+
const posL = bolt.lineGeo.attributes.position;
|
|
170
|
+
const posP = bolt.pointGeo.attributes.position;
|
|
171
|
+
for (let i = 0; i < pts.length && i < N; i++) {
|
|
172
|
+
posL.setXYZ(i, pts[i].x, pts[i].y, pts[i].z);
|
|
173
|
+
posP.setXYZ(i, pts[i].x, pts[i].y, pts[i].z);
|
|
174
|
+
}
|
|
175
|
+
posL.needsUpdate = true;
|
|
176
|
+
posP.needsUpdate = true;
|
|
177
|
+
}
|
|
178
|
+
useFrame((_, delta) => {
|
|
179
|
+
const dt = delta * speed;
|
|
180
|
+
bolts.forEach((bolt, bi) => {
|
|
181
|
+
switch (bolt.phase) {
|
|
182
|
+
case 'wait':
|
|
183
|
+
bolt.timer -= delta;
|
|
184
|
+
// Keep all colors black during wait
|
|
185
|
+
bolt.colBuf.fill(0);
|
|
186
|
+
bolt.brightBuf.fill(0);
|
|
187
|
+
bolt.lineGeo.attributes.color.needsUpdate = true;
|
|
188
|
+
bolt.pointGeo.attributes.aBrightness.needsUpdate = true;
|
|
189
|
+
if (bolt.timer <= 0) {
|
|
190
|
+
rebuildShape(bolt);
|
|
191
|
+
bolt.phase = 'travel';
|
|
192
|
+
}
|
|
193
|
+
break;
|
|
194
|
+
case 'travel':
|
|
195
|
+
bolt.progress += dt * 8.0;
|
|
196
|
+
if (bolt.progress >= 1) {
|
|
197
|
+
bolt.progress = 1;
|
|
198
|
+
bolt.phase = 'flash';
|
|
199
|
+
bolt.timer = 0.06 + Math.random() * 0.05;
|
|
200
|
+
}
|
|
201
|
+
refreshColors(bolt, 1.0);
|
|
202
|
+
break;
|
|
203
|
+
case 'flash': {
|
|
204
|
+
bolt.timer -= delta;
|
|
205
|
+
// Flash: briefly crank overall brightness to 2–3x for the "return stroke"
|
|
206
|
+
const flashBoost = 1.0 + Math.max(0, bolt.timer / 0.08) * 2.5;
|
|
207
|
+
refreshColors(bolt, flashBoost);
|
|
208
|
+
if (bolt.timer <= 0) {
|
|
209
|
+
bolt.phase = 'fade';
|
|
210
|
+
bolt.timer = FADE_DUR;
|
|
211
|
+
}
|
|
212
|
+
break;
|
|
213
|
+
}
|
|
214
|
+
case 'fade': {
|
|
215
|
+
bolt.timer -= delta;
|
|
216
|
+
const ratio = Math.max(0, bolt.timer / FADE_DUR);
|
|
217
|
+
// Recompute full-progress colors then scale uniformly to fade out
|
|
218
|
+
refreshColors(bolt, ratio);
|
|
219
|
+
glowMats[bi].uniforms.uOpacity.value = opacity * 0.12 * ratio;
|
|
220
|
+
if (bolt.timer <= 0) {
|
|
221
|
+
bolt.phase = 'wait';
|
|
222
|
+
bolt.timer = bolt.waitDur;
|
|
223
|
+
glowMats[bi].uniforms.uOpacity.value = opacity * 0.12;
|
|
224
|
+
}
|
|
225
|
+
break;
|
|
226
|
+
}
|
|
227
|
+
}
|
|
228
|
+
});
|
|
229
|
+
if (animations?.length) {
|
|
230
|
+
applyGenerativeAnimations(glowMats, animations, startValuesCacheRef.current, Date.now(), false);
|
|
231
|
+
}
|
|
232
|
+
});
|
|
233
|
+
// ── Render ─────────────────────────────────────────────────────────────────
|
|
234
|
+
// Use primitive to render THREE.Line (not THREE.LineSegments)
|
|
235
|
+
const lineObjects = useMemo(() => bolts.map(bolt => new THREE.Line(bolt.lineGeo, lineMat)),
|
|
236
|
+
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
237
|
+
[bolts, lineMat]);
|
|
238
|
+
return (_jsx("group", { children: lineObjects.map((lineObj, bi) => (_jsxs("group", { children: [_jsx("primitive", { object: lineObj }), _jsx("points", { geometry: bolts[bi].pointGeo, material: glowMats[bi] })] }, bi))) }));
|
|
239
|
+
};
|
|
240
|
+
export default LightningEffect;
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import type { MoleculesConfig, AnimationOptions } from '@ntalmagor/3drize-core';
|
|
3
|
+
interface MoleculesEffectProps {
|
|
4
|
+
boundingRadius: number;
|
|
5
|
+
config: MoleculesConfig;
|
|
6
|
+
animations?: AnimationOptions[];
|
|
7
|
+
}
|
|
8
|
+
declare const MoleculesEffect: React.FC<MoleculesEffectProps>;
|
|
9
|
+
export default MoleculesEffect;
|
|
10
|
+
//# sourceMappingURL=MoleculesEffect.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"MoleculesEffect.d.ts","sourceRoot":"","sources":["../../../src/components/effects/MoleculesEffect.tsx"],"names":[],"mappings":"AAAA,OAAO,KAA0B,MAAM,OAAO,CAAC;AAG/C,OAAO,KAAK,EAAE,eAAe,EAAE,gBAAgB,EAAE,MAAM,wBAAwB,CAAC;AAIhF,UAAU,oBAAoB;IAC5B,cAAc,EAAE,MAAM,CAAC;IACvB,MAAM,EAAE,eAAe,CAAC;IACxB,UAAU,CAAC,EAAE,gBAAgB,EAAE,CAAC;CACjC;AAwDD,QAAA,MAAM,eAAe,EAAE,KAAK,CAAC,EAAE,CAAC,oBAAoB,CA0JnD,CAAC;AAEF,eAAe,eAAe,CAAC"}
|
|
@@ -0,0 +1,179 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } 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
|
+
// Glowing node points at each atom position
|
|
7
|
+
const nodeVertShader = /* glsl */ `
|
|
8
|
+
attribute float aPhase;
|
|
9
|
+
attribute float aSize;
|
|
10
|
+
|
|
11
|
+
uniform float u_time;
|
|
12
|
+
uniform float uPointSize;
|
|
13
|
+
uniform float uIntensity;
|
|
14
|
+
|
|
15
|
+
varying float vAlpha;
|
|
16
|
+
varying vec3 vColor;
|
|
17
|
+
|
|
18
|
+
vec3 hsv2rgb(float h, float s, float v){
|
|
19
|
+
vec3 rgb=clamp(abs(mod(h*6.+vec3(0.,4.,2.),6.)-3.)-1.,0.,1.);
|
|
20
|
+
return v*mix(vec3(1.),rgb,s);
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
void main() {
|
|
24
|
+
// Each node has independent color + pulse
|
|
25
|
+
float hue = mod(aPhase + u_time * 0.08, 1.0);
|
|
26
|
+
float pulse = 0.5 + 0.5 * sin(u_time * 2.5 + aPhase * 6.28);
|
|
27
|
+
vColor = hsv2rgb(hue, 0.85, 1.0);
|
|
28
|
+
vAlpha = 0.55 + 0.45 * pulse;
|
|
29
|
+
|
|
30
|
+
vec4 mv = modelViewMatrix * vec4(position, 1.0);
|
|
31
|
+
gl_PointSize = uPointSize * aSize * (0.6 + 0.4 * pulse) * uIntensity * (250.0 / -mv.z);
|
|
32
|
+
gl_Position = projectionMatrix * mv;
|
|
33
|
+
}
|
|
34
|
+
`;
|
|
35
|
+
const nodeFragShader = /* glsl */ `
|
|
36
|
+
varying float vAlpha;
|
|
37
|
+
varying vec3 vColor;
|
|
38
|
+
uniform float uOpacity;
|
|
39
|
+
|
|
40
|
+
void main() {
|
|
41
|
+
vec2 coord = gl_PointCoord - vec2(0.5);
|
|
42
|
+
float dist = length(coord);
|
|
43
|
+
if (dist > 0.5) discard;
|
|
44
|
+
|
|
45
|
+
// Gaussian core glow
|
|
46
|
+
float glow = exp(-dist * dist * 8.0);
|
|
47
|
+
// Four-point diffraction spike (like a bright star)
|
|
48
|
+
float cx = exp(-abs(coord.x) * 20.0) * exp(-coord.y*coord.y * 36.0);
|
|
49
|
+
float cy = exp(-abs(coord.y) * 20.0) * exp(-coord.x*coord.x * 36.0);
|
|
50
|
+
float spike = (cx + cy) * 0.5;
|
|
51
|
+
// White-hot centre
|
|
52
|
+
float core = exp(-dist * dist * 80.0);
|
|
53
|
+
|
|
54
|
+
vec3 col = mix(vColor, vec3(1.0), core * 0.8 + spike * 0.2);
|
|
55
|
+
gl_FragColor = vec4(col, vAlpha * uOpacity * (glow + spike * 0.6 + core));
|
|
56
|
+
}
|
|
57
|
+
`;
|
|
58
|
+
const MoleculesEffect = ({ boundingRadius, config, animations }) => {
|
|
59
|
+
const { atomCount, orbitRadius, atomSize, showBonds, opacity, speed, intensity } = config;
|
|
60
|
+
const startValuesCacheRef = useRef({});
|
|
61
|
+
const tRef = useRef(new Float32Array(atomCount));
|
|
62
|
+
const r = boundingRadius * orbitRadius;
|
|
63
|
+
const PHI = 1.6180339887;
|
|
64
|
+
// 3D Lissajous frequency ratios per atom
|
|
65
|
+
const orbitalParams = useMemo(() => {
|
|
66
|
+
const pairs = [
|
|
67
|
+
[1, 2, 3], [2, 3, 1], [3, 1, 2], [1, 3, 2], [2, 1, 3], [3, 2, 1],
|
|
68
|
+
[1, 1, 2], [2, 2, 1], [1, 2, 2], [2, 1, 1], [3, 3, 2], [2, 3, 3],
|
|
69
|
+
];
|
|
70
|
+
return Array.from({ length: atomCount }, (_, i) => {
|
|
71
|
+
const [fx, fy, fz] = pairs[i % pairs.length];
|
|
72
|
+
return {
|
|
73
|
+
fx, fy, fz,
|
|
74
|
+
px: (i * PHI * Math.PI) % (Math.PI * 2),
|
|
75
|
+
py: (i * PHI * PHI * Math.PI) % (Math.PI * 2),
|
|
76
|
+
pz: (i * PHI ** 3 * Math.PI) % (Math.PI * 2),
|
|
77
|
+
hueBase: i / Math.max(atomCount - 1, 1),
|
|
78
|
+
speedMult: 0.65 + (i % 7) * 0.07,
|
|
79
|
+
};
|
|
80
|
+
});
|
|
81
|
+
}, [atomCount]);
|
|
82
|
+
// Resize tRef and spread initial times so atoms don't cluster at cycle start
|
|
83
|
+
useMemo(() => {
|
|
84
|
+
tRef.current = new Float32Array(atomCount);
|
|
85
|
+
for (let i = 0; i < atomCount; i++)
|
|
86
|
+
tRef.current[i] = (i / atomCount) * Math.PI * 2;
|
|
87
|
+
}, [atomCount]);
|
|
88
|
+
// ── Node (point) geometry ──────────────────────────────────────────────────
|
|
89
|
+
const { nodeGeo, nodeMat } = useMemo(() => {
|
|
90
|
+
const phases = new Float32Array(atomCount);
|
|
91
|
+
const sizes = new Float32Array(atomCount);
|
|
92
|
+
for (let i = 0; i < atomCount; i++) {
|
|
93
|
+
phases[i] = i / atomCount; // 0..1 → hue spread
|
|
94
|
+
sizes[i] = 0.8 + Math.random() * 0.6; // slight size variation
|
|
95
|
+
}
|
|
96
|
+
const geo = new THREE.BufferGeometry();
|
|
97
|
+
geo.setAttribute('position', new THREE.BufferAttribute(new Float32Array(atomCount * 3), 3));
|
|
98
|
+
geo.setAttribute('aPhase', new THREE.BufferAttribute(phases, 1));
|
|
99
|
+
geo.setAttribute('aSize', new THREE.BufferAttribute(sizes, 1));
|
|
100
|
+
const mat = new THREE.ShaderMaterial({
|
|
101
|
+
vertexShader: nodeVertShader,
|
|
102
|
+
fragmentShader: nodeFragShader,
|
|
103
|
+
uniforms: {
|
|
104
|
+
u_time: { value: 0 },
|
|
105
|
+
uPointSize: { value: atomSize * 200 },
|
|
106
|
+
uIntensity: { value: intensity },
|
|
107
|
+
uOpacity: { value: opacity },
|
|
108
|
+
},
|
|
109
|
+
transparent: true,
|
|
110
|
+
depthWrite: false,
|
|
111
|
+
blending: THREE.AdditiveBlending,
|
|
112
|
+
});
|
|
113
|
+
return { nodeGeo: geo, nodeMat: mat };
|
|
114
|
+
}, [atomCount, atomSize, intensity, opacity]);
|
|
115
|
+
// ── Bond (line) geometry with per-vertex color ─────────────────────────────
|
|
116
|
+
const { bondGeo, bondMat } = useMemo(() => {
|
|
117
|
+
const vertCount = atomCount * 2; // each bond = 2 verts
|
|
118
|
+
const geo = new THREE.BufferGeometry();
|
|
119
|
+
const positions = new Float32Array(vertCount * 3);
|
|
120
|
+
const colors = new Float32Array(vertCount * 3);
|
|
121
|
+
geo.setAttribute('position', new THREE.BufferAttribute(positions, 3));
|
|
122
|
+
geo.setAttribute('color', new THREE.BufferAttribute(colors, 3));
|
|
123
|
+
const mat = new THREE.LineBasicMaterial({
|
|
124
|
+
vertexColors: true,
|
|
125
|
+
transparent: true,
|
|
126
|
+
opacity: opacity * 0.7,
|
|
127
|
+
depthWrite: false,
|
|
128
|
+
blending: THREE.AdditiveBlending,
|
|
129
|
+
});
|
|
130
|
+
return { bondGeo: geo, bondMat: mat };
|
|
131
|
+
}, [atomCount, opacity]);
|
|
132
|
+
const atomPos = useRef([]);
|
|
133
|
+
useMemo(() => {
|
|
134
|
+
atomPos.current = Array.from({ length: atomCount }, () => new THREE.Vector3());
|
|
135
|
+
}, [atomCount]);
|
|
136
|
+
const tmpCol = useMemo(() => new THREE.Color(), []);
|
|
137
|
+
useFrame((state, delta) => {
|
|
138
|
+
const t = state.clock.getElapsedTime();
|
|
139
|
+
nodeMat.uniforms.u_time.value = t;
|
|
140
|
+
const nodePos = nodeGeo.attributes.position;
|
|
141
|
+
for (let i = 0; i < atomCount; i++) {
|
|
142
|
+
tRef.current[i] += delta * speed * orbitalParams[i].speedMult;
|
|
143
|
+
const a = tRef.current[i];
|
|
144
|
+
const p = orbitalParams[i];
|
|
145
|
+
// 3D Lissajous position
|
|
146
|
+
const x = Math.cos(p.fx * a + p.px) * r;
|
|
147
|
+
const y = Math.sin(p.fy * a + p.py) * r * 0.75;
|
|
148
|
+
const z = Math.sin(p.fz * a + p.pz) * r;
|
|
149
|
+
atomPos.current[i].set(x, y, z);
|
|
150
|
+
nodePos.setXYZ(i, x, y, z);
|
|
151
|
+
}
|
|
152
|
+
nodePos.needsUpdate = true;
|
|
153
|
+
// Update bond geometry + animated per-vertex color
|
|
154
|
+
if (showBonds) {
|
|
155
|
+
const bondPos = bondGeo.attributes.position;
|
|
156
|
+
const bondCol = bondGeo.attributes.color;
|
|
157
|
+
for (let i = 0; i < atomCount; i++) {
|
|
158
|
+
const curr = atomPos.current[i];
|
|
159
|
+
const next = atomPos.current[(i + 1) % atomCount];
|
|
160
|
+
bondPos.setXYZ(i * 2, curr.x, curr.y, curr.z);
|
|
161
|
+
bondPos.setXYZ(i * 2 + 1, next.x, next.y, next.z);
|
|
162
|
+
// Color: each vertex gets a hue based on its atom's phase + time
|
|
163
|
+
const hue0 = (orbitalParams[i].hueBase + t * 0.07) % 1;
|
|
164
|
+
const hue1 = (orbitalParams[(i + 1) % atomCount].hueBase + t * 0.07) % 1;
|
|
165
|
+
tmpCol.setHSL(hue0, 1.0, 0.6);
|
|
166
|
+
bondCol.setXYZ(i * 2, tmpCol.r, tmpCol.g, tmpCol.b);
|
|
167
|
+
tmpCol.setHSL(hue1, 1.0, 0.6);
|
|
168
|
+
bondCol.setXYZ(i * 2 + 1, tmpCol.r, tmpCol.g, tmpCol.b);
|
|
169
|
+
}
|
|
170
|
+
bondPos.needsUpdate = true;
|
|
171
|
+
bondCol.needsUpdate = true;
|
|
172
|
+
}
|
|
173
|
+
if (animations?.length) {
|
|
174
|
+
applyGenerativeAnimations([nodeMat, bondMat], animations, startValuesCacheRef.current, Date.now(), false);
|
|
175
|
+
}
|
|
176
|
+
});
|
|
177
|
+
return (_jsxs("group", { name: "MoleculesEffect", children: [_jsx("points", { geometry: nodeGeo, material: nodeMat }), showBonds && (_jsx("lineSegments", { geometry: bondGeo, material: bondMat }))] }));
|
|
178
|
+
};
|
|
179
|
+
export default MoleculesEffect;
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import type { NeuralNetworkConfig, AnimationOptions } from '@ntalmagor/3drize-core';
|
|
3
|
+
interface NeuralNetworkEffectProps {
|
|
4
|
+
boundingRadius: number;
|
|
5
|
+
config: NeuralNetworkConfig;
|
|
6
|
+
animations?: AnimationOptions[];
|
|
7
|
+
}
|
|
8
|
+
declare const NeuralNetworkEffect: React.FC<NeuralNetworkEffectProps>;
|
|
9
|
+
export default NeuralNetworkEffect;
|
|
10
|
+
//# sourceMappingURL=NeuralNetworkEffect.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"NeuralNetworkEffect.d.ts","sourceRoot":"","sources":["../../../src/components/effects/NeuralNetworkEffect.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;AAqCD,QAAA,MAAM,mBAAmB,EAAE,KAAK,CAAC,EAAE,CAAC,wBAAwB,CAkL3D,CAAC;AAEF,eAAe,mBAAmB,CAAC"}
|