Skip to content

Commit d5ef34e

Browse files
committed
base: base setup
1 parent e2488d5 commit d5ef34e

30 files changed

+14858
-384
lines changed

.yarnrc.yml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
1-
nodeLinker: node-modules
21
enableGlobalCache: true
32

4-
nmHoistingLimits: workspaces
5-
6-
# Enable corepack for proper version management
73
enableImmutableInstalls: false
84

5+
enableScripts: true
96

7+
nmHoistingLimits: workspaces
8+
9+
nodeLinker: node-modules

apps/example/package.json

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,15 +12,15 @@
1212
"clean": "expo prebuild --clean"
1313
},
1414
"dependencies": {
15-
"@react-three/fiber": "^10.0.0",
15+
"@react-three/fiber": "^9.4.0",
1616
"@react-three/native": "workspace:*",
1717
"expo": "~52.0.29",
1818
"expo-asset": "~11.0.1",
1919
"expo-file-system": "~18.0.7",
2020
"expo-gl": "~15.0.3",
2121
"expo-status-bar": "~2.0.0",
2222
"react": "^19.0.0",
23-
"react-native": "0.78.7",
23+
"react-native": "0.81.4",
2424
"three": "^0.171.0"
2525
},
2626
"devDependencies": {
@@ -30,4 +30,3 @@
3030
"typescript": "^5.7.2"
3131
}
3232
}
33-

apps/webgpu-example/.gitignore

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
# Learn more https://docs.github.com/en/get-started/getting-started-with-git/ignoring-files
2+
3+
# dependencies
4+
node_modules/
5+
6+
# Expo
7+
.expo/
8+
dist/
9+
web-build/
10+
expo-env.d.ts
11+
12+
# Native
13+
*.orig.*
14+
*.jks
15+
*.p8
16+
*.p12
17+
*.key
18+
*.mobileprovision
19+
20+
# Metro
21+
.metro-health-check*
22+
23+
# debug
24+
npm-debug.*
25+
yarn-debug.*
26+
yarn-error.*
27+
28+
# macOS
29+
.DS_Store
30+
*.pem
31+
32+
# local env files
33+
.env*.local
34+
35+
# typescript
36+
*.tsbuildinfo
37+
38+
app-example

apps/webgpu-example/App.tsx

Lines changed: 0 additions & 127 deletions
This file was deleted.

apps/webgpu-example/README.md

Lines changed: 25 additions & 67 deletions
Original file line numberDiff line numberDiff line change
@@ -1,85 +1,43 @@
11
# WebGPU Example
22

3-
Advanced example demonstrating `@react-three/native` with WebGPU acceleration via [react-native-webgpu](https://github.com/wcandillon/react-native-webgpu).
3+
React Native WebGPU example using [Expo Router](https://docs.expo.dev/router/introduction/), [react-native-wgpu](https://github.com/wcandillon/react-native-webgpu), and Three.js WebGPU renderer.
44

5-
## Features
6-
7-
- ✅ Hardware-accelerated WebGPU rendering
8-
- ✅ Complex geometry (torus knot)
9-
- ✅ Multiple animated objects
10-
- ✅ Advanced materials with metalness/roughness
11-
- ✅ Multiple dynamic lights
5+
This example demonstrates true WebGPU rendering in React Native using the native WebGPU bindings and Three.js's WebGPU renderer (`three/webgpu`).
126

13-
## Requirements
14-
15-
- **Physical device required** (simulators don't support WebGPU)
16-
- **iOS 14+** or **Android with Vulkan support**
17-
- Cannot use Expo Go (requires dev build)
7+
## Features
188

19-
## Running
9+
- Native WebGPU rendering via `react-native-wgpu`
10+
- Three.js WebGPU renderer integration
11+
- React Three Fiber with WebGPU backend
12+
- Custom orbit controls for camera manipulation
13+
- Multiple 3D geometries (boxes, cylinders, spheres)
2014

21-
### First Time Setup
15+
## Getting Started
2216

23-
```bash
24-
# From this directory
25-
yarn expo prebuild
17+
Install dependencies:
2618

27-
# Then run on device
28-
yarn ios # For iOS
29-
yarn android # For Android
19+
```sh
20+
yarn install
3021
```
3122

32-
### After Initial Setup
23+
Run the app:
3324

34-
```bash
35-
# From repo root
36-
yarn dev:webgpu
37-
38-
# Or from this directory
25+
```sh
3926
yarn start
4027
```
4128

42-
## What's Inside
43-
44-
- **App.tsx** - Advanced 3D scene with multiple objects
45-
- **react-native-webgpu** - WebGPU context provider
46-
- Complex materials and lighting
47-
- Animated elements using `useFrame`
48-
49-
## Performance
50-
51-
WebGPU provides significant performance improvements over WebGL:
52-
- Better GPU utilization
53-
- Lower CPU overhead
54-
- Support for modern GPU features
55-
- Faster rendering for complex scenes
56-
57-
## Troubleshooting
58-
59-
### Build fails
60-
61-
```bash
62-
yarn expo prebuild --clean
63-
yarn ios # or yarn android
64-
```
65-
66-
### WebGPU not available
67-
68-
Make sure you're running on a physical device with:
69-
- iOS 14+ (Metal support)
70-
- Android with Vulkan 1.1+
29+
Then press `i` for iOS or `a` for Android. This project requires a custom development client since it uses native modules.
7130

72-
### Changes not reflecting
73-
74-
Rebuild the native app:
75-
```bash
76-
yarn expo prebuild
77-
yarn ios # or yarn android
78-
```
31+
## Key Implementation Details
7932

80-
## Learn More
33+
- Uses `three/webgpu` imports for WebGPU renderer
34+
- Custom `makeWebGPURenderer` function wraps the native canvas
35+
- Integrates with React Three Fiber through custom canvas component
36+
- Orbit controls implemented for interactive camera movement
8137

82-
- [react-native-webgpu GitHub](https://github.com/wcandillon/react-native-webgpu)
83-
- [WebGPU Specification](https://www.w3.org/TR/webgpu/)
84-
- [@react-three/fiber docs](https://docs.pmnd.rs/react-three-fiber)
38+
## Technical Stack
8539

40+
- **react-native-wgpu**: Native WebGPU bindings for React Native
41+
- **three**: Three.js 3D library (WebGPU renderer)
42+
- **@react-three/fiber**: React reconciler for Three.js
43+
- **expo-router**: File-based routing for Expo apps

apps/webgpu-example/app.json

Lines changed: 8 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -1,44 +1,15 @@
11
{
22
"expo": {
3-
"name": "R3F WebGPU Example",
4-
"slug": "r3f-webgpu-example",
5-
"version": "1.0.0",
6-
"orientation": "portrait",
7-
"icon": "./assets/icon.png",
8-
"userInterfaceStyle": "light",
9-
"newArchEnabled": true,
10-
"splash": {
11-
"image": "./assets/splash.png",
12-
"resizeMode": "contain",
13-
"backgroundColor": "#000000"
14-
},
15-
"assetBundlePatterns": [
16-
"**/*"
17-
],
18-
"ios": {
19-
"supportsTablet": true,
20-
"bundleIdentifier": "com.reactthree.native.webgpu"
21-
},
22-
"android": {
23-
"adaptiveIcon": {
24-
"foregroundImage": "./assets/adaptive-icon.png",
25-
"backgroundColor": "#000000"
26-
},
27-
"package": "com.reactthree.native.webgpu"
28-
},
3+
"scheme": "acme",
4+
"userInterfaceStyle": "automatic",
5+
"orientation": "default",
296
"web": {
30-
"favicon": "./assets/favicon.png"
7+
"output": "single"
318
},
329
"plugins": [
33-
[
34-
"react-native-webgpu",
35-
{
36-
"ios": {
37-
"deploymentTarget": "14.0"
38-
}
39-
}
40-
]
41-
]
10+
"expo-router"
11+
],
12+
"name": "webgpu-example",
13+
"slug": "webgpu-example"
4214
}
4315
}
44-

apps/webgpu-example/assets/.gitkeep

Lines changed: 0 additions & 12 deletions
This file was deleted.

apps/webgpu-example/babel.config.js

Lines changed: 0 additions & 7 deletions
This file was deleted.

0 commit comments

Comments
 (0)