@galacean/engine-loader 1.2.0-beta.3 → 1.2.0-beta.4
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/LICENSE +2 -2
- package/dist/main.js +79 -42
- package/dist/main.js.map +1 -1
- package/dist/miniprogram.js +79 -42
- package/dist/module.js +80 -43
- package/dist/module.js.map +1 -1
- package/package.json +4 -4
- package/types/gltf/GLTFParser.d.ts +9 -0
- package/types/gltf/GLTFPipeline.d.ts +23 -0
- package/types/gltf/GLTFResource.d.ts +8 -6
- package/types/gltf/GLTFUtil.d.ts +53 -0
- package/types/gltf/Schema.d.ts +814 -0
- package/types/gltf/extensions/ExtensionParser.d.ts +8 -0
- package/types/gltf/extensions/KHR_draco_mesh_compression.d.ts +1 -0
- package/types/gltf/extensions/Schema.d.ts +142 -0
- package/types/gltf/parser/AnimationParser.d.ts +7 -0
- package/types/gltf/parser/BufferParser.d.ts +7 -0
- package/types/gltf/parser/EntityParser.d.ts +9 -0
- package/types/gltf/parser/GLTFAnimatorControllerParser.d.ts +7 -0
- package/types/gltf/parser/GLTFParserContext.d.ts +4 -2
- package/types/gltf/parser/MaterialParser.d.ts +8 -0
- package/types/gltf/parser/MeshParser.d.ts +13 -0
- package/types/gltf/parser/Parser.d.ts +21 -0
- package/types/gltf/parser/ParserContext.d.ts +46 -0
- package/types/gltf/parser/SceneParser.d.ts +11 -0
- package/types/gltf/parser/SkinParser.d.ts +6 -0
- package/types/gltf/parser/TextureParser.d.ts +8 -0
- package/types/gltf/parser/Validator.d.ts +5 -0
- package/types/gltf/parser/index.d.ts +1 -0
- package/types/ktx2/BinomialLLCTranscoder/BinomialLLCTranscoder.d.ts +13 -0
- package/types/ktx2/BinomialLLCTranscoder/TranscodeWorkerCode.d.ts +33 -0
- package/types/ktx2/KhronosTranscoder/KhronosTranscoder.d.ts +17 -0
- package/types/ktx2/KhronosTranscoder/TranscoderWorkerCode.d.ts +34 -0
- package/types/ktx2/TranscodeResult.d.ts +10 -0
- package/types/ktx2/constants.d.ts +7 -0
- package/types/ktx2/zstddec.d.ts +62 -0
- package/types/resource-deserialize/resources/animationClip/ComponentMap.d.ts +2 -0
- package/types/resource-deserialize/resources/parser/PrefabParser.d.ts +5 -0
- package/types/resource-deserialize/resources/prefab/PrefabDesign.d.ts +70 -0
- package/types/resource-deserialize/resources/prefab/ReflectionParser.d.ts +14 -0
package/LICENSE
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
The MIT License
|
|
2
2
|
|
|
3
|
-
Copyright
|
|
3
|
+
Copyright (c) 2020 - present Ant Group
|
|
4
4
|
|
|
5
5
|
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
6
|
of this software and associated documentation files (the "Software"), to deal
|
|
@@ -18,4 +18,4 @@ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
|
18
18
|
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
19
|
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
20
|
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
|
21
|
-
THE SOFTWARE.
|
|
21
|
+
THE SOFTWARE.
|
package/dist/main.js
CHANGED
|
@@ -1886,6 +1886,7 @@ var TextureWrapMode;
|
|
|
1886
1886
|
this.resourceManager = resourceManager;
|
|
1887
1887
|
this.params = params;
|
|
1888
1888
|
this.accessorBufferCache = {};
|
|
1889
|
+
this.needAnimatorController = false;
|
|
1889
1890
|
this._resourceCache = new Map();
|
|
1890
1891
|
this._progress = {
|
|
1891
1892
|
taskDetail: {},
|
|
@@ -1913,16 +1914,15 @@ var TextureWrapMode;
|
|
|
1913
1914
|
return Promise.resolve(null);
|
|
1914
1915
|
}
|
|
1915
1916
|
var cache = this._resourceCache;
|
|
1916
|
-
var
|
|
1917
|
-
var cacheKey = isOnlyOne || index === undefined ? "" + type : type + ":" + index;
|
|
1917
|
+
var cacheKey = index === undefined ? "" + type : type + ":" + index;
|
|
1918
1918
|
var resource = cache.get(cacheKey);
|
|
1919
1919
|
if (resource) {
|
|
1920
1920
|
return resource;
|
|
1921
1921
|
}
|
|
1922
|
-
|
|
1923
|
-
|
|
1924
|
-
|
|
1925
|
-
var glTFItems = this.glTF[
|
|
1922
|
+
var glTFSchemaKey = glTFSchemaMap[type];
|
|
1923
|
+
var isSubAsset = !!glTFResourceMap[type];
|
|
1924
|
+
if (glTFSchemaKey) {
|
|
1925
|
+
var glTFItems = this.glTF[glTFSchemaKey];
|
|
1926
1926
|
if (glTFItems && (index === undefined || glTFItems[index])) {
|
|
1927
1927
|
if (index === undefined) {
|
|
1928
1928
|
resource = type === 8 ? glTFItems.map(function(_, index) {
|
|
@@ -1932,11 +1932,14 @@ var TextureWrapMode;
|
|
|
1932
1932
|
}));
|
|
1933
1933
|
} else {
|
|
1934
1934
|
resource = parser.parse(this, index);
|
|
1935
|
-
this._handleSubAsset(resource, type, index);
|
|
1935
|
+
isSubAsset && this._handleSubAsset(resource, type, index);
|
|
1936
1936
|
}
|
|
1937
1937
|
} else {
|
|
1938
1938
|
resource = Promise.resolve(null);
|
|
1939
1939
|
}
|
|
1940
|
+
} else {
|
|
1941
|
+
resource = parser.parse(this, index);
|
|
1942
|
+
isSubAsset && this._handleSubAsset(resource, type, index);
|
|
1940
1943
|
}
|
|
1941
1944
|
cache.set(cacheKey, resource);
|
|
1942
1945
|
return resource;
|
|
@@ -1945,6 +1948,7 @@ var TextureWrapMode;
|
|
|
1945
1948
|
var _this = this;
|
|
1946
1949
|
var promise = this.get(0).then(function(json) {
|
|
1947
1950
|
_this.glTF = json;
|
|
1951
|
+
_this.needAnimatorController = !!(json.skins || json.animations);
|
|
1948
1952
|
return Promise.all([
|
|
1949
1953
|
_this.get(1),
|
|
1950
1954
|
_this.get(5),
|
|
@@ -1952,11 +1956,14 @@ var TextureWrapMode;
|
|
|
1952
1956
|
_this.get(7),
|
|
1953
1957
|
_this.get(9),
|
|
1954
1958
|
_this.get(10),
|
|
1959
|
+
_this.get(11),
|
|
1955
1960
|
_this.get(2)
|
|
1956
1961
|
]).then(function() {
|
|
1957
1962
|
var glTFResource = _this.glTFResource;
|
|
1958
|
-
|
|
1959
|
-
|
|
1963
|
+
var animatorController = glTFResource.animatorController;
|
|
1964
|
+
if (animatorController) {
|
|
1965
|
+
var animator = glTFResource._defaultSceneRoot.addComponent(engineCore.Animator);
|
|
1966
|
+
animator.animatorController = animatorController;
|
|
1960
1967
|
}
|
|
1961
1968
|
_this.resourceManager.addContentRestorer(_this.contentRestorer);
|
|
1962
1969
|
return glTFResource;
|
|
@@ -1975,40 +1982,21 @@ var TextureWrapMode;
|
|
|
1975
1982
|
_this._setTaskCompleteProgress(++task.loaded, task.total);
|
|
1976
1983
|
});
|
|
1977
1984
|
};
|
|
1978
|
-
_proto._createAnimator = function _createAnimator(context, animations) {
|
|
1979
|
-
var defaultSceneRoot = context.glTFResource.defaultSceneRoot;
|
|
1980
|
-
var animator = defaultSceneRoot.addComponent(engineCore.Animator);
|
|
1981
|
-
var animatorController = new engineCore.AnimatorController();
|
|
1982
|
-
var layer = new engineCore.AnimatorControllerLayer("layer");
|
|
1983
|
-
var animatorStateMachine = new engineCore.AnimatorStateMachine();
|
|
1984
|
-
animatorController.addLayer(layer);
|
|
1985
|
-
animator.animatorController = animatorController;
|
|
1986
|
-
layer.stateMachine = animatorStateMachine;
|
|
1987
|
-
if (animations) {
|
|
1988
|
-
for(var i = 0; i < animations.length; i++){
|
|
1989
|
-
var animationClip = animations[i];
|
|
1990
|
-
var name = animationClip.name;
|
|
1991
|
-
var uniqueName = animatorStateMachine.makeUniqueStateName(name);
|
|
1992
|
-
if (uniqueName !== name) {
|
|
1993
|
-
console.warn("AnimatorState name is existed, name: " + name + " reset to " + uniqueName);
|
|
1994
|
-
}
|
|
1995
|
-
var animatorState = animatorStateMachine.addState(uniqueName);
|
|
1996
|
-
animatorState.clip = animationClip;
|
|
1997
|
-
}
|
|
1998
|
-
}
|
|
1999
|
-
};
|
|
2000
1985
|
_proto._handleSubAsset = function _handleSubAsset(resource, type, index) {
|
|
2001
1986
|
var _this = this;
|
|
2002
1987
|
var glTFResourceKey = glTFResourceMap[type];
|
|
2003
|
-
if (!glTFResourceKey) return;
|
|
2004
1988
|
if (type === 8) {
|
|
2005
1989
|
var _this_glTFResource, _glTFResourceKey;
|
|
2006
1990
|
((_this_glTFResource = this.glTFResource)[_glTFResourceKey = glTFResourceKey] || (_this_glTFResource[_glTFResourceKey] = []))[index] = resource;
|
|
2007
1991
|
} else {
|
|
2008
1992
|
var url = this.glTFResource.url;
|
|
2009
1993
|
resource.then(function(item) {
|
|
2010
|
-
|
|
2011
|
-
|
|
1994
|
+
if (index == undefined) {
|
|
1995
|
+
_this.glTFResource[glTFResourceKey] = item;
|
|
1996
|
+
} else {
|
|
1997
|
+
var _this_glTFResource, _glTFResourceKey;
|
|
1998
|
+
((_this_glTFResource = _this.glTFResource)[_glTFResourceKey = glTFResourceKey] || (_this_glTFResource[_glTFResourceKey] = []))[index] = item;
|
|
1999
|
+
}
|
|
2012
2000
|
if (type === 7) {
|
|
2013
2001
|
for(var i = 0, length = item.length; i < length; i++){
|
|
2014
2002
|
var mesh = item[i];
|
|
@@ -2056,11 +2044,12 @@ exports.GLTFParserType = void 0;
|
|
|
2056
2044
|
GLTFParserType[GLTFParserType["Entity"] = 8] = "Entity";
|
|
2057
2045
|
GLTFParserType[GLTFParserType["Skin"] = 9] = "Skin";
|
|
2058
2046
|
GLTFParserType[GLTFParserType["Animation"] = 10] = "Animation";
|
|
2047
|
+
GLTFParserType[GLTFParserType["AnimatorController"] = 11] = "AnimatorController";
|
|
2059
2048
|
})(exports.GLTFParserType || (exports.GLTFParserType = {}));
|
|
2060
2049
|
var _obj;
|
|
2061
2050
|
var glTFSchemaMap = (_obj = {}, _obj[2] = "scenes", _obj[3] = "buffers", _obj[5] = "textures", _obj[6] = "materials", _obj[7] = "meshes", _obj[8] = "nodes", _obj[9] = "skins", _obj[10] = "animations", _obj[4] = "bufferViews", _obj);
|
|
2062
2051
|
var _obj1;
|
|
2063
|
-
var glTFResourceMap = (_obj1 = {}, _obj1[2] = "_sceneRoots", _obj1[5] = "textures", _obj1[6] = "materials", _obj1[7] = "meshes", _obj1[8] = "entities", _obj1[9] = "skins", _obj1[10] = "animations", _obj1);
|
|
2052
|
+
var glTFResourceMap = (_obj1 = {}, _obj1[2] = "_sceneRoots", _obj1[5] = "textures", _obj1[6] = "materials", _obj1[7] = "meshes", _obj1[8] = "entities", _obj1[9] = "skins", _obj1[10] = "animations", _obj1[11] = "animatorController", _obj1);
|
|
2064
2053
|
function registerGLTFParser(pipeline) {
|
|
2065
2054
|
return function(Parser) {
|
|
2066
2055
|
var parser = new Parser();
|
|
@@ -4840,6 +4829,48 @@ exports.GLTFBufferViewParser = __decorate([
|
|
|
4840
4829
|
registerGLTFParser(exports.GLTFParserType.BufferView)
|
|
4841
4830
|
], exports.GLTFBufferViewParser);
|
|
4842
4831
|
|
|
4832
|
+
exports.GLTFAnimatorControllerParser = /*#__PURE__*/ function(GLTFParser1) {
|
|
4833
|
+
_inherits(GLTFAnimatorControllerParser, GLTFParser1);
|
|
4834
|
+
function GLTFAnimatorControllerParser() {
|
|
4835
|
+
return GLTFParser1.apply(this, arguments);
|
|
4836
|
+
}
|
|
4837
|
+
var _proto = GLTFAnimatorControllerParser.prototype;
|
|
4838
|
+
_proto.parse = function parse(context) {
|
|
4839
|
+
var _this = this;
|
|
4840
|
+
if (!context.needAnimatorController) {
|
|
4841
|
+
return Promise.resolve(null);
|
|
4842
|
+
}
|
|
4843
|
+
return context.get(exports.GLTFParserType.Animation).then(function(animations) {
|
|
4844
|
+
var animatorController = _this._createAnimatorController(animations);
|
|
4845
|
+
return Promise.resolve(animatorController);
|
|
4846
|
+
});
|
|
4847
|
+
};
|
|
4848
|
+
_proto._createAnimatorController = function _createAnimatorController(animations) {
|
|
4849
|
+
var animatorController = new engineCore.AnimatorController();
|
|
4850
|
+
var layer = new engineCore.AnimatorControllerLayer("layer");
|
|
4851
|
+
var animatorStateMachine = new engineCore.AnimatorStateMachine();
|
|
4852
|
+
animatorController.addLayer(layer);
|
|
4853
|
+
layer.stateMachine = animatorStateMachine;
|
|
4854
|
+
if (animations) {
|
|
4855
|
+
for(var i = 0; i < animations.length; i++){
|
|
4856
|
+
var animationClip = animations[i];
|
|
4857
|
+
var name = animationClip.name;
|
|
4858
|
+
var uniqueName = animatorStateMachine.makeUniqueStateName(name);
|
|
4859
|
+
if (uniqueName !== name) {
|
|
4860
|
+
console.warn("AnimatorState name is existed, name: " + name + " reset to " + uniqueName);
|
|
4861
|
+
}
|
|
4862
|
+
var animatorState = animatorStateMachine.addState(uniqueName);
|
|
4863
|
+
animatorState.clip = animationClip;
|
|
4864
|
+
}
|
|
4865
|
+
}
|
|
4866
|
+
return animatorController;
|
|
4867
|
+
};
|
|
4868
|
+
return GLTFAnimatorControllerParser;
|
|
4869
|
+
}(GLTFParser);
|
|
4870
|
+
exports.GLTFAnimatorControllerParser = __decorate([
|
|
4871
|
+
registerGLTFParser(exports.GLTFParserType.AnimatorController)
|
|
4872
|
+
], exports.GLTFAnimatorControllerParser);
|
|
4873
|
+
|
|
4843
4874
|
// Source: https://github.com/zeux/meshoptimizer/blob/master/js/meshopt_decoder.js
|
|
4844
4875
|
var MeshoptDecoder = function() {
|
|
4845
4876
|
var unpack = function unpack(data) {
|
|
@@ -5077,7 +5108,8 @@ exports.GLTFLoader = __decorate([
|
|
|
5077
5108
|
|
|
5078
5109
|
var _HDRLoader;
|
|
5079
5110
|
var PI = Math.PI;
|
|
5080
|
-
var HDRLoader = (_HDRLoader =
|
|
5111
|
+
var HDRLoader = (_HDRLoader = // referenece: https://www.flipcode.com/archives/HDR_Image_Reader.shtml
|
|
5112
|
+
/*#__PURE__*/ function(Loader1) {
|
|
5081
5113
|
_inherits(HDRLoader1, Loader1);
|
|
5082
5114
|
function HDRLoader1() {
|
|
5083
5115
|
return Loader1.apply(this, arguments);
|
|
@@ -5247,15 +5279,20 @@ var HDRLoader = (_HDRLoader = /*#__PURE__*/ function(Loader1) {
|
|
|
5247
5279
|
var dataRGBA = new Uint8Array(4 * width * height);
|
|
5248
5280
|
var offset = 0, pos = 0;
|
|
5249
5281
|
var ptrEnd = 4 * scanLineWidth;
|
|
5250
|
-
var rgbeStart = new Uint8Array(4);
|
|
5251
5282
|
var scanLineBuffer = new Uint8Array(ptrEnd);
|
|
5252
5283
|
var numScanLines = height; // read in each successive scanLine
|
|
5253
5284
|
while(numScanLines > 0 && pos < byteLength){
|
|
5254
|
-
|
|
5255
|
-
|
|
5256
|
-
|
|
5257
|
-
|
|
5258
|
-
if (
|
|
5285
|
+
var a = buffer[pos++];
|
|
5286
|
+
var b = buffer[pos++];
|
|
5287
|
+
var c = buffer[pos++];
|
|
5288
|
+
var d = buffer[pos++];
|
|
5289
|
+
if (a != 2 || b != 2 || c & 0x80 || width < 8 || width > 32767) {
|
|
5290
|
+
// this file is not run length encoded
|
|
5291
|
+
// read values sequentially
|
|
5292
|
+
return buffer;
|
|
5293
|
+
}
|
|
5294
|
+
if ((c << 8 | d) != scanLineWidth) {
|
|
5295
|
+
// eslint-disable-next-line no-throw-literal
|
|
5259
5296
|
throw "HDR Bad header format, wrong scan line width";
|
|
5260
5297
|
}
|
|
5261
5298
|
// read each of the four channels for the scanline into the buffer
|