{"id":20778072,"url":"https://github.com/stackgl/gl-mesh","last_synced_at":"2025-10-10T16:17:16.523Z","repository":{"id":9081027,"uuid":"10855189","full_name":"stackgl/gl-mesh","owner":"stackgl","description":"Draws static indexed geometry in WebGL","archived":false,"fork":false,"pushed_at":"2016-05-24T17:22:36.000Z","size":214,"stargazers_count":12,"open_issues_count":0,"forks_count":3,"subscribers_count":4,"default_branch":"master","last_synced_at":"2024-11-08T05:47:41.029Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"http://mikolalysenko.github.io/gl-mesh/","language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/stackgl.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2013-06-21T23:42:46.000Z","updated_at":"2022-02-26T17:28:52.000Z","dependencies_parsed_at":"2022-09-10T08:40:58.636Z","dependency_job_id":null,"html_url":"https://github.com/stackgl/gl-mesh","commit_stats":null,"previous_names":["mikolalysenko/gl-mesh"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/stackgl%2Fgl-mesh","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/stackgl%2Fgl-mesh/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/stackgl%2Fgl-mesh/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/stackgl%2Fgl-mesh/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/stackgl","download_url":"https://codeload.github.com/stackgl/gl-mesh/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":225040949,"owners_count":17411567,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-11-17T13:18:59.126Z","updated_at":"2025-10-10T16:17:16.432Z","avatar_url":"https://github.com/stackgl.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"gl-mesh\n=======\nWebGL class for rendering static indexed geometry\n\n# Example\n\n[Try this demo in your browser](http://mikolalysenko.github.io/gl-mesh/)\n\n```javascript\nvar shell = require(\"gl-now\")()\nvar createMesh = require(\"gl-mesh\")\nvar simple2DShader = require(\"simple-2d-shader\")\n\nvar mesh, shader\n\nshell.on(\"gl-init\", function() {\n  shader = simple2DShader(shell.gl)\n  mesh = createMesh(shell.gl,\n      [[0, 1, 2],\n       [2, 1, 3]],\n      { \"position\": [[-1,-1],   [0, 1],    [0, 0],    [1, -1]],\n        \"color\":    [[1, 0, 0], [0, 1, 0], [0, 0, 1], [1, 1, 1]] })\n})\n\nshell.on(\"gl-render\", function(t) {\n  shader.bind()\n  mesh.bind(shader)\n  mesh.draw()\n  mesh.unbind()\n})\n```\n\nAnd here is what it should look like:\n\n\u003cimg src=https://raw.github.com/mikolalysenko/gl-mesh/master/images/screenshot.png\u003e\n\n# Install\n\nUse [npm](https://npmjs.org/) to install it locally:\n\n    npm install gl-mesh\n    \nThen you can build/run the client using any tool that compiles CommonJS modules, for example [browserify](https://github.com/substack/node-browserify) or [beefy](https://github.com/chrisdickinson/beefy).\n\n# API\n\n```javascript\nvar createMesh = require(\"gl-mesh\")\n```\n\n## Constructor\n\n### `var mesh = createMesh(gl, cells, attributes)`\nCreates a static mesh.\n\n* `gl` is a webgl context\n* `cells` is a list of representing indices into the geometry\n* `attributes` is an object of attributes to pass to the mesh\n\nEach of these objects can be encoded as either an array-of-native-arrays or as a typed array using [ndarrays](https://github.com/mikolalysenko/ndarray).  The first dimension in the shape is interepreted as the number of vertices in the attribute while the second dimension is interpreted as the size.  For example, to pass in a packed array of 3d vertices in a typed array you could do:\n\n```javascript\nvar mesh = createMesh(gl, cells, { \"positions\": ndarray(position_data, [numVertices, 3]) })\n```\n\nThe drawing mode for the mesh is determined by the shape of the cells according to the following rule:\n\n* `cells.length == 0` : empty mesh\n* `cells[0].length == 1` : `gl.POINTS`\n* `cells[0].length == 2` : `gl.LINES`\n* `cells[0].length == 3` : `gl.TRIANGLES`\n\nYou can also skip the `cells` parameter, in which case the resulting mesh is drawn as a point cloud.\n\n\nAlso you can pass a single object with a `cells` field.  For example, here is the quickest way to create a Stanford bunny test mesh:\n\n```javascript\nvar bunnyMesh = createMesh(gl, require(\"bunny\"))\n```\n\nWhere the module comes from the [`bunny`](https://npmjs.org/package/bunny) package\n\n**Returns** A `Mesh` object\n\n## Methods\nEach `Mesh` object has the following methods:\n\n### `mesh.bind(shader)`\nBinds the mesh to the given shader updating attributes accordingly.\n\n* `shader` is an instance of a shader created using [`gl-shader`](https://github.com/mikolalysenko/gl-shader)\n\n### `mesh.draw()`\nDraws an instance of the mesh once it is bound to a shader\n\n### `mesh.unbind()`\nUnbinds the mesh releasing the current vertex attribute state\n\n### `mesh.dispose()`\nDestroys the mesh and releases all of its associated resources\n\n# Credits\n(c) 2013 Mikola Lysenko. MIT License","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fstackgl%2Fgl-mesh","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fstackgl%2Fgl-mesh","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fstackgl%2Fgl-mesh/lists"}