@luma.gl/webgl 9.0.0-alpha.2 → 9.0.0-alpha.21
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.
- package/dist/adapter/converters/device-parameters.d.ts +11 -1
- package/dist/adapter/converters/device-parameters.d.ts.map +1 -1
- package/dist/adapter/converters/device-parameters.js +17 -35
- package/dist/adapter/converters/device-parameters.js.map +1 -1
- package/dist/adapter/converters/renderbuffer-formats.d.ts +2 -2
- package/dist/adapter/converters/renderbuffer-formats.d.ts.map +1 -1
- package/dist/adapter/converters/renderbuffer-formats.js +2 -7
- package/dist/adapter/converters/renderbuffer-formats.js.map +1 -1
- package/dist/adapter/converters/sampler-parameters.d.ts +4 -4
- package/dist/adapter/converters/sampler-parameters.d.ts.map +1 -1
- package/dist/adapter/converters/sampler-parameters.js +19 -55
- package/dist/adapter/converters/sampler-parameters.js.map +1 -1
- package/dist/adapter/converters/texture-formats.d.ts.map +1 -1
- package/dist/adapter/converters/texture-formats.js +13 -66
- package/dist/adapter/converters/texture-formats.js.map +1 -1
- package/dist/adapter/converters/vertex-formats.d.ts.map +1 -1
- package/dist/adapter/converters/vertex-formats.js +2 -8
- package/dist/adapter/converters/vertex-formats.js.map +1 -1
- package/dist/adapter/device-helpers/device-features.d.ts.map +1 -1
- package/dist/adapter/device-helpers/device-features.js +13 -20
- package/dist/adapter/device-helpers/device-features.js.map +1 -1
- package/dist/adapter/device-helpers/device-limits.js +1 -4
- package/dist/adapter/device-helpers/device-limits.js.map +1 -1
- package/dist/adapter/device-helpers/get-device-info.js +8 -10
- package/dist/adapter/device-helpers/get-device-info.js.map +1 -1
- package/dist/adapter/device-helpers/is-old-ie.js +2 -1
- package/dist/adapter/device-helpers/is-old-ie.js.map +1 -1
- package/dist/adapter/helpers/attribute-utils.js +0 -17
- package/dist/adapter/helpers/attribute-utils.js.map +1 -1
- package/dist/adapter/helpers/get-shader-info.d.ts +9 -0
- package/dist/adapter/helpers/get-shader-info.d.ts.map +1 -0
- package/dist/adapter/helpers/get-shader-info.js +25 -0
- package/dist/adapter/helpers/get-shader-info.js.map +1 -0
- package/dist/adapter/helpers/get-shader-layout.d.ts +1 -1
- package/dist/adapter/helpers/get-shader-layout.d.ts.map +1 -1
- package/dist/adapter/helpers/get-shader-layout.js +41 -67
- package/dist/adapter/helpers/get-shader-layout.js.map +1 -1
- package/dist/adapter/helpers/parse-shader-compiler-log.d.ts +1 -1
- package/dist/adapter/helpers/parse-shader-compiler-log.d.ts.map +1 -1
- package/dist/adapter/helpers/parse-shader-compiler-log.js +0 -7
- package/dist/adapter/helpers/parse-shader-compiler-log.js.map +1 -1
- package/dist/adapter/helpers/set-uniform.d.ts.map +1 -1
- package/dist/adapter/helpers/set-uniform.js +1 -31
- package/dist/adapter/helpers/set-uniform.js.map +1 -1
- package/dist/adapter/helpers/uniforms.d.ts +1 -1
- package/dist/adapter/helpers/uniforms.d.ts.map +1 -1
- package/dist/adapter/helpers/uniforms.js +4 -14
- package/dist/adapter/helpers/uniforms.js.map +1 -1
- package/dist/adapter/objects/constants-to-keys.d.ts.map +1 -1
- package/dist/adapter/objects/constants-to-keys.js +0 -7
- package/dist/adapter/objects/constants-to-keys.js.map +1 -1
- package/dist/adapter/objects/webgl-renderbuffer.d.ts +3 -3
- package/dist/adapter/objects/webgl-renderbuffer.d.ts.map +1 -1
- package/dist/adapter/objects/webgl-renderbuffer.js +6 -22
- package/dist/adapter/objects/webgl-renderbuffer.js.map +1 -1
- package/dist/adapter/objects/webgl-resource.d.ts +3 -5
- package/dist/adapter/objects/webgl-resource.d.ts.map +1 -1
- package/dist/adapter/objects/webgl-resource.js +15 -68
- package/dist/adapter/objects/webgl-resource.js.map +1 -1
- package/dist/adapter/objects/webgl-vertex-array-object.d.ts +6 -6
- package/dist/adapter/objects/webgl-vertex-array-object.d.ts.map +1 -1
- package/dist/adapter/objects/webgl-vertex-array-object.js +7 -17
- package/dist/adapter/objects/webgl-vertex-array-object.js.map +1 -1
- package/dist/adapter/resources/webgl-buffer.d.ts +3 -4
- package/dist/adapter/resources/webgl-buffer.d.ts.map +1 -1
- package/dist/adapter/resources/webgl-buffer.js +18 -49
- package/dist/adapter/resources/webgl-buffer.js.map +1 -1
- package/dist/adapter/resources/webgl-command-buffer.d.ts +2 -2
- package/dist/adapter/resources/webgl-command-buffer.d.ts.map +1 -1
- package/dist/adapter/resources/webgl-command-buffer.js +3 -18
- package/dist/adapter/resources/webgl-command-buffer.js.map +1 -1
- package/dist/adapter/resources/webgl-command-encoder.d.ts +3 -3
- package/dist/adapter/resources/webgl-command-encoder.d.ts.map +1 -1
- package/dist/adapter/resources/webgl-command-encoder.js +2 -15
- package/dist/adapter/resources/webgl-command-encoder.js.map +1 -1
- package/dist/adapter/resources/webgl-external-texture.js.map +1 -1
- package/dist/adapter/resources/webgl-framebuffer.d.ts +16 -16
- package/dist/adapter/resources/webgl-framebuffer.d.ts.map +1 -1
- package/dist/adapter/resources/webgl-framebuffer.js +17 -75
- package/dist/adapter/resources/webgl-framebuffer.js.map +1 -1
- package/dist/adapter/resources/webgl-render-pass.d.ts +3 -3
- package/dist/adapter/resources/webgl-render-pass.d.ts.map +1 -1
- package/dist/adapter/resources/webgl-render-pass.js +3 -8
- package/dist/adapter/resources/webgl-render-pass.js.map +1 -1
- package/dist/adapter/resources/webgl-render-pipeline.d.ts +5 -5
- package/dist/adapter/resources/webgl-render-pipeline.d.ts.map +1 -1
- package/dist/adapter/resources/webgl-render-pipeline.js +51 -140
- package/dist/adapter/resources/webgl-render-pipeline.js.map +1 -1
- package/dist/adapter/resources/webgl-sampler.d.ts +5 -4
- package/dist/adapter/resources/webgl-sampler.d.ts.map +1 -1
- package/dist/adapter/resources/webgl-sampler.js +5 -13
- package/dist/adapter/resources/webgl-sampler.js.map +1 -1
- package/dist/adapter/resources/webgl-shader.d.ts +3 -4
- package/dist/adapter/resources/webgl-shader.d.ts.map +1 -1
- package/dist/adapter/resources/webgl-shader.js +8 -21
- package/dist/adapter/resources/webgl-shader.js.map +1 -1
- package/dist/adapter/resources/webgl-texture.d.ts +26 -26
- package/dist/adapter/resources/webgl-texture.d.ts.map +1 -1
- package/dist/adapter/resources/webgl-texture.js +66 -183
- package/dist/adapter/resources/webgl-texture.js.map +1 -1
- package/dist/adapter/webgl-canvas-context.d.ts +3 -3
- package/dist/adapter/webgl-canvas-context.d.ts.map +1 -1
- package/dist/adapter/webgl-canvas-context.js +6 -19
- package/dist/adapter/webgl-canvas-context.js.map +1 -1
- package/dist/adapter/webgl-device.d.ts +53 -37
- package/dist/adapter/webgl-device.d.ts.map +1 -1
- package/dist/adapter/webgl-device.js +108 -109
- package/dist/adapter/webgl-device.js.map +1 -1
- package/dist/classic/accessor.d.ts +1 -1
- package/dist/classic/accessor.d.ts.map +1 -1
- package/dist/classic/accessor.js +12 -36
- package/dist/classic/accessor.js.map +1 -1
- package/dist/classic/buffer.d.ts +3 -4
- package/dist/classic/buffer.d.ts.map +1 -1
- package/dist/classic/buffer.js +30 -87
- package/dist/classic/buffer.js.map +1 -1
- package/dist/classic/typed-array-utils.d.ts +1 -1
- package/dist/classic/typed-array-utils.d.ts.map +1 -1
- package/dist/classic/typed-array-utils.js +0 -20
- package/dist/classic/typed-array-utils.js.map +1 -1
- package/dist/context/context/{create-context.d.ts → create-browser-context.d.ts} +2 -1
- package/dist/context/context/create-browser-context.d.ts.map +1 -0
- package/dist/context/context/{create-context.js → create-browser-context.js} +19 -15
- package/dist/context/context/create-browser-context.js.map +1 -0
- package/dist/context/context/create-headless-context.d.ts +9 -0
- package/dist/context/context/create-headless-context.d.ts.map +1 -0
- package/dist/context/context/create-headless-context.js +42 -0
- package/dist/context/context/create-headless-context.js.map +1 -0
- package/dist/context/context/webgl-checks.js +0 -3
- package/dist/context/context/webgl-checks.js.map +1 -1
- package/dist/context/debug/spector.d.ts +1 -0
- package/dist/context/debug/spector.d.ts.map +1 -1
- package/dist/context/debug/spector.js +7 -19
- package/dist/context/debug/spector.js.map +1 -1
- package/dist/context/debug/webgl-developer-tools.d.ts +1 -1
- package/dist/context/debug/webgl-developer-tools.d.ts.map +1 -1
- package/dist/context/debug/webgl-developer-tools.js +8 -32
- package/dist/context/debug/webgl-developer-tools.js.map +1 -1
- package/dist/context/parameters/unified-parameter-api.d.ts +6 -5
- package/dist/context/parameters/unified-parameter-api.d.ts.map +1 -1
- package/dist/context/parameters/unified-parameter-api.js +8 -18
- package/dist/context/parameters/unified-parameter-api.js.map +1 -1
- package/dist/context/parameters/webgl-parameter-tables.d.ts +103 -103
- package/dist/context/parameters/webgl-parameter-tables.d.ts.map +1 -1
- package/dist/context/parameters/webgl-parameter-tables.js +16 -34
- package/dist/context/parameters/webgl-parameter-tables.js.map +1 -1
- package/dist/context/polyfill/context-data.d.ts +13 -0
- package/dist/context/polyfill/context-data.d.ts.map +1 -0
- package/dist/context/polyfill/context-data.js +12 -0
- package/dist/context/polyfill/context-data.js.map +1 -0
- package/dist/context/polyfill/get-parameter-polyfill.d.ts +1 -1
- package/dist/context/polyfill/get-parameter-polyfill.d.ts.map +1 -1
- package/dist/context/polyfill/get-parameter-polyfill.js +1 -6
- package/dist/context/polyfill/get-parameter-polyfill.js.map +1 -1
- package/dist/context/polyfill/polyfill-context.js +20 -28
- package/dist/context/polyfill/polyfill-context.js.map +1 -1
- package/dist/context/polyfill/polyfill-table.d.ts +8 -8
- package/dist/context/polyfill/polyfill-table.d.ts.map +1 -1
- package/dist/context/polyfill/polyfill-table.js +8 -30
- package/dist/context/polyfill/polyfill-table.js.map +1 -1
- package/dist/context/polyfill/polyfill-vertex-array-object.d.ts.map +1 -1
- package/dist/context/polyfill/polyfill-vertex-array-object.js +0 -70
- package/dist/context/polyfill/polyfill-vertex-array-object.js.map +1 -1
- package/dist/context/state-tracker/deep-array-equal.js +0 -4
- package/dist/context/state-tracker/deep-array-equal.js.map +1 -1
- package/dist/context/state-tracker/track-context-state.d.ts.map +1 -1
- package/dist/context/state-tracker/track-context-state.js +15 -50
- package/dist/context/state-tracker/track-context-state.js.map +1 -1
- package/dist/context/state-tracker/with-parameters.d.ts +2 -1
- package/dist/context/state-tracker/with-parameters.d.ts.map +1 -1
- package/dist/context/state-tracker/with-parameters.js +7 -9
- package/dist/context/state-tracker/with-parameters.js.map +1 -1
- package/dist/dist.dev.js +9204 -0
- package/dist/index.cjs +5948 -0
- package/dist/index.d.ts +19 -19
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +24 -26
- package/dist/index.js.map +1 -1
- package/dist/types/webgl.d.ts +8 -7
- package/dist/types/webgl.d.ts.map +1 -1
- package/dist/types/webgl.js.map +1 -1
- package/dist/types.js.map +1 -1
- package/dist.min.js +36 -0
- package/package.json +18 -9
- package/src/.DS_Store +0 -0
- package/src/adapter/.DS_Store +0 -0
- package/src/adapter/converters/device-parameters.ts +45 -16
- package/src/adapter/converters/renderbuffer-formats.ts +1 -3
- package/src/adapter/converters/sampler-parameters.ts +18 -7
- package/src/adapter/converters/texture-formats.ts +18 -16
- package/src/adapter/converters/vertex-formats.ts +1 -0
- package/src/adapter/device-helpers/device-features.ts +9 -2
- package/src/adapter/device-helpers/device-limits.ts +1 -1
- package/src/adapter/device-helpers/get-device-info.ts +12 -8
- package/src/adapter/helpers/get-shader-info.ts +37 -0
- package/src/adapter/helpers/get-shader-layout.ts +59 -37
- package/src/adapter/helpers/parse-shader-compiler-log.ts +2 -2
- package/src/adapter/helpers/set-uniform.ts +3 -1
- package/src/adapter/helpers/uniforms.ts +21 -10
- package/src/adapter/objects/constants-to-keys.ts +4 -1
- package/src/adapter/objects/webgl-renderbuffer.ts +8 -8
- package/src/adapter/objects/webgl-resource.ts +8 -13
- package/src/adapter/objects/webgl-vertex-array-object.ts +10 -10
- package/src/adapter/resources/webgl-buffer.ts +16 -16
- package/src/adapter/resources/webgl-command-buffer.ts +3 -3
- package/src/adapter/resources/webgl-command-encoder.ts +8 -8
- package/src/adapter/resources/webgl-external-texture.ts +1 -1
- package/src/adapter/resources/webgl-framebuffer.ts +36 -33
- package/src/adapter/resources/webgl-render-pass.ts +4 -3
- package/src/adapter/resources/webgl-render-pipeline.ts +89 -77
- package/src/adapter/resources/webgl-sampler.ts +12 -6
- package/src/adapter/resources/webgl-shader.ts +10 -9
- package/src/adapter/resources/webgl-texture.ts +55 -45
- package/src/adapter/webgl-canvas-context.ts +8 -9
- package/src/adapter/webgl-device.ts +153 -69
- package/src/classic/accessor.ts +2 -15
- package/src/classic/buffer.ts +18 -25
- package/src/classic/typed-array-utils.ts +4 -2
- package/src/context/.DS_Store +0 -0
- package/src/context/context/{create-context.ts → create-browser-context.ts} +17 -7
- package/src/context/context/create-headless-context.ts +48 -0
- package/src/context/debug/spector.ts +6 -5
- package/src/context/debug/webgl-developer-tools.ts +13 -13
- package/src/context/parameters/unified-parameter-api.ts +18 -12
- package/src/context/parameters/webgl-parameter-tables.ts +113 -94
- package/src/context/polyfill/context-data.ts +27 -0
- package/src/context/polyfill/get-parameter-polyfill.ts +7 -6
- package/src/context/polyfill/polyfill-context.ts +6 -8
- package/src/context/polyfill/polyfill-table.ts +16 -14
- package/src/context/polyfill/polyfill-vertex-array-object.ts +2 -0
- package/src/context/state-tracker/track-context-state.ts +13 -12
- package/src/context/state-tracker/with-parameters.ts +8 -2
- package/src/index.ts +28 -26
- package/src/types/webgl.ts +10 -7
- package/dist/bundle.d.ts +0 -2
- package/dist/bundle.d.ts.map +0 -1
- package/dist/bundle.js +0 -5
- package/dist/bundle.js.map +0 -1
- package/dist/context/context/context-state.d.ts +0 -18
- package/dist/context/context/context-state.d.ts.map +0 -1
- package/dist/context/context/context-state.js +0 -26
- package/dist/context/context/context-state.js.map +0 -1
- package/dist/context/context/create-context.d.ts.map +0 -1
- package/dist/context/context/create-context.js.map +0 -1
- package/dist/context/context/device-pixels.d.ts +0 -25
- package/dist/context/context/device-pixels.d.ts.map +0 -1
- package/dist/context/context/device-pixels.js +0 -98
- package/dist/context/context/device-pixels.js.map +0 -1
- package/dist/es5/adapter/converters/device-parameters.js +0 -170
- package/dist/es5/adapter/converters/device-parameters.js.map +0 -1
- package/dist/es5/adapter/converters/renderbuffer-formats.js +0 -163
- package/dist/es5/adapter/converters/renderbuffer-formats.js.map +0 -1
- package/dist/es5/adapter/converters/sampler-parameters.js +0 -226
- package/dist/es5/adapter/converters/sampler-parameters.js.map +0 -1
- package/dist/es5/adapter/converters/texture-formats.js +0 -1031
- package/dist/es5/adapter/converters/texture-formats.js.map +0 -1
- package/dist/es5/adapter/converters/vertex-formats.js +0 -45
- package/dist/es5/adapter/converters/vertex-formats.js.map +0 -1
- package/dist/es5/adapter/device-helpers/device-features.js +0 -144
- package/dist/es5/adapter/device-helpers/device-features.js.map +0 -1
- package/dist/es5/adapter/device-helpers/device-limits.js +0 -64
- package/dist/es5/adapter/device-helpers/device-limits.js.map +0 -1
- package/dist/es5/adapter/device-helpers/get-device-info.js +0 -55
- package/dist/es5/adapter/device-helpers/get-device-info.js.map +0 -1
- package/dist/es5/adapter/device-helpers/is-old-ie.js +0 -16
- package/dist/es5/adapter/device-helpers/is-old-ie.js.map +0 -1
- package/dist/es5/adapter/helpers/attribute-utils.js +0 -91
- package/dist/es5/adapter/helpers/attribute-utils.js.map +0 -1
- package/dist/es5/adapter/helpers/get-shader-layout.js +0 -371
- package/dist/es5/adapter/helpers/get-shader-layout.js.map +0 -1
- package/dist/es5/adapter/helpers/parse-shader-compiler-log.js +0 -72
- package/dist/es5/adapter/helpers/parse-shader-compiler-log.js.map +0 -1
- package/dist/es5/adapter/helpers/set-uniform.js +0 -125
- package/dist/es5/adapter/helpers/set-uniform.js.map +0 -1
- package/dist/es5/adapter/helpers/uniforms.js +0 -112
- package/dist/es5/adapter/helpers/uniforms.js.map +0 -1
- package/dist/es5/adapter/objects/constants-to-keys.js +0 -54
- package/dist/es5/adapter/objects/constants-to-keys.js.map +0 -1
- package/dist/es5/adapter/objects/webgl-renderbuffer.js +0 -150
- package/dist/es5/adapter/objects/webgl-renderbuffer.js.map +0 -1
- package/dist/es5/adapter/objects/webgl-resource.js +0 -292
- package/dist/es5/adapter/objects/webgl-resource.js.map +0 -1
- package/dist/es5/adapter/objects/webgl-vertex-array-object.js +0 -137
- package/dist/es5/adapter/objects/webgl-vertex-array-object.js.map +0 -1
- package/dist/es5/adapter/resources/webgl-buffer.js +0 -243
- package/dist/es5/adapter/resources/webgl-buffer.js.map +0 -1
- package/dist/es5/adapter/resources/webgl-command-buffer.js +0 -96
- package/dist/es5/adapter/resources/webgl-command-buffer.js.map +0 -1
- package/dist/es5/adapter/resources/webgl-command-encoder.js +0 -98
- package/dist/es5/adapter/resources/webgl-command-encoder.js.map +0 -1
- package/dist/es5/adapter/resources/webgl-external-texture.js +0 -2
- package/dist/es5/adapter/resources/webgl-external-texture.js.map +0 -1
- package/dist/es5/adapter/resources/webgl-framebuffer.js +0 -345
- package/dist/es5/adapter/resources/webgl-framebuffer.js.map +0 -1
- package/dist/es5/adapter/resources/webgl-render-pass.js +0 -61
- package/dist/es5/adapter/resources/webgl-render-pass.js.map +0 -1
- package/dist/es5/adapter/resources/webgl-render-pipeline.js +0 -505
- package/dist/es5/adapter/resources/webgl-render-pipeline.js.map +0 -1
- package/dist/es5/adapter/resources/webgl-sampler.js +0 -96
- package/dist/es5/adapter/resources/webgl-sampler.js.map +0 -1
- package/dist/es5/adapter/resources/webgl-shader.js +0 -149
- package/dist/es5/adapter/resources/webgl-shader.js.map +0 -1
- package/dist/es5/adapter/resources/webgl-texture.js +0 -986
- package/dist/es5/adapter/resources/webgl-texture.js.map +0 -1
- package/dist/es5/adapter/webgl-canvas-context.js +0 -97
- package/dist/es5/adapter/webgl-canvas-context.js.map +0 -1
- package/dist/es5/adapter/webgl-device.js +0 -399
- package/dist/es5/adapter/webgl-device.js.map +0 -1
- package/dist/es5/bundle.js +0 -7
- package/dist/es5/bundle.js.map +0 -1
- package/dist/es5/classic/accessor.js +0 -181
- package/dist/es5/classic/accessor.js.map +0 -1
- package/dist/es5/classic/buffer.js +0 -470
- package/dist/es5/classic/buffer.js.map +0 -1
- package/dist/es5/classic/typed-array-utils.js +0 -126
- package/dist/es5/classic/typed-array-utils.js.map +0 -1
- package/dist/es5/context/context/context-state.js +0 -31
- package/dist/es5/context/context/context-state.js.map +0 -1
- package/dist/es5/context/context/create-context.js +0 -69
- package/dist/es5/context/context/create-context.js.map +0 -1
- package/dist/es5/context/context/device-pixels.js +0 -115
- package/dist/es5/context/context/device-pixels.js.map +0 -1
- package/dist/es5/context/context/webgl-checks.js +0 -54
- package/dist/es5/context/context/webgl-checks.js.map +0 -1
- package/dist/es5/context/debug/spector.js +0 -133
- package/dist/es5/context/debug/spector.js.map +0 -1
- package/dist/es5/context/debug/webgl-developer-tools.js +0 -198
- package/dist/es5/context/debug/webgl-developer-tools.js.map +0 -1
- package/dist/es5/context/parameters/unified-parameter-api.js +0 -97
- package/dist/es5/context/parameters/unified-parameter-api.js.map +0 -1
- package/dist/es5/context/parameters/webgl-parameter-tables.js +0 -392
- package/dist/es5/context/parameters/webgl-parameter-tables.js.map +0 -1
- package/dist/es5/context/polyfill/get-parameter-polyfill.js +0 -81
- package/dist/es5/context/polyfill/get-parameter-polyfill.js.map +0 -1
- package/dist/es5/context/polyfill/polyfill-context.js +0 -135
- package/dist/es5/context/polyfill/polyfill-context.js.map +0 -1
- package/dist/es5/context/polyfill/polyfill-table.js +0 -166
- package/dist/es5/context/polyfill/polyfill-table.js.map +0 -1
- package/dist/es5/context/polyfill/polyfill-vertex-array-object.js +0 -341
- package/dist/es5/context/polyfill/polyfill-vertex-array-object.js.map +0 -1
- package/dist/es5/context/state-tracker/deep-array-equal.js +0 -28
- package/dist/es5/context/state-tracker/deep-array-equal.js.map +0 -1
- package/dist/es5/context/state-tracker/track-context-state.js +0 -211
- package/dist/es5/context/state-tracker/track-context-state.js.map +0 -1
- package/dist/es5/context/state-tracker/with-parameters.js +0 -44
- package/dist/es5/context/state-tracker/with-parameters.js.map +0 -1
- package/dist/es5/index.js +0 -276
- package/dist/es5/index.js.map +0 -1
- package/dist/es5/init.js +0 -10
- package/dist/es5/init.js.map +0 -1
- package/dist/es5/types/webgl.js +0 -6
- package/dist/es5/types/webgl.js.map +0 -1
- package/dist/es5/types.js +0 -2
- package/dist/es5/types.js.map +0 -1
- package/dist/esm/adapter/converters/device-parameters.js +0 -155
- package/dist/esm/adapter/converters/device-parameters.js.map +0 -1
- package/dist/esm/adapter/converters/renderbuffer-formats.js +0 -185
- package/dist/esm/adapter/converters/renderbuffer-formats.js.map +0 -1
- package/dist/esm/adapter/converters/sampler-parameters.js +0 -208
- package/dist/esm/adapter/converters/sampler-parameters.js.map +0 -1
- package/dist/esm/adapter/converters/texture-formats.js +0 -954
- package/dist/esm/adapter/converters/texture-formats.js.map +0 -1
- package/dist/esm/adapter/converters/vertex-formats.js +0 -35
- package/dist/esm/adapter/converters/vertex-formats.js.map +0 -1
- package/dist/esm/adapter/device-helpers/device-features.js +0 -102
- package/dist/esm/adapter/device-helpers/device-features.js.map +0 -1
- package/dist/esm/adapter/device-helpers/device-limits.js +0 -91
- package/dist/esm/adapter/device-helpers/device-limits.js.map +0 -1
- package/dist/esm/adapter/device-helpers/get-device-info.js +0 -44
- package/dist/esm/adapter/device-helpers/get-device-info.js.map +0 -1
- package/dist/esm/adapter/device-helpers/is-old-ie.js +0 -8
- package/dist/esm/adapter/device-helpers/is-old-ie.js.map +0 -1
- package/dist/esm/adapter/helpers/attribute-utils.js +0 -81
- package/dist/esm/adapter/helpers/attribute-utils.js.map +0 -1
- package/dist/esm/adapter/helpers/get-shader-layout.js +0 -306
- package/dist/esm/adapter/helpers/get-shader-layout.js.map +0 -1
- package/dist/esm/adapter/helpers/parse-shader-compiler-log.js +0 -37
- package/dist/esm/adapter/helpers/parse-shader-compiler-log.js.map +0 -1
- package/dist/esm/adapter/helpers/set-uniform.js +0 -115
- package/dist/esm/adapter/helpers/set-uniform.js.map +0 -1
- package/dist/esm/adapter/helpers/uniforms.js +0 -99
- package/dist/esm/adapter/helpers/uniforms.js.map +0 -1
- package/dist/esm/adapter/objects/constants-to-keys.js +0 -42
- package/dist/esm/adapter/objects/constants-to-keys.js.map +0 -1
- package/dist/esm/adapter/objects/webgl-renderbuffer.js +0 -94
- package/dist/esm/adapter/objects/webgl-renderbuffer.js.map +0 -1
- package/dist/esm/adapter/objects/webgl-resource.js +0 -216
- package/dist/esm/adapter/objects/webgl-resource.js.map +0 -1
- package/dist/esm/adapter/objects/webgl-vertex-array-object.js +0 -84
- package/dist/esm/adapter/objects/webgl-vertex-array-object.js.map +0 -1
- package/dist/esm/adapter/resources/webgl-buffer.js +0 -164
- package/dist/esm/adapter/resources/webgl-buffer.js.map +0 -1
- package/dist/esm/adapter/resources/webgl-command-buffer.js +0 -65
- package/dist/esm/adapter/resources/webgl-command-buffer.js.map +0 -1
- package/dist/esm/adapter/resources/webgl-command-encoder.js +0 -53
- package/dist/esm/adapter/resources/webgl-command-encoder.js.map +0 -1
- package/dist/esm/adapter/resources/webgl-external-texture.js +0 -2
- package/dist/esm/adapter/resources/webgl-external-texture.js.map +0 -1
- package/dist/esm/adapter/resources/webgl-framebuffer.js +0 -265
- package/dist/esm/adapter/resources/webgl-framebuffer.js.map +0 -1
- package/dist/esm/adapter/resources/webgl-render-pass.js +0 -19
- package/dist/esm/adapter/resources/webgl-render-pass.js.map +0 -1
- package/dist/esm/adapter/resources/webgl-render-pipeline.js +0 -400
- package/dist/esm/adapter/resources/webgl-render-pipeline.js.map +0 -1
- package/dist/esm/adapter/resources/webgl-sampler.js +0 -50
- package/dist/esm/adapter/resources/webgl-sampler.js.map +0 -1
- package/dist/esm/adapter/resources/webgl-shader.js +0 -75
- package/dist/esm/adapter/resources/webgl-shader.js.map +0 -1
- package/dist/esm/adapter/resources/webgl-texture.js +0 -831
- package/dist/esm/adapter/resources/webgl-texture.js.map +0 -1
- package/dist/esm/adapter/webgl-canvas-context.js +0 -54
- package/dist/esm/adapter/webgl-canvas-context.js.map +0 -1
- package/dist/esm/adapter/webgl-device.js +0 -280
- package/dist/esm/adapter/webgl-device.js.map +0 -1
- package/dist/esm/bundle.js +0 -5
- package/dist/esm/bundle.js.map +0 -1
- package/dist/esm/classic/accessor.js +0 -144
- package/dist/esm/classic/accessor.js.map +0 -1
- package/dist/esm/classic/buffer.js +0 -384
- package/dist/esm/classic/buffer.js.map +0 -1
- package/dist/esm/classic/typed-array-utils.js +0 -112
- package/dist/esm/classic/typed-array-utils.js.map +0 -1
- package/dist/esm/context/context/context-state.js +0 -26
- package/dist/esm/context/context/context-state.js.map +0 -1
- package/dist/esm/context/context/create-context.js +0 -49
- package/dist/esm/context/context/create-context.js.map +0 -1
- package/dist/esm/context/context/device-pixels.js +0 -98
- package/dist/esm/context/context/device-pixels.js.map +0 -1
- package/dist/esm/context/context/webgl-checks.js +0 -34
- package/dist/esm/context/context/webgl-checks.js.map +0 -1
- package/dist/esm/context/debug/spector.js +0 -76
- package/dist/esm/context/debug/spector.js.map +0 -1
- package/dist/esm/context/debug/webgl-developer-tools.js +0 -121
- package/dist/esm/context/debug/webgl-developer-tools.js.map +0 -1
- package/dist/esm/context/parameters/unified-parameter-api.js +0 -65
- package/dist/esm/context/parameters/unified-parameter-api.js.map +0 -1
- package/dist/esm/context/parameters/webgl-parameter-tables.js +0 -445
- package/dist/esm/context/parameters/webgl-parameter-tables.js.map +0 -1
- package/dist/esm/context/polyfill/get-parameter-polyfill.js +0 -91
- package/dist/esm/context/polyfill/get-parameter-polyfill.js.map +0 -1
- package/dist/esm/context/polyfill/polyfill-context.js +0 -92
- package/dist/esm/context/polyfill/polyfill-context.js.map +0 -1
- package/dist/esm/context/polyfill/polyfill-table.js +0 -160
- package/dist/esm/context/polyfill/polyfill-table.js.map +0 -1
- package/dist/esm/context/polyfill/polyfill-vertex-array-object.js +0 -335
- package/dist/esm/context/polyfill/polyfill-vertex-array-object.js.map +0 -1
- package/dist/esm/context/state-tracker/deep-array-equal.js +0 -21
- package/dist/esm/context/state-tracker/deep-array-equal.js.map +0 -1
- package/dist/esm/context/state-tracker/track-context-state.js +0 -183
- package/dist/esm/context/state-tracker/track-context-state.js.map +0 -1
- package/dist/esm/context/state-tracker/with-parameters.js +0 -36
- package/dist/esm/context/state-tracker/with-parameters.js.map +0 -1
- package/dist/esm/index.js +0 -27
- package/dist/esm/index.js.map +0 -1
- package/dist/esm/init.js +0 -4
- package/dist/esm/init.js.map +0 -1
- package/dist/esm/types/webgl.js +0 -2
- package/dist/esm/types/webgl.js.map +0 -1
- package/dist/esm/types.js +0 -2
- package/dist/esm/types.js.map +0 -1
- package/dist/init.d.ts +0 -2
- package/dist/init.d.ts.map +0 -1
- package/dist/init.js +0 -4
- package/dist/init.js.map +0 -1
- package/src/bundle.ts +0 -4
- package/src/context/context/context-state.ts +0 -41
- package/src/context/context/device-pixels.ts +0 -152
- package/src/init.ts +0 -4
|
@@ -11,13 +11,13 @@ import {assert} from '@luma.gl/api';
|
|
|
11
11
|
import {polyfillVertexArrayObject} from './polyfill-vertex-array-object';
|
|
12
12
|
|
|
13
13
|
import {WEBGL2_CONTEXT_POLYFILLS, WEBGL2_CONTEXT_OVERRIDES} from './polyfill-table';
|
|
14
|
-
import {
|
|
14
|
+
import {getContextData} from './context-data';
|
|
15
15
|
|
|
16
16
|
/**
|
|
17
17
|
* Registers extensions, polyfills or mock functions for extensions in the polyfills list
|
|
18
18
|
*/
|
|
19
19
|
export function polyfillContext(gl: WebGLRenderingContext): WebGL2RenderingContext {
|
|
20
|
-
const contextState =
|
|
20
|
+
const contextState = getContextData(gl);
|
|
21
21
|
|
|
22
22
|
if (!contextState._polyfilled) {
|
|
23
23
|
polyfillVertexArrayObject(gl);
|
|
@@ -32,19 +32,17 @@ export function polyfillContext(gl: WebGLRenderingContext): WebGL2RenderingConte
|
|
|
32
32
|
}
|
|
33
33
|
|
|
34
34
|
function initializeExtensions(gl: WebGLRenderingContext): void {
|
|
35
|
-
const contextState =
|
|
35
|
+
const contextState = getContextData(gl);
|
|
36
36
|
// `getSupportedExtensions` can return null when context is lost.
|
|
37
37
|
const EXTENSIONS = gl.getSupportedExtensions() || [];
|
|
38
38
|
for (const extensionName of EXTENSIONS) {
|
|
39
39
|
const extension = gl.getExtension(extensionName);
|
|
40
40
|
contextState._extensions[extensionName] = extension;
|
|
41
|
-
// TODO - this looks like a mistake?
|
|
42
|
-
contextState[extensionName] = extension;
|
|
43
41
|
}
|
|
44
42
|
}
|
|
45
43
|
|
|
46
44
|
function installPolyfills(gl: WebGLRenderingContext, polyfills): void {
|
|
47
|
-
const contextState =
|
|
45
|
+
const contextState = getContextData(gl);
|
|
48
46
|
for (const extension of Object.getOwnPropertyNames(polyfills)) {
|
|
49
47
|
if (extension !== 'overrides') {
|
|
50
48
|
polyfillExtension(gl, {extension, target: contextState, target2: gl});
|
|
@@ -65,7 +63,7 @@ function polyfillExtension(gl: WebGLRenderingContext, {extension, target, target
|
|
|
65
63
|
for (const key of Object.keys(defaults)) {
|
|
66
64
|
const extKey = `${key}${suffix}`;
|
|
67
65
|
|
|
68
|
-
let polyfill = null;
|
|
66
|
+
let polyfill: Function | null = null;
|
|
69
67
|
if (key === 'meta') {
|
|
70
68
|
// ignore
|
|
71
69
|
} else if (typeof gl[key] === 'function') {
|
|
@@ -86,7 +84,7 @@ function polyfillExtension(gl: WebGLRenderingContext, {extension, target, target
|
|
|
86
84
|
}
|
|
87
85
|
|
|
88
86
|
/** Install simple overrides (mostly get* functions) */
|
|
89
|
-
function installOverrides(gl, {target, target2}) {
|
|
87
|
+
function installOverrides(gl: WebGLRenderingContext, {target, target2}) {
|
|
90
88
|
Object.keys(WEBGL2_CONTEXT_OVERRIDES).forEach((key) => {
|
|
91
89
|
if (typeof WEBGL2_CONTEXT_OVERRIDES[key] === 'function') {
|
|
92
90
|
// install an override, if no implementation was detected
|
|
@@ -3,8 +3,9 @@ import GL from '@luma.gl/constants';
|
|
|
3
3
|
import {isWebGL2} from '../context/webgl-checks';
|
|
4
4
|
|
|
5
5
|
import {getParameterPolyfill} from './get-parameter-polyfill';
|
|
6
|
-
import {
|
|
6
|
+
import {getContextData} from './context-data';
|
|
7
7
|
|
|
8
|
+
/* eslint-disable camelcase */
|
|
8
9
|
const OES_vertex_array_object = 'OES_vertex_array_object';
|
|
9
10
|
const ANGLE_instanced_arrays = 'ANGLE_instanced_arrays';
|
|
10
11
|
const WEBGL_draw_buffers = 'WEBGL_draw_buffers';
|
|
@@ -14,14 +15,14 @@ const EXT_texture_filter_anisotropic = 'EXT_texture_filter_anisotropic';
|
|
|
14
15
|
const ERR_VAO_NOT_SUPPORTED = 'VertexArray requires WebGL2 or OES_vertex_array_object extension';
|
|
15
16
|
|
|
16
17
|
// Return object with webgl2 flag and an extension
|
|
17
|
-
function getExtensionData(gl, extension) {
|
|
18
|
+
function getExtensionData(gl: WebGLRenderingContext, extension: string) {
|
|
18
19
|
return {
|
|
19
20
|
webgl2: isWebGL2(gl),
|
|
20
21
|
ext: gl.getExtension(extension)
|
|
21
22
|
};
|
|
22
23
|
}
|
|
23
24
|
|
|
24
|
-
// function mapExtensionConstant(gl, constant) {
|
|
25
|
+
// function mapExtensionConstant(gl: WebGLRenderingContext, constant) {
|
|
25
26
|
// switch (constant) {
|
|
26
27
|
// case ext.FRAGMENT_SHADER_DERIVATIVE_HINT_OES: return GL.FRAGMENT_SHADER_DERIVATIVE_HINT;
|
|
27
28
|
// }
|
|
@@ -46,7 +47,7 @@ export const WEBGL2_CONTEXT_POLYFILLS = {
|
|
|
46
47
|
// VERTEX_ATTRIB_ARRAY_DIVISOR: 'VERTEX_ATTRIB_ARRAY_DIVISOR_ANGLE'
|
|
47
48
|
// }
|
|
48
49
|
},
|
|
49
|
-
vertexAttribDivisor(location, divisor) {
|
|
50
|
+
vertexAttribDivisor(location: number, divisor: number) {
|
|
50
51
|
// Accept divisor 0 even if instancing is not supported (0 = no instancing)
|
|
51
52
|
assert(divisor === 0, 'WebGL instanced rendering not supported');
|
|
52
53
|
},
|
|
@@ -74,20 +75,20 @@ export const WEBGL2_CONTEXT_POLYFILLS = {
|
|
|
74
75
|
assert(false);
|
|
75
76
|
},
|
|
76
77
|
endQuery: () => {},
|
|
77
|
-
getQuery(handle, pname) {
|
|
78
|
+
getQuery(handle, pname: string) {
|
|
78
79
|
return this.getQueryObject(handle, pname);
|
|
79
80
|
},
|
|
80
81
|
// The WebGL1 extension uses getQueryObject rather then getQueryParameter
|
|
81
|
-
getQueryParameter(handle, pname) {
|
|
82
|
+
getQueryParameter(handle, pname: string) {
|
|
82
83
|
return this.getQueryObject(handle, pname);
|
|
83
84
|
},
|
|
84
|
-
getQueryObject: () => {}
|
|
85
|
+
getQueryObject: (handle: unknown, pname: unknown) => {}
|
|
85
86
|
}
|
|
86
87
|
};
|
|
87
88
|
|
|
88
89
|
export const WEBGL2_CONTEXT_OVERRIDES = {
|
|
89
90
|
// Ensure readBuffer is a no-op
|
|
90
|
-
readBuffer: (gl, originalFunc, attachment) => {
|
|
91
|
+
readBuffer: (gl: WebGLRenderingContext, originalFunc, attachment) => {
|
|
91
92
|
if (isWebGL2(gl)) {
|
|
92
93
|
originalFunc(attachment);
|
|
93
94
|
} else {
|
|
@@ -95,7 +96,7 @@ export const WEBGL2_CONTEXT_OVERRIDES = {
|
|
|
95
96
|
}
|
|
96
97
|
},
|
|
97
98
|
// Override for getVertexAttrib that returns sane values for non-WebGL1 constants
|
|
98
|
-
getVertexAttrib: (gl, originalFunc, location, pname) => {
|
|
99
|
+
getVertexAttrib: (gl: WebGLRenderingContext, originalFunc, location, pname) => {
|
|
99
100
|
// const gl = this; // eslint-disable-line
|
|
100
101
|
const {webgl2, ext} = getExtensionData(gl, ANGLE_instanced_arrays);
|
|
101
102
|
|
|
@@ -115,7 +116,7 @@ export const WEBGL2_CONTEXT_OVERRIDES = {
|
|
|
115
116
|
return result !== undefined ? result : originalFunc(location, pname);
|
|
116
117
|
},
|
|
117
118
|
// Handle transform feedback and uniform block queries in WebGL1
|
|
118
|
-
getProgramParameter: (gl, originalFunc, program, pname) => {
|
|
119
|
+
getProgramParameter: (gl: WebGLRenderingContext, originalFunc, program, pname) => {
|
|
119
120
|
if (!isWebGL2(gl)) {
|
|
120
121
|
switch (pname) {
|
|
121
122
|
case GL.TRANSFORM_FEEDBACK_BUFFER_MODE:
|
|
@@ -129,7 +130,7 @@ export const WEBGL2_CONTEXT_OVERRIDES = {
|
|
|
129
130
|
}
|
|
130
131
|
return originalFunc(program, pname);
|
|
131
132
|
},
|
|
132
|
-
getInternalformatParameter: (gl, originalFunc, target, format, pname) => {
|
|
133
|
+
getInternalformatParameter: (gl: WebGLRenderingContext, originalFunc, target, format, pname) => {
|
|
133
134
|
if (!isWebGL2(gl)) {
|
|
134
135
|
switch (pname) {
|
|
135
136
|
case GL.SAMPLES:
|
|
@@ -137,13 +138,14 @@ export const WEBGL2_CONTEXT_OVERRIDES = {
|
|
|
137
138
|
default:
|
|
138
139
|
}
|
|
139
140
|
}
|
|
140
|
-
|
|
141
|
+
const gl2 = gl as WebGL2RenderingContext;
|
|
142
|
+
return gl2.getInternalformatParameter(target, format, pname);
|
|
141
143
|
},
|
|
142
144
|
getTexParameter(gl, originalFunc, target, pname) {
|
|
143
145
|
switch (pname) {
|
|
144
146
|
case GL.TEXTURE_MAX_ANISOTROPY_EXT:
|
|
145
|
-
const
|
|
146
|
-
const {_extensions} =
|
|
147
|
+
const contextData = getContextData(gl);
|
|
148
|
+
const {_extensions} = contextData;
|
|
147
149
|
const ext = _extensions[EXT_texture_filter_anisotropic];
|
|
148
150
|
pname = (ext && ext.TEXTURE_MAX_ANISOTROPY_EXT) || GL.TEXTURE_MAX_ANISOTROPY_EXT;
|
|
149
151
|
break;
|
|
@@ -25,6 +25,7 @@
|
|
|
25
25
|
// the global class.
|
|
26
26
|
|
|
27
27
|
// @ts-nocheck external code
|
|
28
|
+
/* eslint-disable */
|
|
28
29
|
|
|
29
30
|
const glErrorShadow = {};
|
|
30
31
|
|
|
@@ -103,6 +104,7 @@ WebGLVertexArrayObjectOES.VertexAttrib.prototype.recache = function recache() {
|
|
|
103
104
|
};
|
|
104
105
|
|
|
105
106
|
const OESVertexArrayObject = function OESVertexArrayObject(gl) {
|
|
107
|
+
// eslint-disable-next-line @typescript-eslint/no-this-alias
|
|
106
108
|
const self = this;
|
|
107
109
|
this.gl = gl;
|
|
108
110
|
|
|
@@ -10,14 +10,14 @@ import {deepArrayEqual} from './deep-array-equal';
|
|
|
10
10
|
/* eslint-disable no-shadow */
|
|
11
11
|
class GLState {
|
|
12
12
|
gl: WebGLRenderingContext;
|
|
13
|
-
program = null;
|
|
14
|
-
stateStack = [];
|
|
13
|
+
program: unknown = null;
|
|
14
|
+
stateStack: object[] = [];
|
|
15
15
|
enable = true;
|
|
16
|
-
cache
|
|
16
|
+
cache: Record<string, any>;
|
|
17
17
|
log;
|
|
18
18
|
|
|
19
19
|
constructor(
|
|
20
|
-
gl,
|
|
20
|
+
gl: WebGLRenderingContext,
|
|
21
21
|
{
|
|
22
22
|
copyState = false, // Copy cache from params (slow) or initialize from WebGL defaults (fast)
|
|
23
23
|
log = () => {} // Logging function, called when gl parameter change calls are actually issued
|
|
@@ -50,11 +50,11 @@ class GLState {
|
|
|
50
50
|
* @param values
|
|
51
51
|
* @returns
|
|
52
52
|
*/
|
|
53
|
-
_updateCache(values) {
|
|
53
|
+
_updateCache(values: {[key: number | string]: any}) {
|
|
54
54
|
let valueChanged = false;
|
|
55
55
|
let oldValue; // = undefined
|
|
56
56
|
|
|
57
|
-
const oldValues = this.stateStack.length > 0
|
|
57
|
+
const oldValues: {[key: number | string]: any} | null = this.stateStack.length > 0 ? this.stateStack[this.stateStack.length - 1] : null;
|
|
58
58
|
|
|
59
59
|
for (const key in values) {
|
|
60
60
|
assert(key !== undefined);
|
|
@@ -96,7 +96,7 @@ function getContextState(gl: WebGLRenderingContext): GLState {
|
|
|
96
96
|
* gl.state.push() and gl.state.pop() will be available for saving,
|
|
97
97
|
* temporarily modifying, and then restoring state.
|
|
98
98
|
*/
|
|
99
|
-
|
|
99
|
+
export function trackContextState(
|
|
100
100
|
gl: WebGLRenderingContext,
|
|
101
101
|
options?: {
|
|
102
102
|
enable?: boolean;
|
|
@@ -108,7 +108,6 @@ function getContextState(gl: WebGLRenderingContext): GLState {
|
|
|
108
108
|
assert(copyState !== undefined);
|
|
109
109
|
// @ts-expect-error
|
|
110
110
|
if (!gl.state) {
|
|
111
|
-
const global_ = typeof global !== 'undefined' ? global : window;
|
|
112
111
|
// @ts-ignore
|
|
113
112
|
// const {polyfillContext} = global_;
|
|
114
113
|
// if (polyfillContext) {
|
|
@@ -141,7 +140,7 @@ function getContextState(gl: WebGLRenderingContext): GLState {
|
|
|
141
140
|
/**
|
|
142
141
|
* Saves current WebGL context state onto an internal per-context stack
|
|
143
142
|
*/
|
|
144
|
-
|
|
143
|
+
export function pushContextState(gl: WebGLRenderingContext): void {
|
|
145
144
|
let glState = getContextState(gl);
|
|
146
145
|
if (!glState) {
|
|
147
146
|
trackContextState(gl, {copyState: false});
|
|
@@ -188,9 +187,9 @@ function installGetterOverride(gl: WebGLRenderingContext, functionName: string)
|
|
|
188
187
|
// Optionally call the original function to do a "hard" query from the WebGLRenderingContext
|
|
189
188
|
return glState.enable
|
|
190
189
|
? // Call the getter the params so that it can e.g. serve from a cache
|
|
191
|
-
|
|
190
|
+
glState.cache[pname]
|
|
192
191
|
: // Optionally call the original function to do a "hard" query from the WebGLRenderingContext
|
|
193
|
-
|
|
192
|
+
originalGetterFunc(pname);
|
|
194
193
|
};
|
|
195
194
|
|
|
196
195
|
// Set the name of this anonymous function to help in debugging and profiling
|
|
@@ -209,12 +208,13 @@ function installGetterOverride(gl: WebGLRenderingContext, functionName: string)
|
|
|
209
208
|
* @param setter
|
|
210
209
|
* @returns
|
|
211
210
|
*/
|
|
212
|
-
function installSetterSpy(gl: WebGLRenderingContext, functionName, setter) {
|
|
211
|
+
function installSetterSpy(gl: WebGLRenderingContext, functionName: string, setter: Function) {
|
|
213
212
|
// Get the original function from the WebGLRenderingContext
|
|
214
213
|
if (!gl[functionName]) {
|
|
215
214
|
// This could happen if we try to intercept WebGL2 method on a WebGL1 context
|
|
216
215
|
return;
|
|
217
216
|
}
|
|
217
|
+
|
|
218
218
|
const originalSetterFunc = gl[functionName].bind(gl);
|
|
219
219
|
|
|
220
220
|
// Wrap it with a spy so that we can update our state cache when it gets called
|
|
@@ -222,6 +222,7 @@ function installSetterSpy(gl: WebGLRenderingContext, functionName, setter) {
|
|
|
222
222
|
// Update the value
|
|
223
223
|
// Call the setter with the state cache and the params so that it can store the parameters
|
|
224
224
|
const glState = getContextState(gl);
|
|
225
|
+
// eslint-disable-next-line @typescript-eslint/unbound-method
|
|
225
226
|
const {valueChanged, oldValue} = setter(glState._updateCache, ...params);
|
|
226
227
|
|
|
227
228
|
// Call the original WebGLRenderingContext func to make sure the context actually gets updated
|
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
import type {Device} from '@luma.gl/api';
|
|
2
|
+
import {WebGLDevice} from '../../adapter/webgl-device';
|
|
1
3
|
import {GLParameters, setParameters} from '../parameters/unified-parameter-api';
|
|
2
4
|
import {pushContextState, popContextState} from './track-context-state';
|
|
3
5
|
|
|
@@ -9,10 +11,13 @@ import {pushContextState, popContextState} from './track-context-state';
|
|
|
9
11
|
* - Restores parameters
|
|
10
12
|
* - Returns the return value of the supplied function
|
|
11
13
|
*/
|
|
12
|
-
|
|
14
|
+
export function withParameters(device: Device | WebGLRenderingContext, parameters: GLParameters & {nocatch?: boolean}, func: any): any {
|
|
15
|
+
const webglDevice = WebGLDevice.attach(device);
|
|
16
|
+
const gl = webglDevice.gl;
|
|
17
|
+
|
|
13
18
|
if (isObjectEmpty(parameters)) {
|
|
14
19
|
// Avoid setting state if no parameters provided. Just call and return
|
|
15
|
-
return func(
|
|
20
|
+
return func(device);
|
|
16
21
|
}
|
|
17
22
|
|
|
18
23
|
const {nocatch = true} = parameters;
|
|
@@ -43,6 +48,7 @@ import {pushContextState, popContextState} from './track-context-state';
|
|
|
43
48
|
|
|
44
49
|
// Returns true if given object is empty, false otherwise.
|
|
45
50
|
function isObjectEmpty(object) {
|
|
51
|
+
// @ts-ignore - dummy key variable
|
|
46
52
|
for (const key in object) {
|
|
47
53
|
return false;
|
|
48
54
|
}
|
package/src/index.ts
CHANGED
|
@@ -4,35 +4,40 @@
|
|
|
4
4
|
// but make it easier to use.
|
|
5
5
|
// Higher level abstractions can be built on these classes
|
|
6
6
|
|
|
7
|
-
//
|
|
8
|
-
|
|
9
|
-
import './init'
|
|
7
|
+
// Types
|
|
8
|
+
export type {WebGLLimits} from './adapter/device-helpers/device-limits';
|
|
10
9
|
|
|
11
|
-
export {
|
|
12
|
-
export {default as WebGLCanvasContext} from './adapter/webgl-canvas-context';
|
|
10
|
+
export {registerHeadlessGL} from './context/context/create-headless-context';
|
|
13
11
|
|
|
14
|
-
//
|
|
15
|
-
export {
|
|
16
|
-
export
|
|
17
|
-
export {default as Buffer} from './classic/buffer';
|
|
18
|
-
export {default as WEBGLResource, default as WebGLResource} from './adapter/objects/webgl-resource';
|
|
19
|
-
export {default as WEBGLBuffer} from './adapter/resources/webgl-buffer';
|
|
20
|
-
export {default as WEBGLTexture} from './adapter/resources/webgl-texture';
|
|
21
|
-
// export {default as WEBGLExternalTexture} from './adapter/resources/webgl-external-texture';
|
|
22
|
-
export {default as WEBGLShader} from './adapter/resources/webgl-shader';
|
|
23
|
-
export {default as WEBGLSampler} from './adapter/resources/webgl-sampler';
|
|
24
|
-
export {default as WEBGLFramebuffer} from './adapter/resources/webgl-framebuffer';
|
|
12
|
+
// WebGL adapter classes
|
|
13
|
+
export {WebGLDevice} from './adapter/webgl-device';
|
|
14
|
+
export {WebGLCanvasContext} from './adapter/webgl-canvas-context';
|
|
25
15
|
|
|
26
|
-
|
|
16
|
+
// WebGL Resource classes
|
|
17
|
+
export {WebGLResource, WebGLResource as WEBGLResource} from './adapter/objects/webgl-resource';
|
|
18
|
+
export {WEBGLBuffer} from './adapter/resources/webgl-buffer';
|
|
19
|
+
export {WEBGLTexture} from './adapter/resources/webgl-texture';
|
|
20
|
+
// export {WEBGLExternalTexture} from './adapter/resources/webgl-external-texture';
|
|
21
|
+
export {WEBGLShader} from './adapter/resources/webgl-shader';
|
|
22
|
+
export {WEBGLSampler} from './adapter/resources/webgl-sampler';
|
|
23
|
+
export {WEBGLFramebuffer} from './adapter/resources/webgl-framebuffer';
|
|
27
24
|
|
|
28
|
-
|
|
29
|
-
export {
|
|
30
|
-
export {
|
|
31
|
-
|
|
25
|
+
export {WEBGLRenderPipeline} from './adapter/resources/webgl-render-pipeline';
|
|
26
|
+
// export {WEBGLComputePipeline} from './adapter/resources/webgl-compute-pipeline';
|
|
27
|
+
export {WEBGLCommandEncoder} from './adapter/resources/webgl-command-encoder';
|
|
28
|
+
export {WEBGLRenderPass} from './adapter/resources/webgl-render-pass';
|
|
29
|
+
// export {WEBGLComputePass} from './adapter/resources/webgl-compute-pass';
|
|
32
30
|
|
|
31
|
+
// non-api resources
|
|
33
32
|
export type {RenderbufferProps} from './adapter/objects/webgl-renderbuffer';
|
|
34
|
-
export {
|
|
35
|
-
export {
|
|
33
|
+
export {WEBGLRenderbuffer} from './adapter/objects/webgl-renderbuffer';
|
|
34
|
+
export {WEBGLVertexArrayObject} from './adapter/objects/webgl-vertex-array-object';
|
|
35
|
+
|
|
36
|
+
// WebGL adapter classes (Legacy, will be moved to gltools)
|
|
37
|
+
export {Accessor} from './classic/accessor';
|
|
38
|
+
export type {AccessorObject} from './types';
|
|
39
|
+
export type {ClassicBufferProps, ClassicBufferProps as BufferProps} from './classic/buffer';
|
|
40
|
+
export {ClassicBuffer, ClassicBuffer as Buffer} from './classic/buffer';
|
|
36
41
|
|
|
37
42
|
export {
|
|
38
43
|
isWebGL,
|
|
@@ -42,9 +47,6 @@ export {
|
|
|
42
47
|
assertWebGL2Context
|
|
43
48
|
} from './context/context/webgl-checks';
|
|
44
49
|
|
|
45
|
-
// Device ratio
|
|
46
|
-
export {cssToDeviceRatio, cssToDevicePixels} from './context/context/device-pixels';
|
|
47
|
-
|
|
48
50
|
// Unified parameter API
|
|
49
51
|
|
|
50
52
|
export {setDeviceParameters, withDeviceParameters} from './adapter/converters/device-parameters';
|
package/src/types/webgl.ts
CHANGED
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
import type {NumberArray} from '@luma.gl/api';
|
|
2
2
|
import GL from '@luma.gl/constants';
|
|
3
3
|
|
|
4
|
+
/* eslint-disable camelcase */
|
|
5
|
+
|
|
4
6
|
type Framebuffer = any;
|
|
5
7
|
|
|
6
8
|
export type GLDrawMode =
|
|
@@ -120,7 +122,7 @@ export type GLStencilOp =
|
|
|
120
122
|
| GL.INVERT;
|
|
121
123
|
|
|
122
124
|
/** Parameters for textures and samplers */
|
|
123
|
-
export type
|
|
125
|
+
export type GLSamplerParameters = {
|
|
124
126
|
[GL.TEXTURE_WRAP_S]?: GL.CLAMP_TO_EDGE | GL.REPEAT | GL.MIRRORED_REPEAT;
|
|
125
127
|
[GL.TEXTURE_WRAP_T]?: GL.CLAMP_TO_EDGE | GL.REPEAT | GL.MIRRORED_REPEAT;
|
|
126
128
|
[GL.TEXTURE_WRAP_R]?: GL.CLAMP_TO_EDGE | GL.REPEAT | GL.MIRRORED_REPEAT;
|
|
@@ -135,6 +137,7 @@ export type WebGLSamplerParameters = {
|
|
|
135
137
|
[GL.TEXTURE_MIN_LOD]?: number;
|
|
136
138
|
[GL.TEXTURE_MAX_LOD]?: number;
|
|
137
139
|
[GL.TEXTURE_COMPARE_FUNC]?: number; // COMPARE_FUNC);
|
|
140
|
+
[GL.TEXTURE_COMPARE_MODE]?: GL.COMPARE_REF_TO_TEXTURE;
|
|
138
141
|
[GL.TEXTURE_MAX_ANISOTROPY_EXT]?: number; //
|
|
139
142
|
};
|
|
140
143
|
|
|
@@ -193,11 +196,11 @@ export type GLValueParameters = {
|
|
|
193
196
|
[GL.STENCIL_WRITEMASK]?: number;
|
|
194
197
|
[GL.STENCIL_BACK_WRITEMASK]?: number;
|
|
195
198
|
[GL.STENCIL_FUNC]?: GLFunction;
|
|
196
|
-
[GL.STENCIL_REF]?:
|
|
197
|
-
[GL.STENCIL_VALUE_MASK]?:
|
|
199
|
+
[GL.STENCIL_REF]?: number;
|
|
200
|
+
[GL.STENCIL_VALUE_MASK]?: number;
|
|
198
201
|
[GL.STENCIL_BACK_FUNC]?: GLFunction;
|
|
199
|
-
[GL.STENCIL_BACK_REF]?:
|
|
200
|
-
[GL.STENCIL_BACK_VALUE_MASK]?:
|
|
202
|
+
[GL.STENCIL_BACK_REF]?: number;
|
|
203
|
+
[GL.STENCIL_BACK_VALUE_MASK]?: number;
|
|
201
204
|
[GL.STENCIL_FAIL]?: GLStencilOp;
|
|
202
205
|
[GL.STENCIL_PASS_DEPTH_FAIL]?: GLStencilOp;
|
|
203
206
|
[GL.STENCIL_PASS_DEPTH_PASS]?: GLStencilOp;
|
|
@@ -240,7 +243,7 @@ export type GLFunctionParameters = {
|
|
|
240
243
|
clearDepth?: number;
|
|
241
244
|
clearStencil?: number;
|
|
242
245
|
|
|
243
|
-
colorMask?: [boolean, boolean, boolean, boolean];
|
|
246
|
+
colorMask?: [boolean, boolean, boolean, boolean] | boolean[];
|
|
244
247
|
|
|
245
248
|
cull?: boolean;
|
|
246
249
|
cullFace?: GL.FRONT | GL.BACK | GL.FRONT_AND_BACK;
|
|
@@ -280,4 +283,4 @@ export type GLFunctionParameters = {
|
|
|
280
283
|
};
|
|
281
284
|
|
|
282
285
|
/** WebGL style parameters object (with both GL constants and function style fields) */
|
|
283
|
-
export type GLParameters = GLValueParameters
|
|
286
|
+
export type GLParameters = GLValueParameters & GLFunctionParameters;
|
package/dist/bundle.d.ts
DELETED
package/dist/bundle.d.ts.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"bundle.d.ts","sourceRoot":"","sources":["../src/bundle.ts"],"names":[],"mappings":"AACA,QAAA,MAAM,aAAa,KAAqB,CAAC"}
|
package/dist/bundle.js
DELETED
package/dist/bundle.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/bundle.ts"],"names":["moduleExports","require","globalThis","luma","module","exports","Object","assign"],"mappings":"AACA,MAAMA,aAAa,GAAGC,OAAO,CAAC,SAAD,CAA7B;;AACAC,UAAU,CAACC,IAAX,GAAkBD,UAAU,CAACC,IAAX,IAAmB,EAArC;AACAC,MAAM,CAACC,OAAP,GAAiBC,MAAM,CAACC,MAAP,CAAcL,UAAU,CAACC,IAAzB,EAA+BH,aAA/B,CAAjB","sourcesContent":["// @ts-nocheck\nconst moduleExports = require('./index');\nglobalThis.luma = globalThis.luma || {};\nmodule.exports = Object.assign(globalThis.luma, moduleExports);\n"],"file":"bundle.js"}
|
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Stores luma.gl specific state associated with a context
|
|
3
|
-
*/
|
|
4
|
-
export interface ContextState {
|
|
5
|
-
_canvasSizeInfo: {
|
|
6
|
-
clientWidth: number;
|
|
7
|
-
clientHeight: number;
|
|
8
|
-
devicePixelRatio: number;
|
|
9
|
-
};
|
|
10
|
-
_polyfilled: boolean;
|
|
11
|
-
_extensions: Record<string, any>;
|
|
12
|
-
}
|
|
13
|
-
/**
|
|
14
|
-
* Gets luma.gl specific state from a context
|
|
15
|
-
* @returns context state
|
|
16
|
-
*/
|
|
17
|
-
export declare function getContextState(gl: WebGLRenderingContext): ContextState;
|
|
18
|
-
//# sourceMappingURL=context-state.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"context-state.d.ts","sourceRoot":"","sources":["../../../src/context/context/context-state.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,MAAM,WAAW,YAAY;IAC3B,eAAe,EAAE;QACf,WAAW,EAAE,MAAM,CAAC;QACpB,YAAY,EAAE,MAAM,CAAC;QACrB,gBAAgB,EAAE,MAAM,CAAC;KAC1B,CAAC;IACF,WAAW,EAAE,OAAO,CAAC;IACrB,WAAW,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,CAAC;CAClC;AAED;;;GAGG;AACH,wBAAgB,eAAe,CAAC,EAAE,EAAE,qBAAqB,GAAG,YAAY,CAuBvE"}
|
|
@@ -1,26 +0,0 @@
|
|
|
1
|
-
export function getContextState(gl) {
|
|
2
|
-
const {
|
|
3
|
-
device,
|
|
4
|
-
luma
|
|
5
|
-
} = gl;
|
|
6
|
-
|
|
7
|
-
if (device) {
|
|
8
|
-
return device;
|
|
9
|
-
}
|
|
10
|
-
|
|
11
|
-
if (!luma) {
|
|
12
|
-
const contextState = {
|
|
13
|
-
_canvasSizeInfo: {
|
|
14
|
-
clientWidth: 0,
|
|
15
|
-
clientHeight: 0,
|
|
16
|
-
devicePixelRatio: 1
|
|
17
|
-
},
|
|
18
|
-
_polyfilled: false,
|
|
19
|
-
_extensions: {}
|
|
20
|
-
};
|
|
21
|
-
gl.luma = contextState;
|
|
22
|
-
}
|
|
23
|
-
|
|
24
|
-
throw new Error('context state without device');
|
|
25
|
-
}
|
|
26
|
-
//# sourceMappingURL=context-state.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/context/context/context-state.ts"],"names":["getContextState","gl","device","luma","contextState","_canvasSizeInfo","clientWidth","clientHeight","devicePixelRatio","_polyfilled","_extensions","Error"],"mappings":"AAiBA,OAAO,SAASA,eAAT,CAAyBC,EAAzB,EAAkE;AAEvE,QAAM;AAACC,IAAAA,MAAD;AAASC,IAAAA;AAAT,MAAiBF,EAAvB;;AACA,MAAIC,MAAJ,EAAY;AACV,WAAOA,MAAP;AACD;;AACD,MAAI,CAACC,IAAL,EAAW;AACT,UAAMC,YAA0B,GAAG;AACjCC,MAAAA,eAAe,EAAE;AACfC,QAAAA,WAAW,EAAE,CADE;AAEfC,QAAAA,YAAY,EAAE,CAFC;AAGfC,QAAAA,gBAAgB,EAAE;AAHH,OADgB;AAMjCC,MAAAA,WAAW,EAAE,KANoB;AAOjCC,MAAAA,WAAW,EAAE;AAPoB,KAAnC;AAUAT,IAAAA,EAAE,CAACE,IAAH,GAAUC,YAAV;AACD;;AACD,QAAM,IAAIO,KAAJ,CAAU,8BAAV,CAAN;AAID","sourcesContent":["/**\n * Stores luma.gl specific state associated with a context\n */\nexport interface ContextState {\n _canvasSizeInfo: {\n clientWidth: number;\n clientHeight: number;\n devicePixelRatio: number;\n };\n _polyfilled: boolean;\n _extensions: Record<string, any>;\n}\n\n/**\n * Gets luma.gl specific state from a context\n * @returns context state\n */\nexport function getContextState(gl: WebGLRenderingContext): ContextState {\n // @ts-expect-error\n const {device, luma} = gl;\n if (device) {\n return device as ContextState;\n }\n if (!luma) {\n const contextState: ContextState = {\n _canvasSizeInfo: {\n clientWidth: 0,\n clientHeight: 0,\n devicePixelRatio: 1,\n },\n _polyfilled: false,\n _extensions: {}\n };\n // @ts-expect-error\n gl.luma = contextState;\n }\n throw new Error('context state without device');\n\n // // @ts-expect-error\n // return gl.luma;\n}\n"],"file":"context-state.js"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"create-context.d.ts","sourceRoot":"","sources":["../../../src/context/context/create-context.ts"],"names":[],"mappings":";AAEA;;;;;;;;;;;;;;;;EAgBE;AACF,aAAK,YAAY,GAAG;IAClB,IAAI,CAAC,EAAE,OAAO,GAAG,QAAQ,GAAG,QAAQ,GAAG,MAAM,CAAC;IAC9C,MAAM,CAAC,EAAE,OAAO,CAAC;IACjB,MAAM,CAAC,EAAE,OAAO,CAAC;IACjB,aAAa,CAAC,EAAE,CAAC,KAAK,EAAE,KAAK,KAAK,IAAI,CAAC;IACvC,iBAAiB,CAAC,EAAE,CAAC,KAAK,EAAE,KAAK,KAAK,IAAI,CAAC;IAC3C,KAAK,CAAC,EAAE,OAAO,CAAC;IAChB,cAAc,CAAC,EAAE,OAAO,CAAC;IACzB,SAAS,CAAC,EAAE,OAAO,CAAC;IACpB,KAAK,CAAC,EAAE,OAAO,CAAC;IAChB,4BAA4B,CAAC,EAAE,OAAO,CAAC;IACvC,eAAe,CAAC,EAAE,SAAS,GAAI,kBAAkB,GAAG,WAAW,CAAC;IAChE,kBAAkB,CAAC,EAAE,OAAO,CAAC;IAC7B,qBAAqB,CAAC,EAAE,OAAO,CAAA;CAChC,CAAC;AAUF;;;;GAIG;AACF,wBAAgB,oBAAoB,CAAC,MAAM,EAAE,iBAAiB,GAAG,eAAe,EAAE,KAAK,EAAE,YAAY,GAAG,qBAAqB,CAyC7H"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/context/context/create-context.ts"],"names":["DEFAULT_CONTEXT_PROPS","webgl2","webgl1","powerPreference","onContextLost","console","error","onContextRestored","info","createBrowserContext","canvas","props","errorMessage","onCreateError","statusMessage","addEventListener","gl","type","getContext","removeEventListener","Error"],"mappings":"AAmCA,MAAMA,qBAAmC,GAAG;AAC1CC,EAAAA,MAAM,EAAE,IADkC;AAE1CC,EAAAA,MAAM,EAAE,IAFkC;AAG1CC,EAAAA,eAAe,EAAE,kBAHyB;AAI1CC,EAAAA,aAAa,EAAE,MAAMC,OAAO,CAACC,KAAR,CAAc,oBAAd,CAJqB;AAK1CC,EAAAA,iBAAiB,EAAE,MAAMF,OAAO,CAACG,IAAR,CAAa,wBAAb;AALiB,CAA5C;AAaC,OAAO,SAASC,oBAAT,CAA8BC,MAA9B,EAA2EC,KAA3E,EAAuH;AAC5HA,EAAAA,KAAK,GAAG,EAAC,GAAGX,qBAAJ;AAA2B,OAAGW;AAA9B,GAAR;AAGD,MAAIC,YAAY,GAAG,IAAnB;;AACA,QAAMC,aAAa,GAAIP,KAAD,IAAYM,YAAY,GAAGN,KAAK,CAACQ,aAAN,IAAuBF,YAAxE;;AACAF,EAAAA,MAAM,CAACK,gBAAP,CAAwB,2BAAxB,EAAqDF,aAArD,EAAoE,KAApE;AAGA,MAAIG,EAAE,GAAG,IAAT;;AAEA,MAAIL,KAAK,CAACM,IAAN,KAAe,QAAnB,EAA6B;AAC3BN,IAAAA,KAAK,GAAG,EAAC,GAAGA,KAAJ;AAAWT,MAAAA,MAAM,EAAE;AAAnB,KAAR;AACD;;AACD,MAAIS,KAAK,CAACM,IAAN,KAAe,QAAnB,EAA6B;AAC3BN,IAAAA,KAAK,GAAG,EAAC,GAAGA,KAAJ;AAAWV,MAAAA,MAAM,EAAE;AAAnB,KAAR;AACD;;AAGD,MAAIU,KAAK,CAACV,MAAV,EAAkB;AAChBe,IAAAA,EAAE,GAAGA,EAAE,IAAIN,MAAM,CAACQ,UAAP,CAAkB,QAAlB,EAA4BP,KAA5B,CAAX;AACD;;AACD,MAAIA,KAAK,CAACT,MAAV,EAAkB;AAChBc,IAAAA,EAAE,GAAGA,EAAE,IAAIN,MAAM,CAACQ,UAAP,CAAkB,OAAlB,EAA2BP,KAA3B,CAAX;AACD;;AAGDD,EAAAA,MAAM,CAACS,mBAAP,CAA2B,2BAA3B,EAAwDN,aAAxD,EAAuE,KAAvE;;AAEA,MAAI,CAACG,EAAL,EAAS;AACP,UAAM,IAAII,KAAJ,4BACgBT,KAAK,CAACV,MAAN,IAAgB,CAACU,KAAK,CAACT,MAAvB,GAAgC,QAAhC,GAA2C,OAD3D,uBAEFU,YAAY,IAAI,eAFd,EAAN;AAKD;;AAEDF,EAAAA,MAAM,CAACK,gBAAP,CAAwB,kBAAxB,EAA4CJ,KAAK,CAACP,aAAlD,EAAiE,KAAjE;AACAM,EAAAA,MAAM,CAACK,gBAAP,CAAwB,sBAAxB,EAAgDJ,KAAK,CAACJ,iBAAtD,EAAyE,KAAzE;AAEA,SAAOS,EAAP;AACD","sourcesContent":["// luma.gl, MIT license\n\n/**\n * ContextProps\n* @param webgl2 Set to false to not create a WebGL2 context (force webgl1)\n* @param webgl1 set to false to not create a WebGL1 context (fail if webgl2 not available)\n* @param onContextLost\n* @param onContextRestored\n*\n* BROWSER CONTEXT PARAMETERS\n* @param debug Instrument context (at the expense of performance).\n* @param alpha Default render target has an alpha buffer.\n* @param depth Default render target has a depth buffer of at least 16 bits.\n* @param stencil Default render target has a stencil buffer of at least 8 bits.\n* @param antialias Boolean that indicates whether or not to perform anti-aliasing.\n* @param premultipliedAlpha Boolean that indicates that the page compositor will assume the drawing buffer contains colors with pre-multiplied alpha.\n* @param preserveDrawingBuffer Default render target buffers will not be automatically cleared and will preserve their values until cleared or overwritten\n* @param failIfMajorPerformanceCaveat Do not create if the system performance is low.\n*/\ntype ContextProps = {\n type?: 'webgl' | 'webgl1' | 'webgl2' | string;\n webgl1?: boolean;\n webgl2?: boolean;\n onContextLost?: (event: Event) => void;\n onContextRestored?: (event: Event) => void;\n alpha?: boolean; // indicates if the canvas contains an alpha buffer.\n desynchronized?: boolean; // hints the user agent to reduce the latency by desynchronizing the canvas paint cycle from the event loop\n antialias?: boolean; // indicates whether or not to perform anti-aliasing.\n depth?: boolean; // indicates that the drawing buffer has a depth buffer of at least 16 bits.\n failIfMajorPerformanceCaveat?: boolean, // indicates if a context will be created if the system performance is low or if no hardware GPU is available.\n powerPreference?: 'default' | 'high-performance' | 'low-power',\n premultipliedAlpha?: boolean, // page compositor will assume the drawing buffer contains colors with pre-multiplied alpha.\n preserveDrawingBuffer?: boolean // buffers will not be cleared and will preserve their values until cleared or overwritten by the author.\n};\n\nconst DEFAULT_CONTEXT_PROPS: ContextProps = {\n webgl2: true, // Attempt to create a WebGL2 context\n webgl1: true, // Attempt to create a WebGL1 context (false to fail if webgl2 not available)\n powerPreference: 'high-performance', // After all, most apps are using WebGL for performance reasons\n onContextLost: () => console.error('WebGL context lost'),\n onContextRestored: () => console.info('WebGL context restored'),\n};\n\n/**\n * Create a WebGL context for a canvas\n * Note calling this multiple time on the same canvas does return the same context\n* @param canvas A canvas element or offscreen canvas\n */\n export function createBrowserContext(canvas: HTMLCanvasElement | OffscreenCanvas, props: ContextProps): WebGLRenderingContext {\n props = {...DEFAULT_CONTEXT_PROPS, ...props};\n\n // Try to extract any extra information about why context creation failed\n let errorMessage = null;\n const onCreateError = (error) => (errorMessage = error.statusMessage || errorMessage);\n canvas.addEventListener('webglcontextcreationerror', onCreateError, false);\n\n // Create the desired context\n let gl = null;\n\n if (props.type === 'webgl2') {\n props = {...props, webgl1: false};\n }\n if (props.type === 'webgl1') {\n props = {...props, webgl2: false};\n }\n\n // Prefer webgl2 over webgl1 if both are acceptable\n if (props.webgl2) {\n gl = gl || canvas.getContext('webgl2', props);\n }\n if (props.webgl1) {\n gl = gl || canvas.getContext('webgl', props);\n }\n\n // TODO are we removing this listener before giving it a chance to fire?\n canvas.removeEventListener('webglcontextcreationerror', onCreateError, false);\n\n if (!gl) {\n throw new Error(\n `Failed to create ${props.webgl2 && !props.webgl1 ? 'WebGL2' : 'WebGL'} context: ${\n errorMessage || 'Unknown error'\n }`\n );\n }\n\n canvas.addEventListener('webglcontextlost', props.onContextLost, false);\n canvas.addEventListener('webglcontextrestored', props.onContextRestored, false);\n\n return gl;\n}\n\n/* TODO - can we call this asynchronously to catch the error events?\nexport async function createBrowserContextAsync(canvas: HTMLCanvasElement | OffscreenCanvas, props: ContextProps): Promise<WebGLRenderingContext> {\n props = {...DEFAULT_CONTEXT_PROPS, ...props};\n\n // Try to extract any extra information about why context creation failed\n let errorMessage = null;\n const onCreateError = (error) => (errorMessage = error.statusMessage || errorMessage);\n canvas.addEventListener('webglcontextcreationerror', onCreateError, false);\n\n const gl = createBrowserContext(canvas, props);\n\n // Give the listener a chance to fire\n await new Promise(resolve => setTimeout(resolve, 0));\n\n canvas.removeEventListener('webglcontextcreationerror', onCreateError, false);\n\n return gl;\n}\n*/\n"],"file":"create-context.js"}
|
|
@@ -1,25 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Returns multiplier need to convert CSS size to Device size
|
|
3
|
-
*/
|
|
4
|
-
export declare function cssToDeviceRatio(gl: WebGLRenderingContext): number;
|
|
5
|
-
/**
|
|
6
|
-
* Maps CSS pixel position to device pixel position
|
|
7
|
-
*/
|
|
8
|
-
export declare function cssToDevicePixels(gl: WebGLRenderingContext, cssPixel: number[], yInvert?: boolean): {
|
|
9
|
-
x: number;
|
|
10
|
-
y: number;
|
|
11
|
-
width: number;
|
|
12
|
-
height: number;
|
|
13
|
-
};
|
|
14
|
-
/**
|
|
15
|
-
* Calulates device pixel ratio, used during context creation
|
|
16
|
-
*
|
|
17
|
-
* @param useDevicePixels - boolean or a number
|
|
18
|
-
* @return - device pixel ratio
|
|
19
|
-
*/
|
|
20
|
-
export declare function getDevicePixelRatio(useDevicePixels: boolean | number): number;
|
|
21
|
-
export declare function setDevicePixelRatio(gl: WebGLRenderingContext, devicePixelRatio: number, options?: {
|
|
22
|
-
width?: number;
|
|
23
|
-
height?: number;
|
|
24
|
-
}): void;
|
|
25
|
-
//# sourceMappingURL=device-pixels.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"device-pixels.d.ts","sourceRoot":"","sources":["../../../src/context/context/device-pixels.ts"],"names":[],"mappings":"AAGA;;GAEG;AACH,wBAAgB,gBAAgB,CAAC,EAAE,EAAE,qBAAqB,GAAG,MAAM,CAWlE;AAED;;GAEG;AACF,wBAAgB,iBAAiB,CAChC,EAAE,EAAE,qBAAqB,EACzB,QAAQ,EAAE,MAAM,EAAE,EAClB,OAAO,GAAE,OAAc,GACtB;IACD,CAAC,EAAE,MAAM,CAAC;IACV,CAAC,EAAE,MAAM,CAAC;IACV,KAAK,EAAE,MAAM,CAAC;IACd,MAAM,EAAE,MAAM,CAAC;CAChB,CAKA;AAED;;;;;GAKG;AACF,wBAAgB,mBAAmB,CAAC,eAAe,EAAE,OAAO,GAAG,MAAM,GAAG,MAAM,CAO9E;AAGD,wBAAgB,mBAAmB,CAAC,EAAE,EAAE,qBAAqB,EAAE,gBAAgB,EAAE,MAAM,EAAE,OAAO,GAAE;IAAC,KAAK,CAAC,EAAE,MAAM,CAAC;IAAC,MAAM,CAAC,EAAE,MAAM,CAAA;CAAM,QA4CvI"}
|