Skip to content

Commit

Permalink
Set .background null when removing background component (#5417)
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 Dec 19, 2023
1 parent fe0c971 commit fce5b6a
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 9 deletions.
8 changes: 1 addition & 7 deletions src/components/scene/background.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
/* global THREE */
var register = require('../../core/component').registerComponent;
var COMPONENTS = require('../../core/component').components;

module.exports.Component = register('background', {
schema: {
Expand All @@ -19,12 +18,7 @@ module.exports.Component = register('background', {
},

remove: function () {
var data = this.data;
var object3D = this.el.object3D;
if (data.transparent) {
object3D.background = null;
return;
}
object3D.background = COMPONENTS[this.name].schema.color.default;
object3D.background = null;
}
});
4 changes: 2 additions & 2 deletions tests/components/scene/background.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,11 @@ suite('background', function () {
assert.shallowDeepEqual(sceneEl.object3D.background, {r: 1, g: 1, b: 0});
});

test('change the background color', function () {
test('remove the background', function () {
var sceneEl = this.sceneEl;
assert.shallowDeepEqual(sceneEl.object3D.background, null);
sceneEl.setAttribute('background', {color: 'yellow'});
sceneEl.removeAttribute('background');
assert.equal(sceneEl.object3D.background, 'black');
assert.equal(sceneEl.object3D.background, null);
});
});

0 comments on commit fce5b6a

Please sign in to comment.