Skip to content

Commit bd6ff06

Browse files
authored
feat: prop types exposure (#136)
* added type export to try out * added type exports --------- Co-authored-by: Tino Koch <>
1 parent 3c44dfb commit bd6ff06

File tree

11 files changed

+71
-31
lines changed

11 files changed

+71
-31
lines changed

src/core/pmndrs/Bloom.vue

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
<script setup lang="ts">
1+
<script lang="ts">
22
import type { BlendFunction, KernelSize } from 'postprocessing'
33
import { BloomEffect } from 'postprocessing'
44
import { makePropWatchers } from '../../util/prop'
@@ -57,7 +57,9 @@ export interface BloomProps {
5757
*/
5858
mipmapBlur?: boolean
5959
}
60+
</script>
6061

62+
<script setup lang="ts">
6163
const props = withDefaults(
6264
defineProps<BloomProps>(),
6365
{

src/core/pmndrs/DepthOfField.vue

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
<script lang="ts" setup>
1+
<script lang="ts">
22
import type { BlendFunction } from 'postprocessing'
33
import { useTresContext } from '@tresjs/core'
44
import { DepthOfFieldEffect } from 'postprocessing'
@@ -40,7 +40,9 @@ export interface DepthOfFieldProps {
4040
resolutionX?: number
4141
resolutionY?: number
4242
}
43+
</script>
4344

45+
<script lang="ts" setup>
4446
const props = defineProps<DepthOfFieldProps>()
4547
const { camera } = useTresContext()
4648

src/core/pmndrs/Glitch.vue

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
<script setup lang="ts">
1+
<script lang="ts">
22
import type { BlendFunction } from 'postprocessing'
33
import type { Texture, Vector2 } from 'three'
44
import { useLoop } from '@tresjs/core'
@@ -52,7 +52,9 @@ export interface GlitchProps {
5252
*/
5353
dtSize?: number
5454
}
55+
</script>
5556

57+
<script setup lang="ts">
5658
const props = defineProps<GlitchProps>()
5759
5860
const { pass, effect } = useEffect(() => new GlitchEffect(props), props)

src/core/pmndrs/Noise.vue

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
<script lang="ts" setup>
1+
<script lang="ts">
22
import { useLoop } from '@tresjs/core'
33
import { BlendFunction, NoiseEffect } from 'postprocessing'
44
import { omit } from '../../util/object'
@@ -12,7 +12,9 @@ export interface NoiseProps {
1212
premultiply?: boolean
1313
blendFunction?: BlendFunction
1414
}
15+
</script>
1516

17+
<script lang="ts" setup>
1618
const props = withDefaults(defineProps<NoiseProps>(), {
1719
premultiply: false,
1820
blendFunction: BlendFunction.SCREEN,

src/core/pmndrs/Pixelation.vue

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
<script lang="ts" setup>
1+
<script lang="ts">
22
import { PixelationEffect } from 'postprocessing'
33
import { makePropWatchersUsingAllProps } from '../../util/prop'
44
import { useEffect } from './composables/useEffect'
@@ -9,7 +9,9 @@ export interface PixelationProps {
99
*/
1010
granularity?: number
1111
}
12+
</script>
1213

14+
<script lang="ts" setup>
1315
const props = defineProps<PixelationProps>()
1416
1517
const { pass, effect } = useEffect(() => new PixelationEffect(props.granularity), props)

src/core/pmndrs/Vignette.vue

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
<script lang="ts" setup>
1+
<script lang="ts">
22
import { BlendFunction, VignetteEffect, VignetteTechnique } from 'postprocessing'
33
import { omit } from '../../util/object'
44
import { makePropWatchersUsingAllProps } from '../../util/prop'
@@ -13,7 +13,9 @@ export interface VignetteProps {
1313
offset: number
1414
darkness: number
1515
}
16+
</script>
1617

18+
<script lang="ts" setup>
1719
const props = withDefaults(defineProps<VignetteProps>(), {
1820
technique: VignetteTechnique.DEFAULT,
1921
blendFunction: BlendFunction.NORMAL,

src/core/pmndrs/index.ts

Lines changed: 19 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,14 @@
1-
import Bloom from './Bloom.vue'
1+
/* eslint-disable perfectionist/sort-named-exports */
2+
3+
import Bloom, { type BloomProps } from './Bloom.vue'
24
import { useEffect } from './composables/useEffect'
3-
import DepthOfField from './DepthOfField.vue'
4-
import EffectComposer from './EffectComposer.vue'
5-
import Glitch from './Glitch.vue'
6-
import Noise from './Noise.vue'
7-
import Outline from './Outline.vue'
8-
import Pixelation from './Pixelation.vue'
9-
import Vignette from './Vignette.vue'
5+
import DepthOfField, { type DepthOfFieldProps } from './DepthOfField.vue'
6+
import EffectComposer, { type EffectComposerProps } from './EffectComposer.vue'
7+
import Glitch, { type GlitchProps } from './Glitch.vue'
8+
import Noise, { type NoiseProps } from './Noise.vue'
9+
import Outline, { type OutlineProps } from './Outline.vue'
10+
import Pixelation, { type PixelationProps } from './Pixelation.vue'
11+
import Vignette, { type VignetteProps } from './Vignette.vue'
1012

1113
export {
1214
Bloom,
@@ -18,4 +20,13 @@ export {
1820
Pixelation,
1921
useEffect,
2022
Vignette,
23+
24+
BloomProps,
25+
DepthOfFieldProps,
26+
EffectComposerProps,
27+
GlitchProps,
28+
NoiseProps,
29+
OutlineProps,
30+
PixelationProps,
31+
VignetteProps,
2132
}

src/core/three/EffectComposer.vue

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -6,15 +6,18 @@ import { RenderPass } from 'three/examples/jsm/postprocessing/RenderPass.js'
66
import { type InjectionKey, onUnmounted, provide, type ShallowRef, shallowRef, watchEffect } from 'vue'
77
88
export const effectComposerInjectionKey: InjectionKey<ShallowRef<EffectComposer | null>> = Symbol('effectComposerThree')
9-
</script>
109
11-
<script lang="ts" setup>
12-
const props = withDefaults(defineProps<{
10+
export interface EffectComposerProps {
1311
enabled?: boolean
1412
withoutRenderPass?: boolean
15-
}>(), {
16-
enabled: true,
17-
})
13+
}
14+
</script>
15+
16+
<script lang="ts" setup>
17+
const props = withDefaults(
18+
defineProps<EffectComposerProps>(),
19+
{ enabled: true },
20+
)
1821
1922
const effectComposer: ShallowRef<EffectComposer | null> = shallowRef(null)
2023
provide(effectComposerInjectionKey, effectComposer)

src/core/three/Halftone.vue

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ export enum HalftoneShape {
1313
Square = 4,
1414
}
1515
16-
interface HalftonePassProps {
16+
export interface HalftoneProps {
1717
shape?: HalftoneShape
1818
radius?: number
1919
rotateR?: number
@@ -27,7 +27,7 @@ interface HalftonePassProps {
2727
</script>
2828

2929
<script lang="ts" setup>
30-
const props = defineProps<HalftonePassProps>()
30+
const props = defineProps<HalftoneProps>()
3131
const { sizes } = useTresContext()
3232
3333
const shakedProps = computed(() =>

src/core/three/SMAA.vue

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,18 @@
1-
<script lang="ts" setup>
1+
<script lang="ts">
22
import { useTresContext } from '@tresjs/core'
33
import { useDevicePixelRatio } from '@vueuse/core'
44
import { SMAAPass } from 'three/examples/jsm/postprocessing/SMAAPass.js'
55
import { computed, watchEffect } from 'vue'
66
import { useEffect } from './composables/useEffect'
77
8-
const props = defineProps<{
8+
export interface SMAAProps {
99
width?: number
1010
height?: number
11-
}>()
11+
}
12+
</script>
13+
14+
<script lang="ts" setup>
15+
const props = defineProps<SMAAProps>()
1216
1317
const { sizes } = useTresContext()
1418
const { pixelRatio } = useDevicePixelRatio() // the renderers pixel ratio is not used because it is not reactive

0 commit comments

Comments
 (0)