diff --git a/packages/effects-core/src/composition-source-manager.ts b/packages/effects-core/src/composition-source-manager.ts index cf48d305b..56b9c3b11 100644 --- a/packages/effects-core/src/composition-source-manager.ts +++ b/packages/effects-core/src/composition-source-manager.ts @@ -102,11 +102,6 @@ export class CompositionSourceManager implements Disposable { private assembleItems (composition: spec.Composition) { const items: any[] = []; - let mask = this.mask++; - - if (isNaN(mask)) { - mask = 0; - } composition.items.forEach(item => { const option: Record = {}; @@ -128,11 +123,7 @@ export class CompositionSourceManager implements Disposable { if (renderContent.renderer) { renderContent.renderer = this.changeTex(renderContent.renderer); - - if (!renderContent.renderer.mask) { - this.processMask(renderContent.renderer, this.mask); - } - + this.processMask(renderContent.renderer); const split = renderContent.splits && !renderContent.textureSheetAnimation && renderContent.splits[0]; if (Number.isInteger(renderContent.renderer.shape)) { @@ -192,7 +183,7 @@ export class CompositionSourceManager implements Disposable { ref.items.forEach((item: Record) => { item.listIndex = listOrder++; - this.processMask(item.content, maskRef); + this.processMask(item.content); }); option.items = ref.items; @@ -239,12 +230,17 @@ export class CompositionSourceManager implements Disposable { /** * 处理蒙版和遮挡关系写入 stencil 的 ref 值 */ - private processMask (renderer: Record, maskRef: number) { + private processMask (renderer: Record) { + if (renderer.maskMode === spec.MaskMode.NONE) { + return; + } if (!renderer.mask) { const maskMode: spec.MaskMode = renderer.maskMode; - if (maskMode !== spec.MaskMode.NONE) { - renderer.mask = maskRef; + if (maskMode === spec.MaskMode.MASK) { + renderer.mask = ++this.mask; + } else if (maskMode === spec.MaskMode.OBSCURED || maskMode === spec.MaskMode.REVERSE_OBSCURED) { + renderer.mask = this.mask; } } }