Skip to content

Commit

Permalink
Merge pull request #60 from galacean/fix/mask
Browse files Browse the repository at this point in the history
fix: 多层蒙版穿透问题
  • Loading branch information
yiiqii authored Dec 21, 2023
2 parents aac25d8 + 7194301 commit 582ff8e
Showing 1 changed file with 10 additions and 14 deletions.
24 changes: 10 additions & 14 deletions packages/effects-core/src/composition-source-manager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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<string, any> = {};
Expand All @@ -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)) {
Expand Down Expand Up @@ -192,7 +183,7 @@ export class CompositionSourceManager implements Disposable {

ref.items.forEach((item: Record<string, any>) => {
item.listIndex = listOrder++;
this.processMask(item.content, maskRef);
this.processMask(item.content);
});
option.items = ref.items;

Expand Down Expand Up @@ -239,12 +230,17 @@ export class CompositionSourceManager implements Disposable {
/**
* 处理蒙版和遮挡关系写入 stencil 的 ref 值
*/
private processMask (renderer: Record<string, number>, maskRef: number) {
private processMask (renderer: Record<string, number>) {
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;
}
}
}
Expand Down

0 comments on commit 582ff8e

Please sign in to comment.