@luma.gl/webgl 8.5.8 → 8.6.0-alpha.2
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/api/device2.d.ts +52 -0
- package/dist/api/device2.d.ts.map +1 -0
- package/dist/api/device2.js +23 -0
- package/dist/api/device2.js.map +1 -0
- package/dist/bundle.d.ts +2 -0
- package/dist/bundle.d.ts.map +1 -0
- package/dist/bundle.js +5 -0
- package/dist/bundle.js.map +1 -0
- package/dist/classes/accessor.d.ts +28 -0
- package/dist/classes/accessor.d.ts.map +1 -0
- package/dist/classes/accessor.js +112 -0
- package/dist/classes/accessor.js.map +1 -0
- package/dist/classes/accessor.ts.disabled +159 -0
- package/dist/classes/clear.d.ts +17 -0
- package/dist/classes/clear.d.ts.map +1 -0
- package/{src → dist}/classes/clear.js +29 -23
- package/dist/classes/clear.js.map +1 -0
- package/dist/classes/copy-and-blit.d.ts +86 -0
- package/dist/classes/copy-and-blit.d.ts.map +1 -0
- package/dist/classes/copy-and-blit.js +338 -0
- package/dist/classes/copy-and-blit.js.map +1 -0
- package/dist/classes/framebuffer.d.ts +139 -0
- package/dist/classes/framebuffer.d.ts.map +1 -0
- package/dist/classes/framebuffer.js +656 -0
- package/dist/classes/framebuffer.js.map +1 -0
- package/dist/classes/program-configuration.d.ts +27 -0
- package/dist/classes/program-configuration.d.ts.map +1 -0
- package/dist/classes/program-configuration.js +160 -0
- package/dist/classes/program-configuration.js.map +1 -0
- package/dist/classes/program.d.ts +61 -0
- package/dist/classes/program.d.ts.map +1 -0
- package/dist/classes/program.js +370 -0
- package/dist/classes/program.js.map +1 -0
- package/dist/classes/query.d.ts +27 -0
- package/dist/classes/query.d.ts.map +1 -0
- package/dist/classes/query.js +145 -0
- package/dist/classes/query.js.map +1 -0
- package/dist/classes/renderbuffer-formats.d.ts +16 -0
- package/dist/classes/renderbuffer-formats.d.ts.map +1 -0
- package/dist/classes/renderbuffer-formats.js +185 -0
- package/dist/classes/renderbuffer-formats.js.map +1 -0
- package/dist/classes/renderbuffer.d.ts +60 -0
- package/dist/classes/renderbuffer.d.ts.map +1 -0
- package/dist/classes/renderbuffer.js +128 -0
- package/dist/classes/renderbuffer.js.map +1 -0
- package/dist/classes/texture-2d.d.ts +9 -0
- package/dist/classes/texture-2d.d.ts.map +1 -0
- package/dist/classes/texture-2d.js +36 -0
- package/dist/classes/texture-2d.js.map +1 -0
- package/dist/classes/texture-3d.d.ts +29 -0
- package/dist/classes/texture-3d.d.ts.map +1 -0
- package/dist/classes/texture-3d.js +76 -0
- package/dist/classes/texture-3d.js.map +1 -0
- package/dist/classes/texture-cube.d.ts +28 -0
- package/dist/classes/texture-cube.d.ts.map +1 -0
- package/dist/classes/texture-cube.js +130 -0
- package/dist/classes/texture-cube.js.map +1 -0
- package/dist/classes/texture-formats.d.ts +37 -0
- package/dist/classes/texture-formats.d.ts.map +1 -0
- package/dist/classes/texture-formats.js +98 -0
- package/dist/classes/texture-formats.js.map +1 -0
- package/dist/classes/texture.d.ts +123 -0
- package/dist/classes/texture.d.ts.map +1 -0
- package/dist/classes/texture.js +786 -0
- package/dist/classes/texture.js.map +1 -0
- package/dist/classes/transform-feedback.d.ts +33 -0
- package/dist/classes/transform-feedback.d.ts.map +1 -0
- package/dist/classes/transform-feedback.js +198 -0
- package/dist/classes/transform-feedback.js.map +1 -0
- package/dist/classes/uniform-buffer-layout.d.ts +17 -0
- package/dist/classes/uniform-buffer-layout.d.ts.map +1 -0
- package/dist/classes/uniform-buffer-layout.js +104 -0
- package/dist/classes/uniform-buffer-layout.js.map +1 -0
- package/dist/classes/uniforms.d.ts +37 -0
- package/dist/classes/uniforms.d.ts.map +1 -0
- package/dist/classes/uniforms.js +250 -0
- package/dist/classes/uniforms.js.map +1 -0
- package/dist/classes/vertex-array-object.d.ts +75 -0
- package/dist/classes/vertex-array-object.d.ts.map +1 -0
- package/dist/classes/vertex-array-object.js +261 -0
- package/dist/classes/vertex-array-object.js.map +1 -0
- package/dist/classes/vertex-array.d.ts +75 -0
- package/dist/classes/vertex-array.d.ts.map +1 -0
- package/dist/classes/vertex-array.js +408 -0
- package/dist/classes/vertex-array.js.map +1 -0
- package/dist/classes/webgl-buffer.d.ts +100 -0
- package/dist/classes/webgl-buffer.d.ts.map +1 -0
- package/dist/{esm/classes/buffer.js → classes/webgl-buffer.js} +100 -73
- package/dist/classes/webgl-buffer.js.map +1 -0
- package/dist/classes/webgl-resource.d.ts +56 -0
- package/dist/classes/webgl-resource.d.ts.map +1 -0
- package/dist/{esm/classes/resource.js → classes/webgl-resource.js} +35 -52
- package/dist/classes/webgl-resource.js.map +1 -0
- package/dist/classes/webgl-shader.d.ts +53 -0
- package/dist/classes/webgl-shader.d.ts.map +1 -0
- package/dist/classes/webgl-shader.js +193 -0
- package/dist/classes/webgl-shader.js.map +1 -0
- package/dist/context/context/context-state.d.ts +18 -0
- package/dist/context/context/context-state.d.ts.map +1 -0
- package/dist/context/context/context-state.js +26 -0
- package/dist/context/context/context-state.js.map +1 -0
- package/dist/context/context/create-context.d.ts +40 -0
- package/dist/context/context/create-context.d.ts.map +1 -0
- package/dist/context/context/create-context.js +37 -0
- package/dist/context/context/create-context.js.map +1 -0
- package/dist/context/context/device-pixels.d.ts +25 -0
- package/dist/context/context/device-pixels.d.ts.map +1 -0
- package/dist/context/context/device-pixels.js +98 -0
- package/dist/context/context/device-pixels.js.map +1 -0
- package/dist/context/context/get-canvas.d.ts +13 -0
- package/dist/context/context/get-canvas.d.ts.map +1 -0
- package/dist/context/context/get-canvas.js +31 -0
- package/dist/context/context/get-canvas.js.map +1 -0
- package/dist/context/context/resize-context.d.ts +20 -0
- package/dist/context/context/resize-context.d.ts.map +1 -0
- package/dist/context/context/resize-context.js +15 -0
- package/dist/context/context/resize-context.js.map +1 -0
- package/dist/context/context/webgl-checks.d.ts +13 -0
- package/dist/context/context/webgl-checks.d.ts.map +1 -0
- package/dist/context/context/webgl-checks.js +34 -0
- package/dist/context/context/webgl-checks.js.map +1 -0
- package/dist/context/parameters/unified-parameter-api.d.ts +30 -0
- package/dist/context/parameters/unified-parameter-api.d.ts.map +1 -0
- package/dist/context/parameters/unified-parameter-api.js +65 -0
- package/dist/context/parameters/unified-parameter-api.js.map +1 -0
- package/dist/context/parameters/webgl-parameter-tables.d.ts +169 -0
- package/dist/context/parameters/webgl-parameter-tables.d.ts.map +1 -0
- package/dist/context/parameters/webgl-parameter-tables.js +445 -0
- package/dist/context/parameters/webgl-parameter-tables.js.map +1 -0
- package/dist/context/parameters/webgl-parameters.d.ts +144 -0
- package/dist/context/parameters/webgl-parameters.d.ts.map +1 -0
- package/dist/context/parameters/webgl-parameters.js +2 -0
- package/dist/context/parameters/webgl-parameters.js.map +1 -0
- package/dist/context/polyfill/get-parameter-polyfill.d.ts +2 -0
- package/dist/context/polyfill/get-parameter-polyfill.d.ts.map +1 -0
- package/dist/context/polyfill/get-parameter-polyfill.js +91 -0
- package/dist/context/polyfill/get-parameter-polyfill.js.map +1 -0
- package/dist/context/polyfill/polyfill-context.d.ts +5 -0
- package/dist/context/polyfill/polyfill-context.d.ts.map +1 -0
- package/dist/context/polyfill/polyfill-context.js +91 -0
- package/dist/context/polyfill/polyfill-context.js.map +1 -0
- package/dist/context/polyfill/polyfill-table.d.ts +48 -0
- package/dist/context/polyfill/polyfill-table.d.ts.map +1 -0
- package/dist/context/polyfill/polyfill-table.js +160 -0
- package/dist/context/polyfill/polyfill-table.js.map +1 -0
- package/dist/context/polyfill/polyfill-vertex-array-object.d.ts +2 -0
- package/dist/context/polyfill/polyfill-vertex-array-object.d.ts.map +1 -0
- package/dist/context/polyfill/polyfill-vertex-array-object.js +335 -0
- package/dist/context/polyfill/polyfill-vertex-array-object.js.map +1 -0
- package/dist/context/state-tracker/deep-array-equal.d.ts +3 -0
- package/dist/context/state-tracker/deep-array-equal.d.ts.map +1 -0
- package/dist/context/state-tracker/deep-array-equal.js +21 -0
- package/dist/context/state-tracker/deep-array-equal.js.map +1 -0
- package/dist/context/state-tracker/track-context-state.d.ts +22 -0
- package/dist/context/state-tracker/track-context-state.d.ts.map +1 -0
- package/dist/context/state-tracker/track-context-state.js +169 -0
- package/dist/context/state-tracker/track-context-state.js.map +1 -0
- package/dist/context/state-tracker/with-parameters.d.ts +13 -0
- package/dist/context/state-tracker/with-parameters.d.ts.map +1 -0
- package/dist/context/state-tracker/with-parameters.js +36 -0
- package/dist/context/state-tracker/with-parameters.js.map +1 -0
- package/dist/debug/debug-program-configuration.d.ts +2 -0
- package/dist/debug/debug-program-configuration.d.ts.map +1 -0
- package/dist/debug/debug-program-configuration.js +40 -0
- package/dist/debug/debug-program-configuration.js.map +1 -0
- package/dist/debug/debug-uniforms.d.ts +12 -0
- package/dist/debug/debug-uniforms.d.ts.map +1 -0
- package/dist/debug/debug-uniforms.js +108 -0
- package/dist/debug/debug-uniforms.js.map +1 -0
- package/dist/debug/debug-vertex-array.d.ts +5 -0
- package/dist/debug/debug-vertex-array.d.ts.map +1 -0
- package/dist/debug/debug-vertex-array.js +118 -0
- package/dist/debug/debug-vertex-array.js.map +1 -0
- package/dist/device/check-glsl-extension.d.ts +4 -0
- package/dist/device/check-glsl-extension.d.ts.map +1 -0
- package/dist/device/check-glsl-extension.js +22 -0
- package/dist/device/check-glsl-extension.js.map +1 -0
- package/dist/device/device-features.d.ts +12 -0
- package/dist/device/device-features.d.ts.map +1 -0
- package/dist/device/device-features.js +123 -0
- package/dist/device/device-features.js.map +1 -0
- package/dist/device/device-limits.d.ts +51 -0
- package/dist/device/device-limits.d.ts.map +1 -0
- package/dist/device/device-limits.js +90 -0
- package/dist/device/device-limits.js.map +1 -0
- package/dist/device/get-device-info.d.ts +4 -0
- package/dist/device/get-device-info.d.ts.map +1 -0
- package/dist/device/get-device-info.js +44 -0
- package/dist/device/get-device-info.js.map +1 -0
- package/dist/device/webgl-device.d.ts +111 -0
- package/dist/device/webgl-device.d.ts.map +1 -0
- package/dist/device/webgl-device.js +208 -0
- package/dist/device/webgl-device.js.map +1 -0
- package/dist/es5/api/device2.js +42 -0
- package/dist/es5/api/device2.js.map +1 -0
- package/dist/es5/bundle.js +2 -4
- package/dist/es5/bundle.js.map +1 -1
- package/dist/es5/classes/accessor.js +36 -38
- package/dist/es5/classes/accessor.js.map +1 -1
- package/dist/es5/classes/accessor.ts.disabled +159 -0
- package/dist/es5/classes/clear.js +17 -11
- package/dist/es5/classes/clear.js.map +1 -1
- package/dist/es5/classes/copy-and-blit.js +121 -117
- package/dist/es5/classes/copy-and-blit.js.map +1 -1
- package/dist/es5/classes/framebuffer.js +435 -423
- package/dist/es5/classes/framebuffer.js.map +1 -1
- package/dist/es5/classes/program-configuration.js +14 -11
- package/dist/es5/classes/program-configuration.js.map +1 -1
- package/dist/es5/classes/program.js +79 -67
- package/dist/es5/classes/program.js.map +1 -1
- package/dist/es5/classes/query.js +58 -59
- package/dist/es5/classes/query.js.map +1 -1
- package/dist/es5/classes/renderbuffer-formats.js +79 -52
- package/dist/es5/classes/renderbuffer-formats.js.map +1 -1
- package/dist/es5/classes/renderbuffer.js +129 -100
- package/dist/es5/classes/renderbuffer.js.map +1 -1
- package/dist/es5/classes/texture-2d.js +25 -21
- package/dist/es5/classes/texture-2d.js.map +1 -1
- package/dist/es5/classes/texture-3d.js +49 -29
- package/dist/es5/classes/texture-3d.js.map +1 -1
- package/dist/es5/classes/texture-cube.js +45 -36
- package/dist/es5/classes/texture-cube.js.map +1 -1
- package/dist/es5/classes/texture-formats.js +35 -33
- package/dist/es5/classes/texture-formats.js.map +1 -1
- package/dist/es5/classes/texture.js +213 -101
- package/dist/es5/classes/texture.js.map +1 -1
- package/dist/es5/classes/transform-feedback.js +37 -34
- package/dist/es5/classes/transform-feedback.js.map +1 -1
- package/dist/es5/classes/uniform-buffer-layout.js +4 -4
- package/dist/es5/classes/uniform-buffer-layout.js.map +1 -1
- package/dist/es5/classes/uniforms.js +73 -73
- package/dist/es5/classes/uniforms.js.map +1 -1
- package/dist/es5/classes/vertex-array-object.js +106 -149
- package/dist/es5/classes/vertex-array-object.js.map +1 -1
- package/dist/es5/classes/vertex-array.js +47 -38
- package/dist/es5/classes/vertex-array.js.map +1 -1
- package/dist/es5/classes/{buffer.js → webgl-buffer.js} +120 -111
- package/dist/es5/classes/webgl-buffer.js.map +1 -0
- package/dist/es5/classes/{resource.js → webgl-resource.js} +78 -99
- package/dist/es5/classes/webgl-resource.js.map +1 -0
- package/dist/es5/classes/webgl-shader.js +309 -0
- package/dist/es5/classes/webgl-shader.js.map +1 -0
- package/dist/es5/context/context/context-state.js +31 -0
- package/dist/es5/context/context/context-state.js.map +1 -0
- package/dist/es5/context/context/create-context.js +57 -0
- package/dist/es5/context/context/create-context.js.map +1 -0
- package/dist/es5/context/context/device-pixels.js +115 -0
- package/dist/es5/context/context/device-pixels.js.map +1 -0
- package/dist/es5/context/context/get-canvas.js +40 -0
- package/dist/es5/context/context/get-canvas.js.map +1 -0
- package/dist/es5/context/context/resize-context.js +23 -0
- package/dist/es5/context/context/resize-context.js.map +1 -0
- package/dist/es5/context/context/webgl-checks.js +54 -0
- package/dist/es5/context/context/webgl-checks.js.map +1 -0
- package/dist/es5/context/parameters/unified-parameter-api.js +95 -0
- package/dist/es5/context/parameters/unified-parameter-api.js.map +1 -0
- package/dist/es5/context/parameters/webgl-parameter-tables.js +392 -0
- package/dist/es5/context/parameters/webgl-parameter-tables.js.map +1 -0
- package/dist/es5/context/parameters/webgl-parameters.js +6 -0
- package/dist/es5/context/parameters/webgl-parameters.js.map +1 -0
- package/dist/es5/context/polyfill/get-parameter-polyfill.js +81 -0
- package/dist/es5/context/polyfill/get-parameter-polyfill.js.map +1 -0
- package/dist/es5/context/polyfill/polyfill-context.js +134 -0
- package/dist/es5/context/polyfill/polyfill-context.js.map +1 -0
- package/dist/es5/context/polyfill/polyfill-table.js +166 -0
- package/dist/es5/context/polyfill/polyfill-table.js.map +1 -0
- package/dist/es5/context/polyfill/polyfill-vertex-array-object.js +341 -0
- package/dist/es5/context/polyfill/polyfill-vertex-array-object.js.map +1 -0
- package/dist/es5/context/state-tracker/deep-array-equal.js +28 -0
- package/dist/es5/context/state-tracker/deep-array-equal.js.map +1 -0
- package/dist/es5/context/state-tracker/track-context-state.js +196 -0
- package/dist/es5/context/state-tracker/track-context-state.js.map +1 -0
- package/dist/es5/context/state-tracker/with-parameters.js +44 -0
- package/dist/es5/context/state-tracker/with-parameters.js.map +1 -0
- package/dist/es5/debug/debug-program-configuration.js +1 -1
- package/dist/es5/debug/debug-program-configuration.js.map +1 -1
- package/dist/es5/debug/debug-uniforms.js +18 -20
- package/dist/es5/debug/debug-uniforms.js.map +1 -1
- package/dist/es5/debug/debug-vertex-array.js +16 -16
- package/dist/es5/debug/debug-vertex-array.js.map +1 -1
- package/dist/es5/device/check-glsl-extension.js +33 -0
- package/dist/es5/device/check-glsl-extension.js.map +1 -0
- package/dist/es5/device/device-features.js +152 -0
- package/dist/es5/device/device-features.js.map +1 -0
- package/dist/es5/device/device-limits.js +64 -0
- package/dist/es5/device/device-limits.js.map +1 -0
- package/dist/es5/device/get-device-info.js +55 -0
- package/dist/es5/device/get-device-info.js.map +1 -0
- package/dist/es5/device/webgl-device.js +279 -0
- package/dist/es5/device/webgl-device.js.map +1 -0
- package/dist/es5/index.js +140 -96
- package/dist/es5/index.js.map +1 -1
- package/dist/es5/init.js +21 -41
- package/dist/es5/init.js.map +1 -1
- package/dist/es5/types.js +2 -0
- package/dist/es5/types.js.map +1 -0
- package/dist/es5/webgl-utils/attribute-utils.js +4 -4
- package/dist/es5/webgl-utils/attribute-utils.js.map +1 -1
- package/dist/es5/webgl-utils/constants-to-keys.js +3 -3
- package/dist/es5/webgl-utils/constants-to-keys.js.map +1 -1
- package/dist/es5/webgl-utils/format-utils.js +21 -17
- package/dist/es5/webgl-utils/format-utils.js.map +1 -1
- package/dist/es5/webgl-utils/get-error.js.map +1 -1
- package/dist/es5/webgl-utils/index.js +74 -0
- package/dist/es5/webgl-utils/index.js.map +1 -0
- package/dist/es5/{features/check-old-ie.js → webgl-utils/is-old-ie.js} +3 -3
- package/dist/es5/webgl-utils/is-old-ie.js.map +1 -0
- package/dist/es5/webgl-utils/parse-shader-compiler-log.js +72 -0
- package/dist/es5/webgl-utils/parse-shader-compiler-log.js.map +1 -0
- package/dist/es5/webgl-utils/request-animation-frame.js.map +1 -1
- package/dist/es5/webgl-utils/texture-utils.js +6 -4
- package/dist/es5/webgl-utils/texture-utils.js.map +1 -1
- package/dist/es5/webgl-utils/typed-array-utils.js +39 -34
- package/dist/es5/webgl-utils/typed-array-utils.js.map +1 -1
- package/dist/es5/webgl-utils/webgl-info.ts.disabled +135 -0
- package/dist/esm/api/device2.js +23 -0
- package/dist/esm/api/device2.js.map +1 -0
- package/dist/esm/bundle.js +2 -4
- package/dist/esm/bundle.js.map +1 -1
- package/dist/esm/classes/accessor.js +6 -6
- package/dist/esm/classes/accessor.js.map +1 -1
- package/dist/esm/classes/accessor.ts.disabled +159 -0
- package/dist/esm/classes/clear.js +19 -14
- package/dist/esm/classes/clear.js.map +1 -1
- package/dist/esm/classes/copy-and-blit.js +67 -64
- package/dist/esm/classes/copy-and-blit.js.map +1 -1
- package/dist/esm/classes/framebuffer.js +341 -313
- package/dist/esm/classes/framebuffer.js.map +1 -1
- package/dist/esm/classes/program-configuration.js +18 -10
- package/dist/esm/classes/program-configuration.js.map +1 -1
- package/dist/esm/classes/program.js +71 -44
- package/dist/esm/classes/program.js.map +1 -1
- package/dist/esm/classes/query.js +20 -16
- package/dist/esm/classes/query.js.map +1 -1
- package/dist/esm/classes/renderbuffer-formats.js +72 -49
- package/dist/esm/classes/renderbuffer-formats.js.map +1 -1
- package/dist/esm/classes/renderbuffer.js +86 -73
- package/dist/esm/classes/renderbuffer.js.map +1 -1
- package/dist/esm/classes/texture-2d.js +13 -9
- package/dist/esm/classes/texture-2d.js.map +1 -1
- package/dist/esm/classes/texture-3d.js +28 -16
- package/dist/esm/classes/texture-3d.js.map +1 -1
- package/dist/esm/classes/texture-cube.js +45 -31
- package/dist/esm/classes/texture-cube.js.map +1 -1
- package/dist/esm/classes/texture-formats.js +52 -51
- package/dist/esm/classes/texture-formats.js.map +1 -1
- package/dist/esm/classes/texture.js +174 -58
- package/dist/esm/classes/texture.js.map +1 -1
- package/dist/esm/classes/transform-feedback.js +26 -14
- package/dist/esm/classes/transform-feedback.js.map +1 -1
- package/dist/esm/classes/uniform-buffer-layout.js +1 -1
- package/dist/esm/classes/uniform-buffer-layout.js.map +1 -1
- package/dist/esm/classes/uniforms.js +111 -113
- package/dist/esm/classes/uniforms.js.map +1 -1
- package/dist/esm/classes/vertex-array-object.js +52 -89
- package/dist/esm/classes/vertex-array-object.js.map +1 -1
- package/dist/esm/classes/vertex-array.js +50 -29
- package/dist/esm/classes/vertex-array.js.map +1 -1
- package/dist/esm/classes/webgl-buffer.js +382 -0
- package/dist/esm/classes/webgl-buffer.js.map +1 -0
- package/dist/esm/classes/webgl-resource.js +212 -0
- package/dist/esm/classes/webgl-resource.js.map +1 -0
- package/dist/esm/classes/webgl-shader.js +193 -0
- package/dist/esm/classes/webgl-shader.js.map +1 -0
- package/dist/esm/context/context/context-state.js +26 -0
- package/dist/esm/context/context/context-state.js.map +1 -0
- package/dist/esm/context/context/create-context.js +37 -0
- package/dist/esm/context/context/create-context.js.map +1 -0
- package/dist/esm/context/context/device-pixels.js +98 -0
- package/dist/esm/context/context/device-pixels.js.map +1 -0
- package/dist/esm/context/context/get-canvas.js +31 -0
- package/dist/esm/context/context/get-canvas.js.map +1 -0
- package/dist/esm/context/context/resize-context.js +15 -0
- package/dist/esm/context/context/resize-context.js.map +1 -0
- package/dist/esm/context/context/webgl-checks.js +34 -0
- package/dist/esm/context/context/webgl-checks.js.map +1 -0
- package/dist/esm/context/parameters/unified-parameter-api.js +65 -0
- package/dist/esm/context/parameters/unified-parameter-api.js.map +1 -0
- package/dist/esm/context/parameters/webgl-parameter-tables.js +445 -0
- package/dist/esm/context/parameters/webgl-parameter-tables.js.map +1 -0
- package/dist/esm/context/parameters/webgl-parameters.js +2 -0
- package/dist/esm/context/parameters/webgl-parameters.js.map +1 -0
- package/dist/esm/context/polyfill/get-parameter-polyfill.js +91 -0
- package/dist/esm/context/polyfill/get-parameter-polyfill.js.map +1 -0
- package/dist/esm/context/polyfill/polyfill-context.js +91 -0
- package/dist/esm/context/polyfill/polyfill-context.js.map +1 -0
- package/dist/esm/context/polyfill/polyfill-table.js +160 -0
- package/dist/esm/context/polyfill/polyfill-table.js.map +1 -0
- package/dist/esm/context/polyfill/polyfill-vertex-array-object.js +335 -0
- package/dist/esm/context/polyfill/polyfill-vertex-array-object.js.map +1 -0
- package/dist/esm/context/state-tracker/deep-array-equal.js +21 -0
- package/dist/esm/context/state-tracker/deep-array-equal.js.map +1 -0
- package/dist/esm/context/state-tracker/track-context-state.js +169 -0
- package/dist/esm/context/state-tracker/track-context-state.js.map +1 -0
- package/dist/esm/context/state-tracker/with-parameters.js +36 -0
- package/dist/esm/context/state-tracker/with-parameters.js.map +1 -0
- package/dist/esm/debug/debug-program-configuration.js +4 -4
- package/dist/esm/debug/debug-program-configuration.js.map +1 -1
- package/dist/esm/debug/debug-uniforms.js +9 -9
- package/dist/esm/debug/debug-uniforms.js.map +1 -1
- package/dist/esm/debug/debug-vertex-array.js +18 -16
- package/dist/esm/debug/debug-vertex-array.js.map +1 -1
- package/dist/esm/device/check-glsl-extension.js +22 -0
- package/dist/esm/device/check-glsl-extension.js.map +1 -0
- package/dist/esm/device/device-features.js +123 -0
- package/dist/esm/device/device-features.js.map +1 -0
- package/dist/esm/device/device-limits.js +90 -0
- package/dist/esm/device/device-limits.js.map +1 -0
- package/dist/esm/device/get-device-info.js +44 -0
- package/dist/esm/device/get-device-info.js.map +1 -0
- package/dist/esm/device/webgl-device.js +208 -0
- package/dist/esm/device/webgl-device.js.map +1 -0
- package/dist/esm/index.js +15 -15
- package/dist/esm/index.js.map +1 -1
- package/dist/esm/init.js +12 -28
- package/dist/esm/init.js.map +1 -1
- package/dist/esm/types.js +2 -0
- package/dist/esm/types.js.map +1 -0
- package/dist/esm/webgl-utils/attribute-utils.js +1 -1
- package/dist/esm/webgl-utils/attribute-utils.js.map +1 -1
- package/dist/esm/webgl-utils/constants-to-keys.js +4 -4
- package/dist/esm/webgl-utils/constants-to-keys.js.map +1 -1
- package/dist/esm/webgl-utils/format-utils.js +16 -15
- package/dist/esm/webgl-utils/format-utils.js.map +1 -1
- package/dist/esm/webgl-utils/get-error.js +1 -1
- package/dist/esm/webgl-utils/get-error.js.map +1 -1
- package/dist/esm/webgl-utils/index.js +5 -0
- package/dist/esm/webgl-utils/index.js.map +1 -0
- package/dist/esm/{features/check-old-ie.js → webgl-utils/is-old-ie.js} +3 -3
- package/dist/esm/webgl-utils/is-old-ie.js.map +1 -0
- package/dist/esm/webgl-utils/parse-shader-compiler-log.js +37 -0
- package/dist/esm/webgl-utils/parse-shader-compiler-log.js.map +1 -0
- package/dist/esm/webgl-utils/request-animation-frame.js.map +1 -1
- package/dist/esm/webgl-utils/texture-utils.js +4 -3
- package/dist/esm/webgl-utils/texture-utils.js.map +1 -1
- package/dist/esm/webgl-utils/typed-array-utils.js +41 -36
- package/dist/esm/webgl-utils/typed-array-utils.js.map +1 -1
- package/dist/esm/webgl-utils/webgl-info.ts.disabled +135 -0
- package/dist/index.d.ts +49 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +35 -0
- package/dist/index.js.map +1 -0
- package/dist/init.d.ts +5 -0
- package/dist/init.d.ts.map +1 -0
- package/dist/init.js +33 -0
- package/dist/init.js.map +1 -0
- package/dist/types.d.ts +9 -0
- package/dist/types.d.ts.map +1 -0
- package/dist/types.js +2 -0
- package/dist/types.js.map +1 -0
- package/dist/webgl-utils/attribute-utils.d.ts +18 -0
- package/dist/webgl-utils/attribute-utils.d.ts.map +1 -0
- package/dist/webgl-utils/attribute-utils.js +182 -0
- package/dist/webgl-utils/attribute-utils.js.map +1 -0
- package/dist/webgl-utils/constants-to-keys.d.ts +4 -0
- package/dist/webgl-utils/constants-to-keys.d.ts.map +1 -0
- package/dist/webgl-utils/constants-to-keys.js +41 -0
- package/dist/webgl-utils/constants-to-keys.js.map +1 -0
- package/dist/webgl-utils/format-utils.d.ts +3 -0
- package/dist/webgl-utils/format-utils.d.ts.map +1 -0
- package/dist/webgl-utils/format-utils.js +45 -0
- package/dist/webgl-utils/format-utils.js.map +1 -0
- package/dist/webgl-utils/get-error.d.ts +3 -0
- package/dist/webgl-utils/get-error.d.ts.map +1 -0
- package/dist/webgl-utils/get-error.js +41 -0
- package/dist/webgl-utils/get-error.js.map +1 -0
- package/dist/webgl-utils/index.d.ts +5 -0
- package/dist/webgl-utils/index.d.ts.map +1 -0
- package/dist/webgl-utils/index.js +5 -0
- package/dist/webgl-utils/index.js.map +1 -0
- package/dist/webgl-utils/is-old-ie.d.ts +2 -0
- package/dist/webgl-utils/is-old-ie.d.ts.map +1 -0
- package/dist/webgl-utils/is-old-ie.js +8 -0
- package/dist/webgl-utils/is-old-ie.js.map +1 -0
- package/dist/webgl-utils/parse-shader-compiler-log.d.ts +8 -0
- package/dist/webgl-utils/parse-shader-compiler-log.d.ts.map +1 -0
- package/dist/webgl-utils/parse-shader-compiler-log.js +37 -0
- package/dist/webgl-utils/parse-shader-compiler-log.js.map +1 -0
- package/dist/webgl-utils/request-animation-frame.d.ts +4 -0
- package/dist/webgl-utils/request-animation-frame.d.ts.map +1 -0
- package/dist/webgl-utils/request-animation-frame.js +7 -0
- package/dist/webgl-utils/request-animation-frame.js.map +1 -0
- package/dist/webgl-utils/texture-utils.d.ts +15 -0
- package/dist/webgl-utils/texture-utils.d.ts.map +1 -0
- package/dist/webgl-utils/texture-utils.js +48 -0
- package/dist/webgl-utils/texture-utils.js.map +1 -0
- package/dist/webgl-utils/typed-array-utils.d.ts +43 -0
- package/dist/webgl-utils/typed-array-utils.d.ts.map +1 -0
- package/{src → dist}/webgl-utils/typed-array-utils.js +45 -27
- package/dist/webgl-utils/typed-array-utils.js.map +1 -0
- package/dist/webgl-utils/webgl-info.ts.disabled +135 -0
- package/package.json +9 -9
- package/src/.DS_Store +0 -0
- package/src/api/device2.ts +71 -0
- package/src/bundle.ts +4 -0
- package/src/classes/accessor.js +2 -3
- package/src/classes/accessor.ts.disabled +159 -0
- package/src/classes/clear.ts +108 -0
- package/src/classes/{copy-and-blit.js → copy-and-blit.ts} +143 -55
- package/src/classes/{framebuffer.js → framebuffer.ts} +381 -321
- package/src/classes/{program-configuration.js → program-configuration.ts} +19 -12
- package/src/classes/{program.js → program.ts} +66 -40
- package/src/classes/{query.js → query.ts} +31 -25
- package/src/classes/{renderbuffer-formats.js → renderbuffer-formats.ts} +42 -14
- package/src/classes/renderbuffer.ts +154 -0
- package/src/classes/texture-2d.ts +35 -0
- package/src/classes/{texture-3d.js → texture-3d.ts} +48 -18
- package/src/classes/{texture-cube.js → texture-cube.ts} +52 -34
- package/src/classes/{texture-formats.js → texture-formats.ts} +10 -2
- package/src/classes/{texture.js → texture.ts} +223 -57
- package/src/classes/{transform-feedback.js → transform-feedback.ts} +34 -25
- package/src/classes/{uniform-buffer-layout.js → uniform-buffer-layout.ts} +10 -6
- package/src/classes/{uniforms.js → uniforms.ts} +123 -77
- package/src/classes/{vertex-array-object.js → vertex-array-object.ts} +133 -112
- package/src/classes/{vertex-array.js → vertex-array.ts} +74 -55
- package/src/classes/{buffer.js → webgl-buffer.ts} +126 -50
- package/src/classes/{resource.js → webgl-resource.ts} +55 -46
- package/src/classes/webgl-shader.ts +202 -0
- package/src/context/context/context-state.ts +39 -0
- package/src/context/context/create-context.ts +83 -0
- package/src/context/context/device-pixels.ts +147 -0
- package/src/context/context/get-canvas.ts +37 -0
- package/src/context/context/resize-context.ts +37 -0
- package/src/context/context/webgl-checks.ts +49 -0
- package/src/context/parameters/unified-parameter-api.ts +127 -0
- package/src/context/parameters/webgl-parameter-tables.ts +625 -0
- package/src/context/parameters/webgl-parameters.ts +197 -0
- package/src/context/polyfill/get-parameter-polyfill.ts +118 -0
- package/src/context/polyfill/polyfill-context.ts +98 -0
- package/src/context/polyfill/polyfill-table.ts +162 -0
- package/src/context/polyfill/polyfill-vertex-array-object.ts +360 -0
- package/src/context/state-tracker/deep-array-equal.ts +20 -0
- package/src/context/state-tracker/track-context-state.ts +250 -0
- package/src/context/state-tracker/with-parameters.ts +50 -0
- package/src/debug/{debug-program-configuration.js → debug-program-configuration.ts} +0 -0
- package/src/debug/{debug-uniforms.js → debug-uniforms.ts} +18 -8
- package/src/debug/{debug-vertex-array.js → debug-vertex-array.ts} +6 -5
- package/src/device/check-glsl-extension.ts +44 -0
- package/src/device/device-features.ts +227 -0
- package/src/device/device-limits.ts +150 -0
- package/src/device/get-device-info.ts +49 -0
- package/src/device/webgl-device.ts +406 -0
- package/src/index.ts +127 -0
- package/src/{init.js → init.ts} +11 -25
- package/src/{types.d.ts → types.ts} +1 -1
- package/src/webgl-utils/{attribute-utils.js → attribute-utils.ts} +1 -2
- package/src/webgl-utils/{constants-to-keys.js → constants-to-keys.ts} +1 -1
- package/src/webgl-utils/{format-utils.js → format-utils.ts} +1 -1
- package/src/webgl-utils/{get-error.js → get-error.ts} +0 -0
- package/src/webgl-utils/index.ts +12 -0
- package/src/{features/check-old-ie.js → webgl-utils/is-old-ie.ts} +3 -3
- package/src/webgl-utils/parse-shader-compiler-log.ts +48 -0
- package/src/webgl-utils/{request-animation-frame.js → request-animation-frame.ts} +3 -2
- package/src/webgl-utils/{texture-utils.js → texture-utils.ts} +14 -10
- package/src/webgl-utils/typed-array-utils.ts +137 -0
- package/src/webgl-utils/webgl-info.ts.disabled +135 -0
- package/dist/dist.js +0 -13710
- package/dist/dist.min.js +0 -1
- package/dist/es5/classes/buffer.d.ts +0 -84
- package/dist/es5/classes/buffer.js.map +0 -1
- package/dist/es5/classes/clear.d.ts +0 -11
- package/dist/es5/classes/copy-and-blit.d.ts +0 -101
- package/dist/es5/classes/framebuffer.d.ts +0 -96
- package/dist/es5/classes/program-configuration.d.ts +0 -15
- package/dist/es5/classes/program.d.ts +0 -44
- package/dist/es5/classes/query.d.ts +0 -21
- package/dist/es5/classes/renderbuffer.d.ts +0 -34
- package/dist/es5/classes/resource.d.ts +0 -47
- package/dist/es5/classes/resource.js.map +0 -1
- package/dist/es5/classes/shader.d.ts +0 -29
- package/dist/es5/classes/shader.js +0 -221
- package/dist/es5/classes/shader.js.map +0 -1
- package/dist/es5/classes/texture-2d.d.ts +0 -11
- package/dist/es5/classes/texture-3d.d.ts +0 -29
- package/dist/es5/classes/texture-cube.d.ts +0 -23
- package/dist/es5/classes/texture.d.ts +0 -80
- package/dist/es5/classes/transform-feedback.d.ts +0 -16
- package/dist/es5/classes/uniform-buffer-layout.d.ts +0 -18
- package/dist/es5/classes/uniforms.d.ts +0 -63
- package/dist/es5/classes/vertex-array-object.d.ts +0 -25
- package/dist/es5/classes/vertex-array.d.ts +0 -37
- package/dist/es5/debug/debug-program-configuration.d.ts +0 -1
- package/dist/es5/debug/debug-uniforms.d.ts +0 -11
- package/dist/es5/debug/debug-vertex-array.d.ts +0 -1
- package/dist/es5/features/check-glsl-extension.js +0 -41
- package/dist/es5/features/check-glsl-extension.js.map +0 -1
- package/dist/es5/features/check-old-ie.js.map +0 -1
- package/dist/es5/features/features.js +0 -99
- package/dist/es5/features/features.js.map +0 -1
- package/dist/es5/features/index.js +0 -64
- package/dist/es5/features/index.js.map +0 -1
- package/dist/es5/features/limits.js +0 -64
- package/dist/es5/features/limits.js.map +0 -1
- package/dist/es5/features/webgl-features-table.js +0 -64
- package/dist/es5/features/webgl-features-table.js.map +0 -1
- package/dist/es5/features/webgl-limits-table.js +0 -132
- package/dist/es5/features/webgl-limits-table.js.map +0 -1
- package/dist/es5/glsl-utils/format-glsl-error.d.ts +0 -16
- package/dist/es5/glsl-utils/format-glsl-error.js +0 -108
- package/dist/es5/glsl-utils/format-glsl-error.js.map +0 -1
- package/dist/es5/glsl-utils/get-shader-name.js +0 -14
- package/dist/es5/glsl-utils/get-shader-name.js.map +0 -1
- package/dist/es5/glsl-utils/get-shader-type-name.js +0 -22
- package/dist/es5/glsl-utils/get-shader-type-name.js.map +0 -1
- package/dist/es5/glsl-utils/get-shader-version.js +0 -22
- package/dist/es5/glsl-utils/get-shader-version.js.map +0 -1
- package/dist/es5/glsl-utils/index.js +0 -48
- package/dist/es5/glsl-utils/index.js.map +0 -1
- package/dist/es5/index.d.ts +0 -71
- package/dist/es5/init.d.ts +0 -12
- package/dist/es5/types.d.ts +0 -8
- package/dist/es5/utils/array-utils-flat.js +0 -51
- package/dist/es5/utils/array-utils-flat.js.map +0 -1
- package/dist/es5/utils/assert.d.ts +0 -1
- package/dist/es5/utils/assert.js +0 -13
- package/dist/es5/utils/assert.js.map +0 -1
- package/dist/es5/utils/check-props.js +0 -51
- package/dist/es5/utils/check-props.js.map +0 -1
- package/dist/es5/utils/format-value.js +0 -57
- package/dist/es5/utils/format-value.js.map +0 -1
- package/dist/es5/utils/is-old-ie.d.ts +0 -1
- package/dist/es5/utils/is-old-ie.js +0 -14
- package/dist/es5/utils/is-old-ie.js.map +0 -1
- package/dist/es5/utils/load-file.js +0 -50
- package/dist/es5/utils/load-file.js.map +0 -1
- package/dist/es5/utils/stub-methods.js +0 -25
- package/dist/es5/utils/stub-methods.js.map +0 -1
- package/dist/es5/utils/utils.d.ts +0 -13
- package/dist/es5/utils/utils.js +0 -36
- package/dist/es5/utils/utils.js.map +0 -1
- package/dist/es5/webgl-utils/request-animation-frame.d.ts +0 -3
- package/dist/es5/webgl-utils/texture-utils.d.ts +0 -11
- package/dist/es5/webgl-utils/typed-array-utils.d.ts +0 -36
- package/dist/esm/classes/buffer.d.ts +0 -84
- package/dist/esm/classes/buffer.js.map +0 -1
- package/dist/esm/classes/clear.d.ts +0 -11
- package/dist/esm/classes/copy-and-blit.d.ts +0 -101
- package/dist/esm/classes/framebuffer.d.ts +0 -96
- package/dist/esm/classes/program-configuration.d.ts +0 -15
- package/dist/esm/classes/program.d.ts +0 -44
- package/dist/esm/classes/query.d.ts +0 -21
- package/dist/esm/classes/renderbuffer.d.ts +0 -34
- package/dist/esm/classes/resource.d.ts +0 -47
- package/dist/esm/classes/resource.js.map +0 -1
- package/dist/esm/classes/shader.d.ts +0 -29
- package/dist/esm/classes/shader.js +0 -138
- package/dist/esm/classes/shader.js.map +0 -1
- package/dist/esm/classes/texture-2d.d.ts +0 -11
- package/dist/esm/classes/texture-3d.d.ts +0 -29
- package/dist/esm/classes/texture-cube.d.ts +0 -23
- package/dist/esm/classes/texture.d.ts +0 -80
- package/dist/esm/classes/transform-feedback.d.ts +0 -16
- package/dist/esm/classes/uniform-buffer-layout.d.ts +0 -18
- package/dist/esm/classes/uniforms.d.ts +0 -63
- package/dist/esm/classes/vertex-array-object.d.ts +0 -25
- package/dist/esm/classes/vertex-array.d.ts +0 -37
- package/dist/esm/debug/debug-program-configuration.d.ts +0 -1
- package/dist/esm/debug/debug-uniforms.d.ts +0 -11
- package/dist/esm/debug/debug-vertex-array.d.ts +0 -1
- package/dist/esm/features/check-glsl-extension.js +0 -27
- package/dist/esm/features/check-glsl-extension.js.map +0 -1
- package/dist/esm/features/check-old-ie.js.map +0 -1
- package/dist/esm/features/features.js +0 -66
- package/dist/esm/features/features.js.map +0 -1
- package/dist/esm/features/index.js +0 -5
- package/dist/esm/features/index.js.map +0 -1
- package/dist/esm/features/limits.js +0 -52
- package/dist/esm/features/limits.js.map +0 -1
- package/dist/esm/features/webgl-features-table.js +0 -71
- package/dist/esm/features/webgl-features-table.js.map +0 -1
- package/dist/esm/features/webgl-limits-table.js +0 -160
- package/dist/esm/features/webgl-limits-table.js.map +0 -1
- package/dist/esm/glsl-utils/format-glsl-error.d.ts +0 -16
- package/dist/esm/glsl-utils/format-glsl-error.js +0 -93
- package/dist/esm/glsl-utils/format-glsl-error.js.map +0 -1
- package/dist/esm/glsl-utils/get-shader-name.js +0 -6
- package/dist/esm/glsl-utils/get-shader-name.js.map +0 -1
- package/dist/esm/glsl-utils/get-shader-type-name.js +0 -15
- package/dist/esm/glsl-utils/get-shader-type-name.js.map +0 -1
- package/dist/esm/glsl-utils/get-shader-version.js +0 -15
- package/dist/esm/glsl-utils/get-shader-version.js.map +0 -1
- package/dist/esm/glsl-utils/index.js +0 -5
- package/dist/esm/glsl-utils/index.js.map +0 -1
- package/dist/esm/index.d.ts +0 -71
- package/dist/esm/init.d.ts +0 -12
- package/dist/esm/types.d.ts +0 -8
- package/dist/esm/utils/array-utils-flat.js +0 -39
- package/dist/esm/utils/array-utils-flat.js.map +0 -1
- package/dist/esm/utils/assert.d.ts +0 -1
- package/dist/esm/utils/assert.js +0 -6
- package/dist/esm/utils/assert.js.map +0 -1
- package/dist/esm/utils/check-props.js +0 -38
- package/dist/esm/utils/check-props.js.map +0 -1
- package/dist/esm/utils/format-value.js +0 -50
- package/dist/esm/utils/format-value.js.map +0 -1
- package/dist/esm/utils/is-old-ie.d.ts +0 -1
- package/dist/esm/utils/is-old-ie.js +0 -5
- package/dist/esm/utils/is-old-ie.js.map +0 -1
- package/dist/esm/utils/load-file.js +0 -30
- package/dist/esm/utils/load-file.js.map +0 -1
- package/dist/esm/utils/stub-methods.js +0 -17
- package/dist/esm/utils/stub-methods.js.map +0 -1
- package/dist/esm/utils/utils.d.ts +0 -13
- package/dist/esm/utils/utils.js +0 -22
- package/dist/esm/utils/utils.js.map +0 -1
- package/dist/esm/webgl-utils/request-animation-frame.d.ts +0 -3
- package/dist/esm/webgl-utils/texture-utils.d.ts +0 -11
- package/dist/esm/webgl-utils/typed-array-utils.d.ts +0 -36
- package/src/bundle.js +0 -8
- package/src/classes/buffer.d.ts +0 -84
- package/src/classes/clear.d.ts +0 -11
- package/src/classes/copy-and-blit.d.ts +0 -101
- package/src/classes/framebuffer.d.ts +0 -96
- package/src/classes/program-configuration.d.ts +0 -15
- package/src/classes/program.d.ts +0 -44
- package/src/classes/query.d.ts +0 -21
- package/src/classes/renderbuffer.d.ts +0 -34
- package/src/classes/renderbuffer.js +0 -105
- package/src/classes/resource.d.ts +0 -47
- package/src/classes/shader.d.ts +0 -29
- package/src/classes/shader.js +0 -147
- package/src/classes/texture-2d.d.ts +0 -11
- package/src/classes/texture-2d.js +0 -30
- package/src/classes/texture-3d.d.ts +0 -29
- package/src/classes/texture-cube.d.ts +0 -23
- package/src/classes/texture.d.ts +0 -80
- package/src/classes/transform-feedback.d.ts +0 -16
- package/src/classes/uniform-buffer-layout.d.ts +0 -18
- package/src/classes/uniforms.d.ts +0 -63
- package/src/classes/vertex-array-object.d.ts +0 -25
- package/src/classes/vertex-array.d.ts +0 -37
- package/src/debug/debug-program-configuration.d.ts +0 -1
- package/src/debug/debug-uniforms.d.ts +0 -11
- package/src/debug/debug-vertex-array.d.ts +0 -1
- package/src/features/check-glsl-extension.js +0 -34
- package/src/features/features.js +0 -79
- package/src/features/index.js +0 -5
- package/src/features/limits.js +0 -65
- package/src/features/webgl-features-table.js +0 -104
- package/src/features/webgl-limits-table.js +0 -51
- package/src/glsl-utils/format-glsl-error.d.ts +0 -16
- package/src/glsl-utils/format-glsl-error.js +0 -107
- package/src/glsl-utils/get-shader-name.js +0 -7
- package/src/glsl-utils/get-shader-type-name.js +0 -13
- package/src/glsl-utils/get-shader-version.js +0 -12
- package/src/glsl-utils/index.js +0 -8
- package/src/index.d.ts +0 -71
- package/src/index.js +0 -70
- package/src/init.d.ts +0 -12
- package/src/utils/array-utils-flat.js +0 -56
- package/src/utils/assert.d.ts +0 -1
- package/src/utils/assert.js +0 -7
- package/src/utils/check-props.js +0 -68
- package/src/utils/format-value.js +0 -37
- package/src/utils/is-old-ie.d.ts +0 -1
- package/src/utils/is-old-ie.js +0 -6
- package/src/utils/load-file.js +0 -39
- package/src/utils/stub-methods.js +0 -20
- package/src/utils/utils.d.ts +0 -13
- package/src/utils/utils.js +0 -36
- package/src/webgl-utils/request-animation-frame.d.ts +0 -3
- package/src/webgl-utils/texture-utils.d.ts +0 -11
- package/src/webgl-utils/typed-array-utils.d.ts +0 -36
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../src/classes/webgl-resource.ts"],"names":["Resource","assert","uid","stubRemovedMethods","isWebGL2","assertWebGLContext","getKey","getKeyValue","WebGLDevice","ERR_RESOURCE_METHOD_UNDEFINED","WebGLResource","constructor","device","props","defaultProps","attach","gl","id","userData","gl2","name","_handle","handle","undefined","_createHandle","byteLength","toString","delete","deleteChildren","children","_deleteHandle","removeStats","filter","Boolean","forEach","child","bind","funcOrHandle","_bindHandle","value","_bound","unbind","getParameter","pname","parameters","PARAMETERS","parameter","isWebgl2","parameterAvailable","getExtension","extension","webgl1Default","webgl1","webgl2Default","webgl2","defaultValue","_getParameter","getParameters","options","keys","values","parameterKeys","Object","key","type","setParameter","Error","_setParameter","setParameters","className","version","methodNames","initialize","_getOptsFromHandle"],"mappings":";AACA,SAAQA,QAAR,EAAkBC,MAAlB,EAA0BC,GAA1B,EAA+BC,kBAA/B,QAAwD,cAAxD;AAGA,SAAQC,QAAR,EAAkBC,kBAAlB,QAA2C,iCAA3C;AACA,SAAQC,MAAR,EAAgBC,WAAhB,QAAkC,kCAAlC;AACA,OAAOC,WAAP,MAAwB,wBAAxB;AAEA,MAAMC,6BAA6B,GAAG,+CAAtC;AAKC,eAAe,MAAMC,aAAN,SAAmCV,QAAnC,CAAmD;AAYjEW,EAAAA,WAAW,CAACC,MAAD,EAAiBC,KAAjB,EAA+BC,YAA/B,EAA8D;AACvE,UAAMF,MAAN,EAAcC,KAAd,EAAqBC,YAArB;;AADuE;;AAAA;;AAAA;;AAAA;;AAAA;;AAAA;;AAAA,oCAJxD,KAIwD;;AAAA,wCAF5D,CAE4D;;AAGvE,SAAKF,MAAL,GAAcJ,WAAW,CAACO,MAAZ,CAAmBH,MAAnB,CAAd;AACA,UAAMI,EAAE,GAAG,KAAKJ,MAAL,CAAYI,EAAvB;AAEAX,IAAAA,kBAAkB,CAACW,EAAD,CAAlB;AAIA,UAAM;AAACC,MAAAA,EAAD;AAAKC,MAAAA,QAAQ,GAAG;AAAhB,QAAsBL,KAAK,IAAI,EAArC;AACA,SAAKG,EAAL,GAAUA,EAAV;AACA,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AAW,CAAChB,MAAD,EAAS;AAClB,UAAM,IAAI4C,KAAJ,CAAUzD,6BAAV,CAAN;AACD;;AAEDgE,EAAAA,kBAAkB,GAAG;AACnB,UAAM,IAAIP,KAAJ,CAAUzD,6BAAV,CAAN;AACD;;AAED+C,EAAAA,aAAa,CAACb,KAAD,EAAQ9B,KAAR,EAAuB;AAClC,UAAM,IAAIqD,KAAJ,CAAUzD,6BAAV,CAAN;AACD;;AAED0D,EAAAA,aAAa,CAACxB,KAAD,EAAQJ,KAAR,EAAe;AAC1B,UAAM,IAAI2B,KAAJ,CAAUzD,6BAAV,CAAN;AACD;;AA1QgE","sourcesContent":["// luma.gl, MIT license\nimport {Resource, assert, uid, stubRemovedMethods} from '@luma.gl/api';\nimport type {Device} from '@luma.gl/api';\nexport type {ResourceProps} from '@luma.gl/api';\nimport {isWebGL2, assertWebGLContext} from '../context/context/webgl-checks';\nimport {getKey, getKeyValue} from '../webgl-utils/constants-to-keys';\nimport WebGLDevice from '../device/webgl-device';\n\nconst ERR_RESOURCE_METHOD_UNDEFINED = 'Resource subclass must define virtual methods';\n\n/**\n * Base class for WebGL object wrappers\n */\n export default class WebGLResource<Props> extends Resource<Props> {\n id: string;\n userData: any;\n readonly device: WebGLDevice;\n readonly gl: WebGLRenderingContext;\n readonly gl2: WebGL2RenderingContext;\n private _handle: any;\n\n private _bound = false;\n // Only meaningful for resources that allocate GPU memory\n byteLength = 0;\n\n constructor(device: Device, props: Props, defaultProps: Required<Props>) {\n super(device, props, defaultProps);\n\n this.device = WebGLDevice.attach(device);\n const gl = this.device.gl;\n\n assertWebGLContext(gl);\n\n // extends \n // @ts-expect-error\n const {id, userData = {}} = props || {};\n this.gl = gl;\n this.gl2 = gl as WebGL2RenderingContext;\n this.id = id || uid(this.constructor.name);\n this.userData = userData;\n\n // Set the handle\n // If handle was provided, use it, otherwise create a new handle\n\n // TODO - Stores the handle with context loss information\n // this.glCount = glGetContextLossCount(this.gl);\n\n // Default VertexArray needs to be created with null handle, so compare against undefined\n // @ts-expect-error\n this._handle = props?.handle;\n if (this._handle === undefined) {\n this._handle = this._createHandle();\n }\n\n this.byteLength = 0;\n }\n\n toString(): string {\n return `${this.constructor.name}(${this.id})`;\n }\n\n get handle() {\n // TODO - Add context loss handling\n // Will regenerate and reinitialize the handle if necessary\n // const glCount = glGetContextLossCount(this.gl);\n // if (this.glCount !== glCount) {\n // this._handle = this._createHandle(this.props);\n // this._glCount = glCount;\n // // Reinitialize object\n // this.initialize(this.props);\n // }\n return this._handle;\n }\n\n delete({deleteChildren = false} = {}) {\n // Delete this object, and get refs to any children\n // @ts-expect-error\n const children = this._handle && this._deleteHandle(this._handle);\n if (this._handle) {\n this.removeStats();\n }\n this._handle = null;\n\n // Optionally, recursively delete the children\n // @ts-expect-error\n if (children && deleteChildren) {\n // @ts-expect-error\n children.filter(Boolean).forEach((child) => child.delete());\n }\n\n return this;\n }\n\n bind(funcOrHandle = this.handle) {\n if (typeof funcOrHandle !== 'function') {\n this._bindHandle(funcOrHandle);\n return this;\n }\n\n let value;\n\n if (!this._bound) {\n this._bindHandle(this.handle);\n this._bound = true;\n\n value = funcOrHandle();\n\n this._bound = false;\n this._bindHandle(null);\n } else {\n value = funcOrHandle();\n }\n\n return value;\n }\n\n unbind() {\n this.bind(null);\n }\n\n /**\n * Query a Resource parameter\n *\n * @param name\n * @return param\n */\n getParameter(pname: number, props = {}): any {\n pname = getKeyValue(this.gl, pname);\n assert(pname);\n\n // @ts-expect-error\n const parameters = this.constructor.PARAMETERS || {};\n\n // Use parameter definitions to handle unsupported parameters\n const parameter = parameters[pname];\n if (parameter) {\n const isWebgl2 = isWebGL2(this.gl);\n\n // Check if we can query for this parameter\n const parameterAvailable =\n (!('webgl2' in parameter) || isWebgl2) &&\n (!('extension' in parameter) || this.gl.getExtension(parameter.extension));\n\n if (!parameterAvailable) {\n const webgl1Default = parameter.webgl1;\n const webgl2Default = 'webgl2' in parameter ? parameter.webgl2 : parameter.webgl1;\n const defaultValue = isWebgl2 ? webgl2Default : webgl1Default;\n return defaultValue;\n }\n }\n\n // If unknown parameter - Could be a valid parameter not covered by PARAMS\n // Attempt to query for it and let WebGL report errors\n return this._getParameter(pname, props);\n }\n\n // Many resources support a getParameter call -\n // getParameters will get all parameters - slow but useful for debugging\n // eslint-disable-next-line complexity\n getParameters(options: {parameters?, keys?} = {}) {\n const {parameters, keys} = options;\n\n // Get parameter definitions for this Resource\n // @ts-expect-error\n const PARAMETERS = this.constructor.PARAMETERS || {};\n\n const isWebgl2 = isWebGL2(this.gl);\n\n const values = {};\n\n // Query all parameters if no list provided\n const parameterKeys = parameters || Object.keys(PARAMETERS);\n\n // WEBGL limits\n for (const pname of parameterKeys) {\n const parameter = PARAMETERS[pname];\n\n // Check if this parameter is available on this platform\n const parameterAvailable =\n parameter &&\n (!('webgl2' in parameter) || isWebgl2) &&\n (!('extension' in parameter) || this.gl.getExtension(parameter.extension));\n\n if (parameterAvailable) {\n const key = keys ? getKey(this.gl, pname) : pname;\n values[key] = this.getParameter(pname, options);\n if (keys && parameter.type === 'GLenum') {\n values[key] = getKey(this.gl, values[key]);\n }\n }\n }\n\n return values;\n }\n\n /**\n * Update a Resource setting\n *\n * @todo - cache parameter to avoid issuing WebGL calls?\n *\n * @param {string} pname - parameter (GL constant, value or key)\n * @param {GLint|GLfloat|GLenum} value\n * @return {Resource} returns self to enable chaining\n */\n setParameter(pname, value) {\n pname = getKeyValue(this.gl, pname);\n assert(pname);\n\n // @ts-expect-error\n const parameters = this.constructor.PARAMETERS || {};\n\n const parameter = parameters[pname];\n if (parameter) {\n const isWebgl2 = isWebGL2(this.gl);\n\n // Check if this parameter is available on this platform\n const parameterAvailable =\n (!('webgl2' in parameter) || isWebgl2) &&\n (!('extension' in parameter) || this.gl.getExtension(parameter.extension));\n\n if (!parameterAvailable) {\n throw new Error('Parameter not available on this platform');\n }\n\n // Handle string keys\n if (parameter.type === 'GLenum') {\n // @ts-expect-error\n value = getKeyValue(value);\n }\n }\n\n // If unknown parameter - Could be a valid parameter not covered by PARAMS\n // attempt to set it and let WebGL report errors\n this._setParameter(pname, value);\n return this;\n }\n\n /*\n * Batch update resource parameters\n * Assumes the subclass supports a setParameter call\n */\n setParameters(parameters) {\n for (const pname in parameters) {\n this.setParameter(pname, parameters[pname]);\n }\n return this;\n }\n\n // Install stubs for removed methods\n stubRemovedMethods(className, version, methodNames) {\n return stubRemovedMethods(this, className, version, methodNames);\n }\n\n // PUBLIC VIRTUAL METHODS\n initialize(props) {}\n\n // PROTECTED METHODS - These must be overridden by subclass\n _createHandle() {\n throw new Error(ERR_RESOURCE_METHOD_UNDEFINED);\n }\n\n _deleteHandle() {\n throw new Error(ERR_RESOURCE_METHOD_UNDEFINED);\n }\n\n _bindHandle(handle) {\n throw new Error(ERR_RESOURCE_METHOD_UNDEFINED);\n }\n\n _getOptsFromHandle() {\n throw new Error(ERR_RESOURCE_METHOD_UNDEFINED);\n }\n\n _getParameter(pname, props): number {\n throw new Error(ERR_RESOURCE_METHOD_UNDEFINED);\n }\n\n _setParameter(pname, value) {\n throw new Error(ERR_RESOURCE_METHOD_UNDEFINED);\n }\n\n // PRIVATE METHODS\n\n /*\n _addStats() {\n const name = this.constructor.name;\n const stats = lumaStats.get('Resource Counts');\n\n stats.get('Resources Created').incrementCount();\n stats.get(`${name}s Created`).incrementCount();\n stats.get(`${name}s Active`).incrementCount();\n }\n\n _removeStats() {\n const name = this.constructor.name;\n const stats = lumaStats.get('Resource Counts');\n\n stats.get(`${name}s Active`).decrementCount();\n }\n\n trackAllocatedMemory(bytes, name = this.constructor.name) {\n const stats = lumaStats.get('Memory Usage');\n\n stats.get('GPU Memory').addCount(bytes);\n stats.get(`${name} Memory`).addCount(bytes);\n this.byteLength = bytes;\n }\n\n trackDeallocatedMemory(name = this.constructor.name) {\n const stats = lumaStats.get('Memory Usage');\n\n stats.get('GPU Memory').subtractCount(this.byteLength);\n stats.get(`${name} Memory`).subtractCount(this.byteLength);\n this.byteLength = 0;\n }\n */\n}\n"],"file":"webgl-resource.js"}
|
|
@@ -0,0 +1,193 @@
|
|
|
1
|
+
import _defineProperty from "@babel/runtime/helpers/esm/defineProperty";
|
|
2
|
+
import { log, assert, uid, Shader as ShaderAPI } from '@luma.gl/api';
|
|
3
|
+
import GL from '@luma.gl/constants';
|
|
4
|
+
import { getShaderInfo, formatCompilerLog } from '@luma.gl/shadertools';
|
|
5
|
+
import { assertWebGLContext } from '../context/context/webgl-checks';
|
|
6
|
+
import { parseShaderCompilerLog } from '../webgl-utils/parse-shader-compiler-log';
|
|
7
|
+
import WebGLDevice from '../device/webgl-device';
|
|
8
|
+
const ERR_SOURCE = 'Shader: GLSL source code must be a JavaScript string';
|
|
9
|
+
export class WEBGLShader extends ShaderAPI {
|
|
10
|
+
constructor(gl, props) {
|
|
11
|
+
super(WebGLDevice.attach(gl), {
|
|
12
|
+
id: getShaderIdFromProps(props),
|
|
13
|
+
...props
|
|
14
|
+
});
|
|
15
|
+
|
|
16
|
+
_defineProperty(this, "device", void 0);
|
|
17
|
+
|
|
18
|
+
_defineProperty(this, "gl", void 0);
|
|
19
|
+
|
|
20
|
+
_defineProperty(this, "handle", void 0);
|
|
21
|
+
|
|
22
|
+
_defineProperty(this, "stage", void 0);
|
|
23
|
+
|
|
24
|
+
this.device = WebGLDevice.attach(gl);
|
|
25
|
+
this.gl = gl;
|
|
26
|
+
|
|
27
|
+
switch (this.props.stage) {
|
|
28
|
+
case 'vertex':
|
|
29
|
+
this.handle = this.props.handle || this.gl.createShader(GL.VERTEX_SHADER);
|
|
30
|
+
break;
|
|
31
|
+
|
|
32
|
+
case 'fragment':
|
|
33
|
+
this.handle = this.props.handle || this.gl.createShader(GL.FRAGMENT_SHADER);
|
|
34
|
+
break;
|
|
35
|
+
|
|
36
|
+
default:
|
|
37
|
+
throw new Error(this.props.stage);
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
this.stage = this.props.stage;
|
|
41
|
+
|
|
42
|
+
this._compile(props.source);
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
destroy() {
|
|
46
|
+
if (this.handle) {
|
|
47
|
+
this.removeStats();
|
|
48
|
+
this.gl.deleteShader(this.handle);
|
|
49
|
+
this.handle = null;
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
async compilationInfo() {
|
|
54
|
+
const log = this.gl.getShaderInfoLog(this.handle);
|
|
55
|
+
return parseShaderCompilerLog(log);
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
_compile(source) {
|
|
59
|
+
if (!source.startsWith('#version ')) {
|
|
60
|
+
source = "#version 100\n".concat(source);
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
this.gl.shaderSource(this.handle, source);
|
|
64
|
+
this.gl.compileShader(this.handle);
|
|
65
|
+
const compileStatus = this.gl.getShaderParameter(this.handle, GL.COMPILE_STATUS);
|
|
66
|
+
|
|
67
|
+
if (!compileStatus) {
|
|
68
|
+
const shaderLog = this.gl.getShaderInfoLog(this.handle);
|
|
69
|
+
const messages = parseShaderCompilerLog(shaderLog).filter(message => message.type === 'error');
|
|
70
|
+
const formattedLog = formatCompilerLog(messages, source);
|
|
71
|
+
const shaderName = getShaderInfo(source).name;
|
|
72
|
+
const shaderDescription = "".concat(this.stage, " shader ").concat(shaderName);
|
|
73
|
+
log.error("GLSL compilation errors in ".concat(shaderName, "\n").concat(formattedLog))();
|
|
74
|
+
throw new Error("GLSL compilation errors in ".concat(shaderName));
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
}
|
|
79
|
+
export class Shader extends WEBGLShader {
|
|
80
|
+
static getTypeName(shaderType) {
|
|
81
|
+
switch (shaderType) {
|
|
82
|
+
case GL.VERTEX_SHADER:
|
|
83
|
+
return 'vertex-shader';
|
|
84
|
+
|
|
85
|
+
case GL.FRAGMENT_SHADER:
|
|
86
|
+
return 'fragment-shader';
|
|
87
|
+
|
|
88
|
+
default:
|
|
89
|
+
assert(false);
|
|
90
|
+
return 'unknown';
|
|
91
|
+
}
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
constructor(gl, props) {
|
|
95
|
+
assertWebGLContext(gl);
|
|
96
|
+
assert(typeof props.source === 'string', ERR_SOURCE);
|
|
97
|
+
super(gl, { ...props,
|
|
98
|
+
id: getShaderIdFromProps(props),
|
|
99
|
+
stage: props.shaderType === GL.VERTEX_SHADER ? 'vertex' : 'fragment'
|
|
100
|
+
});
|
|
101
|
+
|
|
102
|
+
_defineProperty(this, "shaderType", void 0);
|
|
103
|
+
|
|
104
|
+
_defineProperty(this, "source", void 0);
|
|
105
|
+
|
|
106
|
+
this.shaderType = props.shaderType;
|
|
107
|
+
this.source = props.source;
|
|
108
|
+
const shaderName = getShaderInfo(props.source).name;
|
|
109
|
+
|
|
110
|
+
if (shaderName) {
|
|
111
|
+
this.id = uid(shaderName);
|
|
112
|
+
}
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
initialize(props) {
|
|
116
|
+
this._compile(props.source);
|
|
117
|
+
|
|
118
|
+
const shaderName = getShaderInfo(props.source).name;
|
|
119
|
+
|
|
120
|
+
if (shaderName) {
|
|
121
|
+
this.id = uid(shaderName);
|
|
122
|
+
}
|
|
123
|
+
|
|
124
|
+
return this;
|
|
125
|
+
}
|
|
126
|
+
|
|
127
|
+
getParameter(pname) {
|
|
128
|
+
return this.gl.getShaderParameter(this.handle, pname);
|
|
129
|
+
}
|
|
130
|
+
|
|
131
|
+
toString() {
|
|
132
|
+
return "".concat(Shader.getTypeName(this.shaderType), ":").concat(this.id);
|
|
133
|
+
}
|
|
134
|
+
|
|
135
|
+
getName() {
|
|
136
|
+
return getShaderInfo(this.source).name || 'unnamed-shader';
|
|
137
|
+
}
|
|
138
|
+
|
|
139
|
+
getSource() {
|
|
140
|
+
return this.gl.getShaderSource(this.handle);
|
|
141
|
+
}
|
|
142
|
+
|
|
143
|
+
getTranslatedSource() {
|
|
144
|
+
const extension = this.gl.getExtension('WEBGL_debug_shaders');
|
|
145
|
+
return extension ? extension.getTranslatedShaderSource(this.handle) : 'No translated source available. WEBGL_debug_shaders not implemented';
|
|
146
|
+
}
|
|
147
|
+
|
|
148
|
+
_getOptsFromHandle() {
|
|
149
|
+
return {
|
|
150
|
+
type: this.getParameter(GL.SHADER_TYPE),
|
|
151
|
+
source: this.getSource()
|
|
152
|
+
};
|
|
153
|
+
}
|
|
154
|
+
|
|
155
|
+
}
|
|
156
|
+
export class VertexShader extends Shader {
|
|
157
|
+
constructor(gl, props) {
|
|
158
|
+
super(gl, getShaderProps(props, GL.VERTEX_SHADER));
|
|
159
|
+
}
|
|
160
|
+
|
|
161
|
+
_createHandle() {
|
|
162
|
+
return this.gl.createShader(GL.VERTEX_SHADER);
|
|
163
|
+
}
|
|
164
|
+
|
|
165
|
+
}
|
|
166
|
+
export class FragmentShader extends Shader {
|
|
167
|
+
constructor(gl, props) {
|
|
168
|
+
super(gl, getShaderProps(props, GL.FRAGMENT_SHADER));
|
|
169
|
+
}
|
|
170
|
+
|
|
171
|
+
_createHandle() {
|
|
172
|
+
return this.gl.createShader(GL.FRAGMENT_SHADER);
|
|
173
|
+
}
|
|
174
|
+
|
|
175
|
+
}
|
|
176
|
+
|
|
177
|
+
function getShaderProps(props, shaderType) {
|
|
178
|
+
if (typeof props === 'string') {
|
|
179
|
+
return {
|
|
180
|
+
source: props,
|
|
181
|
+
shaderType
|
|
182
|
+
};
|
|
183
|
+
}
|
|
184
|
+
|
|
185
|
+
return { ...props,
|
|
186
|
+
shaderType
|
|
187
|
+
};
|
|
188
|
+
}
|
|
189
|
+
|
|
190
|
+
function getShaderIdFromProps(props) {
|
|
191
|
+
return getShaderInfo(props.source).name || props.id || uid("unnamed ".concat(props.stage || Shader.getTypeName(props.shaderType)));
|
|
192
|
+
}
|
|
193
|
+
//# sourceMappingURL=webgl-shader.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../src/classes/webgl-shader.ts"],"names":["log","assert","uid","Shader","ShaderAPI","GL","getShaderInfo","formatCompilerLog","assertWebGLContext","parseShaderCompilerLog","WebGLDevice","ERR_SOURCE","WEBGLShader","constructor","gl","props","attach","id","getShaderIdFromProps","device","stage","handle","createShader","VERTEX_SHADER","FRAGMENT_SHADER","Error","_compile","source","destroy","removeStats","deleteShader","compilationInfo","getShaderInfoLog","startsWith","shaderSource","compileShader","compileStatus","getShaderParameter","COMPILE_STATUS","shaderLog","messages","filter","message","type","formattedLog","shaderName","name","shaderDescription","error","getTypeName","shaderType","initialize","getParameter","pname","toString","getName","getSource","getShaderSource","getTranslatedSource","extension","getExtension","getTranslatedShaderSource","_getOptsFromHandle","SHADER_TYPE","VertexShader","getShaderProps","_createHandle","FragmentShader"],"mappings":";AACA,SAAQA,GAAR,EAAaC,MAAb,EAAqBC,GAArB,EAA0BC,MAAM,IAAIC,SAApC,QAAiE,cAAjE;AACA,OAAOC,EAAP,MAAe,oBAAf;AACA,SAAQC,aAAR,EAAwCC,iBAAxC,QAAgE,sBAAhE;AACA,SAAQC,kBAAR,QAAiC,iCAAjC;AACA,SAAQC,sBAAR,QAAqC,0CAArC;AACA,OAAOC,WAAP,MAAwB,wBAAxB;AAEA,MAAMC,UAAU,GAAG,sDAAnB;AAKA,OAAO,MAAMC,WAAN,SAA0BR,SAA1B,CAAoC;AAOzCS,EAAAA,WAAW,CAACC,EAAD,EAA4BC,KAA5B,EAAgD;AACzD,UAAML,WAAW,CAACM,MAAZ,CAAmBF,EAAnB,CAAN,EAA8B;AAACG,MAAAA,EAAE,EAAEC,oBAAoB,CAACH,KAAD,CAAzB;AAAkC,SAAGA;AAArC,KAA9B;;AADyD;;AAAA;;AAAA;;AAAA;;AAEzD,SAAKI,MAAL,GAAcT,WAAW,CAACM,MAAZ,CAAmBF,EAAnB,CAAd;AACA,SAAKA,EAAL,GAAUA,EAAV;;AACA,YAAQ,KAAKC,KAAL,CAAWK,KAAnB;AACE,WAAK,QAAL;AACE,aAAKC,MAAL,GAAc,KAAKN,KAAL,CAAWM,MAAX,IAAqB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3B,EAFL;AAGD","sourcesContent":["// luma.gl, MIT license\nimport {log, assert, uid, Shader as ShaderAPI, ShaderProps} from '@luma.gl/api';\nimport GL from '@luma.gl/constants';\nimport {getShaderInfo, CompilerMessage, formatCompilerLog} from '@luma.gl/shadertools';\nimport {assertWebGLContext} from '../context/context/webgl-checks';\nimport {parseShaderCompilerLog} from '../webgl-utils/parse-shader-compiler-log';\nimport WebGLDevice from '../device/webgl-device';\n\nconst ERR_SOURCE = 'Shader: GLSL source code must be a JavaScript string';\n\n\nexport type {ShaderProps};\n\nexport class WEBGLShader extends ShaderAPI {\n readonly device: WebGLDevice;\n readonly gl: WebGLRenderingContext;\n readonly handle: WebGLShader;\n\n readonly stage: 'vertex' | 'fragment';\n\n constructor(gl: WebGLRenderingContext, props: ShaderProps) {\n super(WebGLDevice.attach(gl), {id: getShaderIdFromProps(props), ...props});\n this.device = WebGLDevice.attach(gl);\n this.gl = gl;\n switch (this.props.stage) {\n case 'vertex':\n this.handle = this.props.handle || this.gl.createShader(GL.VERTEX_SHADER);\n break;\n case 'fragment':\n this.handle = this.props.handle || this.gl.createShader(GL.FRAGMENT_SHADER);\n break;\n default:\n throw new Error(this.props.stage);\n }\n this.stage = this.props.stage;\n this._compile(props.source);\n }\n\n destroy(): void {\n if (this.handle) {\n this.removeStats();\n this.gl.deleteShader(this.handle);\n // @ts-expect-error\n this.handle = null;\n }\n } \n \n async compilationInfo(): Promise<readonly CompilerMessage[]> {\n const log = this.gl.getShaderInfoLog(this.handle);\n return parseShaderCompilerLog(log);\n }\n\n // PRIVATE METHODS\n _compile(source) {\n if (!source.startsWith('#version ')) {\n source = `#version 100\\n${source}`;\n }\n this.gl.shaderSource(this.handle, source);\n this.gl.compileShader(this.handle);\n\n // TODO - For performance reasons, avoid checking shader compilation errors on production?\n // TODO - Load log even when no error reported, to catch warnings?\n // https://gamedev.stackexchange.com/questions/30429/how-to-detect-glsl-warnings\n const compileStatus = this.gl.getShaderParameter(this.handle, GL.COMPILE_STATUS);\n if (!compileStatus) {\n const shaderLog = this.gl.getShaderInfoLog(this.handle);\n const messages = parseShaderCompilerLog(shaderLog).filter(message => message.type === 'error');\n const formattedLog = formatCompilerLog(messages, source);\n const shaderName: string = getShaderInfo(source).name;\n const shaderDescription = `${this.stage} shader ${shaderName}`;\n log.error(`GLSL compilation errors in ${shaderName}\\n${formattedLog}`)();\n throw new Error(`GLSL compilation errors in ${shaderName}`);\n }\n }\n}\n \n/**\n * Encapsulates the compiled or linked Shaders that execute portions of the WebGL Pipeline\n * For now this is an internal class\n */\nexport class Shader extends WEBGLShader {\n shaderType: GL.FRAGMENT_SHADER | GL.VERTEX_SHADER;\n source: string;\n\n static getTypeName(shaderType: any): 'vertex-shader' | 'fragment-shader' | 'unknown' {\n switch (shaderType) {\n case GL.VERTEX_SHADER:\n return 'vertex-shader';\n case GL.FRAGMENT_SHADER:\n return 'fragment-shader';\n default:\n assert(false);\n return 'unknown';\n }\n }\n\n constructor(gl: WebGLRenderingContext, props: Omit<ShaderProps, 'stage'>) {\n assertWebGLContext(gl);\n assert(typeof props.source === 'string', ERR_SOURCE);\n\n // @ts-expect-error\n super(gl, {...props, id: getShaderIdFromProps(props), stage: props.shaderType === GL.VERTEX_SHADER ? 'vertex' : 'fragment'});\n\n this.shaderType = props.shaderType;\n this.source = props.source;\n\n const shaderName = getShaderInfo(props.source).name;\n if (shaderName) {\n this.id = uid(shaderName);\n }\n }\n\n initialize(props: ShaderProps): this {\n this._compile(props.source);\n const shaderName = getShaderInfo(props.source).name;\n if (shaderName) {\n this.id = uid(shaderName);\n }\n return this;\n }\n\n // Accessors\n\n getParameter(pname: number): any {\n return this.gl.getShaderParameter(this.handle, pname);\n }\n\n toString(): string {\n return `${Shader.getTypeName(this.shaderType)}:${this.id}`;\n }\n\n getName(): string {\n return getShaderInfo(this.source).name || 'unnamed-shader';\n }\n\n getSource(): string {\n return this.gl.getShaderSource(this.handle);\n }\n\n /** Debug method - Returns translated source if available */\n getTranslatedSource(): string {\n const extension = this.gl.getExtension('WEBGL_debug_shaders');\n return extension\n ? extension.getTranslatedShaderSource(this.handle)\n : 'No translated source available. WEBGL_debug_shaders not implemented';\n }\n\n // PRIVATE METHODS\n\n _getOptsFromHandle() {\n return {\n type: this.getParameter(GL.SHADER_TYPE),\n source: this.getSource()\n };\n }\n}\n\n/**\n * Encapsulates the compiled or linked Shaders that execute portions of the WebGL Pipeline\n * @deprecated Use `device.createShader({stage: 'vertex', ...})`\n */\n export class VertexShader extends Shader {\n constructor(gl: WebGLRenderingContext, props: Omit<ShaderProps, 'stage'> | string) {\n super(gl, getShaderProps(props, GL.VERTEX_SHADER));\n }\n\n // PRIVATE METHODS\n _createHandle() {\n return this.gl.createShader(GL.VERTEX_SHADER);\n }\n}\n\n/**\n * Encapsulates the compiled or linked Shaders that execute portions of the WebGL Pipeline\n * @deprecated Use `device.createShader({stage: 'fragment', ...})`\n */\n export class FragmentShader extends Shader {\n constructor(gl: WebGLRenderingContext, props: Omit<ShaderProps, 'stage'> | string) {\n super(gl, getShaderProps(props, GL.FRAGMENT_SHADER));\n }\n\n // PRIVATE METHODS\n _createHandle() {\n return this.gl.createShader(GL.FRAGMENT_SHADER);\n }\n}\n\n// HELPERS\n\nfunction getShaderProps(props: Omit<ShaderProps, 'stage'> | string, shaderType: GL.VERTEX_SHADER | GL.FRAGMENT_SHADER): Omit<ShaderProps, 'stage'> {\n if (typeof props === 'string') {\n return {source: props, shaderType};\n }\n return {...props, shaderType};\n}\n\n/** Deduce an id, from shader source, or supplied id, or shader type */\nfunction getShaderIdFromProps(props: ShaderProps): string {\n return getShaderInfo(props.source).name ||\n props.id ||\n uid(`unnamed ${props.stage || Shader.getTypeName(props.shaderType)}`);\n}\n"],"file":"webgl-shader.js"}
|
|
@@ -0,0 +1,26 @@
|
|
|
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
|
+
return gl.luma;
|
|
25
|
+
}
|
|
26
|
+
//# sourceMappingURL=context-state.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../../src/context/context/context-state.ts"],"names":["getContextState","gl","device","luma","contextState","_canvasSizeInfo","clientWidth","clientHeight","devicePixelRatio","_polyfilled","_extensions"],"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;;AAED,SAAOH,EAAE,CAACE,IAAV;AACD","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 // @ts-expect-error\n return gl.luma;\n}\n"],"file":"context-state.js"}
|
|
@@ -0,0 +1,37 @@
|
|
|
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 = { ...DEFAULT_CONTEXT_PROPS,
|
|
10
|
+
...props
|
|
11
|
+
};
|
|
12
|
+
let errorMessage = null;
|
|
13
|
+
|
|
14
|
+
const onCreateError = error => errorMessage = error.statusMessage || errorMessage;
|
|
15
|
+
|
|
16
|
+
canvas.addEventListener('webglcontextcreationerror', onCreateError, false);
|
|
17
|
+
let gl = null;
|
|
18
|
+
|
|
19
|
+
if (props.webgl2) {
|
|
20
|
+
gl = gl || canvas.getContext('webgl2', props);
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
if (props.webgl1) {
|
|
24
|
+
gl = gl || canvas.getContext('webgl', props);
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
canvas.removeEventListener('webglcontextcreationerror', onCreateError, false);
|
|
28
|
+
|
|
29
|
+
if (!gl) {
|
|
30
|
+
throw new Error("Failed to create ".concat(props.webgl2 && !props.webgl1 ? 'WebGL2' : 'WebGL', " context: ").concat(errorMessage || 'Unknown error'));
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
canvas.addEventListener('webglcontextlost', props.onContextLost, false);
|
|
34
|
+
canvas.addEventListener('webglcontextrestored', props.onContextRestored, false);
|
|
35
|
+
return gl;
|
|
36
|
+
}
|
|
37
|
+
//# sourceMappingURL=create-context.js.map
|
|
@@ -0,0 +1 @@
|
|
|
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","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;;AAGA,MAAIL,KAAK,CAACV,MAAV,EAAkB;AAChBe,IAAAA,EAAE,GAAGA,EAAE,IAAIN,MAAM,CAACO,UAAP,CAAkB,QAAlB,EAA4BN,KAA5B,CAAX;AACD;;AACD,MAAIA,KAAK,CAACT,MAAV,EAAkB;AAChBc,IAAAA,EAAE,GAAGA,EAAE,IAAIN,MAAM,CAACO,UAAP,CAAkB,OAAlB,EAA2BN,KAA3B,CAAX;AACD;;AAGDD,EAAAA,MAAM,CAACQ,mBAAP,CAA2B,2BAA3B,EAAwDL,aAAxD,EAAuE,KAAvE;;AAEA,MAAI,CAACG,EAAL,EAAS;AACP,UAAM,IAAIG,KAAJ,4BACgBR,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*/\n\ntype ContextProps = {\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 // 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"],"file":"create-context.js"}
|
|
@@ -0,0 +1,98 @@
|
|
|
1
|
+
import { log } from '@luma.gl/api';
|
|
2
|
+
import { getContextState } from './context-state';
|
|
3
|
+
export function cssToDeviceRatio(gl) {
|
|
4
|
+
const state = getContextState(gl);
|
|
5
|
+
|
|
6
|
+
if (gl.canvas && state) {
|
|
7
|
+
const {
|
|
8
|
+
clientWidth
|
|
9
|
+
} = state._canvasSizeInfo;
|
|
10
|
+
return clientWidth ? gl.drawingBufferWidth / clientWidth : 1;
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
return 1;
|
|
14
|
+
}
|
|
15
|
+
export function cssToDevicePixels(gl, cssPixel, yInvert = true) {
|
|
16
|
+
const ratio = cssToDeviceRatio(gl);
|
|
17
|
+
const width = gl.drawingBufferWidth;
|
|
18
|
+
const height = gl.drawingBufferHeight;
|
|
19
|
+
return scalePixels(cssPixel, ratio, width, height, yInvert);
|
|
20
|
+
}
|
|
21
|
+
export function getDevicePixelRatio(useDevicePixels) {
|
|
22
|
+
const windowRatio = typeof window === 'undefined' ? 1 : window.devicePixelRatio || 1;
|
|
23
|
+
|
|
24
|
+
if (Number.isFinite(useDevicePixels)) {
|
|
25
|
+
return useDevicePixels <= 0 ? 1 : useDevicePixels;
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
return useDevicePixels ? windowRatio : 1;
|
|
29
|
+
}
|
|
30
|
+
export function setDevicePixelRatio(gl, devicePixelRatio, options = {}) {
|
|
31
|
+
let clientWidth = 'width' in options ? options.width : gl.canvas.clientWidth;
|
|
32
|
+
let clientHeight = 'height' in options ? options.height : gl.canvas.clientHeight;
|
|
33
|
+
|
|
34
|
+
if (!clientWidth || !clientHeight) {
|
|
35
|
+
log.log(1, 'Canvas clientWidth/clientHeight is 0')();
|
|
36
|
+
devicePixelRatio = 1;
|
|
37
|
+
clientWidth = gl.canvas.width || 1;
|
|
38
|
+
clientHeight = gl.canvas.height || 1;
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
const contextState = getContextState(gl);
|
|
42
|
+
const cachedSize = contextState._canvasSizeInfo;
|
|
43
|
+
|
|
44
|
+
if (cachedSize.clientWidth !== clientWidth || cachedSize.clientHeight !== clientHeight || cachedSize.devicePixelRatio !== devicePixelRatio) {
|
|
45
|
+
let clampedPixelRatio = devicePixelRatio;
|
|
46
|
+
const canvasWidth = Math.floor(clientWidth * clampedPixelRatio);
|
|
47
|
+
const canvasHeight = Math.floor(clientHeight * clampedPixelRatio);
|
|
48
|
+
gl.canvas.width = canvasWidth;
|
|
49
|
+
gl.canvas.height = canvasHeight;
|
|
50
|
+
|
|
51
|
+
if (gl.drawingBufferWidth !== canvasWidth || gl.drawingBufferHeight !== canvasHeight) {
|
|
52
|
+
log.warn("Device pixel ratio clamped")();
|
|
53
|
+
clampedPixelRatio = Math.min(gl.drawingBufferWidth / clientWidth, gl.drawingBufferHeight / clientHeight);
|
|
54
|
+
gl.canvas.width = Math.floor(clientWidth * clampedPixelRatio);
|
|
55
|
+
gl.canvas.height = Math.floor(clientHeight * clampedPixelRatio);
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
Object.assign(contextState._canvasSizeInfo, {
|
|
59
|
+
clientWidth,
|
|
60
|
+
clientHeight,
|
|
61
|
+
devicePixelRatio
|
|
62
|
+
});
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
function scalePixels(pixel, ratio, width, height, yInvert) {
|
|
67
|
+
const x = scaleX(pixel[0], ratio, width);
|
|
68
|
+
let y = scaleY(pixel[1], ratio, height, yInvert);
|
|
69
|
+
let t = scaleX(pixel[0] + 1, ratio, width);
|
|
70
|
+
const xHigh = t === width - 1 ? t : t - 1;
|
|
71
|
+
t = scaleY(pixel[1] + 1, ratio, height, yInvert);
|
|
72
|
+
let yHigh;
|
|
73
|
+
|
|
74
|
+
if (yInvert) {
|
|
75
|
+
t = t === 0 ? t : t + 1;
|
|
76
|
+
yHigh = y;
|
|
77
|
+
y = t;
|
|
78
|
+
} else {
|
|
79
|
+
yHigh = t === height - 1 ? t : t - 1;
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
return {
|
|
83
|
+
x,
|
|
84
|
+
y,
|
|
85
|
+
width: Math.max(xHigh - x + 1, 1),
|
|
86
|
+
height: Math.max(yHigh - y + 1, 1)
|
|
87
|
+
};
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
function scaleX(x, ratio, width) {
|
|
91
|
+
const r = Math.min(Math.round(x * ratio), width - 1);
|
|
92
|
+
return r;
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
function scaleY(y, ratio, height, yInvert) {
|
|
96
|
+
return yInvert ? Math.max(0, height - 1 - Math.round(y * ratio)) : Math.min(Math.round(y * ratio), height - 1);
|
|
97
|
+
}
|
|
98
|
+
//# sourceMappingURL=device-pixels.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../../src/context/context/device-pixels.ts"],"names":["log","getContextState","cssToDeviceRatio","gl","state","canvas","clientWidth","_canvasSizeInfo","drawingBufferWidth","cssToDevicePixels","cssPixel","yInvert","ratio","width","height","drawingBufferHeight","scalePixels","getDevicePixelRatio","useDevicePixels","windowRatio","window","devicePixelRatio","Number","isFinite","setDevicePixelRatio","options","clientHeight","contextState","cachedSize","clampedPixelRatio","canvasWidth","Math","floor","canvasHeight","warn","min","Object","assign","pixel","x","scaleX","y","scaleY","t","xHigh","yHigh","max","r","round"],"mappings":"AAAA,SAAQA,GAAR,QAAkB,cAAlB;AACA,SAAQC,eAAR,QAA8B,iBAA9B;AAKA,OAAO,SAASC,gBAAT,CAA0BC,EAA1B,EAA6D;AAClE,QAAMC,KAAK,GAAGH,eAAe,CAACE,EAAD,CAA7B;;AAEA,MAAIA,EAAE,CAACE,MAAH,IAAaD,KAAjB,EAAwB;AAGtB,UAAM;AAACE,MAAAA;AAAD,QAAgBF,KAAK,CAACG,eAA5B;AACA,WAAOD,WAAW,GAAGH,EAAE,CAACK,kBAAH,GAAwBF,WAA3B,GAAyC,CAA3D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AA,MAAM,EAAEiB,IAAI,CAACe,GAAL,CAASD,KAAK,GAAGJ,CAAR,GAAY,CAArB,EAAwB,CAAxB;AALH,GAAP;AAOD;;AAED,SAASD,MAAT,CAAgBD,CAAhB,EAAmB3B,KAAnB,EAA0BC,KAA1B,EAAiC;AAE/B,QAAMkC,CAAC,GAAGhB,IAAI,CAACI,GAAL,CAASJ,IAAI,CAACiB,KAAL,CAAWT,CAAC,GAAG3B,KAAf,CAAT,EAAgCC,KAAK,GAAG,CAAxC,CAAV;AACA,SAAOkC,CAAP;AACD;;AAED,SAASL,MAAT,CAAgBD,CAAhB,EAAmB7B,KAAnB,EAA0BE,MAA1B,EAAkCH,OAAlC,EAA2C;AAEzC,SAAOA,OAAO,GACVoB,IAAI,CAACe,GAAL,CAAS,CAAT,EAAYhC,MAAM,GAAG,CAAT,GAAaiB,IAAI,CAACiB,KAAL,CAAWP,CAAC,GAAG7B,KAAf,CAAzB,CADU,GAEVmB,IAAI,CAACI,GAAL,CAASJ,IAAI,CAACiB,KAAL,CAAWP,CAAC,GAAG7B,KAAf,CAAT,EAAgCE,MAAM,GAAG,CAAzC,CAFJ;AAGD","sourcesContent":["import {log} from '@luma.gl/api';\nimport {getContextState} from './context-state';\n\n/**\n * Returns multiplier need to convert CSS size to Device size\n */\nexport function cssToDeviceRatio(gl: WebGLRenderingContext): number {\n const state = getContextState(gl);\n\n if (gl.canvas && state) {\n // For headless gl we might have used custom width and height\n // hence use cached clientWidth\n const {clientWidth} = state._canvasSizeInfo;\n return clientWidth ? gl.drawingBufferWidth / clientWidth : 1;\n }\n // use default device pixel ratio\n return 1;\n}\n\n/**\n * Maps CSS pixel position to device pixel position\n */\n export function cssToDevicePixels(\n gl: WebGLRenderingContext,\n cssPixel: number[],\n yInvert: boolean = true\n): {\n x: number;\n y: number;\n width: number;\n height: number;\n} {\n const ratio = cssToDeviceRatio(gl);\n const width = gl.drawingBufferWidth;\n const height = gl.drawingBufferHeight;\n return scalePixels(cssPixel, ratio, width, height, yInvert);\n}\n\n/**\n * Calulates device pixel ratio, used during context creation\n *\n * @param useDevicePixels - boolean or a number\n * @return - device pixel ratio\n */\n export function getDevicePixelRatio(useDevicePixels: boolean | number): number {\n const windowRatio = typeof window === 'undefined' ? 1 : window.devicePixelRatio || 1;\n if (Number.isFinite(useDevicePixels)) {\n // @ts-expect-error Can no longer be boolean after previous line\n return useDevicePixels <= 0 ? 1 : useDevicePixels;\n }\n return useDevicePixels ? windowRatio : 1;\n}\n\n// use devicePixelRatio to set canvas width and height\nexport function setDevicePixelRatio(gl, devicePixelRatio, options: {width?: number, height?: number} = {}) {\n // NOTE: if options.width and options.height not used remove in v8\n let clientWidth = 'width' in options ? options.width : gl.canvas.clientWidth;\n let clientHeight = 'height' in options ? options.height : gl.canvas.clientHeight;\n\n if (!clientWidth || !clientHeight) {\n log.log(1, 'Canvas clientWidth/clientHeight is 0')();\n // by forcing devicePixel ratio to 1, we do not scale gl.canvas.width and height in each frame.\n devicePixelRatio = 1;\n clientWidth = gl.canvas.width || 1;\n clientHeight = gl.canvas.height || 1;\n }\n\n const contextState = getContextState(gl);\n const cachedSize = contextState._canvasSizeInfo;\n // Check if canvas needs to be resized\n if (\n cachedSize.clientWidth !== clientWidth ||\n cachedSize.clientHeight !== clientHeight ||\n cachedSize.devicePixelRatio !== devicePixelRatio\n ) {\n let clampedPixelRatio = devicePixelRatio;\n\n const canvasWidth = Math.floor(clientWidth * clampedPixelRatio);\n const canvasHeight = Math.floor(clientHeight * clampedPixelRatio);\n gl.canvas.width = canvasWidth;\n gl.canvas.height = canvasHeight;\n\n // Note: when devicePixelRatio is too high, it is possible we might hit system limit for\n // drawing buffer width and hight, in those cases they get clamped and resulting aspect ration may not be maintained\n // for those cases, reduce devicePixelRatio.\n if (gl.drawingBufferWidth !== canvasWidth || gl.drawingBufferHeight !== canvasHeight) {\n log.warn(`Device pixel ratio clamped`)();\n clampedPixelRatio = Math.min(\n gl.drawingBufferWidth / clientWidth,\n gl.drawingBufferHeight / clientHeight\n );\n\n gl.canvas.width = Math.floor(clientWidth * clampedPixelRatio);\n gl.canvas.height = Math.floor(clientHeight * clampedPixelRatio);\n }\n\n Object.assign(contextState._canvasSizeInfo, {clientWidth, clientHeight, devicePixelRatio});\n }\n}\n\n\n// PRIVATE\n\nfunction scalePixels(pixel, ratio, width, height, yInvert) {\n const x = scaleX(pixel[0], ratio, width);\n let y = scaleY(pixel[1], ratio, height, yInvert);\n\n // Find boundaries of next pixel to provide valid range of device pixel locaitons\n\n let t = scaleX(pixel[0] + 1, ratio, width);\n // If next pixel's position is clamped to boundary, use it as is, otherwise subtract 1 for current pixel boundary\n const xHigh = t === width - 1 ? t : t - 1;\n\n t = scaleY(pixel[1] + 1, ratio, height, yInvert);\n let yHigh;\n if (yInvert) {\n // If next pixel's position is clamped to boundary, use it as is, otherwise clamp it to valid range\n t = t === 0 ? t : t + 1;\n // swap y and yHigh\n yHigh = y;\n y = t;\n } else {\n // If next pixel's position is clamped to boundary, use it as is, otherwise clamp it to valid range\n yHigh = t === height - 1 ? t : t - 1;\n // y remains same\n }\n return {\n x,\n y,\n // when ratio < 1, current css pixel and next css pixel may point to same device pixel, set width/height to 1 in those cases.\n width: Math.max(xHigh - x + 1, 1),\n height: Math.max(yHigh - y + 1, 1)\n };\n}\n\nfunction scaleX(x, ratio, width) {\n // since we are rounding to nearest, when ratio > 1, edge pixels may point to out of bounds value, clamp to the limit\n const r = Math.min(Math.round(x * ratio), width - 1);\n return r;\n}\n\nfunction scaleY(y, ratio, height, yInvert) {\n // since we are rounding to nearest, when ratio > 1, edge pixels may point to out of bounds value, clamp to the limit\n return yInvert\n ? Math.max(0, height - 1 - Math.round(y * ratio))\n : Math.min(Math.round(y * ratio), height - 1);\n}\n"],"file":"device-pixels.js"}
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import { isBrowser } from 'probe.gl/env';
|
|
2
|
+
const isPage = isBrowser() && typeof document !== 'undefined';
|
|
3
|
+
export function getCanvas(options) {
|
|
4
|
+
const {
|
|
5
|
+
canvas,
|
|
6
|
+
width = 800,
|
|
7
|
+
height = 600
|
|
8
|
+
} = options;
|
|
9
|
+
|
|
10
|
+
if (!canvas) {
|
|
11
|
+
const targetCanvas = document.createElement('canvas');
|
|
12
|
+
targetCanvas.id = 'lumagl-canvas';
|
|
13
|
+
targetCanvas.style.width = Number.isFinite(width) ? "".concat(width, "px") : '100%';
|
|
14
|
+
targetCanvas.style.height = Number.isFinite(height) ? "".concat(height, "px") : '100%';
|
|
15
|
+
document.body.insertBefore(targetCanvas, document.body.firstChild);
|
|
16
|
+
return targetCanvas;
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
if (typeof canvas === 'string') {
|
|
20
|
+
const isPageLoaded = isPage && document.readyState === 'complete';
|
|
21
|
+
|
|
22
|
+
if (!isPageLoaded) {
|
|
23
|
+
throw new Error("createGLContext called on canvas '".concat(canvas, "' before page was loaded"));
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
return document.getElementById(canvas);
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
return canvas;
|
|
30
|
+
}
|
|
31
|
+
//# sourceMappingURL=get-canvas.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../../src/context/context/get-canvas.ts"],"names":["isBrowser","isPage","document","getCanvas","options","canvas","width","height","targetCanvas","createElement","id","style","Number","isFinite","body","insertBefore","firstChild","isPageLoaded","readyState","Error","getElementById"],"mappings":"AACA,SAAQA,SAAR,QAAwB,cAAxB;AACA,MAAMC,MAAM,GAAGD,SAAS,MAAM,OAAOE,QAAP,KAAoB,WAAlD;AAQA,OAAO,SAASC,SAAT,CAAmBC,OAAnB,EAIiC;AACtC,QAAM;AAACC,IAAAA,MAAD;AAASC,IAAAA,KAAK,GAAG,GAAjB;AAAsBC,IAAAA,MAAM,GAAG;AAA/B,MAAsCH,OAA5C;;AAEA,MAAI,CAACC,MAAL,EAAa;AACX,UAAMG,YAAY,GAAGN,QAAQ,CAACO,aAAT,CAAuB,QAAvB,CAArB;AACAD,IAAAA,YAAY,CAACE,EAAb,GAAkB,eAAlB;AACAF,IAAAA,YAAY,CAACG,KAAb,CAAmBL,KAAnB,GAA2BM,MAAM,CAACC,QAAP,CAAgBP,KAAhB,cAA4BA,KAA5B,UAAwC,MAAnE;AACAE,IAAAA,YAAY,CAACG,KAAb,CAAmBJ,MAAnB,GAA4BK,MAAM,CAACC,QAAP,CAAgBN,MAAhB,cAA6BA,MAA7B,UAA0C,MAAtE;AACAL,IAAAA,QAAQ,CAACY,IAAT,CAAcC,YAAd,CAA2BP,YAA3B,EAAyCN,QAAQ,CAACY,IAAT,CAAcE,UAAvD;AACA,WAAOR,YAAP;AACD;;AAED,MAAI,OAAOH,MAAP,KAAkB,QAAtB,EAAgC;AAC9B,UAAMY,YAAY,GAAGhB,MAAM,IAAIC,QAAQ,CAACgB,UAAT,KAAwB,UAAvD;;AACA,QAAI,CAACD,YAAL,EAAmB;AACjB,YAAM,IAAIE,KAAJ,6CAA+Cd,MAA/C,8BAAN;AACD;;AAED,WAAOH,QAAQ,CAACkB,cAAT,CAAwBf,MAAxB,CAAP;AACD;;AAED,SAAOA,MAAP;AACD","sourcesContent":["// luma.gl, MIT license\nimport {isBrowser} from 'probe.gl/env';\nconst isPage = isBrowser() && typeof document !== 'undefined';\n\n/**\n * Creates a new canvas or returns the HTML element for a canvas.\n * @param width\n * @param height\n * @returns\n */\nexport function getCanvas(options: {\n canvas?: string | HTMLCanvasElement | OffscreenCanvas,\n width: number,\n height: number\n}): HTMLCanvasElement | OffscreenCanvas {\n const {canvas, width = 800, height = 600} = options;\n\n if (!canvas) {\n const targetCanvas = document.createElement('canvas');\n targetCanvas.id = 'lumagl-canvas';\n targetCanvas.style.width = Number.isFinite(width) ? `${width}px` : '100%';\n targetCanvas.style.height = Number.isFinite(height) ? `${height}px` : '100%';\n document.body.insertBefore(targetCanvas, document.body.firstChild);\n return targetCanvas;\n }\n\n if (typeof canvas === 'string') {\n const isPageLoaded = isPage && document.readyState === 'complete';\n if (!isPageLoaded) {\n throw new Error(`createGLContext called on canvas '${canvas}' before page was loaded`);\n }\n // TODO - check type?\n return document.getElementById(canvas) as HTMLCanvasElement;\n }\n\n return canvas;\n}\n"],"file":"get-canvas.js"}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { getDevicePixelRatio, setDevicePixelRatio } from "./device-pixels";
|
|
2
|
+
export function resizeGLContext(gl, options) {
|
|
3
|
+
if (gl.canvas) {
|
|
4
|
+
const devicePixelRatio = getDevicePixelRatio(options === null || options === void 0 ? void 0 : options.useDevicePixels);
|
|
5
|
+
setDevicePixelRatio(gl, devicePixelRatio, options);
|
|
6
|
+
return;
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
const ext = gl.getExtension('STACKGL_resize_drawingbuffer');
|
|
10
|
+
|
|
11
|
+
if (ext && options && "width" in options && "height" in options) {
|
|
12
|
+
ext.resize(options.width, options.height);
|
|
13
|
+
}
|
|
14
|
+
}
|
|
15
|
+
//# sourceMappingURL=resize-context.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../../src/context/context/resize-context.ts"],"names":["getDevicePixelRatio","setDevicePixelRatio","resizeGLContext","gl","options","canvas","devicePixelRatio","useDevicePixels","ext","getExtension","resize","width","height"],"mappings":"AACA,SAASA,mBAAT,EAA8BC,mBAA9B,QAAyD,iBAAzD;AAeC,OAAO,SAASC,eAAT,CACNC,EADM,EAENC,OAFM,EAON;AAEA,MAAID,EAAE,CAACE,MAAP,EAAe;AACb,UAAMC,gBAAgB,GAAGN,mBAAmB,CAACI,OAAD,aAACA,OAAD,uBAACA,OAAO,CAAEG,eAAV,CAA5C;AACAN,IAAAA,mBAAmB,CAACE,EAAD,EAAKG,gBAAL,EAAuBF,OAAvB,CAAnB;AACA;AACD;;AAGD,QAAMI,GAAG,GAAGL,EAAE,CAACM,YAAH,CAAgB,8BAAhB,CAAZ;;AACA,MAAID,GAAG,IAAIJ,OAAP,IAAkB,WAAWA,OAA7B,IAAwC,YAAYA,OAAxD,EAAiE;AAC/DI,IAAAA,GAAG,CAACE,MAAJ,CAAWN,OAAO,CAACO,KAAnB,EAA0BP,OAAO,CAACQ,MAAlC;AACD;AACF","sourcesContent":["// luma.gl, MIT license\nimport { getDevicePixelRatio, setDevicePixelRatio } from \"./device-pixels\";\n/**\n * Resize the canvas' drawing buffer.\n *\n * Can match the canvas CSS size, and optionally also consider devicePixelRatio\n * Can be called every frame\n *\n * Regardless of size, the drawing buffer will always be scaled to the viewport, but\n * for best visual results, usually set to either:\n * canvas CSS width x canvas CSS height\n * canvas CSS width * devicePixelRatio x canvas CSS height * devicePixelRatio\n * See http://webgl2fundamentals.org/webgl/lessons/webgl-resizing-the-canvas.html\n *\n * resizeGLContext(gl, {width, height, useDevicePixels})\n */\n export function resizeGLContext(\n gl: WebGLRenderingContext,\n options?: {\n width?: number;\n height?: number;\n useDevicePixels?: boolean | number;\n }\n) {\n // Resize browser context .\n if (gl.canvas) {\n const devicePixelRatio = getDevicePixelRatio(options?.useDevicePixels);\n setDevicePixelRatio(gl, devicePixelRatio, options);\n return;\n }\n\n // Resize headless gl context\n const ext = gl.getExtension('STACKGL_resize_drawingbuffer');\n if (ext && options && `width` in options && `height` in options) {\n ext.resize(options.width, options.height);\n }\n}\n"],"file":"resize-context.js"}
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import { assert } from '@luma.gl/api';
|
|
2
|
+
const ERR_CONTEXT = 'Invalid WebGLRenderingContext';
|
|
3
|
+
export const ERR_WEBGL = ERR_CONTEXT;
|
|
4
|
+
export const ERR_WEBGL2 = 'Requires WebGL2';
|
|
5
|
+
export function isWebGL(gl) {
|
|
6
|
+
if (typeof WebGLRenderingContext !== 'undefined' && gl instanceof WebGLRenderingContext) {
|
|
7
|
+
return true;
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
if (typeof WebGL2RenderingContext !== 'undefined' && gl instanceof WebGL2RenderingContext) {
|
|
11
|
+
return true;
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
return Boolean(gl && Number.isFinite(gl._version));
|
|
15
|
+
}
|
|
16
|
+
export function isWebGL2(gl) {
|
|
17
|
+
if (typeof WebGL2RenderingContext !== 'undefined' && gl instanceof WebGL2RenderingContext) {
|
|
18
|
+
return true;
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
return Boolean(gl && gl._version === 2);
|
|
22
|
+
}
|
|
23
|
+
export function getWebGL2Context(gl) {
|
|
24
|
+
return isWebGL2(gl) ? gl : null;
|
|
25
|
+
}
|
|
26
|
+
export function assertWebGLContext(gl) {
|
|
27
|
+
assert(isWebGL(gl), ERR_CONTEXT);
|
|
28
|
+
return gl;
|
|
29
|
+
}
|
|
30
|
+
export function assertWebGL2Context(gl) {
|
|
31
|
+
assert(isWebGL2(gl), ERR_WEBGL2);
|
|
32
|
+
return gl;
|
|
33
|
+
}
|
|
34
|
+
//# sourceMappingURL=webgl-checks.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../../src/context/context/webgl-checks.ts"],"names":["assert","ERR_CONTEXT","ERR_WEBGL","ERR_WEBGL2","isWebGL","gl","WebGLRenderingContext","WebGL2RenderingContext","Boolean","Number","isFinite","_version","isWebGL2","getWebGL2Context","assertWebGLContext","assertWebGL2Context"],"mappings":"AACA,SAAQA,MAAR,QAAqB,cAArB;AAEA,MAAMC,WAAW,GAAG,+BAApB;AACA,OAAO,MAAMC,SAAS,GAAGD,WAAlB;AACP,OAAO,MAAME,UAAU,GAAG,iBAAnB;AAIP,OAAO,SAASC,OAAT,CAAiBC,EAAjB,EAAmC;AACxC,MAAI,OAAOC,qBAAP,KAAiC,WAAjC,IAAgDD,EAAE,YAAYC,qBAAlE,EAAyF;AACvF,WAAO,IAAP;AACD;;AACD,MAAI,OAAOC,sBAAP,KAAkC,WAAlC,IAAiDF,EAAE,YAAYE,sBAAnE,EAA2F;AACzF,WAAO,IAAP;AACD;;AAED,SAAOC,OAAO,CAACH,EAAE,IAAII,MAAM,CAACC,QAAP,CAAgBL,EAAE,CAACM,QAAnB,CAAP,CAAd;AACD;AAID,OAAO,SAASC,QAAT,CAAkBP,EAAlB,EAAoC;AACzC,MAAI,OAAOE,sBAAP,KAAkC,WAAlC,IAAiDF,EAAE,YAAYE,sBAAnE,EAA2F;AACzF,WAAO,IAAP;AACD;;AAED,SAAOC,OAAO,CAACH,EAAE,IAAIA,EAAE,CAACM,QAAH,KAAgB,CAAvB,CAAd;AACD;AAID,OAAO,SAASE,gBAAT,CAA0BR,EAA1B,EAAoF;AAEzF,SAAOO,QAAQ,CAACP,EAAD,CAAR,GAAeA,EAAf,GAAoB,IAA3B;AACD;AAID,OAAO,SAASS,kBAAT,CAA4BT,EAA5B,EAA4D;AACjEL,EAAAA,MAAM,CAACI,OAAO,CAACC,EAAD,CAAR,EAAcJ,WAAd,CAAN;AACA,SAAOI,EAAP;AACD;AAGD,OAAO,SAASU,mBAAT,CAA6BV,EAA7B,EAA8D;AACnEL,EAAAA,MAAM,CAACY,QAAQ,CAACP,EAAD,CAAT,EAAeF,UAAf,CAAN;AACA,SAAOE,EAAP;AACD","sourcesContent":["// luma.gl, MIT license\nimport {assert} from '@luma.gl/api';\n\nconst ERR_CONTEXT = 'Invalid WebGLRenderingContext';\nexport const ERR_WEBGL = ERR_CONTEXT;\nexport const ERR_WEBGL2 = 'Requires WebGL2';\n\n\n/** Check if supplied parameter is a WebGLRenderingContext */\nexport function isWebGL(gl: any): boolean {\n if (typeof WebGLRenderingContext !== 'undefined' && gl instanceof WebGLRenderingContext) {\n return true;\n }\n if (typeof WebGL2RenderingContext !== 'undefined' && gl instanceof WebGL2RenderingContext) {\n return true;\n }\n // Look for debug contexts, headless gl etc\n return Boolean(gl && Number.isFinite(gl._version));\n}\n\n\n/** Check if supplied parameter is a WebGL2RenderingContext */\nexport function isWebGL2(gl: any): boolean {\n if (typeof WebGL2RenderingContext !== 'undefined' && gl instanceof WebGL2RenderingContext) {\n return true;\n }\n // Look for debug contexts, headless gl etc\n return Boolean(gl && gl._version === 2);\n}\n\n\n/** Returns a properly typed WebGL2RenderingContext from a WebGL1 context, or null */\nexport function getWebGL2Context(gl: WebGLRenderingContext): WebGL2RenderingContext | null {\n // @ts-expect-error\n return isWebGL2(gl) ? gl : null;\n}\n\n\n/** Throw if supplied parameter is not a WebGLRenderingContext, otherwise return properly typed value */\nexport function assertWebGLContext(gl: any): WebGLRenderingContext {\n assert(isWebGL(gl), ERR_CONTEXT);\n return gl;\n}\n\n/** Throw if supplied parameter is not a WebGL2RenderingContext, otherwise return properly typed value */\nexport function assertWebGL2Context(gl: any): WebGL2RenderingContext {\n assert(isWebGL2(gl), ERR_WEBGL2);\n return gl;\n}\n"],"file":"webgl-checks.js"}
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
import { assert } from '@luma.gl/api';
|
|
2
|
+
import { GL_PARAMETER_DEFAULTS, GL_PARAMETER_SETTERS, GL_COMPOSITE_PARAMETER_SETTERS, GL_PARAMETER_GETTERS } from './webgl-parameter-tables';
|
|
3
|
+
import { isWebGL } from '../context/webgl-checks';
|
|
4
|
+
export function setParameters(gl, parameters) {
|
|
5
|
+
assert(isWebGL(gl), 'setParameters requires a WebGL context');
|
|
6
|
+
|
|
7
|
+
if (isObjectEmpty(parameters)) {
|
|
8
|
+
return;
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
const compositeSetters = {};
|
|
12
|
+
|
|
13
|
+
for (const key in parameters) {
|
|
14
|
+
const glConstant = Number(key);
|
|
15
|
+
const setter = GL_PARAMETER_SETTERS[key];
|
|
16
|
+
|
|
17
|
+
if (setter) {
|
|
18
|
+
if (typeof setter === 'string') {
|
|
19
|
+
compositeSetters[setter] = true;
|
|
20
|
+
} else {
|
|
21
|
+
setter(gl, parameters[key], glConstant);
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
const cache = gl.state && gl.state.cache;
|
|
27
|
+
|
|
28
|
+
if (cache) {
|
|
29
|
+
for (const key in compositeSetters) {
|
|
30
|
+
const compositeSetter = GL_COMPOSITE_PARAMETER_SETTERS[key];
|
|
31
|
+
compositeSetter(gl, parameters, cache);
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
export function getParameters(gl, parameters) {
|
|
36
|
+
parameters = parameters || GL_PARAMETER_DEFAULTS;
|
|
37
|
+
|
|
38
|
+
if (typeof parameters === 'number') {
|
|
39
|
+
const key = parameters;
|
|
40
|
+
const getter = GL_PARAMETER_GETTERS[key];
|
|
41
|
+
return getter ? getter(gl, key) : gl.getParameter(key);
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
const parameterKeys = Array.isArray(parameters) ? parameters : Object.keys(parameters);
|
|
45
|
+
const state = {};
|
|
46
|
+
|
|
47
|
+
for (const key of parameterKeys) {
|
|
48
|
+
const getter = GL_PARAMETER_GETTERS[key];
|
|
49
|
+
state[key] = getter ? getter(gl, Number(key)) : gl.getParameter(Number(key));
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
return state;
|
|
53
|
+
}
|
|
54
|
+
export function resetParameters(gl) {
|
|
55
|
+
setParameters(gl, GL_PARAMETER_DEFAULTS);
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
function isObjectEmpty(object) {
|
|
59
|
+
for (const key in object) {
|
|
60
|
+
return false;
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
return true;
|
|
64
|
+
}
|
|
65
|
+
//# sourceMappingURL=unified-parameter-api.js.map
|