Documentation generator: JsDoc Toolkit 2.4.0
Template: Codeview 1.2
Generated on: 2016-0-4 21:22

Class enchant.gl.Mesh

Class Summary
Constructor Attributes Constructor Name and Description
 
Class to store peak arrays and textures.
Field Summary
Field Attributes Field Name and Description
 
Mesh peak color array.
 
Sprite3D peak index array.
 
Mesh peak normal vector array.
 
Mesh texture mapping array.
 
Mesh peak array.

Method Summary

Method Attributes Method Name and Description
 
Destroy object.
 
Reverse direction of the mesh surface and the normal vector.
 
setBaseColor(color)
Change Mesh color.

Class Detail

enchant.gl.Mesh()
Class to store peak arrays and textures. Used as a sprite property.

Field Detail

{Number[]} colors
Mesh peak color array. The 4 elements are set as one peak color. The entire number of elements becomes 4n corresponding to the peak quantity n. The 4n, 4n+1, 4n+2, and 4n+3 elements are the n level peak colors r, g, b, a. Peak color is used for drawing when Texture is not assigned to Sprite3D Texture. enchant.gl.Mesh#setBaseColor can be used to bundle together and change.
  var sprite = new Sprite3D();
  //Substitutes peak array
  //Data is stored in an order of x, y, z, x, y, z...
  sprite.vertices = [
      0.0, 0.0, 0.0,  //0 peak (0.0, 0.0, 0.0)
      1.0, 0.0, 0.0,  //1 peak (1.0, 0.0, 0.0)
      1.0, 1.0, 0.0,  //2 peak (1.0, 1.0, 0.0)
      0.0, 1.0, 0.0   //3 peak (0.0, 1.0, 0.0)
  ];

  //Substitutes peak level array
  //Data is stored in an order of r, g, b, a, r, g, b, a...
  sprite.normals = [
      0.0, 0.0, 1.0, 1.0, //0 peak color (0.0, 0.0, 1.0, 1.0)
      0.0, 1.0, 0.0, 1.0, //1 peak color (0.0, 1.0, 0.0, 1.0)
      0.0, 1.0, 1.0, 1.0, //2 peak color (0.0, 1.0, 1.0, 1.0)
      1.0, 0.0, 0.0, 1.0  //3 peak color (1.0, 0.0, 0.0, 1.0)
  ];
See:
enchant.gl.Mesh#setBaseColor
{Integer[]} indices
Sprite3D peak index array. 3 elements are set as one in a triangle. The total number of elements becomes 3n corresponding to the triangle's total quantity n. Index level is the peak number designated in enchant.gl.Sprite3D#vertices.
  var sprite = new Sprite3D();
  //Substitutes peak array
  //Data is stored in an order of x, y, z, x, y, z...
  sprite.vertices = [
      0.0, 0.0, 0.0,  //0 peak (0.0, 0.0, 0.0)
      1.0, 0.0, 0.0,  //1 peak (1.0, 0.0, 0.0)
      1.0, 1.0, 0.0,  //2 peak (1.0, 1.0, 0.0)
      0.0, 1.0, 0.0   //3 peak (0.0, 1.0, 0.0)
  ];

  //Substitutes peak index
  //Draws triangle with 3 elements as one
  //In this example the two triangles (0,0,0), (1,0,0), (1,1,0) and
  //(1,1,0), (0,1,0), (0,0,0) are drawn.
  sprite.indices = [
      0, 1, 2,
      2, 3, 0
  ];
  var scene = new Scene3D();
  scene.addChild(sprite);
See:
enchant.gl.Mesh#vertices
enchant.gl.Mesh#normals
enchant.gl.Mesh#texCoords
{Number[]} normals
Mesh peak normal vector array. Sets 3 elements as one in normal vector. The complete element number becomes 3n for normal vector quantity n. 3n, 3n+1, and 3n+2 elements are the n level peak x, y, and z elements of the normal vector. The normal vector is used in calculations for lighting and shadow.
  var sprite = new Sprite3D();
  //Substitutes peak array
  //Data is stored in an order of x, y, z, x, y, z...
  sprite.vertices = [
      0.0, 0.0, 0.0,  //0 peak (0.0, 0.0, 0.0)
      1.0, 0.0, 0.0,  //1 peak (1.0, 0.0, 0.0)
      1.0, 1.0, 0.0,  //2 peak (1.0, 1.0, 0.0)
      0.0, 1.0, 0.0   //3 peak (0.0, 1.0, 0.0)
  ];

  //Substitutes normal vector array
  //Data is a stored in an order of x, y, z, x, y, z...
  sprite.normals = [
      0.0, 0.0, 0.0,  //0 level peak normal vector (0.0, 0.0, 0.0)
      1.0, 0.0, 0.0,  //1 level peak normal vector (1.0, 0.0, 0.0)
      1.0, 1.0, 0.0,  //2 level peak normal vector (1.0, 1.0, 0.0)
      0.0, 1.0, 0.0   //3 level peak normal vector (0.0, 1.0, 0.0)
  ];
See:
enchant.gl.Mesh#vertices
enchant.gl.Mesh#indices
enchant.gl.Mesh#texCoords
{Number[]} texCoords
Mesh texture mapping array. Sets two elements as one in uv coordinates. The total number of elements becomes 2n in response to the peak quantity. 2n, 2n+1 level elements correspond to n level peak texture u, v coordinates. The coordinates that can be acquired for each coordinate correspond to 0<=u, v<=1.
  var sprite = new Sprite3D();
  var texture = new Texture();
  texture.src = "texture.png";
  sprite.mesh.texture = texture;

  //Substitutes peak level
  //Data is stored in an order of x, y, z, x, y, z...
  sprite.vertices = [
      0.0, 0.0, 0.0,  //0 peak (0.0, 0.0, 0.0)
      1.0, 0.0, 0.0,  //1 peak (1.0, 0.0, 0.0)
      1.0, 1.0, 0.0,  //2 peak (1.0, 1.0, 0.0)
      0.0, 1.0, 0.0   //3 peak (0.0, 1.0, 0.0)
  ];

  //Substitutes uv coordinate array
  //Data is stored in an order of u, v, u, v...
  sprite.texCoords = [
      0.0, 0.0,  //0番目の頂点のuv座標(0.0, 0.0)
      1.0, 0.0,  //1番目の頂点のuv座標(1.0, 0.0)
      1.0, 1.0,  //2番目の頂点のuv座標(1.0, 1.0)
      0.0, 1.0   //3番目の頂点のuv座標(0.0, 1.0)
  ];
See:
enchant.gl.Mesh#vertices
enchant.gl.Mesh#indices
enchant.gl.Mesh#normals
enchant.gl.Mesh#texture#
{Number[]} vertices
Mesh peak array. Sets 3 elements together at peak. The complete number of elements becomes 3n corresponding to the quantity of the peak. The 3n, 3n+1, and 3n+2 elements become, respectively, the n peak x, y, and z coordinates.
  var sprite = new Sprite3D();
  //Substitute peak array
  //Data is stored in an order of x, y, z, x, y, z...
  sprite.mesh.vertices = [
      0.0, 0.0, 0.0,  //0 peak (0.0, 0.0, 0.0)
      1.0, 0.0, 0.0,  //1 peak (1.0, 0.0, 0.0)
      1.0, 1.0, 0.0,  //2 peak (1.0, 1.0, 0.0)
      0.0, 1.0, 0.0   //3 peak (0.0, 1.0, 0.0)
  ];
See:
enchant.gl.Mesh#indices
enchant.gl.Mesh#normals
enchant.gl.Mesh#texCoords

Method Detail

  • destroy()
    Destroy object.
  • reverse()
    Reverse direction of the mesh surface and the normal vector.
  • setBaseColor(color)
    Change Mesh color. Becomes peak array for Mesh.colors set color.
      var sprite = new Sprite3D();
      //Sets to purple. All yield the same result.
      sprite.mesh.setBaseColor([1.0, 0.0, 1.0, 0.0]);
      sprite.mesh.setBaseColor('#ff00ff');
      sprite.mesh.setBaseColor('rgb(255, 0, 255');
      sprite.mesh.setBaseColor('rgba(255, 0, 255, 1.0');
    Parameters:
    {Number[]|String} color
    z Amount of parallel displacement on z axis