Skip to content

Commit

Permalink
now, scene is cleared on start, instead on mounting of the component
Browse files Browse the repository at this point in the history
  • Loading branch information
macrozone committed Nov 28, 2017
1 parent b10cc00 commit dd467ed
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 9 deletions.
9 changes: 0 additions & 9 deletions ARKit.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,10 +30,6 @@ const TRACKING_REASONS = [
];
const TRACKING_STATES_COLOR = ['red', 'orange', 'green'];

// clear scene on start (not on mount)
// this is only needed if you reload the app (in dev mode)
let firstMount = false;

class ARKit extends Component {
state = {
state: 0,
Expand All @@ -43,11 +39,6 @@ class ARKit extends Component {

componentDidMount() {
ARKitManager.resume();
if (!firstMount) {
ARKitManager.clearScene();
} else {
firstMount = true;
}
}

componentWillUnmount() {
Expand Down
3 changes: 3 additions & 0 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ import ARText from './components/ARText';
import ARTorus from './components/ARTorus';
import ARTube from './components/ARTube';
import DeviceMotion from './DeviceMotion';
import startup from './startup';
import withProjectedPosition from './hocs/withProjectedPosition';

ARKit.Box = ARBox;
Expand All @@ -40,6 +41,8 @@ ARKit.Group = ARGroup;
ARKit.Shape = ARShape;
ARKit.Light = ARLight;

startup();

export {
ARKit,
DeviceMotion,
Expand Down
10 changes: 10 additions & 0 deletions startup.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
import { NativeModules } from 'react-native';

const ARKitManager = NativeModules.ARKitManager;

export default () => {
// when reloading the app, the scene should be cleared.
// on prod, this usually does not happen, but you can reload the app in develop mode
// without clearing, this would result in inconsistency
ARKitManager.clearScene();
};

0 comments on commit dd467ed

Please sign in to comment.