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... ";
  }
}