Manual Reference Source
import {ModelViewer} from '@modelo/api/doc/UI/UI.js'
public class | source

ModelViewer

A model viewer is for displaying and manipulating single model. It contains a canvas and a bunch of tools.

Constructor Summary

Public Constructor
public

Construct a viewer with a canvas and associated HTML UI elements.

Method Summary

Public Methods
public

createModelComment(modelId: string, data: {avatar: ?string, username: string, message: ?string}): Promise<number>, Error

Create comment for a model.

public

Destroy the app and all its used resources.

public

Get all comments of model.

public

getViewer(): *

Returns the Viewer3D instanced used by this ModelViewer object.

public

removeModelComment(modelId: string, commentId: number): Promise<number, Error>

Remove a comment from a model.

public

updateModelComment(commentId: number, data: {avatar: ?string, username: string, message: ?string}): Promise<Comment, Error>

Update comment.

Public Constructors

public constructor(config: ModelViewerConfig) source

Construct a viewer with a canvas and associated HTML UI elements.

Params:

NameTypeAttributeDescription
config ModelViewerConfig

The configuration parameters of this viewer. It can't be omitted.

Example:

    var viewer = new Modelo.UI.ModelViewer ({
      modelId,
      containerId: "modelContainer",
      useDefaultFavicon: true,
      onReady: (viewer) => {
        console.log('viewer ready', viewer)
      },
      onError: (err) => {
        console.log(err);
      }
    });

Public Methods

public createModelComment(modelId: string, data: {avatar: ?string, username: string, message: ?string}): Promise<number>, Error source

Create comment for a model.

Params:

NameTypeAttributeDescription
modelId string

The model id.

data {avatar: ?string, username: string, message: ?string}

The comment data, including avatar, message and username. The avatar should be URL string and message is a plain string. Both of them are optional. But the username is mandatory.

Return:

Promise<number>, Error

The comment id.

public destroy() source

Destroy the app and all its used resources.

public getModelComments(modelId: string): Promise<Comment[], Error> source

Get all comments of model.

Params:

NameTypeAttributeDescription
modelId string

The model id.

Return:

Promise<Comment[], Error>

public getViewer(): * source

Returns the Viewer3D instanced used by this ModelViewer object.

Return:

*

the bound Viewer3D instance.

public removeModelComment(modelId: string, commentId: number): Promise<number, Error> source

Remove a comment from a model.

Params:

NameTypeAttributeDescription
modelId string

The model id.

commentId number

The comment id to delete.

Return:

Promise<number, Error>

Return the comment id when delete succeeds.

public updateModelComment(commentId: number, data: {avatar: ?string, username: string, message: ?string}): Promise<Comment, Error> source

Update comment.

Params:

NameTypeAttributeDescription
commentId number

The comment id.

data {avatar: ?string, username: string, message: ?string}

The comment data, including avatar, message and username. The avatar should be URL string and message is a plain string. Both of them are optional. But the username is mandatory.

Return:

Promise<Comment, Error>