Цезий Флайто сходит с ума в режиме 2d - PullRequest
0 голосов
/ 01 марта 2019

Все отлично работает в режиме 3d, но я переключаюсь в режим 2d, глобус продолжает переходить.Я предполагаю использовать fly to в экземпляре или мне нужно, чтобы вы использовали метод Rectangle.когда я нажимаю 2d, я хочу остаться в его текущем местоположении.Есть идеи?Добавьте больше кода, чтобы, возможно, вы, ребята, выяснили, в чем проблема.

private getCurrentCameraState(){
        if (this.map.scene.mode === 3) {
            return {
                x: this.map.camera.position.x,
                y: this.map.camera.position.y,
                z: this.map.camera.position.z,
                heading: this.map.camera.heading,
                pitch: this.map.camera.pitch,
                roll: this.map.camera.roll
            };
        } else {
            return {
                x: this.map.camera.position.x,
                y: this.map.camera.position.y,
                z: this.map.camera.position.z
            };
        }
    }
private applyCameraState(cameraState: ICameraState) {
        if (
            cameraState && this.map.scene.mode === 2) {
            console.log('2d');
            const destination = new Cesium.Cartesian3(
                cameraState.x,
                cameraState.y,
                cameraState.z
            );
            // this.globeDispatcher.setCameraTransition(true);
            this.map.camera.cancelFlight();
            this.map.camera.flyTo({
                destination: destination,
                complete: () => this.globeDispatcher.setCameraTransition(false)
            });
            
        } else if (cameraState &&
            !isEqual(cameraState, this.getCurrentCameraState()) && this.map.scene.mode === 3) {
                console.log('3d')
                const destination = new Cesium.Cartesian3(
                    cameraState.x,
                    cameraState.y,
                    cameraState.z
                );
                this.globeDispatcher.setCameraTransition(true);
                this.map.camera.cancelFlight();
                this.map.camera.flyTo({
                    destination: destination,
                    orientation: {
                        heading: cameraState.heading,
                        pitch: cameraState.pitch,
                        roll: cameraState.roll
                    },
                    pitchAdjustHeight: this.globeConfig.flyToPitchAdjustHeight, // Point Towards the Earth during flight
                    duration: this.globeConfig.flyToDuration,
                    complete: () => this.globeDispatcher.setCameraTransition(false)
                })
        } else if (cameraState === undefined) {
            console.log('undefined')
            // Initialize camera state if undefined
            this.globeDispatcher.setCesiumCameraState(
                this.getCurrentCameraState()
            );
        }
    }

1 Ответ

0 голосов
/ 04 марта 2019

Вы пытались добавить, чтобы добавить небольшой тайм-аут:

scene.morphComplete.addEventListener(function() {
  setTimeout(function() {
    camera.flyTo({
      destination: Cesium.Cartesian3.fromDegrees(-74.0, 41.0, 15000.0)
    });
  }, 300);
});
...