9
7

More than 3 years have passed since last update.

Blender 複数のアニメーションを持つglTFを書き出す方法

Posted at

概要

Blender上で、1つのオブジェクトに対して複数のアニメーションが存在するようなglTFファイルの書き出し方が分からなかったのでメモ

結論

Nonlinear Animation Editor上で複数NlaTrackを追加すればいいです。

解説

結論は上記の通りですが、味気ないので書き出しまでの手順を記します。

Nonlinear Animation Editorを開きます
スクリーンショット 2020-08-08 20.22.59.png

適当にAction Editor上でActionを追加し、「Push Down」を押して Nonlinear Animation Editor に追加します。
スクリーンショット 2020-08-09 0.39.04.png

あとは、File > Export > glTF 2.0 でオブジェクトを書き出せばOKです。

書き出したglTFの中身にもちゃんと"animations"が存在していました。

    "animations" : [
        {
            "channels" : [
                {
                    "sampler" : 0,
                    "target" : {
                        "node" : 0,
                        "path" : "translation"
                    }
                }
            ],
            "name" : "Location",
            "samplers" : [
                {
                    "input" : 2,
                    "interpolation" : "LINEAR",
                    "output" : 3
                }
            ]
        },
        {
            "channels" : [
                {
                    "sampler" : 0,
                    "target" : {
                        "node" : 0,
                        "path" : "rotation"
                    }
                }
            ],
            "name" : "Rotation",
            "samplers" : [
                {
                    "input" : 2,
                    "interpolation" : "LINEAR",
                    "output" : 4
                }
            ]
        },
        {
            "channels" : [
                {
                    "sampler" : 0,
                    "target" : {
                        "node" : 0,
                        "path" : "scale"
                    }
                }
            ],
            "name" : "Scale",
            "samplers" : [
                {
                    "input" : 2,
                    "interpolation" : "LINEAR",
                    "output" : 5
                }
            ]
        }
    ],

また、glTF Tools Extension for Visual Studio Codeで動作確認もしたところ無事再生もできました。
gltf-animation.gif

9
7
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
9
7