Classes
Methods
(static) OBJ.deleteMeshBuffers(gl, mesh)
Takes in the WebGL context and a Mesh. Deletes the mesh's buffers,
which you would do when deleting an object from a scene so that you don't leak video memory.
Excessive buffer creation and deletion leads to video memory fragmentation. Beware.
The deleted texture attributes are:
Attribute | Description normalBuffer | contains the Vertex Normals normalBuffer.itemSize | set to 3 items normalBuffer.numItems | the total number of vertex normals ___________________________________________________________________________________________________ textureBuffer | contains the Texture Coordinates textureBuffer.itemSize | set to 2 items textureBuffer.numItems | the number of texture coordinates ___________________________________________________________________________________________________ vertexBuffer | contains the Vertex Position Coordinates (does not include w) vertexBuffer.itemSize | set to 3 items vertexBuffer.numItems | the total number of vertices ___________________________________________________________________________________________________ indexBuffer | contains the indices of the faces indexBuffer.itemSize | is set to 1 indexBuffer.numItems | the total number of indices
Parameters:
Name | Type | Description |
---|---|---|
gl |
WebGLRenderingContext | the 'canvas.getContext('webgl')' context instance |
mesh |
Mesh | a single 'OBJ.Mesh' instance |
- Source:
(static) OBJ.downloadMeshes(nameAndURLs, completionCallback, meshes)
Takes in an object of 'mesh_name': 'src/object/[objectName].obj' pairs and a callback
function. Each OBJ file will be ajaxed in and automatically converted to
an OBJ.Mesh. When all files have successfully downloaded the callback
function provided will be called and passed in an object containing
the newly created meshes.
Note: Cross Origin Resource Sharing (CORS) is NOT enabled for loading objects. You can not download obj files from other domains. Note: In order to use this function as a way to download objects, a webserver of some sort must be used. The newly created Javascript-Arrays for each loaded Object are:Javascript-Array | Description vertexNormals | contains the Vertex Normals ___________________________________________________________________________________________________ textures | contains the Texture Coordinates ___________________________________________________________________________________________________ vertices | contains the Vertex Position Coordinates (does not include w) ___________________________________________________________________________________________________ indices | contains the indices of the facesThe URL path for loading objects provided by the Editor always begins with: 'src/object/[objectName].obj'. A list of all available objects within the editor can be seen in the menu under sources -> object.
Parameters:
Name | Type | Description |
---|---|---|
nameAndURLs |
Object | an object where the key is the name of the mesh and the value is the url to that mesh's OBJ file |
completionCallback |
function | should contain a function that will take one parameter: an object array where the keys will be the unique object name and the value will be a Mesh object |
meshes |
Object | In case other meshes are loaded separately or if a previously declared variable is desired to be used, pass in a (possibly empty) json object of the pattern: { '< mesh_name >': OBJ.Mesh } |
- Source:
(static) OBJ.initMeshBuffers(gl, mesh)
Takes in the WebGL context and a Mesh, then creates and appends the buffers
to the mesh object as attributes.
The newly created mesh attributes are:
Attribute | Description normalBuffer | contains the Vertex Normals normalBuffer.itemSize | set to 3 items normalBuffer.numItems | the total number of vertex normals ___________________________________________________________________________________________________ textureBuffer | contains the Texture Coordinates textureBuffer.itemSize | set to 2 items textureBuffer.numItems | the number of texture coordinates ___________________________________________________________________________________________________ vertexBuffer | contains the Vertex Position Coordinates (does not include w) vertexBuffer.itemSize | set to 3 items vertexBuffer.numItems | the total number of vertices ___________________________________________________________________________________________________ indexBuffer | contains the indices of the faces indexBuffer.itemSize | is set to 1 indexBuffer.numItems | the total number of indices
Parameters:
Name | Type | Description |
---|---|---|
gl |
WebGLRenderingContext | the 'canvas.getContext('webgl')' context instance |
mesh |
Mesh | a single 'OBJ.Mesh' instance |
- Source: