Problem with finding animations in gltf file using actor class

Hello,
I am new to panda3d and am trying create an animated entity using the actor class.
I have exported the models using block bench as a gltf file which has 2 animations within it however the actor.getAnimNames() method returns an empty list. I have additionally thrown the method within a try catch statement which returns the error : list index out of range. The model itself also loads completely fine however the animation’s do not play.

Any help would be greatly appreciated.

The code:


from ursina import *
from ursina.shaders import lit_with_shadows_shader
from direct.actor.Actor import Actor

app = Ursina()

pig = Entity(model=load_model("path the gltf"), rotation=(0, 90, 0))

model_path = load_model("path the gltf")

actor = Actor(model_path, {"WalkAnimation": "path the gltf"})
actor.reparent_to(pig)

def update():
    actor.loop('WalkAnimation')
    try:
        anim_names = actor.getAnimNames()
        current_anim = actor.getCurrentAnim()
        print(anim_names)
        print(current_anim)
    except Exception as e:
        print(f"Error accessing animations: {e}")

app.run()

the models? Also, Blockbench allows the user to create bones?
I need a bit more detail on your models, I don’t want to jump to conclusions.
However, I’d like to point out that if your models don’t have bones, you’ll need to use ursina’s FrameAnimation3d prefab :wink:

Hello and thank you for your response.
Yes I believe block bench does allow for you to create bones through pivot points which are used for animations. It also allows for these models to be exported as a gltf file. I am also able to export as a obj and export the animations as json files. I have read through the gltf file and it does include the animations. I’m unsure if the issue is with ursina or with the file. If there is an alternative method for running the animations as well that would be helpful to know.

Greetings! (To both of you!) Welcome to the forums, and I hope that you find your time here to be positive! :slight_smile:

So, let me start by saying that, if the problem turns out to lie with Ursina, then it might be more helpful to take this to an Ursina-specific venue.

That said, the problem may of course lie elsewhere, so let’s investigate…

First of all, lachdigger, do you have “panda3d-gltf” installed? (Or does Ursina perhaps install it…?)

Second–and once panda3d-gltf has been confirmed to be installed–you might try viewing your model in the “gltf-viewer” command-line program. See whether the animations show up there…

(For more on both of these–including installation of panda3d-gltf if you don’t have it–take a look at the following manual page:
https://docs.panda3d.org/1.10/python/pipeline/gltf-files
)

And finally, would you be willing to try to create a simple test-model that exhibits this same issue? Something like a simple cube with a basic back-and-forth animation.

If so, then that might give us something to examine on our end, to perhaps find a potential source of the problem.

To eliminate unnecessary confusion about the problem with the engine, you need to make the animation play in the standard glTF format viewer from Khronos

1 Like

Hello,

I have ensured that panda3d-gltf has been installed.
I tried view it through the command-line how ever it could not be loaded/opened.
I also got a message saying: :framework(warning): Empty bounding volume for models.

I had created a rotating cube test model through block bench which was also animated however experienced similar issues with that as well. Was also unable to view it through command line.

Lastly I used gltf viewer from Khronos and the model loaded completely fine with its animations.

You need to keep in mind that Panda3D only supports bone and morph animations. Object animation is currently not possible.

The animations should be and bone and morph. They were animated within block bench using it’s animator.

Okay, that’s interesting–and only more so that the model showed up in the Khronos viewer.

It sounds like there’s a compatibility issue somewhere: the exporter for Blockbench is producing output that doesn’t match what Panda3D expects, I’d guess.

Would you be willing to share the “rotating cube” model, please, so that we can examine it?

testCube.gltf (5.2 KB)
sure here is the cube model.

When I load your model through the interface of the actor class, I get this message.

:Actor(warning): testCube.gltf is not a character!

This means that the model has no bone armature. Accordingly, the animation cannot be played.

I see, thank you.
Do you know if there is a way I can add in bone armatures through block bench? Or should I try and use another 3D software like blender and if so would I have to re-animate the models?

That’s what I thought, since you’re using Ursina, you should be using Blender, yes. And if you’re creating animations without bone armature, you’ll need to go through the FrameAnimation3d prefab :+1: