|
@@ -83,11 +83,13 @@ THREE.XLoader = ( function () {
|
|
|
this.putFlags.putPos = true;
|
|
|
|
|
|
}
|
|
|
+
|
|
|
if ( this.putFlags.putRot === undefined ) {
|
|
|
|
|
|
this.putFlags.putRot = true;
|
|
|
|
|
|
}
|
|
|
+
|
|
|
if ( this.putFlags.putScl === undefined ) {
|
|
|
|
|
|
this.putFlags.putScl = true;
|
|
@@ -105,6 +107,7 @@ THREE.XLoader = ( function () {
|
|
|
this.hierarchy.push( this.makeBonekeys( XAnimationInfoArray[ i ] ) );
|
|
|
|
|
|
}
|
|
|
+
|
|
|
this.length = this.hierarchy[ 0 ].keys[ this.hierarchy[ 0 ].keys.length - 1 ].time;
|
|
|
|
|
|
}
|
|
@@ -128,6 +131,7 @@ THREE.XLoader = ( function () {
|
|
|
return Object.assign( {}, this );
|
|
|
|
|
|
};
|
|
|
+
|
|
|
return refObj;
|
|
|
|
|
|
}
|
|
@@ -145,16 +149,19 @@ THREE.XLoader = ( function () {
|
|
|
keyframe.pos = XAnimationInfo.keyFrames[ i ].pos;
|
|
|
|
|
|
}
|
|
|
+
|
|
|
if ( XAnimationInfo.keyFrames[ i ].rot && this.putFlags.putRot ) {
|
|
|
|
|
|
keyframe.rot = XAnimationInfo.keyFrames[ i ].rot;
|
|
|
|
|
|
}
|
|
|
+
|
|
|
if ( XAnimationInfo.keyFrames[ i ].scl && this.putFlags.putScl ) {
|
|
|
|
|
|
keyframe.scl = XAnimationInfo.keyFrames[ i ].scl;
|
|
|
|
|
|
}
|
|
|
+
|
|
|
if ( XAnimationInfo.keyFrames[ i ].matrix ) {
|
|
|
|
|
|
keyframe.matrix = XAnimationInfo.keyFrames[ i ].matrix;
|
|
@@ -163,11 +170,13 @@ THREE.XLoader = ( function () {
|
|
|
keyframe.pos = new THREE.Vector3().setFromMatrixPosition( keyframe.matrix );
|
|
|
|
|
|
}
|
|
|
+
|
|
|
if ( this.putFlags.putRot ) {
|
|
|
|
|
|
keyframe.rot = new THREE.Quaternion().setFromRotationMatrix( keyframe.matrix );
|
|
|
|
|
|
}
|
|
|
+
|
|
|
if ( this.putFlags.putScl ) {
|
|
|
|
|
|
keyframe.scl = new THREE.Vector3().setFromMatrixScale( keyframe.matrix );
|
|
@@ -175,9 +184,11 @@ THREE.XLoader = ( function () {
|
|
|
}
|
|
|
|
|
|
}
|
|
|
+
|
|
|
keys.push( keyframe );
|
|
|
|
|
|
}
|
|
|
+
|
|
|
return keys;
|
|
|
|
|
|
}
|
|
@@ -239,6 +250,7 @@ THREE.XLoader = ( function () {
|
|
|
return;
|
|
|
|
|
|
}
|
|
|
+
|
|
|
for ( var i = _start; i < _arg.length; i ++ ) {
|
|
|
|
|
|
switch ( i ) {
|
|
@@ -253,6 +265,7 @@ THREE.XLoader = ( function () {
|
|
|
}
|
|
|
|
|
|
}
|
|
|
+
|
|
|
if ( this.options === undefined ) {
|
|
|
|
|
|
this.options = {};
|
|
@@ -291,6 +304,7 @@ THREE.XLoader = ( function () {
|
|
|
find = line.indexOf( '#', readed );
|
|
|
|
|
|
}
|
|
|
+
|
|
|
if ( find > - 1 && find < 2 ) {
|
|
|
|
|
|
var foundNewLine = - 1;
|
|
@@ -321,6 +335,7 @@ THREE.XLoader = ( function () {
|
|
|
}
|
|
|
|
|
|
}
|
|
|
+
|
|
|
return line.substr( readed );
|
|
|
|
|
|
}
|
|
@@ -338,6 +353,7 @@ THREE.XLoader = ( function () {
|
|
|
find = line.indexOf( '#', readed );
|
|
|
|
|
|
}
|
|
|
+
|
|
|
if ( find > - 1 && find < 2 ) {
|
|
|
|
|
|
var foundNewLine = - 1;
|
|
@@ -368,6 +384,7 @@ THREE.XLoader = ( function () {
|
|
|
}
|
|
|
|
|
|
}
|
|
|
+
|
|
|
return line.substr( readed );
|
|
|
|
|
|
}
|
|
@@ -384,6 +401,7 @@ THREE.XLoader = ( function () {
|
|
|
return true;
|
|
|
|
|
|
}
|
|
|
+
|
|
|
var fileLength = reader.byteLength;
|
|
|
for ( var index = 0; index < fileLength; index ++ ) {
|
|
|
|
|
@@ -394,6 +412,7 @@ THREE.XLoader = ( function () {
|
|
|
}
|
|
|
|
|
|
}
|
|
|
+
|
|
|
return false;
|
|
|
|
|
|
}
|
|
@@ -409,6 +428,7 @@ THREE.XLoader = ( function () {
|
|
|
array_buffer[ i ] = buf.charCodeAt( i ) & 0xff;
|
|
|
|
|
|
}
|
|
|
+
|
|
|
return array_buffer.buffer || array_buffer;
|
|
|
|
|
|
} else {
|
|
@@ -515,6 +535,7 @@ THREE.XLoader = ( function () {
|
|
|
_currentObject.type = "";
|
|
|
|
|
|
}
|
|
|
+
|
|
|
if ( _currentObject.type === "Animation" ) {
|
|
|
|
|
|
_currentObject.data = this._data.substr( findNext, findEnd - findNext ).trim();
|
|
@@ -540,6 +561,7 @@ THREE.XLoader = ( function () {
|
|
|
}
|
|
|
|
|
|
}
|
|
|
+
|
|
|
_currentObject.parent = _parent;
|
|
|
if ( _currentObject.type != "template" ) {
|
|
|
|
|
@@ -555,6 +577,7 @@ THREE.XLoader = ( function () {
|
|
|
}
|
|
|
|
|
|
}
|
|
|
+
|
|
|
return {
|
|
|
parent: _parent,
|
|
|
end: endRead
|
|
@@ -664,6 +687,7 @@ THREE.XLoader = ( function () {
|
|
|
this._currentAnime.AnimeFrames.push( this._currentAnimeFrames );
|
|
|
|
|
|
}
|
|
|
+
|
|
|
this._currentAnimeFrames = new XAnimationInfo();
|
|
|
this._currentAnimeFrames.boneName = this._currentObject.data.trim();
|
|
|
break;
|
|
@@ -673,9 +697,11 @@ THREE.XLoader = ( function () {
|
|
|
break;
|
|
|
|
|
|
}
|
|
|
+
|
|
|
this._currentObject.worked = true;
|
|
|
|
|
|
}
|
|
|
+
|
|
|
if ( this._currentObject.children.length > 0 ) {
|
|
|
|
|
|
this._currentObject = this._currentObject.children.shift();
|
|
@@ -684,6 +710,7 @@ THREE.XLoader = ( function () {
|
|
|
console.log( 'processing ' + this._currentObject.name );
|
|
|
|
|
|
}
|
|
|
+
|
|
|
if ( breakFlag ) break;
|
|
|
|
|
|
} else {
|
|
@@ -697,6 +724,7 @@ THREE.XLoader = ( function () {
|
|
|
}
|
|
|
|
|
|
}
|
|
|
+
|
|
|
if ( this._currentObject.parent ) {
|
|
|
|
|
|
this._currentObject = this._currentObject.parent;
|
|
@@ -706,11 +734,13 @@ THREE.XLoader = ( function () {
|
|
|
breakFlag = true;
|
|
|
|
|
|
}
|
|
|
+
|
|
|
if ( breakFlag ) break;
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
+
|
|
|
return;
|
|
|
|
|
|
}
|
|
@@ -723,6 +753,7 @@ THREE.XLoader = ( function () {
|
|
|
this._makeOutputGeometry();
|
|
|
|
|
|
}
|
|
|
+
|
|
|
this._currentGeo = {};
|
|
|
if ( this._currentAnime != null && this._currentAnime.name ) {
|
|
|
|
|
@@ -732,9 +763,11 @@ THREE.XLoader = ( function () {
|
|
|
this._currentAnimeFrames = null;
|
|
|
|
|
|
}
|
|
|
+
|
|
|
this._makeOutputAnimation();
|
|
|
|
|
|
}
|
|
|
+
|
|
|
this._currentAnime = {};
|
|
|
|
|
|
}
|
|
@@ -774,6 +807,7 @@ THREE.XLoader = ( function () {
|
|
|
this._currentFrame.parentName = this._currentObject.parent.name;
|
|
|
|
|
|
}
|
|
|
+
|
|
|
this.frameHierarchie.push( this._nowFrameName );
|
|
|
this.HieStack[ this._nowFrameName ] = this._currentFrame;
|
|
|
|
|
@@ -797,6 +831,7 @@ THREE.XLoader = ( function () {
|
|
|
return;
|
|
|
|
|
|
}
|
|
|
+
|
|
|
var b = new THREE.Bone();
|
|
|
b.name = this._currentFrame.name;
|
|
|
b.applyMatrix4( this._currentFrame.FrameTransformMatrix );
|
|
@@ -854,6 +889,7 @@ THREE.XLoader = ( function () {
|
|
|
break;
|
|
|
|
|
|
}
|
|
|
+
|
|
|
if ( find === 0 || find > maxLength ) {
|
|
|
|
|
|
find = maxLength;
|
|
@@ -861,6 +897,7 @@ THREE.XLoader = ( function () {
|
|
|
changeMode = true;
|
|
|
|
|
|
}
|
|
|
+
|
|
|
switch ( this._currentObject.type ) {
|
|
|
|
|
|
case "Mesh":
|
|
@@ -874,6 +911,7 @@ THREE.XLoader = ( function () {
|
|
|
break;
|
|
|
|
|
|
}
|
|
|
+
|
|
|
break;
|
|
|
case "MeshNormals":
|
|
|
switch ( mode ) {
|
|
@@ -883,9 +921,11 @@ THREE.XLoader = ( function () {
|
|
|
break;
|
|
|
|
|
|
}
|
|
|
+
|
|
|
break;
|
|
|
|
|
|
}
|
|
|
+
|
|
|
endRead = find + 1;
|
|
|
if ( changeMode ) {
|
|
|
|
|
@@ -894,6 +934,7 @@ THREE.XLoader = ( function () {
|
|
|
}
|
|
|
|
|
|
}
|
|
|
+
|
|
|
if ( endRead >= this._currentObject.data.length ) {
|
|
|
|
|
|
break;
|
|
@@ -1053,6 +1094,7 @@ THREE.XLoader = ( function () {
|
|
|
mode_local = 0;
|
|
|
|
|
|
}
|
|
|
+
|
|
|
var line = this._currentObject.data.substr( endRead, find - endRead );
|
|
|
var data = this._readLine( line.trim() ).split( ";" );
|
|
|
if ( this.IsUvYReverse ) {
|
|
@@ -1064,12 +1106,15 @@ THREE.XLoader = ( function () {
|
|
|
this._currentGeo.GeometryData.uvs.push( parseFloat( data[ 0 ] ), parseFloat( data[ 1 ] ) );
|
|
|
|
|
|
}
|
|
|
+
|
|
|
endRead = find + 1;
|
|
|
|
|
|
}
|
|
|
+
|
|
|
break;
|
|
|
|
|
|
}
|
|
|
+
|
|
|
if ( endRead >= this._currentObject.data.length ) {
|
|
|
|
|
|
break;
|
|
@@ -1104,6 +1149,7 @@ THREE.XLoader = ( function () {
|
|
|
mode_local = 0;
|
|
|
|
|
|
}
|
|
|
+
|
|
|
var line = this._currentObject.data.substr( endRead, find - endRead );
|
|
|
var data = this._readLine( line.trim() ).split( "," );
|
|
|
for ( var i = 0; i < data.length; i ++ ) {
|
|
@@ -1111,9 +1157,11 @@ THREE.XLoader = ( function () {
|
|
|
this._currentGeo.GeometryData.materialIndices[ i ] = parseInt( data[ i ] );
|
|
|
|
|
|
}
|
|
|
+
|
|
|
endRead = this._currentObject.data.length;
|
|
|
|
|
|
}
|
|
|
+
|
|
|
if ( endRead >= this._currentObject.data.length || mode >= 3 ) {
|
|
|
|
|
|
break;
|
|
@@ -1157,6 +1205,7 @@ THREE.XLoader = ( function () {
|
|
|
find = this._currentObject.data.length;
|
|
|
|
|
|
}
|
|
|
+
|
|
|
line = this._currentObject.data.substr( endRead, find - endRead );
|
|
|
var data3 = this._readLine( line.trim() ).split( ";" );
|
|
|
_nowMat.emissive.r = parseFloat( data3[ 0 ] );
|
|
@@ -1173,6 +1222,7 @@ THREE.XLoader = ( function () {
|
|
|
console.log( 'processing ' + localObject.name );
|
|
|
|
|
|
}
|
|
|
+
|
|
|
var fileName = localObject.data.substr( 1, localObject.data.length - 2 );
|
|
|
switch ( localObject.type ) {
|
|
|
|
|
@@ -1203,6 +1253,7 @@ THREE.XLoader = ( function () {
|
|
|
}
|
|
|
|
|
|
}
|
|
|
+
|
|
|
this._currentGeo.Materials.push( _nowMat );
|
|
|
|
|
|
}
|
|
@@ -1227,6 +1278,7 @@ THREE.XLoader = ( function () {
|
|
|
boneInf.Indeces.push( parseInt( data[ i ] ) );
|
|
|
|
|
|
}
|
|
|
+
|
|
|
endRead = find + 1;
|
|
|
find = this._currentObject.data.indexOf( ';', endRead );
|
|
|
line = this._currentObject.data.substr( endRead, find - endRead );
|
|
@@ -1236,6 +1288,7 @@ THREE.XLoader = ( function () {
|
|
|
boneInf.Weights.push( parseFloat( data2[ _i ] ) );
|
|
|
|
|
|
}
|
|
|
+
|
|
|
endRead = find + 1;
|
|
|
find = this._currentObject.data.indexOf( ';', endRead );
|
|
|
if ( find <= 0 ) {
|
|
@@ -1243,6 +1296,7 @@ THREE.XLoader = ( function () {
|
|
|
find = this._currentObject.data.length;
|
|
|
|
|
|
}
|
|
|
+
|
|
|
line = this._currentObject.data.substr( endRead, find - endRead );
|
|
|
var data3 = this._readLine( line.trim() ).split( "," );
|
|
|
boneInf.OffsetMatrix = new THREE.Matrix4();
|
|
@@ -1283,6 +1337,7 @@ THREE.XLoader = ( function () {
|
|
|
}
|
|
|
|
|
|
}
|
|
|
+
|
|
|
_bones.push( b );
|
|
|
|
|
|
}
|
|
@@ -1314,6 +1369,7 @@ THREE.XLoader = ( function () {
|
|
|
}
|
|
|
|
|
|
}
|
|
|
+
|
|
|
for ( var vi = 0; vi < this._currentGeo.BoneInfs[ bi ].Indeces.length; vi ++ ) {
|
|
|
|
|
|
var nowVertexID = this._currentGeo.BoneInfs[ bi ].Indeces[ vi ];
|
|
@@ -1341,6 +1397,7 @@ THREE.XLoader = ( function () {
|
|
|
break;
|
|
|
|
|
|
}
|
|
|
+
|
|
|
this._currentGeo.VertexSetedBoneCount[ nowVertexID ] ++;
|
|
|
if ( this._currentGeo.VertexSetedBoneCount[ nowVertexID ] > 4 ) {
|
|
|
|
|
@@ -1351,11 +1408,13 @@ THREE.XLoader = ( function () {
|
|
|
}
|
|
|
|
|
|
}
|
|
|
+
|
|
|
for ( var sk = 0; sk < this._currentGeo.Materials.length; sk ++ ) {
|
|
|
|
|
|
this._currentGeo.Materials[ sk ].skinning = true;
|
|
|
|
|
|
}
|
|
|
+
|
|
|
var offsetList = [];
|
|
|
for ( var _bi = 0; _bi < putBones.length; _bi ++ ) {
|
|
|
|
|
@@ -1382,6 +1441,7 @@ THREE.XLoader = ( function () {
|
|
|
mesh = new THREE.Mesh( _bufferGeometry, this._currentGeo.Materials.length === 1 ? this._currentGeo.Materials[ 0 ] : this._currentGeo.Materials );
|
|
|
|
|
|
}
|
|
|
+
|
|
|
mesh.name = this._currentGeo.name;
|
|
|
var worldBaseMx = new THREE.Matrix4();
|
|
|
var currentMxFrame = this._currentGeo.baseFrame.putBone;
|
|
@@ -1401,9 +1461,11 @@ THREE.XLoader = ( function () {
|
|
|
}
|
|
|
|
|
|
}
|
|
|
+
|
|
|
mesh.applyMatrix4( worldBaseMx );
|
|
|
|
|
|
}
|
|
|
+
|
|
|
this.Meshes.push( mesh );
|
|
|
|
|
|
}
|
|
@@ -1486,6 +1548,7 @@ THREE.XLoader = ( function () {
|
|
|
}
|
|
|
|
|
|
}
|
|
|
+
|
|
|
var frameValue = data2[ 2 ].split( "," );
|
|
|
switch ( nowKeyType ) {
|
|
|
|
|
@@ -1500,6 +1563,7 @@ THREE.XLoader = ( function () {
|
|
|
break;
|
|
|
|
|
|
}
|
|
|
+
|
|
|
if ( ! frameFound ) {
|
|
|
|
|
|
this._currentAnimeFrames.keyFrames.push( keyInfo );
|
|
@@ -1539,16 +1603,19 @@ THREE.XLoader = ( function () {
|
|
|
model = this.Meshes[ 0 ];
|
|
|
|
|
|
}
|
|
|
+
|
|
|
if ( ! animation ) {
|
|
|
|
|
|
animation = this.animations[ 0 ];
|
|
|
|
|
|
}
|
|
|
+
|
|
|
if ( ! model || ! animation ) {
|
|
|
|
|
|
return null;
|
|
|
|
|
|
}
|
|
|
+
|
|
|
var put = {};
|
|
|
put.fps = animation.fps;
|
|
|
put.name = animation.name;
|
|
@@ -1578,12 +1645,14 @@ THREE.XLoader = ( function () {
|
|
|
}
|
|
|
|
|
|
}
|
|
|
+
|
|
|
put.hierarchy.push( c_key );
|
|
|
break;
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
+
|
|
|
if ( ! findAnimation ) {
|
|
|
|
|
|
var _c_key = animation.hierarchy[ 0 ].copy();
|
|
@@ -1596,11 +1665,13 @@ THREE.XLoader = ( function () {
|
|
|
_c_key.keys[ k ].pos.set( 0, 0, 0 );
|
|
|
|
|
|
}
|
|
|
+
|
|
|
if ( _c_key.keys[ k ].scl ) {
|
|
|
|
|
|
_c_key.keys[ k ].scl.set( 1, 1, 1 );
|
|
|
|
|
|
}
|
|
|
+
|
|
|
if ( _c_key.keys[ k ].rot ) {
|
|
|
|
|
|
_c_key.keys[ k ].rot.set( 0, 0, 0, 1 );
|
|
@@ -1608,11 +1679,13 @@ THREE.XLoader = ( function () {
|
|
|
}
|
|
|
|
|
|
}
|
|
|
+
|
|
|
put.hierarchy.push( _c_key );
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
+
|
|
|
if ( ! model.geometry.animations ) {
|
|
|
|
|
|
model.geometry.animations = [];
|