castJSON static method

EventDispatcher castJSON(
  1. Map<String, dynamic> json,
  2. Map<String, dynamic> rootJSON
)

Implementation

static EventDispatcher castJSON(Map<String, dynamic> json, Map<String, dynamic> rootJSON) {
  String? type = json["type"];

  if (type == null) {
    Map<String, dynamic>? object = json["object"];
    if (object != null) {
      type = object["type"];
      json = object;
      print(" object is not null use object as json type: $type ");
    }
  }

  if (type == "Camera") {
    return Camera.fromJSON(json, rootJSON);
  } else if (type == "PerspectiveCamera") {
    return PerspectiveCamera.fromJSON(json, rootJSON);
  } else if (type == "Scene") {
    return Scene.fromJSON(json, rootJSON);
  } else if (type == "PointLight") {
    return PointLight.fromJSON(json, rootJSON);
  } else if (type == "Group") {
    return Group.fromJSON(json, rootJSON);
  } else if (type == "Mesh") {
    return Mesh.fromJSON(json, rootJSON);
  } else if (type == "Line") {
    return Line.fromJSON(json, rootJSON);
  } else if (type == "Points") {
    return Points.fromJSON(json, rootJSON);
  } else if (type == "AmbientLight") {
    return AmbientLight.fromJSON(json, rootJSON);
  } else if (type == "Sprite") {
    return Sprite.fromJSON(json, rootJSON);
  } else if (type == "SpriteMaterial") {
    return SpriteMaterial.fromJSON(json, rootJSON);
  } else if (type == "ShapeGeometry") {
    return ShapeGeometry.fromJSON(json, rootJSON);
  } else {
    throw " type: $type Object3D.castJSON is not support yet... ";
  }
}