Skip to content

Commit b19b22a

Browse files
committed
Decouple property fetching
1 parent f7a8f80 commit b19b22a

File tree

3 files changed

+21
-20
lines changed

3 files changed

+21
-20
lines changed

viewer/src/components/raycaster.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,6 @@ export class IFCRaycaster {
1818
castRay(event: any, onHit: (event: any, item: THREE.Intersection) => any ) {
1919
this.raycaster.setFromCamera(this.mouse, this.camera);
2020
const result = this.raycaster.intersectObjects(this.ifcModels);
21-
if(result.length > 0) onHit(event, result[0]);
21+
if(result.length > 0) return onHit(event, result[0]);
2222
}
2323
}

viewer/src/core/IFC/ifc-manager.ts

Lines changed: 17 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -54,11 +54,26 @@ export class IfcManager {
5454
}
5555
}
5656

57+
getSpatialStructure(modelID: number, recursive = false) {
58+
return this.loader.getSpatialStructure(modelID, recursive);
59+
}
60+
61+
getProperties(modelID: number, id: number, indirect = false) {
62+
const props = this.loader.getItemProperties(modelID, id);
63+
if(indirect){
64+
props.psets = this.loader.getPropertySets(modelID, id, true);
65+
props.type = this.loader.getTypeProperties(modelID, id);
66+
}
67+
console.log(props);
68+
return props;
69+
}
70+
5771
preselect(event: any) {
58-
this.caster.castRay(event, this.preselection.select);
72+
const { modelID, id } = this.caster.castRay(event, this.preselection.select);
5973
}
6074

6175
select(event: any) {
62-
this.caster.castRay(event, this.selection.selectProps);
76+
const { modelID, id } = this.caster.castRay(event, this.selection.select);
77+
return this.getProperties(modelID, id, true);
6378
}
6479
}

viewer/src/core/IFC/selection.ts

Lines changed: 3 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -26,22 +26,8 @@ export class IfcSelection {
2626
this.removePreviousSelection(mesh);
2727
this.modelID = mesh.modelID;
2828
this.newSelection(id);
29-
return id;
30-
}
31-
32-
selectProps = (event: any, item: THREE.Intersection) => {
33-
const id = this.select(event, item);
34-
if(id) return this.getProperties(id);
35-
return null;
36-
}
37-
38-
getProperties(id: number){
39-
const props = this.ifcLoader.getItemProperties(this.modelID, id);
40-
props.psets = this.ifcLoader.getPropertySets(this.modelID, id, true);
41-
props.type = this.ifcLoader.getTypeProperties(this.modelID, id);
42-
console.log(props);
43-
return props;
44-
}
29+
return { modelID: this.modelID, id };
30+
};
4531

4632
newSelection = (id: number) => {
4733
this.ifcLoader.createSubset({
@@ -51,7 +37,7 @@ export class IfcSelection {
5137
removePrevious: true,
5238
material: this.material
5339
});
54-
}
40+
};
5541

5642
removePreviousSelection(mesh: IfcMesh) {
5743
if (this.modelID != undefined && this.modelID != mesh.modelID) {

0 commit comments

Comments
 (0)