API Docs for: 0.5.5
Show:

kick.mesh.MeshData Class

Module: kick.mesh

Mesh data class. Allows for modifying mesh object easily. This is a pure data class with no WebGL dependency

Constructor

kick.mesh.MeshData

(
  • [config]
)

Parameters:

  • [config] Object optional

Methods

combine

(
  • secondMesh
  • transform
)
kick.mesh.MeshData

Combine two meshes and returns the combined mesh as a new Mesh object.
The two meshes must have the same meshType. Only vertex attributes existing in both mesh objects are transferred
Triangle fans cannot be combined

Parameters:

Returns:

kick.mesh.MeshData:

mesh object or null if incompatible objects

createGetterSetter

(
  • type
  • name
)
private

Parameters:

  • type Number

    GL_FLOAT or GL_INT

  • name String

createInterleavedData

() private

createUv1

()

Create an array of empty UV coordinates

createUv2

()

Create an array of empty UV coordinates

deserialize

(
  • data
)

Restores the

Parameters:

  • data ArrayBuffer

Returns:

Boolean

isInterleavedDataInitialized

() Boolean

Returns:

Boolean:

return true if interleaved data is initialized

isValid

() Boolean

Returns:

Boolean:

if mesh is considered valid

isVertexDataInitialized

() Boolean

Returns:

Boolean:

return true if vertex data is initialized

recalculateNormals

() Boolean

Recalculate the angle weighted vertex normals based on the triangle mesh

Returns:

Boolean:

false if meshtype is not GL_TRIANGLES or GL_TRIANGLE_STRIP

recalculateTangents

() Boolean

Recalculates the tangents on a triangle mesh.
Algorithm is based on
Lengyel, Eric. “Computing Tangent Space Basis Vectors for an Arbitrary Mesh”.
Terathon Software 3D Graphics Library, 2001.
http://www.terathon.com/code/tangent.html

Returns:

Boolean:

false if meshtype is not supported

serialize

()

Saves the MeshData into binary form (ArrayBuffer)

Returns:

ArrayBuffer

transform

(
  • transformMatrix
)
kick.mesh.MeshData

Creates a copy of the mesh and transform the vertex positions of the MeshData with a mat4. Note that normals are not modified - so they may need to renormalized.

Parameters:

Returns:

kick.mesh.MeshData:

transformed mesh

Properties

aabb

kick.math.Aabb

Note that this property is not cached. Use kick.mesh.Mesh.aabb for a cached version. Readonly

color

Array_Number

Vertex attribute. Color (vec4)

indices

Array_Number

Vertex attribute. indices (integer). indices is shortcut for subMeshes[0]

int1

Array_Number

Vertex attribute. Integer attribute (one Int32)

int2

Array_Number

Vertex attribute. Integer attribute (two Int32)

int3

Array_Number

Vertex attribute. Integer attribute (three Int32)

int4

Array_Number

Vertex attribute. Integer attribute (four Int32)

interleavedArray

Float32Array

interleavedArrayFormat

Object

Describes the interleaved array format.
The description is an object with a number of properties.
Each property name corresponds to the name of the vertex attribute.
Each property has the format

Example:

{
    pointer: 0, // {Number}
    size: 0, //{Number} number of elements
    normalized: 0, // {Boolean} should be normalized or not
    type: 0 // {GL_FLOAT or GL_INT}
}


Example:

var vertexOffset = meshData.interleavedArrayFormat["vertex"].pointer;

meshType

Number

Must be GL_TRIANGLES, GL_TRIANGLE_FAN, GL_TRIANGLE_STRIP, GL_POINTS, or GL_LINES

name

String

normal

Array_Number

Vertex attribute. Normal (vec3)

subMeshes

Array_Array_Number

Indices (integer) - One index array for each submesh

tangent

Array_Number

Vertex attribute. Tangent (vec4)

usage

Number

Must be either GL_STATIC_DRAW, GL_DYNAMIC_DRAW or GL_STREAM_DRAW.

Default: GL_STATIC_DRAW

uv1

Array_Number

Vertex attribute. UV1 (vec2)

uv2

Array_Number

Vertex attribute. UV2 (vec2)

vertex

Array_Number

Vertex attribute. Vertex (vec3)

vertexAttrLength

Number

The length of vertexAttributes for one vertex in bytes