Model is always upside down.

Hi,

I have seen this discussed a number of places and tried everything but I am still not having success. This is what I have done

  1. Down loaded Cesium-1.31 from http://cesiumjs.org/downloads.html and it works great.
  2. Downloaded a model https://3dwarehouse.sketchup.com/model/2ac1d07d86aa7fdc45e81db730974dc/Sydney-Opera-House
  3. Opened in Sketchup and exported as COLLADA file, which is attached in Sydney_Opera_House_DAE.zip
  4. I downloaded collada2gltf.exe from https://github.com/AnalyticalGraphicsInc/collada2gltf-web-service/blob/master/collada2gltf/win32/collada2gltf.exe
  5. I ran collada2gltf.exe -f Sydney_Opera_House.dae which created my model which is attached as Model.zip.
  6. I created a Model directory where I have CesiumJS installed and placed my model there.
  7. In Sandcastle I tried the following
    var viewer = new Cesium.Viewer(‘cesiumContainer’);
    var origin = Cesium.Cartesian3.fromDegrees(151.21499, -33.85667, 0);
    var modelMatrix = Cesium.Transforms.eastNorthUpToFixedFrame(origin);
    var entity = viewer.entities.add({
    position : origin,
    model : {
    modelMatrix: modelMatrix,
    uri : ‘/Cesium-1.31/Model/Sydney_Opera_House.gltf’,
    }
    });

var heading = Cesium.Math.toRadians(90);
var pitch = Cesium.Math.toRadians(-30);
viewer.zoomTo(entity, new Cesium.HeadingPitchRange(heading, pitch));
But the model is always rendered upside down as shown in UpsidedownModel.PNG.

I have tried not setting the modelMatrix, and have tried all the Cesium.Transforms options but nothing corrects the models orientation.

Any points on what I am doing wrong?

Regards

Marco

Model.zip (294 KB)

Sydney_Opera_House_DAE.zip (374 KB)

Hi Marco,

The way we orient models is by using an orientation, so the code would be something like this (did not test it).

var viewer = new Cesium.Viewer(‘cesiumContainer’);
var origin = Cesium.Cartesian3.fromDegrees(151.21499, -33.85667, 0);
// var modelMatrix = Cesium.Transforms.eastNorthUpToFixedFrame(origin);
var hpr = new Cesium.HeadingPitchRoll(0.0, 0.0, 0.0);
var orientation = Cesium.Transforms.headingPitchRollQuaternion(origin, hpr); // todo will be modified in 1.33.
var entity = viewer.entities.add({
position : origin,
orientation: orientation,
model : {
uri : ‘/Cesium-1.31/Model/Sydney_Opera_House.gltf’,
}
});

``

In case the model is still upside-down you could try changing the HeadingPitchRoll() values.

Regards, Willem

Hi Willem,

thank you very much for the information. I got it going with the following adjustment to the HeadingPitchRoll as you suggested

var hpr = new Cesium.HeadingPitchRoll(180.0 * Cesium.Math.RADIANS_PER_DEGREE, 180.0 * Cesium.Math.RADIANS_PER_DEGREE, 0.0);

Regards

Marco