@codyswann/lisa 2.111.0 → 2.112.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (155) hide show
  1. package/package.json +1 -1
  2. package/plugins/lisa/.claude-plugin/plugin.json +1 -1
  3. package/plugins/lisa/.codex-plugin/plugin.json +1 -1
  4. package/plugins/lisa-cdk/.claude-plugin/plugin.json +1 -1
  5. package/plugins/lisa-cdk/.codex-plugin/plugin.json +1 -1
  6. package/plugins/lisa-expo/.claude-plugin/plugin.json +1 -1
  7. package/plugins/lisa-expo/.codex-plugin/plugin.json +1 -1
  8. package/plugins/lisa-expo/.mcp.json +3 -3
  9. package/plugins/lisa-expo/THIRD-PARTY-NOTICES.md +57 -0
  10. package/plugins/lisa-expo/skills/add-app-clip/SKILL.md +280 -0
  11. package/plugins/lisa-expo/skills/add-app-clip/agents/openai.yaml +4 -0
  12. package/plugins/lisa-expo/skills/add-app-clip/references/native-module.md +96 -0
  13. package/plugins/lisa-expo/skills/building-native-ui/SKILL.md +321 -0
  14. package/plugins/lisa-expo/skills/building-native-ui/agents/openai.yaml +4 -0
  15. package/plugins/lisa-expo/skills/building-native-ui/references/animations.md +220 -0
  16. package/plugins/lisa-expo/skills/building-native-ui/references/controls.md +272 -0
  17. package/plugins/lisa-expo/skills/building-native-ui/references/form-sheet.md +253 -0
  18. package/plugins/lisa-expo/skills/building-native-ui/references/gradients.md +106 -0
  19. package/plugins/lisa-expo/skills/building-native-ui/references/icons.md +213 -0
  20. package/plugins/lisa-expo/skills/building-native-ui/references/media.md +198 -0
  21. package/plugins/lisa-expo/skills/building-native-ui/references/route-structure.md +229 -0
  22. package/plugins/lisa-expo/skills/building-native-ui/references/search.md +248 -0
  23. package/plugins/lisa-expo/skills/building-native-ui/references/storage.md +121 -0
  24. package/plugins/lisa-expo/skills/building-native-ui/references/tabs.md +433 -0
  25. package/plugins/lisa-expo/skills/building-native-ui/references/toolbar-and-headers.md +284 -0
  26. package/plugins/lisa-expo/skills/building-native-ui/references/visual-effects.md +197 -0
  27. package/plugins/lisa-expo/skills/building-native-ui/references/webgpu-three.md +605 -0
  28. package/plugins/lisa-expo/skills/building-native-ui/references/zoom-transitions.md +158 -0
  29. package/plugins/lisa-expo/skills/eas-update-insights/SKILL.md +228 -0
  30. package/plugins/lisa-expo/skills/eas-update-insights/agents/openai.yaml +4 -0
  31. package/plugins/lisa-expo/skills/eas-update-insights/references/channel-insights-schema.md +47 -0
  32. package/plugins/lisa-expo/skills/eas-update-insights/references/update-insights-schema.md +69 -0
  33. package/plugins/lisa-expo/skills/expo-api-routes/SKILL.md +369 -0
  34. package/plugins/lisa-expo/skills/expo-api-routes/agents/openai.yaml +4 -0
  35. package/plugins/lisa-expo/skills/expo-brownfield/SKILL.md +54 -0
  36. package/plugins/lisa-expo/skills/expo-brownfield/agents/openai.yaml +4 -0
  37. package/plugins/lisa-expo/skills/expo-brownfield/references/brownfield-integrated.md +526 -0
  38. package/plugins/lisa-expo/skills/expo-brownfield/references/brownfield-isolated.md +402 -0
  39. package/plugins/lisa-expo/skills/expo-brownfield/references/comparison.md +63 -0
  40. package/plugins/lisa-expo/skills/expo-brownfield/references/troubleshooting.md +88 -0
  41. package/plugins/lisa-expo/skills/expo-cicd-workflows/SKILL.md +92 -0
  42. package/plugins/lisa-expo/skills/expo-cicd-workflows/agents/openai.yaml +4 -0
  43. package/plugins/lisa-expo/skills/expo-cicd-workflows/scripts/fetch.js +113 -0
  44. package/plugins/lisa-expo/skills/expo-cicd-workflows/scripts/package.json +11 -0
  45. package/plugins/lisa-expo/skills/expo-cicd-workflows/scripts/validate.js +85 -0
  46. package/plugins/lisa-expo/skills/expo-deployment/SKILL.md +190 -0
  47. package/plugins/lisa-expo/skills/expo-deployment/agents/openai.yaml +4 -0
  48. package/plugins/lisa-expo/skills/expo-deployment/references/app-store-metadata.md +479 -0
  49. package/plugins/lisa-expo/skills/expo-deployment/references/ios-app-store.md +355 -0
  50. package/plugins/lisa-expo/skills/expo-deployment/references/play-store.md +246 -0
  51. package/plugins/lisa-expo/skills/expo-deployment/references/testflight.md +58 -0
  52. package/plugins/lisa-expo/skills/expo-deployment/references/workflows.md +200 -0
  53. package/plugins/lisa-expo/skills/expo-dev-client/SKILL.md +164 -0
  54. package/plugins/lisa-expo/skills/expo-dev-client/agents/openai.yaml +4 -0
  55. package/plugins/lisa-expo/skills/expo-module/SKILL.md +141 -0
  56. package/plugins/lisa-expo/skills/expo-module/agents/openai.yaml +4 -0
  57. package/plugins/lisa-expo/skills/expo-module/references/config-plugin.md +90 -0
  58. package/plugins/lisa-expo/skills/expo-module/references/create-expo-module.md +206 -0
  59. package/plugins/lisa-expo/skills/expo-module/references/lifecycle.md +127 -0
  60. package/plugins/lisa-expo/skills/expo-module/references/module-config.md +48 -0
  61. package/plugins/lisa-expo/skills/expo-module/references/native-module.md +286 -0
  62. package/plugins/lisa-expo/skills/expo-module/references/native-view.md +171 -0
  63. package/plugins/lisa-expo/skills/expo-tailwind-setup/SKILL.md +480 -0
  64. package/plugins/lisa-expo/skills/expo-tailwind-setup/agents/openai.yaml +4 -0
  65. package/plugins/lisa-expo/skills/expo-ui-jetpack-compose/SKILL.md +40 -0
  66. package/plugins/lisa-expo/skills/expo-ui-jetpack-compose/agents/openai.yaml +4 -0
  67. package/plugins/lisa-expo/skills/expo-ui-swift-ui/SKILL.md +39 -0
  68. package/plugins/lisa-expo/skills/expo-ui-swift-ui/agents/openai.yaml +4 -0
  69. package/plugins/lisa-expo/skills/native-data-fetching/SKILL.md +507 -0
  70. package/plugins/lisa-expo/skills/native-data-fetching/agents/openai.yaml +4 -0
  71. package/plugins/lisa-expo/skills/native-data-fetching/references/expo-router-loaders.md +344 -0
  72. package/plugins/lisa-expo/skills/upgrading-expo/SKILL.md +134 -0
  73. package/plugins/lisa-expo/skills/upgrading-expo/agents/openai.yaml +4 -0
  74. package/plugins/lisa-expo/skills/upgrading-expo/references/expo-av-to-audio.md +132 -0
  75. package/plugins/lisa-expo/skills/upgrading-expo/references/expo-av-to-video.md +160 -0
  76. package/plugins/lisa-expo/skills/upgrading-expo/references/native-tabs.md +124 -0
  77. package/plugins/lisa-expo/skills/upgrading-expo/references/new-architecture.md +79 -0
  78. package/plugins/lisa-expo/skills/upgrading-expo/references/react-19.md +79 -0
  79. package/plugins/lisa-expo/skills/upgrading-expo/references/react-compiler.md +59 -0
  80. package/plugins/lisa-expo/skills/upgrading-expo/references/react-navigation-to-expo-router.md +61 -0
  81. package/plugins/lisa-expo/skills/use-dom/SKILL.md +417 -0
  82. package/plugins/lisa-expo/skills/use-dom/agents/openai.yaml +4 -0
  83. package/plugins/lisa-harper-fabric/.claude-plugin/plugin.json +1 -1
  84. package/plugins/lisa-harper-fabric/.codex-plugin/plugin.json +1 -1
  85. package/plugins/lisa-nestjs/.claude-plugin/plugin.json +1 -1
  86. package/plugins/lisa-nestjs/.codex-plugin/plugin.json +1 -1
  87. package/plugins/lisa-openclaw/.claude-plugin/plugin.json +1 -1
  88. package/plugins/lisa-openclaw/.codex-plugin/plugin.json +1 -1
  89. package/plugins/lisa-rails/.claude-plugin/plugin.json +1 -1
  90. package/plugins/lisa-rails/.codex-plugin/plugin.json +1 -1
  91. package/plugins/lisa-typescript/.claude-plugin/plugin.json +1 -1
  92. package/plugins/lisa-typescript/.codex-plugin/plugin.json +1 -1
  93. package/plugins/lisa-wiki/.claude-plugin/plugin.json +1 -1
  94. package/plugins/lisa-wiki/.codex-plugin/plugin.json +1 -1
  95. package/plugins/src/expo/.mcp.json +3 -3
  96. package/plugins/src/expo/THIRD-PARTY-NOTICES.md +57 -0
  97. package/plugins/src/expo/skills/add-app-clip/SKILL.md +280 -0
  98. package/plugins/src/expo/skills/add-app-clip/references/native-module.md +96 -0
  99. package/plugins/src/expo/skills/building-native-ui/SKILL.md +321 -0
  100. package/plugins/src/expo/skills/building-native-ui/references/animations.md +220 -0
  101. package/plugins/src/expo/skills/building-native-ui/references/controls.md +272 -0
  102. package/plugins/src/expo/skills/building-native-ui/references/form-sheet.md +253 -0
  103. package/plugins/src/expo/skills/building-native-ui/references/gradients.md +106 -0
  104. package/plugins/src/expo/skills/building-native-ui/references/icons.md +213 -0
  105. package/plugins/src/expo/skills/building-native-ui/references/media.md +198 -0
  106. package/plugins/src/expo/skills/building-native-ui/references/route-structure.md +229 -0
  107. package/plugins/src/expo/skills/building-native-ui/references/search.md +248 -0
  108. package/plugins/src/expo/skills/building-native-ui/references/storage.md +121 -0
  109. package/plugins/src/expo/skills/building-native-ui/references/tabs.md +433 -0
  110. package/plugins/src/expo/skills/building-native-ui/references/toolbar-and-headers.md +284 -0
  111. package/plugins/src/expo/skills/building-native-ui/references/visual-effects.md +197 -0
  112. package/plugins/src/expo/skills/building-native-ui/references/webgpu-three.md +605 -0
  113. package/plugins/src/expo/skills/building-native-ui/references/zoom-transitions.md +158 -0
  114. package/plugins/src/expo/skills/eas-update-insights/SKILL.md +228 -0
  115. package/plugins/src/expo/skills/eas-update-insights/references/channel-insights-schema.md +47 -0
  116. package/plugins/src/expo/skills/eas-update-insights/references/update-insights-schema.md +69 -0
  117. package/plugins/src/expo/skills/expo-api-routes/SKILL.md +369 -0
  118. package/plugins/src/expo/skills/expo-brownfield/SKILL.md +54 -0
  119. package/plugins/src/expo/skills/expo-brownfield/references/brownfield-integrated.md +526 -0
  120. package/plugins/src/expo/skills/expo-brownfield/references/brownfield-isolated.md +402 -0
  121. package/plugins/src/expo/skills/expo-brownfield/references/comparison.md +63 -0
  122. package/plugins/src/expo/skills/expo-brownfield/references/troubleshooting.md +88 -0
  123. package/plugins/src/expo/skills/expo-cicd-workflows/SKILL.md +92 -0
  124. package/plugins/src/expo/skills/expo-cicd-workflows/scripts/fetch.js +113 -0
  125. package/plugins/src/expo/skills/expo-cicd-workflows/scripts/package.json +11 -0
  126. package/plugins/src/expo/skills/expo-cicd-workflows/scripts/validate.js +85 -0
  127. package/plugins/src/expo/skills/expo-deployment/SKILL.md +190 -0
  128. package/plugins/src/expo/skills/expo-deployment/references/app-store-metadata.md +479 -0
  129. package/plugins/src/expo/skills/expo-deployment/references/ios-app-store.md +355 -0
  130. package/plugins/src/expo/skills/expo-deployment/references/play-store.md +246 -0
  131. package/plugins/src/expo/skills/expo-deployment/references/testflight.md +58 -0
  132. package/plugins/src/expo/skills/expo-deployment/references/workflows.md +200 -0
  133. package/plugins/src/expo/skills/expo-dev-client/SKILL.md +164 -0
  134. package/plugins/src/expo/skills/expo-module/SKILL.md +141 -0
  135. package/plugins/src/expo/skills/expo-module/references/config-plugin.md +90 -0
  136. package/plugins/src/expo/skills/expo-module/references/create-expo-module.md +206 -0
  137. package/plugins/src/expo/skills/expo-module/references/lifecycle.md +127 -0
  138. package/plugins/src/expo/skills/expo-module/references/module-config.md +48 -0
  139. package/plugins/src/expo/skills/expo-module/references/native-module.md +286 -0
  140. package/plugins/src/expo/skills/expo-module/references/native-view.md +171 -0
  141. package/plugins/src/expo/skills/expo-tailwind-setup/SKILL.md +480 -0
  142. package/plugins/src/expo/skills/expo-ui-jetpack-compose/SKILL.md +40 -0
  143. package/plugins/src/expo/skills/expo-ui-swift-ui/SKILL.md +39 -0
  144. package/plugins/src/expo/skills/native-data-fetching/SKILL.md +507 -0
  145. package/plugins/src/expo/skills/native-data-fetching/references/expo-router-loaders.md +344 -0
  146. package/plugins/src/expo/skills/upgrading-expo/SKILL.md +134 -0
  147. package/plugins/src/expo/skills/upgrading-expo/references/expo-av-to-audio.md +132 -0
  148. package/plugins/src/expo/skills/upgrading-expo/references/expo-av-to-video.md +160 -0
  149. package/plugins/src/expo/skills/upgrading-expo/references/native-tabs.md +124 -0
  150. package/plugins/src/expo/skills/upgrading-expo/references/new-architecture.md +79 -0
  151. package/plugins/src/expo/skills/upgrading-expo/references/react-19.md +79 -0
  152. package/plugins/src/expo/skills/upgrading-expo/references/react-compiler.md +59 -0
  153. package/plugins/src/expo/skills/upgrading-expo/references/react-navigation-to-expo-router.md +61 -0
  154. package/plugins/src/expo/skills/use-dom/SKILL.md +417 -0
  155. package/scripts/generate-codex-plugin-artifacts.mjs +7 -2
@@ -0,0 +1,605 @@
1
+ # WebGPU & Three.js for Expo
2
+
3
+ **Use this skill for ANY 3D graphics, games, GPU compute, or Three.js features in React Native.**
4
+
5
+ ## Locked Versions (Tested & Working)
6
+
7
+ ```json
8
+ {
9
+ "react-native-wgpu": "^0.4.1",
10
+ "three": "0.172.0",
11
+ "@react-three/fiber": "^9.4.0",
12
+ "wgpu-matrix": "^3.0.2",
13
+ "@types/three": "0.172.0"
14
+ }
15
+ ```
16
+
17
+ **Critical:** These versions are tested together. Mismatched versions cause type errors and runtime issues.
18
+
19
+ ## Installation
20
+
21
+ ```bash
22
+ npm install react-native-wgpu@^0.4.1 three@0.172.0 @react-three/fiber@^9.4.0 wgpu-matrix@^3.0.2 @types/three@0.172.0 --legacy-peer-deps
23
+ ```
24
+
25
+ **Note:** `--legacy-peer-deps` may be required due to peer dependency conflicts with canary Expo versions.
26
+
27
+ ## Metro Configuration
28
+
29
+ Create `metro.config.js` in project root:
30
+
31
+ ```js
32
+ const { getDefaultConfig } = require("expo/metro-config");
33
+
34
+ const config = getDefaultConfig(__dirname);
35
+
36
+ config.resolver.resolveRequest = (context, moduleName, platform) => {
37
+ // Force 'three' to webgpu build
38
+ if (moduleName.startsWith("three")) {
39
+ moduleName = "three/webgpu";
40
+ }
41
+
42
+ // Use standard react-three/fiber instead of React Native version
43
+ if (platform !== "web" && moduleName.startsWith("@react-three/fiber")) {
44
+ return context.resolveRequest(
45
+ {
46
+ ...context,
47
+ unstable_conditionNames: ["module"],
48
+ mainFields: ["module"],
49
+ },
50
+ moduleName,
51
+ platform
52
+ );
53
+ }
54
+ return context.resolveRequest(context, moduleName, platform);
55
+ };
56
+
57
+ module.exports = config;
58
+ ```
59
+
60
+ ## Required Lib Files
61
+
62
+ Create these files in `src/lib/`:
63
+
64
+ ### 1. make-webgpu-renderer.ts
65
+
66
+ ```ts
67
+ import type { NativeCanvas } from "react-native-wgpu";
68
+ import * as THREE from "three/webgpu";
69
+
70
+ export class ReactNativeCanvas {
71
+ constructor(private canvas: NativeCanvas) {}
72
+
73
+ get width() {
74
+ return this.canvas.width;
75
+ }
76
+ get height() {
77
+ return this.canvas.height;
78
+ }
79
+ set width(width: number) {
80
+ this.canvas.width = width;
81
+ }
82
+ set height(height: number) {
83
+ this.canvas.height = height;
84
+ }
85
+ get clientWidth() {
86
+ return this.canvas.width;
87
+ }
88
+ get clientHeight() {
89
+ return this.canvas.height;
90
+ }
91
+ set clientWidth(width: number) {
92
+ this.canvas.width = width;
93
+ }
94
+ set clientHeight(height: number) {
95
+ this.canvas.height = height;
96
+ }
97
+
98
+ addEventListener(_type: string, _listener: EventListener) {}
99
+ removeEventListener(_type: string, _listener: EventListener) {}
100
+ dispatchEvent(_event: Event) {}
101
+ setPointerCapture() {}
102
+ releasePointerCapture() {}
103
+ }
104
+
105
+ export const makeWebGPURenderer = (
106
+ context: GPUCanvasContext,
107
+ { antialias = true }: { antialias?: boolean } = {}
108
+ ) =>
109
+ new THREE.WebGPURenderer({
110
+ antialias,
111
+ // @ts-expect-error
112
+ canvas: new ReactNativeCanvas(context.canvas),
113
+ context,
114
+ });
115
+ ```
116
+
117
+ ### 2. fiber-canvas.tsx
118
+
119
+ ```tsx
120
+ import * as THREE from "three/webgpu";
121
+ import React, { useEffect, useRef } from "react";
122
+ import type { ReconcilerRoot, RootState } from "@react-three/fiber";
123
+ import {
124
+ extend,
125
+ createRoot,
126
+ unmountComponentAtNode,
127
+ events,
128
+ } from "@react-three/fiber";
129
+ import type { ViewProps } from "react-native";
130
+ import { PixelRatio } from "react-native";
131
+ import { Canvas, type CanvasRef } from "react-native-wgpu";
132
+
133
+ import {
134
+ makeWebGPURenderer,
135
+ ReactNativeCanvas,
136
+ } from "@/lib/make-webgpu-renderer";
137
+
138
+ // Extend THREE namespace for R3F - add all components you use
139
+ extend({
140
+ AmbientLight: THREE.AmbientLight,
141
+ DirectionalLight: THREE.DirectionalLight,
142
+ PointLight: THREE.PointLight,
143
+ SpotLight: THREE.SpotLight,
144
+ Mesh: THREE.Mesh,
145
+ Group: THREE.Group,
146
+ Points: THREE.Points,
147
+ BoxGeometry: THREE.BoxGeometry,
148
+ SphereGeometry: THREE.SphereGeometry,
149
+ CylinderGeometry: THREE.CylinderGeometry,
150
+ ConeGeometry: THREE.ConeGeometry,
151
+ DodecahedronGeometry: THREE.DodecahedronGeometry,
152
+ BufferGeometry: THREE.BufferGeometry,
153
+ BufferAttribute: THREE.BufferAttribute,
154
+ MeshStandardMaterial: THREE.MeshStandardMaterial,
155
+ MeshBasicMaterial: THREE.MeshBasicMaterial,
156
+ PointsMaterial: THREE.PointsMaterial,
157
+ PerspectiveCamera: THREE.PerspectiveCamera,
158
+ Scene: THREE.Scene,
159
+ });
160
+
161
+ interface FiberCanvasProps {
162
+ children: React.ReactNode;
163
+ style?: ViewProps["style"];
164
+ camera?: THREE.PerspectiveCamera;
165
+ scene?: THREE.Scene;
166
+ }
167
+
168
+ export const FiberCanvas = ({
169
+ children,
170
+ style,
171
+ scene,
172
+ camera,
173
+ }: FiberCanvasProps) => {
174
+ const root = useRef<ReconcilerRoot<OffscreenCanvas>>(null!);
175
+ const canvasRef = useRef<CanvasRef>(null);
176
+
177
+ useEffect(() => {
178
+ const context = canvasRef.current!.getContext("webgpu")!;
179
+ const renderer = makeWebGPURenderer(context);
180
+
181
+ // @ts-expect-error - ReactNativeCanvas wraps native canvas
182
+ const canvas = new ReactNativeCanvas(context.canvas) as HTMLCanvasElement;
183
+ canvas.width = canvas.clientWidth * PixelRatio.get();
184
+ canvas.height = canvas.clientHeight * PixelRatio.get();
185
+ const size = {
186
+ top: 0,
187
+ left: 0,
188
+ width: canvas.clientWidth,
189
+ height: canvas.clientHeight,
190
+ };
191
+
192
+ if (!root.current) {
193
+ root.current = createRoot(canvas);
194
+ }
195
+ root.current.configure({
196
+ size,
197
+ events,
198
+ scene,
199
+ camera,
200
+ gl: renderer,
201
+ frameloop: "always",
202
+ dpr: 1,
203
+ onCreated: async (state: RootState) => {
204
+ // @ts-expect-error - WebGPU renderer has init method
205
+ await state.gl.init();
206
+ const renderFrame = state.gl.render.bind(state.gl);
207
+ state.gl.render = (s: THREE.Scene, c: THREE.Camera) => {
208
+ renderFrame(s, c);
209
+ context?.present();
210
+ };
211
+ },
212
+ });
213
+ root.current.render(children);
214
+ return () => {
215
+ if (canvas != null) {
216
+ unmountComponentAtNode(canvas!);
217
+ }
218
+ };
219
+ });
220
+
221
+ return <Canvas ref={canvasRef} style={style} />;
222
+ };
223
+ ```
224
+
225
+ ## Basic 3D Scene
226
+
227
+ ```tsx
228
+ import * as THREE from "three/webgpu";
229
+ import { View } from "react-native";
230
+ import { useRef, useEffect } from "react";
231
+ import { useFrame, useThree } from "@react-three/fiber";
232
+ import { FiberCanvas } from "@/lib/fiber-canvas";
233
+
234
+ function RotatingBox() {
235
+ const ref = useRef<THREE.Mesh>(null!);
236
+
237
+ useFrame((_, delta) => {
238
+ ref.current.rotation.x += delta;
239
+ ref.current.rotation.y += delta * 0.5;
240
+ });
241
+
242
+ return (
243
+ <mesh ref={ref}>
244
+ <boxGeometry args={[1, 1, 1]} />
245
+ <meshStandardMaterial color="hotpink" />
246
+ </mesh>
247
+ );
248
+ }
249
+
250
+ function Scene() {
251
+ const { camera } = useThree();
252
+
253
+ useEffect(() => {
254
+ camera.position.set(0, 2, 5);
255
+ camera.lookAt(0, 0, 0);
256
+ }, [camera]);
257
+
258
+ return (
259
+ <>
260
+ <ambientLight intensity={0.5} />
261
+ <directionalLight position={[10, 10, 5]} intensity={1} />
262
+ <RotatingBox />
263
+ </>
264
+ );
265
+ }
266
+
267
+ export default function App() {
268
+ return (
269
+ <View style={{ flex: 1 }}>
270
+ <FiberCanvas style={{ flex: 1 }}>
271
+ <Scene />
272
+ </FiberCanvas>
273
+ </View>
274
+ );
275
+ }
276
+ ```
277
+
278
+ ## Lazy Loading (Recommended)
279
+
280
+ Use React.lazy to code-split Three.js for better loading:
281
+
282
+ ```tsx
283
+ import React, { Suspense } from "react";
284
+ import { ActivityIndicator, View } from "react-native";
285
+
286
+ const Scene = React.lazy(() => import("@/components/scene"));
287
+
288
+ export default function Page() {
289
+ return (
290
+ <View style={{ flex: 1 }}>
291
+ <Suspense fallback={<ActivityIndicator size="large" />}>
292
+ <Scene />
293
+ </Suspense>
294
+ </View>
295
+ );
296
+ }
297
+ ```
298
+
299
+ ## Common Geometries
300
+
301
+ ```tsx
302
+ // Box
303
+ <mesh>
304
+ <boxGeometry args={[width, height, depth]} />
305
+ <meshStandardMaterial color="red" />
306
+ </mesh>
307
+
308
+ // Sphere
309
+ <mesh>
310
+ <sphereGeometry args={[radius, widthSegments, heightSegments]} />
311
+ <meshStandardMaterial color="blue" />
312
+ </mesh>
313
+
314
+ // Cylinder
315
+ <mesh>
316
+ <cylinderGeometry args={[radiusTop, radiusBottom, height, segments]} />
317
+ <meshStandardMaterial color="green" />
318
+ </mesh>
319
+
320
+ // Cone
321
+ <mesh>
322
+ <coneGeometry args={[radius, height, segments]} />
323
+ <meshStandardMaterial color="yellow" />
324
+ </mesh>
325
+ ```
326
+
327
+ ## Lighting
328
+
329
+ ```tsx
330
+ // Ambient (uniform light everywhere)
331
+ <ambientLight intensity={0.5} />
332
+
333
+ // Directional (sun-like)
334
+ <directionalLight position={[10, 10, 5]} intensity={1} />
335
+
336
+ // Point (light bulb)
337
+ <pointLight position={[0, 5, 0]} intensity={2} distance={10} />
338
+
339
+ // Spot (flashlight)
340
+ <spotLight position={[0, 10, 0]} angle={0.3} penumbra={1} intensity={2} />
341
+ ```
342
+
343
+ ## Animation with useFrame
344
+
345
+ ```tsx
346
+ import { useFrame } from "@react-three/fiber";
347
+ import { useRef } from "react";
348
+ import * as THREE from "three/webgpu";
349
+
350
+ function AnimatedMesh() {
351
+ const ref = useRef<THREE.Mesh>(null!);
352
+
353
+ // Runs every frame - delta is time since last frame
354
+ useFrame((state, delta) => {
355
+ // Rotate
356
+ ref.current.rotation.y += delta;
357
+
358
+ // Oscillate position
359
+ ref.current.position.y = Math.sin(state.clock.elapsedTime) * 2;
360
+ });
361
+
362
+ return (
363
+ <mesh ref={ref}>
364
+ <boxGeometry />
365
+ <meshStandardMaterial color="orange" />
366
+ </mesh>
367
+ );
368
+ }
369
+ ```
370
+
371
+ ## Particle Systems
372
+
373
+ ```tsx
374
+ import * as THREE from "three/webgpu";
375
+ import { useRef, useEffect } from "react";
376
+ import { useFrame } from "@react-three/fiber";
377
+
378
+ function Particles({ count = 500 }) {
379
+ const ref = useRef<THREE.Points>(null!);
380
+ const positions = useRef<Float32Array>(new Float32Array(count * 3));
381
+
382
+ useEffect(() => {
383
+ for (let i = 0; i < count; i++) {
384
+ positions.current[i * 3] = (Math.random() - 0.5) * 50;
385
+ positions.current[i * 3 + 1] = (Math.random() - 0.5) * 50;
386
+ positions.current[i * 3 + 2] = (Math.random() - 0.5) * 50;
387
+ }
388
+ }, [count]);
389
+
390
+ useFrame((_, delta) => {
391
+ // Animate particles
392
+ for (let i = 0; i < count; i++) {
393
+ positions.current[i * 3 + 1] -= delta * 2;
394
+ if (positions.current[i * 3 + 1] < -25) {
395
+ positions.current[i * 3 + 1] = 25;
396
+ }
397
+ }
398
+ ref.current.geometry.attributes.position.needsUpdate = true;
399
+ });
400
+
401
+ return (
402
+ <points ref={ref}>
403
+ <bufferGeometry>
404
+ <bufferAttribute
405
+ attach="attributes-position"
406
+ args={[positions.current, 3]}
407
+ />
408
+ </bufferGeometry>
409
+ <pointsMaterial color="#ffffff" size={0.2} sizeAttenuation />
410
+ </points>
411
+ );
412
+ }
413
+ ```
414
+
415
+ ## Touch Controls (Orbit)
416
+
417
+ See the full `orbit-controls.tsx` implementation in the lib files. Usage:
418
+
419
+ ```tsx
420
+ import { View } from "react-native";
421
+ import { FiberCanvas } from "@/lib/fiber-canvas";
422
+ import useControls from "@/lib/orbit-controls";
423
+
424
+ function Scene() {
425
+ const [OrbitControls, events] = useControls();
426
+
427
+ return (
428
+ <View style={{ flex: 1 }} {...events}>
429
+ <FiberCanvas style={{ flex: 1 }}>
430
+ <OrbitControls />
431
+ {/* Your 3D content */}
432
+ </FiberCanvas>
433
+ </View>
434
+ );
435
+ }
436
+ ```
437
+
438
+ ## Common Issues & Solutions
439
+
440
+ ### 1. "X is not part of the THREE namespace"
441
+
442
+ **Problem:** Error like `AmbientLight is not part of the THREE namespace`
443
+
444
+ **Solution:** Add the missing component to the `extend()` call in fiber-canvas.tsx:
445
+
446
+ ```tsx
447
+ extend({
448
+ AmbientLight: THREE.AmbientLight,
449
+ // Add other missing components...
450
+ });
451
+ ```
452
+
453
+ ### 2. TypeScript Errors with Three.js
454
+
455
+ **Problem:** Type mismatches between three.js and R3F
456
+
457
+ **Solution:** Use `@ts-expect-error` comments where needed:
458
+
459
+ ```tsx
460
+ // @ts-expect-error - WebGPU renderer types don't match
461
+ await state.gl.init();
462
+ ```
463
+
464
+ ### 3. Blank Screen
465
+
466
+ **Problem:** Canvas renders but nothing visible
467
+
468
+ **Solution:**
469
+
470
+ 1. Ensure camera is positioned correctly and looking at scene
471
+ 2. Add lighting (objects are black without light)
472
+ 3. Check that `extend()` includes all components used
473
+
474
+ ### 4. Performance Issues
475
+
476
+ **Problem:** Low frame rate or stuttering
477
+
478
+ **Solution:**
479
+
480
+ - Reduce polygon count in geometries
481
+ - Use `useMemo` for static data
482
+ - Limit particle count
483
+ - Use `instancedMesh` for many identical objects
484
+
485
+ ### 5. Peer Dependency Errors
486
+
487
+ **Problem:** npm install fails with ERESOLVE
488
+
489
+ **Solution:** Use `--legacy-peer-deps`:
490
+
491
+ ```bash
492
+ npm install <packages> --legacy-peer-deps
493
+ ```
494
+
495
+ ## Building
496
+
497
+ WebGPU requires a custom build:
498
+
499
+ ```bash
500
+ npx expo prebuild
501
+ npx expo run:ios
502
+ ```
503
+
504
+ **Note:** WebGPU does NOT work in Expo Go.
505
+
506
+ ## File Structure
507
+
508
+ ```
509
+ src/
510
+ ├── app/
511
+ │ └── index.tsx # Entry point with lazy loading
512
+ ├── components/
513
+ │ ├── scene.tsx # Main 3D scene
514
+ │ └── game.tsx # Game logic
515
+ └── lib/
516
+ ├── fiber-canvas.tsx # R3F canvas wrapper
517
+ ├── make-webgpu-renderer.ts # WebGPU renderer
518
+ └── orbit-controls.tsx # Touch controls
519
+ ```
520
+
521
+ ## Decision Tree
522
+
523
+ ```
524
+ Need 3D graphics?
525
+ ├── Simple shapes → mesh + geometry + material
526
+ ├── Animated objects → useFrame + refs
527
+ ├── Many objects → instancedMesh
528
+ ├── Particles → Points + BufferGeometry
529
+
530
+ Need interaction?
531
+ ├── Orbit camera → useControls hook
532
+ ├── Touch objects → onClick on mesh
533
+ ├── Gestures → react-native-gesture-handler
534
+
535
+ Performance critical?
536
+ ├── Static geometry → useMemo
537
+ ├── Many instances → InstancedMesh
538
+ └── Complex scenes → LOD (Level of Detail)
539
+ ```
540
+
541
+ ## Example: Complete Game Scene
542
+
543
+ ```tsx
544
+ import * as THREE from "three/webgpu";
545
+ import { View, Text, Pressable } from "react-native";
546
+ import { useRef, useState, useEffect } from "react";
547
+ import { useFrame, useThree } from "@react-three/fiber";
548
+ import { FiberCanvas } from "@/lib/fiber-canvas";
549
+
550
+ function Player({ position }: { position: THREE.Vector3 }) {
551
+ const ref = useRef<THREE.Mesh>(null!);
552
+
553
+ useFrame(() => {
554
+ ref.current.position.copy(position);
555
+ });
556
+
557
+ return (
558
+ <mesh ref={ref}>
559
+ <coneGeometry args={[0.5, 1, 8]} />
560
+ <meshStandardMaterial color="#00ffff" />
561
+ </mesh>
562
+ );
563
+ }
564
+
565
+ function GameScene({ playerX }: { playerX: number }) {
566
+ const { camera } = useThree();
567
+ const playerPos = useRef(new THREE.Vector3(0, 0, 0));
568
+
569
+ playerPos.current.x = playerX;
570
+
571
+ useEffect(() => {
572
+ camera.position.set(0, 10, 15);
573
+ camera.lookAt(0, 0, 0);
574
+ }, [camera]);
575
+
576
+ return (
577
+ <>
578
+ <ambientLight intensity={0.5} />
579
+ <directionalLight position={[5, 10, 5]} />
580
+ <Player position={playerPos.current} />
581
+ </>
582
+ );
583
+ }
584
+
585
+ export default function Game() {
586
+ const [playerX, setPlayerX] = useState(0);
587
+
588
+ return (
589
+ <View style={{ flex: 1, backgroundColor: "#000" }}>
590
+ <FiberCanvas style={{ flex: 1 }}>
591
+ <GameScene playerX={playerX} />
592
+ </FiberCanvas>
593
+
594
+ <View style={{ position: "absolute", bottom: 40, flexDirection: "row" }}>
595
+ <Pressable onPress={() => setPlayerX((x) => x - 1)}>
596
+ <Text style={{ color: "#fff", fontSize: 32 }}>◀</Text>
597
+ </Pressable>
598
+ <Pressable onPress={() => setPlayerX((x) => x + 1)}>
599
+ <Text style={{ color: "#fff", fontSize: 32 }}>▶</Text>
600
+ </Pressable>
601
+ </View>
602
+ </View>
603
+ );
604
+ }
605
+ ```