Skip to content

Commit

Permalink
chore: chore uuid (#264)
Browse files Browse the repository at this point in the history
fix geometry repeat init
change uuid to instanceID
change transform update
remove doc
back stop
  • Loading branch information
ZenderJK authored Jul 28, 2023
1 parent e5152df commit 6ae06db
Show file tree
Hide file tree
Showing 17 changed files with 159 additions and 161 deletions.
11 changes: 10 additions & 1 deletion packages/debug/GUIHelp.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ class _GUIHelp {
let dgui = this._current ? this._current : this.gui;

let tobj = {
[label] : obj[property]
[label]: obj[property]
}
dgui.add(tobj, label, c, d, e).onChange((v) => {
obj[property] = v;
Expand All @@ -53,6 +53,15 @@ class _GUIHelp {
GUIHelp.add({ label: label }, 'label');
}

addInfo(label: string, value: any) {
if (!this.debug)
return this._nullBind;

let obj = {};
obj[label] = value.toString();
GUIHelp.add(obj, label);
}

addColor(target: any, key: string) {
if (!this.debug)
return this._nullBind;
Expand Down
4 changes: 2 additions & 2 deletions samples/base/Sample_BoundingBox.ts
Original file line number Diff line number Diff line change
Expand Up @@ -47,8 +47,8 @@ class Sample_BoundingBox {
red = new Color(1, 0, 0, 1);
gree = new Color(0, 1, 0, 1);
loop() {
this.view.graphic3D.drawBoundingBox(this.box.uuid, this.box.bound as any, this.gree);
this.view.graphic3D.drawBoundingBox(this.container.uuid, this.container.bound as any, this.red);
this.view.graphic3D.drawBoundingBox(this.box.instanceID, this.box.bound as any, this.gree);
this.view.graphic3D.drawBoundingBox(this.container.instanceID, this.container.bound as any, this.red);
}
}

Expand Down
1 change: 1 addition & 0 deletions samples/benchmark/Sample_SphereDraw.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ class Sample_SphereDraw {
public anim: boolean = false;
async run() {
// init engine
Engine3D.setting.pick.enable = false;
await Engine3D.init({ renderLoop: () => this.renderLoop() });
// create new Scene
this.scene = new Scene3D();
Expand Down
61 changes: 53 additions & 8 deletions samples/benchmark/Sample_drawCall.ts
Original file line number Diff line number Diff line change
@@ -1,13 +1,15 @@
import { GUIHelp } from '@orillusion/debug/GUIHelp';
import { Stats } from '@orillusion/stats'
import { Engine3D, Scene3D, AtmosphericComponent, CameraUtil, HoverCameraController, Object3D, MeshRenderer, BoxGeometry, LitMaterial, DirectLight, KelvinUtil, View3D, Vector3, Vector3Ex, UnLitMaterial, InstanceDrawComponent, LambertMaterial, Time, BoundingBox, Color, OcclusionSystem, PostProcessingComponent, GlobalFog } from '@orillusion/core';
import { Engine3D, Scene3D, AtmosphericComponent, CameraUtil, HoverCameraController, Object3D, MeshRenderer, BoxGeometry, LitMaterial, DirectLight, KelvinUtil, View3D, Vector3, Vector3Ex, UnLitMaterial, InstanceDrawComponent, LambertMaterial, Time, BoundingBox, Color, OcclusionSystem, PostProcessingComponent, GlobalFog, SphereGeometry } from '@orillusion/core';
import { GUIUtil } from '@samples/utils/GUIUtil';

// simple base demo
class Sample_drawCall {
scene: Scene3D;
public anim: boolean = false;
async run() {

Engine3D.setting.pick.enable = false;
// init engine
await Engine3D.init({ renderLoop: () => this.renderLoop() });

Expand All @@ -28,7 +30,7 @@ class Sample_drawCall {

// add a basic camera controller
let hoverCameraController = mainCamera.object3D.addComponent(HoverCameraController);
hoverCameraController.setCamera(15, -15, 100);
hoverCameraController.setCamera(15, -15, 300);

// add a basic direct light
let lightObj = new Object3D();
Expand All @@ -51,7 +53,6 @@ class Sample_drawCall {
// start render
Engine3D.startRenderView(view);
GUIHelp.init();

// let post = view.scene.addComponent(PostProcessingComponent);
// let fog = post.addPost(GlobalFog);
// fog.fogColor = new Color(136 / 255, 215 / 255, 236 / 255, 1);
Expand All @@ -67,6 +68,8 @@ class Sample_drawCall {
this.anim != this.anim;
};



this.initScene();
}

Expand All @@ -87,26 +90,61 @@ class Sample_drawCall {
// new LambertMaterial(),
// new LambertMaterial(),
// new LambertMaterial(),
// new LambertMaterial(),
// new LambertMaterial(),
// new LambertMaterial(),
// new LambertMaterial(),
// new LambertMaterial(),
// new LambertMaterial(),
// new LambertMaterial(),
// new LambertMaterial(),
// new LambertMaterial(),
// new LambertMaterial(),
// new LambertMaterial(),
// new LambertMaterial(),
// new LambertMaterial(),
// new LambertMaterial(),
// new LambertMaterial(),
// new LambertMaterial(),
// new LambertMaterial(),
// new LambertMaterial(),
// new LambertMaterial(),
// new LambertMaterial(),
// new LambertMaterial(),
// new LambertMaterial(),
// new LambertMaterial(),
];

for (let i = 0; i < materials.length; i++) {
const element = materials[i];
// element.metallic = 0.97;
// element.roughness = 0.15;
element.baseColor = new Color().hexToRGB(Color.GOLD);
// element.baseColor = new Color().hexToRGB(Color.GOLD);
element.baseColor = new Color(
Math.random(),
Math.random(),
Math.random(),
);
}

// let material = new LitMaterial();

let group = new Object3D();
let count = 10000;
let count = 50000;

GUIHelp.addFolder('info');
GUIHelp.open();
GUIHelp.addInfo(`count `, count);

let ii = 0;
// let count = 70000;
for (let i = 0; i < count; i++) {
let pos = Vector3Ex.sphereXYZ(50, 100, 100, 10, 100);
let pos = Vector3Ex.sphereXYZ(ii * 60 + 20, ii * 60 + 100, 100, i * 0.001 + 10, 100);
// let pos = Vector3Ex.getRandomXYZ(-2, 2);
let obj = new Object3D();
let mr = obj.addComponent(MeshRenderer);
mr.geometry = shareGeometry;
mr.geometry = shareGeometry;// Math.random() > 0.5 ? new BoxGeometry(Math.random() + 0.5, Math.random() + 0.5, Math.random() + 0.5) : new SphereGeometry(Math.random() + 0.5, Math.floor(Math.random() * 15 + 8), Math.floor(Math.random() * 15 + 8));
// mr.geometry = Math.random() > 0.5 ? new BoxGeometry(Math.random() + 0.5, Math.random() + 0.5, Math.random() + 0.5) : new SphereGeometry(Math.random() + 0.5, Math.floor(Math.random() * 15 + 8), Math.floor(Math.random() * 15 + 8));
mr.material = materials[Math.floor(Math.random() * materials.length)];
obj.localPosition = pos;
group.addChild(obj);
Expand All @@ -119,12 +157,19 @@ class Sample_drawCall {
obj.transform.rotationX = Math.random() * 360;
obj.transform.rotationY = Math.random() * 360;
obj.transform.rotationZ = Math.random() * 360;
// if (i < count - 1) {
// obj.localPosition = Vector3.ZERO;
// }

this._rotList.push((Math.random() * 1 - 1 * 0.5) * 2.0 * Math.random() * 100);
obj.transform.rotatingY = 16 * 0.01 * this._rotList[i];

if (i % 10000 == 0) {
ii++;
}
}

// group.addComponent(InstanceDrawComponent);
group.addComponent(InstanceDrawComponent);
this._rotList.push(1.0);
group.transform.rotatingY = 16 * 0.01 * 1;

Expand Down
88 changes: 0 additions & 88 deletions samples/material/Sample_RenderPassClean.ts

This file was deleted.

10 changes: 1 addition & 9 deletions src/Engine3D.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@ import { ShaderUtil } from './gfx/graphics/webGpu/shader/util/ShaderUtil';
import { ComponentCollect } from './gfx/renderJob/collect/ComponentCollect';
import { ShadowLightsCollect } from './gfx/renderJob/collect/ShadowLightsCollect';
import { GUIConfig } from './components/gui/GUIConfig';
import { Transform } from './components/Transform';

/**
* Orillusion 3D Engine
Expand Down Expand Up @@ -452,15 +451,8 @@ export class Engine3D {
let i = 0;
for (i = 0; i < views.length; i++) {
const view = views[i];
Transform.updateChildTransform(view.scene.transform);
view.scene.transform.updateChildTransform()
}
// for (const iterator of RenderShaderCollect.renderNodeList) {
// let nodes = iterator[1];
// for (const node of nodes) {
// let item = node[1];
// item.transform.updateWorldMatrix();
// }
// }

/****** auto update global matrix share buffer write to gpu *****/
let globalMatrixBindGroup = GlobalBindGroup.modelMatrixBindGroup;
Expand Down
26 changes: 14 additions & 12 deletions src/components/Transform.ts
Original file line number Diff line number Diff line change
Expand Up @@ -376,18 +376,19 @@ export class Transform extends ComponentBase {
this._localChange = false;
}

public static updateChildTransform(transform: Transform) {
if (!transform.view3D || !transform.enable) {
return;
}
if (transform._localChange)
transform.updateWorldMatrix();
let children = transform.object3D.entityChildren;
let i = 0;
let len = children.length;
for (i = 0; i < len; i++) {
const node = children[i];
Transform.updateChildTransform(node.transform);
public updateChildTransform() {
let self = this;
if (self._localChange) {
self.updateWorldMatrix();
}
if (self.object3D.numChildren > 0) {
let i = 0;
// for (i = 0; i < self.object3D.numChildren; i++) {
// self.object3D.entityChildren[i].transform.updateChildTransform();
// }
for (const child of self.object3D.entityChildren) {
child.transform.updateChildTransform();
}
}
}

Expand Down Expand Up @@ -793,3 +794,4 @@ export class Transform extends ComponentBase {
// }

}

2 changes: 1 addition & 1 deletion src/components/lights/PointLight.ts
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ export class PointLight extends LightBase {

public onGraphic(view?: View3D): void {
let custom = view.graphic3D.createCustomShape(
`PointLight_${this.object3D.uuid}`,
`PointLight_${this.object3D.instanceID}`,
this.transform,
);
custom.buildAxis();
Expand Down
2 changes: 1 addition & 1 deletion src/components/lights/SpotLight.ts
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,7 @@ export class SpotLight extends LightBase {

public onGraphic(view: View3D) {
let custom = view.graphic3D.createCustomShape(
`SpotLight_${this.object3D.uuid}`,
`SpotLight_${this.object3D.instanceID}`,
this.transform,
);

Expand Down
4 changes: 2 additions & 2 deletions src/components/renderer/RenderNode.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ import { RendererMask, RendererMaskUtil } from "../../gfx/renderJob/passRenderer
import { RendererPassState } from "../../gfx/renderJob/passRenderer/state/RendererPassState";
import { RendererType } from "../../gfx/renderJob/passRenderer/state/RendererType";
import { MaterialBase } from "../../materials/MaterialBase";
import { UUID } from "../../util/Global";
import { GetCountInstanceID, UUID } from "../../util/Global";
import { Reference } from "../../util/Reference";
import { ComponentBase } from "../ComponentBase";
import { IESProfiles } from "../lights/IESProfiles";
Expand Down Expand Up @@ -53,7 +53,7 @@ export class RenderNode extends ComponentBase {

public init() {
this.rendererMask = RendererMask.Default;
this.instanceID = UUID();
this.instanceID = GetCountInstanceID().toString();
}

public copyComponent(from: this): this {
Expand Down
Loading

0 comments on commit 6ae06db

Please sign in to comment.