mirror of
https://github.com/cocos/cocos4.git
synced 2026-12-01 15:52:40 +08:00
add camera in IUIRenderData
This commit is contained in:
+21
-1
@@ -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) {
|
||||
|
||||
Reference in New Issue
Block a user