Options
All
  • Public
  • Public/Protected
  • All
Menu

Class UnityUtil

  • Copyright (C) 2014 3D Repo Ltd *
  • This program is free software: you can redistribute it and/or modify
  • it under the terms of the GNU Affero General Public License as
  • published by the Free Software Foundation, either version 3 of the
  • License, or (at your option) any later version. *
  • This program is distributed in the hope that it will be useful,
  • but WITHOUT ANY WARRANTY; without even the implied warranty of
  • MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  • GNU Affero General Public License for more details. *
  • You should have received a copy of the GNU Affero General Public License
  • along with this program. If not, see http://www.gnu.org/licenses/.

Hierarchy

  • UnityUtil

Index

Properties

Methods

Properties

Static Private modelLoaderProgressCallback

modelLoaderProgressCallback: any

Static Private progressCallback

progressCallback: any

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}`}

Methods

Static addMapSource

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

    category

    GIS

    Parameters

    • mapSource: string

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

    Returns void

Static backView

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

    category

    Navigations

    Returns void

Static bottomView

  • bottomView(): void
  • Reset the viewpoint to Bottom up view.

    category

    Navigations

    Returns void

Static centreToPoint

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

    category

    Navigations

    Parameters

    • meshIDs: [any]

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

    Returns void

Static changePinColour

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

    category

    Pins

    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 clearHighlights

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

    category

    Object Highlighting

    Returns void

Static deselectPin

  • deselectPin(id: string): void

Static diffToolDiffView

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

    category

    Compare Tool

    Returns void

Static diffToolDisableAndClear

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

    category

    Compare Tool

    Returns void

Static diffToolEnableWithClashMode

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

    category

    Compare Tool

    Returns void

Static diffToolEnableWithDiffMode

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

    category

    Compare Tool

    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

    category

    Compare Tool

    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
  • Compare transparent objects as of normal

    category

    Compare Tool

    Returns void

Static diffToolRenderTransAsInvisible

  • diffToolRenderTransAsInvisible(): void
  • Ignore semi-transparent objects in diff

    category

    Compare Tool

    Returns void

Static diffToolRenderTransAsOpaque

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

    category

    Compare Tool

    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)

    category

    Compare Tool

    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

    category

    Compare Tool

    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

    category

    Compare Tool

    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

    category

    Compare Tool

    Returns void

Static disableCaching

  • disableCaching(): void
  • Disable model caching

    category

    Configurations

    Returns void

Static disableClippingPlanes

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

    category

    Model Interactions

    Returns void

Static disableMeasuringTool

  • disableMeasuringTool(): void
  • Disable the Measuring tool.

    category

    Measuring tool

    Returns void

Static disableShadows

  • disableShadows(): void

Static dropIssuePin

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

    category

    Pins

    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

    category

    Pins

    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 enableCaching

  • enableCaching(): void
  • Enable model caching

    category

    Configurations

    Returns void

Static enableHardShadows

  • enableHardShadows(): void
  • Enable hard shadows

    category

    Configurations

    Returns void

Static enableMeasuringTool

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

    category

    Measuring tool

    Returns void

Static enableSoftShadows

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

    category

    Configurations

    Returns void

Static frontView

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

    category

    Navigations

    Returns void

Static getObjectsStatus

  • getObjectsStatus(account: string, model: string): Promise<any>
  • 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.

    category

    Model Interactions

    Parameters

    • account: string

      name of teamspace

    • model: string

      name of the model

    Returns Promise<any>

Static helicopterSpeedDown

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

    category

    Navigations

    Returns void

Static helicopterSpeedReset

  • helicopterSpeedReset(): void
  • Reset the speed of Helicopter navigation

    category

    Navigations

    Returns void

Static helicopterSpeedUp

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

    category

    Navigations

    Returns void

Static hideCoordView

  • hideCoordView(): void
  • Hide x y z coordinates of current point

    category

    Configurations

    Returns void

Static hideHiddenByDefaultObjects

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

    category

    Model Interactions

    Returns void

Static hideProgressBar

  • hideProgressBar(): void

Static highlightObjects

  • highlightObjects(account: string, model: string, idArr: [string], color: [number], toggleMode: boolean, forceReHighlight: boolean): Promise<any[]>
  • Highlight objects

    category

    Object Highlighting

    Parameters

    • account: string

      name of teamspace

    • model: string

      name of model

    • idArr: [string]

      array of unique IDs associated with the objects to highlight

    • color: [number]

      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 Promise<any[]>

Static init

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

    category

    Configurations

    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 leftView

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

    category

    Navigations

    Returns void

Static loadModel

  • loadModel(account: string, model: string, branch?: string, revision?: string): 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

    category

    Configurations

    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

    Returns Promise<void>

    returns a promise that resolves when the model start loading.

Static loadUnity

  • loadUnity(divId: string, unityConfig?: string, memory?: number): Promise<void>
  • Launch the Unity Game.

    category

    Configurations

    Parameters

    • divId: string

      the html div tag this game should be loaded into.

    • Default value unityConfig: string = "unity/Build/unity.json"

      url to find the game configuration

    • Optional memory: number

      Amount of memory the game should start with (in bytes)

    Returns Promise<void>

    returns a promise which resolves when the game is loaded.

Static mapInitialise

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

    category

    GIS

    Parameters

    • surveyingInfo: [any]

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

    Returns void

Static mapStart

  • mapStart(): void

Static mapStop

  • mapStop(): void

Static onLoaded

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

    category

    State Queries

    Returns Promise<any>

    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

    category

    State Queries

    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.

    category

    State Queries

    Returns Promise<void>

    returns a Promise that resolves when the game is loaded.

Static overrideMeshColor

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

    category

    Object Highlighting

    Parameters

    • account: string

      teamspace the meshes resides in

    • model: string

      model ID the meshes resides in

    • meshIDs: [string]

      unique IDs of the meshes to operate on

    • color: [number]

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

    Returns void

Static overrideMeshOpacity

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

    category

    Object Highlighting

    Parameters

    • account: string

      teamspace the meshes resides in

    • model: string

      model ID the meshes resides in

    • meshIDs: [string]

      unique IDs of the meshes to operate on

    • opacity: number

      opacity (>0 - 1) value to override with

    Returns void

Static pauseRendering

  • pauseRendering(): void

Static removeMapSource

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

    category

    GIS

    Parameters

    • mapSource: string

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

    Returns void

Static removePin

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

    category

    Pins

    Parameters

    • id: string

      pin identifier

    Returns void

Static requestScreenShot

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

    category

    Model Interactions

    Returns Promise<any>

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

Static requestViewpoint

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

    category

    Model Interactions

    Parameters

    • account: string

      name of teamspace

    • model: string

      name of model

    Returns Promise<any>

    returns a promises which will resolve with the viewpoint information

Static reset

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

    category

    Configurations

    Returns void

Static resetCamera

  • resetCamera(): void
  • Reset the viewpoint to ISO view.

    category

    Navigations

    Returns void

Static resetMapSources

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

    category

    GIS

    Returns void

Static resetMeshColor

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

    category

    Object Highlighting

    Parameters

    • account: string

      teamspace the meshes resides in

    • model: string

      model ID the meshes resides in

    • meshIDs: [string]

      unique IDs of the meshes to operate on

    Returns void

Static resetMeshOpacity

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

    category

    Object Highlighting

    Parameters

    • account: string

      teamspace the meshes resides in

    • model: string

      model ID the meshes resides in

    • meshIDs: [string]

      unique IDs of the meshes to operate on

    Returns void

Static resumeRendering

  • resumeRendering(): void

Static rightView

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

    category

    Navigations

    Returns void

Static selectPin

  • selectPin(id: string): void

Static setAPIHost

  • setAPIHost(hostname: [string]): 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

    category

    Configurations

    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.

    category

    Configurations

    Parameters

    • value: number

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

    Returns void

Static setNavigation

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

    category

    Navigations

    Parameters

    • navMode: any

      This can be either "HELICOPTER" or "TURNTABLE"

    Returns void

Static setNumCacheThreads

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

    category

    Configurations

    Parameters

    • thread: any

    Returns void

Static setRenderingQualityDefault

  • setRenderingQualityDefault(): void
  • Sets the render quality to default

    category

    Configurations

    Returns void

Static setRenderingQualityHigh

  • setRenderingQualityHigh(): void
  • Sets the render quality to high

    category

    Model Interactions

    Returns 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.

    category

    Configurations

    Parameters

    • units: any

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

    Returns void

Static setViewpoint

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

    category

    Navigations

    Parameters

    • pos: [number]

      3D point in space where the camera should be

    • up: [number]

      Up vector

    • forward: [number]

      forward vector

    • lookAt: [number]

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

    • Optional account: string

      name of teamspace

    • Optional model: string

      name of model

    Returns void

Static setXRayHighlightOff

  • setXRayHighlightOff(): any
  • Sets the highlighting to show xray

    category

    Model Interactions

    Returns any

Static setXRayHighlightOn

  • setXRayHighlightOn(): any
  • Sets the highlighting to show xray

    category

    Model Interactions

    Returns any

Static showCoordView

  • showCoordView(): void
  • Show x y z coordinates of current point

    category

    Configurations

    Returns void

Static showHiddenByDefaultObjects

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

    category

    Model Interactions

    Returns void

Static showProgressBar

  • showProgressBar(): void

Static startAreaSelection

  • startAreaSelection(): void
  • Start rectangular select

    category

    Object Highlighting

    Returns void

Static startBoxClip

  • startBoxClip(): void
  • Start clip editing in box mode

    category

    Clipping Plane

    Returns void

Static startClipEdit

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

    category

    Clipping Plane

    Returns void

Static startSingleClip

  • startSingleClip(): void
  • Start clip editing in single plane mode

    category

    Clipping Plane

    Returns void

Static stopAreaSelection

  • stopAreaSelection(): void
  • Stop rectangular select

    category

    Object Highlighting

    Returns void

Static stopClipEdit

  • stopClipEdit(): void
  • Stop editing mode

    category

    Clipping Plane

    Returns 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.

    category

    Configurations

    Returns void

Static toggleVisibility

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

    category

    Model Interactions

    Parameters

    • account: string

      name of teamspace

    • model: string

      name of model

    • ids: [string]

      list of unique ids to toggle visibility

    • visibility: boolean

      true = visible, false = invisible

    Returns void

Static topView

  • topView(): void
  • Reset the viewpoint to Top down view.

    category

    Navigations

    Returns void

Static unhighlightObjects

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

    category

    Object Highlighting

    Parameters

    • account: string

      name of teamspace

    • model: string

      name of model

    • idArr: [string]

      array of unique IDs associated with the objects to highlight

    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.

    category

    Model Interactions

    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
  • Zoom to highlighted meshes

    category

    Model Interactions

    Returns void

Static zoomToObjects

  • zoomToObjects(meshEntries: any[]): void

Generated using TypeDoc