Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feat/google3d tiles #2124

Merged
merged 1 commit into from
Mar 15, 2024
Merged

Feat/google3d tiles #2124

merged 1 commit into from
Mar 15, 2024

Conversation

jogarnier
Copy link
Contributor

Description

  • added C3DTilesGoogleSource type to C3DTilesSource.
  • C3DTilesGoogleSource requires non-standard parsing metadata to provides valid urls => identified this code clearly
  • Refactored b3dmParser to extract pure gltfparser logic
  • added url parameters to Fetcher methods to allow passing dynamic parameters to url request, (required by C3DTilesGoogleSource authentification logic. https://developers.google.com/maps/documentation/tile/create-renderer?hl=en)

Motivation and Context

#2099

@jogarnier jogarnier requested review from gchoqueux and jailln June 30, 2023 08:58
@jogarnier jogarnier force-pushed the feat/google3dTiles branch from 183f629 to fd7c586 Compare June 30, 2023 09:02
@jailln jailln requested a review from mgermerie June 30, 2023 09:03
@jogarnier jogarnier force-pushed the feat/google3dTiles branch from fd7c586 to 960d517 Compare June 30, 2023 09:03
docs/tutorials/Fundamentals.md Outdated Show resolved Hide resolved
src/Parser/GLTFParser.js Outdated Show resolved Hide resolved
src/Parser/GLTFParser.js Show resolved Hide resolved
src/Parser/GLTFParser.js Outdated Show resolved Hide resolved
src/Parser/GLTFParser.js Outdated Show resolved Hide resolved
src/Parser/GLTFParser.js Outdated Show resolved Hide resolved
src/Process/3dTilesProcessing.js Outdated Show resolved Hide resolved
src/Provider/3dTilesProvider.js Outdated Show resolved Hide resolved
src/Source/C3DTilesGoogleSource.js Outdated Show resolved Hide resolved
src/Source/C3DTilesGoogleSource.js Outdated Show resolved Hide resolved
@jogarnier jogarnier force-pushed the feat/google3dTiles branch 5 times, most recently from 3dc77f9 to 9d4c59b Compare July 3, 2023 15:35
src/Parser/GLTFParser.js Outdated Show resolved Hide resolved
Copy link
Contributor

@Desplandis Desplandis left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice job on this PR! =)
I was able to test it using my google cloud keys and your example branch. This is still "experimental" as they are critical issues (blinking, no loading of some tiles, ...) but these come from our 3D tiles implementation.

As for my comments:

  • I think you should move some parts specific to b3dm outside of the gltf parser
  • I question if we should follow the standard or cesium behavior
  • I'm not convinced by the multiple changes in Fetcher.js due to this use-case being specific but I could change my mind with a little explanation =)
  • Some minor issues

P.S.: Before merging, could you please rewrite your commit messages + your history (notably isolate changes in Fetcher.js, changes in b3dm/gltf parsers in their own commits)?

src/Parser/B3dmParser.js Outdated Show resolved Hide resolved
src/Parser/B3dmParser.js Outdated Show resolved Hide resolved
src/Parser/GLTFParser.js Outdated Show resolved Hide resolved
src/Parser/GLTFParser.js Outdated Show resolved Hide resolved
src/Parser/GLTFParser.js Outdated Show resolved Hide resolved
src/Process/3dTilesProcessing.js Outdated Show resolved Hide resolved
src/Provider/Fetcher.js Outdated Show resolved Hide resolved
src/Provider/Fetcher.js Outdated Show resolved Hide resolved
src/Source/C3DTilesGoogleSource.js Show resolved Hide resolved
src/Source/C3DTilesGoogleSource.js Outdated Show resolved Hide resolved
@jailln jailln self-assigned this Jan 22, 2024
@jailln jailln force-pushed the feat/google3dTiles branch 2 times, most recently from 4028887 to f2d6a18 Compare February 1, 2024 15:23
@jailln
Copy link
Contributor

jailln commented Feb 1, 2024

I just pushed some modifications that should answer all of your comments:

  • GLTFParser is now only a wrapper for gltfLoader and legacyGltfLoader and everything 3D tiles related as been moved to B3DMParser
  • Only export GLTFParser and not gltfLoader and legacyGltfLoader anymore, which is a breaking change but avoids exporting two things having the same purpose. WDYT ? Should we keep it like that or also export gltfLoader and legacyGltfLoader to avoid a breaking change until the next major version?
  • Some 3D Tiles related parts could be refactored / simplified (especially the B3dmParser) but I didn't go into much trouble here since we are seriously considering to handle 3D tiles parsing with an external lib very soon.
  • I wanted to add more tests on the GLTFParser but I decided to wait until rework unit tests (mocking the fetch()) #2183 is merged since I needed to load local files.

@Desplandis let me know what you think :)

@jailln jailln requested a review from Desplandis February 1, 2024 15:32
@jailln jailln force-pushed the feat/google3dTiles branch from f2d6a18 to 9b8011e Compare February 1, 2024 15:41
Copy link
Contributor

@Desplandis Desplandis left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice changes, I did have some additional comments nonetheless but should be easy to answer. Since those are mostly aesthetics + some questions, I'll approve this PR but please answer them. =)

Only export GLTFParser and not gltfLoader and legacyGltfLoader anymore, which is a breaking change but avoids exporting two things having the same purpose. WDYT ? Should we keep it like that or also export gltfLoader and legacyGltfLoader to avoid a breaking change until the next major version?

I'm usually cautious about breaking changes, however I don't think they are used directly by anyone...

Some 3D Tiles related parts could be refactored / simplified (especially the B3dmParser) but I didn't go into much trouble here since we are seriously considering to handle 3D tiles parsing with an external lib very soon.

I held comments on that topic. x)

I wanted to add more tests on the GLTFParser but I decided to wait until #2183 is merged since I needed to load local files.

This will the object of a future PR I think!

* true, a threejs [MeshBasicMaterial](https://threejs.org/docs/index.html?q=meshbasic#api/en/materials/MeshBasicMaterial)
* is set up. config.overrideMaterials can also be a threejs [Material](https://threejs.org/docs/index.html?q=material#api/en/materials/Material)
* in which case it will be the material used to override.
* @return {Promise} - a promise that resolves with an object containig a THREE.Scene (gltf) and a batch table (batchTable).
*
*/
parse(buffer, options) {
const gltfUpAxis = options.gltfUpAxis;
const urlBase = options.urlBase;
const frustumCulled = options.frustumCulled === undefined || options.frustumCulled === null ? true : !!(options.frustumCulled);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A simpler way could be:

Suggested change
const frustumCulled = options.frustumCulled === undefined || options.frustumCulled === null ? true : !!(options.frustumCulled);
const frustumCulled = options.frustumCulled ?? true;

Moreover, the default parameter is documented as false.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Set it back to false and used a more syntetic syntax

};
return Fetcher.arrayBuffer(url, layer.source.networkOptions).then((result) => {
if (result !== undefined) {
let func;
const magic = utf8Decoder.decode(new Uint8Array(result, 0, 4));
if (magic[0] === '{') {
result = JSON.parse(utf8Decoder.decode(new Uint8Array(result)));
const newPrefix = url.slice(0, url.lastIndexOf('/') + 1);
let newPrefix = '';
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No need to assign newPrefix since it is assigned in both branch of the following condition (or do a ternary condition).

Suggested change
let newPrefix = '';
let newPrefix;

Comment on lines 9 to 11
const uri = tile.content.uri.substr(tile.content.uri.indexOf('?') + 1);
const sessionIds = uri.split('=');
return sessionIds[1];
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is there a non-hacky way to do this with URLSearchParams and get this value with the corresponding key (i.e. sessionId)?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yep, done

src/Source/C3DTilesGoogleSource.js Show resolved Hide resolved
src/Parser/B3dmParser.js Show resolved Hide resolved
src/Main.js Outdated
@@ -91,7 +92,7 @@ export { default as LASParser } from 'Parser/LASParser';
export { default as ISGParser } from 'Parser/ISGParser';
export { default as GDFParser } from 'Parser/GDFParser';
export { default as GTXParser } from 'Parser/GTXParser';
export { enableDracoLoader, enableKtx2Loader, glTFLoader, legacyGLTFLoader } from 'Parser/B3dmParser';
export { default as GLTFParser, enableDracoLoader, enableKtx2Loader } from 'Parser/GLTFParser';
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Okay with the change!

@jailln jailln force-pushed the feat/google3dTiles branch from 9b8011e to c91731d Compare February 12, 2024 17:08
@jailln jailln requested a review from Desplandis February 12, 2024 17:08
@jailln jailln force-pushed the feat/google3dTiles branch 2 times, most recently from 0d9430d to 7f1146d Compare February 12, 2024 17:49
@jailln jailln force-pushed the feat/google3dTiles branch 2 times, most recently from 319443e to a6f1b6e Compare February 16, 2024 10:22
@jailln
Copy link
Contributor

jailln commented Feb 16, 2024

I went back on a previous change: I keep exporting gltfLoader and legacyGLTFLoader for now, for several reasons:

  • GLTFParser only has a parse method and not the other methods of gltfLoader and legacyGLTFLoader (e.g. load, loadAsync, etc.) that itowns users might use (including me 😁 )
  • don't introduce an unnecessary breaking change now
  • this is a bit out of scope of this PR

Therefore I think it's ready to merge @Desplandis

Note that I started a branch to migrate to 3d-tiles-renderer-js in which I started implementing an "itowns GltfLoader" that inherits from THREE.Loader, shares the same interface than GLTFLoader but can load gltf 1.0 and 2.0 files. It makes more sense to do it in the 3d-tiles-renderer-js migration since we really need it in this context.

@jailln jailln force-pushed the feat/google3dTiles branch from a6f1b6e to bacf9cc Compare February 16, 2024 10:34
@jailln jailln force-pushed the feat/google3dTiles branch 3 times, most recently from 3eee948 to d5ae6cb Compare March 6, 2024 13:46
Copy link
Contributor

@Desplandis Desplandis left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sounds good to me, all comments have been resolved! =)

@Desplandis
Copy link
Contributor

@jailln Since #2183 was merged before this PR, you have a conflict in the GLTFLoader unit test but it should be easy to resolve!

@jailln jailln force-pushed the feat/google3dTiles branch from d5ae6cb to 974e229 Compare March 15, 2024 11:44
@jailln jailln force-pushed the feat/google3dTiles branch from 974e229 to ceaa063 Compare March 15, 2024 16:25
@jailln jailln force-pushed the feat/google3dTiles branch from ceaa063 to f5c3168 Compare March 15, 2024 16:44
@jailln jailln merged commit e6eb4cf into iTowns:master Mar 15, 2024
9 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants