Skip to content

Commit

Permalink
fix(avatar): add missing leading 0 to avatar text color
Browse files Browse the repository at this point in the history
  • Loading branch information
mwfarb committed Aug 25, 2022
1 parent 3dfdd16 commit 2eec88e
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/components/arena-camera.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ AFRAME.registerComponent('arena-camera', {
enabled: {type: 'boolean', default: false},
vioEnabled: {type: 'boolean', default: false},
displayName: {type: 'string', default: 'No Name'},
color: {type: 'string', default: '#' + Math.floor(Math.random() * 16777215).toString(16)},
color: {type: 'string', default: '#' + ARENAUtils.numToPaddedHex(Math.floor(Math.random() * 16777215), 6)},
rotation: {type: 'vec4', default: new THREE.Quaternion()},
position: {type: 'vec3', default: new THREE.Vector3()},
vioRotation: {type: 'vec4', default: new THREE.Quaternion()},
Expand Down
5 changes: 5 additions & 0 deletions src/utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -249,4 +249,9 @@ export class ARENAUtils {
static isLandscapeMode() {
return (window.orientation == 90 || window.orientation == -90);
}

static numToPaddedHex(num, len) {
const str = num.toString(16);
return "0".repeat(len - str.length) + str;
}
}

0 comments on commit 2eec88e

Please sign in to comment.