@luma.gl/webgl 9.0.0-alpha.11 → 9.0.0-alpha.13

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.
Files changed (229) hide show
  1. package/dist/adapter/converters/device-parameters.js +1 -12
  2. package/dist/adapter/converters/device-parameters.js.map +1 -1
  3. package/dist/adapter/converters/texture-formats.d.ts.map +1 -1
  4. package/dist/adapter/converters/texture-formats.js +0 -9
  5. package/dist/adapter/converters/texture-formats.js.map +1 -1
  6. package/dist/adapter/converters/vertex-formats.d.ts.map +1 -1
  7. package/dist/adapter/converters/vertex-formats.js +3 -0
  8. package/dist/adapter/converters/vertex-formats.js.map +1 -1
  9. package/dist/adapter/device-helpers/device-features.d.ts.map +1 -1
  10. package/dist/adapter/device-helpers/device-features.js.map +1 -1
  11. package/dist/adapter/device-helpers/get-device-info.js +4 -0
  12. package/dist/adapter/device-helpers/get-device-info.js.map +1 -1
  13. package/dist/adapter/helpers/get-shader-layout.d.ts +1 -1
  14. package/dist/adapter/helpers/get-shader-layout.d.ts.map +1 -1
  15. package/dist/adapter/helpers/get-shader-layout.js +2 -4
  16. package/dist/adapter/helpers/get-shader-layout.js.map +1 -1
  17. package/dist/adapter/helpers/set-uniform.js +1 -1
  18. package/dist/adapter/helpers/set-uniform.js.map +1 -1
  19. package/dist/adapter/objects/constants-to-keys.d.ts.map +1 -1
  20. package/dist/adapter/objects/constants-to-keys.js.map +1 -1
  21. package/dist/adapter/objects/webgl-renderbuffer.d.ts.map +1 -1
  22. package/dist/adapter/objects/webgl-renderbuffer.js +1 -1
  23. package/dist/adapter/objects/webgl-renderbuffer.js.map +1 -1
  24. package/dist/adapter/objects/webgl-resource.d.ts +2 -4
  25. package/dist/adapter/objects/webgl-resource.d.ts.map +1 -1
  26. package/dist/adapter/objects/webgl-resource.js +1 -7
  27. package/dist/adapter/objects/webgl-resource.js.map +1 -1
  28. package/dist/adapter/objects/webgl-vertex-array-object.d.ts.map +1 -1
  29. package/dist/adapter/objects/webgl-vertex-array-object.js.map +1 -1
  30. package/dist/adapter/resources/webgl-buffer.d.ts +0 -1
  31. package/dist/adapter/resources/webgl-buffer.d.ts.map +1 -1
  32. package/dist/adapter/resources/webgl-buffer.js +0 -2
  33. package/dist/adapter/resources/webgl-buffer.js.map +1 -1
  34. package/dist/adapter/resources/webgl-command-encoder.d.ts.map +1 -1
  35. package/dist/adapter/resources/webgl-command-encoder.js.map +1 -1
  36. package/dist/adapter/resources/webgl-framebuffer.d.ts +0 -1
  37. package/dist/adapter/resources/webgl-framebuffer.d.ts.map +1 -1
  38. package/dist/adapter/resources/webgl-framebuffer.js +2 -2
  39. package/dist/adapter/resources/webgl-framebuffer.js.map +1 -1
  40. package/dist/adapter/resources/webgl-render-pipeline.d.ts.map +1 -1
  41. package/dist/adapter/resources/webgl-render-pipeline.js +4 -32
  42. package/dist/adapter/resources/webgl-render-pipeline.js.map +1 -1
  43. package/dist/adapter/resources/webgl-sampler.d.ts +1 -0
  44. package/dist/adapter/resources/webgl-sampler.d.ts.map +1 -1
  45. package/dist/adapter/resources/webgl-sampler.js +4 -0
  46. package/dist/adapter/resources/webgl-sampler.js.map +1 -1
  47. package/dist/adapter/resources/webgl-shader.d.ts.map +1 -1
  48. package/dist/adapter/resources/webgl-shader.js.map +1 -1
  49. package/dist/adapter/resources/webgl-texture.d.ts +2 -2
  50. package/dist/adapter/resources/webgl-texture.d.ts.map +1 -1
  51. package/dist/adapter/resources/webgl-texture.js +1 -3
  52. package/dist/adapter/resources/webgl-texture.js.map +1 -1
  53. package/dist/adapter/webgl-canvas-context.d.ts.map +1 -1
  54. package/dist/adapter/webgl-canvas-context.js +3 -0
  55. package/dist/adapter/webgl-canvas-context.js.map +1 -1
  56. package/dist/adapter/webgl-device.d.ts +2 -3
  57. package/dist/adapter/webgl-device.d.ts.map +1 -1
  58. package/dist/adapter/webgl-device.js +5 -4
  59. package/dist/adapter/webgl-device.js.map +1 -1
  60. package/dist/classic/buffer.d.ts.map +1 -1
  61. package/dist/classic/buffer.js.map +1 -1
  62. package/dist/context/debug/webgl-developer-tools.js +1 -7
  63. package/dist/context/debug/webgl-developer-tools.js.map +1 -1
  64. package/dist/context/parameters/unified-parameter-api.d.ts.map +1 -1
  65. package/dist/context/parameters/unified-parameter-api.js.map +1 -1
  66. package/dist/context/parameters/webgl-parameter-tables.d.ts +103 -103
  67. package/dist/context/parameters/webgl-parameter-tables.d.ts.map +1 -1
  68. package/dist/context/parameters/webgl-parameter-tables.js +15 -14
  69. package/dist/context/parameters/webgl-parameter-tables.js.map +1 -1
  70. package/dist/context/{context/context-state.d.ts → polyfill/context-data.d.ts} +3 -3
  71. package/dist/context/polyfill/context-data.d.ts.map +1 -0
  72. package/dist/context/polyfill/context-data.js +14 -0
  73. package/dist/context/polyfill/context-data.js.map +1 -0
  74. package/dist/context/polyfill/get-parameter-polyfill.d.ts +1 -1
  75. package/dist/context/polyfill/get-parameter-polyfill.d.ts.map +1 -1
  76. package/dist/context/polyfill/get-parameter-polyfill.js.map +1 -1
  77. package/dist/context/polyfill/polyfill-context.js +4 -4
  78. package/dist/context/polyfill/polyfill-context.js.map +1 -1
  79. package/dist/context/polyfill/polyfill-table.d.ts +7 -7
  80. package/dist/context/polyfill/polyfill-table.d.ts.map +1 -1
  81. package/dist/context/polyfill/polyfill-table.js +5 -4
  82. package/dist/context/polyfill/polyfill-table.js.map +1 -1
  83. package/dist/context/state-tracker/track-context-state.d.ts.map +1 -1
  84. package/dist/context/state-tracker/track-context-state.js +0 -1
  85. package/dist/context/state-tracker/track-context-state.js.map +1 -1
  86. package/dist/context/state-tracker/with-parameters.js +1 -1
  87. package/dist/context/state-tracker/with-parameters.js.map +1 -1
  88. package/dist/es5/adapter/converters/device-parameters.js +1 -12
  89. package/dist/es5/adapter/converters/device-parameters.js.map +1 -1
  90. package/dist/es5/adapter/converters/texture-formats.js +1 -10
  91. package/dist/es5/adapter/converters/texture-formats.js.map +1 -1
  92. package/dist/es5/adapter/converters/vertex-formats.js +3 -0
  93. package/dist/es5/adapter/converters/vertex-formats.js.map +1 -1
  94. package/dist/es5/adapter/device-helpers/device-features.js.map +1 -1
  95. package/dist/es5/adapter/device-helpers/get-device-info.js +4 -0
  96. package/dist/es5/adapter/device-helpers/get-device-info.js.map +1 -1
  97. package/dist/es5/adapter/helpers/get-shader-layout.js +2 -4
  98. package/dist/es5/adapter/helpers/get-shader-layout.js.map +1 -1
  99. package/dist/es5/adapter/helpers/set-uniform.js +1 -1
  100. package/dist/es5/adapter/helpers/set-uniform.js.map +1 -1
  101. package/dist/es5/adapter/objects/constants-to-keys.js.map +1 -1
  102. package/dist/es5/adapter/objects/webgl-renderbuffer.js +1 -1
  103. package/dist/es5/adapter/objects/webgl-renderbuffer.js.map +1 -1
  104. package/dist/es5/adapter/objects/webgl-resource.js +1 -6
  105. package/dist/es5/adapter/objects/webgl-resource.js.map +1 -1
  106. package/dist/es5/adapter/objects/webgl-vertex-array-object.js.map +1 -1
  107. package/dist/es5/adapter/resources/webgl-buffer.js +0 -1
  108. package/dist/es5/adapter/resources/webgl-buffer.js.map +1 -1
  109. package/dist/es5/adapter/resources/webgl-command-encoder.js.map +1 -1
  110. package/dist/es5/adapter/resources/webgl-framebuffer.js +2 -1
  111. package/dist/es5/adapter/resources/webgl-framebuffer.js.map +1 -1
  112. package/dist/es5/adapter/resources/webgl-render-pipeline.js +2 -38
  113. package/dist/es5/adapter/resources/webgl-render-pipeline.js.map +1 -1
  114. package/dist/es5/adapter/resources/webgl-sampler.js +5 -0
  115. package/dist/es5/adapter/resources/webgl-sampler.js.map +1 -1
  116. package/dist/es5/adapter/resources/webgl-shader.js.map +1 -1
  117. package/dist/es5/adapter/resources/webgl-texture.js +1 -7
  118. package/dist/es5/adapter/resources/webgl-texture.js.map +1 -1
  119. package/dist/es5/adapter/webgl-canvas-context.js +2 -0
  120. package/dist/es5/adapter/webgl-canvas-context.js.map +1 -1
  121. package/dist/es5/adapter/webgl-device.js +4 -3
  122. package/dist/es5/adapter/webgl-device.js.map +1 -1
  123. package/dist/es5/classic/buffer.js.map +1 -1
  124. package/dist/es5/context/debug/webgl-developer-tools.js +1 -7
  125. package/dist/es5/context/debug/webgl-developer-tools.js.map +1 -1
  126. package/dist/es5/context/parameters/unified-parameter-api.js.map +1 -1
  127. package/dist/es5/context/parameters/webgl-parameter-tables.js +10 -9
  128. package/dist/es5/context/parameters/webgl-parameter-tables.js.map +1 -1
  129. package/dist/es5/context/polyfill/context-data.js +21 -0
  130. package/dist/es5/context/polyfill/context-data.js.map +1 -0
  131. package/dist/es5/context/polyfill/get-parameter-polyfill.js.map +1 -1
  132. package/dist/es5/context/polyfill/polyfill-context.js +4 -4
  133. package/dist/es5/context/polyfill/polyfill-context.js.map +1 -1
  134. package/dist/es5/context/polyfill/polyfill-table.js +5 -4
  135. package/dist/es5/context/polyfill/polyfill-table.js.map +1 -1
  136. package/dist/es5/context/state-tracker/track-context-state.js +0 -1
  137. package/dist/es5/context/state-tracker/track-context-state.js.map +1 -1
  138. package/dist/es5/context/state-tracker/with-parameters.js +4 -2
  139. package/dist/es5/context/state-tracker/with-parameters.js.map +1 -1
  140. package/dist/esm/adapter/converters/device-parameters.js +1 -12
  141. package/dist/esm/adapter/converters/device-parameters.js.map +1 -1
  142. package/dist/esm/adapter/converters/texture-formats.js +0 -9
  143. package/dist/esm/adapter/converters/texture-formats.js.map +1 -1
  144. package/dist/esm/adapter/converters/vertex-formats.js +3 -0
  145. package/dist/esm/adapter/converters/vertex-formats.js.map +1 -1
  146. package/dist/esm/adapter/device-helpers/device-features.js.map +1 -1
  147. package/dist/esm/adapter/device-helpers/get-device-info.js +4 -0
  148. package/dist/esm/adapter/device-helpers/get-device-info.js.map +1 -1
  149. package/dist/esm/adapter/helpers/get-shader-layout.js +2 -4
  150. package/dist/esm/adapter/helpers/get-shader-layout.js.map +1 -1
  151. package/dist/esm/adapter/helpers/set-uniform.js +1 -1
  152. package/dist/esm/adapter/helpers/set-uniform.js.map +1 -1
  153. package/dist/esm/adapter/objects/constants-to-keys.js.map +1 -1
  154. package/dist/esm/adapter/objects/webgl-renderbuffer.js +1 -1
  155. package/dist/esm/adapter/objects/webgl-renderbuffer.js.map +1 -1
  156. package/dist/esm/adapter/objects/webgl-resource.js +1 -7
  157. package/dist/esm/adapter/objects/webgl-resource.js.map +1 -1
  158. package/dist/esm/adapter/objects/webgl-vertex-array-object.js.map +1 -1
  159. package/dist/esm/adapter/resources/webgl-buffer.js +0 -2
  160. package/dist/esm/adapter/resources/webgl-buffer.js.map +1 -1
  161. package/dist/esm/adapter/resources/webgl-command-encoder.js.map +1 -1
  162. package/dist/esm/adapter/resources/webgl-framebuffer.js +2 -2
  163. package/dist/esm/adapter/resources/webgl-framebuffer.js.map +1 -1
  164. package/dist/esm/adapter/resources/webgl-render-pipeline.js +4 -32
  165. package/dist/esm/adapter/resources/webgl-render-pipeline.js.map +1 -1
  166. package/dist/esm/adapter/resources/webgl-sampler.js +4 -0
  167. package/dist/esm/adapter/resources/webgl-sampler.js.map +1 -1
  168. package/dist/esm/adapter/resources/webgl-shader.js.map +1 -1
  169. package/dist/esm/adapter/resources/webgl-texture.js +1 -3
  170. package/dist/esm/adapter/resources/webgl-texture.js.map +1 -1
  171. package/dist/esm/adapter/webgl-canvas-context.js +3 -0
  172. package/dist/esm/adapter/webgl-canvas-context.js.map +1 -1
  173. package/dist/esm/adapter/webgl-device.js +5 -4
  174. package/dist/esm/adapter/webgl-device.js.map +1 -1
  175. package/dist/esm/classic/buffer.js.map +1 -1
  176. package/dist/esm/context/debug/webgl-developer-tools.js +1 -7
  177. package/dist/esm/context/debug/webgl-developer-tools.js.map +1 -1
  178. package/dist/esm/context/parameters/unified-parameter-api.js.map +1 -1
  179. package/dist/esm/context/parameters/webgl-parameter-tables.js +15 -14
  180. package/dist/esm/context/parameters/webgl-parameter-tables.js.map +1 -1
  181. package/dist/esm/context/polyfill/context-data.js +14 -0
  182. package/dist/esm/context/polyfill/context-data.js.map +1 -0
  183. package/dist/esm/context/polyfill/get-parameter-polyfill.js.map +1 -1
  184. package/dist/esm/context/polyfill/polyfill-context.js +4 -4
  185. package/dist/esm/context/polyfill/polyfill-context.js.map +1 -1
  186. package/dist/esm/context/polyfill/polyfill-table.js +5 -4
  187. package/dist/esm/context/polyfill/polyfill-table.js.map +1 -1
  188. package/dist/esm/context/state-tracker/track-context-state.js +0 -1
  189. package/dist/esm/context/state-tracker/track-context-state.js.map +1 -1
  190. package/dist/esm/context/state-tracker/with-parameters.js +1 -1
  191. package/dist/esm/context/state-tracker/with-parameters.js.map +1 -1
  192. package/package.json +4 -4
  193. package/src/adapter/converters/device-parameters.ts +11 -11
  194. package/src/adapter/converters/texture-formats.ts +12 -12
  195. package/src/adapter/converters/vertex-formats.ts +1 -0
  196. package/src/adapter/device-helpers/device-features.ts +0 -1
  197. package/src/adapter/device-helpers/get-device-info.ts +5 -1
  198. package/src/adapter/helpers/get-shader-layout.ts +18 -15
  199. package/src/adapter/helpers/set-uniform.ts +1 -1
  200. package/src/adapter/objects/constants-to-keys.ts +4 -1
  201. package/src/adapter/objects/webgl-renderbuffer.ts +5 -5
  202. package/src/adapter/objects/webgl-resource.ts +7 -12
  203. package/src/adapter/objects/webgl-vertex-array-object.ts +4 -4
  204. package/src/adapter/resources/webgl-buffer.ts +4 -4
  205. package/src/adapter/resources/webgl-command-encoder.ts +4 -4
  206. package/src/adapter/resources/webgl-framebuffer.ts +6 -5
  207. package/src/adapter/resources/webgl-render-pipeline.ts +24 -23
  208. package/src/adapter/resources/webgl-sampler.ts +5 -1
  209. package/src/adapter/resources/webgl-shader.ts +1 -1
  210. package/src/adapter/resources/webgl-texture.ts +5 -7
  211. package/src/adapter/webgl-canvas-context.ts +1 -0
  212. package/src/adapter/webgl-device.ts +10 -12
  213. package/src/classic/buffer.ts +7 -4
  214. package/src/context/debug/webgl-developer-tools.ts +7 -7
  215. package/src/context/parameters/unified-parameter-api.ts +1 -1
  216. package/src/context/parameters/webgl-parameter-tables.ts +113 -94
  217. package/src/context/{context/context-state.ts → polyfill/context-data.ts} +6 -10
  218. package/src/context/polyfill/get-parameter-polyfill.ts +7 -6
  219. package/src/context/polyfill/polyfill-context.ts +5 -5
  220. package/src/context/polyfill/polyfill-table.ts +14 -13
  221. package/src/context/state-tracker/track-context-state.ts +0 -1
  222. package/src/context/state-tracker/with-parameters.ts +2 -1
  223. package/dist/context/context/context-state.d.ts.map +0 -1
  224. package/dist/context/context/context-state.js +0 -21
  225. package/dist/context/context/context-state.js.map +0 -1
  226. package/dist/es5/context/context/context-state.js +0 -26
  227. package/dist/es5/context/context/context-state.js.map +0 -1
  228. package/dist/esm/context/context/context-state.js +0 -21
  229. package/dist/esm/context/context/context-state.js.map +0 -1
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/classic/buffer.ts"],"names":["assert","checkProps","GL","assertWebGL2Context","Accessor","getGLTypeFromTypedArray","getTypedArrayFromGLType","WebGLDevice","WEBGLBuffer","DEBUG_DATA_LENGTH","DEPRECATED_PROPS","offset","stride","type","size","divisor","normalized","integer","instanced","isInstanced","PROP_CHECKS_INITIALIZE","removedProps","replacedProps","bytes","deprecatedProps","PROP_CHECKS_SET_PROPS","getWEBGLBufferProps","props","ArrayBuffer","isView","data","byteLength","bufferProps","byteOffset","ClassicBuffer","constructor","device","attach","setAccessor","Object","assign","accessor","seal","destroy","handle","removeStats","trackDeallocatedMemory","gl","deleteBuffer","destroyed","write","subData","getElementCount","Math","round","getBytesPerElement","getVertexCount","getBytesPerVertex","initialize","Number","isFinite","webglUsage","STATIC_DRAW","debugData","_setData","_setByteLength","setProps","buffer","reallocate","bytesUsed","setData","options","srcOffset","length","target","webgl2","COPY_WRITE_BUFFER","bindBuffer","undefined","bufferSubData","_inferType","copyData","sourceBuffer","readOffset","writeOffset","gl2","COPY_READ_BUFFER","copyBufferSubData","getData","dstData","srcByteOffset","dstOffset","ArrayType","FLOAT","clamped","sourceAvailableElementCount","_getAvailableElementCount","dstElementOffset","dstAvailableElementCount","dstElementCount","min","copyElementCount","getBufferSubData","bind","index","UNIFORM_BUFFER","TRANSFORM_FEEDBACK_BUFFER","bindBufferRange","bindBufferBase","unbind","isIndexedBuffer","getDebugData","changed","invalidateDebugData","_getTarget","bufferData","slice","trackAllocatedMemory","Float32Array","sourceElementOffset","BYTES_PER_ELEMENT","getParameter","pname","value","getBufferParameter"],"mappings":";AACA,SAAqBA,MAArB,EAA6BC,UAA7B,QAA8C,cAA9C;AACA,OAAOC,EAAP,MAAe,oBAAf;AACA,SAAQC,mBAAR,QAAkC,iCAAlC;AAEA,OAAOC,QAAP,MAAqB,YAArB;AACA,SAAQC,uBAAR,EAAiCC,uBAAjC,QAA+D,qBAA/D;AAEA,OAAOC,WAAP,MAAwB,yBAAxB;AACA,OAAOC,WAAP,MAAwB,mCAAxB;AAEA,MAAMC,iBAAiB,GAAG,EAA1B;AAGA,MAAMC,gBAAgB,GAAG;AACvBC,EAAAA,MAAM,EAAE,iBADe;AAEvBC,EAAAA,MAAM,EAAE,iBAFe;AAGvBC,EAAAA,IAAI,EAAE,eAHiB;AAIvBC,EAAAA,IAAI,EAAE,eAJiB;AAKvBC,EAAAA,OAAO,EAAE,kBALc;AAMvBC,EAAAA,UAAU,EAAE,qBANW;AAOvBC,EAAAA,OAAO,EAAE,kBAPc;AAQvBC,EAAAA,SAAS,EAAE,kBARY;AASvBC,EAAAA,WAAW,EAAE;AATU,CAAzB;AAaA,MAAMC,sBAAsB,GAAG;AAC7BC,EAAAA,YAAY,EAAE,EADe;AAE7BC,EAAAA,aAAa,EAAE;AACbC,IAAAA,KAAK,EAAE;AADM,GAFc;AAM7BC,EAAAA,eAAe,EAAEd;AANY,CAA/B;AAUA,MAAMe,qBAAqB,GAAG;AAE5BJ,EAAAA,YAAY,EAAEX;AAFc,CAA9B;;AAKA,SAASgB,mBAAT,CAA6BC,KAA7B,EAAgG;AAE9F,MAAIC,WAAW,CAACC,MAAZ,CAAmBF,KAAnB,CAAJ,EAA+B;AAC7B,WAAO;AAACG,MAAAA,IAAI,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B,EAAyB;AACvB,WAAKyB,WAAL,CAAiB,IAAIlC,QAAJ,CAAa,KAAKqC,QAAlB,EAA4B;AAAC5B,QAAAA,IAAI,EAAER,uBAAuB,CAACyB,IAAD;AAA9B,OAA5B,CAAjB;AACD;AACF;;AAID2F,EAAAA,YAAY,CAACC,KAAD,EAAiB;AAC3B,SAAK3E,EAAL,CAAQ8B,UAAR,CAAmB,KAAKH,MAAxB,EAAgC,KAAK9B,MAArC;AACA,UAAM+E,KAAK,GAAG,KAAK5E,EAAL,CAAQ6E,kBAAR,CAA2B,KAAKlD,MAAhC,EAAwCgD,KAAxC,CAAd;AACA,SAAK3E,EAAL,CAAQ8B,UAAR,CAAmB,KAAKH,MAAxB,EAAgC,IAAhC;AACA,WAAOiD,KAAP;AACD;;AAIO,MAAJ9G,IAAI,GAAG;AACT,WAAO,KAAK4B,QAAL,CAAc5B,IAArB;AACD;;AAvYoD","sourcesContent":["import type {Device, BufferProps, TypedArray} from '@luma.gl/api';\nimport {Buffer, log, assert, checkProps} from '@luma.gl/api';\nimport GL from '@luma.gl/constants';\nimport {assertWebGL2Context} from '../context/context/webgl-checks';\nimport {AccessorObject} from '../types';\nimport Accessor from './accessor';\nimport {getGLTypeFromTypedArray, getTypedArrayFromGLType} from './typed-array-utils';\n\nimport WebGLDevice from '../adapter/webgl-device';\nimport WEBGLBuffer from '../adapter/resources/webgl-buffer';\n\nconst DEBUG_DATA_LENGTH = 10;\n\n// Shared prop checks for constructor and setProps\nconst DEPRECATED_PROPS = {\n offset: 'accessor.offset',\n stride: 'accessor.stride',\n type: 'accessor.type',\n size: 'accessor.size',\n divisor: 'accessor.divisor',\n normalized: 'accessor.normalized',\n integer: 'accessor.integer',\n instanced: 'accessor.divisor',\n isInstanced: 'accessor.divisor'\n};\n\n// Prop checks for constructor\nconst PROP_CHECKS_INITIALIZE = {\n removedProps: {},\n replacedProps: {\n bytes: 'byteLength'\n },\n // new Buffer() with individual accessor props is still used in apps, emit warnings\n deprecatedProps: DEPRECATED_PROPS\n};\n\n// Prop checks for setProps\nconst PROP_CHECKS_SET_PROPS = {\n // Buffer.setProps() with individual accessor props is rare => emit errors\n removedProps: DEPRECATED_PROPS\n};\n\nfunction getWEBGLBufferProps(props: ClassicBufferProps | ArrayBufferView | number): BufferProps {\n // Signature `new Buffer(gl, new Float32Array(...)`\n if (ArrayBuffer.isView(props)) {\n return {data: props};\n }\n\n // Signature: `new Buffer(gl, 100)`\n else if (typeof props === 'number') {\n return {byteLength: props as number};\n }\n\n props = checkProps('Buffer', props, PROP_CHECKS_INITIALIZE);\n const bufferProps = {...props as ClassicBufferProps};\n if (bufferProps.offset) {\n bufferProps.byteOffset = bufferProps.offset;\n }\n return bufferProps;\n}\n\n/** WebGL Buffer interface */\nexport type ClassicBufferProps = BufferProps & {\n handle?: WebGLBuffer;\n\n target?: number;\n webglUsage?: number;\n\n accessor?: AccessorObject;\n\n /** @deprecated */\n index?: number;\n /** @deprecated */\n offset?: number;\n /** @deprecated */\n size?: number;\n /** @deprecated */\n type?: number\n}\n\n/** WebGL Buffer interface */\nexport default class ClassicBuffer extends WEBGLBuffer {\n usage: number;\n accessor: Accessor;\n\n constructor(device: Device | WebGLRenderingContext, props?: ClassicBufferProps);\n constructor(device: Device | WebGLRenderingContext, data: ArrayBufferView | number[]);\n constructor(device: Device | WebGLRenderingContext, byteLength: number);\n\n constructor(device: Device | WebGLRenderingContext, props = {}) {\n super(WebGLDevice.attach(device), getWEBGLBufferProps(props));\n\n // Base class initializes\n // this.initialize(props);\n\n // Deprecated: Merge main props and accessor\n this.setAccessor(Object.assign({}, props, (props as ClassicBufferProps).accessor));\n\n // infer GL type from supplied typed array\n if (this.props.data) {\n const type = getGLTypeFromTypedArray(this.props.data as TypedArray);\n assert(type);\n this.setAccessor(new Accessor(this.accessor, {type}));\n }\n\n Object.seal(this);\n }\n\n destroy(): void {\n if (this.handle) {\n this.removeStats();\n this.trackDeallocatedMemory();\n this.gl.deleteBuffer(this.handle);\n // this.handle = null;\n this.destroyed = true;\n }\n }\n\n write(data: TypedArray, byteOffset?: number): void {\n this.subData({data, offset: byteOffset});\n }\n // returns number of elements in the buffer (assuming that the full buffer is used)\n getElementCount(accessor: AccessorObject = this.accessor): number {\n return Math.round(this.byteLength / Accessor.getBytesPerElement(accessor));\n }\n\n // returns number of vertices in the buffer (assuming that the full buffer is used)\n getVertexCount(accessor: AccessorObject = this.accessor): number {\n return Math.round(this.byteLength / Accessor.getBytesPerVertex(accessor));\n }\n\n // Creates and initializes the buffer object's data store.\n // Signature: `new Buffer(gl, {data: new Float32Array(...)})`\n // Signature: `new Buffer(gl, new Float32Array(...))`\n // Signature: `new Buffer(gl, 100)`\n initialize(props: ClassicBufferProps = {}): this {\n // Signature `new Buffer(gl, new Float32Array(...)`\n if (ArrayBuffer.isView(props)) {\n props = {data: props};\n }\n\n // Signature: `new Buffer(gl, 100)`\n if (Number.isFinite(props)) {\n // @ts-expect-error\n props = {byteLength: props};\n }\n\n props = checkProps('Buffer', props, PROP_CHECKS_INITIALIZE);\n\n // Initialize member fields\n this.webglUsage = props.webglUsage || GL.STATIC_DRAW;\n this.debugData = null;\n\n // Deprecated: Merge main props and accessor\n this.setAccessor(Object.assign({}, props, props.accessor));\n\n // Set data: (re)initializes the buffer\n if (props.data) {\n this._setData(props.data, props.offset, props.byteLength);\n } else {\n this._setByteLength(props.byteLength || 0);\n }\n\n return this;\n }\n\n setProps(props: ClassicBufferProps): this {\n props = checkProps('Buffer', props, PROP_CHECKS_SET_PROPS);\n\n if ('accessor' in props) {\n this.setAccessor(props.accessor);\n }\n\n return this;\n }\n\n // Optionally stores an accessor with the buffer, makes it easier to use it as an attribute later\n // {type, size = 1, offset = 0, stride = 0, normalized = false, integer = false, divisor = 0}\n setAccessor(accessor: AccessorObject | Accessor): this {\n // NOTE: From luma.gl v7.0, Accessors have an optional `buffer `field\n // (mainly to support \"interleaving\")\n // To avoid confusion, ensure `buffer.accessor` does not have a `buffer.accessor.buffer` field:\n accessor = Object.assign({}, accessor);\n // @ts-expect-error\n delete accessor.buffer;\n\n // This new statement ensures that an \"accessor object\" is re-packaged as an Accessor instance\n this.accessor = new Accessor(accessor);\n return this;\n }\n\n // Allocate a bigger GPU buffer (if the current buffer is not big enough).\n // If a reallocation is triggered it clears the buffer\n // Returns:\n // `true`: buffer was reallocated, data was cleared\n // `false`: buffer was big enough, data is intact\n reallocate(byteLength: number): boolean {\n if (byteLength > this.byteLength) {\n this._setByteLength(byteLength);\n return true;\n }\n this.bytesUsed = byteLength;\n return false;\n }\n\n // Update with new data. Reinitializes the buffer\n setData(props: ClassicBufferProps) {\n return this.initialize(props);\n }\n\n // Updates a subset of a buffer object's data store.\n // Data (Typed Array or ArrayBuffer), length is inferred unless provided\n // Offset into buffer\n // WebGL2 only: Offset into srcData\n // WebGL2 only: Number of bytes to be copied\n subData(options: TypedArray | {data: TypedArray, offset?: number; srcOffset?: number; byteLength?: number, length?: number}) {\n // Signature: buffer.subData(new Float32Array([...]))\n if (ArrayBuffer.isView(options)) {\n options = {data: options};\n }\n\n const {data, offset = 0, srcOffset = 0} = options;\n const byteLength = options.byteLength || options.length;\n\n assert(data);\n\n // Create the buffer - binding it here for the first time locks the type\n // In WebGL2, use GL.COPY_WRITE_BUFFER to avoid locking the type\n // @ts-expect-error\n const target = this.gl.webgl2 ? GL.COPY_WRITE_BUFFER : this.target;\n this.gl.bindBuffer(target, this.handle);\n // WebGL2: subData supports additional srcOffset and length parameters\n if (srcOffset !== 0 || byteLength !== undefined) {\n assertWebGL2Context(this.gl);\n // @ts-expect-error\n this.gl.bufferSubData(this.target, offset, data, srcOffset, byteLength);\n } else {\n this.gl.bufferSubData(target, offset, data);\n }\n this.gl.bindBuffer(target, null);\n\n // TODO - update local `data` if offsets are right\n this.debugData = null;\n\n this._inferType(data);\n\n return this;\n }\n\n /**\n * Copies part of the data of another buffer into this buffer\n * @note WEBGL2 ONLY\n */\n copyData(options: {\n sourceBuffer: any;\n readOffset?: number;\n writeOffset?: number;\n size: any;\n }): this {\n const {sourceBuffer, readOffset = 0, writeOffset = 0, size} = options;\n const {gl, gl2} = this;\n assertWebGL2Context(gl);\n\n // Use GL.COPY_READ_BUFFER+GL.COPY_WRITE_BUFFER avoid disturbing other targets and locking type\n gl.bindBuffer(GL.COPY_READ_BUFFER, sourceBuffer.handle);\n gl.bindBuffer(GL.COPY_WRITE_BUFFER, this.handle);\n gl2?.copyBufferSubData(GL.COPY_READ_BUFFER, GL.COPY_WRITE_BUFFER, readOffset, writeOffset, size);\n gl.bindBuffer(GL.COPY_READ_BUFFER, null);\n gl.bindBuffer(GL.COPY_WRITE_BUFFER, null);\n\n // TODO - update local `data` if offsets are 0\n this.debugData = null;\n\n return this;\n }\n\n /**\n * Reads data from buffer into an ArrayBufferView or SharedArrayBuffer.\n * @note WEBGL2 ONLY\n */\n getData(options?: {\n dstData?: any;\n srcByteOffset?: number;\n dstOffset?: number;\n length?: number;\n }): any {\n let {dstData = null, length = 0} = options || {};\n const {srcByteOffset = 0, dstOffset = 0} = options || {};\n assertWebGL2Context(this.gl);\n\n const ArrayType = getTypedArrayFromGLType(this.accessor.type || GL.FLOAT, {clamped: false});\n const sourceAvailableElementCount = this._getAvailableElementCount(srcByteOffset);\n\n const dstElementOffset = dstOffset;\n\n let dstAvailableElementCount;\n let dstElementCount;\n if (dstData) {\n dstElementCount = dstData.length;\n dstAvailableElementCount = dstElementCount - dstElementOffset;\n } else {\n // Allocate ArrayBufferView with enough size to copy all eligible data.\n dstAvailableElementCount = Math.min(\n sourceAvailableElementCount,\n length || sourceAvailableElementCount\n );\n dstElementCount = dstElementOffset + dstAvailableElementCount;\n }\n\n const copyElementCount = Math.min(sourceAvailableElementCount, dstAvailableElementCount);\n length = length || copyElementCount;\n assert(length <= copyElementCount);\n dstData = dstData || new ArrayType(dstElementCount);\n\n // Use GL.COPY_READ_BUFFER to avoid disturbing other targets and locking type\n this.gl.bindBuffer(GL.COPY_READ_BUFFER, this.handle);\n this.gl2?.getBufferSubData(GL.COPY_READ_BUFFER, srcByteOffset, dstData, dstOffset, length);\n this.gl.bindBuffer(GL.COPY_READ_BUFFER, null);\n\n // TODO - update local `data` if offsets are 0\n return dstData;\n }\n\n /**\n * Binds a buffer to a given binding point (target).\n * GL.TRANSFORM_FEEDBACK_BUFFER and GL.UNIFORM_BUFFER take an index, and optionally a range.\n * - GL.TRANSFORM_FEEDBACK_BUFFER and GL.UNIFORM_BUFFER need an index to affect state\n * - GL.UNIFORM_BUFFER: `offset` must be aligned to GL.UNIFORM_BUFFER_OFFSET_ALIGNMENT.\n * - GL.UNIFORM_BUFFER: `size` must be a minimum of GL.UNIFORM_BLOCK_SIZE_DATA.\n */\n bind(options?: {target?: number; index?: any; offset?: number; size: any}): this {\n const {\n target = this.target, // target for the bind operation\n index = this.accessor && this.accessor.index, // index = index of target (indexed bind point)\n offset = 0,\n size\n } = options || {};\n // NOTE: While GL.TRANSFORM_FEEDBACK_BUFFER and GL.UNIFORM_BUFFER could\n // be used as direct binding points, they will not affect transform feedback or\n // uniform buffer state. Instead indexed bindings need to be made.\n if (target === GL.UNIFORM_BUFFER || target === GL.TRANSFORM_FEEDBACK_BUFFER) {\n if (size !== undefined) {\n this.gl2?.bindBufferRange(target, index, this.handle, offset, size);\n } else {\n assert(offset === 0); // Make sure offset wasn't supplied\n this.gl2?.bindBufferBase(target, index, this.handle);\n }\n } else {\n this.gl.bindBuffer(target, this.handle);\n }\n\n return this;\n }\n\n unbind(options?: {target?: any; index?: any}): this {\n const {target = this.target, index = this.accessor && this.accessor.index} = options || {};\n const isIndexedBuffer = target === GL.UNIFORM_BUFFER || target === GL.TRANSFORM_FEEDBACK_BUFFER;\n if (isIndexedBuffer) {\n this.gl2?.bindBufferBase(target, index, null);\n } else {\n this.gl.bindBuffer(target, null);\n }\n return this;\n }\n\n // PROTECTED METHODS (INTENDED FOR USE BY OTHER FRAMEWORK CODE ONLY)\n\n // Returns a short initial data array\n getDebugData(): {\n data: any;\n changed: boolean;\n } {\n if (!this.debugData) {\n this.debugData = this.getData({length: Math.min(DEBUG_DATA_LENGTH, this.byteLength)});\n return {data: this.debugData, changed: true};\n }\n return {data: this.debugData, changed: false};\n }\n\n invalidateDebugData() {\n this.debugData = null;\n }\n\n // PRIVATE METHODS\n\n // Allocate a new buffer and initialize to contents of typed array\n _setData(data, offset: number = 0, byteLength: number = data.byteLength + offset): this {\n assert(ArrayBuffer.isView(data));\n\n this.trackDeallocatedMemory();\n\n const target = this._getTarget();\n this.gl.bindBuffer(target, this.handle);\n this.gl.bufferData(target, byteLength, this.webglUsage);\n this.gl.bufferSubData(target, offset, data);\n this.gl.bindBuffer(target, null);\n\n this.debugData = data.slice(0, DEBUG_DATA_LENGTH);\n this.bytesUsed = byteLength;\n this.byteLength = byteLength;\n this.trackAllocatedMemory(byteLength);\n\n // infer GL type from supplied typed array\n const type = getGLTypeFromTypedArray(data);\n assert(type);\n this.setAccessor(new Accessor(this.accessor, {type}));\n return this;\n }\n\n // Allocate a GPU buffer of specified size.\n _setByteLength(byteLength: number, webglUsage = this.webglUsage): this {\n assert(byteLength >= 0);\n\n this.trackDeallocatedMemory();\n\n // Workaround needed for Safari (#291):\n // gl.bufferData with size equal to 0 crashes. Instead create zero sized array.\n let data = byteLength;\n if (byteLength === 0) {\n // @ts-expect-error\n data = new Float32Array(0);\n }\n\n const target = this._getTarget();\n this.gl.bindBuffer(target, this.handle);\n this.gl.bufferData(target, data, webglUsage);\n this.gl.bindBuffer(target, null);\n\n this.webglUsage = webglUsage;\n this.debugData = null;\n this.bytesUsed = byteLength;\n this.byteLength = byteLength;\n\n this.trackAllocatedMemory(byteLength);\n\n return this;\n }\n\n // Binding a buffer for the first time locks the type\n // In WebGL2, use GL.COPY_WRITE_BUFFER to avoid locking the type\n _getTarget() {\n // @ts-expect-error\n return this.gl.webgl2 ? GL.COPY_WRITE_BUFFER : this.target;\n }\n\n _getAvailableElementCount(srcByteOffset: number) {\n const ArrayType = getTypedArrayFromGLType(this.accessor.type || GL.FLOAT, {clamped: false});\n const sourceElementOffset = srcByteOffset / ArrayType.BYTES_PER_ELEMENT;\n return this.getElementCount() - sourceElementOffset;\n }\n\n // Automatically infers type from typed array passed to setData\n // Note: No longer that useful, since type is now autodeduced from the compiled shaders\n _inferType(data) {\n if (!this.accessor.type) {\n this.setAccessor(new Accessor(this.accessor, {type: getGLTypeFromTypedArray(data)}));\n }\n }\n\n // RESOURCE METHODS\n\n getParameter(pname: GL): any {\n this.gl.bindBuffer(this.target, this.handle);\n const value = this.gl.getBufferParameter(this.target, pname);\n this.gl.bindBuffer(this.target, null);\n return value;\n }\n\n // DEPRECATIONS - v7.0\n /** @deprecated Use Buffer.accessor.type */\n get type() {\n return this.accessor.type;\n }\n}\n"],"file":"buffer.js"}
1
+ {"version":3,"sources":["../../src/classic/buffer.ts"],"names":["assert","checkProps","GL","assertWebGL2Context","Accessor","getGLTypeFromTypedArray","getTypedArrayFromGLType","WebGLDevice","WEBGLBuffer","DEBUG_DATA_LENGTH","DEPRECATED_PROPS","offset","stride","type","size","divisor","normalized","integer","instanced","isInstanced","PROP_CHECKS_INITIALIZE","removedProps","replacedProps","bytes","deprecatedProps","PROP_CHECKS_SET_PROPS","getWEBGLBufferProps","props","ArrayBuffer","isView","data","byteLength","bufferProps","byteOffset","ClassicBuffer","constructor","device","attach","setAccessor","Object","assign","accessor","seal","destroy","handle","removeStats","trackDeallocatedMemory","gl","deleteBuffer","destroyed","write","subData","getElementCount","Math","round","getBytesPerElement","getVertexCount","getBytesPerVertex","initialize","Number","isFinite","webglUsage","STATIC_DRAW","debugData","_setData","_setByteLength","setProps","buffer","reallocate","bytesUsed","setData","options","srcOffset","length","target","webgl2","COPY_WRITE_BUFFER","bindBuffer","undefined","bufferSubData","_inferType","copyData","sourceBuffer","readOffset","writeOffset","gl2","COPY_READ_BUFFER","copyBufferSubData","getData","dstData","srcByteOffset","dstOffset","ArrayType","FLOAT","clamped","sourceAvailableElementCount","_getAvailableElementCount","dstElementOffset","dstAvailableElementCount","dstElementCount","min","copyElementCount","getBufferSubData","bind","index","UNIFORM_BUFFER","TRANSFORM_FEEDBACK_BUFFER","bindBufferRange","bindBufferBase","unbind","isIndexedBuffer","getDebugData","changed","invalidateDebugData","_getTarget","bufferData","slice","trackAllocatedMemory","Float32Array","sourceElementOffset","BYTES_PER_ELEMENT","getParameter","pname","value","getBufferParameter"],"mappings":";AAGA,SAAQA,MAAR,EAAgBC,UAAhB,QAAiC,cAAjC;AACA,OAAOC,EAAP,MAAe,oBAAf;AACA,SAAQC,mBAAR,QAAkC,iCAAlC;AAEA,OAAOC,QAAP,MAAqB,YAArB;AACA,SAAQC,uBAAR,EAAiCC,uBAAjC,QAA+D,qBAA/D;AAEA,OAAOC,WAAP,MAAwB,yBAAxB;AACA,OAAOC,WAAP,MAAwB,mCAAxB;AAEA,MAAMC,iBAAiB,GAAG,EAA1B;AAGA,MAAMC,gBAAgB,GAAG;AACvBC,EAAAA,MAAM,EAAE,iBADe;AAEvBC,EAAAA,MAAM,EAAE,iBAFe;AAGvBC,EAAAA,IAAI,EAAE,eAHiB;AAIvBC,EAAAA,IAAI,EAAE,eAJiB;AAKvBC,EAAAA,OAAO,EAAE,kBALc;AAMvBC,EAAAA,UAAU,EAAE,qBANW;AAOvBC,EAAAA,OAAO,EAAE,kBAPc;AAQvBC,EAAAA,SAAS,EAAE,kBARY;AASvBC,EAAAA,WAAW,EAAE;AATU,CAAzB;AAaA,MAAMC,sBAAsB,GAAG;AAC7BC,EAAAA,YAAY,EAAE,EADe;AAE7BC,EAAAA,aAAa,EAAE;AACbC,IAAAA,KAAK,EAAE;AADM,GAFc;AAM7BC,EAAAA,eAAe,EAAEd;AANY,CAA/B;AAUA,MAAMe,qBAAqB,GAAG;AAE5BJ,EAAAA,YAAY,EAAEX;AAFc,CAA9B;;AAKA,SAASgB,mBAAT,CAA6BC,KAA7B,EAAgG;AAE9F,MAAIC,WAAW,CAACC,MAAZ,CAAmBF,KAAnB,CAAJ,EAA+B;AAC7B,WAAO;AAACG,MAAAA,IAAI,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AnB,EAAyB;AACvB,WAAKyB,WAAL,CAAiB,IAAIlC,QAAJ,CAAa,KAAKqC,QAAlB,EAA4B;AAAC5B,QAAAA,IAAI,EAAER,uBAAuB,CAACyB,IAAD;AAA9B,OAA5B,CAAjB;AACD;AACF;;AAID2F,EAAAA,YAAY,CAACC,KAAD,EAAiB;AAC3B,SAAK3E,EAAL,CAAQ8B,UAAR,CAAmB,KAAKH,MAAxB,EAAgC,KAAK9B,MAArC;AACA,UAAM+E,KAAK,GAAG,KAAK5E,EAAL,CAAQ6E,kBAAR,CAA2B,KAAKlD,MAAhC,EAAwCgD,KAAxC,CAAd;AACA,SAAK3E,EAAL,CAAQ8B,UAAR,CAAmB,KAAKH,MAAxB,EAAgC,IAAhC;AACA,WAAOiD,KAAP;AACD;;AAIO,MAAJ9G,IAAI,GAAG;AACT,WAAO,KAAK4B,QAAL,CAAc5B,IAArB;AACD;;AAxYoD","sourcesContent":["// luma.gl, MIT license\n\nimport type {Device, BufferProps, TypedArray} from '@luma.gl/api';\nimport {assert, checkProps} from '@luma.gl/api';\nimport GL from '@luma.gl/constants';\nimport {assertWebGL2Context} from '../context/context/webgl-checks';\nimport {AccessorObject} from '../types';\nimport Accessor from './accessor';\nimport {getGLTypeFromTypedArray, getTypedArrayFromGLType} from './typed-array-utils';\n\nimport WebGLDevice from '../adapter/webgl-device';\nimport WEBGLBuffer from '../adapter/resources/webgl-buffer';\n\nconst DEBUG_DATA_LENGTH = 10;\n\n// Shared prop checks for constructor and setProps\nconst DEPRECATED_PROPS = {\n offset: 'accessor.offset',\n stride: 'accessor.stride',\n type: 'accessor.type',\n size: 'accessor.size',\n divisor: 'accessor.divisor',\n normalized: 'accessor.normalized',\n integer: 'accessor.integer',\n instanced: 'accessor.divisor',\n isInstanced: 'accessor.divisor'\n};\n\n// Prop checks for constructor\nconst PROP_CHECKS_INITIALIZE = {\n removedProps: {},\n replacedProps: {\n bytes: 'byteLength'\n },\n // new Buffer() with individual accessor props is still used in apps, emit warnings\n deprecatedProps: DEPRECATED_PROPS\n};\n\n// Prop checks for setProps\nconst PROP_CHECKS_SET_PROPS = {\n // Buffer.setProps() with individual accessor props is rare => emit errors\n removedProps: DEPRECATED_PROPS\n};\n\nfunction getWEBGLBufferProps(props: ClassicBufferProps | ArrayBufferView | number): BufferProps {\n // Signature `new Buffer(gl, new Float32Array(...)`\n if (ArrayBuffer.isView(props)) {\n return {data: props};\n }\n\n // Signature: `new Buffer(gl, 100)`\n else if (typeof props === 'number') {\n return {byteLength: props as number};\n }\n\n props = checkProps('Buffer', props, PROP_CHECKS_INITIALIZE);\n const bufferProps = {...props as ClassicBufferProps};\n if (bufferProps.offset) {\n bufferProps.byteOffset = bufferProps.offset;\n }\n return bufferProps;\n}\n\n/** WebGL Buffer interface */\nexport type ClassicBufferProps = BufferProps & {\n handle?: WebGLBuffer;\n\n target?: number;\n webglUsage?: number;\n\n accessor?: AccessorObject;\n\n /** @deprecated */\n index?: number;\n /** @deprecated */\n offset?: number;\n /** @deprecated */\n size?: number;\n /** @deprecated */\n type?: number\n}\n\n/** WebGL Buffer interface */\nexport default class ClassicBuffer extends WEBGLBuffer {\n usage: number;\n accessor: Accessor;\n\n constructor(device: Device | WebGLRenderingContext, props?: ClassicBufferProps);\n constructor(device: Device | WebGLRenderingContext, data: ArrayBufferView | number[]);\n constructor(device: Device | WebGLRenderingContext, byteLength: number);\n\n constructor(device: Device | WebGLRenderingContext, props = {}) {\n super(WebGLDevice.attach(device), getWEBGLBufferProps(props));\n\n // Base class initializes\n // this.initialize(props);\n\n // Deprecated: Merge main props and accessor\n this.setAccessor(Object.assign({}, props, (props as ClassicBufferProps).accessor));\n\n // infer GL type from supplied typed array\n if (this.props.data) {\n const type = getGLTypeFromTypedArray(this.props.data as TypedArray);\n assert(type);\n this.setAccessor(new Accessor(this.accessor, {type}));\n }\n\n Object.seal(this);\n }\n\n override destroy(): void {\n if (this.handle) {\n this.removeStats();\n this.trackDeallocatedMemory();\n this.gl.deleteBuffer(this.handle);\n // this.handle = null;\n this.destroyed = true;\n }\n }\n\n override write(data: TypedArray, byteOffset?: number): void {\n this.subData({data, offset: byteOffset});\n }\n\n // returns number of elements in the buffer (assuming that the full buffer is used)\n getElementCount(accessor: AccessorObject = this.accessor): number {\n return Math.round(this.byteLength / Accessor.getBytesPerElement(accessor));\n }\n\n // returns number of vertices in the buffer (assuming that the full buffer is used)\n getVertexCount(accessor: AccessorObject = this.accessor): number {\n return Math.round(this.byteLength / Accessor.getBytesPerVertex(accessor));\n }\n\n // Creates and initializes the buffer object's data store.\n // Signature: `new Buffer(gl, {data: new Float32Array(...)})`\n // Signature: `new Buffer(gl, new Float32Array(...))`\n // Signature: `new Buffer(gl, 100)`\n initialize(props: ClassicBufferProps = {}): this {\n // Signature `new Buffer(gl, new Float32Array(...)`\n if (ArrayBuffer.isView(props)) {\n props = {data: props};\n }\n\n // Signature: `new Buffer(gl, 100)`\n if (Number.isFinite(props)) {\n // @ts-expect-error\n props = {byteLength: props};\n }\n\n props = checkProps('Buffer', props, PROP_CHECKS_INITIALIZE);\n\n // Initialize member fields\n this.webglUsage = props.webglUsage || GL.STATIC_DRAW;\n this.debugData = null;\n\n // Deprecated: Merge main props and accessor\n this.setAccessor(Object.assign({}, props, props.accessor));\n\n // Set data: (re)initializes the buffer\n if (props.data) {\n this._setData(props.data, props.offset, props.byteLength);\n } else {\n this._setByteLength(props.byteLength || 0);\n }\n\n return this;\n }\n\n setProps(props: ClassicBufferProps): this {\n props = checkProps('Buffer', props, PROP_CHECKS_SET_PROPS);\n\n if ('accessor' in props) {\n this.setAccessor(props.accessor);\n }\n\n return this;\n }\n\n // Optionally stores an accessor with the buffer, makes it easier to use it as an attribute later\n // {type, size = 1, offset = 0, stride = 0, normalized = false, integer = false, divisor = 0}\n setAccessor(accessor: AccessorObject | Accessor): this {\n // NOTE: From luma.gl v7.0, Accessors have an optional `buffer `field\n // (mainly to support \"interleaving\")\n // To avoid confusion, ensure `buffer.accessor` does not have a `buffer.accessor.buffer` field:\n accessor = Object.assign({}, accessor);\n // @ts-expect-error\n delete accessor.buffer;\n\n // This new statement ensures that an \"accessor object\" is re-packaged as an Accessor instance\n this.accessor = new Accessor(accessor);\n return this;\n }\n\n // Allocate a bigger GPU buffer (if the current buffer is not big enough).\n // If a reallocation is triggered it clears the buffer\n // Returns:\n // `true`: buffer was reallocated, data was cleared\n // `false`: buffer was big enough, data is intact\n reallocate(byteLength: number): boolean {\n if (byteLength > this.byteLength) {\n this._setByteLength(byteLength);\n return true;\n }\n this.bytesUsed = byteLength;\n return false;\n }\n\n // Update with new data. Reinitializes the buffer\n setData(props: ClassicBufferProps) {\n return this.initialize(props);\n }\n\n // Updates a subset of a buffer object's data store.\n // Data (Typed Array or ArrayBuffer), length is inferred unless provided\n // Offset into buffer\n // WebGL2 only: Offset into srcData\n // WebGL2 only: Number of bytes to be copied\n subData(options: TypedArray | {data: TypedArray, offset?: number; srcOffset?: number; byteLength?: number, length?: number}) {\n // Signature: buffer.subData(new Float32Array([...]))\n if (ArrayBuffer.isView(options)) {\n options = {data: options};\n }\n\n const {data, offset = 0, srcOffset = 0} = options;\n const byteLength = options.byteLength || options.length;\n\n assert(data);\n\n // Create the buffer - binding it here for the first time locks the type\n // In WebGL2, use GL.COPY_WRITE_BUFFER to avoid locking the type\n // @ts-expect-error\n const target = this.gl.webgl2 ? GL.COPY_WRITE_BUFFER : this.target;\n this.gl.bindBuffer(target, this.handle);\n // WebGL2: subData supports additional srcOffset and length parameters\n if (srcOffset !== 0 || byteLength !== undefined) {\n assertWebGL2Context(this.gl);\n // @ts-expect-error\n this.gl.bufferSubData(this.target, offset, data, srcOffset, byteLength);\n } else {\n this.gl.bufferSubData(target, offset, data);\n }\n this.gl.bindBuffer(target, null);\n\n // TODO - update local `data` if offsets are right\n this.debugData = null;\n\n this._inferType(data);\n\n return this;\n }\n\n /**\n * Copies part of the data of another buffer into this buffer\n * @note WEBGL2 ONLY\n */\n copyData(options: {\n sourceBuffer: any;\n readOffset?: number;\n writeOffset?: number;\n size: any;\n }): this {\n const {sourceBuffer, readOffset = 0, writeOffset = 0, size} = options;\n const {gl, gl2} = this;\n assertWebGL2Context(gl);\n\n // Use GL.COPY_READ_BUFFER+GL.COPY_WRITE_BUFFER avoid disturbing other targets and locking type\n gl.bindBuffer(GL.COPY_READ_BUFFER, sourceBuffer.handle);\n gl.bindBuffer(GL.COPY_WRITE_BUFFER, this.handle);\n gl2?.copyBufferSubData(GL.COPY_READ_BUFFER, GL.COPY_WRITE_BUFFER, readOffset, writeOffset, size);\n gl.bindBuffer(GL.COPY_READ_BUFFER, null);\n gl.bindBuffer(GL.COPY_WRITE_BUFFER, null);\n\n // TODO - update local `data` if offsets are 0\n this.debugData = null;\n\n return this;\n }\n\n /**\n * Reads data from buffer into an ArrayBufferView or SharedArrayBuffer.\n * @note WEBGL2 ONLY\n */\n override getData(options?: {\n dstData?: any;\n srcByteOffset?: number;\n dstOffset?: number;\n length?: number;\n }): any {\n let {dstData = null, length = 0} = options || {};\n const {srcByteOffset = 0, dstOffset = 0} = options || {};\n assertWebGL2Context(this.gl);\n\n const ArrayType = getTypedArrayFromGLType(this.accessor.type || GL.FLOAT, {clamped: false});\n const sourceAvailableElementCount = this._getAvailableElementCount(srcByteOffset);\n\n const dstElementOffset = dstOffset;\n\n let dstAvailableElementCount;\n let dstElementCount;\n if (dstData) {\n dstElementCount = dstData.length;\n dstAvailableElementCount = dstElementCount - dstElementOffset;\n } else {\n // Allocate ArrayBufferView with enough size to copy all eligible data.\n dstAvailableElementCount = Math.min(\n sourceAvailableElementCount,\n length || sourceAvailableElementCount\n );\n dstElementCount = dstElementOffset + dstAvailableElementCount;\n }\n\n const copyElementCount = Math.min(sourceAvailableElementCount, dstAvailableElementCount);\n length = length || copyElementCount;\n assert(length <= copyElementCount);\n dstData = dstData || new ArrayType(dstElementCount);\n\n // Use GL.COPY_READ_BUFFER to avoid disturbing other targets and locking type\n this.gl.bindBuffer(GL.COPY_READ_BUFFER, this.handle);\n this.gl2?.getBufferSubData(GL.COPY_READ_BUFFER, srcByteOffset, dstData, dstOffset, length);\n this.gl.bindBuffer(GL.COPY_READ_BUFFER, null);\n\n // TODO - update local `data` if offsets are 0\n return dstData;\n }\n\n /**\n * Binds a buffer to a given binding point (target).\n * GL.TRANSFORM_FEEDBACK_BUFFER and GL.UNIFORM_BUFFER take an index, and optionally a range.\n * - GL.TRANSFORM_FEEDBACK_BUFFER and GL.UNIFORM_BUFFER need an index to affect state\n * - GL.UNIFORM_BUFFER: `offset` must be aligned to GL.UNIFORM_BUFFER_OFFSET_ALIGNMENT.\n * - GL.UNIFORM_BUFFER: `size` must be a minimum of GL.UNIFORM_BLOCK_SIZE_DATA.\n */\n bind(options?: {target?: number; index?: any; offset?: number; size: any}): this {\n const {\n target = this.target, // target for the bind operation\n index = this.accessor && this.accessor.index, // index = index of target (indexed bind point)\n offset = 0,\n size\n } = options || {};\n // NOTE: While GL.TRANSFORM_FEEDBACK_BUFFER and GL.UNIFORM_BUFFER could\n // be used as direct binding points, they will not affect transform feedback or\n // uniform buffer state. Instead indexed bindings need to be made.\n if (target === GL.UNIFORM_BUFFER || target === GL.TRANSFORM_FEEDBACK_BUFFER) {\n if (size !== undefined) {\n this.gl2?.bindBufferRange(target, index, this.handle, offset, size);\n } else {\n assert(offset === 0); // Make sure offset wasn't supplied\n this.gl2?.bindBufferBase(target, index, this.handle);\n }\n } else {\n this.gl.bindBuffer(target, this.handle);\n }\n\n return this;\n }\n\n unbind(options?: {target?: any; index?: any}): this {\n const {target = this.target, index = this.accessor && this.accessor.index} = options || {};\n const isIndexedBuffer = target === GL.UNIFORM_BUFFER || target === GL.TRANSFORM_FEEDBACK_BUFFER;\n if (isIndexedBuffer) {\n this.gl2?.bindBufferBase(target, index, null);\n } else {\n this.gl.bindBuffer(target, null);\n }\n return this;\n }\n\n // PROTECTED METHODS (INTENDED FOR USE BY OTHER FRAMEWORK CODE ONLY)\n\n // Returns a short initial data array\n getDebugData(): {\n data: any;\n changed: boolean;\n } {\n if (!this.debugData) {\n this.debugData = this.getData({length: Math.min(DEBUG_DATA_LENGTH, this.byteLength)});\n return {data: this.debugData, changed: true};\n }\n return {data: this.debugData, changed: false};\n }\n\n invalidateDebugData() {\n this.debugData = null;\n }\n\n // PRIVATE METHODS\n\n // Allocate a new buffer and initialize to contents of typed array\n _setData(data, offset: number = 0, byteLength: number = data.byteLength + offset): this {\n assert(ArrayBuffer.isView(data));\n\n this.trackDeallocatedMemory();\n\n const target = this._getTarget();\n this.gl.bindBuffer(target, this.handle);\n this.gl.bufferData(target, byteLength, this.webglUsage);\n this.gl.bufferSubData(target, offset, data);\n this.gl.bindBuffer(target, null);\n\n this.debugData = data.slice(0, DEBUG_DATA_LENGTH);\n this.bytesUsed = byteLength;\n this.byteLength = byteLength;\n this.trackAllocatedMemory(byteLength);\n\n // infer GL type from supplied typed array\n const type = getGLTypeFromTypedArray(data);\n assert(type);\n this.setAccessor(new Accessor(this.accessor, {type}));\n return this;\n }\n\n // Allocate a GPU buffer of specified size.\n _setByteLength(byteLength: number, webglUsage = this.webglUsage): this {\n assert(byteLength >= 0);\n\n this.trackDeallocatedMemory();\n\n // Workaround needed for Safari (#291):\n // gl.bufferData with size equal to 0 crashes. Instead create zero sized array.\n let data = byteLength;\n if (byteLength === 0) {\n // @ts-expect-error\n data = new Float32Array(0);\n }\n\n const target = this._getTarget();\n this.gl.bindBuffer(target, this.handle);\n this.gl.bufferData(target, data, webglUsage);\n this.gl.bindBuffer(target, null);\n\n this.webglUsage = webglUsage;\n this.debugData = null;\n this.bytesUsed = byteLength;\n this.byteLength = byteLength;\n\n this.trackAllocatedMemory(byteLength);\n\n return this;\n }\n\n // Binding a buffer for the first time locks the type\n // In WebGL2, use GL.COPY_WRITE_BUFFER to avoid locking the type\n _getTarget() {\n // @ts-expect-error\n return this.gl.webgl2 ? GL.COPY_WRITE_BUFFER : this.target;\n }\n\n _getAvailableElementCount(srcByteOffset: number) {\n const ArrayType = getTypedArrayFromGLType(this.accessor.type || GL.FLOAT, {clamped: false});\n const sourceElementOffset = srcByteOffset / ArrayType.BYTES_PER_ELEMENT;\n return this.getElementCount() - sourceElementOffset;\n }\n\n // Automatically infers type from typed array passed to setData\n // Note: No longer that useful, since type is now autodeduced from the compiled shaders\n _inferType(data) {\n if (!this.accessor.type) {\n this.setAccessor(new Accessor(this.accessor, {type: getGLTypeFromTypedArray(data)}));\n }\n }\n\n // RESOURCE METHODS\n\n getParameter(pname: GL): any {\n this.gl.bindBuffer(this.target, this.handle);\n const value = this.gl.getBufferParameter(this.target, pname);\n this.gl.bindBuffer(this.target, null);\n return value;\n }\n\n // DEPRECATIONS - v7.0\n /** @deprecated Use Buffer.accessor.type */\n get type() {\n return this.accessor.type;\n }\n}\n"],"file":"buffer.js"}
@@ -1,12 +1,6 @@
1
- import { log, loadScript } from '@luma.gl/api/';
1
+ import { log, loadScript } from '@luma.gl/api';
2
2
  import GL from '@luma.gl/constants';
3
3
  const WEBGL_DEBUG_CDN_URL = 'https://unpkg.com/webgl-debug@2.0.1/index.js';
4
- const DEFAULT_DEBUG_CONTEXT_PROPS = {
5
- debug: true,
6
- throwOnError: false,
7
- break: [],
8
- webgl2: false
9
- };
10
4
 
11
5
  function getContextData(gl) {
12
6
  gl.luma = gl.luma || {};
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../src/context/debug/webgl-developer-tools.ts"],"names":["log","loadScript","GL","WEBGL_DEBUG_CDN_URL","DEFAULT_DEBUG_CONTEXT_PROPS","debug","throwOnError","break","webgl2","getContextData","gl","luma","loadWebGLDeveloperTools","globalThis","WebGLDebugUtils","global","module","makeDebugContext","props","getDebugContext","getRealContext","data","realContext","warn","debugContext","init","glDebug","onGLError","bind","onValidateGLFunc","key","WebGLDebugContext","Object","setPrototypeOf","getPrototypeOf","create","getFunctionString","functionName","functionArgs","Array","from","map","arg","undefined","args","glFunctionArgsToString","slice","length","err","errorMessage","glEnumToString","glName","message","error","Error","functionString","level","isBreakpoint","every","breakOn","indexOf"],"mappings":"AACA,S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,EAAqG;AACnG,MAAIiB,cAAsB,GAAG,EAA7B;;AACA,MAAIvD,GAAG,CAACwD,KAAJ,IAAa,CAAjB,EAAoB;AAClBD,IAAAA,cAAc,GAAGnB,iBAAiB,CAACC,YAAD,EAAeC,YAAf,CAAlC;AACAtC,IAAAA,GAAG,CAACA,GAAJ,CAAQ,CAAR,EAAWuD,cAAX;AACD;;AAED,MAAIrC,KAAK,CAACX,KAAV,EAAiB;AACfgD,IAAAA,cAAc,GAAGA,cAAc,IAAInB,iBAAiB,CAACC,YAAD,EAAeC,YAAf,CAApD;AACA,UAAMmB,YAAY,GAChBvC,KAAK,CAACX,KAAN,IAAeW,KAAK,CAACX,KAAN,CAAYmD,KAAZ,CAAmBC,OAAD,IAAqBJ,cAAc,CAACK,OAAf,CAAuBD,OAAvB,MAAoC,CAAC,CAA5E,CADjB;;AAEA,QAAIF,YAAJ,EAAkB;AAChB;AACD;AACF;;AAED,OAAK,MAAMf,GAAX,IAAkBJ,YAAlB,EAAgC;AAC9B,QAAII,GAAG,KAAKC,SAAZ,EAAuB;AACrBY,MAAAA,cAAc,GAAGA,cAAc,IAAInB,iBAAiB,CAACC,YAAD,EAAeC,YAAf,CAApD;;AACA,UAAIpB,KAAK,CAACZ,YAAV,EAAwB;AACtB,cAAM,IAAIgD,KAAJ,+BAAiCC,cAAjC,EAAN;AACD,OAFD,MAEO;AACLvD,QAAAA,GAAG,CAACqD,KAAJ,+BAAiCE,cAAjC;AACA;AACD;AACF;AACF;AACF","sourcesContent":["// luma.gl, MIT license\nimport {log, loadScript} from '@luma.gl/api/';\nimport GL from '@luma.gl/constants';\n\nconst WEBGL_DEBUG_CDN_URL = 'https://unpkg.com/webgl-debug@2.0.1/index.js';\n\ntype DebugContextProps = {\n debug?: boolean;\n throwOnError?: boolean;\n break?: string[];\n webgl2?: boolean;\n};\n\nconst DEFAULT_DEBUG_CONTEXT_PROPS: Required<DebugContextProps> = {\n debug: true,\n throwOnError: false,\n break: [],\n webgl2: false,\n}\n\n// Helper to get shared context data\nfunction getContextData(gl: any) {\n gl.luma = gl.luma || {};\n return gl.luma;\n}\n\ndeclare global {\n var WebGLDebugUtils: any;\n}\n\n/**\n * Loads Khronos WebGLDeveloperTools from CDN if not already installed \n * const WebGLDebugUtils = require('webgl-debug');\n * @see https://github.com/KhronosGroup/WebGLDeveloperTools\n * @see https://github.com/vorg/webgl-debug\n */\nexport async function loadWebGLDeveloperTools(): Promise<void> {\n if (!globalThis.WebGLDebugUtils) {\n // @ts-expect-error Developer tools expects global to be set\n globalThis.global = globalThis.global || globalThis;\n // @ts-expect-error Developer tools expects global to be set\n globalThis.global.module = {};\n await loadScript(WEBGL_DEBUG_CDN_URL);\n }\n}\n\n// Returns (a potentially new) context with debug instrumentation turned off or on.\n// Note that this actually returns a new context\nexport function makeDebugContext(gl: WebGLRenderingContext, props: DebugContextProps = {}): WebGLRenderingContext | null {\n // Return null to ensure we don't try to create a context in this case (TODO what case is that?)\n if (!gl) {\n return null;\n }\n\n return props.debug ? getDebugContext(gl, props) : getRealContext(gl);\n}\n\n// Returns the real context from either of the real/debug contexts\nfunction getRealContext(gl: WebGLRenderingContext): WebGLRenderingContext {\n const data = getContextData(gl);\n // If the context has a realContext member, it is a debug context so return the realContext\n return data.realContext ? data.realContext : gl;\n}\n\n// Returns the debug context from either of the real/debug contexts\nfunction getDebugContext(gl: WebGLRenderingContext, props: DebugContextProps): WebGLRenderingContext {\n if (!globalThis.WebGLDebugUtils) {\n log.warn('webgl-debug not loaded')();\n return gl;\n }\n\n const data = getContextData(gl);\n\n // If this already has a debug context, return it.\n if (data.debugContext) {\n return data.debugContext;\n }\n\n // Create a new debug context\n globalThis.WebGLDebugUtils.init({...GL, ...gl});\n const glDebug = globalThis.WebGLDebugUtils.makeDebugContext(\n gl,\n onGLError.bind(null, props),\n onValidateGLFunc.bind(null, props)\n );\n\n // Make sure we have all WebGL2 and extension constants (todo dynamic import to circumvent minification?)\n for (const key in GL) {\n if (!(key in glDebug) && typeof GL[key] === 'number') {\n glDebug[key] = GL[key];\n }\n }\n \n // Ensure we have a clean prototype on the instrumented object\n // Note: setPrototypeOf does come with perf warnings, but we already take a bigger perf reduction\n // by synchronizing the WebGL errors after each WebGL call.\n class WebGLDebugContext {}\n Object.setPrototypeOf(glDebug, Object.getPrototypeOf(gl));\n Object.setPrototypeOf(WebGLDebugContext, glDebug);\n const debugContext = Object.create(WebGLDebugContext);\n // Store the debug context\n data.realContext = gl;\n data.debugContext = debugContext;\n debugContext.debug = true;\n\n // Return it\n return debugContext;\n}\n\n// DEBUG TRACING\n\nfunction getFunctionString(functionName: string, functionArgs): string {\n // Cover bug in webgl-debug-tools\n functionArgs = Array.from(functionArgs).map(arg => arg === undefined ? 'undefined' : arg);\n let args = globalThis.WebGLDebugUtils.glFunctionArgsToString(functionName, functionArgs);\n args = `${args.slice(0, 100)}${args.length > 100 ? '...' : ''}`;\n return `gl.${functionName}(${args})`;\n}\n\nfunction onGLError(props: DebugContextProps, err, functionName: string, args: any[]): void {\n // Cover bug in webgl-debug-tools\n args = Array.from(args).map(arg => arg === undefined ? 'undefined' : arg);\n const errorMessage = globalThis.WebGLDebugUtils.glEnumToString(err);\n const functionArgs = globalThis.WebGLDebugUtils.glFunctionArgsToString(functionName, args);\n const glName = props.webgl2 ? 'gl2' : 'gl1';\n const message = `${errorMessage} in ${glName}.${functionName}(${functionArgs})`;\n log.error(message)();\n debugger; // eslint-disable-line\n if (props.throwOnError) {\n throw new Error(message);\n }\n}\n\n// Don't generate function string until it is needed\nfunction onValidateGLFunc(props: DebugContextProps, functionName: string, functionArgs: any[]): void {\n let functionString: string = '';\n if (log.level >= 1) {\n functionString = getFunctionString(functionName, functionArgs);\n log.log(1, functionString)();\n }\n\n if (props.break) {\n functionString = functionString || getFunctionString(functionName, functionArgs);\n const isBreakpoint =\n props.break && props.break.every((breakOn: string) => functionString.indexOf(breakOn) !== -1);\n if (isBreakpoint) {\n debugger; // eslint-disable-line\n }\n }\n\n for (const arg of functionArgs) {\n if (arg === undefined) {\n functionString = functionString || getFunctionString(functionName, functionArgs);\n if (props.throwOnError) {\n throw new Error(`Undefined argument: ${functionString}`);\n } else {\n log.error(`Undefined argument: ${functionString}`)();\n debugger; // eslint-disable-line\n }\n }\n }\n}\n"],"file":"webgl-developer-tools.js"}
1
+ {"version":3,"sources":["../../../src/context/debug/webgl-developer-tools.ts"],"names":["log","loadScript","GL","WEBGL_DEBUG_CDN_URL","getContextData","gl","luma","loadWebGLDeveloperTools","globalThis","WebGLDebugUtils","global","module","makeDebugContext","props","debug","getDebugContext","getRealContext","data","realContext","warn","debugContext","init","glDebug","onGLError","bind","onValidateGLFunc","key","WebGLDebugContext","Object","setPrototypeOf","getPrototypeOf","create","getFunctionString","functionName","functionArgs","Array","from","map","arg","undefined","args","glFunctionArgsToString","slice","length","err","errorMessage","glEnumToString","glName","webgl2","message","error","throwOnError","Error","functionString","level","break","isBreakpoint","every","breakOn","indexOf"],"mappings":"AACA,SAAQA,GAAR,EAAaC,UAAb,QAA8B,cAA9B;AACA,OAAOC,EAAP,MAAe,oBAAf;AAEA,MAAMC,mBAAmB,GAAG,8CAA5B;;AAiBA,SAASC,cAAT,CAAwBC,EAAxB,EAAiC;AAC/BA,EAAAA,EAAE,CAACC,IAAH,GAAUD,EAAE,CAACC,IAAH,IAAW,EAArB;AACA,SAAOD,EAAE,CAACC,IAAV;AACD;;AAYD,OAAO,eAAeC,uBAAf,GAAwD;AAC7D,MAAI,CAACC,UAAU,CAACC,eAAhB,EAAiC;AAE/BD,IAAAA,UAAU,CAACE,MAAX,GAAoBF,UAAU,CAACE,MAAX,IAAqBF,UAAzC;AAEAA,IAAAA,UAAU,CAACE,MAAX,CAAkBC,MAAlB,GAA2B,EAA3B;AACA,UAAMV,UAAU,CAACE,mBAAD,CAAhB;AACD;AACF;AAID,OAAO,SAASS,gBAAT,CAA0BP,EAA1B,EAAqDQ,KAAwB,GAAG,EAAhF,EAAkH;AAEvH,MAAI,CAACR,EAAL,EAAS;AACP,WAA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CC,cAAjC,EAAN;AACD,OAFD,MAEO;AACLrD,QAAAA,GAAG,CAACkD,KAAJ,+BAAiCG,cAAjC;AACA;AACD;AACF;AACF;AACF","sourcesContent":["// luma.gl, MIT license\nimport {log, loadScript} from '@luma.gl/api';\nimport GL from '@luma.gl/constants';\n\nconst WEBGL_DEBUG_CDN_URL = 'https://unpkg.com/webgl-debug@2.0.1/index.js';\n\ntype DebugContextProps = {\n debug?: boolean;\n throwOnError?: boolean;\n break?: string[];\n webgl2?: boolean;\n};\n\n// const DEFAULT_DEBUG_CONTEXT_PROPS: Required<DebugContextProps> = {\n// debug: true,\n// throwOnError: false,\n// break: [],\n// webgl2: false,\n// }\n\n// Helper to get shared context data\nfunction getContextData(gl: any) {\n gl.luma = gl.luma || {};\n return gl.luma;\n}\n\ndeclare global {\n var WebGLDebugUtils: any;\n}\n\n/**\n * Loads Khronos WebGLDeveloperTools from CDN if not already installed \n * const WebGLDebugUtils = require('webgl-debug');\n * @see https://github.com/KhronosGroup/WebGLDeveloperTools\n * @see https://github.com/vorg/webgl-debug\n */\nexport async function loadWebGLDeveloperTools(): Promise<void> {\n if (!globalThis.WebGLDebugUtils) {\n // @ts-expect-error Developer tools expects global to be set\n globalThis.global = globalThis.global || globalThis;\n // @ts-expect-error Developer tools expects global to be set\n globalThis.global.module = {};\n await loadScript(WEBGL_DEBUG_CDN_URL);\n }\n}\n\n// Returns (a potentially new) context with debug instrumentation turned off or on.\n// Note that this actually returns a new context\nexport function makeDebugContext(gl: WebGLRenderingContext, props: DebugContextProps = {}): WebGLRenderingContext | null {\n // Return null to ensure we don't try to create a context in this case (TODO what case is that?)\n if (!gl) {\n return null;\n }\n\n return props.debug ? getDebugContext(gl, props) : getRealContext(gl);\n}\n\n// Returns the real context from either of the real/debug contexts\nfunction getRealContext(gl: WebGLRenderingContext): WebGLRenderingContext {\n const data = getContextData(gl);\n // If the context has a realContext member, it is a debug context so return the realContext\n return data.realContext ? data.realContext : gl;\n}\n\n// Returns the debug context from either of the real/debug contexts\nfunction getDebugContext(gl: WebGLRenderingContext, props: DebugContextProps): WebGLRenderingContext {\n if (!globalThis.WebGLDebugUtils) {\n log.warn('webgl-debug not loaded')();\n return gl;\n }\n\n const data = getContextData(gl);\n\n // If this already has a debug context, return it.\n if (data.debugContext) {\n return data.debugContext;\n }\n\n // Create a new debug context\n globalThis.WebGLDebugUtils.init({...GL, ...gl});\n const glDebug = globalThis.WebGLDebugUtils.makeDebugContext(\n gl,\n onGLError.bind(null, props),\n onValidateGLFunc.bind(null, props)\n );\n\n // Make sure we have all WebGL2 and extension constants (todo dynamic import to circumvent minification?)\n for (const key in GL) {\n if (!(key in glDebug) && typeof GL[key] === 'number') {\n glDebug[key] = GL[key];\n }\n }\n \n // Ensure we have a clean prototype on the instrumented object\n // Note: setPrototypeOf does come with perf warnings, but we already take a bigger perf reduction\n // by synchronizing the WebGL errors after each WebGL call.\n class WebGLDebugContext {}\n Object.setPrototypeOf(glDebug, Object.getPrototypeOf(gl));\n Object.setPrototypeOf(WebGLDebugContext, glDebug);\n const debugContext = Object.create(WebGLDebugContext);\n // Store the debug context\n data.realContext = gl;\n data.debugContext = debugContext;\n debugContext.debug = true;\n\n // Return it\n return debugContext;\n}\n\n// DEBUG TRACING\n\nfunction getFunctionString(functionName: string, functionArgs): string {\n // Cover bug in webgl-debug-tools\n functionArgs = Array.from(functionArgs).map(arg => arg === undefined ? 'undefined' : arg);\n let args = globalThis.WebGLDebugUtils.glFunctionArgsToString(functionName, functionArgs);\n args = `${args.slice(0, 100)}${args.length > 100 ? '...' : ''}`;\n return `gl.${functionName}(${args})`;\n}\n\nfunction onGLError(props: DebugContextProps, err, functionName: string, args: any[]): void {\n // Cover bug in webgl-debug-tools\n args = Array.from(args).map(arg => arg === undefined ? 'undefined' : arg);\n const errorMessage = globalThis.WebGLDebugUtils.glEnumToString(err);\n const functionArgs = globalThis.WebGLDebugUtils.glFunctionArgsToString(functionName, args);\n const glName = props.webgl2 ? 'gl2' : 'gl1';\n const message = `${errorMessage} in ${glName}.${functionName}(${functionArgs})`;\n log.error(message)();\n debugger; // eslint-disable-line\n if (props.throwOnError) {\n throw new Error(message);\n }\n}\n\n// Don't generate function string until it is needed\nfunction onValidateGLFunc(props: DebugContextProps, functionName: string, functionArgs: any[]): void {\n let functionString: string = '';\n if (log.level >= 1) {\n functionString = getFunctionString(functionName, functionArgs);\n log.log(1, functionString)();\n }\n\n if (props.break) {\n functionString = functionString || getFunctionString(functionName, functionArgs);\n const isBreakpoint =\n props.break && props.break.every((breakOn: string) => functionString.indexOf(breakOn) !== -1);\n if (isBreakpoint) {\n debugger; // eslint-disable-line\n }\n }\n\n for (const arg of functionArgs) {\n if (arg === undefined) {\n functionString = functionString || getFunctionString(functionName, functionArgs);\n if (props.throwOnError) {\n throw new Error(`Undefined argument: ${functionString}`);\n } else {\n log.error(`Undefined argument: ${functionString}`)();\n debugger; // eslint-disable-line\n }\n }\n }\n}\n"],"file":"webgl-developer-tools.js"}
@@ -1 +1 @@
1
- {"version":3,"file":"unified-parameter-api.d.ts","sourceRoot":"","sources":["../../../src/context/parameters/unified-parameter-api.ts"],"names":[],"mappings":"AAGA,OAAO,EAAC,MAAM,EAAC,MAAM,cAAc,CAAC;AACpC,OAAO,KAAK,EAAC,YAAY,EAAC,MAAM,mBAAmB,CAAC;AAWpD,YAAY,EAAC,YAAY,EAAC,CAAC;AAE3B;;;;;GAKG;AACH,wBAAgB,aAAa,CAC3B,MAAM,EAAE,MAAM,GAAG,qBAAqB,EACtC,UAAU,EAAE,YAAY,GACvB,IAAI,CAiDN;AAED;;;;;;;;;;;;;GAaG;AACH,wBAAgB,aAAa,CAC3B,MAAM,EAAE,MAAM,GAAG,qBAAqB,EACtC,UAAU,GAAE,MAAM,YAAY,GAAG,CAAC,MAAM,YAAY,CAAC,EAAE,GAAG,YAAoC,GAC7F,YAAY,CAqBd;AAED;;;;;GAKG;AACH,wBAAgB,eAAe,CAAC,MAAM,EAAE,MAAM,GAAG,qBAAqB,GAAG,IAAI,CAE5E"}
1
+ {"version":3,"file":"unified-parameter-api.d.ts","sourceRoot":"","sources":["../../../src/context/parameters/unified-parameter-api.ts"],"names":[],"mappings":"AAGA,OAAO,EAAC,MAAM,EAAC,MAAM,cAAc,CAAC;AACpC,OAAO,KAAK,EAAC,YAAY,EAAC,MAAM,mBAAmB,CAAC;AAUpD,YAAY,EAAC,YAAY,EAAC,CAAC;AAE3B;;;;;GAKG;AACH,wBAAgB,aAAa,CAC3B,MAAM,EAAE,MAAM,GAAG,qBAAqB,EACtC,UAAU,EAAE,YAAY,GACvB,IAAI,CAiDN;AAED;;;;;;;;;;;;;GAaG;AACH,wBAAgB,aAAa,CAC3B,MAAM,EAAE,MAAM,GAAG,qBAAqB,EACtC,UAAU,GAAE,MAAM,YAAY,GAAG,CAAC,MAAM,YAAY,CAAC,EAAE,GAAG,YAAoC,GAC7F,YAAY,CAqBd;AAED;;;;;GAKG;AACH,wBAAgB,eAAe,CAAC,MAAM,EAAE,MAAM,GAAG,qBAAqB,GAAG,IAAI,CAE5E"}
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../src/context/parameters/unified-parameter-api.ts"],"names":["GL_PARAMETER_DEFAULTS","GL_PARAMETER_SETTERS","GL_COMPOSITE_PARAMETER_SETTERS","GL_PARAMETER_GETTERS","WebGLDevice","setParameters","device","parameters","webglDevice","attach","gl","isObjectEmpty","compositeSetters","key","glConstant","Number","setter","cache","state","compositeSetter","getParameters","getter","getParameter","parameterKeys","Array","isArray","Object","keys","resetParameters","object"],"mappings":"AAKA,SACEA,qBADF,EAEEC,oBAFF,EAGEC,8BAHF,EAIEC,oBAJF,QAKO,0BALP;AAQA,OAAOC,WAAP,MAAwB,4BAAxB;AAUA,OAAO,SAASC,aAAT,CACLC,MADK,EAELC,UAFK,EAGC;AACN,QAAMC,WAAW,GAAGJ,WAAW,CAACK,MAAZ,CAAmBH,MAAnB,CAApB;AACA,QAAMI,EAAE,GAAGF,WAAW,CAACE,EAAvB;;AAEA,MAAI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QAAMU,aAAa,GAAGC,KAAK,CAACC,OAAN,CAAclB,UAAd,IAA4BA,UAA5B,GAAyCmB,MAAM,CAACC,IAAP,CAAYpB,UAAZ,CAA/D;AAEA,QAAMW,KAAK,GAAG,EAAd;;AACA,OAAK,MAAML,GAAX,IAAkBU,aAAlB,EAAiC;AAC/B,UAAMF,MAAM,GAAGlB,oBAAoB,CAACU,GAAD,CAAnC;AACAK,IAAAA,KAAK,CAACL,GAAD,CAAL,GAAaQ,MAAM,GAAGA,MAAM,CAACX,EAAD,EAAKK,MAAM,CAACF,GAAD,CAAX,CAAT,GAA6BH,EAAE,CAACY,YAAH,CAAgBP,MAAM,CAACF,GAAD,CAAtB,CAAhD;AACD;;AACD,SAAOK,KAAP;AACD;AAQD,OAAO,SAASU,eAAT,CAAyBtB,MAAzB,EAAuE;AAC5ED,EAAAA,aAAa,CAACC,MAAD,EAASN,qBAAT,CAAb;AACD;;AAKD,SAASW,aAAT,CAAuBkB,MAAvB,EAA+B;AAC7B,OAAK,MAAMhB,GAAX,IAAkBgB,MAAlB,EAA0B;AACxB,WAAO,KAAP;AACD;;AACD,SAAO,IAAP;AACD","sourcesContent":["// Provides a unified API for getting and setting any WebGL parameter\n// Also knows default values of all parameters, enabling fast cache initialization\n// Provides base functionality for the state caching.\nimport {Device} from '@luma.gl/api';\nimport type {GLParameters} from '../../types/webgl';\nimport {\n GL_PARAMETER_DEFAULTS,\n GL_PARAMETER_SETTERS,\n GL_COMPOSITE_PARAMETER_SETTERS,\n GL_PARAMETER_GETTERS\n} from './webgl-parameter-tables';\n\nimport {isWebGL} from '../context/webgl-checks';\nimport WebGLDevice from '../../adapter/webgl-device';\n\nexport type {GLParameters};\n\n/**\n * Sets any GL parameter regardless of function (gl.blendMode, ...)\n *\n * @note requires a `cache` object to be set on the context (gl.state.cache)\n * This object is used to fill in any missing values for composite setter functions\n */\nexport function setParameters(\n device: Device | WebGLRenderingContext,\n parameters: GLParameters\n): void {\n const webglDevice = WebGLDevice.attach(device);\n const gl = webglDevice.gl;\n\n if (isObjectEmpty(parameters)) {\n return;\n }\n\n const compositeSetters = {};\n\n // HANDLE PRIMITIVE SETTERS (and make note of any composite setters)\n\n for (const key in parameters) {\n const glConstant = Number(key);\n const setter = GL_PARAMETER_SETTERS[key];\n if (setter) {\n // Composite setters should only be called once, so save them\n if (typeof setter === 'string') {\n compositeSetters[setter] = true;\n } else {\n // if (gl[glConstant] !== undefined) {\n // TODO - added above check since this is being called on WebGL2 parameters in WebGL1...\n // TODO - deep equal on values? only call setter if value has changed?\n // NOTE - the setter will automatically update this.state\n setter(gl, parameters[key], glConstant);\n }\n }\n }\n\n // HANDLE COMPOSITE SETTERS\n\n // NOTE: any non-provided values needed by composite setters are filled in from state cache\n // The cache parameter is automatically retrieved from the context\n // This depends on `trackContextState`, which is technically a \"circular\" dependency.\n // But it is too inconvenient to always require a cache parameter here.\n // This is the ONLY external dependency in this module/\n // @ts-expect-error\n const cache = gl.state && gl.state.cache;\n if (cache) {\n for (const key in compositeSetters) {\n // TODO - avoid calling composite setters if values have not changed.\n const compositeSetter = GL_COMPOSITE_PARAMETER_SETTERS[key];\n // Note - if `trackContextState` has been called,\n // the setter will automatically update this.state.cache\n compositeSetter(gl, parameters, cache);\n }\n }\n\n // Add a log for the else case?\n}\n\n/**\n * Reads the entire WebGL state from a context\n\n // default to querying all parameters\n\n * @returns - a newly created map, with values keyed by GL parameters\n *\n * @note Copies the state from a context (gl.getParameter should not be overriden)\n * Reads the entire WebGL state from a context\n *\n * @note This can generates a huge amount of synchronous driver roundtrips and should be\n * considered a very slow operation, to be used only if/when a context already manipulated\n * by external code needs to be synchronized for the first time\n */\nexport function getParameters(\n device: Device | WebGLRenderingContext,\n parameters: keyof GLParameters | (keyof GLParameters)[] | GLParameters = GL_PARAMETER_DEFAULTS\n): GLParameters {\n const webglDevice = WebGLDevice.attach(device);\n const gl = webglDevice.gl;\n\n // support both arrays of parameters and objects (keys represent parameters)\n\n if (typeof parameters === 'number') {\n // single GL enum\n const key = parameters;\n const getter = GL_PARAMETER_GETTERS[key];\n return getter ? getter(gl, key) : gl.getParameter(key);\n }\n\n const parameterKeys = Array.isArray(parameters) ? parameters : Object.keys(parameters);\n\n const state = {};\n for (const key of parameterKeys) {\n const getter = GL_PARAMETER_GETTERS[key];\n state[key] = getter ? getter(gl, Number(key)) : gl.getParameter(Number(key));\n }\n return state;\n}\n\n/**\n * Reset all parameters to a (almost) pure context state\n * @note viewport and scissor will be set to the values in GL_PARAMETER_DEFAULTS,\n * NOT the canvas size dimensions, so they will have to be properly set after\n * calling this function.\n */\nexport function resetParameters(device: Device | WebGLRenderingContext): void {\n setParameters(device, GL_PARAMETER_DEFAULTS);\n}\n\n// Helpers\n\n// Returns true if given object is empty, false otherwise.\nfunction isObjectEmpty(object) {\n for (const key in object) {\n return false;\n }\n return true;\n}\n"],"file":"unified-parameter-api.js"}
1
+ {"version":3,"sources":["../../../src/context/parameters/unified-parameter-api.ts"],"names":["GL_PARAMETER_DEFAULTS","GL_PARAMETER_SETTERS","GL_COMPOSITE_PARAMETER_SETTERS","GL_PARAMETER_GETTERS","WebGLDevice","setParameters","device","parameters","webglDevice","attach","gl","isObjectEmpty","compositeSetters","key","glConstant","Number","setter","cache","state","compositeSetter","getParameters","getter","getParameter","parameterKeys","Array","isArray","Object","keys","resetParameters","object"],"mappings":"AAKA,SACEA,qBADF,EAEEC,oBAFF,EAGEC,8BAHF,EAIEC,oBAJF,QAKO,0BALP;AAOA,OAAOC,WAAP,MAAwB,4BAAxB;AAUA,OAAO,SAASC,aAAT,CACLC,MADK,EAELC,UAFK,EAGC;AACN,QAAMC,WAAW,GAAGJ,WAAW,CAACK,MAAZ,CAAmBH,MAAnB,CAApB;AACA,QAAMI,EAAE,GAAGF,WAAW,CAACE,EAAvB;;AAEA,MAAIC,aAAa,CAACJ,UAAD,CAAjB,EAA+B;AAC7B;AACD;;AAED,QAAMK,gBAAgB,GAAG,EAAzB;;AAIA,OAAK,MAAMC,GAAX,IAAkBN,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AAEA,QAAMW,KAAK,GAAG,EAAd;;AACA,OAAK,MAAML,GAAX,IAAkBU,aAAlB,EAAiC;AAC/B,UAAMF,MAAM,GAAGlB,oBAAoB,CAACU,GAAD,CAAnC;AACAK,IAAAA,KAAK,CAACL,GAAD,CAAL,GAAaQ,MAAM,GAAGA,MAAM,CAACX,EAAD,EAAKK,MAAM,CAACF,GAAD,CAAX,CAAT,GAA6BH,EAAE,CAACY,YAAH,CAAgBP,MAAM,CAACF,GAAD,CAAtB,CAAhD;AACD;;AACD,SAAOK,KAAP;AACD;AAQD,OAAO,SAASU,eAAT,CAAyBtB,MAAzB,EAAuE;AAC5ED,EAAAA,aAAa,CAACC,MAAD,EAASN,qBAAT,CAAb;AACD;;AAKD,SAASW,aAAT,CAAuBkB,MAAvB,EAA+B;AAE7B,OAAK,MAAMhB,GAAX,IAAkBgB,MAAlB,EAA0B;AACxB,WAAO,KAAP;AACD;;AACD,SAAO,IAAP;AACD","sourcesContent":["// Provides a unified API for getting and setting any WebGL parameter\n// Also knows default values of all parameters, enabling fast cache initialization\n// Provides base functionality for the state caching.\nimport {Device} from '@luma.gl/api';\nimport type {GLParameters} from '../../types/webgl';\nimport {\n GL_PARAMETER_DEFAULTS,\n GL_PARAMETER_SETTERS,\n GL_COMPOSITE_PARAMETER_SETTERS,\n GL_PARAMETER_GETTERS\n} from './webgl-parameter-tables';\n\nimport WebGLDevice from '../../adapter/webgl-device';\n\nexport type {GLParameters};\n\n/**\n * Sets any GL parameter regardless of function (gl.blendMode, ...)\n *\n * @note requires a `cache` object to be set on the context (gl.state.cache)\n * This object is used to fill in any missing values for composite setter functions\n */\nexport function setParameters(\n device: Device | WebGLRenderingContext,\n parameters: GLParameters\n): void {\n const webglDevice = WebGLDevice.attach(device);\n const gl = webglDevice.gl;\n\n if (isObjectEmpty(parameters)) {\n return;\n }\n\n const compositeSetters = {};\n\n // HANDLE PRIMITIVE SETTERS (and make note of any composite setters)\n\n for (const key in parameters) {\n const glConstant = Number(key);\n const setter = GL_PARAMETER_SETTERS[key];\n if (setter) {\n // Composite setters should only be called once, so save them\n if (typeof setter === 'string') {\n compositeSetters[setter] = true;\n } else {\n // if (gl[glConstant] !== undefined) {\n // TODO - added above check since this is being called on WebGL2 parameters in WebGL1...\n // TODO - deep equal on values? only call setter if value has changed?\n // NOTE - the setter will automatically update this.state\n setter(gl, parameters[key], glConstant);\n }\n }\n }\n\n // HANDLE COMPOSITE SETTERS\n\n // NOTE: any non-provided values needed by composite setters are filled in from state cache\n // The cache parameter is automatically retrieved from the context\n // This depends on `trackContextState`, which is technically a \"circular\" dependency.\n // But it is too inconvenient to always require a cache parameter here.\n // This is the ONLY external dependency in this module/\n // @ts-expect-error\n const cache = gl.state && gl.state.cache;\n if (cache) {\n for (const key in compositeSetters) {\n // TODO - avoid calling composite setters if values have not changed.\n const compositeSetter = GL_COMPOSITE_PARAMETER_SETTERS[key];\n // Note - if `trackContextState` has been called,\n // the setter will automatically update this.state.cache\n compositeSetter(gl, parameters, cache);\n }\n }\n\n // Add a log for the else case?\n}\n\n/**\n * Reads the entire WebGL state from a context\n\n // default to querying all parameters\n\n * @returns - a newly created map, with values keyed by GL parameters\n *\n * @note Copies the state from a context (gl.getParameter should not be overriden)\n * Reads the entire WebGL state from a context\n *\n * @note This can generates a huge amount of synchronous driver roundtrips and should be\n * considered a very slow operation, to be used only if/when a context already manipulated\n * by external code needs to be synchronized for the first time\n */\nexport function getParameters(\n device: Device | WebGLRenderingContext,\n parameters: keyof GLParameters | (keyof GLParameters)[] | GLParameters = GL_PARAMETER_DEFAULTS\n): GLParameters {\n const webglDevice = WebGLDevice.attach(device);\n const gl = webglDevice.gl;\n\n // support both arrays of parameters and objects (keys represent parameters)\n\n if (typeof parameters === 'number') {\n // single GL enum\n const key = parameters;\n const getter = GL_PARAMETER_GETTERS[key];\n return getter ? getter(gl, key) : gl.getParameter(key);\n }\n\n const parameterKeys = Array.isArray(parameters) ? parameters : Object.keys(parameters);\n\n const state = {};\n for (const key of parameterKeys) {\n const getter = GL_PARAMETER_GETTERS[key];\n state[key] = getter ? getter(gl, Number(key)) : gl.getParameter(Number(key));\n }\n return state;\n}\n\n/**\n * Reset all parameters to a (almost) pure context state\n * @note viewport and scissor will be set to the values in GL_PARAMETER_DEFAULTS,\n * NOT the canvas size dimensions, so they will have to be properly set after\n * calling this function.\n */\nexport function resetParameters(device: Device | WebGLRenderingContext): void {\n setParameters(device, GL_PARAMETER_DEFAULTS);\n}\n\n// Helpers\n\n// Returns true if given object is empty, false otherwise.\nfunction isObjectEmpty(object) {\n // @ts-ignore dummy key variable\n for (const key in object) {\n return false;\n }\n return true;\n}\n"],"file":"unified-parameter-api.js"}
@@ -2,53 +2,53 @@ import GL from '@luma.gl/constants';
2
2
  import type { GLParameters } from '../../types/webgl';
3
3
  export declare const GL_PARAMETER_DEFAULTS: GLParameters;
4
4
  export declare const GL_PARAMETER_SETTERS: {
5
- 3042: (gl: any, value: any, key: any) => any;
6
- 32773: (gl: any, value: any) => any;
5
+ 3042: (gl: WebGLRenderingContext, value: unknown, key: GL) => void;
6
+ 32773: (gl: WebGLRenderingContext, value: [number, number, number, number]) => void;
7
7
  32777: string;
8
8
  34877: string;
9
9
  32969: string;
10
10
  32968: string;
11
11
  32971: string;
12
12
  32970: string;
13
- 3106: (gl: any, value: any) => any;
14
- 3107: (gl: any, value: any) => any;
15
- 2884: (gl: any, value: any, key: any) => any;
16
- 2885: (gl: any, value: any) => any;
17
- 2929: (gl: any, value: any, key: any) => any;
18
- 2931: (gl: any, value: any) => any;
19
- 2932: (gl: any, value: any) => any;
20
- 2928: (gl: any, value: any) => any;
21
- 2930: (gl: any, value: any) => any;
22
- 3024: (gl: any, value: any, key: any) => any;
23
- 35723: (gl: any, value: any, key: any) => any;
24
- 35725: (gl: any, value: any) => any;
25
- 36007: (gl: any, value: any) => any;
26
- 36389: (gl: any, value: any) => any;
27
- 34229: (gl: any, value: any) => any;
28
- 36006: (gl: any, value: any, key: any) => any;
29
- 36010: (gl: any, value: any, key: any) => any;
30
- 34964: (gl: any, value: any, key: any) => void;
31
- 36662: (gl: any, value: any, key: any) => void;
32
- 36663: (gl: any, value: any, key: any) => void;
33
- 35053: (gl: any, value: any, key: any) => void;
34
- 35055: (gl: any, value: any, key: any) => void;
35
- 2886: (gl: any, value: any) => any;
36
- 33170: (gl: any, value: any, key: any) => any;
37
- 2849: (gl: any, value: any) => any;
38
- 32823: (gl: any, value: any, key: any) => any;
13
+ 3106: (gl: WebGLRenderingContext, value: [number, number, number, number]) => void;
14
+ 3107: (gl: WebGLRenderingContext, value: [boolean, boolean, boolean, boolean]) => void;
15
+ 2884: (gl: WebGLRenderingContext, value: unknown, key: GL) => void;
16
+ 2885: (gl: WebGLRenderingContext, value: any) => void;
17
+ 2929: (gl: WebGLRenderingContext, value: unknown, key: GL) => void;
18
+ 2931: (gl: WebGLRenderingContext, value: any) => void;
19
+ 2932: (gl: WebGLRenderingContext, value: any) => void;
20
+ 2928: (gl: WebGLRenderingContext, value: [number, number]) => void;
21
+ 2930: (gl: WebGLRenderingContext, value: any) => void;
22
+ 3024: (gl: WebGLRenderingContext, value: unknown, key: GL) => void;
23
+ 35723: (gl: WebGLRenderingContext, value: GL, key: GL) => void;
24
+ 35725: (gl: WebGLRenderingContext, value: any) => void;
25
+ 36007: (gl: WebGLRenderingContext, value: any) => void;
26
+ 36389: (gl: WebGLRenderingContext, value: any) => void;
27
+ 34229: (gl: WebGLRenderingContext, value: any) => void;
28
+ 36006: (gl: WebGLRenderingContext, value: unknown, key: GL) => void;
29
+ 36010: (gl: WebGLRenderingContext, value: unknown, key: GL) => void;
30
+ 34964: (gl: WebGLRenderingContext, value: unknown, key: GL) => void;
31
+ 36662: (gl: WebGLRenderingContext, value: unknown, key: GL) => void;
32
+ 36663: (gl: WebGLRenderingContext, value: unknown, key: GL) => void;
33
+ 35053: (gl: WebGLRenderingContext, value: unknown, key: GL) => void;
34
+ 35055: (gl: WebGLRenderingContext, value: unknown, key: GL) => void;
35
+ 2886: (gl: WebGLRenderingContext, value: any) => void;
36
+ 33170: (gl: WebGLRenderingContext, value: GL, key: GL) => void;
37
+ 2849: (gl: WebGLRenderingContext, value: any) => void;
38
+ 32823: (gl: WebGLRenderingContext, value: unknown, key: GL) => void;
39
39
  32824: string;
40
40
  10752: string;
41
- 35977: (gl: any, value: any, key: any) => any;
42
- 32926: (gl: any, value: any, key: any) => any;
43
- 32928: (gl: any, value: any, key: any) => any;
41
+ 35977: (gl: WebGLRenderingContext, value: unknown, key: GL) => void;
42
+ 32926: (gl: WebGLRenderingContext, value: unknown, key: GL) => void;
43
+ 32928: (gl: WebGLRenderingContext, value: unknown, key: GL) => void;
44
44
  32938: string;
45
45
  32939: string;
46
- 3089: (gl: any, value: any, key: any) => any;
47
- 3088: (gl: any, value: any) => any;
48
- 2960: (gl: any, value: any, key: any) => any;
49
- 2961: (gl: any, value: any) => any;
50
- 2968: (gl: any, value: any) => any;
51
- 36005: (gl: any, value: any) => any;
46
+ 3089: (gl: WebGLRenderingContext, value: unknown, key: GL) => void;
47
+ 3088: (gl: WebGLRenderingContext, value: [number, number, number, number]) => void;
48
+ 2960: (gl: WebGLRenderingContext, value: unknown, key: GL) => void;
49
+ 2961: (gl: WebGLRenderingContext, value: any) => void;
50
+ 2968: (gl: WebGLRenderingContext, value: any) => void;
51
+ 36005: (gl: WebGLRenderingContext, value: any) => void;
52
52
  2962: string;
53
53
  2967: string;
54
54
  2963: string;
@@ -61,67 +61,67 @@ export declare const GL_PARAMETER_SETTERS: {
61
61
  34817: string;
62
62
  34818: string;
63
63
  34819: string;
64
- 2978: (gl: any, value: any) => any;
65
- 3333: (gl: any, value: any, key: any) => any;
66
- 3317: (gl: any, value: any, key: any) => any;
67
- 37440: (gl: any, value: any, key: any) => any;
68
- 37441: (gl: any, value: any, key: any) => any;
69
- 37443: (gl: any, value: any, key: any) => any;
70
- 3330: (gl: any, value: any, key: any) => any;
71
- 3332: (gl: any, value: any, key: any) => any;
72
- 3331: (gl: any, value: any, key: any) => any;
73
- 3314: (gl: any, value: any, key: any) => any;
74
- 32878: (gl: any, value: any, key: any) => any;
75
- 3316: (gl: any, value: any, key: any) => any;
76
- 3315: (gl: any, value: any, key: any) => any;
77
- 32877: (gl: any, value: any, key: any) => any;
78
- framebuffer: (gl: any, framebuffer: any) => any;
79
- blend: (gl: any, value: any) => any;
80
- blendColor: (gl: any, value: any) => any;
81
- blendEquation: (gl: any, args: any) => void;
82
- blendFunc: (gl: any, args: any) => void;
83
- clearColor: (gl: any, value: any) => any;
84
- clearDepth: (gl: any, value: any) => any;
85
- clearStencil: (gl: any, value: any) => any;
86
- colorMask: (gl: any, value: any) => any;
87
- cull: (gl: any, value: any) => any;
88
- cullFace: (gl: any, value: any) => any;
89
- depthTest: (gl: any, value: any) => any;
90
- depthFunc: (gl: any, value: any) => any;
91
- depthMask: (gl: any, value: any) => any;
92
- depthRange: (gl: any, value: any) => any;
93
- dither: (gl: any, value: any) => any;
94
- derivativeHint: (gl: any, value: any) => void;
95
- frontFace: (gl: any, value: any) => any;
96
- mipmapHint: (gl: any, value: any) => any;
97
- lineWidth: (gl: any, value: any) => any;
98
- polygonOffsetFill: (gl: any, value: any) => any;
99
- polygonOffset: (gl: any, value: any) => any;
100
- sampleCoverage: (gl: any, value: any) => any;
101
- scissorTest: (gl: any, value: any) => any;
102
- scissor: (gl: any, value: any) => any;
103
- stencilTest: (gl: any, value: any) => any;
104
- stencilMask: (gl: any, value: any) => void;
105
- stencilFunc: (gl: any, args: any) => void;
106
- stencilOp: (gl: any, args: any) => void;
107
- viewport: (gl: any, value: any) => any;
64
+ 2978: (gl: WebGLRenderingContext, value: [number, number, number, number]) => void;
65
+ 3333: (gl: WebGLRenderingContext, value: number | boolean, key: GL) => void;
66
+ 3317: (gl: WebGLRenderingContext, value: number | boolean, key: GL) => void;
67
+ 37440: (gl: WebGLRenderingContext, value: number | boolean, key: GL) => void;
68
+ 37441: (gl: WebGLRenderingContext, value: number | boolean, key: GL) => void;
69
+ 37443: (gl: WebGLRenderingContext, value: number | boolean, key: GL) => void;
70
+ 3330: (gl: WebGLRenderingContext, value: number | boolean, key: GL) => void;
71
+ 3332: (gl: WebGLRenderingContext, value: number | boolean, key: GL) => void;
72
+ 3331: (gl: WebGLRenderingContext, value: number | boolean, key: GL) => void;
73
+ 3314: (gl: WebGLRenderingContext, value: number | boolean, key: GL) => void;
74
+ 32878: (gl: WebGLRenderingContext, value: number | boolean, key: GL) => void;
75
+ 3316: (gl: WebGLRenderingContext, value: number | boolean, key: GL) => void;
76
+ 3315: (gl: WebGLRenderingContext, value: number | boolean, key: GL) => void;
77
+ 32877: (gl: WebGLRenderingContext, value: number | boolean, key: GL) => void;
78
+ framebuffer: (gl: WebGLRenderingContext, framebuffer: any) => void;
79
+ blend: (gl: WebGLRenderingContext, value: any) => void;
80
+ blendColor: (gl: WebGLRenderingContext, value: [number, number, number, number]) => void;
81
+ blendEquation: (gl: WebGLRenderingContext, args: number | [number, number]) => void;
82
+ blendFunc: (gl: WebGLRenderingContext, args: [number, number] | [number, number, number, number]) => void;
83
+ clearColor: (gl: WebGLRenderingContext, value: [number, number, number, number]) => void;
84
+ clearDepth: (gl: WebGLRenderingContext, value: any) => void;
85
+ clearStencil: (gl: WebGLRenderingContext, value: any) => void;
86
+ colorMask: (gl: WebGLRenderingContext, value: [boolean, boolean, boolean, boolean]) => void;
87
+ cull: (gl: WebGLRenderingContext, value: any) => void;
88
+ cullFace: (gl: WebGLRenderingContext, value: any) => void;
89
+ depthTest: (gl: WebGLRenderingContext, value: any) => void;
90
+ depthFunc: (gl: WebGLRenderingContext, value: any) => void;
91
+ depthMask: (gl: WebGLRenderingContext, value: any) => void;
92
+ depthRange: (gl: WebGLRenderingContext, value: [number, number]) => void;
93
+ dither: (gl: WebGLRenderingContext, value: any) => void;
94
+ derivativeHint: (gl: WebGLRenderingContext, value: any) => void;
95
+ frontFace: (gl: WebGLRenderingContext, value: any) => void;
96
+ mipmapHint: (gl: WebGLRenderingContext, value: any) => void;
97
+ lineWidth: (gl: WebGLRenderingContext, value: any) => void;
98
+ polygonOffsetFill: (gl: WebGLRenderingContext, value: any) => void;
99
+ polygonOffset: (gl: WebGLRenderingContext, value: [number, number]) => void;
100
+ sampleCoverage: (gl: WebGLRenderingContext, value: [number, boolean?]) => void;
101
+ scissorTest: (gl: WebGLRenderingContext, value: any) => void;
102
+ scissor: (gl: WebGLRenderingContext, value: [number, number, number, number]) => void;
103
+ stencilTest: (gl: WebGLRenderingContext, value: any) => void;
104
+ stencilMask: (gl: WebGLRenderingContext, value: any) => void;
105
+ stencilFunc: (gl: WebGLRenderingContext, args: any) => void;
106
+ stencilOp: (gl: WebGLRenderingContext, args: any) => void;
107
+ viewport: (gl: WebGLRenderingContext, value: [number, number, number, number]) => void;
108
108
  };
109
109
  export declare const GL_COMPOSITE_PARAMETER_SETTERS: {
110
- blendEquation: (gl: any, values: any, cache: any) => any;
111
- blendFunc: (gl: any, values: any, cache: any) => any;
112
- polygonOffset: (gl: any, values: any, cache: any) => any;
113
- sampleCoverage: (gl: any, values: any, cache: any) => any;
114
- stencilFuncFront: (gl: any, values: any, cache: any) => any;
115
- stencilFuncBack: (gl: any, values: any, cache: any) => any;
116
- stencilOpFront: (gl: any, values: any, cache: any) => any;
117
- stencilOpBack: (gl: any, values: any, cache: any) => any;
110
+ blendEquation: (gl: WebGLRenderingContext, values: any, cache: any) => void;
111
+ blendFunc: (gl: WebGLRenderingContext, values: any, cache: any) => void;
112
+ polygonOffset: (gl: WebGLRenderingContext, values: any, cache: any) => void;
113
+ sampleCoverage: (gl: WebGLRenderingContext, values: any, cache: any) => void;
114
+ stencilFuncFront: (gl: WebGLRenderingContext, values: any, cache: any) => void;
115
+ stencilFuncBack: (gl: WebGLRenderingContext, values: any, cache: any) => void;
116
+ stencilOpFront: (gl: WebGLRenderingContext, values: any, cache: any) => void;
117
+ stencilOpBack: (gl: WebGLRenderingContext, values: any, cache: any) => void;
118
118
  };
119
119
  declare type UpdateFunc = (params: Record<string, any>) => void;
120
120
  export declare const GL_HOOKED_SETTERS: {
121
- enable: (update: UpdateFunc, capability: any) => void;
122
- disable: (update: UpdateFunc, capability: any) => void;
123
- pixelStorei: (update: UpdateFunc, pname: any, value: any) => void;
124
- hint: (update: UpdateFunc, pname: any, hint: any) => void;
121
+ enable: (update: UpdateFunc, capability: GL) => void;
122
+ disable: (update: UpdateFunc, capability: GL) => void;
123
+ pixelStorei: (update: UpdateFunc, pname: GL, value: any) => void;
124
+ hint: (update: UpdateFunc, pname: GL, hint: GL) => void;
125
125
  useProgram: (update: UpdateFunc, value: any) => void;
126
126
  bindRenderbuffer: (update: UpdateFunc, target: any, value: any) => void;
127
127
  bindTransformFeedback: (update: UpdateFunc, target: any, value: any) => void;
@@ -157,16 +157,16 @@ export declare const GL_HOOKED_SETTERS: {
157
157
  viewport: (update: UpdateFunc, x: any, y: any, width: any, height: any) => void;
158
158
  };
159
159
  export declare const GL_PARAMETER_GETTERS: {
160
- 3042: (gl: any, key: any) => any;
161
- 2884: (gl: any, key: any) => any;
162
- 2929: (gl: any, key: any) => any;
163
- 3024: (gl: any, key: any) => any;
164
- 32823: (gl: any, key: any) => any;
165
- 32926: (gl: any, key: any) => any;
166
- 32928: (gl: any, key: any) => any;
167
- 3089: (gl: any, key: any) => any;
168
- 2960: (gl: any, key: any) => any;
169
- 35977: (gl: any, key: any) => any;
160
+ 3042: (gl: WebGLRenderingContext, key: any) => boolean;
161
+ 2884: (gl: WebGLRenderingContext, key: any) => boolean;
162
+ 2929: (gl: WebGLRenderingContext, key: any) => boolean;
163
+ 3024: (gl: WebGLRenderingContext, key: any) => boolean;
164
+ 32823: (gl: WebGLRenderingContext, key: any) => boolean;
165
+ 32926: (gl: WebGLRenderingContext, key: any) => boolean;
166
+ 32928: (gl: WebGLRenderingContext, key: any) => boolean;
167
+ 3089: (gl: WebGLRenderingContext, key: any) => boolean;
168
+ 2960: (gl: WebGLRenderingContext, key: any) => boolean;
169
+ 35977: (gl: WebGLRenderingContext, key: any) => boolean;
170
170
  };
171
171
  export declare const NON_CACHE_PARAMETERS: Set<GL>;
172
172
  export {};
@@ -1 +1 @@
1
- {"version":3,"file":"webgl-parameter-tables.d.ts","sourceRoot":"","sources":["../../../src/context/parameters/webgl-parameter-tables.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,MAAM,oBAAoB,CAAC;AAEpC,OAAO,KAAK,EAAC,YAAY,EAAC,MAAM,mBAAmB,CAAC;AAKpD,eAAO,MAAM,qBAAqB,EAAE,YAiFnC,CAAC;AAuCF,eAAO,MAAM,oBAAoB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAgKhC,CAAC;AAOF,eAAO,MAAM,8BAA8B;;;;;;;;;CAmD1C,CAAC;AAEF,aAAK,UAAU,GAAG,CAAC,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,KAAK,IAAI,CAAC;AAGxD,eAAO,MAAM,iBAAiB;qBAGX,UAAU;sBAIT,UAAU;0BAIN,UAAU;mBAIjB,UAAU;yBAMJ,UAAU;+BAGJ,UAAU;oCAGL,UAAU;8BAGhB,UAAU;8BAIV,UAAU;yBAef,UAAU;;;yBAgBV,UAAU,KAAK,MAAM,KAAK,MAAM,KAAK,MAAM,KAAK,MAAM;4BAKnD,UAAU;oCAMF,UAAU;wBAMtB,UAAU;gCAQF,UAAU;yBAQjB,UAAU,KAAK,MAAM,KAAK,MAAM,KAAK,MAAM,KAAK,MAAM;yBAKtD,UAAU,SAAS,MAAM;2BAKvB,UAAU,KAAK,MAAM;wBAKxB,UAAU,KAAK,MAAM,KAAK,MAAM,KAAK,MAAM,KAAK,MAAM;uBAKvD,UAAU;wBAKT,UAAU;yBAKT,UAAU,SAAS,MAAM,QAAQ,MAAM;wBAKxC,UAAU,QAAQ,MAAM;wBAKxB,UAAU;wBAKV,UAAU;4BAKN,UAAU;6BAMT,UAAU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gB3C,CAAC;AAEF,eAAO,MAAM,oBAAoB,SAuC/B,CAAC"}
@@ -95,18 +95,19 @@ const bindFramebuffer = (gl, value, key) => {
95
95
  };
96
96
 
97
97
  const bindBuffer = (gl, value, key) => {
98
- const target = {
99
- [GL.ARRAY_BUFFER_BINDING]: [GL.ARRAY_BUFFER],
100
- [GL.COPY_READ_BUFFER_BINDING]: [GL.COPY_READ_BUFFER],
101
- [GL.COPY_WRITE_BUFFER_BINDING]: [GL.COPY_WRITE_BUFFER],
102
- [GL.PIXEL_PACK_BUFFER_BINDING]: [GL.PIXEL_PACK_BUFFER],
103
- [GL.PIXEL_UNPACK_BUFFER_BINDING]: [GL.PIXEL_UNPACK_BUFFER]
104
- }[key];
98
+ const bindingMap = {
99
+ [GL.ARRAY_BUFFER_BINDING]: GL.ARRAY_BUFFER,
100
+ [GL.COPY_READ_BUFFER_BINDING]: GL.COPY_READ_BUFFER,
101
+ [GL.COPY_WRITE_BUFFER_BINDING]: GL.COPY_WRITE_BUFFER,
102
+ [GL.PIXEL_PACK_BUFFER_BINDING]: GL.PIXEL_PACK_BUFFER,
103
+ [GL.PIXEL_UNPACK_BUFFER_BINDING]: GL.PIXEL_UNPACK_BUFFER
104
+ };
105
+ const target = bindingMap[key];
105
106
  gl.bindBuffer(target, value);
106
107
  };
107
108
 
108
109
  function isArray(array) {
109
- return Array.isArray(array) || ArrayBuffer.isView(array);
110
+ return Array.isArray(array) || ArrayBuffer.isView(array) && !(array instanceof DataView);
110
111
  }
111
112
 
112
113
  export const GL_PARAMETER_SETTERS = {
@@ -132,9 +133,9 @@ export const GL_PARAMETER_SETTERS = {
132
133
  [GL.CURRENT_PROGRAM]: (gl, value) => gl.useProgram(value),
133
134
  [GL.RENDERBUFFER_BINDING]: (gl, value) => gl.bindRenderbuffer(GL.RENDERBUFFER, value),
134
135
  [GL.TRANSFORM_FEEDBACK_BINDING]: (gl, value) => {
135
- var _gl$bindTransformFeed;
136
+ var _bindTransformFeedbac, _ref;
136
137
 
137
- return (_gl$bindTransformFeed = gl.bindTransformFeedback) === null || _gl$bindTransformFeed === void 0 ? void 0 : _gl$bindTransformFeed.call(gl, GL.TRANSFORM_FEEDBACK, value);
138
+ return (_bindTransformFeedbac = (_ref = gl).bindTransformFeedback) === null || _bindTransformFeedbac === void 0 ? void 0 : _bindTransformFeedbac.call(_ref, GL.TRANSFORM_FEEDBACK, value);
138
139
  },
139
140
  [GL.VERTEX_ARRAY_BINDING]: (gl, value) => gl.bindVertexArray(value),
140
141
  [GL.FRAMEBUFFER_BINDING]: bindFramebuffer,
@@ -194,12 +195,12 @@ export const GL_PARAMETER_SETTERS = {
194
195
  blend: (gl, value) => value ? gl.enable(GL.BLEND) : gl.disable(GL.BLEND),
195
196
  blendColor: (gl, value) => gl.blendColor(...value),
196
197
  blendEquation: (gl, args) => {
197
- args = isArray(args) ? args : [args, args];
198
- gl.blendEquationSeparate(...args);
198
+ const separateModes = typeof args === 'number' ? [args, args] : args;
199
+ gl.blendEquationSeparate(...separateModes);
199
200
  },
200
201
  blendFunc: (gl, args) => {
201
- args = isArray(args) && args.length === 2 ? [...args, ...args] : args;
202
- gl.blendFuncSeparate(...args);
202
+ const separateFuncs = (args === null || args === void 0 ? void 0 : args.length) === 2 ? [...args, ...args] : args;
203
+ gl.blendFuncSeparate(...separateFuncs);
203
204
  },
204
205
  clearColor: (gl, value) => gl.clearColor(...value),
205
206
  clearDepth: (gl, value) => gl.clearDepth(value),