Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@react-three/gpu-pathtracer

Package Overview
Dependencies
Maintainers
0
Versions
6
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@react-three/gpu-pathtracer

⚡️ A React abstraction for the popular three-gpu-pathtracer.

  • 0.2.0
  • latest
  • Source
  • npm
  • Socket score

Version published
Maintainers
0
Created
Source

react-three-gpu-pathtracer


This demo is real, you can click it! It contains full code, too. 📦

GameBoy model by (@kleingeo) on Sketchfab . GameBoy Cartridge by (@MeBob) on Sketchfab .


Chat on Twitter Chat on Twitter


react-three-gpu-pathtracer lets you render your react-three-fiber scenes using Path Tracing! It is as simple as

import { Pathtracer } from "@react-three/gpu-pathtracer";

function GradientSphere() {
  return (
    <Canvas>
      <Pathtracer>{/* Your scene */}</Pathtracer>
    </Canvas>
  );
}

The <Pathtracer /> component wraps your scene. The scene is then rendered using Path Tracing.

Props
PropTypeDefaultDescription
minSamplesnumber1Default: 5. Min number of samples before blending the base scene with the pathtraced one.
samplesnumber1Max number of samples before the pathtracer stops.
framesnumberInfinityNumber of frames to path trace. Will pause rendering once this number is reached.
tiles[number, number] / THREE.Vector2 / { x: number; y: number } / number2Number of tiles. Can be used to improve the responsiveness of a page while still rendering a high resolution target.
bouncesnumber1The number of ray bounces to test. Higher is better quality but slower performance.
enabledbooleantrueWether to enable pathtracing.

Env maps

Env maps can be added using Drei's <Environment /> component just like in a regular scene.

<Pathtracer>
  <Environment
    preset="..."
    background // Optional, set as scene background
    backgroundBlurriness={0.5}
    backgroundIntensity={1}
  />
</Pathtracer>

usePathtracer

This hook provides access to useful functions in the internal renderer. Can only be used within the <Pathtracer /> component.

const { renderer, update, reset } = usePathtracer();
Return valueTypeDescription
pathtracerWebGLPathTracerInternal renderer. Can be used to access/edit internal properties
rendererWebGLPathTracerDEPRECIATED: use pathtracer to not get confused with raster renderer
reset() => voidFlushes the rendered scene and resets the samples count.
update() => voidTells the pathtracer that the scene has been updated. Everything is managed internally now.

Note on controls

When you set controls be sure to use makeDefault and it's best to import the OrbitControls from drei

<OrbitControls makeDefault>
        // ...

Development

Dev
cd project-root
yarn
yarn dev
Build
yarn build
Publish
cd package
npm run release

Keywords

FAQs

Package last updated on 30 Sep 2024

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc