Options
All
  • Public
  • Public/Protected
  • All
Menu

Class UnityUtil

Hierarchy

  • UnityUtil

Index

Properties

Clipping Plane Methods

Compare Tool Methods

Configurations Methods

Configurations Quits unity instance & reset all custom callback and promises Methods

GIS Methods

Measuring tool Methods

Model Interactions Methods

Navigations Methods

Object Highlighting Methods

Other Methods

Pins Methods

State Queries Methods

Properties

Static viewer

viewer: any

viewer can be assigned, containing any callback function the user wishes to hook onto. The following functions are supported:

viewer.clipBroadcast(object): Called when a clipping plane broadcast occurs with the new clipping plane information

viewer.numClipPlanesUpdated(int): Called when the number of clipping planes changed, with the latest number of clipping planes in place

viewer.objectSelected(object): Notify the user which object/pin is clicked after a mouse event

viewer.objectsSelected(object): Notify the user which objects is selected after a rectangular select event

viewer.pickPointEvent(object): Notify the user what position within the 3D world was clicked after a mouse event.

example

UnityUtil.viewer = { numClipPlanesUpdated = (nPlanes) => console.log(`Current no. planes: ${nPlanes}`}

Clipping Plane Methods

Static startBoxClip

  • startBoxClip(): void

Static startClipEdit

  • startClipEdit(): void
  • Start editing mode with current clip plane state

    Returns void

Static startSingleClip

  • startSingleClip(): void

Static stopClipEdit

  • stopClipEdit(): void

Compare Tool Methods

Static diffToolDiffView

  • diffToolDiffView(): void
  • When Compare tool is enabled, visalise in differencing view Models will be rendered in greyscale, detailing the difference/clash

    Returns void

Static diffToolDisableAndClear

  • diffToolDisableAndClear(): void
  • Disable compare tool This also unloads the comparator models

    Returns void

Static diffToolEnableWithClashMode

  • diffToolEnableWithClashMode(): void
  • Enable compare tool This starts the compare tool in clash mode

    Returns void

Static diffToolEnableWithDiffMode

  • diffToolEnableWithDiffMode(): void
  • Enable compare tool This starts the compare tool in diff mode

    Returns void

Static diffToolLoadComparator

  • diffToolLoadComparator(account: string, model: string, revision?: string): Promise<void>
  • Load comparator model for compare tool This returns a promise which will be resolved when the comparator model is loaded

    Parameters

    • account: string

      teamspace

    • model: string

      model ID

    • Default value revision: string = "head"

      Specific revision ID/tag to load

    Returns Promise<void>

    returns a promise that resolves upon comparator model finished loading.

Static diffToolRenderTransAsDefault

  • diffToolRenderTransAsDefault(): void

Static diffToolRenderTransAsInvisible

  • diffToolRenderTransAsInvisible(): void

Static diffToolRenderTransAsOpaque

  • diffToolRenderTransAsOpaque(): void
  • Compare transparent objects as if they are opaque objects

    Returns void

Static diffToolSetAsComparator

  • diffToolSetAsComparator(account: string, model: string): void
  • Set an existing submodel/model as a comparator model This will return as a base model when you have cleared the comparator (i.e. disabled diff)

    Parameters

    • account: string

      name of teamspace

    • model: string

      model ID

    Returns void

Static diffToolSetThreshold

  • diffToolSetThreshold(theshold: number): void
  • Set tolerance threshold. In general you should not need to tweak this, but if the differencing looks off, this is the value to tweak

    Parameters

    • theshold: number

      tolerance level for diffing/clashing

    Returns void

Static diffToolShowBaseModel

  • diffToolShowBaseModel(): void
  • Only show the base model i.e. It will show only the original model, not the comparator nor the diff view

    Returns void

Static diffToolShowComparatorModel

  • diffToolShowComparatorModel(): void
  • Only show the comparator model i.e. Only show the model you are trying to compare with, not the base model

    Returns void

Configurations Methods

Static ResetBackground

  • ResetBackground(): void

Static disableCaching

  • disableCaching(): void

Static disableShadows

  • disableShadows(): void

Static disableSnapping

  • disableSnapping(): void

Static enableCaching

  • enableCaching(): void

Static enableHardShadows

  • enableHardShadows(): void

Static enableSnapping

  • enableSnapping(): void
  • Enable snapping to snap the cursor to the closest edge

    Returns void

Static enableSoftShadows

  • enableSoftShadows(): void
  • Enable soft shadows - the highest shadow quality

    Returns void

Static hideCoordView

  • hideCoordView(): void

Static init

  • init(errorCallback: any, progressCallback: any, modelLoaderProgressCallback: any): void
  • Initialise Unity.

    Parameters

    • errorCallback: any

      function to call when an error occurs. This function should take a string(message), boolean(requires reload), boolean(came from unity).

    • progressCallback: any
    • modelLoaderProgressCallback: any

    Returns void

Static loadModel

  • loadModel(account: string, model: string, branch?: string, revision?: string, initView?: any, clearCanvas?: boolean): Promise<void>
  • Loading another model. NOTE: this will also clear the canvas of existing models Use branch = master and revision = head to get the latest revision. If you want to know when the model finishes loading, use onLoaded

    Parameters

    • account: string

      name of teamspace

    • model: string

      name of model

    • Default value branch: string = ""

      ID of the branch (deprecated value)

    • Default value revision: string = "head"

      ID of revision

    • Default value initView: any = null
    • Default value clearCanvas: boolean = true

    Returns Promise<void>

    returns a promise that resolves when the model start loading.

Static loadUnity

  • loadUnity(canvas: any, host: any): Promise<void>
  • Launch the Unity Game.

    Parameters

    Returns Promise<void>

    returns a promise which resolves when the game is loaded.

Static offLoadModel

  • offLoadModel(account: string, model: string, revision?: string): void
  • Offload a model that is currently loaded

    Parameters

    • account: string

      name of teamspace

    • model: string

      name of model

    • Default value revision: string = "head"

      ID of revision

    Returns void

Static reset

  • reset(resetProjection?: boolean): void
  • Clear the canvas and reset all settings

    Parameters

    • Default value resetProjection: boolean = true

    Returns void

Static setAPIHost

  • setAPIHost(hostname: []): void

Static setAPIKey

  • setAPIKey(apiKey: string): void
  • Set API key to use for authentication. Ensure setAPIHost is called before this.

    Parameters

    • apiKey: string

    Returns void

Static setBackgroundColor

  • setBackgroundColor(color: number[]): void
  • Change the background colour of the viewer note: alpha defaults to 1 if an array of 3 numbers is sent

    Parameters

    • color: number[]

      rgba colour value to set to e.g.[1,0,0,1] for solid red.

    Returns void

Static setDefaultNearPlane

  • setDefaultNearPlane(value: number): void
  • Set the default near plane value. This can be use to tweak situations where geometry closest to you are being clipped

    Parameters

    • value: number

      the closest distance (in model units) the camera will render.

    Returns void

Static setMaxShadowDistance

  • setMaxShadowDistance(value: number): void
  • Set the maximum rending distance for shadows. Smaller value may increase shadow quality.

    Parameters

    • value: number

      The maximum distance (in model units) the renderer will render shadows for

    Returns void

Static setNumCacheThreads

  • setNumCacheThreads(thread: any): void
  • Set the number of simultaneously threads for cache access

    Parameters

    • thread: any

    Returns void

Static setRenderingQualityDefault

  • setRenderingQualityDefault(): void

Static setUnits

  • setUnits(units: any): void
  • Set the units By default, units are set to mm. This is used for GIS and measuring tool.

    Parameters

    • units: any

      i.e. "m", "mm", "ft" etc.

    Returns void

Static showCoordView

  • showCoordView(): void

Static toggleStats

  • toggleStats(): void
  • Toggle on/off rendering statistics. When it is toggled on, list of stats will be displayed in the top left corner of the viewer.

    Returns void

Configurations Quits unity instance & reset all custom callback and promises Methods

Static quitUnity

  • quitUnity(): void

GIS Methods

Static addMapSource

  • addMapSource(mapSource: string): void
  • Add map source.

    Parameters

    • mapSource: string

      This can be "OSM", "HERE", "HERE_AERIAL", "HERE_TRAFFIC", "HERE_TRAFFIC_FLOW"

    Returns void

Static mapInitialise

  • mapInitialise(surveyingInfo: []): void
  • Initialise map tiles within unity

    Parameters

    • surveyingInfo: []

      array of survey points and it's respective latitude and longitude value

    Returns void

Static mapStart

  • mapStart(): void

Static mapStop

  • mapStop(): void

Static removeMapSource

  • removeMapSource(mapSource: string): void
  • Remove map source.

    Parameters

    • mapSource: string

      This can be "OSM", "HERE", "HERE_AERIAL", "HERE_TRAFFIC", "HERE_TRAFFIC_FLOW"

    Returns void

Static resetMapSources

  • resetMapSources(): void
  • Reset map sources. This removes all currently displayed maps

    Returns void

Measuring tool Methods

Static clearAllMeasurements

  • clearAllMeasurements(): void

Static disableMeasureToolToolbar

  • disableMeasureToolToolbar(): void

Static disableMeasureToolXYZDisplay

  • disableMeasureToolXYZDisplay(): void

Static disableMeasuringTool

  • disableMeasuringTool(): void

Static enableMeasureToolToolbar

  • enableMeasureToolToolbar(): void

Static enableMeasureToolXYZDisplay

  • enableMeasureToolXYZDisplay(): void

Static enableMeasuringTool

  • enableMeasuringTool(): void
  • Enable measuring tool. This will allow you to start measuring by clicking on the model

    Returns void

Static setMeasureToolMode

  • setMeasureToolMode(mode: any): void
  • Set the measure tool mode.

    Parameters

    • mode: any

      The measuring mode, accepted values are "Point", "Raycast", "MinimumDistance", "SurfaceArea" or "PolygonArea".

    Returns void

Static setMeasureToolUnits

  • setMeasureToolUnits(units: any): void
  • Set the measure tool units.

    Parameters

    • units: any

      The measuring units accepted values are "cm", "mm", "m"

    Returns void

Model Interactions Methods

Static disableClippingPlanes

  • disableClippingPlanes(): void
  • Reset clipping plane This will also toggle edit mode to false

    Returns void

Static getObjectsStatus

  • getObjectsStatus(account: string, model: string): Promise<object>
  • Get Object Status within the viewer. This will return you the list of objects that are currently set invisible, and a list of object that are currently highlighted.

    The object status will be returned via the promise provided.

    Parameters

    • account: string

      name of teamspace

    • model: string

      name of the model

    Returns Promise<object>

Static hideHiddenByDefaultObjects

  • hideHiddenByDefaultObjects(): void
  • Hide objects that are hidden by default (e.g. IFCSpaces)

    Returns void

Static moveMeshes

  • moveMeshes(teamspace: string, modelId: string, meshes: string[], matrix: number[]): void
  • Move mesh/meshes by a given transformation matrix. NOTE: this currently only works as desired in Synchro Scenarios

    Parameters

    • teamspace: string

      teamspace of the model

    • modelId: string

      modelID the meshes belongs in

    • meshes: string[]

      array of mesh unique IDs

    • matrix: number[]

      array of 16 numbers, representing the transformation on the meshes (row major)

    Returns void

Static requestScreenShot

  • requestScreenShot(): Promise<object>
  • Request a screenshot. The screenshot will be returned as a JSON object with a single field, ssByte, containing the screenshot in base64.

    Returns Promise<object>

    returns a promise which will resolve with an object with a screenshot in base64 format

Static requestViewpoint

  • requestViewpoint(account: string, model: string): Promise<object>
  • Request the information of the current viewpoint

    Parameters

    • account: string

      name of teamspace

    • model: string

      name of model

    Returns Promise<object>

    returns a promises which will resolve with the viewpoint information

Static resetMovedMeshes

  • resetMovedMeshes(teamspace: string, modelId: string, meshes: string[]): void
  • Move mesh/meshes by a given transformation matrix. NOTE: this currently only works as desired in Synchro Scenarios

    Parameters

    • teamspace: string

      teamspace of the model

    • modelId: string

      modelID the meshes belongs in

    • meshes: string[]

      array of mesh unique IDs

    Returns void

Static setNavigationOff

  • setNavigationOff(): any

Static setNavigationOn

  • setNavigationOn(): any

Static setPlaneBorderColor

  • setPlaneBorderColor(color: number[]): void
  • Change the colour of the clipping planes border

    Parameters

    • color: number[]

    Returns void

Static setPlaneBorderWidth

  • setPlaneBorderWidth(width: number): void
  • Change the width of the clipping planes border

    Parameters

    • width: number

      the width of the clipping plane border

    Returns void

Static setRenderingQualityHigh

  • setRenderingQualityHigh(): void

Static setXRayHighlightOff

  • setXRayHighlightOff(): any

Static setXRayHighlightOn

  • setXRayHighlightOn(): any

Static showHiddenByDefaultObjects

  • showHiddenByDefaultObjects(): void
  • Make all hidden by default objects visible (typically IFC Spaces)

    Returns void

Static toggleVisibility

  • toggleVisibility(account: string, model: string, ids: [], visibility: boolean): void
  • Toggle visibility of the given list of objects

    Parameters

    • account: string

      name of teamspace

    • model: string

      name of model

    • ids: []

      list of unique ids to toggle visibility

    • visibility: boolean

      true = visible, false = invisible

    Returns void

Static updateClippingPlanes

  • updateClippingPlanes(clipPlane: object, requireBroadcast: boolean, account?: string, model?: string): void
  • Update the clipping plane to the given direction teamspace and model is only needed if the viewpoint is relative to a model Clipping plane is defined by the plane normal, distance from origin and it's direction direction = -1 means it will clip anything above the plane, 1 otherwise.

    example

    UnityUtil.updateClippingPlanes([{normal : [0,-1,0], distance: 10, clipDirection: -1}], false)

    Parameters

    • clipPlane: object

      object containing the clipping plane

    • requireBroadcast: boolean

      if set to true, A callback to viewer.clipBroadcast will be called after it is set.

    • Optional account: string

      name of teamspace

    • Optional model: string

      name of model

    Returns void

Static zoomToHighlightedMeshes

  • zoomToHighlightedMeshes(): void

Navigations Methods

Static backView

  • backView(): void
  • Reset the viewpoint to the back of the model.

    Returns void

Static bottomView

  • bottomView(): void

Static centreToPoint

  • centreToPoint(meshIDs: []): void
  • Move the pivot point to eh centre of the objects provided

    Parameters

    • meshIDs: []

      array of json objects each recording { model: <account.modelID>, meshID: [array of mesh IDs] }

    Returns void

Static frontView

  • frontView(): void
  • Reset the viewpoint to the front of the model.

    Returns void

Static helicopterSpeedDown

  • helicopterSpeedDown(): void
  • Decrease the speed of Helicopter navigation (by x0.75)

    Returns void

Static helicopterSpeedReset

  • helicopterSpeedReset(): void

Static helicopterSpeedUp

  • helicopterSpeedUp(): void
  • Increase the speed of Helicopter navigation (by x1.25)

    Returns void

Static leftView

  • leftView(): void
  • Reset the viewpoint to the left side of the model.

    Returns void

Static resetCamera

  • resetCamera(): void

Static rightView

  • rightView(): void
  • Reset the viewpoint to the right side of the model.

    Returns void

Static setNavigation

  • setNavigation(navMode: any): void
  • Set navigation mode.

    Parameters

    • navMode: any

      This can be either "HELICOPTER" or "TURNTABLE"

    Returns void

Static setViewpoint

  • setViewpoint(pos: [], up: [], forward: [], lookAt: [], projectionType?: boolean, orthographicSize?: number, account?: string, model?: string): void
  • Change the camera configuration teamspace and model is only needed if the viewpoint is relative to a model

    Parameters

    • pos: []

      3D point in space where the camera should be

    • up: []

      Up vector

    • forward: []

      forward vector

    • lookAt: []

      point in space the camera is looking at. (pivot point)

    • Optional projectionType: boolean
    • Optional orthographicSize: number
    • Optional account: string

      name of teamspace

    • Optional model: string

      name of model

    Returns void

Static topView

  • topView(): void

Object Highlighting Methods

Static clearHighlights

  • clearHighlights(): void
  • Clear all highlighting on currently highlighted objects

    Returns void

Static highlightObjects

  • highlightObjects(account: string, model: string, idArr: [], color: [], toggleMode: boolean, forceReHighlight: boolean): void
  • Highlight objects

    Parameters

    • account: string

      name of teamspace

    • model: string

      name of model

    • idArr: []

      array of unique IDs associated with the objects to highlight

    • color: []

      RGB value of the highlighting colour

    • toggleMode: boolean

      If set to true, existing highlighted objects will stay highlighted. Also any objects that are already highlighted will be unhighlighted

    • forceReHighlight: boolean

      If set to true, existing highlighted objects will be forced to re-highlight itself. This is typically used for re-colouring a highlight ] or when you want a specific set of objects to stay highlighted when toggle mode is on

    Returns void

Static overrideMeshColor

  • overrideMeshColor(account: string, model: string, meshIDs: [], color: []): void
  • Override the colour of given object(s)

    Parameters

    • account: string

      teamspace the meshes resides in

    • model: string

      model ID the meshes resides in

    • meshIDs: []

      unique IDs of the meshes to operate on

    • color: []

      RGB value of the override color (note: alpha will be ignored)

    Returns void

Static overrideMeshOpacity

  • overrideMeshOpacity(account: string, model: string, meshIDs: [], opacity: number): void
  • Override the alpha value of given object(s) If you are setting opacity to 0, use toggleVisibility instead.

    Parameters

    • account: string

      teamspace the meshes resides in

    • model: string

      model ID the meshes resides in

    • meshIDs: []

      unique IDs of the meshes to operate on

    • opacity: number

      opacity (>0 - 1) value to override with

    Returns void

Static resetMeshColor

  • resetMeshColor(account: string, model: string, meshIDs: []): void
  • Restore the meshes to its original color values

    Parameters

    • account: string

      teamspace the meshes resides in

    • model: string

      model ID the meshes resides in

    • meshIDs: []

      unique IDs of the meshes to operate on

    Returns void

Static resetMeshOpacity

  • resetMeshOpacity(account: string, model: string, meshIDs: []): void
  • Reset override alpha value of given object(s)

    Parameters

    • account: string

      teamspace the meshes resides in

    • model: string

      model ID the meshes resides in

    • meshIDs: []

      unique IDs of the meshes to operate on

    Returns void

Static startAreaSelection

  • startAreaSelection(): void

Static stopAreaSelection

  • stopAreaSelection(): void

Static unhighlightObjects

  • unhighlightObjects(account: string, model: string, idArr: []): void
  • Unhighlight objects

    Parameters

    • account: string

      name of teamspace

    • model: string

      name of model

    • idArr: []

      array of unique IDs associated with the objects to highlight

    Returns void

Other Methods

Static clearMeasureToolMeasurement

  • clearMeasureToolMeasurement(uuid: any): void
  • Remove a particular measurement.

    Parameters

    • uuid: any

      The measurement id of the measurement to be removed

    Returns void

Static deselectPin

  • deselectPin(id: string): void

Static hideProgressBar

  • hideProgressBar(): void

Static pauseRendering

  • pauseRendering(): void

Static resumeRendering

  • resumeRendering(): void

Static selectPin

  • selectPin(id: string): void

Static setMeasureToolMeasurementColor

  • setMeasureToolMeasurementColor(uuid: any, color: any): void
  • Set color of a particular measurement.

    Parameters

    • uuid: any

      The measurement id of the measurement that will change color

    • color: any

    Returns void

Static setMeasureToolMeasurementName

  • setMeasureToolMeasurementName(uuid: any, name: any): void
  • Set color of a particular measurement.

    Parameters

    • uuid: any

      The measurement id of the measurement that will change name

    • name: any

    Returns void

Static showProgressBar

  • showProgressBar(): void

Static useOrthographicProjection

  • useOrthographicProjection(): void

Static usePerspectiveProjection

  • usePerspectiveProjection(): void

Static zoomToObjects

  • zoomToObjects(meshEntries: object[]): void

Pins Methods

Static changePinColour

  • changePinColour(id: string, colour: number[]): void
  • Change the colour of an existing pin

    Parameters

    • id: string

      ID of the pin

    • colour: number[]

      colour RGB value of the colour to change to. e.g. [1, 0, 0]

    Returns void

Static dropBookmarkPin

  • dropBookmarkPin(id: string, position: number[], normal: number[], colour: number[]): void
  • Add a bookmark pin

    Parameters

    • id: string

      Identifier for the pin

    • position: number[]

      point in space where the pin should generate

    • normal: number[]

      normal vector for the pin (note: this is no longer used)

    • colour: number[]

      RGB value for the colour of the pin

    Returns void

Static dropIssuePin

  • dropIssuePin(id: string, position: number[], normal: number[], colour: number[]): void
  • Add an issue pin

    Parameters

    • id: string

      Identifier for the pin

    • position: number[]

      point in space where the pin should generate

    • normal: number[]

      normal vector for the pin (note: this is no longer used)

    • colour: number[]

      RGB value for the colour of the pin

    Returns void

Static dropRiskPin

  • dropRiskPin(id: string, position: number[], normal: number[], colour: number[]): void
  • Add a Risk pin

    Parameters

    • id: string

      Identifier for the pin

    • position: number[]

      point in space where the pin should generate

    • normal: number[]

      normal vector for the pin (note: this is no longer used)

    • colour: number[]

      RGB value for the colour of the pin

    Returns void

Static removePin

  • removePin(id: string): void
  • Remove a pin from the viewer

    Parameters

    • id: string

      pin identifier

    Returns void

State Queries Methods

Static onLoaded

  • onLoaded(): Promise<object>
  • Returns a promise that lets you know when the model has finished loading.

    Returns Promise<object>

    returns a Promise that resolves when the model has finished loading. The Promise returns the bounding box of the model.

Static onLoading

  • onLoading(): Promise<void>
  • Returns a promise that lets you know when the model has started to load

    Returns Promise<void>

    returns a Promise that resolves when the model has started to load

Static onReady

  • onReady(): Promise<void>
  • Returns a promise that lets you know when the game is loaded.

    Returns Promise<void>

    returns a Promise that resolves when the game is loaded.

Generated using TypeDoc