@luma.gl/webgl 9.0.0-alpha.4 → 9.0.0-alpha.41
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/LICENSE +3 -1
- package/dist/adapter/converters/device-parameters.d.ts +23 -4
- package/dist/adapter/converters/device-parameters.d.ts.map +1 -1
- package/dist/adapter/converters/device-parameters.js +42 -47
- package/dist/adapter/converters/device-parameters.js.map +1 -1
- package/dist/adapter/converters/sampler-parameters.d.ts +5 -5
- package/dist/adapter/converters/sampler-parameters.d.ts.map +1 -1
- package/dist/adapter/converters/sampler-parameters.js +20 -56
- package/dist/adapter/converters/sampler-parameters.js.map +1 -1
- package/dist/adapter/converters/shader-formats.d.ts +9 -0
- package/dist/adapter/converters/shader-formats.d.ts.map +1 -0
- package/dist/adapter/converters/shader-formats.js +53 -0
- package/dist/adapter/converters/shader-formats.js.map +1 -0
- package/dist/adapter/converters/texture-formats.d.ts +32 -44
- package/dist/adapter/converters/texture-formats.d.ts.map +1 -1
- package/dist/adapter/converters/texture-formats.js +165 -201
- package/dist/adapter/converters/texture-formats.js.map +1 -1
- package/dist/adapter/converters/vertex-formats.d.ts +9 -3
- package/dist/adapter/converters/vertex-formats.d.ts.map +1 -1
- package/dist/adapter/converters/vertex-formats.js +51 -19
- package/dist/adapter/converters/vertex-formats.js.map +1 -1
- package/dist/adapter/device-helpers/device-features.d.ts +1 -1
- package/dist/adapter/device-helpers/device-features.d.ts.map +1 -1
- package/dist/adapter/device-helpers/device-features.js +14 -21
- package/dist/adapter/device-helpers/device-features.js.map +1 -1
- package/dist/adapter/device-helpers/device-limits.d.ts +3 -3
- package/dist/adapter/device-helpers/device-limits.d.ts.map +1 -1
- package/dist/adapter/device-helpers/device-limits.js +2 -5
- package/dist/adapter/device-helpers/device-limits.js.map +1 -1
- package/dist/adapter/device-helpers/get-device-info.d.ts +1 -1
- package/dist/adapter/device-helpers/get-device-info.d.ts.map +1 -1
- package/dist/adapter/device-helpers/get-device-info.js +9 -11
- package/dist/adapter/device-helpers/get-device-info.js.map +1 -1
- package/dist/adapter/device-helpers/is-old-ie.d.ts.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/decode-webgl-types.d.ts +26 -0
- package/dist/adapter/helpers/decode-webgl-types.d.ts.map +1 -0
- package/dist/adapter/helpers/{uniforms.js → decode-webgl-types.js} +20 -29
- package/dist/adapter/helpers/decode-webgl-types.js.map +1 -0
- 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 -48
- package/dist/adapter/helpers/get-shader-layout.d.ts.map +1 -1
- package/dist/adapter/helpers/get-shader-layout.js +60 -115
- 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 +3 -2
- package/dist/adapter/helpers/set-uniform.d.ts.map +1 -1
- package/dist/adapter/helpers/set-uniform.js +27 -57
- package/dist/adapter/helpers/set-uniform.js.map +1 -1
- package/dist/adapter/helpers/webgl-topology-utils.d.ts +11 -0
- package/dist/adapter/helpers/webgl-topology-utils.d.ts.map +1 -0
- package/dist/adapter/helpers/{attribute-utils.js → webgl-topology-utils.js} +2 -19
- package/dist/adapter/helpers/webgl-topology-utils.js.map +1 -0
- package/dist/adapter/objects/constants-to-keys.d.ts +1 -3
- package/dist/adapter/objects/constants-to-keys.d.ts.map +1 -1
- package/dist/adapter/objects/constants-to-keys.js +2 -29
- package/dist/adapter/objects/constants-to-keys.js.map +1 -1
- package/dist/adapter/objects/webgl-renderbuffer.d.ts +15 -12
- package/dist/adapter/objects/webgl-renderbuffer.d.ts.map +1 -1
- package/dist/adapter/objects/webgl-renderbuffer.js +34 -41
- package/dist/adapter/objects/webgl-renderbuffer.js.map +1 -1
- package/dist/adapter/objects/webgl-resource.d.ts +6 -9
- package/dist/adapter/objects/webgl-resource.d.ts.map +1 -1
- package/dist/adapter/objects/webgl-resource.js +26 -83
- package/dist/adapter/objects/webgl-resource.js.map +1 -1
- package/dist/adapter/resources/webgl-buffer.d.ts +18 -10
- package/dist/adapter/resources/webgl-buffer.d.ts.map +1 -1
- package/dist/adapter/resources/webgl-buffer.js +49 -78
- package/dist/adapter/resources/webgl-buffer.js.map +1 -1
- package/dist/adapter/resources/webgl-command-buffer.d.ts +15 -9
- package/dist/adapter/resources/webgl-command-buffer.d.ts.map +1 -1
- package/dist/adapter/resources/webgl-command-buffer.js +169 -43
- package/dist/adapter/resources/webgl-command-buffer.js.map +1 -1
- package/dist/adapter/resources/webgl-command-encoder.d.ts +7 -6
- package/dist/adapter/resources/webgl-command-encoder.d.ts.map +1 -1
- package/dist/adapter/resources/webgl-command-encoder.js +10 -20
- 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 +21 -24
- package/dist/adapter/resources/webgl-framebuffer.d.ts.map +1 -1
- package/dist/adapter/resources/webgl-framebuffer.js +46 -155
- package/dist/adapter/resources/webgl-framebuffer.js.map +1 -1
- package/dist/adapter/resources/webgl-render-pass.d.ts +19 -4
- package/dist/adapter/resources/webgl-render-pass.d.ts.map +1 -1
- package/dist/adapter/resources/webgl-render-pass.js +91 -11
- package/dist/adapter/resources/webgl-render-pass.js.map +1 -1
- package/dist/adapter/resources/webgl-render-pipeline.d.ts +53 -19
- package/dist/adapter/resources/webgl-render-pipeline.d.ts.map +1 -1
- package/dist/adapter/resources/webgl-render-pipeline.js +108 -230
- package/dist/adapter/resources/webgl-render-pipeline.js.map +1 -1
- package/dist/adapter/resources/webgl-sampler.d.ts +6 -5
- package/dist/adapter/resources/webgl-sampler.d.ts.map +1 -1
- package/dist/adapter/resources/webgl-sampler.js +10 -19
- 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 +19 -31
- package/dist/adapter/resources/webgl-shader.js.map +1 -1
- package/dist/adapter/resources/webgl-texture.d.ts +64 -44
- package/dist/adapter/resources/webgl-texture.d.ts.map +1 -1
- package/dist/adapter/resources/webgl-texture.js +119 -235
- package/dist/adapter/resources/webgl-texture.js.map +1 -1
- package/dist/adapter/resources/webgl-vertex-array.d.ts +67 -0
- package/dist/adapter/resources/webgl-vertex-array.d.ts.map +1 -0
- package/dist/adapter/resources/webgl-vertex-array.js +166 -0
- package/dist/adapter/resources/webgl-vertex-array.js.map +1 -0
- package/dist/adapter/webgl-canvas-context.d.ts +6 -7
- package/dist/adapter/webgl-canvas-context.d.ts.map +1 -1
- package/dist/adapter/webgl-canvas-context.js +10 -23
- package/dist/adapter/webgl-canvas-context.js.map +1 -1
- package/dist/adapter/webgl-device.d.ts +74 -41
- package/dist/adapter/webgl-device.d.ts.map +1 -1
- package/dist/adapter/webgl-device.js +214 -128
- package/dist/adapter/webgl-device.js.map +1 -1
- package/dist/classic/accessor.d.ts +3 -3
- package/dist/classic/accessor.d.ts.map +1 -1
- package/dist/classic/accessor.js +23 -48
- package/dist/classic/accessor.js.map +1 -1
- package/dist/classic/{buffer.d.ts → buffer-with-accessor.d.ts} +16 -29
- package/dist/classic/buffer-with-accessor.d.ts.map +1 -0
- package/dist/classic/{buffer.js → buffer-with-accessor.js} +55 -125
- package/dist/classic/buffer-with-accessor.js.map +1 -0
- package/dist/classic/clear.d.ts +22 -0
- package/dist/classic/clear.d.ts.map +1 -0
- package/dist/classic/clear.js +88 -0
- package/dist/classic/clear.js.map +1 -0
- package/dist/classic/copy-and-blit.d.ts +62 -0
- package/dist/classic/copy-and-blit.d.ts.map +1 -0
- package/dist/classic/copy-and-blit.js +200 -0
- package/dist/classic/copy-and-blit.js.map +1 -0
- package/dist/classic/format-utils.d.ts +3 -0
- package/dist/classic/format-utils.d.ts.map +1 -0
- package/dist/classic/format-utils.js +38 -0
- package/dist/classic/format-utils.js.map +1 -0
- package/dist/classic/typed-array-utils.d.ts +15 -17
- package/dist/classic/typed-array-utils.d.ts.map +1 -1
- package/dist/classic/typed-array-utils.js +1 -21
- package/dist/classic/typed-array-utils.js.map +1 -1
- package/dist/context/context/create-browser-context.d.ts +40 -0
- package/dist/context/context/create-browser-context.d.ts.map +1 -0
- package/dist/context/context/create-browser-context.js +53 -0
- 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.d.ts.map +1 -1
- package/dist/context/context/webgl-checks.js +1 -4
- package/dist/context/context/webgl-checks.js.map +1 -1
- package/dist/context/debug/spector.d.ts +1 -2
- package/dist/context/debug/spector.d.ts.map +1 -1
- package/dist/context/debug/spector.js +8 -20
- package/dist/context/debug/spector.js.map +1 -1
- package/dist/context/debug/webgl-developer-tools.d.ts +2 -2
- package/dist/context/debug/webgl-developer-tools.d.ts.map +1 -1
- package/dist/context/debug/webgl-developer-tools.js +16 -39
- package/dist/context/debug/webgl-developer-tools.js.map +1 -1
- package/dist/context/parameters/unified-parameter-api.d.ts +9 -8
- package/dist/context/parameters/unified-parameter-api.d.ts.map +1 -1
- package/dist/context/parameters/unified-parameter-api.js +9 -19
- package/dist/context/parameters/unified-parameter-api.js.map +1 -1
- package/dist/context/parameters/webgl-parameter-tables.d.ts +105 -106
- package/dist/context/parameters/webgl-parameter-tables.d.ts.map +1 -1
- package/dist/context/parameters/webgl-parameter-tables.js +18 -36
- 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 +4 -9
- package/dist/context/polyfill/get-parameter-polyfill.js.map +1 -1
- package/dist/context/polyfill/polyfill-context.d.ts.map +1 -1
- package/dist/context/polyfill/polyfill-context.js +22 -30
- 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 +10 -32
- 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.d.ts.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 +26 -62
- 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 +8 -10
- package/dist/context/state-tracker/with-parameters.js.map +1 -1
- package/dist/dist.dev.js +10391 -0
- package/dist/index.cjs +6625 -0
- package/dist/index.d.ts +27 -24
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +27 -26
- package/dist/index.js.map +1 -1
- package/dist/types.d.ts +3 -1
- package/dist/types.d.ts.map +1 -1
- package/dist/types.js.map +1 -1
- package/dist.min.js +37 -0
- package/package.json +21 -9
- package/src/adapter/converters/device-parameters.ts +124 -36
- package/src/adapter/converters/sampler-parameters.ts +22 -9
- package/src/adapter/converters/shader-formats.ts +44 -0
- package/src/adapter/converters/texture-formats.ts +267 -194
- package/src/adapter/converters/vertex-formats.ts +71 -10
- package/src/adapter/device-helpers/device-features.ts +13 -3
- package/src/adapter/device-helpers/device-limits.ts +5 -3
- package/src/adapter/device-helpers/get-device-info.ts +17 -10
- package/src/adapter/device-helpers/is-old-ie.ts +3 -0
- package/src/adapter/helpers/{uniforms.ts → decode-webgl-types.ts} +39 -21
- package/src/adapter/helpers/get-shader-info.ts +41 -0
- package/src/adapter/helpers/get-shader-layout.ts +121 -146
- package/src/adapter/helpers/parse-shader-compiler-log.ts +4 -2
- package/src/adapter/helpers/set-uniform.ts +39 -35
- package/src/adapter/helpers/{attribute-utils.ts → webgl-topology-utils.ts} +7 -5
- package/src/adapter/objects/constants-to-keys.ts +6 -25
- package/src/adapter/objects/webgl-renderbuffer.ts +43 -37
- package/src/adapter/objects/webgl-resource.ts +16 -23
- package/src/adapter/resources/webgl-buffer.ts +59 -58
- package/src/adapter/resources/webgl-command-buffer.ts +333 -25
- package/src/adapter/resources/webgl-command-encoder.ts +20 -12
- package/src/adapter/resources/webgl-external-texture.ts +5 -2
- package/src/adapter/resources/webgl-framebuffer.ts +89 -133
- package/src/adapter/resources/webgl-render-pass.ts +160 -4
- package/src/adapter/resources/webgl-render-pipeline.ts +265 -170
- package/src/adapter/resources/webgl-sampler.ts +15 -9
- package/src/adapter/resources/webgl-shader.ts +14 -11
- package/src/adapter/resources/webgl-texture.ts +120 -90
- package/src/adapter/resources/webgl-vertex-array.ts +279 -0
- package/src/adapter/webgl-canvas-context.ts +16 -14
- package/src/adapter/webgl-device.ts +321 -78
- package/src/classic/accessor.ts +7 -17
- package/src/classic/{buffer.ts → buffer-with-accessor.ts} +68 -76
- package/src/classic/clear.ts +113 -0
- package/src/classic/copy-and-blit.ts +314 -0
- package/src/classic/format-utils.ts +46 -0
- package/src/classic/typed-array-utils.ts +19 -27
- package/src/context/context/create-browser-context.ts +140 -0
- package/src/context/context/create-headless-context.ts +51 -0
- package/src/context/context/webgl-checks.ts +3 -1
- package/src/context/debug/spector.ts +9 -6
- package/src/context/debug/webgl-developer-tools.ts +23 -15
- package/src/context/parameters/unified-parameter-api.ts +23 -14
- package/src/context/parameters/webgl-parameter-tables.ts +120 -98
- package/src/context/polyfill/context-data.ts +30 -0
- package/src/context/polyfill/get-parameter-polyfill.ts +11 -7
- package/src/context/polyfill/polyfill-context.ts +10 -9
- package/src/context/polyfill/polyfill-table.ts +21 -16
- package/src/context/polyfill/polyfill-vertex-array-object.ts +5 -0
- package/src/context/state-tracker/deep-array-equal.ts +2 -0
- package/src/context/state-tracker/track-context-state.ts +20 -16
- package/src/context/state-tracker/with-parameters.ts +13 -4
- package/src/index.ts +69 -35
- package/src/types.ts +5 -0
- package/dist/adapter/converters/renderbuffer-formats.d.ts +0 -16
- package/dist/adapter/converters/renderbuffer-formats.d.ts.map +0 -1
- package/dist/adapter/converters/renderbuffer-formats.js +0 -185
- package/dist/adapter/converters/renderbuffer-formats.js.map +0 -1
- package/dist/adapter/helpers/attribute-utils.d.ts +0 -11
- package/dist/adapter/helpers/attribute-utils.d.ts.map +0 -1
- package/dist/adapter/helpers/attribute-utils.js.map +0 -1
- package/dist/adapter/helpers/uniforms.d.ts +0 -26
- package/dist/adapter/helpers/uniforms.d.ts.map +0 -1
- package/dist/adapter/helpers/uniforms.js.map +0 -1
- package/dist/adapter/objects/webgl-vertex-array-object.d.ts +0 -27
- package/dist/adapter/objects/webgl-vertex-array-object.d.ts.map +0 -1
- package/dist/adapter/objects/webgl-vertex-array-object.js +0 -84
- package/dist/adapter/objects/webgl-vertex-array-object.js.map +0 -1
- 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/classic/buffer.d.ts.map +0 -1
- package/dist/classic/buffer.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 +0 -41
- package/dist/context/context/create-context.d.ts.map +0 -1
- package/dist/context/context/create-context.js +0 -49
- 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/dist/types/webgl.d.ts +0 -144
- package/dist/types/webgl.d.ts.map +0 -1
- package/dist/types/webgl.js +0 -2
- package/dist/types/webgl.js.map +0 -1
- package/src/adapter/converters/renderbuffer-formats.ts +0 -92
- package/src/adapter/objects/webgl-vertex-array-object.ts +0 -111
- package/src/bundle.ts +0 -4
- package/src/context/context/context-state.ts +0 -41
- package/src/context/context/create-context.ts +0 -110
- package/src/context/context/device-pixels.ts +0 -152
- package/src/init.ts +0 -4
- package/src/types/webgl.ts +0 -283
|
@@ -0,0 +1,200 @@
|
|
|
1
|
+
import { assert, Texture, Framebuffer } from '@luma.gl/core';
|
|
2
|
+
import { GL } from '@luma.gl/constants';
|
|
3
|
+
import { BufferWithAccessor as Buffer } from "./buffer-with-accessor.js";
|
|
4
|
+
import { withGLParameters } from "../context/state-tracker/with-parameters.js";
|
|
5
|
+
import { getGLTypeFromTypedArray, getTypedArrayFromGLType } from "./typed-array-utils.js";
|
|
6
|
+
import { glFormatToComponents, glTypeToBytes } from "./format-utils.js";
|
|
7
|
+
export function readPixelsToArray(source, options) {
|
|
8
|
+
var _framebuffer$colorAtt;
|
|
9
|
+
const {
|
|
10
|
+
sourceX = 0,
|
|
11
|
+
sourceY = 0,
|
|
12
|
+
sourceFormat = GL.RGBA,
|
|
13
|
+
sourceAttachment = GL.COLOR_ATTACHMENT0
|
|
14
|
+
} = options || {};
|
|
15
|
+
let {
|
|
16
|
+
target = null,
|
|
17
|
+
sourceWidth,
|
|
18
|
+
sourceHeight,
|
|
19
|
+
sourceType
|
|
20
|
+
} = options || {};
|
|
21
|
+
const {
|
|
22
|
+
framebuffer,
|
|
23
|
+
deleteFramebuffer
|
|
24
|
+
} = getFramebuffer(source);
|
|
25
|
+
assert(framebuffer);
|
|
26
|
+
const {
|
|
27
|
+
gl,
|
|
28
|
+
handle
|
|
29
|
+
} = framebuffer;
|
|
30
|
+
sourceWidth = sourceWidth || framebuffer.width;
|
|
31
|
+
sourceHeight = sourceHeight || framebuffer.height;
|
|
32
|
+
const attachment = sourceAttachment - GL.COLOR_ATTACHMENT0;
|
|
33
|
+
sourceType = sourceType || ((_framebuffer$colorAtt = framebuffer.colorAttachments[attachment]) === null || _framebuffer$colorAtt === void 0 ? void 0 : _framebuffer$colorAtt.type) || GL.UNSIGNED_BYTE;
|
|
34
|
+
target = getPixelArray(target, sourceType, sourceFormat, sourceWidth, sourceHeight);
|
|
35
|
+
sourceType = sourceType || getGLTypeFromTypedArray(target);
|
|
36
|
+
const prevHandle = gl.bindFramebuffer(GL.FRAMEBUFFER, handle);
|
|
37
|
+
gl.readPixels(sourceX, sourceY, sourceWidth, sourceHeight, sourceFormat, sourceType, target);
|
|
38
|
+
gl.bindFramebuffer(GL.FRAMEBUFFER, prevHandle || null);
|
|
39
|
+
if (deleteFramebuffer) {
|
|
40
|
+
framebuffer.destroy();
|
|
41
|
+
}
|
|
42
|
+
return target;
|
|
43
|
+
}
|
|
44
|
+
export function readPixelsToBuffer(source, options) {
|
|
45
|
+
const {
|
|
46
|
+
sourceX = 0,
|
|
47
|
+
sourceY = 0,
|
|
48
|
+
sourceFormat = GL.RGBA,
|
|
49
|
+
targetByteOffset = 0
|
|
50
|
+
} = options || {};
|
|
51
|
+
let {
|
|
52
|
+
target,
|
|
53
|
+
sourceWidth,
|
|
54
|
+
sourceHeight,
|
|
55
|
+
sourceType
|
|
56
|
+
} = options || {};
|
|
57
|
+
const {
|
|
58
|
+
framebuffer,
|
|
59
|
+
deleteFramebuffer
|
|
60
|
+
} = getFramebuffer(source);
|
|
61
|
+
assert(framebuffer);
|
|
62
|
+
sourceWidth = sourceWidth || framebuffer.width;
|
|
63
|
+
sourceHeight = sourceHeight || framebuffer.height;
|
|
64
|
+
const webglFramebuffer = framebuffer;
|
|
65
|
+
const gl2 = webglFramebuffer.device.assertWebGL2();
|
|
66
|
+
sourceType = sourceType || (target ? target.type : GL.UNSIGNED_BYTE);
|
|
67
|
+
if (!target) {
|
|
68
|
+
const components = glFormatToComponents(sourceFormat);
|
|
69
|
+
const byteCount = glTypeToBytes(sourceType);
|
|
70
|
+
const byteLength = targetByteOffset + sourceWidth * sourceHeight * components * byteCount;
|
|
71
|
+
target = new Buffer(gl2, {
|
|
72
|
+
byteLength,
|
|
73
|
+
accessor: {
|
|
74
|
+
type: sourceType,
|
|
75
|
+
size: components
|
|
76
|
+
}
|
|
77
|
+
});
|
|
78
|
+
}
|
|
79
|
+
target.bind({
|
|
80
|
+
glTarget: GL.PIXEL_PACK_BUFFER
|
|
81
|
+
});
|
|
82
|
+
withGLParameters(gl2, {
|
|
83
|
+
framebuffer
|
|
84
|
+
}, () => {
|
|
85
|
+
gl2.readPixels(sourceX, sourceY, sourceWidth, sourceHeight, sourceFormat, sourceType, targetByteOffset);
|
|
86
|
+
});
|
|
87
|
+
target.unbind({
|
|
88
|
+
glTarget: GL.PIXEL_PACK_BUFFER
|
|
89
|
+
});
|
|
90
|
+
if (deleteFramebuffer) {
|
|
91
|
+
framebuffer.destroy();
|
|
92
|
+
}
|
|
93
|
+
return target;
|
|
94
|
+
}
|
|
95
|
+
export function copyToTexture(source, target, options) {
|
|
96
|
+
const {
|
|
97
|
+
sourceX = 0,
|
|
98
|
+
sourceY = 0,
|
|
99
|
+
targetMipmaplevel = 0,
|
|
100
|
+
targetInternalFormat = GL.RGBA
|
|
101
|
+
} = options || {};
|
|
102
|
+
let {
|
|
103
|
+
targetX,
|
|
104
|
+
targetY,
|
|
105
|
+
targetZ,
|
|
106
|
+
width,
|
|
107
|
+
height
|
|
108
|
+
} = options || {};
|
|
109
|
+
const {
|
|
110
|
+
framebuffer,
|
|
111
|
+
deleteFramebuffer
|
|
112
|
+
} = getFramebuffer(source);
|
|
113
|
+
assert(framebuffer);
|
|
114
|
+
const webglFramebuffer = framebuffer;
|
|
115
|
+
const {
|
|
116
|
+
device,
|
|
117
|
+
handle
|
|
118
|
+
} = webglFramebuffer;
|
|
119
|
+
const isSubCopy = typeof targetX !== 'undefined' || typeof targetY !== 'undefined' || typeof targetZ !== 'undefined';
|
|
120
|
+
targetX = targetX || 0;
|
|
121
|
+
targetY = targetY || 0;
|
|
122
|
+
targetZ = targetZ || 0;
|
|
123
|
+
const prevHandle = device.gl.bindFramebuffer(GL.FRAMEBUFFER, handle);
|
|
124
|
+
assert(target);
|
|
125
|
+
let texture = null;
|
|
126
|
+
let textureTarget;
|
|
127
|
+
if (target instanceof Texture) {
|
|
128
|
+
texture = target;
|
|
129
|
+
width = Number.isFinite(width) ? width : texture.width;
|
|
130
|
+
height = Number.isFinite(height) ? height : texture.height;
|
|
131
|
+
texture.bind(0);
|
|
132
|
+
textureTarget = texture.target;
|
|
133
|
+
} else {
|
|
134
|
+
textureTarget = target;
|
|
135
|
+
}
|
|
136
|
+
if (!isSubCopy) {
|
|
137
|
+
device.gl.copyTexImage2D(textureTarget, targetMipmaplevel, targetInternalFormat, sourceX, sourceY, width, height, 0);
|
|
138
|
+
} else {
|
|
139
|
+
switch (textureTarget) {
|
|
140
|
+
case GL.TEXTURE_2D:
|
|
141
|
+
case GL.TEXTURE_CUBE_MAP:
|
|
142
|
+
device.gl.copyTexSubImage2D(textureTarget, targetMipmaplevel, targetX, targetY, sourceX, sourceY, width, height);
|
|
143
|
+
break;
|
|
144
|
+
case GL.TEXTURE_2D_ARRAY:
|
|
145
|
+
case GL.TEXTURE_3D:
|
|
146
|
+
device.assertWebGL2();
|
|
147
|
+
device.gl2.copyTexSubImage3D(textureTarget, targetMipmaplevel, targetX, targetY, targetZ, sourceX, sourceY, width, height);
|
|
148
|
+
break;
|
|
149
|
+
default:
|
|
150
|
+
}
|
|
151
|
+
}
|
|
152
|
+
if (texture) {
|
|
153
|
+
texture.unbind();
|
|
154
|
+
}
|
|
155
|
+
device.gl.bindFramebuffer(GL.FRAMEBUFFER, prevHandle || null);
|
|
156
|
+
if (deleteFramebuffer) {
|
|
157
|
+
framebuffer.destroy();
|
|
158
|
+
}
|
|
159
|
+
return texture;
|
|
160
|
+
}
|
|
161
|
+
function getFramebuffer(source) {
|
|
162
|
+
if (!(source instanceof Framebuffer)) {
|
|
163
|
+
return {
|
|
164
|
+
framebuffer: toFramebuffer(source),
|
|
165
|
+
deleteFramebuffer: true
|
|
166
|
+
};
|
|
167
|
+
}
|
|
168
|
+
return {
|
|
169
|
+
framebuffer: source,
|
|
170
|
+
deleteFramebuffer: false
|
|
171
|
+
};
|
|
172
|
+
}
|
|
173
|
+
export function toFramebuffer(texture, props) {
|
|
174
|
+
const {
|
|
175
|
+
device,
|
|
176
|
+
width,
|
|
177
|
+
height,
|
|
178
|
+
id
|
|
179
|
+
} = texture;
|
|
180
|
+
const framebuffer = device.createFramebuffer({
|
|
181
|
+
...props,
|
|
182
|
+
id: `framebuffer-for-${id}`,
|
|
183
|
+
width,
|
|
184
|
+
height,
|
|
185
|
+
colorAttachments: [texture]
|
|
186
|
+
});
|
|
187
|
+
return framebuffer;
|
|
188
|
+
}
|
|
189
|
+
function getPixelArray(pixelArray, type, format, width, height) {
|
|
190
|
+
if (pixelArray) {
|
|
191
|
+
return pixelArray;
|
|
192
|
+
}
|
|
193
|
+
type = type || GL.UNSIGNED_BYTE;
|
|
194
|
+
const ArrayType = getTypedArrayFromGLType(type, {
|
|
195
|
+
clamped: false
|
|
196
|
+
});
|
|
197
|
+
const components = glFormatToComponents(format);
|
|
198
|
+
return new ArrayType(width * height * components);
|
|
199
|
+
}
|
|
200
|
+
//# sourceMappingURL=copy-and-blit.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"copy-and-blit.js","names":["assert","Texture","Framebuffer","GL","BufferWithAccessor","Buffer","withGLParameters","getGLTypeFromTypedArray","getTypedArrayFromGLType","glFormatToComponents","glTypeToBytes","readPixelsToArray","source","options","_framebuffer$colorAtt","sourceX","sourceY","sourceFormat","RGBA","sourceAttachment","COLOR_ATTACHMENT0","target","sourceWidth","sourceHeight","sourceType","framebuffer","deleteFramebuffer","getFramebuffer","gl","handle","width","height","attachment","colorAttachments","type","UNSIGNED_BYTE","getPixelArray","prevHandle","bindFramebuffer","FRAMEBUFFER","readPixels","destroy","readPixelsToBuffer","targetByteOffset","webglFramebuffer","gl2","device","assertWebGL2","components","byteCount","byteLength","accessor","size","bind","glTarget","PIXEL_PACK_BUFFER","unbind","copyToTexture","targetMipmaplevel","targetInternalFormat","targetX","targetY","targetZ","isSubCopy","texture","textureTarget","Number","isFinite","copyTexImage2D","TEXTURE_2D","TEXTURE_CUBE_MAP","copyTexSubImage2D","TEXTURE_2D_ARRAY","TEXTURE_3D","copyTexSubImage3D","toFramebuffer","props","id","createFramebuffer","pixelArray","format","ArrayType","clamped"],"sources":["../../src/classic/copy-and-blit.ts"],"sourcesContent":["// luma.gl, MIT license\n// Copyright (c) vis.gl contributors\n\nimport {assert, Texture, Framebuffer, FramebufferProps} from '@luma.gl/core';\nimport {GL} from '@luma.gl/constants';\n\nimport {BufferWithAccessor as Buffer} from './buffer-with-accessor';\nimport {WEBGLTexture} from '../adapter/resources/webgl-texture';\nimport {WEBGLFramebuffer} from '../adapter/resources/webgl-framebuffer';\nimport {withGLParameters} from '../context/state-tracker/with-parameters';\nimport {getGLTypeFromTypedArray, getTypedArrayFromGLType} from './typed-array-utils';\nimport {glFormatToComponents, glTypeToBytes} from './format-utils';\n\n/**\n * Copies data from a type or a Texture object into ArrayBuffer object.\n * App can provide targetPixelArray or have it auto allocated by this method\n * newly allocated by this method unless provided by app.\n * @deprecated Use CommandEncoder.copyTextureToBuffer and Buffer.read\n * @note Slow requires roundtrip to GPU\n *\n * @param source\n * @param options\n * @returns pixel array,\n */\nexport function readPixelsToArray(\n source: Framebuffer | Texture,\n options?: {\n sourceX?: number;\n sourceY?: number;\n sourceFormat?: number;\n sourceAttachment?: number;\n target?: Uint8Array | Uint16Array | Float32Array;\n // following parameters are auto deduced if not provided\n sourceWidth?: number;\n sourceHeight?: number;\n sourceType?: number;\n }\n): Uint8Array | Uint16Array | Float32Array {\n const {\n sourceX = 0,\n sourceY = 0,\n sourceFormat = GL.RGBA,\n sourceAttachment = GL.COLOR_ATTACHMENT0 // TODO - support gl.readBuffer\n } = options || {};\n let {\n target = null,\n // following parameters are auto deduced if not provided\n sourceWidth,\n sourceHeight,\n sourceType\n } = options || {};\n\n const {framebuffer, deleteFramebuffer} = getFramebuffer(source);\n assert(framebuffer);\n const {gl, handle} = framebuffer as WEBGLFramebuffer;\n sourceWidth = sourceWidth || framebuffer.width;\n sourceHeight = sourceHeight || framebuffer.height;\n\n // TODO - Set and unset gl.readBuffer\n // if (sourceAttachment === GL.COLOR_ATTACHMENT0 && handle === null) {\n // sourceAttachment = GL.FRONT;\n // }\n\n const attachment = sourceAttachment - GL.COLOR_ATTACHMENT0;\n // assert(attachments[sourceAttachment]);\n\n // Deduce the type from color attachment if not provided.\n sourceType =\n sourceType ||\n (framebuffer.colorAttachments[attachment] as WEBGLTexture)?.type ||\n GL.UNSIGNED_BYTE;\n\n // Deduce type and allocated pixelArray if needed\n target = getPixelArray(target, sourceType, sourceFormat, sourceWidth, sourceHeight);\n\n // Pixel array available, if necessary, deduce type from it.\n sourceType = sourceType || getGLTypeFromTypedArray(target);\n\n const prevHandle = gl.bindFramebuffer(GL.FRAMEBUFFER, handle);\n gl.readPixels(sourceX, sourceY, sourceWidth, sourceHeight, sourceFormat, sourceType, target);\n // @ts-expect-error\n gl.bindFramebuffer(GL.FRAMEBUFFER, prevHandle || null);\n if (deleteFramebuffer) {\n framebuffer.destroy();\n }\n return target;\n}\n\n/**\n * Copies data from a Framebuffer or a Texture object into a Buffer object.\n * NOTE: doesn't wait for copy to be complete, it programs GPU to perform a DMA transffer.\n * @deprecated Use CommandEncoder\n * @param source\n * @param options\n */\nexport function readPixelsToBuffer(\n source: Framebuffer | Texture,\n options?: {\n sourceX?: number;\n sourceY?: number;\n sourceFormat?: number;\n target?: Buffer; // A new Buffer object is created when not provided.\n targetByteOffset?: number; // byte offset in buffer object\n // following parameters are auto deduced if not provided\n sourceWidth?: number;\n sourceHeight?: number;\n sourceType?: number;\n }\n): Buffer {\n const {sourceX = 0, sourceY = 0, sourceFormat = GL.RGBA, targetByteOffset = 0} = options || {};\n // following parameters are auto deduced if not provided\n let {target, sourceWidth, sourceHeight, sourceType} = options || {};\n const {framebuffer, deleteFramebuffer} = getFramebuffer(source);\n assert(framebuffer);\n sourceWidth = sourceWidth || framebuffer.width;\n sourceHeight = sourceHeight || framebuffer.height;\n\n // Asynchronous read (PIXEL_PACK_BUFFER) is WebGL2 only feature\n const webglFramebuffer = framebuffer as WEBGLFramebuffer;\n const gl2 = webglFramebuffer.device.assertWebGL2();\n\n // deduce type if not available.\n sourceType = sourceType || (target ? target.type : GL.UNSIGNED_BYTE);\n\n if (!target) {\n // Create new buffer with enough size\n const components = glFormatToComponents(sourceFormat);\n const byteCount = glTypeToBytes(sourceType);\n const byteLength = targetByteOffset + sourceWidth * sourceHeight * components * byteCount;\n target = new Buffer(gl2, {byteLength, accessor: {type: sourceType, size: components}});\n }\n\n target.bind({glTarget: GL.PIXEL_PACK_BUFFER});\n withGLParameters(gl2, {framebuffer}, () => {\n gl2.readPixels(\n sourceX,\n sourceY,\n sourceWidth,\n sourceHeight,\n sourceFormat,\n sourceType,\n targetByteOffset\n );\n });\n target.unbind({glTarget: GL.PIXEL_PACK_BUFFER});\n if (deleteFramebuffer) {\n framebuffer.destroy();\n }\n\n return target;\n}\n\n/**\n * Copy a rectangle from a Framebuffer or Texture object into a texture (at an offset)\n * @deprecated Use CommandEncoder\n */\n// eslint-disable-next-line complexity, max-statements\nexport function copyToTexture(\n source: Framebuffer | Texture,\n target: Texture | GL,\n options?: {\n sourceX?: number;\n sourceY?: number;\n\n targetX?: number;\n targetY?: number;\n targetZ?: number;\n targetMipmaplevel?: number;\n targetInternalFormat?: number;\n\n width?: number; // defaults to target width\n height?: number; // defaults to target height\n }\n): Texture {\n const {\n sourceX = 0,\n sourceY = 0,\n // attachment = GL.COLOR_ATTACHMENT0, // TODO - support gl.readBuffer\n targetMipmaplevel = 0,\n targetInternalFormat = GL.RGBA\n } = options || {};\n let {\n targetX,\n targetY,\n targetZ,\n width, // defaults to target width\n height // defaults to target height\n } = options || {};\n\n const {framebuffer, deleteFramebuffer} = getFramebuffer(source);\n assert(framebuffer);\n const webglFramebuffer = framebuffer as WEBGLFramebuffer;\n const {device, handle} = webglFramebuffer;\n const isSubCopy =\n typeof targetX !== 'undefined' ||\n typeof targetY !== 'undefined' ||\n typeof targetZ !== 'undefined';\n targetX = targetX || 0;\n targetY = targetY || 0;\n targetZ = targetZ || 0;\n const prevHandle = device.gl.bindFramebuffer(GL.FRAMEBUFFER, handle);\n // TODO - support gl.readBuffer (WebGL2 only)\n // const prevBuffer = gl.readBuffer(attachment);\n assert(target);\n let texture = null;\n let textureTarget: GL;\n if (target instanceof Texture) {\n texture = target;\n width = Number.isFinite(width) ? width : texture.width;\n height = Number.isFinite(height) ? height : texture.height;\n texture.bind(0);\n textureTarget = texture.target;\n } else {\n textureTarget = target;\n }\n\n if (!isSubCopy) {\n device.gl.copyTexImage2D(\n textureTarget,\n targetMipmaplevel,\n targetInternalFormat,\n sourceX,\n sourceY,\n width,\n height,\n 0 /* border must be 0 */\n );\n } else {\n switch (textureTarget) {\n case GL.TEXTURE_2D:\n case GL.TEXTURE_CUBE_MAP:\n device.gl.copyTexSubImage2D(\n textureTarget,\n targetMipmaplevel,\n targetX,\n targetY,\n sourceX,\n sourceY,\n width,\n height\n );\n break;\n case GL.TEXTURE_2D_ARRAY:\n case GL.TEXTURE_3D:\n device.assertWebGL2();\n device.gl2.copyTexSubImage3D(\n textureTarget,\n targetMipmaplevel,\n targetX,\n targetY,\n targetZ,\n sourceX,\n sourceY,\n width,\n height\n );\n break;\n default:\n }\n }\n if (texture) {\n texture.unbind();\n }\n // @ts-expect-error\n device.gl.bindFramebuffer(GL.FRAMEBUFFER, prevHandle || null);\n if (deleteFramebuffer) {\n framebuffer.destroy();\n }\n return texture;\n}\n\nfunction getFramebuffer(source: Texture | Framebuffer): {\n framebuffer: Framebuffer;\n deleteFramebuffer: boolean;\n} {\n if (!(source instanceof Framebuffer)) {\n return {framebuffer: toFramebuffer(source), deleteFramebuffer: true};\n }\n return {framebuffer: source, deleteFramebuffer: false};\n}\n\n/**\n * Wraps a given texture into a framebuffer object, that can be further used\n * to read data from the texture object.\n */\nexport function toFramebuffer(texture: Texture, props?: FramebufferProps): Framebuffer {\n const {device, width, height, id} = texture;\n const framebuffer = device.createFramebuffer({\n ...props,\n id: `framebuffer-for-${id}`,\n width,\n height,\n colorAttachments: [texture]\n });\n return framebuffer;\n}\n\nfunction getPixelArray(\n pixelArray,\n type,\n format,\n width: number,\n height: number\n): Uint8Array | Uint16Array | Float32Array {\n if (pixelArray) {\n return pixelArray;\n }\n // Allocate pixel array if not already available, using supplied type\n type = type || GL.UNSIGNED_BYTE;\n const ArrayType = getTypedArrayFromGLType(type, {clamped: false});\n const components = glFormatToComponents(format);\n // TODO - check for composite type (components = 1).\n return new ArrayType(width * height * components) as Uint8Array | Uint16Array | Float32Array;\n}\n"],"mappings":"AAGA,SAAQA,MAAM,EAAEC,OAAO,EAAEC,WAAW,QAAyB,eAAe;AAC5E,SAAQC,EAAE,QAAO,oBAAoB;AAAC,SAE9BC,kBAAkB,IAAIC,MAAM;AAAA,SAG5BC,gBAAgB;AAAA,SAChBC,uBAAuB,EAAEC,uBAAuB;AAAA,SAChDC,oBAAoB,EAAEC,aAAa;AAa3C,OAAO,SAASC,iBAAiBA,CAC/BC,MAA6B,EAC7BC,OAUC,EACwC;EAAA,IAAAC,qBAAA;EACzC,MAAM;IACJC,OAAO,GAAG,CAAC;IACXC,OAAO,GAAG,CAAC;IACXC,YAAY,GAAGd,EAAE,CAACe,IAAI;IACtBC,gBAAgB,GAAGhB,EAAE,CAACiB;EACxB,CAAC,GAAGP,OAAO,IAAI,CAAC,CAAC;EACjB,IAAI;IACFQ,MAAM,GAAG,IAAI;IAEbC,WAAW;IACXC,YAAY;IACZC;EACF,CAAC,GAAGX,OAAO,IAAI,CAAC,CAAC;EAEjB,MAAM;IAACY,WAAW;IAAEC;EAAiB,CAAC,GAAGC,cAAc,CAACf,MAAM,CAAC;EAC/DZ,MAAM,CAACyB,WAAW,CAAC;EACnB,MAAM;IAACG,EAAE;IAAEC;EAAM,CAAC,GAAGJ,WAA+B;EACpDH,WAAW,GAAGA,WAAW,IAAIG,WAAW,CAACK,KAAK;EAC9CP,YAAY,GAAGA,YAAY,IAAIE,WAAW,CAACM,MAAM;EAOjD,MAAMC,UAAU,GAAGb,gBAAgB,GAAGhB,EAAE,CAACiB,iBAAiB;EAI1DI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CAAC;EACtE;EACA,OAAO;IAACD,WAAW,EAAEb,MAAM;IAAEc,iBAAiB,EAAE;EAAK,CAAC;AACxD;AAMA,OAAO,SAASiD,aAAaA,CAACX,OAAgB,EAAEY,KAAwB,EAAe;EACrF,MAAM;IAAC9B,MAAM;IAAEhB,KAAK;IAAEC,MAAM;IAAE8C;EAAE,CAAC,GAAGb,OAAO;EAC3C,MAAMvC,WAAW,GAAGqB,MAAM,CAACgC,iBAAiB,CAAC;IAC3C,GAAGF,KAAK;IACRC,EAAE,EAAG,mBAAkBA,EAAG,EAAC;IAC3B/C,KAAK;IACLC,MAAM;IACNE,gBAAgB,EAAE,CAAC+B,OAAO;EAC5B,CAAC,CAAC;EACF,OAAOvC,WAAW;AACpB;AAEA,SAASW,aAAaA,CACpB2C,UAAU,EACV7C,IAAI,EACJ8C,MAAM,EACNlD,KAAa,EACbC,MAAc,EAC2B;EACzC,IAAIgD,UAAU,EAAE;IACd,OAAOA,UAAU;EACnB;EAEA7C,IAAI,GAAGA,IAAI,IAAI/B,EAAE,CAACgC,aAAa;EAC/B,MAAM8C,SAAS,GAAGzE,uBAAuB,CAAC0B,IAAI,EAAE;IAACgD,OAAO,EAAE;EAAK,CAAC,CAAC;EACjE,MAAMlC,UAAU,GAAGvC,oBAAoB,CAACuE,MAAM,CAAC;EAE/C,OAAO,IAAIC,SAAS,CAACnD,KAAK,GAAGC,MAAM,GAAGiB,UAAU,CAAC;AACnD"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"format-utils.d.ts","sourceRoot":"","sources":["../../src/classic/format-utils.ts"],"names":[],"mappings":"AAOA,wBAAgB,oBAAoB,CAAC,MAAM,KAAA,qBAoB1C;AAGD,wBAAgB,aAAa,CAAC,IAAI,KAAA,iBAejC"}
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import { assert } from '@luma.gl/core';
|
|
2
|
+
import { GL } from '@luma.gl/constants';
|
|
3
|
+
export function glFormatToComponents(format) {
|
|
4
|
+
switch (format) {
|
|
5
|
+
case GL.ALPHA:
|
|
6
|
+
case GL.R32F:
|
|
7
|
+
case GL.RED:
|
|
8
|
+
return 1;
|
|
9
|
+
case GL.RG32F:
|
|
10
|
+
case GL.RG:
|
|
11
|
+
return 2;
|
|
12
|
+
case GL.RGB:
|
|
13
|
+
case GL.RGB32F:
|
|
14
|
+
return 3;
|
|
15
|
+
case GL.RGBA:
|
|
16
|
+
case GL.RGBA32F:
|
|
17
|
+
return 4;
|
|
18
|
+
default:
|
|
19
|
+
assert(false);
|
|
20
|
+
return 0;
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
export function glTypeToBytes(type) {
|
|
24
|
+
switch (type) {
|
|
25
|
+
case GL.UNSIGNED_BYTE:
|
|
26
|
+
return 1;
|
|
27
|
+
case GL.UNSIGNED_SHORT_5_6_5:
|
|
28
|
+
case GL.UNSIGNED_SHORT_4_4_4_4:
|
|
29
|
+
case GL.UNSIGNED_SHORT_5_5_5_1:
|
|
30
|
+
return 2;
|
|
31
|
+
case GL.FLOAT:
|
|
32
|
+
return 4;
|
|
33
|
+
default:
|
|
34
|
+
assert(false);
|
|
35
|
+
return 0;
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
//# sourceMappingURL=format-utils.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"format-utils.js","names":["assert","GL","glFormatToComponents","format","ALPHA","R32F","RED","RG32F","RG","RGB","RGB32F","RGBA","RGBA32F","glTypeToBytes","type","UNSIGNED_BYTE","UNSIGNED_SHORT_5_6_5","UNSIGNED_SHORT_4_4_4_4","UNSIGNED_SHORT_5_5_5_1","FLOAT"],"sources":["../../src/classic/format-utils.ts"],"sourcesContent":["// luma.gl, MIT license\n// Copyright (c) vis.gl contributors\n\nimport {assert} from '@luma.gl/core';\nimport {GL} from '@luma.gl/constants';\n\n// Returns number of components in a specific readPixels WebGL format\nexport function glFormatToComponents(format) {\n switch (format) {\n case GL.ALPHA:\n case GL.R32F:\n case GL.RED:\n return 1;\n case GL.RG32F:\n case GL.RG:\n return 2;\n case GL.RGB:\n case GL.RGB32F:\n return 3;\n case GL.RGBA:\n case GL.RGBA32F:\n return 4;\n // TODO: Add support for additional WebGL2 formats\n default:\n assert(false);\n return 0;\n }\n}\n\n// Return byte count for given readPixels WebGL type\nexport function glTypeToBytes(type) {\n switch (type) {\n case GL.UNSIGNED_BYTE:\n return 1;\n case GL.UNSIGNED_SHORT_5_6_5:\n case GL.UNSIGNED_SHORT_4_4_4_4:\n case GL.UNSIGNED_SHORT_5_5_5_1:\n return 2;\n case GL.FLOAT:\n return 4;\n // TODO: Add support for additional WebGL2 types\n default:\n assert(false);\n return 0;\n }\n}\n"],"mappings":"AAGA,SAAQA,MAAM,QAAO,eAAe;AACpC,SAAQC,EAAE,QAAO,oBAAoB;AAGrC,OAAO,SAASC,oBAAoBA,CAACC,MAAM,EAAE;EAC3C,QAAQA,MAAM;IACZ,KAAKF,EAAE,CAACG,KAAK;IACb,KAAKH,EAAE,CAACI,IAAI;IACZ,KAAKJ,EAAE,CAACK,GAAG;MACT,OAAO,CAAC;IACV,KAAKL,EAAE,CAACM,KAAK;IACb,KAAKN,EAAE,CAACO,EAAE;MACR,OAAO,CAAC;IACV,KAAKP,EAAE,CAACQ,GAAG;IACX,KAAKR,EAAE,CAACS,MAAM;MACZ,OAAO,CAAC;IACV,KAAKT,EAAE,CAACU,IAAI;IACZ,KAAKV,EAAE,CAACW,OAAO;MACb,OAAO,CAAC;IAEV;MACEZ,MAAM,CAAC,KAAK,CAAC;MACb,OAAO,CAAC;EACZ;AACF;AAGA,OAAO,SAASa,aAAaA,CAACC,IAAI,EAAE;EAClC,QAAQA,IAAI;IACV,KAAKb,EAAE,CAACc,aAAa;MACnB,OAAO,CAAC;IACV,KAAKd,EAAE,CAACe,oBAAoB;IAC5B,KAAKf,EAAE,CAACgB,sBAAsB;IAC9B,KAAKhB,EAAE,CAACiB,sBAAsB;MAC5B,OAAO,CAAC;IACV,KAAKjB,EAAE,CAACkB,KAAK;MACX,OAAO,CAAC;IAEV;MACEnB,MAAM,CAAC,KAAK,CAAC;MACb,OAAO,CAAC;EACZ;AACF"}
|
|
@@ -1,44 +1,42 @@
|
|
|
1
|
-
import { TypedArray } from '@luma.gl/
|
|
2
|
-
import {
|
|
3
|
-
declare type TypedArrayConstructor = Float32ArrayConstructor | Uint16ArrayConstructor | Uint32ArrayConstructor | Uint8ArrayConstructor | Uint8ClampedArrayConstructor | Int8ArrayConstructor | Int16ArrayConstructor | Int32ArrayConstructor;
|
|
1
|
+
import { TypedArray, TypedArrayConstructor } from '@luma.gl/core';
|
|
2
|
+
import { GLDataType, GLPixelType } from '@luma.gl/constants';
|
|
4
3
|
/**
|
|
5
4
|
* Converts TYPED ARRAYS to corresponding GL constant
|
|
6
5
|
* Used to auto deduce gl parameter types
|
|
7
|
-
* @param
|
|
6
|
+
* @param arrayOrType
|
|
8
7
|
* @returns
|
|
9
8
|
*/
|
|
10
|
-
export declare function getGLTypeFromTypedArray(arrayOrType: TypedArray):
|
|
9
|
+
export declare function getGLTypeFromTypedArray(arrayOrType: TypedArray): GLDataType;
|
|
11
10
|
/**
|
|
12
11
|
* Converts GL constant to corresponding TYPED ARRAY
|
|
13
12
|
* Used to auto deduce gl parameter types
|
|
14
|
-
* @param
|
|
15
|
-
* @param
|
|
13
|
+
* @param glType
|
|
14
|
+
* @param param1
|
|
16
15
|
* @returns
|
|
17
16
|
*/
|
|
18
|
-
export declare function getTypedArrayFromGLType(glType:
|
|
17
|
+
export declare function getTypedArrayFromGLType(glType: GLDataType | GLPixelType, options?: {
|
|
19
18
|
clamped?: boolean;
|
|
20
19
|
}): TypedArrayConstructor;
|
|
21
20
|
/**
|
|
22
21
|
* Flip rows (can be used on arrays returned from `Framebuffer.readPixels`)
|
|
23
22
|
* https: *stackoverflow.com/questions/41969562/
|
|
24
23
|
* how-can-i-flip-the-result-of-webglrenderingcontext-readpixels
|
|
25
|
-
* @param
|
|
24
|
+
* @param param0
|
|
26
25
|
*/
|
|
27
26
|
export declare function flipRows(options: {
|
|
28
|
-
data:
|
|
29
|
-
width:
|
|
30
|
-
height:
|
|
27
|
+
data: TypedArray;
|
|
28
|
+
width: number;
|
|
29
|
+
height: number;
|
|
31
30
|
bytesPerPixel?: number;
|
|
32
|
-
temp?:
|
|
31
|
+
temp?: Uint8Array;
|
|
33
32
|
}): void;
|
|
34
33
|
export declare function scalePixels(options: {
|
|
35
|
-
data:
|
|
36
|
-
width:
|
|
37
|
-
height:
|
|
34
|
+
data: TypedArray;
|
|
35
|
+
width: number;
|
|
36
|
+
height: number;
|
|
38
37
|
}): {
|
|
39
38
|
data: Uint8Array;
|
|
40
39
|
width: number;
|
|
41
40
|
height: number;
|
|
42
41
|
};
|
|
43
|
-
export {};
|
|
44
42
|
//# sourceMappingURL=typed-array-utils.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"typed-array-utils.d.ts","sourceRoot":"","sources":["../../src/classic/typed-array-utils.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"typed-array-utils.d.ts","sourceRoot":"","sources":["../../src/classic/typed-array-utils.ts"],"names":[],"mappings":"AAGA,OAAO,EAAC,UAAU,EAAE,qBAAqB,EAAC,MAAM,eAAe,CAAC;AAChE,OAAO,EAAK,UAAU,EAAE,WAAW,EAAC,MAAM,oBAAoB,CAAC;AAI/D;;;;;GAKG;AACH,wBAAgB,uBAAuB,CAAC,WAAW,EAAE,UAAU,GAAG,UAAU,CAuB3E;AAED;;;;;;GAMG;AAEH,wBAAgB,uBAAuB,CACrC,MAAM,EAAE,UAAU,GAAG,WAAW,EAChC,OAAO,CAAC,EAAE;IACR,OAAO,CAAC,EAAE,OAAO,CAAC;CACnB,GACA,qBAAqB,CAwBvB;AAED;;;;;GAKG;AACH,wBAAgB,QAAQ,CAAC,OAAO,EAAE;IAChC,IAAI,EAAE,UAAU,CAAC;IACjB,KAAK,EAAE,MAAM,CAAC;IACd,MAAM,EAAE,MAAM,CAAC;IACf,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB,IAAI,CAAC,EAAE,UAAU,CAAC;CACnB,GAAG,IAAI,CAgBP;AAGD,wBAAgB,WAAW,CAAC,OAAO,EAAE;IACnC,IAAI,EAAE,UAAU,CAAC;IACjB,KAAK,EAAE,MAAM,CAAC;IACd,MAAM,EAAE,MAAM,CAAC;CAChB,GAAG;IACF,IAAI,EAAE,UAAU,CAAC;IACjB,KAAK,EAAE,MAAM,CAAC;IACd,MAAM,EAAE,MAAM,CAAC;CAChB,CAaA"}
|
|
@@ -1,33 +1,24 @@
|
|
|
1
|
-
import GL from '@luma.gl/constants';
|
|
1
|
+
import { GL } from '@luma.gl/constants';
|
|
2
2
|
const ERR_TYPE_DEDUCTION = 'Failed to deduce GL constant from typed array';
|
|
3
3
|
export function getGLTypeFromTypedArray(arrayOrType) {
|
|
4
4
|
const type = ArrayBuffer.isView(arrayOrType) ? arrayOrType.constructor : arrayOrType;
|
|
5
|
-
|
|
6
5
|
switch (type) {
|
|
7
6
|
case Float32Array:
|
|
8
7
|
return GL.FLOAT;
|
|
9
|
-
|
|
10
8
|
case Uint16Array:
|
|
11
9
|
return GL.UNSIGNED_SHORT;
|
|
12
|
-
|
|
13
10
|
case Uint32Array:
|
|
14
11
|
return GL.UNSIGNED_INT;
|
|
15
|
-
|
|
16
12
|
case Uint8Array:
|
|
17
13
|
return GL.UNSIGNED_BYTE;
|
|
18
|
-
|
|
19
14
|
case Uint8ClampedArray:
|
|
20
15
|
return GL.UNSIGNED_BYTE;
|
|
21
|
-
|
|
22
16
|
case Int8Array:
|
|
23
17
|
return GL.BYTE;
|
|
24
|
-
|
|
25
18
|
case Int16Array:
|
|
26
19
|
return GL.SHORT;
|
|
27
|
-
|
|
28
20
|
case Int32Array:
|
|
29
21
|
return GL.INT;
|
|
30
|
-
|
|
31
22
|
default:
|
|
32
23
|
throw new Error(ERR_TYPE_DEDUCTION);
|
|
33
24
|
}
|
|
@@ -36,32 +27,24 @@ export function getTypedArrayFromGLType(glType, options) {
|
|
|
36
27
|
const {
|
|
37
28
|
clamped = true
|
|
38
29
|
} = options || {};
|
|
39
|
-
|
|
40
30
|
switch (glType) {
|
|
41
31
|
case GL.FLOAT:
|
|
42
32
|
return Float32Array;
|
|
43
|
-
|
|
44
33
|
case GL.UNSIGNED_SHORT:
|
|
45
34
|
case GL.UNSIGNED_SHORT_5_6_5:
|
|
46
35
|
case GL.UNSIGNED_SHORT_4_4_4_4:
|
|
47
36
|
case GL.UNSIGNED_SHORT_5_5_5_1:
|
|
48
37
|
return Uint16Array;
|
|
49
|
-
|
|
50
38
|
case GL.UNSIGNED_INT:
|
|
51
39
|
return Uint32Array;
|
|
52
|
-
|
|
53
40
|
case GL.UNSIGNED_BYTE:
|
|
54
41
|
return clamped ? Uint8ClampedArray : Uint8Array;
|
|
55
|
-
|
|
56
42
|
case GL.BYTE:
|
|
57
43
|
return Int8Array;
|
|
58
|
-
|
|
59
44
|
case GL.SHORT:
|
|
60
45
|
return Int16Array;
|
|
61
|
-
|
|
62
46
|
case GL.INT:
|
|
63
47
|
return Int32Array;
|
|
64
|
-
|
|
65
48
|
default:
|
|
66
49
|
throw new Error('Failed to deduce typed array type from GL constant');
|
|
67
50
|
}
|
|
@@ -76,7 +59,6 @@ export function flipRows(options) {
|
|
|
76
59
|
} = options;
|
|
77
60
|
const bytesPerRow = width * bytesPerPixel;
|
|
78
61
|
const tempBuffer = temp || new Uint8Array(bytesPerRow);
|
|
79
|
-
|
|
80
62
|
for (let y = 0; y < height / 2; ++y) {
|
|
81
63
|
const topOffset = y * bytesPerRow;
|
|
82
64
|
const bottomOffset = (height - y - 1) * bytesPerRow;
|
|
@@ -94,7 +76,6 @@ export function scalePixels(options) {
|
|
|
94
76
|
const newWidth = Math.round(width / 2);
|
|
95
77
|
const newHeight = Math.round(height / 2);
|
|
96
78
|
const newData = new Uint8Array(newWidth * newHeight * 4);
|
|
97
|
-
|
|
98
79
|
for (let y = 0; y < newHeight; y++) {
|
|
99
80
|
for (let x = 0; x < newWidth; x++) {
|
|
100
81
|
for (let c = 0; c < 4; c++) {
|
|
@@ -102,7 +83,6 @@ export function scalePixels(options) {
|
|
|
102
83
|
}
|
|
103
84
|
}
|
|
104
85
|
}
|
|
105
|
-
|
|
106
86
|
return {
|
|
107
87
|
data: newData,
|
|
108
88
|
width: newWidth,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"
|
|
1
|
+
{"version":3,"file":"typed-array-utils.js","names":["GL","ERR_TYPE_DEDUCTION","getGLTypeFromTypedArray","arrayOrType","type","ArrayBuffer","isView","constructor","Float32Array","FLOAT","Uint16Array","UNSIGNED_SHORT","Uint32Array","UNSIGNED_INT","Uint8Array","UNSIGNED_BYTE","Uint8ClampedArray","Int8Array","BYTE","Int16Array","SHORT","Int32Array","INT","Error","getTypedArrayFromGLType","glType","options","clamped","UNSIGNED_SHORT_5_6_5","UNSIGNED_SHORT_4_4_4_4","UNSIGNED_SHORT_5_5_5_1","flipRows","data","width","height","bytesPerPixel","temp","bytesPerRow","tempBuffer","y","topOffset","bottomOffset","set","subarray","copyWithin","scalePixels","newWidth","Math","round","newHeight","newData","x","c"],"sources":["../../src/classic/typed-array-utils.ts"],"sourcesContent":["// luma.gl, MIT license\n// Copyright (c) vis.gl contributors\n\nimport {TypedArray, TypedArrayConstructor} from '@luma.gl/core';\nimport {GL, GLDataType, GLPixelType} from '@luma.gl/constants';\n\nconst ERR_TYPE_DEDUCTION = 'Failed to deduce GL constant from typed array';\n\n/**\n * Converts TYPED ARRAYS to corresponding GL constant\n * Used to auto deduce gl parameter types\n * @param arrayOrType\n * @returns\n */\nexport function getGLTypeFromTypedArray(arrayOrType: TypedArray): GLDataType {\n // If typed array, look up constructor\n const type = ArrayBuffer.isView(arrayOrType) ? arrayOrType.constructor : arrayOrType;\n switch (type) {\n case Float32Array:\n return GL.FLOAT;\n case Uint16Array:\n return GL.UNSIGNED_SHORT;\n case Uint32Array:\n return GL.UNSIGNED_INT;\n case Uint8Array:\n return GL.UNSIGNED_BYTE;\n case Uint8ClampedArray:\n return GL.UNSIGNED_BYTE;\n case Int8Array:\n return GL.BYTE;\n case Int16Array:\n return GL.SHORT;\n case Int32Array:\n return GL.INT;\n default:\n throw new Error(ERR_TYPE_DEDUCTION);\n }\n}\n\n/**\n * Converts GL constant to corresponding TYPED ARRAY\n * Used to auto deduce gl parameter types\n * @param glType\n * @param param1\n * @returns\n */\n// eslint-disable-next-line complexity\nexport function getTypedArrayFromGLType(\n glType: GLDataType | GLPixelType,\n options?: {\n clamped?: boolean;\n }\n): TypedArrayConstructor {\n const {clamped = true} = options || {};\n // Sorted in some order of likelihood to reduce amount of comparisons\n switch (glType) {\n case GL.FLOAT:\n return Float32Array;\n case GL.UNSIGNED_SHORT:\n case GL.UNSIGNED_SHORT_5_6_5:\n case GL.UNSIGNED_SHORT_4_4_4_4:\n case GL.UNSIGNED_SHORT_5_5_5_1:\n return Uint16Array;\n case GL.UNSIGNED_INT:\n return Uint32Array;\n case GL.UNSIGNED_BYTE:\n return clamped ? Uint8ClampedArray : Uint8Array;\n case GL.BYTE:\n return Int8Array;\n case GL.SHORT:\n return Int16Array;\n case GL.INT:\n return Int32Array;\n default:\n throw new Error('Failed to deduce typed array type from GL constant');\n }\n}\n\n/**\n * Flip rows (can be used on arrays returned from `Framebuffer.readPixels`)\n * https: *stackoverflow.com/questions/41969562/\n * how-can-i-flip-the-result-of-webglrenderingcontext-readpixels\n * @param param0\n */\nexport function flipRows(options: {\n data: TypedArray;\n width: number;\n height: number;\n bytesPerPixel?: number;\n temp?: Uint8Array;\n}): void {\n const {data, width, height, bytesPerPixel = 4, temp} = options;\n const bytesPerRow = width * bytesPerPixel;\n\n // make a temp buffer to hold one row\n const tempBuffer = temp || new Uint8Array(bytesPerRow);\n for (let y = 0; y < height / 2; ++y) {\n const topOffset = y * bytesPerRow;\n const bottomOffset = (height - y - 1) * bytesPerRow;\n // make copy of a row on the top half\n tempBuffer.set(data.subarray(topOffset, topOffset + bytesPerRow));\n // copy a row from the bottom half to the top\n data.copyWithin(topOffset, bottomOffset, bottomOffset + bytesPerRow);\n // copy the copy of the top half row to the bottom half\n data.set(tempBuffer, bottomOffset);\n }\n}\n\n\nexport function scalePixels(options: {\n data: TypedArray;\n width: number;\n height: number;\n}): {\n data: Uint8Array;\n width: number;\n height: number;\n} {\n const {data, width, height} = options;\n const newWidth = Math.round(width / 2);\n const newHeight = Math.round(height / 2);\n const newData = new Uint8Array(newWidth * newHeight * 4);\n for (let y = 0; y < newHeight; y++) {\n for (let x = 0; x < newWidth; x++) {\n for (let c = 0; c < 4; c++) {\n newData[(y * newWidth + x) * 4 + c] = data[(y * 2 * width + x * 2) * 4 + c];\n }\n }\n }\n return {data: newData, width: newWidth, height: newHeight};\n}\n"],"mappings":"AAIA,SAAQA,EAAE,QAAgC,oBAAoB;AAE9D,MAAMC,kBAAkB,GAAG,+CAA+C;AAQ1E,OAAO,SAASC,uBAAuBA,CAACC,WAAuB,EAAc;EAE3E,MAAMC,IAAI,GAAGC,WAAW,CAACC,MAAM,CAACH,WAAW,CAAC,GAAGA,WAAW,CAACI,WAAW,GAAGJ,WAAW;EACpF,QAAQC,IAAI;IACV,KAAKI,YAAY;MACf,OAAOR,EAAE,CAACS,KAAK;IACjB,KAAKC,WAAW;MACd,OAAOV,EAAE,CAACW,cAAc;IAC1B,KAAKC,WAAW;MACd,OAAOZ,EAAE,CAACa,YAAY;IACxB,KAAKC,UAAU;MACb,OAAOd,EAAE,CAACe,aAAa;IACzB,KAAKC,iBAAiB;MACpB,OAAOhB,EAAE,CAACe,aAAa;IACzB,KAAKE,SAAS;MACZ,OAAOjB,EAAE,CAACkB,IAAI;IAChB,KAAKC,UAAU;MACb,OAAOnB,EAAE,CAACoB,KAAK;IACjB,KAAKC,UAAU;MACb,OAAOrB,EAAE,CAACsB,GAAG;IACf;MACE,MAAM,IAAIC,KAAK,CAACtB,kBAAkB,CAAC;EACvC;AACF;AAUA,O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
|
|
2
|
+
* ContextProps
|
|
3
|
+
* @param webgl2 Set to false to not create a WebGL2 context (force webgl1)
|
|
4
|
+
* @param webgl1 set to false to not create a WebGL1 context (fail if webgl2 not available)
|
|
5
|
+
* @param onContextLost
|
|
6
|
+
* @param onContextRestored
|
|
7
|
+
*
|
|
8
|
+
* BROWSER CONTEXT PARAMETERS
|
|
9
|
+
* @param debug Instrument context (at the expense of performance).
|
|
10
|
+
* @param alpha Default render target has an alpha buffer.
|
|
11
|
+
* @param depth Default render target has a depth buffer of at least 16 bits.
|
|
12
|
+
* @param stencil Default render target has a stencil buffer of at least 8 bits.
|
|
13
|
+
* @param antialias Boolean that indicates whether or not to perform anti-aliasing.
|
|
14
|
+
* @param premultipliedAlpha Boolean that indicates that the page compositor will assume the drawing buffer contains colors with pre-multiplied alpha.
|
|
15
|
+
* @param preserveDrawingBuffer Default render target buffers will not be automatically cleared and will preserve their values until cleared or overwritten
|
|
16
|
+
* @param failIfMajorPerformanceCaveat Do not create if the system performance is low.
|
|
17
|
+
*/
|
|
18
|
+
type ContextProps = {
|
|
19
|
+
type?: 'webgl' | 'webgl1' | 'webgl2' | string;
|
|
20
|
+
webgl1?: boolean;
|
|
21
|
+
webgl2?: boolean;
|
|
22
|
+
onContextLost?: (event: Event) => void;
|
|
23
|
+
onContextRestored?: (event: Event) => void;
|
|
24
|
+
alpha?: boolean;
|
|
25
|
+
desynchronized?: boolean;
|
|
26
|
+
antialias?: boolean;
|
|
27
|
+
depth?: boolean;
|
|
28
|
+
failIfMajorPerformanceCaveat?: boolean;
|
|
29
|
+
powerPreference?: 'default' | 'high-performance' | 'low-power';
|
|
30
|
+
premultipliedAlpha?: boolean;
|
|
31
|
+
preserveDrawingBuffer?: boolean;
|
|
32
|
+
};
|
|
33
|
+
/**
|
|
34
|
+
* Create a WebGL context for a canvas
|
|
35
|
+
* Note calling this multiple time on the same canvas does return the same context
|
|
36
|
+
* @param canvas A canvas element or offscreen canvas
|
|
37
|
+
*/
|
|
38
|
+
export declare function createBrowserContext(canvas: HTMLCanvasElement | OffscreenCanvas, props: ContextProps): WebGLRenderingContext;
|
|
39
|
+
export {};
|
|
40
|
+
//# sourceMappingURL=create-browser-context.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"create-browser-context.d.ts","sourceRoot":"","sources":["../../../src/context/context/create-browser-context.ts"],"names":[],"mappings":"AAGA;;;;;;;;;;;;;;;;GAgBG;AACH,KAAK,YAAY,GAAG;IAClB,IAAI,CAAC,EAAE,OAAO,GAAG,QAAQ,GAAG,QAAQ,GAAG,MAAM,CAAC;IAC9C,MAAM,CAAC,EAAE,OAAO,CAAC;IACjB,MAAM,CAAC,EAAE,OAAO,CAAC;IACjB,aAAa,CAAC,EAAE,CAAC,KAAK,EAAE,KAAK,KAAK,IAAI,CAAC;IACvC,iBAAiB,CAAC,EAAE,CAAC,KAAK,EAAE,KAAK,KAAK,IAAI,CAAC;IAC3C,KAAK,CAAC,EAAE,OAAO,CAAC;IAChB,cAAc,CAAC,EAAE,OAAO,CAAC;IACzB,SAAS,CAAC,EAAE,OAAO,CAAC;IACpB,KAAK,CAAC,EAAE,OAAO,CAAC;IAChB,4BAA4B,CAAC,EAAE,OAAO,CAAC;IACvC,eAAe,CAAC,EAAE,SAAS,GAAG,kBAAkB,GAAG,WAAW,CAAC;IAC/D,kBAAkB,CAAC,EAAE,OAAO,CAAC;IAC7B,qBAAqB,CAAC,EAAE,OAAO,CAAC;CACjC,CAAC;AAYF;;;;GAIG;AACH,wBAAgB,oBAAoB,CAClC,MAAM,EAAE,iBAAiB,GAAG,eAAe,EAC3C,KAAK,EAAE,YAAY,GAClB,qBAAqB,CAiEvB"}
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
const DEFAULT_CONTEXT_PROPS = {
|
|
2
|
+
webgl2: true,
|
|
3
|
+
webgl1: true,
|
|
4
|
+
powerPreference: 'high-performance',
|
|
5
|
+
onContextLost: () => console.error('WebGL context lost'),
|
|
6
|
+
onContextRestored: () => console.info('WebGL context restored')
|
|
7
|
+
};
|
|
8
|
+
export function createBrowserContext(canvas, props) {
|
|
9
|
+
props = {
|
|
10
|
+
...DEFAULT_CONTEXT_PROPS,
|
|
11
|
+
...props
|
|
12
|
+
};
|
|
13
|
+
let errorMessage = null;
|
|
14
|
+
const onCreateError = error => errorMessage = error.statusMessage || errorMessage;
|
|
15
|
+
canvas.addEventListener('webglcontextcreationerror', onCreateError, false);
|
|
16
|
+
let gl = null;
|
|
17
|
+
if (props.type === 'webgl2') {
|
|
18
|
+
props = {
|
|
19
|
+
...props,
|
|
20
|
+
webgl1: false
|
|
21
|
+
};
|
|
22
|
+
}
|
|
23
|
+
if (props.type === 'webgl1') {
|
|
24
|
+
props = {
|
|
25
|
+
...props,
|
|
26
|
+
webgl2: false
|
|
27
|
+
};
|
|
28
|
+
}
|
|
29
|
+
if (!gl && props.webgl2) {
|
|
30
|
+
gl = canvas.getContext('webgl2', props);
|
|
31
|
+
}
|
|
32
|
+
if (!gl && props.webgl1) {
|
|
33
|
+
gl = canvas.getContext('webgl', props);
|
|
34
|
+
}
|
|
35
|
+
canvas.removeEventListener('webglcontextcreationerror', onCreateError, false);
|
|
36
|
+
if (!gl) {
|
|
37
|
+
throw new Error(`Failed to create ${props.webgl2 && !props.webgl1 ? 'WebGL2' : 'WebGL'} context: ${errorMessage || 'Unknown error'}`);
|
|
38
|
+
}
|
|
39
|
+
if (props.onContextLost) {
|
|
40
|
+
const {
|
|
41
|
+
onContextLost
|
|
42
|
+
} = props;
|
|
43
|
+
canvas.addEventListener('webglcontextlost', event => onContextLost(event), false);
|
|
44
|
+
}
|
|
45
|
+
if (props.onContextRestored) {
|
|
46
|
+
const {
|
|
47
|
+
onContextRestored
|
|
48
|
+
} = props;
|
|
49
|
+
canvas.addEventListener('webglcontextrestored', event => onContextRestored(event), false);
|
|
50
|
+
}
|
|
51
|
+
return gl;
|
|
52
|
+
}
|
|
53
|
+
//# sourceMappingURL=create-browser-context.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"create-browser-context.js","names":["DEFAULT_CONTEXT_PROPS","webgl2","webgl1","powerPreference","onContextLost","console","error","onContextRestored","info","createBrowserContext","canvas","props","errorMessage","onCreateError","statusMessage","addEventListener","gl","type","getContext","removeEventListener","Error","event"],"sources":["../../../src/context/context/create-browser-context.ts"],"sourcesContent":["// luma.gl, MIT license\n// Copyright (c) vis.gl contributors\n\n/**\n * ContextProps\n * @param webgl2 Set to false to not create a WebGL2 context (force webgl1)\n * @param webgl1 set to false to not create a WebGL1 context (fail if webgl2 not available)\n * @param onContextLost\n * @param onContextRestored\n *\n * BROWSER CONTEXT PARAMETERS\n * @param debug Instrument context (at the expense of performance).\n * @param alpha Default render target has an alpha buffer.\n * @param depth Default render target has a depth buffer of at least 16 bits.\n * @param stencil Default render target has a stencil buffer of at least 8 bits.\n * @param antialias Boolean that indicates whether or not to perform anti-aliasing.\n * @param premultipliedAlpha Boolean that indicates that the page compositor will assume the drawing buffer contains colors with pre-multiplied alpha.\n * @param preserveDrawingBuffer Default render target buffers will not be automatically cleared and will preserve their values until cleared or overwritten\n * @param failIfMajorPerformanceCaveat Do not create if the system performance is low.\n */\ntype ContextProps = {\n type?: 'webgl' | 'webgl1' | 'webgl2' | string;\n webgl1?: boolean;\n webgl2?: boolean;\n onContextLost?: (event: Event) => void;\n onContextRestored?: (event: Event) => void;\n alpha?: boolean; // indicates if the canvas contains an alpha buffer.\n desynchronized?: boolean; // hints the user agent to reduce the latency by desynchronizing the canvas paint cycle from the event loop\n antialias?: boolean; // indicates whether or not to perform anti-aliasing.\n depth?: boolean; // indicates that the drawing buffer has a depth buffer of at least 16 bits.\n failIfMajorPerformanceCaveat?: boolean; // indicates if a context will be created if the system performance is low or if no hardware GPU is available.\n powerPreference?: 'default' | 'high-performance' | 'low-power';\n premultipliedAlpha?: boolean; // page compositor will assume the drawing buffer contains colors with pre-multiplied alpha.\n preserveDrawingBuffer?: boolean; // buffers will not be cleared and will preserve their values until cleared or overwritten by the author.\n};\n\nconst DEFAULT_CONTEXT_PROPS: ContextProps = {\n webgl2: true, // Attempt to create a WebGL2 context\n webgl1: true, // Attempt to create a WebGL1 context (false to fail if webgl2 not available)\n powerPreference: 'high-performance', // After all, most apps are using WebGL for performance reasons\n // eslint-disable-next-line no-console\n onContextLost: () => console.error('WebGL context lost'),\n // eslint-disable-next-line no-console\n onContextRestored: () => console.info('WebGL context restored')\n};\n\n/**\n * Create a WebGL context for a canvas\n * Note calling this multiple time on the same canvas does return the same context\n * @param canvas A canvas element or offscreen canvas\n */\nexport function createBrowserContext(\n canvas: HTMLCanvasElement | OffscreenCanvas,\n props: ContextProps\n): WebGLRenderingContext {\n props = {...DEFAULT_CONTEXT_PROPS, ...props};\n\n // Try to extract any extra information about why context creation failed\n let errorMessage = null;\n const onCreateError = error => (errorMessage = error.statusMessage || errorMessage);\n canvas.addEventListener('webglcontextcreationerror', onCreateError, false);\n\n // Create the desired context\n let gl: WebGLRenderingContext | WebGL2RenderingContext | null = null;\n\n if (props.type === 'webgl2') {\n props = {...props, webgl1: false};\n }\n if (props.type === 'webgl1') {\n props = {...props, webgl2: false};\n }\n\n // props.failIfMajorPerformanceCaveat = true;\n\n // Prefer webgl2 over webgl1 if both are acceptable\n if (!gl && props.webgl2) {\n gl = canvas.getContext('webgl2', props) as WebGL2RenderingContext;\n }\n if (!gl && props.webgl1) {\n gl = canvas.getContext('webgl', props) as WebGLRenderingContext;\n }\n\n // Software GPU\n\n // props.failIfMajorPerformanceCaveat = false;\n // if (!gl && props.webgl2) {\n // gl = canvas.getContext('webgl2', props);\n // }\n // if (!gl && props.webgl1) {\n // gl = canvas.getContext('webgl', props);\n // }\n\n // TODO are we removing this listener before giving it a chance to fire?\n canvas.removeEventListener('webglcontextcreationerror', onCreateError, false);\n\n if (!gl) {\n throw new Error(\n `Failed to create ${props.webgl2 && !props.webgl1 ? 'WebGL2' : 'WebGL'} context: ${\n errorMessage || 'Unknown error'\n }`\n );\n }\n\n if (props.onContextLost) {\n // Carefully extract and wrap callbacks to prevent addEventListener from rebinding them.\n const {onContextLost} = props;\n canvas.addEventListener('webglcontextlost', (event: Event) => onContextLost(event), false);\n }\n if (props.onContextRestored) {\n // Carefully extract and wrap callbacks to prevent addEventListener from rebinding them.\n const {onContextRestored} = props;\n canvas.addEventListener(\n 'webglcontextrestored',\n (event: Event) => onContextRestored(event),\n false\n );\n }\n\n return gl;\n}\n\n/* TODO - can we call this asynchronously to catch the error events?\nexport async function createBrowserContextAsync(canvas: HTMLCanvasElement | OffscreenCanvas, props: ContextProps): Promise<WebGLRenderingContext> {\n props = {...DEFAULT_CONTEXT_PROPS, ...props};\n\n // Try to extract any extra information about why context creation failed\n let errorMessage = null;\n const onCreateError = (error) => (errorMessage = error.statusMessage || errorMessage);\n canvas.addEventListener('webglcontextcreationerror', onCreateError, false);\n\n const gl = createBrowserContext(canvas, props);\n\n // Give the listener a chance to fire\n await new Promise(resolve => setTimeout(resolve, 0));\n\n canvas.removeEventListener('webglcontextcreationerror', onCreateError, false);\n\n return gl;\n}\n*/\n"],"mappings":"AAoCA,MAAMA,qBAAmC,GAAG;EAC1CC,MAAM,EAAE,IAAI;EACZC,MAAM,EAAE,IAAI;EACZC,eAAe,EAAE,kBAAkB;EAEnCC,aAAa,EAAEA,CAAA,KAAMC,OAAO,CAACC,KAAK,CAAC,oBAAoB,CAAC;EAExDC,iBAAiB,EAAEA,CAAA,KAAMF,OAAO,CAACG,IAAI,CAAC,wBAAwB;AAChE,CAAC;AAOD,OAAO,SAASC,oBAAoBA,CAClCC,MAA2C,EAC3CC,KAAmB,EACI;EACvBA,KAAK,GAAG;IAAC,GAAGX,qBAAqB;IAAE,GAAGW;EAAK,CAAC;EAG5C,IAAIC,YAAY,GAAG,IAAI;EACvB,MAAMC,aAAa,GAAGP,KAAK,IAAKM,YAAY,GAAGN,KAAK,CAACQ,aAAa,IAAIF,YAAa;EACnFF,MAAM,CAACK,gBAAgB,CAAC,2BAA2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AC;EACH;EAEA,OAAOL,EAAE;AACX"}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
/** Duck typing for the main headless gl export, a function to create contexts */
|
|
2
|
+
export type HeadlessGL = (width: number, height: number, options: Record<string, unknown>) => WebGLRenderingContext;
|
|
3
|
+
/** By importing `gl` and registering it with this function, contexts can be created under Node.js */
|
|
4
|
+
export declare function registerHeadlessGL(headlessgl: HeadlessGL): void;
|
|
5
|
+
/** @returns true if headless gl is registered */
|
|
6
|
+
export declare function isHeadlessGLRegistered(): boolean;
|
|
7
|
+
/** Create headless gl context (for running under Node.js) */
|
|
8
|
+
export declare function createHeadlessContext(options?: Record<string, any>): WebGLRenderingContext;
|
|
9
|
+
//# sourceMappingURL=create-headless-context.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"create-headless-context.d.ts","sourceRoot":"","sources":["../../../src/context/context/create-headless-context.ts"],"names":[],"mappings":"AAkBA,iFAAiF;AACjF,MAAM,MAAM,UAAU,GAAG,CAAC,KAAK,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,KAAK,qBAAqB,CAAC;AAIpH,qGAAqG;AACrG,wBAAgB,kBAAkB,CAAC,UAAU,EAAE,UAAU,QAExD;AAED,iDAAiD;AACjD,wBAAgB,sBAAsB,IAAI,OAAO,CAEhD;AAED,6DAA6D;AAC7D,wBAAgB,qBAAqB,CAAC,OAAO,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,GAAG,qBAAqB,CAgB1F"}
|