-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathIssue272.tsx
executable file
·76 lines (71 loc) · 1.95 KB
/
Issue272.tsx
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
import {
ViroARScene,
ViroARSceneNavigator,
ViroCamera,
ViroText,
ViroTrackingReason,
ViroTrackingStateConstants,
} from "@viro-community/react-viro";
import React from "react";
import { StyleSheet } from "react-native";
const HelloWorldSceneAR = () => {
function onInitialized(state: any, reason: ViroTrackingReason) {
console.log("onInitialized", state, reason);
if (state === ViroTrackingStateConstants.TRACKING_NORMAL) {
} else if (state === ViroTrackingStateConstants.TRACKING_UNAVAILABLE) {
// Handle loss of tracking
}
}
const handleEvent = (name: string, ...args: any[]) => {
// console.log(name, args);
console.log(name, args);
};
return (
<ViroARScene onTrackingUpdated={onInitialized}>
<ViroCamera position={[0, 0, 0]} active={true} />
<ViroText
style={styles.helloWorldTextStyle}
text={"onClickState"}
scale={[0.5, 0.5, 0.2]}
position={[0, 0, -2]}
onClickState={(...args) => handleEvent("onClickState", ...args)}
/>
<ViroText
style={styles.helloWorldTextStyle}
text={"onClickState & onClick"}
scale={[0.5, 0.5, 0.2]}
position={[0, -0.5, -2]}
onClickState={(...args) => handleEvent("onClickState", ...args)}
onClick={(...args) => handleEvent("onClick", ...args)}
/>
<ViroText
style={styles.helloWorldTextStyle}
text={"onClick"}
scale={[0.5, 0.5, 0.2]}
position={[0, 0.5, -2]}
onClick={(...args) => handleEvent("onClick", ...args)}
/>
</ViroARScene>
);
};
export default () => {
return (
<ViroARSceneNavigator
autofocus={true}
initialScene={{
scene: HelloWorldSceneAR,
}}
style={styles.f1}
/>
);
};
var styles = StyleSheet.create({
f1: { flex: 1 },
helloWorldTextStyle: {
fontFamily: "Arial",
fontSize: 16,
color: "#ffffff",
textAlignVertical: "center",
textAlign: "center",
},
});