|
| 1 | +<script setup lang="ts"> |
| 2 | +import { ContactShadows, Environment, 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 { EffectComposerPmndrs, GridPmndrs } from '@tresjs/post-processing' |
| 8 | +
|
| 9 | +import '@tresjs/leches/styles' |
| 10 | +
|
| 11 | +const gl = { |
| 12 | + clearColor: '#ffffff', |
| 13 | + toneMapping: NoToneMapping, |
| 14 | + multisampling: 8, |
| 15 | +} |
| 16 | +
|
| 17 | +const { blendFunction, scale, lineWidth } = useControls({ |
| 18 | + blendFunction: { |
| 19 | + options: Object.keys(BlendFunction).map(key => ({ |
| 20 | + text: key, |
| 21 | + value: BlendFunction[key as keyof typeof BlendFunction], |
| 22 | + })), |
| 23 | + value: BlendFunction.OVERLAY, |
| 24 | + }, |
| 25 | + scale: { value: 0.25, step: 0.01, min: 0.0, max: 2.0 }, |
| 26 | + lineWidth: { value: 0.1, step: 0.01, max: 2.0 }, |
| 27 | +}) |
| 28 | +</script> |
| 29 | + |
| 30 | +<template> |
| 31 | + <div class="aspect-16/9"> |
| 32 | + <TresCanvas |
| 33 | + v-bind="gl" |
| 34 | + > |
| 35 | + <TresPerspectiveCamera :position="[5, 5, 5]" /> |
| 36 | + <OrbitControls auto-rotate /> |
| 37 | + |
| 38 | + <TresMesh :position="[0, .5, 0]"> |
| 39 | + <TresBoxGeometry :args="[2, 2, 2]" /> |
| 40 | + <TresMeshPhysicalMaterial color="black" :roughness=".25" /> |
| 41 | + </TresMesh> |
| 42 | + |
| 43 | + <ContactShadows |
| 44 | + :opacity="1" |
| 45 | + :position-y="-.5" |
| 46 | + /> |
| 47 | + |
| 48 | + <Suspense> |
| 49 | + <Environment background :blur=".5" preset="snow" /> |
| 50 | + </Suspense> |
| 51 | + |
| 52 | + <Suspense> |
| 53 | + <EffectComposerPmndrs> |
| 54 | + <GridPmndrs |
| 55 | + :blendFunction="Number(blendFunction)" |
| 56 | + :scale="scale" |
| 57 | + :lineWidth="lineWidth" |
| 58 | + /> |
| 59 | + </EffectComposerPmndrs> |
| 60 | + </Suspense> |
| 61 | + </TresCanvas> |
| 62 | + </div> |
| 63 | + <TresLeches :float="false" /> |
| 64 | +</template> |
0 commit comments