Are SceneKit eulerAngles Floats or CGFloats?

314 Views Asked by At

According to the SceneKit API, euler angles, as a property of SCNNode, are SCNVector3. And SCNVector3 is { CGFloat x, y, z: }. But when I attempt to assign a CGFloat to a eulerAngle property of a node, Xcode claims I'm trying to assign to type 'Float'. Here's a snippet from my panGesture handler:

    baseNode.eulerAngles.x = newAngleX

I can avoid this by casting as Floats but I'm curious, especially since SCNVector3 still seems to accept CGFloats.

1

There are 1 best solutions below

0
On

You're right, the documentation is wrong. Directly from SceneKit/SceneKitTypes.h:

typedef struct SCNVector3 {
    float x, y, z;
} SCNVector3;

Which, amongst other things, means they're 32-bit regardless of target, unlike CGFloats. So it's not a mere typedef issue despite the naming similarity — Swift is right to want an explicit cast.