Skip to content

Commit

Permalink
chore(cookbook): 762 recipe using tweakpane (#790)
Browse files Browse the repository at this point in the history
* docs: tweakpane recipe

* docs(cookbook): tweakpane recipe thumbnail
  • Loading branch information
alvarosabu committed Jul 25, 2024
1 parent 5a063b1 commit 1081bf2
Show file tree
Hide file tree
Showing 5 changed files with 71 additions and 7 deletions.
1 change: 1 addition & 0 deletions docs/.vitepress/config/en.ts
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,7 @@ export const enConfig: LocaleSpecificConfig<DefaultTheme.Config> = {
{ text: 'Load Text', link: '/cookbook/text-3d' },
{ text: 'Lights & Shadows', link: '/cookbook/lights-shadows' },
{ text: 'Shaders', link: '/cookbook/shaders' },
{ text: 'Tweakpane', link: '/cookbook/tweakpane' },
],
},
{
Expand Down
59 changes: 59 additions & 0 deletions docs/cookbook/tweakpane.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
---
title: Tweakpane
description: How to use tweakpane to control your scene
author: alvarosabu
thumbnail: /recipes/tweakpane.png
difficulty: 0
---

# Tweakpane

To make it easier to control the parameters of your scene, you can use [Tweakpane](https://cocopon.github.io/tweakpane/). In this guide, we will show you how to use Tweakpane to control the parameters of your scene.

<StackBlitzEmbed project-id="tweakpane" />

## Installation

First, you need to install Tweakpane:

```bash
pnpm add tweakpane
```

Additionally install type defs

```bash
$ pnpm add -D @tweakpane/core
```

## Usage

In this example, we will create a simple scene with a cube and use Tweakpane to control background color and the cube material `wireframe` property.

```vue
<script setup lang="ts">
import { ref } from 'vue'
import { TresCanvas } from '@tresjs/core'
import { Pane } from 'tweakpane'
const state = reactive({
clearColor: '#c0ffee',
wireframe: false
})
const pane = new Pane()
pane.addInput(state, 'clearColor')
pane.addInput(state, 'wireframe')
</script>
<template>
<TresCanvas :clear-color="state.clearColor">
<TresMesh>
<TresBoxGeometry />
<TresMeshNormalMaterial :wireframe="state.wireframe" />
</TresMesh>
</TresCanvas>
</template>
```
3 changes: 2 additions & 1 deletion docs/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,8 @@
"preview": "vitepress preview"
},
"dependencies": {
"@tresjs/core": "workspace:^"
"@tresjs/core": "workspace:^",
"tweakpane": "^4.0.4"
},
"devDependencies": {
"@iconify-json/logos": "^1.1.43",
Expand Down
Binary file added docs/public/recipes/tweakpane.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
15 changes: 9 additions & 6 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 1081bf2

Please sign in to comment.