parseGeometries method

dynamic parseGeometries(
  1. dynamic json,
  2. dynamic shapes
)

Implementation

parseGeometries(json, shapes) {
  var geometries = {};

  if (json != null) {
    var bufferGeometryLoader = BufferGeometryLoader(null);

    for (var i = 0, l = json.length; i < l; i++) {
      var geometry;
      Map<String, dynamic> data = json[i];

      switch (data["type"]) {
        case 'BufferGeometry':
        case 'InstancedBufferGeometry':
          geometry = bufferGeometryLoader.parse(data);

          break;

        case 'Geometry':
          print(
              'THREE.ObjectLoader: The legacy Geometry type is no longer supported.');

          break;

        default:
          if (data["type"] == "PlaneGeometry") {
            geometry = PlaneGeometry.fromJSON(data);
          } else if (data["type"] == "BoxGeometry") {
            geometry = BoxGeometry.fromJSON(data);
          } else if (data["type"] == "CylinderGeometry") {
            geometry = CylinderGeometry.fromJSON(data);
          } else if (data["type"] == "SphereGeometry") {
            geometry = SphereGeometry.fromJSON(data);
          } else {
            throw ("THREE.ObjectLoader: Unsupported geometry type ${data["type"]}");
          }
      }

      geometry.uuid = data["uuid"];

      if (data["name"] != null) geometry.name = data["name"];
      if (geometry is BufferGeometry && data["userData"] != null) {
        geometry.userData = data["userData"];
      }

      geometries[data["uuid"]] = geometry;
    }
  }

  return geometries;
}