-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathApp.tsx
More file actions
41 lines (36 loc) · 1.14 KB
/
Copy pathApp.tsx
File metadata and controls
41 lines (36 loc) · 1.14 KB
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
import { useState } from "react";
import { SafeAreaView, Text, View } from "react-native";
import {
ModelViewerWebView,
type ModelViewerStatus,
} from "react-native-model-viewer-webview";
const REMOTE_MODEL =
"https://modelviewer.dev/shared-assets/models/Astronaut.glb";
export default function App() {
const [status, setStatus] = useState("Loading model...");
function handleStatus(nextStatus: ModelViewerStatus) {
setStatus(nextStatus.message ?? nextStatus.type);
}
return (
<SafeAreaView style={{ flex: 1, backgroundColor: "#ffffff" }}>
<View style={{ flex: 1, padding: 16, gap: 12 }}>
<Text style={{ fontSize: 20, fontWeight: "700" }}>
React Native Model Viewer WebView
</Text>
<ModelViewerWebView
modelSource={REMOTE_MODEL}
onStatus={handleStatus}
style={{ flex: 1, minHeight: 360 }}
htmlOptions={{
autoRotate: true,
cameraControls: true,
cameraOrbit: "0deg 65deg 3m",
exposure: 1,
shadowIntensity: 0.4,
}}
/>
<Text>{status}</Text>
</View>
</SafeAreaView>
);
}