|
| 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, LinocutPmndrs } from '@tresjs/post-processing' |
| 8 | +
|
| 9 | +import '@tresjs/leches/styles' |
| 10 | +
|
| 11 | +const gl = { |
| 12 | + clearColor: '#00ff00', |
| 13 | + toneMapping: NoToneMapping, |
| 14 | + multisampling: 8, |
| 15 | + envMapIntensity: 10, |
| 16 | +} |
| 17 | +
|
| 18 | +const { blendFunction, scale, noiseScale, centerX, centerY, rotation } = useControls({ |
| 19 | + scale: { value: 0.85, step: 0.01, min: 0, max: 1 }, |
| 20 | + noiseScale: { value: 0.0, step: 0.01, min: 0, max: 1 }, |
| 21 | + centerX: { value: 0.5, step: 0.01, min: 0, max: 1 }, |
| 22 | + centerY: { value: 0.5, step: 0.01, min: 0, max: 1 }, |
| 23 | + rotation: { value: 0.0, step: 0.01, min: -Math.PI, max: Math.PI }, |
| 24 | + blendFunction: { |
| 25 | + options: Object.keys(BlendFunction).map(key => ({ |
| 26 | + text: key, |
| 27 | + value: BlendFunction[key as keyof typeof BlendFunction], |
| 28 | + })), |
| 29 | + value: BlendFunction.NORMAL, |
| 30 | + }, |
| 31 | +}) |
| 32 | +</script> |
| 33 | + |
| 34 | +<template> |
| 35 | + <TresLeches /> |
| 36 | + |
| 37 | + <TresCanvas |
| 38 | + v-bind="gl" |
| 39 | + > |
| 40 | + <TresPerspectiveCamera |
| 41 | + :position="[0, 6.5, 6.5]" |
| 42 | + /> |
| 43 | + <OrbitControls auto-rotate /> |
| 44 | + |
| 45 | + <TresAmbientLight :intensity="1" /> |
| 46 | + |
| 47 | + <TresMesh> |
| 48 | + <TresBoxGeometry :args="[2, 2, 2]" /> |
| 49 | + <TresMeshStandardMaterial color="yellow" :roughness=".5" :metalness="1" /> |
| 50 | + </TresMesh> |
| 51 | + |
| 52 | + <Suspense> |
| 53 | + <Environment :blur=".25" preset="snow" /> |
| 54 | + </Suspense> |
| 55 | + |
| 56 | + <ContactShadows |
| 57 | + :opacity=".65" |
| 58 | + :position-y="-1" |
| 59 | + :scale="35" |
| 60 | + :blur="1" |
| 61 | + /> |
| 62 | + |
| 63 | + <Suspense> |
| 64 | + <EffectComposerPmndrs> |
| 65 | + <LinocutPmndrs |
| 66 | + :scale="scale.value" |
| 67 | + :noiseScale="noiseScale.value" |
| 68 | + :center="[centerX.value, centerY.value]" |
| 69 | + :rotation="rotation.value" |
| 70 | + :blendFunction="Number(blendFunction.value)" |
| 71 | + /> |
| 72 | + </EffectComposerPmndrs> |
| 73 | + </Suspense> |
| 74 | + </TresCanvas> |
| 75 | +</template> |
0 commit comments