@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.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.
|
5
|
+
* Version: v0.3.0-beta.190
|
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$
|
158
|
+
var _a$7, _b$3;
|
159
159
|
// @ts-expect-error safe to assign
|
160
160
|
var constants = {};
|
161
|
-
{
|
162
|
-
|
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
|
-
|
175
|
-
|
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$
|
185
|
-
_a$
|
186
|
-
_a$
|
187
|
-
_a$
|
188
|
-
_a$
|
189
|
-
_a$
|
190
|
-
_a$
|
191
|
-
_a$
|
192
|
-
_a$
|
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$
|
1248
|
-
var DATA_DICT = (_a$
|
1249
|
-
_a$
|
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$
|
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$
|
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$
|
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$
|
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$
|
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$
|
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$
|
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$
|
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$
|
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$
|
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$
|
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$
|
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$
|
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$
|
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$
|
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$
|
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$
|
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$
|
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$
|
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$
|
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$
|
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$
|
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$
|
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$
|
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$
|
1441
|
+
_a$6[constants.SAMPLER_2D] = {
|
1415
1442
|
name: constants.SAMPLER_2D,
|
1416
1443
|
uniform: assignTexUniform,
|
1417
1444
|
},
|
1418
|
-
_a$
|
1445
|
+
_a$6[constants.SAMPLER_CUBE] = {
|
1419
1446
|
name: constants.SAMPLER_CUBE,
|
1420
1447
|
uniform: assignTexUniform,
|
1421
1448
|
},
|
1422
|
-
_a$
|
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$
|
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$
|
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$
|
1594
|
-
_a$
|
1595
|
-
_a$
|
1596
|
-
_a$
|
1597
|
-
_a$
|
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
|
-
|
1799
|
-
|
1800
|
-
if (renderPassSemantics.hasSemanticValue(semanticName)) {
|
1801
|
-
return renderPassSemantics.getSemanticValue(semanticName, state);
|
1825
|
+
if (typeof semanticName === 'function') {
|
1826
|
+
return semanticName(state);
|
1802
1827
|
}
|
1803
|
-
else
|
1804
|
-
|
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$
|
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$
|
1952
|
-
_a$
|
1983
|
+
var downgradeKeywords = (_a$4 = {},
|
1984
|
+
_a$4[ShaderType.vertex] = {
|
1953
1985
|
in: 'attribute',
|
1954
1986
|
out: 'varying',
|
1955
1987
|
},
|
1956
|
-
_a$
|
1988
|
+
_a$4[ShaderType.fragment] = {
|
1957
1989
|
in: 'varying',
|
1958
1990
|
},
|
1959
|
-
_a$
|
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$
|
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$
|
2775
|
-
_a$
|
2776
|
-
_a$
|
2777
|
-
_a$
|
2778
|
-
_a$
|
2779
|
-
_a$
|
2780
|
-
_a$
|
2781
|
-
_a$
|
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,
|
@@ -3568,110 +3600,394 @@ function loadImageAsync(imgOrURL, options) {
|
|
3568
3600
|
});
|
3569
3601
|
}
|
3570
3602
|
|
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
|
-
|
3634
|
-
|
3635
|
-
|
3636
|
-
|
3637
|
-
|
3603
|
+
///////////////////////////////////////////////////
|
3604
|
+
// KTX2 Header.
|
3605
|
+
///////////////////////////////////////////////////
|
3606
|
+
const KHR_SUPERCOMPRESSION_NONE = 0;
|
3607
|
+
///////////////////////////////////////////////////
|
3608
|
+
// Data Format Descriptor (DFD).
|
3609
|
+
///////////////////////////////////////////////////
|
3610
|
+
const KHR_DF_KHR_DESCRIPTORTYPE_BASICFORMAT = 0;
|
3611
|
+
const KHR_DF_VENDORID_KHRONOS = 0;
|
3612
|
+
const KHR_DF_VERSION = 2;
|
3613
|
+
const KHR_DF_MODEL_UNSPECIFIED = 0;
|
3614
|
+
const KHR_DF_FLAG_ALPHA_STRAIGHT = 0;
|
3615
|
+
const KHR_DF_TRANSFER_SRGB = 2;
|
3616
|
+
const KHR_DF_PRIMARIES_BT709 = 1;
|
3617
|
+
const KHR_DF_SAMPLE_DATATYPE_SIGNED = 0x40;
|
3618
|
+
///////////////////////////////////////////////////
|
3619
|
+
// VK FORMAT.
|
3620
|
+
///////////////////////////////////////////////////
|
3621
|
+
const VK_FORMAT_UNDEFINED = 0;
|
3622
|
+
const VK_FORMAT_ASTC_4x4_UNORM_BLOCK = 157;
|
3623
|
+
const VK_FORMAT_ASTC_4x4_SRGB_BLOCK = 158;
|
3624
|
+
const VK_FORMAT_ASTC_5x4_UNORM_BLOCK = 159;
|
3625
|
+
const VK_FORMAT_ASTC_5x4_SRGB_BLOCK = 160;
|
3626
|
+
const VK_FORMAT_ASTC_5x5_UNORM_BLOCK = 161;
|
3627
|
+
const VK_FORMAT_ASTC_5x5_SRGB_BLOCK = 162;
|
3628
|
+
const VK_FORMAT_ASTC_6x5_UNORM_BLOCK = 163;
|
3629
|
+
const VK_FORMAT_ASTC_6x5_SRGB_BLOCK = 164;
|
3630
|
+
const VK_FORMAT_ASTC_6x6_UNORM_BLOCK = 165;
|
3631
|
+
const VK_FORMAT_ASTC_6x6_SRGB_BLOCK = 166;
|
3632
|
+
const VK_FORMAT_ASTC_8x5_UNORM_BLOCK = 167;
|
3633
|
+
const VK_FORMAT_ASTC_8x5_SRGB_BLOCK = 168;
|
3634
|
+
const VK_FORMAT_ASTC_8x6_UNORM_BLOCK = 169;
|
3635
|
+
const VK_FORMAT_ASTC_8x6_SRGB_BLOCK = 170;
|
3636
|
+
const VK_FORMAT_ASTC_8x8_UNORM_BLOCK = 171;
|
3637
|
+
const VK_FORMAT_ASTC_8x8_SRGB_BLOCK = 172;
|
3638
|
+
const VK_FORMAT_ASTC_10x5_UNORM_BLOCK = 173;
|
3639
|
+
const VK_FORMAT_ASTC_10x5_SRGB_BLOCK = 174;
|
3640
|
+
const VK_FORMAT_ASTC_10x6_UNORM_BLOCK = 175;
|
3641
|
+
const VK_FORMAT_ASTC_10x6_SRGB_BLOCK = 176;
|
3642
|
+
const VK_FORMAT_ASTC_10x8_UNORM_BLOCK = 177;
|
3643
|
+
const VK_FORMAT_ASTC_10x8_SRGB_BLOCK = 178;
|
3644
|
+
const VK_FORMAT_ASTC_10x10_UNORM_BLOCK = 179;
|
3645
|
+
const VK_FORMAT_ASTC_10x10_SRGB_BLOCK = 180;
|
3646
|
+
const VK_FORMAT_ASTC_12x10_UNORM_BLOCK = 181;
|
3647
|
+
const VK_FORMAT_ASTC_12x10_SRGB_BLOCK = 182;
|
3648
|
+
const VK_FORMAT_ASTC_12x12_UNORM_BLOCK = 183;
|
3649
|
+
const VK_FORMAT_ASTC_12x12_SRGB_BLOCK = 184;
|
3650
|
+
|
3651
|
+
/**
|
3652
|
+
* Represents an unpacked KTX 2.0 texture container. Data for individual mip levels are stored in
|
3653
|
+
* the `.levels` array, typically compressed in Basis Universal formats. Additional properties
|
3654
|
+
* provide metadata required to process, transcode, and upload these textures.
|
3655
|
+
*/
|
3656
|
+
class KTX2Container {
|
3657
|
+
constructor() {
|
3658
|
+
/**
|
3659
|
+
* Specifies the image format using Vulkan VkFormat enum values. When using Basis Universal
|
3660
|
+
* texture formats, `vkFormat` must be VK_FORMAT_UNDEFINED.
|
3661
|
+
*/
|
3662
|
+
this.vkFormat = VK_FORMAT_UNDEFINED;
|
3663
|
+
/**
|
3664
|
+
* Size of the data type in bytes used to upload the data to a graphics API. When `vkFormat` is
|
3665
|
+
* VK_FORMAT_UNDEFINED, `typeSize` must be 1.
|
3666
|
+
*/
|
3667
|
+
this.typeSize = 1;
|
3668
|
+
/** Width of the texture image for level 0, in pixels. */
|
3669
|
+
this.pixelWidth = 0;
|
3670
|
+
/** Height of the texture image for level 0, in pixels. */
|
3671
|
+
this.pixelHeight = 0;
|
3672
|
+
/** Depth of the texture image for level 0, in pixels (3D textures only). */
|
3673
|
+
this.pixelDepth = 0;
|
3674
|
+
/** Number of array elements (array textures only). */
|
3675
|
+
this.layerCount = 0;
|
3676
|
+
/**
|
3677
|
+
* Number of cubemap faces. For cubemaps and cubemap arrays, `faceCount` must be 6. For all
|
3678
|
+
* other textures, `faceCount` must be 1. Cubemap faces are stored in +X, -X, +Y, -Y, +Z, -Z
|
3679
|
+
* order.
|
3680
|
+
*/
|
3681
|
+
this.faceCount = 1;
|
3682
|
+
/** Indicates which supercompression scheme has been applied to mip level images, if any. */
|
3683
|
+
this.supercompressionScheme = KHR_SUPERCOMPRESSION_NONE;
|
3684
|
+
/** Mip levels, ordered largest (original) to smallest (~1px). */
|
3685
|
+
this.levels = [];
|
3686
|
+
/** Data Format Descriptor. */
|
3687
|
+
this.dataFormatDescriptor = [{
|
3688
|
+
vendorId: KHR_DF_VENDORID_KHRONOS,
|
3689
|
+
descriptorType: KHR_DF_KHR_DESCRIPTORTYPE_BASICFORMAT,
|
3690
|
+
descriptorBlockSize: 0,
|
3691
|
+
versionNumber: KHR_DF_VERSION,
|
3692
|
+
colorModel: KHR_DF_MODEL_UNSPECIFIED,
|
3693
|
+
colorPrimaries: KHR_DF_PRIMARIES_BT709,
|
3694
|
+
transferFunction: KHR_DF_TRANSFER_SRGB,
|
3695
|
+
flags: KHR_DF_FLAG_ALPHA_STRAIGHT,
|
3696
|
+
texelBlockDimension: [0, 0, 0, 0],
|
3697
|
+
bytesPlane: [0, 0, 0, 0, 0, 0, 0, 0],
|
3698
|
+
samples: []
|
3699
|
+
}];
|
3700
|
+
/** Key/Value Data. */
|
3701
|
+
this.keyValue = {};
|
3702
|
+
/** Supercompression Global Data. */
|
3703
|
+
this.globalData = null;
|
3704
|
+
}
|
3705
|
+
}
|
3706
|
+
|
3707
|
+
class BufferReader {
|
3708
|
+
constructor(data, byteOffset, byteLength, littleEndian) {
|
3709
|
+
this._dataView = void 0;
|
3710
|
+
this._littleEndian = void 0;
|
3711
|
+
this._offset = void 0;
|
3712
|
+
this._dataView = new DataView(data.buffer, data.byteOffset + byteOffset, byteLength);
|
3713
|
+
this._littleEndian = littleEndian;
|
3714
|
+
this._offset = 0;
|
3715
|
+
}
|
3716
|
+
_nextUint8() {
|
3717
|
+
const value = this._dataView.getUint8(this._offset);
|
3718
|
+
this._offset += 1;
|
3719
|
+
return value;
|
3720
|
+
}
|
3721
|
+
_nextUint16() {
|
3722
|
+
const value = this._dataView.getUint16(this._offset, this._littleEndian);
|
3723
|
+
this._offset += 2;
|
3724
|
+
return value;
|
3725
|
+
}
|
3726
|
+
_nextUint32() {
|
3727
|
+
const value = this._dataView.getUint32(this._offset, this._littleEndian);
|
3728
|
+
this._offset += 4;
|
3729
|
+
return value;
|
3730
|
+
}
|
3731
|
+
_nextUint64() {
|
3732
|
+
const left = this._dataView.getUint32(this._offset, this._littleEndian);
|
3733
|
+
const right = this._dataView.getUint32(this._offset + 4, this._littleEndian);
|
3734
|
+
// TODO(cleanup): Just test this...
|
3735
|
+
// const value = this._littleEndian ? left + (2 ** 32 * right) : (2 ** 32 * left) + right;
|
3736
|
+
const value = left + 2 ** 32 * right;
|
3737
|
+
this._offset += 8;
|
3738
|
+
return value;
|
3739
|
+
}
|
3740
|
+
_nextInt32() {
|
3741
|
+
const value = this._dataView.getInt32(this._offset, this._littleEndian);
|
3742
|
+
this._offset += 4;
|
3743
|
+
return value;
|
3744
|
+
}
|
3745
|
+
_nextUint8Array(len) {
|
3746
|
+
const value = new Uint8Array(this._dataView.buffer, this._dataView.byteOffset + this._offset, len);
|
3747
|
+
this._offset += len;
|
3748
|
+
return value;
|
3749
|
+
}
|
3750
|
+
_skip(bytes) {
|
3751
|
+
this._offset += bytes;
|
3752
|
+
return this;
|
3753
|
+
}
|
3754
|
+
_scan(maxByteLength, term = 0x00) {
|
3755
|
+
const byteOffset = this._offset;
|
3756
|
+
let byteLength = 0;
|
3757
|
+
while (this._dataView.getUint8(this._offset) !== term && byteLength < maxByteLength) {
|
3758
|
+
byteLength++;
|
3759
|
+
this._offset++;
|
3638
3760
|
}
|
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
|
-
|
3761
|
+
if (byteLength < maxByteLength) this._offset++;
|
3762
|
+
return new Uint8Array(this._dataView.buffer, this._dataView.byteOffset + byteOffset, byteLength);
|
3763
|
+
}
|
3764
|
+
}
|
3765
|
+
///////////////////////////////////////////////////
|
3766
|
+
// KTX2 Header.
|
3767
|
+
///////////////////////////////////////////////////
|
3768
|
+
const KTX2_ID = [
|
3769
|
+
// '´', 'K', 'T', 'X', '2', '0', 'ª', '\r', '\n', '\x1A', '\n'
|
3770
|
+
0xab, 0x4b, 0x54, 0x58, 0x20, 0x32, 0x30, 0xbb, 0x0d, 0x0a, 0x1a, 0x0a];
|
3771
|
+
/** Decodes an ArrayBuffer to text. */
|
3772
|
+
function decodeText(buffer) {
|
3773
|
+
return new TextDecoder().decode(buffer);
|
3774
|
+
}
|
3775
|
+
|
3776
|
+
/**
|
3777
|
+
* Parses a KTX 2.0 file, returning an unpacked {@link KTX2Container} instance with all associated
|
3778
|
+
* data. The container's mip levels and other binary data are pointers into the original file, not
|
3779
|
+
* copies, so the original file should not be overwritten after reading.
|
3780
|
+
*
|
3781
|
+
* @param data Bytes of KTX 2.0 file, as Uint8Array or Buffer.
|
3782
|
+
*/
|
3783
|
+
function read(data) {
|
3784
|
+
///////////////////////////////////////////////////
|
3785
|
+
// KTX 2.0 Identifier.
|
3786
|
+
///////////////////////////////////////////////////
|
3787
|
+
const id = new Uint8Array(data.buffer, data.byteOffset, KTX2_ID.length);
|
3788
|
+
if (id[0] !== KTX2_ID[0] ||
|
3789
|
+
// '´'
|
3790
|
+
id[1] !== KTX2_ID[1] ||
|
3791
|
+
// 'K'
|
3792
|
+
id[2] !== KTX2_ID[2] ||
|
3793
|
+
// 'T'
|
3794
|
+
id[3] !== KTX2_ID[3] ||
|
3795
|
+
// 'X'
|
3796
|
+
id[4] !== KTX2_ID[4] ||
|
3797
|
+
// ' '
|
3798
|
+
id[5] !== KTX2_ID[5] ||
|
3799
|
+
// '2'
|
3800
|
+
id[6] !== KTX2_ID[6] ||
|
3801
|
+
// '0'
|
3802
|
+
id[7] !== KTX2_ID[7] ||
|
3803
|
+
// 'ª'
|
3804
|
+
id[8] !== KTX2_ID[8] ||
|
3805
|
+
// '\r'
|
3806
|
+
id[9] !== KTX2_ID[9] ||
|
3807
|
+
// '\n'
|
3808
|
+
id[10] !== KTX2_ID[10] ||
|
3809
|
+
// '\x1A'
|
3810
|
+
id[11] !== KTX2_ID[11] // '\n'
|
3811
|
+
) {
|
3812
|
+
throw new Error('Missing KTX 2.0 identifier.');
|
3813
|
+
}
|
3814
|
+
const container = new KTX2Container();
|
3815
|
+
///////////////////////////////////////////////////
|
3816
|
+
// Header.
|
3817
|
+
///////////////////////////////////////////////////
|
3818
|
+
const headerByteLength = 17 * Uint32Array.BYTES_PER_ELEMENT;
|
3819
|
+
const headerReader = new BufferReader(data, KTX2_ID.length, headerByteLength, true);
|
3820
|
+
container.vkFormat = headerReader._nextUint32();
|
3821
|
+
container.typeSize = headerReader._nextUint32();
|
3822
|
+
container.pixelWidth = headerReader._nextUint32();
|
3823
|
+
container.pixelHeight = headerReader._nextUint32();
|
3824
|
+
container.pixelDepth = headerReader._nextUint32();
|
3825
|
+
container.layerCount = headerReader._nextUint32();
|
3826
|
+
container.faceCount = headerReader._nextUint32();
|
3827
|
+
const levelCount = headerReader._nextUint32();
|
3828
|
+
container.supercompressionScheme = headerReader._nextUint32();
|
3829
|
+
const dfdByteOffset = headerReader._nextUint32();
|
3830
|
+
const dfdByteLength = headerReader._nextUint32();
|
3831
|
+
const kvdByteOffset = headerReader._nextUint32();
|
3832
|
+
const kvdByteLength = headerReader._nextUint32();
|
3833
|
+
const sgdByteOffset = headerReader._nextUint64();
|
3834
|
+
const sgdByteLength = headerReader._nextUint64();
|
3835
|
+
///////////////////////////////////////////////////
|
3836
|
+
// Level Index.
|
3837
|
+
///////////////////////////////////////////////////
|
3838
|
+
const levelByteLength = levelCount * 3 * 8;
|
3839
|
+
const levelReader = new BufferReader(data, KTX2_ID.length + headerByteLength, levelByteLength, true);
|
3840
|
+
for (let i = 0; i < levelCount; i++) {
|
3841
|
+
container.levels.push({
|
3842
|
+
levelData: new Uint8Array(data.buffer, data.byteOffset + levelReader._nextUint64(), levelReader._nextUint64()),
|
3843
|
+
uncompressedByteLength: levelReader._nextUint64()
|
3844
|
+
});
|
3845
|
+
}
|
3846
|
+
///////////////////////////////////////////////////
|
3847
|
+
// Data Format Descriptor (DFD).
|
3848
|
+
///////////////////////////////////////////////////
|
3849
|
+
const dfdReader = new BufferReader(data, dfdByteOffset, dfdByteLength, true);
|
3850
|
+
const dfd = {
|
3851
|
+
vendorId: dfdReader._skip(4 /* totalSize */)._nextUint16(),
|
3852
|
+
descriptorType: dfdReader._nextUint16(),
|
3853
|
+
versionNumber: dfdReader._nextUint16(),
|
3854
|
+
descriptorBlockSize: dfdReader._nextUint16(),
|
3855
|
+
colorModel: dfdReader._nextUint8(),
|
3856
|
+
colorPrimaries: dfdReader._nextUint8(),
|
3857
|
+
transferFunction: dfdReader._nextUint8(),
|
3858
|
+
flags: dfdReader._nextUint8(),
|
3859
|
+
texelBlockDimension: [dfdReader._nextUint8(), dfdReader._nextUint8(), dfdReader._nextUint8(), dfdReader._nextUint8()],
|
3860
|
+
bytesPlane: [dfdReader._nextUint8(), dfdReader._nextUint8(), dfdReader._nextUint8(), dfdReader._nextUint8(), dfdReader._nextUint8(), dfdReader._nextUint8(), dfdReader._nextUint8(), dfdReader._nextUint8()],
|
3861
|
+
samples: []
|
3862
|
+
};
|
3863
|
+
const sampleStart = 6;
|
3864
|
+
const sampleWords = 4;
|
3865
|
+
const numSamples = (dfd.descriptorBlockSize / 4 - sampleStart) / sampleWords;
|
3866
|
+
for (let i = 0; i < numSamples; i++) {
|
3867
|
+
const sample = {
|
3868
|
+
bitOffset: dfdReader._nextUint16(),
|
3869
|
+
bitLength: dfdReader._nextUint8(),
|
3870
|
+
channelType: dfdReader._nextUint8(),
|
3871
|
+
samplePosition: [dfdReader._nextUint8(), dfdReader._nextUint8(), dfdReader._nextUint8(), dfdReader._nextUint8()],
|
3872
|
+
sampleLower: -Infinity,
|
3873
|
+
sampleUpper: Infinity
|
3874
|
+
};
|
3875
|
+
if (sample.channelType & KHR_DF_SAMPLE_DATATYPE_SIGNED) {
|
3876
|
+
sample.sampleLower = dfdReader._nextInt32();
|
3877
|
+
sample.sampleUpper = dfdReader._nextInt32();
|
3878
|
+
} else {
|
3879
|
+
sample.sampleLower = dfdReader._nextUint32();
|
3880
|
+
sample.sampleUpper = dfdReader._nextUint32();
|
3881
|
+
}
|
3882
|
+
dfd.samples[i] = sample;
|
3883
|
+
}
|
3884
|
+
container.dataFormatDescriptor.length = 0;
|
3885
|
+
container.dataFormatDescriptor.push(dfd);
|
3886
|
+
///////////////////////////////////////////////////
|
3887
|
+
// Key/Value Data (KVD).
|
3888
|
+
///////////////////////////////////////////////////
|
3889
|
+
const kvdReader = new BufferReader(data, kvdByteOffset, kvdByteLength, true);
|
3890
|
+
while (kvdReader._offset < kvdByteLength) {
|
3891
|
+
const keyValueByteLength = kvdReader._nextUint32();
|
3892
|
+
const keyData = kvdReader._scan(keyValueByteLength);
|
3893
|
+
const key = decodeText(keyData);
|
3894
|
+
container.keyValue[key] = kvdReader._nextUint8Array(keyValueByteLength - keyData.byteLength - 1);
|
3895
|
+
if (key.match(/^ktx/i)) {
|
3896
|
+
const text = decodeText(container.keyValue[key]);
|
3897
|
+
container.keyValue[key] = text.substring(0, text.lastIndexOf('\x00'));
|
3898
|
+
}
|
3899
|
+
const kvPadding = keyValueByteLength % 4 ? 4 - keyValueByteLength % 4 : 0; // align(4)
|
3900
|
+
// 4-byte alignment.
|
3901
|
+
kvdReader._skip(kvPadding);
|
3902
|
+
}
|
3903
|
+
///////////////////////////////////////////////////
|
3904
|
+
// Supercompression Global Data (SGD).
|
3905
|
+
///////////////////////////////////////////////////
|
3906
|
+
if (sgdByteLength <= 0) return container;
|
3907
|
+
const sgdReader = new BufferReader(data, sgdByteOffset, sgdByteLength, true);
|
3908
|
+
const endpointCount = sgdReader._nextUint16();
|
3909
|
+
const selectorCount = sgdReader._nextUint16();
|
3910
|
+
const endpointsByteLength = sgdReader._nextUint32();
|
3911
|
+
const selectorsByteLength = sgdReader._nextUint32();
|
3912
|
+
const tablesByteLength = sgdReader._nextUint32();
|
3913
|
+
const extendedByteLength = sgdReader._nextUint32();
|
3914
|
+
const imageDescs = [];
|
3915
|
+
for (let i = 0; i < levelCount; i++) {
|
3916
|
+
imageDescs.push({
|
3917
|
+
imageFlags: sgdReader._nextUint32(),
|
3918
|
+
rgbSliceByteOffset: sgdReader._nextUint32(),
|
3919
|
+
rgbSliceByteLength: sgdReader._nextUint32(),
|
3920
|
+
alphaSliceByteOffset: sgdReader._nextUint32(),
|
3921
|
+
alphaSliceByteLength: sgdReader._nextUint32()
|
3922
|
+
});
|
3923
|
+
}
|
3924
|
+
const endpointsByteOffset = sgdByteOffset + sgdReader._offset;
|
3925
|
+
const selectorsByteOffset = endpointsByteOffset + endpointsByteLength;
|
3926
|
+
const tablesByteOffset = selectorsByteOffset + selectorsByteLength;
|
3927
|
+
const extendedByteOffset = tablesByteOffset + tablesByteLength;
|
3928
|
+
const endpointsData = new Uint8Array(data.buffer, data.byteOffset + endpointsByteOffset, endpointsByteLength);
|
3929
|
+
const selectorsData = new Uint8Array(data.buffer, data.byteOffset + selectorsByteOffset, selectorsByteLength);
|
3930
|
+
const tablesData = new Uint8Array(data.buffer, data.byteOffset + tablesByteOffset, tablesByteLength);
|
3931
|
+
const extendedData = new Uint8Array(data.buffer, data.byteOffset + extendedByteOffset, extendedByteLength);
|
3932
|
+
container.globalData = {
|
3933
|
+
endpointCount,
|
3934
|
+
selectorCount,
|
3935
|
+
imageDescs,
|
3936
|
+
endpointsData,
|
3937
|
+
selectorsData,
|
3938
|
+
tablesData,
|
3939
|
+
extendedData
|
3940
|
+
};
|
3941
|
+
return container;
|
3942
|
+
}
|
3943
|
+
|
3944
|
+
var _a$2;
|
3945
|
+
var formatMap = (_a$2 = {},
|
3946
|
+
_a$2[VK_FORMAT_ASTC_4x4_SRGB_BLOCK] = [constants.UNSIGNED_BYTE, constants.COMPRESSED_SRGB8_ALPHA8_ASTC_4x4_KHR],
|
3947
|
+
_a$2[VK_FORMAT_ASTC_4x4_UNORM_BLOCK] = [constants.UNSIGNED_BYTE, constants.COMPRESSED_RGBA_ASTC_4x4_KHR],
|
3948
|
+
_a$2[VK_FORMAT_ASTC_6x6_SRGB_BLOCK] = [constants.UNSIGNED_BYTE, constants.COMPRESSED_SRGB8_ALPHA8_ASTC_6x6_KHR],
|
3949
|
+
_a$2[VK_FORMAT_ASTC_6x6_UNORM_BLOCK] = [constants.UNSIGNED_BYTE, constants.COMPRESSED_RGBA_ASTC_6x6_KHR],
|
3950
|
+
_a$2[VK_FORMAT_ASTC_8x8_SRGB_BLOCK] = [constants.UNSIGNED_BYTE, constants.COMPRESSED_SRGB8_ALPHA8_ASTC_8x8_KHR],
|
3951
|
+
_a$2[VK_FORMAT_ASTC_8x8_UNORM_BLOCK] = [constants.UNSIGNED_BYTE, constants.COMPRESSED_RGBA_ASTC_8x8_KHR],
|
3952
|
+
_a$2[VK_FORMAT_ASTC_10x10_SRGB_BLOCK] = [constants.UNSIGNED_BYTE, constants.COMPRESSED_SRGB8_ALPHA8_ASTC_10x10_KHR],
|
3953
|
+
_a$2[VK_FORMAT_ASTC_10x10_UNORM_BLOCK] = [constants.UNSIGNED_BYTE, constants.COMPRESSED_RGBA_ASTC_10x10_KHR],
|
3954
|
+
_a$2[VK_FORMAT_ASTC_12x12_SRGB_BLOCK] = [constants.UNSIGNED_BYTE, constants.COMPRESSED_SRGB8_ALPHA8_ASTC_12x12_KHR],
|
3955
|
+
_a$2[VK_FORMAT_ASTC_12x12_UNORM_BLOCK] = [constants.UNSIGNED_BYTE, constants.COMPRESSED_RGBA_ASTC_12x12_KHR],
|
3956
|
+
_a$2[VK_FORMAT_ASTC_5x5_SRGB_BLOCK] = [constants.UNSIGNED_BYTE, constants.COMPRESSED_SRGB8_ALPHA8_ASTC_5x5_KHR],
|
3957
|
+
_a$2[VK_FORMAT_ASTC_5x5_UNORM_BLOCK] = [constants.UNSIGNED_BYTE, constants.COMPRESSED_RGBA_ASTC_5x5_KHR],
|
3958
|
+
_a$2[VK_FORMAT_ASTC_5x4_SRGB_BLOCK] = [constants.UNSIGNED_BYTE, constants.COMPRESSED_SRGB8_ALPHA8_ASTC_5x4_KHR],
|
3959
|
+
_a$2[VK_FORMAT_ASTC_5x4_UNORM_BLOCK] = [constants.UNSIGNED_BYTE, constants.COMPRESSED_RGBA_ASTC_5x4_KHR],
|
3960
|
+
_a$2[VK_FORMAT_ASTC_6x5_SRGB_BLOCK] = [constants.UNSIGNED_BYTE, constants.COMPRESSED_SRGB8_ALPHA8_ASTC_6x5_KHR],
|
3961
|
+
_a$2[VK_FORMAT_ASTC_6x5_UNORM_BLOCK] = [constants.UNSIGNED_BYTE, constants.COMPRESSED_RGBA_ASTC_6x5_KHR],
|
3962
|
+
_a$2[VK_FORMAT_ASTC_10x5_SRGB_BLOCK] = [constants.UNSIGNED_BYTE, constants.COMPRESSED_SRGB8_ALPHA8_ASTC_10x5_KHR],
|
3963
|
+
_a$2[VK_FORMAT_ASTC_10x5_UNORM_BLOCK] = [constants.UNSIGNED_BYTE, constants.COMPRESSED_RGBA_ASTC_10x5_KHR],
|
3964
|
+
_a$2[VK_FORMAT_ASTC_8x6_SRGB_BLOCK] = [constants.UNSIGNED_BYTE, constants.COMPRESSED_SRGB8_ALPHA8_ASTC_8x6_KHR],
|
3965
|
+
_a$2[VK_FORMAT_ASTC_8x6_UNORM_BLOCK] = [constants.UNSIGNED_BYTE, constants.COMPRESSED_RGBA_ASTC_8x6_KHR],
|
3966
|
+
_a$2[VK_FORMAT_ASTC_10x6_SRGB_BLOCK] = [constants.UNSIGNED_BYTE, constants.COMPRESSED_SRGB8_ALPHA8_ASTC_10x6_KHR],
|
3967
|
+
_a$2[VK_FORMAT_ASTC_10x6_UNORM_BLOCK] = [constants.UNSIGNED_BYTE, constants.COMPRESSED_RGBA_ASTC_10x6_KHR],
|
3968
|
+
_a$2[VK_FORMAT_ASTC_8x5_SRGB_BLOCK] = [constants.UNSIGNED_BYTE, constants.COMPRESSED_SRGB8_ALPHA8_ASTC_8x5_KHR],
|
3969
|
+
_a$2[VK_FORMAT_ASTC_8x5_UNORM_BLOCK] = [constants.UNSIGNED_BYTE, constants.COMPRESSED_RGBA_ASTC_8x5_KHR],
|
3970
|
+
_a$2[VK_FORMAT_ASTC_12x10_SRGB_BLOCK] = [constants.UNSIGNED_BYTE, constants.COMPRESSED_SRGB8_ALPHA8_ASTC_12x10_KHR],
|
3971
|
+
_a$2[VK_FORMAT_ASTC_12x10_UNORM_BLOCK] = [constants.UNSIGNED_BYTE, constants.COMPRESSED_RGBA_ASTC_12x10_KHR],
|
3972
|
+
_a$2[VK_FORMAT_ASTC_10x8_SRGB_BLOCK] = [constants.UNSIGNED_BYTE, constants.COMPRESSED_SRGB8_ALPHA8_ASTC_10x8_KHR],
|
3973
|
+
_a$2[VK_FORMAT_ASTC_10x8_UNORM_BLOCK] = [constants.UNSIGNED_BYTE, constants.COMPRESSED_RGBA_ASTC_10x8_KHR],
|
3974
|
+
_a$2);
|
3665
3975
|
function getCompressedTextureOptions(data) {
|
3666
|
-
var
|
3667
|
-
var
|
3976
|
+
var container = read(data);
|
3977
|
+
var width = container.pixelWidth;
|
3978
|
+
var height = container.pixelHeight;
|
3979
|
+
var pair = formatMap[container.vkFormat];
|
3668
3980
|
return {
|
3669
3981
|
sourceType: exports.TextureSourceType.compressed,
|
3670
|
-
|
3671
|
-
|
3672
|
-
internalFormat:
|
3673
|
-
|
3674
|
-
mipmaps:
|
3982
|
+
target: container.faceCount === 6 ? constants.TEXTURE_CUBE_MAP : constants.TEXTURE_2D,
|
3983
|
+
format: pair[1],
|
3984
|
+
internalFormat: pair[1],
|
3985
|
+
type: pair[0],
|
3986
|
+
mipmaps: container.levels.map(function (level, i) { return ({
|
3987
|
+
data: level.levelData,
|
3988
|
+
width: width >> i,
|
3989
|
+
height: height >> i,
|
3990
|
+
}); }),
|
3675
3991
|
};
|
3676
3992
|
}
|
3677
3993
|
|
@@ -3762,7 +4078,7 @@ var MarsTextureFactory = /** @class */ (function () {
|
|
3762
4078
|
}
|
3763
4079
|
else if (sourceFrom.type === exports.TextureSourceType.compressed) {
|
3764
4080
|
return this.requestBinaryAsync(sourceFrom.url).then(function (arrayBuffer) {
|
3765
|
-
return Object.assign(getCompressedTextureOptions(arrayBuffer), config, {
|
4081
|
+
return Object.assign(getCompressedTextureOptions(new Uint8Array(arrayBuffer)), config, {
|
3766
4082
|
sourceFrom: { url: sourceFrom.url, type: exports.TextureSourceType.compressed },
|
3767
4083
|
});
|
3768
4084
|
}, catchError);
|
@@ -3861,7 +4177,7 @@ var MarsTextureFactory = /** @class */ (function () {
|
|
3861
4177
|
return Promise.all(map.map(function (key) { return _this.loadImageAsync(key); }));
|
3862
4178
|
};
|
3863
4179
|
MarsTextureFactory.prototype.loadCompressedTextureFromArrayBuffer = function (arrayBuffer, options) {
|
3864
|
-
return Object.assign(getCompressedTextureOptions(arrayBuffer), options);
|
4180
|
+
return Object.assign(getCompressedTextureOptions(new Uint8Array(arrayBuffer)), options);
|
3865
4181
|
};
|
3866
4182
|
MarsTextureFactory.prototype.reloadTextureAsync = function (texture) {
|
3867
4183
|
var _this = this;
|
@@ -4486,10 +4802,10 @@ var GLMaterial = /** @class */ (function () {
|
|
4486
4802
|
webGLState.depthFunc(currentState.depthFunc);
|
4487
4803
|
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
4804
|
}
|
4805
|
+
webGLState.frontFace(currentState.frontFace);
|
4489
4806
|
if (currentState.cullFaceEnabled) {
|
4490
4807
|
//face
|
4491
4808
|
webGLState.cullFace(currentState.cullFace);
|
4492
|
-
webGLState.frontFace(currentState.frontFace);
|
4493
4809
|
}
|
4494
4810
|
if (currentState.polygonOffsetFill) {
|
4495
4811
|
var polygonOffset = currentState.polygonOffset || [0, 0];
|
@@ -5860,7 +6176,7 @@ var MarsSharedGeometry = /** @class */ (function (_super) {
|
|
5860
6176
|
return MarsSharedGeometry;
|
5861
6177
|
}(MarsGeometry));
|
5862
6178
|
|
5863
|
-
consoleLog('version: ' + "0.3.0-beta.
|
6179
|
+
consoleLog('version: ' + "0.3.0-beta.190");
|
5864
6180
|
var ModuleMsg = 'RI Package: @predy-js/render-interface';
|
5865
6181
|
|
5866
6182
|
var RI = /*#__PURE__*/Object.freeze({
|