Mesh Class
Mesh class contains buffers for 3d objects
Constructor
Mesh
-
[options]
Parameters:
-
[options]Object optional{Dict} Dictionary of options when creating Aex object
Returns:
Returns Mesh Object
Example:
//Draw a simple triangle
var mesh = new Mesh()
mesh.vertices = [[0,0,0],[1,1,0],[0,0,-1]]
mesh.coords = [[0.0,0.0],[1.0,1.0],[0.0,0.0]]
mesh.traingles = [[0,1,2]]
mesh.computeNormals()
mesh.compile()
Item Index
Methods
addChilds
-
mobject
Sets parent on MObject and unbinds current parent in RenderTree
Parameters:
-
mobjectMObjectmobject object to add as a child to RenderTree
addIndexBuffer
-
name
Creates a index Buffer for example: this.addIndexBuffer('triangles');
Parameters:
-
nameStringName of buffer
addVertexBuffer
-
name -
attribute
Creates a vertex Buffer for example: this.addVertexBuffer('normals', 'gl_Normal');
Parameters:
-
nameStringName of buffer
-
attributeStringgl name
checkRepeat
()
Check if there are two vertices in the same place( useful to recognize bad import)
combine
-
mesh -
noCompile
Coombine two meshes into one
Parameters:
-
meshMeshadditional mesh
-
noCompileBooleanflag if set to true doesnt compile mesh
Returns:
Compiled mesh (cube)
compile
()
Recompile the mesh ( for example: if vertices were edited )
computeNormals
()
Recompute normals
computeWireframe
()
Recompute wireframe
cube
()
Mesh
static
Create a cube
Returns:
Compiled mesh (cube)
Example:
someMesh = Mesh.cube()
draw
-
name -
attribute
Drawes a Mesh
Parameters:
-
nameStringName of buffer
-
attributeStringgl name
getAABB
()
Get mesh bounding box
getBoundingSphere
-
aabb
Get mesh bounding sphere
Parameters:
-
aabbObject
getCenter
()
Get center point of meshcar.t
getVertex
-
id
Get vertex by id
Parameters:
-
idIntVertex id
Returns:
position of vertex
getVertex
-
id
Get vertex by id
Parameters:
-
idIntVertex id
Returns:
position of vertex
load
-
json -
options
Load 3d model from json
Parameters:
-
jsonStringmodel in json format
-
optionsDictadditional options
Returns:
Compiled mesh (loaded model)
load
-
dict -
options
Load 3d model from itself
Parameters:
-
dictStringof model
-
optionsDictadditional options
Returns:
Compiled mesh (loaded model)
load
-
mesh
Copy mesh
Parameters:
-
meshMeshto copy
Returns:
Compiled mesh (copied model)
move
-
x -
y -
z
Moves mesh
Parameters:
-
xFloat -
yFloat -
zFloat
obj
-
url -
callback -
[opts]
Load 3d model from obj
Parameters:
-
urlStringpath to .obj file
-
callbackFunctionfunction that happen after successful mesh loading
-
[opts]Dict optionaloptional parameters listed in example
Example:
characterJaw = new GameObject(world, { shader: gshader, material: planetMat, mesh: ludekMesh2, }) Mesh.obj("obj/jaw.obj", function (e) { var meshy = e meshy.rotate(0, 90, 0) meshy.scale(-0.25, 0.25, 0.25) meshy.move(0, 0.05, 0) characterJaw.mesh = meshy })
plane
-
detailX -
detailY -
options
Create a plane
Parameters:
-
detailXIntegerX segments
-
detailYIntegerY segments
-
optionsDictadditional options
Returns:
Compiled mesh (plane)
Example:
someMesh = Mesh.plane(10,10)
remove
()
Removes MObject from RenderTree
rotate
-
x -
y -
z
Rotates mesh
Parameters:
-
xFloat -
yFloat -
zFloat
scale
-
x -
y -
z
Scales mesh
Parameters:
-
xFloat -
yFloat -
zFloat
scaleUniform
-
f
Scales uniformly mesh
Parameters:
-
fFloat
setParent
-
parent
Sets parent on MObject and unbinds current parent in RenderTree. Usually this is done inside GameObject, but you have also possibility to construct RenderTree by yourself.
Parameters:
-
parentMObjectparent object
Example:
world = new Scene() gshader = new basicShader() someMaterial = new Material({}) gshader.setParent(world) someMaterial.setParent(world)
setVertex
-
id -
vector
Set Position of Vertex
Parameters:
-
idIntVertex id
-
vectorVector or arrayNew vertex position
Docs for Version: 1.0a