{"name":"@react-three/fiber","version":"8.0.0-alpha-01","keywords":["react","renderer","fiber","three","threejs"],"author":{"url":"https://github.com/drcmda","name":"Paul Henschel"},"license":"MIT","_id":"@react-three/fiber@8.0.0-alpha-01","maintainers":[{"name":"gsimone","email":"gianmarcosimone89@gmail.com"},{"name":"giulioz","email":"mail.zausa.giulio@gmail.com"},{"name":"stephencorwin","email":"stephenjcorwin@gmail.com"},{"name":"dropthebeatbro","email":"pilll.PL22@gmail.com"},{"name":"mlperego","email":"mlp.perego@gmail.com"},{"name":"sniok","email":"dubenko.oleksandr@gmail.com"},{"name":"iinfin","email":"han@iinf.in"},{"name":"codynova","email":"codyrnova@gmail.com"},{"name":"drcmda","email":"drcmda@gmail.com"},{"name":"marcofugaro","email":"marco.fugaro@gmail.com"},{"name":"alaric.baraou","email":"alaric.baraou@gmail.com"},{"name":"tdfka_rick","email":"Joshua.ellis18@gmail.com"},{"name":"stockhuman","email":"mikemingway@gmail.com"},{"name":"unframework","email":"nick.matantsev@gmail.com"}],"homepage":"https://github.com/pmndrs/react-three-fiber#readme","bugs":{"url":"https://github.com/pmndrs/react-three-fiber/issues"},"dist":{"shasum":"d39317de6fd5dc3f3d490ac75abb42e627c1b7f8","tarball":"http://registry-npm.ywwl.com/@react-three/fiber/download/@react-three/fiber-8.0.0-alpha-01.tgz","fileCount":20,"integrity":"sha512-VWCCU8bk/Xx/+TxZ84cMCUntfIQ7zl+jcoVRVM3Z/iAqoKWaLNj7Fa92saLnVsbGDpLT/FB3YT08EnI++apvTg==","signatures":[{"sig":"MEUCIQDYyFXJaSjWQaxvOYAmylsKoGxqawYNCB0kewS4tVa/zgIgEgEcpnzDbCFh+Ppzx7UxLC1R2Z6W+qtZYQ7sKKq2Muw=","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":236225,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.13\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJhMz1RCRA9TVsSAnZWagAAETMP/1Eqwv73R+4iU8U9LRB0\nsIcPu+mhD1sG+gQgiWwkKmeMHsOnAKIUxL3c578hz52x4s9aDjzPVe61QRmB\nQ1Tqdv+bkQTfuTQzdZVH/huCSsERFL5h9heVrXbJC6sm+tq9Ldr1XkCHMyXf\njOg/o11qpysS1zgckKDawjDJ5OmSpDnJQA+jeph+eDE+dqzdy0gI8ntXHzJ0\n2DxgV7Uebribkbh3W3ZCQCCwIPR4esE7MhaEwZxJCODwlnj8jlSn6VV2u+I9\nXEltMfk7NrLEtA5ypFKbrCgPJWm+/3v7WGhLabWyDr2qK+UrIn1UY/nVe082\no9ihP0HnKrHLMQillRD5O1rko97hl5jZmU7D4Qxmw7Dk6c+Fxabpzj/RS5bc\nlT+jjMIKGoR1gpNRbxFh+vruC2YVS77lRzkNRJ3eKna6POXWW2XMYECb0zQ4\nQbh/gruPQMpyrL5mdUOZTLqQ1/0zBtNPMbNOhgGQgeisjcv9HOUGs9VcLwul\nCEllWJ/oLuXNHZzNvVnp2VMIhP0WtIo+Ll3Epb7qWlkidMq6EGghjsLktTe+\nFgaiUxjRW/+gAVepWmLidRZ878XmHbk4StRKhfAbA1hWRey5Vw4vWuF8zzkb\n0Da4axjPAC4TnVw9R9lb8TMC6fiusAhxri/L6kz5D2vNdiH56PLgYT25kFq3\nrRR0\r\n=iFtN\r\n-----END PGP SIGNATURE-----\r\n","size":61563,"noattachment":false,"key":"/@react-three/fiber/-/@react-three/fiber-8.0.0-alpha-01.tgz"},"main":"dist/react-three-fiber.cjs.js","types":"dist/react-three-fiber.cjs.d.ts","module":"dist/react-three-fiber.esm.js","readme":"<h1>react-three-fiber</h1>\n\n[![Version](https://img.shields.io/npm/v/@react-three/fiber?style=flat&colorA=000000&colorB=000000)](https://npmjs.com/package/@react-three/fiber)\n[![Downloads](https://img.shields.io/npm/dt/react-three-fiber.svg?style=flat&colorA=000000&colorB=000000)](https://npmjs.com/package/@react-three/fiber)\n[![Twitter](https://img.shields.io/twitter/follow/pmndrs?label=%40pmndrs&style=flat&colorA=000000&colorB=000000&logo=twitter&logoColor=000000)](https://twitter.com/pmndrs)\n[![Discord](https://img.shields.io/discord/740090768164651008?style=flat&colorA=000000&colorB=000000&label=discord&logo=discord&logoColor=000000)](https://discord.gg/ZZjjNvJ)\n[![Open Collective](https://img.shields.io/opencollective/all/react-three-fiber?style=flat&colorA=000000&colorB=000000)](https://opencollective.com/react-three-fiber)\n[![ETH](https://img.shields.io/badge/ETH-f5f5f5?style=flat&colorA=000000&colorB=000000)](https://blockchain.com/eth/address/0x6E3f79Ea1d0dcedeb33D3fC6c34d2B1f156F2682)\n[![BTC](https://img.shields.io/badge/BTC-f5f5f5?style=flat&colorA=000000&colorB=000000)](https://blockchain.com/btc/address/36fuguTPxGCNnYZSRdgdh6Ea94brCAjMbH)\n\nreact-three-fiber is a <a href=\"https://reactjs.org/docs/codebase-overview.html#renderers\">React renderer</a> for threejs.\n\n```bash\nnpm install three @react-three/fiber\n```\n\n### Why?\n\nBuild your scene declaratively with re-usable, self-contained components that react to state, are readily interactive and can tap into React's ecosystem.\n\n#### Does it have limitations?\n\nNone. Everything that works in threejs will work here without exception.\n\n#### Can it keep up with frequent updates to threejs?\n\nYes, because it merely expresses threejs in JSX: `<mesh />` becomes `new THREE.Mesh()`, and that happens dynamically. There is no hard dependency on a particular threejs version, it does not wrap or duplicate a single threejs class.\n\n#### Is it slower than plain threejs?\n\nThere is no additional overhead. Components participate in the renderloop outside of React.\n\n### What does it look like?\n\n<table>\n  <tr>\n    <td>Let's make a re-usable component that has its own state, reacts to user-input and participates in the render-loop. (<a href=\"https://codesandbox.io/s/rrppl0y8l4?file=/src/App.js\">live demo</a>).</td>\n    <td>\n      <a href=\"https://codesandbox.io/s/rrppl0y8l4\">\n        <img src=\"https://i.imgur.com/sS4ArrZ.gif\" /></td>\n      </a>\n  </tr>\n</table>\n\n#### Imports first\n\n```jsx\nimport React, { useRef, useState } from 'react'\nimport ReactDOM from 'react-dom'\nimport { Canvas, useFrame } from '@react-three/fiber'\n```\n\n#### Define a component\n\n```jsx\nfunction Box(props) {\n  // This reference will give us direct access to the mesh\n  const mesh = useRef()\n  // Set up state for the hovered and active state\n  const [hovered, setHover] = useState(false)\n  const [active, setActive] = useState(false)\n  // Rotate mesh every frame, this is outside of React without overhead\n  useFrame(() => (mesh.current.rotation.x += 0.01))\n\n  return (\n    <mesh\n      {...props}\n      ref={mesh}\n      scale={active ? 1.5 : 1}\n      onClick={(event) => setActive(!active)}\n      onPointerOver={(event) => setHover(true)}\n      onPointerOut={(event) => setHover(false)}>\n      <boxGeometry args={[1, 2, 3]} />\n      <meshStandardMaterial color={hovered ? 'hotpink' : 'orange'} />\n    </mesh>\n  )\n}\n```\n\n#### Compose the scene\n\nEither use `Canvas`, which you can think of as a portal to threejs inside your regular dom graph. Everything within it is a [native threejs element](https://threejs.org/docs). If you want to mix Webgl and Html (react-dom) this is what you should use.\n\n```jsx\nReactDOM.render(\n  <Canvas>\n    <ambientLight />\n    <pointLight position={[10, 10, 10]} />\n    <Box position={[-1.2, 0, 0]} />\n    <Box position={[1.2, 0, 0]} />\n  </Canvas>,\n  document.getElementById('root'),\n)\n```\n\nOr use react-three-fibers own `render` function, which is a little more low-level but could save you the extra cost of carrying react-dom. It renders into a dom `canvas` element. Use this for Webgl-only apps.\n\n```jsx\nimport { render } from '@react-three/fiber'\n\nrender(<Scene />, document.querySelector('canvas'))\n```\n\n<details>\n  <summary>Show TypeScript example</summary>\n\n```tsx\nimport { Canvas, MeshProps, useFrame } from '@react-three/fiber'\n\nconst Box: React.FC<MeshProps> = (props) => {\n  // This reference will give us direct access to the mesh\n  const mesh = useRef<THREE.Mesh>(null!)\n  // Set up state for the hovered and active state\n  const [hovered, setHover] = useState(false)\n  const [active, setActive] = useState(false)\n  // Rotate mesh every frame, this is outside of React without overhead\n  useFrame(() => (mesh.current.rotation.x += 0.01))\n\n  return (\n    <mesh\n      {...props}\n      ref={mesh}\n      scale={active ? 1.5 : 1}\n      onClick={(event) => setActive(!active)}\n      onPointerOver={(event) => setHover(true)}\n      onPointerOut={(event) => setHover(false)}>\n      <boxGeometry args={[1, 2, 3]} />\n      <meshStandardMaterial color={hovered ? 'hotpink' : 'orange'} />\n    </mesh>\n  )\n}\n\nReactDOM.render(\n  <Canvas>\n    <ambientLight />\n    <pointLight position={[10, 10, 10]} />\n    <Box position={[-1.2, 0, 0]} />\n    <Box position={[1.2, 0, 0]} />\n  </Canvas>,\n  document.getElementById('root'),\n)\n```\n\n</details>\n\n---\n\n# Documentation\n\n- [api.md](/markdown/api.md)\n- [pitfalls.md](/markdown/pitfalls.md)\n- [testing.md](/packages/test-renderer)\n\n# Fundamentals\n\nYou need to be versed in both React and Threejs before rushing into this. If you are unsure about React consult the official [React docs](https://reactjs.org/docs/getting-started.html), especially [the section about hooks](https://reactjs.org/docs/hooks-reference.html). As for Threejs, make sure you at least glance over the following links:\n\n1. Make sure you have a [basic grasp of Threejs](https://threejs.org/docs/index.html#manual/en/introduction/Creating-a-scene). Keep that site open.\n2. When you know what a scene is, a camera, mesh, geometry, material, fork the [demo above](https://github.com/react-spring/react-three-fiber#what-does-it-look-like).\n3. [Look up](https://threejs.org/docs/index.html#api/en/objects/Mesh) the JSX elements that you see (mesh, ambientLight, etc), _all_ threejs exports are native to three-fiber.\n4. Try changing some values, scroll though our [Api](/markdown/api.md) to see what the various settings and hooks do.\n\nSome reading material:\n\n- [Threejs-docs](https://threejs.org/docs)\n- [Threejs-examples](https://threejs.org/examples)\n- [Threejs-fundamentals](https://threejsfundamentals.org)\n- [Discover Threejs](https://discoverthreejs.com)\n- [Do's and don'ts](https://discoverthreejs.com/tips-and-tricks) for performance and best practices\n- [react-three-fiber alligator.io tutorial](https://alligator.io/react/react-with-threejs) by [@dghez\\_](https://twitter.com/dghez_)\n\n# Ecosystem\n\n- [`@react-three/gltfjsx`](https://github.com/react-spring/gltfjsx) &ndash; turns GLTFs into JSX components\n- [`@react-three/drei`](https://github.com/react-spring/drei) &ndash; useful helpers for react-three-fiber\n- [`@react-three/postprocessing`](https://github.com/react-spring/react-postprocessing) &ndash; post-processing effects\n- [`@react-three/flex`](https://github.com/react-spring/react-three-flex) &ndash; flexbox for react-three-fiber\n- [`@react-three/xr`](https://github.com/react-spring/react-xr) &ndash; VR/AR controllers and events\n- [`@react-three/cannon`](https://github.com/react-spring/use-cannon) &ndash; physics based hooks\n- [`zustand`](https://github.com/react-spring/zustand) &ndash; state management\n- [`react-spring`](https://github.com/react-spring/react-spring) &ndash; a spring-physics-based animation library\n- [`react-use-gesture`](https://github.com/react-spring/react-use-gesture) &ndash; mouse/touch gestures\n\n# How to contribute\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 `BTC: 36fuguTPxGCNnYZSRdgdh6Ea94brCAjMbH`, `ETH: 0x6E3f79Ea1d0dcedeb33D3fC6c34d2B1f156F2682`.\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/pmndrs/react-three-fiber/graphs/contributors\">\n  <img src=\"https://opencollective.com/react-three-fiber/contributors.svg?width=890\" />\n</a>\n","scripts":{"prebuild":"cp ../../readme.md readme.md"},"_npmUser":{"name":"drcmda","email":"drcmda@gmail.com"},"collective":{"url":"https://opencollective.com/react-three-fiber","type":"opencollective"},"repository":{"url":"git+https://github.com/pmndrs/react-three-fiber.git","type":"git"},"_npmVersion":"6.14.5","description":"A React renderer for Threejs","directories":{},"sideEffects":false,"_nodeVersion":"12.18.2","dependencies":{"zustand":"^3.5.10","scheduler":"^0.21.0-alpha-1314299c7-20210901","use-asset":"^1.0.4","utility-types":"^3.10.0","@babel/runtime":"^7.15.4","react-merge-refs":"^1.1.0","react-reconciler":"^0.27.0-alpha-1314299c7-20210901","react-use-measure":"^2.0.4","resize-observer-polyfill":"^1.5.1"},"preconstruct":{"entrypoints":["index.tsx"]},"react-native":"dist/native.js","_hasShrinkwrap":false,"readmeFilename":"readme.md","peerDependencies":{"react":">=18.0","three":">=0.132","react-dom":">=18.0"},"peerDependenciesMeta":{"react-dom":{"optional":true}},"_npmOperationalInternal":{"tmp":"tmp/fiber_8.0.0-alpha-01_1630747985669_0.544791210644435","host":"s3://npm-registry-packages"},"publish_time":1630747985862,"_cnpm_publish_time":1630747985862,"dist-tags":{"alpha":"10.0.0-alpha.6","beta":"9.0.0-beta.1","canary":"10.0.0-canary.58acabc","latest":"9.8.2","rc":"9.0.0-rc.10"}}