fix duplicate comps on parser
diff --git a/build/parser/bodymovin_parser.jsx b/build/parser/bodymovin_parser.jsx
index a5ac8d7..9fa9c46 100644
--- a/build/parser/bodymovin_parser.jsx
+++ b/build/parser/bodymovin_parser.jsx
@@ -956,6 +956,7 @@
callback.apply();*/
// END TO TRAVERSE LAYER BY LAYER. NEEDED FOR TIME REMAP?
totalLayers = pendingLayers.length;
+ UI.setState('processing');
extrasInstance.setTimeout(analyzeNextLayer,100);
}
@@ -1678,7 +1679,6 @@
case PropertyValueType.ThreeD_SPATIAL:
case PropertyValueType.TwoD_SPATIAL:
bezierIn.x = 1 - key.easeIn.influence / 100;
- $.writeln('bezierIn.x: ',bezierIn.x);
bezierOut.x = lastKey.easeOut.influence / 100;
averageSpeed = getCurveLength(lastKey.value,key.value, lastKey.to, key.ti)/duration;
break;
@@ -1997,6 +1997,7 @@
/****** END rqManager ******/
/****** INIT LayerConverter ******/
(function(){
+ var compsIndexes;
var pendingComps = [];
var convertedSources = [];
var duplicatedSources = [];
@@ -2005,14 +2006,16 @@
var currentCompositionNum = 0;
var totalLayers;
var tempConverterComp;
- var currentComposition;
+ var currentCompositionData;
var currentSource;
var currentLayerInfo;
var duplicateMainComp;
+ var positions;
var callback;
function convertComposition(comp){
helperFolder = helperFootage.item(2);
AssetsManager.reset();
+ UI.setState('duplicating',comp.name);
duplicateMainComp = comp.duplicate();
//duplicateMainComp.openInViewer() ;
duplicateMainComp.parentFolder = helperFolder;
@@ -2021,28 +2024,43 @@
pendingComps = [];
convertedSources = [];
duplicatedSources = [];
- pendingComps.push(duplicateMainComp);
+ compsIndexes = [];
+ positions = [];
+ pendingComps.push({comp:duplicateMainComp,items:compsIndexes});
if(pendingComps.length == 1){
extrasInstance.setTimeout(iterateNextComposition,100);
}
};
+ function changeSourceToLayers(comp,indexes){
+ var i, len = indexes.length;
+ for(i=0;i<len;i+=1){
+ var layerInfo = comp.layers[indexes[i].index];
+ layerInfo.replaceSource(indexes[i].src,false);
+ if(indexes[i].items.length>0){
+ changeSourceToLayers(layerInfo.source,indexes[i].items);
+ }
+ }
+ }
+
function iterateNextComposition(){
if(currentCompositionNum == pendingComps.length){
//TODO dar acceso externo a main comp
//TODO despachar evento de fin
+ UI.setState('sourcing');
+ changeSourceToLayers(duplicateMainComp,compsIndexes);
callback.apply(null,[duplicateMainComp]);
return;
}
- currentComposition = pendingComps[currentCompositionNum];
+ currentCompositionData = pendingComps[currentCompositionNum];
currentLayerNum = 0;
- totalLayers = currentComposition.layers.length;
+ totalLayers = currentCompositionData.comp.layers.length;
extrasInstance.setTimeout(verifyNextItem,100);
}
function verifyNextItem(){
if(currentLayerNum<totalLayers){
- var layerInfo = currentComposition.layers[currentLayerNum+1];
+ var layerInfo = currentCompositionData.comp.layers[currentLayerNum+1];
var lType = extrasInstance.layerType(layerInfo);
if(lType == 'StillLayer' && layerInfo.enabled){
currentSource = layerInfo.source;
@@ -2061,10 +2079,11 @@
}
}else{
if(lType=='PreCompLayer'){
- var copy = searchCompositionDuplicate(layerInfo);
- layerInfo.replaceSource(copy, false);
- pendingComps.push(copy);
- copy.parentFolder = helperFolder;
+ var src = searchCompositionDuplicate(layerInfo);
+ //layerInfo.replaceSource(copy, false);
+ var indexes = [];
+ currentCompositionData.items.push({index:currentLayerNum+1,src:src,items:indexes});
+ pendingComps.push({comp:layerInfo.source,items:indexes});
}
currentLayerNum++;
extrasInstance.setTimeout(verifyNextItem,100);
@@ -2083,7 +2102,10 @@
}
i++;
}
+ UI.setState('duplicating',layerInfo.source.name);
var copy = layerInfo.source.duplicate();
+ copy.parentFolder = helperFolder;
+ copy.parentFolder = helperFolder;
//copy.openInViewer() ;
duplicatedSources.push({s:layerInfo.source,c:copy});
return copy;
@@ -2118,7 +2140,7 @@
}
function replaceCurrentLayerSource(source){
- var layerInfo = currentComposition.layers[currentLayerNum+1];
+ var layerInfo = currentCompositionData.comp.layers[currentLayerNum+1];
layerInfo.replaceSource(source, false);
}
@@ -2402,7 +2424,6 @@
extrasInstance.convertToBezierValues(prop.property('Opacity'), frameRate, ob,'o');
extrasInstance.convertToBezierValues(prop.property('Stroke Width'), frameRate, ob,'w');
var j, jLen = prop.property('Dashes').numProperties;
- extrasInstance.iterateProperty(prop.property('Dashes').property(1));
var dashesData = [];
var changed = false;
for(j=0;j<jLen;j+=1){
@@ -2586,7 +2607,7 @@
}
function start(){
- UI.setExportText('Starting export');
+ UI.setState('start');
LayerConverter.convertComposition(mainComp);
}
@@ -2666,8 +2687,8 @@
compsColumns : {name:'Name',queue:'In Queue',destination:'Destination Path'},
imagesButtons : {refresh:'Refresh', exportTxt:'Export', notExportTxt:'Do not export'},
imagesColumns : {name:'Name',exportTxt:'Export'},
- renderTexts : {cancel:'Cancel Render'}
- }
+ renderTexts : {cancel:'Cancel Render',start:'Starting export',duplicating:'Duplicating Comp: ',processing:'Processing layers',sourcing:'Changing sources'}
+ };
var availableCompositions = [];
var bodyMovinPanel;
var settingsGroup;
@@ -2764,9 +2785,9 @@
/**** RENDER GROUP ****/
var renderGroupRes = "group{orientation:'column',alignment:['fill','fill'],alignChildren:['fill',fill'],\
- componentText:StaticText{text:'Rendering Composition ',alignment:['left','top']},\
+ componentText:StaticText{text:'Rendering Composition ',alignment:['fill','top']},\
infoText:StaticText{text:'Exporting images ',alignment:['left','top']},\
- progress:Progressbar{value:50,alignment:['fill','top']},\
+ progress:Progressbar{value:0,alignment:['fill','top']},\
cancelButton: Button{text:'"+UITextsData.renderTexts.cancel+"',alignment:['center','top']},\
}";
bodyMovinPanel.mainGroup.renderGroup = bodyMovinPanel.mainGroup.add(renderGroupRes);
@@ -3112,6 +3133,27 @@
bodyMovinPanel.mainGroup.renderGroup.infoText.text = text;
}
+ function setState(state,compName){
+ switch(state){
+ case 'start':
+ bodyMovinPanel.mainGroup.renderGroup.componentText.text = UITextsData.renderTexts.start;
+ setProgress(1);
+ break;
+ case 'duplicating':
+ bodyMovinPanel.mainGroup.renderGroup.componentText.text = UITextsData.renderTexts.duplicating + compName;
+ break;
+ case 'processing':
+ bodyMovinPanel.mainGroup.renderGroup.componentText.text = UITextsData.renderTexts.processing;
+ break;
+ case 'sourcing':
+ bodyMovinPanel.mainGroup.renderGroup.componentText.text = UITextsData.renderTexts.sourcing;
+ break;
+ default:
+ bodyMovinPanel.mainGroup.renderGroup.componentText.text = 'default: '+state;
+ break;
+ }
+ }
+
myScript_buildUI(bodymovinWindow);
if (bodyMovinPanel != null && bodyMovinPanel instanceof Window){
bodyMovinPanel.center();
@@ -3121,6 +3163,7 @@
var ob ={};
ob.setExportText = setExportText;
ob.setProgress = setProgress;
+ ob.setState = setState;
UI = ob;
diff --git a/parser/CompConverter.js b/parser/CompConverter.js
index 98dca68..c8f72b5 100644
--- a/parser/CompConverter.js
+++ b/parser/CompConverter.js
@@ -105,7 +105,7 @@
}
}
//If it gets here there are no more compositions to render and callback is executed
- //helperFootage.remove();
+ helperFootage.remove();
endCallback.apply();
}
diff --git a/parser/LayerConverter.js b/parser/LayerConverter.js
index a3119ab..c3a160c 100644
--- a/parser/LayerConverter.js
+++ b/parser/LayerConverter.js
@@ -1,5 +1,6 @@
/****** INIT LayerConverter ******/
(function(){
+ var compsIndexes;
var pendingComps = [];
var convertedSources = [];
var duplicatedSources = [];
@@ -8,10 +9,11 @@
var currentCompositionNum = 0;
var totalLayers;
var tempConverterComp;
- var currentComposition;
+ var currentCompositionData;
var currentSource;
var currentLayerInfo;
var duplicateMainComp;
+ var positions;
var callback;
function convertComposition(comp){
helperFolder = helperFootage.item(2);
@@ -25,17 +27,22 @@
pendingComps = [];
convertedSources = [];
duplicatedSources = [];
- pendingComps.push(duplicateMainComp);
+ compsIndexes = [];
+ positions = [];
+ pendingComps.push({comp:duplicateMainComp,items:compsIndexes});
if(pendingComps.length == 1){
extrasInstance.setTimeout(iterateNextComposition,100);
}
};
- function changeSourceToLayers(){
- var i, len = duplicatedSources.length;
+ function changeSourceToLayers(comp,indexes){
+ var i, len = indexes.length;
for(i=0;i<len;i+=1){
- duplicatedSources[i].l.replaceSource(duplicatedSources[i].c,false);
- //layerInfo.replaceSource(copy, false);
+ var layerInfo = comp.layers[indexes[i].index];
+ layerInfo.replaceSource(indexes[i].src,false);
+ if(indexes[i].items.length>0){
+ changeSourceToLayers(layerInfo.source,indexes[i].items);
+ }
}
}
@@ -43,19 +50,20 @@
if(currentCompositionNum == pendingComps.length){
//TODO dar acceso externo a main comp
//TODO despachar evento de fin
- changeSourceToLayers();
+ UI.setState('sourcing');
+ changeSourceToLayers(duplicateMainComp,compsIndexes);
callback.apply(null,[duplicateMainComp]);
return;
}
- currentComposition = pendingComps[currentCompositionNum];
+ currentCompositionData = pendingComps[currentCompositionNum];
currentLayerNum = 0;
- totalLayers = currentComposition.layers.length;
+ totalLayers = currentCompositionData.comp.layers.length;
extrasInstance.setTimeout(verifyNextItem,100);
}
function verifyNextItem(){
if(currentLayerNum<totalLayers){
- var layerInfo = currentComposition.layers[currentLayerNum+1];
+ var layerInfo = currentCompositionData.comp.layers[currentLayerNum+1];
var lType = extrasInstance.layerType(layerInfo);
if(lType == 'StillLayer' && layerInfo.enabled){
currentSource = layerInfo.source;
@@ -74,9 +82,11 @@
}
}else{
if(lType=='PreCompLayer'){
- searchCompositionDuplicate(layerInfo);
+ var src = searchCompositionDuplicate(layerInfo);
//layerInfo.replaceSource(copy, false);
- pendingComps.push(layerInfo.source);
+ var indexes = [];
+ currentCompositionData.items.push({index:currentLayerNum+1,src:src,items:indexes});
+ pendingComps.push({comp:layerInfo.source,items:indexes});
}
currentLayerNum++;
extrasInstance.setTimeout(verifyNextItem,100);
@@ -89,29 +99,19 @@
function searchCompositionDuplicate(layerInfo){
var i=0,len = duplicatedSources.length;
- $.writeln('--- new ---');
while(i<len){
- //$.writeln('duplicatedSources[i].s.source: ',duplicatedSources[i].s);
- //$.writeln('layerInfo.source: ',layerInfo.source);
- //$.writeln('layerInfo.source.name: ',layerInfo.source.name);
- /*$.writeln('duplicatedSources[i].s.source.name: ',duplicatedSources[i].s.name);
- $.writeln('layerInfo.source: ',layerInfo.source);
- $.writeln('layerInfo.source.name: ',layerInfo.source.name);*/
if(duplicatedSources[i].s == layerInfo.source){
- $.writeln('is found');
- duplicatedSources.push({c:duplicatedSources[i].c,l:layerInfo});
- return;
+ return duplicatedSources[i].c;
}
i++;
}
- $.writeln('not found');
UI.setState('duplicating',layerInfo.source.name);
var copy = layerInfo.source.duplicate();
copy.parentFolder = helperFolder;
copy.parentFolder = helperFolder;
//copy.openInViewer() ;
- duplicatedSources.push({s:layerInfo.source,c:copy,l:layerInfo});
- return;
+ duplicatedSources.push({s:layerInfo.source,c:copy});
+ return copy;
}
function searchConvertedSource(source){
@@ -143,7 +143,7 @@
}
function replaceCurrentLayerSource(source){
- var layerInfo = currentComposition.layers[currentLayerNum+1];
+ var layerInfo = currentCompositionData.comp.layers[currentLayerNum+1];
layerInfo.replaceSource(source, false);
}
diff --git a/parser/ShapesParser.js b/parser/ShapesParser.js
index b8f2bd7..9be185a 100644
--- a/parser/ShapesParser.js
+++ b/parser/ShapesParser.js
@@ -253,7 +253,6 @@
extrasInstance.convertToBezierValues(prop.property('Opacity'), frameRate, ob,'o');
extrasInstance.convertToBezierValues(prop.property('Stroke Width'), frameRate, ob,'w');
var j, jLen = prop.property('Dashes').numProperties;
- extrasInstance.iterateProperty(prop.property('Dashes').property(1));
var dashesData = [];
var changed = false;
for(j=0;j<jLen;j+=1){
diff --git a/parser/UI.js b/parser/UI.js
index 92eae11..4ac290a 100644
--- a/parser/UI.js
+++ b/parser/UI.js
@@ -10,7 +10,7 @@
compsColumns : {name:'Name',queue:'In Queue',destination:'Destination Path'},
imagesButtons : {refresh:'Refresh', exportTxt:'Export', notExportTxt:'Do not export'},
imagesColumns : {name:'Name',exportTxt:'Export'},
- renderTexts : {cancel:'Cancel Render',start:'Starting export',duplicating:'Duplicating Comp: ',processing:'Processing layers'}
+ renderTexts : {cancel:'Cancel Render',start:'Starting export',duplicating:'Duplicating Comp: ',processing:'Processing layers',sourcing:'Changing sources'}
};
var availableCompositions = [];
var bodyMovinPanel;
@@ -468,6 +468,9 @@
case 'processing':
bodyMovinPanel.mainGroup.renderGroup.componentText.text = UITextsData.renderTexts.processing;
break;
+ case 'sourcing':
+ bodyMovinPanel.mainGroup.renderGroup.componentText.text = UITextsData.renderTexts.sourcing;
+ break;
default:
bodyMovinPanel.mainGroup.renderGroup.componentText.text = 'default: '+state;
break;
diff --git a/player/index.html b/player/index.html
index 004c0ba..166bae6 100644
--- a/player/index.html
+++ b/player/index.html
@@ -36,6 +36,6 @@
<!-- endbuild -->
</head>
<body style="background-color:#666; margin: 0px;height: 100%; font-family: sans-serif;font-size: 10px">
-<div style="width:100%;height:100%;background-color:#000;display:inline-block" class="bodymovin" data-bm-path="exports/multicomp" data-bm-type="canvas" data-bm-loop="true" data-bm-prerender="true"></div>
+<div style="width:100%;height:100%;background-color:#000;display:inline-block" class="bodymovin" data-bm-path="exports/letters/full" data-bm-type="canvas" data-bm-loop="true" data-bm-prerender="true"></div>
</body>
</html>