0

I've tried adding a ScenKit Scene to a WKInterfaceController, created the IBOutlet WKInterfaceSCNScene* sceneInterface; (as documented) and seated the scene property into interface builder to a SceneKit scene just created but I don't see the scene on the watch.

I've tried also using the presentScene method and seated programmatically the scene as below:

SCNScene *scene = [SCNScene sceneNamed:@"circleScene.scn"];

// create and add a camera to the scene
SCNNode *cameraNode = [SCNNode node];
cameraNode.camera = [SCNCamera camera];
[scene.rootNode addChildNode:cameraNode];

// place the camera
cameraNode.position = SCNVector3Make(0, 0, 15);

// create and add a light to the scene
SCNNode *lightNode = [SCNNode node];
lightNode.light = [SCNLight light];
lightNode.light.type = SCNLightTypeOmni;
lightNode.position = SCNVector3Make(0, 10, 10);
[scene.rootNode addChildNode:lightNode];

// create and add an ambient light to the scene
SCNNode *ambientLightNode = [SCNNode node];
ambientLightNode.light = [SCNLight light];
ambientLightNode.light.type = SCNLightTypeAmbient;
ambientLightNode.light.color = [UIColor darkGrayColor];
[scene.rootNode addChildNode:ambientLightNode];

[self.sceneInterface presentScene:scene withTransition:[SKTransition fadeWithDuration:1] incomingPointOfView:lightNode completionHandler:nil];

What I'm doing wrong ?

Hal Mueller
  • 7,019
  • 2
  • 24
  • 42
WonderBoy
  • 145
  • 2
  • 5

1 Answers1

0

Standard things to check when debugging the "my scene is blank" problem:

  • Did the scene load correctly?
  • Is the camera pointed at an object in the scene? Try adding an SCNLookAtConstraint.
  • Is the camera location outside of the object?
  • Is the SCNView using the camera you created?
  • Is the Z range for the camera set correctly? (set automaticallyAdjustsZRange:YES to start with)
  • Is the outlet to sceneInterface connected?

If you run this code in a Playground, it's easier to get all the moving parts working together.

Hal Mueller
  • 7,019
  • 2
  • 24
  • 42
  • The scene renders correctly in a standard SCNView (in a iOS ViewController), while it does not appear placing it in a WKInterfaceController. – WonderBoy Oct 03 '16 at 14:26
  • Hmm. How about adding a couple of NSAssert calls to make sure that `scene` and `sceneInterface` are not nil, and that the interface's camera is the one you created? – Hal Mueller Oct 03 '16 at 22:20