Now that you have successfully integrated the echo3D SDK into Xcode, it's time to display a model in your project!
Scene Kit is a rendering engine that allows you to develop native iOS and visioOS apps in Xcode.
Adding 3D content
Add a model asset through the console. Here's how:
Setting Up an Application
Construct an object of type Echo3D and use it to access Assets stored under your echo3D account's API Key.
Render your assets however you want.
Example Setup:
importSwiftUIimportSceneKitstructContentView:View { // Creates a SwiftUI Viewvar body: some View { // Creates a SwiftUI bodyVStack {Text("View Your Echo3D Model!") .font(.headline)SceneKitView() .frame(width:350, height:350)// Adjust the size as needed } }}structSceneKitView:UIViewRepresentable { // Creates the Scene with 3D Model using SceneKit and Echo3D Swift SDKfuncmakeUIView(context: Context) -> SCNView { // Creates a simple scenelet sceneView =SCNView() sceneView.autoenablesDefaultLighting =true sceneView.allowsCameraControl =truereturn sceneView } func updateUIView(_ sceneView: SCNView, context: Context) { // Adds 3D Model stored under your Echo3D Accounts API Key
let e =Echo3D(); // Create an object of class Echo3D e.queryDatabase(api_key: e.api_key, completion: { (entry_list) -> () in // Queries Echo3D's database for 3d Models
let entry = entry_list[0] entry.downloadFile(completion: { (storage_id) in // Downloads the specificed 3D model entry and loads it into the scene
iflet object =try?SCNScene(url: storage_id, options:nil) {let objectNode = object.rootNode sceneView.scene = object sceneView.scene?.rootNode.addChildNode(objectNode) } }); }); }}@mainstructSDKTest2_6App:App {var body: some Scene {WindowGroup {ContentView() } }}