diff --git a/playground/.eslintrc-auto-import.json b/playground/.eslintrc-auto-import.json
index 81815b05..bd42a113 100644
--- a/playground/.eslintrc-auto-import.json
+++ b/playground/.eslintrc-auto-import.json
@@ -58,7 +58,6 @@
"watch": true,
"watchEffect": true,
"watchPostEffect": true,
- "watchSyncEffect": true,
- "toValue": true
+ "watchSyncEffect": true
}
}
diff --git a/playground/components.d.ts b/playground/components.d.ts
index 5ea681b4..e14c09d7 100644
--- a/playground/components.d.ts
+++ b/playground/components.d.ts
@@ -9,7 +9,9 @@ export {}
declare module '@vue/runtime-core' {
export interface GlobalComponents {
- copy: typeof import('./src/components/TheExperience copy.vue')['default']
+ copy: typeof import('./src/components/UnrealBloom copy.vue')['default']
+ GlitchDemo: typeof import('./src/components/GlitchDemo.vue')['default']
+ OutlineDemo: typeof import('./src/components/OutlineDemo.vue')['default']
RouterLink: typeof import('vue-router')['RouterLink']
RouterView: typeof import('vue-router')['RouterView']
TheExperience: typeof import('./src/components/TheExperience.vue')['default']
diff --git a/playground/src/components/GlitchDemo.vue b/playground/src/components/GlitchDemo.vue
new file mode 100644
index 00000000..cb6c441b
--- /dev/null
+++ b/playground/src/components/GlitchDemo.vue
@@ -0,0 +1,66 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/playground/src/components/OutlineDemo.vue b/playground/src/components/OutlineDemo.vue
new file mode 100644
index 00000000..06ae2994
--- /dev/null
+++ b/playground/src/components/OutlineDemo.vue
@@ -0,0 +1,56 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/playground/src/components/UnrealBloom.vue b/playground/src/components/UnrealBloom.vue
index c0667c10..cc12d3a3 100644
--- a/playground/src/components/UnrealBloom.vue
+++ b/playground/src/components/UnrealBloom.vue
@@ -4,6 +4,7 @@ import { TresCanvas } from '@tresjs/core'
import { OrbitControls, useTweakPane } from '@tresjs/cientos'
import { EffectComposer, Bloom } from '@tresjs/post-processing'
import { BasicShadowMap, NoToneMapping } from 'three'
+import { onMounted, reactive, ref } from 'vue'
const gl = {
clearColor: '#121212',
@@ -14,11 +15,10 @@ const gl = {
}
const bloomParams = reactive({
- luminanceThreshold: 0.1,
+ luminanceThreshold: 0.2,
luminanceSmoothing: 0.3,
mipmapBlur: true,
intensity: 4.0,
- radius: 0.85,
})
const { pane } = useTweakPane()
@@ -27,7 +27,6 @@ pane.addInput(bloomParams, 'luminanceThreshold', { min: 0, max: 1 })
pane.addInput(bloomParams, 'luminanceSmoothing', { min: 0, max: 1 })
pane.addInput(bloomParams, 'mipmapBlur')
pane.addInput(bloomParams, 'intensity', { min: 0, max: 10 })
-pane.addInput(bloomParams, 'radius', { min: 0, max: 1 })
const materialRef = ref(null)
@@ -46,7 +45,7 @@ onMounted(() => {
-->
-
+
@@ -63,8 +62,8 @@ onMounted(() => {
-
-
+
+
diff --git a/playground/src/pages/index.vue b/playground/src/pages/index.vue
index edef43ed..a994230f 100644
--- a/playground/src/pages/index.vue
+++ b/playground/src/pages/index.vue
@@ -1,5 +1,5 @@
-
+
diff --git a/src/core/EffectComposer.vue b/src/core/EffectComposer.vue
new file mode 100644
index 00000000..2ffb0ab7
--- /dev/null
+++ b/src/core/EffectComposer.vue
@@ -0,0 +1,109 @@
+
+
+
+
diff --git a/src/core/effects/Bloom.vue b/src/core/effects/Bloom.vue
new file mode 100644
index 00000000..0ca07abf
--- /dev/null
+++ b/src/core/effects/Bloom.vue
@@ -0,0 +1,136 @@
+
+
diff --git a/src/core/effects/Glitch.vue b/src/core/effects/Glitch.vue
new file mode 100644
index 00000000..fb81a404
--- /dev/null
+++ b/src/core/effects/Glitch.vue
@@ -0,0 +1,183 @@
+
+
diff --git a/src/core/effects/Outline.vue b/src/core/effects/Outline.vue
new file mode 100644
index 00000000..d0d9b206
--- /dev/null
+++ b/src/core/effects/Outline.vue
@@ -0,0 +1,162 @@
+
+
diff --git a/src/core/useEffectComposer/component.ts b/src/core/useEffectComposer/component.ts
deleted file mode 100644
index 33d31fbd..00000000
--- a/src/core/useEffectComposer/component.ts
+++ /dev/null
@@ -1,198 +0,0 @@
-import { useWindowSize } from '@vueuse/core'
-import { useRenderLoop, Camera } from '@tresjs/core'
-import { defineComponent, provide, shallowRef, ShallowRef, toRefs, watch, watchEffect } from 'vue'
-import { DepthDownsamplingPass, EffectComposer as EffectComposerImpl, NormalPass, RenderPass } from 'postprocessing'
-import { isWebGL2Available } from 'three-stdlib'
-
-import { useCore } from '../useCore'
-import { /* HalfFloatType, */ Scene } from 'three'
-
-export interface EffectComposerProps {
- /**
- * The children of the effect composer.
- * @default []
- * @type {Array}
- * @memberof EffectComposerProps
- * @name children
- *
- **/
- children?: Array
- /**
- * Whether the depth buffer is enabled.
- * @default true
- * @type {boolean}
- * @memberof EffectComposerProps
- * @name depthBuffer
- *
- **/
- depthBuffer?: boolean
- /**
- *
- * @default false
- * @type {boolean}
- * @memberof EffectComposerProps
- * @name dissableNormalPass
- *
- **/
- dissableNormalPass?: boolean
- /**
- *
- * Stencil buffer.
- *
- * @type {boolean}
- * @memberof EffectComposerProps
- * @name stencilBuffer
- *
- **/
- stencilBuffer?: boolean
- /**
- *
- * Whether the effect composer should clear the buffers before rendering.
- *
- * @type {boolean}
- * @memberof EffectComposerProps
- * @name autoClear
- *
- **/
- autoClear?: boolean
- /**
- *
- * The resolution scale.
- *
- * @type {number}
- * @memberof EffectComposerProps
- * @name resolutionScale
- *
- **/
- resolutionScale?: number
- /**
- *
- * The multisampling.
- *
- * @type {number}
- * @memberof EffectComposerProps
- * @name multisampling
- *
- **/
- multisampling?: number
- /**
- *
- * The frame buffer type.
- *
- * @type {number}
- * @memberof EffectComposerProps
- * @name frameBufferType
- *
- **/
- frameBufferType?: number
-
- /**
- *
- * The render priority.
- *
- * @type {number}
- * @memberof EffectComposerProps
- * @name renderPriority
- *
- **/
- renderPriority?: number
- /**
- *
- * A camera to use for rendering.
- *
- * @type {Camera}
- * @memberof EffectComposerProps
- * @name camera
- *
- **/
- camera?: Camera
- /**
- * A scene to use for rendering.
- * @type {Scene}
- * @memberof EffectComposerProps
- * @name scene
- *
- **/
- scene?: Scene
-}
-
-export const EffectComposer = defineComponent({
- name: 'EffectComposer',
- props: [
- 'children',
- 'depthBuffer',
- 'dissableNormalPass',
- 'stencilBuffer',
- 'autoClear',
- 'resolutionScale',
- 'multisampling',
- 'frameBufferType',
- 'renderPriority',
- 'camera',
- 'scene',
- ] as unknown as undefined,
-
- setup(props, { slots }) {
- const { state } = useCore()
- const {
- // TODO: Add support for these props
- /* renderPriority = 1,
- autoClear = true,
- multisampling = 8,
- frameBufferType = HalfFloatType, */
- resolutionScale,
- } = toRefs(props)
- const effectComposer: ShallowRef = shallowRef(null)
-
- const scene = props.scene || state.scene
- const camera = props.camera || state.camera
- let downSamplingPass = null
- let normalPass = null
- const webGL2Available = isWebGL2Available()
-
- provide('effectComposer', effectComposer)
-
- const { width, height } = useWindowSize()
-
- function setNormalPass() {
- if (effectComposer.value) {
- normalPass = new NormalPass(scene as Scene, camera as Camera)
- normalPass.enabled = false
- effectComposer.value.addPass(normalPass)
- if (resolutionScale.value !== undefined && webGL2Available) {
- downSamplingPass = new DepthDownsamplingPass({
- normalBuffer: normalPass.texture,
- resolutionScale: resolutionScale?.value,
- })
- downSamplingPass.enabled = false
- effectComposer.value.addPass(downSamplingPass)
- }
- }
- }
-
- watchEffect(() => {
- if (state.renderer && state.scene && state.camera) {
- state.renderer.setSize(width.value, height.value)
- state.renderer.setPixelRatio(Math.min(window.devicePixelRatio, 2))
- effectComposer.value = new EffectComposerImpl(state.renderer)
- effectComposer.value.addPass(new RenderPass(scene, camera))
-
- if (!props.dissableNormalPass) {
- setNormalPass()
- }
- }
- })
-
- const { onLoop } = useRenderLoop()
-
- onLoop(() => {
- if (effectComposer.value) {
- effectComposer.value.render()
- }
- })
-
- return () => {
- return slots.default?.()
- }
- },
-})
diff --git a/src/index.ts b/src/index.ts
index b53ff095..218879ce 100644
--- a/src/index.ts
+++ b/src/index.ts
@@ -1,6 +1,6 @@
-import { EffectComposer } from './core/useEffectComposer/component'
-import { Bloom } from './core/effects/Bloom'
-import { Glitch } from './core/effects/Glitch'
+import EffectComposer from './core/EffectComposer.vue'
+import Bloom from './core/effects/Bloom.vue'
+import Glitch from './core/effects/Glitch.vue'
import { Outline } from './core/effects/Outline'
export { EffectComposer, Bloom, Glitch, Outline }
diff --git a/src/vite-env.d.ts b/src/vite-env.d.ts
index 11f02fe2..aafef950 100644
--- a/src/vite-env.d.ts
+++ b/src/vite-env.d.ts
@@ -1 +1,8 @@
///
+
+declare module '*.vue' {
+ import type { DefineComponent } from 'vue'
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any, @typescript-eslint/ban-types
+ const component: DefineComponent<{}, {}, any>
+ export default component
+}