loadCamera method

dynamic loadCamera(
  1. dynamic cameraIndex
)

Specification: https://github.com/KhronosGroup/glTF/tree/master/specification/2.0#cameras @param {number} cameraIndex @return {Promise<THREE.Camera>}

Implementation

loadCamera(cameraIndex) {
  var camera;
  Map<String, dynamic> cameraDef = this.json["cameras"][cameraIndex];
  var params = cameraDef[cameraDef["type"]];

  if (params == null) {
    print('THREE.GLTFLoader: Missing camera parameters.');
    return;
  }

  if (cameraDef["type"] == 'perspective') {
    camera = new PerspectiveCamera(
        MathUtils.radToDeg(params["yfov"]),
        params["aspectRatio"] ?? 1,
        params["znear"] ?? 1,
        params["zfar"] ?? 2e6);
  } else if (cameraDef["type"] == 'orthographic') {
    camera = new OrthographicCamera(-params["xmag"], params["xmag"],
        params["ymag"], -params["ymag"], params["znear"], params["zfar"]);
  }

  if (cameraDef["name"] != null)
    camera.name = this.createUniqueName(cameraDef["name"]);

  assignExtrasToUserData(camera, cameraDef);

  return camera;
}