kollors
All checks were successful
continuous-integration/drone/push Build is passing

This commit is contained in:
Rei
2023-02-15 18:46:29 +01:00
parent 703b611dfd
commit dc7e82b143
4 changed files with 57 additions and 52 deletions

View File

@@ -1,8 +1,8 @@
import { useRef, useMemo } from 'react'
import { Canvas, useFrame } from '@react-three/fiber'
import { useRef, useMemo } from "react";
import { Canvas, useFrame } from "@react-three/fiber";
import { BufferGeometry, Material, MathUtils, Mesh } from "three";
import { vertexShader } from './Shaders/Background/vertex';
import { fragmentShader } from './Shaders/Background/fragment';
import { vertexShader } from "./Shaders/Background/vertex";
import { fragmentShader } from "./Shaders/Background/fragment";
const Fragment = () => {
// This reference will give us direct access to the mesh
@@ -21,12 +21,13 @@ const Fragment = () => {
);
useFrame((state) => {
if(!meshRef.current){
return;
if (!meshRef.current) {
return;
}
const { clock } = state;
//@ts-ignore
meshRef.current.material.uniforms.u_time.value = 0.4 * clock.getElapsedTime()/5;
meshRef.current.material.uniforms.u_time.value =
(0.4 * clock.getElapsedTime()) / 5;
//@ts-ignore
meshRef.current.material.uniforms.u_intensity.value = MathUtils.lerp(
//@ts-ignore
@@ -37,7 +38,12 @@ const Fragment = () => {
});
return (
<mesh ref={meshRef} position={[0, 0, 0]} rotation={[-Math.PI/17, Math.PI/20, 0]} scale={1.5}>
<mesh
ref={meshRef}
position={[0, 0, 0]}
rotation={[-Math.PI / 17, Math.PI / 20, 0]}
scale={1.5}
>
<planeGeometry args={[30, 30, 200, 200]} />
<shaderMaterial
fragmentShader={fragmentShader}
@@ -49,13 +55,12 @@ const Fragment = () => {
);
};
export const R3Gradient = () => {
return (
<div className='-z-40 h-screen w-screen fixed bg-black opacity-60'>
return (
<div className="-z-40 h-screen w-screen fixed bg-black opacity-60 top-0 left-0">
<Canvas camera={{ position: [0.0, 0.0, 5.0] }}>
<Fragment />
</Canvas>
</div>
);
);
};