diff --git a/cocos/3d/framework/mesh-renderer.ts b/cocos/3d/framework/mesh-renderer.ts index 283237ef239..f516fc608ac 100644 --- a/cocos/3d/framework/mesh-renderer.ts +++ b/cocos/3d/framework/mesh-renderer.ts @@ -44,6 +44,7 @@ import { SubModel } from '../../render-scene/scene'; import { isEnableEffect } from '../../rendering/define'; import type { Model } from '../../render-scene/scene'; import type { ReflectionProbeManager } from '../reflection-probe'; +import { getPipelineSceneData } from '../../rendering/pipeline-scene-data-utils'; const { ccclass, help, executeInEditMode, executionOrder, menu, visible, type, formerlySerializedAs, serializable, editable, disallowAnimation } = _decorator; @@ -541,7 +542,7 @@ export class MeshRenderer extends ModelRenderer { } set isGlobalStandardSkinObject (val) { - (cclegacy.director.root as Root).pipeline.pipelineSceneData.standardSkinMeshRenderer = val ? this : null; + getPipelineSceneData().standardSkinMeshRenderer = val ? this : null; this._enabledGlobalStandardSkinObject = val; } @@ -950,13 +951,13 @@ export class MeshRenderer extends ModelRenderer { if (!mainLight.node) { return; } if (mainLight.node.mobility === MobilityMode.Static) { + const sceneGlobals = this.node.scene.globals; + const lightProbeInfoData = sceneGlobals.lightProbeInfo.data; let forceClose = false; - if (this.bakeSettings.texture && !this.node.scene.globals.disableLightmap) { + if (this.bakeSettings.texture && !sceneGlobals.disableLightmap) { forceClose = true; } - if (this.node.scene.globals.lightProbeInfo.data - && this.node.scene.globals.lightProbeInfo.data.hasCoefficients() - && this._model.useLightProbe) { + if (lightProbeInfoData && lightProbeInfoData.hasCoefficients() && this._model.useLightProbe) { forceClose = true; } @@ -1308,7 +1309,7 @@ export class MeshRenderer extends ModelRenderer { } private _updateStandardSkin (): void { - const pipelineSceneData = (cclegacy.director.root as Root).pipeline.pipelineSceneData; + const pipelineSceneData = getPipelineSceneData(); if (this._enabledGlobalStandardSkinObject) { pipelineSceneData.standardSkinMeshRenderer = this; pipelineSceneData.standardSkinModel = this.model; diff --git a/cocos/3d/lights/directional-light-component.ts b/cocos/3d/lights/directional-light-component.ts index 72a6275d93a..9c965a35989 100644 --- a/cocos/3d/lights/directional-light-component.ts +++ b/cocos/3d/lights/directional-light-component.ts @@ -25,10 +25,11 @@ import { Light } from './light-component'; import { scene } from '../../render-scene'; -import { cclegacy, clamp, warnID, CCBoolean, CCFloat, _decorator, settings, CCInteger, SettingsCategory } from '../../core'; +import { clamp, warnID, CCBoolean, CCFloat, _decorator, settings, CCInteger, SettingsCategory } from '../../core'; import { Camera, PCFType, Shadows, ShadowType, CSMOptimizationMode, CSMLevel } from '../../render-scene/scene'; import { Root } from '../../root'; import { MeshRenderer } from '../framework/mesh-renderer'; +import { getPipelineSceneData } from '../../rendering/pipeline-scene-data-utils'; const { ccclass, menu, executeInEditMode, property, serializable, formerlySerializedAs, tooltip, help, visible, type, editable, slide, range } = _decorator; @@ -99,7 +100,7 @@ export class DirectionalLight extends Light { @range([0, Number.POSITIVE_INFINITY, 10]) @type(CCInteger) get illuminance (): number { - const isHDR = (cclegacy.director.root as Root).pipeline.pipelineSceneData.isHDR; + const isHDR = getPipelineSceneData().isHDR; if (isHDR) { return this._illuminanceHDR; } else { @@ -107,7 +108,7 @@ export class DirectionalLight extends Light { } } set illuminance (val) { - const isHDR = (cclegacy.director.root as Root).pipeline.pipelineSceneData.isHDR; + const isHDR = getPipelineSceneData().isHDR; if (isHDR) { this._illuminanceHDR = val; this._light && ((this._light as scene.DirectionalLight).illuminanceHDR = this._illuminanceHDR); @@ -122,8 +123,8 @@ export class DirectionalLight extends Light { * @zh 是否启用实时阴影? */ @tooltip('i18n:lights.shadowEnabled') - @visible(() => (cclegacy.director.root as Root).pipeline.pipelineSceneData.shadows.enabled - && (cclegacy.director.root as Root).pipeline.pipelineSceneData.shadows.type === ShadowType.ShadowMap) + @visible(() => getPipelineSceneData().shadows.enabled + && getPipelineSceneData().shadows.type === ShadowType.ShadowMap) @property({ group: { name: 'DynamicShadowSettings', displayOrder: 1 } }) @editable @type(CCBoolean) @@ -142,8 +143,8 @@ export class DirectionalLight extends Light { * @zh 实时阴影计算中的阴影 pcf 等级。 */ @tooltip('i18n:lights.shadowPcf') - @visible(() => (cclegacy.director.root as Root).pipeline.pipelineSceneData.shadows.enabled - && (cclegacy.director.root as Root).pipeline.pipelineSceneData.shadows.type === ShadowType.ShadowMap) + @visible(() => getPipelineSceneData().shadows.enabled + && getPipelineSceneData().shadows.type === ShadowType.ShadowMap) @property({ group: { name: 'DynamicShadowSettings', displayOrder: 5 } }) @editable @type(PCFType) @@ -162,8 +163,8 @@ export class DirectionalLight extends Light { * @zh 实时阴影计算中的阴影纹理偏移值。 */ @tooltip('i18n:lights.shadowBias') - @visible(() => (cclegacy.director.root as Root).pipeline.pipelineSceneData.shadows.enabled - && (cclegacy.director.root as Root).pipeline.pipelineSceneData.shadows.type === ShadowType.ShadowMap) + @visible(() => getPipelineSceneData().shadows.enabled + && getPipelineSceneData().shadows.type === ShadowType.ShadowMap) @property({ group: { name: 'DynamicShadowSettings', displayOrder: 6 } }) @editable @type(CCFloat) @@ -182,8 +183,8 @@ export class DirectionalLight extends Light { * @zh 实时阴影计算中的法线偏移。 */ @tooltip('i18n:lights.shadowNormalBias') - @visible(() => (cclegacy.director.root as Root).pipeline.pipelineSceneData.shadows.enabled - && (cclegacy.director.root as Root).pipeline.pipelineSceneData.shadows.type === ShadowType.ShadowMap) + @visible(() => getPipelineSceneData().shadows.enabled + && getPipelineSceneData().shadows.type === ShadowType.ShadowMap) @property({ group: { name: 'DynamicShadowSettings', displayOrder: 7 } }) @editable @type(CCFloat) @@ -202,8 +203,8 @@ export class DirectionalLight extends Light { * @zh 实时阴影计算中的阴影颜色饱和度。 */ @tooltip('i18n:lights.shadowSaturation') - @visible(() => (cclegacy.director.root as Root).pipeline.pipelineSceneData.shadows.enabled - && (cclegacy.director.root as Root).pipeline.pipelineSceneData.shadows.type === ShadowType.ShadowMap) + @visible(() => getPipelineSceneData().shadows.enabled + && getPipelineSceneData().shadows.type === ShadowType.ShadowMap) @property({ group: { name: 'DynamicShadowSettings', displayOrder: 8 } }) @editable @range([0.0, 1.0, 0.01]) @@ -226,8 +227,8 @@ export class DirectionalLight extends Light { */ @tooltip('i18n:lights.shadowDistance') @visible(function (this: DirectionalLight) { - return (cclegacy.director.root as Root).pipeline.pipelineSceneData.shadows.enabled - && (cclegacy.director.root as Root).pipeline.pipelineSceneData.shadows.type + return getPipelineSceneData().shadows.enabled + && getPipelineSceneData().shadows.type === ShadowType.ShadowMap && this._shadowFixedArea === false; }) @property({ group: { name: 'DynamicShadowSettings', displayOrder: 9 } }) @@ -254,8 +255,8 @@ export class DirectionalLight extends Light { */ @tooltip('i18n:lights.shadowInvisibleOcclusionRange') @visible(function (this: DirectionalLight) { - return (cclegacy.director.root as Root).pipeline.pipelineSceneData.shadows.enabled - && (cclegacy.director.root as Root).pipeline.pipelineSceneData.shadows.type + return getPipelineSceneData().shadows.enabled + && getPipelineSceneData().shadows.type === ShadowType.ShadowMap && this._shadowFixedArea === false && this._csmAdvancedOptions; }) @@ -301,8 +302,8 @@ export class DirectionalLight extends Light { */ @tooltip('i18n:lights.enableCSM') @visible(function (this: DirectionalLight) { - return (cclegacy.director.root as Root).pipeline.pipelineSceneData.shadows.enabled - && (cclegacy.director.root as Root).pipeline.pipelineSceneData.shadows.type + return getPipelineSceneData().shadows.enabled + && getPipelineSceneData().shadows.type === ShadowType.ShadowMap && this._shadowFixedArea === false; }) @property({ group: { name: 'DynamicShadowSettings', displayOrder: 11 } }) @@ -367,8 +368,8 @@ export class DirectionalLight extends Light { * @zh 实时阴影计算中是否使用固定区域阴影。 */ @tooltip('i18n:lights.shadowFixedArea') - @visible(() => (cclegacy.director.root as Root).pipeline.pipelineSceneData.shadows.enabled - && (cclegacy.director.root as Root).pipeline.pipelineSceneData.shadows.type === ShadowType.ShadowMap) + @visible(() => getPipelineSceneData().shadows.enabled + && getPipelineSceneData().shadows.type === ShadowType.ShadowMap) @property({ group: { name: 'DynamicShadowSettings', displayOrder: 14 } }) @editable @type(CCBoolean) @@ -388,8 +389,8 @@ export class DirectionalLight extends Light { */ @tooltip('i18n:lights.shadowNear') @visible(function (this: DirectionalLight) { - return (cclegacy.director.root as Root).pipeline.pipelineSceneData.shadows.enabled - && (cclegacy.director.root as Root).pipeline.pipelineSceneData.shadows.type + return getPipelineSceneData().shadows.enabled + && getPipelineSceneData().shadows.type === ShadowType.ShadowMap && this._shadowFixedArea === true; }) @property({ group: { name: 'DynamicShadowSettings', displayOrder: 15 } }) @@ -411,8 +412,8 @@ export class DirectionalLight extends Light { */ @tooltip('i18n:lights.shadowFar') @visible(function (this: DirectionalLight) { - return (cclegacy.director.root as Root).pipeline.pipelineSceneData.shadows.enabled - && (cclegacy.director.root as Root).pipeline.pipelineSceneData.shadows.type + return getPipelineSceneData().shadows.enabled + && getPipelineSceneData().shadows.type === ShadowType.ShadowMap && this._shadowFixedArea === true; }) @property({ group: { name: 'DynamicShadowSettings', displayOrder: 16 } }) @@ -434,8 +435,8 @@ export class DirectionalLight extends Light { */ @tooltip('i18n:lights.shadowOrthoSize') @visible(function (this: DirectionalLight) { - return (cclegacy.director.root as Root).pipeline.pipelineSceneData.shadows.enabled - && (cclegacy.director.root as Root).pipeline.pipelineSceneData.shadows.type + return getPipelineSceneData().shadows.enabled + && getPipelineSceneData().shadows.type === ShadowType.ShadowMap && this._shadowFixedArea === true; }) @property({ group: { name: 'DynamicShadowSettings', displayOrder: 17 } }) @@ -456,8 +457,8 @@ export class DirectionalLight extends Light { */ @tooltip('i18n:lights.shadowAdvancedOptions') @visible(function (this: DirectionalLight) { - return (cclegacy.director.root as Root).pipeline.pipelineSceneData.shadows.enabled - && (cclegacy.director.root as Root).pipeline.pipelineSceneData.shadows.type === ShadowType.ShadowMap + return getPipelineSceneData().shadows.enabled + && getPipelineSceneData().shadows.type === ShadowType.ShadowMap && this._csmLevel > CSMLevel.LEVEL_1; }) @property({ group: { name: 'DynamicShadowSettings', displayOrder: 19 } }) @@ -476,8 +477,8 @@ export class DirectionalLight extends Light { */ @tooltip('i18n:lights.csmLayersTransition') @visible(function (this: DirectionalLight) { - return (cclegacy.director.root as Root).pipeline.pipelineSceneData.shadows.enabled - && (cclegacy.director.root as Root).pipeline.pipelineSceneData.shadows.type === ShadowType.ShadowMap + return getPipelineSceneData().shadows.enabled + && getPipelineSceneData().shadows.type === ShadowType.ShadowMap && this._csmLevel > CSMLevel.LEVEL_1 && this._csmAdvancedOptions; }) @@ -498,8 +499,8 @@ export class DirectionalLight extends Light { */ @tooltip('i18n:lights.csmTransitionRange') @visible(function (this: DirectionalLight) { - return (cclegacy.director.root as Root).pipeline.pipelineSceneData.shadows.enabled - && (cclegacy.director.root as Root).pipeline.pipelineSceneData.shadows.type === ShadowType.ShadowMap + return getPipelineSceneData().shadows.enabled + && getPipelineSceneData().shadows.type === ShadowType.ShadowMap && this._csmLevel > CSMLevel.LEVEL_1 && this._csmAdvancedOptions; }) diff --git a/cocos/3d/lights/point-light-component.ts b/cocos/3d/lights/point-light-component.ts index 6c24cb870be..68da21b465c 100644 --- a/cocos/3d/lights/point-light-component.ts +++ b/cocos/3d/lights/point-light-component.ts @@ -27,7 +27,8 @@ import { ccclass, help, executeInEditMode, menu, tooltip, type, displayOrder, import { scene } from '../../render-scene'; import { Camera, LightType } from '../../render-scene/scene'; import { Light, PhotometricTerm } from './light-component'; -import { CCFloat, CCInteger, cclegacy } from '../../core'; +import { CCFloat, CCInteger } from '../../core'; +import { getPipelineSceneData } from '../../rendering/pipeline-scene-data-utils'; /** * @en The point light component, multiple point lights can be added to one scene. @@ -58,7 +59,7 @@ export class PointLight extends Light { @range([0, Number.POSITIVE_INFINITY, 100]) @type(CCInteger) get luminousFlux (): number { - const isHDR = cclegacy.director.root.pipeline.pipelineSceneData.isHDR; + const isHDR = getPipelineSceneData().isHDR; if (isHDR) { return this._luminanceHDR * scene.nt2lm(1.0); } else { @@ -66,7 +67,7 @@ export class PointLight extends Light { } } set luminousFlux (val) { - const isHDR = cclegacy.director.root.pipeline.pipelineSceneData.isHDR; + const isHDR = getPipelineSceneData().isHDR; let result = 0; if (isHDR) { this._luminanceHDR = val / scene.nt2lm(1.0); @@ -89,7 +90,7 @@ export class PointLight extends Light { @range([0, Number.POSITIVE_INFINITY, 10]) @type(CCInteger) get luminance (): number { - const isHDR = cclegacy.director.root.pipeline.pipelineSceneData.isHDR; + const isHDR = getPipelineSceneData().isHDR; if (isHDR) { return this._luminanceHDR; } else { @@ -97,7 +98,7 @@ export class PointLight extends Light { } } set luminance (val) { - const isHDR = cclegacy.director.root.pipeline.pipelineSceneData.isHDR; + const isHDR = getPipelineSceneData().isHDR; if (isHDR) { this._luminanceHDR = val; // eslint-disable-next-line @typescript-eslint/no-unused-expressions diff --git a/cocos/3d/lights/ranged-directional-light-component.ts b/cocos/3d/lights/ranged-directional-light-component.ts index 2ee1736a9dc..fbbe9cabde5 100644 --- a/cocos/3d/lights/ranged-directional-light-component.ts +++ b/cocos/3d/lights/ranged-directional-light-component.ts @@ -25,6 +25,7 @@ import { Camera, LightType } from '../../render-scene/scene'; import { scene } from '../../render-scene'; import { CCInteger, cclegacy } from '../../core'; import { range } from '../../core/data/decorators'; +import { getPipelineSceneData } from '../../rendering/pipeline-scene-data-utils'; /** * @en The ranged directional light component, Multiple ranged directional light sources are allowed in a scene. @@ -51,7 +52,7 @@ export class RangedDirectionalLight extends Light { @range([0, Number.POSITIVE_INFINITY, 10]) @type(CCInteger) get illuminance (): number { - const isHDR = cclegacy.director.root.pipeline.pipelineSceneData.isHDR; + const isHDR = getPipelineSceneData().isHDR; if (isHDR) { return this._illuminanceHDR; } else { @@ -59,7 +60,7 @@ export class RangedDirectionalLight extends Light { } } set illuminance (val) { - const isHDR = cclegacy.director.root.pipeline.pipelineSceneData.isHDR; + const isHDR = getPipelineSceneData().isHDR; if (isHDR) { this._illuminanceHDR = val; this._light && ((this._light as scene.RangedDirectionalLight).illuminanceHDR = this._illuminanceHDR); diff --git a/cocos/3d/lights/sphere-light-component.ts b/cocos/3d/lights/sphere-light-component.ts index 4fadb107218..e48ba23c3aa 100644 --- a/cocos/3d/lights/sphere-light-component.ts +++ b/cocos/3d/lights/sphere-light-component.ts @@ -29,7 +29,7 @@ import { scene } from '../../render-scene'; import { Light, PhotometricTerm } from './light-component'; import { CCFloat, CCInteger, cclegacy } from '../../core'; import { Camera } from '../../render-scene/scene'; -import { Root } from '../../root'; +import { getPipelineSceneData } from '../../rendering/pipeline-scene-data-utils'; /** * @en The sphere light component, multiple sphere lights can be added to one scene. @@ -62,7 +62,7 @@ export class SphereLight extends Light { @range([0, Number.POSITIVE_INFINITY, 100]) @type(CCInteger) get luminousFlux (): number { - const isHDR = (cclegacy.director.root as Root).pipeline.pipelineSceneData.isHDR; + const isHDR = getPipelineSceneData().isHDR; if (isHDR) { return this._luminanceHDR * scene.nt2lm(this._size); } else { @@ -70,7 +70,7 @@ export class SphereLight extends Light { } } set luminousFlux (val) { - const isHDR = (cclegacy.director.root as Root).pipeline.pipelineSceneData.isHDR; + const isHDR = getPipelineSceneData().isHDR; let result = 0; if (isHDR) { this._luminanceHDR = val / scene.nt2lm(this._size); @@ -92,7 +92,7 @@ export class SphereLight extends Light { @range([0, Number.POSITIVE_INFINITY, 10]) @type(CCInteger) get luminance (): number { - const isHDR = (cclegacy.director.root as Root).pipeline.pipelineSceneData.isHDR; + const isHDR = getPipelineSceneData().isHDR; if (isHDR) { return this._luminanceHDR; } else { @@ -100,7 +100,7 @@ export class SphereLight extends Light { } } set luminance (val) { - const isHDR = (cclegacy.director.root as Root).pipeline.pipelineSceneData.isHDR; + const isHDR = getPipelineSceneData().isHDR; if (isHDR) { this._luminanceHDR = val; this._light && ((this._light as scene.SphereLight).luminanceHDR = this._luminanceHDR); diff --git a/cocos/3d/lights/spot-light-component.ts b/cocos/3d/lights/spot-light-component.ts index b2729fbb086..f6928062274 100644 --- a/cocos/3d/lights/spot-light-component.ts +++ b/cocos/3d/lights/spot-light-component.ts @@ -22,11 +22,11 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ -import { toRadian, cclegacy, CCBoolean, CCFloat, _decorator } from '../../core'; +import { toRadian, CCBoolean, CCFloat, _decorator } from '../../core'; import { scene } from '../../render-scene'; import { Light, PhotometricTerm } from './light-component'; -import { Root } from '../../root'; import { Camera, PCFType, ShadowType } from '../../render-scene/scene'; +import { getPipelineSceneData } from '../../rendering/pipeline-scene-data-utils'; const { ccclass, range, slide, type, editable, displayOrder, help, executeInEditMode, menu, tooltip, serializable, formerlySerializedAs, visible, property } = _decorator; @@ -80,7 +80,7 @@ export class SpotLight extends Light { @displayOrder(-1) @range([0, Number.POSITIVE_INFINITY, 100]) get luminousFlux (): number { - const isHDR = (cclegacy.director.root as Root).pipeline.pipelineSceneData.isHDR; + const isHDR = getPipelineSceneData().isHDR; if (isHDR) { return this._luminanceHDR * scene.nt2lm(this._size); } else { @@ -89,7 +89,7 @@ export class SpotLight extends Light { } set luminousFlux (val) { - const isHDR = (cclegacy.director.root as Root).pipeline.pipelineSceneData.isHDR; + const isHDR = getPipelineSceneData().isHDR; let result = 0; if (isHDR) { this._luminanceHDR = val / scene.nt2lm(this._size); @@ -109,7 +109,7 @@ export class SpotLight extends Light { @displayOrder(-1) @range([0, Number.POSITIVE_INFINITY, 10]) get luminance (): number { - const isHDR = (cclegacy.director.root as Root).pipeline.pipelineSceneData.isHDR; + const isHDR = getPipelineSceneData().isHDR; if (isHDR) { return this._luminanceHDR; } else { @@ -118,7 +118,7 @@ export class SpotLight extends Light { } set luminance (val) { - const isHDR = (cclegacy.director.root as Root).pipeline.pipelineSceneData.isHDR; + const isHDR = getPipelineSceneData().isHDR; if (isHDR) { this._luminanceHDR = val; this._light && ((this._light as scene.SpotLight).luminanceHDR = this._luminanceHDR); @@ -219,7 +219,7 @@ export class SpotLight extends Light { * @zh 是否启用阴影? */ @tooltip('i18n:lights.shadowEnabled') - @visible(() => (cclegacy.director.root as Root).pipeline.pipelineSceneData.shadows.type === ShadowType.ShadowMap) + @visible(() => getPipelineSceneData().shadows.type === ShadowType.ShadowMap) @property({ group: { name: 'DynamicShadowSettings', displayOrder: 1 } }) @editable @type(CCBoolean) @@ -238,7 +238,7 @@ export class SpotLight extends Light { * @zh 获取或者设置阴影 pcf 等级。 */ @tooltip('i18n:lights.shadowPcf') - @visible(() => (cclegacy.director.root as Root).pipeline.pipelineSceneData.shadows.type === ShadowType.ShadowMap) + @visible(() => getPipelineSceneData().shadows.type === ShadowType.ShadowMap) @property({ group: { name: 'DynamicShadowSettings', displayOrder: 2 } }) @editable @type(PCFType) @@ -257,7 +257,7 @@ export class SpotLight extends Light { * @zh 阴影的深度偏移, 可以减弱跨像素导致的条纹状失真 */ @tooltip('i18n:lights.shadowBias') - @visible(() => (cclegacy.director.root as Root).pipeline.pipelineSceneData.shadows.type === ShadowType.ShadowMap) + @visible(() => getPipelineSceneData().shadows.type === ShadowType.ShadowMap) @property({ group: { name: 'DynamicShadowSettings', displayOrder: 3 } }) @editable @type(CCFloat) @@ -276,7 +276,7 @@ export class SpotLight extends Light { * @zh 设置或者获取法线偏移。 */ @tooltip('i18n:lights.shadowNormalBias') - @visible(() => (cclegacy.director.root as Root).pipeline.pipelineSceneData.shadows.type === ShadowType.ShadowMap) + @visible(() => getPipelineSceneData().shadows.type === ShadowType.ShadowMap) @property({ group: { name: 'DynamicShadowSettings', displayOrder: 4 } }) @editable @type(CCFloat) diff --git a/cocos/gi/light-probe/light-probe-group.ts b/cocos/gi/light-probe/light-probe-group.ts index e80b312856f..3643a915d47 100644 --- a/cocos/gi/light-probe/light-probe-group.ts +++ b/cocos/gi/light-probe/light-probe-group.ts @@ -167,11 +167,11 @@ export class LightProbeGroup extends Component { if (!this.node) { return; } - - const changed = this.node.scene.globals.lightProbeInfo.addNode(this.node); + const lightProbeInfo = this.node.scene.globals.lightProbeInfo; + const changed = lightProbeInfo.addNode(this.node); if (changed) { - this.node.scene.globals.lightProbeInfo.syncData(this.node, this.probes); - this.node.scene.globals.lightProbeInfo.update(true); + lightProbeInfo.syncData(this.node, this.probes); + lightProbeInfo.update(true); } } @@ -223,8 +223,9 @@ export class LightProbeGroup extends Component { } public onProbeChanged (updateTet = true, emitEvent = true): void { - this.node.scene.globals.lightProbeInfo.syncData(this.node, this.probes); - this.node.scene.globals.lightProbeInfo.update(updateTet); + const lightProbeInfo = this.node.scene.globals.lightProbeInfo; + lightProbeInfo.syncData(this.node, this.probes); + lightProbeInfo.update(updateTet); if (emitEvent) { this.node.emit(NodeEventType.LIGHT_PROBE_CHANGED); diff --git a/cocos/render-scene/scene/ambient.ts b/cocos/render-scene/scene/ambient.ts index 9faf273aca2..fc640738c26 100644 --- a/cocos/render-scene/scene/ambient.ts +++ b/cocos/render-scene/scene/ambient.ts @@ -23,6 +23,7 @@ */ import { Vec4, cclegacy } from '../../core'; +import { getPipelineSceneData } from '../../rendering/pipeline-scene-data-utils'; import { AmbientInfo } from '../../scene-graph/scene-globals'; /** @@ -58,7 +59,7 @@ export class Ambient { * @zh 天空颜色 */ get skyColor (): Vec4 { - const isHDR = (cclegacy.director.root).pipeline.pipelineSceneData.isHDR; + const isHDR = getPipelineSceneData().isHDR; if (isHDR) { return this._skyColorHDR; } else { @@ -66,7 +67,7 @@ export class Ambient { } } set skyColor (color: Vec4) { - const isHDR = (cclegacy.director.root).pipeline.pipelineSceneData.isHDR; + const isHDR = getPipelineSceneData().isHDR; if (isHDR) { this._skyColorHDR.set(color); } else { @@ -79,7 +80,7 @@ export class Ambient { * @zh 天空亮度 */ get skyIllum (): number { - const isHDR = (cclegacy.director.root).pipeline.pipelineSceneData.isHDR; + const isHDR = getPipelineSceneData().isHDR; if (isHDR) { return this._skyIllumHDR; } else { @@ -87,7 +88,7 @@ export class Ambient { } } set skyIllum (illum: number) { - const isHDR = (cclegacy.director.root).pipeline.pipelineSceneData.isHDR; + const isHDR = getPipelineSceneData().isHDR; if (isHDR) { this._skyIllumHDR = illum; } else { @@ -99,7 +100,7 @@ export class Ambient { * @zh 地面颜色 */ get groundAlbedo (): Vec4 { - const isHDR = (cclegacy.director.root).pipeline.pipelineSceneData.isHDR; + const isHDR = getPipelineSceneData().isHDR; if (isHDR) { return this._groundAlbedoHDR; } else { @@ -107,7 +108,7 @@ export class Ambient { } } set groundAlbedo (color: Vec4) { - const isHDR = (cclegacy.director.root).pipeline.pipelineSceneData.isHDR; + const isHDR = getPipelineSceneData().isHDR; if (isHDR) { this._groundAlbedoHDR.set(color); } else { diff --git a/cocos/render-scene/scene/directional-light.ts b/cocos/render-scene/scene/directional-light.ts index aecb1f7bdf5..6935eb8cc74 100644 --- a/cocos/render-scene/scene/directional-light.ts +++ b/cocos/render-scene/scene/directional-light.ts @@ -23,6 +23,7 @@ */ import { Vec3, cclegacy } from '../../core'; +import { getPipelineSceneData } from '../../rendering/pipeline-scene-data-utils'; import { Ambient } from './ambient'; import { Light, LightType } from './light'; import { CSMLevel, CSMOptimizationMode, PCFType, Shadows } from './shadows'; @@ -80,7 +81,7 @@ export class DirectionalLight extends Light { * @zh 光源的辐照度,单位是 Lux(lx) */ get illuminance (): number { - const isHDR = (cclegacy.director.root).pipeline.pipelineSceneData.isHDR; + const isHDR = getPipelineSceneData().isHDR; if (isHDR) { return this._illuminanceHDR; } else { @@ -88,7 +89,7 @@ export class DirectionalLight extends Light { } } set illuminance (value: number) { - const isHDR = (cclegacy.director.root).pipeline.pipelineSceneData.isHDR; + const isHDR = getPipelineSceneData().isHDR; if (isHDR) { this.illuminanceHDR = value; } else { diff --git a/cocos/render-scene/scene/model.ts b/cocos/render-scene/scene/model.ts index 86eaac9a590..f7eb81e4d78 100644 --- a/cocos/render-scene/scene/model.ts +++ b/cocos/render-scene/scene/model.ts @@ -49,6 +49,7 @@ import { ProbeType, ReflectionProbe } from './reflection-probe'; import { ReflectionProbeType } from '../../3d/reflection-probe/reflection-probe-enum'; import type { SH } from '../../gi/light-probe/sh'; import type { PipelineSceneData } from '../../rendering'; +import { getPipelineSceneData } from '../../rendering/pipeline-scene-data-utils'; const m4_1 = new Mat4(); @@ -715,7 +716,8 @@ export class Model { this._updateStamp = stamp; this.updateSHUBOs(); - const forceUpdateUBO = this.node.scene.globals.shadows.enabled && this.node.scene.globals.shadows.type === ShadowType.Planar; + const shadows = this.node.scene.globals.shadows; + const forceUpdateUBO = shadows.enabled && shadows.type === ShadowType.Planar; if (!this._localDataUpdated) { return; } this._localDataUpdated = false; @@ -760,7 +762,7 @@ export class Model { return false; } - const lightProbes = (cclegacy.director.root as Root).pipeline.pipelineSceneData.lightProbes; + const lightProbes = getPipelineSceneData().lightProbes; if (!lightProbes || lightProbes.empty()) { return false; } @@ -1171,14 +1173,15 @@ export class Model { */ public getMacroPatches (subModelIndex: number): IMacroPatch[] | null { let patches = this.receiveShadow ? shadowMapPatches : null; - if (this._lightmap != null) { - if (this.node && this.node.scene && !this.node.scene.globals.disableLightmap) { - const mainLightIsStationary = this.node.scene.globals.bakedWithStationaryMainLight; + if (this._lightmap != null && this.node && this.node.scene) { + const sceneGlobals = this.node.scene.globals; + if (!sceneGlobals.disableLightmap) { + const mainLightIsStationary = sceneGlobals.bakedWithStationaryMainLight; const lightmapPathes = mainLightIsStationary ? stationaryLightMapPatches : staticLightMapPatches; patches = patches ? patches.concat(lightmapPathes) : lightmapPathes; // use highp lightmap - if (this.node.scene.globals.bakedWithHighpLightmap) { + if (sceneGlobals.bakedWithHighpLightmap) { patches = patches.concat(highpLightMapPatches); } } diff --git a/cocos/render-scene/scene/point-light.ts b/cocos/render-scene/scene/point-light.ts index 24dd9465474..848d7d48677 100644 --- a/cocos/render-scene/scene/point-light.ts +++ b/cocos/render-scene/scene/point-light.ts @@ -24,6 +24,7 @@ import { cclegacy, geometry, v3, Vec3 } from '../../core'; import { AABB } from '../../core/geometry'; +import { getPipelineSceneData } from '../../rendering/pipeline-scene-data-utils'; import { Light, LightType, nt2lm } from './light'; /** @@ -59,7 +60,7 @@ export class PointLight extends Light { * @zh 光源的亮度。 */ get luminance (): number { - const isHDR = cclegacy.director.root.pipeline.pipelineSceneData.isHDR; + const isHDR = getPipelineSceneData().isHDR; if (isHDR) { return this._luminanceHDR; } else { @@ -67,7 +68,7 @@ export class PointLight extends Light { } } set luminance (value: number) { - const isHDR = cclegacy.director.root.pipeline.pipelineSceneData.isHDR; + const isHDR = getPipelineSceneData().isHDR; if (isHDR) { this.luminanceHDR = value; } else { diff --git a/cocos/render-scene/scene/ranged-directional-light.ts b/cocos/render-scene/scene/ranged-directional-light.ts index 121e6fb7d37..0d023e059e9 100644 --- a/cocos/render-scene/scene/ranged-directional-light.ts +++ b/cocos/render-scene/scene/ranged-directional-light.ts @@ -21,6 +21,7 @@ import { cclegacy } from '../../core'; import { Vec3 } from '../../core/math/vec3'; +import { getPipelineSceneData } from '../../rendering/pipeline-scene-data-utils'; import { Ambient } from './ambient'; import { Light, LightType } from './light'; @@ -76,7 +77,7 @@ export class RangedDirectionalLight extends Light { * @zh 光源的辐照度,单位是 Lux(lx) */ get illuminance (): number { - const isHDR = cclegacy.director.root.pipeline.pipelineSceneData.isHDR; + const isHDR = getPipelineSceneData().isHDR; if (isHDR) { return this._illuminanceHDR; } else { @@ -84,7 +85,7 @@ export class RangedDirectionalLight extends Light { } } set illuminance (value: number) { - const isHDR = cclegacy.director.root.pipeline.pipelineSceneData.isHDR; + const isHDR = getPipelineSceneData().isHDR; if (isHDR) { this.illuminanceHDR = value; } else { diff --git a/cocos/render-scene/scene/skybox.ts b/cocos/render-scene/scene/skybox.ts index b155d3607fd..5c603ce5c2d 100644 --- a/cocos/render-scene/scene/skybox.ts +++ b/cocos/render-scene/scene/skybox.ts @@ -34,6 +34,7 @@ import { Root } from '../../root'; import { GlobalDSManager } from '../../rendering/global-descriptor-set-manager'; import { deviceManager } from '../../gfx'; import { Enum, cclegacy } from '../../core'; +import { getPipelineSceneData } from '../../rendering/pipeline-scene-data-utils'; let skybox_mesh: Mesh | null = null; let skybox_material: Material | null = null; @@ -163,7 +164,7 @@ export class Skybox { * @zh 使用的立方体贴图 */ get envmap (): TextureCube | null { - const isHDR = (cclegacy.director.root as Root).pipeline.pipelineSceneData.isHDR; + const isHDR = getPipelineSceneData().isHDR; if (isHDR) { return this._envmapHDR; } else { @@ -171,8 +172,7 @@ export class Skybox { } } set envmap (val: TextureCube | null) { - const root = cclegacy.director.root as Root; - const isHDR = root.pipeline.pipelineSceneData.isHDR; + const isHDR = getPipelineSceneData().isHDR; if (isHDR) { this.setEnvMaps(val, this._envmapLDR); } else { @@ -185,7 +185,7 @@ export class Skybox { * @zh 使用的漫反射卷积图 */ get diffuseMap (): TextureCube | null { - const isHDR = (cclegacy.director.root as Root).pipeline.pipelineSceneData.isHDR; + const isHDR = getPipelineSceneData().isHDR; if (isHDR) { return this._diffuseMapHDR; } else { @@ -193,7 +193,7 @@ export class Skybox { } } set diffuseMap (val: TextureCube | null) { - const isHDR = (cclegacy.director.root as Root).pipeline.pipelineSceneData.isHDR; + const isHDR = getPipelineSceneData().isHDR; if (isHDR) { this.setDiffuseMaps(val, this._diffuseMapLDR); } else { @@ -202,7 +202,7 @@ export class Skybox { } get reflectionMap (): TextureCube | null { - const isHDR = (cclegacy.director.root as Root).pipeline.pipelineSceneData.isHDR; + const isHDR = getPipelineSceneData().isHDR; if (isHDR) { return this._reflectionHDR; } else { diff --git a/cocos/render-scene/scene/sphere-light.ts b/cocos/render-scene/scene/sphere-light.ts index f4626944f70..764db04d6e5 100644 --- a/cocos/render-scene/scene/sphere-light.ts +++ b/cocos/render-scene/scene/sphere-light.ts @@ -23,6 +23,7 @@ */ import { Vec3, cclegacy, geometry } from '../../core'; +import { getPipelineSceneData } from '../../rendering/pipeline-scene-data-utils'; import { Light, LightType, nt2lm } from './light'; /** @@ -70,7 +71,7 @@ export class SphereLight extends Light { * @zh 光源的亮度 */ get luminance (): number { - const isHDR = (cclegacy.director.root).pipeline.pipelineSceneData.isHDR; + const isHDR = getPipelineSceneData().isHDR; if (isHDR) { return this._luminanceHDR; } else { @@ -78,7 +79,7 @@ export class SphereLight extends Light { } } set luminance (value: number) { - const isHDR = (cclegacy.director.root).pipeline.pipelineSceneData.isHDR; + const isHDR = getPipelineSceneData().isHDR; if (isHDR) { this.luminanceHDR = value; } else { diff --git a/cocos/render-scene/scene/spot-light.ts b/cocos/render-scene/scene/spot-light.ts index 3d22424876d..07ba9bac5d8 100644 --- a/cocos/render-scene/scene/spot-light.ts +++ b/cocos/render-scene/scene/spot-light.ts @@ -24,6 +24,7 @@ import { Mat4, Quat, Vec3, geometry, cclegacy } from '../../core'; import type { Frustum } from '../../core/geometry'; +import { getPipelineSceneData } from '../../rendering/pipeline-scene-data-utils'; import { Light, LightType, nt2lm } from './light'; import { PCFType } from './shadows'; @@ -112,7 +113,7 @@ export class SpotLight extends Light { * @zh 光源的亮度 */ get luminance (): number { - const isHDR = (cclegacy.director.root).pipeline.pipelineSceneData.isHDR; + const isHDR = getPipelineSceneData().isHDR; if (isHDR) { return this._luminanceHDR; } else { @@ -120,7 +121,7 @@ export class SpotLight extends Light { } } set luminance (value: number) { - const isHDR = (cclegacy.director.root).pipeline.pipelineSceneData.isHDR; + const isHDR = getPipelineSceneData().isHDR; if (isHDR) { this.luminanceHDR = value; } else { diff --git a/cocos/rendering/custom/define.ts b/cocos/rendering/custom/define.ts index 2a8dc95f7a5..02a96b69176 100644 --- a/cocos/rendering/custom/define.ts +++ b/cocos/rendering/custom/define.ts @@ -72,9 +72,10 @@ export function validPunctualLightsCulling (pipeline: BasicPipeline, camera: Cam validPunctualLights.length = 0; const _sphere = geometry.Sphere.create(0, 0, 0, 1); const { spotLights } = camera.scene!; + const disableLightmap = camera.node.scene.globals.disableLightmap; for (let i = 0; i < spotLights.length; i++) { const light = spotLights[i]; - if (light.baked && !camera.node.scene.globals.disableLightmap) { + if (light.baked && !disableLightmap) { continue; } @@ -87,7 +88,7 @@ export function validPunctualLightsCulling (pipeline: BasicPipeline, camera: Cam const { sphereLights } = camera.scene!; for (let i = 0; i < sphereLights.length; i++) { const light = sphereLights[i]; - if (light.baked && !camera.node.scene.globals.disableLightmap) { + if (light.baked && !disableLightmap) { continue; } geometry.Sphere.set(_sphere, light.position.x, light.position.y, light.position.z, light.range); diff --git a/cocos/rendering/deferred/lighting-stage.ts b/cocos/rendering/deferred/lighting-stage.ts index 332559ad638..922d6d8f910 100644 --- a/cocos/rendering/deferred/lighting-stage.ts +++ b/cocos/rendering/deferred/lighting-stage.ts @@ -99,6 +99,7 @@ export class LightingStage extends RenderStage { } public gatherLights (camera: Camera): void { const pipeline = this._pipeline as DeferredPipeline; + const isHDR = pipeline.pipelineSceneData.isHDR; const cmdBuff = pipeline.commandBuffers[0]; const sphereLights = camera.scene!.sphereLights; @@ -131,7 +132,7 @@ export class LightingStage extends RenderStage { _vec4Array[2] = finalColor.z; } - if (pipeline.pipelineSceneData.isHDR) { + if (isHDR) { _vec4Array[3] = light.luminance * exposure * this._lightMeterScale; } else { _vec4Array[3] = light.luminance; @@ -164,7 +165,7 @@ export class LightingStage extends RenderStage { _vec4Array[1] = finalColor.y; _vec4Array[2] = finalColor.z; } - if (pipeline.pipelineSceneData.isHDR) { + if (isHDR) { _vec4Array[3] = light.luminance * exposure * this._lightMeterScale; } else { _vec4Array[3] = light.luminance; @@ -201,7 +202,7 @@ export class LightingStage extends RenderStage { _vec4Array[2] = finalColor.z; } - if (pipeline.pipelineSceneData.isHDR) { + if (isHDR) { _vec4Array[3] = light.luminance * exposure * this._lightMeterScale; } else { _vec4Array[3] = light.luminance; @@ -234,7 +235,7 @@ export class LightingStage extends RenderStage { _vec4Array[1] = finalColor.y; _vec4Array[2] = finalColor.z; } - if (pipeline.pipelineSceneData.isHDR) { + if (isHDR) { _vec4Array[3] = light.illuminance * exposure; } else { _vec4Array[3] = light.illuminance; diff --git a/cocos/rendering/pipeline-scene-data-utils.ts b/cocos/rendering/pipeline-scene-data-utils.ts new file mode 100644 index 00000000000..7a040a21ed4 --- /dev/null +++ b/cocos/rendering/pipeline-scene-data-utils.ts @@ -0,0 +1,29 @@ +/* + Copyright (c) 2025 Xiamen Yaji Software Co., Ltd. + https://www.cocos.com/ + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated documentation files (the "Software"), to deal + in the Software without restriction, including without limitation the rights to + use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies + of the Software, and to permit persons to whom the Software is furnished to do so, + subject to the following conditions: + + The above copyright notice and this permission notice shall be included in + all copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + THE SOFTWARE. +*/ + +import { cclegacy } from '../core/global-exports'; +import type { Director } from '../game/director'; +import type { PipelineSceneData } from './pipeline-scene-data'; + +export function getPipelineSceneData (): PipelineSceneData { + return (cclegacy.director as Director).root!.pipeline.pipelineSceneData; +} diff --git a/cocos/rendering/pipeline-scene-data.ts b/cocos/rendering/pipeline-scene-data.ts index 56b25656fac..38c93f05286 100644 --- a/cocos/rendering/pipeline-scene-data.ts +++ b/cocos/rendering/pipeline-scene-data.ts @@ -32,12 +32,13 @@ import { Light } from '../render-scene/scene/light'; import { Material } from '../asset/assets'; import { Pass } from '../render-scene/core/pass'; import { CSMLayers } from './shadow/csm-layers'; -import { legacyCC } from '../core/global-exports'; +import { cclegacy } from '../core/global-exports'; import { Skin } from '../render-scene/scene/skin'; import { Model } from '../render-scene/scene/model'; import { PostSettings } from '../render-scene/scene/post-settings'; -import { MeshRenderer } from '../3d/framework/mesh-renderer'; +import type { MeshRenderer } from '../3d/framework/mesh-renderer'; import type { LightProbes } from '../gi/light-probe'; +import type { Director } from '../game/director'; const GEOMETRY_RENDERER_TECHNIQUE_COUNT = 6; @@ -111,7 +112,7 @@ export class PipelineSceneData { public octree: Octree = new Octree(); public skin: Skin = new Skin(); public postSettings: PostSettings = new PostSettings(); - public lightProbes: LightProbes = legacyCC.internal.LightProbes ? new legacyCC.internal.LightProbes() : null; + public lightProbes: LightProbes = cclegacy.internal.LightProbes ? new cclegacy.internal.LightProbes() : null; /** * @en The list for valid punctual Lights, only available after the scene culling of the current frame. diff --git a/cocos/rendering/scene-culling.ts b/cocos/rendering/scene-culling.ts index 92fc2ce5776..936ea306cbe 100644 --- a/cocos/rendering/scene-culling.ts +++ b/cocos/rendering/scene-culling.ts @@ -55,9 +55,10 @@ export function validPunctualLightsCulling (sceneData: PipelineSceneData, camera validPunctualLights.length = 0; const { spotLights } = camera.scene!; + const disableLightmap = camera.node.scene.globals.disableLightmap; for (let i = 0; i < spotLights.length; i++) { const light = spotLights[i]; - if (light.baked && !camera.node.scene.globals.disableLightmap) { + if (light.baked && !disableLightmap) { continue; } @@ -70,7 +71,7 @@ export function validPunctualLightsCulling (sceneData: PipelineSceneData, camera const { sphereLights } = camera.scene!; for (let i = 0; i < sphereLights.length; i++) { const light = sphereLights[i]; - if (light.baked && !camera.node.scene.globals.disableLightmap) { + if (light.baked && !disableLightmap) { continue; } geometry.Sphere.set(_sphere, light.position.x, light.position.y, light.position.z, light.range); diff --git a/cocos/root.ts b/cocos/root.ts index 9b4ea2ff16a..610f0b3718d 100644 --- a/cocos/root.ts +++ b/cocos/root.ts @@ -41,6 +41,7 @@ import { IPipelineEvent, PipelineEventProcessor } from './rendering/pipeline-eve import { localDescriptorSetLayout_ResizeMaxJoints, UBOCameraEnum, UBOGlobalEnum, UBOLocalEnum, UBOShadowEnum, UBOWorldBound } from './rendering/define'; import { XREye, XRPoseType } from './xr/xr-enums'; import { ICustomJointTextureLayout } from './3d/skeletal-animation/skeletal-animation-utils'; +import { getPipelineSceneData } from './rendering/pipeline-scene-data-utils'; /** * @en Initialization information for the Root @@ -434,8 +435,8 @@ export class Root { this._scenes[i].onGlobalPipelineStateChanged(); } - if (this._pipeline!.pipelineSceneData.skybox.enabled) { - this._pipeline!.pipelineSceneData.skybox.model!.onGlobalPipelineStateChanged(); + if (getPipelineSceneData().skybox.enabled) { + getPipelineSceneData().skybox.model!.onGlobalPipelineStateChanged(); } this._pipeline!.onGlobalPipelineStateChanged(); diff --git a/cocos/scene-graph/scene-globals.ts b/cocos/scene-graph/scene-globals.ts index 1b81b400aa8..0f9a43bb472 100644 --- a/cocos/scene-graph/scene-globals.ts +++ b/cocos/scene-graph/scene-globals.ts @@ -45,6 +45,7 @@ import { cclegacy, macro } from '../core'; import { Scene } from './scene'; import { NodeEventType } from './node-event'; import { PostSettings, ToneMappingType } from '../render-scene/scene/post-settings'; +import { getPipelineSceneData } from '../rendering/pipeline-scene-data-utils'; const _up = new Vec3(0, 1, 0); const _v3 = new Vec3(); @@ -132,7 +133,7 @@ export class AmbientInfo { @tooltip('i18n:ambient.skyLightingColor') set skyLightingColor (val: Color) { _v4.set(val.x, val.y, val.z, val.w); - if ((legacyCC.director.root as Root).pipeline.pipelineSceneData.isHDR) { + if (getPipelineSceneData().isHDR) { this._skyColorHDR.set(_v4); } else { this._skyColorLDR.set(_v4); @@ -140,7 +141,7 @@ export class AmbientInfo { if (this._resource) { this._resource.skyColor.set(_v4); } } get skyLightingColor (): Color { - const isHDR = (legacyCC.director.root as Root).pipeline.pipelineSceneData.isHDR; + const isHDR = getPipelineSceneData().isHDR; _v4.set(isHDR ? this._skyColorHDR : this._skyColorLDR); normalizeHDRColor(_v4); return _col.set(_v4.x * 255, _v4.y * 255, _v4.z * 255, 255); @@ -150,7 +151,7 @@ export class AmbientInfo { * @internal */ set skyColor (val: Vec4) { - if ((legacyCC.director.root as Root).pipeline.pipelineSceneData.isHDR) { + if (getPipelineSceneData().isHDR) { this._skyColorHDR.set(val); } else { this._skyColorLDR.set(val); @@ -167,7 +168,7 @@ export class AmbientInfo { @tooltip('i18n:ambient.skyIllum') @range([0, Number.POSITIVE_INFINITY, 100]) set skyIllum (val: number) { - if ((legacyCC.director.root as Root).pipeline.pipelineSceneData.isHDR) { + if (getPipelineSceneData().isHDR) { this._skyIllumHDR = val; } else { this._skyIllumLDR = val; @@ -176,7 +177,7 @@ export class AmbientInfo { if (this._resource) { this._resource.skyIllum = val; } } get skyIllum (): number { - if ((legacyCC.director.root as Root).pipeline.pipelineSceneData.isHDR) { + if (getPipelineSceneData().isHDR) { return this._skyIllumHDR; } else { return this._skyIllumLDR; @@ -200,7 +201,7 @@ export class AmbientInfo { @tooltip('i18n:ambient.groundLightingColor') set groundLightingColor (val: Color) { _v4.set(val.x, val.y, val.z, val.w); - if ((legacyCC.director.root as Root).pipeline.pipelineSceneData.isHDR) { + if (getPipelineSceneData().isHDR) { this._groundAlbedoHDR.set(_v4); } else { this._groundAlbedoLDR.set(_v4); @@ -208,7 +209,7 @@ export class AmbientInfo { if (this._resource) { this._resource.groundAlbedo.set(_v4); } } get groundLightingColor (): Color { - const isHDR = (legacyCC.director.root as Root).pipeline.pipelineSceneData.isHDR; + const isHDR = getPipelineSceneData().isHDR; _v4.set(isHDR ? this._groundAlbedoHDR : this._groundAlbedoLDR); normalizeHDRColor(_v4); return _col.set(_v4.x * 255, _v4.y * 255, _v4.z * 255, 255); @@ -218,7 +219,7 @@ export class AmbientInfo { * @internal */ set groundAlbedo (val: Vec4) { - if ((legacyCC.director.root as Root).pipeline.pipelineSceneData.isHDR) { + if (getPipelineSceneData().isHDR) { this._groundAlbedoHDR.set(val); } else { this._groundAlbedoLDR.set(val); @@ -349,7 +350,7 @@ export class SkyboxInfo { @editable @tooltip('i18n:skybox.useHDR') set useHDR (val) { - (legacyCC.director.root as Root).pipeline.pipelineSceneData.isHDR = val; + getPipelineSceneData().isHDR = val; this._useHDR = val; // Switch UI to and from LDR/HDR textures depends on HDR state @@ -370,7 +371,7 @@ export class SkyboxInfo { } } get useHDR (): boolean { - (legacyCC.director.root as Root).pipeline.pipelineSceneData.isHDR = this._useHDR; + getPipelineSceneData().isHDR = this._useHDR; return this._useHDR; } @@ -382,7 +383,7 @@ export class SkyboxInfo { @type(TextureCube) @tooltip('i18n:skybox.envmap') set envmap (val) { - const isHDR = (legacyCC.director.root as Root).pipeline.pipelineSceneData.isHDR; + const isHDR = getPipelineSceneData().isHDR; if (isHDR) { this._envmapHDR = val; this._reflectionHDR = null; @@ -411,7 +412,7 @@ export class SkyboxInfo { } } get envmap (): TextureCube | null { - const isHDR = (legacyCC.director.root as Root).pipeline.pipelineSceneData.isHDR; + const isHDR = getPipelineSceneData().isHDR; if (isHDR) { return this._envmapHDR; } else { @@ -450,7 +451,7 @@ export class SkyboxInfo { @type(TextureCube) @displayOrder(100) set diffuseMap (val: TextureCube | null) { - const isHDR = (legacyCC.director.root as Root).pipeline.pipelineSceneData.isHDR; + const isHDR = getPipelineSceneData().isHDR; if (isHDR) { this._diffuseMapHDR = val; } else { @@ -462,7 +463,7 @@ export class SkyboxInfo { } } get diffuseMap (): TextureCube | null { - const isHDR = (legacyCC.director.root as Root).pipeline.pipelineSceneData.isHDR; + const isHDR = getPipelineSceneData().isHDR; if (isHDR) { return this._diffuseMapHDR; } else { @@ -485,7 +486,7 @@ export class SkyboxInfo { @type(TextureCube) @displayOrder(100) set reflectionMap (val: TextureCube | null) { - const isHDR = (legacyCC.director.root as Root).pipeline.pipelineSceneData.isHDR; + const isHDR = getPipelineSceneData().isHDR; if (isHDR) { this._reflectionHDR = val; } else { @@ -496,7 +497,7 @@ export class SkyboxInfo { } } get reflectionMap (): TextureCube | null { - const isHDR = (legacyCC.director.root as Root).pipeline.pipelineSceneData.isHDR; + const isHDR = getPipelineSceneData().isHDR; if (isHDR) { return this._reflectionHDR; } else {