Skip to content

Commit

Permalink
feat(front): improve ifc streamer setvisibiility logic
Browse files Browse the repository at this point in the history
  • Loading branch information
agviegas committed Oct 22, 2024
1 parent 59916b4 commit 25ee0aa
Show file tree
Hide file tree
Showing 4 changed files with 30 additions and 15 deletions.
4 changes: 2 additions & 2 deletions packages/core/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@
"access": "public"
},
"devDependencies": {
"@thatopen/fragments": ">=2.4.0-alpha.1",
"@thatopen/fragments": ">=2.4.0-alpha.4",
"@thatopen/ui": "~2.3.0",
"@types/three": "0.160.0",
"stats.js": "^0.17.0",
Expand All @@ -51,7 +51,7 @@
"three-mesh-bvh": "0.7.0"
},
"peerDependencies": {
"@thatopen/fragments": ">=2.4.0-alpha.1",
"@thatopen/fragments": ">=2.4.0-alpha.4",
"three": "^0.160.1",
"web-ifc": "0.0.59"
}
Expand Down
6 changes: 3 additions & 3 deletions packages/front/package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "@thatopen/components-front",
"description": "Collection of frontend tools to author BIM apps.",
"version": "2.4.0-alpha.5",
"version": "2.4.0-alpha.6",
"author": "That Open Company",
"contributors": [
"Antonio Gonzalez Viegas (https://github.com/agviegas)",
Expand Down Expand Up @@ -33,12 +33,12 @@
"publish-alpha": "npm publish --tag alpha"
},
"peerDependencies": {
"@thatopen/fragments": ">=2.4.0-alpha.1",
"@thatopen/fragments": ">=2.4.0-alpha.4",
"three": "^0.160.1",
"web-ifc": "0.0.59"
},
"devDependencies": {
"@thatopen/fragments": ">=2.4.0-alpha.1",
"@thatopen/fragments": ">=2.4.0-alpha.4",
"@thatopen/ui": "~2.3.0",
"@thatopen/ui-obc": "~2.3.0",
"@types/earcut": "^2.1.4",
Expand Down
19 changes: 17 additions & 2 deletions packages/front/src/fragments/IfcStreamer/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -344,9 +344,23 @@ export class IfcStreamer extends OBC.Component implements OBC.Disposable {
* @param visible - The visibility state to set.
* @param filter - A map of fragment IDs to arrays of item IDs.
* Only items with IDs present in the arrays will be visible.
* If not provided, it will take all loaded models as filter.
*/
setVisibility(visible: boolean, filter: FRAG.FragmentIdMap) {
setVisibility(visible: boolean, filter?: FRAG.FragmentIdMap) {
const modelGeomsAssets = new Map<string, Map<number, Set<number>>>();

if (!filter) {
const fragments = this.components.get(OBC.FragmentsManager);
const allFragmentMaps: FRAG.FragmentIdMap = {};
for (const [, group] of fragments.groups) {
const map = group.getFragmentMap();
for (const id in map) {
allFragmentMaps[id] = map[id];
}
}
filter = allFragmentMaps;
}

for (const fragID in filter) {
const found = this.fragIDData.get(fragID);
if (found === undefined) {
Expand Down Expand Up @@ -379,6 +393,7 @@ export class IfcStreamer extends OBC.Component implements OBC.Disposable {
assetGroup.add(asset);
}
}

for (const [modelID, geometriesAssets] of modelGeomsAssets) {
// Set visibility of stream culler
this.culler.setVisibility(visible, modelID, geometriesAssets);
Expand Down Expand Up @@ -451,7 +466,7 @@ export class IfcStreamer extends OBC.Component implements OBC.Disposable {
}

/**
* Gets a FragmentsGroup with the OBB of the specified items. Keep in mind that you will need to dispose this group yourself using the dispoe() method.
* Gets a FragmentsGroup with the OBB of the specified items. Keep in mind that you will need to dispose this group yourself using the dispose(false) method (geometry is shared with bounding boxes used for visibility check).
*
* @param items - The items whose bounding boxes to get.
*/
Expand Down
16 changes: 8 additions & 8 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -690,7 +690,7 @@ __metadata:
resolution: "@thatopen/components-front@workspace:packages/front"
dependencies:
"@thatopen/components": ">=2.4.0-alpha.3"
"@thatopen/fragments": ">=2.4.0-alpha.1"
"@thatopen/fragments": ">=2.4.0-alpha.4"
"@thatopen/ui": ~2.3.0
"@thatopen/ui-obc": ~2.3.0
"@types/earcut": ^2.1.4
Expand All @@ -703,7 +703,7 @@ __metadata:
three: ^0.160.1
web-ifc: 0.0.59
peerDependencies:
"@thatopen/fragments": ">=2.4.0-alpha.1"
"@thatopen/fragments": ">=2.4.0-alpha.4"
three: ^0.160.1
web-ifc: 0.0.59
languageName: unknown
Expand All @@ -713,7 +713,7 @@ __metadata:
version: 0.0.0-use.local
resolution: "@thatopen/components@workspace:packages/core"
dependencies:
"@thatopen/fragments": ">=2.4.0-alpha.1"
"@thatopen/fragments": ">=2.4.0-alpha.4"
"@thatopen/ui": ~2.3.0
"@types/three": 0.160.0
camera-controls: 2.7.3
Expand All @@ -724,21 +724,21 @@ __metadata:
three-mesh-bvh: 0.7.0
web-ifc: 0.0.59
peerDependencies:
"@thatopen/fragments": ">=2.4.0-alpha.1"
"@thatopen/fragments": ">=2.4.0-alpha.4"
three: ^0.160.1
web-ifc: 0.0.59
languageName: unknown
linkType: soft

"@thatopen/fragments@npm:>=2.4.0-alpha.1":
version: 2.4.0-alpha.1
resolution: "@thatopen/fragments@npm:2.4.0-alpha.1"
"@thatopen/fragments@npm:>=2.4.0-alpha.4":
version: 2.4.0-alpha.4
resolution: "@thatopen/fragments@npm:2.4.0-alpha.4"
dependencies:
flatbuffers: 23.3.3
three-mesh-bvh: 0.7.0
peerDependencies:
three: ^0.160.1
checksum: 0fb221065ef0fcc850cb55b5cbcb5b4902f2217cf9ba9ce281e149694bdf252e8cac29b7721eaeb4bcd8b1006092f673155f26338717127bef70a22df872227c
checksum: 04e81b3e63c4ce72dc4ced943d810c732a4ecd280abf60f0a6190b38dea34331bfd9a32e0e04e934901d71ba02b5f63351ad216cd52ef16c7fd2bc6fe27b26c9
languageName: node
linkType: hard

Expand Down

0 comments on commit 25ee0aa

Please sign in to comment.