For AI agents: the complete documentation index is available at /vue-vrm/llms.txt, the full documentation bundle is available at /vue-vrm/llms-full.txt, and this page is available as Markdown at /vue-vrm/api/instance.md.

Instance API

Access the instance through a template ref. Use the VrmCanvasExposed type for type checking.

<script setup lang="ts">
  import { ref } from 'vue';
  import { VrmCanvas, type VrmCanvasExposed } from 'vue-vrm';

  const canvas = ref<VrmCanvasExposed>();

  function logBones(): void {
    const humanoid = canvas.value?.getVrm()?.humanoid;
    console.log(humanoid?.getNormalizedBoneNode('head'));
  }
</script>

<template>
  <VrmCanvas ref="canvas" :model-data="modelData" />
  <button type="button" @click="logBones">Log head bone</button>
</template>
Info

The renderer is created after mount, and the model after it has loaded. Until then, the getters return undefined.

Playback

MethodReturnsDescription
playAnimation(data, weights?)Promise<void>Loads and plays animation data, replacing the current one.
pauseAnimation()voidPauses at the current frame.
resumeAnimation()voidResumes a paused animation.
stopAnimation()voidStops and rewinds to the start.

Expressions

MethodReturnsDescription
getExpressionNames()VrmExpressionNamesPreset and custom expression names defined by the model. Empty when no model is loaded.
setExpression(name, weight)voidSets a weight without Vue reactivity. Applied on the next frame. Suited to lip sync.
resetExpressions()voidClears values set with setExpression(). Those expressions return to 0.

Camera and output

MethodReturnsDescription
resetCamera()voidReturns the camera to the position that frames the model.
captureScreenshot(format?)stringRenders the current frame and returns a data URL. format defaults to 'image/png'. Throws before the renderer is ready.

three.js objects

MethodReturnsDescription
getVrm()VRM | undefinedThe loaded VRM.
getScene()Scene | undefinedThe scene.
getCamera()PerspectiveCamera | undefinedThe camera.
getRenderer()WebGLRenderer | undefinedThe renderer.
getMixer()AnimationMixer | undefinedThe animation mixer, while an animation is loaded.
getCanvas()HTMLCanvasElement | undefinedThe <canvas> element.
Warning

Objects returned by these methods are owned by the component. They are disposed when the model changes or the component is unmounted, so do not keep references to them.

Deprecated

MethodReplacement
resetCameraPose()resetCamera()