forked from OmalPerera/viro-react-starter-kit
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathApp.js
106 lines (97 loc) · 2.57 KB
/
App.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
import React, {useState} from 'react';
import {StyleSheet} from 'react-native';
import {
ViroARScene,
ViroText,
ViroTrackingStateConstants,
ViroARSceneNavigator,
Viro3DObject,
ViroAmbientLight,
Viro360Image,
ViroARTrackingTargets,
ViroARImageMarker,
} from '@viro-community/react-viro';
import {objects_3D} from './viroRes/resources';
const HelloWorldSceneAR = () => {
function onInitialized(state, reason) {
if (state === ViroTrackingStateConstants.TRACKING_NORMAL) {
} else if (state === ViroTrackingStateConstants.TRACKING_UNAVAILABLE) {
// Handle loss of tracking
}
}
/*
// you can try following code segments by calling them inside the <ViroARScene>
const render3DObject = () => {
return (
<Viro3DObject
source={objects_3D.dragon_anim.obj}
type={objects_3D.dragon_anim.type}
position={objects_3D.dragon_anim.position}
scale={objects_3D.dragon_anim.scale}
rotation={[0, 0, 0]}
animation={{...objects_3D.dragon_anim.animation, run: true}}
dragType="FixedToWorld"
onDrag={() => {}}
/>
);
};
const render360Image = () => {
return <Viro360Image source={objects_3D.diving_360.background} />;
};
const imageMarker = () => {
return (
<ViroARImageMarker target={'pug2D_img'}>
<Viro3DObject
source={objects_3D.pug_animated.obj}
type={objects_3D.pug_animated.type}
position={objects_3D.pug_animated.position}
scale={objects_3D.pug_animated.scale}
rotation={[0, 0, 0]}
animation={{...objects_3D.pug_animated.animation, run: true}}
dragType="FixedToWorld"
onDrag={() => {}}
/>
</ViroARImageMarker>
);
};
*/
return (
<ViroARScene onTrackingUpdated={onInitialized}>
<ViroAmbientLight color={'#aaaaaa'} />
<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}
/>
);
};
ViroARTrackingTargets.createTargets({
pug2D_img: {
source: objects_3D.pug_animated.img,
orientation: 'Up',
physicalWidth: 0.12, // real world width in meters
},
});
var styles = StyleSheet.create({
f1: {flex: 1},
helloWorldTextStyle: {
fontFamily: 'Arial',
fontSize: 30,
color: '#ffffff',
textAlignVertical: 'center',
textAlign: 'center',
},
});