Skip to content

Commit

Permalink
fix(components): fragment highlighter meshes added to screen culler (#…
Browse files Browse the repository at this point in the history
  • Loading branch information
HoyosJuan authored Dec 29, 2023
1 parent 28e7890 commit 8f29abf
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 3 deletions.
8 changes: 8 additions & 0 deletions resources/openbim-components.js
Original file line number Diff line number Diff line change
Expand Up @@ -100610,6 +100610,7 @@ class FragmentHighlighter extends Component {
depthTest: true,
}),
autoHighlightOnClick: true,
cullHighlightMesh: true,
};
this._mouseState = {
down: false,
Expand Down Expand Up @@ -100939,6 +100940,13 @@ class FragmentHighlighter extends Component {
if (!fragment.fragments[name]) {
const material = this.highlightMats[name];
const subFragment = fragment.addFragment(name, material);
if (this.config.cullHighlightMesh) {
const culler = this.components.tools.get(ScreenCuller);
if (name !== this.config.selectName &&
name !== this.config.hoverName) {
culler.add(subFragment.mesh);
}
}
if (fragment.blocks.count > 1) {
subFragment.setInstance(0, {
ids: Array.from(fragment.ids),
Expand Down
23 changes: 20 additions & 3 deletions src/fragments/FragmentHighlighter/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,19 @@ import { Fragment, FragmentMesh } from "bim-fragment";
import {
Component,
Disposable,
Updateable, Event,
Updateable,
Event,
FragmentIdMap,
Configurable,
} from "../../base-types";
import { FragmentManager } from "../FragmentManager";
import { FragmentBoundingBox } from "../FragmentBoundingBox";
import { Components, SimpleCamera, ToolComponent } from "../../core";
import {
Components,
ScreenCuller,
SimpleCamera,
ToolComponent,
} from "../../core";
import { toCompositeID } from "../../utils";
import { PostproductionRenderer } from "../../navigation/PostproductionRenderer";

Expand All @@ -32,11 +38,12 @@ export interface FragmentHighlighterConfig {
selectionMaterial: THREE.Material;
hoverMaterial: THREE.Material;
autoHighlightOnClick: boolean;
cullHighlightMesh: boolean;
}

export class FragmentHighlighter
extends Component<HighlightMaterials>
implements Disposable, Updateable , Configurable<FragmentHighlighterConfig>
implements Disposable, Updateable, Configurable<FragmentHighlighterConfig>
{
static readonly uuid = "cb8a76f2-654a-4b50-80c6-66fd83cafd77" as const;

Expand Down Expand Up @@ -98,6 +105,7 @@ export class FragmentHighlighter
depthTest: true,
}),
autoHighlightOnClick: true,
cullHighlightMesh: true,
};

private _mouseState = {
Expand Down Expand Up @@ -468,6 +476,15 @@ export class FragmentHighlighter
if (!fragment.fragments[name]) {
const material = this.highlightMats[name];
const subFragment = fragment.addFragment(name, material);
if (this.config.cullHighlightMesh) {
const culler = this.components.tools.get(ScreenCuller);
if (
name !== this.config.selectName &&
name !== this.config.hoverName
) {
culler.add(subFragment.mesh);
}
}
if (fragment.blocks.count > 1) {
subFragment.setInstance(0, {
ids: Array.from(fragment.ids),
Expand Down

0 comments on commit 8f29abf

Please sign in to comment.