@iwsdk/xr-input 0.2.2 → 0.3.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 (49) hide show
  1. package/README.md +138 -0
  2. package/dist/gamepad/generated-profiles.d.ts.map +1 -1
  3. package/dist/gamepad/generated-profiles.js +9998 -12843
  4. package/dist/gamepad/generated-profiles.js.map +1 -1
  5. package/dist/index.d.ts +3 -0
  6. package/dist/index.d.ts.map +1 -1
  7. package/dist/index.js +4 -1
  8. package/dist/index.js.map +1 -1
  9. package/dist/node_modules/.pnpm/super-three@0.181.0/node_modules/super-three/src/math/MathUtils.js.map +1 -0
  10. package/dist/pointer/cursor-visual.d.ts +34 -0
  11. package/dist/pointer/cursor-visual.d.ts.map +1 -0
  12. package/dist/pointer/cursor-visual.js +110 -0
  13. package/dist/pointer/cursor-visual.js.map +1 -0
  14. package/dist/pointer/multi-pointer.d.ts +137 -12
  15. package/dist/pointer/multi-pointer.d.ts.map +1 -1
  16. package/dist/pointer/multi-pointer.js +481 -107
  17. package/dist/pointer/multi-pointer.js.map +1 -1
  18. package/dist/pointer/ray-pointer.d.ts +5 -5
  19. package/dist/pointer/ray-pointer.d.ts.map +1 -1
  20. package/dist/pointer/ray-pointer.js +11 -84
  21. package/dist/pointer/ray-pointer.js.map +1 -1
  22. package/dist/pointer/touch-pointer.d.ts +42 -0
  23. package/dist/pointer/touch-pointer.d.ts.map +1 -0
  24. package/dist/pointer/touch-pointer.js +51 -0
  25. package/dist/pointer/touch-pointer.js.map +1 -0
  26. package/dist/rig/xr-origin.d.ts +10 -0
  27. package/dist/rig/xr-origin.d.ts.map +1 -1
  28. package/dist/rig/xr-origin.js +11 -1
  29. package/dist/rig/xr-origin.js.map +1 -1
  30. package/dist/version.d.ts +1 -1
  31. package/dist/visual/adapter/hand-visual-adapter.d.ts +5 -0
  32. package/dist/visual/adapter/hand-visual-adapter.d.ts.map +1 -1
  33. package/dist/visual/adapter/hand-visual-adapter.js +7 -0
  34. package/dist/visual/adapter/hand-visual-adapter.js.map +1 -1
  35. package/dist/visual/impl/animated-controller-hand.js +1 -1
  36. package/dist/visual/utils/flex-batched-mesh.d.ts.map +1 -1
  37. package/dist/visual/utils/flex-batched-mesh.js +10 -5
  38. package/dist/visual/utils/flex-batched-mesh.js.map +1 -1
  39. package/dist/visual/utils/simple-batched-mesh.d.ts +47 -0
  40. package/dist/visual/utils/simple-batched-mesh.d.ts.map +1 -0
  41. package/dist/visual/utils/simple-batched-mesh.js +389 -0
  42. package/dist/visual/utils/simple-batched-mesh.js.map +1 -0
  43. package/dist/xr-input-manager.d.ts +5 -0
  44. package/dist/xr-input-manager.d.ts.map +1 -1
  45. package/dist/xr-input-manager.js +24 -0
  46. package/dist/xr-input-manager.js.map +1 -1
  47. package/package.json +1 -1
  48. package/dist/node_modules/.pnpm/super-three@0.177.0/node_modules/super-three/src/math/MathUtils.js.map +0 -1
  49. /package/dist/node_modules/.pnpm/{super-three@0.177.0 → super-three@0.181.0}/node_modules/super-three/src/math/MathUtils.js +0 -0
package/README.md ADDED
@@ -0,0 +1,138 @@
1
+ # @iwsdk/xr-input
2
+
3
+ WebXR input system for Three.js applications. Provides controller and hand tracking support with visual adapters, input profiles, and seamless pointer event integration.
4
+
5
+ ## Features
6
+
7
+ - 🎮 **Controller Support** - Automatic controller model loading with input profiles
8
+ - ✋ **Hand Tracking** - Full hand skeleton tracking with joint positions
9
+ - 👆 **Pointer Events** - Integration with @pmndrs/pointer-events for spatial interaction
10
+ - 📋 **Input Profiles** - Pre-configured profiles for Meta Quest controllers
11
+ - 🎨 **Visual Adapters** - Animated controller and hand mesh rendering
12
+ - 🔄 **Hot-Swapping** - Seamless switching between controllers and hands
13
+
14
+ ## Installation
15
+
16
+ ```bash
17
+ npm install @iwsdk/xr-input three
18
+ ```
19
+
20
+ ## Quick Start
21
+
22
+ ```typescript
23
+ import { XRInputManager } from '@iwsdk/xr-input';
24
+ import { PerspectiveCamera, Scene, WebGLRenderer } from 'three';
25
+
26
+ const scene = new Scene();
27
+ const camera = new PerspectiveCamera(75, window.innerWidth / window.innerHeight);
28
+ const renderer = new WebGLRenderer({ xr: { enabled: true } });
29
+
30
+ // Create the input manager
31
+ const inputManager = new XRInputManager({
32
+ scene,
33
+ camera,
34
+ });
35
+
36
+ // Add XR origin to scene
37
+ scene.add(inputManager.xrOrigin);
38
+
39
+ // In your render loop
40
+ renderer.setAnimationLoop((time, frame) => {
41
+ const delta = /* calculate delta */;
42
+
43
+ // Update input manager with XR state
44
+ inputManager.update(renderer.xr, delta, time);
45
+
46
+ renderer.render(scene, camera);
47
+ });
48
+ ```
49
+
50
+ ## Accessing Controllers
51
+
52
+ ```typescript
53
+ // Get visual adapters for left/right
54
+ const leftAdapter = inputManager.visualAdapters.left.value;
55
+ const rightAdapter = inputManager.visualAdapters.right.value;
56
+
57
+ // Check if using controller or hand
58
+ if (leftAdapter?.type === 'controller') {
59
+ // Controller is active
60
+ } else if (leftAdapter?.type === 'hand') {
61
+ // Hand tracking is active
62
+ }
63
+ ```
64
+
65
+ ## Gamepad Input
66
+
67
+ ```typescript
68
+ import { StatefulGamepad } from '@iwsdk/xr-input';
69
+
70
+ // Access gamepads (available after update)
71
+ const leftGamepad = inputManager.gamepads.left;
72
+ const rightGamepad = inputManager.gamepads.right;
73
+
74
+ if (rightGamepad) {
75
+ // Button states
76
+ const triggerPressed = rightGamepad.getButtonDown('xr-standard-trigger');
77
+ const gripPressed = rightGamepad.getButtonDown('xr-standard-squeeze');
78
+
79
+ // Thumbstick values
80
+ const thumbstick = rightGamepad.getAxes('xr-standard-thumbstick');
81
+ console.log(thumbstick.x, thumbstick.y);
82
+
83
+ // Button events (pressed this frame)
84
+ if (rightGamepad.getSelectStart()) {
85
+ console.log('Trigger just pressed');
86
+ }
87
+ }
88
+ ```
89
+
90
+ ## Multi-Pointer System
91
+
92
+ ```typescript
93
+ // Access multi-pointer for spatial interactions
94
+ const leftPointer = inputManager.multiPointers.left;
95
+ const rightPointer = inputManager.multiPointers.right;
96
+
97
+ // Pointers integrate with @pmndrs/pointer-events
98
+ // They automatically handle ray and grab pointers
99
+ ```
100
+
101
+ ## XR Origin
102
+
103
+ The `XROrigin` provides the tracked reference space:
104
+
105
+ ```typescript
106
+ const xrOrigin = inputManager.xrOrigin;
107
+
108
+ // Access head position
109
+ const headPosition = xrOrigin.head.position;
110
+ const headRotation = xrOrigin.head.quaternion;
111
+
112
+ // Access controller/hand positions via visual adapters
113
+ const rightHand = inputManager.visualAdapters.right.value;
114
+ if (rightHand) {
115
+ const position = rightHand.getPosition();
116
+ const rotation = rightHand.getQuaternion();
117
+ }
118
+ ```
119
+
120
+ ## Supported Devices
121
+
122
+ - Meta Quest 2
123
+ - Meta Quest 3
124
+ - Meta Quest Pro
125
+ - Oculus Quest 1
126
+ - Generic WebXR controllers
127
+
128
+ ## Peer Dependencies
129
+
130
+ - `three` >= 0.160.0
131
+
132
+ ## Documentation
133
+
134
+ For more information, visit: **[https://iwsdk.dev](https://iwsdk.dev)**
135
+
136
+ ## License
137
+
138
+ MIT © Meta Platforms, Inc.
@@ -1 +1 @@
1
- {"version":3,"file":"generated-profiles.d.ts","sourceRoot":"","sources":["../../src/gamepad/generated-profiles.ts"],"names":[],"mappings":"AAIA,MAAM,WAAW,gBAAgB;IAC/B,IAAI,EAAE,MAAM,CAAC;IACb,UAAU,CAAC,EAAE,OAAO,CAAC;CACtB;AAED,MAAM,MAAM,YAAY,GAAG,MAAM,CAAC,MAAM,EAAE,gBAAgB,CAAC,CAAC;AAE5D,eAAO,MAAM,aAAa,EAAE,YAgI3B,CAAC;AAEF,eAAO,MAAM,YAAY,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAgtZ5C,CAAC;AAEF,wBAAgB,UAAU,CAAC,WAAW,EAAE,MAAM,GAAG,GAAG,CAMnD;AAED,wBAAgB,eAAe,IAAI,YAAY,CAE9C"}
1
+ {"version":3,"file":"generated-profiles.d.ts","sourceRoot":"","sources":["../../src/gamepad/generated-profiles.ts"],"names":[],"mappings":"AAIA,MAAM,WAAW,gBAAgB;IAC/B,IAAI,EAAE,MAAM,CAAC;IACb,UAAU,CAAC,EAAE,OAAO,CAAC;CACtB;AAED,MAAM,MAAM,YAAY,GAAG,MAAM,CAAC,MAAM,EAAE,gBAAgB,CAAC,CAAC;AAE5D,eAAO,MAAM,aAAa,EAAE,YAgI3B,CAAC;AAEF,eAAO,MAAM,YAAY,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAm7T5C,CAAC;AAEF,wBAAgB,UAAU,CAAC,WAAW,EAAE,MAAM,GAAG,GAAG,CAMnD;AAED,wBAAgB,eAAe,IAAI,YAAY,CAE9C"}