react-three-gpu-pathtracer icon indicating copy to clipboard operation
react-three-gpu-pathtracer copied to clipboard

PhysicalSpotLight, ShapedAreaLight, and example of how to use lights

Open richardanaya opened this issue 1 year ago • 2 comments

When I first add a cube, it looks black.

richardanaya avatar Feb 28 '23 23:02 richardanaya

Does this help? https://codesandbox.io/s/react-three-gpu-pathttracer-gltf-lights-3t7bqu?file=/src/App.js

FarazzShaikh avatar Mar 12 '23 18:03 FarazzShaikh

It'll look something like

import { PhysicalSpotLight } from "three-gpu-pathtracer";
extend({ PhysicalSpotLight });

<physicalSpotLight [...] />

If you're using TypeScript, you'll have more problems, because 1) three-gpu-pathtracer doesn't have types yet and 2) you have to extend JSX IntrinsicElements anyways. So your code will look something like:

import { PhysicalSpotLight as PathTracerPhysicalSpotLight } from "three-gpu-pathtracer";

class PhysicalSpotLight extends PathTracerPhysicalSpotLight {}
extend({ PhysicalSpotLight });

declare module '@react-three/fiber' {
  interface ThreeElements {
    physicalSpotLight: Object3DNode<PhysicalSpotLight, typeof PhysicalSpotLight>
  }
}

BrendanBerkley avatar Jun 23 '23 14:06 BrendanBerkley

Thanks! We will take a lok at this once we gear up for a major. The major will wrap all of the upstream helpers in React. As of now, you can use the extend syntax to use these features.

FarazzShaikh avatar Sep 30 '24 09:09 FarazzShaikh