I didn't check your code in details, but do you know you can also set as material photo, a video, even a camera, like in this kind of code I use in a script
@on_main_thread
def set_material(self,face_no,type_material,val):
Material = SCNMaterial.material()
if type_material == 'color':
if type(val) is tuple:
r,g,b = val
else:
rgb = getrgb(val)
r,g,b = tuple(c/255.0 for c in rgb)
Material.contents = ObjCClass('UIColor').colorWithRed_green_blue_alpha_(r,g,b,1.0)
elif type_material == 'photo':
Material.contents = ObjCInstance(val.get_ui_image())
elif type_material == 'video':
video_objc = ObjCInstance(val)
video_url = ObjCClass('AVURLAsset').alloc().initWithURL_options_(video_objc.ALAssetURL(),None)
AVPlayer = ObjCClass('AVPlayerItem').playerItemWithAsset_(video_url)
p = ObjCClass('AVPlayer').playerWithPlayerItem_(AVPlayer)
Material.contents = p
p.play()
elif type_material == 'front camera':
inputDevice = ObjCClass('AVCaptureDevice').devices()[1]
Material.contents = inputDevice
elif type_material == 'rear camera':
inputDevice = ObjCClass('AVCaptureDevice').devices()[0]
Material.contents = inputDevice
self.faces[face_no] = (type_material,val)
return Material