Skip to content
Open
Show file tree
Hide file tree
Changes from 6 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
94 changes: 60 additions & 34 deletions packages/fragments/src/FragmentsModels/src/model/fragments-model.ts
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we should run prettier on the entire repo to it cleanup and include organizing imports.
We should also add .vscode/settings.json to cover organizing imports.
If you are troubled by the noise in the diff I will revert and cleanup.

Original file line number Diff line number Diff line change
@@ -1,46 +1,46 @@
import * as THREE from "three";
import {
AttributesUniqueValuesParams,
AttrsChange,
BIMMesh,
MaterialDefinition,
CurrentLod,
Identifier,
ItemInformationType,
ItemsDataConfig,
RectangleRaycastData,
RaycastData,
SnappingRaycastData,
VirtualModelConfig,
ItemSelectionType,
ItemInformationType,
SelectionInputType,
ResultInputType,
AttrsChange,
Identifier,
RelsChange,
ItemsQueryParams,
AttributesUniqueValuesParams,
CurrentLod,
ItemsQueryConfig,
ItemsQueryParams,
LodMode,
MaterialDefinition,
RaycastData,
RectangleRaycastData,
RelsChange,
ResultInputType,
SelectionInputType,
SnappingRaycastData,
VirtualModelConfig,
} from "./model-types";

import { MiscHelper } from "../utils";
import { FragmentsConnection } from "../multithreading/fragments-connection";
import { MiscHelper } from "../utils";
import { MeshManager } from "./mesh-manager";

import { AlignmentsManager } from "./alignments-manager";
import { DataMap, EditRequest, Event } from "../../../Utils";
import { SetupManager } from "./setup-manager";
import { Editor } from "../edit";
import { AlignmentsManager } from "./alignments-manager";
import { BoxManager } from "./box-manager";
import { CoordinatesManager } from "./coordinates-manager";
import { DataManager } from "./data-manager";
import { EditManager } from "./edit-manager";
import { GridsConfig, GridsManager } from "./grids-manager";
import { HighlightManager } from "./highlight-manager";
import { ItemsManager } from "./items-manager";
import { ViewManager } from "./view-manager";
import { RaycastManager } from "./raycast-manager";
import { VisibilityManager } from "./visibility-manager";
import { HighlightManager } from "./highlight-manager";
import { SectionManager } from "./section-manager";
import { DataManager } from "./data-manager";
import { SequenceManager } from "./sequence-manager";
import { EditManager } from "./edit-manager";
import { Editor } from "../edit";
import { GridsManager } from "./grids-manager";
import { SetupManager } from "./setup-manager";
import { ViewManager } from "./view-manager";
import { VisibilityManager } from "./visibility-manager";

/**
* The main class for managing a 3D model loaded from a fragments file. Handles geometry, materials, visibility, highlighting, sections, and more. This class orchestrates multiple specialized managers to handle different aspects of the model like mesh management, item data, raycasting, etc. It maintains the overall state and provides the main interface for interacting with the model. The model data is loaded and processed asynchronously across multiple threads.
Expand Down Expand Up @@ -492,7 +492,7 @@ export class FragmentsModel {
this.modelId,
"getAttributesUniqueValues",
[params],
)) as Record<string, { value: any, localIds: number[] }[]>;
)) as Record<string, { value: any; localIds: number[] }[]>;
return values;
}

Expand Down Expand Up @@ -651,18 +651,26 @@ export class FragmentsModel {
/**
* Get the grids of the model (if any).
*
* Returns a `THREE.Group` with one child per grid (each child carries
* `userData.id = localId` and `userData.kind = "grid"`). Each grid's
* children are `THREE.Line` instances with `userData.kind = "axis"`,
* `userData.tag` (the axis label), and `userData.axis` ("uAxes",
* "vAxes", or "wAxes").
* Returns a `THREE.Group` with one child per grid (each child is a `THREE.Group`
* that carries `userData.id = localId` and `userData.kind = "grid"`).
*
* Each grid's children are `THREE.Group` instances with `userData.kind = "axis"`,
* acting as an axis container.
* A `THREE.LINE` instance with `userData.kind = "line"` is appended to it.
*
* When opting in to showing labels, two `THREE.SHAPE` instances with
* `userData.kind = "label"` and `userData.index` (the label's index, `0` or `1`)
* are appended to the axis container.
*
* All grid's descendants (`"axis"`, `"line"`, `"label"`) carry `userData.tag` (the axis label value)
* and `userData.axis` (`"uAxes"`, `"vAxes"`, or `"wAxes"`).
*/
async getGrids() {
return this._gridsManager.getGrids();
async getGrids(config?: GridsConfig) {
return this._gridsManager.getGrids(config);
}

/**
* The shared `LineDashedMaterial` used to render every grid axis line.
* The shared material used to render every grid axis line.
* Mutating its properties (color, opacity, dash sizes, etc.) updates all
* rendered grid lines immediately. Use `setGridMaterial` to swap to a
* different material instance.
Expand All @@ -675,10 +683,28 @@ export class FragmentsModel {
* Replace the shared grid material. The previous material is disposed
* after the swap.
*/
setGridMaterial(material: THREE.LineDashedMaterial) {
setGridMaterial(material: THREE.LineBasicMaterial) {
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What do you think about this?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Perhaps I should add that the default is a dash line material

this._gridsManager.setGridMaterial(material);
}

/**
* The shared material used to render every grid axis label.
* Mutating its properties (color, opacity, dash sizes, etc.) updates all
* rendered grid labels immediately. Use `setGridLabelMaterial` to swap to a
* different material instance.
*/
getGridLabelMaterial() {
return this._gridsManager.getLabelMaterial();
}

/**
* Replace the shared grid label material. The previous material is disposed
* after the swap.
*/
setGridLabelMaterial(material: THREE.Material) {
this._gridsManager.setLabelMaterial(material);
}

/**
* Sets a camera for the model. The model will use it to load tiles dinamically depending on the users view
* (e.g. hiding items that are not in the view, setting the LOD to far away items, etc).
Expand Down
Loading