Skip to content

Commit 19b2e84

Browse files
committed
alternate tiles so that we rotate around rough center of mass
1 parent eeb9221 commit 19b2e84

File tree

1 file changed

+7
-1
lines changed
  • src/components/crystal-toolkit/scene

1 file changed

+7
-1
lines changed

src/components/crystal-toolkit/scene/Scene.ts

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -522,6 +522,10 @@ export default class Scene {
522522
return tiles;
523523
};
524524

525+
const _alternateTiles = (x: number) => {
526+
return (-1) ** (x + 1) * Math.trunc((x + 1) / 2);
527+
};
528+
525529
const emptyLattice = [
526530
[0, 0, 0],
527531
[0, 0, 0],
@@ -547,7 +551,9 @@ export default class Scene {
547551
this.arrayOfTileRoots[x][y][z].push(tileRootObject);
548552

549553
let tileOffsets: number[][] = lattice.map((vector: number[], index: number) => {
550-
return vector.map((x: number) => x * tile[index]);
554+
return vector.map((x: number) => {
555+
return x * _alternateTiles(tile[index]);
556+
});
551557
});
552558
traverseScene(sceneJson, tileRootObject, tileOffsets, '');
553559
}

0 commit comments

Comments
 (0)