 class AnimatedMesh extends Wage.Mesh
     constructor: (geometry, @materials, options={}) ->
         @animations = {}
-        @weightSchedule = []
-        @warpSchedule = []
-
+        @fadeStack = []
+        @warpStack = []
+        # get skinning material
         originalMaterial = materials[0]
         originalMaterial.skinning = true
-
+        # default visibility
         @meshVisible = true
-
+        # init
         super geometry, originalMaterial, options
 
     create: ->

        return

    update: (dt) ->
        @animate(dt)
        @updateWarps(dt)
        return

    animate: (dt) ->
        return

    updateWarps: (dt) ->
        return

    play: (animation) ->

        return

    crossfade: (fromAnimation, toAnimation, duration) ->
        anim1 = @animations[fromAnimation]
        anim2 = @animations[toAnimation]
        anim1.play 0, 1
        anim2.play 0, 0
        @fadeStack.push
            anim: anim1
            startWeight: 1
            endWeight: 0
            timeElapsed: 0
            duration: duration

        @fadeStack.push
            anim: anim2
            startWeight: 0
            endWeight: 1
            timeElapsed: 0
            duration: duration
        return

    warp: (fromAnimation, toAnimation, duration) ->
        anim1 = @animations[fromAnimation]
        anim2 = @animations[toAnimation]
        anim1.play 0, 1
        anim2.play 0, 0
        @warpStack.push
            from: anim1
            to: anim2
            timeElapsed: 0
            duration: duration
        return

    applyWeight: (animation, w) ->
        @animations[animation].weight = weight

    pauseAll: ->
        for animName, animation of @animations
            if animation.isPlaying
                animation.stop()
        return

    unpauseAll: ->
        for animName, animation of @animations
            if animation.isPlaying and animation.isPaused
                animation.pause()
        return

    stopAll: ->
        for animName, animation of @animations
            if animation.isPlaying
                animation.stop 0
            animation.weight = 0
        @fadeStack.length = 0
        @warpStack.length = 0
        return

    getForward: ->
