提交 05effe21 编写于 作者: T Takahiro

Revert "GLTFExporter: Fix padding in stringToArrayBuffer for multi-byte strings"

This reverts commit 0359d571.
上级 b1401c35
......@@ -131,70 +131,39 @@ THREE.GLTFExporter.prototype = {
/**
* Converts a string to an ArrayBuffer.
* @param {string} text
* @param {Boolean} padded
* @return {ArrayBuffer}
*/
function stringToArrayBuffer( text, padded ) {
if ( padded ) {
var spaceCode = ' '.charCodeAt( 0 );
var pad = getPaddedBufferSize( text.length ) - text.length;
if ( window.TextEncoder !== undefined ) {
var view = new TextEncoder().encode( text );
if ( ! padded || ( view.length % 4 ) === 0 ) return view.buffer;
for ( var i = 0; i < pad; i++ ) {
var view2 = new Uint8Array( new ArrayBuffer( getPaddedBufferSize( view.length ) ) );
for ( var i = 0, il = view.length; i < il; i ++ ) {
view2[ i ] = view[ i ];
text += ' ';
}
// pad with space
for ( var i = view.length, il = view2.length; i < il; i ++ ) {
view2[ i ] = spaceCode;
}
return view2.buffer;
} else {
var length = padded ? getPaddedBufferSize( text.length ) : text.length;
var view = new Uint8Array( new ArrayBuffer( length ) );
for ( var i = 0, il = text.length; i < il; i ++ ) {
var value = text.charCodeAt( i );
if ( value > 0xFF ) {
// replace multi-byte string with space
view[ i ] = spaceCode;
} else {
if ( window.TextEncoder !== undefined ) {
view[ i ] = value;
return new TextEncoder().encode( text ).buffer;
}
}
var buffer = new ArrayBuffer( text.length );
// pad with space
for ( var i = text.length; i < length; i ++ ) {
var bufferView = new Uint8Array( buffer );
view[ i ] = spaceCode;
for ( var i = 0; i < text.length; ++ i ) {
}
return view.buffer;
bufferView[ i ] = text.charCodeAt( i );
}
return buffer;
}
/**
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册