Skip to main content

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​

ParameterTypeDescription
modelIdstring-
modelDataUint8Array-
raw?booleanWhether modelData is raw (uncompressed) or deflated. If
omitted, it is auto-detected from the buffer (see isRawBuffer).

Returns​

SingleThreadedFragmentsModel

Accessors​

modelId​

get modelId(): string

The ID of the model.

Returns​

string


ready​

get ready(): 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​

ParameterTypeDefault valueDescription
requestsEditRequest[]undefined-
raw?booleantruewhether 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​

ParameterTypeDefault valueDescription
rawbooleanfalseWhether 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​

ParameterTypeDescription
idsnumber[]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​

ParameterTypeDescription
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​

ParameterTypeDescription
localIdsnumber[]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​

ParameterType
namestring
keyK

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​

ParameterType
namestring

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​

ParameterType
namestring
indexnumber

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​

ParameterType
namestring

Returns​

null | IndexArrayType<K>

Implementation of​

IFragmentsModel.getIndexKeys


getIndexNames()​

getIndexNames(): string[]

Get the names of every user-defined index stored on this model. See the ModelIndex schema for the supported shapes.

Returns​

string[]

Implementation of​

IFragmentsModel.getIndexNames


getIndexValues()​

getIndexValues<V>(name): null | V[]

Get the values of an index. Useful for inverse lookups.

Type parameters​

Type parameter
V extends string | number

Parameters​

ParameterType
namestring

Returns​

null | V[]

Implementation of​

IFragmentsModel.getIndexValues


getInverseIndexEntry()​

getInverseIndexEntry<K, V>(name, value): null | IndexArrayType<V>

Inverse lookup. Returns every key that maps to value.

Type parameters​

Type parameter
K extends string | number
V extends string | number

Parameters​

ParameterType
namestring
valueK

Returns​

null | IndexArrayType<V>

Implementation of​

IFragmentsModel.getInverseIndexEntry


getItemDrawChunks()​

getItemDrawChunks(localIds): object[]

Returns per-tile index-buffer chunks for the given items. Used by outline-style passes that share tile geometry and clip drawing to just the outlined samples. See VirtualFragmentsModel.getItemDrawChunks.

Parameters​

ParameterType
localIdsIterable<number>

Returns​

object[]

Implementation of​

IFragmentsModel.getItemDrawChunks


getItems()​

getItems(localIds?): Map<number, RawItemData>

Gets the items of the model.

Parameters​

ParameterTypeDescription
localIds?Iterable<number>The local IDs of the items to get. If undefined, it will return all items.

Returns​

Map<number, RawItemData>

Implementation of​

IFragmentsModel.getItems


getItemsByQuery()​

getItemsByQuery(params, config?): number[]

Query items based on specified parameters.

Parameters​

ParameterTypeDescription
paramsItemsQueryParamsThe query parameters.
config?ItemsQueryConfigOptional query configuration.

Returns​

number[]

Implementation of​

IFragmentsModel.getItemsByQuery


getItemsChildren()​

getItemsChildren(ids): number[]

Get the spatial structure children of the specified items.

Parameters​

ParameterTypeDescription
idsIdentifier[]The IDs of the items to look up.

Returns​

number[]

Implementation of​

IFragmentsModel.getItemsChildren


getItemsData()​

getItemsData(ids, config?): ItemData[]

Get all the data of the specified items.

Parameters​

ParameterTypeDescription
idsnumber[]The IDs of the items to look up.
config?Partial <ItemsDataConfig>The configuration of the items data.

Returns​

ItemData[]

Implementation of​

IFragmentsModel.getItemsData


getItemsGeometry()​

getItemsGeometry(localIds, lod?): MeshData[][]

Get geometry data for the specified items.

Parameters​

ParameterTypeDescription
localIdsnumber[]The local IDs of the items to get geometry for.
lod?CurrentLodThe level of detail for the geometry (optional).

Returns​

MeshData[][]

Implementation of​

IFragmentsModel.getItemsGeometry


getItemsIds()​

getItemsIds(): number[]

Gets all the items IDs of the model.

Returns​

number[]

Implementation of​

IFragmentsModel.getItemsIds


getItemsIdsWithGeometry()​

getItemsIdsWithGeometry(): number[]

Get all the items of the model that have geometry.

Returns​

number[]

Implementation of​

IFragmentsModel.getItemsIdsWithGeometry


getItemsOfCategories()​

getItemsOfCategories(categories): object

Get all the items of the model that belong to the specified category.

Parameters​

ParameterType
categoriesRegExp[]

Returns​

object

Implementation of​

IFragmentsModel.getItemsOfCategories


getItemsWithGeometry()​

getItemsWithGeometry(): number[]

Returns​

number[]

Deprecated​

use getItemsIdsWithGeometry


getLocalIds()​

getLocalIds(): number[]

Get all the local IDs of the model.

Returns​

number[]

Implementation of​

IFragmentsModel.getLocalIds


getLocalIdsByGuids()​

getLocalIdsByGuids(guids): (null | number)[]

Get the local IDs corresponding to the specified GUIDs.

Parameters​

ParameterTypeDescription
guidsstring[]Array of GUIDs to look up.

Returns​

(null | number)[]

Implementation of​

IFragmentsModel.getLocalIdsByGuids


getLocalIdsFromItemIds()​

getLocalIdsFromItemIds(itemIds): number[]

Translate internal itemIds into user-facing localIds, preserving order. See VirtualFragmentsModel.getLocalIdsFromItemIds.

Parameters​

ParameterType
itemIdsIterable<number>

Returns​

number[]

Implementation of​

IFragmentsModel.getLocalIdsFromItemIds


getLocalTransforms()​

getLocalTransforms(localIds?): Map<number, RawTransformData>

Gets the local transforms of the model.

Parameters​

ParameterTypeDescription
localIds?Iterable<number>The local IDs of the local transforms to get. If undefined, it will return all local transforms.

Returns​

Map<number, RawTransformData>

Implementation of​

IFragmentsModel.getLocalTransforms


getLocalTransformsIds()​

getLocalTransformsIds(): number[]

Gets all the local transforms IDs of the model.

Returns​

number[]

Implementation of​

IFragmentsModel.getLocalTransformsIds


getMaterials()​

getMaterials(localIds?): Map<number, RawMaterial>

Gets the materials of the model.

Parameters​

ParameterTypeDescription
localIds?Iterable<number>The local IDs of the materials to get. If undefined, it will return all materials.

Returns​

Map<number, RawMaterial>

Implementation of​

IFragmentsModel.getMaterials


getMaterialsIds()​

getMaterialsIds(): number[]

Gets all the materials IDs of the model.

Returns​

number[]

Implementation of​

IFragmentsModel.getMaterialsIds


getMaxLocalId()​

getMaxLocalId(): number

Get the maximum local ID of the model.

Returns​

number

Implementation of​

IFragmentsModel.getMaxLocalId


getMetadata()​

getMetadata<T>(): T

Get the metadata of the model.

Type parameters​

Type parameterValue
T extends Record<string, any>Record<string, any>

Returns​

T

Implementation of​

IFragmentsModel.getMetadata


getPositions()​

getPositions(localIds?): object[]

Get the absolute positions of the specified items.

Parameters​

ParameterTypeDescription
localIds?number[]The local IDs of the items to look up.

Returns​

object[]

Implementation of​

IFragmentsModel.getPositions


getRelations()​

getRelations(localIds?): Map<number, RawRelationData>

Gets the relations of the model.

Parameters​

ParameterTypeDescription
localIds?number[]The local IDs of the relations to get. If undefined, it will return all relations.

Returns​

Map<number, RawRelationData>

Implementation of​

IFragmentsModel.getRelations


getRepresentations()​

getRepresentations(localIds?): Map<number, RawRepresentation>

Gets the representations of the model.

Parameters​

ParameterTypeDescription
localIds?Iterable<number>The local IDs of the representations to get. If undefined, it will return all representations.

Returns​

Map<number, RawRepresentation>

Implementation of​

IFragmentsModel.getRepresentations


getRepresentationsIds()​

getRepresentationsIds(): number[]

Gets all the representations IDs of the model.

Returns​

number[]

Implementation of​

IFragmentsModel.getRepresentationsIds


getRequests()​

getRequests(): object

Get the current edit history (applied requests + undone redo stack).

Returns​

object

requests​

requests: EditRequest[]

undoneRequests​

undoneRequests: EditRequest[]


getSamples()​

getSamples(localIds?): Map<number, RawSample>

Gets the samples of the model.

Parameters​

ParameterTypeDescription
localIds?Iterable<number>The local IDs of the samples to get. If undefined, it will return all samples.

Returns​

Map<number, RawSample>

Implementation of​

IFragmentsModel.getSamples


getSamplesIds()​

getSamplesIds(): number[]

Gets all the samples IDs of the model.

Returns​

number[]

Implementation of​

IFragmentsModel.getSamplesIds


getSection()​

getSection(plane, localIds?): ModelSection

Gets the section (edges and fills) between the model and a given clipping plane.

Parameters​

ParameterTypeDescription
planePlaneThe plane to get the section of.
localIds?number[]The local IDs of the items to get the section of. If undefined, it will return the section of all items.

Returns​

ModelSection

Implementation of​

IFragmentsModel.getSection


getSpatialStructure()​

getSpatialStructure(): any

Get the spatial structure of the model.

Returns​

any

Implementation of​

IFragmentsModel.getSpatialStructure


getSubsetBuffer()​

getSubsetBuffer(localIds, raw): Uint8Array

Get a buffer containing only the specified items and their associated geometry.

Parameters​

ParameterTypeDefault valueDescription
localIdsnumber[]undefinedThe local IDs of the items to include.
rawbooleanfalseWhether to get the raw buffer. If false, it will be compressed.

Returns​

Uint8Array

Implementation of​

IFragmentsModel.getSubsetBuffer


hasIndexEntry()​

hasIndexEntry<K>(name, key): boolean

Test whether a key exists in the named index without resolving its value.

Type parameters​

Type parameter
K extends string | number

Parameters​

ParameterType
namestring
keyK

Returns​

boolean

Implementation of​

IFragmentsModel.hasIndexEntry


redo()​

redo(): void

Redo the last undone edit.

Returns​

void


reset()​

reset(): void

Discard all pending edits on this model.

Returns​

void


save()​

save(raw?): Uint8Array

Flatten the current pending-edit history into a new committed buffer.

Parameters​

ParameterTypeDefault valueDescription
raw?booleantruewhether to return the raw buffer or the the result of pako.deflate. Defaults to true.

Returns​

Uint8Array

The raw/deflated flatbuffer bytes of the updated model.


selectRequest()​

selectRequest(index): void

Navigate to a specific point in the edit history by index.

Parameters​

ParameterType
indexnumber

Returns​

void


setRequests()​

setRequests(data): void

Replace the edit history with a caller-provided one. Useful for restoring state from disk.

Parameters​

ParameterType
dataobject
data.requests?EditRequest[]
data.undoneRequests?EditRequest[]

Returns​

void


undo()​

undo(): void

Undo the last edit.

Returns​

void