diff --git a/App.js b/App.js index 8eac444..bc536cb 100644 --- a/App.js +++ b/App.js @@ -3,40 +3,31 @@ import {StyleSheet} from 'react-native'; import { ViroARScene, ViroText, + ViroConstants, ViroARSceneNavigator, - ViroTrackingStateConstants, - ViroBox, } from '@viro-community/react-viro'; +import BusinessCard from './BusinessCard'; + const HelloWorldSceneAR = () => { const [text, setText] = useState('Initializing AR...'); function onInitialized(state, reason) { console.log('guncelleme', state, reason); - if (state === ViroTrackingStateConstants.TRACKING_NORMAL) { - setText('Hello Popop'); - console.log(); - } else if (state === ViroTrackingStateConstants.TRACKING_NONE) { + if (true) { + setText('Hello World!'); + } else if (state === ViroConstants.TRACKING_NONE) { // Handle loss of tracking } } return ( - {/* */} - console.log('Drag Event:', event)} /> ); @@ -47,7 +38,7 @@ export default () => { diff --git a/BusinessCard.js b/BusinessCard.js new file mode 100644 index 0000000..e0562e1 --- /dev/null +++ b/BusinessCard.js @@ -0,0 +1,288 @@ +'use strict'; + +import React, { Component } from 'react'; + +import {StyleSheet} from 'react-native'; + +import { + ViroARScene, + ViroDirectionalLight, + ViroBox, + ViroTrackingStateConstants, + ViroARTrackingTargets, + ViroMaterials, + ViroText, + ViroImage, + ViroFlexView, + ViroARImageMarker, + ViroARObjectMarker, + ViroAmbientLight, + ViroARPlane, + ViroAnimatedImage, + ViroAnimations, + ViroNode, + Viro3DObject, + ViroQuad +} from '@viro-community/react-viro'; + +class BusinessCard extends Component { + + state = { + isTracking: false, + initialized: false, + runAnimation: false + } + + getNoTrackingUI(){ + const { isTracking, initialized } = this.state; + return ( + + ) + } + + + + getARScene() { + return ( + <> + + this.setState({ + runAnimation: true + })} + > + + + + + + + + alert("twitter")} + style={styles.subText} + > + + + + + + + + + + + + + this.setState({ + runAnimation: true + })} + > + + + + + + + + alert("twitter")} + style={styles.subText} + > + + + + + + + + + + + + + ) + } + + render() { + return ( + + { this.state.isTracking ? this.getNoTrackingUI() : this.getARScene() } + + ); + } + + _onInitialized = (state, reason) => { + if (state == ViroTrackingStateConstants.TRACKING_NORMAL) { + isTracking: true + } else { + isTracking: false + } + } +} + +var styles = StyleSheet.create({ + textStyle: { + flex: .5, + fontFamily: 'Roboto', + fontSize: 30, + color: '#ffffff', + textAlignVertical: 'top', + textAlign: 'left', + fontWeight: 'bold', + }, + card: { + flexDirection: 'column' + }, + cardWrapper: { + flexDirection: 'row', + alignItems: 'flex-start', + padding: 0.001, + flex: .5 + }, + subText: { + flexDirection: 'column', + alignItems: 'flex-start', + justifyContent: 'flex-start', + flex: .5 + } +}); + +ViroARTrackingTargets.createTargets({ + "qr" : { + source : require('./res/testQR.png'), + orientation : "Up", + physicalWidth : 0.1 // real world width in meters + }, + "businessCard" : { + source : require('./res/business_card.png'), + orientation : "Up", + physicalWidth : 0.1 // real world width in meters + } +}); + +ViroMaterials.createMaterials({ + imagePlaceholder: { + diffuseColor: "rgba(255,255,255,1)" + }, + quad: { + diffuseColor: "rgba(0,0,0,0.5)" + } +}); + +ViroAnimations.registerAnimations({ + animateImage:{ + properties:{ + positionX: 0.05, + opacity: 1.0 + }, + easing:"Bounce", + duration: 500 + }, + animateViro: { + properties: { + positionZ: 0.02, + opacity: 1.0, + }, + easing:"Bounce", + duration: 500 + } +}); + +export default BusinessCard; \ No newline at end of file diff --git a/res/avatar.png b/res/avatar.png new file mode 100644 index 0000000..286fea2 Binary files /dev/null and b/res/avatar.png differ diff --git a/res/business_card.png b/res/business_card.png new file mode 100644 index 0000000..4251561 Binary files /dev/null and b/res/business_card.png differ diff --git a/res/local_spinner.jpg b/res/local_spinner.jpg new file mode 100644 index 0000000..7a6ecbd Binary files /dev/null and b/res/local_spinner.jpg differ diff --git a/res/testQR.png b/res/testQR.png new file mode 100644 index 0000000..2751d5b Binary files /dev/null and b/res/testQR.png differ diff --git a/res/tweet.gif b/res/tweet.gif new file mode 100644 index 0000000..fdef80d Binary files /dev/null and b/res/tweet.gif differ