Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

change avatar preview background to background theme color #4666

Merged
merged 4 commits into from
Sep 27, 2021
Merged
Changes from 3 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
22 changes: 21 additions & 1 deletion src/react-components/avatar-preview.js
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,26 @@ function fitBoxInFrustum(camera, box, center, margin = DEFAULT_MARGIN) {
camera.lookAt(center);
}

function getThemeBackground() {
const currentTheme = APP.store.state.preferences.theme;
matthewbcool marked this conversation as resolved.
Show resolved Hide resolved
const themes = window.APP_CONFIG?.theme.themes;
matthewbcool marked this conversation as resolved.
Show resolved Hide resolved
const defaultColor = 0xeaeaea;
if (currentTheme === "hubs-default") {
matthewbcool marked this conversation as resolved.
Show resolved Hide resolved
return defaultColor;
}
matthewbcool marked this conversation as resolved.
Show resolved Hide resolved
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) {
matthewbcool marked this conversation as resolved.
Show resolved Hide resolved
return defaultColor;
}
bgHex = parseInt(bgHex, 16);
return bgHex;
}
}
matthewbcool marked this conversation as resolved.
Show resolved Hide resolved
}

class AvatarPreview extends Component {
static propTypes = {
avatarGltfUrl: PropTypes.string,
Expand Down Expand Up @@ -112,7 +132,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