ebeaufay / threedtiles

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

Tileset not showing #11

Closed AdrienHoule closed 1 year ago

AdrienHoule commented 1 year ago

Hi I'm trying to load a b3dm in a scene but can't see it even tough I have no error in the console. So if you have any idea why I would love to know. Thanks in advance. Capture d’écran 2023-01-04 120415 Capture d’écran 2023-01-04 120441

ebeaufay commented 1 year ago

Hi Adrien,

A few things might cause the black screen.

First, be sure to add light to your scene e.g.: Scene.add(new THREE.AmbientLight("#ffffff,1.0));

If that doesn't solve it, your Tilesets may be outside the view. Check the tile "bounding volume" and adjust the camera to point at it.

Come back to me if it doesn't solve it

AdrienHoule commented 1 year ago

Thanks for your answer, so I added lighting to the scene and it didn't change anything. So I tried moving my camera near the object and using camera.lookAt for rotation but still couldn't see the object. The bouding volume of the root tile is the following "root": { "boundingVolume": { "region": [ 0, 0.6811202739730972, 0.4163239024191421, 0.9734848446547839, -475989.18440294435, 472931.24836871633 ] },

ebeaufay commented 1 year ago

Ah ok, I see the bounding volume is a region.. these are specific to Georeferenced tilesets and I don't support it.

However, I've been waiting for the opportunity to add it, I just didn't have a sample use case

I can do it quite quickly but it could help if you can share the tileset or host it on a public file server

AdrienHoule commented 1 year ago

Of course I will share it to you, but I need a little time cause it is a geopackage not json tileset and there is an app my company made that converts it to json and make it useable from a server. And I unfortunately can't share the app with you. So let me convert it first or regenerate an other 3DTiles b3dm with region and will send it to you. I currently only have i3dm and cmpt that are in this format.

ebeaufay commented 1 year ago

You know what, I found some datasets online and I think I fixed it, I'm going to test a bit more and I'll push a new version

AdrienHoule commented 1 year ago

Okay, if you need I still made some random data that is a b3dm with region around corsica. https://drive.google.com/file/d/1gho8gt0fUcVVwqEkTlktWz_JecoAPgZV/view?usp=share_link

laraduarte commented 1 year ago

I'm having the same issue! I can add the model to the scene but only the first mesh/level loads! The lod does not seem to be working with this type of model!

image

ebeaufay commented 1 year ago

Okay, if you need I still made some random data that is a b3dm with region around corsica. https://drive.google.com/file/d/1gho8gt0fUcVVwqEkTlktWz_JecoAPgZV/view?usp=share_link

I can view the model but I have no texture is that normal? Also the model loads very slowly and that's because the tiles are encoded in a sub-optimal manner.

Nevertheless, I can see the model. I'm going to add some helper function to center the model on the origin and perhaps rotate it according to the shape of the earth. The "region" bounding volume is in lon/lat/height and takes the ellipsoid into account

ebeaufay commented 1 year ago

Hi @AdrienHoule I find an inconsistency with your dataset relative to others I found online.

The doc stated that : glTFs must be transformed from y-up to z-up at runtime and I see that the gltf files in your model are indeed defined as y-up. However, I have not seen this implemented in other tilesets where the GLTFs are all z-up

Now, it is very possible that I mess up something in the transformations but I have 2 tilesets from 2 different sources that work different from yours.

Do you have another tileset I could test with?

@laraduarte , would you care to share the model in the screenshot or a link to it?

laraduarte commented 1 year ago

@ebeaufay I will send you an email with the link!

AdrienHoule commented 1 year ago

Hi, yeah the model has no texture don't worry it's normal. It is an old tileset I generated months ago, so don't worry about the gltf axis it is wrong, you should not use y-up but cesium still allows it to be used and you probably will have errors. I will try making/finding another b3dm but as I said most are geopackage tileset or CPMT and i3dm (if you need the second ones I can give it to you). ps : sry if I made english errors, I have a hard time talking english on technical points

ebeaufay commented 1 year ago

You can try with version 5.1.3 also on NPM.

use the property "centerModel: true" to center and rotate the model so that it's up axis aligns with the y-axis.

ebeaufay commented 1 year ago

@laraduarte

About the issue where you'd like to raise the model so that its lowest point is on y = 0, you can do it by creating the tileset like this :

const ogc3DTile = new OGC3DTile({
        url: "http://localhost:8082/tileset.json",
        static: false,
        centerModel:true,
        renderer: renderer,
        onLoadCallback: (tile)=>{
            if (!!tile.json.boundingVolume.region) {
                const halfHeight = (tile.json.boundingVolume.region[5] - tile.json.boundingVolume.region[4]) * 0.5;
                ogc3DTile.translateOnAxis(new THREE.Vector3(0, 1, 0), halfHeight);
            }
        }
    });

In this example, I wait for the tileset.json to be loaded in order to access the bounding volume and infer how much to raise the model by.

I would consider having some API for this in the future, but I think this workaround should get you going.

ebeaufay commented 1 year ago

@AdrienHoule, I'll close the issue if this worked for you