Extracting transforms from GLTF imported models/scenes?

Hey folks! Just getting started with js and three.js, pardon the basic question.

I’m looking to build a scene in Maya for a small game and set up positions for a first person camera to animate and “snap” to. I’m hoping to do this programmatically without manually writing x/y/z/rotation values into the script itself, and grab updates from objects in the 3D scene.

When generating GLTF models the polys are in the correct place, but inherently transforms are set to zero and not maintained from the original scene.

What’s an efficient way to extract data from transforms within the scene? I can add children objects ahead of time, deliberately convert my set up cameras to verts or something, or skip the whole thing and write out a JSON that we parse to skip the whole GLTF bit of it.

Thanks in advance!

  1. Could you share any model / code sample of what kind of model you’re loading?
  2. To get an absolute position, it should be enough to use Object3D.getWorldPosition - it should work regardless of how your model is set up, as long as the mesh is a separate child within the model (there’s also getWorldDirection, but if you’re saying transforms are set to 0 on every child within your model, it will likely not help much.)

@mjurczyk, thanks for the reply, sorry I didn’t post a while back. Was really me just not understanding how the GLTF loader works.

Assuming I named things properly in the Maya scene, each object has a separate entry in the GLTF file, and such in the ThreeJS scene. All I have to do then is:

var object = scene.getObjectByName( "objectName" );

and I can use the transforms of those objects however I need, all is well.