@galacean/engine-loader 1.2.0-beta.3 → 1.2.0-beta.5
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 +116 -81
- package/dist/main.js.map +1 -1
- package/dist/miniprogram.js +116 -81
- package/dist/module.js +117 -82
- 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();
|
|
@@ -4545,25 +4534,31 @@ exports.GLTFSceneParser = /*#__PURE__*/ function(GLTFParser1) {
|
|
|
4545
4534
|
camera.enabled = false;
|
|
4546
4535
|
};
|
|
4547
4536
|
_proto._createRenderer = function _createRenderer(context, entityInfo, entity) {
|
|
4548
|
-
var
|
|
4549
|
-
|
|
4550
|
-
|
|
4551
|
-
|
|
4552
|
-
|
|
4553
|
-
|
|
4554
|
-
|
|
4555
|
-
|
|
4556
|
-
|
|
4537
|
+
var _this = this;
|
|
4538
|
+
var meshID = entityInfo.mesh, skinID = entityInfo.skin;
|
|
4539
|
+
var glTFMesh = context.glTF.meshes[meshID];
|
|
4540
|
+
var glTFMeshPrimitives = glTFMesh.primitives;
|
|
4541
|
+
var rendererCount = glTFMeshPrimitives.length;
|
|
4542
|
+
var blendShapeWeights = entityInfo.weights || glTFMesh.weights;
|
|
4543
|
+
var materialPromises = new Array(rendererCount);
|
|
4544
|
+
for(var i = 0; i < rendererCount; i++){
|
|
4545
|
+
materialPromises[i] = context.get(exports.GLTFParserType.Material, glTFMeshPrimitives[i].material);
|
|
4546
|
+
}
|
|
4547
|
+
return Promise.all([
|
|
4548
|
+
context.get(exports.GLTFParserType.Mesh, meshID),
|
|
4549
|
+
skinID !== undefined && context.get(exports.GLTFParserType.Skin, skinID),
|
|
4550
|
+
Promise.all(materialPromises)
|
|
4551
|
+
]).then(function(param) {
|
|
4552
|
+
var _loop = function(i) {
|
|
4553
|
+
var material = materials[i] || exports.GLTFMaterialParser._getDefaultMaterial(context.glTFResource.engine);
|
|
4554
|
+
var glTFPrimitive = glTFMeshPrimitives[i];
|
|
4557
4555
|
var mesh = meshes[i];
|
|
4558
|
-
var renderer;
|
|
4559
|
-
material || (material = exports.GLTFMaterialParser._getDefaultMaterial(context.glTFResource.engine));
|
|
4556
|
+
var renderer = void 0;
|
|
4560
4557
|
if (skin || blendShapeWeights) {
|
|
4561
4558
|
var skinRenderer = entity.addComponent(engineCore.SkinnedMeshRenderer);
|
|
4562
4559
|
skinRenderer.mesh = mesh;
|
|
4563
4560
|
if (skin) {
|
|
4564
|
-
skinRenderer.rootBone
|
|
4565
|
-
skinRenderer.bones = skin._bones;
|
|
4566
|
-
_this._computeLocalBounds(skinRenderer, mesh, skin._bones, skin._rootBone, skin.inverseBindMatrices);
|
|
4561
|
+
_this._computeLocalBounds(skinRenderer, mesh, skin.bones, skin.rootBone, skin.inverseBindMatrices);
|
|
4567
4562
|
skinRenderer.skin = skin;
|
|
4568
4563
|
}
|
|
4569
4564
|
if (blendShapeWeights) {
|
|
@@ -4582,17 +4577,10 @@ exports.GLTFSceneParser = /*#__PURE__*/ function(GLTFParser1) {
|
|
|
4582
4577
|
}
|
|
4583
4578
|
});
|
|
4584
4579
|
GLTFParser.executeExtensionsAdditiveAndParse(glTFPrimitive.extensions, context, renderer, glTFPrimitive);
|
|
4585
|
-
}
|
|
4586
|
-
|
|
4587
|
-
|
|
4588
|
-
|
|
4589
|
-
var meshID = entityInfo.mesh, skinID = entityInfo.skin;
|
|
4590
|
-
var glTFMesh = glTFMeshes[meshID];
|
|
4591
|
-
var glTFMeshPrimitives = glTFMesh.primitives;
|
|
4592
|
-
var blendShapeWeights = entityInfo.weights || glTFMesh.weights;
|
|
4593
|
-
var promises = new Array();
|
|
4594
|
-
for(var i = 0; i < glTFMeshPrimitives.length; i++)_loop(i);
|
|
4595
|
-
return Promise.all(promises);
|
|
4580
|
+
};
|
|
4581
|
+
var meshes = param[0], skin = param[1], materials = param[2];
|
|
4582
|
+
for(var i = 0; i < rendererCount; i++)_loop(i);
|
|
4583
|
+
});
|
|
4596
4584
|
};
|
|
4597
4585
|
_proto._computeLocalBounds = function _computeLocalBounds(skinnedMeshRenderer, mesh, bones, rootBone, inverseBindMatrices) {
|
|
4598
4586
|
var rootBoneIndex = bones.indexOf(rootBone);
|
|
@@ -4646,7 +4634,7 @@ exports.GLTFSkinParser = /*#__PURE__*/ function(GLTFParser1) {
|
|
|
4646
4634
|
var jointCount = joints.length;
|
|
4647
4635
|
var skin = new engineCore.Skin(name);
|
|
4648
4636
|
skin.inverseBindMatrices.length = jointCount;
|
|
4649
|
-
|
|
4637
|
+
var bones = new Array(jointCount);
|
|
4650
4638
|
// parse IBM
|
|
4651
4639
|
var accessor = glTF.accessors[inverseBindMatrices];
|
|
4652
4640
|
var skinPromise = GLTFUtils.getAccessorBuffer(context, glTF.bufferViews, accessor).then(function(bufferInfo) {
|
|
@@ -4658,21 +4646,20 @@ exports.GLTFSkinParser = /*#__PURE__*/ function(GLTFParser1) {
|
|
|
4658
4646
|
skin.inverseBindMatrices[i] = inverseBindMatrix;
|
|
4659
4647
|
// Get bones
|
|
4660
4648
|
var bone = entities[joints[i]];
|
|
4661
|
-
|
|
4649
|
+
bones[i] = bone;
|
|
4662
4650
|
skin.joints[i] = bone.name;
|
|
4663
|
-
|
|
4664
|
-
|
|
4665
|
-
|
|
4666
|
-
|
|
4667
|
-
|
|
4651
|
+
}
|
|
4652
|
+
skin.bones = bones;
|
|
4653
|
+
// Get skeleton
|
|
4654
|
+
if (skeleton !== undefined) {
|
|
4655
|
+
var rootBone = entities[skeleton];
|
|
4656
|
+
skin.rootBone = rootBone;
|
|
4657
|
+
} else {
|
|
4658
|
+
var rootBone1 = _this._findSkeletonRootBone(joints, entities);
|
|
4659
|
+
if (rootBone1) {
|
|
4660
|
+
skin.rootBone = rootBone1;
|
|
4668
4661
|
} else {
|
|
4669
|
-
|
|
4670
|
-
if (rootBone1) {
|
|
4671
|
-
skin._rootBone = rootBone1;
|
|
4672
|
-
skin.skeleton = rootBone1.name;
|
|
4673
|
-
} else {
|
|
4674
|
-
throw "Failed to find skeleton root bone.";
|
|
4675
|
-
}
|
|
4662
|
+
throw "Failed to find skeleton root bone.";
|
|
4676
4663
|
}
|
|
4677
4664
|
}
|
|
4678
4665
|
return skin;
|
|
@@ -4840,6 +4827,48 @@ exports.GLTFBufferViewParser = __decorate([
|
|
|
4840
4827
|
registerGLTFParser(exports.GLTFParserType.BufferView)
|
|
4841
4828
|
], exports.GLTFBufferViewParser);
|
|
4842
4829
|
|
|
4830
|
+
exports.GLTFAnimatorControllerParser = /*#__PURE__*/ function(GLTFParser1) {
|
|
4831
|
+
_inherits(GLTFAnimatorControllerParser, GLTFParser1);
|
|
4832
|
+
function GLTFAnimatorControllerParser() {
|
|
4833
|
+
return GLTFParser1.apply(this, arguments);
|
|
4834
|
+
}
|
|
4835
|
+
var _proto = GLTFAnimatorControllerParser.prototype;
|
|
4836
|
+
_proto.parse = function parse(context) {
|
|
4837
|
+
var _this = this;
|
|
4838
|
+
if (!context.needAnimatorController) {
|
|
4839
|
+
return Promise.resolve(null);
|
|
4840
|
+
}
|
|
4841
|
+
return context.get(exports.GLTFParserType.Animation).then(function(animations) {
|
|
4842
|
+
var animatorController = _this._createAnimatorController(animations);
|
|
4843
|
+
return Promise.resolve(animatorController);
|
|
4844
|
+
});
|
|
4845
|
+
};
|
|
4846
|
+
_proto._createAnimatorController = function _createAnimatorController(animations) {
|
|
4847
|
+
var animatorController = new engineCore.AnimatorController();
|
|
4848
|
+
var layer = new engineCore.AnimatorControllerLayer("layer");
|
|
4849
|
+
var animatorStateMachine = new engineCore.AnimatorStateMachine();
|
|
4850
|
+
animatorController.addLayer(layer);
|
|
4851
|
+
layer.stateMachine = animatorStateMachine;
|
|
4852
|
+
if (animations) {
|
|
4853
|
+
for(var i = 0; i < animations.length; i++){
|
|
4854
|
+
var animationClip = animations[i];
|
|
4855
|
+
var name = animationClip.name;
|
|
4856
|
+
var uniqueName = animatorStateMachine.makeUniqueStateName(name);
|
|
4857
|
+
if (uniqueName !== name) {
|
|
4858
|
+
console.warn("AnimatorState name is existed, name: " + name + " reset to " + uniqueName);
|
|
4859
|
+
}
|
|
4860
|
+
var animatorState = animatorStateMachine.addState(uniqueName);
|
|
4861
|
+
animatorState.clip = animationClip;
|
|
4862
|
+
}
|
|
4863
|
+
}
|
|
4864
|
+
return animatorController;
|
|
4865
|
+
};
|
|
4866
|
+
return GLTFAnimatorControllerParser;
|
|
4867
|
+
}(GLTFParser);
|
|
4868
|
+
exports.GLTFAnimatorControllerParser = __decorate([
|
|
4869
|
+
registerGLTFParser(exports.GLTFParserType.AnimatorController)
|
|
4870
|
+
], exports.GLTFAnimatorControllerParser);
|
|
4871
|
+
|
|
4843
4872
|
// Source: https://github.com/zeux/meshoptimizer/blob/master/js/meshopt_decoder.js
|
|
4844
4873
|
var MeshoptDecoder = function() {
|
|
4845
4874
|
var unpack = function unpack(data) {
|
|
@@ -5077,7 +5106,8 @@ exports.GLTFLoader = __decorate([
|
|
|
5077
5106
|
|
|
5078
5107
|
var _HDRLoader;
|
|
5079
5108
|
var PI = Math.PI;
|
|
5080
|
-
var HDRLoader = (_HDRLoader =
|
|
5109
|
+
var HDRLoader = (_HDRLoader = // referenece: https://www.flipcode.com/archives/HDR_Image_Reader.shtml
|
|
5110
|
+
/*#__PURE__*/ function(Loader1) {
|
|
5081
5111
|
_inherits(HDRLoader1, Loader1);
|
|
5082
5112
|
function HDRLoader1() {
|
|
5083
5113
|
return Loader1.apply(this, arguments);
|
|
@@ -5247,15 +5277,20 @@ var HDRLoader = (_HDRLoader = /*#__PURE__*/ function(Loader1) {
|
|
|
5247
5277
|
var dataRGBA = new Uint8Array(4 * width * height);
|
|
5248
5278
|
var offset = 0, pos = 0;
|
|
5249
5279
|
var ptrEnd = 4 * scanLineWidth;
|
|
5250
|
-
var rgbeStart = new Uint8Array(4);
|
|
5251
5280
|
var scanLineBuffer = new Uint8Array(ptrEnd);
|
|
5252
5281
|
var numScanLines = height; // read in each successive scanLine
|
|
5253
5282
|
while(numScanLines > 0 && pos < byteLength){
|
|
5254
|
-
|
|
5255
|
-
|
|
5256
|
-
|
|
5257
|
-
|
|
5258
|
-
if (
|
|
5283
|
+
var a = buffer[pos++];
|
|
5284
|
+
var b = buffer[pos++];
|
|
5285
|
+
var c = buffer[pos++];
|
|
5286
|
+
var d = buffer[pos++];
|
|
5287
|
+
if (a != 2 || b != 2 || c & 0x80 || width < 8 || width > 32767) {
|
|
5288
|
+
// this file is not run length encoded
|
|
5289
|
+
// read values sequentially
|
|
5290
|
+
return buffer;
|
|
5291
|
+
}
|
|
5292
|
+
if ((c << 8 | d) != scanLineWidth) {
|
|
5293
|
+
// eslint-disable-next-line no-throw-literal
|
|
5259
5294
|
throw "HDR Bad header format, wrong scan line width";
|
|
5260
5295
|
}
|
|
5261
5296
|
// read each of the four channels for the scanline into the buffer
|