@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/module.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { Utils, AssetPromise, AnimationClip, AnimationEvent, Loader, AnimationStringCurve, Keyframe, AnimationBoolCurve, AnimationRefCurve, AnimationQuaternionCurve, AnimationColorCurve, AnimationVector4Curve, AnimationVector3Curve, AnimationVector2Curve, AnimationFloatArrayCurve, AnimationArrayCurve, AnimationFloatCurve, ModelMesh, BlendShape, Entity, Transform, Texture2D, ReferResource, resourceLoader, ContentRestorer,
|
|
1
|
+
import { Utils, AssetPromise, AnimationClip, AnimationEvent, Loader, AnimationStringCurve, Keyframe, AnimationBoolCurve, AnimationRefCurve, AnimationQuaternionCurve, AnimationColorCurve, AnimationVector4Curve, AnimationVector3Curve, AnimationVector2Curve, AnimationFloatArrayCurve, AnimationArrayCurve, AnimationFloatCurve, ModelMesh, BlendShape, Entity, Transform, Texture2D, ReferResource, resourceLoader, ContentRestorer, DiffuseMode, BackgroundMode, AssetType, AnimatorController, AnimatorControllerLayer, AnimatorStateTransition, AmbientLight, TextureCube, TextureFilterMode, TextureCubeFace, Font, SystemInfo, Animator, Logger, IndexFormat, VertexElementFormat, GLCapabilityType, TextureFormat, request, InterpolationType, SkinnedMeshRenderer, PBRMaterial, TextureCoordinate, RenderFace, VertexElement, Buffer, BufferBindFlag, BufferUsage, Camera, MeshRenderer, Skin, TextureWrapMode as TextureWrapMode$1, AnimatorStateMachine, Shader, Material, PrimitiveMesh, SpriteAtlas, Sprite, TextureUtils, AudioClip, AudioManager, ShaderFactory, ShaderLib, PhysicsMaterial, Scene, DirectLight, PointLight, SpotLight, UnlitMaterial } from '@galacean/engine-core';
|
|
2
2
|
import { Quaternion, Vector4, Color, Vector3, Vector2, SphericalHarmonics3, MathUtil, BoundingBox, Matrix, Rect } from '@galacean/engine-math';
|
|
3
3
|
import { GLCompressedTextureInternalFormat } from '@galacean/engine-rhi-webgl';
|
|
4
4
|
|
|
@@ -676,6 +676,9 @@ var ParserType = /*#__PURE__*/ function(ParserType) {
|
|
|
676
676
|
this.componentConfigMap = new Map();
|
|
677
677
|
this.rootIds = [];
|
|
678
678
|
this.strippedIds = [];
|
|
679
|
+
this._tasks = new Set();
|
|
680
|
+
this._loaded = 0;
|
|
681
|
+
this._total = 0;
|
|
679
682
|
this.resourceManager = engine.resourceManager;
|
|
680
683
|
}
|
|
681
684
|
var _proto = ParserContext.prototype;
|
|
@@ -687,6 +690,17 @@ var ParserType = /*#__PURE__*/ function(ParserType) {
|
|
|
687
690
|
this.rootIds.length = 0;
|
|
688
691
|
this.strippedIds.length = 0;
|
|
689
692
|
};
|
|
693
|
+
/** @internal */ _proto._addDependentAsset = function _addDependentAsset(refID, promise) {
|
|
694
|
+
var _this = this;
|
|
695
|
+
var tasks = this._tasks;
|
|
696
|
+
if (tasks.has(refID)) return;
|
|
697
|
+
++this._total;
|
|
698
|
+
tasks.add(refID);
|
|
699
|
+
promise.finally(function() {
|
|
700
|
+
++_this._loaded;
|
|
701
|
+
_this._setTaskCompleteProgress(_this._loaded, _this._total);
|
|
702
|
+
});
|
|
703
|
+
};
|
|
690
704
|
return ParserContext;
|
|
691
705
|
}();
|
|
692
706
|
|
|
@@ -1387,6 +1401,24 @@ var EditorTexture2DContentRestorer = /*#__PURE__*/ function(ContentRestorer) {
|
|
|
1387
1401
|
return EditorTexture2DContentRestorer;
|
|
1388
1402
|
}(ContentRestorer);
|
|
1389
1403
|
|
|
1404
|
+
var MaterialLoaderType = /*#__PURE__*/ function(MaterialLoaderType) {
|
|
1405
|
+
MaterialLoaderType["Vector2"] = "Vector2";
|
|
1406
|
+
MaterialLoaderType["Vector3"] = "Vector3";
|
|
1407
|
+
MaterialLoaderType["Vector4"] = "Vector4";
|
|
1408
|
+
MaterialLoaderType["Color"] = "Color";
|
|
1409
|
+
MaterialLoaderType["Float"] = "Float";
|
|
1410
|
+
MaterialLoaderType["Texture"] = "Texture";
|
|
1411
|
+
MaterialLoaderType["Boolean"] = "Boolean";
|
|
1412
|
+
MaterialLoaderType["Integer"] = "Integer";
|
|
1413
|
+
return MaterialLoaderType;
|
|
1414
|
+
}({});
|
|
1415
|
+
|
|
1416
|
+
var SpecularMode = /*#__PURE__*/ function(SpecularMode) {
|
|
1417
|
+
SpecularMode["Sky"] = "Sky";
|
|
1418
|
+
SpecularMode["Custom"] = "Custom";
|
|
1419
|
+
return SpecularMode;
|
|
1420
|
+
}({});
|
|
1421
|
+
|
|
1390
1422
|
/** @Internal */ var SceneParser = /*#__PURE__*/ function(HierarchyParser) {
|
|
1391
1423
|
_inherits(SceneParser, HierarchyParser);
|
|
1392
1424
|
function SceneParser(data, context, scene) {
|
|
@@ -1395,6 +1427,43 @@ var EditorTexture2DContentRestorer = /*#__PURE__*/ function(ContentRestorer) {
|
|
|
1395
1427
|
return _this;
|
|
1396
1428
|
}
|
|
1397
1429
|
var _proto = SceneParser.prototype;
|
|
1430
|
+
/**
|
|
1431
|
+
* @internal
|
|
1432
|
+
*/ _proto._collectDependentAssets = function _collectDependentAssets(data) {
|
|
1433
|
+
var context = this.context;
|
|
1434
|
+
var resourceManager = context.resourceManager;
|
|
1435
|
+
this._parseDependentAssets(data);
|
|
1436
|
+
var scene = data.scene;
|
|
1437
|
+
var ambient = scene.ambient;
|
|
1438
|
+
if (ambient) {
|
|
1439
|
+
var useCustomAmbient = ambient.specularMode === SpecularMode.Custom;
|
|
1440
|
+
var useSH = ambient.diffuseMode === DiffuseMode.SphericalHarmonics;
|
|
1441
|
+
var customAmbientLight = ambient.customAmbientLight, ambientLight = ambient.ambientLight;
|
|
1442
|
+
if (useCustomAmbient && customAmbientLight) {
|
|
1443
|
+
// @ts-ignore
|
|
1444
|
+
context._addDependentAsset(customAmbientLight.refId, resourceManager.getResourceByRef(customAmbientLight));
|
|
1445
|
+
}
|
|
1446
|
+
if (ambientLight && (!useCustomAmbient || useSH)) {
|
|
1447
|
+
// @ts-ignore
|
|
1448
|
+
context._addDependentAsset(ambientLight.refId, resourceManager.getResourceByRef(ambientLight));
|
|
1449
|
+
}
|
|
1450
|
+
}
|
|
1451
|
+
var background = scene.background;
|
|
1452
|
+
var backgroundMode = background.mode;
|
|
1453
|
+
if (backgroundMode === BackgroundMode.Texture) {
|
|
1454
|
+
var texture = background.texture;
|
|
1455
|
+
// @ts-ignore
|
|
1456
|
+
texture && context._addDependentAsset(texture.refId, resourceManager.getResourceByRef(texture));
|
|
1457
|
+
} else if (backgroundMode === BackgroundMode.Sky) {
|
|
1458
|
+
var skyMesh = background.skyMesh, skyMaterial = background.skyMaterial;
|
|
1459
|
+
if (skyMesh && skyMaterial) {
|
|
1460
|
+
// @ts-ignore
|
|
1461
|
+
context._addDependentAsset(skyMesh.refId, resourceManager.getResourceByRef(skyMesh));
|
|
1462
|
+
// @ts-ignore
|
|
1463
|
+
context._addDependentAsset(skyMaterial.refId, resourceManager.getResourceByRef(skyMaterial));
|
|
1464
|
+
}
|
|
1465
|
+
}
|
|
1466
|
+
};
|
|
1398
1467
|
_proto._handleRootEntity = function _handleRootEntity(id) {
|
|
1399
1468
|
var entityMap = this.context.entityMap;
|
|
1400
1469
|
this.scene.addRootEntity(entityMap.get(id));
|
|
@@ -1403,41 +1472,51 @@ var EditorTexture2DContentRestorer = /*#__PURE__*/ function(ContentRestorer) {
|
|
|
1403
1472
|
this.context.clear();
|
|
1404
1473
|
return this.scene;
|
|
1405
1474
|
};
|
|
1406
|
-
|
|
1407
|
-
|
|
1408
|
-
|
|
1409
|
-
|
|
1410
|
-
|
|
1411
|
-
|
|
1412
|
-
|
|
1413
|
-
|
|
1414
|
-
|
|
1415
|
-
|
|
1416
|
-
|
|
1417
|
-
|
|
1418
|
-
|
|
1475
|
+
_proto._parseDependentAssets = function _parseDependentAssets(file) {
|
|
1476
|
+
var entities = file.entities;
|
|
1477
|
+
for(var i = 0, n = entities.length; i < n; i++){
|
|
1478
|
+
var entity = entities[i];
|
|
1479
|
+
if (!!entity.assetRefId) {
|
|
1480
|
+
var context = this.context;
|
|
1481
|
+
var refId = entity.assetRefId, key = entity.key;
|
|
1482
|
+
// @ts-ignore
|
|
1483
|
+
context._addDependentAsset(refId, context.resourceManager.getResourceByRef({
|
|
1484
|
+
refId: refId,
|
|
1485
|
+
key: key
|
|
1486
|
+
}));
|
|
1487
|
+
} else if (entity.strippedId) {
|
|
1488
|
+
continue;
|
|
1489
|
+
} else {
|
|
1490
|
+
var components = entity.components;
|
|
1491
|
+
for(var j = 0, m = components.length; j < m; j++){
|
|
1492
|
+
var component = components[j];
|
|
1493
|
+
this._searchDependentAssets(component.methods);
|
|
1494
|
+
this._searchDependentAssets(component.props);
|
|
1495
|
+
}
|
|
1496
|
+
}
|
|
1497
|
+
}
|
|
1498
|
+
};
|
|
1499
|
+
_proto._searchDependentAssets = function _searchDependentAssets(value) {
|
|
1500
|
+
if (Array.isArray(value)) {
|
|
1501
|
+
for(var i = 0, n = value.length; i < n; i++){
|
|
1502
|
+
this._searchDependentAssets(value[i]);
|
|
1503
|
+
}
|
|
1504
|
+
} else if (!!value && (typeof value === "undefined" ? "undefined" : _type_of(value)) === "object") {
|
|
1505
|
+
// @ts-ignore
|
|
1506
|
+
if (ReflectionParser._isAssetRef(value)) {
|
|
1507
|
+
var context = this.context;
|
|
1508
|
+
// @ts-ignore
|
|
1509
|
+
context._addDependentAsset(value.refId, context.resourceManager.getResourceByRef(value));
|
|
1510
|
+
} else {
|
|
1511
|
+
for(var key in value){
|
|
1512
|
+
this._searchDependentAssets(value[key]);
|
|
1513
|
+
}
|
|
1514
|
+
}
|
|
1515
|
+
}
|
|
1419
1516
|
};
|
|
1420
1517
|
return SceneParser;
|
|
1421
1518
|
}(HierarchyParser);
|
|
1422
1519
|
|
|
1423
|
-
var MaterialLoaderType = /*#__PURE__*/ function(MaterialLoaderType) {
|
|
1424
|
-
MaterialLoaderType["Vector2"] = "Vector2";
|
|
1425
|
-
MaterialLoaderType["Vector3"] = "Vector3";
|
|
1426
|
-
MaterialLoaderType["Vector4"] = "Vector4";
|
|
1427
|
-
MaterialLoaderType["Color"] = "Color";
|
|
1428
|
-
MaterialLoaderType["Float"] = "Float";
|
|
1429
|
-
MaterialLoaderType["Texture"] = "Texture";
|
|
1430
|
-
MaterialLoaderType["Boolean"] = "Boolean";
|
|
1431
|
-
MaterialLoaderType["Integer"] = "Integer";
|
|
1432
|
-
return MaterialLoaderType;
|
|
1433
|
-
}({});
|
|
1434
|
-
|
|
1435
|
-
var SpecularMode = /*#__PURE__*/ function(SpecularMode) {
|
|
1436
|
-
SpecularMode["Sky"] = "Sky";
|
|
1437
|
-
SpecularMode["Custom"] = "Custom";
|
|
1438
|
-
return SpecularMode;
|
|
1439
|
-
}({});
|
|
1440
|
-
|
|
1441
1520
|
/**
|
|
1442
1521
|
* Decode engine binary resource.
|
|
1443
1522
|
* @param arrayBuffer - array buffer of decode binary file
|
|
@@ -2357,9 +2436,11 @@ function getMeshoptDecoder() {
|
|
|
2357
2436
|
var _this = this;
|
|
2358
2437
|
var task = this._progress.taskComplete;
|
|
2359
2438
|
task.total += 1;
|
|
2360
|
-
taskPromise.
|
|
2439
|
+
taskPromise.finally(function() {
|
|
2361
2440
|
_this._setTaskCompleteProgress(++task.loaded, task.total);
|
|
2362
|
-
}
|
|
2441
|
+
}).catch(function(e) {
|
|
2442
|
+
// Need catch to avoid unhandled rejection
|
|
2443
|
+
});
|
|
2363
2444
|
};
|
|
2364
2445
|
_proto._handleSubAsset = function _handleSubAsset(resource, type, index) {
|
|
2365
2446
|
var _this = this;
|
|
@@ -2425,8 +2506,8 @@ var GLTFParserType = /*#__PURE__*/ function(GLTFParserType) {
|
|
|
2425
2506
|
GLTFParserType[GLTFParserType["AnimatorController"] = 11] = "AnimatorController";
|
|
2426
2507
|
return GLTFParserType;
|
|
2427
2508
|
}({});
|
|
2428
|
-
var _obj$
|
|
2429
|
-
var glTFSchemaMap = (_obj$
|
|
2509
|
+
var _obj$2;
|
|
2510
|
+
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);
|
|
2430
2511
|
var _obj1$1;
|
|
2431
2512
|
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);
|
|
2432
2513
|
function registerGLTFParser(pipeline) {
|
|
@@ -2828,12 +2909,11 @@ var DFDTransferFunction = /*#__PURE__*/ function(DFDTransferFunction) {
|
|
|
2828
2909
|
DFDTransferFunction[DFDTransferFunction["sRGB"] = 2] = "sRGB";
|
|
2829
2910
|
return DFDTransferFunction;
|
|
2830
2911
|
}({});
|
|
2831
|
-
var
|
|
2832
|
-
|
|
2833
|
-
|
|
2834
|
-
|
|
2835
|
-
|
|
2836
|
-
return SupercompressionScheme;
|
|
2912
|
+
var ColorModel = /*#__PURE__*/ function(ColorModel) {
|
|
2913
|
+
ColorModel[ColorModel["ETC1S"] = 163] = "ETC1S";
|
|
2914
|
+
ColorModel[ColorModel["UASTC_LDR_4X4"] = 166] = "UASTC_LDR_4X4";
|
|
2915
|
+
ColorModel[ColorModel["UASTC_HDR_4X4"] = 167] = "UASTC_HDR_4X4";
|
|
2916
|
+
return ColorModel;
|
|
2837
2917
|
}({});
|
|
2838
2918
|
/** @internal */ var KTX2Container = /*#__PURE__*/ function() {
|
|
2839
2919
|
function KTX2Container(buffer) {
|
|
@@ -2993,9 +3073,9 @@ var SupercompressionScheme = /*#__PURE__*/ function(SupercompressionScheme) {
|
|
|
2993
3073
|
}
|
|
2994
3074
|
},
|
|
2995
3075
|
{
|
|
2996
|
-
key: "
|
|
3076
|
+
key: "colorModel",
|
|
2997
3077
|
get: function get() {
|
|
2998
|
-
return this.dataFormatDescriptor.colorModel
|
|
3078
|
+
return this.dataFormatDescriptor.colorModel;
|
|
2999
3079
|
}
|
|
3000
3080
|
}
|
|
3001
3081
|
]);
|
|
@@ -3013,6 +3093,9 @@ var SupercompressionScheme = /*#__PURE__*/ function(SupercompressionScheme) {
|
|
|
3013
3093
|
/** R format, 8 bits per pixel. */ KTX2TargetFormat[KTX2TargetFormat["R8"] = 5] = "R8";
|
|
3014
3094
|
/** RG format, 16 bits per pixel. */ KTX2TargetFormat[KTX2TargetFormat["R8G8"] = 6] = "R8G8";
|
|
3015
3095
|
/** RGBA format, 32 bits per pixel. */ KTX2TargetFormat[KTX2TargetFormat["R8G8B8A8"] = 7] = "R8G8B8A8";
|
|
3096
|
+
/** RGB HDR compressed format, 8 bits per pixel. */ KTX2TargetFormat[KTX2TargetFormat["BC6H"] = 8] = "BC6H";
|
|
3097
|
+
/** 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";
|
|
3098
|
+
/** RGBA format, 16 bits per channel. */ KTX2TargetFormat[KTX2TargetFormat["R16G16B16A16"] = 10] = "R16G16B16A16";
|
|
3016
3099
|
return KTX2TargetFormat;
|
|
3017
3100
|
}({});
|
|
3018
3101
|
|
|
@@ -3158,7 +3241,7 @@ var AbstractTranscoder = /*#__PURE__*/ function() {
|
|
|
3158
3241
|
return AbstractTranscoder;
|
|
3159
3242
|
}();
|
|
3160
3243
|
|
|
3161
|
-
/** @internal */ function TranscodeWorkerCode
|
|
3244
|
+
/** @internal */ function TranscodeWorkerCode() {
|
|
3162
3245
|
var initPromise;
|
|
3163
3246
|
var init = function init(wasmBinary) {
|
|
3164
3247
|
if (!initPromise) {
|
|
@@ -3242,6 +3325,12 @@ function transcode(buffer, targetFormat, KTX2File) {
|
|
|
3242
3325
|
return 10;
|
|
3243
3326
|
case 1:
|
|
3244
3327
|
return 7;
|
|
3328
|
+
case 8:
|
|
3329
|
+
return 22;
|
|
3330
|
+
case 9:
|
|
3331
|
+
return 23;
|
|
3332
|
+
case 10:
|
|
3333
|
+
return 25;
|
|
3245
3334
|
}
|
|
3246
3335
|
}
|
|
3247
3336
|
function concat(arrays) {
|
|
@@ -3298,6 +3387,9 @@ function transcode(buffer, targetFormat, KTX2File) {
|
|
|
3298
3387
|
}
|
|
3299
3388
|
var dst = new Uint8Array(ktx2File.getImageTranscodedSizeInBytes(mip, layer, 0, format));
|
|
3300
3389
|
var status = ktx2File.transcodeImage(dst, mip, layer, face, format, 0, -1, -1);
|
|
3390
|
+
if (targetFormat === 10) {
|
|
3391
|
+
dst = new Uint16Array(dst.buffer, dst.byteOffset, dst.byteLength / Uint16Array.BYTES_PER_ELEMENT);
|
|
3392
|
+
}
|
|
3301
3393
|
if (!status) {
|
|
3302
3394
|
cleanup();
|
|
3303
3395
|
throw new Error("transcodeImage failed.");
|
|
@@ -3359,7 +3451,7 @@ function transcode(buffer, targetFormat, KTX2File) {
|
|
|
3359
3451
|
};
|
|
3360
3452
|
});
|
|
3361
3453
|
} else {
|
|
3362
|
-
var funcCode = TranscodeWorkerCode
|
|
3454
|
+
var funcCode = TranscodeWorkerCode.toString();
|
|
3363
3455
|
var transcodeString = funcCode.substring(funcCode.indexOf("{"), funcCode.lastIndexOf("}") + 1);
|
|
3364
3456
|
var workerCode = "\n " + jsCode + "\n " + transcode.toString() + "\n " + transcodeString + "\n ";
|
|
3365
3457
|
var workerURL = URL.createObjectURL(new Blob([
|
|
@@ -3387,212 +3479,6 @@ function transcode(buffer, targetFormat, KTX2File) {
|
|
|
3387
3479
|
return BinomialLLCTranscoder;
|
|
3388
3480
|
}(AbstractTranscoder);
|
|
3389
3481
|
|
|
3390
|
-
function TranscodeWorkerCode() {
|
|
3391
|
-
var wasmPromise;
|
|
3392
|
-
/**
|
|
3393
|
-
* ZSTD (Zstandard) decoder.
|
|
3394
|
-
*/ var ZSTDDecoder = /*#__PURE__*/ function() {
|
|
3395
|
-
function ZSTDDecoder() {}
|
|
3396
|
-
var _proto = ZSTDDecoder.prototype;
|
|
3397
|
-
_proto.init = function init() {
|
|
3398
|
-
if (!this._initPromise) {
|
|
3399
|
-
this._initPromise = fetch(ZSTDDecoder.WasmModuleURL).then(function(response) {
|
|
3400
|
-
if (response.ok) {
|
|
3401
|
-
return response.arrayBuffer();
|
|
3402
|
-
}
|
|
3403
|
-
throw new Error("Could not fetch the wasm component for the Zstandard decompression lib: " + response.status + " - " + response.statusText);
|
|
3404
|
-
}).then(function(arrayBuffer) {
|
|
3405
|
-
return WebAssembly.instantiate(arrayBuffer, ZSTDDecoder.IMPORT_OBJECT);
|
|
3406
|
-
}).then(this._init);
|
|
3407
|
-
}
|
|
3408
|
-
return this._initPromise;
|
|
3409
|
-
};
|
|
3410
|
-
_proto._init = function _init(result) {
|
|
3411
|
-
ZSTDDecoder.instance = result.instance;
|
|
3412
|
-
ZSTDDecoder.IMPORT_OBJECT.env.emscripten_notify_memory_growth(); // initialize heap.
|
|
3413
|
-
};
|
|
3414
|
-
_proto.decode = function decode(array, uncompressedSize) {
|
|
3415
|
-
if (uncompressedSize === void 0) uncompressedSize = 0;
|
|
3416
|
-
if (!ZSTDDecoder.instance) {
|
|
3417
|
-
throw new Error("ZSTDDecoder: Await .init() before decoding.");
|
|
3418
|
-
}
|
|
3419
|
-
var exports = ZSTDDecoder.instance.exports;
|
|
3420
|
-
// Write compressed data into WASM memory
|
|
3421
|
-
var compressedSize = array.byteLength;
|
|
3422
|
-
var compressedPtr = exports.malloc(compressedSize);
|
|
3423
|
-
ZSTDDecoder.heap.set(array, compressedPtr);
|
|
3424
|
-
// Decompress into WASM memory
|
|
3425
|
-
uncompressedSize = uncompressedSize || Number(exports.ZSTD_findDecompressedSize(compressedPtr, compressedSize));
|
|
3426
|
-
var uncompressedPtr = exports.malloc(uncompressedSize);
|
|
3427
|
-
var actualSize = exports.ZSTD_decompress(uncompressedPtr, uncompressedSize, compressedPtr, compressedSize);
|
|
3428
|
-
// Read decompressed data and free WASM memory
|
|
3429
|
-
var dec = ZSTDDecoder.heap.slice(uncompressedPtr, uncompressedPtr + actualSize);
|
|
3430
|
-
exports.free(compressedPtr);
|
|
3431
|
-
exports.free(uncompressedPtr);
|
|
3432
|
-
return dec;
|
|
3433
|
-
};
|
|
3434
|
-
return ZSTDDecoder;
|
|
3435
|
-
}();
|
|
3436
|
-
ZSTDDecoder.IMPORT_OBJECT = {
|
|
3437
|
-
env: {
|
|
3438
|
-
emscripten_notify_memory_growth: function emscripten_notify_memory_growth() {
|
|
3439
|
-
ZSTDDecoder.heap = new Uint8Array(ZSTDDecoder.instance.exports.memory.buffer);
|
|
3440
|
-
}
|
|
3441
|
-
}
|
|
3442
|
-
};
|
|
3443
|
-
ZSTDDecoder.WasmModuleURL = "https://mdn.alipayobjects.com/rms/afts/file/A*awNJR7KqIAEAAAAAAAAAAAAAARQnAQ/zstddec.wasm";
|
|
3444
|
-
function transcodeASTCAndBC7(wasmTranscoder, compressedData, width, height) {
|
|
3445
|
-
var nBlocks = (width + 3 >> 2) * (height + 3 >> 2);
|
|
3446
|
-
var texMemoryPages = nBlocks * 16 + 65535 >> 16;
|
|
3447
|
-
var memory = wasmTranscoder.memory;
|
|
3448
|
-
var delta = texMemoryPages + 1 - (memory.buffer.byteLength >> 16);
|
|
3449
|
-
if (delta > 0) memory.grow(delta);
|
|
3450
|
-
var textureView = new Uint8Array(memory.buffer, 65536, nBlocks * 16);
|
|
3451
|
-
textureView.set(compressedData);
|
|
3452
|
-
return wasmTranscoder.transcode(nBlocks) === 0 ? textureView : null;
|
|
3453
|
-
}
|
|
3454
|
-
function initWasm(buffer) {
|
|
3455
|
-
wasmPromise = WebAssembly.instantiate(buffer, {
|
|
3456
|
-
env: {
|
|
3457
|
-
memory: new WebAssembly.Memory({
|
|
3458
|
-
initial: 16
|
|
3459
|
-
})
|
|
3460
|
-
}
|
|
3461
|
-
}).then(function(moduleWrapper) {
|
|
3462
|
-
return moduleWrapper.instance.exports;
|
|
3463
|
-
});
|
|
3464
|
-
return wasmPromise;
|
|
3465
|
-
}
|
|
3466
|
-
var zstdDecoder = new ZSTDDecoder();
|
|
3467
|
-
function transcode(data, needZstd, wasmModule) {
|
|
3468
|
-
var faceCount = data.length;
|
|
3469
|
-
var result = new Array(faceCount);
|
|
3470
|
-
var promise = Promise.resolve();
|
|
3471
|
-
if (needZstd) {
|
|
3472
|
-
zstdDecoder.init();
|
|
3473
|
-
promise = zstdDecoder._initPromise;
|
|
3474
|
-
}
|
|
3475
|
-
return promise.then(function() {
|
|
3476
|
-
for(var faceIndex = 0; faceIndex < faceCount; faceIndex++){
|
|
3477
|
-
var mipmapCount = data[faceIndex].length;
|
|
3478
|
-
var decodedData = new Array(mipmapCount);
|
|
3479
|
-
for(var i = 0; i < mipmapCount; i++){
|
|
3480
|
-
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;
|
|
3481
|
-
if (needZstd) buffer = zstdDecoder.decode(buffer.slice(), uncompressedByteLength);
|
|
3482
|
-
var faceByteLength = buffer.byteLength / faceCount;
|
|
3483
|
-
var originByteOffset = buffer.byteOffset;
|
|
3484
|
-
var decodedBuffer = transcodeASTCAndBC7(wasmModule, new Uint8Array(buffer.buffer, originByteOffset + faceIndex * faceByteLength, faceByteLength), levelWidth, levelHeight);
|
|
3485
|
-
if (decodedBuffer) {
|
|
3486
|
-
decodedData[i] = {
|
|
3487
|
-
// use wasm memory as buffer, should slice to avoid duplicate
|
|
3488
|
-
data: decodedBuffer.slice(),
|
|
3489
|
-
width: levelWidth,
|
|
3490
|
-
height: levelHeight
|
|
3491
|
-
};
|
|
3492
|
-
} else {
|
|
3493
|
-
throw "buffer decoded error";
|
|
3494
|
-
}
|
|
3495
|
-
}
|
|
3496
|
-
result[faceIndex] = decodedData;
|
|
3497
|
-
}
|
|
3498
|
-
return result;
|
|
3499
|
-
});
|
|
3500
|
-
}
|
|
3501
|
-
self.onmessage = function onmessage(event) {
|
|
3502
|
-
var message = event.data;
|
|
3503
|
-
switch(message.type){
|
|
3504
|
-
case "init":
|
|
3505
|
-
initWasm(message.transcoderWasm).then(function() {
|
|
3506
|
-
self.postMessage("init-completed");
|
|
3507
|
-
}).catch(function(e) {
|
|
3508
|
-
self.postMessage({
|
|
3509
|
-
error: e
|
|
3510
|
-
});
|
|
3511
|
-
});
|
|
3512
|
-
break;
|
|
3513
|
-
case "transcode":
|
|
3514
|
-
wasmPromise.then(function(module) {
|
|
3515
|
-
transcode(message.data, message.needZstd, module).then(function(decodedData) {
|
|
3516
|
-
self.postMessage(decodedData);
|
|
3517
|
-
}).catch(function(e) {
|
|
3518
|
-
return self.postMessage({
|
|
3519
|
-
error: e
|
|
3520
|
-
});
|
|
3521
|
-
});
|
|
3522
|
-
});
|
|
3523
|
-
break;
|
|
3524
|
-
}
|
|
3525
|
-
};
|
|
3526
|
-
}
|
|
3527
|
-
|
|
3528
|
-
/** @internal */ var KhronosTranscoder = /*#__PURE__*/ function(AbstractTranscoder) {
|
|
3529
|
-
_inherits(KhronosTranscoder, AbstractTranscoder);
|
|
3530
|
-
function KhronosTranscoder(workerLimitCount, type) {
|
|
3531
|
-
var _this;
|
|
3532
|
-
_this = AbstractTranscoder.call(this, workerLimitCount) || this, _this.type = type;
|
|
3533
|
-
return _this;
|
|
3534
|
-
}
|
|
3535
|
-
var _proto = KhronosTranscoder.prototype;
|
|
3536
|
-
_proto._initTranscodeWorkerPool = function _initTranscodeWorkerPool() {
|
|
3537
|
-
var _this = this;
|
|
3538
|
-
return fetch(KhronosTranscoder.transcoderMap[this.type]).then(function(res) {
|
|
3539
|
-
return res.arrayBuffer();
|
|
3540
|
-
}).then(function(wasmBuffer) {
|
|
3541
|
-
var funcCode = TranscodeWorkerCode.toString();
|
|
3542
|
-
var workerURL = URL.createObjectURL(new Blob([
|
|
3543
|
-
funcCode.substring(funcCode.indexOf("{") + 1, funcCode.lastIndexOf("}"))
|
|
3544
|
-
], {
|
|
3545
|
-
type: "application/javascript"
|
|
3546
|
-
}));
|
|
3547
|
-
return _this._createTranscodePool(workerURL, wasmBuffer);
|
|
3548
|
-
});
|
|
3549
|
-
};
|
|
3550
|
-
_proto.transcode = function transcode(ktx2Container) {
|
|
3551
|
-
var needZstd = ktx2Container.supercompressionScheme === SupercompressionScheme.Zstd;
|
|
3552
|
-
var levelCount = ktx2Container.levels.length;
|
|
3553
|
-
var faceCount = ktx2Container.faceCount;
|
|
3554
|
-
var decodedData = {
|
|
3555
|
-
width: ktx2Container.pixelWidth,
|
|
3556
|
-
height: ktx2Container.pixelHeight,
|
|
3557
|
-
mipmaps: null
|
|
3558
|
-
};
|
|
3559
|
-
var postMessageData = {
|
|
3560
|
-
type: "transcode",
|
|
3561
|
-
format: 0,
|
|
3562
|
-
needZstd: needZstd,
|
|
3563
|
-
data: new Array(faceCount)
|
|
3564
|
-
};
|
|
3565
|
-
var messageData = postMessageData.data;
|
|
3566
|
-
for(var faceIndex = 0; faceIndex < faceCount; faceIndex++){
|
|
3567
|
-
var mipmapData = new Array(levelCount);
|
|
3568
|
-
for(var mipmapIndex = 0; mipmapIndex < levelCount; mipmapIndex++){
|
|
3569
|
-
var level = ktx2Container.levels[mipmapIndex];
|
|
3570
|
-
var levelWidth = Math.floor(ktx2Container.pixelWidth / (1 << mipmapIndex)) || 1;
|
|
3571
|
-
var levelHeight = Math.floor(ktx2Container.pixelHeight / (1 << mipmapIndex)) || 1;
|
|
3572
|
-
var originBuffer = level.levelData.buffer;
|
|
3573
|
-
var originOffset = level.levelData.byteOffset;
|
|
3574
|
-
var originByteLength = level.levelData.byteLength;
|
|
3575
|
-
mipmapData[mipmapIndex] = {
|
|
3576
|
-
buffer: new Uint8Array(originBuffer, originOffset, originByteLength),
|
|
3577
|
-
levelWidth: levelWidth,
|
|
3578
|
-
levelHeight: levelHeight,
|
|
3579
|
-
uncompressedByteLength: level.uncompressedByteLength
|
|
3580
|
-
};
|
|
3581
|
-
}
|
|
3582
|
-
messageData[faceIndex] = mipmapData;
|
|
3583
|
-
}
|
|
3584
|
-
return this._transcodeWorkerPool.postMessage(postMessageData).then(function(data) {
|
|
3585
|
-
decodedData.faces = data;
|
|
3586
|
-
decodedData.hasAlpha = true;
|
|
3587
|
-
return decodedData;
|
|
3588
|
-
});
|
|
3589
|
-
};
|
|
3590
|
-
return KhronosTranscoder;
|
|
3591
|
-
}(AbstractTranscoder);
|
|
3592
|
-
var _obj$2;
|
|
3593
|
-
KhronosTranscoder.transcoderMap = (_obj$2 = {}, // TODO: support bc7
|
|
3594
|
-
_obj$2[KTX2TargetFormat.ASTC] = "https://mdn.alipayobjects.com/rms/afts/file/A*0jiKRK6D1-kAAAAAAAAAAAAAARQnAQ/uastc_astc.wasm", _obj$2);
|
|
3595
|
-
|
|
3596
3482
|
var KTX2Loader = /*#__PURE__*/ function(Loader) {
|
|
3597
3483
|
_inherits(KTX2Loader, Loader);
|
|
3598
3484
|
function KTX2Loader() {
|
|
@@ -3606,11 +3492,7 @@ var KTX2Loader = /*#__PURE__*/ function(Loader) {
|
|
|
3606
3492
|
KTX2Loader._priorityFormats["etc1s"] = options.priorityFormats;
|
|
3607
3493
|
KTX2Loader._priorityFormats["uastc"] = options.priorityFormats;
|
|
3608
3494
|
}
|
|
3609
|
-
|
|
3610
|
-
return KTX2Loader._getKhronosTranscoder(options.workerCount).init();
|
|
3611
|
-
} else {
|
|
3612
|
-
return KTX2Loader._getBinomialLLCTranscoder(options.workerCount).init();
|
|
3613
|
-
}
|
|
3495
|
+
return KTX2Loader._getBinomialLLCTranscoder(options.workerCount).init();
|
|
3614
3496
|
}
|
|
3615
3497
|
};
|
|
3616
3498
|
/**
|
|
@@ -3638,29 +3520,17 @@ var KTX2Loader = /*#__PURE__*/ function(Loader) {
|
|
|
3638
3520
|
* @remarks If use loader after releasing, we should release again.
|
|
3639
3521
|
*/ KTX2Loader.release = function release() {
|
|
3640
3522
|
if (this._binomialLLCTranscoder) this._binomialLLCTranscoder.destroy();
|
|
3641
|
-
if (this._khronosTranscoder) this._khronosTranscoder.destroy();
|
|
3642
3523
|
this._binomialLLCTranscoder = null;
|
|
3643
|
-
this._khronosTranscoder = null;
|
|
3644
|
-
this._isBinomialInit = false;
|
|
3645
3524
|
};
|
|
3646
3525
|
/** @internal */ KTX2Loader._parseBuffer = function _parseBuffer(buffer, engine, params) {
|
|
3647
3526
|
var ktx2Container = new KTX2Container(buffer);
|
|
3648
3527
|
var _params_priorityFormats;
|
|
3649
|
-
var formatPriorities = (_params_priorityFormats = params == null ? void 0 : params.priorityFormats) != null ? _params_priorityFormats : KTX2Loader._priorityFormats[ktx2Container.
|
|
3528
|
+
var formatPriorities = (_params_priorityFormats = params == null ? void 0 : params.priorityFormats) != null ? _params_priorityFormats : KTX2Loader._priorityFormats[ktx2Container.colorModel];
|
|
3650
3529
|
var targetFormat = KTX2Loader._decideTargetFormat(engine, ktx2Container, formatPriorities);
|
|
3651
|
-
var
|
|
3652
|
-
|
|
3653
|
-
|
|
3654
|
-
|
|
3655
|
-
return binomialLLCWorker.transcode(buffer, targetFormat);
|
|
3656
|
-
});
|
|
3657
|
-
} else {
|
|
3658
|
-
var khronosWorker = KTX2Loader._getKhronosTranscoder();
|
|
3659
|
-
transcodeResultPromise = khronosWorker.init().then(function() {
|
|
3660
|
-
return khronosWorker.transcode(ktx2Container);
|
|
3661
|
-
});
|
|
3662
|
-
}
|
|
3663
|
-
return transcodeResultPromise.then(function(result) {
|
|
3530
|
+
var binomialLLCWorker = KTX2Loader._getBinomialLLCTranscoder();
|
|
3531
|
+
return binomialLLCWorker.init().then(function() {
|
|
3532
|
+
return binomialLLCWorker.transcode(buffer, targetFormat);
|
|
3533
|
+
}).then(function(result) {
|
|
3664
3534
|
return {
|
|
3665
3535
|
ktx2Container: ktx2Container,
|
|
3666
3536
|
engine: engine,
|
|
@@ -3739,15 +3609,9 @@ var KTX2Loader = /*#__PURE__*/ function(Loader) {
|
|
|
3739
3609
|
};
|
|
3740
3610
|
KTX2Loader._getBinomialLLCTranscoder = function _getBinomialLLCTranscoder(workerCount) {
|
|
3741
3611
|
if (workerCount === void 0) workerCount = 4;
|
|
3742
|
-
KTX2Loader._isBinomialInit = true;
|
|
3743
3612
|
var _this__binomialLLCTranscoder;
|
|
3744
3613
|
return (_this__binomialLLCTranscoder = this._binomialLLCTranscoder) != null ? _this__binomialLLCTranscoder : this._binomialLLCTranscoder = new BinomialLLCTranscoder(workerCount);
|
|
3745
3614
|
};
|
|
3746
|
-
KTX2Loader._getKhronosTranscoder = function _getKhronosTranscoder(workerCount) {
|
|
3747
|
-
if (workerCount === void 0) workerCount = 4;
|
|
3748
|
-
var _this__khronosTranscoder;
|
|
3749
|
-
return (_this__khronosTranscoder = this._khronosTranscoder) != null ? _this__khronosTranscoder : this._khronosTranscoder = new KhronosTranscoder(workerCount, KTX2TargetFormat.ASTC);
|
|
3750
|
-
};
|
|
3751
3615
|
KTX2Loader._getEngineTextureFormat = function _getEngineTextureFormat(basisFormat, transcodeResult) {
|
|
3752
3616
|
var hasAlpha = transcodeResult.hasAlpha;
|
|
3753
3617
|
switch(basisFormat){
|
|
@@ -3763,52 +3627,65 @@ var KTX2Loader = /*#__PURE__*/ function(Loader) {
|
|
|
3763
3627
|
return hasAlpha ? TextureFormat.PVRTC_RGBA4 : TextureFormat.PVRTC_RGB4;
|
|
3764
3628
|
case KTX2TargetFormat.R8G8B8A8:
|
|
3765
3629
|
return TextureFormat.R8G8B8A8;
|
|
3630
|
+
case KTX2TargetFormat.BC6H:
|
|
3631
|
+
return TextureFormat.BC6H;
|
|
3632
|
+
case KTX2TargetFormat.ASTC_HDR_4x4:
|
|
3633
|
+
return TextureFormat.ASTC_4x4;
|
|
3634
|
+
case KTX2TargetFormat.R16G16B16A16:
|
|
3635
|
+
return TextureFormat.R16G16B16A16;
|
|
3766
3636
|
}
|
|
3767
3637
|
};
|
|
3768
3638
|
return KTX2Loader;
|
|
3769
3639
|
}(Loader);
|
|
3770
|
-
|
|
3771
|
-
KTX2Loader._priorityFormats = {
|
|
3772
|
-
|
|
3773
|
-
|
|
3774
|
-
|
|
3775
|
-
|
|
3776
|
-
|
|
3777
|
-
|
|
3778
|
-
|
|
3779
|
-
|
|
3780
|
-
|
|
3781
|
-
|
|
3782
|
-
|
|
3783
|
-
|
|
3784
|
-
|
|
3785
|
-
|
|
3786
|
-
|
|
3787
|
-
|
|
3788
|
-
|
|
3640
|
+
var _obj$1;
|
|
3641
|
+
KTX2Loader._priorityFormats = (_obj$1 = {}, _obj$1[ColorModel.ETC1S] = [
|
|
3642
|
+
KTX2TargetFormat.ETC,
|
|
3643
|
+
KTX2TargetFormat.BC7,
|
|
3644
|
+
KTX2TargetFormat.ASTC,
|
|
3645
|
+
KTX2TargetFormat.BC1_BC3,
|
|
3646
|
+
KTX2TargetFormat.PVRTC
|
|
3647
|
+
], _obj$1[ColorModel.UASTC_LDR_4X4] = [
|
|
3648
|
+
KTX2TargetFormat.ASTC,
|
|
3649
|
+
KTX2TargetFormat.BC7,
|
|
3650
|
+
KTX2TargetFormat.ETC,
|
|
3651
|
+
KTX2TargetFormat.BC1_BC3,
|
|
3652
|
+
KTX2TargetFormat.PVRTC
|
|
3653
|
+
], _obj$1[ColorModel.UASTC_HDR_4X4] = [
|
|
3654
|
+
KTX2TargetFormat.ASTC_HDR_4x4,
|
|
3655
|
+
KTX2TargetFormat.BC6H,
|
|
3656
|
+
KTX2TargetFormat.R16G16B16A16
|
|
3657
|
+
], _obj$1);
|
|
3658
|
+
var _obj1, _obj2, _obj3, _obj4, _obj5, _obj6, _obj7, _obj8, _obj9;
|
|
3659
|
+
KTX2Loader._capabilityMap = (_obj9 = {}, _obj9[KTX2TargetFormat.ASTC] = (_obj1 = {}, _obj1[DFDTransferFunction.linear] = [
|
|
3789
3660
|
GLCapabilityType.astc,
|
|
3790
3661
|
GLCapabilityType.astc_webkit
|
|
3791
|
-
],
|
|
3662
|
+
], _obj1[DFDTransferFunction.sRGB] = [
|
|
3792
3663
|
GLCapabilityType.astc,
|
|
3793
3664
|
GLCapabilityType.astc_webkit
|
|
3794
|
-
],
|
|
3665
|
+
], _obj1), _obj9[KTX2TargetFormat.ETC] = (_obj2 = {}, _obj2[DFDTransferFunction.linear] = [
|
|
3795
3666
|
GLCapabilityType.etc,
|
|
3796
3667
|
GLCapabilityType.etc_webkit
|
|
3797
|
-
],
|
|
3668
|
+
], _obj2[DFDTransferFunction.sRGB] = [
|
|
3798
3669
|
GLCapabilityType.etc,
|
|
3799
3670
|
GLCapabilityType.etc_webkit
|
|
3800
|
-
],
|
|
3671
|
+
], _obj2), _obj9[KTX2TargetFormat.BC7] = (_obj3 = {}, _obj3[DFDTransferFunction.linear] = [
|
|
3801
3672
|
GLCapabilityType.bptc
|
|
3802
|
-
],
|
|
3673
|
+
], _obj3[DFDTransferFunction.sRGB] = [
|
|
3803
3674
|
GLCapabilityType.bptc
|
|
3804
|
-
],
|
|
3675
|
+
], _obj3), _obj9[KTX2TargetFormat.BC1_BC3] = (_obj4 = {}, _obj4[DFDTransferFunction.linear] = [
|
|
3805
3676
|
GLCapabilityType.s3tc
|
|
3806
|
-
],
|
|
3677
|
+
], _obj4[DFDTransferFunction.sRGB] = [
|
|
3807
3678
|
GLCapabilityType.s3tc_srgb
|
|
3808
|
-
],
|
|
3679
|
+
], _obj4), _obj9[KTX2TargetFormat.BC6H] = (_obj5 = {}, _obj5[DFDTransferFunction.linear] = [
|
|
3680
|
+
GLCapabilityType.bptc
|
|
3681
|
+
], _obj5), _obj9[KTX2TargetFormat.ASTC_HDR_4x4] = (_obj6 = {}, _obj6[DFDTransferFunction.linear] = [
|
|
3682
|
+
GLCapabilityType.astc_hdr
|
|
3683
|
+
], _obj6), _obj9[KTX2TargetFormat.R16G16B16A16] = (_obj7 = {}, _obj7[DFDTransferFunction.linear] = [
|
|
3684
|
+
GLCapabilityType.textureHalfFloat
|
|
3685
|
+
], _obj7), _obj9[KTX2TargetFormat.PVRTC] = (_obj8 = {}, _obj8[DFDTransferFunction.linear] = [
|
|
3809
3686
|
GLCapabilityType.pvrtc,
|
|
3810
3687
|
GLCapabilityType.pvrtc_webkit
|
|
3811
|
-
],
|
|
3688
|
+
], _obj8), _obj9);
|
|
3812
3689
|
KTX2Loader = __decorate([
|
|
3813
3690
|
resourceLoader(AssetType.KTX2, [
|
|
3814
3691
|
"ktx2"
|
|
@@ -3838,11 +3715,6 @@ var KTX2ContentRestorer = /*#__PURE__*/ function(ContentRestorer) {
|
|
|
3838
3715
|
};
|
|
3839
3716
|
return KTX2ContentRestorer;
|
|
3840
3717
|
}(ContentRestorer);
|
|
3841
|
-
/** Used for initialize KTX2 transcoder. */ var KTX2Transcoder = /*#__PURE__*/ function(KTX2Transcoder) {
|
|
3842
|
-
/** BinomialLLC transcoder. */ KTX2Transcoder[KTX2Transcoder["BinomialLLC"] = 0] = "BinomialLLC";
|
|
3843
|
-
/** Khronos transcoder. */ KTX2Transcoder[KTX2Transcoder["Khronos"] = 1] = "Khronos";
|
|
3844
|
-
return KTX2Transcoder;
|
|
3845
|
-
}({});
|
|
3846
3718
|
|
|
3847
3719
|
/**
|
|
3848
3720
|
* @internal
|
|
@@ -4582,7 +4454,7 @@ var GLTFMaterialParser = /*#__PURE__*/ function(GLTFParser1) {
|
|
|
4582
4454
|
}
|
|
4583
4455
|
}
|
|
4584
4456
|
}
|
|
4585
|
-
if (material.constructor === PBRMaterial
|
|
4457
|
+
if (material.constructor === PBRMaterial) {
|
|
4586
4458
|
if (emissiveTexture) {
|
|
4587
4459
|
GLTFMaterialParser._checkOtherTextureTransform(emissiveTexture, "Emissive");
|
|
4588
4460
|
context.get(GLTFParserType.Texture, emissiveTexture.index).then(function(texture) {
|
|
@@ -5145,7 +5017,7 @@ var GLTFTextureParser = /*#__PURE__*/ function(GLTFParser1) {
|
|
|
5145
5017
|
};
|
|
5146
5018
|
_proto._isSRGBColorSpace = function _isSRGBColorSpace(textureIndex, materials) {
|
|
5147
5019
|
return materials == null ? void 0 : materials.some(function(material) {
|
|
5148
|
-
var _material_emissiveTexture, _material_pbrMetallicRoughness_baseColorTexture, _material_pbrMetallicRoughness, _material_extensions_KHR_materials_sheen_sheenColorTexture, _material_extensions_KHR_materials_sheen, _material_extensions,
|
|
5020
|
+
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;
|
|
5149
5021
|
if (((_material_emissiveTexture = material.emissiveTexture) == null ? void 0 : _material_emissiveTexture.index) === textureIndex) {
|
|
5150
5022
|
return true;
|
|
5151
5023
|
}
|
|
@@ -5155,10 +5027,7 @@ var GLTFTextureParser = /*#__PURE__*/ function(GLTFParser1) {
|
|
|
5155
5027
|
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) {
|
|
5156
5028
|
return true;
|
|
5157
5029
|
}
|
|
5158
|
-
if (((_material_extensions1 = material.extensions) == null ? void 0 : (
|
|
5159
|
-
return true;
|
|
5160
|
-
}
|
|
5161
|
-
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) {
|
|
5030
|
+
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) {
|
|
5162
5031
|
return true;
|
|
5163
5032
|
}
|
|
5164
5033
|
});
|
|
@@ -6265,7 +6134,7 @@ var ProjectLoader = /*#__PURE__*/ function(Loader) {
|
|
|
6265
6134
|
var _proto = ProjectLoader.prototype;
|
|
6266
6135
|
_proto.load = function load(item, resourceManager) {
|
|
6267
6136
|
var engine = resourceManager.engine;
|
|
6268
|
-
return new AssetPromise(function(resolve, reject) {
|
|
6137
|
+
return new AssetPromise(function(resolve, reject, onTaskCompeteProgress) {
|
|
6269
6138
|
resourceManager// @ts-ignore
|
|
6270
6139
|
._request(item.url, _extends({}, item, {
|
|
6271
6140
|
type: "json"
|
|
@@ -6275,7 +6144,7 @@ var ProjectLoader = /*#__PURE__*/ function(Loader) {
|
|
|
6275
6144
|
return resourceManager.load({
|
|
6276
6145
|
type: AssetType.Scene,
|
|
6277
6146
|
url: data.scene
|
|
6278
|
-
}).then(function(scene) {
|
|
6147
|
+
}).onProgress(onTaskCompeteProgress).then(function(scene) {
|
|
6279
6148
|
engine.sceneManager.activeScene = scene;
|
|
6280
6149
|
resolve();
|
|
6281
6150
|
});
|
|
@@ -6792,12 +6661,18 @@ var SceneLoader = /*#__PURE__*/ function(Loader) {
|
|
|
6792
6661
|
var _proto = SceneLoader.prototype;
|
|
6793
6662
|
_proto.load = function load(item, resourceManager) {
|
|
6794
6663
|
var engine = resourceManager.engine;
|
|
6795
|
-
return new AssetPromise(function(resolve, reject) {
|
|
6664
|
+
return new AssetPromise(function(resolve, reject, setTaskCompleteProgress) {
|
|
6796
6665
|
resourceManager// @ts-ignore
|
|
6797
6666
|
._request(item.url, _extends({}, item, {
|
|
6798
6667
|
type: "json"
|
|
6799
6668
|
})).then(function(data) {
|
|
6800
|
-
|
|
6669
|
+
var scene = new Scene(engine);
|
|
6670
|
+
var context = new ParserContext(engine, ParserType.Scene, scene);
|
|
6671
|
+
var parser = new SceneParser(data, context, scene);
|
|
6672
|
+
parser._collectDependentAssets(data);
|
|
6673
|
+
context._setTaskCompleteProgress = setTaskCompleteProgress;
|
|
6674
|
+
parser.start();
|
|
6675
|
+
return parser.promise.then(function() {
|
|
6801
6676
|
var promises = [];
|
|
6802
6677
|
// parse ambient light
|
|
6803
6678
|
var ambient = data.scene.ambient;
|
|
@@ -7019,51 +6894,6 @@ KHR_materials_ior = __decorate([
|
|
|
7019
6894
|
registerGLTFExtension("KHR_materials_ior", GLTFExtensionMode.AdditiveParse)
|
|
7020
6895
|
], KHR_materials_ior);
|
|
7021
6896
|
|
|
7022
|
-
var KHR_materials_pbrSpecularGlossiness = /*#__PURE__*/ function(GLTFExtensionParser) {
|
|
7023
|
-
_inherits(KHR_materials_pbrSpecularGlossiness, GLTFExtensionParser);
|
|
7024
|
-
function KHR_materials_pbrSpecularGlossiness() {
|
|
7025
|
-
return GLTFExtensionParser.apply(this, arguments) || this;
|
|
7026
|
-
}
|
|
7027
|
-
var _proto = KHR_materials_pbrSpecularGlossiness.prototype;
|
|
7028
|
-
_proto.createAndParse = function createAndParse(context, schema, ownerSchema) {
|
|
7029
|
-
var engine = context.glTFResource.engine;
|
|
7030
|
-
var material = new PBRSpecularMaterial(engine);
|
|
7031
|
-
var diffuseFactor = schema.diffuseFactor, diffuseTexture = schema.diffuseTexture, specularFactor = schema.specularFactor, glossinessFactor = schema.glossinessFactor, specularGlossinessTexture = schema.specularGlossinessTexture;
|
|
7032
|
-
if (diffuseFactor) {
|
|
7033
|
-
material.baseColor.copyFromArray(diffuseFactor);
|
|
7034
|
-
}
|
|
7035
|
-
if (diffuseTexture) {
|
|
7036
|
-
context.get(GLTFParserType.Texture, diffuseTexture.index).then(function(texture) {
|
|
7037
|
-
material.baseTexture = texture;
|
|
7038
|
-
GLTFParser.executeExtensionsAdditiveAndParse(diffuseTexture.extensions, context, material, diffuseTexture);
|
|
7039
|
-
}).catch(function(e) {
|
|
7040
|
-
Logger.error("KHR_materials_pbrSpecularGlossiness: diffuse texture error", e);
|
|
7041
|
-
});
|
|
7042
|
-
}
|
|
7043
|
-
if (specularFactor) {
|
|
7044
|
-
material.specularColor.set(specularFactor[0], specularFactor[1], specularFactor[2], 1.0);
|
|
7045
|
-
}
|
|
7046
|
-
if (glossinessFactor !== undefined) {
|
|
7047
|
-
material.glossiness = glossinessFactor;
|
|
7048
|
-
}
|
|
7049
|
-
if (specularGlossinessTexture) {
|
|
7050
|
-
GLTFMaterialParser._checkOtherTextureTransform(specularGlossinessTexture, "Specular glossiness");
|
|
7051
|
-
context.get(GLTFParserType.Texture, specularGlossinessTexture.index).then(function(texture) {
|
|
7052
|
-
material.specularGlossinessTexture = texture;
|
|
7053
|
-
}).catch(function(e) {
|
|
7054
|
-
Logger.error("KHR_materials_pbrSpecularGlossiness: specular glossiness texture error", e);
|
|
7055
|
-
});
|
|
7056
|
-
}
|
|
7057
|
-
material.name = ownerSchema.name;
|
|
7058
|
-
GLTFMaterialParser._parseStandardProperty(context, material, ownerSchema);
|
|
7059
|
-
return material;
|
|
7060
|
-
};
|
|
7061
|
-
return KHR_materials_pbrSpecularGlossiness;
|
|
7062
|
-
}(GLTFExtensionParser);
|
|
7063
|
-
KHR_materials_pbrSpecularGlossiness = __decorate([
|
|
7064
|
-
registerGLTFExtension("KHR_materials_pbrSpecularGlossiness", GLTFExtensionMode.CreateAndParse)
|
|
7065
|
-
], KHR_materials_pbrSpecularGlossiness);
|
|
7066
|
-
|
|
7067
6897
|
var KHR_materials_sheen = /*#__PURE__*/ function(GLTFExtensionParser) {
|
|
7068
6898
|
_inherits(KHR_materials_sheen, GLTFExtensionParser);
|
|
7069
6899
|
function KHR_materials_sheen() {
|
|
@@ -7423,6 +7253,41 @@ KHR_materials_iridescence = __decorate([
|
|
|
7423
7253
|
registerGLTFExtension("KHR_materials_iridescence", GLTFExtensionMode.AdditiveParse)
|
|
7424
7254
|
], KHR_materials_iridescence);
|
|
7425
7255
|
|
|
7256
|
+
var KHR_materials_specular = /*#__PURE__*/ function(GLTFExtensionParser) {
|
|
7257
|
+
_inherits(KHR_materials_specular, GLTFExtensionParser);
|
|
7258
|
+
function KHR_materials_specular() {
|
|
7259
|
+
return GLTFExtensionParser.apply(this, arguments) || this;
|
|
7260
|
+
}
|
|
7261
|
+
var _proto = KHR_materials_specular.prototype;
|
|
7262
|
+
_proto.additiveParse = function additiveParse(context, material, schema) {
|
|
7263
|
+
var _schema_specularFactor = schema.specularFactor, specularFactor = _schema_specularFactor === void 0 ? 1 : _schema_specularFactor, specularTexture = schema.specularTexture, specularColorFactor = schema.specularColorFactor, specularColorTexture = schema.specularColorTexture;
|
|
7264
|
+
material.specularIntensity = specularFactor;
|
|
7265
|
+
if (specularColorFactor) {
|
|
7266
|
+
material.specularColor.set(specularColorFactor[0], specularColorFactor[1], specularColorFactor[2], undefined);
|
|
7267
|
+
}
|
|
7268
|
+
if (specularTexture) {
|
|
7269
|
+
GLTFMaterialParser._checkOtherTextureTransform(specularTexture, "Specular intensity texture");
|
|
7270
|
+
context.get(GLTFParserType.Texture, specularTexture.index).then(function(texture) {
|
|
7271
|
+
material.specularIntensityTexture = texture;
|
|
7272
|
+
}).catch(function(e) {
|
|
7273
|
+
Logger.error("KHR_materials_specular: specularTexture error", e);
|
|
7274
|
+
});
|
|
7275
|
+
}
|
|
7276
|
+
if (specularColorTexture) {
|
|
7277
|
+
GLTFMaterialParser._checkOtherTextureTransform(specularColorTexture, "Specular color texture");
|
|
7278
|
+
context.get(GLTFParserType.Texture, specularColorTexture.index).then(function(texture) {
|
|
7279
|
+
material.specularColorTexture = texture;
|
|
7280
|
+
}).catch(function(e) {
|
|
7281
|
+
Logger.error("KHR_materials_specular: SpecularColorTexture error", e);
|
|
7282
|
+
});
|
|
7283
|
+
}
|
|
7284
|
+
};
|
|
7285
|
+
return KHR_materials_specular;
|
|
7286
|
+
}(GLTFExtensionParser);
|
|
7287
|
+
KHR_materials_specular = __decorate([
|
|
7288
|
+
registerGLTFExtension("KHR_materials_specular", GLTFExtensionMode.AdditiveParse)
|
|
7289
|
+
], KHR_materials_specular);
|
|
7290
|
+
|
|
7426
7291
|
var EXT_texture_webp = /*#__PURE__*/ function(GLTFExtensionParser) {
|
|
7427
7292
|
_inherits(EXT_texture_webp, GLTFExtensionParser);
|
|
7428
7293
|
function EXT_texture_webp() {
|
|
@@ -7442,5 +7307,5 @@ EXT_texture_webp = __decorate([
|
|
|
7442
7307
|
registerGLTFExtension("EXT_texture_webp", GLTFExtensionMode.CreateAndParse)
|
|
7443
7308
|
], EXT_texture_webp);
|
|
7444
7309
|
|
|
7445
|
-
export { AccessorType, AnimationClipDecoder, BufferInfo, BufferReader, EditorTextureLoader, FileHeader, GLTFAnimationParser, GLTFAnimatorControllerParser, GLTFBufferParser, GLTFBufferViewParser, GLTFEntityParser, GLTFExtensionMode, GLTFExtensionParser, GLTFLoader, GLTFMaterialParser, GLTFMeshParser, GLTFParser, GLTFParserContext, GLTFParserType, GLTFResource, GLTFSceneParser, GLTFSchemaParser, GLTFSkinParser, GLTFTextureParser, GLTFUtils, GLTFValidator, HierarchyParser, InterpolableValueType, KTX2Loader, KTX2TargetFormat,
|
|
7310
|
+
export { AccessorType, AnimationClipDecoder, BufferInfo, BufferReader, EditorTextureLoader, FileHeader, GLTFAnimationParser, GLTFAnimatorControllerParser, GLTFBufferParser, GLTFBufferViewParser, GLTFEntityParser, GLTFExtensionMode, GLTFExtensionParser, GLTFLoader, GLTFMaterialParser, GLTFMeshParser, GLTFParser, GLTFParserContext, GLTFParserType, GLTFResource, GLTFSceneParser, GLTFSchemaParser, GLTFSkinParser, GLTFTextureParser, GLTFUtils, GLTFValidator, HierarchyParser, InterpolableValueType, KTX2Loader, KTX2TargetFormat, MaterialLoaderType, MeshDecoder, ParserContext, ParserType, PrefabResource, ReflectionParser, SceneParser, SpecularMode, Texture2DDecoder, decode, decoder, decoderMap, parseSingleKTX, registerGLTFExtension, registerGLTFParser };
|
|
7446
7311
|
//# sourceMappingURL=module.js.map
|