{"id":20778098,"url":"https://github.com/stackgl/gl-magic-uniforms","last_synced_at":"2025-07-10T12:14:42.486Z","repository":{"id":66140271,"uuid":"62937952","full_name":"stackgl/gl-magic-uniforms","owner":"stackgl","description":"🎩 Create a magic getter/setter object for a given WebGLProgram's uniforms.","archived":false,"fork":false,"pushed_at":"2018-06-17T18:07:58.000Z","size":9,"stargazers_count":18,"open_issues_count":1,"forks_count":3,"subscribers_count":16,"default_branch":"master","last_synced_at":"2024-11-07T04:44:18.684Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"","language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"other","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.md","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2016-07-09T07:25:48.000Z","updated_at":"2023-07-05T02:15:05.000Z","dependencies_parsed_at":"2023-05-07T08:24:20.986Z","dependency_job_id":null,"html_url":"https://github.com/stackgl/gl-magic-uniforms","commit_stats":{"total_commits":5,"total_committers":1,"mean_commits":5.0,"dds":0.0,"last_synced_commit":"fe85138a044917965fece1199304d53b4206bf32"},"previous_names":[],"tags_count":2,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/stackgl%2Fgl-magic-uniforms","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/stackgl%2Fgl-magic-uniforms/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/stackgl%2Fgl-magic-uniforms/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/stackgl%2Fgl-magic-uniforms/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/stackgl","download_url":"https://codeload.github.com/stackgl/gl-magic-uniforms/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":225040983,"owners_count":17411573,"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:19:09.443Z","updated_at":"2024-11-17T13:19:11.268Z","avatar_url":"https://github.com/stackgl.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# gl-magic-uniforms\n\n[![](https://img.shields.io/badge/stability-experimental-ffa100.svg?style=flat-square)](https://nodejs.org/api/documentation.html#documentation_stability_index)\n[![](https://img.shields.io/badge/code%20style-standard-brightgreen.svg?style=flat-square)](http://standardjs.com/)\n[![](https://img.shields.io/npm/v/gl-magic-uniforms.svg?style=flat-square)](https://npmjs.com/package/gl-magic-uniforms)\n[![](https://img.shields.io/circleci/project/stackgl/gl-magic-uniforms/master.svg?style=flat-square)](https://circleci.com/gh/stackgl/gl-magic-uniforms)\n\nCreate a magic getter/setter object for a given WebGLProgram's uniforms. This provides a standalone [gl-shader](https://github.com/stackgl/gl-shader)-style interface for setting shader programs' uniforms that you can use in your own projects.\n\n## Usage\n\n### `uniforms = Magic(gl, program[, uniforms[, opts]])`\n\n* `gl` is the `WebGLRenderingContext` that `program` is attached to.\n* `program` is a `WebGLProgram` instance to modify the uniforms of.\n\nOptionally, you can pass in a custom set of `uniforms` objects. This should be in the same format as the results of [gl-shader-extract](https://github.com/mattdesl/gl-shader-extract). If not supplied, uniforms are automatically inferred at runtime by inspecting `program`.\n\n``` javascript\nvar uniforms = require('gl-magic-uniforms')\n\nvar canvas = document.createElement('canvas')\nvar gl = canvas.getContext('webgl')\nvar program = gl.createProgram()\nvar start = Date.now()\n\n// ...setup the program object...\n\nvar uniforms = MagicUniforms(gl, program)\n\ngl.useProgram(program)\nuniforms.time = (Date.now() - start) / 1000\nuniforms.light = [1, 0, 1, 1]\n```\n\nUniforms can now be got and set by name, in the same style as documented in [gl-shader](https://github.com/stackgl/gl-shader#uniforms).\n\n_**Note:** `program` must be in use when setting `uniforms`, or unexpected behavior may occur. This is not done by default to avoid an excess of calls to `gl.useProgram`._\n\nAdditionally, you can pass in the following options:\n\n* `opts.cacheScalars`: if `true`, scalar uniforms (e.g. `float`, `bool`, `int`) will be cached where possible, reducing the amount of work for the GPU. Defaults to `true`.\n* `opts.cacheVectors`: if `true`, vector uniforms will be cached where possible, provided they're 4 or less elements long. Defaults to `false`, as there are cases where this produces more overhead when enabled depending on how often these values change.\n\n## License\n\nMIT. See [LICENSE.md](LICENSE.md) for details.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fstackgl%2Fgl-magic-uniforms","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fstackgl%2Fgl-magic-uniforms","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fstackgl%2Fgl-magic-uniforms/lists"}