Skip to content

Commit

Permalink
Merge pull request #4666 from mozilla/feature/theme-avatar-preview
Browse files Browse the repository at this point in the history
change avatar preview background to background theme color
  • Loading branch information
matthewbcool authored Sep 27, 2021
2 parents 4f0b5dc + 67bd0b6 commit 9d6967d
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion src/react-components/avatar-preview.js
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,14 @@ function fitBoxInFrustum(camera, box, center, margin = DEFAULT_MARGIN) {
camera.lookAt(center);
}

function getThemeBackground() {
const currentTheme = APP?.store?.state?.preferences?.theme;
const themes = window.APP_CONFIG?.theme?.themes;
const currentThemeObject = themes?.find(t => t.id === currentTheme);
const previewBackgroundColor = new THREE.Color(currentThemeObject?.variables["background3-color"] || 0xeaeaea);
return previewBackgroundColor;
}

class AvatarPreview extends Component {
static propTypes = {
avatarGltfUrl: PropTypes.string,
Expand Down Expand Up @@ -112,7 +120,7 @@ class AvatarPreview extends Component {
this.snapshotRenderer.setClearAlpha(0);

this.previewRenderer = createRenderer(this.canvas);
this.previewRenderer.setClearColor(0xeaeaea);
this.previewRenderer.setClearColor(getThemeBackground());
this.previewRenderer.setAnimationLoop(() => {
const dt = clock.getDelta();
this.mixer && this.mixer.update(dt);
Expand Down

0 comments on commit 9d6967d

Please sign in to comment.