Issue with Adding Node to Scene View

Issue with adding node to scene view

It seems that this issue entirely depends on a pivot point's position and a scale of your model.

Pivot point meets ARAnchor and helps you control a model's offset, orientation and scale of model on a floor, a table-top, or a wall.

node.scale = SCNVector3(x: 0.2, y: 0.2, z: 0.2)
node.pivot = SCNMatrix4MakeTranslation(0, -0.5, 0)

...or for positioning pivot use this approach:

node.simdPivot.columns.3.y = -0.5

So if you want your model to precisely stand on an invisible detected plane move a pivot point in SceneKit toward desired place or set its position in 3D authoring tool (like 3dsMax or Blender).

Sample Image

How to attach SCNNode fixed to ARKit's pointOfView?

You should use .kinematic instead of .static

Use kinematic bodies for scene elements that you want to control directly directly but whose movement manipulates other elements. For example, to allow the user to push objects around with a finger, you might create a kinematic body and attach it to an invisible node that you move to follow touch events.

Why Node is being added below the detected plane in ARKit

When you're setting the position of a SCNNode, you're defining position of the node's center point and that's the reason your node is vertically in the middle of the plane.

Adding half of the node's height to the y-axis is probably a very easy way to place the node on the plane as you already mentioned:

let position = SCNVector3(planeHitTest.worldTransform.columns.3.x,
planeHitTest.worldTransform.columns.3.y + Float(box.height/2),
planeHitTest.worldTransform.columns.3.z)


Related Topics



Leave a reply



Submit