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

geo-layers: refactor tile-3d-layer #4319

Merged
merged 1 commit into from
Mar 11, 2020
Merged

geo-layers: refactor tile-3d-layer #4319

merged 1 commit into from
Mar 11, 2020

Conversation

xintongxia
Copy link
Contributor

Background

  • loaders.gl v2.1 refactors change the tile loaders api

Change List

  • Tile3DLayer API change

This PR depends on loaders.gl v2.1

Copy link
Collaborator

@ibgreen ibgreen left a comment

Choose a reason for hiding this comment

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

Aren't there a bunch of playground examples with ionToken props that will need updating? Will they still work with the new props?

docs/layers/tile-3d-layer.md Outdated Show resolved Hide resolved
docs/layers/tile-3d-layer.md Outdated Show resolved Hide resolved
docs/layers/tile-3d-layer.md Outdated Show resolved Hide resolved
docs/layers/tile-3d-layer.md Outdated Show resolved Hide resolved
##### `_ionAccessToken` (String, Optional)

- `_ionAssetId` and `_ionAccessToken` are used to fetch ion dataset. They are experimental properties, may change in next releases.

[Set up Ion account](https://cesium.com/docs/tutorials/getting-started/#your-first-app);

##### `loadOptions` (Object, Optional)
Copy link
Collaborator

Choose a reason for hiding this comment

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

I find this name a little confusing. I would have called this prop tilesetOptions. Not sure if it is worth renaming it now.

@xintongxia xintongxia requested a review from ibgreen February 27, 2020 18:37
const {attributes, modelMatrix, cartographicOrigin, texture} = content;
const {normals, texCoords} = attributes;
const positions = new Float32Array(attributes.positions.value.length);
for (let i = 0; i < positions.length; i += 3) {
Copy link
Collaborator

Choose a reason for hiding this comment

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

Why do you need to manually transform the positions? The layer’s modelMatrix should propagate in meter offsets mode.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

positions are Float64, can I construct a geometry with Float64Array?

Copy link
Collaborator

Choose a reason for hiding this comment

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

Casting it to Float32Array is fine. Why do you need to apply the modelMatrix?

docs/layers/tile-3d-layer.md Outdated Show resolved Hide resolved

##### Tile3DLayer

`_ionAccessId` and `_ionAccesToken` are removed. To render an ion dataset with `Tile3DLayer`, pass the ion dataset url to prop `data`, and `loadOptions.headers` with Cesium authentication token.
Copy link
Collaborator

Choose a reason for hiding this comment

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

The layer will attempt to download data and parse with registered loaders. Use a different prop name if that is not the intention.

Copy link
Contributor Author

@xintongxia xintongxia Mar 2, 2020

Choose a reason for hiding this comment

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

data of Tile3DLayer is the url to fetch entry point tileset file.

I am proposing the following change:

    const layer = new Tile3DLayer({
      id: 'tile-3d-layer',	      id: 'tile-3d-layer',
      data: '<path-to-your-tileset json file>',	      data: 'https://api.cesium.com/v1/assets/49378',
      loader: Tiles3DLoader,
      // https://cesium.com/docs/rest-api/
      loadOptions: {
        headers: {Authentication: `Bearer <your_ion_access_token>`} 
      },
      ...
    })

Tile3DLayer will do load(data, loader, options) in updateState call. So do you mean data prop will be processed in the base layer.js first?

Copy link
Collaborator

Choose a reason for hiding this comment

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

To get the ion-access-token suitable for use as Bearer, isn't it necessary to first do a couple of ping-pongs with the Cesium API? We had a function for that...

If this works with the tokens users normally use then things are fine.

But if it requires calling a separate function to get the required Authentication header token, then it will no longer be possible to show 3D tilesets in the playground.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I checked the code, also Cesium website, to access the tiles, it only needs the auth header.

Copy link
Collaborator

Choose a reason for hiding this comment

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

it only needs the auth header.

Yes, I believe that is correct, as long as you have the auth header you can access the tiles. My question is how does the application get the auth header in the first place. I seem to recall having to do a ping-pong with the Cesium server to get that header, feeding the ion tokens and ultimately getting the auth header back.

See https://github.com/uber-web/loaders.gl/blob/9c0a8c74dba44e393eb671113b5f3e96768327a8/modules/3d-tiles/src/lib/ion/ion.js

Copy link
Contributor Author

Choose a reason for hiding this comment

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

  • If the user provides both the assetId and access token, then only needs pass in header.
  • If user only provides access token, then the ion util function will try to fetch the all the assets associated with that token and find one asset id.

The current API can cover case 1, for case 2, I am thinking I could provide doc/example of using ion utils to get the asset url pass in Tile3DLayer.

The rest of ion util is for getting ion dataset metadata. I feel that is an application level of detail. I staged my changes and tested with examples, it didn't have auth issues to request the tiles.

Copy link
Collaborator

@ibgreen ibgreen Mar 5, 2020

Choose a reason for hiding this comment

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

am thinking I could provide doc/example of using ion utils to get the asset url pass in Tile3DLayer. I feel that is an application level of detail.

@xintongxia Thanks for explaining. I am not disagreeing with the logic of providing the ion utils separately.

My only real concern is what happens to the JSON playground examples. They will no longer be able to reference ION tokens, right? Is your plan to list headers: {Authentication: "... accessToken"}` in the JSON?

I don't think we are supposed to store the access tokens returned from Cesium ION directly in our github repo, and also I assume those tokens can be rotated by Cesium at any time so even it works during testing it may fail a week later.

One approach could be that you include any required changes to the playground apps this PR:

  • either make sure the playground examples still work without ionAccessToken prop,
  • or conversely, you could delete those examples, if your decision is that we now require apps to call the ion utility functions to use Tile3DLayer with Cesium ION.

Making sure that we agree that this PR may leave the 3D tiles playground examples broken is really my only concern. I am fine with however you decide to resolve that.

modules/geo-layers/src/tile-3d-layer/tile-3d-layer.js Outdated Show resolved Hide resolved
const {attributes, modelMatrix, cartographicOrigin, texture} = content;
const {normals, texCoords} = attributes;
const positions = new Float32Array(attributes.positions.value.length);
for (let i = 0; i < positions.length; i += 3) {
Copy link
Collaborator

Choose a reason for hiding this comment

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

Casting it to Float32Array is fine. Why do you need to apply the modelMatrix?

modules/geo-layers/src/tile-3d-layer/tile-3d-layer.js Outdated Show resolved Hide resolved
modules/geo-layers/src/tile-3d-layer/tile-3d-layer.js Outdated Show resolved Hide resolved
@xintongxia xintongxia force-pushed the xx/tile-3d-layer branch 4 times, most recently from 46c5a69 to 4677804 Compare March 10, 2020 23:01
fix

update doc

Fix example

Use subclass for simplemesh layer

address comments

Fix subclass layer

address comments

fix doc

pass modelMatrix to layer

bump loaders.gl

bump loaders

default loader to Tiles3DLoader

fix jupyter-widget
@coveralls
Copy link

Coverage Status

Coverage decreased (-2.5%) to 80.653% when pulling 8af7ce0 on xx/tile-3d-layer into eb6f163 on master.

@xintongxia xintongxia merged commit baf4125 into master Mar 11, 2020
@xintongxia xintongxia deleted the xx/tile-3d-layer branch March 11, 2020 03:32
@xintongxia xintongxia restored the xx/tile-3d-layer branch March 14, 2020 16:23
@xintongxia xintongxia deleted the xx/tile-3d-layer branch March 14, 2020 16:26
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.

4 participants