1
$\begingroup$

I'm trying to do a best-as-I-can recreation of a blender scene in three.js simply from exporting it. So far the simplest / best way to start doing this is through the GTLF exporter / loader in THREE.js, which works great for the model and basic animations.

However, as seen in the still in progress documentation, it says:

Animation glTF allows multiple animations per file, with animations targeted to particular objects at time of export. To ensure that an animation is included, either (a) make it the active Action on the object, (b) create a single-strip NLA track, or (c) stash the action.

Note

Only certain types of animation are supported:

Keyframe (translation, rotation, scale) Shape Keys Armatures / Skinning

Animation of other properties, like lights or materials, will be ignored.

The question: how can I (or anyone else) implement a simple way to include animation of, lets say, the mapping node from cycleS? The main python source is here, and the file that reads the materials is here, and the file that gets other animations is here, it seems like the key part in the last one is:

def __gather_path(channels: typing.Tuple[bpy.types.FCurve],
                  blender_object: bpy.types.Object,
                  export_settings
                  ) -> str:
    target = channels[0].data_path.split('.')[-1]
    path = {
        "delta_location": "translation",
        "delta_rotation_euler": "rotation",
        "location": "translation",
        "rotation_axis_angle": "rotation",
        "rotation_euler": "rotation",
        "rotation_quaternion": "rotation",
        "scale": "scale",
        "value": "weights"
    }.get(target)

    if target is None:
        raise RuntimeError("Cannot export an animation with {} target".format(target))

    return path

seemingly just adding the correct array value should do it maybe? But I don't know what to add, or what else to change to get this to work.

To clarify: I would mainly just like to be able to export the animation for the Mapping texture node's position/scale/rotation (for now).

$\endgroup$
  • 1
    $\begingroup$ The unsupported animation types are current limitations of the glTF format, not the exporter, so unfortunately there's nothing you can embed in the file that will work, unless you're also planning to customize THREE.GLTFLoader (which, technically, you could do). I do expect UV mapping animation to be supported by glTF in the future. $\endgroup$ – Don McCurdy Jan 4 at 8:34
  • $\begingroup$ @DonMcCurdy Yes I was planning o n customizing the three loader, but how can I go about it? Mainly, how, with blender python, can I get the animation node data in some kind of list (that can be eventually converted to JSON)? $\endgroup$ – Yaakov5777 Jan 4 at 19:39
  • $\begingroup$ I'm not too familiar with the Blender Python API, hopefully someone else can answer how to access the animation node data. Once you have it, I expect the glTF gitter channel or threejs forums could be helpful for the rest. $\endgroup$ – Don McCurdy Jan 4 at 20:18

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.