Browse Source

adding a disposal check

rickfromwork 4 years ago
parent
commit
cbce658c54
1 changed files with 6 additions and 1 deletions
  1. 6 1
      gui/src/3D/controls/touchButton3D.ts

+ 6 - 1
gui/src/3D/controls/touchButton3D.ts

@@ -120,7 +120,12 @@ export class TouchButton3D extends Button3D {
                 }
 
                 // Debug line mesh
-                debugLineMesh.dispose();
+                if (debugLineMesh)
+                {
+                    // remove the previous line before drawing the new one
+                    debugLineMesh.dispose();
+                }
+                
                 debugLineMesh = Mesh.CreateLines("debug_line", [
                     _this._collisionMesh.getAbsolutePosition(),
                     indexMesh.getAbsolutePosition()