Skip to content
On this page

useGLTF

A composable that allows you to easily load glTF models into your TresJS scene.

Usage

ts
import { useGLTF } from '@tresjs/cientos'

const { scene } = await useGLTF('/models/AkuAku.gltf')

Then is as straightforward as adding the scene to your scene:

html
<TresCanvas shadows alpha>
  <Suspense>
    <TresMesh v-bind="scene" />
  </Suspense>
</TresCanvas>

An advantage of using useGLTFis that you can pass a draco prop to enable Draco compression for the model. This will reduce the size of the model and improve performance.

ts
import { useGLTF } from '@tresjs/cientos'

const { scene } = await useGLTF('/models/AkuAku.gltf', { draco: true })

Options

NameTypeDefaultDescription
dracobooleanfalseWhether to enable Draco compression.
decoderPathstringundefinedLocal path to the Draco decoder.