diff --git a/src/base/TilesRendererBase.d.ts b/src/base/TilesRendererBase.d.ts index dd3b8f1d4..996d1d304 100644 --- a/src/base/TilesRendererBase.d.ts +++ b/src/base/TilesRendererBase.d.ts @@ -1,7 +1,27 @@ import { LRUCache } from '../utilities/LRUCache'; import { PriorityQueue } from '../utilities/PriorityQueue'; +import { Tile } from './Tile'; -export class TilesRendererBase { +export type Attribution = + | { type: 'string'; value: string } + | { type: 'html'; value: string } + | { type: 'image'; value: string }; + +export interface TilesRendererBasePlugin { + init?: ( renderer: TilesRendererBase ) => void; + + fetchData?: ( url: RequestInfo, options: RequestInit ) => Promise; + parseTile?: ( content: ArrayBuffer | DataView, tile: Tile, extension: string, uri: string ) => Promise; + preprocessURL?: ( uri: string ) => string; + preprocessNode?: ( tile: Tile, tileSetDir: string, parentTile: Tile | null ) => void; + loadRootTileSet?: () => Promise; + disposeTile?: ( tile: Tile ) => void; + getAttributions?: ( target: Attribution[] ) => void; + + dispose?: () => void; +} + +export class TilesRendererBase { readonly rootTileSet : object | null; readonly root : object | null; @@ -20,9 +40,9 @@ export class TilesRendererBase { constructor( url?: string ); update() : void; - registerPlugin( plugin: object ) : void; - unregisterPlugin( plugin: object | string ) : boolean; - getPluginByName( plugin: object | string ) : object; + registerPlugin( plugin: TPlugin ) : void; + unregisterPlugin( plugin: TPlugin | string ) : boolean; + getPluginByName( plugin: string ) : TPlugin; traverse( beforeCb : ( ( tile : object, parent : object, depth : number ) => boolean ) | null, afterCb : ( ( tile : object, parent : object, depth : number ) => boolean ) | null diff --git a/src/index.d.ts b/src/index.d.ts index 8dfe82ea4..61f41f82d 100644 --- a/src/index.d.ts +++ b/src/index.d.ts @@ -1,6 +1,6 @@ // three.js export { DebugTilesRenderer } from './three/DebugTilesRenderer'; -export { TilesRenderer } from './three/TilesRenderer'; +export { TilesRenderer, TilesRendererPlugin } from './three/TilesRenderer'; export { TilesGroup } from './three/TilesGroup'; export { B3DMLoader, B3DMScene } from './three/loaders/B3DMLoader'; export { I3DMLoader, I3DMScene } from './three/loaders/I3DMLoader'; @@ -24,7 +24,7 @@ export * from './three/plugins/DebugTilesPlugin'; export { ImplicitTilingPlugin } from './base/plugins/ImplicitTilingPlugin'; // common -export { TilesRendererBase } from './base/TilesRendererBase'; +export { TilesRendererBase, TilesRendererBasePlugin } from './base/TilesRendererBase'; export { Tile } from './base/Tile'; export { TileBase } from './base/TileBase'; export { Tileset } from './base/Tileset'; diff --git a/src/three/TilesRenderer.d.ts b/src/three/TilesRenderer.d.ts index 1d8fff7af..38ee99e0b 100644 --- a/src/three/TilesRenderer.d.ts +++ b/src/three/TilesRenderer.d.ts @@ -1,10 +1,15 @@ import { Box3, Camera, Vector2, Matrix4, WebGLRenderer, Object3D, LoadingManager, Sphere } from 'three'; import { Tile } from '../base/Tile'; -import { TilesRendererBase } from '../base/TilesRendererBase'; +import { TilesRendererBase, TilesRendererBasePlugin } from '../base/TilesRendererBase'; import { TilesGroup } from './TilesGroup'; import { Ellipsoid } from './math/Ellipsoid'; -export class TilesRenderer extends TilesRendererBase { +export interface TilesRendererPlugin extends TilesRendererBasePlugin { + processTileModel?: ( scene: Object3D, tile: Tile ) => Promise; + doTilesNeedUpdate?: () => boolean; +} + +export class TilesRenderer extends TilesRendererBase { ellipsoid: Ellipsoid; autoDisableRendererCulling : boolean;