@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.86 kB
JavaScript
import {EXTMeshFeatures}from'../EXTMeshFeatures/EXTMeshFeatures.js';import {EXTStructuralMetadata}from'../EXTMeshFeatures/EXTStructuralMetadata.js';import {StructuralMetadataPropertyTables}from'../EXTMeshFeatures/StructuralMetadataPropertyTables.js';import {BinaryPropertyTableBuilder}from'../EXTMeshFeatures/BinaryPropertyTableBuilder.js';async function O(r,y,c){const u=r.getRoot(),m=r.createExtension(EXTMeshFeatures),b=r.getRoot().listBuffers()[0],p=[];for(const t of u.listScenes())t.traverse(e=>{const s=e.getMesh();s&&p.push(...s.listPrimitives());});const a=r.createExtension(EXTStructuralMetadata),n={id:"schema_01",name:"Schema 01",description:"An example schema",version:"1.0.0",enums:{},classes:{tree:{name:"Tree",description:"Jo",properties:{id:{name:"ID",type:"STRING"}}}}},f=new Set;for(const t of c)for(const e of Object.keys(t))n.classes.tree.properties[e]={name:e,type:"STRING"},f.add(e);const o={};for(const t of c)for(const e of f.values())o[e]||(o[e]=[]),o[e].push(String(t[e]??"-"));const T=BinaryPropertyTableBuilder.create(n,"tree","Property Table").addProperty("id",y).addProperties(o).build(),i=StructuralMetadataPropertyTables.create(a,T),h=a.createStructuralMetadata().addPropertyTable(i).setSchema(a.createSchemaFrom(n));u.setExtension("EXT_structural_metadata",h);for(const t of p){const e=t,s=e.getAttribute("TEXCOORD_1")?.getArray();if(!s)continue;const S=s,A=r.createAccessor().setType("SCALAR").setBuffer(b).setNormalized(false).setArray(new Int16Array(S)),d=0;e.setAttribute(`_FEATURE_ID_${d}`,A);const g=m.createFeatureId().setFeatureCount(i.getCount()).setPropertyTable(i).setAttribute(d),l=m.createMeshFeatures();l.addFeatureId(g),e.setExtension("EXT_mesh_features",l),e.setAttribute("TEXCOORD_1",null);}}export{O as assignFeatureIds};//# sourceMappingURL=assignFeaturesIds.js.map
//# sourceMappingURL=assignFeaturesIds.js.map