parseScene method
dynamic
parseScene(
- dynamic deformers,
- dynamic geometryMap,
- dynamic materialMap
Implementation
parseScene(deformers, geometryMap, materialMap) {
sceneGraph = Group();
Map modelMap = parseModels(deformers["skeletons"], geometryMap, materialMap);
var modelNodes = fbxTree.objects["Model"];
var scope = this;
modelMap.forEach((key, model) {
var modelNode = modelNodes[model.id];
scope.setLookAtProperties(model, modelNode);
var parentConnections = connections[model.id]["parents"];
parentConnections.forEach((connection) {
var parent = modelMap[connection["ID"]];
if (parent != null) parent.add(model);
});
if (model.parent == null) {
sceneGraph.add(model);
}
});
bindSkeleton(deformers["skeletons"], geometryMap, modelMap);
createAmbientLight();
sceneGraph.traverse((node) {
if (node.userData["transformData"] != null) {
if (node.parent != null) {
node.userData["transformData"]["parentMatrix"] = node.parent.matrix;
node.userData["transformData"]["parentMatrixWorld"] = node.parent.matrixWorld;
}
var transform = generateTransform(node.userData["transformData"]);
node.applyMatrix4(transform);
node.updateWorldMatrix(false, false);
}
});
var animations = AnimationParser().parse();
// if all the models where already combined in a single group, just return that
if (sceneGraph.children.length == 1 && sceneGraph.children[0] is Group) {
sceneGraph.children[0].animations = animations;
sceneGraph = sceneGraph.children[0];
}
sceneGraph.animations = animations;
}