Skip to content

Commit

Permalink
feat(core): implement model cloning and subsets
Browse files Browse the repository at this point in the history
  • Loading branch information
agviegas committed Jul 31, 2024
1 parent 319391d commit 4aba42e
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 2 deletions.
2 changes: 1 addition & 1 deletion packages/core/package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "@thatopen/components",
"description": "Collection of core functionalities to author BIM apps.",
"version": "2.1.16",
"version": "2.1.17",
"author": "That Open Company",
"contributors": [
"Antonio Gonzalez Viegas (https://github.com/agviegas)",
Expand Down
2 changes: 1 addition & 1 deletion packages/core/src/core/Components/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ export class Components implements Disposable {
/**
* The version of the @thatopen/components library.
*/
static readonly release = "2.1.16";
static readonly release = "2.1.17";

/** {@link Disposable.onDisposed} */
readonly onDisposed = new Event<void>();
Expand Down
16 changes: 16 additions & 0 deletions packages/core/src/fragments/FragmentsManager/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -265,4 +265,20 @@ export class FragmentsManager extends Component implements Disposable {
object.applyMatrix4(originalCoordinateSystem.clone().invert());
object.applyMatrix4(this.baseCoordinationMatrix);
}

/**
* Creates a copy of the whole model or a part of it.
*
* @param model - The model to clone.
* @param items - Optional - The part of the model to be cloned. If not given, the whole group is cloned.
*
*/
clone(model: FRAGS.FragmentsGroup, items?: FRAGS.FragmentIdMap) {
const clone = model.cloneGroup(items);
this.groups.set(clone.uuid, clone);
for (const frag of clone.items) {
this.list.set(frag.id, frag);
}
return clone;
}
}

0 comments on commit 4aba42e

Please sign in to comment.