Hi, currently tinkering with a little shareplay app for the Vision Pro that allows people to facetime and shareplay to play with random 3d models (as well as move them around, which should sync the model positions for everyone in relative space).
When the users start their facetime call, then open the immersive space to see the 3d models, the models load in properly in context of the group immersive space's coordinate system, and moving the models reflects the new positions real-time for each participant.
The main issue comes if/when users use the digital crown to re-center their view. It appears to re-center the model and view, which is expected. However, it also seems to re-position the model/root entity to match the user's origin. Not sure if this is intentional or not, but this essentially makes it so that it "de-syncs" the model (so me moving the model next to someone does not reflect it 1:1 - it still moves properly, but the new "initial" position after re-centering makes it offset).
Is there a potential solution or work-around for this such that re-centering the view doesn't de-sync the model/entity's position?
Rough code for my RealityView component is below:
RealityView { content, attachments in
content.add(appModel.originEntity)
appModel.originEntity.addChild(appModel.modelContainerEntity)
appModel.setInitialModelPosition()
configureGestures(forModel: appModel.modelContainerEntity)
configureToolbarAttachment(content: content, attachments: attachments)
} update: { content, _ in
// I have modified the Apple provided gesture components to
// send the app model the new positions/rotations
// as well as broadcast the position/rotation to shareplay participants
// When user re-centers view, it seems to also re-position the model
// so that its origin is at the local user's origin, rather than
// the original origin
// Can we receive a notification that user has re-centered view?
// Or some other work-around?
appModel.modelContainerEntity.setPosition(appModel.modelState.position, relativeTo: nil)
appModel.modelContainerEntity.setOrientation(.init(appModel.modelState.rotation3d), relativeTo: nil)
} attachments: {
Attachment(id: "customViewAttachment") {
CustomView()
}
}
.installGestures()
Please let me know if anything wasn't clear or if more information is needed. Thanks!
Thanks for the context. I’m less convinced immersiveSpaceDisplacement
will solve this issue. Pressing the digital crown should not change the shared origin for the group activity and it shouldn’t change an entity’s transform relative to that origin.
Here's my understanding of the issue. Please let me know if I'm holding it wrong.
Your app allows participants in a group activity to manipulate entities in an immersive space. An entity’s transform (position, rotation, scale) should be consistently posititioned relatvie to all the participants. For example, given 2 participants, A and B, and a toy car, if the toy car is in front of participant A, participant B should see it in font of participant A. Initally this works, but when participant B walks acroos the room and presses the digital crown, the toy car no longer appears in front of participant A (it appears offset). Subsiquent moves to the toy car are synced, but are offset since pressing the digital crown offset them.
Suggestions to try if you haven't already:
- The shared root seems like a likely culprit since a disparity (across participants) in its transform would cause a uniform shift of all its children. Are you sure the root's transform is consistent for all participants?
- Be sure the participant is spatial before syncing their position.
- Try simplifying the experience then slowly layer back in the complexity. Reduce things to a single entity with no shared parent. Does pressing the digital crown still cause the shift? Next add, syncing to one entity (no shared parent) and make the same observation.
- Revisit this session and this article. Maybe it'll spark something.
If none of that works, please file a bug via feedback assistant with a project that recreates the issue in a focused manor and reply with a link to it.