Using time reference value to fit in 32bit float.

This commit is contained in:
Alexander Tumin 2020-08-29 15:22:54 +03:00
parent 664756eea7
commit 7acca4fa68

View file

@ -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;
}
});