Skip to content

Commit 226721b

Browse files
committed
feat: allow to control highlighter fragment update
1 parent cce3824 commit 226721b

File tree

2 files changed

+12
-1
lines changed

2 files changed

+12
-1
lines changed

packages/front/src/fragments/Highlighter/index.ts

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,7 @@ export class Highlighter
6363
autoHighlightOnClick: true,
6464
world: null,
6565
selectEnabled: true,
66+
autoUpdateFragments: true,
6667
selectMaterialDefinition: {
6768
color: new THREE.Color("#BCF124"),
6869
renderedFaces: FRAGS.RenderedFaces.ONE,
@@ -297,6 +298,12 @@ export class Highlighter
297298
OBC.ModelIdMapUtils.add(map, { [model.parentModelId]: ids });
298299
}
299300

301+
const selectables = this.selectable?.[name];
302+
if (selectables) {
303+
const selectable = OBC.ModelIdMapUtils.clone(selectables);
304+
map = OBC.ModelIdMapUtils.intersect([map, selectable]);
305+
}
306+
300307
if (exclude) {
301308
// Include the parent modelIds in the exclusion modelIdMap from exclude
302309
const exclusion = OBC.ModelIdMapUtils.clone(exclude);
@@ -380,7 +387,9 @@ export class Highlighter
380387
fragments.highlight({ ...definition, customId: style }, map),
381388
);
382389
}
383-
promises.push(fragments.core.update(true));
390+
if (this.config.autoUpdateFragments) {
391+
promises.push(fragments.core.update(true));
392+
}
384393
await Promise.allSettled(promises);
385394
}
386395

packages/front/src/fragments/Highlighter/src/types.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,4 +34,6 @@ export interface HighlighterConfig {
3434
/** The world in which the highlighter operates. */
3535
world: OBC.World | null;
3636
selectMaterialDefinition: Omit<FRAGS.MaterialDefinition, "customId"> | null;
37+
/** Whether to automatically update fragments when highlighting. */
38+
autoUpdateFragments: boolean;
3739
}

0 commit comments

Comments
 (0)