提交 ad47d7dc 编写于 作者: T Takahiro 提交者: Mr.doob

Fix PMX parse bug of MMDLoader (#9127)

上级 6d626701
......@@ -989,7 +989,7 @@ THREE.MMDLoader.prototype.parsePmx = function ( buffer ) {
var parseFace = function () {
var p = {};
p.indices = dv.getIndexArray( metadata.vertexIndexSize, 3 );
p.indices = dv.getIndexArray( metadata.vertexIndexSize, 3, true );
return p;
};
......@@ -1214,7 +1214,7 @@ THREE.MMDLoader.prototype.parsePmx = function ( buffer ) {
} else if ( p.type === 1 ) { // vertex morph
var m = {};
m.index = dv.getIndex( pmx.metadata.vertexIndexSize );
m.index = dv.getIndex( pmx.metadata.vertexIndexSize, true );
m.position = dv.getFloat32Array( 3 );
p.elements.push( m );
......@@ -1229,7 +1229,7 @@ THREE.MMDLoader.prototype.parsePmx = function ( buffer ) {
} else if ( p.type === 3 ) { // uv morph
var m = {};
m.index = dv.getIndex( pmx.metadata.vertexIndexSize );
m.index = dv.getIndex( pmx.metadata.vertexIndexSize, true );
m.uv = dv.getFloat32Array( 4 );
p.elements.push( m );
......@@ -1268,7 +1268,6 @@ THREE.MMDLoader.prototype.parsePmx = function ( buffer ) {
}
};
var parseFrames = function () {
......@@ -3449,18 +3448,18 @@ THREE.MMDLoader.DataView.prototype = {
},
getIndex: function ( type ) {
getIndex: function ( type, isUnsigned ) {
switch ( type ) {
case 1:
return this.getInt8();
return ( isUnsigned === true ) ? this.getUint8() : this.getInt8();
case 2:
return this.getInt16();
return ( isUnsigned === true ) ? this.getUint16() : this.getInt16();
case 4:
return this.getInt32();
return this.getInt32(); // No Uint32
default:
throw 'unknown number type ' + type + ' exception.';
......@@ -3469,13 +3468,13 @@ THREE.MMDLoader.DataView.prototype = {
},
getIndexArray: function ( type, size ) {
getIndexArray: function ( type, size, isUnsigned ) {
var a = [];
for ( var i = 0; i < size; i++ ) {
a.push( this.getIndex( type ) );
a.push( this.getIndex( type, isUnsigned ) );
}
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册