-
Notifications
You must be signed in to change notification settings - Fork 58
visionOS sample code: add view model, get Mesh construction off the main thread #116
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
…l platforms", for on-device Vision Pro build. (nicklockwood#114)
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## main #116 +/- ##
=======================================
Coverage 77.36% 77.36%
=======================================
Files 32 32
Lines 8218 8218
=======================================
Hits 6358 6358
Misses 1860 1860 ☔ View full report in Codecov by Sentry. |
ExampleVisionOS/VolumetricView.swift
Outdated
| // for gesture targeting | ||
| demoBoxEntity.components.set(InputTargetComponent()) | ||
| var body: some View { | ||
| let _ = Self._printChanges() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Did you mean to leave this in the sample code?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes. It shows the view's redraw/update as it reacts to the model changes.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
On second thought, it's a distraction. Removed.
ExampleVisionOS/MeshViewModel.swift
Outdated
| entity = demoBoxEntity | ||
| contentReady = true | ||
| } catch { | ||
| print("nope") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Would recommend removing this, leaving an empty catch for clarity, or adding a more explicit logging message that reports that nothing was updated in the background.
| func prepareContent() { | ||
| Task.init { | ||
| do { | ||
| let demoBoxEntity = try await ModelEntity(euclidMesh.scaled(by: 0.5)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Probably not a huge deal, but what about moving euclidMesh into this class? (I always look askance at global functions.)
|
As I get more experience on visionOS, I’m having second thoughts about this PR. The RealityView initialization is already async. I was seeing the placeholder view and thinking it was the equivalent of a beach ball. But nothing’s blocked, and I think I’ve made this example needlessly complex. I’m working on something different at the moment, will take another crack next week. If someone else wants to run with it you have my blessing. |
ab73495 to
5f6ffe2
Compare
c92a7a4 to
f5f0a69
Compare
bca138c to
067e21d
Compare
95acdc7 to
2ba20cc
Compare
7cb94b0 to
621752f
Compare
392c6d6 to
83149e5
Compare
607b2eb to
96a74b1
Compare
6f25c78 to
6623087
Compare
38d3435 to
82fb502
Compare
6fdcb77 to
db4a794
Compare
8d0ed6a to
841cc30
Compare
ExampleVisionOSnow has a view model, and creates theMeshandEntityinstances on a separate thread. I've added somesleep()time to simulate a long-runningMeshcreation. The sample code now reflects typical SwiftUI patterns used in visionOS and in iOS 17+. No changes made to theEuclidcodebase, just to the sample app.