TileLoader

A Tile loader that manages caching and load order. The cache is an LRU cache and is defined by the number of items it can hold. The actual number of cached items might grow beyond max if all items are in use. The load order is designed for optimal perceived loading speed (nearby tiles are refined first).

Constructor

new TileLoader(optionsopt)

Creates a tile loader with a maximum number of cached items and callbacks. The only required property is a renderer that will be used to visualize the tiles. The maxCachedItems property is the size of the cache in number of objects, mesh tile and tileset.json files. The mesh and point callbacks will be called for every incoming mesh or points.
Parameters:
NameTypeAttributesDescription
optionsObject<optional>
Optional configuration object.
Properties
NameTypeAttributesDefaultDescription
maxCachedItemsnumber<optional>
100the cache size.
meshCallbackfunction<optional>
A callback to call on newly decoded meshes.
pointsCallbackfunction<optional>
A callback to call on newly decoded points.
proxysring<optional>
An optional proxy that tile requests will be directed too as POST requests with the actual tile url in the body of the request.
ktx2LoaderKTX2Loader<optional>
A KTX2Loader (three/addons)
dracoLoaderDRACOLoader<optional>
A DRACOLoader (three/addons)
rendererrenderer<optional>
optional the renderer, this is required only for on the fly ktx2 support. not needed if you pass a ktx2Loader manually

Methods

clear()

Invalidates all the unused cached tiles.

get(abortController, tileIdentifier, path, callback, distanceFunction, getSiblings, level, sceneZupToYup, meshZupToYup, geometricError)

Schedules a tile content to be downloaded
Parameters:
NameTypeDescription
abortControllerAbortController
tileIdentifierstring | Number
pathstring
callbackfunction
distanceFunctionfunction
getSiblingsfunction
levelNumber
sceneZupToYupBoolean
meshZupToYupBoolean
geometricErrorNumber

invalidate(path, tileIdentifier)

unregisters a tile content for a specific tile, removing it from the cache if no other tile is using the same content.
Parameters:
NameTypeDescription
pathstringthe content path/url
tileIdentifierstring | Numberthe tile ID

update()

To be called in the render loop or at regular intervals. launches tile downloading and loading in an orderly fashion.