scenekit

ARSCNView freezes when adding 14 ARAnchor subclass objects with strong reference

耗尽温柔 提交于 2019-12-24 19:39:01
问题 I have next code: guard let feauturePoint = frame.hitTest(normalizedPoint, types: .featurePoint).first?.worldTransform else { return } let anchor = MyAnchorSubclass(transform: feauturePoint, plus: someAdditionalInfo) arSession.add(anchor: anchor) This function creates and adds object of my subclass of ARAnchor. Then... func renderer(_ renderer: SCNSceneRenderer, didAdd node: SCNNode, for anchor: ARAnchor) { guard let anchor = anchor as? MyAnchorSubclass else { return } anchors.append(anchor)

Using Blending Functions in Scenekit

旧街凉风 提交于 2019-12-24 17:01:14
问题 I can't see an obvious way to change the blending function (glBlendFunc) for a scene kit node or geometry - it doesn't seem to be part of the material, and it isn't very obvious from the scene kit documentation how it organises render passes. Do I need to make a Render delegate for the node which just changes the GLblending mode, or do I need to somehow set up different render passes etc. (It's not obvious from the documentation how I even control things like render passes)? 回答1: Will It

Character is not moving in desired scene in scenekit

柔情痞子 提交于 2019-12-24 16:22:51
问题 i want to move my character in scene kit .i have a map as at github Fpscontroller and i want my character move in this map but when ever i touch to move character it jumps and don,t know where is goes here is my code.` override func touchesBegan(touches: Set<UITouch>, withEvent event: UIEvent?) { for touch in touches { if CGRectContainsPoint(gameView.virtualDPadBounds(), touch.locationInView(gameView)) { if padTouch == nil { padTouch = touch controllerStoredDirection = float2(0.0) } } else if

How to check which SCNNode is tapped in scenekit iOS

邮差的信 提交于 2019-12-24 15:57:00
问题 Currently i have three SCNNode in SceneView.i want to get indexpath like which cube is Tapped. Here is my code of Tap Event - (void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event { UITouch *touch = [touches anyObject]; CGPoint touchPoint = [touch locationInView:gameVW]; SCNHitTestResult *hitTestResult = [[gameVW hitTest:touchPoint options:nil] firstObject]; SCNNode *hitNode = hitTestResult.node; } Here is my code to create SCNNodes. SCNBox *Box = [SCNBox boxWithWidth:2.0 height:2.0

How to remove SCNNode when Tap on it?

ぐ巨炮叔叔 提交于 2019-12-24 10:55:25
问题 I have Creat Cubes using SceneView and i want to disappear cube on which Tap action. How can achieve it? Here is my code to create Cube SCNBox *Box = [SCNBox boxWithWidth:2.0 height:2.0 length:2.0 chamferRadius:Radius]; Box.firstMaterial.diffuse.contents = [UIColor whiteColor]; SCNNode *cubeNode = [SCNNode nodeWithGeometry:Box]; [ArrBoxNode addObject:cubeNode]; self.sceneView.backgroundColor = [UIColor redColor]; self.view.backgroundColor = [UIColor grayColor]; cubeNode.position =

SceneKit: export scene as STL file for 3D printing?

我是研究僧i 提交于 2019-12-24 08:37:42
问题 How can you export a SceneKit scene as a STL file (for 3D printing)? The write function from SCNScene does not appear to support the STL format. 回答1: you can use SCNScene 's write(to:options:delegate:progressHandler:) . While the online documentation only mentions Collada and SceneKit file formats, the header documentation states that: macOS 10.10 and lower only supports exporting to .dae files. Starting iOS 10 exporting supports .scn as well as all file formats supported by Model I/O.

How to place text in the certain position when using SceneKit?

岁酱吖の 提交于 2019-12-24 08:34:25
问题 I have tried to follow the same simple logic as for cylinder, box … , so just by defining the position for textNode, but it is not working. func makeText(text3D: String, position: SCNVector3, depthOfText: CGFloat, color: NSColor, transparency: CGFloat) -> SCNNode { let textTodraw = SCNText(string: text3D, extrusionDepth: depthOfText) textTodraw.firstMaterial?.transparency = transparency textTodraw.firstMaterial?.diffuse.contents = color let textNode = SCNNode(geometry: textTodraw) textNode

Why does SCNNode .flattenedClone() either crash or make performance worse?

你离开我真会死。 提交于 2019-12-24 07:39:06
问题 I'm attempting to add around 4.5k SCNNode objects to a scene. Their geometries are one of two SCNPlane s, whose materials are rendered by CALayer s (but I don't think that matters, the CALayerDelegate s are only called once each, so that doesn't seem to be an issue.) Performance is terrible (< 1fps.) With .showsStatistics enabled I see I'm doing almost 3.5k draw calls, which is my problem according to this WWDC video from 2017. So, as suggested, I add all my nodes to one parent node and call

How to make SCNNode is always toward to ARFrame.camera

百般思念 提交于 2019-12-24 06:59:10
问题 - (void)session:(ARSession *)session didUpdateFrame:(ARFrame *)frame { SCNNode *shipNode = self.sceneView.scene.rootNode.childNodes[0]; if (shipNode) { shipNode.eulerAngles = SCNVector3FromFloat3(frame.camera.eulerAngles); } } I want to change ship's orientation with camera's moving, but the above code seems useless. 回答1: Use an SCNBillboardConstraint to keep one node pointed toward another node. 来源: https://stackoverflow.com/questions/44921072/how-to-make-scnnode-is-always-toward-to-arframe

How to make SCNNode is always toward to ARFrame.camera

我的未来我决定 提交于 2019-12-24 06:59:06
问题 - (void)session:(ARSession *)session didUpdateFrame:(ARFrame *)frame { SCNNode *shipNode = self.sceneView.scene.rootNode.childNodes[0]; if (shipNode) { shipNode.eulerAngles = SCNVector3FromFloat3(frame.camera.eulerAngles); } } I want to change ship's orientation with camera's moving, but the above code seems useless. 回答1: Use an SCNBillboardConstraint to keep one node pointed toward another node. 来源: https://stackoverflow.com/questions/44921072/how-to-make-scnnode-is-always-toward-to-arframe