parseDeformers method

Map parseDeformers()

Implementation

Map parseDeformers() {
  Map skeletons = {};
  Map morphTargets = {};

  if (fbxTree.objects["Deformer"] != null) {
    var deformerNodes = fbxTree.objects["Deformer"];

    for (var nodeID in deformerNodes.keys) {
      Map deformerNode = deformerNodes[nodeID];

      var relationships = connections[parseInt(nodeID)];

      if (deformerNode["attrType"] == 'Skin') {
        var skeleton = parseSkeleton(relationships, deformerNodes);
        skeleton["ID"] = nodeID;

        if (relationships["parents"].length > 1) {
          print('THREE.FBXLoader: skeleton attached to more than one geometry is not supported.');
        }
        skeleton["geometryID"] = relationships["parents"][0]["ID"];

        skeletons[nodeID] = skeleton;
      } else if (deformerNode["attrType"] == 'BlendShape') {
        Map<String, dynamic> morphTarget = {
          "id": nodeID,
        };

        morphTarget["rawTargets"] = parseMorphTargets(relationships, deformerNodes);
        morphTarget["id"] = nodeID;

        if (relationships["parents"].length > 1) {
          print('THREE.FBXLoader: morph target attached to more than one geometry is not supported.');
        }

        morphTargets[nodeID] = morphTarget;
      }
    }
  }

  return {
    "skeletons": skeletons,
    "morphTargets": morphTargets,
  };
}