Skip to content

Commit

Permalink
docs: halftone
Browse files Browse the repository at this point in the history
  • Loading branch information
alvarosabu committed Oct 4, 2024
1 parent b683fa0 commit 3755b76
Show file tree
Hide file tree
Showing 3 changed files with 92 additions and 0 deletions.
54 changes: 54 additions & 0 deletions docs/.vitepress/theme/components/three/HalftoneThreeDemo.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
<script lang="ts" setup>
import { OrbitControls } from '@tresjs/cientos'
import { TresCanvas } from '@tresjs/core'
import { EffectComposer, Halftone } from '@tresjs/post-processing/three'
import { useRouteDisposal } from '../../composables/useRouteDisposal'
// Need to dispose of the effect composer when the route changes because Vitepress doesnt unmount the components
const { effectComposer } = useRouteDisposal()
</script>

<template>
<TresCanvas
clear-color="#121212"
:alpha="false"
:shadows="true"
>
<TresPerspectiveCamera
:position="[3, 2, 4]"
:look-at="[0, 0, 0]"
/>
<OrbitControls />
<TresMesh
:position="[1, 0.5, 1]"
>
<TresBoxGeometry />
<TresMeshStandardMaterial
color="hotpink"
/>
</TresMesh>
<TresMesh
:position="[-1.5, 0.75, 0]"
>
<TresConeGeometry :args="[1, 1.5, 4, 1, false, Math.PI * 0.25]" />
<TresMeshNormalMaterial />
<TresMeshStandardMaterial
color="aqua"
/>
</TresMesh>

<TresGridHelper />
<TresAmbientLight :intensity="0.9" />
<TresDirectionalLight
:position="[-10, 5, 8]"
:intensity="2"
/>

<Suspense>
<EffectComposer ref="effectComposer">
<Halftone :shape="1" :radius="4" :rotateR="Math.PI / 12" :rotateG="Math.PI / 3" :rotateB="Math.PI / 6" :scatter="0" :blending="1" :greyscale="false" />
</EffectComposer>
</Suspense>
</TresCanvas>
</template>
2 changes: 2 additions & 0 deletions docs/components.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,13 @@ declare module 'vue' {
export interface GlobalComponents {
BlenderCube: typeof import('./.vitepress/theme/components/BlenderCube.vue')['default']
BloomDemo: typeof import('./.vitepress/theme/components/pmdrs/BloomDemo.vue')['default']
copy: typeof import('./.vitepress/theme/components/three/PixelationThreeDemo copy.vue')['default']
DepthOfFieldDemo: typeof import('./.vitepress/theme/components/pmdrs/DepthOfFieldDemo.vue')['default']
DocsDemo: typeof import('./.vitepress/theme/components/DocsDemo.vue')['default']
GlitchDemo: typeof import('./.vitepress/theme/components/pmdrs/GlitchDemo.vue')['default']
GlitchThreeDemo: typeof import('./.vitepress/theme/components/three/GlitchThreeDemo.vue')['default']
GlitchTreeDemo: typeof import('./.vitepress/theme/components/three/GlitchTreeDemo.vue')['default']
HalftoneThreeDemo: typeof import('./.vitepress/theme/components/three/HalftoneThreeDemo.vue')['default']
LoveVueThreeJS: typeof import('./.vitepress/theme/components/LoveVueThreeJS.vue')['default']
NoiseDemo: typeof import('./.vitepress/theme/components/pmdrs/NoiseDemo.vue')['default']
OutlineDemo: typeof import('./.vitepress/theme/components/pmdrs/OutlineDemo.vue')['default']
Expand Down
36 changes: 36 additions & 0 deletions docs/guide/three/halftone.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
# Halftone

<DocsDemo>
<HalftoneThreeDemo />
</DocsDemo>

Halftone is an effect that simulates the halftone printing technique, which uses dots of varying sizes and spacing to create the illusion of continuous tone images. This effect can be used to give your 3D scenes a unique, comic book-like appearance.

## Usage

```vue
<script setup lang="ts">
import { EffectComposer, Halftone } from '@tresjs/post-processing/three'
</script>
<template>
<EffectComposer>
<Halftone :shape="1" :radius="4" :rotateR="Math.PI / 12" :rotateG="Math.PI / 3" :rotateB="Math.PI / 6" :scatter="0" :blending="1" :greyscale="false" />
</EffectComposer>
</template>
```
## Props

## Props

| Prop | Description | Default |
|---------------|---------------------------------------------------------------------------------------------------|---------|
| `shape` | The shape of the halftone dots. Can be `1` (Dot), `2` (Ellipse), `3` (Line), or `4` (Square). | `1` |
| `radius` | The radius of the halftone dots. | `4` |
| `rotateR` | The rotation of the red channel. | `0` |
| `rotateG` | The rotation of the green channel. | `0` |
| `rotateB` | The rotation of the blue channel. | `0` |
| `scatter` | The scatter of the halftone dots. | `0` |
| `blending` | The blending mode of the halftone effect. | `1` |
| `greyscale` | If true, the halftone effect will be in greyscale. | `false` |
| `blendingMode`| The blending mode used for the halftone effect. | `1` |

0 comments on commit 3755b76

Please sign in to comment.