Pen Settings

HTML

CSS

CSS Base

Vendor Prefixing

Add External Stylesheets/Pens

Any URLs added here will be added as <link>s in order, and before the CSS in the editor. You can use the CSS from another Pen by using its URL and the proper URL extension.

+ add another resource

JavaScript

Babel includes JSX processing.

Add External Scripts/Pens

Any URL's added here will be added as <script>s in order, and run before the JavaScript in the editor. You can use the URL of any other Pen and it will include the JavaScript from that Pen.

+ add another resource

Packages

Add Packages

Search for and use JavaScript packages from npm here. By selecting a package, an import statement will be added to the top of the JavaScript editor for this package.

Behavior

Save Automatically?

If active, Pens will autosave every 30 seconds after being saved once.

Auto-Updating Preview

If enabled, the preview panel updates automatically as you code. If disabled, use the "Run" button to update.

Format on Save

If enabled, your code will be formatted when you actively save your Pen. Note: your code becomes un-folded during formatting.

Editor Settings

Code Indentation

Want to change your Syntax Highlighting theme, Fonts and more?

Visit your global Editor Settings.

HTML

              
                <details close id="animate-container">
    <summary>Properties</summary>
    <ul>
        <li><button type="button" id="start" onclick="startAnimation()">start</button></li>
        <li><button type="button" id="pause" onclick="cpauseAnimation()">Pause</button></li>
        <li><button type="button" id="resume" onclick="resumeAnimation()">Resume</button></li>
        <hr>
        <div id="time">Progress:</div>
        <div class="progress white">
            <div id="progress" class="red progress"> </div>
        </div>
        </div>
    </ul>
</details>

<div class="alpha" id="a">a</div>
<div  class="alpha" id="b">b</div>
<div  class="alpha" id="c">c</div>
<div  class="alpha" id="d">d</div>
<div  class="alpha" id="e">e</div>
<div  class="alpha" id="f">f</div>
<div  class="alpha" id="g">g</div>
<div  class="alpha" id="i">i</div>
<div  class="alpha" id="j">j</div>
<div  class="alpha" id="l">l</div>
<div  class="alpha" id="m">m</div>
<div  class="alpha" id="n">n</div>
<div  class="alpha" id="p">p</div>

              
            
!

CSS

              
                
        details {

           background: rgb(131, 184, 241);
           color: black;
           width: 200px;
           border-radius: 4px;
           margin-bottom: 5px;
           margin-top: 20px;
           position: absolute;
           padding-top: 10px;
           z-index: 1;
        }

        details ul {
           -family: monospace;
           background: #ddd;
           margin: 0;
           color: black;
           padding-left: 10px;
           padding-top: 2px;
           border-radius: 0 0 0 0;
        }

        details li {
           margin-top: 5px;
        } 

        #myProgress {
           width: 100%;
           background-color: #ddd;
        }

        #myBar {
           width: 1%;
           height: 20px;
           background-color: #93ace4;
           text-align: center;
           color: black;
        }
        .progress{
           width:150px;
           height:10px;
        }
        #time{
            padding: 5px;
        }

        .red{
           position: relative;
	       background: #555;
	       -moz-border-radius: 25px;
	       -webkit-border-radius: 25px;
	       border-radius: 25px;	
	       box-shadow: inset 0 -1px 1px rgba(255,255,255,0.3); 
        }

        .white{
           background-color:white;
          .alpha{
            margin:200px;
            padding:200px;
          }
              
            
!

JS

              
                
tweenArr=[];
 
//This is a onclick function which gets triggered on a button click which is responsible to animated each node to some coordinates defined
 function startAnimation(){
        findTheChildrens();
 
   
        var animationData = [
            { x: -15 },
            { x: 10 },
            { x: -10 },
            { x: 15 },
            { z: 15 },
            { z: 15 },
            { z: 15 },
            { z: 15 },
            { x: 25 },
            { x: 25 },
            { x: -20 },
            { x: -20 },
            { x: -20 },
            { x: -20 },
            { y: -20 },
            { y: -20 },
            { x: 15 },
            { x: -15 },
            { z: 0 },
            { z: 5 },
            { z: 10 }

        ];

        this.tweenArr.forEach((node, i) => {
            
            var settings = Object.assign({
                duration: 5,
                ease: "none",
                onUpdate: showProgress.bind(this),
                onComplete: chainTween.bind(this)
            }, animationData[i]);
            this.tweening = gsap.timeline();
            this.tweening.to(node.position, settings)
        });
   
     this.tweening.from(".red", this.tweening.duration(), { scaleX: 0, transformOrigin: "0px 0px", ease: Linear.easeNone }, 0);
        var progress = document.getElementsByClassName("red");
        var duration = document.getElementById("time");
        function showProgress() {
            this.progress = new TweenLite.set(progress, { scaleX: this.tweening.progress(), transformOrigin: "0px 0px" });
            duration.innerHTML = "Progress:" + parseInt(this.tweening.time() * 10) + "%";
        }
        function chainTween() {
//change my animationData array coordinates to something else
            var animationData = [
                { x: -100 },
                { x: 100 },
                { x: -100 },
                { x: 15 },
                { z: 15 },
                { z: 15 },
                { z: 15 },
                { z: 15 },
                { x: 25 },
                { x: 25 },
                { x: -20 },
                { x: -20 },
                { x: -20 },
                { x: -20 },
                { y: -20 },
                { y: -20 },
                { x: 15 },
                { x: -15 },
                { z: 0 },
                { z: 5 },
                { z: 10 }
    
            ];
            this.tweenArr.forEach((node, i) => {
                var settings = Object.assign({ 
                    duration: 5,
                    ease: "none",
                    onUpdate: showProgress.bind(this),
                }, animationData[i]);
                this.tweening.to(node.position, settings)
            });
        }
    }
 
        }
    
//This functions gets called only one time which is responsible to  tranverse the assembly and keep all found childrens into a global array (tweenArr) 
      ffunction findtheChildrens(){   
         findTheChildrens = function(){};
           var node = scene.children[2].children[0];
            for (var i = 0; i < node.children.length; i++) {
                var childNode = node.children[i];
                if (childNode.children.length > 0) {
                    if (childNode.children[0].type == "Group" ||
                        childNode.children[0].type == "Mesh") {
                        this.tweenArr.push(childNode);
        
         
                 
                    } 
                }
            }
        }
              
            
!
999px

Console