@luma.gl/shadertools
Advanced tools
Comparing version 7.3.0-alpha.5 to 7.3.0-alpha.6
@@ -16,2 +16,3 @@ "use strict"; | ||
createModuleInjection: true, | ||
resetGlobalShaderHooks: true, | ||
combineInjects: true, | ||
@@ -61,2 +62,8 @@ normalizeShaderModule: true, | ||
}); | ||
Object.defineProperty(exports, "resetGlobalShaderHooks", { | ||
enumerable: true, | ||
get: function get() { | ||
return _assembleShaders.resetGlobalShaderHooks; | ||
} | ||
}); | ||
Object.defineProperty(exports, "combineInjects", { | ||
@@ -63,0 +70,0 @@ enumerable: true, |
@@ -12,2 +12,3 @@ "use strict"; | ||
exports.createModuleInjection = createModuleInjection; | ||
exports.resetGlobalShaderHooks = resetGlobalShaderHooks; | ||
exports.assembleShaders = assembleShaders; | ||
@@ -67,2 +68,9 @@ | ||
function resetGlobalShaderHooks() { | ||
HOOK_FUNCTIONS[_constants.VERTEX_SHADER] = {}; | ||
HOOK_FUNCTIONS[_constants.FRAGMENT_SHADER] = {}; | ||
MODULE_INJECTIONS[_constants.VERTEX_SHADER] = {}; | ||
MODULE_INJECTIONS[_constants.FRAGMENT_SHADER] = {}; | ||
} | ||
function assembleShaders(gl, opts) { | ||
@@ -106,2 +114,15 @@ var vs = opts.vs, | ||
(0, _utils.assert)(typeof source === 'string', 'shader source must be a string'); | ||
if (hookFunctions !== HOOK_FUNCTIONS) { | ||
var _hookFunctions; | ||
hookFunctions = (_hookFunctions = {}, (0, _defineProperty2["default"])(_hookFunctions, _constants.VERTEX_SHADER, Object.assign({}, HOOK_FUNCTIONS[_constants.VERTEX_SHADER], hookFunctions[_constants.VERTEX_SHADER])), (0, _defineProperty2["default"])(_hookFunctions, _constants.FRAGMENT_SHADER, Object.assign({}, HOOK_FUNCTIONS[_constants.FRAGMENT_SHADER], hookFunctions[_constants.FRAGMENT_SHADER])), _hookFunctions); | ||
} | ||
if (moduleInjections !== MODULE_INJECTIONS) { | ||
var _moduleInjections; | ||
moduleInjections = (_moduleInjections = {}, (0, _defineProperty2["default"])(_moduleInjections, _constants.VERTEX_SHADER, Object.assign({}, MODULE_INJECTIONS[_constants.VERTEX_SHADER], moduleInjections[_constants.VERTEX_SHADER])), (0, _defineProperty2["default"])(_moduleInjections, _constants.FRAGMENT_SHADER, Object.assign({}, MODULE_INJECTIONS[_constants.FRAGMENT_SHADER], moduleInjections[_constants.FRAGMENT_SHADER])), _moduleInjections); | ||
} | ||
var isVertex = type === _constants.VERTEX_SHADER; | ||
@@ -108,0 +129,0 @@ var sourceLines = source.split('\n'); |
import MODULAR_VS from './shaders/modular-vertex.glsl'; | ||
import MODULAR_FS from './shaders/modular-fragment.glsl'; | ||
export { registerShaderModules, setDefaultShaderModules, getDefaultShaderModules } from './lib/resolve-modules'; | ||
export { assembleShaders, createShaderHook, createModuleInjection } from './lib/assemble-shaders'; | ||
export { assembleShaders, createShaderHook, createModuleInjection, resetGlobalShaderHooks } from './lib/assemble-shaders'; | ||
export { combineInjects } from './lib/inject-shader'; | ||
@@ -6,0 +6,0 @@ export { normalizeShaderModule } from './lib/shader-module'; |
@@ -44,2 +44,8 @@ import { VERTEX_SHADER, FRAGMENT_SHADER } from './constants'; | ||
} | ||
export function resetGlobalShaderHooks() { | ||
HOOK_FUNCTIONS[VERTEX_SHADER] = {}; | ||
HOOK_FUNCTIONS[FRAGMENT_SHADER] = {}; | ||
MODULE_INJECTIONS[VERTEX_SHADER] = {}; | ||
MODULE_INJECTIONS[FRAGMENT_SHADER] = {}; | ||
} | ||
export function assembleShaders(gl, opts) { | ||
@@ -82,2 +88,17 @@ const { | ||
assert(typeof source === 'string', 'shader source must be a string'); | ||
if (hookFunctions !== HOOK_FUNCTIONS) { | ||
hookFunctions = { | ||
[VERTEX_SHADER]: Object.assign({}, HOOK_FUNCTIONS[VERTEX_SHADER], hookFunctions[VERTEX_SHADER]), | ||
[FRAGMENT_SHADER]: Object.assign({}, HOOK_FUNCTIONS[FRAGMENT_SHADER], hookFunctions[FRAGMENT_SHADER]) | ||
}; | ||
} | ||
if (moduleInjections !== MODULE_INJECTIONS) { | ||
moduleInjections = { | ||
[VERTEX_SHADER]: Object.assign({}, MODULE_INJECTIONS[VERTEX_SHADER], moduleInjections[VERTEX_SHADER]), | ||
[FRAGMENT_SHADER]: Object.assign({}, MODULE_INJECTIONS[FRAGMENT_SHADER], moduleInjections[FRAGMENT_SHADER]) | ||
}; | ||
} | ||
const isVertex = type === VERTEX_SHADER; | ||
@@ -84,0 +105,0 @@ const sourceLines = source.split('\n'); |
import MODULAR_VS from './shaders/modular-vertex.glsl'; | ||
import MODULAR_FS from './shaders/modular-fragment.glsl'; | ||
export { registerShaderModules, setDefaultShaderModules, getDefaultShaderModules } from './lib/resolve-modules'; | ||
export { assembleShaders, createShaderHook, createModuleInjection } from './lib/assemble-shaders'; | ||
export { assembleShaders, createShaderHook, createModuleInjection, resetGlobalShaderHooks } from './lib/assemble-shaders'; | ||
export { combineInjects } from './lib/inject-shader'; | ||
@@ -6,0 +6,0 @@ export { normalizeShaderModule } from './lib/shader-module'; |
@@ -44,2 +44,8 @@ import _slicedToArray from "@babel/runtime/helpers/esm/slicedToArray"; | ||
} | ||
export function resetGlobalShaderHooks() { | ||
HOOK_FUNCTIONS[VERTEX_SHADER] = {}; | ||
HOOK_FUNCTIONS[FRAGMENT_SHADER] = {}; | ||
MODULE_INJECTIONS[VERTEX_SHADER] = {}; | ||
MODULE_INJECTIONS[FRAGMENT_SHADER] = {}; | ||
} | ||
export function assembleShaders(gl, opts) { | ||
@@ -83,2 +89,15 @@ var vs = opts.vs, | ||
assert(typeof source === 'string', 'shader source must be a string'); | ||
if (hookFunctions !== HOOK_FUNCTIONS) { | ||
var _hookFunctions; | ||
hookFunctions = (_hookFunctions = {}, _defineProperty(_hookFunctions, VERTEX_SHADER, Object.assign({}, HOOK_FUNCTIONS[VERTEX_SHADER], hookFunctions[VERTEX_SHADER])), _defineProperty(_hookFunctions, FRAGMENT_SHADER, Object.assign({}, HOOK_FUNCTIONS[FRAGMENT_SHADER], hookFunctions[FRAGMENT_SHADER])), _hookFunctions); | ||
} | ||
if (moduleInjections !== MODULE_INJECTIONS) { | ||
var _moduleInjections; | ||
moduleInjections = (_moduleInjections = {}, _defineProperty(_moduleInjections, VERTEX_SHADER, Object.assign({}, MODULE_INJECTIONS[VERTEX_SHADER], moduleInjections[VERTEX_SHADER])), _defineProperty(_moduleInjections, FRAGMENT_SHADER, Object.assign({}, MODULE_INJECTIONS[FRAGMENT_SHADER], moduleInjections[FRAGMENT_SHADER])), _moduleInjections); | ||
} | ||
var isVertex = type === VERTEX_SHADER; | ||
@@ -85,0 +104,0 @@ var sourceLines = source.split('\n'); |
{ | ||
"name": "@luma.gl/shadertools", | ||
"version": "7.3.0-alpha.5", | ||
"version": "7.3.0-alpha.6", | ||
"description": "Shader module system for luma.gl", | ||
@@ -42,3 +42,3 @@ "license": "MIT", | ||
}, | ||
"gitHead": "516debe2cc98a49aced52de925d222487b6ae9bc" | ||
"gitHead": "6a3d027967da08ee15109d2723374279d36009d0" | ||
} |
@@ -15,3 +15,8 @@ // shadertools exports | ||
} from './lib/resolve-modules'; | ||
export {assembleShaders, createShaderHook, createModuleInjection} from './lib/assemble-shaders'; | ||
export { | ||
assembleShaders, | ||
createShaderHook, | ||
createModuleInjection, | ||
resetGlobalShaderHooks | ||
} from './lib/assemble-shaders'; | ||
@@ -18,0 +23,0 @@ // HELPERS |
@@ -54,2 +54,11 @@ import {VERTEX_SHADER, FRAGMENT_SHADER} from './constants'; | ||
// Helpful for tests | ||
export function resetGlobalShaderHooks() { | ||
HOOK_FUNCTIONS[VERTEX_SHADER] = {}; | ||
HOOK_FUNCTIONS[FRAGMENT_SHADER] = {}; | ||
MODULE_INJECTIONS[VERTEX_SHADER] = {}; | ||
MODULE_INJECTIONS[FRAGMENT_SHADER] = {}; | ||
} | ||
// Inject a list of modules | ||
@@ -87,2 +96,33 @@ export function assembleShaders(gl, opts) { | ||
// TODO(Tarek): Supporting global hooks, remove when they're removed. | ||
if (hookFunctions !== HOOK_FUNCTIONS) { | ||
hookFunctions = { | ||
[VERTEX_SHADER]: Object.assign( | ||
{}, | ||
HOOK_FUNCTIONS[VERTEX_SHADER], | ||
hookFunctions[VERTEX_SHADER] | ||
), | ||
[FRAGMENT_SHADER]: Object.assign( | ||
{}, | ||
HOOK_FUNCTIONS[FRAGMENT_SHADER], | ||
hookFunctions[FRAGMENT_SHADER] | ||
) | ||
}; | ||
} | ||
if (moduleInjections !== MODULE_INJECTIONS) { | ||
moduleInjections = { | ||
[VERTEX_SHADER]: Object.assign( | ||
{}, | ||
MODULE_INJECTIONS[VERTEX_SHADER], | ||
moduleInjections[VERTEX_SHADER] | ||
), | ||
[FRAGMENT_SHADER]: Object.assign( | ||
{}, | ||
MODULE_INJECTIONS[FRAGMENT_SHADER], | ||
moduleInjections[FRAGMENT_SHADER] | ||
) | ||
}; | ||
} | ||
const isVertex = type === VERTEX_SHADER; | ||
@@ -89,0 +129,0 @@ |
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
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
1504259
21131