@luma.gl/webgl 9.1.0-alpha.10 → 9.1.0-alpha.12
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/device-helpers/webgl-device-features.d.ts.map +1 -1
- package/dist/adapter/device-helpers/webgl-device-features.js +1 -2
- package/dist/adapter/helpers/format-utils.d.ts.map +1 -0
- package/dist/adapter/helpers/get-shader-layout.d.ts.map +1 -1
- package/dist/adapter/helpers/get-shader-layout.js +1 -3
- package/dist/adapter/helpers/typed-array-utils.d.ts.map +1 -0
- package/dist/adapter/helpers/webgl-texture-utils.d.ts +85 -18
- package/dist/adapter/helpers/webgl-texture-utils.d.ts.map +1 -1
- package/dist/adapter/helpers/webgl-texture-utils.js +210 -18
- package/dist/adapter/resources/webgl-render-pass.d.ts.map +1 -1
- package/dist/adapter/resources/webgl-render-pipeline.d.ts +1 -3
- package/dist/adapter/resources/webgl-render-pipeline.d.ts.map +1 -1
- package/dist/adapter/resources/webgl-texture.d.ts +1 -1
- package/dist/adapter/resources/webgl-texture.d.ts.map +1 -1
- package/dist/adapter/resources/webgl-texture.js +33 -8
- package/dist/adapter/webgl-device.d.ts +1 -2
- package/dist/adapter/webgl-device.d.ts.map +1 -1
- package/dist/adapter/webgl-device.js +2 -2
- package/dist/deprecated/accessor.d.ts.map +1 -0
- package/dist/{classic → deprecated}/accessor.js +36 -1
- package/dist/deprecated/clear.d.ts.map +1 -0
- package/dist/{classic → deprecated}/clear.js +2 -0
- package/dist/dist.dev.js +490 -432
- package/dist/dist.min.js +2 -2
- package/dist/index.cjs +491 -441
- package/dist/index.cjs.map +4 -4
- package/dist/index.d.ts +1 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +1 -1
- package/dist/utils/fill-array.d.ts +4 -4
- package/dist/utils/fill-array.d.ts.map +1 -1
- package/package.json +5 -5
- package/src/adapter/device-helpers/webgl-device-features.ts +5 -2
- package/src/adapter/helpers/get-shader-layout.ts +1 -3
- package/src/adapter/helpers/webgl-texture-utils.ts +356 -37
- package/src/adapter/resources/webgl-render-pass.ts +3 -3
- package/src/adapter/resources/webgl-render-pipeline.ts +10 -3
- package/src/adapter/resources/webgl-texture.ts +41 -8
- package/src/adapter/webgl-device.ts +13 -4
- package/src/{classic → deprecated}/accessor.ts +44 -3
- package/src/{classic → deprecated}/clear.ts +3 -1
- package/src/index.ts +1 -1
- package/src/utils/fill-array.ts +4 -4
- package/dist/classic/accessor.d.ts.map +0 -1
- package/dist/classic/clear.d.ts.map +0 -1
- package/dist/classic/copy-and-blit.d.ts +0 -64
- package/dist/classic/copy-and-blit.d.ts.map +0 -1
- package/dist/classic/copy-and-blit.js +0 -194
- package/dist/classic/format-utils.d.ts.map +0 -1
- package/dist/classic/typed-array-utils.d.ts.map +0 -1
- package/src/classic/copy-and-blit.ts +0 -323
- /package/dist/{classic → adapter/helpers}/format-utils.d.ts +0 -0
- /package/dist/{classic → adapter/helpers}/format-utils.js +0 -0
- /package/dist/{classic → adapter/helpers}/typed-array-utils.d.ts +0 -0
- /package/dist/{classic → adapter/helpers}/typed-array-utils.js +0 -0
- /package/dist/{classic → deprecated}/accessor.d.ts +0 -0
- /package/dist/{classic → deprecated}/clear.d.ts +0 -0
- /package/src/{classic → adapter/helpers}/format-utils.ts +0 -0
- /package/src/{classic → adapter/helpers}/typed-array-utils.ts +0 -0
package/dist/dist.dev.js
CHANGED
|
@@ -74,10 +74,10 @@ var __exports__ = (() => {
|
|
|
74
74
|
__reExport(bundle_exports, __toESM(require_core(), 1));
|
|
75
75
|
|
|
76
76
|
// src/adapter/webgl-adapter.ts
|
|
77
|
-
var
|
|
77
|
+
var import_core24 = __toESM(require_core(), 1);
|
|
78
78
|
|
|
79
79
|
// src/adapter/webgl-device.ts
|
|
80
|
-
var
|
|
80
|
+
var import_core23 = __toESM(require_core(), 1);
|
|
81
81
|
|
|
82
82
|
// ../constants/src/webgl-constants.ts
|
|
83
83
|
var GLEnum = /* @__PURE__ */ ((GLEnum2) => {
|
|
@@ -2142,13 +2142,13 @@ var __exports__ = (() => {
|
|
|
2142
2142
|
};
|
|
2143
2143
|
|
|
2144
2144
|
// src/adapter/webgl-canvas-context.ts
|
|
2145
|
-
var
|
|
2145
|
+
var import_core10 = __toESM(require_core(), 1);
|
|
2146
2146
|
|
|
2147
2147
|
// src/adapter/resources/webgl-framebuffer.ts
|
|
2148
|
-
var
|
|
2148
|
+
var import_core9 = __toESM(require_core(), 1);
|
|
2149
2149
|
|
|
2150
2150
|
// src/adapter/resources/webgl-texture.ts
|
|
2151
|
-
var
|
|
2151
|
+
var import_core8 = __toESM(require_core(), 1);
|
|
2152
2152
|
|
|
2153
2153
|
// src/context/state-tracker/with-parameters.ts
|
|
2154
2154
|
function withGLParameters(gl, parameters, func) {
|
|
@@ -2568,6 +2568,94 @@ var __exports__ = (() => {
|
|
|
2568
2568
|
}
|
|
2569
2569
|
};
|
|
2570
2570
|
|
|
2571
|
+
// src/adapter/helpers/webgl-texture-utils.ts
|
|
2572
|
+
var import_core7 = __toESM(require_core(), 1);
|
|
2573
|
+
|
|
2574
|
+
// src/adapter/helpers/typed-array-utils.ts
|
|
2575
|
+
var ERR_TYPE_DEDUCTION = "Failed to deduce GL constant from typed array";
|
|
2576
|
+
function getGLTypeFromTypedArray(arrayOrType) {
|
|
2577
|
+
const type = ArrayBuffer.isView(arrayOrType) ? arrayOrType.constructor : arrayOrType;
|
|
2578
|
+
switch (type) {
|
|
2579
|
+
case Float32Array:
|
|
2580
|
+
return 5126 /* FLOAT */;
|
|
2581
|
+
case Uint16Array:
|
|
2582
|
+
return 5123 /* UNSIGNED_SHORT */;
|
|
2583
|
+
case Uint32Array:
|
|
2584
|
+
return 5125 /* UNSIGNED_INT */;
|
|
2585
|
+
case Uint8Array:
|
|
2586
|
+
return 5121 /* UNSIGNED_BYTE */;
|
|
2587
|
+
case Uint8ClampedArray:
|
|
2588
|
+
return 5121 /* UNSIGNED_BYTE */;
|
|
2589
|
+
case Int8Array:
|
|
2590
|
+
return 5120 /* BYTE */;
|
|
2591
|
+
case Int16Array:
|
|
2592
|
+
return 5122 /* SHORT */;
|
|
2593
|
+
case Int32Array:
|
|
2594
|
+
return 5124 /* INT */;
|
|
2595
|
+
default:
|
|
2596
|
+
throw new Error(ERR_TYPE_DEDUCTION);
|
|
2597
|
+
}
|
|
2598
|
+
}
|
|
2599
|
+
function getTypedArrayFromGLType(glType, options) {
|
|
2600
|
+
const { clamped = true } = options || {};
|
|
2601
|
+
switch (glType) {
|
|
2602
|
+
case 5126 /* FLOAT */:
|
|
2603
|
+
return Float32Array;
|
|
2604
|
+
case 5123 /* UNSIGNED_SHORT */:
|
|
2605
|
+
case 33635 /* UNSIGNED_SHORT_5_6_5 */:
|
|
2606
|
+
case 32819 /* UNSIGNED_SHORT_4_4_4_4 */:
|
|
2607
|
+
case 32820 /* UNSIGNED_SHORT_5_5_5_1 */:
|
|
2608
|
+
return Uint16Array;
|
|
2609
|
+
case 5125 /* UNSIGNED_INT */:
|
|
2610
|
+
return Uint32Array;
|
|
2611
|
+
case 5121 /* UNSIGNED_BYTE */:
|
|
2612
|
+
return clamped ? Uint8ClampedArray : Uint8Array;
|
|
2613
|
+
case 5120 /* BYTE */:
|
|
2614
|
+
return Int8Array;
|
|
2615
|
+
case 5122 /* SHORT */:
|
|
2616
|
+
return Int16Array;
|
|
2617
|
+
case 5124 /* INT */:
|
|
2618
|
+
return Int32Array;
|
|
2619
|
+
default:
|
|
2620
|
+
throw new Error("Failed to deduce typed array type from GL constant");
|
|
2621
|
+
}
|
|
2622
|
+
}
|
|
2623
|
+
|
|
2624
|
+
// src/adapter/helpers/format-utils.ts
|
|
2625
|
+
function glFormatToComponents(format) {
|
|
2626
|
+
switch (format) {
|
|
2627
|
+
case 6406 /* ALPHA */:
|
|
2628
|
+
case 33326 /* R32F */:
|
|
2629
|
+
case 6403 /* RED */:
|
|
2630
|
+
return 1;
|
|
2631
|
+
case 33328 /* RG32F */:
|
|
2632
|
+
case 33319 /* RG */:
|
|
2633
|
+
return 2;
|
|
2634
|
+
case 6407 /* RGB */:
|
|
2635
|
+
case 34837 /* RGB32F */:
|
|
2636
|
+
return 3;
|
|
2637
|
+
case 6408 /* RGBA */:
|
|
2638
|
+
case 34836 /* RGBA32F */:
|
|
2639
|
+
return 4;
|
|
2640
|
+
default:
|
|
2641
|
+
return 0;
|
|
2642
|
+
}
|
|
2643
|
+
}
|
|
2644
|
+
function glTypeToBytes(type) {
|
|
2645
|
+
switch (type) {
|
|
2646
|
+
case 5121 /* UNSIGNED_BYTE */:
|
|
2647
|
+
return 1;
|
|
2648
|
+
case 33635 /* UNSIGNED_SHORT_5_6_5 */:
|
|
2649
|
+
case 32819 /* UNSIGNED_SHORT_4_4_4_4 */:
|
|
2650
|
+
case 32820 /* UNSIGNED_SHORT_5_5_5_1 */:
|
|
2651
|
+
return 2;
|
|
2652
|
+
case 5126 /* FLOAT */:
|
|
2653
|
+
return 4;
|
|
2654
|
+
default:
|
|
2655
|
+
return 0;
|
|
2656
|
+
}
|
|
2657
|
+
}
|
|
2658
|
+
|
|
2571
2659
|
// src/adapter/helpers/webgl-texture-utils.ts
|
|
2572
2660
|
function initializeTextureStorage(gl, levels, options) {
|
|
2573
2661
|
const { dimension, width, height, depth = 0 } = options;
|
|
@@ -2582,26 +2670,31 @@ var __exports__ = (() => {
|
|
|
2582
2670
|
gl.texStorage2D(glTarget, levels, glInternalFormat, width, height);
|
|
2583
2671
|
}
|
|
2584
2672
|
}
|
|
2585
|
-
function
|
|
2586
|
-
const {
|
|
2673
|
+
function copyExternalImageToMipLevel(gl, handle, image, options) {
|
|
2674
|
+
const { width, height } = options;
|
|
2675
|
+
const { dimension, depth = 0, mipLevel = 0 } = options;
|
|
2587
2676
|
const { x = 0, y = 0, z = 0 } = options;
|
|
2588
2677
|
const { glFormat, glType } = options;
|
|
2589
2678
|
const glTarget = getWebGLCubeFaceTarget(options.glTarget, dimension, depth);
|
|
2590
2679
|
switch (dimension) {
|
|
2591
2680
|
case "2d-array":
|
|
2592
2681
|
case "3d":
|
|
2593
|
-
gl.
|
|
2682
|
+
gl.bindTexture(glTarget, handle);
|
|
2683
|
+
gl.texSubImage3D(glTarget, mipLevel, x, y, z, width, height, depth, glFormat, glType, image);
|
|
2684
|
+
gl.bindTexture(glTarget, null);
|
|
2594
2685
|
break;
|
|
2595
2686
|
case "2d":
|
|
2596
2687
|
case "cube":
|
|
2597
|
-
gl.
|
|
2688
|
+
gl.bindTexture(glTarget, handle);
|
|
2689
|
+
gl.texSubImage2D(glTarget, mipLevel, x, y, width, height, glFormat, glType, image);
|
|
2690
|
+
gl.bindTexture(glTarget, null);
|
|
2598
2691
|
break;
|
|
2599
2692
|
default:
|
|
2600
2693
|
throw new Error(dimension);
|
|
2601
2694
|
}
|
|
2602
2695
|
}
|
|
2603
2696
|
function copyCPUDataToMipLevel(gl, typedArray, options) {
|
|
2604
|
-
const { dimension, width, height, depth = 0,
|
|
2697
|
+
const { dimension, width, height, depth = 0, mipLevel = 0, byteOffset = 0 } = options;
|
|
2605
2698
|
const { x = 0, y = 0, z = 0 } = options;
|
|
2606
2699
|
const { glFormat, glType, compressed } = options;
|
|
2607
2700
|
const glTarget = getWebGLCubeFaceTarget(options.glTarget, dimension, depth);
|
|
@@ -2609,17 +2702,17 @@ var __exports__ = (() => {
|
|
|
2609
2702
|
case "2d-array":
|
|
2610
2703
|
case "3d":
|
|
2611
2704
|
if (compressed) {
|
|
2612
|
-
gl.compressedTexSubImage3D(glTarget,
|
|
2705
|
+
gl.compressedTexSubImage3D(glTarget, mipLevel, x, y, z, width, height, depth, glFormat, typedArray, byteOffset);
|
|
2613
2706
|
} else {
|
|
2614
|
-
gl.texSubImage3D(glTarget,
|
|
2707
|
+
gl.texSubImage3D(glTarget, mipLevel, x, y, z, width, height, depth, glFormat, glType, typedArray, byteOffset);
|
|
2615
2708
|
}
|
|
2616
2709
|
break;
|
|
2617
2710
|
case "2d":
|
|
2618
2711
|
case "cube":
|
|
2619
2712
|
if (compressed) {
|
|
2620
|
-
gl.compressedTexSubImage2D(glTarget,
|
|
2713
|
+
gl.compressedTexSubImage2D(glTarget, mipLevel, x, y, width, height, glFormat, typedArray, byteOffset);
|
|
2621
2714
|
} else {
|
|
2622
|
-
gl.texSubImage2D(glTarget,
|
|
2715
|
+
gl.texSubImage2D(glTarget, mipLevel, x, y, width, height, glFormat, glType, typedArray, byteOffset);
|
|
2623
2716
|
}
|
|
2624
2717
|
break;
|
|
2625
2718
|
default:
|
|
@@ -2646,6 +2739,102 @@ var __exports__ = (() => {
|
|
|
2646
2739
|
function getWebGLCubeFaceTarget(glTarget, dimension, level) {
|
|
2647
2740
|
return dimension === "cube" ? 34069 /* TEXTURE_CUBE_MAP_POSITIVE_X */ + level : glTarget;
|
|
2648
2741
|
}
|
|
2742
|
+
function readPixelsToArray(source, options) {
|
|
2743
|
+
const {
|
|
2744
|
+
sourceX = 0,
|
|
2745
|
+
sourceY = 0,
|
|
2746
|
+
sourceAttachment = 36064 /* COLOR_ATTACHMENT0 */
|
|
2747
|
+
// TODO - support gl.readBuffer
|
|
2748
|
+
} = options || {};
|
|
2749
|
+
let {
|
|
2750
|
+
target = null,
|
|
2751
|
+
// following parameters are auto deduced if not provided
|
|
2752
|
+
sourceWidth,
|
|
2753
|
+
sourceHeight,
|
|
2754
|
+
sourceDepth,
|
|
2755
|
+
sourceFormat,
|
|
2756
|
+
sourceType
|
|
2757
|
+
} = options || {};
|
|
2758
|
+
const { framebuffer, deleteFramebuffer } = getFramebuffer(source);
|
|
2759
|
+
const { gl, handle } = framebuffer;
|
|
2760
|
+
const attachment = sourceAttachment - 36064 /* COLOR_ATTACHMENT0 */;
|
|
2761
|
+
sourceWidth ||= framebuffer.width;
|
|
2762
|
+
sourceHeight ||= framebuffer.height;
|
|
2763
|
+
sourceDepth = framebuffer.colorAttachments[attachment]?.texture?.depth || 1;
|
|
2764
|
+
sourceFormat ||= framebuffer.colorAttachments[attachment]?.texture?.glFormat || 6408 /* RGBA */;
|
|
2765
|
+
sourceType ||= framebuffer.colorAttachments[attachment]?.texture?.glType || 5121 /* UNSIGNED_BYTE */;
|
|
2766
|
+
target = getPixelArray(target, sourceType, sourceFormat, sourceWidth, sourceHeight, sourceDepth);
|
|
2767
|
+
sourceType = sourceType || getGLTypeFromTypedArray(target);
|
|
2768
|
+
const prevHandle = gl.bindFramebuffer(36160 /* FRAMEBUFFER */, handle);
|
|
2769
|
+
gl.readPixels(sourceX, sourceY, sourceWidth, sourceHeight, sourceFormat, sourceType, target);
|
|
2770
|
+
gl.bindFramebuffer(36160 /* FRAMEBUFFER */, prevHandle || null);
|
|
2771
|
+
if (deleteFramebuffer) {
|
|
2772
|
+
framebuffer.destroy();
|
|
2773
|
+
}
|
|
2774
|
+
return target;
|
|
2775
|
+
}
|
|
2776
|
+
function readPixelsToBuffer(source, options) {
|
|
2777
|
+
const {
|
|
2778
|
+
target,
|
|
2779
|
+
sourceX = 0,
|
|
2780
|
+
sourceY = 0,
|
|
2781
|
+
sourceFormat = 6408 /* RGBA */,
|
|
2782
|
+
targetByteOffset = 0
|
|
2783
|
+
} = options || {};
|
|
2784
|
+
let { sourceWidth, sourceHeight, sourceType } = options || {};
|
|
2785
|
+
const { framebuffer, deleteFramebuffer } = getFramebuffer(source);
|
|
2786
|
+
sourceWidth = sourceWidth || framebuffer.width;
|
|
2787
|
+
sourceHeight = sourceHeight || framebuffer.height;
|
|
2788
|
+
const webglFramebuffer = framebuffer;
|
|
2789
|
+
sourceType = sourceType || 5121 /* UNSIGNED_BYTE */;
|
|
2790
|
+
let webglBufferTarget = target;
|
|
2791
|
+
if (!webglBufferTarget) {
|
|
2792
|
+
const components = glFormatToComponents(sourceFormat);
|
|
2793
|
+
const byteCount = glTypeToBytes(sourceType);
|
|
2794
|
+
const byteLength = targetByteOffset + sourceWidth * sourceHeight * components * byteCount;
|
|
2795
|
+
webglBufferTarget = webglFramebuffer.device.createBuffer({ byteLength });
|
|
2796
|
+
}
|
|
2797
|
+
const commandEncoder = source.device.createCommandEncoder();
|
|
2798
|
+
commandEncoder.copyTextureToBuffer({
|
|
2799
|
+
source,
|
|
2800
|
+
width: sourceWidth,
|
|
2801
|
+
height: sourceHeight,
|
|
2802
|
+
origin: [sourceX, sourceY],
|
|
2803
|
+
destination: webglBufferTarget,
|
|
2804
|
+
byteOffset: targetByteOffset
|
|
2805
|
+
});
|
|
2806
|
+
commandEncoder.destroy();
|
|
2807
|
+
if (deleteFramebuffer) {
|
|
2808
|
+
framebuffer.destroy();
|
|
2809
|
+
}
|
|
2810
|
+
return webglBufferTarget;
|
|
2811
|
+
}
|
|
2812
|
+
function getFramebuffer(source) {
|
|
2813
|
+
if (!(source instanceof import_core7.Framebuffer)) {
|
|
2814
|
+
return { framebuffer: toFramebuffer(source), deleteFramebuffer: true };
|
|
2815
|
+
}
|
|
2816
|
+
return { framebuffer: source, deleteFramebuffer: false };
|
|
2817
|
+
}
|
|
2818
|
+
function toFramebuffer(texture, props) {
|
|
2819
|
+
const { device, width, height, id } = texture;
|
|
2820
|
+
const framebuffer = device.createFramebuffer({
|
|
2821
|
+
...props,
|
|
2822
|
+
id: `framebuffer-for-${id}`,
|
|
2823
|
+
width,
|
|
2824
|
+
height,
|
|
2825
|
+
colorAttachments: [texture]
|
|
2826
|
+
});
|
|
2827
|
+
return framebuffer;
|
|
2828
|
+
}
|
|
2829
|
+
function getPixelArray(pixelArray, type, format, width, height, depth) {
|
|
2830
|
+
if (pixelArray) {
|
|
2831
|
+
return pixelArray;
|
|
2832
|
+
}
|
|
2833
|
+
type = type || 5121 /* UNSIGNED_BYTE */;
|
|
2834
|
+
const ArrayType = getTypedArrayFromGLType(type, { clamped: false });
|
|
2835
|
+
const components = glFormatToComponents(format);
|
|
2836
|
+
return new ArrayType(width * height * components);
|
|
2837
|
+
}
|
|
2649
2838
|
|
|
2650
2839
|
// src/adapter/resources/webgl-texture.ts
|
|
2651
2840
|
function normalizeTextureData(data, options) {
|
|
@@ -2667,7 +2856,7 @@ var __exports__ = (() => {
|
|
|
2667
2856
|
}
|
|
2668
2857
|
return lodArray;
|
|
2669
2858
|
}
|
|
2670
|
-
var WEBGLTexture = class extends
|
|
2859
|
+
var WEBGLTexture = class extends import_core8.Texture {
|
|
2671
2860
|
MAX_ATTRIBUTES;
|
|
2672
2861
|
device;
|
|
2673
2862
|
gl;
|
|
@@ -2708,7 +2897,7 @@ var __exports__ = (() => {
|
|
|
2708
2897
|
/** For automatically updating video */
|
|
2709
2898
|
_video = null;
|
|
2710
2899
|
constructor(device, props) {
|
|
2711
|
-
super(device, { ...
|
|
2900
|
+
super(device, { ...import_core8.Texture.defaultProps, ...props, data: void 0 });
|
|
2712
2901
|
this.device = device;
|
|
2713
2902
|
this.gl = this.device.gl;
|
|
2714
2903
|
this.glTarget = getWebGLTextureTarget(this.props.dimension);
|
|
@@ -2736,7 +2925,7 @@ var __exports__ = (() => {
|
|
|
2736
2925
|
const data = props.data;
|
|
2737
2926
|
let { width, height } = props;
|
|
2738
2927
|
if (!width || !height) {
|
|
2739
|
-
const textureSize =
|
|
2928
|
+
const textureSize = import_core8.Texture.getTextureDataSize(data);
|
|
2740
2929
|
width = textureSize?.width || 1;
|
|
2741
2930
|
height = textureSize?.height || 1;
|
|
2742
2931
|
}
|
|
@@ -2829,7 +3018,7 @@ var __exports__ = (() => {
|
|
|
2829
3018
|
}
|
|
2830
3019
|
/** Update external texture (video frame or canvas) */
|
|
2831
3020
|
update() {
|
|
2832
|
-
|
|
3021
|
+
import_core8.log.warn("Texture.update() not implemented");
|
|
2833
3022
|
}
|
|
2834
3023
|
// Call to regenerate mipmaps after modifying texture(s)
|
|
2835
3024
|
generateMipmap(params = {}) {
|
|
@@ -2845,12 +3034,32 @@ var __exports__ = (() => {
|
|
|
2845
3034
|
}
|
|
2846
3035
|
// Image Data Setters
|
|
2847
3036
|
copyExternalImage(options) {
|
|
2848
|
-
const size =
|
|
2849
|
-
const opts = { ...
|
|
2850
|
-
const { depth, mipLevel
|
|
2851
|
-
|
|
2852
|
-
|
|
2853
|
-
|
|
3037
|
+
const size = import_core8.Texture.getExternalImageSize(options.image);
|
|
3038
|
+
const opts = { ...import_core8.Texture.defaultCopyExternalImageOptions, ...size, ...options };
|
|
3039
|
+
const { image, depth, mipLevel, x, y, z } = opts;
|
|
3040
|
+
let { width, height } = opts;
|
|
3041
|
+
const { dimension, glTarget, glFormat, glInternalFormat, glType } = this;
|
|
3042
|
+
width = Math.min(width, size.width - x);
|
|
3043
|
+
height = Math.min(height, size.height - y);
|
|
3044
|
+
if (options.sourceX || options.sourceY) {
|
|
3045
|
+
throw new Error(
|
|
3046
|
+
"WebGL does not yet support sourceX/sourceY in copyExternalImage; requires copyTexSubImage2D from a framebuffer"
|
|
3047
|
+
);
|
|
3048
|
+
}
|
|
3049
|
+
copyExternalImageToMipLevel(this.device.gl, this.handle, image, {
|
|
3050
|
+
dimension,
|
|
3051
|
+
mipLevel,
|
|
3052
|
+
x,
|
|
3053
|
+
y,
|
|
3054
|
+
z,
|
|
3055
|
+
width,
|
|
3056
|
+
height,
|
|
3057
|
+
depth,
|
|
3058
|
+
glFormat,
|
|
3059
|
+
glInternalFormat,
|
|
3060
|
+
glType,
|
|
3061
|
+
glTarget
|
|
3062
|
+
});
|
|
2854
3063
|
return { width: opts.width, height: opts.height };
|
|
2855
3064
|
}
|
|
2856
3065
|
setTexture1DData(data) {
|
|
@@ -2861,7 +3070,7 @@ var __exports__ = (() => {
|
|
|
2861
3070
|
this.bind();
|
|
2862
3071
|
const lodArray = normalizeTextureData(lodData, this);
|
|
2863
3072
|
if (lodArray.length > 1 && this.props.mipmaps !== false) {
|
|
2864
|
-
|
|
3073
|
+
import_core8.log.warn(`Texture ${this.id} mipmap and multiple LODs.`)();
|
|
2865
3074
|
}
|
|
2866
3075
|
for (let lodLevel = 0; lodLevel < lodArray.length; lodLevel++) {
|
|
2867
3076
|
const imageData = lodArray[lodLevel];
|
|
@@ -2893,7 +3102,7 @@ var __exports__ = (() => {
|
|
|
2893
3102
|
if (this.props.dimension !== "cube") {
|
|
2894
3103
|
throw new Error(this.id);
|
|
2895
3104
|
}
|
|
2896
|
-
for (const face of
|
|
3105
|
+
for (const face of import_core8.Texture.CubeFaces) {
|
|
2897
3106
|
this.setTextureCubeFaceData(data[face], face);
|
|
2898
3107
|
}
|
|
2899
3108
|
}
|
|
@@ -2916,9 +3125,9 @@ var __exports__ = (() => {
|
|
|
2916
3125
|
}
|
|
2917
3126
|
setTextureCubeFaceData(lodData, face, depth = 0) {
|
|
2918
3127
|
if (Array.isArray(lodData) && lodData.length > 1 && this.props.mipmaps !== false) {
|
|
2919
|
-
|
|
3128
|
+
import_core8.log.warn(`${this.id} has mipmap and multiple LODs.`)();
|
|
2920
3129
|
}
|
|
2921
|
-
const faceDepth =
|
|
3130
|
+
const faceDepth = import_core8.Texture.CubeFaces.indexOf(face);
|
|
2922
3131
|
this.setTexture2DData(lodData, faceDepth);
|
|
2923
3132
|
}
|
|
2924
3133
|
// INTERNAL METHODS
|
|
@@ -2954,8 +3163,8 @@ var __exports__ = (() => {
|
|
|
2954
3163
|
}
|
|
2955
3164
|
}
|
|
2956
3165
|
_getImageDataMap(faceData) {
|
|
2957
|
-
for (let i = 0; i <
|
|
2958
|
-
const faceName =
|
|
3166
|
+
for (let i = 0; i < import_core8.Texture.CubeFaces.length; ++i) {
|
|
3167
|
+
const faceName = import_core8.Texture.CubeFaces[i];
|
|
2959
3168
|
if (faceData[faceName]) {
|
|
2960
3169
|
faceData[34069 /* TEXTURE_CUBE_MAP_POSITIVE_X */ + i] = faceData[faceName];
|
|
2961
3170
|
delete faceData[faceName];
|
|
@@ -2968,7 +3177,7 @@ var __exports__ = (() => {
|
|
|
2968
3177
|
* Sets sampler parameters on texture
|
|
2969
3178
|
*/
|
|
2970
3179
|
_setSamplerParameters(parameters) {
|
|
2971
|
-
|
|
3180
|
+
import_core8.log.log(1, "texture sampler parameters", parameters)();
|
|
2972
3181
|
this.gl.bindTexture(this.glTarget, this.handle);
|
|
2973
3182
|
for (const [pname, pvalue] of Object.entries(parameters)) {
|
|
2974
3183
|
const param = Number(pname);
|
|
@@ -3057,16 +3266,21 @@ var __exports__ = (() => {
|
|
|
3057
3266
|
* Copy a region of data from a CPU memory buffer into this texture.
|
|
3058
3267
|
* @todo - GLUnpackParameters parameters
|
|
3059
3268
|
*/
|
|
3060
|
-
_setMipLevel(depth,
|
|
3061
|
-
if (
|
|
3062
|
-
|
|
3269
|
+
_setMipLevel(depth, mipLevel, textureData, glTarget = this.glTarget) {
|
|
3270
|
+
if (import_core8.Texture.isExternalImage(textureData)) {
|
|
3271
|
+
copyExternalImageToMipLevel(this.device.gl, this.handle, textureData, {
|
|
3272
|
+
...this,
|
|
3273
|
+
depth,
|
|
3274
|
+
mipLevel,
|
|
3275
|
+
glTarget
|
|
3276
|
+
});
|
|
3063
3277
|
return;
|
|
3064
3278
|
}
|
|
3065
|
-
if (
|
|
3279
|
+
if (import_core8.Texture.isTextureLevelData(textureData)) {
|
|
3066
3280
|
copyCPUDataToMipLevel(this.device.gl, textureData.data, {
|
|
3067
3281
|
...this,
|
|
3068
3282
|
depth,
|
|
3069
|
-
|
|
3283
|
+
mipLevel,
|
|
3070
3284
|
glTarget
|
|
3071
3285
|
});
|
|
3072
3286
|
return;
|
|
@@ -3098,7 +3312,7 @@ var __exports__ = (() => {
|
|
|
3098
3312
|
};
|
|
3099
3313
|
|
|
3100
3314
|
// src/adapter/resources/webgl-framebuffer.ts
|
|
3101
|
-
var WEBGLFramebuffer = class extends
|
|
3315
|
+
var WEBGLFramebuffer = class extends import_core9.Framebuffer {
|
|
3102
3316
|
device;
|
|
3103
3317
|
gl;
|
|
3104
3318
|
handle;
|
|
@@ -3244,7 +3458,7 @@ var __exports__ = (() => {
|
|
|
3244
3458
|
}
|
|
3245
3459
|
|
|
3246
3460
|
// src/adapter/webgl-canvas-context.ts
|
|
3247
|
-
var WebGLCanvasContext = class extends
|
|
3461
|
+
var WebGLCanvasContext = class extends import_core10.CanvasContext {
|
|
3248
3462
|
device;
|
|
3249
3463
|
format = "rgba8unorm";
|
|
3250
3464
|
depthStencilFormat = "depth24plus";
|
|
@@ -3297,7 +3511,7 @@ var __exports__ = (() => {
|
|
|
3297
3511
|
};
|
|
3298
3512
|
|
|
3299
3513
|
// src/context/debug/spector.ts
|
|
3300
|
-
var
|
|
3514
|
+
var import_core11 = __toESM(require_core(), 1);
|
|
3301
3515
|
|
|
3302
3516
|
// src/utils/load-script.ts
|
|
3303
3517
|
async function loadScript(scriptUrl, scriptId) {
|
|
@@ -3323,7 +3537,7 @@ var __exports__ = (() => {
|
|
|
3323
3537
|
var spector = null;
|
|
3324
3538
|
var initialized = false;
|
|
3325
3539
|
var DEFAULT_SPECTOR_PROPS = {
|
|
3326
|
-
debugWithSpectorJS:
|
|
3540
|
+
debugWithSpectorJS: import_core11.log.get("spector") || import_core11.log.get("spectorjs"),
|
|
3327
3541
|
// https://github.com/BabylonJS/Spector.js#basic-usage
|
|
3328
3542
|
// https://forum.babylonjs.com/t/spectorcdn-is-temporarily-off/48241
|
|
3329
3543
|
// spectorUrl: 'https://spectorcdn.babylonjs.com/spector.bundle.js';
|
|
@@ -3335,7 +3549,7 @@ var __exports__ = (() => {
|
|
|
3335
3549
|
try {
|
|
3336
3550
|
await loadScript(props.spectorUrl || DEFAULT_SPECTOR_PROPS.spectorUrl);
|
|
3337
3551
|
} catch (error) {
|
|
3338
|
-
|
|
3552
|
+
import_core11.log.warn(String(error));
|
|
3339
3553
|
}
|
|
3340
3554
|
}
|
|
3341
3555
|
}
|
|
@@ -3345,7 +3559,7 @@ var __exports__ = (() => {
|
|
|
3345
3559
|
return null;
|
|
3346
3560
|
}
|
|
3347
3561
|
if (!spector && globalThis.SPECTOR && !globalThis.luma?.spector) {
|
|
3348
|
-
|
|
3562
|
+
import_core11.log.probe(LOG_LEVEL, "SPECTOR found and initialized. Start with `luma.spector.displayUI()`")();
|
|
3349
3563
|
const { Spector } = globalThis.SPECTOR;
|
|
3350
3564
|
spector = new Spector();
|
|
3351
3565
|
if (globalThis.luma) {
|
|
@@ -3359,10 +3573,10 @@ var __exports__ = (() => {
|
|
|
3359
3573
|
initialized = true;
|
|
3360
3574
|
spector.spyCanvases();
|
|
3361
3575
|
spector?.onCaptureStarted.add(
|
|
3362
|
-
(capture) =>
|
|
3576
|
+
(capture) => import_core11.log.info("Spector capture started:", capture)()
|
|
3363
3577
|
);
|
|
3364
3578
|
spector?.onCapture.add((capture) => {
|
|
3365
|
-
|
|
3579
|
+
import_core11.log.info("Spector capture complete:", capture)();
|
|
3366
3580
|
spector?.getResultUI();
|
|
3367
3581
|
spector?.resultView.display();
|
|
3368
3582
|
spector?.resultView.addCapture(capture);
|
|
@@ -3374,7 +3588,7 @@ var __exports__ = (() => {
|
|
|
3374
3588
|
spector?.startCapture(props.gl, 500);
|
|
3375
3589
|
gl.device = device;
|
|
3376
3590
|
new Promise((resolve) => setTimeout(resolve, 2e3)).then((_) => {
|
|
3377
|
-
|
|
3591
|
+
import_core11.log.info("Spector capture stopped after 2 seconds")();
|
|
3378
3592
|
spector?.stopCapture();
|
|
3379
3593
|
});
|
|
3380
3594
|
}
|
|
@@ -3382,7 +3596,7 @@ var __exports__ = (() => {
|
|
|
3382
3596
|
}
|
|
3383
3597
|
|
|
3384
3598
|
// src/context/debug/webgl-developer-tools.ts
|
|
3385
|
-
var
|
|
3599
|
+
var import_core12 = __toESM(require_core(), 1);
|
|
3386
3600
|
|
|
3387
3601
|
// ../../node_modules/@probe.gl/env/dist/lib/globals.js
|
|
3388
3602
|
var document_ = globalThis.document || {};
|
|
@@ -3458,7 +3672,7 @@ var __exports__ = (() => {
|
|
|
3458
3672
|
}
|
|
3459
3673
|
function getDebugContext(gl, props) {
|
|
3460
3674
|
if (!globalThis.WebGLDebugUtils) {
|
|
3461
|
-
|
|
3675
|
+
import_core12.log.warn("webgl-debug not loaded")();
|
|
3462
3676
|
return gl;
|
|
3463
3677
|
}
|
|
3464
3678
|
const data = getWebGLContextData(gl);
|
|
@@ -3497,7 +3711,7 @@ var __exports__ = (() => {
|
|
|
3497
3711
|
const errorMessage = globalThis.WebGLDebugUtils.glEnumToString(err);
|
|
3498
3712
|
const functionArgs = globalThis.WebGLDebugUtils.glFunctionArgsToString(functionName, args);
|
|
3499
3713
|
const message2 = `${errorMessage} in gl.${functionName}(${functionArgs})`;
|
|
3500
|
-
|
|
3714
|
+
import_core12.log.error(message2)();
|
|
3501
3715
|
debugger;
|
|
3502
3716
|
if (props.throwOnError) {
|
|
3503
3717
|
throw new Error(message2);
|
|
@@ -3505,9 +3719,9 @@ var __exports__ = (() => {
|
|
|
3505
3719
|
}
|
|
3506
3720
|
function onValidateGLFunc(props, functionName, functionArgs) {
|
|
3507
3721
|
let functionString = "";
|
|
3508
|
-
if (
|
|
3722
|
+
if (import_core12.log.level >= 1) {
|
|
3509
3723
|
functionString = getFunctionString(functionName, functionArgs);
|
|
3510
|
-
|
|
3724
|
+
import_core12.log.log(1, functionString)();
|
|
3511
3725
|
}
|
|
3512
3726
|
if (props.break && props.break.length > 0) {
|
|
3513
3727
|
functionString = functionString || getFunctionString(functionName, functionArgs);
|
|
@@ -3524,7 +3738,7 @@ var __exports__ = (() => {
|
|
|
3524
3738
|
if (props.throwOnError) {
|
|
3525
3739
|
throw new Error(`Undefined argument: ${functionString}`);
|
|
3526
3740
|
} else {
|
|
3527
|
-
|
|
3741
|
+
import_core12.log.error(`Undefined argument: ${functionString}`)();
|
|
3528
3742
|
debugger;
|
|
3529
3743
|
}
|
|
3530
3744
|
}
|
|
@@ -3540,8 +3754,8 @@ var __exports__ = (() => {
|
|
|
3540
3754
|
}
|
|
3541
3755
|
|
|
3542
3756
|
// src/adapter/resources/webgl-buffer.ts
|
|
3543
|
-
var
|
|
3544
|
-
var WEBGLBuffer = class extends
|
|
3757
|
+
var import_core13 = __toESM(require_core(), 1);
|
|
3758
|
+
var WEBGLBuffer = class extends import_core13.Buffer {
|
|
3545
3759
|
device;
|
|
3546
3760
|
gl;
|
|
3547
3761
|
handle;
|
|
@@ -3639,32 +3853,32 @@ var __exports__ = (() => {
|
|
|
3639
3853
|
}
|
|
3640
3854
|
};
|
|
3641
3855
|
function getWebGLTarget(usage) {
|
|
3642
|
-
if (usage &
|
|
3856
|
+
if (usage & import_core13.Buffer.INDEX) {
|
|
3643
3857
|
return 34963 /* ELEMENT_ARRAY_BUFFER */;
|
|
3644
3858
|
}
|
|
3645
|
-
if (usage &
|
|
3859
|
+
if (usage & import_core13.Buffer.VERTEX) {
|
|
3646
3860
|
return 34962 /* ARRAY_BUFFER */;
|
|
3647
3861
|
}
|
|
3648
|
-
if (usage &
|
|
3862
|
+
if (usage & import_core13.Buffer.UNIFORM) {
|
|
3649
3863
|
return 35345 /* UNIFORM_BUFFER */;
|
|
3650
3864
|
}
|
|
3651
3865
|
return 34962 /* ARRAY_BUFFER */;
|
|
3652
3866
|
}
|
|
3653
3867
|
function getWebGLUsage(usage) {
|
|
3654
|
-
if (usage &
|
|
3868
|
+
if (usage & import_core13.Buffer.INDEX) {
|
|
3655
3869
|
return 35044 /* STATIC_DRAW */;
|
|
3656
3870
|
}
|
|
3657
|
-
if (usage &
|
|
3871
|
+
if (usage & import_core13.Buffer.VERTEX) {
|
|
3658
3872
|
return 35044 /* STATIC_DRAW */;
|
|
3659
3873
|
}
|
|
3660
|
-
if (usage &
|
|
3874
|
+
if (usage & import_core13.Buffer.UNIFORM) {
|
|
3661
3875
|
return 35048 /* DYNAMIC_DRAW */;
|
|
3662
3876
|
}
|
|
3663
3877
|
return 35044 /* STATIC_DRAW */;
|
|
3664
3878
|
}
|
|
3665
3879
|
|
|
3666
3880
|
// src/adapter/resources/webgl-shader.ts
|
|
3667
|
-
var
|
|
3881
|
+
var import_core14 = __toESM(require_core(), 1);
|
|
3668
3882
|
|
|
3669
3883
|
// src/adapter/helpers/parse-shader-compiler-log.ts
|
|
3670
3884
|
function parseShaderCompilerLog(errLog) {
|
|
@@ -3711,7 +3925,7 @@ var __exports__ = (() => {
|
|
|
3711
3925
|
}
|
|
3712
3926
|
|
|
3713
3927
|
// src/adapter/resources/webgl-shader.ts
|
|
3714
|
-
var WEBGLShader = class extends
|
|
3928
|
+
var WEBGLShader = class extends import_core14.Shader {
|
|
3715
3929
|
device;
|
|
3716
3930
|
handle;
|
|
3717
3931
|
constructor(device, props) {
|
|
@@ -3741,8 +3955,8 @@ var __exports__ = (() => {
|
|
|
3741
3955
|
return this.getCompilationInfoSync();
|
|
3742
3956
|
}
|
|
3743
3957
|
getCompilationInfoSync() {
|
|
3744
|
-
const
|
|
3745
|
-
return
|
|
3958
|
+
const log12 = this.device.gl.getShaderInfoLog(this.handle);
|
|
3959
|
+
return log12 ? parseShaderCompilerLog(log12) : [];
|
|
3746
3960
|
}
|
|
3747
3961
|
getTranslatedSource() {
|
|
3748
3962
|
const extensions = this.device.getExtension("WEBGL_debug_shaders");
|
|
@@ -3758,7 +3972,7 @@ ${source2}`;
|
|
|
3758
3972
|
const { gl } = this.device;
|
|
3759
3973
|
gl.shaderSource(this.handle, source);
|
|
3760
3974
|
gl.compileShader(this.handle);
|
|
3761
|
-
if (
|
|
3975
|
+
if (import_core14.log.level === 0) {
|
|
3762
3976
|
this.compilationStatus = "pending";
|
|
3763
3977
|
return;
|
|
3764
3978
|
}
|
|
@@ -3770,9 +3984,9 @@ ${source2}`;
|
|
|
3770
3984
|
}
|
|
3771
3985
|
return;
|
|
3772
3986
|
}
|
|
3773
|
-
|
|
3987
|
+
import_core14.log.once(1, "Shader compilation is asynchronous")();
|
|
3774
3988
|
await this._waitForCompilationComplete();
|
|
3775
|
-
|
|
3989
|
+
import_core14.log.info(2, `Shader ${this.id} - async compilation complete: ${this.compilationStatus}`)();
|
|
3776
3990
|
this._getCompilationStatus();
|
|
3777
3991
|
this.debugShader();
|
|
3778
3992
|
}
|
|
@@ -3804,13 +4018,13 @@ ${source2}`;
|
|
|
3804
4018
|
};
|
|
3805
4019
|
|
|
3806
4020
|
// src/adapter/resources/webgl-render-pass.ts
|
|
3807
|
-
var
|
|
4021
|
+
var import_core15 = __toESM(require_core(), 1);
|
|
3808
4022
|
var GL_DEPTH_BUFFER_BIT = 256;
|
|
3809
4023
|
var GL_STENCIL_BUFFER_BIT = 1024;
|
|
3810
4024
|
var GL_COLOR_BUFFER_BIT = 16384;
|
|
3811
4025
|
var GL_COLOR = 6144;
|
|
3812
4026
|
var COLOR_CHANNELS = [1, 2, 4, 8];
|
|
3813
|
-
var WEBGLRenderPass = class extends
|
|
4027
|
+
var WEBGLRenderPass = class extends import_core15.RenderPass {
|
|
3814
4028
|
device;
|
|
3815
4029
|
/** Parameters that should be applied before each draw call */
|
|
3816
4030
|
glParameters;
|
|
@@ -3954,179 +4168,11 @@ ${source2}`;
|
|
|
3954
4168
|
};
|
|
3955
4169
|
|
|
3956
4170
|
// src/adapter/resources/webgl-render-pipeline.ts
|
|
3957
|
-
var
|
|
4171
|
+
var import_core16 = __toESM(require_core(), 1);
|
|
3958
4172
|
|
|
3959
|
-
// src/
|
|
3960
|
-
|
|
3961
|
-
|
|
3962
|
-
const type = ArrayBuffer.isView(arrayOrType) ? arrayOrType.constructor : arrayOrType;
|
|
3963
|
-
switch (type) {
|
|
3964
|
-
case Float32Array:
|
|
3965
|
-
return 5126 /* FLOAT */;
|
|
3966
|
-
case Uint16Array:
|
|
3967
|
-
return 5123 /* UNSIGNED_SHORT */;
|
|
3968
|
-
case Uint32Array:
|
|
3969
|
-
return 5125 /* UNSIGNED_INT */;
|
|
3970
|
-
case Uint8Array:
|
|
3971
|
-
return 5121 /* UNSIGNED_BYTE */;
|
|
3972
|
-
case Uint8ClampedArray:
|
|
3973
|
-
return 5121 /* UNSIGNED_BYTE */;
|
|
3974
|
-
case Int8Array:
|
|
3975
|
-
return 5120 /* BYTE */;
|
|
3976
|
-
case Int16Array:
|
|
3977
|
-
return 5122 /* SHORT */;
|
|
3978
|
-
case Int32Array:
|
|
3979
|
-
return 5124 /* INT */;
|
|
3980
|
-
default:
|
|
3981
|
-
throw new Error(ERR_TYPE_DEDUCTION);
|
|
3982
|
-
}
|
|
3983
|
-
}
|
|
3984
|
-
function getTypedArrayFromGLType(glType, options) {
|
|
3985
|
-
const { clamped = true } = options || {};
|
|
3986
|
-
switch (glType) {
|
|
3987
|
-
case 5126 /* FLOAT */:
|
|
3988
|
-
return Float32Array;
|
|
3989
|
-
case 5123 /* UNSIGNED_SHORT */:
|
|
3990
|
-
case 33635 /* UNSIGNED_SHORT_5_6_5 */:
|
|
3991
|
-
case 32819 /* UNSIGNED_SHORT_4_4_4_4 */:
|
|
3992
|
-
case 32820 /* UNSIGNED_SHORT_5_5_5_1 */:
|
|
3993
|
-
return Uint16Array;
|
|
3994
|
-
case 5125 /* UNSIGNED_INT */:
|
|
3995
|
-
return Uint32Array;
|
|
3996
|
-
case 5121 /* UNSIGNED_BYTE */:
|
|
3997
|
-
return clamped ? Uint8ClampedArray : Uint8Array;
|
|
3998
|
-
case 5120 /* BYTE */:
|
|
3999
|
-
return Int8Array;
|
|
4000
|
-
case 5122 /* SHORT */:
|
|
4001
|
-
return Int16Array;
|
|
4002
|
-
case 5124 /* INT */:
|
|
4003
|
-
return Int32Array;
|
|
4004
|
-
default:
|
|
4005
|
-
throw new Error("Failed to deduce typed array type from GL constant");
|
|
4006
|
-
}
|
|
4007
|
-
}
|
|
4008
|
-
|
|
4009
|
-
// src/classic/accessor.ts
|
|
4010
|
-
var DEFAULT_ACCESSOR_VALUES = {
|
|
4011
|
-
offset: 0,
|
|
4012
|
-
stride: 0,
|
|
4013
|
-
type: 5126 /* FLOAT */,
|
|
4014
|
-
size: 1,
|
|
4015
|
-
divisor: 0,
|
|
4016
|
-
normalized: false,
|
|
4017
|
-
integer: false
|
|
4018
|
-
};
|
|
4019
|
-
var Accessor = class {
|
|
4020
|
-
offset;
|
|
4021
|
-
stride;
|
|
4022
|
-
type;
|
|
4023
|
-
size;
|
|
4024
|
-
divisor;
|
|
4025
|
-
normalized;
|
|
4026
|
-
integer;
|
|
4027
|
-
buffer;
|
|
4028
|
-
index;
|
|
4029
|
-
static getBytesPerElement(accessor) {
|
|
4030
|
-
const ArrayType = getTypedArrayFromGLType(accessor.type || 5126 /* FLOAT */);
|
|
4031
|
-
return ArrayType.BYTES_PER_ELEMENT;
|
|
4032
|
-
}
|
|
4033
|
-
static getBytesPerVertex(accessor) {
|
|
4034
|
-
const ArrayType = getTypedArrayFromGLType(accessor.type || 5126 /* FLOAT */);
|
|
4035
|
-
return ArrayType.BYTES_PER_ELEMENT * accessor.size;
|
|
4036
|
-
}
|
|
4037
|
-
// Combines (merges) a list of accessors. On top of default values
|
|
4038
|
-
// Usually [programAccessor, bufferAccessor, appAccessor]
|
|
4039
|
-
// All props will be set in the returned object.
|
|
4040
|
-
// TODO check for conflicts between values in the supplied accessors
|
|
4041
|
-
static resolve(...accessors) {
|
|
4042
|
-
return new Accessor(...[DEFAULT_ACCESSOR_VALUES, ...accessors]);
|
|
4043
|
-
}
|
|
4044
|
-
constructor(...accessors) {
|
|
4045
|
-
accessors.forEach((accessor) => this._assign(accessor));
|
|
4046
|
-
Object.freeze(this);
|
|
4047
|
-
}
|
|
4048
|
-
toString() {
|
|
4049
|
-
return JSON.stringify(this);
|
|
4050
|
-
}
|
|
4051
|
-
// ACCESSORS
|
|
4052
|
-
// TODO - remove>
|
|
4053
|
-
get BYTES_PER_ELEMENT() {
|
|
4054
|
-
return Accessor.getBytesPerElement(this);
|
|
4055
|
-
}
|
|
4056
|
-
get BYTES_PER_VERTEX() {
|
|
4057
|
-
return Accessor.getBytesPerVertex(this);
|
|
4058
|
-
}
|
|
4059
|
-
// PRIVATE
|
|
4060
|
-
// eslint-disable-next-line complexity, max-statements
|
|
4061
|
-
_assign(props = {}) {
|
|
4062
|
-
if (props.type !== void 0) {
|
|
4063
|
-
this.type = props.type;
|
|
4064
|
-
if (props.type === 5124 /* INT */ || props.type === 5125 /* UNSIGNED_INT */) {
|
|
4065
|
-
this.integer = true;
|
|
4066
|
-
}
|
|
4067
|
-
}
|
|
4068
|
-
if (props.size !== void 0) {
|
|
4069
|
-
this.size = props.size;
|
|
4070
|
-
}
|
|
4071
|
-
if (props.offset !== void 0) {
|
|
4072
|
-
this.offset = props.offset;
|
|
4073
|
-
}
|
|
4074
|
-
if (props.stride !== void 0) {
|
|
4075
|
-
this.stride = props.stride;
|
|
4076
|
-
}
|
|
4077
|
-
if (props.normalize !== void 0) {
|
|
4078
|
-
this.normalized = props.normalize;
|
|
4079
|
-
}
|
|
4080
|
-
if (props.normalized !== void 0) {
|
|
4081
|
-
this.normalized = props.normalized;
|
|
4082
|
-
}
|
|
4083
|
-
if (props.integer !== void 0) {
|
|
4084
|
-
this.integer = props.integer;
|
|
4085
|
-
}
|
|
4086
|
-
if (props.divisor !== void 0) {
|
|
4087
|
-
this.divisor = props.divisor;
|
|
4088
|
-
}
|
|
4089
|
-
if (props.buffer !== void 0) {
|
|
4090
|
-
this.buffer = props.buffer;
|
|
4091
|
-
}
|
|
4092
|
-
if (props.index !== void 0) {
|
|
4093
|
-
if (typeof props.index === "boolean") {
|
|
4094
|
-
this.index = props.index ? 1 : 0;
|
|
4095
|
-
} else {
|
|
4096
|
-
this.index = props.index;
|
|
4097
|
-
}
|
|
4098
|
-
}
|
|
4099
|
-
if (props.instanced !== void 0) {
|
|
4100
|
-
this.divisor = props.instanced ? 1 : 0;
|
|
4101
|
-
}
|
|
4102
|
-
if (props.isInstanced !== void 0) {
|
|
4103
|
-
this.divisor = props.isInstanced ? 1 : 0;
|
|
4104
|
-
}
|
|
4105
|
-
if (this.offset === void 0)
|
|
4106
|
-
delete this.offset;
|
|
4107
|
-
if (this.stride === void 0)
|
|
4108
|
-
delete this.stride;
|
|
4109
|
-
if (this.type === void 0)
|
|
4110
|
-
delete this.type;
|
|
4111
|
-
if (this.size === void 0)
|
|
4112
|
-
delete this.size;
|
|
4113
|
-
if (this.divisor === void 0)
|
|
4114
|
-
delete this.divisor;
|
|
4115
|
-
if (this.normalized === void 0)
|
|
4116
|
-
delete this.normalized;
|
|
4117
|
-
if (this.integer === void 0)
|
|
4118
|
-
delete this.integer;
|
|
4119
|
-
if (this.buffer === void 0)
|
|
4120
|
-
delete this.buffer;
|
|
4121
|
-
if (this.index === void 0)
|
|
4122
|
-
delete this.index;
|
|
4123
|
-
return this;
|
|
4124
|
-
}
|
|
4125
|
-
};
|
|
4126
|
-
|
|
4127
|
-
// src/adapter/helpers/decode-webgl-types.ts
|
|
4128
|
-
function isSamplerUniform(type) {
|
|
4129
|
-
return SAMPLER_TYPES.includes(type);
|
|
4173
|
+
// src/adapter/helpers/decode-webgl-types.ts
|
|
4174
|
+
function isSamplerUniform(type) {
|
|
4175
|
+
return SAMPLER_TYPES.includes(type);
|
|
4130
4176
|
}
|
|
4131
4177
|
var SAMPLER_TYPES = [
|
|
4132
4178
|
35678 /* SAMPLER_2D */,
|
|
@@ -4289,8 +4335,7 @@ ${source2}`;
|
|
|
4289
4335
|
}
|
|
4290
4336
|
const { name, type: compositeType, size } = activeInfo;
|
|
4291
4337
|
const { glType, components } = decodeGLUniformType(compositeType);
|
|
4292
|
-
const
|
|
4293
|
-
const varying = { location, name, accessor };
|
|
4338
|
+
const varying = { location, name, type: glType, size: size * components };
|
|
4294
4339
|
varyings.push(varying);
|
|
4295
4340
|
}
|
|
4296
4341
|
varyings.sort((a, b) => a.location - b.location);
|
|
@@ -4503,13 +4548,16 @@ ${source2}`;
|
|
|
4503
4548
|
|
|
4504
4549
|
// ../../node_modules/@math.gl/types/dist/is-array.js
|
|
4505
4550
|
function isTypedArray(value) {
|
|
4506
|
-
return ArrayBuffer.isView(value) && !(value instanceof DataView)
|
|
4551
|
+
return ArrayBuffer.isView(value) && !(value instanceof DataView);
|
|
4507
4552
|
}
|
|
4508
|
-
function
|
|
4553
|
+
function isNumberArray(value) {
|
|
4509
4554
|
if (Array.isArray(value)) {
|
|
4510
|
-
return value.length === 0 || typeof value[0] === "number"
|
|
4555
|
+
return value.length === 0 || typeof value[0] === "number";
|
|
4511
4556
|
}
|
|
4512
|
-
return
|
|
4557
|
+
return false;
|
|
4558
|
+
}
|
|
4559
|
+
function isNumericArray(value) {
|
|
4560
|
+
return isTypedArray(value) || isNumberArray(value);
|
|
4513
4561
|
}
|
|
4514
4562
|
|
|
4515
4563
|
// src/utils/split-uniforms-and-bindings.ts
|
|
@@ -4565,7 +4613,7 @@ ${source2}`;
|
|
|
4565
4613
|
|
|
4566
4614
|
// src/adapter/resources/webgl-render-pipeline.ts
|
|
4567
4615
|
var LOG_PROGRAM_PERF_PRIORITY = 4;
|
|
4568
|
-
var WEBGLRenderPipeline = class extends
|
|
4616
|
+
var WEBGLRenderPipeline = class extends import_core16.RenderPipeline {
|
|
4569
4617
|
/** The WebGL device that created this render pipeline */
|
|
4570
4618
|
device;
|
|
4571
4619
|
/** Handle to underlying WebGL program */
|
|
@@ -4598,9 +4646,9 @@ ${source2}`;
|
|
|
4598
4646
|
this.device.gl.transformFeedbackVaryings(this.handle, varyings, bufferMode);
|
|
4599
4647
|
}
|
|
4600
4648
|
this._linkShaders();
|
|
4601
|
-
|
|
4649
|
+
import_core16.log.time(1, `RenderPipeline ${this.id} - shaderLayout introspection`)();
|
|
4602
4650
|
this.introspectedLayout = getShaderLayout(this.device.gl, this.handle);
|
|
4603
|
-
|
|
4651
|
+
import_core16.log.timeEnd(1, `RenderPipeline ${this.id} - shaderLayout introspection`)();
|
|
4604
4652
|
this.shaderLayout = mergeShaderLayout(this.introspectedLayout, props.shaderLayout);
|
|
4605
4653
|
}
|
|
4606
4654
|
destroy() {
|
|
@@ -4619,7 +4667,7 @@ ${source2}`;
|
|
|
4619
4667
|
if (!binding) {
|
|
4620
4668
|
const validBindings = this.shaderLayout.bindings.map((binding2) => `"${binding2.name}"`).join(", ");
|
|
4621
4669
|
if (!options?.disableWarnings) {
|
|
4622
|
-
|
|
4670
|
+
import_core16.log.warn(
|
|
4623
4671
|
`No binding "${name}" in render pipeline "${this.id}", expected one of ${validBindings}`,
|
|
4624
4672
|
value
|
|
4625
4673
|
)();
|
|
@@ -4627,7 +4675,7 @@ ${source2}`;
|
|
|
4627
4675
|
continue;
|
|
4628
4676
|
}
|
|
4629
4677
|
if (!value) {
|
|
4630
|
-
|
|
4678
|
+
import_core16.log.warn(`Unsetting binding "${name}" in render pipeline "${this.id}"`)();
|
|
4631
4679
|
}
|
|
4632
4680
|
switch (binding.type) {
|
|
4633
4681
|
case "uniform":
|
|
@@ -4641,7 +4689,7 @@ ${source2}`;
|
|
|
4641
4689
|
}
|
|
4642
4690
|
break;
|
|
4643
4691
|
case "sampler":
|
|
4644
|
-
|
|
4692
|
+
import_core16.log.warn(`Ignoring sampler ${name}`)();
|
|
4645
4693
|
break;
|
|
4646
4694
|
default:
|
|
4647
4695
|
throw new Error(binding.type);
|
|
@@ -4673,11 +4721,11 @@ ${source2}`;
|
|
|
4673
4721
|
const isIndexed = Boolean(vertexArray.indexBuffer);
|
|
4674
4722
|
const glIndexType = vertexArray.indexBuffer?.glIndexType;
|
|
4675
4723
|
if (this.linkStatus !== "success") {
|
|
4676
|
-
|
|
4724
|
+
import_core16.log.info(2, `RenderPipeline:${this.id}.draw() aborted - waiting for shader linking`)();
|
|
4677
4725
|
return false;
|
|
4678
4726
|
}
|
|
4679
4727
|
if (!this._areTexturesRenderable()) {
|
|
4680
|
-
|
|
4728
|
+
import_core16.log.info(2, `RenderPipeline:${this.id}.draw() aborted - textures not yet loaded`)();
|
|
4681
4729
|
return false;
|
|
4682
4730
|
}
|
|
4683
4731
|
this.device.gl.useProgram(this.handle);
|
|
@@ -4721,7 +4769,7 @@ ${source2}`;
|
|
|
4721
4769
|
setUniformsWebGL(uniforms) {
|
|
4722
4770
|
const { bindings } = splitUniformsAndBindings(uniforms);
|
|
4723
4771
|
Object.keys(bindings).forEach((name) => {
|
|
4724
|
-
|
|
4772
|
+
import_core16.log.warn(
|
|
4725
4773
|
`Unsupported value "${JSON.stringify(
|
|
4726
4774
|
bindings[name]
|
|
4727
4775
|
)}" used in setUniforms() for key ${name}. Use setBindings() instead?`
|
|
@@ -4736,19 +4784,19 @@ ${source2}`;
|
|
|
4736
4784
|
const { gl } = this.device;
|
|
4737
4785
|
gl.attachShader(this.handle, this.vs.handle);
|
|
4738
4786
|
gl.attachShader(this.handle, this.fs.handle);
|
|
4739
|
-
|
|
4787
|
+
import_core16.log.time(LOG_PROGRAM_PERF_PRIORITY, `linkProgram for ${this.id}`)();
|
|
4740
4788
|
gl.linkProgram(this.handle);
|
|
4741
|
-
|
|
4742
|
-
if (
|
|
4789
|
+
import_core16.log.timeEnd(LOG_PROGRAM_PERF_PRIORITY, `linkProgram for ${this.id}`)();
|
|
4790
|
+
if (import_core16.log.level === 0) {
|
|
4743
4791
|
}
|
|
4744
4792
|
if (!this.device.features.has("compilation-status-async-webgl")) {
|
|
4745
4793
|
const status2 = this._getLinkStatus();
|
|
4746
4794
|
this._reportLinkStatus(status2);
|
|
4747
4795
|
return;
|
|
4748
4796
|
}
|
|
4749
|
-
|
|
4797
|
+
import_core16.log.once(1, "RenderPipeline linking is asynchronous")();
|
|
4750
4798
|
await this._waitForLinkComplete();
|
|
4751
|
-
|
|
4799
|
+
import_core16.log.info(2, `RenderPipeline ${this.id} - async linking complete: ${this.linkStatus}`)();
|
|
4752
4800
|
const status = this._getLinkStatus();
|
|
4753
4801
|
this._reportLinkStatus(status);
|
|
4754
4802
|
}
|
|
@@ -4816,7 +4864,7 @@ ${source2}`;
|
|
|
4816
4864
|
let texturesRenderable = true;
|
|
4817
4865
|
for (const bindingInfo of this.shaderLayout.bindings) {
|
|
4818
4866
|
if (!this.bindings[bindingInfo.name] && !this.bindings[bindingInfo.name.replace(/Uniforms$/, "")]) {
|
|
4819
|
-
|
|
4867
|
+
import_core16.log.warn(`Binding ${bindingInfo.name} not found in ${this.id}`)();
|
|
4820
4868
|
texturesRenderable = false;
|
|
4821
4869
|
}
|
|
4822
4870
|
}
|
|
@@ -4875,7 +4923,7 @@ ${source2}`;
|
|
|
4875
4923
|
} else if (value instanceof WEBGLTexture) {
|
|
4876
4924
|
texture = value;
|
|
4877
4925
|
} else if (value instanceof WEBGLFramebuffer && value.colorAttachments[0] instanceof WEBGLTextureView) {
|
|
4878
|
-
|
|
4926
|
+
import_core16.log.warn(
|
|
4879
4927
|
"Passing framebuffer in texture binding may be deprecated. Use fbo.colorAttachments[0] instead"
|
|
4880
4928
|
)();
|
|
4881
4929
|
texture = value.colorAttachments[0].texture;
|
|
@@ -4916,7 +4964,7 @@ ${source2}`;
|
|
|
4916
4964
|
for (const attribute of overrideLayout?.attributes || []) {
|
|
4917
4965
|
const baseAttribute = mergedLayout.attributes.find((attr) => attr.name === attribute.name);
|
|
4918
4966
|
if (!baseAttribute) {
|
|
4919
|
-
|
|
4967
|
+
import_core16.log.warn(`shader layout attribute ${attribute.name} not present in shader`);
|
|
4920
4968
|
} else {
|
|
4921
4969
|
baseAttribute.type = attribute.type || baseAttribute.type;
|
|
4922
4970
|
baseAttribute.stepMode = attribute.stepMode || baseAttribute.stepMode;
|
|
@@ -4926,11 +4974,11 @@ ${source2}`;
|
|
|
4926
4974
|
}
|
|
4927
4975
|
|
|
4928
4976
|
// src/adapter/resources/webgl-command-encoder.ts
|
|
4929
|
-
var
|
|
4977
|
+
var import_core18 = __toESM(require_core(), 1);
|
|
4930
4978
|
|
|
4931
4979
|
// src/adapter/resources/webgl-command-buffer.ts
|
|
4932
|
-
var
|
|
4933
|
-
var WEBGLCommandBuffer = class extends
|
|
4980
|
+
var import_core17 = __toESM(require_core(), 1);
|
|
4981
|
+
var WEBGLCommandBuffer = class extends import_core17.CommandBuffer {
|
|
4934
4982
|
device;
|
|
4935
4983
|
commands = [];
|
|
4936
4984
|
constructor(device) {
|
|
@@ -5011,7 +5059,7 @@ ${source2}`;
|
|
|
5011
5059
|
if (mipLevel !== 0 || depthOrArrayLayers !== 0 || bytesPerRow || rowsPerImage) {
|
|
5012
5060
|
throw new Error("not implemented");
|
|
5013
5061
|
}
|
|
5014
|
-
const { framebuffer, destroyFramebuffer } =
|
|
5062
|
+
const { framebuffer, destroyFramebuffer } = getFramebuffer2(source);
|
|
5015
5063
|
let prevHandle;
|
|
5016
5064
|
try {
|
|
5017
5065
|
const webglBuffer = destination;
|
|
@@ -5069,7 +5117,7 @@ ${source2}`;
|
|
|
5069
5117
|
height = options.destination.height
|
|
5070
5118
|
// depthOrArrayLayers = 0
|
|
5071
5119
|
} = options;
|
|
5072
|
-
const { framebuffer, destroyFramebuffer } =
|
|
5120
|
+
const { framebuffer, destroyFramebuffer } = getFramebuffer2(source);
|
|
5073
5121
|
const [sourceX, sourceY] = origin;
|
|
5074
5122
|
const [destinationX, destinationY, destinationZ] = destinationOrigin;
|
|
5075
5123
|
const prevHandle = device.gl.bindFramebuffer(
|
|
@@ -5125,8 +5173,8 @@ ${source2}`;
|
|
|
5125
5173
|
framebuffer.destroy();
|
|
5126
5174
|
}
|
|
5127
5175
|
}
|
|
5128
|
-
function
|
|
5129
|
-
if (source instanceof
|
|
5176
|
+
function getFramebuffer2(source) {
|
|
5177
|
+
if (source instanceof import_core17.Texture) {
|
|
5130
5178
|
const { width, height, id } = source;
|
|
5131
5179
|
const framebuffer = source.device.createFramebuffer({
|
|
5132
5180
|
id: `framebuffer-for-${id}`,
|
|
@@ -5140,7 +5188,7 @@ ${source2}`;
|
|
|
5140
5188
|
}
|
|
5141
5189
|
|
|
5142
5190
|
// src/adapter/resources/webgl-command-encoder.ts
|
|
5143
|
-
var WEBGLCommandEncoder = class extends
|
|
5191
|
+
var WEBGLCommandEncoder = class extends import_core18.CommandEncoder {
|
|
5144
5192
|
device;
|
|
5145
5193
|
commandBuffer;
|
|
5146
5194
|
constructor(device, props) {
|
|
@@ -5179,7 +5227,7 @@ ${source2}`;
|
|
|
5179
5227
|
};
|
|
5180
5228
|
|
|
5181
5229
|
// src/adapter/resources/webgl-vertex-array.ts
|
|
5182
|
-
var
|
|
5230
|
+
var import_core19 = __toESM(require_core(), 1);
|
|
5183
5231
|
|
|
5184
5232
|
// src/utils/fill-array.ts
|
|
5185
5233
|
function fillArray(options) {
|
|
@@ -5203,7 +5251,7 @@ ${source2}`;
|
|
|
5203
5251
|
}
|
|
5204
5252
|
|
|
5205
5253
|
// src/adapter/resources/webgl-vertex-array.ts
|
|
5206
|
-
var WEBGLVertexArray = class extends
|
|
5254
|
+
var WEBGLVertexArray = class extends import_core19.VertexArray {
|
|
5207
5255
|
get [Symbol.toStringTag]() {
|
|
5208
5256
|
return "VertexArray";
|
|
5209
5257
|
}
|
|
@@ -5371,7 +5419,7 @@ ${source2}`;
|
|
|
5371
5419
|
this.buffer = this.buffer || this.device.createBuffer({ byteLength });
|
|
5372
5420
|
updateNeeded = updateNeeded || !compareConstantArrayValues(constantValue, this.bufferValue);
|
|
5373
5421
|
if (updateNeeded) {
|
|
5374
|
-
const typedArray = (0,
|
|
5422
|
+
const typedArray = (0, import_core19.getScratchArray)(value.constructor, length);
|
|
5375
5423
|
fillArray({ target: typedArray, source: constantValue, start: 0, count: length });
|
|
5376
5424
|
this.buffer.write(typedArray);
|
|
5377
5425
|
this.bufferValue = value;
|
|
@@ -5398,8 +5446,8 @@ ${source2}`;
|
|
|
5398
5446
|
}
|
|
5399
5447
|
|
|
5400
5448
|
// src/adapter/resources/webgl-transform-feedback.ts
|
|
5401
|
-
var
|
|
5402
|
-
var WEBGLTransformFeedback = class extends
|
|
5449
|
+
var import_core20 = __toESM(require_core(), 1);
|
|
5450
|
+
var WEBGLTransformFeedback = class extends import_core20.TransformFeedback {
|
|
5403
5451
|
device;
|
|
5404
5452
|
gl;
|
|
5405
5453
|
handle;
|
|
@@ -5462,7 +5510,7 @@ ${source2}`;
|
|
|
5462
5510
|
const { buffer, byteLength, byteOffset } = this._getBufferRange(bufferOrRange);
|
|
5463
5511
|
if (location < 0) {
|
|
5464
5512
|
this.unusedBuffers[locationOrName] = buffer;
|
|
5465
|
-
|
|
5513
|
+
import_core20.log.warn(`${this.id} unusedBuffers varying buffer ${locationOrName}`)();
|
|
5466
5514
|
return;
|
|
5467
5515
|
}
|
|
5468
5516
|
this.buffers[location] = { buffer, byteLength, byteOffset };
|
|
@@ -5549,8 +5597,8 @@ ${source2}`;
|
|
|
5549
5597
|
}
|
|
5550
5598
|
|
|
5551
5599
|
// src/adapter/resources/webgl-query-set.ts
|
|
5552
|
-
var
|
|
5553
|
-
var WEBGLQuerySet = class extends
|
|
5600
|
+
var import_core21 = __toESM(require_core(), 1);
|
|
5601
|
+
var WEBGLQuerySet = class extends import_core21.QuerySet {
|
|
5554
5602
|
device;
|
|
5555
5603
|
handle;
|
|
5556
5604
|
target = null;
|
|
@@ -5682,147 +5730,13 @@ ${source2}`;
|
|
|
5682
5730
|
}
|
|
5683
5731
|
};
|
|
5684
5732
|
|
|
5685
|
-
// src/
|
|
5686
|
-
var
|
|
5687
|
-
|
|
5688
|
-
// src/classic/format-utils.ts
|
|
5689
|
-
function glFormatToComponents(format) {
|
|
5690
|
-
switch (format) {
|
|
5691
|
-
case 6406 /* ALPHA */:
|
|
5692
|
-
case 33326 /* R32F */:
|
|
5693
|
-
case 6403 /* RED */:
|
|
5694
|
-
return 1;
|
|
5695
|
-
case 33328 /* RG32F */:
|
|
5696
|
-
case 33319 /* RG */:
|
|
5697
|
-
return 2;
|
|
5698
|
-
case 6407 /* RGB */:
|
|
5699
|
-
case 34837 /* RGB32F */:
|
|
5700
|
-
return 3;
|
|
5701
|
-
case 6408 /* RGBA */:
|
|
5702
|
-
case 34836 /* RGBA32F */:
|
|
5703
|
-
return 4;
|
|
5704
|
-
default:
|
|
5705
|
-
return 0;
|
|
5706
|
-
}
|
|
5707
|
-
}
|
|
5708
|
-
function glTypeToBytes(type) {
|
|
5709
|
-
switch (type) {
|
|
5710
|
-
case 5121 /* UNSIGNED_BYTE */:
|
|
5711
|
-
return 1;
|
|
5712
|
-
case 33635 /* UNSIGNED_SHORT_5_6_5 */:
|
|
5713
|
-
case 32819 /* UNSIGNED_SHORT_4_4_4_4 */:
|
|
5714
|
-
case 32820 /* UNSIGNED_SHORT_5_5_5_1 */:
|
|
5715
|
-
return 2;
|
|
5716
|
-
case 5126 /* FLOAT */:
|
|
5717
|
-
return 4;
|
|
5718
|
-
default:
|
|
5719
|
-
return 0;
|
|
5720
|
-
}
|
|
5721
|
-
}
|
|
5722
|
-
|
|
5723
|
-
// src/classic/copy-and-blit.ts
|
|
5724
|
-
function readPixelsToArray(source, options) {
|
|
5725
|
-
const {
|
|
5726
|
-
sourceX = 0,
|
|
5727
|
-
sourceY = 0,
|
|
5728
|
-
sourceAttachment = 36064 /* COLOR_ATTACHMENT0 */
|
|
5729
|
-
// TODO - support gl.readBuffer
|
|
5730
|
-
} = options || {};
|
|
5731
|
-
let {
|
|
5732
|
-
target = null,
|
|
5733
|
-
// following parameters are auto deduced if not provided
|
|
5734
|
-
sourceWidth,
|
|
5735
|
-
sourceHeight,
|
|
5736
|
-
sourceDepth,
|
|
5737
|
-
sourceFormat,
|
|
5738
|
-
sourceType
|
|
5739
|
-
} = options || {};
|
|
5740
|
-
const { framebuffer, deleteFramebuffer } = getFramebuffer2(source);
|
|
5741
|
-
const { gl, handle } = framebuffer;
|
|
5742
|
-
const attachment = sourceAttachment - 36064 /* COLOR_ATTACHMENT0 */;
|
|
5743
|
-
sourceWidth ||= framebuffer.width;
|
|
5744
|
-
sourceHeight ||= framebuffer.height;
|
|
5745
|
-
sourceDepth = framebuffer.colorAttachments[attachment]?.texture?.depth || 1;
|
|
5746
|
-
sourceFormat ||= framebuffer.colorAttachments[attachment]?.texture?.glFormat || 6408 /* RGBA */;
|
|
5747
|
-
sourceType ||= framebuffer.colorAttachments[attachment]?.texture?.glType || 5121 /* UNSIGNED_BYTE */;
|
|
5748
|
-
target = getPixelArray(target, sourceType, sourceFormat, sourceWidth, sourceHeight, sourceDepth);
|
|
5749
|
-
sourceType = sourceType || getGLTypeFromTypedArray(target);
|
|
5750
|
-
const prevHandle = gl.bindFramebuffer(36160 /* FRAMEBUFFER */, handle);
|
|
5751
|
-
gl.readPixels(sourceX, sourceY, sourceWidth, sourceHeight, sourceFormat, sourceType, target);
|
|
5752
|
-
gl.bindFramebuffer(36160 /* FRAMEBUFFER */, prevHandle || null);
|
|
5753
|
-
if (deleteFramebuffer) {
|
|
5754
|
-
framebuffer.destroy();
|
|
5755
|
-
}
|
|
5756
|
-
return target;
|
|
5757
|
-
}
|
|
5758
|
-
function readPixelsToBuffer(source, options) {
|
|
5759
|
-
const {
|
|
5760
|
-
target,
|
|
5761
|
-
sourceX = 0,
|
|
5762
|
-
sourceY = 0,
|
|
5763
|
-
sourceFormat = 6408 /* RGBA */,
|
|
5764
|
-
targetByteOffset = 0
|
|
5765
|
-
} = options || {};
|
|
5766
|
-
let { sourceWidth, sourceHeight, sourceType } = options || {};
|
|
5767
|
-
const { framebuffer, deleteFramebuffer } = getFramebuffer2(source);
|
|
5768
|
-
sourceWidth = sourceWidth || framebuffer.width;
|
|
5769
|
-
sourceHeight = sourceHeight || framebuffer.height;
|
|
5770
|
-
const webglFramebuffer = framebuffer;
|
|
5771
|
-
sourceType = sourceType || 5121 /* UNSIGNED_BYTE */;
|
|
5772
|
-
let webglBufferTarget = target;
|
|
5773
|
-
if (!webglBufferTarget) {
|
|
5774
|
-
const components = glFormatToComponents(sourceFormat);
|
|
5775
|
-
const byteCount = glTypeToBytes(sourceType);
|
|
5776
|
-
const byteLength = targetByteOffset + sourceWidth * sourceHeight * components * byteCount;
|
|
5777
|
-
webglBufferTarget = webglFramebuffer.device.createBuffer({ byteLength });
|
|
5778
|
-
}
|
|
5779
|
-
const commandEncoder = source.device.createCommandEncoder();
|
|
5780
|
-
commandEncoder.copyTextureToBuffer({
|
|
5781
|
-
source,
|
|
5782
|
-
width: sourceWidth,
|
|
5783
|
-
height: sourceHeight,
|
|
5784
|
-
origin: [sourceX, sourceY],
|
|
5785
|
-
destination: webglBufferTarget,
|
|
5786
|
-
byteOffset: targetByteOffset
|
|
5787
|
-
});
|
|
5788
|
-
commandEncoder.destroy();
|
|
5789
|
-
if (deleteFramebuffer) {
|
|
5790
|
-
framebuffer.destroy();
|
|
5791
|
-
}
|
|
5792
|
-
return webglBufferTarget;
|
|
5793
|
-
}
|
|
5794
|
-
function getFramebuffer2(source) {
|
|
5795
|
-
if (!(source instanceof import_core21.Framebuffer)) {
|
|
5796
|
-
return { framebuffer: toFramebuffer(source), deleteFramebuffer: true };
|
|
5797
|
-
}
|
|
5798
|
-
return { framebuffer: source, deleteFramebuffer: false };
|
|
5799
|
-
}
|
|
5800
|
-
function toFramebuffer(texture, props) {
|
|
5801
|
-
const { device, width, height, id } = texture;
|
|
5802
|
-
const framebuffer = device.createFramebuffer({
|
|
5803
|
-
...props,
|
|
5804
|
-
id: `framebuffer-for-${id}`,
|
|
5805
|
-
width,
|
|
5806
|
-
height,
|
|
5807
|
-
colorAttachments: [texture]
|
|
5808
|
-
});
|
|
5809
|
-
return framebuffer;
|
|
5810
|
-
}
|
|
5811
|
-
function getPixelArray(pixelArray, type, format, width, height, depth) {
|
|
5812
|
-
if (pixelArray) {
|
|
5813
|
-
return pixelArray;
|
|
5814
|
-
}
|
|
5815
|
-
type = type || 5121 /* UNSIGNED_BYTE */;
|
|
5816
|
-
const ArrayType = getTypedArrayFromGLType(type, { clamped: false });
|
|
5817
|
-
const components = glFormatToComponents(format);
|
|
5818
|
-
return new ArrayType(width * height * components);
|
|
5819
|
-
}
|
|
5820
|
-
|
|
5821
|
-
// src/classic/clear.ts
|
|
5733
|
+
// src/deprecated/clear.ts
|
|
5734
|
+
var import_core22 = __toESM(require_core(), 1);
|
|
5822
5735
|
var GL_DEPTH_BUFFER_BIT2 = 256;
|
|
5823
5736
|
var GL_STENCIL_BUFFER_BIT2 = 1024;
|
|
5824
5737
|
var GL_COLOR_BUFFER_BIT2 = 16384;
|
|
5825
5738
|
function clear(device, options) {
|
|
5739
|
+
import_core22.log.warn("clear will be removed in next minor release");
|
|
5826
5740
|
const { framebuffer = null, color = null, depth = null, stencil = null } = options || {};
|
|
5827
5741
|
const parameters = {};
|
|
5828
5742
|
if (framebuffer) {
|
|
@@ -5854,7 +5768,7 @@ ${source2}`;
|
|
|
5854
5768
|
}
|
|
5855
5769
|
|
|
5856
5770
|
// src/adapter/webgl-device.ts
|
|
5857
|
-
var WebGLDevice = class extends
|
|
5771
|
+
var WebGLDevice = class extends import_core23.Device {
|
|
5858
5772
|
//
|
|
5859
5773
|
// Public `Device` API
|
|
5860
5774
|
//
|
|
@@ -5914,14 +5828,14 @@ ${source2}`;
|
|
|
5914
5828
|
}
|
|
5915
5829
|
this.canvasContext.resize();
|
|
5916
5830
|
const glState = new WebGLStateTracker(this.gl, {
|
|
5917
|
-
log: (...args) =>
|
|
5831
|
+
log: (...args) => import_core23.log.log(1, ...args)()
|
|
5918
5832
|
});
|
|
5919
5833
|
glState.trackState(this.gl, { copyState: false });
|
|
5920
5834
|
if (props.debug) {
|
|
5921
5835
|
this.gl = makeDebugContext(this.gl, { ...props, throwOnError: true });
|
|
5922
5836
|
this.debug = true;
|
|
5923
|
-
|
|
5924
|
-
|
|
5837
|
+
import_core23.log.level = Math.max(import_core23.log.level, 1);
|
|
5838
|
+
import_core23.log.warn("WebGL debug mode activated. Performance reduced.")();
|
|
5925
5839
|
}
|
|
5926
5840
|
}
|
|
5927
5841
|
/**
|
|
@@ -6024,7 +5938,7 @@ ${source2}`;
|
|
|
6024
5938
|
clear(this, options);
|
|
6025
5939
|
}
|
|
6026
5940
|
resetWebGL() {
|
|
6027
|
-
|
|
5941
|
+
import_core23.log.warn("WebGLDevice.resetWebGL is deprecated, use only for debugging")();
|
|
6028
5942
|
resetGLParameters(this.gl);
|
|
6029
5943
|
}
|
|
6030
5944
|
//
|
|
@@ -6093,7 +6007,7 @@ ${source2}`;
|
|
|
6093
6007
|
this._constants = this._constants || new Array(maxVertexAttributes).fill(null);
|
|
6094
6008
|
const currentConstant = this._constants[location];
|
|
6095
6009
|
if (currentConstant && compareConstantArrayValues2(currentConstant, constant)) {
|
|
6096
|
-
|
|
6010
|
+
import_core23.log.info(
|
|
6097
6011
|
1,
|
|
6098
6012
|
`setConstantAttributeWebGL(${location}) could have been skipped, value unchanged`
|
|
6099
6013
|
)();
|
|
@@ -6260,12 +6174,12 @@ ${source2}`;
|
|
|
6260
6174
|
|
|
6261
6175
|
// src/adapter/webgl-adapter.ts
|
|
6262
6176
|
var LOG_LEVEL2 = 1;
|
|
6263
|
-
var WebGLAdapter = class extends
|
|
6177
|
+
var WebGLAdapter = class extends import_core24.Adapter {
|
|
6264
6178
|
/** type of device's created by this adapter */
|
|
6265
6179
|
type = "webgl";
|
|
6266
6180
|
constructor() {
|
|
6267
6181
|
super();
|
|
6268
|
-
|
|
6182
|
+
import_core24.Device.defaultProps = { ...import_core24.Device.defaultProps, ...DEFAULT_SPECTOR_PROPS };
|
|
6269
6183
|
WebGLDevice.adapter = this;
|
|
6270
6184
|
}
|
|
6271
6185
|
/** Check if WebGL 2 is available */
|
|
@@ -6286,7 +6200,7 @@ ${source2}`;
|
|
|
6286
6200
|
if (gl instanceof WebGLDevice) {
|
|
6287
6201
|
return gl;
|
|
6288
6202
|
}
|
|
6289
|
-
if (gl?.device instanceof
|
|
6203
|
+
if (gl?.device instanceof import_core24.Device) {
|
|
6290
6204
|
return gl.device;
|
|
6291
6205
|
}
|
|
6292
6206
|
if (!isWebGL(gl)) {
|
|
@@ -6295,7 +6209,7 @@ ${source2}`;
|
|
|
6295
6209
|
return new WebGLDevice({ gl });
|
|
6296
6210
|
}
|
|
6297
6211
|
async create(props = {}) {
|
|
6298
|
-
|
|
6212
|
+
import_core24.log.groupCollapsed(LOG_LEVEL2, "WebGLDevice created")();
|
|
6299
6213
|
const promises = [];
|
|
6300
6214
|
if (props.debug) {
|
|
6301
6215
|
promises.push(loadWebGLDeveloperTools());
|
|
@@ -6304,20 +6218,20 @@ ${source2}`;
|
|
|
6304
6218
|
promises.push(loadSpectorJS(props));
|
|
6305
6219
|
}
|
|
6306
6220
|
if (typeof props.canvas === "string") {
|
|
6307
|
-
promises.push(
|
|
6221
|
+
promises.push(import_core24.CanvasContext.pageLoaded);
|
|
6308
6222
|
}
|
|
6309
6223
|
const results = await Promise.allSettled(promises);
|
|
6310
6224
|
for (const result of results) {
|
|
6311
6225
|
if (result.status === "rejected") {
|
|
6312
|
-
|
|
6226
|
+
import_core24.log.error(`Failed to initialize debug libraries ${result.reason}`)();
|
|
6313
6227
|
}
|
|
6314
6228
|
}
|
|
6315
|
-
|
|
6229
|
+
import_core24.log.probe(LOG_LEVEL2 + 1, "DOM is loaded")();
|
|
6316
6230
|
const device = new WebGLDevice(props);
|
|
6317
6231
|
const message2 = `Created ${device.type}${device.debug ? " debug" : ""} context: ${device.info.vendor}, ${device.info.renderer} for canvas: ${device.canvasContext.id}`;
|
|
6318
|
-
|
|
6319
|
-
|
|
6320
|
-
|
|
6232
|
+
import_core24.log.probe(LOG_LEVEL2, message2)();
|
|
6233
|
+
import_core24.log.table(LOG_LEVEL2, device.info)();
|
|
6234
|
+
import_core24.log.groupEnd(LOG_LEVEL2)();
|
|
6321
6235
|
return device;
|
|
6322
6236
|
}
|
|
6323
6237
|
};
|
|
@@ -6328,6 +6242,150 @@ ${source2}`;
|
|
|
6328
6242
|
return Boolean(gl && Number.isFinite(gl._version));
|
|
6329
6243
|
}
|
|
6330
6244
|
var webgl2Adapter = new WebGLAdapter();
|
|
6245
|
+
|
|
6246
|
+
// src/deprecated/accessor.ts
|
|
6247
|
+
var import_core25 = __toESM(require_core(), 1);
|
|
6248
|
+
var DEFAULT_ACCESSOR_VALUES = {
|
|
6249
|
+
offset: 0,
|
|
6250
|
+
stride: 0,
|
|
6251
|
+
type: 5126 /* FLOAT */,
|
|
6252
|
+
size: 1,
|
|
6253
|
+
divisor: 0,
|
|
6254
|
+
normalized: false,
|
|
6255
|
+
integer: false
|
|
6256
|
+
};
|
|
6257
|
+
var Accessor = class {
|
|
6258
|
+
offset;
|
|
6259
|
+
stride;
|
|
6260
|
+
type;
|
|
6261
|
+
size;
|
|
6262
|
+
divisor;
|
|
6263
|
+
normalized;
|
|
6264
|
+
integer;
|
|
6265
|
+
buffer;
|
|
6266
|
+
index;
|
|
6267
|
+
static getBytesPerElement(accessor) {
|
|
6268
|
+
const ArrayType = getTypedArrayFromGLType2(accessor.type || 5126 /* FLOAT */);
|
|
6269
|
+
return ArrayType.BYTES_PER_ELEMENT;
|
|
6270
|
+
}
|
|
6271
|
+
static getBytesPerVertex(accessor) {
|
|
6272
|
+
const ArrayType = getTypedArrayFromGLType2(accessor.type || 5126 /* FLOAT */);
|
|
6273
|
+
return ArrayType.BYTES_PER_ELEMENT * accessor.size;
|
|
6274
|
+
}
|
|
6275
|
+
// Combines (merges) a list of accessors. On top of default values
|
|
6276
|
+
// Usually [programAccessor, bufferAccessor, appAccessor]
|
|
6277
|
+
// All props will be set in the returned object.
|
|
6278
|
+
// TODO check for conflicts between values in the supplied accessors
|
|
6279
|
+
static resolve(...accessors) {
|
|
6280
|
+
return new Accessor(...[DEFAULT_ACCESSOR_VALUES, ...accessors]);
|
|
6281
|
+
}
|
|
6282
|
+
constructor(...accessors) {
|
|
6283
|
+
import_core25.log.warn("Accessor will be removed in next minor release");
|
|
6284
|
+
accessors.forEach((accessor) => this._assign(accessor));
|
|
6285
|
+
Object.freeze(this);
|
|
6286
|
+
}
|
|
6287
|
+
toString() {
|
|
6288
|
+
return JSON.stringify(this);
|
|
6289
|
+
}
|
|
6290
|
+
// ACCESSORS
|
|
6291
|
+
// TODO - remove>
|
|
6292
|
+
get BYTES_PER_ELEMENT() {
|
|
6293
|
+
return Accessor.getBytesPerElement(this);
|
|
6294
|
+
}
|
|
6295
|
+
get BYTES_PER_VERTEX() {
|
|
6296
|
+
return Accessor.getBytesPerVertex(this);
|
|
6297
|
+
}
|
|
6298
|
+
// PRIVATE
|
|
6299
|
+
// eslint-disable-next-line complexity, max-statements
|
|
6300
|
+
_assign(props = {}) {
|
|
6301
|
+
if (props.type !== void 0) {
|
|
6302
|
+
this.type = props.type;
|
|
6303
|
+
if (props.type === 5124 /* INT */ || props.type === 5125 /* UNSIGNED_INT */) {
|
|
6304
|
+
this.integer = true;
|
|
6305
|
+
}
|
|
6306
|
+
}
|
|
6307
|
+
if (props.size !== void 0) {
|
|
6308
|
+
this.size = props.size;
|
|
6309
|
+
}
|
|
6310
|
+
if (props.offset !== void 0) {
|
|
6311
|
+
this.offset = props.offset;
|
|
6312
|
+
}
|
|
6313
|
+
if (props.stride !== void 0) {
|
|
6314
|
+
this.stride = props.stride;
|
|
6315
|
+
}
|
|
6316
|
+
if (props.normalize !== void 0) {
|
|
6317
|
+
this.normalized = props.normalize;
|
|
6318
|
+
}
|
|
6319
|
+
if (props.normalized !== void 0) {
|
|
6320
|
+
this.normalized = props.normalized;
|
|
6321
|
+
}
|
|
6322
|
+
if (props.integer !== void 0) {
|
|
6323
|
+
this.integer = props.integer;
|
|
6324
|
+
}
|
|
6325
|
+
if (props.divisor !== void 0) {
|
|
6326
|
+
this.divisor = props.divisor;
|
|
6327
|
+
}
|
|
6328
|
+
if (props.buffer !== void 0) {
|
|
6329
|
+
this.buffer = props.buffer;
|
|
6330
|
+
}
|
|
6331
|
+
if (props.index !== void 0) {
|
|
6332
|
+
if (typeof props.index === "boolean") {
|
|
6333
|
+
this.index = props.index ? 1 : 0;
|
|
6334
|
+
} else {
|
|
6335
|
+
this.index = props.index;
|
|
6336
|
+
}
|
|
6337
|
+
}
|
|
6338
|
+
if (props.instanced !== void 0) {
|
|
6339
|
+
this.divisor = props.instanced ? 1 : 0;
|
|
6340
|
+
}
|
|
6341
|
+
if (props.isInstanced !== void 0) {
|
|
6342
|
+
this.divisor = props.isInstanced ? 1 : 0;
|
|
6343
|
+
}
|
|
6344
|
+
if (this.offset === void 0)
|
|
6345
|
+
delete this.offset;
|
|
6346
|
+
if (this.stride === void 0)
|
|
6347
|
+
delete this.stride;
|
|
6348
|
+
if (this.type === void 0)
|
|
6349
|
+
delete this.type;
|
|
6350
|
+
if (this.size === void 0)
|
|
6351
|
+
delete this.size;
|
|
6352
|
+
if (this.divisor === void 0)
|
|
6353
|
+
delete this.divisor;
|
|
6354
|
+
if (this.normalized === void 0)
|
|
6355
|
+
delete this.normalized;
|
|
6356
|
+
if (this.integer === void 0)
|
|
6357
|
+
delete this.integer;
|
|
6358
|
+
if (this.buffer === void 0)
|
|
6359
|
+
delete this.buffer;
|
|
6360
|
+
if (this.index === void 0)
|
|
6361
|
+
delete this.index;
|
|
6362
|
+
return this;
|
|
6363
|
+
}
|
|
6364
|
+
};
|
|
6365
|
+
function getTypedArrayFromGLType2(glType, options) {
|
|
6366
|
+
const { clamped = true } = options || {};
|
|
6367
|
+
switch (glType) {
|
|
6368
|
+
case 5126 /* FLOAT */:
|
|
6369
|
+
return Float32Array;
|
|
6370
|
+
case 5123 /* UNSIGNED_SHORT */:
|
|
6371
|
+
case 33635 /* UNSIGNED_SHORT_5_6_5 */:
|
|
6372
|
+
case 32819 /* UNSIGNED_SHORT_4_4_4_4 */:
|
|
6373
|
+
case 32820 /* UNSIGNED_SHORT_5_5_5_1 */:
|
|
6374
|
+
return Uint16Array;
|
|
6375
|
+
case 5125 /* UNSIGNED_INT */:
|
|
6376
|
+
return Uint32Array;
|
|
6377
|
+
case 5121 /* UNSIGNED_BYTE */:
|
|
6378
|
+
return clamped ? Uint8ClampedArray : Uint8Array;
|
|
6379
|
+
case 5120 /* BYTE */:
|
|
6380
|
+
return Int8Array;
|
|
6381
|
+
case 5122 /* SHORT */:
|
|
6382
|
+
return Int16Array;
|
|
6383
|
+
case 5124 /* INT */:
|
|
6384
|
+
return Int32Array;
|
|
6385
|
+
default:
|
|
6386
|
+
throw new Error("Failed to deduce typed array type from GL constant");
|
|
6387
|
+
}
|
|
6388
|
+
}
|
|
6331
6389
|
return __toCommonJS(bundle_exports);
|
|
6332
6390
|
})();
|
|
6333
6391
|
return __exports__;
|