@luma.gl/shadertools
Advanced tools
Comparing version 7.3.0-beta.1 to 7.3.0-beta.2
@@ -20,3 +20,4 @@ import { VERTEX_SHADER, FRAGMENT_SHADER } from './constants'; | ||
const FRAGMENT_SHADER_PROLOGUE = "precision highp float;\n\n"; | ||
export function createShaderHook(hook, opts = {}) { | ||
export function createShaderHook(hook) { | ||
let opts = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {}; | ||
hook = hook.trim(); | ||
@@ -73,14 +74,15 @@ const [stage, signature] = hook.split(':'); | ||
function assembleShader(gl, { | ||
id, | ||
source, | ||
type, | ||
modules, | ||
defines = {}, | ||
hookFunctions = HOOK_FUNCTIONS, | ||
moduleInjections = MODULE_INJECTIONS, | ||
inject = {}, | ||
prologue = true, | ||
log | ||
}) { | ||
function assembleShader(gl, _ref) { | ||
let { | ||
id, | ||
source, | ||
type, | ||
modules, | ||
defines = {}, | ||
hookFunctions = HOOK_FUNCTIONS, | ||
moduleInjections = MODULE_INJECTIONS, | ||
inject = {}, | ||
prologue = true, | ||
log | ||
} = _ref; | ||
assert(typeof source === 'string', 'shader source must be a string'); | ||
@@ -211,13 +213,15 @@ | ||
function getShaderType({ | ||
type | ||
}) { | ||
function getShaderType(_ref2) { | ||
let { | ||
type | ||
} = _ref2; | ||
return "\n#define SHADER_TYPE_".concat(SHADER_TYPE[type].toUpperCase(), "\n"); | ||
} | ||
function getShaderName({ | ||
id, | ||
source, | ||
type | ||
}) { | ||
function getShaderName(_ref3) { | ||
let { | ||
id, | ||
source, | ||
type | ||
} = _ref3; | ||
const injectShaderName = id && typeof id === 'string' && source.indexOf('SHADER_NAME') === -1; | ||
@@ -227,3 +231,4 @@ return injectShaderName ? "\n#define SHADER_NAME ".concat(id, "_").concat(SHADER_TYPE[type], "\n\n") : ''; | ||
function getApplicationDefines(defines = {}) { | ||
function getApplicationDefines() { | ||
let defines = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {}; | ||
let count = 0; | ||
@@ -230,0 +235,0 @@ let sourceText = ''; |
@@ -9,5 +9,6 @@ import ShaderModuleRegistry from './shader-module-registry'; | ||
} | ||
export function registerShaderModules(shaderModuleList, { | ||
ignoreMultipleRegistrations = false | ||
} = {}) { | ||
export function registerShaderModules(shaderModuleList) { | ||
let { | ||
ignoreMultipleRegistrations = false | ||
} = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {}; | ||
shaderModuleRegistry.registerShaderModules(shaderModuleList, { | ||
@@ -38,8 +39,10 @@ ignoreMultipleRegistrations | ||
function getDependencyGraph({ | ||
modules, | ||
level, | ||
moduleMap, | ||
moduleDepth | ||
}) { | ||
function getDependencyGraph(_ref) { | ||
let { | ||
modules, | ||
level, | ||
moduleMap, | ||
moduleDepth | ||
} = _ref; | ||
if (level >= 5) { | ||
@@ -46,0 +49,0 @@ throw new Error('Possible loop in shader dependency graph'); |
@@ -17,5 +17,7 @@ import ShaderModule from './shader-module'; | ||
registerShaderModules(shaderModuleList, { | ||
ignoreMultipleRegistrations = false | ||
} = {}) { | ||
registerShaderModules(shaderModuleList) { | ||
let { | ||
ignoreMultipleRegistrations = false | ||
} = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {}; | ||
for (const shaderModule of shaderModuleList) { | ||
@@ -48,3 +50,5 @@ this._registerShaderModule(shaderModule, ignoreMultipleRegistrations); | ||
_registerShaderModule(module, ignoreMultipleRegistrations = false) { | ||
_registerShaderModule(module) { | ||
let ignoreMultipleRegistrations = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false; | ||
if (module instanceof ShaderModule) { | ||
@@ -51,0 +55,0 @@ return module; |
@@ -7,14 +7,15 @@ import transpileShader from './transpile-shader'; | ||
export default class ShaderModule { | ||
constructor({ | ||
name, | ||
vs, | ||
fs, | ||
dependencies = [], | ||
uniforms, | ||
getUniforms, | ||
deprecations = [], | ||
defines = {}, | ||
vertexShader, | ||
fragmentShader | ||
}) { | ||
constructor(_ref) { | ||
let { | ||
name, | ||
vs, | ||
fs, | ||
dependencies = [], | ||
uniforms, | ||
getUniforms, | ||
deprecations = [], | ||
defines = {}, | ||
vertexShader, | ||
fragmentShader | ||
} = _ref; | ||
assert(typeof name === 'string'); | ||
@@ -95,3 +96,4 @@ this.name = name; | ||
_defaultGetUniforms(opts = {}) { | ||
_defaultGetUniforms() { | ||
let opts = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {}; | ||
const uniforms = {}; | ||
@@ -98,0 +100,0 @@ const propTypes = this.uniforms; |
@@ -6,3 +6,4 @@ const DEFAULT_MODULE_OPTIONS = { | ||
function getUniforms(opts = DEFAULT_MODULE_OPTIONS) { | ||
function getUniforms() { | ||
let opts = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : DEFAULT_MODULE_OPTIONS; | ||
const uniforms = {}; | ||
@@ -9,0 +10,0 @@ |
@@ -7,3 +7,4 @@ import project from '../project/project'; | ||
function getUniforms(opts = DEFAULT_MODULE_OPTIONS) { | ||
function getUniforms() { | ||
let opts = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : DEFAULT_MODULE_OPTIONS; | ||
const uniforms = {}; | ||
@@ -10,0 +11,0 @@ |
@@ -1,7 +0,8 @@ | ||
function getUniforms({ | ||
fogEnable = false, | ||
fogColor = [0.5, 0.5, 0.5], | ||
fogNear = 1, | ||
fogFar = 100 | ||
} = {}) { | ||
function getUniforms() { | ||
let { | ||
fogEnable = false, | ||
fogColor = [0.5, 0.5, 0.5], | ||
fogNear = 1, | ||
fogFar = 100 | ||
} = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {}; | ||
return { | ||
@@ -8,0 +9,0 @@ fog_uEnable: fogEnable, |
@@ -1,2 +0,4 @@ | ||
export function fp64ify(a, out = [], startIndex = 0) { | ||
export function fp64ify(a) { | ||
let out = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : []; | ||
let startIndex = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : 0; | ||
const hiPart = Math.fround(a); | ||
@@ -3,0 +5,0 @@ const loPart = a - hiPart; |
@@ -11,3 +11,4 @@ import { Buffer, Program, assembleShaders, registerShaderModules, fp64 } from '@luma.gl/core'; | ||
function getFloat64(upper = 256) { | ||
function getFloat64() { | ||
let upper = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 256; | ||
return Math.random() * Math.pow(2.0, (Math.random() - 0.5) * upper); | ||
@@ -40,8 +41,9 @@ } | ||
function setupFloatTest(gl, { | ||
glslFunc, | ||
binary = false, | ||
limit = 256, | ||
op | ||
}) { | ||
function setupFloatTest(gl, _ref) { | ||
let { | ||
glslFunc, | ||
binary = false, | ||
limit = 256, | ||
op | ||
} = _ref; | ||
const a = getFloat64(limit); | ||
@@ -83,9 +85,11 @@ const b = getFloat64(limit); | ||
const EPSILON = 1e-14; | ||
export function testcase(gl, { | ||
glslFunc, | ||
binary, | ||
op, | ||
limit = 256, | ||
t | ||
}) { | ||
export function testcase(gl, _ref2) { | ||
let { | ||
glslFunc, | ||
binary, | ||
op, | ||
limit = 256, | ||
t | ||
} = _ref2; | ||
for (let idx0 = 0; idx0 < ITERATIONS; idx0++) { | ||
@@ -92,0 +96,0 @@ const { |
@@ -13,14 +13,16 @@ import lightingShader from './lights.glsl'; | ||
function convertColor({ | ||
color = [0, 0, 0], | ||
intensity = 1.0 | ||
} = {}) { | ||
function convertColor() { | ||
let { | ||
color = [0, 0, 0], | ||
intensity = 1.0 | ||
} = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {}; | ||
return color.map(component => component * intensity / 255.0); | ||
} | ||
function getLightSourceUniforms({ | ||
ambientLight, | ||
pointLights = [], | ||
directionalLights = [] | ||
}) { | ||
function getLightSourceUniforms(_ref) { | ||
let { | ||
ambientLight, | ||
pointLights = [], | ||
directionalLights = [] | ||
} = _ref; | ||
const lightSourceUniforms = {}; | ||
@@ -48,3 +50,5 @@ | ||
function getUniforms(opts = INITIAL_MODULE_OPTIONS) { | ||
function getUniforms() { | ||
let opts = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : INITIAL_MODULE_OPTIONS; | ||
if ('lightSources' in opts) { | ||
@@ -51,0 +55,0 @@ const { |
@@ -32,3 +32,5 @@ import lights from '../lights/lights'; | ||
function getUniforms(opts = INITIAL_MODULE_OPTIONS) { | ||
function getUniforms() { | ||
let opts = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : INITIAL_MODULE_OPTIONS; | ||
if (!('material' in opts)) { | ||
@@ -35,0 +37,0 @@ return {}; |
@@ -9,3 +9,4 @@ const DEFAULT_HIGHLIGHT_COLOR = new Uint8Array([0, 255, 255, 255]); | ||
function getUniforms(opts = DEFAULT_MODULE_OPTIONS) { | ||
function getUniforms() { | ||
let opts = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : DEFAULT_MODULE_OPTIONS; | ||
const uniforms = {}; | ||
@@ -12,0 +13,0 @@ |
@@ -10,3 +10,5 @@ import { Matrix4 } from 'math.gl'; | ||
function getUniforms(opts = DEFAULT_MODULE_OPTIONS, prevUniforms = {}) { | ||
function getUniforms() { | ||
let opts = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : DEFAULT_MODULE_OPTIONS; | ||
let prevUniforms = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {}; | ||
const uniforms = {}; | ||
@@ -13,0 +15,0 @@ |
@@ -1,2 +0,3 @@ | ||
export default function isOldIE(opts = {}) { | ||
export default function isOldIE() { | ||
let opts = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {}; | ||
const navigator = typeof window !== 'undefined' ? window.navigator || {} : {}; | ||
@@ -3,0 +4,0 @@ const userAgent = opts.userAgent || navigator.userAgent || ''; |
@@ -21,8 +21,10 @@ import { assert } from '../utils'; | ||
} | ||
export function getPassthroughFS({ | ||
version = 100, | ||
input, | ||
inputType, | ||
output | ||
} = {}) { | ||
export function getPassthroughFS() { | ||
let { | ||
version = 100, | ||
input, | ||
inputType, | ||
output | ||
} = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {}; | ||
if (!input) { | ||
@@ -29,0 +31,0 @@ if (version === 300) { |
@@ -55,3 +55,4 @@ import isOldIE from './is-old-ie'; | ||
const compiledGlslExtensions = {}; | ||
export function canCompileGLGSExtension(gl, cap, opts = {}) { | ||
export function canCompileGLGSExtension(gl, cap) { | ||
let opts = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {}; | ||
const feature = WEBGL_FEATURES[cap]; | ||
@@ -58,0 +59,0 @@ assert(feature, cap); |
{ | ||
"name": "@luma.gl/shadertools", | ||
"version": "7.3.0-beta.1", | ||
"version": "7.3.0-beta.2", | ||
"description": "Shader module system for luma.gl", | ||
@@ -42,3 +42,3 @@ "license": "MIT", | ||
}, | ||
"gitHead": "f04b050a0994cac705e905976fb41a419eb86f79" | ||
"gitHead": "f58d82d7793207d8d6c35e8e5a5af915ffcf2bbb" | ||
} |
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
1529225
21847