* @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)
| 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 |
no test coverage detected