@luma.gl/webgl 9.1.0-alpha.10 → 9.1.0-alpha.13
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-framebuffer.d.ts +1 -2
- package/dist/adapter/resources/webgl-framebuffer.d.ts.map +1 -1
- package/dist/adapter/resources/webgl-framebuffer.js +27 -31
- 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 +514 -457
- package/dist/dist.min.js +2 -2
- package/dist/index.cjs +509 -459
- 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-framebuffer.ts +37 -42
- 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;
|
|
@@ -3113,30 +3327,7 @@ var __exports__ = (() => {
|
|
|
3113
3327
|
if (!isDefaultFramebuffer) {
|
|
3114
3328
|
device.setSpectorMetadata(this.handle, { id: this.props.id, props: this.props });
|
|
3115
3329
|
this.autoCreateAttachmentTextures();
|
|
3116
|
-
|
|
3117
|
-
36160 /* FRAMEBUFFER */,
|
|
3118
|
-
this.handle
|
|
3119
|
-
);
|
|
3120
|
-
for (let i = 0; i < this.colorAttachments.length; ++i) {
|
|
3121
|
-
const attachment = this.colorAttachments[i];
|
|
3122
|
-
const attachmentPoint = 36064 /* COLOR_ATTACHMENT0 */ + i;
|
|
3123
|
-
if (attachment) {
|
|
3124
|
-
this._attachTexture(attachmentPoint, attachment);
|
|
3125
|
-
}
|
|
3126
|
-
}
|
|
3127
|
-
if (this.depthStencilAttachment) {
|
|
3128
|
-
this._attachTexture(
|
|
3129
|
-
getDepthStencilAttachmentWebGL(this.depthStencilAttachment.props.format),
|
|
3130
|
-
this.depthStencilAttachment
|
|
3131
|
-
);
|
|
3132
|
-
}
|
|
3133
|
-
if (props.check !== false) {
|
|
3134
|
-
const status = this.gl.checkFramebufferStatus(36160 /* FRAMEBUFFER */);
|
|
3135
|
-
if (status !== 36053 /* FRAMEBUFFER_COMPLETE */) {
|
|
3136
|
-
throw new Error(`Framebuffer ${_getFrameBufferStatus(status)}`);
|
|
3137
|
-
}
|
|
3138
|
-
}
|
|
3139
|
-
this.gl.bindFramebuffer(36160 /* FRAMEBUFFER */, prevHandle);
|
|
3330
|
+
this.updateAttachments();
|
|
3140
3331
|
}
|
|
3141
3332
|
}
|
|
3142
3333
|
/** destroys any auto created resources etc. */
|
|
@@ -3146,6 +3337,32 @@ var __exports__ = (() => {
|
|
|
3146
3337
|
this.gl.deleteFramebuffer(this.handle);
|
|
3147
3338
|
}
|
|
3148
3339
|
}
|
|
3340
|
+
updateAttachments() {
|
|
3341
|
+
const prevHandle = this.gl.bindFramebuffer(
|
|
3342
|
+
36160 /* FRAMEBUFFER */,
|
|
3343
|
+
this.handle
|
|
3344
|
+
);
|
|
3345
|
+
for (let i = 0; i < this.colorAttachments.length; ++i) {
|
|
3346
|
+
const attachment = this.colorAttachments[i];
|
|
3347
|
+
if (attachment) {
|
|
3348
|
+
const attachmentPoint = 36064 /* COLOR_ATTACHMENT0 */ + i;
|
|
3349
|
+
this._attachTextureView(attachmentPoint, attachment);
|
|
3350
|
+
}
|
|
3351
|
+
}
|
|
3352
|
+
if (this.depthStencilAttachment) {
|
|
3353
|
+
const attachmentPoint = getDepthStencilAttachmentWebGL(
|
|
3354
|
+
this.depthStencilAttachment.props.format
|
|
3355
|
+
);
|
|
3356
|
+
this._attachTextureView(attachmentPoint, this.depthStencilAttachment);
|
|
3357
|
+
}
|
|
3358
|
+
if (this.props.check !== false) {
|
|
3359
|
+
const status = this.gl.checkFramebufferStatus(36160 /* FRAMEBUFFER */);
|
|
3360
|
+
if (status !== 36053 /* FRAMEBUFFER_COMPLETE */) {
|
|
3361
|
+
throw new Error(`Framebuffer ${_getFrameBufferStatus(status)}`);
|
|
3362
|
+
}
|
|
3363
|
+
}
|
|
3364
|
+
this.gl.bindFramebuffer(36160 /* FRAMEBUFFER */, prevHandle);
|
|
3365
|
+
}
|
|
3149
3366
|
// PRIVATE
|
|
3150
3367
|
/** In WebGL we must use renderbuffers for depth/stencil attachments (unless we have extensions) */
|
|
3151
3368
|
createDepthStencilTexture(format) {
|
|
@@ -3187,10 +3404,6 @@ var __exports__ = (() => {
|
|
|
3187
3404
|
return this;
|
|
3188
3405
|
}
|
|
3189
3406
|
*/
|
|
3190
|
-
/** Attach one attachment */
|
|
3191
|
-
_attachTexture(attachmentPoint, textureView) {
|
|
3192
|
-
this._attachTextureView(attachmentPoint, textureView);
|
|
3193
|
-
}
|
|
3194
3407
|
/**
|
|
3195
3408
|
* @param attachment
|
|
3196
3409
|
* @param texture
|
|
@@ -3244,7 +3457,7 @@ var __exports__ = (() => {
|
|
|
3244
3457
|
}
|
|
3245
3458
|
|
|
3246
3459
|
// src/adapter/webgl-canvas-context.ts
|
|
3247
|
-
var WebGLCanvasContext = class extends
|
|
3460
|
+
var WebGLCanvasContext = class extends import_core10.CanvasContext {
|
|
3248
3461
|
device;
|
|
3249
3462
|
format = "rgba8unorm";
|
|
3250
3463
|
depthStencilFormat = "depth24plus";
|
|
@@ -3297,7 +3510,7 @@ var __exports__ = (() => {
|
|
|
3297
3510
|
};
|
|
3298
3511
|
|
|
3299
3512
|
// src/context/debug/spector.ts
|
|
3300
|
-
var
|
|
3513
|
+
var import_core11 = __toESM(require_core(), 1);
|
|
3301
3514
|
|
|
3302
3515
|
// src/utils/load-script.ts
|
|
3303
3516
|
async function loadScript(scriptUrl, scriptId) {
|
|
@@ -3323,7 +3536,7 @@ var __exports__ = (() => {
|
|
|
3323
3536
|
var spector = null;
|
|
3324
3537
|
var initialized = false;
|
|
3325
3538
|
var DEFAULT_SPECTOR_PROPS = {
|
|
3326
|
-
debugWithSpectorJS:
|
|
3539
|
+
debugWithSpectorJS: import_core11.log.get("spector") || import_core11.log.get("spectorjs"),
|
|
3327
3540
|
// https://github.com/BabylonJS/Spector.js#basic-usage
|
|
3328
3541
|
// https://forum.babylonjs.com/t/spectorcdn-is-temporarily-off/48241
|
|
3329
3542
|
// spectorUrl: 'https://spectorcdn.babylonjs.com/spector.bundle.js';
|
|
@@ -3335,7 +3548,7 @@ var __exports__ = (() => {
|
|
|
3335
3548
|
try {
|
|
3336
3549
|
await loadScript(props.spectorUrl || DEFAULT_SPECTOR_PROPS.spectorUrl);
|
|
3337
3550
|
} catch (error) {
|
|
3338
|
-
|
|
3551
|
+
import_core11.log.warn(String(error));
|
|
3339
3552
|
}
|
|
3340
3553
|
}
|
|
3341
3554
|
}
|
|
@@ -3345,7 +3558,7 @@ var __exports__ = (() => {
|
|
|
3345
3558
|
return null;
|
|
3346
3559
|
}
|
|
3347
3560
|
if (!spector && globalThis.SPECTOR && !globalThis.luma?.spector) {
|
|
3348
|
-
|
|
3561
|
+
import_core11.log.probe(LOG_LEVEL, "SPECTOR found and initialized. Start with `luma.spector.displayUI()`")();
|
|
3349
3562
|
const { Spector } = globalThis.SPECTOR;
|
|
3350
3563
|
spector = new Spector();
|
|
3351
3564
|
if (globalThis.luma) {
|
|
@@ -3359,10 +3572,10 @@ var __exports__ = (() => {
|
|
|
3359
3572
|
initialized = true;
|
|
3360
3573
|
spector.spyCanvases();
|
|
3361
3574
|
spector?.onCaptureStarted.add(
|
|
3362
|
-
(capture) =>
|
|
3575
|
+
(capture) => import_core11.log.info("Spector capture started:", capture)()
|
|
3363
3576
|
);
|
|
3364
3577
|
spector?.onCapture.add((capture) => {
|
|
3365
|
-
|
|
3578
|
+
import_core11.log.info("Spector capture complete:", capture)();
|
|
3366
3579
|
spector?.getResultUI();
|
|
3367
3580
|
spector?.resultView.display();
|
|
3368
3581
|
spector?.resultView.addCapture(capture);
|
|
@@ -3374,7 +3587,7 @@ var __exports__ = (() => {
|
|
|
3374
3587
|
spector?.startCapture(props.gl, 500);
|
|
3375
3588
|
gl.device = device;
|
|
3376
3589
|
new Promise((resolve) => setTimeout(resolve, 2e3)).then((_) => {
|
|
3377
|
-
|
|
3590
|
+
import_core11.log.info("Spector capture stopped after 2 seconds")();
|
|
3378
3591
|
spector?.stopCapture();
|
|
3379
3592
|
});
|
|
3380
3593
|
}
|
|
@@ -3382,7 +3595,7 @@ var __exports__ = (() => {
|
|
|
3382
3595
|
}
|
|
3383
3596
|
|
|
3384
3597
|
// src/context/debug/webgl-developer-tools.ts
|
|
3385
|
-
var
|
|
3598
|
+
var import_core12 = __toESM(require_core(), 1);
|
|
3386
3599
|
|
|
3387
3600
|
// ../../node_modules/@probe.gl/env/dist/lib/globals.js
|
|
3388
3601
|
var document_ = globalThis.document || {};
|
|
@@ -3458,7 +3671,7 @@ var __exports__ = (() => {
|
|
|
3458
3671
|
}
|
|
3459
3672
|
function getDebugContext(gl, props) {
|
|
3460
3673
|
if (!globalThis.WebGLDebugUtils) {
|
|
3461
|
-
|
|
3674
|
+
import_core12.log.warn("webgl-debug not loaded")();
|
|
3462
3675
|
return gl;
|
|
3463
3676
|
}
|
|
3464
3677
|
const data = getWebGLContextData(gl);
|
|
@@ -3497,7 +3710,7 @@ var __exports__ = (() => {
|
|
|
3497
3710
|
const errorMessage = globalThis.WebGLDebugUtils.glEnumToString(err);
|
|
3498
3711
|
const functionArgs = globalThis.WebGLDebugUtils.glFunctionArgsToString(functionName, args);
|
|
3499
3712
|
const message2 = `${errorMessage} in gl.${functionName}(${functionArgs})`;
|
|
3500
|
-
|
|
3713
|
+
import_core12.log.error(message2)();
|
|
3501
3714
|
debugger;
|
|
3502
3715
|
if (props.throwOnError) {
|
|
3503
3716
|
throw new Error(message2);
|
|
@@ -3505,9 +3718,9 @@ var __exports__ = (() => {
|
|
|
3505
3718
|
}
|
|
3506
3719
|
function onValidateGLFunc(props, functionName, functionArgs) {
|
|
3507
3720
|
let functionString = "";
|
|
3508
|
-
if (
|
|
3721
|
+
if (import_core12.log.level >= 1) {
|
|
3509
3722
|
functionString = getFunctionString(functionName, functionArgs);
|
|
3510
|
-
|
|
3723
|
+
import_core12.log.log(1, functionString)();
|
|
3511
3724
|
}
|
|
3512
3725
|
if (props.break && props.break.length > 0) {
|
|
3513
3726
|
functionString = functionString || getFunctionString(functionName, functionArgs);
|
|
@@ -3524,7 +3737,7 @@ var __exports__ = (() => {
|
|
|
3524
3737
|
if (props.throwOnError) {
|
|
3525
3738
|
throw new Error(`Undefined argument: ${functionString}`);
|
|
3526
3739
|
} else {
|
|
3527
|
-
|
|
3740
|
+
import_core12.log.error(`Undefined argument: ${functionString}`)();
|
|
3528
3741
|
debugger;
|
|
3529
3742
|
}
|
|
3530
3743
|
}
|
|
@@ -3540,8 +3753,8 @@ var __exports__ = (() => {
|
|
|
3540
3753
|
}
|
|
3541
3754
|
|
|
3542
3755
|
// src/adapter/resources/webgl-buffer.ts
|
|
3543
|
-
var
|
|
3544
|
-
var WEBGLBuffer = class extends
|
|
3756
|
+
var import_core13 = __toESM(require_core(), 1);
|
|
3757
|
+
var WEBGLBuffer = class extends import_core13.Buffer {
|
|
3545
3758
|
device;
|
|
3546
3759
|
gl;
|
|
3547
3760
|
handle;
|
|
@@ -3639,32 +3852,32 @@ var __exports__ = (() => {
|
|
|
3639
3852
|
}
|
|
3640
3853
|
};
|
|
3641
3854
|
function getWebGLTarget(usage) {
|
|
3642
|
-
if (usage &
|
|
3855
|
+
if (usage & import_core13.Buffer.INDEX) {
|
|
3643
3856
|
return 34963 /* ELEMENT_ARRAY_BUFFER */;
|
|
3644
3857
|
}
|
|
3645
|
-
if (usage &
|
|
3858
|
+
if (usage & import_core13.Buffer.VERTEX) {
|
|
3646
3859
|
return 34962 /* ARRAY_BUFFER */;
|
|
3647
3860
|
}
|
|
3648
|
-
if (usage &
|
|
3861
|
+
if (usage & import_core13.Buffer.UNIFORM) {
|
|
3649
3862
|
return 35345 /* UNIFORM_BUFFER */;
|
|
3650
3863
|
}
|
|
3651
3864
|
return 34962 /* ARRAY_BUFFER */;
|
|
3652
3865
|
}
|
|
3653
3866
|
function getWebGLUsage(usage) {
|
|
3654
|
-
if (usage &
|
|
3867
|
+
if (usage & import_core13.Buffer.INDEX) {
|
|
3655
3868
|
return 35044 /* STATIC_DRAW */;
|
|
3656
3869
|
}
|
|
3657
|
-
if (usage &
|
|
3870
|
+
if (usage & import_core13.Buffer.VERTEX) {
|
|
3658
3871
|
return 35044 /* STATIC_DRAW */;
|
|
3659
3872
|
}
|
|
3660
|
-
if (usage &
|
|
3873
|
+
if (usage & import_core13.Buffer.UNIFORM) {
|
|
3661
3874
|
return 35048 /* DYNAMIC_DRAW */;
|
|
3662
3875
|
}
|
|
3663
3876
|
return 35044 /* STATIC_DRAW */;
|
|
3664
3877
|
}
|
|
3665
3878
|
|
|
3666
3879
|
// src/adapter/resources/webgl-shader.ts
|
|
3667
|
-
var
|
|
3880
|
+
var import_core14 = __toESM(require_core(), 1);
|
|
3668
3881
|
|
|
3669
3882
|
// src/adapter/helpers/parse-shader-compiler-log.ts
|
|
3670
3883
|
function parseShaderCompilerLog(errLog) {
|
|
@@ -3711,7 +3924,7 @@ var __exports__ = (() => {
|
|
|
3711
3924
|
}
|
|
3712
3925
|
|
|
3713
3926
|
// src/adapter/resources/webgl-shader.ts
|
|
3714
|
-
var WEBGLShader = class extends
|
|
3927
|
+
var WEBGLShader = class extends import_core14.Shader {
|
|
3715
3928
|
device;
|
|
3716
3929
|
handle;
|
|
3717
3930
|
constructor(device, props) {
|
|
@@ -3741,8 +3954,8 @@ var __exports__ = (() => {
|
|
|
3741
3954
|
return this.getCompilationInfoSync();
|
|
3742
3955
|
}
|
|
3743
3956
|
getCompilationInfoSync() {
|
|
3744
|
-
const
|
|
3745
|
-
return
|
|
3957
|
+
const log12 = this.device.gl.getShaderInfoLog(this.handle);
|
|
3958
|
+
return log12 ? parseShaderCompilerLog(log12) : [];
|
|
3746
3959
|
}
|
|
3747
3960
|
getTranslatedSource() {
|
|
3748
3961
|
const extensions = this.device.getExtension("WEBGL_debug_shaders");
|
|
@@ -3758,7 +3971,7 @@ ${source2}`;
|
|
|
3758
3971
|
const { gl } = this.device;
|
|
3759
3972
|
gl.shaderSource(this.handle, source);
|
|
3760
3973
|
gl.compileShader(this.handle);
|
|
3761
|
-
if (
|
|
3974
|
+
if (import_core14.log.level === 0) {
|
|
3762
3975
|
this.compilationStatus = "pending";
|
|
3763
3976
|
return;
|
|
3764
3977
|
}
|
|
@@ -3770,9 +3983,9 @@ ${source2}`;
|
|
|
3770
3983
|
}
|
|
3771
3984
|
return;
|
|
3772
3985
|
}
|
|
3773
|
-
|
|
3986
|
+
import_core14.log.once(1, "Shader compilation is asynchronous")();
|
|
3774
3987
|
await this._waitForCompilationComplete();
|
|
3775
|
-
|
|
3988
|
+
import_core14.log.info(2, `Shader ${this.id} - async compilation complete: ${this.compilationStatus}`)();
|
|
3776
3989
|
this._getCompilationStatus();
|
|
3777
3990
|
this.debugShader();
|
|
3778
3991
|
}
|
|
@@ -3804,13 +4017,13 @@ ${source2}`;
|
|
|
3804
4017
|
};
|
|
3805
4018
|
|
|
3806
4019
|
// src/adapter/resources/webgl-render-pass.ts
|
|
3807
|
-
var
|
|
4020
|
+
var import_core15 = __toESM(require_core(), 1);
|
|
3808
4021
|
var GL_DEPTH_BUFFER_BIT = 256;
|
|
3809
4022
|
var GL_STENCIL_BUFFER_BIT = 1024;
|
|
3810
4023
|
var GL_COLOR_BUFFER_BIT = 16384;
|
|
3811
4024
|
var GL_COLOR = 6144;
|
|
3812
4025
|
var COLOR_CHANNELS = [1, 2, 4, 8];
|
|
3813
|
-
var WEBGLRenderPass = class extends
|
|
4026
|
+
var WEBGLRenderPass = class extends import_core15.RenderPass {
|
|
3814
4027
|
device;
|
|
3815
4028
|
/** Parameters that should be applied before each draw call */
|
|
3816
4029
|
glParameters;
|
|
@@ -3954,175 +4167,7 @@ ${source2}`;
|
|
|
3954
4167
|
};
|
|
3955
4168
|
|
|
3956
4169
|
// src/adapter/resources/webgl-render-pipeline.ts
|
|
3957
|
-
var
|
|
3958
|
-
|
|
3959
|
-
// src/classic/typed-array-utils.ts
|
|
3960
|
-
var ERR_TYPE_DEDUCTION = "Failed to deduce GL constant from typed array";
|
|
3961
|
-
function getGLTypeFromTypedArray(arrayOrType) {
|
|
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
|
-
};
|
|
4170
|
+
var import_core16 = __toESM(require_core(), 1);
|
|
4126
4171
|
|
|
4127
4172
|
// src/adapter/helpers/decode-webgl-types.ts
|
|
4128
4173
|
function isSamplerUniform(type) {
|
|
@@ -4289,8 +4334,7 @@ ${source2}`;
|
|
|
4289
4334
|
}
|
|
4290
4335
|
const { name, type: compositeType, size } = activeInfo;
|
|
4291
4336
|
const { glType, components } = decodeGLUniformType(compositeType);
|
|
4292
|
-
const
|
|
4293
|
-
const varying = { location, name, accessor };
|
|
4337
|
+
const varying = { location, name, type: glType, size: size * components };
|
|
4294
4338
|
varyings.push(varying);
|
|
4295
4339
|
}
|
|
4296
4340
|
varyings.sort((a, b) => a.location - b.location);
|
|
@@ -4503,13 +4547,16 @@ ${source2}`;
|
|
|
4503
4547
|
|
|
4504
4548
|
// ../../node_modules/@math.gl/types/dist/is-array.js
|
|
4505
4549
|
function isTypedArray(value) {
|
|
4506
|
-
return ArrayBuffer.isView(value) && !(value instanceof DataView)
|
|
4550
|
+
return ArrayBuffer.isView(value) && !(value instanceof DataView);
|
|
4507
4551
|
}
|
|
4508
|
-
function
|
|
4552
|
+
function isNumberArray(value) {
|
|
4509
4553
|
if (Array.isArray(value)) {
|
|
4510
|
-
return value.length === 0 || typeof value[0] === "number"
|
|
4554
|
+
return value.length === 0 || typeof value[0] === "number";
|
|
4511
4555
|
}
|
|
4512
|
-
return
|
|
4556
|
+
return false;
|
|
4557
|
+
}
|
|
4558
|
+
function isNumericArray(value) {
|
|
4559
|
+
return isTypedArray(value) || isNumberArray(value);
|
|
4513
4560
|
}
|
|
4514
4561
|
|
|
4515
4562
|
// src/utils/split-uniforms-and-bindings.ts
|
|
@@ -4565,7 +4612,7 @@ ${source2}`;
|
|
|
4565
4612
|
|
|
4566
4613
|
// src/adapter/resources/webgl-render-pipeline.ts
|
|
4567
4614
|
var LOG_PROGRAM_PERF_PRIORITY = 4;
|
|
4568
|
-
var WEBGLRenderPipeline = class extends
|
|
4615
|
+
var WEBGLRenderPipeline = class extends import_core16.RenderPipeline {
|
|
4569
4616
|
/** The WebGL device that created this render pipeline */
|
|
4570
4617
|
device;
|
|
4571
4618
|
/** Handle to underlying WebGL program */
|
|
@@ -4598,9 +4645,9 @@ ${source2}`;
|
|
|
4598
4645
|
this.device.gl.transformFeedbackVaryings(this.handle, varyings, bufferMode);
|
|
4599
4646
|
}
|
|
4600
4647
|
this._linkShaders();
|
|
4601
|
-
|
|
4648
|
+
import_core16.log.time(1, `RenderPipeline ${this.id} - shaderLayout introspection`)();
|
|
4602
4649
|
this.introspectedLayout = getShaderLayout(this.device.gl, this.handle);
|
|
4603
|
-
|
|
4650
|
+
import_core16.log.timeEnd(1, `RenderPipeline ${this.id} - shaderLayout introspection`)();
|
|
4604
4651
|
this.shaderLayout = mergeShaderLayout(this.introspectedLayout, props.shaderLayout);
|
|
4605
4652
|
}
|
|
4606
4653
|
destroy() {
|
|
@@ -4619,7 +4666,7 @@ ${source2}`;
|
|
|
4619
4666
|
if (!binding) {
|
|
4620
4667
|
const validBindings = this.shaderLayout.bindings.map((binding2) => `"${binding2.name}"`).join(", ");
|
|
4621
4668
|
if (!options?.disableWarnings) {
|
|
4622
|
-
|
|
4669
|
+
import_core16.log.warn(
|
|
4623
4670
|
`No binding "${name}" in render pipeline "${this.id}", expected one of ${validBindings}`,
|
|
4624
4671
|
value
|
|
4625
4672
|
)();
|
|
@@ -4627,7 +4674,7 @@ ${source2}`;
|
|
|
4627
4674
|
continue;
|
|
4628
4675
|
}
|
|
4629
4676
|
if (!value) {
|
|
4630
|
-
|
|
4677
|
+
import_core16.log.warn(`Unsetting binding "${name}" in render pipeline "${this.id}"`)();
|
|
4631
4678
|
}
|
|
4632
4679
|
switch (binding.type) {
|
|
4633
4680
|
case "uniform":
|
|
@@ -4641,7 +4688,7 @@ ${source2}`;
|
|
|
4641
4688
|
}
|
|
4642
4689
|
break;
|
|
4643
4690
|
case "sampler":
|
|
4644
|
-
|
|
4691
|
+
import_core16.log.warn(`Ignoring sampler ${name}`)();
|
|
4645
4692
|
break;
|
|
4646
4693
|
default:
|
|
4647
4694
|
throw new Error(binding.type);
|
|
@@ -4673,11 +4720,11 @@ ${source2}`;
|
|
|
4673
4720
|
const isIndexed = Boolean(vertexArray.indexBuffer);
|
|
4674
4721
|
const glIndexType = vertexArray.indexBuffer?.glIndexType;
|
|
4675
4722
|
if (this.linkStatus !== "success") {
|
|
4676
|
-
|
|
4723
|
+
import_core16.log.info(2, `RenderPipeline:${this.id}.draw() aborted - waiting for shader linking`)();
|
|
4677
4724
|
return false;
|
|
4678
4725
|
}
|
|
4679
4726
|
if (!this._areTexturesRenderable()) {
|
|
4680
|
-
|
|
4727
|
+
import_core16.log.info(2, `RenderPipeline:${this.id}.draw() aborted - textures not yet loaded`)();
|
|
4681
4728
|
return false;
|
|
4682
4729
|
}
|
|
4683
4730
|
this.device.gl.useProgram(this.handle);
|
|
@@ -4721,7 +4768,7 @@ ${source2}`;
|
|
|
4721
4768
|
setUniformsWebGL(uniforms) {
|
|
4722
4769
|
const { bindings } = splitUniformsAndBindings(uniforms);
|
|
4723
4770
|
Object.keys(bindings).forEach((name) => {
|
|
4724
|
-
|
|
4771
|
+
import_core16.log.warn(
|
|
4725
4772
|
`Unsupported value "${JSON.stringify(
|
|
4726
4773
|
bindings[name]
|
|
4727
4774
|
)}" used in setUniforms() for key ${name}. Use setBindings() instead?`
|
|
@@ -4736,19 +4783,19 @@ ${source2}`;
|
|
|
4736
4783
|
const { gl } = this.device;
|
|
4737
4784
|
gl.attachShader(this.handle, this.vs.handle);
|
|
4738
4785
|
gl.attachShader(this.handle, this.fs.handle);
|
|
4739
|
-
|
|
4786
|
+
import_core16.log.time(LOG_PROGRAM_PERF_PRIORITY, `linkProgram for ${this.id}`)();
|
|
4740
4787
|
gl.linkProgram(this.handle);
|
|
4741
|
-
|
|
4742
|
-
if (
|
|
4788
|
+
import_core16.log.timeEnd(LOG_PROGRAM_PERF_PRIORITY, `linkProgram for ${this.id}`)();
|
|
4789
|
+
if (import_core16.log.level === 0) {
|
|
4743
4790
|
}
|
|
4744
4791
|
if (!this.device.features.has("compilation-status-async-webgl")) {
|
|
4745
4792
|
const status2 = this._getLinkStatus();
|
|
4746
4793
|
this._reportLinkStatus(status2);
|
|
4747
4794
|
return;
|
|
4748
4795
|
}
|
|
4749
|
-
|
|
4796
|
+
import_core16.log.once(1, "RenderPipeline linking is asynchronous")();
|
|
4750
4797
|
await this._waitForLinkComplete();
|
|
4751
|
-
|
|
4798
|
+
import_core16.log.info(2, `RenderPipeline ${this.id} - async linking complete: ${this.linkStatus}`)();
|
|
4752
4799
|
const status = this._getLinkStatus();
|
|
4753
4800
|
this._reportLinkStatus(status);
|
|
4754
4801
|
}
|
|
@@ -4816,7 +4863,7 @@ ${source2}`;
|
|
|
4816
4863
|
let texturesRenderable = true;
|
|
4817
4864
|
for (const bindingInfo of this.shaderLayout.bindings) {
|
|
4818
4865
|
if (!this.bindings[bindingInfo.name] && !this.bindings[bindingInfo.name.replace(/Uniforms$/, "")]) {
|
|
4819
|
-
|
|
4866
|
+
import_core16.log.warn(`Binding ${bindingInfo.name} not found in ${this.id}`)();
|
|
4820
4867
|
texturesRenderable = false;
|
|
4821
4868
|
}
|
|
4822
4869
|
}
|
|
@@ -4875,7 +4922,7 @@ ${source2}`;
|
|
|
4875
4922
|
} else if (value instanceof WEBGLTexture) {
|
|
4876
4923
|
texture = value;
|
|
4877
4924
|
} else if (value instanceof WEBGLFramebuffer && value.colorAttachments[0] instanceof WEBGLTextureView) {
|
|
4878
|
-
|
|
4925
|
+
import_core16.log.warn(
|
|
4879
4926
|
"Passing framebuffer in texture binding may be deprecated. Use fbo.colorAttachments[0] instead"
|
|
4880
4927
|
)();
|
|
4881
4928
|
texture = value.colorAttachments[0].texture;
|
|
@@ -4916,7 +4963,7 @@ ${source2}`;
|
|
|
4916
4963
|
for (const attribute of overrideLayout?.attributes || []) {
|
|
4917
4964
|
const baseAttribute = mergedLayout.attributes.find((attr) => attr.name === attribute.name);
|
|
4918
4965
|
if (!baseAttribute) {
|
|
4919
|
-
|
|
4966
|
+
import_core16.log.warn(`shader layout attribute ${attribute.name} not present in shader`);
|
|
4920
4967
|
} else {
|
|
4921
4968
|
baseAttribute.type = attribute.type || baseAttribute.type;
|
|
4922
4969
|
baseAttribute.stepMode = attribute.stepMode || baseAttribute.stepMode;
|
|
@@ -4926,11 +4973,11 @@ ${source2}`;
|
|
|
4926
4973
|
}
|
|
4927
4974
|
|
|
4928
4975
|
// src/adapter/resources/webgl-command-encoder.ts
|
|
4929
|
-
var
|
|
4976
|
+
var import_core18 = __toESM(require_core(), 1);
|
|
4930
4977
|
|
|
4931
4978
|
// src/adapter/resources/webgl-command-buffer.ts
|
|
4932
|
-
var
|
|
4933
|
-
var WEBGLCommandBuffer = class extends
|
|
4979
|
+
var import_core17 = __toESM(require_core(), 1);
|
|
4980
|
+
var WEBGLCommandBuffer = class extends import_core17.CommandBuffer {
|
|
4934
4981
|
device;
|
|
4935
4982
|
commands = [];
|
|
4936
4983
|
constructor(device) {
|
|
@@ -5011,7 +5058,7 @@ ${source2}`;
|
|
|
5011
5058
|
if (mipLevel !== 0 || depthOrArrayLayers !== 0 || bytesPerRow || rowsPerImage) {
|
|
5012
5059
|
throw new Error("not implemented");
|
|
5013
5060
|
}
|
|
5014
|
-
const { framebuffer, destroyFramebuffer } =
|
|
5061
|
+
const { framebuffer, destroyFramebuffer } = getFramebuffer2(source);
|
|
5015
5062
|
let prevHandle;
|
|
5016
5063
|
try {
|
|
5017
5064
|
const webglBuffer = destination;
|
|
@@ -5069,7 +5116,7 @@ ${source2}`;
|
|
|
5069
5116
|
height = options.destination.height
|
|
5070
5117
|
// depthOrArrayLayers = 0
|
|
5071
5118
|
} = options;
|
|
5072
|
-
const { framebuffer, destroyFramebuffer } =
|
|
5119
|
+
const { framebuffer, destroyFramebuffer } = getFramebuffer2(source);
|
|
5073
5120
|
const [sourceX, sourceY] = origin;
|
|
5074
5121
|
const [destinationX, destinationY, destinationZ] = destinationOrigin;
|
|
5075
5122
|
const prevHandle = device.gl.bindFramebuffer(
|
|
@@ -5125,8 +5172,8 @@ ${source2}`;
|
|
|
5125
5172
|
framebuffer.destroy();
|
|
5126
5173
|
}
|
|
5127
5174
|
}
|
|
5128
|
-
function
|
|
5129
|
-
if (source instanceof
|
|
5175
|
+
function getFramebuffer2(source) {
|
|
5176
|
+
if (source instanceof import_core17.Texture) {
|
|
5130
5177
|
const { width, height, id } = source;
|
|
5131
5178
|
const framebuffer = source.device.createFramebuffer({
|
|
5132
5179
|
id: `framebuffer-for-${id}`,
|
|
@@ -5140,7 +5187,7 @@ ${source2}`;
|
|
|
5140
5187
|
}
|
|
5141
5188
|
|
|
5142
5189
|
// src/adapter/resources/webgl-command-encoder.ts
|
|
5143
|
-
var WEBGLCommandEncoder = class extends
|
|
5190
|
+
var WEBGLCommandEncoder = class extends import_core18.CommandEncoder {
|
|
5144
5191
|
device;
|
|
5145
5192
|
commandBuffer;
|
|
5146
5193
|
constructor(device, props) {
|
|
@@ -5179,7 +5226,7 @@ ${source2}`;
|
|
|
5179
5226
|
};
|
|
5180
5227
|
|
|
5181
5228
|
// src/adapter/resources/webgl-vertex-array.ts
|
|
5182
|
-
var
|
|
5229
|
+
var import_core19 = __toESM(require_core(), 1);
|
|
5183
5230
|
|
|
5184
5231
|
// src/utils/fill-array.ts
|
|
5185
5232
|
function fillArray(options) {
|
|
@@ -5203,7 +5250,7 @@ ${source2}`;
|
|
|
5203
5250
|
}
|
|
5204
5251
|
|
|
5205
5252
|
// src/adapter/resources/webgl-vertex-array.ts
|
|
5206
|
-
var WEBGLVertexArray = class extends
|
|
5253
|
+
var WEBGLVertexArray = class extends import_core19.VertexArray {
|
|
5207
5254
|
get [Symbol.toStringTag]() {
|
|
5208
5255
|
return "VertexArray";
|
|
5209
5256
|
}
|
|
@@ -5371,7 +5418,7 @@ ${source2}`;
|
|
|
5371
5418
|
this.buffer = this.buffer || this.device.createBuffer({ byteLength });
|
|
5372
5419
|
updateNeeded = updateNeeded || !compareConstantArrayValues(constantValue, this.bufferValue);
|
|
5373
5420
|
if (updateNeeded) {
|
|
5374
|
-
const typedArray = (0,
|
|
5421
|
+
const typedArray = (0, import_core19.getScratchArray)(value.constructor, length);
|
|
5375
5422
|
fillArray({ target: typedArray, source: constantValue, start: 0, count: length });
|
|
5376
5423
|
this.buffer.write(typedArray);
|
|
5377
5424
|
this.bufferValue = value;
|
|
@@ -5398,8 +5445,8 @@ ${source2}`;
|
|
|
5398
5445
|
}
|
|
5399
5446
|
|
|
5400
5447
|
// src/adapter/resources/webgl-transform-feedback.ts
|
|
5401
|
-
var
|
|
5402
|
-
var WEBGLTransformFeedback = class extends
|
|
5448
|
+
var import_core20 = __toESM(require_core(), 1);
|
|
5449
|
+
var WEBGLTransformFeedback = class extends import_core20.TransformFeedback {
|
|
5403
5450
|
device;
|
|
5404
5451
|
gl;
|
|
5405
5452
|
handle;
|
|
@@ -5462,7 +5509,7 @@ ${source2}`;
|
|
|
5462
5509
|
const { buffer, byteLength, byteOffset } = this._getBufferRange(bufferOrRange);
|
|
5463
5510
|
if (location < 0) {
|
|
5464
5511
|
this.unusedBuffers[locationOrName] = buffer;
|
|
5465
|
-
|
|
5512
|
+
import_core20.log.warn(`${this.id} unusedBuffers varying buffer ${locationOrName}`)();
|
|
5466
5513
|
return;
|
|
5467
5514
|
}
|
|
5468
5515
|
this.buffers[location] = { buffer, byteLength, byteOffset };
|
|
@@ -5549,8 +5596,8 @@ ${source2}`;
|
|
|
5549
5596
|
}
|
|
5550
5597
|
|
|
5551
5598
|
// src/adapter/resources/webgl-query-set.ts
|
|
5552
|
-
var
|
|
5553
|
-
var WEBGLQuerySet = class extends
|
|
5599
|
+
var import_core21 = __toESM(require_core(), 1);
|
|
5600
|
+
var WEBGLQuerySet = class extends import_core21.QuerySet {
|
|
5554
5601
|
device;
|
|
5555
5602
|
handle;
|
|
5556
5603
|
target = null;
|
|
@@ -5682,147 +5729,13 @@ ${source2}`;
|
|
|
5682
5729
|
}
|
|
5683
5730
|
};
|
|
5684
5731
|
|
|
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
|
|
5732
|
+
// src/deprecated/clear.ts
|
|
5733
|
+
var import_core22 = __toESM(require_core(), 1);
|
|
5822
5734
|
var GL_DEPTH_BUFFER_BIT2 = 256;
|
|
5823
5735
|
var GL_STENCIL_BUFFER_BIT2 = 1024;
|
|
5824
5736
|
var GL_COLOR_BUFFER_BIT2 = 16384;
|
|
5825
5737
|
function clear(device, options) {
|
|
5738
|
+
import_core22.log.warn("clear will be removed in next minor release");
|
|
5826
5739
|
const { framebuffer = null, color = null, depth = null, stencil = null } = options || {};
|
|
5827
5740
|
const parameters = {};
|
|
5828
5741
|
if (framebuffer) {
|
|
@@ -5854,7 +5767,7 @@ ${source2}`;
|
|
|
5854
5767
|
}
|
|
5855
5768
|
|
|
5856
5769
|
// src/adapter/webgl-device.ts
|
|
5857
|
-
var WebGLDevice = class extends
|
|
5770
|
+
var WebGLDevice = class extends import_core23.Device {
|
|
5858
5771
|
//
|
|
5859
5772
|
// Public `Device` API
|
|
5860
5773
|
//
|
|
@@ -5914,14 +5827,14 @@ ${source2}`;
|
|
|
5914
5827
|
}
|
|
5915
5828
|
this.canvasContext.resize();
|
|
5916
5829
|
const glState = new WebGLStateTracker(this.gl, {
|
|
5917
|
-
log: (...args) =>
|
|
5830
|
+
log: (...args) => import_core23.log.log(1, ...args)()
|
|
5918
5831
|
});
|
|
5919
5832
|
glState.trackState(this.gl, { copyState: false });
|
|
5920
5833
|
if (props.debug) {
|
|
5921
5834
|
this.gl = makeDebugContext(this.gl, { ...props, throwOnError: true });
|
|
5922
5835
|
this.debug = true;
|
|
5923
|
-
|
|
5924
|
-
|
|
5836
|
+
import_core23.log.level = Math.max(import_core23.log.level, 1);
|
|
5837
|
+
import_core23.log.warn("WebGL debug mode activated. Performance reduced.")();
|
|
5925
5838
|
}
|
|
5926
5839
|
}
|
|
5927
5840
|
/**
|
|
@@ -6024,7 +5937,7 @@ ${source2}`;
|
|
|
6024
5937
|
clear(this, options);
|
|
6025
5938
|
}
|
|
6026
5939
|
resetWebGL() {
|
|
6027
|
-
|
|
5940
|
+
import_core23.log.warn("WebGLDevice.resetWebGL is deprecated, use only for debugging")();
|
|
6028
5941
|
resetGLParameters(this.gl);
|
|
6029
5942
|
}
|
|
6030
5943
|
//
|
|
@@ -6093,7 +6006,7 @@ ${source2}`;
|
|
|
6093
6006
|
this._constants = this._constants || new Array(maxVertexAttributes).fill(null);
|
|
6094
6007
|
const currentConstant = this._constants[location];
|
|
6095
6008
|
if (currentConstant && compareConstantArrayValues2(currentConstant, constant)) {
|
|
6096
|
-
|
|
6009
|
+
import_core23.log.info(
|
|
6097
6010
|
1,
|
|
6098
6011
|
`setConstantAttributeWebGL(${location}) could have been skipped, value unchanged`
|
|
6099
6012
|
)();
|
|
@@ -6260,12 +6173,12 @@ ${source2}`;
|
|
|
6260
6173
|
|
|
6261
6174
|
// src/adapter/webgl-adapter.ts
|
|
6262
6175
|
var LOG_LEVEL2 = 1;
|
|
6263
|
-
var WebGLAdapter = class extends
|
|
6176
|
+
var WebGLAdapter = class extends import_core24.Adapter {
|
|
6264
6177
|
/** type of device's created by this adapter */
|
|
6265
6178
|
type = "webgl";
|
|
6266
6179
|
constructor() {
|
|
6267
6180
|
super();
|
|
6268
|
-
|
|
6181
|
+
import_core24.Device.defaultProps = { ...import_core24.Device.defaultProps, ...DEFAULT_SPECTOR_PROPS };
|
|
6269
6182
|
WebGLDevice.adapter = this;
|
|
6270
6183
|
}
|
|
6271
6184
|
/** Check if WebGL 2 is available */
|
|
@@ -6286,7 +6199,7 @@ ${source2}`;
|
|
|
6286
6199
|
if (gl instanceof WebGLDevice) {
|
|
6287
6200
|
return gl;
|
|
6288
6201
|
}
|
|
6289
|
-
if (gl?.device instanceof
|
|
6202
|
+
if (gl?.device instanceof import_core24.Device) {
|
|
6290
6203
|
return gl.device;
|
|
6291
6204
|
}
|
|
6292
6205
|
if (!isWebGL(gl)) {
|
|
@@ -6295,7 +6208,7 @@ ${source2}`;
|
|
|
6295
6208
|
return new WebGLDevice({ gl });
|
|
6296
6209
|
}
|
|
6297
6210
|
async create(props = {}) {
|
|
6298
|
-
|
|
6211
|
+
import_core24.log.groupCollapsed(LOG_LEVEL2, "WebGLDevice created")();
|
|
6299
6212
|
const promises = [];
|
|
6300
6213
|
if (props.debug) {
|
|
6301
6214
|
promises.push(loadWebGLDeveloperTools());
|
|
@@ -6304,20 +6217,20 @@ ${source2}`;
|
|
|
6304
6217
|
promises.push(loadSpectorJS(props));
|
|
6305
6218
|
}
|
|
6306
6219
|
if (typeof props.canvas === "string") {
|
|
6307
|
-
promises.push(
|
|
6220
|
+
promises.push(import_core24.CanvasContext.pageLoaded);
|
|
6308
6221
|
}
|
|
6309
6222
|
const results = await Promise.allSettled(promises);
|
|
6310
6223
|
for (const result of results) {
|
|
6311
6224
|
if (result.status === "rejected") {
|
|
6312
|
-
|
|
6225
|
+
import_core24.log.error(`Failed to initialize debug libraries ${result.reason}`)();
|
|
6313
6226
|
}
|
|
6314
6227
|
}
|
|
6315
|
-
|
|
6228
|
+
import_core24.log.probe(LOG_LEVEL2 + 1, "DOM is loaded")();
|
|
6316
6229
|
const device = new WebGLDevice(props);
|
|
6317
6230
|
const message2 = `Created ${device.type}${device.debug ? " debug" : ""} context: ${device.info.vendor}, ${device.info.renderer} for canvas: ${device.canvasContext.id}`;
|
|
6318
|
-
|
|
6319
|
-
|
|
6320
|
-
|
|
6231
|
+
import_core24.log.probe(LOG_LEVEL2, message2)();
|
|
6232
|
+
import_core24.log.table(LOG_LEVEL2, device.info)();
|
|
6233
|
+
import_core24.log.groupEnd(LOG_LEVEL2)();
|
|
6321
6234
|
return device;
|
|
6322
6235
|
}
|
|
6323
6236
|
};
|
|
@@ -6328,6 +6241,150 @@ ${source2}`;
|
|
|
6328
6241
|
return Boolean(gl && Number.isFinite(gl._version));
|
|
6329
6242
|
}
|
|
6330
6243
|
var webgl2Adapter = new WebGLAdapter();
|
|
6244
|
+
|
|
6245
|
+
// src/deprecated/accessor.ts
|
|
6246
|
+
var import_core25 = __toESM(require_core(), 1);
|
|
6247
|
+
var DEFAULT_ACCESSOR_VALUES = {
|
|
6248
|
+
offset: 0,
|
|
6249
|
+
stride: 0,
|
|
6250
|
+
type: 5126 /* FLOAT */,
|
|
6251
|
+
size: 1,
|
|
6252
|
+
divisor: 0,
|
|
6253
|
+
normalized: false,
|
|
6254
|
+
integer: false
|
|
6255
|
+
};
|
|
6256
|
+
var Accessor = class {
|
|
6257
|
+
offset;
|
|
6258
|
+
stride;
|
|
6259
|
+
type;
|
|
6260
|
+
size;
|
|
6261
|
+
divisor;
|
|
6262
|
+
normalized;
|
|
6263
|
+
integer;
|
|
6264
|
+
buffer;
|
|
6265
|
+
index;
|
|
6266
|
+
static getBytesPerElement(accessor) {
|
|
6267
|
+
const ArrayType = getTypedArrayFromGLType2(accessor.type || 5126 /* FLOAT */);
|
|
6268
|
+
return ArrayType.BYTES_PER_ELEMENT;
|
|
6269
|
+
}
|
|
6270
|
+
static getBytesPerVertex(accessor) {
|
|
6271
|
+
const ArrayType = getTypedArrayFromGLType2(accessor.type || 5126 /* FLOAT */);
|
|
6272
|
+
return ArrayType.BYTES_PER_ELEMENT * accessor.size;
|
|
6273
|
+
}
|
|
6274
|
+
// Combines (merges) a list of accessors. On top of default values
|
|
6275
|
+
// Usually [programAccessor, bufferAccessor, appAccessor]
|
|
6276
|
+
// All props will be set in the returned object.
|
|
6277
|
+
// TODO check for conflicts between values in the supplied accessors
|
|
6278
|
+
static resolve(...accessors) {
|
|
6279
|
+
return new Accessor(...[DEFAULT_ACCESSOR_VALUES, ...accessors]);
|
|
6280
|
+
}
|
|
6281
|
+
constructor(...accessors) {
|
|
6282
|
+
import_core25.log.warn("Accessor will be removed in next minor release");
|
|
6283
|
+
accessors.forEach((accessor) => this._assign(accessor));
|
|
6284
|
+
Object.freeze(this);
|
|
6285
|
+
}
|
|
6286
|
+
toString() {
|
|
6287
|
+
return JSON.stringify(this);
|
|
6288
|
+
}
|
|
6289
|
+
// ACCESSORS
|
|
6290
|
+
// TODO - remove>
|
|
6291
|
+
get BYTES_PER_ELEMENT() {
|
|
6292
|
+
return Accessor.getBytesPerElement(this);
|
|
6293
|
+
}
|
|
6294
|
+
get BYTES_PER_VERTEX() {
|
|
6295
|
+
return Accessor.getBytesPerVertex(this);
|
|
6296
|
+
}
|
|
6297
|
+
// PRIVATE
|
|
6298
|
+
// eslint-disable-next-line complexity, max-statements
|
|
6299
|
+
_assign(props = {}) {
|
|
6300
|
+
if (props.type !== void 0) {
|
|
6301
|
+
this.type = props.type;
|
|
6302
|
+
if (props.type === 5124 /* INT */ || props.type === 5125 /* UNSIGNED_INT */) {
|
|
6303
|
+
this.integer = true;
|
|
6304
|
+
}
|
|
6305
|
+
}
|
|
6306
|
+
if (props.size !== void 0) {
|
|
6307
|
+
this.size = props.size;
|
|
6308
|
+
}
|
|
6309
|
+
if (props.offset !== void 0) {
|
|
6310
|
+
this.offset = props.offset;
|
|
6311
|
+
}
|
|
6312
|
+
if (props.stride !== void 0) {
|
|
6313
|
+
this.stride = props.stride;
|
|
6314
|
+
}
|
|
6315
|
+
if (props.normalize !== void 0) {
|
|
6316
|
+
this.normalized = props.normalize;
|
|
6317
|
+
}
|
|
6318
|
+
if (props.normalized !== void 0) {
|
|
6319
|
+
this.normalized = props.normalized;
|
|
6320
|
+
}
|
|
6321
|
+
if (props.integer !== void 0) {
|
|
6322
|
+
this.integer = props.integer;
|
|
6323
|
+
}
|
|
6324
|
+
if (props.divisor !== void 0) {
|
|
6325
|
+
this.divisor = props.divisor;
|
|
6326
|
+
}
|
|
6327
|
+
if (props.buffer !== void 0) {
|
|
6328
|
+
this.buffer = props.buffer;
|
|
6329
|
+
}
|
|
6330
|
+
if (props.index !== void 0) {
|
|
6331
|
+
if (typeof props.index === "boolean") {
|
|
6332
|
+
this.index = props.index ? 1 : 0;
|
|
6333
|
+
} else {
|
|
6334
|
+
this.index = props.index;
|
|
6335
|
+
}
|
|
6336
|
+
}
|
|
6337
|
+
if (props.instanced !== void 0) {
|
|
6338
|
+
this.divisor = props.instanced ? 1 : 0;
|
|
6339
|
+
}
|
|
6340
|
+
if (props.isInstanced !== void 0) {
|
|
6341
|
+
this.divisor = props.isInstanced ? 1 : 0;
|
|
6342
|
+
}
|
|
6343
|
+
if (this.offset === void 0)
|
|
6344
|
+
delete this.offset;
|
|
6345
|
+
if (this.stride === void 0)
|
|
6346
|
+
delete this.stride;
|
|
6347
|
+
if (this.type === void 0)
|
|
6348
|
+
delete this.type;
|
|
6349
|
+
if (this.size === void 0)
|
|
6350
|
+
delete this.size;
|
|
6351
|
+
if (this.divisor === void 0)
|
|
6352
|
+
delete this.divisor;
|
|
6353
|
+
if (this.normalized === void 0)
|
|
6354
|
+
delete this.normalized;
|
|
6355
|
+
if (this.integer === void 0)
|
|
6356
|
+
delete this.integer;
|
|
6357
|
+
if (this.buffer === void 0)
|
|
6358
|
+
delete this.buffer;
|
|
6359
|
+
if (this.index === void 0)
|
|
6360
|
+
delete this.index;
|
|
6361
|
+
return this;
|
|
6362
|
+
}
|
|
6363
|
+
};
|
|
6364
|
+
function getTypedArrayFromGLType2(glType, options) {
|
|
6365
|
+
const { clamped = true } = options || {};
|
|
6366
|
+
switch (glType) {
|
|
6367
|
+
case 5126 /* FLOAT */:
|
|
6368
|
+
return Float32Array;
|
|
6369
|
+
case 5123 /* UNSIGNED_SHORT */:
|
|
6370
|
+
case 33635 /* UNSIGNED_SHORT_5_6_5 */:
|
|
6371
|
+
case 32819 /* UNSIGNED_SHORT_4_4_4_4 */:
|
|
6372
|
+
case 32820 /* UNSIGNED_SHORT_5_5_5_1 */:
|
|
6373
|
+
return Uint16Array;
|
|
6374
|
+
case 5125 /* UNSIGNED_INT */:
|
|
6375
|
+
return Uint32Array;
|
|
6376
|
+
case 5121 /* UNSIGNED_BYTE */:
|
|
6377
|
+
return clamped ? Uint8ClampedArray : Uint8Array;
|
|
6378
|
+
case 5120 /* BYTE */:
|
|
6379
|
+
return Int8Array;
|
|
6380
|
+
case 5122 /* SHORT */:
|
|
6381
|
+
return Int16Array;
|
|
6382
|
+
case 5124 /* INT */:
|
|
6383
|
+
return Int32Array;
|
|
6384
|
+
default:
|
|
6385
|
+
throw new Error("Failed to deduce typed array type from GL constant");
|
|
6386
|
+
}
|
|
6387
|
+
}
|
|
6331
6388
|
return __toCommonJS(bundle_exports);
|
|
6332
6389
|
})();
|
|
6333
6390
|
return __exports__;
|