Reference Source
import ModelRender from 'minerender/src/model/index.js'
public class | source

ModelRender

Extends:

Render → ModelRender

A renderer for Minecraft models, i.e. blocks & items

Constructor Summary

Public Constructor
public

constructor(options: Object, element: HTMLElement)

Member Summary

Public Members
public
public

models: *[]

public

Method Summary

Public Methods
public

render(models: string[] | Object[], cb: function)

Does the actual rendering

Inherited Summary

From class Render
public

element: HTMLElement

DOM Element to attach the renderer to

public

options: {

Combined options

public
public

addToScene(toAdd: *)

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

public

clearScene(onlySelfType: *)

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

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

Initializes the scene

Public Constructors

public constructor(options: Object, element: HTMLElement) source

Override:

Render#constructor

Params:

NameTypeAttributeDescription
options Object
  • optional

The options for this renderer, see defaultOptions

options.assetRoot string
  • optional
  • default: DEFAULT_ROOT

root to get asset files from

element HTMLElement
  • optional
  • default: document.body

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

Public Members

public attached: boolean source

public models: *[] source

public renderType: string source

Override:

Render#renderType

Public Methods

public render(models: string[] | Object[], cb: function) source

Does the actual rendering

Params:

NameTypeAttributeDescription
models string[] | Object[]

Array of models to render - Either strings in the format <block|item>/<model name> or objects

models[].type string
  • optional
  • default: block

either 'block' or 'item'

models[].model string

if 'type' is given, just the block/item name otherwise '<block|item>/<model name>'

models[].offset number[]
  • optional

[x,y,z] array of the offset

models[].rotation number[]
  • optional

[x,y,z] array of the rotation

models[].blockstate string
  • optional

name of a blockstate to be used to determine the models (only for blocks)

models[].variant string
  • optional
  • default: normal

if 'blockstate' is given, the block variant to use

cb function
  • optional

Callback when rendering finished