Skip to content

Commit

Permalink
made it so that functions that customize a camera set the cameraType …
Browse files Browse the repository at this point in the history
…to custom
  • Loading branch information
RandomGamingDev committed Oct 25, 2023
1 parent c9609ca commit 409d980
Showing 1 changed file with 12 additions and 1 deletion.
13 changes: 12 additions & 1 deletion src/webgl/p5.Camera.js
Original file line number Diff line number Diff line change
Expand Up @@ -465,7 +465,7 @@ p5.prototype.createCamera = function () {
* camera view pans left and right across a series of rotating 3D boxes.
*/
p5.Camera = class Camera {
constructor(renderer) {
constructor(renderer, autoPosition = false, autoProjection = false) { // change
this._renderer = renderer;

this.cameraType = 'default';
Expand Down Expand Up @@ -1050,6 +1050,8 @@ p5.Camera = class Camera {
* @private
*/
_rotateView(a, x, y, z) {
this.cameraType = 'custom';

let centerX = this.centerX;
let centerY = this.centerY;
let centerZ = this.centerZ;
Expand Down Expand Up @@ -1142,6 +1144,7 @@ p5.Camera = class Camera {
* camera view pans left and right across a series of rotating 3D boxes.
*/
pan(amount) {
this.cameraType = 'custom';
const local = this._getLocalAxes();
this._rotateView(amount, local.y[0], local.y[1], local.y[2]);
}
Expand Down Expand Up @@ -1200,6 +1203,7 @@ p5.Camera = class Camera {
* camera view tilts up and down across a series of rotating 3D boxes.
*/
tilt(amount) {
this.cameraType = 'custom';
const local = this._getLocalAxes();
this._rotateView(amount, local.x[0], local.x[1], local.x[2]);
}
Expand Down Expand Up @@ -1254,6 +1258,7 @@ p5.Camera = class Camera {
* point every second .
*/
lookAt(x, y, z) {
this.cameraType = 'custom';
this.camera(
this.eyeX,
this.eyeY,
Expand Down Expand Up @@ -1366,6 +1371,7 @@ p5.Camera = class Camera {
upY,
upZ
) {
this.cameraType = 'custom';
if (typeof eyeX === 'undefined') {
eyeX = this.defaultEyeX;
eyeY = this.defaultEyeY;
Expand Down Expand Up @@ -1486,6 +1492,7 @@ p5.Camera = class Camera {
* orientation throughout the move
*/
move(x, y, z) {
this.cameraType = 'custom';
const local = this._getLocalAxes();

// scale local axes by movement amounts
Expand Down Expand Up @@ -1552,6 +1559,7 @@ p5.Camera = class Camera {
* camera position changes as the user presses keys, altering view of a 3D box
*/
setPosition(x, y, z) {
this.cameraType = 'custom';
const diffX = x - this.eyeX;
const diffY = y - this.eyeY;
const diffZ = z - this.eyeZ;
Expand Down Expand Up @@ -1746,6 +1754,7 @@ p5.Camera = class Camera {
* The camera cannot be moved during that time.
*/
slerp(cam0, cam1, amt) {
this.cameraType = 'custom';
// If t is 0 or 1, do not interpolate and set the argument camera.
if (amt === 0) {
this.set(cam0);
Expand Down Expand Up @@ -2087,6 +2096,7 @@ p5.Camera = class Camera {
* @param {Number} dRadius change in radius
*/
_orbit(dTheta, dPhi, dRadius) {
this.cameraType = 'custom';
// Calculate the vector and its magnitude from the center to the viewpoint
const diffX = this.eyeX - this.centerX;
const diffY = this.eyeY - this.centerY;
Expand Down Expand Up @@ -2157,6 +2167,7 @@ p5.Camera = class Camera {
* @param {Number} dRadius change in radius
*/
_orbitFree(dx, dy, dRadius) {
this.cameraType = 'custom';
// Calculate the vector and its magnitude from the center to the viewpoint
const diffX = this.eyeX - this.centerX;
const diffY = this.eyeY - this.centerY;
Expand Down

0 comments on commit 409d980

Please sign in to comment.