parseScene method

dynamic parseScene(
  1. dynamic deformers,
  2. dynamic geometryMap,
  3. dynamic materialMap
)

Implementation

parseScene( deformers, geometryMap, materialMap ) {

	sceneGraph = new Group();

	Map modelMap = this.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 );

		}


	} );

	this.bindSkeleton( deformers["skeletons"], geometryMap, modelMap );

	this.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 = new 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;

}