Using FBXModel
The FBXModel
component is a wrapper around useFBX
composable and accepts the same options as props.
Usage
vue
<script setup lang="ts">
import { FBXModel, OrbitControls } from '@tresjs/cientos'
import { TresCanvas } from '@tresjs/core'
import { BasicShadowMap, NoToneMapping, SRGBColorSpace } from 'three'
const gl = {
clearColor: '#82DBC5',
shadows: true,
alpha: false,
shadowMapType: BasicShadowMap,
outputColorSpace: SRGBColorSpace,
toneMapping: NoToneMapping,
}
</script>
<template>
<TresCanvas v-bind="gl">
<TresPerspectiveCamera :position="[5.3, 2.45, 9.3]" :look-at="[0, 0, 0]" />
<OrbitControls />
<FBXModel
path="https://raw.githubusercontent.com/Tresjs/assets/main/models/fbx/low-poly-truck/Jeep_done.fbx"
cast-shadow
:scale="0.01"
:position="[0, -1.6, 0]"
:rotation-y="-Math.PI * 0.5"
/>
<TresMesh
:rotate-x="Math.PI * -0.5"
:position-y="-2"
receive-shadow
>
<TresPlaneGeometry :args="[40, 40]" />
<TresMeshStandardMaterial :color="0xF7F7F7" />
</TresMesh>
<TresAmbientLight :intensity="1" />
<TresDirectionalLight
:intensity="1"
cast-shadow
:position="[5, 10, 5]"
/>
</TresCanvas>
</template>
Model reference
You can access the model reference by passing a ref
to the FBXModel
component and then using it to get the object.
vue
<script setup lang="ts">
import type { TresObject } from '@tresjs/core'
import { FBXModel, OrbitControls } from '@tresjs/cientos'
const modelRef = shallowRef<TresObject>()
watch(modelRef, (model) => {
// Do something with the model
model.position.set(0, 0, 0)
})
</script>
<template>
<FBXModel
ref="modelRef"
path="https://raw.githubusercontent.com/Tresjs/assets/main/models/fbx/low-poly-truck/Jeep_done.fbx"
/>
</template>
Props
Prop | Description | Default |
---|---|---|
path | Path to the model file. | undefined |
castShadow | Apply cast-shadow to all meshes inside your model. | false |
receiveShadow | Apply receive-shadow to all meshes inside your model. | false |