buildSkeleton method
dynamic
buildSkeleton(
- dynamic relationships,
- dynamic skeletons,
- dynamic id,
- dynamic name,
Implementation
buildSkeleton(relationships, skeletons, id, name) {
var bone = null;
relationships["parents"].forEach((parent) {
for (var ID in skeletons.keys) {
var skeleton = skeletons[ID];
skeleton["rawBones"].asMap().forEach((i, rawBone) {
if (rawBone["ID"] == parent["ID"]) {
var subBone = bone;
bone = new Bone();
bone.matrixWorld.copy(rawBone["transformLink"]);
// set name and id here - otherwise in cases where "subBone" is created it will not have a name / id
bone.name =
name != null ? PropertyBinding.sanitizeNodeName(name) : '';
bone.id = id;
if (skeleton["bones"].length <= i) {
final boneList =
List<Bone>.filled((i + 1) - skeleton["bones"].length, Bone());
skeleton["bones"].addAll(boneList);
}
skeleton["bones"][i] = bone;
// In cases where a bone is shared between multiple meshes
// duplicate the bone here and and it as a child of the first bone
if (subBone != null) {
bone.add(subBone);
}
}
});
}
});
return bone;
}