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