Skip to main content

Editor

The Editor class provides functionality for editing and managing Fragments models. It handles operations like editing model elements, saving changes and managing edit history.

Properties

onEdit

onEdit: Event<object>

Event triggered when an edit is made.

Type declaration

modelId

modelId: string

Methods

_update()

_update(modelId): Promise<void>

Internal method to update the specified Fragments model. Do not use this method directly.

Parameters

ParameterTypeDescription
modelIdstringThe ID of the model to update.

Returns

Promise<void>


applyChanges()

applyChanges(modelId, elements): Promise<number[]>

Applies changes to the specified Fragments model.

Parameters

ParameterTypeDefault valueDescription
modelIdstringundefinedThe ID of the model to apply the changes to.
elementsElement[][]The elements to apply the changes to.

Returns

Promise<number[]>

The applied changes.


clearElementsRequests()

clearElementsRequests(modelId): null | EditRequest[]

Clears all the element edit requests of the specified Fragments model.

Parameters

ParameterTypeDescription
modelIdstringThe ID of the model to clear the requests from.

Returns

null | EditRequest[]


createCircleExtrusion()

createCircleExtrusion(modelId, data): string

Creates a circle extrusion in the specified Fragments model.

Parameters

ParameterTypeDescription
modelIdstringThe ID of the model to create the circle extrusion in.
dataRawCircleExtrusionThe data of the circle extrusion to create.

Returns

string

The created circle extrusion.


createElements()

createElements(modelId, elements): Promise<null | Element[]>

Creates elements in the specified Fragments model.

Parameters

ParameterTypeDescription
modelIdstringThe ID of the model to create the elements in.
elementsNewElementData[]The elements to create.

Returns

Promise<null | Element[]>

The created elements.


createGlobalTransform()

createGlobalTransform(modelId, transform, itemId): string

Creates a global transform in the specified Fragments model.

Parameters

ParameterTypeDescription
modelIdstringThe ID of the model to create the global transform in.
transformMatrix4The global transform to create.
itemIdstring | numberThe ID of the item to create the global transform for.

Returns

string

The created global transform.


createItem()

createItem(modelId, item): string

Creates an item in the specified Fragments model.

Parameters

ParameterTypeDescription
modelIdstringThe ID of the model to create the item in.
itemRawItemDataThe item to create.

Returns

string

The created item.


createLocalTransform()

createLocalTransform(modelId, transform): string

Creates a local transform in the specified Fragments model.

Parameters

ParameterTypeDescription
modelIdstringThe ID of the model to create the local transform in.
transformMatrix4The local transform to create.

Returns

string

The created local transform.


createMaterial()

createMaterial(modelId, material): string

Creates a material in the specified Fragments model.

Parameters

ParameterTypeDescription
modelIdstringThe ID of the model to create the material in.
materialMeshLambertMaterialThe material to create.

Returns

string

The created material.


createSample()

createSample(modelId, data): string

Creates a sample in the specified Fragments model.

Parameters

ParameterTypeDescription
modelIdstringThe ID of the model to create the sample in.
dataobjectThe data of the sample to create.
data.globalTransformstring | number-
data.localTransformstring | number-
data.materialstring | number-
data.representationstring | number-

Returns

string

The created sample.


createShell()

createShell(modelId, geometry): string

Creates a shell in the specified Fragments model.

Parameters

ParameterTypeDescription
modelIdstringThe ID of the model to create the shell in.
geometryBufferGeometry<NormalBufferAttributes>The geometry of the shell to create.

Returns

string

The created shell.


deleteData()

deleteData(modelId, data): Promise<void>

Deletes any type of data from the specified Fragments model.

Parameters

ParameterTypeDescription
modelIdstringThe ID of the model to delete the data from.
dataobjectThe data to delete.
data.filterInUse?boolean-
data.itemIds?Iterable<number>-
data.localTransformIds?Iterable<number>-
data.materialIds?Iterable<number>-
data.representationIds?Iterable<number>-
data.sampleIds?Iterable<number>-

Returns

Promise<void>

The deleted data.


deleteElements()

deleteElements(modelId, elements): void

Deletes elements in the specified Fragments model.

Parameters

ParameterTypeDescription
modelIdstringThe ID of the model to delete the elements in.
elementsElement[]The elements to delete.

Returns

void

The deleted elements.


edit()

edit(modelId, actions, config): Promise<number[]>

Edits a Fragments model.

Parameters

ParameterTypeDescription
modelIdstringThe ID of the model to edit.
actionsEditRequest[]The actions to perform on the model.
configobjectThe configuration for the edit.
config.removeRedoboolean-

Returns

Promise<number[]>

The IDs of the elements that were edited.


getElements()

getElements(modelId, localIds): Promise<Element[]>

Gets the elements of the specified Fragments model.

Parameters

ParameterTypeDescription
modelIdstringThe ID of the model to get the elements from.
localIdsIterable<number>The local IDs of the elements to get.

Returns

Promise<Element[]>

The elements of the model.


getModelRequests()

getModelRequests(modelId): Promise<object>

Gets the requests of the specified Fragments model. Useful for building a history menu.

Parameters

ParameterTypeDescription
modelIdstringThe ID of the model to get the requests from.

Returns

Promise<object>

The requests of the model.

requests

requests: EditRequest[]

undoneRequests

undoneRequests: EditRequest[]


relate()

relate(modelId, itemId, relationName, itemIds): Promise<void>

Relates an item to other items in the specified Fragments model.

Parameters

ParameterTypeDescription
modelIdstringThe ID of the model to relate the item in.
itemIdnumberThe ID of the item to relate.
relationNamestringThe name of the relation to relate.
itemIdsnumber[]The IDs of the items to relate.

Returns

Promise<void>

The related items.


reset()

reset(modelId): Promise<void>

Resets the edits of the specified Fragments model.

Parameters

ParameterTypeDescription
modelIdstringThe ID of the model to reset.

Returns

Promise<void>


save()

save(modelId): Promise<null | object>

Saves all the edits of the specified Fragments model. Useful for exporting the model with the edits applied. Similar to "Saving" the changes in a BIM app.

Parameters

ParameterTypeDescription
modelIdstringThe ID of the model to save.

Returns

Promise<null | object>

The requests that were saved.


selectRequest()

selectRequest(modelId, index): Promise<void>

Selects an edit request of the specified Fragments model to set the model in the state it was after the request was applied.

Parameters

ParameterTypeDescription
modelIdstringThe ID of the model to select the request from.
indexnumberThe index of the request to select.

Returns

Promise<void>

The selected request.


setItem()

setItem(modelId, item): void

Sets an item in the specified Fragments model.

Parameters

ParameterTypeDescription
modelIdstringThe ID of the model to set the item in.
itemItemDataThe item to set.

Returns

void

The set item.


unrelate()

unrelate(modelId, itemId, relationName, itemIds): Promise<void>

Removes a relation between an item and other items in the specified Fragments model.

Parameters

ParameterTypeDescription
modelIdstringThe ID of the model to unrelate the item in.
itemIdnumberThe ID of the item to unrelate.
relationNamestringThe name of the relation to unrelate.
itemIdsnumber[]The IDs of the items to unrelate.

Returns

Promise<void>

The unrelated items.