* Dispose of material from memory and unsubscribe material from scene updates like fog.
(material, system)
| 251 | * Dispose of material from memory and unsubscribe material from scene updates like fog. |
| 252 | */ |
| 253 | function disposeMaterial (material, system) { |
| 254 | material.dispose(); |
| 255 | system.unregisterMaterial(material); |
| 256 | |
| 257 | // Dispose textures on this material |
| 258 | Object.keys(material) |
| 259 | .filter(function (propName) { |
| 260 | return material[propName] && material[propName].isTexture; |
| 261 | }) |
| 262 | .forEach(function (mapName) { |
| 263 | material[mapName].dispose(); |
| 264 | }); |
| 265 | } |