public setFrame()

in src/render/RenderCamera.ts [186:310]


    public setFrame(frame: AnimationFrame): void {
        const state = frame.state;

        if (state.state !== this._state) {
            this._state = state.state;
            if (this._state !== State.Custom) {
                this.setRenderMode(this._renderMode);
                this.setSize(this._size);
            }
            if (this._state === State.Earth) {
                const y = this._fovToY(this._perspective.fov, this._zoom);
                this._stateTransitionFov = this._yToFov(y, 0);
            }

            this._changed = true;
        }

        const currentImageId = state.currentImage.id;
        const previousImageId = !!state.previousImage ? state.previousImage.id : null;

        if (currentImageId !== this._currentImageId || this._changed) {
            this._currentImageId = currentImageId;
            this._currentSpherical = isSpherical(state.currentTransform.cameraType);
            this._currentProjectedPoints = this._computeProjectedPoints(state.currentTransform);
            this._currentCameraUp.copy(state.currentCamera.up);
            this._currentTransformUp.copy(state.currentTransform.upVector());
            this._currentTransformForward.copy(
                new Vector3().fromArray(
                    state.currentTransform.unprojectSfM([0, 0], 10))
                    .sub(
                        new Vector3().fromArray(
                            state.currentTransform.
                                unprojectSfM([0, 0], 0))));

            this._changed = true;
        }

        if (previousImageId !== this._previousImageId) {
            this._previousImageId = previousImageId;
            this._previousSpherical =
                isSpherical(state.previousTransform.cameraType);
            this._previousProjectedPoints = this._computeProjectedPoints(state.previousTransform);
            this._previousCameraUp.copy(state.previousCamera.up);
            this._previousTransformUp.copy(state.previousTransform.upVector());
            this._previousTransformForward.copy(
                new Vector3().fromArray(
                    state.previousTransform.unprojectSfM([0, 0], 10))
                    .sub(
                        new Vector3().fromArray(
                            state.previousTransform.
                                unprojectSfM([0, 0], 0))));

            this._changed = true;
        }

        const zoom = state.zoom;
        if (zoom !== this._zoom) {
            this._changed = true;
        }

        const camera = state.camera;

        if (this._changed) {
            this._currentFov = this._computeCurrentFov(zoom);
            this._previousFov = this._computePreviousFov(zoom);
        }

        const alpha = state.alpha;
        const sta = state.stateTransitionAlpha;
        if (this._changed ||
            alpha !== this._alpha ||
            sta !== this._stateTransitionAlpha) {

            this._alpha = alpha;
            this._stateTransitionAlpha = sta;

            switch (this._state) {
                case State.Earth: {
                    const startFov = this._stateTransitionFov;
                    const endFov = this._focalToFov(state.camera.focal);
                    const fov = MathUtils.lerp(startFov, endFov, sta);
                    const y = this._fovToY(fov, 0);
                    this._perspective.fov = this._yToFov(y, zoom);
                    break;
                }
                case State.Custom:
                    break;
                default:
                    this._perspective.fov =
                        this._interpolateFov(
                            this._currentFov,
                            this._previousFov,
                            this._alpha);
                    this._changed = true;
                    break;
            }

            this._zoom = zoom;

            if (this._state !== State.Custom) {
                this._perspective.updateProjectionMatrix();
            }
        }

        if (this._camera.diff(camera) > 1e-9) {
            this._camera.copy(camera);

            this._rotation = this._computeRotation(camera);

            this._perspective.up.copy(camera.up);
            this._perspective.position.copy(camera.position);

            // Workaround for shaking camera
            this._perspective.matrixAutoUpdate = true;
            this._perspective.lookAt(camera.lookat);
            this._perspective.matrixAutoUpdate = false;

            this._perspective.updateMatrix();
            this._perspective.updateMatrixWorld(false);

            this._changed = true;
        }

        this._setFrameId(frame.id);
    }