@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
@@ -0,0 +1,192 @@
1
+ import { assert, Texture, Framebuffer } from '@luma.gl/core';
2
+ import { getGLTypeFromTypedArray, getTypedArrayFromGLType } from "./typed-array-utils.js";
3
+ import { glFormatToComponents, glTypeToBytes } from "./format-utils.js";
4
+ export function readPixelsToArray(source, options) {
5
+ var _framebuffer$colorAtt;
6
+ const {
7
+ sourceX = 0,
8
+ sourceY = 0,
9
+ sourceFormat = 6408,
10
+ sourceAttachment = 36064
11
+ } = options || {};
12
+ let {
13
+ target = null,
14
+ sourceWidth,
15
+ sourceHeight,
16
+ sourceType
17
+ } = options || {};
18
+ const {
19
+ framebuffer,
20
+ deleteFramebuffer
21
+ } = getFramebuffer(source);
22
+ assert(framebuffer);
23
+ const {
24
+ gl,
25
+ handle
26
+ } = framebuffer;
27
+ sourceWidth = sourceWidth || framebuffer.width;
28
+ sourceHeight = sourceHeight || framebuffer.height;
29
+ const attachment = sourceAttachment - 36064;
30
+ sourceType = sourceType || ((_framebuffer$colorAtt = framebuffer.colorAttachments[attachment]) === null || _framebuffer$colorAtt === void 0 ? void 0 : _framebuffer$colorAtt.type) || 5121;
31
+ target = getPixelArray(target, sourceType, sourceFormat, sourceWidth, sourceHeight);
32
+ sourceType = sourceType || getGLTypeFromTypedArray(target);
33
+ const prevHandle = gl.bindFramebuffer(36160, handle);
34
+ gl.readPixels(sourceX, sourceY, sourceWidth, sourceHeight, sourceFormat, sourceType, target);
35
+ gl.bindFramebuffer(36160, prevHandle || null);
36
+ if (deleteFramebuffer) {
37
+ framebuffer.destroy();
38
+ }
39
+ return target;
40
+ }
41
+ export function readPixelsToBuffer(source, options) {
42
+ const {
43
+ target,
44
+ sourceX = 0,
45
+ sourceY = 0,
46
+ sourceFormat = 6408,
47
+ targetByteOffset = 0
48
+ } = options || {};
49
+ let {
50
+ sourceWidth,
51
+ sourceHeight,
52
+ sourceType
53
+ } = options || {};
54
+ const {
55
+ framebuffer,
56
+ deleteFramebuffer
57
+ } = getFramebuffer(source);
58
+ assert(framebuffer);
59
+ sourceWidth = sourceWidth || framebuffer.width;
60
+ sourceHeight = sourceHeight || framebuffer.height;
61
+ const webglFramebuffer = framebuffer;
62
+ sourceType = sourceType || 5121;
63
+ let webglBufferTarget = target;
64
+ if (!webglBufferTarget) {
65
+ const components = glFormatToComponents(sourceFormat);
66
+ const byteCount = glTypeToBytes(sourceType);
67
+ const byteLength = targetByteOffset + sourceWidth * sourceHeight * components * byteCount;
68
+ webglBufferTarget = webglFramebuffer.device.createBuffer({
69
+ byteLength
70
+ });
71
+ }
72
+ const commandEncoder = source.device.createCommandEncoder();
73
+ commandEncoder.copyTextureToBuffer({
74
+ source: source,
75
+ width: sourceWidth,
76
+ height: sourceHeight,
77
+ origin: [sourceX, sourceY],
78
+ destination: webglBufferTarget,
79
+ byteOffset: targetByteOffset
80
+ });
81
+ commandEncoder.destroy();
82
+ if (deleteFramebuffer) {
83
+ framebuffer.destroy();
84
+ }
85
+ return webglBufferTarget;
86
+ }
87
+ export function copyToTexture(source, target, options) {
88
+ const {
89
+ sourceX = 0,
90
+ sourceY = 0,
91
+ targetMipmaplevel = 0,
92
+ targetInternalFormat = 6408
93
+ } = options || {};
94
+ let {
95
+ targetX,
96
+ targetY,
97
+ targetZ,
98
+ width,
99
+ height
100
+ } = options || {};
101
+ const {
102
+ framebuffer,
103
+ deleteFramebuffer
104
+ } = getFramebuffer(source);
105
+ assert(framebuffer);
106
+ const webglFramebuffer = framebuffer;
107
+ const {
108
+ device,
109
+ handle
110
+ } = webglFramebuffer;
111
+ const isSubCopy = typeof targetX !== 'undefined' || typeof targetY !== 'undefined' || typeof targetZ !== 'undefined';
112
+ targetX = targetX || 0;
113
+ targetY = targetY || 0;
114
+ targetZ = targetZ || 0;
115
+ const prevHandle = device.gl.bindFramebuffer(36160, handle);
116
+ assert(target);
117
+ let texture = null;
118
+ let textureTarget;
119
+ if (target instanceof Texture) {
120
+ texture = target;
121
+ width = Number.isFinite(width) ? width : texture.width;
122
+ height = Number.isFinite(height) ? height : texture.height;
123
+ texture.bind(0);
124
+ textureTarget = texture.target;
125
+ } else {
126
+ textureTarget = target;
127
+ }
128
+ if (!isSubCopy) {
129
+ device.gl.copyTexImage2D(textureTarget, targetMipmaplevel, targetInternalFormat, sourceX, sourceY, width, height, 0);
130
+ } else {
131
+ switch (textureTarget) {
132
+ case 3553:
133
+ case 34067:
134
+ device.gl.copyTexSubImage2D(textureTarget, targetMipmaplevel, targetX, targetY, sourceX, sourceY, width, height);
135
+ break;
136
+ case 35866:
137
+ case 32879:
138
+ device.assertWebGL2();
139
+ device.gl2.copyTexSubImage3D(textureTarget, targetMipmaplevel, targetX, targetY, targetZ, sourceX, sourceY, width, height);
140
+ break;
141
+ default:
142
+ }
143
+ }
144
+ if (texture) {
145
+ texture.unbind();
146
+ }
147
+ device.gl.bindFramebuffer(36160, prevHandle || null);
148
+ if (deleteFramebuffer) {
149
+ framebuffer.destroy();
150
+ }
151
+ return texture;
152
+ }
153
+ function getFramebuffer(source) {
154
+ if (!(source instanceof Framebuffer)) {
155
+ return {
156
+ framebuffer: toFramebuffer(source),
157
+ deleteFramebuffer: true
158
+ };
159
+ }
160
+ return {
161
+ framebuffer: source,
162
+ deleteFramebuffer: false
163
+ };
164
+ }
165
+ export function toFramebuffer(texture, props) {
166
+ const {
167
+ device,
168
+ width,
169
+ height,
170
+ id
171
+ } = texture;
172
+ const framebuffer = device.createFramebuffer({
173
+ ...props,
174
+ id: `framebuffer-for-${id}`,
175
+ width,
176
+ height,
177
+ colorAttachments: [texture]
178
+ });
179
+ return framebuffer;
180
+ }
181
+ function getPixelArray(pixelArray, type, format, width, height) {
182
+ if (pixelArray) {
183
+ return pixelArray;
184
+ }
185
+ type = type || 5121;
186
+ const ArrayType = getTypedArrayFromGLType(type, {
187
+ clamped: false
188
+ });
189
+ const components = glFormatToComponents(format);
190
+ return new ArrayType(width * height * components);
191
+ }
192
+ //# sourceMappingURL=copy-and-blit.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"copy-and-blit.js","names":["assert","Texture","Framebuffer","getGLTypeFromTypedArray","getTypedArrayFromGLType","glFormatToComponents","glTypeToBytes","readPixelsToArray","source","options","_framebuffer$colorAtt","sourceX","sourceY","sourceFormat","sourceAttachment","target","sourceWidth","sourceHeight","sourceType","framebuffer","deleteFramebuffer","getFramebuffer","gl","handle","width","height","attachment","colorAttachments","type","getPixelArray","prevHandle","bindFramebuffer","readPixels","destroy","readPixelsToBuffer","targetByteOffset","webglFramebuffer","webglBufferTarget","components","byteCount","byteLength","device","createBuffer","commandEncoder","createCommandEncoder","copyTextureToBuffer","origin","destination","byteOffset","copyToTexture","targetMipmaplevel","targetInternalFormat","targetX","targetY","targetZ","isSubCopy","texture","textureTarget","Number","isFinite","bind","copyTexImage2D","copyTexSubImage2D","assertWebGL2","gl2","copyTexSubImage3D","unbind","toFramebuffer","props","id","createFramebuffer","pixelArray","format","ArrayType","clamped"],"sources":["../../src/classic/copy-and-blit.ts"],"sourcesContent":["// luma.gl, MIT license\n// Copyright (c) vis.gl contributors\n\nimport {assert, Buffer, Texture, Framebuffer, FramebufferProps} from '@luma.gl/core';\nimport {GL} from '@luma.gl/constants';\n\nimport {WEBGLTexture} from '../adapter/resources/webgl-texture';\nimport {WEBGLFramebuffer} from '../adapter/resources/webgl-framebuffer';\nimport {getGLTypeFromTypedArray, getTypedArrayFromGLType} from './typed-array-utils';\nimport {glFormatToComponents, glTypeToBytes} from './format-utils';\nimport {WEBGLBuffer} from '../adapter/resources/webgl-buffer';\n\n/**\n * Copies data from a type or a Texture object into ArrayBuffer object.\n * App can provide targetPixelArray or have it auto allocated by this method\n * newly allocated by this method unless provided by app.\n * @deprecated Use CommandEncoder.copyTextureToBuffer and Buffer.read\n * @note Slow requires roundtrip to GPU\n *\n * @param source\n * @param options\n * @returns pixel array,\n */\nexport function readPixelsToArray(\n source: Framebuffer | Texture,\n options?: {\n sourceX?: number;\n sourceY?: number;\n sourceFormat?: number;\n sourceAttachment?: number;\n target?: Uint8Array | Uint16Array | Float32Array;\n // following parameters are auto deduced if not provided\n sourceWidth?: number;\n sourceHeight?: number;\n sourceType?: number;\n }\n): Uint8Array | Uint16Array | Float32Array {\n const {\n sourceX = 0,\n sourceY = 0,\n sourceFormat = GL.RGBA,\n sourceAttachment = GL.COLOR_ATTACHMENT0 // TODO - support gl.readBuffer\n } = options || {};\n let {\n target = null,\n // following parameters are auto deduced if not provided\n sourceWidth,\n sourceHeight,\n sourceType\n } = options || {};\n\n const {framebuffer, deleteFramebuffer} = getFramebuffer(source);\n assert(framebuffer);\n const {gl, handle} = framebuffer as WEBGLFramebuffer;\n sourceWidth = sourceWidth || framebuffer.width;\n sourceHeight = sourceHeight || framebuffer.height;\n\n // TODO - Set and unset gl.readBuffer\n // if (sourceAttachment === GL.COLOR_ATTACHMENT0 && handle === null) {\n // sourceAttachment = GL.FRONT;\n // }\n\n const attachment = sourceAttachment - GL.COLOR_ATTACHMENT0;\n // assert(attachments[sourceAttachment]);\n\n // Deduce the type from color attachment if not provided.\n sourceType =\n sourceType ||\n (framebuffer.colorAttachments[attachment] as WEBGLTexture)?.type ||\n GL.UNSIGNED_BYTE;\n\n // Deduce type and allocated pixelArray if needed\n target = getPixelArray(target, sourceType, sourceFormat, sourceWidth, sourceHeight);\n\n // Pixel array available, if necessary, deduce type from it.\n sourceType = sourceType || getGLTypeFromTypedArray(target);\n\n const prevHandle = gl.bindFramebuffer(GL.FRAMEBUFFER, handle);\n gl.readPixels(sourceX, sourceY, sourceWidth, sourceHeight, sourceFormat, sourceType, target);\n // @ts-expect-error\n gl.bindFramebuffer(GL.FRAMEBUFFER, prevHandle || null);\n if (deleteFramebuffer) {\n framebuffer.destroy();\n }\n return target;\n}\n\n/**\n * Copies data from a Framebuffer or a Texture object into a Buffer object.\n * NOTE: doesn't wait for copy to be complete, it programs GPU to perform a DMA transffer.\n * @deprecated Use CommandEncoder\n * @param source\n * @param options\n */\nexport function readPixelsToBuffer(\n source: Framebuffer | Texture,\n options?: {\n sourceX?: number;\n sourceY?: number;\n sourceFormat?: number;\n target?: Buffer; // A new Buffer object is created when not provided.\n targetByteOffset?: number; // byte offset in buffer object\n // following parameters are auto deduced if not provided\n sourceWidth?: number;\n sourceHeight?: number;\n sourceType?: number;\n }\n): WEBGLBuffer {\n const {target, sourceX = 0, sourceY = 0, sourceFormat = GL.RGBA, targetByteOffset = 0} = options || {};\n // following parameters are auto deduced if not provided\n let {sourceWidth, sourceHeight, sourceType} = options || {};\n const {framebuffer, deleteFramebuffer} = getFramebuffer(source);\n assert(framebuffer);\n sourceWidth = sourceWidth || framebuffer.width;\n sourceHeight = sourceHeight || framebuffer.height;\n\n // Asynchronous read (PIXEL_PACK_BUFFER) is WebGL2 only feature\n const webglFramebuffer = framebuffer as WEBGLFramebuffer;\n\n // deduce type if not available.\n sourceType = sourceType || GL.UNSIGNED_BYTE;\n\n let webglBufferTarget = target as unknown as WEBGLBuffer | undefined;\n if (!webglBufferTarget) {\n // Create new buffer with enough size\n const components = glFormatToComponents(sourceFormat);\n const byteCount = glTypeToBytes(sourceType);\n const byteLength = targetByteOffset + sourceWidth * sourceHeight * components * byteCount;\n webglBufferTarget = webglFramebuffer.device.createBuffer({byteLength});\n }\n\n // TODO(donmccurdy): Do we have tests to confirm this is working?\n const commandEncoder = source.device.createCommandEncoder();\n commandEncoder.copyTextureToBuffer({\n source: source as Texture,\n width: sourceWidth,\n height: sourceHeight,\n origin: [sourceX, sourceY],\n destination: webglBufferTarget,\n byteOffset: targetByteOffset\n });\n commandEncoder.destroy();\n\n if (deleteFramebuffer) {\n framebuffer.destroy();\n }\n\n return webglBufferTarget;\n}\n\n/**\n * Copy a rectangle from a Framebuffer or Texture object into a texture (at an offset)\n * @deprecated Use CommandEncoder\n */\n// eslint-disable-next-line complexity, max-statements\nexport function copyToTexture(\n source: Framebuffer | Texture,\n target: Texture | GL,\n options?: {\n sourceX?: number;\n sourceY?: number;\n\n targetX?: number;\n targetY?: number;\n targetZ?: number;\n targetMipmaplevel?: number;\n targetInternalFormat?: number;\n\n width?: number; // defaults to target width\n height?: number; // defaults to target height\n }\n): Texture {\n const {\n sourceX = 0,\n sourceY = 0,\n // attachment = GL.COLOR_ATTACHMENT0, // TODO - support gl.readBuffer\n targetMipmaplevel = 0,\n targetInternalFormat = GL.RGBA\n } = options || {};\n let {\n targetX,\n targetY,\n targetZ,\n width, // defaults to target width\n height // defaults to target height\n } = options || {};\n\n const {framebuffer, deleteFramebuffer} = getFramebuffer(source);\n assert(framebuffer);\n const webglFramebuffer = framebuffer as WEBGLFramebuffer;\n const {device, handle} = webglFramebuffer;\n const isSubCopy =\n typeof targetX !== 'undefined' ||\n typeof targetY !== 'undefined' ||\n typeof targetZ !== 'undefined';\n targetX = targetX || 0;\n targetY = targetY || 0;\n targetZ = targetZ || 0;\n const prevHandle = device.gl.bindFramebuffer(GL.FRAMEBUFFER, handle);\n // TODO - support gl.readBuffer (WebGL2 only)\n // const prevBuffer = gl.readBuffer(attachment);\n assert(target);\n let texture = null;\n let textureTarget: GL;\n if (target instanceof Texture) {\n texture = target;\n width = Number.isFinite(width) ? width : texture.width;\n height = Number.isFinite(height) ? height : texture.height;\n texture.bind(0);\n textureTarget = texture.target;\n } else {\n textureTarget = target;\n }\n\n if (!isSubCopy) {\n device.gl.copyTexImage2D(\n textureTarget,\n targetMipmaplevel,\n targetInternalFormat,\n sourceX,\n sourceY,\n width,\n height,\n 0 /* border must be 0 */\n );\n } else {\n switch (textureTarget) {\n case GL.TEXTURE_2D:\n case GL.TEXTURE_CUBE_MAP:\n device.gl.copyTexSubImage2D(\n textureTarget,\n targetMipmaplevel,\n targetX,\n targetY,\n sourceX,\n sourceY,\n width,\n height\n );\n break;\n case GL.TEXTURE_2D_ARRAY:\n case GL.TEXTURE_3D:\n device.assertWebGL2();\n device.gl2.copyTexSubImage3D(\n textureTarget,\n targetMipmaplevel,\n targetX,\n targetY,\n targetZ,\n sourceX,\n sourceY,\n width,\n height\n );\n break;\n default:\n }\n }\n if (texture) {\n texture.unbind();\n }\n // @ts-expect-error\n device.gl.bindFramebuffer(GL.FRAMEBUFFER, prevHandle || null);\n if (deleteFramebuffer) {\n framebuffer.destroy();\n }\n return texture;\n}\n\nfunction getFramebuffer(source: Texture | Framebuffer): {\n framebuffer: Framebuffer;\n deleteFramebuffer: boolean;\n} {\n if (!(source instanceof Framebuffer)) {\n return {framebuffer: toFramebuffer(source), deleteFramebuffer: true};\n }\n return {framebuffer: source, deleteFramebuffer: false};\n}\n\n/**\n * Wraps a given texture into a framebuffer object, that can be further used\n * to read data from the texture object.\n */\nexport function toFramebuffer(texture: Texture, props?: FramebufferProps): Framebuffer {\n const {device, width, height, id} = texture;\n const framebuffer = device.createFramebuffer({\n ...props,\n id: `framebuffer-for-${id}`,\n width,\n height,\n colorAttachments: [texture]\n });\n return framebuffer;\n}\n\nfunction getPixelArray(\n pixelArray,\n type,\n format,\n width: number,\n height: number\n): Uint8Array | Uint16Array | Float32Array {\n if (pixelArray) {\n return pixelArray;\n }\n // Allocate pixel array if not already available, using supplied type\n type = type || GL.UNSIGNED_BYTE;\n const ArrayType = getTypedArrayFromGLType(type, {clamped: false});\n const components = glFormatToComponents(format);\n // TODO - check for composite type (components = 1).\n return new ArrayType(width * height * components) as Uint8Array | Uint16Array | Float32Array;\n}\n"],"mappings":"AAGA,SAAQA,MAAM,EAAUC,OAAO,EAAEC,WAAW,QAAyB,eAAe;AAAC,SAK7EC,uBAAuB,EAAEC,uBAAuB;AAAA,SAChDC,oBAAoB,EAAEC,aAAa;AAc3C,OAAO,SAASC,iBAAiBA,CAC/BC,MAA6B,EAC7BC,OAUC,EACwC;EAAA,IAAAC,qBAAA;EACzC,MAAM;IACJC,OAAO,GAAG,CAAC;IACXC,OAAO,GAAG,CAAC;IACXC,YAAY,OAAU;IACtBC,gBAAgB;EAClB,CAAC,GAAGL,OAAO,IAAI,CAAC,CAAC;EACjB,IAAI;IACFM,MAAM,GAAG,IAAI;IAEbC,WAAW;IACXC,YAAY;IACZC;EACF,CAAC,GAAGT,OAA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;EACrF,MAAM;IAAC3B,MAAM;IAAEjB,KAAK;IAAEC,MAAM;IAAE4C;EAAE,CAAC,GAAGb,OAAO;EAC3C,MAAMrC,WAAW,GAAGsB,MAAM,CAAC6B,iBAAiB,CAAC;IAC3C,GAAGF,KAAK;IACRC,EAAE,EAAG,mBAAkBA,EAAG,EAAC;IAC3B7C,KAAK;IACLC,MAAM;IACNE,gBAAgB,EAAE,CAAC6B,OAAO;EAC5B,CAAC,CAAC;EACF,OAAOrC,WAAW;AACpB;AAEA,SAASU,aAAaA,CACpB0C,UAAU,EACV3C,IAAI,EACJ4C,MAAM,EACNhD,KAAa,EACbC,MAAc,EAC2B;EACzC,IAAI8C,UAAU,EAAE;IACd,OAAOA,UAAU;EACnB;EAEA3C,IAAI,GAAGA,IAAI,QAAoB;EAC/B,MAAM6C,SAAS,GAAGrE,uBAAuB,CAACwB,IAAI,EAAE;IAAC8C,OAAO,EAAE;EAAK,CAAC,CAAC;EACjE,MAAMpC,UAAU,GAAGjC,oBAAoB,CAACmE,MAAM,CAAC;EAE/C,OAAO,IAAIC,SAAS,CAACjD,KAAK,GAAGC,MAAM,GAAGa,UAAU,CAAC;AACnD"}
@@ -0,0 +1,3 @@
1
+ export declare function glFormatToComponents(format: any): 2 | 0 | 1 | 4 | 3;
2
+ export declare function glTypeToBytes(type: any): 2 | 0 | 1 | 4;
3
+ //# sourceMappingURL=format-utils.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"format-utils.d.ts","sourceRoot":"","sources":["../../src/classic/format-utils.ts"],"names":[],"mappings":"AAOA,wBAAgB,oBAAoB,CAAC,MAAM,KAAA,qBAoB1C;AAGD,wBAAgB,aAAa,CAAC,IAAI,KAAA,iBAejC"}
@@ -0,0 +1,37 @@
1
+ import { assert } from '@luma.gl/core';
2
+ export function glFormatToComponents(format) {
3
+ switch (format) {
4
+ case 6406:
5
+ case 33326:
6
+ case 6403:
7
+ return 1;
8
+ case 33328:
9
+ case 33319:
10
+ return 2;
11
+ case 6407:
12
+ case 34837:
13
+ return 3;
14
+ case 6408:
15
+ case 34836:
16
+ return 4;
17
+ default:
18
+ assert(false);
19
+ return 0;
20
+ }
21
+ }
22
+ export function glTypeToBytes(type) {
23
+ switch (type) {
24
+ case 5121:
25
+ return 1;
26
+ case 33635:
27
+ case 32819:
28
+ case 32820:
29
+ return 2;
30
+ case 5126:
31
+ return 4;
32
+ default:
33
+ assert(false);
34
+ return 0;
35
+ }
36
+ }
37
+ //# sourceMappingURL=format-utils.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"format-utils.js","names":["assert","glFormatToComponents","format","glTypeToBytes","type"],"sources":["../../src/classic/format-utils.ts"],"sourcesContent":["// luma.gl, MIT license\n// Copyright (c) vis.gl contributors\n\nimport {assert} from '@luma.gl/core';\nimport {GL} from '@luma.gl/constants';\n\n// Returns number of components in a specific readPixels WebGL format\nexport function glFormatToComponents(format) {\n switch (format) {\n case GL.ALPHA:\n case GL.R32F:\n case GL.RED:\n return 1;\n case GL.RG32F:\n case GL.RG:\n return 2;\n case GL.RGB:\n case GL.RGB32F:\n return 3;\n case GL.RGBA:\n case GL.RGBA32F:\n return 4;\n // TODO: Add support for additional WebGL2 formats\n default:\n assert(false);\n return 0;\n }\n}\n\n// Return byte count for given readPixels WebGL type\nexport function glTypeToBytes(type) {\n switch (type) {\n case GL.UNSIGNED_BYTE:\n return 1;\n case GL.UNSIGNED_SHORT_5_6_5:\n case GL.UNSIGNED_SHORT_4_4_4_4:\n case GL.UNSIGNED_SHORT_5_5_5_1:\n return 2;\n case GL.FLOAT:\n return 4;\n // TODO: Add support for additional WebGL2 types\n default:\n assert(false);\n return 0;\n }\n}\n"],"mappings":"AAGA,SAAQA,MAAM,QAAO,eAAe;AAIpC,OAAO,SAASC,oBAAoBA,CAACC,MAAM,EAAE;EAC3C,QAAQA,MAAM;IACZ;IACA;IACA;MACE,OAAO,CAAC;IACV;IACA;MACE,OAAO,CAAC;IACV;IACA;MACE,OAAO,CAAC;IACV;IACA;MACE,OAAO,CAAC;IAEV;MACEF,MAAM,CAAC,KAAK,CAAC;MACb,OAAO,CAAC;EACZ;AACF;AAGA,OAAO,SAASG,aAAaA,CAACC,IAAI,EAAE;EAClC,QAAQA,IAAI;IACV;MACE,OAAO,CAAC;IACV;IACA;IACA;MACE,OAAO,CAAC;IACV;MACE,OAAO,CAAC;IAEV;MACEJ,MAAM,CAAC,KAAK,CAAC;MACb,OAAO,CAAC;EACZ;AACF"}
@@ -1,44 +1,44 @@
1
- import { TypedArray } from '@luma.gl/api';
2
- import { GLType } from '../types/webgl';
3
- declare type TypedArrayConstructor = Float32ArrayConstructor | Uint16ArrayConstructor | Uint32ArrayConstructor | Uint8ArrayConstructor | Uint8ClampedArrayConstructor | Int8ArrayConstructor | Int16ArrayConstructor | Int32ArrayConstructor;
1
+ import { TypedArray, TypedArrayConstructor } from '@luma.gl/core';
2
+ import { GLDataType, GLPixelType } from '@luma.gl/constants';
4
3
  /**
5
4
  * Converts TYPED ARRAYS to corresponding GL constant
6
5
  * Used to auto deduce gl parameter types
7
- * @param {*} arrayOrType
6
+ * @deprecated Use getDataTypeFromTypedArray
7
+ * @param arrayOrType
8
8
  * @returns
9
9
  */
10
- export declare function getGLTypeFromTypedArray(arrayOrType: TypedArray): GLType;
10
+ export declare function getGLTypeFromTypedArray(arrayOrType: TypedArray): GLDataType;
11
11
  /**
12
12
  * Converts GL constant to corresponding TYPED ARRAY
13
13
  * Used to auto deduce gl parameter types
14
- * @param {*} glType
15
- * @param {*} param1
14
+ * @deprecated Use getTypedArrayFromDataType
15
+ * @param glType
16
+ * @param param1
16
17
  * @returns
17
18
  */
18
- export declare function getTypedArrayFromGLType(glType: any, options?: {
19
+ export declare function getTypedArrayFromGLType(glType: GLDataType | GLPixelType, options?: {
19
20
  clamped?: boolean;
20
21
  }): TypedArrayConstructor;
21
22
  /**
22
23
  * Flip rows (can be used on arrays returned from `Framebuffer.readPixels`)
23
24
  * https: *stackoverflow.com/questions/41969562/
24
25
  * how-can-i-flip-the-result-of-webglrenderingcontext-readpixels
25
- * @param {*} param0
26
+ * @param param0
26
27
  */
27
28
  export declare function flipRows(options: {
28
- data: any;
29
- width: any;
30
- height: any;
29
+ data: TypedArray;
30
+ width: number;
31
+ height: number;
31
32
  bytesPerPixel?: number;
32
- temp?: any;
33
+ temp?: Uint8Array;
33
34
  }): void;
34
35
  export declare function scalePixels(options: {
35
- data: any;
36
- width: any;
37
- height: any;
36
+ data: TypedArray;
37
+ width: number;
38
+ height: number;
38
39
  }): {
39
40
  data: Uint8Array;
40
41
  width: number;
41
42
  height: number;
42
43
  };
43
- export {};
44
44
  //# sourceMappingURL=typed-array-utils.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"typed-array-utils.d.ts","sourceRoot":"","sources":["../../src/classic/typed-array-utils.ts"],"names":[],"mappings":"AAEA,OAAO,EAAC,UAAU,EAAC,MAAM,cAAc,CAAC;AAExC,OAAO,EAAC,MAAM,EAAC,MAAM,gBAAgB,CAAA;AAIrC,aAAK,qBAAqB,GACtB,uBAAuB,GACvB,sBAAsB,GACtB,sBAAsB,GACtB,qBAAqB,GACrB,4BAA4B,GAC5B,oBAAoB,GACpB,qBAAqB,GACrB,qBAAqB,CAAC;AAE1B;;;;;GAKG;AACH,wBAAgB,uBAAuB,CAAC,WAAW,EAAE,UAAU,GAAG,MAAM,CAuBvE;AAED;;;;;;GAMG;AAEH,wBAAgB,uBAAuB,CACrC,MAAM,EAAE,GAAG,EACX,OAAO,CAAC,EAAE;IACR,OAAO,CAAC,EAAE,OAAO,CAAC;CACnB,GACA,qBAAqB,CAwBvB;AAED;;;;;GAKG;AACF,wBAAgB,QAAQ,CAAC,OAAO,EAAE;IACjC,IAAI,EAAE,GAAG,CAAC;IACV,KAAK,EAAE,GAAG,CAAC;IACX,MAAM,EAAE,GAAG,CAAC;IACZ,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB,IAAI,CAAC,EAAE,GAAG,CAAC;CACZ,GAAG,IAAI,CAgBP;AAGD,wBAAgB,WAAW,CAAC,OAAO,EAAE;IACnC,IAAI,EAAE,GAAG,CAAC;IACV,KAAK,EAAE,GAAG,CAAC;IACX,MAAM,EAAE,GAAG,CAAC;CACb,GAAG;IACF,IAAI,EAAE,UAAU,CAAC;IACjB,KAAK,EAAE,MAAM,CAAC;IACd,MAAM,EAAE,MAAM,CAAC;CAChB,CAaA"}
1
+ {"version":3,"file":"typed-array-utils.d.ts","sourceRoot":"","sources":["../../src/classic/typed-array-utils.ts"],"names":[],"mappings":"AAGA,OAAO,EAAC,UAAU,EAAE,qBAAqB,EAAC,MAAM,eAAe,CAAC;AAChE,OAAO,EAAK,UAAU,EAAE,WAAW,EAAC,MAAM,oBAAoB,CAAC;AAI/D;;;;;;GAMG;AACH,wBAAgB,uBAAuB,CAAC,WAAW,EAAE,UAAU,GAAG,UAAU,CAuB3E;AAED;;;;;;;GAOG;AAEH,wBAAgB,uBAAuB,CACrC,MAAM,EAAE,UAAU,GAAG,WAAW,EAChC,OAAO,CAAC,EAAE;IACR,OAAO,CAAC,EAAE,OAAO,CAAC;CACnB,GACA,qBAAqB,CAwBvB;AAED;;;;;GAKG;AACH,wBAAgB,QAAQ,CAAC,OAAO,EAAE;IAChC,IAAI,EAAE,UAAU,CAAC;IACjB,KAAK,EAAE,MAAM,CAAC;IACd,MAAM,EAAE,MAAM,CAAC;IACf,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB,IAAI,CAAC,EAAE,UAAU,CAAC;CACnB,GAAG,IAAI,CAgBP;AAGD,wBAAgB,WAAW,CAAC,OAAO,EAAE;IACnC,IAAI,EAAE,UAAU,CAAC;IACjB,KAAK,EAAE,MAAM,CAAC;IACd,MAAM,EAAE,MAAM,CAAC;CAChB,GAAG;IACF,IAAI,EAAE,UAAU,CAAC;IACjB,KAAK,EAAE,MAAM,CAAC;IACd,MAAM,EAAE,MAAM,CAAC;CAChB,CAaA"}
@@ -1,33 +1,23 @@
1
- import GL from '@luma.gl/constants';
2
1
  const ERR_TYPE_DEDUCTION = 'Failed to deduce GL constant from typed array';
3
2
  export function getGLTypeFromTypedArray(arrayOrType) {
4
3
  const type = ArrayBuffer.isView(arrayOrType) ? arrayOrType.constructor : arrayOrType;
5
-
6
4
  switch (type) {
7
5
  case Float32Array:
8
- return GL.FLOAT;
9
-
6
+ return 5126;
10
7
  case Uint16Array:
11
- return GL.UNSIGNED_SHORT;
12
-
8
+ return 5123;
13
9
  case Uint32Array:
14
- return GL.UNSIGNED_INT;
15
-
10
+ return 5125;
16
11
  case Uint8Array:
17
- return GL.UNSIGNED_BYTE;
18
-
12
+ return 5121;
19
13
  case Uint8ClampedArray:
20
- return GL.UNSIGNED_BYTE;
21
-
14
+ return 5121;
22
15
  case Int8Array:
23
- return GL.BYTE;
24
-
16
+ return 5120;
25
17
  case Int16Array:
26
- return GL.SHORT;
27
-
18
+ return 5122;
28
19
  case Int32Array:
29
- return GL.INT;
30
-
20
+ return 5124;
31
21
  default:
32
22
  throw new Error(ERR_TYPE_DEDUCTION);
33
23
  }
@@ -36,32 +26,24 @@ export function getTypedArrayFromGLType(glType, options) {
36
26
  const {
37
27
  clamped = true
38
28
  } = options || {};
39
-
40
29
  switch (glType) {
41
- case GL.FLOAT:
30
+ case 5126:
42
31
  return Float32Array;
43
-
44
- case GL.UNSIGNED_SHORT:
45
- case GL.UNSIGNED_SHORT_5_6_5:
46
- case GL.UNSIGNED_SHORT_4_4_4_4:
47
- case GL.UNSIGNED_SHORT_5_5_5_1:
32
+ case 5123:
33
+ case 33635:
34
+ case 32819:
35
+ case 32820:
48
36
  return Uint16Array;
49
-
50
- case GL.UNSIGNED_INT:
37
+ case 5125:
51
38
  return Uint32Array;
52
-
53
- case GL.UNSIGNED_BYTE:
39
+ case 5121:
54
40
  return clamped ? Uint8ClampedArray : Uint8Array;
55
-
56
- case GL.BYTE:
41
+ case 5120:
57
42
  return Int8Array;
58
-
59
- case GL.SHORT:
43
+ case 5122:
60
44
  return Int16Array;
61
-
62
- case GL.INT:
45
+ case 5124:
63
46
  return Int32Array;
64
-
65
47
  default:
66
48
  throw new Error('Failed to deduce typed array type from GL constant');
67
49
  }
@@ -76,7 +58,6 @@ export function flipRows(options) {
76
58
  } = options;
77
59
  const bytesPerRow = width * bytesPerPixel;
78
60
  const tempBuffer = temp || new Uint8Array(bytesPerRow);
79
-
80
61
  for (let y = 0; y < height / 2; ++y) {
81
62
  const topOffset = y * bytesPerRow;
82
63
  const bottomOffset = (height - y - 1) * bytesPerRow;
@@ -94,7 +75,6 @@ export function scalePixels(options) {
94
75
  const newWidth = Math.round(width / 2);
95
76
  const newHeight = Math.round(height / 2);
96
77
  const newData = new Uint8Array(newWidth * newHeight * 4);
97
-
98
78
  for (let y = 0; y < newHeight; y++) {
99
79
  for (let x = 0; x < newWidth; x++) {
100
80
  for (let c = 0; c < 4; c++) {
@@ -102,7 +82,6 @@ export function scalePixels(options) {
102
82
  }
103
83
  }
104
84
  }
105
-
106
85
  return {
107
86
  data: newData,
108
87
  width: newWidth,
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/classic/typed-array-utils.ts"],"names":["GL","ERR_TYPE_DEDUCTION","getGLTypeFromTypedArray","arrayOrType","type","ArrayBuffer","isView","constructor","Float32Array","FLOAT","Uint16Array","UNSIGNED_SHORT","Uint32Array","UNSIGNED_INT","Uint8Array","UNSIGNED_BYTE","Uint8ClampedArray","Int8Array","BYTE","Int16Array","SHORT","Int32Array","INT","Error","getTypedArrayFromGLType","glType","options","clamped","UNSIGNED_SHORT_5_6_5","UNSIGNED_SHORT_4_4_4_4","UNSIGNED_SHORT_5_5_5_1","flipRows","data","width","height","bytesPerPixel","temp","bytesPerRow","tempBuffer","y","topOffset","bottomOffset","set","subarray","copyWithin","scalePixels","newWidth","Math","round","newHeight","newData","x","c"],"mappings":"AAGA,OAAOA,EAAP,MAAe,oBAAf;AAGA,MAAMC,kBAAkB,GAAG,+CAA3B;AAkBA,OAAO,SAASC,uBAAT,CAAiCC,WAAjC,EAAkE;AAEvE,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AuB,CAAtC,CAAhB;;AACA,OAAK,IAAIV,CAAC,GAAG,CAAb,EAAgBA,CAAC,GAAGU,SAApB,EAA+BV,CAAC,EAAhC,EAAoC;AAClC,SAAK,IAAIY,CAAC,GAAG,CAAb,EAAgBA,CAAC,GAAGL,QAApB,EAA8BK,CAAC,EAA/B,EAAmC;AACjC,WAAK,IAAIC,CAAC,GAAG,CAAb,EAAgBA,CAAC,GAAG,CAApB,EAAuBA,CAAC,EAAxB,EAA4B;AAC1BF,QAAAA,OAAO,CAAC,CAACX,CAAC,GAAGO,QAAJ,GAAeK,CAAhB,IAAqB,CAArB,GAAyBC,CAA1B,CAAP,GAAsCpB,IAAI,CAAC,CAACO,CAAC,GAAG,CAAJ,GAAQN,KAAR,GAAgBkB,CAAC,GAAG,CAArB,IAA0B,CAA1B,GAA8BC,CAA/B,CAA1C;AACD;AACF;AACF;;AACD,SAAO;AAACpB,IAAAA,IAAI,EAAEkB,OAAP;AAAgBjB,IAAAA,KAAK,EAAEa,QAAvB;AAAiCZ,IAAAA,MAAM,EAAEe;AAAzC,GAAP;AACD","sourcesContent":["// luma.gl, MIT license\n\nimport {TypedArray} from '@luma.gl/api';\nimport GL from '@luma.gl/constants';\nimport {GLType} from '../types/webgl'\n\nconst ERR_TYPE_DEDUCTION = 'Failed to deduce GL constant from typed array';\n\ntype TypedArrayConstructor =\n | Float32ArrayConstructor\n | Uint16ArrayConstructor\n | Uint32ArrayConstructor\n | Uint8ArrayConstructor\n | Uint8ClampedArrayConstructor\n | Int8ArrayConstructor\n | Int16ArrayConstructor\n | Int32ArrayConstructor;\n\n/**\n * Converts TYPED ARRAYS to corresponding GL constant\n * Used to auto deduce gl parameter types\n * @param {*} arrayOrType\n * @returns\n */\nexport function getGLTypeFromTypedArray(arrayOrType: TypedArray): GLType {\n // If typed array, look up constructor\n const type = ArrayBuffer.isView(arrayOrType) ? arrayOrType.constructor : arrayOrType;\n switch (type) {\n case Float32Array:\n return GL.FLOAT;\n case Uint16Array:\n return GL.UNSIGNED_SHORT;\n case Uint32Array:\n return GL.UNSIGNED_INT;\n case Uint8Array:\n return GL.UNSIGNED_BYTE;\n case Uint8ClampedArray:\n return GL.UNSIGNED_BYTE;\n case Int8Array:\n return GL.BYTE;\n case Int16Array:\n return GL.SHORT;\n case Int32Array:\n return GL.INT;\n default:\n throw new Error(ERR_TYPE_DEDUCTION);\n }\n}\n\n/**\n * Converts GL constant to corresponding TYPED ARRAY\n * Used to auto deduce gl parameter types\n * @param {*} glType\n * @param {*} param1\n * @returns\n */\n// eslint-disable-next-line complexity\nexport function getTypedArrayFromGLType(\n glType: any,\n options?: {\n clamped?: boolean;\n }\n): TypedArrayConstructor {\n const {clamped = true} = options || {};\n // Sorted in some order of likelihood to reduce amount of comparisons\n switch (glType) {\n case GL.FLOAT:\n return Float32Array;\n case GL.UNSIGNED_SHORT:\n case GL.UNSIGNED_SHORT_5_6_5:\n case GL.UNSIGNED_SHORT_4_4_4_4:\n case GL.UNSIGNED_SHORT_5_5_5_1:\n return Uint16Array;\n case GL.UNSIGNED_INT:\n return Uint32Array;\n case GL.UNSIGNED_BYTE:\n return clamped ? Uint8ClampedArray : Uint8Array;\n case GL.BYTE:\n return Int8Array;\n case GL.SHORT:\n return Int16Array;\n case GL.INT:\n return Int32Array;\n default:\n throw new Error('Failed to deduce typed array type from GL constant');\n }\n}\n\n/**\n * Flip rows (can be used on arrays returned from `Framebuffer.readPixels`)\n * https: *stackoverflow.com/questions/41969562/\n * how-can-i-flip-the-result-of-webglrenderingcontext-readpixels\n * @param {*} param0\n */\n export function flipRows(options: {\n data: any;\n width: any;\n height: any;\n bytesPerPixel?: number;\n temp?: any;\n}): void {\n const {data, width, height, bytesPerPixel = 4, temp} = options;\n const bytesPerRow = width * bytesPerPixel;\n\n // make a temp buffer to hold one row\n const tempBuffer = temp || new Uint8Array(bytesPerRow);\n for (let y = 0; y < height / 2; ++y) {\n const topOffset = y * bytesPerRow;\n const bottomOffset = (height - y - 1) * bytesPerRow;\n // make copy of a row on the top half\n tempBuffer.set(data.subarray(topOffset, topOffset + bytesPerRow));\n // copy a row from the bottom half to the top\n data.copyWithin(topOffset, bottomOffset, bottomOffset + bytesPerRow);\n // copy the copy of the top half row to the bottom half\n data.set(tempBuffer, bottomOffset);\n }\n}\n\n\nexport function scalePixels(options: {\n data: any;\n width: any;\n height: any;\n}): {\n data: Uint8Array;\n width: number;\n height: number;\n} {\n const {data, width, height} = options;\n const newWidth = Math.round(width / 2);\n const newHeight = Math.round(height / 2);\n const newData = new Uint8Array(newWidth * newHeight * 4);\n for (let y = 0; y < newHeight; y++) {\n for (let x = 0; x < newWidth; x++) {\n for (let c = 0; c < 4; c++) {\n newData[(y * newWidth + x) * 4 + c] = data[(y * 2 * width + x * 2) * 4 + c];\n }\n }\n }\n return {data: newData, width: newWidth, height: newHeight};\n}\n"],"file":"typed-array-utils.js"}
1
+ {"version":3,"file":"typed-array-utils.js","names":["ERR_TYPE_DEDUCTION","getGLTypeFromTypedArray","arrayOrType","type","ArrayBuffer","isView","constructor","Float32Array","Uint16Array","Uint32Array","Uint8Array","Uint8ClampedArray","Int8Array","Int16Array","Int32Array","Error","getTypedArrayFromGLType","glType","options","clamped","flipRows","data","width","height","bytesPerPixel","temp","bytesPerRow","tempBuffer","y","topOffset","bottomOffset","set","subarray","copyWithin","scalePixels","newWidth","Math","round","newHeight","newData","x","c"],"sources":["../../src/classic/typed-array-utils.ts"],"sourcesContent":["// luma.gl, MIT license\n// Copyright (c) vis.gl contributors\n\nimport {TypedArray, TypedArrayConstructor} from '@luma.gl/core';\nimport {GL, GLDataType, GLPixelType} from '@luma.gl/constants';\n\nconst ERR_TYPE_DEDUCTION = 'Failed to deduce GL constant from typed array';\n\n/**\n * Converts TYPED ARRAYS to corresponding GL constant\n * Used to auto deduce gl parameter types\n * @deprecated Use getDataTypeFromTypedArray\n * @param arrayOrType\n * @returns\n */\nexport function getGLTypeFromTypedArray(arrayOrType: TypedArray): GLDataType {\n // If typed array, look up constructor\n const type = ArrayBuffer.isView(arrayOrType) ? arrayOrType.constructor : arrayOrType;\n switch (type) {\n case Float32Array:\n return GL.FLOAT;\n case Uint16Array:\n return GL.UNSIGNED_SHORT;\n case Uint32Array:\n return GL.UNSIGNED_INT;\n case Uint8Array:\n return GL.UNSIGNED_BYTE;\n case Uint8ClampedArray:\n return GL.UNSIGNED_BYTE;\n case Int8Array:\n return GL.BYTE;\n case Int16Array:\n return GL.SHORT;\n case Int32Array:\n return GL.INT;\n default:\n throw new Error(ERR_TYPE_DEDUCTION);\n }\n}\n\n/**\n * Converts GL constant to corresponding TYPED ARRAY\n * Used to auto deduce gl parameter types\n * @deprecated Use getTypedArrayFromDataType\n * @param glType\n * @param param1\n * @returns\n */\n// eslint-disable-next-line complexity\nexport function getTypedArrayFromGLType(\n glType: GLDataType | GLPixelType,\n options?: {\n clamped?: boolean;\n }\n): TypedArrayConstructor {\n const {clamped = true} = options || {};\n // Sorted in some order of likelihood to reduce amount of comparisons\n switch (glType) {\n case GL.FLOAT:\n return Float32Array;\n case GL.UNSIGNED_SHORT:\n case GL.UNSIGNED_SHORT_5_6_5:\n case GL.UNSIGNED_SHORT_4_4_4_4:\n case GL.UNSIGNED_SHORT_5_5_5_1:\n return Uint16Array;\n case GL.UNSIGNED_INT:\n return Uint32Array;\n case GL.UNSIGNED_BYTE:\n return clamped ? Uint8ClampedArray : Uint8Array;\n case GL.BYTE:\n return Int8Array;\n case GL.SHORT:\n return Int16Array;\n case GL.INT:\n return Int32Array;\n default:\n throw new Error('Failed to deduce typed array type from GL constant');\n }\n}\n\n/**\n * Flip rows (can be used on arrays returned from `Framebuffer.readPixels`)\n * https: *stackoverflow.com/questions/41969562/\n * how-can-i-flip-the-result-of-webglrenderingcontext-readpixels\n * @param param0\n */\nexport function flipRows(options: {\n data: TypedArray;\n width: number;\n height: number;\n bytesPerPixel?: number;\n temp?: Uint8Array;\n}): void {\n const {data, width, height, bytesPerPixel = 4, temp} = options;\n const bytesPerRow = width * bytesPerPixel;\n\n // make a temp buffer to hold one row\n const tempBuffer = temp || new Uint8Array(bytesPerRow);\n for (let y = 0; y < height / 2; ++y) {\n const topOffset = y * bytesPerRow;\n const bottomOffset = (height - y - 1) * bytesPerRow;\n // make copy of a row on the top half\n tempBuffer.set(data.subarray(topOffset, topOffset + bytesPerRow));\n // copy a row from the bottom half to the top\n data.copyWithin(topOffset, bottomOffset, bottomOffset + bytesPerRow);\n // copy the copy of the top half row to the bottom half\n data.set(tempBuffer, bottomOffset);\n }\n}\n\n\nexport function scalePixels(options: {\n data: TypedArray;\n width: number;\n height: number;\n}): {\n data: Uint8Array;\n width: number;\n height: number;\n} {\n const {data, width, height} = options;\n const newWidth = Math.round(width / 2);\n const newHeight = Math.round(height / 2);\n const newData = new Uint8Array(newWidth * newHeight * 4);\n for (let y = 0; y < newHeight; y++) {\n for (let x = 0; x < newWidth; x++) {\n for (let c = 0; c < 4; c++) {\n newData[(y * newWidth + x) * 4 + c] = data[(y * 2 * width + x * 2) * 4 + c];\n }\n }\n }\n return {data: newData, width: newWidth, height: newHeight};\n}\n"],"mappings":"AAMA,MAAMA,kBAAkB,GAAG,+CAA+C;AAS1E,OAAO,SAASC,uBAAuBA,CAACC,WAAuB,EAAc;EAE3E,MAAMC,IAAI,GAAGC,WAAW,CAACC,MAAM,CAACH,WAAW,CAAC,GAAGA,WAAW,CAACI,WAAW,GAAGJ,WAAW;EACpF,QAAQC,IAAI;IACV,KAAKI,YAAY;MACf;IACF,KAAKC,WAAW;MACd;IACF,KAAKC,WAAW;MACd;IACF,KAAKC,UAAU;MACb;IACF,KAAKC,iBAAiB;MACpB;IACF,KAAKC,SAAS;MACZ;IACF,KAAKC,UAAU;MACb;IACF,KAAKC,UAAU;MACb;IACF;MACE,MAAM,IAAIC,KAAK,CAACf,kBAAkB,CAAC;EACvC;AACF;AAWA,OAAO,SAASgB,uBAAuBA,CACrCC,MAAgC,EAChCC,OAEC,EACsB;EACvB,MAAM;IAACC,OAAO,GAAG;EAAI,CAAC,GAA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KAAK,CAACf,KAAK,GAAG,CAAC,CAAC;EACtC,MAAMgB,SAAS,GAAGF,IAAI,CAACC,KAAK,CAACd,MAAM,GAAG,CAAC,CAAC;EACxC,MAAMgB,OAAO,GAAG,IAAI7B,UAAU,CAACyB,QAAQ,GAAGG,SAAS,GAAG,CAAC,CAAC;EACxD,KAAK,IAAIV,CAAC,GAAG,CAAC,EAAEA,CAAC,GAAGU,SAAS,EAAEV,CAAC,EAAE,EAAE;IAClC,KAAK,IAAIY,CAAC,GAAG,CAAC,EAAEA,CAAC,GAAGL,QAAQ,EAAEK,CAAC,EAAE,EAAE;MACjC,KAAK,IAAIC,CAAC,GAAG,CAAC,EAAEA,CAAC,GAAG,CAAC,EAAEA,CAAC,EAAE,EAAE;QAC1BF,OAAO,CAAC,CAACX,CAAC,GAAGO,QAAQ,GAAGK,CAAC,IAAI,CAAC,GAAGC,CAAC,CAAC,GAAGpB,IAAI,CAAC,CAACO,CAAC,GAAG,CAAC,GAAGN,KAAK,GAAGkB,CAAC,GAAG,CAAC,IAAI,CAAC,GAAGC,CAAC,CAAC;MAC7E;IACF;EACF;EACA,OAAO;IAACpB,IAAI,EAAEkB,OAAO;IAAEjB,KAAK,EAAEa,QAAQ;IAAEZ,MAAM,EAAEe;EAAS,CAAC;AAC5D"}
@@ -1,22 +1,21 @@
1
- /// <reference types="offscreencanvas" />
2
1
  /**
3
2
  * ContextProps
4
- * @param webgl2 Set to false to not create a WebGL2 context (force webgl1)
5
- * @param webgl1 set to false to not create a WebGL1 context (fail if webgl2 not available)
6
- * @param onContextLost
7
- * @param onContextRestored
8
- *
9
- * BROWSER CONTEXT PARAMETERS
10
- * @param debug Instrument context (at the expense of performance).
11
- * @param alpha Default render target has an alpha buffer.
12
- * @param depth Default render target has a depth buffer of at least 16 bits.
13
- * @param stencil Default render target has a stencil buffer of at least 8 bits.
14
- * @param antialias Boolean that indicates whether or not to perform anti-aliasing.
15
- * @param premultipliedAlpha Boolean that indicates that the page compositor will assume the drawing buffer contains colors with pre-multiplied alpha.
16
- * @param preserveDrawingBuffer Default render target buffers will not be automatically cleared and will preserve their values until cleared or overwritten
17
- * @param failIfMajorPerformanceCaveat Do not create if the system performance is low.
18
- */
19
- declare type ContextProps = {
3
+ * @param webgl2 Set to false to not create a WebGL2 context (force webgl1)
4
+ * @param webgl1 set to false to not create a WebGL1 context (fail if webgl2 not available)
5
+ * @param onContextLost
6
+ * @param onContextRestored
7
+ *
8
+ * BROWSER CONTEXT PARAMETERS
9
+ * @param debug Instrument context (at the expense of performance).
10
+ * @param alpha Default render target has an alpha buffer.
11
+ * @param depth Default render target has a depth buffer of at least 16 bits.
12
+ * @param stencil Default render target has a stencil buffer of at least 8 bits.
13
+ * @param antialias Boolean that indicates whether or not to perform anti-aliasing.
14
+ * @param premultipliedAlpha Boolean that indicates that the page compositor will assume the drawing buffer contains colors with pre-multiplied alpha.
15
+ * @param preserveDrawingBuffer Default render target buffers will not be automatically cleared and will preserve their values until cleared or overwritten
16
+ * @param failIfMajorPerformanceCaveat Do not create if the system performance is low.
17
+ */
18
+ type ContextProps = {
20
19
  type?: 'webgl' | 'webgl1' | 'webgl2' | string;
21
20
  webgl1?: boolean;
22
21
  webgl2?: boolean;
@@ -34,7 +33,7 @@ declare type ContextProps = {
34
33
  /**
35
34
  * Create a WebGL context for a canvas
36
35
  * Note calling this multiple time on the same canvas does return the same context
37
- * @param canvas A canvas element or offscreen canvas
36
+ * @param canvas A canvas element or offscreen canvas
38
37
  */
39
38
  export declare function createBrowserContext(canvas: HTMLCanvasElement | OffscreenCanvas, props: ContextProps): WebGLRenderingContext;
40
39
  export {};
@@ -1 +1 @@
1
- {"version":3,"file":"create-browser-context.d.ts","sourceRoot":"","sources":["../../../src/context/context/create-browser-context.ts"],"names":[],"mappings":";AAEA;;;;;;;;;;;;;;;;EAgBE;AACF,aAAK,YAAY,GAAG;IAClB,IAAI,CAAC,EAAE,OAAO,GAAG,QAAQ,GAAG,QAAQ,GAAG,MAAM,CAAC;IAC9C,MAAM,CAAC,EAAE,OAAO,CAAC;IACjB,MAAM,CAAC,EAAE,OAAO,CAAC;IACjB,aAAa,CAAC,EAAE,CAAC,KAAK,EAAE,KAAK,KAAK,IAAI,CAAC;IACvC,iBAAiB,CAAC,EAAE,CAAC,KAAK,EAAE,KAAK,KAAK,IAAI,CAAC;IAC3C,KAAK,CAAC,EAAE,OAAO,CAAC;IAChB,cAAc,CAAC,EAAE,OAAO,CAAC;IACzB,SAAS,CAAC,EAAE,OAAO,CAAC;IACpB,KAAK,CAAC,EAAE,OAAO,CAAC;IAChB,4BAA4B,CAAC,EAAE,OAAO,CAAC;IACvC,eAAe,CAAC,EAAE,SAAS,GAAI,kBAAkB,GAAG,WAAW,CAAC;IAChE,kBAAkB,CAAC,EAAE,OAAO,CAAC;IAC7B,qBAAqB,CAAC,EAAE,OAAO,CAAA;CAChC,CAAC;AAUF;;;;GAIG;AACF,wBAAgB,oBAAoB,CAAC,MAAM,EAAE,iBAAiB,GAAG,eAAe,EAAE,KAAK,EAAE,YAAY,GAAG,qBAAqB,CAiD7H"}
1
+ {"version":3,"file":"create-browser-context.d.ts","sourceRoot":"","sources":["../../../src/context/context/create-browser-context.ts"],"names":[],"mappings":"AAGA;;;;;;;;;;;;;;;;GAgBG;AACH,KAAK,YAAY,GAAG;IAClB,IAAI,CAAC,EAAE,OAAO,GAAG,QAAQ,GAAG,QAAQ,GAAG,MAAM,CAAC;IAC9C,MAAM,CAAC,EAAE,OAAO,CAAC;IACjB,MAAM,CAAC,EAAE,OAAO,CAAC;IACjB,aAAa,CAAC,EAAE,CAAC,KAAK,EAAE,KAAK,KAAK,IAAI,CAAC;IACvC,iBAAiB,CAAC,EAAE,CAAC,KAAK,EAAE,KAAK,KAAK,IAAI,CAAC;IAC3C,KAAK,CAAC,EAAE,OAAO,CAAC;IAChB,cAAc,CAAC,EAAE,OAAO,CAAC;IACzB,SAAS,CAAC,EAAE,OAAO,CAAC;IACpB,KAAK,CAAC,EAAE,OAAO,CAAC;IAChB,4BAA4B,CAAC,EAAE,OAAO,CAAC;IACvC,eAAe,CAAC,EAAE,SAAS,GAAG,kBAAkB,GAAG,WAAW,CAAC;IAC/D,kBAAkB,CAAC,EAAE,OAAO,CAAC;IAC7B,qBAAqB,CAAC,EAAE,OAAO,CAAC;CACjC,CAAC;AAYF;;;;GAIG;AACH,wBAAgB,oBAAoB,CAClC,MAAM,EAAE,iBAAiB,GAAG,eAAe,EAC3C,KAAK,EAAE,YAAY,GAClB,qBAAqB,CAiEvB"}
@@ -6,56 +6,48 @@ const DEFAULT_CONTEXT_PROPS = {
6
6
  onContextRestored: () => console.info('WebGL context restored')
7
7
  };
8
8
  export function createBrowserContext(canvas, props) {
9
- props = { ...DEFAULT_CONTEXT_PROPS,
9
+ props = {
10
+ ...DEFAULT_CONTEXT_PROPS,
10
11
  ...props
11
12
  };
12
13
  let errorMessage = null;
13
-
14
14
  const onCreateError = error => errorMessage = error.statusMessage || errorMessage;
15
-
16
15
  canvas.addEventListener('webglcontextcreationerror', onCreateError, false);
17
16
  let gl = null;
18
-
19
17
  if (props.type === 'webgl2') {
20
- props = { ...props,
18
+ props = {
19
+ ...props,
21
20
  webgl1: false
22
21
  };
23
22
  }
24
-
25
23
  if (props.type === 'webgl1') {
26
- props = { ...props,
24
+ props = {
25
+ ...props,
27
26
  webgl2: false
28
27
  };
29
28
  }
30
-
31
- if (props.webgl2) {
32
- gl = gl || canvas.getContext('webgl2', props);
29
+ if (!gl && props.webgl2) {
30
+ gl = canvas.getContext('webgl2', props);
33
31
  }
34
-
35
- if (props.webgl1) {
36
- gl = gl || canvas.getContext('webgl', props);
32
+ if (!gl && props.webgl1) {
33
+ gl = canvas.getContext('webgl', props);
37
34
  }
38
-
39
35
  canvas.removeEventListener('webglcontextcreationerror', onCreateError, false);
40
-
41
36
  if (!gl) {
42
- throw new Error("Failed to create ".concat(props.webgl2 && !props.webgl1 ? 'WebGL2' : 'WebGL', " context: ").concat(errorMessage || 'Unknown error'));
37
+ throw new Error(`Failed to create ${props.webgl2 && !props.webgl1 ? 'WebGL2' : 'WebGL'} context: ${errorMessage || 'Unknown error'}`);
43
38
  }
44
-
45
39
  if (props.onContextLost) {
46
40
  const {
47
41
  onContextLost
48
42
  } = props;
49
43
  canvas.addEventListener('webglcontextlost', event => onContextLost(event), false);
50
44
  }
51
-
52
45
  if (props.onContextRestored) {
53
46
  const {
54
47
  onContextRestored
55
48
  } = props;
56
49
  canvas.addEventListener('webglcontextrestored', event => onContextRestored(event), false);
57
50
  }
58
-
59
51
  return gl;
60
52
  }
61
53
  //# sourceMappingURL=create-browser-context.js.map