UNPKG

@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 • 1.11 kB
import {Logger}from'@gltf-transform/core';import {parentPort}from'worker_threads';import {buildGeometry}from'./buildGeometry.js';import {createDatabase}from'../database/index.js';Logger.DEFAULT_INSTANCE=new Logger(Logger.Verbosity.SILENT);const d="+proj=geocent +datum=WGS84 +units=m +no_defs +type=crs";if(!parentPort)throw new Error("Is not being called in a worker context!");let r,i="",o=null;parentPort.on("message",async t=>{try{switch(t.type){case "init":r=JSON.parse(t.data.cityJsonRaw),i=t.data.src,o=await createDatabase(t.data.dbFile),parentPort?.postMessage(null);break;case "work":{try{if(!o)throw new Error("DB Instance not initialized!");const e=await buildGeometry({geometry:r.CityObjects[t.data.id].geometry,vertices:r.vertices,id:t.data.id,cityJson:r,src:i,dest:t.data.dest??d,folderPath:t.data.folderPath,appearance:t.data.appearance,noTransform:!1,dbInstance:o});parentPort.postMessage(e);break}catch(e){console.error(e);}break}case "terminate":await o?.close(),parentPort.postMessage(null);}}catch(e){console.error(e);}});//# sourceMappingURL=worker.js.map //# sourceMappingURL=worker.js.map