|
@@ -9,6 +9,17 @@ import {
|
|
|
VectorKeyframeTrack
|
|
VectorKeyframeTrack
|
|
|
} from 'three';
|
|
} from 'three';
|
|
|
|
|
|
|
|
|
|
+function getBoneName( bone, options ) {
|
|
|
|
|
+
|
|
|
|
|
+ if ( options.getBoneName !== undefined ) {
|
|
|
|
|
+
|
|
|
|
|
+ return options.getBoneName( bone );
|
|
|
|
|
+
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ return options.names[ bone.name ];
|
|
|
|
|
+
|
|
|
|
|
+}
|
|
|
|
|
|
|
|
function retarget( target, source, options = {} ) {
|
|
function retarget( target, source, options = {} ) {
|
|
|
|
|
|
|
@@ -77,7 +88,7 @@ function retarget( target, source, options = {} ) {
|
|
|
for ( let i = 0; i < bones.length; ++ i ) {
|
|
for ( let i = 0; i < bones.length; ++ i ) {
|
|
|
|
|
|
|
|
bone = bones[ i ];
|
|
bone = bones[ i ];
|
|
|
- name = options.names[ bone.name ];
|
|
|
|
|
|
|
+ name = getBoneName( bone, options );
|
|
|
|
|
|
|
|
boneTo = getBoneByName( name, sourceBones );
|
|
boneTo = getBoneByName( name, sourceBones );
|
|
|
|
|
|
|
@@ -161,7 +172,7 @@ function retarget( target, source, options = {} ) {
|
|
|
for ( let i = 0; i < bones.length; ++ i ) {
|
|
for ( let i = 0; i < bones.length; ++ i ) {
|
|
|
|
|
|
|
|
bone = bones[ i ];
|
|
bone = bones[ i ];
|
|
|
- name = options.names[ bone.name ] || bone.name;
|
|
|
|
|
|
|
+ name = getBoneName( bone, options ) || bone.name;
|
|
|
|
|
|
|
|
if ( name !== options.hip ) {
|
|
if ( name !== options.hip ) {
|
|
|
|
|
|
|
@@ -203,6 +214,7 @@ function retargetClip( target, source, clip, options = {} ) {
|
|
|
mixer = new AnimationMixer( source ),
|
|
mixer = new AnimationMixer( source ),
|
|
|
bones = getBones( target.skeleton ),
|
|
bones = getBones( target.skeleton ),
|
|
|
boneDatas = [];
|
|
boneDatas = [];
|
|
|
|
|
+
|
|
|
let positionOffset,
|
|
let positionOffset,
|
|
|
bone, boneTo, boneData,
|
|
bone, boneTo, boneData,
|
|
|
name;
|
|
name;
|
|
@@ -220,13 +232,12 @@ function retargetClip( target, source, clip, options = {} ) {
|
|
|
|
|
|
|
|
for ( let j = 0; j < bones.length; ++ j ) {
|
|
for ( let j = 0; j < bones.length; ++ j ) {
|
|
|
|
|
|
|
|
- name = options.names[ bones[ j ].name ] || bones[ j ].name;
|
|
|
|
|
-
|
|
|
|
|
|
|
+ bone = bones[ j ];
|
|
|
|
|
+ name = getBoneName( bone, options ) || bone.name;
|
|
|
boneTo = getBoneByName( name, source.skeleton );
|
|
boneTo = getBoneByName( name, source.skeleton );
|
|
|
|
|
|
|
|
if ( boneTo ) {
|
|
if ( boneTo ) {
|
|
|
|
|
|
|
|
- bone = bones[ j ];
|
|
|
|
|
boneData = boneDatas[ j ] = boneDatas[ j ] || { bone: bone };
|
|
boneData = boneDatas[ j ] = boneDatas[ j ] || { bone: bone };
|
|
|
|
|
|
|
|
if ( options.hip === name ) {
|
|
if ( options.hip === name ) {
|