Skip to content

Commit ccdb7a6

Browse files
felixtrzmeta-codesync[bot]
authored andcommitted
docs: add and unify README documentation across all packages
Summary: add and unify README documentation across all packages includes some formatting fixes with pnpm run format Reviewed By: zjm-meta Differential Revision: D89694178 fbshipit-source-id: 82a2835dad6f0d0766d019fd1310eb7962b351b0
1 parent c03c892 commit ccdb7a6

13 files changed

Lines changed: 989 additions & 97 deletions

File tree

README.md

Lines changed: 54 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -13,46 +13,82 @@ The **Immersive Web SDK** makes building immersive web experiences as approachab
1313

1414
**Same code, two experiences**: Run immersively in VR/AR headsets and automatically provide mouse-and-keyboard emulation on desktop browsers. No browser extensions, no special setup—anyone with a laptop can develop for the immersive web.
1515

16-
## Quick Start
16+
## Getting Started
17+
18+
Create a new project with a single command:
1719

1820
```bash
19-
# Install dependencies
20-
pnpm install
21+
npm create @iwsdk@latest
22+
```
2123

22-
# Build and pack all packages
23-
pnpm run build:tgz
24+
Or install into an existing project:
2425

25-
# Run example
26-
cd examples/locomotion && pnpm run fresh:dev
26+
```bash
27+
npm install @iwsdk/core three
2728
```
2829

30+
## Documentation
31+
32+
For guides, concepts, and API reference, visit: **[https://iwsdk.dev](https://iwsdk.dev)**
33+
34+
## Packages
35+
36+
| Package | Description |
37+
| -------------------------------------------------------------------------- | ------------------------------------------------- |
38+
| [@iwsdk/core](./packages/core) | Core SDK with ECS, systems, and WebXR integration |
39+
| [@iwsdk/create](./packages/create) | CLI for scaffolding new projects |
40+
| [@iwsdk/glxf](./packages/glxf) | GLXF scene format loader for Three.js |
41+
| [@iwsdk/locomotor](./packages/locomotor) | Locomotion engine for Three.js WebXR |
42+
| [@iwsdk/xr-input](./packages/xr-input) | WebXR input system for Three.js |
43+
| [@iwsdk/vite-plugin-iwer](./packages/vite-plugin-iwer) | WebXR emulator injection for development |
44+
| [@iwsdk/vite-plugin-gltf-optimizer](./packages/vite-plugin-gltf-optimizer) | GLTF/GLB optimization during build |
45+
| [@iwsdk/vite-plugin-uikitml](./packages/vite-plugin-uikitml) | UIKitML to JSON compiler for spatial UI |
46+
| [@iwsdk/vite-plugin-metaspatial](./packages/vite-plugin-metaspatial) | Meta Spatial Editor integration |
47+
48+
### Internal Packages
49+
50+
| Package | Description |
51+
| -------------------------------------------------- | --------------------------------------- |
52+
| [@iwsdk/starter-assets](./packages/starter-assets) | CDN-hosted templates and assets for CLI |
53+
2954
## Development
3055

3156
```bash
32-
# Lint and format code
57+
# Install dependencies
58+
pnpm install
59+
60+
# Build all packages as tgz files (for examples to consume)
61+
npm run build:tgz
62+
63+
# Run an example (fresh install from local tgz packages)
64+
cd examples/locomotion && npm run fresh:dev
65+
66+
# Lint and format
3367
pnpm run lint
3468
pnpm run format
3569

36-
# Build specific package
37-
pnpm --filter '@iwsdk/core' run build
70+
# Build a specific package
71+
pnpm --filter @iwsdk/core build
3872
```
3973

40-
## Documentation
74+
### Development Workflow
4175

42-
For detailed information about using IWSDK, including step-by-step guides, architectural concepts, and complete API references, please visit our documentation site:
76+
The examples use `file:` dependencies pointing to `.tgz` files built from local packages. This simulates how end-users will consume the packages from npm.
4377

44-
- **[IWSDK Documentation](https://facebook.github.io/immersive-web-sdk)**
78+
1. **`npm run build:tgz`** - Builds all packages in dependency order and creates `.tgz` archives
79+
2. **`npm run fresh:dev`** (in example) - Cleans `node_modules`, reinstalls from tgz files, and starts dev server
80+
81+
This ensures examples always test against the latest local build.
4582

4683
## License
4784

48-
IWSDK is licensed under the MIT License. For more details, see the [LICENSE](https://github.com/facebook/immersive-web-sdk/blob/main/LICENSE) file in this repository.
85+
IWSDK is licensed under the MIT License. See the [LICENSE](./LICENSE) file for details.
4986

5087
## Contributing
5188

52-
Your contributions are welcome! Please feel free to submit issues and pull requests. Before contributing, make sure to review our [Contributing Guidelines](https://github.com/facebook/immersive-web-sdk/blob/main/CONTRIBUTING.md) and [Code of Conduct](https://github.com/facebook/immersive-web-sdk/blob/main/CODE_OF_CONDUCT.md).
89+
Contributions are welcome! Please review our [Contributing Guidelines](./CONTRIBUTING.md) and [Code of Conduct](./CODE_OF_CONDUCT.md) before submitting issues or pull requests.
5390

5491
## Developer Terms
5592

56-
- Open source Terms of Use - https://opensource.fb.com/legal/terms
57-
58-
- Open source Privacy Policy - https://opensource.fb.com/legal/privacy
93+
- [Open Source Terms of Use](https://opensource.fb.com/legal/terms)
94+
- [Open Source Privacy Policy](https://opensource.fb.com/legal/privacy)

examples/physics/README.md

Lines changed: 17 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -89,9 +89,9 @@ Enable physics in your world configuration:
8989
```javascript
9090
World.create(document.getElementById('scene-container'), {
9191
features: {
92-
physics: true, // Enable Havok physics engine
93-
grabbing: true, // Enable object grabbing
94-
locomotion: true, // Enable player movement
92+
physics: true, // Enable Havok physics engine
93+
grabbing: true, // Enable object grabbing
94+
locomotion: true, // Enable player movement
9595
},
9696
});
9797
```
@@ -105,18 +105,21 @@ The physics system uses three main ECS components:
105105
Defines the motion type and physical behavior of an entity. See `immersive-web-sdk/packages/core/src/physics/physicsBody.ts:47-66`
106106

107107
**Motion Types** (`PhysicsState`):
108+
108109
- **`Static`**: Immovable objects like walls and floors. Affects other bodies but never moves.
109110
- **`Dynamic`**: Objects that respond to forces, collisions, and gravity.
110111
- **`Kinematic`**: Programmatically controlled objects that push dynamic bodies but aren't affected by physics.
111112

112113
**Properties**:
114+
113115
- `state`: Motion type (default: `PhysicsState.Dynamic`)
114116
- `linearDamping`: Reduces linear velocity over time (default: 0.0)
115117
- `angularDamping`: Reduces angular velocity over time (default: 0.0)
116118
- `gravityFactor`: Multiplier for gravity effect (default: 1.0)
117119
- `centerOfMass`: Custom center of mass offset (default: auto-calculated)
118120

119121
**Example**:
122+
120123
```javascript
121124
entity.addComponent(PhysicsBody, {
122125
state: PhysicsState.Dynamic,
@@ -130,6 +133,7 @@ entity.addComponent(PhysicsBody, {
130133
Defines the collision shape and material properties. See `immersive-web-sdk/packages/core/src/physics/physicsShape.ts:80-100`
131134

132135
**Shape Types** (`PhysicsShapeType`):
136+
133137
- **`Sphere`**: Defined by radius in `dimensions[0]`. Efficient for round objects.
134138
- **`Box`**: Defined by `[width, height, depth]` in dimensions. Good for rectangular objects.
135139
- **`Cylinder`**: Defined by radius in `dimensions[0]` and height in `dimensions[1]`.
@@ -138,18 +142,20 @@ Defines the collision shape and material properties. See `immersive-web-sdk/pack
138142
- **`Auto`**: Automatically detects the best shape from Three.js geometry (SphereGeometry → Sphere, BoxGeometry → Box, etc.)
139143

140144
**Material Properties**:
145+
141146
- `density`: Mass per unit volume (default: 1.0)
142147
- `restitution`: Bounciness, 0 = no bounce, 1 = perfect bounce (default: 0.0)
143148
- `friction`: Surface friction (default: 0.5)
144149

145150
**Example**:
151+
146152
```javascript
147153
entity.addComponent(PhysicsShape, {
148154
shape: PhysicsShapeType.Sphere,
149-
dimensions: [0.5, 0, 0], // radius = 0.5 meters
155+
dimensions: [0.5, 0, 0], // radius = 0.5 meters
150156
density: 2.0,
151-
restitution: 0.8, // bouncy
152-
friction: 0.1, // slippery
157+
restitution: 0.8, // bouncy
158+
friction: 0.1, // slippery
153159
});
154160
```
155161

@@ -158,15 +164,17 @@ entity.addComponent(PhysicsShape, {
158164
Applies one-time forces or velocity changes to a physics body. The component is automatically removed after application. See `immersive-web-sdk/packages/core/src/physics/physicsManipulation.ts:37-48`
159165

160166
**Properties**:
167+
161168
- `force`: Impulse force vector `[x, y, z]`
162169
- `linearVelocity`: Set linear velocity directly `[x, y, z]`
163170
- `angularVelocity`: Set angular velocity directly `[x, y, z]`
164171

165172
**Example**:
173+
166174
```javascript
167175
// Apply an impulse force
168176
entity.addComponent(PhysicsManipulation, {
169-
force: [10, 5, 0], // Push right and up
177+
force: [10, 5, 0], // Push right and up
170178
});
171179
```
172180

@@ -193,10 +201,10 @@ entity.addComponent(PhysicsShape, {
193201
dimensions: [0.2],
194202
});
195203
entity.addComponent(PhysicsBody, {
196-
state: PhysicsState.Dynamic
204+
state: PhysicsState.Dynamic,
197205
});
198206
entity.addComponent(PhysicsManipulation, {
199-
force: [10, 1, 1]
207+
force: [10, 1, 1],
200208
});
201209
```
202210

examples/scene-understanding/README.md

Lines changed: 22 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -80,14 +80,14 @@ World.create(document.getElementById('scene-container'), {
8080
sessionMode: SessionMode.ImmersiveAR,
8181
features: {
8282
hitTest: true,
83-
planeDetection: { required: true }, // Enable plane detection
84-
meshDetection: { required: true }, // Enable mesh detection
85-
anchors: { required: true }, // Enable spatial anchors
83+
planeDetection: { required: true }, // Enable plane detection
84+
meshDetection: { required: true }, // Enable mesh detection
85+
anchors: { required: true }, // Enable spatial anchors
8686
},
8787
},
8888
features: {
8989
grabbing: true,
90-
sceneUnderstanding: true, // Enable IWSDK scene understanding system
90+
sceneUnderstanding: true, // Enable IWSDK scene understanding system
9191
},
9292
});
9393
```
@@ -107,6 +107,7 @@ Planes are automatically created and updated by the `SceneUnderstandingSystem` a
107107
Represents detected 3D geometry in the environment. See `immersive-web-sdk/packages/core/src/scene-understanding/mesh.ts:43-55`
108108

109109
**Properties**:
110+
110111
- `isBounded3D`: Whether this is a bounded object (true) or global mesh (false)
111112
- `semanticLabel`: Semantic label from the device (e.g., "wall", "couch", "global mesh")
112113
- `min`: Minimum bounding box corner `[x, y, z]`
@@ -120,9 +121,11 @@ Meshes are automatically created and updated by the `SceneUnderstandingSystem` h
120121
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`
121122

122123
**Properties**:
124+
123125
- `attached`: Boolean indicating if the entity is attached to the anchor group, default `false`
124126

125127
**Usage**:
128+
126129
```javascript
127130
// Create an entity that stays fixed in the real world
128131
const entity = world.createTransformEntity(mesh);
@@ -131,7 +134,6 @@ entity.addComponent(XRAnchor);
131134

132135
Objects with the `XRAnchor` component are automatically attached to a stable anchor point by the `SceneUnderstandingSystem`.
133136

134-
135137
### How Scene Understanding Works
136138

137139
The `SceneUnderstandingSystem` (see `src/scene-understanding/scene-understanding-system.ts:72-408`) handles:
@@ -152,16 +154,19 @@ Scene understanding features require specific hardware capabilities. Always chec
152154
### Working with Meshes
153155

154156
**Mesh Types**:
157+
155158
- **Bounded meshes** (`isBounded3D: true`): Individual objects like furniture, walls
156159
- **Global mesh** (`isBounded3D: false`): Environment-wide mesh without semantic meaning
157160

158161
**Best Practices**:
162+
159163
- Use `semanticLabel` to identify what the mesh represents (e.g., "couch", "wall", "table")
160164
- Bounded meshes include useful bounding box data (`min`, `max`, `dimensions`)
161165
- Global meshes are useful for physics or collision but not for semantic understanding
162166
- Filter by `isBounded3D` to work with specific objects vs. the entire environment
163167

164168
**Example: Finding Furniture**:
169+
165170
```javascript
166171
this.queries.meshEntities.entities.forEach((meshEntity) => {
167172
const label = meshEntity.getValue(XRMesh, 'semanticLabel');
@@ -178,15 +183,18 @@ this.queries.meshEntities.entities.forEach((meshEntity) => {
178183
### Working with Anchors
179184

180185
**Anchor Behavior**:
186+
181187
- Anchors keep objects fixed in the real world even as the device tracking shifts
182188
- Perfect for persistent AR content that should stay in one place
183189
- The system maintains anchor stability by updating transforms automatically
184190

185191
**Tips**:
192+
186193
- Use anchors for important objects that must stay in a specific location
187194
- Can be combine with `DistanceGrabbable` to let users position objects precisely
188195

189196
**Example: User-Placed Anchored Object**:
197+
190198
```javascript
191199
// Let user grab and position an anchored object
192200
const entity = world.createTransformEntity(mesh);
@@ -216,11 +224,13 @@ WebXR requires HTTPS for all features to work properly. This example includes:
216224
**For Meta Quest Devices**:
217225

218226
1. Start the dev server:
227+
219228
```bash
220229
pnpm dev
221230
```
222231

223232
2. On your Quest device, open the browser and navigate to:
233+
224234
```
225235
https://YOUR_LOCAL_IP:8081
226236
```
@@ -233,7 +243,6 @@ https://YOUR_LOCAL_IP:8081
233243

234244
## 🛠 Customization
235245

236-
237246
### Enabling Wireframe Toggle
238247

239248
The `SceneUnderstandingSystem` has a built-in `showWireFrame` config option:
@@ -244,13 +253,13 @@ World.create(document.getElementById('scene-container'), {
244253
sessionMode: SessionMode.ImmersiveAR,
245254
features: {
246255
hitTest: true,
247-
planeDetection: { required: true }, // Enable plane detection
248-
meshDetection: { required: true }, // Enable mesh detection
249-
anchors: { required: true }, // Enable spatial anchors
256+
planeDetection: { required: true }, // Enable plane detection
257+
meshDetection: { required: true }, // Enable mesh detection
258+
anchors: { required: true }, // Enable spatial anchors
250259
},
251260
},
252261
features: {
253-
sceneUnderstanding: { showWireFrame: true }, // Enable IWSDK scene understanding system with wireframe enabled
262+
sceneUnderstanding: { showWireFrame: true }, // Enable IWSDK scene understanding system with wireframe enabled
254263
},
255264
});
256265
```
@@ -278,18 +287,21 @@ This example demonstrates integration with:
278287
### Use Cases for Scene Understanding
279288

280289
**Plane Detection**:
290+
281291
- Furniture placement apps
282292
- AR games that need floor/table surfaces
283293
- Virtual interior design
284294
- Educational AR overlays on walls
285295

286296
**Mesh Detection**:
297+
287298
- Obstacle avoidance for AR navigation
288299
- Environment-aware lighting and shadows
289300
- Physics interactions with real objects
290301
- Semantic understanding for context-aware apps
291302

292303
**Spatial Anchors**:
304+
293305
- Persistent AR content that stays in place
294306
- Multi-user AR experiences with shared reference points
295307
- AR annotations on real-world objects

0 commit comments

Comments
 (0)