From 7acca4fa6821efe6d106b015c9b818b212eef162 Mon Sep 17 00:00:00 2001 From: Alexander Tumin Date: Sat, 29 Aug 2020 15:22:54 +0300 Subject: [PATCH] Using time reference value to fit in 32bit float. --- src/components/LevelSprite.tsx | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/components/LevelSprite.tsx b/src/components/LevelSprite.tsx index 913f80e..1055bd9 100644 --- a/src/components/LevelSprite.tsx +++ b/src/components/LevelSprite.tsx @@ -73,14 +73,16 @@ const LevelSprite = (props: LevelSpriteConstructorProps) => { void main() { vec4 t1 = texture2D(tex1,vUv); vec4 t2 = texture2D(tex2,vUv); - float bias = abs(sin(timeMSeconds)); + float bias = abs(sin(timeMSeconds / (1600.0 / M_PI))); gl_FragColor = mix(t1, t2, bias); } `; + const timeRef = Date.now(); + useFrame(() => { if (materialRef.current) { - (materialRef.current! as any).uniforms.timeMSeconds.value = 1.5; + (materialRef.current! as any).uniforms.timeMSeconds.value = Date.now() - timeRef; } });