@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,189 @@
|
|
|
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
|
+
// Stars: per-particle twinkle + size variation
|
|
7
|
+
const starVertShader = /* glsl */ `
|
|
8
|
+
attribute float aPhase;
|
|
9
|
+
attribute float aSize;
|
|
10
|
+
|
|
11
|
+
uniform float u_time;
|
|
12
|
+
uniform float uTwinkleSpeed;
|
|
13
|
+
uniform float uPointSize;
|
|
14
|
+
|
|
15
|
+
varying float vAlpha;
|
|
16
|
+
varying float vBrightness;
|
|
17
|
+
|
|
18
|
+
void main() {
|
|
19
|
+
float twinkle = 0.5 + 0.5 * sin(u_time * uTwinkleSpeed + aPhase);
|
|
20
|
+
float twinkle2 = 0.5 + 0.5 * sin(u_time * uTwinkleSpeed * 1.618 + aPhase * 2.3);
|
|
21
|
+
vAlpha = 0.35 + 0.65 * twinkle;
|
|
22
|
+
vBrightness = twinkle2;
|
|
23
|
+
|
|
24
|
+
vec4 mv = modelViewMatrix * vec4(position, 1.0);
|
|
25
|
+
gl_PointSize = uPointSize * aSize * (twinkle * 0.6 + 0.4) * (260.0 / -mv.z);
|
|
26
|
+
gl_Position = projectionMatrix * mv;
|
|
27
|
+
}
|
|
28
|
+
`;
|
|
29
|
+
const starFragShader = /* glsl */ `
|
|
30
|
+
uniform vec3 uColor;
|
|
31
|
+
uniform float uOpacity;
|
|
32
|
+
|
|
33
|
+
varying float vAlpha;
|
|
34
|
+
varying float vBrightness;
|
|
35
|
+
|
|
36
|
+
void main() {
|
|
37
|
+
vec2 coord = gl_PointCoord - vec2(0.5);
|
|
38
|
+
float dist = length(coord);
|
|
39
|
+
if (dist > 0.5) discard;
|
|
40
|
+
|
|
41
|
+
// Gaussian glow
|
|
42
|
+
float glow = exp(-dist * dist * 10.0);
|
|
43
|
+
|
|
44
|
+
// Four-pointed diffraction spike (like real stars through telescopes)
|
|
45
|
+
float cx = exp(-abs(coord.x) * 16.0) * exp(-coord.y*coord.y * 40.0);
|
|
46
|
+
float cy = exp(-abs(coord.y) * 16.0) * exp(-coord.x*coord.x * 40.0);
|
|
47
|
+
float spike = (cx + cy) * 0.5 * vBrightness;
|
|
48
|
+
|
|
49
|
+
// Hot core: center goes white
|
|
50
|
+
float core = exp(-dist * dist * 80.0);
|
|
51
|
+
vec3 col = mix(uColor, vec3(1.0, 1.0, 1.0), core * 0.7 + spike * 0.3);
|
|
52
|
+
|
|
53
|
+
gl_FragColor = vec4(col, vAlpha * uOpacity * (glow + spike + core));
|
|
54
|
+
}
|
|
55
|
+
`;
|
|
56
|
+
// Animated connection lines — pulse in/out using time + per-line phase
|
|
57
|
+
const lineVertShader = /* glsl */ `
|
|
58
|
+
attribute float aLinePhase;
|
|
59
|
+
attribute float aLineSeed;
|
|
60
|
+
|
|
61
|
+
uniform float u_time;
|
|
62
|
+
uniform float uPulseSpeed;
|
|
63
|
+
|
|
64
|
+
varying float vLineAlpha;
|
|
65
|
+
|
|
66
|
+
void main() {
|
|
67
|
+
// Each line independently pulses with a unique phase
|
|
68
|
+
float pulse = 0.5 + 0.5 * sin(u_time * uPulseSpeed + aLinePhase);
|
|
69
|
+
// Some lines are fast, some slow
|
|
70
|
+
float pulse2 = 0.5 + 0.5 * sin(u_time * uPulseSpeed * aLineSeed + aLinePhase * 1.7);
|
|
71
|
+
vLineAlpha = pulse * pulse2;
|
|
72
|
+
|
|
73
|
+
gl_Position = projectionMatrix * modelViewMatrix * vec4(position, 1.0);
|
|
74
|
+
}
|
|
75
|
+
`;
|
|
76
|
+
const lineFragShader = /* glsl */ `
|
|
77
|
+
uniform vec3 uColor;
|
|
78
|
+
uniform float uLineOpacity;
|
|
79
|
+
|
|
80
|
+
varying float vLineAlpha;
|
|
81
|
+
|
|
82
|
+
void main() {
|
|
83
|
+
gl_FragColor = vec4(uColor, vLineAlpha * uLineOpacity);
|
|
84
|
+
}
|
|
85
|
+
`;
|
|
86
|
+
// Fibonacci sphere for even distribution
|
|
87
|
+
function fibonacciSphere(count, radius) {
|
|
88
|
+
const positions = new Float32Array(count * 3);
|
|
89
|
+
const golden = Math.PI * (3 - Math.sqrt(5));
|
|
90
|
+
for (let i = 0; i < count; i++) {
|
|
91
|
+
const y = 1 - (i / (count - 1)) * 2;
|
|
92
|
+
const r = Math.sqrt(Math.max(0, 1 - y * y));
|
|
93
|
+
const theta = golden * i;
|
|
94
|
+
positions[i * 3] = Math.cos(theta) * r * radius;
|
|
95
|
+
positions[i * 3 + 1] = y * radius;
|
|
96
|
+
positions[i * 3 + 2] = Math.sin(theta) * r * radius;
|
|
97
|
+
}
|
|
98
|
+
return positions;
|
|
99
|
+
}
|
|
100
|
+
const ConstellationEffect = ({ boundingRadius, config, animations }) => {
|
|
101
|
+
const { starCount, connectRadius, orbitRadius, twinkleSpeed, lineOpacity, starSize, color, opacity, speed } = config;
|
|
102
|
+
const startValuesCacheRef = useRef({});
|
|
103
|
+
const groupRef = useRef(null);
|
|
104
|
+
const r = boundingRadius * orbitRadius;
|
|
105
|
+
const connR = boundingRadius * connectRadius;
|
|
106
|
+
const colorVec = useMemo(() => {
|
|
107
|
+
const c = new THREE.Color(color);
|
|
108
|
+
return new THREE.Vector3(c.r, c.g, c.b);
|
|
109
|
+
}, [color]);
|
|
110
|
+
const { starGeo, starMat, lineGeo, lineMat } = useMemo(() => {
|
|
111
|
+
const positions = fibonacciSphere(starCount, r);
|
|
112
|
+
// Per-star random size multipliers (slight variation makes it feel natural)
|
|
113
|
+
const phases = new Float32Array(starCount);
|
|
114
|
+
const sizes = new Float32Array(starCount);
|
|
115
|
+
for (let i = 0; i < starCount; i++) {
|
|
116
|
+
phases[i] = Math.random() * Math.PI * 2;
|
|
117
|
+
sizes[i] = 0.5 + Math.random() * 1.0; // 0.5 – 1.5× size
|
|
118
|
+
}
|
|
119
|
+
const sGeo = new THREE.BufferGeometry();
|
|
120
|
+
sGeo.setAttribute('position', new THREE.BufferAttribute(positions, 3));
|
|
121
|
+
sGeo.setAttribute('aPhase', new THREE.BufferAttribute(phases, 1));
|
|
122
|
+
sGeo.setAttribute('aSize', new THREE.BufferAttribute(sizes, 1));
|
|
123
|
+
const sMat = new THREE.ShaderMaterial({
|
|
124
|
+
vertexShader: starVertShader,
|
|
125
|
+
fragmentShader: starFragShader,
|
|
126
|
+
uniforms: {
|
|
127
|
+
u_time: { value: 0 },
|
|
128
|
+
uTwinkleSpeed: { value: twinkleSpeed },
|
|
129
|
+
uPointSize: { value: starSize * 220 },
|
|
130
|
+
uColor: { value: colorVec },
|
|
131
|
+
uOpacity: { value: opacity },
|
|
132
|
+
},
|
|
133
|
+
transparent: true,
|
|
134
|
+
depthWrite: false,
|
|
135
|
+
blending: THREE.AdditiveBlending,
|
|
136
|
+
});
|
|
137
|
+
// Build connection line geometry — each nearby pair gets a line
|
|
138
|
+
const lineVerts = [];
|
|
139
|
+
const linePhases = [];
|
|
140
|
+
const lineSeeds = [];
|
|
141
|
+
for (let i = 0; i < starCount; i++) {
|
|
142
|
+
for (let j = i + 1; j < starCount; j++) {
|
|
143
|
+
const ax = positions[i * 3], ay = positions[i * 3 + 1], az = positions[i * 3 + 2];
|
|
144
|
+
const bx = positions[j * 3], by = positions[j * 3 + 1], bz = positions[j * 3 + 2];
|
|
145
|
+
const dx = ax - bx, dy = ay - by, dz = az - bz;
|
|
146
|
+
if (Math.sqrt(dx * dx + dy * dy + dz * dz) < connR) {
|
|
147
|
+
lineVerts.push(ax, ay, az, bx, by, bz);
|
|
148
|
+
const ph = Math.random() * Math.PI * 2;
|
|
149
|
+
const sd = 0.5 + Math.random() * 1.5;
|
|
150
|
+
linePhases.push(ph, ph); // same phase for both ends of the segment
|
|
151
|
+
lineSeeds.push(sd, sd);
|
|
152
|
+
}
|
|
153
|
+
}
|
|
154
|
+
}
|
|
155
|
+
const lGeo = new THREE.BufferGeometry();
|
|
156
|
+
lGeo.setAttribute('position', new THREE.BufferAttribute(new Float32Array(lineVerts), 3));
|
|
157
|
+
lGeo.setAttribute('aLinePhase', new THREE.BufferAttribute(new Float32Array(linePhases), 1));
|
|
158
|
+
lGeo.setAttribute('aLineSeed', new THREE.BufferAttribute(new Float32Array(lineSeeds), 1));
|
|
159
|
+
const lMat = new THREE.ShaderMaterial({
|
|
160
|
+
vertexShader: lineVertShader,
|
|
161
|
+
fragmentShader: lineFragShader,
|
|
162
|
+
uniforms: {
|
|
163
|
+
u_time: { value: 0 },
|
|
164
|
+
uPulseSpeed: { value: 0.4 },
|
|
165
|
+
uColor: { value: colorVec },
|
|
166
|
+
uLineOpacity: { value: lineOpacity },
|
|
167
|
+
},
|
|
168
|
+
transparent: true,
|
|
169
|
+
depthWrite: false,
|
|
170
|
+
blending: THREE.AdditiveBlending,
|
|
171
|
+
});
|
|
172
|
+
return { starGeo: sGeo, starMat: sMat, lineGeo: lGeo, lineMat: lMat };
|
|
173
|
+
}, [starCount, r, connR, twinkleSpeed, starSize, colorVec, opacity, lineOpacity]);
|
|
174
|
+
useFrame((state, delta) => {
|
|
175
|
+
if (groupRef.current) {
|
|
176
|
+
// Dual-axis rotation: primary Y + slow precession around X for a tumbling feel
|
|
177
|
+
groupRef.current.rotation.y += delta * speed * 0.18;
|
|
178
|
+
groupRef.current.rotation.x += delta * speed * 0.04;
|
|
179
|
+
}
|
|
180
|
+
const t = state.clock.getElapsedTime();
|
|
181
|
+
starMat.uniforms.u_time.value = t;
|
|
182
|
+
lineMat.uniforms.u_time.value = t;
|
|
183
|
+
if (animations?.length) {
|
|
184
|
+
applyGenerativeAnimations([starMat, lineMat], animations, startValuesCacheRef.current, Date.now(), false);
|
|
185
|
+
}
|
|
186
|
+
});
|
|
187
|
+
return (_jsxs("group", { ref: groupRef, children: [_jsx("points", { geometry: starGeo, material: starMat }), _jsx("lineSegments", { geometry: lineGeo, material: lineMat })] }));
|
|
188
|
+
};
|
|
189
|
+
export default ConstellationEffect;
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import type { DataStreamConfig, AnimationOptions } from '@ntalmagor/3drize-core';
|
|
3
|
+
interface DataStreamEffectProps {
|
|
4
|
+
boundingRadius: number;
|
|
5
|
+
config: DataStreamConfig;
|
|
6
|
+
animations?: AnimationOptions[];
|
|
7
|
+
}
|
|
8
|
+
declare const DataStreamEffect: React.FC<DataStreamEffectProps>;
|
|
9
|
+
export default DataStreamEffect;
|
|
10
|
+
//# sourceMappingURL=DataStreamEffect.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"DataStreamEffect.d.ts","sourceRoot":"","sources":["../../../src/components/effects/DataStreamEffect.tsx"],"names":[],"mappings":"AAAA,OAAO,KAA0B,MAAM,OAAO,CAAC;AAG/C,OAAO,KAAK,EAAE,gBAAgB,EAAE,gBAAgB,EAAE,MAAM,wBAAwB,CAAC;AAIjF,UAAU,qBAAqB;IAC7B,cAAc,EAAE,MAAM,CAAC;IACvB,MAAM,EAAE,gBAAgB,CAAC;IACzB,UAAU,CAAC,EAAE,gBAAgB,EAAE,CAAC;CACjC;AAsFD,QAAA,MAAM,gBAAgB,EAAE,KAAK,CAAC,EAAE,CAAC,qBAAqB,CA0DrD,CAAC;AAEF,eAAe,gBAAgB,CAAC"}
|
|
@@ -0,0 +1,138 @@
|
|
|
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
|
+
// Dual counter-rotating helices with cold→hot color gradient.
|
|
7
|
+
// All animation is GPU-side — only u_time updates per frame.
|
|
8
|
+
const vertexShader = /* glsl */ `
|
|
9
|
+
attribute float aT;
|
|
10
|
+
attribute float aOffset;
|
|
11
|
+
attribute float aStrand; // 0 = CW, 1 = CCW (second helix, π-phase offset)
|
|
12
|
+
|
|
13
|
+
uniform float u_time;
|
|
14
|
+
uniform float u_speed;
|
|
15
|
+
uniform float uRadius;
|
|
16
|
+
uniform float uTurns;
|
|
17
|
+
uniform float uHeight;
|
|
18
|
+
uniform float uPointSize;
|
|
19
|
+
uniform float uIntensity;
|
|
20
|
+
|
|
21
|
+
varying float vAlpha;
|
|
22
|
+
varying vec3 vColor;
|
|
23
|
+
|
|
24
|
+
// Palette: deep electric blue → cyan → white-gold
|
|
25
|
+
vec3 palette(float t) {
|
|
26
|
+
vec3 cold = vec3(0.05, 0.15, 0.9); // deep blue
|
|
27
|
+
vec3 mid = vec3(0.0, 0.85, 1.0); // cyan
|
|
28
|
+
vec3 hot = vec3(1.0, 0.92, 0.55); // warm gold-white
|
|
29
|
+
if (t < 0.5) return mix(cold, mid, t * 2.0);
|
|
30
|
+
else return mix(mid, hot, (t - 0.5) * 2.0);
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
void main() {
|
|
34
|
+
const float TAU = 6.28318530718;
|
|
35
|
+
|
|
36
|
+
// Second strand runs the opposite direction, phase-shifted by half turn
|
|
37
|
+
float dir = aStrand > 0.5 ? -1.0 : 1.0;
|
|
38
|
+
float phase = aStrand > 0.5 ? TAU * 0.5 : 0.0;
|
|
39
|
+
float t = fract(aT + aOffset + u_time * u_speed * dir);
|
|
40
|
+
|
|
41
|
+
float angle = t * uTurns * TAU + phase;
|
|
42
|
+
float y = (t - 0.5) * uHeight;
|
|
43
|
+
|
|
44
|
+
// Slight radius oscillation along the helix for organic feel
|
|
45
|
+
float rWave = uRadius * (1.0 + 0.06 * sin(t * TAU * 3.0 + u_time * 2.0));
|
|
46
|
+
vec3 helixPos = vec3(cos(angle) * rWave, y, sin(angle) * rWave);
|
|
47
|
+
|
|
48
|
+
// Head/tail fade
|
|
49
|
+
float nearHead = smoothstep(0.0, 0.10, t);
|
|
50
|
+
float nearTail = 1.0 - smoothstep(0.88, 1.0, t);
|
|
51
|
+
vAlpha = nearHead * nearTail;
|
|
52
|
+
|
|
53
|
+
// Color: gradient along t, second strand tinted slightly differently
|
|
54
|
+
float tColor = aStrand > 0.5 ? 1.0 - t : t; // CW cold→hot, CCW hot→cold
|
|
55
|
+
vColor = palette(tColor);
|
|
56
|
+
if (aStrand > 0.5) vColor = mix(vColor, vColor.zxy, 0.25); // slight RGB swizzle for 2nd strand
|
|
57
|
+
|
|
58
|
+
// Size: larger at the bright head of the stream
|
|
59
|
+
float sizeT = aStrand > 0.5 ? 1.0 - t : t;
|
|
60
|
+
float sizeMod = 0.3 + 0.7 * pow(sizeT, 0.4);
|
|
61
|
+
|
|
62
|
+
vec4 mv = modelViewMatrix * vec4(helixPos, 1.0);
|
|
63
|
+
gl_PointSize = uPointSize * sizeMod * uIntensity * (280.0 / -mv.z);
|
|
64
|
+
gl_Position = projectionMatrix * mv;
|
|
65
|
+
}
|
|
66
|
+
`;
|
|
67
|
+
const fragmentShader = /* glsl */ `
|
|
68
|
+
varying float vAlpha;
|
|
69
|
+
varying vec3 vColor;
|
|
70
|
+
uniform float uOpacity;
|
|
71
|
+
|
|
72
|
+
void main() {
|
|
73
|
+
vec2 coord = gl_PointCoord - vec2(0.5);
|
|
74
|
+
float dist = length(coord);
|
|
75
|
+
if (dist > 0.5) discard;
|
|
76
|
+
|
|
77
|
+
// Soft circular glow
|
|
78
|
+
float glow = exp(-dist * dist * 9.0);
|
|
79
|
+
|
|
80
|
+
// Cross-shaped sparkle on bright particles
|
|
81
|
+
float cx = exp(-abs(coord.x) * 18.0) * exp(-coord.y*coord.y * 28.0);
|
|
82
|
+
float cy = exp(-abs(coord.y) * 18.0) * exp(-coord.x*coord.x * 28.0);
|
|
83
|
+
float star = (cx + cy) * 0.25;
|
|
84
|
+
|
|
85
|
+
gl_FragColor = vec4(vColor, vAlpha * uOpacity * (glow + star));
|
|
86
|
+
}
|
|
87
|
+
`;
|
|
88
|
+
const DataStreamEffect = ({ boundingRadius, config, animations }) => {
|
|
89
|
+
const { particleCount, spiralTurns, streamRadius, inward, particleSize, opacity, speed, intensity } = config;
|
|
90
|
+
const startValuesCacheRef = useRef({});
|
|
91
|
+
const r = boundingRadius * streamRadius;
|
|
92
|
+
const h = boundingRadius * 2.6;
|
|
93
|
+
const { geometry, material } = useMemo(() => {
|
|
94
|
+
// Double the particles — half on each strand
|
|
95
|
+
const total = particleCount * 2;
|
|
96
|
+
const tArr = new Float32Array(total);
|
|
97
|
+
const offsetArr = new Float32Array(total);
|
|
98
|
+
const strandArr = new Float32Array(total);
|
|
99
|
+
for (let i = 0; i < total; i++) {
|
|
100
|
+
const half = i < particleCount ? 0 : 1;
|
|
101
|
+
const localI = i % particleCount;
|
|
102
|
+
tArr[i] = localI / particleCount;
|
|
103
|
+
offsetArr[i] = Math.random();
|
|
104
|
+
strandArr[i] = half;
|
|
105
|
+
}
|
|
106
|
+
const geo = new THREE.BufferGeometry();
|
|
107
|
+
geo.setAttribute('position', new THREE.BufferAttribute(new Float32Array(total * 3), 3));
|
|
108
|
+
geo.setAttribute('aT', new THREE.BufferAttribute(tArr, 1));
|
|
109
|
+
geo.setAttribute('aOffset', new THREE.BufferAttribute(offsetArr, 1));
|
|
110
|
+
geo.setAttribute('aStrand', new THREE.BufferAttribute(strandArr, 1));
|
|
111
|
+
const mat = new THREE.ShaderMaterial({
|
|
112
|
+
vertexShader,
|
|
113
|
+
fragmentShader,
|
|
114
|
+
uniforms: {
|
|
115
|
+
u_time: { value: 0 },
|
|
116
|
+
u_speed: { value: speed * (inward ? -1 : 1) },
|
|
117
|
+
uRadius: { value: r },
|
|
118
|
+
uTurns: { value: spiralTurns },
|
|
119
|
+
uHeight: { value: h },
|
|
120
|
+
uPointSize: { value: particleSize * 80 },
|
|
121
|
+
uIntensity: { value: intensity },
|
|
122
|
+
uOpacity: { value: opacity },
|
|
123
|
+
},
|
|
124
|
+
transparent: true,
|
|
125
|
+
depthWrite: false,
|
|
126
|
+
blending: THREE.AdditiveBlending,
|
|
127
|
+
});
|
|
128
|
+
return { geometry: geo, material: mat };
|
|
129
|
+
}, [particleCount, spiralTurns, r, h, inward, particleSize, intensity, speed, opacity]);
|
|
130
|
+
useFrame((state) => {
|
|
131
|
+
material.uniforms.u_time.value = state.clock.getElapsedTime();
|
|
132
|
+
if (animations?.length) {
|
|
133
|
+
applyGenerativeAnimations([material], animations, startValuesCacheRef.current, Date.now(), false);
|
|
134
|
+
}
|
|
135
|
+
});
|
|
136
|
+
return _jsx("points", { geometry: geometry, material: material });
|
|
137
|
+
};
|
|
138
|
+
export default DataStreamEffect;
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import type { DnaHelixConfig, AnimationOptions } from '@ntalmagor/3drize-core';
|
|
3
|
+
interface DnaHelixEffectProps {
|
|
4
|
+
boundingRadius: number;
|
|
5
|
+
config: DnaHelixConfig;
|
|
6
|
+
animations?: AnimationOptions[];
|
|
7
|
+
}
|
|
8
|
+
declare const DnaHelixEffect: React.FC<DnaHelixEffectProps>;
|
|
9
|
+
export default DnaHelixEffect;
|
|
10
|
+
//# sourceMappingURL=DnaHelixEffect.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"DnaHelixEffect.d.ts","sourceRoot":"","sources":["../../../src/components/effects/DnaHelixEffect.tsx"],"names":[],"mappings":"AAAA,OAAO,KAA0B,MAAM,OAAO,CAAC;AAG/C,OAAO,KAAK,EAAE,cAAc,EAAE,gBAAgB,EAAE,MAAM,wBAAwB,CAAC;AAI/E,UAAU,mBAAmB;IAC3B,cAAc,EAAE,MAAM,CAAC;IACvB,MAAM,EAAE,cAAc,CAAC;IACvB,UAAU,CAAC,EAAE,gBAAgB,EAAE,CAAC;CACjC;AA+ED,QAAA,MAAM,cAAc,EAAE,KAAK,CAAC,EAAE,CAAC,mBAAmB,CAmRjD,CAAC;AAEF,eAAe,cAAc,CAAC"}
|
|
@@ -0,0 +1,311 @@
|
|
|
1
|
+
import { jsx as _jsx, Fragment as _Fragment, 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
|
+
// ── Pulsing junction-dot shader ───────────────────────────────────────────────
|
|
7
|
+
const dotVert = /* glsl */ `
|
|
8
|
+
attribute float aPhase;
|
|
9
|
+
uniform float uSize;
|
|
10
|
+
uniform float u_time;
|
|
11
|
+
varying float vP;
|
|
12
|
+
void main() {
|
|
13
|
+
vP = 0.55 + 0.45 * sin(u_time * 2.0 + aPhase);
|
|
14
|
+
vec4 mv = modelViewMatrix * vec4(position, 1.0);
|
|
15
|
+
gl_PointSize = uSize * vP * (200.0 / -mv.z);
|
|
16
|
+
gl_Position = projectionMatrix * mv;
|
|
17
|
+
}
|
|
18
|
+
`;
|
|
19
|
+
const dotFrag = /* glsl */ `
|
|
20
|
+
uniform vec3 uColor;
|
|
21
|
+
uniform float uOpacity;
|
|
22
|
+
varying float vP;
|
|
23
|
+
void main() {
|
|
24
|
+
vec2 c = gl_PointCoord - 0.5;
|
|
25
|
+
float d = length(c);
|
|
26
|
+
if (d > 0.5) discard;
|
|
27
|
+
float core = smoothstep(0.2, 0.0, d);
|
|
28
|
+
float halo = exp(-d * d * 4.5) * 0.6;
|
|
29
|
+
gl_FragColor = vec4(uColor + vec3(core * 0.5), (core + halo) * vP * uOpacity);
|
|
30
|
+
}
|
|
31
|
+
`;
|
|
32
|
+
// ── Bolt glow-sprite shader ───────────────────────────────────────────────────
|
|
33
|
+
const boltPtVert = /* glsl */ `
|
|
34
|
+
attribute float aBright;
|
|
35
|
+
uniform float uSize;
|
|
36
|
+
varying float vB;
|
|
37
|
+
void main() {
|
|
38
|
+
vB = aBright;
|
|
39
|
+
vec4 mv = modelViewMatrix * vec4(position, 1.0);
|
|
40
|
+
gl_PointSize = uSize * aBright * (200.0 / -mv.z);
|
|
41
|
+
gl_Position = projectionMatrix * mv;
|
|
42
|
+
}
|
|
43
|
+
`;
|
|
44
|
+
const boltPtFrag = /* 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.0);
|
|
53
|
+
gl_FragColor = vec4(uColor, g * vB * uOpacity);
|
|
54
|
+
}
|
|
55
|
+
`;
|
|
56
|
+
// ── Constants ─────────────────────────────────────────────────────────────────
|
|
57
|
+
const TURNS = 4;
|
|
58
|
+
const BOLT_N = 12; // helix samples per bolt (more = smoother glow)
|
|
59
|
+
const BOLT_LEN_T = 0.08; // fraction of helix per bolt (longer = more visible)
|
|
60
|
+
const BOLTS_PER_STRAND = 2;
|
|
61
|
+
const SEGS_PER_BOLT = BOLT_N - 1; // line segments per bolt
|
|
62
|
+
const VERTS_PER_BOLT = SEGS_PER_BOLT * 2; // 2 verts per GL_LINES segment
|
|
63
|
+
const BASE_GLOW = 0.12;
|
|
64
|
+
const CYAN = new THREE.Color('#00ffee');
|
|
65
|
+
const WHITE = new THREE.Color('#ffffff');
|
|
66
|
+
// ── Seeded LCG RNG ────────────────────────────────────────────────────────────
|
|
67
|
+
function makeRng(seed) {
|
|
68
|
+
let s = (seed * 1664525 + 1013904223) >>> 0;
|
|
69
|
+
return () => { s = (s * 1664525 + 1013904223) >>> 0; return s / 0xffffffff; };
|
|
70
|
+
}
|
|
71
|
+
// ── Analytical helix position ─────────────────────────────────────────────────
|
|
72
|
+
function helixAt(t, si, numStrands, r, h) {
|
|
73
|
+
const angle = t * Math.PI * 2 * TURNS + si * (Math.PI * 2 / numStrands);
|
|
74
|
+
return new THREE.Vector3(Math.cos(angle) * r, t * h - h / 2, Math.sin(angle) * r);
|
|
75
|
+
}
|
|
76
|
+
// ── Component ─────────────────────────────────────────────────────────────────
|
|
77
|
+
const DnaHelixEffect = ({ boundingRadius, config, animations }) => {
|
|
78
|
+
const { particleCount, strandCount, helixRadius, helixHeight, basePairColor, runningLightEnabled, opacity, speed, intensity, } = config;
|
|
79
|
+
const startValuesCacheRef = useRef({});
|
|
80
|
+
const groupRef = useRef(null);
|
|
81
|
+
const washProgress = useRef(0);
|
|
82
|
+
const r = boundingRadius * helixRadius;
|
|
83
|
+
const h = boundingRadius * helixHeight;
|
|
84
|
+
const numStrands = Math.min(strandCount, 3);
|
|
85
|
+
// Bolt travel state — just headT + seed per bolt, no THREE objects
|
|
86
|
+
const boltStates = useRef([]);
|
|
87
|
+
// ── Static geometry: backbone, rungs, dots ────────────────────────────────
|
|
88
|
+
const scene = useMemo(() => {
|
|
89
|
+
const N = Math.max(particleCount, 150);
|
|
90
|
+
const RUNG_STEP = Math.max(3, Math.floor(N / 22));
|
|
91
|
+
const strandPts = Array.from({ length: numStrands }, () => []);
|
|
92
|
+
for (let si = 0; si < numStrands; si++) {
|
|
93
|
+
for (let i = 0; i < N; i++) {
|
|
94
|
+
strandPts[si].push(helixAt(i / (N - 1), si, numStrands, r, h));
|
|
95
|
+
}
|
|
96
|
+
}
|
|
97
|
+
// Backbone lines — colors updated each frame
|
|
98
|
+
const makeStrandLine = (pts) => {
|
|
99
|
+
const pos = new Float32Array(pts.length * 3);
|
|
100
|
+
const col = new Float32Array(pts.length * 3);
|
|
101
|
+
for (let i = 0; i < pts.length; i++) {
|
|
102
|
+
pos[i * 3] = pts[i].x;
|
|
103
|
+
pos[i * 3 + 1] = pts[i].y;
|
|
104
|
+
pos[i * 3 + 2] = pts[i].z;
|
|
105
|
+
col[i * 3] = CYAN.r * BASE_GLOW;
|
|
106
|
+
col[i * 3 + 1] = CYAN.g * BASE_GLOW;
|
|
107
|
+
col[i * 3 + 2] = CYAN.b * BASE_GLOW;
|
|
108
|
+
}
|
|
109
|
+
const geo = new THREE.BufferGeometry();
|
|
110
|
+
geo.setAttribute('position', new THREE.BufferAttribute(pos, 3));
|
|
111
|
+
geo.setAttribute('color', new THREE.BufferAttribute(col, 3));
|
|
112
|
+
const mat = new THREE.LineBasicMaterial({
|
|
113
|
+
vertexColors: true, transparent: true, depthWrite: false,
|
|
114
|
+
blending: THREE.AdditiveBlending,
|
|
115
|
+
});
|
|
116
|
+
return {
|
|
117
|
+
line: new THREE.Line(geo, mat),
|
|
118
|
+
colorBuf: col,
|
|
119
|
+
colorAttr: geo.attributes.color,
|
|
120
|
+
N: pts.length,
|
|
121
|
+
};
|
|
122
|
+
};
|
|
123
|
+
const strands = strandPts.map(makeStrandLine);
|
|
124
|
+
// Rungs
|
|
125
|
+
const rV = [], rC = [];
|
|
126
|
+
const rc = new THREE.Color(basePairColor || '#00ffee');
|
|
127
|
+
for (let i = 0; i < N; i += RUNG_STEP) {
|
|
128
|
+
const a = strandPts[0][i];
|
|
129
|
+
const b = strandPts[1 % numStrands][i];
|
|
130
|
+
rV.push(a.x, a.y, a.z, b.x, b.y, b.z);
|
|
131
|
+
const br = 0.55 + 0.3 * Math.sin((i / (N - 1)) * Math.PI);
|
|
132
|
+
rC.push(rc.r * br, rc.g * br, rc.b * br, rc.r * br, rc.g * br, rc.b * br);
|
|
133
|
+
}
|
|
134
|
+
const rungGeo = new THREE.BufferGeometry();
|
|
135
|
+
rungGeo.setAttribute('position', new THREE.BufferAttribute(new Float32Array(rV), 3));
|
|
136
|
+
rungGeo.setAttribute('color', new THREE.BufferAttribute(new Float32Array(rC), 3));
|
|
137
|
+
const rungMat = new THREE.LineBasicMaterial({
|
|
138
|
+
vertexColors: true, transparent: true, opacity: opacity * 0.7,
|
|
139
|
+
depthWrite: false, blending: THREE.AdditiveBlending,
|
|
140
|
+
});
|
|
141
|
+
// Junction dots
|
|
142
|
+
const dP = [], dPh = [];
|
|
143
|
+
let di = 0;
|
|
144
|
+
for (let i = 0; i < N; i += RUNG_STEP) {
|
|
145
|
+
for (let si = 0; si < numStrands; si++) {
|
|
146
|
+
const p = strandPts[si][i];
|
|
147
|
+
dP.push(p.x, p.y, p.z);
|
|
148
|
+
dPh.push(di * 1.37 + si * 2.09);
|
|
149
|
+
di++;
|
|
150
|
+
}
|
|
151
|
+
}
|
|
152
|
+
const dotGeo = new THREE.BufferGeometry();
|
|
153
|
+
dotGeo.setAttribute('position', new THREE.BufferAttribute(new Float32Array(dP), 3));
|
|
154
|
+
dotGeo.setAttribute('aPhase', new THREE.BufferAttribute(new Float32Array(dPh), 1));
|
|
155
|
+
const dotMat = new THREE.ShaderMaterial({
|
|
156
|
+
vertexShader: dotVert, fragmentShader: dotFrag,
|
|
157
|
+
uniforms: {
|
|
158
|
+
uSize: { value: 14 * intensity },
|
|
159
|
+
uColor: { value: new THREE.Vector3(0.15, 1.0, 0.93) },
|
|
160
|
+
uOpacity: { value: opacity },
|
|
161
|
+
u_time: { value: 0 },
|
|
162
|
+
},
|
|
163
|
+
transparent: true, depthWrite: false, blending: THREE.AdditiveBlending,
|
|
164
|
+
});
|
|
165
|
+
return { strands, N, rungGeo, rungMat, dotGeo, dotMat };
|
|
166
|
+
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
167
|
+
}, [particleCount, numStrands, r, h, opacity, intensity, basePairColor]);
|
|
168
|
+
// ── Single combined geometry for ALL energy bolts ─────────────────────────
|
|
169
|
+
// Uses LineSegments (GL_LINES: disconnected pairs), one draw call for all bolts.
|
|
170
|
+
const { boltGeo, boltMat, boltPtsGeo, boltPtsMat } = useMemo(() => {
|
|
171
|
+
const totalBolts = numStrands * BOLTS_PER_STRAND;
|
|
172
|
+
const totalVerts = totalBolts * VERTS_PER_BOLT;
|
|
173
|
+
const pos = new Float32Array(totalVerts * 3);
|
|
174
|
+
const col = new Float32Array(totalVerts * 3);
|
|
175
|
+
const geo = new THREE.BufferGeometry();
|
|
176
|
+
geo.setAttribute('position', new THREE.BufferAttribute(pos, 3));
|
|
177
|
+
geo.setAttribute('color', new THREE.BufferAttribute(col, 3));
|
|
178
|
+
const mat = new THREE.LineBasicMaterial({
|
|
179
|
+
vertexColors: true, transparent: true, depthWrite: false,
|
|
180
|
+
blending: THREE.AdditiveBlending,
|
|
181
|
+
});
|
|
182
|
+
// Initialise bolt travel states
|
|
183
|
+
boltStates.current = [];
|
|
184
|
+
for (let si = 0; si < numStrands; si++) {
|
|
185
|
+
for (let bi = 0; bi < BOLTS_PER_STRAND; bi++) {
|
|
186
|
+
boltStates.current.push({
|
|
187
|
+
si,
|
|
188
|
+
headT: bi / BOLTS_PER_STRAND,
|
|
189
|
+
seed: si * 200 + bi * 37 + 1,
|
|
190
|
+
});
|
|
191
|
+
}
|
|
192
|
+
}
|
|
193
|
+
// Points layer — one sprite per BOLT_N sample, drives the glow thickness
|
|
194
|
+
const totalPts = numStrands * BOLTS_PER_STRAND * BOLT_N;
|
|
195
|
+
const ptPos = new Float32Array(totalPts * 3);
|
|
196
|
+
const ptBright = new Float32Array(totalPts);
|
|
197
|
+
const ptsGeo = new THREE.BufferGeometry();
|
|
198
|
+
ptsGeo.setAttribute('position', new THREE.BufferAttribute(ptPos, 3));
|
|
199
|
+
ptsGeo.setAttribute('aBright', new THREE.BufferAttribute(ptBright, 1));
|
|
200
|
+
const ptsMat = new THREE.ShaderMaterial({
|
|
201
|
+
vertexShader: boltPtVert,
|
|
202
|
+
fragmentShader: boltPtFrag,
|
|
203
|
+
uniforms: {
|
|
204
|
+
uSize: { value: 18 },
|
|
205
|
+
uColor: { value: new THREE.Vector3(0.1, 1.0, 0.95) },
|
|
206
|
+
uOpacity: { value: 1.0 },
|
|
207
|
+
},
|
|
208
|
+
transparent: true, depthWrite: false, blending: THREE.AdditiveBlending,
|
|
209
|
+
});
|
|
210
|
+
return { boltGeo: geo, boltMat: mat, boltPtsGeo: ptsGeo, boltPtsMat: ptsMat };
|
|
211
|
+
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
212
|
+
}, [numStrands]);
|
|
213
|
+
// ── Frame loop ────────────────────────────────────────────────────────────
|
|
214
|
+
useFrame((state, delta) => {
|
|
215
|
+
if (!groupRef.current)
|
|
216
|
+
return;
|
|
217
|
+
groupRef.current.rotation.y += delta * speed * 0.18;
|
|
218
|
+
scene.dotMat.uniforms.u_time.value = state.clock.getElapsedTime();
|
|
219
|
+
// Backbone color wash
|
|
220
|
+
washProgress.current = (washProgress.current + delta * speed * 0.28) % 1;
|
|
221
|
+
const head = washProgress.current;
|
|
222
|
+
scene.strands.forEach(({ colorBuf, colorAttr, N }) => {
|
|
223
|
+
for (let i = 0; i < N; i++) {
|
|
224
|
+
const t = i / (N - 1);
|
|
225
|
+
const dist = Math.min(Math.abs(t - head), 1 - Math.abs(t - head));
|
|
226
|
+
const trail = Math.exp(-dist * 9.0);
|
|
227
|
+
const corona = Math.exp(-dist * dist * 200);
|
|
228
|
+
const bright = BASE_GLOW + (trail * 0.6 + corona * 2.2) * intensity;
|
|
229
|
+
const hm = Math.min(1, corona * 0.7);
|
|
230
|
+
colorBuf[i * 3] = (CYAN.r + (WHITE.r - CYAN.r) * hm) * bright;
|
|
231
|
+
colorBuf[i * 3 + 1] = (CYAN.g + (WHITE.g - CYAN.g) * hm) * bright;
|
|
232
|
+
colorBuf[i * 3 + 2] = (CYAN.b + (WHITE.b - CYAN.b) * hm) * bright;
|
|
233
|
+
}
|
|
234
|
+
colorAttr.needsUpdate = true;
|
|
235
|
+
});
|
|
236
|
+
// Energy bolts
|
|
237
|
+
if (runningLightEnabled) {
|
|
238
|
+
const posAttr = boltGeo.attributes.position;
|
|
239
|
+
const colAttr = boltGeo.attributes.color;
|
|
240
|
+
const ptPosAttr = boltPtsGeo.attributes.position;
|
|
241
|
+
const ptBrtAttr = boltPtsGeo.attributes.aBright;
|
|
242
|
+
const JITTER = r * 0.20;
|
|
243
|
+
boltPtsMat.uniforms.uSize.value = 18 * intensity;
|
|
244
|
+
boltPtsMat.uniforms.uOpacity.value = opacity;
|
|
245
|
+
boltStates.current.forEach((state, boltIdx) => {
|
|
246
|
+
state.headT += delta * speed * 0.18; // slow — so each bolt is clearly visible
|
|
247
|
+
if (state.headT >= 1) {
|
|
248
|
+
state.headT -= 1;
|
|
249
|
+
state.seed++;
|
|
250
|
+
}
|
|
251
|
+
const { si, headT, seed } = state;
|
|
252
|
+
const rng = makeRng(seed);
|
|
253
|
+
const pts = [];
|
|
254
|
+
const cols = [];
|
|
255
|
+
const bright = [];
|
|
256
|
+
for (let i = 0; i < BOLT_N; i++) {
|
|
257
|
+
const frac = i / (BOLT_N - 1);
|
|
258
|
+
const t = headT - BOLT_LEN_T + frac * BOLT_LEN_T;
|
|
259
|
+
const tw = ((t % 1) + 1) % 1;
|
|
260
|
+
const p = helixAt(tw, si, numStrands, r, h);
|
|
261
|
+
if (i > 0 && i < BOLT_N - 1) {
|
|
262
|
+
const lxz = Math.sqrt(p.x * p.x + p.z * p.z);
|
|
263
|
+
if (lxz > 0.001) {
|
|
264
|
+
const rx = p.x / lxz, rz = p.z / lxz;
|
|
265
|
+
const dr = (rng() * 2 - 1) * JITTER;
|
|
266
|
+
const dt = (rng() * 2 - 1) * JITTER * 0.5;
|
|
267
|
+
p.x += rx * dr - rz * dt;
|
|
268
|
+
p.z += rz * dr + rx * dt;
|
|
269
|
+
p.y += (rng() * 2 - 1) * JITTER * 0.3;
|
|
270
|
+
}
|
|
271
|
+
}
|
|
272
|
+
const trail = Math.exp(-(1 - frac) * 5.0);
|
|
273
|
+
const corona = Math.exp(-Math.pow((1 - frac) / 0.12, 2) * 2) * 3.5;
|
|
274
|
+
const b = (trail * 1.0 + corona) * intensity * 1.5;
|
|
275
|
+
const hm = Math.min(1, corona * 0.55);
|
|
276
|
+
pts.push([p.x, p.y, p.z]);
|
|
277
|
+
cols.push([
|
|
278
|
+
(CYAN.r + (WHITE.r - CYAN.r) * hm) * b,
|
|
279
|
+
(CYAN.g + (WHITE.g - CYAN.g) * hm) * b,
|
|
280
|
+
(CYAN.b + (WHITE.b - CYAN.b) * hm) * b,
|
|
281
|
+
]);
|
|
282
|
+
bright.push(Math.min(1, b * 0.7));
|
|
283
|
+
}
|
|
284
|
+
// GL_LINES pairs into line buffer
|
|
285
|
+
const baseV = boltIdx * VERTS_PER_BOLT;
|
|
286
|
+
for (let j = 0; j < SEGS_PER_BOLT; j++) {
|
|
287
|
+
const va = baseV + j * 2;
|
|
288
|
+
posAttr.setXYZ(va, pts[j][0], pts[j][1], pts[j][2]);
|
|
289
|
+
posAttr.setXYZ(va + 1, pts[j + 1][0], pts[j + 1][1], pts[j + 1][2]);
|
|
290
|
+
colAttr.setXYZ(va, cols[j][0], cols[j][1], cols[j][2]);
|
|
291
|
+
colAttr.setXYZ(va + 1, cols[j + 1][0], cols[j + 1][1], cols[j + 1][2]);
|
|
292
|
+
}
|
|
293
|
+
// Sprite points into points buffer
|
|
294
|
+
const baseP = boltIdx * BOLT_N;
|
|
295
|
+
for (let i = 0; i < BOLT_N; i++) {
|
|
296
|
+
ptPosAttr.setXYZ(baseP + i, pts[i][0], pts[i][1], pts[i][2]);
|
|
297
|
+
ptBrtAttr.setX(baseP + i, bright[i]);
|
|
298
|
+
}
|
|
299
|
+
});
|
|
300
|
+
posAttr.needsUpdate = true;
|
|
301
|
+
colAttr.needsUpdate = true;
|
|
302
|
+
ptPosAttr.needsUpdate = true;
|
|
303
|
+
ptBrtAttr.needsUpdate = true;
|
|
304
|
+
}
|
|
305
|
+
if (animations?.length) {
|
|
306
|
+
applyGenerativeAnimations([scene.dotMat, boltPtsMat], animations, startValuesCacheRef.current, Date.now(), false);
|
|
307
|
+
}
|
|
308
|
+
});
|
|
309
|
+
return (_jsxs("group", { ref: groupRef, children: [scene.strands.map(({ line }, i) => _jsx("primitive", { object: line }, i)), _jsx("lineSegments", { geometry: scene.rungGeo, material: scene.rungMat }), _jsx("points", { geometry: scene.dotGeo, material: scene.dotMat }), runningLightEnabled && (_jsxs(_Fragment, { children: [_jsx("lineSegments", { geometry: boltGeo, material: boltMat }), _jsx("points", { geometry: boltPtsGeo, material: boltPtsMat })] }))] }));
|
|
310
|
+
};
|
|
311
|
+
export default DnaHelixEffect;
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import type { FireConfig, AnimationOptions } from '@ntalmagor/3drize-core';
|
|
3
|
+
interface FireEffectProps {
|
|
4
|
+
boundingRadius: number;
|
|
5
|
+
config: FireConfig;
|
|
6
|
+
animations?: AnimationOptions[];
|
|
7
|
+
}
|
|
8
|
+
declare const FireEffect: React.FC<FireEffectProps>;
|
|
9
|
+
export default FireEffect;
|
|
10
|
+
//# sourceMappingURL=FireEffect.d.ts.map
|