update sensor control when changed
This commit is contained in:
parent
21130bad54
commit
71c60bfd23
1 changed files with 32 additions and 21 deletions
|
|
@ -207,6 +207,34 @@ class _PanoramaState extends State<Panorama> with SingleTickerProviderStateMixin
|
||||||
scene.update();
|
scene.update();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void _updateSensorControl() {
|
||||||
|
_orientationSubscription?.cancel();
|
||||||
|
switch (widget.sensorControl) {
|
||||||
|
case SensorControl.Orientation:
|
||||||
|
motionSensors.orientationUpdateInterval = Duration.microsecondsPerSecond ~/ 60;
|
||||||
|
_orientationSubscription = motionSensors.orientation.listen((OrientationEvent event) {
|
||||||
|
orientation.setFrom(Vector3(event.yaw, event.pitch, event.roll));
|
||||||
|
_updateView();
|
||||||
|
});
|
||||||
|
break;
|
||||||
|
case SensorControl.AbsoluteOrientation:
|
||||||
|
motionSensors.absoluteOrientationUpdateInterval = Duration.microsecondsPerSecond ~/ 60;
|
||||||
|
_orientationSubscription = motionSensors.absoluteOrientation.listen((AbsoluteOrientationEvent event) {
|
||||||
|
orientation.setFrom(Vector3(event.yaw, event.pitch, event.roll));
|
||||||
|
_updateView();
|
||||||
|
});
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
}
|
||||||
|
|
||||||
|
_screenOrientSubscription?.cancel();
|
||||||
|
if (widget.sensorControl != SensorControl.None) {
|
||||||
|
_screenOrientSubscription = motionSensors.screenOrientation.listen((ScreenOrientationEvent event) {
|
||||||
|
screenOrientation = radians(event.angle);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void _onSceneCreated(Scene scene) {
|
void _onSceneCreated(Scene scene) {
|
||||||
this.scene = scene;
|
this.scene = scene;
|
||||||
if (widget.child != null) {
|
if (widget.child != null) {
|
||||||
|
|
@ -230,27 +258,7 @@ class _PanoramaState extends State<Panorama> with SingleTickerProviderStateMixin
|
||||||
latitude = degrees(widget.latitude);
|
latitude = degrees(widget.latitude);
|
||||||
longitude = degrees(widget.longitude);
|
longitude = degrees(widget.longitude);
|
||||||
|
|
||||||
switch (widget.sensorControl) {
|
_updateSensorControl();
|
||||||
case SensorControl.Orientation:
|
|
||||||
motionSensors.orientationUpdateInterval = Duration.microsecondsPerSecond ~/ 60;
|
|
||||||
_orientationSubscription = motionSensors.orientation.listen((OrientationEvent event) {
|
|
||||||
orientation.setFrom(Vector3(event.yaw, event.pitch, event.roll));
|
|
||||||
_updateView();
|
|
||||||
});
|
|
||||||
break;
|
|
||||||
case SensorControl.AbsoluteOrientation:
|
|
||||||
motionSensors.absoluteOrientationUpdateInterval = Duration.microsecondsPerSecond ~/ 60;
|
|
||||||
_orientationSubscription = motionSensors.absoluteOrientation.listen((AbsoluteOrientationEvent event) {
|
|
||||||
orientation.setFrom(Vector3(event.yaw, event.pitch, event.roll));
|
|
||||||
_updateView();
|
|
||||||
});
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
}
|
|
||||||
|
|
||||||
motionSensors.screenOrientation.listen((ScreenOrientationEvent event) {
|
|
||||||
screenOrientation = radians(event.angle);
|
|
||||||
});
|
|
||||||
|
|
||||||
_controller = AnimationController(duration: Duration(milliseconds: 60000), vsync: this)..addListener(_updateView);
|
_controller = AnimationController(duration: Duration(milliseconds: 60000), vsync: this)..addListener(_updateView);
|
||||||
if (widget.sensorControl == SensorControl.None && widget.animSpeed != 0) _controller.repeat();
|
if (widget.sensorControl == SensorControl.None && widget.animSpeed != 0) _controller.repeat();
|
||||||
|
|
@ -279,6 +287,9 @@ class _PanoramaState extends State<Panorama> with SingleTickerProviderStateMixin
|
||||||
scene.updateTexture();
|
scene.updateTexture();
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
if (widget.sensorControl != oldWidget.sensorControl) {
|
||||||
|
_updateSensorControl();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@override
|
@override
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue