update example
This commit is contained in:
parent
f9b664646d
commit
52d70a0e07
2 changed files with 80 additions and 45 deletions
BIN
example/assets/panorama_cropped.jpg
Normal file
BIN
example/assets/panorama_cropped.jpg
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 2.8 MiB |
|
|
@ -32,8 +32,17 @@ class _MyHomePageState extends State<MyHomePage> {
|
||||||
List<Image> panoImages = [
|
List<Image> panoImages = [
|
||||||
Image.asset('assets/panorama.jpg'),
|
Image.asset('assets/panorama.jpg'),
|
||||||
Image.asset('assets/panorama2.webp'),
|
Image.asset('assets/panorama2.webp'),
|
||||||
|
Image.asset('assets/panorama_cropped.webp'),
|
||||||
];
|
];
|
||||||
|
|
||||||
|
void onViewChanged(longitude, latitude, tilt) {
|
||||||
|
setState(() {
|
||||||
|
_lon = longitude;
|
||||||
|
_lat = latitude;
|
||||||
|
_tilt = tilt;
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
Widget hotspotButton({String text, IconData icon, VoidCallback onPressed}) {
|
Widget hotspotButton({String text, IconData icon, VoidCallback onPressed}) {
|
||||||
return Column(
|
return Column(
|
||||||
mainAxisAlignment: MainAxisAlignment.center,
|
mainAxisAlignment: MainAxisAlignment.center,
|
||||||
|
|
@ -57,25 +66,15 @@ class _MyHomePageState extends State<MyHomePage> {
|
||||||
|
|
||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
return Scaffold(
|
Widget panorama;
|
||||||
appBar: AppBar(
|
switch (_panoId % panoImages.length) {
|
||||||
title: Text(widget.title),
|
case 0:
|
||||||
),
|
panorama = Panorama(
|
||||||
body: Stack(
|
|
||||||
children: [
|
|
||||||
Panorama(
|
|
||||||
animSpeed: 1.0,
|
animSpeed: 1.0,
|
||||||
sensorControl: SensorControl.Orientation,
|
sensorControl: SensorControl.Orientation,
|
||||||
onViewChanged: (longitude, latitude, tilt) {
|
onViewChanged: onViewChanged,
|
||||||
setState(() {
|
child: Image.asset('assets/panorama.jpg'),
|
||||||
_lon = longitude;
|
hotspots: [
|
||||||
_lat = latitude;
|
|
||||||
_tilt = tilt;
|
|
||||||
});
|
|
||||||
},
|
|
||||||
child: panoImages[_panoId % panoImages.length],
|
|
||||||
hotspots: _panoId % panoImages.length == 0
|
|
||||||
? [
|
|
||||||
Hotspot(
|
Hotspot(
|
||||||
latitude: -15.0,
|
latitude: -15.0,
|
||||||
longitude: -129.0,
|
longitude: -129.0,
|
||||||
|
|
@ -88,7 +87,7 @@ class _MyHomePageState extends State<MyHomePage> {
|
||||||
longitude: -46.0,
|
longitude: -46.0,
|
||||||
width: 60.0,
|
width: 60.0,
|
||||||
height: 60.0,
|
height: 60.0,
|
||||||
widget: hotspotButton(icon: Icons.search, onPressed: () {}),
|
widget: hotspotButton(icon: Icons.search, onPressed: () => setState(() => _panoId = 2)),
|
||||||
),
|
),
|
||||||
Hotspot(
|
Hotspot(
|
||||||
latitude: -33.0,
|
latitude: -33.0,
|
||||||
|
|
@ -97,8 +96,36 @@ class _MyHomePageState extends State<MyHomePage> {
|
||||||
height: 60.0,
|
height: 60.0,
|
||||||
widget: hotspotButton(icon: Icons.arrow_upward, onPressed: () {}),
|
widget: hotspotButton(icon: Icons.arrow_upward, onPressed: () {}),
|
||||||
),
|
),
|
||||||
]
|
],
|
||||||
: [
|
);
|
||||||
|
break;
|
||||||
|
case 2:
|
||||||
|
panorama = Panorama(
|
||||||
|
animSpeed: 1.0,
|
||||||
|
sensorControl: SensorControl.Orientation,
|
||||||
|
onViewChanged: onViewChanged,
|
||||||
|
croppedArea: Rect.fromLTWH(2533.0, 1265.0, 5065.0, 2533.0),
|
||||||
|
croppedFullWidth: 10132.0,
|
||||||
|
croppedFullHeight: 5066.0,
|
||||||
|
child: Image.asset('assets/panorama_cropped.jpg'),
|
||||||
|
hotspots: [
|
||||||
|
Hotspot(
|
||||||
|
latitude: 0.0,
|
||||||
|
longitude: -46.0,
|
||||||
|
width: 90.0,
|
||||||
|
height: 75.0,
|
||||||
|
widget: hotspotButton(text: "Next scene", icon: Icons.double_arrow, onPressed: () => setState(() => _panoId++)),
|
||||||
|
),
|
||||||
|
],
|
||||||
|
);
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
panorama = Panorama(
|
||||||
|
animSpeed: 1.0,
|
||||||
|
sensorControl: SensorControl.Orientation,
|
||||||
|
onViewChanged: onViewChanged,
|
||||||
|
child: panoImages[_panoId % panoImages.length],
|
||||||
|
hotspots: [
|
||||||
Hotspot(
|
Hotspot(
|
||||||
latitude: 0.0,
|
latitude: 0.0,
|
||||||
longitude: 160.0,
|
longitude: 160.0,
|
||||||
|
|
@ -107,7 +134,15 @@ class _MyHomePageState extends State<MyHomePage> {
|
||||||
widget: hotspotButton(text: "Next scene", icon: Icons.double_arrow, onPressed: () => setState(() => _panoId++)),
|
widget: hotspotButton(text: "Next scene", icon: Icons.double_arrow, onPressed: () => setState(() => _panoId++)),
|
||||||
),
|
),
|
||||||
],
|
],
|
||||||
|
);
|
||||||
|
}
|
||||||
|
return Scaffold(
|
||||||
|
appBar: AppBar(
|
||||||
|
title: Text(widget.title),
|
||||||
),
|
),
|
||||||
|
body: Stack(
|
||||||
|
children: [
|
||||||
|
panorama,
|
||||||
Text('${_lon.toStringAsFixed(3)}, ${_lat.toStringAsFixed(3)}, ${_tilt.toStringAsFixed(3)}'),
|
Text('${_lon.toStringAsFixed(3)}, ${_lat.toStringAsFixed(3)}, ${_tilt.toStringAsFixed(3)}'),
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue