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:
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?
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?
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?
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?
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?
I’m glad you got the batch table up and running quickly, I like the screenshot.
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.
Tools like that don’t exist yet, at the moment you will just need your own toolchain.
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.
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.
Maybe a different thread per tile format is a good idea? It doesn’t matter too much to me.
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:
Is the uri containing the position and normal data?
Should the batchID also be in the above uri?
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).
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写道:
Yes you can do that
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.
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:
Is the uri containing the position and normal data?
Should the batchID also be in the above uri?
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).
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写道:
Yes you can do that
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.
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.
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?
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.
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.
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!