scenekit

How to determine that ARObjectAnchor was removed from the scene?

自作多情 提交于 2020-04-11 04:48:27
问题 I am trying to use ARKit for validating the position of a toy. I have an ARObject scan resource, and placing the toy in camera view works pretty well. In other words, didAdd and didUpdate of SCNScene and ARSession are called as expected in a reasonable time after the toy is placed in camera view. But when i move the toy away from the camera view, didRemove does not get called, neither for SCNScene nor for ARSession . I did read advocations of this behaviour, saying "well ARKit can't know if

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

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

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

How to load SCN or glTF model at runtime in ARKit app?

情到浓时终转凉″ 提交于 2020-02-23 04:00:43
问题 What is the best way to load a 3d model from a URL inside of iOS at runtime. I have tried this .scn and .gtlf models importer. I am using this framework https://github.com/prolificinteractive/SamMitiAR-iOS I load the model like this: let virtualObjectGLTFNode = SamMitiVirtualObject(gltfUrl: URL(string: "https://raw.githubusercontent.com/KhronosGroup/glTF-Sample- Models/master/2.0/Duck/glTF-Embedded/Duck.gltf")!, allowedAlignments: [.horizontal]) virtualObjectGLTFNode.name = "Duck"

Deferred Shadow doesn't work if detecting Multiple Transparent Planes

↘锁芯ラ 提交于 2020-02-22 07:46:44
问题 In my code, I detect the plane and show shadow for the object above the plane. If there is one plane, it works fine, but if it detects multiple planes, the redundant shadow will show. As the picture shows, on the plane #1, the shadow is right, but if I add another plane #2, the plane #2 has the wrong shadow, even if I remove the airplane, the shadow on plane #1 disappears, but the shadow on plane #2 is still there. I don't want to remove the plane #2, but how to remove the wrong shadow on

Add 3d node to sceneView following wwdc code, but the 3d node rotates 90 degrees

余生颓废 提交于 2020-02-06 07:42:35
问题 I use iPad to develop an AR app. I follow the wwdc code to add my first node on the sceneView. If the iPad is landscape, I can get the right result, but if the iPad is Portrait, it rotates 90 degrees. Anybody can help me, thanks? guard let frame = sceneView.session.currentFrame else { return } if let scnStr = noti.object as? String { // Create a new scene let scene = SCNScene(named: "art.scnassets/\(scnStr)")! let emojiNode = SCNNode() for node in scene.rootNode.childNodes { emojiNode

SceneKit - Rotate object around X and Z axis

拈花ヽ惹草 提交于 2020-02-04 15:55:37
问题 I’m using ARKit with SceneKit. When user presses a button I create an anchor and to the SCNNode corresponding to it I add a 3D object (loaded from a .scn file in the project). The 3D object is placed facing the camera, with the same orientation the camera has. I would like to make it look like the object is laying on a plane surface and not inclined if it is that way. So, if I got it right, I’d need to apply a rotation transformation so that it’s rotation around the X and Z axis become 0. My

Which are the right Matrix Values to use in a metal shader passed by a SCNProgram to get a correct chrome like reflection

核能气质少年 提交于 2020-02-04 01:46:09
问题 I am working on an App, that should render a chrome-style reflective sphere-like object inside a skybox (using a six faced cube map). I am doing this in Swift using Scenekit with different approaches. Everything is fine and perfectly reflected (see Figure 1 below) as long as I let Scenekit doing all the work - in other words, using a standard SCNMaterial with metalness 1.0, roughness 0.0 and color UIColor.white (using .physicallyBased as lighting model) attached to the firstMaterial of the

How to make a 3D model from AVDepthData?

扶醉桌前 提交于 2020-01-31 04:01:06
问题 I’m interested in the issue of data processing from TrueDepth Camera. It is necessary to obtain the data of a person’s face, build a 3D model of the face and save this model in an .obj file. Since in the 3D model needed presence of the person’s eyes and teeth, then ARKit / SceneKit is not suitable, because ARKit / SceneKit do not fill these areas with data. But with the help of the SceneKit.ModelIO library, I managed to export ARSCNView.scene (type SCNScene) in the .obj format. I tried to