scnnode

SceneKit: vertically center scaled SCNNode inside parent?

痞子三分冷 提交于 2019-12-12 03:37:32
问题 The goal is to scale a SCNNode and vertically center it within its parent. However, scaling a SCNNode does not affect its bounding box and computing the scaled height does not work. Without an accurate height, how can you vertically center the node inside its parent? To illustrate the problem with using the scaled height, see the attached file, Tiki.dae. The original height of the asset (as shown by the bounding box) is 324.36. If you set the Y-scale to 0.01, however, the height doesn't

ARKit hitTest(_:options:) to select placed 3d-objects not working

狂风中的少年 提交于 2019-12-12 01:16:35
问题 I am trying to select an object which has been placed on a detected plane in order to perform various task on it such as rotating through gestures. In order to search for placed objects and avoid getting hitTestResults of irrelevant nature (eg. selecting the plane or the ARWorldMap itself) I am trying to use hitTest(_:options:) with SCNHitTestOption.categoryBitMask. However it seems as the hitTest returns results of all types, not just objects with the selected categoryBitMask = 5, even

SceneKit get node position after rotation

微笑、不失礼 提交于 2019-12-11 18:30:17
问题 For example I have two SCNNode s with SCNBox geometry positioned one after another increasing x position property: SCNBox(width: 0, height: 0, length: 0.02, chamferRadius: 0) Then I want to rotate the first one using rotation property with SCNVector4 , but when rotation happens I want my second node to follow the first one and change its position according rotation of the first one. I found this solution on the web and tried to print node's position , worldPosition and presentation.position

adding a lot of custom nodes to scene takes a long time to load

丶灬走出姿态 提交于 2019-12-11 14:28:57
问题 I am building a scenekit app however I am having issues with some of the finer details. I created a scene and I am adding custom geometry to it and it works fine until the number of nodes gets to about 100. It is ideal to add a large number of nodes to a scene and is there a cleaner way to do it? for i in 0..<modelArr!.count { let model = modelArr![i] let pos: [SCNVector3] = Parser.loadPosition(model) let norm:[SCNVector3] = Parser.loadNormals(model) let ind:[CInt] = Parser.loadIndices(model)

Update SCNPhysicsBody when scaling SCNNode

核能气质少年 提交于 2019-12-11 07:28:09
问题 I know that SCNPhysicsBody dont scale when the node scale, but I haven't found a great solution to fix this. I want to scale the node and then update the SCNPhysicsBody to node after scaling it. let box = SCNBox(width: 0.2, height: 0.3, length: 0.4, chamferRadius: 0.1) box.firstMaterial?.diffuse.contents = UIColor.blue var boxNode = SCNNode(geometry: box) boxNode.scale = SCNVector3(0.5, 0.5, 0.5) boxNode.position.x += 0.5 boxNode.physicsBody = SCNPhysicsBody(type: SCNPhysicsBodyType.static,

SceneKit: how to control size of imported assets, one DAE file creates SCNNode of huge size while another is “normal”

試著忘記壹切 提交于 2019-12-10 21:23:40
问题 A designer provided the attached two DAE files created in Cinema 4D. Both assets are of comparable size inside of Cinema 4D. Both DAE files were produced with the same export process. Importing the DAE files into a SceneKit scene, however, produces different results. Chango.dae imports at a "normal" size with a bounding box of ~3x4x3. Tiki.dae imports at a huge size with a bounding box of ~155x325x140. Its dimensions inside C4D are ~122x283x142. Questions: 1) How do you make sure assets "fit"

Why SCNPhysicsBody resets position when set eulerAngles?

人盡茶涼 提交于 2019-12-10 15:26:19
问题 I'm trying to use SceneKit to develop a game for tvOS, and I'm having an issue. When I set the node's eulerAngle before apply an impulse to the physicsBody the node is reset to his original position. I was expecting to see the nodes moving around on the floor's plane, but on each tap the nodes are moved to the origin position before the impulse is applied. I'm new at the use of this framework, so I wonder where is the mistake. I'm using the new AppleTV with tvOS 9.0 and XCode 7.1.1 To

Why is SCNNode “jiggling” when dropped onto SCNPlane?

眉间皱痕 提交于 2019-12-10 07:39:08
问题 I have a SCNPlane that is added to the scene when a sufficient area is detected for a horizontal surface. The plane appears to be placed in a correct spot, according to the floor/table it's being placed on. The problem is when I drop a SCNNode(this has been consistent whether it was a box, pyramid, 3D-model, etc.) onto the plane, it will eventually find a spot to land and 99% start jiggling all crazy. Very few times has it just landed and not moved at all. I also think this may be cause by

ARKit Place a SCNNode facing the camera

做~自己de王妃 提交于 2019-12-09 04:27:58
问题 I'm using ARKit to display 3D objects. I managed to place the nodes in the real world in front of the user (aka the camera). But I don't manage to make them to face the camera when I drop them. let tap_point=CGPoint(x: x, y: y) let results=arscn_view.hitTest(tap_point, types: .estimatedHorizontalPlane) guard results.count>0 else{ return } guard let r=results.first else{ return } let hit_tf=SCNMatrix4(r.worldTransform) let new_pos=SCNVector3Make(hit_tf.m41, hit_tf.m42+Float(0.2), hit_tf.m43)

Detect touch on SCNNode in ARKit

自作多情 提交于 2019-12-08 08:49:24
问题 I have placed a SCNNode (a plane) at the location of a recognized image in ARKit 1.5 beta. I would like to print a message to the console when the plane is tapped on. So far I have this code: // MARK: - ARSCNViewDelegate (Image detection results) /// - Tag: ARImageAnchor-Visualizing func renderer(_ renderer: SCNSceneRenderer, didAdd node: SCNNode, for anchor: ARAnchor) { guard let imageAnchor = anchor as? ARImageAnchor else { return } let referenceImage = imageAnchor.referenceImage