Skip to content

Commit

Permalink
feat: add graphic sample (#265)
Browse files Browse the repository at this point in the history
add graphic sample
  • Loading branch information
ZenderJK committed Jul 28, 2023
1 parent 81ded0f commit 6e51c74
Show file tree
Hide file tree
Showing 2 changed files with 75 additions and 3 deletions.
72 changes: 72 additions & 0 deletions samples/graphic/Sample_GraphicLine.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
import { createExampleScene, createSceneParam } from "@samples/utils/ExampleScene";
import { Object3D, Scene3D, Engine3D, GlobalIlluminationComponent, Object3DUtil, GTAOPost, HDRBloomPost, PostProcessingComponent, TAAPost, Vector3, Color, AnimationCurve, Keyframe } from "@orillusion/core";
import { GUIUtil } from "@samples/utils/GUIUtil";
import { GUIHelp } from "@orillusion/debug/GUIHelp";

class Sample_GraphicLine {
scene: Scene3D;
view: import("c:/work/git/orillusion-nian/src/index").View3D;
async run() {

Engine3D.setting.material.materialChannelDebug = true;
Engine3D.setting.material.materialDebug = false;

Engine3D.setting.render.postProcessing.bloom = {
enable: true,
debug: false,
blurX: 4,
blurY: 4,
luminosityThreshold: 0.9,
radius: 4,
strength: 1.2
};

await Engine3D.init({});
GUIHelp.init();
let param = createSceneParam();
param.camera.distance = 200;
let exampleScene = createExampleScene(param);
exampleScene.atmosphericSky.exposure = 1.0;
this.view = exampleScene.view;
this.scene = exampleScene.scene;
Engine3D.startRenderViews([exampleScene.view]);
let job = Engine3D.getRenderJob(exampleScene.view);
await this.initScene();
// GUIUtil.renderAtomosphericSky(exampleScene.atmosphericSky);
GUIUtil.renderDirLight(exampleScene.light);
}

async initScene() {
this.view.graphic3D.drawLines('line1', [Vector3.ZERO, new Vector3(0, 10, 0)], new Color().hexToRGB(Color.RED));



let animCurve = new AnimationCurve();
animCurve.addKeyFrame(new Keyframe(0, 0.5));
animCurve.addKeyFrame(new Keyframe(0.15, -0.2));
animCurve.addKeyFrame(new Keyframe(0.22, 0.4));
animCurve.addKeyFrame(new Keyframe(0.34, 0.2));
animCurve.addKeyFrame(new Keyframe(0.65, -0.2));
animCurve.addKeyFrame(new Keyframe(1, 0.9));
let lines = [];
for (let i = 0; i < 100; i++) {
let y = animCurve.getValue(i / (100 - 1)) * 10;
lines.push(
new Vector3(
i,
y,
0
)
);
}
this.view.graphic3D.drawLines('line2', lines, new Color().hexToRGB(Color.RED));

this.view.graphic3D.drawBox('box1', new Vector3(-5, -5, -5), new Vector3(5, 5, 5), new Color().hexToRGB(Color.GREEN));

this.view.graphic3D.drawCircle('Circle1', new Vector3(-15, -5, -5), 5, 15, Vector3.X_AXIS, new Color().hexToRGB(Color.GREEN));
this.view.graphic3D.drawCircle('Circle2', new Vector3(-15, -5, -5), 5, 15, Vector3.Y_AXIS, new Color().hexToRGB(Color.GREEN));
this.view.graphic3D.drawCircle('Circle3', new Vector3(-15, -5, -5), 5, 15, Vector3.Z_AXIS, new Color().hexToRGB(Color.GREEN));
}
}

new Sample_GraphicLine().run();
6 changes: 3 additions & 3 deletions src/gfx/graphics/webGpu/core/uniforms/UniformNode.ts
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ export class UniformNode {
}

public get vector2(): Vector2 {
return new Vector2(this._data.x, this._data.y);
return this._data;//new Vector2(this._data.x, this._data.y);
}

public set vector2(value: Vector2) {
Expand All @@ -102,7 +102,7 @@ export class UniformNode {
}

public get vector3(): Vector3 {
return new Vector3(this._data.x, this._data.y, this._data.z);
return this._data;//new Vector3(this._data.x, this._data.y, this._data.z);
}

public set vector3(value: Vector3) {
Expand All @@ -116,7 +116,7 @@ export class UniformNode {

public get vector4(): Vector4 {
// this.onChange();
return new Vector4(this._data.x, this._data.y, this._data.z, this._data.w);
return this._data;//new Vector4(this._data.x, this._data.y, this._data.z, this._data.w);
}

public set vector4(value: Vector4) {
Expand Down

0 comments on commit 6e51c74

Please sign in to comment.