{"id":13534303,"url":"https://github.com/oframe/ogl","last_synced_at":"2025-05-14T23:02:05.406Z","repository":{"id":32517349,"uuid":"134879852","full_name":"oframe/ogl","owner":"oframe","description":"Minimal WebGL Library","archived":false,"fork":false,"pushed_at":"2025-04-13T07:51:49.000Z","size":29139,"stargazers_count":3998,"open_issues_count":20,"forks_count":220,"subscribers_count":65,"default_branch":"master","last_synced_at":"2025-05-07T22:01:57.002Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"https://oframe.github.io/ogl/examples","language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/oframe.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"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,"zenodo":null}},"created_at":"2018-05-25T16:21:37.000Z","updated_at":"2025-05-07T21:55:07.000Z","dependencies_parsed_at":"2024-06-18T12:25:27.568Z","dependency_job_id":"d0c99fca-0597-4280-9e85-47a82e0b5cb9","html_url":"https://github.com/oframe/ogl","commit_stats":{"total_commits":437,"total_committers":23,"mean_commits":19.0,"dds":"0.11212814645308922","last_synced_commit":"861581401f4e1f17e628571e8744d8689afbb651"},"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/oframe%2Fogl","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/oframe%2Fogl/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/oframe%2Fogl/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/oframe%2Fogl/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/oframe","download_url":"https://codeload.github.com/oframe/ogl/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":254243353,"owners_count":22038044,"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-08-01T07:01:30.055Z","updated_at":"2025-05-14T23:02:00.775Z","avatar_url":"https://github.com/oframe.png","language":"JavaScript","readme":"\u003cp align=\"center\"\u003e\n  \u003cimg src=\"https://github.com/oframe/ogl/raw/master/examples/assets/ogl.png\" alt=\"OGL\" width=\"510\" /\u003e\n\u003c/p\u003e\n\n\u003ch1 align=\"center\"\u003eOGL\u003c/h1\u003e\n\n\u003cp align=\"center\"\u003e\n    \u003ca href=\"https://npmjs.org/package/ogl\"\u003e\n        \u003cimg src=\"https://img.shields.io/npm/v/ogl.svg\" alt=\"version\" /\u003e\n    \u003c/a\u003e\n    \u003ca href=\"https://github.com/oframe/ogl/blob/master/LICENSE\"\u003e\n        \u003cimg src=\"https://img.shields.io/npm/l/ogl.svg\" alt=\"license\" /\u003e\n    \u003c/a\u003e\n    \u003ca href=\"https://bundlephobia.com/result?p=ogl\"\u003e\n        \u003cimg src=\"https://badgen.net/bundlephobia/minzip/ogl\" alt=\"size\" /\u003e\n    \u003c/a\u003e\n\u003c/p\u003e\n\n\u003cp align=\"center\"\u003e\u003cb\u003eMinimal WebGL library.\u003c/b\u003e\u003c/p\u003e\n\n\u003cbr /\u003e\n\n[See the Examples!](https://oframe.github.io/ogl/examples)\n\nOGL is a small, effective WebGL library aimed at developers who like minimal layers of abstraction, and are interested in creating their own shaders.\n\nWritten in es6 modules with zero dependencies, the API shares many similarities with ThreeJS, however it is tightly coupled with WebGL and comes with much fewer features.\n\nIn its design, the library does the minimum abstraction necessary, so devs should still feel comfortable using it in conjunction with native WebGL commands.\n\nKeeping the level of abstraction low helps to make the library easier to understand, extend, and also makes it more practical as a WebGL learning resource.\n\n## Install\n\n[Download](https://github.com/oframe/ogl/archive/master.zip)\n\n**or**\n\n```\nnpm i ogl\n```\n\n**or**\n\n```\nyarn add ogl\n```\n\n## Examples\n\n[Show me what you got!](https://oframe.github.io/ogl/examples) - Explore a comprehensive list of examples, with comments in the source code.\n\nInspired by the effectiveness of ThreeJS' examples, they will hopefully serve as reference for how to use the library, and to achieve a wide range of techniques.\n\n## Weight\n\nEven though the source is modular, as a guide, below are the complete component download sizes.\n\n| Component | Size (minzipped) |\n| --------- | ---------------: |\n| Core      |              8kb |\n| Math      |              6kb |\n| Extras    |             15kb |\n| Total     |             29kb |\n\nWith tree-shaking applied in a build step, one can expect the final size to be much lighter than the values above.\n\n## Usage\n\nIf installed amongst your project files, importing can be done from one single entry point.\n\n```js\nimport { ... } from './path/to/src/index.js';\n```\n\nElse if using a bundler or import maps with node modules, then import directly from the installed node module.\n\n```js\nimport { ... } from 'ogl';\n```\n\nBy default, the ES source modules are loaded (`src/index.js`).\n\nAs another alternative, you could load from a CDN, using either the jsdelivr, unpkg or skypack services.\n\n```js\nimport { ... } from 'https://cdn.jsdelivr.net/npm/ogl';\nimport { ... } from 'https://unpkg.com/ogl';\nimport { ... } from 'https://cdn.skypack.dev/ogl';\n```\n\nIf you take this route, I would highly recommend defining a specific version (append `@x.x.x`) to avoid code breaking, rather than fetching the latest version, as per the above links.\n\nAs a basic API example, below renders a spinning white cube.\n\n```js\nimport { Renderer, Camera, Transform, Box, Program, Mesh } from 'ogl';\n\n{\n    const renderer = new Renderer();\n    const gl = renderer.gl;\n    document.body.appendChild(gl.canvas);\n\n    const camera = new Camera(gl);\n    camera.position.z = 5;\n\n    function resize() {\n        renderer.setSize(window.innerWidth, window.innerHeight);\n        camera.perspective({\n            aspect: gl.canvas.width / gl.canvas.height,\n        });\n    }\n    window.addEventListener('resize', resize, false);\n    resize();\n\n    const scene = new Transform();\n\n    const geometry = new Box(gl);\n\n    const program = new Program(gl, {\n        vertex: /* glsl */ `\n            attribute vec3 position;\n\n            uniform mat4 modelViewMatrix;\n            uniform mat4 projectionMatrix;\n\n            void main() {\n                gl_Position = projectionMatrix * modelViewMatrix * vec4(position, 1.0);\n            }\n        `,\n        fragment: /* glsl */ `\n            void main() {\n                gl_FragColor = vec4(1.0);\n            }\n        `,\n    });\n\n    const mesh = new Mesh(gl, { geometry, program });\n    mesh.setParent(scene);\n\n    requestAnimationFrame(update);\n    function update(t) {\n        requestAnimationFrame(update);\n\n        mesh.rotation.y -= 0.04;\n        mesh.rotation.x += 0.03;\n\n        renderer.render({ scene, camera });\n    }\n}\n```\n\nHere you can play with the above template live in a codesandbox\nhttps://codesandbox.io/s/ogl-5i69p\n\nFor a simpler use, such as a full-screen shader, more of the core can be omitted as a scene graph (Transform) and projection matrices (Camera) are not necessary. We'll also show how to easily create custom geometry.\n\n```js\nimport { Renderer, Geometry, Program, Mesh } from 'ogl';\n\n{\n    const renderer = new Renderer({\n        width: window.innerWidth,\n        height: window.innerHeight,\n    });\n    const gl = renderer.gl;\n    document.body.appendChild(gl.canvas);\n\n    // Triangle that covers viewport, with UVs that still span 0 \u003e 1 across viewport\n    const geometry = new Geometry(gl, {\n        position: { size: 2, data: new Float32Array([-1, -1, 3, -1, -1, 3]) },\n        uv: { size: 2, data: new Float32Array([0, 0, 2, 0, 0, 2]) },\n    });\n    // Alternatively, you could use the Triangle class.\n\n    const program = new Program(gl, {\n        vertex: /* glsl */ `\n            attribute vec2 uv;\n            attribute vec2 position;\n\n            varying vec2 vUv;\n\n            void main() {\n                vUv = uv;\n                gl_Position = vec4(position, 0, 1);\n            }\n        `,\n        fragment: /* glsl */ `\n            precision highp float;\n\n            uniform float uTime;\n\n            varying vec2 vUv;\n\n            void main() {\n                gl_FragColor.rgb = vec3(0.8, 0.7, 1.0) + 0.3 * cos(vUv.xyx + uTime);\n                gl_FragColor.a = 1.0;\n            }\n        `,\n        uniforms: {\n            uTime: { value: 0 },\n        },\n    });\n\n    const mesh = new Mesh(gl, { geometry, program });\n\n    requestAnimationFrame(update);\n    function update(t) {\n        requestAnimationFrame(update);\n\n        program.uniforms.uTime.value = t * 0.001;\n\n        // Don't need a camera if camera uniforms aren't required\n        renderer.render({ scene: mesh });\n    }\n}\n```\n\n## Structure\n\nIn an attempt to keep things light and modular, the library is split up into three components: **Math**, **Core**, and **Extras**.\n\nThe **Math** component is an extension of [gl-matrix](http://glmatrix.net/), providing instancable classes that extend Array for each of the module types. 8kb when gzipped, it has no dependencies and can be used separately.\n\nThe **Core** is made up of the following:\n\n-   Geometry.js\n-   Program.js\n-   Renderer.js\n-   Camera.js\n-   Transform.js\n-   Mesh.js\n-   Texture.js\n-   RenderTarget.js\n\nAny additional layers of abstraction will be included as **Extras**, and not part of the core as to reduce bloat. These provide a wide breadth of functionality, ranging from simple to advanced.\n\n## Unlicense\n\nThis is free and unencumbered software released into the public domain.\n\nAnyone is free to copy, modify, publish, use, compile, sell, or\ndistribute this software, either in source code form or as a compiled\nbinary, for any purpose, commercial or non-commercial, and by any\nmeans.\n\nIn jurisdictions that recognize copyright laws, the author or authors\nof this software dedicate any and all copyright interest in the\nsoftware to the public domain. We make this dedication for the benefit\nof the public at large and to the detriment of our heirs and\nsuccessors. We intend this dedication to be an overt act of\nrelinquishment in perpetuity of all present and future rights to this\nsoftware under copyright law.\n\nTHE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND,\nEXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF\nMERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.\nIN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR\nOTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,\nARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR\nOTHER DEALINGS IN THE SOFTWARE.\n\nFor more information, please refer to \u003chttps://unlicense.org\u003e\n","funding_links":[],"categories":["Libraries","JavaScript","Tools","Uncategorized"],"sub_categories":["JavaScript","Web Programming • Libraries","Uncategorized"],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Foframe%2Fogl","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Foframe%2Fogl","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Foframe%2Fogl/lists"}