Model
new Model()
Core class representing the geometry.
Methods
getInstanceTree()
Returns
| type | description |
|---|---|
| InstanceTree | Instance tree of the model if available, otherwise null. |
getFragmentMap()
Returns
getBoundingBox()
Returns
| type | description |
|---|---|
| THREE.Box3 | Bounding box of the model if available, otherwise null. |
is2d()
Returns
| type | description |
|---|---|
| boolean | Whether the model is 2D. |
is3d()
Returns
| type | description |
|---|---|
| boolean | Whether the model is 3D. |
isOTG()
Returns
| type | description |
|---|---|
| boolean | true if the model is an OTG file - which supports sharing of materials and geometry. |
getData()
Returns the geometry data.
getDocumentNode()
Returns an object wrapping the bubble/manifest entry for the loaded geometry. Contains data such as the viewableID, guid, role…
Returns
getRoot()
Returns the root of the geometry node graph.
Returns
| type | description |
|---|---|
| object | The root of the geometry node graph. Null if it doesn’t exist. |
getRootId()
Returns the root of the geometry node graph.
Returns
| type | description |
|---|---|
| number | The ID of the root or null if it doesn’t exist. |
getUnitData(unit)
Returns an object that contains the standard unit string (unitString) and the scale value (unitScale).
Parameters
| unit* string | Unit name from the metadata |
Returns
| type | description |
|---|---|
| object | this object contains the standardized unit string (unitString) and a unit scaling value (unitScale) |
getUnitScale()
Returns the scale factor of model’s distance unit to meters.
Returns
| type | description |
|---|---|
| number | The scale factor of the model’s distance unit to meters or unity if the units aren’t known. |
getUnitString()
Returns a standard string representation of the model’s distance unit.
Returns
| type | description |
|---|---|
| string | Standard representation of model’s unit distance or null if it is not known. |
getDisplayUnit()
Returns a standard string representation of the model’s display unit.
Returns
| type | description |
|---|---|
| string | Standard representation of model’s display unit or null if it is not known. |
getMetadata(itemName, subitemName, defaultValue)
Return metadata value.
Parameters
| itemName* string | Metadata item name. |
| subitemName string | Metadata subitem name. |
| defaultValue | Default value. |
Returns
| type | description |
|---|---|
| Metadata value, or defaultValue if no metadata or metadata item/subitem does not exist. |
getDefaultCamera()
Returns the default camera.
isAEC()
Returns
| type | description |
|---|---|
| boolean | true when the "AEC" loader settings were used when loading the model |
getUpVector()
Returns up vector as an array of 3.
geomPolyCount()
Returns the polygon count.
Returns
| type | description |
|---|---|
| number |
instancePolyCount()
Returns the instanced polygon count.
Returns
| type | description |
|---|---|
| number |
isLoadDone()
Returns true if the model with all its geometries has loaded.
Returns
| type | description |
|---|---|
| boolean |
isObjectTreeCreated()
Returns true if the frag to node id mapping is done.
Returns
| type | description |
|---|---|
| boolean |
getPropertyDb()
Returns an instance of PropertyDatabase Loader, responsible for communicating with the PropertyDatabase instance hosted in a browser worker thread.
Returns
| type | description |
|---|---|
| PropDbLoader |
getProperties(dbId, onSuccessCallback, onErrorCallback)
Asyncronous method that gets object properties
Parameters
| dbId* number | The database identifier. |
| onSuccessCallback Callbacks#onPropertiesSuccess | Callback for when the properties are fetched. |
| onErrorCallback Callbacks#onGenericError | Callback for when the properties are not found or another error occurs. |
getBulkProperties(dbIds, options, onSuccessCallback, onErrorCallback)
Returns properties for multiple objects with an optional filter on which properties to retrieve.
Parameters
getExternalIdMapping(onSuccessCallback, onErrorCallback)
Returns an object with key values being dbNodeIds and values externalIds. Useful to map LMV node ids to Fusion node ids.
Parameters
| onSuccessCallback* function | This method is called when request for property db succeeds. |
| onErrorCallback* function | This method is called when request for property db fails. |
getLayerToNodeIdMapping(onSuccessCallback, onErrorCallback)
Returns an object with key values being layer names, pointing to Arrays containing dbIds.
Parameters
| onSuccessCallback* function | This method is called when request for property db succeeds. |
| onErrorCallback* function | This method is called when request for property db fails. |
getObjectTree(onSuccessCallback, onErrorCallback)
Asyncronous operation that gets a reference to the object tree.
You can use the model object tree to get information about items in the model. The tree is made up of nodes, which correspond to model components such as assemblies or parts.
Parameters
| onSuccessCallback Callbacks#onObjectTreeSuccess | Success callback invoked once the object tree is available. |
| onErrorCallback Callbacks#onGenericError | Error callback invoked when the object tree is not found available. |
isObjectTreeLoaded()
Returns true only when the object tree is loaded into memory.
Will return false while the object tree is still loading,
or when the object tree fails to load.
Returns
| type | description |
|---|---|
| boolean |
search(text, onSuccessCallback, onErrorCallback, attributeNames)
Async operation to search the object property database.
Parameters
| text* string | The search term (not case sensitive). |
| onSuccessCallback* Callbacks#onSearchSuccess | Invoked when the search results are ready. |
| onErrorCallback* Callbacks#onGenericError | Invoke when an error occured during search. |
| attributeNames Array.<string> | Restricts search to specific attribute names. |
findProperty(propertyName)
Searches the property database for all dbIds that contains a specific property name.
Parameters
| propertyName* string | The property name to search for (case sensitive). |
Returns
| type | description |
|---|---|
| Promise | that resolves with an Array of dbIds containing the specified property. |
getTopology(index)
Return topology data of one fragment.
Requires topology data to have been fetched with [fetchTopology()]`Autodesk.Viewing.Model#fetchTopology </en/docs/viewer/v6/reference/Viewing/Model/#fetchTopology/>`_.
Parameters
| index* number | Topology index. |
Returns
| type | description |
|---|---|
| object | Topology data. |
hasTopology()
See also [fetchTopology()]`Autodesk.Viewing.Model#fetchTopology </en/docs/viewer/v6/reference/Viewing/Model/#fetchTopology/>`_.
Returns
| type | description |
|---|---|
| boolean | true if topology data has been downloaded and is available in memory |
fetchTopology(maxSizeMB)
Downloads the topology file, if one is available. The file may not get downloaded if the topology content size in memory is bigger than a specified limit (100 MB by default, 20 MB for mobile).
Parameters
| maxSizeMB number | Maximum uncompressed topology size allowed (in MegaBytes). |
Returns
| type | description |
|---|---|
| Promise | that resolves with the topology object. |
hasGeometry()
Returns
| type | description |
|---|---|
| boolean | true if the model loaded contains at least 1 fragment. |