Skip to content

Commit 013b4a1

Browse files
alvarosabuTinoooo
andauthored
fix: 58 postprocessing breaks on nuxt (#69)
* feat: added pixelation effect component * chore: added playground code for pixelation effect * docs: pixelation effect docs * chore: removed debug code * chore: add nuxt playground * fix: initilize effect composer onmounted if canvas sizes > 0 * chore: stats * chore: removed onMounted in EffectComposer --------- Co-authored-by: Tino Koch <17991193+Tinoooo@users.noreply.github.com>
1 parent 577125d commit 013b4a1

File tree

14 files changed

+4465
-159
lines changed

14 files changed

+4465
-159
lines changed

playground-nuxt/.gitignore

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
# Nuxt dev/build outputs
2+
.output
3+
.data
4+
.nuxt
5+
.nitro
6+
.cache
7+
dist
8+
9+
# Node dependencies
10+
node_modules
11+
12+
# Logs
13+
logs
14+
*.log
15+
16+
# Misc
17+
.DS_Store
18+
.fleet
19+
.idea
20+
21+
# Local env files
22+
.env
23+
.env.*
24+
!.env.example

playground-nuxt/.npmrc

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
shamefully-hoist=true

playground-nuxt/README.md

Lines changed: 75 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,75 @@
1+
# Nuxt 3 Minimal Starter
2+
3+
Look at the [Nuxt 3 documentation](https://nuxt.com/docs/getting-started/introduction) to learn more.
4+
5+
## Setup
6+
7+
Make sure to install the dependencies:
8+
9+
```bash
10+
# npm
11+
npm install
12+
13+
# pnpm
14+
pnpm install
15+
16+
# yarn
17+
yarn install
18+
19+
# bun
20+
bun install
21+
```
22+
23+
## Development Server
24+
25+
Start the development server on `http://localhost:3000`:
26+
27+
```bash
28+
# npm
29+
npm run dev
30+
31+
# pnpm
32+
pnpm run dev
33+
34+
# yarn
35+
yarn dev
36+
37+
# bun
38+
bun run dev
39+
```
40+
41+
## Production
42+
43+
Build the application for production:
44+
45+
```bash
46+
# npm
47+
npm run build
48+
49+
# pnpm
50+
pnpm run build
51+
52+
# yarn
53+
yarn build
54+
55+
# bun
56+
bun run build
57+
```
58+
59+
Locally preview production build:
60+
61+
```bash
62+
# npm
63+
npm run preview
64+
65+
# pnpm
66+
pnpm run preview
67+
68+
# yarn
69+
yarn preview
70+
71+
# bun
72+
bun run preview
73+
```
74+
75+
Check out the [deployment documentation](https://nuxt.com/docs/getting-started/deployment) for more information.

playground-nuxt/app.vue

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
<template>
2+
<div>
3+
<NuxtPage />
4+
</div>
5+
</template>

playground-nuxt/nuxt.config.ts

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
import { resolve } from 'pathe'
2+
3+
// https://nuxt.com/docs/api/configuration/nuxt-config
4+
export default defineNuxtConfig({
5+
devtools: { enabled: true },
6+
modules: [
7+
'@tresjs/nuxt',
8+
],
9+
vite: {
10+
resolve: {
11+
alias: {
12+
'@tresjs/post-processing': resolve(__dirname, '../src/'),
13+
},
14+
dedupe: ['three', '@tresjs/core'],
15+
},
16+
},
17+
})

playground-nuxt/package.json

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
{
2+
"name": "nuxt-app",
3+
"type": "module",
4+
"private": true,
5+
"scripts": {
6+
"build": "nuxt build",
7+
"dev": "nuxt dev",
8+
"generate": "nuxt generate",
9+
"preview": "nuxt preview",
10+
"postinstall": "nuxt prepare"
11+
},
12+
"dependencies": {
13+
"@tresjs/cientos": "^3.5.1",
14+
"@tresjs/nuxt": "^1.2.2",
15+
"@types/three": "^0.152.1"
16+
},
17+
"devDependencies": {
18+
"@nuxt/devtools": "latest",
19+
"nuxt": "^3.8.0",
20+
"vue": "^3.3.7",
21+
"vue-router": "^4.2.5"
22+
}
23+
}

playground-nuxt/pages/index.vue

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
<script setup lang="ts">
2+
import { BlendFunction } from 'postprocessing'
3+
import { Color, BasicShadowMap, SRGBColorSpace, NoToneMapping } from 'three'
4+
import { reactive } from 'vue'
5+
import { EffectComposer, Bloom } from '@tresjs/post-processing'
6+
7+
const gl = {
8+
clearColor: '#82DBC5',
9+
shadows: true,
10+
alpha: false,
11+
shadowMapType: BasicShadowMap,
12+
outputColorSpace: SRGBColorSpace,
13+
toneMapping: NoToneMapping,
14+
}
15+
16+
const bloomParams = reactive({
17+
luminanceThreshold: 0.2,
18+
luminanceSmoothing: 0.3,
19+
intensity: 4.0,
20+
blendFunction: BlendFunction.ADD,
21+
})
22+
</script>
23+
24+
<template>
25+
<TresCanvas
26+
v-bind="gl"
27+
window-size
28+
>
29+
<TresPerspectiveCamera :position="[3, 3, 3]" />
30+
<OrbitControls />
31+
<TresMesh>
32+
<TresSphereGeometry :args="[2, 32, 32]" />
33+
<TresMeshStandardMaterial
34+
color="hotpink"
35+
:emissive="new Color('hotpink')"
36+
:emissive-intensity="9"
37+
/>
38+
</TresMesh>
39+
<TresGridHelper />
40+
<TresAmbientLight :intensity="1" />
41+
<Suspense>
42+
<EffectComposer :depth-buffer="true">
43+
<Bloom />
44+
</EffectComposer>
45+
</Suspense>
46+
</TresCanvas>
47+
</template>

playground-nuxt/public/favicon.ico

4.19 KB
Binary file not shown.

playground-nuxt/server/tsconfig.json

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
{
2+
"extends": "../.nuxt/tsconfig.server.json"
3+
}

playground-nuxt/tsconfig.json

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
{
2+
// https://nuxt.com/docs/guide/concepts/typescript
3+
"extends": "./.nuxt/tsconfig.json"
4+
}

0 commit comments

Comments
 (0)