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
Show file tree
Hide file tree
Changes from all 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
8 changes: 8 additions & 0 deletions src/webgl/3d_primitives.js
Original file line number Diff line number Diff line change
Expand Up @@ -180,6 +180,14 @@ p5.prototype.freeGeometry = function(geometry) {
this._renderer._freeBuffers(geometry.gid);
};

/**
* Clears the internal Color of the Geometry.
* @method clearColors
*/
p5.prototype.clearColors = function () {
return this._renderer.clearColors();
};

/**
* Draw a plane with given a width and height
* @method plane
Expand Down
31 changes: 26 additions & 5 deletions src/webgl/p5.Camera.js
Original file line number Diff line number Diff line change
Expand Up @@ -122,18 +122,39 @@ p5.prototype.camera = function (...args) {
* that are close to the camera appear their actual size while those
* that are further away from the camera appear smaller.
*
*
* The parameters to this function define the viewing frustum
* (the truncated pyramid within which objects are seen by the camera) through
* 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 as:
*
*
* fov- The default field of view for the camera is such that the full height of renderer is visible when it is positioned at a default distance of 800 units from the camera.
*
* aspect- The default aspect ratio is the ratio of renderer's width to renderer's height.
*
* near - The default value for the near clipping plane is 0.1 times the default distance from the camera to the point it is looking at i.e 800.
*
* far - The default value for the far clipping plane is 10 times the default distance from the camera to the point it is looking at i.e 800.
*
* If you prefer a fixed field of view, follow these steps:
*
* 1.Choose your desired field of view angle (`fovy`). This is how wide the camera can see.
*
* 2.To position the camera correctly, use the formula:
* cameraDistance = (height / 2) / tan(fovy / 2);
* This ensures that you can see the entire width across horizontally and height across vertically at the fixed field of view.
*
* 3.Set the near value to cameraDistance / 10 and the far value to cameraDistance * 10 .
*
* 4.Simply, call perspective with the chosen field of view, canvas aspect ratio, and near/far values:
* perspective(fovy, width / height, cameraDistance / 10, cameraDistance * 10);
* @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
* 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
Expand All @@ -156,7 +177,7 @@ p5.prototype.camera = function (...args) {
*
* rotateX(-0.3);
* rotateY(-0.2);
* translate(0, 0, -50);
* translate(0, 0, -100);
*
* push();
* translate(-15, 0, sin(frameCount / 30) * 95);
Expand Down
Loading