Options
All
  • Public
  • Public/Protected
  • All
Menu

Class RenderMesh

Class representing a set of vertices with some other parameters required to display them correctly. Used as block, entity and item models, in animations and actually anywhere you need some physical shape

Hierarchy

  • RenderMesh

Index

Constructors

constructor

  • new RenderMesh(path: string, type: string, params: object): RenderMesh
  • new RenderMesh(): RenderMesh

Methods

addMesh

  • addMesh(mesh: RenderMesh, x: number, y: number, z: number, sx: number, sy: number, sz: number): void
  • addMesh(mesh: RenderMesh, x: number, y: number, z: number): void
  • addMesh(mesh: RenderMesh): void
  • Adds new mesh to the current one on the specified coordinates with specified scale

    Parameters

    • mesh: RenderMesh

      RenderMesh object to be added to current mesh

    • x: number
    • y: number
    • z: number
    • sx: number
    • sy: number
    • sz: number

    Returns void

  • Adds new mesh to the current one on the specified coordinates

    Parameters

    Returns void

  • Adds new mesh to the current one

    Parameters

    Returns void

addVertex

  • addVertex(x: number, y: number, z: number, u: number, v: number): void
  • Adds a new vertex on the specified coordinates

    Parameters

    • x: number
    • y: number
    • z: number
    • u: number

      x texture offset of the vertex

    • v: number

      y texture offset of the vertex

    Returns void

clear

  • clear(): void

clone

fitIn

  • fitIn(x1: number, y1: number, z1: number, x2: number, y2: number, z2: number, keepRatio: boolean): void
  • Scales the mesh to fit into the specified box

    Parameters

    • x1: number
    • y1: number
    • z1: number
    • x2: number
    • y2: number
    • z2: number
    • keepRatio: boolean

      if true, the ratio of the dimensions are preserved

    Returns void

importFromFile

  • importFromFile(path: string, type: string, params: { clear?: boolean; invertV: boolean; noRebuild: boolean; scale?: [number, number, number]; translate?: [number, number, number] }): void
  • Imports mesh file using specified path

    Parameters

    • path: string

      path to the mesh file. Path should be abolute path or be relative to the resources folder or to the "models/" folder

    • type: string

      file type to read mesh from. The only currently supported mesh file type is "obj"

    • params: { clear?: boolean; invertV: boolean; noRebuild: boolean; scale?: [number, number, number]; translate?: [number, number, number] }

      additional import parameters

      • Optional clear?: boolean

        If true, all existing vertices of the mesh are deleted before the file is imported

      • invertV: boolean

        If true, v of the texture is inverted

      • noRebuild: boolean
      • Optional scale?: [number, number, number]

        Additional scale along x, y and z axis

      • Optional translate?: [number, number, number]

        Additional translation along x, y and z axis

    Returns void

rebuild

  • rebuild(): void

resetColor

  • resetColor(): void

resetTexture

  • resetTexture(): void

rotate

  • rotate(x: number, y: number, z: number, rotX: number, rotY: number, rotZ: number): void
  • rotate(rotX: number, rotY: number, rotZ: number): void
  • Rotates the mesh around the specified coordinates

    Parameters

    • x: number
    • y: number
    • z: number
    • rotX: number

      rotation angle along X axis, in radians

    • rotY: number

      rotation angle along Y axis, in radians

    • rotZ: number

      rotation angle along Z axis, in radians

    Returns void

  • Rotates the mesh around the (0, 0, 0) coordinates

    Parameters

    • rotX: number

      rotation angle along X axis, in radians

    • rotY: number

      rotation angle along Y axis, in radians

    • rotZ: number

      rotation angle along Z axis, in radians

    Returns void

scale

  • scale(x: number, y: number, z: number): void
  • Scales the whole mesh along the three axis

    Parameters

    • x: number
    • y: number
    • z: number

    Returns void

setBlockTexture

  • setBlockTexture(name: string, index: number): void
  • Specifies block texture to be used by mesh

    Parameters

    • name: string
    • index: number

    Returns void

setColor

  • setColor(r: number, g: number, b: number, a?: number): void
  • Specifies color to be applied to the next vertices. If the color is not white and the texture is applied to mesh, texture's colors will be affected

    Parameters

    • r: number
    • g: number
    • b: number
    • Optional a: number

    Returns void

setNormal

  • setNormal(x: number, y: number, z: number): void
  • Specifies the normal vector for the next vertices

    Parameters

    • x: number
    • y: number
    • z: number

    Returns void

translate

  • translate(x: number, y: number, z: number): void
  • Translates the whole mesh along three axis

    Parameters

    • x: number
    • y: number
    • z: number

    Returns void

Generated using TypeDoc