Any way to move the origin after scan ?


#1

Hi everyone,

I’m looking for a way to move the origin into the center of the cube after scan has been released. Is it possible to change it on the STMesh ?

I need it to rotate from the center of the mesh in SceneKit.

Any help will be appreciated.

Thanks.


#2

Something like this has been working for me…

        let bBoxMax = model.boundingBox.max
        let bBoxMin = model.boundingBox.min
        let isoCenter = SCNVector3((bBoxMax.x + bBoxMin.x)/2, (bBoxMax.y + bBoxMin.y)/2,
                                   (bBoxMax.z + bBoxMin.z)/2)
        model.pivot = SCNMatrix4MakeTranslation(isoCenter.x, isoCenter.y, isoCenter.z)

#3

Thanks it work like a charm !

No way to modify the STMesh ?


#4

Sure, the vertex data is accessible…