Forum Discussion

🚨 This forum is archived and read-only. To submit a forum post, please visit our new Developer Forum. 🚨
checksum's avatar
checksum
Explorer
1 year ago

gltf nodes of entity in composition using meta spatial sdk

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?

3 Replies

Replies have been turned off for this discussion
  • 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's avatar
    MetaStoreHelp
    Community Manager

    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

    • checksum's avatar
      checksum
      Explorer

      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...