mirror of
https://github.com/cocos/cocos4.git
synced 2026-11-20 23:52:40 +08:00
2 subtle improvements (#9318)
* add an optional parameter `out` * no need to create temp function when clear the `targetTexture`
This commit is contained in:
@@ -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);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user