5.4.0

GLTFModel

A component based on useGLTF to load models in TresJS scenes.

The GLTFModel component is a wrapper around useGLTF composable and accepts the same options as props.

Usage

<script setup lang="ts">
import { GLTFModel } from '@tresjs/cientos'

const path = './blender-cube.glb'
</script>

<template>
  <GLTFModel :path="path" />
</template>

Model reference

You can access the model reference by passing a ref to the model prop and then using to get the object.

<script setup lang="ts">
import type { TresObject } from 'tresjs'
import { GLTFModel } from '@tresjs/cientos'

const modelRef = shallowRef<TresObject>()

watch(modelRef, (model) => {
  // Do something with the model
  model.position.set(0, 0, 0)
})
</script>

<template>
  <GLTFModel
    ref="modelRef"
    path="https://raw.githubusercontent.com/Tresjs/assets/main/models/gltf/blender-cube.glb"
  />
</template>

Props

PropDescriptionDefault
pathPath to the model file.undefined
dracoEnable Draco compression for the model.false
decoderPathPath to a local Draco decoder.undefined
castShadowApply cast-shadow to all meshes inside your model.false
receiveShadowApply receive-shadow to all meshes inside your model.false