@luma.gl/webgl 9.0.17 → 9.1.0-alpha.10
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/adapter/converters/device-parameters.d.ts.map +1 -1
- package/dist/adapter/converters/device-parameters.js +30 -12
- package/dist/adapter/converters/texture-formats.d.ts +22 -16
- package/dist/adapter/converters/texture-formats.d.ts.map +1 -1
- package/dist/adapter/converters/texture-formats.js +39 -47
- package/dist/adapter/device-helpers/webgl-device-features.d.ts.map +1 -1
- package/dist/adapter/device-helpers/webgl-device-features.js +1 -2
- package/dist/adapter/device-helpers/webgl-device-limits.js +1 -1
- package/dist/adapter/helpers/webgl-texture-utils.d.ts +300 -0
- package/dist/adapter/helpers/webgl-texture-utils.d.ts.map +1 -0
- package/dist/adapter/helpers/webgl-texture-utils.js +370 -0
- package/dist/adapter/helpers/webgl-topology-utils.d.ts.map +1 -1
- package/dist/adapter/helpers/webgl-topology-utils.js +0 -4
- package/dist/adapter/resources/webgl-buffer.d.ts.map +1 -1
- package/dist/adapter/resources/webgl-buffer.js +2 -2
- package/dist/adapter/resources/webgl-command-buffer.d.ts.map +1 -1
- package/dist/adapter/resources/webgl-command-buffer.js +6 -9
- package/dist/adapter/resources/webgl-framebuffer.d.ts +32 -5
- package/dist/adapter/resources/webgl-framebuffer.d.ts.map +1 -1
- package/dist/adapter/resources/webgl-framebuffer.js +42 -60
- package/dist/adapter/resources/webgl-render-pass.d.ts +3 -2
- package/dist/adapter/resources/webgl-render-pass.d.ts.map +1 -1
- package/dist/adapter/resources/webgl-render-pass.js +18 -7
- package/dist/adapter/resources/webgl-render-pipeline.d.ts.map +1 -1
- package/dist/adapter/resources/webgl-render-pipeline.js +46 -21
- package/dist/adapter/resources/webgl-shader.d.ts.map +1 -1
- package/dist/adapter/resources/webgl-shader.js +3 -3
- package/dist/adapter/resources/webgl-texture-view.d.ts +1 -1
- package/dist/adapter/resources/webgl-texture-view.d.ts.map +1 -1
- package/dist/adapter/resources/webgl-texture-view.js +1 -1
- package/dist/adapter/resources/webgl-texture.d.ts +76 -172
- package/dist/adapter/resources/webgl-texture.d.ts.map +1 -1
- package/dist/adapter/resources/webgl-texture.js +397 -511
- package/dist/adapter/resources/webgl-vertex-array.d.ts +3 -2
- package/dist/adapter/resources/webgl-vertex-array.d.ts.map +1 -1
- package/dist/adapter/resources/webgl-vertex-array.js +2 -2
- package/dist/adapter/webgl-adapter.d.ts +21 -0
- package/dist/adapter/webgl-adapter.d.ts.map +1 -0
- package/dist/adapter/webgl-adapter.js +91 -0
- package/dist/adapter/webgl-canvas-context.d.ts +3 -1
- package/dist/adapter/webgl-canvas-context.d.ts.map +1 -1
- package/dist/adapter/webgl-canvas-context.js +2 -0
- package/dist/adapter/webgl-device.d.ts +19 -30
- package/dist/adapter/webgl-device.d.ts.map +1 -1
- package/dist/adapter/webgl-device.js +35 -114
- package/dist/classic/accessor.d.ts +22 -1
- package/dist/classic/accessor.d.ts.map +1 -1
- package/dist/classic/accessor.js +1 -9
- package/dist/classic/clear.d.ts.map +1 -1
- package/dist/classic/clear.js +2 -5
- package/dist/classic/copy-and-blit.d.ts +3 -1
- package/dist/classic/copy-and-blit.d.ts.map +1 -1
- package/dist/classic/copy-and-blit.js +21 -18
- package/dist/classic/format-utils.d.ts.map +1 -1
- package/dist/classic/format-utils.js +0 -3
- package/dist/classic/typed-array-utils.d.ts +1 -1
- package/dist/classic/typed-array-utils.d.ts.map +1 -1
- package/dist/context/debug/spector-types.d.ts +1108 -0
- package/dist/context/debug/spector-types.d.ts.map +1 -0
- package/dist/context/debug/spector-types.js +697 -0
- package/dist/context/debug/spector.d.ts +12 -8
- package/dist/context/debug/spector.d.ts.map +1 -1
- package/dist/context/debug/spector.js +25 -18
- package/dist/context/debug/webgl-developer-tools.d.ts +1 -1
- package/dist/context/debug/webgl-developer-tools.d.ts.map +1 -1
- package/dist/context/debug/webgl-developer-tools.js +2 -5
- package/dist/context/parameters/webgl-parameter-tables.js +1 -1
- package/dist/context/polyfills/polyfill-webgl1-extensions.d.ts +9 -0
- package/dist/context/polyfills/polyfill-webgl1-extensions.d.ts.map +1 -0
- package/dist/context/polyfills/polyfill-webgl1-extensions.js +181 -0
- package/dist/context/state-tracker/webgl-state-tracker.d.ts +43 -0
- package/dist/context/state-tracker/webgl-state-tracker.d.ts.map +1 -0
- package/dist/context/state-tracker/{track-context-state.js → webgl-state-tracker.js} +46 -77
- package/dist/context/state-tracker/with-parameters.d.ts.map +1 -1
- package/dist/context/state-tracker/with-parameters.js +5 -4
- package/dist/dist.dev.js +1112 -1380
- package/dist/dist.min.js +2 -2
- package/dist/index.cjs +1122 -1284
- package/dist/index.cjs.map +4 -4
- package/dist/index.d.ts +3 -5
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +3 -5
- package/dist/utils/fill-array.d.ts +8 -0
- package/dist/utils/fill-array.d.ts.map +1 -0
- package/dist/utils/fill-array.js +26 -0
- package/dist/utils/load-script.d.ts +8 -0
- package/dist/utils/load-script.d.ts.map +1 -0
- package/dist/utils/load-script.js +26 -0
- package/dist/utils/split-uniforms-and-bindings.d.ts +9 -0
- package/dist/utils/split-uniforms-and-bindings.d.ts.map +1 -0
- package/dist/utils/split-uniforms-and-bindings.js +20 -0
- package/dist/utils/uid.d.ts +7 -0
- package/dist/utils/uid.d.ts.map +1 -0
- package/dist/utils/uid.js +14 -0
- package/package.json +6 -5
- package/src/adapter/converters/device-parameters.ts +31 -13
- package/src/adapter/converters/texture-formats.ts +51 -56
- package/src/adapter/device-helpers/webgl-device-features.ts +1 -2
- package/src/adapter/device-helpers/webgl-device-limits.ts +1 -1
- package/src/adapter/helpers/webgl-texture-utils.ts +484 -0
- package/src/adapter/helpers/webgl-topology-utils.ts +0 -4
- package/src/adapter/resources/webgl-buffer.ts +2 -2
- package/src/adapter/resources/webgl-command-buffer.ts +8 -10
- package/src/adapter/resources/webgl-framebuffer.ts +22 -56
- package/src/adapter/resources/webgl-render-pass.ts +21 -9
- package/src/adapter/resources/webgl-render-pipeline.ts +50 -24
- package/src/adapter/resources/webgl-shader.ts +4 -4
- package/src/adapter/resources/webgl-texture-view.ts +1 -3
- package/src/adapter/resources/webgl-texture.ts +445 -784
- package/src/adapter/resources/webgl-vertex-array.ts +8 -7
- package/src/adapter/webgl-adapter.ts +113 -0
- package/src/adapter/webgl-canvas-context.ts +4 -1
- package/src/adapter/webgl-device.ts +40 -151
- package/src/classic/accessor.ts +31 -11
- package/src/classic/clear.ts +3 -6
- package/src/classic/copy-and-blit.ts +32 -27
- package/src/classic/format-utils.ts +0 -3
- package/src/classic/typed-array-utils.ts +1 -1
- package/src/context/debug/spector-types.ts +1154 -0
- package/src/context/debug/spector.ts +40 -30
- package/src/context/debug/webgl-developer-tools.ts +3 -7
- package/src/context/parameters/webgl-parameter-tables.ts +3 -3
- package/src/context/polyfills/polyfill-webgl1-extensions.ts +202 -0
- package/src/context/state-tracker/{track-context-state.ts → webgl-state-tracker.ts} +57 -97
- package/src/context/state-tracker/with-parameters.ts +5 -4
- package/src/index.ts +5 -13
- package/src/utils/fill-array.ts +35 -0
- package/src/utils/load-script.ts +30 -0
- package/src/utils/split-uniforms-and-bindings.ts +31 -0
- package/src/utils/uid.ts +16 -0
- package/dist/adapter/objects/constants-to-keys.d.ts +0 -3
- package/dist/adapter/objects/constants-to-keys.d.ts.map +0 -1
- package/dist/adapter/objects/constants-to-keys.js +0 -22
- package/dist/adapter/objects/webgl-renderbuffer.d.ts +0 -43
- package/dist/adapter/objects/webgl-renderbuffer.d.ts.map +0 -1
- package/dist/adapter/objects/webgl-renderbuffer.js +0 -95
- package/dist/adapter/objects/webgl-resource.d.ts +0 -32
- package/dist/adapter/objects/webgl-resource.d.ts.map +0 -1
- package/dist/adapter/objects/webgl-resource.js +0 -114
- package/dist/context/state-tracker/track-context-state.d.ts +0 -22
- package/dist/context/state-tracker/track-context-state.d.ts.map +0 -1
- package/src/adapter/objects/constants-to-keys.ts +0 -27
- package/src/adapter/objects/webgl-renderbuffer.ts +0 -132
- package/src/adapter/objects/webgl-resource.ts +0 -183
package/dist/index.d.ts
CHANGED
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
export type { WebGLDeviceLimits } from "./adapter/device-helpers/webgl-device-limits.js";
|
|
2
|
+
export { webgl2Adapter } from "./adapter/webgl-adapter.js";
|
|
3
|
+
export type { WebGLAdapter } from "./adapter/webgl-adapter.js";
|
|
2
4
|
export { WebGLDevice } from "./adapter/webgl-device.js";
|
|
3
5
|
export { WebGLCanvasContext } from "./adapter/webgl-canvas-context.js";
|
|
4
|
-
export { WebGLResource, WebGLResource as WEBGLResource } from "./adapter/objects/webgl-resource.js";
|
|
5
6
|
export { WEBGLBuffer } from "./adapter/resources/webgl-buffer.js";
|
|
6
7
|
export { WEBGLTexture } from "./adapter/resources/webgl-texture.js";
|
|
7
8
|
export { WEBGLShader } from "./adapter/resources/webgl-shader.js";
|
|
@@ -16,11 +17,8 @@ export { Accessor } from "./classic/accessor.js";
|
|
|
16
17
|
export type { AccessorObject } from "./types.js";
|
|
17
18
|
export { setDeviceParameters, withDeviceParameters } from "./adapter/converters/device-parameters.js";
|
|
18
19
|
export { getShaderLayout } from "./adapter/helpers/get-shader-layout.js";
|
|
19
|
-
export {
|
|
20
|
-
export type { RenderbufferProps as _RenderbufferProps } from "./adapter/objects/webgl-renderbuffer.js";
|
|
21
|
-
export { WEBGLRenderbuffer as _WEBGLRenderbuffer } from "./adapter/objects/webgl-renderbuffer.js";
|
|
20
|
+
export { WebGLStateTracker } from "./context/state-tracker/webgl-state-tracker.js";
|
|
22
21
|
export { TEXTURE_FORMATS as _TEXTURE_FORMATS } from "./adapter/converters/texture-formats.js";
|
|
23
|
-
export { trackContextState, pushContextState, popContextState } from "./context/state-tracker/track-context-state.js";
|
|
24
22
|
export { resetGLParameters, setGLParameters, getGLParameters } from "./context/parameters/unified-parameter-api.js";
|
|
25
23
|
export { withGLParameters } from "./context/state-tracker/with-parameters.js";
|
|
26
24
|
//# sourceMappingURL=index.d.ts.map
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAWA,YAAY,EAAC,iBAAiB,EAAC,wDAAqD;AAGpF,OAAO,EAAC,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAWA,YAAY,EAAC,iBAAiB,EAAC,wDAAqD;AAGpF,OAAO,EAAC,aAAa,EAAC,mCAAgC;AACtD,YAAY,EAAC,YAAY,EAAC,mCAAgC;AAG1D,OAAO,EAAC,WAAW,EAAC,kCAA+B;AACnD,OAAO,EAAC,kBAAkB,EAAC,0CAAuC;AAGlE,OAAO,EAAC,WAAW,EAAC,4CAAyC;AAC7D,OAAO,EAAC,YAAY,EAAC,6CAA0C;AAE/D,OAAO,EAAC,WAAW,EAAC,4CAAyC;AAC7D,OAAO,EAAC,YAAY,EAAC,6CAA0C;AAC/D,OAAO,EAAC,gBAAgB,EAAC,iDAA8C;AAEvE,OAAO,EAAC,mBAAmB,EAAC,qDAAkD;AAE9E,OAAO,EAAC,mBAAmB,EAAC,qDAAkD;AAC9E,OAAO,EAAC,eAAe,EAAC,iDAA8C;AAEtE,OAAO,EAAC,gBAAgB,EAAC,kDAA+C;AAGxE,OAAO,EAAC,sBAAsB,EAAC,wDAAqD;AAGpF,OAAO,EAAC,QAAQ,EAAC,8BAA2B;AAC5C,YAAY,EAAC,cAAc,EAAC,mBAAgB;AAI5C,OAAO,EAAC,mBAAmB,EAAE,oBAAoB,EAAC,kDAA+C;AAGjG,OAAO,EAAC,eAAe,EAAC,+CAA4C;AACpE,OAAO,EAAC,iBAAiB,EAAC,uDAAoD;AAG9E,OAAO,EAAC,eAAe,IAAI,gBAAgB,EAAC,gDAA6C;AAGzF,OAAO,EACL,iBAAiB,EACjB,eAAe,EACf,eAAe,EAChB,sDAAmD;AAEpD,OAAO,EAAC,gBAAgB,EAAC,mDAAgD"}
|
package/dist/index.js
CHANGED
|
@@ -2,10 +2,11 @@
|
|
|
2
2
|
// SPDX-License-Identifier: MIT
|
|
3
3
|
// Copyright (c) vis.gl contributors
|
|
4
4
|
// WebGL adapter classes
|
|
5
|
+
export { webgl2Adapter } from "./adapter/webgl-adapter.js";
|
|
6
|
+
// WebGL Device classes
|
|
5
7
|
export { WebGLDevice } from "./adapter/webgl-device.js";
|
|
6
8
|
export { WebGLCanvasContext } from "./adapter/webgl-canvas-context.js";
|
|
7
9
|
// WebGL Resource classes
|
|
8
|
-
export { WebGLResource, WebGLResource as WEBGLResource } from "./adapter/objects/webgl-resource.js";
|
|
9
10
|
export { WEBGLBuffer } from "./adapter/resources/webgl-buffer.js";
|
|
10
11
|
export { WEBGLTexture } from "./adapter/resources/webgl-texture.js";
|
|
11
12
|
// export {WEBGLExternalTexture} from './adapter/resources/webgl-external-texture';
|
|
@@ -26,12 +27,9 @@ export { Accessor } from "./classic/accessor.js";
|
|
|
26
27
|
export { setDeviceParameters, withDeviceParameters } from "./adapter/converters/device-parameters.js";
|
|
27
28
|
// HELPERS - EXPERIMENTAL
|
|
28
29
|
export { getShaderLayout } from "./adapter/helpers/get-shader-layout.js";
|
|
29
|
-
export {
|
|
30
|
-
export { WEBGLRenderbuffer as _WEBGLRenderbuffer } from "./adapter/objects/webgl-renderbuffer.js";
|
|
30
|
+
export { WebGLStateTracker } from "./context/state-tracker/webgl-state-tracker.js";
|
|
31
31
|
// TEST EXPORTS
|
|
32
32
|
export { TEXTURE_FORMATS as _TEXTURE_FORMATS } from "./adapter/converters/texture-formats.js";
|
|
33
33
|
// DEPRECATED TEST EXPORTS
|
|
34
|
-
// State tracking
|
|
35
|
-
export { trackContextState, pushContextState, popContextState } from "./context/state-tracker/track-context-state.js";
|
|
36
34
|
export { resetGLParameters, setGLParameters, getGLParameters } from "./context/parameters/unified-parameter-api.js";
|
|
37
35
|
export { withGLParameters } from "./context/state-tracker/with-parameters.js";
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"fill-array.d.ts","sourceRoot":"","sources":["../../src/utils/fill-array.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAC,WAAW,EAAC,MAAM,gBAAgB,CAAC;AAGhD,wBAAgB,SAAS,CAAC,OAAO,EAAE;IACjC,MAAM,EAAE,WAAW,CAAC;IACpB,MAAM,EAAE,WAAW,CAAC;IACpB,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,KAAK,CAAC,EAAE,MAAM,CAAC;CAChB,GAAG,WAAW,CAsBd"}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
// luma.gl
|
|
2
|
+
// SPDX-License-Identifier: MIT
|
|
3
|
+
// Copyright (c) vis.gl contributors
|
|
4
|
+
// Uses copyWithin to significantly speed up typed array value filling
|
|
5
|
+
export function fillArray(options) {
|
|
6
|
+
const { target, source, start = 0, count = 1 } = options;
|
|
7
|
+
const length = source.length;
|
|
8
|
+
const total = count * length;
|
|
9
|
+
let copied = 0;
|
|
10
|
+
for (let i = start; copied < length; copied++) {
|
|
11
|
+
target[i++] = source[copied];
|
|
12
|
+
}
|
|
13
|
+
while (copied < total) {
|
|
14
|
+
// If we have copied less than half, copy everything we got
|
|
15
|
+
// else copy remaining in one operation
|
|
16
|
+
if (copied < total - copied) {
|
|
17
|
+
target.copyWithin(start + copied, start, start + copied);
|
|
18
|
+
copied *= 2;
|
|
19
|
+
}
|
|
20
|
+
else {
|
|
21
|
+
target.copyWithin(start + copied, start, start + total - copied);
|
|
22
|
+
copied = total;
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
return options.target;
|
|
26
|
+
}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Load a script (identified by an url). When the url returns, the
|
|
3
|
+
* content of this file is added into a new script element, attached to the DOM (body element)
|
|
4
|
+
* @param scriptUrl defines the url of the script to laod
|
|
5
|
+
* @param scriptId defines the id of the script element
|
|
6
|
+
*/
|
|
7
|
+
export declare function loadScript(scriptUrl: string, scriptId?: string): Promise<Event>;
|
|
8
|
+
//# sourceMappingURL=load-script.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"load-script.d.ts","sourceRoot":"","sources":["../../src/utils/load-script.ts"],"names":[],"mappings":"AAIA;;;;;GAKG;AACH,wBAAsB,UAAU,CAAC,SAAS,EAAE,MAAM,EAAE,QAAQ,CAAC,EAAE,MAAM,GAAG,OAAO,CAAC,KAAK,CAAC,CAmBrF"}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
// luma.gl
|
|
2
|
+
// SPDX-License-Identifier: MIT
|
|
3
|
+
// Copyright (c) vis.gl contributors
|
|
4
|
+
/**
|
|
5
|
+
* Load a script (identified by an url). When the url returns, the
|
|
6
|
+
* content of this file is added into a new script element, attached to the DOM (body element)
|
|
7
|
+
* @param scriptUrl defines the url of the script to laod
|
|
8
|
+
* @param scriptId defines the id of the script element
|
|
9
|
+
*/
|
|
10
|
+
export async function loadScript(scriptUrl, scriptId) {
|
|
11
|
+
const head = document.getElementsByTagName('head')[0];
|
|
12
|
+
if (!head) {
|
|
13
|
+
throw new Error('loadScript');
|
|
14
|
+
}
|
|
15
|
+
const script = document.createElement('script');
|
|
16
|
+
script.setAttribute('type', 'text/javascript');
|
|
17
|
+
script.setAttribute('src', scriptUrl);
|
|
18
|
+
if (scriptId) {
|
|
19
|
+
script.id = scriptId;
|
|
20
|
+
}
|
|
21
|
+
return new Promise((resolve, reject) => {
|
|
22
|
+
script.onload = resolve;
|
|
23
|
+
script.onerror = error => reject(new Error(`Unable to load script '${scriptUrl}': ${error}`));
|
|
24
|
+
head.appendChild(script);
|
|
25
|
+
});
|
|
26
|
+
}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import type { UniformValue, Binding } from '@luma.gl/core';
|
|
2
|
+
export declare function isUniformValue(value: unknown): value is UniformValue;
|
|
3
|
+
type UniformsAndBindings = {
|
|
4
|
+
bindings: Record<string, Binding>;
|
|
5
|
+
uniforms: Record<string, UniformValue>;
|
|
6
|
+
};
|
|
7
|
+
export declare function splitUniformsAndBindings(uniforms: Record<string, Binding | UniformValue>): UniformsAndBindings;
|
|
8
|
+
export {};
|
|
9
|
+
//# sourceMappingURL=split-uniforms-and-bindings.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"split-uniforms-and-bindings.d.ts","sourceRoot":"","sources":["../../src/utils/split-uniforms-and-bindings.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAC,YAAY,EAAE,OAAO,EAAC,MAAM,eAAe,CAAC;AAGzD,wBAAgB,cAAc,CAAC,KAAK,EAAE,OAAO,GAAG,KAAK,IAAI,YAAY,CAEpE;AAED,KAAK,mBAAmB,GAAG;IACzB,QAAQ,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;IAClC,QAAQ,EAAE,MAAM,CAAC,MAAM,EAAE,YAAY,CAAC,CAAC;CACxC,CAAC;AAEF,wBAAgB,wBAAwB,CACtC,QAAQ,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,GAAG,YAAY,CAAC,GAC/C,mBAAmB,CAYrB"}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
// luma.gl
|
|
2
|
+
// SPDX-License-Identifier: MIT
|
|
3
|
+
// Copyright (c) vis.gl contributors
|
|
4
|
+
import { isNumericArray } from '@math.gl/types';
|
|
5
|
+
export function isUniformValue(value) {
|
|
6
|
+
return isNumericArray(value) !== null || typeof value === 'number' || typeof value === 'boolean';
|
|
7
|
+
}
|
|
8
|
+
export function splitUniformsAndBindings(uniforms) {
|
|
9
|
+
const result = { bindings: {}, uniforms: {} };
|
|
10
|
+
Object.keys(uniforms).forEach(name => {
|
|
11
|
+
const uniform = uniforms[name];
|
|
12
|
+
if (isUniformValue(uniform)) {
|
|
13
|
+
result.uniforms[name] = uniform;
|
|
14
|
+
}
|
|
15
|
+
else {
|
|
16
|
+
result.bindings[name] = uniform;
|
|
17
|
+
}
|
|
18
|
+
});
|
|
19
|
+
return result;
|
|
20
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"uid.d.ts","sourceRoot":"","sources":["../../src/utils/uid.ts"],"names":[],"mappings":"AAMA;;;;IAII;AACJ,wBAAgB,GAAG,CAAC,EAAE,GAAE,MAAa,GAAG,MAAM,CAI7C"}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
// luma.gl
|
|
2
|
+
// SPDX-License-Identifier: MIT
|
|
3
|
+
// Copyright (c) vis.gl contributors
|
|
4
|
+
const uidCounters = {};
|
|
5
|
+
/**
|
|
6
|
+
* Returns a UID.
|
|
7
|
+
* @param id= - Identifier base name
|
|
8
|
+
* @return uid
|
|
9
|
+
**/
|
|
10
|
+
export function uid(id = 'id') {
|
|
11
|
+
uidCounters[id] = uidCounters[id] || 1;
|
|
12
|
+
const count = uidCounters[id]++;
|
|
13
|
+
return `${id}-${count}`;
|
|
14
|
+
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@luma.gl/webgl",
|
|
3
|
-
"version": "9.0.
|
|
3
|
+
"version": "9.1.0-alpha.10",
|
|
4
4
|
"description": "WebGL2 adapter for the luma.gl core API",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"license": "MIT",
|
|
@@ -40,11 +40,12 @@
|
|
|
40
40
|
"prepublishOnly": "npm run build-minified-bundle && npm run build-dev-bundle"
|
|
41
41
|
},
|
|
42
42
|
"peerDependencies": {
|
|
43
|
-
"@luma.gl/core": "^9.0.0"
|
|
43
|
+
"@luma.gl/core": "^9.0.0-beta"
|
|
44
44
|
},
|
|
45
45
|
"dependencies": {
|
|
46
|
-
"@luma.gl/constants": "9.0.
|
|
47
|
-
"@
|
|
46
|
+
"@luma.gl/constants": "9.1.0-alpha.10",
|
|
47
|
+
"@math.gl/types": "^4.0.0",
|
|
48
|
+
"@probe.gl/env": "^4.0.8"
|
|
48
49
|
},
|
|
49
|
-
"gitHead": "
|
|
50
|
+
"gitHead": "f419cdc284e87b553df60af49d2888ac7dbbf288"
|
|
50
51
|
}
|
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
// Copyright (c) vis.gl contributors
|
|
4
4
|
|
|
5
5
|
import type {CompareFunction, StencilOperation, BlendOperation, BlendFactor} from '@luma.gl/core';
|
|
6
|
-
import {Device, log,
|
|
6
|
+
import {Device, log, Parameters, PolygonMode, ProvokingVertex} from '@luma.gl/core';
|
|
7
7
|
import {GL} from '@luma.gl/constants';
|
|
8
8
|
import type {
|
|
9
9
|
GLBlendEquation,
|
|
@@ -14,7 +14,6 @@ import type {
|
|
|
14
14
|
GLProvokingVertex,
|
|
15
15
|
GLStencilOp
|
|
16
16
|
} from '@luma.gl/constants';
|
|
17
|
-
import {pushContextState, popContextState} from '../../context/state-tracker/track-context-state';
|
|
18
17
|
import {setGLParameters} from '../../context/parameters/unified-parameter-api';
|
|
19
18
|
import {WebGLDevice} from '../webgl-device';
|
|
20
19
|
|
|
@@ -41,13 +40,13 @@ export function withDeviceAndGLParameters<T = unknown>(
|
|
|
41
40
|
|
|
42
41
|
// Wrap in a try-catch to ensure that parameters are restored on exceptions
|
|
43
42
|
const webglDevice = device as WebGLDevice;
|
|
44
|
-
|
|
43
|
+
webglDevice.pushState();
|
|
45
44
|
try {
|
|
46
45
|
setDeviceParameters(device, parameters);
|
|
47
46
|
setGLParameters(webglDevice.gl, glParameters);
|
|
48
47
|
return func(device);
|
|
49
48
|
} finally {
|
|
50
|
-
|
|
49
|
+
webglDevice.popState();
|
|
51
50
|
}
|
|
52
51
|
}
|
|
53
52
|
|
|
@@ -72,12 +71,12 @@ export function withGLParameters<T = unknown>(
|
|
|
72
71
|
|
|
73
72
|
// Wrap in a try-catch to ensure that parameters are restored on exceptions
|
|
74
73
|
const webglDevice = device as WebGLDevice;
|
|
75
|
-
|
|
74
|
+
webglDevice.pushState();
|
|
76
75
|
try {
|
|
77
76
|
setGLParameters(webglDevice.gl, parameters);
|
|
78
77
|
return func(device);
|
|
79
78
|
} finally {
|
|
80
|
-
|
|
79
|
+
webglDevice.popState();
|
|
81
80
|
}
|
|
82
81
|
}
|
|
83
82
|
|
|
@@ -99,15 +98,14 @@ export function withDeviceParameters<T = unknown>(
|
|
|
99
98
|
return func(device);
|
|
100
99
|
}
|
|
101
100
|
|
|
102
|
-
// Wrap in a try-catch to ensure that parameters are restored on exceptions
|
|
103
|
-
|
|
104
|
-
|
|
101
|
+
// Wrap in a try-catch to ensure that parameters are restored on exceptions'
|
|
102
|
+
const webglDevice = device as WebGLDevice;
|
|
103
|
+
webglDevice.pushState();
|
|
105
104
|
try {
|
|
106
105
|
setDeviceParameters(device, parameters);
|
|
107
106
|
return func(device);
|
|
108
107
|
} finally {
|
|
109
|
-
|
|
110
|
-
popContextState(device.gl);
|
|
108
|
+
webglDevice.popState();
|
|
111
109
|
}
|
|
112
110
|
}
|
|
113
111
|
|
|
@@ -280,10 +278,18 @@ export function setDeviceParameters(device: Device, parameters: Parameters) {
|
|
|
280
278
|
// },
|
|
281
279
|
|
|
282
280
|
// COLOR STATE
|
|
281
|
+
switch (parameters.blend) {
|
|
282
|
+
case true:
|
|
283
|
+
gl.enable(GL.BLEND);
|
|
284
|
+
break;
|
|
285
|
+
case false:
|
|
286
|
+
gl.disable(GL.BLEND);
|
|
287
|
+
break;
|
|
288
|
+
default:
|
|
289
|
+
// leave WebGL blend state unchanged if `parameters.blend` is not set
|
|
290
|
+
}
|
|
283
291
|
|
|
284
292
|
if (parameters.blendColorOperation || parameters.blendAlphaOperation) {
|
|
285
|
-
gl.enable(GL.BLEND);
|
|
286
|
-
|
|
287
293
|
const colorEquation = convertBlendOperationToEquation(
|
|
288
294
|
'blendColorOperation',
|
|
289
295
|
parameters.blendColorOperation || 'add'
|
|
@@ -423,3 +429,15 @@ function map<K extends string | number, V>(parameter: string, value: K, valueMap
|
|
|
423
429
|
function mapBoolean(parameter: string, value: boolean): boolean {
|
|
424
430
|
return value;
|
|
425
431
|
}
|
|
432
|
+
|
|
433
|
+
/** Returns true if given object is empty, false otherwise. */
|
|
434
|
+
function isObjectEmpty(obj: object): boolean {
|
|
435
|
+
let isEmpty = true;
|
|
436
|
+
// @ts-ignore key is unused
|
|
437
|
+
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
438
|
+
for (const key in obj) {
|
|
439
|
+
isEmpty = false;
|
|
440
|
+
break;
|
|
441
|
+
}
|
|
442
|
+
return isEmpty;
|
|
443
|
+
}
|
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
|
|
5
5
|
import type {TextureFormat, DeviceFeature} from '@luma.gl/core';
|
|
6
6
|
import {decodeTextureFormat} from '@luma.gl/core';
|
|
7
|
-
import {GL, GLExtensions} from '@luma.gl/constants';
|
|
7
|
+
import {GL, GLPixelType, GLExtensions, GLTexelDataFormat} from '@luma.gl/constants';
|
|
8
8
|
import {getWebGLExtension} from '../../context/helpers/webgl-extensions';
|
|
9
9
|
import {getGLFromVertexType} from './vertex-formats';
|
|
10
10
|
|
|
@@ -123,9 +123,8 @@ type Format = {
|
|
|
123
123
|
/** If not supported on WebGPU */
|
|
124
124
|
wgpu?: false;
|
|
125
125
|
|
|
126
|
-
types?:
|
|
127
|
-
|
|
128
|
-
dataFormat?: GL;
|
|
126
|
+
types?: GLPixelType[];
|
|
127
|
+
dataFormat?: GLTexelDataFormat;
|
|
129
128
|
/** Depth and stencil format attachment points. If set, needs to be a Renderbuffer unless depthTexture is set */
|
|
130
129
|
attachment?: GL.DEPTH_ATTACHMENT | GL.STENCIL_ATTACHMENT | GL.DEPTH_STENCIL_ATTACHMENT;
|
|
131
130
|
/** if depthTexture is set this is a depth/stencil format that can be set to a texture */
|
|
@@ -142,15 +141,6 @@ type Format = {
|
|
|
142
141
|
*/
|
|
143
142
|
// prettier-ignore
|
|
144
143
|
export const TEXTURE_FORMATS: Record<TextureFormat, Format> = {
|
|
145
|
-
// Unsized formats that leave the precision up to the driver. TODO - Fix bpp constants
|
|
146
|
-
'rgb8unorm-unsized': {gl: GL.RGB, b: 4, c: 2, bpp: 4,
|
|
147
|
-
dataFormat: GL.RGB, types: [GL.UNSIGNED_BYTE, GL.UNSIGNED_SHORT_5_6_5]},
|
|
148
|
-
'rgba8unorm-unsized': {gl: GL.RGBA, b: 4, c: 2, bpp: 4,
|
|
149
|
-
dataFormat: GL.RGBA, types: [GL.UNSIGNED_BYTE, GL.UNSIGNED_SHORT_4_4_4_4, GL.UNSIGNED_SHORT_5_5_5_1]},
|
|
150
|
-
// 'r8unorm-unsized': {gl: GL.LUMINANCE, b: 4, c: 2, bpp: 4},
|
|
151
|
-
// 'rgb8unorm-srgb-unsized': {gl: GL.SRGB_EXT, b: 4, c: 2, bpp: 4, gl1Ext: SRGB},
|
|
152
|
-
// 'rgba8unorm-srgb-unsized': {gl: GL.SRGB_ALPHA_EXT, b: 4, c: 2, bpp: 4, gl1Ext: SRGB},
|
|
153
|
-
|
|
154
144
|
// 8-bit formats
|
|
155
145
|
'r8unorm': {gl: GL.R8, b: 1, c: 1, rb: true},
|
|
156
146
|
'r8snorm': {gl: GL.R8_SNORM, b: 1, c: 1, render: snorm8_renderable},
|
|
@@ -190,7 +180,6 @@ export const TEXTURE_FORMATS: Record<TextureFormat, Format> = {
|
|
|
190
180
|
|
|
191
181
|
'rg16uint': {gl: GL.RG16UI, b: 4, c: 1, bpp: 4},
|
|
192
182
|
'rg16sint': {gl: GL.RG16I, b: 4, c: 2, bpp: 4},
|
|
193
|
-
// When using a WebGL 2 context and the EXT_color_buffer_float WebGL2 extension
|
|
194
183
|
'rg16float': {gl: GL.RG16F, bpp: 4, b: 4, c: 2, render: float16_renderable, filter: float16_filterable, rb: true},
|
|
195
184
|
'rg16unorm-webgl': {gl: GL.RG16_EXT, b:2, c:2, render: norm16_renderable},
|
|
196
185
|
'rg16snorm-webgl': {gl: GL.RG16_SNORM_EXT, b:2, c:2, render: snorm16_renderable},
|
|
@@ -241,9 +230,6 @@ export const TEXTURE_FORMATS: Record<TextureFormat, Format> = {
|
|
|
241
230
|
// The depth component of the "depth24plus" and "depth24plus-stencil8" formats may be implemented as either a 24-bit depth value or a "depth32float" value.
|
|
242
231
|
'depth24plus-stencil8': {gl: GL.DEPTH24_STENCIL8, b: 4, c: 2, p: 1, attachment: GL.DEPTH_STENCIL_ATTACHMENT, rb: true, depthTexture: true,
|
|
243
232
|
dataFormat: GL.DEPTH_STENCIL, types: [GL.UNSIGNED_INT_24_8]},
|
|
244
|
-
// "depth24unorm-stencil8" feature
|
|
245
|
-
'depth24unorm-stencil8': {gl: GL.DEPTH24_STENCIL8, b: 4, c: 2, p: 1, attachment: GL.DEPTH_STENCIL_ATTACHMENT,
|
|
246
|
-
dataFormat: GL.DEPTH_STENCIL, types: [GL.UNSIGNED_INT_24_8], rb: true},
|
|
247
233
|
// "depth32float-stencil8" feature - TODO below is render buffer only?
|
|
248
234
|
'depth32float-stencil8': {gl: GL.DEPTH32F_STENCIL8, b: 5, c: 2, p: 1, attachment: GL.DEPTH_STENCIL_ATTACHMENT,
|
|
249
235
|
dataFormat: GL.DEPTH_STENCIL, types: [GL.FLOAT_32_UNSIGNED_INT_24_8_REV], rb: true},
|
|
@@ -471,6 +457,10 @@ export function isTextureFormatSupported(
|
|
|
471
457
|
if (info.gl === undefined) {
|
|
472
458
|
return false;
|
|
473
459
|
}
|
|
460
|
+
const feature = info.f;
|
|
461
|
+
if (feature) {
|
|
462
|
+
return checkTextureFeature(gl, feature, extensions);
|
|
463
|
+
}
|
|
474
464
|
// Check extensions
|
|
475
465
|
const extension = info.x || info.gl2ext;
|
|
476
466
|
if (extension) {
|
|
@@ -485,33 +475,7 @@ export function isRenderbufferFormatSupported(
|
|
|
485
475
|
extensions: GLExtensions
|
|
486
476
|
): boolean {
|
|
487
477
|
// Note: Order is important since the function call initializes extensions.
|
|
488
|
-
return isTextureFormatSupported(gl, format, extensions) && TEXTURE_FORMATS[format]?.rb;
|
|
489
|
-
}
|
|
490
|
-
|
|
491
|
-
/**
|
|
492
|
-
* Map WebGL texture formats (GL constants) to WebGPU-style TextureFormat strings
|
|
493
|
-
*/
|
|
494
|
-
export function convertGLToTextureFormat(format: GL | TextureFormat): TextureFormat {
|
|
495
|
-
if (typeof format === 'string') {
|
|
496
|
-
return format;
|
|
497
|
-
}
|
|
498
|
-
const entry = Object.entries(TEXTURE_FORMATS).find(([, entry]) => entry.gl === format);
|
|
499
|
-
if (!entry) {
|
|
500
|
-
throw new Error(`Unknown texture format ${format}`);
|
|
501
|
-
}
|
|
502
|
-
return entry[0] as TextureFormat;
|
|
503
|
-
}
|
|
504
|
-
|
|
505
|
-
/**
|
|
506
|
-
* Map WebGPU style texture format strings to GL constants
|
|
507
|
-
*/
|
|
508
|
-
export function convertTextureFormatToGL(format: TextureFormat): GL | undefined {
|
|
509
|
-
const formatInfo = TEXTURE_FORMATS[format];
|
|
510
|
-
const webglFormat = formatInfo?.gl;
|
|
511
|
-
if (webglFormat === undefined) {
|
|
512
|
-
throw new Error(`Unsupported texture format ${format}`);
|
|
513
|
-
}
|
|
514
|
-
return webglFormat;
|
|
478
|
+
return isTextureFormatSupported(gl, format, extensions) && Boolean(TEXTURE_FORMATS[format]?.rb);
|
|
515
479
|
}
|
|
516
480
|
|
|
517
481
|
/** Checks if a texture format is supported */
|
|
@@ -601,21 +565,25 @@ export function isTextureFormatRenderable(
|
|
|
601
565
|
}
|
|
602
566
|
|
|
603
567
|
/** Get parameters necessary to work with format in WebGL: internalFormat, dataFormat, type, compressed, */
|
|
604
|
-
export function
|
|
568
|
+
export function getTextureFormatWebGL(format: TextureFormat): {
|
|
569
|
+
internalFormat: GL;
|
|
570
|
+
format: GLTexelDataFormat;
|
|
571
|
+
type: GLPixelType;
|
|
572
|
+
compressed: boolean;
|
|
573
|
+
} {
|
|
605
574
|
const formatData = TEXTURE_FORMATS[format];
|
|
606
575
|
const webglFormat = convertTextureFormatToGL(format);
|
|
607
576
|
const decoded = decodeTextureFormat(format);
|
|
608
577
|
return {
|
|
609
|
-
|
|
610
|
-
|
|
578
|
+
internalFormat: webglFormat,
|
|
579
|
+
format:
|
|
611
580
|
formatData?.dataFormat ||
|
|
612
|
-
getWebGLPixelDataFormat(decoded.
|
|
581
|
+
getWebGLPixelDataFormat(decoded.channels, decoded.integer, decoded.normalized, webglFormat),
|
|
613
582
|
// depth formats don't have a type
|
|
614
583
|
type: decoded.dataType
|
|
615
584
|
? getGLFromVertexType(decoded.dataType)
|
|
616
585
|
: formatData?.types?.[0] || GL.UNSIGNED_BYTE,
|
|
617
|
-
|
|
618
|
-
compressed: decoded.compressed
|
|
586
|
+
compressed: decoded.compressed || false
|
|
619
587
|
};
|
|
620
588
|
}
|
|
621
589
|
|
|
@@ -632,31 +600,58 @@ export function getDepthStencilAttachmentWebGL(
|
|
|
632
600
|
/** TODO - VERY roundabout legacy way of calculating bytes per pixel */
|
|
633
601
|
export function getTextureFormatBytesPerPixel(format: TextureFormat): number {
|
|
634
602
|
// TODO remove webgl1 support
|
|
635
|
-
const params =
|
|
603
|
+
const params = getTextureFormatWebGL(format);
|
|
636
604
|
// NOTE(Tarek): Default to RGBA bytes
|
|
637
|
-
const channels = DATA_FORMAT_CHANNELS[params.
|
|
605
|
+
const channels = DATA_FORMAT_CHANNELS[params.format] || 4;
|
|
638
606
|
const channelSize = TYPE_SIZES[params.type] || 1;
|
|
639
607
|
return channels * channelSize;
|
|
640
608
|
}
|
|
641
609
|
|
|
642
610
|
// DATA TYPE HELPERS
|
|
643
611
|
|
|
644
|
-
function getWebGLPixelDataFormat(
|
|
645
|
-
|
|
612
|
+
export function getWebGLPixelDataFormat(
|
|
613
|
+
channels: 'r' | 'rg' | 'rgb' | 'rgba' | 'bgra',
|
|
646
614
|
integer: boolean,
|
|
647
615
|
normalized: boolean,
|
|
648
616
|
format: GL
|
|
649
|
-
):
|
|
617
|
+
): GLTexelDataFormat {
|
|
650
618
|
// WebGL1 formats use same internalFormat
|
|
651
619
|
if (format === GL.RGBA || format === GL.RGB) {
|
|
652
620
|
return format;
|
|
653
621
|
}
|
|
654
622
|
// prettier-ignore
|
|
655
|
-
switch (
|
|
623
|
+
switch (channels) {
|
|
656
624
|
case 'r': return integer && !normalized ? GL.RED_INTEGER : GL.RED;
|
|
657
625
|
case 'rg': return integer && !normalized ? GL.RG_INTEGER : GL.RG;
|
|
658
626
|
case 'rgb': return integer && !normalized ? GL.RGB_INTEGER : GL.RGB;
|
|
659
627
|
case 'rgba': return integer && !normalized ? GL.RGBA_INTEGER : GL.RGBA;
|
|
628
|
+
case 'bgra': throw new Error('bgra pixels not supported by WebGL');
|
|
660
629
|
default: return GL.RGBA;
|
|
661
630
|
}
|
|
662
631
|
}
|
|
632
|
+
|
|
633
|
+
/**
|
|
634
|
+
* Map WebGPU style texture format strings to GL constants
|
|
635
|
+
*/
|
|
636
|
+
function convertTextureFormatToGL(format: TextureFormat): GL | undefined {
|
|
637
|
+
const formatInfo = TEXTURE_FORMATS[format];
|
|
638
|
+
const webglFormat = formatInfo?.gl;
|
|
639
|
+
if (webglFormat === undefined) {
|
|
640
|
+
throw new Error(`Unsupported texture format ${format}`);
|
|
641
|
+
}
|
|
642
|
+
return webglFormat;
|
|
643
|
+
}
|
|
644
|
+
|
|
645
|
+
/**
|
|
646
|
+
* Map WebGL texture formats (GL constants) to WebGPU-style TextureFormat strings
|
|
647
|
+
export function convertGLToTextureFormat(format: GL | TextureFormat): TextureFormat {
|
|
648
|
+
if (typeof format === 'string') {
|
|
649
|
+
return format;
|
|
650
|
+
}
|
|
651
|
+
const entry = Object.entries(TEXTURE_FORMATS).find(([, entry]) => entry.gl === format);
|
|
652
|
+
if (!entry) {
|
|
653
|
+
throw new Error(`Unknown texture format ${format}`);
|
|
654
|
+
}
|
|
655
|
+
return entry[0] as TextureFormat;
|
|
656
|
+
}
|
|
657
|
+
*/
|
|
@@ -21,7 +21,6 @@ const WEBGL_FEATURES: Partial<Record<DeviceFeature, boolean | string>> = {
|
|
|
21
21
|
// 'timestamp-query' // GPUQueryType "timestamp-query"
|
|
22
22
|
// "indirect-first-instance"
|
|
23
23
|
// Textures are handled by getTextureFeatures()
|
|
24
|
-
// 'depth24unorm-stencil8' // GPUTextureFormat 'depth24unorm-stencil8'
|
|
25
24
|
// 'depth32float-stencil8' // GPUTextureFormat 'depth32float-stencil8'
|
|
26
25
|
|
|
27
26
|
// optional WebGL features
|
|
@@ -71,7 +70,7 @@ export class WebGLDeviceFeatures extends DeviceFeatures {
|
|
|
71
70
|
}
|
|
72
71
|
|
|
73
72
|
override has(feature: DeviceFeature): boolean {
|
|
74
|
-
if (this.disabledFeatures[feature]) {
|
|
73
|
+
if (this.disabledFeatures?.[feature]) {
|
|
75
74
|
return false;
|
|
76
75
|
}
|
|
77
76
|
|