GLB Model Animation

When I perform the following code to rotate the glb model, the center of the rotation is shifted to the right hand side. Any idea? Thanks.

[https://drive.google.com/file/d/1Snb6kWNhlBQIl7ZYx1qoj37Eu_KulTch/view?usp=sharing] (GLB model)

var towercrane = viewer.entities.add({
        name : 'towercrane',
        position : Cesium.Cartesian3.fromDegrees(114.20687787712089, 22.317371897060156, 35),
        model: {
           uri: "./model/tower_crane_v5.glb",
          nodeTransformations : {
                 'crane_rotation': new Cesium.NodeTransformationProperty({
                    rotation: new Cesium.CallbackProperty(function(time, result) {
                        var angle = (time.secondsOfDay % (Math.PI * 2)) * 1;
                        return Cesium.Quaternion.fromAxisAngle(Cesium.Cartesian3.UNIT_Y, angle, result);
                    }, false)
                })
            }
        },

Hi, It’s not due to CesiumJS functionality. I’ve checked the glb file in gestaltor. You need to change center of your model’s node in the application like blender or in which you’ve created it.

  • Regards

The model itself seems to be fine. When you load it, straightforward, in a sandcastle like this

const viewer = new Cesium.Viewer("cesiumContainer");

var towercrane = viewer.entities.add({
  name : 'towercrane',
  position : Cesium.Cartesian3.fromDegrees(
    114.20687787712089, 22.317371897060156, 35),
  model: {
     uri: "http://localhost:8003/Models/tower_crane_v5.glb",
  }
});
viewer.zoomTo(viewer.entities);

and then press the “Play” button on the timeline, it looks correct:

Cesium Crane Animation

I don’t know what you wanted to achieve with the custom nodeTransformations, but apparently, this is what caused the issue…

1 Like

The model is working fine when it is played by a 3D player. Because it is a digital twin project, it reads an external IoT device to control the angle of rotation. i.e. we use a nodeTransformations function to control the angle of rotation for testing purpose. Anyway, I will re-align the center of the object per @Jacky advice.

Thanks.

From a quick look at the model and the animation channels/samplers, this might not be enough: Apparently, the ‘rotation’ animation affects the rotation of node 3, and the translation of node 3. So when only modifying the rotation of that node, the result might still be inconsistent. (But that might also depend on how exactly SimLabGLTF is exporting the model - you might be lucky, and it might work…)