@predy-js/render-interface 0.3.0-beta.195 → 0.3.0-beta.197
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 +188 -472
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +188 -472
- package/dist/index.mjs.map +1 -1
- package/dist/src/webgl/KhronosTextureContainer.d.ts +24 -2
- package/dist/statistic.js +1 -1
- package/package.json +1 -1
package/dist/index.mjs
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.
|
5
|
+
* Version: v0.3.0-beta.197
|
6
6
|
*/
|
7
7
|
|
8
8
|
/******************************************************************************
|
@@ -151,7 +151,7 @@ var TextureSourceType;
|
|
151
151
|
|
152
152
|
var GPUBufferOptionsMemoryShared = 1 << 1;
|
153
153
|
|
154
|
-
var _a$
|
154
|
+
var _a$6, _b$3;
|
155
155
|
// @ts-expect-error safe to assign
|
156
156
|
var constants = {};
|
157
157
|
if (typeof WebGL2RenderingContext === 'function') {
|
@@ -204,15 +204,15 @@ function copy(target) {
|
|
204
204
|
}
|
205
205
|
}
|
206
206
|
}
|
207
|
-
var map = (_a$
|
208
|
-
_a$
|
209
|
-
_a$
|
210
|
-
_a$
|
211
|
-
_a$
|
212
|
-
_a$
|
213
|
-
_a$
|
214
|
-
_a$
|
215
|
-
_a$
|
207
|
+
var map = (_a$6 = {},
|
208
|
+
_a$6[constants.INT] = Int32Array,
|
209
|
+
_a$6[constants.FLOAT] = Float32Array,
|
210
|
+
_a$6[constants.SHORT] = Int16Array,
|
211
|
+
_a$6[constants.BYTE] = Int8Array,
|
212
|
+
_a$6[constants.UNSIGNED_BYTE] = Uint8Array,
|
213
|
+
_a$6[constants.UNSIGNED_INT] = Uint32Array,
|
214
|
+
_a$6[constants.UNSIGNED_SHORT] = Uint16Array,
|
215
|
+
_a$6);
|
216
216
|
function getBytesPerElementByGLType(type) {
|
217
217
|
var _a;
|
218
218
|
return ((_a = map[type]) === null || _a === void 0 ? void 0 : _a.BYTES_PER_ELEMENT) || 0;
|
@@ -1267,9 +1267,9 @@ function requestAnimationFrame(cb) {
|
|
1267
1267
|
return window.requestAnimationFrame(cb);
|
1268
1268
|
}
|
1269
1269
|
|
1270
|
-
var _a$
|
1271
|
-
var DATA_DICT = (_a$
|
1272
|
-
_a$
|
1270
|
+
var _a$5;
|
1271
|
+
var DATA_DICT = (_a$5 = {},
|
1272
|
+
_a$5[constants.FLOAT] = {
|
1273
1273
|
name: constants.FLOAT,
|
1274
1274
|
uniform: function (gl, info, value) {
|
1275
1275
|
if (value.length != undefined) {
|
@@ -1280,79 +1280,79 @@ var DATA_DICT = (_a$6 = {},
|
|
1280
1280
|
}
|
1281
1281
|
},
|
1282
1282
|
},
|
1283
|
-
_a$
|
1283
|
+
_a$5[constants.FLOAT_VEC2] = {
|
1284
1284
|
name: constants.FLOAT_VEC2,
|
1285
1285
|
uniform: function (gl, info, value) {
|
1286
1286
|
gl.uniform2fv(info.loc, value);
|
1287
1287
|
},
|
1288
1288
|
},
|
1289
|
-
_a$
|
1289
|
+
_a$5[constants.FLOAT_VEC3] = {
|
1290
1290
|
name: constants.FLOAT_VEC3,
|
1291
1291
|
uniform: function (gl, info, value) {
|
1292
1292
|
gl.uniform3fv(info.loc, value);
|
1293
1293
|
},
|
1294
1294
|
},
|
1295
|
-
_a$
|
1295
|
+
_a$5[constants.FLOAT_VEC4] = {
|
1296
1296
|
name: constants.FLOAT_VEC4,
|
1297
1297
|
uniform: function (gl, info, value) {
|
1298
1298
|
gl.uniform4fv(info.loc, value);
|
1299
1299
|
},
|
1300
1300
|
},
|
1301
|
-
_a$
|
1301
|
+
_a$5[constants.FLOAT_MAT2] = {
|
1302
1302
|
name: constants.FLOAT_MAT2,
|
1303
1303
|
uniform: function (gl, info, value) {
|
1304
1304
|
gl.uniformMatrix2fv(info.loc, false, value);
|
1305
1305
|
},
|
1306
1306
|
},
|
1307
|
-
_a$
|
1307
|
+
_a$5[constants.FLOAT_MAT2x3] = {
|
1308
1308
|
name: constants.FLOAT_MAT2x3,
|
1309
1309
|
uniform: function (gl, info, value) {
|
1310
1310
|
gl.uniformMatrix2x3fv(info.loc, false, value);
|
1311
1311
|
},
|
1312
1312
|
},
|
1313
|
-
_a$
|
1313
|
+
_a$5[constants.FLOAT_MAT2x4] = {
|
1314
1314
|
name: constants.FLOAT_MAT2x4,
|
1315
1315
|
uniform: function (gl, info, value) {
|
1316
1316
|
gl.uniformMatrix2x3fv(info.loc, false, value);
|
1317
1317
|
},
|
1318
1318
|
},
|
1319
|
-
_a$
|
1319
|
+
_a$5[constants.FLOAT_MAT3] = {
|
1320
1320
|
name: constants.FLOAT_MAT3,
|
1321
1321
|
uniform: function (gl, info, value) {
|
1322
1322
|
gl.uniformMatrix3fv(info.loc, false, value);
|
1323
1323
|
},
|
1324
1324
|
},
|
1325
|
-
_a$
|
1325
|
+
_a$5[constants.FLOAT_MAT3x2] = {
|
1326
1326
|
name: constants.FLOAT_MAT3x2,
|
1327
1327
|
uniform: function (gl, info, value) {
|
1328
1328
|
gl.uniformMatrix3x2fv(info.loc, false, value);
|
1329
1329
|
},
|
1330
1330
|
},
|
1331
|
-
_a$
|
1331
|
+
_a$5[constants.FLOAT_MAT3x4] = {
|
1332
1332
|
name: constants.FLOAT_MAT3x4,
|
1333
1333
|
uniform: function (gl, info, value) {
|
1334
1334
|
gl.uniformMatrix3x4fv(info.loc, false, value);
|
1335
1335
|
},
|
1336
1336
|
},
|
1337
|
-
_a$
|
1337
|
+
_a$5[constants.FLOAT_MAT4] = {
|
1338
1338
|
name: constants.FLOAT_MAT4,
|
1339
1339
|
uniform: function (gl, info, value) {
|
1340
1340
|
gl.uniformMatrix4fv(info.loc, false, value);
|
1341
1341
|
},
|
1342
1342
|
},
|
1343
|
-
_a$
|
1343
|
+
_a$5[constants.FLOAT_MAT4x3] = {
|
1344
1344
|
name: constants.FLOAT_MAT4x3,
|
1345
1345
|
uniform: function (gl, info, value) {
|
1346
1346
|
gl.uniformMatrix4x3fv(info.loc, false, value);
|
1347
1347
|
},
|
1348
1348
|
},
|
1349
|
-
_a$
|
1349
|
+
_a$5[constants.FLOAT_MAT4x2] = {
|
1350
1350
|
name: constants.FLOAT_MAT4x2,
|
1351
1351
|
uniform: function (gl, info, value) {
|
1352
1352
|
gl.uniformMatrix4x2fv(info.loc, false, value);
|
1353
1353
|
},
|
1354
1354
|
},
|
1355
|
-
_a$
|
1355
|
+
_a$5[constants.INT] = {
|
1356
1356
|
name: constants.INT,
|
1357
1357
|
uniform: function (gl, info, value) {
|
1358
1358
|
if (value.length != undefined) {
|
@@ -1363,49 +1363,49 @@ var DATA_DICT = (_a$6 = {},
|
|
1363
1363
|
}
|
1364
1364
|
},
|
1365
1365
|
},
|
1366
|
-
_a$
|
1366
|
+
_a$5[constants.INT_VEC2] = {
|
1367
1367
|
name: constants.INT_VEC2,
|
1368
1368
|
uniform: function (gl, info, value) {
|
1369
1369
|
gl.uniform2iv(info.loc, value);
|
1370
1370
|
},
|
1371
1371
|
},
|
1372
|
-
_a$
|
1372
|
+
_a$5[constants.INT_VEC3] = {
|
1373
1373
|
name: constants.INT_VEC3,
|
1374
1374
|
uniform: function (gl, info, value) {
|
1375
1375
|
gl.uniform3iv(info.loc, value);
|
1376
1376
|
},
|
1377
1377
|
},
|
1378
|
-
_a$
|
1378
|
+
_a$5[constants.INT_VEC4] = {
|
1379
1379
|
name: constants.INT_VEC4,
|
1380
1380
|
uniform: function (gl, info, value) {
|
1381
1381
|
gl.uniform4iv(info.loc, value);
|
1382
1382
|
},
|
1383
1383
|
},
|
1384
|
-
_a$
|
1384
|
+
_a$5[constants.UNSIGNED_INT] = {
|
1385
1385
|
name: constants.UNSIGNED_INT,
|
1386
1386
|
uniform: function (gl, info, value) {
|
1387
1387
|
gl.uniform1uiv(info.loc, value);
|
1388
1388
|
},
|
1389
1389
|
},
|
1390
|
-
_a$
|
1390
|
+
_a$5[constants.UNSIGNED_INT_VEC2] = {
|
1391
1391
|
name: constants.UNSIGNED_INT_VEC2,
|
1392
1392
|
uniform: function (gl, info, value) {
|
1393
1393
|
gl.uniform2uiv(info.loc, value);
|
1394
1394
|
},
|
1395
1395
|
},
|
1396
|
-
_a$
|
1396
|
+
_a$5[constants.UNSIGNED_INT_VEC3] = {
|
1397
1397
|
name: constants.UNSIGNED_INT_VEC3,
|
1398
1398
|
uniform: function (gl, info, value) {
|
1399
1399
|
gl.uniform3uiv(info.loc, value);
|
1400
1400
|
},
|
1401
1401
|
},
|
1402
|
-
_a$
|
1402
|
+
_a$5[constants.UNSIGNED_INT_VEC4] = {
|
1403
1403
|
name: constants.UNSIGNED_INT_VEC4,
|
1404
1404
|
uniform: function (gl, info, value) {
|
1405
1405
|
gl.uniform4uiv(info.loc, value);
|
1406
1406
|
},
|
1407
1407
|
},
|
1408
|
-
_a$
|
1408
|
+
_a$5[constants.BOOL] = {
|
1409
1409
|
name: constants.BOOL,
|
1410
1410
|
uniform: function (gl, info, value) {
|
1411
1411
|
if (value.length != undefined) {
|
@@ -1416,33 +1416,33 @@ var DATA_DICT = (_a$6 = {},
|
|
1416
1416
|
}
|
1417
1417
|
},
|
1418
1418
|
},
|
1419
|
-
_a$
|
1419
|
+
_a$5[constants.BOOL_VEC2] = {
|
1420
1420
|
name: constants.BOOL_VEC2,
|
1421
1421
|
uniform: function (gl, info, value) {
|
1422
1422
|
gl.uniform2iv(info.loc, value);
|
1423
1423
|
},
|
1424
1424
|
},
|
1425
|
-
_a$
|
1425
|
+
_a$5[constants.BOOL_VEC4] = {
|
1426
1426
|
name: constants.BOOL_VEC4,
|
1427
1427
|
uniform: function (gl, info, value) {
|
1428
1428
|
gl.uniform4iv(info.loc, value);
|
1429
1429
|
},
|
1430
1430
|
},
|
1431
|
-
_a$
|
1431
|
+
_a$5[constants.BOOL_VEC3] = {
|
1432
1432
|
name: constants.BOOL_VEC3,
|
1433
1433
|
uniform: function (gl, info, value) {
|
1434
1434
|
gl.uniform3iv(info.loc, value);
|
1435
1435
|
},
|
1436
1436
|
},
|
1437
|
-
_a$
|
1437
|
+
_a$5[constants.SAMPLER_2D] = {
|
1438
1438
|
name: constants.SAMPLER_2D,
|
1439
1439
|
uniform: assignTexUniform,
|
1440
1440
|
},
|
1441
|
-
_a$
|
1441
|
+
_a$5[constants.SAMPLER_CUBE] = {
|
1442
1442
|
name: constants.SAMPLER_CUBE,
|
1443
1443
|
uniform: assignTexUniform,
|
1444
1444
|
},
|
1445
|
-
_a$
|
1445
|
+
_a$5);
|
1446
1446
|
function assignTexUniform(gl, info, value, renderer) {
|
1447
1447
|
if (value) {
|
1448
1448
|
if (info.size > 1) {
|
@@ -1476,7 +1476,7 @@ function assignTextureLoc(gl, info, value, renderer, index) {
|
|
1476
1476
|
}
|
1477
1477
|
}
|
1478
1478
|
|
1479
|
-
var _a$
|
1479
|
+
var _a$4, _b$2;
|
1480
1480
|
var BlockUniformInfoOffset = 1;
|
1481
1481
|
var BlockUniformInfoByteLength = 8;
|
1482
1482
|
var BlockUniformInfoType = 0;
|
@@ -1589,35 +1589,35 @@ var arrSetter = function (type) { return function setArray(value, info, name, ra
|
|
1589
1589
|
var setFloat32Array = arrSetter(Float32Array);
|
1590
1590
|
var setInt32Array = arrSetter(Int32Array);
|
1591
1591
|
var setUInt8Array = arrSetter(Uint8Array);
|
1592
|
-
var MemorySetter = (_a$
|
1593
|
-
_a$
|
1594
|
-
_a$
|
1595
|
-
_a$
|
1596
|
-
_a$
|
1597
|
-
_a$
|
1598
|
-
_a$
|
1599
|
-
_a$
|
1600
|
-
_a$
|
1601
|
-
_a$
|
1602
|
-
_a$
|
1603
|
-
_a$
|
1604
|
-
_a$
|
1605
|
-
_a$
|
1606
|
-
_a$
|
1607
|
-
_a$
|
1608
|
-
_a$
|
1609
|
-
_a$
|
1610
|
-
_a$
|
1611
|
-
_a$
|
1612
|
-
_a$
|
1613
|
-
_a$
|
1614
|
-
_a$
|
1615
|
-
_a$
|
1616
|
-
_a$
|
1617
|
-
_a$
|
1618
|
-
_a$
|
1619
|
-
_a$
|
1620
|
-
_a$
|
1592
|
+
var MemorySetter = (_a$4 = {},
|
1593
|
+
_a$4[constants.FLOAT] = numberSetter(Float32Array),
|
1594
|
+
_a$4[constants.INT] = numberSetter(Int32Array),
|
1595
|
+
_a$4[constants.UNSIGNED_INT] = numberSetter(Uint32Array),
|
1596
|
+
_a$4[constants.SHORT] = numberSetter(Int16Array),
|
1597
|
+
_a$4[constants.BOOL] = numberSetter(Uint8Array),
|
1598
|
+
_a$4[constants.UNSIGNED_SHORT] = numberSetter(Uint16Array),
|
1599
|
+
_a$4[constants.FLOAT_VEC2] = setFloat32Array,
|
1600
|
+
_a$4[constants.FLOAT_VEC3] = setFloat32Array,
|
1601
|
+
_a$4[constants.FLOAT_VEC4] = setFloat32Array,
|
1602
|
+
_a$4[constants.FLOAT_MAT2] = setFloat32Array,
|
1603
|
+
_a$4[constants.FLOAT_MAT3] = setFloat32Array,
|
1604
|
+
_a$4[constants.FLOAT_MAT4] = setFloat32Array,
|
1605
|
+
_a$4[constants.FLOAT_MAT2x3] = setFloat32Array,
|
1606
|
+
_a$4[constants.FLOAT_MAT2x4] = setFloat32Array,
|
1607
|
+
_a$4[constants.FLOAT_MAT4x3] = setFloat32Array,
|
1608
|
+
_a$4[constants.FLOAT_MAT4x2] = setFloat32Array,
|
1609
|
+
_a$4[constants.FLOAT_MAT3x4] = setFloat32Array,
|
1610
|
+
_a$4[constants.FLOAT_MAT3x2] = setFloat32Array,
|
1611
|
+
_a$4[constants.INT_VEC2] = setInt32Array,
|
1612
|
+
_a$4[constants.INT_VEC3] = setInt32Array,
|
1613
|
+
_a$4[constants.INT_VEC4] = setInt32Array,
|
1614
|
+
_a$4[constants.UNSIGNED_INT_VEC2] = setInt32Array,
|
1615
|
+
_a$4[constants.UNSIGNED_INT_VEC3] = setInt32Array,
|
1616
|
+
_a$4[constants.UNSIGNED_INT_VEC4] = setInt32Array,
|
1617
|
+
_a$4[constants.BOOL_VEC2] = setUInt8Array,
|
1618
|
+
_a$4[constants.BOOL_VEC3] = setUInt8Array,
|
1619
|
+
_a$4[constants.BOOL_VEC4] = setUInt8Array,
|
1620
|
+
_a$4);
|
1621
1621
|
var ItemPerValueMap = (_b$2 = {},
|
1622
1622
|
_b$2[constants.FLOAT] = 1,
|
1623
1623
|
_b$2[constants.INT] = 1,
|
@@ -1970,21 +1970,21 @@ var GLProgram = /** @class */ (function () {
|
|
1970
1970
|
return GLProgram;
|
1971
1971
|
}());
|
1972
1972
|
|
1973
|
-
var _a$
|
1973
|
+
var _a$3;
|
1974
1974
|
var ShaderType;
|
1975
1975
|
(function (ShaderType) {
|
1976
1976
|
ShaderType[ShaderType["vertex"] = 0] = "vertex";
|
1977
1977
|
ShaderType[ShaderType["fragment"] = 1] = "fragment";
|
1978
1978
|
})(ShaderType || (ShaderType = {}));
|
1979
|
-
var downgradeKeywords = (_a$
|
1980
|
-
_a$
|
1979
|
+
var downgradeKeywords = (_a$3 = {},
|
1980
|
+
_a$3[ShaderType.vertex] = {
|
1981
1981
|
in: 'attribute',
|
1982
1982
|
out: 'varying',
|
1983
1983
|
},
|
1984
|
-
_a$
|
1984
|
+
_a$3[ShaderType.fragment] = {
|
1985
1985
|
in: 'varying',
|
1986
1986
|
},
|
1987
|
-
_a$
|
1987
|
+
_a$3);
|
1988
1988
|
var shaderSeed = 1;
|
1989
1989
|
var GLShaderLibrary = /** @class */ (function () {
|
1990
1990
|
function GLShaderLibrary(renderer) {
|
@@ -2462,7 +2462,7 @@ function registerCompressedTexture(gl) {
|
|
2462
2462
|
return 0;
|
2463
2463
|
}
|
2464
2464
|
|
2465
|
-
var _a$
|
2465
|
+
var _a$2, _b$1;
|
2466
2466
|
var flipCanvas;
|
2467
2467
|
var imageBitMapAvailable$1 = typeof ImageBitmap === 'function' && typeof createImageBitmap == 'function';
|
2468
2468
|
var GLTexture = /** @class */ (function () {
|
@@ -2799,14 +2799,14 @@ function nearestPowerOfTwo(value) {
|
|
2799
2799
|
function isPowerOfTwo(value) {
|
2800
2800
|
return (value & (value - 1)) === 0 && value !== 0;
|
2801
2801
|
}
|
2802
|
-
var FORMAT_HALF_FLOAT = (_a$
|
2803
|
-
_a$
|
2804
|
-
_a$
|
2805
|
-
_a$
|
2806
|
-
_a$
|
2807
|
-
_a$
|
2808
|
-
_a$
|
2809
|
-
_a$
|
2802
|
+
var FORMAT_HALF_FLOAT = (_a$2 = {},
|
2803
|
+
_a$2[constants.RGBA] = 34842,
|
2804
|
+
_a$2[constants.RGB] = 34843,
|
2805
|
+
_a$2[constants.ALPHA] = 33325,
|
2806
|
+
_a$2[constants.RED] = 33325,
|
2807
|
+
_a$2[constants.LUMINANCE_ALPHA] = 33327,
|
2808
|
+
_a$2[constants.LUMINANCE] = 33325,
|
2809
|
+
_a$2);
|
2810
2810
|
var FORMAT_FLOAT = (_b$1 = {},
|
2811
2811
|
_b$1[constants.RGBA] = 34836,
|
2812
2812
|
_b$1[constants.RGB] = 34837,
|
@@ -3601,394 +3601,110 @@ function loadImageAsync(imgOrURL, options) {
|
|
3601
3601
|
});
|
3602
3602
|
}
|
3603
3603
|
|
3604
|
-
|
3605
|
-
//
|
3606
|
-
|
3607
|
-
|
3608
|
-
|
3609
|
-
|
3610
|
-
|
3611
|
-
|
3612
|
-
|
3613
|
-
|
3614
|
-
|
3615
|
-
|
3616
|
-
|
3617
|
-
|
3618
|
-
|
3619
|
-
|
3620
|
-
|
3621
|
-
|
3622
|
-
|
3623
|
-
|
3624
|
-
|
3625
|
-
|
3626
|
-
|
3627
|
-
|
3628
|
-
|
3629
|
-
|
3630
|
-
|
3631
|
-
|
3632
|
-
|
3633
|
-
|
3634
|
-
|
3635
|
-
|
3636
|
-
|
3637
|
-
|
3638
|
-
|
3639
|
-
|
3640
|
-
|
3641
|
-
|
3642
|
-
|
3643
|
-
|
3644
|
-
|
3645
|
-
|
3646
|
-
|
3647
|
-
|
3648
|
-
|
3649
|
-
|
3650
|
-
|
3651
|
-
|
3652
|
-
|
3653
|
-
|
3654
|
-
|
3655
|
-
|
3656
|
-
|
3657
|
-
|
3658
|
-
|
3659
|
-
|
3660
|
-
|
3661
|
-
|
3662
|
-
|
3663
|
-
|
3664
|
-
|
3665
|
-
|
3666
|
-
|
3667
|
-
|
3668
|
-
|
3669
|
-
|
3670
|
-
|
3671
|
-
/** Height of the texture image for level 0, in pixels. */
|
3672
|
-
this.pixelHeight = 0;
|
3673
|
-
/** Depth of the texture image for level 0, in pixels (3D textures only). */
|
3674
|
-
this.pixelDepth = 0;
|
3675
|
-
/** Number of array elements (array textures only). */
|
3676
|
-
this.layerCount = 0;
|
3677
|
-
/**
|
3678
|
-
* Number of cubemap faces. For cubemaps and cubemap arrays, `faceCount` must be 6. For all
|
3679
|
-
* other textures, `faceCount` must be 1. Cubemap faces are stored in +X, -X, +Y, -Y, +Z, -Z
|
3680
|
-
* order.
|
3681
|
-
*/
|
3682
|
-
this.faceCount = 1;
|
3683
|
-
/** Indicates which supercompression scheme has been applied to mip level images, if any. */
|
3684
|
-
this.supercompressionScheme = KHR_SUPERCOMPRESSION_NONE;
|
3685
|
-
/** Mip levels, ordered largest (original) to smallest (~1px). */
|
3686
|
-
this.levels = [];
|
3687
|
-
/** Data Format Descriptor. */
|
3688
|
-
this.dataFormatDescriptor = [{
|
3689
|
-
vendorId: KHR_DF_VENDORID_KHRONOS,
|
3690
|
-
descriptorType: KHR_DF_KHR_DESCRIPTORTYPE_BASICFORMAT,
|
3691
|
-
descriptorBlockSize: 0,
|
3692
|
-
versionNumber: KHR_DF_VERSION,
|
3693
|
-
colorModel: KHR_DF_MODEL_UNSPECIFIED,
|
3694
|
-
colorPrimaries: KHR_DF_PRIMARIES_BT709,
|
3695
|
-
transferFunction: KHR_DF_TRANSFER_SRGB,
|
3696
|
-
flags: KHR_DF_FLAG_ALPHA_STRAIGHT,
|
3697
|
-
texelBlockDimension: [0, 0, 0, 0],
|
3698
|
-
bytesPlane: [0, 0, 0, 0, 0, 0, 0, 0],
|
3699
|
-
samples: []
|
3700
|
-
}];
|
3701
|
-
/** Key/Value Data. */
|
3702
|
-
this.keyValue = {};
|
3703
|
-
/** Supercompression Global Data. */
|
3704
|
-
this.globalData = null;
|
3705
|
-
}
|
3706
|
-
}
|
3707
|
-
|
3708
|
-
class BufferReader {
|
3709
|
-
constructor(data, byteOffset, byteLength, littleEndian) {
|
3710
|
-
this._dataView = void 0;
|
3711
|
-
this._littleEndian = void 0;
|
3712
|
-
this._offset = void 0;
|
3713
|
-
this._dataView = new DataView(data.buffer, data.byteOffset + byteOffset, byteLength);
|
3714
|
-
this._littleEndian = littleEndian;
|
3715
|
-
this._offset = 0;
|
3716
|
-
}
|
3717
|
-
_nextUint8() {
|
3718
|
-
const value = this._dataView.getUint8(this._offset);
|
3719
|
-
this._offset += 1;
|
3720
|
-
return value;
|
3721
|
-
}
|
3722
|
-
_nextUint16() {
|
3723
|
-
const value = this._dataView.getUint16(this._offset, this._littleEndian);
|
3724
|
-
this._offset += 2;
|
3725
|
-
return value;
|
3726
|
-
}
|
3727
|
-
_nextUint32() {
|
3728
|
-
const value = this._dataView.getUint32(this._offset, this._littleEndian);
|
3729
|
-
this._offset += 4;
|
3730
|
-
return value;
|
3731
|
-
}
|
3732
|
-
_nextUint64() {
|
3733
|
-
const left = this._dataView.getUint32(this._offset, this._littleEndian);
|
3734
|
-
const right = this._dataView.getUint32(this._offset + 4, this._littleEndian);
|
3735
|
-
// TODO(cleanup): Just test this...
|
3736
|
-
// const value = this._littleEndian ? left + (2 ** 32 * right) : (2 ** 32 * left) + right;
|
3737
|
-
const value = left + 2 ** 32 * right;
|
3738
|
-
this._offset += 8;
|
3739
|
-
return value;
|
3740
|
-
}
|
3741
|
-
_nextInt32() {
|
3742
|
-
const value = this._dataView.getInt32(this._offset, this._littleEndian);
|
3743
|
-
this._offset += 4;
|
3744
|
-
return value;
|
3745
|
-
}
|
3746
|
-
_nextUint8Array(len) {
|
3747
|
-
const value = new Uint8Array(this._dataView.buffer, this._dataView.byteOffset + this._offset, len);
|
3748
|
-
this._offset += len;
|
3749
|
-
return value;
|
3750
|
-
}
|
3751
|
-
_skip(bytes) {
|
3752
|
-
this._offset += bytes;
|
3753
|
-
return this;
|
3754
|
-
}
|
3755
|
-
_scan(maxByteLength, term = 0x00) {
|
3756
|
-
const byteOffset = this._offset;
|
3757
|
-
let byteLength = 0;
|
3758
|
-
while (this._dataView.getUint8(this._offset) !== term && byteLength < maxByteLength) {
|
3759
|
-
byteLength++;
|
3760
|
-
this._offset++;
|
3761
|
-
}
|
3762
|
-
if (byteLength < maxByteLength) this._offset++;
|
3763
|
-
return new Uint8Array(this._dataView.buffer, this._dataView.byteOffset + byteOffset, byteLength);
|
3764
|
-
}
|
3765
|
-
}
|
3766
|
-
///////////////////////////////////////////////////
|
3767
|
-
// KTX2 Header.
|
3768
|
-
///////////////////////////////////////////////////
|
3769
|
-
const KTX2_ID = [
|
3770
|
-
// '´', 'K', 'T', 'X', '2', '0', 'ª', '\r', '\n', '\x1A', '\n'
|
3771
|
-
0xab, 0x4b, 0x54, 0x58, 0x20, 0x32, 0x30, 0xbb, 0x0d, 0x0a, 0x1a, 0x0a];
|
3772
|
-
/** Decodes an ArrayBuffer to text. */
|
3773
|
-
function decodeText(buffer) {
|
3774
|
-
return new TextDecoder().decode(buffer);
|
3775
|
-
}
|
3776
|
-
|
3777
|
-
/**
|
3778
|
-
* Parses a KTX 2.0 file, returning an unpacked {@link KTX2Container} instance with all associated
|
3779
|
-
* data. The container's mip levels and other binary data are pointers into the original file, not
|
3780
|
-
* copies, so the original file should not be overwritten after reading.
|
3781
|
-
*
|
3782
|
-
* @param data Bytes of KTX 2.0 file, as Uint8Array or Buffer.
|
3783
|
-
*/
|
3784
|
-
function read(data) {
|
3785
|
-
///////////////////////////////////////////////////
|
3786
|
-
// KTX 2.0 Identifier.
|
3787
|
-
///////////////////////////////////////////////////
|
3788
|
-
const id = new Uint8Array(data.buffer, data.byteOffset, KTX2_ID.length);
|
3789
|
-
if (id[0] !== KTX2_ID[0] ||
|
3790
|
-
// '´'
|
3791
|
-
id[1] !== KTX2_ID[1] ||
|
3792
|
-
// 'K'
|
3793
|
-
id[2] !== KTX2_ID[2] ||
|
3794
|
-
// 'T'
|
3795
|
-
id[3] !== KTX2_ID[3] ||
|
3796
|
-
// 'X'
|
3797
|
-
id[4] !== KTX2_ID[4] ||
|
3798
|
-
// ' '
|
3799
|
-
id[5] !== KTX2_ID[5] ||
|
3800
|
-
// '2'
|
3801
|
-
id[6] !== KTX2_ID[6] ||
|
3802
|
-
// '0'
|
3803
|
-
id[7] !== KTX2_ID[7] ||
|
3804
|
-
// 'ª'
|
3805
|
-
id[8] !== KTX2_ID[8] ||
|
3806
|
-
// '\r'
|
3807
|
-
id[9] !== KTX2_ID[9] ||
|
3808
|
-
// '\n'
|
3809
|
-
id[10] !== KTX2_ID[10] ||
|
3810
|
-
// '\x1A'
|
3811
|
-
id[11] !== KTX2_ID[11] // '\n'
|
3812
|
-
) {
|
3813
|
-
throw new Error('Missing KTX 2.0 identifier.');
|
3814
|
-
}
|
3815
|
-
const container = new KTX2Container();
|
3816
|
-
///////////////////////////////////////////////////
|
3817
|
-
// Header.
|
3818
|
-
///////////////////////////////////////////////////
|
3819
|
-
const headerByteLength = 17 * Uint32Array.BYTES_PER_ELEMENT;
|
3820
|
-
const headerReader = new BufferReader(data, KTX2_ID.length, headerByteLength, true);
|
3821
|
-
container.vkFormat = headerReader._nextUint32();
|
3822
|
-
container.typeSize = headerReader._nextUint32();
|
3823
|
-
container.pixelWidth = headerReader._nextUint32();
|
3824
|
-
container.pixelHeight = headerReader._nextUint32();
|
3825
|
-
container.pixelDepth = headerReader._nextUint32();
|
3826
|
-
container.layerCount = headerReader._nextUint32();
|
3827
|
-
container.faceCount = headerReader._nextUint32();
|
3828
|
-
const levelCount = headerReader._nextUint32();
|
3829
|
-
container.supercompressionScheme = headerReader._nextUint32();
|
3830
|
-
const dfdByteOffset = headerReader._nextUint32();
|
3831
|
-
const dfdByteLength = headerReader._nextUint32();
|
3832
|
-
const kvdByteOffset = headerReader._nextUint32();
|
3833
|
-
const kvdByteLength = headerReader._nextUint32();
|
3834
|
-
const sgdByteOffset = headerReader._nextUint64();
|
3835
|
-
const sgdByteLength = headerReader._nextUint64();
|
3836
|
-
///////////////////////////////////////////////////
|
3837
|
-
// Level Index.
|
3838
|
-
///////////////////////////////////////////////////
|
3839
|
-
const levelByteLength = levelCount * 3 * 8;
|
3840
|
-
const levelReader = new BufferReader(data, KTX2_ID.length + headerByteLength, levelByteLength, true);
|
3841
|
-
for (let i = 0; i < levelCount; i++) {
|
3842
|
-
container.levels.push({
|
3843
|
-
levelData: new Uint8Array(data.buffer, data.byteOffset + levelReader._nextUint64(), levelReader._nextUint64()),
|
3844
|
-
uncompressedByteLength: levelReader._nextUint64()
|
3845
|
-
});
|
3846
|
-
}
|
3847
|
-
///////////////////////////////////////////////////
|
3848
|
-
// Data Format Descriptor (DFD).
|
3849
|
-
///////////////////////////////////////////////////
|
3850
|
-
const dfdReader = new BufferReader(data, dfdByteOffset, dfdByteLength, true);
|
3851
|
-
const dfd = {
|
3852
|
-
vendorId: dfdReader._skip(4 /* totalSize */)._nextUint16(),
|
3853
|
-
descriptorType: dfdReader._nextUint16(),
|
3854
|
-
versionNumber: dfdReader._nextUint16(),
|
3855
|
-
descriptorBlockSize: dfdReader._nextUint16(),
|
3856
|
-
colorModel: dfdReader._nextUint8(),
|
3857
|
-
colorPrimaries: dfdReader._nextUint8(),
|
3858
|
-
transferFunction: dfdReader._nextUint8(),
|
3859
|
-
flags: dfdReader._nextUint8(),
|
3860
|
-
texelBlockDimension: [dfdReader._nextUint8(), dfdReader._nextUint8(), dfdReader._nextUint8(), dfdReader._nextUint8()],
|
3861
|
-
bytesPlane: [dfdReader._nextUint8(), dfdReader._nextUint8(), dfdReader._nextUint8(), dfdReader._nextUint8(), dfdReader._nextUint8(), dfdReader._nextUint8(), dfdReader._nextUint8(), dfdReader._nextUint8()],
|
3862
|
-
samples: []
|
3863
|
-
};
|
3864
|
-
const sampleStart = 6;
|
3865
|
-
const sampleWords = 4;
|
3866
|
-
const numSamples = (dfd.descriptorBlockSize / 4 - sampleStart) / sampleWords;
|
3867
|
-
for (let i = 0; i < numSamples; i++) {
|
3868
|
-
const sample = {
|
3869
|
-
bitOffset: dfdReader._nextUint16(),
|
3870
|
-
bitLength: dfdReader._nextUint8(),
|
3871
|
-
channelType: dfdReader._nextUint8(),
|
3872
|
-
samplePosition: [dfdReader._nextUint8(), dfdReader._nextUint8(), dfdReader._nextUint8(), dfdReader._nextUint8()],
|
3873
|
-
sampleLower: -Infinity,
|
3874
|
-
sampleUpper: Infinity
|
3875
|
-
};
|
3876
|
-
if (sample.channelType & KHR_DF_SAMPLE_DATATYPE_SIGNED) {
|
3877
|
-
sample.sampleLower = dfdReader._nextInt32();
|
3878
|
-
sample.sampleUpper = dfdReader._nextInt32();
|
3879
|
-
} else {
|
3880
|
-
sample.sampleLower = dfdReader._nextUint32();
|
3881
|
-
sample.sampleUpper = dfdReader._nextUint32();
|
3882
|
-
}
|
3883
|
-
dfd.samples[i] = sample;
|
3884
|
-
}
|
3885
|
-
container.dataFormatDescriptor.length = 0;
|
3886
|
-
container.dataFormatDescriptor.push(dfd);
|
3887
|
-
///////////////////////////////////////////////////
|
3888
|
-
// Key/Value Data (KVD).
|
3889
|
-
///////////////////////////////////////////////////
|
3890
|
-
const kvdReader = new BufferReader(data, kvdByteOffset, kvdByteLength, true);
|
3891
|
-
while (kvdReader._offset < kvdByteLength) {
|
3892
|
-
const keyValueByteLength = kvdReader._nextUint32();
|
3893
|
-
const keyData = kvdReader._scan(keyValueByteLength);
|
3894
|
-
const key = decodeText(keyData);
|
3895
|
-
container.keyValue[key] = kvdReader._nextUint8Array(keyValueByteLength - keyData.byteLength - 1);
|
3896
|
-
if (key.match(/^ktx/i)) {
|
3897
|
-
const text = decodeText(container.keyValue[key]);
|
3898
|
-
container.keyValue[key] = text.substring(0, text.lastIndexOf('\x00'));
|
3604
|
+
var HEADER_LEN = 12 + 13 * 4; // identifier + header elements (not including key value meta-data pairs)
|
3605
|
+
var COMPRESSED_2D = 0; // uses a gl.compressedTexImage2D()
|
3606
|
+
//const COMPRESSED_3D = 1; // uses a gl.compressedTexImage3D()
|
3607
|
+
var TEX_2D = 2; // uses a gl.texImage2D()
|
3608
|
+
//const TEX_3D = 3; // uses a gl.texImage3D()
|
3609
|
+
var KhronosTextureContainer = /** @class */ (function () {
|
3610
|
+
function KhronosTextureContainer(arrayBuffer, facesExpected, baseOffset) {
|
3611
|
+
if (baseOffset === void 0) { baseOffset = 0; }
|
3612
|
+
this.arrayBuffer = arrayBuffer;
|
3613
|
+
this.baseOffset = baseOffset;
|
3614
|
+
// Test that it is a ktx formatted file, based on the first 12 bytes, character representation is:
|
3615
|
+
// '´', 'K', 'T', 'X', ' ', '1', '1', 'ª', '\r', '\n', '\x1A', '\n'
|
3616
|
+
// 0xAB, 0x4B, 0x54, 0x58, 0x20, 0x31, 0x31, 0xBB, 0x0D, 0x0A, 0x1A, 0x0A
|
3617
|
+
var identifier = new Uint8Array(this.arrayBuffer, this.baseOffset, 12);
|
3618
|
+
if (identifier[0] !== 0xab ||
|
3619
|
+
identifier[1] !== 0x4b ||
|
3620
|
+
identifier[2] !== 0x54 ||
|
3621
|
+
identifier[3] !== 0x58 ||
|
3622
|
+
identifier[4] !== 0x20 ||
|
3623
|
+
identifier[5] !== 0x31 ||
|
3624
|
+
identifier[6] !== 0x31 ||
|
3625
|
+
identifier[7] !== 0xbb ||
|
3626
|
+
identifier[8] !== 0x0d ||
|
3627
|
+
identifier[9] !== 0x0a ||
|
3628
|
+
identifier[10] !== 0x1a ||
|
3629
|
+
identifier[11] !== 0x0a) {
|
3630
|
+
throw Error('texture missing KTX identifier');
|
3631
|
+
}
|
3632
|
+
// load the reset of the header in native 32 bit uint
|
3633
|
+
var dataSize = Uint32Array.BYTES_PER_ELEMENT;
|
3634
|
+
var headerDataView = new DataView(this.arrayBuffer, this.baseOffset + 12, 13 * dataSize);
|
3635
|
+
var endianness = headerDataView.getUint32(0, true);
|
3636
|
+
var littleEndian = endianness === 0x04030201;
|
3637
|
+
this.glType = headerDataView.getUint32(1 * dataSize, littleEndian); // must be 0 for compressed textures
|
3638
|
+
this.glTypeSize = headerDataView.getUint32(2 * dataSize, littleEndian); // must be 1 for compressed textures
|
3639
|
+
this.glFormat = headerDataView.getUint32(3 * dataSize, littleEndian); // must be 0 for compressed textures
|
3640
|
+
this.glInternalFormat = headerDataView.getUint32(4 * dataSize, littleEndian); // the value of arg passed to gl.compressedTexImage2D(,,x,,,,)
|
3641
|
+
this.glBaseInternalFormat = headerDataView.getUint32(5 * dataSize, littleEndian); // specify GL_RGB, GL_RGBA, GL_ALPHA, etc (un-compressed only)
|
3642
|
+
this.pixelWidth = headerDataView.getUint32(6 * dataSize, littleEndian); // level 0 value of arg passed to gl.compressedTexImage2D(,,,x,,,)
|
3643
|
+
this.pixelHeight = headerDataView.getUint32(7 * dataSize, littleEndian); // level 0 value of arg passed to gl.compressedTexImage2D(,,,,x,,)
|
3644
|
+
this.pixelDepth = headerDataView.getUint32(8 * dataSize, littleEndian); // level 0 value of arg passed to gl.compressedTexImage3D(,,,,,x,,)
|
3645
|
+
this.numberOfArrayElements = headerDataView.getUint32(9 * dataSize, littleEndian); // used for texture arrays
|
3646
|
+
this.numberOfFaces = headerDataView.getUint32(10 * dataSize, littleEndian); // used for cubemap textures, should either be 1 or 6
|
3647
|
+
this.numberOfMipmapLevels = headerDataView.getUint32(11 * dataSize, littleEndian); // number of levels; disregard possibility of 0 for compressed textures
|
3648
|
+
this.bytesOfKeyValueData = headerDataView.getUint32(12 * dataSize, littleEndian); // the amount of space after the header for meta-data
|
3649
|
+
// value of zero is an indication to generate mipmaps @ runtime. Not usually allowed for compressed, so disregard.
|
3650
|
+
this.numberOfMipmapLevels = Math.max(1, this.numberOfMipmapLevels);
|
3651
|
+
if (this.pixelHeight === 0 || this.pixelDepth !== 0) {
|
3652
|
+
//consoleWarn('only 2D textures currently supported');
|
3653
|
+
return;
|
3654
|
+
}
|
3655
|
+
if (this.numberOfArrayElements !== 0) {
|
3656
|
+
//consoleWarn('texture arrays not currently supported');
|
3657
|
+
return;
|
3658
|
+
}
|
3659
|
+
if (this.numberOfFaces !== facesExpected) {
|
3660
|
+
//consoleWarn('number of faces expected' + facesExpected + ', but found ' + this.numberOfFaces);
|
3661
|
+
return;
|
3662
|
+
}
|
3663
|
+
// we now have a completely validated file, so could use existence of loadType as success
|
3664
|
+
// would need to make this more elaborate & adjust checks above to support more than one load type
|
3665
|
+
if (this.glType === 0) {
|
3666
|
+
this.loadType = COMPRESSED_2D;
|
3667
|
+
}
|
3668
|
+
else {
|
3669
|
+
this.loadType = TEX_2D;
|
3670
|
+
}
|
3899
3671
|
}
|
3900
|
-
|
3901
|
-
|
3902
|
-
|
3903
|
-
|
3904
|
-
|
3905
|
-
|
3906
|
-
|
3907
|
-
|
3908
|
-
|
3909
|
-
|
3910
|
-
|
3911
|
-
|
3912
|
-
|
3913
|
-
|
3914
|
-
|
3915
|
-
|
3916
|
-
|
3917
|
-
|
3918
|
-
|
3919
|
-
|
3920
|
-
|
3921
|
-
|
3922
|
-
|
3923
|
-
}
|
3924
|
-
|
3925
|
-
|
3926
|
-
const selectorsByteOffset = endpointsByteOffset + endpointsByteLength;
|
3927
|
-
const tablesByteOffset = selectorsByteOffset + selectorsByteLength;
|
3928
|
-
const extendedByteOffset = tablesByteOffset + tablesByteLength;
|
3929
|
-
const endpointsData = new Uint8Array(data.buffer, data.byteOffset + endpointsByteOffset, endpointsByteLength);
|
3930
|
-
const selectorsData = new Uint8Array(data.buffer, data.byteOffset + selectorsByteOffset, selectorsByteLength);
|
3931
|
-
const tablesData = new Uint8Array(data.buffer, data.byteOffset + tablesByteOffset, tablesByteLength);
|
3932
|
-
const extendedData = new Uint8Array(data.buffer, data.byteOffset + extendedByteOffset, extendedByteLength);
|
3933
|
-
container.globalData = {
|
3934
|
-
endpointCount,
|
3935
|
-
selectorCount,
|
3936
|
-
imageDescs,
|
3937
|
-
endpointsData,
|
3938
|
-
selectorsData,
|
3939
|
-
tablesData,
|
3940
|
-
extendedData
|
3941
|
-
};
|
3942
|
-
return container;
|
3943
|
-
}
|
3944
|
-
|
3945
|
-
var _a$2;
|
3946
|
-
var formatMap = (_a$2 = {},
|
3947
|
-
_a$2[VK_FORMAT_ASTC_4x4_SRGB_BLOCK] = [constants.UNSIGNED_BYTE, constants.COMPRESSED_SRGB8_ALPHA8_ASTC_4x4_KHR],
|
3948
|
-
_a$2[VK_FORMAT_ASTC_4x4_UNORM_BLOCK] = [constants.UNSIGNED_BYTE, constants.COMPRESSED_RGBA_ASTC_4x4_KHR],
|
3949
|
-
_a$2[VK_FORMAT_ASTC_6x6_SRGB_BLOCK] = [constants.UNSIGNED_BYTE, constants.COMPRESSED_SRGB8_ALPHA8_ASTC_6x6_KHR],
|
3950
|
-
_a$2[VK_FORMAT_ASTC_6x6_UNORM_BLOCK] = [constants.UNSIGNED_BYTE, constants.COMPRESSED_RGBA_ASTC_6x6_KHR],
|
3951
|
-
_a$2[VK_FORMAT_ASTC_8x8_SRGB_BLOCK] = [constants.UNSIGNED_BYTE, constants.COMPRESSED_SRGB8_ALPHA8_ASTC_8x8_KHR],
|
3952
|
-
_a$2[VK_FORMAT_ASTC_8x8_UNORM_BLOCK] = [constants.UNSIGNED_BYTE, constants.COMPRESSED_RGBA_ASTC_8x8_KHR],
|
3953
|
-
_a$2[VK_FORMAT_ASTC_10x10_SRGB_BLOCK] = [constants.UNSIGNED_BYTE, constants.COMPRESSED_SRGB8_ALPHA8_ASTC_10x10_KHR],
|
3954
|
-
_a$2[VK_FORMAT_ASTC_10x10_UNORM_BLOCK] = [constants.UNSIGNED_BYTE, constants.COMPRESSED_RGBA_ASTC_10x10_KHR],
|
3955
|
-
_a$2[VK_FORMAT_ASTC_12x12_SRGB_BLOCK] = [constants.UNSIGNED_BYTE, constants.COMPRESSED_SRGB8_ALPHA8_ASTC_12x12_KHR],
|
3956
|
-
_a$2[VK_FORMAT_ASTC_12x12_UNORM_BLOCK] = [constants.UNSIGNED_BYTE, constants.COMPRESSED_RGBA_ASTC_12x12_KHR],
|
3957
|
-
_a$2[VK_FORMAT_ASTC_5x5_SRGB_BLOCK] = [constants.UNSIGNED_BYTE, constants.COMPRESSED_SRGB8_ALPHA8_ASTC_5x5_KHR],
|
3958
|
-
_a$2[VK_FORMAT_ASTC_5x5_UNORM_BLOCK] = [constants.UNSIGNED_BYTE, constants.COMPRESSED_RGBA_ASTC_5x5_KHR],
|
3959
|
-
_a$2[VK_FORMAT_ASTC_5x4_SRGB_BLOCK] = [constants.UNSIGNED_BYTE, constants.COMPRESSED_SRGB8_ALPHA8_ASTC_5x4_KHR],
|
3960
|
-
_a$2[VK_FORMAT_ASTC_5x4_UNORM_BLOCK] = [constants.UNSIGNED_BYTE, constants.COMPRESSED_RGBA_ASTC_5x4_KHR],
|
3961
|
-
_a$2[VK_FORMAT_ASTC_6x5_SRGB_BLOCK] = [constants.UNSIGNED_BYTE, constants.COMPRESSED_SRGB8_ALPHA8_ASTC_6x5_KHR],
|
3962
|
-
_a$2[VK_FORMAT_ASTC_6x5_UNORM_BLOCK] = [constants.UNSIGNED_BYTE, constants.COMPRESSED_RGBA_ASTC_6x5_KHR],
|
3963
|
-
_a$2[VK_FORMAT_ASTC_10x5_SRGB_BLOCK] = [constants.UNSIGNED_BYTE, constants.COMPRESSED_SRGB8_ALPHA8_ASTC_10x5_KHR],
|
3964
|
-
_a$2[VK_FORMAT_ASTC_10x5_UNORM_BLOCK] = [constants.UNSIGNED_BYTE, constants.COMPRESSED_RGBA_ASTC_10x5_KHR],
|
3965
|
-
_a$2[VK_FORMAT_ASTC_8x6_SRGB_BLOCK] = [constants.UNSIGNED_BYTE, constants.COMPRESSED_SRGB8_ALPHA8_ASTC_8x6_KHR],
|
3966
|
-
_a$2[VK_FORMAT_ASTC_8x6_UNORM_BLOCK] = [constants.UNSIGNED_BYTE, constants.COMPRESSED_RGBA_ASTC_8x6_KHR],
|
3967
|
-
_a$2[VK_FORMAT_ASTC_10x6_SRGB_BLOCK] = [constants.UNSIGNED_BYTE, constants.COMPRESSED_SRGB8_ALPHA8_ASTC_10x6_KHR],
|
3968
|
-
_a$2[VK_FORMAT_ASTC_10x6_UNORM_BLOCK] = [constants.UNSIGNED_BYTE, constants.COMPRESSED_RGBA_ASTC_10x6_KHR],
|
3969
|
-
_a$2[VK_FORMAT_ASTC_8x5_SRGB_BLOCK] = [constants.UNSIGNED_BYTE, constants.COMPRESSED_SRGB8_ALPHA8_ASTC_8x5_KHR],
|
3970
|
-
_a$2[VK_FORMAT_ASTC_8x5_UNORM_BLOCK] = [constants.UNSIGNED_BYTE, constants.COMPRESSED_RGBA_ASTC_8x5_KHR],
|
3971
|
-
_a$2[VK_FORMAT_ASTC_12x10_SRGB_BLOCK] = [constants.UNSIGNED_BYTE, constants.COMPRESSED_SRGB8_ALPHA8_ASTC_12x10_KHR],
|
3972
|
-
_a$2[VK_FORMAT_ASTC_12x10_UNORM_BLOCK] = [constants.UNSIGNED_BYTE, constants.COMPRESSED_RGBA_ASTC_12x10_KHR],
|
3973
|
-
_a$2[VK_FORMAT_ASTC_10x8_SRGB_BLOCK] = [constants.UNSIGNED_BYTE, constants.COMPRESSED_SRGB8_ALPHA8_ASTC_10x8_KHR],
|
3974
|
-
_a$2[VK_FORMAT_ASTC_10x8_UNORM_BLOCK] = [constants.UNSIGNED_BYTE, constants.COMPRESSED_RGBA_ASTC_10x8_KHR],
|
3975
|
-
_a$2);
|
3672
|
+
KhronosTextureContainer.prototype.mipmaps = function (loadMipmaps) {
|
3673
|
+
var mipmaps = [];
|
3674
|
+
// initialize width & height for level 1
|
3675
|
+
var dataOffset = HEADER_LEN + this.bytesOfKeyValueData;
|
3676
|
+
var width = this.pixelWidth;
|
3677
|
+
var height = this.pixelHeight;
|
3678
|
+
var mipmapCount = loadMipmaps ? this.numberOfMipmapLevels : 1;
|
3679
|
+
for (var level = 0; level < mipmapCount; level++) {
|
3680
|
+
var imageSize = new Int32Array(this.arrayBuffer, this.baseOffset + dataOffset, 1)[0]; // size per face, since not supporting array cubemaps
|
3681
|
+
for (var face = 0; face < this.numberOfFaces; face++) {
|
3682
|
+
var byteArray = new Uint8Array(this.arrayBuffer, this.baseOffset + dataOffset + 4, imageSize);
|
3683
|
+
mipmaps.push({
|
3684
|
+
data: byteArray,
|
3685
|
+
width: width,
|
3686
|
+
height: height,
|
3687
|
+
});
|
3688
|
+
dataOffset += imageSize + 4; // size of the image + 4 for the imageSize field
|
3689
|
+
dataOffset += 3 - ((imageSize + 3) % 4); // add padding for odd sized image
|
3690
|
+
}
|
3691
|
+
width = Math.max(1.0, width * 0.5);
|
3692
|
+
height = Math.max(1.0, height * 0.5);
|
3693
|
+
}
|
3694
|
+
return mipmaps;
|
3695
|
+
};
|
3696
|
+
return KhronosTextureContainer;
|
3697
|
+
}());
|
3976
3698
|
function getCompressedTextureOptions(data) {
|
3977
|
-
var
|
3978
|
-
var
|
3979
|
-
var height = container.pixelHeight;
|
3980
|
-
var pair = formatMap[container.vkFormat];
|
3699
|
+
var ktx = new KhronosTextureContainer(data, 1);
|
3700
|
+
var useMipmaps = ktx.numberOfMipmapLevels >= Math.floor(Math.log2(Math.max(ktx.pixelWidth, ktx.pixelHeight)) + 1);
|
3981
3701
|
return {
|
3982
3702
|
sourceType: TextureSourceType.compressed,
|
3983
|
-
|
3984
|
-
|
3985
|
-
|
3986
|
-
|
3987
|
-
mipmaps:
|
3988
|
-
data: level.levelData,
|
3989
|
-
width: width >> i,
|
3990
|
-
height: height >> i,
|
3991
|
-
}); }),
|
3703
|
+
type: constants.UNSIGNED_BYTE,
|
3704
|
+
target: ktx.numberOfFaces === 6 ? constants.TEXTURE_CUBE_MAP : constants.TEXTURE_2D,
|
3705
|
+
format: ktx.glInternalFormat,
|
3706
|
+
internalFormat: ktx.glInternalFormat,
|
3707
|
+
mipmaps: ktx.mipmaps(useMipmaps),
|
3992
3708
|
};
|
3993
3709
|
}
|
3994
3710
|
|
@@ -4079,7 +3795,7 @@ var MarsTextureFactory = /** @class */ (function () {
|
|
4079
3795
|
}
|
4080
3796
|
else if (sourceFrom.type === TextureSourceType.compressed) {
|
4081
3797
|
return this.requestBinaryAsync(sourceFrom.url).then(function (arrayBuffer) {
|
4082
|
-
return Object.assign(getCompressedTextureOptions(
|
3798
|
+
return Object.assign(getCompressedTextureOptions(arrayBuffer), config, {
|
4083
3799
|
sourceFrom: { url: sourceFrom.url, type: TextureSourceType.compressed },
|
4084
3800
|
});
|
4085
3801
|
}, catchError);
|
@@ -4178,7 +3894,7 @@ var MarsTextureFactory = /** @class */ (function () {
|
|
4178
3894
|
return Promise.all(map.map(function (key) { return _this.loadImageAsync(key); }));
|
4179
3895
|
};
|
4180
3896
|
MarsTextureFactory.prototype.loadCompressedTextureFromArrayBuffer = function (arrayBuffer, options) {
|
4181
|
-
return Object.assign(getCompressedTextureOptions(
|
3897
|
+
return Object.assign(getCompressedTextureOptions(arrayBuffer), options);
|
4182
3898
|
};
|
4183
3899
|
MarsTextureFactory.prototype.reloadTextureAsync = function (texture) {
|
4184
3900
|
var _this = this;
|
@@ -6177,7 +5893,7 @@ var MarsSharedGeometry = /** @class */ (function (_super) {
|
|
6177
5893
|
return MarsSharedGeometry;
|
6178
5894
|
}(MarsGeometry));
|
6179
5895
|
|
6180
|
-
consoleLog('version: ' + "0.3.0-beta.
|
5896
|
+
consoleLog('version: ' + "0.3.0-beta.197");
|
6181
5897
|
var ModuleMsg = 'RI Package: @predy-js/render-interface';
|
6182
5898
|
|
6183
5899
|
var RI = /*#__PURE__*/Object.freeze({
|