1 Reply
      Latest reply on Oct 29, 2019 1:49 PM by gchiste
      rad.bobby Level 1 Level 1 (0 points)

        I am trying to create ModelIO Meshes from SceneKit data.  As a simple example, I see in the documentation for MDLMesh that:

         

        "

        Objects from SceneKit

         

        init(scnGeometry: SCNGeometry, bufferAllocator: MDLMeshBufferAllocator?)

        Creates a mesh from the specified SceneKit geometry, using the specified allocator.

         

        init(scnGeometry: SCNGeometry)

        Creates a mesh from the specified SceneKit geometry.

        "

         

        So I am at a loss as to why the following code doesn't work:

        import Foundation
        import ModelIO
        import SceneKit
        import MetalKit
        
        class WhyNotWorking {
            init() {
                let box = SCNBox(width: 10.0, height: 10.0, length: 10.0, chamferRadius: 0.0)
                let mesh = MDLMesh(scnGeometry: box, bufferAllocator: nil)
            }
        }
        
        

        This gives me an error that:

        Expression type 'MDLMesh' is ambiguous without more context.  Looking into the MDLMesh.h file I don't see any referene to the initializer noted in the documentation.

         

        Am I missing something here? 

        • Re: SceneKit ModelIO broken?
          gchiste Apple Staff Apple Staff (200 points)

          Hello,

           

          You need to import SceneKit.ModelIO to use that convenience initializer

           

          import Foundation
          import ModelIO
          import SceneKit
          import MetalKit
          import SceneKit.ModelIO
           
          class WhyNotWorking {
              init() {
                  let box = SCNBox(width: 10.0, height: 10.0, length: 10.0, chamferRadius: 0.0)
                  let mesh = MDLMesh(scnGeometry: box, bufferAllocator: nil)
              }
          }