Skip to content

Commit

Permalink
fix: fix renderer (#281)
Browse files Browse the repository at this point in the history
fix transform localQuat
fix renderer enable
  • Loading branch information
ZenderJK committed Aug 10, 2023
1 parent 0cf0e1c commit 1f66ee8
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 47 deletions.
2 changes: 1 addition & 1 deletion samples/material/Sample_PBRMaterial.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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);

Expand Down
8 changes: 7 additions & 1 deletion src/components/AtmosphericComponent.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
51 changes: 9 additions & 42 deletions src/components/Transform.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand All @@ -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 {
Expand All @@ -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 {
Expand All @@ -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 {
Expand All @@ -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 {
Expand All @@ -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;
}

/**
Expand All @@ -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;
}

/**
Expand Down
6 changes: 3 additions & 3 deletions src/components/renderer/RenderNode.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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());
Expand Down

0 comments on commit 1f66ee8

Please sign in to comment.