@wemap/positioning 2.0.0 → 2.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (99) hide show
  1. package/.eslintrc.json +4 -2
  2. package/debug/absolute-attitude.html +16 -0
  3. package/debug/arcore.html +16 -0
  4. package/debug/gnss-wifi-pdr.html +16 -0
  5. package/debug/gnss-wifi.html +16 -0
  6. package/debug/imu.html +16 -0
  7. package/debug/inclination.html +16 -0
  8. package/debug/pdr.html +16 -0
  9. package/debug/pose.html +16 -0
  10. package/debug/positioning.html +16 -0
  11. package/debug/relative-attitude.html +16 -0
  12. package/package.json +7 -4
  13. package/src/PositioningHandler.js +96 -34
  14. package/src/components/AbsoluteAttitudeComponent.jsx +104 -0
  15. package/src/components/ArCoreComponent.jsx +74 -0
  16. package/src/components/GnssWifiComponent.jsx +58 -0
  17. package/src/components/GnssWifiPdrComponent.jsx +94 -0
  18. package/src/components/ImuComponent.jsx +100 -0
  19. package/src/components/InclinationComponent.jsx +53 -0
  20. package/src/components/MapComponent.jsx +226 -0
  21. package/src/components/PdrComponent.jsx +97 -0
  22. package/src/components/PoseComponent.jsx +81 -0
  23. package/src/components/PositioningComponent.jsx +26 -0
  24. package/src/components/PositioningInclinationComponent.jsx +76 -0
  25. package/src/components/PositioningPoseComponent.jsx +120 -0
  26. package/src/components/RelativeAttitudeComponent.jsx +82 -0
  27. package/src/components/StartStopComponent.jsx +50 -0
  28. package/src/components/Utils.js +92 -0
  29. package/src/components/index.js +32 -0
  30. package/src/errors/AskImuOnDesktopError.js +9 -0
  31. package/src/errors/GeolocationApiMissingError.js +9 -0
  32. package/src/errors/GeolocationPermissionDeniedError.js +9 -0
  33. package/src/errors/GeolocationPositionUnavailableError.js +9 -0
  34. package/src/errors/IpResolveServerError.js +9 -0
  35. package/src/errors/MissingAccelerometerError.js +11 -0
  36. package/src/errors/MissingArCoreError.js +9 -0
  37. package/src/errors/MissingGyroscopeError.js +11 -0
  38. package/src/errors/MissingMagnetometerError.js +9 -0
  39. package/src/errors/MissingNativeInterfaceError.js +9 -0
  40. package/src/errors/MissingSensorError.js +14 -0
  41. package/src/events/EventType.js +20 -0
  42. package/src/events/ProviderError.js +52 -0
  43. package/src/events/ProviderEvent.js +35 -0
  44. package/src/index.js +2 -2
  45. package/src/providers/Constants.js +5 -0
  46. package/src/providers/FakeAbsolutePositionProvider.js +56 -0
  47. package/src/providers/Provider.js +230 -0
  48. package/src/providers/ProviderOptions.js +28 -0
  49. package/{src.old → src}/providers/ProvidersLogger.js +2 -2
  50. package/src/providers/attitude/AbsoluteAttitudeProvider.js +207 -0
  51. package/src/providers/attitude/RelativeAttitudeProvider.js +129 -0
  52. package/src/providers/others/ImuProvider.js +186 -0
  53. package/src/providers/others/InclinationProvider.js +107 -0
  54. package/{src.old/providers/LocationSource.js → src/providers/others/MapMatchingProvider.js} +5 -148
  55. package/src/providers/pose/ArCoreProvider.js +127 -0
  56. package/src/providers/pose/GnssWifiPdrProvider.js +233 -0
  57. package/src/providers/pose/PoseProvider.js +90 -0
  58. package/{src.old/providers/PdrLocationSource.js → src/providers/pose/pdr/PdrProvider.js} +145 -113
  59. package/{src.old/providers/pdr → src/providers/pose/pdr/helpers}/Smoother.js +1 -1
  60. package/src/providers/position/GnssWifiProvider.js +129 -0
  61. package/src/providers/position/IpProvider.js +75 -0
  62. package/webpack/webpack.common.js +1 -1
  63. package/webpack/webpack.dev.js +1 -1
  64. package/debug/index.html +0 -15
  65. package/debug/index.old.html +0 -37
  66. package/scripts/release-github.js +0 -216
  67. package/src/providers/FakeLocationSource.js +0 -36
  68. package/src.old/Constants.js +0 -11
  69. package/src.old/NavigationHandler.js +0 -244
  70. package/src.old/Pose.js +0 -8
  71. package/src.old/attitude/AttitudeHandler.js +0 -342
  72. package/src.old/components/AbsoluteAttitude.jsx +0 -136
  73. package/src.old/components/Imu.jsx +0 -89
  74. package/src.old/components/LocationSource.jsx +0 -434
  75. package/src.old/components/Logger.jsx +0 -113
  76. package/src.old/components/NavigationDebugApp.jsx +0 -106
  77. package/src.old/components/Others.jsx +0 -121
  78. package/src.old/components/RelativeAttitude.jsx +0 -104
  79. package/src.old/components/Utils.js +0 -35
  80. package/src.old/components/index.js +0 -13
  81. package/src.old/index.js +0 -7
  82. package/src.old/providers/FixedLocationImuLocationSource.js +0 -66
  83. package/src.old/providers/GnssLocationSource.js +0 -118
  84. package/src.old/providers/GnssPdrLocationSource.js +0 -182
  85. package/src.old/providers/IPLocationSource.js +0 -96
  86. package/src.old/sensors/SensorsCompatibility.js +0 -486
  87. package/src.old/sensors/SensorsCompatibility.spec.js +0 -270
  88. package/src.old/sensors/SensorsLogger.js +0 -94
  89. package/src.old/sensors/SensorsLoggerUtils.js +0 -35
  90. /package/{src.old → src/providers}/attitude/EkfAttitude.js +0 -0
  91. /package/{src.old → src/providers}/attitude/EkfAttitude.spec.js +0 -0
  92. /package/{src.old/providers/pdr → src/providers/pose/pdr/helpers}/HeadingUnlocker.js +0 -0
  93. /package/{src.old/providers/pdr → src/providers/pose/pdr/helpers}/HeadingUnlocker.spec.js +0 -0
  94. /package/{src.old/providers/pdr → src/providers/pose/pdr/helpers}/Smoother.spec.js +0 -0
  95. /package/{src.old/providers/pdr → src/providers/pose/pdr/helpers}/ThugDetector.js +0 -0
  96. /package/{src.old/providers → src/providers/pose/pdr}/steps/StepDetection.js +0 -0
  97. /package/{src.old/providers → src/providers/pose/pdr}/steps/StepDetectionLadetto.js +0 -0
  98. /package/{src.old/providers → src/providers/pose/pdr}/steps/StepDetectionMinMaxPeaks.js +0 -0
  99. /package/{src.old/providers → src/providers/pose/pdr}/steps/StepDetectionMinMaxPeaks2.js +0 -0
@@ -0,0 +1,186 @@
1
+ import { deg2rad } from '@wemap/maths';
2
+ import {
3
+ Browser, BrowserUtils
4
+ } from '@wemap/utils';
5
+
6
+ import Provider from '../Provider';
7
+ import EventType from '../../events/EventType';
8
+ import MissingAccelerometerError from '../../errors/MissingAccelerometerError';
9
+ import MissingGyroscopeError from '../../errors/MissingGyroscopeError';
10
+ import AskImuOnDesktopError from '../../errors/AskImuOnDesktopError';
11
+
12
+ /**
13
+ * Imu (Inertial Measurement Unit) provider retrieve acceleration data
14
+ * and/or angular rate data from inertial sensors.
15
+ * opions.require has to be defined in order to work
16
+ *
17
+ * -----------------------------------
18
+ * Overview of compatibilities:
19
+ * -----------------------------------
20
+ *
21
+ * Chrome Android (v72.0.3626): YES (via devicemotion)
22
+ * Safari iOS (v12.0): YES (via devicemotion)
23
+ * Opera Android (v50.2.2426): NO {@link https://developer.mozilla.org/en-US/docs/Web/API/DeviceMotionEvent}
24
+ * Firefox Android (v65.0.1): YES (via devicemotion)
25
+ *
26
+ * -----------------------------------
27
+ */
28
+ class ImuProvider extends Provider {
29
+
30
+ requiredSensors = [];
31
+
32
+ /**
33
+ * Constructor of ImuProvider
34
+ * options.require has to be filled by a list of EventType
35
+ * @example options = {require: [EventType.Acceleration, EventType.AngularRate]};
36
+ * @example options = {require: [EventType.Acceleration]};
37
+ *
38
+ * @param {Function} onEvent @see Provider#constructor
39
+ * @param {Function} onError @see Provider#constructor
40
+ * @param {Object} options @see Provider#constructor
41
+ */
42
+ constructor(onEvent, onError, options) {
43
+ super(onEvent, onError, options);
44
+
45
+ if (!options.hasOwnProperty('require')) {
46
+ throw new Error('options.require is missing in ImuProvider constructor');
47
+ }
48
+
49
+ if (options.require.length === 0) {
50
+ throw new Error('option.require is empty');
51
+ }
52
+
53
+ options.require.forEach(elem => {
54
+ if (!ImuProvider.eventsType.includes(elem)) {
55
+ throw new Error(elem + ' is not recognised in options.require');
56
+ }
57
+ });
58
+
59
+ this.requiredSensors = options.require;
60
+ }
61
+
62
+
63
+ /**
64
+ * @override
65
+ */
66
+ static get displayName() {
67
+ return 'Inertial Measurement Unit';
68
+ }
69
+
70
+ /**
71
+ * @override
72
+ */
73
+ static get eventsType() {
74
+ return [EventType.AngularRate, EventType.Acceleration];
75
+ }
76
+
77
+ /**
78
+ * @override
79
+ */
80
+ static checkAvailabilityErrors() {
81
+
82
+ if (BrowserUtils.isMobile) {
83
+ return [];
84
+ }
85
+
86
+ return [
87
+ ImuProvider.createError(
88
+ EventType.AngularRate,
89
+ new AskImuOnDesktopError()
90
+ ),
91
+ ImuProvider.createError(
92
+ EventType.Acceleration,
93
+ new AskImuOnDesktopError()
94
+ )
95
+ ];
96
+ }
97
+
98
+ /**
99
+ * @override
100
+ */
101
+ startInternal() {
102
+ window.addEventListener('devicemotion', this.parseDeviceMotionEvent, true);
103
+ }
104
+
105
+ /**
106
+ * @override
107
+ */
108
+ stopInternal() {
109
+ window.removeEventListener('devicemotion', this.parseDeviceMotionEvent, true);
110
+ }
111
+
112
+ /**
113
+ * devicemotion callback
114
+ * @param {DeviceMotionEvent} e device motion event
115
+ * @returns {ProviderEvent[]} an array of provider events
116
+ * @private
117
+ */
118
+ parseDeviceMotionEvent = e => {
119
+
120
+ const events = [];
121
+
122
+ const timestamp = e.timeStamp / 1e3;
123
+
124
+ if (this.requiredSensors.includes(EventType.Acceleration)) {
125
+
126
+ let acc;
127
+ if (e.accelerationIncludingGravity) {
128
+ const {
129
+ x, y, z
130
+ } = e.accelerationIncludingGravity;
131
+
132
+ if (x && y && z) {
133
+ acc = [x, y, z];
134
+
135
+ if (BrowserUtils.name === Browser.SAFARI) {
136
+ acc[0] *= -1;
137
+ acc[1] *= -1;
138
+ acc[2] *= -1;
139
+ }
140
+ }
141
+ }
142
+
143
+ if (!acc) {
144
+ super.notifyError(this.createError(
145
+ EventType.AngularRate,
146
+ new MissingAccelerometerError().from('devicemotion'),
147
+ timestamp
148
+ ));
149
+ return;
150
+ }
151
+
152
+ events.push(this.createEvent(EventType.Acceleration, acc, timestamp));
153
+ }
154
+
155
+
156
+ if (this.requiredSensors.includes(EventType.AngularRate)) {
157
+
158
+ let gyr;
159
+ if (e.rotationRate) {
160
+ const {
161
+ alpha, beta, gamma
162
+ } = e.rotationRate;
163
+
164
+ if (alpha && beta && gamma) {
165
+ gyr = [deg2rad(alpha), deg2rad(beta), deg2rad(gamma)];
166
+ }
167
+ }
168
+
169
+ if (!gyr) {
170
+ super.notifyError(this.createError(EventType.AngularRate,
171
+ new MissingGyroscopeError().from('devicemotion'),
172
+ timestamp));
173
+ return;
174
+ }
175
+
176
+ events.push(this.createEvent(EventType.AngularRate, gyr, timestamp));
177
+ }
178
+
179
+ if (events.length !== 0) {
180
+ super.notify(...events);
181
+ }
182
+ }
183
+
184
+ }
185
+
186
+ export default ImuProvider;
@@ -0,0 +1,107 @@
1
+ import Provider from '../Provider';
2
+ import EventType from '../../events/EventType';
3
+ import ImuProvider from './ImuProvider';
4
+ import ProviderError from '../../events/ProviderError';
5
+
6
+ /**
7
+ * Inclination provider gives the inclination of the device using Imu Sensor
8
+ * For example, when the top of the device is pointing the sky, inclination = Math.PI/2
9
+ * when the device is layed on a table, inclination = 0
10
+ * This provider use window.orientation to return a result in function of screen orientation
11
+ */
12
+ class InclinationProvider extends Provider {
13
+
14
+ /**
15
+ * @override
16
+ */
17
+ constructor(onEvent, onError, options) {
18
+ super(onEvent, onError, options);
19
+
20
+ this.imuProvider = new ImuProvider(
21
+ this.onImuEvent,
22
+ this.onImuError,
23
+ { require: [EventType.Acceleration] }
24
+ );
25
+ }
26
+
27
+ /**
28
+ * @override
29
+ */
30
+ static get displayName() {
31
+ return 'Inertial Measurement Unit';
32
+ }
33
+
34
+ /**
35
+ * @override
36
+ */
37
+ static get eventsType() {
38
+ return [EventType.Inclination];
39
+ }
40
+
41
+ /**
42
+ * @override
43
+ */
44
+ static get requiredProviders() {
45
+ return [ImuProvider];
46
+ }
47
+
48
+ /**
49
+ * @override
50
+ */
51
+ startInternal() {
52
+ return this.imuProvider.start();
53
+ }
54
+
55
+ /**
56
+ * @override
57
+ */
58
+ stopInternal() {
59
+ return this.imuProvider.stop();
60
+ }
61
+
62
+ /**
63
+ * @private
64
+ */
65
+ onImuEvent = imuEvent => {
66
+ const accelerationEvent = imuEvent[0];
67
+ const acc = accelerationEvent.data;
68
+
69
+ const screenOrientation = window.orientation || 0;
70
+
71
+ const sizeAcc = Math.sqrt(acc[0] * acc[0] + acc[1] * acc[1] + acc[2] * acc[2]);
72
+ const accNormalized = [acc[0] / sizeAcc, acc[1] / sizeAcc, acc[2] / sizeAcc];
73
+
74
+ const q = [accNormalized[2] + 1, accNormalized[1], -accNormalized[0], 0];
75
+ const qSize = Math.sqrt(q[0] * q[0] + q[1] * q[1] + q[2] * q[2]);
76
+ const qNormalized = [q[0] / qSize, q[1] / qSize, q[2] / qSize, 0];
77
+
78
+ let inclination;
79
+ if (screenOrientation === 0) {
80
+ inclination = Math.asin(2 * qNormalized[1] * qNormalized[0]);
81
+ } else if (screenOrientation === 90) {
82
+ inclination = -Math.asin(2 * qNormalized[2] * qNormalized[0]);
83
+ } else if (screenOrientation === -90) {
84
+ inclination = Math.asin(2 * qNormalized[2] * qNormalized[0]);
85
+ } else if (screenOrientation === 180) {
86
+ inclination = -Math.asin(2 * qNormalized[1] * qNormalized[0]);
87
+ }
88
+
89
+ this.notify(this.createEvent(EventType.Inclination, inclination));
90
+ };
91
+
92
+ onImuError = imuErrors => {
93
+ this.notifyError(...ProviderError.modifyArrayDataType(imuErrors, EventType.Inclination));
94
+ }
95
+
96
+ /**
97
+ * @override
98
+ */
99
+ static checkAvailabilityErrors() {
100
+ return ProviderError.modifyArrayDataType(
101
+ super.checkAvailabilityErrors(),
102
+ EventType.Inclination
103
+ );
104
+ }
105
+ }
106
+
107
+ export default InclinationProvider;
@@ -1,150 +1,9 @@
1
+ import Provider from '../Provider';
1
2
  import {
2
- MapMatching, Network, Itinerary, Edge, WGS84
3
+ WGS84, Edge, Itinerary, Network, MapMatching
3
4
  } from '@wemap/geo';
4
5
 
5
- import Pose from '../Pose';
6
- import Constants from '../Constants';
7
- import SensorsLogger from '../sensors/SensorsLogger';
8
- import ProvidersLogger from './ProvidersLogger';
9
-
10
- /**
11
- * A LocationSource is an independant component which can be instantiate to provide a pose (localisation and orientation)
12
- * @see PdrLocationSource
13
- * @see GnssPdrLocationSource
14
- * @see GnssLocationSource
15
- * @see IPLocationSource
16
- */
17
- class LocationSource {
18
-
19
- /**
20
- * Constructor of a LocationSource
21
- * This constructor must be called by any implementation of a LocationSource
22
- * @param {Function} callback function called when a new location or new orientation is calculated
23
- * @protected
24
- */
25
- constructor(callback) {
26
- if (new.target === LocationSource) {
27
- throw new TypeError('Cannot instantiate LocationSource directly');
28
- }
29
- ProvidersLogger.addEvent(this, 'constructor');
30
- this.callback = callback;
31
- this.pose = new Pose();
32
- }
33
-
34
- /**
35
- * Start the LocationSource
36
- * @public
37
- */
38
- start() {
39
- ProvidersLogger.addEvent(this, 'start');
40
- }
41
-
42
- /**
43
- * Stop the LocationSource
44
- * @public
45
- */
46
- stop() {
47
- ProvidersLogger.addEvent(this, 'stop');
48
- }
49
-
50
- /**
51
- * Same than providerName but with options
52
- * @public
53
- */
54
- get providerNameWithOptions() {
55
- return this.providerName;
56
- }
57
-
58
- /**
59
- * Set a logger to record raw data
60
- * @param {SensorsLogger} logger the sensors logger
61
- */
62
- setLogger(logger) {
63
-
64
- if (logger && !(logger instanceof SensorsLogger)) {
65
- throw new Error('logger is not an instance of SensorsLogger');
66
- }
67
-
68
- this.logger = logger;
69
- }
70
-
71
- /**
72
- * @see providerName
73
- * @public
74
- */
75
- static get providerName() {
76
- return null;
77
- }
78
-
79
- /**
80
- * Explicit name of Location Source
81
- * This name is used in "provider" of pose.location
82
- * @returns provider name
83
- * @public
84
- */
85
- get providerName() {
86
- return this.constructor.providerName;
87
- }
88
-
89
- /**
90
- * Get current pose
91
- * @returns current pose
92
- * @public
93
- */
94
- getPose() {
95
- return this.pose;
96
- }
97
-
98
- /**
99
- * This method must be called to notify callback when pose changed
100
- * @protected
101
- */
102
- notify() {
103
- ProvidersLogger.addPushEvent(this);
104
-
105
- if (!this.callback) {
106
- return;
107
- }
108
-
109
- if (!this.pose.location) {
110
- return;
111
- }
112
-
113
- this.pose.location.provider = this.providerName;
114
- this.callback(this.pose);
115
- }
116
-
117
- /**
118
- * Get most accurate LocationSource from two LocationSource
119
- * @param {LocationSource} ls1 LocationSource 1
120
- * @param {LocationSource} ls2 LocationSource 2
121
- * @returns The most accuracte LocationSource
122
- * @public
123
- */
124
- static getMostAccurateLocationSource(ls1, ls2) {
125
-
126
- if (!(ls1 instanceof LocationSource)) {
127
- throw new TypeError(ls1 + ' is not an instance of LocationSource');
128
- }
129
-
130
- if (!(ls2 instanceof LocationSource)) {
131
- throw new TypeError(ls2 + ' is not an instance of LocationSource');
132
- }
133
-
134
- const accuracyOrder = [];
135
- accuracyOrder[Constants.LOCATION_SOURCE_PROVIDERS.IP] = 0;
136
- accuracyOrder[Constants.LOCATION_SOURCE_PROVIDERS.GNSS] = 1;
137
- accuracyOrder[Constants.LOCATION_SOURCE_PROVIDERS.GNSS_PDR] = 2;
138
- accuracyOrder[Constants.LOCATION_SOURCE_PROVIDERS.PDR] = 3;
139
- accuracyOrder[Constants.LOCATION_SOURCE_PROVIDERS.FIXED_LOCATION] = 4;
140
-
141
- return accuracyOrder[ls1.providerName] > accuracyOrder[ls2.providerName] ? ls1 : ls2;
142
- }
143
-
144
-
145
- /**
146
- * MapMatching
147
- */
6
+ class MapMatchingProvider extends Provider {
148
7
 
149
8
  /**
150
9
  * Enable LocationSource mapmatching
@@ -153,7 +12,7 @@ class LocationSource {
153
12
  * @param {*} maxAngleBearing threshold to match a parallel segment for angle between location bearing and segment. null disables this threshold (default: null)
154
13
  * @public
155
14
  */
156
- enableMapMatching(network = null, maxDistance = null, maxAngleBearing = null) {
15
+ enableMapMatching(network, maxDistance, maxAngleBearing) {
157
16
  this.mapMatching = new MapMatching();
158
17
  this.mapMatching.maxDistance = maxDistance;
159
18
  this.mapMatching.maxAngleBearing = maxAngleBearing;
@@ -283,8 +142,6 @@ class LocationSource {
283
142
  remainingPercentage: 1 - traveledDistance / totalDistance
284
143
  };
285
144
  }
286
-
287
-
288
145
  }
289
146
 
290
- export default LocationSource;
147
+ export default MapMatchingProvider;
@@ -0,0 +1,127 @@
1
+ import { Attitude } from '@wemap/geo';
2
+
3
+ import Provider from '../Provider';
4
+ import EventType from '../../events/EventType';
5
+ import MissingArCoreError from '../../errors/MissingArCoreError';
6
+
7
+ /**
8
+ * Pose provider is the provider used by the PositioningHandler. It uses the best fusion
9
+ * of what he can and provides an AbsoluteAttitude and an AbsolutePosition as an output.
10
+ */
11
+ class ArCoreProvider extends Provider {
12
+
13
+ /**
14
+ * @override
15
+ */
16
+ constructor(onEvent, onError, options) {
17
+ super(onEvent, onError, options);
18
+
19
+ }
20
+
21
+ /**
22
+ * @override
23
+ */
24
+ static get displayName() {
25
+ return 'ArCore provider';
26
+ }
27
+
28
+ /**
29
+ * @override
30
+ */
31
+ static get eventsType() {
32
+ return [EventType.RelativeAttitude, EventType.RelativePosition];
33
+ }
34
+
35
+ /**
36
+ * Return the list of required providers
37
+ */
38
+ static get requiredProviders() {
39
+ return [];
40
+ }
41
+
42
+ /**
43
+ * @override
44
+ */
45
+ startInternal() {
46
+ const nativeProvider = this.constructor.getNativeProvider();
47
+ if (Array.isArray(nativeProvider)) {
48
+ this.notifyError(nativeProvider);
49
+ return;
50
+ }
51
+ nativeProvider.start();
52
+
53
+ this.pullDataLoop();
54
+ }
55
+
56
+ /**
57
+ * @override
58
+ */
59
+ stopInternal() {
60
+ const nativeProvider = this.constructor.getNativeProvider();
61
+ if (Array.isArray(nativeProvider)) {
62
+ this.notifyError(nativeProvider);
63
+ return;
64
+ }
65
+ nativeProvider.stop();
66
+ }
67
+
68
+ pullDataLoop = () => {
69
+
70
+ if (this.state !== Provider.State.STARTED) {
71
+ return;
72
+ }
73
+
74
+ const nativeProvider = this.constructor.getNativeProvider();
75
+ if (Array.isArray(nativeProvider)) {
76
+ this.notifyError(...nativeProvider);
77
+ return;
78
+ }
79
+
80
+ const pose = JSON.parse(nativeProvider.getInfo());
81
+ if (pose.length !== 0) {
82
+ const attitude = new Attitude(pose.slice(0, 4));
83
+ const position = pose.slice(4, 7);
84
+ this.notify(
85
+ this.createEvent(EventType.RelativeAttitude, attitude),
86
+ this.createEvent(EventType.RelativePosition, position)
87
+ );
88
+ }
89
+
90
+ requestAnimationFrame(this.pullDataLoop);
91
+ }
92
+
93
+ static getNativeProvider() {
94
+ const nativeInterface = this.getNativeInterface();
95
+
96
+ if (!nativeInterface) {
97
+ return [
98
+ this.createMissingNativeInterfaceError(EventType.RelativeAttitude),
99
+ this.createMissingNativeInterfaceError(EventType.RelativePosition)
100
+ ];
101
+ }
102
+
103
+ return nativeInterface.getArCoreProvider();
104
+ }
105
+
106
+ /**
107
+ * @override
108
+ */
109
+ static checkAvailabilityErrors() {
110
+
111
+ const nativeProvider = this.getNativeProvider();
112
+ if (Array.isArray(nativeProvider)) {
113
+ return nativeProvider;
114
+ }
115
+
116
+ if (nativeProvider.checkAvailability()) {
117
+ return [];
118
+ }
119
+
120
+ return [
121
+ this.createError(EventType.RelativeAttitude, new MissingArCoreError()),
122
+ this.createError(EventType.RelativePosition, new MissingArCoreError())
123
+ ];
124
+ }
125
+ }
126
+
127
+ export default ArCoreProvider;