I’m successfully displaying the 3d avatars in my iOS app.
But I want to get the position of the head of the 3d avatar, but I’m only getting 0,0 coordinates. The only coordinates I am given are that of the hips. Why is that? Is there a way to find where the head is located?
here is my Swift code:
let scene = SCNScene.init(gltfAsset: asset)
print(scene.rootNode.childNodes.count)
scene.rootNode.childNodes.first?.childNodes.forEach { $0.simdTransform = $0.simdTransform }
if let children = scene.rootNode.childNodes.first?.childNodes {
for node in children {
print(node)
print(node.position)
print(node.worldPosition)
}
}
This prints the following:
<SCNNode: 0x106f3fc70 'Hips' pos(-0.000000 1.036964 0.040429) rot(-1.000013 -0.000872 0.000026 0.059964) | 3 children>
SCNVector3(x: -3.8782454e-14, y: 1.0369642, z: 0.04042893)
SCNVector3(x: -3.8782454e-14, y: 1.0369642, z: 0.04042893)
<SCNNode: 0x106f3feb0 'EyeLeft' | geometry=<SCNGeometry: 0x30257b440 'EyeLeft'> | no child>
SCNVector3(x: 0.0, y: 0.0, z: 0.0)
SCNVector3(x: 0.0, y: 0.0, z: 0.0)
<SCNNode: 0x106f400f0 'EyeRight' | geometry=<SCNGeometry: 0x30257b4f0 'EyeRight'> | no child>
SCNVector3(x: 0.0, y: 0.0, z: 0.0)
SCNVector3(x: 0.0, y: 0.0, z: 0.0)
<SCNNode: 0x106f40330 'Wolf3D_Head' | geometry=<SCNGeometry: 0x30257b5a0 'Wolf3D_Head'> | no child>
SCNVector3(x: 0.0, y: 0.0, z: 0.0)
SCNVector3(x: 0.0, y: 0.0, z: 0.0)
<SCNNode: 0x106f40570 'Wolf3D_Teeth' | geometry=<SCNGeometry: 0x30257b650 'Wolf3D_Teeth'> | no child>
SCNVector3(x: 0.0, y: 0.0, z: 0.0)
SCNVector3(x: 0.0, y: 0.0, z: 0.0)
<SCNNode: 0x106f409f0 'Wolf3D_Headwear' | geometry=<SCNGeometry: 0x30257b700 'Wolf3D_Headwear'> | no child>
SCNVector3(x: 0.0, y: 0.0, z: 0.0)
SCNVector3(x: 0.0, y: 0.0, z: 0.0)
<SCNNode: 0x106f40c30 'Wolf3D_Body' | geometry=<SCNGeometry: 0x30257b7b0 'Wolf3D_Body'> | no child>
SCNVector3(x: 0.0, y: 0.0, z: 0.0)
SCNVector3(x: 0.0, y: 0.0, z: 0.0)
<SCNNode: 0x106f40e70 'Wolf3D_Outfit_Bottom' | geometry=<SCNGeometry: 0x30257b860 'Wolf3D_Outfit_Bottom'> | no child>
SCNVector3(x: 0.0, y: 0.0, z: 0.0)
SCNVector3(x: 0.0, y: 0.0, z: 0.0)
<SCNNode: 0x106f410b0 'Wolf3D_Outfit_Footwear' | geometry=<SCNGeometry: 0x30257b910 'Wolf3D_Outfit_Footwear'> | no child>
SCNVector3(x: 0.0, y: 0.0, z: 0.0)
SCNVector3(x: 0.0, y: 0.0, z: 0.0)
<SCNNode: 0x106f412f0 'Wolf3D_Outfit_Top' | geometry=<SCNGeometry: 0x30257b9c0 'Wolf3D_Outfit_Top'> | no child>
SCNVector3(x: 0.0, y: 0.0, z: 0.0)
SCNVector3(x: 0.0, y: 0.0, z: 0.0)