loadCamera method
dynamic
loadCamera(
- 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 = json["cameras"][cameraIndex];
var params = cameraDef[cameraDef["type"]];
if (params == null) {
print('THREE.GLTFLoader: Missing camera parameters.');
return;
}
if (cameraDef["type"] == 'perspective') {
camera = PerspectiveCamera(
MathUtils.radToDeg(params["yfov"]), params["aspectRatio"] ?? 1, params["znear"] ?? 1, params["zfar"] ?? 2e6);
} else if (cameraDef["type"] == 'orthographic') {
camera = OrthographicCamera(
-params["xmag"], params["xmag"], params["ymag"], -params["ymag"], params["znear"], params["zfar"]);
}
if (cameraDef["name"] != null) camera.name = createUniqueName(cameraDef["name"]);
assignExtrasToUserData(camera, cameraDef);
return camera;
}