Options
All
  • Public
  • Public/Protected
  • All
Menu

Class Viewer

Hierarchy

  • Viewer

Index

Constructors

Properties

Accessors

Methods

Constructors

constructor

  • new Viewer(canvas: string | HTMLCanvasElement, errorHandler?: (__namedParameters: { string: any }) => void): Viewer
  • This is constructor of the xBIM Viewer. It gets HTMLCanvasElement or string ID as an argument. Viewer will than be initialized in the context of specified canvas. Any other argument will throw exception.

    If any Zone technology is in use, this constructor should run in the root zone without any additional load. It has global event handlers and hooks in document.mousemove, document.keyup, requestAnimationFrame and otherw which need to run fast and should not cause any additional sideeffects (like data binding refresh in Angular)

    name

    Viewer

    classdesc

    This is the main and the only class you need to load and render IFC models in wexBIM format. This viewer is part of xBIM toolkit which can be used to create wexBIM files from IFC, ifcZIP and ifcXML. WexBIM files are highly optimized for transmition over internet and rendering performance. Viewer uses WebGL technology for hardware accelerated 3D rendering and SVG for certain kinds of user interaction. This means that it won't work with obsolete and non-standard-compliant browsers like IE10 and less.

    Parameters

    • canvas: string | HTMLCanvasElement

      string ID of the canvas or HTML canvas element.

    • Optional errorHandler: (__namedParameters: { string: any }) => void
        • (__namedParameters: { string: any }): void
        • Parameters

          • __namedParameters: { string: any }
            • string: any

          Returns void

    Returns Viewer

Properties

animations

animations: Animations

Animations functionality

canvas

canvas: HTMLCanvasElement

gl

gl: WebGLRenderingContext

glVersion

glVersion: number

lockedOrbitOrigin

lockedOrbitOrigin: vec3

zoomDuration

zoomDuration: number = 1000

Number of milliseconds for animated zooming

Accessors

activeHandles

adaptivePerformanceOn

  • get adaptivePerformanceOn(): boolean
  • set adaptivePerformanceOn(value: boolean): void
  • The viewer is watching the performance based on the FPS. When performance drops down, it can reduce amount of geometry to be rendered. This is usefull for some navigation and animations but might not be convenient in all scenarios like in a wals mode. This property can be used to switch the addaptive performance on and off.

    Returns boolean

  • The viewer is watching the performance based on the FPS. When performance drops down, it can reduce amount of geometry to be rendered. This is usefull for some navigation and animations but might not be convenient in all scenarios like in a wals mode. This property can be used to switch the addaptive performance on and off.

    Parameters

    • value: boolean

    Returns void

adjustments

  • This can be used to adjust ortgographic and perspective camera properties to be close. Particularly useful when restoring orthographic view with displaced camera.

    Returns CameraAdjustment

background

  • get background(): number[]
  • set background(value: number[]): void
  • Array of four integers between 0 and 255 representing RGBA colour components. This defines background colour of the viewer. You can change this value at any time with instant effect.

    member

    {Number[]} Viewer#background

    Returns number[]

  • Array of four integers between 0 and 255 representing RGBA colour components. This defines background colour of the viewer. You can change this value at any time with instant effect.

    member

    {Number[]} Viewer#background

    Parameters

    • value: number[]

    Returns void

brightness

  • get brightness(): number
  • set brightness(value: number): void
  • Allows to adjust brightness of the view

    Returns number

  • Allows to adjust brightness of the view

    Parameters

    • value: number

    Returns void

camera

  • Type of camera to be used. Available values are 'perspective' and 'orthogonal' You can change this value at any time with instant effect.

    member

    {string} Viewer#camera

    Returns CameraType

  • Type of camera to be used. Available values are 'perspective' and 'orthogonal' You can change this value at any time with instant effect.

    member

    {string} Viewer#camera

    Parameters

    Returns void

cameraProperties

contrast

  • get contrast(): number
  • set contrast(value: number): void
  • Allows to adjust contrast of the view

    Returns number

  • Allows to adjust contrast of the view

    Parameters

    • value: number

    Returns void

gamma

  • get gamma(): number
  • set gamma(value: number): void
  • Allows to adjust gamma of the view

    Returns number

  • Allows to adjust gamma of the view

    Parameters

    • value: number

    Returns void

hasDepthSupport

  • get hasDepthSupport(): boolean

height

  • get height(): number
  • set height(value: number): void

highlightingColour

  • get highlightingColour(): number[]
  • set highlightingColour(value: number[]): void
  • Array of four integers between 0 and 255 representing RGBA colour components. This defines colour for highlighted elements. You can change this value at any time with instant effect.

    member

    {Number[]} Viewer#highlightingColour

    Returns number[]

  • Array of four integers between 0 and 255 representing RGBA colour components. This defines colour for highlighted elements. You can change this value at any time with instant effect.

    member

    {Number[]} Viewer#highlightingColour

    Parameters

    • value: number[]

    Returns void

hoverPickColour

  • get hoverPickColour(): number[]
  • set hoverPickColour(value: number[]): void
  • Array of four integers between 0 and 255 representing RGBA colour components. This defines colour for elements when hovered over. You can change this value at any time with instant effect.

    member

    {Number[]} Viewer#hoverPickColour

    Returns number[]

  • Array of four integers between 0 and 255 representing RGBA colour components. This defines colour for elements when hovered over. You can change this value at any time with instant effect.

    member

    {Number[]} Viewer#hoverPickColour

    Parameters

    • value: number[]

    Returns void

hoverPickEnabled

  • get hoverPickEnabled(): boolean
  • set hoverPickEnabled(value: boolean): void
  • Determines whether the viewer raised 'hoverpick' events when the mouse hovers over an element. When enabled the currently hovered item will be be highlighted. The 'hoverpicked' event can be used to provide tooltips/context menus etc.

    Returns boolean

  • Determines whether the viewer raised 'hoverpick' events when the mouse hovers over an element. When enabled the currently hovered item will be be highlighted. The 'hoverpicked' event can be used to provide tooltips/context menus etc.

    Parameters

    • value: boolean

    Returns void

isRunning

  • get isRunning(): boolean
  • Indicates if the viewer is running the rendering loop

    Returns boolean

mvMatrix

  • get mvMatrix(): mat4
  • set mvMatrix(value: mat4): void
  • World matrix

    member

    {Number[]} Viewer#mvMatrix

    Returns mat4

  • World matrix

    member

    {Number[]} Viewer#mvMatrix

    Parameters

    • value: mat4

    Returns void

mvMatrixAge

  • get mvMatrixAge(): number
  • Returns number of milliseconds for which Model View Matris hasn't been changed. This can be used for optimisations and actions to happen after vertain amount of time after the last movement of the model.

    Returns number

navigationMode

  • Switch between different navigation modes for left mouse button. Allowed values: 'pan', 'zoom', 'orbit' (or 'fixed-orbit') , 'free-orbit' and 'none'. Default value is 'orbit';

    member

    {String} Viewer#navigationMode

    Returns NavigationMode

  • Switch between different navigation modes for left mouse button. Allowed values: 'pan', 'zoom', 'orbit' (or 'fixed-orbit') , 'free-orbit' and 'none'. Default value is 'orbit';

    member

    {String} Viewer#navigationMode

    Parameters

    Returns void

pMatrix

  • get pMatrix(): mat4
  • set pMatrix(value: mat4): void
  • Camera matrix (perspective or orthogonal)

    member

    {Number[]} Viewer#pMatrix

    Returns mat4

  • Camera matrix (perspective or orthogonal)

    member

    {Number[]} Viewer#pMatrix

    Parameters

    • value: mat4

    Returns void

performance

plugins

  • Returns readonly array of plugins

    member

    {IPlugin[]} Viewer#plugins

    Returns IPlugin[]

readerOptions

renderingMode

  • Switch between different rendering modes.

    member

    {String} Viewer#renderingMode

    Returns RenderingMode

  • Switch between different rendering modes.

    member

    {String} Viewer#renderingMode

    Parameters

    Returns void

sectionBox

unitsInMeter

  • get unitsInMeter(): number
  • Returns number of units in active model (1000 is model is in mm)

    member

    {Number} Viewer#unitsInMeter

    Returns number

width

  • get width(): number
  • set width(value: number): void

xrayColour

  • get xrayColour(): number[]
  • set xrayColour(value: number[]): void
  • Array of four integers between 0 and 255 representing RGBA colour components. This defines colour for xray mode rendering. You can change this value at any time with instant effect.

    member

    {Number[]} Viewer#xrayColour

    Returns number[]

  • Array of four integers between 0 and 255 representing RGBA colour components. This defines colour for xray mode rendering. You can change this value at any time with instant effect.

    member

    {Number[]} Viewer#xrayColour

    Parameters

    • value: number[]

    Returns void

Methods

_initShaders

  • _initShaders(): boolean

addPlugin

  • Adds plugin to the viewer. Plugins can implement certain methods which get called in certain moments in time like before draw, after draw etc. This makes it possible to implement functionality tightly integrated into Viewer like navigation cube or others.

    function

    Viewer#addPlugin

    Parameters

    Returns void

addState

  • addState(state: State, target: number | number[], modelId?: number): void
  • You can use this function to change state of products in the model. State has to have one of values from {@link xState xState} enumeration. Target is either enumeration from {@link xProductType xProductType} or array of product IDs. If you specify type it will effect all elements of the type.

    function

    Viewer#setState

    Parameters

    • state: State

      One of State enumeration values.

    • target: number | number[]

      Target of the change. It can either be array of product IDs or product type from {@link xProductType xProductType}.

    • Optional modelId: number

    Returns void

clearHighlighting

  • clearHighlighting(): void
  • Clears all highlighting in all visible models

    Returns void

clip

  • clip(point: number[], normal: number[]): void
  • Use this method to clip the model with A plane. Use {@link Viewer#unclip unclip()} method to unset clipping plane.

    function

    Viewer#setClippingPlaneA

    Parameters

    • point: number[]

      point in clipping plane

    • normal: number[]

      normal pointing to the half space which will be hidden

    Returns void

defineStyle

  • defineStyle(index: number, colour: number[]): void
  • Use this function to define up to 224 optional styles which you can use to change appearance of products and types if you pass the index specified in this function to {@link Viewer#setState setState()} function.

    function

    Viewer#defineStyle

    Parameters

    • index: number

      Index of the style to be defined. This has to be in range 0 - 224. Index can than be passed to change appearance of the products in model

    • colour: number[]

      Array of four numbers in range 0 - 255 representing RGBA colour. If there are less or more numbers exception is thrown.

    Returns void

disableTextSelection

  • disableTextSelection(): void

draw

  • draw(framebuffer?: Framebuffer, disablePlugins?: boolean): void
  • This is the main draw method. You can use it if you just want to render model once with no navigation and interaction. If you want interactive model, call {@link Viewer#start start()} method. {@link Viewer#frame Frame event} is fired when draw call is finished.

    function

    Viewer#draw

    fires

    Viewer#frame

    Parameters

    • Optional framebuffer: Framebuffer
    • Default value disablePlugins: boolean = false

    Returns void

enableTextSelection

  • enableTextSelection(): void

error

  • error(msg: any): void
  • Parameters

    • msg: any

      Fires error event. This might be used by plugins.

    Returns void

fire

  • fire<K>(eventName: K, args: ViewerEventMap[K]): void

getCameraDirection

  • getCameraDirection(): vec3
  • Use this method to get camera direction

    function

    Viewer#getCameraDirection

    Returns vec3

getCameraHeading

  • getCameraHeading(): vec3
  • Use this method to get camera direction

    function

    Viewer#getCameraHeading

    Returns vec3

getCameraPosition

  • getCameraPosition(): vec3
  • Use this method to get actual camera position.

    function

    Viewer#getCameraPosition

    Returns vec3

getCameraPositionWcs

  • getCameraPositionWcs(): vec3
  • Use this method to get camera position in the WCS coordinates. Useful for persistance accross executions.

    Returns vec3

getClip

  • getClip(modelId?: number): { PlaneA: number[]; PlaneB: number[] }
  • Gets clipping plane of the defined model or of the first clipping plane curently visible. Bare in mind that every model might have different clipping plane

    Parameters

    • Optional modelId: number

      Optional ID of the model which clipping plane we want to obtain

    Returns { PlaneA: number[]; PlaneB: number[] }

    • PlaneA: number[]
    • PlaneB: number[]

getCurrentImageBlob

  • getCurrentImageBlob(callback: (blob: Blob) => void): void
  • Parameters

    • callback: (blob: Blob) => void
        • (blob: Blob): void
        • Parameters

          • blob: Blob

          Returns void

    Returns void

getCurrentImageDataArray

  • getCurrentImageDataArray(width?: number, height?: number): Uint8ClampedArray
  • Parameters

    • Default value width: number = this.width
    • Default value height: number = this.height

    Returns Uint8ClampedArray

getCurrentImageDataUrl

  • getCurrentImageDataUrl(width?: number, height?: number, type?: "png" | "jpeg"): string
  • Parameters

    • Default value width: number = this.width
    • Default value height: number = this.height
    • Default value type: "png" | "jpeg" = "png"

    Returns string

getCurrentImageHtml

  • getCurrentImageHtml(width?: number, height?: number): HTMLImageElement
  • Parameters

    • Default value width: number = this.width
    • Default value height: number = this.height

    Returns HTMLImageElement

getCurrentWcs

  • getCurrentWcs(): vec3
  • Gets current WCS displacement used for visualisation

    Returns vec3

getData

  • getData(points: { x: number; y: number }[]): { id: number; model: number }[]
  • This renders the colour coded model into the memory buffer not to the canvas and use it to identify ID, model id and 3D location at canvas location [x,y]

    Parameters

    • points: { x: number; y: number }[]

    Returns { id: number; model: number }[]

getDistanceAndHeight

  • getDistanceAndHeight(bBox: number[] | Float32Array, viewDirection: vec3, upDirection: vec3): { distance: number; height: number }
  • Parameters

    • bBox: number[] | Float32Array
    • viewDirection: vec3
    • upDirection: vec3

    Returns { distance: number; height: number }

    • distance: number
    • height: number

getEventData

  • getEventData(x: number, y: number): { id: number; model: number; xyz: vec3 }
  • Parameters

    • x: number
    • y: number

    Returns { id: number; model: number; xyz: vec3 }

    • id: number
    • model: number
    • xyz: vec3

getEventDataFromEvent

  • getEventDataFromEvent(event: MouseEvent | Touch, raw?: boolean): { id: number; model: number; xyz: vec3 }
  • Parameters

    • event: MouseEvent | Touch
    • Default value raw: boolean = false

    Returns { id: number; model: number; xyz: vec3 }

    • id: number
    • model: number
    • xyz: vec3

getEventDataRaw

  • getEventDataRaw(x: number, y: number): { location: vec3; modelId: number; renderId: number }
  • This renders the colour coded model into the memory buffer not to the canvas and use it to identify ID, model id and 3D location at canvas location [x,y]

    Parameters

    • x: number

      X coordinate on the canvas

    • y: number

      Y coordinate on the canvas

    Returns { location: vec3; modelId: number; renderId: number }

    • location: vec3
    • modelId: number
    • renderId: number

getHTMLPositionOfProductCentroid

  • getHTMLPositionOfProductCentroid(productId: number, modelId: number): number[]
  • This function can be used to place HTML markup relative to the centroid of a product

    Parameters

    • productId: number

      ID of the product

    • modelId: number

      ID of the model

    Returns number[]

    HTML foordinates of the centroid of the product bounding box

getInteractionOrigin

  • getInteractionOrigin(event: MouseEvent | Touch): vec3
  • Parameters

    • event: MouseEvent | Touch

    Returns vec3

getIsolated

  • getIsolated(modelId: number): number[]
  • Gets list of isolated product IDs

    Parameters

    • modelId: number

    Returns number[]

getMergedRegion

getMergedRegionWcs

  • getMergedRegionWcs(): Region

getModelState

  • getModelState(modelId: number): number[][]
  • Gets complete model state and style. Resulting object can be used to restore the state later on.

    Parameters

    • modelId: number

      Model ID which you can get from {@link Viewer#event:loaded loaded} event.

    Returns number[][]

    • Array representing model state in compact form suitable for serialization

getProductAnalysis

  • Counts number of triangles for every product. This is usefull to understand performance of certain models. The default sort order is by number of triangles, but density of triangles (number of triangles per a volume unit) might also be a good measure to find the most expensive products to draw.

    Parameters

    • Default value orderBy: "triangles" | "density" = "triangles"

      Measure to use for the default ascending sort order. Default value: 'triangles'

    Returns ProductAnalyticalResult[]

    List of product analytical results sorted in descendent order by number of triangles or density (number of triangles per volumetric unit of the product bounding box)

getProductBoundingBox

  • getProductBoundingBox(prodId: number, modelId?: number): Float32Array
  • function

    Viewer#getProductBoundingBox

    Parameters

    • prodId: number
    • Optional modelId: number

    Returns Float32Array

    Bounding box of the product in model coordinates (not reduced by current WCS)

getProductType

  • getProductType(prodId: number, modelId?: number): number
  • function

    Viewer#getProductType

    Parameters

    • prodId: number
    • Optional modelId: number

    Returns number

    Product type ID. This is either null if no type is identified or one of {@link xProductType type ids}.

getProductsStates

  • getProductsStates(modelId: number): { id: number; states: State[] }[]
  • Parameters

    • modelId: number

    Returns { id: number; states: State[] }[]

getProductsWithState

  • getProductsWithState(state: State): { id: number; model: number }[]
  • Parameters

    Returns { id: number; model: number }[]

getState

  • getState(id: number, modelId?: number): number
  • Use this function to get state of the products in the model. You can compare result of this function with one of values from {@link xState xState} enumeration. 0xFF is the default value.

    function

    Viewer#getState

    Parameters

    • id: number

      Id of the product. You would typically get the id from {@link Viewer#event:pick pick event} or similar event.

    • Optional modelId: number

    Returns number

getStyle

  • getStyle(id: number, modelId?: number): number
  • Use this function to get overriding colour style of the products in the model. The number you get is the index of your custom colour which you have defined in {@link Viewer#defineStyle defineStyle()} function. 0xFF is the default value.

    function

    Viewer#getStyle

    Parameters

    • id: number

      Id of the product. You would typically get the id from {@link Viewer#event:pick pick event} or similar event.

    • Optional modelId: number

    Returns number

    Returns style index or 255 (State.UNDEFINED) if there is no overriding style defined for the product. Use viewer.defineStyle() to define overriding style and viewer.setStyle() to set it for a product.

getTargetBoundingBox

  • getTargetBoundingBox(prodId?: number, modelId?: number): number[] | Float32Array
  • This method returns specified product's bounding box or bbox of the current acite models if no product ID is specified.

    function

    Viewer#setCameraTarget

    Parameters

    • Optional prodId: number

      Product ID. You can get ID either from semantic structure of the model or from {@link Viewer#event:pick pick event}.

    • Optional modelId: number

    Returns number[] | Float32Array

    Returns bounding box of the target, null if not found

getTargetsBoundingBox

  • getTargetsBoundingBox(targets: { id: number; model: number }[]): number[] | Float32Array
  • Parameters

    • targets: { id: number; model: number }[]

    Returns number[] | Float32Array

isModelLoaded

  • isModelLoaded(id: number): boolean
  • Checks if the model with defined ID is currently loaded in the viewer.

    Parameters

    • id: number

      Model ID

    Returns boolean

    True if model is loaded, false otherwise

isModelOn

  • isModelOn(id: number): boolean
  • Checks if the model with defined ID is currently loaded and running

    Parameters

    • id: number

      Model ID

    Returns boolean

    True if model is loaded and running, false otherwise

isPickable

  • isPickable(modelId: number): boolean
  • Returns true if model participates in picking, false otherwise

    Parameters

    • modelId: number

      ID of the model

    Returns boolean

isProductInModel

  • isProductInModel(productId: number, modelId: number): boolean
  • Checks if product with this ID exists in the model

    Parameters

    • productId: number
    • modelId: number

    Returns boolean

isolate

  • isolate(productIds: number[], modelId: number): void
  • Stops all models and only shows a single product

    Parameters

    • productIds: number[]
    • modelId: number

      Model ID

    Returns void

isolateHeavyProducts

  • Isolates products which have most geometry (number of triangles). This function is meant for data debugging, identifying products which are likely to be over-detailed or poorly modeled.

    Use {@link Viewer#isolate isolate()} to cancel this operation

    Parameters

    • Default value measure: "triangles" | "density" = "triangles"

      Measure to use for sorting and selection. Defaul value: 'triangles'

    • Default value ratio: number = 0.2

      Top ratio to isolate. Should be a number between 0.0 - 1.0. Default value is 0.2 which means top 20% of the geometry

    Returns ProductAnalyticalResult[]

    The set of product analytical results isolated, sorted in descendent order by number of triangles or density (number of triangles per volumetric unit of the product bounding box)

load

  • load(model: string | Blob | File, tag?: any, headers?: {}, progress?: (message: Message) => void): void
  • This method is used to load model data into viewer. Model has to be either URL to wexBIM file or Blob or File representing wexBIM file binary data. Any other type of argument will throw an exception. Region extend is determined based on the region of the model Default view if 'front'. If you want to define different view you have to set it up in handler of {@link Viewer#event:loaded loaded} event.
    You can load more than one model if they occupy the same space, use the same scale and have unique product IDs. Duplicated IDs won't affect visualization itself but would cause unexpected user interaction (picking, zooming, ...)

    function

    Viewer#load

    fires

    Viewer#loaded

    Parameters

    • model: string | Blob | File

      Model has to be either URL to wexBIM file or Blob or File representing wexBIM file binary data.

    • Optional tag: any

      Tag to be used to identify the model in {@link Viewer#event:loaded loaded} event.

    • Optional headers: {}

      Headers to be used for request. This can be used for authorized access for example.

      • [name: string]: string
    • Optional progress: (message: Message) => void

      Progress reporting delegate

    Returns void

loadAsync

  • loadAsync(model: string | Blob | File, tag?: any, headers?: {}, progress?: (message: Message) => void): void
  • This method uses WebWorker if available to load the model into this viewer. Model has to be either URL to wexBIM file or Blob or File representing wexBIM file binary data. Any other type of argument will throw an exception. You can load more than one model if they occupy the same space, use the same scale and have unique product IDs. Duplicated IDs won't affect visualization itself but would cause unexpected user interaction (picking, zooming, ...).

    function

    Viewer#load

    fires

    Viewer#loaded

    Parameters

    • model: string | Blob | File

      Model has to be either URL to wexBIM file or Blob or File representing wexBIM file binary data.

    • Optional tag: any

      Tag to be used to identify the model in {@link Viewer#event:loaded loaded} event.

    • Optional headers: {}

      Headers to be used for request. This can be used for authorized access for example.

      • [name: string]: string
    • Optional progress: (message: Message) => void

    Returns void

navigate

  • navigate(type: NavigationMode, deltaX: number, deltaY: number, origin: vec3): void

off

  • off(eventName: string, callback: any): void
  • Use this method to unregister handlers from events. You can add event handlers by calling the {@link Viewer#on on()} method.

    function

    Viewer#off

    Parameters

    • eventName: string

      Name of the event

    • callback: any

      Handler to be removed

    Returns void

on

  • on<K>(eventName: K, handler: (args: ViewerEventMap[K]) => void): void
  • Use this method to register to events of the viewer like {@link Viewer#event:pick pick}, {@link Viewer#event:mouseDown mouseDown}, {@link Viewer#event:loaded loaded} and others. You can define arbitrary number of event handlers for any event. You can remove handler by calling {@link Viewer#off off()} method.

    function

    Viewer#on

    Type parameters

    Parameters

    • eventName: K

      Name of the event you would like to listen to.

    • handler: (args: ViewerEventMap[K]) => void

      Callback handler of the event which will consume arguments and perform any custom action.

        • (args: ViewerEventMap[K]): void
        • Parameters

          • args: ViewerEventMap[K]

          Returns void

    Returns void

removePlugin

  • removePlugin(plugin: IPlugin): void
  • Removes plugin from the viewer. Plugins can implement certain methods which get called in certain moments in time like before draw, after draw etc. This makes it possible to implement functionality tightly integrated into Viewer like navigation cube or others.

    function

    Viewer#removePlugin

    Parameters

    Returns void

removeState

  • removeState(state: State, target: number | number[], modelId?: number): void
  • Parameters

    • state: State
    • target: number | number[]
    • Optional modelId: number

    Returns void

resetState

  • resetState(target: number | number[], modelId?: number): void
  • Use this function to reset state of all products to 'UNDEFINED' which means visible and not highlighted. You can use optional hideSpaces parameter if you also want to show spaces. They will be hidden by default.

    function

    Viewer#resetStates

    Parameters

    • target: number | number[]

      Target of the change. It can either be array of product IDs or product type from {@link xProductType xProductType}.

    • Optional modelId: number

    Returns void

resetStyles

  • resetStyles(modelId?: number): void
  • Use this function to reset appearance of all products to their default styles.

    function

    Viewer#resetStyles

    Parameters

    • Optional modelId: number

    Returns void

restoreModelState

  • restoreModelState(modelId: number, state: number[][]): void
  • Restores model state from the data previously captured with {@link Viewer#getModelState getModelState()} function

    Parameters

    • modelId: number

      ID of the model

    • state: number[][]

      State of the model as obtained from {@link Viewer#getModelState getModelState()} function

    Returns void

restoreProductsStates

  • restoreProductsStates(modelId: number, stateMap: { id: number; states: State[] }[]): void
  • Parameters

    • modelId: number
    • stateMap: { id: number; states: State[] }[]

    Returns void

set

  • set(settings: Partial<Viewer>): void
  • This method can be used for batch setting of viewer members. It doesn't check validity of the input.

    function

    Viewer#set

    Parameters

    • settings: Partial<Viewer>

      Object containing key - value pairs

    Returns void

setClippingPlaneA

  • setClippingPlaneA(plane: number[], modelId?: number): void
  • Use this method to clip the model with A plane. Use {@link Viewer#unclip unclip()} method to unset clipping plane.

    function

    Viewer#setClippingPlaneA

    Parameters

    • plane: number[]

      normal equation of the plane

    • Optional modelId: number

    Returns void

setClippingPlaneB

  • setClippingPlaneB(plane: number[], modelId?: number): void
  • Use this method to clip the model with A plane. Use {@link Viewer#unclip unclip()} method to unset clipping plane.

    function

    Viewer#setClippingPlaneB

    Parameters

    • plane: number[]

      normal equation of the plane

    • Optional modelId: number

    Returns void

setHoverPick

  • setHoverPick(id: number, model: number): void
  • Sets state of the given item to be hovered over, unsetting an previous item. Setting the id to undefined will clear the current.

    Parameters

    • id: number

      The product Id

    • model: number

      Id of the model

    Returns void

setLockedOrbitOrigin

  • setLockedOrbitOrigin(productId: number, modelId: number): void
  • Parameters

    • productId: number
    • modelId: number

    Returns void

setNearAndFarFromCurrentModels

  • setNearAndFarFromCurrentModels(): void
  • Sets camera parameters (near and far clipping planes) from current active models. This should be called whenever active models are very different (size, units)

    Returns void

setState

  • setState(state: State, target: number | number[], modelId?: number): void
  • Parameters

    • state: State
    • target: number | number[]
    • Optional modelId: number

    Returns void

setStyle

  • setStyle(style: number, target: number | number[], modelId?: number): void
  • Use this method for restyling of the model. This doesn't change the default appearance of the products so you can think about it as an overlay. You can remove the overlay if you set the style to {@link State#UNSTYLED State.UNSTYLED} value. You can combine restyling and hiding in this way. Use {@link Viewer#defineStyle defineStyle()} to define styling first.

    function

    Viewer#setStyle

    Parameters

    • style: number

      style defined in {@link Viewer#defineStyle defineStyle()} method

    • target: number | number[]

      Target of the change. It can either be array of product IDs or product type from {@link xProductType xProductType}.

    • Optional modelId: number

    Returns void

show

  • show(type: ViewType, id?: number, model?: number, withAnimation?: boolean): Promise<void>
  • Use this function to show default views.

    function

    Viewer#show

    Parameters

    • type: ViewType

      Type of view. Allowed values are 'top', 'bottom', 'front', 'back', 'left', 'right'. Directions of this views are defined by the coordinate system. Target and distance are defined by {@link Viewer#setCameraTarget setCameraTarget()} method to certain product ID or to the model extent if {@link Viewer#setCameraTarget setCameraTarget()} is called with no arguments.

    • Optional id: number
    • Optional model: number
    • Default value withAnimation: boolean = true

      Optional parameter, default is 'true'. When true, transition to the view is animated. When false, view is changed imediately.

    Returns Promise<void>

start

  • start(modelId?: number): void
  • Use this function to start animation of the model. If you start animation before geometry is loaded it will wait for content to render it. This function is bound to browser framerate of the screen so it will stop consuming any resources if you switch to another tab.

    function

    Viewer#start

    Parameters

    • Optional modelId: number

      Optional ID of the model to be stopped. You can get this ID from {@link Viewer#event:loaded loaded} event.

    Returns void

startAll

  • startAll(): void
  • Use this function to start all models. You can switch animation of the model off by calling {@link Viewer#stop stop()}.

    function

    Viewer#startAll

    Returns void

startPicking

  • startPicking(id: number): void
  • Use this function to enable picking of the objects in the specified model. All models are pickable by default when loaded. You can stop the model from being pickable using {@link Viewer#stopPicking} function.

    function

    Viewer#startPicking

    Parameters

    • id: number

      ID of the model to be stopped. You can get this ID from {@link Viewer#event:loaded loaded} event.

    Returns void

startRotation

  • startRotation(): void
  • Starts rotation around to present the model

    Returns void

stop

  • stop(id?: number): void
  • Use this function to stop animation of the model. User will still be able to see the latest state of the model. You can switch animation of the model on again by calling {@link Viewer#start start()}.

    function

    Viewer#stop

    Parameters

    • Optional id: number

      Optional ID of the model to be stopped. You can get this ID from {@link Viewer#event:loaded loaded} event.

    Returns void

stopAll

  • stopAll(): void
  • Use this function to stop all models. You can switch animation of the model on again by calling {@link Viewer#start start()}.

    function

    Viewer#stopAll

    Returns void

stopPicking

  • stopPicking(id: number): void
  • Use this function to stop picking of the objects in the specified model. It will behave as if not present for all picking operations. All models are pickable by default when loaded.

    function

    Viewer#stopPicking

    Parameters

    • id: number

      ID of the model to be stopped. You can get this ID from {@link Viewer#event:loaded loaded} event.

    Returns void

stopRotation

  • stopRotation(): void

unclip

  • unclip(modelId?: number): void
  • This method will cancel any clipping plane if it is defined. Use {@link Viewer#clip clip()} method to define clipping by point and normal of the plane.

    function

    Viewer#unclip

    Parameters

    • Optional modelId: number

    Returns void

unload

  • unload(modelId: number): void
  • Unloads model from the GPU. This action is not reversible.

    Parameters

    • modelId: number

      ID of the model which you can get from {@link Viewer#event:loaded loaded} event.

    Returns void

zoomTo

  • zoomTo(target?: number | { id: number; model: number }[], model?: number, withAnimation?: boolean, checkVisibility?: boolean): Promise<void>
  • Use this method to zoom to specified element. If you don't specify a product ID it will zoom to full extent. If you specify list of products, this function will zoom to grouped bounding box. You should use this only for elements which are close to each other (like aggregations)

    function

    Viewer#zoomTo

    Parameters

    • Optional target: number | { id: number; model: number }[]
    • Optional model: number
    • Default value withAnimation: boolean = true

      Optional parameter, default is 'true'. When true, transition to the view is animated. When false, view is changed imediately.

    • Default value checkVisibility: boolean = true

    Returns Promise<void>

    True if target exists and zoom was successful, False otherwise

Static check

  • This is a static function which should always be called before Viewer is instantiated. It will check all prerequisites of the viewer and will report all issues. If Prerequisities.errors contain any messages viewer won't work. If Prerequisities.warnings contain any messages it will work but some functions may be restricted or may not work or it may have poor performance.

    function

    Viewer.check

    Returns CheckResult

Generated using TypeDoc