@luma.gl/webgl 9.0.0-alpha.23 → 9.0.0-alpha.25
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/adapter/converters/device-parameters.d.ts +1 -1
- package/dist/adapter/converters/device-parameters.d.ts.map +1 -1
- package/dist/adapter/converters/device-parameters.js +1 -1
- package/dist/adapter/converters/device-parameters.js.map +1 -1
- package/dist/adapter/converters/sampler-parameters.js.map +1 -1
- package/dist/adapter/converters/texture-formats.d.ts +3 -3
- package/dist/adapter/converters/texture-formats.d.ts.map +1 -1
- package/dist/adapter/converters/texture-formats.js +1 -1
- package/dist/adapter/converters/texture-formats.js.map +1 -1
- package/dist/adapter/converters/vertex-formats.d.ts +1 -1
- package/dist/adapter/converters/vertex-formats.d.ts.map +1 -1
- package/dist/adapter/converters/vertex-formats.js +1 -1
- package/dist/adapter/converters/vertex-formats.js.map +1 -1
- package/dist/adapter/device-helpers/device-features.js.map +1 -1
- package/dist/adapter/device-helpers/device-limits.d.ts +2 -2
- package/dist/adapter/device-helpers/device-limits.d.ts.map +1 -1
- package/dist/adapter/device-helpers/device-limits.js +1 -1
- package/dist/adapter/device-helpers/device-limits.js.map +1 -1
- package/dist/adapter/device-helpers/get-device-info.js +1 -1
- package/dist/adapter/device-helpers/get-device-info.js.map +1 -1
- package/dist/adapter/helpers/attribute-utils.js.map +1 -1
- package/dist/adapter/helpers/get-shader-info.d.ts +1 -1
- package/dist/adapter/helpers/get-shader-info.d.ts.map +1 -1
- package/dist/adapter/helpers/get-shader-layout.js +1 -1
- package/dist/adapter/helpers/get-shader-layout.js.map +1 -1
- package/dist/adapter/helpers/parse-shader-compiler-log.js.map +1 -1
- package/dist/adapter/helpers/set-uniform.d.ts +1 -1
- package/dist/adapter/helpers/set-uniform.d.ts.map +1 -1
- package/dist/adapter/helpers/set-uniform.js +1 -1
- package/dist/adapter/helpers/set-uniform.js.map +1 -1
- package/dist/adapter/helpers/uniforms.js.map +1 -1
- package/dist/adapter/objects/constants-to-keys.d.ts +1 -1
- package/dist/adapter/objects/constants-to-keys.d.ts.map +1 -1
- package/dist/adapter/objects/constants-to-keys.js.map +1 -1
- package/dist/adapter/objects/webgl-renderbuffer.d.ts +2 -2
- package/dist/adapter/objects/webgl-renderbuffer.d.ts.map +1 -1
- package/dist/adapter/objects/webgl-renderbuffer.js +1 -1
- package/dist/adapter/objects/webgl-renderbuffer.js.map +1 -1
- package/dist/adapter/objects/webgl-resource.d.ts +1 -1
- package/dist/adapter/objects/webgl-resource.d.ts.map +1 -1
- package/dist/adapter/objects/webgl-resource.js.map +1 -1
- package/dist/adapter/objects/webgl-vertex-array-object.d.ts +1 -1
- package/dist/adapter/objects/webgl-vertex-array-object.d.ts.map +1 -1
- package/dist/adapter/objects/webgl-vertex-array-object.js +1 -1
- package/dist/adapter/objects/webgl-vertex-array-object.js.map +1 -1
- package/dist/adapter/resources/webgl-buffer.js +1 -1
- package/dist/adapter/resources/webgl-buffer.js.map +1 -1
- package/dist/adapter/resources/webgl-command-buffer.d.ts +6 -6
- package/dist/adapter/resources/webgl-command-buffer.d.ts.map +1 -1
- package/dist/adapter/resources/webgl-command-buffer.js +1 -1
- package/dist/adapter/resources/webgl-command-buffer.js.map +1 -1
- package/dist/adapter/resources/webgl-command-encoder.js.map +1 -1
- package/dist/adapter/resources/webgl-framebuffer.d.ts +3 -3
- package/dist/adapter/resources/webgl-framebuffer.d.ts.map +1 -1
- package/dist/adapter/resources/webgl-framebuffer.js +1 -1
- package/dist/adapter/resources/webgl-framebuffer.js.map +1 -1
- package/dist/adapter/resources/webgl-render-pass.js.map +1 -1
- package/dist/adapter/resources/webgl-render-pipeline.js +3 -2
- package/dist/adapter/resources/webgl-render-pipeline.js.map +1 -1
- package/dist/adapter/resources/webgl-sampler.js.map +1 -1
- package/dist/adapter/resources/webgl-shader.js +1 -1
- package/dist/adapter/resources/webgl-shader.js.map +1 -1
- package/dist/adapter/resources/webgl-texture.d.ts +5 -5
- package/dist/adapter/resources/webgl-texture.d.ts.map +1 -1
- package/dist/adapter/resources/webgl-texture.js.map +1 -1
- package/dist/adapter/webgl-canvas-context.js.map +1 -1
- package/dist/adapter/webgl-device.js +2 -2
- package/dist/adapter/webgl-device.js.map +1 -1
- package/dist/classic/accessor.d.ts +1 -1
- package/dist/classic/accessor.d.ts.map +1 -1
- package/dist/classic/accessor.js +1 -1
- package/dist/classic/accessor.js.map +1 -1
- package/dist/classic/{buffer.d.ts → buffer-with-accessor.d.ts} +8 -8
- package/dist/classic/buffer-with-accessor.d.ts.map +1 -0
- package/dist/classic/{buffer.js → buffer-with-accessor.js} +3 -3
- package/dist/classic/buffer-with-accessor.js.map +1 -0
- package/dist/classic/clear.d.ts +22 -0
- package/dist/classic/clear.d.ts.map +1 -0
- package/dist/classic/clear.js +88 -0
- package/dist/classic/clear.js.map +1 -0
- package/dist/classic/copy-and-blit.d.ts +45 -0
- package/dist/classic/copy-and-blit.d.ts.map +1 -0
- package/dist/classic/copy-and-blit.js +136 -0
- package/dist/classic/copy-and-blit.js.map +1 -0
- package/dist/classic/format-utils.d.ts +3 -0
- package/dist/classic/format-utils.d.ts.map +1 -0
- package/dist/classic/format-utils.js +38 -0
- package/dist/classic/format-utils.js.map +1 -0
- package/dist/classic/typed-array-utils.js.map +1 -1
- package/dist/context/context/create-browser-context.d.ts +17 -19
- package/dist/context/context/create-browser-context.d.ts.map +1 -1
- package/dist/context/context/create-browser-context.js +4 -4
- package/dist/context/context/create-browser-context.js.map +1 -1
- package/dist/context/context/create-headless-context.d.ts +1 -1
- package/dist/context/context/create-headless-context.d.ts.map +1 -1
- package/dist/context/debug/spector.d.ts +1 -3
- package/dist/context/debug/spector.d.ts.map +1 -1
- package/dist/context/debug/spector.js.map +1 -1
- package/dist/context/debug/webgl-developer-tools.d.ts +1 -1
- package/dist/context/debug/webgl-developer-tools.d.ts.map +1 -1
- package/dist/context/debug/webgl-developer-tools.js +1 -1
- package/dist/context/debug/webgl-developer-tools.js.map +1 -1
- package/dist/context/parameters/webgl-parameter-tables.d.ts +1 -1
- package/dist/context/parameters/webgl-parameter-tables.d.ts.map +1 -1
- package/dist/context/parameters/webgl-parameter-tables.js.map +1 -1
- package/dist/context/polyfill/get-parameter-polyfill.js +3 -3
- package/dist/context/polyfill/get-parameter-polyfill.js.map +1 -1
- package/dist/context/polyfill/polyfill-context.js.map +1 -1
- package/dist/context/polyfill/polyfill-table.js +1 -1
- package/dist/context/polyfill/polyfill-table.js.map +1 -1
- package/dist/context/polyfill/polyfill-vertex-array-object.js.map +1 -1
- package/dist/context/state-tracker/track-context-state.js.map +1 -1
- package/dist/dist.dev.js +251 -83
- package/dist/index.cjs +694 -520
- package/dist/index.d.ts +4 -2
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +3 -1
- package/dist/index.js.map +1 -1
- package/dist/types.d.ts +1 -1
- package/dist/types.d.ts.map +1 -1
- package/dist.min.js +22 -22
- package/package.json +5 -5
- package/src/adapter/converters/device-parameters.ts +1 -1
- package/src/adapter/converters/texture-formats.ts +1 -1
- package/src/adapter/converters/vertex-formats.ts +1 -1
- package/src/adapter/device-helpers/device-limits.ts +1 -1
- package/src/adapter/device-helpers/get-device-info.ts +1 -1
- package/src/adapter/helpers/get-shader-layout.ts +1 -1
- package/src/adapter/helpers/set-uniform.ts +1 -1
- package/src/adapter/objects/constants-to-keys.ts +1 -1
- package/src/adapter/objects/webgl-renderbuffer.ts +1 -1
- package/src/adapter/objects/webgl-resource.ts +1 -1
- package/src/adapter/objects/webgl-vertex-array-object.ts +1 -1
- package/src/adapter/resources/webgl-buffer.ts +1 -1
- package/src/adapter/resources/webgl-command-buffer.ts +1 -1
- package/src/adapter/resources/webgl-framebuffer.ts +1 -1
- package/src/adapter/resources/webgl-render-pipeline.ts +2 -2
- package/src/adapter/resources/webgl-shader.ts +1 -1
- package/src/adapter/webgl-device.ts +2 -2
- package/src/classic/accessor.ts +1 -1
- package/src/classic/{buffer.ts → buffer-with-accessor.ts} +9 -9
- package/src/classic/clear.ts +110 -0
- package/src/classic/copy-and-blit.ts +189 -0
- package/src/classic/format-utils.ts +43 -0
- package/src/context/context/create-browser-context.ts +37 -30
- package/src/context/debug/webgl-developer-tools.ts +1 -1
- package/src/context/polyfill/get-parameter-polyfill.ts +1 -1
- package/src/context/polyfill/polyfill-table.ts +1 -1
- package/src/index.ts +8 -3
- package/dist/classic/buffer.d.ts.map +0 -1
- package/dist/classic/buffer.js.map +0 -1
package/dist/dist.dev.js
CHANGED
|
@@ -32,8 +32,7 @@ var __exports__ = (() => {
|
|
|
32
32
|
var src_exports = {};
|
|
33
33
|
__export(src_exports, {
|
|
34
34
|
Accessor: () => Accessor,
|
|
35
|
-
|
|
36
|
-
ClassicBuffer: () => ClassicBuffer,
|
|
35
|
+
BufferWithAccessor: () => BufferWithAccessor,
|
|
37
36
|
WEBGLBuffer: () => WEBGLBuffer,
|
|
38
37
|
WEBGLCommandEncoder: () => WEBGLCommandEncoder,
|
|
39
38
|
WEBGLFramebuffer: () => WEBGLFramebuffer,
|
|
@@ -52,6 +51,7 @@ var __exports__ = (() => {
|
|
|
52
51
|
_checkFloat32ColorAttachment: () => _checkFloat32ColorAttachment,
|
|
53
52
|
assertWebGL2Context: () => assertWebGL2Context,
|
|
54
53
|
assertWebGLContext: () => assertWebGLContext,
|
|
54
|
+
clear: () => clear,
|
|
55
55
|
convertGLToTextureFormat: () => convertGLToTextureFormat,
|
|
56
56
|
getParameters: () => getParameters,
|
|
57
57
|
getProgramBindings: () => getProgramBindings,
|
|
@@ -62,6 +62,8 @@ var __exports__ = (() => {
|
|
|
62
62
|
polyfillContext: () => polyfillContext,
|
|
63
63
|
popContextState: () => popContextState,
|
|
64
64
|
pushContextState: () => pushContextState,
|
|
65
|
+
readPixelsToArray: () => readPixelsToArray,
|
|
66
|
+
readPixelsToBuffer: () => readPixelsToBuffer,
|
|
65
67
|
registerHeadlessGL: () => registerHeadlessGL,
|
|
66
68
|
resetParameters: () => resetParameters,
|
|
67
69
|
setDeviceParameters: () => setDeviceParameters,
|
|
@@ -175,52 +177,6 @@ var __exports__ = (() => {
|
|
|
175
177
|
return "Unknown";
|
|
176
178
|
}
|
|
177
179
|
|
|
178
|
-
// ../../node_modules/@babel/runtime/helpers/esm/typeof.js
|
|
179
|
-
function _typeof(obj) {
|
|
180
|
-
"@babel/helpers - typeof";
|
|
181
|
-
return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function(obj2) {
|
|
182
|
-
return typeof obj2;
|
|
183
|
-
} : function(obj2) {
|
|
184
|
-
return obj2 && "function" == typeof Symbol && obj2.constructor === Symbol && obj2 !== Symbol.prototype ? "symbol" : typeof obj2;
|
|
185
|
-
}, _typeof(obj);
|
|
186
|
-
}
|
|
187
|
-
|
|
188
|
-
// ../../node_modules/@babel/runtime/helpers/esm/toPrimitive.js
|
|
189
|
-
function _toPrimitive(input, hint2) {
|
|
190
|
-
if (_typeof(input) !== "object" || input === null)
|
|
191
|
-
return input;
|
|
192
|
-
var prim = input[Symbol.toPrimitive];
|
|
193
|
-
if (prim !== void 0) {
|
|
194
|
-
var res = prim.call(input, hint2 || "default");
|
|
195
|
-
if (_typeof(res) !== "object")
|
|
196
|
-
return res;
|
|
197
|
-
throw new TypeError("@@toPrimitive must return a primitive value.");
|
|
198
|
-
}
|
|
199
|
-
return (hint2 === "string" ? String : Number)(input);
|
|
200
|
-
}
|
|
201
|
-
|
|
202
|
-
// ../../node_modules/@babel/runtime/helpers/esm/toPropertyKey.js
|
|
203
|
-
function _toPropertyKey(arg) {
|
|
204
|
-
var key = _toPrimitive(arg, "string");
|
|
205
|
-
return _typeof(key) === "symbol" ? key : String(key);
|
|
206
|
-
}
|
|
207
|
-
|
|
208
|
-
// ../../node_modules/@babel/runtime/helpers/esm/defineProperty.js
|
|
209
|
-
function _defineProperty(obj, key, value) {
|
|
210
|
-
key = _toPropertyKey(key);
|
|
211
|
-
if (key in obj) {
|
|
212
|
-
Object.defineProperty(obj, key, {
|
|
213
|
-
value,
|
|
214
|
-
enumerable: true,
|
|
215
|
-
configurable: true,
|
|
216
|
-
writable: true
|
|
217
|
-
});
|
|
218
|
-
} else {
|
|
219
|
-
obj[key] = value;
|
|
220
|
-
}
|
|
221
|
-
return obj;
|
|
222
|
-
}
|
|
223
|
-
|
|
224
180
|
// ../../node_modules/@probe.gl/log/dist/utils/local-storage.js
|
|
225
181
|
function getStorage(type) {
|
|
226
182
|
try {
|
|
@@ -236,9 +192,9 @@ var __exports__ = (() => {
|
|
|
236
192
|
var LocalStorage = class {
|
|
237
193
|
constructor(id, defaultConfig) {
|
|
238
194
|
let type = arguments.length > 2 && arguments[2] !== void 0 ? arguments[2] : "sessionStorage";
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
195
|
+
this.storage = void 0;
|
|
196
|
+
this.id = void 0;
|
|
197
|
+
this.config = void 0;
|
|
242
198
|
this.storage = getStorage(type);
|
|
243
199
|
this.id = id;
|
|
244
200
|
this.config = defaultConfig;
|
|
@@ -402,13 +358,13 @@ var __exports__ = (() => {
|
|
|
402
358
|
} = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : {
|
|
403
359
|
id: ""
|
|
404
360
|
};
|
|
405
|
-
|
|
406
|
-
|
|
407
|
-
|
|
408
|
-
|
|
409
|
-
|
|
410
|
-
|
|
411
|
-
|
|
361
|
+
this.id = void 0;
|
|
362
|
+
this.VERSION = VERSION;
|
|
363
|
+
this._startTs = getHiResTimestamp();
|
|
364
|
+
this._deltaTs = getHiResTimestamp();
|
|
365
|
+
this._storage = void 0;
|
|
366
|
+
this.userData = {};
|
|
367
|
+
this.LOG_THROTTLE_TIMEOUT = 0;
|
|
412
368
|
this.id = id;
|
|
413
369
|
this.userData = {};
|
|
414
370
|
this._storage = new LocalStorage("__probe-".concat(this.id, "__"), DEFAULT_LOG_CONFIGURATION);
|
|
@@ -606,7 +562,7 @@ var __exports__ = (() => {
|
|
|
606
562
|
return noop;
|
|
607
563
|
}
|
|
608
564
|
};
|
|
609
|
-
|
|
565
|
+
Log.VERSION = VERSION;
|
|
610
566
|
function normalizeLogLevel(logLevel) {
|
|
611
567
|
if (!logLevel) {
|
|
612
568
|
return 0;
|
|
@@ -737,20 +693,20 @@ var __exports__ = (() => {
|
|
|
737
693
|
// ../../node_modules/@probe.gl/stats/dist/lib/stat.js
|
|
738
694
|
var Stat = class {
|
|
739
695
|
constructor(name, type) {
|
|
740
|
-
|
|
741
|
-
|
|
742
|
-
|
|
743
|
-
|
|
744
|
-
|
|
745
|
-
|
|
746
|
-
|
|
747
|
-
|
|
748
|
-
|
|
749
|
-
|
|
750
|
-
|
|
751
|
-
|
|
752
|
-
|
|
753
|
-
|
|
696
|
+
this.name = void 0;
|
|
697
|
+
this.type = void 0;
|
|
698
|
+
this.sampleSize = 1;
|
|
699
|
+
this.time = 0;
|
|
700
|
+
this.count = 0;
|
|
701
|
+
this.samples = 0;
|
|
702
|
+
this.lastTiming = 0;
|
|
703
|
+
this.lastSampleTime = 0;
|
|
704
|
+
this.lastSampleCount = 0;
|
|
705
|
+
this._count = 0;
|
|
706
|
+
this._time = 0;
|
|
707
|
+
this._samples = 0;
|
|
708
|
+
this._startTime = 0;
|
|
709
|
+
this._timerPending = false;
|
|
754
710
|
this.name = name;
|
|
755
711
|
this.type = type;
|
|
756
712
|
this.reset();
|
|
@@ -849,8 +805,8 @@ var __exports__ = (() => {
|
|
|
849
805
|
// ../../node_modules/@probe.gl/stats/dist/lib/stats.js
|
|
850
806
|
var Stats = class {
|
|
851
807
|
constructor(options) {
|
|
852
|
-
|
|
853
|
-
|
|
808
|
+
this.id = void 0;
|
|
809
|
+
this.stats = {};
|
|
854
810
|
this.id = options.id;
|
|
855
811
|
this.stats = {};
|
|
856
812
|
this._initializeStats(options.stats);
|
|
@@ -4333,11 +4289,11 @@ var __exports__ = (() => {
|
|
|
4333
4289
|
webgl2: false
|
|
4334
4290
|
};
|
|
4335
4291
|
}
|
|
4336
|
-
if (props.webgl2) {
|
|
4337
|
-
gl =
|
|
4292
|
+
if (!gl && props.webgl2) {
|
|
4293
|
+
gl = canvas.getContext("webgl2", props);
|
|
4338
4294
|
}
|
|
4339
|
-
if (props.webgl1) {
|
|
4340
|
-
gl =
|
|
4295
|
+
if (!gl && props.webgl1) {
|
|
4296
|
+
gl = canvas.getContext("webgl", props);
|
|
4341
4297
|
}
|
|
4342
4298
|
canvas.removeEventListener("webglcontextcreationerror", onCreateError, false);
|
|
4343
4299
|
if (!gl) {
|
|
@@ -7625,7 +7581,7 @@ void main(void) {}`;
|
|
|
7625
7581
|
}
|
|
7626
7582
|
};
|
|
7627
7583
|
|
|
7628
|
-
// src/classic/buffer.ts
|
|
7584
|
+
// src/classic/buffer-with-accessor.ts
|
|
7629
7585
|
var DEBUG_DATA_LENGTH2 = 10;
|
|
7630
7586
|
var DEPRECATED_PROPS = {
|
|
7631
7587
|
offset: "accessor.offset",
|
|
@@ -7669,7 +7625,7 @@ void main(void) {}`;
|
|
|
7669
7625
|
}
|
|
7670
7626
|
return bufferProps;
|
|
7671
7627
|
}
|
|
7672
|
-
var
|
|
7628
|
+
var BufferWithAccessor = class extends WEBGLBuffer {
|
|
7673
7629
|
constructor(device, props = {}) {
|
|
7674
7630
|
super(WebGLDevice.attach(device), getWEBGLBufferProps(props));
|
|
7675
7631
|
this.setAccessor(Object.assign({}, props, props.accessor));
|
|
@@ -9023,7 +8979,7 @@ ${formattedLog}`)();
|
|
|
9023
8979
|
type,
|
|
9024
8980
|
textureUnit
|
|
9025
8981
|
} = uniformLayout;
|
|
9026
|
-
const value = this.uniforms[name]
|
|
8982
|
+
const value = this.uniforms[name] ?? textureUnit;
|
|
9027
8983
|
if (value !== void 0) {
|
|
9028
8984
|
setUniform(this.device.gl, location, type, value);
|
|
9029
8985
|
}
|
|
@@ -9490,7 +9446,7 @@ ${formattedLog}`)();
|
|
|
9490
9446
|
}
|
|
9491
9447
|
createBuffer(props) {
|
|
9492
9448
|
const newProps = this._getBufferProps(props);
|
|
9493
|
-
return new
|
|
9449
|
+
return new BufferWithAccessor(this, newProps);
|
|
9494
9450
|
}
|
|
9495
9451
|
_createTexture(props) {
|
|
9496
9452
|
return new WEBGLTexture(this, props);
|
|
@@ -9630,6 +9586,218 @@ ${formattedLog}`)();
|
|
|
9630
9586
|
}
|
|
9631
9587
|
return Boolean(gl && gl._version === 2);
|
|
9632
9588
|
}
|
|
9589
|
+
|
|
9590
|
+
// src/classic/clear.ts
|
|
9591
|
+
var GL_DEPTH_BUFFER_BIT2 = 256;
|
|
9592
|
+
var GL_STENCIL_BUFFER_BIT2 = 1024;
|
|
9593
|
+
var GL_COLOR_BUFFER_BIT2 = 16384;
|
|
9594
|
+
var ERR_ARGUMENTS = "clear: bad arguments";
|
|
9595
|
+
function clear(gl, options) {
|
|
9596
|
+
const device = WebGLDevice.attach(gl);
|
|
9597
|
+
const {
|
|
9598
|
+
framebuffer = null,
|
|
9599
|
+
color = null,
|
|
9600
|
+
depth = null,
|
|
9601
|
+
stencil = null
|
|
9602
|
+
} = options || {};
|
|
9603
|
+
const parameters = {};
|
|
9604
|
+
if (framebuffer) {
|
|
9605
|
+
parameters.framebuffer = framebuffer;
|
|
9606
|
+
}
|
|
9607
|
+
let clearFlags = 0;
|
|
9608
|
+
if (color) {
|
|
9609
|
+
clearFlags |= GL_COLOR_BUFFER_BIT2;
|
|
9610
|
+
if (color !== true) {
|
|
9611
|
+
parameters.clearColor = color;
|
|
9612
|
+
}
|
|
9613
|
+
}
|
|
9614
|
+
if (depth) {
|
|
9615
|
+
clearFlags |= GL_DEPTH_BUFFER_BIT2;
|
|
9616
|
+
if (depth !== true) {
|
|
9617
|
+
parameters.clearDepth = depth;
|
|
9618
|
+
}
|
|
9619
|
+
}
|
|
9620
|
+
if (stencil) {
|
|
9621
|
+
clearFlags |= GL_STENCIL_BUFFER_BIT2;
|
|
9622
|
+
if (depth !== true) {
|
|
9623
|
+
parameters.clearStencil = depth;
|
|
9624
|
+
}
|
|
9625
|
+
}
|
|
9626
|
+
assert2(clearFlags !== 0, ERR_ARGUMENTS);
|
|
9627
|
+
withParameters(device.gl, parameters, () => {
|
|
9628
|
+
device.gl.clear(clearFlags);
|
|
9629
|
+
});
|
|
9630
|
+
}
|
|
9631
|
+
|
|
9632
|
+
// src/classic/format-utils.ts
|
|
9633
|
+
function glFormatToComponents(format) {
|
|
9634
|
+
switch (format) {
|
|
9635
|
+
case GL.ALPHA:
|
|
9636
|
+
case GL.R32F:
|
|
9637
|
+
case GL.RED:
|
|
9638
|
+
return 1;
|
|
9639
|
+
case GL.RG32F:
|
|
9640
|
+
case GL.RG:
|
|
9641
|
+
return 2;
|
|
9642
|
+
case GL.RGB:
|
|
9643
|
+
case GL.RGB32F:
|
|
9644
|
+
return 3;
|
|
9645
|
+
case GL.RGBA:
|
|
9646
|
+
case GL.RGBA32F:
|
|
9647
|
+
return 4;
|
|
9648
|
+
default:
|
|
9649
|
+
assert2(false);
|
|
9650
|
+
return 0;
|
|
9651
|
+
}
|
|
9652
|
+
}
|
|
9653
|
+
function glTypeToBytes(type) {
|
|
9654
|
+
switch (type) {
|
|
9655
|
+
case GL.UNSIGNED_BYTE:
|
|
9656
|
+
return 1;
|
|
9657
|
+
case GL.UNSIGNED_SHORT_5_6_5:
|
|
9658
|
+
case GL.UNSIGNED_SHORT_4_4_4_4:
|
|
9659
|
+
case GL.UNSIGNED_SHORT_5_5_5_1:
|
|
9660
|
+
return 2;
|
|
9661
|
+
case GL.FLOAT:
|
|
9662
|
+
return 4;
|
|
9663
|
+
default:
|
|
9664
|
+
assert2(false);
|
|
9665
|
+
return 0;
|
|
9666
|
+
}
|
|
9667
|
+
}
|
|
9668
|
+
|
|
9669
|
+
// src/classic/copy-and-blit.ts
|
|
9670
|
+
function readPixelsToArray(source, options) {
|
|
9671
|
+
const {
|
|
9672
|
+
sourceX = 0,
|
|
9673
|
+
sourceY = 0,
|
|
9674
|
+
sourceFormat = GL.RGBA
|
|
9675
|
+
} = options || {};
|
|
9676
|
+
let {
|
|
9677
|
+
sourceAttachment = GL.COLOR_ATTACHMENT0,
|
|
9678
|
+
// TODO - support gl.readBuffer
|
|
9679
|
+
target = null,
|
|
9680
|
+
// following parameters are auto deduced if not provided
|
|
9681
|
+
sourceWidth,
|
|
9682
|
+
sourceHeight,
|
|
9683
|
+
sourceType
|
|
9684
|
+
} = options || {};
|
|
9685
|
+
const {
|
|
9686
|
+
framebuffer,
|
|
9687
|
+
deleteFramebuffer
|
|
9688
|
+
} = getFramebuffer2(source);
|
|
9689
|
+
assert2(framebuffer);
|
|
9690
|
+
const {
|
|
9691
|
+
gl,
|
|
9692
|
+
handle
|
|
9693
|
+
} = framebuffer;
|
|
9694
|
+
sourceWidth = sourceWidth || framebuffer.width;
|
|
9695
|
+
sourceHeight = sourceHeight || framebuffer.height;
|
|
9696
|
+
if (sourceAttachment === GL.COLOR_ATTACHMENT0 && handle === null) {
|
|
9697
|
+
sourceAttachment = GL.FRONT;
|
|
9698
|
+
}
|
|
9699
|
+
const attachment = sourceAttachment - GL.COLOR_ATTACHMENT0;
|
|
9700
|
+
sourceType = sourceType || framebuffer.colorAttachments[attachment].type;
|
|
9701
|
+
target = getPixelArray(target, sourceType, sourceFormat, sourceWidth, sourceHeight);
|
|
9702
|
+
sourceType = sourceType || getGLTypeFromTypedArray(target);
|
|
9703
|
+
const prevHandle2 = gl.bindFramebuffer(GL.FRAMEBUFFER, handle);
|
|
9704
|
+
gl.readPixels(sourceX, sourceY, sourceWidth, sourceHeight, sourceFormat, sourceType, target);
|
|
9705
|
+
gl.bindFramebuffer(GL.FRAMEBUFFER, prevHandle2 || null);
|
|
9706
|
+
if (deleteFramebuffer) {
|
|
9707
|
+
framebuffer.destroy();
|
|
9708
|
+
}
|
|
9709
|
+
return target;
|
|
9710
|
+
}
|
|
9711
|
+
function readPixelsToBuffer(source, options) {
|
|
9712
|
+
const {
|
|
9713
|
+
sourceX = 0,
|
|
9714
|
+
sourceY = 0,
|
|
9715
|
+
sourceFormat = GL.RGBA,
|
|
9716
|
+
targetByteOffset = 0
|
|
9717
|
+
} = options || {};
|
|
9718
|
+
let {
|
|
9719
|
+
target,
|
|
9720
|
+
sourceWidth,
|
|
9721
|
+
sourceHeight,
|
|
9722
|
+
sourceType
|
|
9723
|
+
} = options || {};
|
|
9724
|
+
const {
|
|
9725
|
+
framebuffer,
|
|
9726
|
+
deleteFramebuffer
|
|
9727
|
+
} = getFramebuffer2(source);
|
|
9728
|
+
assert2(framebuffer);
|
|
9729
|
+
sourceWidth = sourceWidth || framebuffer.width;
|
|
9730
|
+
sourceHeight = sourceHeight || framebuffer.height;
|
|
9731
|
+
const webglFramebuffer = framebuffer;
|
|
9732
|
+
const gl2 = webglFramebuffer.device.assertWebGL2();
|
|
9733
|
+
sourceType = sourceType || (target ? target.type : GL.UNSIGNED_BYTE);
|
|
9734
|
+
if (!target) {
|
|
9735
|
+
const components = glFormatToComponents(sourceFormat);
|
|
9736
|
+
const byteCount = glTypeToBytes(sourceType);
|
|
9737
|
+
const byteLength = targetByteOffset + sourceWidth * sourceHeight * components * byteCount;
|
|
9738
|
+
target = new BufferWithAccessor(gl2, {
|
|
9739
|
+
byteLength,
|
|
9740
|
+
accessor: {
|
|
9741
|
+
type: sourceType,
|
|
9742
|
+
size: components
|
|
9743
|
+
}
|
|
9744
|
+
});
|
|
9745
|
+
}
|
|
9746
|
+
target.bind({
|
|
9747
|
+
target: GL.PIXEL_PACK_BUFFER
|
|
9748
|
+
});
|
|
9749
|
+
withParameters(gl2, {
|
|
9750
|
+
framebuffer
|
|
9751
|
+
}, () => {
|
|
9752
|
+
gl2.readPixels(sourceX, sourceY, sourceWidth, sourceHeight, sourceFormat, sourceType, targetByteOffset);
|
|
9753
|
+
});
|
|
9754
|
+
target.unbind({
|
|
9755
|
+
target: GL.PIXEL_PACK_BUFFER
|
|
9756
|
+
});
|
|
9757
|
+
if (deleteFramebuffer) {
|
|
9758
|
+
framebuffer.destroy();
|
|
9759
|
+
}
|
|
9760
|
+
return target;
|
|
9761
|
+
}
|
|
9762
|
+
function getFramebuffer2(source) {
|
|
9763
|
+
if (!(source instanceof Framebuffer)) {
|
|
9764
|
+
return {
|
|
9765
|
+
framebuffer: toFramebuffer(source),
|
|
9766
|
+
deleteFramebuffer: true
|
|
9767
|
+
};
|
|
9768
|
+
}
|
|
9769
|
+
return {
|
|
9770
|
+
framebuffer: source,
|
|
9771
|
+
deleteFramebuffer: false
|
|
9772
|
+
};
|
|
9773
|
+
}
|
|
9774
|
+
function toFramebuffer(texture, props) {
|
|
9775
|
+
const {
|
|
9776
|
+
device,
|
|
9777
|
+
width,
|
|
9778
|
+
height,
|
|
9779
|
+
id
|
|
9780
|
+
} = texture;
|
|
9781
|
+
const framebuffer = device.createFramebuffer({
|
|
9782
|
+
...props,
|
|
9783
|
+
id: `framebuffer-for-${id}`,
|
|
9784
|
+
width,
|
|
9785
|
+
height,
|
|
9786
|
+
colorAttachments: [texture]
|
|
9787
|
+
});
|
|
9788
|
+
return framebuffer;
|
|
9789
|
+
}
|
|
9790
|
+
function getPixelArray(pixelArray, type, format, width, height) {
|
|
9791
|
+
if (pixelArray) {
|
|
9792
|
+
return pixelArray;
|
|
9793
|
+
}
|
|
9794
|
+
type = type || GL.UNSIGNED_BYTE;
|
|
9795
|
+
const ArrayType = getTypedArrayFromGLType(type, {
|
|
9796
|
+
clamped: false
|
|
9797
|
+
});
|
|
9798
|
+
const components = glFormatToComponents(format);
|
|
9799
|
+
return new ArrayType(width * height * components);
|
|
9800
|
+
}
|
|
9633
9801
|
return __toCommonJS(src_exports);
|
|
9634
9802
|
})();
|
|
9635
9803
|
return __exports__;
|