I'm loading a .usdz file into my ARSCNView and so far it works fine, except from the fact that when I load multiple objects into my scene the app crashes with message: Terminated due to memory issue.
I'm using Apple's default .usdz samples (https://developer.apple.com/augmented-reality/quick-look/) and the robot file is around 13.5MB big.
It works with up to 4-5 instances and then crashes.
Is the limit for ARKit application so small, or am I doing something wrong?
Here's my code:
// My touch point on the screen
let touchLocation = sender.location(in: sceneView)
// We have a touch point on an ARPlane
if let result = self.sceneView.hitTest(touchLocation, types: ARHitTestResult.ResultType.existingPlaneUsingExtent).last {
let position = SCNVector3Make(result.worldTransform.columns.3.x, result.worldTransform.columns.3.y, result.worldTransform.columns.3.z)
// Load the .usdz model
guard let usdzURL = Bundle.main.url(forResource: "toy_robot_vintage", withExtension: "usdz") else {
return
}
// Create a node, set position and scale
let referenceNode = SCNReferenceNode(url: usdzURL)!
referenceNode.load()
referenceNode.position = position
referenceNode.scale = SCNVector3Make(0.01, 0.01, 0.01)
// Add node to scene
sceneView.scene.rootNode.addChildNode(referenceNode)
}