Which part of .b3dm contains the position property?

Yeah the data uri represents the buffer data, which includes positions, normals, and any other vertex attributes. This is getting into pretty technical territory and there are probably too many steps to explain it in perfect detail here, but you should become more familiarized with the glTF format and the concept of vertex attributes. Basically for each vertex you need to store a batchId that says this vertex belongs to this feature. I’m not sure what tools you’re using to edit these tiles, but the batchId buffer is typically a Uint16Array. You can append this to the main buffer, or make a new buffer for it.

In addition to the glTF changes you will need to edit the batchLength property of the b3dm header, which says how many features there are (I’m guessing your model above would be 4). Finally you need to create a batch table JSON and insert that into the tile as described in the b3dm spec: https://github.com/AnalyticalGraphicsInc/3d-tiles/tree/master/TileFormats/Batched3DModel.

Hello Sean,
First of all, thanks very much for your advice.

I have created my first .b3dm with batchTable, and load it into 3d-tiles-transform branch. Then, I manage to use simple styling code to change the apperance according to a batchTable field (shown in the following picture).

Since I have gone through all the procedures of creating .b3dm (or 3d-tiles) from scratch, I have questions about the procedure itself:

  1. My 3d tiles are based on the COLLADA models created from 3d softwares (such as Sketchup). So I need to convert the models to gltf, glb, and then to .b3dm. Is there any method to create .b3dm directly? Or can I convert 3d models in 3d softwares to .b3dm directly?

  2. For each tile, I need a COLLADA model. So for the whole five tiles (one parent tile and four children), I need four different .dae file and convert each file seperately to .b3dm. Is there a method to convert a whole .dae file to five seperate .b3dm according to my tiling scheme?

  3. I write the tileset.json almost manually. The boundingVolume is divided by myself. Is there any tool or algorithm that can divide the models into tiles according to their spatial distribution?

  4. I really appreciate the NewYork city example in demos. I wonder for such a large dataset, how do you generate the .b3dm files, and divide tiles? Are the .b3dm generated from ordinary 3d models like COLLADA, or from something like GityGML? And by which criteria do you define the tiling scheme?

  5. I will continue to learn other tile formats in 3d-tiles. And I am likely to met other problems. Should I ask question in this thread or start a new thread?

Thanks again for your great work.

Chris

在 2016年8月31日星期三 UTC+8上午8:28:15,Sean Lilley写道:

I’m glad you got the batch table up and running quickly, I like the screenshot.

  1. As of now, the main way is just COLLADA to glTF to b3dm. We hope to see more 3d software exporting glTF directly, and possibly b3dm sometime in the future.

  2. Tools like that don’t exist yet, at the moment you will just need your own toolchain.

  3. Also no tools for that right now that I know of. This is an interesting problem to solve, and we are working on it now.

  4. In the New York demo the data comes from CityGML / OpenStreetMap. The individual buildings are in COLLADA and we have a custom pipeline for batching building models together and splitting into tiles. Usually the tiling scheme is based around a quadtree that takes geometric error into account.

  5. Maybe a different thread per tile format is a good idea? It doesn’t matter too much to me.

Thanks again, Sean

Chris

在 2016年9月2日星期五 UTC+8上午10:58:57,Sean Lilley写道:

Hello Chris,
I really appreciate your wonderful post, which helps me a lot. I have managed to generate the .b3dm file without batch table, but i am stuck when adding batchId to the glTF. I have no idea where to add batchId or what should i modify in glTF. Can you offer me a example glTF with batchId? Or can you tell me where did you find the example glTF with batchID, because i didn’t find any of them in Cesium data folder. There are only many .b3dm files in it.
You said “need to fill the buffer in glTF with batchID”, which confuses me a lot. The buffer containing position and normal data is binary and what should i do to add batchID into the buffer?

Best

Zhang

在 2016年8月30日星期二 UTC+8下午9:01:04,Chris Wang写道:

Hi Sean, I’m now trying to figure out batch table. But I don’t know how to add batchID to the glTF.
I find there are places in glTF relating to batchID:

  1. “techniques”:{“technique0”:{“attributes”:{“a_batchId”:“batchId”,“a_normal”:“normal”,“a_position”:“position”},“parameters”:{“ambient”:{“type”:35666},“batchId”:{“semantic”:“BATCHID”,“type”:5126}…
  1. “primitives”:[{“attributes”:{“BATCHID”:“accessor_27”}…}…]
  1. “accessor_27”:{“bufferView”:“bufferView_30”,“byteOffset”:33600,“byteStride”:2,“componentType”:5123,“count”:2400,“max”:[99],“min”:[0],“type”:“SCALAR”}

Then I find the accessor_27 contains the batchID buffer. So I guess I need to fill the buffer in glTF with batchID.

So I open an ordinary glTF file and find the buffer containing position and normal data (should the batchID be put in the same buffer?).

The buffer is organized like this:

“buffer_0”: {

“type”: “arraybuffer”,

“byteLength”: 1512,

“uri”: “data:application/octet-stream;base64,//8AQzpej0…UABcA”

}

Now, I have a few questions:

  1. Is the uri containing the position and normal data?
  1. Should the batchID also be in the above uri?
  1. What does octet-stream mean? How can I read the encoded data? It seems this data has been encoded twice (base64 and something related to octet-stream).
  1. After I manage to add batchID into the buffer, and modify the abovementioned parts relating to batchID (including batchTable). Can I get the right .b3dm with batchTable and display it in Cesium?.

Best

Chris

在 2016年8月30日星期二 UTC+8上午12:05:46,Sean Lilley写道:

  1. Yes you can do that
  2. You will need to update the boundingVolume box as well. The first three values are the center position - you may want to change the 2nd value to half the height of the model.
  1. The glTF model will need a batchId vertex attribute. You may be able to examine our example tilesets and work backwards to see what’s going on in terms of the glTF, but as of now we don’t have any tutorials for doing this.

Thanks for your interest in 3D Tiles!

在 2016年8月30日星期二 UTC+8下午9:01:04,Chris Wang写道:

Hi Sean, I’m now trying to figure out batch table. But I don’t know how to add batchID to the glTF.
I find there are places in glTF relating to batchID:

  1. “techniques”:{“technique0”:{“attributes”:{“a_batchId”:“batchId”,“a_normal”:“normal”,“a_position”:“position”},“parameters”:{“ambient”:{“type”:35666},“batchId”:{“semantic”:“BATCHID”,“type”:5126}…
  1. “primitives”:[{“attributes”:{“BATCHID”:“accessor_27”}…}…]
  1. “accessor_27”:{“bufferView”:“bufferView_30”,“byteOffset”:33600,“byteStride”:2,“componentType”:5123,“count”:2400,“max”:[99],“min”:[0],“type”:“SCALAR”}

Then I find the accessor_27 contains the batchID buffer. So I guess I need to fill the buffer in glTF with batchID.

So I open an ordinary glTF file and find the buffer containing position and normal data (should the batchID be put in the same buffer?).

The buffer is organized like this:

“buffer_0”: {

“type”: “arraybuffer”,

“byteLength”: 1512,

“uri”: “data:application/octet-stream;base64,//8AQzpej0…UABcA”

}

Now, I have a few questions:

  1. Is the uri containing the position and normal data?
  1. Should the batchID also be in the above uri?
  1. What does octet-stream mean? How can I read the encoded data? It seems this data has been encoded twice (base64 and something related to octet-stream).
  1. After I manage to add batchID into the buffer, and modify the abovementioned parts relating to batchID (including batchTable). Can I get the right .b3dm with batchTable and display it in Cesium?.

Best

Chris

在 2016年8月30日星期二 UTC+8上午12:05:46,Sean Lilley写道:

  1. Yes you can do that
  2. You will need to update the boundingVolume box as well. The first three values are the center position - you may want to change the 2nd value to half the height of the model.
  1. The glTF model will need a batchId vertex attribute. You may be able to examine our example tilesets and work backwards to see what’s going on in terms of the glTF, but as of now we don’t have any tutorials for doing this.

Thanks for your interest in 3D Tiles!

在 2016年8月30日星期二 UTC+8下午9:01:04,Chris Wang写道:

You can extract the gltf from the b3dm using 3d-tiles-tools and gltf-pipeline. I attached a glTF extracted from here so you can reference it easily.

I would also recommend checking out 3d-tiles-samples-generator for a basic idea of how b3dm tiles are created. The code that you should focus on is here: https://github.com/AnalyticalGraphicsInc/3d-tiles-tools/blob/master/samples-generator/lib/createGltf.js#L371-L452. Basically the batch id is just another vertex attribute like positions and normals. It is typically an array of unsigned shorts whose length is equal to the number of vertices.

batchedWithBatchTable.gltf (19.3 KB)

Hi Sean,
Thanks very much for your reply!

Yesterday, I had managed to create the b3dm with batch table. It is so cool. Although I encountered many problems in the past few days, I learned a lot from them.

Currently, i find out that the model doesn’t match the correct position like the below shown:

The model should be placed in the red bounding volume but it deviates away from its position. I used a transform property in tileset.json file and the transform matrix was generated by
Cesium.Transforms.eastNorthUpToFixedFrame(Cesium.Cartesian3.fromDegrees(lon,lat,0))

``

where, the (lon, lat, 0) is the center of bounding volume. I thought it was a translation problem, so i added Cesium_RTC extension when creating b3dm and the CESIUM_RTC center was ECEF coordinate. However, the model didn’t display in cesium and only red bounding volume was visible.

Am i wrong in mentionedabove steps? Or can you tell me how i can fix this translation problem?

在 2017年9月26日星期二 UTC+8上午7:15:51,Sean Lilley写道:

It looks like the model is off center, almost as if the origin of the model is at one of its corners. The reason I suspect this is one corner is directly at the center of the tile. I think you’ll need to tweak the geometry or add a node to the glTF to translate it a bit.

If you decide to use RTC, make sure you are not also using a transform. That will cause the model to be offset by both the transform and the RTC causing it to not show up where expected. Just be aware that since RTC does not include a rotation the model geometry will need to be rotated.

Hi Sean

I’m now trying to convert gltf 2.0 models to 3d-tiles.

I wonder if 3d-tiles in Cesium support gltf 2.0?

if so, how should I add batchid to each meshes?

In fact, I can’t find shaders property in gltf 2.0, so there is no way to insert attribute float a_batchId into gltf file

Any help appreciated

Chris

Cesium supports glTF 2.0 models, so using glTF 2.0 models in your tilesets should be fine.

For batch ids, continue to use the _BATCHID semantic on the vertex attribute. However you don’t need to do anything for shaders and techniques since these were removed from glTF 2.0. Cesium will generate the correct shaders automatically.

Great, THANKS Sean

Hi Sean

I write a .gltf 2.0 file with _BATCHID in the vertex attribute.

But I can’t load it into Cesium. It shows some errors about a_BATCHID redefinition.

The error is shown below:

The gltf file is uploaded.

Any help is appreciated.

Thanks

Chris.

在 2017年10月18日星期三 UTC+8上午7:51:50,Sean Lilley写道:

0_100_bid.gltf (2.01 MB)

Thanks for the bug report. I submitted a fix: https://github.com/AnalyticalGraphicsInc/cesium/pull/6036.

By the way, this bug happened to be exposed by loading the gltf by itself, but I think it would have loaded fine as part of the b3dm. Nevertheless, good catch!

Thanks Sean

I will try it with .b3dm




ecnuzlwang

邮箱:ecnuzlwang@gmail.com

签名由 网易邮箱大师 定制

Hi Sean

Just let you know, the .b3dm works perfectly.

Hi Chris,

Sean’s fix #6036 was just merged, and will be in Cesium 1.41 on January 2.

Patrick

Thanks Patrick