@galacean/engine-loader 1.4.0-alpha.0 → 1.4.0-alpha.1
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 +122 -24
- package/dist/main.js.map +1 -1
- package/dist/module.js +123 -25
- package/dist/module.js.map +1 -1
- package/package.json +4 -4
- package/types/AudioLoader.d.ts +1 -0
- package/types/GLTFContentRestorer.d.ts +1 -2
- package/types/Texture2DContentRestorer.d.ts +1 -2
- package/types/TextureCubeContentRestorer.d.ts +1 -2
- package/types/gltf/extensions/KHR_materials_sheen.d.ts +1 -0
- package/types/index.d.ts +1 -0
package/dist/main.js
CHANGED
|
@@ -1574,32 +1574,18 @@ var EnvLoader = /*#__PURE__*/ function(Loader) {
|
|
|
1574
1574
|
var _proto = EnvLoader.prototype;
|
|
1575
1575
|
_proto.load = function load(item, resourceManager) {
|
|
1576
1576
|
return new engineCore.AssetPromise(function(resolve, reject) {
|
|
1577
|
-
|
|
1578
|
-
._request(item.url, _extends({}, item, {
|
|
1577
|
+
var requestConfig = _extends({}, item, {
|
|
1579
1578
|
type: "arraybuffer"
|
|
1580
|
-
})
|
|
1581
|
-
|
|
1582
|
-
|
|
1583
|
-
|
|
1584
|
-
var
|
|
1585
|
-
|
|
1586
|
-
var texture = new engineCore.TextureCube(engine, size);
|
|
1587
|
-
texture.filterMode = engineCore.TextureFilterMode.Trilinear;
|
|
1588
|
-
var mipmapCount = texture.mipmapCount;
|
|
1589
|
-
var offset = shByteLength + 2;
|
|
1590
|
-
for(var mipLevel = 0; mipLevel < mipmapCount; mipLevel++){
|
|
1591
|
-
var mipSize = size >> mipLevel;
|
|
1592
|
-
for(var face = 0; face < 6; face++){
|
|
1593
|
-
var dataSize = mipSize * mipSize * 4;
|
|
1594
|
-
var data = new Uint8Array(arraybuffer, offset, dataSize);
|
|
1595
|
-
offset += dataSize;
|
|
1596
|
-
texture.setPixelBuffer(engineCore.TextureCubeFace.PositiveX + face, data, mipLevel);
|
|
1597
|
-
}
|
|
1598
|
-
}
|
|
1579
|
+
});
|
|
1580
|
+
var engine = resourceManager.engine;
|
|
1581
|
+
resourceManager// @ts-ignore
|
|
1582
|
+
._request(item.url, requestConfig).then(function(arraybuffer) {
|
|
1583
|
+
var texture = EnvLoader._setTextureByBuffer(engine, arraybuffer);
|
|
1584
|
+
engine.resourceManager.addContentRestorer(new EnvContentRestorer(texture, item.url, requestConfig));
|
|
1599
1585
|
var ambientLight = new engineCore.AmbientLight(engine);
|
|
1600
1586
|
var sh = new engineMath.SphericalHarmonics3();
|
|
1601
1587
|
ambientLight.diffuseMode = engineCore.DiffuseMode.SphericalHarmonics;
|
|
1602
|
-
sh.copyFromArray(
|
|
1588
|
+
sh.copyFromArray(new Float32Array(arraybuffer, 0, 27));
|
|
1603
1589
|
ambientLight.diffuseSphericalHarmonics = sh;
|
|
1604
1590
|
ambientLight.specularTexture = texture;
|
|
1605
1591
|
ambientLight.specularTextureDecodeRGBM = true;
|
|
@@ -1609,6 +1595,27 @@ var EnvLoader = /*#__PURE__*/ function(Loader) {
|
|
|
1609
1595
|
});
|
|
1610
1596
|
});
|
|
1611
1597
|
};
|
|
1598
|
+
/**
|
|
1599
|
+
* @internal
|
|
1600
|
+
*/ EnvLoader._setTextureByBuffer = function _setTextureByBuffer(engine, buffer, texture) {
|
|
1601
|
+
var _this;
|
|
1602
|
+
var shByteLength = 27 * 4;
|
|
1603
|
+
var size = (_this = new Uint16Array(buffer, shByteLength, 1)) == null ? void 0 : _this[0];
|
|
1604
|
+
texture || (texture = new engineCore.TextureCube(engine, size));
|
|
1605
|
+
texture.filterMode = engineCore.TextureFilterMode.Trilinear;
|
|
1606
|
+
var mipmapCount = texture.mipmapCount;
|
|
1607
|
+
var offset = shByteLength + 2;
|
|
1608
|
+
for(var mipLevel = 0; mipLevel < mipmapCount; mipLevel++){
|
|
1609
|
+
var mipSize = size >> mipLevel;
|
|
1610
|
+
for(var face = 0; face < 6; face++){
|
|
1611
|
+
var dataSize = mipSize * mipSize * 4;
|
|
1612
|
+
var data = new Uint8Array(buffer, offset, dataSize);
|
|
1613
|
+
offset += dataSize;
|
|
1614
|
+
texture.setPixelBuffer(engineCore.TextureCubeFace.PositiveX + face, data, mipLevel);
|
|
1615
|
+
}
|
|
1616
|
+
}
|
|
1617
|
+
return texture;
|
|
1618
|
+
};
|
|
1612
1619
|
return EnvLoader;
|
|
1613
1620
|
}(engineCore.Loader);
|
|
1614
1621
|
EnvLoader = __decorate([
|
|
@@ -1616,6 +1623,27 @@ EnvLoader = __decorate([
|
|
|
1616
1623
|
"env"
|
|
1617
1624
|
])
|
|
1618
1625
|
], EnvLoader);
|
|
1626
|
+
/**
|
|
1627
|
+
* @internal
|
|
1628
|
+
*/ var EnvContentRestorer = /*#__PURE__*/ function(ContentRestorer) {
|
|
1629
|
+
_inherits(EnvContentRestorer, ContentRestorer);
|
|
1630
|
+
function EnvContentRestorer(resource, url, requestConfig) {
|
|
1631
|
+
var _this;
|
|
1632
|
+
_this = ContentRestorer.call(this, resource) || this, _this.url = url, _this.requestConfig = requestConfig;
|
|
1633
|
+
return _this;
|
|
1634
|
+
}
|
|
1635
|
+
var _proto = EnvContentRestorer.prototype;
|
|
1636
|
+
_proto.restoreContent = function restoreContent() {
|
|
1637
|
+
var _this = this;
|
|
1638
|
+
return new engineCore.AssetPromise(function(resolve, reject) {
|
|
1639
|
+
engineCore.request(_this.url, _this.requestConfig).then(function(buffer) {
|
|
1640
|
+
EnvLoader._setTextureByBuffer(_this.resource.engine, buffer, _this.resource);
|
|
1641
|
+
resolve(_this.resource);
|
|
1642
|
+
}).catch(reject);
|
|
1643
|
+
});
|
|
1644
|
+
};
|
|
1645
|
+
return EnvContentRestorer;
|
|
1646
|
+
}(engineCore.ContentRestorer);
|
|
1619
1647
|
|
|
1620
1648
|
function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) {
|
|
1621
1649
|
try {
|
|
@@ -2033,7 +2061,7 @@ FontLoader = __decorate([
|
|
|
2033
2061
|
task.total += 1;
|
|
2034
2062
|
taskPromise.then(function() {
|
|
2035
2063
|
_this._setTaskCompleteProgress(++task.loaded, task.total);
|
|
2036
|
-
});
|
|
2064
|
+
}, function() {});
|
|
2037
2065
|
};
|
|
2038
2066
|
_proto._handleSubAsset = function _handleSubAsset(resource, type, index) {
|
|
2039
2067
|
var _this = this;
|
|
@@ -6323,6 +6351,45 @@ TextureCubeLoader = __decorate([
|
|
|
6323
6351
|
])
|
|
6324
6352
|
], TextureCubeLoader);
|
|
6325
6353
|
|
|
6354
|
+
var AudioLoader = /*#__PURE__*/ function(Loader) {
|
|
6355
|
+
_inherits(AudioLoader, Loader);
|
|
6356
|
+
function AudioLoader() {
|
|
6357
|
+
return Loader.apply(this, arguments) || this;
|
|
6358
|
+
}
|
|
6359
|
+
var _proto = AudioLoader.prototype;
|
|
6360
|
+
_proto.load = function load(item, resourceManager) {
|
|
6361
|
+
return new engineCore.AssetPromise(function(resolve, reject) {
|
|
6362
|
+
var url = item.url;
|
|
6363
|
+
var requestConfig = _extends({}, item, {
|
|
6364
|
+
type: "arraybuffer"
|
|
6365
|
+
});
|
|
6366
|
+
// @ts-ignore
|
|
6367
|
+
resourceManager._request(url, requestConfig).then(function(arrayBuffer) {
|
|
6368
|
+
var audioClip = new engineCore.AudioClip(resourceManager.engine);
|
|
6369
|
+
engineCore.AudioManager.getContext().decodeAudioData(arrayBuffer).then(function(result) {
|
|
6370
|
+
// @ts-ignore
|
|
6371
|
+
audioClip._setAudioSource(result);
|
|
6372
|
+
if (url.indexOf("data:") !== 0) {
|
|
6373
|
+
var index = url.lastIndexOf("/");
|
|
6374
|
+
audioClip.name = url.substring(index + 1);
|
|
6375
|
+
}
|
|
6376
|
+
resolve(audioClip);
|
|
6377
|
+
}).catch(function(e) {
|
|
6378
|
+
reject(e);
|
|
6379
|
+
});
|
|
6380
|
+
});
|
|
6381
|
+
});
|
|
6382
|
+
};
|
|
6383
|
+
return AudioLoader;
|
|
6384
|
+
}(engineCore.Loader);
|
|
6385
|
+
AudioLoader = __decorate([
|
|
6386
|
+
engineCore.resourceLoader(engineCore.AssetType.Audio, [
|
|
6387
|
+
"mp3",
|
|
6388
|
+
"ogg",
|
|
6389
|
+
"wav"
|
|
6390
|
+
])
|
|
6391
|
+
], AudioLoader);
|
|
6392
|
+
|
|
6326
6393
|
var ShaderChunkLoader = /*#__PURE__*/ function(Loader) {
|
|
6327
6394
|
_inherits(ShaderChunkLoader, Loader);
|
|
6328
6395
|
function ShaderChunkLoader() {
|
|
@@ -6360,7 +6427,7 @@ var ShaderChunkLoader = /*#__PURE__*/ function(Loader) {
|
|
|
6360
6427
|
};
|
|
6361
6428
|
return ShaderChunkLoader;
|
|
6362
6429
|
}(engineCore.Loader);
|
|
6363
|
-
ShaderChunkLoader._shaderIncludeRegex =
|
|
6430
|
+
ShaderChunkLoader._shaderIncludeRegex = /#include\s+"([./][^\\"]+)"/gm;
|
|
6364
6431
|
ShaderChunkLoader = __decorate([
|
|
6365
6432
|
engineCore.resourceLoader("ShaderChunk", [
|
|
6366
6433
|
"glsl"
|
|
@@ -6698,6 +6765,37 @@ KHR_materials_pbrSpecularGlossiness = __decorate([
|
|
|
6698
6765
|
registerGLTFExtension("KHR_materials_pbrSpecularGlossiness", GLTFExtensionMode.CreateAndParse)
|
|
6699
6766
|
], KHR_materials_pbrSpecularGlossiness);
|
|
6700
6767
|
|
|
6768
|
+
var KHR_materials_sheen = /*#__PURE__*/ function(GLTFExtensionParser) {
|
|
6769
|
+
_inherits(KHR_materials_sheen, GLTFExtensionParser);
|
|
6770
|
+
function KHR_materials_sheen() {
|
|
6771
|
+
return GLTFExtensionParser.apply(this, arguments) || this;
|
|
6772
|
+
}
|
|
6773
|
+
var _proto = KHR_materials_sheen.prototype;
|
|
6774
|
+
_proto.additiveParse = function additiveParse(context, material, schema) {
|
|
6775
|
+
var sheenColorFactor = schema.sheenColorFactor, sheenColorTexture = schema.sheenColorTexture, _schema_sheenRoughnessFactor = schema.sheenRoughnessFactor, sheenRoughnessFactor = _schema_sheenRoughnessFactor === void 0 ? 0 : _schema_sheenRoughnessFactor, sheenRoughnessTexture = schema.sheenRoughnessTexture;
|
|
6776
|
+
if (sheenColorFactor) {
|
|
6777
|
+
material.sheenColor.set(engineMath.Color.linearToGammaSpace(sheenColorFactor[0]), engineMath.Color.linearToGammaSpace(sheenColorFactor[1]), engineMath.Color.linearToGammaSpace(sheenColorFactor[2]), undefined);
|
|
6778
|
+
}
|
|
6779
|
+
material.sheenRoughness = sheenRoughnessFactor;
|
|
6780
|
+
if (sheenColorTexture) {
|
|
6781
|
+
exports.GLTFMaterialParser._checkOtherTextureTransform(sheenColorTexture, "Sheen texture");
|
|
6782
|
+
context.get(GLTFParserType.Texture, sheenColorTexture.index).then(function(texture) {
|
|
6783
|
+
material.sheenColorTexture = texture;
|
|
6784
|
+
});
|
|
6785
|
+
}
|
|
6786
|
+
if (sheenRoughnessTexture) {
|
|
6787
|
+
exports.GLTFMaterialParser._checkOtherTextureTransform(sheenRoughnessTexture, "SheenRoughness texture");
|
|
6788
|
+
context.get(GLTFParserType.Texture, sheenRoughnessTexture.index).then(function(texture) {
|
|
6789
|
+
material.sheenRoughnessTexture = texture;
|
|
6790
|
+
});
|
|
6791
|
+
}
|
|
6792
|
+
};
|
|
6793
|
+
return KHR_materials_sheen;
|
|
6794
|
+
}(GLTFExtensionParser);
|
|
6795
|
+
KHR_materials_sheen = __decorate([
|
|
6796
|
+
registerGLTFExtension("KHR_materials_sheen", GLTFExtensionMode.AdditiveParse)
|
|
6797
|
+
], KHR_materials_sheen);
|
|
6798
|
+
|
|
6701
6799
|
var KHR_materials_unlit = /*#__PURE__*/ function(GLTFExtensionParser) {
|
|
6702
6800
|
_inherits(KHR_materials_unlit, GLTFExtensionParser);
|
|
6703
6801
|
function KHR_materials_unlit() {
|