SCNBillboardConstraint isn’t working. Node with constraint doesn’t change

Related searches

Perhaps I am not setting up the camera properly… I’m starting with a scn file with a camera. In Xcode, rotating the free camera around, the geometries rotate as expected. However, at runtime, nothing happens.

It doesn’t seem to matter if I add the constraint in code or in the editor. The look at constraint works.

It also doesn’t seem to matter if I use the camera from the scn file or if I add a camera in code.

The sample code is

class Poster: SCNNode {
    let match:GKTurnBasedMatch

    init(match:GKTurnBasedMatch, width:CGFloat, height:CGFloat) {
        self.match = match

        super.init()

        // SCNPlane(width: width, height: height)
        self.geometry = SCNBox(width: width, height: height, length: 0.1, chamferRadius: 0) 

        self.constraints = [SCNBillboardConstraint()]

        self.updatePosterImage()
    }
}

So… I gave up on the billboard constraint.

I’m using a SCNLookAtConstraint that looks at the camera node, with the gimbal lock enabled.

I was using a SCNPlane but it was doing weird stuff. So I went with a SCNBox for the geometry.

So, in the constructor:

self.geometry = SCNBox(width: self.size.width, height: self.size.height, length: 0.1, chamferRadius: 0) 
let it = SCNLookAtConstraint(target: cameraNode)
it.isGimbalLockEnabled = true
self.constraints = [it]

It works.

SCNBillboardConstraint isn't working. Node with , So… I gave up on the billboard constraint. I'm using a SCNLookAtConstraint that looks at the camera node, with the gimbal lock enabled. Perhaps I am not setting up the camera properly… I’m starting with a scn file with a camera. In Xcode, rotating the free camera around, the geometries rotate as expected. However, at runtime, nothing

Try this:

A constraint that orients theNode to always point toward the current camera.

   // Create the constraint
   SCNBillboardConstraint *aConstraint = [SCNBillboardConstraint billboardConstraint];

   theNode.constraints = @[aConstraint];

theNode is the node you want pointing to the camera. This should work.

Updated

Ok, if you were to create a sample Project with the Game template. And then make the following changes:

// create a clone of the ship, change position and rotation
SCNNode *ship2 = [ship clone];
ship2.position = SCNVector3Make(0, 4, 0);
ship2.eulerAngles = SCNVector3Make(0, M_PI_2, 0);
[scene.rootNode addChildNode:ship2];

// Add the constraint to `ship`
SCNBillboardConstraint *aConstraint = [SCNBillboardConstraint billboardConstraint];
ship.constraints = @[aConstraint];

ship is constrained but ship2 isn't.

If you were to add this:

       ship2.constraints = @[aConstraint];

Now, both will face the camera. Isn't this what you are looking for?

SCNBillboardConstraint isn't working. Node with - iOS, Perhaps I am not setting up the camera properly… I'm starting with a scn file with a camera. In Xcode, rotating the free camera around, the geometries rotate as� Automatically constrains a SCNNode so that it always points to the current rendering node.

You're missing ".init()" on the SCNBillboardConstraint(). This line alone did all the work for me:

node.constraints = [SCNBillboardConstraint.init()]

SCNBillboardConstraint Class (SceneKit), All, null)] public class SCNBillboardConstraint : SceneKit.SCNConstraint A constructor that initializes the object from the data stored in the unarchiver object. In macOS 10.9 and later, a custom accessibility object that is an NSObject subclass can post accessibility notifications if it meets the following criteria:The lifetime of the custom accessibility object must match the lifetime of the corresponding element in the app's UI.Typically, a custom accessibility object that acts as a proxy for an onscreen UI element gets autoreleased and deallocated

By any chance are you using the allowsCameraControl property on SCNView?

If so, remember setting that will add a new camera to your scene (cloning an existing camera if one is present to match its settings), so if you create a constraint to your own camera, the constraint will not be linked to the camera that’s actually being used.

Per Apple in their WWDC 2017 video, they say that property is really for debugging purposes, not for a real-world use.

Simply put, you have to ensure you are moving around your own camera, not relying on the auto-created one.

SCNBillboardConstraint Constructor (SceneKit), SCNBillboardConstraint(NSCoder). A constructor that initializes the object from the data stored in the unarchiver object. C# Copy. [Foundation. SCNBillboard Axis All Align an affected node such that its orientation always matches that of the view.

SCNBillboardConstraint, A constraint that orients a node to always point toward the current camera. See: https://developer.apple.com/documentation/scenekit/scnbillboardconstraint� As explained in my previous answer, the accepted answer isn't optimal and works properly only for billboards, huds and other generally flat objects (not necessarily entirely 2D). When using 3D objects and disabling reading from the depth buffer and objects like the one in the image in above, it won't render correctly from every angle.

Call 1-866-257-6025 to talk about how billboards and other forms of outdoor advertising can make traffic work for you. We'll help you create the right campaign to increase your brand awareness and get more customers.

The SC Contractor's Licensing Board regulates the license, certification or registration of general and mechanical contractors, construction managers, burglar alarm and fire alarm contractors, fire sprinkler contractors, and the boiler safety program.

Comments
  • Can you post your sample code?
  • Do you have any code controlling the camera's response to input?
  • I did that. But I’ll try it again :)
  • The billboard constraint is exactly what I was looking for. In one scene, it seems to work as expected. But in the scene that I need it, it is doing nothing. I don’t know why the scenes would be different :(
  • Oh, how I wished that worked. I’ve tried that in a number of ways. When the node is created, after the node gets added to its parents children, etc.
  • init is implied and can be omitted.