2 subtle improvements (#9318)

* add an optional parameter `out`

* no need to create temp function when clear the `targetTexture`
This commit is contained in:
J.C
2021-09-14 18:28:59 +08:00
committed by GitHub
parent cf3e10b6c4
commit 677599de35
2 changed files with 7 additions and 9 deletions
+5 -7
View File
@@ -580,18 +580,16 @@ export class Camera extends Component {
}
protected _checkTargetTextureEvent (old: RenderTexture | null) {
const resizeFunc = (window: RenderWindow) => {
if (this._camera) {
this._camera.setFixedSize(window.width, window.height);
}
};
if (old) {
old.off('resize');
}
if (this._targetTexture) {
this._targetTexture.on('resize', resizeFunc, this);
this._targetTexture.on('resize', (window: RenderWindow) => {
if (this._camera) {
this._camera.setFixedSize(window.width, window.height);
}
}, this);
}
}
+2 -2
View File
@@ -182,8 +182,8 @@ export abstract class RenderPipeline extends Asset {
* @param camera the camera
* @returns
*/
public generateRenderArea (camera: Camera): Rect {
const res = new Rect();
public generateRenderArea (camera: Camera, out?: Rect): Rect {
const res = out || new Rect();
const vp = camera.viewport;
const sceneData = this.pipelineSceneData;
// render area is not oriented