Skip to main content
Up and Coming
October 9, 2024

gltf nodes of entity in composition using meta spatial sdk

  • October 9, 2024
  • 3 replies
  • 878 views

I want to animate a gltf object manually.
I get my object using something like "composition.getNodeByName("myobject_gltf")"
How can I parse and modify the transformations of each node individually?

    This topic has been closed for replies.

    3 replies

    checksumAuthor
    Up and Coming
    October 10, 2024

    To be more clear, let's say that I have a clock face, and I want to set the time (see simplified gltf below).
    How can I set the ShorterBar and LongerBar rotation dynamically?
    The gltf is referenced in my composition.glfx. 

    Note that in my real application, it not a clockface and I have multiple moving part in my gltf.

    {
      "asset": {
        "version": "2.0"
      },
      "scene": 0,
      "scenes": [
        {
          "nodes": [0]
        }
      ],
      "nodes": [
        {
          "name": "Circle",
          "mesh": 0,
          "children": [1, 2]
        },
        {
          "name": "ShortBar",
          "mesh": 1,
          "rotation": [0, 0, 0, 1]  // Rotation quaternion for setting angle
        },
        {
          "name": "LongBar",
          "mesh": 2,
          "rotation": [0, 0, 0, 1]  // Rotation quaternion for setting angle
        }
      ]
    }



    MetaStoreHelp
    Community Manager
    October 17, 2024

    val shortBar: Entity = composition.getNodeByName("ShortBar").entity will give you access to the entity, you can edit that ent's transform in a system to "animate" it. This is assuming you are referring to a GLXF where each of the hands are their own GLTF

    If you're the author of a thread, remember to mark a reply as the Accepted Solution to help others find answers!
    checksumAuthor
    Up and Coming
    October 17, 2024

    Thanks but ShortBar is a GLTF node, not a GLXF nodes.
    My GLTF's are complex mechanisms that can be hard to convert into GLXF components (can be difficult,I think, maybe it can be my solution ?).

    I already do something like 
    val shortBar: clock= composition.getNodeByName("clock").entity
    and I want to do
    val Shortbar = clock.getgltfnode("ShortBar").node (of course getgltfnode is a sample)....
    Shortbat.rotate(...)

    In final, I want to be able to parse a gltf and animate myself without using internal animation of the gltf.
    I do it in unity, webxr, c++ but I want to use kotlin/java and mix with already available android API...