{"id":19448360,"url":"https://github.com/tnahrf/React-Three-JS-Boilerplate","last_synced_at":"2025-04-25T02:31:04.582Z","repository":{"id":175041994,"uuid":"327369906","full_name":"lnahrf/React-Three-JS-Boilerplate","owner":"lnahrf","description":"A simple boilerplate for a React JS + ThreeJS project (with CRA template).","archived":false,"fork":false,"pushed_at":"2021-06-09T19:06:34.000Z","size":1373,"stargazers_count":4,"open_issues_count":0,"forks_count":1,"subscribers_count":2,"default_branch":"master","last_synced_at":"2023-11-11T16:27:30.788Z","etag":null,"topics":["boilerplate","react","react-js","three","three-js"],"latest_commit_sha":null,"homepage":"","language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/lnahrf.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null}},"created_at":"2021-01-06T16:34:25.000Z","updated_at":"2023-09-09T03:11:42.000Z","dependencies_parsed_at":"2023-07-20T20:41:21.228Z","dependency_job_id":null,"html_url":"https://github.com/lnahrf/React-Three-JS-Boilerplate","commit_stats":null,"previous_names":["tk-ni/react-three-js-boilerplate","talnahar/react-three-js-boilerplate","lnahrf/react-three-js-boilerplate"],"tags_count":null,"template":null,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/lnahrf%2FReact-Three-JS-Boilerplate","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/lnahrf%2FReact-Three-JS-Boilerplate/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/lnahrf%2FReact-Three-JS-Boilerplate/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/lnahrf%2FReact-Three-JS-Boilerplate/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/lnahrf","download_url":"https://codeload.github.com/lnahrf/React-Three-JS-Boilerplate/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":223978371,"owners_count":17235161,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["boilerplate","react","react-js","three","three-js"],"created_at":"2024-11-10T16:26:25.538Z","updated_at":"2025-04-25T02:30:59.184Z","avatar_url":"https://github.com/lnahrf.png","language":"JavaScript","funding_links":["https://ko-fi.com/tk_ni"],"categories":[],"sub_categories":[],"readme":"# React + Three JS Boilerplate \u003cimg src=\"https://theconsoleblog.com/wp-content/uploads/2021/01/three-js-symbol-png.png\" width=\"35\" align=\"right\" href=\"#\"/\u003e  \u003cimg src=\"https://theconsoleblog.com/wp-content/uploads/2020/12/1280px-React-icon-e1609508110908.png\" width=\"35\" align=\"right\" href=\"#\"/\u003e\n\nThe first time I tried running a Three JS Scene on a React project I encountered a couple of problems until I eventually got the shtick of it, I hope this article and repository will save some developers a couple of precious hours.\n\nYou can either clone my boilerplate and start working from there or you can follow my guide on how to start a basic React + Three project from scratch.\n\nLike it and want to support me? [\u003cimg src=\"https://uploads-ssl.webflow.com/5c14e387dab576fe667689cf/5cbee341ae2b8813ae072f5b_Ko-fi_logo_RGB_Outline.png\" width=\"20\"/\u003e Buy me a coffee!](https://ko-fi.com/tk_ni)\n\n\n# Using the boilerplate\n **Step 1** Clone the repo \n ```\n git clone https://github.com/tk-ni/React-JS-Three-JS-Boilerplate.git\n```\n\n**Step 2** In the main repo directory open a CMD/Terminal and type in these commands.\n\n```\nnpm install\nnpm start\n```\n\nThe boilerplate includes a basic **CRA** project structure and basic scene \u003ci\u003e**MainScene.component.js**\u003c/i\u003e already imported in App.js.\n\nFeel free to modify/copy/replace the MainScene component or anything else to fit your project's needs.\n\nThe boilerplate's folder structure follows the basic CRA template structure with a few modifications.\n\n\u003e - public \u003cbr\u003e\n\u003e - src\n\u003e   - Assets ```- Store all your 3D Models/Textures/Graphics.```\n\u003e   - Components ```- Store all your React/3D components (that aren't scenes).```\n\u003e   - Scenes ```- Store all your scenes React components. ```\n\u003e   - Styles ```- Store all your CSS/SASS files. ```\n\u003e   - Utils ```- Store all your globally used functions (e.g sceneResize.js)```\n\u003e   - App.js\n\u003e   - index.js\n\n\n---\n## Update - 1.1 \nAdded a loading manager functionality to the MainScene component. \u003cbr\u003e\nTurn loading mode on using loading props, e.g.\n```jsx\nexport default class App extends React.Component{\n  render(){\n    return(\u003c\u003e\n    \u003cMainScene loading={true}/\u003e\n    \u003c/\u003e)\n  }\n}\n```\nTo modify the actual loading screen, edit the ***Loading.component.js*** in ```src/Components``` and ***loading.css*** in ```src/Styles```.\n\n---\n## Update - 1.2\nAdded handle window resizing functionality. \u003cbr\u003e\nTo add this functionality to other scenes, import handleResize from ```src/Utils/sceneResize.js ```.\n```javascript\nimport {handleSceneResize, initEventListener} from './../Utils/sceneResize';\n```\nAdd this code before the animation loop of every scene to handle window resizing.\n```javascript\n//init Handle Resize\nhandleSceneResize(window, camera, renderer, composer);\ninitEventListener(window);\n```\n***\u003cspan style=\"color:orange\"\u003ewindow\u003c/span\u003e*** refers to the global window object. \u003cbr\u003e\n***\u003cspan style=\"color:orange\"\u003ecamera*** refers to the camera the scene currently uses. \u003cbr\u003e\n***\u003cspan style=\"color:orange\"\u003erenderer*** refers to the current renderer instance. \u003cbr\u003e\n***\u003cspan style=\"color:orange\"\u003ecomposer*** (optional) refers to the current composer instance. \u003cbr\u003e\n\nTo modify how Three JS scenes handle window resizing, edit the ***sceneResize.js*** file in ```src/Utils/sceneResize.js ```\n\n---\nIf you have any questions or comments, feel free to contact me!\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftnahrf%2FReact-Three-JS-Boilerplate","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ftnahrf%2FReact-Three-JS-Boilerplate","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftnahrf%2FReact-Three-JS-Boilerplate/lists"}