---
title: Tweakpane
description: Learn how to integrate Tweakpane with TresJS for interactive 3D controls
thumbnail: /recipes/tweakpane.png
---
[Tweakpane](https://tweakpane.github.io/docs/) is a compact GUI library that provides an excellent way to create interactive controls for your 3D scenes. This recipe shows you how to integrate Tweakpane with TresJS to create dynamic, real-time controls for your 3D objects and scenes.
::examples-tweakpane
::
## Installation
First, install Tweakpane v4 in your project:
::code-group
```bash [npm]
npm install tweakpane@^4.0.0
```
```bash [yarn]
yarn add tweakpane@^4.0.0
```
```bash [pnpm]
pnpm add tweakpane@^4.0.0
```
::
Additionally, if you are working with TypeScript:
::code-group
```bash [npm]
npm install --save-dev @tweakpane/core
```
```bash [yarn]
yarn add --save-dev @tweakpane/core
```
```bash [pnpm]
pnpm add --save-dev @tweakpane/core
```
::
::tip
Make sure to use Tweakpane v4 or higher, as this recipe uses the latest API which has breaking changes from v3.
::
## Basic Setup
Here's how to set up Tweakpane with a basic TresJS scene:
```vue
```
### Monitoring Values
You can also monitor values without making them editable:
```ts
const stats = ref({
triangles: 0,
fps: 0,
})
const statsFolder = pane.value.addFolder({ title: 'Statistics' })
statsFolder.addMonitor(stats.value, 'triangles')
statsFolder.addMonitor(stats.value, 'fps', { interval: 100 })
```
## Cleanup
Don't forget to dispose of the pane when the component unmounts:
```ts
import { onUnmounted } from 'vue'
onUnmounted(() => {
pane.value?.dispose()
})
```
:::tip
Always dispose of the pane instance to prevent memory leaks, especially in SPAs where components are frequently mounted/unmounted.
:::