A Mixed Reality magic wand application for visionOS, powered by Logitech MUSE spatial stylus. Transform your MUSE into a wand with haptic feedback, motion detection, and physics interactions.
MagicWand demonstrates advanced visionOS capabilities including:
- Spatial Tracking: Real-time 6DOF tracking of Logitech MUSE stylus
- Haptic Feedback: Dual-intensity haptics for motion and impact
- Motion Detection: Velocity-based swing detection
- Physics Interactions: Collision detection with RealityKit entities
- Visual Effects: Particle effects and dynamic color cycling
- Color Cycling: 6 vibrant colors (White, Blue, Green, Red, Purple, Yellow)
- Extension/Retraction: Smooth animation between collapsed and extended states
- Glowing Effect: UnlitMaterial for glow
- Swing Detection: Velocity-based motion detection (threshold: 0.8 m/s)
- Light Haptic: Subtle feedback when swinging the wand (intensity: 0.3)
- Impact Haptic: Strong feedback on collision (intensity: 1.0)
- Collision Detection: RealityKit physics-based collision system
- Target Destruction: Hit floating spheres to trigger particle effects
- Particle Effects: Color-matched explosion effects on impact
- Visual Markers: Red (tip), Green (center), Blue (tail) debug cubes
- Position Logging: Real-time position and velocity logging
- Toggle Controls: Easy debug mode switching
- Apple Vision Pro (visionOS 26 or later)
- Logitech MUSE (Spatial Stylus)
- Xcode 26.0+
- Swift 6.2+
- visionOS SDK 26+
The app requires the following entitlements (already configured):
<key>NSAccessorySetupKitSupport</key>
<true/>git clone https://github.com/alohayos/MagicWands.git
cd MagicWandopen MagicWand.xcodeproj- Power on your Logitech MUSE
- Pair with Vision Pro via Bluetooth Settings
- Ensure MUSE is connected before launching the app
- Select "MagicWand" scheme
- Choose "Apple Vision Pro" or "Designed for iPad (visionOS)" destination
- Press
Cmd + Rto build and run
| Input | Action |
|---|---|
| Upper Side Button | Cycle wand color |
| Lower Side Button | Extend/Retract wand |
| Swing Motion | Trigger light haptic feedback |
| Hit Target | Destroy sphere with particle effect |
- Launch App: Tap "Toggle Immersive Space" button in the volumetric window
- MUSE Detection: App automatically detects and connects to MUSE
- Extend Wand: Press lower side button to extend the wand
- Start Playing: Swing the wand and hit floating targets
Toggle debug visualization with the "Debug" button in the UI:
- Red Cube: MUSE tip position (0, 0, 0)
- Green Cube: MUSE center position
- Blue Cube: MUSE tail position
Enable position logging to see real-time tracking data in Xcode console.
- RealityKit: 3D rendering and physics simulation
- ARKit: Spatial tracking session and accessory anchoring
- GameController: MUSE device integration and input handling
- CoreHaptics: Haptic feedback patterns
- SwiftUI: UI and app structure
- AccessoryAnchoringSource: MUSE position tracking
- AnchorEntity: Entity anchoring to MUSE location
- PhysicsBodyComponent: Collision detection (kinematic wand vs dynamic targets)
- CollisionComponent: Collision shape and filtering
- ParticleEmitterComponent: Particle effects on impact
- CHHapticEngine: Dual-pattern haptic feedback
- AppModel: Observable app-wide state management
- WandModel: MUSE tracking, motion detection, and wand state
- HapticsModel: Haptic pattern creation and triggering
- ImmersiveView: RealityKit scene and collision handling
MagicWand/
βββ MagicWand/
β βββ MagicWandApp.swift # App entry point
β βββ AppModel.swift # App state management
β βββ ContentView.swift # Volumetric window UI
β βββ ImmersiveView.swift # Immersive space scene
β βββ WandModel.swift # MUSE tracking & wand logic
β βββ HapticsModel.swift # Haptic feedback management
β βββ ToggleImmersiveSpaceButton.swift
β βββ ToggleDebugButton.swift
β βββ TogglePositionLoggingButton.swift
βββ Packages/
β βββ RealityKitContent/ # RealityKit assets package
β βββ Sources/
β βββ RealityKitContent.rkassets/
β βββ Immersive.usda # Immersive scene
βββ docs/
If MUSE tracking stops working after any of the following events, power cycle the MUSE (OFF β ON):
- visionOS Restart: Tracking session disconnects
- App Crash: Spatial tracking session not properly terminated
- Long Sleep: Coordinate system may reset after wake
- Repeated Connections: Bluetooth connection becomes unstable
Symptom: The wand entity occasionally jumps to incorrect positions (typically 6-11cm offset) while maintaining correct orientation. The position then spontaneously corrects itself after continued movement.
Root Cause: This is a visionOS/MUSE hardware tracking limitation, not an application-level issue. Our investigation revealed:
-
Hardware/OS Level Issue: Debug logging shows the
AnchorEntityposition itself jumps, proving the instability originates from visionOS's accessory tracking system, not our RealityKit implementation. -
Verified Tracking Modes: Both
.predicted(low latency, prediction-based) and.continuous(higher latency, measurement-only) tracking modes exhibit the same instability..continuousonly adds latency without improving stability. -
Verified Anchor Locations: Testing both
"aim"(stylus tip) and"origin"(grip position ~5cm from tip) anchor locations shows identical instability patterns. -
Proper Implementation Verified: The RealityKit entity hierarchy (AnchorEntity β wandModel β debug cubes) correctly maintains relative positions with 0.000m offset, confirming our implementation follows Apple's best practices.
Why Software Mitigation Isn't Feasible:
- Smoothing filters would introduce lag and misalignment during actual movement
- Jump threshold filters would cause the wand to "stick" at incorrect positions
- The tracking jumps are unpredictable in timing and magnitude (6-11cm)
- Any software correction risks degrading the user experience more than the original issue
Possible Hardware/OS Causes:
- IMU (Inertial Measurement Unit) sensor precision limits in MUSE hardware
- Visual-inertial fusion algorithm accuracy in visionOS spatial tracking
- Prediction model errors during rapid motion in
.predictedmode - Environmental factors affecting optical tracking (lighting, reflections)
Status: This issue has been reported to Apple via Feedback Assistant (FB22487954) and requires a fix at the visionOS or MUSE firmware level.
Workaround: Game design can minimize impact through larger hit boxes, visual effects (glowing trails), and strong haptic feedback to compensate for occasional visual misalignment.
Contributions are welcome! Please feel free to submit a Pull Request.
- Follow Swift 6 concurrency best practices (@MainActor, sendable)
- Use structured concurrency (async/await, Task)
- Add comprehensive code comments
- Test on real Vision Pro hardware with MUSE
MIT License
Copyright (c) 2026 Yos
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
- Apple: visionOS, RealityKit, ARKit frameworks
- Logitech: MUSE spatial stylus hardware
- Author: Yos (@alohayos)
- GitHub: https://github.com/alohayos
- Issues: https://github.com/alohayos/MagicWands/issues
Built with β€οΈ for Apple Vision Pro