Three Vue3Three Vue3
Guide
  • English
  • 简体中文
GitHub
Guide
  • English
  • 简体中文
GitHub
    • Getting Started
    • Scene
    • SkyBox
    • Model Loader

      • Component Loader
      • Function Loader
    • Popup
    • Movable Element
    • Animation
      • Default Usage
      • Methods
    • Mesh

      • Wave Circle Mesh
    • Effect

      • Bloom

type

Class

Default Usage

Click me to view the codes
<template>
  <tv-scene class="scene" bg-color="#FAEBD7" @created="created"></tv-scene>
</template>

<script lang="ts" setup>
import { GLTFLoader, Animation } from 'three-vue3'

const created = async (scene, { camera }) => {
  scene.position.set(0, -0.5, 0)
  camera.position.set(0, 1.5, 3)

  // Load model to scene.
  const model = await GLTFLoader('/models/perseverance.glb')
  scene.add(model)

  // Play animation.
  const animation = new Animation(model)
  animation.playAll()
}
</script>

<style>
.scene {
  margin-top: 10px;
  width: 100%;
  height: 300px;
}
</style>

Methods

NameParametersDescription
constructor(mesh: THREE.Mesh) => voidmesh is the mesh containing the animation.
set(index: number) => thisindex is the index of the animation to play. The default is 0.
setByName(name: string) => thisname is the name of the animation to play.
setLoop(loop: typeof THREE.LoopOnce | typeof THREE.LoopRepeat | typeof THREE.LoopPingPong) => thisloop is the loop mode. The default is LoopRepeat.
setTimeScale(timeScale: number) => thistimeScale is the time scale of the animation.
setClampWhenFinished(clampWhenFinished: boolean) => thisclampWhenFinished is the clamp when finished of the animation.
play() => voidPlay the animation. Default is the first animation of the mesh contained. If you want to play a specific animation, you need to call set or setByName first.
playAll() => voidPlay all animations of the mesh contained.
stop() => voidStop the animation. Only stop the animation using play method played.
stopAll() => voidStop all animations using playAll method played.
pause() => voidPause the animation. Only pause the animation using play method played.
pauseAll() => voidPause all animations using playAll method played.
Edit this page on GitHub
Last Updated:
Contributors: Shing Rui
Prev
Movable Element