forked from react-native-ar/react-native-arkit
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.js
47 lines (39 loc) · 1008 Bytes
/
index.js
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
//
// index.js
//
// Created by HippoAR on 7/9/17.
// Copyright © 2017 HippoAR. All rights reserved.
//
import PropTypes from 'prop-types';
import React from 'react';
import { NativeModules, requireNativeComponent } from 'react-native';
const ARKitManager = NativeModules.ARKitManager;
class ARKit extends React.Component {
render() {
return <RCTARKit
{...this.props}
onPlaneDetected={this.callback('onPlaneDetected')}
onPlaneUpdate={this.callback('onPlaneUpdate')}
/>;
}
getCameraPosition() {
return ARKitManager.getCameraPosition();
}
callback(name) {
return event => {
if (!this.props[name]) {
return;
}
this.props[name](event.nativeEvent);
};
}
}
ARKit.propTypes = {
debug: PropTypes.bool,
planeDetection: PropTypes.bool,
lightEstimation: PropTypes.bool,
onPlaneDetected: PropTypes.func,
onPlaneUpdate: PropTypes.func,
};
const RCTARKit = requireNativeComponent('RCTARKit', ARKit);
module.exports = ARKit;