@galacean/engine-loader 1.1.0-beta.13 → 1.1.0-beta.15
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 +33 -33
- package/dist/main.js.map +1 -1
- package/dist/miniprogram.js +33 -33
- package/dist/module.js +33 -33
- package/dist/module.js.map +1 -1
- package/package.json +5 -5
- package/types/ktx2/KTX2Loader.d.ts +4 -3
package/dist/miniprogram.js
CHANGED
|
@@ -294,7 +294,7 @@ exports.MeshDecoder = /*#__PURE__*/ function() {
|
|
|
294
294
|
var encodedMeshData = JSON.parse(jsonDataString);
|
|
295
295
|
// @ts-ignore Vector3 is not compatible with {x: number, y: number, z: number}.
|
|
296
296
|
encodedMeshData.bounds && modelMesh.bounds.copyFrom(encodedMeshData.bounds);
|
|
297
|
-
var offset = Math.ceil(bufferReader.
|
|
297
|
+
var offset = Math.ceil(bufferReader.position / 4) * 4;
|
|
298
298
|
var buffer = bufferReader.data.buffer;
|
|
299
299
|
var byteOffset = bufferReader.data.byteOffset;
|
|
300
300
|
var float32Array = new Float32Array(buffer, encodedMeshData.positions.start + offset + byteOffset, (encodedMeshData.positions.end - encodedMeshData.positions.start) / 4);
|
|
@@ -2248,7 +2248,7 @@ var SupercompressionScheme;
|
|
|
2248
2248
|
alphaSliceByteLength: sgdReader.nextUint32()
|
|
2249
2249
|
};
|
|
2250
2250
|
}
|
|
2251
|
-
var endpointsByteOffset = sgdByteOffset + sgdReader.
|
|
2251
|
+
var endpointsByteOffset = sgdByteOffset + sgdReader.position;
|
|
2252
2252
|
var selectorsByteOffset = endpointsByteOffset + endpointsByteLength;
|
|
2253
2253
|
var tablesByteOffset = selectorsByteOffset + selectorsByteLength;
|
|
2254
2254
|
var extendedByteOffset = tablesByteOffset + tablesByteLength;
|
|
@@ -2908,6 +2908,7 @@ exports.KTX2Loader = (_KTX2Loader = /*#__PURE__*/ function(Loader1) {
|
|
|
2908
2908
|
_proto.initialize = function initialize(engine, configuration) {
|
|
2909
2909
|
if (configuration.ktx2Loader) {
|
|
2910
2910
|
var options = configuration.ktx2Loader;
|
|
2911
|
+
if (options.priorityFormats) exports.KTX2Loader._priorityFormats = options.priorityFormats;
|
|
2911
2912
|
if (this._isKhronosSupported(options.priorityFormats, engine) && options.workerCount !== 0) {
|
|
2912
2913
|
return exports.KTX2Loader._getKhronosTranscoder(options.workerCount).init();
|
|
2913
2914
|
} else {
|
|
@@ -2928,25 +2929,7 @@ exports.KTX2Loader = (_KTX2Loader = /*#__PURE__*/ function(Loader1) {
|
|
|
2928
2929
|
});
|
|
2929
2930
|
};
|
|
2930
2931
|
_proto._isKhronosSupported = function _isKhronosSupported(priorityFormats, engine) {
|
|
2931
|
-
|
|
2932
|
-
exports.KTX2TargetFormat.ASTC,
|
|
2933
|
-
exports.KTX2TargetFormat.ETC,
|
|
2934
|
-
exports.KTX2TargetFormat.BC7,
|
|
2935
|
-
exports.KTX2TargetFormat.BC1_BC3,
|
|
2936
|
-
exports.KTX2TargetFormat.PVRTC,
|
|
2937
|
-
exports.KTX2TargetFormat.R8G8B8A8
|
|
2938
|
-
];
|
|
2939
|
-
var supportedList = new Array();
|
|
2940
|
-
if (Array.isArray(priorityFormats[0])) {
|
|
2941
|
-
for(var i = 0; i < priorityFormats.length; i++){
|
|
2942
|
-
supportedList.push(exports.KTX2Loader._detectSupportedFormat(engine._hardwareRenderer, priorityFormats[i]));
|
|
2943
|
-
}
|
|
2944
|
-
} else {
|
|
2945
|
-
supportedList.push(exports.KTX2Loader._detectSupportedFormat(engine._hardwareRenderer, priorityFormats));
|
|
2946
|
-
}
|
|
2947
|
-
return supportedList.every(function(format) {
|
|
2948
|
-
return KhronosTranscoder.transcoderMap[format];
|
|
2949
|
-
});
|
|
2932
|
+
return !!KhronosTranscoder.transcoderMap[exports.KTX2Loader._detectSupportedFormat(engine._hardwareRenderer, priorityFormats)];
|
|
2950
2933
|
};
|
|
2951
2934
|
/**
|
|
2952
2935
|
* Destroy ktx2 transcoder worker.
|
|
@@ -2960,7 +2943,8 @@ exports.KTX2Loader = (_KTX2Loader = /*#__PURE__*/ function(Loader1) {
|
|
|
2960
2943
|
/** @internal */ KTX2Loader1._parseBuffer = function _parseBuffer(buffer, engine, params) {
|
|
2961
2944
|
var _params;
|
|
2962
2945
|
var ktx2Container = new KTX2Container(buffer);
|
|
2963
|
-
var
|
|
2946
|
+
var _params_priorityFormats;
|
|
2947
|
+
var formatPriorities = (_params_priorityFormats = (_params = params) == null ? void 0 : _params.priorityFormats) != null ? _params_priorityFormats : exports.KTX2Loader._priorityFormats;
|
|
2964
2948
|
var targetFormat = exports.KTX2Loader._decideTargetFormat(engine, ktx2Container, formatPriorities);
|
|
2965
2949
|
var transcodeResultPromise;
|
|
2966
2950
|
if (exports.KTX2Loader._isBinomialInit || !KhronosTranscoder.transcoderMap[targetFormat] || !ktx2Container.isUASTC) {
|
|
@@ -3027,18 +3011,22 @@ exports.KTX2Loader = (_KTX2Loader = /*#__PURE__*/ function(Loader1) {
|
|
|
3027
3011
|
return targetFormat;
|
|
3028
3012
|
};
|
|
3029
3013
|
KTX2Loader1._detectSupportedFormat = function _detectSupportedFormat(renderer, priorityFormats) {
|
|
3030
|
-
if (priorityFormats === void 0) priorityFormats = [
|
|
3031
|
-
exports.KTX2TargetFormat.ASTC,
|
|
3032
|
-
exports.KTX2TargetFormat.ETC,
|
|
3033
|
-
exports.KTX2TargetFormat.BC7,
|
|
3034
|
-
exports.KTX2TargetFormat.BC1_BC3,
|
|
3035
|
-
exports.KTX2TargetFormat.PVRTC
|
|
3036
|
-
];
|
|
3037
3014
|
for(var i = 0; i < priorityFormats.length; i++){
|
|
3038
|
-
var
|
|
3039
|
-
|
|
3040
|
-
|
|
3041
|
-
|
|
3015
|
+
var format = priorityFormats[i];
|
|
3016
|
+
var capabilities = this._supportedMap[format];
|
|
3017
|
+
if (capabilities) {
|
|
3018
|
+
for(var j = 0; j < capabilities.length; j++){
|
|
3019
|
+
if (renderer.canIUse(capabilities[j])) {
|
|
3020
|
+
return format;
|
|
3021
|
+
}
|
|
3022
|
+
}
|
|
3023
|
+
} else {
|
|
3024
|
+
switch(priorityFormats[i]){
|
|
3025
|
+
case exports.KTX2TargetFormat.R8G8B8A8:
|
|
3026
|
+
return format;
|
|
3027
|
+
case exports.KTX2TargetFormat.R8:
|
|
3028
|
+
case exports.KTX2TargetFormat.R8G8:
|
|
3029
|
+
if (renderer.isWebGL2) return format;
|
|
3042
3030
|
}
|
|
3043
3031
|
}
|
|
3044
3032
|
}
|
|
@@ -3075,6 +3063,14 @@ exports.KTX2Loader = (_KTX2Loader = /*#__PURE__*/ function(Loader1) {
|
|
|
3075
3063
|
return KTX2Loader1;
|
|
3076
3064
|
}(miniprogram.Loader), function() {
|
|
3077
3065
|
_KTX2Loader._isBinomialInit = false;
|
|
3066
|
+
}(), function() {
|
|
3067
|
+
_KTX2Loader._priorityFormats = [
|
|
3068
|
+
exports.KTX2TargetFormat.BC7,
|
|
3069
|
+
exports.KTX2TargetFormat.ASTC,
|
|
3070
|
+
exports.KTX2TargetFormat.BC1_BC3,
|
|
3071
|
+
exports.KTX2TargetFormat.ETC,
|
|
3072
|
+
exports.KTX2TargetFormat.PVRTC
|
|
3073
|
+
];
|
|
3078
3074
|
}(), function() {
|
|
3079
3075
|
var _obj;
|
|
3080
3076
|
_KTX2Loader._supportedMap = (_obj = {}, _obj[exports.KTX2TargetFormat.ASTC] = [
|
|
@@ -3549,6 +3545,10 @@ exports.GLTFAnimationParser = /*#__PURE__*/ function(GLTFParser1) {
|
|
|
3549
3545
|
relativePath = relativePath === "" ? "" + entity.name : entity.name + "/" + relativePath;
|
|
3550
3546
|
entity = entity.parent;
|
|
3551
3547
|
}
|
|
3548
|
+
// If the target node is in the default scene, relativePath will be empty
|
|
3549
|
+
if (entity !== context.glTFResource.defaultSceneRoot) {
|
|
3550
|
+
continue;
|
|
3551
|
+
}
|
|
3552
3552
|
var ComponentType = void 0;
|
|
3553
3553
|
var propertyName = void 0;
|
|
3554
3554
|
switch(target.path){
|
package/dist/module.js
CHANGED
|
@@ -289,7 +289,7 @@ var MeshDecoder = /*#__PURE__*/ function() {
|
|
|
289
289
|
var encodedMeshData = JSON.parse(jsonDataString);
|
|
290
290
|
// @ts-ignore Vector3 is not compatible with {x: number, y: number, z: number}.
|
|
291
291
|
encodedMeshData.bounds && modelMesh.bounds.copyFrom(encodedMeshData.bounds);
|
|
292
|
-
var offset = Math.ceil(bufferReader.
|
|
292
|
+
var offset = Math.ceil(bufferReader.position / 4) * 4;
|
|
293
293
|
var buffer = bufferReader.data.buffer;
|
|
294
294
|
var byteOffset = bufferReader.data.byteOffset;
|
|
295
295
|
var float32Array = new Float32Array(buffer, encodedMeshData.positions.start + offset + byteOffset, (encodedMeshData.positions.end - encodedMeshData.positions.start) / 4);
|
|
@@ -2243,7 +2243,7 @@ var SupercompressionScheme;
|
|
|
2243
2243
|
alphaSliceByteLength: sgdReader.nextUint32()
|
|
2244
2244
|
};
|
|
2245
2245
|
}
|
|
2246
|
-
var endpointsByteOffset = sgdByteOffset + sgdReader.
|
|
2246
|
+
var endpointsByteOffset = sgdByteOffset + sgdReader.position;
|
|
2247
2247
|
var selectorsByteOffset = endpointsByteOffset + endpointsByteLength;
|
|
2248
2248
|
var tablesByteOffset = selectorsByteOffset + selectorsByteLength;
|
|
2249
2249
|
var extendedByteOffset = tablesByteOffset + tablesByteLength;
|
|
@@ -2903,6 +2903,7 @@ var KTX2Loader = (_KTX2Loader = /*#__PURE__*/ function(Loader1) {
|
|
|
2903
2903
|
_proto.initialize = function initialize(engine, configuration) {
|
|
2904
2904
|
if (configuration.ktx2Loader) {
|
|
2905
2905
|
var options = configuration.ktx2Loader;
|
|
2906
|
+
if (options.priorityFormats) KTX2Loader._priorityFormats = options.priorityFormats;
|
|
2906
2907
|
if (this._isKhronosSupported(options.priorityFormats, engine) && options.workerCount !== 0) {
|
|
2907
2908
|
return KTX2Loader._getKhronosTranscoder(options.workerCount).init();
|
|
2908
2909
|
} else {
|
|
@@ -2923,25 +2924,7 @@ var KTX2Loader = (_KTX2Loader = /*#__PURE__*/ function(Loader1) {
|
|
|
2923
2924
|
});
|
|
2924
2925
|
};
|
|
2925
2926
|
_proto._isKhronosSupported = function _isKhronosSupported(priorityFormats, engine) {
|
|
2926
|
-
|
|
2927
|
-
KTX2TargetFormat.ASTC,
|
|
2928
|
-
KTX2TargetFormat.ETC,
|
|
2929
|
-
KTX2TargetFormat.BC7,
|
|
2930
|
-
KTX2TargetFormat.BC1_BC3,
|
|
2931
|
-
KTX2TargetFormat.PVRTC,
|
|
2932
|
-
KTX2TargetFormat.R8G8B8A8
|
|
2933
|
-
];
|
|
2934
|
-
var supportedList = new Array();
|
|
2935
|
-
if (Array.isArray(priorityFormats[0])) {
|
|
2936
|
-
for(var i = 0; i < priorityFormats.length; i++){
|
|
2937
|
-
supportedList.push(KTX2Loader._detectSupportedFormat(engine._hardwareRenderer, priorityFormats[i]));
|
|
2938
|
-
}
|
|
2939
|
-
} else {
|
|
2940
|
-
supportedList.push(KTX2Loader._detectSupportedFormat(engine._hardwareRenderer, priorityFormats));
|
|
2941
|
-
}
|
|
2942
|
-
return supportedList.every(function(format) {
|
|
2943
|
-
return KhronosTranscoder.transcoderMap[format];
|
|
2944
|
-
});
|
|
2927
|
+
return !!KhronosTranscoder.transcoderMap[KTX2Loader._detectSupportedFormat(engine._hardwareRenderer, priorityFormats)];
|
|
2945
2928
|
};
|
|
2946
2929
|
/**
|
|
2947
2930
|
* Destroy ktx2 transcoder worker.
|
|
@@ -2955,7 +2938,8 @@ var KTX2Loader = (_KTX2Loader = /*#__PURE__*/ function(Loader1) {
|
|
|
2955
2938
|
/** @internal */ KTX2Loader1._parseBuffer = function _parseBuffer(buffer, engine, params) {
|
|
2956
2939
|
var _params;
|
|
2957
2940
|
var ktx2Container = new KTX2Container(buffer);
|
|
2958
|
-
var
|
|
2941
|
+
var _params_priorityFormats;
|
|
2942
|
+
var formatPriorities = (_params_priorityFormats = (_params = params) == null ? void 0 : _params.priorityFormats) != null ? _params_priorityFormats : KTX2Loader._priorityFormats;
|
|
2959
2943
|
var targetFormat = KTX2Loader._decideTargetFormat(engine, ktx2Container, formatPriorities);
|
|
2960
2944
|
var transcodeResultPromise;
|
|
2961
2945
|
if (KTX2Loader._isBinomialInit || !KhronosTranscoder.transcoderMap[targetFormat] || !ktx2Container.isUASTC) {
|
|
@@ -3022,18 +3006,22 @@ var KTX2Loader = (_KTX2Loader = /*#__PURE__*/ function(Loader1) {
|
|
|
3022
3006
|
return targetFormat;
|
|
3023
3007
|
};
|
|
3024
3008
|
KTX2Loader1._detectSupportedFormat = function _detectSupportedFormat(renderer, priorityFormats) {
|
|
3025
|
-
if (priorityFormats === void 0) priorityFormats = [
|
|
3026
|
-
KTX2TargetFormat.ASTC,
|
|
3027
|
-
KTX2TargetFormat.ETC,
|
|
3028
|
-
KTX2TargetFormat.BC7,
|
|
3029
|
-
KTX2TargetFormat.BC1_BC3,
|
|
3030
|
-
KTX2TargetFormat.PVRTC
|
|
3031
|
-
];
|
|
3032
3009
|
for(var i = 0; i < priorityFormats.length; i++){
|
|
3033
|
-
var
|
|
3034
|
-
|
|
3035
|
-
|
|
3036
|
-
|
|
3010
|
+
var format = priorityFormats[i];
|
|
3011
|
+
var capabilities = this._supportedMap[format];
|
|
3012
|
+
if (capabilities) {
|
|
3013
|
+
for(var j = 0; j < capabilities.length; j++){
|
|
3014
|
+
if (renderer.canIUse(capabilities[j])) {
|
|
3015
|
+
return format;
|
|
3016
|
+
}
|
|
3017
|
+
}
|
|
3018
|
+
} else {
|
|
3019
|
+
switch(priorityFormats[i]){
|
|
3020
|
+
case KTX2TargetFormat.R8G8B8A8:
|
|
3021
|
+
return format;
|
|
3022
|
+
case KTX2TargetFormat.R8:
|
|
3023
|
+
case KTX2TargetFormat.R8G8:
|
|
3024
|
+
if (renderer.isWebGL2) return format;
|
|
3037
3025
|
}
|
|
3038
3026
|
}
|
|
3039
3027
|
}
|
|
@@ -3070,6 +3058,14 @@ var KTX2Loader = (_KTX2Loader = /*#__PURE__*/ function(Loader1) {
|
|
|
3070
3058
|
return KTX2Loader1;
|
|
3071
3059
|
}(Loader), function() {
|
|
3072
3060
|
_KTX2Loader._isBinomialInit = false;
|
|
3061
|
+
}(), function() {
|
|
3062
|
+
_KTX2Loader._priorityFormats = [
|
|
3063
|
+
KTX2TargetFormat.BC7,
|
|
3064
|
+
KTX2TargetFormat.ASTC,
|
|
3065
|
+
KTX2TargetFormat.BC1_BC3,
|
|
3066
|
+
KTX2TargetFormat.ETC,
|
|
3067
|
+
KTX2TargetFormat.PVRTC
|
|
3068
|
+
];
|
|
3073
3069
|
}(), function() {
|
|
3074
3070
|
var _obj;
|
|
3075
3071
|
_KTX2Loader._supportedMap = (_obj = {}, _obj[KTX2TargetFormat.ASTC] = [
|
|
@@ -3544,6 +3540,10 @@ var GLTFAnimationParser = /*#__PURE__*/ function(GLTFParser1) {
|
|
|
3544
3540
|
relativePath = relativePath === "" ? "" + entity.name : entity.name + "/" + relativePath;
|
|
3545
3541
|
entity = entity.parent;
|
|
3546
3542
|
}
|
|
3543
|
+
// If the target node is in the default scene, relativePath will be empty
|
|
3544
|
+
if (entity !== context.glTFResource.defaultSceneRoot) {
|
|
3545
|
+
continue;
|
|
3546
|
+
}
|
|
3547
3547
|
var ComponentType = void 0;
|
|
3548
3548
|
var propertyName = void 0;
|
|
3549
3549
|
switch(target.path){
|