Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

231
Vistas
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 Respuestas
Responde la pregunta

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 Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda