ARKit : Make virtual 3D objects to point towards camera

懵懂的女人 提交于 2021-02-08 03:46:48

问题


I am trying to build an app based on ARKit to place 3D virtual objects on to the plane that is detected. I found a useful project on GitHub Placing Virtual Objects

This does the job exactly what I am looking for. However, when any virtual object is placed in front of the camera, it may or may not face the camera. Sometimes 3D objects look in the opposite direction of camera

I have tried to add SCNconstraints to virtual object node and tweak the rotation and orientation of 3D Models to look at the camera when placed. Nothing seems to be working.

Below code works while placing the object in the scene. However, the object rotates when the camera is moved back and forth. I want to disable this after object has been placed

let yFreeConstraint = SCNBillboardConstraint()
yFreeConstraint.freeAxes = .Y // optionally
object.constraints = [yFreeConstraint]

It would be a great help if someone can crack this down!

来源:https://stackoverflow.com/questions/47579083/arkit-make-virtual-3d-objects-to-point-towards-camera

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!