Skip to content

Commit

Permalink
To fix the issue of image stretching after resizing a reflection probe.
Browse files Browse the repository at this point in the history
  • Loading branch information
GengineJS committed Dec 5, 2024
1 parent 01e98e8 commit 959f86e
Showing 1 changed file with 9 additions and 5 deletions.
14 changes: 9 additions & 5 deletions cocos/3d/reflection-probe/reflection-probe-component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
*/
import { ccclass, executeInEditMode, help, menu, playOnFocus, serializable, tooltip, type, visible } from 'cc.decorator';
import { EDITOR, EDITOR_NOT_IN_PREVIEW } from 'internal:constants';
import { CCBoolean, CCObject, Color, Enum, Vec3, warn } from '../../core';
import { CCBoolean, CCObject, Color, screen, Enum, Vec3, warn } from '../../core';

import { TextureCube } from '../../asset/assets';
import { scene } from '../../render-scene';
Expand Down Expand Up @@ -105,10 +105,6 @@ export class ReflectionProbe extends Component {

private _position = new Vec3(0, 0, 0);

constructor () {
super();
}

/**
* @en
* Gets or sets the size of the box
Expand Down Expand Up @@ -325,6 +321,14 @@ export class ReflectionProbe extends Component {
if (EDITOR) {
ReflectionProbeManager.probeManager.registerEvent();
}
screen.on('window-resize', this._handleResize$, this);
screen.on('fullscreen-change', this._handleResize$, this);
}

private _handleResize$(): void {
if (this.probe && this.sourceCamera && this.probeType === ProbeType.PLANAR) {
this.probe.renderPlanarReflection(this.sourceCamera.camera);
}
}

onEnable (): void {
Expand Down

0 comments on commit 959f86e

Please sign in to comment.