parsegraph-shader
Advanced tools
Comparing version 1.5.9 to 1.5.10-dev
@@ -1,2 +0,211 @@ | ||
!function(r,e){"object"==typeof exports&&"object"==typeof module?module.exports=e(require("parsegraph-checkglerror")):"function"==typeof define&&define.amd?define(["parsegraph-checkglerror"],e):"object"==typeof exports?exports.parsegraph_shader=e(require("parsegraph-checkglerror")):r.parsegraph_shader=e(r.parsegraph_checkglerror)}(this,(r=>(()=>{"use strict";var e={561:e=>{e.exports=r}},t={};function o(r){var a=t[r];if(void 0!==a)return a.exports;var n=t[r]={exports:{}};return e[r](n,n.exports,o),n.exports}o.n=r=>{var e=r&&r.__esModule?()=>r.default:()=>r;return o.d(e,{a:e}),e},o.d=(r,e)=>{for(var t in e)o.o(e,t)&&!o.o(r,t)&&Object.defineProperty(r,t,{enumerable:!0,get:e[t]})},o.o=(r,e)=>Object.prototype.hasOwnProperty.call(r,e),o.r=r=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(r,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(r,"__esModule",{value:!0})};var a={};return(()=>{o.r(a),o.d(a,{compileShader:()=>e,createProgram:()=>t,createProgramFromScripts:()=>p,createShaderFromScriptTag:()=>n});var r=o(561);function e(e,t,o,a){var n=e.createShader(o);if(!(e.shaderSource(n,t),e.compileShader(n),(0,r.ignoreGLErrors)()||e.getShaderParameter(n,e.COMPILE_STATUS)))throw new Error("Could not compile "+(o===e.FRAGMENT_SHADER?"fragment":"vertex")+" shader "+a+": "+e.getShaderInfoLog(n));return n}function t(r,e,t){var o=r.createProgram();if(r.attachShader(o,e),r.attachShader(o,t),r.linkProgram(o),!r.getProgramParameter(o,r.LINK_STATUS))throw new Error("program filed to link:"+r.getProgramInfoLog(o));return o}function n(r,t,o){var a=document.getElementById(t);if(!a)throw new Error("*** Error: unknown script element: "+t);var n=a.text;if(!o)if("x-shader/x-vertex"==a.type)o=r.VERTEX_SHADER;else if("x-shader/x-fragment"==a.type)o=r.FRAGMENT_SHADER;else if(!o)throw new Error("*** Error: shader type not set");return e(r,n,o)}function p(r,e,o){return t(r,n(r,e),n(r,o))}})(),a})())); | ||
(function webpackUniversalModuleDefinition(root, factory) { | ||
if(typeof exports === 'object' && typeof module === 'object') | ||
module.exports = factory(require("parsegraph-checkglerror")); | ||
else if(typeof define === 'function' && define.amd) | ||
define(["parsegraph-checkglerror"], factory); | ||
else if(typeof exports === 'object') | ||
exports["parsegraph_shader"] = factory(require("parsegraph-checkglerror")); | ||
else | ||
root["parsegraph_shader"] = factory(root["parsegraph_checkglerror"]); | ||
})(this, (__WEBPACK_EXTERNAL_MODULE_parsegraph_checkglerror__) => { | ||
return /******/ (() => { // webpackBootstrap | ||
/******/ "use strict"; | ||
/******/ var __webpack_modules__ = ({ | ||
/***/ "parsegraph-checkglerror": | ||
/*!**************************************************************************************************************************************************************!*\ | ||
!*** external {"commonjs":"parsegraph-checkglerror","commonjs2":"parsegraph-checkglerror","amd":"parsegraph-checkglerror","root":"parsegraph_checkglerror"} ***! | ||
\**************************************************************************************************************************************************************/ | ||
/***/ ((module) => { | ||
module.exports = __WEBPACK_EXTERNAL_MODULE_parsegraph_checkglerror__; | ||
/***/ }) | ||
/******/ }); | ||
/************************************************************************/ | ||
/******/ // The module cache | ||
/******/ var __webpack_module_cache__ = {}; | ||
/******/ | ||
/******/ // The require function | ||
/******/ function __webpack_require__(moduleId) { | ||
/******/ // Check if module is in cache | ||
/******/ var cachedModule = __webpack_module_cache__[moduleId]; | ||
/******/ if (cachedModule !== undefined) { | ||
/******/ return cachedModule.exports; | ||
/******/ } | ||
/******/ // Create a new module (and put it into the cache) | ||
/******/ var module = __webpack_module_cache__[moduleId] = { | ||
/******/ // no module.id needed | ||
/******/ // no module.loaded needed | ||
/******/ exports: {} | ||
/******/ }; | ||
/******/ | ||
/******/ // Execute the module function | ||
/******/ __webpack_modules__[moduleId](module, module.exports, __webpack_require__); | ||
/******/ | ||
/******/ // Return the exports of the module | ||
/******/ return module.exports; | ||
/******/ } | ||
/******/ | ||
/************************************************************************/ | ||
/******/ /* webpack/runtime/compat get default export */ | ||
/******/ (() => { | ||
/******/ // getDefaultExport function for compatibility with non-harmony modules | ||
/******/ __webpack_require__.n = (module) => { | ||
/******/ var getter = module && module.__esModule ? | ||
/******/ () => (module['default']) : | ||
/******/ () => (module); | ||
/******/ __webpack_require__.d(getter, { a: getter }); | ||
/******/ return getter; | ||
/******/ }; | ||
/******/ })(); | ||
/******/ | ||
/******/ /* webpack/runtime/define property getters */ | ||
/******/ (() => { | ||
/******/ // define getter functions for harmony exports | ||
/******/ __webpack_require__.d = (exports, definition) => { | ||
/******/ for(var key in definition) { | ||
/******/ if(__webpack_require__.o(definition, key) && !__webpack_require__.o(exports, key)) { | ||
/******/ Object.defineProperty(exports, key, { enumerable: true, get: definition[key] }); | ||
/******/ } | ||
/******/ } | ||
/******/ }; | ||
/******/ })(); | ||
/******/ | ||
/******/ /* webpack/runtime/hasOwnProperty shorthand */ | ||
/******/ (() => { | ||
/******/ __webpack_require__.o = (obj, prop) => (Object.prototype.hasOwnProperty.call(obj, prop)) | ||
/******/ })(); | ||
/******/ | ||
/******/ /* webpack/runtime/make namespace object */ | ||
/******/ (() => { | ||
/******/ // define __esModule on exports | ||
/******/ __webpack_require__.r = (exports) => { | ||
/******/ if(typeof Symbol !== 'undefined' && Symbol.toStringTag) { | ||
/******/ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' }); | ||
/******/ } | ||
/******/ Object.defineProperty(exports, '__esModule', { value: true }); | ||
/******/ }; | ||
/******/ })(); | ||
/******/ | ||
/************************************************************************/ | ||
var __webpack_exports__ = {}; | ||
// This entry need to be wrapped in an IIFE because it need to be isolated against other modules in the chunk. | ||
(() => { | ||
/*!**********************!*\ | ||
!*** ./src/index.ts ***! | ||
\**********************/ | ||
__webpack_require__.r(__webpack_exports__); | ||
/* harmony export */ __webpack_require__.d(__webpack_exports__, { | ||
/* harmony export */ "compileShader": () => (/* binding */ compileShader), | ||
/* harmony export */ "createProgram": () => (/* binding */ createProgram), | ||
/* harmony export */ "createProgramFromScripts": () => (/* binding */ createProgramFromScripts), | ||
/* harmony export */ "createShaderFromScriptTag": () => (/* binding */ createShaderFromScriptTag) | ||
/* harmony export */ }); | ||
/* harmony import */ var parsegraph_checkglerror__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! parsegraph-checkglerror */ "parsegraph-checkglerror"); | ||
/* harmony import */ var parsegraph_checkglerror__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(parsegraph_checkglerror__WEBPACK_IMPORTED_MODULE_0__); | ||
// The following methods were based on code from webglfundamentals.org: | ||
/** | ||
* Creates and compiles a shader. | ||
* | ||
* @param {!WebGLRenderingContext} gl The WebGL Context. | ||
* @param {string} shaderSource The GLSL source code for the shader. | ||
* @param {number} shaderType The type of shader, VERTEX_SHADER or | ||
* FRAGMENT_SHADER. | ||
* @param {string} shaderName The name used for debugging | ||
* @return {!WebGLShader} The shader. | ||
*/ | ||
function compileShader(gl, shaderSource, shaderType, shaderName) { | ||
// Create the shader object | ||
var shader = gl.createShader(shaderType); | ||
// Set the shader source code. | ||
gl.shaderSource(shader, shaderSource); | ||
// Compile the shader | ||
gl.compileShader(shader); | ||
// Check if it compiled | ||
if (!(0,parsegraph_checkglerror__WEBPACK_IMPORTED_MODULE_0__.ignoreGLErrors)()) { | ||
var success = gl.getShaderParameter(shader, gl.COMPILE_STATUS); | ||
if (!success) { | ||
// Something went wrong during compilation; get the error | ||
throw new Error("Could not compile " + (shaderType === gl.FRAGMENT_SHADER ? "fragment" : "vertex") + " shader " + shaderName + ": " + gl.getShaderInfoLog(shader)); | ||
} | ||
} | ||
return shader; | ||
} | ||
/** | ||
* Creates a program from 2 shaders. | ||
* | ||
* @param {WebGLRenderingContext} gl The WebGL context. | ||
* @param {WebGLShader} vertexShader A vertex shader. | ||
* @param {WebGLShader} fragmentShader A fragment shader. | ||
* @return {WebGLProgram} A program. | ||
*/ | ||
function createProgram(gl, vertexShader, fragmentShader) { | ||
// create a program. | ||
var program = gl.createProgram(); | ||
// attach the shaders. | ||
gl.attachShader(program, vertexShader); | ||
gl.attachShader(program, fragmentShader); | ||
// link the program. | ||
gl.linkProgram(program); | ||
// Check if it linked. | ||
var success = gl.getProgramParameter(program, gl.LINK_STATUS); | ||
if (!success) { | ||
// something went wrong with the link | ||
throw new Error("program filed to link:" + gl.getProgramInfoLog(program)); | ||
} | ||
return program; | ||
} | ||
/** | ||
* Creates a shader from the content of a script tag. | ||
* | ||
* @param {!WebGLRenderingContext} gl The WebGL Context. | ||
* @param {string} scriptId The id of the script tag. | ||
* @param {number} optShaderType The type of shader to create. | ||
* If not passed in will use the type attribute from the | ||
* script tag. | ||
* @return {!WebGLShader} A shader. | ||
*/ | ||
function createShaderFromScriptTag(gl, scriptId, optShaderType) { | ||
// look up the script tag by id. | ||
var shaderScript = document.getElementById(scriptId); | ||
if (!shaderScript) { | ||
throw new Error("*** Error: unknown script element: " + scriptId); | ||
} | ||
// extract the contents of the script tag. | ||
var shaderSource = shaderScript.text; | ||
// If we didn't pass in a type, use the 'type' from | ||
// the script tag. | ||
if (!optShaderType) { | ||
if (shaderScript.type == "x-shader/x-vertex") { | ||
optShaderType = gl.VERTEX_SHADER; | ||
} else if (shaderScript.type == "x-shader/x-fragment") { | ||
optShaderType = gl.FRAGMENT_SHADER; | ||
} else if (!optShaderType) { | ||
throw new Error("*** Error: shader type not set"); | ||
} | ||
} | ||
return compileShader(gl, shaderSource, optShaderType); | ||
} | ||
/** | ||
* Creates a program from 2 script tags. | ||
* | ||
* @param {!WebGLRenderingContext} gl The WebGL Context. | ||
* @param {string} vertexShaderId The id of the vertex shader script tag. | ||
* @param {string} fragmentShaderId The id of the fragment shader script tag. | ||
* @return {!WebGLProgram} A program | ||
*/ | ||
function createProgramFromScripts(gl, vertexShaderId, fragmentShaderId) { | ||
var vertexShader = createShaderFromScriptTag(gl, vertexShaderId); | ||
var fragmentShader = createShaderFromScriptTag(gl, fragmentShaderId); | ||
return createProgram(gl, vertexShader, fragmentShader); | ||
} | ||
})(); | ||
/******/ return __webpack_exports__; | ||
/******/ })() | ||
; | ||
}); | ||
//# sourceMappingURL=index.js.map |
{ | ||
"name": "parsegraph-shader", | ||
"version": "1.5.9", | ||
"version": "1.5.10-dev", | ||
"description": "shader", | ||
@@ -53,4 +53,4 @@ "main": "dist/src/index.js", | ||
"peerDependencies": { | ||
"parsegraph-checkglerror": "^1.5.6" | ||
"parsegraph-checkglerror": "^1.5.7" | ||
} | ||
} |
Sorry, the diff of this file is not supported yet
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
No v1
QualityPackage is not semver >=1. This means it is not stable and does not support ^ ranges.
Found 1 instance in 1 package
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
Minified code
QualityThis package contains minified code. This may be harmless in some cases where minified code is included in packaged libraries, however packages on npm should not minify code.
Found 1 instance in 1 package
51908
11
517