iv.object > iv.mesh

WebGL FinalMesh API | 3D Mesh

iv.mesh

Constructor

iv.mesh(gl)

Constructor creates new mesh object.

gl WebGL context.

Properties

gl WebGL context
boxMin Bounding box, min point
boxMax Bounding box, max point
lineMode boolean. true for line mesh, false for mesh made from lines
points Arrays of points
faces Array of triangles
normals Array of normals
uvpoints Arrays of uv coordinates. #0 channel
uv2points Arrays of uv coordinates. #1 channel
edgeBuffer Array of edges for wireframe render mode.
vBuffer WebGL vertex buffer
nBuffer WebGL buffer for per vertex normals
uvBuffer WebGL buffer for uv #0 corrdinates
uv2Buffer WebGL buffer for uv #1 corrdinates
cBuffer WebGL buffer for diffuse per vertex color
ceBuffer WebGL buffer for per vertex emissive color
bnBuffer WebGL buffer for binormals
btBuffer WebGL buffer for tangents

 

To be rendered mesh needs at least valid bounding box, point and face buffers. For smooth, shaded appearance normal buffer is required. Source points, normals, triangle indices are required for hit testing only.

 

Methods

 

.setPoints(a,keep)

Method sets mesh points and updates WebGL buffer.

a

Array of points. Points may be in Float32Array or in classic JS array.

keep Keep points or not. If true array of points will be keept. If false or undefined, only webgl buffer will be updated. Points are required if hit test will be executed

.setNormals(a,keep)

Method sets mesh points and updates WebGL buffer.

a

Array of normals. Points may be in Float32Array or in classic JS array.

keep Keep normals or not. If true array of normals will be keept. If false or undefined, only webgl buffer will be updated.

.setUV(uv,keep)

Method sets mesh UV coordinates and updates WebGL buffer.

uv

Array of uv points. UV coordinates may be in Float32Array or in classic JS array.

keep Keep uv points or not. If true array of uv coordinates will be keept. If false or undefined, only webgl buffer will be updated.

.setUV2(a,keep)

Method sets mesh points and updates WebGL buffer.

a

Array of secondary uv points. Points may be in Float32Array or in classic JS array.

keep Keep points or not. If true array of points will be keept. If false or undefined, only webgl buffer will be updated.

.setBuffer(name,b)

Method sets or updates specified mesh buffer.

name

Prefix of buffer name. For instance: "n", "uv", "uv2". Name of buffer will be name+"Buffer".

b WebGL buffer object.

This method decrements reference count of old buffer and increments for a new one.

.setFaces(a,keep)

Method sets mesh faces and updates webgl buffer.

a

Array of triangle indices. Indices may be in Uint16Array or in classic JS array.

keep Keep faces or not. If true array of faces will be keept. If false or undefined, only webgl buffer will be update.

 

.updateEdges()

Used internally for rendering wireframe edges.