Created
July 31, 2023 03:20
-
-
Save OmalPerera/65cdf11f5aa08a474a6fe9a7b9492777 to your computer and use it in GitHub Desktop.
Fixing ViroConstants error in Viro Starter-Kit project
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import React, {useState} from 'react'; | |
import {StyleSheet} from 'react-native'; | |
import { | |
ViroARScene, | |
ViroText, | |
ViroTrackingStateConstants, | |
ViroARSceneNavigator, | |
} from '@viro-community/react-viro'; | |
const HelloWorldSceneAR = () => { | |
const [text, setText] = useState('Initializing AR...'); | |
function onInitialized(state, reason) { | |
console.log('guncelleme', state, reason); | |
if (state === ViroTrackingStateConstants.TRACKING_NORMAL) { | |
setText('Hello World!'); | |
} else if (state === ViroTrackingStateConstants.TRACKING_UNAVAILABLE) { | |
// Handle loss of tracking | |
} | |
} | |
return ( | |
<ViroARScene onTrackingUpdated={onInitialized}> | |
<ViroText | |
text={text} | |
scale={[0.5, 0.5, 0.5]} | |
position={[0, 0, -1]} | |
style={styles.helloWorldTextStyle} | |
/> | |
</ViroARScene> | |
); | |
}; | |
export default () => { | |
return ( | |
<ViroARSceneNavigator | |
autofocus={true} | |
initialScene={{ | |
scene: HelloWorldSceneAR, | |
}} | |
style={styles.f1} | |
/> | |
); | |
}; | |
var styles = StyleSheet.create({ | |
f1: {flex: 1}, | |
helloWorldTextStyle: { | |
fontFamily: 'Arial', | |
fontSize: 30, | |
color: '#ffffff', | |
textAlignVertical: 'center', | |
textAlign: 'center', | |
}, | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
The problem is with the old import statement
import { ViroConstants } from '@viro-community/react-viro';
now the tracking constants are defined in
ViroTrackingStateConstants
. so alter the import statement toimport { ViroTrackingStateConstants } from '@viro-community/react-viro';