You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
fix(example) Update scene understanding example README.
Summary: Updated scene understanding example README to reflect the correct information.
Reviewed By: felixtrz
Differential Revision: D83393541
fbshipit-source-id: 67962de52fa40ba9ba830e30250f466f138be44c
This is the official boilerplate project for the WebXR Framework, designed for optimal developer, designer, and tech artist workflow.
3
+
This example demonstrates WebXR scene understanding features in the Immersive Web SDK (IWSDK), showcasing real-world plane detection, mesh detection, and spatial anchors for augmented reality (AR) applications. Learn how to build AR experiences that understand and interact with the physical environment.
4
+
5
+
## 🎯 What You'll Learn
6
+
7
+
This example demonstrates:
8
+
9
+
-**Scene Understanding System**: Detecting and tracking real-world surfaces and objects
10
+
-**Plane Detection**: Identifying horizontal and vertical surfaces (floors, walls, tables)
11
+
-**Mesh Detection**: Capturing detailed 3D geometry of the environment
12
+
-**Spatial Anchors**: Placing virtual objects that stay fixed in the real world
13
+
-**Interactive AR**: Making detected planes and meshes interactive with pointer events
14
+
-**AR Session Management**: Configuring WebXR AR sessions with required features
15
+
16
+
### What's in the Example
17
+
18
+
The example includes:
19
+
20
+
1.**Plane Detection System**: Automatically detects real-world surfaces and visualizes them as wireframe meshes
21
+
2.**Mesh Detection System**: Captures 3D geometry of the environment with semantic labels
22
+
3.**Anchored Sphere**: A grabbable sphere that stays anchored to a fixed position in the real world
23
+
4.**Interactive Visualization**: Detected planes and meshes become visible when you point at them
24
+
5.**Custom System**: A `SceneShowSystem` that manages visibility and interaction of detected geometry
4
25
5
26
## 📁 Project Structure
6
27
7
28
```
8
-
boilerplate/
29
+
scene-understanding/
9
30
├── src/ # Source code
10
-
│ ├── index.js # Main application entry point
11
-
│ ├── settings.js # Settings configuration
12
-
│ ├── test-component.js # Example component
13
-
│ └── settings.uikitml # UI markup
14
-
├── public/ # Static assets (served at root)
15
-
│ ├── gltf/ # 3D models in GLTF format
16
-
│ ├── glxf/ # GLXF scene files
17
-
│ ├── textures/ # Images and texture files
18
-
│ ├── audio/ # Audio files
19
-
│ └── models/ # Other 3D model formats
20
-
├── generated/ # Auto-generated files (committed for designers)
21
-
│ └── components/ # Generated component XML definitions
│ └── index.js # Main application entry point with SceneShowSystem
32
+
├── dist/ # Build output (generated)
33
+
├── index.html # Main HTML file
34
+
├── vite.config.js # Vite configuration
35
+
└── package.json # Project dependencies
30
36
```
31
37
38
+
**Note**: This example focuses on code-based AR scene understanding and doesn't require static assets or Meta Spatial project files.
39
+
32
40
## 🚀 Quick Start
33
41
34
42
### Prerequisites
35
43
36
-
- Node.js 18+ and pnpm
44
+
- Node.js 20.19.0+ and pnpm
37
45
- HTTPS support for WebXR development
38
46
39
47
### Installation
40
48
41
49
```bash
42
-
cdboilerplate
50
+
cdscene-understanding
43
51
pnpm install
44
52
```
45
53
@@ -58,96 +66,194 @@ pnpm preview
58
66
59
67
The development server will start at `https://localhost:8081` with automatic HTTPS certificates.
60
68
61
-
## 📦 Asset Organization
69
+
**Important**: Scene understanding features require an AR-capable device (e.g., Meta Quest 3, Quest Pro) with plane detection, mesh detection, and anchor support.
70
+
71
+
## 🔍 Scene Understanding System Overview
72
+
73
+
### Enabling Scene Understanding
74
+
75
+
Configure your WebXR AR session with scene understanding features:
sceneUnderstanding:true, // Enable IWSDK scene understanding system
91
+
},
92
+
});
93
+
```
94
+
95
+
### Scene Understanding Components
96
+
97
+
The scene understanding system uses three main ECS components:
98
+
99
+
#### 1. XRPlane
100
+
101
+
Represents a detected real-world surface (floor, wall, table, etc.). See `immersive-web-sdk/packages/core/src/scene-understanding/plane.ts:32-42`
102
+
103
+
Planes are automatically created and updated by the `SceneUnderstandingSystem` and has an Object3D representing the Plane's geometry associated.
62
104
63
-
###WebXR-Optimized Asset Handling
105
+
#### 2. XRMesh
64
106
65
-
This boilerplate uses Vite's `public/` directory for WebXR assets since they are:
107
+
Represents detected 3D geometry in the environment. See `immersive-web-sdk/packages/core/src/scene-understanding/mesh.ts:43-55`
66
108
67
-
- Loaded at runtime via URLs (not imported as modules)
68
-
- Large files that shouldn't be bundled or processed
69
-
- Need direct URL access for asset loaders
109
+
**Properties**:
110
+
-`isBounded3D`: Whether this is a bounded object (true) or global mesh (false)
111
+
-`semanticLabel`: Semantic label from the device (e.g., "wall", "couch", "global mesh")
112
+
-`min`: Minimum bounding box corner `[x, y, z]`
113
+
-`max`: Maximum bounding box corner `[x, y, z]`
114
+
-`dimensions`: Size of the bounding box `[width, height, depth]`
70
115
71
-
### Assets Directory Structure
116
+
Meshes are automatically created and updated by the `SceneUnderstandingSystem` has an Object3D representing the Mesh's geometry associated.
72
117
73
-
-**`public/gltf/`** - 3D models in GLTF/GLB format
74
-
-**`public/glxf/`** - GLXF scene files containing component data
75
-
-**`public/textures/`** - Images, textures, and visual assets (.png, .jpg, etc.)
76
-
-**`public/audio/`** - Sound effects and music files
77
-
-**`public/models/`** - Other 3D model formats
118
+
#### 3. XRAnchor
78
119
79
-
### Asset Usage
120
+
Marks an entity to be anchored at a fixed position in the real world (will not move after recentering the view). See `immersive-web-sdk/packages/core/src/scene-understanding/anchor.ts:35-45`
80
121
122
+
**Properties**:
123
+
-`attached`: Boolean indicating if the entity is attached to the anchor group, default `false`
124
+
125
+
**Usage**:
81
126
```javascript
82
-
// Reference assets using root-relative paths (Vite serves public/ at root)
console.log(`Found ${label} with size:`, dimensions);
174
+
}
175
+
});
176
+
```
177
+
178
+
### Working with Anchors
179
+
180
+
**Anchor Behavior**:
181
+
- Anchors keep objects fixed in the real world even as the device tracking shifts
182
+
- Perfect for persistent AR content that should stay in one place
183
+
- The system maintains anchor stability by updating transforms automatically
184
+
185
+
**Tips**:
186
+
- Use anchors for important objects that must stay in a specific location
187
+
- Can be combine with `DistanceGrabbable` to let users position objects precisely
188
+
189
+
**Example: User-Placed Anchored Object**:
190
+
```javascript
191
+
// Let user grab and position an anchored object
192
+
constentity=world.createTransformEntity(mesh);
193
+
entity.addComponent(DistanceGrabbable);
194
+
entity.addComponent(Interactable);
195
+
entity.addComponent(XRAnchor);
196
+
```
106
197
107
-
### Important Notes
198
+
### Performance Tips
108
199
109
-
- All generated files should be committed to ensure the project works out-of-the-box
110
-
- Designers and tech artists can use these without running build commands
111
-
- Files are regenerated when components change during development
200
+
1.**Limit Mesh Rendering**: Only make meshes visible when needed (like on pointer hover or for development only)
201
+
2.**Filter Bounded Meshes**: Use `where: [eq(XRMesh, 'isBounded3D', true)]` to ignore the global mesh
202
+
3.**Simplify Geometry**: Consider creating simplified collision shapes instead of using full mesh geometry
112
203
113
204
## 🌐 WebXR Development
114
205
115
206
### HTTPS Requirements
116
207
117
-
WebXR requires HTTPS for all features to work properly. This boilerplate includes:
208
+
WebXR requires HTTPS for all features to work properly. This example includes:
118
209
119
210
- Automatic HTTPS certificate generation via `vite-plugin-mkcert`
120
211
- Self-signed certificates for local development
121
212
- Proper CORS configuration for asset loading
122
213
123
214
### Testing on Devices
124
215
216
+
**For Meta Quest Devices**:
217
+
218
+
1. Start the dev server:
125
219
```bash
126
-
# Find your local IP
127
-
ipconfig getifaddr en0 # macOS
128
-
# or
129
-
hostname -I # Linux
220
+
pnpm dev
221
+
```
130
222
131
-
# Access from VR headset
223
+
2. On your Quest device, open the browser and navigate to:
224
+
```
132
225
https://YOUR_LOCAL_IP:8081
133
226
```
134
227
135
-
## 🛠 Customization
228
+
3. Accept the self-signed certificate warning
229
+
230
+
4. Enter VR/AR mode to test scene understanding features
231
+
232
+
**Important**: Scene understanding works best in well-lit environments with distinct surfaces. Walk around slowly to allow the device to scan your environment.
136
233
137
-
### Vite Configuration
234
+
##🛠 Customization
138
235
139
-
The `vite.config.js` file includes:
140
236
141
-
- HTTPS development server setup
142
-
- Static asset copying configuration
143
-
- Build optimization settings
144
-
- Asset handling rules
237
+
### Enabling Wireframe Toggle
145
238
146
-
### Adding New Assets
239
+
The `SceneUnderstandingSystem` has a built-in `showWireFrame` config option:
147
240
148
-
1. Place assets in the appropriate `public/` subdirectory
149
-
2. Reference them in your code using root-relative paths (e.g., `/gltf/model.gltf`)
150
-
3. Assets are automatically served by Vite during development and copied to build output
0 commit comments