ä»å¹´ã®WWDCã®åºèª¿è¬æ¼ã¯ãã¨ã³ãã¦ã¼ã¶åãã®æ°æ©è½ã®è©±ã«çµæ¢ããæãå¼·ãããããããçã«ã¯ãã¾ããã³ã¨æ¥ãªã2æéã ã£ãããã«æãã¾ããããState of the Unionãããã¥ã¡ã³ããè¦ãã¨ã試ãã¦ã¿ããæ°APIãç®ç½æ¼ãã§ããä¾å¹´éããæ°ã«ãªã£ããã®ãåæãã¦ããã¾ã 1ã
å ¨é¨æ¸ãã¦ãã¨æéããããããªã®ã§ãã¾ãã¯æ¬è¨äºã§ã¯ ARKit 2 ã«ã¤ãã¦ã
Multiuser and Persistent AR
èªåãè¦ã¦ããARã®ä¸çãå ±æã»æ°¸ç¶åã§ããããã«ãªã£ãã¨ããã®ã¯æ¬å½ã«å¤§ããã§ããAppleã®ãã¢ã¯ãã²ã¼ã ã§å¯¾æ±ºã§ãã¾ããã¿ãããªæ´¾æãªãã®ã§ãããããã¨ãã°å¥¥ããã®æºã«è±ãç½®ãã¦ããã¨ãã¿ãããªãããããªãã®ã§ãããã§ãããã½ã¼ã·ã£ã«ã³ãã¥ãã±ã¼ã·ã§ã³ãªä½ãã§ãããã§ãããæè²çãªä½ãã§ã使ãããã§ãããã¨ã«ãããèªåããè¦ããªããã¨ããå¾æ¥ã®å¶ç´ããªããªãã ãã§ARãå©ç¨ããã¢ããªã®ã¢ã¤ãã¢ã¯ãã¡ããã¡ãåºããã¨æãã¾ãã
APIçã«ã¯ãARWorldMap
ã¨ããã¯ã©ã¹ã追å ããã¦ãã¦ãããããä¸çãã®æ
å ±ã§ããããä¿åãããã·ã§ã¢ãããããããã§ãã
ARMultiuserã¨ãããµã³ãã«ãå ¬éããã¦ãã¦ãéåä¿¡ã®ãããã®ã³ã¼ãã¯ãããªæãã§ãã
ï¼éãå´ï¼
sceneView.session.getCurrentWorldMap { worldMap, error in guard let map = worldMap else { print("Error: \(error!.localizedDescription)"); return } guard let data = try? NSKeyedArchiver.archivedData(withRootObject: map, requiringSecureCoding: true) else { fatalError("can't encode map") } self.multipeerSession.sendToAllPeers(data) }
ï¼åãåãå´ï¼
if let unarchived = try? NSKeyedUnarchiver.unarchivedObject(of: ARWorldMap.classForKeyedUnarchiver(), from: data), let worldMap = unarchived as? ARWorldMap { // Run the session with the received world map. let configuration = ARWorldTrackingConfiguration() configuration.planeDetection = .horizontal configuration.initialWorldMap = worldMap sceneView.session.run(configuration, options: [.resetTracking, .removeExistingAnchors]) // Remember who provided the map for showing UI feedback. mapProvider = peer }
ããã§é¢ç½ãã®ã¯ããã®ãµã³ãã«ã§ã¯éåä¿¡ã« Multipeer Connectivity ã使ã£ã¦ãã¦ããã¼ã¿ã¨ãã¦ã¯æ®éã«NSKeyedArchiver
ã§ã¢ã¼ã«ã¤ãï¼ã¢ã³ã¢ã¼ã«ã¤ããããã¼ã¿ãéãåã£ã¦ããç¹ã§ãã
ã¤ã¾ããéåä¿¡ãä¿åã®æ¹æ³ã¯ARKitã«ä¾åãã¦ãããããªãã§ãOKã¨ãããã¨ã§ãããã¼ã¿ããµã¼ãã«éã£ã¦ãããããã§ãããããã¯ã¨ã³ããç¨æããã¨ãããµã¯ãã¨UserDefaults
ã«ä¿åãã¦ãããããRealm
ã«ä¿åãã¦ãããããCore Bluetoothï¼BLEï¼ãå©ç¨ãã¦ãè¯ãããã§ããï¼ï¼»PRï¼½ãã®éãããããæ¬ãå½¹ã«ç«ã¤ããããã¾ããï¼
3D Object Detection
ã3Dç©ä½æ¤åºãã¯å¾æ¥ã®ï¼2Dï¼ç©ä½æ¤åºã¨ä½ãéããã¨ããã¨ããæ£é¢ããè¦ãç¶æ ãã ãã§ãªãã横ããã§ããå¾ãããã§ããä¸ããã§ãããã®ç©ä½ãèªèã§ããã¨ãããã¨ã§ãããã®æ©è½ã«ãããç¾å®ç©ºéã®ç©ä½ï¼é åã¨ãï¼ããã¼ã«ã¼ã¨ãã¦ä»®æ³ã³ã³ãã³ããç½®ããã¨ãã£ããã¨ãå¯è½ã«ãªãã¾ãã
ARKit 2ã«ã¯ã3Dç©ä½ããã¹ãã£ã³ããã¦ããªãã¡ã¬ã³ã¹ãªãã¸ã§ã¯ãããçæããæ©è½ã¨ããã®ãªãã¡ã¬ã³ã¹ãªãã¸ã§ã¯ãã¨åãç¹å¾´ãæã¤ç©ä½ãç¾å®ç©ºéããæ¤åºããæ©è½ã¨ã追å ããã¦ãã¾ãã
ï¼ãµã³ãã«ã«å梱ããã¦ããç»åãã¹ãã£ã³ãæ¤åºã®æµãã示ããã¦ããï¼
ãã®ããã¨è¤éãªã¹ãã£ã³ããã¼ãåºæ¥åãã®ãã¤ãããã®ããªã¨æããããã½ã¼ã¹ãè¦ã¦ã¿ãã¨ãã£ã¤ãã¢ããªå´ã§å®è£ ããã¦ãã¾ãã3Dãã¦ã³ãã£ã³ã°ããã¯ã¹ãé çªã«åãã¦ããã®ã¨ããå ¨é¨ãã¾ããããã¯UIUXã¨ãã¦å·¥å¤«ã®ããããããã¨ãããªã®ã§ããã®æ¹ãè¯ãã§ãããã
ã¹ãã£ã³ããéã¯ãã³ã³ãã£ã®ã¥ã¬ã¼ã·ã§ã³ã¨ãã¦ARObjectScanningConfiguration
ã使ç¨ãã¾ãã
let configuration = ARObjectScanningConfiguration()
ã§ãã¹ãã£ã³ä¸ã«ã©ããããã¨ããããã§ããã»ã»ã»é常ã«æ³¥èãå®è£
ãããã¦ãã¾ããããã§ã¯çç¥ãã¾ãããARSessionDelegate
ã®åããªã²ã¼ãã¡ã½ããããå®è£
ã追ã£ã¦ã¿ã¦ãã ããã
ãªãã¡ã¬ã³ã¹ãªãã¸ã§ã¯ãã表ãARReferenceObject
ãä½æããã«ã¯ãARSession
ã®createReferenceObject(transform:center:extent:completionHandler:)
ã¡ã½ãããå¼ã³ã¾ãããã®å¼æ°ã«ãã¹ãã£ã³å¯¾è±¡ã®ãã¦ã³ãã£ã³ã°ããã¯ã¹ã®transform, center, extentã渡ãã¾ãã
sceneView.session.createReferenceObject( transform: boundingBox.simdWorldTransform, center: float3(), extent: boundingBox.extent, completionHandler: { object, error in if let referenceObject = object { // Adjust the object's origin with the user-provided transform. ... } else { print("Error: Failed to create reference object. \(error!.localizedDescription)") ... } })
ARKitã®æ°è¦è¿½å API
æ°APIãçºããã ãã§ãããããã¨å¯ãããã¨ã¯ã§ããã®ã§ããã¼ã£ã¨è¼ãã¦ããã¾ãã
- ARWorldMap
The space-mapping state and set of anchors from a world-tracking AR session.
- AREnvironmentProbeAnchor
An object that provides environmental lighting information for a specific area of space in a world-tracking AR session.
- ARReferenceObject
A 3D object to be recognized in the real-world environment during a world-tracking AR session.
- ARObjectAnchor
Information about the position and orientation of a real-world 3D object detected in a world-tracking AR session.
- ARObjectScanningConfiguration
A configuration that uses the back-facing camera to collect high-fidelity spatial data for use in scanning 3D objects for later detection.
ARFaceAnchor - ç®ã®åãã®ãã©ããã³ã°
var leftEyeTransform: simd_float4x4
A transform matrix indicating the position and orientation of the face's left eye.
var rightEyeTransform: simd_float4x4
A transform matrix indicating the position and orientation of the face's right eye.
var lookAtPoint: simd_float3
A position in face coordinate space estimating the direction of the face's gaze.
ARImageTrackingConfiguration
A configuration that uses the back-facing camera to detect and track known images.