ThreeJS-Webpack-ES6-Boilerp.../README.md

61 lines
2.3 KiB
Markdown
Raw Normal View History

2016-09-12 19:54:07 +00:00
# Three.js Webpack ES6 Boilerplate
2018-06-27 02:46:49 +00:00
https://github.com/paulmg/ThreeJS-Webpack-ES6-Boilerplate/
2016-09-12 19:54:07 +00:00
A basic boilerplate for a Three.js project including the use of Webpack and ES6 syntax via Babel.
2016-10-07 18:56:18 +00:00
## Project Structure
2018-06-21 15:05:55 +00:00
```
build - Directory for built and compressed files from the npm build script
src - Directory for all dev files
├── css - Contains all SCSS files, that are compiled to `src/public/css`
├── js - All the Three.js app files, with `app.js` as entry point. Compiled to `src/public/js` with webpack
2018-06-21 15:05:55 +00:00
│ ├── app
│ │ ├── components - Three.js components that get initialized in `main.js`
│ │ ├── helpers - Classes that provide ideas on how to set up and work with defaults
│ │ ├── managers - Manage complex tasks such as GUI or input
│ │ └── model - Classes that set up the model object
│ ├── data - Any data to be imported into app
│ └── utils - Various helpers and vendor classes
└── public - Used by webpack-dev-server to serve content. Webpack builds local dev files here.
2019-02-05 21:47:12 +00:00
└── assets - Is copied over to build folder with build command. Place external asset files here.
2018-06-21 15:05:55 +00:00
```
2016-10-07 18:56:18 +00:00
2016-09-12 19:54:07 +00:00
## Getting started
2016-10-07 18:56:18 +00:00
Install dependencies:
2016-09-12 19:54:07 +00:00
```
npm install
```
2016-10-07 18:56:18 +00:00
Then run dev script:
2016-09-12 19:54:07 +00:00
```
npm run dev
```
2019-01-29 21:56:28 +00:00
Spins up a webpack dev server at localhost:8080 and keeps track of all js and sass changes to files.
2016-09-12 19:54:07 +00:00
## Build
```
npm run build
```
Cleans existing build folder while linting js folder and copies over the public assets folder from src. Then sets environment to production and compiles js and css into build.
2016-10-07 18:56:18 +00:00
## Other NPM Scripts
You can run any of these individually if you'd like with the `npm run` command:
* `prebuild` - Cleans up build folder and lints `src/js`
* `clean` - Cleans build folder
* `lint` - Runs lint on the `src/js` folder and uses the `.eslintrc` file in root for linting rules
* `webpack-server` - Start up a webpack-dev-server with hot-module-replacement
* `webpack-watch` - Run webpack in dev environment with watch
* `dev:js` - Run webpack in dev environment without watch
* `build:dir` - Copy files and folders from `src/public` to `build`
* `build:js` - Run webpack in production environment
2016-10-07 18:56:18 +00:00
## Input Controls
2016-10-07 19:08:15 +00:00
* Press H to hide dat.GUI
* Arrow controls will pan
* Mouse left click will rotate/right click will pan
2019-01-29 21:56:28 +00:00
* Scroll wheel zooms in and out