ThatOpen / web-ifc-three

The official IFC Loader for Three.js.
https://ifcjs.github.io/info/
MIT License
506 stars 132 forks source link

Update to latest Web-IFC #153

Closed beachtom closed 1 year ago

beachtom commented 1 year ago

This PR updates to the latest web-ifc.

Please note this needs through testing I am not necessarily familiar with all aspects of web-ifc-three. Someone can use this as a start point to update to latest web-ifc

jespa007 commented 1 year ago

Hi @beachtom , I've tested the modified files in this PR and the models load ok but, during the tests I found issues that I've localized and fixed... If you want to commit the modifications in the same PR it should be great.


The changes are the following,

In IFC/Components/TypeManager.ts at export class TypeManager function getAllTypesOfModel

Make this modification,

Change,

async getAllTypesOfModel(modelID: number, worker?: IFCWorkerHandler) {
    //...        
        const elements = Object.keys(IfcElements).map((e) => parseInt(e));
    //...
}

By,

async getAllTypesOfModel(modelID: number, worker?: IFCWorkerHandler) {
    //...
        const elements =  await this.state.api.GetIfcEntityList(modelID);
    // ...
}

In IFC/web-worker/BaseDefinitions.ts at export interface WebIfcWorkerAPI extends BaseWorkerAPI,

Add the following IfcWorkerEventHandler,

export interface WebIfcWorkerAPI extends BaseWorkerAPI {

     // ...

    [WorkerActions.GetNameFromTypeCode]: IfcWorkerEventHandler;
    [WorkerActions.GetIfcEntityList]: IfcWorkerEventHandler;
    [WorkerActions.GetTypeCodeFromName]: IfcWorkerEventHandler;
}

In IFC/web-worker/workers/WebIfcWorker.ts at export class WebIfcWorker implements WebIfcWorkerAPI,

Add the following functions,

export class WebIfcWorker implements WebIfcWorkerAPI{

    //...

    GetNameFromTypeCode(data: IfcEventData) {
        data.result=this.webIFC.GetNameFromTypeCode(data.args.modelID);
        this.worker.post(data);
    }

    GetIfcEntityList(data: IfcEventData) {
        data.result=this.webIFC.GetIfcEntityList(data.args.modelID);
        this.worker.post(data);
    }

    GetTypeCodeFromName(data: IfcEventData) {
        data.result=this.webIFC.GetTypeCodeFromName(data.args.modelID,data.args.typeName);
        this.worker.post(data);
    }
}
beachtom commented 1 year ago

OK great - done!