From 83184737ea202947b25491985775c346e981db96 Mon Sep 17 00:00:00 2001 From: themancalledjakob Date: Fri, 22 Mar 2024 16:36:45 +0100 Subject: [PATCH] fix bug recording did not work, when there were layers with mapped but not hot values dependencies hashes: openFrameworks d78075f4bca6be2a2533c6e51a75cc1f18404501 ofxMsdfgen e14da13d02c4dff04fb69d7923469f606924e6c3 ofxGPUFont d482bb7cbdf6b296fa4ab5abcf73fb5ff8c8b239 ofxVariableLab 8df98846248a93aa068989a3ebd0d2f0f16e5e69 ofxProfiler a868e34fa1a79189dd4fbdede2938e308535e5e8 theatre 86d3e07f6f2c75fd6e08fca8c97e3617c9e23b18 --- bin/em/variabletime/web/js/audio.js | 33 ++++++++++++++++++++++------ bin/em/variabletime/web/js/record.js | 12 ++++++---- 2 files changed, 34 insertions(+), 11 deletions(-) diff --git a/bin/em/variabletime/web/js/audio.js b/bin/em/variabletime/web/js/audio.js index 8c06cf6..77557e2 100644 --- a/bin/em/variabletime/web/js/audio.js +++ b/bin/em/variabletime/web/js/audio.js @@ -1161,11 +1161,23 @@ const Audio = function(tp, record) { //} } else { const position = tp.sheet.sequence.position; + let values = {}; propsToSet.forEach((p) => { const title = tp .getPanelPropTitle(p.title); const layer = getLayer(p.id); + const newValues = { + [p.title]: p.value + }; + if (!values.hasOwnProperty(p.id)) { + values[p.id] = {}; + } + values[p.id] = { + ...values[p.id], + ...newValues, + }; + if (title !== null) { const inputElement = title .parentNode.parentNode @@ -1176,14 +1188,21 @@ const Audio = function(tp, record) { inputElement.dispatchEvent(new Event('change')); } } - record.addValue(p.id, p.title, p.value, position); - if (p.title.indexOf('color') === 0) { - if (!config.audio.colorSeparateRGBA || p.title === 'color.a') { - record.liveUpdate(layer, position); - } - } else { - record.liveUpdate(layer, position); + if (record.isHot(p.id, p.title)) { + record.addValue(p.id, p.title, p.value, position); } + // NOTE: liveUpdate does not work if the layer is not registered + //if (p.title.indexOf('color') === 0) { + //if (!config.audio.colorSeparateRGBA || p.title === 'color.a') { + //record.liveUpdate(layer, position); + //} + //} else { + //record.liveUpdate(layer, position); + //} + }); + Object.keys(values).forEach((layerID) => { + deFlattenObject(values[layerID]); + record.liveUpdater.immediateUpdate(getLayer(layerID), values[layerID]); }); } } diff --git a/bin/em/variabletime/web/js/record.js b/bin/em/variabletime/web/js/record.js index 8a601a5..e01b01f 100644 --- a/bin/em/variabletime/web/js/record.js +++ b/bin/em/variabletime/web/js/record.js @@ -177,8 +177,10 @@ const Record = function(tp) { }; const isHot = (layerID, propTitle) => { - return hot.hasOwnProperty(layerID) - && hot[layerID].hasOwnProperty(propTitle); + return typeof hot[layerID] === 'object' + && typeof hot[layerID][propTitle] === 'object'; + //return hot.hasOwnProperty(layerID) + //&& hot[layerID].hasOwnProperty(propTitle); }; const addHot = (layerID, propTitle) => { if (!isHot(layerID, propTitle)) { @@ -303,12 +305,13 @@ const Record = function(tp) { // only make these propTitles hot and // register their layer for recording propPaths.forEach((p) => { + if (typeof p === 'string') { + p = p.split('.'); + } if (Array.isArray(p)) { const layerID = p[0]; const propTitle = p.slice(1).join('.'); addHot(layerID, propTitle); - } else if (typeof p === 'string') { - console.error('not implemented yet, so sorry'); } }); } @@ -596,6 +599,7 @@ const Record = function(tp) { this.liveUpdate = liveUpdate; this.liveUpdater = liveUpdater; this.addRecordButton = addRecordButton; + this.isHot = isHot; this.addHot = addHot; this.removeHot = removeHot; this.getHot = () => {