import WBVector3 from './wbVector3';
import WBVectorXZ from './wbVectorXZ';
export class Chunk3Utils {
    constructor(chunkSize) {
        this.chunkSize = chunkSize;
    }
    toChunkSpace(loc) {
        return WBVector3.fromMC(loc).multiply(1 / this.chunkSize);
    }
    fromChunkSpace(chunk) {
        return WBVector3.fromMC(chunk).multiply(this.chunkSize);
    }
    getRelativeCoords(chunk, loc) {
        const chunkOrigin = WBVector3.fromMC(chunk).floorAll();
        return WBVector3.fromMC(loc).subtract(this.fromChunkSpace(chunkOrigin));
    }
    getRandomLocationInChunk(chunk) {
        const chunkOrigin = WBVector3.fromMC(chunk).floorAll();
        return this.fromChunkSpace(chunkOrigin.add({ x: Math.random(), y: Math.random(), z: Math.random() })).floorAll();
    }
    getChunkCenter(chunk) {
        const chunkOrigin = WBVector3.fromMC(chunk).floorAll();
        return this.fromChunkSpace(chunkOrigin.add({ x: 0.5, y: 0.5, z: 0.5 }));
    }
}
export class ChunkXZUtils {
    constructor(chunkSize) {
        this.chunkSize = chunkSize;
    }
    toChunkSpace(loc) {
        return WBVectorXZ.fromMC(loc).multiply(1 / this.chunkSize);
    }
    fromChunkSpace(chunk) {
        return WBVectorXZ.fromMC(chunk).multiply(this.chunkSize);
    }
    getRelativeCoords(chunk, loc) {
        const chunkOrigin = WBVectorXZ.fromMC(chunk).floorAll();
        return WBVectorXZ.fromMC(loc).subtract(this.fromChunkSpace(chunkOrigin));
    }
    getRandomLocationInChunk(chunk) {
        const chunkOrigin = WBVectorXZ.fromMC(chunk).floorAll();
        return this.fromChunkSpace(chunkOrigin.add({ x: Math.random(), z: Math.random() })).floorAll();
    }
    getChunkCenter(chunk) {
        const chunkOrigin = WBVectorXZ.fromMC(chunk).floorAll();
        return this.fromChunkSpace(chunkOrigin.add({ x: 0.5, z: 0.5 }));
    }
}
