user3765506 user3765506 - 3 months ago 30x
iOS Question

How to set contents of scenekit background to cube map

I am trying to set the background contents of a scene to a skybox effect using about array of 6 images.

I have created the array of images in the correct order, I know I need to then use

+ (instancetype) materialPropertyWithContents:(id)contents

However I'm struggling to work out how and where exactly I use that class method to return the property containing the cube map.


SCNScene's "background" property is of the SCNMaterialProperty class. So you can directly set it's contents to an array of 6 images to setup your skybox (see SCNScene.h).

aScene.background.contents = @[@"Right.png", @"Left.png", @"Top.png", @"Bottom.png", @"Back.png", @"Front.png"];

Make sure your 6 images are square and with the same dimensions.