Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

228
Views
Three Js React how to have mesh refract it's environment but hide the environment background to the camera

I have been trying to solve this for a while, so any help would be greatly appreciated!

What I am trying to do is give the appearance that an image is trapped within a mesh. The thought I had to do this was to have some mesh that has a thickness and a refractive index, place it inside an environment with a 360 photo, then hide the background image to the camera and still have the image through the mesh visible to the user, every time I try to hide the background though, the refraction part vanishes and all that is left is the reflective part. here is my code for the object in an environment:

import { useRef } from "react";
import { Suspense } from "react";
import { Canvas, useFrame, useLoader } from "@react-three/fiber";
import { OrbitControls, Environment } from "@react-three/drei";
import * as THREE from "three";

function Thing() {
  const ref = useRef();
  useFrame(() => (ref.current.rotation.x = ref.current.rotation.y += 0.0));
  return (
    <mesh
      ref={ref}
      onClick={(e) => console.log("click")}
      onPointerOver={(e) => console.log("hover")}
      onPointerOut={(e) => console.log("unhover")}
    >
      <meshPhysicalMaterial roughness={0} transmission={1} thickness={2} />
      <icosahedronGeometry attach="geometry" args={[2, 0]} />
    </mesh>
  );
}

export default function MomentsObject() {
  return (
    <Canvas
      style={{
        height: 700,
        width: 700,
      }}
    >
      <Suspense fallback={null}>
        <Thing />
        <OrbitControls
          enablePan={true}
          enableZoom={false}
          enableRotate={true}
        />
        <Environment preset="sunset" background={true} />
      </Suspense>
    </Canvas>
  );
}

If any of you have any advice on how to do this, or a better approach to make it appear like a 360 image is trapped within a glass n-gon, that would be great; Thank you!

about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

Change the prop to background={false}

Instead of doing this, you can also directly apply this image to your n-gon and make sure the material side property is set to 'Backside', it would give the same effect

about 4 years ago · Juan Pablo Isaza Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!