|
@@ -54,7 +54,7 @@ THREE.LegacyGLTFLoader = ( function () {
|
|
|
var content;
|
|
|
var extensions = {};
|
|
|
|
|
|
- var magic = convertUint8ArrayToString( new Uint8Array( data, 0, 4 ) );
|
|
|
+ var magic = THREE.Loader.decodeText( new Uint8Array( data, 0, 4 ) );
|
|
|
|
|
|
if ( magic === BINARY_EXTENSION_HEADER_DEFAULTS.magic ) {
|
|
|
|
|
@@ -63,7 +63,7 @@ THREE.LegacyGLTFLoader = ( function () {
|
|
|
|
|
|
} else {
|
|
|
|
|
|
- content = convertUint8ArrayToString( new Uint8Array( data ) );
|
|
|
+ content = THREE.Loader.decodeText( new Uint8Array( data ) );
|
|
|
|
|
|
}
|
|
|
|
|
@@ -358,7 +358,7 @@ THREE.LegacyGLTFLoader = ( function () {
|
|
|
var headerView = new DataView( data, 0, BINARY_EXTENSION_HEADER_LENGTH );
|
|
|
|
|
|
var header = {
|
|
|
- magic: convertUint8ArrayToString( new Uint8Array( data.slice( 0, 4 ) ) ),
|
|
|
+ magic: THREE.Loader.decodeText( new Uint8Array( data.slice( 0, 4 ) ) ),
|
|
|
version: headerView.getUint32( 4, true ),
|
|
|
length: headerView.getUint32( 8, true ),
|
|
|
contentLength: headerView.getUint32( 12, true ),
|
|
@@ -380,7 +380,7 @@ THREE.LegacyGLTFLoader = ( function () {
|
|
|
var contentArray = new Uint8Array( data, BINARY_EXTENSION_HEADER_LENGTH, header.contentLength );
|
|
|
|
|
|
this.header = header;
|
|
|
- this.content = convertUint8ArrayToString( contentArray );
|
|
|
+ this.content = THREE.Loader.decodeText( contentArray );
|
|
|
this.body = data.slice( BINARY_EXTENSION_HEADER_LENGTH + header.contentLength, header.length );
|
|
|
|
|
|
}
|
|
@@ -390,7 +390,7 @@ THREE.LegacyGLTFLoader = ( function () {
|
|
|
var bufferView = bufferViews[ shader.extensions[ EXTENSIONS.KHR_BINARY_GLTF ].bufferView ];
|
|
|
var array = new Uint8Array( bufferView );
|
|
|
|
|
|
- return convertUint8ArrayToString( array );
|
|
|
+ return THREE.Loader.decodeText( array );
|
|
|
|
|
|
};
|
|
|
|
|
@@ -398,7 +398,7 @@ THREE.LegacyGLTFLoader = ( function () {
|
|
|
|
|
|
var metadata = source.extensions[ EXTENSIONS.KHR_BINARY_GLTF ];
|
|
|
var bufferView = bufferViews[ metadata.bufferView ];
|
|
|
- var stringData = convertUint8ArrayToString( new Uint8Array( bufferView ) );
|
|
|
+ var stringData = THREE.Loader.decodeText( new Uint8Array( bufferView ) );
|
|
|
|
|
|
return 'data:' + metadata.mimeType + ';base64,' + btoa( stringData );
|
|
|
|
|
@@ -664,29 +664,6 @@ THREE.LegacyGLTFLoader = ( function () {
|
|
|
|
|
|
}
|
|
|
|
|
|
- function convertUint8ArrayToString( array ) {
|
|
|
-
|
|
|
- if ( window.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 ++ ) {
|
|
|
-
|
|
|
- s += String.fromCharCode( array[ i ] );
|
|
|
-
|
|
|
- }
|
|
|
-
|
|
|
- return s;
|
|
|
-
|
|
|
- }
|
|
|
-
|
|
|
// Three.js seems too dependent on attribute names so globally
|
|
|
// replace those in the shader code
|
|
|
function replaceTHREEShaderAttributes( shaderText, technique ) {
|