Skip to content

Commit

Permalink
z index
Browse files Browse the repository at this point in the history
  • Loading branch information
jerzakm committed Mar 6, 2024
1 parent 564494d commit bd13c41
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,7 @@ export const initBunnies = async (renderer: WebGLRenderer, scene: Scene, count:

const positionX: number[] = new Array(count).fill(0);
const positionY: number[] = new Array(count).fill(0);
const zIndex: number[] = new Array(count).fill(0);

const speedX: number[] = new Array(count).fill(0);
const speedY: number[] = new Array(count).fill(0);
Expand All @@ -97,6 +98,7 @@ export const initBunnies = async (renderer: WebGLRenderer, scene: Scene, count:
for (let i = 0; i < count; i++) {
positionX[i] = 0;
positionY[i] = 0;
zIndex[i] = -Math.random() * 10;

speedX[i] = Math.random() * 10;
speedY[i] = Math.random() * 10 - 5;
Expand Down Expand Up @@ -138,7 +140,7 @@ export const initBunnies = async (renderer: WebGLRenderer, scene: Scene, count:
}

for (let i = 0; i < count; i++) {
updatePosition(i, [positionX[i], positionY[i], 0]);
updatePosition(i, [positionX[i], positionY[i], zIndex[i]]);
}
};
sprite.update();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,7 @@ export const initDemons = async (renderer: WebGLRenderer, scene: Scene, count: n

const positionX: number[] = new Array(count).fill(0);
const positionY: number[] = new Array(count).fill(0);
const zIndex: number[] = new Array(count).fill(0);

const speedX: number[] = new Array(count).fill(0);
const speedY: number[] = new Array(count).fill(0);
Expand All @@ -79,6 +80,7 @@ export const initDemons = async (renderer: WebGLRenderer, scene: Scene, count: n
for (let i = 0; i < count; i++) {
positionX[i] = 0;
positionY[i] = 0;
zIndex[i] = -Math.random() * 10;

speedX[i] = Math.random() * 10;
speedY[i] = Math.random() * 10 - 5;
Expand Down Expand Up @@ -125,7 +127,7 @@ export const initDemons = async (renderer: WebGLRenderer, scene: Scene, count: n
}

for (let i = 0; i < count; i++) {
updatePosition(i, [positionX[i], positionY[i], 0]);
updatePosition(i, [positionX[i], positionY[i], zIndex[i]]);
}
};

Expand Down

0 comments on commit bd13c41

Please sign in to comment.