Scnview节点显示为半透明

时间:2016-12-01 17:40:08

标签: scenekit scnnode

3D Perspective应该正确阻止货架等

ScnView的示例图片:

sample ScnView

非常简单。添加了Scnview。添加了Scnnodes(形状和灯光)

使用标准Omni型灯。

为什么前面的物体不会挡住后面的物体?

这是CODE:

[self.studioView addSubview:showTimeView];

showTimeView.frame = CGRectMake(self.paperView.frame.origin.x,
                                self.paperView.frame.origin.y,
                                self.paperView.frame.size.width,
                                self.paperView.frame.size.height);

SCNView *sceneView = (SCNView *)showTimeView;
sceneView.backgroundColor = [UIColor whiteColor];  

sceneView.scene = [SCNScene scene];
SCNNode *root = sceneView.scene.rootNode;
sceneView.allowsCameraControl           = YES;
sceneView.autoenablesDefaultLighting    = NO;


// Add Camera
SCNNode *cameraNode = [SCNNode node];
cameraNode.camera = [SCNCamera camera];
cameraNode.position = SCNVector3Make(0, 0, 100);
cameraNode.eulerAngles = SCNVector3Make(0, -M_PI/8, 0);
cameraNode.camera.zNear = 0;
cameraNode.camera.zFar  = thisModuleDepth;
cameraNode.camera.xFov  = thisWallWidth;
cameraNode.camera.yFov  = thisModuleHeight;
[root addChildNode:cameraNode];

// Add Cabinet Piece
SCNBox *cubeGeom = [SCNBox boxWithWidth:tW
                                 height:tH
                                 length:tD
                          chamferRadius:0.0];
SCNNode *cubeNode = [SCNNode nodeWithGeometry:cubeGeom];
cubeNode.position = SCNVector3Make(tX, tY, tZ);

// Tag Material
SCNMaterial *material = [SCNMaterial material];
material.diffuse.contents = [UIImage imageNamed:thisColor];
[material.diffuse.contents setAccessibilityIdentifier:thisColor] ;
[material.diffuse.contents setAccessibilityLabel:thisID] ;
cubeNode.geometry.firstMaterial = material;
cubeNode.geometry.firstMaterial.locksAmbientWithDiffuse = NO;
cubeNode.physicsBody = [SCNPhysicsBody staticBody];
[root addChildNode:cubeNode];

// Add spotlight
SCNLight *spotLight = [SCNLight light];
spotLight.type = SCNLightTypeOmni;
spotLight.color = [UIColor whiteColor];
SCNNode *spotLightNode = [SCNNode node];
spotLightNode.light = spotLight;
spotLightNode.position = SCNVector3Make(thisWallWidth / 2 ,thisModuleHeight, thisModuleDepth *2);
spotLightNode.light.intensity = 1000;
[root addChildNode:spotLightNode];

1 个答案:

答案 0 :(得分:1)

非常感谢,

我终于弄清楚出了什么问题!!!

将SCNCamera的automaticAdjustsZRange属性设置为true,并确保不会因为设置了错误的zNear或zFar而剪切任何内容。

感谢您的帮助!!!

在这里它被修复:Perfect 3D Perspective

enter image description here