-
Notifications
You must be signed in to change notification settings - Fork 2.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
To fix the issue of image stretching after resizing a reflection probe. #18004
Merged
Merged
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -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'; | ||
|
@@ -105,10 +105,6 @@ | |
|
||
private _position = new Vec3(0, 0, 0); | ||
|
||
constructor () { | ||
super(); | ||
} | ||
|
||
/** | ||
* @en | ||
* Gets or sets the size of the box | ||
|
@@ -180,7 +176,7 @@ | |
* @en set render texture size | ||
* @zh 设置渲染纹理大小 | ||
*/ | ||
@visible(function (this: ReflectionProbe) { return this.probeType === ProbeType.CUBE; }) | ||
@type(Enum(ProbeResolution)) | ||
set resolution (value: number) { | ||
this._resolution = value; | ||
|
@@ -196,7 +192,7 @@ | |
* @zh 相机的缓冲清除标志位,指定帧缓冲的哪部分要每帧清除。 | ||
*/ | ||
@type(Enum(ProbeClearFlag)) | ||
@visible(function (this: ReflectionProbe) { return this.probeType === ProbeType.CUBE; }) | ||
set clearFlag (value: number) { | ||
this._clearFlag = value; | ||
this.probe.clearFlag = this._clearFlag; | ||
|
@@ -209,7 +205,7 @@ | |
* @en Clearing color of the camera. | ||
* @zh 相机的颜色缓冲默认值。 | ||
*/ | ||
@visible(function (this: ReflectionProbe) { return this._clearFlag === ProbeClearFlag.SOLID_COLOR && this.probeType === ProbeType.CUBE; }) | ||
@type(Color) | ||
set backgroundColor (val: Color) { | ||
this._backgroundColor = val; | ||
|
@@ -237,7 +233,7 @@ | |
* @en The camera to render planar reflections, specified by the user | ||
* @zh 需要渲染平面反射的相机,由用户指定 | ||
*/ | ||
@visible(function (this: ReflectionProbe) { return this.probeType === ProbeType.PLANAR; }) | ||
@type(Camera) | ||
set sourceCamera (camera: Camera) { | ||
this._sourceCamera = camera; | ||
|
@@ -258,7 +254,7 @@ | |
* @en fast bake no convolution. | ||
* @zh 快速烘焙不会进行卷积。 | ||
*/ | ||
@visible(function (this: ReflectionProbe) { return this.probeType === ProbeType.CUBE; }) | ||
@type(CCBoolean) | ||
@tooltip('i18n:reflection_probe.fastBake') | ||
get fastBake (): boolean { | ||
|
@@ -327,6 +323,12 @@ | |
} | ||
} | ||
|
||
private _handleResize$ (): void { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Don't add |
||
if (this.probe && this.sourceCamera && this.probeType === ProbeType.PLANAR) { | ||
this.probe.renderPlanarReflection(this.sourceCamera.camera); | ||
} | ||
} | ||
|
||
onEnable (): void { | ||
if (this._probe) { | ||
const probe = ReflectionProbeManager.probeManager.getProbeById(this._probeId); | ||
|
@@ -338,12 +340,16 @@ | |
ReflectionProbeManager.probeManager.onUpdateProbes(); | ||
this._probe.enable(); | ||
} | ||
screen.on('window-resize', this._handleResize$, this); | ||
screen.on('fullscreen-change', this._handleResize$, this); | ||
} | ||
onDisable (): void { | ||
if (this._probe) { | ||
ReflectionProbeManager.probeManager.unregister(this._probe); | ||
this._probe.disable(); | ||
} | ||
screen.off('window-resize', this._handleResize$, this); | ||
screen.off('fullscreen-change', this._handleResize$, this); | ||
} | ||
|
||
public start (): void { | ||
|
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Removing the default constructor will make the package size bigger. So don't remove it.