-
Notifications
You must be signed in to change notification settings - Fork 267
/
Copy pathdebugoptionsexample.dart
117 lines (110 loc) · 3.92 KB
/
debugoptionsexample.dart
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
import 'package:ar_flutter_plugin/managers/ar_location_manager.dart';
import 'package:ar_flutter_plugin/managers/ar_session_manager.dart';
import 'package:ar_flutter_plugin/managers/ar_object_manager.dart';
import 'package:ar_flutter_plugin/managers/ar_anchor_manager.dart';
import 'package:flutter/material.dart';
import 'package:ar_flutter_plugin/ar_flutter_plugin.dart';
import 'package:ar_flutter_plugin/datatypes/config_planedetection.dart';
class DebugOptionsWidget extends StatefulWidget {
DebugOptionsWidget({Key? key}) : super(key: key);
@override
_DebugOptionsWidgetState createState() => _DebugOptionsWidgetState();
}
class _DebugOptionsWidgetState extends State<DebugOptionsWidget> {
ARSessionManager? arSessionManager;
ARObjectManager? arObjectManager;
bool _showFeaturePoints = false;
bool _showPlanes = false;
bool _showWorldOrigin = false;
bool _showAnimatedGuide = true;
String _planeTexturePath = "Images/triangle.png";
bool _handleTaps = false;
@override
void dispose() {
super.dispose();
arSessionManager!.dispose();
}
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
title: const Text('Debug Options'),
),
body: Container(
child: Stack(children: [
ARView(
onARViewCreated: onARViewCreated,
planeDetectionConfig: PlaneDetectionConfig.horizontalAndVertical,
showPlatformType: true,
),
Align(
alignment: FractionalOffset.bottomRight,
child: Container(
width: MediaQuery.of(context).size.width * 0.5,
color: Color(0xFFFFFFF).withOpacity(0.5),
child: Column(
crossAxisAlignment: CrossAxisAlignment.end,
mainAxisSize: MainAxisSize.min,
children: [
SwitchListTile(
title: const Text('Feature Points'),
value: _showFeaturePoints,
onChanged: (bool value) {
setState(() {
_showFeaturePoints = value;
updateSessionSettings();
});
},
),
SwitchListTile(
title: const Text('Planes'),
value: _showPlanes,
onChanged: (bool value) {
setState(() {
_showPlanes = value;
updateSessionSettings();
});
},
),
SwitchListTile(
title: const Text('World Origin'),
value: _showWorldOrigin,
onChanged: (bool value) {
setState(() {
_showWorldOrigin = value;
updateSessionSettings();
});
},
),
],
),
),
),
])));
}
void onARViewCreated(
ARSessionManager arSessionManager,
ARObjectManager arObjectManager,
ARAnchorManager arAnchorManager,
ARLocationManager arLocationManager) {
this.arSessionManager = arSessionManager;
this.arObjectManager = arObjectManager;
this.arSessionManager!.onInitialize(
showFeaturePoints: _showFeaturePoints,
showPlanes: _showPlanes,
customPlaneTexturePath: _planeTexturePath,
showWorldOrigin: _showWorldOrigin,
showAnimatedGuide: _showAnimatedGuide,
handleTaps: _handleTaps,
);
this.arObjectManager!.onInitialize();
}
void updateSessionSettings() {
this.arSessionManager!.onInitialize(
showFeaturePoints: _showFeaturePoints,
showPlanes: _showPlanes,
customPlaneTexturePath: _planeTexturePath,
showWorldOrigin: _showWorldOrigin,
);
}
}