Great article!
You can use these two lines to assign the physical based lighting mode instead of recreating and reassigning the material:
cakeNode.geometry?.firstMaterial?.lightingModel = .physicallyBased
plateNode.geometry?.firstMaterial?.lightingModel = .physicallyBased