Skip to main content

Type Alias: ModelContainer

ModelContainer = object

Wraps functionality for interacting with models in the scene.

Properties​

metadata​

metadata: Map<string, any>

Custom metadata associated with the model.


position​

position: Vector

The position of the model, in scene space.


rotation​

rotation: Vector

The rotation of the model, in scene space.


scale​

scale: Vector

The scale of the model, in scene space.

Methods​

applyMaterialVariant()​

applyMaterialVariant(targetMaterial, key, material, removeWhenUndefined?): Promise<void>

Applies a given material modifier to a target material in the scene.

Parameters​

targetMaterial​

string

The material to target.

key​

string

A unique key used to identify this action.

material​

Partial<MaterialResource>

The material modifier to apply.

removeWhenUndefined?​

boolean

Whether or not to remove the material modifier when the material is undefined.

Returns​

Promise<void>


applyModelVariant()​

applyModelVariant(key, modelDetails, replaceProductModel): Promise<void>

Applies a given model variant to the scene.

Parameters​

key​

string

A unique key used to identify this action.

modelDetails​

ModelDetails | undefined

replaceProductModel​

boolean

Whether or not to replace the product model with the new model.

Returns​

Promise<void>


beginModelVariantBatch()​

beginModelVariantBatch(): void

Opens a model variant batch. While one is open, newly loaded models stay hidden and the models they replace stay on screen, so a group of related applyModelVariant calls becomes a single atomic transition rather than a series of pops as each download finishes.

Batches nest, so it is safe to open one around work that opens its own. Always pair this with endModelVariantBatch in a finally - leaving a batch open leaves the held changes invisible.

Returns​

void


dispose()​

dispose(): void

Disposes all resources associated with the model container. Note: This will also remove the container from the preview service.

Returns​

void


endModelVariantBatch()​

endModelVariantBatch(): void

Closes a model variant batch, revealing everything it held if it was the outermost one.

Returns​

void


executeAnimation()​

executeAnimation(animation, immediate?): Promise<void>

Executes an animation on the model.

Parameters​

animation​

ModelAnimation

The animation track to run.

immediate?​

boolean

Returns​

Promise<void>

A promise which resolves when the animation has completed. If the animation is looping, the promise will resolve after the first loop.


getAnimations()​

getAnimations(includeVariants?): readonly ModelAnimation[]

Returns the animations available on the model.

Parameters​

includeVariants?​

boolean

When true, animations on model variants will be included. Defaults to false.

Returns​

readonly ModelAnimation[]


getId()​

getId(): string

Returns the unique ID of the model container.

Returns​

string


getInitializationPromise()​

getInitializationPromise(): Promise<ModelContainer>

Returns a promise which resolves when the model has been initialized.

Returns​

Promise<ModelContainer>


getIsInitialized()​

getIsInitialized(): boolean

Returns true if the model has been initialized.

Returns​

boolean


getLastRequestedAnimation()​

getLastRequestedAnimation(): ModelAnimation | undefined

Returns the last animation that was executed on the model.

Returns​

ModelAnimation | undefined


getUVIslandOutline()​

getUVIslandOutline(materialName): readonly UVSegment[]

Traces the boundary/seam edges of the UV island(s) that a named material's mesh(es) occupy in the model's texture unwrap. Designed for use when utilizing the 3D preview in an editor format, to overlay a guide showing where a material's UVs actually land versus the canvas/panel bounds. Segments are returned in normalized 0..1 UV space.

Parameters​

materialName​

string

The name of the material to trace, as returned by listMaterials().

Returns​

readonly UVSegment[]


listMaterials()​

listMaterials(): readonly MaterialHandle[]

List named materials that are available on the model. Designed for use when utilizing the 3D preview in an editor format.

Returns​

readonly MaterialHandle[]


registerMaterialDeselectedCallback()​

registerMaterialDeselectedCallback(callback): void

Registers a callback that will be invoked when a material is no longer under the cursor.

Parameters​

callback​

(material) => void

The callback to register.

Returns​

void


registerMaterialSelectedCallback()​

registerMaterialSelectedCallback(callback): void

Registers a callback that will be invoked when a material is under the cursor.

Parameters​

callback​

(material) => void

The callback to register.

Returns​

void


unregisterMaterialDeselectedCallback()​

unregisterMaterialDeselectedCallback(callback): void

Removes a callback that was previously registered to be invoked when a material is no longer under the cursor.

Parameters​

callback​

(material) => void

The callback to unregister.

Returns​

void


unregisterMaterialSelectedCallback()​

unregisterMaterialSelectedCallback(callback): void

Removes a callback that was previously registered to be invoked when a material is under the cursor.

Parameters​

callback​

(material) => void

The callback to unregister.

Returns​

void