Skip to content
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

fix: fix renderer #281

Merged
merged 2 commits into from
Aug 10, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
53 changes: 10 additions & 43 deletions src/components/Transform.ts
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,7 @@ export class Transform extends ComponentBase {
} else {
this._scene3d = hasRoot;
for (let c of this.object3D.components.values()) {
ComponentCollect.appendWaitStart(this.object3D, c);
ComponentCollect.appendWaitStart(c);
}
}

Expand Down 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
13 changes: 5 additions & 8 deletions src/core/entities/Entity.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,8 @@ import { RenderNode } from '../../components/renderer/RenderNode';
import { Transform } from '../../components/Transform';
import { CEventDispatcher } from '../../event/CEventDispatcher';
import { RenderLayer } from '../../gfx/renderJob/config/RenderLayer';
import { Vector3 } from '../../math/Vector3';
import { BoundUtil } from '../../util/BoundUtil';
import { GetCountInstanceID, UUID } from '../../util/Global';
import { GetCountInstanceID } from '../../util/Global';
import { BoundingBox } from '../bound/BoundingBox';
import { IBound } from '../bound/IBound';
import { Object3D } from './Object3D';
Expand All @@ -24,6 +23,7 @@ export class Entity extends CEventDispatcher {
public name: string = '';

protected readonly _instanceID: string = '';
private _numChildren: number;

/**
* The unique identifier of the object.
Expand Down Expand Up @@ -62,9 +62,6 @@ export class Entity extends CEventDispatcher {
public components: Map<any, IComponent>;


public numChildren: number = 0;


protected waitDisposeComponents: IComponent[];

/**
Expand Down Expand Up @@ -132,7 +129,7 @@ export class Entity extends CEventDispatcher {
* Returns the number of child objects of an object
*/
public get numChildren(): number {
return this.entityChildren.length;
return this._numChildren;
}

/**
Expand All @@ -157,7 +154,7 @@ export class Entity extends CEventDispatcher {
}
child.transform.parent = this.transform;
this.entityChildren.push(child);
this.numChildren = this.entityChildren.length;
this._numChildren = this.entityChildren.length;
return child;
}
return null;
Expand All @@ -175,7 +172,7 @@ export class Entity extends CEventDispatcher {
if (index != -1) {
this.entityChildren.splice(index, 1);
child.transform.parent = null;
this.numChildren = this.entityChildren.length;
this._numChildren = this.entityChildren.length;
}
}

Expand Down