Files
cocos4/cocos/renderer/ui/ui-batch-model.ts
T
Yun Hsiao Wu 9403a19382 update resources on pipeline change (#4106)
...and get inspector on light component to work
2019-03-26 18:45:23 +08:00

52 lines
1.3 KiB
TypeScript

import { Material } from '../../3d/assets/material';
import { GFXInputAssembler } from '../../gfx/input-assembler';
import { GFXPipelineState } from '../../gfx/pipeline-state';
import { Model } from '../scene/model';
import { RenderScene } from '../scene/render-scene';
import { SubModel } from '../scene/submodel';
import { UIDrawBatch } from './ui';
export class UIBatchModel extends Model {
private _subModel: UISubModel;
constructor (scene: RenderScene) {
super(scene, null!);
this._subModel = new UISubModel();
}
public updateTransform () {
}
public updateUBOs () {
}
public initialize (ia: GFXInputAssembler, batch: UIDrawBatch) {
this._subModel.directInitialize(ia, batch.material!, batch.pipelineState!);
this._subModels[0] = this._subModel;
}
public destroy () {
this._subModel.destroy();
}
}
class UISubModel extends SubModel {
constructor () {
super();
this.psos = [];
}
public directInitialize (ia: GFXInputAssembler, mat: Material, pso: GFXPipelineState) {
this._inputAssembler = ia;
this.psos[0] = pso;
this.material = mat;
}
public destroy () {
if (this.commandBuffers.length > 0) {
this.commandBuffers[0].destroy();
}
}
}