loadSkin_new method
Specification: https://github.com/KhronosGroup/glTF/tree/master/specification/2.0#skins @param {number} skinIndex @return {Promise
Implementation
Future loadSkin_new(skinIndex) async {
final skinDef = this.json['skins'][ skinIndex ];
final pending = [];
for (int i = 0, il = skinDef['joints'].length; i < il; i ++ ) {
pending.add( await loadNodeShallow( skinDef['joints'][ i ] ) );
}
if ( skinDef['inverseBindMatrices'] != null ) {
pending.add( await getDependency( 'accessor', skinDef['inverseBindMatrices'] ) );
} else {
pending.add( null );
}
final inverseBindMatrices = pending.removeLast();
final jointNodes = pending;
// Note that bones (joint nodes) may or may not be in the
// scene graph at this time.
final List<Bone> bones = [];
final List<Matrix4> boneInverses = [];
for (int i = 0, il = jointNodes.length; i < il; i ++ ) {
final jointNode = jointNodes[ i ];
if ( jointNode != null) {
bones.add( jointNode );
final mat = Matrix4.identity();
if ( inverseBindMatrices != null ) {
mat.copyFromUnknown( inverseBindMatrices.array, i * 16 );
}
boneInverses.add( mat );
}
else {
console.warning( 'THREE.GLTFLoader: Joint "%s" could not be found. ${skinDef['joints'][ i ]}', );
}
}
return Skeleton( bones, boneInverses );
}