Skip to content

fix(SingleThreadedFragmentsModel)!: apply common fragments model interface#227

Open
ShaMan123 wants to merge 8 commits into
ThatOpen:mainfrom
ShaMan123:feat/model-interface
Open

fix(SingleThreadedFragmentsModel)!: apply common fragments model interface#227
ShaMan123 wants to merge 8 commits into
ThatOpen:mainfrom
ShaMan123:feat/model-interface

Conversation

@ShaMan123
Copy link
Copy Markdown
Contributor

@ShaMan123 ShaMan123 commented May 30, 2026

Description

closes #216

  • drop redundant async directives
  • BREAKING: rename SingleThreadedFragmentsModel#getItemsWithGeometry to getItemsWithGeometry for compat with FragmentsModel
  • exposed getItemsVolume

Additional context

Misalignments — methods present in one class but absent (or internal) in the other

  • In FragmentsModel only (missing from SingleThreadedFragmentsModel):
    • getGuids() — VirtualFragmentsModel exposes this but SingleThreaded does not.
    • getItemsWithGeometryCategories() — same situation.
    • getItemsIdsWithGeometry() — FragmentsModel only.
    • getCoordinationMatrix() — FragmentsModel only.
    • getMergedBox() / getBoxes() — FragmentsModel only.
    • getAlignments() / getHorizontalAlignments() / getVerticalAlignments() / getAlignmentStyles() — FragmentsModel only.
    • getGrids() / getGridMaterial() / setGridMaterial() / getGridLabelMaterial() / setGridLabelMaterial() — FragmentsModel only.
    • useCamera() / setLodMode() — FragmentsModel only.
    • raycast() / raycastAll() / raycastWithSnapping() / rectangleRaycast() — FragmentsModel only.
    • setVisible() / toggleVisible() / resetVisible() / getVisible() / getItemsByVisibility() — FragmentsModel only.
    • highlight() / setColor() / resetColor() / setOpacity() / resetOpacity() — FragmentsModel only.
    • getHighlight() / resetHighlight() / getHighlightItemIds() — FragmentsModel only.
    • getItemsMaterialDefinition() — FragmentsModel only.
    • getAttributesUniqueValues() — FragmentsModel only.
    • getEditedElements() — FragmentsModel only.
    • getItemsVolume() — FragmentsModel only.
    • getAttributeNames() / getAttributeValues() / getAttributeTypes() / getRelationNames() — FragmentsModel only.
    • getGeometries() — FragmentsModel only.
    • getItem() — FragmentsModel only.
  • In SingleThreadedFragmentsModel only (absent or internal in FragmentsModel):
    • edit() — public in SingleThreaded; FragmentsModel exposes _edit() (internal) and routes edits through the Editor class.
    • reset() / save() — same; _reset() / _save() are internal in FragmentsModel.
    • undo() / redo() — SingleThreaded only; no equivalent in FragmentsModel.
    • getRequests() / setRequests() / selectRequest() — SingleThreaded only; _getRequests() etc. are internal in FragmentsModel.

What is the purpose of this pull request?

  • Bug fix
  • New Feature
  • Documentation update
  • Other

Before submitting the PR, please make sure you do the following:

  • Check that there isn't already a PR that solves the problem the same way to avoid creating a duplicate.
  • Follow the Conventional Commits v1.0.0 standard for PR naming (e.g. feat(examples): add hello-world example).
  • Provide a description in this PR that addresses what the PR is solving, or reference the issue that it solves (e.g. fixes #123).
  • Ideally, include relevant tests that fail without this PR but pass with it.

@ShaMan123
Copy link
Copy Markdown
Contributor Author

Methods that can be added to SingleThreadedFragmentsModel

  getGuids() {
    return this._virtualModel.getGuids();
  }

  getItemsWithGeometryCategories() {
    return this._virtualModel.getItemsWithGeometryCategories();
  }

  getItemsVolume(localIds: number[]) {
    return this._virtualModel.getItemsVolume(localIds);
  }

  getAttributeNames() {
    return this._virtualModel.getAttributeNames();
  }

  getAttributeValues() {
    return this._virtualModel.getAttributeValues();
  }

  getAttributeTypes() {
    return this._virtualModel.getAttributeTypes();
  }

  getRelationNames() {
    return this._virtualModel.getRelationNames();
  }

  getAttributesUniqueValues(params: AttributesUniqueValuesParams[]) {
    return this._virtualModel.getAttributesUniqueValues(params);
  }

  getItemsMaterialDefinition(localIds: number[]) {
    return this._virtualModel.getItemsMaterialDefinition(localIds);
  }

  getMergedBox(localIds: number[]) {
    return this._virtualModel.getBBoxes(localIds);
  }

  getBoxes(localIds?: number[]) {
    const ids = localIds ?? (this._virtualModel.getLocalIds() as number[]);
    return ids.map((id) => this._virtualModel.getBBoxes([id]));
  }

  setLodMode(lodMode: LodMode) {
    this._virtualModel.setLodMode(lodMode);
  }

@ShaMan123 ShaMan123 force-pushed the feat/model-interface branch from 9e82a89 to 40961c6 Compare May 30, 2026 09:13
@ShaMan123 ShaMan123 force-pushed the feat/model-interface branch from c99c6db to c428f5a Compare May 30, 2026 09:28
Copy link
Copy Markdown
Contributor Author

@ShaMan123 ShaMan123 left a comment

Choose a reason for hiding this comment

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

  • drop redundant async directives
  • BREAKING: rename SingleThreadedFragmentsModel#getItemsWithGeometry to getItemsWithGeometry for compat with FragmentsModel
  • exposed getItemsVolume

* Get all the items of the model that have geometry.
*/
getItemsWithGeometry() {
getItemsIdsWithGeometry() {
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.

breaking!

* @param localIds - The local IDs of the items to look up.
*/
getPositions(localIds: number[]) {
getPositions(localIds?: number[]) {
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.

fixed signature, non breaking

@ShaMan123 ShaMan123 changed the title fix(): apply common fragments model interface fix()!: apply common fragments model interface May 30, 2026
@ShaMan123 ShaMan123 changed the title fix()!: apply common fragments model interface fix(SingleThreadedFragmentsModel)!: apply common fragments model interface May 30, 2026
@ShaMan123 ShaMan123 marked this pull request as ready for review May 30, 2026 09:36
Copy link
Copy Markdown
Contributor Author

@ShaMan123 ShaMan123 left a comment

Choose a reason for hiding this comment

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

Ready for review
Regarding file/interface naming please suggest to desired pattern so I can align with standards.

@ShaMan123
Copy link
Copy Markdown
Contributor Author

Should IModelSerializer methods return Uint8Array only?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Consolidate FragmentsModel / SingleThreadedFragmentsModel return types

1 participant