Skip to main content
←API Reference ←com.nianticspatial.nsdk.mesh ←MeshDownloaderSession

downloadByAsset


Declaration​

fun downloadByAsset( vpsMapAssetId: String, latitude: Double, longitude: Double, getTexture: Boolean, maxChunks: Int = 0, maxSizeKb: Int = 0, maxDecodedSizeKb: Int = DEFAULT_MAX_DECODED_SIZE_KB, ): Flow<NSDKResult<MeshDownloaderData, MeshDownloaderError>>

Summary​

Streams mesh chunks for a VPS map asset, sorted closest-first by GPS position.


MeshDownloader resolves the mesh sibling for vpsMapAssetId via SitesManager, then
downloads chunks. The flow completes normally once all chunks have been delivered. Any
failure is emitted as a terminal NSDKResult.Error whose code is the relevant
MeshDownloaderError, ending the flow.

Returns​

A Flow that emits NSDKResult.Success for each chunk and a terminal NSDKResult.Error if the download fails or the size limit is reached. The download starts when the Flow is collected. Cancelling the collection, or ending it early with an operator such as first() or take(), does not stop the native download, which has no cancel: it runs until it completes or reaches its limits. Bound it with maxChunks, maxSizeKb and maxDecodedSizeKb rather than by stopping collection.

Parameters​

NameTypeSummary
vpsMapAssetIdString
The VPS map (VPS_INFO) asset ID from the Sites API.
latitudeDouble
User latitude in decimal degrees, used to sort chunks closest-first.
longitudeDouble
User longitude in decimal degrees, used to sort chunks closest-first.
getTextureBoolean
If true, texture bytes are included in each chunk.
maxChunksInt
Maximum number of mesh nodes to download. Pass 0 for no limit.
maxSizeKbInt
Cumulative size cap in kilobytes, counting bytes served from the on-disk cache as well as downloaded ones. Pass 0 for no limit.
maxDecodedSizeKbInt
Cumulative budget in kilobytes for what the delivered chunks occupy once decoded, cached or downloaded: vertices, UVs, indices and per-vertex colours at 4 bytes each, plus texture bytes as received. Pass 0 for no budget.