# Cesium 3d-tiles problem with tileset.modelMatrix

**URL:** <https://community.cesium.com/t/cesium-3d-tiles-problem-with-tileset-modelmatrix/5563>\
**Category:** CesiumJS\
**Created:** [May 26, 2017, 2:49pm UTC](https://community.cesium.com/t/cesium-3d-tiles-problem-with-tileset-modelmatrix/5563 "2017-05-26T14:49:17Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![hergest](https://avatars.discourse-cdn.com/v4/letter/h/db5fbb/32.png) [@hergest](https://community.cesium.com/u/hergest)\
**Post date:** [May 26, 2017, 2:49pm UTC](https://community.cesium.com/t/cesium-3d-tiles-problem-with-tileset-modelmatrix/5563/1 "2017-05-26T14:49:17Z")

</div>

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

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

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.

---

<div class="post-metadata">

**Author:** ![Rachel\_Hwang](https://avatars.discourse-cdn.com/v4/letter/r/d78d45/32.png) [@Rachel\_Hwang](https://community.cesium.com/u/Rachel_Hwang)\
**Post date:** [May 26, 2017, 6:38pm UTC](https://community.cesium.com/t/cesium-3d-tiles-problem-with-tileset-modelmatrix/5563/2 "2017-05-26T18:38:17Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![hergest](https://avatars.discourse-cdn.com/v4/letter/h/db5fbb/32.png) [@hergest](https://community.cesium.com/u/hergest)\
**Post date:** [May 28, 2017, 10:12am UTC](https://community.cesium.com/t/cesium-3d-tiles-problem-with-tileset-modelmatrix/5563/3 "2017-05-28T10:12:56Z")

</div>

What information would you need?

This is the scene json:  
[http://gofile.me/23N3A/0aOEaTzAj](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.

---

<div class="post-metadata">

**Author:** ![hergest](https://avatars.discourse-cdn.com/v4/letter/h/db5fbb/32.png) [@hergest](https://community.cesium.com/u/hergest)\
**Post date:** [May 29, 2017, 8:48am UTC](https://community.cesium.com/t/cesium-3d-tiles-problem-with-tileset-modelmatrix/5563/4 "2017-05-29T08:48:37Z")

</div>

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', {  
&nbsp;&nbsp;&nbsp;&nbsp;get: function () {  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;return tileset.\_modelMatrix;  
&nbsp;&nbsp;&nbsp;&nbsp;},

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

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.
