| 120 | } |
| 121 | |
| 122 | export async function loadIfc(file: File): Promise<IfcModel> { |
| 123 | try { |
| 124 | IFCModels.isLoading = true; |
| 125 | |
| 126 | const arrayBuffer = await file.arrayBuffer(); |
| 127 | const uint8Array = new Uint8Array(arrayBuffer); |
| 128 | |
| 129 | // Load IFC model |
| 130 | const ifcId = await wasm.loadIfc(Array.from(uint8Array)) as string; |
| 131 | |
| 132 | // Add to models list |
| 133 | const model: IfcModel = { |
| 134 | id: ifcId, |
| 135 | fileName: file.name, |
| 136 | fileSize: file.size, |
| 137 | loadedAt: new Date() |
| 138 | }; |
| 139 | IFCModels.models = [...IFCModels.models, model]; |
| 140 | |
| 141 | console.log(`IFC model "${file.name}" loaded with ID: ${ifcId}`); |
| 142 | return model; |
| 143 | } catch (error) { |
| 144 | console.error('Failed to load IFC model:', error); |
| 145 | throw error; |
| 146 | } finally { |
| 147 | IFCModels.isLoading = false; |
| 148 | } |
| 149 | } |
| 150 | |
| 151 | export async function unloadIfc(modelId: string) { |
| 152 | try { |