Convert obj from 3dMax to glTF

65 views
Skip to first unread message

zf455...@gmail.com

unread,
Apr 8, 2018, 8:11:50 AM4/8/18
to cesium-dev
Hi, I'm Fan. I have converted obj models exported from 3DMax to glTF by obj2gltf(https://github.com/AnalyticalGraphicsInc/obj2gltf).
But when display the glTF model in Cesium, it shows nothing, can you help me with this problem.
I upload the original obj model and the generated glTF model, mabe you can help me check if there are some format problems on the generated glTF model.





obj.zip
glTF.zip

Sean Lilley

unread,
Apr 9, 2018, 10:24:39 PM4/9/18
to cesium-dev
The glTF looks fine when I view it standalone (screenshot attached). I had to turn the globe off though because otherwise it isn't visible. Do you know what coordinate system the file is in?

var viewer = new Cesium.Viewer('cesiumContainer', {
    globe : false
});

function createModel(url) {
    var entity = viewer.entities.add({
        name : url,
        position : Cesium.Cartesian3.ZERO,
        orientation : Cesium.Quaternion.IDENTITY,
        model : {
            uri : url
        }
    });
    viewer.trackedEntity = entity;
}

createModel('../../SampleData/test/test.gltf');

obj.PNG

张帆

unread,
Apr 11, 2018, 8:42:43 AM4/11/18
to cesiu...@googlegroups.com
It is in WGS84 coordinate system , I know Cesium is in WGS84 the same, so what's the problem. 

--
You received this message because you are subscribed to a topic in the Google Groups "cesium-dev" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/cesium-dev/6amKKJunxtg/unsubscribe.
To unsubscribe from this group and all its topics, send an email to cesium-dev+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Sean Lilley

unread,
Apr 12, 2018, 6:48:54 PM4/12/18
to cesium-dev
I tried bypassing the entity API and constructing a model directly but it still looks like the model is under the surface. To test this I drew a sphere using the max coordinate in the glTF file (661590.1875, 244.36329650878906, -5450425.5), but the center of the sphere is clearly underground. I think this is potentially a problem with the data.

var viewer = new Cesium.Viewer('cesiumContainer', {
    //globe : false
});
var scene = viewer.scene;
var camera = viewer.camera;

var model = scene.primitives.add(Cesium.Model.fromGltf({
    url : '../../SampleData/test/test.gltf',
    modelMatrix : Cesium.Matrix4.IDENTITY,
    upAxis : Cesium.Axis.Z
}));

model.readyPromise.then(function(model) {
    // Zoom to model
    var controller = scene.screenSpaceCameraController;
    var r = 2.0 * Math.max(model.boundingSphere.radius, camera.frustum.near);
    controller.minimumZoomDistance = r * 0.5;

    var center = Cesium.Matrix4.multiplyByPoint(model.modelMatrix, model.boundingSphere.center, new Cesium.Cartesian3());
    var heading = Cesium.Math.toRadians(230.0);
    var pitch = Cesium.Math.toRadians(-20.0);
    camera.lookAt(center, new Cesium.HeadingPitchRange(heading, pitch, r * 2.0));
}).otherwise(function(error){
    window.alert(error);
});


var position = new Cesium.Cartesian3(661590.1875, 244.36329650878906, -5450425.5);

var blueEllipsoid = viewer.entities.add({
    name : 'Blue ellipsoid',
    position: position,
    ellipsoid : {
        radii : new Cesium.Cartesian3(2000000.0, 2000000.0, 2000000.0),
        material : Cesium.Color.BLUE
    }
});

To unsubscribe from this group and all its topics, send an email to cesium-dev+...@googlegroups.com.
underneath.PNG
Reply all
Reply to author
Forward
0 new messages