@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,213 @@
|
|
|
1
|
+
import { easing } from 'maath';
|
|
2
|
+
import { Color } from 'three';
|
|
3
|
+
export function shouldEffectBeActive(effect, hovered, clicked) {
|
|
4
|
+
if (!effect.enabled)
|
|
5
|
+
return false;
|
|
6
|
+
const mode = effect.triggerMode ?? 'always';
|
|
7
|
+
switch (mode) {
|
|
8
|
+
case 'always': return true;
|
|
9
|
+
case 'hover': return hovered;
|
|
10
|
+
case 'click': return clicked;
|
|
11
|
+
default: return true;
|
|
12
|
+
}
|
|
13
|
+
}
|
|
14
|
+
export function getActiveEffects(effects, hovered, clicked) {
|
|
15
|
+
return effects.filter(effect => shouldEffectBeActive(effect, hovered, clicked));
|
|
16
|
+
}
|
|
17
|
+
export function applyWaveEffect(object, effect, time, originalY) {
|
|
18
|
+
const options = effect.options;
|
|
19
|
+
const amplitude = options?.amplitude ?? 0.1;
|
|
20
|
+
const frequency = options?.frequency ?? 2;
|
|
21
|
+
object.position.y = originalY + Math.sin(time * frequency * (effect.speed ?? 1)) * amplitude * (effect.intensity ?? 1);
|
|
22
|
+
}
|
|
23
|
+
export function applyFloatEffect(object, effect, time, originalPosition) {
|
|
24
|
+
const options = effect.options;
|
|
25
|
+
const speed = effect.speed ?? 1;
|
|
26
|
+
const intensity = effect.intensity ?? 1;
|
|
27
|
+
object.position.x = originalPosition.x + Math.cos(time * speed * 0.5) * ((options?.amplitudeX ?? 0.05) * intensity);
|
|
28
|
+
object.position.y = originalPosition.y + Math.sin(time * speed) * ((options?.amplitudeY ?? 0.1) * intensity);
|
|
29
|
+
object.position.z = originalPosition.z + Math.sin(time * speed * 0.3) * ((options?.amplitudeZ ?? 0.03) * intensity);
|
|
30
|
+
}
|
|
31
|
+
export function applyPulseEffect(object, effect, time, originalScale) {
|
|
32
|
+
const options = effect.options;
|
|
33
|
+
const minScale = options?.minScale ?? 0.95;
|
|
34
|
+
const maxScale = options?.maxScale ?? 1.05;
|
|
35
|
+
const scaleFactor = minScale + (Math.sin(time * (effect.speed ?? 2)) + 1) * 0.5 * (maxScale - minScale);
|
|
36
|
+
object.scale.set(originalScale.x * scaleFactor, originalScale.y * scaleFactor, originalScale.z * scaleFactor);
|
|
37
|
+
}
|
|
38
|
+
export function applyShakeEffect(object, effect, originalPosition) {
|
|
39
|
+
const options = effect.options;
|
|
40
|
+
const intensity = effect.intensity ?? 1;
|
|
41
|
+
object.position.x = originalPosition.x + (Math.random() - 0.5) * ((options?.amplitudeX ?? 0.02) * intensity);
|
|
42
|
+
object.position.y = originalPosition.y + (Math.random() - 0.5) * ((options?.amplitudeY ?? 0.02) * intensity);
|
|
43
|
+
}
|
|
44
|
+
export function applyBounceEffect(object, effect, time, originalY) {
|
|
45
|
+
const options = effect.options;
|
|
46
|
+
object.position.y = originalY + Math.abs(Math.sin(time * (effect.speed ?? 3))) * (options?.bounceHeight ?? 0.2) * (effect.intensity ?? 1);
|
|
47
|
+
}
|
|
48
|
+
export function applyRotate3DEffect(object, effect, time, originalRotation) {
|
|
49
|
+
const options = effect.options;
|
|
50
|
+
const speed = effect.speed ?? 1;
|
|
51
|
+
const intensity = (effect.intensity ?? 1) * 0.1;
|
|
52
|
+
if (options?.axisX !== false)
|
|
53
|
+
object.rotation.x = originalRotation.x + Math.cos(time * speed * 0.7) * intensity * 0.5;
|
|
54
|
+
if (options?.axisY !== false)
|
|
55
|
+
object.rotation.y = originalRotation.y + Math.sin(time * speed) * intensity;
|
|
56
|
+
if (options?.axisZ)
|
|
57
|
+
object.rotation.z = originalRotation.z + Math.sin(time * speed * 0.5) * intensity * 0.3;
|
|
58
|
+
}
|
|
59
|
+
export function applyFadeEffect(effect, time) {
|
|
60
|
+
const options = effect.options;
|
|
61
|
+
const fadeMin = options?.fadeMin ?? 0.3;
|
|
62
|
+
const fadeMax = options?.fadeMax ?? 1;
|
|
63
|
+
return fadeMin + (Math.sin(time * (effect.speed ?? 1)) + 1) * 0.5 * (fadeMax - fadeMin);
|
|
64
|
+
}
|
|
65
|
+
export function applySpinEffect(object, effect, dt) {
|
|
66
|
+
const options = effect.options;
|
|
67
|
+
const axis = options?.axis ?? 'y';
|
|
68
|
+
object.rotation[axis] += dt * (effect.speed ?? 1);
|
|
69
|
+
}
|
|
70
|
+
export function applySwayEffect(object, effect, time, originalRotation) {
|
|
71
|
+
const options = effect.options;
|
|
72
|
+
const axis = options?.axis ?? 'z';
|
|
73
|
+
object.rotation[axis] = originalRotation[axis] + Math.sin(time * (effect.speed ?? 1)) * (options?.angle ?? 0.2) * (effect.intensity ?? 1);
|
|
74
|
+
}
|
|
75
|
+
export function applyFlipEffect(object, effect, isActive, dt, originalRotation, sensitivity = 0.5) {
|
|
76
|
+
const options = effect.options;
|
|
77
|
+
const axis = options?.axis ?? 'y';
|
|
78
|
+
const dampSpeed = (effect.speed ?? 0.3) * (1 - sensitivity * 0.5);
|
|
79
|
+
easing.damp(object.rotation, axis, isActive ? originalRotation[axis] + Math.PI : originalRotation[axis], dampSpeed, dt);
|
|
80
|
+
}
|
|
81
|
+
export function applyScaleEffect(object, effect, isActive, dt, originalScale, sensitivity = 0.5) {
|
|
82
|
+
const options = effect.options;
|
|
83
|
+
const targetScale = options?.targetScale ?? 1.2;
|
|
84
|
+
const dampSpeed = (effect.speed ?? 0.1) * (1 - sensitivity * 0.5);
|
|
85
|
+
const scale = isActive
|
|
86
|
+
? [originalScale.x * targetScale, originalScale.y * targetScale, originalScale.z * targetScale]
|
|
87
|
+
: [originalScale.x, originalScale.y, originalScale.z];
|
|
88
|
+
easing.damp3(object.scale, scale, dampSpeed, dt);
|
|
89
|
+
}
|
|
90
|
+
export function applyTransformEffects(object, effects, time, dt, state, hovered, clicked, sensitivity = 0.5) {
|
|
91
|
+
const result = {};
|
|
92
|
+
for (const effect of effects) {
|
|
93
|
+
const isActive = shouldEffectBeActive(effect, hovered, clicked);
|
|
94
|
+
if (!isActive)
|
|
95
|
+
continue;
|
|
96
|
+
switch (effect.type) {
|
|
97
|
+
case 'wave':
|
|
98
|
+
applyWaveEffect(object, effect, time, state.originalPosition.y);
|
|
99
|
+
break;
|
|
100
|
+
case 'float':
|
|
101
|
+
applyFloatEffect(object, effect, time, state.originalPosition);
|
|
102
|
+
break;
|
|
103
|
+
case 'pulse':
|
|
104
|
+
applyPulseEffect(object, effect, time, state.originalScale);
|
|
105
|
+
break;
|
|
106
|
+
case 'shake':
|
|
107
|
+
applyShakeEffect(object, effect, state.originalPosition);
|
|
108
|
+
break;
|
|
109
|
+
case 'bounce':
|
|
110
|
+
applyBounceEffect(object, effect, time, state.originalPosition.y);
|
|
111
|
+
break;
|
|
112
|
+
case 'rotate3d':
|
|
113
|
+
applyRotate3DEffect(object, effect, time, state.originalRotation);
|
|
114
|
+
break;
|
|
115
|
+
case 'fade':
|
|
116
|
+
result.opacity = applyFadeEffect(effect, time);
|
|
117
|
+
break;
|
|
118
|
+
case 'spin':
|
|
119
|
+
applySpinEffect(object, effect, dt);
|
|
120
|
+
break;
|
|
121
|
+
case 'sway':
|
|
122
|
+
applySwayEffect(object, effect, time, state.originalRotation);
|
|
123
|
+
break;
|
|
124
|
+
}
|
|
125
|
+
}
|
|
126
|
+
for (const effect of effects) {
|
|
127
|
+
if (!effect.enabled)
|
|
128
|
+
continue;
|
|
129
|
+
const isActive = shouldEffectBeActive(effect, hovered, clicked);
|
|
130
|
+
switch (effect.type) {
|
|
131
|
+
case 'flip':
|
|
132
|
+
applyFlipEffect(object, effect, isActive, dt, state.originalRotation, sensitivity);
|
|
133
|
+
break;
|
|
134
|
+
case 'scale':
|
|
135
|
+
applyScaleEffect(object, effect, isActive, dt, state.originalScale, sensitivity);
|
|
136
|
+
break;
|
|
137
|
+
}
|
|
138
|
+
}
|
|
139
|
+
return result;
|
|
140
|
+
}
|
|
141
|
+
function getColorFromPath(material, path) {
|
|
142
|
+
let current = material;
|
|
143
|
+
for (const part of path.split('.')) {
|
|
144
|
+
if (current == null)
|
|
145
|
+
return null;
|
|
146
|
+
current = current[part];
|
|
147
|
+
}
|
|
148
|
+
if (current?.value instanceof Color)
|
|
149
|
+
return current.value;
|
|
150
|
+
if (current instanceof Color)
|
|
151
|
+
return current;
|
|
152
|
+
return null;
|
|
153
|
+
}
|
|
154
|
+
export function applyColorTransitionEffect(object, effect, isActive, dt, baseColors, applyToChildren = true, sensitivity = 0.5) {
|
|
155
|
+
const targetProperties = effect.targetProperties ?? ['color'];
|
|
156
|
+
const targetColor = isActive ? effect.targetColor : null;
|
|
157
|
+
const dampSpeed = 0.1 * (1 - sensitivity * 0.5);
|
|
158
|
+
const applyToMaterial = (material) => {
|
|
159
|
+
for (const propPath of targetProperties) {
|
|
160
|
+
const color = getColorFromPath(material, propPath);
|
|
161
|
+
if (color)
|
|
162
|
+
easing.dampC(color, targetColor || baseColors[propPath] || '#ffffff', dampSpeed, dt);
|
|
163
|
+
}
|
|
164
|
+
};
|
|
165
|
+
if (applyToChildren)
|
|
166
|
+
object.traverse((child) => { if (child.material)
|
|
167
|
+
applyToMaterial(child.material); });
|
|
168
|
+
else {
|
|
169
|
+
const mesh = object;
|
|
170
|
+
if (mesh.material)
|
|
171
|
+
applyToMaterial(mesh.material);
|
|
172
|
+
}
|
|
173
|
+
}
|
|
174
|
+
export function applyPulseColorEffect(object, effect, time, baseColors, applyToChildren = true) {
|
|
175
|
+
const targetProperties = effect.targetProperties ?? ['color'];
|
|
176
|
+
const blend = (Math.sin(time * (effect.speed ?? 1) * 2) + 1) * 0.5 * (effect.intensity ?? 1);
|
|
177
|
+
const baseColorObj = new Color();
|
|
178
|
+
const targetColorObj = new Color(effect.targetColor);
|
|
179
|
+
const resultColor = new Color();
|
|
180
|
+
const applyToMaterial = (material) => {
|
|
181
|
+
for (const propPath of targetProperties) {
|
|
182
|
+
const color = getColorFromPath(material, propPath);
|
|
183
|
+
if (color) {
|
|
184
|
+
baseColorObj.set(baseColors[propPath] || '#ffffff');
|
|
185
|
+
color.copy(resultColor.copy(baseColorObj).lerp(targetColorObj, blend));
|
|
186
|
+
}
|
|
187
|
+
}
|
|
188
|
+
};
|
|
189
|
+
if (applyToChildren)
|
|
190
|
+
object.traverse((child) => { if (child.material)
|
|
191
|
+
applyToMaterial(child.material); });
|
|
192
|
+
else {
|
|
193
|
+
const mesh = object;
|
|
194
|
+
if (mesh.material)
|
|
195
|
+
applyToMaterial(mesh.material);
|
|
196
|
+
}
|
|
197
|
+
}
|
|
198
|
+
export function applyAllColorEffects(object, effects, time, dt, baseColors, hovered, clicked, applyToChildren = true, sensitivity = 0.5) {
|
|
199
|
+
for (const effect of effects) {
|
|
200
|
+
if (!effect.enabled)
|
|
201
|
+
continue;
|
|
202
|
+
const isActive = shouldEffectBeActive(effect, hovered, clicked);
|
|
203
|
+
switch (effect.type) {
|
|
204
|
+
case 'color-transition':
|
|
205
|
+
applyColorTransitionEffect(object, effect, isActive, dt, baseColors, applyToChildren, sensitivity);
|
|
206
|
+
break;
|
|
207
|
+
case 'pulse-color':
|
|
208
|
+
if (isActive)
|
|
209
|
+
applyPulseColorEffect(object, effect, time, baseColors, applyToChildren);
|
|
210
|
+
break;
|
|
211
|
+
}
|
|
212
|
+
}
|
|
213
|
+
}
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import * as THREE from 'three';
|
|
2
|
+
import type { AnimationOptions } from '@ntalmagor/3drize-core';
|
|
3
|
+
export declare const DEBUG_GENERATIVE_EFFECTS = false;
|
|
4
|
+
export declare function applyGenerativeAnimations(materials: THREE.ShaderMaterial[], animations: AnimationOptions[] | undefined, startValuesCache: Record<string, any>, currentTime: number, hovered: boolean): void;
|
|
5
|
+
//# sourceMappingURL=handleGenerativeEffectsAnimations.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"handleGenerativeEffectsAnimations.d.ts","sourceRoot":"","sources":["../../src/utils/handleGenerativeEffectsAnimations.ts"],"names":[],"mappings":"AAoBA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAE/B,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,wBAAwB,CAAC;AAuG/D,eAAO,MAAM,wBAAwB,QAAQ,CAAC;AA4F9C,wBAAgB,yBAAyB,CACvC,SAAS,EAAE,KAAK,CAAC,cAAc,EAAE,EACjC,UAAU,EAAE,gBAAgB,EAAE,GAAG,SAAS,EAC1C,gBAAgB,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,EACrC,WAAW,EAAE,MAAM,EACnB,OAAO,EAAE,OAAO,GACf,IAAI,CA4DN"}
|
|
@@ -0,0 +1,268 @@
|
|
|
1
|
+
// =============================================================================
|
|
2
|
+
// HANDLE GENERATIVE EFFECTS ANIMATIONS — per-effect utility
|
|
3
|
+
// =============================================================================
|
|
4
|
+
//
|
|
5
|
+
// Called from inside each generative effect component's own useFrame loop.
|
|
6
|
+
// Each effect component holds direct refs to its ShaderMaterials and passes
|
|
7
|
+
// them here, avoiding fragile scene-graph traversal.
|
|
8
|
+
//
|
|
9
|
+
// Usage (inside an effect component's useFrame):
|
|
10
|
+
//
|
|
11
|
+
// useFrame((state) => {
|
|
12
|
+
// const t = state.clock.getElapsedTime();
|
|
13
|
+
// mat.uniforms.u_time.value = t;
|
|
14
|
+
//
|
|
15
|
+
// if (animations?.length) {
|
|
16
|
+
// applyGenerativeAnimations([mat], animations, startValuesCacheRef.current, Date.now(), hovered ?? false);
|
|
17
|
+
// }
|
|
18
|
+
// });
|
|
19
|
+
//
|
|
20
|
+
import * as THREE from 'three';
|
|
21
|
+
import { MathUtils } from 'three';
|
|
22
|
+
// =============================================================================
|
|
23
|
+
// INLINED HELPERS (from client/app/utils/materialUtils.ts and hooks/useAnimations.ts)
|
|
24
|
+
// =============================================================================
|
|
25
|
+
const calculateTimeProgress = (currentTime, duration, yoyo, loop) => {
|
|
26
|
+
const animationSpeed = 1000 / duration;
|
|
27
|
+
const rawProgress = currentTime * animationSpeed * 0.001;
|
|
28
|
+
if (yoyo) {
|
|
29
|
+
const cycleProgress = rawProgress % 1;
|
|
30
|
+
return Math.sin(cycleProgress * Math.PI * 2) * 0.5 + 0.5;
|
|
31
|
+
}
|
|
32
|
+
if (loop)
|
|
33
|
+
return rawProgress % 1;
|
|
34
|
+
return Math.min(rawProgress, 1);
|
|
35
|
+
};
|
|
36
|
+
const easingFunctions = {
|
|
37
|
+
linear: (t) => t,
|
|
38
|
+
easeInQuad: (t) => t * t,
|
|
39
|
+
easeOutQuad: (t) => t * (2 - t),
|
|
40
|
+
easeInOutQuad: (t) => t < 0.5 ? 2 * t * t : -1 + (4 - 2 * t) * t,
|
|
41
|
+
easeInCubic: (t) => t * t * t,
|
|
42
|
+
easeOutCubic: (t) => (--t) * t * t + 1,
|
|
43
|
+
easeInOutCubic: (t) => t < 0.5 ? 4 * t * t * t : (t - 1) * (2 * t - 2) * (2 * t - 2) + 1,
|
|
44
|
+
easeInQuart: (t) => t * t * t * t,
|
|
45
|
+
easeOutQuart: (t) => 1 - (--t) * t * t * t,
|
|
46
|
+
easeInOutQuart: (t) => t < 0.5 ? 8 * t * t * t * t : 1 - 8 * (--t) * t * t * t,
|
|
47
|
+
easeInQuint: (t) => t * t * t * t * t,
|
|
48
|
+
easeOutQuint: (t) => 1 + (--t) * t * t * t * t,
|
|
49
|
+
easeInOutQuint: (t) => t < 0.5 ? 16 * t * t * t * t * t : 1 + 16 * (--t) * t * t * t * t,
|
|
50
|
+
easeInSine: (t) => 1 - Math.cos(t * Math.PI / 2),
|
|
51
|
+
easeOutSine: (t) => Math.sin(t * Math.PI / 2),
|
|
52
|
+
easeInOutSine: (t) => -(Math.cos(Math.PI * t) - 1) / 2,
|
|
53
|
+
easeInExpo: (t) => t === 0 ? 0 : Math.pow(2, 10 * (t - 1)),
|
|
54
|
+
easeOutExpo: (t) => t === 1 ? 1 : 1 - Math.pow(2, -10 * t),
|
|
55
|
+
easeInOutExpo: (t) => {
|
|
56
|
+
if (t === 0)
|
|
57
|
+
return 0;
|
|
58
|
+
if (t === 1)
|
|
59
|
+
return 1;
|
|
60
|
+
if (t < 0.5)
|
|
61
|
+
return Math.pow(2, 20 * t - 10) / 2;
|
|
62
|
+
return (2 - Math.pow(2, -20 * t + 10)) / 2;
|
|
63
|
+
},
|
|
64
|
+
easeInCirc: (t) => 1 - Math.sqrt(1 - t * t),
|
|
65
|
+
easeOutCirc: (t) => Math.sqrt(1 - (t - 1) * (t - 1)),
|
|
66
|
+
easeInOutCirc: (t) => {
|
|
67
|
+
if (t < 0.5)
|
|
68
|
+
return (1 - Math.sqrt(1 - 4 * t * t)) / 2;
|
|
69
|
+
return (Math.sqrt(1 - (-2 * t + 2) * (-2 * t + 2)) + 1) / 2;
|
|
70
|
+
},
|
|
71
|
+
easeInBack: (t) => { const c1 = 1.70158; const c3 = c1 + 1; return c3 * t * t * t - c1 * t * t; },
|
|
72
|
+
easeOutBack: (t) => { const c1 = 1.70158; const c3 = c1 + 1; return 1 + c3 * Math.pow(t - 1, 3) + c1 * Math.pow(t - 1, 2); },
|
|
73
|
+
easeInOutBack: (t) => {
|
|
74
|
+
const c1 = 1.70158;
|
|
75
|
+
const c2 = c1 * 1.525;
|
|
76
|
+
return t < 0.5 ? (Math.pow(2 * t, 2) * ((c2 + 1) * 2 * t - c2)) / 2 : (Math.pow(2 * t - 2, 2) * ((c2 + 1) * (t * 2 - 2) + c2) + 2) / 2;
|
|
77
|
+
},
|
|
78
|
+
easeInElastic: (t) => { const c4 = (2 * Math.PI) / 3; return t === 0 ? 0 : t === 1 ? 1 : -Math.pow(2, 10 * t - 10) * Math.sin((t * 10 - 10.75) * c4); },
|
|
79
|
+
easeOutElastic: (t) => { const c4 = (2 * Math.PI) / 3; return t === 0 ? 0 : t === 1 ? 1 : Math.pow(2, -10 * t) * Math.sin((t * 10 - 0.75) * c4) + 1; },
|
|
80
|
+
easeInOutElastic: (t) => {
|
|
81
|
+
const c5 = (2 * Math.PI) / 4.5;
|
|
82
|
+
return t === 0 ? 0 : t === 1 ? 1 : t < 0.5
|
|
83
|
+
? -(Math.pow(2, 20 * t - 10) * Math.sin((20 * t - 11.125) * c5)) / 2
|
|
84
|
+
: (Math.pow(2, -20 * t + 10) * Math.sin((20 * t - 11.125) * c5)) / 2 + 1;
|
|
85
|
+
},
|
|
86
|
+
easeInBounce: (t) => 1 - easingFunctions.easeOutBounce(1 - t),
|
|
87
|
+
easeOutBounce: (t) => {
|
|
88
|
+
const n1 = 7.5625;
|
|
89
|
+
const d1 = 2.75;
|
|
90
|
+
if (t < 1 / d1)
|
|
91
|
+
return n1 * t * t;
|
|
92
|
+
else if (t < 2 / d1)
|
|
93
|
+
return n1 * (t -= 1.5 / d1) * t + 0.75;
|
|
94
|
+
else if (t < 2.5 / d1)
|
|
95
|
+
return n1 * (t -= 2.25 / d1) * t + 0.9375;
|
|
96
|
+
else
|
|
97
|
+
return n1 * (t -= 2.625 / d1) * t + 0.984375;
|
|
98
|
+
},
|
|
99
|
+
easeInOutBounce: (t) => t < 0.5
|
|
100
|
+
? (1 - easingFunctions.easeOutBounce(1 - 2 * t)) / 2
|
|
101
|
+
: (1 + easingFunctions.easeOutBounce(2 * t - 1)) / 2,
|
|
102
|
+
};
|
|
103
|
+
const gsapEasingMap = {
|
|
104
|
+
'power1.in': 'easeInQuad', 'power1.out': 'easeOutQuad', 'power1.inOut': 'easeInOutQuad',
|
|
105
|
+
'power2.in': 'easeInCubic', 'power2.out': 'easeOutCubic', 'power2.inOut': 'easeInOutCubic',
|
|
106
|
+
'power3.in': 'easeInQuart', 'power3.out': 'easeOutQuart', 'power3.inOut': 'easeInOutQuart',
|
|
107
|
+
'power4.in': 'easeInQuint', 'power4.out': 'easeOutQuint', 'power4.inOut': 'easeInOutQuint',
|
|
108
|
+
'sine.in': 'easeInSine', 'sine.out': 'easeOutSine', 'sine.inOut': 'easeInOutSine',
|
|
109
|
+
'expo.in': 'easeInExpo', 'expo.out': 'easeOutExpo', 'expo.inOut': 'easeInOutExpo',
|
|
110
|
+
'circ.in': 'easeInCirc', 'circ.out': 'easeOutCirc', 'circ.inOut': 'easeInOutCirc',
|
|
111
|
+
'back.in': 'easeInBack', 'back.out': 'easeOutBack', 'back.inOut': 'easeInOutBack',
|
|
112
|
+
'elastic.in': 'easeInElastic', 'elastic.out': 'easeOutElastic', 'elastic.inOut': 'easeInOutElastic',
|
|
113
|
+
'bounce.in': 'easeInBounce', 'bounce.out': 'easeOutBounce', 'bounce.inOut': 'easeInOutBounce',
|
|
114
|
+
'none': 'linear', 'linear': 'linear',
|
|
115
|
+
};
|
|
116
|
+
const applyEasing = (easingName, progress) => {
|
|
117
|
+
const fn = easingFunctions[easingName];
|
|
118
|
+
return fn ? fn(progress) : progress;
|
|
119
|
+
};
|
|
120
|
+
// =============================================================================
|
|
121
|
+
// DEBUG
|
|
122
|
+
// =============================================================================
|
|
123
|
+
export const DEBUG_GENERATIVE_EFFECTS = false;
|
|
124
|
+
const log = (message, ...args) => {
|
|
125
|
+
if (DEBUG_GENERATIVE_EFFECTS)
|
|
126
|
+
console.log(`[GenerativeEffectsAnimations] ${message}`, ...args);
|
|
127
|
+
};
|
|
128
|
+
const _loggedOnce = new Set();
|
|
129
|
+
const logOnce = (key, message, ...args) => {
|
|
130
|
+
if (_loggedOnce.has(key))
|
|
131
|
+
return;
|
|
132
|
+
_loggedOnce.add(key);
|
|
133
|
+
console.log(`[GenerativeEffectsAnimations] ${message}`, ...args);
|
|
134
|
+
};
|
|
135
|
+
const warnOnce = (key, message, ...args) => {
|
|
136
|
+
if (_loggedOnce.has(key))
|
|
137
|
+
return;
|
|
138
|
+
_loggedOnce.add(key);
|
|
139
|
+
console.warn(`[GenerativeEffectsAnimations] ${message}`, ...args);
|
|
140
|
+
};
|
|
141
|
+
// =============================================================================
|
|
142
|
+
// HELPERS
|
|
143
|
+
// =============================================================================
|
|
144
|
+
function candidateUniformNames(property) {
|
|
145
|
+
const capitalized = property.charAt(0).toUpperCase() + property.slice(1);
|
|
146
|
+
return [`u${capitalized}`, `u_${property}`];
|
|
147
|
+
}
|
|
148
|
+
function findUniformName(materials, property) {
|
|
149
|
+
const candidates = candidateUniformNames(property);
|
|
150
|
+
for (const candidate of candidates) {
|
|
151
|
+
for (const mat of materials) {
|
|
152
|
+
if (mat.uniforms[candidate] !== undefined)
|
|
153
|
+
return candidate;
|
|
154
|
+
}
|
|
155
|
+
}
|
|
156
|
+
return null;
|
|
157
|
+
}
|
|
158
|
+
const _colorFrom = new THREE.Color();
|
|
159
|
+
const _colorTo = new THREE.Color();
|
|
160
|
+
function readUniformValue(materials, uniformName) {
|
|
161
|
+
for (const mat of materials) {
|
|
162
|
+
const u = mat.uniforms[uniformName];
|
|
163
|
+
if (u !== undefined) {
|
|
164
|
+
if (u.value instanceof THREE.Color)
|
|
165
|
+
return '#' + u.value.getHexString();
|
|
166
|
+
if (u.value instanceof THREE.Vector3) {
|
|
167
|
+
_colorFrom.setRGB(u.value.x, u.value.y, u.value.z);
|
|
168
|
+
return '#' + _colorFrom.getHexString();
|
|
169
|
+
}
|
|
170
|
+
return u.value;
|
|
171
|
+
}
|
|
172
|
+
}
|
|
173
|
+
return undefined;
|
|
174
|
+
}
|
|
175
|
+
function applyNumericToMaterials(materials, uniformName, value) {
|
|
176
|
+
for (const mat of materials) {
|
|
177
|
+
const u = mat.uniforms[uniformName];
|
|
178
|
+
if (u !== undefined)
|
|
179
|
+
u.value = value;
|
|
180
|
+
}
|
|
181
|
+
}
|
|
182
|
+
function applyColorToMaterials(materials, uniformName, from, to, t) {
|
|
183
|
+
_colorFrom.set(from);
|
|
184
|
+
_colorTo.set(to);
|
|
185
|
+
const r = MathUtils.lerp(_colorFrom.r, _colorTo.r, t);
|
|
186
|
+
const g = MathUtils.lerp(_colorFrom.g, _colorTo.g, t);
|
|
187
|
+
const b = MathUtils.lerp(_colorFrom.b, _colorTo.b, t);
|
|
188
|
+
for (const mat of materials) {
|
|
189
|
+
const u = mat.uniforms[uniformName];
|
|
190
|
+
if (u !== undefined) {
|
|
191
|
+
const val = u.value;
|
|
192
|
+
if (val instanceof THREE.Color)
|
|
193
|
+
val.setRGB(r, g, b);
|
|
194
|
+
else if (val && typeof val === 'object' && 'x' in val)
|
|
195
|
+
val.set(r, g, b);
|
|
196
|
+
}
|
|
197
|
+
}
|
|
198
|
+
}
|
|
199
|
+
function isColorValue(value) {
|
|
200
|
+
return typeof value === 'string' && (value.startsWith('#') || value.startsWith('rgb'));
|
|
201
|
+
}
|
|
202
|
+
// =============================================================================
|
|
203
|
+
// MAIN EXPORT
|
|
204
|
+
// =============================================================================
|
|
205
|
+
export function applyGenerativeAnimations(materials, animations, startValuesCache, currentTime, hovered) {
|
|
206
|
+
if (!animations || animations.length === 0)
|
|
207
|
+
return;
|
|
208
|
+
if (materials.length === 0)
|
|
209
|
+
return;
|
|
210
|
+
logOnce('called', `Processing ${animations.length} animation(s) across ${materials.length} material(s)`);
|
|
211
|
+
for (const animation of animations) {
|
|
212
|
+
try {
|
|
213
|
+
const { property, to, duration, ease, loop = false, yoyo = false, active, triggerMode = 'always', } = animation;
|
|
214
|
+
if (active === false) {
|
|
215
|
+
log(`Skipping "${property}": active=false`);
|
|
216
|
+
continue;
|
|
217
|
+
}
|
|
218
|
+
if (triggerMode === 'hover' && !hovered) {
|
|
219
|
+
log(`Skipping "${property}": triggerMode=hover but not hovered`);
|
|
220
|
+
continue;
|
|
221
|
+
}
|
|
222
|
+
if (to === undefined) {
|
|
223
|
+
warnOnce(`no-to-${property}`, `Skipping "${property}": no 'to' value defined`);
|
|
224
|
+
continue;
|
|
225
|
+
}
|
|
226
|
+
const uniformName = findUniformName(materials, property);
|
|
227
|
+
if (!uniformName) {
|
|
228
|
+
warnOnce(`no-uniform-${property}`, `No uniform found for property "${property}" (tried: ${candidateUniformNames(property).join(', ')}) — available uniforms on mat[0]: ${Object.keys(materials[0]?.uniforms ?? {}).join(', ')}`);
|
|
229
|
+
continue;
|
|
230
|
+
}
|
|
231
|
+
if (!(property in startValuesCache)) {
|
|
232
|
+
const currentVal = readUniformValue(materials, uniformName);
|
|
233
|
+
startValuesCache[property] = animation.from !== undefined ? animation.from : currentVal;
|
|
234
|
+
log('cached start value', { property, uniformName, startValue: startValuesCache[property] });
|
|
235
|
+
}
|
|
236
|
+
const from = startValuesCache[property];
|
|
237
|
+
if (from === undefined || from === null)
|
|
238
|
+
continue;
|
|
239
|
+
let timeProgress = calculateTimeProgress(currentTime, duration, yoyo, loop);
|
|
240
|
+
if (ease) {
|
|
241
|
+
const easingFunctionName = gsapEasingMap[ease] || ease;
|
|
242
|
+
timeProgress = applyEasing(easingFunctionName, timeProgress);
|
|
243
|
+
}
|
|
244
|
+
if (isColorValue(from)) {
|
|
245
|
+
if (typeof to !== 'string') {
|
|
246
|
+
warnOnce(`bad-to-${property}`, `Color property "${property}" has non-string 'to' value:`, to);
|
|
247
|
+
continue;
|
|
248
|
+
}
|
|
249
|
+
applyColorToMaterials(materials, uniformName, from, to, timeProgress);
|
|
250
|
+
}
|
|
251
|
+
else if (typeof from === 'number') {
|
|
252
|
+
if (typeof to !== 'number') {
|
|
253
|
+
warnOnce(`bad-to-num-${property}`, `Numeric property "${property}" has non-numeric 'to' value:`, to);
|
|
254
|
+
continue;
|
|
255
|
+
}
|
|
256
|
+
applyNumericToMaterials(materials, uniformName, MathUtils.lerp(from, to, timeProgress));
|
|
257
|
+
}
|
|
258
|
+
else {
|
|
259
|
+
warnOnce(`bad-from-${property}`, `Unhandled 'from' type for property "${property}":`, typeof from, from);
|
|
260
|
+
continue;
|
|
261
|
+
}
|
|
262
|
+
log('animated', { property, uniformName, from, to, timeProgress });
|
|
263
|
+
}
|
|
264
|
+
catch (err) {
|
|
265
|
+
console.error(`[GenerativeEffectsAnimations] Error animating property "${animation.property}":`, err);
|
|
266
|
+
}
|
|
267
|
+
}
|
|
268
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"hasHoverAnimation.d.ts","sourceRoot":"","sources":["../../src/utils/hasHoverAnimation.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,wBAAwB,CAAC;AAE/D,wBAAgB,iBAAiB,CAAC,UAAU,EAAE,gBAAgB,GAAG,SAAS,GAAG,OAAO,CAQnF"}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
export function hasHoverAnimation(animations) {
|
|
2
|
+
if (!animations)
|
|
3
|
+
return false;
|
|
4
|
+
if (animations.transform?.animations?.some(a => a.triggerMode === 'hover'))
|
|
5
|
+
return true;
|
|
6
|
+
if (animations.transform?.effects?.some(e => e.triggerMode === 'hover'))
|
|
7
|
+
return true;
|
|
8
|
+
if (animations.material?.animations?.some(a => a.triggerMode === 'hover'))
|
|
9
|
+
return true;
|
|
10
|
+
if (animations.edges?.animations?.some(a => a.triggerMode === 'hover'))
|
|
11
|
+
return true;
|
|
12
|
+
if (animations.effects?.animations?.some(a => a.triggerMode === 'hover'))
|
|
13
|
+
return true;
|
|
14
|
+
return false;
|
|
15
|
+
}
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
import type { Points } from 'three';
|
|
2
|
+
export declare const handleShapeAnimation: (delta: number, speed: number, animationProgress: React.RefObject<number>, pointsRef: React.RefObject<Points | null>, basePositions: React.RefObject<Float32Array | null>, targetPositions: React.RefObject<Float32Array | null>) => void;
|
|
3
|
+
//# sourceMappingURL=particleAnimations.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"particleAnimations.d.ts","sourceRoot":"","sources":["../../src/utils/particleAnimations.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,OAAO,CAAC;AAEpC,eAAO,MAAM,oBAAoB,GAC/B,OAAO,MAAM,EACb,OAAO,MAAM,EACb,mBAAmB,KAAK,CAAC,SAAS,CAAC,MAAM,CAAC,EAC1C,WAAW,KAAK,CAAC,SAAS,CAAC,MAAM,GAAG,IAAI,CAAC,EACzC,eAAe,KAAK,CAAC,SAAS,CAAC,YAAY,GAAG,IAAI,CAAC,EACnD,iBAAiB,KAAK,CAAC,SAAS,CAAC,YAAY,GAAG,IAAI,CAAC,KACpD,IAkBF,CAAC"}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
export const handleShapeAnimation = (delta, speed, animationProgress, pointsRef, basePositions, targetPositions) => {
|
|
2
|
+
if (!pointsRef.current || !basePositions.current)
|
|
3
|
+
return;
|
|
4
|
+
const progress = Math.min(animationProgress.current + delta * speed, 1);
|
|
5
|
+
const geometry = pointsRef.current.geometry;
|
|
6
|
+
const posAttr = geometry.attributes.position;
|
|
7
|
+
if (targetPositions.current) {
|
|
8
|
+
const galPos = targetPositions.current;
|
|
9
|
+
for (let i = 0; i < basePositions.current.length; i += 3) {
|
|
10
|
+
posAttr.array[i] = basePositions.current[i] + (galPos[i] - basePositions.current[i]) * progress;
|
|
11
|
+
posAttr.array[i + 1] = basePositions.current[i + 1] + (galPos[i + 1] - basePositions.current[i + 1]) * progress;
|
|
12
|
+
posAttr.array[i + 2] = basePositions.current[i + 2] + (galPos[i + 2] - basePositions.current[i + 2]) * progress;
|
|
13
|
+
}
|
|
14
|
+
}
|
|
15
|
+
animationProgress.current = progress;
|
|
16
|
+
posAttr.needsUpdate = true;
|
|
17
|
+
};
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import type { Object3D } from 'three';
|
|
2
|
+
export declare function findById(id: string): Object3D | null;
|
|
3
|
+
/**
|
|
4
|
+
* Find a Three.js object in the live scene by its Three.js name (object.name).
|
|
5
|
+
* Uses the native Three.js getObjectByName for efficiency.
|
|
6
|
+
* Returns null if the scene is not yet initialised or the object is not found.
|
|
7
|
+
*/
|
|
8
|
+
export declare function findByName(name: string): Object3D | null;
|
|
9
|
+
//# sourceMappingURL=sceneQuery.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"sceneQuery.d.ts","sourceRoot":"","sources":["../../src/utils/sceneQuery.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAC;AAItC,wBAAgB,QAAQ,CAAC,EAAE,EAAE,MAAM,GAAG,QAAQ,GAAG,IAAI,CASpD;AAED;;;;GAIG;AACH,wBAAgB,UAAU,CAAC,IAAI,EAAE,MAAM,GAAG,QAAQ,GAAG,IAAI,CAGxD"}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { SceneStore } from '@ntalmagor/3drize-core';
|
|
2
|
+
export function findById(id) {
|
|
3
|
+
if (!id || !SceneStore.scene)
|
|
4
|
+
return null;
|
|
5
|
+
let found = null;
|
|
6
|
+
SceneStore.scene.traverse((obj) => {
|
|
7
|
+
if (!found && obj.userData.id === id) {
|
|
8
|
+
found = obj;
|
|
9
|
+
}
|
|
10
|
+
});
|
|
11
|
+
return found;
|
|
12
|
+
}
|
|
13
|
+
/**
|
|
14
|
+
* Find a Three.js object in the live scene by its Three.js name (object.name).
|
|
15
|
+
* Uses the native Three.js getObjectByName for efficiency.
|
|
16
|
+
* Returns null if the scene is not yet initialised or the object is not found.
|
|
17
|
+
*/
|
|
18
|
+
export function findByName(name) {
|
|
19
|
+
if (!SceneStore.scene)
|
|
20
|
+
return null;
|
|
21
|
+
return SceneStore.scene.getObjectByName(name) ?? null;
|
|
22
|
+
}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import type { Use3driseShaderEffects } from '@ntalmagor/3drize-core';
|
|
2
|
+
export declare function update3driseShaderUniforms(uniforms: any, effects: Use3driseShaderEffects, u_time: number, pointer: {
|
|
3
|
+
x: number;
|
|
4
|
+
y: number;
|
|
5
|
+
}): void;
|
|
6
|
+
//# sourceMappingURL=shaderUtils.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"shaderUtils.d.ts","sourceRoot":"","sources":["../../src/utils/shaderUtils.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,sBAAsB,EAAE,MAAM,wBAAwB,CAAC;AAErE,wBAAgB,0BAA0B,CACxC,QAAQ,EAAE,GAAG,EACb,OAAO,EAAE,sBAAsB,EAC/B,MAAM,EAAE,MAAM,EACd,OAAO,EAAE;IAAE,CAAC,EAAE,MAAM,CAAC;IAAC,CAAC,EAAE,MAAM,CAAA;CAAE,GAChC,IAAI,CAqGN"}
|