@galacean/engine-loader 1.3.1 → 1.3.3
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 +87 -49
- package/dist/main.js.map +1 -1
- package/dist/miniprogram.js +87 -49
- package/dist/module.js +87 -49
- package/dist/module.js.map +1 -1
- package/package.json +4 -4
- package/types/gltf/GLTFSchema.d.ts +1 -1
- package/types/gltf/extensions/EXT_texture_webp.d.ts +1 -0
- package/types/gltf/extensions/index.d.ts +1 -0
- package/types/gltf/parser/GLTFTextureParser.d.ts +4 -2
package/dist/main.js
CHANGED
|
@@ -4749,57 +4749,18 @@ exports.GLTFSkinParser = __decorate([
|
|
|
4749
4749
|
|
|
4750
4750
|
var _GLTFTextureParser;
|
|
4751
4751
|
exports.GLTFTextureParser = (_GLTFTextureParser = /*#__PURE__*/ function(GLTFParser1) {
|
|
4752
|
-
_inherits(
|
|
4753
|
-
function
|
|
4752
|
+
_inherits(GLTFTextureParser1, GLTFParser1);
|
|
4753
|
+
function GLTFTextureParser1() {
|
|
4754
4754
|
return GLTFParser1.apply(this, arguments);
|
|
4755
4755
|
}
|
|
4756
|
-
var _proto =
|
|
4757
|
-
_proto.parse = function parse(context,
|
|
4758
|
-
var textureInfo = context.glTF.textures[
|
|
4759
|
-
var glTFResource = context.glTFResource
|
|
4760
|
-
var
|
|
4761
|
-
var
|
|
4762
|
-
var _glTF_images_source = glTF.images[source], uri = _glTF_images_source.uri, bufferViewIndex = _glTF_images_source.bufferView, mimeType = _glTF_images_source.mimeType, imageName = _glTF_images_source.name;
|
|
4763
|
-
var texture = GLTFParser.executeExtensionsCreateAndParse(extensions, context, textureInfo);
|
|
4756
|
+
var _proto = GLTFTextureParser1.prototype;
|
|
4757
|
+
_proto.parse = function parse(context, textureIndex) {
|
|
4758
|
+
var textureInfo = context.glTF.textures[textureIndex];
|
|
4759
|
+
var glTFResource = context.glTFResource;
|
|
4760
|
+
var sampler = textureInfo.sampler, tmp = textureInfo.source, imageIndex = tmp === void 0 ? 0 : tmp, textureName = textureInfo.name, extensions = textureInfo.extensions;
|
|
4761
|
+
var texture = GLTFParser.executeExtensionsCreateAndParse(extensions, context, textureInfo, textureIndex);
|
|
4764
4762
|
if (!texture) {
|
|
4765
|
-
|
|
4766
|
-
var samplerInfo = sampler !== undefined && GLTFUtils.getSamplerInfo(glTF.samplers[sampler]);
|
|
4767
|
-
if (uri) {
|
|
4768
|
-
var _samplerInfo;
|
|
4769
|
-
// TODO: deleted in 2.0
|
|
4770
|
-
var extIndex = uri.lastIndexOf(".");
|
|
4771
|
-
var ext = uri.substring(extIndex + 1);
|
|
4772
|
-
var type = ext.startsWith("ktx") ? engineCore.AssetType.KTX : engineCore.AssetType.Texture2D;
|
|
4773
|
-
texture = engine.resourceManager.load({
|
|
4774
|
-
url: engineCore.Utils.resolveAbsoluteUrl(url, uri),
|
|
4775
|
-
type: type,
|
|
4776
|
-
params: {
|
|
4777
|
-
mipmap: (_samplerInfo = samplerInfo) == null ? void 0 : _samplerInfo.mipmap
|
|
4778
|
-
}
|
|
4779
|
-
}).onProgress(undefined, context._onTaskDetail).then(function(texture) {
|
|
4780
|
-
texture.name = textureName || imageName || texture.name || "texture_" + index;
|
|
4781
|
-
useSampler && GLTFUtils.parseSampler(texture, samplerInfo);
|
|
4782
|
-
return texture;
|
|
4783
|
-
});
|
|
4784
|
-
context._addTaskCompletePromise(texture);
|
|
4785
|
-
} else {
|
|
4786
|
-
var bufferView = glTF.bufferViews[bufferViewIndex];
|
|
4787
|
-
texture = context.get(exports.GLTFParserType.Buffer).then(function(buffers) {
|
|
4788
|
-
var buffer = buffers[bufferView.buffer];
|
|
4789
|
-
var imageBuffer = new Uint8Array(buffer, bufferView.byteOffset, bufferView.byteLength);
|
|
4790
|
-
return GLTFUtils.loadImageBuffer(imageBuffer, mimeType).then(function(image) {
|
|
4791
|
-
var _samplerInfo;
|
|
4792
|
-
var texture = new engineCore.Texture2D(engine, image.width, image.height, undefined, (_samplerInfo = samplerInfo) == null ? void 0 : _samplerInfo.mipmap);
|
|
4793
|
-
texture.setImageSource(image);
|
|
4794
|
-
texture.generateMipmaps();
|
|
4795
|
-
texture.name = textureName || imageName || "texture_" + index;
|
|
4796
|
-
useSampler && GLTFUtils.parseSampler(texture, samplerInfo);
|
|
4797
|
-
var bufferTextureRestoreInfo = new BufferTextureRestoreInfo(texture, bufferView, mimeType);
|
|
4798
|
-
context.contentRestorer.bufferTextures.push(bufferTextureRestoreInfo);
|
|
4799
|
-
return texture;
|
|
4800
|
-
});
|
|
4801
|
-
});
|
|
4802
|
-
}
|
|
4763
|
+
texture = exports.GLTFTextureParser._parseTexture(context, imageIndex, textureIndex, sampler, textureName);
|
|
4803
4764
|
}
|
|
4804
4765
|
return Promise.resolve(texture).then(function(texture) {
|
|
4805
4766
|
GLTFParser.executeExtensionsAdditiveAndParse(extensions, context, texture, textureInfo);
|
|
@@ -4808,7 +4769,51 @@ exports.GLTFTextureParser = (_GLTFTextureParser = /*#__PURE__*/ function(GLTFPar
|
|
|
4808
4769
|
return texture;
|
|
4809
4770
|
});
|
|
4810
4771
|
};
|
|
4811
|
-
|
|
4772
|
+
/** @internal */ GLTFTextureParser1._parseTexture = function _parseTexture(context, imageIndex, textureIndex, sampler, textureName) {
|
|
4773
|
+
var glTFResource = context.glTFResource, glTF = context.glTF;
|
|
4774
|
+
var engine = glTFResource.engine, url = glTFResource.url;
|
|
4775
|
+
var _glTF_images_imageIndex = glTF.images[imageIndex], uri = _glTF_images_imageIndex.uri, bufferViewIndex = _glTF_images_imageIndex.bufferView, mimeType = _glTF_images_imageIndex.mimeType, imageName = _glTF_images_imageIndex.name;
|
|
4776
|
+
var useSampler = sampler !== undefined;
|
|
4777
|
+
var samplerInfo = useSampler && GLTFUtils.getSamplerInfo(glTF.samplers[sampler]);
|
|
4778
|
+
var texture;
|
|
4779
|
+
if (uri) {
|
|
4780
|
+
var _samplerInfo;
|
|
4781
|
+
var extIndex = uri.lastIndexOf(".");
|
|
4782
|
+
var ext = uri.substring(extIndex + 1);
|
|
4783
|
+
var type = ext.startsWith("ktx") ? engineCore.AssetType.KTX : engineCore.AssetType.Texture2D;
|
|
4784
|
+
texture = engine.resourceManager.load({
|
|
4785
|
+
url: engineCore.Utils.resolveAbsoluteUrl(url, uri),
|
|
4786
|
+
type: type,
|
|
4787
|
+
params: {
|
|
4788
|
+
mipmap: (_samplerInfo = samplerInfo) == null ? void 0 : _samplerInfo.mipmap
|
|
4789
|
+
}
|
|
4790
|
+
}).onProgress(undefined, context._onTaskDetail).then(function(texture) {
|
|
4791
|
+
texture.name = textureName || imageName || texture.name || "texture_" + textureIndex;
|
|
4792
|
+
useSampler && GLTFUtils.parseSampler(texture, samplerInfo);
|
|
4793
|
+
return texture;
|
|
4794
|
+
});
|
|
4795
|
+
context._addTaskCompletePromise(texture);
|
|
4796
|
+
} else {
|
|
4797
|
+
var bufferView = glTF.bufferViews[bufferViewIndex];
|
|
4798
|
+
texture = context.get(exports.GLTFParserType.Buffer).then(function(buffers) {
|
|
4799
|
+
var buffer = buffers[bufferView.buffer];
|
|
4800
|
+
var imageBuffer = new Uint8Array(buffer, bufferView.byteOffset, bufferView.byteLength);
|
|
4801
|
+
return GLTFUtils.loadImageBuffer(imageBuffer, mimeType).then(function(image) {
|
|
4802
|
+
var _samplerInfo;
|
|
4803
|
+
var texture = new engineCore.Texture2D(engine, image.width, image.height, undefined, (_samplerInfo = samplerInfo) == null ? void 0 : _samplerInfo.mipmap);
|
|
4804
|
+
texture.setImageSource(image);
|
|
4805
|
+
texture.generateMipmaps();
|
|
4806
|
+
texture.name = textureName || imageName || "texture_" + textureIndex;
|
|
4807
|
+
useSampler && GLTFUtils.parseSampler(texture, samplerInfo);
|
|
4808
|
+
var bufferTextureRestoreInfo = new BufferTextureRestoreInfo(texture, bufferView, mimeType);
|
|
4809
|
+
context.contentRestorer.bufferTextures.push(bufferTextureRestoreInfo);
|
|
4810
|
+
return texture;
|
|
4811
|
+
});
|
|
4812
|
+
});
|
|
4813
|
+
}
|
|
4814
|
+
return texture;
|
|
4815
|
+
};
|
|
4816
|
+
return GLTFTextureParser1;
|
|
4812
4817
|
}(GLTFParser), function() {
|
|
4813
4818
|
var _obj;
|
|
4814
4819
|
/** @internal */ _GLTFTextureParser._wrapMap = (_obj = {}, _obj[TextureWrapMode.CLAMP_TO_EDGE] = engineCore.TextureWrapMode.Clamp, _obj[TextureWrapMode.MIRRORED_REPEAT] = engineCore.TextureWrapMode.Mirror, _obj[TextureWrapMode.REPEAT] = engineCore.TextureWrapMode.Repeat, _obj);
|
|
@@ -6874,6 +6879,39 @@ KHR_materials_anisotropy = __decorate([
|
|
|
6874
6879
|
registerGLTFExtension("KHR_materials_anisotropy", exports.GLTFExtensionMode.AdditiveParse)
|
|
6875
6880
|
], KHR_materials_anisotropy);
|
|
6876
6881
|
|
|
6882
|
+
var EXT_texture_webp = /*#__PURE__*/ function(GLTFExtensionParser1) {
|
|
6883
|
+
_inherits(EXT_texture_webp, GLTFExtensionParser1);
|
|
6884
|
+
function EXT_texture_webp() {
|
|
6885
|
+
var _this;
|
|
6886
|
+
_this = GLTFExtensionParser1.call(this) || this;
|
|
6887
|
+
_this._supportWebP = false;
|
|
6888
|
+
var testCanvas = document.createElement("canvas");
|
|
6889
|
+
testCanvas.width = testCanvas.height = 1;
|
|
6890
|
+
_this._supportWebP = testCanvas.toDataURL("image/webp").indexOf("data:image/webp") == 0;
|
|
6891
|
+
return _this;
|
|
6892
|
+
}
|
|
6893
|
+
var _proto = EXT_texture_webp.prototype;
|
|
6894
|
+
_proto.createAndParse = function createAndParse(context, schema, textureInfo, textureIndex) {
|
|
6895
|
+
var _this = this;
|
|
6896
|
+
return _async_to_generator(function() {
|
|
6897
|
+
var webPIndex, sampler, tmp, fallbackIndex, textureName, texture;
|
|
6898
|
+
return __generator(this, function(_state) {
|
|
6899
|
+
webPIndex = schema.source;
|
|
6900
|
+
sampler = textureInfo.sampler, tmp = textureInfo.source, fallbackIndex = tmp === void 0 ? 0 : tmp, textureName = textureInfo.name;
|
|
6901
|
+
texture = exports.GLTFTextureParser._parseTexture(context, _this._supportWebP ? webPIndex : fallbackIndex, textureIndex, sampler, textureName);
|
|
6902
|
+
return [
|
|
6903
|
+
2,
|
|
6904
|
+
texture
|
|
6905
|
+
];
|
|
6906
|
+
});
|
|
6907
|
+
})();
|
|
6908
|
+
};
|
|
6909
|
+
return EXT_texture_webp;
|
|
6910
|
+
}(GLTFExtensionParser);
|
|
6911
|
+
EXT_texture_webp = __decorate([
|
|
6912
|
+
registerGLTFExtension("EXT_texture_webp", exports.GLTFExtensionMode.CreateAndParse)
|
|
6913
|
+
], EXT_texture_webp);
|
|
6914
|
+
|
|
6877
6915
|
exports.BufferInfo = BufferInfo;
|
|
6878
6916
|
exports.BufferReader = BufferReader;
|
|
6879
6917
|
exports.FileHeader = FileHeader;
|