Skip to content

Commit

Permalink
[Camera] Pass ortho camera values down to rigCameras (#12741)
Browse files Browse the repository at this point in the history
* Pass rig changes

* Pass camera ortho parameters down to the rig cameras
  • Loading branch information
carolhmj authored Jul 13, 2022
1 parent 5af34ca commit 8e5bafb
Show file tree
Hide file tree
Showing 3 changed files with 79 additions and 10 deletions.
7 changes: 7 additions & 0 deletions packages/dev/core/src/Cameras/arcRotateCamera.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1270,6 +1270,13 @@ export class ArcRotateCamera extends TargetCamera {
rigCam.isRigCamera = true;
rigCam.rigParent = this;
rigCam.upVector = this.upVector;

rigCam.mode = this.mode;
rigCam.orthoLeft = this.orthoLeft;
rigCam.orthoRight = this.orthoRight;
rigCam.orthoBottom = this.orthoBottom;
rigCam.orthoTop = this.orthoTop;

return rigCam;
}

Expand Down
75 changes: 65 additions & 10 deletions packages/dev/core/src/Cameras/camera.ts
Original file line number Diff line number Diff line change
Expand Up @@ -169,29 +169,73 @@ export class Camera extends Node {
* Define the current limit on the left side for an orthographic camera
* In scene unit
*/
@serialize()
public orthoLeft: Nullable<number> = null;
private _orthoLeft: Nullable<number> = null;

public set orthoLeft(value: Nullable<number>) {
this._orthoLeft = value;

for (const rigCamera of this._rigCameras) {
rigCamera.orthoLeft = value;
}
}

public get orthoLeft(): Nullable<number> {
return this._orthoLeft;
}

/**
* Define the current limit on the right side for an orthographic camera
* In scene unit
*/
@serialize()
public orthoRight: Nullable<number> = null;
private _orthoRight: Nullable<number> = null;

public set orthoRight(value: Nullable<number>) {
this._orthoRight = value;

for (const rigCamera of this._rigCameras) {
rigCamera.orthoRight = value;
}
}

public get orthoRight(): Nullable<number> {
return this._orthoRight;
}

/**
* Define the current limit on the bottom side for an orthographic camera
* In scene unit
*/
@serialize()
public orthoBottom: Nullable<number> = null;
private _orthoBottom: Nullable<number> = null;

public set orthoBottom(value: Nullable<number>) {
this._orthoBottom = value;

for (const rigCamera of this._rigCameras) {
rigCamera.orthoBottom = value;
}
}

public get orthoBottom(): Nullable<number> {
return this._orthoBottom;
}

/**
* Define the current limit on the top side for an orthographic camera
* In scene unit
*/
@serialize()
public orthoTop: Nullable<number> = null;
private _orthoTop: Nullable<number> = null;

public set orthoTop(value: Nullable<number>) {
this._orthoTop = value;

for (const rigCamera of this._rigCameras) {
rigCamera.orthoTop = value;
}
}

public get orthoTop(): Nullable<number> {
return this._orthoTop;
}

/**
* Field Of View is set in Radians. (default is 0.8)
Expand Down Expand Up @@ -233,8 +277,19 @@ export class Camera extends Node {
/**
* Define the mode of the camera (Camera.PERSPECTIVE_CAMERA or Camera.ORTHOGRAPHIC_CAMERA)
*/
@serialize()
public mode = Camera.PERSPECTIVE_CAMERA;
private _mode = Camera.PERSPECTIVE_CAMERA;
set mode(mode: number) {
this._mode = mode;

// Pass the mode down to the rig cameras
for (const rigCamera of this._rigCameras) {
rigCamera.mode = mode;
}
}

get mode(): number {
return this._mode;
}

/**
* Define whether the camera is intermediate.
Expand Down
7 changes: 7 additions & 0 deletions packages/dev/core/src/Cameras/targetCamera.ts
Original file line number Diff line number Diff line change
Expand Up @@ -503,6 +503,13 @@ export class TargetCamera extends Camera {
rigCamera._cameraRigParams = {};
rigCamera.rotationQuaternion = new Quaternion();
}

rigCamera.mode = this.mode;
rigCamera.orthoLeft = this.orthoLeft;
rigCamera.orthoRight = this.orthoRight;
rigCamera.orthoTop = this.orthoTop;
rigCamera.orthoBottom = this.orthoBottom;

return rigCamera;
}
return null;
Expand Down

0 comments on commit 8e5bafb

Please sign in to comment.