Skip to content

Commit

Permalink
Cache Source instead of Texture instances in material system
Browse files Browse the repository at this point in the history
  • Loading branch information
mrxz committed Feb 10, 2024
1 parent 18b25a0 commit 6744582
Show file tree
Hide file tree
Showing 8 changed files with 266 additions and 336 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 6744582

Please sign in to comment.