Skip to content

Commit

Permalink
Cache Source instead of Texture instances in material system (#5455)
Browse files Browse the repository at this point in the history
Co-authored-by: Noeri Huisman <[email protected]>
  • Loading branch information
mrxz and mrxz authored Feb 20, 2024
1 parent 001a122 commit fecd166
Show file tree
Hide file tree
Showing 8 changed files with 265 additions and 334 deletions.
9 changes: 9 additions & 0 deletions src/components/material.js
Original file line number Diff line number Diff line change
Expand Up @@ -250,4 +250,13 @@ function parseBlending (blending) {
function disposeMaterial (material, system) {
material.dispose();
system.unregisterMaterial(material);

// Dispose textures on this material
Object.keys(material)
.filter(function (propName) {
return material[propName] && material[propName].isTexture;
})
.forEach(function (mapName) {
material[mapName].dispose();
});
}
3 changes: 0 additions & 3 deletions src/core/shader.js
Original file line number Diff line number Diff line change
Expand Up @@ -135,9 +135,6 @@ Shader.prototype = {
color = new THREE.Color(value);
return new THREE.Vector3(color.r, color.g, color.b);
}
case 'map': {
return THREE.ImageUtils.loadTexture(value);
}
default: {
return value;
}
Expand Down
Loading

0 comments on commit fecd166

Please sign in to comment.