|
| 1 | +<script setup lang="ts"> |
| 2 | +import { OrbitControls } from '@tresjs/cientos' |
| 3 | +import { TresCanvas } from '@tresjs/core' |
| 4 | +import { TresLeches, useControls } from '@tresjs/leches' |
| 5 | +import { Physics, RigidBody } from '@tresjs/rapier' |
| 6 | +import { ACESFilmicToneMapping, SRGBColorSpace } from 'three' |
| 7 | +import '@tresjs/leches/styles' |
| 8 | +
|
| 9 | +const gl = { |
| 10 | + clearColor: '#82DBC5', |
| 11 | + shadows: true, |
| 12 | + alpha: false, |
| 13 | + outputColorSpace: SRGBColorSpace, |
| 14 | + toneMapping: ACESFilmicToneMapping, |
| 15 | +} |
| 16 | +
|
| 17 | +const { gravityY } = useControls({ |
| 18 | + gravityY: { value: 0, min: -20, max: 20, step: 0.1 }, |
| 19 | +}) |
| 20 | +</script> |
| 21 | + |
| 22 | +<template> |
| 23 | + <TresLeches /> |
| 24 | + <TresCanvas v-bind="gl" window-size> |
| 25 | + <TresPerspectiveCamera :position="[15, 15, 15]" :look-at="[0, 0, 0]" /> |
| 26 | + <OrbitControls /> |
| 27 | + |
| 28 | + <Suspense> |
| 29 | + <Physics debug :gravity="[0, gravityY, 0]"> |
| 30 | + <RigidBody> |
| 31 | + <TresMesh :position="[0, 8, 0]"> |
| 32 | + <TresTorusGeometry /> |
| 33 | + <TresMeshNormalMaterial /> |
| 34 | + </TresMesh> |
| 35 | + |
| 36 | + <TresMesh :position="[0, 5, 0]"> |
| 37 | + <TresBoxGeometry /> |
| 38 | + <TresMeshNormalMaterial /> |
| 39 | + </TresMesh> |
| 40 | + </RigidBody> |
| 41 | + |
| 42 | + <RigidBody v-for="ball in [1, 2, 3, 4, 5, 6, 7] " :key="ball" collider="ball"> |
| 43 | + <TresMesh :position="[Math.random() * 2, Math.random() * 2 + 8, Math.random() * 2]"> |
| 44 | + <TresSphereGeometry /> |
| 45 | + <TresMeshNormalMaterial /> |
| 46 | + </TresMesh> |
| 47 | + </RigidBody> |
| 48 | + |
| 49 | + <RigidBody type="fixed"> |
| 50 | + <TresMesh :position="[0, 0, 0]"> |
| 51 | + <TresPlaneGeometry :args="[20, 20, 20]" :rotate-x="-Math.PI / 2" /> |
| 52 | + <TresMeshBasicMaterial color="#f4f4f4" /> |
| 53 | + </TresMesh> |
| 54 | + </RigidBody> |
| 55 | + </Physics> |
| 56 | + </Suspense> |
| 57 | + </TresCanvas> |
| 58 | +</template> |
0 commit comments