I have downloaded two different 3D models from Sketchfab. i imported both model in ARKit 3D object placing. While placing the 3D models the node is not properly aligning with the manipulator for one of the models..
i have attached screenshot.
Left side is where the selected node(viewport) and manipulator are properly aligned. But Right side the selected node(viewport) and manipulator are not properly aligned. How do i make the node and manipulator align to the center like left side 3D model. please guide me. Thank you
@Josh Robbins
i have tried your code but still i am getting same issue.
box.firstMaterial?.emission.contents = UIColor.green
box.firstMaterial?.shaderModifiers = [SCNShaderModifierEntryPoint.surface: sm]
box.firstMaterial?.isDoubleSided = true
let boxNode = SCNNode(geometry: box)
boxNode.position = SCNVector3(node.position.x,(node.position.y + Float((proheights * 0.0234)/2)),node.position.z)
let minimum = float3(treenode.boundingBox.min)
let maximum = float3(treenode.boundingBox.max)
let translation = (maximum - minimum) * 0.5
//3. Set The Pivot
treenode.pivot = SCNMatrix4MakeTranslation(translation.x, translation.y, translation.z)
boxNode.pivot = SCNMatrix4MakeTranslation(translation.x, translation.y, translation.z)
self.addChildNode(boxNode)
updated code
let treenode = SCNNode()
let box = SCNBox(width: (prowidths * 0.0234), height: (proheights * 0.0234), length: (prolenght * 0.0234), chamferRadius: 0)
box.firstMaterial?.emission.contents = UIColor.green
box.firstMaterial?.shaderModifiers = [SCNShaderModifierEntryPoint.surface: sm]
box.firstMaterial?.isDoubleSided = true
let boxNode = SCNNode(geometry: box)
boxNode.position = SCNVector3(treenode.position.x,(treenode.position.y + Float((proheights * 0.0234)/2)),treenode.position.z)
let minimum = float3(treenode.boundingBox.min)
let maximum = float3(treenode.boundingBox.max)
let translation = (maximum - minimum) * 0.5
//3. Set The Pivot
treenode.pivot = SCNMatrix4MakeTranslation(translation.x, translation.y, translation.z)
boxNode.pivot = SCNMatrix4MakeTranslation(translation.x, translation.y, translation.z)
self.addChildNode(boxNode)
self.addChildNode(treenode)
return treenode