diff --git a/__tests__/integration/mask.spec.ts b/__tests__/integration/mask.spec.ts index 8561e92d51..5fc9456cf5 100644 --- a/__tests__/integration/mask.spec.ts +++ b/__tests__/integration/mask.spec.ts @@ -4,6 +4,10 @@ const TEST_CASES = [ { name: 'single', }, + { + name: 'multi', + sleepTime: 2500, + }, ]; describe('Mask Snapshot', () => { diff --git a/__tests__/integration/snapshots/Mask_multi.png b/__tests__/integration/snapshots/Mask_multi.png new file mode 100644 index 0000000000..25d32428c0 Binary files /dev/null and b/__tests__/integration/snapshots/Mask_multi.png differ diff --git a/__tests__/integration/snapshots/Point_billboard.png b/__tests__/integration/snapshots/Point_billboard.png index 06113268e1..89cf9f30d0 100644 Binary files a/__tests__/integration/snapshots/Point_billboard.png and b/__tests__/integration/snapshots/Point_billboard.png differ diff --git a/__tests__/integration/snapshots/Point_fill_image.png b/__tests__/integration/snapshots/Point_fill_image.png index 58aadff76f..4ee836e689 100644 Binary files a/__tests__/integration/snapshots/Point_fill_image.png and b/__tests__/integration/snapshots/Point_fill_image.png differ diff --git a/__tests__/integration/snapshots/Point_text.png b/__tests__/integration/snapshots/Point_text.png index ef40ffe2bb..b4c065eb07 100644 Binary files a/__tests__/integration/snapshots/Point_text.png and b/__tests__/integration/snapshots/Point_text.png differ diff --git a/examples/demos/mask/multi.ts b/examples/demos/mask/multi.ts index c4e1bf7ed8..4d0c748728 100644 --- a/examples/demos/mask/multi.ts +++ b/examples/demos/mask/multi.ts @@ -72,18 +72,6 @@ export function MapRender(options: RenderDemoOptions) { ) ).json(); - // 影像地图图层 - const baseLayer = new RasterLayer({ zIndex: -1 }).source( - 'https://www.google.com/maps/vt?lyrs=s@189&gl=cn&x={x}&y={y}&z={z}', - { - parser: { - type: 'rasterTile', - tileSize: 256, - zoomOffset: 0, - }, - }, - ); - const polygonLayer = new PolygonLayer({ visible: true, name: 'china', @@ -131,8 +119,6 @@ export function MapRender(options: RenderDemoOptions) { leftLayer.addMask(maskLayer); - scene.addLayer(baseLayer); - scene.addLayer(leftLayer); scene.addLayer(polygonLayer); scene.addLayer(maskLayer); diff --git a/packages/renderer/src/device/DeviceModel.ts b/packages/renderer/src/device/DeviceModel.ts index fdffa42099..37751e3e4f 100644 --- a/packages/renderer/src/device/DeviceModel.ts +++ b/packages/renderer/src/device/DeviceModel.ts @@ -43,7 +43,7 @@ import { stencilFuncMap, stencilOpMap, } from './constants'; -const { isPlainObject, isTypedArray } = lodashUtil; +const { isPlainObject, isTypedArray, isNil } = lodashUtil; export default class DeviceModel implements IModel { private destroyed: boolean = false; @@ -156,7 +156,7 @@ export default class DeviceModel implements IModel { const stencilParams = this.getStencilDrawParams({ stencil }); const stencilEnabled = !!(stencilParams && stencilParams.enable); - return this.device.createRenderPipeline({ + const pipeline = this.device.createRenderPipeline({ // return this.service.renderCache.createRenderPipeline({ inputLayout: this.inputLayout, program: this.program, @@ -219,6 +219,14 @@ export default class DeviceModel implements IModel { }, }, }); + + // Save stencil reference on pipeline for later use. + if (stencilEnabled && !isNil(stencil?.func?.ref)) { + // @ts-ignore + pipeline.stencilFuncReference = stencil.func.ref; + } + + return pipeline; } updateAttributesAndElements() {} @@ -285,7 +293,11 @@ export default class DeviceModel implements IModel { device['swapChainHeight'] = tmpHeight; renderPass.setPipeline(this.pipeline); - renderPass.setStencilReference(1); + // @ts-ignore + if (!isNil(this.pipeline.stencilFuncReference)) { + // @ts-ignore + renderPass.setStencilReference(this.pipeline.stencilFuncReference); + } renderPass.setVertexInput( this.inputLayout, this.vertexBuffers.map((buffer) => ({