kml->gltf->glb->b3dm

Hi,

I've converted gltf files obtained from a kml file with 3DCityDB Importer Exporter to b3dm files.

The steps followed are:

Gltf 2 glb: https://github.com/Qantas94Heavy/binary-gltf-utils
Glb 2 b3dm: https://github.com/AnalyticalGraphicsInc/3d-tiles-tools/tree/master/tools

The b3dm files I've got are not the same as those at directory \Specs\Data\Cesium3DTiles\Batched\BatchedNoBatchIds from the 3D Tiles branch.

So I get strange results when trying to visualize them.

Any ideas???

THANK U ALL!!!

Héctor

Can you post the b3dm tiles that you generated?

Also what sorts of results are you seeing?

Hi Sean,

I attach the files I am working with.

From the gltf I got the glb and the b3dm.

Depending on the tileset I use I get different results.

With the TilesetWithDiscreteLOD file I can view the image but not in the place I want and with the BatchedNoBatchIds I see nothing ang it takes me to other place…

:frowning:

Any idea???

THANKS!!!

Building_6672307NH3467D.b3dm (4.37 KB)

Building_6672307NH3467D.glb (4.32 KB)

Building_6672307NH3467D.gltf (8.32 KB)

It looks like the glTF is stored in a local reference frame rather than a global one. If you want to position the model at the right location you’ll need to either convert the model to glTF differently (I’m not familiar with the tools you’re using) or provide a transform to the tileset. The reason it partially works for TilesetWithDiscreteLOD is because the tileset has a transform property already, but its based on a longitude/latitude that you don’t expect.

So there are two ways to change the transform - edit the transform in the tileset (like in TilesetWithDiscreteLOD), or set the tileset.modelMatrix property directly in Cesium (like for BatchedNoBatchIds). One way to calculate the transform is with

Cesium.Transforms.headingPitchRollToFixedFrame(Cesium.Cartesian3.fromRadians(longitude, latitude, height), new Cesium.HeadingPitchRoll());

``

Hope this works!

Hi Sean,

This is the code I use:

function startup(Cesium) {

‘use strict’;

//Sandcastle_Begin

// Check for the various File API support.

if (window.File && window.FileReader && window.FileList && window.Blob) {

alert("CESIUM VERSION: "+Cesium.VERSION+’\nGreat success! All the File APIs are supported.’);

} else {

alert("CESIUM VERSION: "+Cesium.VERSION+’\nThe File APIs are not fully supported in this browser.’);

}

//CLAVE DEL BING

Cesium.BingMapsApi.defaultKey = ‘ApOW9LMkerqWIVSnFauilSeaZyp8df66byy1USCTjgTdMvhb4y1iAhEsUHQfCgzq’

//VISOR CESIUM

var viewer = new Cesium.Viewer(‘cesiumContainer’);

var tileset = viewer.scene.primitives.add(new Cesium.Cesium3DTileset({

url : ‘./region/tileset.json’

}));

tileset.readyPromise.then(function(tileset) {

viewer.camera.viewBoundingSphere(tileset.boundingSphere, new Cesium.HeadingPitchRange(0, -0.5, 0));

viewer.camera.lookAtTransform(Cesium.Matrix4.IDENTITY);

});

///////////////////////////////////////////////////////////////////////////////

//Sandcastle_End

Sandcastle.finishedLoading();

}

if (typeof Cesium !== “undefined”) {

startup(Cesium);

} else if (typeof require === “function”) {

require([“Cesium”], startup);

}

Another question:

How could I change the tileset I’m using?

{

“asset”: {

“version”: “0.0”

},

“geometricError”: 70,

“root”: {

“refine”: “add”,

“boundingVolume”: {

“region”: [

-2.7048683,

42.8288976,

-2.6454735,

42.87219,

0,

20

]

},

“geometricError”: 0,

“content”: {

“url”: “…/data/Tiles/16/22/4024/Building_1407_196_27.b3dm”

}

}

}

THANKS AGAIN!!!

Right after creating the tileset just add this line:

tileset.modelMatrix = Cesium.Transforms.headingPitchRollToFixedFrame(Cesium.Cartesian3.fromRadians(longitude, latitude, 0), new Cesium.HeadingPitchRoll());

``

Your values (-2.7048683,42.8288976,0) should be converted to radians both in the code and in the tileset.json.

Thanks Sean!!!

I’ve done what you told me and I get the viewer at the location I want but the b3dm file is not showed…

I attach the code and the tileset:

var viewer = new Cesium.Viewer(‘cesiumContainer’);

var tileset = viewer.scene.primitives.add(new Cesium.Cesium3DTileset({

url : ‘./region/tileset.json’

}));

var longitude_degrees=-2.7048683;

var longitude_radians=longitude_degrees*Math.PI/180;

var latitude_degrees=42.8288976;

var latitude_radians=latitude_degrees*Math.PI/180;

Cesium.Transforms.headingPitchRollToFixedFrame(Cesium.Cartesian3.fromRadians(longitude_radians,latitude_radians,100), new Cesium.HeadingPitchRoll());

tileset.readyPromise.then(function(tileset) {

viewer.camera.viewBoundingSphere(tileset.boundingSphere, new Cesium.HeadingPitchRange(0, -0.5, 0));

viewer.camera.lookAtTransform(Cesium.Matrix4.IDENTITY);

});

{

“asset”: {

“version”: “0.0”

},

“geometricError”: 70,

“root”: {

“refine”: “add”,

“boundingVolume”: {

“region”: [

-0.047208857667821735,

0.7475052781194974,

-0.046172222849258204,

0.7482608730405877,

0,

39

]

},

“geometricError”: 0,

“content”: {

“url”: “…/data/Tiles/16/22/4024/Building_1407_196_27.b3dm”

}

}

}

THANKS AGAIN!!!

The line
Cesium.Transforms.headingPitchRollToFixedFrame(Cesium.Cartesian3.fromRadians(longitude_radians,latitude_radians,100), new Cesium.HeadingPitchRoll());

``

should be

tileset.modelMatrix = Cesium.Transforms.headingPitchRollToFixedFrame(Cesium.Cartesian3.fromRadians(longitude_radians,latitude_radians,100), new Cesium.HeadingPitchRoll());

``

After that it becomes visible in the lower-left corner:

Hi Sean,

After changing the line, I get the same, no red lines, no building…

Can you post your complete code and tileset?

THANKS

In code.txt change the url to whatever makes sense for your case. I also changed the geometric error in tileset.json so it was easier to see. You can change that back too. The red lines are set with debugShowBoundingVolume : true.

tileset.json (392 Bytes)

Building_6672307NH3467D.b3dm (4.37 KB)

code.txt (860 Bytes)

THANKS SEAN!!!

I finally see the building and the red lines!!!

:wink:

But this is just the beginning because I need to see 603 buildings more and then I would like to apply styling as described at https://github.com/AnalyticalGraphicsInc/3d-tiles/tree/master/Styling

I think that I need to batch the 604 b3dm files but I don’t know exactly how to do it, am I right?

Do u know a site where this process of batching b3dm files is explained or a tool to do it?

THANKS AGAIN!!!

We are working on our own tools for batching models and generating tilesets. If you haven’t already seen it, check out this thread and send us an email with your data: https://groups.google.com/forum/#!topic/cesium-dev/xLkYIuku9hA.

Hello Hector!

Greetings!

Could you send me or post the final code and the files you used in order to generate the 3d building? It would be of great help if you do so.

Regards,

Angarika Das

Hello Hector!

I am trying to create a 3d city using the 3d tiles just like the new york 3d city example given in cesium. Could you please tell me what to do in order to create the 3d tiles for the 3d city in cesium.

looking forward to your reply!

here is the demo link of what i am trying to create- http://cesiumjs.org/NewYork

with regards,

Angarika Das