visgl / deck.gl

WebGL2 powered visualization framework
https://deck.gl
MIT License
12.07k stars 2.08k forks source link

Mini RFC - Consistent API for data loaders #5263

Open Pessimistress opened 3 years ago

Pessimistress commented 3 years ago

Background

deck.gl core includes two loaders: json and image

There are 4 official layers that currently require specialized loaders: layer loader package dependency can customize? notes
MVTLayer MVTLoader @loaders.gl/mvt no
TerrainLayer TerrainLoader @loaders.gl/terrain no
ScenegraphLayer GLTFLoader none yes, with registerLoaders requires explicit import in app
Tile3DLayer Tiles3DLoader @loaders.gl/3d-tiles, @loaders.gl/gltf, @loaders.gl/draco yes, with loader prop

There are multiple design inconsistencies here:

Proposal

High-level principles

Roadmap

Pessimistress commented 3 years ago

cc @kylebarron @ibgreen @alasarr

ibgreen commented 3 years ago

This sounds great. Approved from my side.

Happy to help write the docs on how to use loaders.gl with deck. Do you want to get a skeleton page in place so I see how it is intended to integrate with the rest of the docs?

Some comments:

This makes it pointless to exclude GLTFLoader from the ScenegraphLayer from bundle size optimization perspective.

Not completely true, as there is a use case where the ScenegraphLayer can be provided with a programmatically built up scenegraph from luma.gl. But we don't have any examples showing how to do this, and I doubt it is being used, so I agree that we might as well include the loader.

When possible, *WorkerLoader should be used instead of the regular loader. This makes the bundle footprint negligible, without breaking the existing behavior.

If the bundle size issue is particularly worrisome, we could certainly build the non-worker loaders as separately loadable scripts as well. This is not done today, but the DracoLoader loads all the Draco libraries dynamically even when using the non-worker version so we have a good starting point there.

Note that a couple of issues in loaders.gl recently have been around how to use the loaders in air-gapped/no-network environments. Not sure how important this is for deck (use of tiled layers would presumably be ruled out), but it is nice if the user can provide the bundled, non-worker loader as an override. This should be possible with the loaders prop in this proposal, so all good.

MVTLoader and TerrainLoader by default run on webworkers, but the full parser code is still bundled with the main app.

Yes... just curious as to whether we use the output in binary form? If not we are probably not getting optimal performance here.