{"bugs":{"url":"https://github.com/drcmda/react-three-fiber/issues"},"dist":{"shasum":"21be4b08bfce3239904c6a8f4c0656ade6983e15","tarball":"https://registry.npmjs.org/react-three-fiber/-/react-three-fiber-1.3.0-beta.0.tgz","fileCount":12,"integrity":"sha512-eE30GSiVotbf1iiCUiD41xjpNGEGNZJWeC6pyXk8z7i1Fayiz2JRA5I6QxI9l+l/XXaw/NdjaoAsFidAEKnp1w==","signatures":[{"sig":"MEQCIGS4KxO8E01JJtpeMkzMYC+qgbpwBry3dtUUnlfCsF1CAiBXsQxYu55QtdPIj8LfnuH96m/dkJpH0OdPN+BlnI1IDg==","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":257965,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.4\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJcgjKmCRA9TVsSAnZWagAAf3wP/1LqzxeSA4azSHMMueEU\nZPF0qEu1/T9jqSabgfRmcQXNCFnqM7Pdma1uvBciKmIf4t1zBLeV4zI8aWc5\nYy4T1gcZlpn0+WgETjOg5yIuXXDOlDO8fygwLFHj66HAmhJsuJDfO4gVLxeJ\nGSeFhZG+gGgJZ9xAD4DSspgHhXHSmYFEf7SxfL0+//YjKS2v4vFfOUdm+7wA\nUNsv3OTo560Wm/2H42MW5uLuOdTjhA880066u4FhxqPd4Re08Ryv51S0KBNq\nw5B/BmUATrqfSlUXtaUyeJV6uhzhXtwfeJpYiCEo8NsPPO5cIhd/9X6owmLT\nj/tueeglTr9dDFUbWRj2Yp89vLxEQDgIrbV/G1dmqV+aa9jSvV4IjVl1rkDJ\nxZ2VpZbcAqQvYFE6D5UMGoC/hFMVtPM2p+AXWFl1TF0v7fusWUWpetiXReCA\ng9wnuZlsFmvDWjXyWG2P1hGryVM8XucdEnFCu5zFr8U+M0nkcVfD+6oRYJKJ\n7//paGbI//zPE3VKaNvJ6G503yANm0w/D6dEMVjSojBOynNRzwC/KiQS//uf\ngqomVASoc4aDefrKb5pONM3DWiUmzsYvRczm7iLP4mdIa0LHhds1jIklvNZI\nJnx3hXm4WPXMOYHUzfbgERPJnYLuURwgKOCd2/0wvY0MNdVhwU0qS+OG9VB4\nnRRH\r\n=f4XB\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.cjs.js","name":"react-three-fiber","husky":{"hooks":{"pre-commit":"lint-staged"}},"author":{"name":"Paul Henschel"},"module":"dist/index.js","readme":"<p align=\"center\">\n  <a href=\"https://codesandbox.io/embed/9y8vkjykyy\"><img width=\"430\" src=\"https://i.imgur.com/tQi753C.gif\" /></a>\n  <a href=\"https://codesandbox.io/embed/y3j31r13zz\"><img width=\"430\" src=\"https://i.imgur.com/iFtjKHM.gif\" /></a>\n</p>\n<p align=\"middle\">\n  <i>These demos are real, click them!</i>\n</p>\n\n    npm install react-three-fiber\n\nReact-three-fiber is a small React renderer for THREE-js. Driving THREE as a render-target makes just as much sense as it makes for the DOM. Building a complex scene graph becomes easier because it can be componentized declaratively with clean, reactive semantics. This also opens up the eco system, you can now apply generic packages for state, animation, gestures, etc.\n\n#### Difference to react-three, react-three-renderer, react-three-renderer-fiber\n\nWe ship a small reconciler config with a few additions for interaction. It does not know or care about THREE deeply, it uses heuristics to support attributes generically, so we can get away without creating a strong dependency. Hooks of course hold it all together. The aforementioned libs served as an inspiration.\n\n# How it looks like ...\n\n```jsx\nimport { Canvas } from 'react-three-fiber'\n\nfunction Thing({ vertices, color }) {\n  return (\n    <group ref={ref => console.log('we have access to the instance')}>\n      <line position={[10, 20, 30]} rotation={[THREE.Math.degToRad(90), 0, 0]}>\n        <geometry\n          name=\"geometry\"\n          vertices={vertices.map(v => new THREE.Vector3(...v))}\n          onUpdate={self => (self.verticesNeedUpdate = true)}\n        />\n        <lineBasicMaterial name=\"material\" color={color} />\n      </line>\n      <mesh\n        onClick={e => console.log('click')}\n        onHover={e => console.log('hover')}\n        onUnhover={e => console.log('unhover')}>\n        <octahedronGeometry name=\"geometry\" />\n        <meshStandardMaterial name=\"material\" color=\"grey\" opacity={0.5} transparent />\n      </mesh>\n    </group>\n  )\n}\n\nReactDOM.render(\n  <Canvas>\n    <Thing color=\"blue\" vertices={[[-1, 0, 0], [0, 1, 0], [1, 0, 0]]} />\n  </Canvas>,\n  document.getElementById('root')\n)\n```\n\n# Objects and properties\n\nYou can use [THREE's entire object catalogue and all properties](https://threejs.org/docs). When in doubt, always consult the docs.\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('indianred'), transparent: true })} />\n```\n\n#### Shortcuts and non-Object3D stow-away\n\nAll properties that have a `.set()` method (colors, vectors, euler, matrix, etc) 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('peachpuff')` you can do `color=\"peachpuff\"`. Some set-methods take multiple arguments (vectors for instance), in this case you can pass an array.\n\nYou can stow 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`. If you give them a name they attach automatically to their parent.\n\nThe following is the same as above, but it's leaner and critical properties aren't re-instanciated on every render.\n\n```jsx\n<mesh visible userData={ test: \"hello\" } position={[1, 2, 3]} rotation={[0, 0, 0]}>\n  <sphereGeometry name=\"geometry\" args={[1, 16, 16]} />\n  <meshStandardMaterial name=\"material\" color=\"indianred\" transparent />\n</mesh>\n```\n\nYou can nest primitive objects, good for awaiting async textures and such. You could use React-suspense if you wanted!\n\n```jsx\n<meshBasicMaterial name=\"material\">\n  <texture\n    name=\"map\"\n    format={THREE.RGBFormat}\n    image={img}\n    onUpdate={self => img && (self.needsUpdate = true)} />\n</meshBasicMaterial>\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-color=\"lightblue\" geometry-vertices={newVertices} />\n```\n\n#### Extending or using arbitrary objects\n\nWhen you need managed local (or custom/extended) objects, you can use the `primitive` placeholder.\n\n```jsx\nconst msh = new THREE.Mesh()\nreturn <primitive object={msh} />\n```\n\n# Events\n\nTHREE objects that implement their own `raycast` method (for instance meshes, lines, etc) can be interacted with by declaring events on the object. For now that's prop-updates (very useful for things like `verticesNeedUpdate`), hovering-state and clicks. Touch follows soon!\n\n```jsx\n<mesh\n  onClick={e => console.log('click')}\n  onHover={e => console.log('hover')}\n  onUnhover={e => console.log('unhover')}\n  onUpdate={self => console.log('props have been updated')}\n/>\n```\n\n# Gl data & hooking into the render loop\n\nSometimes you're running effects, postprocessing, etc that needs to get updated. You can fetch the renderer, the camera, scene, and a render-loop subscribe to do this.\n\n```jsx\nimport { Canvas, useRender, useThree } from 'react-three-fiber'\n\nfunction App() {\n  // gl is the webgl-renderer\n  // canvas the dom element that was created\n  // size the bounds of the view (which stretches 100% and auto-adjusts)\n  // viewport is the calculated screen-size, it's a function\n  const { gl, canvas, scene, camera, size, viewport } = useThree()\n  // Subscribes to the render-loop, gets cleaned up automatically when the component unmounts\n  // Add a \"true\" as the 2nd argument and you take over the render-loop \n  useRender(({ gl, canvas, scene, camera }) => console.log(\"i'm in the render-loop\"))\n  return <group />\n}\n```\n\n# Receipes\n\n## Handling loaders\n\n```jsx\nfunction Image({ url }) {\n  const texture = useMemo(() => new THREE.TextureLoader().load(url), [url])\n  return (\n    <mesh>\n      <planeBufferGeometry name=\"geometry\" args={[1, 1]} />\n      <meshLambertMaterial name=\"material\" transparent>\n        <primitive name=\"map\" object={texture} />\n      </meshLambertMaterial>\n    </mesh>\n  )\n}\n```\n\n## Dealing with effects (hijacking main render-loop)\n\n```jsx\nimport { apply, Canvas, useRender, useThree } from 'react-three-fiber'\nimport { EffectComposer } from './impl/postprocessing/EffectComposer'\nimport { RenderPass } from './impl/postprocessing/RenderPass'\nimport { GlitchPass } from './impl/postprocessing/GlitchPass'\n// Makes these objects available as native objects \"<renderPass />\" and so on\napply({ EffectComposer, RenderPass, GlitchPass })\n\nfunction Effects({ factor }) {\n  const { gl, scene, camera, size } = useThree()\n  const composer = useRef()\n  useEffect(() => void composer.current.obj.setSize(size.width, size.height), [size.width, size.height])\n  // This takes over as the main render-loop (when 2nd arg is set to true)\n  useRender(() => composer.current.obj.render(), true)\n  return (\n    <effectComposer ref={composer} args={[gl]}>\n      <renderPass name=\"passes\" args={[scene, camera]} />\n      <glitchPass name=\"passes\" renderToScreen factor={factor} />\n    </effectComposer>\n  )\n}\n```\n\n## Heads-up display (rendering multiple scenes)\n\n```jsx\nfunction Hud() {\n  const scene = useRef()\n  const hud = useRef()\n\n  const cam = useRef()\n  const { size: { aspect, width, height} } = useThree()\n  const [data, set] = useState({ aspect: 0, radius: 0 })\n  useEffect(() => void set({ aspect, radius: (width + height) / 4 }), [width, height])\n  \n  // This takes over as the main render-loop (when 2nd arg is set to true)\n  useRender(({ gl }) => {\n    gl.autoClear = true\n    gl.render(scene.current, cam.current)\n    gl.autoClear = false\n    gl.clearDepth()\n    gl.render(hud.current, cam.current)\n  }, true)\n\n  return (\n    <>\n      <scene ref={scene}>\n        <perspectiveCamera\n          {...data}\n          ref={cam}\n          position={[0, 0, 5]}\n          onUpdate={self => self.updateProjectionMatrix()} />\n        {/* Main scene ... */}\n      </scene>\n      <scene ref={hud}>\n        {/* This scene will be projected on top... */}\n      </scene>\n    </>\n  )\n}\n```\n","gitHead":"0b51aef73909af7bfa5b7e21dc3cca2ef6a6067e","license":"MIT","scripts":{"test":"echo \"Error: no test specified\" && exit 1","build":"rollup -c","prepare":"npm run build","prebuild":"rimraf dist"},"_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},"repository":{"url":"git+https://github.com/drcmda/react-three-fiber.git","type":"git"},"_npmVersion":"6.4.1","description":"React-fiber renderer for THREE.js","directories":{},"lint-staged":{"*.{js,}":["prettier --write","git add"]},"maintainers":[{"name":"drcmda","email":"drcmda@gmail.com"}],"sideEffects":false,"_nodeVersion":"11.1.0","dependencies":{"scheduler":"^0.13.3","@babel/runtime":"^7.3.4","react-reconciler":"^0.20.1","resize-observer-polyfill":"^1.5.1"},"_hasShrinkwrap":false,"readmeFilename":"readme.md","devDependencies":{"husky":"^1.3.1","rollup":"^1.4.1","prettier":"^1.16.4","typescript":"^3.3.3333","@babel/core":"7.3.4","lint-staged":"^8.1.5","@babel/preset-env":"7.3.4","@babel/preset-react":"7.0.0","rollup-plugin-babel":"^4.3.2","rollup-plugin-commonjs":"^9.2.1","@babel/preset-typescript":"^7.3.3","rollup-plugin-node-resolve":"^4.0.1","rollup-plugin-size-snapshot":"^0.8.0","@babel/plugin-transform-runtime":"7.3.4","@babel/plugin-transform-parameters":"7.3.3","@babel/plugin-proposal-do-expressions":"7.2.0","@babel/plugin-proposal-class-properties":"7.3.4","@babel/plugin-transform-modules-commonjs":"7.2.0","@babel/plugin-proposal-object-rest-spread":"7.3.4","@babel/plugin-transform-template-literals":"7.2.0","babel-plugin-transform-react-remove-prop-types":"^0.4.24"},"peerDependencies":{"react":">=16.8","three":">=100","react-dom":">=16.8"},"_npmOperationalInternal":{"tmp":"tmp/react-three-fiber_1.3.0-beta.0_1552036518358_0.4174704827969513","host":"s3://npm-registry-packages"},"_id":"react-three-fiber@1.3.0-beta.0","version":"1.3.0-beta.0"}