@luma.gl/webgl 9.0.0-alpha.15 → 9.0.0-alpha.16

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (367) hide show
  1. package/dist/adapter/converters/device-parameters.js +199 -136
  2. package/dist/adapter/converters/renderbuffer-formats.d.ts +1 -1
  3. package/dist/adapter/converters/renderbuffer-formats.d.ts.map +1 -1
  4. package/dist/adapter/converters/renderbuffer-formats.js +62 -176
  5. package/dist/adapter/converters/sampler-parameters.js +149 -206
  6. package/dist/adapter/converters/texture-formats.d.ts +2 -2
  7. package/dist/adapter/converters/texture-formats.d.ts.map +1 -1
  8. package/dist/adapter/converters/texture-formats.js +437 -890
  9. package/dist/adapter/converters/vertex-formats.js +15 -33
  10. package/dist/adapter/device-helpers/device-features.js +119 -100
  11. package/dist/adapter/device-helpers/device-limits.d.ts +1 -1
  12. package/dist/adapter/device-helpers/device-limits.d.ts.map +1 -1
  13. package/dist/adapter/device-helpers/device-limits.js +88 -86
  14. package/dist/adapter/device-helpers/get-device-info.js +42 -43
  15. package/dist/adapter/device-helpers/is-old-ie.js +9 -6
  16. package/dist/adapter/helpers/attribute-utils.js +50 -74
  17. package/dist/adapter/helpers/get-shader-info.d.ts +9 -0
  18. package/dist/adapter/helpers/get-shader-info.d.ts.map +1 -0
  19. package/dist/adapter/helpers/get-shader-info.js +27 -0
  20. package/dist/adapter/helpers/get-shader-layout.js +307 -296
  21. package/dist/adapter/helpers/parse-shader-compiler-log.d.ts +1 -1
  22. package/dist/adapter/helpers/parse-shader-compiler-log.d.ts.map +1 -1
  23. package/dist/adapter/helpers/parse-shader-compiler-log.js +32 -33
  24. package/dist/adapter/helpers/set-uniform.js +67 -110
  25. package/dist/adapter/helpers/uniforms.js +80 -85
  26. package/dist/adapter/objects/constants-to-keys.js +33 -33
  27. package/dist/adapter/objects/webgl-renderbuffer.d.ts +1 -1
  28. package/dist/adapter/objects/webgl-renderbuffer.d.ts.map +1 -1
  29. package/dist/adapter/objects/webgl-renderbuffer.js +67 -86
  30. package/dist/adapter/objects/webgl-resource.js +213 -205
  31. package/dist/adapter/objects/webgl-vertex-array-object.d.ts +1 -1
  32. package/dist/adapter/objects/webgl-vertex-array-object.d.ts.map +1 -1
  33. package/dist/adapter/objects/webgl-vertex-array-object.js +74 -76
  34. package/dist/adapter/resources/webgl-buffer.js +150 -147
  35. package/dist/adapter/resources/webgl-command-buffer.d.ts +5 -5
  36. package/dist/adapter/resources/webgl-command-buffer.d.ts.map +1 -1
  37. package/dist/adapter/resources/webgl-command-buffer.js +39 -55
  38. package/dist/adapter/resources/webgl-command-encoder.js +25 -49
  39. package/dist/adapter/resources/webgl-external-texture.js +91 -1
  40. package/dist/adapter/resources/webgl-framebuffer.d.ts +2 -2
  41. package/dist/adapter/resources/webgl-framebuffer.d.ts.map +1 -1
  42. package/dist/adapter/resources/webgl-framebuffer.js +231 -258
  43. package/dist/adapter/resources/webgl-render-pass.d.ts +1 -1
  44. package/dist/adapter/resources/webgl-render-pass.d.ts.map +1 -1
  45. package/dist/adapter/resources/webgl-render-pass.js +8 -18
  46. package/dist/adapter/resources/webgl-render-pipeline.js +316 -378
  47. package/dist/adapter/resources/webgl-sampler.js +42 -47
  48. package/dist/adapter/resources/webgl-shader.d.ts +1 -2
  49. package/dist/adapter/resources/webgl-shader.d.ts.map +1 -1
  50. package/dist/adapter/resources/webgl-shader.js +58 -68
  51. package/dist/adapter/resources/webgl-texture.d.ts +5 -5
  52. package/dist/adapter/resources/webgl-texture.d.ts.map +1 -1
  53. package/dist/adapter/resources/webgl-texture.js +661 -815
  54. package/dist/adapter/webgl-canvas-context.js +55 -49
  55. package/dist/adapter/webgl-device.js +288 -338
  56. package/dist/bundle.js +1 -2
  57. package/dist/classic/accessor.js +120 -127
  58. package/dist/classic/buffer.d.ts +1 -1
  59. package/dist/classic/buffer.d.ts.map +1 -1
  60. package/dist/classic/buffer.js +325 -356
  61. package/dist/classic/typed-array-utils.d.ts +1 -1
  62. package/dist/classic/typed-array-utils.d.ts.map +1 -1
  63. package/dist/classic/typed-array-utils.js +91 -101
  64. package/dist/context/context/create-browser-context.d.ts +1 -2
  65. package/dist/context/context/create-browser-context.d.ts.map +1 -1
  66. package/dist/context/context/create-browser-context.js +61 -52
  67. package/dist/context/context/create-headless-context.d.ts +1 -1
  68. package/dist/context/context/create-headless-context.d.ts.map +1 -1
  69. package/dist/context/context/create-headless-context.js +26 -33
  70. package/dist/context/context/webgl-checks.js +25 -20
  71. package/dist/context/debug/spector.d.ts +1 -2
  72. package/dist/context/debug/spector.d.ts.map +1 -1
  73. package/dist/context/debug/spector.js +53 -62
  74. package/dist/context/debug/webgl-developer-tools.d.ts +1 -1
  75. package/dist/context/debug/webgl-developer-tools.d.ts.map +1 -1
  76. package/dist/context/debug/webgl-developer-tools.js +106 -93
  77. package/dist/context/parameters/unified-parameter-api.js +91 -55
  78. package/dist/context/parameters/webgl-parameter-tables.d.ts +1 -1
  79. package/dist/context/parameters/webgl-parameter-tables.d.ts.map +1 -1
  80. package/dist/context/parameters/webgl-parameter-tables.js +462 -423
  81. package/dist/context/polyfill/context-data.js +16 -12
  82. package/dist/context/polyfill/get-parameter-polyfill.js +91 -76
  83. package/dist/context/polyfill/polyfill-context.js +75 -80
  84. package/dist/context/polyfill/polyfill-table.js +133 -139
  85. package/dist/context/polyfill/polyfill-vertex-array-object.js +255 -297
  86. package/dist/context/state-tracker/deep-array-equal.js +16 -18
  87. package/dist/context/state-tracker/track-context-state.js +183 -161
  88. package/dist/context/state-tracker/with-parameters.js +43 -35
  89. package/dist/dist.min.js +1 -0
  90. package/dist/es5/adapter/converters/device-parameters.js +3 -38
  91. package/dist/es5/adapter/converters/device-parameters.js.map +1 -1
  92. package/dist/es5/adapter/converters/renderbuffer-formats.js +2 -14
  93. package/dist/es5/adapter/converters/renderbuffer-formats.js.map +1 -1
  94. package/dist/es5/adapter/converters/sampler-parameters.js +2 -65
  95. package/dist/es5/adapter/converters/sampler-parameters.js.map +1 -1
  96. package/dist/es5/adapter/converters/texture-formats.js +9 -81
  97. package/dist/es5/adapter/converters/texture-formats.js.map +1 -1
  98. package/dist/es5/adapter/converters/vertex-formats.js +0 -12
  99. package/dist/es5/adapter/converters/vertex-formats.js.map +1 -1
  100. package/dist/es5/adapter/device-helpers/device-features.js +6 -40
  101. package/dist/es5/adapter/device-helpers/device-features.js.map +1 -1
  102. package/dist/es5/adapter/device-helpers/device-limits.js +0 -10
  103. package/dist/es5/adapter/device-helpers/device-limits.js.map +1 -1
  104. package/dist/es5/adapter/device-helpers/get-device-info.js +0 -10
  105. package/dist/es5/adapter/device-helpers/get-device-info.js.map +1 -1
  106. package/dist/es5/adapter/device-helpers/is-old-ie.js +0 -1
  107. package/dist/es5/adapter/device-helpers/is-old-ie.js.map +1 -1
  108. package/dist/es5/adapter/helpers/attribute-utils.js +3 -25
  109. package/dist/es5/adapter/helpers/attribute-utils.js.map +1 -1
  110. package/dist/es5/adapter/helpers/get-shader-info.js +31 -0
  111. package/dist/es5/adapter/helpers/get-shader-info.js.map +1 -0
  112. package/dist/es5/adapter/helpers/get-shader-layout.js +23 -101
  113. package/dist/es5/adapter/helpers/get-shader-layout.js.map +1 -1
  114. package/dist/es5/adapter/helpers/parse-shader-compiler-log.js +6 -24
  115. package/dist/es5/adapter/helpers/parse-shader-compiler-log.js.map +1 -1
  116. package/dist/es5/adapter/helpers/set-uniform.js +0 -33
  117. package/dist/es5/adapter/helpers/set-uniform.js.map +1 -1
  118. package/dist/es5/adapter/helpers/uniforms.js +13 -37
  119. package/dist/es5/adapter/helpers/uniforms.js.map +1 -1
  120. package/dist/es5/adapter/objects/constants-to-keys.js +1 -12
  121. package/dist/es5/adapter/objects/constants-to-keys.js.map +1 -1
  122. package/dist/es5/adapter/objects/webgl-renderbuffer.js +5 -33
  123. package/dist/es5/adapter/objects/webgl-renderbuffer.js.map +1 -1
  124. package/dist/es5/adapter/objects/webgl-resource.js +6 -60
  125. package/dist/es5/adapter/objects/webgl-resource.js.map +1 -1
  126. package/dist/es5/adapter/objects/webgl-vertex-array-object.js +7 -35
  127. package/dist/es5/adapter/objects/webgl-vertex-array-object.js.map +1 -1
  128. package/dist/es5/adapter/resources/webgl-buffer.js +20 -66
  129. package/dist/es5/adapter/resources/webgl-buffer.js.map +1 -1
  130. package/dist/es5/adapter/resources/webgl-command-buffer.js +6 -32
  131. package/dist/es5/adapter/resources/webgl-command-buffer.js.map +1 -1
  132. package/dist/es5/adapter/resources/webgl-command-encoder.js +0 -18
  133. package/dist/es5/adapter/resources/webgl-command-encoder.js.map +1 -1
  134. package/dist/es5/adapter/resources/webgl-external-texture.js.map +1 -1
  135. package/dist/es5/adapter/resources/webgl-framebuffer.js +10 -82
  136. package/dist/es5/adapter/resources/webgl-framebuffer.js.map +1 -1
  137. package/dist/es5/adapter/resources/webgl-render-pass.js +2 -19
  138. package/dist/es5/adapter/resources/webgl-render-pass.js.map +1 -1
  139. package/dist/es5/adapter/resources/webgl-render-pipeline.js +24 -133
  140. package/dist/es5/adapter/resources/webgl-render-pipeline.js.map +1 -1
  141. package/dist/es5/adapter/resources/webgl-sampler.js +2 -28
  142. package/dist/es5/adapter/resources/webgl-sampler.js.map +1 -1
  143. package/dist/es5/adapter/resources/webgl-shader.js +13 -52
  144. package/dist/es5/adapter/resources/webgl-shader.js.map +1 -1
  145. package/dist/es5/adapter/resources/webgl-texture.js +137 -291
  146. package/dist/es5/adapter/resources/webgl-texture.js.map +1 -1
  147. package/dist/es5/adapter/webgl-canvas-context.js +0 -24
  148. package/dist/es5/adapter/webgl-canvas-context.js.map +1 -1
  149. package/dist/es5/adapter/webgl-device.js +40 -127
  150. package/dist/es5/adapter/webgl-device.js.map +1 -1
  151. package/dist/es5/bundle.js +0 -1
  152. package/dist/es5/bundle.js.map +1 -1
  153. package/dist/es5/classic/accessor.js +1 -31
  154. package/dist/es5/classic/accessor.js.map +1 -1
  155. package/dist/es5/classic/buffer.js +32 -102
  156. package/dist/es5/classic/buffer.js.map +1 -1
  157. package/dist/es5/classic/typed-array-utils.js +10 -37
  158. package/dist/es5/classic/typed-array-utils.js.map +1 -1
  159. package/dist/es5/context/context/create-browser-context.js +4 -21
  160. package/dist/es5/context/context/create-browser-context.js.map +1 -1
  161. package/dist/es5/context/context/create-headless-context.js +8 -21
  162. package/dist/es5/context/context/create-headless-context.js.map +1 -1
  163. package/dist/es5/context/context/webgl-checks.js +4 -14
  164. package/dist/es5/context/context/webgl-checks.js.map +1 -1
  165. package/dist/es5/context/debug/spector.js +20 -54
  166. package/dist/es5/context/debug/spector.js.map +1 -1
  167. package/dist/es5/context/debug/webgl-developer-tools.js +19 -65
  168. package/dist/es5/context/debug/webgl-developer-tools.js.map +1 -1
  169. package/dist/es5/context/parameters/unified-parameter-api.js +3 -28
  170. package/dist/es5/context/parameters/unified-parameter-api.js.map +1 -1
  171. package/dist/es5/context/parameters/webgl-parameter-tables.js +18 -65
  172. package/dist/es5/context/parameters/webgl-parameter-tables.js.map +1 -1
  173. package/dist/es5/context/polyfill/context-data.js +0 -3
  174. package/dist/es5/context/polyfill/context-data.js.map +1 -1
  175. package/dist/es5/context/polyfill/get-parameter-polyfill.js +0 -12
  176. package/dist/es5/context/polyfill/get-parameter-polyfill.js.map +1 -1
  177. package/dist/es5/context/polyfill/polyfill-context.js +8 -33
  178. package/dist/es5/context/polyfill/polyfill-context.js.map +1 -1
  179. package/dist/es5/context/polyfill/polyfill-table.js +3 -27
  180. package/dist/es5/context/polyfill/polyfill-table.js.map +1 -1
  181. package/dist/es5/context/polyfill/polyfill-vertex-array-object.js +0 -70
  182. package/dist/es5/context/polyfill/polyfill-vertex-array-object.js.map +1 -1
  183. package/dist/es5/context/state-tracker/deep-array-equal.js +0 -5
  184. package/dist/es5/context/state-tracker/deep-array-equal.js.map +1 -1
  185. package/dist/es5/context/state-tracker/track-context-state.js +10 -53
  186. package/dist/es5/context/state-tracker/track-context-state.js.map +1 -1
  187. package/dist/es5/context/state-tracker/with-parameters.js +1 -13
  188. package/dist/es5/context/state-tracker/with-parameters.js.map +1 -1
  189. package/dist/es5/index.js +72 -99
  190. package/dist/es5/index.js.map +1 -1
  191. package/dist/es5/init.js +0 -3
  192. package/dist/es5/init.js.map +1 -1
  193. package/dist/es5/types/webgl.js +0 -1
  194. package/dist/es5/types/webgl.js.map +1 -1
  195. package/dist/es5/types.js.map +1 -1
  196. package/dist/esm/adapter/converters/device-parameters.js +0 -20
  197. package/dist/esm/adapter/converters/device-parameters.js.map +1 -1
  198. package/dist/esm/adapter/converters/renderbuffer-formats.js +0 -4
  199. package/dist/esm/adapter/converters/renderbuffer-formats.js.map +1 -1
  200. package/dist/esm/adapter/converters/sampler-parameters.js +2 -57
  201. package/dist/esm/adapter/converters/sampler-parameters.js.map +1 -1
  202. package/dist/esm/adapter/converters/texture-formats.js +8 -52
  203. package/dist/esm/adapter/converters/texture-formats.js.map +1 -1
  204. package/dist/esm/adapter/converters/vertex-formats.js +0 -9
  205. package/dist/esm/adapter/converters/vertex-formats.js.map +1 -1
  206. package/dist/esm/adapter/device-helpers/device-features.js +2 -19
  207. package/dist/esm/adapter/device-helpers/device-features.js.map +1 -1
  208. package/dist/esm/adapter/device-helpers/device-limits.js +0 -3
  209. package/dist/esm/adapter/device-helpers/device-limits.js.map +1 -1
  210. package/dist/esm/adapter/device-helpers/get-device-info.js +0 -6
  211. package/dist/esm/adapter/device-helpers/get-device-info.js.map +1 -1
  212. package/dist/esm/adapter/device-helpers/is-old-ie.js +2 -1
  213. package/dist/esm/adapter/device-helpers/is-old-ie.js.map +1 -1
  214. package/dist/esm/adapter/helpers/attribute-utils.js +0 -17
  215. package/dist/esm/adapter/helpers/attribute-utils.js.map +1 -1
  216. package/dist/esm/adapter/helpers/get-shader-info.js +25 -0
  217. package/dist/esm/adapter/helpers/get-shader-info.js.map +1 -0
  218. package/dist/esm/adapter/helpers/get-shader-layout.js +2 -48
  219. package/dist/esm/adapter/helpers/get-shader-layout.js.map +1 -1
  220. package/dist/esm/adapter/helpers/parse-shader-compiler-log.js +0 -7
  221. package/dist/esm/adapter/helpers/parse-shader-compiler-log.js.map +1 -1
  222. package/dist/esm/adapter/helpers/set-uniform.js +0 -30
  223. package/dist/esm/adapter/helpers/set-uniform.js.map +1 -1
  224. package/dist/esm/adapter/helpers/uniforms.js +0 -10
  225. package/dist/esm/adapter/helpers/uniforms.js.map +1 -1
  226. package/dist/esm/adapter/objects/constants-to-keys.js +0 -7
  227. package/dist/esm/adapter/objects/constants-to-keys.js.map +1 -1
  228. package/dist/esm/adapter/objects/webgl-renderbuffer.js +2 -18
  229. package/dist/esm/adapter/objects/webgl-renderbuffer.js.map +1 -1
  230. package/dist/esm/adapter/objects/webgl-resource.js +10 -57
  231. package/dist/esm/adapter/objects/webgl-resource.js.map +1 -1
  232. package/dist/esm/adapter/objects/webgl-vertex-array-object.js +5 -15
  233. package/dist/esm/adapter/objects/webgl-vertex-array-object.js.map +1 -1
  234. package/dist/esm/adapter/resources/webgl-buffer.js +12 -40
  235. package/dist/esm/adapter/resources/webgl-buffer.js.map +1 -1
  236. package/dist/esm/adapter/resources/webgl-command-buffer.js +2 -17
  237. package/dist/esm/adapter/resources/webgl-command-buffer.js.map +1 -1
  238. package/dist/esm/adapter/resources/webgl-command-encoder.js +0 -12
  239. package/dist/esm/adapter/resources/webgl-command-encoder.js.map +1 -1
  240. package/dist/esm/adapter/resources/webgl-external-texture.js.map +1 -1
  241. package/dist/esm/adapter/resources/webgl-framebuffer.js +0 -60
  242. package/dist/esm/adapter/resources/webgl-framebuffer.js.map +1 -1
  243. package/dist/esm/adapter/resources/webgl-render-pass.js +1 -8
  244. package/dist/esm/adapter/resources/webgl-render-pass.js.map +1 -1
  245. package/dist/esm/adapter/resources/webgl-render-pipeline.js +0 -89
  246. package/dist/esm/adapter/resources/webgl-render-pipeline.js.map +1 -1
  247. package/dist/esm/adapter/resources/webgl-sampler.js +0 -12
  248. package/dist/esm/adapter/resources/webgl-sampler.js.map +1 -1
  249. package/dist/esm/adapter/resources/webgl-shader.js +2 -16
  250. package/dist/esm/adapter/resources/webgl-shader.js.map +1 -1
  251. package/dist/esm/adapter/resources/webgl-texture.js +36 -154
  252. package/dist/esm/adapter/resources/webgl-texture.js.map +1 -1
  253. package/dist/esm/adapter/webgl-canvas-context.js +0 -14
  254. package/dist/esm/adapter/webgl-canvas-context.js.map +1 -1
  255. package/dist/esm/adapter/webgl-device.js +19 -89
  256. package/dist/esm/adapter/webgl-device.js.map +1 -1
  257. package/dist/esm/bundle.js +0 -1
  258. package/dist/esm/bundle.js.map +1 -1
  259. package/dist/esm/classic/accessor.js +10 -34
  260. package/dist/esm/classic/accessor.js.map +1 -1
  261. package/dist/esm/classic/buffer.js +15 -71
  262. package/dist/esm/classic/buffer.js.map +1 -1
  263. package/dist/esm/classic/typed-array-utils.js +0 -20
  264. package/dist/esm/classic/typed-array-utils.js.map +1 -1
  265. package/dist/esm/context/context/create-browser-context.js +6 -14
  266. package/dist/esm/context/context/create-browser-context.js.map +1 -1
  267. package/dist/esm/context/context/create-headless-context.js +2 -6
  268. package/dist/esm/context/context/create-headless-context.js.map +1 -1
  269. package/dist/esm/context/context/webgl-checks.js +0 -3
  270. package/dist/esm/context/context/webgl-checks.js.map +1 -1
  271. package/dist/esm/context/debug/spector.js +2 -14
  272. package/dist/esm/context/debug/spector.js.map +1 -1
  273. package/dist/esm/context/debug/webgl-developer-tools.js +4 -22
  274. package/dist/esm/context/debug/webgl-developer-tools.js.map +1 -1
  275. package/dist/esm/context/parameters/unified-parameter-api.js +2 -13
  276. package/dist/esm/context/parameters/unified-parameter-api.js.map +1 -1
  277. package/dist/esm/context/parameters/webgl-parameter-tables.js +0 -19
  278. package/dist/esm/context/parameters/webgl-parameter-tables.js.map +1 -1
  279. package/dist/esm/context/polyfill/context-data.js +0 -2
  280. package/dist/esm/context/polyfill/context-data.js.map +1 -1
  281. package/dist/esm/context/polyfill/get-parameter-polyfill.js +0 -5
  282. package/dist/esm/context/polyfill/get-parameter-polyfill.js.map +1 -1
  283. package/dist/esm/context/polyfill/polyfill-context.js +14 -21
  284. package/dist/esm/context/polyfill/polyfill-context.js.map +1 -1
  285. package/dist/esm/context/polyfill/polyfill-table.js +0 -23
  286. package/dist/esm/context/polyfill/polyfill-table.js.map +1 -1
  287. package/dist/esm/context/polyfill/polyfill-vertex-array-object.js +0 -70
  288. package/dist/esm/context/polyfill/polyfill-vertex-array-object.js.map +1 -1
  289. package/dist/esm/context/state-tracker/deep-array-equal.js +0 -4
  290. package/dist/esm/context/state-tracker/deep-array-equal.js.map +1 -1
  291. package/dist/esm/context/state-tracker/track-context-state.js +11 -45
  292. package/dist/esm/context/state-tracker/track-context-state.js.map +1 -1
  293. package/dist/esm/context/state-tracker/with-parameters.js +0 -6
  294. package/dist/esm/context/state-tracker/with-parameters.js.map +1 -1
  295. package/dist/esm/index.js.map +1 -1
  296. package/dist/esm/init.js.map +1 -1
  297. package/dist/esm/types/webgl.js.map +1 -1
  298. package/dist/esm/types.js.map +1 -1
  299. package/dist/index.js +39 -25
  300. package/dist/init.js +1 -2
  301. package/dist/types/webgl.d.ts +20 -20
  302. package/dist/types/webgl.d.ts.map +1 -1
  303. package/dist/types/webgl.js +0 -1
  304. package/dist/types.d.ts +1 -1
  305. package/dist/types.d.ts.map +1 -1
  306. package/dist/types.js +0 -1
  307. package/package.json +8 -8
  308. package/src/adapter/helpers/get-shader-info.ts +37 -0
  309. package/src/adapter/helpers/parse-shader-compiler-log.ts +1 -1
  310. package/src/adapter/resources/webgl-render-pass.ts +1 -1
  311. package/src/adapter/resources/webgl-shader.ts +2 -2
  312. package/src/adapter/webgl-device.ts +1 -1
  313. package/src/context/debug/webgl-developer-tools.ts +0 -1
  314. package/src/types/webgl.ts +4 -4
  315. package/dist/adapter/converters/device-parameters.js.map +0 -1
  316. package/dist/adapter/converters/renderbuffer-formats.js.map +0 -1
  317. package/dist/adapter/converters/sampler-parameters.js.map +0 -1
  318. package/dist/adapter/converters/texture-formats.js.map +0 -1
  319. package/dist/adapter/converters/vertex-formats.js.map +0 -1
  320. package/dist/adapter/device-helpers/device-features.js.map +0 -1
  321. package/dist/adapter/device-helpers/device-limits.js.map +0 -1
  322. package/dist/adapter/device-helpers/get-device-info.js.map +0 -1
  323. package/dist/adapter/device-helpers/is-old-ie.js.map +0 -1
  324. package/dist/adapter/helpers/attribute-utils.js.map +0 -1
  325. package/dist/adapter/helpers/get-shader-layout.js.map +0 -1
  326. package/dist/adapter/helpers/parse-shader-compiler-log.js.map +0 -1
  327. package/dist/adapter/helpers/set-uniform.js.map +0 -1
  328. package/dist/adapter/helpers/uniforms.js.map +0 -1
  329. package/dist/adapter/objects/constants-to-keys.js.map +0 -1
  330. package/dist/adapter/objects/webgl-renderbuffer.js.map +0 -1
  331. package/dist/adapter/objects/webgl-resource.js.map +0 -1
  332. package/dist/adapter/objects/webgl-vertex-array-object.js.map +0 -1
  333. package/dist/adapter/resources/webgl-buffer.js.map +0 -1
  334. package/dist/adapter/resources/webgl-command-buffer.js.map +0 -1
  335. package/dist/adapter/resources/webgl-command-encoder.js.map +0 -1
  336. package/dist/adapter/resources/webgl-external-texture.js.map +0 -1
  337. package/dist/adapter/resources/webgl-framebuffer.js.map +0 -1
  338. package/dist/adapter/resources/webgl-render-pass.js.map +0 -1
  339. package/dist/adapter/resources/webgl-render-pipeline.js.map +0 -1
  340. package/dist/adapter/resources/webgl-sampler.js.map +0 -1
  341. package/dist/adapter/resources/webgl-shader.js.map +0 -1
  342. package/dist/adapter/resources/webgl-texture.js.map +0 -1
  343. package/dist/adapter/webgl-canvas-context.js.map +0 -1
  344. package/dist/adapter/webgl-device.js.map +0 -1
  345. package/dist/bundle.js.map +0 -1
  346. package/dist/classic/accessor.js.map +0 -1
  347. package/dist/classic/buffer.js.map +0 -1
  348. package/dist/classic/typed-array-utils.js.map +0 -1
  349. package/dist/context/context/create-browser-context.js.map +0 -1
  350. package/dist/context/context/create-headless-context.js.map +0 -1
  351. package/dist/context/context/webgl-checks.js.map +0 -1
  352. package/dist/context/debug/spector.js.map +0 -1
  353. package/dist/context/debug/webgl-developer-tools.js.map +0 -1
  354. package/dist/context/parameters/unified-parameter-api.js.map +0 -1
  355. package/dist/context/parameters/webgl-parameter-tables.js.map +0 -1
  356. package/dist/context/polyfill/context-data.js.map +0 -1
  357. package/dist/context/polyfill/get-parameter-polyfill.js.map +0 -1
  358. package/dist/context/polyfill/polyfill-context.js.map +0 -1
  359. package/dist/context/polyfill/polyfill-table.js.map +0 -1
  360. package/dist/context/polyfill/polyfill-vertex-array-object.js.map +0 -1
  361. package/dist/context/state-tracker/deep-array-equal.js.map +0 -1
  362. package/dist/context/state-tracker/track-context-state.js.map +0 -1
  363. package/dist/context/state-tracker/with-parameters.js.map +0 -1
  364. package/dist/index.js.map +0 -1
  365. package/dist/init.js.map +0 -1
  366. package/dist/types/webgl.js.map +0 -1
  367. package/dist/types.js.map +0 -1
@@ -1,76 +1,67 @@
1
+ // luma.gl, MIT license
1
2
  import { log, loadScript } from '@luma.gl/api';
2
3
  const DEFAULT_SPECTOR_PROPS = {
3
- spector: log.get('spector') || log.get('inspect')
4
+ spector: log.get('spector') || log.get('inspect')
4
5
  };
6
+ // https://github.com/BabylonJS/Spector.js#basic-usage
5
7
  const SPECTOR_CDN_URL = 'https://spectorcdn.babylonjs.com/spector.bundle.js';
6
8
  const LOG_LEVEL = 1;
7
9
  let spector = null;
8
10
  let initialized = false;
11
+ /** Loads spector from CDN if not already installed */
9
12
  export async function loadSpectorJS(props) {
10
- if (!globalThis.SPECTOR) {
11
- try {
12
- await loadScript(SPECTOR_CDN_URL);
13
- } catch (error) {
14
- log.warn(String(error));
13
+ if (!globalThis.SPECTOR) {
14
+ try {
15
+ await loadScript(SPECTOR_CDN_URL);
16
+ }
17
+ catch (error) {
18
+ log.warn(String(error));
19
+ }
15
20
  }
16
- }
17
21
  }
18
22
  export function initializeSpectorJS(props) {
19
- var _props, _props2;
20
-
21
- props = { ...DEFAULT_SPECTOR_PROPS,
22
- ...props
23
- };
24
-
25
- if (!((_props = props) !== null && _props !== void 0 && _props.spector)) {
26
- return null;
27
- }
28
-
29
- if (!spector && globalThis.SPECTOR) {
30
- log.probe(LOG_LEVEL, "SPECTOR found and initialized")();
31
- spector = new globalThis.SPECTOR.Spector();
32
-
33
- if (globalThis.luma) {
34
- globalThis.luma.spector = spector;
23
+ props = { ...DEFAULT_SPECTOR_PROPS, ...props };
24
+ if (!props?.spector) {
25
+ return null;
35
26
  }
36
- }
37
-
38
- if (!spector) {
39
- return null;
40
- }
41
-
42
- if (!initialized) {
43
- var _spector, _spector2;
44
-
45
- initialized = true;
46
- spector.spyCanvases();
47
- (_spector = spector) === null || _spector === void 0 ? void 0 : _spector.onCaptureStarted.add(capture => log.info("Spector capture started:", capture)());
48
- (_spector2 = spector) === null || _spector2 === void 0 ? void 0 : _spector2.onCapture.add(capture => {
49
- var _spector3, _spector4, _spector5;
50
-
51
- log.info("Spector capture complete:", capture)();
52
- (_spector3 = spector) === null || _spector3 === void 0 ? void 0 : _spector3.getResultUI();
53
- (_spector4 = spector) === null || _spector4 === void 0 ? void 0 : _spector4.resultView.display();
54
- (_spector5 = spector) === null || _spector5 === void 0 ? void 0 : _spector5.resultView.addCapture(capture);
55
- });
56
- }
57
-
58
- if ((_props2 = props) !== null && _props2 !== void 0 && _props2.canvas) {
59
- var _spector6, _props3;
60
-
61
- if (typeof props.spector === 'string' && props.spector !== props.canvas.id) {
62
- return spector;
27
+ if (!spector && globalThis.SPECTOR) {
28
+ log.probe(LOG_LEVEL, "SPECTOR found and initialized")();
29
+ spector = new globalThis.SPECTOR.Spector();
30
+ if (globalThis.luma) {
31
+ globalThis.luma.spector = spector;
32
+ }
63
33
  }
64
-
65
- (_spector6 = spector) === null || _spector6 === void 0 ? void 0 : _spector6.startCapture((_props3 = props) === null || _props3 === void 0 ? void 0 : _props3.canvas, 500);
66
- new Promise(resolve => setTimeout(resolve, 2000)).then(_ => {
67
- var _spector7;
68
-
69
- log.info("Spector capture stopped after 2 seconds")();
70
- (_spector7 = spector) === null || _spector7 === void 0 ? void 0 : _spector7.stopCapture();
71
- });
72
- }
73
-
74
- return spector;
34
+ if (!spector) {
35
+ return null;
36
+ }
37
+ if (!initialized) {
38
+ initialized = true;
39
+ // enables recording some extra information merged in the capture like texture memory sizes and formats
40
+ spector.spyCanvases();
41
+ // A callback when results are ready
42
+ spector?.onCaptureStarted.add((capture) => log.info(`Spector capture started:`, capture)());
43
+ spector?.onCapture.add((capture) => {
44
+ log.info(`Spector capture complete:`, capture)();
45
+ // Use undocumented Spector API to open the UI with our capture
46
+ // See https://github.com/BabylonJS/Spector.js/blob/767ad1195a25b85a85c381f400eb50a979239eca/src/spector.ts#L124
47
+ spector?.getResultUI();
48
+ spector?.resultView.display();
49
+ spector?.resultView.addCapture(capture);
50
+ });
51
+ }
52
+ if (props?.canvas) {
53
+ // @ts-expect-error If spector is specified as a canvas id, only monitor that canvas
54
+ if (typeof props.spector === 'string' && props.spector !== props.canvas.id) {
55
+ return spector;
56
+ }
57
+ // capture startup
58
+ // spector?.captureCanvas(props?.canvas);
59
+ spector?.startCapture(props?.canvas, 500); // 500 commands
60
+ new Promise(resolve => setTimeout(resolve, 2000)).then(_ => {
61
+ log.info(`Spector capture stopped after 2 seconds`)();
62
+ spector?.stopCapture();
63
+ // spector?.displayUI();
64
+ });
65
+ }
66
+ return spector;
75
67
  }
76
- //# sourceMappingURL=spector.js.map
@@ -1,4 +1,4 @@
1
- declare type DebugContextProps = {
1
+ type DebugContextProps = {
2
2
  debug?: boolean;
3
3
  throwOnError?: boolean;
4
4
  break?: string[];
@@ -1 +1 @@
1
- {"version":3,"file":"webgl-developer-tools.d.ts","sourceRoot":"","sources":["../../../src/context/debug/webgl-developer-tools.ts"],"names":[],"mappings":"AAMA,aAAK,iBAAiB,GAAG;IACvB,KAAK,CAAC,EAAE,OAAO,CAAC;IAChB,YAAY,CAAC,EAAE,OAAO,CAAC;IACvB,KAAK,CAAC,EAAE,MAAM,EAAE,CAAC;IACjB,MAAM,CAAC,EAAE,OAAO,CAAC;CAClB,CAAC;AAeF,OAAO,CAAC,MAAM,CAAC;IACb,IAAI,eAAe,EAAE,GAAG,CAAC;CAC1B;AAED;;;;;GAKG;AACH,wBAAsB,uBAAuB,IAAI,OAAO,CAAC,IAAI,CAAC,CAQ7D;AAID,wBAAgB,gBAAgB,CAAC,EAAE,EAAE,qBAAqB,EAAE,KAAK,GAAE,iBAAsB,GAAG,qBAAqB,GAAG,IAAI,CAOvH"}
1
+ {"version":3,"file":"webgl-developer-tools.d.ts","sourceRoot":"","sources":["../../../src/context/debug/webgl-developer-tools.ts"],"names":[],"mappings":"AAMA,KAAK,iBAAiB,GAAG;IACvB,KAAK,CAAC,EAAE,OAAO,CAAC;IAChB,YAAY,CAAC,EAAE,OAAO,CAAC;IACvB,KAAK,CAAC,EAAE,MAAM,EAAE,CAAC;IACjB,MAAM,CAAC,EAAE,OAAO,CAAC;CAClB,CAAC;AAeF,OAAO,CAAC,MAAM,CAAC;IACb,IAAI,eAAe,EAAE,GAAG,CAAC;CAC1B;AAED;;;;;GAKG;AACH,wBAAsB,uBAAuB,IAAI,OAAO,CAAC,IAAI,CAAC,CAO7D;AAID,wBAAgB,gBAAgB,CAAC,EAAE,EAAE,qBAAqB,EAAE,KAAK,GAAE,iBAAsB,GAAG,qBAAqB,GAAG,IAAI,CAOvH"}
@@ -1,115 +1,128 @@
1
+ // luma.gl, MIT license
1
2
  import { log, loadScript } from '@luma.gl/api';
2
3
  import GL from '@luma.gl/constants';
3
4
  const WEBGL_DEBUG_CDN_URL = 'https://unpkg.com/webgl-debug@2.0.1/index.js';
4
-
5
+ // const DEFAULT_DEBUG_CONTEXT_PROPS: Required<DebugContextProps> = {
6
+ // debug: true,
7
+ // throwOnError: false,
8
+ // break: [],
9
+ // webgl2: false,
10
+ // }
11
+ // Helper to get shared context data
5
12
  function getContextData(gl) {
6
- gl.luma = gl.luma || {};
7
- return gl.luma;
13
+ gl.luma = gl.luma || {};
14
+ return gl.luma;
8
15
  }
9
-
16
+ /**
17
+ * Loads Khronos WebGLDeveloperTools from CDN if not already installed
18
+ * const WebGLDebugUtils = require('webgl-debug');
19
+ * @see https://github.com/KhronosGroup/WebGLDeveloperTools
20
+ * @see https://github.com/vorg/webgl-debug
21
+ */
10
22
  export async function loadWebGLDeveloperTools() {
11
- if (!globalThis.WebGLDebugUtils) {
12
- globalThis.global = globalThis.global || globalThis;
13
- globalThis.global.module = {};
14
- await loadScript(WEBGL_DEBUG_CDN_URL);
15
- }
23
+ if (!globalThis.WebGLDebugUtils) {
24
+ globalThis.global = globalThis.global || globalThis;
25
+ // @ts-expect-error Developer tools expects global to be set
26
+ globalThis.global.module = {};
27
+ await loadScript(WEBGL_DEBUG_CDN_URL);
28
+ }
16
29
  }
30
+ // Returns (a potentially new) context with debug instrumentation turned off or on.
31
+ // Note that this actually returns a new context
17
32
  export function makeDebugContext(gl, props = {}) {
18
- if (!gl) {
19
- return null;
20
- }
21
-
22
- return props.debug ? getDebugContext(gl, props) : getRealContext(gl);
33
+ // Return null to ensure we don't try to create a context in this case (TODO what case is that?)
34
+ if (!gl) {
35
+ return null;
36
+ }
37
+ return props.debug ? getDebugContext(gl, props) : getRealContext(gl);
23
38
  }
24
-
39
+ // Returns the real context from either of the real/debug contexts
25
40
  function getRealContext(gl) {
26
- const data = getContextData(gl);
27
- return data.realContext ? data.realContext : gl;
41
+ const data = getContextData(gl);
42
+ // If the context has a realContext member, it is a debug context so return the realContext
43
+ return data.realContext ? data.realContext : gl;
28
44
  }
29
-
45
+ // Returns the debug context from either of the real/debug contexts
30
46
  function getDebugContext(gl, props) {
31
- if (!globalThis.WebGLDebugUtils) {
32
- log.warn('webgl-debug not loaded')();
33
- return gl;
34
- }
35
-
36
- const data = getContextData(gl);
37
-
38
- if (data.debugContext) {
39
- return data.debugContext;
40
- }
41
-
42
- globalThis.WebGLDebugUtils.init({ ...GL,
43
- ...gl
44
- });
45
- const glDebug = globalThis.WebGLDebugUtils.makeDebugContext(gl, onGLError.bind(null, props), onValidateGLFunc.bind(null, props));
46
-
47
- for (const key in GL) {
48
- if (!(key in glDebug) && typeof GL[key] === 'number') {
49
- glDebug[key] = GL[key];
47
+ if (!globalThis.WebGLDebugUtils) {
48
+ log.warn('webgl-debug not loaded')();
49
+ return gl;
50
+ }
51
+ const data = getContextData(gl);
52
+ // If this already has a debug context, return it.
53
+ if (data.debugContext) {
54
+ return data.debugContext;
55
+ }
56
+ // Create a new debug context
57
+ globalThis.WebGLDebugUtils.init({ ...GL, ...gl });
58
+ const glDebug = globalThis.WebGLDebugUtils.makeDebugContext(gl, onGLError.bind(null, props), onValidateGLFunc.bind(null, props));
59
+ // Make sure we have all WebGL2 and extension constants (todo dynamic import to circumvent minification?)
60
+ for (const key in GL) {
61
+ if (!(key in glDebug) && typeof GL[key] === 'number') {
62
+ glDebug[key] = GL[key];
63
+ }
50
64
  }
51
- }
52
-
53
- class WebGLDebugContext {}
54
-
55
- Object.setPrototypeOf(glDebug, Object.getPrototypeOf(gl));
56
- Object.setPrototypeOf(WebGLDebugContext, glDebug);
57
- const debugContext = Object.create(WebGLDebugContext);
58
- data.realContext = gl;
59
- data.debugContext = debugContext;
60
- debugContext.debug = true;
61
- return debugContext;
65
+ // Ensure we have a clean prototype on the instrumented object
66
+ // Note: setPrototypeOf does come with perf warnings, but we already take a bigger perf reduction
67
+ // by synchronizing the WebGL errors after each WebGL call.
68
+ class WebGLDebugContext {
69
+ }
70
+ Object.setPrototypeOf(glDebug, Object.getPrototypeOf(gl));
71
+ Object.setPrototypeOf(WebGLDebugContext, glDebug);
72
+ const debugContext = Object.create(WebGLDebugContext);
73
+ // Store the debug context
74
+ data.realContext = gl;
75
+ data.debugContext = debugContext;
76
+ debugContext.debug = true;
77
+ // Return it
78
+ return debugContext;
62
79
  }
63
-
80
+ // DEBUG TRACING
64
81
  function getFunctionString(functionName, functionArgs) {
65
- functionArgs = Array.from(functionArgs).map(arg => arg === undefined ? 'undefined' : arg);
66
- let args = globalThis.WebGLDebugUtils.glFunctionArgsToString(functionName, functionArgs);
67
- args = "".concat(args.slice(0, 100)).concat(args.length > 100 ? '...' : '');
68
- return "gl.".concat(functionName, "(").concat(args, ")");
82
+ // Cover bug in webgl-debug-tools
83
+ functionArgs = Array.from(functionArgs).map(arg => arg === undefined ? 'undefined' : arg);
84
+ let args = globalThis.WebGLDebugUtils.glFunctionArgsToString(functionName, functionArgs);
85
+ args = `${args.slice(0, 100)}${args.length > 100 ? '...' : ''}`;
86
+ return `gl.${functionName}(${args})`;
69
87
  }
70
-
71
88
  function onGLError(props, err, functionName, args) {
72
- args = Array.from(args).map(arg => arg === undefined ? 'undefined' : arg);
73
- const errorMessage = globalThis.WebGLDebugUtils.glEnumToString(err);
74
- const functionArgs = globalThis.WebGLDebugUtils.glFunctionArgsToString(functionName, args);
75
- const glName = props.webgl2 ? 'gl2' : 'gl1';
76
- const message = "".concat(errorMessage, " in ").concat(glName, ".").concat(functionName, "(").concat(functionArgs, ")");
77
- log.error(message)();
78
- debugger;
79
-
80
- if (props.throwOnError) {
81
- throw new Error(message);
82
- }
89
+ // Cover bug in webgl-debug-tools
90
+ args = Array.from(args).map(arg => arg === undefined ? 'undefined' : arg);
91
+ const errorMessage = globalThis.WebGLDebugUtils.glEnumToString(err);
92
+ const functionArgs = globalThis.WebGLDebugUtils.glFunctionArgsToString(functionName, args);
93
+ const glName = props.webgl2 ? 'gl2' : 'gl1';
94
+ const message = `${errorMessage} in ${glName}.${functionName}(${functionArgs})`;
95
+ log.error(message)();
96
+ debugger; // eslint-disable-line
97
+ if (props.throwOnError) {
98
+ throw new Error(message);
99
+ }
83
100
  }
84
-
101
+ // Don't generate function string until it is needed
85
102
  function onValidateGLFunc(props, functionName, functionArgs) {
86
- let functionString = '';
87
-
88
- if (log.level >= 1) {
89
- functionString = getFunctionString(functionName, functionArgs);
90
- log.log(1, functionString)();
91
- }
92
-
93
- if (props.break && props.break.length > 0) {
94
- functionString = functionString || getFunctionString(functionName, functionArgs);
95
- const isBreakpoint = props.break.every(breakOn => functionString.indexOf(breakOn) !== -1);
96
-
97
- if (isBreakpoint) {
98
- debugger;
103
+ let functionString = '';
104
+ if (log.level >= 1) {
105
+ functionString = getFunctionString(functionName, functionArgs);
106
+ log.log(1, functionString)();
107
+ }
108
+ // If array of breakpoint strings supplied, check if any of them is contained in current GL function
109
+ if (props.break && props.break.length > 0) {
110
+ functionString = functionString || getFunctionString(functionName, functionArgs);
111
+ const isBreakpoint = props.break.every((breakOn) => functionString.indexOf(breakOn) !== -1);
112
+ if (isBreakpoint) {
113
+ debugger; // eslint-disable-line
114
+ }
99
115
  }
100
- }
101
-
102
- for (const arg of functionArgs) {
103
- if (arg === undefined) {
104
- functionString = functionString || getFunctionString(functionName, functionArgs);
105
-
106
- if (props.throwOnError) {
107
- throw new Error("Undefined argument: ".concat(functionString));
108
- } else {
109
- log.error("Undefined argument: ".concat(functionString))();
110
- debugger;
111
- }
116
+ for (const arg of functionArgs) {
117
+ if (arg === undefined) {
118
+ functionString = functionString || getFunctionString(functionName, functionArgs);
119
+ if (props.throwOnError) {
120
+ throw new Error(`Undefined argument: ${functionString}`);
121
+ }
122
+ else {
123
+ log.error(`Undefined argument: ${functionString}`)();
124
+ debugger; // eslint-disable-line
125
+ }
126
+ }
112
127
  }
113
- }
114
128
  }
115
- //# sourceMappingURL=webgl-developer-tools.js.map
@@ -1,66 +1,102 @@
1
- import { GL_PARAMETER_DEFAULTS, GL_PARAMETER_SETTERS, GL_COMPOSITE_PARAMETER_SETTERS, GL_PARAMETER_GETTERS } from './webgl-parameter-tables';
2
- import WebGLDevice from '../../adapter/webgl-device';
1
+ import { GL_PARAMETER_DEFAULTS, GL_PARAMETER_SETTERS, GL_COMPOSITE_PARAMETER_SETTERS, GL_PARAMETER_GETTERS } from './webgl-parameter-tables.js';
2
+ import WebGLDevice from '../../adapter/webgl-device.js';
3
+ /**
4
+ * Sets any GL parameter regardless of function (gl.blendMode, ...)
5
+ *
6
+ * @note requires a `cache` object to be set on the context (gl.state.cache)
7
+ * This object is used to fill in any missing values for composite setter functions
8
+ */
3
9
  export function setParameters(device, parameters) {
4
- const webglDevice = WebGLDevice.attach(device);
5
- const gl = webglDevice.gl;
6
-
7
- if (isObjectEmpty(parameters)) {
8
- return;
9
- }
10
-
11
- const compositeSetters = {};
12
-
13
- for (const key in parameters) {
14
- const glConstant = Number(key);
15
- const setter = GL_PARAMETER_SETTERS[key];
16
-
17
- if (setter) {
18
- if (typeof setter === 'string') {
19
- compositeSetters[setter] = true;
20
- } else {
21
- setter(gl, parameters[key], glConstant);
22
- }
10
+ const webglDevice = WebGLDevice.attach(device);
11
+ const gl = webglDevice.gl;
12
+ if (isObjectEmpty(parameters)) {
13
+ return;
23
14
  }
24
- }
25
-
26
- const cache = gl.state && gl.state.cache;
27
-
28
- if (cache) {
29
- for (const key in compositeSetters) {
30
- const compositeSetter = GL_COMPOSITE_PARAMETER_SETTERS[key];
31
- compositeSetter(gl, parameters, cache);
15
+ const compositeSetters = {};
16
+ // HANDLE PRIMITIVE SETTERS (and make note of any composite setters)
17
+ for (const key in parameters) {
18
+ const glConstant = Number(key);
19
+ const setter = GL_PARAMETER_SETTERS[key];
20
+ if (setter) {
21
+ // Composite setters should only be called once, so save them
22
+ if (typeof setter === 'string') {
23
+ compositeSetters[setter] = true;
24
+ }
25
+ else {
26
+ // if (gl[glConstant] !== undefined) {
27
+ // TODO - added above check since this is being called on WebGL2 parameters in WebGL1...
28
+ // TODO - deep equal on values? only call setter if value has changed?
29
+ // NOTE - the setter will automatically update this.state
30
+ setter(gl, parameters[key], glConstant);
31
+ }
32
+ }
32
33
  }
33
- }
34
+ // HANDLE COMPOSITE SETTERS
35
+ // NOTE: any non-provided values needed by composite setters are filled in from state cache
36
+ // The cache parameter is automatically retrieved from the context
37
+ // This depends on `trackContextState`, which is technically a "circular" dependency.
38
+ // But it is too inconvenient to always require a cache parameter here.
39
+ // This is the ONLY external dependency in this module/
40
+ // @ts-expect-error
41
+ const cache = gl.state && gl.state.cache;
42
+ if (cache) {
43
+ for (const key in compositeSetters) {
44
+ // TODO - avoid calling composite setters if values have not changed.
45
+ const compositeSetter = GL_COMPOSITE_PARAMETER_SETTERS[key];
46
+ // Note - if `trackContextState` has been called,
47
+ // the setter will automatically update this.state.cache
48
+ compositeSetter(gl, parameters, cache);
49
+ }
50
+ }
51
+ // Add a log for the else case?
34
52
  }
35
- export function getParameters(device, parameters = GL_PARAMETER_DEFAULTS) {
36
- const webglDevice = WebGLDevice.attach(device);
37
- const gl = webglDevice.gl;
53
+ /**
54
+ * Reads the entire WebGL state from a context
38
55
 
39
- if (typeof parameters === 'number') {
40
- const key = parameters;
41
- const getter = GL_PARAMETER_GETTERS[key];
42
- return getter ? getter(gl, key) : gl.getParameter(key);
43
- }
56
+ // default to querying all parameters
44
57
 
45
- const parameterKeys = Array.isArray(parameters) ? parameters : Object.keys(parameters);
46
- const state = {};
47
-
48
- for (const key of parameterKeys) {
49
- const getter = GL_PARAMETER_GETTERS[key];
50
- state[key] = getter ? getter(gl, Number(key)) : gl.getParameter(Number(key));
51
- }
52
-
53
- return state;
58
+ * @returns - a newly created map, with values keyed by GL parameters
59
+ *
60
+ * @note Copies the state from a context (gl.getParameter should not be overriden)
61
+ * Reads the entire WebGL state from a context
62
+ *
63
+ * @note This can generates a huge amount of synchronous driver roundtrips and should be
64
+ * considered a very slow operation, to be used only if/when a context already manipulated
65
+ * by external code needs to be synchronized for the first time
66
+ */
67
+ export function getParameters(device, parameters = GL_PARAMETER_DEFAULTS) {
68
+ const webglDevice = WebGLDevice.attach(device);
69
+ const gl = webglDevice.gl;
70
+ // support both arrays of parameters and objects (keys represent parameters)
71
+ if (typeof parameters === 'number') {
72
+ // single GL enum
73
+ const key = parameters;
74
+ const getter = GL_PARAMETER_GETTERS[key];
75
+ return getter ? getter(gl, key) : gl.getParameter(key);
76
+ }
77
+ const parameterKeys = Array.isArray(parameters) ? parameters : Object.keys(parameters);
78
+ const state = {};
79
+ for (const key of parameterKeys) {
80
+ const getter = GL_PARAMETER_GETTERS[key];
81
+ state[key] = getter ? getter(gl, Number(key)) : gl.getParameter(Number(key));
82
+ }
83
+ return state;
54
84
  }
85
+ /**
86
+ * Reset all parameters to a (almost) pure context state
87
+ * @note viewport and scissor will be set to the values in GL_PARAMETER_DEFAULTS,
88
+ * NOT the canvas size dimensions, so they will have to be properly set after
89
+ * calling this function.
90
+ */
55
91
  export function resetParameters(device) {
56
- setParameters(device, GL_PARAMETER_DEFAULTS);
92
+ setParameters(device, GL_PARAMETER_DEFAULTS);
57
93
  }
58
-
94
+ // Helpers
95
+ // Returns true if given object is empty, false otherwise.
59
96
  function isObjectEmpty(object) {
60
- for (const key in object) {
61
- return false;
62
- }
63
-
64
- return true;
97
+ // @ts-ignore dummy key variable
98
+ for (const key in object) {
99
+ return false;
100
+ }
101
+ return true;
65
102
  }
66
- //# sourceMappingURL=unified-parameter-api.js.map
@@ -116,7 +116,7 @@ export declare const GL_COMPOSITE_PARAMETER_SETTERS: {
116
116
  stencilOpFront: (gl: WebGLRenderingContext, values: any, cache: any) => void;
117
117
  stencilOpBack: (gl: WebGLRenderingContext, values: any, cache: any) => void;
118
118
  };
119
- declare type UpdateFunc = (params: Record<string, any>) => void;
119
+ type UpdateFunc = (params: Record<string, any>) => void;
120
120
  export declare const GL_HOOKED_SETTERS: {
121
121
  enable: (update: UpdateFunc, capability: GL) => void;
122
122
  disable: (update: UpdateFunc, capability: GL) => void;
@@ -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;AA0CF,eAAO,MAAM,oBAAoB;eAtCb,qBAAqB,SAAS,OAAO,OAAO,EAAE;gBAwCzC,qBAAqB,SAAS,CAAC,MAAM,EAAE,MAAM,EAAE,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