How this method works is very different from what is expected.
Looking at the comments, it seems that this method will simulate the reflection of light? maxReflections This parameter is used to control how many times the light will be reflected? And to reflect at least once?
If it is understood according to the above logic, it is in line with the actual phenomenon.
If so, what method should be used for ray detection in general?
Ray detection as I understand it is simply calculating the intersection of a ray with a shape.