For AI agents: the complete documentation index is available at /vue-vrm/ja/llms.txt, the full documentation bundle is available at /vue-vrm/ja/llms-full.txt, and this page is available as Markdown at /vue-vrm/ja/api/instance.md.
  • 日本語
  • インスタンスAPI

    インスタンスにはテンプレート参照からアクセスします。型チェックにはVrmCanvasExposed型を使います。

    <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

    レンダラーはマウント後に、モデルは読み込みが終わった後に作られます。それまでは、取得系のメソッドはundefinedを返します。

    再生

    メソッド戻り値説明
    playAnimation(data, weights?)Promise<void>アニメーションを読み込んで再生します。再生中のものは置き換えます。
    pauseAnimation()void現在のフレームで一時停止します。
    resumeAnimation()void一時停止したアニメーションを再開します。
    stopAnimation()void停止して先頭に戻します。

    表情

    メソッド戻り値説明
    getExpressionNames()VrmExpressionNamesモデルに定義されたプリセットとカスタムの表情名です。モデルがないときは空です。
    setExpression(name, weight)voidVueのリアクティブ機構を通さずに重みを設定します。次のフレームで反映されます。リップシンク向けです。
    resetExpressions()voidsetExpression()で設定した値を消去します。それらの表情は0に戻ります。

    カメラと出力

    メソッド戻り値説明
    resetCamera()voidモデル全体が収まる位置にカメラを戻します。
    captureScreenshot(format?)string現在のフレームを描画し、データURLで返します。formatの既定値は'image/png'です。レンダラーの準備前に呼ぶと例外を投げます。

    three.jsのオブジェクト

    メソッド戻り値説明
    getVrm()VRM | undefined読み込んだVRMです。
    getScene()Scene | undefinedシーンです。
    getCamera()PerspectiveCamera | undefinedカメラです。
    getRenderer()WebGLRenderer | undefinedレンダラーです。
    getMixer()AnimationMixer | undefinedアニメーションを読み込んでいる間のミキサーです。
    getCanvas()HTMLCanvasElement | undefined<canvas>要素です。
    Warning

    これらのメソッドが返すオブジェクトはコンポーネントが管理しています。モデルの差し替えやアンマウントのときに破棄されるので、参照を保持し続けないでください。

    非推奨

    メソッド代わりに使うもの
    resetCameraPose()resetCamera()