How to move b3dm model to right position??

1915 views
Skip to first unread message

dhd...@naver.com

unread,
Mar 20, 2018, 2:49:19 AM3/20/18
to cesium-dev
1. A concise explanation of the problem you're experiencing.

----------My process workflow----------

1. Photogrammetry (Photoscan,GCP Proccessed)

2. Export obj (Photoscan,Local Coordinate)

3. Convert to b3dm (obj23dtiles command line tools, --tileset option)

4. move b3dm, tileset.json files to one directory(in my case 'http://localhost:8080/Apps/SampleData/models/test2/'

5. Test in Sandcastle, I could see my model, but location was wrong.
My model's right location is Korea, but it showing in USA.


I wanna move my model to right position(Korea)

2. A minimal code example. If you've found a bug, this helps us reproduce and repair it.

-------------javascript code------------

var viewer = new Cesium.Viewer('cesiumContainer');

var tileset = new Cesium.Cesium3DTileset({
url: 'http://localhost:8080/Apps/SampleData/models/test2/'
});

viewer.scene.primitives.add(tileset);
viewer.zoomTo(tileset);

---------------tileset.json-------------

{
"asset": {
"version": "0.0",
"tilesetVersion": "1.0.0-obj23dtiles",
"gltfUpAxis": "Z"
},
"geometricError": 200,
"root": {
"transform": [
0.9686356343768793,
0.24848542777253738,
0,
0,
-0.15986461316605738,
0.6231776341036305,
0.7655670720519978,
0,
0.1902322613874096,
-0.7415555464951368,
0.6433560897277117,
0,
1215022.9309072953,
-4736352.219974792,
4081639.203163236,
1
],
"boundingVolume": {
"region": [
-1.3197046886133135,
0.6988739942707489,
-1.3197020262666388,
0.6988744679437489,
0,
10.101737976074219
]
},
"geometricError": 0,
"refine": "ADD",
"content": {
"url": "objlocal.b3dm"
}
}
}

3. Context. Why do you need to do this? We might know a better way to accomplish your goal.

I wanna move my model to korea from wrong position.

Right position of My model is logitude, latitude (129.191971, 35.173105) by degree
logitude, latitude(2.254825261091031, 0.6138864903996801) by radian

How can i move my model to this coordinate ??

What i have to modify ??


4. The Cesium version you're using, your operating system and browser.

cesium version : Lastest Version(Maybe 1.43)
System : Win 10 64bit, 16gb ram, gtx970, i7-4790
Browser : Chrome, Firefox

Message has been deleted

dhd...@naver.com

unread,
Mar 20, 2018, 3:01:01 AM3/20/18
to cesium-dev

Sean Lilley

unread,
Mar 20, 2018, 11:10:12 PM3/20/18
to cesium-dev
Normally the code would look something like:

var viewer = new Cesium.Viewer('cesiumContainer');

var tileset = new Cesium.Cesium3DTileset({
    url: '../../SampleData/test/objlocal'
});
viewer.scene.primitives.add(tileset);

tileset.readyPromise.then(function(){
    var longitude = 2.254825261091031;
    var latitude = 0.6138864903996801;
    var height = 0.0;
    var cartesian = Cesium.Cartesian3.fromDegrees(longitude, latitude, height);
    var transform = Cesium.Transforms.headingPitchRollToFixedFrame(cartesian, new Cesium.HeadingPitchRoll());
    tileset._root.transform = Cesium.Matrix4.IDENTITY;
    tileset.modelMatrix = transform;
    viewer.zoomTo(tileset, new Cesium.HeadingPitchRange(0.0, -0.5, tileset.boundingSphere.radius / 4.0));
});

But right now we have a bug where a tileset using the region bounding volume doesn't get transformed properly: https://github.com/AnalyticalGraphicsInc/cesium/issues/5984.

Looking at the objTo3d-tiles project it should be possible to specify a custom longitude and latitude.


The customTilesetOptions.json can have options bellow, and these are fake values, please only add properties you need, other value will be auto calculate through .obj file.

dhd...@naver.com

unread,
Mar 21, 2018, 3:46:42 AM3/21/18
to cesium-dev
Thank you Sean Lilley. very quickly reply!!

It's work with custom longitude and latitude.

Now i can move my model to custom position.

My code is under here.

--------------------javascript code------------------


var viewer = new Cesium.Viewer('cesiumContainer');

var tileset = new Cesium.Cesium3DTileset({

url: 'http://localhost:8080/Apps/SampleData/models/test5/'
});

viewer.scene.primitives.add(tileset);
tileset.readyPromise.then(function(tileset) {
viewer.camera.viewBoundingSphere(tileset.boundingSphere, new Cesium.HeadingPitchRange(0, -0.5, 0));
viewer.camera.lookAtTransform(Cesium.Matrix4.IDENTITY);
});

---------------------tileset.json---------------


{
"asset": {
"version": "0.0",
"tilesetVersion": "1.0.0-obj23dtiles",
"gltfUpAxis": "Z"
},
"geometricError": 200,
"root": {
"transform": [

-0.7749404279524483,
-0.632034281605734,
0,
0,
0.3641343205358554,
-0.4464669313052492,
0.8173576180955096,
0,
-0.5165980349679692,
0.633403462357128,
0.5761306485001776,
0,
-3298600.4110291977,
4044430.6401747838,
3654103.3849516404,
1
],
"boundingVolume": {
"region": [
2.2547854736485844,
0.6138257242719676,
2.255169112331271,
0.6141415062719675,
0,
50


]
},
"geometricError": 0,
"refine": "ADD",
"content": {

"url": "objlocalbig.b3dm"
}
}
}
----------------------------------------------------------

Next step, How to locate b3dm model to model's original position(example, coordinate contains in obj file, not custom position)

I mean obj file has original coordinate. it's not custom longitude, latitude
i wanna locate my b3dm model to really right position

Sorry, my english is not good.

Maybe it's hard to understand my question

Sean Lilley

unread,
Mar 21, 2018, 8:43:18 PM3/21/18
to cesium-dev
Are the obj positions in ECEF coordinates?

Could you upload the obj file?

dhd...@naver.com

unread,
Mar 21, 2018, 10:53:08 PM3/21/18
to cesium-dev
Hi Sean Lilley

Ok. I share 3 obj files.

All file is same model but just coordinate system is different each other.

Check Please!!

And obj position have to ECEF coordinates ??
Unable other coordinate system?(like, WGS84(EPSG:4326), WGS84/UTM zone(EPSG:32652)

https://drive.google.com/file/d/1VET1-YoHo4B6Efe0S9-kB_RoseIiBD-g/view?usp=sharing
https://drive.google.com/file/d/1dvHjed_hEH-p9Jz2nrOru80xtcXj-2Ga/view?usp=sharing
https://drive.google.com/file/d/18-R93yqxWumwMrzt6GkSzAuwTsevB58F/view?usp=sharing

Sean Lilley

unread,
Mar 22, 2018, 7:13:11 PM3/22/18
to cesium-dev
Thanks for sending them over.

Yeah, the model needs to either be in local coordinates + transform (like what you tried before) or ECEF coordinates to be loaded properly in Cesium, as we don't convert projections of models at runtime.

If you are able to calculate a more accurate transform that would be the best approach.

dhd...@naver.com

unread,
Mar 23, 2018, 3:31:10 AM3/23/18
to cesium-dev
Thanks you Sean Lilley!!
Then are there no problem in my obj models ??
Did you check it ??

Sean Lilley

unread,
Mar 26, 2018, 8:54:58 PM3/26/18
to cesium-dev
Sorry I wasn't more clear, but objutm and objwgs84 won't work because they are not in a Cartesian coordinate system which 3D Tiles requires. Using objlocal and tweaking the model matrix is the best approach.

吳承霖

unread,
May 3, 2018, 10:57:07 PM5/3/18
to cesium-dev
Hi Sean,

After reading the discussion above, I got this summary below:

1.
If i got a OBJ file whose vertices are like (1, -1, 0), (0, 0, 0), (-3, 2, 1)...etc, I can assume that it use local coordinates.
And, after converting this OBJ file into 3D tiles I found the orientation is wrong and size is too small, 
what I should do is applying a transform matrix for rotation and scaling, and setup the origin's position like settings in customTilesetOption.json of obj23dtiles

2.
According to ECEF's definition, for any object on the surface, it's X, Y, Z coordinate value should be greater than or equal to earth's radius.
And this is the way that Cesium tells the model's coordinate type.

Are these summaries correct?

Sean Lilley於 2018年3月27日星期二 UTC+8上午8時54分58秒寫道:

Sean Lilley

unread,
May 5, 2018, 8:06:34 PM5/5/18
to cesium-dev
1. Yeah try passing in a longitude and latitude to customTilesetOptions.json. For further adjustments to the rotation and scale you may need to edit the Tile Transform of the root tile.

2. Correct. For the most part 3D Tiles and Cesium operate in ECEF coordinates.

Gabby Getz

unread,
Jul 11, 2018, 9:37:01 AM7/11/18
to cesium-dev
Hey all, 

The issue at #5984 has just been closed and may resolve your issue. Look for the change in the Cesium 1.48 release on August 1st, or get it now in the master branch on GitHub https://github.com/AnalyticalGraphicsInc/cesium.

Thanks!
Gabby
Reply all
Reply to author
Forward
0 new messages