Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

gl-texture2d

Package Overview
Dependencies
Maintainers
11
Versions
34
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

gl-texture2d - npm Package Compare versions

Comparing version 2.0.12 to 2.1.0

2

package.json
{
"name": "gl-texture2d",
"version": "2.0.12",
"version": "2.1.0",
"description": "WebGL texture wrapper",

@@ -5,0 +5,0 @@ "main": "texture.js",

@@ -90,2 +90,8 @@ gl-texture2d

### `var tex = createTexture(gl, rawObject[, format, type])`
Creates a texture from the given raw element. `rawObject` is a DOM-like element that have a `raw`, `width` and `height` fields. `raw` is a value that directly get passed to `texImage2D` / `texSubImage2D`.
This allows to support non-DOM implementation of WebGL like gl-headless.
### `var tex = createTexture(gl, array)`

@@ -135,3 +141,3 @@ Creates a texture from an [ndarray](https://github.com/mikolalysenko/ndarray). The rules for selecting the format and type depend on the shape of the ndarray. The type of the texture is inferred according to the following rules. Let:

### `tex.setPixels(data[, offset, mipLevel])`
Unpacks `data` into a subregion of the texture. As before in the constructor `data` can be either an `ndarray`, `HTMLCanvas`, `HTMLImage` or `HTMLVideo` object. If `data` is an ndarray it must have a compatible format with the initial array layout.
Unpacks `data` into a subregion of the texture. As before in the constructor `data` can be either an `ndarray`, `HTMLCanvas`, `HTMLImage`, `HTMLVideo` or a `rawObject`. If `data` is an ndarray it must have a compatible format with the initial array layout.

@@ -138,0 +144,0 @@ * `offset` is a length 2 array representing the offset into which the pixels will be written in `[x,y]`. (Default: `[0,0]`)

@@ -306,9 +306,10 @@ 'use strict'

mip_level = mip_level || 0
if(acceptTextureDOM(data)) {
var directData = acceptTextureDOM(data) ? data : data.raw
if(directData) {
var needsMip = this._mipLevels.indexOf(mip_level) < 0
if(needsMip) {
gl.texImage2D(gl.TEXTURE_2D, 0, this.format, this.format, this.type, data)
gl.texImage2D(gl.TEXTURE_2D, 0, this.format, this.format, this.type, directData)
this._mipLevels.push(mip_level)
} else {
gl.texSubImage2D(gl.TEXTURE_2D, mip_level, x_off, y_off, this.format, this.type, data)
gl.texSubImage2D(gl.TEXTURE_2D, mip_level, x_off, y_off, this.format, this.type, directData)
}

@@ -460,6 +461,6 @@ } else if(data.shape && data.stride && data.data) {

function createTextureDOM(gl, element, format, type) {
function createTextureDOM(gl, directData, width, height, format, type) {
var tex = initTexture(gl)
gl.texImage2D(gl.TEXTURE_2D, 0, format, format, type, element)
return new Texture2D(gl, tex, element.width|0, element.height|0, format, type)
gl.texImage2D(gl.TEXTURE_2D, 0, format, format, type, directData)
return new Texture2D(gl, tex, width, height, format, type)
}

@@ -554,4 +555,5 @@

var obj = arguments[1]
if (acceptTextureDOM(obj)) {
return createTextureDOM(gl, obj, arguments[2]||gl.RGBA, arguments[3]||gl.UNSIGNED_BYTE)
var directData = acceptTextureDOM(obj) ? obj : obj.raw
if (directData) {
return createTextureDOM(gl, directData, obj.width|0, obj.height|0, arguments[2]||gl.RGBA, arguments[3]||gl.UNSIGNED_BYTE)
} else if(obj.shape && obj.data && obj.stride) {

@@ -558,0 +560,0 @@ return createTextureArray(gl, obj)

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc