Skip to content

Commit

Permalink
guard against undefined values and use THREE.color to allow for more …
Browse files Browse the repository at this point in the history
…values
  • Loading branch information
matthewbcool committed Sep 27, 2021
1 parent dd07c3c commit 67bd0b6
Showing 1 changed file with 5 additions and 17 deletions.
22 changes: 5 additions & 17 deletions src/react-components/avatar-preview.js
Original file line number Diff line number Diff line change
Expand Up @@ -64,23 +64,11 @@ function fitBoxInFrustum(camera, box, center, margin = DEFAULT_MARGIN) {
}

function getThemeBackground() {
const currentTheme = APP.store.state.preferences.theme;
const themes = window.APP_CONFIG?.theme.themes;
const defaultColor = 0xeaeaea;
if (currentTheme === "hubs-default") {
return defaultColor;
}
for (let i = 0; i < themes.length; i++) {
if (themes[i].id === currentTheme) {
let bgHex = themes[i].variables["background3-color"];
bgHex = `0x${bgHex.substring(1)}`;
if (bgHex.length !== 8) {
return defaultColor;
}
bgHex = parseInt(bgHex, 16);
return bgHex;
}
}
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 {
Expand Down

0 comments on commit 67bd0b6

Please sign in to comment.