Installation
Quick Start (Recommended)
The fastest way to get started with TresJS is using our interactive CLI wizard:
npx create-tres my-tres-project
yarn create tres my-tres-project
pnpm create tres my-tres-project
The CLI provides an interactive wizard that guides you through:
- ๐ฏ Template selection: Choose between Vue + Vite or Nuxt
- ๐ฆ Ecosystem packages: Select from TresJS ecosystem packages (Cientos, Post-processing, Leches)
- ๐ง TypeScript support: Type safe development with TypeScript
- ๐ ESLint integration: Code quality with TresJS ESLint config
Manual Installation
If you prefer to set up TresJS manually or add it to an existing project, follow the instructions below:
Vue project
Install TresJS and Three.js
Install the core TresJS package and the Three.js dependency:
npm install @tresjs/core three
yarn add @tresjs/core three
pnpm add @tresjs/core three
Install TypeScript types (Optional)
If you're using TypeScript, install the Three.js type definitions:
npm install @types/three -D
yarn add @types/three -D
pnpm add @types/three -D
Configure Vite
Add the TresJS template compiler options to your vite.config.ts
:
import { templateCompilerOptions } from '@tresjs/core'
import { defineConfig } from 'vite'
import vue from '@vitejs/plugin-vue'
export default defineConfig({
plugins: [
vue({
// Other config
...templateCompilerOptions
}),
],
})
Ecosystem packages (Optional)
Install additional TresJS ecosystem packages for extended functionality:
npm install @tresjs/cientos @tresjs/post-processing
yarn add @tresjs/cientos @tresjs/post-processing
pnpm add @tresjs/cientos @tresjs/post-processing
- Cientos: A collection of useful helpers and components
- Post-processing: Post-processing effects for enhanced visuals
Nuxt project
If you're using Nuxt, you can use the official TresJS Nuxt module for a seamless integration experience.
Install the Nuxt module
Install the TresJS Nuxt module and Three.js:
npm install three @tresjs/nuxt
yarn add three @tresjs/nuxt
pnpm add three @tresjs/nuxt
Configure the module
Add @tresjs/nuxt
to the modules
section of your nuxt.config.ts
:
export default defineNuxtConfig({
modules: ['@tresjs/nuxt'],
})
Start using TresJS
That's it! The module provides several benefits:
- ๐ค Auto-import components and composables from the TresJS ecosystem
- ๐ฅ๏ธ Client-only rendering for
TresCanvas
(no need for.client
suffix or<ClientOnly />
) - โ๏ธ Automatic configuration of the Vue compiler for TresJS components
- โจ DX Magic that comes with Nuxt