Skip to content

πŸ”₯ Three.js + TypeScript + SolidJS + Vite + Vitest πŸš€

License

Notifications You must be signed in to change notification settings

UstymUkhman/threejs-boilerplate

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

Three.js Boilerplate

πŸ”₯ Three.js + TypeScript + SolidJS + Vite + Vitest πŸš€

Minimal, yet complete template for developing three.js projects.

πŸ“‚ Structure

Three.js Boilerplate
β”œβ”€β”€ __mocks__/
β”œβ”€β”€ coverage/
β”œβ”€β”€ dist/
β”œβ”€β”€ node_modules/
β”œβ”€β”€ public/
β”‚Β Β  β”œβ”€β”€ assets/
β”‚Β Β  β”œβ”€β”€ favicons/
β”‚Β Β  β”œβ”€β”€ scripts/
β”‚Β Β  β”œβ”€β”€ styles/
β”‚Β Β  β”œβ”€β”€ browserconfig.xml
β”‚Β Β  β”œβ”€β”€ manifest.json
β”‚Β Β  β”œβ”€β”€ robots.txt
β”‚Β Β  └── sitemap.xml
β”œβ”€β”€ src/
β”‚Β Β  β”œβ”€β”€ app/
β”‚Β Β  β”œβ”€β”€ assets/
β”‚Β Β  β”œβ”€β”€ components/
β”‚Β Β  β”œβ”€β”€ sandbox/
β”‚Β Β  β”œβ”€β”€ scss/
β”‚Β Β  β”œβ”€β”€ shaders/
β”‚Β Β  β”œβ”€β”€ utils/
β”‚Β Β  β”œβ”€β”€ global.d.ts
β”‚Β Β  └── main.tsx
β”œβ”€β”€ tests/
β”‚Β Β  β”œβ”€β”€ app/
β”‚Β Β  β”œβ”€β”€ components/
β”‚Β Β  β”œβ”€β”€ sandbox/
β”‚Β Β  β”œβ”€β”€ shaders/
β”‚   β”œβ”€β”€ utils/
β”‚   β”œβ”€β”€ canvas.mock.d.ts
β”‚   β”œβ”€β”€ canvas.mock.ts
β”‚   └── global.spec.ts
β”œβ”€β”€ index.html
β”œβ”€β”€ package.json
β”œβ”€β”€ tsconfig.json
β”œβ”€β”€ vite.config.ts
└── vitest.config.ts

πŸ”Œ Usage

  Simply click Use this template and Create a new repository.
  This will initialize your own repository from this boilerplate.

✨ Features

β€ƒβ€ƒβ€‚βš™οΈ Basic

      ‒ Cross-platform Favicons
      ‒ Meta tags for sharing on Facebook and Twitter
      ‒ Unsupported browser and disabled JavaScript screens

β€ƒβ€ƒβ€‚πŸ§© Components

      ‒ Application entry point
      ‒ Logo label component
      ‒ Current version tag

β€ƒβ€ƒβ€‚πŸοΈ Sandbox

      ‒ Simple three.js scene with:

       ◦ Linear Fog
       ◦ Ground Plane
       ◦ Orbit Controls
       ◦ Stats Monitoring
       ◦ Perspective Camera
       ◦ Default WebGL2 Renderer
       ◦ Ambient & Directional Lighting

      ‒ Scene configuration file with initial parameter values.
      ‒ Custom checkerboard-like ground plane material.
      ‒ GUI controls built on top of lil-gui.
      ‒ Uncharted 2 tone mapping shader.

β€ƒβ€ƒβ€‚πŸŽ¨ Shaders

      ‒ Custom shader support through vite-plugin-glsl.
      ‒ Three.js shaders for ground plane material.
      ‒ Three.js shaders for custom tone mapping.

β€ƒβ€ƒβ€‚πŸ› οΈ Utilities

      ‒ Assets loading manager:

       ◦ Promise based APIs
       ◦ Loading errors logging
       ◦ Start, Progress & Complete loading events
       ◦ usePublicFolder option for setting assets path
       ◦ Audio, GLTF/GLB, CubeTexture & Texture loaders

      ‒ Array, Color, Number, String & deepFreeze methods.
      ‒ Elastic Number, Vector3 and Vector3 classes.
      ‒ Custom Events and EventEmitter manager.
      ‒ Mouse Wheel normalization function.
      ‒ debounce and throttle functions.
      ‒ requestAnimationFrame manager.
      ‒ Custom Web Worker manager.
      ‒ Unity-like Vector3 directions.
      ‒ Spline interpolation manager.
      ‒ Screen Viewport manager.

β€ƒβ€ƒβ€‚πŸ§° Miscellaneous

      ‒ Scoped SCSS and common easing functions.
      ‒ Support for common 3D formats.
      ‒ Common assets folders.
      ‒ PWA-ready manifest.
      ‒ MIT license.

β€ƒβ€ƒβ€‚πŸ“¦ Package Manager

      This project was build with pnpm, but yarn and npm are also supported.
      Just replace pnpm in all commands below with yarn or npm run.
      For npm users, one exception is the installation, where it's npm i.

β€ƒβ€ƒβ€‚πŸ“ˆ Tests Coverage

      All the code in the src/ directory has been fully tested and has a 100% code coverage.
     Show me some numbers!

      Tests Coverage

πŸ’Ύ Download

  git clone https://github.com/UstymUkhman/threejs-boilerplate.git
  cd threejs-boilerplate

⌨️ Develop

  pnpm i
  pnpm start

βœ”οΈ Lint

  pnpm lint:js
  pnpm lint:css

πŸ§ͺ Test

  pnpm test
  pnpm test:watch
  pnpm test:cover

🧱 Build

  pnpm build
  pnpm serve