Skip to content

Commit fecd166

Browse files
authored
Cache Source instead of Texture instances in material system (#5455)
Co-authored-by: Noeri Huisman <mrxz@users.noreply.github.com>
1 parent 001a122 commit fecd166

File tree

8 files changed

+265
-334
lines changed

8 files changed

+265
-334
lines changed

src/components/material.js

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -250,4 +250,13 @@ function parseBlending (blending) {
250250
function disposeMaterial (material, system) {
251251
material.dispose();
252252
system.unregisterMaterial(material);
253+
254+
// Dispose textures on this material
255+
Object.keys(material)
256+
.filter(function (propName) {
257+
return material[propName] && material[propName].isTexture;
258+
})
259+
.forEach(function (mapName) {
260+
material[mapName].dispose();
261+
});
253262
}

src/core/shader.js

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -135,9 +135,6 @@ Shader.prototype = {
135135
color = new THREE.Color(value);
136136
return new THREE.Vector3(color.r, color.g, color.b);
137137
}
138-
case 'map': {
139-
return THREE.ImageUtils.loadTexture(value);
140-
}
141138
default: {
142139
return value;
143140
}

0 commit comments

Comments
 (0)