@luma.gl/webgl 8.5.15 → 8.5.16
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/dist.js +732 -848
- package/dist/dist.min.js +1 -1
- package/dist/es5/bundle.js.map +1 -1
- package/dist/es5/classes/accessor.js +31 -33
- package/dist/es5/classes/accessor.js.map +1 -1
- package/dist/es5/classes/buffer.js +24 -26
- package/dist/es5/classes/buffer.js.map +1 -1
- package/dist/es5/classes/clear.js.map +1 -1
- package/dist/es5/classes/copy-and-blit.js +3 -3
- package/dist/es5/classes/copy-and-blit.js.map +1 -1
- package/dist/es5/classes/framebuffer.js +70 -72
- package/dist/es5/classes/framebuffer.js.map +1 -1
- package/dist/es5/classes/program-configuration.js.map +1 -1
- package/dist/es5/classes/program.js +11 -13
- package/dist/es5/classes/program.js.map +1 -1
- package/dist/es5/classes/query.js +47 -49
- package/dist/es5/classes/query.js.map +1 -1
- package/dist/es5/classes/renderbuffer-formats.js.map +1 -1
- package/dist/es5/classes/renderbuffer.js +37 -39
- package/dist/es5/classes/renderbuffer.js.map +1 -1
- package/dist/es5/classes/resource.js +13 -15
- package/dist/es5/classes/resource.js.map +1 -1
- package/dist/es5/classes/shader.js +38 -44
- package/dist/es5/classes/shader.js.map +1 -1
- package/dist/es5/classes/texture-2d.js +16 -17
- package/dist/es5/classes/texture-2d.js.map +1 -1
- package/dist/es5/classes/texture-3d.js +15 -17
- package/dist/es5/classes/texture-3d.js.map +1 -1
- package/dist/es5/classes/texture-cube.js +10 -12
- package/dist/es5/classes/texture-cube.js.map +1 -1
- package/dist/es5/classes/texture-formats.js +1 -1
- package/dist/es5/classes/texture-formats.js.map +1 -1
- package/dist/es5/classes/texture.js +24 -26
- package/dist/es5/classes/texture.js.map +1 -1
- package/dist/es5/classes/transform-feedback.js +16 -22
- package/dist/es5/classes/transform-feedback.js.map +1 -1
- package/dist/es5/classes/uniform-buffer-layout.js.map +1 -1
- package/dist/es5/classes/uniforms.js +2 -2
- package/dist/es5/classes/uniforms.js.map +1 -1
- package/dist/es5/classes/vertex-array-object.js +69 -71
- package/dist/es5/classes/vertex-array-object.js.map +1 -1
- package/dist/es5/classes/vertex-array.js.map +1 -1
- package/dist/es5/debug/debug-program-configuration.js +1 -1
- package/dist/es5/debug/debug-program-configuration.js.map +1 -1
- package/dist/es5/debug/debug-uniforms.js +1 -1
- package/dist/es5/debug/debug-uniforms.js.map +1 -1
- package/dist/es5/debug/debug-vertex-array.js.map +1 -1
- package/dist/es5/features/check-glsl-extension.js.map +1 -1
- package/dist/es5/features/check-old-ie.js.map +1 -1
- package/dist/es5/features/features.js +2 -2
- package/dist/es5/features/features.js.map +1 -1
- package/dist/es5/features/index.js +16 -16
- package/dist/es5/features/index.js.map +1 -1
- package/dist/es5/features/limits.js +1 -1
- package/dist/es5/features/limits.js.map +1 -1
- package/dist/es5/features/webgl-features-table.js.map +1 -1
- package/dist/es5/features/webgl-limits-table.js.map +1 -1
- package/dist/es5/glsl-utils/format-glsl-error.js.map +1 -1
- package/dist/es5/glsl-utils/get-shader-name.js.map +1 -1
- package/dist/es5/glsl-utils/get-shader-type-name.js.map +1 -1
- package/dist/es5/glsl-utils/get-shader-version.js.map +1 -1
- package/dist/es5/glsl-utils/index.js +11 -7
- package/dist/es5/glsl-utils/index.js.map +1 -1
- package/dist/es5/index.js +104 -104
- package/dist/es5/index.js.map +1 -1
- package/dist/es5/init.d.ts +1 -1
- package/dist/es5/init.js +4 -4
- package/dist/es5/init.js.map +1 -1
- package/dist/es5/utils/array-utils-flat.js +2 -2
- package/dist/es5/utils/array-utils-flat.js.map +1 -1
- package/dist/es5/utils/assert.js.map +1 -1
- package/dist/es5/utils/check-props.js.map +1 -1
- package/dist/es5/utils/format-value.js.map +1 -1
- package/dist/es5/utils/is-old-ie.js.map +1 -1
- package/dist/es5/utils/load-file.js +1 -1
- package/dist/es5/utils/load-file.js.map +1 -1
- package/dist/es5/utils/stub-methods.js.map +1 -1
- package/dist/es5/utils/utils.js +2 -2
- package/dist/es5/utils/utils.js.map +1 -1
- package/dist/es5/webgl-utils/attribute-utils.js +3 -3
- package/dist/es5/webgl-utils/attribute-utils.js.map +1 -1
- package/dist/es5/webgl-utils/constants-to-keys.js +1 -1
- package/dist/es5/webgl-utils/constants-to-keys.js.map +1 -1
- package/dist/es5/webgl-utils/format-utils.js.map +1 -1
- package/dist/es5/webgl-utils/get-error.js +1 -1
- package/dist/es5/webgl-utils/get-error.js.map +1 -1
- package/dist/es5/webgl-utils/request-animation-frame.js +1 -1
- package/dist/es5/webgl-utils/request-animation-frame.js.map +1 -1
- package/dist/es5/webgl-utils/texture-utils.js.map +1 -1
- package/dist/es5/webgl-utils/typed-array-utils.js +1 -1
- package/dist/es5/webgl-utils/typed-array-utils.js.map +1 -1
- package/dist/esm/bundle.js.map +1 -1
- package/dist/esm/classes/accessor.js +12 -3
- package/dist/esm/classes/accessor.js.map +1 -1
- package/dist/esm/classes/buffer.js +41 -28
- package/dist/esm/classes/buffer.js.map +1 -1
- package/dist/esm/classes/clear.js +14 -12
- package/dist/esm/classes/clear.js.map +1 -1
- package/dist/esm/classes/copy-and-blit.js +27 -21
- package/dist/esm/classes/copy-and-blit.js.map +1 -1
- package/dist/esm/classes/framebuffer.js +89 -64
- package/dist/esm/classes/framebuffer.js.map +1 -1
- package/dist/esm/classes/program-configuration.js.map +1 -1
- package/dist/esm/classes/program.js +40 -32
- package/dist/esm/classes/program.js.map +1 -1
- package/dist/esm/classes/query.js +11 -6
- package/dist/esm/classes/query.js.map +1 -1
- package/dist/esm/classes/renderbuffer-formats.js.map +1 -1
- package/dist/esm/classes/renderbuffer.js +25 -19
- package/dist/esm/classes/renderbuffer.js.map +1 -1
- package/dist/esm/classes/resource.js +34 -19
- package/dist/esm/classes/resource.js.map +1 -1
- package/dist/esm/classes/shader.js +13 -10
- package/dist/esm/classes/shader.js.map +1 -1
- package/dist/esm/classes/texture-2d.js +2 -1
- package/dist/esm/classes/texture-2d.js.map +1 -1
- package/dist/esm/classes/texture-3d.js +17 -14
- package/dist/esm/classes/texture-3d.js.map +1 -1
- package/dist/esm/classes/texture-cube.js +23 -19
- package/dist/esm/classes/texture-cube.js.map +1 -1
- package/dist/esm/classes/texture-formats.js.map +1 -1
- package/dist/esm/classes/texture.js +47 -35
- package/dist/esm/classes/texture.js.map +1 -1
- package/dist/esm/classes/transform-feedback.js +12 -6
- package/dist/esm/classes/transform-feedback.js.map +1 -1
- package/dist/esm/classes/uniform-buffer-layout.js.map +1 -1
- package/dist/esm/classes/uniforms.js +6 -6
- package/dist/esm/classes/uniforms.js.map +1 -1
- package/dist/esm/classes/vertex-array-object.js +17 -9
- package/dist/esm/classes/vertex-array-object.js.map +1 -1
- package/dist/esm/classes/vertex-array.js +17 -7
- package/dist/esm/classes/vertex-array.js.map +1 -1
- package/dist/esm/debug/debug-program-configuration.js +4 -4
- package/dist/esm/debug/debug-program-configuration.js.map +1 -1
- package/dist/esm/debug/debug-uniforms.js +16 -14
- package/dist/esm/debug/debug-uniforms.js.map +1 -1
- package/dist/esm/debug/debug-vertex-array.js +16 -14
- package/dist/esm/debug/debug-vertex-array.js.map +1 -1
- package/dist/esm/features/check-glsl-extension.js +3 -2
- package/dist/esm/features/check-glsl-extension.js.map +1 -1
- package/dist/esm/features/check-old-ie.js +2 -1
- package/dist/esm/features/check-old-ie.js.map +1 -1
- package/dist/esm/features/features.js +1 -1
- package/dist/esm/features/features.js.map +1 -1
- package/dist/esm/features/index.js.map +1 -1
- package/dist/esm/features/limits.js.map +1 -1
- package/dist/esm/features/webgl-features-table.js +1 -1
- package/dist/esm/features/webgl-features-table.js.map +1 -1
- package/dist/esm/features/webgl-limits-table.js.map +1 -1
- package/dist/esm/glsl-utils/format-glsl-error.js +9 -7
- package/dist/esm/glsl-utils/format-glsl-error.js.map +1 -1
- package/dist/esm/glsl-utils/get-shader-name.js +2 -1
- package/dist/esm/glsl-utils/get-shader-name.js.map +1 -1
- package/dist/esm/glsl-utils/get-shader-type-name.js.map +1 -1
- package/dist/esm/glsl-utils/get-shader-version.js.map +1 -1
- package/dist/esm/glsl-utils/index.js.map +1 -1
- package/dist/esm/index.js.map +1 -1
- package/dist/esm/init.d.ts +1 -1
- package/dist/esm/init.js +4 -4
- package/dist/esm/init.js.map +1 -1
- package/dist/esm/utils/array-utils-flat.js +7 -6
- package/dist/esm/utils/array-utils-flat.js.map +1 -1
- package/dist/esm/utils/assert.js.map +1 -1
- package/dist/esm/utils/check-props.js +4 -4
- package/dist/esm/utils/check-props.js.map +1 -1
- package/dist/esm/utils/format-value.js +4 -3
- package/dist/esm/utils/format-value.js.map +1 -1
- package/dist/esm/utils/is-old-ie.js +2 -1
- package/dist/esm/utils/is-old-ie.js.map +1 -1
- package/dist/esm/utils/load-file.js +3 -2
- package/dist/esm/utils/load-file.js.map +1 -1
- package/dist/esm/utils/stub-methods.js +2 -3
- package/dist/esm/utils/stub-methods.js.map +1 -1
- package/dist/esm/utils/utils.js +3 -2
- package/dist/esm/utils/utils.js.map +1 -1
- package/dist/esm/webgl-utils/attribute-utils.js +11 -8
- package/dist/esm/webgl-utils/attribute-utils.js.map +1 -1
- package/dist/esm/webgl-utils/constants-to-keys.js +3 -3
- package/dist/esm/webgl-utils/constants-to-keys.js.map +1 -1
- package/dist/esm/webgl-utils/format-utils.js.map +1 -1
- package/dist/esm/webgl-utils/get-error.js +1 -1
- package/dist/esm/webgl-utils/get-error.js.map +1 -1
- package/dist/esm/webgl-utils/request-animation-frame.js.map +1 -1
- package/dist/esm/webgl-utils/texture-utils.js +1 -1
- package/dist/esm/webgl-utils/texture-utils.js.map +1 -1
- package/dist/esm/webgl-utils/typed-array-utils.js +19 -15
- package/dist/esm/webgl-utils/typed-array-utils.js.map +1 -1
- package/package.json +5 -5
- package/src/classes/framebuffer.js +1 -0
- package/src/classes/transform-feedback.js +1 -1
- package/src/classes/vertex-array-object.js +1 -1
- package/src/init.d.ts +1 -1
- package/src/init.js +1 -1
- package/src/webgl-utils/texture-utils.js +2 -0
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/classes/uniforms.js"],"names":["UNIFORM_SETTERS","getArraySetter","bind","toFloatArray","setVectorUniform","toIntArray","setMatrixUniform","getSamplerSetter","toUIntArray","FLOAT_ARRAY","INT_ARRAY","UINT_ARRAY","array1","toTypedArray","value","uniformLength","Type","cache","Number","isFinite","length","log","warn","result","i","Float32Array","Int32Array","Uint32Array","getUniformSetter","gl","location","info","setter","type","Error","parseUniformName","name","isArray","UNIFORM_NAME_REGEXP","matches","match","Boolean","checkUniformValues","uniforms","source","uniformMap","uniformName","shouldCheck","checkUniformValue","console","error","Array","ArrayBuffer","isView","checkUniformArray","Texture","Renderbuffer","Framebuffer","texture","copyUniform","key","dest","len","slice","checkLength","Math","min","update","uniform1i","functionName","toArray","size","uniformSetter","cacheLength","arrayValue","set"],"mappings":";;;;;;;;;;;;;;AAGA;;AAEA;;AACA;;AACA;;AACA;;;;AAEA,IAAMA,eAAe,iFAIPC,cAAc,CAACC,IAAf,CAAoB,IAApB,EAA0B,YAA1B,EAAwCC,YAAxC,EAAsD,CAAtD,EAAyDC,gBAAzD,CAJO,0DAKFH,cAAc,CAACC,IAAf,CAAoB,IAApB,EAA0B,YAA1B,EAAwCC,YAAxC,EAAsD,CAAtD,EAAyDC,gBAAzD,CALE,0DAMFH,cAAc,CAACC,IAAf,CAAoB,IAApB,EAA0B,YAA1B,EAAwCC,YAAxC,EAAsD,CAAtD,EAAyDC,gBAAzD,CANE,0DAOFH,cAAc,CAACC,IAAf,CAAoB,IAApB,EAA0B,YAA1B,EAAwCC,YAAxC,EAAsD,CAAtD,EAAyDC,gBAAzD,CAPE,yDASTH,cAAc,CAACC,IAAf,CAAoB,IAApB,EAA0B,YAA1B,EAAwCG,UAAxC,EAAoD,CAApD,EAAuDD,gBAAvD,CATS,0DAUJH,cAAc,CAACC,IAAf,CAAoB,IAApB,EAA0B,YAA1B,EAAwCG,UAAxC,EAAoD,CAApD,EAAuDD,gBAA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MAAP;AACD,GAvBD;AAwBD;;AAED,SAAS/D,gBAAT,CAA0ByB,EAA1B,EAA8BwC,YAA9B,EAA4CvC,QAA5C,EAAsDhB,KAAtD,EAA6D;AAC3De,EAAAA,EAAE,CAACwC,YAAD,CAAF,CAAiBvC,QAAjB,EAA2BhB,KAA3B;AACD;;AAED,SAASR,gBAAT,CAA0BuB,EAA1B,EAA8BwC,YAA9B,EAA4CvC,QAA5C,EAAsDhB,KAAtD,EAA6D;AAC3De,EAAAA,EAAE,CAACwC,YAAD,CAAF,CAAiBvC,QAAjB,EAA2B,KAA3B,EAAkChB,KAAlC;AACD","sourcesContent":["/** @typedef {import('./uniforms')} types */\n\nimport GL from '@luma.gl/constants';\nimport {log} from '@luma.gl/gltools';\n\nimport Framebuffer from './framebuffer';\nimport Renderbuffer from './renderbuffer';\nimport Texture from './texture';\nimport {assert} from '../utils/assert';\n\nconst UNIFORM_SETTERS = {\n // WEBGL1\n\n /* eslint-disable max-len */\n [GL.FLOAT]: getArraySetter.bind(null, 'uniform1fv', toFloatArray, 1, setVectorUniform),\n [GL.FLOAT_VEC2]: getArraySetter.bind(null, 'uniform2fv', toFloatArray, 2, setVectorUniform),\n [GL.FLOAT_VEC3]: getArraySetter.bind(null, 'uniform3fv', toFloatArray, 3, setVectorUniform),\n [GL.FLOAT_VEC4]: getArraySetter.bind(null, 'uniform4fv', toFloatArray, 4, setVectorUniform),\n\n [GL.INT]: getArraySetter.bind(null, 'uniform1iv', toIntArray, 1, setVectorUniform),\n [GL.INT_VEC2]: getArraySetter.bind(null, 'uniform2iv', toIntArray, 2, setVectorUniform),\n [GL.INT_VEC3]: getArraySetter.bind(null, 'uniform3iv', toIntArray, 3, setVectorUniform),\n [GL.INT_VEC4]: getArraySetter.bind(null, 'uniform4iv', toIntArray, 4, setVectorUniform),\n\n [GL.BOOL]: getArraySetter.bind(null, 'uniform1iv', toIntArray, 1, setVectorUniform),\n [GL.BOOL_VEC2]: getArraySetter.bind(null, 'uniform2iv', toIntArray, 2, setVectorUniform),\n [GL.BOOL_VEC3]: getArraySetter.bind(null, 'uniform3iv', toIntArray, 3, setVectorUniform),\n [GL.BOOL_VEC4]: getArraySetter.bind(null, 'uniform4iv', toIntArray, 4, setVectorUniform),\n\n // uniformMatrix(false): don't transpose the matrix\n [GL.FLOAT_MAT2]: getArraySetter.bind(null, 'uniformMatrix2fv', toFloatArray, 4, setMatrixUniform),\n [GL.FLOAT_MAT3]: getArraySetter.bind(null, 'uniformMatrix3fv', toFloatArray, 9, setMatrixUniform),\n [GL.FLOAT_MAT4]: getArraySetter.bind(\n null,\n 'uniformMatrix4fv',\n toFloatArray,\n 16,\n setMatrixUniform\n ),\n\n [GL.SAMPLER_2D]: getSamplerSetter,\n [GL.SAMPLER_CUBE]: getSamplerSetter,\n\n // WEBGL2 - unsigned integers, irregular matrices, additional texture samplers\n\n [GL.UNSIGNED_INT]: getArraySetter.bind(null, 'uniform1uiv', toUIntArray, 1, setVectorUniform),\n [GL.UNSIGNED_INT_VEC2]: getArraySetter.bind(\n null,\n 'uniform2uiv',\n toUIntArray,\n 2,\n setVectorUniform\n ),\n [GL.UNSIGNED_INT_VEC3]: getArraySetter.bind(\n null,\n 'uniform3uiv',\n toUIntArray,\n 3,\n setVectorUniform\n ),\n [GL.UNSIGNED_INT_VEC4]: getArraySetter.bind(\n null,\n 'uniform4uiv',\n toUIntArray,\n 4,\n setVectorUniform\n ),\n\n // uniformMatrix(false): don't transpose the matrix\n [GL.FLOAT_MAT2x3]: getArraySetter.bind(\n null,\n 'uniformMatrix2x3fv',\n toFloatArray,\n 6,\n setMatrixUniform\n ),\n [GL.FLOAT_MAT2x4]: getArraySetter.bind(\n null,\n 'uniformMatrix2x4fv',\n toFloatArray,\n 8,\n setMatrixUniform\n ),\n [GL.FLOAT_MAT3x2]: getArraySetter.bind(\n null,\n 'uniformMatrix3x2fv',\n toFloatArray,\n 6,\n setMatrixUniform\n ),\n [GL.FLOAT_MAT3x4]: getArraySetter.bind(\n null,\n 'uniformMatrix3x4fv',\n toFloatArray,\n 12,\n setMatrixUniform\n ),\n [GL.FLOAT_MAT4x2]: getArraySetter.bind(\n null,\n 'uniformMatrix4x2fv',\n toFloatArray,\n 8,\n setMatrixUniform\n ),\n [GL.FLOAT_MAT4x3]: getArraySetter.bind(\n null,\n 'uniformMatrix4x3fv',\n toFloatArray,\n 12,\n setMatrixUniform\n ),\n\n [GL.SAMPLER_2D]: getSamplerSetter,\n [GL.SAMPLER_CUBE]: getSamplerSetter,\n\n [GL.SAMPLER_3D]: getSamplerSetter,\n [GL.SAMPLER_2D_SHADOW]: getSamplerSetter,\n [GL.SAMPLER_2D_ARRAY]: getSamplerSetter,\n [GL.SAMPLER_2D_ARRAY_SHADOW]: getSamplerSetter,\n [GL.SAMPLER_CUBE_SHADOW]: getSamplerSetter,\n [GL.INT_SAMPLER_2D]: getSamplerSetter,\n [GL.INT_SAMPLER_3D]: getSamplerSetter,\n [GL.INT_SAMPLER_CUBE]: getSamplerSetter,\n [GL.INT_SAMPLER_2D_ARRAY]: getSamplerSetter,\n [GL.UNSIGNED_INT_SAMPLER_2D]: getSamplerSetter,\n [GL.UNSIGNED_INT_SAMPLER_3D]: getSamplerSetter,\n [GL.UNSIGNED_INT_SAMPLER_CUBE]: getSamplerSetter,\n [GL.UNSIGNED_INT_SAMPLER_2D_ARRAY]: getSamplerSetter\n /* eslint-enable max-len */\n};\n\n// Pre-allocated typed arrays for temporary conversion\nconst FLOAT_ARRAY = {};\nconst INT_ARRAY = {};\nconst UINT_ARRAY = {};\n\nconst array1 = [0];\n\n// Functions to ensure the type of uniform values\n// This is done because uniform*v functions\n// are extremely slow when consuming JS arrays directly.\nfunction toTypedArray(value, uniformLength, Type, cache) {\n // convert boolean uniforms to Number\n if (uniformLength === 1 && typeof value === 'boolean') {\n value = value ? 1 : 0;\n }\n if (Number.isFinite(value)) {\n array1[0] = value;\n value = array1;\n }\n const length = value.length;\n if (length % uniformLength) {\n log.warn(`Uniform size should be multiples of ${uniformLength}`, value)();\n }\n\n if (value instanceof Type) {\n return value;\n }\n let result = cache[length];\n if (!result) {\n result = new Type(length);\n cache[length] = result;\n }\n for (let i = 0; i < length; i++) {\n result[i] = value[i];\n }\n return result;\n}\n\nfunction toFloatArray(value, uniformLength) {\n return toTypedArray(value, uniformLength, Float32Array, FLOAT_ARRAY);\n}\n\nfunction toIntArray(value, uniformLength) {\n return toTypedArray(value, uniformLength, Int32Array, INT_ARRAY);\n}\n\nfunction toUIntArray(value, uniformLength) {\n return toTypedArray(value, uniformLength, Uint32Array, UINT_ARRAY);\n} // Returns a Magic Uniform Setter\n\n// PUBLIC API\n\n/** @type {types['getUniformSetter']} */ export function getUniformSetter(gl, location, info) {\n const setter = UNIFORM_SETTERS[info.type];\n if (!setter) {\n throw new Error(`Unknown GLSL uniform type ${info.type}`);\n }\n\n // NOTE(Tarek): This construction is the ensure\n // separate caches for all setters.\n return setter().bind(null, gl, location);\n}\n\n/** @type {types['parseUniformName']} */\nexport function parseUniformName(name) {\n // Shortcut to avoid redundant or bad matches\n if (name[name.length - 1] !== ']') {\n return {\n name,\n length: 1,\n isArray: false\n };\n }\n\n // if array name then clean the array brackets\n const UNIFORM_NAME_REGEXP = /([^[]*)(\\[[0-9]+\\])?/;\n const matches = name.match(UNIFORM_NAME_REGEXP);\n if (!matches || matches.length < 2) {\n throw new Error(`Failed to parse GLSL uniform name ${name}`);\n }\n\n return {\n name: matches[1],\n length: matches[2] || 1,\n isArray: Boolean(matches[2])\n };\n} // To facilitate early detection of e.g. undefined values in JavaScript\n\n// Basic checks of uniform values (with or without knowledge of program)\n\n/** @type {types['checkUniformValues']} */\nexport function checkUniformValues(uniforms, source, uniformMap) {\n for (const uniformName in uniforms) {\n const value = uniforms[uniformName];\n const shouldCheck = !uniformMap || Boolean(uniformMap[uniformName]);\n if (shouldCheck && !checkUniformValue(value)) {\n // Add space to source\n source = source ? `${source} ` : '';\n // Value could be unprintable so write the object on console\n console.error(`${source} Bad uniform ${uniformName}`, value); // eslint-disable-line\n /* eslint-enable no-console */\n throw new Error(`${source} Bad uniform ${uniformName}`);\n }\n }\n return true;\n}\n\n// TODO use type information during validation\nfunction checkUniformValue(value) {\n if (Array.isArray(value) || ArrayBuffer.isView(value)) {\n return checkUniformArray(value);\n }\n\n // Check if single value is a number\n if (isFinite(value)) {\n return true;\n } else if (value === true || value === false) {\n return true;\n } else if (value instanceof Texture) {\n return true;\n } else if (value instanceof Renderbuffer) {\n return true;\n } else if (value instanceof Framebuffer) {\n return Boolean(value.texture);\n }\n return false;\n}\n\n/** @type {types['copyUniform']} */\nexport function copyUniform(uniforms, key, value) {\n if (Array.isArray(value) || ArrayBuffer.isView(value)) {\n if (uniforms[key]) {\n const dest = uniforms[key];\n // @ts-ignore\n for (let i = 0, len = value.length; i < len; ++i) {\n dest[i] = value[i];\n }\n } else {\n // @ts-ignore\n uniforms[key] = value.slice();\n }\n } else {\n uniforms[key] = value;\n }\n}\n\n// HELPERS\n\nfunction checkUniformArray(value) {\n // Check that every element in array is a number, and at least 1 element\n if (value.length === 0) {\n return false;\n }\n\n const checkLength = Math.min(value.length, 16);\n\n for (let i = 0; i < checkLength; ++i) {\n if (!Number.isFinite(value[i])) {\n return false;\n }\n }\n\n return true;\n}\n\n// NOTE(Tarek): Setters maintain a cache\n// of the previously set value, and\n// avoid resetting it if it's the same.\nfunction getSamplerSetter() {\n let cache = null;\n return (gl, location, value) => {\n const update = cache !== value;\n if (update) {\n gl.uniform1i(location, value);\n cache = value;\n }\n\n return update;\n };\n}\n\nfunction getArraySetter(functionName, toArray, size, uniformSetter) {\n let cache = null;\n let cacheLength = null;\n return (gl, location, value) => {\n const arrayValue = toArray(value, size);\n const length = arrayValue.length;\n let update = false;\n if (cache === null) {\n cache = new Float32Array(length);\n cacheLength = length;\n update = true;\n } else {\n assert(cacheLength === length, 'Uniform length cannot change.');\n for (let i = 0; i < length; ++i) {\n if (arrayValue[i] !== cache[i]) {\n update = true;\n break;\n }\n }\n }\n if (update) {\n uniformSetter(gl, functionName, location, arrayValue);\n cache.set(arrayValue);\n }\n\n return update;\n };\n}\n\nfunction setVectorUniform(gl, functionName, location, value) {\n gl[functionName](location, value);\n}\n\nfunction setMatrixUniform(gl, functionName, location, value) {\n gl[functionName](location, false, value);\n}\n"],"file":"uniforms.js"}
|
|
1
|
+
{"version":3,"file":"uniforms.js","names":["UNIFORM_SETTERS","getArraySetter","bind","toFloatArray","setVectorUniform","toIntArray","setMatrixUniform","getSamplerSetter","toUIntArray","FLOAT_ARRAY","INT_ARRAY","UINT_ARRAY","array1","toTypedArray","value","uniformLength","Type","cache","Number","isFinite","length","log","warn","result","i","Float32Array","Int32Array","Uint32Array","getUniformSetter","gl","location","info","setter","type","Error","parseUniformName","name","isArray","UNIFORM_NAME_REGEXP","matches","match","Boolean","checkUniformValues","uniforms","source","uniformMap","uniformName","shouldCheck","checkUniformValue","console","error","Array","ArrayBuffer","isView","checkUniformArray","Texture","Renderbuffer","Framebuffer","texture","copyUniform","key","dest","len","slice","checkLength","Math","min","update","uniform1i","functionName","toArray","size","uniformSetter","cacheLength","arrayValue","assert","set"],"sources":["../../../src/classes/uniforms.js"],"sourcesContent":["/** @typedef {import('./uniforms')} types */\n\nimport GL from '@luma.gl/constants';\nimport {log} from '@luma.gl/gltools';\n\nimport Framebuffer from './framebuffer';\nimport Renderbuffer from './renderbuffer';\nimport Texture from './texture';\nimport {assert} from '../utils/assert';\n\nconst UNIFORM_SETTERS = {\n // WEBGL1\n\n /* eslint-disable max-len */\n [GL.FLOAT]: getArraySetter.bind(null, 'uniform1fv', toFloatArray, 1, setVectorUniform),\n [GL.FLOAT_VEC2]: getArraySetter.bind(null, 'uniform2fv', toFloatArray, 2, setVectorUniform),\n [GL.FLOAT_VEC3]: getArraySetter.bind(null, 'uniform3fv', toFloatArray, 3, setVectorUniform),\n [GL.FLOAT_VEC4]: getArraySetter.bind(null, 'uniform4fv', toFloatArray, 4, setVectorUniform),\n\n [GL.INT]: getArraySetter.bind(null, 'uniform1iv', toIntArray, 1, setVectorUniform),\n [GL.INT_VEC2]: getArraySetter.bind(null, 'uniform2iv', toIntArray, 2, setVectorUniform),\n [GL.INT_VEC3]: getArraySetter.bind(null, 'uniform3iv', toIntArray, 3, setVectorUniform),\n [GL.INT_VEC4]: getArraySetter.bind(null, 'uniform4iv', toIntArray, 4, setVectorUniform),\n\n [GL.BOOL]: getArraySetter.bind(null, 'uniform1iv', toIntArray, 1, setVectorUniform),\n [GL.BOOL_VEC2]: getArraySetter.bind(null, 'uniform2iv', toIntArray, 2, setVectorUniform),\n [GL.BOOL_VEC3]: getArraySetter.bind(null, 'uniform3iv', toIntArray, 3, setVectorUniform),\n [GL.BOOL_VEC4]: getArraySetter.bind(null, 'uniform4iv', toIntArray, 4, setVectorUniform),\n\n // uniformMatrix(false): don't transpose the matrix\n [GL.FLOAT_MAT2]: getArraySetter.bind(null, 'uniformMatrix2fv', toFloatArray, 4, setMatrixUniform),\n [GL.FLOAT_MAT3]: getArraySetter.bind(null, 'uniformMatrix3fv', toFloatArray, 9, setMatrixUniform),\n [GL.FLOAT_MAT4]: getArraySetter.bind(\n null,\n 'uniformMatrix4fv',\n toFloatArray,\n 16,\n setMatrixUniform\n ),\n\n [GL.SAMPLER_2D]: getSamplerSetter,\n [GL.SAMPLER_CUBE]: getSamplerSetter,\n\n // WEBGL2 - unsigned integers, irregular matrices, additional texture samplers\n\n [GL.UNSIGNED_INT]: getArraySetter.bind(null, 'uniform1uiv', toUIntArray, 1, setVectorUniform),\n [GL.UNSIGNED_INT_VEC2]: getArraySetter.bind(\n null,\n 'uniform2uiv',\n toUIntArray,\n 2,\n setVectorUniform\n ),\n [GL.UNSIGNED_INT_VEC3]: getArraySetter.bind(\n null,\n 'uniform3uiv',\n toUIntArray,\n 3,\n setVectorUniform\n ),\n [GL.UNSIGNED_INT_VEC4]: getArraySetter.bind(\n null,\n 'uniform4uiv',\n toUIntArray,\n 4,\n setVectorUniform\n ),\n\n // uniformMatrix(false): don't transpose the matrix\n [GL.FLOAT_MAT2x3]: getArraySetter.bind(\n null,\n 'uniformMatrix2x3fv',\n toFloatArray,\n 6,\n setMatrixUniform\n ),\n [GL.FLOAT_MAT2x4]: getArraySetter.bind(\n null,\n 'uniformMatrix2x4fv',\n toFloatArray,\n 8,\n setMatrixUniform\n ),\n [GL.FLOAT_MAT3x2]: getArraySetter.bind(\n null,\n 'uniformMatrix3x2fv',\n toFloatArray,\n 6,\n setMatrixUniform\n ),\n [GL.FLOAT_MAT3x4]: getArraySetter.bind(\n null,\n 'uniformMatrix3x4fv',\n toFloatArray,\n 12,\n setMatrixUniform\n ),\n [GL.FLOAT_MAT4x2]: getArraySetter.bind(\n null,\n 'uniformMatrix4x2fv',\n toFloatArray,\n 8,\n setMatrixUniform\n ),\n [GL.FLOAT_MAT4x3]: getArraySetter.bind(\n null,\n 'uniformMatrix4x3fv',\n toFloatArray,\n 12,\n setMatrixUniform\n ),\n\n [GL.SAMPLER_2D]: getSamplerSetter,\n [GL.SAMPLER_CUBE]: getSamplerSetter,\n\n [GL.SAMPLER_3D]: getSamplerSetter,\n [GL.SAMPLER_2D_SHADOW]: getSamplerSetter,\n [GL.SAMPLER_2D_ARRAY]: getSamplerSetter,\n [GL.SAMPLER_2D_ARRAY_SHADOW]: getSamplerSetter,\n [GL.SAMPLER_CUBE_SHADOW]: getSamplerSetter,\n [GL.INT_SAMPLER_2D]: getSamplerSetter,\n [GL.INT_SAMPLER_3D]: getSamplerSetter,\n [GL.INT_SAMPLER_CUBE]: getSamplerSetter,\n [GL.INT_SAMPLER_2D_ARRAY]: getSamplerSetter,\n [GL.UNSIGNED_INT_SAMPLER_2D]: getSamplerSetter,\n [GL.UNSIGNED_INT_SAMPLER_3D]: getSamplerSetter,\n [GL.UNSIGNED_INT_SAMPLER_CUBE]: getSamplerSetter,\n [GL.UNSIGNED_INT_SAMPLER_2D_ARRAY]: getSamplerSetter\n /* eslint-enable max-len */\n};\n\n// Pre-allocated typed arrays for temporary conversion\nconst FLOAT_ARRAY = {};\nconst INT_ARRAY = {};\nconst UINT_ARRAY = {};\n\nconst array1 = [0];\n\n// Functions to ensure the type of uniform values\n// This is done because uniform*v functions\n// are extremely slow when consuming JS arrays directly.\nfunction toTypedArray(value, uniformLength, Type, cache) {\n // convert boolean uniforms to Number\n if (uniformLength === 1 && typeof value === 'boolean') {\n value = value ? 1 : 0;\n }\n if (Number.isFinite(value)) {\n array1[0] = value;\n value = array1;\n }\n const length = value.length;\n if (length % uniformLength) {\n log.warn(`Uniform size should be multiples of ${uniformLength}`, value)();\n }\n\n if (value instanceof Type) {\n return value;\n }\n let result = cache[length];\n if (!result) {\n result = new Type(length);\n cache[length] = result;\n }\n for (let i = 0; i < length; i++) {\n result[i] = value[i];\n }\n return result;\n}\n\nfunction toFloatArray(value, uniformLength) {\n return toTypedArray(value, uniformLength, Float32Array, FLOAT_ARRAY);\n}\n\nfunction toIntArray(value, uniformLength) {\n return toTypedArray(value, uniformLength, Int32Array, INT_ARRAY);\n}\n\nfunction toUIntArray(value, uniformLength) {\n return toTypedArray(value, uniformLength, Uint32Array, UINT_ARRAY);\n} // Returns a Magic Uniform Setter\n\n// PUBLIC API\n\n/** @type {types['getUniformSetter']} */ export function getUniformSetter(gl, location, info) {\n const setter = UNIFORM_SETTERS[info.type];\n if (!setter) {\n throw new Error(`Unknown GLSL uniform type ${info.type}`);\n }\n\n // NOTE(Tarek): This construction is the ensure\n // separate caches for all setters.\n return setter().bind(null, gl, location);\n}\n\n/** @type {types['parseUniformName']} */\nexport function parseUniformName(name) {\n // Shortcut to avoid redundant or bad matches\n if (name[name.length - 1] !== ']') {\n return {\n name,\n length: 1,\n isArray: false\n };\n }\n\n // if array name then clean the array brackets\n const UNIFORM_NAME_REGEXP = /([^[]*)(\\[[0-9]+\\])?/;\n const matches = name.match(UNIFORM_NAME_REGEXP);\n if (!matches || matches.length < 2) {\n throw new Error(`Failed to parse GLSL uniform name ${name}`);\n }\n\n return {\n name: matches[1],\n length: matches[2] || 1,\n isArray: Boolean(matches[2])\n };\n} // To facilitate early detection of e.g. undefined values in JavaScript\n\n// Basic checks of uniform values (with or without knowledge of program)\n\n/** @type {types['checkUniformValues']} */\nexport function checkUniformValues(uniforms, source, uniformMap) {\n for (const uniformName in uniforms) {\n const value = uniforms[uniformName];\n const shouldCheck = !uniformMap || Boolean(uniformMap[uniformName]);\n if (shouldCheck && !checkUniformValue(value)) {\n // Add space to source\n source = source ? `${source} ` : '';\n // Value could be unprintable so write the object on console\n console.error(`${source} Bad uniform ${uniformName}`, value); // eslint-disable-line\n /* eslint-enable no-console */\n throw new Error(`${source} Bad uniform ${uniformName}`);\n }\n }\n return true;\n}\n\n// TODO use type information during validation\nfunction checkUniformValue(value) {\n if (Array.isArray(value) || ArrayBuffer.isView(value)) {\n return checkUniformArray(value);\n }\n\n // Check if single value is a number\n if (isFinite(value)) {\n return true;\n } else if (value === true || value === false) {\n return true;\n } else if (value instanceof Texture) {\n return true;\n } else if (value instanceof Renderbuffer) {\n return true;\n } else if (value instanceof Framebuffer) {\n return Boolean(value.texture);\n }\n return false;\n}\n\n/** @type {types['copyUniform']} */\nexport function copyUniform(uniforms, key, value) {\n if (Array.isArray(value) || ArrayBuffer.isView(value)) {\n if (uniforms[key]) {\n const dest = uniforms[key];\n // @ts-ignore\n for (let i = 0, len = value.length; i < len; ++i) {\n dest[i] = value[i];\n }\n } else {\n // @ts-ignore\n uniforms[key] = value.slice();\n }\n } else {\n uniforms[key] = value;\n }\n}\n\n// HELPERS\n\nfunction checkUniformArray(value) {\n // Check that every element in array is a number, and at least 1 element\n if (value.length === 0) {\n return false;\n }\n\n const checkLength = Math.min(value.length, 16);\n\n for (let i = 0; i < checkLength; ++i) {\n if (!Number.isFinite(value[i])) {\n return false;\n }\n }\n\n return true;\n}\n\n// NOTE(Tarek): Setters maintain a cache\n// of the previously set value, and\n// avoid resetting it if it's the same.\nfunction getSamplerSetter() {\n let cache = null;\n return (gl, location, value) => {\n const update = cache !== value;\n if (update) {\n gl.uniform1i(location, value);\n cache = value;\n }\n\n return update;\n };\n}\n\nfunction getArraySetter(functionName, toArray, size, uniformSetter) {\n let cache = null;\n let cacheLength = null;\n return (gl, location, value) => {\n const arrayValue = toArray(value, size);\n const length = arrayValue.length;\n let update = false;\n if (cache === null) {\n cache = new Float32Array(length);\n cacheLength = length;\n update = true;\n } else {\n assert(cacheLength === length, 'Uniform length cannot change.');\n for (let i = 0; i < length; ++i) {\n if (arrayValue[i] !== cache[i]) {\n update = true;\n break;\n }\n }\n }\n if (update) {\n uniformSetter(gl, functionName, location, arrayValue);\n cache.set(arrayValue);\n }\n\n return update;\n };\n}\n\nfunction setVectorUniform(gl, functionName, location, value) {\n gl[functionName](location, value);\n}\n\nfunction setMatrixUniform(gl, functionName, location, value) {\n gl[functionName](location, false, value);\n}\n"],"mappings":";;;;;;;;;;;;;;AAGA;;AAEA;;AACA;;AACA;;AACA;;;;AAEA,IAAMA,eAAe,iFAIPC,cAAc,CAACC,IAAf,CAAoB,IAApB,EAA0B,YAA1B,EAAwCC,YAAxC,EAAsD,CAAtD,EAAyDC,gBAAzD,CAJO,0DAKFH,cAAc,CAACC,IAAf,CAAoB,IAApB,EAA0B,YAA1B,EAAwCC,YAAxC,EAAsD,CAAtD,EAAyDC,gBAAzD,CALE,0DAMFH,cAAc,CAACC,IAAf,CAAoB,IAApB,EAA0B,YAA1B,EAAwCC,YAAxC,EAAsD,CAAtD,EAAyDC,gBAAzD,CANE,0DAOFH,cAAc,CAACC,IAAf,CAAoB,IAApB,EAA0B,YAA1B,EAAwCC,YAAxC,EAAsD,CAAtD,EAAyDC,gBAAzD,CAPE,yDASTH,cAAc,CAACC,IAAf,CAAoB,IAApB,EAA0B,YAA1B,EAAwCG,UAAxC,EAAoD,CAApD,EAAuDD,gBAAvD,CATS,0DAUJH,cAAc,CAACC,IAAf,CAAoB,IAApB,EAA0B,YAA1B,EAAwCG,UAAxC,EAAoD,CAApD,EAAuDD,gBAAvD,CAVI,0DAWJH,cAAc,CAACC,IAAf,CAAoB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gBAAT,CAA0BuB,EAA1B,EAA8BwC,YAA9B,EAA4CvC,QAA5C,EAAsDhB,KAAtD,EAA6D;EAC3De,EAAE,CAACwC,YAAD,CAAF,CAAiBvC,QAAjB,EAA2B,KAA3B,EAAkChB,KAAlC;AACD"}
|
|
@@ -9,12 +9,12 @@ exports.default = void 0;
|
|
|
9
9
|
|
|
10
10
|
var _classCallCheck2 = _interopRequireDefault(require("@babel/runtime/helpers/classCallCheck"));
|
|
11
11
|
|
|
12
|
+
var _createClass2 = _interopRequireDefault(require("@babel/runtime/helpers/createClass"));
|
|
13
|
+
|
|
12
14
|
var _assertThisInitialized2 = _interopRequireDefault(require("@babel/runtime/helpers/assertThisInitialized"));
|
|
13
15
|
|
|
14
16
|
var _get2 = _interopRequireDefault(require("@babel/runtime/helpers/get"));
|
|
15
17
|
|
|
16
|
-
var _createClass2 = _interopRequireDefault(require("@babel/runtime/helpers/createClass"));
|
|
17
|
-
|
|
18
18
|
var _inherits2 = _interopRequireDefault(require("@babel/runtime/helpers/inherits"));
|
|
19
19
|
|
|
20
20
|
var _possibleConstructorReturn2 = _interopRequireDefault(require("@babel/runtime/helpers/possibleConstructorReturn"));
|
|
@@ -31,80 +31,19 @@ var _arrayUtilsFlat = require("../utils/array-utils-flat");
|
|
|
31
31
|
|
|
32
32
|
var _assert = require("../utils/assert");
|
|
33
33
|
|
|
34
|
-
var
|
|
34
|
+
var _env = require("@probe.gl/env");
|
|
35
35
|
|
|
36
36
|
function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = (0, _getPrototypeOf2.default)(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = (0, _getPrototypeOf2.default)(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return (0, _possibleConstructorReturn2.default)(this, result); }; }
|
|
37
37
|
|
|
38
|
-
function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try {
|
|
38
|
+
function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); return true; } catch (e) { return false; } }
|
|
39
39
|
|
|
40
40
|
var ERR_ELEMENTS = 'elements must be GL.ELEMENT_ARRAY_BUFFER';
|
|
41
41
|
|
|
42
|
-
var VertexArrayObject = function (_Resource) {
|
|
42
|
+
var VertexArrayObject = function (_Resource, _Symbol$toStringTag) {
|
|
43
43
|
(0, _inherits2.default)(VertexArrayObject, _Resource);
|
|
44
44
|
|
|
45
45
|
var _super = _createSuper(VertexArrayObject);
|
|
46
46
|
|
|
47
|
-
(0, _createClass2.default)(VertexArrayObject, [{
|
|
48
|
-
key: Symbol.toStringTag,
|
|
49
|
-
get: function get() {
|
|
50
|
-
return 'VertexArrayObject';
|
|
51
|
-
}
|
|
52
|
-
}], [{
|
|
53
|
-
key: "isSupported",
|
|
54
|
-
value: function isSupported(gl) {
|
|
55
|
-
var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
|
|
56
|
-
|
|
57
|
-
if (options.constantAttributeZero) {
|
|
58
|
-
return (0, _gltools.isWebGL2)(gl) || (0, _probe.getBrowser)() === 'Chrome';
|
|
59
|
-
}
|
|
60
|
-
|
|
61
|
-
return true;
|
|
62
|
-
}
|
|
63
|
-
}, {
|
|
64
|
-
key: "getDefaultArray",
|
|
65
|
-
value: function getDefaultArray(gl) {
|
|
66
|
-
gl.luma = gl.luma || {};
|
|
67
|
-
|
|
68
|
-
if (!gl.luma.defaultVertexArray) {
|
|
69
|
-
gl.luma.defaultVertexArray = new VertexArrayObject(gl, {
|
|
70
|
-
handle: null,
|
|
71
|
-
isDefaultArray: true
|
|
72
|
-
});
|
|
73
|
-
}
|
|
74
|
-
|
|
75
|
-
return gl.luma.defaultVertexArray;
|
|
76
|
-
}
|
|
77
|
-
}, {
|
|
78
|
-
key: "getMaxAttributes",
|
|
79
|
-
value: function getMaxAttributes(gl) {
|
|
80
|
-
VertexArrayObject.MAX_ATTRIBUTES = VertexArrayObject.MAX_ATTRIBUTES || gl.getParameter(34921);
|
|
81
|
-
return VertexArrayObject.MAX_ATTRIBUTES;
|
|
82
|
-
}
|
|
83
|
-
}, {
|
|
84
|
-
key: "setConstant",
|
|
85
|
-
value: function setConstant(gl, location, array) {
|
|
86
|
-
switch (array.constructor) {
|
|
87
|
-
case Float32Array:
|
|
88
|
-
VertexArrayObject._setConstantFloatArray(gl, location, array);
|
|
89
|
-
|
|
90
|
-
break;
|
|
91
|
-
|
|
92
|
-
case Int32Array:
|
|
93
|
-
VertexArrayObject._setConstantIntArray(gl, location, array);
|
|
94
|
-
|
|
95
|
-
break;
|
|
96
|
-
|
|
97
|
-
case Uint32Array:
|
|
98
|
-
VertexArrayObject._setConstantUintArray(gl, location, array);
|
|
99
|
-
|
|
100
|
-
break;
|
|
101
|
-
|
|
102
|
-
default:
|
|
103
|
-
(0, _assert.assert)(false);
|
|
104
|
-
}
|
|
105
|
-
}
|
|
106
|
-
}]);
|
|
107
|
-
|
|
108
47
|
function VertexArrayObject(gl) {
|
|
109
48
|
var _this;
|
|
110
49
|
|
|
@@ -126,6 +65,11 @@ var VertexArrayObject = function (_Resource) {
|
|
|
126
65
|
}
|
|
127
66
|
|
|
128
67
|
(0, _createClass2.default)(VertexArrayObject, [{
|
|
68
|
+
key: _Symbol$toStringTag,
|
|
69
|
+
get: function get() {
|
|
70
|
+
return 'VertexArrayObject';
|
|
71
|
+
}
|
|
72
|
+
}, {
|
|
129
73
|
key: "delete",
|
|
130
74
|
value: function _delete() {
|
|
131
75
|
(0, _get2.default)((0, _getPrototypeOf2.default)(VertexArrayObject.prototype), "delete", this).call(this);
|
|
@@ -136,6 +80,11 @@ var VertexArrayObject = function (_Resource) {
|
|
|
136
80
|
|
|
137
81
|
return this;
|
|
138
82
|
}
|
|
83
|
+
}, {
|
|
84
|
+
key: "MAX_ATTRIBUTES",
|
|
85
|
+
get: function get() {
|
|
86
|
+
return VertexArrayObject.getMaxAttributes(this.gl);
|
|
87
|
+
}
|
|
139
88
|
}, {
|
|
140
89
|
key: "initialize",
|
|
141
90
|
value: function initialize() {
|
|
@@ -296,12 +245,61 @@ var VertexArrayObject = function (_Resource) {
|
|
|
296
245
|
}
|
|
297
246
|
});
|
|
298
247
|
}
|
|
248
|
+
}], [{
|
|
249
|
+
key: "isSupported",
|
|
250
|
+
value: function isSupported(gl) {
|
|
251
|
+
var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
|
|
252
|
+
|
|
253
|
+
if (options.constantAttributeZero) {
|
|
254
|
+
return (0, _gltools.isWebGL2)(gl) || (0, _env.getBrowser)() === 'Chrome';
|
|
255
|
+
}
|
|
256
|
+
|
|
257
|
+
return true;
|
|
258
|
+
}
|
|
299
259
|
}, {
|
|
300
|
-
key: "
|
|
301
|
-
|
|
302
|
-
|
|
260
|
+
key: "getDefaultArray",
|
|
261
|
+
value: function getDefaultArray(gl) {
|
|
262
|
+
gl.luma = gl.luma || {};
|
|
263
|
+
|
|
264
|
+
if (!gl.luma.defaultVertexArray) {
|
|
265
|
+
gl.luma.defaultVertexArray = new VertexArrayObject(gl, {
|
|
266
|
+
handle: null,
|
|
267
|
+
isDefaultArray: true
|
|
268
|
+
});
|
|
269
|
+
}
|
|
270
|
+
|
|
271
|
+
return gl.luma.defaultVertexArray;
|
|
303
272
|
}
|
|
304
|
-
}
|
|
273
|
+
}, {
|
|
274
|
+
key: "getMaxAttributes",
|
|
275
|
+
value: function getMaxAttributes(gl) {
|
|
276
|
+
VertexArrayObject.MAX_ATTRIBUTES = VertexArrayObject.MAX_ATTRIBUTES || gl.getParameter(34921);
|
|
277
|
+
return VertexArrayObject.MAX_ATTRIBUTES;
|
|
278
|
+
}
|
|
279
|
+
}, {
|
|
280
|
+
key: "setConstant",
|
|
281
|
+
value: function setConstant(gl, location, array) {
|
|
282
|
+
switch (array.constructor) {
|
|
283
|
+
case Float32Array:
|
|
284
|
+
VertexArrayObject._setConstantFloatArray(gl, location, array);
|
|
285
|
+
|
|
286
|
+
break;
|
|
287
|
+
|
|
288
|
+
case Int32Array:
|
|
289
|
+
VertexArrayObject._setConstantIntArray(gl, location, array);
|
|
290
|
+
|
|
291
|
+
break;
|
|
292
|
+
|
|
293
|
+
case Uint32Array:
|
|
294
|
+
VertexArrayObject._setConstantUintArray(gl, location, array);
|
|
295
|
+
|
|
296
|
+
break;
|
|
297
|
+
|
|
298
|
+
default:
|
|
299
|
+
(0, _assert.assert)(false);
|
|
300
|
+
}
|
|
301
|
+
}
|
|
302
|
+
}, {
|
|
305
303
|
key: "_setConstantFloatArray",
|
|
306
304
|
value: function _setConstantFloatArray(gl, location, array) {
|
|
307
305
|
switch (array.length) {
|
|
@@ -379,7 +377,7 @@ var VertexArrayObject = function (_Resource) {
|
|
|
379
377
|
}
|
|
380
378
|
}]);
|
|
381
379
|
return VertexArrayObject;
|
|
382
|
-
}(_resource.default);
|
|
380
|
+
}(_resource.default, Symbol.toStringTag);
|
|
383
381
|
|
|
384
382
|
exports.default = VertexArrayObject;
|
|
385
383
|
//# sourceMappingURL=vertex-array-object.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/classes/vertex-array-object.js"],"names":["ERR_ELEMENTS","VertexArrayObject","Symbol","toStringTag","gl","options","constantAttributeZero","luma","defaultVertexArray","handle","isDefaultArray","MAX_ATTRIBUTES","getParameter","location","array","constructor","Float32Array","_setConstantFloatArray","Int32Array","_setConstantIntArray","Uint32Array","_setConstantUintArray","opts","id","program","Object","assign","buffer","bufferValue","gl2","initialize","seal","delete","props","setProps","elementBuffer","target","bind","bindBuffer","accessor","setElementBuffer","size","type","stride","offset","normalized","integer","divisor","Number","vertexAttribIPointer","vertexAttribPointer","enableVertexAttribArray","vertexAttribDivisor","enable","disablingAttributeZero","isSupported","disableVertexAttribArray","elementCount","value","constantValue","_normalizeConstantArrayValue","byteLength","length","updateNeeded","Buffer","reallocate","_compareConstantArrayValues","typedArray","source","start","count","subData","arrayValue","Array","isArray","v1","v2","i","createVertexArray","deleteVertexArray","elements","bindVertexArray","pname","isFinite","getVertexAttribOffset","getVertexAttrib","getMaxAttributes","vertexAttrib1fv","vertexAttrib2fv","vertexAttrib3fv","vertexAttrib4fv","vertexAttribI1iv","vertexAttribI2iv","vertexAttribI3iv","vertexAttribI4iv","vertexAttribI1uiv","vertexAttribI2uiv","vertexAttribI3uiv","vertexAttribI4uiv","Resource"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;;;;;AAEA,IAAMA,YAAY,GAAG,0CAArB;;IAEqBC,iB;;;;;;SAEdC,MAAM,CAACC,W;wBAAe;AACzB,aAAO,mBAAP;AACD;;;gCACkBC,E,EAAkB;AAAA,UAAdC,OAAc,uEAAJ,EAAI;;AAGnC,UAAIA,OAAO,CAACC,qBAAZ,EAAmC;AACjC,eAAO,uBAASF,EAAT,KAAgB,6BAAiB,QAAxC;AACD;;AAGD,aAAO,IAAP;AACD;;;oCAIsBA,E,EAAI;AACzBA,MAAAA,EAAE,CAACG,IAAH,GAAUH,EAAE,CAACG,IAAH,IAAW,EAArB;;AACA,UAAI,CAACH,EAAE,CAACG,IAAH,CAAQC,kBAAb,EAAiC;AAC/BJ,QAAAA,EAAE,CAACG,IAAH,CAAQC,kBAAR,GAA6B,IAAIP,iBAAJ,CAAsBG,EAAtB,EAA0B;AAACK,UAAAA,MAAM,EAAE,IAAT;AAAeC,UAAAA,cAAc,EAAE;AAA/B,SAA1B,CAA7B;AACD;;AACD,aAAON,EAAE,CAACG,IAAH,CAAQC,kBAAf;AACD;;;qCAEuBJ,E,EAAI;AAG1BH,MAAAA,iBAAiB,CAACU,cAAlB,GAEEV,iBAAiB,CAACU,cAAlB,IAAoCP,EAAE,CAACQ,YAAH,OAFtC;AAIA,aAAOX,iBAAiB,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AnB,EAA6BC,KAA7B;AACA;;AACF;AACE,8BAAO,KAAP;AAdJ;AAgBD;;;yCAE2BV,E,EAAIS,Q,EAAUC,K,EAAO;AAC/C,0BAAO,uBAASV,EAAT,CAAP;;AACA,cAAQU,KAAK,CAACgD,MAAd;AACE,aAAK,CAAL;AACE1D,UAAAA,EAAE,CAACuF,gBAAH,CAAoB9E,QAApB,EAA8BC,KAA9B;AACA;;AACF,aAAK,CAAL;AACEV,UAAAA,EAAE,CAACwF,gBAAH,CAAoB/E,QAApB,EAA8BC,KAA9B;AACA;;AACF,aAAK,CAAL;AACEV,UAAAA,EAAE,CAACyF,gBAAH,CAAoBhF,QAApB,EAA8BC,KAA9B;AACA;;AACF,aAAK,CAAL;AACEV,UAAAA,EAAE,CAAC0F,gBAAH,CAAoBjF,QAApB,EAA8BC,KAA9B;AACA;;AACF;AACE,8BAAO,KAAP;AAdJ;AAgBD;;;0CAE4BV,E,EAAIS,Q,EAAUC,K,EAAO;AAChD,0BAAO,uBAASV,EAAT,CAAP;;AACA,cAAQU,KAAK,CAACgD,MAAd;AACE,aAAK,CAAL;AACE1D,UAAAA,EAAE,CAAC2F,iBAAH,CAAqBlF,QAArB,EAA+BC,KAA/B;AACA;;AACF,aAAK,CAAL;AACEV,UAAAA,EAAE,CAAC4F,iBAAH,CAAqBnF,QAArB,EAA+BC,KAA/B;AACA;;AACF,aAAK,CAAL;AACEV,UAAAA,EAAE,CAAC6F,iBAAH,CAAqBpF,QAArB,EAA+BC,KAA/B;AACA;;AACF,aAAK,CAAL;AACEV,UAAAA,EAAE,CAAC8F,iBAAH,CAAqBrF,QAArB,EAA+BC,KAA/B;AACA;;AACF;AACE,8BAAO,KAAP;AAdJ;AAgBD;;;EApR4CqF,iB","sourcesContent":["import GL from '@luma.gl/constants';\nimport Resource from './resource';\nimport Buffer from './buffer';\nimport {isWebGL2} from '@luma.gl/gltools';\nimport {getScratchArray, fillArray} from '../utils/array-utils-flat';\nimport {assert} from '../utils/assert';\nimport {getBrowser} from 'probe.gl';\n\nconst ERR_ELEMENTS = 'elements must be GL.ELEMENT_ARRAY_BUFFER';\n\nexport default class VertexArrayObject extends Resource {\n // eslint-disable-next-line accessor-pairs\n get [Symbol.toStringTag]() {\n return 'VertexArrayObject';\n }\n static isSupported(gl, options = {}) {\n // Attribute 0 can not be disable on most desktop OpenGL based browsers\n // and on iOS Safari browser.\n if (options.constantAttributeZero) {\n return isWebGL2(gl) || getBrowser() === 'Chrome';\n }\n\n // Whether additional objects can be created\n return true;\n }\n\n // Returns the global (null) vertex array object. Exists even when no extension available\n // TODO(Tarek): VAOs are now polyfilled. Deprecate this in 9.0\n static getDefaultArray(gl) {\n gl.luma = gl.luma || {};\n if (!gl.luma.defaultVertexArray) {\n gl.luma.defaultVertexArray = new VertexArrayObject(gl, {handle: null, isDefaultArray: true});\n }\n return gl.luma.defaultVertexArray;\n }\n\n static getMaxAttributes(gl) {\n // TODO - should be cached per context\n // @ts-ignore\n VertexArrayObject.MAX_ATTRIBUTES =\n // @ts-ignore\n VertexArrayObject.MAX_ATTRIBUTES || gl.getParameter(gl.MAX_VERTEX_ATTRIBS);\n // @ts-ignore\n return VertexArrayObject.MAX_ATTRIBUTES;\n }\n\n // Note: Constants are stored globally on the WebGL context, not the VAO\n // So they need to be updated before every render\n // TODO - use known type (in configuration or passed in) to allow non-typed arrays?\n // TODO - remember/cache values to avoid setting them unnecessarily?\n static setConstant(gl, location, array) {\n switch (array.constructor) {\n case Float32Array:\n VertexArrayObject._setConstantFloatArray(gl, location, array);\n break;\n case Int32Array:\n VertexArrayObject._setConstantIntArray(gl, location, array);\n break;\n case Uint32Array:\n VertexArrayObject._setConstantUintArray(gl, location, array);\n break;\n default:\n assert(false);\n }\n }\n\n // Create a VertexArray\n constructor(gl, opts = {}) {\n // Use program's id if program but no id is supplied\n const id = opts.id || (opts.program && opts.program.id);\n super(gl, Object.assign({}, opts, {id}));\n\n this.buffer = null;\n this.bufferValue = null;\n this.isDefaultArray = opts.isDefaultArray || false;\n\n /** @type {WebGL2RenderingContext} */\n this.gl2 = gl;\n\n this.initialize(opts);\n\n Object.seal(this);\n }\n\n delete() {\n super.delete();\n if (this.buffer) {\n this.buffer.delete();\n }\n return this;\n }\n\n get MAX_ATTRIBUTES() {\n return VertexArrayObject.getMaxAttributes(this.gl);\n }\n\n initialize(props = {}) {\n return this.setProps(props);\n }\n\n setProps(props) {\n // TODO: decide which props should be supported\n return this;\n }\n\n // Set (bind) an elements buffer, for indexed rendering.\n // Must be a Buffer bound to GL.ELEMENT_ARRAY_BUFFER. Constants not supported\n setElementBuffer(elementBuffer = null, opts = {}) {\n assert(!elementBuffer || elementBuffer.target === GL.ELEMENT_ARRAY_BUFFER, ERR_ELEMENTS);\n\n // The GL.ELEMENT_ARRAY_BUFFER_BINDING is stored on the VertexArrayObject...\n this.bind(() => {\n this.gl.bindBuffer(GL.ELEMENT_ARRAY_BUFFER, elementBuffer ? elementBuffer.handle : null);\n });\n\n return this;\n }\n\n // Set a location in vertex attributes array to a bufferk, enables the location, sets divisor\n setBuffer(location, buffer, accessor) {\n // Check target\n if (buffer.target === GL.ELEMENT_ARRAY_BUFFER) {\n return this.setElementBuffer(buffer, accessor);\n }\n\n const {size, type, stride, offset, normalized, integer, divisor} = accessor;\n\n const {gl, gl2} = this;\n location = Number(location);\n\n this.bind(() => {\n // A non-zero buffer object must be bound to the GL_ARRAY_BUFFER target\n gl.bindBuffer(gl.ARRAY_BUFFER, buffer.handle);\n\n // WebGL2 supports *integer* data formats, i.e. GPU will see integer values\n if (integer) {\n assert(isWebGL2(gl));\n gl2.vertexAttribIPointer(location, size, type, stride, offset);\n } else {\n // Attaches ARRAY_BUFFER with specified buffer format to location\n gl.vertexAttribPointer(location, size, type, normalized, stride, offset);\n }\n gl.enableVertexAttribArray(location);\n gl2.vertexAttribDivisor(location, divisor || 0);\n\n // NOTE We don't unbind buffer here, typically another buffer will be bound just after\n });\n\n return this;\n }\n\n // Enabling an attribute location makes it reference the currently bound buffer\n // Disabling an attribute location makes it reference the global constant value\n // TODO - handle single values for size 1 attributes?\n // TODO - convert classic arrays based on known type?\n enable(location, enable = true) {\n // Attribute 0 cannot be disabled in most desktop OpenGL based browsers\n const disablingAttributeZero =\n !enable &&\n location === 0 &&\n !VertexArrayObject.isSupported(this.gl, {constantAttributeZero: true});\n\n if (!disablingAttributeZero) {\n location = Number(location);\n this.bind(\n () =>\n enable\n ? this.gl.enableVertexAttribArray(location)\n : this.gl.disableVertexAttribArray(location)\n );\n }\n return this;\n }\n\n // Provide a means to create a buffer that is equivalent to a constant.\n // NOTE: Desktop OpenGL cannot disable attribute 0.\n // https://stackoverflow.com/questions/20305231/webgl-warning-attribute-0-is-disabled-\n // this-has-significant-performance-penalt\n getConstantBuffer(elementCount, value) {\n // Create buffer only when needed, and reuse it (avoids inflating buffer creation statistics)\n\n const constantValue = this._normalizeConstantArrayValue(value);\n\n const byteLength = constantValue.byteLength * elementCount;\n const length = constantValue.length * elementCount;\n\n let updateNeeded = !this.buffer;\n\n this.buffer = this.buffer || new Buffer(this.gl, byteLength);\n updateNeeded = updateNeeded || this.buffer.reallocate(byteLength);\n\n // Reallocate and update contents if needed\n updateNeeded =\n updateNeeded || !this._compareConstantArrayValues(constantValue, this.bufferValue);\n\n if (updateNeeded) {\n // Create a typed array that is big enough, and fill it with the required data\n const typedArray = getScratchArray(value.constructor, length);\n fillArray({target: typedArray, source: constantValue, start: 0, count: length});\n this.buffer.subData(typedArray);\n this.bufferValue = value;\n }\n\n return this.buffer;\n }\n\n // PRIVATE\n\n // TODO - convert Arrays based on known type? (read type from accessor, don't assume Float32Array)\n // TODO - handle single values for size 1 attributes?\n _normalizeConstantArrayValue(arrayValue) {\n if (Array.isArray(arrayValue)) {\n return new Float32Array(arrayValue);\n }\n return arrayValue;\n }\n\n _compareConstantArrayValues(v1, v2) {\n if (!v1 || !v2 || v1.length !== v2.length || v1.constructor !== v2.constructor) {\n return false;\n }\n for (let i = 0; i < v1.length; ++i) {\n if (v1[i] !== v2[i]) {\n return false;\n }\n }\n return true;\n }\n\n static _setConstantFloatArray(gl, location, array) {\n switch (array.length) {\n case 1:\n gl.vertexAttrib1fv(location, array);\n break;\n case 2:\n gl.vertexAttrib2fv(location, array);\n break;\n case 3:\n gl.vertexAttrib3fv(location, array);\n break;\n case 4:\n gl.vertexAttrib4fv(location, array);\n break;\n default:\n assert(false);\n }\n }\n\n static _setConstantIntArray(gl, location, array) {\n assert(isWebGL2(gl));\n switch (array.length) {\n case 1:\n gl.vertexAttribI1iv(location, array);\n break;\n case 2:\n gl.vertexAttribI2iv(location, array);\n break;\n case 3:\n gl.vertexAttribI3iv(location, array);\n break;\n case 4:\n gl.vertexAttribI4iv(location, array);\n break;\n default:\n assert(false);\n }\n }\n\n static _setConstantUintArray(gl, location, array) {\n assert(isWebGL2(gl));\n switch (array.length) {\n case 1:\n gl.vertexAttribI1uiv(location, array);\n break;\n case 2:\n gl.vertexAttribI2uiv(location, array);\n break;\n case 3:\n gl.vertexAttribI3uiv(location, array);\n break;\n case 4:\n gl.vertexAttribI4uiv(location, array);\n break;\n default:\n assert(false);\n }\n }\n\n // RESOURCE IMPLEMENTATION\n\n _createHandle() {\n /** @type {WebGL2RenderingContext} */\n // @ts-ignore\n const gl2 = this.gl;\n return gl2.createVertexArray();\n }\n\n _deleteHandle(handle) {\n this.gl2.deleteVertexArray(handle);\n // @ts-ignore\n return [this.elements];\n // return [this.elements, ...this.buffers];\n }\n\n _bindHandle(handle) {\n this.gl2.bindVertexArray(handle);\n }\n\n // Generic getter for information about a vertex attribute at a given position\n _getParameter(pname, {location}) {\n assert(Number.isFinite(location));\n return this.bind(() => {\n switch (pname) {\n case GL.VERTEX_ATTRIB_ARRAY_POINTER:\n return this.gl.getVertexAttribOffset(location, pname);\n default:\n return this.gl.getVertexAttrib(location, pname);\n }\n });\n }\n}\n"],"file":"vertex-array-object.js"}
|
|
1
|
+
{"version":3,"file":"vertex-array-object.js","names":["ERR_ELEMENTS","VertexArrayObject","gl","opts","id","program","Object","assign","buffer","bufferValue","isDefaultArray","gl2","initialize","seal","delete","getMaxAttributes","props","setProps","elementBuffer","assert","target","bind","bindBuffer","handle","location","accessor","setElementBuffer","size","type","stride","offset","normalized","integer","divisor","Number","isWebGL2","vertexAttribIPointer","vertexAttribPointer","enableVertexAttribArray","vertexAttribDivisor","enable","disablingAttributeZero","isSupported","constantAttributeZero","disableVertexAttribArray","elementCount","value","constantValue","_normalizeConstantArrayValue","byteLength","length","updateNeeded","Buffer","reallocate","_compareConstantArrayValues","typedArray","getScratchArray","constructor","fillArray","source","start","count","subData","arrayValue","Array","isArray","Float32Array","v1","v2","i","createVertexArray","deleteVertexArray","elements","bindVertexArray","pname","isFinite","getVertexAttribOffset","getVertexAttrib","options","getBrowser","luma","defaultVertexArray","MAX_ATTRIBUTES","getParameter","array","_setConstantFloatArray","Int32Array","_setConstantIntArray","Uint32Array","_setConstantUintArray","vertexAttrib1fv","vertexAttrib2fv","vertexAttrib3fv","vertexAttrib4fv","vertexAttribI1iv","vertexAttribI2iv","vertexAttribI3iv","vertexAttribI4iv","vertexAttribI1uiv","vertexAttribI2uiv","vertexAttribI3uiv","vertexAttribI4uiv","Resource","Symbol","toStringTag"],"sources":["../../../src/classes/vertex-array-object.js"],"sourcesContent":["import GL from '@luma.gl/constants';\nimport Resource from './resource';\nimport Buffer from './buffer';\nimport {isWebGL2} from '@luma.gl/gltools';\nimport {getScratchArray, fillArray} from '../utils/array-utils-flat';\nimport {assert} from '../utils/assert';\nimport {getBrowser} from '@probe.gl/env';\n\nconst ERR_ELEMENTS = 'elements must be GL.ELEMENT_ARRAY_BUFFER';\n\nexport default class VertexArrayObject extends Resource {\n // eslint-disable-next-line accessor-pairs\n get [Symbol.toStringTag]() {\n return 'VertexArrayObject';\n }\n static isSupported(gl, options = {}) {\n // Attribute 0 can not be disable on most desktop OpenGL based browsers\n // and on iOS Safari browser.\n if (options.constantAttributeZero) {\n return isWebGL2(gl) || getBrowser() === 'Chrome';\n }\n\n // Whether additional objects can be created\n return true;\n }\n\n // Returns the global (null) vertex array object. Exists even when no extension available\n // TODO(Tarek): VAOs are now polyfilled. Deprecate this in 9.0\n static getDefaultArray(gl) {\n gl.luma = gl.luma || {};\n if (!gl.luma.defaultVertexArray) {\n gl.luma.defaultVertexArray = new VertexArrayObject(gl, {handle: null, isDefaultArray: true});\n }\n return gl.luma.defaultVertexArray;\n }\n\n static getMaxAttributes(gl) {\n // TODO - should be cached per context\n // @ts-ignore\n VertexArrayObject.MAX_ATTRIBUTES =\n // @ts-ignore\n VertexArrayObject.MAX_ATTRIBUTES || gl.getParameter(gl.MAX_VERTEX_ATTRIBS);\n // @ts-ignore\n return VertexArrayObject.MAX_ATTRIBUTES;\n }\n\n // Note: Constants are stored globally on the WebGL context, not the VAO\n // So they need to be updated before every render\n // TODO - use known type (in configuration or passed in) to allow non-typed arrays?\n // TODO - remember/cache values to avoid setting them unnecessarily?\n static setConstant(gl, location, array) {\n switch (array.constructor) {\n case Float32Array:\n VertexArrayObject._setConstantFloatArray(gl, location, array);\n break;\n case Int32Array:\n VertexArrayObject._setConstantIntArray(gl, location, array);\n break;\n case Uint32Array:\n VertexArrayObject._setConstantUintArray(gl, location, array);\n break;\n default:\n assert(false);\n }\n }\n\n // Create a VertexArray\n constructor(gl, opts = {}) {\n // Use program's id if program but no id is supplied\n const id = opts.id || (opts.program && opts.program.id);\n super(gl, Object.assign({}, opts, {id}));\n\n this.buffer = null;\n this.bufferValue = null;\n this.isDefaultArray = opts.isDefaultArray || false;\n\n /** @type {WebGL2RenderingContext} */\n this.gl2 = gl;\n\n this.initialize(opts);\n\n Object.seal(this);\n }\n\n delete() {\n super.delete();\n if (this.buffer) {\n this.buffer.delete();\n }\n return this;\n }\n\n get MAX_ATTRIBUTES() {\n return VertexArrayObject.getMaxAttributes(this.gl);\n }\n\n initialize(props = {}) {\n return this.setProps(props);\n }\n\n setProps(props) {\n // TODO: decide which props should be supported\n return this;\n }\n\n // Set (bind) an elements buffer, for indexed rendering.\n // Must be a Buffer bound to GL.ELEMENT_ARRAY_BUFFER. Constants not supported\n setElementBuffer(elementBuffer = null, opts = {}) {\n assert(!elementBuffer || elementBuffer.target === GL.ELEMENT_ARRAY_BUFFER, ERR_ELEMENTS);\n\n // The GL.ELEMENT_ARRAY_BUFFER_BINDING is stored on the VertexArrayObject...\n this.bind(() => {\n this.gl.bindBuffer(GL.ELEMENT_ARRAY_BUFFER, elementBuffer ? elementBuffer.handle : null);\n });\n\n return this;\n }\n\n // Set a location in vertex attributes array to a bufferk, enables the location, sets divisor\n setBuffer(location, buffer, accessor) {\n // Check target\n if (buffer.target === GL.ELEMENT_ARRAY_BUFFER) {\n return this.setElementBuffer(buffer, accessor);\n }\n\n const {size, type, stride, offset, normalized, integer, divisor} = accessor;\n\n const {gl, gl2} = this;\n location = Number(location);\n\n this.bind(() => {\n // A non-zero buffer object must be bound to the GL_ARRAY_BUFFER target\n gl.bindBuffer(gl.ARRAY_BUFFER, buffer.handle);\n\n // WebGL2 supports *integer* data formats, i.e. GPU will see integer values\n if (integer) {\n assert(isWebGL2(gl));\n gl2.vertexAttribIPointer(location, size, type, stride, offset);\n } else {\n // Attaches ARRAY_BUFFER with specified buffer format to location\n gl.vertexAttribPointer(location, size, type, normalized, stride, offset);\n }\n gl.enableVertexAttribArray(location);\n gl2.vertexAttribDivisor(location, divisor || 0);\n\n // NOTE We don't unbind buffer here, typically another buffer will be bound just after\n });\n\n return this;\n }\n\n // Enabling an attribute location makes it reference the currently bound buffer\n // Disabling an attribute location makes it reference the global constant value\n // TODO - handle single values for size 1 attributes?\n // TODO - convert classic arrays based on known type?\n enable(location, enable = true) {\n // Attribute 0 cannot be disabled in most desktop OpenGL based browsers\n const disablingAttributeZero =\n !enable &&\n location === 0 &&\n !VertexArrayObject.isSupported(this.gl, {constantAttributeZero: true});\n\n if (!disablingAttributeZero) {\n location = Number(location);\n this.bind(\n () =>\n enable\n ? this.gl.enableVertexAttribArray(location)\n : this.gl.disableVertexAttribArray(location)\n );\n }\n return this;\n }\n\n // Provide a means to create a buffer that is equivalent to a constant.\n // NOTE: Desktop OpenGL cannot disable attribute 0.\n // https://stackoverflow.com/questions/20305231/webgl-warning-attribute-0-is-disabled-\n // this-has-significant-performance-penalt\n getConstantBuffer(elementCount, value) {\n // Create buffer only when needed, and reuse it (avoids inflating buffer creation statistics)\n\n const constantValue = this._normalizeConstantArrayValue(value);\n\n const byteLength = constantValue.byteLength * elementCount;\n const length = constantValue.length * elementCount;\n\n let updateNeeded = !this.buffer;\n\n this.buffer = this.buffer || new Buffer(this.gl, byteLength);\n updateNeeded = updateNeeded || this.buffer.reallocate(byteLength);\n\n // Reallocate and update contents if needed\n updateNeeded =\n updateNeeded || !this._compareConstantArrayValues(constantValue, this.bufferValue);\n\n if (updateNeeded) {\n // Create a typed array that is big enough, and fill it with the required data\n const typedArray = getScratchArray(value.constructor, length);\n fillArray({target: typedArray, source: constantValue, start: 0, count: length});\n this.buffer.subData(typedArray);\n this.bufferValue = value;\n }\n\n return this.buffer;\n }\n\n // PRIVATE\n\n // TODO - convert Arrays based on known type? (read type from accessor, don't assume Float32Array)\n // TODO - handle single values for size 1 attributes?\n _normalizeConstantArrayValue(arrayValue) {\n if (Array.isArray(arrayValue)) {\n return new Float32Array(arrayValue);\n }\n return arrayValue;\n }\n\n _compareConstantArrayValues(v1, v2) {\n if (!v1 || !v2 || v1.length !== v2.length || v1.constructor !== v2.constructor) {\n return false;\n }\n for (let i = 0; i < v1.length; ++i) {\n if (v1[i] !== v2[i]) {\n return false;\n }\n }\n return true;\n }\n\n static _setConstantFloatArray(gl, location, array) {\n switch (array.length) {\n case 1:\n gl.vertexAttrib1fv(location, array);\n break;\n case 2:\n gl.vertexAttrib2fv(location, array);\n break;\n case 3:\n gl.vertexAttrib3fv(location, array);\n break;\n case 4:\n gl.vertexAttrib4fv(location, array);\n break;\n default:\n assert(false);\n }\n }\n\n static _setConstantIntArray(gl, location, array) {\n assert(isWebGL2(gl));\n switch (array.length) {\n case 1:\n gl.vertexAttribI1iv(location, array);\n break;\n case 2:\n gl.vertexAttribI2iv(location, array);\n break;\n case 3:\n gl.vertexAttribI3iv(location, array);\n break;\n case 4:\n gl.vertexAttribI4iv(location, array);\n break;\n default:\n assert(false);\n }\n }\n\n static _setConstantUintArray(gl, location, array) {\n assert(isWebGL2(gl));\n switch (array.length) {\n case 1:\n gl.vertexAttribI1uiv(location, array);\n break;\n case 2:\n gl.vertexAttribI2uiv(location, array);\n break;\n case 3:\n gl.vertexAttribI3uiv(location, array);\n break;\n case 4:\n gl.vertexAttribI4uiv(location, array);\n break;\n default:\n assert(false);\n }\n }\n\n // RESOURCE IMPLEMENTATION\n\n _createHandle() {\n /** @type {WebGL2RenderingContext} */\n // @ts-ignore\n const gl2 = this.gl;\n return gl2.createVertexArray();\n }\n\n _deleteHandle(handle) {\n this.gl2.deleteVertexArray(handle);\n // @ts-ignore\n return [this.elements];\n // return [this.elements, ...this.buffers];\n }\n\n _bindHandle(handle) {\n this.gl2.bindVertexArray(handle);\n }\n\n // Generic getter for information about a vertex attribute at a given position\n _getParameter(pname, {location}) {\n assert(Number.isFinite(location));\n return this.bind(() => {\n switch (pname) {\n case GL.VERTEX_ATTRIB_ARRAY_POINTER:\n return this.gl.getVertexAttribOffset(location, pname);\n default:\n return this.gl.getVertexAttrib(location, pname);\n }\n });\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;;;;;AAEA,IAAMA,YAAY,GAAG,0CAArB;;IAEqBC,iB;;;;;EAyDnB,2BAAYC,EAAZ,EAA2B;IAAA;;IAAA,IAAXC,IAAW,uEAAJ,EAAI;IAAA;IAEzB,IAAMC,EAAE,GAAGD,IAAI,CAACC,EAAL,IAAYD,IAAI,CAACE,OAAL,IAAgBF,IAAI,CAACE,OAAL,CAAaD,EAApD;IACA,0BAAMF,EAAN,EAAUI,MAAM,CAACC,MAAP,CAAc,EAAd,EAAkBJ,IAAlB,EAAwB;MAACC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gBD;;;WAED,+BAA6BjB,EAA7B,EAAiCsB,QAAjC,EAA2C4D,KAA3C,EAAkD;MAChD,IAAAjE,cAAA,EAAO,IAAAgB,iBAAA,EAASjC,EAAT,CAAP;;MACA,QAAQkF,KAAK,CAAClC,MAAd;QACE,KAAK,CAAL;UACEhD,EAAE,CAACgG,iBAAH,CAAqB1E,QAArB,EAA+B4D,KAA/B;UACA;;QACF,KAAK,CAAL;UACElF,EAAE,CAACiG,iBAAH,CAAqB3E,QAArB,EAA+B4D,KAA/B;UACA;;QACF,KAAK,CAAL;UACElF,EAAE,CAACkG,iBAAH,CAAqB5E,QAArB,EAA+B4D,KAA/B;UACA;;QACF,KAAK,CAAL;UACElF,EAAE,CAACmG,iBAAH,CAAqB7E,QAArB,EAA+B4D,KAA/B;UACA;;QACF;UACE,IAAAjE,cAAA,EAAO,KAAP;MAdJ;IAgBD;;;EApR4CmF,iB,EAExCC,MAAM,CAACC,W"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/classes/vertex-array.js"],"names":["ERR_ATTRIBUTE_TYPE","MULTI_LOCATION_ATTRIBUTE_REGEXP","DEPRECATIONS_V6","VertexArray","gl","opts","id","program","configuration","elements","elementsAccessor","values","accessors","unused","drawParams","buffer","attributes","vertexArrayObject","VertexArrayObject","initialize","Object","seal","delete","props","reset","bindOnUse","setProps","MAX_ATTRIBUTES","Array","fill","setAttributes","setElementBuffer","_updateDrawParams","assign","bind","locationOrName","value","_setAttribute","bindBuffer","elementBuffer","accessor","clearDrawParams","appAccessor","target","_resolveLocationAndAccessor","location","setBuffer","arrayValue","size","length","_normalizeConstantArrayValue","enable","Buffer","disableVertexAttribArray","handle","vertexAttribPointer","vertexCount","instanceCount","func","_setConstantAttributes","valueAccessor","INVALID_RESULT","_getAttributeIndex","name","Number","isFinite","log","once","accessInfo","_getAttributeInfo","currentAccessor","Accessor","resolve","type","attributeName","getAttributeInfo","multiLocation","exec","locationOffset","getAttributeLocation","isArray","ArrayBuffer","isView","constant","setConstant","Error","elementCount","Math","max","_setConstantAttributeZero","_setConstantAttribute","isSupported","constantAttributeZero","getConstantBuffer","isIndexed","isInstanced","indexCount","Infinity","_updateDrawParamsForLocation","getElementCount","indexType","indexOffset","offset","divisor","getVertexCount","min","deprecated"],"mappings":";;;;;;;;;;;;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AAEA,IAAMA,kBAAkB,GACtB,yEADF;AAMA,IAAMC,+BAA+B,GAAG,2BAAxC;AAEA,IAAMC,eAAe,GAAG,CACtB,YADsB,EAEtB,YAFsB,EAGtB,eAHsB,EAItB,cAJsB,EAKtB,kBALsB,EAMtB,YANsB,EAOtB,QAPsB,EAQtB,SARsB,CAAxB;;IAWqBC,W;AACnB,uBAAYC,EAAZ,EAA2B;AAAA,QAAXC,IAAW,uEAAJ,EAAI;AAAA;AAEzB,QAAMC,EAAE,GAAGD,IAAI,CAACC,EAAL,IAAYD,IAAI,CAACE,OAAL,IAAgBF,IAAI,CAACE,OAAL,CAAaD,EAApD;AAGA,SAAKA,EAAL,GAAUA,EAAV;AACA,SAAKF,EAAL,GAAUA,EAAV;AACA,SAAKI,aAAL,GAAqB,IAArB;AAGA,SAAKC,QAAL,GAAgB,IAAhB;AACA,SAAKC,gBAAL,GAAwB,IAAxB;AACA,SAAKC,MAAL,GAAc,IAAd;AACA,SAAKC,SAAL,GAAiB,IAAjB;AACA,SAAKC,MAAL,GAAc,IAAd;AACA,SAAKC,UAAL,GAAkB,IAAlB;AACA,SAAKC,MAAL,GAAc,IAAd;AAEA,SAAKC,UAAL,GAAkB,EAAlB;AAEA,SAAKC,iBAAL,GAAyB,IAAIC,0BAAJ,CAAsBd,EAAtB,CAAzB;AAGA,yCAAmB,IAAnB,EAAyB,aAAzB,EAAwC,MAAxC,EAAgDF,eAAhD;AAEA,SAAKiB,UAAL,CAAgBd,IAAhB;AACAe,IAAAA,MAAM,CAACC,IAAP,CAAY,IAAZ;AACD;;;;8BAEQ;AACP,UAAI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U,CAAC0C,WAAX,GAAyB+B,IAAI,CAACkB,GAAL,CAAS3F,UAAU,CAAC0C,WAApB,EAAiCA,WAAjC,CAAzB;AACD;AACF;AACF;;;kCAIgD;AAAA,UAArCjB,aAAqC,uEAArB,IAAqB;AAAA,UAAfC,QAAe,uEAAJ,EAAI;;AAC/C0B,mBAAIwC,UAAJ,CAAe,aAAf,EAA8B,kBAA9B;;AACA,aAAO,KAAK3E,gBAAL,CAAsBQ,aAAtB,EAAqCC,QAArC,CAAP;AACD","sourcesContent":["import GL from '@luma.gl/constants';\nimport {log} from '@luma.gl/gltools';\nimport Accessor from './accessor';\nimport Buffer from './buffer';\nimport VertexArrayObject from './vertex-array-object';\nimport {assert} from '../utils/assert';\nimport {stubRemovedMethods} from '../utils/stub-methods';\n\nconst ERR_ATTRIBUTE_TYPE =\n 'VertexArray: attributes must be Buffers or constants (i.e. typed array)';\n\n// This is done to support mat type attributes.\n// See section \"Notes about setting mat type attributes\"\n// in vertex-array.md\nconst MULTI_LOCATION_ATTRIBUTE_REGEXP = /^(.+)__LOCATION_([0-9]+)$/;\n\nconst DEPRECATIONS_V6 = [\n 'setBuffers',\n 'setGeneric',\n 'clearBindings',\n 'setLocations',\n 'setGenericValues',\n 'setDivisor',\n 'enable',\n 'disable'\n];\n\nexport default class VertexArray {\n constructor(gl, opts = {}) {\n // Use program's id if program is supplied but no id is supplied\n const id = opts.id || (opts.program && opts.program.id);\n // super(gl, Object.assign({}, opts, {id}));\n\n this.id = id;\n this.gl = gl;\n this.configuration = null;\n\n // Extracted information\n this.elements = null;\n this.elementsAccessor = null;\n this.values = null;\n this.accessors = null;\n this.unused = null;\n this.drawParams = null;\n this.buffer = null; // For attribute 0 on desktops, and created when unbinding buffers\n\n this.attributes = {};\n\n this.vertexArrayObject = new VertexArrayObject(gl);\n\n // Issue errors when using removed methods\n stubRemovedMethods(this, 'VertexArray', 'v6.0', DEPRECATIONS_V6);\n\n this.initialize(opts);\n Object.seal(this);\n }\n\n delete() {\n if (this.buffer) {\n this.buffer.delete();\n }\n\n this.vertexArrayObject.delete();\n }\n\n initialize(props = {}) {\n this.reset();\n this.configuration = null;\n this.bindOnUse = false;\n return this.setProps(props);\n }\n\n // Resets all attributes (to default valued constants)\n reset() {\n // this.vertexArrayObject.reset();\n\n this.elements = null;\n this.elementsAccessor = null;\n const {MAX_ATTRIBUTES} = this.vertexArrayObject;\n this.values = new Array(MAX_ATTRIBUTES).fill(null);\n this.accessors = new Array(MAX_ATTRIBUTES).fill(null);\n this.unused = {};\n\n // Auto detects draw params\n this.drawParams = null;\n\n return this;\n }\n\n setProps(props) {\n if ('program' in props) {\n this.configuration = props.program && props.program.configuration;\n }\n if ('configuration' in props) {\n this.configuration = props.configuration;\n }\n if ('attributes' in props) {\n this.setAttributes(props.attributes);\n }\n if ('elements' in props) {\n this.setElementBuffer(props.elements);\n }\n if ('bindOnUse' in props) {\n props = props.bindOnUse;\n }\n return this;\n }\n\n // Automatically called if buffers changed through VertexArray API\n clearDrawParams() {\n this.drawParams = null;\n }\n\n getDrawParams() {\n // Auto deduced draw parameters\n this.drawParams = this.drawParams || this._updateDrawParams();\n\n return this.drawParams;\n }\n\n // Set (bind) an array or map of vertex array buffers, either in numbered or named locations.\n // For names that are not present in `location`, the supplied buffers will be ignored.\n // if a single buffer of type GL.ELEMENT_ARRAY_BUFFER is present, it will be set as elements\n // Signatures:\n // {attributeName: buffer}\n // {attributeName: [buffer, accessor]}\n // {attributeName: (typed) array} => constant\n setAttributes(attributes) {\n Object.assign(this.attributes, attributes);\n this.vertexArrayObject.bind(() => {\n for (const locationOrName in attributes) {\n const value = attributes[locationOrName];\n this._setAttribute(locationOrName, value);\n }\n // Make sure we don't leave any bindings\n this.gl.bindBuffer(GL.ARRAY_BUFFER, null);\n });\n\n return this;\n }\n\n // Set (bind) an elements buffer, for indexed rendering.\n // Must be a Buffer bound to GL.ELEMENT_ARRAY_BUFFER. Constants not supported\n setElementBuffer(elementBuffer = null, accessor = {}) {\n this.elements = elementBuffer; // Save value for debugging\n this.elementsAccessor = accessor;\n this.clearDrawParams();\n this.vertexArrayObject.setElementBuffer(elementBuffer, accessor);\n\n return this;\n }\n\n // Set a location in vertex attributes array to a buffer\n setBuffer(locationOrName, buffer, appAccessor = {}) {\n // Check target\n if (buffer.target === GL.ELEMENT_ARRAY_BUFFER) {\n return this.setElementBuffer(buffer, appAccessor);\n }\n\n const {location, accessor} = this._resolveLocationAndAccessor(\n locationOrName,\n buffer,\n buffer.accessor,\n appAccessor\n );\n\n if (location >= 0) {\n this.values[location] = buffer;\n this.accessors[location] = accessor;\n this.clearDrawParams();\n this.vertexArrayObject.setBuffer(location, buffer, accessor);\n }\n\n return this;\n }\n\n // Set attribute to constant value (small typed array corresponding to one vertex' worth of data)\n setConstant(locationOrName, arrayValue, appAccessor = {}) {\n const {location, accessor} = this._resolveLocationAndAccessor(\n locationOrName,\n arrayValue,\n // Ensure that size isn't taken from program for multi-column\n // attributes\n Object.assign({size: arrayValue.length}, appAccessor)\n );\n\n if (location >= 0) {\n arrayValue = this.vertexArrayObject._normalizeConstantArrayValue(arrayValue);\n\n this.values[location] = arrayValue;\n this.accessors[location] = accessor;\n this.clearDrawParams();\n\n // NOTE: We set the actual constant value later on bind. We can't set the value now since\n // constants are global and affect all other VertexArrays that have disabled attributes\n // in the same location.\n // We do disable the attribute which makes it use the global constant value at that location\n this.vertexArrayObject.enable(location, false);\n }\n\n return this;\n }\n\n // Workaround for Chrome TransformFeedback binding issue\n // If required, unbind temporarily to avoid conflicting with TransformFeedback\n unbindBuffers() {\n this.vertexArrayObject.bind(() => {\n if (this.elements) {\n this.vertexArrayObject.setElementBuffer(null);\n }\n\n // Chrome does not like buffers that are bound to several binding points,\n // so we need to offer and unbind facility\n // WebGL offers disabling, but no clear way to set a VertexArray buffer to `null`\n // So we just bind all the attributes to the dummy \"attribute zero\" buffer\n this.buffer = this.buffer || new Buffer(this.gl, {accessor: {size: 4}});\n\n for (let location = 0; location < this.vertexArrayObject.MAX_ATTRIBUTES; location++) {\n if (this.values[location] instanceof Buffer) {\n this.gl.disableVertexAttribArray(location);\n this.gl.bindBuffer(GL.ARRAY_BUFFER, this.buffer.handle);\n this.gl.vertexAttribPointer(location, 1, GL.FLOAT, false, 0, 0);\n }\n }\n });\n return this;\n }\n\n // Workaround for Chrome TransformFeedback binding issue\n // If required, rebind rebind after temporary unbind\n bindBuffers() {\n this.vertexArrayObject.bind(() => {\n if (this.elements) {\n this.setElementBuffer(this.elements);\n }\n\n for (let location = 0; location < this.vertexArrayObject.MAX_ATTRIBUTES; location++) {\n const buffer = this.values[location];\n if (buffer instanceof Buffer) {\n this.setBuffer(location, buffer);\n }\n }\n });\n return this;\n }\n\n // Bind for use\n // When a vertex array is about to be used, we must:\n // - Set constant attributes (since these are stored on the context and reset on bind)\n // - Check if we need to initialize the buffer\n bindForDraw(vertexCount, instanceCount, func) {\n let value;\n\n this.vertexArrayObject.bind(() => {\n // Make sure that any constant attributes are updated (stored on the context, not the VAO)\n // Also handles attribute 0\n this._setConstantAttributes(vertexCount, instanceCount);\n\n value = func();\n });\n\n return value;\n }\n\n // PRIVATE\n\n // Resolve locations and accessors\n _resolveLocationAndAccessor(locationOrName, value, valueAccessor, appAccessor) {\n const INVALID_RESULT = {\n location: -1,\n accessor: null\n };\n\n const {location, name} = this._getAttributeIndex(locationOrName);\n if (!Number.isFinite(location) || location < 0) {\n this.unused[locationOrName] = value;\n log.once(3, () => `unused value ${locationOrName} in ${this.id}`)();\n return INVALID_RESULT;\n }\n\n const accessInfo = this._getAttributeInfo(name || location);\n\n // Attribute location wasn't directly found.\n // Likely due to multi-location attributes (e.g. matrix)\n if (!accessInfo) {\n return INVALID_RESULT;\n }\n\n // Resolve the partial accessors into a final accessor\n const currentAccessor = this.accessors[location] || {};\n const accessor = Accessor.resolve(\n accessInfo.accessor,\n currentAccessor,\n valueAccessor,\n appAccessor\n );\n\n const {size, type} = accessor;\n assert(Number.isFinite(size) && Number.isFinite(type));\n\n return {location, accessor};\n }\n\n _getAttributeInfo(attributeName) {\n return this.configuration && this.configuration.getAttributeInfo(attributeName);\n }\n\n _getAttributeIndex(locationOrName) {\n const location = Number(locationOrName);\n if (Number.isFinite(location)) {\n return {location};\n }\n\n const multiLocation = MULTI_LOCATION_ATTRIBUTE_REGEXP.exec(locationOrName);\n const name = multiLocation ? multiLocation[1] : locationOrName;\n const locationOffset = multiLocation ? Number(multiLocation[2]) : 0;\n\n if (this.configuration) {\n return {\n location: this.configuration.getAttributeLocation(name) + locationOffset,\n name\n };\n }\n\n return {location: -1};\n }\n\n _setAttribute(locationOrName, value) {\n if (value instanceof Buffer) {\n // Signature: {attributeName: Buffer}\n this.setBuffer(locationOrName, value);\n } else if (Array.isArray(value) && value.length && value[0] instanceof Buffer) {\n // Signature: {attributeName: [buffer, accessor]}\n const buffer = value[0];\n const accessor = value[1];\n this.setBuffer(locationOrName, buffer, accessor);\n } else if (ArrayBuffer.isView(value) || Array.isArray(value)) {\n // Signature: {attributeName: constant}, constant == short (typed) array\n const constant = value;\n this.setConstant(locationOrName, constant);\n } else if (value.buffer instanceof Buffer) {\n // luma.gl v7: Support accessor objects with 'buffer' field\n // for interleaved data\n // Signature: {attributeName: {...accessor, buffer}}\n const accessor = value;\n this.setBuffer(locationOrName, accessor.buffer, accessor);\n } else {\n throw new Error(ERR_ATTRIBUTE_TYPE);\n }\n }\n\n // Updates all constant attribute values (constants are used when vertex attributes are disabled).\n // This needs to be done repeatedly since in contrast to buffer bindings,\n // constants are stored on the WebGL context, not the VAO\n _setConstantAttributes(vertexCount, instanceCount) {\n // TODO - use accessor to determine what length to use\n const elementCount = Math.max(vertexCount | 0, instanceCount | 0);\n let constant = this.values[0];\n if (ArrayBuffer.isView(constant)) {\n this._setConstantAttributeZero(constant, elementCount);\n }\n\n for (let location = 1; location < this.vertexArrayObject.MAX_ATTRIBUTES; location++) {\n constant = this.values[location];\n if (ArrayBuffer.isView(constant)) {\n this._setConstantAttribute(location, constant);\n }\n }\n }\n\n _setConstantAttributeZero(constant, elementCount) {\n if (VertexArrayObject.isSupported(this.gl, {constantAttributeZero: true})) {\n this._setConstantAttribute(0, constant);\n return;\n }\n\n // Get a dummy buffer populated with repeated constants\n const buffer = this.vertexArrayObject.getConstantBuffer(elementCount, constant);\n\n // Set the buffer on location 0\n this.vertexArrayObject.setBuffer(0, buffer, this.accessors[0]);\n }\n\n _setConstantAttribute(location, constant) {\n VertexArrayObject.setConstant(this.gl, location, constant);\n }\n\n // Walks the buffers and updates draw parameters\n _updateDrawParams() {\n const drawParams = {\n isIndexed: false,\n isInstanced: false,\n indexCount: Infinity,\n vertexCount: Infinity,\n instanceCount: Infinity\n };\n\n for (let location = 0; location < this.vertexArrayObject.MAX_ATTRIBUTES; location++) {\n this._updateDrawParamsForLocation(drawParams, location);\n }\n\n if (this.elements) {\n // indexing is autodetected - buffer with target GL.ELEMENT_ARRAY_BUFFER\n // index type is saved for drawElement calls\n drawParams.elementCount = this.elements.getElementCount(this.elements.accessor);\n drawParams.isIndexed = true;\n drawParams.indexType = this.elementsAccessor.type || this.elements.accessor.type;\n drawParams.indexOffset = this.elementsAccessor.offset || 0;\n }\n\n // Post-calculation checks\n if (drawParams.indexCount === Infinity) {\n drawParams.indexCount = 0;\n }\n if (drawParams.vertexCount === Infinity) {\n drawParams.vertexCount = 0;\n }\n if (drawParams.instanceCount === Infinity) {\n drawParams.instanceCount = 0;\n }\n\n return drawParams;\n }\n\n _updateDrawParamsForLocation(drawParams, location) {\n const value = this.values[location];\n const accessor = this.accessors[location];\n\n if (!value) {\n return;\n }\n\n // Check if instanced (whether buffer or constant)\n const {divisor} = accessor;\n const isInstanced = divisor > 0;\n drawParams.isInstanced = drawParams.isInstanced || isInstanced;\n\n if (value instanceof Buffer) {\n const buffer = value;\n\n if (isInstanced) {\n // instance attribute\n const instanceCount = buffer.getVertexCount(accessor);\n drawParams.instanceCount = Math.min(drawParams.instanceCount, instanceCount);\n } else {\n // normal attribute\n const vertexCount = buffer.getVertexCount(accessor);\n drawParams.vertexCount = Math.min(drawParams.vertexCount, vertexCount);\n }\n }\n }\n\n // DEPRECATED in v6.x - but not warnings not properly implemented\n\n setElements(elementBuffer = null, accessor = {}) {\n log.deprecated('setElements', 'setElementBuffer')();\n return this.setElementBuffer(elementBuffer, accessor);\n }\n}\n"],"file":"vertex-array.js"}
|
|
1
|
+
{"version":3,"file":"vertex-array.js","names":["ERR_ATTRIBUTE_TYPE","MULTI_LOCATION_ATTRIBUTE_REGEXP","DEPRECATIONS_V6","VertexArray","gl","opts","id","program","configuration","elements","elementsAccessor","values","accessors","unused","drawParams","buffer","attributes","vertexArrayObject","VertexArrayObject","stubRemovedMethods","initialize","Object","seal","delete","props","reset","bindOnUse","setProps","MAX_ATTRIBUTES","Array","fill","setAttributes","setElementBuffer","_updateDrawParams","assign","bind","locationOrName","value","_setAttribute","bindBuffer","elementBuffer","accessor","clearDrawParams","appAccessor","target","_resolveLocationAndAccessor","location","setBuffer","arrayValue","size","length","_normalizeConstantArrayValue","enable","Buffer","disableVertexAttribArray","handle","vertexAttribPointer","vertexCount","instanceCount","func","_setConstantAttributes","valueAccessor","INVALID_RESULT","_getAttributeIndex","name","Number","isFinite","log","once","accessInfo","_getAttributeInfo","currentAccessor","Accessor","resolve","type","assert","attributeName","getAttributeInfo","multiLocation","exec","locationOffset","getAttributeLocation","isArray","ArrayBuffer","isView","constant","setConstant","Error","elementCount","Math","max","_setConstantAttributeZero","_setConstantAttribute","isSupported","constantAttributeZero","getConstantBuffer","isIndexed","isInstanced","indexCount","Infinity","_updateDrawParamsForLocation","getElementCount","indexType","indexOffset","offset","divisor","getVertexCount","min","deprecated"],"sources":["../../../src/classes/vertex-array.js"],"sourcesContent":["import GL from '@luma.gl/constants';\nimport {log} from '@luma.gl/gltools';\nimport Accessor from './accessor';\nimport Buffer from './buffer';\nimport VertexArrayObject from './vertex-array-object';\nimport {assert} from '../utils/assert';\nimport {stubRemovedMethods} from '../utils/stub-methods';\n\nconst ERR_ATTRIBUTE_TYPE =\n 'VertexArray: attributes must be Buffers or constants (i.e. typed array)';\n\n// This is done to support mat type attributes.\n// See section \"Notes about setting mat type attributes\"\n// in vertex-array.md\nconst MULTI_LOCATION_ATTRIBUTE_REGEXP = /^(.+)__LOCATION_([0-9]+)$/;\n\nconst DEPRECATIONS_V6 = [\n 'setBuffers',\n 'setGeneric',\n 'clearBindings',\n 'setLocations',\n 'setGenericValues',\n 'setDivisor',\n 'enable',\n 'disable'\n];\n\nexport default class VertexArray {\n constructor(gl, opts = {}) {\n // Use program's id if program is supplied but no id is supplied\n const id = opts.id || (opts.program && opts.program.id);\n // super(gl, Object.assign({}, opts, {id}));\n\n this.id = id;\n this.gl = gl;\n this.configuration = null;\n\n // Extracted information\n this.elements = null;\n this.elementsAccessor = null;\n this.values = null;\n this.accessors = null;\n this.unused = null;\n this.drawParams = null;\n this.buffer = null; // For attribute 0 on desktops, and created when unbinding buffers\n\n this.attributes = {};\n\n this.vertexArrayObject = new VertexArrayObject(gl);\n\n // Issue errors when using removed methods\n stubRemovedMethods(this, 'VertexArray', 'v6.0', DEPRECATIONS_V6);\n\n this.initialize(opts);\n Object.seal(this);\n }\n\n delete() {\n if (this.buffer) {\n this.buffer.delete();\n }\n\n this.vertexArrayObject.delete();\n }\n\n initialize(props = {}) {\n this.reset();\n this.configuration = null;\n this.bindOnUse = false;\n return this.setProps(props);\n }\n\n // Resets all attributes (to default valued constants)\n reset() {\n // this.vertexArrayObject.reset();\n\n this.elements = null;\n this.elementsAccessor = null;\n const {MAX_ATTRIBUTES} = this.vertexArrayObject;\n this.values = new Array(MAX_ATTRIBUTES).fill(null);\n this.accessors = new Array(MAX_ATTRIBUTES).fill(null);\n this.unused = {};\n\n // Auto detects draw params\n this.drawParams = null;\n\n return this;\n }\n\n setProps(props) {\n if ('program' in props) {\n this.configuration = props.program && props.program.configuration;\n }\n if ('configuration' in props) {\n this.configuration = props.configuration;\n }\n if ('attributes' in props) {\n this.setAttributes(props.attributes);\n }\n if ('elements' in props) {\n this.setElementBuffer(props.elements);\n }\n if ('bindOnUse' in props) {\n props = props.bindOnUse;\n }\n return this;\n }\n\n // Automatically called if buffers changed through VertexArray API\n clearDrawParams() {\n this.drawParams = null;\n }\n\n getDrawParams() {\n // Auto deduced draw parameters\n this.drawParams = this.drawParams || this._updateDrawParams();\n\n return this.drawParams;\n }\n\n // Set (bind) an array or map of vertex array buffers, either in numbered or named locations.\n // For names that are not present in `location`, the supplied buffers will be ignored.\n // if a single buffer of type GL.ELEMENT_ARRAY_BUFFER is present, it will be set as elements\n // Signatures:\n // {attributeName: buffer}\n // {attributeName: [buffer, accessor]}\n // {attributeName: (typed) array} => constant\n setAttributes(attributes) {\n Object.assign(this.attributes, attributes);\n this.vertexArrayObject.bind(() => {\n for (const locationOrName in attributes) {\n const value = attributes[locationOrName];\n this._setAttribute(locationOrName, value);\n }\n // Make sure we don't leave any bindings\n this.gl.bindBuffer(GL.ARRAY_BUFFER, null);\n });\n\n return this;\n }\n\n // Set (bind) an elements buffer, for indexed rendering.\n // Must be a Buffer bound to GL.ELEMENT_ARRAY_BUFFER. Constants not supported\n setElementBuffer(elementBuffer = null, accessor = {}) {\n this.elements = elementBuffer; // Save value for debugging\n this.elementsAccessor = accessor;\n this.clearDrawParams();\n this.vertexArrayObject.setElementBuffer(elementBuffer, accessor);\n\n return this;\n }\n\n // Set a location in vertex attributes array to a buffer\n setBuffer(locationOrName, buffer, appAccessor = {}) {\n // Check target\n if (buffer.target === GL.ELEMENT_ARRAY_BUFFER) {\n return this.setElementBuffer(buffer, appAccessor);\n }\n\n const {location, accessor} = this._resolveLocationAndAccessor(\n locationOrName,\n buffer,\n buffer.accessor,\n appAccessor\n );\n\n if (location >= 0) {\n this.values[location] = buffer;\n this.accessors[location] = accessor;\n this.clearDrawParams();\n this.vertexArrayObject.setBuffer(location, buffer, accessor);\n }\n\n return this;\n }\n\n // Set attribute to constant value (small typed array corresponding to one vertex' worth of data)\n setConstant(locationOrName, arrayValue, appAccessor = {}) {\n const {location, accessor} = this._resolveLocationAndAccessor(\n locationOrName,\n arrayValue,\n // Ensure that size isn't taken from program for multi-column\n // attributes\n Object.assign({size: arrayValue.length}, appAccessor)\n );\n\n if (location >= 0) {\n arrayValue = this.vertexArrayObject._normalizeConstantArrayValue(arrayValue);\n\n this.values[location] = arrayValue;\n this.accessors[location] = accessor;\n this.clearDrawParams();\n\n // NOTE: We set the actual constant value later on bind. We can't set the value now since\n // constants are global and affect all other VertexArrays that have disabled attributes\n // in the same location.\n // We do disable the attribute which makes it use the global constant value at that location\n this.vertexArrayObject.enable(location, false);\n }\n\n return this;\n }\n\n // Workaround for Chrome TransformFeedback binding issue\n // If required, unbind temporarily to avoid conflicting with TransformFeedback\n unbindBuffers() {\n this.vertexArrayObject.bind(() => {\n if (this.elements) {\n this.vertexArrayObject.setElementBuffer(null);\n }\n\n // Chrome does not like buffers that are bound to several binding points,\n // so we need to offer and unbind facility\n // WebGL offers disabling, but no clear way to set a VertexArray buffer to `null`\n // So we just bind all the attributes to the dummy \"attribute zero\" buffer\n this.buffer = this.buffer || new Buffer(this.gl, {accessor: {size: 4}});\n\n for (let location = 0; location < this.vertexArrayObject.MAX_ATTRIBUTES; location++) {\n if (this.values[location] instanceof Buffer) {\n this.gl.disableVertexAttribArray(location);\n this.gl.bindBuffer(GL.ARRAY_BUFFER, this.buffer.handle);\n this.gl.vertexAttribPointer(location, 1, GL.FLOAT, false, 0, 0);\n }\n }\n });\n return this;\n }\n\n // Workaround for Chrome TransformFeedback binding issue\n // If required, rebind rebind after temporary unbind\n bindBuffers() {\n this.vertexArrayObject.bind(() => {\n if (this.elements) {\n this.setElementBuffer(this.elements);\n }\n\n for (let location = 0; location < this.vertexArrayObject.MAX_ATTRIBUTES; location++) {\n const buffer = this.values[location];\n if (buffer instanceof Buffer) {\n this.setBuffer(location, buffer);\n }\n }\n });\n return this;\n }\n\n // Bind for use\n // When a vertex array is about to be used, we must:\n // - Set constant attributes (since these are stored on the context and reset on bind)\n // - Check if we need to initialize the buffer\n bindForDraw(vertexCount, instanceCount, func) {\n let value;\n\n this.vertexArrayObject.bind(() => {\n // Make sure that any constant attributes are updated (stored on the context, not the VAO)\n // Also handles attribute 0\n this._setConstantAttributes(vertexCount, instanceCount);\n\n value = func();\n });\n\n return value;\n }\n\n // PRIVATE\n\n // Resolve locations and accessors\n _resolveLocationAndAccessor(locationOrName, value, valueAccessor, appAccessor) {\n const INVALID_RESULT = {\n location: -1,\n accessor: null\n };\n\n const {location, name} = this._getAttributeIndex(locationOrName);\n if (!Number.isFinite(location) || location < 0) {\n this.unused[locationOrName] = value;\n log.once(3, () => `unused value ${locationOrName} in ${this.id}`)();\n return INVALID_RESULT;\n }\n\n const accessInfo = this._getAttributeInfo(name || location);\n\n // Attribute location wasn't directly found.\n // Likely due to multi-location attributes (e.g. matrix)\n if (!accessInfo) {\n return INVALID_RESULT;\n }\n\n // Resolve the partial accessors into a final accessor\n const currentAccessor = this.accessors[location] || {};\n const accessor = Accessor.resolve(\n accessInfo.accessor,\n currentAccessor,\n valueAccessor,\n appAccessor\n );\n\n const {size, type} = accessor;\n assert(Number.isFinite(size) && Number.isFinite(type));\n\n return {location, accessor};\n }\n\n _getAttributeInfo(attributeName) {\n return this.configuration && this.configuration.getAttributeInfo(attributeName);\n }\n\n _getAttributeIndex(locationOrName) {\n const location = Number(locationOrName);\n if (Number.isFinite(location)) {\n return {location};\n }\n\n const multiLocation = MULTI_LOCATION_ATTRIBUTE_REGEXP.exec(locationOrName);\n const name = multiLocation ? multiLocation[1] : locationOrName;\n const locationOffset = multiLocation ? Number(multiLocation[2]) : 0;\n\n if (this.configuration) {\n return {\n location: this.configuration.getAttributeLocation(name) + locationOffset,\n name\n };\n }\n\n return {location: -1};\n }\n\n _setAttribute(locationOrName, value) {\n if (value instanceof Buffer) {\n // Signature: {attributeName: Buffer}\n this.setBuffer(locationOrName, value);\n } else if (Array.isArray(value) && value.length && value[0] instanceof Buffer) {\n // Signature: {attributeName: [buffer, accessor]}\n const buffer = value[0];\n const accessor = value[1];\n this.setBuffer(locationOrName, buffer, accessor);\n } else if (ArrayBuffer.isView(value) || Array.isArray(value)) {\n // Signature: {attributeName: constant}, constant == short (typed) array\n const constant = value;\n this.setConstant(locationOrName, constant);\n } else if (value.buffer instanceof Buffer) {\n // luma.gl v7: Support accessor objects with 'buffer' field\n // for interleaved data\n // Signature: {attributeName: {...accessor, buffer}}\n const accessor = value;\n this.setBuffer(locationOrName, accessor.buffer, accessor);\n } else {\n throw new Error(ERR_ATTRIBUTE_TYPE);\n }\n }\n\n // Updates all constant attribute values (constants are used when vertex attributes are disabled).\n // This needs to be done repeatedly since in contrast to buffer bindings,\n // constants are stored on the WebGL context, not the VAO\n _setConstantAttributes(vertexCount, instanceCount) {\n // TODO - use accessor to determine what length to use\n const elementCount = Math.max(vertexCount | 0, instanceCount | 0);\n let constant = this.values[0];\n if (ArrayBuffer.isView(constant)) {\n this._setConstantAttributeZero(constant, elementCount);\n }\n\n for (let location = 1; location < this.vertexArrayObject.MAX_ATTRIBUTES; location++) {\n constant = this.values[location];\n if (ArrayBuffer.isView(constant)) {\n this._setConstantAttribute(location, constant);\n }\n }\n }\n\n _setConstantAttributeZero(constant, elementCount) {\n if (VertexArrayObject.isSupported(this.gl, {constantAttributeZero: true})) {\n this._setConstantAttribute(0, constant);\n return;\n }\n\n // Get a dummy buffer populated with repeated constants\n const buffer = this.vertexArrayObject.getConstantBuffer(elementCount, constant);\n\n // Set the buffer on location 0\n this.vertexArrayObject.setBuffer(0, buffer, this.accessors[0]);\n }\n\n _setConstantAttribute(location, constant) {\n VertexArrayObject.setConstant(this.gl, location, constant);\n }\n\n // Walks the buffers and updates draw parameters\n _updateDrawParams() {\n const drawParams = {\n isIndexed: false,\n isInstanced: false,\n indexCount: Infinity,\n vertexCount: Infinity,\n instanceCount: Infinity\n };\n\n for (let location = 0; location < this.vertexArrayObject.MAX_ATTRIBUTES; location++) {\n this._updateDrawParamsForLocation(drawParams, location);\n }\n\n if (this.elements) {\n // indexing is autodetected - buffer with target GL.ELEMENT_ARRAY_BUFFER\n // index type is saved for drawElement calls\n drawParams.elementCount = this.elements.getElementCount(this.elements.accessor);\n drawParams.isIndexed = true;\n drawParams.indexType = this.elementsAccessor.type || this.elements.accessor.type;\n drawParams.indexOffset = this.elementsAccessor.offset || 0;\n }\n\n // Post-calculation checks\n if (drawParams.indexCount === Infinity) {\n drawParams.indexCount = 0;\n }\n if (drawParams.vertexCount === Infinity) {\n drawParams.vertexCount = 0;\n }\n if (drawParams.instanceCount === Infinity) {\n drawParams.instanceCount = 0;\n }\n\n return drawParams;\n }\n\n _updateDrawParamsForLocation(drawParams, location) {\n const value = this.values[location];\n const accessor = this.accessors[location];\n\n if (!value) {\n return;\n }\n\n // Check if instanced (whether buffer or constant)\n const {divisor} = accessor;\n const isInstanced = divisor > 0;\n drawParams.isInstanced = drawParams.isInstanced || isInstanced;\n\n if (value instanceof Buffer) {\n const buffer = value;\n\n if (isInstanced) {\n // instance attribute\n const instanceCount = buffer.getVertexCount(accessor);\n drawParams.instanceCount = Math.min(drawParams.instanceCount, instanceCount);\n } else {\n // normal attribute\n const vertexCount = buffer.getVertexCount(accessor);\n drawParams.vertexCount = Math.min(drawParams.vertexCount, vertexCount);\n }\n }\n }\n\n // DEPRECATED in v6.x - but not warnings not properly implemented\n\n setElements(elementBuffer = null, accessor = {}) {\n log.deprecated('setElements', 'setElementBuffer')();\n return this.setElementBuffer(elementBuffer, accessor);\n }\n}\n"],"mappings":";;;;;;;;;;;;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AAEA,IAAMA,kBAAkB,GACtB,yEADF;AAMA,IAAMC,+BAA+B,GAAG,2BAAxC;AAEA,IAAMC,eAAe,GAAG,CACtB,YADsB,EAEtB,YAFsB,EAGtB,eAHsB,EAItB,cAJsB,EAKtB,kBALsB,EAMtB,YANsB,EAOtB,QAPsB,EAQtB,SARsB,CAAxB;;IAWqBC,W;EACnB,qBAAYC,EAAZ,EAA2B;IAAA,IAAXC,IAAW,uEA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1B,MAAL,CAAYmC,QAAZ,CAAd;MACA,IAAML,QAAQ,GAAG,KAAK7B,SAAL,CAAekC,QAAf,CAAjB;;MAEA,IAAI,CAACT,KAAL,EAAY;QACV;MACD;;MAGD,IAAOoE,OAAP,GAAkBhE,QAAlB,CAAOgE,OAAP;MACA,IAAMR,WAAW,GAAGQ,OAAO,GAAG,CAA9B;MACA3F,UAAU,CAACmF,WAAX,GAAyBnF,UAAU,CAACmF,WAAX,IAA0BA,WAAnD;;MAEA,IAAI5D,KAAK,YAAYgB,eAArB,EAA6B;QAC3B,IAAMtC,MAAM,GAAGsB,KAAf;;QAEA,IAAI4D,WAAJ,EAAiB;UAEf,IAAMvC,aAAa,GAAG3C,MAAM,CAAC2F,cAAP,CAAsBjE,QAAtB,CAAtB;UACA3B,UAAU,CAAC4C,aAAX,GAA2B+B,IAAI,CAACkB,GAAL,CAAS7F,UAAU,CAAC4C,aAApB,EAAmCA,aAAnC,CAA3B;QACD,CAJD,MAIO;UAEL,IAAMD,WAAW,GAAG1C,MAAM,CAAC2F,cAAP,CAAsBjE,QAAtB,CAApB;UACA3B,UAAU,CAAC2C,WAAX,GAAyBgC,IAAI,CAACkB,GAAL,CAAS7F,UAAU,CAAC2C,WAApB,EAAiCA,WAAjC,CAAzB;QACD;MACF;IACF;;;WAID,uBAAiD;MAAA,IAArCjB,aAAqC,uEAArB,IAAqB;MAAA,IAAfC,QAAe,uEAAJ,EAAI;;MAC/C0B,YAAA,CAAIyC,UAAJ,CAAe,aAAf,EAA8B,kBAA9B;;MACA,OAAO,KAAK5E,gBAAL,CAAsBQ,aAAtB,EAAqCC,QAArC,CAAP;IACD"}
|
|
@@ -11,7 +11,7 @@ var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/de
|
|
|
11
11
|
|
|
12
12
|
var _attributeUtils = require("../webgl-utils/attribute-utils");
|
|
13
13
|
|
|
14
|
-
function _createForOfIteratorHelper(o, allowArrayLike) { var it
|
|
14
|
+
function _createForOfIteratorHelper(o, allowArrayLike) { var it = typeof Symbol !== "undefined" && o[Symbol.iterator] || o["@@iterator"]; if (!it) { if (Array.isArray(o) || (it = _unsupportedIterableToArray(o)) || allowArrayLike && o && typeof o.length === "number") { if (it) o = it; var i = 0; var F = function F() {}; return { s: F, n: function n() { if (i >= o.length) return { done: true }; return { done: false, value: o[i++] }; }, e: function e(_e) { throw _e; }, f: F }; } throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); } var normalCompletion = true, didErr = false, err; return { s: function s() { it = it.call(o); }, n: function n() { var step = it.next(); normalCompletion = step.done; return step; }, e: function e(_e2) { didErr = true; err = _e2; }, f: function f() { try { if (!normalCompletion && it.return != null) it.return(); } finally { if (didErr) throw err; } } }; }
|
|
15
15
|
|
|
16
16
|
function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
|
|
17
17
|
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"
|
|
1
|
+
{"version":3,"file":"debug-program-configuration.js","names":["getDebugTableForProgramConfiguration","config","table","header","id","attributeInfos","attributeInfo","glslDeclaration","getGLSLDeclaration","JSON","stringify","accessor","varyingInfos","varyingInfo","type","size","typeAndName","getCompositeGLType","name"],"sources":["../../../src/debug/debug-program-configuration.js"],"sourcesContent":["import {getCompositeGLType} from '../webgl-utils/attribute-utils';\n\nexport function getDebugTableForProgramConfiguration(config) {\n const table = {};\n\n const header = `Accessors for ${config.id}`;\n\n for (const attributeInfo of config.attributeInfos) {\n if (attributeInfo) {\n const glslDeclaration = getGLSLDeclaration(attributeInfo);\n table[`in ${glslDeclaration}`] = {[header]: JSON.stringify(attributeInfo.accessor)};\n }\n }\n\n for (const varyingInfo of config.varyingInfos) {\n if (varyingInfo) {\n const glslDeclaration = getGLSLDeclaration(varyingInfo);\n table[`out ${glslDeclaration}`] = {[header]: JSON.stringify(varyingInfo.accessor)};\n }\n }\n\n return table;\n}\n\nfunction getGLSLDeclaration(attributeInfo) {\n const {type, size} = attributeInfo.accessor;\n const typeAndName = getCompositeGLType(type, size);\n if (typeAndName) {\n return `${typeAndName.name} ${attributeInfo.name}`;\n }\n return attributeInfo.name;\n}\n"],"mappings":";;;;;;;;;;;AAAA;;;;;;;;AAEO,SAASA,oCAAT,CAA8CC,MAA9C,EAAsD;EAC3D,IAAMC,KAAK,GAAG,EAAd;EAEA,IAAMC,MAAM,2BAAoBF,MAAM,CAACG,EAA3B,CAAZ;;EAH2D,2CAK/BH,MAAM,CAACI,cALwB;EAAA;;EAAA;IAK3D,oDAAmD;MAAA,IAAxCC,aAAwC;;MACjD,IAAIA,aAAJ,EAAmB;QACjB,IAAMC,eAAe,GAAGC,kBAAkB,CAACF,aAAD,CAA1C;QACAJ,KAAK,cAAOK,eAAP,EAAL,qCAAmCJ,MAAnC,EAA4CM,IAAI,CAACC,SAAL,CAAeJ,aAAa,CAACK,QAA7B,CAA5C;MACD;IACF;EAV0D;IAAA;EAAA;IAAA;EAAA;;EAAA,4CAYjCV,MAAM,CAACW,YAZ0B;EAAA;;EAAA;IAY3D,uDAA+C;MAAA,IAApCC,WAAoC;;MAC7C,IAAIA,WAAJ,EAAiB;QACf,IAAMN,gBAAe,GAAGC,kBAAkB,CAACK,WAAD,CAA1C;;QACAX,KAAK,eAAQK,gBAAR,EAAL,qCAAoCJ,MAApC,EAA6CM,IAAI,CAACC,SAAL,CAAeG,WAAW,CAACF,QAA3B,CAA7C;MACD;IACF;EAjB0D;IAAA;EAAA;IAAA;EAAA;;EAmB3D,OAAOT,KAAP;AACD;;AAED,SAASM,kBAAT,CAA4BF,aAA5B,EAA2C;EACzC,4BAAqBA,aAAa,CAACK,QAAnC;EAAA,IAAOG,IAAP,yBAAOA,IAAP;EAAA,IAAaC,IAAb,yBAAaA,IAAb;EACA,IAAMC,WAAW,GAAG,IAAAC,kCAAA,EAAmBH,IAAnB,EAAyBC,IAAzB,CAApB;;EACA,IAAIC,WAAJ,EAAiB;IACf,iBAAUA,WAAW,CAACE,IAAtB,cAA8BZ,aAAa,CAACY,IAA5C;EACD;;EACD,OAAOZ,aAAa,CAACY,IAArB;AACD"}
|
|
@@ -13,7 +13,7 @@ var _assert = require("../utils/assert");
|
|
|
13
13
|
|
|
14
14
|
var _formatValue = require("../utils/format-value");
|
|
15
15
|
|
|
16
|
-
function _createForOfIteratorHelper(o, allowArrayLike) { var it
|
|
16
|
+
function _createForOfIteratorHelper(o, allowArrayLike) { var it = typeof Symbol !== "undefined" && o[Symbol.iterator] || o["@@iterator"]; if (!it) { if (Array.isArray(o) || (it = _unsupportedIterableToArray(o)) || allowArrayLike && o && typeof o.length === "number") { if (it) o = it; var i = 0; var F = function F() {}; return { s: F, n: function n() { if (i >= o.length) return { done: true }; return { done: false, value: o[i++] }; }, e: function e(_e) { throw _e; }, f: F }; } throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); } var normalCompletion = true, didErr = false, err; return { s: function s() { it = it.call(o); }, n: function n() { var step = it.next(); normalCompletion = step.done; return step; }, e: function e(_e2) { didErr = true; err = _e2; }, f: function f() { try { if (!normalCompletion && it.return != null) it.return(); } finally { if (didErr) throw err; } } }; }
|
|
17
17
|
|
|
18
18
|
function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
|
|
19
19
|
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"
|
|
1
|
+
{"version":3,"file":"debug-uniforms.js","names":["getDebugTableForUniforms","header","program","uniforms","undefinedOnly","assert","SHADER_MODULE_UNIFORM_REGEXP","PROJECT_MODULE_UNIFORM_REGEXP","uniformLocations","_uniformSetters","table","uniformNames","Object","keys","sort","count","uniformName","match","addUniformToTable","unusedCount","unusedTable","uniform","Type","formatValue","value","isDefined","isUniformDefined","undefined"],"sources":["../../../src/debug/debug-uniforms.js"],"sourcesContent":["import {assert} from '../utils/assert';\nimport {formatValue} from '../utils/format-value';\n\n// Prepares a table suitable for console.table\n/* eslint-disable max-statements, complexity */\nexport function getDebugTableForUniforms({\n header = 'Uniforms',\n program,\n uniforms,\n undefinedOnly = false\n}) {\n assert(program);\n\n const SHADER_MODULE_UNIFORM_REGEXP = '.*_.*';\n const PROJECT_MODULE_UNIFORM_REGEXP = '.*Matrix'; // TODO - Use explicit list\n\n const uniformLocations = program._uniformSetters;\n const table = {}; // {[header]: {}};\n\n // Add program's provided uniforms (in alphabetical order)\n const uniformNames = Object.keys(uniformLocations).sort();\n\n let count = 0;\n\n // First add non-underscored uniforms (assumed not coming from shader modules)\n for (const uniformName of uniformNames) {\n if (\n !uniformName.match(SHADER_MODULE_UNIFORM_REGEXP) &&\n !uniformName.match(PROJECT_MODULE_UNIFORM_REGEXP)\n ) {\n if (addUniformToTable({table, header, uniforms, uniformName, undefinedOnly})) {\n count++;\n }\n }\n }\n\n // add underscored uniforms (assumed from shader modules)\n for (const uniformName of uniformNames) {\n if (uniformName.match(PROJECT_MODULE_UNIFORM_REGEXP)) {\n if (addUniformToTable({table, header, uniforms, uniformName, undefinedOnly})) {\n count++;\n }\n }\n }\n\n for (const uniformName of uniformNames) {\n if (!table[uniformName]) {\n if (addUniformToTable({table, header, uniforms, uniformName, undefinedOnly})) {\n count++;\n }\n }\n }\n\n // Create a table of unused uniforms\n let unusedCount = 0;\n const unusedTable = {};\n if (!undefinedOnly) {\n for (const uniformName in uniforms) {\n const uniform = uniforms[uniformName];\n if (!table[uniformName]) {\n unusedCount++;\n unusedTable[uniformName] = {\n Type: `NOT USED: ${uniform}`,\n [header]: formatValue(uniform)\n };\n }\n }\n }\n\n return {table, count, unusedTable, unusedCount};\n}\n\n// Helper\nfunction addUniformToTable({table, header, uniforms, uniformName, undefinedOnly}) {\n const value = uniforms[uniformName];\n const isDefined = isUniformDefined(value);\n if (!undefinedOnly || !isDefined) {\n table[uniformName] = {\n // Add program's unprovided uniforms\n [header]: isDefined ? formatValue(value) : 'N/A',\n 'Uniform Type': isDefined ? value : 'NOT PROVIDED'\n };\n return true;\n }\n return false;\n}\n\nfunction isUniformDefined(value) {\n return value !== undefined && value !== null;\n}\n"],"mappings":";;;;;;;;;;;AAAA;;AACA;;;;;;;;AAIO,SAASA,wBAAT,OAKJ;EAAA,uBAJDC,MAIC;EAAA,IAJDA,MAIC,4BAJQ,UAIR;EAAA,IAHDC,OAGC,QAHDA,OAGC;EAAA,IAFDC,QAEC,QAFDA,QAEC;EAAA,8BADDC,aACC;EAAA,IADDA,aACC,mCADe,KACf;EACD,IAAAC,cAAA,EAAOH,OAAP;EAEA,IAAMI,4BAA4B,GAAG,OAArC;EACA,IAAMC,6BAA6B,GAAG,UAAtC;EAEA,IAAMC,gBAAgB,GAAGN,OAAO,CAACO,eAAjC;EACA,IAAMC,KAAK,GAAG,EAAd;EAGA,IAAMC,YAAY,GAAGC,MAAM,CAACC,IAAP,CAAYL,gBAAZ,EAA8BM,IAA9B,EAArB;EAEA,IAAIC,KAAK,GAAG,CAAZ;;EAZC,2CAeyBJ,YAfzB;EAAA;;EAAA;IAeD,oDAAwC;MAAA,IAA7BK,YAA6B;;MACtC,IACE,CAACA,YAAW,CAACC,KAAZ,CAAkBX,4BAAlB,CAAD,IACA,CAACU,YAAW,CAACC,KAAZ,CAAkBV,6BAAlB,CAFH,EAGE;QACA,IAAIW,iBAAiB,CAAC;UAACR,KAAK,EAALA,KAAD;UAAQT,MAAM,EAANA,MA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