viromedia / viro

ViroReact: AR and VR using React Native
MIT License
2.31k stars 483 forks source link

App crashes when navigating to ViroARSceneNavigator from StackNavigator. #986

Open amir-aa1908770 opened 1 year ago

amir-aa1908770 commented 1 year ago

When I navigate from Home component to Scene1** app crashes and closes.

If anyone knows how to solve this issue, please help.**

App.js

const Stack = createStackNavigator();

const Scene1 = ({navigation}) => {
  return (
    <ViroARSceneNavigator
      initialScene={{
        scene: SceneAR,
        passProps: {navigation},
      }}
    />
  );
};
const Home = ({navigation}) => {
  return (
    <>
      <View>
        <Text>Vei</Text>
        <Button
          title="Test AR"
          onPress={() => navigation.navigate('Scene1')}></Button>
      </View>
    </>
  );
};
const App = () => {
  return (
    <NavigationContainer>
      <Stack.Navigator screenOptions={{headerShown: false}}>
        <Stack.Screen name="Home" component={Home} />
        <Stack.Screen  name="Scene1" component={Scene1} />
      </Stack.Navigator>
    </NavigationContainer>
    // <Scene1 />
  );
};
export default App;

SceneAR.js

class SceneAR extends Component {

  render() {
    ViroARTrackingTargets.createTargets({
      skullImage: {
        source: require('./assets/QRcode.png'),
        orientation: 'Up',
        physicalWidth: 0.1,
        type: 'Image',
      },
    });
    const anchorFound = () => {
      console.log('Image Detected');
    };
    return (
      <ViroARScene>

        <ViroARImageMarker target="skullImage" onAnchorFound={anchorFound}>
          <ViroImage
              rotation={[-90, 0, 0]}
              scale={[0.2, 0.2, 0]}
              position={[0,0,0.2]}
              source={require('./res/tracking_diffuse_2.png')}
            />

        </ViroARImageMarker>
      </ViroARScene>
    );
  }
}
export default SceneAR;
amol909 commented 1 year ago

Did you find any solution? Even i am having a similar issue