{"bugs":{"url":"https://github.com/drcmda/react-three-fiber/issues"},"dist":{"shasum":"765f89f429723f27fbf6749815872af137be013c","tarball":"https://registry.npmjs.org/react-three-fiber/-/react-three-fiber-4.0.0-beta.7.tgz","fileCount":32,"integrity":"sha512-QCR0vWvnBHRtfNOHbjuyGV3oKzG0jlFPGzovjXydC5dLTPxncjrv/JU9YPM2KaXXs7M5MZ7G4MkTKNnaJQhzOg==","signatures":[{"sig":"MEQCICy4zlS+4N+57M4p8nM0WK5JiCLqXNKRgdiPsCXRKAesAiByZzG+eToUsCUXK9isPoCCuveNyABAkvKGfmx02CW5vg==","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":486119,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.4\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJd5EPuCRA9TVsSAnZWagAA7AQQAIjC0x2fxQ4abHYaZz7B\np1xcH7pCbf9uDf850DPuzxt8LjKMgcTpKudJybELH5hVCDrpx234OTq4wtHn\n/2mRRjLA8+KMv6gmLAWI4NIHYvdEfJtQDbAi6H7yJplt8XRBLwqijiWgDJgO\nJhDIidhByWV3v7rOT59kWSE8yJswaxuCRUkF9BqKLIFuEdJikoZJeJqUrXh+\nmNBdwjSZ+RqdVxf+PbcClEb2gWeoYVVgMzVF9oQq12LMkQJD9+F9429N32Io\n7CfqW1XA77kfgm4/agCwd94YWp9HoXiCDduVaBsU/a63iQ4TKDnlb5vS8QyJ\nr1pD8EeAabRpsF98N0BbUKjSrVHO5xGxCn3IqD5RsjeaOhlcXbqAkn/FFBkQ\npZDt1bjZ4WgomSuMIQsXWrlK2XF5kZ/pe58t+qQQq+2lb7uRlMaN824IG7RS\nbzm1aQpt1Uo9Acp9qtex4m43VX05wkROwdUqhA/wG1Mx6tv1RUivbEOj6NQZ\nq7NpOE/OuHCMRXLUW6wkjN5sepTDhEQOneRflqNNSngVVRGycAN1vVfHyjFA\nM90VkWlZGfO72azKA0xvXQxquUmvxLT97i6vuIzedQzFqQiDGMdKUefWPv0w\nPHpOl/aEqrzsiGPK2tIeBV3PcQ8nMtAmHRVuOC7xt+74FJWBsA/GHYyAG+gN\nC09Y\r\n=h98i\r\n-----END PGP SIGNATURE-----\r\n"},"main":"web.cjs.js","name":"react-three-fiber","types":"types/src/targets/web/index.d.ts","author":{"name":"Paul Henschel"},"module":"web.js","readme":"<p align=\"center\">\n  <a href=\"https://codesandbox.io/embed/react-three-fiber-untitled-game-i2160\"><img width=\"288\" height=\"160\" src=\"https://i.imgur.com/2Ix4Du8.gif\" /></a>\n  <a href=\"https://codesandbox.io/embed/react-three-fiber-gltf-loader-animations-c671i\"><img width=\"288\" height=\"160\" src=\"https://i.imgur.com/OwxJQfx.gif\" /></a>\n  <a href=\"https://codesandbox.io/embed/react-three-fiber-gestures-dh2jc\"><img width=\"288\" height=\"160\" src=\"https://i.imgur.com/ZJ04pRJ.gif\" /></a>\n  <a href=\"https://codesandbox.io/embed/react-three-fiber-gltf-loader-animations-w633u\"><img width=\"288\" height=\"160\" src=\"https://i.imgur.com/UzG518m.gif\" /></a>\n  <a href=\"https://github.com/drcmda/learnwithjason\"><img width=\"288\" height=\"160\" src=\"https://i.imgur.com/1atWRR3.gif\" /></a>\n  <a href=\"https://codesandbox.io/embed/react-three-fiber-suspense-gltf-loader-l900i\"><img width=\"288\" height=\"160\" src=\"https://i.imgur.com/8xpKFkN.gif\" /></a>\n  <a href=\"https://codesandbox.io/embed/387z7o2zrq\"><img width=\"288\" height=\"160\" src=\"https://i.imgur.com/YewcWL5.gif\" /></a>\n  <a href=\"https://codesandbox.io/embed/m7q0r29nn9\"><img width=\"288\" height=\"160\" src=\"https://i.imgur.com/LDddjjC.gif\" /></a>\n  <a href=\"https://codesandbox.io/embed/jz9l97qn89\"><img width=\"288\" height=\"160\" src=\"https://i.imgur.com/zrhe5Jc.gif\" /></a>\n  <a href=\"https://codesandbox.io/embed/kky7yk087v\"><img width=\"288\" height=\"160\" src=\"https://i.imgur.com/jemlXzE.gif\" /></a>\n  <a href=\"https://codesandbox.io/embed/ly0oxkp899\"><img width=\"288\" height=\"160\" src=\"https://i.imgur.com/vjmDwpS.gif\" /></a>\n  <a href=\"https://codesandbox.io/embed/y3j31r13zz\"><img width=\"288\" height=\"160\" src=\"https://i.imgur.com/iFtjKHM.gif\" /></a>\n</p>\n<p align=\"middle\">\n  <i>These demos are real, you can click them! They contain the full code, too.</i>\n</p>\n\n    npm install three react-three-fiber\n\n#### What is it?\n\nThis is a React renderer for Threejs on the web and react-native. Building a dynamic scene graph becomes so much easier when you can break it up into declarative, re-usable components that react to state changes.\n\n#### Does it have regressions?\n\nThis is less of an abstraction and more of a pure reconciler (like react-dom in relation to HTML). It does not target a specific Threejs version nor does it need updates when Threejs alters, adds or removes features. It won't change any specifics or rules. There are zero limitations.\n\n#### Is it slower than raw Threejs?\n\nNo. But it could potentially outperform it. Rendering performance is fully up to Threejs and the GPU, react-three-fiber drives a renderloop outside of React with zero overhead. But React is very efficent in building and updating component-trees, this can make a major difference.\n\n# What it looks like ...\n\nCopy the following into a project to get going. [Here's the same](https://codesandbox.io/s/rrppl0y8l4) running in a code sandbox.\n\n```jsx\nimport { Canvas, useFrame } from 'react-three-fiber'\n\nfunction Thing() {\n  const ref = useRef()\n  useFrame(() => (ref.current.rotation.x = ref.current.rotation.y += 0.01))\n  return (\n    <mesh\n      ref={ref}\n      onClick={e => console.log('click')}\n      onPointerOver={e => console.log('hover')}\n      onPointerOut={e => console.log('unhover')}>\n      <boxBufferGeometry attach=\"geometry\" args={[1, 1, 1]} />\n      <meshNormalMaterial attach=\"material\" />\n    </mesh>\n  )\n}\n\n<Canvas>\n  <Thing />\n</Canvas>\n```\n\n# Canvas\n\nThe `Canvas` object is your portal into Threejs. It renders Threejs elements, _not DOM elements_!\n\n```jsx\n<Canvas\n  children                      // Either a function child (which receives state) or regular children\n  gl                            // Props that go into the default webGL-renderer\n  camera                        // Props that go into the default camera\n  raycaster                     // Props that go into the default raycaster\n  shadowMap                     // Props that go into gl.shadowMap, can also be set true for PCFsoft\n  vr = false                    // Switches renderer to VR mode, then uses gl.setAnimationLoop\n  gl2 = false                   // Enables webgl2\n  concurrent = false            // Enables React concurrent mode\n  resize = undefined            // Resize config, see react-use-measure's options\n  orthographic = false          // Creates an orthographic camera if true\n  noEvents = false              // Switch off raytracing and event support\n  pixelRatio = undefined        // You could provide window.devicePixelRatio if you like\n  invalidateFrameloop = false   // When true it only renders on changes, when false it's a game loop\n  updateDefaultCamera = true    // Adjusts default camera on size changes\n  onCreated                     // Callback when vdom is ready (you can block first render via promise)\n  onPointerMissed />            // Response for pointer clicks that have missed a target\n```\n\nYou can give it additional properties like style and className, which will be added to the container (a div) that holds the dom-canvas element.\n\n# Defaults that the canvas component sets up\n\nCanvas will create a _translucent WebGL-renderer_ with the following properties: `antialias, alpha, setClearAlpha(0)`\n\nA default _perspective camera_: `fov: 75, near: 0.1, far: 1000, position.z: 5`\n\nA default _orthographic camera_ if Canvas.orthographic is true: `near: 0.1, far: 1000, position.z: 5`\n\nA default _shadowMap_ if Canvas.shadowMap is true: `type: PCFSoftShadowMap`\n\nA default _scene_ (into which all the JSX is rendered) and a _raycaster_.\n\nA _wrapping container_ with a [resize observer](https://github.com/react-spring/react-use-measure): `scroll: true, debounce: { scroll: 50, resize: 0 }`\n\nYou do not have to use any of these objects, look under \"receipes\" down below if you want to bring your own.\n\n# Objects and properties\n\nYou can use [Threejs's entire object catalogue and all properties](https://threejs.org/docs). When in doubt, always consult the docs.\n\nYou could lay out an object like this:\n\n```jsx\n<mesh\n  visible\n  userData={{ test: 'hello' }}\n  position={new THREE.Vector3(1, 2, 3)}\n  rotation={new THREE.Euler(0, 0, 0)}\n  geometry={new THREE.SphereGeometry(1, 16, 16)}\n  material={new THREE.MeshBasicMaterial({ color: new THREE.Color('hotpink'), transparent: true })}\n/>\n```\n\nThe problem is that all of these properties will always be re-created. Instead, you should define properties declaratively.\n\n```jsx\n<mesh visible userData={{ test: 'hello' }} position={[1, 2, 3]} rotation={[0, 0, 0]}>\n  <sphereGeometry attach=\"geometry\" args={[1, 16, 16]} />\n  <meshStandardMaterial attach=\"material\" color=\"hotpink\" transparent />\n</mesh>\n```\n\n#### Shortcuts (set)\n\nAll properties that have a `.set()` method can be given a shortcut. For example [THREE.Color.set](https://threejs.org/docs/index.html#api/en/math/Color.set) can take a color string, hence instead of `color={new THREE.Color('hotpink')}` you can do `color=\"hotpink\"`. Some `set` methods take multiple arguments ([THREE.Vector3.set](https://threejs.org/docs/index.html#api/en/math/Vector3.set)), so you can pass an array `position={[100, 0, 0]}`.\n\n#### Shortcuts and non-Object3D stow-away\n\nStow away non-Object3D primitives (geometries, materials, etc) into the render tree so that they become managed and reactive. They take the same properties they normally would, constructor arguments are passed with `args`. Using the `attach` property objects bind automatically to their parent and are taken off it once they unmount.\n\nYou can nest primitive objects, too, which is good for awaiting async textures and such. You could use React-suspense if you wanted!\n\n```jsx\n<meshBasicMaterial attach=\"material\">\n  <texture attach=\"map\" image={img} onUpdate={self => img && (self.needsUpdate = true)} />\n```\n\nSometimes attaching isn't enough. For example, this code attaches effects to an array called \"passes\" of the parent `effectComposer`. Note the use of `attachArray` which adds the object to the target array and takes it out on unmount:\n\n```jsx\n<effectComposer>\n  <renderPass attachArray=\"passes\" scene={scene} camera={camera} />\n  <glitchPass attachArray=\"passes\" renderToScreen />\n```\n\nYou can also attach to named parent properties using `attachObject={[target, name]}`, which adds the object and takes it out on unmount. The following adds a buffer-attribute to parent.attributes.position.\n\n```jsx\n<bufferGeometry attach=\"geometry\">\n  <bufferAttribute attachObject={['attributes', 'position']} count={v.length / 3} array={v} itemSize={3} />\n```\n\n#### Piercing into nested properties\n\nIf you want to reach into nested attributes (for instance: `mesh.rotation.x`), just use dash-case:\n\n```jsx\n<mesh rotation-x={1} material-uniforms-resolution-value={[1 / size.width, 1 / size.height]} />\n```\n\n#### Putting already existing objects into the scene-graph\n\nYou can use the `primitive` placeholder for that. You can still give it properties or attach nodes to it.\n\n```jsx\nconst mesh = new THREE.Mesh()\nreturn <primitive object={mesh} position={[0, 0, 0]} />\n```\n\n#### Using 3rd-party (non THREE namespaced) objects in the scene-graph\n\nThe `extend` function extends three-fibers catalogue of known native JSX elements.\n\n```jsx\nimport { extend } from 'react-three-fiber'\nimport { EffectComposer } from 'three/examples/jsm/postprocessing/EffectComposer'\nimport { RenderPass } from 'three/examples/jsm/postprocessing/RenderPass'\nextend({ EffectComposer, RenderPass })\n\n<effectComposer>\n  <renderPass />\n```\n\n# Events\n\nThreejs objects that implement their own `raycast` method (meshes, lines, etc) can be interacted with by declaring events on the object. We support pointer events ([you need to polyfill them yourself](https://github.com/jquery/PEP)), clicks and wheel-scroll. Events contain the browser event as well as the Threejs event data (object, point, distance, etc).\n\nAdditionally there's a special `onUpdate` that is called every time the object gets fresh props, which is good for things like `self => (self.verticesNeedUpdate = true)`.\n\n```jsx\n<mesh\n  onClick={e => console.log('click')}\n  onWheel={e => console.log('wheel spins')}\n  onPointerUp={e => console.log('up')}\n  onPointerDown={e => console.log('down')}\n  onPointerOver={e => console.log('over')}\n  onPointerOut={e => console.log('out')}\n  onPointerEnter={e => console.log('enter')}\n  onPointerLeave={e => console.log('leave')}\n  onPointerMove={e => console.log('move')}\n  onUpdate={self => console.log('props have been updated')}\n/>\n```\n\n#### Event data\n\n```jsx\n({\n  ...DomEvent                   // All the original event data\n  ...ThreeEvent                 // All of Three's intersection data\n  object: Object3D              // The object that was actually hit\n  eventObject: Object3D         // The object that registered the event\n  unprojectedPoint: Vector3     // Camera-unprojected point\n  ray: Ray                      // The ray that was used to strike the object\n  camera: Camera                // The camera that was used in the raycaster\n  sourceEvent: DomEvent         // A reference to the host event\n  delta: number                 // Initial-click delta\n}) => ...\n```\n\n#### Propagation and capturing\n\n```jsx\n  onPointerDown={e => {\n    // Only the mesh closest to the camera will be processed\n    e.stopPropagation()\n    // You may optionally capture the target\n    e.target.setPointerCapture(e.pointerId)\n  }}\n  onPointerUp={e => {\n    e.stopPropagation()\n    // Optionally release capture\n    e.target.releasePointerCapture(e.pointerId)\n  }}\n```\n\n# Hooks\n\nHooks can only be used **inside** the Canvas element because they rely on context! You cannot expect something like this to work:\n\n```jsx\nfunction App() {\n  const { size } = useThree() // This will just crash\n  return (\n    <Canvas>\n      <mesh>\n```\n\nDo this instead:\n\n```jsx\nfunction SomeComponent() {\n  const { size } = useThree()\n  return <mesh />\n}\n\nfunction App() {\n  return (\n    <Canvas>\n      <SomeComponent />\n```\n\n#### useThree(): SharedCanvasContext\n\nThis hooks gives you access to all the basic objects that are kept internally, like the default renderer, scene, camera. It also gives you the current size of the canvas in screen and viewport coordinates.\n\n```jsx\nimport { useThree } from 'react-three-fiber'\n\nconst {\n  gl,                           // WebGL renderer\n  scene,                        // Default scene\n  camera,                       // Default camera\n  size,                         // Bounds of the view (which stretches 100% and auto-adjusts)\n  viewport,                     // Bounds of the viewport in 3d units + factor (size/viewport)\n  aspect,                       // Aspect ratio (size.width / size.height)\n  mouse,                        // Current 2D mouse coordinates\n  clock,                        // THREE.Clock (useful for useFrame deltas)\n  invalidate,                   // Invalidates a single frame (for <Canvas invalidateFrameloop />)\n  intersect,                    // Calls onMouseMove handlers for objects underneath the cursor\n  setDefaultCamera,             // Sets the default camera\n} = useThree()\n```\n\n#### useFrame(callback: (state, delta) => void, renderPriority: number = 0)\n\nThis hooks calls you back every frame, which is good for running effects, updating controls, etc. You receive the state (same as useThree) and a clock delta. If you supply a render priority greater than zero it will switch off automatic rendering entirely, you can then control rendering yourself. If you have multiple frames with a render priority then they are ordered highest priority last, similar to the web's z-index. Frames are managed, three-fiber will remove them automatically when the component that holds them is unmounted.\n\nUpdating controls:\n\n```jsx\nimport { useFrame } from 'react-three-fiber'\n\nconst controls = useRef()\nuseFrame(state => controls.current.update())\nreturn <orbitControls ref={controls} />\n```\n\nTaking over the render-loop:\n\n```jsx\nuseFrame(({ gl, scene, camera }) => gl.render(scene, camera), 1)\n```\n\n#### useResource(optionalRef=undefined)\n\nWhen you want to share and re-use resources. `useResource` creates a ref and re-renders the component when it becomes available next frame.\n\n```jsx\nimport { useResource } from 'react-three-fiber'\n\nconst [ref, material] = useResource()\nreturn (\n  <meshBasicMaterial ref={ref} />\n  {material && (\n    <mesh material={material} />\n    <mesh material={material} />\n    <mesh material={material} />\n```\n\n#### useUpdate(callback, dependencies, optionalRef=undefined)\n\nWhen objects need to be updated imperatively.\n\n```jsx\nimport { useUpdate } from 'react-three-fiber'\n\nconst ref = useUpdate(\n  geometry => {\n    geometry.addAttribute('position', getVertices(x, y, z))\n    geometry.attributes.position.needsUpdate = true\n  },\n  [x, y, z] // execute only if these properties change\n)\nreturn <bufferGeometry ref={ref} />\n```\n\n#### useLoader(loader, url: string | string[], extensions?) (experimental!)\n\nThis hooks loads assets and suspends for easier fallback- and error-handling. If you need to lay out GLTF's declaratively check out [gltfjsx](https://github.com/react-spring/gltfjsx).\n\n```jsx\nimport React, { Suspense } from 'react'\nimport { useLoader } from 'react-three-fiber'\nimport { GLTFLoader } from 'three/examples/jsm/loaders/GLTFLoader'\n\nfunction Asset({ url }) {\n  const gltf = useLoader(GLTFLoader, url)\n  return <primitive object={gltf.scene} />\n}\n\n<Suspense fallback={<Cube />}>\n  <Asset url=\"/spaceship.gltf\" />\n</Suspense>\n```\n\nYou can provide a callback if you need to configure your loader:\n\n```jsx\nimport { DRACOLoader } from 'three/examples/jsm/loaders/DRACOLoader'\n\nuseLoader(GLTFLoader, url, loader => {\n  const dracoLoader = new DRACOLoader()\n  dracoLoader.setDecoderPath('/draco-gltf/')\n  loader.setDRACOLoader(dracoLoader)\n})\n```\n\nIt can also make multiple requests in parallel:\n\n```jsx\nconst [bumpMap, specMap, normalMap] = useLoader(TextureLoader, [url1, url2, url2])\n```\n\n#### useCamera(camera, props) (experimental!)\n\nThis is a special purpose hook for the rare case when you are using non-default cameras for heads-up-displays or portals, and you need events/raytracing to function properly (raycasting uses the default camera otherwise).\n\n```jsx\nimport { useCamera } from 'react-three-fiber'\n\n<mesh raycast={useCamera(customCamera)} onPointerMove={e => console.log('move')}>\n```\n\n# Additional exports\n\n```jsx\nimport {\n  addEffect,                    // Adds a global callback which is called each frame\n  invalidate,                   // Forces view global invalidation\n  extend,                       // Extends the native-object catalogue\n  createPortal,                 // Creates a portal (it's a React feature for re-parenting)\n  render,                       // Internal: Renders three jsx into a scene\n  unmountComponentAtNode,       // Internal: Unmounts root scene\n  applyProps,                   // Internal: Sets element properties\n  Dom,                          // Project HTML content\n} from 'react-three-fiber'\n```\n\n#### Dom (experimental, web-only!)\n\nSometimes you want to project dom-content on top (or underneath) of the canvas. The experimental `Dom` component behaves like a generic `THREE.Group` internally, you can transform and nest it inside the canvas. It's children on the other hand will be rendered into a separate dom container. They will be projected to the groups whereabouts.\n\n```jsx\nimport { Canvas, Dom } from 'react-three-fiber'\n\n<Canvas>\n  <Dom prepend position={[100, 0, 100]}>\n    <h1>hello world!</h1>\n  </Dom>\n</Canvas>\n```\n\n# Further information\n\nRecipes and FAQ: [/react-three-fiber/recipes.md](recipes.md)\n\nGLTF-to-JSX converter: https://github.com/react-spring/gltfjsx\n\nLearn-with-jason: https://www.youtube.com/watch?v=1rP3nNY2hTo\n\n# Contributions\n\nIf you like this project, please consider helping out. All contributions are welcome as well as donations to [Opencollective](https://opencollective.com/react-three-fiber), or in crypto:\n\nBTC: 36fuguTPxGCNnYZSRdgdh6Ea94brCAjMbH\n\nETH: 0x6E3f79Ea1d0dcedeb33D3fC6c34d2B1f156F2682\n\n#### Sponsors\n\n<a href=\"https://opencollective.com/react-three-fiber/sponsor/0/website\" target=\"_blank\">\n  <img src=\"https://opencollective.com/react-three-fiber/sponsor/0/avatar.svg\"/>\n</a>\n<a href=\"https://opencollective.com/react-three-fiber/sponsor/1/website\" target=\"_blank\">\n  <img src=\"https://opencollective.com/react-three-fiber/sponsor/1/avatar.svg\"/>\n</a>\n\n#### Backers\n\nThank you to all our backers! 🙏\n\n<a href=\"https://opencollective.com/react-three-fiber#backers\" target=\"_blank\">\n  <img src=\"https://opencollective.com/react-three-fiber/backers.svg?width=890\"/>\n</a>\n\n##### Contributors\n\nThis project exists thanks to all the people who contribute.\n\n<a href=\"https://github.com/react-spring/react-three-fiber/graphs/contributors\">\n  <img src=\"https://opencollective.com/react-three-fiber/contributors.svg?width=890\" />\n</a>\n","license":"MIT","private":false,"_npmUser":{"name":"drcmda","email":"drcmda@gmail.com"},"homepage":"https://github.com/drcmda/react-three-fiber#readme","keywords":["react","renderer","fiber","three","threejs"],"collective":{"url":"https://opencollective.com/react-three-fiber","type":"opencollective"},"repository":{"url":"git+https://github.com/drcmda/react-three-fiber.git","type":"git"},"_npmVersion":"6.10.3","description":"React-fiber renderer for THREE.js","directories":{},"maintainers":[{"name":"drcmda","email":"drcmda@gmail.com"}],"sideEffects":false,"_nodeVersion":"12.9.1","contributors":[{"name":"Birkir Gudjonsson","email":"birkir.gudjonsson@gmail.com"}],"dependencies":{"scheduler":"0.17.0","tiny-emitter":"^2.1.0","@babel/runtime":"^7.7.1","react-merge-refs":"^1.0.0","react-reconciler":"0.23.0","react-use-measure":"^2.0.0","react-promise-suspense":"^0.3.1","@juggle/resize-observer":"^2.4.0","resize-observer-polyfill":"^1.5.1"},"react-native":"native.js","_hasShrinkwrap":false,"readmeFilename":"readme.md","peerDependencies":{"react":">=16.11","three":">=0.110","react-dom":">=16.11"},"_npmOperationalInternal":{"tmp":"tmp/react-three-fiber_4.0.0-beta.7_1575240686424_0.8353246638283969","host":"s3://npm-registry-packages"},"_id":"react-three-fiber@4.0.0-beta.7","version":"4.0.0-beta.7"}