From 25ee0aa398cf91543aca20211ababf897f841b5c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Antonio=20Gonz=C3=A1lez=20Viegas?= Date: Tue, 22 Oct 2024 11:12:14 +0200 Subject: [PATCH] feat(front): improve ifc streamer setvisibiility logic --- packages/core/package.json | 4 ++-- packages/front/package.json | 6 +++--- .../front/src/fragments/IfcStreamer/index.ts | 19 +++++++++++++++++-- yarn.lock | 16 ++++++++-------- 4 files changed, 30 insertions(+), 15 deletions(-) diff --git a/packages/core/package.json b/packages/core/package.json index c365e578b..e828fbfb4 100644 --- a/packages/core/package.json +++ b/packages/core/package.json @@ -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", @@ -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" } diff --git a/packages/front/package.json b/packages/front/package.json index c229a0452..2cfcf177d 100644 --- a/packages/front/package.json +++ b/packages/front/package.json @@ -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)", @@ -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", diff --git a/packages/front/src/fragments/IfcStreamer/index.ts b/packages/front/src/fragments/IfcStreamer/index.ts index 6a16cf3f2..7a95f0482 100644 --- a/packages/front/src/fragments/IfcStreamer/index.ts +++ b/packages/front/src/fragments/IfcStreamer/index.ts @@ -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>>(); + + 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) { @@ -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); @@ -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. */ diff --git a/yarn.lock b/yarn.lock index 436fdd0ba..1bfd837a2 100644 --- a/yarn.lock +++ b/yarn.lock @@ -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 @@ -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 @@ -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 @@ -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