Skip to content

Commit 40f0891

Browse files
committed
feat: add methods to traverse properties
1 parent 787ede6 commit 40f0891

File tree

3 files changed

+48
-1
lines changed

3 files changed

+48
-1
lines changed

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "bim-fragment",
3-
"version": "1.3.20",
3+
"version": "1.3.22",
44
"description": "3D BIM Geometry API",
55
"main": "src/index.js",
66
"scripts": {

resources/fragment.js

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7516,6 +7516,28 @@ class FragmentsGroup extends THREE.Group {
75167516
this.items = [];
75177517
this.ifcCivil = undefined;
75187518
}
7519+
setProperties(properties) {
7520+
this._properties = properties;
7521+
}
7522+
getAllIDs() {
7523+
if (this._properties) {
7524+
return Object.keys(this._properties).map((id) => parseInt(id, 10));
7525+
}
7526+
return Array.from(this.streamSettings.ids.keys());
7527+
}
7528+
getAllTypes() {
7529+
if (this._properties) {
7530+
const types = new Set();
7531+
for (const id in this._properties) {
7532+
const property = this._properties[id];
7533+
if (property.type !== undefined) {
7534+
types.add(property.type);
7535+
}
7536+
}
7537+
return Array.from(types);
7538+
}
7539+
return Array.from(this.streamSettings.types.keys());
7540+
}
75197541
getProperties(id) {
75207542
if (!this._properties) {
75217543
throw new Error("Properties not initialized!");

src/fragments-group.ts

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,31 @@ export class FragmentsGroup extends THREE.Group {
7777
this.ifcCivil = undefined;
7878
}
7979

80+
setProperties(properties: IfcProperties) {
81+
this._properties = properties;
82+
}
83+
84+
getAllIDs() {
85+
if (this._properties) {
86+
return Object.keys(this._properties).map((id) => parseInt(id, 10));
87+
}
88+
return Array.from(this.streamSettings.ids.keys());
89+
}
90+
91+
getAllTypes() {
92+
if (this._properties) {
93+
const types = new Set<number>();
94+
for (const id in this._properties) {
95+
const property = this._properties[id];
96+
if (property.type !== undefined) {
97+
types.add(property.type);
98+
}
99+
}
100+
return Array.from(types);
101+
}
102+
return Array.from(this.streamSettings.types.keys());
103+
}
104+
80105
getProperties(id: number): IfcProperties | null {
81106
if (!this._properties) {
82107
throw new Error("Properties not initialized!");

0 commit comments

Comments
 (0)