Skip to content

Commit

Permalink
Move filter param
Browse files Browse the repository at this point in the history
  • Loading branch information
adroitwhiz committed Mar 8, 2023
1 parent b76a34a commit b811d8a
Showing 1 changed file with 5 additions and 9 deletions.
14 changes: 5 additions & 9 deletions src/Renderer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -286,13 +286,11 @@ export default class Renderer {
// Handles rendering of all layers (including stage, pen layer, sprites, and all clones) in proper order.
private _renderLayers(
layers?: Set<Sprite | Stage | PenSkin>,
optionsIn: {
filter?: (layer: Sprite | Stage | PenSkin) => boolean;
} & Partial<RenderSpriteOptions> = {}
optionsIn: Partial<RenderSpriteOptions> = {},
filter?: (layer: Sprite | Stage | PenSkin) => boolean
): void {
const options = {
drawMode: ShaderManager.DrawModes.DEFAULT,
renderSpeechBubbles: true,
...optionsIn,
};

Expand All @@ -303,7 +301,7 @@ export default class Renderer {
const shouldIncludeLayer = (layer: Sprite | Stage | PenSkin): boolean =>
!(
(shouldRestrictLayers && !layers.has(layer)) ||
(options.filter && !options.filter(layer))
(filter && !filter(layer))
);

// Stage
Expand Down Expand Up @@ -516,7 +514,7 @@ export default class Renderer {

if (
options.renderSpeechBubbles &&
'_speechBubble' in sprite &&
"_speechBubble" in sprite &&
sprite._speechBubble &&
sprite._speechBubble.text !== "" &&
sprite instanceof Sprite
Expand Down Expand Up @@ -703,9 +701,7 @@ export default class Renderer {
this._stencilSprite(spr, sprColor);

// Render the sprites to check that we're touching, which will now be masked in to the area of the first sprite.
this._renderLayers(undefined, {
filter: (layer) => layer !== spr,
});
this._renderLayers(undefined, undefined, (layer) => layer !== spr);

// Make sure to disable the stencil test so as not to affect other rendering!
gl.disable(gl.STENCIL_TEST);
Expand Down

0 comments on commit b811d8a

Please sign in to comment.