diff --git a/cocos/3d/framework/mesh-renderer.ts b/cocos/3d/framework/mesh-renderer.ts index 287e1e5d96..6754e0ed11 100644 --- a/cocos/3d/framework/mesh-renderer.ts +++ b/cocos/3d/framework/mesh-renderer.ts @@ -23,6 +23,7 @@ THE SOFTWARE. */ import { JSB } from 'internal:constants'; +import { displayOrder, group } from 'cc.decorator'; import { Texture2D, TextureCube } from '../../asset/assets'; import { Material } from '../../asset/assets/material'; import { Mesh } from '../assets/mesh'; @@ -204,6 +205,7 @@ export class MeshRenderer extends ModelRenderer { @disallowAnimation // eslint-disable-next-line func-names @visible(function (this: MeshRenderer) { return !!(this.node && this.node.mobility !== MobilityMode.Movable); }) + @displayOrder(1) public lightmapSettings = new ModelLightmapSettings(); @serializable @@ -244,7 +246,7 @@ export class MeshRenderer extends ModelRenderer { */ @type(CCFloat) @tooltip('i18n:model.shadow_bias') - @property({ group: { id: 'DynamicShadow', name: 'DynamicShadowSettings', displayOrder: 0 } }) + @group({ id: 'DynamicShadow', name: 'DynamicShadowSettings', displayOrder: 0 }) @disallowAnimation get shadowBias () { return this._shadowBias; @@ -262,7 +264,7 @@ export class MeshRenderer extends ModelRenderer { */ @type(CCFloat) @tooltip('i18n:model.shadow_normal_bias') - @property({ group: { id: 'DynamicShadow', name: 'DynamicShadowSettings', displayOrder: 1 } }) + @group({ id: 'DynamicShadow', name: 'DynamicShadowSettings' }) @disallowAnimation get shadowNormalBias () { return this._shadowNormalBias; @@ -280,7 +282,7 @@ export class MeshRenderer extends ModelRenderer { */ @type(ModelShadowCastingMode) @tooltip('i18n:model.shadow_casting_model') - @property({ group: { id: 'DynamicShadow', name: 'DynamicShadowSettings', displayOrder: 2 } }) + @group({ id: 'DynamicShadow', name: 'DynamicShadowSettings' }) @disallowAnimation get shadowCastingMode () { return this._shadowCastingMode; @@ -297,7 +299,7 @@ export class MeshRenderer extends ModelRenderer { */ @type(ModelShadowReceivingMode) @tooltip('i18n:model.shadow_receiving_model') - @property({ group: { id: 'DynamicShadow', name: 'DynamicShadowSettings', displayOrder: 3 } }) + @group({ id: 'DynamicShadow', name: 'DynamicShadowSettings' }) @disallowAnimation get receiveShadow () { return this._shadowReceivingMode; @@ -356,6 +358,7 @@ export class MeshRenderer extends ModelRenderer { * @en Whether the model can be render by the reflection probe * @zh 模型是否能被反射探针渲染 */ + @group({ id: 'ReflectionProbe', name: 'ReflectionProbeSettings', displayOrder: 2 }) @type(CCBoolean) get bakeToReflectionProbe () { return this._bakeToReflectionProbe; @@ -370,6 +373,7 @@ export class MeshRenderer extends ModelRenderer { * @en Used to set whether to use the reflection probe or set probe's type. * @zh 用于设置是否使用反射探针或者设置反射探针的类型。 */ + @group({ id: 'ReflectionProbe', name: 'ReflectionProbeSettings' }) @type(Enum(ReflectionProbeType)) get reflectionProbe () { return this._reflectionProbeType; diff --git a/cocos/misc/reflection-probe-component.ts b/cocos/misc/reflection-probe-component.ts index 052609f179..570c4e2d90 100644 --- a/cocos/misc/reflection-probe-component.ts +++ b/cocos/misc/reflection-probe-component.ts @@ -24,7 +24,7 @@ */ import { ccclass, executeInEditMode, menu, playOnFocus, serializable, tooltip, type, visible } from 'cc.decorator'; import { EDITOR } from 'internal:constants'; -import { CCObject, Color, Enum, Vec3 } from '../core'; +import { CCObject, Color, Enum, size, Vec3 } from '../core'; import { TextureCube } from '../asset/assets'; import { scene } from '../render-scene'; @@ -75,6 +75,8 @@ export enum ProbeResolution { @executeInEditMode @playOnFocus export class ReflectionProbe extends Component { + protected static readonly DEFAULT_CUBE_SIZE: Readonly = new Vec3(1, 1, 1); + protected static readonly DEFAULT_PLANER_SIZE: Readonly = new Vec3(5, 0.5, 5); @serializable protected _resolution = 256; @serializable @@ -93,7 +95,7 @@ export class ReflectionProbe extends Component { protected _cubemap: TextureCube | null = null; @serializable - protected _size = new Vec3(1, 1, 1); + protected readonly _size = new Vec3(1, 1, 1); @serializable protected _sourceCamera: Camera | null = null; @@ -110,7 +112,7 @@ export class ReflectionProbe extends Component { * 获取或设置包围盒的大小。 */ set size (value) { - this._size = value; + this._size.set(value); this.probe.size = this._size; } @type(Vec3) @@ -128,11 +130,13 @@ export class ReflectionProbe extends Component { this.probe.probeType = value; if (this._probeType === ProbeType.CUBE) { + this._size.set(ReflectionProbe.DEFAULT_CUBE_SIZE); this.probe.switchProbeType(value); if (EDITOR) { this._objFlags |= CCObject.Flags.IsRotationLocked; } } else { + this._size.set(ReflectionProbe.DEFAULT_PLANER_SIZE); if (EDITOR && this._objFlags & CCObject.Flags.IsRotationLocked) { this._objFlags ^= CCObject.Flags.IsRotationLocked; } @@ -151,11 +155,13 @@ export class ReflectionProbe extends Component { * @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; this.probe.resolution = value; } + get resolution () { return this._resolution; } diff --git a/cocos/render-scene/scene/reflection-probe.ts b/cocos/render-scene/scene/reflection-probe.ts index b77b0d0c32..c86066f544 100644 --- a/cocos/render-scene/scene/reflection-probe.ts +++ b/cocos/render-scene/scene/reflection-probe.ts @@ -25,7 +25,7 @@ import { EDITOR } from 'internal:constants'; import { Camera, CameraAperture, CameraFOVAxis, CameraISO, CameraProjection, CameraShutter, CameraType, SKYBOX_FLAG, TrackingType } from './camera'; import { Node } from '../../scene-graph/node'; -import { CCObject, Color, Quat, Rect, toRadian, Vec2, Vec3, geometry, cclegacy } from '../../core'; +import { CCObject, Color, Quat, Rect, toRadian, Vec2, Vec3, geometry, cclegacy, Size } from '../../core'; import { CAMERA_DEFAULT_MASK } from '../../rendering/define'; import { ClearFlagBit } from '../../gfx'; import { TextureCube } from '../../asset/assets/texture-cube'; @@ -63,7 +63,7 @@ export class ReflectionProbe { protected _visibility = CAMERA_DEFAULT_MASK; protected _probeType = ProbeType.CUBE; protected _cubemap: TextureCube | null = null; - protected _size = new Vec3(1, 1, 1); + protected readonly _size = new Vec3(1, 1, 1); /** * @en Render cubemap's camera @@ -125,6 +125,10 @@ export class ReflectionProbe { return this._probeType; } + get resolution () { + return this._resolution; + } + /** * @en set render texture size * @zh 设置渲染纹理大小 @@ -137,9 +141,6 @@ export class ReflectionProbe { } this._resolution = value; } - get resolution () { - return this._resolution; - } /** * @en Clearing flags of the camera, specifies which part of the framebuffer will be actually cleared every frame. @@ -181,7 +182,7 @@ export class ReflectionProbe { * @zh 获取或设置盒的大小。 */ set size (value) { - this._size = value; + this._size.set(value); const pos = this.node.getWorldPosition(); geometry.AABB.set(this._boundingBox!, pos.x, pos.y, pos.z, this._size.x, this._size.y, this._size.z); diff --git a/editor/assets/gizmo/reflection-probe.png b/editor/assets/gizmo/reflection-probe.png index fad3a56cf0..ec1894a933 100644 Binary files a/editor/assets/gizmo/reflection-probe.png and b/editor/assets/gizmo/reflection-probe.png differ