Skip to content

Commit

Permalink
image change
Browse files Browse the repository at this point in the history
  • Loading branch information
rohittp0 committed Mar 12, 2024
1 parent 00f43bd commit 5ea49e5
Show file tree
Hide file tree
Showing 7 changed files with 4 additions and 7 deletions.
Binary file added public/img/hero/cubes/0.webp
Binary file not shown.
Binary file added public/img/hero/cubes/1.webp
Binary file not shown.
Binary file added public/img/hero/cubes/2.webp
Binary file not shown.
File renamed without changes.
Binary file removed public/img/hero/cubes/ada.webp
Binary file not shown.
2 changes: 1 addition & 1 deletion src/sections/hero.ts
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ function createTextFromCubes(letter, offsetX: number, offsetY: number, offsetZ:
const Y = posY + Math.random() * cubeSize * 10;
const Z = offsetZ + Math.random() * cubeSize * 10;

const {url, name} = letter.images.pop();
const url = letter.images.pop();

const cube = createCube(X, Y, Z, cubeSize, url, letter.text);
cube.rotation.y = pattern[y][x] === '0' ? Math.PI / 2 - 0.15 : 0.15;
Expand Down
9 changes: 3 additions & 6 deletions src/utils/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,20 +16,17 @@ const LETTERS = {
],
};

const IMAGES = [
{url: 'img/cubes/ada.webp', name: 'Ada Lovelace'},
{url: 'img/cubes/susan.webp', name: 'Susan Wojcicki'},
]

const text = ["W", "M", "C"];

const num_images = 4;

export const LETTER_MAP = ["W", "M", "C"].map((letter, index) => {
const pattern = LETTERS[letter];
const count = pattern.reduce((acc: number, row: string) => acc + row.split('').filter(cell => cell !== ' ').length, 0);

const images = [];
for (let i = 0; i < count; i++) {
images.push(IMAGES[IMAGES.length * Math.random() | 0]);
images.push(`/img/hero/cubes/${Math.floor(num_images * Math.random())}.webp`);
}

return {
Expand Down

0 comments on commit 5ea49e5

Please sign in to comment.