Skip to content

Commit

Permalink
chunk
Browse files Browse the repository at this point in the history
  • Loading branch information
ponderingdemocritus committed Dec 12, 2024
1 parent fb4d8ab commit 83d691d
Showing 1 changed file with 18 additions and 23 deletions.
41 changes: 18 additions & 23 deletions client/src/three/scenes/Worldmap.ts
Original file line number Diff line number Diff line change
Expand Up @@ -584,12 +584,7 @@ export default class WorldmapScene extends HexagonScene {
const globalRow = startRow + row;
const globalCol = startCol + col;

const hashedTile = torii.poseidonHash([
(startCol + col + FELT_CENTER).toString(),
(startRow + row + FELT_CENTER).toString(),
]);

hashedTiles.push(hashedTile);

hexPositions.push(new THREE.Vector3(dummy.position.x, dummy.position.y, dummy.position.z));
const pos = getWorldPositionForHex({ row: globalRow, col: globalCol });
Expand Down Expand Up @@ -660,56 +655,56 @@ export default class WorldmapScene extends HexagonScene {
}

private async computeTileEntities() {
const cameraPosition = new THREE.Vector3();
cameraPosition.copy(this.controls.target);

const adjustedX = cameraPosition.x + (this.chunkSize * HEX_SIZE * Math.sqrt(3)) / 2;
const adjustedZ = cameraPosition.z + (this.chunkSize * HEX_SIZE * 1.5) / 3;

// Parse current chunk coordinates
const [chunkRow, chunkCol] = this.currentChunk.split(",").map(Number);
const { chunkX, chunkZ } = this.worldToChunkCoordinates(adjustedX, adjustedZ);

const startCol = chunkX * this.chunkSize + FELT_CENTER;
const startRow = chunkZ * this.chunkSize + FELT_CENTER;

console.log(chunkRow, chunkCol)

const sub = await getEntities(this.dojo.network.toriiClient, {
Composite: {
operator: "And",
clauses: [
{
Composite: {
operator: "And",
operator: "Or",
clauses: [
{
Member: {
model: "s0-eternum-Tile",
model: "s0_eternum-Tile",
member: "col",
operator: "Gte",
value: { Primitive: { U32: chunkCol - 10 } },
value: { Primitive: { U32: startCol - 10 } },
},
},
{
Member: {
model: "s0-eternum-Tile",
model: "s0_eternum-Tile",
member: "col",
operator: "Lte",
value: { Primitive: { U32: chunkCol + 10 } },
value: { Primitive: { U32: startCol + 10 } },
},
},
{
Member: {
model: "s0-eternum-Tile",
model: "s0_eternum-Tile",
member: "row",
operator: "Gte",
value: { Primitive: { U32: chunkRow - 10 } },
value: { Primitive: { U32: startRow - 10 } },
},
},
{
Member: {
model: "s0-eternum-Tile",
model: "s0_eternum-Tile",
member: "row",
operator: "Lte",
value: { Primitive: { U32: chunkRow + 10 } },
value: { Primitive: { U32: startRow + 10 } },
},
},
],
},
},
],
},
}, this.dojo.network.contractComponents as any, 1000, false);

Expand Down

0 comments on commit 83d691d

Please sign in to comment.