@predy-js/render-interface 0.3.0-beta.19 → 0.3.0-beta.191

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/index.js CHANGED
@@ -2,7 +2,7 @@
2
2
  * Name: @predy-js/render-interface
3
3
  * Description: undefined
4
4
  * Author: undefined
5
- * Version: v0.3.0-beta.19
5
+ * Version: v0.3.0-beta.191
6
6
  */
7
7
 
8
8
  'use strict';
@@ -23,7 +23,7 @@ LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
23
23
  OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
24
24
  PERFORMANCE OF THIS SOFTWARE.
25
25
  ***************************************************************************** */
26
- /* global Reflect, Promise, SuppressedError, Symbol */
26
+ /* global Reflect, Promise, SuppressedError, Symbol, Iterator */
27
27
 
28
28
  var extendStatics = function(d, b) {
29
29
  extendStatics = Object.setPrototypeOf ||
@@ -155,24 +155,51 @@ exports.TextureSourceType = void 0;
155
155
 
156
156
  var GPUBufferOptionsMemoryShared = 1 << 1;
157
157
 
158
- var _a$6, _b$3;
158
+ var _a$7, _b$3;
159
159
  // @ts-expect-error safe to assign
160
160
  var constants = {};
161
- {
162
- if (typeof WebGL2RenderingContext === 'function') {
163
- copy(WebGL2RenderingContext);
164
- }
165
- else if (typeof WebGLRenderingContext !== 'undefined') {
166
- copy(WebGLRenderingContext);
167
- copy(WebGLRenderingContext.prototype);
168
- }
169
- else {
170
- //ios 16 lockdown mode
171
- consoleError('WebGL not in global');
172
- }
161
+ if (typeof WebGL2RenderingContext === 'function') {
162
+ copy(WebGL2RenderingContext);
173
163
  }
174
- // @ts-expect-error set default value
175
- constants['HALF_FLOAT'] = 5131;
164
+ else if (typeof WebGLRenderingContext !== 'undefined') {
165
+ copy(WebGLRenderingContext);
166
+ copy(WebGLRenderingContext.prototype);
167
+ }
168
+ else {
169
+ //ios 16 lockdown mode
170
+ consoleError('WebGL not in global');
171
+ }
172
+ Object.assign(constants, {
173
+ HALF_FLOAT: 5131,
174
+ COMPRESSED_RGBA_ASTC_4x4_KHR: 0x93B0,
175
+ COMPRESSED_RGBA_ASTC_5x4_KHR: 0x93B1,
176
+ COMPRESSED_RGBA_ASTC_5x5_KHR: 0x93B2,
177
+ COMPRESSED_RGBA_ASTC_6x5_KHR: 0x93B3,
178
+ COMPRESSED_RGBA_ASTC_6x6_KHR: 0x93B4,
179
+ COMPRESSED_RGBA_ASTC_8x5_KHR: 0x93B5,
180
+ COMPRESSED_RGBA_ASTC_8x6_KHR: 0x93B6,
181
+ COMPRESSED_RGBA_ASTC_8x8_KHR: 0x93B7,
182
+ COMPRESSED_RGBA_ASTC_10x5_KHR: 0x93B8,
183
+ COMPRESSED_RGBA_ASTC_10x6_KHR: 0x93B9,
184
+ COMPRESSED_RGBA_ASTC_10x8_KHR: 0x93BA,
185
+ COMPRESSED_RGBA_ASTC_10x10_KHR: 0x93BB,
186
+ COMPRESSED_RGBA_ASTC_12x10_KHR: 0x93BC,
187
+ COMPRESSED_RGBA_ASTC_12x12_KHR: 0x93BD,
188
+ COMPRESSED_SRGB8_ALPHA8_ASTC_4x4_KHR: 0x93D0,
189
+ COMPRESSED_SRGB8_ALPHA8_ASTC_5x4_KHR: 0x93D1,
190
+ COMPRESSED_SRGB8_ALPHA8_ASTC_5x5_KHR: 0x93D2,
191
+ COMPRESSED_SRGB8_ALPHA8_ASTC_6x5_KHR: 0x93D3,
192
+ COMPRESSED_SRGB8_ALPHA8_ASTC_6x6_KHR: 0x93D4,
193
+ COMPRESSED_SRGB8_ALPHA8_ASTC_8x5_KHR: 0x93D5,
194
+ COMPRESSED_SRGB8_ALPHA8_ASTC_8x6_KHR: 0x93D6,
195
+ COMPRESSED_SRGB8_ALPHA8_ASTC_8x8_KHR: 0x93D7,
196
+ COMPRESSED_SRGB8_ALPHA8_ASTC_10x5_KHR: 0x93D8,
197
+ COMPRESSED_SRGB8_ALPHA8_ASTC_10x6_KHR: 0x93D9,
198
+ COMPRESSED_SRGB8_ALPHA8_ASTC_10x8_KHR: 0x93DA,
199
+ COMPRESSED_SRGB8_ALPHA8_ASTC_10x10_KHR: 0x93DB,
200
+ COMPRESSED_SRGB8_ALPHA8_ASTC_12x10_KHR: 0x93DC,
201
+ COMPRESSED_SRGB8_ALPHA8_ASTC_12x12_KHR: 0x93DD,
202
+ });
176
203
  function copy(target) {
177
204
  for (var name_1 in target) {
178
205
  if (/^[A-Z_]/.test(name_1)) {
@@ -181,15 +208,15 @@ function copy(target) {
181
208
  }
182
209
  }
183
210
  }
184
- var map = (_a$6 = {},
185
- _a$6[constants.INT] = Int32Array,
186
- _a$6[constants.FLOAT] = Float32Array,
187
- _a$6[constants.SHORT] = Int16Array,
188
- _a$6[constants.BYTE] = Int8Array,
189
- _a$6[constants.UNSIGNED_BYTE] = Uint8Array,
190
- _a$6[constants.UNSIGNED_INT] = Uint32Array,
191
- _a$6[constants.UNSIGNED_SHORT] = Uint16Array,
192
- _a$6);
211
+ var map = (_a$7 = {},
212
+ _a$7[constants.INT] = Int32Array,
213
+ _a$7[constants.FLOAT] = Float32Array,
214
+ _a$7[constants.SHORT] = Int16Array,
215
+ _a$7[constants.BYTE] = Int8Array,
216
+ _a$7[constants.UNSIGNED_BYTE] = Uint8Array,
217
+ _a$7[constants.UNSIGNED_INT] = Uint32Array,
218
+ _a$7[constants.UNSIGNED_SHORT] = Uint16Array,
219
+ _a$7);
193
220
  function getBytesPerElementByGLType(type) {
194
221
  var _a;
195
222
  return ((_a = map[type]) === null || _a === void 0 ? void 0 : _a.BYTES_PER_ELEMENT) || 0;
@@ -1244,9 +1271,9 @@ function requestAnimationFrame(cb) {
1244
1271
  return window.requestAnimationFrame(cb);
1245
1272
  }
1246
1273
 
1247
- var _a$5;
1248
- var DATA_DICT = (_a$5 = {},
1249
- _a$5[constants.FLOAT] = {
1274
+ var _a$6;
1275
+ var DATA_DICT = (_a$6 = {},
1276
+ _a$6[constants.FLOAT] = {
1250
1277
  name: constants.FLOAT,
1251
1278
  uniform: function (gl, info, value) {
1252
1279
  if (value.length != undefined) {
@@ -1257,79 +1284,79 @@ var DATA_DICT = (_a$5 = {},
1257
1284
  }
1258
1285
  },
1259
1286
  },
1260
- _a$5[constants.FLOAT_VEC2] = {
1287
+ _a$6[constants.FLOAT_VEC2] = {
1261
1288
  name: constants.FLOAT_VEC2,
1262
1289
  uniform: function (gl, info, value) {
1263
1290
  gl.uniform2fv(info.loc, value);
1264
1291
  },
1265
1292
  },
1266
- _a$5[constants.FLOAT_VEC3] = {
1293
+ _a$6[constants.FLOAT_VEC3] = {
1267
1294
  name: constants.FLOAT_VEC3,
1268
1295
  uniform: function (gl, info, value) {
1269
1296
  gl.uniform3fv(info.loc, value);
1270
1297
  },
1271
1298
  },
1272
- _a$5[constants.FLOAT_VEC4] = {
1299
+ _a$6[constants.FLOAT_VEC4] = {
1273
1300
  name: constants.FLOAT_VEC4,
1274
1301
  uniform: function (gl, info, value) {
1275
1302
  gl.uniform4fv(info.loc, value);
1276
1303
  },
1277
1304
  },
1278
- _a$5[constants.FLOAT_MAT2] = {
1305
+ _a$6[constants.FLOAT_MAT2] = {
1279
1306
  name: constants.FLOAT_MAT2,
1280
1307
  uniform: function (gl, info, value) {
1281
1308
  gl.uniformMatrix2fv(info.loc, false, value);
1282
1309
  },
1283
1310
  },
1284
- _a$5[constants.FLOAT_MAT2x3] = {
1311
+ _a$6[constants.FLOAT_MAT2x3] = {
1285
1312
  name: constants.FLOAT_MAT2x3,
1286
1313
  uniform: function (gl, info, value) {
1287
1314
  gl.uniformMatrix2x3fv(info.loc, false, value);
1288
1315
  },
1289
1316
  },
1290
- _a$5[constants.FLOAT_MAT2x4] = {
1317
+ _a$6[constants.FLOAT_MAT2x4] = {
1291
1318
  name: constants.FLOAT_MAT2x4,
1292
1319
  uniform: function (gl, info, value) {
1293
1320
  gl.uniformMatrix2x3fv(info.loc, false, value);
1294
1321
  },
1295
1322
  },
1296
- _a$5[constants.FLOAT_MAT3] = {
1323
+ _a$6[constants.FLOAT_MAT3] = {
1297
1324
  name: constants.FLOAT_MAT3,
1298
1325
  uniform: function (gl, info, value) {
1299
1326
  gl.uniformMatrix3fv(info.loc, false, value);
1300
1327
  },
1301
1328
  },
1302
- _a$5[constants.FLOAT_MAT3x2] = {
1329
+ _a$6[constants.FLOAT_MAT3x2] = {
1303
1330
  name: constants.FLOAT_MAT3x2,
1304
1331
  uniform: function (gl, info, value) {
1305
1332
  gl.uniformMatrix3x2fv(info.loc, false, value);
1306
1333
  },
1307
1334
  },
1308
- _a$5[constants.FLOAT_MAT3x4] = {
1335
+ _a$6[constants.FLOAT_MAT3x4] = {
1309
1336
  name: constants.FLOAT_MAT3x4,
1310
1337
  uniform: function (gl, info, value) {
1311
1338
  gl.uniformMatrix3x4fv(info.loc, false, value);
1312
1339
  },
1313
1340
  },
1314
- _a$5[constants.FLOAT_MAT4] = {
1341
+ _a$6[constants.FLOAT_MAT4] = {
1315
1342
  name: constants.FLOAT_MAT4,
1316
1343
  uniform: function (gl, info, value) {
1317
1344
  gl.uniformMatrix4fv(info.loc, false, value);
1318
1345
  },
1319
1346
  },
1320
- _a$5[constants.FLOAT_MAT4x3] = {
1347
+ _a$6[constants.FLOAT_MAT4x3] = {
1321
1348
  name: constants.FLOAT_MAT4x3,
1322
1349
  uniform: function (gl, info, value) {
1323
1350
  gl.uniformMatrix4x3fv(info.loc, false, value);
1324
1351
  },
1325
1352
  },
1326
- _a$5[constants.FLOAT_MAT4x2] = {
1353
+ _a$6[constants.FLOAT_MAT4x2] = {
1327
1354
  name: constants.FLOAT_MAT4x2,
1328
1355
  uniform: function (gl, info, value) {
1329
1356
  gl.uniformMatrix4x2fv(info.loc, false, value);
1330
1357
  },
1331
1358
  },
1332
- _a$5[constants.INT] = {
1359
+ _a$6[constants.INT] = {
1333
1360
  name: constants.INT,
1334
1361
  uniform: function (gl, info, value) {
1335
1362
  if (value.length != undefined) {
@@ -1340,49 +1367,49 @@ var DATA_DICT = (_a$5 = {},
1340
1367
  }
1341
1368
  },
1342
1369
  },
1343
- _a$5[constants.INT_VEC2] = {
1370
+ _a$6[constants.INT_VEC2] = {
1344
1371
  name: constants.INT_VEC2,
1345
1372
  uniform: function (gl, info, value) {
1346
1373
  gl.uniform2iv(info.loc, value);
1347
1374
  },
1348
1375
  },
1349
- _a$5[constants.INT_VEC3] = {
1376
+ _a$6[constants.INT_VEC3] = {
1350
1377
  name: constants.INT_VEC3,
1351
1378
  uniform: function (gl, info, value) {
1352
1379
  gl.uniform3iv(info.loc, value);
1353
1380
  },
1354
1381
  },
1355
- _a$5[constants.INT_VEC4] = {
1382
+ _a$6[constants.INT_VEC4] = {
1356
1383
  name: constants.INT_VEC4,
1357
1384
  uniform: function (gl, info, value) {
1358
1385
  gl.uniform4iv(info.loc, value);
1359
1386
  },
1360
1387
  },
1361
- _a$5[constants.UNSIGNED_INT] = {
1388
+ _a$6[constants.UNSIGNED_INT] = {
1362
1389
  name: constants.UNSIGNED_INT,
1363
1390
  uniform: function (gl, info, value) {
1364
1391
  gl.uniform1uiv(info.loc, value);
1365
1392
  },
1366
1393
  },
1367
- _a$5[constants.UNSIGNED_INT_VEC2] = {
1394
+ _a$6[constants.UNSIGNED_INT_VEC2] = {
1368
1395
  name: constants.UNSIGNED_INT_VEC2,
1369
1396
  uniform: function (gl, info, value) {
1370
1397
  gl.uniform2uiv(info.loc, value);
1371
1398
  },
1372
1399
  },
1373
- _a$5[constants.UNSIGNED_INT_VEC3] = {
1400
+ _a$6[constants.UNSIGNED_INT_VEC3] = {
1374
1401
  name: constants.UNSIGNED_INT_VEC3,
1375
1402
  uniform: function (gl, info, value) {
1376
1403
  gl.uniform3uiv(info.loc, value);
1377
1404
  },
1378
1405
  },
1379
- _a$5[constants.UNSIGNED_INT_VEC4] = {
1406
+ _a$6[constants.UNSIGNED_INT_VEC4] = {
1380
1407
  name: constants.UNSIGNED_INT_VEC4,
1381
1408
  uniform: function (gl, info, value) {
1382
1409
  gl.uniform4uiv(info.loc, value);
1383
1410
  },
1384
1411
  },
1385
- _a$5[constants.BOOL] = {
1412
+ _a$6[constants.BOOL] = {
1386
1413
  name: constants.BOOL,
1387
1414
  uniform: function (gl, info, value) {
1388
1415
  if (value.length != undefined) {
@@ -1393,33 +1420,33 @@ var DATA_DICT = (_a$5 = {},
1393
1420
  }
1394
1421
  },
1395
1422
  },
1396
- _a$5[constants.BOOL_VEC2] = {
1423
+ _a$6[constants.BOOL_VEC2] = {
1397
1424
  name: constants.BOOL_VEC2,
1398
1425
  uniform: function (gl, info, value) {
1399
1426
  gl.uniform2iv(info.loc, value);
1400
1427
  },
1401
1428
  },
1402
- _a$5[constants.BOOL_VEC4] = {
1429
+ _a$6[constants.BOOL_VEC4] = {
1403
1430
  name: constants.BOOL_VEC4,
1404
1431
  uniform: function (gl, info, value) {
1405
1432
  gl.uniform4iv(info.loc, value);
1406
1433
  },
1407
1434
  },
1408
- _a$5[constants.BOOL_VEC3] = {
1435
+ _a$6[constants.BOOL_VEC3] = {
1409
1436
  name: constants.BOOL_VEC3,
1410
1437
  uniform: function (gl, info, value) {
1411
1438
  gl.uniform3iv(info.loc, value);
1412
1439
  },
1413
1440
  },
1414
- _a$5[constants.SAMPLER_2D] = {
1441
+ _a$6[constants.SAMPLER_2D] = {
1415
1442
  name: constants.SAMPLER_2D,
1416
1443
  uniform: assignTexUniform,
1417
1444
  },
1418
- _a$5[constants.SAMPLER_CUBE] = {
1445
+ _a$6[constants.SAMPLER_CUBE] = {
1419
1446
  name: constants.SAMPLER_CUBE,
1420
1447
  uniform: assignTexUniform,
1421
1448
  },
1422
- _a$5);
1449
+ _a$6);
1423
1450
  function assignTexUniform(gl, info, value, renderer) {
1424
1451
  if (value) {
1425
1452
  if (info.size > 1) {
@@ -1453,7 +1480,7 @@ function assignTextureLoc(gl, info, value, renderer, index) {
1453
1480
  }
1454
1481
  }
1455
1482
 
1456
- var _a$4, _b$2;
1483
+ var _a$5, _b$2;
1457
1484
  var BlockUniformInfoOffset = 1;
1458
1485
  var BlockUniformInfoByteLength = 8;
1459
1486
  var BlockUniformInfoType = 0;
@@ -1566,35 +1593,35 @@ var arrSetter = function (type) { return function setArray(value, info, name, ra
1566
1593
  var setFloat32Array = arrSetter(Float32Array);
1567
1594
  var setInt32Array = arrSetter(Int32Array);
1568
1595
  var setUInt8Array = arrSetter(Uint8Array);
1569
- var MemorySetter = (_a$4 = {},
1570
- _a$4[constants.FLOAT] = numberSetter(Float32Array),
1571
- _a$4[constants.INT] = numberSetter(Int32Array),
1572
- _a$4[constants.UNSIGNED_INT] = numberSetter(Uint32Array),
1573
- _a$4[constants.SHORT] = numberSetter(Int16Array),
1574
- _a$4[constants.BOOL] = numberSetter(Uint8Array),
1575
- _a$4[constants.UNSIGNED_SHORT] = numberSetter(Uint16Array),
1576
- _a$4[constants.FLOAT_VEC2] = setFloat32Array,
1577
- _a$4[constants.FLOAT_VEC3] = setFloat32Array,
1578
- _a$4[constants.FLOAT_VEC4] = setFloat32Array,
1579
- _a$4[constants.FLOAT_MAT2] = setFloat32Array,
1580
- _a$4[constants.FLOAT_MAT3] = setFloat32Array,
1581
- _a$4[constants.FLOAT_MAT4] = setFloat32Array,
1582
- _a$4[constants.FLOAT_MAT2x3] = setFloat32Array,
1583
- _a$4[constants.FLOAT_MAT2x4] = setFloat32Array,
1584
- _a$4[constants.FLOAT_MAT4x3] = setFloat32Array,
1585
- _a$4[constants.FLOAT_MAT4x2] = setFloat32Array,
1586
- _a$4[constants.FLOAT_MAT3x4] = setFloat32Array,
1587
- _a$4[constants.FLOAT_MAT3x2] = setFloat32Array,
1588
- _a$4[constants.INT_VEC2] = setInt32Array,
1589
- _a$4[constants.INT_VEC3] = setInt32Array,
1590
- _a$4[constants.INT_VEC4] = setInt32Array,
1591
- _a$4[constants.UNSIGNED_INT_VEC2] = setInt32Array,
1592
- _a$4[constants.UNSIGNED_INT_VEC3] = setInt32Array,
1593
- _a$4[constants.UNSIGNED_INT_VEC4] = setInt32Array,
1594
- _a$4[constants.BOOL_VEC2] = setUInt8Array,
1595
- _a$4[constants.BOOL_VEC3] = setUInt8Array,
1596
- _a$4[constants.BOOL_VEC4] = setUInt8Array,
1597
- _a$4);
1596
+ var MemorySetter = (_a$5 = {},
1597
+ _a$5[constants.FLOAT] = numberSetter(Float32Array),
1598
+ _a$5[constants.INT] = numberSetter(Int32Array),
1599
+ _a$5[constants.UNSIGNED_INT] = numberSetter(Uint32Array),
1600
+ _a$5[constants.SHORT] = numberSetter(Int16Array),
1601
+ _a$5[constants.BOOL] = numberSetter(Uint8Array),
1602
+ _a$5[constants.UNSIGNED_SHORT] = numberSetter(Uint16Array),
1603
+ _a$5[constants.FLOAT_VEC2] = setFloat32Array,
1604
+ _a$5[constants.FLOAT_VEC3] = setFloat32Array,
1605
+ _a$5[constants.FLOAT_VEC4] = setFloat32Array,
1606
+ _a$5[constants.FLOAT_MAT2] = setFloat32Array,
1607
+ _a$5[constants.FLOAT_MAT3] = setFloat32Array,
1608
+ _a$5[constants.FLOAT_MAT4] = setFloat32Array,
1609
+ _a$5[constants.FLOAT_MAT2x3] = setFloat32Array,
1610
+ _a$5[constants.FLOAT_MAT2x4] = setFloat32Array,
1611
+ _a$5[constants.FLOAT_MAT4x3] = setFloat32Array,
1612
+ _a$5[constants.FLOAT_MAT4x2] = setFloat32Array,
1613
+ _a$5[constants.FLOAT_MAT3x4] = setFloat32Array,
1614
+ _a$5[constants.FLOAT_MAT3x2] = setFloat32Array,
1615
+ _a$5[constants.INT_VEC2] = setInt32Array,
1616
+ _a$5[constants.INT_VEC3] = setInt32Array,
1617
+ _a$5[constants.INT_VEC4] = setInt32Array,
1618
+ _a$5[constants.UNSIGNED_INT_VEC2] = setInt32Array,
1619
+ _a$5[constants.UNSIGNED_INT_VEC3] = setInt32Array,
1620
+ _a$5[constants.UNSIGNED_INT_VEC4] = setInt32Array,
1621
+ _a$5[constants.BOOL_VEC2] = setUInt8Array,
1622
+ _a$5[constants.BOOL_VEC3] = setUInt8Array,
1623
+ _a$5[constants.BOOL_VEC4] = setUInt8Array,
1624
+ _a$5);
1598
1625
  var ItemPerValueMap = (_b$2 = {},
1599
1626
  _b$2[constants.FLOAT] = 1,
1600
1627
  _b$2[constants.INT] = 1,
@@ -1795,13 +1822,18 @@ var GLProgram = /** @class */ (function () {
1795
1822
  }
1796
1823
  };
1797
1824
  GLProgram.prototype.getSemanticValue = function (state, semanticName) {
1798
- var renderPassSemantics = state.currentPass.semantics;
1799
- var renderFrameSemantics = state.currentFrame.semantics;
1800
- if (renderPassSemantics.hasSemanticValue(semanticName)) {
1801
- return renderPassSemantics.getSemanticValue(semanticName, state);
1825
+ if (typeof semanticName === 'function') {
1826
+ return semanticName(state);
1802
1827
  }
1803
- else if (renderFrameSemantics.hasSemanticValue(semanticName)) {
1804
- return renderFrameSemantics.getSemanticValue(semanticName, state);
1828
+ else {
1829
+ var renderPassSemantics = state.currentPass.semantics;
1830
+ var renderFrameSemantics = state.currentFrame.semantics;
1831
+ if (renderPassSemantics.hasSemanticValue(semanticName)) {
1832
+ return renderPassSemantics.getSemanticValue(semanticName, state);
1833
+ }
1834
+ else if (renderFrameSemantics.hasSemanticValue(semanticName)) {
1835
+ return renderFrameSemantics.getSemanticValue(semanticName, state);
1836
+ }
1805
1837
  }
1806
1838
  };
1807
1839
  GLProgram.prototype.setupUniforms = function (state) {
@@ -1942,21 +1974,21 @@ var GLProgram = /** @class */ (function () {
1942
1974
  return GLProgram;
1943
1975
  }());
1944
1976
 
1945
- var _a$3;
1977
+ var _a$4;
1946
1978
  var ShaderType;
1947
1979
  (function (ShaderType) {
1948
1980
  ShaderType[ShaderType["vertex"] = 0] = "vertex";
1949
1981
  ShaderType[ShaderType["fragment"] = 1] = "fragment";
1950
1982
  })(ShaderType || (ShaderType = {}));
1951
- var downgradeKeywords = (_a$3 = {},
1952
- _a$3[ShaderType.vertex] = {
1983
+ var downgradeKeywords = (_a$4 = {},
1984
+ _a$4[ShaderType.vertex] = {
1953
1985
  in: 'attribute',
1954
1986
  out: 'varying',
1955
1987
  },
1956
- _a$3[ShaderType.fragment] = {
1988
+ _a$4[ShaderType.fragment] = {
1957
1989
  in: 'varying',
1958
1990
  },
1959
- _a$3);
1991
+ _a$4);
1960
1992
  var shaderSeed = 1;
1961
1993
  var GLShaderLibrary = /** @class */ (function () {
1962
1994
  function GLShaderLibrary(renderer) {
@@ -2434,7 +2466,7 @@ function registerCompressedTexture(gl) {
2434
2466
  return 0;
2435
2467
  }
2436
2468
 
2437
- var _a$2, _b$1;
2469
+ var _a$3, _b$1;
2438
2470
  var flipCanvas;
2439
2471
  var imageBitMapAvailable$1 = typeof ImageBitmap === 'function' && typeof createImageBitmap == 'function';
2440
2472
  var GLTexture = /** @class */ (function () {
@@ -2771,14 +2803,14 @@ function nearestPowerOfTwo(value) {
2771
2803
  function isPowerOfTwo(value) {
2772
2804
  return (value & (value - 1)) === 0 && value !== 0;
2773
2805
  }
2774
- var FORMAT_HALF_FLOAT = (_a$2 = {},
2775
- _a$2[constants.RGBA] = 34842,
2776
- _a$2[constants.RGB] = 34843,
2777
- _a$2[constants.ALPHA] = 33325,
2778
- _a$2[constants.RED] = 33325,
2779
- _a$2[constants.LUMINANCE_ALPHA] = 33327,
2780
- _a$2[constants.LUMINANCE] = 33325,
2781
- _a$2);
2806
+ var FORMAT_HALF_FLOAT = (_a$3 = {},
2807
+ _a$3[constants.RGBA] = 34842,
2808
+ _a$3[constants.RGB] = 34843,
2809
+ _a$3[constants.ALPHA] = 33325,
2810
+ _a$3[constants.RED] = 33325,
2811
+ _a$3[constants.LUMINANCE_ALPHA] = 33327,
2812
+ _a$3[constants.LUMINANCE] = 33325,
2813
+ _a$3);
2782
2814
  var FORMAT_FLOAT = (_b$1 = {},
2783
2815
  _b$1[constants.RGBA] = 34836,
2784
2816
  _b$1[constants.RGB] = 34837,
@@ -3121,6 +3153,11 @@ var PredyResourceCacheStatus;
3121
3153
  PredyResourceCacheStatus[PredyResourceCacheStatus["cached"] = 1] = "cached";
3122
3154
  PredyResourceCacheStatus[PredyResourceCacheStatus["preloaded"] = 2] = "preloaded";
3123
3155
  })(PredyResourceCacheStatus || (PredyResourceCacheStatus = {}));
3156
+ var PredyTextEncoding;
3157
+ (function (PredyTextEncoding) {
3158
+ PredyTextEncoding[PredyTextEncoding["utf8"] = 0] = "utf8";
3159
+ PredyTextEncoding[PredyTextEncoding["ascii"] = 1] = "ascii";
3160
+ })(PredyTextEncoding || (PredyTextEncoding = {}));
3124
3161
 
3125
3162
  var GLRenderBuffer = /** @class */ (function () {
3126
3163
  function GLRenderBuffer(renderer, options) {
@@ -3568,110 +3605,394 @@ function loadImageAsync(imgOrURL, options) {
3568
3605
  });
3569
3606
  }
3570
3607
 
3571
- var HEADER_LEN = 12 + 13 * 4; // identifier + header elements (not including key value meta-data pairs)
3572
- var COMPRESSED_2D = 0; // uses a gl.compressedTexImage2D()
3573
- //const COMPRESSED_3D = 1; // uses a gl.compressedTexImage3D()
3574
- var TEX_2D = 2; // uses a gl.texImage2D()
3575
- //const TEX_3D = 3; // uses a gl.texImage3D()
3576
- var KhronosTextureContainer = /** @class */ (function () {
3577
- function KhronosTextureContainer(arrayBuffer, facesExpected, baseOffset) {
3578
- if (baseOffset === void 0) { baseOffset = 0; }
3579
- this.arrayBuffer = arrayBuffer;
3580
- this.baseOffset = baseOffset;
3581
- // Test that it is a ktx formatted file, based on the first 12 bytes, character representation is:
3582
- // '´', 'K', 'T', 'X', ' ', '1', '1', 'ª', '\r', '\n', '\x1A', '\n'
3583
- // 0xAB, 0x4B, 0x54, 0x58, 0x20, 0x31, 0x31, 0xBB, 0x0D, 0x0A, 0x1A, 0x0A
3584
- var identifier = new Uint8Array(this.arrayBuffer, this.baseOffset, 12);
3585
- if (identifier[0] !== 0xab ||
3586
- identifier[1] !== 0x4b ||
3587
- identifier[2] !== 0x54 ||
3588
- identifier[3] !== 0x58 ||
3589
- identifier[4] !== 0x20 ||
3590
- identifier[5] !== 0x31 ||
3591
- identifier[6] !== 0x31 ||
3592
- identifier[7] !== 0xbb ||
3593
- identifier[8] !== 0x0d ||
3594
- identifier[9] !== 0x0a ||
3595
- identifier[10] !== 0x1a ||
3596
- identifier[11] !== 0x0a) {
3597
- throw Error('texture missing KTX identifier');
3598
- }
3599
- // load the reset of the header in native-ri 32 bit uint
3600
- var dataSize = Uint32Array.BYTES_PER_ELEMENT;
3601
- var headerDataView = new DataView(this.arrayBuffer, this.baseOffset + 12, 13 * dataSize);
3602
- var endianness = headerDataView.getUint32(0, true);
3603
- var littleEndian = endianness === 0x04030201;
3604
- this.glType = headerDataView.getUint32(1 * dataSize, littleEndian); // must be 0 for compressed textures
3605
- this.glTypeSize = headerDataView.getUint32(2 * dataSize, littleEndian); // must be 1 for compressed textures
3606
- this.glFormat = headerDataView.getUint32(3 * dataSize, littleEndian); // must be 0 for compressed textures
3607
- this.glInternalFormat = headerDataView.getUint32(4 * dataSize, littleEndian); // the value of arg passed to gl.compressedTexImage2D(,,x,,,,)
3608
- this.glBaseInternalFormat = headerDataView.getUint32(5 * dataSize, littleEndian); // specify GL_RGB, GL_RGBA, GL_ALPHA, etc (un-compressed only)
3609
- this.pixelWidth = headerDataView.getUint32(6 * dataSize, littleEndian); // level 0 value of arg passed to gl.compressedTexImage2D(,,,x,,,)
3610
- this.pixelHeight = headerDataView.getUint32(7 * dataSize, littleEndian); // level 0 value of arg passed to gl.compressedTexImage2D(,,,,x,,)
3611
- this.pixelDepth = headerDataView.getUint32(8 * dataSize, littleEndian); // level 0 value of arg passed to gl.compressedTexImage3D(,,,,,x,,)
3612
- this.numberOfArrayElements = headerDataView.getUint32(9 * dataSize, littleEndian); // used for texture arrays
3613
- this.numberOfFaces = headerDataView.getUint32(10 * dataSize, littleEndian); // used for cubemap textures, should either be 1 or 6
3614
- this.numberOfMipmapLevels = headerDataView.getUint32(11 * dataSize, littleEndian); // number of levels; disregard possibility of 0 for compressed textures
3615
- this.bytesOfKeyValueData = headerDataView.getUint32(12 * dataSize, littleEndian); // the amount of space after the header for meta-data
3616
- // value of zero is an indication to generate mipmaps @ runtime. Not usually allowed for compressed, so disregard.
3617
- this.numberOfMipmapLevels = Math.max(1, this.numberOfMipmapLevels);
3618
- if (this.pixelHeight === 0 || this.pixelDepth !== 0) {
3619
- consoleWarn('only 2D textures currently supported');
3620
- return;
3621
- }
3622
- if (this.numberOfArrayElements !== 0) {
3623
- consoleWarn('texture arrays not currently supported');
3624
- return;
3625
- }
3626
- if (this.numberOfFaces !== facesExpected) {
3627
- consoleWarn('number of faces expected' + facesExpected + ', but found ' + this.numberOfFaces);
3628
- return;
3629
- }
3630
- // we now have a completely validated file, so could use existence of loadType as success
3631
- // would need to make this more elaborate & adjust checks above to support more than one load type
3632
- if (this.glType === 0) {
3633
- this.loadType = COMPRESSED_2D;
3634
- }
3635
- else {
3636
- this.loadType = TEX_2D;
3637
- }
3608
+ ///////////////////////////////////////////////////
3609
+ // KTX2 Header.
3610
+ ///////////////////////////////////////////////////
3611
+ const KHR_SUPERCOMPRESSION_NONE = 0;
3612
+ ///////////////////////////////////////////////////
3613
+ // Data Format Descriptor (DFD).
3614
+ ///////////////////////////////////////////////////
3615
+ const KHR_DF_KHR_DESCRIPTORTYPE_BASICFORMAT = 0;
3616
+ const KHR_DF_VENDORID_KHRONOS = 0;
3617
+ const KHR_DF_VERSION = 2;
3618
+ const KHR_DF_MODEL_UNSPECIFIED = 0;
3619
+ const KHR_DF_FLAG_ALPHA_STRAIGHT = 0;
3620
+ const KHR_DF_TRANSFER_SRGB = 2;
3621
+ const KHR_DF_PRIMARIES_BT709 = 1;
3622
+ const KHR_DF_SAMPLE_DATATYPE_SIGNED = 0x40;
3623
+ ///////////////////////////////////////////////////
3624
+ // VK FORMAT.
3625
+ ///////////////////////////////////////////////////
3626
+ const VK_FORMAT_UNDEFINED = 0;
3627
+ const VK_FORMAT_ASTC_4x4_UNORM_BLOCK = 157;
3628
+ const VK_FORMAT_ASTC_4x4_SRGB_BLOCK = 158;
3629
+ const VK_FORMAT_ASTC_5x4_UNORM_BLOCK = 159;
3630
+ const VK_FORMAT_ASTC_5x4_SRGB_BLOCK = 160;
3631
+ const VK_FORMAT_ASTC_5x5_UNORM_BLOCK = 161;
3632
+ const VK_FORMAT_ASTC_5x5_SRGB_BLOCK = 162;
3633
+ const VK_FORMAT_ASTC_6x5_UNORM_BLOCK = 163;
3634
+ const VK_FORMAT_ASTC_6x5_SRGB_BLOCK = 164;
3635
+ const VK_FORMAT_ASTC_6x6_UNORM_BLOCK = 165;
3636
+ const VK_FORMAT_ASTC_6x6_SRGB_BLOCK = 166;
3637
+ const VK_FORMAT_ASTC_8x5_UNORM_BLOCK = 167;
3638
+ const VK_FORMAT_ASTC_8x5_SRGB_BLOCK = 168;
3639
+ const VK_FORMAT_ASTC_8x6_UNORM_BLOCK = 169;
3640
+ const VK_FORMAT_ASTC_8x6_SRGB_BLOCK = 170;
3641
+ const VK_FORMAT_ASTC_8x8_UNORM_BLOCK = 171;
3642
+ const VK_FORMAT_ASTC_8x8_SRGB_BLOCK = 172;
3643
+ const VK_FORMAT_ASTC_10x5_UNORM_BLOCK = 173;
3644
+ const VK_FORMAT_ASTC_10x5_SRGB_BLOCK = 174;
3645
+ const VK_FORMAT_ASTC_10x6_UNORM_BLOCK = 175;
3646
+ const VK_FORMAT_ASTC_10x6_SRGB_BLOCK = 176;
3647
+ const VK_FORMAT_ASTC_10x8_UNORM_BLOCK = 177;
3648
+ const VK_FORMAT_ASTC_10x8_SRGB_BLOCK = 178;
3649
+ const VK_FORMAT_ASTC_10x10_UNORM_BLOCK = 179;
3650
+ const VK_FORMAT_ASTC_10x10_SRGB_BLOCK = 180;
3651
+ const VK_FORMAT_ASTC_12x10_UNORM_BLOCK = 181;
3652
+ const VK_FORMAT_ASTC_12x10_SRGB_BLOCK = 182;
3653
+ const VK_FORMAT_ASTC_12x12_UNORM_BLOCK = 183;
3654
+ const VK_FORMAT_ASTC_12x12_SRGB_BLOCK = 184;
3655
+
3656
+ /**
3657
+ * Represents an unpacked KTX 2.0 texture container. Data for individual mip levels are stored in
3658
+ * the `.levels` array, typically compressed in Basis Universal formats. Additional properties
3659
+ * provide metadata required to process, transcode, and upload these textures.
3660
+ */
3661
+ class KTX2Container {
3662
+ constructor() {
3663
+ /**
3664
+ * Specifies the image format using Vulkan VkFormat enum values. When using Basis Universal
3665
+ * texture formats, `vkFormat` must be VK_FORMAT_UNDEFINED.
3666
+ */
3667
+ this.vkFormat = VK_FORMAT_UNDEFINED;
3668
+ /**
3669
+ * Size of the data type in bytes used to upload the data to a graphics API. When `vkFormat` is
3670
+ * VK_FORMAT_UNDEFINED, `typeSize` must be 1.
3671
+ */
3672
+ this.typeSize = 1;
3673
+ /** Width of the texture image for level 0, in pixels. */
3674
+ this.pixelWidth = 0;
3675
+ /** Height of the texture image for level 0, in pixels. */
3676
+ this.pixelHeight = 0;
3677
+ /** Depth of the texture image for level 0, in pixels (3D textures only). */
3678
+ this.pixelDepth = 0;
3679
+ /** Number of array elements (array textures only). */
3680
+ this.layerCount = 0;
3681
+ /**
3682
+ * Number of cubemap faces. For cubemaps and cubemap arrays, `faceCount` must be 6. For all
3683
+ * other textures, `faceCount` must be 1. Cubemap faces are stored in +X, -X, +Y, -Y, +Z, -Z
3684
+ * order.
3685
+ */
3686
+ this.faceCount = 1;
3687
+ /** Indicates which supercompression scheme has been applied to mip level images, if any. */
3688
+ this.supercompressionScheme = KHR_SUPERCOMPRESSION_NONE;
3689
+ /** Mip levels, ordered largest (original) to smallest (~1px). */
3690
+ this.levels = [];
3691
+ /** Data Format Descriptor. */
3692
+ this.dataFormatDescriptor = [{
3693
+ vendorId: KHR_DF_VENDORID_KHRONOS,
3694
+ descriptorType: KHR_DF_KHR_DESCRIPTORTYPE_BASICFORMAT,
3695
+ descriptorBlockSize: 0,
3696
+ versionNumber: KHR_DF_VERSION,
3697
+ colorModel: KHR_DF_MODEL_UNSPECIFIED,
3698
+ colorPrimaries: KHR_DF_PRIMARIES_BT709,
3699
+ transferFunction: KHR_DF_TRANSFER_SRGB,
3700
+ flags: KHR_DF_FLAG_ALPHA_STRAIGHT,
3701
+ texelBlockDimension: [0, 0, 0, 0],
3702
+ bytesPlane: [0, 0, 0, 0, 0, 0, 0, 0],
3703
+ samples: []
3704
+ }];
3705
+ /** Key/Value Data. */
3706
+ this.keyValue = {};
3707
+ /** Supercompression Global Data. */
3708
+ this.globalData = null;
3709
+ }
3710
+ }
3711
+
3712
+ class BufferReader {
3713
+ constructor(data, byteOffset, byteLength, littleEndian) {
3714
+ this._dataView = void 0;
3715
+ this._littleEndian = void 0;
3716
+ this._offset = void 0;
3717
+ this._dataView = new DataView(data.buffer, data.byteOffset + byteOffset, byteLength);
3718
+ this._littleEndian = littleEndian;
3719
+ this._offset = 0;
3720
+ }
3721
+ _nextUint8() {
3722
+ const value = this._dataView.getUint8(this._offset);
3723
+ this._offset += 1;
3724
+ return value;
3725
+ }
3726
+ _nextUint16() {
3727
+ const value = this._dataView.getUint16(this._offset, this._littleEndian);
3728
+ this._offset += 2;
3729
+ return value;
3730
+ }
3731
+ _nextUint32() {
3732
+ const value = this._dataView.getUint32(this._offset, this._littleEndian);
3733
+ this._offset += 4;
3734
+ return value;
3735
+ }
3736
+ _nextUint64() {
3737
+ const left = this._dataView.getUint32(this._offset, this._littleEndian);
3738
+ const right = this._dataView.getUint32(this._offset + 4, this._littleEndian);
3739
+ // TODO(cleanup): Just test this...
3740
+ // const value = this._littleEndian ? left + (2 ** 32 * right) : (2 ** 32 * left) + right;
3741
+ const value = left + 2 ** 32 * right;
3742
+ this._offset += 8;
3743
+ return value;
3744
+ }
3745
+ _nextInt32() {
3746
+ const value = this._dataView.getInt32(this._offset, this._littleEndian);
3747
+ this._offset += 4;
3748
+ return value;
3749
+ }
3750
+ _nextUint8Array(len) {
3751
+ const value = new Uint8Array(this._dataView.buffer, this._dataView.byteOffset + this._offset, len);
3752
+ this._offset += len;
3753
+ return value;
3754
+ }
3755
+ _skip(bytes) {
3756
+ this._offset += bytes;
3757
+ return this;
3758
+ }
3759
+ _scan(maxByteLength, term = 0x00) {
3760
+ const byteOffset = this._offset;
3761
+ let byteLength = 0;
3762
+ while (this._dataView.getUint8(this._offset) !== term && byteLength < maxByteLength) {
3763
+ byteLength++;
3764
+ this._offset++;
3638
3765
  }
3639
- KhronosTextureContainer.prototype.mipmaps = function (loadMipmaps) {
3640
- var mipmaps = [];
3641
- // initialize width & height for level 1
3642
- var dataOffset = HEADER_LEN + this.bytesOfKeyValueData;
3643
- var width = this.pixelWidth;
3644
- var height = this.pixelHeight;
3645
- var mipmapCount = loadMipmaps ? this.numberOfMipmapLevels : 1;
3646
- for (var level = 0; level < mipmapCount; level++) {
3647
- var imageSize = new Int32Array(this.arrayBuffer, this.baseOffset + dataOffset, 1)[0]; // size per face, since not supporting array cubemaps
3648
- for (var face = 0; face < this.numberOfFaces; face++) {
3649
- var byteArray = new Uint8Array(this.arrayBuffer, this.baseOffset + dataOffset + 4, imageSize);
3650
- mipmaps.push({
3651
- data: byteArray,
3652
- width: width,
3653
- height: height,
3654
- });
3655
- dataOffset += imageSize + 4; // size of the image + 4 for the imageSize field
3656
- dataOffset += 3 - ((imageSize + 3) % 4); // add padding for odd sized image
3657
- }
3658
- width = Math.max(1.0, width * 0.5);
3659
- height = Math.max(1.0, height * 0.5);
3660
- }
3661
- return mipmaps;
3662
- };
3663
- return KhronosTextureContainer;
3664
- }());
3766
+ if (byteLength < maxByteLength) this._offset++;
3767
+ return new Uint8Array(this._dataView.buffer, this._dataView.byteOffset + byteOffset, byteLength);
3768
+ }
3769
+ }
3770
+ ///////////////////////////////////////////////////
3771
+ // KTX2 Header.
3772
+ ///////////////////////////////////////////////////
3773
+ const KTX2_ID = [
3774
+ // '´', 'K', 'T', 'X', '2', '0', 'ª', '\r', '\n', '\x1A', '\n'
3775
+ 0xab, 0x4b, 0x54, 0x58, 0x20, 0x32, 0x30, 0xbb, 0x0d, 0x0a, 0x1a, 0x0a];
3776
+ /** Decodes an ArrayBuffer to text. */
3777
+ function decodeText(buffer) {
3778
+ return new TextDecoder().decode(buffer);
3779
+ }
3780
+
3781
+ /**
3782
+ * Parses a KTX 2.0 file, returning an unpacked {@link KTX2Container} instance with all associated
3783
+ * data. The container's mip levels and other binary data are pointers into the original file, not
3784
+ * copies, so the original file should not be overwritten after reading.
3785
+ *
3786
+ * @param data Bytes of KTX 2.0 file, as Uint8Array or Buffer.
3787
+ */
3788
+ function read(data) {
3789
+ ///////////////////////////////////////////////////
3790
+ // KTX 2.0 Identifier.
3791
+ ///////////////////////////////////////////////////
3792
+ const id = new Uint8Array(data.buffer, data.byteOffset, KTX2_ID.length);
3793
+ if (id[0] !== KTX2_ID[0] ||
3794
+ // '´'
3795
+ id[1] !== KTX2_ID[1] ||
3796
+ // 'K'
3797
+ id[2] !== KTX2_ID[2] ||
3798
+ // 'T'
3799
+ id[3] !== KTX2_ID[3] ||
3800
+ // 'X'
3801
+ id[4] !== KTX2_ID[4] ||
3802
+ // ' '
3803
+ id[5] !== KTX2_ID[5] ||
3804
+ // '2'
3805
+ id[6] !== KTX2_ID[6] ||
3806
+ // '0'
3807
+ id[7] !== KTX2_ID[7] ||
3808
+ // 'ª'
3809
+ id[8] !== KTX2_ID[8] ||
3810
+ // '\r'
3811
+ id[9] !== KTX2_ID[9] ||
3812
+ // '\n'
3813
+ id[10] !== KTX2_ID[10] ||
3814
+ // '\x1A'
3815
+ id[11] !== KTX2_ID[11] // '\n'
3816
+ ) {
3817
+ throw new Error('Missing KTX 2.0 identifier.');
3818
+ }
3819
+ const container = new KTX2Container();
3820
+ ///////////////////////////////////////////////////
3821
+ // Header.
3822
+ ///////////////////////////////////////////////////
3823
+ const headerByteLength = 17 * Uint32Array.BYTES_PER_ELEMENT;
3824
+ const headerReader = new BufferReader(data, KTX2_ID.length, headerByteLength, true);
3825
+ container.vkFormat = headerReader._nextUint32();
3826
+ container.typeSize = headerReader._nextUint32();
3827
+ container.pixelWidth = headerReader._nextUint32();
3828
+ container.pixelHeight = headerReader._nextUint32();
3829
+ container.pixelDepth = headerReader._nextUint32();
3830
+ container.layerCount = headerReader._nextUint32();
3831
+ container.faceCount = headerReader._nextUint32();
3832
+ const levelCount = headerReader._nextUint32();
3833
+ container.supercompressionScheme = headerReader._nextUint32();
3834
+ const dfdByteOffset = headerReader._nextUint32();
3835
+ const dfdByteLength = headerReader._nextUint32();
3836
+ const kvdByteOffset = headerReader._nextUint32();
3837
+ const kvdByteLength = headerReader._nextUint32();
3838
+ const sgdByteOffset = headerReader._nextUint64();
3839
+ const sgdByteLength = headerReader._nextUint64();
3840
+ ///////////////////////////////////////////////////
3841
+ // Level Index.
3842
+ ///////////////////////////////////////////////////
3843
+ const levelByteLength = levelCount * 3 * 8;
3844
+ const levelReader = new BufferReader(data, KTX2_ID.length + headerByteLength, levelByteLength, true);
3845
+ for (let i = 0; i < levelCount; i++) {
3846
+ container.levels.push({
3847
+ levelData: new Uint8Array(data.buffer, data.byteOffset + levelReader._nextUint64(), levelReader._nextUint64()),
3848
+ uncompressedByteLength: levelReader._nextUint64()
3849
+ });
3850
+ }
3851
+ ///////////////////////////////////////////////////
3852
+ // Data Format Descriptor (DFD).
3853
+ ///////////////////////////////////////////////////
3854
+ const dfdReader = new BufferReader(data, dfdByteOffset, dfdByteLength, true);
3855
+ const dfd = {
3856
+ vendorId: dfdReader._skip(4 /* totalSize */)._nextUint16(),
3857
+ descriptorType: dfdReader._nextUint16(),
3858
+ versionNumber: dfdReader._nextUint16(),
3859
+ descriptorBlockSize: dfdReader._nextUint16(),
3860
+ colorModel: dfdReader._nextUint8(),
3861
+ colorPrimaries: dfdReader._nextUint8(),
3862
+ transferFunction: dfdReader._nextUint8(),
3863
+ flags: dfdReader._nextUint8(),
3864
+ texelBlockDimension: [dfdReader._nextUint8(), dfdReader._nextUint8(), dfdReader._nextUint8(), dfdReader._nextUint8()],
3865
+ bytesPlane: [dfdReader._nextUint8(), dfdReader._nextUint8(), dfdReader._nextUint8(), dfdReader._nextUint8(), dfdReader._nextUint8(), dfdReader._nextUint8(), dfdReader._nextUint8(), dfdReader._nextUint8()],
3866
+ samples: []
3867
+ };
3868
+ const sampleStart = 6;
3869
+ const sampleWords = 4;
3870
+ const numSamples = (dfd.descriptorBlockSize / 4 - sampleStart) / sampleWords;
3871
+ for (let i = 0; i < numSamples; i++) {
3872
+ const sample = {
3873
+ bitOffset: dfdReader._nextUint16(),
3874
+ bitLength: dfdReader._nextUint8(),
3875
+ channelType: dfdReader._nextUint8(),
3876
+ samplePosition: [dfdReader._nextUint8(), dfdReader._nextUint8(), dfdReader._nextUint8(), dfdReader._nextUint8()],
3877
+ sampleLower: -Infinity,
3878
+ sampleUpper: Infinity
3879
+ };
3880
+ if (sample.channelType & KHR_DF_SAMPLE_DATATYPE_SIGNED) {
3881
+ sample.sampleLower = dfdReader._nextInt32();
3882
+ sample.sampleUpper = dfdReader._nextInt32();
3883
+ } else {
3884
+ sample.sampleLower = dfdReader._nextUint32();
3885
+ sample.sampleUpper = dfdReader._nextUint32();
3886
+ }
3887
+ dfd.samples[i] = sample;
3888
+ }
3889
+ container.dataFormatDescriptor.length = 0;
3890
+ container.dataFormatDescriptor.push(dfd);
3891
+ ///////////////////////////////////////////////////
3892
+ // Key/Value Data (KVD).
3893
+ ///////////////////////////////////////////////////
3894
+ const kvdReader = new BufferReader(data, kvdByteOffset, kvdByteLength, true);
3895
+ while (kvdReader._offset < kvdByteLength) {
3896
+ const keyValueByteLength = kvdReader._nextUint32();
3897
+ const keyData = kvdReader._scan(keyValueByteLength);
3898
+ const key = decodeText(keyData);
3899
+ container.keyValue[key] = kvdReader._nextUint8Array(keyValueByteLength - keyData.byteLength - 1);
3900
+ if (key.match(/^ktx/i)) {
3901
+ const text = decodeText(container.keyValue[key]);
3902
+ container.keyValue[key] = text.substring(0, text.lastIndexOf('\x00'));
3903
+ }
3904
+ const kvPadding = keyValueByteLength % 4 ? 4 - keyValueByteLength % 4 : 0; // align(4)
3905
+ // 4-byte alignment.
3906
+ kvdReader._skip(kvPadding);
3907
+ }
3908
+ ///////////////////////////////////////////////////
3909
+ // Supercompression Global Data (SGD).
3910
+ ///////////////////////////////////////////////////
3911
+ if (sgdByteLength <= 0) return container;
3912
+ const sgdReader = new BufferReader(data, sgdByteOffset, sgdByteLength, true);
3913
+ const endpointCount = sgdReader._nextUint16();
3914
+ const selectorCount = sgdReader._nextUint16();
3915
+ const endpointsByteLength = sgdReader._nextUint32();
3916
+ const selectorsByteLength = sgdReader._nextUint32();
3917
+ const tablesByteLength = sgdReader._nextUint32();
3918
+ const extendedByteLength = sgdReader._nextUint32();
3919
+ const imageDescs = [];
3920
+ for (let i = 0; i < levelCount; i++) {
3921
+ imageDescs.push({
3922
+ imageFlags: sgdReader._nextUint32(),
3923
+ rgbSliceByteOffset: sgdReader._nextUint32(),
3924
+ rgbSliceByteLength: sgdReader._nextUint32(),
3925
+ alphaSliceByteOffset: sgdReader._nextUint32(),
3926
+ alphaSliceByteLength: sgdReader._nextUint32()
3927
+ });
3928
+ }
3929
+ const endpointsByteOffset = sgdByteOffset + sgdReader._offset;
3930
+ const selectorsByteOffset = endpointsByteOffset + endpointsByteLength;
3931
+ const tablesByteOffset = selectorsByteOffset + selectorsByteLength;
3932
+ const extendedByteOffset = tablesByteOffset + tablesByteLength;
3933
+ const endpointsData = new Uint8Array(data.buffer, data.byteOffset + endpointsByteOffset, endpointsByteLength);
3934
+ const selectorsData = new Uint8Array(data.buffer, data.byteOffset + selectorsByteOffset, selectorsByteLength);
3935
+ const tablesData = new Uint8Array(data.buffer, data.byteOffset + tablesByteOffset, tablesByteLength);
3936
+ const extendedData = new Uint8Array(data.buffer, data.byteOffset + extendedByteOffset, extendedByteLength);
3937
+ container.globalData = {
3938
+ endpointCount,
3939
+ selectorCount,
3940
+ imageDescs,
3941
+ endpointsData,
3942
+ selectorsData,
3943
+ tablesData,
3944
+ extendedData
3945
+ };
3946
+ return container;
3947
+ }
3948
+
3949
+ var _a$2;
3950
+ var formatMap = (_a$2 = {},
3951
+ _a$2[VK_FORMAT_ASTC_4x4_SRGB_BLOCK] = [constants.UNSIGNED_BYTE, constants.COMPRESSED_SRGB8_ALPHA8_ASTC_4x4_KHR],
3952
+ _a$2[VK_FORMAT_ASTC_4x4_UNORM_BLOCK] = [constants.UNSIGNED_BYTE, constants.COMPRESSED_RGBA_ASTC_4x4_KHR],
3953
+ _a$2[VK_FORMAT_ASTC_6x6_SRGB_BLOCK] = [constants.UNSIGNED_BYTE, constants.COMPRESSED_SRGB8_ALPHA8_ASTC_6x6_KHR],
3954
+ _a$2[VK_FORMAT_ASTC_6x6_UNORM_BLOCK] = [constants.UNSIGNED_BYTE, constants.COMPRESSED_RGBA_ASTC_6x6_KHR],
3955
+ _a$2[VK_FORMAT_ASTC_8x8_SRGB_BLOCK] = [constants.UNSIGNED_BYTE, constants.COMPRESSED_SRGB8_ALPHA8_ASTC_8x8_KHR],
3956
+ _a$2[VK_FORMAT_ASTC_8x8_UNORM_BLOCK] = [constants.UNSIGNED_BYTE, constants.COMPRESSED_RGBA_ASTC_8x8_KHR],
3957
+ _a$2[VK_FORMAT_ASTC_10x10_SRGB_BLOCK] = [constants.UNSIGNED_BYTE, constants.COMPRESSED_SRGB8_ALPHA8_ASTC_10x10_KHR],
3958
+ _a$2[VK_FORMAT_ASTC_10x10_UNORM_BLOCK] = [constants.UNSIGNED_BYTE, constants.COMPRESSED_RGBA_ASTC_10x10_KHR],
3959
+ _a$2[VK_FORMAT_ASTC_12x12_SRGB_BLOCK] = [constants.UNSIGNED_BYTE, constants.COMPRESSED_SRGB8_ALPHA8_ASTC_12x12_KHR],
3960
+ _a$2[VK_FORMAT_ASTC_12x12_UNORM_BLOCK] = [constants.UNSIGNED_BYTE, constants.COMPRESSED_RGBA_ASTC_12x12_KHR],
3961
+ _a$2[VK_FORMAT_ASTC_5x5_SRGB_BLOCK] = [constants.UNSIGNED_BYTE, constants.COMPRESSED_SRGB8_ALPHA8_ASTC_5x5_KHR],
3962
+ _a$2[VK_FORMAT_ASTC_5x5_UNORM_BLOCK] = [constants.UNSIGNED_BYTE, constants.COMPRESSED_RGBA_ASTC_5x5_KHR],
3963
+ _a$2[VK_FORMAT_ASTC_5x4_SRGB_BLOCK] = [constants.UNSIGNED_BYTE, constants.COMPRESSED_SRGB8_ALPHA8_ASTC_5x4_KHR],
3964
+ _a$2[VK_FORMAT_ASTC_5x4_UNORM_BLOCK] = [constants.UNSIGNED_BYTE, constants.COMPRESSED_RGBA_ASTC_5x4_KHR],
3965
+ _a$2[VK_FORMAT_ASTC_6x5_SRGB_BLOCK] = [constants.UNSIGNED_BYTE, constants.COMPRESSED_SRGB8_ALPHA8_ASTC_6x5_KHR],
3966
+ _a$2[VK_FORMAT_ASTC_6x5_UNORM_BLOCK] = [constants.UNSIGNED_BYTE, constants.COMPRESSED_RGBA_ASTC_6x5_KHR],
3967
+ _a$2[VK_FORMAT_ASTC_10x5_SRGB_BLOCK] = [constants.UNSIGNED_BYTE, constants.COMPRESSED_SRGB8_ALPHA8_ASTC_10x5_KHR],
3968
+ _a$2[VK_FORMAT_ASTC_10x5_UNORM_BLOCK] = [constants.UNSIGNED_BYTE, constants.COMPRESSED_RGBA_ASTC_10x5_KHR],
3969
+ _a$2[VK_FORMAT_ASTC_8x6_SRGB_BLOCK] = [constants.UNSIGNED_BYTE, constants.COMPRESSED_SRGB8_ALPHA8_ASTC_8x6_KHR],
3970
+ _a$2[VK_FORMAT_ASTC_8x6_UNORM_BLOCK] = [constants.UNSIGNED_BYTE, constants.COMPRESSED_RGBA_ASTC_8x6_KHR],
3971
+ _a$2[VK_FORMAT_ASTC_10x6_SRGB_BLOCK] = [constants.UNSIGNED_BYTE, constants.COMPRESSED_SRGB8_ALPHA8_ASTC_10x6_KHR],
3972
+ _a$2[VK_FORMAT_ASTC_10x6_UNORM_BLOCK] = [constants.UNSIGNED_BYTE, constants.COMPRESSED_RGBA_ASTC_10x6_KHR],
3973
+ _a$2[VK_FORMAT_ASTC_8x5_SRGB_BLOCK] = [constants.UNSIGNED_BYTE, constants.COMPRESSED_SRGB8_ALPHA8_ASTC_8x5_KHR],
3974
+ _a$2[VK_FORMAT_ASTC_8x5_UNORM_BLOCK] = [constants.UNSIGNED_BYTE, constants.COMPRESSED_RGBA_ASTC_8x5_KHR],
3975
+ _a$2[VK_FORMAT_ASTC_12x10_SRGB_BLOCK] = [constants.UNSIGNED_BYTE, constants.COMPRESSED_SRGB8_ALPHA8_ASTC_12x10_KHR],
3976
+ _a$2[VK_FORMAT_ASTC_12x10_UNORM_BLOCK] = [constants.UNSIGNED_BYTE, constants.COMPRESSED_RGBA_ASTC_12x10_KHR],
3977
+ _a$2[VK_FORMAT_ASTC_10x8_SRGB_BLOCK] = [constants.UNSIGNED_BYTE, constants.COMPRESSED_SRGB8_ALPHA8_ASTC_10x8_KHR],
3978
+ _a$2[VK_FORMAT_ASTC_10x8_UNORM_BLOCK] = [constants.UNSIGNED_BYTE, constants.COMPRESSED_RGBA_ASTC_10x8_KHR],
3979
+ _a$2);
3665
3980
  function getCompressedTextureOptions(data) {
3666
- var ktx = new KhronosTextureContainer(data, 1);
3667
- var useMipmaps = ktx.numberOfMipmapLevels >= Math.floor(Math.log2(Math.max(ktx.pixelWidth, ktx.pixelHeight)) + 1);
3981
+ var container = read(data);
3982
+ var width = container.pixelWidth;
3983
+ var height = container.pixelHeight;
3984
+ var pair = formatMap[container.vkFormat];
3668
3985
  return {
3669
3986
  sourceType: exports.TextureSourceType.compressed,
3670
- type: ktx.glType,
3671
- target: ktx.numberOfFaces === 6 ? constants.TEXTURE_CUBE_MAP : constants.TEXTURE_2D,
3672
- internalFormat: ktx.glInternalFormat,
3673
- format: ktx.glFormat,
3674
- mipmaps: ktx.mipmaps(useMipmaps),
3987
+ target: container.faceCount === 6 ? constants.TEXTURE_CUBE_MAP : constants.TEXTURE_2D,
3988
+ format: pair[1],
3989
+ internalFormat: pair[1],
3990
+ type: pair[0],
3991
+ mipmaps: container.levels.map(function (level, i) { return ({
3992
+ data: level.levelData,
3993
+ width: width >> i,
3994
+ height: height >> i,
3995
+ }); }),
3675
3996
  };
3676
3997
  }
3677
3998
 
@@ -3762,7 +4083,7 @@ var MarsTextureFactory = /** @class */ (function () {
3762
4083
  }
3763
4084
  else if (sourceFrom.type === exports.TextureSourceType.compressed) {
3764
4085
  return this.requestBinaryAsync(sourceFrom.url).then(function (arrayBuffer) {
3765
- return Object.assign(getCompressedTextureOptions(arrayBuffer), config, {
4086
+ return Object.assign(getCompressedTextureOptions(new Uint8Array(arrayBuffer)), config, {
3766
4087
  sourceFrom: { url: sourceFrom.url, type: exports.TextureSourceType.compressed },
3767
4088
  });
3768
4089
  }, catchError);
@@ -3861,7 +4182,7 @@ var MarsTextureFactory = /** @class */ (function () {
3861
4182
  return Promise.all(map.map(function (key) { return _this.loadImageAsync(key); }));
3862
4183
  };
3863
4184
  MarsTextureFactory.prototype.loadCompressedTextureFromArrayBuffer = function (arrayBuffer, options) {
3864
- return Object.assign(getCompressedTextureOptions(arrayBuffer), options);
4185
+ return Object.assign(getCompressedTextureOptions(new Uint8Array(arrayBuffer)), options);
3865
4186
  };
3866
4187
  MarsTextureFactory.prototype.reloadTextureAsync = function (texture) {
3867
4188
  var _this = this;
@@ -4486,10 +4807,10 @@ var GLMaterial = /** @class */ (function () {
4486
4807
  webGLState.depthFunc(currentState.depthFunc);
4487
4808
  webGLState.depthRange((_a = currentState.depthRange) === null || _a === void 0 ? void 0 : _a[0], (_b = currentState.depthRange) === null || _b === void 0 ? void 0 : _b[1]);
4488
4809
  }
4810
+ webGLState.frontFace(currentState.frontFace);
4489
4811
  if (currentState.cullFaceEnabled) {
4490
4812
  //face
4491
4813
  webGLState.cullFace(currentState.cullFace);
4492
- webGLState.frontFace(currentState.frontFace);
4493
4814
  }
4494
4815
  if (currentState.polygonOffsetFill) {
4495
4816
  var polygonOffset = currentState.polygonOffset || [0, 0];
@@ -5860,7 +6181,7 @@ var MarsSharedGeometry = /** @class */ (function (_super) {
5860
6181
  return MarsSharedGeometry;
5861
6182
  }(MarsGeometry));
5862
6183
 
5863
- consoleLog('version: ' + "0.3.0-beta.19");
6184
+ consoleLog('version: ' + "0.3.0-beta.191");
5864
6185
  var ModuleMsg = 'RI Package: @predy-js/render-interface';
5865
6186
 
5866
6187
  var RI = /*#__PURE__*/Object.freeze({