File tree Expand file tree Collapse file tree 1 file changed +19
-9
lines changed
Expand file tree Collapse file tree 1 file changed +19
-9
lines changed Original file line number Diff line number Diff line change @@ -7,14 +7,24 @@ func parseReferenceImagesSet(_ images: [[String: Any]]) -> Set<ARReferenceImage>
77}
88
99func parseReferenceImage( _ dict: [ String : Any ] ) -> ARReferenceImage ? {
10- if let physicalWidth = dict [ " physicalWidth " ] as? Double ,
11- let name = dict [ " name " ] as? String ,
12- let image = getImageByName ( name) ,
13- let cgImage = image. cgImage
14- {
15- let referenceImage = ARReferenceImage ( cgImage, orientation: CGImagePropertyOrientation . up, physicalWidth: CGFloat ( physicalWidth) )
16- referenceImage. name = name
17- return referenceImage
10+ guard let physicalWidth = dict [ " physicalWidth " ] as? Double else {
11+ debugPrint ( " ARKitReferenceImage: missing or invalid physicalWidth: \( dict) " )
12+ return nil
1813 }
19- return nil
14+ guard let name = dict [ " name " ] as? String else {
15+ debugPrint ( " ARKitReferenceImage: missing or invalid name: \( dict) " )
16+ return nil
17+ }
18+ guard let image = getImageByName ( name) else {
19+ debugPrint ( " ARKitReferenceImage: failed to load image for name: \( name) " )
20+ return nil
21+ }
22+ guard let cgImage = image. cgImage else {
23+ debugPrint ( " ARKitReferenceImage: loaded image has no CGImage for name: \( name) " )
24+ return nil
25+ }
26+
27+ let referenceImage = ARReferenceImage ( cgImage, orientation: CGImagePropertyOrientation . up, physicalWidth: CGFloat ( physicalWidth) )
28+ referenceImage. name = name
29+ return referenceImage
2030}
You can’t perform that action at this time.
0 commit comments