I have created an object and now I am trying to add an image as a texture to the object. But for some reason the texture doesnt show up and the object appears white. I downloaded a png file and added it to Xcode and created a SCNMaterial object that uses the image.
SCNMaterial *silverMaterial = [SCNMaterial material];
silverMaterial.diffuse.contents = [UIImage imageNamed:@"silver-background"];
SCNBox *horizontalBarOne = [SCNBox boxWithWidth:11 height:0.5 length:0.5 chamferRadius:0];
SCNNode *horizontalBarOneNode = [SCNNode nodeWithGeometry:horizontalBarOne];
horizontalBarOneNode.position = SCNVector3Make(0, 2.0, 0.5);
horizontalBarOne.materials = @[silverMaterial];
[scene.rootNode addChildNode:horizontalBarOneNode];
What am I doing wrong?
Move "silver-background" to Assets.xcassets.
Collected from the Internet
Please contact [email protected] to delete if infringement.
Comments