@galacean/engine-loader 1.2.0-beta.2 → 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/GLTFResource.d.ts +8 -6
- package/types/gltf/parser/GLTFAnimatorControllerParser.d.ts +7 -0
- package/types/gltf/parser/GLTFParserContext.d.ts +4 -2
- package/types/gltf/parser/index.d.ts +1 -0
package/dist/miniprogram.js
CHANGED
|
@@ -1887,6 +1887,7 @@ var TextureWrapMode;
|
|
|
1887
1887
|
this.resourceManager = resourceManager;
|
|
1888
1888
|
this.params = params;
|
|
1889
1889
|
this.accessorBufferCache = {};
|
|
1890
|
+
this.needAnimatorController = false;
|
|
1890
1891
|
this._resourceCache = new Map();
|
|
1891
1892
|
this._progress = {
|
|
1892
1893
|
taskDetail: {},
|
|
@@ -1914,16 +1915,15 @@ var TextureWrapMode;
|
|
|
1914
1915
|
return Promise.resolve(null);
|
|
1915
1916
|
}
|
|
1916
1917
|
var cache = this._resourceCache;
|
|
1917
|
-
var
|
|
1918
|
-
var cacheKey = isOnlyOne || index === undefined ? "" + type : type + ":" + index;
|
|
1918
|
+
var cacheKey = index === undefined ? "" + type : type + ":" + index;
|
|
1919
1919
|
var resource = cache.get(cacheKey);
|
|
1920
1920
|
if (resource) {
|
|
1921
1921
|
return resource;
|
|
1922
1922
|
}
|
|
1923
|
-
|
|
1924
|
-
|
|
1925
|
-
|
|
1926
|
-
var glTFItems = this.glTF[
|
|
1923
|
+
var glTFSchemaKey = glTFSchemaMap[type];
|
|
1924
|
+
var isSubAsset = !!glTFResourceMap[type];
|
|
1925
|
+
if (glTFSchemaKey) {
|
|
1926
|
+
var glTFItems = this.glTF[glTFSchemaKey];
|
|
1927
1927
|
if (glTFItems && (index === undefined || glTFItems[index])) {
|
|
1928
1928
|
if (index === undefined) {
|
|
1929
1929
|
resource = type === 8 ? glTFItems.map(function(_, index) {
|
|
@@ -1933,11 +1933,14 @@ var TextureWrapMode;
|
|
|
1933
1933
|
}));
|
|
1934
1934
|
} else {
|
|
1935
1935
|
resource = parser.parse(this, index);
|
|
1936
|
-
this._handleSubAsset(resource, type, index);
|
|
1936
|
+
isSubAsset && this._handleSubAsset(resource, type, index);
|
|
1937
1937
|
}
|
|
1938
1938
|
} else {
|
|
1939
1939
|
resource = Promise.resolve(null);
|
|
1940
1940
|
}
|
|
1941
|
+
} else {
|
|
1942
|
+
resource = parser.parse(this, index);
|
|
1943
|
+
isSubAsset && this._handleSubAsset(resource, type, index);
|
|
1941
1944
|
}
|
|
1942
1945
|
cache.set(cacheKey, resource);
|
|
1943
1946
|
return resource;
|
|
@@ -1946,6 +1949,7 @@ var TextureWrapMode;
|
|
|
1946
1949
|
var _this = this;
|
|
1947
1950
|
var promise = this.get(0).then(function(json) {
|
|
1948
1951
|
_this.glTF = json;
|
|
1952
|
+
_this.needAnimatorController = !!(json.skins || json.animations);
|
|
1949
1953
|
return Promise.all([
|
|
1950
1954
|
_this.get(1),
|
|
1951
1955
|
_this.get(5),
|
|
@@ -1953,11 +1957,14 @@ var TextureWrapMode;
|
|
|
1953
1957
|
_this.get(7),
|
|
1954
1958
|
_this.get(9),
|
|
1955
1959
|
_this.get(10),
|
|
1960
|
+
_this.get(11),
|
|
1956
1961
|
_this.get(2)
|
|
1957
1962
|
]).then(function() {
|
|
1958
1963
|
var glTFResource = _this.glTFResource;
|
|
1959
|
-
|
|
1960
|
-
|
|
1964
|
+
var animatorController = glTFResource.animatorController;
|
|
1965
|
+
if (animatorController) {
|
|
1966
|
+
var animator = glTFResource._defaultSceneRoot.addComponent(miniprogram.Animator);
|
|
1967
|
+
animator.animatorController = animatorController;
|
|
1961
1968
|
}
|
|
1962
1969
|
_this.resourceManager.addContentRestorer(_this.contentRestorer);
|
|
1963
1970
|
return glTFResource;
|
|
@@ -1976,40 +1983,21 @@ var TextureWrapMode;
|
|
|
1976
1983
|
_this._setTaskCompleteProgress(++task.loaded, task.total);
|
|
1977
1984
|
});
|
|
1978
1985
|
};
|
|
1979
|
-
_proto._createAnimator = function _createAnimator(context, animations) {
|
|
1980
|
-
var defaultSceneRoot = context.glTFResource.defaultSceneRoot;
|
|
1981
|
-
var animator = defaultSceneRoot.addComponent(miniprogram.Animator);
|
|
1982
|
-
var animatorController = new miniprogram.AnimatorController();
|
|
1983
|
-
var layer = new miniprogram.AnimatorControllerLayer("layer");
|
|
1984
|
-
var animatorStateMachine = new miniprogram.AnimatorStateMachine();
|
|
1985
|
-
animatorController.addLayer(layer);
|
|
1986
|
-
animator.animatorController = animatorController;
|
|
1987
|
-
layer.stateMachine = animatorStateMachine;
|
|
1988
|
-
if (animations) {
|
|
1989
|
-
for(var i = 0; i < animations.length; i++){
|
|
1990
|
-
var animationClip = animations[i];
|
|
1991
|
-
var name = animationClip.name;
|
|
1992
|
-
var uniqueName = animatorStateMachine.makeUniqueStateName(name);
|
|
1993
|
-
if (uniqueName !== name) {
|
|
1994
|
-
console.warn("AnimatorState name is existed, name: " + name + " reset to " + uniqueName);
|
|
1995
|
-
}
|
|
1996
|
-
var animatorState = animatorStateMachine.addState(uniqueName);
|
|
1997
|
-
animatorState.clip = animationClip;
|
|
1998
|
-
}
|
|
1999
|
-
}
|
|
2000
|
-
};
|
|
2001
1986
|
_proto._handleSubAsset = function _handleSubAsset(resource, type, index) {
|
|
2002
1987
|
var _this = this;
|
|
2003
1988
|
var glTFResourceKey = glTFResourceMap[type];
|
|
2004
|
-
if (!glTFResourceKey) return;
|
|
2005
1989
|
if (type === 8) {
|
|
2006
1990
|
var _this_glTFResource, _glTFResourceKey;
|
|
2007
1991
|
((_this_glTFResource = this.glTFResource)[_glTFResourceKey = glTFResourceKey] || (_this_glTFResource[_glTFResourceKey] = []))[index] = resource;
|
|
2008
1992
|
} else {
|
|
2009
1993
|
var url = this.glTFResource.url;
|
|
2010
1994
|
resource.then(function(item) {
|
|
2011
|
-
|
|
2012
|
-
|
|
1995
|
+
if (index == undefined) {
|
|
1996
|
+
_this.glTFResource[glTFResourceKey] = item;
|
|
1997
|
+
} else {
|
|
1998
|
+
var _this_glTFResource, _glTFResourceKey;
|
|
1999
|
+
((_this_glTFResource = _this.glTFResource)[_glTFResourceKey = glTFResourceKey] || (_this_glTFResource[_glTFResourceKey] = []))[index] = item;
|
|
2000
|
+
}
|
|
2013
2001
|
if (type === 7) {
|
|
2014
2002
|
for(var i = 0, length = item.length; i < length; i++){
|
|
2015
2003
|
var mesh = item[i];
|
|
@@ -2057,11 +2045,12 @@ exports.GLTFParserType = void 0;
|
|
|
2057
2045
|
GLTFParserType[GLTFParserType["Entity"] = 8] = "Entity";
|
|
2058
2046
|
GLTFParserType[GLTFParserType["Skin"] = 9] = "Skin";
|
|
2059
2047
|
GLTFParserType[GLTFParserType["Animation"] = 10] = "Animation";
|
|
2048
|
+
GLTFParserType[GLTFParserType["AnimatorController"] = 11] = "AnimatorController";
|
|
2060
2049
|
})(exports.GLTFParserType || (exports.GLTFParserType = {}));
|
|
2061
2050
|
var _obj;
|
|
2062
2051
|
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);
|
|
2063
2052
|
var _obj1;
|
|
2064
|
-
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);
|
|
2053
|
+
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);
|
|
2065
2054
|
function registerGLTFParser(pipeline) {
|
|
2066
2055
|
return function(Parser) {
|
|
2067
2056
|
var parser = new Parser();
|
|
@@ -4841,6 +4830,48 @@ exports.GLTFBufferViewParser = __decorate([
|
|
|
4841
4830
|
registerGLTFParser(exports.GLTFParserType.BufferView)
|
|
4842
4831
|
], exports.GLTFBufferViewParser);
|
|
4843
4832
|
|
|
4833
|
+
exports.GLTFAnimatorControllerParser = /*#__PURE__*/ function(GLTFParser1) {
|
|
4834
|
+
_inherits(GLTFAnimatorControllerParser, GLTFParser1);
|
|
4835
|
+
function GLTFAnimatorControllerParser() {
|
|
4836
|
+
return GLTFParser1.apply(this, arguments);
|
|
4837
|
+
}
|
|
4838
|
+
var _proto = GLTFAnimatorControllerParser.prototype;
|
|
4839
|
+
_proto.parse = function parse(context) {
|
|
4840
|
+
var _this = this;
|
|
4841
|
+
if (!context.needAnimatorController) {
|
|
4842
|
+
return Promise.resolve(null);
|
|
4843
|
+
}
|
|
4844
|
+
return context.get(exports.GLTFParserType.Animation).then(function(animations) {
|
|
4845
|
+
var animatorController = _this._createAnimatorController(animations);
|
|
4846
|
+
return Promise.resolve(animatorController);
|
|
4847
|
+
});
|
|
4848
|
+
};
|
|
4849
|
+
_proto._createAnimatorController = function _createAnimatorController(animations) {
|
|
4850
|
+
var animatorController = new miniprogram.AnimatorController();
|
|
4851
|
+
var layer = new miniprogram.AnimatorControllerLayer("layer");
|
|
4852
|
+
var animatorStateMachine = new miniprogram.AnimatorStateMachine();
|
|
4853
|
+
animatorController.addLayer(layer);
|
|
4854
|
+
layer.stateMachine = animatorStateMachine;
|
|
4855
|
+
if (animations) {
|
|
4856
|
+
for(var i = 0; i < animations.length; i++){
|
|
4857
|
+
var animationClip = animations[i];
|
|
4858
|
+
var name = animationClip.name;
|
|
4859
|
+
var uniqueName = animatorStateMachine.makeUniqueStateName(name);
|
|
4860
|
+
if (uniqueName !== name) {
|
|
4861
|
+
console.warn("AnimatorState name is existed, name: " + name + " reset to " + uniqueName);
|
|
4862
|
+
}
|
|
4863
|
+
var animatorState = animatorStateMachine.addState(uniqueName);
|
|
4864
|
+
animatorState.clip = animationClip;
|
|
4865
|
+
}
|
|
4866
|
+
}
|
|
4867
|
+
return animatorController;
|
|
4868
|
+
};
|
|
4869
|
+
return GLTFAnimatorControllerParser;
|
|
4870
|
+
}(GLTFParser);
|
|
4871
|
+
exports.GLTFAnimatorControllerParser = __decorate([
|
|
4872
|
+
registerGLTFParser(exports.GLTFParserType.AnimatorController)
|
|
4873
|
+
], exports.GLTFAnimatorControllerParser);
|
|
4874
|
+
|
|
4844
4875
|
var MeshoptDecoder = function() {
|
|
4845
4876
|
var unpack = function unpack(data) {
|
|
4846
4877
|
var result = new Uint8Array(data.length);
|
|
@@ -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
|
package/dist/module.js
CHANGED
|
@@ -1882,6 +1882,7 @@ var TextureWrapMode;
|
|
|
1882
1882
|
this.resourceManager = resourceManager;
|
|
1883
1883
|
this.params = params;
|
|
1884
1884
|
this.accessorBufferCache = {};
|
|
1885
|
+
this.needAnimatorController = false;
|
|
1885
1886
|
this._resourceCache = new Map();
|
|
1886
1887
|
this._progress = {
|
|
1887
1888
|
taskDetail: {},
|
|
@@ -1909,16 +1910,15 @@ var TextureWrapMode;
|
|
|
1909
1910
|
return Promise.resolve(null);
|
|
1910
1911
|
}
|
|
1911
1912
|
var cache = this._resourceCache;
|
|
1912
|
-
var
|
|
1913
|
-
var cacheKey = isOnlyOne || index === undefined ? "" + type : type + ":" + index;
|
|
1913
|
+
var cacheKey = index === undefined ? "" + type : type + ":" + index;
|
|
1914
1914
|
var resource = cache.get(cacheKey);
|
|
1915
1915
|
if (resource) {
|
|
1916
1916
|
return resource;
|
|
1917
1917
|
}
|
|
1918
|
-
|
|
1919
|
-
|
|
1920
|
-
|
|
1921
|
-
var glTFItems = this.glTF[
|
|
1918
|
+
var glTFSchemaKey = glTFSchemaMap[type];
|
|
1919
|
+
var isSubAsset = !!glTFResourceMap[type];
|
|
1920
|
+
if (glTFSchemaKey) {
|
|
1921
|
+
var glTFItems = this.glTF[glTFSchemaKey];
|
|
1922
1922
|
if (glTFItems && (index === undefined || glTFItems[index])) {
|
|
1923
1923
|
if (index === undefined) {
|
|
1924
1924
|
resource = type === 8 ? glTFItems.map(function(_, index) {
|
|
@@ -1928,11 +1928,14 @@ var TextureWrapMode;
|
|
|
1928
1928
|
}));
|
|
1929
1929
|
} else {
|
|
1930
1930
|
resource = parser.parse(this, index);
|
|
1931
|
-
this._handleSubAsset(resource, type, index);
|
|
1931
|
+
isSubAsset && this._handleSubAsset(resource, type, index);
|
|
1932
1932
|
}
|
|
1933
1933
|
} else {
|
|
1934
1934
|
resource = Promise.resolve(null);
|
|
1935
1935
|
}
|
|
1936
|
+
} else {
|
|
1937
|
+
resource = parser.parse(this, index);
|
|
1938
|
+
isSubAsset && this._handleSubAsset(resource, type, index);
|
|
1936
1939
|
}
|
|
1937
1940
|
cache.set(cacheKey, resource);
|
|
1938
1941
|
return resource;
|
|
@@ -1941,6 +1944,7 @@ var TextureWrapMode;
|
|
|
1941
1944
|
var _this = this;
|
|
1942
1945
|
var promise = this.get(0).then(function(json) {
|
|
1943
1946
|
_this.glTF = json;
|
|
1947
|
+
_this.needAnimatorController = !!(json.skins || json.animations);
|
|
1944
1948
|
return Promise.all([
|
|
1945
1949
|
_this.get(1),
|
|
1946
1950
|
_this.get(5),
|
|
@@ -1948,11 +1952,14 @@ var TextureWrapMode;
|
|
|
1948
1952
|
_this.get(7),
|
|
1949
1953
|
_this.get(9),
|
|
1950
1954
|
_this.get(10),
|
|
1955
|
+
_this.get(11),
|
|
1951
1956
|
_this.get(2)
|
|
1952
1957
|
]).then(function() {
|
|
1953
1958
|
var glTFResource = _this.glTFResource;
|
|
1954
|
-
|
|
1955
|
-
|
|
1959
|
+
var animatorController = glTFResource.animatorController;
|
|
1960
|
+
if (animatorController) {
|
|
1961
|
+
var animator = glTFResource._defaultSceneRoot.addComponent(Animator);
|
|
1962
|
+
animator.animatorController = animatorController;
|
|
1956
1963
|
}
|
|
1957
1964
|
_this.resourceManager.addContentRestorer(_this.contentRestorer);
|
|
1958
1965
|
return glTFResource;
|
|
@@ -1971,40 +1978,21 @@ var TextureWrapMode;
|
|
|
1971
1978
|
_this._setTaskCompleteProgress(++task.loaded, task.total);
|
|
1972
1979
|
});
|
|
1973
1980
|
};
|
|
1974
|
-
_proto._createAnimator = function _createAnimator(context, animations) {
|
|
1975
|
-
var defaultSceneRoot = context.glTFResource.defaultSceneRoot;
|
|
1976
|
-
var animator = defaultSceneRoot.addComponent(Animator);
|
|
1977
|
-
var animatorController = new AnimatorController();
|
|
1978
|
-
var layer = new AnimatorControllerLayer("layer");
|
|
1979
|
-
var animatorStateMachine = new AnimatorStateMachine();
|
|
1980
|
-
animatorController.addLayer(layer);
|
|
1981
|
-
animator.animatorController = animatorController;
|
|
1982
|
-
layer.stateMachine = animatorStateMachine;
|
|
1983
|
-
if (animations) {
|
|
1984
|
-
for(var i = 0; i < animations.length; i++){
|
|
1985
|
-
var animationClip = animations[i];
|
|
1986
|
-
var name = animationClip.name;
|
|
1987
|
-
var uniqueName = animatorStateMachine.makeUniqueStateName(name);
|
|
1988
|
-
if (uniqueName !== name) {
|
|
1989
|
-
console.warn("AnimatorState name is existed, name: " + name + " reset to " + uniqueName);
|
|
1990
|
-
}
|
|
1991
|
-
var animatorState = animatorStateMachine.addState(uniqueName);
|
|
1992
|
-
animatorState.clip = animationClip;
|
|
1993
|
-
}
|
|
1994
|
-
}
|
|
1995
|
-
};
|
|
1996
1981
|
_proto._handleSubAsset = function _handleSubAsset(resource, type, index) {
|
|
1997
1982
|
var _this = this;
|
|
1998
1983
|
var glTFResourceKey = glTFResourceMap[type];
|
|
1999
|
-
if (!glTFResourceKey) return;
|
|
2000
1984
|
if (type === 8) {
|
|
2001
1985
|
var _this_glTFResource, _glTFResourceKey;
|
|
2002
1986
|
((_this_glTFResource = this.glTFResource)[_glTFResourceKey = glTFResourceKey] || (_this_glTFResource[_glTFResourceKey] = []))[index] = resource;
|
|
2003
1987
|
} else {
|
|
2004
1988
|
var url = this.glTFResource.url;
|
|
2005
1989
|
resource.then(function(item) {
|
|
2006
|
-
|
|
2007
|
-
|
|
1990
|
+
if (index == undefined) {
|
|
1991
|
+
_this.glTFResource[glTFResourceKey] = item;
|
|
1992
|
+
} else {
|
|
1993
|
+
var _this_glTFResource, _glTFResourceKey;
|
|
1994
|
+
((_this_glTFResource = _this.glTFResource)[_glTFResourceKey = glTFResourceKey] || (_this_glTFResource[_glTFResourceKey] = []))[index] = item;
|
|
1995
|
+
}
|
|
2008
1996
|
if (type === 7) {
|
|
2009
1997
|
for(var i = 0, length = item.length; i < length; i++){
|
|
2010
1998
|
var mesh = item[i];
|
|
@@ -2052,11 +2040,12 @@ var GLTFParserType;
|
|
|
2052
2040
|
GLTFParserType[GLTFParserType["Entity"] = 8] = "Entity";
|
|
2053
2041
|
GLTFParserType[GLTFParserType["Skin"] = 9] = "Skin";
|
|
2054
2042
|
GLTFParserType[GLTFParserType["Animation"] = 10] = "Animation";
|
|
2043
|
+
GLTFParserType[GLTFParserType["AnimatorController"] = 11] = "AnimatorController";
|
|
2055
2044
|
})(GLTFParserType || (GLTFParserType = {}));
|
|
2056
2045
|
var _obj;
|
|
2057
2046
|
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);
|
|
2058
2047
|
var _obj1;
|
|
2059
|
-
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);
|
|
2048
|
+
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);
|
|
2060
2049
|
function registerGLTFParser(pipeline) {
|
|
2061
2050
|
return function(Parser) {
|
|
2062
2051
|
var parser = new Parser();
|
|
@@ -4836,6 +4825,48 @@ GLTFBufferViewParser = __decorate([
|
|
|
4836
4825
|
registerGLTFParser(GLTFParserType.BufferView)
|
|
4837
4826
|
], GLTFBufferViewParser);
|
|
4838
4827
|
|
|
4828
|
+
var GLTFAnimatorControllerParser = /*#__PURE__*/ function(GLTFParser1) {
|
|
4829
|
+
_inherits(GLTFAnimatorControllerParser, GLTFParser1);
|
|
4830
|
+
function GLTFAnimatorControllerParser() {
|
|
4831
|
+
return GLTFParser1.apply(this, arguments);
|
|
4832
|
+
}
|
|
4833
|
+
var _proto = GLTFAnimatorControllerParser.prototype;
|
|
4834
|
+
_proto.parse = function parse(context) {
|
|
4835
|
+
var _this = this;
|
|
4836
|
+
if (!context.needAnimatorController) {
|
|
4837
|
+
return Promise.resolve(null);
|
|
4838
|
+
}
|
|
4839
|
+
return context.get(GLTFParserType.Animation).then(function(animations) {
|
|
4840
|
+
var animatorController = _this._createAnimatorController(animations);
|
|
4841
|
+
return Promise.resolve(animatorController);
|
|
4842
|
+
});
|
|
4843
|
+
};
|
|
4844
|
+
_proto._createAnimatorController = function _createAnimatorController(animations) {
|
|
4845
|
+
var animatorController = new AnimatorController();
|
|
4846
|
+
var layer = new AnimatorControllerLayer("layer");
|
|
4847
|
+
var animatorStateMachine = new AnimatorStateMachine();
|
|
4848
|
+
animatorController.addLayer(layer);
|
|
4849
|
+
layer.stateMachine = animatorStateMachine;
|
|
4850
|
+
if (animations) {
|
|
4851
|
+
for(var i = 0; i < animations.length; i++){
|
|
4852
|
+
var animationClip = animations[i];
|
|
4853
|
+
var name = animationClip.name;
|
|
4854
|
+
var uniqueName = animatorStateMachine.makeUniqueStateName(name);
|
|
4855
|
+
if (uniqueName !== name) {
|
|
4856
|
+
console.warn("AnimatorState name is existed, name: " + name + " reset to " + uniqueName);
|
|
4857
|
+
}
|
|
4858
|
+
var animatorState = animatorStateMachine.addState(uniqueName);
|
|
4859
|
+
animatorState.clip = animationClip;
|
|
4860
|
+
}
|
|
4861
|
+
}
|
|
4862
|
+
return animatorController;
|
|
4863
|
+
};
|
|
4864
|
+
return GLTFAnimatorControllerParser;
|
|
4865
|
+
}(GLTFParser);
|
|
4866
|
+
GLTFAnimatorControllerParser = __decorate([
|
|
4867
|
+
registerGLTFParser(GLTFParserType.AnimatorController)
|
|
4868
|
+
], GLTFAnimatorControllerParser);
|
|
4869
|
+
|
|
4839
4870
|
// Source: https://github.com/zeux/meshoptimizer/blob/master/js/meshopt_decoder.js
|
|
4840
4871
|
var MeshoptDecoder = function() {
|
|
4841
4872
|
var unpack = function unpack(data) {
|
|
@@ -5073,7 +5104,8 @@ GLTFLoader = __decorate([
|
|
|
5073
5104
|
|
|
5074
5105
|
var _HDRLoader;
|
|
5075
5106
|
var PI = Math.PI;
|
|
5076
|
-
var HDRLoader = (_HDRLoader =
|
|
5107
|
+
var HDRLoader = (_HDRLoader = // referenece: https://www.flipcode.com/archives/HDR_Image_Reader.shtml
|
|
5108
|
+
/*#__PURE__*/ function(Loader1) {
|
|
5077
5109
|
_inherits(HDRLoader1, Loader1);
|
|
5078
5110
|
function HDRLoader1() {
|
|
5079
5111
|
return Loader1.apply(this, arguments);
|
|
@@ -5243,15 +5275,20 @@ var HDRLoader = (_HDRLoader = /*#__PURE__*/ function(Loader1) {
|
|
|
5243
5275
|
var dataRGBA = new Uint8Array(4 * width * height);
|
|
5244
5276
|
var offset = 0, pos = 0;
|
|
5245
5277
|
var ptrEnd = 4 * scanLineWidth;
|
|
5246
|
-
var rgbeStart = new Uint8Array(4);
|
|
5247
5278
|
var scanLineBuffer = new Uint8Array(ptrEnd);
|
|
5248
5279
|
var numScanLines = height; // read in each successive scanLine
|
|
5249
5280
|
while(numScanLines > 0 && pos < byteLength){
|
|
5250
|
-
|
|
5251
|
-
|
|
5252
|
-
|
|
5253
|
-
|
|
5254
|
-
if (
|
|
5281
|
+
var a = buffer[pos++];
|
|
5282
|
+
var b = buffer[pos++];
|
|
5283
|
+
var c = buffer[pos++];
|
|
5284
|
+
var d = buffer[pos++];
|
|
5285
|
+
if (a != 2 || b != 2 || c & 0x80 || width < 8 || width > 32767) {
|
|
5286
|
+
// this file is not run length encoded
|
|
5287
|
+
// read values sequentially
|
|
5288
|
+
return buffer;
|
|
5289
|
+
}
|
|
5290
|
+
if ((c << 8 | d) != scanLineWidth) {
|
|
5291
|
+
// eslint-disable-next-line no-throw-literal
|
|
5255
5292
|
throw "HDR Bad header format, wrong scan line width";
|
|
5256
5293
|
}
|
|
5257
5294
|
// read each of the four channels for the scanline into the buffer
|
|
@@ -6689,5 +6726,5 @@ KHR_materials_anisotropy = __decorate([
|
|
|
6689
6726
|
registerGLTFExtension("KHR_materials_anisotropy", GLTFExtensionMode.AdditiveParse)
|
|
6690
6727
|
], KHR_materials_anisotropy);
|
|
6691
6728
|
|
|
6692
|
-
export { AccessorType, AnimationClipDecoder, BufferInfo, EditorTextureLoader, GLTFAnimationParser, GLTFBufferParser, GLTFBufferViewParser, GLTFEntityParser, GLTFExtensionMode, GLTFExtensionParser, GLTFLoader, GLTFMaterialParser, GLTFMeshParser, GLTFParser, GLTFParserContext, GLTFParserType, GLTFResource, GLTFSceneParser, GLTFSchemaParser, GLTFSkinParser, GLTFTextureParser, GLTFUtils, GLTFValidator, InterpolableValueType, KTX2Loader, KTX2TargetFormat, KTX2Transcoder, MeshDecoder, MeshLoader$1 as MeshLoader, ParserContext, PrefabParser, ReflectionParser, SceneParser, SpecularMode, Texture2DDecoder, decode, parseSingleKTX, registerGLTFExtension, registerGLTFParser };
|
|
6729
|
+
export { AccessorType, AnimationClipDecoder, BufferInfo, EditorTextureLoader, GLTFAnimationParser, GLTFAnimatorControllerParser, GLTFBufferParser, GLTFBufferViewParser, GLTFEntityParser, GLTFExtensionMode, GLTFExtensionParser, GLTFLoader, GLTFMaterialParser, GLTFMeshParser, GLTFParser, GLTFParserContext, GLTFParserType, GLTFResource, GLTFSceneParser, GLTFSchemaParser, GLTFSkinParser, GLTFTextureParser, GLTFUtils, GLTFValidator, InterpolableValueType, KTX2Loader, KTX2TargetFormat, KTX2Transcoder, MeshDecoder, MeshLoader$1 as MeshLoader, ParserContext, PrefabParser, ReflectionParser, SceneParser, SpecularMode, Texture2DDecoder, decode, parseSingleKTX, registerGLTFExtension, registerGLTFParser };
|
|
6693
6730
|
//# sourceMappingURL=module.js.map
|