Asset.prototype.reader

Return an AssetByteReader object that can be used to read the contents of the asset.

Syntax

reader()

Return value

An AssetByteReader object.

The AssetByteReader that has a method read(length) that reads length bytes from the asset and returns ArrayBuffer. It keeps track of the offset in the asset, and updates it with each read. When the end of the asset is reached, it returns undefined.

Examples

let reader = Asset("myasset").reader()
reader.read(6)
ArrayBuffer [ 0, 1, 2, 3, 4, 5 ]

See also