@luma.gl/webgl 8.6.0-alpha.5 → 9.0.0-alpha.11
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/README.md +3 -67
- package/dist/adapter/converters/device-parameters.d.ts +27 -0
- package/dist/adapter/converters/device-parameters.d.ts.map +1 -0
- package/dist/adapter/converters/{set-device-parameters.js → device-parameters.js} +50 -6
- package/dist/adapter/converters/device-parameters.js.map +1 -0
- package/dist/{classes → adapter/converters}/renderbuffer-formats.d.ts +0 -0
- package/dist/adapter/converters/renderbuffer-formats.d.ts.map +1 -0
- package/dist/{classes → adapter/converters}/renderbuffer-formats.js +1 -1
- package/dist/adapter/converters/renderbuffer-formats.js.map +1 -0
- package/dist/adapter/converters/sampler-parameters.d.ts +19 -0
- package/dist/adapter/converters/sampler-parameters.d.ts.map +1 -0
- package/dist/adapter/converters/sampler-parameters.js +227 -0
- package/dist/adapter/converters/sampler-parameters.js.map +1 -0
- package/dist/adapter/converters/texture-formats.d.ts +93 -0
- package/dist/adapter/converters/texture-formats.d.ts.map +1 -0
- package/dist/adapter/converters/texture-formats.js +954 -0
- package/dist/adapter/converters/texture-formats.js.map +1 -0
- package/dist/adapter/converters/vertex-formats.d.ts +4 -0
- package/dist/adapter/converters/vertex-formats.d.ts.map +1 -0
- package/dist/adapter/converters/vertex-formats.js +35 -0
- package/dist/adapter/converters/vertex-formats.js.map +1 -0
- package/dist/adapter/device-helpers/device-features.d.ts +3 -6
- package/dist/adapter/device-helpers/device-features.d.ts.map +1 -1
- package/dist/adapter/device-helpers/device-features.js +39 -50
- package/dist/adapter/device-helpers/device-features.js.map +1 -1
- package/dist/adapter/device-helpers/device-limits.d.ts +1 -0
- package/dist/adapter/device-helpers/device-limits.d.ts.map +1 -1
- package/dist/adapter/device-helpers/device-limits.js +1 -0
- package/dist/adapter/device-helpers/device-limits.js.map +1 -1
- package/dist/adapter/device-helpers/get-device-info.js +7 -7
- package/dist/adapter/device-helpers/get-device-info.js.map +1 -1
- package/dist/adapter/helpers/attribute-utils.d.ts +11 -0
- package/dist/adapter/helpers/attribute-utils.d.ts.map +1 -0
- package/dist/adapter/helpers/attribute-utils.js +81 -0
- package/dist/adapter/helpers/attribute-utils.js.map +1 -0
- package/dist/adapter/helpers/get-shader-layout.d.ts +55 -0
- package/dist/adapter/helpers/get-shader-layout.d.ts.map +1 -0
- package/dist/adapter/helpers/get-shader-layout.js +330 -0
- package/dist/adapter/helpers/get-shader-layout.js.map +1 -0
- package/dist/{webgl-utils → adapter/helpers}/parse-shader-compiler-log.d.ts +0 -0
- package/dist/adapter/helpers/parse-shader-compiler-log.d.ts.map +1 -0
- package/dist/{esm/webgl-utils → adapter/helpers}/parse-shader-compiler-log.js +0 -0
- package/dist/adapter/helpers/parse-shader-compiler-log.js.map +1 -0
- package/dist/adapter/helpers/set-uniform.d.ts +4 -0
- package/dist/adapter/helpers/set-uniform.d.ts.map +1 -0
- package/dist/adapter/helpers/set-uniform.js +115 -0
- package/dist/adapter/helpers/set-uniform.js.map +1 -0
- package/dist/adapter/helpers/uniforms.d.ts +26 -0
- package/dist/adapter/helpers/uniforms.d.ts.map +1 -0
- package/dist/adapter/helpers/uniforms.js +99 -0
- package/dist/adapter/helpers/uniforms.js.map +1 -0
- package/dist/adapter/objects/constants-to-keys.d.ts +5 -0
- package/dist/adapter/objects/constants-to-keys.d.ts.map +1 -0
- package/dist/{esm/webgl-utils → adapter/objects}/constants-to-keys.js +1 -0
- package/dist/adapter/objects/constants-to-keys.js.map +1 -0
- package/dist/adapter/objects/webgl-renderbuffer.d.ts +40 -0
- package/dist/adapter/objects/webgl-renderbuffer.d.ts.map +1 -0
- package/dist/{esm/classes/renderbuffer.js → adapter/objects/webgl-renderbuffer.js} +38 -72
- package/dist/adapter/objects/webgl-renderbuffer.js.map +1 -0
- package/dist/{classes → adapter/objects}/webgl-resource.d.ts +15 -14
- package/dist/adapter/objects/webgl-resource.d.ts.map +1 -0
- package/dist/{classes → adapter/objects}/webgl-resource.js +7 -3
- package/dist/adapter/objects/webgl-resource.js.map +1 -0
- package/dist/adapter/objects/webgl-vertex-array-object.d.ts +27 -0
- package/dist/adapter/objects/webgl-vertex-array-object.d.ts.map +1 -0
- package/dist/adapter/objects/webgl-vertex-array-object.js +84 -0
- package/dist/adapter/objects/webgl-vertex-array-object.js.map +1 -0
- package/dist/adapter/resources/webgl-buffer.d.ts +27 -0
- package/dist/adapter/resources/webgl-buffer.d.ts.map +1 -0
- package/dist/adapter/resources/webgl-buffer.js +164 -0
- package/dist/adapter/resources/webgl-buffer.js.map +1 -0
- package/dist/adapter/resources/webgl-command-buffer.d.ts +25 -0
- package/dist/adapter/resources/webgl-command-buffer.d.ts.map +1 -0
- package/dist/adapter/resources/webgl-command-buffer.js +65 -0
- package/dist/adapter/resources/webgl-command-buffer.js.map +1 -0
- package/dist/adapter/resources/webgl-command-encoder.d.ts +18 -0
- package/dist/adapter/resources/webgl-command-encoder.d.ts.map +1 -0
- package/dist/adapter/resources/webgl-command-encoder.js +53 -0
- package/dist/adapter/resources/webgl-command-encoder.js.map +1 -0
- package/dist/adapter/resources/webgl-external-texture.d.ts +1 -0
- package/dist/adapter/resources/webgl-external-texture.d.ts.map +1 -0
- package/dist/adapter/resources/webgl-external-texture.js +2 -0
- package/dist/{es5/helpers/program-bindings.js.map → adapter/resources/webgl-external-texture.js.map} +1 -1
- package/dist/adapter/resources/webgl-framebuffer.d.ts +41 -0
- package/dist/adapter/resources/webgl-framebuffer.d.ts.map +1 -0
- package/dist/adapter/resources/webgl-framebuffer.js +267 -0
- package/dist/adapter/resources/webgl-framebuffer.js.map +1 -0
- package/dist/adapter/resources/webgl-render-pass.d.ts +11 -0
- package/dist/adapter/resources/webgl-render-pass.d.ts.map +1 -0
- package/dist/adapter/resources/webgl-render-pass.js +21 -0
- package/dist/adapter/resources/webgl-render-pass.js.map +1 -0
- package/dist/adapter/resources/webgl-render-pipeline.d.ts +55 -0
- package/dist/adapter/resources/webgl-render-pipeline.d.ts.map +1 -0
- package/dist/adapter/resources/webgl-render-pipeline.js +428 -0
- package/dist/adapter/resources/webgl-render-pipeline.js.map +1 -0
- package/dist/adapter/resources/webgl-sampler.d.ts +20 -0
- package/dist/adapter/resources/webgl-sampler.d.ts.map +1 -0
- package/dist/adapter/resources/webgl-sampler.js +50 -0
- package/dist/adapter/resources/webgl-sampler.js.map +1 -0
- package/dist/adapter/{webgl-shader.d.ts → resources/webgl-shader.d.ts} +3 -6
- package/dist/adapter/resources/webgl-shader.d.ts.map +1 -0
- package/dist/{esm/adapter → adapter/resources}/webgl-shader.js +17 -23
- package/dist/adapter/resources/webgl-shader.js.map +1 -0
- package/dist/adapter/resources/webgl-texture.d.ts +193 -0
- package/dist/adapter/resources/webgl-texture.d.ts.map +1 -0
- package/dist/{classes/texture.js → adapter/resources/webgl-texture.js} +280 -232
- package/dist/adapter/resources/webgl-texture.js.map +1 -0
- package/dist/adapter/webgl-canvas-context.d.ts +36 -0
- package/dist/adapter/webgl-canvas-context.d.ts.map +1 -0
- package/dist/adapter/webgl-canvas-context.js +52 -0
- package/dist/adapter/webgl-canvas-context.js.map +1 -0
- package/dist/adapter/webgl-device.d.ts +77 -83
- package/dist/adapter/webgl-device.d.ts.map +1 -1
- package/dist/adapter/webgl-device.js +253 -115
- package/dist/adapter/webgl-device.js.map +1 -1
- package/dist/classic/accessor.d.ts +32 -0
- package/dist/classic/accessor.d.ts.map +1 -0
- package/dist/{classes → classic}/accessor.js +33 -1
- package/dist/classic/accessor.js.map +1 -0
- package/dist/{classes/webgl-buffer.d.ts → classic/buffer.d.ts} +28 -33
- package/dist/classic/buffer.d.ts.map +1 -0
- package/dist/{classes/webgl-buffer.js → classic/buffer.js} +67 -57
- package/dist/classic/buffer.js.map +1 -0
- package/dist/{webgl-utils → classic}/typed-array-utils.d.ts +3 -2
- package/dist/classic/typed-array-utils.d.ts.map +1 -0
- package/dist/{esm/webgl-utils → classic}/typed-array-utils.js +0 -0
- package/dist/classic/typed-array-utils.js.map +1 -0
- package/dist/context/context/context-state.d.ts +0 -5
- package/dist/context/context/context-state.d.ts.map +1 -1
- package/dist/context/context/context-state.js +1 -6
- package/dist/context/context/context-state.js.map +1 -1
- package/dist/context/context/{create-context.d.ts → create-browser-context.d.ts} +2 -1
- package/dist/context/context/create-browser-context.d.ts.map +1 -0
- package/dist/{esm/context/context/create-context.js → context/context/create-browser-context.js} +27 -3
- package/dist/context/context/create-browser-context.js.map +1 -0
- package/dist/context/context/create-headless-context.d.ts +9 -0
- package/dist/context/context/create-headless-context.d.ts.map +1 -0
- package/dist/context/context/create-headless-context.js +43 -0
- package/dist/context/context/create-headless-context.js.map +1 -0
- package/dist/context/debug/spector.d.ts +18 -0
- package/dist/context/debug/spector.d.ts.map +1 -0
- package/dist/context/debug/spector.js +76 -0
- package/dist/context/debug/spector.js.map +1 -0
- package/dist/context/debug/webgl-developer-tools.d.ts +19 -0
- package/dist/context/debug/webgl-developer-tools.d.ts.map +1 -0
- package/dist/context/debug/webgl-developer-tools.js +121 -0
- package/dist/context/debug/webgl-developer-tools.js.map +1 -0
- package/dist/context/parameters/unified-parameter-api.d.ts +9 -7
- package/dist/context/parameters/unified-parameter-api.d.ts.map +1 -1
- package/dist/context/parameters/unified-parameter-api.js +9 -8
- package/dist/context/parameters/unified-parameter-api.js.map +1 -1
- package/dist/context/parameters/webgl-parameter-tables.d.ts +40 -36
- package/dist/context/parameters/webgl-parameter-tables.d.ts.map +1 -1
- package/dist/context/parameters/webgl-parameter-tables.js.map +1 -1
- package/dist/context/polyfill/get-parameter-polyfill.js.map +1 -1
- package/dist/context/polyfill/polyfill-context.js +3 -3
- package/dist/context/polyfill/polyfill-context.js.map +1 -1
- package/dist/context/polyfill/polyfill-table.d.ts +1 -1
- package/dist/context/polyfill/polyfill-table.d.ts.map +1 -1
- package/dist/context/polyfill/polyfill-table.js +1 -1
- package/dist/context/polyfill/polyfill-table.js.map +1 -1
- package/dist/context/state-tracker/deep-array-equal.d.ts.map +1 -1
- package/dist/context/state-tracker/deep-array-equal.js.map +1 -1
- package/dist/context/state-tracker/track-context-state.d.ts.map +1 -1
- package/dist/context/state-tracker/track-context-state.js +26 -12
- package/dist/context/state-tracker/track-context-state.js.map +1 -1
- package/dist/context/state-tracker/with-parameters.d.ts +2 -1
- package/dist/context/state-tracker/with-parameters.d.ts.map +1 -1
- package/dist/context/state-tracker/with-parameters.js +6 -2
- package/dist/context/state-tracker/with-parameters.js.map +1 -1
- package/dist/es5/adapter/converters/{set-device-parameters.js → device-parameters.js} +53 -6
- package/dist/es5/adapter/converters/device-parameters.js.map +1 -0
- package/dist/es5/{classes → adapter/converters}/renderbuffer-formats.js +1 -1
- package/dist/es5/adapter/converters/renderbuffer-formats.js.map +1 -0
- package/dist/es5/adapter/converters/sampler-parameters.js +245 -0
- package/dist/es5/adapter/converters/sampler-parameters.js.map +1 -0
- package/dist/es5/adapter/converters/texture-formats.js +1031 -0
- package/dist/es5/adapter/converters/texture-formats.js.map +1 -0
- package/dist/es5/adapter/converters/vertex-formats.js +45 -0
- package/dist/es5/adapter/converters/vertex-formats.js.map +1 -0
- package/dist/es5/adapter/device-helpers/device-features.js +61 -58
- package/dist/es5/adapter/device-helpers/device-features.js.map +1 -1
- package/dist/es5/adapter/device-helpers/device-limits.js +1 -1
- package/dist/es5/adapter/device-helpers/device-limits.js.map +1 -1
- package/dist/es5/adapter/device-helpers/get-device-info.js +7 -7
- package/dist/es5/adapter/device-helpers/get-device-info.js.map +1 -1
- package/dist/es5/adapter/helpers/attribute-utils.js +91 -0
- package/dist/es5/adapter/helpers/attribute-utils.js.map +1 -0
- package/dist/es5/{helpers/get-program-bindings.js → adapter/helpers/get-shader-layout.js} +211 -94
- package/dist/es5/adapter/helpers/get-shader-layout.js.map +1 -0
- package/dist/es5/{webgl-utils → adapter/helpers}/parse-shader-compiler-log.js +0 -0
- package/dist/es5/adapter/helpers/parse-shader-compiler-log.js.map +1 -0
- package/dist/es5/adapter/helpers/set-uniform.js +125 -0
- package/dist/es5/adapter/helpers/set-uniform.js.map +1 -0
- package/dist/es5/adapter/helpers/uniforms.js +112 -0
- package/dist/es5/adapter/helpers/uniforms.js.map +1 -0
- package/dist/es5/{webgl-utils → adapter/objects}/constants-to-keys.js +1 -0
- package/dist/es5/adapter/objects/constants-to-keys.js.map +1 -0
- package/dist/es5/{classes/renderbuffer.js → adapter/objects/webgl-renderbuffer.js} +48 -98
- package/dist/es5/adapter/objects/webgl-renderbuffer.js.map +1 -0
- package/dist/es5/{classes → adapter/objects}/webgl-resource.js +8 -3
- package/dist/es5/adapter/objects/webgl-resource.js.map +1 -0
- package/dist/es5/adapter/objects/webgl-vertex-array-object.js +137 -0
- package/dist/es5/adapter/objects/webgl-vertex-array-object.js.map +1 -0
- package/dist/es5/adapter/resources/webgl-buffer.js +243 -0
- package/dist/es5/adapter/resources/webgl-buffer.js.map +1 -0
- package/dist/es5/adapter/resources/webgl-command-buffer.js +96 -0
- package/dist/es5/adapter/resources/webgl-command-buffer.js.map +1 -0
- package/dist/es5/adapter/resources/webgl-command-encoder.js +98 -0
- package/dist/es5/adapter/resources/webgl-command-encoder.js.map +1 -0
- package/dist/es5/adapter/resources/webgl-external-texture.js +2 -0
- package/dist/{esm/helpers/program-bindings.js.map → es5/adapter/resources/webgl-external-texture.js.map} +1 -1
- package/dist/es5/adapter/resources/webgl-framebuffer.js +346 -0
- package/dist/es5/adapter/resources/webgl-framebuffer.js.map +1 -0
- package/dist/es5/{classes/texture-2d.js → adapter/resources/webgl-render-pass.js} +26 -45
- package/dist/es5/adapter/resources/webgl-render-pass.js.map +1 -0
- package/dist/es5/adapter/resources/webgl-render-pipeline.js +530 -0
- package/dist/es5/adapter/resources/webgl-render-pipeline.js.map +1 -0
- package/dist/es5/adapter/resources/webgl-sampler.js +96 -0
- package/dist/es5/adapter/resources/webgl-sampler.js.map +1 -0
- package/dist/es5/adapter/{webgl-shader.js → resources/webgl-shader.js} +16 -21
- package/dist/es5/adapter/resources/webgl-shader.js.map +1 -0
- package/dist/es5/{classes/texture.js → adapter/resources/webgl-texture.js} +374 -298
- package/dist/es5/adapter/resources/webgl-texture.js.map +1 -0
- package/dist/es5/adapter/webgl-canvas-context.js +94 -0
- package/dist/es5/adapter/webgl-canvas-context.js.map +1 -0
- package/dist/es5/adapter/webgl-device.js +325 -131
- package/dist/es5/adapter/webgl-device.js.map +1 -1
- package/dist/es5/{classes → classic}/accessor.js +25 -1
- package/dist/es5/classic/accessor.js.map +1 -0
- package/dist/es5/{classes/webgl-buffer.js → classic/buffer.js} +88 -72
- package/dist/es5/classic/buffer.js.map +1 -0
- package/dist/es5/{webgl-utils → classic}/typed-array-utils.js +0 -0
- package/dist/es5/classic/typed-array-utils.js.map +1 -0
- package/dist/es5/context/context/context-state.js +1 -6
- package/dist/es5/context/context/context-state.js.map +1 -1
- package/dist/es5/context/context/{create-context.js → create-browser-context.js} +29 -3
- package/dist/es5/context/context/create-browser-context.js.map +1 -0
- package/dist/es5/context/context/create-headless-context.js +60 -0
- package/dist/es5/context/context/create-headless-context.js.map +1 -0
- package/dist/es5/context/debug/spector.js +133 -0
- package/dist/es5/context/debug/spector.js.map +1 -0
- package/dist/es5/context/debug/webgl-developer-tools.js +198 -0
- package/dist/es5/context/debug/webgl-developer-tools.js.map +1 -0
- package/dist/es5/context/parameters/unified-parameter-api.js +15 -9
- package/dist/es5/context/parameters/unified-parameter-api.js.map +1 -1
- package/dist/es5/context/parameters/webgl-parameter-tables.js.map +1 -1
- package/dist/es5/context/polyfill/get-parameter-polyfill.js.map +1 -1
- package/dist/es5/context/polyfill/polyfill-context.js +3 -3
- package/dist/es5/context/polyfill/polyfill-context.js.map +1 -1
- package/dist/es5/context/polyfill/polyfill-table.js +1 -1
- package/dist/es5/context/polyfill/polyfill-table.js.map +1 -1
- package/dist/es5/context/state-tracker/deep-array-equal.js.map +1 -1
- package/dist/es5/context/state-tracker/track-context-state.js +39 -24
- package/dist/es5/context/state-tracker/track-context-state.js.map +1 -1
- package/dist/es5/context/state-tracker/with-parameters.js +8 -2
- package/dist/es5/context/state-tracker/with-parameters.js.map +1 -1
- package/dist/es5/index.js +63 -305
- package/dist/es5/index.js.map +1 -1
- package/dist/es5/init.js +1 -41
- package/dist/es5/init.js.map +1 -1
- package/dist/es5/{context/parameters/webgl-parameters.js → types/webgl.js} +1 -1
- package/dist/es5/types/webgl.js.map +1 -0
- package/dist/esm/adapter/converters/{set-device-parameters.js → device-parameters.js} +50 -6
- package/dist/esm/adapter/converters/device-parameters.js.map +1 -0
- package/dist/esm/{classes → adapter/converters}/renderbuffer-formats.js +1 -1
- package/dist/esm/adapter/converters/renderbuffer-formats.js.map +1 -0
- package/dist/esm/adapter/converters/sampler-parameters.js +227 -0
- package/dist/esm/adapter/converters/sampler-parameters.js.map +1 -0
- package/dist/esm/adapter/converters/texture-formats.js +954 -0
- package/dist/esm/adapter/converters/texture-formats.js.map +1 -0
- package/dist/esm/adapter/converters/vertex-formats.js +35 -0
- package/dist/esm/adapter/converters/vertex-formats.js.map +1 -0
- package/dist/esm/adapter/device-helpers/device-features.js +39 -50
- package/dist/esm/adapter/device-helpers/device-features.js.map +1 -1
- package/dist/esm/adapter/device-helpers/device-limits.js +1 -0
- package/dist/esm/adapter/device-helpers/device-limits.js.map +1 -1
- package/dist/esm/adapter/device-helpers/get-device-info.js +7 -7
- package/dist/esm/adapter/device-helpers/get-device-info.js.map +1 -1
- package/dist/esm/adapter/helpers/attribute-utils.js +81 -0
- package/dist/esm/adapter/helpers/attribute-utils.js.map +1 -0
- package/dist/esm/adapter/helpers/get-shader-layout.js +330 -0
- package/dist/esm/adapter/helpers/get-shader-layout.js.map +1 -0
- package/dist/{webgl-utils → esm/adapter/helpers}/parse-shader-compiler-log.js +0 -0
- package/dist/esm/adapter/helpers/parse-shader-compiler-log.js.map +1 -0
- package/dist/esm/adapter/helpers/set-uniform.js +115 -0
- package/dist/esm/adapter/helpers/set-uniform.js.map +1 -0
- package/dist/esm/adapter/helpers/uniforms.js +99 -0
- package/dist/esm/adapter/helpers/uniforms.js.map +1 -0
- package/dist/{webgl-utils → esm/adapter/objects}/constants-to-keys.js +1 -0
- package/dist/esm/adapter/objects/constants-to-keys.js.map +1 -0
- package/dist/{classes/renderbuffer.js → esm/adapter/objects/webgl-renderbuffer.js} +38 -72
- package/dist/esm/adapter/objects/webgl-renderbuffer.js.map +1 -0
- package/dist/esm/{classes → adapter/objects}/webgl-resource.js +7 -3
- package/dist/esm/adapter/objects/webgl-resource.js.map +1 -0
- package/dist/esm/adapter/objects/webgl-vertex-array-object.js +84 -0
- package/dist/esm/adapter/objects/webgl-vertex-array-object.js.map +1 -0
- package/dist/esm/adapter/resources/webgl-buffer.js +164 -0
- package/dist/esm/adapter/resources/webgl-buffer.js.map +1 -0
- package/dist/esm/adapter/resources/webgl-command-buffer.js +65 -0
- package/dist/esm/adapter/resources/webgl-command-buffer.js.map +1 -0
- package/dist/esm/adapter/resources/webgl-command-encoder.js +53 -0
- package/dist/esm/adapter/resources/webgl-command-encoder.js.map +1 -0
- package/dist/esm/adapter/resources/webgl-external-texture.js +2 -0
- package/dist/{helpers/program-bindings.js.map → esm/adapter/resources/webgl-external-texture.js.map} +1 -1
- package/dist/esm/adapter/resources/webgl-framebuffer.js +267 -0
- package/dist/esm/adapter/resources/webgl-framebuffer.js.map +1 -0
- package/dist/esm/adapter/resources/webgl-render-pass.js +21 -0
- package/dist/esm/adapter/resources/webgl-render-pass.js.map +1 -0
- package/dist/esm/adapter/resources/webgl-render-pipeline.js +428 -0
- package/dist/esm/adapter/resources/webgl-render-pipeline.js.map +1 -0
- package/dist/esm/adapter/resources/webgl-sampler.js +50 -0
- package/dist/esm/adapter/resources/webgl-sampler.js.map +1 -0
- package/dist/{adapter → esm/adapter/resources}/webgl-shader.js +17 -23
- package/dist/esm/adapter/resources/webgl-shader.js.map +1 -0
- package/dist/esm/{classes/texture.js → adapter/resources/webgl-texture.js} +280 -232
- package/dist/esm/adapter/resources/webgl-texture.js.map +1 -0
- package/dist/esm/adapter/webgl-canvas-context.js +52 -0
- package/dist/esm/adapter/webgl-canvas-context.js.map +1 -0
- package/dist/esm/adapter/webgl-device.js +253 -115
- package/dist/esm/adapter/webgl-device.js.map +1 -1
- package/dist/esm/{classes → classic}/accessor.js +33 -1
- package/dist/esm/classic/accessor.js.map +1 -0
- package/dist/esm/{classes/webgl-buffer.js → classic/buffer.js} +67 -57
- package/dist/esm/classic/buffer.js.map +1 -0
- package/dist/{webgl-utils → esm/classic}/typed-array-utils.js +0 -0
- package/dist/esm/classic/typed-array-utils.js.map +1 -0
- package/dist/esm/context/context/context-state.js +1 -6
- package/dist/esm/context/context/context-state.js.map +1 -1
- package/dist/{context/context/create-context.js → esm/context/context/create-browser-context.js} +27 -3
- package/dist/esm/context/context/create-browser-context.js.map +1 -0
- package/dist/esm/context/context/create-headless-context.js +43 -0
- package/dist/esm/context/context/create-headless-context.js.map +1 -0
- package/dist/esm/context/debug/spector.js +76 -0
- package/dist/esm/context/debug/spector.js.map +1 -0
- package/dist/esm/context/debug/webgl-developer-tools.js +121 -0
- package/dist/esm/context/debug/webgl-developer-tools.js.map +1 -0
- package/dist/esm/context/parameters/unified-parameter-api.js +9 -8
- package/dist/esm/context/parameters/unified-parameter-api.js.map +1 -1
- package/dist/esm/context/parameters/webgl-parameter-tables.js.map +1 -1
- package/dist/esm/context/polyfill/get-parameter-polyfill.js.map +1 -1
- package/dist/esm/context/polyfill/polyfill-context.js +3 -3
- package/dist/esm/context/polyfill/polyfill-context.js.map +1 -1
- package/dist/esm/context/polyfill/polyfill-table.js +1 -1
- package/dist/esm/context/polyfill/polyfill-table.js.map +1 -1
- package/dist/esm/context/state-tracker/deep-array-equal.js.map +1 -1
- package/dist/esm/context/state-tracker/track-context-state.js +26 -12
- package/dist/esm/context/state-tracker/track-context-state.js.map +1 -1
- package/dist/esm/context/state-tracker/with-parameters.js +6 -2
- package/dist/esm/context/state-tracker/with-parameters.js.map +1 -1
- package/dist/esm/index.js +20 -32
- package/dist/esm/index.js.map +1 -1
- package/dist/esm/init.js +2 -31
- package/dist/esm/init.js.map +1 -1
- package/dist/esm/types/webgl.js +2 -0
- package/dist/esm/types/webgl.js.map +1 -0
- package/dist/index.d.ts +25 -47
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +20 -32
- package/dist/index.js.map +1 -1
- package/dist/init.d.ts +1 -4
- package/dist/init.d.ts.map +1 -1
- package/dist/init.js +2 -31
- package/dist/init.js.map +1 -1
- package/dist/types/webgl.d.ts +145 -0
- package/dist/types/webgl.d.ts.map +1 -0
- package/dist/types/webgl.js +2 -0
- package/dist/types/webgl.js.map +1 -0
- package/package.json +5 -5
- package/src/adapter/converters/{set-device-parameters.ts → device-parameters.ts} +81 -12
- package/src/{classes → adapter/converters}/renderbuffer-formats.ts +1 -1
- package/src/adapter/converters/sampler-parameters.ts +184 -0
- package/src/adapter/converters/texture-formats.ts +633 -0
- package/src/adapter/converters/vertex-formats.ts +22 -0
- package/src/adapter/device-helpers/device-features.ts +55 -124
- package/src/adapter/device-helpers/device-limits.ts +6 -3
- package/src/adapter/device-helpers/get-device-info.ts +8 -8
- package/src/adapter/helpers/attribute-utils.ts +61 -0
- package/src/adapter/helpers/get-shader-layout.ts +407 -0
- package/src/{webgl-utils → adapter/helpers}/parse-shader-compiler-log.ts +0 -0
- package/src/adapter/helpers/set-uniform.ts +87 -0
- package/src/adapter/helpers/uniforms.ts +121 -0
- package/src/{webgl-utils → adapter/objects}/constants-to-keys.ts +6 -3
- package/src/adapter/objects/webgl-renderbuffer.ts +104 -0
- package/src/{classes → adapter/objects}/webgl-resource.ts +23 -17
- package/src/adapter/objects/webgl-vertex-array-object.ts +111 -0
- package/src/adapter/resources/webgl-buffer.ts +219 -0
- package/src/adapter/resources/webgl-command-buffer.ts +94 -0
- package/src/adapter/resources/webgl-command-encoder.ts +58 -0
- package/src/adapter/resources/webgl-external-texture.ts +92 -0
- package/src/adapter/resources/webgl-framebuffer.ts +282 -0
- package/src/adapter/resources/webgl-render-pass.ts +24 -0
- package/src/adapter/resources/webgl-render-pipeline.ts +425 -0
- package/src/adapter/resources/webgl-sampler.ts +56 -0
- package/src/adapter/{webgl-shader.ts → resources/webgl-shader.ts} +19 -24
- package/src/adapter/resources/webgl-texture.ts +1036 -0
- package/src/adapter/webgl-canvas-context.ts +72 -0
- package/src/adapter/webgl-device.ts +312 -285
- package/{dist/esm/classes/accessor.ts.disabled → src/classic/accessor.ts} +38 -37
- package/src/{classes/webgl-buffer.ts → classic/buffer.ts} +76 -84
- package/src/{webgl-utils → classic}/typed-array-utils.ts +5 -1
- package/src/context/context/context-state.ts +4 -12
- package/src/context/context/{create-context.ts → create-browser-context.ts} +41 -6
- package/src/context/context/create-headless-context.ts +48 -0
- package/src/context/debug/spector.ts +92 -0
- package/src/context/debug/webgl-developer-tools.ts +162 -0
- package/src/context/parameters/unified-parameter-api.ts +21 -13
- package/src/context/parameters/webgl-parameter-tables.ts +38 -36
- package/src/context/polyfill/get-parameter-polyfill.ts +1 -1
- package/src/context/polyfill/polyfill-context.ts +4 -5
- package/src/context/polyfill/polyfill-table.ts +1 -1
- package/src/context/state-tracker/deep-array-equal.ts +1 -1
- package/src/context/state-tracker/track-context-state.ts +34 -26
- package/src/context/state-tracker/with-parameters.ts +7 -2
- package/src/index.ts +42 -105
- package/src/init.ts +2 -46
- package/src/types/webgl.ts +284 -0
- package/dist/_deprecated/context-api.d.ts +0 -85
- package/dist/_deprecated/context-api.d.ts.map +0 -1
- package/dist/_deprecated/context-api.js +0 -76
- package/dist/_deprecated/context-api.js.map +0 -1
- package/dist/_deprecated/features.d.ts +0 -27
- package/dist/_deprecated/features.d.ts.map +0 -1
- package/dist/_deprecated/features.js +0 -111
- package/dist/_deprecated/features.js.map +0 -1
- package/dist/adapter/converters/set-device-parameters.d.ts +0 -5
- package/dist/adapter/converters/set-device-parameters.d.ts.map +0 -1
- package/dist/adapter/converters/set-device-parameters.js.map +0 -1
- package/dist/adapter/converters/webgpu-texture-formats.d.ts +0 -281
- package/dist/adapter/converters/webgpu-texture-formats.d.ts.map +0 -1
- package/dist/adapter/converters/webgpu-texture-formats.js +0 -285
- package/dist/adapter/converters/webgpu-texture-formats.js.map +0 -1
- package/dist/adapter/webgl-shader.d.ts.map +0 -1
- package/dist/adapter/webgl-shader.js.map +0 -1
- package/dist/classes/accessor.d.ts +0 -28
- package/dist/classes/accessor.d.ts.map +0 -1
- package/dist/classes/accessor.js.map +0 -1
- package/dist/classes/accessor.ts.disabled +0 -159
- package/dist/classes/clear.d.ts +0 -17
- package/dist/classes/clear.d.ts.map +0 -1
- package/dist/classes/clear.js +0 -105
- package/dist/classes/clear.js.map +0 -1
- package/dist/classes/copy-and-blit.d.ts +0 -86
- package/dist/classes/copy-and-blit.d.ts.map +0 -1
- package/dist/classes/copy-and-blit.js +0 -338
- package/dist/classes/copy-and-blit.js.map +0 -1
- package/dist/classes/framebuffer.d.ts +0 -139
- package/dist/classes/framebuffer.d.ts.map +0 -1
- package/dist/classes/framebuffer.js +0 -656
- package/dist/classes/framebuffer.js.map +0 -1
- package/dist/classes/program-configuration.d.ts +0 -24
- package/dist/classes/program-configuration.d.ts.map +0 -1
- package/dist/classes/program-configuration.js +0 -73
- package/dist/classes/program-configuration.js.map +0 -1
- package/dist/classes/program.d.ts +0 -66
- package/dist/classes/program.d.ts.map +0 -1
- package/dist/classes/program.js +0 -379
- package/dist/classes/program.js.map +0 -1
- package/dist/classes/query.d.ts +0 -27
- package/dist/classes/query.d.ts.map +0 -1
- package/dist/classes/query.js +0 -145
- package/dist/classes/query.js.map +0 -1
- package/dist/classes/renderbuffer-formats.d.ts.map +0 -1
- package/dist/classes/renderbuffer-formats.js.map +0 -1
- package/dist/classes/renderbuffer.d.ts +0 -60
- package/dist/classes/renderbuffer.d.ts.map +0 -1
- package/dist/classes/renderbuffer.js.map +0 -1
- package/dist/classes/shader.d.ts +0 -42
- package/dist/classes/shader.d.ts.map +0 -1
- package/dist/classes/shader.js +0 -118
- package/dist/classes/shader.js.map +0 -1
- package/dist/classes/texture-2d.d.ts +0 -9
- package/dist/classes/texture-2d.d.ts.map +0 -1
- package/dist/classes/texture-2d.js +0 -36
- package/dist/classes/texture-2d.js.map +0 -1
- package/dist/classes/texture-3d.d.ts +0 -29
- package/dist/classes/texture-3d.d.ts.map +0 -1
- package/dist/classes/texture-3d.js +0 -76
- package/dist/classes/texture-3d.js.map +0 -1
- package/dist/classes/texture-cube.d.ts +0 -28
- package/dist/classes/texture-cube.d.ts.map +0 -1
- package/dist/classes/texture-cube.js +0 -130
- package/dist/classes/texture-cube.js.map +0 -1
- package/dist/classes/texture-formats.d.ts +0 -37
- package/dist/classes/texture-formats.d.ts.map +0 -1
- package/dist/classes/texture-formats.js +0 -98
- package/dist/classes/texture-formats.js.map +0 -1
- package/dist/classes/texture.d.ts +0 -123
- package/dist/classes/texture.d.ts.map +0 -1
- package/dist/classes/texture.js.map +0 -1
- package/dist/classes/transform-feedback.d.ts +0 -33
- package/dist/classes/transform-feedback.d.ts.map +0 -1
- package/dist/classes/transform-feedback.js +0 -198
- package/dist/classes/transform-feedback.js.map +0 -1
- package/dist/classes/uniform-buffer-layout.d.ts +0 -17
- package/dist/classes/uniform-buffer-layout.d.ts.map +0 -1
- package/dist/classes/uniform-buffer-layout.js +0 -104
- package/dist/classes/uniform-buffer-layout.js.map +0 -1
- package/dist/classes/uniforms.d.ts +0 -37
- package/dist/classes/uniforms.d.ts.map +0 -1
- package/dist/classes/uniforms.js +0 -250
- package/dist/classes/uniforms.js.map +0 -1
- package/dist/classes/vertex-array-object.d.ts +0 -76
- package/dist/classes/vertex-array-object.d.ts.map +0 -1
- package/dist/classes/vertex-array-object.js +0 -261
- package/dist/classes/vertex-array-object.js.map +0 -1
- package/dist/classes/vertex-array.d.ts +0 -75
- package/dist/classes/vertex-array.d.ts.map +0 -1
- package/dist/classes/vertex-array.js +0 -408
- package/dist/classes/vertex-array.js.map +0 -1
- package/dist/classes/webgl-buffer.d.ts.map +0 -1
- package/dist/classes/webgl-buffer.js.map +0 -1
- package/dist/classes/webgl-resource.d.ts.map +0 -1
- package/dist/classes/webgl-resource.js.map +0 -1
- package/dist/context/context/create-context.d.ts.map +0 -1
- package/dist/context/context/create-context.js.map +0 -1
- package/dist/context/context/device-pixels.d.ts +0 -25
- package/dist/context/context/device-pixels.d.ts.map +0 -1
- package/dist/context/context/device-pixels.js +0 -98
- package/dist/context/context/device-pixels.js.map +0 -1
- package/dist/context/context/get-canvas.d.ts +0 -13
- package/dist/context/context/get-canvas.d.ts.map +0 -1
- package/dist/context/context/get-canvas.js +0 -31
- package/dist/context/context/get-canvas.js.map +0 -1
- package/dist/context/context/resize-context.d.ts +0 -20
- package/dist/context/context/resize-context.d.ts.map +0 -1
- package/dist/context/context/resize-context.js +0 -15
- package/dist/context/context/resize-context.js.map +0 -1
- package/dist/context/parameters/webgl-parameters.d.ts +0 -144
- package/dist/context/parameters/webgl-parameters.d.ts.map +0 -1
- package/dist/context/parameters/webgl-parameters.js +0 -2
- package/dist/context/parameters/webgl-parameters.js.map +0 -1
- package/dist/debug/debug-program-configuration.d.ts +0 -2
- package/dist/debug/debug-program-configuration.d.ts.map +0 -1
- package/dist/debug/debug-program-configuration.js +0 -40
- package/dist/debug/debug-program-configuration.js.map +0 -1
- package/dist/debug/debug-uniforms.d.ts +0 -12
- package/dist/debug/debug-uniforms.d.ts.map +0 -1
- package/dist/debug/debug-uniforms.js +0 -108
- package/dist/debug/debug-uniforms.js.map +0 -1
- package/dist/debug/debug-vertex-array.d.ts +0 -5
- package/dist/debug/debug-vertex-array.d.ts.map +0 -1
- package/dist/debug/debug-vertex-array.js +0 -118
- package/dist/debug/debug-vertex-array.js.map +0 -1
- package/dist/es5/_deprecated/context-api.js +0 -116
- package/dist/es5/_deprecated/context-api.js.map +0 -1
- package/dist/es5/_deprecated/features.js +0 -118
- package/dist/es5/_deprecated/features.js.map +0 -1
- package/dist/es5/adapter/converters/set-device-parameters.js.map +0 -1
- package/dist/es5/adapter/converters/webgpu-texture-formats.js +0 -296
- package/dist/es5/adapter/converters/webgpu-texture-formats.js.map +0 -1
- package/dist/es5/adapter/webgl-shader.js.map +0 -1
- package/dist/es5/classes/accessor.d.ts +0 -28
- package/dist/es5/classes/accessor.js.map +0 -1
- package/dist/es5/classes/accessor.ts.disabled +0 -159
- package/dist/es5/classes/clear.js +0 -135
- package/dist/es5/classes/clear.js.map +0 -1
- package/dist/es5/classes/copy-and-blit.js +0 -382
- package/dist/es5/classes/copy-and-blit.js.map +0 -1
- package/dist/es5/classes/framebuffer.js +0 -807
- package/dist/es5/classes/framebuffer.js.map +0 -1
- package/dist/es5/classes/program-configuration.js +0 -119
- package/dist/es5/classes/program-configuration.js.map +0 -1
- package/dist/es5/classes/program.js +0 -471
- package/dist/es5/classes/program.js.map +0 -1
- package/dist/es5/classes/query.js +0 -222
- package/dist/es5/classes/query.js.map +0 -1
- package/dist/es5/classes/renderbuffer-formats.js.map +0 -1
- package/dist/es5/classes/renderbuffer.js.map +0 -1
- package/dist/es5/classes/shader.js +0 -195
- package/dist/es5/classes/shader.js.map +0 -1
- package/dist/es5/classes/texture-2d.js.map +0 -1
- package/dist/es5/classes/texture-3d.js +0 -142
- package/dist/es5/classes/texture-3d.js.map +0 -1
- package/dist/es5/classes/texture-cube.js +0 -202
- package/dist/es5/classes/texture-cube.js.map +0 -1
- package/dist/es5/classes/texture-formats.js +0 -87
- package/dist/es5/classes/texture-formats.js.map +0 -1
- package/dist/es5/classes/texture.js.map +0 -1
- package/dist/es5/classes/transform-feedback.js +0 -267
- package/dist/es5/classes/transform-feedback.js.map +0 -1
- package/dist/es5/classes/uniform-buffer-layout.js +0 -130
- package/dist/es5/classes/uniform-buffer-layout.js.map +0 -1
- package/dist/es5/classes/uniforms.js +0 -232
- package/dist/es5/classes/uniforms.js.map +0 -1
- package/dist/es5/classes/vertex-array-object.js +0 -337
- package/dist/es5/classes/vertex-array-object.js.map +0 -1
- package/dist/es5/classes/vertex-array.js +0 -465
- package/dist/es5/classes/vertex-array.js.map +0 -1
- package/dist/es5/classes/webgl-buffer.js.map +0 -1
- package/dist/es5/classes/webgl-resource.js.map +0 -1
- package/dist/es5/context/context/create-context.js.map +0 -1
- package/dist/es5/context/context/device-pixels.js +0 -115
- package/dist/es5/context/context/device-pixels.js.map +0 -1
- package/dist/es5/context/context/get-canvas.js +0 -40
- package/dist/es5/context/context/get-canvas.js.map +0 -1
- package/dist/es5/context/context/resize-context.js +0 -23
- package/dist/es5/context/context/resize-context.js.map +0 -1
- package/dist/es5/context/parameters/webgl-parameters.js.map +0 -1
- package/dist/es5/debug/debug-program-configuration.js +0 -76
- package/dist/es5/debug/debug-program-configuration.js.map +0 -1
- package/dist/es5/debug/debug-uniforms.js +0 -156
- package/dist/es5/debug/debug-uniforms.js.map +0 -1
- package/dist/es5/debug/debug-vertex-array.js +0 -126
- package/dist/es5/debug/debug-vertex-array.js.map +0 -1
- package/dist/es5/helpers/get-program-bindings.js.map +0 -1
- package/dist/es5/helpers/program-bindings.js +0 -2
- package/dist/es5/types/accessor.d.ts +0 -29
- package/dist/es5/webgl-utils/attribute-utils.js +0 -186
- package/dist/es5/webgl-utils/attribute-utils.js.map +0 -1
- package/dist/es5/webgl-utils/constants-to-keys.js.map +0 -1
- package/dist/es5/webgl-utils/format-utils.js +0 -58
- package/dist/es5/webgl-utils/format-utils.js.map +0 -1
- package/dist/es5/webgl-utils/get-error.js +0 -49
- package/dist/es5/webgl-utils/get-error.js.map +0 -1
- package/dist/es5/webgl-utils/index.js +0 -74
- package/dist/es5/webgl-utils/index.js.map +0 -1
- package/dist/es5/webgl-utils/parse-shader-compiler-log.js.map +0 -1
- package/dist/es5/webgl-utils/request-animation-frame.js +0 -16
- package/dist/es5/webgl-utils/request-animation-frame.js.map +0 -1
- package/dist/es5/webgl-utils/texture-utils.js +0 -61
- package/dist/es5/webgl-utils/texture-utils.js.map +0 -1
- package/dist/es5/webgl-utils/typed-array-utils.js.map +0 -1
- package/dist/esm/_deprecated/context-api.js +0 -76
- package/dist/esm/_deprecated/context-api.js.map +0 -1
- package/dist/esm/_deprecated/features.js +0 -111
- package/dist/esm/_deprecated/features.js.map +0 -1
- package/dist/esm/adapter/converters/set-device-parameters.js.map +0 -1
- package/dist/esm/adapter/converters/webgpu-texture-formats.js +0 -285
- package/dist/esm/adapter/converters/webgpu-texture-formats.js.map +0 -1
- package/dist/esm/adapter/webgl-shader.js.map +0 -1
- package/dist/esm/classes/accessor.d.ts +0 -28
- package/dist/esm/classes/accessor.js.map +0 -1
- package/dist/esm/classes/clear.js +0 -105
- package/dist/esm/classes/clear.js.map +0 -1
- package/dist/esm/classes/copy-and-blit.js +0 -338
- package/dist/esm/classes/copy-and-blit.js.map +0 -1
- package/dist/esm/classes/framebuffer.js +0 -656
- package/dist/esm/classes/framebuffer.js.map +0 -1
- package/dist/esm/classes/program-configuration.js +0 -73
- package/dist/esm/classes/program-configuration.js.map +0 -1
- package/dist/esm/classes/program.js +0 -379
- package/dist/esm/classes/program.js.map +0 -1
- package/dist/esm/classes/query.js +0 -145
- package/dist/esm/classes/query.js.map +0 -1
- package/dist/esm/classes/renderbuffer-formats.js.map +0 -1
- package/dist/esm/classes/renderbuffer.js.map +0 -1
- package/dist/esm/classes/shader.js +0 -118
- package/dist/esm/classes/shader.js.map +0 -1
- package/dist/esm/classes/texture-2d.js +0 -36
- package/dist/esm/classes/texture-2d.js.map +0 -1
- package/dist/esm/classes/texture-3d.js +0 -76
- package/dist/esm/classes/texture-3d.js.map +0 -1
- package/dist/esm/classes/texture-cube.js +0 -130
- package/dist/esm/classes/texture-cube.js.map +0 -1
- package/dist/esm/classes/texture-formats.js +0 -98
- package/dist/esm/classes/texture-formats.js.map +0 -1
- package/dist/esm/classes/texture.js.map +0 -1
- package/dist/esm/classes/transform-feedback.js +0 -198
- package/dist/esm/classes/transform-feedback.js.map +0 -1
- package/dist/esm/classes/uniform-buffer-layout.js +0 -104
- package/dist/esm/classes/uniform-buffer-layout.js.map +0 -1
- package/dist/esm/classes/uniforms.js +0 -250
- package/dist/esm/classes/uniforms.js.map +0 -1
- package/dist/esm/classes/vertex-array-object.js +0 -261
- package/dist/esm/classes/vertex-array-object.js.map +0 -1
- package/dist/esm/classes/vertex-array.js +0 -408
- package/dist/esm/classes/vertex-array.js.map +0 -1
- package/dist/esm/classes/webgl-buffer.js.map +0 -1
- package/dist/esm/classes/webgl-resource.js.map +0 -1
- package/dist/esm/context/context/create-context.js.map +0 -1
- package/dist/esm/context/context/device-pixels.js +0 -98
- package/dist/esm/context/context/device-pixels.js.map +0 -1
- package/dist/esm/context/context/get-canvas.js +0 -31
- package/dist/esm/context/context/get-canvas.js.map +0 -1
- package/dist/esm/context/context/resize-context.js +0 -15
- package/dist/esm/context/context/resize-context.js.map +0 -1
- package/dist/esm/context/parameters/webgl-parameters.js +0 -2
- package/dist/esm/context/parameters/webgl-parameters.js.map +0 -1
- package/dist/esm/debug/debug-program-configuration.js +0 -40
- package/dist/esm/debug/debug-program-configuration.js.map +0 -1
- package/dist/esm/debug/debug-uniforms.js +0 -108
- package/dist/esm/debug/debug-uniforms.js.map +0 -1
- package/dist/esm/debug/debug-vertex-array.js +0 -118
- package/dist/esm/debug/debug-vertex-array.js.map +0 -1
- package/dist/esm/helpers/get-program-bindings.js +0 -228
- package/dist/esm/helpers/get-program-bindings.js.map +0 -1
- package/dist/esm/helpers/program-bindings.js +0 -2
- package/dist/esm/types/accessor.d.ts +0 -29
- package/dist/esm/webgl-utils/attribute-utils.js +0 -182
- package/dist/esm/webgl-utils/attribute-utils.js.map +0 -1
- package/dist/esm/webgl-utils/constants-to-keys.js.map +0 -1
- package/dist/esm/webgl-utils/format-utils.js +0 -45
- package/dist/esm/webgl-utils/format-utils.js.map +0 -1
- package/dist/esm/webgl-utils/get-error.js +0 -41
- package/dist/esm/webgl-utils/get-error.js.map +0 -1
- package/dist/esm/webgl-utils/index.js +0 -5
- package/dist/esm/webgl-utils/index.js.map +0 -1
- package/dist/esm/webgl-utils/parse-shader-compiler-log.js.map +0 -1
- package/dist/esm/webgl-utils/request-animation-frame.js +0 -7
- package/dist/esm/webgl-utils/request-animation-frame.js.map +0 -1
- package/dist/esm/webgl-utils/texture-utils.js +0 -48
- package/dist/esm/webgl-utils/texture-utils.js.map +0 -1
- package/dist/esm/webgl-utils/typed-array-utils.js.map +0 -1
- package/dist/helpers/get-program-bindings.d.ts +0 -8
- package/dist/helpers/get-program-bindings.d.ts.map +0 -1
- package/dist/helpers/get-program-bindings.js +0 -228
- package/dist/helpers/get-program-bindings.js.map +0 -1
- package/dist/helpers/program-bindings.d.ts +0 -41
- package/dist/helpers/program-bindings.d.ts.map +0 -1
- package/dist/helpers/program-bindings.js +0 -2
- package/dist/types/accessor.d.ts +0 -29
- package/dist/webgl-utils/attribute-utils.d.ts +0 -18
- package/dist/webgl-utils/attribute-utils.d.ts.map +0 -1
- package/dist/webgl-utils/attribute-utils.js +0 -182
- package/dist/webgl-utils/attribute-utils.js.map +0 -1
- package/dist/webgl-utils/constants-to-keys.d.ts +0 -4
- package/dist/webgl-utils/constants-to-keys.d.ts.map +0 -1
- package/dist/webgl-utils/constants-to-keys.js.map +0 -1
- package/dist/webgl-utils/format-utils.d.ts +0 -3
- package/dist/webgl-utils/format-utils.d.ts.map +0 -1
- package/dist/webgl-utils/format-utils.js +0 -45
- package/dist/webgl-utils/format-utils.js.map +0 -1
- package/dist/webgl-utils/get-error.d.ts +0 -3
- package/dist/webgl-utils/get-error.d.ts.map +0 -1
- package/dist/webgl-utils/get-error.js +0 -41
- package/dist/webgl-utils/get-error.js.map +0 -1
- package/dist/webgl-utils/index.d.ts +0 -5
- package/dist/webgl-utils/index.d.ts.map +0 -1
- package/dist/webgl-utils/index.js +0 -5
- package/dist/webgl-utils/index.js.map +0 -1
- package/dist/webgl-utils/parse-shader-compiler-log.d.ts.map +0 -1
- package/dist/webgl-utils/parse-shader-compiler-log.js.map +0 -1
- package/dist/webgl-utils/request-animation-frame.d.ts +0 -4
- package/dist/webgl-utils/request-animation-frame.d.ts.map +0 -1
- package/dist/webgl-utils/request-animation-frame.js +0 -7
- package/dist/webgl-utils/request-animation-frame.js.map +0 -1
- package/dist/webgl-utils/texture-utils.d.ts +0 -15
- package/dist/webgl-utils/texture-utils.d.ts.map +0 -1
- package/dist/webgl-utils/texture-utils.js +0 -48
- package/dist/webgl-utils/texture-utils.js.map +0 -1
- package/dist/webgl-utils/typed-array-utils.d.ts.map +0 -1
- package/dist/webgl-utils/typed-array-utils.js.map +0 -1
- package/src/.DS_Store +0 -0
- package/src/_deprecated/context-api.ts +0 -146
- package/src/_deprecated/features.ts +0 -159
- package/src/adapter/converters/webgpu-texture-formats.ts +0 -167
- package/src/classes/accessor.d.ts +0 -28
- package/src/classes/accessor.js +0 -129
- package/src/classes/accessor.ts.disabled +0 -159
- package/src/classes/clear.ts +0 -108
- package/src/classes/copy-and-blit.ts +0 -460
- package/src/classes/framebuffer.ts +0 -763
- package/src/classes/program-configuration.ts +0 -77
- package/src/classes/program.ts +0 -431
- package/src/classes/query.ts +0 -171
- package/src/classes/renderbuffer.ts +0 -154
- package/src/classes/shader.ts +0 -129
- package/src/classes/texture-2d.ts +0 -35
- package/src/classes/texture-3d.ts +0 -123
- package/src/classes/texture-cube.ts +0 -162
- package/src/classes/texture-formats.ts +0 -171
- package/src/classes/texture.ts +0 -965
- package/src/classes/transform-feedback.ts +0 -191
- package/src/classes/uniform-buffer-layout.ts +0 -113
- package/src/classes/uniforms.ts +0 -394
- package/src/classes/vertex-array-object.ts +0 -339
- package/src/classes/vertex-array.ts +0 -484
- package/src/context/context/device-pixels.ts +0 -147
- package/src/context/context/get-canvas.ts +0 -37
- package/src/context/context/resize-context.ts +0 -37
- package/src/context/parameters/webgl-parameters.ts +0 -197
- package/src/debug/debug-program-configuration.ts +0 -32
- package/src/debug/debug-uniforms.ts +0 -100
- package/src/debug/debug-vertex-array.ts +0 -123
- package/src/helpers/get-program-bindings.ts +0 -244
- package/src/helpers/program-bindings.ts +0 -46
- package/src/types/accessor.d.ts +0 -29
- package/src/webgl-utils/attribute-utils.ts +0 -171
- package/src/webgl-utils/format-utils.ts +0 -43
- package/src/webgl-utils/get-error.ts +0 -56
- package/src/webgl-utils/index.ts +0 -12
- package/src/webgl-utils/request-animation-frame.ts +0 -14
- package/src/webgl-utils/texture-utils.ts +0 -60
|
@@ -36,6 +36,18 @@ function createBrowserContext(canvas, props) {
|
|
|
36
36
|
canvas.addEventListener('webglcontextcreationerror', onCreateError, false);
|
|
37
37
|
var gl = null;
|
|
38
38
|
|
|
39
|
+
if (props.type === 'webgl2') {
|
|
40
|
+
props = _objectSpread(_objectSpread({}, props), {}, {
|
|
41
|
+
webgl1: false
|
|
42
|
+
});
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
if (props.type === 'webgl1') {
|
|
46
|
+
props = _objectSpread(_objectSpread({}, props), {}, {
|
|
47
|
+
webgl2: false
|
|
48
|
+
});
|
|
49
|
+
}
|
|
50
|
+
|
|
39
51
|
if (props.webgl2) {
|
|
40
52
|
gl = gl || canvas.getContext('webgl2', props);
|
|
41
53
|
}
|
|
@@ -50,8 +62,22 @@ function createBrowserContext(canvas, props) {
|
|
|
50
62
|
throw new Error("Failed to create ".concat(props.webgl2 && !props.webgl1 ? 'WebGL2' : 'WebGL', " context: ").concat(errorMessage || 'Unknown error'));
|
|
51
63
|
}
|
|
52
64
|
|
|
53
|
-
|
|
54
|
-
|
|
65
|
+
if (props.onContextLost) {
|
|
66
|
+
var _props = props,
|
|
67
|
+
onContextLost = _props.onContextLost;
|
|
68
|
+
canvas.addEventListener('webglcontextlost', function (event) {
|
|
69
|
+
return onContextLost(event);
|
|
70
|
+
}, false);
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
if (props.onContextRestored) {
|
|
74
|
+
var _props2 = props,
|
|
75
|
+
onContextRestored = _props2.onContextRestored;
|
|
76
|
+
canvas.addEventListener('webglcontextrestored', function (event) {
|
|
77
|
+
return onContextRestored(event);
|
|
78
|
+
}, false);
|
|
79
|
+
}
|
|
80
|
+
|
|
55
81
|
return gl;
|
|
56
82
|
}
|
|
57
|
-
//# sourceMappingURL=create-context.js.map
|
|
83
|
+
//# sourceMappingURL=create-browser-context.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../../src/context/context/create-browser-context.ts"],"names":["DEFAULT_CONTEXT_PROPS","webgl2","webgl1","powerPreference","onContextLost","console","error","onContextRestored","info","createBrowserContext","canvas","props","errorMessage","onCreateError","statusMessage","addEventListener","gl","type","getContext","removeEventListener","Error","event"],"mappings":";;;;;;;;;;;;;;;AAmCA,IAAMA,qBAAmC,GAAG;AAC1CC,EAAAA,MAAM,EAAE,IADkC;AAE1CC,EAAAA,MAAM,EAAE,IAFkC;AAG1CC,EAAAA,eAAe,EAAE,kBAHyB;AAI1CC,EAAAA,aAAa,EAAE;AAAA,WAAMC,OAAO,CAACC,KAAR,CAAc,oBAAd,CAAN;AAAA,GAJ2B;AAK1CC,EAAAA,iBAAiB,EAAE;AAAA,WAAMF,OAAO,CAACG,IAAR,CAAa,wBAAb,CAAN;AAAA;AALuB,CAA5C;;AAaQ,SAASC,oBAAT,CAA8BC,MAA9B,EAA2EC,KAA3E,EAAuH;AAC5HA,EAAAA,KAAK,mCAAOX,qBAAP,GAAiCW,KAAjC,CAAL;AAGD,MAAIC,YAAY,GAAG,IAAnB;;AACA,MAAMC,aAAa,GAAG,SAAhBA,aAAgB,CAACP,KAAD;AAAA,WAAYM,YAAY,GAAGN,KAAK,CAACQ,aAAN,IAAuBF,YAAlD;AAAA,GAAtB;;AACAF,EAAAA,MAAM,CAACK,gBAAP,CAAwB,2BAAxB,EAAqDF,aAArD,EAAoE,KAApE;AAGA,MAAIG,EAAgC,GAAG,IAAvC;;AAEA,MAAIL,KAAK,CAACM,IAAN,KAAe,QAAnB,EAA6B;AAC3BN,IAAAA,KAAK,mCAAOA,KAAP;AAAcT,MAAAA,MAAM,EAAE;AAAtB,MAAL;AACD;;AACD,MAAIS,KAAK,CAACM,IAAN,KAAe,QAAnB,EAA6B;AAC3BN,IAAAA,KAAK,mCAAOA,KAAP;AAAcV,MAAAA,MAAM,EAAE;AAAtB,MAAL;AACD;;AAGD,MAAIU,KAAK,CAACV,MAAV,EAAkB;AAChBe,IAAAA,EAAE,GAAGA,EAAE,IAAIN,MAAM,CAACQ,UAAP,CAAkB,QAAlB,EAA4BP,KAA5B,CAAX;AACD;;AACD,MAAIA,KAAK,CAACT,MAAV,EAAkB;AAChBc,IAAAA,EAAE,GAAGA,EAAE,IAAIN,MAAM,CAACQ,UAAP,CAAkB,OAAlB,EAA2BP,KAA3B,CAAX;AACD;;AAGDD,EAAAA,MAAM,CAACS,mBAAP,CAA2B,2BAA3B,EAAwDN,aAAxD,EAAuE,KAAvE;;AAEA,MAAI,CAACG,EAAL,EAAS;AACP,UAAM,IAAII,KAAJ,4BACgBT,KAAK,CAACV,MAAN,IAAgB,CAACU,KAAK,CAACT,MAAvB,GAAgC,QAAhC,GAA2C,OAD3D,uBAEFU,YAAY,IAAI,eAFd,EAAN;AAKD;;AAED,MAAID,KAAK,CAACP,aAAV,EAAyB;AAEvB,iBAAwBO,KAAxB;AAAA,QAAOP,aAAP,UAAOA,aAAP;AACAM,IAAAA,MAAM,CAACK,gBAAP,CAAwB,kBAAxB,EAA2C,UAACM,KAAD;AAAA,aAAkBjB,aAAa,CAACiB,KAAD,CAA/B;AAAA,KAA3C,EAAmF,KAAnF;AACD;;AACD,MAAIV,KAAK,CAACJ,iBAAV,EAA6B;AAE3B,kBAA4BI,KAA5B;AAAA,QAAOJ,iBAAP,WAAOA,iBAAP;AACAG,IAAAA,MAAM,CAACK,gBAAP,CAAwB,sBAAxB,EAAgD,UAACM,KAAD;AAAA,aAAkBd,iBAAiB,CAACc,KAAD,CAAnC;AAAA,KAAhD,EAA4F,KAA5F;AACD;;AAED,SAAOL,EAAP;AACD","sourcesContent":["// luma.gl, MIT license\n\n/**\n * ContextProps\n* @param webgl2 Set to false to not create a WebGL2 context (force webgl1)\n* @param webgl1 set to false to not create a WebGL1 context (fail if webgl2 not available)\n* @param onContextLost\n* @param onContextRestored\n*\n* BROWSER CONTEXT PARAMETERS\n* @param debug Instrument context (at the expense of performance).\n* @param alpha Default render target has an alpha buffer.\n* @param depth Default render target has a depth buffer of at least 16 bits.\n* @param stencil Default render target has a stencil buffer of at least 8 bits.\n* @param antialias Boolean that indicates whether or not to perform anti-aliasing.\n* @param premultipliedAlpha Boolean that indicates that the page compositor will assume the drawing buffer contains colors with pre-multiplied alpha.\n* @param preserveDrawingBuffer Default render target buffers will not be automatically cleared and will preserve their values until cleared or overwritten\n* @param failIfMajorPerformanceCaveat Do not create if the system performance is low.\n*/\ntype ContextProps = {\n type?: 'webgl' | 'webgl1' | 'webgl2' | string;\n webgl1?: boolean;\n webgl2?: boolean;\n onContextLost?: (event: Event) => void;\n onContextRestored?: (event: Event) => void;\n alpha?: boolean; // indicates if the canvas contains an alpha buffer.\n desynchronized?: boolean; // hints the user agent to reduce the latency by desynchronizing the canvas paint cycle from the event loop\n antialias?: boolean; // indicates whether or not to perform anti-aliasing.\n depth?: boolean; // indicates that the drawing buffer has a depth buffer of at least 16 bits.\n failIfMajorPerformanceCaveat?: boolean, // indicates if a context will be created if the system performance is low or if no hardware GPU is available.\n powerPreference?: 'default' | 'high-performance' | 'low-power',\n premultipliedAlpha?: boolean, // page compositor will assume the drawing buffer contains colors with pre-multiplied alpha.\n preserveDrawingBuffer?: boolean // buffers will not be cleared and will preserve their values until cleared or overwritten by the author.\n};\n\nconst DEFAULT_CONTEXT_PROPS: ContextProps = {\n webgl2: true, // Attempt to create a WebGL2 context\n webgl1: true, // Attempt to create a WebGL1 context (false to fail if webgl2 not available)\n powerPreference: 'high-performance', // After all, most apps are using WebGL for performance reasons\n onContextLost: () => console.error('WebGL context lost'),\n onContextRestored: () => console.info('WebGL context restored'),\n};\n\n/**\n * Create a WebGL context for a canvas\n * Note calling this multiple time on the same canvas does return the same context\n* @param canvas A canvas element or offscreen canvas\n */\n export function createBrowserContext(canvas: HTMLCanvasElement | OffscreenCanvas, props: ContextProps): WebGLRenderingContext {\n props = {...DEFAULT_CONTEXT_PROPS, ...props};\n\n // Try to extract any extra information about why context creation failed\n let errorMessage = null;\n const onCreateError = (error) => (errorMessage = error.statusMessage || errorMessage);\n canvas.addEventListener('webglcontextcreationerror', onCreateError, false);\n\n // Create the desired context\n let gl: WebGLRenderingContext | null = null;\n\n if (props.type === 'webgl2') {\n props = {...props, webgl1: false};\n }\n if (props.type === 'webgl1') {\n props = {...props, webgl2: false};\n }\n\n // Prefer webgl2 over webgl1 if both are acceptable\n if (props.webgl2) {\n gl = gl || canvas.getContext('webgl2', props) as WebGL2RenderingContext | null;\n }\n if (props.webgl1) {\n gl = gl || canvas.getContext('webgl', props) as WebGLRenderingContext | null;\n }\n\n // TODO are we removing this listener before giving it a chance to fire?\n canvas.removeEventListener('webglcontextcreationerror', onCreateError, false);\n\n if (!gl) {\n throw new Error(\n `Failed to create ${props.webgl2 && !props.webgl1 ? 'WebGL2' : 'WebGL'} context: ${\n errorMessage || 'Unknown error'\n }`\n );\n }\n\n if (props.onContextLost) {\n // Carefully extract and wrap callbacks to prevent addEventListener from rebinding them.\n const {onContextLost} = props;\n canvas.addEventListener('webglcontextlost',(event: Event) => onContextLost(event), false);\n }\n if (props.onContextRestored) {\n // Carefully extract and wrap callbacks to prevent addEventListener from rebinding them.\n const {onContextRestored} = props;\n canvas.addEventListener('webglcontextrestored', (event: Event) => onContextRestored(event), false);\n }\n\n return gl;\n}\n\n/* TODO - can we call this asynchronously to catch the error events?\nexport async function createBrowserContextAsync(canvas: HTMLCanvasElement | OffscreenCanvas, props: ContextProps): Promise<WebGLRenderingContext> {\n props = {...DEFAULT_CONTEXT_PROPS, ...props};\n\n // Try to extract any extra information about why context creation failed\n let errorMessage = null;\n const onCreateError = (error) => (errorMessage = error.statusMessage || errorMessage);\n canvas.addEventListener('webglcontextcreationerror', onCreateError, false);\n\n const gl = createBrowserContext(canvas, props);\n\n // Give the listener a chance to fire\n await new Promise(resolve => setTimeout(resolve, 0));\n\n canvas.removeEventListener('webglcontextcreationerror', onCreateError, false);\n\n return gl;\n}\n*/\n"],"file":"create-browser-context.js"}
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
|
+
|
|
5
|
+
Object.defineProperty(exports, "__esModule", {
|
|
6
|
+
value: true
|
|
7
|
+
});
|
|
8
|
+
exports.registerHeadlessGL = registerHeadlessGL;
|
|
9
|
+
exports.isHeadlessGLRegistered = isHeadlessGLRegistered;
|
|
10
|
+
exports.createHeadlessContext = createHeadlessContext;
|
|
11
|
+
|
|
12
|
+
var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
|
|
13
|
+
|
|
14
|
+
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); if (enumerableOnly) { symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; }); } keys.push.apply(keys, symbols); } return keys; }
|
|
15
|
+
|
|
16
|
+
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; if (i % 2) { ownKeys(Object(source), true).forEach(function (key) { (0, _defineProperty2.default)(target, key, source[key]); }); } else if (Object.getOwnPropertyDescriptors) { Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)); } else { ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } } return target; }
|
|
17
|
+
|
|
18
|
+
var ERR_HEADLESSGL_FAILED = 'Failed to create WebGL context in Node.js, headless gl returned null';
|
|
19
|
+
var ERR_HEADLESSGL_LOAD = " luma.gl: loaded under Node.js without headless gl installed, meaning that WebGL contexts can not be created. This may not be an error. For example, this is a typical configuration for isorender applications running on the server.";
|
|
20
|
+
var CONTEXT_DEFAULTS = {
|
|
21
|
+
width: 1,
|
|
22
|
+
height: 1,
|
|
23
|
+
debug: true,
|
|
24
|
+
throwOnError: false
|
|
25
|
+
};
|
|
26
|
+
var headlessGL = null;
|
|
27
|
+
|
|
28
|
+
function registerHeadlessGL(headlessgl) {
|
|
29
|
+
headlessGL = headlessgl;
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
function isHeadlessGLRegistered() {
|
|
33
|
+
return headlessGL !== null;
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
function createHeadlessContext(options) {
|
|
37
|
+
options = _objectSpread(_objectSpread({}, CONTEXT_DEFAULTS), options);
|
|
38
|
+
var _options = options,
|
|
39
|
+
width = _options.width,
|
|
40
|
+
height = _options.height,
|
|
41
|
+
webgl1 = _options.webgl1,
|
|
42
|
+
webgl2 = _options.webgl2;
|
|
43
|
+
|
|
44
|
+
if (webgl2 && !webgl1) {
|
|
45
|
+
throw new Error('headless-gl does not support WebGL2');
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
if (!headlessGL) {
|
|
49
|
+
throw new Error(ERR_HEADLESSGL_LOAD);
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
var gl = headlessGL(width, height, options);
|
|
53
|
+
|
|
54
|
+
if (!gl) {
|
|
55
|
+
throw new Error(ERR_HEADLESSGL_FAILED);
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
return gl;
|
|
59
|
+
}
|
|
60
|
+
//# sourceMappingURL=create-headless-context.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../../src/context/context/create-headless-context.ts"],"names":["ERR_HEADLESSGL_FAILED","ERR_HEADLESSGL_LOAD","CONTEXT_DEFAULTS","width","height","debug","throwOnError","headlessGL","registerHeadlessGL","headlessgl","isHeadlessGLRegistered","createHeadlessContext","options","webgl1","webgl2","Error","gl"],"mappings":";;;;;;;;;;;;;;;;;AAAA,IAAMA,qBAAqB,GACzB,sEADF;AAGA,IAAMC,mBAAmB,gPAAzB;AAKA,IAAMC,gBAAgB,GAAG;AACvBC,EAAAA,KAAK,EAAE,CADgB;AAEvBC,EAAAA,MAAM,EAAE,CAFe;AAGvBC,EAAAA,KAAK,EAAE,IAHgB;AAIvBC,EAAAA,YAAY,EAAE;AAJS,CAAzB;AAUA,IAAIC,UAA6B,GAAG,IAApC;;AAGO,SAASC,kBAAT,CAA4BC,UAA5B,EAAoD;AACzDF,EAAAA,UAAU,GAAGE,UAAb;AACD;;AAGM,SAASC,sBAAT,GAA2C;AAChD,SAAOH,UAAU,KAAK,IAAtB;AACD;;AAGM,SAASI,qBAAT,CAA+BC,OAA/B,EAAqF;AAC1FA,EAAAA,OAAO,mCAAOV,gBAAP,GAA4BU,OAA5B,CAAP;AAEA,iBAAwCA,OAAxC;AAAA,MAAOT,KAAP,YAAOA,KAAP;AAAA,MAAcC,MAAd,YAAcA,MAAd;AAAA,MAAsBS,MAAtB,YAAsBA,MAAtB;AAAA,MAA8BC,MAA9B,YAA8BA,MAA9B;;AAEA,MAAIA,MAAM,IAAI,CAACD,MAAf,EAAuB;AACrB,UAAM,IAAIE,KAAJ,CAAU,qCAAV,CAAN;AACD;;AACD,MAAI,CAACR,UAAL,EAAiB;AACf,UAAM,IAAIQ,KAAJ,CAAUd,mBAAV,CAAN;AACD;;AACD,MAAMe,EAAE,GAAGT,UAAU,CAACJ,KAAD,EAAQC,MAAR,EAAgBQ,OAAhB,CAArB;;AACA,MAAI,CAACI,EAAL,EAAS;AACP,UAAM,IAAID,KAAJ,CAAUf,qBAAV,CAAN;AACD;;AACD,SAAOgB,EAAP;AACD","sourcesContent":["const ERR_HEADLESSGL_FAILED =\n 'Failed to create WebGL context in Node.js, headless gl returned null';\n\nconst ERR_HEADLESSGL_LOAD = `\\\n luma.gl: loaded under Node.js without headless gl installed, meaning that WebGL \\\n contexts can not be created. This may not be an error. For example, this is a \\\n typical configuration for isorender applications running on the server.`;\n\nconst CONTEXT_DEFAULTS = {\n width: 1,\n height: 1,\n debug: true,\n throwOnError: false\n};\n\n/** Duck typing for the main headless gl export, a function to create contexts */\nexport type HeadlessGL = (width: number, height: number, options: Record<string, unknown>) => WebGLRenderingContext;\n\nlet headlessGL: HeadlessGL | null = null; \n\n/** By importing `gl` and registering it with this function, contexts can be created under Node.js */\nexport function registerHeadlessGL(headlessgl: HeadlessGL) {\n headlessGL = headlessgl;\n}\n\n/** @returns true if headless gl is registered */\nexport function isHeadlessGLRegistered(): boolean {\n return headlessGL !== null;\n}\n\n/** Create headless gl context (for running under Node.js) */\nexport function createHeadlessContext(options?: Record<string, any>): WebGLRenderingContext {\n options = {...CONTEXT_DEFAULTS, ...options};\n\n const {width, height, webgl1, webgl2} = options;\n\n if (webgl2 && !webgl1) {\n throw new Error('headless-gl does not support WebGL2');\n }\n if (!headlessGL) {\n throw new Error(ERR_HEADLESSGL_LOAD);\n }\n const gl = headlessGL(width, height, options);\n if (!gl) {\n throw new Error(ERR_HEADLESSGL_FAILED);\n }\n return gl;\n}\n"],"file":"create-headless-context.js"}
|
|
@@ -0,0 +1,133 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
|
+
|
|
5
|
+
Object.defineProperty(exports, "__esModule", {
|
|
6
|
+
value: true
|
|
7
|
+
});
|
|
8
|
+
exports.loadSpectorJS = loadSpectorJS;
|
|
9
|
+
exports.initializeSpectorJS = initializeSpectorJS;
|
|
10
|
+
|
|
11
|
+
var _regenerator = _interopRequireDefault(require("@babel/runtime/regenerator"));
|
|
12
|
+
|
|
13
|
+
var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
|
|
14
|
+
|
|
15
|
+
var _asyncToGenerator2 = _interopRequireDefault(require("@babel/runtime/helpers/asyncToGenerator"));
|
|
16
|
+
|
|
17
|
+
var _api = require("@luma.gl/api");
|
|
18
|
+
|
|
19
|
+
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); if (enumerableOnly) { symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; }); } keys.push.apply(keys, symbols); } return keys; }
|
|
20
|
+
|
|
21
|
+
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; if (i % 2) { ownKeys(Object(source), true).forEach(function (key) { (0, _defineProperty2.default)(target, key, source[key]); }); } else if (Object.getOwnPropertyDescriptors) { Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)); } else { ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } } return target; }
|
|
22
|
+
|
|
23
|
+
var DEFAULT_SPECTOR_PROPS = {
|
|
24
|
+
spector: _api.log.get('spector') || _api.log.get('inspect')
|
|
25
|
+
};
|
|
26
|
+
var SPECTOR_CDN_URL = 'https://spectorcdn.babylonjs.com/spector.bundle.js';
|
|
27
|
+
var LOG_LEVEL = 1;
|
|
28
|
+
var spector = null;
|
|
29
|
+
var initialized = false;
|
|
30
|
+
|
|
31
|
+
function loadSpectorJS(_x) {
|
|
32
|
+
return _loadSpectorJS.apply(this, arguments);
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
function _loadSpectorJS() {
|
|
36
|
+
_loadSpectorJS = (0, _asyncToGenerator2.default)(_regenerator.default.mark(function _callee(props) {
|
|
37
|
+
return _regenerator.default.wrap(function _callee$(_context) {
|
|
38
|
+
while (1) {
|
|
39
|
+
switch (_context.prev = _context.next) {
|
|
40
|
+
case 0:
|
|
41
|
+
if (globalThis.SPECTOR) {
|
|
42
|
+
_context.next = 9;
|
|
43
|
+
break;
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
_context.prev = 1;
|
|
47
|
+
_context.next = 4;
|
|
48
|
+
return (0, _api.loadScript)(SPECTOR_CDN_URL);
|
|
49
|
+
|
|
50
|
+
case 4:
|
|
51
|
+
_context.next = 9;
|
|
52
|
+
break;
|
|
53
|
+
|
|
54
|
+
case 6:
|
|
55
|
+
_context.prev = 6;
|
|
56
|
+
_context.t0 = _context["catch"](1);
|
|
57
|
+
|
|
58
|
+
_api.log.warn(String(_context.t0));
|
|
59
|
+
|
|
60
|
+
case 9:
|
|
61
|
+
case "end":
|
|
62
|
+
return _context.stop();
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
}, _callee, null, [[1, 6]]);
|
|
66
|
+
}));
|
|
67
|
+
return _loadSpectorJS.apply(this, arguments);
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
function initializeSpectorJS(props) {
|
|
71
|
+
var _props, _props2;
|
|
72
|
+
|
|
73
|
+
props = _objectSpread(_objectSpread({}, DEFAULT_SPECTOR_PROPS), props);
|
|
74
|
+
|
|
75
|
+
if (!((_props = props) !== null && _props !== void 0 && _props.spector)) {
|
|
76
|
+
return null;
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
if (!spector && globalThis.SPECTOR) {
|
|
80
|
+
_api.log.probe(LOG_LEVEL, "SPECTOR found and initialized")();
|
|
81
|
+
|
|
82
|
+
spector = new globalThis.SPECTOR.Spector();
|
|
83
|
+
|
|
84
|
+
if (globalThis.luma) {
|
|
85
|
+
globalThis.luma.spector = spector;
|
|
86
|
+
}
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
if (!spector) {
|
|
90
|
+
return null;
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
if (!initialized) {
|
|
94
|
+
var _spector, _spector2;
|
|
95
|
+
|
|
96
|
+
initialized = true;
|
|
97
|
+
spector.spyCanvases();
|
|
98
|
+
(_spector = spector) === null || _spector === void 0 ? void 0 : _spector.onCaptureStarted.add(function (capture) {
|
|
99
|
+
return _api.log.info("Spector capture started:", capture)();
|
|
100
|
+
});
|
|
101
|
+
(_spector2 = spector) === null || _spector2 === void 0 ? void 0 : _spector2.onCapture.add(function (capture) {
|
|
102
|
+
var _spector3, _spector4, _spector5;
|
|
103
|
+
|
|
104
|
+
_api.log.info("Spector capture complete:", capture)();
|
|
105
|
+
|
|
106
|
+
(_spector3 = spector) === null || _spector3 === void 0 ? void 0 : _spector3.getResultUI();
|
|
107
|
+
(_spector4 = spector) === null || _spector4 === void 0 ? void 0 : _spector4.resultView.display();
|
|
108
|
+
(_spector5 = spector) === null || _spector5 === void 0 ? void 0 : _spector5.resultView.addCapture(capture);
|
|
109
|
+
});
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
if ((_props2 = props) !== null && _props2 !== void 0 && _props2.canvas) {
|
|
113
|
+
var _spector6, _props3;
|
|
114
|
+
|
|
115
|
+
if (typeof props.spector === 'string' && props.spector !== props.canvas.id) {
|
|
116
|
+
return spector;
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
(_spector6 = spector) === null || _spector6 === void 0 ? void 0 : _spector6.startCapture((_props3 = props) === null || _props3 === void 0 ? void 0 : _props3.canvas, 500);
|
|
120
|
+
new Promise(function (resolve) {
|
|
121
|
+
return setTimeout(resolve, 2000);
|
|
122
|
+
}).then(function (_) {
|
|
123
|
+
var _spector7;
|
|
124
|
+
|
|
125
|
+
_api.log.info("Spector capture stopped after 2 seconds")();
|
|
126
|
+
|
|
127
|
+
(_spector7 = spector) === null || _spector7 === void 0 ? void 0 : _spector7.stopCapture();
|
|
128
|
+
});
|
|
129
|
+
}
|
|
130
|
+
|
|
131
|
+
return spector;
|
|
132
|
+
}
|
|
133
|
+
//# sourceMappingURL=spector.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../../src/context/debug/spector.ts"],"names":["DEFAULT_SPECTOR_PROPS","spector","log","get","SPECTOR_CDN_URL","LOG_LEVEL","initialized","loadSpectorJS","props","globalThis","SPECTOR","warn","String","initializeSpectorJS","probe","Spector","luma","spyCanvases","onCaptureStarted","add","capture","info","onCapture","getResultUI","resultView","display","addCapture","canvas","id","startCapture","Promise","resolve","setTimeout","then","_","stopCapture"],"mappings":";;;;;;;;;;;;;;;;AACA;;;;;;AAYA,IAAMA,qBAAmC,GAAG;AAC1CC,EAAAA,OAAO,EAAEC,SAAIC,GAAJ,CAAQ,SAAR,KAAsBD,SAAIC,GAAJ,CAAQ,SAAR;AADW,CAA5C;AAKA,IAAMC,eAAe,GAAG,oDAAxB;AACA,IAAMC,SAAS,GAAG,CAAlB;AAEA,IAAIJ,OAAY,GAAG,IAAnB;AACA,IAAIK,WAAoB,GAAG,KAA3B;;SAOsBC,a;;;;;6EAAf,iBAA6BC,KAA7B;AAAA;AAAA;AAAA;AAAA;AAAA,gBACAC,UAAU,CAACC,OADX;AAAA;AAAA;AAAA;;AAAA;AAAA;AAAA,mBAGK,qBAAWN,eAAX,CAHL;;AAAA;AAAA;AAAA;;AAAA;AAAA;AAAA;;AAKDF,qBAAIS,IAAJ,CAASC,MAAM,aAAf;;AALC;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,G;;;;AAUA,SAASC,mBAAT,CAA6BL,KAA7B,EAAmD;AAAA;;AACxDA,EAAAA,KAAK,mCAAOR,qBAAP,GAAiCQ,KAAjC,CAAL;;AACA,MAAI,YAACA,KAAD,mCAAC,OAAOP,OAAR,CAAJ,EAAqB;AACnB,WAAO,IAAP;AACD;;AAED,MAAI,CAACA,OAAD,IAAYQ,UAAU,CAACC,OAA3B,EAAoC;AAClCR,aAAIY,KAAJ,CAAUT,SAAV,EAAqB,+BAArB;;AACAJ,IAAAA,OAAO,GAAG,IAAIQ,UAAU,CAACC,OAAX,CAAmBK,OAAvB,EAAV;;AACA,QAAIN,UAAU,CAACO,IAAf,EAAqB;AACnBP,MAAAA,UAAU,CAACO,IAAX,CAAgBf,OAAhB,GAA0BA,OAA1B;AACD;AACF;;AAED,MAAI,CAACA,OAAL,EAAc;AACZ,WAAO,IAAP;AACD;;AAED,MAAI,CAACK,WAAL,EAAkB;AAAA;;AAChBA,IAAAA,WAAW,GAAG,IAAd;AAGAL,IAAAA,OAAO,CAACgB,WAAR;AAEA,gBAAAhB,OAAO,UAAP,4CAASiB,gBAAT,CAA0BC,GAA1B,CAA8B,UAACC,OAAD;AAAA,aAAsBlB,SAAImB,IAAJ,6BAAqCD,OAArC,GAAtB;AAAA,KAA9B;AACA,iBAAAnB,OAAO,UAAP,8CAASqB,SAAT,CAAmBH,GAAnB,CAAuB,UAACC,OAAD,EAAsB;AAAA;;AAC3ClB,eAAImB,IAAJ,8BAAsCD,OAAtC;;AAGA,mBAAAnB,OAAO,UAAP,8CAASsB,WAAT;AACA,mBAAAtB,OAAO,UAAP,8CAASuB,UAAT,CAAoBC,OAApB;AACA,mBAAAxB,OAAO,UAAP,8CAASuB,UAAT,CAAoBE,UAApB,CAA+BN,OAA/B;AACD,KAPD;AAQD;;AAED,iBAAIZ,KAAJ,oCAAI,QAAOmB,MAAX,EAAmB;AAAA;;AAEjB,QAAI,OAAOnB,KAAK,CAACP,OAAb,KAAyB,QAAzB,IAAqCO,KAAK,CAACP,OAAN,KAAkBO,KAAK,CAACmB,MAAN,CAAaC,EAAxE,EAA4E;AAC1E,aAAO3B,OAAP;AACD;;AAID,iBAAAA,OAAO,UAAP,8CAAS4B,YAAT,YAAsBrB,KAAtB,4CAAsB,QAAOmB,MAA7B,EAAqC,GAArC;AACA,QAAIG,OAAJ,CAAY,UAAAC,OAAO;AAAA,aAAIC,UAAU,CAACD,OAAD,EAAU,IAAV,CAAd;AAAA,KAAnB,EAAkDE,IAAlD,CAAuD,UAAAC,CAAC,EAAI;AAAA;;AAC1DhC,eAAImB,IAAJ;;AACA,mBAAApB,OAAO,UAAP,8CAASkC,WAAT;AAED,KAJD;AAKD;;AAED,SAAOlC,OAAP;AACD","sourcesContent":["// luma.gl, MIT license\nimport {log, loadScript} from '@luma.gl/api';\n\n/** Spector debug initialization options */\ntype SpectorProps = {\n /** Canvas to monitor */\n canvas?: HTMLCanvasElement | OffscreenCanvas;\n /** Whether debug is enabled. Auto-detected if ommitted */\n debug?: boolean;\n /** Whether spector is disabled */\n spector?: boolean | string | object;\n};\n\nconst DEFAULT_SPECTOR_PROPS: SpectorProps = {\n spector: log.get('spector') || log.get('inspect')\n};\n\n// https://github.com/BabylonJS/Spector.js#basic-usage\nconst SPECTOR_CDN_URL = 'https://spectorcdn.babylonjs.com/spector.bundle.js';\nconst LOG_LEVEL = 1;\n\nlet spector: any = null;\nlet initialized: boolean = false;\n\ndeclare global {\n var SPECTOR: any;\n}\n\n/** Loads spector from CDN if not already installed */\nexport async function loadSpectorJS(props?: SpectorProps) {\n if (!globalThis.SPECTOR) {\n try {\n await loadScript(SPECTOR_CDN_URL);\n } catch(error) {\n log.warn(String(error))\n }\n }\n}\n\nexport function initializeSpectorJS(props?: SpectorProps) {\n props = {...DEFAULT_SPECTOR_PROPS, ...props};\n if (!props?.spector) {\n return null;\n }\n\n if (!spector && globalThis.SPECTOR) {\n log.probe(LOG_LEVEL, \"SPECTOR found and initialized\")();\n spector = new globalThis.SPECTOR.Spector();\n if (globalThis.luma) {\n globalThis.luma.spector = spector;\n }\n }\n\n if (!spector) {\n return null;\n }\n\n if (!initialized) {\n initialized = true;\n\n // enables recording some extra information merged in the capture like texture memory sizes and formats\n spector.spyCanvases();\n // A callback when results are ready\n spector?.onCaptureStarted.add((capture: unknown) => log.info(`Spector capture started:`, capture)());\n spector?.onCapture.add((capture: unknown) => {\n log.info(`Spector capture complete:`, capture)();\n // Use undocumented Spector API to open the UI with our capture\n // See https://github.com/BabylonJS/Spector.js/blob/767ad1195a25b85a85c381f400eb50a979239eca/src/spector.ts#L124\n spector?.getResultUI()\n spector?.resultView.display();\n spector?.resultView.addCapture(capture)\n });\n }\n\n if (props?.canvas) {\n // @ts-expect-error If spector is specified as a canvas id, only monitor that canvas\n if (typeof props.spector === 'string' && props.spector !== props.canvas.id) {\n return spector;\n }\n\n // capture startup\n // spector?.captureCanvas(props?.canvas);\n spector?.startCapture(props?.canvas, 500); // 500 commands\n new Promise(resolve => setTimeout(resolve, 2000)).then(_ => {\n log.info(`Spector capture stopped after 2 seconds`)();\n spector?.stopCapture();\n // spector?.displayUI();\n });\n }\n\n return spector;\n}\n"],"file":"spector.js"}
|
|
@@ -0,0 +1,198 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
|
+
|
|
5
|
+
Object.defineProperty(exports, "__esModule", {
|
|
6
|
+
value: true
|
|
7
|
+
});
|
|
8
|
+
exports.loadWebGLDeveloperTools = loadWebGLDeveloperTools;
|
|
9
|
+
exports.makeDebugContext = makeDebugContext;
|
|
10
|
+
|
|
11
|
+
var _regenerator = _interopRequireDefault(require("@babel/runtime/regenerator"));
|
|
12
|
+
|
|
13
|
+
var _classCallCheck2 = _interopRequireDefault(require("@babel/runtime/helpers/classCallCheck"));
|
|
14
|
+
|
|
15
|
+
var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
|
|
16
|
+
|
|
17
|
+
var _asyncToGenerator2 = _interopRequireDefault(require("@babel/runtime/helpers/asyncToGenerator"));
|
|
18
|
+
|
|
19
|
+
var _api = require("@luma.gl/api/");
|
|
20
|
+
|
|
21
|
+
var _constants = _interopRequireDefault(require("@luma.gl/constants"));
|
|
22
|
+
|
|
23
|
+
function _createForOfIteratorHelper(o, allowArrayLike) { var it = typeof Symbol !== "undefined" && o[Symbol.iterator] || o["@@iterator"]; if (!it) { if (Array.isArray(o) || (it = _unsupportedIterableToArray(o)) || allowArrayLike && o && typeof o.length === "number") { if (it) o = it; var i = 0; var F = function F() {}; return { s: F, n: function n() { if (i >= o.length) return { done: true }; return { done: false, value: o[i++] }; }, e: function e(_e) { throw _e; }, f: F }; } throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); } var normalCompletion = true, didErr = false, err; return { s: function s() { it = it.call(o); }, n: function n() { var step = it.next(); normalCompletion = step.done; return step; }, e: function e(_e2) { didErr = true; err = _e2; }, f: function f() { try { if (!normalCompletion && it.return != null) it.return(); } finally { if (didErr) throw err; } } }; }
|
|
24
|
+
|
|
25
|
+
function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
|
|
26
|
+
|
|
27
|
+
function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) { arr2[i] = arr[i]; } return arr2; }
|
|
28
|
+
|
|
29
|
+
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); if (enumerableOnly) { symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; }); } keys.push.apply(keys, symbols); } return keys; }
|
|
30
|
+
|
|
31
|
+
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; if (i % 2) { ownKeys(Object(source), true).forEach(function (key) { (0, _defineProperty2.default)(target, key, source[key]); }); } else if (Object.getOwnPropertyDescriptors) { Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)); } else { ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } } return target; }
|
|
32
|
+
|
|
33
|
+
var WEBGL_DEBUG_CDN_URL = 'https://unpkg.com/webgl-debug@2.0.1/index.js';
|
|
34
|
+
var DEFAULT_DEBUG_CONTEXT_PROPS = {
|
|
35
|
+
debug: true,
|
|
36
|
+
throwOnError: false,
|
|
37
|
+
break: [],
|
|
38
|
+
webgl2: false
|
|
39
|
+
};
|
|
40
|
+
|
|
41
|
+
function getContextData(gl) {
|
|
42
|
+
gl.luma = gl.luma || {};
|
|
43
|
+
return gl.luma;
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
function loadWebGLDeveloperTools() {
|
|
47
|
+
return _loadWebGLDeveloperTools.apply(this, arguments);
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
function _loadWebGLDeveloperTools() {
|
|
51
|
+
_loadWebGLDeveloperTools = (0, _asyncToGenerator2.default)(_regenerator.default.mark(function _callee() {
|
|
52
|
+
return _regenerator.default.wrap(function _callee$(_context) {
|
|
53
|
+
while (1) {
|
|
54
|
+
switch (_context.prev = _context.next) {
|
|
55
|
+
case 0:
|
|
56
|
+
if (globalThis.WebGLDebugUtils) {
|
|
57
|
+
_context.next = 5;
|
|
58
|
+
break;
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
globalThis.global = globalThis.global || globalThis;
|
|
62
|
+
globalThis.global.module = {};
|
|
63
|
+
_context.next = 5;
|
|
64
|
+
return (0, _api.loadScript)(WEBGL_DEBUG_CDN_URL);
|
|
65
|
+
|
|
66
|
+
case 5:
|
|
67
|
+
case "end":
|
|
68
|
+
return _context.stop();
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
}, _callee);
|
|
72
|
+
}));
|
|
73
|
+
return _loadWebGLDeveloperTools.apply(this, arguments);
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
function makeDebugContext(gl) {
|
|
77
|
+
var props = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
|
|
78
|
+
|
|
79
|
+
if (!gl) {
|
|
80
|
+
return null;
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
return props.debug ? getDebugContext(gl, props) : getRealContext(gl);
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
function getRealContext(gl) {
|
|
87
|
+
var data = getContextData(gl);
|
|
88
|
+
return data.realContext ? data.realContext : gl;
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
function getDebugContext(gl, props) {
|
|
92
|
+
if (!globalThis.WebGLDebugUtils) {
|
|
93
|
+
_api.log.warn('webgl-debug not loaded')();
|
|
94
|
+
|
|
95
|
+
return gl;
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
var data = getContextData(gl);
|
|
99
|
+
|
|
100
|
+
if (data.debugContext) {
|
|
101
|
+
return data.debugContext;
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
globalThis.WebGLDebugUtils.init(_objectSpread(_objectSpread({}, _constants.default), gl));
|
|
105
|
+
var glDebug = globalThis.WebGLDebugUtils.makeDebugContext(gl, onGLError.bind(null, props), onValidateGLFunc.bind(null, props));
|
|
106
|
+
|
|
107
|
+
for (var key in _constants.default) {
|
|
108
|
+
if (!(key in glDebug) && typeof _constants.default[key] === 'number') {
|
|
109
|
+
glDebug[key] = _constants.default[key];
|
|
110
|
+
}
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
var WebGLDebugContext = function WebGLDebugContext() {
|
|
114
|
+
(0, _classCallCheck2.default)(this, WebGLDebugContext);
|
|
115
|
+
};
|
|
116
|
+
|
|
117
|
+
Object.setPrototypeOf(glDebug, Object.getPrototypeOf(gl));
|
|
118
|
+
Object.setPrototypeOf(WebGLDebugContext, glDebug);
|
|
119
|
+
var debugContext = Object.create(WebGLDebugContext);
|
|
120
|
+
data.realContext = gl;
|
|
121
|
+
data.debugContext = debugContext;
|
|
122
|
+
debugContext.debug = true;
|
|
123
|
+
return debugContext;
|
|
124
|
+
}
|
|
125
|
+
|
|
126
|
+
function getFunctionString(functionName, functionArgs) {
|
|
127
|
+
functionArgs = Array.from(functionArgs).map(function (arg) {
|
|
128
|
+
return arg === undefined ? 'undefined' : arg;
|
|
129
|
+
});
|
|
130
|
+
var args = globalThis.WebGLDebugUtils.glFunctionArgsToString(functionName, functionArgs);
|
|
131
|
+
args = "".concat(args.slice(0, 100)).concat(args.length > 100 ? '...' : '');
|
|
132
|
+
return "gl.".concat(functionName, "(").concat(args, ")");
|
|
133
|
+
}
|
|
134
|
+
|
|
135
|
+
function onGLError(props, err, functionName, args) {
|
|
136
|
+
args = Array.from(args).map(function (arg) {
|
|
137
|
+
return arg === undefined ? 'undefined' : arg;
|
|
138
|
+
});
|
|
139
|
+
var errorMessage = globalThis.WebGLDebugUtils.glEnumToString(err);
|
|
140
|
+
var functionArgs = globalThis.WebGLDebugUtils.glFunctionArgsToString(functionName, args);
|
|
141
|
+
var glName = props.webgl2 ? 'gl2' : 'gl1';
|
|
142
|
+
var message = "".concat(errorMessage, " in ").concat(glName, ".").concat(functionName, "(").concat(functionArgs, ")");
|
|
143
|
+
|
|
144
|
+
_api.log.error(message)();
|
|
145
|
+
|
|
146
|
+
debugger;
|
|
147
|
+
|
|
148
|
+
if (props.throwOnError) {
|
|
149
|
+
throw new Error(message);
|
|
150
|
+
}
|
|
151
|
+
}
|
|
152
|
+
|
|
153
|
+
function onValidateGLFunc(props, functionName, functionArgs) {
|
|
154
|
+
var functionString = '';
|
|
155
|
+
|
|
156
|
+
if (_api.log.level >= 1) {
|
|
157
|
+
functionString = getFunctionString(functionName, functionArgs);
|
|
158
|
+
|
|
159
|
+
_api.log.log(1, functionString)();
|
|
160
|
+
}
|
|
161
|
+
|
|
162
|
+
if (props.break) {
|
|
163
|
+
functionString = functionString || getFunctionString(functionName, functionArgs);
|
|
164
|
+
var isBreakpoint = props.break && props.break.every(function (breakOn) {
|
|
165
|
+
return functionString.indexOf(breakOn) !== -1;
|
|
166
|
+
});
|
|
167
|
+
|
|
168
|
+
if (isBreakpoint) {
|
|
169
|
+
debugger;
|
|
170
|
+
}
|
|
171
|
+
}
|
|
172
|
+
|
|
173
|
+
var _iterator = _createForOfIteratorHelper(functionArgs),
|
|
174
|
+
_step;
|
|
175
|
+
|
|
176
|
+
try {
|
|
177
|
+
for (_iterator.s(); !(_step = _iterator.n()).done;) {
|
|
178
|
+
var arg = _step.value;
|
|
179
|
+
|
|
180
|
+
if (arg === undefined) {
|
|
181
|
+
functionString = functionString || getFunctionString(functionName, functionArgs);
|
|
182
|
+
|
|
183
|
+
if (props.throwOnError) {
|
|
184
|
+
throw new Error("Undefined argument: ".concat(functionString));
|
|
185
|
+
} else {
|
|
186
|
+
_api.log.error("Undefined argument: ".concat(functionString))();
|
|
187
|
+
|
|
188
|
+
debugger;
|
|
189
|
+
}
|
|
190
|
+
}
|
|
191
|
+
}
|
|
192
|
+
} catch (err) {
|
|
193
|
+
_iterator.e(err);
|
|
194
|
+
} finally {
|
|
195
|
+
_iterator.f();
|
|
196
|
+
}
|
|
197
|
+
}
|
|
198
|
+
//# sourceMappingURL=webgl-developer-tools.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../../src/context/debug/webgl-developer-tools.ts"],"names":["WEBGL_DEBUG_CDN_URL","DEFAULT_DEBUG_CONTEXT_PROPS","debug","throwOnError","break","webgl2","getContextData","gl","luma","loadWebGLDeveloperTools","globalThis","WebGLDebugUtils","global","module","makeDebugContext","props","getDebugContext","getRealContext","data","realContext","log","warn","debugContext","init","GL","glDebug","onGLError","bind","onValidateGLFunc","key","WebGLDebugContext","Object","setPrototypeOf","getPrototypeOf","create","getFunctionString","functionName","functionArgs","Array","from","map","arg","undefined","args","glFunctionArgsToString","slice","length","err","errorMessage","glEnumToString","glName","message","error","Error","functionString","level","isBreakpoint","every","breakOn","indexOf"],"mappings":";;;;;;;;;;;;;;;;;;AACA;;AACA;;;;;;;;;;;;AAEA,IAAMA,mBAAmB,GAAG,8CAA5B;AASA,IAAMC,2BAAwD,GAAG;AAC/DC,EAAAA,KAAK,EAAE,IADwD;AAE/DC,EAAAA,YAAY,EAAE,KAFiD;AAG/DC,EAAAA,KAAK,EAAE,EAHwD;AAI/DC,EAAAA,MAAM,EAAE;AAJuD,CAAjE;;AAQA,SAASC,cAAT,CAAwBC,EAAxB,EAAiC;AAC/BA,EAAAA,EAAE,CAACC,IAAH,GAAUD,EAAE,CAACC,IAAH,IAAW,EAArB;AACA,SAAOD,EAAE,CAACC,IAAV;AACD;;SAYqBC,uB;;;;;uFAAf;AAAA;AAAA;AAAA;AAAA;AAAA,gBACAC,UAAU,CAACC,eADX;AAAA;AAAA;AAAA;;AAGHD,YAAAA,UAAU,CAACE,MAAX,GAAoBF,UAAU,CAACE,MAAX,IAAqBF,UAAzC;AAEAA,YAAAA,UAAU,CAACE,MAAX,CAAkBC,MAAlB,GAA2B,EAA3B;AALG;AAAA,mBAMG,qBAAWb,mBAAX,CANH;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,G;;;;AAYA,SAASc,gBAAT,CAA0BP,EAA1B,EAAkH;AAAA,MAA7DQ,KAA6D,uEAAlC,EAAkC;;AAEvH,MAAI,CAACR,EAAL,EAAS;AACP,WAAO,IAAP;AACD;;AAED,SAAOQ,KAAK,CAACb,KAAN,GAAcc,eAAe,CAACT,EAAD,EAAKQ,KAAL,CAA7B,GAA2CE,cAAc,CAACV,EAAD,CAAhE;AACD;;AAGD,SAASU,cAAT,CAAwBV,EAAxB,EAA0E;AACxE,MAAMW,IAAI,GAAGZ,cAAc,CAACC,EAAD,CAA3B;AAEA,SAAOW,IAAI,CAACC,WAAL,GAAmBD,IAAI,CAACC,WAAxB,GAAsCZ,EAA7C;AACD;;AAGD,SAASS,eAAT,CAAyBT,EAAzB,EAAoDQ,KAApD,EAAqG;AACnG,MAAI,CAACL,UAAU,CAACC,eAAhB,EAAiC;AAC/BS,aAAIC,IAAJ,CAAS,wBAAT;;AACA,WAAOd,EAAP;AACD;;AAED,MAAMW,IAAI,GAAGZ,cAAc,CAACC,EAAD,CAA3B;;AAGA,MAAIW,IAAI,CAACI,YAAT,EAAuB;AACrB,WAAOJ,IAAI,CAACI,YAAZ;AACD;;AAGDZ,EAAAA,UAAU,CAACC,eAAX,CAA2BY,IAA3B,iCAAoCC,kBAApC,GAA2CjB,EAA3C;AACA,MAAMkB,OAAO,GAAGf,UAAU,CAACC,eAAX,CAA2BG,gBAA3B,CACdP,EADc,EAEdmB,SAAS,CAACC,IAAV,CAAe,IAAf,EAAqBZ,KAArB,CAFc,EAGda,gBAAgB,CAACD,IAAjB,CAAsB,IAAtB,EAA4BZ,KAA5B,CAHc,CAAhB;;AAOA,OAAK,IAAMc,GAAX,IAAkBL,kBAAlB,EAAsB;AACpB,QAAI,EAAEK,GAAG,IAAIJ,OAAT,KAAqB,OAAOD,mBAAGK,GAAH,CAAP,KAAmB,QAA5C,EAAsD;AACpDJ,MAAAA,OAAO,CAACI,GAAD,CAAP,GAAeL,mBAAGK,GAAH,CAAf;AACD;AACF;;AA1BkG,MA+B7FC,iBA/B6F;AAAA;AAAA;;AAgCnGC,EAAAA,MAAM,CAACC,cAAP,CAAsBP,OAAtB,EAA+BM,MAAM,CAACE,cAAP,CAAsB1B,EAAtB,CAA/B;AACAwB,EAAAA,MAAM,CAACC,cAAP,CAAsBF,iBAAtB,EAAyCL,OAAzC;AACA,MAAMH,YAAY,GAAGS,MAAM,CAACG,MAAP,CAAcJ,iBAAd,CAArB;AAEAZ,EAAAA,IAAI,CAACC,WAAL,GAAmBZ,EAAnB;AACAW,EAAAA,IAAI,CAACI,YAAL,GAAoBA,YAApB;AACAA,EAAAA,YAAY,CAACpB,KAAb,GAAqB,IAArB;AAGA,SAAOoB,YAAP;AACD;;AAID,SAASa,iBAAT,CAA2BC,YAA3B,EAAiDC,YAAjD,EAAuE;AAErEA,EAAAA,YAAY,GAAGC,KAAK,CAACC,IAAN,CAAWF,YAAX,EAAyBG,GAAzB,CAA6B,UAAAC,GAAG;AAAA,WAAIA,GAAG,KAAKC,SAAR,GAAoB,WAApB,GAAkCD,GAAtC;AAAA,GAAhC,CAAf;AACA,MAAIE,IAAI,GAAGjC,UAAU,CAACC,eAAX,CAA2BiC,sBAA3B,CAAkDR,YAAlD,EAAgEC,YAAhE,CAAX;AACAM,EAAAA,IAAI,aAAMA,IAAI,CAACE,KAAL,CAAW,CAAX,EAAc,GAAd,CAAN,SAA2BF,IAAI,CAACG,MAAL,GAAc,GAAd,GAAoB,KAApB,GAA4B,EAAvD,CAAJ;AACA,sBAAaV,YAAb,cAA6BO,IAA7B;AACD;;AAED,SAASjB,SAAT,CAAmBX,KAAnB,EAA6CgC,GAA7C,EAAkDX,YAAlD,EAAwEO,IAAxE,EAA2F;AAEzFA,EAAAA,IAAI,GAAGL,KAAK,CAACC,IAAN,CAAWI,IAAX,EAAiBH,GAAjB,CAAqB,UAAAC,GAAG;AAAA,WAAIA,GAAG,KAAKC,SAAR,GAAoB,WAApB,GAAkCD,GAAtC;AAAA,GAAxB,CAAP;AACA,MAAMO,YAAY,GAAGtC,UAAU,CAACC,eAAX,CAA2BsC,cAA3B,CAA0CF,GAA1C,CAArB;AACA,MAAMV,YAAY,GAAG3B,UAAU,CAACC,eAAX,CAA2BiC,sBAA3B,CAAkDR,YAAlD,EAAgEO,IAAhE,CAArB;AACA,MAAMO,MAAM,GAAGnC,KAAK,CAACV,MAAN,GAAe,KAAf,GAAuB,KAAtC;AACA,MAAM8C,OAAO,aAAMH,YAAN,iBAAyBE,MAAzB,cAAmCd,YAAnC,cAAmDC,YAAnD,MAAb;;AACAjB,WAAIgC,KAAJ,CAAUD,OAAV;;AACA;;AACA,MAAIpC,KAAK,CAACZ,YAAV,EAAwB;AACtB,UAAM,IAAIkD,KAAJ,CAAUF,OAAV,CAAN;AACD;AACF;;AAGD,SAASvB,gBAAT,CAA0Bb,KAA1B,EAAoDqB,YAApD,EAA0EC,YAA1E,EAAqG;AACnG,MAAIiB,cAAsB,GAAG,EAA7B;;AACA,MAAIlC,SAAImC,KAAJ,IAAa,CAAjB,EAAoB;AAClBD,IAAAA,cAAc,GAAGnB,iBAAiB,CAACC,YAAD,EAAeC,YAAf,CAAlC;;AACAjB,aAAIA,GAAJ,CAAQ,CAAR,EAAWkC,cAAX;AACD;;AAED,MAAIvC,KAAK,CAACX,KAAV,EAAiB;AACfkD,IAAAA,cAAc,GAAGA,cAAc,IAAInB,iBAAiB,CAACC,YAAD,EAAeC,YAAf,CAApD;AACA,QAAMmB,YAAY,GAChBzC,KAAK,CAACX,KAAN,IAAeW,KAAK,CAACX,KAAN,CAAYqD,KAAZ,CAAkB,UAACC,OAAD;AAAA,aAAqBJ,cAAc,CAACK,OAAf,CAAuBD,OAAvB,MAAoC,CAAC,CAA1D;AAAA,KAAlB,CADjB;;AAEA,QAAIF,YAAJ,EAAkB;AAChB;AACD;AACF;;AAdkG,6CAgBjFnB,YAhBiF;AAAA;;AAAA;AAgBnG,wDAAgC;AAAA,UAArBI,GAAqB;;AAC9B,UAAIA,GAAG,KAAKC,SAAZ,EAAuB;AACrBY,QAAAA,cAAc,GAAGA,cAAc,IAAInB,iBAAiB,CAACC,YAAD,EAAeC,YAAf,CAApD;;AACA,YAAItB,KAAK,CAACZ,YAAV,EAAwB;AACtB,gBAAM,IAAIkD,KAAJ,+BAAiCC,cAAjC,EAAN;AACD,SAFD,MAEO;AACLlC,mBAAIgC,KAAJ,+BAAiCE,cAAjC;;AACA;AACD;AACF;AACF;AA1BkG;AAAA;AAAA;AAAA;AAAA;AA2BpG","sourcesContent":["// luma.gl, MIT license\nimport {log, loadScript} from '@luma.gl/api/';\nimport GL from '@luma.gl/constants';\n\nconst WEBGL_DEBUG_CDN_URL = 'https://unpkg.com/webgl-debug@2.0.1/index.js';\n\ntype DebugContextProps = {\n debug?: boolean;\n throwOnError?: boolean;\n break?: string[];\n webgl2?: boolean;\n};\n\nconst DEFAULT_DEBUG_CONTEXT_PROPS: Required<DebugContextProps> = {\n debug: true,\n throwOnError: false,\n break: [],\n webgl2: false,\n}\n\n// Helper to get shared context data\nfunction getContextData(gl: any) {\n gl.luma = gl.luma || {};\n return gl.luma;\n}\n\ndeclare global {\n var WebGLDebugUtils: any;\n}\n\n/**\n * Loads Khronos WebGLDeveloperTools from CDN if not already installed \n * const WebGLDebugUtils = require('webgl-debug');\n * @see https://github.com/KhronosGroup/WebGLDeveloperTools\n * @see https://github.com/vorg/webgl-debug\n */\nexport async function loadWebGLDeveloperTools(): Promise<void> {\n if (!globalThis.WebGLDebugUtils) {\n // @ts-expect-error Developer tools expects global to be set\n globalThis.global = globalThis.global || globalThis;\n // @ts-expect-error Developer tools expects global to be set\n globalThis.global.module = {};\n await loadScript(WEBGL_DEBUG_CDN_URL);\n }\n}\n\n// Returns (a potentially new) context with debug instrumentation turned off or on.\n// Note that this actually returns a new context\nexport function makeDebugContext(gl: WebGLRenderingContext, props: DebugContextProps = {}): WebGLRenderingContext | null {\n // Return null to ensure we don't try to create a context in this case (TODO what case is that?)\n if (!gl) {\n return null;\n }\n\n return props.debug ? getDebugContext(gl, props) : getRealContext(gl);\n}\n\n// Returns the real context from either of the real/debug contexts\nfunction getRealContext(gl: WebGLRenderingContext): WebGLRenderingContext {\n const data = getContextData(gl);\n // If the context has a realContext member, it is a debug context so return the realContext\n return data.realContext ? data.realContext : gl;\n}\n\n// Returns the debug context from either of the real/debug contexts\nfunction getDebugContext(gl: WebGLRenderingContext, props: DebugContextProps): WebGLRenderingContext {\n if (!globalThis.WebGLDebugUtils) {\n log.warn('webgl-debug not loaded')();\n return gl;\n }\n\n const data = getContextData(gl);\n\n // If this already has a debug context, return it.\n if (data.debugContext) {\n return data.debugContext;\n }\n\n // Create a new debug context\n globalThis.WebGLDebugUtils.init({...GL, ...gl});\n const glDebug = globalThis.WebGLDebugUtils.makeDebugContext(\n gl,\n onGLError.bind(null, props),\n onValidateGLFunc.bind(null, props)\n );\n\n // Make sure we have all WebGL2 and extension constants (todo dynamic import to circumvent minification?)\n for (const key in GL) {\n if (!(key in glDebug) && typeof GL[key] === 'number') {\n glDebug[key] = GL[key];\n }\n }\n \n // Ensure we have a clean prototype on the instrumented object\n // Note: setPrototypeOf does come with perf warnings, but we already take a bigger perf reduction\n // by synchronizing the WebGL errors after each WebGL call.\n class WebGLDebugContext {}\n Object.setPrototypeOf(glDebug, Object.getPrototypeOf(gl));\n Object.setPrototypeOf(WebGLDebugContext, glDebug);\n const debugContext = Object.create(WebGLDebugContext);\n // Store the debug context\n data.realContext = gl;\n data.debugContext = debugContext;\n debugContext.debug = true;\n\n // Return it\n return debugContext;\n}\n\n// DEBUG TRACING\n\nfunction getFunctionString(functionName: string, functionArgs): string {\n // Cover bug in webgl-debug-tools\n functionArgs = Array.from(functionArgs).map(arg => arg === undefined ? 'undefined' : arg);\n let args = globalThis.WebGLDebugUtils.glFunctionArgsToString(functionName, functionArgs);\n args = `${args.slice(0, 100)}${args.length > 100 ? '...' : ''}`;\n return `gl.${functionName}(${args})`;\n}\n\nfunction onGLError(props: DebugContextProps, err, functionName: string, args: any[]): void {\n // Cover bug in webgl-debug-tools\n args = Array.from(args).map(arg => arg === undefined ? 'undefined' : arg);\n const errorMessage = globalThis.WebGLDebugUtils.glEnumToString(err);\n const functionArgs = globalThis.WebGLDebugUtils.glFunctionArgsToString(functionName, args);\n const glName = props.webgl2 ? 'gl2' : 'gl1';\n const message = `${errorMessage} in ${glName}.${functionName}(${functionArgs})`;\n log.error(message)();\n debugger; // eslint-disable-line\n if (props.throwOnError) {\n throw new Error(message);\n }\n}\n\n// Don't generate function string until it is needed\nfunction onValidateGLFunc(props: DebugContextProps, functionName: string, functionArgs: any[]): void {\n let functionString: string = '';\n if (log.level >= 1) {\n functionString = getFunctionString(functionName, functionArgs);\n log.log(1, functionString)();\n }\n\n if (props.break) {\n functionString = functionString || getFunctionString(functionName, functionArgs);\n const isBreakpoint =\n props.break && props.break.every((breakOn: string) => functionString.indexOf(breakOn) !== -1);\n if (isBreakpoint) {\n debugger; // eslint-disable-line\n }\n }\n\n for (const arg of functionArgs) {\n if (arg === undefined) {\n functionString = functionString || getFunctionString(functionName, functionArgs);\n if (props.throwOnError) {\n throw new Error(`Undefined argument: ${functionString}`);\n } else {\n log.error(`Undefined argument: ${functionString}`)();\n debugger; // eslint-disable-line\n }\n }\n }\n}\n"],"file":"webgl-developer-tools.js"}
|
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
|
+
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
|
+
|
|
3
5
|
Object.defineProperty(exports, "__esModule", {
|
|
4
6
|
value: true
|
|
5
7
|
});
|
|
@@ -7,11 +9,9 @@ exports.setParameters = setParameters;
|
|
|
7
9
|
exports.getParameters = getParameters;
|
|
8
10
|
exports.resetParameters = resetParameters;
|
|
9
11
|
|
|
10
|
-
var _api = require("@luma.gl/api");
|
|
11
|
-
|
|
12
12
|
var _webglParameterTables = require("./webgl-parameter-tables");
|
|
13
13
|
|
|
14
|
-
var
|
|
14
|
+
var _webglDevice = _interopRequireDefault(require("../../adapter/webgl-device"));
|
|
15
15
|
|
|
16
16
|
function _createForOfIteratorHelper(o, allowArrayLike) { var it = typeof Symbol !== "undefined" && o[Symbol.iterator] || o["@@iterator"]; if (!it) { if (Array.isArray(o) || (it = _unsupportedIterableToArray(o)) || allowArrayLike && o && typeof o.length === "number") { if (it) o = it; var i = 0; var F = function F() {}; return { s: F, n: function n() { if (i >= o.length) return { done: true }; return { done: false, value: o[i++] }; }, e: function e(_e) { throw _e; }, f: F }; } throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); } var normalCompletion = true, didErr = false, err; return { s: function s() { it = it.call(o); }, n: function n() { var step = it.next(); normalCompletion = step.done; return step; }, e: function e(_e2) { didErr = true; err = _e2; }, f: function f() { try { if (!normalCompletion && it.return != null) it.return(); } finally { if (didErr) throw err; } } }; }
|
|
17
17
|
|
|
@@ -19,8 +19,10 @@ function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o =
|
|
|
19
19
|
|
|
20
20
|
function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) { arr2[i] = arr[i]; } return arr2; }
|
|
21
21
|
|
|
22
|
-
function setParameters(
|
|
23
|
-
|
|
22
|
+
function setParameters(device, parameters) {
|
|
23
|
+
var webglDevice = _webglDevice.default.attach(device);
|
|
24
|
+
|
|
25
|
+
var gl = webglDevice.gl;
|
|
24
26
|
|
|
25
27
|
if (isObjectEmpty(parameters)) {
|
|
26
28
|
return;
|
|
@@ -51,8 +53,12 @@ function setParameters(gl, parameters) {
|
|
|
51
53
|
}
|
|
52
54
|
}
|
|
53
55
|
|
|
54
|
-
function getParameters(
|
|
55
|
-
parameters =
|
|
56
|
+
function getParameters(device) {
|
|
57
|
+
var parameters = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : _webglParameterTables.GL_PARAMETER_DEFAULTS;
|
|
58
|
+
|
|
59
|
+
var webglDevice = _webglDevice.default.attach(device);
|
|
60
|
+
|
|
61
|
+
var gl = webglDevice.gl;
|
|
56
62
|
|
|
57
63
|
if (typeof parameters === 'number') {
|
|
58
64
|
var key = parameters;
|
|
@@ -81,8 +87,8 @@ function getParameters(gl, parameters) {
|
|
|
81
87
|
return state;
|
|
82
88
|
}
|
|
83
89
|
|
|
84
|
-
function resetParameters(
|
|
85
|
-
setParameters(
|
|
90
|
+
function resetParameters(device) {
|
|
91
|
+
setParameters(device, _webglParameterTables.GL_PARAMETER_DEFAULTS);
|
|
86
92
|
}
|
|
87
93
|
|
|
88
94
|
function isObjectEmpty(object) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../src/context/parameters/unified-parameter-api.ts"],"names":["setParameters","
|
|
1
|
+
{"version":3,"sources":["../../../../src/context/parameters/unified-parameter-api.ts"],"names":["setParameters","device","parameters","webglDevice","WebGLDevice","attach","gl","isObjectEmpty","compositeSetters","key","glConstant","Number","setter","GL_PARAMETER_SETTERS","cache","state","compositeSetter","GL_COMPOSITE_PARAMETER_SETTERS","getParameters","GL_PARAMETER_DEFAULTS","getter","GL_PARAMETER_GETTERS","getParameter","parameterKeys","Array","isArray","Object","keys","resetParameters","object"],"mappings":";;;;;;;;;;;AAKA;;AAQA;;;;;;;;AAUO,SAASA,aAAT,CACLC,MADK,EAELC,UAFK,EAGC;AACN,MAAMC,WAAW,GAAGC,qBAAYC,MAAZ,CAAmBJ,MAAnB,CAApB;;AACA,MAAMK,EAAE,GAAGH,WAAW,CAACG,EAAvB;;AAEA,MAAIC,aAAa,CAACL,UAAD,CAAjB,EAA+B;AAC7B;AACD;;AAED,MAAMM,gBAAgB,GAAG,EAAzB;;AAIA,OAAK,IAAMC,GAAX,IAAkBP,UAAlB,EAA8B;AAC5B,QAAMQ,UAAU,GAAGC,MAAM,CAACF,GAAD,CAAzB;AACA,QAAMG,MAAM,GAAGC,2CAAqBJ,GAArB,CAAf;;AACA,QAAIG,MAAJ,EAAY;AAEV,UAAI,OAAOA,MAAP,KAAkB,QAAtB,EAAgC;AAC9BJ,QAAAA,gBAAgB,CAACI,MAAD,CAAhB,GAA2B,IAA3B;AACD,OAFD,MAEO;AAKLA,QAAAA,MAAM,CAACN,EAAD,EAAKJ,UAAU,CAACO,GAAD,CAAf,EAAsBC,UAAtB,CAAN;AACD;AACF;AACF;;AAUD,MAAMI,KAAK,GAAGR,EAAE,CAACS,KAAH,IAAYT,EAAE,CAACS,KAAH,CAASD,KAAnC;;AACA,MAAIA,KAAJ,EAAW;AACT,SAAK,IAAML,IAAX,IAAkBD,gBAAlB,EAAoC;AAElC,UAAMQ,eAAe,GAAGC,qDAA+BR,IAA/B,CAAxB;AAGAO,MAAAA,eAAe,CAACV,EAAD,EAAKJ,UAAL,EAAiBY,KAAjB,CAAf;AACD;AACF;AAGF;;AAgBM,SAASI,aAAT,CACLjB,MADK,EAGS;AAAA,MADdC,UACc,uEAD2DiB,2CAC3D;;AACd,MAAMhB,WAAW,GAAGC,qBAAYC,MAAZ,CAAmBJ,MAAnB,CAApB;;AACA,MAAMK,EAAE,GAAGH,WAAW,CAACG,EAAvB;;AAIA,MAAI,OAAOJ,UAAP,KAAsB,QAA1B,EAAoC;AAElC,QAAMO,GAAG,GAAGP,UAAZ;AACA,QAAMkB,MAAM,GAAGC,2CAAqBZ,GAArB,CAAf;AACA,WAAOW,MAAM,GAAGA,MAAM,CAACd,EAAD,EAAKG,GAAL,CAAT,GAAqBH,EAAE,CAACgB,YAAH,CAAgBb,GAAhB,CAAlC;AACD;;AAED,MAAMc,aAAa,GAAGC,KAAK,CAACC,OAAN,CAAcvB,UAAd,IAA4BA,UAA5B,GAAyCwB,MAAM,CAACC,IAAP,CAAYzB,UAAZ,CAA/D;AAEA,MAAMa,KAAK,GAAG,EAAd;;AAfc,6CAgBIQ,aAhBJ;AAAA;;AAAA;AAgBd,wDAAiC;AAAA,UAAtBd,KAAsB;AAC/B,UAAMW,OAAM,GAAGC,2CAAqBZ,KAArB,CAAf;AACAM,MAAAA,KAAK,CAACN,KAAD,CAAL,GAAaW,OAAM,GAAGA,OAAM,CAACd,EAAD,EAAKK,MAAM,CAACF,KAAD,CAAX,CAAT,GAA6BH,EAAE,CAACgB,YAAH,CAAgBX,MAAM,CAACF,KAAD,CAAtB,CAAhD;AACD;AAnBa;AAAA;AAAA;AAAA;AAAA;;AAoBd,SAAOM,KAAP;AACD;;AAQM,SAASa,eAAT,CAAyB3B,MAAzB,EAAuE;AAC5ED,EAAAA,aAAa,CAACC,MAAD,EAASkB,2CAAT,CAAb;AACD;;AAKD,SAASZ,aAAT,CAAuBsB,MAAvB,EAA+B;AAC7B,OAAK,IAAMpB,GAAX,IAAkBoB,MAAlB,EAA0B;AACxB,WAAO,KAAP;AACD;;AACD,SAAO,IAAP;AACD","sourcesContent":["// Provides a unified API for getting and setting any WebGL parameter\n// Also knows default values of all parameters, enabling fast cache initialization\n// Provides base functionality for the state caching.\nimport {Device} from '@luma.gl/api';\nimport type {GLParameters} from '../../types/webgl';\nimport {\n GL_PARAMETER_DEFAULTS,\n GL_PARAMETER_SETTERS,\n GL_COMPOSITE_PARAMETER_SETTERS,\n GL_PARAMETER_GETTERS\n} from './webgl-parameter-tables';\n\nimport {isWebGL} from '../context/webgl-checks';\nimport WebGLDevice from '../../adapter/webgl-device';\n\nexport type {GLParameters};\n\n/**\n * Sets any GL parameter regardless of function (gl.blendMode, ...)\n *\n * @note requires a `cache` object to be set on the context (gl.state.cache)\n * This object is used to fill in any missing values for composite setter functions\n */\nexport function setParameters(\n device: Device | WebGLRenderingContext,\n parameters: GLParameters\n): void {\n const webglDevice = WebGLDevice.attach(device);\n const gl = webglDevice.gl;\n\n if (isObjectEmpty(parameters)) {\n return;\n }\n\n const compositeSetters = {};\n\n // HANDLE PRIMITIVE SETTERS (and make note of any composite setters)\n\n for (const key in parameters) {\n const glConstant = Number(key);\n const setter = GL_PARAMETER_SETTERS[key];\n if (setter) {\n // Composite setters should only be called once, so save them\n if (typeof setter === 'string') {\n compositeSetters[setter] = true;\n } else {\n // if (gl[glConstant] !== undefined) {\n // TODO - added above check since this is being called on WebGL2 parameters in WebGL1...\n // TODO - deep equal on values? only call setter if value has changed?\n // NOTE - the setter will automatically update this.state\n setter(gl, parameters[key], glConstant);\n }\n }\n }\n\n // HANDLE COMPOSITE SETTERS\n\n // NOTE: any non-provided values needed by composite setters are filled in from state cache\n // The cache parameter is automatically retrieved from the context\n // This depends on `trackContextState`, which is technically a \"circular\" dependency.\n // But it is too inconvenient to always require a cache parameter here.\n // This is the ONLY external dependency in this module/\n // @ts-expect-error\n const cache = gl.state && gl.state.cache;\n if (cache) {\n for (const key in compositeSetters) {\n // TODO - avoid calling composite setters if values have not changed.\n const compositeSetter = GL_COMPOSITE_PARAMETER_SETTERS[key];\n // Note - if `trackContextState` has been called,\n // the setter will automatically update this.state.cache\n compositeSetter(gl, parameters, cache);\n }\n }\n\n // Add a log for the else case?\n}\n\n/**\n * Reads the entire WebGL state from a context\n\n // default to querying all parameters\n\n * @returns - a newly created map, with values keyed by GL parameters\n *\n * @note Copies the state from a context (gl.getParameter should not be overriden)\n * Reads the entire WebGL state from a context\n *\n * @note This can generates a huge amount of synchronous driver roundtrips and should be\n * considered a very slow operation, to be used only if/when a context already manipulated\n * by external code needs to be synchronized for the first time\n */\nexport function getParameters(\n device: Device | WebGLRenderingContext,\n parameters: keyof GLParameters | (keyof GLParameters)[] | GLParameters = GL_PARAMETER_DEFAULTS\n): GLParameters {\n const webglDevice = WebGLDevice.attach(device);\n const gl = webglDevice.gl;\n\n // support both arrays of parameters and objects (keys represent parameters)\n\n if (typeof parameters === 'number') {\n // single GL enum\n const key = parameters;\n const getter = GL_PARAMETER_GETTERS[key];\n return getter ? getter(gl, key) : gl.getParameter(key);\n }\n\n const parameterKeys = Array.isArray(parameters) ? parameters : Object.keys(parameters);\n\n const state = {};\n for (const key of parameterKeys) {\n const getter = GL_PARAMETER_GETTERS[key];\n state[key] = getter ? getter(gl, Number(key)) : gl.getParameter(Number(key));\n }\n return state;\n}\n\n/**\n * Reset all parameters to a (almost) pure context state\n * @note viewport and scissor will be set to the values in GL_PARAMETER_DEFAULTS,\n * NOT the canvas size dimensions, so they will have to be properly set after\n * calling this function.\n */\nexport function resetParameters(device: Device | WebGLRenderingContext): void {\n setParameters(device, GL_PARAMETER_DEFAULTS);\n}\n\n// Helpers\n\n// Returns true if given object is empty, false otherwise.\nfunction isObjectEmpty(object) {\n for (const key in object) {\n return false;\n }\n return true;\n}\n"],"file":"unified-parameter-api.js"}
|