Error messages#
| Message | Cause | Fix |
|---|---|---|
useScene() must be used inside <Scene> |
A hook ran in the component that renders <Scene>, or outside any scene |
Move the hook into a child component rendered inside <Scene> (Hooks) |
Apricot components must be used inside <Scene> |
A shape, light, camera or model is rendered outside <Scene> |
Put it inside a <Scene> |
Unknown material preset "x". Known: … |
A typo, or a custom preset used before definePreset ran |
Use a listed name, or register the preset at startup (Materials) |
Unknown environment "x". Known: … |
As above, for environments | "studio", "soft", "sunset", "night", "none", or defineEnvironment first |
Unknown camera view "x". Known: … |
view names a view that is neither built-in nor in views |
Add it to views, or pass a view object |
Unknown hinge word "x" |
A joint's hinge has a word other than front, back, top, bottom, left, right, center |
Fix the word, or give a point [x, y, z] |
No animation "x" in this model. It has: … |
animations names a clip that is not in the file |
Use a listed name (npx apricot-models inspect) |
<Model> needs `src` or `kit` |
Neither was given | Pass one |
A trip needs at least two stops |
useTrip with fewer than two stops |
Give two or more distances |
A "loop" trip needs the path length |
pattern: "loop" without path |
Pass path to useTrip |
A path needs at least two points |
usePath with fewer than two points |
|
mergeColoredParts: color "vertex" needs a color attribute |
A part uses "vertex" but its geometry has no colours |
Give a colour instead |
[apricot] Loading a bundled model needs expo-asset expo-file-system: npx expo install expo-asset expo-file-system |
A <Model>, useModel or useTexture got a require(...) file, and those optional packages are not installed |
Run the command it gives, then rebuild. URLs need neither |
[apricot] captureScene needs expo-file-system: … / [apricot] download needs expo-file-system: … |
Saving pictures or downloads on a phone without expo-file-system |
Run the command it gives, then rebuild |
[apricot] findFreePlace needs a size or an extent, or the id of a thing in the placement |
findFreePlace was called without any of them, or with an id that isn't in the placement (the message names it) |
Pass size: [w, h, d], extent from measureModel, or the id of a thing in the placement |
<Placeable> must be inside a <Placement> |
A <Placeable> rendered outside <Placement> |
Put it (or the component that renders it) inside a <Placement> |
[apricot] WebGPU isn't available on this device |
A phone without a WebGPU adapter (there is no WebGL on iOS or Android), or a browser with neither WebGPU nor WebGL 2 (the message then ends ", and neither is WebGL 2") | Check gpuSupport() before showing scenes and show something else. See On the web |
WebGPU canvas context not available |
The canvas never got a size, or WebGPU is unavailable | Give the scene a size (flex: 1 inside a sized parent, or a height). Use a dev build |
Warnings (logged, not thrown):
| Warning | Meaning |
|---|---|
Material override "x" matches no part |
A materials key matches nothing. Check names with npx apricot-models inspect |
Joint "x" matches no part |
A joint's select matches nothing |
No shape key "x" in this model |
A morphs key is not in the file |
<Pile> drops meshes only; ignoring "x" |
A <Pile> child is a group, a model or a <Peach>. Use a single mesh |
Shader warm-up failed |
The scene still works |
[apricot] useLayout keeps layouts with expo-file-system … |
useLayout was given save on a phone without expo-file-system. The layout works for this run but isn't kept. Install it, or pass storage |
[apricot] GPU error: … |
The GPU rejected something, and part of the scene may draw nothing. Each kind is logged once and added to the performance report. Include it when you share the report |
apricot-models needs the model tools: npm install --save-dev … |
The CLI's optional dependencies are missing. Run the command it prints |
Setup#
The app crashes or shows nothing in Expo Go#
Expo Go is not supported, because react-native-webgpu needs native code. Make a development build with npx expo prebuild, then npx expo run:ios or npx expo run:android. See Installation.
Android build fails on minSdkVersion#
react-native-webgpu needs Android 8.0 (API 26). Add "@apricotjs/react-native" to your config plugins (it raises minSdkVersion to 26), then run npx expo prebuild again.
The iOS simulator crashes on start#
The simulator needs Metal API validation off, which the config plugin sets. Check that "@apricotjs/react-native" is in plugins and run npx expo prebuild again. Simulators are much slower than devices, so judge performance on a phone, in a release build.
require("./model.glb") fails to resolve#
Metro does not bundle .glb files by default. Wrap your config with withApricot in metro.config.js and restart Metro with --clear.
Shared values do nothing, or Animatable props ignore them#
Shared values need react-native-reanimated and react-native-worklets, which are optional. Without them, props read plain values only. Install them with npx expo install react-native-reanimated react-native-worklets and rebuild.
Two copies of three.js, or "multiple instances of three" warnings#
withApricot resolves three and three/webgpu to one build. Check that it wraps your final Metro config, and that only one three version is installed (npm ls three).
Blank, black or slow scenes#
The scene is blank for a moment after it mounts#
This is expected. A new scene shows only its background for about a second on a phone, and at most 12 s. Show your own placeholder with loading={…}, or wait for onReady.
The scene stays blank#
- The scene has no size. A
<Scene style={{ flex: 1 }}>inside a parent without a height is 0 tall. Give the parentflex: 1or the scene aheight. - The camera is inside or behind the object. The default camera is at
[0, 0, 6]looking at the origin, and an object larger than about 4 units fills or passes it. Move the camera back, or use<FitCamera>or<CameraRig>. - The object is beyond the camera's
farplane (default 200). Raisecamera.far. - The scene has
look="none"and no lights, environment or<Daylight>, so everything is black. Add one.
Metal objects look black or flat#
Metals reflect their surroundings, and a look alone gives them nothing to reflect. Add environment="studio" (or another environment) to the scene, usually with look="none".
Glass is invisible#
Glass shows what is behind it, so over a plain background it shows nothing. Put <Backdrop> or other objects behind it.
Objects are too small or too big#
Units are metres. A 1-unit box is a metre wide, and the default camera sees it from 6 m away. Scale your models to real size in Blender, or frame them with a <CameraRig> inside the <Model>, which fits the subject at any size. For a <Pile>, scale is relative to each child. With the recipe's camera, the screen is about 10 units tall.
A model appears lying down, upside down or facing away#
Apricot expects y up and the front facing +z. Fix it in Blender, or wrap it: <Group rotation={[-Math.PI / 2, 0, 0]}><Model … /></Group>. To stand it on the floor, use ground.
The frame rate is low#
Count draw calls. Every separate mesh costs about 80 µs per frame on a mid-range phone. Use <Instances> for repeats, merge model parts in Blender, and keep models under 150,000 triangles. Keep frameloop="demand" (the default) so idle scenes do not render. Turn on debug to see fps and render time. See Performance.
Placement and layouts#
Tapping a piece does nothing#
- It isn't a
<Placeable>inside a<Placement>, or it islocked. - A
<Model>inside it hasn't loaded yet (it has no size until then).
A dragged piece won't go where I want#
- With
collide="block"(the default), solid things stop against each other. Use"warn"to pass through, orsolid={false}on things that may be overlapped (a rug). - It stays inside
bounds, and inside its kind of area (ground or water).canPlacemay be saying no, so log itscheck. - Things on a wall can only be dragged onto walls the camera sees from the side they face. A room that isn't a rectangle needs
walls(its outline), notbounds.
Pieces go back to their old places when the screen opens again#
The places only live in <Placement> until you store them. Store each place from onChange (useLayout's place does) and pass it back as position and turn.
A saved layout doesn't come back#
saveneedsexpo-file-systemon a phone (or your ownstorage).- Raising
versiondrops layouts kept by older versions on purpose. - Draw the pieces only when
layout.loadedis true, or the starting layout shows first.
A new piece appears on top of another#
Give it findRoom. When it first appears, it moves to the nearest place it fits. Or ask findFreePlace for a place before adding it.
Pieces end up outside the room after it changed size#
Nothing is moved for you when bounds, walls or areas change. Listen to onOutside and call the ref's moveInside() (or let people move them by hand).
Moving one piece is slow#
Each piece is re-rendered with the list. Render pieces in a memo component, use <Merged> for pieces made of many shapes, and wrap the room in <Bundle>.
Lighting#
A lamp glows but lights nothing#
<Scene lamps> defaults to 0, so lamps only glow. Set it to how many lamps should light at once (<Scene lamps={3}>). It is read at mount.
Sun comes in through the ceiling or open walls of a cut-away room#
Add shadowOnly boxes for the roof and the missing walls. They aren't drawn, but they keep the sun out, so it comes in by the window only.
Models and textures#
A model never appears#
<Model> renders nothing until it has loaded, and its children wait too. Add onError={(e) => console.warn(e)} to see why. Common causes:
- Draco, meshopt or KTX2 compression, which the phone can't decode. Run the file through
npx apricot-models, which decodes them on your computer. - A
.gltfwith a separate.binfile: convert it to.glbwithapricot-models. - A URL that needs headers, or a path typed as a string instead of
require(...). Bundled files must userequire.
Material overrides or joints do nothing#
The selector matches nothing (a warning is logged). List the real names with npx apricot-models inspect file.glb, or tap parts with <Model inspect>. material: selectors match the material name in the file. Plain patterns match node or material names.
A door turns around the wrong edge#
hinge words refer to the part's bounds with the model facing +z. front is +z and left is +x. Try the opposite word, swap the sign of range, or give an exact point.
A texture shows the wrong colours or is black#
Use color: "#ffffff" with map (the image multiplies the colour). For masks and data images, pass colorSpace: NoColorSpace. PNG and JPEG only.
Updates and animation#
Changing a three.js object does nothing#
With frameloop="demand", the scene renders only when Apricot knows something changed. After changing an object through a ref outside useFrame, call useScene().invalidate(). Or drive it with props, shared values or useFrame, which wake the scene themselves.
An animation in useFrame stops after a moment#
The callback returned false or nothing. Return true while it should keep moving.
Changing a <Scene> prop has no effect#
Scene options are read once, at mount (except frameloop, background and paused). Change the scene's key to remount it, or use <Environment>, <Daylight> or a camera component, which change live. The same applies to <Vehicle> and <FollowCamera> options.
Shared value props jitter or lag#
Use useSharedValue / useDerivedValue from Reanimated (not React state) for values that change every frame, and type tuples as readonly [number, number, number].
Gestures#
Orbiting does not work inside a ScrollView on iOS#
On iOS, JavaScript cannot stop a scroll view from scrolling. Turn scrolling off while a finger is on the scene, with onOrbitStart={() => setScrolls(false)} and onOrbitEnd={() => setScrolls(true)} on the rig and <ScrollView scrollEnabled={scrolls}>. See Camera.
Gestures do nothing#
Wrap the app root in GestureHandlerRootView from react-native-gesture-handler, with style={{ flex: 1 }}.
Taps do not reach the screen behind an overlay scene#
Give the overlay transparent and pointerEvents="none".
Still stuck#
Turn on <Scene debug> and use the Share button (or shareDiagnostics(scene)) to export a performance report with frame times, scene contents and GPU details.