Skip to content

Commit

Permalink
chore: keep documenting the BCF integration
Browse files Browse the repository at this point in the history
  • Loading branch information
HoyosJuan committed Aug 29, 2024
1 parent dff9d2f commit 73e5030
Show file tree
Hide file tree
Showing 4 changed files with 32 additions and 4 deletions.
4 changes: 4 additions & 0 deletions packages/core/src/core/Viewpoints/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,9 @@ interface ViewpointsConfig {
overwriteColors: boolean;
}

/*
* The viewpoints component manages and applies BCF compliant viewpoint to a world.
*/
export class Viewpoints
extends Component
implements Disposable, Configurable<ViewpointsConfig>
Expand Down Expand Up @@ -58,6 +61,7 @@ export class Viewpoints
onSetup = new Event();
config: Required<ViewpointsConfig> = { overwriteColors: false };

/** {@link Disposable.onDisposed} */
readonly onDisposed = new Event();

/**
Expand Down
25 changes: 21 additions & 4 deletions packages/core/src/core/Viewpoints/src/Viewpoint.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,14 +21,22 @@ import { Classifier, Hider } from "../../../fragments";
import { SimplePlane } from "../../Clipper";
import { Viewpoints } from "..";

/**
* Represents a BCF compliant viewpoint from BuildingSMART.
*
* The Viewpoint class provides methods for managing and interacting with viewpoints.
* It includes functionality for setting viewpoint properties, updating the camera,
* applying color to components, and serializing the viewpoint for export.
*/
export class Viewpoint implements BCFViewpoint {
title?: string;
guid = UUID.create();
readonly guid = UUID.create();

/**
* ClippingPlanes can be used to define a subsection of a building model that is related to the topic.
* Each clipping plane is defined by Location and Direction.
* The Direction vector points in the invisible direction meaning the half-space that is clipped.
* @experimental
*/
clippingPlanes = new DataSet<SimplePlane>();

Expand Down Expand Up @@ -229,8 +237,6 @@ export class Viewpoint implements BCFViewpoint {
* Adds components to the viewpoint based on the provided fragment ID map.
*
* @param fragmentIdMap - A map containing fragment IDs as keys and arrays of express IDs as values.
*
* @returns A Promise that resolves when the components have been added to the viewpoint.
*/
addComponentsFromMap(fragmentIdMap: FRAGS.FragmentIdMap) {
const fragments = this._components.get(FragmentsManager);
Expand All @@ -241,9 +247,10 @@ export class Viewpoint implements BCFViewpoint {
}

/**
* Sets the properties of the viewpoint with the provided data.
* Replace the properties of the viewpoint with the provided data.
*
* @remarks The guid will be ommited as it shouldn't change after it has been initially set.
* @remarks The existing selection and exception components will be fully replaced in case new ones are provided.
*
* @param data - An object containing the properties to be set.
* The properties not included in the object will remain unchanged.
Expand All @@ -256,6 +263,16 @@ export class Viewpoint implements BCFViewpoint {
for (const key in data) {
if (key === "guid") continue;
const value = _data[key];
if (key === "selectionComponents") {
this.selectionComponents.clear();
this.selectionComponents.add(...value);
continue;
}
if (key === "exceptionComponents") {
this.exceptionComponents.clear();
this.exceptionComponents.add(...value);
continue;
}
if (key in this) _this[key] = value;
}
const manager = this._components.get(Viewpoints);
Expand Down
3 changes: 3 additions & 0 deletions packages/core/src/core/Viewpoints/src/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,9 @@ export interface ViewpointOrthographicCamera extends ViewpointCamera {
viewToWorldScale: number;
}

/**
* Represents a viewpoint in a BCF file.
*/
export interface BCFViewpoint {
title?: string;
guid: string;
Expand Down
4 changes: 4 additions & 0 deletions packages/core/src/openbim/BCFTopics/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,10 @@ import { Clipper } from "../../core/Clipper";

// TODO: Extract import/export logic in its own class for better maintenance.

/**
* BCFTopics manages Building Collaboration Format (BCF) data the engine.
* It provides functionality for importing, exporting, and manipulating BCF data.
*/
export class BCFTopics
extends Component
implements Disposable, Configurable<BCFTopicsConfig>
Expand Down

0 comments on commit 73e5030

Please sign in to comment.