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).
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
Why Is the Alert Triggering Out of Order If Value Is Not Updated
Swift - Force Synchronous Execution of Work and Subsequent UI Rendering
Add Environmentobject in Swiftui 2.0
Pdfview Does Not Display My PDF
Callkit - How to Bring the Cxcallcontroller to the Front
No Value Associated with Key Codingkeys While Trying to Get Data from Github API in Xcode App
How to Create a Struct to Match This JSON
Differencebetween ":" and "=" in Swift
How to Make an Enum Conform to a Protocol in Swift
Map or Reduce with Index in Swift
Hide Password with "•••••••" in a Textfield
How to Access a Swift Enum Associated Value Outside of a Switch Statement
How to Declare a Class Level Function in Swift
Output Compile Durations for Swift Files
Type of Expression Is Ambiguous Without More Context Swift
How to Click a Button Programmatically
Flip Arfaceanchor from Left-Handed to Right-Handed Coordinate System