Skip to main content
Participating Frequently
October 19, 2024
Question

control RigParent rotation to drive child with jsfl

  • October 19, 2024
  • 1 reply
  • 248 views
 

I have a problem. In the doc stage, I can control the rotation properties of the parent to drive the rotation of the child. This way I can copy the actions of one template to other models. But when I use jsfl to control the rotation properties of the parent layer of the template, the child will not move with it. How to solve this problem?

 

 

    This topic has been closed for replies.

    1 reply

    Participating Frequently
    October 19, 2024
    function test2(){
    
        // an.getDocumentDOM().getTimeline().currentLayer=2;
        var library = an.getDocumentDOM().library;
        var sourceModel = library.items[library.findItemIndex("sourceModel")];
        var timeline = sourceModel.timeline;
    
        //整个对象数组,保存 帧, 名字, 对象的属性(旋转,缩放,等等)   帧,还是图层?  一个帧一个动作, 帧级别吧
        var propertyArr = [];
        var layers = timeline.layers;
        var keyFrames = getKeyFrames(layers[0]);
    
        keyFrames.forEach(function (num){
            if (num==0){
                return
            }
            var eleDataArr=[];
            for (var i = 0; i < layers.length; i++) {
                var layerName = layers[i].name;
    
                var rotation = layers[i].frames[num].elements[0].rotation;
                var eleData = {layerName:layerName,rotation:Math.floor(rotation)};
                // fl.trace("fram   " +num+ "   mydata.layerName   " + layerName+ "   " + rotation);
                eleDataArr.push(eleData);
            }
            propertyArr.push({keyNum:num,data:eleDataArr});
        })
    
        var copySymblo = library.items[library.findItemIndex("sourceModel 复制")];
        library.editItem(copySymblo.name);
    
        var doc = an.getDocumentDOM();
        var timeline1 = an.getDocumentDOM().getTimeline();
    
        keyFrames.forEach(function (num){
            if (num==0){
                return
            }
            for (var i = 0; i < timeline1.layers.length; i++) {
                timeline1.setSelectedLayers(i);
                timeline1.setSelectedFrames(num,num+1);
                timeline1.convertToKeyframes();
            }
        })
    
    
        keyFrames.sort(function (a,b){
            return a-b;
        });
    
        keyFrames.forEach(function (num){
            if (num==0){
                return
            }
            for (var i = 0; i < timeline1.layers.length; i++) {
    
                timeline1.setSelectedLayers(i);
                timeline1.setSelectedFrames(num,num+1);
                propertyArr.forEach(function (property){
                    if (property.keyNum===num){
                        property.data.forEach(function (mydata){
    
                            // if (timeline1.layers[i].name.indexOf("大")<0){
                            //     fl.trace("   you ==========" +timeline1.layers[i].name );
                            //     return;
                            // }
                            if (mydata.layerName===timeline1.layers[i].name){
                                if (mydata.rotation===null || mydata.rotation==0  || isNaN(mydata.rotation)){
                                    return;
                                }
                                fl.trace("mydata.layerName   " + mydata.layerName+ "   " + parseFloat(mydata.rotation));
                                // doc.selection[0].rotation=parseFloat(mydata.rotation);
                                an.getDocumentDOM().rotateSelection(mydata.rotation);
                            }
                        })
                    }
                })
            }
        })
    
    
    }
    Participating Frequently
    October 19, 2024

    Save save child