Skip to content

Commit

Permalink
Merge branch 'main' into bugfix/67-depth-of-field-and-outline-effect-…
Browse files Browse the repository at this point in the history
…docs-are-broken-2
  • Loading branch information
alvarosabu authored Oct 15, 2024
2 parents 589f1c1 + bd6ff06 commit 08cdf19
Show file tree
Hide file tree
Showing 11 changed files with 71 additions and 31 deletions.
4 changes: 3 additions & 1 deletion src/core/pmndrs/Bloom.vue
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<script setup lang="ts">
<script lang="ts">
import type { BlendFunction, KernelSize } from 'postprocessing'
import { BloomEffect } from 'postprocessing'
import { makePropWatchers } from '../../util/prop'
Expand Down Expand Up @@ -57,7 +57,9 @@ export interface BloomProps {
*/
mipmapBlur?: boolean
}
</script>

<script setup lang="ts">
const props = withDefaults(
defineProps<BloomProps>(),
{
Expand Down
4 changes: 3 additions & 1 deletion src/core/pmndrs/DepthOfField.vue
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<script lang="ts" setup>
<script lang="ts">
import type { BlendFunction } from 'postprocessing'
import { useTresContext } from '@tresjs/core'
import { DepthOfFieldEffect } from 'postprocessing'
Expand Down Expand Up @@ -40,7 +40,9 @@ export interface DepthOfFieldProps {
resolutionX?: number
resolutionY?: number
}
</script>

<script lang="ts" setup>
const props = defineProps<DepthOfFieldProps>()
const { camera } = useTresContext()
Expand Down
4 changes: 3 additions & 1 deletion src/core/pmndrs/Glitch.vue
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<script setup lang="ts">
<script lang="ts">
import type { BlendFunction } from 'postprocessing'
import type { Texture, Vector2 } from 'three'
import { useLoop } from '@tresjs/core'
Expand Down Expand Up @@ -52,7 +52,9 @@ export interface GlitchProps {
*/
dtSize?: number
}
</script>

<script setup lang="ts">
const props = defineProps<GlitchProps>()
const { pass, effect } = useEffect(() => new GlitchEffect(props), props)
Expand Down
4 changes: 3 additions & 1 deletion src/core/pmndrs/Noise.vue
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<script lang="ts" setup>
<script lang="ts">
import { useLoop } from '@tresjs/core'
import { BlendFunction, NoiseEffect } from 'postprocessing'
import { omit } from '../../util/object'
Expand All @@ -12,7 +12,9 @@ export interface NoiseProps {
premultiply?: boolean
blendFunction?: BlendFunction
}
</script>

<script lang="ts" setup>
const props = withDefaults(defineProps<NoiseProps>(), {
premultiply: false,
blendFunction: BlendFunction.SCREEN,
Expand Down
4 changes: 3 additions & 1 deletion src/core/pmndrs/Pixelation.vue
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<script lang="ts" setup>
<script lang="ts">
import { PixelationEffect } from 'postprocessing'
import { makePropWatchersUsingAllProps } from '../../util/prop'
import { useEffect } from './composables/useEffect'
Expand All @@ -9,7 +9,9 @@ export interface PixelationProps {
*/
granularity?: number
}
</script>

<script lang="ts" setup>
const props = defineProps<PixelationProps>()
const { pass, effect } = useEffect(() => new PixelationEffect(props.granularity), props)
Expand Down
4 changes: 3 additions & 1 deletion src/core/pmndrs/Vignette.vue
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<script lang="ts" setup>
<script lang="ts">
import { BlendFunction, VignetteEffect, VignetteTechnique } from 'postprocessing'
import { omit } from '../../util/object'
import { makePropWatchersUsingAllProps } from '../../util/prop'
Expand All @@ -13,7 +13,9 @@ export interface VignetteProps {
offset: number
darkness: number
}
</script>

<script lang="ts" setup>
const props = withDefaults(defineProps<VignetteProps>(), {
technique: VignetteTechnique.DEFAULT,
blendFunction: BlendFunction.NORMAL,
Expand Down
27 changes: 19 additions & 8 deletions src/core/pmndrs/index.ts
Original file line number Diff line number Diff line change
@@ -1,12 +1,14 @@
import Bloom from './Bloom.vue'
/* eslint-disable perfectionist/sort-named-exports */

import Bloom, { type BloomProps } from './Bloom.vue'
import { useEffect } from './composables/useEffect'
import DepthOfField from './DepthOfField.vue'
import EffectComposer from './EffectComposer.vue'
import Glitch from './Glitch.vue'
import Noise from './Noise.vue'
import Outline from './Outline.vue'
import Pixelation from './Pixelation.vue'
import Vignette from './Vignette.vue'
import DepthOfField, { type DepthOfFieldProps } from './DepthOfField.vue'
import EffectComposer, { type EffectComposerProps } from './EffectComposer.vue'
import Glitch, { type GlitchProps } from './Glitch.vue'
import Noise, { type NoiseProps } from './Noise.vue'
import Outline, { type OutlineProps } from './Outline.vue'
import Pixelation, { type PixelationProps } from './Pixelation.vue'
import Vignette, { type VignetteProps } from './Vignette.vue'

export {
Bloom,
Expand All @@ -18,4 +20,13 @@ export {
Pixelation,
useEffect,
Vignette,

BloomProps,
DepthOfFieldProps,
EffectComposerProps,
GlitchProps,
NoiseProps,
OutlineProps,
PixelationProps,
VignetteProps,
}
15 changes: 9 additions & 6 deletions src/core/three/EffectComposer.vue
Original file line number Diff line number Diff line change
Expand Up @@ -6,15 +6,18 @@ import { RenderPass } from 'three/examples/jsm/postprocessing/RenderPass.js'
import { type InjectionKey, onUnmounted, provide, type ShallowRef, shallowRef, watchEffect } from 'vue'
export const effectComposerInjectionKey: InjectionKey<ShallowRef<EffectComposer | null>> = Symbol('effectComposerThree')
</script>
<script lang="ts" setup>
const props = withDefaults(defineProps<{
export interface EffectComposerProps {
enabled?: boolean
withoutRenderPass?: boolean
}>(), {
enabled: true,
})
}
</script>

<script lang="ts" setup>
const props = withDefaults(
defineProps<EffectComposerProps>(),
{ enabled: true },
)
const effectComposer: ShallowRef<EffectComposer | null> = shallowRef(null)
provide(effectComposerInjectionKey, effectComposer)
Expand Down
4 changes: 2 additions & 2 deletions src/core/three/Halftone.vue
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ export enum HalftoneShape {
Square = 4,
}
interface HalftonePassProps {
export interface HalftoneProps {
shape?: HalftoneShape
radius?: number
rotateR?: number
Expand All @@ -27,7 +27,7 @@ interface HalftonePassProps {
</script>

<script lang="ts" setup>
const props = defineProps<HalftonePassProps>()
const props = defineProps<HalftoneProps>()
const { sizes } = useTresContext()
const shakedProps = computed(() =>
Expand Down
10 changes: 7 additions & 3 deletions src/core/three/SMAA.vue
Original file line number Diff line number Diff line change
@@ -1,14 +1,18 @@
<script lang="ts" setup>
<script lang="ts">
import { useTresContext } from '@tresjs/core'
import { useDevicePixelRatio } from '@vueuse/core'
import { SMAAPass } from 'three/examples/jsm/postprocessing/SMAAPass.js'
import { computed, watchEffect } from 'vue'
import { useEffect } from './composables/useEffect'
const props = defineProps<{
export interface SMAAProps {
width?: number
height?: number
}>()
}
</script>

<script lang="ts" setup>
const props = defineProps<SMAAProps>()
const { sizes } = useTresContext()
const { pixelRatio } = useDevicePixelRatio() // the renderers pixel ratio is not used because it is not reactive
Expand Down
22 changes: 16 additions & 6 deletions src/core/three/index.ts
Original file line number Diff line number Diff line change
@@ -1,19 +1,29 @@
/* eslint-disable perfectionist/sort-named-exports */
import { useEffect } from './composables/useEffect'
import EffectComposer from './EffectComposer.vue'
import Glitch from './Glitch.vue'
import Halftone from './Halftone.vue'
import EffectComposer, { type EffectComposerProps } from './EffectComposer.vue'
import Glitch, { type GlitchProps } from './Glitch.vue'
import Halftone, { type HalftoneProps } from './Halftone.vue'
import Pixelation, { type PixelationProps } from './Pixelation.vue'
import Output from './Output.vue'
import Pixelation from './Pixelation.vue'
import SMAA from './SMAA.vue'
import UnrealBloom from './UnrealBloom.vue'
import SMAA, { type SMAAProps } from './SMAA.vue'
import UnrealBloom, { type UnrealBloomProps } from './UnrealBloom.vue'

export {
EffectComposer,

Glitch,
Halftone,
Output,
Pixelation,
SMAA,
UnrealBloom,

useEffect,

EffectComposerProps,
GlitchProps,
HalftoneProps,
PixelationProps,
SMAAProps,
UnrealBloomProps,
}

0 comments on commit 08cdf19

Please sign in to comment.