New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

@luma.gl/webgl

Package Overview
Dependencies
Maintainers
8
Versions
243
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@luma.gl/webgl - npm Package Compare versions

Comparing version 7.4.0-alpha.2 to 8.0.0-alpha.2

102

dist/es5/classes/program.js

@@ -80,4 +80,7 @@ "use strict";

_props$bufferMode = props.bufferMode,
bufferMode = _props$bufferMode === void 0 ? GL_SEPARATE_ATTRIBS : _props$bufferMode;
bufferMode = _props$bufferMode === void 0 ? GL_SEPARATE_ATTRIBS : _props$bufferMode,
_props$debug = props.debug,
debug = _props$debug === void 0 ? false : _props$debug;
this.hash = hash || '';
this.debug = debug;
this.vs = typeof vs === 'string' ? new _shader.VertexShader(this.gl, {

@@ -94,2 +97,3 @@ id: "".concat(props.id, "-vs"),

this.uniforms = {};
this._texturesRenderable = true;

@@ -165,3 +169,3 @@ if (varyings && varyings.length > 0) {

if (logPriority !== undefined) {
if (this.debug && logPriority !== undefined) {
var fb = framebuffer ? framebuffer.id : 'default';

@@ -219,21 +223,43 @@ var message = "mode=".concat((0, _webglUtils.getKey)(this.gl, drawMode), " verts=").concat(vertexCount, " ") + "instances=".concat(instanceCount, " indexType=").concat((0, _webglUtils.getKey)(this.gl, indexType), " ") + "isInstanced=".concat(isInstanced, " isIndexed=").concat(isIndexed, " ") + "Framebuffer=".concat(fb);

var _onChangeCallback = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : function () {};
if (this.debug) {
(0, _uniforms.checkUniformValues)(uniforms, this.id, this._uniformSetters);
}
var somethingChanged = false;
var changedUniforms = {};
this.gl.useProgram(this.handle);
for (var key in uniforms) {
if (!(0, _uniforms.areUniformsEqual)(this.uniforms[key], uniforms[key])) {
somethingChanged = true;
changedUniforms[key] = uniforms[key];
this.uniforms[key] = (0, _uniforms.getUniformCopy)(uniforms[key]);
}
}
for (var uniformName in uniforms) {
var uniform = uniforms[uniformName];
var uniformSetter = this._uniformSetters[uniformName];
if (somethingChanged) {
_onChangeCallback();
if (uniformSetter) {
var value = uniform;
var textureUpdate = false;
(0, _uniforms.checkUniformValues)(changedUniforms, this.id, this._uniformSetters);
if (value instanceof _framebuffer["default"]) {
value = value.texture;
}
this._setUniforms(changedUniforms);
if (value instanceof _texture["default"]) {
textureUpdate = this.uniforms[uniformName] !== uniform;
if (textureUpdate) {
if (uniformSetter.textureIndex === undefined) {
uniformSetter.textureIndex = this._textureIndexCounter++;
}
var texture = value;
var textureIndex = uniformSetter.textureIndex;
texture.bind(textureIndex);
value = textureIndex;
if (!texture.loaded) {
this._texturesRenderable = false;
}
}
}
if (uniformSetter(value) || textureUpdate) {
(0, _uniforms.copyUniform)(this.uniforms, uniformName, uniform);
}
}
}

@@ -244,9 +270,10 @@

}, {
key: "reset",
value: function reset() {}
}, {
key: "_areTexturesRenderable",
value: function _areTexturesRenderable() {
var texturesRenderable = true;
if (this._texturesRenderable) {
return true;
}
this._texturesRenderable = true;
for (var uniformName in this.uniforms) {

@@ -265,3 +292,3 @@ var uniformSetter = this._uniformSetters[uniformName];

var texture = uniform;
texturesRenderable = texturesRenderable && texture.loaded;
this._texturesRenderable = this._texturesRenderable && texture.loaded;
}

@@ -271,3 +298,3 @@ }

return texturesRenderable;
return this._texturesRenderable;
}

@@ -295,33 +322,2 @@ }, {

}, {
key: "_setUniforms",
value: function _setUniforms(uniforms) {
this.gl.useProgram(this.handle);
for (var uniformName in uniforms) {
var uniform = uniforms[uniformName];
var uniformSetter = this._uniformSetters[uniformName];
if (uniformSetter) {
if (uniform instanceof _framebuffer["default"]) {
uniform = uniform.texture;
}
if (uniform instanceof _texture["default"]) {
if (uniformSetter.textureIndex === undefined) {
uniformSetter.textureIndex = this._textureIndexCounter++;
}
var texture = uniform;
var textureIndex = uniformSetter.textureIndex;
texture.bind(textureIndex);
uniformSetter(textureIndex);
} else {
uniformSetter(uniform);
}
}
}
return this;
}
}, {
key: "_createHandle",

@@ -328,0 +324,0 @@ value: function _createHandle() {

@@ -11,4 +11,3 @@ "use strict";

exports.checkUniformValues = checkUniformValues;
exports.areUniformsEqual = areUniformsEqual;
exports.getUniformCopy = getUniformCopy;
exports.copyUniform = copyUniform;

@@ -27,83 +26,3 @@ var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));

var UNIFORM_SETTERS = (_UNIFORM_SETTERS = {}, (0, _defineProperty2["default"])(_UNIFORM_SETTERS, 5126, function (gl, location, value) {
return gl.uniform1fv(location, toFloatArray(value, 1));
}), (0, _defineProperty2["default"])(_UNIFORM_SETTERS, 35664, function (gl, location, value) {
return gl.uniform2fv(location, toFloatArray(value, 2));
}), (0, _defineProperty2["default"])(_UNIFORM_SETTERS, 35665, function (gl, location, value) {
return gl.uniform3fv(location, toFloatArray(value, 3));
}), (0, _defineProperty2["default"])(_UNIFORM_SETTERS, 35666, function (gl, location, value) {
return gl.uniform4fv(location, toFloatArray(value, 4));
}), (0, _defineProperty2["default"])(_UNIFORM_SETTERS, 5124, function (gl, location, value) {
return gl.uniform1iv(location, toIntArray(value, 1));
}), (0, _defineProperty2["default"])(_UNIFORM_SETTERS, 35667, function (gl, location, value) {
return gl.uniform2iv(location, toIntArray(value, 2));
}), (0, _defineProperty2["default"])(_UNIFORM_SETTERS, 35668, function (gl, location, value) {
return gl.uniform3iv(location, toIntArray(value, 3));
}), (0, _defineProperty2["default"])(_UNIFORM_SETTERS, 35669, function (gl, location, value) {
return gl.uniform4iv(location, toIntArray(value, 4));
}), (0, _defineProperty2["default"])(_UNIFORM_SETTERS, 35670, function (gl, location, value) {
return gl.uniform1iv(location, toIntArray(value, 1));
}), (0, _defineProperty2["default"])(_UNIFORM_SETTERS, 35671, function (gl, location, value) {
return gl.uniform2iv(location, toIntArray(value, 2));
}), (0, _defineProperty2["default"])(_UNIFORM_SETTERS, 35672, function (gl, location, value) {
return gl.uniform3iv(location, toIntArray(value, 3));
}), (0, _defineProperty2["default"])(_UNIFORM_SETTERS, 35673, function (gl, location, value) {
return gl.uniform4iv(location, toIntArray(value, 4));
}), (0, _defineProperty2["default"])(_UNIFORM_SETTERS, 35674, function (gl, location, value) {
return gl.uniformMatrix2fv(location, false, toFloatArray(value, 4));
}), (0, _defineProperty2["default"])(_UNIFORM_SETTERS, 35675, function (gl, location, value) {
return gl.uniformMatrix3fv(location, false, toFloatArray(value, 9));
}), (0, _defineProperty2["default"])(_UNIFORM_SETTERS, 35676, function (gl, location, value) {
return gl.uniformMatrix4fv(location, false, toFloatArray(value, 16));
}), (0, _defineProperty2["default"])(_UNIFORM_SETTERS, 35678, function (gl, location, value) {
return gl.uniform1i(location, value);
}), (0, _defineProperty2["default"])(_UNIFORM_SETTERS, 35680, function (gl, location, value) {
return gl.uniform1i(location, value);
}), (0, _defineProperty2["default"])(_UNIFORM_SETTERS, 5125, function (gl, location, value) {
return gl.uniform1uiv(location, toUIntArray(value, 1));
}), (0, _defineProperty2["default"])(_UNIFORM_SETTERS, 36294, function (gl, location, value) {
return gl.uniform2uiv(location, toUIntArray(value, 2));
}), (0, _defineProperty2["default"])(_UNIFORM_SETTERS, 36295, function (gl, location, value) {
return gl.uniform3uiv(location, toUIntArray(value, 3));
}), (0, _defineProperty2["default"])(_UNIFORM_SETTERS, 36296, function (gl, location, value) {
return gl.uniform4uiv(location, toUIntArray(value, 4));
}), (0, _defineProperty2["default"])(_UNIFORM_SETTERS, 35685, function (gl, location, value) {
return gl.uniformMatrix2x3fv(location, false, toFloatArray(value, 6));
}), (0, _defineProperty2["default"])(_UNIFORM_SETTERS, 35686, function (gl, location, value) {
return gl.uniformMatrix2x4fv(location, false, toFloatArray(value, 8));
}), (0, _defineProperty2["default"])(_UNIFORM_SETTERS, 35687, function (gl, location, value) {
return gl.uniformMatrix3x2fv(location, false, toFloatArray(value, 6));
}), (0, _defineProperty2["default"])(_UNIFORM_SETTERS, 35688, function (gl, location, value) {
return gl.uniformMatrix3x4fv(location, false, toFloatArray(value, 12));
}), (0, _defineProperty2["default"])(_UNIFORM_SETTERS, 35689, function (gl, location, value) {
return gl.uniformMatrix4x2fv(location, false, toFloatArray(value, 8));
}), (0, _defineProperty2["default"])(_UNIFORM_SETTERS, 35690, function (gl, location, value) {
return gl.uniformMatrix4x3fv(location, false, toFloatArray(value, 12));
}), (0, _defineProperty2["default"])(_UNIFORM_SETTERS, 35679, function (gl, location, value) {
return gl.uniform1i(location, value);
}), (0, _defineProperty2["default"])(_UNIFORM_SETTERS, 35682, function (gl, location, value) {
return gl.uniform1i(location, value);
}), (0, _defineProperty2["default"])(_UNIFORM_SETTERS, 36289, function (gl, location, value) {
return gl.uniform1i(location, value);
}), (0, _defineProperty2["default"])(_UNIFORM_SETTERS, 36292, function (gl, location, value) {
return gl.uniform1i(location, value);
}), (0, _defineProperty2["default"])(_UNIFORM_SETTERS, 36293, function (gl, location, value) {
return gl.uniform1i(location, value);
}), (0, _defineProperty2["default"])(_UNIFORM_SETTERS, 36298, function (gl, location, value) {
return gl.uniform1i(location, value);
}), (0, _defineProperty2["default"])(_UNIFORM_SETTERS, 36299, function (gl, location, value) {
return gl.uniform1i(location, value);
}), (0, _defineProperty2["default"])(_UNIFORM_SETTERS, 36300, function (gl, location, value) {
return gl.uniform1i(location, value);
}), (0, _defineProperty2["default"])(_UNIFORM_SETTERS, 36303, function (gl, location, value) {
return gl.uniform1i(location, value);
}), (0, _defineProperty2["default"])(_UNIFORM_SETTERS, 36306, function (gl, location, value) {
return gl.uniform1i(location, value);
}), (0, _defineProperty2["default"])(_UNIFORM_SETTERS, 36307, function (gl, location, value) {
return gl.uniform1i(location, value);
}), (0, _defineProperty2["default"])(_UNIFORM_SETTERS, 36308, function (gl, location, value) {
return gl.uniform1i(location, value);
}), (0, _defineProperty2["default"])(_UNIFORM_SETTERS, 36311, function (gl, location, value) {
return gl.uniform1i(location, value);
}), _UNIFORM_SETTERS);
var UNIFORM_SETTERS = (_UNIFORM_SETTERS = {}, (0, _defineProperty2["default"])(_UNIFORM_SETTERS, 5126, getArraySetter.bind(null, 'uniform1fv', toFloatArray, 1, setVectorUniform)), (0, _defineProperty2["default"])(_UNIFORM_SETTERS, 35664, getArraySetter.bind(null, 'uniform2fv', toFloatArray, 2, setVectorUniform)), (0, _defineProperty2["default"])(_UNIFORM_SETTERS, 35665, getArraySetter.bind(null, 'uniform3fv', toFloatArray, 3, setVectorUniform)), (0, _defineProperty2["default"])(_UNIFORM_SETTERS, 35666, getArraySetter.bind(null, 'uniform4fv', toFloatArray, 4, setVectorUniform)), (0, _defineProperty2["default"])(_UNIFORM_SETTERS, 5124, getArraySetter.bind(null, 'uniform1iv', toIntArray, 1, setVectorUniform)), (0, _defineProperty2["default"])(_UNIFORM_SETTERS, 35667, getArraySetter.bind(null, 'uniform2iv', toIntArray, 2, setVectorUniform)), (0, _defineProperty2["default"])(_UNIFORM_SETTERS, 35668, getArraySetter.bind(null, 'uniform3iv', toIntArray, 3, setVectorUniform)), (0, _defineProperty2["default"])(_UNIFORM_SETTERS, 35669, getArraySetter.bind(null, 'uniform4iv', toIntArray, 4, setVectorUniform)), (0, _defineProperty2["default"])(_UNIFORM_SETTERS, 35670, getArraySetter.bind(null, 'uniform1iv', toIntArray, 1, setVectorUniform)), (0, _defineProperty2["default"])(_UNIFORM_SETTERS, 35671, getArraySetter.bind(null, 'uniform2iv', toIntArray, 2, setVectorUniform)), (0, _defineProperty2["default"])(_UNIFORM_SETTERS, 35672, getArraySetter.bind(null, 'uniform3iv', toIntArray, 3, setVectorUniform)), (0, _defineProperty2["default"])(_UNIFORM_SETTERS, 35673, getArraySetter.bind(null, 'uniform4iv', toIntArray, 4, setVectorUniform)), (0, _defineProperty2["default"])(_UNIFORM_SETTERS, 35674, getArraySetter.bind(null, 'uniformMatrix2fv', toFloatArray, 4, setMatrixUniform)), (0, _defineProperty2["default"])(_UNIFORM_SETTERS, 35675, getArraySetter.bind(null, 'uniformMatrix3fv', toFloatArray, 9, setMatrixUniform)), (0, _defineProperty2["default"])(_UNIFORM_SETTERS, 35676, getArraySetter.bind(null, 'uniformMatrix4fv', toFloatArray, 16, setMatrixUniform)), (0, _defineProperty2["default"])(_UNIFORM_SETTERS, 35678, getSamplerSetter), (0, _defineProperty2["default"])(_UNIFORM_SETTERS, 35680, getSamplerSetter), (0, _defineProperty2["default"])(_UNIFORM_SETTERS, 5125, getArraySetter.bind(null, 'uniform1uiv', toUIntArray, 1, setVectorUniform)), (0, _defineProperty2["default"])(_UNIFORM_SETTERS, 36294, getArraySetter.bind(null, 'uniform2uiv', toUIntArray, 2, setVectorUniform)), (0, _defineProperty2["default"])(_UNIFORM_SETTERS, 36295, getArraySetter.bind(null, 'uniform3uiv', toUIntArray, 3, setVectorUniform)), (0, _defineProperty2["default"])(_UNIFORM_SETTERS, 36296, getArraySetter.bind(null, 'uniform4uiv', toUIntArray, 4, setVectorUniform)), (0, _defineProperty2["default"])(_UNIFORM_SETTERS, 35685, getArraySetter.bind(null, 'uniformMatrix2x3fv', toFloatArray, 6, setMatrixUniform)), (0, _defineProperty2["default"])(_UNIFORM_SETTERS, 35686, getArraySetter.bind(null, 'uniformMatrix2x4fv', toFloatArray, 8, setMatrixUniform)), (0, _defineProperty2["default"])(_UNIFORM_SETTERS, 35687, getArraySetter.bind(null, 'uniformMatrix3x2fv', toFloatArray, 6, setMatrixUniform)), (0, _defineProperty2["default"])(_UNIFORM_SETTERS, 35688, getArraySetter.bind(null, 'uniformMatrix3x4fv', toFloatArray, 12, setMatrixUniform)), (0, _defineProperty2["default"])(_UNIFORM_SETTERS, 35689, getArraySetter.bind(null, 'uniformMatrix4x2fv', toFloatArray, 8, setMatrixUniform)), (0, _defineProperty2["default"])(_UNIFORM_SETTERS, 35690, getArraySetter.bind(null, 'uniformMatrix4x3fv', toFloatArray, 12, setMatrixUniform)), (0, _defineProperty2["default"])(_UNIFORM_SETTERS, 35679, getSamplerSetter), (0, _defineProperty2["default"])(_UNIFORM_SETTERS, 35682, getSamplerSetter), (0, _defineProperty2["default"])(_UNIFORM_SETTERS, 36289, getSamplerSetter), (0, _defineProperty2["default"])(_UNIFORM_SETTERS, 36292, getSamplerSetter), (0, _defineProperty2["default"])(_UNIFORM_SETTERS, 36293, getSamplerSetter), (0, _defineProperty2["default"])(_UNIFORM_SETTERS, 36298, getSamplerSetter), (0, _defineProperty2["default"])(_UNIFORM_SETTERS, 36299, getSamplerSetter), (0, _defineProperty2["default"])(_UNIFORM_SETTERS, 36300, getSamplerSetter), (0, _defineProperty2["default"])(_UNIFORM_SETTERS, 36303, getSamplerSetter), (0, _defineProperty2["default"])(_UNIFORM_SETTERS, 36306, getSamplerSetter), (0, _defineProperty2["default"])(_UNIFORM_SETTERS, 36307, getSamplerSetter), (0, _defineProperty2["default"])(_UNIFORM_SETTERS, 36308, getSamplerSetter), (0, _defineProperty2["default"])(_UNIFORM_SETTERS, 36311, getSamplerSetter), _UNIFORM_SETTERS);
var FLOAT_ARRAY = {};

@@ -190,3 +109,3 @@ var INT_ARRAY = {};

return setter.bind(null, gl, location);
return setter().bind(null, gl, location);
}

@@ -245,33 +164,71 @@

function areUniformsEqual(uniform1, uniform2) {
if (Array.isArray(uniform1) || ArrayBuffer.isView(uniform1)) {
if (!uniform2) {
return false;
function copyUniform(uniforms, key, value) {
if (Array.isArray(value) || ArrayBuffer.isView(value)) {
if (uniforms[key]) {
var dest = uniforms[key];
for (var i = 0, len = value.length; i < len; ++i) {
dest[i] = value[i];
}
} else {
uniforms[key] = value.slice();
}
} else {
uniforms[key] = value;
}
}
var len = uniform1.length;
function getSamplerSetter() {
var cache = null;
return function (gl, location, value) {
var update = cache !== value;
if (uniform2.length !== len) {
return false;
if (update) {
gl.uniform1i(location, value);
cache = value;
}
for (var i = 0; i < len; i++) {
if (uniform1[i] !== uniform2[i]) {
return false;
return update;
};
}
function getArraySetter(functionName, toArray, size, uniformSetter) {
var cache = null;
var cacheLength = null;
return function (gl, location, value) {
var arrayValue = toArray(value, size);
var length = arrayValue.length;
var update = false;
if (cache === null) {
cache = new Float32Array(length);
cacheLength = length;
update = true;
} else {
(0, _utils.assert)(cacheLength === length, 'Uniform length cannot change.');
for (var i = 0; i < length; ++i) {
if (arrayValue[i] !== cache[i]) {
update = true;
break;
}
}
}
return true;
}
if (update) {
uniformSetter(gl, functionName, location, arrayValue);
cache.set(arrayValue);
}
return uniform1 === uniform2;
return update;
};
}
function getUniformCopy(uniform) {
if (Array.isArray(uniform) || ArrayBuffer.isView(uniform)) {
return uniform.slice();
}
function setVectorUniform(gl, functionName, location, value) {
gl[functionName](location, value);
}
return uniform;
function setMatrixUniform(gl, functionName, location, value) {
gl[functionName](location, false, value);
}
//# sourceMappingURL=uniforms.js.map

@@ -108,5 +108,5 @@ "use strict";

key: "getDrawParams",
value: function getDrawParams(appParameters) {
value: function getDrawParams() {
this.drawParams = this.drawParams || this._updateDrawParams();
return Object.assign({}, this.drawParams, appParameters);
return this.drawParams;
}

@@ -113,0 +113,0 @@ }, {

@@ -21,3 +21,3 @@ "use strict";

var _webglStateTracker = require("@luma.gl/webgl-state-tracker");
var _gltools = require("@luma.gl/gltools");

@@ -140,3 +140,3 @@ var _createHeadlessContext = require("./create-headless-context");

if (manageState) {
(0, _webglStateTracker.trackContextState)(gl, {
(0, _gltools.trackContextState)(gl, {
copyState: false,

@@ -143,0 +143,0 @@ log: function log() {

@@ -9,3 +9,3 @@ "use strict";

get: function get() {
return _webglStateTracker.trackContextState;
return _gltools.trackContextState;
}

@@ -16,3 +16,3 @@ });

get: function get() {
return _webglStateTracker.resetParameters;
return _gltools.resetParameters;
}

@@ -23,3 +23,3 @@ });

get: function get() {
return _webglStateTracker.getParameter;
return _gltools.getParameter;
}

@@ -30,3 +30,3 @@ });

get: function get() {
return _webglStateTracker.getParameters;
return _gltools.getParameters;
}

@@ -37,3 +37,3 @@ });

get: function get() {
return _webglStateTracker.setParameter;
return _gltools.setParameter;
}

@@ -44,3 +44,3 @@ });

get: function get() {
return _webglStateTracker.setParameters;
return _gltools.setParameters;
}

@@ -51,3 +51,3 @@ });

get: function get() {
return _webglStateTracker.withParameters;
return _gltools.withParameters;
}

@@ -58,3 +58,3 @@ });

get: function get() {
return _webglStateTracker.getModifiedParameters;
return _gltools.getModifiedParameters;
}

@@ -105,3 +105,3 @@ });

var _webglStateTracker = require("@luma.gl/webgl-state-tracker");
var _gltools = require("@luma.gl/gltools");

@@ -108,0 +108,0 @@ var _context = require("./context");

@@ -17,3 +17,3 @@ "use strict";

get: function get() {
return _webglStateTracker.resetParameters;
return _gltools.resetParameters;
}

@@ -24,3 +24,3 @@ });

get: function get() {
return _webglStateTracker.getParameter;
return _gltools.getParameter;
}

@@ -31,3 +31,3 @@ });

get: function get() {
return _webglStateTracker.getParameters;
return _gltools.getParameters;
}

@@ -38,3 +38,3 @@ });

get: function get() {
return _webglStateTracker.setParameter;
return _gltools.setParameter;
}

@@ -45,3 +45,3 @@ });

get: function get() {
return _webglStateTracker.setParameters;
return _gltools.setParameters;
}

@@ -52,3 +52,3 @@ });

get: function get() {
return _webglStateTracker.withParameters;
return _gltools.withParameters;
}

@@ -59,3 +59,3 @@ });

get: function get() {
return _webglStateTracker.getModifiedParameters;
return _gltools.getModifiedParameters;
}

@@ -552,3 +552,3 @@ });

var _webglStateTracker = require("@luma.gl/webgl-state-tracker");
var _gltools = require("@luma.gl/gltools");

@@ -555,0 +555,0 @@ var _webglTypes = require("./webgl-utils/webgl-types");

@@ -28,5 +28,5 @@ "use strict";

require("@luma.gl/webgl2-polyfill");
require("@luma.gl/gltools");
var VERSION = typeof "7.4.0-alpha.1" !== 'undefined' ? "7.4.0-alpha.1" : 'untranspiled source';
var VERSION = typeof "8.0.0-alpha.1" !== 'undefined' ? "8.0.0-alpha.1" : 'untranspiled source';
var STARTUP_MESSAGE = 'set luma.log.priority=1 (or higher) to trace rendering';

@@ -33,0 +33,0 @@

@@ -19,3 +19,10 @@ "use strict";

exports.ERR_HEADLESSGL_LOAD = ERR_HEADLESSGL_LOAD;
var m = module;
var m;
try {
m = module;
} catch (e) {
m = null;
}
var headlessTypes = null;

@@ -22,0 +29,0 @@ exports.headlessTypes = headlessTypes;

@@ -7,3 +7,3 @@ import Resource from './resource';

import ProgramConfiguration from './program-configuration';
import { checkUniformValues, areUniformsEqual, getUniformCopy } from './uniforms';
import { copyUniform, checkUniformValues } from './uniforms';
import { withParameters } from '../context';

@@ -33,5 +33,7 @@ import { assertWebGL2Context, isWebGL2, getKey } from '../webgl-utils';

varyings,
bufferMode = GL_SEPARATE_ATTRIBS
bufferMode = GL_SEPARATE_ATTRIBS,
debug = false
} = props;
this.hash = hash || '';
this.debug = debug;
this.vs = typeof vs === 'string' ? new VertexShader(this.gl, {

@@ -48,2 +50,3 @@ id: "".concat(props.id, "-vs"),

this.uniforms = {};
this._texturesRenderable = true;

@@ -103,3 +106,3 @@ if (varyings && varyings.length > 0) {

if (logPriority !== undefined) {
if (this.debug && logPriority !== undefined) {
const fb = framebuffer ? framebuffer.id : 'default';

@@ -152,20 +155,46 @@ const message = "mode=".concat(getKey(this.gl, drawMode), " verts=").concat(vertexCount, " ") + "instances=".concat(instanceCount, " indexType=").concat(getKey(this.gl, indexType), " ") + "isInstanced=".concat(isInstanced, " isIndexed=").concat(isIndexed, " ") + "Framebuffer=".concat(fb);

setUniforms(uniforms = {}, _onChangeCallback = () => {}) {
let somethingChanged = false;
const changedUniforms = {};
for (const key in uniforms) {
if (!areUniformsEqual(this.uniforms[key], uniforms[key])) {
somethingChanged = true;
changedUniforms[key] = uniforms[key];
this.uniforms[key] = getUniformCopy(uniforms[key]);
}
setUniforms(uniforms = {}) {
if (this.debug) {
checkUniformValues(uniforms, this.id, this._uniformSetters);
}
if (somethingChanged) {
_onChangeCallback();
this.gl.useProgram(this.handle);
checkUniformValues(changedUniforms, this.id, this._uniformSetters);
for (const uniformName in uniforms) {
const uniform = uniforms[uniformName];
const uniformSetter = this._uniformSetters[uniformName];
this._setUniforms(changedUniforms);
if (uniformSetter) {
let value = uniform;
let textureUpdate = false;
if (value instanceof Framebuffer) {
value = value.texture;
}
if (value instanceof Texture) {
textureUpdate = this.uniforms[uniformName] !== uniform;
if (textureUpdate) {
if (uniformSetter.textureIndex === undefined) {
uniformSetter.textureIndex = this._textureIndexCounter++;
}
const texture = value;
const {
textureIndex
} = uniformSetter;
texture.bind(textureIndex);
value = textureIndex;
if (!texture.loaded) {
this._texturesRenderable = false;
}
}
}
if (uniformSetter(value) || textureUpdate) {
copyUniform(this.uniforms, uniformName, uniform);
}
}
}

@@ -176,7 +205,9 @@

reset() {}
_areTexturesRenderable() {
let texturesRenderable = true;
if (this._texturesRenderable) {
return true;
}
this._texturesRenderable = true;
for (const uniformName in this.uniforms) {

@@ -195,3 +226,3 @@ const uniformSetter = this._uniformSetters[uniformName];

const texture = uniform;
texturesRenderable = texturesRenderable && texture.loaded;
this._texturesRenderable = this._texturesRenderable && texture.loaded;
}

@@ -201,3 +232,3 @@ }

return texturesRenderable;
return this._texturesRenderable;
}

@@ -224,34 +255,2 @@

_setUniforms(uniforms) {
this.gl.useProgram(this.handle);
for (const uniformName in uniforms) {
let uniform = uniforms[uniformName];
const uniformSetter = this._uniformSetters[uniformName];
if (uniformSetter) {
if (uniform instanceof Framebuffer) {
uniform = uniform.texture;
}
if (uniform instanceof Texture) {
if (uniformSetter.textureIndex === undefined) {
uniformSetter.textureIndex = this._textureIndexCounter++;
}
const texture = uniform;
const {
textureIndex
} = uniformSetter;
texture.bind(textureIndex);
uniformSetter(textureIndex);
} else {
uniformSetter(uniform);
}
}
}
return this;
}
_createHandle() {

@@ -258,0 +257,0 @@ return this.gl.createProgram();

import Framebuffer from './framebuffer';
import Renderbuffer from './renderbuffer';
import Texture from './texture';
import { log } from '../utils';
import { log, assert } from '../utils';
const UNIFORM_SETTERS = {
[5126]: (gl, location, value) => gl.uniform1fv(location, toFloatArray(value, 1)),
[35664]: (gl, location, value) => gl.uniform2fv(location, toFloatArray(value, 2)),
[35665]: (gl, location, value) => gl.uniform3fv(location, toFloatArray(value, 3)),
[35666]: (gl, location, value) => gl.uniform4fv(location, toFloatArray(value, 4)),
[5124]: (gl, location, value) => gl.uniform1iv(location, toIntArray(value, 1)),
[35667]: (gl, location, value) => gl.uniform2iv(location, toIntArray(value, 2)),
[35668]: (gl, location, value) => gl.uniform3iv(location, toIntArray(value, 3)),
[35669]: (gl, location, value) => gl.uniform4iv(location, toIntArray(value, 4)),
[35670]: (gl, location, value) => gl.uniform1iv(location, toIntArray(value, 1)),
[35671]: (gl, location, value) => gl.uniform2iv(location, toIntArray(value, 2)),
[35672]: (gl, location, value) => gl.uniform3iv(location, toIntArray(value, 3)),
[35673]: (gl, location, value) => gl.uniform4iv(location, toIntArray(value, 4)),
[35674]: (gl, location, value) => gl.uniformMatrix2fv(location, false, toFloatArray(value, 4)),
[35675]: (gl, location, value) => gl.uniformMatrix3fv(location, false, toFloatArray(value, 9)),
[35676]: (gl, location, value) => gl.uniformMatrix4fv(location, false, toFloatArray(value, 16)),
[35678]: (gl, location, value) => gl.uniform1i(location, value),
[35680]: (gl, location, value) => gl.uniform1i(location, value),
[5125]: (gl, location, value) => gl.uniform1uiv(location, toUIntArray(value, 1)),
[36294]: (gl, location, value) => gl.uniform2uiv(location, toUIntArray(value, 2)),
[36295]: (gl, location, value) => gl.uniform3uiv(location, toUIntArray(value, 3)),
[36296]: (gl, location, value) => gl.uniform4uiv(location, toUIntArray(value, 4)),
[35685]: (gl, location, value) => gl.uniformMatrix2x3fv(location, false, toFloatArray(value, 6)),
[35686]: (gl, location, value) => gl.uniformMatrix2x4fv(location, false, toFloatArray(value, 8)),
[35687]: (gl, location, value) => gl.uniformMatrix3x2fv(location, false, toFloatArray(value, 6)),
[35688]: (gl, location, value) => gl.uniformMatrix3x4fv(location, false, toFloatArray(value, 12)),
[35689]: (gl, location, value) => gl.uniformMatrix4x2fv(location, false, toFloatArray(value, 8)),
[35690]: (gl, location, value) => gl.uniformMatrix4x3fv(location, false, toFloatArray(value, 12)),
[35679]: (gl, location, value) => gl.uniform1i(location, value),
[35682]: (gl, location, value) => gl.uniform1i(location, value),
[36289]: (gl, location, value) => gl.uniform1i(location, value),
[36292]: (gl, location, value) => gl.uniform1i(location, value),
[36293]: (gl, location, value) => gl.uniform1i(location, value),
[36298]: (gl, location, value) => gl.uniform1i(location, value),
[36299]: (gl, location, value) => gl.uniform1i(location, value),
[36300]: (gl, location, value) => gl.uniform1i(location, value),
[36303]: (gl, location, value) => gl.uniform1i(location, value),
[36306]: (gl, location, value) => gl.uniform1i(location, value),
[36307]: (gl, location, value) => gl.uniform1i(location, value),
[36308]: (gl, location, value) => gl.uniform1i(location, value),
[36311]: (gl, location, value) => gl.uniform1i(location, value)
[5126]: getArraySetter.bind(null, 'uniform1fv', toFloatArray, 1, setVectorUniform),
[35664]: getArraySetter.bind(null, 'uniform2fv', toFloatArray, 2, setVectorUniform),
[35665]: getArraySetter.bind(null, 'uniform3fv', toFloatArray, 3, setVectorUniform),
[35666]: getArraySetter.bind(null, 'uniform4fv', toFloatArray, 4, setVectorUniform),
[5124]: getArraySetter.bind(null, 'uniform1iv', toIntArray, 1, setVectorUniform),
[35667]: getArraySetter.bind(null, 'uniform2iv', toIntArray, 2, setVectorUniform),
[35668]: getArraySetter.bind(null, 'uniform3iv', toIntArray, 3, setVectorUniform),
[35669]: getArraySetter.bind(null, 'uniform4iv', toIntArray, 4, setVectorUniform),
[35670]: getArraySetter.bind(null, 'uniform1iv', toIntArray, 1, setVectorUniform),
[35671]: getArraySetter.bind(null, 'uniform2iv', toIntArray, 2, setVectorUniform),
[35672]: getArraySetter.bind(null, 'uniform3iv', toIntArray, 3, setVectorUniform),
[35673]: getArraySetter.bind(null, 'uniform4iv', toIntArray, 4, setVectorUniform),
[35674]: getArraySetter.bind(null, 'uniformMatrix2fv', toFloatArray, 4, setMatrixUniform),
[35675]: getArraySetter.bind(null, 'uniformMatrix3fv', toFloatArray, 9, setMatrixUniform),
[35676]: getArraySetter.bind(null, 'uniformMatrix4fv', toFloatArray, 16, setMatrixUniform),
[35678]: getSamplerSetter,
[35680]: getSamplerSetter,
[5125]: getArraySetter.bind(null, 'uniform1uiv', toUIntArray, 1, setVectorUniform),
[36294]: getArraySetter.bind(null, 'uniform2uiv', toUIntArray, 2, setVectorUniform),
[36295]: getArraySetter.bind(null, 'uniform3uiv', toUIntArray, 3, setVectorUniform),
[36296]: getArraySetter.bind(null, 'uniform4uiv', toUIntArray, 4, setVectorUniform),
[35685]: getArraySetter.bind(null, 'uniformMatrix2x3fv', toFloatArray, 6, setMatrixUniform),
[35686]: getArraySetter.bind(null, 'uniformMatrix2x4fv', toFloatArray, 8, setMatrixUniform),
[35687]: getArraySetter.bind(null, 'uniformMatrix3x2fv', toFloatArray, 6, setMatrixUniform),
[35688]: getArraySetter.bind(null, 'uniformMatrix3x4fv', toFloatArray, 12, setMatrixUniform),
[35689]: getArraySetter.bind(null, 'uniformMatrix4x2fv', toFloatArray, 8, setMatrixUniform),
[35690]: getArraySetter.bind(null, 'uniformMatrix4x3fv', toFloatArray, 12, setMatrixUniform),
[35679]: getSamplerSetter,
[35682]: getSamplerSetter,
[36289]: getSamplerSetter,
[36292]: getSamplerSetter,
[36293]: getSamplerSetter,
[36298]: getSamplerSetter,
[36299]: getSamplerSetter,
[36300]: getSamplerSetter,
[36303]: getSamplerSetter,
[36306]: getSamplerSetter,
[36307]: getSamplerSetter,
[36308]: getSamplerSetter,
[36311]: getSamplerSetter
};

@@ -127,3 +127,3 @@ const FLOAT_ARRAY = {};

return setter.bind(null, gl, location);
return setter().bind(null, gl, location);
}

@@ -181,32 +181,71 @@ export function checkUniformValues(uniforms, source, uniformMap) {

export function areUniformsEqual(uniform1, uniform2) {
if (Array.isArray(uniform1) || ArrayBuffer.isView(uniform1)) {
if (!uniform2) {
return false;
export function copyUniform(uniforms, key, value) {
if (Array.isArray(value) || ArrayBuffer.isView(value)) {
if (uniforms[key]) {
const dest = uniforms[key];
for (let i = 0, len = value.length; i < len; ++i) {
dest[i] = value[i];
}
} else {
uniforms[key] = value.slice();
}
} else {
uniforms[key] = value;
}
}
const len = uniform1.length;
function getSamplerSetter() {
let cache = null;
return (gl, location, value) => {
const update = cache !== value;
if (uniform2.length !== len) {
return false;
if (update) {
gl.uniform1i(location, value);
cache = value;
}
for (let i = 0; i < len; i++) {
if (uniform1[i] !== uniform2[i]) {
return false;
return update;
};
}
function getArraySetter(functionName, toArray, size, uniformSetter) {
let cache = null;
let cacheLength = null;
return (gl, location, value) => {
const arrayValue = toArray(value, size);
const length = arrayValue.length;
let update = false;
if (cache === null) {
cache = new Float32Array(length);
cacheLength = length;
update = true;
} else {
assert(cacheLength === length, 'Uniform length cannot change.');
for (let i = 0; i < length; ++i) {
if (arrayValue[i] !== cache[i]) {
update = true;
break;
}
}
}
return true;
}
if (update) {
uniformSetter(gl, functionName, location, arrayValue);
cache.set(arrayValue);
}
return uniform1 === uniform2;
return update;
};
}
export function getUniformCopy(uniform) {
if (Array.isArray(uniform) || ArrayBuffer.isView(uniform)) {
return uniform.slice();
}
return uniform;
function setVectorUniform(gl, functionName, location, value) {
gl[functionName](location, value);
}
function setMatrixUniform(gl, functionName, location, value) {
gl[functionName](location, false, value);
}
//# sourceMappingURL=uniforms.js.map

@@ -82,5 +82,5 @@ import Accessor from './accessor';

getDrawParams(appParameters) {
getDrawParams() {
this.drawParams = this.drawParams || this._updateDrawParams();
return Object.assign({}, this.drawParams, appParameters);
return this.drawParams;
}

@@ -87,0 +87,0 @@

import _objectSpread from "@babel/runtime/helpers/esm/objectSpread";
import { trackContextState } from '@luma.gl/webgl-state-tracker';
import { trackContextState } from '@luma.gl/gltools';
import { createHeadlessContext } from './create-headless-context';

@@ -4,0 +4,0 @@ import { getCanvas } from './create-canvas';

@@ -1,4 +0,4 @@

export { trackContextState, resetParameters, getParameter, getParameters, setParameter, setParameters, withParameters, getModifiedParameters } from '@luma.gl/webgl-state-tracker';
export { trackContextState, resetParameters, getParameter, getParameters, setParameter, setParameters, withParameters, getModifiedParameters } from '@luma.gl/gltools';
export { createGLContext, instrumentGLContext, destroyGLContext, resizeGLContext, setGLContextDefaults } from './context';
export { getPageLoadPromise, getCanvas } from './create-canvas';
//# sourceMappingURL=index.js.map
export { lumaStats } from './init';
export { resetParameters, getParameter, getParameters, setParameter, setParameters, withParameters, getModifiedParameters } from '@luma.gl/webgl-state-tracker';
export { resetParameters, getParameter, getParameters, setParameter, setParameters, withParameters, getModifiedParameters } from '@luma.gl/gltools';
export { Image, WebGLRenderingContext, WebGLProgram, WebGLShader, WebGLBuffer, WebGLFramebuffer, WebGLRenderbuffer, WebGLTexture, WebGLUniformLocation, WebGLActiveInfo, WebGLShaderPrecisionFormat, WebGL2RenderingContext, webGLTypesAvailable } from './webgl-utils/webgl-types';

@@ -4,0 +4,0 @@ export { createGLContext, destroyGLContext, resizeGLContext, instrumentGLContext, setGLContextDefaults } from './context/context';

@@ -5,4 +5,4 @@ import isBrowser from './utils/is-browser';

import { Stats } from 'probe.gl';
import '@luma.gl/webgl2-polyfill';
const VERSION = typeof "7.4.0-alpha.1" !== 'undefined' ? "7.4.0-alpha.1" : 'untranspiled source';
import '@luma.gl/gltools';
const VERSION = typeof "8.0.0-alpha.1" !== 'undefined' ? "8.0.0-alpha.1" : 'untranspiled source';
const STARTUP_MESSAGE = 'set luma.log.priority=1 (or higher) to trace rendering';

@@ -9,0 +9,0 @@

import { global } from '../utils/globals';
import isBrowser from '../utils/is-browser';
export const ERR_HEADLESSGL_LOAD = "luma.gl: loaded under Node.js without headless gl installed, meaning that WebGL contexts can not be created. This may not be an error. For example, this is a typical configuration for isorender applications running on the server.";
const m = module;
let m;
try {
m = module;
} catch (e) {
m = null;
}
export let headlessTypes = null;

@@ -6,0 +13,0 @@ export function headlessGL(...args) {

@@ -14,3 +14,3 @@ import _classCallCheck from "@babel/runtime/helpers/esm/classCallCheck";

import ProgramConfiguration from './program-configuration';
import { checkUniformValues, areUniformsEqual, getUniformCopy } from './uniforms';
import { copyUniform, checkUniformValues } from './uniforms';
import { withParameters } from '../context';

@@ -58,4 +58,7 @@ import { assertWebGL2Context, isWebGL2, getKey } from '../webgl-utils';

_props$bufferMode = props.bufferMode,
bufferMode = _props$bufferMode === void 0 ? GL_SEPARATE_ATTRIBS : _props$bufferMode;
bufferMode = _props$bufferMode === void 0 ? GL_SEPARATE_ATTRIBS : _props$bufferMode,
_props$debug = props.debug,
debug = _props$debug === void 0 ? false : _props$debug;
this.hash = hash || '';
this.debug = debug;
this.vs = typeof vs === 'string' ? new VertexShader(this.gl, {

@@ -72,2 +75,3 @@ id: "".concat(props.id, "-vs"),

this.uniforms = {};
this._texturesRenderable = true;

@@ -142,3 +146,3 @@ if (varyings && varyings.length > 0) {

if (logPriority !== undefined) {
if (this.debug && logPriority !== undefined) {
var fb = framebuffer ? framebuffer.id : 'default';

@@ -195,21 +199,43 @@ var message = "mode=".concat(getKey(this.gl, drawMode), " verts=").concat(vertexCount, " ") + "instances=".concat(instanceCount, " indexType=").concat(getKey(this.gl, indexType), " ") + "isInstanced=".concat(isInstanced, " isIndexed=").concat(isIndexed, " ") + "Framebuffer=".concat(fb);

var _onChangeCallback = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : function () {};
if (this.debug) {
checkUniformValues(uniforms, this.id, this._uniformSetters);
}
var somethingChanged = false;
var changedUniforms = {};
this.gl.useProgram(this.handle);
for (var key in uniforms) {
if (!areUniformsEqual(this.uniforms[key], uniforms[key])) {
somethingChanged = true;
changedUniforms[key] = uniforms[key];
this.uniforms[key] = getUniformCopy(uniforms[key]);
}
}
for (var uniformName in uniforms) {
var uniform = uniforms[uniformName];
var uniformSetter = this._uniformSetters[uniformName];
if (somethingChanged) {
_onChangeCallback();
if (uniformSetter) {
var value = uniform;
var textureUpdate = false;
checkUniformValues(changedUniforms, this.id, this._uniformSetters);
if (value instanceof Framebuffer) {
value = value.texture;
}
this._setUniforms(changedUniforms);
if (value instanceof Texture) {
textureUpdate = this.uniforms[uniformName] !== uniform;
if (textureUpdate) {
if (uniformSetter.textureIndex === undefined) {
uniformSetter.textureIndex = this._textureIndexCounter++;
}
var texture = value;
var textureIndex = uniformSetter.textureIndex;
texture.bind(textureIndex);
value = textureIndex;
if (!texture.loaded) {
this._texturesRenderable = false;
}
}
}
if (uniformSetter(value) || textureUpdate) {
copyUniform(this.uniforms, uniformName, uniform);
}
}
}

@@ -220,9 +246,10 @@

}, {
key: "reset",
value: function reset() {}
}, {
key: "_areTexturesRenderable",
value: function _areTexturesRenderable() {
var texturesRenderable = true;
if (this._texturesRenderable) {
return true;
}
this._texturesRenderable = true;
for (var uniformName in this.uniforms) {

@@ -241,3 +268,3 @@ var uniformSetter = this._uniformSetters[uniformName];

var texture = uniform;
texturesRenderable = texturesRenderable && texture.loaded;
this._texturesRenderable = this._texturesRenderable && texture.loaded;
}

@@ -247,3 +274,3 @@ }

return texturesRenderable;
return this._texturesRenderable;
}

@@ -271,33 +298,2 @@ }, {

}, {
key: "_setUniforms",
value: function _setUniforms(uniforms) {
this.gl.useProgram(this.handle);
for (var uniformName in uniforms) {
var uniform = uniforms[uniformName];
var uniformSetter = this._uniformSetters[uniformName];
if (uniformSetter) {
if (uniform instanceof Framebuffer) {
uniform = uniform.texture;
}
if (uniform instanceof Texture) {
if (uniformSetter.textureIndex === undefined) {
uniformSetter.textureIndex = this._textureIndexCounter++;
}
var texture = uniform;
var textureIndex = uniformSetter.textureIndex;
texture.bind(textureIndex);
uniformSetter(textureIndex);
} else {
uniformSetter(uniform);
}
}
}
return this;
}
}, {
key: "_createHandle",

@@ -304,0 +300,0 @@ value: function _createHandle() {

@@ -8,84 +8,4 @@ import _defineProperty from "@babel/runtime/helpers/esm/defineProperty";

import Texture from './texture';
import { log } from '../utils';
var UNIFORM_SETTERS = (_UNIFORM_SETTERS = {}, _defineProperty(_UNIFORM_SETTERS, 5126, function (gl, location, value) {
return gl.uniform1fv(location, toFloatArray(value, 1));
}), _defineProperty(_UNIFORM_SETTERS, 35664, function (gl, location, value) {
return gl.uniform2fv(location, toFloatArray(value, 2));
}), _defineProperty(_UNIFORM_SETTERS, 35665, function (gl, location, value) {
return gl.uniform3fv(location, toFloatArray(value, 3));
}), _defineProperty(_UNIFORM_SETTERS, 35666, function (gl, location, value) {
return gl.uniform4fv(location, toFloatArray(value, 4));
}), _defineProperty(_UNIFORM_SETTERS, 5124, function (gl, location, value) {
return gl.uniform1iv(location, toIntArray(value, 1));
}), _defineProperty(_UNIFORM_SETTERS, 35667, function (gl, location, value) {
return gl.uniform2iv(location, toIntArray(value, 2));
}), _defineProperty(_UNIFORM_SETTERS, 35668, function (gl, location, value) {
return gl.uniform3iv(location, toIntArray(value, 3));
}), _defineProperty(_UNIFORM_SETTERS, 35669, function (gl, location, value) {
return gl.uniform4iv(location, toIntArray(value, 4));
}), _defineProperty(_UNIFORM_SETTERS, 35670, function (gl, location, value) {
return gl.uniform1iv(location, toIntArray(value, 1));
}), _defineProperty(_UNIFORM_SETTERS, 35671, function (gl, location, value) {
return gl.uniform2iv(location, toIntArray(value, 2));
}), _defineProperty(_UNIFORM_SETTERS, 35672, function (gl, location, value) {
return gl.uniform3iv(location, toIntArray(value, 3));
}), _defineProperty(_UNIFORM_SETTERS, 35673, function (gl, location, value) {
return gl.uniform4iv(location, toIntArray(value, 4));
}), _defineProperty(_UNIFORM_SETTERS, 35674, function (gl, location, value) {
return gl.uniformMatrix2fv(location, false, toFloatArray(value, 4));
}), _defineProperty(_UNIFORM_SETTERS, 35675, function (gl, location, value) {
return gl.uniformMatrix3fv(location, false, toFloatArray(value, 9));
}), _defineProperty(_UNIFORM_SETTERS, 35676, function (gl, location, value) {
return gl.uniformMatrix4fv(location, false, toFloatArray(value, 16));
}), _defineProperty(_UNIFORM_SETTERS, 35678, function (gl, location, value) {
return gl.uniform1i(location, value);
}), _defineProperty(_UNIFORM_SETTERS, 35680, function (gl, location, value) {
return gl.uniform1i(location, value);
}), _defineProperty(_UNIFORM_SETTERS, 5125, function (gl, location, value) {
return gl.uniform1uiv(location, toUIntArray(value, 1));
}), _defineProperty(_UNIFORM_SETTERS, 36294, function (gl, location, value) {
return gl.uniform2uiv(location, toUIntArray(value, 2));
}), _defineProperty(_UNIFORM_SETTERS, 36295, function (gl, location, value) {
return gl.uniform3uiv(location, toUIntArray(value, 3));
}), _defineProperty(_UNIFORM_SETTERS, 36296, function (gl, location, value) {
return gl.uniform4uiv(location, toUIntArray(value, 4));
}), _defineProperty(_UNIFORM_SETTERS, 35685, function (gl, location, value) {
return gl.uniformMatrix2x3fv(location, false, toFloatArray(value, 6));
}), _defineProperty(_UNIFORM_SETTERS, 35686, function (gl, location, value) {
return gl.uniformMatrix2x4fv(location, false, toFloatArray(value, 8));
}), _defineProperty(_UNIFORM_SETTERS, 35687, function (gl, location, value) {
return gl.uniformMatrix3x2fv(location, false, toFloatArray(value, 6));
}), _defineProperty(_UNIFORM_SETTERS, 35688, function (gl, location, value) {
return gl.uniformMatrix3x4fv(location, false, toFloatArray(value, 12));
}), _defineProperty(_UNIFORM_SETTERS, 35689, function (gl, location, value) {
return gl.uniformMatrix4x2fv(location, false, toFloatArray(value, 8));
}), _defineProperty(_UNIFORM_SETTERS, 35690, function (gl, location, value) {
return gl.uniformMatrix4x3fv(location, false, toFloatArray(value, 12));
}), _defineProperty(_UNIFORM_SETTERS, 35679, function (gl, location, value) {
return gl.uniform1i(location, value);
}), _defineProperty(_UNIFORM_SETTERS, 35682, function (gl, location, value) {
return gl.uniform1i(location, value);
}), _defineProperty(_UNIFORM_SETTERS, 36289, function (gl, location, value) {
return gl.uniform1i(location, value);
}), _defineProperty(_UNIFORM_SETTERS, 36292, function (gl, location, value) {
return gl.uniform1i(location, value);
}), _defineProperty(_UNIFORM_SETTERS, 36293, function (gl, location, value) {
return gl.uniform1i(location, value);
}), _defineProperty(_UNIFORM_SETTERS, 36298, function (gl, location, value) {
return gl.uniform1i(location, value);
}), _defineProperty(_UNIFORM_SETTERS, 36299, function (gl, location, value) {
return gl.uniform1i(location, value);
}), _defineProperty(_UNIFORM_SETTERS, 36300, function (gl, location, value) {
return gl.uniform1i(location, value);
}), _defineProperty(_UNIFORM_SETTERS, 36303, function (gl, location, value) {
return gl.uniform1i(location, value);
}), _defineProperty(_UNIFORM_SETTERS, 36306, function (gl, location, value) {
return gl.uniform1i(location, value);
}), _defineProperty(_UNIFORM_SETTERS, 36307, function (gl, location, value) {
return gl.uniform1i(location, value);
}), _defineProperty(_UNIFORM_SETTERS, 36308, function (gl, location, value) {
return gl.uniform1i(location, value);
}), _defineProperty(_UNIFORM_SETTERS, 36311, function (gl, location, value) {
return gl.uniform1i(location, value);
}), _UNIFORM_SETTERS);
import { log, assert } from '../utils';
var UNIFORM_SETTERS = (_UNIFORM_SETTERS = {}, _defineProperty(_UNIFORM_SETTERS, 5126, getArraySetter.bind(null, 'uniform1fv', toFloatArray, 1, setVectorUniform)), _defineProperty(_UNIFORM_SETTERS, 35664, getArraySetter.bind(null, 'uniform2fv', toFloatArray, 2, setVectorUniform)), _defineProperty(_UNIFORM_SETTERS, 35665, getArraySetter.bind(null, 'uniform3fv', toFloatArray, 3, setVectorUniform)), _defineProperty(_UNIFORM_SETTERS, 35666, getArraySetter.bind(null, 'uniform4fv', toFloatArray, 4, setVectorUniform)), _defineProperty(_UNIFORM_SETTERS, 5124, getArraySetter.bind(null, 'uniform1iv', toIntArray, 1, setVectorUniform)), _defineProperty(_UNIFORM_SETTERS, 35667, getArraySetter.bind(null, 'uniform2iv', toIntArray, 2, setVectorUniform)), _defineProperty(_UNIFORM_SETTERS, 35668, getArraySetter.bind(null, 'uniform3iv', toIntArray, 3, setVectorUniform)), _defineProperty(_UNIFORM_SETTERS, 35669, getArraySetter.bind(null, 'uniform4iv', toIntArray, 4, setVectorUniform)), _defineProperty(_UNIFORM_SETTERS, 35670, getArraySetter.bind(null, 'uniform1iv', toIntArray, 1, setVectorUniform)), _defineProperty(_UNIFORM_SETTERS, 35671, getArraySetter.bind(null, 'uniform2iv', toIntArray, 2, setVectorUniform)), _defineProperty(_UNIFORM_SETTERS, 35672, getArraySetter.bind(null, 'uniform3iv', toIntArray, 3, setVectorUniform)), _defineProperty(_UNIFORM_SETTERS, 35673, getArraySetter.bind(null, 'uniform4iv', toIntArray, 4, setVectorUniform)), _defineProperty(_UNIFORM_SETTERS, 35674, getArraySetter.bind(null, 'uniformMatrix2fv', toFloatArray, 4, setMatrixUniform)), _defineProperty(_UNIFORM_SETTERS, 35675, getArraySetter.bind(null, 'uniformMatrix3fv', toFloatArray, 9, setMatrixUniform)), _defineProperty(_UNIFORM_SETTERS, 35676, getArraySetter.bind(null, 'uniformMatrix4fv', toFloatArray, 16, setMatrixUniform)), _defineProperty(_UNIFORM_SETTERS, 35678, getSamplerSetter), _defineProperty(_UNIFORM_SETTERS, 35680, getSamplerSetter), _defineProperty(_UNIFORM_SETTERS, 5125, getArraySetter.bind(null, 'uniform1uiv', toUIntArray, 1, setVectorUniform)), _defineProperty(_UNIFORM_SETTERS, 36294, getArraySetter.bind(null, 'uniform2uiv', toUIntArray, 2, setVectorUniform)), _defineProperty(_UNIFORM_SETTERS, 36295, getArraySetter.bind(null, 'uniform3uiv', toUIntArray, 3, setVectorUniform)), _defineProperty(_UNIFORM_SETTERS, 36296, getArraySetter.bind(null, 'uniform4uiv', toUIntArray, 4, setVectorUniform)), _defineProperty(_UNIFORM_SETTERS, 35685, getArraySetter.bind(null, 'uniformMatrix2x3fv', toFloatArray, 6, setMatrixUniform)), _defineProperty(_UNIFORM_SETTERS, 35686, getArraySetter.bind(null, 'uniformMatrix2x4fv', toFloatArray, 8, setMatrixUniform)), _defineProperty(_UNIFORM_SETTERS, 35687, getArraySetter.bind(null, 'uniformMatrix3x2fv', toFloatArray, 6, setMatrixUniform)), _defineProperty(_UNIFORM_SETTERS, 35688, getArraySetter.bind(null, 'uniformMatrix3x4fv', toFloatArray, 12, setMatrixUniform)), _defineProperty(_UNIFORM_SETTERS, 35689, getArraySetter.bind(null, 'uniformMatrix4x2fv', toFloatArray, 8, setMatrixUniform)), _defineProperty(_UNIFORM_SETTERS, 35690, getArraySetter.bind(null, 'uniformMatrix4x3fv', toFloatArray, 12, setMatrixUniform)), _defineProperty(_UNIFORM_SETTERS, 35679, getSamplerSetter), _defineProperty(_UNIFORM_SETTERS, 35682, getSamplerSetter), _defineProperty(_UNIFORM_SETTERS, 36289, getSamplerSetter), _defineProperty(_UNIFORM_SETTERS, 36292, getSamplerSetter), _defineProperty(_UNIFORM_SETTERS, 36293, getSamplerSetter), _defineProperty(_UNIFORM_SETTERS, 36298, getSamplerSetter), _defineProperty(_UNIFORM_SETTERS, 36299, getSamplerSetter), _defineProperty(_UNIFORM_SETTERS, 36300, getSamplerSetter), _defineProperty(_UNIFORM_SETTERS, 36303, getSamplerSetter), _defineProperty(_UNIFORM_SETTERS, 36306, getSamplerSetter), _defineProperty(_UNIFORM_SETTERS, 36307, getSamplerSetter), _defineProperty(_UNIFORM_SETTERS, 36308, getSamplerSetter), _defineProperty(_UNIFORM_SETTERS, 36311, getSamplerSetter), _UNIFORM_SETTERS);
var FLOAT_ARRAY = {};

@@ -171,3 +91,3 @@ var INT_ARRAY = {};

return setter.bind(null, gl, location);
return setter().bind(null, gl, location);
}

@@ -225,32 +145,71 @@ export function checkUniformValues(uniforms, source, uniformMap) {

export function areUniformsEqual(uniform1, uniform2) {
if (Array.isArray(uniform1) || ArrayBuffer.isView(uniform1)) {
if (!uniform2) {
return false;
export function copyUniform(uniforms, key, value) {
if (Array.isArray(value) || ArrayBuffer.isView(value)) {
if (uniforms[key]) {
var dest = uniforms[key];
for (var i = 0, len = value.length; i < len; ++i) {
dest[i] = value[i];
}
} else {
uniforms[key] = value.slice();
}
} else {
uniforms[key] = value;
}
}
var len = uniform1.length;
function getSamplerSetter() {
var cache = null;
return function (gl, location, value) {
var update = cache !== value;
if (uniform2.length !== len) {
return false;
if (update) {
gl.uniform1i(location, value);
cache = value;
}
for (var i = 0; i < len; i++) {
if (uniform1[i] !== uniform2[i]) {
return false;
return update;
};
}
function getArraySetter(functionName, toArray, size, uniformSetter) {
var cache = null;
var cacheLength = null;
return function (gl, location, value) {
var arrayValue = toArray(value, size);
var length = arrayValue.length;
var update = false;
if (cache === null) {
cache = new Float32Array(length);
cacheLength = length;
update = true;
} else {
assert(cacheLength === length, 'Uniform length cannot change.');
for (var i = 0; i < length; ++i) {
if (arrayValue[i] !== cache[i]) {
update = true;
break;
}
}
}
return true;
}
if (update) {
uniformSetter(gl, functionName, location, arrayValue);
cache.set(arrayValue);
}
return uniform1 === uniform2;
return update;
};
}
export function getUniformCopy(uniform) {
if (Array.isArray(uniform) || ArrayBuffer.isView(uniform)) {
return uniform.slice();
}
return uniform;
function setVectorUniform(gl, functionName, location, value) {
gl[functionName](location, value);
}
function setMatrixUniform(gl, functionName, location, value) {
gl[functionName](location, false, value);
}
//# sourceMappingURL=uniforms.js.map

@@ -95,5 +95,5 @@ import _classCallCheck from "@babel/runtime/helpers/esm/classCallCheck";

key: "getDrawParams",
value: function getDrawParams(appParameters) {
value: function getDrawParams() {
this.drawParams = this.drawParams || this._updateDrawParams();
return Object.assign({}, this.drawParams, appParameters);
return this.drawParams;
}

@@ -100,0 +100,0 @@ }, {

import _objectSpread from "@babel/runtime/helpers/esm/objectSpread";
import { trackContextState } from '@luma.gl/webgl-state-tracker';
import { trackContextState } from '@luma.gl/gltools';
import { createHeadlessContext } from './create-headless-context';

@@ -4,0 +4,0 @@ import { getCanvas } from './create-canvas';

@@ -1,4 +0,4 @@

export { trackContextState, resetParameters, getParameter, getParameters, setParameter, setParameters, withParameters, getModifiedParameters } from '@luma.gl/webgl-state-tracker';
export { trackContextState, resetParameters, getParameter, getParameters, setParameter, setParameters, withParameters, getModifiedParameters } from '@luma.gl/gltools';
export { createGLContext, instrumentGLContext, destroyGLContext, resizeGLContext, setGLContextDefaults } from './context';
export { getPageLoadPromise, getCanvas } from './create-canvas';
//# sourceMappingURL=index.js.map
export { lumaStats } from './init';
export { resetParameters, getParameter, getParameters, setParameter, setParameters, withParameters, getModifiedParameters } from '@luma.gl/webgl-state-tracker';
export { resetParameters, getParameter, getParameters, setParameter, setParameters, withParameters, getModifiedParameters } from '@luma.gl/gltools';
export { Image, WebGLRenderingContext, WebGLProgram, WebGLShader, WebGLBuffer, WebGLFramebuffer, WebGLRenderbuffer, WebGLTexture, WebGLUniformLocation, WebGLActiveInfo, WebGLShaderPrecisionFormat, WebGL2RenderingContext, webGLTypesAvailable } from './webgl-utils/webgl-types';

@@ -4,0 +4,0 @@ export { createGLContext, destroyGLContext, resizeGLContext, instrumentGLContext, setGLContextDefaults } from './context/context';

@@ -7,4 +7,4 @@ import _classCallCheck from "@babel/runtime/helpers/esm/classCallCheck";

import { Stats } from 'probe.gl';
import '@luma.gl/webgl2-polyfill';
var VERSION = typeof "7.4.0-alpha.1" !== 'undefined' ? "7.4.0-alpha.1" : 'untranspiled source';
import '@luma.gl/gltools';
var VERSION = typeof "8.0.0-alpha.1" !== 'undefined' ? "8.0.0-alpha.1" : 'untranspiled source';
var STARTUP_MESSAGE = 'set luma.log.priority=1 (or higher) to trace rendering';

@@ -11,0 +11,0 @@

@@ -5,3 +5,10 @@ import _classCallCheck from "@babel/runtime/helpers/esm/classCallCheck";

export var ERR_HEADLESSGL_LOAD = "luma.gl: loaded under Node.js without headless gl installed, meaning that WebGL contexts can not be created. This may not be an error. For example, this is a typical configuration for isorender applications running on the server.";
var m = module;
var m;
try {
m = module;
} catch (e) {
m = null;
}
export var headlessTypes = null;

@@ -8,0 +15,0 @@ export function headlessGL() {

{
"name": "@luma.gl/webgl",
"version": "7.4.0-alpha.2",
"version": "8.0.0-alpha.2",
"description": "WebGL2 Classes",

@@ -38,8 +38,7 @@ "license": "MIT",

"@babel/runtime": "^7.0.0",
"@luma.gl/constants": "7.4.0-alpha.2",
"@luma.gl/webgl-state-tracker": "7.4.0-alpha.2",
"@luma.gl/webgl2-polyfill": "7.4.0-alpha.2",
"@luma.gl/constants": "8.0.0-alpha.2",
"@luma.gl/gltools": "8.0.0-alpha.2",
"probe.gl": "^3.1.1"
},
"gitHead": "9e0402154cd180e539baca244519383a993fe099"
"gitHead": "07e2a074d37155ea97f16d1ee7b627284acc4840"
}

@@ -9,3 +9,3 @@ import GL from '@luma.gl/constants';

import ProgramConfiguration from './program-configuration';
import {checkUniformValues, areUniformsEqual, getUniformCopy} from './uniforms';
import {copyUniform, checkUniformValues} from './uniforms';

@@ -58,5 +58,6 @@ import {withParameters} from '../context';

initialize(props = {}) {
const {hash, vs, fs, varyings, bufferMode = GL_SEPARATE_ATTRIBS} = props;
const {hash, vs, fs, varyings, bufferMode = GL_SEPARATE_ATTRIBS, debug = false} = props;
this.hash = hash || ''; // Used by ProgramManager
this.debug = debug;

@@ -74,2 +75,4 @@ // Create shaders if needed

this._texturesRenderable = true;
// Setup varyings if supplied

@@ -134,3 +137,3 @@ if (varyings && varyings.length > 0) {

if (logPriority !== undefined) {
if (this.debug && logPriority !== undefined) {
const fb = framebuffer ? framebuffer.id : 'default';

@@ -192,18 +195,47 @@ const message =

setUniforms(uniforms = {}, _onChangeCallback = () => {}) {
// Simple change detection - if all uniforms are unchanged, do nothing
let somethingChanged = false;
const changedUniforms = {};
for (const key in uniforms) {
if (!areUniformsEqual(this.uniforms[key], uniforms[key])) {
somethingChanged = true;
changedUniforms[key] = uniforms[key];
this.uniforms[key] = getUniformCopy(uniforms[key]);
}
setUniforms(uniforms = {}) {
if (this.debug) {
checkUniformValues(uniforms, this.id, this._uniformSetters);
}
if (somethingChanged) {
_onChangeCallback();
checkUniformValues(changedUniforms, this.id, this._uniformSetters);
this._setUniforms(changedUniforms);
this.gl.useProgram(this.handle);
for (const uniformName in uniforms) {
const uniform = uniforms[uniformName];
const uniformSetter = this._uniformSetters[uniformName];
if (uniformSetter) {
let value = uniform;
let textureUpdate = false;
if (value instanceof Framebuffer) {
value = value.texture;
}
if (value instanceof Texture) {
textureUpdate = this.uniforms[uniformName] !== uniform;
if (textureUpdate) {
// eslint-disable-next-line max-depth
if (uniformSetter.textureIndex === undefined) {
uniformSetter.textureIndex = this._textureIndexCounter++;
}
// Bind texture to index
const texture = value;
const {textureIndex} = uniformSetter;
texture.bind(textureIndex);
value = textureIndex;
if (!texture.loaded) {
this._texturesRenderable = false;
}
}
}
// NOTE(Tarek): uniformSetter returns whether
// value had to be updated or not.
if (uniformSetter(value) || textureUpdate) {
copyUniform(this.uniforms, uniformName, uniform);
}
}
}

@@ -216,10 +248,11 @@

// stub for shader chache, should reset uniforms to default valiues
reset() {}
// Checks if all texture-values uniforms are renderable (i.e. loaded)
// Note: This is currently done before every draw call
_areTexturesRenderable() {
let texturesRenderable = true;
if (this._texturesRenderable) {
return true;
}
this._texturesRenderable = true;
for (const uniformName in this.uniforms) {

@@ -239,3 +272,3 @@ const uniformSetter = this._uniformSetters[uniformName];

// Check that texture is loaded
texturesRenderable = texturesRenderable && texture.loaded;
this._texturesRenderable = this._texturesRenderable && texture.loaded;
}

@@ -245,3 +278,3 @@ }

return texturesRenderable;
return this._texturesRenderable;
}

@@ -270,39 +303,2 @@

// Apply a set of uniform values to a program
// Only uniforms actually present in the linked program will be updated.
_setUniforms(uniforms) {
this.gl.useProgram(this.handle);
for (const uniformName in uniforms) {
let uniform = uniforms[uniformName];
const uniformSetter = this._uniformSetters[uniformName];
if (uniformSetter) {
if (uniform instanceof Framebuffer) {
uniform = uniform.texture;
}
if (uniform instanceof Texture) {
// eslint-disable-next-line max-depth
if (uniformSetter.textureIndex === undefined) {
uniformSetter.textureIndex = this._textureIndexCounter++;
}
// Bind texture to index
const texture = uniform;
const {textureIndex} = uniformSetter;
texture.bind(textureIndex);
// Set the uniform sampler to the texture index
uniformSetter(textureIndex);
} else {
// Just set the value
uniformSetter(uniform);
}
}
}
return this;
}
// RESOURCE METHODS

@@ -309,0 +305,0 @@

@@ -5,3 +5,3 @@ import GL from '@luma.gl/constants';

import Texture from './texture';
import {log} from '../utils';
import {log, assert} from '../utils';

@@ -12,62 +12,113 @@ const UNIFORM_SETTERS = {

/* eslint-disable max-len */
[GL.FLOAT]: (gl, location, value) => gl.uniform1fv(location, toFloatArray(value, 1)),
[GL.FLOAT_VEC2]: (gl, location, value) => gl.uniform2fv(location, toFloatArray(value, 2)),
[GL.FLOAT_VEC3]: (gl, location, value) => gl.uniform3fv(location, toFloatArray(value, 3)),
[GL.FLOAT_VEC4]: (gl, location, value) => gl.uniform4fv(location, toFloatArray(value, 4)),
[GL.FLOAT]: getArraySetter.bind(null, 'uniform1fv', toFloatArray, 1, setVectorUniform),
[GL.FLOAT_VEC2]: getArraySetter.bind(null, 'uniform2fv', toFloatArray, 2, setVectorUniform),
[GL.FLOAT_VEC3]: getArraySetter.bind(null, 'uniform3fv', toFloatArray, 3, setVectorUniform),
[GL.FLOAT_VEC4]: getArraySetter.bind(null, 'uniform4fv', toFloatArray, 4, setVectorUniform),
[GL.INT]: (gl, location, value) => gl.uniform1iv(location, toIntArray(value, 1)),
[GL.INT_VEC2]: (gl, location, value) => gl.uniform2iv(location, toIntArray(value, 2)),
[GL.INT_VEC3]: (gl, location, value) => gl.uniform3iv(location, toIntArray(value, 3)),
[GL.INT_VEC4]: (gl, location, value) => gl.uniform4iv(location, toIntArray(value, 4)),
[GL.INT]: getArraySetter.bind(null, 'uniform1iv', toIntArray, 1, setVectorUniform),
[GL.INT_VEC2]: getArraySetter.bind(null, 'uniform2iv', toIntArray, 2, setVectorUniform),
[GL.INT_VEC3]: getArraySetter.bind(null, 'uniform3iv', toIntArray, 3, setVectorUniform),
[GL.INT_VEC4]: getArraySetter.bind(null, 'uniform4iv', toIntArray, 4, setVectorUniform),
[GL.BOOL]: (gl, location, value) => gl.uniform1iv(location, toIntArray(value, 1)),
[GL.BOOL_VEC2]: (gl, location, value) => gl.uniform2iv(location, toIntArray(value, 2)),
[GL.BOOL_VEC3]: (gl, location, value) => gl.uniform3iv(location, toIntArray(value, 3)),
[GL.BOOL_VEC4]: (gl, location, value) => gl.uniform4iv(location, toIntArray(value, 4)),
[GL.BOOL]: getArraySetter.bind(null, 'uniform1iv', toIntArray, 1, setVectorUniform),
[GL.BOOL_VEC2]: getArraySetter.bind(null, 'uniform2iv', toIntArray, 2, setVectorUniform),
[GL.BOOL_VEC3]: getArraySetter.bind(null, 'uniform3iv', toIntArray, 3, setVectorUniform),
[GL.BOOL_VEC4]: getArraySetter.bind(null, 'uniform4iv', toIntArray, 4, setVectorUniform),
// uniformMatrix(false): don't transpose the matrix
[GL.FLOAT_MAT2]: (gl, location, value) =>
gl.uniformMatrix2fv(location, false, toFloatArray(value, 4)),
[GL.FLOAT_MAT3]: (gl, location, value) =>
gl.uniformMatrix3fv(location, false, toFloatArray(value, 9)),
[GL.FLOAT_MAT4]: (gl, location, value) =>
gl.uniformMatrix4fv(location, false, toFloatArray(value, 16)),
[GL.FLOAT_MAT2]: getArraySetter.bind(null, 'uniformMatrix2fv', toFloatArray, 4, setMatrixUniform),
[GL.FLOAT_MAT3]: getArraySetter.bind(null, 'uniformMatrix3fv', toFloatArray, 9, setMatrixUniform),
[GL.FLOAT_MAT4]: getArraySetter.bind(
null,
'uniformMatrix4fv',
toFloatArray,
16,
setMatrixUniform
),
[GL.SAMPLER_2D]: (gl, location, value) => gl.uniform1i(location, value),
[GL.SAMPLER_CUBE]: (gl, location, value) => gl.uniform1i(location, value),
[GL.SAMPLER_2D]: getSamplerSetter,
[GL.SAMPLER_CUBE]: getSamplerSetter,
// WEBGL2 - unsigned integers, irregular matrices, additional texture samplers
[GL.UNSIGNED_INT]: (gl, location, value) => gl.uniform1uiv(location, toUIntArray(value, 1)),
[GL.UNSIGNED_INT_VEC2]: (gl, location, value) => gl.uniform2uiv(location, toUIntArray(value, 2)),
[GL.UNSIGNED_INT_VEC3]: (gl, location, value) => gl.uniform3uiv(location, toUIntArray(value, 3)),
[GL.UNSIGNED_INT_VEC4]: (gl, location, value) => gl.uniform4uiv(location, toUIntArray(value, 4)),
[GL.UNSIGNED_INT]: getArraySetter.bind(null, 'uniform1uiv', toUIntArray, 1, setVectorUniform),
[GL.UNSIGNED_INT_VEC2]: getArraySetter.bind(
null,
'uniform2uiv',
toUIntArray,
2,
setVectorUniform
),
[GL.UNSIGNED_INT_VEC3]: getArraySetter.bind(
null,
'uniform3uiv',
toUIntArray,
3,
setVectorUniform
),
[GL.UNSIGNED_INT_VEC4]: getArraySetter.bind(
null,
'uniform4uiv',
toUIntArray,
4,
setVectorUniform
),
// uniformMatrix(false): don't transpose the matrix
[GL.FLOAT_MAT2x3]: (gl, location, value) =>
gl.uniformMatrix2x3fv(location, false, toFloatArray(value, 6)),
[GL.FLOAT_MAT2x4]: (gl, location, value) =>
gl.uniformMatrix2x4fv(location, false, toFloatArray(value, 8)),
[GL.FLOAT_MAT3x2]: (gl, location, value) =>
gl.uniformMatrix3x2fv(location, false, toFloatArray(value, 6)),
[GL.FLOAT_MAT3x4]: (gl, location, value) =>
gl.uniformMatrix3x4fv(location, false, toFloatArray(value, 12)),
[GL.FLOAT_MAT4x2]: (gl, location, value) =>
gl.uniformMatrix4x2fv(location, false, toFloatArray(value, 8)),
[GL.FLOAT_MAT4x3]: (gl, location, value) =>
gl.uniformMatrix4x3fv(location, false, toFloatArray(value, 12)),
[GL.FLOAT_MAT2x3]: getArraySetter.bind(
null,
'uniformMatrix2x3fv',
toFloatArray,
6,
setMatrixUniform
),
[GL.FLOAT_MAT2x4]: getArraySetter.bind(
null,
'uniformMatrix2x4fv',
toFloatArray,
8,
setMatrixUniform
),
[GL.FLOAT_MAT3x2]: getArraySetter.bind(
null,
'uniformMatrix3x2fv',
toFloatArray,
6,
setMatrixUniform
),
[GL.FLOAT_MAT3x4]: getArraySetter.bind(
null,
'uniformMatrix3x4fv',
toFloatArray,
12,
setMatrixUniform
),
[GL.FLOAT_MAT4x2]: getArraySetter.bind(
null,
'uniformMatrix4x2fv',
toFloatArray,
8,
setMatrixUniform
),
[GL.FLOAT_MAT4x3]: getArraySetter.bind(
null,
'uniformMatrix4x3fv',
toFloatArray,
12,
setMatrixUniform
),
[GL.SAMPLER_3D]: (gl, location, value) => gl.uniform1i(location, value),
[GL.SAMPLER_2D_SHADOW]: (gl, location, value) => gl.uniform1i(location, value),
[GL.SAMPLER_2D_ARRAY]: (gl, location, value) => gl.uniform1i(location, value),
[GL.SAMPLER_2D_ARRAY_SHADOW]: (gl, location, value) => gl.uniform1i(location, value),
[GL.SAMPLER_CUBE_SHADOW]: (gl, location, value) => gl.uniform1i(location, value),
[GL.INT_SAMPLER_2D]: (gl, location, value) => gl.uniform1i(location, value),
[GL.INT_SAMPLER_3D]: (gl, location, value) => gl.uniform1i(location, value),
[GL.INT_SAMPLER_CUBE]: (gl, location, value) => gl.uniform1i(location, value),
[GL.INT_SAMPLER_2D_ARRAY]: (gl, location, value) => gl.uniform1i(location, value),
[GL.UNSIGNED_INT_SAMPLER_2D]: (gl, location, value) => gl.uniform1i(location, value),
[GL.UNSIGNED_INT_SAMPLER_3D]: (gl, location, value) => gl.uniform1i(location, value),
[GL.UNSIGNED_INT_SAMPLER_CUBE]: (gl, location, value) => gl.uniform1i(location, value),
[GL.UNSIGNED_INT_SAMPLER_2D_ARRAY]: (gl, location, value) => gl.uniform1i(location, value)
[GL.SAMPLER_3D]: getSamplerSetter,
[GL.SAMPLER_2D_SHADOW]: getSamplerSetter,
[GL.SAMPLER_2D_ARRAY]: getSamplerSetter,
[GL.SAMPLER_2D_ARRAY_SHADOW]: getSamplerSetter,
[GL.SAMPLER_CUBE_SHADOW]: getSamplerSetter,
[GL.INT_SAMPLER_2D]: getSamplerSetter,
[GL.INT_SAMPLER_3D]: getSamplerSetter,
[GL.INT_SAMPLER_CUBE]: getSamplerSetter,
[GL.INT_SAMPLER_2D_ARRAY]: getSamplerSetter,
[GL.UNSIGNED_INT_SAMPLER_2D]: getSamplerSetter,
[GL.UNSIGNED_INT_SAMPLER_3D]: getSamplerSetter,
[GL.UNSIGNED_INT_SAMPLER_CUBE]: getSamplerSetter,
[GL.UNSIGNED_INT_SAMPLER_2D_ARRAY]: getSamplerSetter
/* eslint-enable max-len */

@@ -84,3 +135,4 @@ };

// Functions to ensure the type of uniform values
// TODO - Why is this necessary? The uniform*v funtions can consume Arrays
// This is done because uniform*v functions
// are extremely slow when consuming JS arrays directly.
function toTypedArray(value, uniformLength, Type, cache) {

@@ -157,3 +209,6 @@ // convert boolean uniforms to Number

}
return setter.bind(null, gl, location);
// NOTE(Tarek): This construction is the ensure
// separate caches for all setters.
return setter().bind(null, gl, location);
}

@@ -218,31 +273,69 @@

/**
* Given two values of a uniform, returns `true` if they are equal
* Creates a copy of the uniform
*/
export function areUniformsEqual(uniform1, uniform2) {
if (Array.isArray(uniform1) || ArrayBuffer.isView(uniform1)) {
if (!uniform2) {
return false;
export function copyUniform(uniforms, key, value) {
if (Array.isArray(value) || ArrayBuffer.isView(value)) {
if (uniforms[key]) {
const dest = uniforms[key];
for (let i = 0, len = value.length; i < len; ++i) {
dest[i] = value[i];
}
} else {
uniforms[key] = value.slice();
}
const len = uniform1.length;
if (uniform2.length !== len) {
return false;
} else {
uniforms[key] = value;
}
}
// NOTE(Tarek): Setters maintain a cache
// of the previously set value, and
// avoid resetting it if it's the same.
function getSamplerSetter() {
let cache = null;
return (gl, location, value) => {
const update = cache !== value;
if (update) {
gl.uniform1i(location, value);
cache = value;
}
for (let i = 0; i < len; i++) {
if (uniform1[i] !== uniform2[i]) {
return false;
return update;
};
}
function getArraySetter(functionName, toArray, size, uniformSetter) {
let cache = null;
let cacheLength = null;
return (gl, location, value) => {
const arrayValue = toArray(value, size);
const length = arrayValue.length;
let update = false;
if (cache === null) {
cache = new Float32Array(length);
cacheLength = length;
update = true;
} else {
assert(cacheLength === length, 'Uniform length cannot change.');
for (let i = 0; i < length; ++i) {
if (arrayValue[i] !== cache[i]) {
update = true;
break;
}
}
}
return true;
}
return uniform1 === uniform2;
if (update) {
uniformSetter(gl, functionName, location, arrayValue);
cache.set(arrayValue);
}
return update;
};
}
/**
* Creates a copy of the uniform
*/
export function getUniformCopy(uniform) {
if (Array.isArray(uniform) || ArrayBuffer.isView(uniform)) {
return uniform.slice();
}
return uniform;
function setVectorUniform(gl, functionName, location, value) {
gl[functionName](location, value);
}
function setMatrixUniform(gl, functionName, location, value) {
gl[functionName](location, false, value);
}

@@ -112,8 +112,7 @@ import GL from '@luma.gl/constants';

getDrawParams(appParameters) {
getDrawParams() {
// Auto deduced draw parameters
this.drawParams = this.drawParams || this._updateDrawParams();
// Override with any application supplied draw parameters
return Object.assign({}, this.drawParams, appParameters);
return this.drawParams;
}

@@ -120,0 +119,0 @@

/* eslint-disable quotes */
// WebGLRenderingContext related methods
import {trackContextState} from '@luma.gl/webgl-state-tracker';
import {trackContextState} from '@luma.gl/gltools';

@@ -5,0 +5,0 @@ import {createHeadlessContext} from './create-headless-context';

@@ -10,3 +10,3 @@ export {

getModifiedParameters
} from '@luma.gl/webgl-state-tracker';
} from '@luma.gl/gltools';

@@ -13,0 +13,0 @@ export {

@@ -19,3 +19,3 @@ // luma.gl Base WebGL wrapper library

getModifiedParameters
} from '@luma.gl/webgl-state-tracker';
} from '@luma.gl/gltools';

@@ -22,0 +22,0 @@ // Exports WebGL API constants and types, plus some basic type checks

@@ -8,3 +8,3 @@ import isBrowser from './utils/is-browser';

// Can be installed by applications
import '@luma.gl/webgl2-polyfill';
import '@luma.gl/gltools';

@@ -11,0 +11,0 @@ // Version detection using babel plugin

@@ -21,3 +21,12 @@ // WEBGL BUILT-IN TYPES

// remove automatic headless context creation
const m = module;
// NOTE: Rollup does not process the line `const m = module;`
// and writes it out verbatim in its final output, which ends
// up falling over in browser environments at runtime. Added
// a `try/catch` block to fix usage in rollup builds.
let m;
try {
m = module;
} catch (e) {
m = null;
}

@@ -24,0 +33,0 @@ // Load headless gl dynamically, if available

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 not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

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