Socket
Socket
Sign inDemoInstall

regl

Package Overview
Dependencies
Maintainers
5
Versions
42
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

regl - npm Package Compare versions

Comparing version 1.3.13 to 1.4.0

2

DEVELOPING.md

@@ -24,3 +24,3 @@ # A developer's guide to regl

```sh
budo basic.js --open
budo example/basic.js --open
```

@@ -27,0 +27,0 @@

@@ -219,2 +219,5 @@ // Type definitions for regl 1.3.1

/* Creates a vertex array object */
vao(attributes: REGL.AttributeState[]) : REGL.VertexArrayObject;
/* Events and listeners */

@@ -485,2 +488,7 @@

/**
* Configuration of vertex array object
*/
vao?: REGL.MaybeDynamic<REGL.VertexArrayObject | AttributeState[], ParentContext & OwnContext, Props>,
/* Drawing */

@@ -659,3 +667,3 @@

type Attribute =
type AttributeState =
ConstantAttribute |

@@ -666,2 +674,6 @@ AttributeConfig |

type Attribute =
number |
AttributeState;
interface Attributes {

@@ -685,13 +697,15 @@ [name: string]: Attribute;

/** A REGLBuffer wrapping the buffer object. (Default: null) */
buffer?: REGL.Buffer;
buffer?: REGL.Buffer|undefined|null|false;
/** The offset of the vertexAttribPointer in bytes. (Default: 0) */
offset?: number;
offset?: number|undefined;
/** The stride of the vertexAttribPointer in bytes. (Default: 0) */
stride?: number;
stride?: number|undefined;
/** Whether the pointer is normalized. (Default: false) */
normalized?: boolean;
/** The size of the vertex attribute. (Default: Inferred from shader) */
size?: number;
size?: number|undefined;
/** Sets gl.vertexAttribDivisorANGLE. Only supported if the ANGLE_instanced_arrays extension is available. (Default: 0) */
divisor?: number;
divisor?: number|undefined;
/** Data type for attribute */
type?: 'uint8'|'uint16'|'uint32'|'float'|'int8'|'int16'|'int32';
}

@@ -946,2 +960,6 @@

interface VertexArrayObject extends REGL.Resource {
(attributes:REGL.AttributeState[]) : REGL.VertexArrayObject;
}
interface Buffer extends REGL.Resource {

@@ -1648,2 +1666,4 @@ /**

maxTextureUnits: number;
/** Number of vertex array objects */
vaoCount: number;

@@ -1650,0 +1670,0 @@ // The following functions are only available if regl is initialized with option `profile: true`

@@ -0,2 +1,9 @@

var check = require('./util/check')
var values = require('./util/values')
var bufferTypes = require('./constants/dtypes.json')
var isTypedArray = require('./util/is-typed-array')
var isNDArrayLike = require('./util/is-ndarray')
var GL_FLOAT = 5126
var GL_ARRAY_BUFFER = 34962

@@ -24,3 +31,4 @@ function AttributeRecord () {

limits,
stringStore) {
stats,
bufferState) {
var NUM_ATTRIBUTES = limits.maxAttributes

@@ -31,8 +39,242 @@ var attributeBindings = new Array(NUM_ATTRIBUTES)

}
var vaoCount = 0
var vaoSet = {}
return {
var state = {
Record: AttributeRecord,
scope: {},
state: attributeBindings
state: attributeBindings,
currentVAO: null,
targetVAO: null,
restore: extVAO() ? restoreVAO : function () {},
createVAO: createVAO,
getVAO: getVAO,
destroyBuffer: destroyBuffer,
setVAO: extVAO() ? setVAOEXT : setVAOEmulated,
clear: extVAO() ? destroyVAOEXT : function () {}
}
function destroyBuffer (buffer) {
for (var i = 0; i < attributeBindings.length; ++i) {
var record = attributeBindings[i]
if (record.buffer === buffer) {
gl.disableVertexAttribArray(i)
record.buffer = null
}
}
}
function extVAO () {
return extensions.oes_vertex_array_object
}
function extInstanced () {
return extensions.angle_instanced_arrays
}
function getVAO (vao) {
if (typeof vao === 'function' && vao._vao) {
return vao._vao
}
return null
}
function setVAOEXT (vao) {
if (vao === state.currentVAO) {
return
}
var ext = extVAO()
if (vao) {
ext.bindVertexArrayOES(vao.vao)
} else {
ext.bindVertexArrayOES(null)
}
state.currentVAO = vao
}
function setVAOEmulated (vao) {
if (vao === state.currentVAO) {
return
}
if (vao) {
vao.bindAttrs()
} else {
var exti = extInstanced()
for (let i = 0; i < attributeBindings.length; ++i) {
var binding = attributeBindings[i]
if (binding.buffer) {
gl.enableVertexAttribArray(i)
gl.vertexAttribPointer(i, binding.size, binding.type, binding.normalized, binding.stride, binding.offfset)
if (exti) {
exti.vertexAttribDivisorANGLE(i, binding.divisor)
}
} else {
gl.disableVertexAttribArray(i)
gl.vertexAttrib4f(i, binding.x, binding.y, binding.z, binding.w)
}
}
}
state.currentVAO = vao
}
function destroyVAOEXT (vao) {
values(vaoSet).forEach((vao) => {
vao.destroy()
})
}
function REGLVAO () {
this.id = ++vaoCount
this.attributes = []
var extension = extVAO()
if (extension) {
this.vao = extension.createVertexArrayOES()
} else {
this.vao = null
}
vaoSet[this.id] = this
this.buffers = []
}
REGLVAO.prototype.bindAttrs = function () {
var exti = extInstanced()
var attributes = this.attributes
for (var i = 0; i < attributes.length; ++i) {
var attr = attributes[i]
if (attr.buffer) {
gl.enableVertexAttribArray(i)
gl.bindBuffer(GL_ARRAY_BUFFER, attr.buffer.buffer)
gl.vertexAttribPointer(i, attr.size, attr.type, attr.normalized, attr.stride, attr.offset)
if (exti) {
exti.vertexAttribDivisorANGLE(i, attr.divisor)
}
} else {
gl.disableVertexAttribArray(i)
gl.vertexAttrib4f(i, attr.x, attr.y, attr.z, attr.w)
}
}
for (var j = attributes.length; j < NUM_ATTRIBUTES; ++j) {
gl.disableVertexAttribArray(j)
}
}
REGLVAO.prototype.refresh = function () {
var ext = extVAO()
if (ext) {
ext.bindVertexArrayOES(this.vao)
this.bindAttrs()
state.currentVAO = this
}
}
REGLVAO.prototype.destroy = function () {
if (this.vao) {
var extension = extVAO()
if (this === state.currentVAO) {
state.currentVAO = null
extension.bindVertexArrayOES(null)
}
extension.deleteVertexArrayOES(this.vao)
this.vao = null
}
if (vaoSet[this.id]) {
delete vaoSet[this.id]
stats.vaoCount -= 1
}
}
function restoreVAO () {
var ext = extVAO()
if (ext) {
values(vaoSet).forEach(function (vao) {
vao.refresh()
})
}
}
function createVAO (_attr) {
var vao = new REGLVAO()
stats.vaoCount += 1
function updateVAO (attributes) {
check(Array.isArray(attributes), 'arguments to vertex array constructor must be an array')
check(attributes.length < NUM_ATTRIBUTES, 'too many attributes')
check(attributes.length > 0, 'must specify at least one attribute')
for (var j = 0; j < vao.buffers.length; ++j) {
vao.buffers[j].destroy()
}
vao.buffers.length = 0
var nattributes = vao.attributes
nattributes.length = attributes.length
for (var i = 0; i < attributes.length; ++i) {
var spec = attributes[i]
var rec = nattributes[i] = new AttributeRecord()
if (Array.isArray(spec) || isTypedArray(spec) || isNDArrayLike(spec)) {
var buf = bufferState.create(spec, GL_ARRAY_BUFFER, false, true)
rec.buffer = bufferState.getBuffer(buf)
rec.size = rec.buffer.dimension | 0
rec.normalized = false
rec.type = rec.buffer.dtype
rec.offset = 0
rec.stride = 0
rec.divisor = 0
rec.state = 1
vao.buffers.push(buf)
} else if (bufferState.getBuffer(spec)) {
rec.buffer = bufferState.getBuffer(spec)
rec.size = rec.buffer.dimension | 0
rec.normalized = false
rec.type = rec.buffer.dtype
rec.offset = 0
rec.stride = 0
rec.divisor = 0
rec.state = 1
} else if (bufferState.getBuffer(spec.buffer)) {
rec.buffer = bufferState.getBuffer(spec.buffer)
rec.size = ((+spec.size) || rec.buffer.dimension) | 0
rec.normalized = !!spec.normalized || false
if ('type' in spec) {
check.parameter(spec.type, bufferTypes, 'invalid buffer type')
rec.type = bufferTypes[spec.type]
} else {
rec.type = rec.buffer.dtype
}
rec.offset = (spec.offset || 0) | 0
rec.stride = (spec.stride || 0) | 0
rec.divisor = (spec.divisor || 0) | 0
rec.state = 1
check(rec.size >= 1 && rec.size <= 4, 'size must be between 1 and 4')
check(rec.offset >= 0, 'invalid offset')
check(rec.stride >= 0 && rec.stride <= 255, 'stride must be between 0 and 255')
check(rec.divisor >= 0, 'divisor must be positive')
check(!rec.divisor || !!extensions.angle_instanced_arrays, 'ANGLE_instanced_arrays must be enabled to use divisor')
} else if ('x' in spec) {
check(i > 0, 'first attribute must not be a constant')
rec.x = +spec.x || 0
rec.y = +spec.y || 0
rec.z = +spec.z || 0
rec.w = +spec.w || 0
rec.state = 2
} else {
check(false, 'invalid attribute spec for location ' + i)
}
}
vao.refresh()
return updateVAO
}
updateVAO.destroy = function () {
vao.destroy()
}
updateVAO._vao = vao
return updateVAO(_attr)
}
return state
}

@@ -50,3 +50,3 @@ var check = require('./util/check')

module.exports = function wrapBufferState (gl, stats, config, attributeState) {
module.exports = function wrapBufferState (gl, stats, config, destroyBuffer) {
var bufferCount = 0

@@ -67,3 +67,3 @@ var bufferSet = {}

if (config.profile) {
this.stats = {size: 0}
this.stats = { size: 0 }
}

@@ -209,9 +209,4 @@ }

for (var i = 0; i < attributeState.state.length; ++i) {
var record = attributeState.state[i]
if (record.buffer === buffer) {
gl.disableVertexAttribArray(i)
record.buffer = null
}
}
// remove attribute link
destroyBuffer(buffer)

@@ -218,0 +213,0 @@ var handle = buffer.buffer

@@ -33,4 +33,4 @@ var VARIABLE_COUNTER = 0

splitParts(str.substr(0, parts.index))
.concat(splitParts(parts[1]))
.concat(splitParts(str.substr(parts.index + parts[0].length)))
.concat(splitParts(parts[1]))
.concat(splitParts(str.substr(parts.index + parts[0].length)))
)

@@ -37,0 +37,0 @@ }

@@ -79,6 +79,7 @@ var check = require('./util/check')

elements.buffer.bind()
var dtype
if (data) {
var predictedType = type
if (!type && (
!isTypedArray(data) ||
!isTypedArray(data) ||
(isNDArrayLike(data) && !isTypedArray(data.data)))) {

@@ -103,3 +104,3 @@ predictedType = extensions.oes_element_index_uint

var dtype = type
dtype = type
if (!type) {

@@ -200,6 +201,6 @@ switch (elements.buffer.dtype) {

check(
Array.isArray(data) ||
Array.isArray(data) ||
isTypedArray(data) ||
isNDArrayLike(data),
'invalid data for element buffer')
'invalid data for element buffer')
}

@@ -206,0 +207,0 @@ if ('usage' in options) {

@@ -443,6 +443,6 @@ var check = require('./util/check')

!(colorType === 'float' || colorType === 'float32'),
'you must enable OES_texture_float in order to use floating point framebuffer objects')
'you must enable OES_texture_float in order to use floating point framebuffer objects')
check(extensions.oes_texture_half_float ||
!(colorType === 'half float' || colorType === 'float16'),
'you must enable OES_texture_half_float in order to use 16-bit floating point framebuffer objects')
'you must enable OES_texture_half_float in order to use 16-bit floating point framebuffer objects')
}

@@ -585,3 +585,3 @@ check.oneOf(colorType, colorTypes, 'invalid color type')

colorRenderbufferFormatEnums.indexOf(colorAttachments[i].renderbuffer._renderbuffer.format) >= 0),
'framebuffer color attachment ' + i + ' is invalid')
'framebuffer color attachment ' + i + ' is invalid')

@@ -600,3 +600,3 @@ if (colorAttachments[i] && colorAttachments[i].texture) {

check(commonColorAttachmentSize === colorAttachmentSize,
'all color attachments much have the same number of bits per pixel.')
'all color attachments much have the same number of bits per pixel.')
}

@@ -611,3 +611,3 @@ }

depthAttachment.renderbuffer._renderbuffer.format === GL_DEPTH_COMPONENT16),
'invalid depth attachment for framebuffer object')
'invalid depth attachment for framebuffer object')
incRefAndCheckShape(stencilAttachment, width, height)

@@ -617,3 +617,3 @@ check(!stencilAttachment ||

stencilAttachment.renderbuffer._renderbuffer.format === GL_STENCIL_INDEX8),
'invalid stencil attachment for framebuffer object')
'invalid stencil attachment for framebuffer object')
incRefAndCheckShape(depthStencilAttachment, width, height)

@@ -625,3 +625,3 @@ check(!depthStencilAttachment ||

depthStencilAttachment.renderbuffer._renderbuffer.format === GL_DEPTH_STENCIL),
'invalid depth-stencil attachment for framebuffer object')
'invalid depth-stencil attachment for framebuffer object')

@@ -628,0 +628,0 @@ // decrement references

@@ -27,3 +27,3 @@ var check = require('./util/check')

framebufferState.next.colorAttachments[0].texture !== null,
'You cannot read from a renderbuffer')
'You cannot read from a renderbuffer')
type = framebufferState.next.colorAttachments[0].texture._texture.type

@@ -111,4 +111,4 @@

gl.readPixels(x, y, width, height, GL_RGBA,
type,
data)
type,
data)

@@ -138,2 +138,1 @@ return data

}

@@ -82,3 +82,3 @@ var check = require('./util/check')

if (config.profile) {
this.stats = {size: 0}
this.stats = { size: 0 }
}

@@ -85,0 +85,0 @@ }

@@ -74,3 +74,3 @@ var check = require('./util/check')

function linkProgram (desc, command) {
function linkProgram (desc, command, attributeLocations) {
var i, info

@@ -87,2 +87,9 @@

gl.attachShader(program, vertShader)
if (attributeLocations) {
for (let i = 0; i < attributeLocations.length; ++i) {
var binding = attributeLocations[i]
gl.bindAttribLocation(program, binding[0], binding[1])
}
}
gl.linkProgram(program)

@@ -173,3 +180,5 @@ check.linkError(

for (var i = 0; i < programList.length; ++i) {
linkProgram(programList[i])
linkProgram(programList[i], null, programList[i].attributes.map(function (info) {
return [info.location, info.name]
}))
}

@@ -195,3 +204,3 @@ }

program: function (vertId, fragId, command) {
program: function (vertId, fragId, command, attribLocations) {
check.command(vertId >= 0, 'missing vertex shader', command)

@@ -204,11 +213,13 @@ check.command(fragId >= 0, 'missing fragment shader', command)

}
var program = cache[vertId]
if (!program) {
program = new REGLProgram(fragId, vertId)
stats.shaderCount++
linkProgram(program, command)
var prevProgram = cache[vertId]
if (prevProgram && !attribLocations) {
return prevProgram
}
var program = new REGLProgram(fragId, vertId)
stats.shaderCount++
linkProgram(program, command, attribLocations)
if (!prevProgram) {
cache[vertId] = program
programList.push(program)
}
programList.push(program)
return program

@@ -215,0 +226,0 @@ },

module.exports = function stats () {
return {
vaoCount: 0,
bufferCount: 0,

@@ -5,0 +6,0 @@ elementsCount: 0,

module.exports = function createStringStore () {
var stringIds = {'': 0}
var stringIds = { '': 0 }
var stringValues = ['']

@@ -4,0 +4,0 @@ return {

@@ -136,2 +136,3 @@ var check = require('./util/check')

var CANVAS_CLASS = objectName('HTMLCanvasElement')
var OFFSCREENCANVAS_CLASS = objectName('OffscreenCanvas')
var CONTEXT2D_CLASS = objectName('CanvasRenderingContext2D')

@@ -144,2 +145,3 @@ var BITMAP_CLASS = objectName('ImageBitmap')

CANVAS_CLASS,
OFFSCREENCANVAS_CLASS,
CONTEXT2D_CLASS,

@@ -209,2 +211,6 @@ BITMAP_CLASS,

function isOffscreenCanvas (object) {
return classString(object) === OFFSCREENCANVAS_CLASS
}
function isContext2D (object) {

@@ -498,3 +504,6 @@ return classString(object) === CONTEXT2D_CLASS

glenum === GL_DEPTH_COMPONENT ||
glenum === GL_DEPTH_STENCIL) {
glenum === GL_DEPTH_STENCIL ||
(extensions.ext_srgb &&
(glenum === GL_SRGB_EXT ||
glenum === GL_SRGB_ALPHA_EXT))) {
color[glenum] = glenum

@@ -577,9 +586,9 @@ } else if (glenum === GL_RGB5_A1 || key.indexOf('rgba') >= 0) {

!(type === 'float' || type === 'float32'),
'you must enable the OES_texture_float extension in order to use floating point textures.')
'you must enable the OES_texture_float extension in order to use floating point textures.')
check(extensions.oes_texture_half_float ||
!(type === 'half float' || type === 'float16'),
'you must enable the OES_texture_half_float extension in order to use 16-bit floating point textures.')
'you must enable the OES_texture_half_float extension in order to use 16-bit floating point textures.')
check(extensions.webgl_depth_texture ||
!(type === 'uint16' || type === 'uint32' || type === 'depth stencil'),
'you must enable the WEBGL_depth_texture extension in order to use depth/stencil textures.')
'you must enable the WEBGL_depth_texture extension in order to use depth/stencil textures.')
check.parameter(type, textureTypes,

@@ -634,3 +643,3 @@ 'invalid texture type')

!(formatStr === 'depth' || formatStr === 'depth stencil'),
'you must enable the WEBGL_depth_texture extension in order to use depth/stencil textures.')
'you must enable the WEBGL_depth_texture extension in order to use depth/stencil textures.')
check.parameter(formatStr, textureFormats,

@@ -726,3 +735,3 @@ 'invalid texture format')

image.height > 0 && image.height <= viewH,
'copy texture read out of bounds')
'copy texture read out of bounds')
} else if (!data) {

@@ -770,4 +779,4 @@ image.width = image.width || 1

transposeData(image, array, strideX, strideY, strideC, data.offset)
} else if (isCanvasElement(data) || isContext2D(data)) {
if (isCanvasElement(data)) {
} else if (isCanvasElement(data) || isOffscreenCanvas(data) || isContext2D(data)) {
if (isCanvasElement(data) || isOffscreenCanvas(data)) {
image.element = data

@@ -839,3 +848,2 @@ } else {

var height = info.height
var channels = info.channels

@@ -853,12 +861,3 @@ setFlags(info)

} else {
var nullData = !data
if (nullData) {
data = pool.zero.allocType(type, width * height * channels)
}
gl.texImage2D(target, miplevel, format, width, height, 0, format, type, data)
if (nullData && data) {
pool.zero.freeType(data)
}
gl.texImage2D(target, miplevel, format, width, height, 0, format, type, data || null)
}

@@ -966,10 +965,13 @@ }

if (mipmap.compressed &&
(mipmap.internalformat === GL_COMPRESSED_RGB_S3TC_DXT1_EXT) ||
(mipmap.internalformat === GL_COMPRESSED_RGBA_S3TC_DXT1_EXT) ||
(mipmap.internalformat === GL_COMPRESSED_RGBA_S3TC_DXT3_EXT) ||
(mipmap.internalformat === GL_COMPRESSED_RGBA_S3TC_DXT5_EXT)) {
check(mipmap.width % 4 === 0 &&
mipmap.height % 4 === 0,
'for compressed texture formats, mipmap level 0 must have width and height that are a multiple of 4')
if (
mipmap.compressed &&
(
mipmap.internalformat === GL_COMPRESSED_RGB_S3TC_DXT1_EXT ||
mipmap.internalformat === GL_COMPRESSED_RGBA_S3TC_DXT1_EXT ||
mipmap.internalformat === GL_COMPRESSED_RGBA_S3TC_DXT3_EXT ||
mipmap.internalformat === GL_COMPRESSED_RGBA_S3TC_DXT5_EXT
)
) {
check(mipmap.width % 4 === 0 && mipmap.height % 4 === 0,
'for compressed texture formats, mipmap level 0 must have width and height that are a multiple of 4')
}

@@ -1075,3 +1077,3 @@ }

anisotropic >= 1 && anisotropic <= limits.maxAnisotropic,
'aniso samples must be between 1 and ')
'aniso samples must be between 1 and ')
info.anisotropic = options.anisotropic

@@ -1152,3 +1154,3 @@ }

if (config.profile) {
this.stats = {size: 0}
this.stats = { size: 0 }
}

@@ -1351,6 +1353,2 @@ }

var data
var channels = texture.channels
var type = texture.type
for (var i = 0; texture.mipmask >> i; ++i) {

@@ -1360,3 +1358,2 @@ var _w = w >> i

if (!_w || !_h) break
data = pool.zero.allocType(type, _w * _h * channels)
gl.texImage2D(

@@ -1371,4 +1368,3 @@ GL_TEXTURE_2D,

texture.type,
data)
if (data) pool.zero.freeType(data)
null)
}

@@ -1439,10 +1435,10 @@ tempRestore()

if ('faces' in a0) {
var face_input = a0.faces
check(Array.isArray(face_input) && face_input.length === 6,
var faceInput = a0.faces
check(Array.isArray(faceInput) && faceInput.length === 6,
'cube faces must be a length 6 array')
for (i = 0; i < 6; ++i) {
check(typeof face_input[i] === 'object' && !!face_input[i],
check(typeof faceInput[i] === 'object' && !!faceInput[i],
'invalid input for cube map face')
copyFlags(faces[i], texture)
parseMipMapFromObject(faces[i], face_input[i])
parseMipMapFromObject(faces[i], faceInput[i])
}

@@ -1449,0 +1445,0 @@ } else {

@@ -55,4 +55,16 @@ // Error checking and parameter validation.

function standardTypeEh (value, type) {
switch (type) {
case 'number': return typeof value === 'number'
case 'object': return typeof value === 'object'
case 'string': return typeof value === 'string'
case 'boolean': return typeof value === 'boolean'
case 'function': return typeof value === 'function'
case 'undefined': return typeof value === 'undefined'
case 'symbol': return typeof value === 'symbol'
}
}
function checkTypeOf (value, type, message) {
if (typeof value !== type) {
if (!standardTypeEh(value, type)) {
raise(

@@ -165,3 +177,3 @@ 'invalid parameter type' + encolon(message) +

var line = lines[i]
var parts = /^\s*\#\s*(\w+)\s+(.+)\s*$/.exec(line)
var parts = /^\s*#\s*(\w+)\s+(.+)\s*$/.exec(line)
if (parts) {

@@ -185,4 +197,4 @@ switch (parts[1]) {

files[fileNumber].name = (nameInfo[1]
? decodeB64(nameInfo[2])
: nameInfo[2])
? decodeB64(nameInfo[2])
: nameInfo[2])
}

@@ -209,3 +221,3 @@ break

}
var parts = /^ERROR\:\s+(\d+)\:(\d+)\:\s*(.*)$/.exec(errMsg)
var parts = /^ERROR:\s+(\d+):(\d+):\s*(.*)$/.exec(errMsg)
if (parts) {

@@ -273,3 +285,3 @@ result.push(new ShaderError(

var message = error.message
var token = /^\s*\'(.*)\'\s*\:\s*(.*)$/.exec(message)
var token = /^\s*'(.*)'\s*:\s*(.*)$/.exec(message)
if (token) {

@@ -391,3 +403,3 @@ var tokenPat = token[1]

function checkCommandType (value, type, message, command) {
if (typeof value !== type) {
if (!standardTypeEh(value, type)) {
commandRaise(

@@ -483,3 +495,3 @@ 'invalid parameter type' + encolon(message) +

h > 0 && h <= limits.maxTextureSize,
'invalid texture shape')
'invalid texture shape')

@@ -616,3 +628,3 @@ // check wrap mode

Math.max(pixelSize(img.type, c), img.unpackAlignment),
'invalid data for image, buffer size is inconsistent with image format')
'invalid data for image, buffer size is inconsistent with image format')
} else if (img.element) {

@@ -619,0 +631,0 @@ // TODO: check element can be loaded

/* globals performance */
module.exports =
(typeof performance !== 'undefined' && performance.now)
? function () { return performance.now() }
: function () { return +(new Date()) }
? function () { return performance.now() }
: function () { return +(new Date()) }

@@ -184,2 +184,4 @@ // Context and canvas creation helper functions

}
// workaround for chromium bug, premultiplied alpha value is platform dependent
contextAttributes.premultipliedAlpha = contextAttributes.premultipliedAlpha || false
gl = createContext(canvas, contextAttributes)

@@ -186,0 +188,0 @@ }

{
"name": "regl",
"version": "1.3.13",
"version": "1.4.0",
"description": "regl is a fast functional WebGL framework.",

@@ -46,3 +46,3 @@ "main": "dist/regl.js",

"git-parse-commit": "^1.0.0",
"gl": "^4.0.1",
"gl": "4.0.1",
"gl-mat3": "^1.0.0",

@@ -78,11 +78,11 @@ "gl-mat4": "^1.1.4",

"resl": "^1.0.0",
"rollup": "^0.36.1",
"rollup-plugin-buble": "^0.14.0",
"rollup-plugin-commonjs": "^5.0.4",
"rollup-plugin-json": "^2.0.2",
"rollup-plugin-node-resolve": "^2.0.0",
"rollup": "0.36.1",
"rollup-plugin-buble": "0.14.0",
"rollup-plugin-commonjs": "5.0.4",
"rollup-plugin-json": "2.0.2",
"rollup-plugin-node-resolve": "2.0.0",
"runscript": "^1.1.0",
"seedrandom": "^2.4.2",
"snazzy": "^3.0.0",
"standard": "^6.0.7",
"standard": "^12.0.1",
"surface-nets": "^1.0.2",

@@ -106,3 +106,3 @@ "tap-min": "^1.2.2",

"bench-history": "node bench/bench-history",
"build": "npm run build-script && npm run build-min && npm run build-bench && npm run build-compare && npm run build-typescript",
"build": "npm run build-script && npm run build-min && npm run build-typescript",
"build-script": "rollup -c rollup/config.js",

@@ -109,0 +109,0 @@ "build-min": "rollup -c rollup/config.unchecked.js && node bin/minify.js dist/regl.unchecked.js dist/regl.min.js",

@@ -219,2 +219,5 @@ // Type definitions for regl 1.3.1

/* Creates a vertex array object */
vao(attributes: REGL.AttributeState[]) : REGL.VertexArrayObject;
/* Events and listeners */

@@ -485,2 +488,7 @@

/**
* Configuration of vertex array object
*/
vao?: REGL.MaybeDynamic<REGL.VertexArrayObject | AttributeState[], ParentContext & OwnContext, Props>,
/* Drawing */

@@ -659,3 +667,3 @@

type Attribute =
type AttributeState =
ConstantAttribute |

@@ -666,2 +674,6 @@ AttributeConfig |

type Attribute =
number |
AttributeState;
interface Attributes {

@@ -685,13 +697,15 @@ [name: string]: Attribute;

/** A REGLBuffer wrapping the buffer object. (Default: null) */
buffer?: REGL.Buffer;
buffer?: REGL.Buffer|undefined|null|false;
/** The offset of the vertexAttribPointer in bytes. (Default: 0) */
offset?: number;
offset?: number|undefined;
/** The stride of the vertexAttribPointer in bytes. (Default: 0) */
stride?: number;
stride?: number|undefined;
/** Whether the pointer is normalized. (Default: false) */
normalized?: boolean;
/** The size of the vertex attribute. (Default: Inferred from shader) */
size?: number;
size?: number|undefined;
/** Sets gl.vertexAttribDivisorANGLE. Only supported if the ANGLE_instanced_arrays extension is available. (Default: 0) */
divisor?: number;
divisor?: number|undefined;
/** Data type for attribute */
type?: 'uint8'|'uint16'|'uint32'|'float'|'int8'|'int16'|'int32';
}

@@ -946,2 +960,6 @@

interface VertexArrayObject extends REGL.Resource {
(attributes:REGL.AttributeState[]) : REGL.VertexArrayObject;
}
interface Buffer extends REGL.Resource {

@@ -1648,2 +1666,4 @@ /**

maxTextureUnits: number;
/** Number of vertex array objects */
vaoCount: number;

@@ -1650,0 +1670,0 @@ // The following functions are only available if regl is initialized with option `profile: true`

@@ -89,2 +89,7 @@ var check = require('./lib/util/check')

var limits = wrapLimits(gl, extensions)
var bufferState = wrapBuffers(
gl,
stats,
config,
destroyBuffer)
var attributeState = wrapAttributes(

@@ -94,8 +99,7 @@ gl,

limits,
stringStore)
var bufferState = wrapBuffers(
gl,
stats,
config,
attributeState)
bufferState)
function destroyBuffer (buffer) {
return attributeState.destroyBuffer(buffer)
}
var elementState = wrapElements(gl, extensions, bufferState, stats)

@@ -225,2 +229,3 @@ var shaderState = wrapShaders(gl, stringStore, stats, config)

framebufferState.restore()
attributeState.restore()
if (timer) {

@@ -262,2 +267,3 @@ timer.restore()

bufferState.clear()
attributeState.clear()

@@ -282,2 +288,3 @@ if (timer) {

delete result.context
delete result.vao

@@ -306,2 +313,6 @@ if ('stencil' in result && result.stencil.op) {

if ('vao' in options) {
result.vao = options.vao
}
return result

@@ -367,3 +378,2 @@ }

}
return
} else if (Array.isArray(args)) {

@@ -373,3 +383,2 @@ for (i = 0; i < args.length; ++i) {

}
return
} else {

@@ -566,2 +575,3 @@ return scope.call(this, args, body, 0)

framebufferCube: framebufferState.createCube,
vao: attributeState.createVAO,

@@ -568,0 +578,0 @@ // Expose context attributes

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is too big to display

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