MCPcopy Index your code
hub / github.com/processing/p5.js / parseSTL

Function parseSTL

src/webgl/loading.js:668–687  ·  view source on GitHub ↗

* @private * STL files can be of two types, ASCII and Binary, * * We need to convert the arrayBuffer to an array of strings, * to parse it as an ASCII file.

(model, buffer)

Source from the content-addressed store, hash-verified

666 * to parse it as an ASCII file.
667 */
668 function parseSTL(model, buffer) {
669 if (isBinary(buffer)) {
670 parseBinarySTL(model, buffer);
671 } else {
672 const reader = new DataView(buffer);
673
674 if (!('TextDecoder' in window)) {
675 console.warn(
676 'Sorry, ASCII STL loading only works in browsers that support TextDecoder (https://caniuse.com/#feat=textencoder)'
677 );
678 return model;
679 }
680
681 const decoder = new TextDecoder('utf-8');
682 const lines = decoder.decode(reader);
683 const lineArray = lines.split('\n');
684 parseASCIISTL(model, lineArray);
685 }
686 return model;
687 }
688
689 /**
690 * @private

Callers 2

cbFunction · 0.85
loadingFunction · 0.85

Calls 4

isBinaryFunction · 0.85
parseBinarySTLFunction · 0.85
parseASCIISTLFunction · 0.85
splitMethod · 0.80

Tested by

no test coverage detected