@luma.gl/webgl 9.0.0-alpha.7 → 9.0.0-alpha.8

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 (52) hide show
  1. package/dist/adapter/resources/webgl-render-pipeline.js +12 -0
  2. package/dist/adapter/resources/webgl-render-pipeline.js.map +1 -1
  3. package/dist/adapter/webgl-device.d.ts +13 -7
  4. package/dist/adapter/webgl-device.d.ts.map +1 -1
  5. package/dist/adapter/webgl-device.js +65 -17
  6. package/dist/adapter/webgl-device.js.map +1 -1
  7. package/dist/classic/accessor.d.ts.map +1 -1
  8. package/dist/classic/accessor.js.map +1 -1
  9. package/dist/context/context/create-browser-context.d.ts.map +1 -1
  10. package/dist/context/context/create-browser-context.js +8 -2
  11. package/dist/context/context/create-browser-context.js.map +1 -1
  12. package/dist/context/debug/webgl-developer-tools.d.ts +1 -1
  13. package/dist/context/debug/webgl-developer-tools.d.ts.map +1 -1
  14. package/dist/context/debug/webgl-developer-tools.js +1 -1
  15. package/dist/context/debug/webgl-developer-tools.js.map +1 -1
  16. package/dist/context/polyfill/polyfill-context.js +0 -1
  17. package/dist/context/polyfill/polyfill-context.js.map +1 -1
  18. package/dist/es5/adapter/resources/webgl-render-pipeline.js +12 -0
  19. package/dist/es5/adapter/resources/webgl-render-pipeline.js.map +1 -1
  20. package/dist/es5/adapter/webgl-device.js +79 -25
  21. package/dist/es5/adapter/webgl-device.js.map +1 -1
  22. package/dist/es5/classic/accessor.js.map +1 -1
  23. package/dist/es5/context/context/create-browser-context.js +10 -2
  24. package/dist/es5/context/context/create-browser-context.js.map +1 -1
  25. package/dist/es5/context/debug/webgl-developer-tools.js +1 -1
  26. package/dist/es5/context/debug/webgl-developer-tools.js.map +1 -1
  27. package/dist/es5/context/polyfill/polyfill-context.js +0 -1
  28. package/dist/es5/context/polyfill/polyfill-context.js.map +1 -1
  29. package/dist/es5/index.js.map +1 -1
  30. package/dist/esm/adapter/resources/webgl-render-pipeline.js +12 -0
  31. package/dist/esm/adapter/resources/webgl-render-pipeline.js.map +1 -1
  32. package/dist/esm/adapter/webgl-device.js +65 -17
  33. package/dist/esm/adapter/webgl-device.js.map +1 -1
  34. package/dist/esm/classic/accessor.js.map +1 -1
  35. package/dist/esm/context/context/create-browser-context.js +8 -2
  36. package/dist/esm/context/context/create-browser-context.js.map +1 -1
  37. package/dist/esm/context/debug/webgl-developer-tools.js +1 -1
  38. package/dist/esm/context/debug/webgl-developer-tools.js.map +1 -1
  39. package/dist/esm/context/polyfill/polyfill-context.js +0 -1
  40. package/dist/esm/context/polyfill/polyfill-context.js.map +1 -1
  41. package/dist/esm/index.js.map +1 -1
  42. package/dist/index.d.ts +1 -0
  43. package/dist/index.d.ts.map +1 -1
  44. package/dist/index.js.map +1 -1
  45. package/package.json +4 -4
  46. package/src/adapter/resources/webgl-render-pipeline.ts +5 -1
  47. package/src/adapter/webgl-device.ts +79 -27
  48. package/src/classic/accessor.ts +0 -13
  49. package/src/context/context/create-browser-context.ts +6 -2
  50. package/src/context/debug/webgl-developer-tools.ts +2 -2
  51. package/src/context/polyfill/polyfill-context.ts +0 -2
  52. package/src/index.ts +1 -0
@@ -1,5 +1,5 @@
1
1
  import _defineProperty from "@babel/runtime/helpers/esm/defineProperty";
2
- import { Device, CanvasContext, log, assert } from '@luma.gl/api';
2
+ import { Device, CanvasContext, log } from '@luma.gl/api';
3
3
  import { isBrowser } from '@probe.gl/env';
4
4
  import { polyfillContext } from '../context/polyfill/polyfill-context';
5
5
  import { trackContextState } from '../context/state-tracker/track-context-state';
@@ -59,7 +59,7 @@ export default class WebGLDevice extends Device {
59
59
  });
60
60
  }
61
61
 
62
- static async create(props) {
62
+ static async create(props = {}) {
63
63
  log.groupCollapsed(LOG_LEVEL, 'WebGLDevice created');
64
64
 
65
65
  if (typeof props.canvas === 'string') {
@@ -74,7 +74,12 @@ export default class WebGLDevice extends Device {
74
74
  await loadSpectorJS();
75
75
  }
76
76
 
77
- log.probe(LOG_LEVEL, 'DOM is loaded')();
77
+ log.probe(LOG_LEVEL + 1, 'DOM is loaded')();
78
+
79
+ if (props.gl && props.gl.device) {
80
+ return WebGLDevice.attach(props.gl);
81
+ }
82
+
78
83
  return new WebGLDevice(props);
79
84
  }
80
85
 
@@ -87,13 +92,19 @@ export default class WebGLDevice extends Device {
87
92
 
88
93
  _defineProperty(this, "canvasContext", void 0);
89
94
 
95
+ _defineProperty(this, "handle", void 0);
96
+
90
97
  _defineProperty(this, "lost", void 0);
91
98
 
92
- _defineProperty(this, "handle", void 0);
99
+ _defineProperty(this, "_resolveContextLost", void 0);
100
+
101
+ _defineProperty(this, "_features", void 0);
102
+
103
+ _defineProperty(this, "_limits", void 0);
93
104
 
94
105
  _defineProperty(this, "gl", void 0);
95
106
 
96
- _defineProperty(this, "gl2", void 0);
107
+ _defineProperty(this, "gl2", null);
97
108
 
98
109
  _defineProperty(this, "debug", false);
99
110
 
@@ -101,10 +112,6 @@ export default class WebGLDevice extends Device {
101
112
 
102
113
  _defineProperty(this, "isWebGL2", void 0);
103
114
 
104
- _defineProperty(this, "_features", void 0);
105
-
106
- _defineProperty(this, "_limits", void 0);
107
-
108
115
  _defineProperty(this, "_webglLimits", void 0);
109
116
 
110
117
  _defineProperty(this, "_canvasSizeInfo", {
@@ -119,19 +126,40 @@ export default class WebGLDevice extends Device {
119
126
 
120
127
  _defineProperty(this, "spector", void 0);
121
128
 
122
- _defineProperty(this, "renderPass", void 0);
129
+ _defineProperty(this, "renderPass", null);
123
130
 
124
131
  const device = (_props$gl = props.gl) === null || _props$gl === void 0 ? void 0 : _props$gl.device;
125
132
 
126
133
  if (device) {
127
- log.warn("WebGL context already attached to device ".concat(device.id));
128
- return device;
134
+ throw new Error("WebGL context already attached to device ".concat(device.id));
129
135
  }
130
136
 
131
137
  this.canvasContext = new WebGLCanvasContext(this, props);
138
+ this.lost = new Promise(resolve => {
139
+ this._resolveContextLost = resolve;
140
+ });
141
+
142
+ const onContextLost = event => {
143
+ var _this$_resolveContext;
144
+
145
+ return (_this$_resolveContext = this._resolveContextLost) === null || _this$_resolveContext === void 0 ? void 0 : _this$_resolveContext.call(this, {
146
+ reason: 'destroyed',
147
+ message: 'Computer entered sleep mode, or too many apps or browser tabs are using the GPU.'
148
+ });
149
+ };
150
+
132
151
  let gl = props.gl;
133
- gl = gl || isBrowser() && createBrowserContext(this.canvasContext.canvas, props);
134
- gl = gl || !isBrowser() && createHeadlessContext(props);
152
+ gl = gl || (isBrowser() ? createBrowserContext(this.canvasContext.canvas, { ...props,
153
+ onContextLost
154
+ }) : null);
155
+ gl = gl || (!isBrowser() ? createHeadlessContext({ ...props,
156
+ onContextLost
157
+ }) : null);
158
+
159
+ if (!gl) {
160
+ throw new Error('WebGL context creation failed');
161
+ }
162
+
135
163
  this.handle = gl;
136
164
  this.gl = this.handle;
137
165
  this.gl2 = this.gl;
@@ -175,13 +203,28 @@ export default class WebGLDevice extends Device {
175
203
  }
176
204
 
177
205
  destroy() {
178
- let ext = this.gl.getExtension('STACKGL_destroy_context');
206
+ const ext = this.gl.getExtension('STACKGL_destroy_context');
179
207
 
180
208
  if (ext) {
181
209
  ext.destroy();
182
210
  }
183
211
  }
184
212
 
213
+ loseDevice() {
214
+ var _this$_resolveContext2;
215
+
216
+ const ext = this.gl.getExtension('WEBGL_lose_context');
217
+
218
+ if (ext) {
219
+ ext.loseContext();
220
+ }
221
+
222
+ (_this$_resolveContext2 = this._resolveContextLost) === null || _this$_resolveContext2 === void 0 ? void 0 : _this$_resolveContext2.call(this, {
223
+ reason: 'destroyed',
224
+ message: 'Application triggered context loss'
225
+ });
226
+ }
227
+
185
228
  get isLost() {
186
229
  return this.gl.isContextLost();
187
230
  }
@@ -203,7 +246,10 @@ export default class WebGLDevice extends Device {
203
246
  }
204
247
 
205
248
  assertWebGL2() {
206
- assert(this.isWebGL2, 'Requires WebGL2');
249
+ if (!this.gl2) {
250
+ throw new Error('Requires WebGL2');
251
+ }
252
+
207
253
  return this.gl2;
208
254
  }
209
255
 
@@ -259,7 +305,9 @@ export default class WebGLDevice extends Device {
259
305
  }
260
306
 
261
307
  submit() {
262
- this.renderPass.endPass();
308
+ var _this$renderPass;
309
+
310
+ (_this$renderPass = this.renderPass) === null || _this$renderPass === void 0 ? void 0 : _this$renderPass.endPass();
263
311
  this.renderPass = null;
264
312
  }
265
313
 
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../src/adapter/webgl-device.ts"],"names":["Device","CanvasContext","log","assert","isBrowser","polyfillContext","trackContextState","createBrowserContext","createHeadlessContext","isHeadlessGLRegistered","getDeviceInfo","getDeviceFeatures","getDeviceLimits","getWebGLLimits","WebGLCanvasContext","loadSpectorJS","initializeSpectorJS","loadWebGLDeveloperTools","makeDebugContext","isTextureFormatSupported","isTextureFormatRenderable","isTextureFormatFilterable","ClassicBuffer","WEBGLShader","WEBGLSampler","WEBGLTexture","WEBGLFramebuffer","WEBGLRenderPass","WEBGLRenderPipeline","LOG_LEVEL","counter","WebGLDevice","isSupported","WebGLRenderingContext","features","_features","gl","limits","_limits","webglLimits","_webglLimits","attach","device","isWebGL","Error","create","props","groupCollapsed","canvas","pageLoaded","debug","spector","probe","constructor","clientWidth","clientHeight","devicePixelRatio","warn","id","canvasContext","handle","gl2","isWebGL2","isWebGL1","info","_version","enable","copyState","args","webgl2","throwOnError","level","Math","max","message","type","vendor","renderer","groupEnd","destroy","ext","getExtension","isLost","isContextLost","getSize","drawingBufferWidth","drawingBufferHeight","format","assertWebGL2","createCanvasContext","_createBuffer","_createTexture","createExternalTexture","createSampler","createShader","createFramebuffer","createRenderPipeline","beginRenderPass","createComputePipeline","beginComputePass","getDefaultRenderPass","renderPass","framebuffer","getCurrentFramebuffer","submit","endPass","WebGL2RenderingContext","Boolean","Number","isFinite"],"mappings":";AASA,SAAQA,MAAR,EAAgBC,aAAhB,EAA+BC,GAA/B,EAAoCC,MAApC,QAAiD,cAAjD;AACA,SAAQC,SAAR,QAAwB,eAAxB;AACA,SAAQC,eAAR,QAA8B,sCAA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AE,YAAYH,qBAAlE,EAAyF;AACvF,WAAO,IAAP;AACD;;AACD,MAAI,OAAOyE,sBAAP,KAAkC,WAAlC,IAAiDtE,EAAE,YAAYsE,sBAAnE,EAA2F;AACzF,WAAO,IAAP;AACD;;AAED,SAAOC,OAAO,CAACvE,EAAE,IAAIwE,MAAM,CAACC,QAAP,CAAgBzE,EAAE,CAAC6B,QAAnB,CAAP,CAAd;AACD;;AAID,SAASH,QAAT,CAAkB1B,EAAlB,EAAoC;AAClC,MAAI,OAAOsE,sBAAP,KAAkC,WAAlC,IAAiDtE,EAAE,YAAYsE,sBAAnE,EAA2F;AACzF,WAAO,IAAP;AACD;;AAED,SAAOC,OAAO,CAACvE,EAAE,IAAIA,EAAE,CAAC6B,QAAH,KAAgB,CAAvB,CAAd;AACD","sourcesContent":["// luma.gl, MIT license\nimport type {\n DeviceProps,\n DeviceInfo,\n DeviceLimits,\n DeviceFeature,\n CanvasContextProps,\n TextureFormat\n} from '@luma.gl/api';\nimport {Device, CanvasContext, log, assert} from '@luma.gl/api';\nimport {isBrowser} from '@probe.gl/env';\nimport {polyfillContext} from '../context/polyfill/polyfill-context';\nimport {trackContextState} from '../context/state-tracker/track-context-state';\nimport {ContextState} from '../context/context/context-state';\nimport {createBrowserContext} from '../context/context/create-browser-context';\nimport {createHeadlessContext, isHeadlessGLRegistered} from '../context/context/create-headless-context';\nimport {getDeviceInfo} from './device-helpers/get-device-info';\nimport {getDeviceFeatures} from './device-helpers/device-features';\nimport {getDeviceLimits, getWebGLLimits, WebGLLimits} from './device-helpers/device-limits';\nimport WebGLCanvasContext from './webgl-canvas-context';\nimport {loadSpectorJS, initializeSpectorJS} from '../context/debug/spector';\nimport {loadWebGLDeveloperTools, makeDebugContext} from '../context/debug/webgl-developer-tools';\nimport {\n isTextureFormatSupported,\n isTextureFormatRenderable,\n isTextureFormatFilterable\n} from './converters/texture-formats';\n\n// WebGL classes\nimport type {\n BufferProps,\n ShaderProps,\n Sampler,\n SamplerProps,\n TextureProps,\n ExternalTexture,\n ExternalTextureProps,\n FramebufferProps,\n RenderPipeline,\n RenderPipelineProps,\n ComputePipeline,\n ComputePipelineProps,\n RenderPass,\n RenderPassProps,\n ComputePass,\n ComputePassProps\n} from '@luma.gl/api';\n\nimport ClassicBuffer from '../classic/buffer';\nimport WEBGLBuffer from './resources/webgl-buffer';\nimport WEBGLShader from './resources/webgl-shader';\nimport WEBGLSampler from './resources/webgl-sampler';\nimport WEBGLTexture from './resources/webgl-texture';\nimport WEBGLFramebuffer from './resources/webgl-framebuffer';\nimport WEBGLRenderPass from './resources/webgl-render-pass';\nimport WEBGLRenderPipeline from './resources/webgl-render-pipeline';\n\nconst LOG_LEVEL = 1;\n\nlet counter = 0;\n\n/** WebGPU style Device API for a WebGL context */\nexport default class WebGLDevice extends Device implements ContextState {\n // Public API\n\n static type: string = 'webgl';\n\n static isSupported(): boolean {\n return typeof WebGLRenderingContext !== 'undefined' || isHeadlessGLRegistered();\n }\n\n readonly info: DeviceInfo;\n readonly canvasContext: WebGLCanvasContext;\n readonly lost: Promise<{reason: 'destroyed'; message: string}>;\n readonly handle: WebGLRenderingContext;\n\n get features(): Set<DeviceFeature> {\n this._features = this._features || getDeviceFeatures(this.gl);\n return this._features;\n }\n\n get limits(): DeviceLimits {\n this._limits = this._limits || getDeviceLimits(this.gl);\n return this._limits;\n }\n\n // WebGL specific API\n\n /** WebGL1 typed context. Can always be used. */\n readonly gl: WebGLRenderingContext;\n /** WebGL2 typed context. Need to check isWebGL2 or isWebGL1 before using. */\n readonly gl2: WebGL2RenderingContext;\n readonly debug: boolean = false;\n\n /** `true` if this is a WebGL1 context. @note `false` if WebGL2 */\n readonly isWebGL1: boolean;\n /** `true` if this is a WebGL2 context. @note `false` if WebGL1 */\n readonly isWebGL2: boolean;\n\n get webglLimits(): WebGLLimits {\n this._webglLimits = this._webglLimits || getWebGLLimits(this.gl);\n return this._webglLimits;\n }\n\n private _features: Set<DeviceFeature>;\n private _limits: DeviceLimits;\n private _webglLimits: WebGLLimits;\n\n /** State used by luma.gl classes: TODO - move to canvasContext*/\n readonly _canvasSizeInfo = {clientWidth: 0, clientHeight: 0, devicePixelRatio: 1};\n /** State used by luma.gl classes */\n readonly _extensions: Record<string, any> = {};\n _polyfilled: boolean = false;\n\n /** Instance of Spector.js (if initialized) */\n spector;\n\n /**\n * Get a device instance from a GL context\n * Creates and instruments the device if not already created\n * @param gl\n * @returns\n */\n static attach(gl: Device | WebGLRenderingContext | WebGL2RenderingContext): WebGLDevice {\n if (gl instanceof WebGLDevice) {\n return gl;\n }\n // @ts-expect-error\n if (gl?.device instanceof Device) {\n // @ts-expect-error\n return gl.device as WebGLDevice;\n }\n if (!isWebGL(gl)) {\n throw new Error('Invalid WebGLRenderingContext');\n }\n return new WebGLDevice({gl: gl as WebGLRenderingContext});\n }\n\n static async create(props?: DeviceProps): Promise<WebGLDevice> {\n log.groupCollapsed(LOG_LEVEL, 'WebGLDevice created');\n\n // Wait for page to load. Only wait when props. canvas is string\n // to avoid setting page onload callback unless necessary\n if (typeof props.canvas === 'string') {\n await CanvasContext.pageLoaded;\n }\n\n // Load webgl and spector debug scripts from CDN if requested\n if (props.debug) {\n await loadWebGLDeveloperTools();\n }\n // @ts-expect-error spector not on props\n if (props.spector) {\n await loadSpectorJS();\n }\n\n log.probe(LOG_LEVEL, 'DOM is loaded')();\n return new WebGLDevice(props);\n }\n\n constructor(props: DeviceProps) {\n super(props);\n\n // If attaching to an already attached context, return the attached device\n // @ts-expect-error device is attached to context\n const device: WebGLDevice | undefined = props.gl?.device;\n if (device) {\n log.warn(`WebGL context already attached to device ${device.id}`);\n return device;\n }\n\n // Create and instrument context\n this.canvasContext = new WebGLCanvasContext(this, props);\n\n let gl = props.gl;\n gl = gl || (isBrowser() && createBrowserContext(this.canvasContext.canvas, props));\n gl = gl || (!isBrowser() && createHeadlessContext(props));\n\n this.handle = gl;\n this.gl = this.handle;\n this.gl2 = this.gl as WebGL2RenderingContext;\n this.isWebGL2 = isWebGL2(this.gl);\n this.isWebGL1 = !this.isWebGL2;\n\n // luma Device fields\n this.info = getDeviceInfo(this.gl);\n\n // @ts-expect-error Link webgl context back to device\n this.gl.device = this;\n // @ts-expect-error Annotate webgl context to handle \n this.gl._version = this.isWebGL2 ? 2 : 1;\n\n // Add subset of WebGL2 methods to WebGL1 context\n polyfillContext(this.gl);\n\n // Install context state tracking\n // @ts-expect-error - hidden parameters\n const {enable = true, copyState = false} = props;\n trackContextState(this.gl, {\n enable,\n copyState, \n log: (...args: any[]) => log.log(1, ...args)()\n });\n\n // DEBUG contexts: Add debug instrumentation to the context, force log level to at least 1\n if (isBrowser() && props.debug) {\n this.gl = makeDebugContext(this.gl, {...props, webgl2: this.isWebGL2, throwOnError: true});\n this.gl2 = this.gl as WebGL2RenderingContext;\n this.debug = true;\n log.level = Math.max(log.level, 1);\n log.warn('WebGL debug mode activated. Performance reduced.')();\n }\n\n // @ts-expect-error spector not on props\n if (isBrowser() && props.spector) {\n const canvas = this.handle.canvas || (props.canvas as HTMLCanvasElement);\n this.spector = initializeSpectorJS({...this.props, canvas});\n }\n\n // Log some debug info about the newly created context\n const message = `\\\nCreated ${this.info.type}${this.debug ? ' debug' : ''} context: \\\n${this.info.vendor}, ${this.info.renderer} for canvas: ${this.canvasContext.id}`;\n log.probe(LOG_LEVEL, message)();\n\n log.groupEnd(LOG_LEVEL)();\n }\n\n /**\n * Destroys the context\n * @note Has no effect for browser contexts, there is no browser API for destroying contexts\n */\n destroy() {\n let ext = this.gl.getExtension('STACKGL_destroy_context');\n if (ext) {\n ext.destroy();\n }\n // ext = this.gl.getExtension('WEBGL_lose_context');\n // if (ext) {\n // // TODO - disconnect context lost callbacks?\n // ext.loseContext();\n // }\n }\n\n get isLost(): boolean {\n return this.gl.isContextLost();\n }\n\n getSize(): [number, number] {\n return [this.gl.drawingBufferWidth, this.gl.drawingBufferHeight];\n }\n\n isTextureFormatSupported(format: TextureFormat): boolean {\n return isTextureFormatSupported(this.gl, format);\n }\n\n isTextureFormatFilterable(format: TextureFormat): boolean {\n return isTextureFormatFilterable(this.gl, format);\n }\n\n isTextureFormatRenderable(format: TextureFormat): boolean {\n return isTextureFormatRenderable(this.gl, format);\n }\n\n // WEBGL SPECIFIC METHODS\n\n /** Returns a WebGL2RenderingContext or throws an error */\n assertWebGL2(): WebGL2RenderingContext {\n assert(this.isWebGL2, 'Requires WebGL2');\n return this.gl2;\n }\n\n // IMPLEMENTATION OF ABSTRACT DEVICE\n\n createCanvasContext(props?: CanvasContextProps): CanvasContext {\n throw new Error('WebGL only supports a single canvas');\n }\n\n _createBuffer(props: BufferProps): WEBGLBuffer {\n return new ClassicBuffer(this, props);\n }\n\n _createTexture(props: TextureProps): WEBGLTexture {\n return new WEBGLTexture(this, props);\n }\n\n createExternalTexture(props: ExternalTextureProps): ExternalTexture {\n throw new Error('createExternalTexture() not implemented'); // return new Program(props);\n }\n\n createSampler(props: SamplerProps): WEBGLSampler {\n return new WEBGLSampler(this, props);\n }\n\n createShader(props: ShaderProps): WEBGLShader {\n return new WEBGLShader(this, props);\n }\n\n createFramebuffer(props: FramebufferProps): WEBGLFramebuffer {\n return new WEBGLFramebuffer(this, props);\n }\n\n createRenderPipeline(props: RenderPipelineProps): WEBGLRenderPipeline {\n return new WEBGLRenderPipeline(this, props);\n }\n\n beginRenderPass(props: RenderPassProps): WEBGLRenderPass {\n return new WEBGLRenderPass(this, props);\n }\n\n createComputePipeline(props?: ComputePipelineProps): ComputePipeline {\n throw new Error('ComputePipeline not supported in WebGL');\n }\n\n beginComputePass(props: ComputePassProps): ComputePass {\n throw new Error('compute shaders not supported in WebGL');\n }\n\n private renderPass: WEBGLRenderPass;\n\n getDefaultRenderPass(): WEBGLRenderPass {\n this.renderPass =\n this.renderPass ||\n this.beginRenderPass({\n framebuffer: this.canvasContext.getCurrentFramebuffer()\n });\n return this.renderPass;\n }\n\n /**\n * Offscreen Canvas Support: Commit the frame\n * https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/commit\n * Chrome's offscreen canvas does not require gl.commit\n */\n submit(): void {\n this.renderPass.endPass();\n this.renderPass = null;\n // this.canvasContext.commit();\n }\n}\n\n/** Check if supplied parameter is a WebGLRenderingContext */\nfunction isWebGL(gl: any): boolean {\n if (typeof WebGLRenderingContext !== 'undefined' && gl instanceof WebGLRenderingContext) {\n return true;\n }\n if (typeof WebGL2RenderingContext !== 'undefined' && gl instanceof WebGL2RenderingContext) {\n return true;\n }\n // Look for debug contexts, headless gl etc\n return Boolean(gl && Number.isFinite(gl._version));\n}\n\n\n/** Check if supplied parameter is a WebGL2RenderingContext */\nfunction isWebGL2(gl: any): boolean {\n if (typeof WebGL2RenderingContext !== 'undefined' && gl instanceof WebGL2RenderingContext) {\n return true;\n }\n // Look for debug contexts, headless gl etc\n return Boolean(gl && gl._version === 2);\n}\n"],"file":"webgl-device.js"}
1
+ {"version":3,"sources":["../../../src/adapter/webgl-device.ts"],"names":["Device","CanvasContext","log","isBrowser","polyfillContext","trackContextState","createBrowserContext","createHeadlessContext","isHeadlessGLRegistered","getDeviceInfo","getDeviceFeatures","getDeviceLimits","getWebGLLimits","WebGLCanvasContext","loadSpectorJS","initializeSpectorJS","loadWebGLDeveloperTools","makeDebugContext","isTextureFormatSupported","isTextureFormatRenderable","isTextureFormatFilterable","ClassicBuffer","WEBGLShader","WEBGLSampler","WEBGLTexture","WEBGLFramebuffer","WEBGLRenderPass","WEBGLRenderPipeline","LOG_LEVEL","counter","WebGLDevice","isSupported","WebGLRenderingContext","features","_features","gl","limits","_limits","webglLimits","_webglLimits","attach","device","isWebGL","Error","create","props","groupCollapsed","canvas","pageLoaded","debug","spector","probe","constructor","clientWidth","clientHeight","devicePixelRatio","id","canvasContext","lost","Promise","resolve","_resolveContextLost","onContextLost","event","reason","message","handle","gl2","isWebGL2","isWebGL1","info","_version","enable","copyState","args","webgl2","throwOnError","level","Math","max","warn","type","vendor","renderer","groupEnd","destroy","ext","getExtension","loseDevice","loseContext","isLost","isContextLost","getSize","drawingBufferWidth","drawingBufferHeight","format","assertWebGL2","createCanvasContext","_createBuffer","_createTexture","createExternalTexture","createSampler","createShader","createFramebuffer","createRenderPipeline","beginRenderPass","createComputePipeline","beginComputePass","getDefaultRenderPass","renderPass","framebuffer","getCurrentFramebuffer","submit","endPass","WebGL2RenderingContext","Boolean","Number","isFinite"],"mappings":";AASA,SAAQA,MAAR,EAAgBC,aAAhB,EAA+BC,GAA/B,QAAiD,cAAjD;AACA,SAAQC,SAAR,QAAwB,eAAxB;AACA,SAAQC,eAAR,QAA8B,sCAA9B;AACA,SAAQC,iBAAR,QAAgC,8CAAhC;AAEA,SAAQC,oBAAR,QAAmC,2CAAnC;AACA,SACEC,qBADF,EAEEC,sBAFF,QAGO,4CAHP;AAIA,SAAQC,aAAR,QAA4B,kCAA5B;AACA,SAAQC,iBAAR,QAAgC,kCAAhC;AACA,SAAQC,eAAR,EAAyBC,cAAzB,QAA2D,gCAA3D;AACA,OAAOC,kBAAP,MAA+B,wBAA/B;AACA,SAAQC,aAAR,EAAuBC,mBAAvB,QAAiD,0BAAjD;AACA,SAAQC,uBAAR,EAAiCC,gBAAjC,QAAwD,wCAAxD;AACA,SACEC,wBADF,EAEEC,yBAFF,EAGEC,yBAHF,QAIO,8BAJP;AA0BA,OAAOC,aAAP,MAA0B,mBAA1B;AAEA,OAAOC,WAAP,MAAwB,0BAAxB;AACA,OAAOC,YAAP,MAAyB,2BAAzB;AACA,OAAOC,YAAP,MAAyB,2BAAzB;AACA,OAAOC,gBAAP,MAA6B,+BAA7B;AACA,OAAOC,eAAP,MAA4B,+BAA5B;AACA,OAAOC,mBAAP,MAAgC,mCAAhC;AAEA,MAAMC,SAAS,GAAG,CAAlB;AAEA,IAAIC,OAAO,GAAG,CAAd;AAGA,eAAe,MAAMC,WAAN,SAA0B9B,MAA1B,CAAyD;AAOpD,SAAX+B,WAAW,GAAY;AAC5B,WAAO,OAAOC,qBAAP,KAAiC,WAAjC,IAAgDxB,sBAAsB,EAA7E;AACD;;AAOW,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AtUqE;;gBAAnD/E,W,UAKG,O;;AAqUxB,SAASY,OAAT,CAAiBP,EAAjB,EAAmC;AACjC,MAAI,OAAOH,qBAAP,KAAiC,WAAjC,IAAgDG,EAAE,YAAYH,qBAAlE,EAAyF;AACvF,WAAO,IAAP;AACD;;AACD,MAAI,OAAOkF,sBAAP,KAAkC,WAAlC,IAAiD/E,EAAE,YAAY+E,sBAAnE,EAA2F;AACzF,WAAO,IAAP;AACD;;AAED,SAAOC,OAAO,CAAChF,EAAE,IAAIiF,MAAM,CAACC,QAAP,CAAgBlF,EAAE,CAACoC,QAAnB,CAAP,CAAd;AACD;;AAGD,SAASH,QAAT,CAAkBjC,EAAlB,EAAoC;AAClC,MAAI,OAAO+E,sBAAP,KAAkC,WAAlC,IAAiD/E,EAAE,YAAY+E,sBAAnE,EAA2F;AACzF,WAAO,IAAP;AACD;;AAED,SAAOC,OAAO,CAAChF,EAAE,IAAIA,EAAE,CAACoC,QAAH,KAAgB,CAAvB,CAAd;AACD","sourcesContent":["// luma.gl, MIT license\nimport type {\n DeviceProps,\n DeviceInfo,\n DeviceLimits,\n DeviceFeature,\n CanvasContextProps,\n TextureFormat\n} from '@luma.gl/api';\nimport {Device, CanvasContext, log, assert} from '@luma.gl/api';\nimport {isBrowser} from '@probe.gl/env';\nimport {polyfillContext} from '../context/polyfill/polyfill-context';\nimport {trackContextState} from '../context/state-tracker/track-context-state';\nimport {ContextState} from '../context/context/context-state';\nimport {createBrowserContext} from '../context/context/create-browser-context';\nimport {\n createHeadlessContext,\n isHeadlessGLRegistered\n} from '../context/context/create-headless-context';\nimport {getDeviceInfo} from './device-helpers/get-device-info';\nimport {getDeviceFeatures} from './device-helpers/device-features';\nimport {getDeviceLimits, getWebGLLimits, WebGLLimits} from './device-helpers/device-limits';\nimport WebGLCanvasContext from './webgl-canvas-context';\nimport {loadSpectorJS, initializeSpectorJS} from '../context/debug/spector';\nimport {loadWebGLDeveloperTools, makeDebugContext} from '../context/debug/webgl-developer-tools';\nimport {\n isTextureFormatSupported,\n isTextureFormatRenderable,\n isTextureFormatFilterable\n} from './converters/texture-formats';\n\n// WebGL classes\nimport type {\n BufferProps,\n ShaderProps,\n Sampler,\n SamplerProps,\n TextureProps,\n ExternalTexture,\n ExternalTextureProps,\n FramebufferProps,\n RenderPipeline,\n RenderPipelineProps,\n ComputePipeline,\n ComputePipelineProps,\n RenderPass,\n RenderPassProps,\n ComputePass,\n ComputePassProps\n} from '@luma.gl/api';\n\nimport ClassicBuffer from '../classic/buffer';\nimport WEBGLBuffer from './resources/webgl-buffer';\nimport WEBGLShader from './resources/webgl-shader';\nimport WEBGLSampler from './resources/webgl-sampler';\nimport WEBGLTexture from './resources/webgl-texture';\nimport WEBGLFramebuffer from './resources/webgl-framebuffer';\nimport WEBGLRenderPass from './resources/webgl-render-pass';\nimport WEBGLRenderPipeline from './resources/webgl-render-pipeline';\n\nconst LOG_LEVEL = 1;\n\nlet counter = 0;\n\n/** WebGPU style Device API for a WebGL context */\nexport default class WebGLDevice extends Device implements ContextState {\n //\n // Public `Device` API\n //\n\n static type: string = 'webgl';\n\n static isSupported(): boolean {\n return typeof WebGLRenderingContext !== 'undefined' || isHeadlessGLRegistered();\n }\n\n readonly info: DeviceInfo;\n readonly canvasContext: WebGLCanvasContext;\n\n readonly handle: WebGLRenderingContext;\n\n get features(): Set<DeviceFeature> {\n this._features = this._features || getDeviceFeatures(this.gl);\n return this._features;\n }\n\n get limits(): DeviceLimits {\n this._limits = this._limits || getDeviceLimits(this.gl);\n return this._limits;\n }\n\n readonly lost: Promise<{reason: 'destroyed'; message: string}>;\n\n private _resolveContextLost?: (value: {reason: 'destroyed'; message: string}) => void;\n private _features?: Set<DeviceFeature>;\n private _limits?: DeviceLimits;\n\n //\n // WebGL-only API (not part of `Device` API)\n //\n\n /** WebGL1 typed context. Can always be used. */\n readonly gl: WebGLRenderingContext;\n /** WebGL2 typed context. Need to check isWebGL2 or isWebGL1 before using. */\n readonly gl2: WebGL2RenderingContext | null = null;\n readonly debug: boolean = false;\n\n /** `true` if this is a WebGL1 context. @note `false` if WebGL2 */\n readonly isWebGL1: boolean;\n /** `true` if this is a WebGL2 context. @note `false` if WebGL1 */\n readonly isWebGL2: boolean;\n\n get webglLimits(): WebGLLimits {\n this._webglLimits = this._webglLimits || getWebGLLimits(this.gl);\n return this._webglLimits;\n }\n\n private _webglLimits?: WebGLLimits;\n\n /** State used by luma.gl classes: TODO - move to canvasContext*/\n readonly _canvasSizeInfo = {clientWidth: 0, clientHeight: 0, devicePixelRatio: 1};\n /** State used by luma.gl classes */\n readonly _extensions: Record<string, any> = {};\n _polyfilled: boolean = false;\n\n /** Instance of Spector.js (if initialized) */\n spector;\n\n //\n // Static methods, expected to be present by `luma.createDevice()`\n //\n\n /**\n * Get a device instance from a GL context\n * Creates and instruments the device if not already created\n * @param gl\n * @returns\n */\n static attach(gl: Device | WebGLRenderingContext | WebGL2RenderingContext): WebGLDevice {\n if (gl instanceof WebGLDevice) {\n return gl;\n }\n // @ts-expect-error\n if (gl?.device instanceof Device) {\n // @ts-expect-error\n return gl.device as WebGLDevice;\n }\n if (!isWebGL(gl)) {\n throw new Error('Invalid WebGLRenderingContext');\n }\n return new WebGLDevice({gl: gl as WebGLRenderingContext});\n }\n\n static async create(props: DeviceProps = {}): Promise<WebGLDevice> {\n log.groupCollapsed(LOG_LEVEL, 'WebGLDevice created');\n\n // Wait for page to load. Only wait when props. canvas is string\n // to avoid setting page onload callback unless necessary\n if (typeof props.canvas === 'string') {\n await CanvasContext.pageLoaded;\n }\n\n // Load webgl and spector debug scripts from CDN if requested\n if (props.debug) {\n await loadWebGLDeveloperTools();\n }\n // @ts-expect-error spector not on props\n if (props.spector) {\n await loadSpectorJS();\n }\n\n log.probe(LOG_LEVEL + 1, 'DOM is loaded')();\n\n // @ts-expect-error\n if (props.gl && props.gl.device) {\n return WebGLDevice.attach(props.gl);\n }\n\n return new WebGLDevice(props);\n }\n\n //\n // Public API\n //\n\n constructor(props: DeviceProps) {\n super(props);\n\n // If attaching to an already attached context, return the attached device\n // @ts-expect-error device is attached to context\n const device: WebGLDevice | undefined = props.gl?.device;\n if (device) {\n throw new Error(`WebGL context already attached to device ${device.id}`);\n }\n\n // Create and instrument context\n this.canvasContext = new WebGLCanvasContext(this, props);\n\n this.lost = new Promise<{reason: 'destroyed'; message: string}>((resolve) => {\n this._resolveContextLost = resolve;\n });\n\n const onContextLost = (event: Event) =>\n this._resolveContextLost?.({\n reason: 'destroyed',\n message: 'Computer entered sleep mode, or too many apps or browser tabs are using the GPU.'\n });\n\n let gl: WebGLRenderingContext | WebGL2RenderingContext | null = props.gl;\n gl =\n gl ||\n (isBrowser() ? createBrowserContext(this.canvasContext.canvas, {...props, onContextLost}) : null);\n gl = gl || (!isBrowser() ? createHeadlessContext({...props, onContextLost}) : null);\n\n if (!gl) {\n throw new Error('WebGL context creation failed');\n }\n\n this.handle = gl;\n this.gl = this.handle;\n this.gl2 = this.gl as WebGL2RenderingContext;\n this.isWebGL2 = isWebGL2(this.gl);\n this.isWebGL1 = !this.isWebGL2;\n\n // luma Device fields\n this.info = getDeviceInfo(this.gl);\n\n // @ts-expect-error Link webgl context back to device\n this.gl.device = this;\n // @ts-expect-error Annotate webgl context to handle\n this.gl._version = this.isWebGL2 ? 2 : 1;\n\n // Add subset of WebGL2 methods to WebGL1 context\n polyfillContext(this.gl);\n\n // Install context state tracking\n // @ts-expect-error - hidden parameters\n const {enable = true, copyState = false} = props;\n trackContextState(this.gl, {\n enable,\n copyState,\n log: (...args: any[]) => log.log(1, ...args)()\n });\n\n // DEBUG contexts: Add debug instrumentation to the context, force log level to at least 1\n if (isBrowser() && props.debug) {\n this.gl = makeDebugContext(this.gl, {...props, webgl2: this.isWebGL2, throwOnError: true});\n this.gl2 = this.gl as WebGL2RenderingContext;\n this.debug = true;\n log.level = Math.max(log.level, 1);\n log.warn('WebGL debug mode activated. Performance reduced.')();\n }\n\n // @ts-expect-error spector not on props\n if (isBrowser() && props.spector) {\n const canvas = this.handle.canvas || (props.canvas as HTMLCanvasElement);\n this.spector = initializeSpectorJS({...this.props, canvas});\n }\n\n // Log some debug info about the newly created context\n const message = `\\\nCreated ${this.info.type}${this.debug ? ' debug' : ''} context: \\\n${this.info.vendor}, ${this.info.renderer} for canvas: ${this.canvasContext.id}`;\n log.probe(LOG_LEVEL, message)();\n\n log.groupEnd(LOG_LEVEL)();\n }\n\n /**\n * Destroys the context\n * @note Has no effect for browser contexts, there is no browser API for destroying contexts\n */\n destroy() {\n const ext = this.gl.getExtension('STACKGL_destroy_context');\n if (ext) {\n ext.destroy();\n }\n }\n\n /**\n * Loses the context\n * @note Triggers context loss, mainly for testing\n */\n loseDevice() {\n const ext = this.gl.getExtension('WEBGL_lose_context');\n if (ext) {\n ext.loseContext();\n }\n // loseContext should trigger context loss callback but \n this._resolveContextLost?.({\n reason: 'destroyed',\n message: 'Application triggered context loss'\n });\n }\n\n get isLost(): boolean {\n return this.gl.isContextLost();\n }\n\n getSize(): [number, number] {\n return [this.gl.drawingBufferWidth, this.gl.drawingBufferHeight];\n }\n\n isTextureFormatSupported(format: TextureFormat): boolean {\n return isTextureFormatSupported(this.gl, format);\n }\n\n isTextureFormatFilterable(format: TextureFormat): boolean {\n return isTextureFormatFilterable(this.gl, format);\n }\n\n isTextureFormatRenderable(format: TextureFormat): boolean {\n return isTextureFormatRenderable(this.gl, format);\n }\n\n // WEBGL SPECIFIC METHODS\n\n /** Returns a WebGL2RenderingContext or throws an error */\n assertWebGL2(): WebGL2RenderingContext {\n if (!this.gl2) {\n throw new Error('Requires WebGL2');\n }\n return this.gl2;\n }\n\n // IMPLEMENTATION OF ABSTRACT DEVICE\n\n createCanvasContext(props?: CanvasContextProps): CanvasContext {\n throw new Error('WebGL only supports a single canvas');\n }\n\n _createBuffer(props: BufferProps): WEBGLBuffer {\n return new ClassicBuffer(this, props);\n }\n\n _createTexture(props: TextureProps): WEBGLTexture {\n return new WEBGLTexture(this, props);\n }\n\n createExternalTexture(props: ExternalTextureProps): ExternalTexture {\n throw new Error('createExternalTexture() not implemented'); // return new Program(props);\n }\n\n createSampler(props: SamplerProps): WEBGLSampler {\n return new WEBGLSampler(this, props);\n }\n\n createShader(props: ShaderProps): WEBGLShader {\n return new WEBGLShader(this, props);\n }\n\n createFramebuffer(props: FramebufferProps): WEBGLFramebuffer {\n return new WEBGLFramebuffer(this, props);\n }\n\n createRenderPipeline(props: RenderPipelineProps): WEBGLRenderPipeline {\n return new WEBGLRenderPipeline(this, props);\n }\n\n beginRenderPass(props: RenderPassProps): WEBGLRenderPass {\n return new WEBGLRenderPass(this, props);\n }\n\n createComputePipeline(props?: ComputePipelineProps): ComputePipeline {\n throw new Error('ComputePipeline not supported in WebGL');\n }\n\n beginComputePass(props: ComputePassProps): ComputePass {\n throw new Error('compute shaders not supported in WebGL');\n }\n\n private renderPass: WEBGLRenderPass | null = null;\n\n getDefaultRenderPass(): WEBGLRenderPass {\n this.renderPass =\n this.renderPass ||\n this.beginRenderPass({\n framebuffer: this.canvasContext.getCurrentFramebuffer()\n });\n return this.renderPass;\n }\n\n /**\n * Offscreen Canvas Support: Commit the frame\n * https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/commit\n * Chrome's offscreen canvas does not require gl.commit\n */\n submit(): void {\n this.renderPass?.endPass();\n this.renderPass = null;\n // this.canvasContext.commit();\n }\n}\n\n/** Check if supplied parameter is a WebGLRenderingContext */\nfunction isWebGL(gl: any): boolean {\n if (typeof WebGLRenderingContext !== 'undefined' && gl instanceof WebGLRenderingContext) {\n return true;\n }\n if (typeof WebGL2RenderingContext !== 'undefined' && gl instanceof WebGL2RenderingContext) {\n return true;\n }\n // Look for debug contexts, headless gl etc\n return Boolean(gl && Number.isFinite(gl._version));\n}\n\n/** Check if supplied parameter is a WebGL2RenderingContext */\nfunction isWebGL2(gl: any): boolean {\n if (typeof WebGL2RenderingContext !== 'undefined' && gl instanceof WebGL2RenderingContext) {\n return true;\n }\n // Look for debug contexts, headless gl etc\n return Boolean(gl && gl._version === 2);\n}\n"],"file":"webgl-device.js"}
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../src/classic/accessor.ts"],"names":["assert","checkProps","GL","getTypedArrayFromGLType","DEFAULT_ACCESSOR_VALUES","offset","stride","type","FLOAT","size","divisor","normalized","integer","PROP_CHECKS","deprecatedProps","instanced","isInstanced","Accessor","getBytesPerElement","accessor","ArrayType","BYTES_PER_ELEMENT","getBytesPerVertex","resolve","accessors","constructor","forEach","_assign","Object","freeze","toString","JSON","stringify","BYTES_PER_VERTEX","props","undefined","INT","UNSIGNED_INT","normalize","buffer","index"],"mappings":";AAAA,SAAQA,MAAR,EAAgBC,UAAhB,QAAyD,cAAzD;AACA,OAAOC,EAAP,MAAe,oBAAf;AACA,SAAQC,uBAAR,QAAsC,qBAAtC;AAeA,MAAMC,uBAAuB,GAAG;AAC9BC,EAAAA,MAAM,EAAE,CADsB;AAE9BC,EAAAA,MAAM,EAAE,CAFsB;AAG9BC,EAAAA,IAAI,EAAEL,EAAE,CAACM,KAHqB;AAI9BC,EAAAA,IAAI,EAAE,CAJwB;AAK9BC,EAAAA,OAAO,EAAE,CALqB;AAM9BC,EAAAA,UAAU,EAAE,KANkB;AAO9BC,EAAAA,OAAO,EAAE;AAPqB,CAAhC;AAUA,MAAMC,WAAW,GAAG;AAClBC,EAAAA,eAAe,EAAE;AACfC,IAAAA,SAAS,EAAE,SADI;AAEfC,IAAAA,WAAW,EAAE;AAFE;AADC,CAApB;AAOA,eAAe,MAAMC,QAAN,CAAyC;AAY7B,SAAlBC,kBAAkB,CAACC,QAAD,EAA8C;AAGrE,UAAMC,SAAS,GAAGjB,uBAAuB,CAACgB,QAAQ,CAACZ,IAAT,IAAiBL,EAAE,CAACM,KAArB,CAAzC;AACA,WAAOY,SAAS,CAACC,iBAAjB;AACD;;AAEuB,SAAjBC,iBAAiB,CAACH,QAAD,EAAmC;AACzDnB,IAAAA,MAAM,CAACmB,QAAQ,CAACV,IAAV,CAAN;AAGA,UAAMW,SAAS,GAAG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SAAN,GAAkB,CAAlB,GAAsB,CAArC;AACD;;AAED,QAAImB,KAAK,CAAClB,WAAN,KAAsBmB,SAA1B,EAAqC;AAEnC,WAAKzB,OAAL,GAAewB,KAAK,CAAClB,WAAN,GAAoB,CAApB,GAAwB,CAAvC;AACD;;AAED,QAAI,KAAKX,MAAL,KAAgB8B,SAApB,EAA+B,OAAO,KAAK9B,MAAZ;AAC/B,QAAI,KAAKC,MAAL,KAAgB6B,SAApB,EAA+B,OAAO,KAAK7B,MAAZ;AAC/B,QAAI,KAAKC,IAAL,KAAc4B,SAAlB,EAA6B,OAAO,KAAK5B,IAAZ;AAC7B,QAAI,KAAKE,IAAL,KAAc0B,SAAlB,EAA6B,OAAO,KAAK1B,IAAZ;AAC7B,QAAI,KAAKC,OAAL,KAAiByB,SAArB,EAAgC,OAAO,KAAKzB,OAAZ;AAChC,QAAI,KAAKC,UAAL,KAAoBwB,SAAxB,EAAmC,OAAO,KAAKxB,UAAZ;AACnC,QAAI,KAAKC,OAAL,KAAiBuB,SAArB,EAAgC,OAAO,KAAKvB,OAAZ;AAEhC,QAAI,KAAK2B,MAAL,KAAgBJ,SAApB,EAA+B,OAAO,KAAKI,MAAZ;AAC/B,QAAI,KAAKC,KAAL,KAAeL,SAAnB,EAA8B,OAAO,KAAKK,KAAZ;AAE9B,WAAO,IAAP;AACD;;AAtIqD;AA0IxD,SAAQpC,uBAAR","sourcesContent":["import {assert, checkProps, Buffer, AccessorObject} from '@luma.gl/api';\nimport GL from '@luma.gl/constants';\nimport {getTypedArrayFromGLType} from './typed-array-utils';\n\n// export interface AccessorObject {\n// offset?: number;\n// stride?: number;\n// type?: number;\n// size?: number;\n// divisor?: number;\n// normalized?: boolean;\n// integer?: boolean;\n\n// buffer?: Buffer;\n// index?: number;\n// }\n\nconst DEFAULT_ACCESSOR_VALUES = {\n offset: 0,\n stride: 0,\n type: GL.FLOAT,\n size: 1,\n divisor: 0,\n normalized: false,\n integer: false\n};\n\nconst PROP_CHECKS = {\n deprecatedProps: {\n instanced: 'divisor',\n isInstanced: 'divisor'\n }\n};\n\nexport default class Accessor implements AccessorObject {\n offset?: number;\n stride?: number;\n type?: number;\n size?: number;\n divisor?: number;\n normalized?: boolean;\n integer?: boolean;\n\n buffer?: Buffer;\n index?: number;\n\n static getBytesPerElement(accessor: Accessor | AccessorObject): number {\n // TODO: using `FLOAT` when type is not specified,\n // ensure this assumption is valid or force API to specify type.\n const ArrayType = getTypedArrayFromGLType(accessor.type || GL.FLOAT);\n return ArrayType.BYTES_PER_ELEMENT;\n }\n\n static getBytesPerVertex(accessor: AccessorObject): number {\n assert(accessor.size);\n // TODO: using `FLOAT` when type is not specified,\n // ensure this assumption is valid or force API to specify type.\n const ArrayType = getTypedArrayFromGLType(accessor.type || GL.FLOAT);\n return ArrayType.BYTES_PER_ELEMENT * accessor.size;\n }\n\n // Combines (merges) a list of accessors. On top of default values\n // Usually [programAccessor, bufferAccessor, appAccessor]\n // All props will be set in the returned object.\n // TODO check for conflicts between values in the supplied accessors\n static resolve(...accessors: AccessorObject[]): Accessor {\n return new Accessor(...[DEFAULT_ACCESSOR_VALUES, ...accessors]); // Default values\n }\n\n constructor(...accessors: AccessorObject[]) {\n accessors.forEach((accessor) => this._assign(accessor)); // Merge in sequence\n Object.freeze(this);\n }\n\n toString(): string {\n return JSON.stringify(this);\n }\n\n // ACCESSORS\n\n // TODO - remove>\n get BYTES_PER_ELEMENT(): number {\n return Accessor.getBytesPerElement(this);\n }\n\n get BYTES_PER_VERTEX(): number {\n return Accessor.getBytesPerVertex(this);\n }\n\n // PRIVATE\n\n // eslint-disable-next-line complexity, max-statements\n _assign(props: AccessorObject = {}): this {\n props = checkProps('Accessor', props, PROP_CHECKS);\n\n if (props.type !== undefined) {\n this.type = props.type;\n\n // Auto-deduce integer type?\n if (props.type === GL.INT || props.type === GL.UNSIGNED_INT) {\n this.integer = true;\n }\n }\n if (props.size !== undefined) {\n this.size = props.size;\n }\n if (props.offset !== undefined) {\n this.offset = props.offset;\n }\n if (props.stride !== undefined) {\n this.stride = props.stride;\n }\n // @ts-expect-error\n if (props.normalize !== undefined) {\n // @ts-expect-error\n this.normalized = props.normalize;\n }\n if (props.normalized !== undefined) {\n this.normalized = props.normalized;\n }\n if (props.integer !== undefined) {\n this.integer = props.integer;\n }\n\n // INSTANCE DIVISOR\n if (props.divisor !== undefined) {\n this.divisor = props.divisor;\n }\n\n // Buffer is optional\n if (props.buffer !== undefined) {\n this.buffer = props.buffer;\n }\n\n // The binding index (for binding e.g. Transform feedbacks and Uniform buffers)\n // TODO - should this be part of accessor?\n if (props.index !== undefined) {\n if (typeof props.index === 'boolean') {\n this.index = props.index ? 1 : 0;\n } else {\n this.index = props.index;\n }\n }\n\n // DEPRECATED\n // @ts-expect-error\n if (props.instanced !== undefined) {\n // @ts-expect-error\n this.divisor = props.instanced ? 1 : 0;\n }\n // @ts-expect-error\n if (props.isInstanced !== undefined) {\n // @ts-expect-error\n this.divisor = props.isInstanced ? 1 : 0;\n }\n\n if (this.offset === undefined) delete this.offset;\n if (this.stride === undefined) delete this.stride;\n if (this.type === undefined) delete this.type;\n if (this.size === undefined) delete this.size;\n if (this.divisor === undefined) delete this.divisor;\n if (this.normalized === undefined) delete this.normalized;\n if (this.integer === undefined) delete this.integer;\n \n if (this.buffer === undefined) delete this.buffer;\n if (this.index === undefined) delete this.index;\n \n return this;\n }\n}\n\n// TEST EXPORTS\nexport {DEFAULT_ACCESSOR_VALUES};\n"],"file":"accessor.js"}
1
+ {"version":3,"sources":["../../../src/classic/accessor.ts"],"names":["assert","checkProps","GL","getTypedArrayFromGLType","DEFAULT_ACCESSOR_VALUES","offset","stride","type","FLOAT","size","divisor","normalized","integer","PROP_CHECKS","deprecatedProps","instanced","isInstanced","Accessor","getBytesPerElement","accessor","ArrayType","BYTES_PER_ELEMENT","getBytesPerVertex","resolve","accessors","constructor","forEach","_assign","Object","freeze","toString","JSON","stringify","BYTES_PER_VERTEX","props","undefined","INT","UNSIGNED_INT","normalize","buffer","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,EAA6B,OAAO,KAAK5B,IAAZ;AAC7B,QAAI,KAAKE,IAAL,KAAc0B,SAAlB,EAA6B,OAAO,KAAK1B,IAAZ;AAC7B,QAAI,KAAKC,OAAL,KAAiByB,SAArB,EAAgC,OAAO,KAAKzB,OAAZ;AAChC,QAAI,KAAKC,UAAL,KAAoBwB,SAAxB,EAAmC,OAAO,KAAKxB,UAAZ;AACnC,QAAI,KAAKC,OAAL,KAAiBuB,SAArB,EAAgC,OAAO,KAAKvB,OAAZ;AAEhC,QAAI,KAAK2B,MAAL,KAAgBJ,SAApB,EAA+B,OAAO,KAAKI,MAAZ;AAC/B,QAAI,KAAKC,KAAL,KAAeL,SAAnB,EAA8B,OAAO,KAAKK,KAAZ;AAE9B,WAAO,IAAP;AACD;;AAtIqD;AA0IxD,SAAQpC,uBAAR","sourcesContent":["import {assert, checkProps, Buffer, AccessorObject} from '@luma.gl/api';\nimport GL from '@luma.gl/constants';\nimport {getTypedArrayFromGLType} from './typed-array-utils';\n\nconst DEFAULT_ACCESSOR_VALUES = {\n offset: 0,\n stride: 0,\n type: GL.FLOAT,\n size: 1,\n divisor: 0,\n normalized: false,\n integer: false\n};\n\nconst PROP_CHECKS = {\n deprecatedProps: {\n instanced: 'divisor',\n isInstanced: 'divisor'\n }\n};\n\nexport default class Accessor implements AccessorObject {\n offset?: number;\n stride?: number;\n type?: number;\n size?: number;\n divisor?: number;\n normalized?: boolean;\n integer?: boolean;\n\n buffer?: Buffer;\n index?: number;\n\n static getBytesPerElement(accessor: Accessor | AccessorObject): number {\n // TODO: using `FLOAT` when type is not specified,\n // ensure this assumption is valid or force API to specify type.\n const ArrayType = getTypedArrayFromGLType(accessor.type || GL.FLOAT);\n return ArrayType.BYTES_PER_ELEMENT;\n }\n\n static getBytesPerVertex(accessor: AccessorObject): number {\n assert(accessor.size);\n // TODO: using `FLOAT` when type is not specified,\n // ensure this assumption is valid or force API to specify type.\n const ArrayType = getTypedArrayFromGLType(accessor.type || GL.FLOAT);\n return ArrayType.BYTES_PER_ELEMENT * accessor.size;\n }\n\n // Combines (merges) a list of accessors. On top of default values\n // Usually [programAccessor, bufferAccessor, appAccessor]\n // All props will be set in the returned object.\n // TODO check for conflicts between values in the supplied accessors\n static resolve(...accessors: AccessorObject[]): Accessor {\n return new Accessor(...[DEFAULT_ACCESSOR_VALUES, ...accessors]); // Default values\n }\n\n constructor(...accessors: AccessorObject[]) {\n accessors.forEach((accessor) => this._assign(accessor)); // Merge in sequence\n Object.freeze(this);\n }\n\n toString(): string {\n return JSON.stringify(this);\n }\n\n // ACCESSORS\n\n // TODO - remove>\n get BYTES_PER_ELEMENT(): number {\n return Accessor.getBytesPerElement(this);\n }\n\n get BYTES_PER_VERTEX(): number {\n return Accessor.getBytesPerVertex(this);\n }\n\n // PRIVATE\n\n // eslint-disable-next-line complexity, max-statements\n _assign(props: AccessorObject = {}): this {\n props = checkProps('Accessor', props, PROP_CHECKS);\n\n if (props.type !== undefined) {\n this.type = props.type;\n\n // Auto-deduce integer type?\n if (props.type === GL.INT || props.type === GL.UNSIGNED_INT) {\n this.integer = true;\n }\n }\n if (props.size !== undefined) {\n this.size = props.size;\n }\n if (props.offset !== undefined) {\n this.offset = props.offset;\n }\n if (props.stride !== undefined) {\n this.stride = props.stride;\n }\n // @ts-expect-error\n if (props.normalize !== undefined) {\n // @ts-expect-error\n this.normalized = props.normalize;\n }\n if (props.normalized !== undefined) {\n this.normalized = props.normalized;\n }\n if (props.integer !== undefined) {\n this.integer = props.integer;\n }\n\n // INSTANCE DIVISOR\n if (props.divisor !== undefined) {\n this.divisor = props.divisor;\n }\n\n // Buffer is optional\n if (props.buffer !== undefined) {\n this.buffer = props.buffer;\n }\n\n // The binding index (for binding e.g. Transform feedbacks and Uniform buffers)\n // TODO - should this be part of accessor?\n if (props.index !== undefined) {\n if (typeof props.index === 'boolean') {\n this.index = props.index ? 1 : 0;\n } else {\n this.index = props.index;\n }\n }\n\n // DEPRECATED\n // @ts-expect-error\n if (props.instanced !== undefined) {\n // @ts-expect-error\n this.divisor = props.instanced ? 1 : 0;\n }\n // @ts-expect-error\n if (props.isInstanced !== undefined) {\n // @ts-expect-error\n this.divisor = props.isInstanced ? 1 : 0;\n }\n\n if (this.offset === undefined) delete this.offset;\n if (this.stride === undefined) delete this.stride;\n if (this.type === undefined) delete this.type;\n if (this.size === undefined) delete this.size;\n if (this.divisor === undefined) delete this.divisor;\n if (this.normalized === undefined) delete this.normalized;\n if (this.integer === undefined) delete this.integer;\n \n if (this.buffer === undefined) delete this.buffer;\n if (this.index === undefined) delete this.index;\n \n return this;\n }\n}\n\n// TEST EXPORTS\nexport {DEFAULT_ACCESSOR_VALUES};\n"],"file":"accessor.js"}
@@ -43,11 +43,17 @@ export function createBrowserContext(canvas, props) {
43
43
  }
44
44
 
45
45
  if (props.onContextLost) {
46
- canvas.addEventListener('webglcontextlost', props.onContextLost, false);
46
+ const {
47
+ onContextLost
48
+ } = props;
49
+ canvas.addEventListener('webglcontextlost', event => onContextLost(event), false);
47
50
  }
48
51
 
49
52
  if (props.onContextRestored) {
50
- canvas.addEventListener('webglcontextrestored', props.onContextRestored, false);
53
+ const {
54
+ onContextRestored
55
+ } = props;
56
+ canvas.addEventListener('webglcontextrestored', event => onContextRestored(event), false);
51
57
  }
52
58
 
53
59
  return gl;
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../../src/context/context/create-browser-context.ts"],"names":["DEFAULT_CONTEXT_PROPS","webgl2","webgl1","powerPreference","onContextLost","console","error","onContextRestored","info","createBrowserContext","canvas","props","errorMessage","onCreateError","statusMessage","addEventListener","gl","type","getContext","removeEventListener","Error"],"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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,YAAY,IAAI,eAFd,EAAN;AAKD;;AAED,MAAID,KAAK,CAACP,aAAV,EAAyB;AACvBM,IAAAA,MAAM,CAACK,gBAAP,CAAwB,kBAAxB,EAA4CJ,KAAK,CAACP,aAAlD,EAAiE,KAAjE;AACD;;AACD,MAAIO,KAAK,CAACJ,iBAAV,EAA6B;AAC3BG,IAAAA,MAAM,CAACK,gBAAP,CAAwB,sBAAxB,EAAgDJ,KAAK,CAACJ,iBAAtD,EAAyE,KAAzE;AACD;;AAED,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: WebGLRenderingContext | null = null;\n\n if (props.type === 'webgl2') {\n props = {...props, webgl1: false};\n }\n if (props.type === 'webgl1') {\n props = {...props, webgl2: false};\n }\n\n // Prefer webgl2 over webgl1 if both are acceptable\n if (props.webgl2) {\n gl = gl || canvas.getContext('webgl2', props) as WebGL2RenderingContext | null;\n }\n if (props.webgl1) {\n gl = gl || canvas.getContext('webgl', props) as WebGLRenderingContext | null;\n }\n\n // TODO are we removing this listener before giving it a chance to fire?\n canvas.removeEventListener('webglcontextcreationerror', onCreateError, false);\n\n if (!gl) {\n throw new Error(\n `Failed to create ${props.webgl2 && !props.webgl1 ? 'WebGL2' : 'WebGL'} context: ${\n errorMessage || 'Unknown error'\n }`\n );\n }\n\n if (props.onContextLost) {\n canvas.addEventListener('webglcontextlost', props.onContextLost, false);\n }\n if (props.onContextRestored) {\n canvas.addEventListener('webglcontextrestored', props.onContextRestored, false);\n }\n\n return gl;\n}\n\n/* TODO - can we call this asynchronously to catch the error events?\nexport async function createBrowserContextAsync(canvas: HTMLCanvasElement | OffscreenCanvas, props: ContextProps): Promise<WebGLRenderingContext> {\n props = {...DEFAULT_CONTEXT_PROPS, ...props};\n\n // Try to extract any extra information about why context creation failed\n let errorMessage = null;\n const onCreateError = (error) => (errorMessage = error.statusMessage || errorMessage);\n canvas.addEventListener('webglcontextcreationerror', onCreateError, false);\n\n const gl = createBrowserContext(canvas, props);\n\n // Give the listener a chance to fire\n await new Promise(resolve => setTimeout(resolve, 0));\n\n canvas.removeEventListener('webglcontextcreationerror', onCreateError, false);\n\n return gl;\n}\n*/\n"],"file":"create-browser-context.js"}
1
+ {"version":3,"sources":["../../../../src/context/context/create-browser-context.ts"],"names":["DEFAULT_CONTEXT_PROPS","webgl2","webgl1","powerPreference","onContextLost","console","error","onContextRestored","info","createBrowserContext","canvas","props","errorMessage","onCreateError","statusMessage","addEventListener","gl","type","getContext","removeEventListener","Error","event"],"mappings":"AAmCA,MAAMA,qBAAmC,GAAG;AAC1CC,EAAAA,MAAM,EAAE,IADkC;AAE1CC,EAAAA,MAAM,EAAE,IAFkC;AAG1CC,EAAAA,eAAe,EAAE,kBAHyB;AAI1CC,EAAAA,aAAa,EAAE,MAAMC,OAAO,CAACC,KAAR,CAAc,oBAAd,CAJqB;AAK1CC,EAAAA,iBAAiB,EAAE,MAAMF,OAAO,CAACG,IAAR,CAAa,wBAAb;AALiB,CAA5C;AAaC,OAAO,SAASC,oBAAT,CAA8BC,MAA9B,EAA2EC,KAA3E,EAAuH;AAC5HA,EAAAA,KAAK,GAAG,EAAC,GAAGX,qBAAJ;AAA2B,OAAGW;AAA9B,GAAR;AAGD,MAAIC,YAAY,GAAG,IAAnB;;AACA,QAAMC,aAAa,GAAIP,KAAD,IAAYM,YAAY,GAAGN,KAAK,CAACQ,aAAN,IAAuBF,YAAxE;;AACAF,EAAAA,MAAM,CAACK,gBAAP,CAAwB,2BAAxB,EAAqDF,aAArD,EAAoE,KAApE;AAGA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,CAACc,KAAD,CAAnF,EAA4F,KAA5F;AACD;;AAED,SAAOL,EAAP;AACD","sourcesContent":["// luma.gl, MIT license\n\n/**\n * ContextProps\n* @param webgl2 Set to false to not create a WebGL2 context (force webgl1)\n* @param webgl1 set to false to not create a WebGL1 context (fail if webgl2 not available)\n* @param onContextLost\n* @param onContextRestored\n*\n* BROWSER CONTEXT PARAMETERS\n* @param debug Instrument context (at the expense of performance).\n* @param alpha Default render target has an alpha buffer.\n* @param depth Default render target has a depth buffer of at least 16 bits.\n* @param stencil Default render target has a stencil buffer of at least 8 bits.\n* @param antialias Boolean that indicates whether or not to perform anti-aliasing.\n* @param premultipliedAlpha Boolean that indicates that the page compositor will assume the drawing buffer contains colors with pre-multiplied alpha.\n* @param preserveDrawingBuffer Default render target buffers will not be automatically cleared and will preserve their values until cleared or overwritten\n* @param failIfMajorPerformanceCaveat Do not create if the system performance is low.\n*/\ntype ContextProps = {\n type?: 'webgl' | 'webgl1' | 'webgl2' | string;\n webgl1?: boolean;\n webgl2?: boolean;\n onContextLost?: (event: Event) => void;\n onContextRestored?: (event: Event) => void;\n alpha?: boolean; // indicates if the canvas contains an alpha buffer.\n desynchronized?: boolean; // hints the user agent to reduce the latency by desynchronizing the canvas paint cycle from the event loop\n antialias?: boolean; // indicates whether or not to perform anti-aliasing.\n depth?: boolean; // indicates that the drawing buffer has a depth buffer of at least 16 bits.\n failIfMajorPerformanceCaveat?: boolean, // indicates if a context will be created if the system performance is low or if no hardware GPU is available.\n powerPreference?: 'default' | 'high-performance' | 'low-power',\n premultipliedAlpha?: boolean, // page compositor will assume the drawing buffer contains colors with pre-multiplied alpha.\n preserveDrawingBuffer?: boolean // buffers will not be cleared and will preserve their values until cleared or overwritten by the author.\n};\n\nconst DEFAULT_CONTEXT_PROPS: ContextProps = {\n webgl2: true, // Attempt to create a WebGL2 context\n webgl1: true, // Attempt to create a WebGL1 context (false to fail if webgl2 not available)\n powerPreference: 'high-performance', // After all, most apps are using WebGL for performance reasons\n onContextLost: () => console.error('WebGL context lost'),\n onContextRestored: () => console.info('WebGL context restored'),\n};\n\n/**\n * Create a WebGL context for a canvas\n * Note calling this multiple time on the same canvas does return the same context\n* @param canvas A canvas element or offscreen canvas\n */\n export function createBrowserContext(canvas: HTMLCanvasElement | OffscreenCanvas, props: ContextProps): WebGLRenderingContext {\n props = {...DEFAULT_CONTEXT_PROPS, ...props};\n\n // Try to extract any extra information about why context creation failed\n let errorMessage = null;\n const onCreateError = (error) => (errorMessage = error.statusMessage || errorMessage);\n canvas.addEventListener('webglcontextcreationerror', onCreateError, false);\n\n // Create the desired context\n let gl: WebGLRenderingContext | null = null;\n\n if (props.type === 'webgl2') {\n props = {...props, webgl1: false};\n }\n if (props.type === 'webgl1') {\n props = {...props, webgl2: false};\n }\n\n // Prefer webgl2 over webgl1 if both are acceptable\n if (props.webgl2) {\n gl = gl || canvas.getContext('webgl2', props) as WebGL2RenderingContext | null;\n }\n if (props.webgl1) {\n gl = gl || canvas.getContext('webgl', props) as WebGLRenderingContext | null;\n }\n\n // TODO are we removing this listener before giving it a chance to fire?\n canvas.removeEventListener('webglcontextcreationerror', onCreateError, false);\n\n if (!gl) {\n throw new Error(\n `Failed to create ${props.webgl2 && !props.webgl1 ? 'WebGL2' : 'WebGL'} context: ${\n errorMessage || 'Unknown error'\n }`\n );\n }\n\n if (props.onContextLost) {\n // Carefully extract and wrap callbacks to prevent addEventListener from rebinding them.\n const {onContextLost} = props;\n canvas.addEventListener('webglcontextlost',(event: Event) => onContextLost(event), false);\n }\n if (props.onContextRestored) {\n // Carefully extract and wrap callbacks to prevent addEventListener from rebinding them.\n const {onContextRestored} = props;\n canvas.addEventListener('webglcontextrestored', (event: Event) => onContextRestored(event), false);\n }\n\n return gl;\n}\n\n/* TODO - can we call this asynchronously to catch the error events?\nexport async function createBrowserContextAsync(canvas: HTMLCanvasElement | OffscreenCanvas, props: ContextProps): Promise<WebGLRenderingContext> {\n props = {...DEFAULT_CONTEXT_PROPS, ...props};\n\n // Try to extract any extra information about why context creation failed\n let errorMessage = null;\n const onCreateError = (error) => (errorMessage = error.statusMessage || errorMessage);\n canvas.addEventListener('webglcontextcreationerror', onCreateError, false);\n\n const gl = createBrowserContext(canvas, props);\n\n // Give the listener a chance to fire\n await new Promise(resolve => setTimeout(resolve, 0));\n\n canvas.removeEventListener('webglcontextcreationerror', onCreateError, false);\n\n return gl;\n}\n*/\n"],"file":"create-browser-context.js"}
@@ -89,7 +89,7 @@ function onGLError(props, err, functionName, args) {
89
89
  }
90
90
 
91
91
  function onValidateGLFunc(props, functionName, functionArgs) {
92
- let functionString;
92
+ let functionString = '';
93
93
 
94
94
  if (log.level >= 1) {
95
95
  functionString = getFunctionString(functionName, functionArgs);
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../../src/context/debug/webgl-developer-tools.ts"],"names":["log","loadScript","GL","WEBGL_DEBUG_CDN_URL","DEFAULT_DEBUG_CONTEXT_PROPS","debug","throwOnError","break","webgl2","getContextData","gl","luma","loadWebGLDeveloperTools","globalThis","WebGLDebugUtils","global","module","makeDebugContext","props","getDebugContext","getRealContext","data","realContext","warn","debugContext","init","glDebug","onGLError","bind","onValidateGLFunc","key","WebGLDebugContext","Object","setPrototypeOf","getPrototypeOf","create","getFunctionString","functionName","functionArgs","Array","from","map","arg","undefined","args","glFunctionArgsToString","slice","length","err","errorMessage","glEnumToString","glName","message","error","Error","functionString","level","isBreakpoint","every","breakOn","indexOf"],"mappings":"AACA,SAAQA,GAAR,EAAaC,UAAb,QAA8B,eAA9B;AACA,OAAOC,EAAP,MAAe,oBAAf;AAEA,MAAMC,mBAAmB,GAAG,8CAA5B;AASA,MAAMC,2BAAwD,GAAG;AAC/DC,EAAAA,KAAK,EAAE,IADwD;AAE/DC,EAAAA,YAAY,EAAE,KAFiD;AAG/DC,EAAAA,KAAK,EAAE,EAHwD;AAI/DC,EAAAA,MAAM,EAAE;AAJuD,CAAjE;;AAQA,SAASC,cAAT,CAAwBC,EAAxB,EAAiC;AAC/BA,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YAAf,CAApD;AACA,UAAMmB,YAAY,GAChBvC,KAAK,CAACX,KAAN,IAAeW,KAAK,CAACX,KAAN,CAAYmD,KAAZ,CAAmBC,OAAD,IAAqBJ,cAAc,CAACK,OAAf,CAAuBD,OAAvB,MAAoC,CAAC,CAA5E,CADjB;;AAEA,QAAIF,YAAJ,EAAkB;AAChB;AACD;AACF;;AAED,OAAK,MAAMf,GAAX,IAAkBJ,YAAlB,EAAgC;AAC9B,QAAII,GAAG,KAAKC,SAAZ,EAAuB;AACrBY,MAAAA,cAAc,GAAGA,cAAc,IAAInB,iBAAiB,CAACC,YAAD,EAAeC,YAAf,CAApD;;AACA,UAAIpB,KAAK,CAACZ,YAAV,EAAwB;AACtB,cAAM,IAAIgD,KAAJ,+BAAiCC,cAAjC,EAAN;AACD,OAFD,MAEO;AACLvD,QAAAA,GAAG,CAACqD,KAAJ,+BAAiCE,cAAjC;AACA;AACD;AACF;AACF;AACF","sourcesContent":["// luma.gl, MIT license\nimport {log, loadScript} from '@luma.gl/api/';\nimport GL from '@luma.gl/constants';\n\nconst WEBGL_DEBUG_CDN_URL = 'https://unpkg.com/webgl-debug@2.0.1/index.js';\n\ntype DebugContextProps = {\n debug?: boolean;\n throwOnError?: boolean;\n break?: string[];\n webgl2?: boolean;\n};\n\nconst DEFAULT_DEBUG_CONTEXT_PROPS: Required<DebugContextProps> = {\n debug: true,\n throwOnError: false,\n break: [],\n webgl2: false,\n}\n\n// Helper to get shared context data\nfunction getContextData(gl: any) {\n gl.luma = gl.luma || {};\n return gl.luma;\n}\n\ndeclare global {\n var WebGLDebugUtils: any;\n}\n\n/**\n * Loads Khronos WebGLDeveloperTools from CDN if not already installed \n * const WebGLDebugUtils = require('webgl-debug');\n * @see https://github.com/KhronosGroup/WebGLDeveloperTools\n * @see https://github.com/vorg/webgl-debug\n */\nexport async function loadWebGLDeveloperTools(): Promise<void> {\n if (!globalThis.WebGLDebugUtils) {\n // @ts-expect-error Developer tools expects global to be set\n globalThis.global = globalThis.global || globalThis;\n // @ts-expect-error Developer tools expects global to be set\n globalThis.global.module = {};\n await loadScript(WEBGL_DEBUG_CDN_URL);\n }\n}\n\n// Returns (a potentially new) context with debug instrumentation turned off or on.\n// Note that this actually returns a new context\nexport function makeDebugContext(gl: WebGLRenderingContext, props: DebugContextProps = {}): WebGLRenderingContext {\n // Return null to ensure we don't try to create a context in this case (TODO what case is that?)\n if (!gl) {\n return null;\n }\n\n return props.debug ? getDebugContext(gl, props) : getRealContext(gl);\n}\n\n// Returns the real context from either of the real/debug contexts\nfunction getRealContext(gl: WebGLRenderingContext): WebGLRenderingContext {\n const data = getContextData(gl);\n // If the context has a realContext member, it is a debug context so return the realContext\n return data.realContext ? data.realContext : gl;\n}\n\n// Returns the debug context from either of the real/debug contexts\nfunction getDebugContext(gl: WebGLRenderingContext, props: DebugContextProps): WebGLRenderingContext {\n if (!globalThis.WebGLDebugUtils) {\n log.warn('webgl-debug not loaded')();\n return gl;\n }\n\n const data = getContextData(gl);\n\n // If this already has a debug context, return it.\n if (data.debugContext) {\n return data.debugContext;\n }\n\n // Create a new debug context\n globalThis.WebGLDebugUtils.init({...GL, ...gl});\n const glDebug = globalThis.WebGLDebugUtils.makeDebugContext(\n gl,\n onGLError.bind(null, props),\n onValidateGLFunc.bind(null, props)\n );\n\n // Make sure we have all WebGL2 and extension constants (todo dynamic import to circumvent minification?)\n for (const key in GL) {\n if (!(key in glDebug) && typeof GL[key] === 'number') {\n glDebug[key] = GL[key];\n }\n }\n \n // Ensure we have a clean prototype on the instrumented object\n // Note: setPrototypeOf does come with perf warnings, but we already take a bigger perf reduction\n // by synchronizing the WebGL errors after each WebGL call.\n class WebGLDebugContext {}\n Object.setPrototypeOf(glDebug, Object.getPrototypeOf(gl));\n Object.setPrototypeOf(WebGLDebugContext, glDebug);\n const debugContext = Object.create(WebGLDebugContext);\n // Store the debug context\n data.realContext = gl;\n data.debugContext = debugContext;\n debugContext.debug = true;\n\n // Return it\n return debugContext;\n}\n\n// DEBUG TRACING\n\nfunction getFunctionString(functionName: string, functionArgs): string {\n // Cover bug in webgl-debug-tools\n functionArgs = Array.from(functionArgs).map(arg => arg === undefined ? 'undefined' : arg);\n let args = globalThis.WebGLDebugUtils.glFunctionArgsToString(functionName, functionArgs);\n args = `${args.slice(0, 100)}${args.length > 100 ? '...' : ''}`;\n return `gl.${functionName}(${args})`;\n}\n\nfunction onGLError(props: DebugContextProps, err, functionName: string, args: any[]): void {\n // Cover bug in webgl-debug-tools\n args = Array.from(args).map(arg => arg === undefined ? 'undefined' : arg);\n const errorMessage = globalThis.WebGLDebugUtils.glEnumToString(err);\n const functionArgs = globalThis.WebGLDebugUtils.glFunctionArgsToString(functionName, args);\n const glName = props.webgl2 ? 'gl2' : 'gl1';\n const message = `${errorMessage} in ${glName}.${functionName}(${functionArgs})`;\n log.error(message)();\n debugger; // eslint-disable-line\n if (props.throwOnError) {\n throw new Error(message);\n }\n}\n\n// Don't generate function string until it is needed\nfunction onValidateGLFunc(props: DebugContextProps, functionName: string, functionArgs: any[]): void {\n let functionString: string;\n if (log.level >= 1) {\n functionString = getFunctionString(functionName, functionArgs);\n log.log(1, functionString)();\n }\n\n if (props.break) {\n functionString = functionString || getFunctionString(functionName, functionArgs);\n const isBreakpoint =\n props.break && props.break.every((breakOn: string) => functionString.indexOf(breakOn) !== -1);\n if (isBreakpoint) {\n debugger; // eslint-disable-line\n }\n }\n\n for (const arg of functionArgs) {\n if (arg === undefined) {\n functionString = functionString || getFunctionString(functionName, functionArgs);\n if (props.throwOnError) {\n throw new Error(`Undefined argument: ${functionString}`);\n } else {\n log.error(`Undefined argument: ${functionString}`)();\n debugger; // eslint-disable-line\n }\n }\n }\n}\n"],"file":"webgl-developer-tools.js"}
1
+ {"version":3,"sources":["../../../../src/context/debug/webgl-developer-tools.ts"],"names":["log","loadScript","GL","WEBGL_DEBUG_CDN_URL","DEFAULT_DEBUG_CONTEXT_PROPS","debug","throwOnError","break","webgl2","getContextData","gl","luma","loadWebGLDeveloperTools","globalThis","WebGLDebugUtils","global","module","makeDebugContext","props","getDebugContext","getRealContext","data","realContext","warn","debugContext","init","glDebug","onGLError","bind","onValidateGLFunc","key","WebGLDebugContext","Object","setPrototypeOf","getPrototypeOf","create","getFunctionString","functionName","functionArgs","Array","from","map","arg","undefined","args","glFunctionArgsToString","slice","length","err","errorMessage","glEnumToString","glName","message","error","Error","functionString","level","isBreakpoint","every","breakOn","indexOf"],"mappings":"AACA,SAAQA,GAAR,EAAaC,UAAb,QAA8B,eAA9B;AACA,OAAOC,EAAP,MAAe,oBAAf;AAEA,MAAMC,mBAAmB,GAAG,8CAA5B;AASA,MAAMC,2BAAwD,GAAG;AAC/DC,EAAAA,KAAK,EAAE,IADwD;AAE/DC,EAAAA,YAAY,EAAE,KAFiD;AAG/DC,EAAAA,KAAK,EAAE,EAHwD;AAI/DC,EAAAA,MAAM,EAAE;AAJuD,CAAjE;;AAQA,SAASC,cAAT,CAAwBC,EAAxB,EAAiC;AAC/BA,EAAAA,EAAE,CAACC,IAAH,GAAUD,EAAE,CAACC,IAAH,IAAW,EAArB;AACA,SAAOD,EAAE,CAACC,IAAV;AACD;;AAYD,OAAO,eAAeC,uBAAf,GAAwD;AAC7D,MAAI,CAACC,UAAU,CAACC,eAAhB,EAAiC;AAE/BD,IAAAA,UAAU,CAACE,MAAX,GAAoBF,UAAU,CAACE,MAAX,IAAqBF,UAAzC;AAEAA,IAAAA,UAAU,CAACE,MAAX,CAAkBC,MAAlB,GAA2B,EAA3B;AACA,UAAMf,UAAU,CAACE,mBAAD,CAAhB;AACD;AACF;AAID,OAAO,SAASc,gBAAT,CAA0BP,EAA1B,EAAqDQ,KAAwB,GAAG,EAAhF,EAAkH;AAEvH,MAAI,CAACR,EAAL,EAAS;AACP,WAAO,IAAP;AACD;;AAED,SAAOQ,KAAK,CAACb,KAAN,GAAcc,eAAe,CAACT,EAAD,EAAKQ,KAAL,CAA7B,GAA2CE,cAAc,CAACV,EAAD,CAAhE;AACD;;AAGD,SAASU,c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loadScript} from '@luma.gl/api/';\nimport GL from '@luma.gl/constants';\n\nconst WEBGL_DEBUG_CDN_URL = 'https://unpkg.com/webgl-debug@2.0.1/index.js';\n\ntype DebugContextProps = {\n debug?: boolean;\n throwOnError?: boolean;\n break?: string[];\n webgl2?: boolean;\n};\n\nconst DEFAULT_DEBUG_CONTEXT_PROPS: Required<DebugContextProps> = {\n debug: true,\n throwOnError: false,\n break: [],\n webgl2: false,\n}\n\n// Helper to get shared context data\nfunction getContextData(gl: any) {\n gl.luma = gl.luma || {};\n return gl.luma;\n}\n\ndeclare global {\n var WebGLDebugUtils: any;\n}\n\n/**\n * Loads Khronos WebGLDeveloperTools from CDN if not already installed \n * const WebGLDebugUtils = require('webgl-debug');\n * @see https://github.com/KhronosGroup/WebGLDeveloperTools\n * @see https://github.com/vorg/webgl-debug\n */\nexport async function loadWebGLDeveloperTools(): Promise<void> {\n if (!globalThis.WebGLDebugUtils) {\n // @ts-expect-error Developer tools expects global to be set\n globalThis.global = globalThis.global || globalThis;\n // @ts-expect-error Developer tools expects global to be set\n globalThis.global.module = {};\n await loadScript(WEBGL_DEBUG_CDN_URL);\n }\n}\n\n// Returns (a potentially new) context with debug instrumentation turned off or on.\n// Note that this actually returns a new context\nexport function makeDebugContext(gl: WebGLRenderingContext, props: DebugContextProps = {}): WebGLRenderingContext | null {\n // Return null to ensure we don't try to create a context in this case (TODO what case is that?)\n if (!gl) {\n return null;\n }\n\n return props.debug ? getDebugContext(gl, props) : getRealContext(gl);\n}\n\n// Returns the real context from either of the real/debug contexts\nfunction getRealContext(gl: WebGLRenderingContext): WebGLRenderingContext {\n const data = getContextData(gl);\n // If the context has a realContext member, it is a debug context so return the realContext\n return data.realContext ? data.realContext : gl;\n}\n\n// Returns the debug context from either of the real/debug contexts\nfunction getDebugContext(gl: WebGLRenderingContext, props: DebugContextProps): WebGLRenderingContext {\n if (!globalThis.WebGLDebugUtils) {\n log.warn('webgl-debug not loaded')();\n return gl;\n }\n\n const data = getContextData(gl);\n\n // If this already has a debug context, return it.\n if (data.debugContext) {\n return data.debugContext;\n }\n\n // Create a new debug context\n globalThis.WebGLDebugUtils.init({...GL, ...gl});\n const glDebug = globalThis.WebGLDebugUtils.makeDebugContext(\n gl,\n onGLError.bind(null, props),\n onValidateGLFunc.bind(null, props)\n );\n\n // Make sure we have all WebGL2 and extension constants (todo dynamic import to circumvent minification?)\n for (const key in GL) {\n if (!(key in glDebug) && typeof GL[key] === 'number') {\n glDebug[key] = GL[key];\n }\n }\n \n // Ensure we have a clean prototype on the instrumented object\n // Note: setPrototypeOf does come with perf warnings, but we already take a bigger perf reduction\n // by synchronizing the WebGL errors after each WebGL call.\n class WebGLDebugContext {}\n Object.setPrototypeOf(glDebug, Object.getPrototypeOf(gl));\n Object.setPrototypeOf(WebGLDebugContext, glDebug);\n const debugContext = Object.create(WebGLDebugContext);\n // Store the debug context\n data.realContext = gl;\n data.debugContext = debugContext;\n debugContext.debug = true;\n\n // Return it\n return debugContext;\n}\n\n// DEBUG TRACING\n\nfunction getFunctionString(functionName: string, functionArgs): string {\n // Cover bug in webgl-debug-tools\n functionArgs = Array.from(functionArgs).map(arg => arg === undefined ? 'undefined' : arg);\n let args = globalThis.WebGLDebugUtils.glFunctionArgsToString(functionName, functionArgs);\n args = `${args.slice(0, 100)}${args.length > 100 ? '...' : ''}`;\n return `gl.${functionName}(${args})`;\n}\n\nfunction onGLError(props: DebugContextProps, err, functionName: string, args: any[]): void {\n // Cover bug in webgl-debug-tools\n args = Array.from(args).map(arg => arg === undefined ? 'undefined' : arg);\n const errorMessage = globalThis.WebGLDebugUtils.glEnumToString(err);\n const functionArgs = globalThis.WebGLDebugUtils.glFunctionArgsToString(functionName, args);\n const glName = props.webgl2 ? 'gl2' : 'gl1';\n const message = `${errorMessage} in ${glName}.${functionName}(${functionArgs})`;\n log.error(message)();\n debugger; // eslint-disable-line\n if (props.throwOnError) {\n throw new Error(message);\n }\n}\n\n// Don't generate function string until it is needed\nfunction onValidateGLFunc(props: DebugContextProps, functionName: string, functionArgs: any[]): void {\n let functionString: string = '';\n if (log.level >= 1) {\n functionString = getFunctionString(functionName, functionArgs);\n log.log(1, functionString)();\n }\n\n if (props.break) {\n functionString = functionString || getFunctionString(functionName, functionArgs);\n const isBreakpoint =\n props.break && props.break.every((breakOn: string) => functionString.indexOf(breakOn) !== -1);\n if (isBreakpoint) {\n debugger; // eslint-disable-line\n }\n }\n\n for (const arg of functionArgs) {\n if (arg === undefined) {\n functionString = functionString || getFunctionString(functionName, functionArgs);\n if (props.throwOnError) {\n throw new Error(`Undefined argument: ${functionString}`);\n } else {\n log.error(`Undefined argument: ${functionString}`)();\n debugger; // eslint-disable-line\n }\n }\n }\n}\n"],"file":"webgl-developer-tools.js"}
@@ -26,7 +26,6 @@ function initializeExtensions(gl) {
26
26
  for (const extensionName of EXTENSIONS) {
27
27
  const extension = gl.getExtension(extensionName);
28
28
  contextState._extensions[extensionName] = extension;
29
- contextState[extensionName] = extension;
30
29
  }
31
30
  }
32
31
 
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../../src/context/polyfill/polyfill-context.ts"],"names":["assert","polyfillVertexArrayObject","WEBGL2_CONTEXT_POLYFILLS","WEBGL2_CONTEXT_OVERRIDES","getContextState","polyfillContext","gl","contextState","_polyfilled","initializeExtensions","installPolyfills","installOverrides","target","target2","EXTENSIONS","getSupportedExtensions","extensionName","extension","getExtension","_extensions","polyfills","Object","getOwnPropertyNames","polyfillExtension","defaults","meta","suffix","ext","key","keys","extKey","polyfill","args","bind","forEach","originalFunc"],"mappings":"AASA,SAAQA,MAAR,QAAqB,cAArB;AACA,SAAQC,yBAAR,QAAwC,gCAAxC;AAEA,SAAQC,wBAAR,EAAkCC,wBAAlC,QAAiE,kBAAjE;AACA,SAAQC,eAAR,QAA8B,0BAA9B;AAKA,OAAO,SAASC,eAAT,CAAyBC,EAAzB,EAA4E;AACjF,QAAMC,YAAY,GAAGH,eAAe,CAACE,EAAD,CAApC;;AAEA,MAAI,CAACC,YAAY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,EAAAA,MAAM,CAACQ,IAAP,CAAY1B,wBAAZ,EAAsC+B,OAAtC,CAA+CN,GAAD,IAAS;AACrD,QAAI,OAAOzB,wBAAwB,CAACyB,GAAD,CAA/B,KAAyC,UAA7C,EAAyD;AAEvD,YAAMO,YAAY,GAAG7B,EAAE,CAACsB,GAAD,CAAF,GAAUtB,EAAE,CAACsB,GAAD,CAAF,CAAQK,IAAR,CAAa3B,EAAb,CAAV,GAA6B,MAAM,CAAE,CAA1D;AACA,YAAMyB,QAAQ,GAAG5B,wBAAwB,CAACyB,GAAD,CAAxB,CAA8BK,IAA9B,CAAmC,IAAnC,EAAyC3B,EAAzC,EAA6C6B,YAA7C,CAAjB;AACAvB,MAAAA,MAAM,CAACgB,GAAD,CAAN,GAAcG,QAAd;AACAlB,MAAAA,OAAO,CAACe,GAAD,CAAP,GAAeG,QAAf;AACD;AACF,GARD;AASD","sourcesContent":["// WebGL1/WebGL2 extension polyfill support\n//\n// Provides a function that creates polyfills for WebGL2 functions based\n// on available extensions and installs them on a supplied target (could be\n// the WebGLContext or its prototype, or a separate object).\n//\n// This is intended to be a stand-alone file with minimal dependencies,\n// easy to reuse or repurpose in other projects.\n\nimport {assert} from '@luma.gl/api';\nimport {polyfillVertexArrayObject} from './polyfill-vertex-array-object';\n\nimport {WEBGL2_CONTEXT_POLYFILLS, WEBGL2_CONTEXT_OVERRIDES} from './polyfill-table';\nimport {getContextState} from '../context/context-state';\n\n/**\n * Registers extensions, polyfills or mock functions for extensions in the polyfills list\n */\nexport function polyfillContext(gl: WebGLRenderingContext): WebGL2RenderingContext {\n const contextState = getContextState(gl);\n\n if (!contextState._polyfilled) {\n polyfillVertexArrayObject(gl);\n initializeExtensions(gl);\n installPolyfills(gl, WEBGL2_CONTEXT_POLYFILLS);\n installOverrides(gl, {target: contextState, target2: gl});\n contextState._polyfilled = true;\n }\n\n // Note - only supports a subset of WebGL2\n return gl as WebGL2RenderingContext;\n}\n\nfunction initializeExtensions(gl: WebGLRenderingContext): void {\n const contextState = getContextState(gl);\n // `getSupportedExtensions` can return null when context is lost.\n const EXTENSIONS = gl.getSupportedExtensions() || [];\n for (const extensionName of EXTENSIONS) {\n const extension = gl.getExtension(extensionName);\n contextState._extensions[extensionName] = extension;\n // TODO - this looks like a mistake?\n contextState[extensionName] = extension;\n }\n}\n\nfunction installPolyfills(gl: WebGLRenderingContext, polyfills): void {\n const contextState = getContextState(gl);\n for (const extension of Object.getOwnPropertyNames(polyfills)) {\n if (extension !== 'overrides') {\n polyfillExtension(gl, {extension, target: contextState, target2: gl});\n }\n }\n}\n\n/** Polyfills a single WebGL extension into the `target` object */\nfunction polyfillExtension(gl: WebGLRenderingContext, {extension, target, target2}): void {\n const defaults = WEBGL2_CONTEXT_POLYFILLS[extension];\n assert(defaults);\n\n const {meta = {}} = defaults;\n const {suffix = ''} = meta;\n\n const ext = gl.getExtension(extension);\n\n for (const key of Object.keys(defaults)) {\n const extKey = `${key}${suffix}`;\n\n let polyfill: Function | null = null;\n if (key === 'meta') {\n // ignore\n } else if (typeof gl[key] === 'function') {\n // WebGL2 implementation is already\n } else if (ext && typeof ext[extKey] === 'function') {\n // pick extension implementation,if available\n polyfill = (...args) => ext[extKey](...args);\n } else if (typeof defaults[key] === 'function') {\n // pick the mock implementation, if no implementation was detected\n polyfill = defaults[key].bind(target);\n }\n\n if (polyfill) {\n target[key] = polyfill;\n target2[key] = polyfill;\n }\n }\n}\n\n/** Install simple overrides (mostly get* functions) */\nfunction installOverrides(gl, {target, target2}) {\n Object.keys(WEBGL2_CONTEXT_OVERRIDES).forEach((key) => {\n if (typeof WEBGL2_CONTEXT_OVERRIDES[key] === 'function') {\n // install an override, if no implementation was detected\n const originalFunc = gl[key] ? gl[key].bind(gl) : () => {};\n const polyfill = WEBGL2_CONTEXT_OVERRIDES[key].bind(null, gl, originalFunc);\n target[key] = polyfill;\n target2[key] = polyfill;\n }\n });\n}\n"],"file":"polyfill-context.js"}
1
+ {"version":3,"sources":["../../../../src/context/polyfill/polyfill-context.ts"],"names":["assert","polyfillVertexArrayObject","WEBGL2_CONTEXT_POLYFILLS","WEBGL2_CONTEXT_OVERRIDES","getContextState","polyfillContext","gl","contextState","_polyfilled","initializeExtensions","installPolyfills","installOverrides","target","target2","EXTENSIONS","getSupportedExtensions","extensionName","extension","getExtension","_extensions","polyfills","Object","getOwnPropertyNames","polyfillExtension","defaults","meta","suffix","ext","key","keys","extKey","polyfill","args","bind","forEach","originalFunc"],"mappings":"AASA,SAAQA,MAAR,QAAqB,cAArB;AACA,SAAQC,yBAAR,QAAwC,gCAAxC;AAEA,SAAQC,wBAAR,EAAkCC,wBAAlC,QAAiE,kBAAjE;AACA,SAAQC,eAAR,QAA8B,0BAA9B;AAKA,OAAO,SAASC,eAAT,CAAyBC,EAAzB,EAA4E;AACjF,QAAMC,YAAY,GAAGH,eAAe,CAACE,EAAD,CAApC;;AAEA,MAAI,CAACC,YAAY,CAACC,WAAlB,EAA+B;AAC7BP,IAAAA,yBAAyB,CAACK,EAAD,CAAzB;AACAG,IAAAA,oBAAoB,CAACH,EAAD,CAApB;AACAI,IAAAA,gBAAgB,CAACJ,EAAD,EAAKJ,wBAAL,CAAhB;AACAS,IAAAA,gBAAgB,CAACL,EAAD,EAAK;AAACM,MAAAA,MAAM,EAAEL,YAAT;AAAuBM,MAAAA,OAAO,EAAEP;AAAhC,KAAL,CAAhB;AACAC,IAAAA,YAAY,CAACC,WAAb,GAA2B,IAA3B;AACD;;AAGD,SAAOF,EAAP;AACD;;AAED,SAASG,oBAAT,CAA8BH,EAA9B,EAA+D;AAC7D,QAAMC,YAAY,GAAGH,eAAe,CAACE,EAAD,CAApC;AAEA,QAAMQ,UAAU,GAAGR,EAAE,CAACS,sBAAH,MAA+B,EAAlD;;AACA,OAAK,MAAMC,aAAX,IAA4BF,UAA5B,EAAwC;AACtC,UAAMG,SAAS,GAAGX,EAAE,CAACY,YAAH,CAAgBF,aAAhB,CAAlB;AACAT,IAAAA,YAAY,CAACY,WAAb,CAAyBH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AAG,CAAC,GAAGC,IAAJ,KAAaL,GAAG,CAACG,MAAD,CAAH,CAAY,GAAGE,IAAf,CAAxB;AACD,KAHM,MAGA,IAAI,OAAOR,QAAQ,CAACI,GAAD,CAAf,KAAyB,UAA7B,EAAyC;AAE9CG,MAAAA,QAAQ,GAAGP,QAAQ,CAACI,GAAD,CAAR,CAAcK,IAAd,CAAmBrB,MAAnB,CAAX;AACD;;AAED,QAAImB,QAAJ,EAAc;AACZnB,MAAAA,MAAM,CAACgB,GAAD,CAAN,GAAcG,QAAd;AACAlB,MAAAA,OAAO,CAACe,GAAD,CAAP,GAAeG,QAAf;AACD;AACF;AACF;;AAGD,SAASpB,gBAAT,CAA0BL,EAA1B,EAA8B;AAACM,EAAAA,MAAD;AAASC,EAAAA;AAAT,CAA9B,EAAiD;AAC/CQ,EAAAA,MAAM,CAACQ,IAAP,CAAY1B,wBAAZ,EAAsC+B,OAAtC,CAA+CN,GAAD,IAAS;AACrD,QAAI,OAAOzB,wBAAwB,CAACyB,GAAD,CAA/B,KAAyC,UAA7C,EAAyD;AAEvD,YAAMO,YAAY,GAAG7B,EAAE,CAACsB,GAAD,CAAF,GAAUtB,EAAE,CAACsB,GAAD,CAAF,CAAQK,IAAR,CAAa3B,EAAb,CAAV,GAA6B,MAAM,CAAE,CAA1D;AACA,YAAMyB,QAAQ,GAAG5B,wBAAwB,CAACyB,GAAD,CAAxB,CAA8BK,IAA9B,CAAmC,IAAnC,EAAyC3B,EAAzC,EAA6C6B,YAA7C,CAAjB;AACAvB,MAAAA,MAAM,CAACgB,GAAD,CAAN,GAAcG,QAAd;AACAlB,MAAAA,OAAO,CAACe,GAAD,CAAP,GAAeG,QAAf;AACD;AACF,GARD;AASD","sourcesContent":["// WebGL1/WebGL2 extension polyfill support\n//\n// Provides a function that creates polyfills for WebGL2 functions based\n// on available extensions and installs them on a supplied target (could be\n// the WebGLContext or its prototype, or a separate object).\n//\n// This is intended to be a stand-alone file with minimal dependencies,\n// easy to reuse or repurpose in other projects.\n\nimport {assert} from '@luma.gl/api';\nimport {polyfillVertexArrayObject} from './polyfill-vertex-array-object';\n\nimport {WEBGL2_CONTEXT_POLYFILLS, WEBGL2_CONTEXT_OVERRIDES} from './polyfill-table';\nimport {getContextState} from '../context/context-state';\n\n/**\n * Registers extensions, polyfills or mock functions for extensions in the polyfills list\n */\nexport function polyfillContext(gl: WebGLRenderingContext): WebGL2RenderingContext {\n const contextState = getContextState(gl);\n\n if (!contextState._polyfilled) {\n polyfillVertexArrayObject(gl);\n initializeExtensions(gl);\n installPolyfills(gl, WEBGL2_CONTEXT_POLYFILLS);\n installOverrides(gl, {target: contextState, target2: gl});\n contextState._polyfilled = true;\n }\n\n // Note - only supports a subset of WebGL2\n return gl as WebGL2RenderingContext;\n}\n\nfunction initializeExtensions(gl: WebGLRenderingContext): void {\n const contextState = getContextState(gl);\n // `getSupportedExtensions` can return null when context is lost.\n const EXTENSIONS = gl.getSupportedExtensions() || [];\n for (const extensionName of EXTENSIONS) {\n const extension = gl.getExtension(extensionName);\n contextState._extensions[extensionName] = extension;\n }\n}\n\nfunction installPolyfills(gl: WebGLRenderingContext, polyfills): void {\n const contextState = getContextState(gl);\n for (const extension of Object.getOwnPropertyNames(polyfills)) {\n if (extension !== 'overrides') {\n polyfillExtension(gl, {extension, target: contextState, target2: gl});\n }\n }\n}\n\n/** Polyfills a single WebGL extension into the `target` object */\nfunction polyfillExtension(gl: WebGLRenderingContext, {extension, target, target2}): void {\n const defaults = WEBGL2_CONTEXT_POLYFILLS[extension];\n assert(defaults);\n\n const {meta = {}} = defaults;\n const {suffix = ''} = meta;\n\n const ext = gl.getExtension(extension);\n\n for (const key of Object.keys(defaults)) {\n const extKey = `${key}${suffix}`;\n\n let polyfill: Function | null = null;\n if (key === 'meta') {\n // ignore\n } else if (typeof gl[key] === 'function') {\n // WebGL2 implementation is already\n } else if (ext && typeof ext[extKey] === 'function') {\n // pick extension implementation,if available\n polyfill = (...args) => ext[extKey](...args);\n } else if (typeof defaults[key] === 'function') {\n // pick the mock implementation, if no implementation was detected\n polyfill = defaults[key].bind(target);\n }\n\n if (polyfill) {\n target[key] = polyfill;\n target2[key] = polyfill;\n }\n }\n}\n\n/** Install simple overrides (mostly get* functions) */\nfunction installOverrides(gl, {target, target2}) {\n Object.keys(WEBGL2_CONTEXT_OVERRIDES).forEach((key) => {\n if (typeof WEBGL2_CONTEXT_OVERRIDES[key] === 'function') {\n // install an override, if no implementation was detected\n const originalFunc = gl[key] ? gl[key].bind(gl) : () => {};\n const polyfill = WEBGL2_CONTEXT_OVERRIDES[key].bind(null, gl, originalFunc);\n target[key] = polyfill;\n target2[key] = polyfill;\n }\n });\n}\n"],"file":"polyfill-context.js"}
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/index.ts"],"names":["registerHeadlessGL","default","WebGLDevice","WebGLCanvasContext","WEBGLResource","WebGLResource","WEBGLBuffer","WEBGLTexture","WEBGLShader","WEBGLSampler","WEBGLFramebuffer","WEBGLRenderPipeline","WEBGLCommandEncoder","WEBGLRenderPass","WEBGLRenderbuffer","WEBGLVertexArrayObject","Accessor","ClassicBuffer","Buffer","isWebGL","isWebGL2","getWebGL2Context","assertWebGLContext","assertWebGL2Context","cssToDeviceRatio","cssToDevicePixels","setDeviceParameters","withDeviceParameters","getParameters","setParameters","resetParameters","withParameters","trackContextState","pushContextState","popContextState","polyfillContext","getShaderLayout","getProgramBindings","_checkFloat32ColorAttachment"],"mappings":"AAOA,OAAO,cAAP;AACA,OAAO,QAAP;AAKA,SAAQA,kBAAR,QAAiC,2CAAjC;AAGA,SAAQC,OAAO,IAAIC,WAAnB,QAAqC,wBAArC;AACA,SAAQD,OAAO,IAAIE,kBAAnB,QAA4C,gCAA5C;AAGA,SAAQF,OAAO,IAAIG,aAAnB,EAAkCH,OAAO,IAAII,aAA7C,QAAiE,kCAAjE;AACA,SAAQJ,OAAO,IAAIK,WAAnB,QAAqC,kCAArC;AACA,SAAQL,OAAO,IAAIM,YAAnB,QAAsC,mCAAtC;AAEA,SAAQN,OAAO,IAAIO,WAAnB,QAAqC,kCAArC;AACA,SAAQP,OAAO,IAAIQ,YAAnB,QAAsC,mCAAtC;AACA,SAAQR,OAAO,IAAIS,gBAAnB,QAA0C,uCAA1C;AAEA,SAAQT,OAAO,IAAIU,mBAAnB,QAA6C,2CAA7C;AAEA,SAAQV,OAAO,IAAIW,mBAAnB,QAA6C,2CAA7C;AACA,SAAQX,OAAO,IAAIY,eAAnB,QAAyC,uCAAzC;AAKA,SAAQZ,OAAO,IAAIa,iBAAnB,QAA2C,sCAA3C;AACA,SAAQb,OAAO,IAAIc,sBAAnB,QAAgD,6CAAhD;AAGA,SAAQd,OAAO,IAAIe,QAAnB,QAAkC,oBAAlC;AAEA,SAAQf,OAAO,IAAIgB,aAAnB,EAAkChB,OAAO,IAAIiB,MAA7C,QAA0D,kBAA1D;AAEA,SACEC,OADF,EAEEC,QAFF,EAGEC,gBAHF,EAIEC,kBAJF,EAKEC,mBALF,QAMO,gCANP;AASA,SAAQC,gBAAR,EAA0BC,iBAA1B,QAAkD,iCAAlD;AAIA,SAAQC,mBAAR,EAA6BC,oBAA7B,QAAwD,wCAAxD;AAGA,SACEC,aADF,EAEEC,aAFF,EAGEC,eAHF,QAIO,4CAJP;AAMA,SACEC,cADF,QAEO,yCAFP;AAKA,SACEC,iBADF,EAEEC,gBAFF,EAGEC,eAHF,QAIO,6CAJP;AAOA,SAAQC,eAAR,QAA8B,qCAA9B;AAGA,SAAQC,eAAR,EAAyBC,kBAAzB,QAAkD,qCAAlD;AACA,SAAQC,4BAAR,QAA2C,sCAA3C","sourcesContent":["// luma.gl Base WebGL wrapper library\n// Provides simple class/function wrappers around the low level webgl objects\n// These classes are intentionally close to the WebGL API\n// but make it easier to use.\n// Higher level abstractions can be built on these classes\n\n// Initialize any global state\nimport '@luma.gl/api';\nimport './init'\n\n// Types\nexport type {WebGLLimits} from './adapter/device-helpers/device-limits';\n\nexport {registerHeadlessGL} from './context/context/create-headless-context';\n\n// WebGL adapter classes\nexport {default as WebGLDevice} from './adapter/webgl-device';\nexport {default as WebGLCanvasContext} from './adapter/webgl-canvas-context';\n\n// WebGL Resource classes\nexport {default as WEBGLResource, default as WebGLResource} from './adapter/objects/webgl-resource';\nexport {default as WEBGLBuffer} from './adapter/resources/webgl-buffer';\nexport {default as WEBGLTexture} from './adapter/resources/webgl-texture';\n// export {default as WEBGLExternalTexture} from './adapter/resources/webgl-external-texture';\nexport {default as WEBGLShader} from './adapter/resources/webgl-shader';\nexport {default as WEBGLSampler} from './adapter/resources/webgl-sampler';\nexport {default as WEBGLFramebuffer} from './adapter/resources/webgl-framebuffer';\n\nexport {default as WEBGLRenderPipeline} from './adapter/resources/webgl-render-pipeline';\n// export {default as WEBGLComputePipeline} from './adapter/resources/webgl-compute-pipeline';\nexport {default as WEBGLCommandEncoder} from './adapter/resources/webgl-command-encoder';\nexport {default as WEBGLRenderPass} from './adapter/resources/webgl-render-pass';\n//export {default as WEBGLComputePass} from './adapter/resources/webgl-compute-pass';\n\n// non-api resources\nexport type {RenderbufferProps} from './adapter/objects/webgl-renderbuffer';\nexport {default as WEBGLRenderbuffer} from './adapter/objects/webgl-renderbuffer';\nexport {default as WEBGLVertexArrayObject} from './adapter/objects/webgl-vertex-array-object';\n\n// WebGL adapter classes (Legacy, will be moved to gltools)\nexport {default as Accessor} from './classic/accessor';\nexport type {ClassicBufferProps, ClassicBufferProps as BufferProps} from './classic/buffer';\nexport {default as ClassicBuffer, default as Buffer} from './classic/buffer';\n\nexport {\n isWebGL,\n isWebGL2,\n getWebGL2Context,\n assertWebGLContext,\n assertWebGL2Context\n} from './context/context/webgl-checks';\n\n// Device ratio\nexport {cssToDeviceRatio, cssToDevicePixels} from './context/context/device-pixels';\n\n// Unified parameter API\n\nexport {setDeviceParameters, withDeviceParameters} from './adapter/converters/device-parameters';\n\nexport type {GLParameters} from './types/webgl';\nexport {\n getParameters,\n setParameters,\n resetParameters\n} from './context/parameters/unified-parameter-api';\n\nexport {\n withParameters\n} from './context/state-tracker/with-parameters';\n\n// State tracking\nexport {\n trackContextState,\n pushContextState,\n popContextState\n} from './context/state-tracker/track-context-state';\n\n// Polyfills (supports a subset of WebGL2 APIs on WebGL1 contexts)\nexport {polyfillContext} from './context/polyfill/polyfill-context';\n\n// HELPERS - EXPERIMENTAL\nexport {getShaderLayout, getProgramBindings} from './adapter/helpers/get-shader-layout';\nexport {_checkFloat32ColorAttachment} from './adapter/converters/texture-formats';\n"],"file":"index.js"}
1
+ {"version":3,"sources":["../../src/index.ts"],"names":["registerHeadlessGL","default","WebGLDevice","WebGLCanvasContext","WEBGLResource","WebGLResource","WEBGLBuffer","WEBGLTexture","WEBGLShader","WEBGLSampler","WEBGLFramebuffer","WEBGLRenderPipeline","WEBGLCommandEncoder","WEBGLRenderPass","WEBGLRenderbuffer","WEBGLVertexArrayObject","Accessor","ClassicBuffer","Buffer","isWebGL","isWebGL2","getWebGL2Context","assertWebGLContext","assertWebGL2Context","cssToDeviceRatio","cssToDevicePixels","setDeviceParameters","withDeviceParameters","getParameters","setParameters","resetParameters","withParameters","trackContextState","pushContextState","popContextState","polyfillContext","getShaderLayout","getProgramBindings","_checkFloat32ColorAttachment"],"mappings":"AAOA,OAAO,cAAP;AACA,OAAO,QAAP;AAKA,SAAQA,kBAAR,QAAiC,2CAAjC;AAGA,SAAQC,OAAO,IAAIC,WAAnB,QAAqC,wBAArC;AACA,SAAQD,OAAO,IAAIE,kBAAnB,QAA4C,gCAA5C;AAGA,SAAQF,OAAO,IAAIG,aAAnB,EAAkCH,OAAO,IAAII,aAA7C,QAAiE,kCAAjE;AACA,SAAQJ,OAAO,IAAIK,WAAnB,QAAqC,kCAArC;AACA,SAAQL,OAAO,IAAIM,YAAnB,QAAsC,mCAAtC;AAEA,SAAQN,OAAO,IAAIO,WAAnB,QAAqC,kCAArC;AACA,SAAQP,OAAO,IAAIQ,YAAnB,QAAsC,mCAAtC;AACA,SAAQR,OAAO,IAAIS,gBAAnB,QAA0C,uCAA1C;AAEA,SAAQT,OAAO,IAAIU,mBAAnB,QAA6C,2CAA7C;AAEA,SAAQV,OAAO,IAAIW,mBAAnB,QAA6C,2CAA7C;AACA,SAAQX,OAAO,IAAIY,eAAnB,QAAyC,uCAAzC;AAKA,SAAQZ,OAAO,IAAIa,iBAAnB,QAA2C,sCAA3C;AACA,SAAQb,OAAO,IAAIc,sBAAnB,QAAgD,6CAAhD;AAGA,SAAQd,OAAO,IAAIe,QAAnB,QAAkC,oBAAlC;AAGA,SAAQf,OAAO,IAAIgB,aAAnB,EAAkChB,OAAO,IAAIiB,MAA7C,QAA0D,kBAA1D;AAEA,SACEC,OADF,EAEEC,QAFF,EAGEC,gBAHF,EAIEC,kBAJF,EAKEC,mBALF,QAMO,gCANP;AASA,SAAQC,gBAAR,EAA0BC,iBAA1B,QAAkD,iCAAlD;AAIA,SAAQC,mBAAR,EAA6BC,oBAA7B,QAAwD,wCAAxD;AAGA,SACEC,aADF,EAEEC,aAFF,EAGEC,eAHF,QAIO,4CAJP;AAMA,SACEC,cADF,QAEO,yCAFP;AAKA,SACEC,iBADF,EAEEC,gBAFF,EAGEC,eAHF,QAIO,6CAJP;AAOA,SAAQC,eAAR,QAA8B,qCAA9B;AAGA,SAAQC,eAAR,EAAyBC,kBAAzB,QAAkD,qCAAlD;AACA,SAAQC,4BAAR,QAA2C,sCAA3C","sourcesContent":["// luma.gl Base WebGL wrapper library\n// Provides simple class/function wrappers around the low level webgl objects\n// These classes are intentionally close to the WebGL API\n// but make it easier to use.\n// Higher level abstractions can be built on these classes\n\n// Initialize any global state\nimport '@luma.gl/api';\nimport './init'\n\n// Types\nexport type {WebGLLimits} from './adapter/device-helpers/device-limits';\n\nexport {registerHeadlessGL} from './context/context/create-headless-context';\n\n// WebGL adapter classes\nexport {default as WebGLDevice} from './adapter/webgl-device';\nexport {default as WebGLCanvasContext} from './adapter/webgl-canvas-context';\n\n// WebGL Resource classes\nexport {default as WEBGLResource, default as WebGLResource} from './adapter/objects/webgl-resource';\nexport {default as WEBGLBuffer} from './adapter/resources/webgl-buffer';\nexport {default as WEBGLTexture} from './adapter/resources/webgl-texture';\n// export {default as WEBGLExternalTexture} from './adapter/resources/webgl-external-texture';\nexport {default as WEBGLShader} from './adapter/resources/webgl-shader';\nexport {default as WEBGLSampler} from './adapter/resources/webgl-sampler';\nexport {default as WEBGLFramebuffer} from './adapter/resources/webgl-framebuffer';\n\nexport {default as WEBGLRenderPipeline} from './adapter/resources/webgl-render-pipeline';\n// export {default as WEBGLComputePipeline} from './adapter/resources/webgl-compute-pipeline';\nexport {default as WEBGLCommandEncoder} from './adapter/resources/webgl-command-encoder';\nexport {default as WEBGLRenderPass} from './adapter/resources/webgl-render-pass';\n//export {default as WEBGLComputePass} from './adapter/resources/webgl-compute-pass';\n\n// non-api resources\nexport type {RenderbufferProps} from './adapter/objects/webgl-renderbuffer';\nexport {default as WEBGLRenderbuffer} from './adapter/objects/webgl-renderbuffer';\nexport {default as WEBGLVertexArrayObject} from './adapter/objects/webgl-vertex-array-object';\n\n// WebGL adapter classes (Legacy, will be moved to gltools)\nexport {default as Accessor} from './classic/accessor';\nexport type {AccessorObject} from './types';\nexport type {ClassicBufferProps, ClassicBufferProps as BufferProps} from './classic/buffer';\nexport {default as ClassicBuffer, default as Buffer} from './classic/buffer';\n\nexport {\n isWebGL,\n isWebGL2,\n getWebGL2Context,\n assertWebGLContext,\n assertWebGL2Context\n} from './context/context/webgl-checks';\n\n// Device ratio\nexport {cssToDeviceRatio, cssToDevicePixels} from './context/context/device-pixels';\n\n// Unified parameter API\n\nexport {setDeviceParameters, withDeviceParameters} from './adapter/converters/device-parameters';\n\nexport type {GLParameters} from './types/webgl';\nexport {\n getParameters,\n setParameters,\n resetParameters\n} from './context/parameters/unified-parameter-api';\n\nexport {\n withParameters\n} from './context/state-tracker/with-parameters';\n\n// State tracking\nexport {\n trackContextState,\n pushContextState,\n popContextState\n} from './context/state-tracker/track-context-state';\n\n// Polyfills (supports a subset of WebGL2 APIs on WebGL1 contexts)\nexport {polyfillContext} from './context/polyfill/polyfill-context';\n\n// HELPERS - EXPERIMENTAL\nexport {getShaderLayout, getProgramBindings} from './adapter/helpers/get-shader-layout';\nexport {_checkFloat32ColorAttachment} from './adapter/converters/texture-formats';\n"],"file":"index.js"}
package/dist/index.d.ts CHANGED
@@ -17,6 +17,7 @@ export type { RenderbufferProps } from './adapter/objects/webgl-renderbuffer';
17
17
  export { default as WEBGLRenderbuffer } from './adapter/objects/webgl-renderbuffer';
18
18
  export { default as WEBGLVertexArrayObject } from './adapter/objects/webgl-vertex-array-object';
19
19
  export { default as Accessor } from './classic/accessor';
20
+ export type { AccessorObject } from './types';
20
21
  export type { ClassicBufferProps, ClassicBufferProps as BufferProps } from './classic/buffer';
21
22
  export { default as ClassicBuffer, default as Buffer } from './classic/buffer';
22
23
  export { isWebGL, isWebGL2, getWebGL2Context, assertWebGLContext, assertWebGL2Context } from './context/context/webgl-checks';
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAOA,OAAO,cAAc,CAAC;AACtB,OAAO,QAAQ,CAAA;AAGf,YAAY,EAAC,WAAW,EAAC,MAAM,wCAAwC,CAAC;AAExE,OAAO,EAAC,kBAAkB,EAAC,MAAM,2CAA2C,CAAC;AAG7E,OAAO,EAAC,OAAO,IAAI,WAAW,EAAC,MAAM,wBAAwB,CAAC;AAC9D,OAAO,EAAC,OAAO,IAAI,kBAAkB,EAAC,MAAM,gCAAgC,CAAC;AAG7E,OAAO,EAAC,OAAO,IAAI,aAAa,EAAE,OAAO,IAAI,aAAa,EAAC,MAAM,kCAAkC,CAAC;AACpG,OAAO,EAAC,OAAO,IAAI,WAAW,EAAC,MAAM,kCAAkC,CAAC;AACxE,OAAO,EAAC,OAAO,IAAI,YAAY,EAAC,MAAM,mCAAmC,CAAC;AAE1E,OAAO,EAAC,OAAO,IAAI,WAAW,EAAC,MAAM,kCAAkC,CAAC;AACxE,OAAO,EAAC,O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EAAC,OAAO,IAAI,sBAAsB,EAAC,MAAM,6CAA6C,CAAC;AAG9F,OAAO,EAAC,OAAO,IAAI,QAAQ,EAAC,MAAM,oBAAoB,CAAC;AACvD,YAAY,EAAC,cAAc,EAAC,MAAM,SAAS,CAAC;AAC5C,YAAY,EAAC,kBAAkB,EAAE,kBAAkB,IAAI,WAAW,EAAC,MAAM,kBAAkB,CAAC;AAC5F,OAAO,EAAC,OAAO,IAAI,aAAa,EAAE,OAAO,IAAI,MAAM,EAAC,MAAM,kBAAkB,CAAC;AAE7E,OAAO,EACL,OAAO,EACP,QAAQ,EACR,gBAAgB,EAChB,kBAAkB,EAClB,mBAAmB,EACpB,MAAM,gCAAgC,CAAC;AAGxC,OAAO,EAAC,gBAAgB,EAAE,iBAAiB,EAAC,MAAM,iCAAiC,CAAC;AAIpF,OAAO,EAAC,mBAAmB,EAAE,oBAAoB,EAAC,MAAM,wCAAwC,CAAC;AAEjG,YAAY,EAAC,YAAY,EAAC,MAAM,eAAe,CAAC;AAChD,OAAO,EACL,aAAa,EACb,aAAa,EACb,eAAe,EAChB,MAAM,4CAA4C,CAAC;AAEpD,OAAO,EACL,cAAc,EACf,MAAM,yCAAyC,CAAC;AAGjD,OAAO,EACL,iBAAiB,EACjB,gBAAgB,EAChB,eAAe,EAChB,MAAM,6CAA6C,CAAC;AAGrD,OAAO,EAAC,eAAe,EAAC,MAAM,qCAAqC,CAAC;AAGpE,OAAO,EAAC,eAAe,EAAE,kBAAkB,EAAC,MAAM,qCAAqC,CAAC;AACxF,OAAO,EAAC,4BAA4B,EAAC,MAAM,sCAAsC,CAAC"}
package/dist/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/index.ts"],"names":["registerHeadlessGL","default","WebGLDevice","WebGLCanvasContext","WEBGLResource","WebGLResource","WEBGLBuffer","WEBGLTexture","WEBGLShader","WEBGLSampler","WEBGLFramebuffer","WEBGLRenderPipeline","WEBGLCommandEncoder","WEBGLRenderPass","WEBGLRenderbuffer","WEBGLVertexArrayObject","Accessor","ClassicBuffer","Buffer","isWebGL","isWebGL2","getWebGL2Context","assertWebGLContext","assertWebGL2Context","cssToDeviceRatio","cssToDevicePixels","setDeviceParameters","withDeviceParameters","getParameters","setParameters","resetParameters","withParameters","trackContextState","pushContextState","popContextState","polyfillContext","getShaderLayout","getProgramBindings","_checkFloat32ColorAttachment"],"mappings":"AAOA,OAAO,cAAP;AACA,OAAO,QAAP;AAKA,SAAQA,kBAAR,QAAiC,2CAAjC;AAGA,SAAQC,OAAO,IAAIC,WAAnB,QAAqC,wBAArC;AACA,SAAQD,OAAO,IAAIE,kBAAnB,QAA4C,gCAA5C;AAGA,SAAQF,OAAO,IAAIG,aAAnB,EAAkCH,OAAO,IAAII,aAA7C,QAAiE,kCAAjE;AACA,SAAQJ,OAAO,IAAIK,WAAnB,QAAqC,kCAArC;AACA,SAAQL,OAAO,IAAIM,YAAnB,QAAsC,mCAAtC;AAEA,SAAQN,OAAO,IAAIO,WAAnB,QAAqC,kCAArC;AACA,SAAQP,OAAO,IAAIQ,YAAnB,QAAsC,mCAAtC;AACA,SAAQR,OAAO,IAAIS,gBAAnB,QAA0C,uCAA1C;AAEA,SAAQT,OAAO,IAAIU,mBAAnB,QAA6C,2CAA7C;AAEA,SAAQV,OAAO,IAAIW,mBAAnB,QAA6C,2CAA7C;AACA,SAAQX,OAAO,IAAIY,eAAnB,QAAyC,uCAAzC;AAKA,SAAQZ,OAAO,IAAIa,iBAAnB,QAA2C,sCAA3C;AACA,SAAQb,OAAO,IAAIc,sBAAnB,QAAgD,6CAAhD;AAGA,SAAQd,OAAO,IAAIe,QAAnB,QAAkC,oBAAlC;AAEA,SAAQf,OAAO,IAAIgB,aAAnB,EAAkChB,OAAO,IAAIiB,MAA7C,QAA0D,kBAA1D;AAEA,SACEC,OADF,EAEEC,QAFF,EAGEC,gBAHF,EAIEC,kBAJF,EAKEC,mBALF,QAMO,gCANP;AASA,SAAQC,gBAAR,EAA0BC,iBAA1B,QAAkD,iCAAlD;AAIA,SAAQC,mBAAR,EAA6BC,oBAA7B,QAAwD,wCAAxD;AAGA,SACEC,aADF,EAEEC,aAFF,EAGEC,eAHF,QAIO,4CAJP;AAMA,SACEC,cADF,QAEO,yCAFP;AAKA,SACEC,iBADF,EAEEC,gBAFF,EAGEC,eAHF,QAIO,6CAJP;AAOA,SAAQC,eAAR,QAA8B,qCAA9B;AAGA,SAAQC,eAAR,EAAyBC,kBAAzB,QAAkD,qCAAlD;AACA,SAAQC,4BAAR,QAA2C,sCAA3C","sourcesContent":["// luma.gl Base WebGL wrapper library\n// Provides simple class/function wrappers around the low level webgl objects\n// These classes are intentionally close to the WebGL API\n// but make it easier to use.\n// Higher level abstractions can be built on these classes\n\n// Initialize any global state\nimport '@luma.gl/api';\nimport './init'\n\n// Types\nexport type {WebGLLimits} from './adapter/device-helpers/device-limits';\n\nexport {registerHeadlessGL} from './context/context/create-headless-context';\n\n// WebGL adapter classes\nexport {default as WebGLDevice} from './adapter/webgl-device';\nexport {default as WebGLCanvasContext} from './adapter/webgl-canvas-context';\n\n// WebGL Resource classes\nexport {default as WEBGLResource, default as WebGLResource} from './adapter/objects/webgl-resource';\nexport {default as WEBGLBuffer} from './adapter/resources/webgl-buffer';\nexport {default as WEBGLTexture} from './adapter/resources/webgl-texture';\n// export {default as WEBGLExternalTexture} from './adapter/resources/webgl-external-texture';\nexport {default as WEBGLShader} from './adapter/resources/webgl-shader';\nexport {default as WEBGLSampler} from './adapter/resources/webgl-sampler';\nexport {default as WEBGLFramebuffer} from './adapter/resources/webgl-framebuffer';\n\nexport {default as WEBGLRenderPipeline} from './adapter/resources/webgl-render-pipeline';\n// export {default as WEBGLComputePipeline} from './adapter/resources/webgl-compute-pipeline';\nexport {default as WEBGLCommandEncoder} from './adapter/resources/webgl-command-encoder';\nexport {default as WEBGLRenderPass} from './adapter/resources/webgl-render-pass';\n//export {default as WEBGLComputePass} from './adapter/resources/webgl-compute-pass';\n\n// non-api resources\nexport type {RenderbufferProps} from './adapter/objects/webgl-renderbuffer';\nexport {default as WEBGLRenderbuffer} from './adapter/objects/webgl-renderbuffer';\nexport {default as WEBGLVertexArrayObject} from './adapter/objects/webgl-vertex-array-object';\n\n// WebGL adapter classes (Legacy, will be moved to gltools)\nexport {default as Accessor} from './classic/accessor';\nexport type {ClassicBufferProps, ClassicBufferProps as BufferProps} from './classic/buffer';\nexport {default as ClassicBuffer, default as Buffer} from './classic/buffer';\n\nexport {\n isWebGL,\n isWebGL2,\n getWebGL2Context,\n assertWebGLContext,\n assertWebGL2Context\n} from './context/context/webgl-checks';\n\n// Device ratio\nexport {cssToDeviceRatio, cssToDevicePixels} from './context/context/device-pixels';\n\n// Unified parameter API\n\nexport {setDeviceParameters, withDeviceParameters} from './adapter/converters/device-parameters';\n\nexport type {GLParameters} from './types/webgl';\nexport {\n getParameters,\n setParameters,\n resetParameters\n} from './context/parameters/unified-parameter-api';\n\nexport {\n withParameters\n} from './context/state-tracker/with-parameters';\n\n// State tracking\nexport {\n trackContextState,\n pushContextState,\n popContextState\n} from './context/state-tracker/track-context-state';\n\n// Polyfills (supports a subset of WebGL2 APIs on WebGL1 contexts)\nexport {polyfillContext} from './context/polyfill/polyfill-context';\n\n// HELPERS - EXPERIMENTAL\nexport {getShaderLayout, getProgramBindings} from './adapter/helpers/get-shader-layout';\nexport {_checkFloat32ColorAttachment} from './adapter/converters/texture-formats';\n"],"file":"index.js"}
1
+ {"version":3,"sources":["../src/index.ts"],"names":["registerHeadlessGL","default","WebGLDevice","WebGLCanvasContext","WEBGLResource","WebGLResource","WEBGLBuffer","WEBGLTexture","WEBGLShader","WEBGLSampler","WEBGLFramebuffer","WEBGLRenderPipeline","WEBGLCommandEncoder","WEBGLRenderPass","WEBGLRenderbuffer","WEBGLVertexArrayObject","Accessor","ClassicBuffer","Buffer","isWebGL","isWebGL2","getWebGL2Context","assertWebGLContext","assertWebGL2Context","cssToDeviceRatio","cssToDevicePixels","setDeviceParameters","withDeviceParameters","getParameters","setParameters","resetParameters","withParameters","trackContextState","pushContextState","popContextState","polyfillContext","getShaderLayout","getProgramBindings","_checkFloat32ColorAttachment"],"mappings":"AAOA,OAAO,cAAP;AACA,OAAO,QAAP;AAKA,SAAQA,kBAAR,QAAiC,2CAAjC;AAGA,SAAQC,OAAO,IAAIC,WAAnB,QAAqC,wBAArC;AACA,SAAQD,OAAO,IAAIE,kBAAnB,QAA4C,gCAA5C;AAGA,SAAQF,OAAO,IAAIG,aAAnB,EAAkCH,OAAO,IAAII,aAA7C,QAAiE,kCAAjE;AACA,SAAQJ,OAAO,IAAIK,WAAnB,QAAqC,kCAArC;AACA,SAAQL,OAAO,IAAIM,YAAnB,QAAsC,mCAAtC;AAEA,SAAQN,OAAO,IAAIO,WAAnB,QAAqC,kCAArC;AACA,SAAQP,OAAO,IAAIQ,YAAnB,QAAsC,mCAAtC;AACA,SAAQR,OAAO,IAAIS,gBAAnB,QAA0C,uCAA1C;AAEA,SAAQT,OAAO,IAAIU,mBAAnB,QAA6C,2CAA7C;AAEA,SAAQV,OAAO,IAAIW,mBAAnB,QAA6C,2CAA7C;AACA,SAAQX,OAAO,IAAIY,eAAnB,QAAyC,uCAAzC;AAKA,SAAQZ,OAAO,IAAIa,iBAAnB,QAA2C,sCAA3C;AACA,SAAQb,OAAO,IAAIc,sBAAnB,QAAgD,6CAAhD;AAGA,SAAQd,OAAO,IAAIe,QAAnB,QAAkC,oBAAlC;AAGA,SAAQf,OAAO,IAAIgB,aAAnB,EAAkChB,OAAO,IAAIiB,MAA7C,QAA0D,kBAA1D;AAEA,SACEC,OADF,EAEEC,QAFF,EAGEC,gBAHF,EAIEC,kBAJF,EAKEC,mBALF,QAMO,gCANP;AASA,SAAQC,gBAAR,EAA0BC,iBAA1B,QAAkD,iCAAlD;AAIA,SAAQC,mBAAR,EAA6BC,oBAA7B,QAAwD,wCAAxD;AAGA,SACEC,aADF,EAEEC,aAFF,EAGEC,eAHF,QAIO,4CAJP;AAMA,SACEC,cADF,QAEO,yCAFP;AAKA,SACEC,iBADF,EAEEC,gBAFF,EAGEC,eAHF,QAIO,6CAJP;AAOA,SAAQC,eAAR,QAA8B,qCAA9B;AAGA,SAAQC,eAAR,EAAyBC,kBAAzB,QAAkD,qCAAlD;AACA,SAAQC,4BAAR,QAA2C,sCAA3C","sourcesContent":["// luma.gl Base WebGL wrapper library\n// Provides simple class/function wrappers around the low level webgl objects\n// These classes are intentionally close to the WebGL API\n// but make it easier to use.\n// Higher level abstractions can be built on these classes\n\n// Initialize any global state\nimport '@luma.gl/api';\nimport './init'\n\n// Types\nexport type {WebGLLimits} from './adapter/device-helpers/device-limits';\n\nexport {registerHeadlessGL} from './context/context/create-headless-context';\n\n// WebGL adapter classes\nexport {default as WebGLDevice} from './adapter/webgl-device';\nexport {default as WebGLCanvasContext} from './adapter/webgl-canvas-context';\n\n// WebGL Resource classes\nexport {default as WEBGLResource, default as WebGLResource} from './adapter/objects/webgl-resource';\nexport {default as WEBGLBuffer} from './adapter/resources/webgl-buffer';\nexport {default as WEBGLTexture} from './adapter/resources/webgl-texture';\n// export {default as WEBGLExternalTexture} from './adapter/resources/webgl-external-texture';\nexport {default as WEBGLShader} from './adapter/resources/webgl-shader';\nexport {default as WEBGLSampler} from './adapter/resources/webgl-sampler';\nexport {default as WEBGLFramebuffer} from './adapter/resources/webgl-framebuffer';\n\nexport {default as WEBGLRenderPipeline} from './adapter/resources/webgl-render-pipeline';\n// export {default as WEBGLComputePipeline} from './adapter/resources/webgl-compute-pipeline';\nexport {default as WEBGLCommandEncoder} from './adapter/resources/webgl-command-encoder';\nexport {default as WEBGLRenderPass} from './adapter/resources/webgl-render-pass';\n//export {default as WEBGLComputePass} from './adapter/resources/webgl-compute-pass';\n\n// non-api resources\nexport type {RenderbufferProps} from './adapter/objects/webgl-renderbuffer';\nexport {default as WEBGLRenderbuffer} from './adapter/objects/webgl-renderbuffer';\nexport {default as WEBGLVertexArrayObject} from './adapter/objects/webgl-vertex-array-object';\n\n// WebGL adapter classes (Legacy, will be moved to gltools)\nexport {default as Accessor} from './classic/accessor';\nexport type {AccessorObject} from './types';\nexport type {ClassicBufferProps, ClassicBufferProps as BufferProps} from './classic/buffer';\nexport {default as ClassicBuffer, default as Buffer} from './classic/buffer';\n\nexport {\n isWebGL,\n isWebGL2,\n getWebGL2Context,\n assertWebGLContext,\n assertWebGL2Context\n} from './context/context/webgl-checks';\n\n// Device ratio\nexport {cssToDeviceRatio, cssToDevicePixels} from './context/context/device-pixels';\n\n// Unified parameter API\n\nexport {setDeviceParameters, withDeviceParameters} from './adapter/converters/device-parameters';\n\nexport type {GLParameters} from './types/webgl';\nexport {\n getParameters,\n setParameters,\n resetParameters\n} from './context/parameters/unified-parameter-api';\n\nexport {\n withParameters\n} from './context/state-tracker/with-parameters';\n\n// State tracking\nexport {\n trackContextState,\n pushContextState,\n popContextState\n} from './context/state-tracker/track-context-state';\n\n// Polyfills (supports a subset of WebGL2 APIs on WebGL1 contexts)\nexport {polyfillContext} from './context/polyfill/polyfill-context';\n\n// HELPERS - EXPERIMENTAL\nexport {getShaderLayout, getProgramBindings} from './adapter/helpers/get-shader-layout';\nexport {_checkFloat32ColorAttachment} from './adapter/converters/texture-formats';\n"],"file":"index.js"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@luma.gl/webgl",
3
- "version": "9.0.0-alpha.7",
3
+ "version": "9.0.0-alpha.8",
4
4
  "description": "WebGL2 adapter for the luma.gl API",
5
5
  "license": "MIT",
6
6
  "publishConfig": {
@@ -35,9 +35,9 @@
35
35
  },
36
36
  "dependencies": {
37
37
  "@babel/runtime": "^7.0.0",
38
- "@luma.gl/api": "9.0.0-alpha.7",
39
- "@luma.gl/constants": "9.0.0-alpha.7",
38
+ "@luma.gl/api": "9.0.0-alpha.8",
39
+ "@luma.gl/constants": "9.0.0-alpha.8",
40
40
  "@probe.gl/env": "^3.5.0"
41
41
  },
42
- "gitHead": "c1fbf71bb1311dcdc54338d82d299f8ed0d73346"
42
+ "gitHead": "9f5c5cca812c45ccf35e03b0491fd7243c5f2a6d"
43
43
  }