import { MolangVariableMap } from '@minecraft/server';
import WBVector3 from '../util/wbVector3';
export default function createCircleBorderEffect(location, radius, numSegments) {
    if (radius <= 0.0)
        console.warn(`createCircleBorderEffect: Expected radius>0.0, got ${radius}`);
    if (Math.floor(numSegments) !== numSegments)
        console.error('createCircleBorderEffect: numSegments is not a decimal');
    if (numSegments <= 0)
        console.error(`createCircleBorderEffect expected numSegments>0, got ${numSegments}`);
    const segmentWidth = (2 * Math.PI * radius) / numSegments;
    const rotationDelta = 360 / numSegments;
    const molangMap = new MolangVariableMap();
    const baseOffset = new WBVector3(0, 0, radius);
    molangMap.setFloat('width', segmentWidth);
    for (let i = 0; i < numSegments; i++) {
        const offset = baseOffset.rotateY(i * rotationDelta);
        const topmostBlock = location.dimension.getTopmostBlock(offset.add(location));
        if (topmostBlock) {
            offset.y = topmostBlock.y - location.y + 1;
        }
        molangMap.setVector3('offset', offset);
        location.dimension.spawnParticle('twb_wisu:border_segment', location, molangMap);
    }
}
