Merge pull request #65 from JoneLau/new-3d

add camera in IUIRenderData
This commit is contained in:
Weiliang Wang
2019-01-17 16:35:57 +08:00
committed by GitHub
+21 -1
View File
@@ -21,6 +21,7 @@ import { LabelComponent } from '../../3d/ui/components/label-component';
import { SpriteComponent } from '../../3d/ui/components/sprite-component';
import { UIBatchModel } from './ui-batch-model';
import { vfmt } from '../../gfx/vertex-format-sample';
import { UITransformComponent } from '../../3d/ui/components/ui-transfrom-component';
// import { GFXBuffer } from '../../gfx/buffer';
// import { RenderComponent } from '../../3d/ui/components/ui-render-component';
@@ -43,6 +44,7 @@ export interface IUIRenderItem {
export interface IUIRenderData {
meshBuffer: MeshBuffer;
material: Material;
camera: Camera;
}
export class UI {
@@ -113,6 +115,18 @@ export class UI {
this._screens.push(comp);
}
public getScreen (visibility: number) {
for (const screen of this._screens) {
if (screen.camera) {
if (screen.camera.visibility === visibility) {
return screen;
}
}
}
return null;
}
public removeScreen (comp) {
const idx = this._screens.indexOf(comp);
if (idx !== -1) {
@@ -176,7 +190,13 @@ export class UI {
attributes: vfmt,
} as IMeshBufferInitData);
comp.updateRenderData(buffer);
this._emit({ meshBuffer: buffer, material: comp.material} as IUIRenderData);
const canvasComp: CanvasComponent | null = this.getScreen(comp.viewID);
this._emit({
meshBuffer: buffer,
material: comp.material,
camera: canvasComp ? canvasComp.camera : null,
} as IUIRenderData);
}
private _emit (renderData: IUIRenderData) {