此代码摘录(场景,相机,灯光等,从代码中删除)在iOS模拟器上的
Swift中工作:
let BoxNode = SCNNode() // Create a Box BoxNode.geometry = SCNBox(width: 1,height: 1,length: 1,chamferRadius: 0.1) let numFaces = 6 scene.rootNode.addChildNode(BoxNode) // create and configure a material for each face var materials: [SCNMaterial] = Array() for i in 1...numFaces { let material = SCNMaterial() material.diffuse.contents = UIImage(named: "texture") materials += material } // set the material to the 3d object geometry BoxNode.geometry.materials = materials
尝试在Wings3D中创建的简单库存几何体,保存到DAE,并在应用程序中加载,给我一个合适的形状,但脸上没有阴影和图像:
let BoxNode = SCNNode() // Load the geometry let urlToColladaFile = NSBundle.mainBundle().URLForResource("Objects",withExtension:"dae") let scenesource = SCNScenesource(URL:urlToColladaFile,options:nil) BoxNode.geometry = scenesource.entryWithIdentifier("dodecahedron3-0",withClass:SCNGeometry.self) as SCNGeometry let numFaces = 10 scene.rootNode.addChildNode(BoxNode) // create and configure a material for each face var materials: [SCNMaterial] = Array() for i in 1...numFaces { let material = SCNMaterial() material.diffuse.contents = UIImage(named: "texture") materials += material } // set the material to the 3d object geometry BoxNode.geometry.materials = materials
我错过了什么?