UniversalLink
https://line.worksmobile.com/default
Custom Scheme
com.nttdocomo.jp.ne.docomo.lemino.apps://connectcallback
AppLinks
https://rpapl.aif.pub.cilite.docomo.ne.jp/dpay_app
if let ship = sceneView.scene.rootNode.childNode(withName: "ship", recursively: true) {
ship.position = targetNode.position
let configuration = ARWorldTrackingConfiguration()
sceneView.session.pause()
sceneView.session.run(configuration)
let completion = {
let rotationAction = SCNAction.repeatForever(SCNAction.rotateBy(x: 0, y: 0, z: 1, duration: 1))
ship.runAction(rotationAction)
}
SCNTransaction.begin()
SCNTransaction.animationDuration = 1.5
SCNTransaction.completionBlock = completion
ship.opacity = 1
SCNTransaction.commit()
targetNode.isHidden = true
}
if let ship = sceneView.scene.rootNode.childNode(withName: "ship", recursively: true) {
ship.position = targetNode.position
let configuration = ARWorldTrackingConfiguration()
sceneView.session.pause()
sceneView.session.run(configuration)
let completion = {
let rotationAction = SCNAction.repeatForever(SCNAction.rotateBy(x: 0, y: 0, z: 1, duration: 1))
if let shipMesh = ship.childNode(withName: "shipMesh", recursively: false) {
shipMesh.runAction(rotationAction)
}
}
SCNTransaction.begin()
SCNTransaction.animationDuration = 1.5
SCNTransaction.completionBlock = completion
ship.opacity = 1
SCNTransaction.commit()
targetNode.isHidden = true
}
let targetPlane = SCNPlane(width: 0.2, height: 0.2) targetPlane.cornerRadius = 1 targetPlane.firstMaterial?.diffuse.contents = UIColor.blue.withAlphaComponent(0.5)
targetNode = SCNNode(geometry: targetPlane) targetNode.isHidden = true targetNode.name = "target" targetNode.eulerAngles.x = -Float.pi / 2
var screenCenter: CGPoint {
let bounds = sceneView.bounds
return CGPoint(x: bounds.midX, y: bounds.midY)
}
DispatchQueue.main.async {
let results = self.sceneView.hitTest(self.screenCenter, types: [.existingPlaneUsingGeometry])
if let existingPlaneUsingGeometryResult = results.first(where: { $0.type == .existingPlaneUsingGeometry }) {
let result = existingPlaneUsingGeometryResult
let transform = result.worldTransform
let newPosition = transform.position
self.targetNode.position = newPosition
}
}
func renderer(_ renderer: SCNSceneRenderer, didAdd node: SCNNode, for anchor: ARAnchor) {
targetNode.isHidden = false
}
if let result = results.first {
guard let hitNodeName = result.node.name else { return }
if hitNodeName == "shipMesh" {
if let ship = result.node.parent {
let actMove = SCNAction.move(by: SCNVector3(0, 0, 0.1), duration: 0.2)
ship.runAction(actMove)
}
} else if hitNodeName == "target" {
.....
}
}
ship.position = targetNode.position
import UIKit
import SceneKit
import ARKit
class ViewController: UIViewController, ARSCNViewDelegate, UIGestureRecognizerDelegate {
@IBOutlet var sceneView: ARSCNView!
var targetNode : SCNNode!
var screenCenter: CGPoint {
let bounds = sceneView.bounds
return CGPoint(x: bounds.midX, y: bounds.midY)
}
override func viewDidLoad() {
super.viewDidLoad()
// Set the view's delegate
sceneView.delegate = self
// Show statistics such as fps and timing information
sceneView.showsStatistics = true
// Create a new scene
let scene = SCNScene(named: "art.scnassets/ship.scn")!
if let ship = scene.rootNode.childNode(withName: "ship", recursively: true) {
if let particle = SCNParticleSystem(named: "BoostFire.scnp", inDirectory: "art.scnassets") {
particle.particleSize = 0.3
if let emitter = ship.childNode(withName: "emitter", recursively: true) {
emitter.addParticleSystem(particle)
}
}
ship.opacity = 0
}
// Create a target
let targetPlane = SCNPlane(width: 0.2, height: 0.2)
targetPlane.cornerRadius = 1
targetPlane.firstMaterial?.diffuse.contents = UIColor.blue.withAlphaComponent(0.5)
targetNode = SCNNode(geometry: targetPlane)
targetNode.isHidden = true
targetNode.name = "target"
targetNode.eulerAngles.x = -Float.pi / 2
scene.rootNode.addChildNode(targetNode)
// Setup Omni Light
let light = SCNLight()
light.type = .omni
let LightNode = SCNNode()
LightNode.light = light
LightNode.name = "light"
LightNode.position = SCNVector3(-1,2,-1)
scene.rootNode.addChildNode(LightNode)
// Set the scene to the view
sceneView.scene = scene
let tapRecognizer = UITapGestureRecognizer(target: self, action: #selector(tap(_:)))
tapRecognizer.delegate = self
sceneView.addGestureRecognizer(tapRecognizer)
}
override func viewWillAppear(_ animated: Bool) {
super.viewWillAppear(animated)
// Create a session configuration
let configuration = ARWorldTrackingConfiguration()
configuration.planeDetection = [.horizontal]
// Run the view's session
sceneView.session.run(configuration)
}
override func viewWillDisappear(_ animated: Bool) {
super.viewWillDisappear(animated)
// Pause the view's session
sceneView.session.pause()
}
@objc func tap(_ tapRecognizer: UITapGestureRecognizer) {
let touchPoint = tapRecognizer.location(in: self.sceneView)
let results = self.sceneView.hitTest(touchPoint, options: [SCNHitTestOption.searchMode : SCNHitTestSearchMode.all.rawValue])
if let result = results.first {
guard let hitNodeName = result.node.name else { return }
if hitNodeName == "shipMesh" {
if let ship = result.node.parent {
let actMove = SCNAction.move(by: SCNVector3(0, 0, 0.1), duration: 0.2)
ship.runAction(actMove)
}
} else if hitNodeName == "target" {
if let ship = sceneView.scene.rootNode.childNode(withName: "ship", recursively: true) {
ship.position = targetNode.position
let configuration = ARWorldTrackingConfiguration()
sceneView.session.pause()
sceneView.session.run(configuration)
let completion = {
let rotationAction = SCNAction.repeatForever(SCNAction.rotateBy(x: 0, y: 0, z: 1, duration: 1))
ship.runAction(rotationAction)
}
SCNTransaction.begin()
SCNTransaction.animationDuration = 1.5
SCNTransaction.completionBlock = completion
ship.opacity = 1
SCNTransaction.commit()
targetNode.isHidden = true
}
}
}
}
// MARK: - ARSCNViewDelegate
/*
// Override to create and configure nodes for anchors added to the view's session.
func renderer(_ renderer: SCNSceneRenderer, nodeFor anchor: ARAnchor) -> SCNNode? {
let node = SCNNode()
return node
}
*/
func renderer(_ renderer: SCNSceneRenderer, didAdd node: SCNNode, for anchor: ARAnchor) {
targetNode.isHidden = false
}
func renderer(_ renderer: SCNSceneRenderer, updateAtTime time: TimeInterval) {
guard let lightEstimate = self.sceneView.session.currentFrame?.lightEstimate else { return }
let ambientIntensity = lightEstimate.ambientIntensity
let ambientColorTemperature = lightEstimate.ambientColorTemperature
if let lightNode = self.sceneView.scene.rootNode.childNode(withName: "light", recursively: true) {
guard let light = lightNode.light else { return }
light.intensity = ambientIntensity
light.temperature = ambientColorTemperature
}
DispatchQueue.main.async {
let results = self.sceneView.hitTest(self.screenCenter, types: [.existingPlaneUsingGeometry])
if let existingPlaneUsingGeometryResult = results.first(where: { $0.type == .existingPlaneUsingGeometry }) {
let result = existingPlaneUsingGeometryResult
let transform = result.worldTransform
let newPosition = transform.position
self.targetNode.position = newPosition
}
}
}
func session(_ session: ARSession, didFailWithError error: Error) {
// Present an error message to the user
}
func sessionWasInterrupted(_ session: ARSession) {
// Inform the user that the session has been interrupted, for example, by presenting an overlay
}
func sessionInterruptionEnded(_ session: ARSession) {
// Reset tracking and/or remove existing anchors if consistent tracking is required
}
}
extension matrix_float4x4 {
var position : SCNVector3 {
get {
return SCNVector3(columns.3.x, columns.3.y, columns.3.z)
}
}
}
*** Terminating app due to uncaught exception 'GADInvalidInitializationException', reason: 'The Google Mobile Ads SDK was initialized incorrectly. Google AdMob publishers should follow instructions here: https://googlemobileadssdk.page.link/admob-ios-update-plist to include the AppMeasurement framework, set the -ObjC linker flag, and set GADApplicationIdentifier with a valid App ID. Google Ad Manager publishers should follow instructions here: https://googlemobileadssdk.page.link/ad-manager-ios-update-plist'
![]() |
| 日本語版 |
![]() |
| 英語版 |
if let particle = SCNParticleSystem(named: "BoostFire.scnp", inDirectory: "art.scnassets") {
particle.particleSize = 0.3
if let emitter = ship.childNode(withName: "emitter", recursively: true) {
emitter.addParticleSystem(particle)
}
}
import UIKit
import SceneKit
import ARKit
class ViewController: UIViewController, ARSCNViewDelegate, UIGestureRecognizerDelegate {
@IBOutlet var sceneView: ARSCNView!
override func viewDidLoad() {
super.viewDidLoad()
// Set the view's delegate
sceneView.delegate = self
// Show statistics such as fps and timing information
sceneView.showsStatistics = true
// Create a new scene
let scene = SCNScene(named: "art.scnassets/ship.scn")!
if let ship = scene.rootNode.childNode(withName: "ship", recursively: true) {
if let particle = SCNParticleSystem(named: "BoostFire.scnp", inDirectory: "art.scnassets") {
particle.particleSize = 0.3
if let emitter = ship.childNode(withName: "emitter", recursively: true) {
emitter.addParticleSystem(particle)
}
}
ship.opacity = 0
}
// Setup Omni Light
let light = SCNLight()
light.type = .omni
let LightNode = SCNNode()
LightNode.light = light
LightNode.name = "light"
LightNode.position = SCNVector3(-1,2,-1)
scene.rootNode.addChildNode(LightNode)
// Set the scene to the view
sceneView.scene = scene
let tapRecognizer = UITapGestureRecognizer(target: self, action: #selector(tap(_:)))
tapRecognizer.delegate = self
sceneView.addGestureRecognizer(tapRecognizer)
}
override func viewWillAppear(_ animated: Bool) {
super.viewWillAppear(animated)
// Create a session configuration
let configuration = ARWorldTrackingConfiguration()
configuration.planeDetection = [.horizontal]
// Run the view's session
sceneView.session.run(configuration)
}
override func viewWillDisappear(_ animated: Bool) {
super.viewWillDisappear(animated)
// Pause the view's session
sceneView.session.pause()
}
@objc func tap(_ tapRecognizer: UITapGestureRecognizer) {
let touchPoint = tapRecognizer.location(in: self.sceneView)
let results = self.sceneView.hitTest(touchPoint, options: [SCNHitTestOption.searchMode : SCNHitTestSearchMode.all.rawValue])
if let result = results.first {
guard let hitNodeName = result.node.name else { return }
guard hitNodeName == "shipMesh" else { return }
if let ship = result.node.parent {
let actMove = SCNAction.move(by: SCNVector3(0, 0, 0.1), duration: 0.2)
ship.runAction(actMove)
}
}
}
// MARK: - ARSCNViewDelegate
/*
// Override to create and configure nodes for anchors added to the view's session.
func renderer(_ renderer: SCNSceneRenderer, nodeFor anchor: ARAnchor) -> SCNNode? {
let node = SCNNode()
return node
}
*/
func renderer(_ renderer: SCNSceneRenderer, didAdd node: SCNNode, for anchor: ARAnchor) {
if let ship = sceneView.scene.rootNode.childNode(withName: "ship", recursively: true) {
ship.removeFromParentNode()
node.addChildNode(ship)
let configuration = ARWorldTrackingConfiguration()
sceneView.session.pause()
sceneView.session.run(configuration)
let completion = {
let rotationAction = SCNAction.repeatForever(SCNAction.rotateBy(x: 0, y: 0, z: 1, duration: 1))
ship.runAction(rotationAction)
}
SCNTransaction.begin()
SCNTransaction.animationDuration = 1.5
SCNTransaction.completionBlock = completion
ship.opacity = 1
SCNTransaction.commit()
}
}
func renderer(_ renderer: SCNSceneRenderer, updateAtTime time: TimeInterval) {
guard let lightEstimate = self.sceneView.session.currentFrame?.lightEstimate else { return }
let ambientIntensity = lightEstimate.ambientIntensity
let ambientColorTemperature = lightEstimate.ambientColorTemperature
if let lightNode = self.sceneView.scene.rootNode.childNode(withName: "light", recursively: true) {
guard let light = lightNode.light else { return }
light.intensity = ambientIntensity
light.temperature = ambientColorTemperature
}
}
func session(_ session: ARSession, didFailWithError error: Error) {
// Present an error message to the user
}
func sessionWasInterrupted(_ session: ARSession) {
// Inform the user that the session has been interrupted, for example, by presenting an overlay
}
func sessionInterruptionEnded(_ session: ARSession) {
// Reset tracking and/or remove existing anchors if consistent tracking is required
}
}
UIGestureRecognizerDelegate
let tapRecognizer = UITapGestureRecognizer(target: self, action: #selector(tap(_:))) tapRecognizer.delegate = self sceneView.addGestureRecognizer(tapRecognizer)
@objc func tap(_ tapRecognizer: UITapGestureRecognizer) {
}
let touchPoint = tapRecognizer.location(in: self.sceneView)
let results = self.sceneView.hitTest(touchPoint, options: [SCNHitTestOption.searchMode : SCNHitTestSearchMode.all.rawValue])
if let result = results.first {
guard let hitNodeName = result.node.name else { return }
guard hitNodeName == "shipMesh" else { return }
if let ship = result.node.parent {
let actMove = SCNAction.move(by: SCNVector3(0, 0, 0.1), duration: 0.2)
ship.runAction(actMove)
}
}
import UIKit
import SceneKit
import ARKit
class ViewController: UIViewController, ARSCNViewDelegate, UIGestureRecognizerDelegate {
@IBOutlet var sceneView: ARSCNView!
override func viewDidLoad() {
super.viewDidLoad()
// Set the view's delegate
sceneView.delegate = self
// Show statistics such as fps and timing information
sceneView.showsStatistics = true
// Create a new scene
let scene = SCNScene(named: "art.scnassets/ship.scn")!
if let ship = scene.rootNode.childNode(withName: "ship", recursively: true) {
ship.opacity = 0
}
// Setup Omni Light
let light = SCNLight()
light.type = .omni
let LightNode = SCNNode()
LightNode.light = light
LightNode.name = "light"
LightNode.position = SCNVector3(-1,2,-1)
scene.rootNode.addChildNode(LightNode)
// Set the scene to the view
sceneView.scene = scene
let tapRecognizer = UITapGestureRecognizer(target: self, action: #selector(tap(_:)))
tapRecognizer.delegate = self
sceneView.addGestureRecognizer(tapRecognizer)
}
override func viewWillAppear(_ animated: Bool) {
super.viewWillAppear(animated)
// Create a session configuration
let configuration = ARWorldTrackingConfiguration()
configuration.planeDetection = [.horizontal]
// Run the view's session
sceneView.session.run(configuration)
}
override func viewWillDisappear(_ animated: Bool) {
super.viewWillDisappear(animated)
// Pause the view's session
sceneView.session.pause()
}
@objc func tap(_ tapRecognizer: UITapGestureRecognizer) {
let touchPoint = tapRecognizer.location(in: self.sceneView)
let results = self.sceneView.hitTest(touchPoint, options: [SCNHitTestOption.searchMode : SCNHitTestSearchMode.all.rawValue])
if let result = results.first {
guard let hitNodeName = result.node.name else { return }
guard hitNodeName == "shipMesh" else { return }
if let ship = result.node.parent {
let actMove = SCNAction.move(by: SCNVector3(0, 0, 0.1), duration: 0.2)
ship.runAction(actMove)
}
}
}
// MARK: - ARSCNViewDelegate
/*
// Override to create and configure nodes for anchors added to the view's session.
func renderer(_ renderer: SCNSceneRenderer, nodeFor anchor: ARAnchor) -> SCNNode? {
let node = SCNNode()
return node
}
*/
func renderer(_ renderer: SCNSceneRenderer, didAdd node: SCNNode, for anchor: ARAnchor) {
if let ship = sceneView.scene.rootNode.childNode(withName: "ship", recursively: true) {
ship.removeFromParentNode()
node.addChildNode(ship)
let configuration = ARWorldTrackingConfiguration()
sceneView.session.pause()
sceneView.session.run(configuration)
let completion = {
let rotationAction = SCNAction.repeatForever(SCNAction.rotateBy(x: 0, y: 0, z: 1, duration: 1))
ship.runAction(rotationAction)
}
SCNTransaction.begin()
SCNTransaction.animationDuration = 1.5
SCNTransaction.completionBlock = completion
ship.opacity = 1
SCNTransaction.commit()
}
}
func renderer(_ renderer: SCNSceneRenderer, updateAtTime time: TimeInterval) {
guard let lightEstimate = self.sceneView.session.currentFrame?.lightEstimate else { return }
let ambientIntensity = lightEstimate.ambientIntensity
let ambientColorTemperature = lightEstimate.ambientColorTemperature
if let lightNode = self.sceneView.scene.rootNode.childNode(withName: "light", recursively: true) {
guard let light = lightNode.light else { return }
light.intensity = ambientIntensity
light.temperature = ambientColorTemperature
}
}
func session(_ session: ARSession, didFailWithError error: Error) {
// Present an error message to the user
}
func sessionWasInterrupted(_ session: ARSession) {
// Inform the user that the session has been interrupted, for example, by presenting an overlay
}
func sessionInterruptionEnded(_ session: ARSession) {
// Reset tracking and/or remove existing anchors if consistent tracking is required
}
}