Skip to content

Commit

Permalink
No need to update materials when scene fog changes
Browse files Browse the repository at this point in the history
  • Loading branch information
mrxz committed Dec 19, 2023
1 parent 5b90b60 commit 20e19d0
Show file tree
Hide file tree
Showing 3 changed files with 0 additions and 17 deletions.
2 changes: 0 additions & 2 deletions src/components/scene/fog.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,6 @@ module.exports.Component = register('fog', {
// (Re)create fog if fog doesn't exist or fog type changed.
if (!fog || data.type !== fog.name) {
el.object3D.fog = getFog(data);
el.systems.material.updateMaterials();
return;
}

Expand All @@ -51,7 +50,6 @@ module.exports.Component = register('fog', {
if (!fog) { return; }

el.object3D.fog = null;
el.systems.material.updateMaterials();
}
});

Expand Down
10 changes: 0 additions & 10 deletions src/systems/material.js
Original file line number Diff line number Diff line change
Expand Up @@ -222,16 +222,6 @@ module.exports.System = registerSystem('material', {
});
},

/**
* Trigger update to all registered materials.
*/
updateMaterials: function (material) {
var materials = this.materials;
Object.keys(materials).forEach(function (uuid) {
materials[uuid].needsUpdate = true;
});
},

/**
* Track textures used by material components, so that they can be safely
* disposed when no longer in use. Textures must be registered here, and not
Expand Down
5 changes: 0 additions & 5 deletions tests/components/scene/fog.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ suite('fog', function () {
var self = this;

el.addEventListener('loaded', function () {
self.updateMaterialsSpy = self.sinon.spy(el.systems.material, 'updateMaterials');
// Stub scene load to avoid WebGL code.
el.hasLoaded = true;
el.setAttribute('fog', '');
Expand All @@ -28,10 +27,6 @@ suite('fog', function () {
assert.ok(this.el.object3D.fog);
});

test('triggers material update when adding fog', function () {
assert.ok(this.updateMaterialsSpy.called);
});

test('updates fog', function () {
var el = this.el;
el.setAttribute('fog', 'color: #F0F');
Expand Down

0 comments on commit 20e19d0

Please sign in to comment.