feat: 调整线图层纹理监听控制逻辑

This commit is contained in:
shihui 2023-02-13 16:14:24 +08:00
parent 8a8a0ab71b
commit baaced6f63
1 changed files with 5 additions and 2 deletions

View File

@ -31,6 +31,7 @@ const lineStyleObj: { [key: string]: number } = {
dash: 1.0,
};
export default class LineModel extends BaseModel {
private textureListenService: undefined | any;
protected texture: ITexture2D = this.createTexture2D({
data: [0,0,0,0],
mag: gl.NEAREST,
@ -163,8 +164,10 @@ export default class LineModel extends BaseModel {
public async initModels():Promise<IModel[]>{
this.updateTexture();
// Tip: keep updateTexture listen only once
this.iconService.off('imageUpdate', this.updateTexture);
this.iconService.on('imageUpdate', this.updateTexture);
if(!this.textureListenService) {
this.textureListenService = this.iconService.on('imageUpdate', this.updateTexture);
}
return await this.buildModels();
}