api icon indicating copy to clipboard operation
api copied to clipboard

3D: angles are not defined consistently

Open glenrobson opened this issue 1 year ago • 1 comments

Remark by Rita in the European timed 3d TSG call:

Angles are not defined consistently as far as I can see

  • Value for fieldOfView of a perspective camera denotes the full angle
  • Value for angle in the case of SpotLight denotes the half angle

We noted that 3js isn't very clear in what it supports for spotlight:

"angle - Maximum angle of light dispersion from its direction whose upper bound is Math.PI/2."

Math.PI / 2 = 90 degrees so we assume its half the angle but it would be good to test this.

The discussion in the meeting was that it would be useful to have consistency but if we are following the 3JS approach then that is also fine with implementers but would be good to confirm this is the reason for the inconsistency.

glenrobson avatar Feb 21 '24 11:02 glenrobson

For spotlights in three.js, the angle is indeed the half-angle of the spotlight cone. Here is an example demonstrating a spotlight angle of 90 degrees: https://codepen.io/JellyfishJail/pen/vYPwNvx (copied and only slightly modified from https://codepen.io/boytchev/full/ZEMJEeR). The angle is specified in line 40 and can be changed to interactively see the effect.

With regard to differences between the fieldOfView angle value and the spotlight dispersion angle, it's worth noting that the spotlight angle defines a cone while the field of view doesn't. The FOV is defining a square frustum, and for both the draft spec and three.js specifically the FOV defines the top-to-bottom angle of the frustum planes. Out of curiosity, does anything use half-angles for FOV?

JulieWinchester avatar Feb 21 '24 16:02 JulieWinchester