Reference Source
import Render from 'minerender/src/renderBase.js'
public class | source

Render

Base class for all Renders

Constructor Summary

Public Constructor
public

constructor(options: object, defOptions: object, element: HTMLElement)

Member Summary

Public Members
public

element: HTMLElement

DOM Element to attach the renderer to

public

options: {

Combined options

public

Method Summary

Public Methods
public

addToScene(toAdd: *)

Adds an object to the scene & sets userData.renderType to this renderer's type

public

clearScene(onlySelfType: *, filterFn: *)

Clears the scene

public
public

toGLTF(exportOptions: *): Promise<any>

Export the current scene content in the .gltf format (geometries + textures)

public

toImage(trim: boolean, mime: string): string

public

Export the current scene content in the .obj format (only geometries, no textures)

public

toPLY(exportOptions: *): *

Protected Methods
protected

initScene(renderCb: *, doNotAnimate: *): boolean

Initializes the scene

Public Constructors

public constructor(options: object, defOptions: object, element: HTMLElement) source

Params:

NameTypeAttributeDescription
options object

The options for this renderer, see defaultOptions

defOptions object

Additional default options, provided by the individual renders

element HTMLElement
  • optional
  • default: document.body

DOM Element to attach the renderer to - defaults to document.body

Public Members

public element: HTMLElement source

DOM Element to attach the renderer to

public options: { source

Combined options

public renderType: string source

Public Methods

public addToScene(toAdd: *) source

Adds an object to the scene & sets userData.renderType to this renderer's type

Params:

NameTypeAttributeDescription
toAdd *

object to add

public clearScene(onlySelfType: *, filterFn: *) source

Clears the scene

Params:

NameTypeAttributeDescription
onlySelfType *

whether to remove only objects whose type is equal to this renderer's type (useful for combined render)

filterFn *

Filter function to check which children of the scene to remove

public dispose() source

public toGLTF(exportOptions: *): Promise<any> source

Export the current scene content in the .gltf format (geometries + textures)

Params:

NameTypeAttributeDescription
exportOptions *

Return:

Promise<any>

a promise which resolves with the .gltf file content

public toImage(trim: boolean, mime: string): string source

Params:

NameTypeAttributeDescription
trim boolean
  • optional
  • default: false

whether to trim transparent pixels

mime string
  • optional
  • default: image/png

mime type of the image

Return:

string

The content of the renderer's canvas as a Base64 encoded image

public toObj(): string source

Export the current scene content in the .obj format (only geometries, no textures)

Return:

string

the .obj file content

public toPLY(exportOptions: *): * source

Params:

NameTypeAttributeDescription
exportOptions *

Return:

*

Protected Methods

protected initScene(renderCb: *, doNotAnimate: *): boolean source

Initializes the scene

Params:

NameTypeAttributeDescription
renderCb *
doNotAnimate *

Return:

boolean