NASA-AMMOS / 3DTilesRendererJS

Renderer for 3D Tiles in Javascript using three.js
https://nasa-ammos.github.io/3DTilesRendererJS/example/bundle/mars.html
Apache License 2.0
1.47k stars 266 forks source link

Added `loaderMap` property on `TilesRenderer` class to enable using custom loaders for tile formats #517

Closed Insopitus closed 3 months ago

Insopitus commented 3 months ago

508

I didn't go the LoadingManager.getHandler solution, since B3DMLoader and other tile format loaders aren't inherited from three.js' Loader class. It would at least cause ts errors for the library users.

Instead, a property called loaderMap is added to the TilesRenderer class to define which loader should be used for each format.

const tilesRenderer = new TilesRenderer( './path/to/tileset.json' );
tilesRenderer.loaderMap.set('b3dm', new YourCustomB3DMLoader(tilesRenderer.manager));
tilesRenderer.setCamera( camera );
tilesRenderer.setResolutionFromRenderer( camera, renderer );
scene.add( tilesRenderer.group );

@gkjohnson how do you like it?

Insopitus commented 3 months ago

I think I forgot the loaders used in CMPTLoader. I'll update it tomorrow if you think the loaderMap thing is acceptable.

gkjohnson commented 3 months ago

Instead, a property called loaderMap is added to the TilesRenderer class to define which loader should be used for each format.

Thanks! But B3DM, I3DM, PNTS, and CMPT are all deprecated now and glTF is the only officially supported 3d tiles geometry format - so ultimately this is an addition that's only for your usecase. I'd prefer not to modify the public facing API for this change.

Insopitus commented 3 months ago

Okay, understood.