@luma.gl/webgl 8.5.15 → 8.5.17
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 +692 -816
- package/dist/dist.min.js +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.js +37 -39
- package/dist/es5/classes/renderbuffer.js.map +1 -1
- package/dist/es5/classes/resource.js +29 -32
- 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.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/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-vertex-array.js.map +1 -1
- package/dist/es5/features/features.js +2 -2
- package/dist/es5/features/index.js +16 -16
- package/dist/es5/features/limits.js +1 -1
- package/dist/es5/glsl-utils/format-glsl-error.js.map +1 -1
- package/dist/es5/glsl-utils/index.js +11 -7
- package/dist/es5/index.js +104 -104
- 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/check-props.js.map +1 -1
- package/dist/es5/utils/format-value.js.map +1 -1
- package/dist/es5/utils/load-file.js +1 -1
- package/dist/es5/utils/utils.js +2 -2
- 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/get-error.js +1 -1
- package/dist/es5/webgl-utils/request-animation-frame.js +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/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.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.js +25 -19
- package/dist/esm/classes/renderbuffer.js.map +1 -1
- package/dist/esm/classes/resource.js +39 -28
- 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.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/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/webgl-features-table.js +1 -1
- package/dist/esm/features/webgl-features-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/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/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/get-error.js +1 -1
- package/dist/esm/webgl-utils/get-error.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/resource.js +11 -19
- 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/vertex-array-object.js"],"names":["Resource","Buffer","isWebGL2","getScratchArray","fillArray","assert","getBrowser","ERR_ELEMENTS","VertexArrayObject","Symbol","toStringTag","isSupported","gl","options","constantAttributeZero","getDefaultArray","luma","defaultVertexArray","handle","isDefaultArray","getMaxAttributes","MAX_ATTRIBUTES","getParameter","setConstant","location","array","constructor","Float32Array","_setConstantFloatArray","Int32Array","_setConstantIntArray","Uint32Array","_setConstantUintArray","opts","id","program","Object","assign","buffer","bufferValue","gl2","initialize","seal","delete","props","setProps","setElementBuffer","elementBuffer","target","bind","bindBuffer","setBuffer","accessor","size","type","stride","offset","normalized","integer","divisor","Number","vertexAttribIPointer","vertexAttribPointer","enableVertexAttribArray","vertexAttribDivisor","enable","disablingAttributeZero","disableVertexAttribArray","getConstantBuffer","elementCount","value","constantValue","_normalizeConstantArrayValue","byteLength","length","updateNeeded","reallocate","_compareConstantArrayValues","typedArray","source","start","count","subData","arrayValue","Array","isArray","v1","v2","i","vertexAttrib1fv","vertexAttrib2fv","vertexAttrib3fv","vertexAttrib4fv","vertexAttribI1iv","vertexAttribI2iv","vertexAttribI3iv","vertexAttribI4iv","vertexAttribI1uiv","vertexAttribI2uiv","vertexAttribI3uiv","vertexAttribI4uiv","_createHandle","createVertexArray","_deleteHandle","deleteVertexArray","elements","_bindHandle","bindVertexArray","_getParameter","pname","isFinite","getVertexAttribOffset","getVertexAttrib"],"mappings":"AACA,OAAOA,QAAP,MAAqB,YAArB;AACA,OAAOC,MAAP,MAAmB,UAAnB;AACA,SAAQC,QAAR,QAAuB,kBAAvB;AACA,SAAQC,eAAR,EAAyBC,SAAzB,QAAyC,2BAAzC;AACA,SAAQC,MAAR,QAAqB,iBAArB;AACA,SAAQC,UAAR,QAAyB,UAAzB;AAEA,MAAMC,YAAY,GAAG,0CAArB;AAEA,eAAe,MAAMC,iBAAN,SAAgCR,QAAhC,CAAyC;AAEtD,OAAKS,MAAM,CAACC,WAAZ,IAA2B;AACzB,WAAO,mBAAP;AACD;;AACD,SAAOC,WAAP,CAAmBC,EAAnB,EAAuBC,OAAO,GAAG,EAAjC,EAAqC;AAGnC,QAAIA,OAAO,CAACC,qBAAZ,EAAmC;AACjC,aAAOZ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AA,MAAM,CAAC,KAAD,CAAN;AAdJ;AAgBD;;AAIDgG,EAAAA,aAAa,GAAG;AAGd,UAAM7D,GAAG,GAAG,KAAK5B,EAAjB;AACA,WAAO4B,GAAG,CAAC8D,iBAAJ,EAAP;AACD;;AAEDC,EAAAA,aAAa,CAACrF,MAAD,EAAS;AACpB,SAAKsB,GAAL,CAASgE,iBAAT,CAA2BtF,MAA3B;AAEA,WAAO,CAAC,KAAKuF,QAAN,CAAP;AAED;;AAEDC,EAAAA,WAAW,CAACxF,MAAD,EAAS;AAClB,SAAKsB,GAAL,CAASmE,eAAT,CAAyBzF,MAAzB;AACD;;AAGD0F,EAAAA,aAAa,CAACC,KAAD,EAAQ;AAACrF,IAAAA;AAAD,GAAR,EAAoB;AAC/BnB,IAAAA,MAAM,CAACuD,MAAM,CAACkD,QAAP,CAAgBtF,QAAhB,CAAD,CAAN;AACA,WAAO,KAAKyB,IAAL,CAAU,MAAM;AACrB,cAAQ4D,KAAR;AACE;AACE,iBAAO,KAAKjG,EAAL,CAAQmG,qBAAR,CAA8BvF,QAA9B,EAAwCqF,KAAxC,CAAP;;AACF;AACE,iBAAO,KAAKjG,EAAL,CAAQoG,eAAR,CAAwBxF,QAAxB,EAAkCqF,KAAlC,CAAP;AAJJ;AAMD,KAPM,CAAP;AAQD;;AArTqD","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,"sources":["../../../src/classes/vertex-array-object.js"],"names":["Resource","Buffer","isWebGL2","getScratchArray","fillArray","assert","getBrowser","ERR_ELEMENTS","VertexArrayObject","Symbol","toStringTag","isSupported","gl","options","constantAttributeZero","getDefaultArray","luma","defaultVertexArray","handle","isDefaultArray","getMaxAttributes","MAX_ATTRIBUTES","getParameter","setConstant","location","array","constructor","Float32Array","_setConstantFloatArray","Int32Array","_setConstantIntArray","Uint32Array","_setConstantUintArray","opts","id","program","Object","assign","buffer","bufferValue","gl2","initialize","seal","delete","props","setProps","setElementBuffer","elementBuffer","target","bind","bindBuffer","setBuffer","accessor","size","type","stride","offset","normalized","integer","divisor","Number","vertexAttribIPointer","vertexAttribPointer","enableVertexAttribArray","vertexAttribDivisor","enable","disablingAttributeZero","disableVertexAttribArray","getConstantBuffer","elementCount","value","constantValue","_normalizeConstantArrayValue","byteLength","length","updateNeeded","reallocate","_compareConstantArrayValues","typedArray","source","start","count","subData","arrayValue","Array","isArray","v1","v2","i","vertexAttrib1fv","vertexAttrib2fv","vertexAttrib3fv","vertexAttrib4fv","vertexAttribI1iv","vertexAttribI2iv","vertexAttribI3iv","vertexAttribI4iv","vertexAttribI1uiv","vertexAttribI2uiv","vertexAttribI3uiv","vertexAttribI4uiv","_createHandle","createVertexArray","_deleteHandle","deleteVertexArray","elements","_bindHandle","bindVertexArray","_getParameter","pname","isFinite","getVertexAttribOffset","getVertexAttrib"],"mappings":"AACA,OAAOA,QAAP,MAAqB,YAArB;AACA,OAAOC,MAAP,MAAmB,UAAnB;AACA,SAAQC,QAAR,QAAuB,kBAAvB;AACA,SAAQC,eAAR,EAAyBC,SAAzB,QAAyC,2BAAzC;AACA,SAAQC,MAAR,QAAqB,iBAArB;AACA,SAAQC,UAAR,QAAyB,eAAzB;AAEA,MAAMC,YAAY,GAAG,0CAArB;AAEA,eAAe,MAAMC,iBAAN,SAAgCR,QAAhC,CAAyC;AAE/B,OAAlBS,MAAM,CAACC,WAAW,IAAI;AACzB,WAAO,mBAAP;AACD;;AACiB,SAAXC,WAAW,CAACC,EAAD,EAAmB;AAAA,QAAdC,OAAc,uEAAJ,EAAI;;AAGnC,QAAIA,OAAO,CAACC,qBAAZ,EAAmC;AACjC,aAAOZ,QAAQ,CAACU,EAAD,CAAR,IAAgBN,UAAU,OAAO,QAAxC;AACD;;AAGD,WAAO,IAAP;AACD;;AAIqB,SAAfS,eAAe,CAACH,EAAD,EAAK;AACzBA,IAAAA,EAAE,CAACI,IAAH,GAAUJ,EAAE,CAACI,I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;;AAEDC,EAAAA,aAAa,CAACrF,MAAD,EAAS;AACpB,SAAKsB,GAAL,CAASgE,iBAAT,CAA2BtF,MAA3B;AAEA,WAAO,CAAC,KAAKuF,QAAN,CAAP;AAED;;AAEDC,EAAAA,WAAW,CAACxF,MAAD,EAAS;AAClB,SAAKsB,GAAL,CAASmE,eAAT,CAAyBzF,MAAzB;AACD;;AAGD0F,EAAAA,aAAa,CAACC,KAAD,QAAoB;AAAA,QAAZ;AAACrF,MAAAA;AAAD,KAAY;AAC/BnB,IAAAA,MAAM,CAACuD,MAAM,CAACkD,QAAP,CAAgBtF,QAAhB,CAAD,CAAN;AACA,WAAO,KAAKyB,IAAL,CAAU,MAAM;AACrB,cAAQ4D,KAAR;AACE;AACE,iBAAO,KAAKjG,EAAL,CAAQmG,qBAAR,CAA8BvF,QAA9B,EAAwCqF,KAAxC,CAAP;;AACF;AACE,iBAAO,KAAKjG,EAAL,CAAQoG,eAAR,CAAwBxF,QAAxB,EAAkCqF,KAAlC,CAAP;AAJJ;AAMD,KAPM,CAAP;AAQD;;AArTqD","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"],"file":"vertex-array-object.js"}
|
|
@@ -8,7 +8,8 @@ const ERR_ATTRIBUTE_TYPE = 'VertexArray: attributes must be Buffers or constants
|
|
|
8
8
|
const MULTI_LOCATION_ATTRIBUTE_REGEXP = /^(.+)__LOCATION_([0-9]+)$/;
|
|
9
9
|
const DEPRECATIONS_V6 = ['setBuffers', 'setGeneric', 'clearBindings', 'setLocations', 'setGenericValues', 'setDivisor', 'enable', 'disable'];
|
|
10
10
|
export default class VertexArray {
|
|
11
|
-
constructor(gl
|
|
11
|
+
constructor(gl) {
|
|
12
|
+
let opts = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
|
|
12
13
|
const id = opts.id || opts.program && opts.program.id;
|
|
13
14
|
this.id = id;
|
|
14
15
|
this.gl = gl;
|
|
@@ -35,7 +36,8 @@ export default class VertexArray {
|
|
|
35
36
|
this.vertexArrayObject.delete();
|
|
36
37
|
}
|
|
37
38
|
|
|
38
|
-
initialize(
|
|
39
|
+
initialize() {
|
|
40
|
+
let props = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
|
|
39
41
|
this.reset();
|
|
40
42
|
this.configuration = null;
|
|
41
43
|
this.bindOnUse = false;
|
|
@@ -102,7 +104,9 @@ export default class VertexArray {
|
|
|
102
104
|
return this;
|
|
103
105
|
}
|
|
104
106
|
|
|
105
|
-
setElementBuffer(
|
|
107
|
+
setElementBuffer() {
|
|
108
|
+
let elementBuffer = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : null;
|
|
109
|
+
let accessor = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
|
|
106
110
|
this.elements = elementBuffer;
|
|
107
111
|
this.elementsAccessor = accessor;
|
|
108
112
|
this.clearDrawParams();
|
|
@@ -110,7 +114,9 @@ export default class VertexArray {
|
|
|
110
114
|
return this;
|
|
111
115
|
}
|
|
112
116
|
|
|
113
|
-
setBuffer(locationOrName, buffer
|
|
117
|
+
setBuffer(locationOrName, buffer) {
|
|
118
|
+
let appAccessor = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};
|
|
119
|
+
|
|
114
120
|
if (buffer.target === 34963) {
|
|
115
121
|
return this.setElementBuffer(buffer, appAccessor);
|
|
116
122
|
}
|
|
@@ -130,7 +136,9 @@ export default class VertexArray {
|
|
|
130
136
|
return this;
|
|
131
137
|
}
|
|
132
138
|
|
|
133
|
-
setConstant(locationOrName, arrayValue
|
|
139
|
+
setConstant(locationOrName, arrayValue) {
|
|
140
|
+
let appAccessor = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};
|
|
141
|
+
|
|
134
142
|
const {
|
|
135
143
|
location,
|
|
136
144
|
accessor
|
|
@@ -212,7 +220,7 @@ export default class VertexArray {
|
|
|
212
220
|
|
|
213
221
|
if (!Number.isFinite(location) || location < 0) {
|
|
214
222
|
this.unused[locationOrName] = value;
|
|
215
|
-
log.once(3, () =>
|
|
223
|
+
log.once(3, () => "unused value ".concat(locationOrName, " in ").concat(this.id))();
|
|
216
224
|
return INVALID_RESULT;
|
|
217
225
|
}
|
|
218
226
|
|
|
@@ -378,7 +386,9 @@ export default class VertexArray {
|
|
|
378
386
|
}
|
|
379
387
|
}
|
|
380
388
|
|
|
381
|
-
setElements(
|
|
389
|
+
setElements() {
|
|
390
|
+
let elementBuffer = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : null;
|
|
391
|
+
let accessor = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
|
|
382
392
|
log.deprecated('setElements', 'setElementBuffer')();
|
|
383
393
|
return this.setElementBuffer(elementBuffer, accessor);
|
|
384
394
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/classes/vertex-array.js"],"names":["log","Accessor","Buffer","VertexArrayObject","assert","stubRemovedMethods","ERR_ATTRIBUTE_TYPE","MULTI_LOCATION_ATTRIBUTE_REGEXP","DEPRECATIONS_V6","VertexArray","constructor","gl","opts","id","program","configuration","elements","elementsAccessor","values","accessors","unused","drawParams","buffer","attributes","vertexArrayObject","initialize","Object","seal","delete","props","reset","bindOnUse","setProps","MAX_ATTRIBUTES","Array","fill","setAttributes","setElementBuffer","clearDrawParams","getDrawParams","_updateDrawParams","assign","bind","locationOrName","value","_setAttribute","bindBuffer","elementBuffer","accessor","setBuffer","appAccessor","target","location","_resolveLocationAndAccessor","setConstant","arrayValue","size","length","_normalizeConstantArrayValue","enable","unbindBuffers","disableVertexAttribArray","handle","vertexAttribPointer","bindBuffers","bindForDraw","vertexCount","instanceCount","func","_setConstantAttributes","valueAccessor","INVALID_RESULT","name","_getAttributeIndex","Number","isFinite","once","accessInfo","_getAttributeInfo","currentAccessor","resolve","type","attributeName","getAttributeInfo","multiLocation","exec","locationOffset","getAttributeLocation","isArray","ArrayBuffer","isView","constant","Error","elementCount","Math","max","_setConstantAttributeZero","_setConstantAttribute","isSupported","constantAttributeZero","getConstantBuffer","isIndexed","isInstanced","indexCount","Infinity","_updateDrawParamsForLocation","getElementCount","indexType","indexOffset","offset","divisor","getVertexCount","min","setElements","deprecated"],"mappings":"AACA,SAAQA,GAAR,QAAkB,kBAAlB;AACA,OAAOC,QAAP,MAAqB,YAArB;AACA,OAAOC,MAAP,MAAmB,UAAnB;AACA,OAAOC,iBAAP,MAA8B,uBAA9B;AACA,SAAQC,MAAR,QAAqB,iBAArB;AACA,SAAQC,kBAAR,QAAiC,uBAAjC;AAEA,MAAMC,kBAAkB,GACtB,yEADF;AAMA,MAAMC,+BAA+B,GAAG,2BAAxC;AAEA,MAAMC,eAAe,GAAG,CACtB,YADsB,EAEtB,YAFsB,EAGtB,eAHsB,EAItB,cAJsB,EAKtB,kBALsB,EAMtB,YANsB,EAOtB,QAPsB,EAQtB,SARsB,CAAxB;AAWA,eAAe,MAAMC,WAAN,CAAkB;AAC/BC,EAAAA,WAAW,CAACC,EAAD,EAAKC,IAAI,GAAG,EAAZ,EAAgB;AAEzB,UAAMC,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,IAAIrB,iBAAJ,CAAsBQ,EAAtB,CAAzB;AAGAN,IAAAA,kBAAkB,CAAC,IAAD,EAAO,aAAP,EAA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,CAAtB;AACA3B,QAAAA,UAAU,CAAC8C,aAAX,GAA2B2B,IAAI,CAACkB,GAAL,CAAS3F,UAAU,CAAC8C,aAApB,EAAmCA,aAAnC,CAA3B;AACD,OAJD,MAIO;AAEL,cAAMD,WAAW,GAAG5C,MAAM,CAACyF,cAAP,CAAsB/D,QAAtB,CAApB;AACA3B,QAAAA,UAAU,CAAC6C,WAAX,GAAyB4B,IAAI,CAACkB,GAAL,CAAS3F,UAAU,CAAC6C,WAApB,EAAiCA,WAAjC,CAAzB;AACD;AACF;AACF;;AAID+C,EAAAA,WAAW,CAAClE,aAAa,GAAG,IAAjB,EAAuBC,QAAQ,GAAG,EAAlC,EAAsC;AAC/ChD,IAAAA,GAAG,CAACkH,UAAJ,CAAe,aAAf,EAA8B,kBAA9B;AACA,WAAO,KAAK7E,gBAAL,CAAsBU,aAAtB,EAAqCC,QAArC,CAAP;AACD;;AA9a8B","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,"sources":["../../../src/classes/vertex-array.js"],"names":["log","Accessor","Buffer","VertexArrayObject","assert","stubRemovedMethods","ERR_ATTRIBUTE_TYPE","MULTI_LOCATION_ATTRIBUTE_REGEXP","DEPRECATIONS_V6","VertexArray","constructor","gl","opts","id","program","configuration","elements","elementsAccessor","values","accessors","unused","drawParams","buffer","attributes","vertexArrayObject","initialize","Object","seal","delete","props","reset","bindOnUse","setProps","MAX_ATTRIBUTES","Array","fill","setAttributes","setElementBuffer","clearDrawParams","getDrawParams","_updateDrawParams","assign","bind","locationOrName","value","_setAttribute","bindBuffer","elementBuffer","accessor","setBuffer","appAccessor","target","location","_resolveLocationAndAccessor","setConstant","arrayValue","size","length","_normalizeConstantArrayValue","enable","unbindBuffers","disableVertexAttribArray","handle","vertexAttribPointer","bindBuffers","bindForDraw","vertexCount","instanceCount","func","_setConstantAttributes","valueAccessor","INVALID_RESULT","name","_getAttributeIndex","Number","isFinite","once","accessInfo","_getAttributeInfo","currentAccessor","resolve","type","attributeName","getAttributeInfo","multiLocation","exec","locationOffset","getAttributeLocation","isArray","ArrayBuffer","isView","constant","Error","elementCount","Math","max","_setConstantAttributeZero","_setConstantAttribute","isSupported","constantAttributeZero","getConstantBuffer","isIndexed","isInstanced","indexCount","Infinity","_updateDrawParamsForLocation","getElementCount","indexType","indexOffset","offset","divisor","getVertexCount","min","setElements","deprecated"],"mappings":"AACA,SAAQA,GAAR,QAAkB,kBAAlB;AACA,OAAOC,QAAP,MAAqB,YAArB;AACA,OAAOC,MAAP,MAAmB,UAAnB;AACA,OAAOC,iBAAP,MAA8B,uBAA9B;AACA,SAAQC,MAAR,QAAqB,iBAArB;AACA,SAAQC,kBAAR,QAAiC,uBAAjC;AAEA,MAAMC,kBAAkB,GACtB,yEADF;AAMA,MAAMC,+BAA+B,GAAG,2BAAxC;AAEA,MAAMC,eAAe,GAAG,CACtB,YADsB,EAEtB,YAFsB,EAGtB,eAHsB,EAItB,cAJsB,EAKtB,kBALsB,EAMtB,YANsB,EAOtB,QAPsB,EAQtB,SARsB,CAAxB;AAWA,eAAe,MAAMC,WAAN,CAAkB;AAC/BC,EAAAA,WAAW,CAACC,EAAD,EAAgB;AAAA,QAAXC,IAAW,uEAAJ,EAAI;AAEzB,UAAMC,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,IAAIrB,iBAAJ,CAAsBQ,EAAtB,CAAzB;AAGAN,IAAAA,kBAAkB,CAAC,IAAD,EAAO,aAAP,EAAsB,MAAtB,EAA8BG,eAA9B,CAAlB;AAEA,SAA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B,CAAtB;AACA3B,QAAAA,UAAU,CAAC8C,aAAX,GAA2B2B,IAAI,CAACkB,GAAL,CAAS3F,UAAU,CAAC8C,aAApB,EAAmCA,aAAnC,CAA3B;AACD,OAJD,MAIO;AAEL,cAAMD,WAAW,GAAG5C,MAAM,CAACyF,cAAP,CAAsB/D,QAAtB,CAApB;AACA3B,QAAAA,UAAU,CAAC6C,WAAX,GAAyB4B,IAAI,CAACkB,GAAL,CAAS3F,UAAU,CAAC6C,WAApB,EAAiCA,WAAjC,CAAzB;AACD;AACF;AACF;;AAID+C,EAAAA,WAAW,GAAsC;AAAA,QAArClE,aAAqC,uEAArB,IAAqB;AAAA,QAAfC,QAAe,uEAAJ,EAAI;AAC/ChD,IAAAA,GAAG,CAACkH,UAAJ,CAAe,aAAf,EAA8B,kBAA9B;AACA,WAAO,KAAK7E,gBAAL,CAAsBU,aAAtB,EAAqCC,QAArC,CAAP;AACD;;AA9a8B","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,12 +1,12 @@
|
|
|
1
1
|
import { getCompositeGLType } from '../webgl-utils/attribute-utils';
|
|
2
2
|
export function getDebugTableForProgramConfiguration(config) {
|
|
3
3
|
const table = {};
|
|
4
|
-
const header =
|
|
4
|
+
const header = "Accessors for ".concat(config.id);
|
|
5
5
|
|
|
6
6
|
for (const attributeInfo of config.attributeInfos) {
|
|
7
7
|
if (attributeInfo) {
|
|
8
8
|
const glslDeclaration = getGLSLDeclaration(attributeInfo);
|
|
9
|
-
table[
|
|
9
|
+
table["in ".concat(glslDeclaration)] = {
|
|
10
10
|
[header]: JSON.stringify(attributeInfo.accessor)
|
|
11
11
|
};
|
|
12
12
|
}
|
|
@@ -15,7 +15,7 @@ export function getDebugTableForProgramConfiguration(config) {
|
|
|
15
15
|
for (const varyingInfo of config.varyingInfos) {
|
|
16
16
|
if (varyingInfo) {
|
|
17
17
|
const glslDeclaration = getGLSLDeclaration(varyingInfo);
|
|
18
|
-
table[
|
|
18
|
+
table["out ".concat(glslDeclaration)] = {
|
|
19
19
|
[header]: JSON.stringify(varyingInfo.accessor)
|
|
20
20
|
};
|
|
21
21
|
}
|
|
@@ -32,7 +32,7 @@ function getGLSLDeclaration(attributeInfo) {
|
|
|
32
32
|
const typeAndName = getCompositeGLType(type, size);
|
|
33
33
|
|
|
34
34
|
if (typeAndName) {
|
|
35
|
-
return
|
|
35
|
+
return "".concat(typeAndName.name, " ").concat(attributeInfo.name);
|
|
36
36
|
}
|
|
37
37
|
|
|
38
38
|
return attributeInfo.name;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/debug/debug-program-configuration.js"],"names":["getCompositeGLType","getDebugTableForProgramConfiguration","config","table","header","id","attributeInfo","attributeInfos","glslDeclaration","getGLSLDeclaration","JSON","stringify","accessor","varyingInfo","varyingInfos","type","size","typeAndName","name"],"mappings":"AAAA,SAAQA,kBAAR,QAAiC,gCAAjC;AAEA,OAAO,SAASC,oCAAT,CAA8CC,MAA9C,EAAsD;AAC3D,QAAMC,KAAK,GAAG,EAAd;AAEA,QAAMC,MAAM,
|
|
1
|
+
{"version":3,"sources":["../../../src/debug/debug-program-configuration.js"],"names":["getCompositeGLType","getDebugTableForProgramConfiguration","config","table","header","id","attributeInfo","attributeInfos","glslDeclaration","getGLSLDeclaration","JSON","stringify","accessor","varyingInfo","varyingInfos","type","size","typeAndName","name"],"mappings":"AAAA,SAAQA,kBAAR,QAAiC,gCAAjC;AAEA,OAAO,SAASC,oCAAT,CAA8CC,MAA9C,EAAsD;AAC3D,QAAMC,KAAK,GAAG,EAAd;AAEA,QAAMC,MAAM,2BAAoBF,MAAM,CAACG,EAA3B,CAAZ;;AAEA,OAAK,MAAMC,aAAX,IAA4BJ,MAAM,CAACK,cAAnC,EAAmD;AACjD,QAAID,aAAJ,EAAmB;AACjB,YAAME,eAAe,GAAGC,kBAAkB,CAACH,aAAD,CAA1C;AACAH,MAAAA,KAAK,cAAOK,eAAP,EAAL,GAAiC;AAAC,SAACJ,MAAD,GAAUM,IAAI,CAACC,SAAL,CAAeL,aAAa,CAACM,QAA7B;AAAX,OAAjC;AACD;AACF;;AAED,OAAK,MAAMC,WAAX,IAA0BX,MAAM,CAACY,YAAjC,EAA+C;AAC7C,QAAID,WAAJ,EAAiB;AACf,YAAML,eAAe,GAAGC,kBAAkB,CAACI,WAAD,CAA1C;AACAV,MAAAA,KAAK,eAAQK,eAAR,EAAL,GAAkC;AAAC,SAACJ,MAAD,GAAUM,IAAI,CAACC,SAAL,CAAeE,WAAW,CAACD,QAA3B;AAAX,OAAlC;AACD;AACF;;AAED,SAAOT,KAAP;AACD;;AAED,SAASM,kBAAT,CAA4BH,aAA5B,EAA2C;AACzC,QAAM;AAACS,IAAAA,IAAD;AAAOC,IAAAA;AAAP,MAAeV,aAAa,CAACM,QAAnC;AACA,QAAMK,WAAW,GAAGjB,kBAAkB,CAACe,IAAD,EAAOC,IAAP,CAAtC;;AACA,MAAIC,WAAJ,EAAiB;AACf,qBAAUA,WAAW,CAACC,IAAtB,cAA8BZ,aAAa,CAACY,IAA5C;AACD;;AACD,SAAOZ,aAAa,CAACY,IAArB;AACD","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"],"file":"debug-program-configuration.js"}
|
|
@@ -1,11 +1,12 @@
|
|
|
1
1
|
import { assert } from '../utils/assert';
|
|
2
2
|
import { formatValue } from '../utils/format-value';
|
|
3
|
-
export function getDebugTableForUniforms({
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
3
|
+
export function getDebugTableForUniforms(_ref) {
|
|
4
|
+
let {
|
|
5
|
+
header = 'Uniforms',
|
|
6
|
+
program,
|
|
7
|
+
uniforms,
|
|
8
|
+
undefinedOnly = false
|
|
9
|
+
} = _ref;
|
|
9
10
|
assert(program);
|
|
10
11
|
const SHADER_MODULE_UNIFORM_REGEXP = '.*_.*';
|
|
11
12
|
const PROJECT_MODULE_UNIFORM_REGEXP = '.*Matrix';
|
|
@@ -66,7 +67,7 @@ export function getDebugTableForUniforms({
|
|
|
66
67
|
if (!table[uniformName]) {
|
|
67
68
|
unusedCount++;
|
|
68
69
|
unusedTable[uniformName] = {
|
|
69
|
-
Type:
|
|
70
|
+
Type: "NOT USED: ".concat(uniform),
|
|
70
71
|
[header]: formatValue(uniform)
|
|
71
72
|
};
|
|
72
73
|
}
|
|
@@ -81,13 +82,14 @@ export function getDebugTableForUniforms({
|
|
|
81
82
|
};
|
|
82
83
|
}
|
|
83
84
|
|
|
84
|
-
function addUniformToTable({
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
85
|
+
function addUniformToTable(_ref2) {
|
|
86
|
+
let {
|
|
87
|
+
table,
|
|
88
|
+
header,
|
|
89
|
+
uniforms,
|
|
90
|
+
uniformName,
|
|
91
|
+
undefinedOnly
|
|
92
|
+
} = _ref2;
|
|
91
93
|
const value = uniforms[uniformName];
|
|
92
94
|
const isDefined = isUniformDefined(value);
|
|
93
95
|
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/debug/debug-uniforms.js"],"names":["assert","formatValue","getDebugTableForUniforms","header","program","uniforms","undefinedOnly","SHADER_MODULE_UNIFORM_REGEXP","PROJECT_MODULE_UNIFORM_REGEXP","uniformLocations","_uniformSetters","table","uniformNames","Object","keys","sort","count","uniformName","match","addUniformToTable","unusedCount","unusedTable","uniform","Type","value","isDefined","isUniformDefined","undefined"],"mappings":"AAAA,SAAQA,MAAR,QAAqB,iBAArB;AACA,SAAQC,WAAR,QAA0B,uBAA1B;AAIA,OAAO,SAASC,wBAAT,
|
|
1
|
+
{"version":3,"sources":["../../../src/debug/debug-uniforms.js"],"names":["assert","formatValue","getDebugTableForUniforms","header","program","uniforms","undefinedOnly","SHADER_MODULE_UNIFORM_REGEXP","PROJECT_MODULE_UNIFORM_REGEXP","uniformLocations","_uniformSetters","table","uniformNames","Object","keys","sort","count","uniformName","match","addUniformToTable","unusedCount","unusedTable","uniform","Type","value","isDefined","isUniformDefined","undefined"],"mappings":"AAAA,SAAQA,MAAR,QAAqB,iBAArB;AACA,SAAQC,WAAR,QAA0B,uBAA1B;AAIA,OAAO,SAASC,wBAAT,OAKJ;AAAA,MALsC;AACvCC,IAAAA,MAAM,GAAG,UAD8B;AAEvCC,IAAAA,OAFuC;AAGvCC,IAAAA,QAHuC;AAIvCC,IAAAA,aAAa,GAAG;AAJuB,GAKtC;AACDN,EAAAA,MAAM,CAACI,OAAD,CAAN;AAEA,QAAMG,4BAA4B,GAAG,OAArC;AACA,QAAMC,6BAA6B,GAAG,UAAtC;AAEA,QAAMC,gBAAgB,GAAGL,OAAO,CAACM,eAAjC;AACA,QAAMC,KAAK,GAAG,EAAd;AAGA,QAAMC,YAAY,GAAGC,MAAM,CAACC,IAAP,CAAYL,gBAAZ,EAA8BM,IAA9B,EAArB;AAEA,MAAIC,KAAK,GAAG,CAAZ;;AAGA,OAAK,MAAMC,WAAX,IAA0BL,YAA1B,EAAwC;AACtC,QACE,CAACK,WAAW,CAACC,KAAZ,CAAkBX,4BAAlB,CAAD,IACA,CAACU,WAAW,CAACC,KAAZ,CAAkBV,6BAAlB,CAFH,EAGE;AACA,UAAIW,iBAAiB,CAAC;AAACR,QAAAA,KAAD;AAAQR,QAAAA,MAAR;AAAgBE,QAAAA,QAAhB;AAA0BY,QAAAA,WAA1B;AAA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AAA,MAAvD;AAACR,IAAAA,KAAD;AAAQR,IAAAA,MAAR;AAAgBE,IAAAA,QAAhB;AAA0BY,IAAAA,WAA1B;AAAuCX,IAAAA;AAAvC,GAAuD;AAChF,QAAMkB,KAAK,GAAGnB,QAAQ,CAACY,WAAD,CAAtB;AACA,QAAMQ,SAAS,GAAGC,gBAAgB,CAACF,KAAD,CAAlC;;AACA,MAAI,CAAClB,aAAD,IAAkB,CAACmB,SAAvB,EAAkC;AAChCd,IAAAA,KAAK,CAACM,WAAD,CAAL,GAAqB;AAEnB,OAACd,MAAD,GAAUsB,SAAS,GAAGxB,WAAW,CAACuB,KAAD,CAAd,GAAwB,KAFxB;AAGnB,sBAAgBC,SAAS,GAAGD,KAAH,GAAW;AAHjB,KAArB;AAKA,WAAO,IAAP;AACD;;AACD,SAAO,KAAP;AACD;;AAED,SAASE,gBAAT,CAA0BF,KAA1B,EAAiC;AAC/B,SAAOA,KAAK,KAAKG,SAAV,IAAuBH,KAAK,KAAK,IAAxC;AACD","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"],"file":"debug-uniforms.js"}
|
|
@@ -2,10 +2,12 @@ import Buffer from '../classes/buffer';
|
|
|
2
2
|
import { getKey } from '../webgl-utils/constants-to-keys';
|
|
3
3
|
import { getCompositeGLType } from '../webgl-utils/attribute-utils';
|
|
4
4
|
import { formatValue } from '../utils/format-value';
|
|
5
|
-
export function getDebugTableForVertexArray({
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
5
|
+
export function getDebugTableForVertexArray(_ref) {
|
|
6
|
+
let {
|
|
7
|
+
vertexArray,
|
|
8
|
+
header = 'Attributes'
|
|
9
|
+
} = _ref;
|
|
10
|
+
|
|
9
11
|
if (!vertexArray.configuration) {
|
|
10
12
|
return {};
|
|
11
13
|
}
|
|
@@ -22,11 +24,11 @@ export function getDebugTableForVertexArray({
|
|
|
22
24
|
const info = vertexArray._getAttributeInfo(attributeLocation);
|
|
23
25
|
|
|
24
26
|
if (info) {
|
|
25
|
-
let rowHeader =
|
|
27
|
+
let rowHeader = "".concat(attributeLocation, ": ").concat(info.name);
|
|
26
28
|
const accessor = vertexArray.accessors[info.location];
|
|
27
29
|
|
|
28
30
|
if (accessor) {
|
|
29
|
-
rowHeader =
|
|
31
|
+
rowHeader = "".concat(attributeLocation, ": ").concat(getGLSLDeclaration(info.name, accessor));
|
|
30
32
|
}
|
|
31
33
|
|
|
32
34
|
table[rowHeader] = getDebugTableRow(vertexArray, attributes[attributeLocation], accessor, header);
|
|
@@ -77,17 +79,17 @@ function getDebugTableRow(vertexArray, attribute, accessor, header) {
|
|
|
77
79
|
|
|
78
80
|
if (accessor) {
|
|
79
81
|
const instanced = accessor.divisor > 0;
|
|
80
|
-
format =
|
|
82
|
+
format = "".concat(instanced ? 'I ' : 'P ', " ").concat(verts, " (x").concat(size, "=").concat(bytes, " bytes ").concat(getKey(gl, type), ")");
|
|
81
83
|
} else {
|
|
82
84
|
isInteger = true;
|
|
83
|
-
format =
|
|
85
|
+
format = "".concat(bytes, " bytes");
|
|
84
86
|
}
|
|
85
87
|
|
|
86
88
|
return {
|
|
87
|
-
[header]:
|
|
89
|
+
[header]: "".concat(marker).concat(formatValue(value, {
|
|
88
90
|
size,
|
|
89
91
|
isInteger
|
|
90
|
-
})
|
|
92
|
+
})),
|
|
91
93
|
'Format ': format
|
|
92
94
|
};
|
|
93
95
|
}
|
|
@@ -97,11 +99,11 @@ function getDebugTableRow(vertexArray, attribute, accessor, header) {
|
|
|
97
99
|
type = String(attribute.constructor.name).replace('Array', '');
|
|
98
100
|
isInteger = type.indexOf('nt') !== -1;
|
|
99
101
|
return {
|
|
100
|
-
[header]:
|
|
102
|
+
[header]: "".concat(formatValue(value, {
|
|
101
103
|
size,
|
|
102
104
|
isInteger
|
|
103
|
-
})
|
|
104
|
-
'Format ':
|
|
105
|
+
}), " (constant)"),
|
|
106
|
+
'Format ': "".concat(size, "x").concat(type, " (constant)")
|
|
105
107
|
};
|
|
106
108
|
}
|
|
107
109
|
|
|
@@ -111,6 +113,6 @@ function getGLSLDeclaration(name, accessor) {
|
|
|
111
113
|
size
|
|
112
114
|
} = accessor;
|
|
113
115
|
const typeAndName = getCompositeGLType(type, size);
|
|
114
|
-
return typeAndName ?
|
|
116
|
+
return typeAndName ? "".concat(name, " (").concat(typeAndName.name, ")") : name;
|
|
115
117
|
}
|
|
116
118
|
//# sourceMappingURL=debug-vertex-array.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/debug/debug-vertex-array.js"],"names":["Buffer","getKey","getCompositeGLType","formatValue","getDebugTableForVertexArray","vertexArray","header","configuration","table","elements","ELEMENT_ARRAY_BUFFER","getDebugTableRow","attributes","values","attributeLocation","info","_getAttributeInfo","rowHeader","name","accessor","accessors","location","getGLSLDeclaration","attribute","gl","type","size","verts","bytes","isInteger","marker","value","String","replace","indexOf","buffer","data","changed","getDebugData","byteLength","BYTES_PER_ELEMENT","format","instanced","divisor","length","constructor","typeAndName"],"mappings":"AAAA,OAAOA,MAAP,MAAmB,mBAAnB;AACA,SAAQC,MAAR,QAAqB,kCAArB;AACA,SAAQC,kBAAR,QAAiC,gCAAjC;AACA,SAAQC,WAAR,QAA0B,uBAA1B;AAGA,OAAO,SAASC,2BAAT,
|
|
1
|
+
{"version":3,"sources":["../../../src/debug/debug-vertex-array.js"],"names":["Buffer","getKey","getCompositeGLType","formatValue","getDebugTableForVertexArray","vertexArray","header","configuration","table","elements","ELEMENT_ARRAY_BUFFER","getDebugTableRow","attributes","values","attributeLocation","info","_getAttributeInfo","rowHeader","name","accessor","accessors","location","getGLSLDeclaration","attribute","gl","type","size","verts","bytes","isInteger","marker","value","String","replace","indexOf","buffer","data","changed","getDebugData","byteLength","BYTES_PER_ELEMENT","format","instanced","divisor","length","constructor","typeAndName"],"mappings":"A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BAA4CD,IAA5C,cAAoDE,KAApD,oBAAmE3B,MAAM,CAACuB,EAAD,EAAKC,IAAL,CAAzE,MAAN;AACD,KAHD,MAGO;AAELI,MAAAA,SAAS,GAAG,IAAZ;AACAY,MAAAA,MAAM,aAAMb,KAAN,WAAN;AACD;;AAED,WAAO;AACL,OAACtB,MAAD,aAAawB,MAAb,SAAsB3B,WAAW,CAAC4B,KAAD,EAAQ;AAACL,QAAAA,IAAD;AAAOG,QAAAA;AAAP,OAAR,CAAjC,CADK;AAEL,iBAAWY;AAFN,KAAP;AAID;;AAGDV,EAAAA,KAAK,GAAGR,SAAR;AACAG,EAAAA,IAAI,GAAGH,SAAS,CAACqB,MAAjB;AAEAnB,EAAAA,IAAI,GAAGO,MAAM,CAACT,SAAS,CAACsB,WAAV,CAAsB3B,IAAvB,CAAN,CAAmCe,OAAnC,CAA2C,OAA3C,EAAoD,EAApD,CAAP;AAEAJ,EAAAA,SAAS,GAAGJ,IAAI,CAACS,OAAL,CAAa,IAAb,MAAuB,CAAC,CAApC;AAEA,SAAO;AACL,KAAC5B,MAAD,aAAaH,WAAW,CAAC4B,KAAD,EAAQ;AAACL,MAAAA,IAAD;AAAOG,MAAAA;AAAP,KAAR,CAAxB,gBADK;AAEL,yBAAcH,IAAd,cAAsBD,IAAtB;AAFK,GAAP;AAID;;AAGD,SAASH,kBAAT,CAA4BJ,IAA5B,EAAkCC,QAAlC,EAA4C;AAC1C,QAAM;AAACM,IAAAA,IAAD;AAAOC,IAAAA;AAAP,MAAeP,QAArB;AACA,QAAM2B,WAAW,GAAG5C,kBAAkB,CAACuB,IAAD,EAAOC,IAAP,CAAtC;AACA,SAAOoB,WAAW,aAAM5B,IAAN,eAAe4B,WAAW,CAAC5B,IAA3B,SAAqCA,IAAvD;AACD","sourcesContent":["import Buffer from '../classes/buffer';\nimport {getKey} from '../webgl-utils/constants-to-keys';\nimport {getCompositeGLType} from '../webgl-utils/attribute-utils';\nimport {formatValue} from '../utils/format-value';\n\n// Creates object suitable as input for console.table\nexport function getDebugTableForVertexArray({vertexArray, header = 'Attributes'}) {\n if (!vertexArray.configuration) {\n return {};\n }\n\n const table = {}; // {[header]: {}};\n\n // Add index (elements) if available\n if (vertexArray.elements) {\n // const elements = Object.assign({size: 1}, vertexArray.elements);\n table.ELEMENT_ARRAY_BUFFER = getDebugTableRow(vertexArray, vertexArray.elements, null, header);\n }\n\n // Add used attributes\n const attributes = vertexArray.values;\n\n for (const attributeLocation in attributes) {\n const info = vertexArray._getAttributeInfo(attributeLocation);\n if (info) {\n let rowHeader = `${attributeLocation}: ${info.name}`;\n const accessor = vertexArray.accessors[info.location];\n if (accessor) {\n rowHeader = `${attributeLocation}: ${getGLSLDeclaration(info.name, accessor)}`;\n }\n table[rowHeader] = getDebugTableRow(\n vertexArray,\n attributes[attributeLocation],\n accessor,\n header\n );\n }\n }\n\n return table;\n}\n\n/* eslint-disable max-statements */\nfunction getDebugTableRow(vertexArray, attribute, accessor, header) {\n const {gl} = vertexArray;\n\n if (!attribute) {\n return {\n [header]: 'null',\n 'Format ': 'N/A'\n };\n }\n\n let type = 'NOT PROVIDED';\n let size = 1;\n let verts = 0;\n let bytes = 0;\n\n let isInteger;\n let marker;\n let value;\n\n if (accessor) {\n type = accessor.type;\n size = accessor.size;\n\n // Generate a type name by dropping Array from Float32Array etc.\n type = String(type).replace('Array', '');\n\n // Look for 'nt' to detect integer types, e.g. Int32Array, Uint32Array\n isInteger = type.indexOf('nt') !== -1;\n }\n\n if (attribute instanceof Buffer) {\n const buffer = attribute;\n\n const {data, changed} = buffer.getDebugData();\n marker = changed ? '*' : '';\n\n value = data;\n // @ts-ignore\n bytes = buffer.byteLength;\n // @ts-ignore\n verts = bytes / data.BYTES_PER_ELEMENT / size;\n\n let format;\n\n if (accessor) {\n const instanced = accessor.divisor > 0;\n format = `${instanced ? 'I ' : 'P '} ${verts} (x${size}=${bytes} bytes ${getKey(gl, type)})`;\n } else {\n // element buffer\n isInteger = true;\n format = `${bytes} bytes`;\n }\n\n return {\n [header]: `${marker}${formatValue(value, {size, isInteger})}`,\n 'Format ': format\n };\n }\n\n // CONSTANT VALUE\n value = attribute;\n size = attribute.length;\n // Generate a type name by dropping Array from Float32Array etc.\n type = String(attribute.constructor.name).replace('Array', '');\n // Look for 'nt' to detect integer types, e.g. Int32Array, Uint32Array\n isInteger = type.indexOf('nt') !== -1;\n\n return {\n [header]: `${formatValue(value, {size, isInteger})} (constant)`,\n 'Format ': `${size}x${type} (constant)`\n };\n}\n/* eslint-ensable max-statements */\n\nfunction getGLSLDeclaration(name, accessor) {\n const {type, size} = accessor;\n const typeAndName = getCompositeGLType(type, size);\n return typeAndName ? `${name} (${typeAndName.name})` : name;\n}\n"],"file":"debug-vertex-array.js"}
|
|
@@ -2,7 +2,8 @@ import isOldIE from './check-old-ie';
|
|
|
2
2
|
import WEBGL_FEATURES from './webgl-features-table';
|
|
3
3
|
import { assert } from '../utils/assert';
|
|
4
4
|
const compiledGlslExtensions = {};
|
|
5
|
-
export default function canCompileGLGSExtension(gl, cap
|
|
5
|
+
export default function canCompileGLGSExtension(gl, cap) {
|
|
6
|
+
let options = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};
|
|
6
7
|
const feature = WEBGL_FEATURES[cap];
|
|
7
8
|
assert(feature, cap);
|
|
8
9
|
|
|
@@ -15,7 +16,7 @@ export default function canCompileGLGSExtension(gl, cap, options = {}) {
|
|
|
15
16
|
}
|
|
16
17
|
|
|
17
18
|
const extensionName = feature[0];
|
|
18
|
-
const source =
|
|
19
|
+
const source = "#extension GL_".concat(extensionName, " : enable\nvoid main(void) {}");
|
|
19
20
|
const shader = gl.createShader(35633);
|
|
20
21
|
gl.shaderSource(shader, source);
|
|
21
22
|
gl.compileShader(shader);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/features/check-glsl-extension.js"],"names":["isOldIE","WEBGL_FEATURES","assert","compiledGlslExtensions","canCompileGLGSExtension","gl","cap","options","feature","extensionName","source","shader","createShader","shaderSource","compileShader","canCompile","getShaderParameter","deleteShader"],"mappings":"AAAA,OAAOA,OAAP,MAAoB,gBAApB;AACA,OAAOC,cAAP,MAA2B,wBAA3B;AACA,SAAQC,MAAR,QAAqB,iBAArB;AAMA,MAAMC,sBAAsB,GAAG,EAA/B;AAGA,eAAe,SAASC,uBAAT,CAAiCC,EAAjC,EAAqCC,GAArC,
|
|
1
|
+
{"version":3,"sources":["../../../src/features/check-glsl-extension.js"],"names":["isOldIE","WEBGL_FEATURES","assert","compiledGlslExtensions","canCompileGLGSExtension","gl","cap","options","feature","extensionName","source","shader","createShader","shaderSource","compileShader","canCompile","getShaderParameter","deleteShader"],"mappings":"AAAA,OAAOA,OAAP,MAAoB,gBAApB;AACA,OAAOC,cAAP,MAA2B,wBAA3B;AACA,SAAQC,MAAR,QAAqB,iBAArB;AAMA,MAAMC,sBAAsB,GAAG,EAA/B;AAGA,eAAe,SAASC,uBAAT,CAAiCC,EAAjC,EAAqCC,GAArC,EAAwD;AAAA,MAAdC,OAAc,uEAAJ,EAAI;AACrE,QAAMC,OAAO,GAAGP,cAAc,CAACK,GAAD,CAA9B;AACAJ,EAAAA,MAAM,CAACM,OAAD,EAAUF,GAAV,CAAN;;AAEA,MAAI,CAACN,OAAO,CAACO,OAAD,CAAZ,EAAuB;AACrB,WAAO,IAAP;AACD;;AAED,MAAID,GAAG,IAAIH,sBAAX,EAAmC;AACjC,WAAOA,sBAAsB,CAACG,GAAD,CAA7B;AACD;;AAED,QAAMG,aAAa,GAAGD,OAAO,CAAC,CAAD,CAA7B;AACA,QAAME,MAAM,2BAAoBD,aAApB,kCAAZ;AAEA,QAAME,MAAM,GAAGN,EAAE,CAACO,YAAH,OAAf;AACAP,EAAAA,EAAE,CAACQ,YAAH,CAAgBF,MAAhB,EAAwBD,MAAxB;AACAL,EAAAA,EAAE,CAACS,aAAH,CAAiBH,MAAjB;AACA,QAAMI,UAAU,GAAGV,EAAE,CAACW,kBAAH,CAAsBL,MAAtB,QAAnB;AACAN,EAAAA,EAAE,CAACY,YAAH,CAAgBN,MAAhB;AACAR,EAAAA,sBAAsB,CAACG,GAAD,CAAtB,GAA8BS,UAA9B;AACA,SAAOA,UAAP;AACD","sourcesContent":["import isOldIE from './check-old-ie';\nimport WEBGL_FEATURES from './webgl-features-table';\nimport {assert} from '../utils/assert';\n\n// Enables feature detection in IE11 due to a bug where gl.getExtension may return true\n// but fail to compile when the extension is enabled in the shader. Specifically,\n// the OES_standard_derivatives extension fails to compile in IE11 even though its included\n// in the list of supported extensions.\nconst compiledGlslExtensions = {};\n\n// options allows user agent to be overridden for testing\nexport default function canCompileGLGSExtension(gl, cap, options = {}) {\n const feature = WEBGL_FEATURES[cap];\n assert(feature, cap);\n\n if (!isOldIE(options)) {\n return true;\n }\n\n if (cap in compiledGlslExtensions) {\n return compiledGlslExtensions[cap];\n }\n\n const extensionName = feature[0];\n const source = `#extension GL_${extensionName} : enable\\nvoid main(void) {}`;\n\n const shader = gl.createShader(gl.VERTEX_SHADER);\n gl.shaderSource(shader, source);\n gl.compileShader(shader);\n const canCompile = gl.getShaderParameter(shader, gl.COMPILE_STATUS);\n gl.deleteShader(shader);\n compiledGlslExtensions[cap] = canCompile;\n return canCompile;\n}\n"],"file":"check-glsl-extension.js"}
|
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
export default function isOldIE(
|
|
1
|
+
export default function isOldIE() {
|
|
2
|
+
let opts = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
|
|
2
3
|
const navigator = typeof window !== 'undefined' && window.navigator || {};
|
|
3
4
|
const userAgent = opts.userAgent || navigator.userAgent || '';
|
|
4
5
|
const isMSIE = userAgent.indexOf('MSIE ') !== -1;
|