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

drei

Package Overview
Dependencies
Maintainers
1
Versions
97
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

drei

useful add-ons for react-three-fiber

  • 0.0.26
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
1.6K
increased by33.9%
Maintainers
1
Weekly downloads
 
Created
Source

Build Status npm version npm

logo

A growing collection of useful helpers and abstractions for react-three-fiber, saving you some boilerplate.

If you find yourself repeating set-up code often and if it's generic enough, add it here, everyone benefits!

Requirements
  • Types
  • ForwardRefs if possible, so that objects can be referenced back
  • Invalidate frames on any movement for those using invalidateFrameloop
  • Cleanup on unmount, no left-overs, restore previous states
yarn add drei
import { ... } from 'drei'

Index

  • <PerspectiveCamera />
  • <OrbitControls />
  • <MapControls />
  • <TrackballControls />
  • <TransformControls />
  • <Detailed />
  • <PositionalAudio />
  • <StandardEffects />
  • <Sky />
  • <HTML />
  • <Stats />
  • draco()

Exports

Cameras

⚡️ <PerspectiveCamera />

A responsive THREE.PerspectiveCamera that sets itself as the default.

<PerspectiveCamera
  makeDefault               // Registers it as the default camera system-wide (default=true)
  {...props}                // All THREE.PerspectiveCamera props are valid
>
  <mesh />
</PerspectiveCamera>

Controls

If available controls have damping enabled by default, they manage their own updates, remove themselves on unmount, are compatible with the invalidateFrameloop canvas-flag. They inherit all props from their underlying THREE controls.

⚡️ <OrbitControls />
⚡️ <MapControls />
⚡️ <TrackballControls />
⚡️ <TransformControls />

Abstractions

⚡️ <Detailed>

A wrapper around THREE.LOD (Level of detail).

<Detailed
  distances={[0, 10, 20]}   // Camera distances, correspends to the # of the children
  {...props}                // All THREE.LOD props are valid
>
  <mesh geometry={highDetail} />
  <mesh geometry={mediumDetail} />
  <mesh geometry={lowDetail} />
</Detailed>
⚡️ <PositionalAudio />

A wrapper around THREE.PositionalAudio. Add this to groups or meshes to tie them to a sound that plays when the camera comes near.

<PositionalAudio
  url="/sound.mp3"          // Url of the sound file
  distance={1}              // Camera distance (default=1)
  loop                      // Repat play (default=true)
  {...props}                // All THREE.PositionalAudio props are valid
/>
⚡️ <StandardEffects />

Adds ambient-occlusion, bloom and SMAA using the postprocessing library.

<StandardEffects
  smaa                      // Can be a boolean (default=true)
  ao                        // Can be a boolean or all valid postprocessing AO props (default=true)
  bloom                     // Can be a boolean or all valid postprocessing Bloom props (default=true)
  edgeDetection={0.1}       // SMAA precision (default=0.1)
  bloomOpacity={1}          // Bloom blendMode opacity (default=1)
  effects={() => [...fx]}   // Define your own: ([smaa, ao, bloom]) => [...effects] (default=undefined)
/>

Shaders

⚡️ <Sky />

Adds a sky to your scene.

<Sky
  distance={450000}         // Camera distance (default=450000)
  sunPosition={[0, 1, 0]}   // Sun position normal (default=[0, 1, 0])
  {...props}                // All three/examples/jsm/objects/Sky props are valid
/>

Misc

⚡️ <HTML />

Allows you to tie HTML content to any object of your scene. It will be projected to the objects whereabouts automatically.

<HTML
  prepend                   // Project content behind the canvas (default: false)
  center                    // Adds a -50%/-50% css transform (default: false)
  fullscreen                // Aligns to the upper-left corner, fills the screen (default:false)
  scaleFactor={10}          // Scales children if set to a number (default=undefined)
  zIndexRange={[100, 0]}    // Z-order range (default=[16777271, 0])
  portal={domnodeRef}       // Reference to target container (default=undefined)
  {...groupProps}           // All THREE.Group props are valid
  {...divProps}             // All HTMLDivElement props are valid
>
  <h1>hello</h1>
  <p>world</p>
</HTML>
⚡️ <Stats />

Adds stats to document.body. It takes over the render-loop!

<Stats
  showPanel={0}             // Start-up panel (default=0)
  {...props}                // All stats.js props are valid
/>
⚡️ draco()

Adds the Draco extension to your GLTFLoader.

useLoader(
  GLTFLoader,
  url,
  draco(
    '/draco-gtltf/'         // Path to the Draco binaries (default='/draco-gtltf/')
  )
)

Keywords

FAQs

Package last updated on 05 May 2020

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