From 1f66ee858eea3c19c11acf743b2cc6aa3be6ed37 Mon Sep 17 00:00:00 2001 From: OldGentleMan <397939361@qq.com> Date: Thu, 10 Aug 2023 23:15:13 +0800 Subject: [PATCH] fix: fix renderer (#281) fix transform localQuat fix renderer enable --- samples/material/Sample_PBRMaterial.ts | 2 +- src/components/AtmosphericComponent.ts | 8 +++- src/components/Transform.ts | 51 +++++--------------------- src/components/renderer/RenderNode.ts | 6 +-- 4 files changed, 20 insertions(+), 47 deletions(-) diff --git a/samples/material/Sample_PBRMaterial.ts b/samples/material/Sample_PBRMaterial.ts index dc46703b..e7f4d91d 100644 --- a/samples/material/Sample_PBRMaterial.ts +++ b/samples/material/Sample_PBRMaterial.ts @@ -54,7 +54,7 @@ class Sample_PBRMaterial { let directLight = this.lightObj3D.addComponent(DirectLight); directLight.lightColor = KelvinUtil.color_temperature_to_rgb(5355); directLight.castShadow = true; - directLight.intensity = 43; + directLight.intensity = 72; GUIUtil.renderDirLight(directLight); this.scene.addChild(this.lightObj3D); diff --git a/src/components/AtmosphericComponent.ts b/src/components/AtmosphericComponent.ts index 9f274a65..c3139a46 100644 --- a/src/components/AtmosphericComponent.ts +++ b/src/components/AtmosphericComponent.ts @@ -129,9 +129,15 @@ export class AtmosphericComponent extends SkyRenderer { super.init(); this._historyData = new HistoryData(); this._atmosphericScatteringSky = new AtmosphericScatteringSky(new AtmosphericScatteringSkySetting()); + + let view3D = this.transform.view3D; + let scene = this.transform.scene3D; + this.map = this._atmosphericScatteringSky; + scene.envMap = this._atmosphericScatteringSky; + this.onUpdate(view3D); } - public start(): void { + public start(view?: any): void { let scene = this.transform.scene3D; this.map = this._atmosphericScatteringSky; scene.envMap = this._atmosphericScatteringSky; diff --git a/src/components/Transform.ts b/src/components/Transform.ts index a237193e..53b0a474 100644 --- a/src/components/Transform.ts +++ b/src/components/Transform.ts @@ -217,12 +217,9 @@ export class Transform extends ComponentBase { public set up(value: Vector3) { this._up.copyFrom(value); - this.notifyLocalChange(); - this.onRotationChange?.(); - if (this.eventRotationChange) { - this.eventDispatcher.dispatchEvent(this.eventRotationChange); - } + MathUtil.fromToRotation(Vector3.UP, this._up, Quaternion.HELP_0); + this.transform.localRotQuat = Quaternion.HELP_0; } public get down(): Vector3 { @@ -232,13 +229,8 @@ export class Transform extends ComponentBase { public set down(value: Vector3) { this._down.copyFrom(value); - this.notifyLocalChange(); - - this.onRotationChange?.(); - - if (this.eventRotationChange) { - this.eventDispatcher.dispatchEvent(this.eventRotationChange); - } + MathUtil.fromToRotation(Vector3.DOWN, this._down, Quaternion.HELP_0); + this.transform.localRotQuat = Quaternion.HELP_0; } public get forward(): Vector3 { @@ -250,12 +242,6 @@ export class Transform extends ComponentBase { this._forward.copyFrom(value); MathUtil.fromToRotation(Vector3.FORWARD, this._forward, Quaternion.HELP_0); this.transform.localRotQuat = Quaternion.HELP_0; - this.notifyLocalChange(); - this.onRotationChange?.(); - - if (this.eventRotationChange) { - this.eventDispatcher.dispatchEvent(this.eventRotationChange); - } } public get back(): Vector3 { @@ -267,12 +253,6 @@ export class Transform extends ComponentBase { this._back.copyFrom(value); MathUtil.fromToRotation(Vector3.BACK, this._back, Quaternion.HELP_0); this.transform.localRotQuat = Quaternion.HELP_0; - this.notifyLocalChange(); - this.onRotationChange?.(); - - if (this.eventRotationChange) { - this.eventDispatcher.dispatchEvent(this.eventRotationChange); - } } public get left(): Vector3 { @@ -282,11 +262,8 @@ export class Transform extends ComponentBase { public set left(value: Vector3) { this._left.copyFrom(value); - this.notifyLocalChange(); - this.onRotationChange?.(); - if (this.eventRotationChange) { - this.eventDispatcher.dispatchEvent(this.eventRotationChange); - } + MathUtil.fromToRotation(Vector3.LEFT, this._left, Quaternion.HELP_0); + this.transform.localRotQuat = Quaternion.HELP_0; } public get right(): Vector3 { @@ -296,12 +273,8 @@ export class Transform extends ComponentBase { public set right(value: Vector3) { this._right.copyFrom(value); - this.notifyLocalChange(); - this.onRotationChange?.(); - - if (this.eventRotationChange) { - this.eventDispatcher.dispatchEvent(this.eventRotationChange); - } + MathUtil.fromToRotation(Vector3.RIGHT, this._right, Quaternion.HELP_0); + this.transform.localRotQuat = Quaternion.HELP_0; } /** @@ -315,13 +288,7 @@ export class Transform extends ComponentBase { public set localRotQuat(value: Quaternion) { this._localRotQuat = value; this._localRotQuat.getEulerAngles(this._localRot); - - this.notifyLocalChange(); - this.onRotationChange?.(); - - if (this.eventRotationChange) { - this.eventDispatcher.dispatchEvent(this.eventRotationChange); - } + this.localRotation = this._localRot; } /** diff --git a/src/components/renderer/RenderNode.ts b/src/components/renderer/RenderNode.ts index b21a5d54..8f8bc88b 100644 --- a/src/components/renderer/RenderNode.ts +++ b/src/components/renderer/RenderNode.ts @@ -467,9 +467,9 @@ export class RenderNode extends ComponentBase { renderShader.setTexture(`envMap`, envMap); } - if (!node._ignorePrefilterMap && renderShader.prefilterMap != envMap) { - renderShader.setTexture(`prefilterMap`, envMap); - } + // if (!node._ignorePrefilterMap && renderShader.prefilterMap != envMap) { + renderShader.setTexture(`prefilterMap`, envMap); + // } if (renderShader.pipeline) { renderShader.apply(node._geometry, pass, renderPassState, () => node.noticeShaderChange());