SingleThreadedFragmentsModel
The main class for managing a 3D model loaded from a fragments file in a single thread. It's designed for easy data querying in the backend, so all the 3D visualization logic is not present.
Implements
IFragmentsModel<false>
Constructors
new SingleThreadedFragmentsModel()
new SingleThreadedFragmentsModel(
modelId,modelData,raw?):SingleThreadedFragmentsModel
The constructor of the fragments model.
Parameters
| Parameter | Type | Description |
|---|---|---|
modelId | string | - |
modelData | Uint8Array | - |
raw? | boolean | Whether modelData is raw (uncompressed) or deflated. If |
| omitted, it is auto-detected from the buffer (see isRawBuffer). |
Returns
Accessors
modelId
getmodelId():string
The ID of the model.
Returns
string
ready
getready():Promise<void>
Resolves when the model is fully set up. The constructor starts an asynchronous setup that spans multiple macrotasks; await this before relying on the model being completely initialized.
If dispose is called while the setup is still running, this promise rejects with a LoadAbortedError. If nobody awaits it, the rejection is already handled internally, so it never surfaces as an unhandled rejection.
Returns
Promise<void>
Methods
dispose()
dispose():
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.
If the setup started by the constructor is still running, it is aborted at its next yield point and ready rejects with a LoadAbortedError. Calling this more than once is a no-op.
Returns
void
Implementation of
IFragmentsModel.dispose
edit()
edit(
requests,raw?):object
Apply a batch of edit requests. Accumulates onto this model's pending-edit history; call save to flatten them into a new committed buffer or reset to discard.
Parameters
| Parameter | Type | Default value | Description |
|---|---|---|---|
requests | EditRequest[] | undefined | - |
raw? | boolean | true | whether to return the raw buffer or the the result of pako.deflate. Defaults to true. |
Returns
object
The delta raw/deflated flatbuffer bytes and the local IDs assigned to any newly-created items.
deltaModelBuffer
deltaModelBuffer:
Uint8Array=model
ids
ids:
number[]
getBuffer()
getBuffer(
raw):ArrayBufferLike
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
ArrayBufferLike
Implementation of
IFragmentsModel.getBuffer
getCRS()
getCRS():
any
Get the Coordinate Reference System (CRS) data of the model, if available.
Returns
any
Implementation of
IFragmentsModel.getCRS
getCategories()
getCategories():
string[]
Get all the categories of the model.
Returns
string[]
Implementation of
IFragmentsModel.getCategories
getCoordinates()
getCoordinates():
number[]
Gets coordinates of the model.
Returns
number[]
Implementation of
IFragmentsModel.getCoordinates
getGlobalTranformsIdsOfItems()
getGlobalTranformsIdsOfItems(
ids):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
number[]
Implementation of
IFragmentsModel.getGlobalTranformsIdsOfItems
getGlobalTransforms()
getGlobalTransforms(
localIds?):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
Map<number, RawGlobalTransformData>
Implementation of
IFragmentsModel.getGlobalTransforms
getGlobalTransformsIds()
getGlobalTransformsIds():
number[]
Gets all the global transforms IDs of the model.
Returns
number[]
Implementation of
IFragmentsModel.getGlobalTransformsIds
getGuidsByLocalIds()
getGuidsByLocalIds(
localIds): (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
(null | string)[]
Implementation of
IFragmentsModel.getGuidsByLocalIds
getIndexEntry()
getIndexEntry<
K,V>(name,key):null|V
Forward lookup of a single entry in the named index. The return shape depends on the index mode.
Type parameters
| Type parameter |
|---|
K extends string | number |
V extends IndexEntry |
Parameters
| Parameter | Type |
|---|---|
name | string |
key | K |
Returns
null | V
Implementation of
IFragmentsModel.getIndexEntry
getIndexInfo()
getIndexInfo(
name):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
null | IndexInfo
Implementation of
IFragmentsModel.getIndexInfo
getIndexKey()
getIndexKey<
K>(name,index):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 |
Parameters
| Parameter | Type |
|---|---|
name | string |
index | number |
Returns
null | K
Implementation of
IFragmentsModel.getIndexKey
getIndexKeys()
getIndexKeys<
K>(name):null|IndexArrayType<K>
Get the keys of an index. Useful for keys-only indexes (membership tests,
iteration) but valid for any mode. Number keys come back as a
Uint32Array, string keys as string[].
Type parameters
| Type parameter |
|---|
K extends string | number |
Parameters
| Parameter | Type |
|---|---|
name | string |