Class: ViewData

PD. ViewData

Stores core view-based state values for quick view comparisons.

The aim of this class is encapsulate the core properties that define how model geometry is converted to a set of mesh representations for visualisation. It is used primarily by BIM.Renderable classes (such as BIM.Level and BIM.DrawingView), as well as the PD.ModelManager, to store their last rendered state and subsequently use it to determine if they need to regenerate different geometry.

This class also defines the view data that is passed to BIM.Element instances when they are being rebuilt and/or highlighted, so that they know how to create and/or render themselves suitably for the current view.

This class also serves as the basis for a range of subclasses that introduce additional view and display data.


new ViewData()

Creates a new view data instance.

Author:
  • drajmarsh

Members


:number

canvasColor

The current color of the model canvas background.

This value is used to set the background color of the canvas when rendering the model. It is also used to set the background color of the model when it is being rendered in a 2D drawing. When set to a negative value, the canvas will use the default canvas color.

Type
  • number

:boolean

isPlanView

Whether or not the current view is restricted to the XY in plan.

This value monitors and reflects the current viewAxis property.

Type
  • boolean

:boolean

isViewData <readonly>

A flag identifying this object as a view state object.

Type
  • boolean

:PD.DISPLAY

modelView

The current display mode of the model.

Determines whether the model is shown in plan section, spatial, solid or whole building mode.

Type

:number

pointSizeDash

Stores a reference dash size relative to the current model size.

This is calculated whenever the overall size of the visible model changes. It is used for generating dashes and drafting line extensions.

Type
  • number

:number

pointSizeModel

Stores a reference point size relative to the current model size.

This is calculated as a fraction of the scene size and is typically used to size text labels and other fixed drawing elements that need to be visible within the model context.

Type
  • number

:number

pointSizeView

Stores a dynamic reference point size relative to both model and view size.

This value is updated whenever either the overall size of the visible model or the current view zoom/dolly changes. It is given in model units (typically mm) that is used by dynamic drawing elements such as cursors, snap indicators and interactive dimensions that must be drawn within the context of the model, but need to stay roughly the same size relative to the drawing canvas even when zooming in or out.

Type
  • number

:number

sceneSize

Stores the slightly modified size of the bounding sphere.

This value is used to update the camera radius and is the basis for both the pointSizeModel and pointSizeView properties that are used directly by 3D cursors, arrows and dimensions.

Type
  • number

:boolean

show3D

Whether or not to display the model in three dimensions.

This refers specifically to model geometry rather than the camera view. When false, the model is displayed as flat 2D plan sections, which are useful for 2D drawings and plans. This allows you to view a 2D plan section within a 3D view, or view a 3D model within a 2D plan or elevation view.

Type
  • boolean

:boolean

showAll

Whether or not to show all levels and structures.

This indicates that the whole model or structure is being displayed, rather than just the current level.

Type
  • boolean

:boolean

showDoubleSided

Whether or not to show 3D internal surfaces as double-sided rather than single-sided.

Type
  • boolean

:boolean

showDraftingLines

Whether or not to show architectural-style extended drafting lines.

When true, elements should be drawn with extended drafting lines rather than straight technical lines.

Type
  • boolean

:boolean

showSpaceColors

Whether or not to show the color of individual spaces.

Type
  • boolean

:boolean

showSpatial

Whether or not to show a simplified spatial model view.

This indicates that the model should be displayed as a spatial or analytical model, with only the basic structure and spaces shown. You can determine exactly what analytical model is being shown by checking the PD.ViewData#modelView property.

Type
  • boolean

:PD.AXIS

viewAxis

The current camera view axis.

When this value is non-zero, an orthographic view of the model is generated. When zero, a perspective view is generated.

Type

Methods


copyFrom(viewData)

Copies data from the given instance to this instance.

Parameters:
Name Type Description
viewData PD.ViewData

The view state instance to copy data from.

Returns:

Returns this view state to support method chaining.

Type
PD.ViewData

copyTo(viewData)

Copies data from this instance to another given instance.

Parameters:
Name Type Description
viewData PD.ViewData

The view state instance to copy data to.

Returns:

Returns this view state to support method chaining.

Type
PD.ViewData

fromJSON(data)

Safely copy properties from a source object.

See the PD.Base#fromJSON method for more details.

Parameters:
Name Type Description
data object

The source object containing data to copy.

Returns:

Returns this view data instance to support method chaining.

Type
PD.ViewData

isModelRebuildRequired(viewData)

Determines if changing to the new view would requires a model rebuild.

Parameters:
Name Type Description
viewData PD.ViewData

The view state instance to compare with.

Returns:

Returns true if there has been a material change.

Type
boolean

isViewRebuildRequired(viewData)

Determines if changing to the new view would requires a renderable container mesh rebuild.

Parameters:
Name Type Description
viewData PD.ViewData

The view state instance to compare with.

Returns:

Returns true if changing view would need a rebuild.

Type
boolean

toJSON( [data])

Converts the object instance to a simple POJO for JSON storage.

This method is used to copy, store and save the data for ths object, so the returned object must have all the properties required be able to rebuild this instance in its entirety when passed to the class constructor.

See the PD.Base#toJSON method for more details.

Parameters:
Name Type Argument Description
data object <optional>

An optional parent object to append this data to.

Returns:

Returns a JSON object.

Type
object