BCF Viewpoints

Imports and exports BCF (Building Collaboration Format) viewpoints.

A BCF viewpoint stores viewer state for an issue or bookmark, including camera, section planes, object visibility, selection, coloring, translucency, annotations, bitmaps, and an optional snapshot.

%%{init:{"theme":"dark"}}%% classDiagram direction TB class saveBCFViewpoint { +(params) SDKResult~BCFViewpoint~ } class loadBCFViewpoint { +(params) SDKResult~void~ } class BCFViewpoint { +perspective_camera? : BCFPerspectiveCamera +orthogonal_camera? : BCFOrthogonalCamera +clipping_planes? : BCFClippingPlane[] +lines? : BCFLine[] +bitmaps? : BCFBitmap[] +components? : BCFComponents +snapshot? : BCFSnapshot } class BCFComponents { +selection? / coloring? / visibility? / translucency? +view_setup_hints? : BCFViewSetupHints } class SaveBCFViewpointParams { +view : View +renderer? : BCFSnapshotSource +snapshot? : boolean +includeViewLayerIds? / excludeViewLayerIds? } class LoadBCFViewpointParams { +view : View +data : Data +bcfViewpoint : BCFViewpoint +includeViewLayerIds? / excludeViewLayerIds? } class View { <<viewer>> } class Data { <<data>> } saveBCFViewpoint ..> SaveBCFViewpointParams : reads saveBCFViewpoint ..> BCFViewpoint : returns loadBCFViewpoint ..> LoadBCFViewpointParams : reads loadBCFViewpoint ..> View : mutates SaveBCFViewpointParams o-- View LoadBCFViewpointParams o-- View LoadBCFViewpointParams o-- Data LoadBCFViewpointParams o-- BCFViewpoint BCFViewpoint *-- BCFComponents
%%{init:{"theme":"default"}}%% classDiagram direction TB class saveBCFViewpoint { +(params) SDKResult~BCFViewpoint~ } class loadBCFViewpoint { +(params) SDKResult~void~ } class BCFViewpoint { +perspective_camera? : BCFPerspectiveCamera +orthogonal_camera? : BCFOrthogonalCamera +clipping_planes? : BCFClippingPlane[] +lines? : BCFLine[] +bitmaps? : BCFBitmap[] +components? : BCFComponents +snapshot? : BCFSnapshot } class BCFComponents { +selection? / coloring? / visibility? / translucency? +view_setup_hints? : BCFViewSetupHints } class SaveBCFViewpointParams { +view : View +renderer? : BCFSnapshotSource +snapshot? : boolean +includeViewLayerIds? / excludeViewLayerIds? } class LoadBCFViewpointParams { +view : View +data : Data +bcfViewpoint : BCFViewpoint +includeViewLayerIds? / excludeViewLayerIds? } class View { <<viewer>> } class Data { <<data>> } saveBCFViewpoint ..> SaveBCFViewpointParams : reads saveBCFViewpoint ..> BCFViewpoint : returns loadBCFViewpoint ..> LoadBCFViewpointParams : reads loadBCFViewpoint ..> View : mutates SaveBCFViewpointParams o-- View LoadBCFViewpointParams o-- View LoadBCFViewpointParams o-- Data LoadBCFViewpointParams o-- BCFViewpoint BCFViewpoint *-- BCFComponents
classDiagram
    direction TB
    class saveBCFViewpoint {
      +(params) SDKResult~BCFViewpoint~
    }
    class loadBCFViewpoint {
      +(params) SDKResult~void~
    }
    class BCFViewpoint {
      +perspective_camera? : BCFPerspectiveCamera
      +orthogonal_camera?  : BCFOrthogonalCamera
      +clipping_planes?    : BCFClippingPlane[]
      +lines?              : BCFLine[]
      +bitmaps?            : BCFBitmap[]
      +components?         : BCFComponents
      +snapshot?           : BCFSnapshot
    }
    class BCFComponents {
      +selection? / coloring? / visibility? / translucency?
      +view_setup_hints? : BCFViewSetupHints
    }
    class SaveBCFViewpointParams {
      +view              : View
      +renderer?         : BCFSnapshotSource
      +snapshot?         : boolean
      +includeViewLayerIds? / excludeViewLayerIds?
    }
    class LoadBCFViewpointParams {
      +view         : View
      +data         : Data
      +bcfViewpoint : BCFViewpoint
      +includeViewLayerIds? / excludeViewLayerIds?
    }
    class View {
      <<viewer>>
    }
    class Data {
      <<data>>
    }
    saveBCFViewpoint ..> SaveBCFViewpointParams : reads
    saveBCFViewpoint ..> BCFViewpoint : returns
    loadBCFViewpoint ..> LoadBCFViewpointParams : reads
    loadBCFViewpoint ..> View : mutates
    SaveBCFViewpointParams o-- View
    LoadBCFViewpointParams o-- View
    LoadBCFViewpointParams o-- Data
    LoadBCFViewpointParams o-- BCFViewpoint
    BCFViewpoint *-- BCFComponents
npm install @xeokit/sdk
import { Scene } from "@xeokit/sdk/model/scene";
import { Data } from "@xeokit/sdk/model/data";
import { Viewer } from "@xeokit/sdk/viewing/viewer";
import { WebGLRenderer } from "@xeokit/sdk/viewing/webGLRenderer";
import { loadXKT } from "@xeokit/sdk/formats/xkt";
import { saveBCFViewpoint, loadBCFViewpoint } from "@xeokit/sdk/interop/bcf";

const scene = new Scene();
const data = new Data();

const viewer = new Viewer({
scene
});

const renderer = new WebGLRenderer({
viewer
});

const viewResult = viewer.createView({
id: "myView",
elementId: "myCanvas"
});

const view = viewResult.value;

const sceneModelResult = scene.createModel({ id: "myModel" });
const sceneModel = sceneModelResult.value;

const dataModelResult = data.createModel({ id: "myModel" });
const dataModel = dataModelResult.value;

fetch("myModel.xkt").then(response => response.arrayBuffer().then(fileData => {
loadXKT({ data, sceneModel, dataModel });
}));

Save the current view state:

view.camera.eye = [0, 0, -33];
view.camera.look = [0, 0, 0];
view.camera.up = [0, 0, 1];

view.setObjectsVisible(view.objectIds, false);
view.setObjectsVisible(["myObject1", "myObject2"], true);
view.setObjectsXRayed(["myObject1"], true);

const bcfViewpointResult = saveBCFViewpoint({ view });
const bcfViewpoint = bcfViewpointResult.value;

Load the viewpoint:

loadBCFViewpoint({
bcfViewpoint,
view
});

Use includeViewLayerIds to save or load only selected ViewLayers.

view.createLayer({ id: "foreground" });
view.createLayer({ id: "background" });

scene.createModel({
id: "myModel",
layerId: "foreground"
});

//...

const bcfViewpointResult = saveBCFViewpoint({
view,
includeViewLayerIds: ["foreground"]
});

const bcfViewpoint = bcfViewpointResult.value;

Load the viewpoint for the same layer:

loadBCFViewpoint({
bcfViewpoint,
view,
includeViewLayerIds: ["foreground"]
});

Interfaces

BCFBitmap
BCFClippingPlane
BCFColoringComponent
BCFComponent
BCFComponents
BCFLine
BCFOrthogonalCamera
BCFPerspectiveCamera
BCFSelectionComponent
BCFSnapshot
BCFSnapshotSource
BCFTranslucencyComponent
BCFVector
BCFViewpoint
BCFViewSetupHints
BCFVisibilityComponent
LoadBCFViewpointParams
SaveBCFViewpointParams

Functions

loadBCFViewpoint
saveBCFViewpoint