File tree Expand file tree Collapse file tree 3 files changed +35
-1
lines changed
examples/worlds/Multiplayer Expand file tree Collapse file tree 3 files changed +35
-1
lines changed Original file line number Diff line number Diff line change 1
- import { StandardReality , Background } from "spacesvr" ;
1
+ import { StandardReality , Background , Model } from "spacesvr" ;
2
2
import LightSwitch from "./ideas/LightSwitch" ;
3
3
4
4
export default function Multiplayer ( ) {
@@ -15,6 +15,7 @@ export default function Multiplayer() {
15
15
< planeBufferGeometry args = { [ 200 , 200 ] } />
16
16
< meshBasicMaterial color = { "purple" } />
17
17
</ mesh >
18
+ < Model src = "https://d27rt3a60hh1lx.cloudfront.net/models/Camera-1652915410/camera_02_cleaned.glb.gz" />
18
19
</ StandardReality >
19
20
) ;
20
21
}
Original file line number Diff line number Diff line change @@ -14,4 +14,5 @@ export * from "./physical/Fog";
14
14
export * from "./physical/Frame" ;
15
15
export * from "./physical/HDRI" ;
16
16
export * from "./physical/InfinitePlane" ;
17
+ export * from "./physical/Model" ;
17
18
export * from "./physical/Video" ;
Original file line number Diff line number Diff line change
1
+ import { Fragment , Suspense } from "react" ;
2
+ import { GroupProps } from "@react-three/fiber" ;
3
+ import { Center } from "@react-three/drei" ;
4
+ import { useModel } from "../../logic" ;
5
+
6
+ type ModelProps = {
7
+ src : string ;
8
+ center ?: boolean ;
9
+ } & GroupProps ;
10
+
11
+ function UnsuspensedModel ( props : ModelProps ) {
12
+ const { src, center, ...rest } = props ;
13
+ const gltf = useModel ( src ) ;
14
+
15
+ const Parent = center ? Center : Fragment ;
16
+
17
+ return (
18
+ < group name = "spacesvr-model" { ...rest } >
19
+ < Parent >
20
+ < primitive object = { gltf . scene } />
21
+ </ Parent >
22
+ </ group >
23
+ ) ;
24
+ }
25
+
26
+ export function Model ( props : ModelProps ) {
27
+ return (
28
+ < Suspense fallback = { null } >
29
+ < UnsuspensedModel { ...props } />
30
+ </ Suspense >
31
+ ) ;
32
+ }
You can’t perform that action at this time.
0 commit comments