How to add 2D preview to 3D SCNNode in sceneset

I am trying to add a type of "notification" above a 3D view that follows it, and if the camera rotates or SCNNode is rotated, that view always stays in front of the front view, it does "expensive" calculations and does a flat 3D and rotate it every time some of the parents rotate, or the camera, and I don't want to add a UIView to everything that follows the 3D xyz because I want it to interact with the depth sorting of 3D operations.

Here's an example of what I want to achieve:

Example

This is an idea that does not revolve parents with him, how can I achieve it?

Thank you in advance!

+3


source to share


1 answer


I found a way to do it, it's really simple like this:

SCNLookAtConstraint *constraint = [SCNLookAtConstraint lookAtConstraintWithTarget:cameraNode];
constraint.gimbalLockEnabled = YES;
nodeA.constraints = @[constraint];

      



This will make nodeA always look at the camera and I am setting gimbalLockEnabled = YES

so that it does not rotate strangely.

Hope it helps someone, it saved my game :-)

+3


source







All Articles