Browse Source

Added nullByte check to getString

Lewy Blue 7 years ago
parent
commit
6eb1c2eab6
1 changed files with 4 additions and 18 deletions
  1. 4 18
      examples/js/loaders/FBXLoader.js

+ 4 - 18
examples/js/loaders/FBXLoader.js

@@ -3650,25 +3650,11 @@
 
 		getString: function ( size ) {
 
-			var a = [];
-
-			while ( size > 0 ) {
-
-				var value = this.getUint8();
-				size --;
-
-				if ( value === 0 ) {
-
-					this.skip( size );
-					break;
-
-				}
-
-				a.push( value );
-
-			}
+			var a = new Uint8Array( this.getUint8Array( size ) );
+			var nullByte = a.indexOf( 0 );
+			if ( nullByte >= 0 ) a = a.slice( 0, nullByte );
 
-			return THREE.LoaderUtils.decodeText( new Uint8Array( a ) );
+			return THREE.LoaderUtils.decodeText( a );
 
 		}