@csi-foxbyte/cityjson-to-3d-tiles
Version:
A Node.js library that converts CityJSON files into Cesium 3D Tiles—complete with automatic texture atlas packing, Basis compression, three LOD levels, and customizable threading.
2 lines • 889 B
JavaScript
import {Vector2}from'three';class o{constructor(t,e){this._sparseCells=new Map;this._size=new Vector2,this._bounds=t,t.getSize(this._size),this._indexWidth=Math.ceil(this._size.x/e),this._indexHeight=Math.ceil(this._size.y/e);}add(t,e,i){const s=this._calculateIndex(t,e);this._sparseCells.has(s)||this._sparseCells.set(s,[]),this._sparseCells.get(s).push({x:t,y:e,data:i});}traverse(t){for(let e=0;e<this._indexHeight;e++)for(let i=0;i<this._indexWidth;i++){const s=this._calculateIndex(i,e);this._sparseCells.has(s)&&t(this._sparseCells.get(s),i,e);}}get cells(){return Array.from(this._sparseCells.values())}_calculateIndex(t,e){const i=Math.floor((t-this._bounds.min.x)/this._size.x*this._indexWidth),s=Math.floor((e-this._bounds.min.y)/this._size.y*this._indexHeight);return i+s*this._indexWidth}}export{o as Grid2D};//# sourceMappingURL=index.js.map
//# sourceMappingURL=index.js.map