2
0
Эх сурвалжийг харах

Added nullByte check to getString

Lewy Blue 7 жил өмнө
parent
commit
6eb1c2eab6

+ 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 );
 
 		}