From 8d011ab8c1e8b1a42068462be38dc1c987aa6a17 Mon Sep 17 00:00:00 2001 From: airnan Date: Thu, 14 Sep 2023 09:25:25 -0400 Subject: [PATCH] Fix for track matte masks pointing to an ind that is not the previous one in older format --- player/js/elements/canvasElements/CVBaseElement.js | 4 +++- player/js/renderers/BaseRenderer.js | 12 ++++++++++++ 2 files changed, 15 insertions(+), 1 deletion(-) diff --git a/player/js/elements/canvasElements/CVBaseElement.js b/player/js/elements/canvasElements/CVBaseElement.js index b93734e63..c2cc859fe 100644 --- a/player/js/elements/canvasElements/CVBaseElement.js +++ b/player/js/elements/canvasElements/CVBaseElement.js @@ -102,7 +102,9 @@ CVBaseElement.prototype = { this.clearCanvas(this.canvasContext); this.canvasContext.setTransform(this.currentTransform); // We draw the mask - const mask = this.comp.getElementById('tp' in this.data ? this.data.tp : this.data.ind - 1); + const mask = ('tp' in this.data) + ? this.comp.getElementById(this.data.tp) + : this.comp.getElementByRelativePos(this, -1); mask.renderFrame(true); // We draw the second buffer (that contains the content of this layer) this.canvasContext.setTransform(1, 0, 0, 1, 0, 0); diff --git a/player/js/renderers/BaseRenderer.js b/player/js/renderers/BaseRenderer.js index 324e8e42c..82e1f5629 100644 --- a/player/js/renderers/BaseRenderer.js +++ b/player/js/renderers/BaseRenderer.js @@ -145,6 +145,18 @@ BaseRenderer.prototype.getElementById = function (ind) { return null; }; +BaseRenderer.prototype.getElementByRelativePos = function (element, relativeIndex) { + var i; + var len = this.elements.length; + for (i = 0; i < len; i += 1) { + if (this.elements[i] === element && this.elements[i + relativeIndex]) { + return this.elements[i + relativeIndex]; + } + } + // Returning element in index 0 to avoid errors + return this.elements[0]; +}; + BaseRenderer.prototype.getElementByPath = function (path) { var pathValue = path.shift(); var element;