2
votes

I have ARKit-scene where i place a spotlight overhead to cast shadows.

Because i want to cast shadow on a transparent plane, i set the property shadowMode to deferred (https://developer.apple.com/documentation/scenekit/scnshadowmode/1523758-deferred) on the spotlight.

This works, but when i remove the spotlight again, the app crashes with:

[SceneKit] Error: The shadow node is not registered
[SceneKit] Error: _willExecuteDeferredShadows - no light

The app does not crash, when shadowMode is not set (defaults to "forward")

How can i remove the light without crashing?

1
It is hard to help without this part of your code, but it looks like you set property of shadow before declaring it.Zydnar

1 Answers

2
votes

I found out that i need to set node.hidden=Yes on the node that contains the light before removing it. This provents the crash:

if(node.light) {
  node.hidden = YES;
  [node removeFromParentNode];
}