Skip to content

Commit c03c892

Browse files
felixtrzmeta-codesync[bot]
authored andcommitted
chore: apply formatting fixes and add missing newlines across docs and examples
Summary: apply formatting fixes and add missing newlines across docs and examples with pnpm run format Reviewed By: zjm-meta Differential Revision: D89688995 Privacy Context Container: L1334777 fbshipit-source-id: 6c1d7c67445001dc361b8a79f008dea4209f45a8
1 parent 947a3bb commit c03c892

File tree

27 files changed

+316
-221
lines changed

27 files changed

+316
-221
lines changed

docs/concepts/ecs/entity.md

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,7 @@ entity.dispose();
7777

7878
::: warning
7979
**Use with caution!** `dispose()` is destructive and will free GPU memory for:
80+
8081
- All geometries attached to the entity's `object3D` and its children
8182
- All materials (including shared materials)
8283
- All textures referenced by those materials
@@ -86,12 +87,12 @@ If other entities share the same geometry, material, or texture, they will break
8687

8788
### When to use each
8889

89-
| Scenario | Method |
90-
|----------|--------|
91-
| Removing an entity that uses shared/reusable assets | `destroy()` |
90+
| Scenario | Method |
91+
| ---------------------------------------------------------- | ----------- |
92+
| Removing an entity that uses shared/reusable assets | `destroy()` |
9293
| Removing an entity with unique, one-off geometry/materials | `dispose()` |
93-
| Level unloading with asset reuse | `destroy()` |
94-
| Full cleanup of procedurally generated content | `dispose()` |
94+
| Level unloading with asset reuse | `destroy()` |
95+
| Full cleanup of procedurally generated content | `dispose()` |
9596

9697
### Example: Safe cleanup pattern
9798

docs/concepts/grabbing/distance-grabbing.md

Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ DistanceGrabHandle.update() called
1919
2020
Switch based on movementMode:
2121
├─ MoveTowardsTarget → Step-based interpolation
22-
├─ MoveAtSource → Delta tracking
22+
├─ MoveAtSource → Delta tracking
2323
├─ MoveFromTarget → Direct ray mapping
2424
└─ RotateAtSource → Rotation-only mode
2525
@@ -40,7 +40,8 @@ const distance = pointerOrigin.distanceTo(position);
4040

4141
if (distance > this.moveSpeed) {
4242
// Calculate step vector toward target
43-
const step = pointerOrigin.sub(position)
43+
const step = pointerOrigin
44+
.sub(position)
4445
.normalize()
4546
.multiplyScalar(this.moveSpeed);
4647
position.add(step);
@@ -95,7 +96,7 @@ this.previousPointerOrigin.copy(current);
9596
- **Distance Independence**: Object depth doesn't affect lateral movement sensitivity
9697
- **Local Coordinate Response**: Movement feels natural in controller's reference frame
9798

98-
#### Design Trade-offs
99+
#### Design Trade-offs
99100

100101
- **Naturalness vs Precision**: Feels intuitive but lacks absolute positioning
101102
- **Responsiveness vs Stability**: Immediate response but susceptible to hand jitter
@@ -147,11 +148,11 @@ Objects rotate in place without translation or scaling, using automatic constrai
147148

148149
```ts
149150
// Translation and scale automatically disabled
150-
translate: movementMode === MovementMode.RotateAtSource
151-
? ('as-rotate' as const)
151+
translate: movementMode === MovementMode.RotateAtSource
152+
? ('as-rotate' as const)
152153
: /* normal translate config */,
153-
scale: movementMode === MovementMode.RotateAtSource
154-
? false
154+
scale: movementMode === MovementMode.RotateAtSource
155+
? false
155156
: /* normal scale config */
156157
```
157158

@@ -215,14 +216,14 @@ The system captures initial transform state during handle creation:
215216

216217
- **Magical/Fantasy**: MoveTowardsTarget for supernatural pull effects
217218
- **Technical/Precise**: MoveFromTarget for exact positioning
218-
- **Natural/Intuitive**: MoveAtSource for gesture-based manipulation
219+
- **Natural/Intuitive**: MoveAtSource for gesture-based manipulation
219220
- **Constrained/Fixed**: RotateAtSource for orientation-only controls
220221

221222
### User Experience Goals
222223

223-
- **Comfort First**: MoveTowardsTarget reduces motion sickness through predictable movement
224+
- **Comfort First**: MoveTowardsTarget reduces motion sickness through predictable movement
224225
- **Control First**: MoveFromTarget provides maximum manipulation precision
225226
- **Natural First**: MoveAtSource feels most similar to direct hand movement
226227
- **Simplicity First**: RotateAtSource eliminates position complexity
227228

228-
The system's flexibility allows mixing movement modes within the same application, with each object configured for its specific interaction requirements.
229+
The system's flexibility allows mixing movement modes within the same application, with each object configured for its specific interaction requirements.

docs/concepts/grabbing/index.md

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ title: Grabbing Overview
77
Interactive object manipulation is foundational to immersive experiences. IWSDK provides a comprehensive grabbing system that enables natural, performant object interaction through three distinct manipulation patterns—each optimized for different use cases and comfort requirements.
88

99
- **One-Hand Grabbing** — Direct single input manipulation for basic interactions
10-
- **Two-Hand Grabbing** — Dual-hand manipulation with scaling capabilities for precise control
10+
- **Two-Hand Grabbing** — Dual-hand manipulation with scaling capabilities for precise control
1111
- **Distance Grabbing** — Ray-based remote manipulation with telekinetic-style interactions
1212

1313
Under the hood, the system bridges IWSDK's ECS architecture with the `@pmndrs/handle` library, providing automatic handle lifecycle management, performance optimizations, and seamless integration with the input system.
@@ -37,7 +37,7 @@ The grabbing system operates through a unified `GrabSystem` that automatically c
3737
Entity with Grabbable Component
3838
3939
GrabSystem detects via queries
40-
40+
4141
Creates HandleStore instance
4242
4343
Configures pointer events & constraints
@@ -59,16 +59,19 @@ The system uses reactive ECS queries to manage handle creation and cleanup:
5959
## Core Design Principles
6060

6161
### Automatic Integration
62+
6263
- The system discovers grabbable entities through ECS queries rather than manual registration
6364
- Handle creation, updates, and cleanup happen automatically based on component presence
6465
- Multi-pointer coordination (left/right hand sub-pointers) is enabled automatically when the system is active
6566

6667
### Constraint-Based Control
68+
6769
- All transformation types (rotate, translate, scale) support per-axis min/max constraints
6870
- Specialized movement modes provide different manipulation semantics
6971
- Pointer event filtering prevents interaction conflicts
7072

7173
### Seamless Library Integration
74+
7275
- Acts as a bridge between IWSDK's ECS and `@pmndrs/handle`'s imperative API
7376
- Translates component data into handle configurations automatically
7477
- Maintains separation of concerns between interaction logic and ECS lifecycle
@@ -94,23 +97,26 @@ World.create(document.getElementById('scene-container'), {
9497
entity.addComponent(OneHandGrabbable, {
9598
rotate: true,
9699
translate: true,
97-
rotateMin: [-Math.PI/4, -Math.PI, -Math.PI/4],
98-
rotateMax: [Math.PI/4, Math.PI, Math.PI/4],
100+
rotateMin: [-Math.PI / 4, -Math.PI, -Math.PI / 4],
101+
rotateMax: [Math.PI / 4, Math.PI, Math.PI / 4],
99102
});
100103
});
101104
```
102105

103106
## When to Use Which Pattern
104107

105108
### One-Hand Grabbing
109+
106110
- Direct manipulation with immediate response
107111
- Best for: tools, simple objects, quick interactions
108112

109-
### Two-Hand Grabbing
113+
### Two-Hand Grabbing
114+
110115
- Advanced manipulation including scaling operations
111116
- Best for: resizable objects, precise positioning, complex manipulation
112117

113118
### Distance Grabbing
119+
114120
- Remote manipulation with specialized movement algorithms
115121
- Best for: out-of-reach objects, magical interactions, telekinetic experiences
116122

@@ -128,4 +134,4 @@ The grabbing system integrates with multiple IWSDK systems:
128134
## Next Steps
129135

130136
- [Interaction Types](/concepts/grabbing/interaction-types) — Understanding the three grabbing patterns
131-
- [Distance Grabbing](/concepts/grabbing/distance-grabbing) — Deep dive into movement modes and algorithms
137+
- [Distance Grabbing](/concepts/grabbing/distance-grabbing) — Deep dive into movement modes and algorithms

docs/concepts/grabbing/interaction-types.md

Lines changed: 27 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -23,17 +23,21 @@ The system creates a standard `HandleStore` with constraints derived directly fr
2323
```ts
2424
// Simplified handle creation from GrabSystem
2525
const handle = new HandleStore(object, () => ({
26-
rotate: entity.getValue(OneHandGrabbable, 'rotate') ? {
27-
x: [rotateMin[0], rotateMax[0]],
28-
y: [rotateMin[1], rotateMax[1]],
29-
z: [rotateMin[2], rotateMax[2]]
30-
} : false,
31-
translate: entity.getValue(OneHandGrabbable, 'translate') ? {
32-
x: [translateMin[0], translateMax[0]],
33-
y: [translateMin[1], translateMax[1]],
34-
z: [translateMin[2], translateMax[2]]
35-
} : false,
36-
multitouch: false // Single pointer only
26+
rotate: entity.getValue(OneHandGrabbable, 'rotate')
27+
? {
28+
x: [rotateMin[0], rotateMax[0]],
29+
y: [rotateMin[1], rotateMax[1]],
30+
z: [rotateMin[2], rotateMax[2]],
31+
}
32+
: false,
33+
translate: entity.getValue(OneHandGrabbable, 'translate')
34+
? {
35+
x: [translateMin[0], translateMax[0]],
36+
y: [translateMin[1], translateMax[1]],
37+
z: [translateMin[2], translateMax[2]],
38+
}
39+
: false,
40+
multitouch: false, // Single pointer only
3741
}));
3842
```
3943

@@ -65,7 +69,7 @@ Dual-input manipulation enabling advanced operations including scaling through m
6569
Two-hand grabbing uses the relationship between controllers to derive transformations:
6670

6771
- **Translation**: Controlled by primary hand position
68-
- **Rotation**: Derived from the orientation relationship between hands
72+
- **Rotation**: Derived from the orientation relationship between hands
6973
- **Scaling**: Based on the distance between controllers — closer hands reduce scale, farther hands increase scale
7074

7175
### Implementation Details
@@ -78,7 +82,7 @@ const handle = new HandleStore(object, () => ({
7882
translate: /* translation constraints */,
7983
scale: entity.getValue(TwoHandsGrabbable, 'scale') ? {
8084
x: [scaleMin[0], scaleMax[0]],
81-
y: [scaleMin[1], scaleMax[1]],
85+
y: [scaleMin[1], scaleMax[1]],
8286
z: [scaleMin[2], scaleMax[2]]
8387
} : false,
8488
multitouch: true // Enables dual-pointer processing
@@ -113,13 +117,15 @@ Ray-based remote manipulation with specialized movement algorithms for telekinet
113117
Distance grabbing implements four distinct movement algorithms:
114118

115119
#### MoveTowardsTarget Algorithm
120+
116121
```ts
117122
// From DistanceGrabHandle.update()
118123
const pointerOrigin = p1.pointerWorldOrigin;
119124
const distance = pointerOrigin.distanceTo(position);
120125

121126
if (distance > this.moveSpeed) {
122-
const step = pointerOrigin.sub(position)
127+
const step = pointerOrigin
128+
.sub(position)
123129
.normalize()
124130
.multiplyScalar(this.moveSpeed);
125131
position.add(step);
@@ -130,7 +136,8 @@ if (distance > this.moveSpeed) {
130136
}
131137
```
132138

133-
#### MoveAtSource Algorithm
139+
#### MoveAtSource Algorithm
140+
134141
```ts
135142
// Delta-based movement tracking
136143
const current = p1.pointerWorldOrigin;
@@ -142,6 +149,7 @@ this.previousPointerOrigin.copy(current);
142149
```
143150

144151
#### MoveFromTarget & RotateAtSource
152+
145153
- **MoveFromTarget**: Direct 1:1 mapping with ray endpoint (delegates to standard handle)
146154
- **RotateAtSource**: Rotation-only mode with automatic translation/scale disabling
147155

@@ -165,7 +173,7 @@ The `returnToOrigin` feature overrides the standard handle application:
165173
// From DistanceGrabHandle.apply()
166174
if (this.returnToOrigin && this.outputState?.last) {
167175
target.position.copy(this.initialTargetPosition);
168-
target.quaternion.copy(this.initialTargetQuaternion);
176+
target.quaternion.copy(this.initialTargetQuaternion);
169177
target.scale.copy(this.initialTargetScale);
170178
return; // Skip standard handle application
171179
}
@@ -180,7 +188,7 @@ if (this.returnToOrigin && this.outputState?.last) {
180188
### Best Use Cases
181189

182190
- Out-of-reach objects in large environments
183-
- Magical or supernatural interaction themes
191+
- Magical or supernatural interaction themes
184192
- Accessibility — reaching objects without physical movement
185193
- Telekinetic gameplay mechanics
186194

@@ -189,7 +197,7 @@ if (this.returnToOrigin && this.outputState?.last) {
189197
### Interaction Context
190198

191199
- **Immediate objects**: Use direct grabbing (one/two-hand)
192-
- **Remote objects**: Use distance grabbing
200+
- **Remote objects**: Use distance grabbing
193201
- **Resizable content**: Requires two-hand grabbing
194202
- **Tool-like objects**: Usually one-hand grabbing
195203

@@ -201,4 +209,4 @@ Most applications combine multiple grabbing types:
201209
- **Workshop Environment**: Tools (one-hand), Workpieces (two-hand), Stored materials (distance)
202210
- **Gaming Context**: Weapons (one-hand), Interactive objects (two-hand), Magic items (distance)
203211

204-
The system's automatic handle management makes it seamless to use different grabbing types on different objects within the same scene.
212+
The system's automatic handle management makes it seamless to use different grabbing types on different objects within the same scene.

docs/guides/10-spatial-ui-uikitml.md

Lines changed: 18 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -64,9 +64,9 @@ import { compileUIKit } from '@iwsdk/vite-plugin-uikitml';
6464
export default defineConfig({
6565
plugins: [
6666
compileUIKit({
67-
sourceDir: 'ui', // Directory containing .uikitml files
68-
outputDir: 'public/ui', // Where compiled .json files are written
69-
verbose: true, // Enable build logging
67+
sourceDir: 'ui', // Directory containing .uikitml files
68+
outputDir: 'public/ui', // Where compiled .json files are written
69+
verbose: true, // Enable build logging
7070
}),
7171
],
7272
});
@@ -127,7 +127,7 @@ import * as horizonKit from '@pmndrs/uikit-horizon';
127127
World.create(document.getElementById('scene-container'), {
128128
features: {
129129
spatialUI: {
130-
kits: [horizonKit]
130+
kits: [horizonKit],
131131
},
132132
},
133133
});
@@ -144,7 +144,7 @@ import * as defaultKit from '@pmndrs/uikit-default';
144144
World.create(document.getElementById('scene-container'), {
145145
features: {
146146
spatialUI: {
147-
kits: [horizonKit, defaultKit]
147+
kits: [horizonKit, defaultKit],
148148
},
149149
},
150150
});
@@ -156,15 +156,19 @@ For large icon libraries like `@pmndrs/uikit-lucide` (which contains over 1000 i
156156

157157
```typescript
158158
import * as horizonKit from '@pmndrs/uikit-horizon';
159-
import { LogInIcon, RectangleGogglesIcon, SettingsIcon } from '@pmndrs/uikit-lucide';
159+
import {
160+
LogInIcon,
161+
RectangleGogglesIcon,
162+
SettingsIcon,
163+
} from '@pmndrs/uikit-lucide';
160164

161165
World.create(document.getElementById('scene-container'), {
162166
features: {
163167
spatialUI: {
164168
kits: [
165169
horizonKit,
166-
{ LogInIcon, RectangleGogglesIcon, SettingsIcon } // Only these icons
167-
]
170+
{ LogInIcon, RectangleGogglesIcon, SettingsIcon }, // Only these icons
171+
],
168172
},
169173
},
170174
});
@@ -186,7 +190,7 @@ import { ColorSchemeType } from '@iwsdk/core';
186190
World.create(document.getElementById('scene-container'), {
187191
features: {
188192
spatialUI: {
189-
preferredColorScheme: ColorSchemeType.Dark, // Force dark mode
193+
preferredColorScheme: ColorSchemeType.Dark, // Force dark mode
190194
},
191195
},
192196
});
@@ -203,7 +207,9 @@ World.create(document.getElementById('scene-container'), {
203207
You can dynamically change the color scheme after initialization:
204208

205209
```typescript
206-
const world = await World.create(container, { /* ... */ });
210+
const world = await World.create(container, {
211+
/* ... */
212+
});
207213
const panelSystem = world.getSystem(PanelUISystem);
208214

209215
// Switch to light mode
@@ -223,13 +229,13 @@ Use the `:dark` pseudo-selector to define styles that apply only in dark mode:
223229
```html
224230
<style>
225231
.heading {
226-
color: #272727; /* Light mode color */
232+
color: #272727; /* Light mode color */
227233
font-size: 24px;
228234
font-weight: 700;
229235
}
230236
231237
.heading:dark {
232-
color: rgba(255, 255, 255, 0.9); /* Dark mode color */
238+
color: rgba(255, 255, 255, 0.9); /* Dark mode color */
233239
}
234240
235241
.panel {

docs/guides/11-scene-understanding.md

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -528,4 +528,3 @@ class MeshSystem extends createSystem({
528528
}
529529
}
530530
```
531-

docs/guides/12-physics.md

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -506,4 +506,3 @@ cd examples/physics
506506
pnpm install
507507
pnpm dev
508508
```
509-

0 commit comments

Comments
 (0)