Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/simonbs/immersivemoveandrotate
Example project showing how an immersive scene on visionOS can contain a RealityView that presents a ModelEntity and how that entity can be dragged using DragGesture and rotated using RotateGesture3D.
https://github.com/simonbs/immersivemoveandrotate
ios swift visionos
Last synced: about 1 month ago
JSON representation
Example project showing how an immersive scene on visionOS can contain a RealityView that presents a ModelEntity and how that entity can be dragged using DragGesture and rotated using RotateGesture3D.
- Host: GitHub
- URL: https://github.com/simonbs/immersivemoveandrotate
- Owner: simonbs
- Created: 2023-08-07T19:52:24.000Z (over 1 year ago)
- Default Branch: main
- Last Pushed: 2024-01-24T09:59:36.000Z (11 months ago)
- Last Synced: 2024-10-29T16:36:52.933Z (about 2 months ago)
- Topics: ios, swift, visionos
- Language: Swift
- Homepage:
- Size: 367 KB
- Stars: 64
- Watchers: 2
- Forks: 3
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- Funding: .github/FUNDING.yml
Awesome Lists containing this project
README
# ImmersiveMoveAndRotate
Example project showing how an immersive scene on visionOS can contain a [RealityView](https://developer.apple.com/documentation/realitykit/realityview/) that presents a [ModelEntity](https://developer.apple.com/documentation/realitykit/modelentity) and how that entity can be dragged using [DragGesture](https://developer.apple.com/documentation/swiftui/draggesture) and rotated using [RotateGesture3D](https://developer.apple.com/documentation/swiftui/rotategesture3d).
This example project deliberately only allows moving the object along the X- and Z-axis to prevent the user from lifting the object from the ground. However, it is straightforward to allow movement along the Y-axis by modifying the code in [EntityMovementViewModifier.swift](https://github.com/simonbs/ImmersiveMoveAndRotate/blob/main/ImmersiveMoveAndRotate/EntityMovementViewModifier.swift).
**Note:** Performing 3D gestures in the simulator is difficult because the simulated gestures are actually performed on a 2D surface. Based on my testing, it appears that the axis around which the gesture rotates depends on the side of the object we are touching and/or the side of the object we are looking at. I expect this to work better on a device.
![](https://github.com/simonbs/ImmersiveMoveAndRotate/blob/main/video.gif?raw=true)