arkit

SwiftUI – Passing data from SwiftUIView to SceneKit

懵懂的女人 提交于 2020-04-10 05:59:08
问题 Goal: SwiftUI toggle button that controls a SwiftUI View with Scenekit (UIViewRepresentable) // show statistics such as fps and timing information What I did: This is the UIViewRepresentable ScenekitView import SwiftUI import SceneKit struct ScenekitView : UIViewRepresentable { let scene = SCNScene(named: "art.scnassets/ship.scn")! func makeUIView(context: Context) -> SCNView { // create and add a camera to the scene let cameraNode = SCNNode() cameraNode.camera = SCNCamera() scene.rootNode

making the arkit camera vertical rather than horizontal

北慕城南 提交于 2020-04-06 22:21:37
问题 I am trying to make an app where the user enters some text in a textfield and then the app displays this text in front of the ar camera to the user. I positioned the text correctly in front of the camera and I have changed the anchor of the text to be in the center of the text. but when I add the text into the scene the text is rotated 90 degrees around the z-axis. And I know why but I don't know how to solve it. The reason is that the camera of the arscene.session has a rotation of 0 for all

Object detection ARKit vs CoreML

随声附和 提交于 2020-03-20 07:55:33
问题 I am building ARKit application for iPhone. I need to detect specific perfume bottle and display content depending on what is detected. I used demo app from developer.apple.com to scan real world object and export .arobject file which I can use in assets. It's working fine, although since bottle is from glass detection is very poor. It detects only in location where scan was made in range from 2-30 seconds or doesn't detect at all. Merging of scans doesn't improve situation, something making

Unable to create circle using UIBezierPath and SCNShape

*爱你&永不变心* 提交于 2020-03-19 07:41:09
问题 Anyone familiar with using curved UIBezierPaths to create a SCNShape in ARKit? I'm creating a closed circle path, but I get a diamond shape in my ARKit scene. Here is the code I use to create the bezier path and SCNShape: let radius : CGFloat = 1.0 let outerPath = UIBezierPath(ovalIn: CGRect(x: -radius, y: -radius, width: 2* radius, height: 2* radius)) let material = SCNMaterial() material.diffuse.contents = UIColor.blue material.isDoubleSided = true material.ambient.contents = UIColor.black

What is the difference between sceneView.delegate and sceneView.session.delegate?

倾然丶 夕夏残阳落幕 提交于 2020-03-16 07:35:10
问题 I am reading the code below. https://github.com/tukuyo/rakumaruCardMan/blob/master/rakutencard-Man/ViewController.swift sceneView.delegate = self sceneView.session.delegate = self The code does not work without sceneView.delegate = self , but sceneView.session.delegate = self seems to work without error even if commented out. So what is the reason of writing sceneView.session.delegate = self? 回答1: The sceneView delegate is of type ARSCNViewDelegate, while the session delegate is of type

Swift -How to update ARAnchor to follow Camera's position

霸气de小男生 提交于 2020-03-04 19:35:15
问题 I followed this code from @rickster which 100% works and looks great. In the video he's animating a SCNNode that is set using an ARAnchor from 1 position to another and back. I tried to do something similar except I want the node that is set with the ARAnchor to follow/update it's position to another node that is a child of the camera. I'm having a problem updating the position in func renderer(_ renderer: SCNSceneRenderer, willRenderScene scene: SCNScene, atTime time: TimeInterval) { } I

Adding CIFilter to SCNNode turns node into white box

末鹿安然 提交于 2020-02-28 20:25:24
问题 I'd like to add a CIGaussianBlur to a SCNNode that is being displayed in ARKit. However, adding that filter turns the node into "a white box". Here is the node without and with filter. No CIFilter With CIFilter Here is the relevant code: let gaussianBlurFilter = CIFilter(name: "CIGaussianBlur")! gaussianBlurFilter.name = "blur" node.filters = [gaussianBlurFilter] let material = node.geometry?.firstMaterial material?.diffuse.contents = UIColor.blue node.position = SCNVector3(x: 0, y: 0, z: -0

Getting the rotation of device around the world origin's y axis in ARKit

对着背影说爱祢 提交于 2020-02-28 09:46:05
问题 I am trying to calculate the rotation of my device when I rotate it around the y-axis in ARKit. For clarification the y-axis in ARKit is the axis pointing upwards perpendicular to the ground. I used eulerangles to get the rotation of the camera like this: var alpha = sceneView.pointOfView?.eulerAngles.y This approximately works when 0=<alpha<pi/2 and when -pi/2<alpha<=0 , but for what is supposed to be other angles I get the wrong readings. I suspect this has to do with gimbal lock and that I

RealityKit - Animate opacity of a ModelEntity?

怎甘沉沦 提交于 2020-02-28 08:48:47
问题 By setting the color of a material on the model property of a ModelEntity , I can alter the opacity/alpha of an object. But how do you animate this? My goal is to animate objects with full opacity, then have them fade to a set opacity, such as 50%. With SCNAction.fadeOpacity on a SCNNode in SceneKit , this was particularly easy. let fade = SCNAction.fadeOpacity(by: 0.5, duration: 0.5) node.runAction(fade) An Entity conforms to HasTransform , but that will only allow you to animate scale,

Support ARKit in lower end devices?

a 夏天 提交于 2020-02-24 14:59:19
问题 In Apple presentation they said if ARWorldTrackingConfiguration not supported we can use the lesser AROrientationTrackingConfiguration (previously named ARSessionConfiguration). But when I try this on an A8 device (iPad mini 4), it makes no difference whether to let ARWorldTrackingConfiguration() fail or not. Tracking just don't work. if ARWorldTrackingConfiguration.isSupported { let configuration = ARWorldTrackingConfiguration() sceneView.session.run(configuration) } else { sceneView.session