Skip to content

Instantly share code, notes, and snippets.

@OmalPerera
Created July 31, 2023 03:20
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save OmalPerera/65cdf11f5aa08a474a6fe9a7b9492777 to your computer and use it in GitHub Desktop.
Save OmalPerera/65cdf11f5aa08a474a6fe9a7b9492777 to your computer and use it in GitHub Desktop.
Fixing ViroConstants error in Viro Starter-Kit project
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',
},
});
@OmalPerera
Copy link
Author

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 to import { ViroTrackingStateConstants } from '@viro-community/react-viro';

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment