castJson static method
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;
console.warning("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);
// }
else {
throw " type: $type Object3D.castJson is not support yet... ";
}
}