UNPKG

three

Version:

JavaScript 3D library

47 lines (26 loc) 805 B
/** * @author Don McCurdy / https://www.donmccurdy.com */ var LoaderUtils = { decodeText: function ( array ) { if ( typeof TextDecoder !== 'undefined' ) { return new TextDecoder().decode( array ); } // Avoid the String.fromCharCode.apply(null, array) shortcut, which // throws a "maximum call stack size exceeded" error for large arrays. var s = ''; for ( var i = 0, il = array.length; i < il; i ++ ) { // Implicitly assumes little-endian. s += String.fromCharCode( array[ i ] ); } // Merges multi-byte utf-8 characters. return decodeURIComponent( escape( s ) ); }, extractUrlBase: function ( url ) { var parts = url.split( '/' ); if ( parts.length === 1 ) return './'; parts.pop(); return parts.join( '/' ) + '/'; } }; export { LoaderUtils };