Code Monkey home page Code Monkey logo

drei's Introduction

Build Status npm version npm

logo

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

yarn add drei
import { ... } from 'drei'

Exports

Cameras

⚡️ PerspectiveCamera makeDefault=true

A responsive, perspective camera that sets itself as the default. Can take children, which from then on move along.

<PerspectiveCamera>
  <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.

⚡️ OrbitControls enableDamping=true

⚡️ MapControls enableDamping=true

⚡️ TrackballControls

⚡️ TransformControls

<TransformControls>
  <mesh />
</TransformControls>

Abstractions

⚡️ Detailed

A wrapper around THREE.LOD (Level of detail). The number of distances corresponds to the direct children you add. Only one of the children will be shown according to how close the camera is to it.

<Detailed distances={[0, 10, 20]}>
  <mesh geometry={highDetail} />
  <mesh geometry={mediumDetail} />
  <mesh geometry={lowDetail} />
</Detailed>

⚡️ PositionalAudio url distance=1 loop=true

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

<PositionalAudo url="/song.mp3" />

Misc

⚡️ draco(url = '/draco-gtltf/')

Adds the Draco extension to your GLTFLoader.

useLoader(GLTFLoader, url, draco())

⚡️ StandardEffects ao=true|{...} bloom=true|{...}

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

<StandardEffects />

Contributions

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

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.