Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: cientos playground structure alike #76

Merged
merged 5 commits into from
Nov 8, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion playground/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
<html lang="en">
<head>
<meta charset="UTF-8" />
<link rel="icon" type="image/svg+xml" href="/vite.svg" />
<link rel="icon" type="image/svg+xml" href="/favicon.svg" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>Vite + Vue + TS</title>
</head>
Expand Down
3 changes: 3 additions & 0 deletions playground/public/favicon.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
6 changes: 6 additions & 0 deletions playground/public/logo.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
23 changes: 23 additions & 0 deletions playground/public/nuxt-stones/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
{
"name": "docs",
"private": true,
"version": "0.0.0",
"type": "module",
"scripts": {
"dev": "vitepress dev",
"build": "vitepress build",
"preview": "vitepress preview"
},
"dependencies": {
"@tresjs/cientos": "^3.0.1",
"@tresjs/core": "^3.2.2",
"@tresjs/post-processing": "workspace:^",
"gsap": "^3.11.5"
},
"devDependencies": {
"unocss": "^0.52.3",
"unplugin-vue-components": "^0.24.1",
"vite-svg-loader": "^4.0.0",
"vitepress": "1.0.0-beta.1"
}
}
16 changes: 14 additions & 2 deletions playground/src/App.vue
Original file line number Diff line number Diff line change
@@ -1,5 +1,17 @@
<script setup lang="ts"></script>
<script setup lang="ts">
import { watch } from 'vue'
import { useRoute } from 'vue-router'

const route = useRoute()
function setBodyClass(routeName: string) {
document.title = `Post-processing Playground - ${routeName}`
document.body.className = routeName
}
watch([route], () => setBodyClass(route.name?.toString() ?? ''))
</script>

<template>
<router-view />
<Suspense>
<router-view />
</Suspense>
</template>
71 changes: 0 additions & 71 deletions playground/src/components/GlitchDemo.vue

This file was deleted.

85 changes: 0 additions & 85 deletions playground/src/components/UnrealBloom.vue

This file was deleted.

143 changes: 143 additions & 0 deletions playground/src/pages/bloom.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,143 @@
<script setup lang="ts">
import { Color, BasicShadowMap, NoToneMapping } from 'three'
import { TresCanvas } from '@tresjs/core'
import { OrbitControls, useTweakPane } from '@tresjs/cientos'
import { BlendFunction, KernelSize } from 'postprocessing'
import { EffectComposer, Bloom } from '@tresjs/post-processing'
import { onMounted, reactive, ref, watch } from 'vue'
import { TresLeches, useControls } from '@tresjs/leches'
import '@tresjs/leches/styles'

const gl = {
clearColor: '#121212',
shadows: true,
alpha: false,
shadowMapType: BasicShadowMap,
toneMapping: NoToneMapping,
}

useControls('fpsgraph')

const materialRef = ref()
const {
intensity,
blendFunction,
resolution,
kernelSize,
mipmapBlur,
} = useControls({
intensity: {
value: 4.0,
min: 0,
max: 10,
step: 0.1,
},
blendFunction: {
options: Object.keys(BlendFunction).map(key => ({
text: key,
value: BlendFunction[key],
})),
value: BlendFunction.ADD,
},
resolution: {
value: 256,
min: 64,
max: 512,
step: 64,
},
kernelSize: {
options: Object.keys(KernelSize).map(key => ({
text: key,
value: KernelSize[key],
})),
value: KernelSize.VERY_SMALL,
},
mipmapBlur: true,
})

const { threshold, smoothing } = useControls('luminance', {
threshold: {
value: 0.2,
min: 0,
max: 1,
step: 0.01,
},
smoothing: {
value: 0.3,
min: 0,
max: 1,
step: 0.01,
},
})

onMounted(() => {
if (materialRef.value) {
const { value: emissiveIntensity } = useControls({
emissiveIntensity: {
value: 1,
min: 0,
max: 10,
step: 0.1,
},
})

watch(emissiveIntensity, (newValue) => {
materialRef.value.emissiveIntensity = newValue
})
}
})
</script>

<template>
<TresLeches />
<TresCanvas
v-bind="gl"
:disable-render="true"
>
<TresPerspectiveCamera
:position="[5, 5, 5]"
:look-at="[0, 0, 0]"
/>
<OrbitControls />
<TresMesh>
<TresSphereGeometry :args="[2, 32, 32]" />
<TresMeshStandardMaterial
color="hotpink"
:emissive="new Color('hotpink')"
:emissive-intensity="9"
/>
</TresMesh>
<TresMesh :position="[2, 2, -2]">
<TresSphereGeometry :args="[2, 32, 32]" />
<TresMeshStandardMaterial color="hotpink" />
</TresMesh>
<TresMesh>
<TresSphereGeometry :args="[2, 32, 32]" />
<TresMeshStandardMaterial
ref="materialRef"
color="hotpink"
:emissive="new Color('hotpink')"
:emissive-intensity="1"
/>
</TresMesh>
<TresGridHelper />
<TresAmbientLight :intensity="0.5" />
<TresDirectionalLight
:position="[3, 3, 3]"
:intensity="2"
/>
<Suspense>
<EffectComposer :depth-buffer="true">
<Bloom
:luminance-threshold="threshold.value"
:luminance-smoothing="smoothing.value"
:intensity="intensity.value"
:blend-function="blendFunction.value"
:kernel-size="kernelSize.value"
:resolution="resolution.value"
:mipmap-blur="mipmapBlur.value"
/>
</EffectComposer>
</Suspense>
</TresCanvas>
</template>
Loading