-
-
Notifications
You must be signed in to change notification settings - Fork 3.5k
Implemented roll function #6819
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -1058,6 +1058,64 @@ p5.Camera = class Camera { | |
); | ||
} | ||
|
||
/** | ||
* Rolling rotates the camera view in forward direction. | ||
* @method roll | ||
* @param {Number} angle amount to rotate camera in current | ||
* <a href="#/p5/angleMode">angleMode</a> units. | ||
* Greater than 0 values rotate counterclockwise (to the left). | ||
* @example | ||
* <div> | ||
* <code> | ||
* let cam; | ||
* let delta = 0.01; | ||
* | ||
* function setup() { | ||
* createCanvas(100, 100, WEBGL); | ||
* normalMaterial(); | ||
* cam = createCamera(); | ||
* // set initial pan angle | ||
* cam.roll(-0.8); | ||
* } | ||
* | ||
* function draw() { | ||
* background(200); | ||
* | ||
* // pan camera according to angle 'delta' | ||
* cam.roll(delta); | ||
* | ||
* // every 160 frames, switch direction | ||
* if (frameCount % 160 === 0) { | ||
* delta *= -1; | ||
* } | ||
* | ||
* rotateX(frameCount * 0.01); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Since we're going to be doing something akin to a rotateY(frameCount * 0.01);
translate(0, -100, 0);
box(20);
translate(0, 35, 0);
box(20);
translate(0, 35, 0);
box(20);
translate(0, 35, 0);
box(20);
translate(0, 35, 0);
box(20);
translate(0, 35, 0);
box(20);
translate(0, 35, 0);
box(20); |
||
* translate(0, 0, -100); | ||
* box(20); | ||
* translate(0, 0, 35); | ||
* box(20); | ||
* translate(0, 0, 35); | ||
* box(20); | ||
* translate(0, 0, 35); | ||
* box(20); | ||
* translate(0, 0, 35); | ||
* box(20); | ||
* translate(0, 0, 35); | ||
* box(20); | ||
* translate(0, 0, 35); | ||
* box(20); | ||
* } | ||
* </code> | ||
* </div> | ||
* | ||
* @alt | ||
* camera view pans in forward direction across a series boxes. | ||
*/ | ||
roll(amount) { | ||
const local = this._getLocalAxes(); | ||
this._rotateView(amount, local.z[0], local.z[1], local.z[2]); | ||
} | ||
|
||
/** | ||
* Panning rotates the camera view to the left and right. | ||
* @method pan | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There are a few uses of
pan
in comments, should these beroll
?