`camera.viewport` is undocumented

There’s no indication of camera.viewport in the docs. Looks like it is used specifically for WebXR purposes, f.e. it is set here:

I see it used outside of the class in this example:

Should it perhaps be set to null as default in the Camera class, and a blurb added to docs?

I’m not sure what the blurb should be, but probably something starting with If rendering in WebXR mode, this will be set to...

Both examples feature two different viewport-s.

In the first example, viewport appears to be a custom variable inside camera. That’s why it is not documented. You can check the source code of Camera, PerspectiveCamera and StereoCamera. Neither of them defines property viewport.

The second example uses the method viewport(...) which is part of the rendering context – it is external to Three.js, not a part of it. The documentation points to WebGLRenderingContext, that describes the viewport method.

The first link is not an example, it is WebXRManager, and it sets the camera.viewport.

The second link is an example using that same camera.viewport.

1 Like

By example I mean the piece of code posted in your message.

Otherwise, yes, I got confused because there are two distinct viewports in the second example → the value viewport and the method viewport. Initially I thought you are referring to the method.

In any case, if viewport is used outside the class, it is better to be documented, because someone else might need to restore the viewport and will have no clue that it is already stored in the camera.

1 Like