MCPcopy Create free account
hub / github.com/processing/p5.js / isBinary

Function isBinary

src/webgl/loading.js:703–715  ·  view source on GitHub ↗

* @private * This function checks if the file is in ASCII format or in Binary format * * It is done by searching keyword `solid` at the start of the file. * * An ASCII STL data must begin with `solid` as the first six bytes. * However, ASCII STLs lacking the SPACE after the `d` are

(data)

Source from the content-addressed store, hash-verified

701 * Search for `solid` to start anywhere after those prefixes.
702 */
703 function isBinary(data) {
704 const reader = new DataView(data);
705
706 // US-ASCII ordinal values for `s`, `o`, `l`, `i`, `d`
707 const solid = [115, 111, 108, 105, 100];
708 for (let off = 0; off < 5; off++) {
709 // If "solid" text is matched to the current offset, declare it to be an ASCII STL.
710 if (matchDataViewAt(solid, reader, off)) return false;
711 }
712
713 // Couldn't find "solid" text at the beginning; it is binary STL.
714 return true;
715 }
716
717 /**
718 * @private

Callers 1

parseSTLFunction · 0.85

Calls 1

matchDataViewAtFunction · 0.85

Tested by

no test coverage detected