parse method

dynamic parse(
  1. dynamic onLoad,
  2. dynamic onError
)

Implementation

parse(onLoad, onError) async {
  var parser = this;
  var json = this.json;
  var extensions = this.extensions;

  // Clear the loader cache
  cache.removeAll();

  // Mark the special nodes/meshes in json for efficient parse
  _invokeAll((ext) {
    return ext._markDefs != null && ext._markDefs() != null;
  });

  final scenes = await getDependencies('scene');
  final animations = await getDependencies('animation');
  final cameras = await getDependencies('camera');

  var result = {
    "scene": scenes[json["scene"] ?? 0],
    "scenes": scenes,
    "animations": animations,
    "cameras": cameras,
    "asset": json["asset"],
    "parser": parser,
    "userData": {}
  };

  addUnknownExtensionsToUserData(extensions, result, json);

  assignExtrasToUserData(result, json);

  onLoad(result);
}