Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Set .background null when removing background component
  • Loading branch information
mrxz committed Dec 19, 2023
commit 754b8ada8e7c692da0fdd58f71f857a530f48991
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);
});
});