import { BaseTileLoader , Tile , TileLoaderState } from "@here/harp-mapview" ; import { addGroundPlane } from "@here/harp-mapview/lib/geometry/AddGroundPlane" ; import { enableBlending } from "@here/harp-materials" ; import * as THREE from "three" ; import { WebTileDataProvider , WebTileDataSource } from "./WebTileDataSource" ; /**
 * TileLoader used by `WebTileDataSource`.
 */ export class WebTileLoader extends BaseTileLoader { param dataSource param tileKey param dataProvider constructor ( protected dataSource , private readonly tile , private readonly dataProvider ) { super ( dataSource , tile . tileKey ) ; } @override
      protected loadImpl ( abortSignal , onDone , onError ) { this . dataProvider . getTexture ( this . tile , abortSignal ) . then ( value => { if ( value === undefined || value [ 0 ] === undefined ) { this . tile . forceHasGeometry ( true ) ; onDone ( TileLoaderState . Ready ) ; return ; } const [ texture , copyrightInfo ] = value ; if ( copyrightInfo !== undefined ) { this . tile . copyrightInfo = copyrightInfo ; } texture . minFilter = THREE . LinearFilter ; texture . magFilter = THREE . LinearFilter ; texture . generateMipmaps = false ; this . tile . clear ( ) ; this . tile . addOwnedTexture ( texture ) ; const planeMesh = addGroundPlane ( this . tile , this . dataSource . renderOrder , 0xffffff , this . dataSource . opacity , true ) ; const planeMaterial = planeMesh . material as THREE . MeshBasicMaterial ; planeMaterial . map = texture ; if ( this . dataSource . transparent ) { enableBlending ( planeMaterial ) ; } planeMaterial . depthTest = false ; this . tile . invalidateResourceInfo ( ) ; this . dataSource . requestUpdate ( ) ; onDone ( TileLoaderState . Ready ) ; } , onError ) . catch ( onError ) ; } }