react-three-fiber react-three-fiber react-three-fiber react-three-fiber

Custom lens effect

Using postprocessing to create a custom effect like concentric circular lenses. Fork on Codesandbox

Live example


Coming Soon

Code

import React from "react";
import ReactDOM from "react-dom";
import { Canvas } from "react-three-fiber";
import { EffectComposer } from "@react-three/postprocessing";
import { CircleLens } from "./circleLens";
import { OrbitControls, Stats } from "@react-three/drei";
import "./styles.css";

import { SmallBox, Wall, Box, Ball, Ground } from "./scene";

function Effects() {
  return (
    <EffectComposer>
      <CircleLens fragments={53} />
    </EffectComposer>
  );
}
const App = () => {
  return (
    <Canvas
      style=
      camera=
    >
      <directionalLight position={[2.5, 5, 5]} />
      <SmallBox />
      <Box />
      <Ball />
      <Wall />
      <Ground />
      <Effects />
      <OrbitControls />
      <Stats />
    </Canvas>
  );
};

ReactDOM.render(<App />, document.getElementById("root"));

Running this example

Clone this repo, and then NPM install and NPM start from the relevant directory.

$ cd examples/effects/postprocessing-custom-lens-effect
$ npm install && npm run start