Cesium 3d-tiles problem with tileset.modelMatrix

I've a tileset with heights moved.
Googling I found this code to displace the model:

  var heightOffset = 500.0;
  var tileset = widget.scene.primitives.add(new Cesium.Cesium3DTileset({
    url: '../cesium-ordesa/Scene/Teide_1.json'
  }));
  
  tileset.readyPromise.then(function(tileset) {
      var boundingSphere = tileset.boundingSphere;
      viewer.camera.viewBoundingSphere(boundingSphere, new Cesium.HeadingPitchRange(0, -2.0, 0));
      viewer.camera.lookAtTransform(Cesium.Matrix4.IDENTITY);
      // Position tileset
      var cartographic = Cesium.Cartographic.fromCartesian(boundingSphere.center);
      var surface = Cesium.Cartesian3.fromRadians(cartographic.longitude, cartographic.latitude, 0.0);
      var offset = Cesium.Cartesian3.fromRadians(cartographic.longitude, cartographic.latitude, heightOffset);
      var translation = Cesium.Cartesian3.subtract(offset, surface, new Cesium.Cartesian3());
      tileset.modelMatrix = Cesium.Matrix4.fromTranslation(translation);
      console.log(tileset.modelMatrix);
  });

The tileset.modelMatrix is set without errors, but nothing changes.
I've tried different values in heightOffset, but doesn't move.
I compiled and used the last Cesium 3d-tiles branch code.

Any idea?

Thanks in advance.

hi there,

Could we have more information about your tileset? That code is correct, and works when I test it with one of our test datasets. There could be something wrong with your tileset, or your case could be exposing a bug on our end.

Thanks,

  • Rachel

What information would you need?

This is the scene json:
http://gofile.me/23N3A/0aOEaTzAj

In the code, when enter "tileset.readyPromise.then(function(tileset) {", "tileset.modelMatrix = undefined". Is this correct?

The console log shows:
c {0: 1, 1: 0, 2: 0, 3: 0, 4: 0, 5: 1, 6: 0, 7: 0, 8: 0, 9: 0, 10: 1, 11: 0, 12: 421.91188665945083, 13: -126.11762787867337, 14: 236.8220932134427, 15: 1}

Could you give me a hint as to which part of the code to watch for?

Thanks.

Javier.

I've added this code to debug the read/write access a modelMatrix:

// save in another property
tileset._modelMatrix = tileset.modelMatrix;
// overwrite with accessor
Object.defineProperty(tileset, 'modelMatrix', {
    get: function () {
        return tileset._modelMatrix;
    },

    set: function (value) {
        tileset._modelMatrix = value;
    }
});

Now the displacement takes place!

I assumed the problem was that there was no defined "modelMatrix".
Added "tileset.modelMatrix = Cesium.Matrix4.IDENTITY;" after "var tileset = widget.scene.primitives.add(new Cesium.Cesium3DTileset({ (...)".

Now it works!

Sorry for the inconvenience.

Javier.