Created
          August 10, 2015 19:49 
        
      - 
      
 - 
        
Save rclai/13635dbf5ecc05502c85 to your computer and use it in GitHub Desktop.  
    Recursive function that cleans up Three.js rendering
  
        
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
  | function doDispose (obj) { | |
| if (obj !== null) { | |
| for (var i = 0; i < obj.children.length; i++) { | |
| doDispose(obj.children[i]); | |
| } | |
| if (obj.geometry) { | |
| obj.geometry.dispose(); | |
| obj.geometry = undefined; | |
| } | |
| if (obj.material) { | |
| if (obj.material.materials) { | |
| for (i = 0; i < obj.material.materials.length; i++) { | |
| obj.material.materials[i].dispose(); | |
| } | |
| } | |
| else { | |
| obj.material.dispose(); | |
| } | |
| obj.material = undefined; | |
| } | |
| if (obj.texture) { | |
| obj.texture.dispose(); | |
| obj.texture = undefined; | |
| } | |
| } | |
| obj = undefined; | |
| } | |
| doDispose(sceneObject); | 
  
    Sign up for free
    to join this conversation on GitHub.
    Already have an account?
    Sign in to comment