I would like to download the USDZ 3D model from the web server within the visionOS app and display it with the Shared Space volumetric window which size set to fit the downloaded USDZ model.
Currently, after downloading USDZ and generating it as a Model Entity, Using openWindow, the ModelEntity is created as a volumetric WindowGroup in the RealityViewContent of the RealityView using openWindow. The Model Entity generated by downloading USDZ is added to the RealityViewContent of the RealityView in the View called by openWindow.
The USDZ downloaded by the above method appears in the volume on visionOS without any problems. However, the proportions of the USDZ tv model to be downloaded is not uniform, so it's not fit in the volume. The AR Quick Look in visionOS, however, scales the USDZ to its full size without missing any USDZ display when 100% is specified.
If there is any information on how to properly set the position and size of the USDZ files created by RealityKit for visionOS, I would appreciate it.
Solution
The method
defaultSize(..)
is called on the WindowGroup object long before your model is downloaded from the website, and today, the size of a SwiftUI's volumetric window in visionOS is immutable after creation.However, there is a very simple and effective solution that will help you to solve the problem. For that, use
.resizable()
modifier onResolvedModel3D
object that helps you to fill the container with a model. And use.aspectRatio(contentMode: .fit)
group's modifier that helps to maintain proportions of the downloaded model.