{"bin":{"react-three-fiber":"./tools/index.js"},"bugs":{"url":"https://github.com/drcmda/react-three-fiber/issues"},"dist":{"shasum":"8a57cad86e695455c1476578be2bcee59db54919","tarball":"https://registry.npmjs.org/react-three-fiber/-/react-three-fiber-3.0.0-beta.6.tgz","fileCount":35,"integrity":"sha512-P9iOgq19s/VLHDN/A0TvDBix9MMM5Tv8Hq5Wb1JPifhGwVtM1nC6Wk9HvsKZvdXE2qA2iTGQvXrEwmORvdvJ4g==","signatures":[{"sig":"MEUCIDz7OlAD6JEZXTiFsikDXL0PTmsABzk5rRU9fTVS+RDAAiEAxAemeLIlhfgTedcTD7aO31W/4PesljXKh/mNKnHCt34=","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":272392,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.4\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJdepbyCRA9TVsSAnZWagAA450P/3ZZtKdVplcv3tun3V8k\n0viMzq8bbLfT9r3Omeeaq+Qy2dSdsNjvu4KJKrh2UA6b/9agHLsSKv4eHRsR\n7b9KtRQbzhJkcaKEeL6MpqxRM9B9m7djyUnxqYDwEA+Q3LT/EdK/8dNRiTU5\nOjZjqsTdCfo/7xgdV1twTcU5fu4WxqPw4UslmIwf2EHIVLuxwh//PYdm2HCr\nGpRlttumy4w9ZbDnBkhxYoroyhZh+IKVurWDszzo/vxE4ZOvxEusqnfX6Udy\nWSbv2HtFtvyLOX4IogPBb6DZoZf3y1gLQB5TlaWFkG0Wv0xkYfbPWAFjf0zl\nN8EL5E4lkWVvb7182ItHoAPNNAJdpClLlokBKTobwV7MTDeTIi6aAFYTmJ8J\ntzwto3lBeWzZcOdlk7IDT3xRXHwjnZ+mAzESTPr3cMKY/BAkg19bHPRfLvlH\nNkrediiAylFDZwNXIKSBhsuumMSkBscXDHTBR7OXZutj4HodcjoRTLHtdGQg\npaY8glcfUsIpGTXUd2bun66XmqI3uT7IdKpGjmIEXpLObsnFi24hQ/cEbPZT\nLehTiXTm+qntagOkroDWDIxjhaMgLD7WPGKtv3fUcLwE+htXnsgCiTj+IsEd\nW650rFq/EOiwbrp1DXw5G6JIAgfAQ/asiJ0DpugiY4bmVZmNVlgss+hFjXk2\n/yqi\r\n=G3iO\r\n-----END PGP SIGNATURE-----\r\n"},"main":"./dist/web.cjs.js","name":"react-three-fiber","husky":{"hooks":{"pre-commit":"lint-staged"}},"types":"./types/index.d.ts","author":{"name":"Paul Henschel"},"module":"./dist/web.js","readme":"<p align=\"center\">\n  <a href=\"https://github.com/drcmda/learnwithjason\"><img width=\"288\" height=\"172\" 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=\"172\" src=\"https://i.imgur.com/8xpKFkN.gif\" /></a>\n  <a href=\"https://codesandbox.io/embed/387z7o2zrq\"><img width=\"288\" height=\"172\" src=\"https://i.imgur.com/YewcWL5.gif\" /></a>\n  <a href=\"https://codesandbox.io/embed/m7q0r29nn9\"><img width=\"288\" height=\"172\" src=\"https://i.imgur.com/LDddjjC.gif\" /></a>\n  <a href=\"https://codesandbox.io/embed/jz9l97qn89\"><img width=\"288\" height=\"172\" src=\"https://i.imgur.com/zrhe5Jc.gif\" /></a>\n  <a href=\"https://codesandbox.io/embed/kky7yk087v\"><img width=\"288\" height=\"172\" src=\"https://i.imgur.com/jemlXzE.gif\" /></a>\n  <a href=\"https://codesandbox.io/embed/ly0oxkp899\"><img width=\"288\" height=\"172\" src=\"https://i.imgur.com/vjmDwpS.gif\" /></a>\n  <a href=\"https://codesandbox.io/embed/9y8vkjykyy\"><img width=\"288\" height=\"172\" src=\"https://i.imgur.com/tQi753C.gif\" /></a>\n  <a href=\"https://codesandbox.io/embed/y3j31r13zz\"><img width=\"288\" height=\"172\" 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\nReact-three-fiber is a small React renderer for Threejs on the web and react-native. Why, you might ask? React was made to drive complex tree structures, it makes just as much sense for Threejs as for the DOM. Building a dynamic scene graph becomes so much easier because you can break it up into declarative, re-usable components with clean, reactive semantics. This also opens up the ecosystem, you can now apply generic packages for state, animation, gestures and so on.\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.z += 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      <planeBufferGeometry attach=\"geometry\" args={[1, 1]} />\n      <meshBasicMaterial attach=\"material\" color=\"hotpink\" opacity={0.5} transparent />\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  orthographic = false          // Creates an orthographic camera if true\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\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\nThe problem is that all of these properties will be re-created on every render pass. 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('hover')}\n  onPointerOut={e => console.log('unhover')}\n  onPointerMove={e => console.log('move')}\n  onUpdate={self => console.log('props have been updated')} />\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\nfunciton App() {\n  const { size } = useThree() // This will just crash\n  return (\n    <Canvas>\n      <mesh>\n```\n\nDo this instead:\n\n```jsx\nfunciton SomeComponent() {\n  const { size } = useThree()\n  return <mesh />\n}\n        \nfunciton App() {\n  return (\n    <Canvas>\n      <SomeComponent />\n```\n\n#### useThree()\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  canvas,           // canvas the dom element that was created\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  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, priority=0)\n\nWhen you're running effects, postprocessings, controls, etc that need to get updated every frame. You receive the internal state as well, which is the same as what you would get from useThree.\n\n```jsx\nimport { useFrame } from 'react-three-fiber'\n\n// Subscribes to the render-loop, gets cleaned up automatically when the component unmounts\nuseFrame(state => console.log(\"I'm in the render-loop\"))\n\n// Add a priority as the 2nd argument and you have to take care of rendering yourself\n// If you have multiple frames that render, they are ordered after the priority you give it\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, [extensions]) (experimental!)\n\nWhen you want to write out a loaded object declaratively, where you get to lay events on objects, alter materials, etc. It loads a file (which must be present in your /public folder) and caches it. It returns an array of geometry/material pairs.\n\n```jsx\nimport { useLoader } from 'react-three-fiber'\nimport { GLTFLoader } from 'three/examples/jsm/loaders/GLTFLoader'\nimport { DRACOLoader } from 'three/examples/jsm/loaders/DRACOLoader'\n\nconst model = useLoader(GLTFLoader, '/spaceship.gltf', loader => {\n  const dracoLoader = new DRACOLoader()\n  dracoLoader.setDecoderPath('/draco-gltf/')\n  loader.setDRACOLoader(dracoLoader)\n}))\nreturn model.map(({ geometry, material }) => (\n  <mesh key={geometry.uuid} geometry={geometry} castShadow>\n    <meshStandardMaterial attach=\"material\" map={material.map} roughness={1} />\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  apply,                  // 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} from 'react-three-fiber'\n```\n\n# Further information\n\nRecipes and FAQ: [/react-three-fiber/recipes.md](https://github.com/react-three-fiber/react-three-fiber/blob/master/recipes.md)\n\nReact-podcast episode: https://reactpodcast.simplecast.fm/56\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","gitHead":"29c65ed6f23ad1578d9f3689ef1c43f79c0d1150","license":"MIT","scripts":{"test":"echo \"Error: no test specified\" && exit 1","build":"rollup -c","eslint":"eslint ./src","prepare":"npm run build","typegen":"tsc || true && prettier types/**/** --write","prebuild":"rimraf dist && npm run typegen","typecheck":"tsc --noEmit --strict --jsx react src/*"},"_npmUser":{"name":"drcmda","email":"drcmda@gmail.com"},"homepage":"https://github.com/drcmda/react-three-fiber#readme","keywords":["react","renderer","fiber","three","threejs"],"prettier":{"semi":false,"tabWidth":2,"printWidth":120,"singleQuote":true,"trailingComma":"es5","jsxBracketSameLine":true},"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":{},"lint-staged":{"*.{js,jsx,ts,tsx}":["prettier --write","git add"]},"maintainers":[{"name":"drcmda","email":"drcmda@gmail.com"}],"sideEffects":false,"_nodeVersion":"12.9.1","contributors":[{"name":"Birkir Gudjonsson","email":"birkir.gudjonsson@gmail.com"}],"dependencies":{"three":"^0.105.0","lodash-es":"^4.17.15","scheduler":"0.13.3","@types/three":"^0.103.2","tiny-emitter":"^2.1.0","@babel/runtime":"^7.4.4","react-reconciler":"0.20.4","pointer-events-polyfill":"^0.4.4-pre","resize-observer-polyfill":"^1.5.1"},"react-native":"./dist/native.js","_hasShrinkwrap":false,"readmeFilename":"readme.md","devDependencies":{"husky":"^2.1.0","react":"^16.8.6","three":"^0.107.0","eslint":"^5.16.0","rollup":"^1.19.4","cypress":"^3.2.0","expo-gl":"^6.0.0","wait-on":"^3.2.0","prettier":"^1.18.2","react-dom":"^16.8.6","expo-three":"^5.0.0","typescript":"^3.5.3","@babel/core":"7.4.4","lint-staged":"^8.1.5","@types/react":"^16.9.1","babel-eslint":"^10.0.1","@types/lodash-es":"^4.17.3","@types/scheduler":"^0.12.1","@babel/preset-env":"7.4.4","rollup-plugin-json":"^4.0.0","@babel/preset-react":"7.0.0","@types/react-native":"^0.60.11","rollup-plugin-babel":"^4.3.2","eslint-plugin-import":"^2.17.2","eslint-config-prettier":"^4.2.0","rollup-plugin-commonjs":"^9.3.4","@types/react-reconciler":"^0.18.0","@babel/preset-typescript":"^7.3.3","eslint-plugin-react-hooks":"^1.6.0","rollup-plugin-node-resolve":"^4.2.3","rollup-plugin-size-snapshot":"^0.8.0","@babel/plugin-transform-runtime":"7.4.4","@babel/plugin-transform-parameters":"7.4.4","@babel/plugin-proposal-do-expressions":"7.2.0","@babel/plugin-proposal-class-properties":"7.4.4","@babel/plugin-transform-modules-commonjs":"7.4.4","@babel/plugin-proposal-object-rest-spread":"7.4.4","@babel/plugin-transform-template-literals":"7.4.4","babel-plugin-transform-react-remove-prop-types":"^0.4.24"},"peerDependencies":{"react":">=16.9","three":">=0.105","react-dom":">=16.9"},"_npmOperationalInternal":{"tmp":"tmp/react-three-fiber_3.0.0-beta.6_1568315122057_0.8948149957996807","host":"s3://npm-registry-packages"},"_id":"react-three-fiber@3.0.0-beta.6","version":"3.0.0-beta.6"}