Upgrade to Pro — share decks privately, control downloads, hide ads and more …

ARKitの話

 ARKitの話

WWDC After Party 2017 @Ebisu での発表資料です。

https://pre-wwdc.connpass.com/event/56731/

Takaaki Tanaka

June 22, 2017
Tweet

More Decks by Takaaki Tanaka

Other Decks in Technology

Transcript

  1. • ాத ޹໌ (Takaaki Tanaka) • Ϋϥεϝιουגࣜձࣾ • @kongmingtrap •

    Swift / Objective-C / Scala / JavaScript … • GyazSquare / GitHub
  2. AR

  3. AR

  4. AR • AVFoundation • Core Location • Heading • Core

    Motion • Gyro scope • Accelerometer
  5. Plane Detection // configure session if let worldSessionConfig = sessionConfig

    as? ARWorldTrackingSessionConfiguration { worldSessionConfig.planeDetection = .horizontal session.run(worldSessionConfig, options: [.resetTracking, .removeExistingAnchors]) }
  6. ARAnchor • ARPlaneAnchor • ARAnchorͷαϒΫϥε • ݕग़͞Εͨฏ໘ • ݕग़͞ΕͨΒARSCNViewDelegateͷϝιου ʹ௨஌͞ΕΔ

    • renderer(_ renderer: SCNSceneRenderer, didAdd node: SCNNode, for anchor: ARAnchor)
  7. ARSCNViewDelegate func renderer(_ renderer: SCNSceneRenderer, didAdd node: SCNNode, for anchor:

    ARAnchor) { DispatchQueue.main.async { if let planeAnchor = anchor as? ARPlaneAnchor { self.addPlane(node: node, anchor: planeAnchor) self.checkIfObjectShouldMoveOntoPlane(anchor: planeAnchor) } } }
  8. ARPlaneAnchor + SCNNode func addPlane(node: SCNNode, anchor: ARPlaneAnchor) { let

    pos = SCNVector3.positionFromTransform(anchor.transform) textManager.showDebugMessage("NEW SURFACE DETECTED AT \ (pos.friendlyString())") let plane = Plane(anchor, showDebugVisuals) planes[anchor] = plane node.addChildNode(plane) textManager.cancelScheduledMessage(forType: .planeEstimation) textManager.showMessage("SURFACE DETECTED") if virtualObject == nil { textManager.scheduleMessage("TAP + TO PLACE AN OBJECT", inSeconds: 7.5, messageType: .contentPlacement) } }
  9. ARPlaneAnchor + SCNNode private func updateOcclusionNode() { guard let occlusionNode

    = occlusionNode, let occlusionPlane = occlusionNode.geometry as? SCNPlane else { return } occlusionPlane.width = CGFloat(anchor.extent.x - 0.05) occlusionPlane.height = CGFloat(anchor.extent.z - 0.05) occlusionNode.position = SCNVector3Make(anchor.center.x, occlusionPlaneVerticalOffset, anchor.center.z) }