Repository navigation
Implement camera-orbit attribute - #452
Conversation
| /** | ||
| * Convert a number expressing degrees to a number expressing radians. | ||
| */ | ||
| const degreesToRadians = (() => { |
There was a problem hiding this comment.
There was a problem hiding this comment.
👍 good catch, will fix!
9ed440a to
af011e3
Compare
af011e3 to
f5cc8f3
Compare
f5cc8f3 to
52d9f5e
Compare
| const expect = chai.expect; | ||
|
|
||
| suite('conversions', () => { | ||
| suite('deserializeSpherical', () => { |
There was a problem hiding this comment.
Nice! So glad to see the unit tests :)
| const value = parseFloat(lengthValueNode.value as any); | ||
|
|
||
| if ((self as any).isNaN(value)) { | ||
| return 0; |
There was a problem hiding this comment.
Why not throw an exception or log an error?
There was a problem hiding this comment.
The rationale here is that 0 is a reasonable default for any given meters length that cannot be parsed correctly. This is an homage to the CSS roots of this configuration value style. CSS doesn't throw or even warn you for invalid values. Instead, it substitutes a reasonable default.
| @@ -0,0 +1,55 @@ | |||
| export interface ValueNode { | |||
| }; | ||
|
|
||
| const extractValue = (() => { | ||
| const VALUE_RE = /^(([^-^.^0-9].*)|([-]?[0-9.]+))/; |
There was a problem hiding this comment.
In [^-^.^0-9], I think you only need the first ^ (that negates the entire class; the additional ^ match the actual ^ character). New thing I learned: you don't seem to need to escape the . inside of the class. I think that ([^-\.0-9]) is equivalent (or ([^-.0-9]) but I guess I'm not comfortable with my new fact).
Logically, extracting the value and the units feels paired, but here they're in separate methods. I'd see about combining them (I thought about suggesting putting them in the same regex, but I think that might make things more confusing); or, documenting the flow a bit more.
There was a problem hiding this comment.
This makes a bit more logical sense to me (ha, I know, regexes), although it still only extracts the values. I think it's a bit stricter (although still not strict) - specifically, "#a3#fd" now only matches "#a3".
^((?:(?:#|[a-zA-Z])[a-zA-Z\d]*)|(?:-?[\d.]+))
Oh! This will get the units too (in a second capture group). If my comment above regarding capturing both the values & units in the same method makes sense, and then the whole string can be matched (taking advantage of the strictness).
^((?:(?:#|[a-zA-Z])[a-zA-Z\d]*)|(?:-?[\d.]+))([a-zA-Z]*)$
Fixes fidelity test camera orientation and interaction prompt timing
|
FYI @svinkle this change will pull in the fix for screen reader SVG discoverability. |
| const POLAR_TRIENT_LABELS = ['upper-', '', 'lower-']; | ||
|
|
||
| const ORBIT_CAMERA_NEAR_PLANE = FRAMED_HEIGHT / 10.0; | ||
| const ORBIT_CAMERA_FAR_PLANE = FRAMED_HEIGHT * 10.0; |

Configurable
camera-orbitattributeThis change proposes the addition of a
camera-orbitattribute to enable users to control the starting and subsequent positions of the camera long a spherical orbit centered on the model.Highlights
camera-orbitattribute allows CSS-like configuration of starting and subsequent camera positions$theta $phi $radius0deg 75deg 1m,1 2 3,1rad 2deg 100cmauto: refers to the "ideal" camera distance as determined by scene framingcamera-orbit(see also Ability to disable camera interpolation when changing camera orbital position #454)getCameraOrbitmethod for real-time querying of current orbital positioninteraction-prompt-thresholdattribute controls the time that must have passed before an interaction prompt is presented to the usercontrolsattribute has been renamed tocamera-controlscontrolsattribute in the<video>elementalign-modelattribute introduced in Implement align-model attribute #441Name rationale
I waffled a bit when deciding what name to propose for the attribute. Initially, I thought that
camera-positionwas a good name. But,positionis already used by Three.js (and other libraries) to refer to the cartesian coordinates of things in 3D space. This attribute, by contrast, represents the spherical coordinates of the camera relative to a separately defined target origin.As far as API shape is concerned, the spherical position can be queried by the user, and is represented by a plain-object version of Three.js's
Sphericaldata structure e.g.,{ theta, phi, radius }. However, it might make sense to name this object's properties more explicitly, e.g.,{ azimuth, inclination, radius }. Feedback here is requested.Future work
Fixes #98
Additional fixes have been rolled in from #457 :
Fixes #435
Fixes #437
Fixes #446
Fixes #456