Skip to content

Commit

Permalink
fix(UniformNode): Fix error of Uniform data(number) (#276)
Browse files Browse the repository at this point in the history
Fix error of Uniform data(number)
  • Loading branch information
hellmor committed Aug 9, 2023
1 parent e00b1b4 commit 09266a6
Show file tree
Hide file tree
Showing 5 changed files with 27 additions and 12 deletions.
2 changes: 1 addition & 1 deletion public
16 changes: 11 additions & 5 deletions samples/gi/Sample_GI.ts
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,14 @@ class Sample_GI {
strength: 1.2
};

await Engine3D.init({});
await Engine3D.init({
renderLoop: () => {
if (this.giComponent?.isStart) {
GUIUtil.renderGIComponent(this.giComponent);
this.giComponent = null;
}
}
});
GUIHelp.init();
let param = createSceneParam();
param.camera.distance = 200;
Expand All @@ -65,13 +72,12 @@ class Sample_GI {

}

private giComponent: GlobalIlluminationComponent;

private addGIProbes() {
let probeObj = new Object3D();
let component = probeObj.addComponent(GlobalIlluminationComponent);
this.giComponent = probeObj.addComponent(GlobalIlluminationComponent);
this.scene.addChild(probeObj);
setTimeout(() => {
GUIUtil.renderGIComponent(component);
}, 2000);
}

async initScene() {
Expand Down
15 changes: 10 additions & 5 deletions samples/gi/Sample_GICornellBox.ts
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,14 @@ class Sample_GICornellBox {
strength: 1.2
};

await Engine3D.init({});
await Engine3D.init({
renderLoop: () => {
if (this.giComponent?.isStart) {
GUIUtil.renderGIComponent(this.giComponent);
this.giComponent = null;
}
}
});
let param = createSceneParam();
param.camera.distance = 40;

Expand All @@ -65,14 +72,12 @@ class Sample_GICornellBox {
await this.initScene();
}

private giComponent: GlobalIlluminationComponent;
private addGIProbes() {
let probeObj = new Object3D();
GUIHelp.init();
let component = probeObj.addComponent(GlobalIlluminationComponent);
this.giComponent = probeObj.addComponent(GlobalIlluminationComponent);
this.scene.addChild(probeObj);
setTimeout(() => {
GUIUtil.renderGIComponent(component);
}, 2000);
}

async initScene() {
Expand Down
3 changes: 3 additions & 0 deletions src/components/ComponentBase.ts
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,9 @@ export class ComponentBase implements IComponent {

private __isStart: boolean = false;

public get isStart(): boolean {
return this.__isStart;
}

/**
* Return the Transform component attached to the Object3D.
Expand Down
3 changes: 2 additions & 1 deletion src/gfx/graphics/webGpu/core/uniforms/UniformNode.ts
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,8 @@ export class UniformNode {
this._type = UniformType.Float32Array;
} else {
this.size = 1;
this._x = value.x;
this._x = value;
this._data = value;
this._type = UniformType.Number;
}
}
Expand Down

0 comments on commit 09266a6

Please sign in to comment.