@luma.gl/webgl 9.0.0-alpha.2 → 9.0.0-alpha.20

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 (454) hide show
  1. package/dist/adapter/converters/device-parameters.d.ts +11 -1
  2. package/dist/adapter/converters/device-parameters.d.ts.map +1 -1
  3. package/dist/adapter/converters/device-parameters.js +17 -35
  4. package/dist/adapter/converters/device-parameters.js.map +1 -1
  5. package/dist/adapter/converters/renderbuffer-formats.js +1 -5
  6. package/dist/adapter/converters/renderbuffer-formats.js.map +1 -1
  7. package/dist/adapter/converters/sampler-parameters.d.ts +4 -4
  8. package/dist/adapter/converters/sampler-parameters.d.ts.map +1 -1
  9. package/dist/adapter/converters/sampler-parameters.js +19 -55
  10. package/dist/adapter/converters/sampler-parameters.js.map +1 -1
  11. package/dist/adapter/converters/texture-formats.d.ts.map +1 -1
  12. package/dist/adapter/converters/texture-formats.js +13 -66
  13. package/dist/adapter/converters/texture-formats.js.map +1 -1
  14. package/dist/adapter/converters/vertex-formats.d.ts.map +1 -1
  15. package/dist/adapter/converters/vertex-formats.js +2 -8
  16. package/dist/adapter/converters/vertex-formats.js.map +1 -1
  17. package/dist/adapter/device-helpers/device-features.d.ts.map +1 -1
  18. package/dist/adapter/device-helpers/device-features.js +13 -20
  19. package/dist/adapter/device-helpers/device-features.js.map +1 -1
  20. package/dist/adapter/device-helpers/device-limits.js +1 -4
  21. package/dist/adapter/device-helpers/device-limits.js.map +1 -1
  22. package/dist/adapter/device-helpers/get-device-info.js +8 -10
  23. package/dist/adapter/device-helpers/get-device-info.js.map +1 -1
  24. package/dist/adapter/device-helpers/is-old-ie.js +2 -1
  25. package/dist/adapter/device-helpers/is-old-ie.js.map +1 -1
  26. package/dist/adapter/helpers/attribute-utils.js +0 -17
  27. package/dist/adapter/helpers/attribute-utils.js.map +1 -1
  28. package/dist/adapter/helpers/get-shader-info.d.ts +9 -0
  29. package/dist/adapter/helpers/get-shader-info.d.ts.map +1 -0
  30. package/dist/adapter/helpers/get-shader-info.js +25 -0
  31. package/dist/adapter/helpers/get-shader-info.js.map +1 -0
  32. package/dist/adapter/helpers/get-shader-layout.d.ts +1 -1
  33. package/dist/adapter/helpers/get-shader-layout.d.ts.map +1 -1
  34. package/dist/adapter/helpers/get-shader-layout.js +41 -67
  35. package/dist/adapter/helpers/get-shader-layout.js.map +1 -1
  36. package/dist/adapter/helpers/parse-shader-compiler-log.d.ts +1 -1
  37. package/dist/adapter/helpers/parse-shader-compiler-log.d.ts.map +1 -1
  38. package/dist/adapter/helpers/parse-shader-compiler-log.js +0 -7
  39. package/dist/adapter/helpers/parse-shader-compiler-log.js.map +1 -1
  40. package/dist/adapter/helpers/set-uniform.d.ts.map +1 -1
  41. package/dist/adapter/helpers/set-uniform.js +1 -31
  42. package/dist/adapter/helpers/set-uniform.js.map +1 -1
  43. package/dist/adapter/helpers/uniforms.d.ts +1 -1
  44. package/dist/adapter/helpers/uniforms.d.ts.map +1 -1
  45. package/dist/adapter/helpers/uniforms.js +4 -14
  46. package/dist/adapter/helpers/uniforms.js.map +1 -1
  47. package/dist/adapter/objects/constants-to-keys.d.ts.map +1 -1
  48. package/dist/adapter/objects/constants-to-keys.js +0 -7
  49. package/dist/adapter/objects/constants-to-keys.js.map +1 -1
  50. package/dist/adapter/objects/webgl-renderbuffer.d.ts.map +1 -1
  51. package/dist/adapter/objects/webgl-renderbuffer.js +5 -21
  52. package/dist/adapter/objects/webgl-renderbuffer.js.map +1 -1
  53. package/dist/adapter/objects/webgl-resource.d.ts +2 -4
  54. package/dist/adapter/objects/webgl-resource.d.ts.map +1 -1
  55. package/dist/adapter/objects/webgl-resource.js +14 -67
  56. package/dist/adapter/objects/webgl-resource.js.map +1 -1
  57. package/dist/adapter/objects/webgl-vertex-array-object.d.ts +1 -1
  58. package/dist/adapter/objects/webgl-vertex-array-object.d.ts.map +1 -1
  59. package/dist/adapter/objects/webgl-vertex-array-object.js +6 -16
  60. package/dist/adapter/objects/webgl-vertex-array-object.js.map +1 -1
  61. package/dist/adapter/resources/webgl-buffer.d.ts +1 -2
  62. package/dist/adapter/resources/webgl-buffer.d.ts.map +1 -1
  63. package/dist/adapter/resources/webgl-buffer.js +17 -48
  64. package/dist/adapter/resources/webgl-buffer.js.map +1 -1
  65. package/dist/adapter/resources/webgl-command-buffer.js +2 -17
  66. package/dist/adapter/resources/webgl-command-buffer.js.map +1 -1
  67. package/dist/adapter/resources/webgl-command-encoder.d.ts.map +1 -1
  68. package/dist/adapter/resources/webgl-command-encoder.js +1 -14
  69. package/dist/adapter/resources/webgl-command-encoder.js.map +1 -1
  70. package/dist/adapter/resources/webgl-external-texture.js.map +1 -1
  71. package/dist/adapter/resources/webgl-framebuffer.d.ts +1 -1
  72. package/dist/adapter/resources/webgl-framebuffer.d.ts.map +1 -1
  73. package/dist/adapter/resources/webgl-framebuffer.js +9 -67
  74. package/dist/adapter/resources/webgl-framebuffer.js.map +1 -1
  75. package/dist/adapter/resources/webgl-render-pass.d.ts +1 -1
  76. package/dist/adapter/resources/webgl-render-pass.d.ts.map +1 -1
  77. package/dist/adapter/resources/webgl-render-pass.js +2 -7
  78. package/dist/adapter/resources/webgl-render-pass.js.map +1 -1
  79. package/dist/adapter/resources/webgl-render-pipeline.d.ts +1 -1
  80. package/dist/adapter/resources/webgl-render-pipeline.d.ts.map +1 -1
  81. package/dist/adapter/resources/webgl-render-pipeline.js +50 -139
  82. package/dist/adapter/resources/webgl-render-pipeline.js.map +1 -1
  83. package/dist/adapter/resources/webgl-sampler.d.ts +3 -2
  84. package/dist/adapter/resources/webgl-sampler.d.ts.map +1 -1
  85. package/dist/adapter/resources/webgl-sampler.js +4 -12
  86. package/dist/adapter/resources/webgl-sampler.js.map +1 -1
  87. package/dist/adapter/resources/webgl-shader.d.ts +1 -2
  88. package/dist/adapter/resources/webgl-shader.d.ts.map +1 -1
  89. package/dist/adapter/resources/webgl-shader.js +7 -20
  90. package/dist/adapter/resources/webgl-shader.js.map +1 -1
  91. package/dist/adapter/resources/webgl-texture.d.ts +23 -23
  92. package/dist/adapter/resources/webgl-texture.d.ts.map +1 -1
  93. package/dist/adapter/resources/webgl-texture.js +65 -182
  94. package/dist/adapter/resources/webgl-texture.js.map +1 -1
  95. package/dist/adapter/webgl-canvas-context.d.ts.map +1 -1
  96. package/dist/adapter/webgl-canvas-context.js +5 -18
  97. package/dist/adapter/webgl-canvas-context.js.map +1 -1
  98. package/dist/adapter/webgl-device.d.ts +45 -29
  99. package/dist/adapter/webgl-device.d.ts.map +1 -1
  100. package/dist/adapter/webgl-device.js +107 -108
  101. package/dist/adapter/webgl-device.js.map +1 -1
  102. package/dist/classic/accessor.d.ts.map +1 -1
  103. package/dist/classic/accessor.js +11 -35
  104. package/dist/classic/accessor.js.map +1 -1
  105. package/dist/classic/buffer.d.ts +0 -1
  106. package/dist/classic/buffer.d.ts.map +1 -1
  107. package/dist/classic/buffer.js +29 -86
  108. package/dist/classic/buffer.js.map +1 -1
  109. package/dist/classic/typed-array-utils.d.ts +1 -1
  110. package/dist/classic/typed-array-utils.d.ts.map +1 -1
  111. package/dist/classic/typed-array-utils.js +0 -20
  112. package/dist/classic/typed-array-utils.js.map +1 -1
  113. package/dist/context/context/{create-context.d.ts → create-browser-context.d.ts} +2 -1
  114. package/dist/context/context/create-browser-context.d.ts.map +1 -0
  115. package/dist/context/context/{create-context.js → create-browser-context.js} +19 -15
  116. package/dist/context/context/create-browser-context.js.map +1 -0
  117. package/dist/context/context/create-headless-context.d.ts +9 -0
  118. package/dist/context/context/create-headless-context.d.ts.map +1 -0
  119. package/dist/context/context/create-headless-context.js +42 -0
  120. package/dist/context/context/create-headless-context.js.map +1 -0
  121. package/dist/context/context/webgl-checks.js +0 -3
  122. package/dist/context/context/webgl-checks.js.map +1 -1
  123. package/dist/context/debug/spector.d.ts +1 -0
  124. package/dist/context/debug/spector.d.ts.map +1 -1
  125. package/dist/context/debug/spector.js +7 -19
  126. package/dist/context/debug/spector.js.map +1 -1
  127. package/dist/context/debug/webgl-developer-tools.d.ts +1 -1
  128. package/dist/context/debug/webgl-developer-tools.d.ts.map +1 -1
  129. package/dist/context/debug/webgl-developer-tools.js +8 -32
  130. package/dist/context/debug/webgl-developer-tools.js.map +1 -1
  131. package/dist/context/parameters/unified-parameter-api.d.ts +6 -5
  132. package/dist/context/parameters/unified-parameter-api.d.ts.map +1 -1
  133. package/dist/context/parameters/unified-parameter-api.js +8 -18
  134. package/dist/context/parameters/unified-parameter-api.js.map +1 -1
  135. package/dist/context/parameters/webgl-parameter-tables.d.ts +103 -103
  136. package/dist/context/parameters/webgl-parameter-tables.d.ts.map +1 -1
  137. package/dist/context/parameters/webgl-parameter-tables.js +16 -34
  138. package/dist/context/parameters/webgl-parameter-tables.js.map +1 -1
  139. package/dist/context/polyfill/context-data.d.ts +13 -0
  140. package/dist/context/polyfill/context-data.d.ts.map +1 -0
  141. package/dist/context/polyfill/context-data.js +12 -0
  142. package/dist/context/polyfill/context-data.js.map +1 -0
  143. package/dist/context/polyfill/get-parameter-polyfill.d.ts +1 -1
  144. package/dist/context/polyfill/get-parameter-polyfill.d.ts.map +1 -1
  145. package/dist/context/polyfill/get-parameter-polyfill.js +1 -6
  146. package/dist/context/polyfill/get-parameter-polyfill.js.map +1 -1
  147. package/dist/context/polyfill/polyfill-context.js +20 -28
  148. package/dist/context/polyfill/polyfill-context.js.map +1 -1
  149. package/dist/context/polyfill/polyfill-table.d.ts +8 -8
  150. package/dist/context/polyfill/polyfill-table.d.ts.map +1 -1
  151. package/dist/context/polyfill/polyfill-table.js +8 -30
  152. package/dist/context/polyfill/polyfill-table.js.map +1 -1
  153. package/dist/context/polyfill/polyfill-vertex-array-object.d.ts.map +1 -1
  154. package/dist/context/polyfill/polyfill-vertex-array-object.js +0 -70
  155. package/dist/context/polyfill/polyfill-vertex-array-object.js.map +1 -1
  156. package/dist/context/state-tracker/deep-array-equal.js +0 -4
  157. package/dist/context/state-tracker/deep-array-equal.js.map +1 -1
  158. package/dist/context/state-tracker/track-context-state.d.ts.map +1 -1
  159. package/dist/context/state-tracker/track-context-state.js +15 -50
  160. package/dist/context/state-tracker/track-context-state.js.map +1 -1
  161. package/dist/context/state-tracker/with-parameters.d.ts +2 -1
  162. package/dist/context/state-tracker/with-parameters.d.ts.map +1 -1
  163. package/dist/context/state-tracker/with-parameters.js +7 -9
  164. package/dist/context/state-tracker/with-parameters.js.map +1 -1
  165. package/dist/dist.dev.js +9205 -0
  166. package/dist/index.cjs +5948 -0
  167. package/dist/index.d.ts +6 -6
  168. package/dist/index.d.ts.map +1 -1
  169. package/dist/index.js +24 -26
  170. package/dist/index.js.map +1 -1
  171. package/dist/types/webgl.d.ts +8 -7
  172. package/dist/types/webgl.d.ts.map +1 -1
  173. package/dist/types/webgl.js.map +1 -1
  174. package/dist/types.js.map +1 -1
  175. package/dist.min.js +36 -0
  176. package/package.json +18 -9
  177. package/src/adapter/converters/device-parameters.ts +44 -15
  178. package/src/adapter/converters/sampler-parameters.ts +18 -7
  179. package/src/adapter/converters/texture-formats.ts +18 -16
  180. package/src/adapter/converters/vertex-formats.ts +1 -0
  181. package/src/adapter/device-helpers/device-features.ts +9 -2
  182. package/src/adapter/device-helpers/device-limits.ts +1 -1
  183. package/src/adapter/device-helpers/get-device-info.ts +12 -8
  184. package/src/adapter/helpers/get-shader-info.ts +37 -0
  185. package/src/adapter/helpers/get-shader-layout.ts +58 -36
  186. package/src/adapter/helpers/parse-shader-compiler-log.ts +2 -2
  187. package/src/adapter/helpers/set-uniform.ts +3 -1
  188. package/src/adapter/helpers/uniforms.ts +21 -10
  189. package/src/adapter/objects/constants-to-keys.ts +4 -1
  190. package/src/adapter/objects/webgl-renderbuffer.ts +5 -5
  191. package/src/adapter/objects/webgl-resource.ts +7 -12
  192. package/src/adapter/objects/webgl-vertex-array-object.ts +5 -5
  193. package/src/adapter/resources/webgl-buffer.ts +14 -14
  194. package/src/adapter/resources/webgl-command-encoder.ts +5 -5
  195. package/src/adapter/resources/webgl-framebuffer.ts +14 -11
  196. package/src/adapter/resources/webgl-render-pass.ts +2 -1
  197. package/src/adapter/resources/webgl-render-pipeline.ts +83 -71
  198. package/src/adapter/resources/webgl-sampler.ts +10 -4
  199. package/src/adapter/resources/webgl-shader.ts +9 -8
  200. package/src/adapter/resources/webgl-texture.ts +51 -41
  201. package/src/adapter/webgl-canvas-context.ts +5 -6
  202. package/src/adapter/webgl-device.ts +144 -60
  203. package/src/classic/accessor.ts +1 -14
  204. package/src/classic/buffer.ts +14 -21
  205. package/src/classic/typed-array-utils.ts +4 -2
  206. package/src/context/context/{create-context.ts → create-browser-context.ts} +17 -7
  207. package/src/context/context/create-headless-context.ts +48 -0
  208. package/src/context/debug/spector.ts +6 -5
  209. package/src/context/debug/webgl-developer-tools.ts +13 -13
  210. package/src/context/parameters/unified-parameter-api.ts +17 -11
  211. package/src/context/parameters/webgl-parameter-tables.ts +113 -94
  212. package/src/context/polyfill/context-data.ts +27 -0
  213. package/src/context/polyfill/get-parameter-polyfill.ts +7 -6
  214. package/src/context/polyfill/polyfill-context.ts +6 -8
  215. package/src/context/polyfill/polyfill-table.ts +16 -14
  216. package/src/context/polyfill/polyfill-vertex-array-object.ts +2 -0
  217. package/src/context/state-tracker/track-context-state.ts +13 -12
  218. package/src/context/state-tracker/with-parameters.ts +8 -2
  219. package/src/index.ts +14 -12
  220. package/src/types/webgl.ts +10 -7
  221. package/dist/bundle.d.ts +0 -2
  222. package/dist/bundle.d.ts.map +0 -1
  223. package/dist/bundle.js +0 -5
  224. package/dist/bundle.js.map +0 -1
  225. package/dist/context/context/context-state.d.ts +0 -18
  226. package/dist/context/context/context-state.d.ts.map +0 -1
  227. package/dist/context/context/context-state.js +0 -26
  228. package/dist/context/context/context-state.js.map +0 -1
  229. package/dist/context/context/create-context.d.ts.map +0 -1
  230. package/dist/context/context/create-context.js.map +0 -1
  231. package/dist/context/context/device-pixels.d.ts +0 -25
  232. package/dist/context/context/device-pixels.d.ts.map +0 -1
  233. package/dist/context/context/device-pixels.js +0 -98
  234. package/dist/context/context/device-pixels.js.map +0 -1
  235. package/dist/es5/adapter/converters/device-parameters.js +0 -170
  236. package/dist/es5/adapter/converters/device-parameters.js.map +0 -1
  237. package/dist/es5/adapter/converters/renderbuffer-formats.js +0 -163
  238. package/dist/es5/adapter/converters/renderbuffer-formats.js.map +0 -1
  239. package/dist/es5/adapter/converters/sampler-parameters.js +0 -226
  240. package/dist/es5/adapter/converters/sampler-parameters.js.map +0 -1
  241. package/dist/es5/adapter/converters/texture-formats.js +0 -1031
  242. package/dist/es5/adapter/converters/texture-formats.js.map +0 -1
  243. package/dist/es5/adapter/converters/vertex-formats.js +0 -45
  244. package/dist/es5/adapter/converters/vertex-formats.js.map +0 -1
  245. package/dist/es5/adapter/device-helpers/device-features.js +0 -144
  246. package/dist/es5/adapter/device-helpers/device-features.js.map +0 -1
  247. package/dist/es5/adapter/device-helpers/device-limits.js +0 -64
  248. package/dist/es5/adapter/device-helpers/device-limits.js.map +0 -1
  249. package/dist/es5/adapter/device-helpers/get-device-info.js +0 -55
  250. package/dist/es5/adapter/device-helpers/get-device-info.js.map +0 -1
  251. package/dist/es5/adapter/device-helpers/is-old-ie.js +0 -16
  252. package/dist/es5/adapter/device-helpers/is-old-ie.js.map +0 -1
  253. package/dist/es5/adapter/helpers/attribute-utils.js +0 -91
  254. package/dist/es5/adapter/helpers/attribute-utils.js.map +0 -1
  255. package/dist/es5/adapter/helpers/get-shader-layout.js +0 -371
  256. package/dist/es5/adapter/helpers/get-shader-layout.js.map +0 -1
  257. package/dist/es5/adapter/helpers/parse-shader-compiler-log.js +0 -72
  258. package/dist/es5/adapter/helpers/parse-shader-compiler-log.js.map +0 -1
  259. package/dist/es5/adapter/helpers/set-uniform.js +0 -125
  260. package/dist/es5/adapter/helpers/set-uniform.js.map +0 -1
  261. package/dist/es5/adapter/helpers/uniforms.js +0 -112
  262. package/dist/es5/adapter/helpers/uniforms.js.map +0 -1
  263. package/dist/es5/adapter/objects/constants-to-keys.js +0 -54
  264. package/dist/es5/adapter/objects/constants-to-keys.js.map +0 -1
  265. package/dist/es5/adapter/objects/webgl-renderbuffer.js +0 -150
  266. package/dist/es5/adapter/objects/webgl-renderbuffer.js.map +0 -1
  267. package/dist/es5/adapter/objects/webgl-resource.js +0 -292
  268. package/dist/es5/adapter/objects/webgl-resource.js.map +0 -1
  269. package/dist/es5/adapter/objects/webgl-vertex-array-object.js +0 -137
  270. package/dist/es5/adapter/objects/webgl-vertex-array-object.js.map +0 -1
  271. package/dist/es5/adapter/resources/webgl-buffer.js +0 -243
  272. package/dist/es5/adapter/resources/webgl-buffer.js.map +0 -1
  273. package/dist/es5/adapter/resources/webgl-command-buffer.js +0 -96
  274. package/dist/es5/adapter/resources/webgl-command-buffer.js.map +0 -1
  275. package/dist/es5/adapter/resources/webgl-command-encoder.js +0 -98
  276. package/dist/es5/adapter/resources/webgl-command-encoder.js.map +0 -1
  277. package/dist/es5/adapter/resources/webgl-external-texture.js +0 -2
  278. package/dist/es5/adapter/resources/webgl-external-texture.js.map +0 -1
  279. package/dist/es5/adapter/resources/webgl-framebuffer.js +0 -345
  280. package/dist/es5/adapter/resources/webgl-framebuffer.js.map +0 -1
  281. package/dist/es5/adapter/resources/webgl-render-pass.js +0 -61
  282. package/dist/es5/adapter/resources/webgl-render-pass.js.map +0 -1
  283. package/dist/es5/adapter/resources/webgl-render-pipeline.js +0 -505
  284. package/dist/es5/adapter/resources/webgl-render-pipeline.js.map +0 -1
  285. package/dist/es5/adapter/resources/webgl-sampler.js +0 -96
  286. package/dist/es5/adapter/resources/webgl-sampler.js.map +0 -1
  287. package/dist/es5/adapter/resources/webgl-shader.js +0 -149
  288. package/dist/es5/adapter/resources/webgl-shader.js.map +0 -1
  289. package/dist/es5/adapter/resources/webgl-texture.js +0 -986
  290. package/dist/es5/adapter/resources/webgl-texture.js.map +0 -1
  291. package/dist/es5/adapter/webgl-canvas-context.js +0 -97
  292. package/dist/es5/adapter/webgl-canvas-context.js.map +0 -1
  293. package/dist/es5/adapter/webgl-device.js +0 -399
  294. package/dist/es5/adapter/webgl-device.js.map +0 -1
  295. package/dist/es5/bundle.js +0 -7
  296. package/dist/es5/bundle.js.map +0 -1
  297. package/dist/es5/classic/accessor.js +0 -181
  298. package/dist/es5/classic/accessor.js.map +0 -1
  299. package/dist/es5/classic/buffer.js +0 -470
  300. package/dist/es5/classic/buffer.js.map +0 -1
  301. package/dist/es5/classic/typed-array-utils.js +0 -126
  302. package/dist/es5/classic/typed-array-utils.js.map +0 -1
  303. package/dist/es5/context/context/context-state.js +0 -31
  304. package/dist/es5/context/context/context-state.js.map +0 -1
  305. package/dist/es5/context/context/create-context.js +0 -69
  306. package/dist/es5/context/context/create-context.js.map +0 -1
  307. package/dist/es5/context/context/device-pixels.js +0 -115
  308. package/dist/es5/context/context/device-pixels.js.map +0 -1
  309. package/dist/es5/context/context/webgl-checks.js +0 -54
  310. package/dist/es5/context/context/webgl-checks.js.map +0 -1
  311. package/dist/es5/context/debug/spector.js +0 -133
  312. package/dist/es5/context/debug/spector.js.map +0 -1
  313. package/dist/es5/context/debug/webgl-developer-tools.js +0 -198
  314. package/dist/es5/context/debug/webgl-developer-tools.js.map +0 -1
  315. package/dist/es5/context/parameters/unified-parameter-api.js +0 -97
  316. package/dist/es5/context/parameters/unified-parameter-api.js.map +0 -1
  317. package/dist/es5/context/parameters/webgl-parameter-tables.js +0 -392
  318. package/dist/es5/context/parameters/webgl-parameter-tables.js.map +0 -1
  319. package/dist/es5/context/polyfill/get-parameter-polyfill.js +0 -81
  320. package/dist/es5/context/polyfill/get-parameter-polyfill.js.map +0 -1
  321. package/dist/es5/context/polyfill/polyfill-context.js +0 -135
  322. package/dist/es5/context/polyfill/polyfill-context.js.map +0 -1
  323. package/dist/es5/context/polyfill/polyfill-table.js +0 -166
  324. package/dist/es5/context/polyfill/polyfill-table.js.map +0 -1
  325. package/dist/es5/context/polyfill/polyfill-vertex-array-object.js +0 -341
  326. package/dist/es5/context/polyfill/polyfill-vertex-array-object.js.map +0 -1
  327. package/dist/es5/context/state-tracker/deep-array-equal.js +0 -28
  328. package/dist/es5/context/state-tracker/deep-array-equal.js.map +0 -1
  329. package/dist/es5/context/state-tracker/track-context-state.js +0 -211
  330. package/dist/es5/context/state-tracker/track-context-state.js.map +0 -1
  331. package/dist/es5/context/state-tracker/with-parameters.js +0 -44
  332. package/dist/es5/context/state-tracker/with-parameters.js.map +0 -1
  333. package/dist/es5/index.js +0 -276
  334. package/dist/es5/index.js.map +0 -1
  335. package/dist/es5/init.js +0 -10
  336. package/dist/es5/init.js.map +0 -1
  337. package/dist/es5/types/webgl.js +0 -6
  338. package/dist/es5/types/webgl.js.map +0 -1
  339. package/dist/es5/types.js +0 -2
  340. package/dist/es5/types.js.map +0 -1
  341. package/dist/esm/adapter/converters/device-parameters.js +0 -155
  342. package/dist/esm/adapter/converters/device-parameters.js.map +0 -1
  343. package/dist/esm/adapter/converters/renderbuffer-formats.js +0 -185
  344. package/dist/esm/adapter/converters/renderbuffer-formats.js.map +0 -1
  345. package/dist/esm/adapter/converters/sampler-parameters.js +0 -208
  346. package/dist/esm/adapter/converters/sampler-parameters.js.map +0 -1
  347. package/dist/esm/adapter/converters/texture-formats.js +0 -954
  348. package/dist/esm/adapter/converters/texture-formats.js.map +0 -1
  349. package/dist/esm/adapter/converters/vertex-formats.js +0 -35
  350. package/dist/esm/adapter/converters/vertex-formats.js.map +0 -1
  351. package/dist/esm/adapter/device-helpers/device-features.js +0 -102
  352. package/dist/esm/adapter/device-helpers/device-features.js.map +0 -1
  353. package/dist/esm/adapter/device-helpers/device-limits.js +0 -91
  354. package/dist/esm/adapter/device-helpers/device-limits.js.map +0 -1
  355. package/dist/esm/adapter/device-helpers/get-device-info.js +0 -44
  356. package/dist/esm/adapter/device-helpers/get-device-info.js.map +0 -1
  357. package/dist/esm/adapter/device-helpers/is-old-ie.js +0 -8
  358. package/dist/esm/adapter/device-helpers/is-old-ie.js.map +0 -1
  359. package/dist/esm/adapter/helpers/attribute-utils.js +0 -81
  360. package/dist/esm/adapter/helpers/attribute-utils.js.map +0 -1
  361. package/dist/esm/adapter/helpers/get-shader-layout.js +0 -306
  362. package/dist/esm/adapter/helpers/get-shader-layout.js.map +0 -1
  363. package/dist/esm/adapter/helpers/parse-shader-compiler-log.js +0 -37
  364. package/dist/esm/adapter/helpers/parse-shader-compiler-log.js.map +0 -1
  365. package/dist/esm/adapter/helpers/set-uniform.js +0 -115
  366. package/dist/esm/adapter/helpers/set-uniform.js.map +0 -1
  367. package/dist/esm/adapter/helpers/uniforms.js +0 -99
  368. package/dist/esm/adapter/helpers/uniforms.js.map +0 -1
  369. package/dist/esm/adapter/objects/constants-to-keys.js +0 -42
  370. package/dist/esm/adapter/objects/constants-to-keys.js.map +0 -1
  371. package/dist/esm/adapter/objects/webgl-renderbuffer.js +0 -94
  372. package/dist/esm/adapter/objects/webgl-renderbuffer.js.map +0 -1
  373. package/dist/esm/adapter/objects/webgl-resource.js +0 -216
  374. package/dist/esm/adapter/objects/webgl-resource.js.map +0 -1
  375. package/dist/esm/adapter/objects/webgl-vertex-array-object.js +0 -84
  376. package/dist/esm/adapter/objects/webgl-vertex-array-object.js.map +0 -1
  377. package/dist/esm/adapter/resources/webgl-buffer.js +0 -164
  378. package/dist/esm/adapter/resources/webgl-buffer.js.map +0 -1
  379. package/dist/esm/adapter/resources/webgl-command-buffer.js +0 -65
  380. package/dist/esm/adapter/resources/webgl-command-buffer.js.map +0 -1
  381. package/dist/esm/adapter/resources/webgl-command-encoder.js +0 -53
  382. package/dist/esm/adapter/resources/webgl-command-encoder.js.map +0 -1
  383. package/dist/esm/adapter/resources/webgl-external-texture.js +0 -2
  384. package/dist/esm/adapter/resources/webgl-external-texture.js.map +0 -1
  385. package/dist/esm/adapter/resources/webgl-framebuffer.js +0 -265
  386. package/dist/esm/adapter/resources/webgl-framebuffer.js.map +0 -1
  387. package/dist/esm/adapter/resources/webgl-render-pass.js +0 -19
  388. package/dist/esm/adapter/resources/webgl-render-pass.js.map +0 -1
  389. package/dist/esm/adapter/resources/webgl-render-pipeline.js +0 -400
  390. package/dist/esm/adapter/resources/webgl-render-pipeline.js.map +0 -1
  391. package/dist/esm/adapter/resources/webgl-sampler.js +0 -50
  392. package/dist/esm/adapter/resources/webgl-sampler.js.map +0 -1
  393. package/dist/esm/adapter/resources/webgl-shader.js +0 -75
  394. package/dist/esm/adapter/resources/webgl-shader.js.map +0 -1
  395. package/dist/esm/adapter/resources/webgl-texture.js +0 -831
  396. package/dist/esm/adapter/resources/webgl-texture.js.map +0 -1
  397. package/dist/esm/adapter/webgl-canvas-context.js +0 -54
  398. package/dist/esm/adapter/webgl-canvas-context.js.map +0 -1
  399. package/dist/esm/adapter/webgl-device.js +0 -280
  400. package/dist/esm/adapter/webgl-device.js.map +0 -1
  401. package/dist/esm/bundle.js +0 -5
  402. package/dist/esm/bundle.js.map +0 -1
  403. package/dist/esm/classic/accessor.js +0 -144
  404. package/dist/esm/classic/accessor.js.map +0 -1
  405. package/dist/esm/classic/buffer.js +0 -384
  406. package/dist/esm/classic/buffer.js.map +0 -1
  407. package/dist/esm/classic/typed-array-utils.js +0 -112
  408. package/dist/esm/classic/typed-array-utils.js.map +0 -1
  409. package/dist/esm/context/context/context-state.js +0 -26
  410. package/dist/esm/context/context/context-state.js.map +0 -1
  411. package/dist/esm/context/context/create-context.js +0 -49
  412. package/dist/esm/context/context/create-context.js.map +0 -1
  413. package/dist/esm/context/context/device-pixels.js +0 -98
  414. package/dist/esm/context/context/device-pixels.js.map +0 -1
  415. package/dist/esm/context/context/webgl-checks.js +0 -34
  416. package/dist/esm/context/context/webgl-checks.js.map +0 -1
  417. package/dist/esm/context/debug/spector.js +0 -76
  418. package/dist/esm/context/debug/spector.js.map +0 -1
  419. package/dist/esm/context/debug/webgl-developer-tools.js +0 -121
  420. package/dist/esm/context/debug/webgl-developer-tools.js.map +0 -1
  421. package/dist/esm/context/parameters/unified-parameter-api.js +0 -65
  422. package/dist/esm/context/parameters/unified-parameter-api.js.map +0 -1
  423. package/dist/esm/context/parameters/webgl-parameter-tables.js +0 -445
  424. package/dist/esm/context/parameters/webgl-parameter-tables.js.map +0 -1
  425. package/dist/esm/context/polyfill/get-parameter-polyfill.js +0 -91
  426. package/dist/esm/context/polyfill/get-parameter-polyfill.js.map +0 -1
  427. package/dist/esm/context/polyfill/polyfill-context.js +0 -92
  428. package/dist/esm/context/polyfill/polyfill-context.js.map +0 -1
  429. package/dist/esm/context/polyfill/polyfill-table.js +0 -160
  430. package/dist/esm/context/polyfill/polyfill-table.js.map +0 -1
  431. package/dist/esm/context/polyfill/polyfill-vertex-array-object.js +0 -335
  432. package/dist/esm/context/polyfill/polyfill-vertex-array-object.js.map +0 -1
  433. package/dist/esm/context/state-tracker/deep-array-equal.js +0 -21
  434. package/dist/esm/context/state-tracker/deep-array-equal.js.map +0 -1
  435. package/dist/esm/context/state-tracker/track-context-state.js +0 -183
  436. package/dist/esm/context/state-tracker/track-context-state.js.map +0 -1
  437. package/dist/esm/context/state-tracker/with-parameters.js +0 -36
  438. package/dist/esm/context/state-tracker/with-parameters.js.map +0 -1
  439. package/dist/esm/index.js +0 -27
  440. package/dist/esm/index.js.map +0 -1
  441. package/dist/esm/init.js +0 -4
  442. package/dist/esm/init.js.map +0 -1
  443. package/dist/esm/types/webgl.js +0 -2
  444. package/dist/esm/types/webgl.js.map +0 -1
  445. package/dist/esm/types.js +0 -2
  446. package/dist/esm/types.js.map +0 -1
  447. package/dist/init.d.ts +0 -2
  448. package/dist/init.d.ts.map +0 -1
  449. package/dist/init.js +0 -4
  450. package/dist/init.js.map +0 -1
  451. package/src/bundle.ts +0 -4
  452. package/src/context/context/context-state.ts +0 -41
  453. package/src/context/context/device-pixels.ts +0 -152
  454. package/src/init.ts +0 -4
@@ -11,13 +11,13 @@ import {assert} from '@luma.gl/api';
11
11
  import {polyfillVertexArrayObject} from './polyfill-vertex-array-object';
12
12
 
13
13
  import {WEBGL2_CONTEXT_POLYFILLS, WEBGL2_CONTEXT_OVERRIDES} from './polyfill-table';
14
- import {getContextState} from '../context/context-state';
14
+ import {getContextData} from './context-data';
15
15
 
16
16
  /**
17
17
  * Registers extensions, polyfills or mock functions for extensions in the polyfills list
18
18
  */
19
19
  export function polyfillContext(gl: WebGLRenderingContext): WebGL2RenderingContext {
20
- const contextState = getContextState(gl);
20
+ const contextState = getContextData(gl);
21
21
 
22
22
  if (!contextState._polyfilled) {
23
23
  polyfillVertexArrayObject(gl);
@@ -32,19 +32,17 @@ export function polyfillContext(gl: WebGLRenderingContext): WebGL2RenderingConte
32
32
  }
33
33
 
34
34
  function initializeExtensions(gl: WebGLRenderingContext): void {
35
- const contextState = getContextState(gl);
35
+ const contextState = getContextData(gl);
36
36
  // `getSupportedExtensions` can return null when context is lost.
37
37
  const EXTENSIONS = gl.getSupportedExtensions() || [];
38
38
  for (const extensionName of EXTENSIONS) {
39
39
  const extension = gl.getExtension(extensionName);
40
40
  contextState._extensions[extensionName] = extension;
41
- // TODO - this looks like a mistake?
42
- contextState[extensionName] = extension;
43
41
  }
44
42
  }
45
43
 
46
44
  function installPolyfills(gl: WebGLRenderingContext, polyfills): void {
47
- const contextState = getContextState(gl);
45
+ const contextState = getContextData(gl);
48
46
  for (const extension of Object.getOwnPropertyNames(polyfills)) {
49
47
  if (extension !== 'overrides') {
50
48
  polyfillExtension(gl, {extension, target: contextState, target2: gl});
@@ -65,7 +63,7 @@ function polyfillExtension(gl: WebGLRenderingContext, {extension, target, target
65
63
  for (const key of Object.keys(defaults)) {
66
64
  const extKey = `${key}${suffix}`;
67
65
 
68
- let polyfill = null;
66
+ let polyfill: Function | null = null;
69
67
  if (key === 'meta') {
70
68
  // ignore
71
69
  } else if (typeof gl[key] === 'function') {
@@ -86,7 +84,7 @@ function polyfillExtension(gl: WebGLRenderingContext, {extension, target, target
86
84
  }
87
85
 
88
86
  /** Install simple overrides (mostly get* functions) */
89
- function installOverrides(gl, {target, target2}) {
87
+ function installOverrides(gl: WebGLRenderingContext, {target, target2}) {
90
88
  Object.keys(WEBGL2_CONTEXT_OVERRIDES).forEach((key) => {
91
89
  if (typeof WEBGL2_CONTEXT_OVERRIDES[key] === 'function') {
92
90
  // install an override, if no implementation was detected
@@ -3,8 +3,9 @@ import GL from '@luma.gl/constants';
3
3
  import {isWebGL2} from '../context/webgl-checks';
4
4
 
5
5
  import {getParameterPolyfill} from './get-parameter-polyfill';
6
- import {getContextState} from '../context/context-state';
6
+ import {getContextData} from './context-data';
7
7
 
8
+ /* eslint-disable camelcase */
8
9
  const OES_vertex_array_object = 'OES_vertex_array_object';
9
10
  const ANGLE_instanced_arrays = 'ANGLE_instanced_arrays';
10
11
  const WEBGL_draw_buffers = 'WEBGL_draw_buffers';
@@ -14,14 +15,14 @@ const EXT_texture_filter_anisotropic = 'EXT_texture_filter_anisotropic';
14
15
  const ERR_VAO_NOT_SUPPORTED = 'VertexArray requires WebGL2 or OES_vertex_array_object extension';
15
16
 
16
17
  // Return object with webgl2 flag and an extension
17
- function getExtensionData(gl, extension) {
18
+ function getExtensionData(gl: WebGLRenderingContext, extension: string) {
18
19
  return {
19
20
  webgl2: isWebGL2(gl),
20
21
  ext: gl.getExtension(extension)
21
22
  };
22
23
  }
23
24
 
24
- // function mapExtensionConstant(gl, constant) {
25
+ // function mapExtensionConstant(gl: WebGLRenderingContext, constant) {
25
26
  // switch (constant) {
26
27
  // case ext.FRAGMENT_SHADER_DERIVATIVE_HINT_OES: return GL.FRAGMENT_SHADER_DERIVATIVE_HINT;
27
28
  // }
@@ -46,7 +47,7 @@ export const WEBGL2_CONTEXT_POLYFILLS = {
46
47
  // VERTEX_ATTRIB_ARRAY_DIVISOR: 'VERTEX_ATTRIB_ARRAY_DIVISOR_ANGLE'
47
48
  // }
48
49
  },
49
- vertexAttribDivisor(location, divisor) {
50
+ vertexAttribDivisor(location: number, divisor: number) {
50
51
  // Accept divisor 0 even if instancing is not supported (0 = no instancing)
51
52
  assert(divisor === 0, 'WebGL instanced rendering not supported');
52
53
  },
@@ -74,20 +75,20 @@ export const WEBGL2_CONTEXT_POLYFILLS = {
74
75
  assert(false);
75
76
  },
76
77
  endQuery: () => {},
77
- getQuery(handle, pname) {
78
+ getQuery(handle, pname: string) {
78
79
  return this.getQueryObject(handle, pname);
79
80
  },
80
81
  // The WebGL1 extension uses getQueryObject rather then getQueryParameter
81
- getQueryParameter(handle, pname) {
82
+ getQueryParameter(handle, pname: string) {
82
83
  return this.getQueryObject(handle, pname);
83
84
  },
84
- getQueryObject: () => {}
85
+ getQueryObject: (handle: unknown, pname: unknown) => {}
85
86
  }
86
87
  };
87
88
 
88
89
  export const WEBGL2_CONTEXT_OVERRIDES = {
89
90
  // Ensure readBuffer is a no-op
90
- readBuffer: (gl, originalFunc, attachment) => {
91
+ readBuffer: (gl: WebGLRenderingContext, originalFunc, attachment) => {
91
92
  if (isWebGL2(gl)) {
92
93
  originalFunc(attachment);
93
94
  } else {
@@ -95,7 +96,7 @@ export const WEBGL2_CONTEXT_OVERRIDES = {
95
96
  }
96
97
  },
97
98
  // Override for getVertexAttrib that returns sane values for non-WebGL1 constants
98
- getVertexAttrib: (gl, originalFunc, location, pname) => {
99
+ getVertexAttrib: (gl: WebGLRenderingContext, originalFunc, location, pname) => {
99
100
  // const gl = this; // eslint-disable-line
100
101
  const {webgl2, ext} = getExtensionData(gl, ANGLE_instanced_arrays);
101
102
 
@@ -115,7 +116,7 @@ export const WEBGL2_CONTEXT_OVERRIDES = {
115
116
  return result !== undefined ? result : originalFunc(location, pname);
116
117
  },
117
118
  // Handle transform feedback and uniform block queries in WebGL1
118
- getProgramParameter: (gl, originalFunc, program, pname) => {
119
+ getProgramParameter: (gl: WebGLRenderingContext, originalFunc, program, pname) => {
119
120
  if (!isWebGL2(gl)) {
120
121
  switch (pname) {
121
122
  case GL.TRANSFORM_FEEDBACK_BUFFER_MODE:
@@ -129,7 +130,7 @@ export const WEBGL2_CONTEXT_OVERRIDES = {
129
130
  }
130
131
  return originalFunc(program, pname);
131
132
  },
132
- getInternalformatParameter: (gl, originalFunc, target, format, pname) => {
133
+ getInternalformatParameter: (gl: WebGLRenderingContext, originalFunc, target, format, pname) => {
133
134
  if (!isWebGL2(gl)) {
134
135
  switch (pname) {
135
136
  case GL.SAMPLES:
@@ -137,13 +138,14 @@ export const WEBGL2_CONTEXT_OVERRIDES = {
137
138
  default:
138
139
  }
139
140
  }
140
- return gl.getInternalformatParameter(target, format, pname);
141
+ const gl2 = gl as WebGL2RenderingContext;
142
+ return gl2.getInternalformatParameter(target, format, pname);
141
143
  },
142
144
  getTexParameter(gl, originalFunc, target, pname) {
143
145
  switch (pname) {
144
146
  case GL.TEXTURE_MAX_ANISOTROPY_EXT:
145
- const contextState = getContextState(gl);
146
- const {_extensions} = contextState;
147
+ const contextData = getContextData(gl);
148
+ const {_extensions} = contextData;
147
149
  const ext = _extensions[EXT_texture_filter_anisotropic];
148
150
  pname = (ext && ext.TEXTURE_MAX_ANISOTROPY_EXT) || GL.TEXTURE_MAX_ANISOTROPY_EXT;
149
151
  break;
@@ -25,6 +25,7 @@
25
25
  // the global class.
26
26
 
27
27
  // @ts-nocheck external code
28
+ /* eslint-disable */
28
29
 
29
30
  const glErrorShadow = {};
30
31
 
@@ -103,6 +104,7 @@ WebGLVertexArrayObjectOES.VertexAttrib.prototype.recache = function recache() {
103
104
  };
104
105
 
105
106
  const OESVertexArrayObject = function OESVertexArrayObject(gl) {
107
+ // eslint-disable-next-line @typescript-eslint/no-this-alias
106
108
  const self = this;
107
109
  this.gl = gl;
108
110
 
@@ -10,14 +10,14 @@ import {deepArrayEqual} from './deep-array-equal';
10
10
  /* eslint-disable no-shadow */
11
11
  class GLState {
12
12
  gl: WebGLRenderingContext;
13
- program = null;
14
- stateStack = [];
13
+ program: unknown = null;
14
+ stateStack: object[] = [];
15
15
  enable = true;
16
- cache;
16
+ cache: Record<string, any>;
17
17
  log;
18
18
 
19
19
  constructor(
20
- gl,
20
+ gl: WebGLRenderingContext,
21
21
  {
22
22
  copyState = false, // Copy cache from params (slow) or initialize from WebGL defaults (fast)
23
23
  log = () => {} // Logging function, called when gl parameter change calls are actually issued
@@ -50,11 +50,11 @@ class GLState {
50
50
  * @param values
51
51
  * @returns
52
52
  */
53
- _updateCache(values) {
53
+ _updateCache(values: {[key: number | string]: any}) {
54
54
  let valueChanged = false;
55
55
  let oldValue; // = undefined
56
56
 
57
- const oldValues = this.stateStack.length > 0 && this.stateStack[this.stateStack.length - 1];
57
+ const oldValues: {[key: number | string]: any} | null = this.stateStack.length > 0 ? this.stateStack[this.stateStack.length - 1] : null;
58
58
 
59
59
  for (const key in values) {
60
60
  assert(key !== undefined);
@@ -96,7 +96,7 @@ function getContextState(gl: WebGLRenderingContext): GLState {
96
96
  * gl.state.push() and gl.state.pop() will be available for saving,
97
97
  * temporarily modifying, and then restoring state.
98
98
  */
99
- export function trackContextState(
99
+ export function trackContextState(
100
100
  gl: WebGLRenderingContext,
101
101
  options?: {
102
102
  enable?: boolean;
@@ -108,7 +108,6 @@ function getContextState(gl: WebGLRenderingContext): GLState {
108
108
  assert(copyState !== undefined);
109
109
  // @ts-expect-error
110
110
  if (!gl.state) {
111
- const global_ = typeof global !== 'undefined' ? global : window;
112
111
  // @ts-ignore
113
112
  // const {polyfillContext} = global_;
114
113
  // if (polyfillContext) {
@@ -141,7 +140,7 @@ function getContextState(gl: WebGLRenderingContext): GLState {
141
140
  /**
142
141
  * Saves current WebGL context state onto an internal per-context stack
143
142
  */
144
- export function pushContextState(gl: WebGLRenderingContext): void {
143
+ export function pushContextState(gl: WebGLRenderingContext): void {
145
144
  let glState = getContextState(gl);
146
145
  if (!glState) {
147
146
  trackContextState(gl, {copyState: false});
@@ -188,9 +187,9 @@ function installGetterOverride(gl: WebGLRenderingContext, functionName: string)
188
187
  // Optionally call the original function to do a "hard" query from the WebGLRenderingContext
189
188
  return glState.enable
190
189
  ? // Call the getter the params so that it can e.g. serve from a cache
191
- glState.cache[pname]
190
+ glState.cache[pname]
192
191
  : // Optionally call the original function to do a "hard" query from the WebGLRenderingContext
193
- originalGetterFunc(pname);
192
+ originalGetterFunc(pname);
194
193
  };
195
194
 
196
195
  // Set the name of this anonymous function to help in debugging and profiling
@@ -209,12 +208,13 @@ function installGetterOverride(gl: WebGLRenderingContext, functionName: string)
209
208
  * @param setter
210
209
  * @returns
211
210
  */
212
- function installSetterSpy(gl: WebGLRenderingContext, functionName, setter) {
211
+ function installSetterSpy(gl: WebGLRenderingContext, functionName: string, setter: Function) {
213
212
  // Get the original function from the WebGLRenderingContext
214
213
  if (!gl[functionName]) {
215
214
  // This could happen if we try to intercept WebGL2 method on a WebGL1 context
216
215
  return;
217
216
  }
217
+
218
218
  const originalSetterFunc = gl[functionName].bind(gl);
219
219
 
220
220
  // Wrap it with a spy so that we can update our state cache when it gets called
@@ -222,6 +222,7 @@ function installSetterSpy(gl: WebGLRenderingContext, functionName, setter) {
222
222
  // Update the value
223
223
  // Call the setter with the state cache and the params so that it can store the parameters
224
224
  const glState = getContextState(gl);
225
+ // eslint-disable-next-line @typescript-eslint/unbound-method
225
226
  const {valueChanged, oldValue} = setter(glState._updateCache, ...params);
226
227
 
227
228
  // Call the original WebGLRenderingContext func to make sure the context actually gets updated
@@ -1,3 +1,5 @@
1
+ import type {Device} from '@luma.gl/api';
2
+ import {default as WebGLDevice} from '../../adapter/webgl-device';
1
3
  import {GLParameters, setParameters} from '../parameters/unified-parameter-api';
2
4
  import {pushContextState, popContextState} from './track-context-state';
3
5
 
@@ -9,10 +11,13 @@ import {pushContextState, popContextState} from './track-context-state';
9
11
  * - Restores parameters
10
12
  * - Returns the return value of the supplied function
11
13
  */
12
- export function withParameters(gl: WebGLRenderingContext, parameters: GLParameters & {nocatch?: boolean}, func: any): any {
14
+ export function withParameters(device: Device | WebGLRenderingContext, parameters: GLParameters & {nocatch?: boolean}, func: any): any {
15
+ const webglDevice = WebGLDevice.attach(device);
16
+ const gl = webglDevice.gl;
17
+
13
18
  if (isObjectEmpty(parameters)) {
14
19
  // Avoid setting state if no parameters provided. Just call and return
15
- return func(gl);
20
+ return func(device);
16
21
  }
17
22
 
18
23
  const {nocatch = true} = parameters;
@@ -43,6 +48,7 @@ import {pushContextState, popContextState} from './track-context-state';
43
48
 
44
49
  // Returns true if given object is empty, false otherwise.
45
50
  function isObjectEmpty(object) {
51
+ // @ts-ignore - dummy key variable
46
52
  for (const key in object) {
47
53
  return false;
48
54
  }
package/src/index.ts CHANGED
@@ -4,17 +4,16 @@
4
4
  // but make it easier to use.
5
5
  // Higher level abstractions can be built on these classes
6
6
 
7
- // Initialize any global state
8
- import '@luma.gl/api';
9
- import './init'
7
+ // Types
8
+ export type {WebGLLimits} from './adapter/device-helpers/device-limits';
10
9
 
10
+ export {registerHeadlessGL} from './context/context/create-headless-context';
11
+
12
+ // WebGL adapter classes
11
13
  export {default as WebGLDevice} from './adapter/webgl-device';
12
14
  export {default as WebGLCanvasContext} from './adapter/webgl-canvas-context';
13
15
 
14
- // Legacy WebGL Classes - will be moved to gltools
15
- export {default as Accessor} from './classic/accessor';
16
- export type {ClassicBufferProps as BufferProps} from './classic/buffer';
17
- export {default as Buffer} from './classic/buffer';
16
+ // WebGL Resource classes
18
17
  export {default as WEBGLResource, default as WebGLResource} from './adapter/objects/webgl-resource';
19
18
  export {default as WEBGLBuffer} from './adapter/resources/webgl-buffer';
20
19
  export {default as WEBGLTexture} from './adapter/resources/webgl-texture';
@@ -24,16 +23,22 @@ export {default as WEBGLSampler} from './adapter/resources/webgl-sampler';
24
23
  export {default as WEBGLFramebuffer} from './adapter/resources/webgl-framebuffer';
25
24
 
26
25
  export {default as WEBGLRenderPipeline} from './adapter/resources/webgl-render-pipeline';
27
-
28
26
  // export {default as WEBGLComputePipeline} from './adapter/resources/webgl-compute-pipeline';
29
27
  export {default as WEBGLCommandEncoder} from './adapter/resources/webgl-command-encoder';
30
28
  export {default as WEBGLRenderPass} from './adapter/resources/webgl-render-pass';
31
- //export {default as WEBGLComputePass} from './adapter/resources/webgl-compute-pass';
29
+ // export {default as WEBGLComputePass} from './adapter/resources/webgl-compute-pass';
32
30
 
31
+ // non-api resources
33
32
  export type {RenderbufferProps} from './adapter/objects/webgl-renderbuffer';
34
33
  export {default as WEBGLRenderbuffer} from './adapter/objects/webgl-renderbuffer';
35
34
  export {default as WEBGLVertexArrayObject} from './adapter/objects/webgl-vertex-array-object';
36
35
 
36
+ // WebGL adapter classes (Legacy, will be moved to gltools)
37
+ export {default as Accessor} from './classic/accessor';
38
+ export type {AccessorObject} from './types';
39
+ export type {ClassicBufferProps, ClassicBufferProps as BufferProps} from './classic/buffer';
40
+ export {default as ClassicBuffer, default as Buffer} from './classic/buffer';
41
+
37
42
  export {
38
43
  isWebGL,
39
44
  isWebGL2,
@@ -42,9 +47,6 @@ export {
42
47
  assertWebGL2Context
43
48
  } from './context/context/webgl-checks';
44
49
 
45
- // Device ratio
46
- export {cssToDeviceRatio, cssToDevicePixels} from './context/context/device-pixels';
47
-
48
50
  // Unified parameter API
49
51
 
50
52
  export {setDeviceParameters, withDeviceParameters} from './adapter/converters/device-parameters';
@@ -1,6 +1,8 @@
1
1
  import type {NumberArray} from '@luma.gl/api';
2
2
  import GL from '@luma.gl/constants';
3
3
 
4
+ /* eslint-disable camelcase */
5
+
4
6
  type Framebuffer = any;
5
7
 
6
8
  export type GLDrawMode =
@@ -120,7 +122,7 @@ export type GLStencilOp =
120
122
  | GL.INVERT;
121
123
 
122
124
  /** Parameters for textures and samplers */
123
- export type WebGLSamplerParameters = {
125
+ export type GLSamplerParameters = {
124
126
  [GL.TEXTURE_WRAP_S]?: GL.CLAMP_TO_EDGE | GL.REPEAT | GL.MIRRORED_REPEAT;
125
127
  [GL.TEXTURE_WRAP_T]?: GL.CLAMP_TO_EDGE | GL.REPEAT | GL.MIRRORED_REPEAT;
126
128
  [GL.TEXTURE_WRAP_R]?: GL.CLAMP_TO_EDGE | GL.REPEAT | GL.MIRRORED_REPEAT;
@@ -135,6 +137,7 @@ export type WebGLSamplerParameters = {
135
137
  [GL.TEXTURE_MIN_LOD]?: number;
136
138
  [GL.TEXTURE_MAX_LOD]?: number;
137
139
  [GL.TEXTURE_COMPARE_FUNC]?: number; // COMPARE_FUNC);
140
+ [GL.TEXTURE_COMPARE_MODE]?: GL.COMPARE_REF_TO_TEXTURE;
138
141
  [GL.TEXTURE_MAX_ANISOTROPY_EXT]?: number; //
139
142
  };
140
143
 
@@ -193,11 +196,11 @@ export type GLValueParameters = {
193
196
  [GL.STENCIL_WRITEMASK]?: number;
194
197
  [GL.STENCIL_BACK_WRITEMASK]?: number;
195
198
  [GL.STENCIL_FUNC]?: GLFunction;
196
- [GL.STENCIL_REF]?: GLFunction;
197
- [GL.STENCIL_VALUE_MASK]?: GLFunction;
199
+ [GL.STENCIL_REF]?: number;
200
+ [GL.STENCIL_VALUE_MASK]?: number;
198
201
  [GL.STENCIL_BACK_FUNC]?: GLFunction;
199
- [GL.STENCIL_BACK_REF]?: GLFunction;
200
- [GL.STENCIL_BACK_VALUE_MASK]?: GLFunction;
202
+ [GL.STENCIL_BACK_REF]?: number;
203
+ [GL.STENCIL_BACK_VALUE_MASK]?: number;
201
204
  [GL.STENCIL_FAIL]?: GLStencilOp;
202
205
  [GL.STENCIL_PASS_DEPTH_FAIL]?: GLStencilOp;
203
206
  [GL.STENCIL_PASS_DEPTH_PASS]?: GLStencilOp;
@@ -240,7 +243,7 @@ export type GLFunctionParameters = {
240
243
  clearDepth?: number;
241
244
  clearStencil?: number;
242
245
 
243
- colorMask?: [boolean, boolean, boolean, boolean];
246
+ colorMask?: [boolean, boolean, boolean, boolean] | boolean[];
244
247
 
245
248
  cull?: boolean;
246
249
  cullFace?: GL.FRONT | GL.BACK | GL.FRONT_AND_BACK;
@@ -280,4 +283,4 @@ export type GLFunctionParameters = {
280
283
  };
281
284
 
282
285
  /** WebGL style parameters object (with both GL constants and function style fields) */
283
- export type GLParameters = GLValueParameters | GLFunctionParameters;
286
+ export type GLParameters = GLValueParameters & GLFunctionParameters;
package/dist/bundle.d.ts DELETED
@@ -1,2 +0,0 @@
1
- declare const moduleExports: any;
2
- //# sourceMappingURL=bundle.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"bundle.d.ts","sourceRoot":"","sources":["../src/bundle.ts"],"names":[],"mappings":"AACA,QAAA,MAAM,aAAa,KAAqB,CAAC"}
package/dist/bundle.js DELETED
@@ -1,5 +0,0 @@
1
- const moduleExports = require('./index');
2
-
3
- globalThis.luma = globalThis.luma || {};
4
- module.exports = Object.assign(globalThis.luma, moduleExports);
5
- //# sourceMappingURL=bundle.js.map
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../src/bundle.ts"],"names":["moduleExports","require","globalThis","luma","module","exports","Object","assign"],"mappings":"AACA,MAAMA,aAAa,GAAGC,OAAO,CAAC,SAAD,CAA7B;;AACAC,UAAU,CAACC,IAAX,GAAkBD,UAAU,CAACC,IAAX,IAAmB,EAArC;AACAC,MAAM,CAACC,OAAP,GAAiBC,MAAM,CAACC,MAAP,CAAcL,UAAU,CAACC,IAAzB,EAA+BH,aAA/B,CAAjB","sourcesContent":["// @ts-nocheck\nconst moduleExports = require('./index');\nglobalThis.luma = globalThis.luma || {};\nmodule.exports = Object.assign(globalThis.luma, moduleExports);\n"],"file":"bundle.js"}
@@ -1,18 +0,0 @@
1
- /**
2
- * Stores luma.gl specific state associated with a context
3
- */
4
- export interface ContextState {
5
- _canvasSizeInfo: {
6
- clientWidth: number;
7
- clientHeight: number;
8
- devicePixelRatio: number;
9
- };
10
- _polyfilled: boolean;
11
- _extensions: Record<string, any>;
12
- }
13
- /**
14
- * Gets luma.gl specific state from a context
15
- * @returns context state
16
- */
17
- export declare function getContextState(gl: WebGLRenderingContext): ContextState;
18
- //# sourceMappingURL=context-state.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"context-state.d.ts","sourceRoot":"","sources":["../../../src/context/context/context-state.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,MAAM,WAAW,YAAY;IAC3B,eAAe,EAAE;QACf,WAAW,EAAE,MAAM,CAAC;QACpB,YAAY,EAAE,MAAM,CAAC;QACrB,gBAAgB,EAAE,MAAM,CAAC;KAC1B,CAAC;IACF,WAAW,EAAE,OAAO,CAAC;IACrB,WAAW,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,CAAC;CAClC;AAED;;;GAGG;AACH,wBAAgB,eAAe,CAAC,EAAE,EAAE,qBAAqB,GAAG,YAAY,CAuBvE"}
@@ -1,26 +0,0 @@
1
- export function getContextState(gl) {
2
- const {
3
- device,
4
- luma
5
- } = gl;
6
-
7
- if (device) {
8
- return device;
9
- }
10
-
11
- if (!luma) {
12
- const contextState = {
13
- _canvasSizeInfo: {
14
- clientWidth: 0,
15
- clientHeight: 0,
16
- devicePixelRatio: 1
17
- },
18
- _polyfilled: false,
19
- _extensions: {}
20
- };
21
- gl.luma = contextState;
22
- }
23
-
24
- throw new Error('context state without device');
25
- }
26
- //# sourceMappingURL=context-state.js.map
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../../../src/context/context/context-state.ts"],"names":["getContextState","gl","device","luma","contextState","_canvasSizeInfo","clientWidth","clientHeight","devicePixelRatio","_polyfilled","_extensions","Error"],"mappings":"AAiBA,OAAO,SAASA,eAAT,CAAyBC,EAAzB,EAAkE;AAEvE,QAAM;AAACC,IAAAA,MAAD;AAASC,IAAAA;AAAT,MAAiBF,EAAvB;;AACA,MAAIC,MAAJ,EAAY;AACV,WAAOA,MAAP;AACD;;AACD,MAAI,CAACC,IAAL,EAAW;AACT,UAAMC,YAA0B,GAAG;AACjCC,MAAAA,eAAe,EAAE;AACfC,QAAAA,WAAW,EAAE,CADE;AAEfC,QAAAA,YAAY,EAAE,CAFC;AAGfC,QAAAA,gBAAgB,EAAE;AAHH,OADgB;AAMjCC,MAAAA,WAAW,EAAE,KANoB;AAOjCC,MAAAA,WAAW,EAAE;AAPoB,KAAnC;AAUAT,IAAAA,EAAE,CAACE,IAAH,GAAUC,YAAV;AACD;;AACD,QAAM,IAAIO,KAAJ,CAAU,8BAAV,CAAN;AAID","sourcesContent":["/**\n * Stores luma.gl specific state associated with a context\n */\nexport interface ContextState {\n _canvasSizeInfo: {\n clientWidth: number;\n clientHeight: number;\n devicePixelRatio: number;\n };\n _polyfilled: boolean;\n _extensions: Record<string, any>;\n}\n\n/**\n * Gets luma.gl specific state from a context\n * @returns context state\n */\nexport function getContextState(gl: WebGLRenderingContext): ContextState {\n // @ts-expect-error\n const {device, luma} = gl;\n if (device) {\n return device as ContextState;\n }\n if (!luma) {\n const contextState: ContextState = {\n _canvasSizeInfo: {\n clientWidth: 0,\n clientHeight: 0,\n devicePixelRatio: 1,\n },\n _polyfilled: false,\n _extensions: {}\n };\n // @ts-expect-error\n gl.luma = contextState;\n }\n throw new Error('context state without device');\n\n // // @ts-expect-error\n // return gl.luma;\n}\n"],"file":"context-state.js"}
@@ -1 +0,0 @@
1
- {"version":3,"file":"create-context.d.ts","sourceRoot":"","sources":["../../../src/context/context/create-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,CAyC7H"}
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../../../src/context/context/create-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"],"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,EAAE,GAAG,IAAT;;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;;AAEDF,EAAAA,MAAM,CAACK,gBAAP,CAAwB,kBAAxB,EAA4CJ,KAAK,CAACP,aAAlD,EAAiE,KAAjE;AACAM,EAAAA,MAAM,CAACK,gBAAP,CAAwB,sBAAxB,EAAgDJ,KAAK,CAACJ,iBAAtD,EAAyE,KAAzE;AAEA,SAAOS,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 = 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);\n }\n if (props.webgl1) {\n gl = 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 canvas.addEventListener('webglcontextlost', props.onContextLost, false);\n canvas.addEventListener('webglcontextrestored', props.onContextRestored, false);\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-context.js"}
@@ -1,25 +0,0 @@
1
- /**
2
- * Returns multiplier need to convert CSS size to Device size
3
- */
4
- export declare function cssToDeviceRatio(gl: WebGLRenderingContext): number;
5
- /**
6
- * Maps CSS pixel position to device pixel position
7
- */
8
- export declare function cssToDevicePixels(gl: WebGLRenderingContext, cssPixel: number[], yInvert?: boolean): {
9
- x: number;
10
- y: number;
11
- width: number;
12
- height: number;
13
- };
14
- /**
15
- * Calulates device pixel ratio, used during context creation
16
- *
17
- * @param useDevicePixels - boolean or a number
18
- * @return - device pixel ratio
19
- */
20
- export declare function getDevicePixelRatio(useDevicePixels: boolean | number): number;
21
- export declare function setDevicePixelRatio(gl: WebGLRenderingContext, devicePixelRatio: number, options?: {
22
- width?: number;
23
- height?: number;
24
- }): void;
25
- //# sourceMappingURL=device-pixels.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"device-pixels.d.ts","sourceRoot":"","sources":["../../../src/context/context/device-pixels.ts"],"names":[],"mappings":"AAGA;;GAEG;AACH,wBAAgB,gBAAgB,CAAC,EAAE,EAAE,qBAAqB,GAAG,MAAM,CAWlE;AAED;;GAEG;AACF,wBAAgB,iBAAiB,CAChC,EAAE,EAAE,qBAAqB,EACzB,QAAQ,EAAE,MAAM,EAAE,EAClB,OAAO,GAAE,OAAc,GACtB;IACD,CAAC,EAAE,MAAM,CAAC;IACV,CAAC,EAAE,MAAM,CAAC;IACV,KAAK,EAAE,MAAM,CAAC;IACd,MAAM,EAAE,MAAM,CAAC;CAChB,CAKA;AAED;;;;;GAKG;AACF,wBAAgB,mBAAmB,CAAC,eAAe,EAAE,OAAO,GAAG,MAAM,GAAG,MAAM,CAO9E;AAGD,wBAAgB,mBAAmB,CAAC,EAAE,EAAE,qBAAqB,EAAE,gBAAgB,EAAE,MAAM,EAAE,OAAO,GAAE;IAAC,KAAK,CAAC,EAAE,MAAM,CAAC;IAAC,MAAM,CAAC,EAAE,MAAM,CAAA;CAAM,QA4CvI"}
@@ -1,98 +0,0 @@
1
- import { log } from '@luma.gl/api';
2
- import { getContextState } from './context-state';
3
- export function cssToDeviceRatio(gl) {
4
- const state = getContextState(gl);
5
-
6
- if (gl.canvas && state) {
7
- const {
8
- clientWidth
9
- } = state._canvasSizeInfo;
10
- return clientWidth ? gl.drawingBufferWidth / clientWidth : 1;
11
- }
12
-
13
- return 1;
14
- }
15
- export function cssToDevicePixels(gl, cssPixel, yInvert = true) {
16
- const ratio = cssToDeviceRatio(gl);
17
- const width = gl.drawingBufferWidth;
18
- const height = gl.drawingBufferHeight;
19
- return scalePixels(cssPixel, ratio, width, height, yInvert);
20
- }
21
- export function getDevicePixelRatio(useDevicePixels) {
22
- const windowRatio = typeof window === 'undefined' ? 1 : window.devicePixelRatio || 1;
23
-
24
- if (Number.isFinite(useDevicePixels)) {
25
- return useDevicePixels <= 0 ? 1 : useDevicePixels;
26
- }
27
-
28
- return useDevicePixels ? windowRatio : 1;
29
- }
30
- export function setDevicePixelRatio(gl, devicePixelRatio, options = {}) {
31
- let clientWidth = 'width' in options ? options.width : gl.canvas.clientWidth;
32
- let clientHeight = 'height' in options ? options.height : gl.canvas.clientHeight;
33
-
34
- if (!clientWidth || !clientHeight) {
35
- log.log(1, 'Canvas clientWidth/clientHeight is 0')();
36
- devicePixelRatio = 1;
37
- clientWidth = gl.canvas.width || 1;
38
- clientHeight = gl.canvas.height || 1;
39
- }
40
-
41
- const contextState = getContextState(gl);
42
- const cachedSize = contextState._canvasSizeInfo;
43
-
44
- if (cachedSize.clientWidth !== clientWidth || cachedSize.clientHeight !== clientHeight || cachedSize.devicePixelRatio !== devicePixelRatio) {
45
- let clampedPixelRatio = devicePixelRatio;
46
- const canvasWidth = Math.floor(clientWidth * clampedPixelRatio);
47
- const canvasHeight = Math.floor(clientHeight * clampedPixelRatio);
48
- gl.canvas.width = canvasWidth;
49
- gl.canvas.height = canvasHeight;
50
-
51
- if (gl.drawingBufferWidth !== canvasWidth || gl.drawingBufferHeight !== canvasHeight) {
52
- log.warn("Device pixel ratio clamped")();
53
- clampedPixelRatio = Math.min(gl.drawingBufferWidth / clientWidth, gl.drawingBufferHeight / clientHeight);
54
- gl.canvas.width = Math.floor(clientWidth * clampedPixelRatio);
55
- gl.canvas.height = Math.floor(clientHeight * clampedPixelRatio);
56
- }
57
-
58
- Object.assign(contextState._canvasSizeInfo, {
59
- clientWidth,
60
- clientHeight,
61
- devicePixelRatio
62
- });
63
- }
64
- }
65
-
66
- function scalePixels(pixel, ratio, width, height, yInvert) {
67
- const x = scaleX(pixel[0], ratio, width);
68
- let y = scaleY(pixel[1], ratio, height, yInvert);
69
- let t = scaleX(pixel[0] + 1, ratio, width);
70
- const xHigh = t === width - 1 ? t : t - 1;
71
- t = scaleY(pixel[1] + 1, ratio, height, yInvert);
72
- let yHigh;
73
-
74
- if (yInvert) {
75
- t = t === 0 ? t : t + 1;
76
- yHigh = y;
77
- y = t;
78
- } else {
79
- yHigh = t === height - 1 ? t : t - 1;
80
- }
81
-
82
- return {
83
- x,
84
- y,
85
- width: Math.max(xHigh - x + 1, 1),
86
- height: Math.max(yHigh - y + 1, 1)
87
- };
88
- }
89
-
90
- function scaleX(x, ratio, width) {
91
- const r = Math.min(Math.round(x * ratio), width - 1);
92
- return r;
93
- }
94
-
95
- function scaleY(y, ratio, height, yInvert) {
96
- return yInvert ? Math.max(0, height - 1 - Math.round(y * ratio)) : Math.min(Math.round(y * ratio), height - 1);
97
- }
98
- //# sourceMappingURL=device-pixels.js.map