How to place a building by a 3D Tiles tileset.json onto specific location - transform property

775 views
Skip to first unread message

mholt...@gmail.com

unread,
Nov 8, 2018, 9:30:04 AM11/8/18
to cesium-dev
I have a model converted into a b3dm-File, let's say its just one building calles scene.b3dm.
I define in the tileset.json the root element with a boundingVolumen and a specific region of where the building should appear (in radians and height).

If i use the coordinates of an Cesium example, this works, but when i change them to another region, there appears no builind on the specified location.The initial camera position changes to the specified region of the boundingVolume.
I guess, it has something to do with the transform-Element. There are 15 numbers, i can not understand how to generate for my own location.

Is there a function by Cesium (or something else) to generate these transform-Numbers?
If I use this (https://github.com/AnalyticalGraphicsInc/3d-tiles/tree/master/specification#implementation-example) it throws an error in Line 2, where the function tries to access root of Tileset. I can see in the console, that root is filled with another object, but says its undefined, if i try to access it via tileset.root or tileset._root.

Omar Shehata

unread,
Nov 13, 2018, 2:36:05 PM11/13/18
to cesium-dev
One important concept in 3D Tiles is that the bounding volume does not set the location of the tileset, it describes it.

For example, you might export your building geometry from Blender with the location of the vertices already in coordinates relative to the center of the earth. So the 0,0,0 point of this model is at the center of the earth, but the building itself is somewhere on the surface. In order for Cesium to know that, it relies on the bounding volume being set to the correct area. In this case, no transform is needed, the geometry is already in the correct location.

Another situation is if your geometry is all in relative coordinates (so it's centered at 0,0,0) and you want to place it at the surface. You'll need to define the root transform (those 16 numbers, which are a transformation matrix that controls how to translate, scale and orient the tileset). You can write it by hand or generate it with CesiumJS. The code snippet below defines a cartographic position on the surface of the earth, and gets a matrix representing that position in the east-north-up frame of reference:

var lon = 175.3050519951;
var lat = -41.1948830262;
var height = 0;
var location = Cesium.Cartesian3.fromDegrees(lon, lat, height);
console.log(Cesium.Transforms.eastNorthUpToFixedFrame(location));

 The easiest way to run that would be pasting that in Sandcastle (https://cesiumjs.org/Cesium/Build/Apps/Sandcastle/). 

Does that make sense?
Reply all
Reply to author
Forward
0 new messages