imwithye commited on
Commit
e98fc97
·
1 Parent(s): ec43676

filter duplicates

Browse files
src/components/rotator.tsx CHANGED
@@ -12,7 +12,7 @@ export const Rotator = ({ facingDirection }: RotatorProps) => {
12
  const handleClick = (direction: "clockwise" | "counter-clockwise") => {
13
  const cubes = getCubes(facingDirection);
14
  cubes.forEach((cube) => {
15
- console.log(cube.position);
16
  });
17
  console.log(cubes.length, direction);
18
  };
 
12
  const handleClick = (direction: "clockwise" | "counter-clockwise") => {
13
  const cubes = getCubes(facingDirection);
14
  cubes.forEach((cube) => {
15
+ console.log(cube);
16
  });
17
  console.log(cubes.length, direction);
18
  };
src/contexts/cubes-context.tsx CHANGED
@@ -22,7 +22,9 @@ export const CubesProvider = ({ children }: { children: React.ReactNode }) => {
22
  const cubes = useRef<CubeMeshRef[]>([]);
23
 
24
  const addCube = (cubeMeshRef: CubeMeshRef) => {
25
- cubes.current.push(cubeMeshRef);
 
 
26
  };
27
 
28
  const getCubes = (faceDirection: FacingDirection) => {
 
22
  const cubes = useRef<CubeMeshRef[]>([]);
23
 
24
  const addCube = (cubeMeshRef: CubeMeshRef) => {
25
+ if (!cubes.current.includes(cubeMeshRef)) {
26
+ cubes.current.push(cubeMeshRef);
27
+ }
28
  };
29
 
30
  const getCubes = (faceDirection: FacingDirection) => {