Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Addresses issue #6519 #6532

Closed
wants to merge 16 commits into from
Closed
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
31 changes: 23 additions & 8 deletions src/webgl/p5.Camera.js
Original file line number Diff line number Diff line change
Expand Up @@ -127,16 +127,31 @@ p5.prototype.camera = function (...args) {
* vertical field of view, aspect ratio (usually width/height), and near and far
* clipping planes.
*
* If no parameters are given, the following default is used:
* perspective(PI/3, width/height, eyeZ/10, eyeZ*10),
* where eyeZ is equal to ((height/2) / tan(PI/6)).
* If no parameters are given, the default values are used, with a fixed location and a variable field of view.
* @method perspective
* @for p5
* @param {Number} [fovy] camera frustum vertical field of view,
* from bottom to top of view, in <a href="#/p5/angleMode">angleMode</a> units
* @param {Number} [aspect] camera frustum aspect ratio
* @param {Number} [near] frustum near plane length
* @param {Number} [far] frustum far plane length
* @param {Number} [fovy] - camera frustum vertical field of view,
* from bottom to top of view, in <a href="#/p5/angleMode">angleMode</a> units.
* The default value is now variable and based on the canvas size as:
* this.defaultEyeZ = 800;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Instead of writing this as code, maybe we can write what's going on in plain English? i.e. we pick a field of view that ensures you can see exactly width pixels across horizontally and height pixels across vertically 800 units away from the camera.

* defaultCameraFOV = 2 * Math.atan(this._renderer.height / 2 / this.defaultEyeZ);
*
* @param {Number} [aspect] camera frustum aspect ratio .The default value = this._renderer.width / this._renderer.height;
* @param {Number} [near] frustum near plane length or the near clipping plane. The default value = this.defaultEyeZ * 0.1;
* @param {Number} [far] frustum far plane length or the far clipping plane. The default value = this.defaultEyeZ * 10;
*
* However,If you prefer a fixed field of view, you can use the old defaults:
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Rather than referring to these as the old defaults, we can motivate why someone might want to do this by starting with "If you want a fixed field of view". To ensure that you can see width across horizontally and height across vertically at that fixed field of view, you need to place your camera (height/2) / tan(fovy / 2) away from the subject, and ten go on to explain how the near/far values are derived from that.

*
* - Field of view: PI/3 (60 degrees)
* - Canvas aspect ratio: width / height
* - Near clipping plane: eyeZ / 10
* - Far clipping plane: eyeZ * 10
*
* @example
* Set a fixed field of view
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Was this intended to be a new example with code?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Was this intended to be a new example with code?

yes my bad , I thought of providing a separate example for the perspective function's syntax with the old default values. But now , i think there's no need of a separate example for this. I 'll just remove this one.

* perspective(PI/3, width / height, eyeZ / 10, eyeZ * 10);
* where eyeZ is equal to ((height/2) / tan(PI/6)).
*
* @chainable
* @example
* <div>
Expand Down
Loading