@luma.gl/webgl 9.0.0-alpha.9 → 9.0.0-beta.1

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 (525) hide show
  1. package/LICENSE +3 -1
  2. package/dist/adapter/converters/device-parameters.d.ts +12 -3
  3. package/dist/adapter/converters/device-parameters.d.ts.map +1 -1
  4. package/dist/adapter/converters/device-parameters.js +89 -74
  5. package/dist/adapter/converters/device-parameters.js.map +1 -1
  6. package/dist/adapter/converters/sampler-parameters.d.ts +4 -10
  7. package/dist/adapter/converters/sampler-parameters.d.ts.map +1 -1
  8. package/dist/adapter/converters/sampler-parameters.js +29 -180
  9. package/dist/adapter/converters/sampler-parameters.js.map +1 -1
  10. package/dist/adapter/converters/shader-formats.d.ts +9 -0
  11. package/dist/adapter/converters/shader-formats.d.ts.map +1 -0
  12. package/dist/adapter/converters/shader-formats.js +52 -0
  13. package/dist/adapter/converters/shader-formats.js.map +1 -0
  14. package/dist/adapter/converters/texture-formats.d.ts +32 -44
  15. package/dist/adapter/converters/texture-formats.d.ts.map +1 -1
  16. package/dist/adapter/converters/texture-formats.js +306 -343
  17. package/dist/adapter/converters/texture-formats.js.map +1 -1
  18. package/dist/adapter/converters/vertex-formats.d.ts +9 -3
  19. package/dist/adapter/converters/vertex-formats.d.ts.map +1 -1
  20. package/dist/adapter/converters/vertex-formats.js +53 -22
  21. package/dist/adapter/converters/vertex-formats.js.map +1 -1
  22. package/dist/adapter/device-helpers/device-features.d.ts +1 -1
  23. package/dist/adapter/device-helpers/device-features.d.ts.map +1 -1
  24. package/dist/adapter/device-helpers/device-features.js +9 -25
  25. package/dist/adapter/device-helpers/device-features.js.map +1 -1
  26. package/dist/adapter/device-helpers/device-limits.d.ts +3 -3
  27. package/dist/adapter/device-helpers/device-limits.d.ts.map +1 -1
  28. package/dist/adapter/device-helpers/device-limits.js +54 -58
  29. package/dist/adapter/device-helpers/device-limits.js.map +1 -1
  30. package/dist/adapter/device-helpers/get-device-info.d.ts +1 -1
  31. package/dist/adapter/device-helpers/get-device-info.d.ts.map +1 -1
  32. package/dist/adapter/device-helpers/get-device-info.js +49 -22
  33. package/dist/adapter/device-helpers/get-device-info.js.map +1 -1
  34. package/dist/adapter/device-helpers/is-old-ie.d.ts.map +1 -1
  35. package/dist/adapter/device-helpers/is-old-ie.js +2 -1
  36. package/dist/adapter/device-helpers/is-old-ie.js.map +1 -1
  37. package/dist/adapter/helpers/decode-webgl-types.d.ts +26 -0
  38. package/dist/adapter/helpers/decode-webgl-types.d.ts.map +1 -0
  39. package/dist/adapter/helpers/decode-webgl-types.js +89 -0
  40. package/dist/adapter/helpers/decode-webgl-types.js.map +1 -0
  41. package/dist/adapter/helpers/get-shader-layout.d.ts +1 -48
  42. package/dist/adapter/helpers/get-shader-layout.d.ts.map +1 -1
  43. package/dist/adapter/helpers/get-shader-layout.js +58 -138
  44. package/dist/adapter/helpers/get-shader-layout.js.map +1 -1
  45. package/dist/adapter/helpers/parse-shader-compiler-log.d.ts +1 -1
  46. package/dist/adapter/helpers/parse-shader-compiler-log.d.ts.map +1 -1
  47. package/dist/adapter/helpers/parse-shader-compiler-log.js +16 -11
  48. package/dist/adapter/helpers/parse-shader-compiler-log.js.map +1 -1
  49. package/dist/adapter/helpers/set-uniform.d.ts +3 -2
  50. package/dist/adapter/helpers/set-uniform.d.ts.map +1 -1
  51. package/dist/adapter/helpers/set-uniform.js +51 -82
  52. package/dist/adapter/helpers/set-uniform.js.map +1 -1
  53. package/dist/adapter/helpers/webgl-topology-utils.d.ts +16 -0
  54. package/dist/adapter/helpers/webgl-topology-utils.d.ts.map +1 -0
  55. package/dist/adapter/helpers/webgl-topology-utils.js +103 -0
  56. package/dist/adapter/helpers/webgl-topology-utils.js.map +1 -0
  57. package/dist/adapter/objects/constants-to-keys.d.ts +1 -3
  58. package/dist/adapter/objects/constants-to-keys.d.ts.map +1 -1
  59. package/dist/adapter/objects/constants-to-keys.js +2 -29
  60. package/dist/adapter/objects/constants-to-keys.js.map +1 -1
  61. package/dist/adapter/objects/webgl-renderbuffer.d.ts +15 -12
  62. package/dist/adapter/objects/webgl-renderbuffer.d.ts.map +1 -1
  63. package/dist/adapter/objects/webgl-renderbuffer.js +36 -44
  64. package/dist/adapter/objects/webgl-renderbuffer.js.map +1 -1
  65. package/dist/adapter/objects/webgl-resource.d.ts +6 -9
  66. package/dist/adapter/objects/webgl-resource.d.ts.map +1 -1
  67. package/dist/adapter/objects/webgl-resource.js +26 -83
  68. package/dist/adapter/objects/webgl-resource.js.map +1 -1
  69. package/dist/adapter/resources/webgl-buffer.d.ts +19 -14
  70. package/dist/adapter/resources/webgl-buffer.d.ts.map +1 -1
  71. package/dist/adapter/resources/webgl-buffer.js +67 -101
  72. package/dist/adapter/resources/webgl-buffer.js.map +1 -1
  73. package/dist/adapter/resources/webgl-command-buffer.d.ts +15 -9
  74. package/dist/adapter/resources/webgl-command-buffer.d.ts.map +1 -1
  75. package/dist/adapter/resources/webgl-command-buffer.js +175 -48
  76. package/dist/adapter/resources/webgl-command-buffer.js.map +1 -1
  77. package/dist/adapter/resources/webgl-command-encoder.d.ts +7 -6
  78. package/dist/adapter/resources/webgl-command-encoder.d.ts.map +1 -1
  79. package/dist/adapter/resources/webgl-command-encoder.js +10 -20
  80. package/dist/adapter/resources/webgl-command-encoder.js.map +1 -1
  81. package/dist/adapter/resources/webgl-external-texture.js.map +1 -1
  82. package/dist/adapter/resources/webgl-framebuffer.d.ts +21 -25
  83. package/dist/adapter/resources/webgl-framebuffer.d.ts.map +1 -1
  84. package/dist/adapter/resources/webgl-framebuffer.js +63 -175
  85. package/dist/adapter/resources/webgl-framebuffer.js.map +1 -1
  86. package/dist/adapter/resources/webgl-render-pass.d.ts +19 -4
  87. package/dist/adapter/resources/webgl-render-pass.d.ts.map +1 -1
  88. package/dist/adapter/resources/webgl-render-pass.js +98 -12
  89. package/dist/adapter/resources/webgl-render-pass.js.map +1 -1
  90. package/dist/adapter/resources/webgl-render-pipeline.d.ts +34 -20
  91. package/dist/adapter/resources/webgl-render-pipeline.d.ts.map +1 -1
  92. package/dist/adapter/resources/webgl-render-pipeline.js +110 -293
  93. package/dist/adapter/resources/webgl-render-pipeline.js.map +1 -1
  94. package/dist/adapter/resources/webgl-sampler.d.ts +5 -4
  95. package/dist/adapter/resources/webgl-sampler.d.ts.map +1 -1
  96. package/dist/adapter/resources/webgl-sampler.js +11 -21
  97. package/dist/adapter/resources/webgl-sampler.js.map +1 -1
  98. package/dist/adapter/resources/webgl-shader.d.ts +5 -5
  99. package/dist/adapter/resources/webgl-shader.d.ts.map +1 -1
  100. package/dist/adapter/resources/webgl-shader.js +18 -44
  101. package/dist/adapter/resources/webgl-shader.js.map +1 -1
  102. package/dist/adapter/resources/webgl-texture.d.ts +51 -31
  103. package/dist/adapter/resources/webgl-texture.d.ts.map +1 -1
  104. package/dist/adapter/resources/webgl-texture.js +123 -244
  105. package/dist/adapter/resources/webgl-texture.js.map +1 -1
  106. package/dist/adapter/resources/webgl-transform-feedback.d.ts +47 -0
  107. package/dist/adapter/resources/webgl-transform-feedback.d.ts.map +1 -0
  108. package/dist/adapter/resources/webgl-transform-feedback.js +164 -0
  109. package/dist/adapter/resources/webgl-transform-feedback.js.map +1 -0
  110. package/dist/adapter/resources/webgl-vertex-array.d.ts +67 -0
  111. package/dist/adapter/resources/webgl-vertex-array.d.ts.map +1 -0
  112. package/dist/adapter/resources/webgl-vertex-array.js +167 -0
  113. package/dist/adapter/resources/webgl-vertex-array.js.map +1 -0
  114. package/dist/adapter/webgl-canvas-context.d.ts +6 -7
  115. package/dist/adapter/webgl-canvas-context.d.ts.map +1 -1
  116. package/dist/adapter/webgl-canvas-context.js +12 -23
  117. package/dist/adapter/webgl-canvas-context.js.map +1 -1
  118. package/dist/adapter/webgl-device.d.ts +92 -41
  119. package/dist/adapter/webgl-device.d.ts.map +1 -1
  120. package/dist/adapter/webgl-device.js +205 -158
  121. package/dist/adapter/webgl-device.js.map +1 -1
  122. package/dist/classic/accessor.d.ts +3 -3
  123. package/dist/classic/accessor.d.ts.map +1 -1
  124. package/dist/classic/accessor.js +26 -52
  125. package/dist/classic/accessor.js.map +1 -1
  126. package/dist/classic/clear.d.ts +22 -0
  127. package/dist/classic/clear.d.ts.map +1 -0
  128. package/dist/classic/clear.js +88 -0
  129. package/dist/classic/clear.js.map +1 -0
  130. package/dist/classic/copy-and-blit.d.ts +62 -0
  131. package/dist/classic/copy-and-blit.d.ts.map +1 -0
  132. package/dist/classic/copy-and-blit.js +192 -0
  133. package/dist/classic/copy-and-blit.js.map +1 -0
  134. package/dist/classic/format-utils.d.ts +3 -0
  135. package/dist/classic/format-utils.d.ts.map +1 -0
  136. package/dist/classic/format-utils.js +37 -0
  137. package/dist/classic/format-utils.js.map +1 -0
  138. package/dist/classic/typed-array-utils.d.ts +17 -17
  139. package/dist/classic/typed-array-utils.d.ts.map +1 -1
  140. package/dist/classic/typed-array-utils.js +18 -39
  141. package/dist/classic/typed-array-utils.js.map +1 -1
  142. package/dist/context/context/create-browser-context.d.ts +17 -18
  143. package/dist/context/context/create-browser-context.d.ts.map +1 -1
  144. package/dist/context/context/create-browser-context.js +11 -19
  145. package/dist/context/context/create-browser-context.js.map +1 -1
  146. package/dist/context/context/create-headless-context.d.ts +1 -1
  147. package/dist/context/context/create-headless-context.d.ts.map +1 -1
  148. package/dist/context/context/create-headless-context.js +6 -7
  149. package/dist/context/context/create-headless-context.js.map +1 -1
  150. package/dist/context/context/webgl-checks.d.ts.map +1 -1
  151. package/dist/context/context/webgl-checks.js +1 -4
  152. package/dist/context/context/webgl-checks.js.map +1 -1
  153. package/dist/context/debug/spector.d.ts +1 -2
  154. package/dist/context/debug/spector.d.ts.map +1 -1
  155. package/dist/context/debug/spector.js +7 -19
  156. package/dist/context/debug/spector.js.map +1 -1
  157. package/dist/context/debug/webgl-developer-tools.d.ts +1 -1
  158. package/dist/context/debug/webgl-developer-tools.d.ts.map +1 -1
  159. package/dist/context/debug/webgl-developer-tools.js +18 -41
  160. package/dist/context/debug/webgl-developer-tools.js.map +1 -1
  161. package/dist/context/parameters/unified-parameter-api.d.ts +5 -5
  162. package/dist/context/parameters/unified-parameter-api.d.ts.map +1 -1
  163. package/dist/context/parameters/unified-parameter-api.js +9 -17
  164. package/dist/context/parameters/unified-parameter-api.js.map +1 -1
  165. package/dist/context/parameters/webgl-parameter-tables.d.ts +105 -106
  166. package/dist/context/parameters/webgl-parameter-tables.d.ts.map +1 -1
  167. package/dist/context/parameters/webgl-parameter-tables.js +267 -286
  168. package/dist/context/parameters/webgl-parameter-tables.js.map +1 -1
  169. package/dist/context/polyfill/context-data.d.ts +13 -0
  170. package/dist/context/polyfill/context-data.d.ts.map +1 -0
  171. package/dist/context/polyfill/context-data.js +12 -0
  172. package/dist/context/polyfill/context-data.js.map +1 -0
  173. package/dist/context/polyfill/get-parameter-polyfill.d.ts +1 -1
  174. package/dist/context/polyfill/get-parameter-polyfill.d.ts.map +1 -1
  175. package/dist/context/polyfill/get-parameter-polyfill.js +37 -43
  176. package/dist/context/polyfill/get-parameter-polyfill.js.map +1 -1
  177. package/dist/context/polyfill/polyfill-context.d.ts.map +1 -1
  178. package/dist/context/polyfill/polyfill-context.js +27 -31
  179. package/dist/context/polyfill/polyfill-context.js.map +1 -1
  180. package/dist/context/polyfill/polyfill-table.d.ts +7 -7
  181. package/dist/context/polyfill/polyfill-table.d.ts.map +1 -1
  182. package/dist/context/polyfill/polyfill-table.js +17 -40
  183. package/dist/context/polyfill/polyfill-table.js.map +1 -1
  184. package/dist/context/polyfill/polyfill-vertex-array-object.d.ts.map +1 -1
  185. package/dist/context/polyfill/polyfill-vertex-array-object.js +17 -87
  186. package/dist/context/polyfill/polyfill-vertex-array-object.js.map +1 -1
  187. package/dist/context/state-tracker/deep-array-equal.d.ts.map +1 -1
  188. package/dist/context/state-tracker/deep-array-equal.js +0 -4
  189. package/dist/context/state-tracker/deep-array-equal.js.map +1 -1
  190. package/dist/context/state-tracker/track-context-state.d.ts.map +1 -1
  191. package/dist/context/state-tracker/track-context-state.js +25 -61
  192. package/dist/context/state-tracker/track-context-state.js.map +1 -1
  193. package/dist/context/state-tracker/with-parameters.d.ts +2 -1
  194. package/dist/context/state-tracker/with-parameters.d.ts.map +1 -1
  195. package/dist/context/state-tracker/with-parameters.js +8 -10
  196. package/dist/context/state-tracker/with-parameters.js.map +1 -1
  197. package/dist/dist.dev.js +9344 -0
  198. package/dist/index.cjs +6556 -0
  199. package/dist/index.d.ts +23 -24
  200. package/dist/index.d.ts.map +1 -1
  201. package/dist/index.js +27 -27
  202. package/dist/index.js.map +1 -1
  203. package/dist/types.d.ts +3 -1
  204. package/dist/types.d.ts.map +1 -1
  205. package/dist/types.js.map +1 -1
  206. package/dist.min.js +52 -0
  207. package/package.json +21 -9
  208. package/src/adapter/converters/device-parameters.ts +120 -43
  209. package/src/adapter/converters/sampler-parameters.ts +54 -126
  210. package/src/adapter/converters/shader-formats.ts +44 -0
  211. package/src/adapter/converters/texture-formats.ts +265 -192
  212. package/src/adapter/converters/vertex-formats.ts +71 -10
  213. package/src/adapter/device-helpers/device-features.ts +5 -2
  214. package/src/adapter/device-helpers/device-limits.ts +4 -2
  215. package/src/adapter/device-helpers/get-device-info.ts +72 -18
  216. package/src/adapter/device-helpers/is-old-ie.ts +3 -0
  217. package/src/adapter/helpers/{uniforms.ts → decode-webgl-types.ts} +31 -24
  218. package/src/adapter/helpers/get-shader-layout.ts +87 -131
  219. package/src/adapter/helpers/parse-shader-compiler-log.ts +24 -8
  220. package/src/adapter/helpers/set-uniform.ts +39 -35
  221. package/src/adapter/helpers/webgl-topology-utils.ts +103 -0
  222. package/src/adapter/objects/constants-to-keys.ts +6 -25
  223. package/src/adapter/objects/webgl-renderbuffer.ts +43 -37
  224. package/src/adapter/objects/webgl-resource.ts +16 -23
  225. package/src/adapter/resources/webgl-buffer.ts +101 -106
  226. package/src/adapter/resources/webgl-command-buffer.ts +327 -25
  227. package/src/adapter/resources/webgl-command-encoder.ts +20 -12
  228. package/src/adapter/resources/webgl-external-texture.ts +5 -2
  229. package/src/adapter/resources/webgl-framebuffer.ts +86 -133
  230. package/src/adapter/resources/webgl-render-pass.ts +165 -4
  231. package/src/adapter/resources/webgl-render-pipeline.ts +209 -205
  232. package/src/adapter/resources/webgl-sampler.ts +12 -8
  233. package/src/adapter/resources/webgl-shader.ts +32 -27
  234. package/src/adapter/resources/webgl-texture.ts +117 -91
  235. package/src/adapter/resources/webgl-transform-feedback.ts +202 -0
  236. package/src/adapter/resources/webgl-vertex-array.ts +283 -0
  237. package/src/adapter/webgl-canvas-context.ts +18 -13
  238. package/src/adapter/webgl-device.ts +327 -92
  239. package/src/classic/accessor.ts +8 -5
  240. package/src/classic/clear.ts +113 -0
  241. package/src/classic/copy-and-blit.ts +312 -0
  242. package/src/classic/format-utils.ts +46 -0
  243. package/src/classic/typed-array-utils.ts +19 -27
  244. package/src/context/context/create-browser-context.ts +53 -31
  245. package/src/context/context/create-headless-context.ts +5 -2
  246. package/src/context/context/webgl-checks.ts +3 -1
  247. package/src/context/debug/spector.ts +8 -5
  248. package/src/context/debug/webgl-developer-tools.ts +26 -17
  249. package/src/context/parameters/unified-parameter-api.ts +15 -9
  250. package/src/context/parameters/webgl-parameter-tables.ts +120 -98
  251. package/src/context/polyfill/context-data.ts +30 -0
  252. package/src/context/polyfill/get-parameter-polyfill.ts +11 -7
  253. package/src/context/polyfill/polyfill-context.ts +15 -8
  254. package/src/context/polyfill/polyfill-table.ts +20 -15
  255. package/src/context/polyfill/polyfill-vertex-array-object.ts +5 -0
  256. package/src/context/state-tracker/deep-array-equal.ts +2 -0
  257. package/src/context/state-tracker/track-context-state.ts +13 -10
  258. package/src/context/state-tracker/with-parameters.ts +13 -4
  259. package/src/index.ts +65 -39
  260. package/src/types.ts +5 -0
  261. package/dist/adapter/converters/renderbuffer-formats.d.ts +0 -16
  262. package/dist/adapter/converters/renderbuffer-formats.d.ts.map +0 -1
  263. package/dist/adapter/converters/renderbuffer-formats.js +0 -185
  264. package/dist/adapter/converters/renderbuffer-formats.js.map +0 -1
  265. package/dist/adapter/helpers/attribute-utils.d.ts +0 -11
  266. package/dist/adapter/helpers/attribute-utils.d.ts.map +0 -1
  267. package/dist/adapter/helpers/attribute-utils.js +0 -81
  268. package/dist/adapter/helpers/attribute-utils.js.map +0 -1
  269. package/dist/adapter/helpers/uniforms.d.ts +0 -26
  270. package/dist/adapter/helpers/uniforms.d.ts.map +0 -1
  271. package/dist/adapter/helpers/uniforms.js +0 -99
  272. package/dist/adapter/helpers/uniforms.js.map +0 -1
  273. package/dist/adapter/objects/webgl-vertex-array-object.d.ts +0 -27
  274. package/dist/adapter/objects/webgl-vertex-array-object.d.ts.map +0 -1
  275. package/dist/adapter/objects/webgl-vertex-array-object.js +0 -84
  276. package/dist/adapter/objects/webgl-vertex-array-object.js.map +0 -1
  277. package/dist/bundle.d.ts +0 -2
  278. package/dist/bundle.d.ts.map +0 -1
  279. package/dist/bundle.js +0 -5
  280. package/dist/bundle.js.map +0 -1
  281. package/dist/classic/buffer.d.ts +0 -95
  282. package/dist/classic/buffer.d.ts.map +0 -1
  283. package/dist/classic/buffer.js +0 -392
  284. package/dist/classic/buffer.js.map +0 -1
  285. package/dist/context/context/context-state.d.ts +0 -18
  286. package/dist/context/context/context-state.d.ts.map +0 -1
  287. package/dist/context/context/context-state.js +0 -26
  288. package/dist/context/context/context-state.js.map +0 -1
  289. package/dist/context/context/device-pixels.d.ts +0 -25
  290. package/dist/context/context/device-pixels.d.ts.map +0 -1
  291. package/dist/context/context/device-pixels.js +0 -103
  292. package/dist/context/context/device-pixels.js.map +0 -1
  293. package/dist/es5/adapter/converters/device-parameters.js +0 -185
  294. package/dist/es5/adapter/converters/device-parameters.js.map +0 -1
  295. package/dist/es5/adapter/converters/renderbuffer-formats.js +0 -163
  296. package/dist/es5/adapter/converters/renderbuffer-formats.js.map +0 -1
  297. package/dist/es5/adapter/converters/sampler-parameters.js +0 -245
  298. package/dist/es5/adapter/converters/sampler-parameters.js.map +0 -1
  299. package/dist/es5/adapter/converters/texture-formats.js +0 -1031
  300. package/dist/es5/adapter/converters/texture-formats.js.map +0 -1
  301. package/dist/es5/adapter/converters/vertex-formats.js +0 -45
  302. package/dist/es5/adapter/converters/vertex-formats.js.map +0 -1
  303. package/dist/es5/adapter/device-helpers/device-features.js +0 -155
  304. package/dist/es5/adapter/device-helpers/device-features.js.map +0 -1
  305. package/dist/es5/adapter/device-helpers/device-limits.js +0 -64
  306. package/dist/es5/adapter/device-helpers/device-limits.js.map +0 -1
  307. package/dist/es5/adapter/device-helpers/get-device-info.js +0 -55
  308. package/dist/es5/adapter/device-helpers/get-device-info.js.map +0 -1
  309. package/dist/es5/adapter/device-helpers/is-old-ie.js +0 -16
  310. package/dist/es5/adapter/device-helpers/is-old-ie.js.map +0 -1
  311. package/dist/es5/adapter/helpers/attribute-utils.js +0 -91
  312. package/dist/es5/adapter/helpers/attribute-utils.js.map +0 -1
  313. package/dist/es5/adapter/helpers/get-shader-layout.js +0 -391
  314. package/dist/es5/adapter/helpers/get-shader-layout.js.map +0 -1
  315. package/dist/es5/adapter/helpers/parse-shader-compiler-log.js +0 -72
  316. package/dist/es5/adapter/helpers/parse-shader-compiler-log.js.map +0 -1
  317. package/dist/es5/adapter/helpers/set-uniform.js +0 -125
  318. package/dist/es5/adapter/helpers/set-uniform.js.map +0 -1
  319. package/dist/es5/adapter/helpers/uniforms.js +0 -112
  320. package/dist/es5/adapter/helpers/uniforms.js.map +0 -1
  321. package/dist/es5/adapter/objects/constants-to-keys.js +0 -54
  322. package/dist/es5/adapter/objects/constants-to-keys.js.map +0 -1
  323. package/dist/es5/adapter/objects/webgl-renderbuffer.js +0 -150
  324. package/dist/es5/adapter/objects/webgl-renderbuffer.js.map +0 -1
  325. package/dist/es5/adapter/objects/webgl-resource.js +0 -292
  326. package/dist/es5/adapter/objects/webgl-resource.js.map +0 -1
  327. package/dist/es5/adapter/objects/webgl-vertex-array-object.js +0 -137
  328. package/dist/es5/adapter/objects/webgl-vertex-array-object.js.map +0 -1
  329. package/dist/es5/adapter/resources/webgl-buffer.js +0 -243
  330. package/dist/es5/adapter/resources/webgl-buffer.js.map +0 -1
  331. package/dist/es5/adapter/resources/webgl-command-buffer.js +0 -96
  332. package/dist/es5/adapter/resources/webgl-command-buffer.js.map +0 -1
  333. package/dist/es5/adapter/resources/webgl-command-encoder.js +0 -98
  334. package/dist/es5/adapter/resources/webgl-command-encoder.js.map +0 -1
  335. package/dist/es5/adapter/resources/webgl-external-texture.js +0 -2
  336. package/dist/es5/adapter/resources/webgl-external-texture.js.map +0 -1
  337. package/dist/es5/adapter/resources/webgl-framebuffer.js +0 -346
  338. package/dist/es5/adapter/resources/webgl-framebuffer.js.map +0 -1
  339. package/dist/es5/adapter/resources/webgl-render-pass.js +0 -62
  340. package/dist/es5/adapter/resources/webgl-render-pass.js.map +0 -1
  341. package/dist/es5/adapter/resources/webgl-render-pipeline.js +0 -530
  342. package/dist/es5/adapter/resources/webgl-render-pipeline.js.map +0 -1
  343. package/dist/es5/adapter/resources/webgl-sampler.js +0 -96
  344. package/dist/es5/adapter/resources/webgl-sampler.js.map +0 -1
  345. package/dist/es5/adapter/resources/webgl-shader.js +0 -150
  346. package/dist/es5/adapter/resources/webgl-shader.js.map +0 -1
  347. package/dist/es5/adapter/resources/webgl-texture.js +0 -986
  348. package/dist/es5/adapter/resources/webgl-texture.js.map +0 -1
  349. package/dist/es5/adapter/webgl-canvas-context.js +0 -97
  350. package/dist/es5/adapter/webgl-canvas-context.js.map +0 -1
  351. package/dist/es5/adapter/webgl-device.js +0 -463
  352. package/dist/es5/adapter/webgl-device.js.map +0 -1
  353. package/dist/es5/bundle.js +0 -7
  354. package/dist/es5/bundle.js.map +0 -1
  355. package/dist/es5/classic/accessor.js +0 -181
  356. package/dist/es5/classic/accessor.js.map +0 -1
  357. package/dist/es5/classic/buffer.js +0 -478
  358. package/dist/es5/classic/buffer.js.map +0 -1
  359. package/dist/es5/classic/typed-array-utils.js +0 -126
  360. package/dist/es5/classic/typed-array-utils.js.map +0 -1
  361. package/dist/es5/context/context/context-state.js +0 -31
  362. package/dist/es5/context/context/context-state.js.map +0 -1
  363. package/dist/es5/context/context/create-browser-context.js +0 -83
  364. package/dist/es5/context/context/create-browser-context.js.map +0 -1
  365. package/dist/es5/context/context/create-headless-context.js +0 -60
  366. package/dist/es5/context/context/create-headless-context.js.map +0 -1
  367. package/dist/es5/context/context/device-pixels.js +0 -121
  368. package/dist/es5/context/context/device-pixels.js.map +0 -1
  369. package/dist/es5/context/context/webgl-checks.js +0 -54
  370. package/dist/es5/context/context/webgl-checks.js.map +0 -1
  371. package/dist/es5/context/debug/spector.js +0 -133
  372. package/dist/es5/context/debug/spector.js.map +0 -1
  373. package/dist/es5/context/debug/webgl-developer-tools.js +0 -198
  374. package/dist/es5/context/debug/webgl-developer-tools.js.map +0 -1
  375. package/dist/es5/context/parameters/unified-parameter-api.js +0 -97
  376. package/dist/es5/context/parameters/unified-parameter-api.js.map +0 -1
  377. package/dist/es5/context/parameters/webgl-parameter-tables.js +0 -392
  378. package/dist/es5/context/parameters/webgl-parameter-tables.js.map +0 -1
  379. package/dist/es5/context/polyfill/get-parameter-polyfill.js +0 -81
  380. package/dist/es5/context/polyfill/get-parameter-polyfill.js.map +0 -1
  381. package/dist/es5/context/polyfill/polyfill-context.js +0 -134
  382. package/dist/es5/context/polyfill/polyfill-context.js.map +0 -1
  383. package/dist/es5/context/polyfill/polyfill-table.js +0 -166
  384. package/dist/es5/context/polyfill/polyfill-table.js.map +0 -1
  385. package/dist/es5/context/polyfill/polyfill-vertex-array-object.js +0 -341
  386. package/dist/es5/context/polyfill/polyfill-vertex-array-object.js.map +0 -1
  387. package/dist/es5/context/state-tracker/deep-array-equal.js +0 -28
  388. package/dist/es5/context/state-tracker/deep-array-equal.js.map +0 -1
  389. package/dist/es5/context/state-tracker/track-context-state.js +0 -211
  390. package/dist/es5/context/state-tracker/track-context-state.js.map +0 -1
  391. package/dist/es5/context/state-tracker/with-parameters.js +0 -44
  392. package/dist/es5/context/state-tracker/with-parameters.js.map +0 -1
  393. package/dist/es5/index.js +0 -290
  394. package/dist/es5/index.js.map +0 -1
  395. package/dist/es5/init.js +0 -10
  396. package/dist/es5/init.js.map +0 -1
  397. package/dist/es5/types/webgl.js +0 -6
  398. package/dist/es5/types/webgl.js.map +0 -1
  399. package/dist/es5/types.js +0 -2
  400. package/dist/es5/types.js.map +0 -1
  401. package/dist/esm/adapter/converters/device-parameters.js +0 -168
  402. package/dist/esm/adapter/converters/device-parameters.js.map +0 -1
  403. package/dist/esm/adapter/converters/renderbuffer-formats.js +0 -185
  404. package/dist/esm/adapter/converters/renderbuffer-formats.js.map +0 -1
  405. package/dist/esm/adapter/converters/sampler-parameters.js +0 -227
  406. package/dist/esm/adapter/converters/sampler-parameters.js.map +0 -1
  407. package/dist/esm/adapter/converters/texture-formats.js +0 -954
  408. package/dist/esm/adapter/converters/texture-formats.js.map +0 -1
  409. package/dist/esm/adapter/converters/vertex-formats.js +0 -35
  410. package/dist/esm/adapter/converters/vertex-formats.js.map +0 -1
  411. package/dist/esm/adapter/device-helpers/device-features.js +0 -112
  412. package/dist/esm/adapter/device-helpers/device-features.js.map +0 -1
  413. package/dist/esm/adapter/device-helpers/device-limits.js +0 -91
  414. package/dist/esm/adapter/device-helpers/device-limits.js.map +0 -1
  415. package/dist/esm/adapter/device-helpers/get-device-info.js +0 -44
  416. package/dist/esm/adapter/device-helpers/get-device-info.js.map +0 -1
  417. package/dist/esm/adapter/device-helpers/is-old-ie.js +0 -8
  418. package/dist/esm/adapter/device-helpers/is-old-ie.js.map +0 -1
  419. package/dist/esm/adapter/helpers/attribute-utils.js +0 -81
  420. package/dist/esm/adapter/helpers/attribute-utils.js.map +0 -1
  421. package/dist/esm/adapter/helpers/get-shader-layout.js +0 -330
  422. package/dist/esm/adapter/helpers/get-shader-layout.js.map +0 -1
  423. package/dist/esm/adapter/helpers/parse-shader-compiler-log.js +0 -37
  424. package/dist/esm/adapter/helpers/parse-shader-compiler-log.js.map +0 -1
  425. package/dist/esm/adapter/helpers/set-uniform.js +0 -115
  426. package/dist/esm/adapter/helpers/set-uniform.js.map +0 -1
  427. package/dist/esm/adapter/helpers/uniforms.js +0 -99
  428. package/dist/esm/adapter/helpers/uniforms.js.map +0 -1
  429. package/dist/esm/adapter/objects/constants-to-keys.js +0 -42
  430. package/dist/esm/adapter/objects/constants-to-keys.js.map +0 -1
  431. package/dist/esm/adapter/objects/webgl-renderbuffer.js +0 -94
  432. package/dist/esm/adapter/objects/webgl-renderbuffer.js.map +0 -1
  433. package/dist/esm/adapter/objects/webgl-resource.js +0 -216
  434. package/dist/esm/adapter/objects/webgl-resource.js.map +0 -1
  435. package/dist/esm/adapter/objects/webgl-vertex-array-object.js +0 -84
  436. package/dist/esm/adapter/objects/webgl-vertex-array-object.js.map +0 -1
  437. package/dist/esm/adapter/resources/webgl-buffer.js +0 -164
  438. package/dist/esm/adapter/resources/webgl-buffer.js.map +0 -1
  439. package/dist/esm/adapter/resources/webgl-command-buffer.js +0 -65
  440. package/dist/esm/adapter/resources/webgl-command-buffer.js.map +0 -1
  441. package/dist/esm/adapter/resources/webgl-command-encoder.js +0 -53
  442. package/dist/esm/adapter/resources/webgl-command-encoder.js.map +0 -1
  443. package/dist/esm/adapter/resources/webgl-external-texture.js +0 -2
  444. package/dist/esm/adapter/resources/webgl-external-texture.js.map +0 -1
  445. package/dist/esm/adapter/resources/webgl-framebuffer.js +0 -267
  446. package/dist/esm/adapter/resources/webgl-framebuffer.js.map +0 -1
  447. package/dist/esm/adapter/resources/webgl-render-pass.js +0 -21
  448. package/dist/esm/adapter/resources/webgl-render-pass.js.map +0 -1
  449. package/dist/esm/adapter/resources/webgl-render-pipeline.js +0 -428
  450. package/dist/esm/adapter/resources/webgl-render-pipeline.js.map +0 -1
  451. package/dist/esm/adapter/resources/webgl-sampler.js +0 -50
  452. package/dist/esm/adapter/resources/webgl-sampler.js.map +0 -1
  453. package/dist/esm/adapter/resources/webgl-shader.js +0 -76
  454. package/dist/esm/adapter/resources/webgl-shader.js.map +0 -1
  455. package/dist/esm/adapter/resources/webgl-texture.js +0 -834
  456. package/dist/esm/adapter/resources/webgl-texture.js.map +0 -1
  457. package/dist/esm/adapter/webgl-canvas-context.js +0 -54
  458. package/dist/esm/adapter/webgl-canvas-context.js.map +0 -1
  459. package/dist/esm/adapter/webgl-device.js +0 -337
  460. package/dist/esm/adapter/webgl-device.js.map +0 -1
  461. package/dist/esm/bundle.js +0 -5
  462. package/dist/esm/bundle.js.map +0 -1
  463. package/dist/esm/classic/accessor.js +0 -144
  464. package/dist/esm/classic/accessor.js.map +0 -1
  465. package/dist/esm/classic/buffer.js +0 -392
  466. package/dist/esm/classic/buffer.js.map +0 -1
  467. package/dist/esm/classic/typed-array-utils.js +0 -112
  468. package/dist/esm/classic/typed-array-utils.js.map +0 -1
  469. package/dist/esm/context/context/context-state.js +0 -26
  470. package/dist/esm/context/context/context-state.js.map +0 -1
  471. package/dist/esm/context/context/create-browser-context.js +0 -61
  472. package/dist/esm/context/context/create-browser-context.js.map +0 -1
  473. package/dist/esm/context/context/create-headless-context.js +0 -43
  474. package/dist/esm/context/context/create-headless-context.js.map +0 -1
  475. package/dist/esm/context/context/device-pixels.js +0 -103
  476. package/dist/esm/context/context/device-pixels.js.map +0 -1
  477. package/dist/esm/context/context/webgl-checks.js +0 -34
  478. package/dist/esm/context/context/webgl-checks.js.map +0 -1
  479. package/dist/esm/context/debug/spector.js +0 -76
  480. package/dist/esm/context/debug/spector.js.map +0 -1
  481. package/dist/esm/context/debug/webgl-developer-tools.js +0 -121
  482. package/dist/esm/context/debug/webgl-developer-tools.js.map +0 -1
  483. package/dist/esm/context/parameters/unified-parameter-api.js +0 -63
  484. package/dist/esm/context/parameters/unified-parameter-api.js.map +0 -1
  485. package/dist/esm/context/parameters/webgl-parameter-tables.js +0 -445
  486. package/dist/esm/context/parameters/webgl-parameter-tables.js.map +0 -1
  487. package/dist/esm/context/polyfill/get-parameter-polyfill.js +0 -91
  488. package/dist/esm/context/polyfill/get-parameter-polyfill.js.map +0 -1
  489. package/dist/esm/context/polyfill/polyfill-context.js +0 -91
  490. package/dist/esm/context/polyfill/polyfill-context.js.map +0 -1
  491. package/dist/esm/context/polyfill/polyfill-table.js +0 -160
  492. package/dist/esm/context/polyfill/polyfill-table.js.map +0 -1
  493. package/dist/esm/context/polyfill/polyfill-vertex-array-object.js +0 -335
  494. package/dist/esm/context/polyfill/polyfill-vertex-array-object.js.map +0 -1
  495. package/dist/esm/context/state-tracker/deep-array-equal.js +0 -21
  496. package/dist/esm/context/state-tracker/deep-array-equal.js.map +0 -1
  497. package/dist/esm/context/state-tracker/track-context-state.js +0 -183
  498. package/dist/esm/context/state-tracker/track-context-state.js.map +0 -1
  499. package/dist/esm/context/state-tracker/with-parameters.js +0 -36
  500. package/dist/esm/context/state-tracker/with-parameters.js.map +0 -1
  501. package/dist/esm/index.js +0 -28
  502. package/dist/esm/index.js.map +0 -1
  503. package/dist/esm/init.js +0 -4
  504. package/dist/esm/init.js.map +0 -1
  505. package/dist/esm/types/webgl.js +0 -2
  506. package/dist/esm/types/webgl.js.map +0 -1
  507. package/dist/esm/types.js +0 -2
  508. package/dist/esm/types.js.map +0 -1
  509. package/dist/init.d.ts +0 -2
  510. package/dist/init.d.ts.map +0 -1
  511. package/dist/init.js +0 -4
  512. package/dist/init.js.map +0 -1
  513. package/dist/types/webgl.d.ts +0 -145
  514. package/dist/types/webgl.d.ts.map +0 -1
  515. package/dist/types/webgl.js +0 -2
  516. package/dist/types/webgl.js.map +0 -1
  517. package/src/adapter/converters/renderbuffer-formats.ts +0 -92
  518. package/src/adapter/helpers/attribute-utils.ts +0 -61
  519. package/src/adapter/objects/webgl-vertex-array-object.ts +0 -111
  520. package/src/bundle.ts +0 -4
  521. package/src/classic/buffer.ts +0 -474
  522. package/src/context/context/context-state.ts +0 -41
  523. package/src/context/context/device-pixels.ts +0 -158
  524. package/src/init.ts +0 -4
  525. package/src/types/webgl.ts +0 -284
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../src/context/context/create-browser-context.ts"],"names":["DEFAULT_CONTEXT_PROPS","webgl2","webgl1","powerPreference","onContextLost","console","error","onContextRestored","info","createBrowserContext","canvas","props","errorMessage","onCreateError","statusMessage","addEventListener","gl","type","getContext","removeEventListener","Error","event"],"mappings":"AAmCA,MAAMA,qBAAmC,GAAG;AAC1CC,EAAAA,MAAM,EAAE,IADkC;AAE1CC,EAAAA,MAAM,EAAE,IAFkC;AAG1CC,EAAAA,eAAe,EAAE,kBAHyB;AAI1CC,EAAAA,aAAa,EAAE,MAAMC,OAAO,CAACC,KAAR,CAAc,oBAAd,CAJqB;AAK1CC,EAAAA,iBAAiB,EAAE,MAAMF,OAAO,CAACG,IAAR,CAAa,wBAAb;AALiB,CAA5C;AAaC,OAAO,SAASC,oBAAT,CAA8BC,MAA9B,EAA2EC,KAA3E,EAAuH;AAC5HA,EAAAA,KAAK,GAAG,EAAC,GAAGX,qBAAJ;AAA2B,OAAGW;AAA9B,GAAR;AAGD,MAAIC,YAAY,GAAG,IAAnB;;AACA,QAAMC,aAAa,GAAIP,KAAD,IAAYM,YAAY,GAAGN,KAAK,CAACQ,aAAN,IAAuBF,YAAxE;;AACAF,EAAAA,MAAM,CAACK,gBAAP,CAAwB,2BAAxB,EAAqDF,aAArD,EAAoE,KAApE;AAGA,MAAIG,EAAgC,GAAG,IAAvC;;AAEA,MAAIL,KAAK,CAACM,IAAN,KAAe,QAAnB,EAA6B;AAC3BN,IAAAA,KAAK,GAAG,EAAC,GAAGA,KAAJ;AAAWT,MAAAA,MAAM,EAAE;AAAnB,KAAR;AACD;;AACD,MAAIS,KAAK,CAACM,IAAN,KAAe,QAAnB,EAA6B;AAC3BN,IAAAA,KAAK,GAAG,EAAC,GAAGA,KAAJ;AAAWV,MAAAA,MAAM,EAAE;AAAnB,KAAR;AACD;;AAGD,MAAIU,KAAK,CAACV,MAAV,EAAkB;AAChBe,IAAAA,EAAE,GAAGA,EAAE,IAAIN,MAAM,CAACQ,UAAP,CAAkB,QAAlB,EAA4BP,KAA5B,CAAX;AACD;;AACD,MAAIA,KAAK,CAACT,MAAV,EAAkB;AAChBc,IAAAA,EAAE,GAAGA,EAAE,IAAIN,MAAM,CAACQ,UAAP,CAAkB,OAAlB,EAA2BP,KAA3B,CAAX;AACD;;AAGDD,EAAAA,MAAM,CAACS,mBAAP,CAA2B,2BAA3B,EAAwDN,aAAxD,EAAuE,KAAvE;;AAEA,MAAI,CAACG,EAAL,EAAS;AACP,UAAM,IAAII,KAAJ,4BACgBT,KAAK,CAACV,MAAN,IAAgB,CAACU,KAAK,CAACT,MAAvB,GAAgC,QAAhC,GAA2C,OAD3D,uBAEFU,YAAY,IAAI,eAFd,EAAN;AAKD;;AAED,MAAID,KAAK,CAACP,aAAV,EAAyB;AAEvB,UAAM;AAACA,MAAAA;AAAD,QAAkBO,KAAxB;AACAD,IAAAA,MAAM,CAACK,gBAAP,CAAwB,kBAAxB,EAA4CM,KAAD,IAAkBjB,aAAa,CAACiB,KAAD,CAA1E,EAAmF,KAAnF;AACD;;AACD,MAAIV,KAAK,CAACJ,iBAAV,EAA6B;AAE3B,UAAM;AAACA,MAAAA;AAAD,QAAsBI,KAA5B;AACAD,IAAAA,MAAM,CAACK,gBAAP,CAAwB,sBAAxB,EAAiDM,KAAD,IAAkBd,iBAAiB,CAACc,KAAD,CAAnF,EAA4F,KAA5F;AACD;;AAED,SAAOL,EAAP;AACD","sourcesContent":["// luma.gl, MIT license\n\n/**\n * ContextProps\n* @param webgl2 Set to false to not create a WebGL2 context (force webgl1)\n* @param webgl1 set to false to not create a WebGL1 context (fail if webgl2 not available)\n* @param onContextLost\n* @param onContextRestored\n*\n* BROWSER CONTEXT PARAMETERS\n* @param debug Instrument context (at the expense of performance).\n* @param alpha Default render target has an alpha buffer.\n* @param depth Default render target has a depth buffer of at least 16 bits.\n* @param stencil Default render target has a stencil buffer of at least 8 bits.\n* @param antialias Boolean that indicates whether or not to perform anti-aliasing.\n* @param premultipliedAlpha Boolean that indicates that the page compositor will assume the drawing buffer contains colors with pre-multiplied alpha.\n* @param preserveDrawingBuffer Default render target buffers will not be automatically cleared and will preserve their values until cleared or overwritten\n* @param failIfMajorPerformanceCaveat Do not create if the system performance is low.\n*/\ntype ContextProps = {\n type?: 'webgl' | 'webgl1' | 'webgl2' | string;\n webgl1?: boolean;\n webgl2?: boolean;\n onContextLost?: (event: Event) => void;\n onContextRestored?: (event: Event) => void;\n alpha?: boolean; // indicates if the canvas contains an alpha buffer.\n desynchronized?: boolean; // hints the user agent to reduce the latency by desynchronizing the canvas paint cycle from the event loop\n antialias?: boolean; // indicates whether or not to perform anti-aliasing.\n depth?: boolean; // indicates that the drawing buffer has a depth buffer of at least 16 bits.\n failIfMajorPerformanceCaveat?: boolean, // indicates if a context will be created if the system performance is low or if no hardware GPU is available.\n powerPreference?: 'default' | 'high-performance' | 'low-power',\n premultipliedAlpha?: boolean, // page compositor will assume the drawing buffer contains colors with pre-multiplied alpha.\n preserveDrawingBuffer?: boolean // buffers will not be cleared and will preserve their values until cleared or overwritten by the author.\n};\n\nconst DEFAULT_CONTEXT_PROPS: ContextProps = {\n webgl2: true, // Attempt to create a WebGL2 context\n webgl1: true, // Attempt to create a WebGL1 context (false to fail if webgl2 not available)\n powerPreference: 'high-performance', // After all, most apps are using WebGL for performance reasons\n onContextLost: () => console.error('WebGL context lost'),\n onContextRestored: () => console.info('WebGL context restored'),\n};\n\n/**\n * Create a WebGL context for a canvas\n * Note calling this multiple time on the same canvas does return the same context\n* @param canvas A canvas element or offscreen canvas\n */\n export function createBrowserContext(canvas: HTMLCanvasElement | OffscreenCanvas, props: ContextProps): WebGLRenderingContext {\n props = {...DEFAULT_CONTEXT_PROPS, ...props};\n\n // Try to extract any extra information about why context creation failed\n let errorMessage = null;\n const onCreateError = (error) => (errorMessage = error.statusMessage || errorMessage);\n canvas.addEventListener('webglcontextcreationerror', onCreateError, false);\n\n // Create the desired context\n let gl: WebGLRenderingContext | null = null;\n\n if (props.type === 'webgl2') {\n props = {...props, webgl1: false};\n }\n if (props.type === 'webgl1') {\n props = {...props, webgl2: false};\n }\n\n // Prefer webgl2 over webgl1 if both are acceptable\n if (props.webgl2) {\n gl = gl || canvas.getContext('webgl2', props) as WebGL2RenderingContext | null;\n }\n if (props.webgl1) {\n gl = gl || canvas.getContext('webgl', props) as WebGLRenderingContext | null;\n }\n\n // TODO are we removing this listener before giving it a chance to fire?\n canvas.removeEventListener('webglcontextcreationerror', onCreateError, false);\n\n if (!gl) {\n throw new Error(\n `Failed to create ${props.webgl2 && !props.webgl1 ? 'WebGL2' : 'WebGL'} context: ${\n errorMessage || 'Unknown error'\n }`\n );\n }\n\n if (props.onContextLost) {\n // Carefully extract and wrap callbacks to prevent addEventListener from rebinding them.\n const {onContextLost} = props;\n canvas.addEventListener('webglcontextlost',(event: Event) => onContextLost(event), false);\n }\n if (props.onContextRestored) {\n // Carefully extract and wrap callbacks to prevent addEventListener from rebinding them.\n const {onContextRestored} = props;\n canvas.addEventListener('webglcontextrestored', (event: Event) => onContextRestored(event), false);\n }\n\n return gl;\n}\n\n/* TODO - can we call this asynchronously to catch the error events?\nexport async function createBrowserContextAsync(canvas: HTMLCanvasElement | OffscreenCanvas, props: ContextProps): Promise<WebGLRenderingContext> {\n props = {...DEFAULT_CONTEXT_PROPS, ...props};\n\n // Try to extract any extra information about why context creation failed\n let errorMessage = null;\n const onCreateError = (error) => (errorMessage = error.statusMessage || errorMessage);\n canvas.addEventListener('webglcontextcreationerror', onCreateError, false);\n\n const gl = createBrowserContext(canvas, props);\n\n // Give the listener a chance to fire\n await new Promise(resolve => setTimeout(resolve, 0));\n\n canvas.removeEventListener('webglcontextcreationerror', onCreateError, false);\n\n return gl;\n}\n*/\n"],"file":"create-browser-context.js"}
1
+ {"version":3,"file":"create-browser-context.js","names":["DEFAULT_CONTEXT_PROPS","webgl2","webgl1","powerPreference","onContextLost","console","error","onContextRestored","info","createBrowserContext","canvas","props","errorMessage","onCreateError","statusMessage","addEventListener","gl","type","getContext","removeEventListener","Error","event"],"sources":["../../../src/context/context/create-browser-context.ts"],"sourcesContent":["// luma.gl, MIT license\n// Copyright (c) vis.gl contributors\n\n/**\n * ContextProps\n * @param webgl2 Set to false to not create a WebGL2 context (force webgl1)\n * @param webgl1 set to false to not create a WebGL1 context (fail if webgl2 not available)\n * @param onContextLost\n * @param onContextRestored\n *\n * BROWSER CONTEXT PARAMETERS\n * @param debug Instrument context (at the expense of performance).\n * @param alpha Default render target has an alpha buffer.\n * @param depth Default render target has a depth buffer of at least 16 bits.\n * @param stencil Default render target has a stencil buffer of at least 8 bits.\n * @param antialias Boolean that indicates whether or not to perform anti-aliasing.\n * @param premultipliedAlpha Boolean that indicates that the page compositor will assume the drawing buffer contains colors with pre-multiplied alpha.\n * @param preserveDrawingBuffer Default render target buffers will not be automatically cleared and will preserve their values until cleared or overwritten\n * @param failIfMajorPerformanceCaveat Do not create if the system performance is low.\n */\ntype ContextProps = {\n type?: 'webgl' | 'webgl1' | 'webgl2' | string;\n webgl1?: boolean;\n webgl2?: boolean;\n onContextLost?: (event: Event) => void;\n onContextRestored?: (event: Event) => void;\n alpha?: boolean; // indicates if the canvas contains an alpha buffer.\n desynchronized?: boolean; // hints the user agent to reduce the latency by desynchronizing the canvas paint cycle from the event loop\n antialias?: boolean; // indicates whether or not to perform anti-aliasing.\n depth?: boolean; // indicates that the drawing buffer has a depth buffer of at least 16 bits.\n failIfMajorPerformanceCaveat?: boolean; // indicates if a context will be created if the system performance is low or if no hardware GPU is available.\n powerPreference?: 'default' | 'high-performance' | 'low-power';\n premultipliedAlpha?: boolean; // page compositor will assume the drawing buffer contains colors with pre-multiplied alpha.\n preserveDrawingBuffer?: boolean; // buffers will not be cleared and will preserve their values until cleared or overwritten by the author.\n};\n\nconst DEFAULT_CONTEXT_PROPS: ContextProps = {\n webgl2: true, // Attempt to create a WebGL2 context\n webgl1: true, // Attempt to create a WebGL1 context (false to fail if webgl2 not available)\n powerPreference: 'high-performance', // After all, most apps are using WebGL for performance reasons\n // eslint-disable-next-line no-console\n onContextLost: () => console.error('WebGL context lost'),\n // eslint-disable-next-line no-console\n onContextRestored: () => console.info('WebGL context restored')\n};\n\n/**\n * Create a WebGL context for a canvas\n * Note calling this multiple time on the same canvas does return the same context\n * @param canvas A canvas element or offscreen canvas\n */\nexport function createBrowserContext(\n canvas: HTMLCanvasElement | OffscreenCanvas,\n props: ContextProps\n): WebGLRenderingContext {\n props = {...DEFAULT_CONTEXT_PROPS, ...props};\n\n // Try to extract any extra information about why context creation failed\n let errorMessage = null;\n const onCreateError = error => (errorMessage = error.statusMessage || errorMessage);\n canvas.addEventListener('webglcontextcreationerror', onCreateError, false);\n\n // Create the desired context\n let gl: WebGLRenderingContext | WebGL2RenderingContext | null = null;\n\n if (props.type === 'webgl2') {\n props = {...props, webgl1: false};\n }\n if (props.type === 'webgl1') {\n props = {...props, webgl2: false};\n }\n\n // props.failIfMajorPerformanceCaveat = true;\n\n // Prefer webgl2 over webgl1 if both are acceptable\n if (!gl && props.webgl2) {\n gl = canvas.getContext('webgl2', props) as WebGL2RenderingContext;\n }\n if (!gl && props.webgl1) {\n gl = canvas.getContext('webgl', props) as WebGLRenderingContext;\n }\n\n // Software GPU\n\n // props.failIfMajorPerformanceCaveat = false;\n // if (!gl && props.webgl2) {\n // gl = canvas.getContext('webgl2', props);\n // }\n // if (!gl && props.webgl1) {\n // gl = canvas.getContext('webgl', props);\n // }\n\n // TODO are we removing this listener before giving it a chance to fire?\n canvas.removeEventListener('webglcontextcreationerror', onCreateError, false);\n\n if (!gl) {\n throw new Error(\n `Failed to create ${props.webgl2 && !props.webgl1 ? 'WebGL2' : 'WebGL'} context: ${\n errorMessage || 'Unknown error'\n }`\n );\n }\n\n if (props.onContextLost) {\n // Carefully extract and wrap callbacks to prevent addEventListener from rebinding them.\n const {onContextLost} = props;\n canvas.addEventListener('webglcontextlost', (event: Event) => onContextLost(event), false);\n }\n if (props.onContextRestored) {\n // Carefully extract and wrap callbacks to prevent addEventListener from rebinding them.\n const {onContextRestored} = props;\n canvas.addEventListener(\n 'webglcontextrestored',\n (event: Event) => onContextRestored(event),\n false\n );\n }\n\n return gl;\n}\n\n/* TODO - can we call this asynchronously to catch the error events?\nexport async function createBrowserContextAsync(canvas: HTMLCanvasElement | OffscreenCanvas, props: ContextProps): Promise<WebGLRenderingContext> {\n props = {...DEFAULT_CONTEXT_PROPS, ...props};\n\n // Try to extract any extra information about why context creation failed\n let errorMessage = null;\n const onCreateError = (error) => (errorMessage = error.statusMessage || errorMessage);\n canvas.addEventListener('webglcontextcreationerror', onCreateError, false);\n\n const gl = createBrowserContext(canvas, props);\n\n // Give the listener a chance to fire\n await new Promise(resolve => setTimeout(resolve, 0));\n\n canvas.removeEventListener('webglcontextcreationerror', onCreateError, false);\n\n return gl;\n}\n*/\n"],"mappings":"AAoCA,MAAMA,qBAAmC,GAAG;EAC1CC,MAAM,EAAE,IAAI;EACZC,MAAM,EAAE,IAAI;EACZC,eAAe,EAAE,kBAAkB;EAEnCC,aAAa,EAAEA,CAAA,KAAMC,OAAO,CAACC,KAAK,CAAC,oBAAoB,CAAC;EAExDC,iBAAiB,EAAEA,CAAA,KAAMF,OAAO,CAACG,IAAI,CAAC,wBAAwB;AAChE,CAAC;AAOD,OAAO,SAASC,oBAAoBA,CAClCC,MAA2C,EAC3CC,KAAmB,EACI;EACvBA,KAAK,GAAG;IAAC,GAAGX,qBAAqB;IAAE,GAAGW;EAAK,CAAC;EAG5C,IAAIC,YAAY,GAAG,IAAI;EACvB,MAAMC,aAAa,GAAGP,KAAK,IAAKM,YAAY,GAAGN,KAAK,CAACQ,aAAa,IAAIF,YAAa;EACnFF,MAAM,CAACK,gBAAgB,CAAC,2BAA2B,EAAEF,aAAa,EAAE,KAAK,CAAC;EAG1E,IAAIG,EAAyD,GAAG,IAAI;EAEpE,IAAIL,KAAK,CAACM,IAAI,KAAK,QAAQ,EAAE;IAC3BN,KAAK,GAAG;MAAC,GAAGA,KAAK;MAAET,MAAM,EAAE;IAAK,CAAC;EACnC;EACA,IAAIS,KAAK,CAACM,IAAI,KAAK,QAAQ,EAAE;IAC3BN,KAAK,GAAG;MAAC,GAAGA,KAAK;MAAEV,MAAM,EAAE;IAAK,CAAC;EACnC;EAKA,IAAI,CAACe,EAAE,IAAIL,KAAK,CAACV,MAAM,EAAE;IACvBe,EAAE,GAAGN,MAAM,CAACQ,UAAU,CAAC,QAAQ,EAAEP,KAAK,CAA2B;EACnE;EACA,IAAI,CAACK,EAAE,IAAIL,KAAK,CAACT,MAAM,EAAE;IACvBc,EAAE,GAAGN,MAAM,CAACQ,UAAU,CAAC,OAAO,EAAEP,KAAK,CAA0B;EACjE;EAaAD,MAAM,CAACS,mBAAmB,CAAC,2BAA2B,EAAEN,aAAa,EAAE,KAAK,CAAC;EAE7E,IAAI,CAACG,EAAE,EAAE;IACP,MAAM,IAAII,KAAK,CACZ,oBAAmBT,KAAK,CAACV,MAAM,IAAI,CAACU,KAAK,CAACT,MAAM,GAAG,QAAQ,GAAG,OAAQ,aACrEU,YAAY,IAAI,eACjB,EACH,CAAC;EACH;EAEA,IAAID,KAAK,CAACP,aAAa,EAAE;IAEvB,MAAM;MAACA;IAAa,CAAC,GAAGO,KAAK;IAC7BD,MAAM,CAACK,gBAAgB,CAAC,kBAAkB,EAAGM,KAAY,IAAKjB,aAAa,CAACiB,KAAK,CAAC,EAAE,KAAK,CAAC;EAC5F;EACA,IAAIV,KAAK,CAACJ,iBAAiB,EAAE;IAE3B,MAAM;MAACA;IAAiB,CAAC,GAAGI,KAAK;IACjCD,MAAM,CAACK,gBAAgB,CACrB,sBAAsB,EACrBM,KAAY,IAAKd,iBAAiB,CAACc,KAAK,CAAC,EAC1C,KACF,CAAC;EACH;EAEA,OAAOL,EAAE;AACX"}
@@ -1,5 +1,5 @@
1
1
  /** Duck typing for the main headless gl export, a function to create contexts */
2
- export declare type HeadlessGL = (width: number, height: number, options: Record<string, unknown>) => WebGLRenderingContext;
2
+ export type HeadlessGL = (width: number, height: number, options: Record<string, unknown>) => WebGLRenderingContext;
3
3
  /** By importing `gl` and registering it with this function, contexts can be created under Node.js */
4
4
  export declare function registerHeadlessGL(headlessgl: HeadlessGL): void;
5
5
  /** @returns true if headless gl is registered */
@@ -1 +1 @@
1
- {"version":3,"file":"create-headless-context.d.ts","sourceRoot":"","sources":["../../../src/context/context/create-headless-context.ts"],"names":[],"mappings":"AAeA,iFAAiF;AACjF,oBAAY,UAAU,GAAG,CAAC,KAAK,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,KAAK,qBAAqB,CAAC;AAIpH,qGAAqG;AACrG,wBAAgB,kBAAkB,CAAC,UAAU,EAAE,UAAU,QAExD;AAED,iDAAiD;AACjD,wBAAgB,sBAAsB,IAAI,OAAO,CAEhD;AAED,6DAA6D;AAC7D,wBAAgB,qBAAqB,CAAC,OAAO,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,GAAG,qBAAqB,CAgB1F"}
1
+ {"version":3,"file":"create-headless-context.d.ts","sourceRoot":"","sources":["../../../src/context/context/create-headless-context.ts"],"names":[],"mappings":"AAkBA,iFAAiF;AACjF,MAAM,MAAM,UAAU,GAAG,CAAC,KAAK,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,KAAK,qBAAqB,CAAC;AAIpH,qGAAqG;AACrG,wBAAgB,kBAAkB,CAAC,UAAU,EAAE,UAAU,QAExD;AAED,iDAAiD;AACjD,wBAAgB,sBAAsB,IAAI,OAAO,CAEhD;AAED,6DAA6D;AAC7D,wBAAgB,qBAAqB,CAAC,OAAO,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,GAAG,qBAAqB,CAgB1F"}
@@ -1,5 +1,8 @@
1
1
  const ERR_HEADLESSGL_FAILED = 'Failed to create WebGL context in Node.js, headless gl returned null';
2
- const ERR_HEADLESSGL_LOAD = " luma.gl: loaded under Node.js without headless gl installed, meaning that WebGL contexts can not be created. This may not be an error. For example, this is a typical configuration for isorender applications running on the server.";
2
+ const ERR_HEADLESSGL_LOAD = '\
3
+ luma.gl: loaded under Node.js without headless gl installed, meaning that WebGL \
4
+ contexts can not be created. This may not be an error. For example, this is a \
5
+ typical configuration for isorender applications running on the server.';
3
6
  const CONTEXT_DEFAULTS = {
4
7
  width: 1,
5
8
  height: 1,
@@ -14,7 +17,8 @@ export function isHeadlessGLRegistered() {
14
17
  return headlessGL !== null;
15
18
  }
16
19
  export function createHeadlessContext(options) {
17
- options = { ...CONTEXT_DEFAULTS,
20
+ options = {
21
+ ...CONTEXT_DEFAULTS,
18
22
  ...options
19
23
  };
20
24
  const {
@@ -23,21 +27,16 @@ export function createHeadlessContext(options) {
23
27
  webgl1,
24
28
  webgl2
25
29
  } = options;
26
-
27
30
  if (webgl2 && !webgl1) {
28
31
  throw new Error('headless-gl does not support WebGL2');
29
32
  }
30
-
31
33
  if (!headlessGL) {
32
34
  throw new Error(ERR_HEADLESSGL_LOAD);
33
35
  }
34
-
35
36
  const gl = headlessGL(width, height, options);
36
-
37
37
  if (!gl) {
38
38
  throw new Error(ERR_HEADLESSGL_FAILED);
39
39
  }
40
-
41
40
  return gl;
42
41
  }
43
42
  //# sourceMappingURL=create-headless-context.js.map
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../src/context/context/create-headless-context.ts"],"names":["ERR_HEADLESSGL_FAILED","ERR_HEADLESSGL_LOAD","CONTEXT_DEFAULTS","width","height","debug","throwOnError","headlessGL","registerHeadlessGL","headlessgl","isHeadlessGLRegistered","createHeadlessContext","options","webgl1","webgl2","Error","gl"],"mappings":"AAAA,MAAMA,qBAAqB,GACzB,sEADF;AAGA,MAAMC,mBAAmB,gPAAzB;AAKA,MAAMC,gBAAgB,GAAG;AACvBC,EAAAA,KAAK,EAAE,CADgB;AAEvBC,EAAAA,MAAM,EAAE,CAFe;AAGvBC,EAAAA,KAAK,EAAE,IAHgB;AAIvBC,EAAAA,YAAY,EAAE;AAJS,CAAzB;AAUA,IAAIC,UAA6B,GAAG,IAApC;AAGA,OAAO,SAASC,kBAAT,CAA4BC,UAA5B,EAAoD;AACzDF,EAAAA,UAAU,GAAGE,UAAb;AACD;AAGD,OAAO,SAASC,sBAAT,GAA2C;AAChD,SAAOH,UAAU,KAAK,IAAtB;AACD;AAGD,OAAO,SAASI,qBAAT,CAA+BC,OAA/B,EAAqF;AAC1FA,EAAAA,OAAO,GAAG,EAAC,GAAGV,gBAAJ;AAAsB,OAAGU;AAAzB,GAAV;AAEA,QAAM;AAACT,IAAAA,KAAD;AAAQC,IAAAA,MAAR;AAAgBS,IAAAA,MAAhB;AAAwBC,IAAAA;AAAxB,MAAkCF,OAAxC;;AAEA,MAAIE,MAAM,IAAI,CAACD,MAAf,EAAuB;AACrB,UAAM,IAAIE,KAAJ,CAAU,qCAAV,CAAN;AACD;;AACD,MAAI,CAACR,UAAL,EAAiB;AACf,UAAM,IAAIQ,KAAJ,CAAUd,mBAAV,CAAN;AACD;;AACD,QAAMe,EAAE,GAAGT,UAAU,CAACJ,KAAD,EAAQC,MAAR,EAAgBQ,OAAhB,CAArB;;AACA,MAAI,CAACI,EAAL,EAAS;AACP,UAAM,IAAID,KAAJ,CAAUf,qBAAV,CAAN;AACD;;AACD,SAAOgB,EAAP;AACD","sourcesContent":["const ERR_HEADLESSGL_FAILED =\n 'Failed to create WebGL context in Node.js, headless gl returned null';\n\nconst ERR_HEADLESSGL_LOAD = `\\\n luma.gl: loaded under Node.js without headless gl installed, meaning that WebGL \\\n contexts can not be created. This may not be an error. For example, this is a \\\n typical configuration for isorender applications running on the server.`;\n\nconst CONTEXT_DEFAULTS = {\n width: 1,\n height: 1,\n debug: true,\n throwOnError: false\n};\n\n/** Duck typing for the main headless gl export, a function to create contexts */\nexport type HeadlessGL = (width: number, height: number, options: Record<string, unknown>) => WebGLRenderingContext;\n\nlet headlessGL: HeadlessGL | null = null; \n\n/** By importing `gl` and registering it with this function, contexts can be created under Node.js */\nexport function registerHeadlessGL(headlessgl: HeadlessGL) {\n headlessGL = headlessgl;\n}\n\n/** @returns true if headless gl is registered */\nexport function isHeadlessGLRegistered(): boolean {\n return headlessGL !== null;\n}\n\n/** Create headless gl context (for running under Node.js) */\nexport function createHeadlessContext(options?: Record<string, any>): WebGLRenderingContext {\n options = {...CONTEXT_DEFAULTS, ...options};\n\n const {width, height, webgl1, webgl2} = options;\n\n if (webgl2 && !webgl1) {\n throw new Error('headless-gl does not support WebGL2');\n }\n if (!headlessGL) {\n throw new Error(ERR_HEADLESSGL_LOAD);\n }\n const gl = headlessGL(width, height, options);\n if (!gl) {\n throw new Error(ERR_HEADLESSGL_FAILED);\n }\n return gl;\n}\n"],"file":"create-headless-context.js"}
1
+ {"version":3,"file":"create-headless-context.js","names":["ERR_HEADLESSGL_FAILED","ERR_HEADLESSGL_LOAD","CONTEXT_DEFAULTS","width","height","debug","throwOnError","headlessGL","registerHeadlessGL","headlessgl","isHeadlessGLRegistered","createHeadlessContext","options","webgl1","webgl2","Error","gl"],"sources":["../../../src/context/context/create-headless-context.ts"],"sourcesContent":["// luma.gl, MIT license\n// Copyright (c) vis.gl contributors\n\nconst ERR_HEADLESSGL_FAILED =\n 'Failed to create WebGL context in Node.js, headless gl returned null';\n\nconst ERR_HEADLESSGL_LOAD = '\\\n luma.gl: loaded under Node.js without headless gl installed, meaning that WebGL \\\n contexts can not be created. This may not be an error. For example, this is a \\\n typical configuration for isorender applications running on the server.';\n\nconst CONTEXT_DEFAULTS = {\n width: 1,\n height: 1,\n debug: true,\n throwOnError: false\n};\n\n/** Duck typing for the main headless gl export, a function to create contexts */\nexport type HeadlessGL = (width: number, height: number, options: Record<string, unknown>) => WebGLRenderingContext;\n\nlet headlessGL: HeadlessGL | null = null; \n\n/** By importing `gl` and registering it with this function, contexts can be created under Node.js */\nexport function registerHeadlessGL(headlessgl: HeadlessGL) {\n headlessGL = headlessgl;\n}\n\n/** @returns true if headless gl is registered */\nexport function isHeadlessGLRegistered(): boolean {\n return headlessGL !== null;\n}\n\n/** Create headless gl context (for running under Node.js) */\nexport function createHeadlessContext(options?: Record<string, any>): WebGLRenderingContext {\n options = {...CONTEXT_DEFAULTS, ...options};\n\n const {width, height, webgl1, webgl2} = options;\n\n if (webgl2 && !webgl1) {\n throw new Error('headless-gl does not support WebGL2');\n }\n if (!headlessGL) {\n throw new Error(ERR_HEADLESSGL_LOAD);\n }\n const gl = headlessGL(width, height, options);\n if (!gl) {\n throw new Error(ERR_HEADLESSGL_FAILED);\n }\n return gl;\n}\n"],"mappings":"AAGA,MAAMA,qBAAqB,GACzB,sEAAsE;AAExE,MAAMC,mBAAmB,GAAG;AAC5B;AACA;AACA,0EAA0E;AAE1E,MAAMC,gBAAgB,GAAG;EACvBC,KAAK,EAAE,CAAC;EACRC,MAAM,EAAE,CAAC;EACTC,KAAK,EAAE,IAAI;EACXC,YAAY,EAAE;AAChB,CAAC;AAKD,IAAIC,UAA6B,GAAG,IAAI;AAGxC,OAAO,SAASC,kBAAkBA,CAACC,UAAsB,EAAE;EACzDF,UAAU,GAAGE,UAAU;AACzB;AAGA,OAAO,SAASC,sBAAsBA,CAAA,EAAY;EAChD,OAAOH,UAAU,KAAK,IAAI;AAC5B;AAGA,OAAO,SAASI,qBAAqBA,CAACC,OAA6B,EAAyB;EAC1FA,OAAO,GAAG;IAAC,GAAGV,gBAAgB;IAAE,GAAGU;EAAO,CAAC;EAE3C,MAAM;IAACT,KAAK;IAAEC,MAAM;IAAES,MAAM;IAAEC;EAAM,CAAC,GAAGF,OAAO;EAE/C,IAAIE,MAAM,IAAI,CAACD,MAAM,EAAE;IACrB,MAAM,IAAIE,KAAK,CAAC,qCAAqC,CAAC;EACxD;EACA,IAAI,CAACR,UAAU,EAAE;IACf,MAAM,IAAIQ,KAAK,CAACd,mBAAmB,CAAC;EACtC;EACA,MAAMe,EAAE,GAAGT,UAAU,CAACJ,KAAK,EAAEC,MAAM,EAAEQ,OAAO,CAAC;EAC7C,IAAI,CAACI,EAAE,EAAE;IACP,MAAM,IAAID,KAAK,CAACf,qBAAqB,CAAC;EACxC;EACA,OAAOgB,EAAE;AACX"}
@@ -1 +1 @@
1
- {"version":3,"file":"webgl-checks.d.ts","sourceRoot":"","sources":["../../../src/context/context/webgl-checks.ts"],"names":[],"mappings":"AAIA,eAAO,MAAM,SAAS,kCAAc,CAAC;AACrC,eAAO,MAAM,UAAU,oBAAoB,CAAC;AAG5C,6DAA6D;AAC7D,wBAAgB,OAAO,CAAC,EAAE,EAAE,GAAG,GAAG,OAAO,CASxC;AAGD,8DAA8D;AAC9D,wBAAgB,QAAQ,CAAC,EAAE,EAAE,GAAG,GAAG,OAAO,CAMzC;AAGD,qFAAqF;AACrF,wBAAgB,gBAAgB,CAAC,EAAE,EAAE,qBAAqB,GAAG,sBAAsB,GAAG,IAAI,CAGzF;AAGD,wGAAwG;AACxG,wBAAgB,kBAAkB,CAAC,EAAE,EAAE,GAAG,GAAG,qBAAqB,CAGjE;AAED,yGAAyG;AACzG,wBAAgB,mBAAmB,CAAC,EAAE,EAAE,GAAG,GAAG,sBAAsB,CAGnE"}
1
+ {"version":3,"file":"webgl-checks.d.ts","sourceRoot":"","sources":["../../../src/context/context/webgl-checks.ts"],"names":[],"mappings":"AAMA,eAAO,MAAM,SAAS,kCAAc,CAAC;AACrC,eAAO,MAAM,UAAU,oBAAoB,CAAC;AAG5C,6DAA6D;AAC7D,wBAAgB,OAAO,CAAC,EAAE,EAAE,GAAG,GAAG,OAAO,CASxC;AAGD,8DAA8D;AAC9D,wBAAgB,QAAQ,CAAC,EAAE,EAAE,GAAG,GAAG,OAAO,CAMzC;AAGD,qFAAqF;AACrF,wBAAgB,gBAAgB,CAAC,EAAE,EAAE,qBAAqB,GAAG,sBAAsB,GAAG,IAAI,CAGzF;AAGD,wGAAwG;AACxG,wBAAgB,kBAAkB,CAAC,EAAE,EAAE,GAAG,GAAG,qBAAqB,CAGjE;AAED,yGAAyG;AACzG,wBAAgB,mBAAmB,CAAC,EAAE,EAAE,GAAG,GAAG,sBAAsB,CAGnE"}
@@ -1,4 +1,4 @@
1
- import { assert } from '@luma.gl/api';
1
+ import { assert } from '@luma.gl/core';
2
2
  const ERR_CONTEXT = 'Invalid WebGLRenderingContext';
3
3
  export const ERR_WEBGL = ERR_CONTEXT;
4
4
  export const ERR_WEBGL2 = 'Requires WebGL2';
@@ -6,18 +6,15 @@ export function isWebGL(gl) {
6
6
  if (typeof WebGLRenderingContext !== 'undefined' && gl instanceof WebGLRenderingContext) {
7
7
  return true;
8
8
  }
9
-
10
9
  if (typeof WebGL2RenderingContext !== 'undefined' && gl instanceof WebGL2RenderingContext) {
11
10
  return true;
12
11
  }
13
-
14
12
  return Boolean(gl && Number.isFinite(gl._version));
15
13
  }
16
14
  export function isWebGL2(gl) {
17
15
  if (typeof WebGL2RenderingContext !== 'undefined' && gl instanceof WebGL2RenderingContext) {
18
16
  return true;
19
17
  }
20
-
21
18
  return Boolean(gl && gl._version === 2);
22
19
  }
23
20
  export function getWebGL2Context(gl) {
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../src/context/context/webgl-checks.ts"],"names":["assert","ERR_CONTEXT","ERR_WEBGL","ERR_WEBGL2","isWebGL","gl","WebGLRenderingContext","WebGL2RenderingContext","Boolean","Number","isFinite","_version","isWebGL2","getWebGL2Context","assertWebGLContext","assertWebGL2Context"],"mappings":"AACA,SAAQA,MAAR,QAAqB,cAArB;AAEA,MAAMC,WAAW,GAAG,+BAApB;AACA,OAAO,MAAMC,SAAS,GAAGD,WAAlB;AACP,OAAO,MAAME,UAAU,GAAG,iBAAnB;AAIP,OAAO,SAASC,OAAT,CAAiBC,EAAjB,EAAmC;AACxC,MAAI,OAAOC,qBAAP,KAAiC,WAAjC,IAAgDD,EAAE,YAAYC,qBAAlE,EAAyF;AACvF,WAAO,IAAP;AACD;;AACD,MAAI,OAAOC,sBAAP,KAAkC,WAAlC,IAAiDF,EAAE,YAAYE,sBAAnE,EAA2F;AACzF,WAAO,IAAP;AACD;;AAED,SAAOC,OAAO,CAACH,EAAE,IAAII,MAAM,CAACC,QAAP,CAAgBL,EAAE,CAACM,QAAnB,CAAP,CAAd;AACD;AAID,OAAO,SAASC,QAAT,CAAkBP,EAAlB,EAAoC;AACzC,MAAI,OAAOE,sBAAP,KAAkC,WAAlC,IAAiDF,EAAE,YAAYE,sBAAnE,EAA2F;AACzF,WAAO,IAAP;AACD;;AAED,SAAOC,OAAO,CAACH,EAAE,IAAIA,EAAE,CAACM,QAAH,KAAgB,CAAvB,CAAd;AACD;AAID,OAAO,SAASE,gBAAT,CAA0BR,EAA1B,EAAoF;AAEzF,SAAOO,QAAQ,CAACP,EAAD,CAAR,GAAeA,EAAf,GAAoB,IAA3B;AACD;AAID,OAAO,SAASS,kBAAT,CAA4BT,EAA5B,EAA4D;AACjEL,EAAAA,MAAM,CAACI,OAAO,CAACC,EAAD,CAAR,EAAcJ,WAAd,CAAN;AACA,SAAOI,EAAP;AACD;AAGD,OAAO,SAASU,mBAAT,CAA6BV,EAA7B,EAA8D;AACnEL,EAAAA,MAAM,CAACY,QAAQ,CAACP,EAAD,CAAT,EAAeF,UAAf,CAAN;AACA,SAAOE,EAAP;AACD","sourcesContent":["// luma.gl, MIT license\nimport {assert} from '@luma.gl/api';\n\nconst ERR_CONTEXT = 'Invalid WebGLRenderingContext';\nexport const ERR_WEBGL = ERR_CONTEXT;\nexport const ERR_WEBGL2 = 'Requires WebGL2';\n\n\n/** Check if supplied parameter is a WebGLRenderingContext */\nexport function isWebGL(gl: any): boolean {\n if (typeof WebGLRenderingContext !== 'undefined' && gl instanceof WebGLRenderingContext) {\n return true;\n }\n if (typeof WebGL2RenderingContext !== 'undefined' && gl instanceof WebGL2RenderingContext) {\n return true;\n }\n // Look for debug contexts, headless gl etc\n return Boolean(gl && Number.isFinite(gl._version));\n}\n\n\n/** Check if supplied parameter is a WebGL2RenderingContext */\nexport function isWebGL2(gl: any): boolean {\n if (typeof WebGL2RenderingContext !== 'undefined' && gl instanceof WebGL2RenderingContext) {\n return true;\n }\n // Look for debug contexts, headless gl etc\n return Boolean(gl && gl._version === 2);\n}\n\n\n/** Returns a properly typed WebGL2RenderingContext from a WebGL1 context, or null */\nexport function getWebGL2Context(gl: WebGLRenderingContext): WebGL2RenderingContext | null {\n // @ts-expect-error\n return isWebGL2(gl) ? gl : null;\n}\n\n\n/** Throw if supplied parameter is not a WebGLRenderingContext, otherwise return properly typed value */\nexport function assertWebGLContext(gl: any): WebGLRenderingContext {\n assert(isWebGL(gl), ERR_CONTEXT);\n return gl;\n}\n\n/** Throw if supplied parameter is not a WebGL2RenderingContext, otherwise return properly typed value */\nexport function assertWebGL2Context(gl: any): WebGL2RenderingContext {\n assert(isWebGL2(gl), ERR_WEBGL2);\n return gl;\n}\n"],"file":"webgl-checks.js"}
1
+ {"version":3,"file":"webgl-checks.js","names":["assert","ERR_CONTEXT","ERR_WEBGL","ERR_WEBGL2","isWebGL","gl","WebGLRenderingContext","WebGL2RenderingContext","Boolean","Number","isFinite","_version","isWebGL2","getWebGL2Context","assertWebGLContext","assertWebGL2Context"],"sources":["../../../src/context/context/webgl-checks.ts"],"sourcesContent":["// luma.gl, MIT license\n// Copyright (c) vis.gl contributors\n\nimport {assert} from '@luma.gl/core';\n\nconst ERR_CONTEXT = 'Invalid WebGLRenderingContext';\nexport const ERR_WEBGL = ERR_CONTEXT;\nexport const ERR_WEBGL2 = 'Requires WebGL2';\n\n\n/** Check if supplied parameter is a WebGLRenderingContext */\nexport function isWebGL(gl: any): boolean {\n if (typeof WebGLRenderingContext !== 'undefined' && gl instanceof WebGLRenderingContext) {\n return true;\n }\n if (typeof WebGL2RenderingContext !== 'undefined' && gl instanceof WebGL2RenderingContext) {\n return true;\n }\n // Look for debug contexts, headless gl etc\n return Boolean(gl && Number.isFinite(gl._version));\n}\n\n\n/** Check if supplied parameter is a WebGL2RenderingContext */\nexport function isWebGL2(gl: any): boolean {\n if (typeof WebGL2RenderingContext !== 'undefined' && gl instanceof WebGL2RenderingContext) {\n return true;\n }\n // Look for debug contexts, headless gl etc\n return Boolean(gl && gl._version === 2);\n}\n\n\n/** Returns a properly typed WebGL2RenderingContext from a WebGL1 context, or null */\nexport function getWebGL2Context(gl: WebGLRenderingContext): WebGL2RenderingContext | null {\n // @ts-expect-error\n return isWebGL2(gl) ? gl : null;\n}\n\n\n/** Throw if supplied parameter is not a WebGLRenderingContext, otherwise return properly typed value */\nexport function assertWebGLContext(gl: any): WebGLRenderingContext {\n assert(isWebGL(gl), ERR_CONTEXT);\n return gl;\n}\n\n/** Throw if supplied parameter is not a WebGL2RenderingContext, otherwise return properly typed value */\nexport function assertWebGL2Context(gl: any): WebGL2RenderingContext {\n assert(isWebGL2(gl), ERR_WEBGL2);\n return gl;\n}\n"],"mappings":"AAGA,SAAQA,MAAM,QAAO,eAAe;AAEpC,MAAMC,WAAW,GAAG,+BAA+B;AACnD,OAAO,MAAMC,SAAS,GAAGD,WAAW;AACpC,OAAO,MAAME,UAAU,GAAG,iBAAiB;AAI3C,OAAO,SAASC,OAAOA,CAACC,EAAO,EAAW;EACxC,IAAI,OAAOC,qBAAqB,KAAK,WAAW,IAAID,EAAE,YAAYC,qBAAqB,EAAE;IACvF,OAAO,IAAI;EACb;EACA,IAAI,OAAOC,sBAAsB,KAAK,WAAW,IAAIF,EAAE,YAAYE,sBAAsB,EAAE;IACzF,OAAO,IAAI;EACb;EAEA,OAAOC,OAAO,CAACH,EAAE,IAAII,MAAM,CAACC,QAAQ,CAACL,EAAE,CAACM,QAAQ,CAAC,CAAC;AACpD;AAIA,OAAO,SAASC,QAAQA,CAACP,EAAO,EAAW;EACzC,IAAI,OAAOE,sBAAsB,KAAK,WAAW,IAAIF,EAAE,YAAYE,sBAAsB,EAAE;IACzF,OAAO,IAAI;EACb;EAEA,OAAOC,OAAO,CAACH,EAAE,IAAIA,EAAE,CAACM,QAAQ,KAAK,CAAC,CAAC;AACzC;AAIA,OAAO,SAASE,gBAAgBA,CAACR,EAAyB,EAAiC;EAEzF,OAAOO,QAAQ,CAACP,EAAE,CAAC,GAAGA,EAAE,GAAG,IAAI;AACjC;AAIA,OAAO,SAASS,kBAAkBA,CAACT,EAAO,EAAyB;EACjEL,MAAM,CAACI,OAAO,CAACC,EAAE,CAAC,EAAEJ,WAAW,CAAC;EAChC,OAAOI,EAAE;AACX;AAGA,OAAO,SAASU,mBAAmBA,CAACV,EAAO,EAA0B;EACnEL,MAAM,CAACY,QAAQ,CAACP,EAAE,CAAC,EAAEF,UAAU,CAAC;EAChC,OAAOE,EAAE;AACX"}
@@ -1,6 +1,5 @@
1
- /// <reference types="offscreencanvas" />
2
1
  /** Spector debug initialization options */
3
- declare type SpectorProps = {
2
+ type SpectorProps = {
4
3
  /** Canvas to monitor */
5
4
  canvas?: HTMLCanvasElement | OffscreenCanvas;
6
5
  /** Whether debug is enabled. Auto-detected if ommitted */
@@ -1 +1 @@
1
- {"version":3,"file":"spector.d.ts","sourceRoot":"","sources":["../../../src/context/debug/spector.ts"],"names":[],"mappings":";AAGA,2CAA2C;AAC3C,aAAK,YAAY,GAAG;IAClB,wBAAwB;IACxB,MAAM,CAAC,EAAE,iBAAiB,GAAG,eAAe,CAAC;IAC7C,0DAA0D;IAC1D,KAAK,CAAC,EAAE,OAAO,CAAC;IAChB,kCAAkC;IAClC,OAAO,CAAC,EAAE,OAAO,GAAG,MAAM,GAAG,MAAM,CAAC;CACrC,CAAC;AAaF,OAAO,CAAC,MAAM,CAAC;IACb,IAAI,OAAO,EAAE,GAAG,CAAC;CAClB;AAED,sDAAsD;AACtD,wBAAsB,aAAa,CAAC,KAAK,CAAC,EAAE,YAAY,iBAQvD;AAED,wBAAgB,mBAAmB,CAAC,KAAK,CAAC,EAAE,YAAY,OAoDvD"}
1
+ {"version":3,"file":"spector.d.ts","sourceRoot":"","sources":["../../../src/context/debug/spector.ts"],"names":[],"mappings":"AAKA,2CAA2C;AAC3C,KAAK,YAAY,GAAG;IAClB,wBAAwB;IACxB,MAAM,CAAC,EAAE,iBAAiB,GAAG,eAAe,CAAC;IAC7C,0DAA0D;IAC1D,KAAK,CAAC,EAAE,OAAO,CAAC;IAChB,kCAAkC;IAClC,OAAO,CAAC,EAAE,OAAO,GAAG,MAAM,GAAG,MAAM,CAAC;CACrC,CAAC;AAaF,OAAO,CAAC,MAAM,CAAC;IAEb,IAAI,OAAO,EAAE,GAAG,CAAC;CAClB;AAED,sDAAsD;AACtD,wBAAsB,aAAa,CAAC,KAAK,CAAC,EAAE,YAAY,iBAQvD;AAED,wBAAgB,mBAAmB,CAAC,KAAK,CAAC,EAAE,YAAY,OAoDvD"}
@@ -1,4 +1,4 @@
1
- import { log, loadScript } from '@luma.gl/api';
1
+ import { log, loadScript } from '@luma.gl/core';
2
2
  const DEFAULT_SPECTOR_PROPS = {
3
3
  spector: log.get('spector') || log.get('inspect')
4
4
  };
@@ -17,60 +17,48 @@ export async function loadSpectorJS(props) {
17
17
  }
18
18
  export function initializeSpectorJS(props) {
19
19
  var _props, _props2;
20
-
21
- props = { ...DEFAULT_SPECTOR_PROPS,
20
+ props = {
21
+ ...DEFAULT_SPECTOR_PROPS,
22
22
  ...props
23
23
  };
24
-
25
24
  if (!((_props = props) !== null && _props !== void 0 && _props.spector)) {
26
25
  return null;
27
26
  }
28
-
29
27
  if (!spector && globalThis.SPECTOR) {
30
- log.probe(LOG_LEVEL, "SPECTOR found and initialized")();
28
+ log.probe(LOG_LEVEL, 'SPECTOR found and initialized')();
31
29
  spector = new globalThis.SPECTOR.Spector();
32
-
33
30
  if (globalThis.luma) {
34
31
  globalThis.luma.spector = spector;
35
32
  }
36
33
  }
37
-
38
34
  if (!spector) {
39
35
  return null;
40
36
  }
41
-
42
37
  if (!initialized) {
43
38
  var _spector, _spector2;
44
-
45
39
  initialized = true;
46
40
  spector.spyCanvases();
47
- (_spector = spector) === null || _spector === void 0 ? void 0 : _spector.onCaptureStarted.add(capture => log.info("Spector capture started:", capture)());
41
+ (_spector = spector) === null || _spector === void 0 ? void 0 : _spector.onCaptureStarted.add(capture => log.info('Spector capture started:', capture)());
48
42
  (_spector2 = spector) === null || _spector2 === void 0 ? void 0 : _spector2.onCapture.add(capture => {
49
43
  var _spector3, _spector4, _spector5;
50
-
51
- log.info("Spector capture complete:", capture)();
44
+ log.info('Spector capture complete:', capture)();
52
45
  (_spector3 = spector) === null || _spector3 === void 0 ? void 0 : _spector3.getResultUI();
53
46
  (_spector4 = spector) === null || _spector4 === void 0 ? void 0 : _spector4.resultView.display();
54
47
  (_spector5 = spector) === null || _spector5 === void 0 ? void 0 : _spector5.resultView.addCapture(capture);
55
48
  });
56
49
  }
57
-
58
50
  if ((_props2 = props) !== null && _props2 !== void 0 && _props2.canvas) {
59
51
  var _spector6, _props3;
60
-
61
52
  if (typeof props.spector === 'string' && props.spector !== props.canvas.id) {
62
53
  return spector;
63
54
  }
64
-
65
55
  (_spector6 = spector) === null || _spector6 === void 0 ? void 0 : _spector6.startCapture((_props3 = props) === null || _props3 === void 0 ? void 0 : _props3.canvas, 500);
66
56
  new Promise(resolve => setTimeout(resolve, 2000)).then(_ => {
67
57
  var _spector7;
68
-
69
- log.info("Spector capture stopped after 2 seconds")();
58
+ log.info('Spector capture stopped after 2 seconds')();
70
59
  (_spector7 = spector) === null || _spector7 === void 0 ? void 0 : _spector7.stopCapture();
71
60
  });
72
61
  }
73
-
74
62
  return spector;
75
63
  }
76
64
  //# sourceMappingURL=spector.js.map
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../src/context/debug/spector.ts"],"names":["log","loadScript","DEFAULT_SPECTOR_PROPS","spector","get","SPECTOR_CDN_URL","LOG_LEVEL","initialized","loadSpectorJS","props","globalThis","SPECTOR","error","warn","String","initializeSpectorJS","probe","Spector","luma","spyCanvases","onCaptureStarted","add","capture","info","onCapture","getResultUI","resultView","display","addCapture","canvas","id","startCapture","Promise","resolve","setTimeout","then","_","stopCapture"],"mappings":"AACA,SAAQA,GAAR,EAA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A,gBAAAhB,OAAO,UAAP,4CAASiB,gBAAT,CAA0BC,GAA1B,CAA+BC,OAAD,IAAsBtB,GAAG,CAACuB,IAAJ,6BAAqCD,OAArC,GAApD;AACA,iBAAAnB,OAAO,UAAP,8CAASqB,SAAT,CAAmBH,GAAnB,CAAwBC,OAAD,IAAsB;AAAA;;AAC3CtB,MAAAA,GAAG,CAACuB,IAAJ,8BAAsCD,OAAtC;AAGA,mBAAAnB,OAAO,UAAP,8CAASsB,WAAT;AACA,mBAAAtB,OAAO,UAAP,8CAASuB,UAAT,CAAoBC,OAApB;AACA,mBAAAxB,OAAO,UAAP,8CAASuB,UAAT,CAAoBE,UAApB,CAA+BN,OAA/B;AACD,KAPD;AAQD;;AAED,iBAAIb,KAAJ,oCAAI,QAAOoB,MAAX,EAAmB;AAAA;;AAEjB,QAAI,OAAOpB,KAAK,CAACN,OAAb,KAAyB,QAAzB,IAAqCM,KAAK,CAACN,OAAN,KAAkBM,KAAK,CAACoB,MAAN,CAAaC,EAAxE,EAA4E;AAC1E,aAAO3B,OAAP;AACD;;AAID,iBAAAA,OAAO,UAAP,8CAAS4B,YAAT,YAAsBtB,KAAtB,4CAAsB,QAAOoB,MAA7B,EAAqC,GAArC;AACA,QAAIG,OAAJ,CAAYC,OAAO,IAAIC,UAAU,CAACD,OAAD,EAAU,IAAV,CAAjC,EAAkDE,IAAlD,CAAuDC,CAAC,IAAI;AAAA;;AAC1DpC,MAAAA,GAAG,CAACuB,IAAJ;AACA,mBAAApB,OAAO,UAAP,8CAASkC,WAAT;AAED,KAJD;AAKD;;AAED,SAAOlC,OAAP;AACD","sourcesContent":["// luma.gl, MIT license\nimport {log, loadScript} from '@luma.gl/api';\n\n/** Spector debug initialization options */\ntype SpectorProps = {\n /** Canvas to monitor */\n canvas?: HTMLCanvasElement | OffscreenCanvas;\n /** Whether debug is enabled. Auto-detected if ommitted */\n debug?: boolean;\n /** Whether spector is disabled */\n spector?: boolean | string | object;\n};\n\nconst DEFAULT_SPECTOR_PROPS: SpectorProps = {\n spector: log.get('spector') || log.get('inspect')\n};\n\n// https://github.com/BabylonJS/Spector.js#basic-usage\nconst SPECTOR_CDN_URL = 'https://spectorcdn.babylonjs.com/spector.bundle.js';\nconst LOG_LEVEL = 1;\n\nlet spector: any = null;\nlet initialized: boolean = false;\n\ndeclare global {\n var SPECTOR: any;\n}\n\n/** Loads spector from CDN if not already installed */\nexport async function loadSpectorJS(props?: SpectorProps) {\n if (!globalThis.SPECTOR) {\n try {\n await loadScript(SPECTOR_CDN_URL);\n } catch(error) {\n log.warn(String(error))\n }\n }\n}\n\nexport function initializeSpectorJS(props?: SpectorProps) {\n props = {...DEFAULT_SPECTOR_PROPS, ...props};\n if (!props?.spector) {\n return null;\n }\n\n if (!spector && globalThis.SPECTOR) {\n log.probe(LOG_LEVEL, \"SPECTOR found and initialized\")();\n spector = new globalThis.SPECTOR.Spector();\n if (globalThis.luma) {\n globalThis.luma.spector = spector;\n }\n }\n\n if (!spector) {\n return null;\n }\n\n if (!initialized) {\n initialized = true;\n\n // enables recording some extra information merged in the capture like texture memory sizes and formats\n spector.spyCanvases();\n // A callback when results are ready\n spector?.onCaptureStarted.add((capture: unknown) => log.info(`Spector capture started:`, capture)());\n spector?.onCapture.add((capture: unknown) => {\n log.info(`Spector capture complete:`, capture)();\n // Use undocumented Spector API to open the UI with our capture\n // See https://github.com/BabylonJS/Spector.js/blob/767ad1195a25b85a85c381f400eb50a979239eca/src/spector.ts#L124\n spector?.getResultUI()\n spector?.resultView.display();\n spector?.resultView.addCapture(capture)\n });\n }\n\n if (props?.canvas) {\n // @ts-expect-error If spector is specified as a canvas id, only monitor that canvas\n if (typeof props.spector === 'string' && props.spector !== props.canvas.id) {\n return spector;\n }\n\n // capture startup\n // spector?.captureCanvas(props?.canvas);\n spector?.startCapture(props?.canvas, 500); // 500 commands\n new Promise(resolve => setTimeout(resolve, 2000)).then(_ => {\n log.info(`Spector capture stopped after 2 seconds`)();\n spector?.stopCapture();\n // spector?.displayUI();\n });\n }\n\n return spector;\n}\n"],"file":"spector.js"}
1
+ {"version":3,"file":"spector.js","names":["log","loadScript","DEFAULT_SPECTOR_PROPS","spector","get","SPECTOR_CDN_URL","LOG_LEVEL","initialized","loadSpectorJS","props","globalThis","SPECTOR","error","warn","String","initializeSpectorJS","_props","_props2","probe","Spector","luma","_spector","_spector2","spyCanvases","onCaptureStarted","add","capture","info","onCapture","_spector3","_spector4","_spector5","getResultUI","resultView","display","addCapture","canvas","_spector6","_props3","id","startCapture","Promise","resolve","setTimeout","then","_","_spector7","stopCapture"],"sources":["../../../src/context/debug/spector.ts"],"sourcesContent":["// luma.gl, MIT license\n// Copyright (c) vis.gl contributors\n\nimport {log, loadScript} from '@luma.gl/core';\n\n/** Spector debug initialization options */\ntype SpectorProps = {\n /** Canvas to monitor */\n canvas?: HTMLCanvasElement | OffscreenCanvas;\n /** Whether debug is enabled. Auto-detected if ommitted */\n debug?: boolean;\n /** Whether spector is disabled */\n spector?: boolean | string | object;\n};\n\nconst DEFAULT_SPECTOR_PROPS: SpectorProps = {\n spector: log.get('spector') || log.get('inspect')\n};\n\n// https://github.com/BabylonJS/Spector.js#basic-usage\nconst SPECTOR_CDN_URL = 'https://spectorcdn.babylonjs.com/spector.bundle.js';\nconst LOG_LEVEL = 1;\n\nlet spector: any = null;\nlet initialized: boolean = false;\n\ndeclare global {\n // eslint-disable-next-line no-var\n var SPECTOR: any;\n}\n\n/** Loads spector from CDN if not already installed */\nexport async function loadSpectorJS(props?: SpectorProps) {\n if (!globalThis.SPECTOR) {\n try {\n await loadScript(SPECTOR_CDN_URL);\n } catch(error) {\n log.warn(String(error))\n }\n }\n}\n\nexport function initializeSpectorJS(props?: SpectorProps) {\n props = {...DEFAULT_SPECTOR_PROPS, ...props};\n if (!props?.spector) {\n return null;\n }\n\n if (!spector && globalThis.SPECTOR) {\n log.probe(LOG_LEVEL, 'SPECTOR found and initialized')();\n spector = new globalThis.SPECTOR.Spector();\n if (globalThis.luma) {\n globalThis.luma.spector = spector;\n }\n }\n\n if (!spector) {\n return null;\n }\n\n if (!initialized) {\n initialized = true;\n\n // enables recording some extra information merged in the capture like texture memory sizes and formats\n spector.spyCanvases();\n // A callback when results are ready\n spector?.onCaptureStarted.add((capture: unknown) => log.info('Spector capture started:', capture)());\n spector?.onCapture.add((capture: unknown) => {\n log.info('Spector capture complete:', capture)();\n // Use undocumented Spector API to open the UI with our capture\n // See https://github.com/BabylonJS/Spector.js/blob/767ad1195a25b85a85c381f400eb50a979239eca/src/spector.ts#L124\n spector?.getResultUI()\n spector?.resultView.display();\n spector?.resultView.addCapture(capture)\n });\n }\n\n if (props?.canvas) {\n // @ts-expect-error If spector is specified as a canvas id, only monitor that canvas\n if (typeof props.spector === 'string' && props.spector !== props.canvas.id) {\n return spector;\n }\n\n // capture startup\n // spector?.captureCanvas(props?.canvas);\n spector?.startCapture(props?.canvas, 500); // 500 commands\n new Promise(resolve => setTimeout(resolve, 2000)).then(_ => {\n log.info('Spector capture stopped after 2 seconds')();\n spector?.stopCapture();\n // spector?.displayUI();\n });\n }\n\n return spector;\n}\n"],"mappings":"AAGA,SAAQA,GAAG,EAAEC,UAAU,QAAO,eAAe;AAY7C,MAAMC,qBAAmC,GAAG;EAC1CC,OAAO,EAAEH,GAAG,CAACI,GAAG,CAAC,SAAS,CAAC,IAAIJ,GAAG,CAACI,GAAG,CAAC,SAAS;AAClD,CAAC;AAGD,MAAMC,eAAe,GAAG,oDAAoD;AAC5E,MAAMC,SAAS,GAAG,CAAC;AAEnB,IAAIH,OAAY,GAAG,IAAI;AACvB,IAAII,WAAoB,GAAG,KAAK;AAQhC,OAAO,eAAeC,aAAaA,CAACC,KAAoB,EAAE;EACxD,IAAI,CAACC,UAAU,CAACC,OAAO,EAAE;IACvB,IAAI;MACF,MAAMV,UAAU,CAACI,eAAe,CAAC;IACnC,CAAC,CAAC,OAAMO,KAAK,EAAE;MACbZ,GAAG,CAACa,IAAI,CAACC,MAAM,CAACF,KAAK,CAAC,CAAC;I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,CAAC,CAAC;MACtB,CAAAF,SAAA,GAAA3B,OAAO,cAAA2B,SAAA,uBAAPA,SAAA,CAASG,UAAU,CAACC,OAAO,CAAC,CAAC;MAC7B,CAAAH,SAAA,GAAA5B,OAAO,cAAA4B,SAAA,uBAAPA,SAAA,CAASE,UAAU,CAACE,UAAU,CAACT,OAAO,CAAC;IACzC,CAAC,CAAC;EACJ;EAEA,KAAAT,OAAA,GAAIR,KAAK,cAAAQ,OAAA,eAALA,OAAA,CAAOmB,MAAM,EAAE;IAAA,IAAAC,SAAA,EAAAC,OAAA;IAEjB,IAAI,OAAO7B,KAAK,CAACN,OAAO,KAAK,QAAQ,IAAIM,KAAK,CAACN,OAAO,KAAKM,KAAK,CAAC2B,MAAM,CAACG,EAAE,EAAE;MAC1E,OAAOpC,OAAO;IAChB;IAIA,CAAAkC,SAAA,GAAAlC,OAAO,cAAAkC,SAAA,uBAAPA,SAAA,CAASG,YAAY,EAAAF,OAAA,GAAC7B,KAAK,cAAA6B,OAAA,uBAALA,OAAA,CAAOF,MAAM,EAAE,GAAG,CAAC;IACzC,IAAIK,OAAO,CAACC,OAAO,IAAIC,UAAU,CAACD,OAAO,EAAE,IAAI,CAAC,CAAC,CAACE,IAAI,CAACC,CAAC,IAAI;MAAA,IAAAC,SAAA;MAC1D9C,GAAG,CAAC2B,IAAI,CAAC,yCAAyC,CAAC,CAAC,CAAC;MACrD,CAAAmB,SAAA,GAAA3C,OAAO,cAAA2C,SAAA,uBAAPA,SAAA,CAASC,WAAW,CAAC,CAAC;IAExB,CAAC,CAAC;EACJ;EAEA,OAAO5C,OAAO;AAChB"}
@@ -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":"AAUA,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;AAoBF,OAAO,CAAC,MAAM,CAAC;IAEb,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,63 +1,49 @@
1
- import { log, loadScript } from '@luma.gl/api/';
2
- import GL from '@luma.gl/constants';
1
+ import { log, loadScript } from '@luma.gl/core';
2
+ import { GL as GLEnum } from '@luma.gl/constants';
3
+ import { isBrowser } from '@probe.gl/env';
3
4
  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
-
11
5
  function getContextData(gl) {
12
6
  gl.luma = gl.luma || {};
13
7
  return gl.luma;
14
8
  }
15
-
16
9
  export async function loadWebGLDeveloperTools() {
17
- if (!globalThis.WebGLDebugUtils) {
10
+ if (isBrowser() && !globalThis.WebGLDebugUtils) {
18
11
  globalThis.global = globalThis.global || globalThis;
19
12
  globalThis.global.module = {};
20
13
  await loadScript(WEBGL_DEBUG_CDN_URL);
21
14
  }
22
15
  }
23
- export function makeDebugContext(gl, props = {}) {
16
+ export function makeDebugContext(gl) {
17
+ let props = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
24
18
  if (!gl) {
25
19
  return null;
26
20
  }
27
-
28
21
  return props.debug ? getDebugContext(gl, props) : getRealContext(gl);
29
22
  }
30
-
31
23
  function getRealContext(gl) {
32
24
  const data = getContextData(gl);
33
25
  return data.realContext ? data.realContext : gl;
34
26
  }
35
-
36
27
  function getDebugContext(gl, props) {
37
28
  if (!globalThis.WebGLDebugUtils) {
38
29
  log.warn('webgl-debug not loaded')();
39
30
  return gl;
40
31
  }
41
-
42
32
  const data = getContextData(gl);
43
-
44
33
  if (data.debugContext) {
45
34
  return data.debugContext;
46
35
  }
47
-
48
- globalThis.WebGLDebugUtils.init({ ...GL,
36
+ globalThis.WebGLDebugUtils.init({
37
+ ...GLEnum,
49
38
  ...gl
50
39
  });
51
40
  const glDebug = globalThis.WebGLDebugUtils.makeDebugContext(gl, onGLError.bind(null, props), onValidateGLFunc.bind(null, props));
52
-
53
- for (const key in GL) {
54
- if (!(key in glDebug) && typeof GL[key] === 'number') {
55
- glDebug[key] = GL[key];
41
+ for (const key in GLEnum) {
42
+ if (!(key in glDebug) && typeof GLEnum[key] === 'number') {
43
+ glDebug[key] = GLEnum[key];
56
44
  }
57
45
  }
58
-
59
46
  class WebGLDebugContext {}
60
-
61
47
  Object.setPrototypeOf(glDebug, Object.getPrototypeOf(gl));
62
48
  Object.setPrototypeOf(WebGLDebugContext, glDebug);
63
49
  const debugContext = Object.create(WebGLDebugContext);
@@ -66,53 +52,44 @@ function getDebugContext(gl, props) {
66
52
  debugContext.debug = true;
67
53
  return debugContext;
68
54
  }
69
-
70
55
  function getFunctionString(functionName, functionArgs) {
71
56
  functionArgs = Array.from(functionArgs).map(arg => arg === undefined ? 'undefined' : arg);
72
57
  let args = globalThis.WebGLDebugUtils.glFunctionArgsToString(functionName, functionArgs);
73
- args = "".concat(args.slice(0, 100)).concat(args.length > 100 ? '...' : '');
74
- return "gl.".concat(functionName, "(").concat(args, ")");
58
+ args = `${args.slice(0, 100)}${args.length > 100 ? '...' : ''}`;
59
+ return `gl.${functionName}(${args})`;
75
60
  }
76
-
77
61
  function onGLError(props, err, functionName, args) {
78
62
  args = Array.from(args).map(arg => arg === undefined ? 'undefined' : arg);
79
63
  const errorMessage = globalThis.WebGLDebugUtils.glEnumToString(err);
80
64
  const functionArgs = globalThis.WebGLDebugUtils.glFunctionArgsToString(functionName, args);
81
65
  const glName = props.webgl2 ? 'gl2' : 'gl1';
82
- const message = "".concat(errorMessage, " in ").concat(glName, ".").concat(functionName, "(").concat(functionArgs, ")");
66
+ const message = `${errorMessage} in ${glName}.${functionName}(${functionArgs})`;
83
67
  log.error(message)();
84
68
  debugger;
85
-
86
69
  if (props.throwOnError) {
87
70
  throw new Error(message);
88
71
  }
89
72
  }
90
-
91
73
  function onValidateGLFunc(props, functionName, functionArgs) {
92
74
  let functionString = '';
93
-
94
75
  if (log.level >= 1) {
95
76
  functionString = getFunctionString(functionName, functionArgs);
96
77
  log.log(1, functionString)();
97
78
  }
98
-
99
- if (props.break) {
79
+ if (props.break && props.break.length > 0) {
100
80
  functionString = functionString || getFunctionString(functionName, functionArgs);
101
- const isBreakpoint = props.break && props.break.every(breakOn => functionString.indexOf(breakOn) !== -1);
102
-
81
+ const isBreakpoint = props.break.every(breakOn => functionString.indexOf(breakOn) !== -1);
103
82
  if (isBreakpoint) {
104
83
  debugger;
105
84
  }
106
85
  }
107
-
108
86
  for (const arg of functionArgs) {
109
87
  if (arg === undefined) {
110
88
  functionString = functionString || getFunctionString(functionName, functionArgs);
111
-
112
89
  if (props.throwOnError) {
113
- throw new Error("Undefined argument: ".concat(functionString));
90
+ throw new Error(`Undefined argument: ${functionString}`);
114
91
  } else {
115
- log.error("Undefined argument: ".concat(functionString))();
92
+ log.error(`Undefined argument: ${functionString}`)();
116
93
  debugger;
117
94
  }
118
95
  }
@@ -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,SAAQA,GAAR,EAAaC,UAAb,QAA8B,eAA9B;AACA,OAAOC,EAAP,MAAe,oBAAf;AAEA,MAAMC,mBAAmB,GAAG,8CAA5B;AASA,MAAMC,2BAAwD,GAAG;AAC/DC,EAAAA,KAAK,EAAE,IADwD;AAE/DC,EAAAA,YAAY,EAAE,KAFiD;AAG/DC,EAAAA,KAAK,EAAE,EAHwD;AAI/DC,EAAAA,MAAM,EAAE;AAJuD,CAAjE;;AAQA,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,MAA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AACK,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,"file":"webgl-developer-tools.js","names":["log","loadScript","GL","GLEnum","isBrowser","WEBGL_DEBUG_CDN_URL","getContextData","gl","luma","loadWebGLDeveloperTools","globalThis","WebGLDebugUtils","global","module","makeDebugContext","props","arguments","length","undefined","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","args","glFunctionArgsToString","slice","err","errorMessage","glEnumToString","glName","webgl2","message","error","throwOnError","Error","functionString","level","break","isBreakpoint","every","breakOn","indexOf"],"sources":["../../../src/context/debug/webgl-developer-tools.ts"],"sourcesContent":["// luma.gl, MIT license\n// Copyright (c) vis.gl contributors\n\nimport {log, loadScript} from '@luma.gl/core';\n// Rename constant to prevent inlining. We need the full set of constants for generating debug strings.\nimport {GL as GLEnum} from '@luma.gl/constants';\nimport {isBrowser} from '@probe.gl/env'\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\ntype ContextData = {\n realContext?: WebGLRenderingContext;\n debugContext?: WebGLRenderingContext;\n}\n\n// Helper to get shared context data\nfunction getContextData(gl: any): ContextData {\n gl.luma = gl.luma || {};\n return gl.luma;\n}\n\ndeclare global {\n // eslint-disable-next-line no-var\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 (isBrowser() && !globalThis.WebGLDebugUtils) {\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({...GLEnum, ...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 GLEnum) {\n if (!(key in glDebug) && typeof GLEnum[key] === 'number') {\n glDebug[key] = GLEnum[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 array of breakpoint strings supplied, check if any of them is contained in current GLEnum function\n if (props.break && props.break.length > 0) {\n functionString = functionString || getFunctionString(functionName, functionArgs);\n const isBreakpoint = 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"],"mappings":"AAGA,SAAQA,GAAG,EAAEC,UAAU,QAAO,eAAe;AAE7C,SAAQC,EAAE,IAAIC,MAAM,QAAO,oBAAoB;AAC/C,SAAQC,SAAS,QAAO,eAAe;AAEvC,MAAMC,mBAAmB,GAAG,8CAA8C;AAsB1E,SAASC,cAAcA,CAACC,EAAO,EAAe;EAC5CA,EAAE,CAACC,IAAI,GAAGD,EAAE,CAACC,IAAI,IAAI,CAAC,CAAC;EACvB,OAAOD,EAAE,CAACC,IAAI;AAChB;AAaA,OAAO,eAAeC,uBAAuBA,CAAA,EAAkB;EAC7D,IAAIL,SAAS,CAAC,CAAC,I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ACD,OAAO,CAAC,KAAK,CAAC,CAAC,CAAC;IACnG,IAAIF,YAAY,EAAE;MAChB;IACF;EACF;EAEA,KAAK,MAAMhB,GAAG,IAAIJ,YAAY,EAAE;IAC9B,IAAII,GAAG,KAAKzB,SAAS,EAAE;MACrBsC,cAAc,GAAGA,cAAc,IAAInB,iBAAiB,CAACC,YAAY,EAAEC,YAAY,CAAC;MAChF,IAAIxB,KAAK,CAACuC,YAAY,EAAE;QACtB,MAAM,IAAIC,KAAK,CAAE,uBAAsBC,cAAe,EAAC,CAAC;MAC1D,CAAC,MAAM;QACLxD,GAAG,CAACqD,KAAK,CAAE,uBAAsBG,cAAe,EAAC,CAAC,CAAC,CAAC;QACpD;MACF;IACF;EACF;AACF"}
@@ -1,5 +1,5 @@
1
- import { Device } from '@luma.gl/api';
2
- import type { GLParameters } from '../../types/webgl';
1
+ import { Device } from '@luma.gl/core';
2
+ import type { GLParameters } from '@luma.gl/constants';
3
3
  export type { GLParameters };
4
4
  /**
5
5
  * Sets any GL parameter regardless of function (gl.blendMode, ...)
@@ -7,7 +7,7 @@ export type { GLParameters };
7
7
  * @note requires a `cache` object to be set on the context (gl.state.cache)
8
8
  * This object is used to fill in any missing values for composite setter functions
9
9
  */
10
- export declare function setParameters(device: Device | WebGLRenderingContext, parameters: GLParameters): void;
10
+ export declare function setGLParameters(device: Device | WebGLRenderingContext, parameters: GLParameters): void;
11
11
  /**
12
12
  * Reads the entire WebGL state from a context
13
13
 
@@ -22,12 +22,12 @@ export declare function setParameters(device: Device | WebGLRenderingContext, pa
22
22
  * considered a very slow operation, to be used only if/when a context already manipulated
23
23
  * by external code needs to be synchronized for the first time
24
24
  */
25
- export declare function getParameters(gl: WebGLRenderingContext, parameters?: keyof GLParameters | (keyof GLParameters)[] | GLParameters): GLParameters;
25
+ export declare function getGLParameters(device: Device | WebGLRenderingContext, parameters?: keyof GLParameters | (keyof GLParameters)[] | GLParameters): GLParameters;
26
26
  /**
27
27
  * Reset all parameters to a (almost) pure context state
28
28
  * @note viewport and scissor will be set to the values in GL_PARAMETER_DEFAULTS,
29
29
  * NOT the canvas size dimensions, so they will have to be properly set after
30
30
  * calling this function.
31
31
  */
32
- export declare function resetParameters(gl: WebGLRenderingContext): void;
32
+ export declare function resetGLParameters(device: Device | WebGLRenderingContext): void;
33
33
  //# sourceMappingURL=unified-parameter-api.d.ts.map
@@ -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,EAAE,EAAE,qBAAqB,EACzB,UAAU,GAAE,MAAM,YAAY,GAAG,CAAC,MAAM,YAAY,CAAC,EAAE,GAAG,YAAoC,GAC7F,YAAY,CAkBd;AAED;;;;;GAKG;AACH,wBAAgB,eAAe,CAAC,EAAE,EAAE,qBAAqB,GAAG,IAAI,CAE/D"}
1
+ {"version":3,"file":"unified-parameter-api.d.ts","sourceRoot":"","sources":["../../../src/context/parameters/unified-parameter-api.ts"],"names":[],"mappings":"AAMA,OAAO,EAAC,MAAM,EAAC,MAAM,eAAe,CAAC;AACrC,OAAO,KAAK,EAAC,YAAY,EAAC,MAAM,oBAAoB,CAAC;AAUrD,YAAY,EAAC,YAAY,EAAC,CAAC;AAE3B;;;;;GAKG;AACH,wBAAgB,eAAe,CAC7B,MAAM,EAAE,MAAM,GAAG,qBAAqB,EACtC,UAAU,EAAE,YAAY,GACvB,IAAI,CAiDN;AAED;;;;;;;;;;;;;GAaG;AACH,wBAAgB,eAAe,CAC7B,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,iBAAiB,CAAC,MAAM,EAAE,MAAM,GAAG,qBAAqB,GAAG,IAAI,CAE9E"}
@@ -1,19 +1,15 @@
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';
3
- export function setParameters(device, parameters) {
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
+ export function setGLParameters(device, parameters) {
4
4
  const webglDevice = WebGLDevice.attach(device);
5
5
  const gl = webglDevice.gl;
6
-
7
6
  if (isObjectEmpty(parameters)) {
8
7
  return;
9
8
  }
10
-
11
9
  const compositeSetters = {};
12
-
13
10
  for (const key in parameters) {
14
11
  const glConstant = Number(key);
15
12
  const setter = GL_PARAMETER_SETTERS[key];
16
-
17
13
  if (setter) {
18
14
  if (typeof setter === 'string') {
19
15
  compositeSetters[setter] = true;
@@ -22,9 +18,7 @@ export function setParameters(device, parameters) {
22
18
  }
23
19
  }
24
20
  }
25
-
26
21
  const cache = gl.state && gl.state.cache;
27
-
28
22
  if (cache) {
29
23
  for (const key in compositeSetters) {
30
24
  const compositeSetter = GL_COMPOSITE_PARAMETER_SETTERS[key];
@@ -32,32 +26,30 @@ export function setParameters(device, parameters) {
32
26
  }
33
27
  }
34
28
  }
35
- export function getParameters(gl, parameters = GL_PARAMETER_DEFAULTS) {
29
+ export function getGLParameters(device) {
30
+ let parameters = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : GL_PARAMETER_DEFAULTS;
31
+ const webglDevice = WebGLDevice.attach(device);
32
+ const gl = webglDevice.gl;
36
33
  if (typeof parameters === 'number') {
37
34
  const key = parameters;
38
35
  const getter = GL_PARAMETER_GETTERS[key];
39
36
  return getter ? getter(gl, key) : gl.getParameter(key);
40
37
  }
41
-
42
38
  const parameterKeys = Array.isArray(parameters) ? parameters : Object.keys(parameters);
43
39
  const state = {};
44
-
45
40
  for (const key of parameterKeys) {
46
41
  const getter = GL_PARAMETER_GETTERS[key];
47
42
  state[key] = getter ? getter(gl, Number(key)) : gl.getParameter(Number(key));
48
43
  }
49
-
50
44
  return state;
51
45
  }
52
- export function resetParameters(gl) {
53
- setParameters(gl, GL_PARAMETER_DEFAULTS);
46
+ export function resetGLParameters(device) {
47
+ setGLParameters(device, GL_PARAMETER_DEFAULTS);
54
48
  }
55
-
56
49
  function isObjectEmpty(object) {
57
50
  for (const key in object) {
58
51
  return false;
59
52
  }
60
-
61
53
  return true;
62
54
  }
63
55
  //# sourceMappingURL=unified-parameter-api.js.map