'SceneKit – SCNLightTypeProbe doesn't work

My scene has been developed programmatically and not through an Xcode scene file. I could gather that light probes can be updated programmatically through the use of the updateProbes() of the SCNRenderer class. I have the following code, where I am trying to initialize a light probe by using the updateProbes() method:

SCNNode *probe = [SCNNode node];
probe.position = SCNVector3Make(2.145f, 1.216f, 3.1f);
probe.light = [SCNLight light];
probe.light.type = SCNLightTypeProbe;

SCNScene* scene = [SCNScene scene];

SCNNode *ambientLight = [SCNNode node];
ambientLight.light = [SCNLight light];
ambientLight.light.type = SCNLightTypeAmbient;
ambientLight.light.color = [NSColor whiteColor];
ambientLight.light.intensity = 800.0;
[scene.rootNode addChildNode:ambientLight];
[scene.rootNode addChildNode:probe];

// create environment lights
NSColor * backgroundColor = [NSColor whiteColor];

scene.background.contents = backgroundColor;  // TODO Set to spec background color.
scene.background.intensity = 2.;

SCNRenderer* probeRenderer = [SCNRenderer rendererWithDevice:nil options:nil];
probeRenderer.scene = scene;

NSArray<SCNNode*> *probes = [NSArray arrayWithObjects: probe, nil];
[probeRenderer updateProbes: probes atTime:0.0];

NSLog(@"%@", probe.light.sphericalHarmonicsCoefficients);

However, I do not get any light from this lightprobe. Also, when I dumped the sphericalHarmonicsCoefficients I see all zeros. What am I missing?



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source