|
| 1 | +<script setup lang="ts"> |
| 2 | +import { Environment, Levioso, OrbitControls } from '@tresjs/cientos' |
| 3 | +import { TresCanvas } from '@tresjs/core' |
| 4 | +import { TresLeches, useControls } from '@tresjs/leches' |
| 5 | +import { NoToneMapping } from 'three' |
| 6 | +import { BlendFunction } from 'postprocessing' |
| 7 | +import { ASCIIPmndrs, EffectComposerPmndrs } from '@tresjs/post-processing' |
| 8 | +
|
| 9 | +import '@tresjs/leches/styles' |
| 10 | +
|
| 11 | +const gl = { |
| 12 | + clearColor: '#ffffff', |
| 13 | + toneMapping: NoToneMapping, |
| 14 | +} |
| 15 | +
|
| 16 | +const glComposer = { |
| 17 | + multisampling: 4, |
| 18 | +} |
| 19 | +
|
| 20 | +const leviosoProps = { |
| 21 | + speed: 2, |
| 22 | + rotationFactor: 2, |
| 23 | + range: [-1, 1] as [number, number], |
| 24 | +} |
| 25 | +
|
| 26 | +const { size: textureSize, characters, font, fontSize, cellCount, enabled, blendFunction, opacity, cellSize, inverted, color, useSceneColor } = useControls({ |
| 27 | + enabled: true, |
| 28 | + cellSize: { value: 10, step: 1, min: 2, max: 64 }, |
| 29 | + useSceneColor: false, |
| 30 | + color: '#ffffff', |
| 31 | + inverted: false, |
| 32 | + characters: { value: ' .,:-~+=*≡TRESJCIENTOSLECHESPOSTPROCESSING3D#░▒▓█■▲◼◾' }, |
| 33 | + font: { value: 'Arial' }, |
| 34 | + fontSize: { value: 44, step: 1, min: 10, max: 100 }, |
| 35 | + size: { value: 1024, step: 128, min: 256, max: 2048, label: 'textureSize' }, |
| 36 | + cellCount: { value: 16, step: 1, min: 4, max: 64 }, |
| 37 | + opacity: { value: 1, step: 0.1, min: 0.0, max: 1.0 }, |
| 38 | + blendFunction: { |
| 39 | + options: Object.keys(BlendFunction).map(key => ({ |
| 40 | + text: key, |
| 41 | + value: BlendFunction[key as keyof typeof BlendFunction], |
| 42 | + })), |
| 43 | + value: BlendFunction.LINEAR_BURN, |
| 44 | + }, |
| 45 | +}) |
| 46 | +</script> |
| 47 | + |
| 48 | +<template> |
| 49 | + <div class="aspect-16/9"> |
| 50 | + <TresCanvas |
| 51 | + v-bind="gl" |
| 52 | + > |
| 53 | + <TresPerspectiveCamera :position="[5, 3, 7]" /> |
| 54 | + <OrbitControls auto-rotate /> |
| 55 | + |
| 56 | + <Levioso v-bind="leviosoProps"> |
| 57 | + <TresMesh :position="[-2, .5, 0]"> |
| 58 | + <TresBoxGeometry :args="[2, 2, 2]" /> |
| 59 | + <TresMeshPhysicalMaterial color="white" /> |
| 60 | + </TresMesh> |
| 61 | + </Levioso> |
| 62 | + |
| 63 | + <Levioso v-bind="leviosoProps"> |
| 64 | + <TresMesh :position="[3, .5, 0]"> |
| 65 | + <TresSphereGeometry :args="[1.5, 32, 32]" /> |
| 66 | + <TresMeshPhysicalMaterial color="white" /> |
| 67 | + </TresMesh> |
| 68 | + </Levioso> |
| 69 | + |
| 70 | + <Suspense> |
| 71 | + <Environment background :blur="0.2" preset="snow" /> |
| 72 | + </Suspense> |
| 73 | + |
| 74 | + <Suspense> |
| 75 | + <EffectComposerPmndrs v-bind="glComposer"> |
| 76 | + <ASCIIPmndrs |
| 77 | + :blendFunction="enabled ? Number(blendFunction) : Number(BlendFunction.SKIP)" |
| 78 | + :opacity="opacity" |
| 79 | + :cellSize="cellSize" |
| 80 | + :inverted="inverted" |
| 81 | + :color="color" |
| 82 | + :useSceneColor="useSceneColor" |
| 83 | + :asciiTexture="{ |
| 84 | + characters, |
| 85 | + font, |
| 86 | + fontSize, |
| 87 | + size: textureSize, |
| 88 | + cellCount, |
| 89 | + }" |
| 90 | + /> |
| 91 | + </EffectComposerPmndrs> |
| 92 | + </Suspense> |
| 93 | + </TresCanvas> |
| 94 | + </div> |
| 95 | + <TresLeches :float="false" /> |
| 96 | +</template> |
0 commit comments