Permalink
Browse files

morph support to legacy

  • Loading branch information...
sunag committed Nov 28, 2017
1 parent 2bb5827 commit 8e31a930df02d7c29c6d512c0d23ad698414643d
Showing with 82 additions and 16 deletions.
  1. +52 −3 Source/Three.JS/SEA3DLegacy.js
  2. +30 −13 Source/Three.JS/SEA3DLoader.js
@@ -13,10 +13,11 @@ Object.assign( THREE.SEA3D.prototype, {
_onHead: THREE.SEA3D.prototype.onHead,
_updateTransform: THREE.SEA3D.prototype.updateTransform,
_readMorph: THREE.SEA3D.prototype.readMorph,
_readVertexAnimation: THREE.SEA3D.prototype.readVertexAnimation,
_readGeometryBuffer: THREE.SEA3D.prototype.readGeometryBuffer,
_readLine: THREE.SEA3D.prototype.readLine,
_getAnimationType: THREE.SEA3D.prototype.getAnimationType,
_getModifier: THREE.SEA3D.prototype.getModifier,
_readAnimation: THREE.SEA3D.prototype.readAnimation
} );
@@ -57,6 +58,20 @@ THREE.SEA3D.prototype.flipVec3 = function ( v ) {
};
THREE.SEA3D.prototype.addVector = function ( v, t ) {
if ( ! v ) return;
for ( var i = 0; i < v.length; i ++ ) {
v[ i ] += t[ i ];
}
return v;
};
THREE.SEA3D.prototype.expandJoints = function ( sea ) {
var numJoints = sea.numVertex * 4;
@@ -397,7 +412,7 @@ THREE.SEA3D.prototype.readAnimation = function ( sea ) {
};
THREE.SEA3D.prototype.getAnimationType = function ( req ) {
THREE.SEA3D.prototype.getModifier = function ( req ) {
var sea = req.sea;
@@ -416,6 +431,7 @@ THREE.SEA3D.prototype.getAnimationType = function ( req ) {
break;
case SEA3D.Animation.prototype.type:
case SEA3D.MorphAnimation.prototype.type:
case SEA3D.UVWAnimation.prototype.type:
if ( req.scope instanceof THREE.Object3D ) {
@@ -430,11 +446,16 @@ THREE.SEA3D.prototype.getAnimationType = function ( req ) {
break;
case SEA3D.Morph.prototype.type:
this.readMorphLegacy( sea, req.geometry );
break;
}
}
return this._getAnimationType( req );
return this._getModifier( req );
};
@@ -654,6 +675,34 @@ THREE.SEA3D.prototype.readSkeletonAnimationLegacy = function () {
}();
THREE.SEA3D.prototype.readMorphLegacy = function ( sea, geo ) {
for ( var i = 0; i < sea.node.length; i ++ ) {
var node = sea.node[ i ];
this.flipVec3( node.vertex );
this.flipVec3( node.normal );
this.addVector( node.vertex, geo.vertex );
this.addVector( node.normal, geo.normal );
}
this._readMorph( sea );
};
THREE.SEA3D.prototype.readMorph = function ( sea ) {
if ( ! this.isLegacy( sea ) ) {
this._readMorph( sea );
}
};
THREE.SEA3D.prototype.readVertexAnimation = function ( sea ) {
if ( this.isLegacy( sea ) ) {
@@ -1797,7 +1797,7 @@ THREE.SEA3D.prototype.addDefaultAnimation = function ( sea, animatorClass ) {
case SEA3D.Animation.prototype.type:
var animation = anm.tag.tag || this.getAnimationType( {
var animation = anm.tag.tag || this.getModifier( {
sea: anm.tag,
scope: scope,
relative: anm.relative
@@ -2016,10 +2016,13 @@ THREE.SEA3D.prototype.readMesh = function ( sea ) {
case SEA3D.Morph.prototype.type:
morpher = mod;
morpher = mod.tag || this.getModifier( {
sea: mod,
geometry: sea.geometry
} );
geo.morphAttributes = morpher.tag.attribs;
geo.morphTargets = morpher.tag.targets;
geo.morphAttributes = morpher.attribs;
geo.morphTargets = morpher.targets;
break;
@@ -2038,7 +2041,7 @@ THREE.SEA3D.prototype.readMesh = function ( sea ) {
skeletonAnimation = anmTag;
geo.animations = skeletonAnimation.tag || this.getAnimationType( {
geo.animations = skeletonAnimation.tag || this.getModifier( {
sea: skeletonAnimation,
skeleton: skeleton,
relative: true
@@ -2058,15 +2061,15 @@ THREE.SEA3D.prototype.readMesh = function ( sea ) {
case SEA3D.UVWAnimation.prototype.type:
uvwAnimationClips = anmTag.tag || this.getAnimationType( {
uvwAnimationClips = anmTag.tag || this.getModifier( {
sea: anmTag
} );
break;
case SEA3D.MorphAnimation.prototype.type:
morphAnimation = anmTag.tag || this.getAnimationType( {
morphAnimation = anmTag.tag || this.getModifier( {
sea: anmTag
} );
@@ -2078,7 +2081,7 @@ THREE.SEA3D.prototype.readMesh = function ( sea ) {
var uMorph = morpher != undefined || vertexAnimation != undefined,
uMorphNormal =
( morpher && morpher.tag.attribs.normal != undefined ) ||
( morpher.attribs.normal != undefined ) ||
( vertexAnimation && vertexAnimation.tag.attribs.normal != undefined );
if ( sea.material ) {
@@ -3041,10 +3044,10 @@ THREE.SEA3D.prototype.readJointObject = function ( sea ) {
};
//
// Morpher
// Morph
//
THREE.SEA3D.prototype.readMorpher = function ( sea ) {
THREE.SEA3D.prototype.readMorph = function ( sea ) {
var attribs = { position: [] }, targets = [];
@@ -3378,10 +3381,10 @@ THREE.SEA3D.prototype.readVertexAnimation = function ( sea ) {
};
//
// Animation Selector
// Selector
//
THREE.SEA3D.prototype.getAnimationType = function ( req ) {
THREE.SEA3D.prototype.getModifier = function ( req ) {
var sea = req.sea;
@@ -3393,6 +3396,20 @@ THREE.SEA3D.prototype.getAnimationType = function ( req ) {
break;
case SEA3D.Animation.prototype.type:
case SEA3D.MorphAnimation.prototype.type:
case SEA3D.UVWAnimation.prototype.type:
this.readAnimation( sea );
break;
case SEA3D.Morph.prototype.type:
this.readMorph( sea, req.geometry );
break;
}
return sea.tag;
@@ -3740,7 +3757,7 @@ THREE.SEA3D.prototype.setTypeRead = function () {
this.file.typeRead[ SEA3D.TextureURL.prototype.type ] = this.readTextureURL;
this.file.typeRead[ SEA3D.CubeMapURL.prototype.type ] = this.readCubeMapURL;
this.file.typeRead[ SEA3D.TextureUpdate.prototype.type ] = this.readTextureUpdate;
this.file.typeRead[ SEA3D.Morph.prototype.type ] = this.readMorpher;
this.file.typeRead[ SEA3D.Morph.prototype.type ] = this.readMorph;
this.file.typeRead[ SEA3D.VertexAnimation.prototype.type ] = this.readVertexAnimation;
this.file.typeRead[ SEA3D.Actions.prototype.type ] = this.readActions;
this.file.typeRead[ SEA3D.FileInfo.prototype.type ] = this.readFileInfo;

0 comments on commit 8e31a93

Please sign in to comment.