RealityView not displaying content

I'm playing with visionOS and trying to get a usdz file to load in a RealityView. It works fine if I use a Model3D but if I use a RealityView nothing shows up. I'm just using the fender_stratocaster asset right off the apple web site so it seems like it should work. This is the code:

            RealityView { content in
                if let sphereEntity = try? await Entity(named: "fender_stratocaster") {
                    content.add(sphereEntity)
                    sphereEntity.position = [0,0,0]
                    sphereEntity.transform.scale = [scale, scale, scale]
                    let _ = print(sphereEntity)
                }
            } update: { content in
                if let sphereEntity = content.entities.first {
                    sphereEntity.transform.scale = [scale, scale, scale]
                }

Any clues as to why this is not showing would be appreciated.

Hi @jim_rain

Your overall approach looks correct. Here are a few troubleshooting tips:

  • Make sure the entity successfully loads. Try wrapping if let sphereEntity = try? await Entity(named: "fender_stratocaster") in a do/catch block and printing the error. Since you do not specify a bundle, the usd has to be in your application's main bundle. Make sure the file is there, correctly named and has the appropriate extension (.usd, .usda, .usdc, .usdz or .reality). Note, if the file is in your project's Reality Composer Pro project you will need to specify a bundle via the in parameter, for example: try? await Entity(named: "fender_stratocaster", in: realityKitContentBundle).

  • What's the value of scale? Try removing the scale related code to see if that's the cause.

If none of the above works, please reply with a link to the usd file and I'll help you.

I added error checking and also print "success" when the call is call to init the entity is successful. I see success every time. I removed the code for "scaling" and the made the usdz file from apple work. So then I changed to one that I downloaded from sketchfab - here is the link: https://sketchfab.com/search?q=Amethyst_Trunced_Dodecahedron&type=models And that one does not show. I downloaded this and added it to my main bundle. This works with Model3D. I'm not sure if this will be helpful but I print the entity object after a successful load and this is what I see: Success ▿ '' : Entity, children: 1 ⟐ Transform ⟐ SynchronizationComponent ⟐ AnimationLibraryComponent ▿ 'scene' : Entity, children: 1 ⟐ Transform ⟐ SynchronizationComponent ⟐ AnimationLibraryComponent ▿ 'Meshes' : Entity, children: 1 ⟐ Transform ⟐ SynchronizationComponent ⟐ AnimationLibraryComponent ▿ 'Sketchfab_model' : Entity, children: 1 ⟐ Transform ⟐ SynchronizationComponent ⟐ AnimationLibraryComponent ▿ 'root' : Entity, children: 1 ⟐ Transform ⟐ SynchronizationComponent ⟐ AnimationLibraryComponent ▿ 'GLTF_SceneRootNode' : Entity, children: 1 ⟐ Transform ⟐ SynchronizationComponent ⟐ AnimationLibraryComponent ▿ 'Fragment_Icosphere_2' : Entity, children: 2 ⟐ Transform ⟐ SynchronizationComponent ⟐ AnimationLibraryComponent ▿ 'Object_4' : Entity, children: 1 ⟐ Transform ⟐ SynchronizationComponent ▿ 'Object_0' : ModelEntity ⟐ ModelComponent ⟐ Transform ⟐ SynchronizationComponent ▿ 'Object_5' : Entity, children: 1 ⟐ Transform ⟐ SynchronizationComponent ▿ 'Object_1' : ModelEntity ⟐ ModelComponent ⟐ Transform ⟐ SynchronizationComponent

Updating

I could really use some help here. I tried to simplify this as much as possible so I created a bare bones app with the standard template for a volumetric view. I downloaded this usdz file from Apple.com: https://developer.apple.com/augmented-reality/quick-look/models/stratocaster/fender_stratocaster.usdz

I copied that to asset to my main app bundle. I load it with this code:

            RealityView { content in

                // Add the initial RealityKit content

                if let scene = try? await Entity(named: "fender_stratocaster") {
                    print("success!")
                    content.add(scene)
                }

But when I run it on the simulator or the device I see "success" in the console but I don't see the image.

RealityView not displaying content
 
 
Q