{"_id":"@ahmerhh/webgraphiclibrary-texture","name":"@ahmerhh/webgraphiclibrary-texture","dist-tags":{"latest":"2.0.2"},"versions":{"2.0.2":{"name":"@ahmerhh/webgraphiclibrary-texture","version":"2.0.2","description":"WebGL texture wrapper.","main":"dist/index.js","scripts":{"start":"budo example/index.js --live -- -t babelify","test":"browserify test/index.js -t babelify | browser-run --static . | tap-spec","build":"browserify src/index.js -t babelify -s @ahmerhh/WebGraphicLibrary-texture > dist/index.js","prepublish":"npm run build"},"repository":{"type":"git","url":"git+https://github.com/ahmerhh/WebGraphicLibrary-texture.git"},"keywords":["WebGL","texture"],"author":{"name":"Ahmer","email":"ahmerhh@proton.me"},"author2":"Ahmer <ahmerhabibb@gmail.com","license":"MIT","bugs":{"url":"https://github.com/ahmerhh/WebGraphicLibrary-texture/issues"},"homepage":"https://github.com/ahmerhh/WebGraphicLibrary-texture#readme","devDependencies":{"babel-preset-es2015":"^6.3.13","babelify":"^7.2.0","browser-run":"^3.0.8","browserify":"^13.0.0","budo":"^8.0.3","tap-spec":"^4.1.1","tape":"^4.4.0"},"dependencies":{"@ahmerhh/geo-plane":"^1.0.1","@ahmerhh/gl-buffer":"^1.0.2","@ahmerhh/gl-context":"^1.0.5","@ahmerhh/gl-program":"^1.0.3","math-functions":"^1.0.1"},"directories":{"example":"example","test":"test"},"_id":"@ahmerhh/webgraphiclibrary-texture@2.0.2","gitHead":"a4395274f3ba19bcb6301b235bb7fae068d69382","_nodeVersion":"18.15.0","_npmVersion":"9.8.1","dist":{"integrity":"sha512-npPLS7hXluE78Vz56BA6LDoeLolnGlqZS62IjG+caPIVWi8/xTFPazxQa7EmQb3so2gqJ5ksarMEutUlQY5gWQ==","shasum":"a934bdfacd01d48d7a59bff508d90a9dd0720051","tarball":"https://registry.npmjs.org/@ahmerhh/webgraphiclibrary-texture/-/webgraphiclibrary-texture-2.0.2.tgz","fileCount":5,"unpackedSize":7974,"signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCICWTzUpwYp0/iIlZNBI39k8/aPIjryYmoJ5lEOg+0bBkAiEApv7i62bIJEU1O3w7hVzTUQL6WaaXAbejpTY/U2qznEc="}]},"_npmUser":{"name":"ahmerhh","email":"ahmerhabibb@gmail.com"},"maintainers":[{"name":"ahmerhh","email":"ahmerhabibb@gmail.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/webgraphiclibrary-texture_2.0.2_1691873220158_0.7202574915257389"},"_hasShrinkwrap":false}},"time":{"created":"2023-08-12T20:47:00.083Z","2.0.2":"2023-08-12T20:47:00.324Z","modified":"2023-08-12T20:47:00.601Z"},"maintainers":[{"name":"ahmerhh","email":"ahmerhabibb@gmail.com"}],"description":"WebGL texture wrapper.","homepage":"https://github.com/ahmerhh/WebGraphicLibrary-texture#readme","keywords":["WebGL","texture"],"repository":{"type":"git","url":"git+https://github.com/ahmerhh/WebGraphicLibrary-texture.git"},"author":{"name":"Ahmer","email":"ahmerhh@proton.me"},"bugs":{"url":"https://github.com/ahmerhh/WebGraphicLibrary-texture/issues"},"license":"MIT","readme":"# GL Texture\r\n\r\nWebGL texture wrapper.\r\n\r\nWebGraphicLibrary texture is a WebGL texture wrapper that simplifies the creation and management of textures for use in WebGL applications\r\n\r\n## Installation\r\n\r\n```sh\r\n$ npm install --save @ahmerhh/WebGraphicLibrary-texture\r\n```\r\n\r\n## Usage\r\n\r\n```js\r\nimport Texture from '@ahmerhh/WebGraphicLibrary-texture';\r\n\r\nconst texture = new Texture(gl, gl.TEXTURE_2D);\r\n\r\nconst img = document.createElement('img');\r\n\r\nimg.onload = () => {\r\n\ttexture.bind(1);\r\n\ttexture.setData(img);\r\n}\r\n\r\nimg.src = '';\r\n\r\nprogram.bind();\r\nprogram.setUniform('uTexture', texture.bind(1));\r\n```\r\n\r\n## API\r\n\r\n#### `texture = new Texture(gl, type)`\r\n#### `texture = new Texture(gl, type, width, height)`\r\n#### `texture = new Texture(gl, type, data)`\r\n\r\nCreate a new texture, if no `data` is provided, the texture is empty.\r\n- `gl` is the [WebGL context](https://github.com/ahmerhh/WebGraphicLibrary-context).\r\n- `type` is the texture type. Default is `gl.TEXTURE_2D`.\r\n- `data` can be an image, video or canvas.\r\n\r\n#### `texture.setData(data)`\r\n\r\nSet the texture data. The texture must be bound first.\r\n\r\n```js\r\ntexture.bind(1);\r\ntexture.setData(image);\r\n```\r\n\r\n#### `texture.bind(unit)`\r\n\r\nBind the texture to the given unit, and returns it. Default is `0`.\r\nThis allows to set a [program](https://github.com/ahmerhh/WebGraphicLibrary-Program) uniform at the same time.\r\n\r\n```js\r\nprogram.setUniform('uTextureA', textureA.bind(0));\r\nprogram.setUniform('uTextureB', textureA.bind(1));\r\n```\r\n\r\n#### `texture.dispose()`\r\n\r\nDelete instance. Calls `gl.deleteTexture()`.\r\n\r\n## License\r\n\r\nMIT, see [LICENSE.md](https://github.com/ahmerhh/WebGraphicLibrary-texture/blob/master/LICENSE) for more details.\r\n\r\n## Credits\r\n\r\nThanks to the amazing [stackgl](http://stack.gl/) for the inspiration.\r\n","readmeFilename":"README.md"}