@galacean/engine-loader 1.5.14 → 1.6.0-alpha.0
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/main.js +232 -368
- package/dist/main.js.map +1 -1
- package/dist/module.js +234 -369
- package/dist/module.js.map +1 -1
- package/package.json +4 -4
- package/types/gltf/extensions/GLTFExtensionSchema.d.ts +5 -14
- package/types/gltf/extensions/index.d.ts +1 -1
- package/types/gltf/parser/GLTFMaterialParser.d.ts +2 -2
- package/types/gltf/parser/GLTFParserContext.d.ts +1 -1
- package/types/index.d.ts +1 -1
- package/types/ktx2/KTX2Container.d.ts +6 -1
- package/types/ktx2/KTX2Loader.d.ts +0 -12
- package/types/ktx2/KTX2TargetFormat.d.ts +7 -1
- package/types/resource-deserialize/resources/parser/ParserContext.d.ts +8 -1
- package/types/resource-deserialize/resources/scene/SceneParser.d.ts +7 -8
- package/types/resource-deserialize/resources/schema/SceneSchema.d.ts +8 -9
- package/types/ktx2/transcoder/KhronosTranscoder.d.ts +0 -13
- package/types/ktx2/transcoder/KhronosWorkerCode.d.ts +0 -1
- /package/types/gltf/extensions/{KHR_materials_pbrSpecularGlossiness.d.ts → KHR_materials_specular.d.ts} +0 -0
package/dist/main.js
CHANGED
|
@@ -680,6 +680,9 @@ var ParserType = /*#__PURE__*/ function(ParserType) {
|
|
|
680
680
|
this.componentConfigMap = new Map();
|
|
681
681
|
this.rootIds = [];
|
|
682
682
|
this.strippedIds = [];
|
|
683
|
+
this._tasks = new Set();
|
|
684
|
+
this._loaded = 0;
|
|
685
|
+
this._total = 0;
|
|
683
686
|
this.resourceManager = engine.resourceManager;
|
|
684
687
|
}
|
|
685
688
|
var _proto = ParserContext.prototype;
|
|
@@ -691,6 +694,17 @@ var ParserType = /*#__PURE__*/ function(ParserType) {
|
|
|
691
694
|
this.rootIds.length = 0;
|
|
692
695
|
this.strippedIds.length = 0;
|
|
693
696
|
};
|
|
697
|
+
/** @internal */ _proto._addDependentAsset = function _addDependentAsset(refID, promise) {
|
|
698
|
+
var _this = this;
|
|
699
|
+
var tasks = this._tasks;
|
|
700
|
+
if (tasks.has(refID)) return;
|
|
701
|
+
++this._total;
|
|
702
|
+
tasks.add(refID);
|
|
703
|
+
promise.finally(function() {
|
|
704
|
+
++_this._loaded;
|
|
705
|
+
_this._setTaskCompleteProgress(_this._loaded, _this._total);
|
|
706
|
+
});
|
|
707
|
+
};
|
|
694
708
|
return ParserContext;
|
|
695
709
|
}();
|
|
696
710
|
|
|
@@ -1391,6 +1405,24 @@ var EditorTexture2DContentRestorer = /*#__PURE__*/ function(ContentRestorer) {
|
|
|
1391
1405
|
return EditorTexture2DContentRestorer;
|
|
1392
1406
|
}(engineCore.ContentRestorer);
|
|
1393
1407
|
|
|
1408
|
+
var MaterialLoaderType = /*#__PURE__*/ function(MaterialLoaderType) {
|
|
1409
|
+
MaterialLoaderType["Vector2"] = "Vector2";
|
|
1410
|
+
MaterialLoaderType["Vector3"] = "Vector3";
|
|
1411
|
+
MaterialLoaderType["Vector4"] = "Vector4";
|
|
1412
|
+
MaterialLoaderType["Color"] = "Color";
|
|
1413
|
+
MaterialLoaderType["Float"] = "Float";
|
|
1414
|
+
MaterialLoaderType["Texture"] = "Texture";
|
|
1415
|
+
MaterialLoaderType["Boolean"] = "Boolean";
|
|
1416
|
+
MaterialLoaderType["Integer"] = "Integer";
|
|
1417
|
+
return MaterialLoaderType;
|
|
1418
|
+
}({});
|
|
1419
|
+
|
|
1420
|
+
var SpecularMode = /*#__PURE__*/ function(SpecularMode) {
|
|
1421
|
+
SpecularMode["Sky"] = "Sky";
|
|
1422
|
+
SpecularMode["Custom"] = "Custom";
|
|
1423
|
+
return SpecularMode;
|
|
1424
|
+
}({});
|
|
1425
|
+
|
|
1394
1426
|
/** @Internal */ var SceneParser = /*#__PURE__*/ function(HierarchyParser) {
|
|
1395
1427
|
_inherits(SceneParser, HierarchyParser);
|
|
1396
1428
|
function SceneParser(data, context, scene) {
|
|
@@ -1399,6 +1431,43 @@ var EditorTexture2DContentRestorer = /*#__PURE__*/ function(ContentRestorer) {
|
|
|
1399
1431
|
return _this;
|
|
1400
1432
|
}
|
|
1401
1433
|
var _proto = SceneParser.prototype;
|
|
1434
|
+
/**
|
|
1435
|
+
* @internal
|
|
1436
|
+
*/ _proto._collectDependentAssets = function _collectDependentAssets(data) {
|
|
1437
|
+
var context = this.context;
|
|
1438
|
+
var resourceManager = context.resourceManager;
|
|
1439
|
+
this._parseDependentAssets(data);
|
|
1440
|
+
var scene = data.scene;
|
|
1441
|
+
var ambient = scene.ambient;
|
|
1442
|
+
if (ambient) {
|
|
1443
|
+
var useCustomAmbient = ambient.specularMode === SpecularMode.Custom;
|
|
1444
|
+
var useSH = ambient.diffuseMode === engineCore.DiffuseMode.SphericalHarmonics;
|
|
1445
|
+
var customAmbientLight = ambient.customAmbientLight, ambientLight = ambient.ambientLight;
|
|
1446
|
+
if (useCustomAmbient && customAmbientLight) {
|
|
1447
|
+
// @ts-ignore
|
|
1448
|
+
context._addDependentAsset(customAmbientLight.refId, resourceManager.getResourceByRef(customAmbientLight));
|
|
1449
|
+
}
|
|
1450
|
+
if (ambientLight && (!useCustomAmbient || useSH)) {
|
|
1451
|
+
// @ts-ignore
|
|
1452
|
+
context._addDependentAsset(ambientLight.refId, resourceManager.getResourceByRef(ambientLight));
|
|
1453
|
+
}
|
|
1454
|
+
}
|
|
1455
|
+
var background = scene.background;
|
|
1456
|
+
var backgroundMode = background.mode;
|
|
1457
|
+
if (backgroundMode === engineCore.BackgroundMode.Texture) {
|
|
1458
|
+
var texture = background.texture;
|
|
1459
|
+
// @ts-ignore
|
|
1460
|
+
texture && context._addDependentAsset(texture.refId, resourceManager.getResourceByRef(texture));
|
|
1461
|
+
} else if (backgroundMode === engineCore.BackgroundMode.Sky) {
|
|
1462
|
+
var skyMesh = background.skyMesh, skyMaterial = background.skyMaterial;
|
|
1463
|
+
if (skyMesh && skyMaterial) {
|
|
1464
|
+
// @ts-ignore
|
|
1465
|
+
context._addDependentAsset(skyMesh.refId, resourceManager.getResourceByRef(skyMesh));
|
|
1466
|
+
// @ts-ignore
|
|
1467
|
+
context._addDependentAsset(skyMaterial.refId, resourceManager.getResourceByRef(skyMaterial));
|
|
1468
|
+
}
|
|
1469
|
+
}
|
|
1470
|
+
};
|
|
1402
1471
|
_proto._handleRootEntity = function _handleRootEntity(id) {
|
|
1403
1472
|
var entityMap = this.context.entityMap;
|
|
1404
1473
|
this.scene.addRootEntity(entityMap.get(id));
|
|
@@ -1407,41 +1476,51 @@ var EditorTexture2DContentRestorer = /*#__PURE__*/ function(ContentRestorer) {
|
|
|
1407
1476
|
this.context.clear();
|
|
1408
1477
|
return this.scene;
|
|
1409
1478
|
};
|
|
1410
|
-
|
|
1411
|
-
|
|
1412
|
-
|
|
1413
|
-
|
|
1414
|
-
|
|
1415
|
-
|
|
1416
|
-
|
|
1417
|
-
|
|
1418
|
-
|
|
1419
|
-
|
|
1420
|
-
|
|
1421
|
-
|
|
1422
|
-
|
|
1479
|
+
_proto._parseDependentAssets = function _parseDependentAssets(file) {
|
|
1480
|
+
var entities = file.entities;
|
|
1481
|
+
for(var i = 0, n = entities.length; i < n; i++){
|
|
1482
|
+
var entity = entities[i];
|
|
1483
|
+
if (!!entity.assetRefId) {
|
|
1484
|
+
var context = this.context;
|
|
1485
|
+
var refId = entity.assetRefId, key = entity.key;
|
|
1486
|
+
// @ts-ignore
|
|
1487
|
+
context._addDependentAsset(refId, context.resourceManager.getResourceByRef({
|
|
1488
|
+
refId: refId,
|
|
1489
|
+
key: key
|
|
1490
|
+
}));
|
|
1491
|
+
} else if (entity.strippedId) {
|
|
1492
|
+
continue;
|
|
1493
|
+
} else {
|
|
1494
|
+
var components = entity.components;
|
|
1495
|
+
for(var j = 0, m = components.length; j < m; j++){
|
|
1496
|
+
var component = components[j];
|
|
1497
|
+
this._searchDependentAssets(component.methods);
|
|
1498
|
+
this._searchDependentAssets(component.props);
|
|
1499
|
+
}
|
|
1500
|
+
}
|
|
1501
|
+
}
|
|
1502
|
+
};
|
|
1503
|
+
_proto._searchDependentAssets = function _searchDependentAssets(value) {
|
|
1504
|
+
if (Array.isArray(value)) {
|
|
1505
|
+
for(var i = 0, n = value.length; i < n; i++){
|
|
1506
|
+
this._searchDependentAssets(value[i]);
|
|
1507
|
+
}
|
|
1508
|
+
} else if (!!value && (typeof value === "undefined" ? "undefined" : _type_of(value)) === "object") {
|
|
1509
|
+
// @ts-ignore
|
|
1510
|
+
if (ReflectionParser._isAssetRef(value)) {
|
|
1511
|
+
var context = this.context;
|
|
1512
|
+
// @ts-ignore
|
|
1513
|
+
context._addDependentAsset(value.refId, context.resourceManager.getResourceByRef(value));
|
|
1514
|
+
} else {
|
|
1515
|
+
for(var key in value){
|
|
1516
|
+
this._searchDependentAssets(value[key]);
|
|
1517
|
+
}
|
|
1518
|
+
}
|
|
1519
|
+
}
|
|
1423
1520
|
};
|
|
1424
1521
|
return SceneParser;
|
|
1425
1522
|
}(HierarchyParser);
|
|
1426
1523
|
|
|
1427
|
-
var MaterialLoaderType = /*#__PURE__*/ function(MaterialLoaderType) {
|
|
1428
|
-
MaterialLoaderType["Vector2"] = "Vector2";
|
|
1429
|
-
MaterialLoaderType["Vector3"] = "Vector3";
|
|
1430
|
-
MaterialLoaderType["Vector4"] = "Vector4";
|
|
1431
|
-
MaterialLoaderType["Color"] = "Color";
|
|
1432
|
-
MaterialLoaderType["Float"] = "Float";
|
|
1433
|
-
MaterialLoaderType["Texture"] = "Texture";
|
|
1434
|
-
MaterialLoaderType["Boolean"] = "Boolean";
|
|
1435
|
-
MaterialLoaderType["Integer"] = "Integer";
|
|
1436
|
-
return MaterialLoaderType;
|
|
1437
|
-
}({});
|
|
1438
|
-
|
|
1439
|
-
var SpecularMode = /*#__PURE__*/ function(SpecularMode) {
|
|
1440
|
-
SpecularMode["Sky"] = "Sky";
|
|
1441
|
-
SpecularMode["Custom"] = "Custom";
|
|
1442
|
-
return SpecularMode;
|
|
1443
|
-
}({});
|
|
1444
|
-
|
|
1445
1524
|
/**
|
|
1446
1525
|
* Decode engine binary resource.
|
|
1447
1526
|
* @param arrayBuffer - array buffer of decode binary file
|
|
@@ -2361,9 +2440,11 @@ function getMeshoptDecoder() {
|
|
|
2361
2440
|
var _this = this;
|
|
2362
2441
|
var task = this._progress.taskComplete;
|
|
2363
2442
|
task.total += 1;
|
|
2364
|
-
taskPromise.
|
|
2443
|
+
taskPromise.finally(function() {
|
|
2365
2444
|
_this._setTaskCompleteProgress(++task.loaded, task.total);
|
|
2366
|
-
}
|
|
2445
|
+
}).catch(function(e) {
|
|
2446
|
+
// Need catch to avoid unhandled rejection
|
|
2447
|
+
});
|
|
2367
2448
|
};
|
|
2368
2449
|
_proto._handleSubAsset = function _handleSubAsset(resource, type, index) {
|
|
2369
2450
|
var _this = this;
|
|
@@ -2429,8 +2510,8 @@ var GLTFParserType = /*#__PURE__*/ function(GLTFParserType) {
|
|
|
2429
2510
|
GLTFParserType[GLTFParserType["AnimatorController"] = 11] = "AnimatorController";
|
|
2430
2511
|
return GLTFParserType;
|
|
2431
2512
|
}({});
|
|
2432
|
-
var _obj$
|
|
2433
|
-
var glTFSchemaMap = (_obj$
|
|
2513
|
+
var _obj$2;
|
|
2514
|
+
var glTFSchemaMap = (_obj$2 = {}, _obj$2[2] = "scenes", _obj$2[3] = "buffers", _obj$2[5] = "textures", _obj$2[6] = "materials", _obj$2[7] = "meshes", _obj$2[8] = "nodes", _obj$2[9] = "skins", _obj$2[10] = "animations", _obj$2[4] = "bufferViews", _obj$2);
|
|
2434
2515
|
var _obj1$1;
|
|
2435
2516
|
var glTFResourceMap = (_obj1$1 = {}, _obj1$1[2] = "_sceneRoots", _obj1$1[5] = "textures", _obj1$1[6] = "materials", _obj1$1[7] = "meshes", _obj1$1[8] = "entities", _obj1$1[9] = "skins", _obj1$1[10] = "animations", _obj1$1[11] = "animatorController", _obj1$1);
|
|
2436
2517
|
function registerGLTFParser(pipeline) {
|
|
@@ -2832,12 +2913,11 @@ var DFDTransferFunction = /*#__PURE__*/ function(DFDTransferFunction) {
|
|
|
2832
2913
|
DFDTransferFunction[DFDTransferFunction["sRGB"] = 2] = "sRGB";
|
|
2833
2914
|
return DFDTransferFunction;
|
|
2834
2915
|
}({});
|
|
2835
|
-
var
|
|
2836
|
-
|
|
2837
|
-
|
|
2838
|
-
|
|
2839
|
-
|
|
2840
|
-
return SupercompressionScheme;
|
|
2916
|
+
var ColorModel = /*#__PURE__*/ function(ColorModel) {
|
|
2917
|
+
ColorModel[ColorModel["ETC1S"] = 163] = "ETC1S";
|
|
2918
|
+
ColorModel[ColorModel["UASTC_LDR_4X4"] = 166] = "UASTC_LDR_4X4";
|
|
2919
|
+
ColorModel[ColorModel["UASTC_HDR_4X4"] = 167] = "UASTC_HDR_4X4";
|
|
2920
|
+
return ColorModel;
|
|
2841
2921
|
}({});
|
|
2842
2922
|
/** @internal */ var KTX2Container = /*#__PURE__*/ function() {
|
|
2843
2923
|
function KTX2Container(buffer) {
|
|
@@ -2997,9 +3077,9 @@ var SupercompressionScheme = /*#__PURE__*/ function(SupercompressionScheme) {
|
|
|
2997
3077
|
}
|
|
2998
3078
|
},
|
|
2999
3079
|
{
|
|
3000
|
-
key: "
|
|
3080
|
+
key: "colorModel",
|
|
3001
3081
|
get: function get() {
|
|
3002
|
-
return this.dataFormatDescriptor.colorModel
|
|
3082
|
+
return this.dataFormatDescriptor.colorModel;
|
|
3003
3083
|
}
|
|
3004
3084
|
}
|
|
3005
3085
|
]);
|
|
@@ -3017,6 +3097,9 @@ var SupercompressionScheme = /*#__PURE__*/ function(SupercompressionScheme) {
|
|
|
3017
3097
|
/** R format, 8 bits per pixel. */ KTX2TargetFormat[KTX2TargetFormat["R8"] = 5] = "R8";
|
|
3018
3098
|
/** RG format, 16 bits per pixel. */ KTX2TargetFormat[KTX2TargetFormat["R8G8"] = 6] = "R8G8";
|
|
3019
3099
|
/** RGBA format, 32 bits per pixel. */ KTX2TargetFormat[KTX2TargetFormat["R8G8B8A8"] = 7] = "R8G8B8A8";
|
|
3100
|
+
/** RGB HDR compressed format, 8 bits per pixel. */ KTX2TargetFormat[KTX2TargetFormat["BC6H"] = 8] = "BC6H";
|
|
3101
|
+
/** HDR RGB(A) compressed format, 128 bits per 4x4 pixel block (currently UASTC HDR 4x4 encoders are only RGB). */ KTX2TargetFormat[KTX2TargetFormat["ASTC_HDR_4x4"] = 9] = "ASTC_HDR_4x4";
|
|
3102
|
+
/** RGBA format, 16 bits per channel. */ KTX2TargetFormat[KTX2TargetFormat["R16G16B16A16"] = 10] = "R16G16B16A16";
|
|
3020
3103
|
return KTX2TargetFormat;
|
|
3021
3104
|
}({});
|
|
3022
3105
|
|
|
@@ -3162,7 +3245,7 @@ var AbstractTranscoder = /*#__PURE__*/ function() {
|
|
|
3162
3245
|
return AbstractTranscoder;
|
|
3163
3246
|
}();
|
|
3164
3247
|
|
|
3165
|
-
/** @internal */ function TranscodeWorkerCode
|
|
3248
|
+
/** @internal */ function TranscodeWorkerCode() {
|
|
3166
3249
|
var initPromise;
|
|
3167
3250
|
var init = function init(wasmBinary) {
|
|
3168
3251
|
if (!initPromise) {
|
|
@@ -3246,6 +3329,12 @@ function transcode(buffer, targetFormat, KTX2File) {
|
|
|
3246
3329
|
return 10;
|
|
3247
3330
|
case 1:
|
|
3248
3331
|
return 7;
|
|
3332
|
+
case 8:
|
|
3333
|
+
return 22;
|
|
3334
|
+
case 9:
|
|
3335
|
+
return 23;
|
|
3336
|
+
case 10:
|
|
3337
|
+
return 25;
|
|
3249
3338
|
}
|
|
3250
3339
|
}
|
|
3251
3340
|
function concat(arrays) {
|
|
@@ -3302,6 +3391,9 @@ function transcode(buffer, targetFormat, KTX2File) {
|
|
|
3302
3391
|
}
|
|
3303
3392
|
var dst = new Uint8Array(ktx2File.getImageTranscodedSizeInBytes(mip, layer, 0, format));
|
|
3304
3393
|
var status = ktx2File.transcodeImage(dst, mip, layer, face, format, 0, -1, -1);
|
|
3394
|
+
if (targetFormat === 10) {
|
|
3395
|
+
dst = new Uint16Array(dst.buffer, dst.byteOffset, dst.byteLength / Uint16Array.BYTES_PER_ELEMENT);
|
|
3396
|
+
}
|
|
3305
3397
|
if (!status) {
|
|
3306
3398
|
cleanup();
|
|
3307
3399
|
throw new Error("transcodeImage failed.");
|
|
@@ -3363,7 +3455,7 @@ function transcode(buffer, targetFormat, KTX2File) {
|
|
|
3363
3455
|
};
|
|
3364
3456
|
});
|
|
3365
3457
|
} else {
|
|
3366
|
-
var funcCode = TranscodeWorkerCode
|
|
3458
|
+
var funcCode = TranscodeWorkerCode.toString();
|
|
3367
3459
|
var transcodeString = funcCode.substring(funcCode.indexOf("{"), funcCode.lastIndexOf("}") + 1);
|
|
3368
3460
|
var workerCode = "\n " + jsCode + "\n " + transcode.toString() + "\n " + transcodeString + "\n ";
|
|
3369
3461
|
var workerURL = URL.createObjectURL(new Blob([
|
|
@@ -3391,212 +3483,6 @@ function transcode(buffer, targetFormat, KTX2File) {
|
|
|
3391
3483
|
return BinomialLLCTranscoder;
|
|
3392
3484
|
}(AbstractTranscoder);
|
|
3393
3485
|
|
|
3394
|
-
function TranscodeWorkerCode() {
|
|
3395
|
-
var wasmPromise;
|
|
3396
|
-
/**
|
|
3397
|
-
* ZSTD (Zstandard) decoder.
|
|
3398
|
-
*/ var ZSTDDecoder = /*#__PURE__*/ function() {
|
|
3399
|
-
function ZSTDDecoder() {}
|
|
3400
|
-
var _proto = ZSTDDecoder.prototype;
|
|
3401
|
-
_proto.init = function init() {
|
|
3402
|
-
if (!this._initPromise) {
|
|
3403
|
-
this._initPromise = fetch(ZSTDDecoder.WasmModuleURL).then(function(response) {
|
|
3404
|
-
if (response.ok) {
|
|
3405
|
-
return response.arrayBuffer();
|
|
3406
|
-
}
|
|
3407
|
-
throw new Error("Could not fetch the wasm component for the Zstandard decompression lib: " + response.status + " - " + response.statusText);
|
|
3408
|
-
}).then(function(arrayBuffer) {
|
|
3409
|
-
return WebAssembly.instantiate(arrayBuffer, ZSTDDecoder.IMPORT_OBJECT);
|
|
3410
|
-
}).then(this._init);
|
|
3411
|
-
}
|
|
3412
|
-
return this._initPromise;
|
|
3413
|
-
};
|
|
3414
|
-
_proto._init = function _init(result) {
|
|
3415
|
-
ZSTDDecoder.instance = result.instance;
|
|
3416
|
-
ZSTDDecoder.IMPORT_OBJECT.env.emscripten_notify_memory_growth(); // initialize heap.
|
|
3417
|
-
};
|
|
3418
|
-
_proto.decode = function decode(array, uncompressedSize) {
|
|
3419
|
-
if (uncompressedSize === void 0) uncompressedSize = 0;
|
|
3420
|
-
if (!ZSTDDecoder.instance) {
|
|
3421
|
-
throw new Error("ZSTDDecoder: Await .init() before decoding.");
|
|
3422
|
-
}
|
|
3423
|
-
var exports = ZSTDDecoder.instance.exports;
|
|
3424
|
-
// Write compressed data into WASM memory
|
|
3425
|
-
var compressedSize = array.byteLength;
|
|
3426
|
-
var compressedPtr = exports.malloc(compressedSize);
|
|
3427
|
-
ZSTDDecoder.heap.set(array, compressedPtr);
|
|
3428
|
-
// Decompress into WASM memory
|
|
3429
|
-
uncompressedSize = uncompressedSize || Number(exports.ZSTD_findDecompressedSize(compressedPtr, compressedSize));
|
|
3430
|
-
var uncompressedPtr = exports.malloc(uncompressedSize);
|
|
3431
|
-
var actualSize = exports.ZSTD_decompress(uncompressedPtr, uncompressedSize, compressedPtr, compressedSize);
|
|
3432
|
-
// Read decompressed data and free WASM memory
|
|
3433
|
-
var dec = ZSTDDecoder.heap.slice(uncompressedPtr, uncompressedPtr + actualSize);
|
|
3434
|
-
exports.free(compressedPtr);
|
|
3435
|
-
exports.free(uncompressedPtr);
|
|
3436
|
-
return dec;
|
|
3437
|
-
};
|
|
3438
|
-
return ZSTDDecoder;
|
|
3439
|
-
}();
|
|
3440
|
-
ZSTDDecoder.IMPORT_OBJECT = {
|
|
3441
|
-
env: {
|
|
3442
|
-
emscripten_notify_memory_growth: function emscripten_notify_memory_growth() {
|
|
3443
|
-
ZSTDDecoder.heap = new Uint8Array(ZSTDDecoder.instance.exports.memory.buffer);
|
|
3444
|
-
}
|
|
3445
|
-
}
|
|
3446
|
-
};
|
|
3447
|
-
ZSTDDecoder.WasmModuleURL = "https://mdn.alipayobjects.com/rms/afts/file/A*awNJR7KqIAEAAAAAAAAAAAAAARQnAQ/zstddec.wasm";
|
|
3448
|
-
function transcodeASTCAndBC7(wasmTranscoder, compressedData, width, height) {
|
|
3449
|
-
var nBlocks = (width + 3 >> 2) * (height + 3 >> 2);
|
|
3450
|
-
var texMemoryPages = nBlocks * 16 + 65535 >> 16;
|
|
3451
|
-
var memory = wasmTranscoder.memory;
|
|
3452
|
-
var delta = texMemoryPages + 1 - (memory.buffer.byteLength >> 16);
|
|
3453
|
-
if (delta > 0) memory.grow(delta);
|
|
3454
|
-
var textureView = new Uint8Array(memory.buffer, 65536, nBlocks * 16);
|
|
3455
|
-
textureView.set(compressedData);
|
|
3456
|
-
return wasmTranscoder.transcode(nBlocks) === 0 ? textureView : null;
|
|
3457
|
-
}
|
|
3458
|
-
function initWasm(buffer) {
|
|
3459
|
-
wasmPromise = WebAssembly.instantiate(buffer, {
|
|
3460
|
-
env: {
|
|
3461
|
-
memory: new WebAssembly.Memory({
|
|
3462
|
-
initial: 16
|
|
3463
|
-
})
|
|
3464
|
-
}
|
|
3465
|
-
}).then(function(moduleWrapper) {
|
|
3466
|
-
return moduleWrapper.instance.exports;
|
|
3467
|
-
});
|
|
3468
|
-
return wasmPromise;
|
|
3469
|
-
}
|
|
3470
|
-
var zstdDecoder = new ZSTDDecoder();
|
|
3471
|
-
function transcode(data, needZstd, wasmModule) {
|
|
3472
|
-
var faceCount = data.length;
|
|
3473
|
-
var result = new Array(faceCount);
|
|
3474
|
-
var promise = Promise.resolve();
|
|
3475
|
-
if (needZstd) {
|
|
3476
|
-
zstdDecoder.init();
|
|
3477
|
-
promise = zstdDecoder._initPromise;
|
|
3478
|
-
}
|
|
3479
|
-
return promise.then(function() {
|
|
3480
|
-
for(var faceIndex = 0; faceIndex < faceCount; faceIndex++){
|
|
3481
|
-
var mipmapCount = data[faceIndex].length;
|
|
3482
|
-
var decodedData = new Array(mipmapCount);
|
|
3483
|
-
for(var i = 0; i < mipmapCount; i++){
|
|
3484
|
-
var _data_faceIndex_i = data[faceIndex][i], buffer = _data_faceIndex_i.buffer, levelHeight = _data_faceIndex_i.levelHeight, levelWidth = _data_faceIndex_i.levelWidth, uncompressedByteLength = _data_faceIndex_i.uncompressedByteLength;
|
|
3485
|
-
if (needZstd) buffer = zstdDecoder.decode(buffer.slice(), uncompressedByteLength);
|
|
3486
|
-
var faceByteLength = buffer.byteLength / faceCount;
|
|
3487
|
-
var originByteOffset = buffer.byteOffset;
|
|
3488
|
-
var decodedBuffer = transcodeASTCAndBC7(wasmModule, new Uint8Array(buffer.buffer, originByteOffset + faceIndex * faceByteLength, faceByteLength), levelWidth, levelHeight);
|
|
3489
|
-
if (decodedBuffer) {
|
|
3490
|
-
decodedData[i] = {
|
|
3491
|
-
// use wasm memory as buffer, should slice to avoid duplicate
|
|
3492
|
-
data: decodedBuffer.slice(),
|
|
3493
|
-
width: levelWidth,
|
|
3494
|
-
height: levelHeight
|
|
3495
|
-
};
|
|
3496
|
-
} else {
|
|
3497
|
-
throw "buffer decoded error";
|
|
3498
|
-
}
|
|
3499
|
-
}
|
|
3500
|
-
result[faceIndex] = decodedData;
|
|
3501
|
-
}
|
|
3502
|
-
return result;
|
|
3503
|
-
});
|
|
3504
|
-
}
|
|
3505
|
-
self.onmessage = function onmessage(event) {
|
|
3506
|
-
var message = event.data;
|
|
3507
|
-
switch(message.type){
|
|
3508
|
-
case "init":
|
|
3509
|
-
initWasm(message.transcoderWasm).then(function() {
|
|
3510
|
-
self.postMessage("init-completed");
|
|
3511
|
-
}).catch(function(e) {
|
|
3512
|
-
self.postMessage({
|
|
3513
|
-
error: e
|
|
3514
|
-
});
|
|
3515
|
-
});
|
|
3516
|
-
break;
|
|
3517
|
-
case "transcode":
|
|
3518
|
-
wasmPromise.then(function(module) {
|
|
3519
|
-
transcode(message.data, message.needZstd, module).then(function(decodedData) {
|
|
3520
|
-
self.postMessage(decodedData);
|
|
3521
|
-
}).catch(function(e) {
|
|
3522
|
-
return self.postMessage({
|
|
3523
|
-
error: e
|
|
3524
|
-
});
|
|
3525
|
-
});
|
|
3526
|
-
});
|
|
3527
|
-
break;
|
|
3528
|
-
}
|
|
3529
|
-
};
|
|
3530
|
-
}
|
|
3531
|
-
|
|
3532
|
-
/** @internal */ var KhronosTranscoder = /*#__PURE__*/ function(AbstractTranscoder) {
|
|
3533
|
-
_inherits(KhronosTranscoder, AbstractTranscoder);
|
|
3534
|
-
function KhronosTranscoder(workerLimitCount, type) {
|
|
3535
|
-
var _this;
|
|
3536
|
-
_this = AbstractTranscoder.call(this, workerLimitCount) || this, _this.type = type;
|
|
3537
|
-
return _this;
|
|
3538
|
-
}
|
|
3539
|
-
var _proto = KhronosTranscoder.prototype;
|
|
3540
|
-
_proto._initTranscodeWorkerPool = function _initTranscodeWorkerPool() {
|
|
3541
|
-
var _this = this;
|
|
3542
|
-
return fetch(KhronosTranscoder.transcoderMap[this.type]).then(function(res) {
|
|
3543
|
-
return res.arrayBuffer();
|
|
3544
|
-
}).then(function(wasmBuffer) {
|
|
3545
|
-
var funcCode = TranscodeWorkerCode.toString();
|
|
3546
|
-
var workerURL = URL.createObjectURL(new Blob([
|
|
3547
|
-
funcCode.substring(funcCode.indexOf("{") + 1, funcCode.lastIndexOf("}"))
|
|
3548
|
-
], {
|
|
3549
|
-
type: "application/javascript"
|
|
3550
|
-
}));
|
|
3551
|
-
return _this._createTranscodePool(workerURL, wasmBuffer);
|
|
3552
|
-
});
|
|
3553
|
-
};
|
|
3554
|
-
_proto.transcode = function transcode(ktx2Container) {
|
|
3555
|
-
var needZstd = ktx2Container.supercompressionScheme === SupercompressionScheme.Zstd;
|
|
3556
|
-
var levelCount = ktx2Container.levels.length;
|
|
3557
|
-
var faceCount = ktx2Container.faceCount;
|
|
3558
|
-
var decodedData = {
|
|
3559
|
-
width: ktx2Container.pixelWidth,
|
|
3560
|
-
height: ktx2Container.pixelHeight,
|
|
3561
|
-
mipmaps: null
|
|
3562
|
-
};
|
|
3563
|
-
var postMessageData = {
|
|
3564
|
-
type: "transcode",
|
|
3565
|
-
format: 0,
|
|
3566
|
-
needZstd: needZstd,
|
|
3567
|
-
data: new Array(faceCount)
|
|
3568
|
-
};
|
|
3569
|
-
var messageData = postMessageData.data;
|
|
3570
|
-
for(var faceIndex = 0; faceIndex < faceCount; faceIndex++){
|
|
3571
|
-
var mipmapData = new Array(levelCount);
|
|
3572
|
-
for(var mipmapIndex = 0; mipmapIndex < levelCount; mipmapIndex++){
|
|
3573
|
-
var level = ktx2Container.levels[mipmapIndex];
|
|
3574
|
-
var levelWidth = Math.floor(ktx2Container.pixelWidth / (1 << mipmapIndex)) || 1;
|
|
3575
|
-
var levelHeight = Math.floor(ktx2Container.pixelHeight / (1 << mipmapIndex)) || 1;
|
|
3576
|
-
var originBuffer = level.levelData.buffer;
|
|
3577
|
-
var originOffset = level.levelData.byteOffset;
|
|
3578
|
-
var originByteLength = level.levelData.byteLength;
|
|
3579
|
-
mipmapData[mipmapIndex] = {
|
|
3580
|
-
buffer: new Uint8Array(originBuffer, originOffset, originByteLength),
|
|
3581
|
-
levelWidth: levelWidth,
|
|
3582
|
-
levelHeight: levelHeight,
|
|
3583
|
-
uncompressedByteLength: level.uncompressedByteLength
|
|
3584
|
-
};
|
|
3585
|
-
}
|
|
3586
|
-
messageData[faceIndex] = mipmapData;
|
|
3587
|
-
}
|
|
3588
|
-
return this._transcodeWorkerPool.postMessage(postMessageData).then(function(data) {
|
|
3589
|
-
decodedData.faces = data;
|
|
3590
|
-
decodedData.hasAlpha = true;
|
|
3591
|
-
return decodedData;
|
|
3592
|
-
});
|
|
3593
|
-
};
|
|
3594
|
-
return KhronosTranscoder;
|
|
3595
|
-
}(AbstractTranscoder);
|
|
3596
|
-
var _obj$2;
|
|
3597
|
-
KhronosTranscoder.transcoderMap = (_obj$2 = {}, // TODO: support bc7
|
|
3598
|
-
_obj$2[KTX2TargetFormat.ASTC] = "https://mdn.alipayobjects.com/rms/afts/file/A*0jiKRK6D1-kAAAAAAAAAAAAAARQnAQ/uastc_astc.wasm", _obj$2);
|
|
3599
|
-
|
|
3600
3486
|
exports.KTX2Loader = /*#__PURE__*/ function(Loader) {
|
|
3601
3487
|
_inherits(KTX2Loader, Loader);
|
|
3602
3488
|
function KTX2Loader() {
|
|
@@ -3610,11 +3496,7 @@ exports.KTX2Loader = /*#__PURE__*/ function(Loader) {
|
|
|
3610
3496
|
KTX2Loader._priorityFormats["etc1s"] = options.priorityFormats;
|
|
3611
3497
|
KTX2Loader._priorityFormats["uastc"] = options.priorityFormats;
|
|
3612
3498
|
}
|
|
3613
|
-
|
|
3614
|
-
return KTX2Loader._getKhronosTranscoder(options.workerCount).init();
|
|
3615
|
-
} else {
|
|
3616
|
-
return KTX2Loader._getBinomialLLCTranscoder(options.workerCount).init();
|
|
3617
|
-
}
|
|
3499
|
+
return KTX2Loader._getBinomialLLCTranscoder(options.workerCount).init();
|
|
3618
3500
|
}
|
|
3619
3501
|
};
|
|
3620
3502
|
/**
|
|
@@ -3642,29 +3524,17 @@ exports.KTX2Loader = /*#__PURE__*/ function(Loader) {
|
|
|
3642
3524
|
* @remarks If use loader after releasing, we should release again.
|
|
3643
3525
|
*/ KTX2Loader.release = function release() {
|
|
3644
3526
|
if (this._binomialLLCTranscoder) this._binomialLLCTranscoder.destroy();
|
|
3645
|
-
if (this._khronosTranscoder) this._khronosTranscoder.destroy();
|
|
3646
3527
|
this._binomialLLCTranscoder = null;
|
|
3647
|
-
this._khronosTranscoder = null;
|
|
3648
|
-
this._isBinomialInit = false;
|
|
3649
3528
|
};
|
|
3650
3529
|
/** @internal */ KTX2Loader._parseBuffer = function _parseBuffer(buffer, engine, params) {
|
|
3651
3530
|
var ktx2Container = new KTX2Container(buffer);
|
|
3652
3531
|
var _params_priorityFormats;
|
|
3653
|
-
var formatPriorities = (_params_priorityFormats = params == null ? void 0 : params.priorityFormats) != null ? _params_priorityFormats : KTX2Loader._priorityFormats[ktx2Container.
|
|
3532
|
+
var formatPriorities = (_params_priorityFormats = params == null ? void 0 : params.priorityFormats) != null ? _params_priorityFormats : KTX2Loader._priorityFormats[ktx2Container.colorModel];
|
|
3654
3533
|
var targetFormat = KTX2Loader._decideTargetFormat(engine, ktx2Container, formatPriorities);
|
|
3655
|
-
var
|
|
3656
|
-
|
|
3657
|
-
|
|
3658
|
-
|
|
3659
|
-
return binomialLLCWorker.transcode(buffer, targetFormat);
|
|
3660
|
-
});
|
|
3661
|
-
} else {
|
|
3662
|
-
var khronosWorker = KTX2Loader._getKhronosTranscoder();
|
|
3663
|
-
transcodeResultPromise = khronosWorker.init().then(function() {
|
|
3664
|
-
return khronosWorker.transcode(ktx2Container);
|
|
3665
|
-
});
|
|
3666
|
-
}
|
|
3667
|
-
return transcodeResultPromise.then(function(result) {
|
|
3534
|
+
var binomialLLCWorker = KTX2Loader._getBinomialLLCTranscoder();
|
|
3535
|
+
return binomialLLCWorker.init().then(function() {
|
|
3536
|
+
return binomialLLCWorker.transcode(buffer, targetFormat);
|
|
3537
|
+
}).then(function(result) {
|
|
3668
3538
|
return {
|
|
3669
3539
|
ktx2Container: ktx2Container,
|
|
3670
3540
|
engine: engine,
|
|
@@ -3743,15 +3613,9 @@ exports.KTX2Loader = /*#__PURE__*/ function(Loader) {
|
|
|
3743
3613
|
};
|
|
3744
3614
|
KTX2Loader._getBinomialLLCTranscoder = function _getBinomialLLCTranscoder(workerCount) {
|
|
3745
3615
|
if (workerCount === void 0) workerCount = 4;
|
|
3746
|
-
KTX2Loader._isBinomialInit = true;
|
|
3747
3616
|
var _this__binomialLLCTranscoder;
|
|
3748
3617
|
return (_this__binomialLLCTranscoder = this._binomialLLCTranscoder) != null ? _this__binomialLLCTranscoder : this._binomialLLCTranscoder = new BinomialLLCTranscoder(workerCount);
|
|
3749
3618
|
};
|
|
3750
|
-
KTX2Loader._getKhronosTranscoder = function _getKhronosTranscoder(workerCount) {
|
|
3751
|
-
if (workerCount === void 0) workerCount = 4;
|
|
3752
|
-
var _this__khronosTranscoder;
|
|
3753
|
-
return (_this__khronosTranscoder = this._khronosTranscoder) != null ? _this__khronosTranscoder : this._khronosTranscoder = new KhronosTranscoder(workerCount, KTX2TargetFormat.ASTC);
|
|
3754
|
-
};
|
|
3755
3619
|
KTX2Loader._getEngineTextureFormat = function _getEngineTextureFormat(basisFormat, transcodeResult) {
|
|
3756
3620
|
var hasAlpha = transcodeResult.hasAlpha;
|
|
3757
3621
|
switch(basisFormat){
|
|
@@ -3767,52 +3631,65 @@ exports.KTX2Loader = /*#__PURE__*/ function(Loader) {
|
|
|
3767
3631
|
return hasAlpha ? engineCore.TextureFormat.PVRTC_RGBA4 : engineCore.TextureFormat.PVRTC_RGB4;
|
|
3768
3632
|
case KTX2TargetFormat.R8G8B8A8:
|
|
3769
3633
|
return engineCore.TextureFormat.R8G8B8A8;
|
|
3634
|
+
case KTX2TargetFormat.BC6H:
|
|
3635
|
+
return engineCore.TextureFormat.BC6H;
|
|
3636
|
+
case KTX2TargetFormat.ASTC_HDR_4x4:
|
|
3637
|
+
return engineCore.TextureFormat.ASTC_4x4;
|
|
3638
|
+
case KTX2TargetFormat.R16G16B16A16:
|
|
3639
|
+
return engineCore.TextureFormat.R16G16B16A16;
|
|
3770
3640
|
}
|
|
3771
3641
|
};
|
|
3772
3642
|
return KTX2Loader;
|
|
3773
3643
|
}(engineCore.Loader);
|
|
3774
|
-
|
|
3775
|
-
exports.KTX2Loader._priorityFormats = {
|
|
3776
|
-
|
|
3777
|
-
|
|
3778
|
-
|
|
3779
|
-
|
|
3780
|
-
|
|
3781
|
-
|
|
3782
|
-
|
|
3783
|
-
|
|
3784
|
-
|
|
3785
|
-
|
|
3786
|
-
|
|
3787
|
-
|
|
3788
|
-
|
|
3789
|
-
|
|
3790
|
-
|
|
3791
|
-
|
|
3792
|
-
|
|
3644
|
+
var _obj$1;
|
|
3645
|
+
exports.KTX2Loader._priorityFormats = (_obj$1 = {}, _obj$1[ColorModel.ETC1S] = [
|
|
3646
|
+
KTX2TargetFormat.ETC,
|
|
3647
|
+
KTX2TargetFormat.BC7,
|
|
3648
|
+
KTX2TargetFormat.ASTC,
|
|
3649
|
+
KTX2TargetFormat.BC1_BC3,
|
|
3650
|
+
KTX2TargetFormat.PVRTC
|
|
3651
|
+
], _obj$1[ColorModel.UASTC_LDR_4X4] = [
|
|
3652
|
+
KTX2TargetFormat.ASTC,
|
|
3653
|
+
KTX2TargetFormat.BC7,
|
|
3654
|
+
KTX2TargetFormat.ETC,
|
|
3655
|
+
KTX2TargetFormat.BC1_BC3,
|
|
3656
|
+
KTX2TargetFormat.PVRTC
|
|
3657
|
+
], _obj$1[ColorModel.UASTC_HDR_4X4] = [
|
|
3658
|
+
KTX2TargetFormat.ASTC_HDR_4x4,
|
|
3659
|
+
KTX2TargetFormat.BC6H,
|
|
3660
|
+
KTX2TargetFormat.R16G16B16A16
|
|
3661
|
+
], _obj$1);
|
|
3662
|
+
var _obj1, _obj2, _obj3, _obj4, _obj5, _obj6, _obj7, _obj8, _obj9;
|
|
3663
|
+
exports.KTX2Loader._capabilityMap = (_obj9 = {}, _obj9[KTX2TargetFormat.ASTC] = (_obj1 = {}, _obj1[DFDTransferFunction.linear] = [
|
|
3793
3664
|
engineCore.GLCapabilityType.astc,
|
|
3794
3665
|
engineCore.GLCapabilityType.astc_webkit
|
|
3795
|
-
],
|
|
3666
|
+
], _obj1[DFDTransferFunction.sRGB] = [
|
|
3796
3667
|
engineCore.GLCapabilityType.astc,
|
|
3797
3668
|
engineCore.GLCapabilityType.astc_webkit
|
|
3798
|
-
],
|
|
3669
|
+
], _obj1), _obj9[KTX2TargetFormat.ETC] = (_obj2 = {}, _obj2[DFDTransferFunction.linear] = [
|
|
3799
3670
|
engineCore.GLCapabilityType.etc,
|
|
3800
3671
|
engineCore.GLCapabilityType.etc_webkit
|
|
3801
|
-
],
|
|
3672
|
+
], _obj2[DFDTransferFunction.sRGB] = [
|
|
3802
3673
|
engineCore.GLCapabilityType.etc,
|
|
3803
3674
|
engineCore.GLCapabilityType.etc_webkit
|
|
3804
|
-
],
|
|
3675
|
+
], _obj2), _obj9[KTX2TargetFormat.BC7] = (_obj3 = {}, _obj3[DFDTransferFunction.linear] = [
|
|
3805
3676
|
engineCore.GLCapabilityType.bptc
|
|
3806
|
-
],
|
|
3677
|
+
], _obj3[DFDTransferFunction.sRGB] = [
|
|
3807
3678
|
engineCore.GLCapabilityType.bptc
|
|
3808
|
-
],
|
|
3679
|
+
], _obj3), _obj9[KTX2TargetFormat.BC1_BC3] = (_obj4 = {}, _obj4[DFDTransferFunction.linear] = [
|
|
3809
3680
|
engineCore.GLCapabilityType.s3tc
|
|
3810
|
-
],
|
|
3681
|
+
], _obj4[DFDTransferFunction.sRGB] = [
|
|
3811
3682
|
engineCore.GLCapabilityType.s3tc_srgb
|
|
3812
|
-
],
|
|
3683
|
+
], _obj4), _obj9[KTX2TargetFormat.BC6H] = (_obj5 = {}, _obj5[DFDTransferFunction.linear] = [
|
|
3684
|
+
engineCore.GLCapabilityType.bptc
|
|
3685
|
+
], _obj5), _obj9[KTX2TargetFormat.ASTC_HDR_4x4] = (_obj6 = {}, _obj6[DFDTransferFunction.linear] = [
|
|
3686
|
+
engineCore.GLCapabilityType.astc_hdr
|
|
3687
|
+
], _obj6), _obj9[KTX2TargetFormat.R16G16B16A16] = (_obj7 = {}, _obj7[DFDTransferFunction.linear] = [
|
|
3688
|
+
engineCore.GLCapabilityType.textureHalfFloat
|
|
3689
|
+
], _obj7), _obj9[KTX2TargetFormat.PVRTC] = (_obj8 = {}, _obj8[DFDTransferFunction.linear] = [
|
|
3813
3690
|
engineCore.GLCapabilityType.pvrtc,
|
|
3814
3691
|
engineCore.GLCapabilityType.pvrtc_webkit
|
|
3815
|
-
],
|
|
3692
|
+
], _obj8), _obj9);
|
|
3816
3693
|
exports.KTX2Loader = __decorate([
|
|
3817
3694
|
engineCore.resourceLoader(engineCore.AssetType.KTX2, [
|
|
3818
3695
|
"ktx2"
|
|
@@ -3842,11 +3719,6 @@ var KTX2ContentRestorer = /*#__PURE__*/ function(ContentRestorer) {
|
|
|
3842
3719
|
};
|
|
3843
3720
|
return KTX2ContentRestorer;
|
|
3844
3721
|
}(engineCore.ContentRestorer);
|
|
3845
|
-
/** Used for initialize KTX2 transcoder. */ var KTX2Transcoder = /*#__PURE__*/ function(KTX2Transcoder) {
|
|
3846
|
-
/** BinomialLLC transcoder. */ KTX2Transcoder[KTX2Transcoder["BinomialLLC"] = 0] = "BinomialLLC";
|
|
3847
|
-
/** Khronos transcoder. */ KTX2Transcoder[KTX2Transcoder["Khronos"] = 1] = "Khronos";
|
|
3848
|
-
return KTX2Transcoder;
|
|
3849
|
-
}({});
|
|
3850
3722
|
|
|
3851
3723
|
/**
|
|
3852
3724
|
* @internal
|
|
@@ -4586,7 +4458,7 @@ exports.GLTFMaterialParser = /*#__PURE__*/ function(GLTFParser1) {
|
|
|
4586
4458
|
}
|
|
4587
4459
|
}
|
|
4588
4460
|
}
|
|
4589
|
-
if (material.constructor === engineCore.PBRMaterial
|
|
4461
|
+
if (material.constructor === engineCore.PBRMaterial) {
|
|
4590
4462
|
if (emissiveTexture) {
|
|
4591
4463
|
GLTFMaterialParser._checkOtherTextureTransform(emissiveTexture, "Emissive");
|
|
4592
4464
|
context.get(GLTFParserType.Texture, emissiveTexture.index).then(function(texture) {
|
|
@@ -5149,7 +5021,7 @@ exports.GLTFTextureParser = /*#__PURE__*/ function(GLTFParser1) {
|
|
|
5149
5021
|
};
|
|
5150
5022
|
_proto._isSRGBColorSpace = function _isSRGBColorSpace(textureIndex, materials) {
|
|
5151
5023
|
return materials == null ? void 0 : materials.some(function(material) {
|
|
5152
|
-
var _material_emissiveTexture, _material_pbrMetallicRoughness_baseColorTexture, _material_pbrMetallicRoughness, _material_extensions_KHR_materials_sheen_sheenColorTexture, _material_extensions_KHR_materials_sheen, _material_extensions,
|
|
5024
|
+
var _material_emissiveTexture, _material_pbrMetallicRoughness_baseColorTexture, _material_pbrMetallicRoughness, _material_extensions_KHR_materials_sheen_sheenColorTexture, _material_extensions_KHR_materials_sheen, _material_extensions, _material_extensions_KHR_materials_specular_specularColorTexture, _material_extensions_KHR_materials_specular, _material_extensions1;
|
|
5153
5025
|
if (((_material_emissiveTexture = material.emissiveTexture) == null ? void 0 : _material_emissiveTexture.index) === textureIndex) {
|
|
5154
5026
|
return true;
|
|
5155
5027
|
}
|
|
@@ -5159,10 +5031,7 @@ exports.GLTFTextureParser = /*#__PURE__*/ function(GLTFParser1) {
|
|
|
5159
5031
|
if (((_material_extensions = material.extensions) == null ? void 0 : (_material_extensions_KHR_materials_sheen = _material_extensions.KHR_materials_sheen) == null ? void 0 : (_material_extensions_KHR_materials_sheen_sheenColorTexture = _material_extensions_KHR_materials_sheen.sheenColorTexture) == null ? void 0 : _material_extensions_KHR_materials_sheen_sheenColorTexture.index) === textureIndex) {
|
|
5160
5032
|
return true;
|
|
5161
5033
|
}
|
|
5162
|
-
if (((_material_extensions1 = material.extensions) == null ? void 0 : (
|
|
5163
|
-
return true;
|
|
5164
|
-
}
|
|
5165
|
-
if (((_material_extensions2 = material.extensions) == null ? void 0 : (_material_extensions_KHR_materials_pbrSpecularGlossiness1 = _material_extensions2.KHR_materials_pbrSpecularGlossiness) == null ? void 0 : (_material_extensions_KHR_materials_pbrSpecularGlossiness_specularGlossinessTexture = _material_extensions_KHR_materials_pbrSpecularGlossiness1.specularGlossinessTexture) == null ? void 0 : _material_extensions_KHR_materials_pbrSpecularGlossiness_specularGlossinessTexture.index) === textureIndex) {
|
|
5034
|
+
if (((_material_extensions1 = material.extensions) == null ? void 0 : (_material_extensions_KHR_materials_specular = _material_extensions1.KHR_materials_specular) == null ? void 0 : (_material_extensions_KHR_materials_specular_specularColorTexture = _material_extensions_KHR_materials_specular.specularColorTexture) == null ? void 0 : _material_extensions_KHR_materials_specular_specularColorTexture.index) === textureIndex) {
|
|
5166
5035
|
return true;
|
|
5167
5036
|
}
|
|
5168
5037
|
});
|
|
@@ -6269,7 +6138,7 @@ var ProjectLoader = /*#__PURE__*/ function(Loader) {
|
|
|
6269
6138
|
var _proto = ProjectLoader.prototype;
|
|
6270
6139
|
_proto.load = function load(item, resourceManager) {
|
|
6271
6140
|
var engine = resourceManager.engine;
|
|
6272
|
-
return new engineCore.AssetPromise(function(resolve, reject) {
|
|
6141
|
+
return new engineCore.AssetPromise(function(resolve, reject, onTaskCompeteProgress) {
|
|
6273
6142
|
resourceManager// @ts-ignore
|
|
6274
6143
|
._request(item.url, _extends({}, item, {
|
|
6275
6144
|
type: "json"
|
|
@@ -6279,7 +6148,7 @@ var ProjectLoader = /*#__PURE__*/ function(Loader) {
|
|
|
6279
6148
|
return resourceManager.load({
|
|
6280
6149
|
type: engineCore.AssetType.Scene,
|
|
6281
6150
|
url: data.scene
|
|
6282
|
-
}).then(function(scene) {
|
|
6151
|
+
}).onProgress(onTaskCompeteProgress).then(function(scene) {
|
|
6283
6152
|
engine.sceneManager.activeScene = scene;
|
|
6284
6153
|
resolve();
|
|
6285
6154
|
});
|
|
@@ -6796,12 +6665,18 @@ var SceneLoader = /*#__PURE__*/ function(Loader) {
|
|
|
6796
6665
|
var _proto = SceneLoader.prototype;
|
|
6797
6666
|
_proto.load = function load(item, resourceManager) {
|
|
6798
6667
|
var engine = resourceManager.engine;
|
|
6799
|
-
return new engineCore.AssetPromise(function(resolve, reject) {
|
|
6668
|
+
return new engineCore.AssetPromise(function(resolve, reject, setTaskCompleteProgress) {
|
|
6800
6669
|
resourceManager// @ts-ignore
|
|
6801
6670
|
._request(item.url, _extends({}, item, {
|
|
6802
6671
|
type: "json"
|
|
6803
6672
|
})).then(function(data) {
|
|
6804
|
-
|
|
6673
|
+
var scene = new engineCore.Scene(engine);
|
|
6674
|
+
var context = new ParserContext(engine, ParserType.Scene, scene);
|
|
6675
|
+
var parser = new SceneParser(data, context, scene);
|
|
6676
|
+
parser._collectDependentAssets(data);
|
|
6677
|
+
context._setTaskCompleteProgress = setTaskCompleteProgress;
|
|
6678
|
+
parser.start();
|
|
6679
|
+
return parser.promise.then(function() {
|
|
6805
6680
|
var promises = [];
|
|
6806
6681
|
// parse ambient light
|
|
6807
6682
|
var ambient = data.scene.ambient;
|
|
@@ -7023,51 +6898,6 @@ KHR_materials_ior = __decorate([
|
|
|
7023
6898
|
registerGLTFExtension("KHR_materials_ior", GLTFExtensionMode.AdditiveParse)
|
|
7024
6899
|
], KHR_materials_ior);
|
|
7025
6900
|
|
|
7026
|
-
var KHR_materials_pbrSpecularGlossiness = /*#__PURE__*/ function(GLTFExtensionParser) {
|
|
7027
|
-
_inherits(KHR_materials_pbrSpecularGlossiness, GLTFExtensionParser);
|
|
7028
|
-
function KHR_materials_pbrSpecularGlossiness() {
|
|
7029
|
-
return GLTFExtensionParser.apply(this, arguments) || this;
|
|
7030
|
-
}
|
|
7031
|
-
var _proto = KHR_materials_pbrSpecularGlossiness.prototype;
|
|
7032
|
-
_proto.createAndParse = function createAndParse(context, schema, ownerSchema) {
|
|
7033
|
-
var engine = context.glTFResource.engine;
|
|
7034
|
-
var material = new engineCore.PBRSpecularMaterial(engine);
|
|
7035
|
-
var diffuseFactor = schema.diffuseFactor, diffuseTexture = schema.diffuseTexture, specularFactor = schema.specularFactor, glossinessFactor = schema.glossinessFactor, specularGlossinessTexture = schema.specularGlossinessTexture;
|
|
7036
|
-
if (diffuseFactor) {
|
|
7037
|
-
material.baseColor.copyFromArray(diffuseFactor);
|
|
7038
|
-
}
|
|
7039
|
-
if (diffuseTexture) {
|
|
7040
|
-
context.get(GLTFParserType.Texture, diffuseTexture.index).then(function(texture) {
|
|
7041
|
-
material.baseTexture = texture;
|
|
7042
|
-
GLTFParser.executeExtensionsAdditiveAndParse(diffuseTexture.extensions, context, material, diffuseTexture);
|
|
7043
|
-
}).catch(function(e) {
|
|
7044
|
-
engineCore.Logger.error("KHR_materials_pbrSpecularGlossiness: diffuse texture error", e);
|
|
7045
|
-
});
|
|
7046
|
-
}
|
|
7047
|
-
if (specularFactor) {
|
|
7048
|
-
material.specularColor.set(specularFactor[0], specularFactor[1], specularFactor[2], 1.0);
|
|
7049
|
-
}
|
|
7050
|
-
if (glossinessFactor !== undefined) {
|
|
7051
|
-
material.glossiness = glossinessFactor;
|
|
7052
|
-
}
|
|
7053
|
-
if (specularGlossinessTexture) {
|
|
7054
|
-
exports.GLTFMaterialParser._checkOtherTextureTransform(specularGlossinessTexture, "Specular glossiness");
|
|
7055
|
-
context.get(GLTFParserType.Texture, specularGlossinessTexture.index).then(function(texture) {
|
|
7056
|
-
material.specularGlossinessTexture = texture;
|
|
7057
|
-
}).catch(function(e) {
|
|
7058
|
-
engineCore.Logger.error("KHR_materials_pbrSpecularGlossiness: specular glossiness texture error", e);
|
|
7059
|
-
});
|
|
7060
|
-
}
|
|
7061
|
-
material.name = ownerSchema.name;
|
|
7062
|
-
exports.GLTFMaterialParser._parseStandardProperty(context, material, ownerSchema);
|
|
7063
|
-
return material;
|
|
7064
|
-
};
|
|
7065
|
-
return KHR_materials_pbrSpecularGlossiness;
|
|
7066
|
-
}(GLTFExtensionParser);
|
|
7067
|
-
KHR_materials_pbrSpecularGlossiness = __decorate([
|
|
7068
|
-
registerGLTFExtension("KHR_materials_pbrSpecularGlossiness", GLTFExtensionMode.CreateAndParse)
|
|
7069
|
-
], KHR_materials_pbrSpecularGlossiness);
|
|
7070
|
-
|
|
7071
6901
|
var KHR_materials_sheen = /*#__PURE__*/ function(GLTFExtensionParser) {
|
|
7072
6902
|
_inherits(KHR_materials_sheen, GLTFExtensionParser);
|
|
7073
6903
|
function KHR_materials_sheen() {
|
|
@@ -7427,6 +7257,41 @@ KHR_materials_iridescence = __decorate([
|
|
|
7427
7257
|
registerGLTFExtension("KHR_materials_iridescence", GLTFExtensionMode.AdditiveParse)
|
|
7428
7258
|
], KHR_materials_iridescence);
|
|
7429
7259
|
|
|
7260
|
+
var KHR_materials_specular = /*#__PURE__*/ function(GLTFExtensionParser) {
|
|
7261
|
+
_inherits(KHR_materials_specular, GLTFExtensionParser);
|
|
7262
|
+
function KHR_materials_specular() {
|
|
7263
|
+
return GLTFExtensionParser.apply(this, arguments) || this;
|
|
7264
|
+
}
|
|
7265
|
+
var _proto = KHR_materials_specular.prototype;
|
|
7266
|
+
_proto.additiveParse = function additiveParse(context, material, schema) {
|
|
7267
|
+
var _schema_specularFactor = schema.specularFactor, specularFactor = _schema_specularFactor === void 0 ? 1 : _schema_specularFactor, specularTexture = schema.specularTexture, specularColorFactor = schema.specularColorFactor, specularColorTexture = schema.specularColorTexture;
|
|
7268
|
+
material.specularIntensity = specularFactor;
|
|
7269
|
+
if (specularColorFactor) {
|
|
7270
|
+
material.specularColor.set(specularColorFactor[0], specularColorFactor[1], specularColorFactor[2], undefined);
|
|
7271
|
+
}
|
|
7272
|
+
if (specularTexture) {
|
|
7273
|
+
exports.GLTFMaterialParser._checkOtherTextureTransform(specularTexture, "Specular intensity texture");
|
|
7274
|
+
context.get(GLTFParserType.Texture, specularTexture.index).then(function(texture) {
|
|
7275
|
+
material.specularIntensityTexture = texture;
|
|
7276
|
+
}).catch(function(e) {
|
|
7277
|
+
engineCore.Logger.error("KHR_materials_specular: specularTexture error", e);
|
|
7278
|
+
});
|
|
7279
|
+
}
|
|
7280
|
+
if (specularColorTexture) {
|
|
7281
|
+
exports.GLTFMaterialParser._checkOtherTextureTransform(specularColorTexture, "Specular color texture");
|
|
7282
|
+
context.get(GLTFParserType.Texture, specularColorTexture.index).then(function(texture) {
|
|
7283
|
+
material.specularColorTexture = texture;
|
|
7284
|
+
}).catch(function(e) {
|
|
7285
|
+
engineCore.Logger.error("KHR_materials_specular: SpecularColorTexture error", e);
|
|
7286
|
+
});
|
|
7287
|
+
}
|
|
7288
|
+
};
|
|
7289
|
+
return KHR_materials_specular;
|
|
7290
|
+
}(GLTFExtensionParser);
|
|
7291
|
+
KHR_materials_specular = __decorate([
|
|
7292
|
+
registerGLTFExtension("KHR_materials_specular", GLTFExtensionMode.AdditiveParse)
|
|
7293
|
+
], KHR_materials_specular);
|
|
7294
|
+
|
|
7430
7295
|
var EXT_texture_webp = /*#__PURE__*/ function(GLTFExtensionParser) {
|
|
7431
7296
|
_inherits(EXT_texture_webp, GLTFExtensionParser);
|
|
7432
7297
|
function EXT_texture_webp() {
|
|
@@ -7460,7 +7325,6 @@ exports.GLTFUtils = GLTFUtils;
|
|
|
7460
7325
|
exports.HierarchyParser = HierarchyParser;
|
|
7461
7326
|
exports.InterpolableValueType = InterpolableValueType;
|
|
7462
7327
|
exports.KTX2TargetFormat = KTX2TargetFormat;
|
|
7463
|
-
exports.KTX2Transcoder = KTX2Transcoder;
|
|
7464
7328
|
exports.MaterialLoaderType = MaterialLoaderType;
|
|
7465
7329
|
exports.ParserContext = ParserContext;
|
|
7466
7330
|
exports.ParserType = ParserType;
|