new Viewer(client, params)
Parameters:
Name | Type | Description | ||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
client |
The |
|||||||||||||
params |
An object containing viewer configuration parameters. Properties
|
Members
-
<readonly> draggers
-
List of names of available draggers:
Line
Text
Pan
Orbit
Zoom
ZoomWindow
OrbitAroundBuilding
MeasureLine
CuttingPlaneXAxis
CuttingPlaneYAxis
CuttingPlaneZAxis
Walk
-
options
-
VisualizeJS
parameters. -
visualizeJs
-
Returns
VisualizeJS
module instance. -
<readonly> visualizeJsUrl
-
VisualizeJS
library URL. Use configure() to change library URL.
Methods
-
activeDragger()
-
Returns active dragger instance or
null
if there is no active dragger. -
addMarkupEntity()
-
Add an empty markup entity to the overlay.
-
cancel()
-
Cancels asynchronous model loading started by open().
-
clear()
-
Unloads the model and clears the viewer.
-
clearOverlay()
-
Remove markup overlay.
-
clearSlices()
-
Remove all cutting planes.
-
colorizeAllMarkup(r, g, b)
-
Colorize all markup entities with the specified color.
Parameters:
Name Type Default Description r
255 Red
part of color.g
0 Green
part of color.b
0 Blue
part of color. -
colorizeSelectedMarkups(r, g, b)
-
Colorize all selected markup entities with the specified color.
Parameters:
Name Type Default Description r
255 Red
part of color.g
0 Green
part of color.b
0 Blue
part of color. -
configure(params)
-
Change the viewer configuration parameters.
Parameters:
Name Type Description params
An object containing new configuration parameters.
Properties
Name Type Description visualizeJsUrl
VisualizeJS
library URL. Set this URL to use your own library instance or leave it blank to use the default URL defined byClient.js
. -
createViewpoint()
-
Create a viewpoint. To add a viewpoint to the list of model viewpoints, use the Model.saveViewpoint() or File.saveViewpoint().
-
dispose()
-
Releases all resources allocated by this
Viewer
instance. Call this method before release theViewer
instance. -
drawViewpoint(viewpoint)
-
Draw a viewpoint. To get a list of available model viewpoints, use the Model.getViewpoints() or File.getViewpoints().
Parameters:
Name Type Description viewpoint
Viewpoint data.
-
executeCommand(id, args)
-
Executes the command denoted by the given command identifier.
Parameters:
Name Type Argument Description id
Identifier of the command to execute.
args
<repeatable>
Parameters passed to the command function.
Returns:
A returned value of the given command. Returns
undefined
when the command doesn't exists. -
getMarkupColor()
-
Get markup color.
Returns:
Color with
RGB
values. -
getSelected()
-
Returns a list of original handles for the selected entities.
-
<async> initialize(canvas, onProgress)
-
Load
VisualizeJS
module and initialize it with the specified canvas. Call dispose() to release allocated resources.Parameters:
Name Type Description canvas
HTML
<canvas>
element forVisualizeJS
.onProgress
A callback function that handles events measuring progress of loading of the
VisualizeJS
library. Retrieves visualizeprogress event. -
is3D()
-
Returns
true
if current drawing is 3D drawing. -
isInitialized()
-
Returns
true
ifVisualizeJS
module has been loaded andinitialized. -
<async> loadReferences(model)
-
Load model references into the viewer. References are images, fonts, or any other files to correct rendering of the model.
Parameters:
Name Type Description model
Instance of model with references. If a
File
instance is specified instead of a model, the file references will be loaded. -
<async> open(file)
-
Loads a model of a file or assembly into the viewer.
This method requires a Client instance to work. For standalone viewer instance use openVsfFile() or openVsfxFile().
Fires:
- open
- geometrystart
- geometryprogress
- databasechunk
- geometrychunk
- geometryend
- geometryerror
Parameters:
Name Type Description file
File or Assembly or Model instance to load. If a
File
instance with multiple models is specified, the default model will be loaded. If there is no default model, first availiable model will be loaded. -
openVsfFile(buffer)
-
Loads a VSF file into the viewer.
Fires:
- open
- geometrystart
- geometryprogress
- databasechunk
- geometryend
- geometryerror
Parameters:
Name Type Description buffer
Binary data buffer to load.
-
openVsfxFile(buffer)
-
Loads a VSFX file into the viewer.
Fires:
- open
- geometrystart
- geometryprogress
- databasechunk
- geometryend
- geometryerror
Parameters:
Name Type Description buffer
Binary data buffer to load.
-
registerDragger(name, dragger)
-
Register dragger on draggerFactory.
Parameters:
Name Type Description name
Dragger name.
dragger
Dragger class.
-
resetActiveDragger()
-
Reset the state of the active dragger.
-
scheduleUpdateAsync(maxScheduleUpdateTimeInMs, maxScheduleUpdateCount)
-
Update with internal schedule, need after change operation when have long update for update without lock UI
Parameters:
Name Type Default Description maxScheduleUpdateTimeInMs
50 Maximum time for one update, by default 30 ms
maxScheduleUpdateCount
Maximum count of schedule update
Returns:
return void Promise
-
setActiveDragger(name)
-
Set active dragger.
Viewer
must be initialized before enable dragger or exception is thrown.Fires:
- changeactivedragger
Parameters:
Name Type Description name
Dragger name. Can be one of the draggers list.
Returns:
Returns active dragger instance or
null
if there is no dragger with the given name. -
setMarkupColor(r, g, b)
-
Set markup color.
Parameters:
Name Type Default Description r
255 Red
part of color.g
0 Green
part of color.b
0 Blue
part of color. -
setSelected(handles)
-
Select model entities by original handles that are obtained using File.getProperties() or File.searchProperties() methods.
Fires:
- select
Parameters:
Name Type Description handles
The list of original handles.
-
syncOverlay()
-
Synchronize markup overlay.
-
update(force)
-
Updates the viewer. Do nothing if the auto-update mode is disabled in the constructor (use the
update
event to update viewer manually).Fires:
- update
Parameters:
Name Type Default Description force
false If
true
updates the viewer immidietly. Otherwise updates on next animation frame. Default isfalse
. -
visLib()
-
Returns
VisualizeJS
module instance. -
visViewer()
-
Returns
VisualizeJS
Viewer instance.