Contents

init(url:)

Loads and displays a model from the specified URL.

Declaration

nonisolated init(url: URL) where Content == ResolvedModel3D

Parameters

  • url:

    The URL of the model to display.

Discussion

Until the model loads, SwiftUI displays a default placeholder. When the load operation completes successfully, SwiftUI updates the view to show the loaded model. If the operation fails, SwiftUI continues to display the placeholder. The following example loads and displays a model from an example server:

Model3D(url: URL(string: "https://example.com/robot.usdz")!)

If you want to customize the placeholder or apply Model3D-specific modifiers — like ResolvedModel3D/resizable() — to the loaded model, use the init(url:content:placeholder:) initializer instead.

See Also

Creating a Model3D