Skip to content

Conversation

@halmueller
Copy link
Contributor

ExampleVisionOS now has a view model, and creates the Mesh and Entity instances on a separate thread. I've added some sleep() time to simulate a long-running Mesh creation. The sample code now reflects typical SwiftUI patterns used in visionOS and in iOS 17+. No changes made to the Euclid codebase, just to the sample app.

@codecov
Copy link

codecov bot commented Mar 13, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 77.36%. Comparing base (1399eec) to head (ae3e6a8).

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.
📢 Have feedback on the report? Share it here.

// for gesture targeting
demoBoxEntity.components.set(InputTargetComponent())
var body: some View {
let _ = Self._printChanges()
Copy link
Contributor

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?

Copy link
Contributor Author

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.

Copy link
Contributor Author

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.

entity = demoBoxEntity
contentReady = true
} catch {
print("nope")
Copy link
Contributor

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))
Copy link

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.)

@halmueller halmueller marked this pull request as draft March 22, 2024 07:21
@halmueller
Copy link
Contributor Author

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.

@nicklockwood nicklockwood force-pushed the main branch 2 times, most recently from ab73495 to 5f6ffe2 Compare July 24, 2024 07:26
@nicklockwood nicklockwood force-pushed the main branch 3 times, most recently from c92a7a4 to f5f0a69 Compare October 9, 2024 17:35
@nicklockwood nicklockwood force-pushed the main branch 4 times, most recently from bca138c to 067e21d Compare April 15, 2025 21:07
@nicklockwood nicklockwood force-pushed the main branch 4 times, most recently from 95acdc7 to 2ba20cc Compare May 10, 2025 17:04
@nicklockwood nicklockwood force-pushed the main branch 3 times, most recently from 7cb94b0 to 621752f Compare May 19, 2025 15:31
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants