kml->gltf->glb->b3dm

2,797 views
Skip to first unread message

holm...@gmail.com

unread,
Jun 2, 2017, 9:01:40 AM6/2/17
to cesium-dev
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

Sean Lilley

unread,
Jun 2, 2017, 7:19:37 PM6/2/17
to cesium-dev
Can you post the b3dm tiles that you generated?

Also what sorts of results are you seeing?

Héctor Olmedo

unread,
Jun 5, 2017, 8:54:54 AM6/5/17
to cesiu...@googlegroups.com
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...

:(

Any idea???

THANKS!!!

--
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/3tCx3CkL-3U/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.

Building_6672307NH3467D.b3dm
Building_6672307NH3467D.glb
Building_6672307NH3467D.gltf

Sean Lilley

unread,
Jun 5, 2017, 8:31:23 PM6/5/17
to cesium-dev
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!

To unsubscribe from this group and all its topics, send an email to cesium-dev+...@googlegroups.com.

Héctor Olmedo

unread,
Jun 14, 2017, 3:42:08 AM6/14/17
to cesiu...@googlegroups.com
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);
}

How should I apply the code to change the transform:

Cesium.Transforms.headingPitchRollToFixedFrame(Cesium.Cartesian3.fromRadians(-2.7048683,42.8288976,0), new Cesium.HeadingPitchRoll());

THANKS!!!

Héctor 


To unsubscribe from this group and all its topics, send an email to cesium-dev+unsubscribe@googlegroups.com.

Héctor Olmedo

unread,
Jun 14, 2017, 3:49:21 AM6/14/17
to cesiu...@googlegroups.com
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!!!

Héctor 

Sean Lilley

unread,
Jun 17, 2017, 1:15:14 PM6/17/17
to cesium-dev
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.

Héctor Olmedo

unread,
Jun 19, 2017, 6:30:09 AM6/19/17
to cesiu...@googlegroups.com
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!!!

Héctor


To unsubscribe from this group and all its topics, send an email to cesium-dev+unsubscribe@googlegroups.com.

Sean Lilley

unread,
Jun 19, 2017, 7:20:11 PM6/19/17
to cesium-dev
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:



















Héctor Olmedo

unread,
Jun 20, 2017, 4:50:07 AM6/20/17
to cesiu...@googlegroups.com
Hi Sean,

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

Can you post your complete code and tileset?

THANKS 
To unsubscribe from this group and all its topics, send an email to cesium-dev+unsubscribe@googlegroups.com.

Sean Lilley

unread,
Jun 20, 2017, 9:10:06 PM6/20/17
to cesium-dev
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
Building_6672307NH3467D.b3dm
code.txt

Héctor Olmedo

unread,
Jun 21, 2017, 5:31:07 AM6/21/17
to cesiu...@googlegroups.com
THANKS SEAN!!!

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

;-)

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!!!
To unsubscribe from this group and all its topics, send an email to cesium-dev+unsubscribe@googlegroups.com.

Sean Lilley

unread,
Jun 22, 2017, 7:53:54 PM6/22/17
to cesium-dev
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.

Angarika Das

unread,
Jun 6, 2018, 3:35:40 AM6/6/18
to cesium-dev
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

Angarika Das

unread,
Jun 6, 2018, 7:04:36 AM6/6/18
to cesium-dev
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

On Friday, June 2, 2017 at 6:31:40 PM UTC+5:30, Hector Olmedo wrote:
Reply all
Reply to author
Forward
Message has been deleted
0 new messages