ebeaufay / threedtiles

3DTiles viewer for three.js
MIT License
270 stars 32 forks source link

Adding local data #6

Closed Iron-john closed 2 years ago

Iron-john commented 2 years ago

Hi there! Thanks for sharing the excellent project to us! I had some problems when I tried to add some local 3DTiles rather than the data you provided. Firstly, I open the service by "webpack-dev-server" and create a "public" folder in "threedtiles-master". Secondly, I put the 3Dtiles data to "public" floder which is converted from FBX model ,including "tileset.json" and "b3dm". But finally, I found that the local 3Dtiles data can not be rendered even though the path is correct and I wonder why o(╥﹏╥)o. The local data can be rendered by Cesium. Whether I have to use the 3Dtiles converted by your tools then I the data can be rendered by "threedtiles" correctly?

ebeaufay commented 2 years ago

Hi John, There are a few things that could be going on. Can you share the 3DTiles dataset? (emericbeaufays@gmail.com) I'd like to test it myself and I can adapt the library if there is a feature of OGC 3DTiles that is not supported.

My tools will indeed make OGC3DTiles that both cesium and this library understand but I suggest we first try to make these 3DTiles work. This library "should" be able to render any 3DTiles dataset.

ebeaufay commented 2 years ago

Hi John,

It turns out the datasets are georeferenced through a transformation matrix at the root of the tileset.json.

In the fbx tileset.json, you can remove the following line to move the model to 0,0,0 :

"transform": [-0.895779, -0.444499, 0.000000, 0.000000, 0.285160, -0.574672, 0.767096, 0.000000, -0.340973, 0.687149, 0.641533, 0.000000, -2177775.065110, 4388777.764681, 4070002.196402, 1.000000],

in the osgb tileset.json, the transform tag is at the end of the file, you can remove it too. For the OSGB, I also had to add an extra translation that is baked into the tiles :

scene.autoUpdate = true;

ogc3DTile.translateX(-57);
ogc3DTile.translateY(-800);
ogc3DTile.translateZ(-105);

image image

I hope this helps