     # FIXME: this is only fired for resizing the whole window, not just the panel
     window.addEventListener('resize', @_onResize, false)
 
-  renderShader: (text = null, reload = false) ->
-    if text? and text.length > 0 and !reload
-      @fragShader = @_defaultUniforms() + text
-    else
-      @fragShader = @_fragmentShader() if !reload
-
+  swapMesh: () ->
     material = new THREE.ShaderMaterial({
       uniforms: @uniforms,
       vertexShader: @_vertexShader()
       fragmentShader: @fragShader,
     });
 
-    @mesh2 = new THREE.Mesh(new THREE.PlaneBufferGeometry(2, 2), material)
-
-    @scene.add(@mesh2)
+    tmpMesh = new THREE.Mesh(@geometry, material)
+
+    @scene.add(tmpMesh)
 
     setTimeout =>
-      if(@mesh2.material.program?.diagnostics? and !@mesh2.material.program.diagnostics.runnable)
-        msg = @mesh2.material.program.diagnostics.fragmentShader.log
+      diagnostics = tmpMesh.material.program?.diagnostics
+      if (diagnostics? and !diagnostics.runnable)
+        msg = diagnostics.fragmentShader.log
         @showError(msg, parseLineNumberFromErrorMsg(msg))
+        tmpMesh.material.dispose()
+        @scene.remove(tmpMesh)
       else
         @hideError()
-        @scene.remove(@mesh1)
-        @mesh1 = @mesh2
+        @mesh?.material.dispose()
+        @scene.remove(@mesh)
+        @mesh = tmpMesh
     , 100
 
   _getActiveTab: () ->

    return unless @uniforms[textureId]?

    @uniforms[textureId].value.dispose()

    @uniforms[textureId].value.needsUpdate = true

    @mesh2.material.needsUpdate = true

    delete @uniforms[textureId]

    @renderShader(@fragShader, true)

      'uniform vec2 u_resolution;'
      'uniform vec2 u_mouse;'
      'uniform float u_time;'
    ].join('\n')

  attached: ->
