Search code examples
iosscenekitsketchup

scenekit model from sketchup disappears


I am playing around with scene kit.

I do not know a lot about modeling but i created a very basic Sketchup model with no materials or textures.

I exported the model from ketchup and imported it into the scene.

As i move the camera around towards one end of the model the rear disappears and vice versa. As the camera rotates towards the front the rear gets shadowed in black.

What is the reason for this?

Lighting? Here is the code for the scene. Its a basic Xcode game project

// create a new scene
SCNScene *scene = [SCNScene sceneNamed:@"ship_transport.dae"];

// 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, 100);

// 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 whiteColor];
[scene.rootNode addChildNode:ambientLightNode];


// retrieve the ship node
SCNNode *ship = [scene.rootNode childNodeWithName:@"ship" recursively:YES];
ship.geometry.firstMaterial.diffuse.contents = [UIColor redColor];
ship.geometry.firstMaterial.specular.contents = [UIColor whiteColor];
SCNVector3 vector = SCNVector3Make(.1, .1, .1);
[ship setScale:vector];
//[scene.rootNode addChildNode:lightNode];

// animate the 3d object
[ship runAction:[SCNAction repeatActionForever:[SCNAction rotateByX:0 y:0 z:0 duration:1]]];

// retrieve the SCNView
SCNView *scnView = (SCNView *)self.view;
scnView.autoenablesDefaultLighting = true;

// set the scene to the view
scnView.scene = scene;

// allows the user to manipulate the camera
scnView.allowsCameraControl = YES;

// show statistics such as fps and timing information
scnView.showsStatistics = YES;

// configure the view
scnView.backgroundColor = [UIColor darkGrayColor];

Solution

  • Try setting the zFar property on the camera. Other related properties to try changing would be the xFov and yFov.