FragmentsModel
The main class for managing a 3D model loaded from a fragments file. Handles geometry, materials, visibility, highlighting, sections, and more. This class orchestrates multiple specialized managers to handle different aspects of the model like mesh management, item data, raycasting, etc. It maintains the overall state and provides the main interface for interacting with the model. The model data is loaded and processed asynchronously across multiple threads.
Implements
IFragmentsModel<true>
Constructors
new FragmentsModel()
new FragmentsModel(
modelId,meshManager,threads,editor,threadGroup?):FragmentsModel
The constructor of the fragments model. Don't use this directly. Use the FragmentsModels.load instead.
Parameters
| Parameter | Type |
|---|---|
modelId | string |
meshManager | MeshManager |
threads | FragmentsConnection |
editor | Editor |
threadGroup? | string |
Returns
Properties
attrsChanges
readonlyattrsChanges:Map<number,AttrsChange>
A map of attribute changes that have occurred in the model. The key is the local ID of the item, and the value is the change.
graphicsQuality
graphicsQuality:
number=0
The graphics quality of the model. It ranges from 0 (lowest) to 1 (highest).
object
object:
Object3D<Object3DEventMap>
The object that represents the model in the Three.js scene.
onViewUpdated
readonlyonViewUpdated:Event<FragmentsModel>
Event triggered after a view update cycle finishes processing. Listeners receive this FragmentsModel instance, allowing queries like getItemsByVisibility to retrieve seen/unseen elements.
relsChanges
readonlyrelsChanges:Map<number,RelsModifyChange>
A map of relation changes that have occurred in the model. The key is the local ID of the item, and the value is the change.
threadGroup
readonlythreadGroup:undefined|string
The thread group this model was loaded into, or undefined if it was
loaded into the default pool. Set once at load time, never changes.
threads
readonlythreads:FragmentsConnection
The connection to the threads that handle the model data.
tiles
readonlytiles:DataMap<string|number,BIMMesh>
A map of tiles that have been loaded for the model. The key is the tile ID, and the value is the tile.
visibleItems
readonlyvisibleItems:Set<number>
A set of item IDs that are currently visible (i.e. have at least one tile rendered on screen). Updated automatically as tiles are created and deleted by the mesh manager.
Accessors
box
getbox():Box3
The bounding box of the whole model.
Returns
Box3
clippingPlanes
getclippingPlanes():Plane[]
The clipping planes the model culls against, in world space. This is the
array passed to useClippingPlanes (or the clippingPlanes load
option) itself, not a copy.
Returns
Plane[]
frozen
getfrozen():boolean
Whether the model should stop updating..
setfrozen(value):void
Whether the model should stop updating..
Parameters
| Parameter | Type |
|---|---|
value | boolean |
Returns
boolean
getClippingPlanesEvent
getgetClippingPlanesEvent(): () =>Plane[]
The event that is triggered when the clipping planes are needed in the thread. Set this method to pass your Three.js clipping planes to the model.
Deprecated
Pass the planes with the clippingPlanes option of
FragmentsModels.load, or call useClippingPlanes after
loading. This callback keeps working; whichever of the two was set last
is the one the model uses.
setgetClippingPlanesEvent(value):void
The event that is triggered when the clipping planes are needed in the thread. Set this method to pass your Three.js clipping planes to the model.
Deprecated
Pass the planes with the clippingPlanes option of
FragmentsModels.load, or call useClippingPlanes after
loading. This callback keeps working; whichever of the two was set last
is the one the model uses.
Parameters
| Parameter | Type |
|---|---|
value | () => Plane[] |
Returns
Function
Returns
Plane[]
isBusy
getisBusy():boolean
Whether the model is busy loading data.
Returns
boolean
modelId
getmodelId():string
The ID of the model.
Returns
string
Methods
_edit()
_edit(
requests):Promise<object>
Internal method to edit the model. Don't use this directly.
Parameters
| Parameter | Type | Description |
|---|---|---|
requests | EditRequest[] | The requests to edit the model. |
Returns
Promise<object>
deltaModelBuffer
deltaModelBuffer:
Uint8Array
ids
ids:
number[]
_finishProcessing()
_finishProcessing():
void
Internal method to finish processing. Don't use this directly.
Returns
void
_getItemSnapData()
_getItemSnapData(
itemId):Promise<null|ElementData>
Fast snap-only fetch keyed by itemId. See
EditManager.getItemSnapData. Internal — picker / SnapResolver
consume this. App code should keep using _getElements (localId).
Parameters
| Parameter | Type |
|---|---|
itemId | number |
Returns
Promise<null | ElementData>
_getRequests()
_getRequests():
Promise<object>
Internal method to get the requests of the model. Don't use this directly.
Returns
Promise<object>
requests
requests:
EditRequest[]
undoneRequests
undoneRequests:
EditRequest[]
_refreshView()
_refreshView(
force):Promise<void>
Internal method to refresh the view of the model. You shouldn't call this directly. Instead, use FragmentsModels.update.
Parameters
| Parameter | Type | Default value |
|---|---|---|
force | boolean | false |
Returns
Promise<void>
_reset()
_reset():
Promise<void>
Internal method to reset the model. Don't use this directly.
Returns
Promise<void>
_save()
_save():
Promise<Uint8Array>
Internal method to save the model. Don't use this directly.
Returns
Promise<Uint8Array>
_selectRequest()
_selectRequest(
index):Promise<void>
Internal method to select a request of the model. Don't use this directly.
Parameters
| Parameter | Type | Description |
|---|---|---|
index | number | The index of the request to select. |
Returns
Promise<void>
_setRequests()
_setRequests(
data):Promise<void>
Internal method to set the requests of the model. Don't use this directly.
Parameters
| Parameter | Type | Description |
|---|---|---|
data | object | The data to set the requests of the model. |
data.requests? | EditRequest[] | - |
data.undoneRequests? | EditRequest[] | - |
Returns
Promise<void>
_setup()
_setup(
data,raw?,config?):Promise<void>
Internal method to set up the model. Don't use this directly.
Parameters
| Parameter | Type |
|---|---|
data | Uint8Array | ArrayBuffer |
raw? | boolean |
config? | VirtualModelConfig |
Returns
Promise<void>
dispose()
dispose(
options?):Promise<void>
Dispose the model. Use this when you're done with the model. If you use the FragmentsModels.dispose method, this will be called automatically for all models.
Parameters
| Parameter | Type | Description |
|---|---|---|
options? | object | - |
options.keepInScene? | boolean | If true, frees the model's worker slot, registry entries and shared MaterialManager slot but leaves the THREE object, tiles, materials in Caller must finalize the visual cleanup later via finalizeDispose. Used by loaded model without a blank frame. |
Returns
Promise<void>
Implementation of
IFragmentsModel.dispose
finalizeDispose()
finalizeDispose():
void
Finalize a deferred dispose. Removes the THREE object from its parent, tears down tile meshes (geometry only — materials are shared via the MaterialManager and may be reused by a replacement model under the same modelId), and disposes the model's alignments and grids.
Only call this after dispose({ keepInScene: true }). The tile map
is cleared with events disabled to bypass the onBeforeDelete listener
registered in the constructor (which would otherwise dispose tile
materials).
Returns
void
getAlignmentStyles()
getAlignmentStyles():
Promise<object>
Get the civil alignment styles of the model (if any).
Returns
Promise<object>
exterior
exterior:
PointsMaterial
interior
interior:
PointsMaterial
getAlignments()
getAlignments():
Promise<Group<Object3DEventMap>>
Get the absolute alignments of the model (if any).
Returns
Promise<Group<Object3DEventMap>>
getAttributeNames()
getAttributeNames():
Promise<string[]>
Retrieves the names of all attributes associated with the model.
Returns
Promise<string[]>
A promise that resolves to an array of strings, where each string is the name of an attribute.
getAttributeTypes()
getAttributeTypes():
Promise<string[]>
Retrieves the attribute types associated with the model.
Returns
Promise<string[]>
A promise that resolves to an array of attribute types.
getAttributeValues()
getAttributeValues():
Promise<any[]>
Retrieves the attribute values associated with the model.
Returns
Promise<any[]>
A promise that resolves to an array of attribute values.
getBoxes()
getBoxes(
localIds?):Promise<Box3[]>
Get the individual bounding boxes of the specified items.
Parameters
| Parameter | Type | Description |
|---|---|---|
localIds? | number[] | The local IDs of the items to look up. |
Returns
Promise<Box3[]>
getBuffer()
getBuffer(
raw):Promise<ArrayBuffer>
Get the buffer of the model.
Parameters
| Parameter | Type | Default value | Description |
|---|---|---|---|
raw | boolean | false | Whether to get the raw buffer. If false, it will be compressed. |
Returns
Promise<ArrayBuffer>
Implementation of
IFragmentsModel.getBuffer
getCRS()
getCRS():
Promise<null|CRSData>
Get the Coordinate Reference System (CRS) data of the model, if available. Returns null if the source IFC file did not contain IFCPROJECTEDCRS or IFCCOORDINATEREFERENCESYSTEM entities.
Returns
Promise<null | CRSData>
Implementation of
IFragmentsModel.getCRS
getCategories()
getCategories():
Promise<string[]>
Get all the categories of the model.
Returns
Promise<string[]>
Implementation of
IFragmentsModel.getCategories
getCoordinates()
getCoordinates():
Promise<number[]>
Gets coordinates of the model.
Returns
Promise<number[]>
Implementation of
IFragmentsModel.getCoordinates
getCoordinationMatrix()
getCoordinationMatrix():
Promise<Matrix4>
Retrieves the coordination matrix for the current model.
This method utilizes the _coordinatesManager to compute and return a
THREE.Matrix4 object based on the original model coordinates.
Returns
Promise<Matrix4>
getEditedElements()
getEditedElements():
Promise<number[]>
Gets the edited elements of the model.
Returns
Promise<number[]>
getGlobalTranformsIdsOfItems()
getGlobalTranformsIdsOfItems(
ids):Promise<number[]>
Gets the global transforms IDs of the items of the model.
Parameters
| Parameter | Type | Description |
|---|---|---|
ids | number[] | The local IDs of the items to get the global transforms IDs of. |
Returns
Promise<number[]>
Implementation of
IFragmentsModel.getGlobalTranformsIdsOfItems
getGlobalTransforms()
getGlobalTransforms(
localIds?):Promise<Map<number,RawGlobalTransformData>>
Gets the global transforms of the model.
Parameters
| Parameter | Type | Description |
|---|---|---|
localIds? | Iterable<number> | The local IDs of the global transforms to get. If undefined, it will return all global transforms. |
Returns
Promise<Map<number, RawGlobalTransformData>>
Implementation of
IFragmentsModel.getGlobalTransforms
getGlobalTransformsIds()
getGlobalTransformsIds():
Promise<number[]>
Gets all the global transforms IDs of the model.
Returns
Promise<number[]>
Implementation of
IFragmentsModel.getGlobalTransformsIds
getGridLabelMaterial()
getGridLabelMaterial():
Material
The shared material used to render every grid axis label.
Mutating its properties (color, opacity, dash sizes, etc.) updates all
rendered grid labels immediately. Use setGridLabelMaterial to swap to a
different material instance.
Returns
Material
getGridMaterial()
getGridMaterial():
LineBasicMaterial
The shared material used to render every grid axis line.
Mutating its properties (color, opacity, dash sizes, etc.) updates all
rendered grid lines immediately. Use setGridMaterial to swap to a
different material instance.
Returns
LineBasicMaterial
getGrids()
getGrids(
config?):Promise<Group<Object3DEventMap>>
Get the grids of the model (if any).
Returns a THREE.Group with one child per grid (each child is a THREE.Group
that carries userData.id = localId and userData.kind = "grid").
Each grid's children are THREE.Group instances with userData.kind = "axis",
acting as an axis container.
A THREE.LINE instance with userData.kind = "line" is appended to it.
When opting in to showing labels, two THREE.SHAPE instances with
userData.kind = "label" and userData.index (the label's index, 0 or 1)
are appended to the axis container.
All grid's descendants ("axis", "line", "label") carry userData.tag (the axis label value)
and userData.axis ("uAxes", "vAxes", or "wAxes").
Parameters
| Parameter | Type |
|---|---|
config? | GridsConfig |
Returns
Promise<Group<Object3DEventMap>>
getGuidsByLocalIds()
getGuidsByLocalIds(
localIds):Promise<(null|string)[]>
Get the GUIDs corresponding to the specified local IDs.
Parameters
| Parameter | Type | Description |
|---|---|---|
localIds | number[] | Array of local IDs to look up. |
Returns
Promise<(null | string)[]>
Implementation of
IFragmentsModel.getGuidsByLocalIds
getHighlight()
getHighlight(
localIds?):Promise<MaterialDefinition[]>
Gets the highlight of the specified items.
Parameters
| Parameter | Type | Description |
|---|---|---|
localIds? | number[] | The local IDs of the items to get the highlight of. If undefined, it will return the highlight of all items. |
Returns
Promise <MaterialDefinition[]>
getHighlightItemIds()
getHighlightItemIds():
Promise<number[]>
Gets the item IDs of the items that are highlighted.
Returns
Promise<number[]>
getHorizontalAlignments()
getHorizontalAlignments():
Promise<Group<Object3DEventMap>>
Get the horizontal alignments of the model (if any).
Returns
Promise<Group<Object3DEventMap>>
getIndexEntry()
getIndexEntry<
K,V>(name,key):Promise<null|V>
Forward lookup of a single entry in the named index. The return shape depends on the index mode (see IndexEntry).
Type parameters
| Type parameter |
|---|
K extends string | number |
V extends IndexEntry |
Parameters
| Parameter | Type |
|---|---|
name | string |
key | K |
Returns
Promise<null | V>
Implementation of
IFragmentsModel.getIndexEntry
getIndexInfo()
getIndexInfo(
name):Promise<null|IndexInfo>
Describe the shape of a named index without performing any lookups.
Returns null if no index with that name exists.
Parameters
| Parameter | Type |
|---|---|
name | string |
Returns
Promise<null | IndexInfo>
Implementation of
IFragmentsModel.getIndexInfo
getIndexKey()
getIndexKey<
K>(name,index):Promise<null|K>
Get key at given index. Useful for keys-only indexes but valid for any mode.
Type parameters
| Type parameter |
|---|
K extends string | number |