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

Viewer

Direct Subclass:

Viewer3D

Constructor Summary

Public Constructor
public

constructor(containerId: string, config: ViewerConfig)

Constructor a viewer object.

Method Summary

Public Methods
public

Add an input method to this viewer, e.g., mouse.

public

addTool(tool: Tool): *

Add an tool to this viewer.

public

Clear content of the scene.

public

Stop rendering, destroy the viewer and release all internal resources.

public

Return the canvas DOM.

public

Get the input

public

Get the tool instance by name.

public

Return the viewer's width.

public

Return the viewer's height.

public

Invalidate the current rendering and refresh it again.

public

pause()

Pause the current rendering.

public

Remove the tool instance by its name.

public

resize(width: number, height: number)

Resize the viewer.

public

resume()

Resume the rendering.

Public Constructors

public constructor(containerId: string, config: ViewerConfig) source

Constructor a viewer object.

Params:

NameTypeAttributeDescription
containerId string

An HTML div DOM that embodies this viewer. Viewer may create additional HTML DOMs inside this container.

config ViewerConfig

The configuration parameters of this viewer. It can be omitted and then default values will be used.

Public Methods

public addInput(input: Mouse | Keyboard): number source

Add an input method to this viewer, e.g., mouse.

Params:

NameTypeAttributeDescription
input Mouse | Keyboard

Must be the instance of Modelo.Input that is compatible with current platform.

Return:

number

The input id in this viewer. -1 is returned if it fails to add this input.

public addTool(tool: Tool): * source

Add an tool to this viewer.

Params:

NameTypeAttributeDescription
tool Tool

The tool to be added to the viewer.

Return:

*

The id of the tool. If fails, returns -1.

public clearScene() source

Clear content of the scene.

public destroy() source

Stop rendering, destroy the viewer and release all internal resources.

public getCanvas(): Object source

Return the canvas DOM.

Return:

Object

The canvas DOM.

public getInput(id: number) source

Get the input

Params:

NameTypeAttributeDescription
id number

The id of the input.

public getTool(id: number): Tool source

Get the tool instance by name.

Params:

NameTypeAttributeDescription
id number

The id of tool.

Return:

Tool

If fails, return null.

public getWidth(): number source

Return the viewer's width.

Return:

number

The width of the viewer, scaled by pixel ratio.

public getWidth(): number source

Return the viewer's height.

Return:

number

The height of the viewer, scaled by pixel ratio.

public invalidate() source

Invalidate the current rendering and refresh it again.

public pause() source

Pause the current rendering.

public removeTool(id: number) source

Remove the tool instance by its name.

Params:

NameTypeAttributeDescription
id number

The id of tool.

public resize(width: number, height: number) source

Resize the viewer.

Params:

NameTypeAttributeDescription
width number
height number

public resume() source

Resume the rendering.