loaders.gl API consistently uses ArrayBuffers to represent and transport binary data.
One of the design goals of loaders.gl is to provide applications with a single, consistent API that works across (reasonably modern) browsers, worker threads and Node.js. One of the characteristics of this API is how binary data is represented.
loaders.gl "standardizes" on ArrayBuffers for a number of reasons:
Bufferclass is now backed by an
Recall that typed arrays (e.g.
Float32Array) are just views into array buffers. Every typed array has a
Many loaders.gl functions directly accept typed arrays.
Caveat: typed arrays that are partial views (e.g. with offsets) sometimes need special handling in the application.
Since these classes are central to using ArrayBuffers correctly, loaders.gl re-exports these symbols, transparently polyfilling them under Node.js.
Binary formats in JS:
Examples of semi-"binary" formats in JS: