Viewpoints
Class in @bimworks/viewercommon.
API catalogue · @bimworks/viewercommon · Class
class Viewpointsviewer3d.viewpoints of both 3D viewers: a view as a ViewpointValue and back
Members#
| Member | Kind | Description |
|---|---|---|
| constructor | Method | |
| capture | Method | The view now as a value: a new plain object, JSON as it is. |
| captureMeasurements | Method | The finished measurements as capture stores them, in the version frame of vid |
| frameFor | Method | The loaded version a value's coordinates are read in: its own frame version; else a loaded version of the same model; else a loaded version it recorded, or a… |
| restore | Method | Brings a value back. A stored part replaces that part of the view for the models it recorded; models it did not record keep theirs. The object state first, t… |
| decodeQids | Method | A value's set of objects back as a QidSet; throws on a run that is not "n" or "from-to" |
| encodeQids | Method | A set of objects as a value stores it: per version, its object ids as runs (ViewpointQids) |
constructor#
constructor(viewer3d: object, frames: VersionFrames)Parameters#
| Name | Type | Description |
|---|---|---|
viewer3d |
object |
|
frames |
VersionFrames |
capture#
capture(options?: { parts?: Iterable<ViewpointPart, any, any> }): ViewpointValueThe view now as a value: a new plain object, JSON as it is.
Parameters#
| Name | Type | Description |
|---|---|---|
options |
{ parts?: Iterable<ViewpointPart, any, any> } |
parts: what to store, VIEWER_VIEWPOINT_PARTS by default; the application's parts given here are listed in bimworks.parts for the application to fill in. The loaded models are recorded whatever the parts |
Exceptions#
- Error when no model is loaded
captureMeasurements#
captureMeasurements(vid: string): (ViewpointMeasurement)[]The finished measurements as capture stores them, in the version frame of vid
Parameters#
| Name | Type | Description |
|---|---|---|
vid |
string |
frameFor#
frameFor(bimworks: { camera?: { pivot: [number, number, number] | null; target_distance: number }; measurements?: (ViewpointMeasurement)[]; model_set?: { models: (ViewpointModel)[]; placement: "LOCAL" | "GEO" }; models?: (string)[]; parts?: (ViewpointPart)[]; planes?: ({ name: string | null; standard: string | null })[]; schema: "bimworks.viewpoint/1"; sets?: { coloring?: ({ color: string; qids: ViewpointQids } | { alter: number; qids: ViewpointQids })[]; exceptions?: ViewpointQids; selection?: ViewpointQids; xray?: ViewpointQids }; version_uuid: string; visibility?: { default_visibility: boolean }; [member: string]: unknown }): { match: "exact" | "same-model" | "other-model"; vid: string } | nullThe loaded version a value's coordinates are read in: its own frame version; else a loaded version of the same model; else a loaded version it recorded, or any. Null with nothing loaded
Parameters#
| Name | Type | Description |
|---|---|---|
bimworks |
{ camera?: { pivot: [number, number, number] | null; target_distance: number }; measurements?: (ViewpointMeasurement)[]; model_set?: { models: (ViewpointModel)[]; placement: "LOCAL" | "GEO" }; models?: (string)[]; parts?: (ViewpointPart)[]; planes?: ({ name: string | null; standard: string | null })[]; schema: "bimworks.viewpoint/1"; sets?: { coloring?: ({ color: string; qids: ViewpointQids } | { alter: number; qids: ViewpointQids })[]; exceptions?: ViewpointQids; selection?: ViewpointQids; xray?: ViewpointQids }; version_uuid: string; visibility?: { default_visibility: boolean }; [member: string]: unknown } |
restore#
restore(value: ViewpointValue, options?: { animate?: number; beforeCamera?: (report: ViewpointRestoreReport) => void | Promise<void> | null; measurements?: "replace" | "add" | null; parts?: Iterable<ViewpointPart, any, any> | null }): Promise<ViewpointRestoreReport>Brings a value back. A stored part replaces that part of the view for the models it recorded; models it did not record keep theirs. The object state first, then the section planes, the measurements, options.beforeCamera, and the camera last (not awaited: it may animate).
Parameters#
| Name | Type | Description |
|---|---|---|
value |
ViewpointValue | |
options |
{ animate?: number; beforeCamera?: (report: ViewpointRestoreReport) => void | Promise<void> | null; measurements?: "replace" | "add" | null; parts?: Iterable<ViewpointPart, any, any> | null } |
parts: which of the stored parts, all of them by default; animate: the camera's flight in ms, 0 (the default) jumps; measurements: "replace" takes the measurements on screen away, "add" keeps them, by default a full restore (no parts) replaces and a chosen one adds; beforeCamera: awaited once everything but the camera is back, for the parts the application restores itself, which it can add to the report |
Exceptions#
- Error when the value is not a VIEWPOINT_SCHEMA value
decodeQids#
static decodeQids(encoded: ViewpointQids | null | undefined): QidSetA value's set of objects back as a QidSet; throws on a run that is not "n" or "from-to"
Parameters#
| Name | Type | Description |
|---|---|---|
encoded |
ViewpointQids | null | undefined |
encodeQids#
static encodeQids(qids: QidSet): ViewpointQidsA set of objects as a value stores it: per version, its object ids as runs (ViewpointQids)
Parameters#
| Name | Type | Description |
|---|---|---|
qids |
QidSet |