I want to create 3D scene with water like in this example three.js shader ocean or water but I have to create this in react-three-fiber library. I already searched the internet to find some good working example for this case but without result.
Can I ask for help to figure it out how to implement above examples into react-three-fiber approach?
here is what I have so far for metioned Water component:
import React from "react";
import waterNormal from "./waternormals.jpg";
//import { useLoader } from "react-three-fiber";
import * as THREE from "three";
import { Water } from "three/examples/jsm/objects/Water.js";
const WaterObject = () => {
//const mapNormalWater = useLoader(TextureLoader, waterNormal);
return (
<mesh>
<planeBufferGeometry attach="geometry" args={[100, 100]} />
<Water
options={{
textureWidth: 512,
textureHeight: 512,
waterNormals: new THREE.TextureLoader().load(
waterNormal,
function (texture) {
texture.wrapS = texture.wrapT = THREE.RepeatWrapping;
}
),
sunDirection: new THREE.Vector3(),
sunColor: 0xffffff,
waterColor: 0x001e0f,
distortionScale: 3.7,
// fog: scene.fog !== undefined
}}
></Water>
</mesh>
);
};
export default WaterObject ;