@galacean/engine-loader 2.0.0-alpha.30 → 2.0.0-alpha.32
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 +37 -78
- package/dist/main.js.map +1 -1
- package/dist/module.js +38 -79
- package/dist/module.js.map +1 -1
- package/package.json +4 -4
- package/types/index.d.ts +0 -1
- package/types/resource-deserialize/resources/parser/HierarchyParser.d.ts +1 -1
- package/types/resource-deserialize/resources/parser/ReflectionParser.d.ts +9 -5
- package/types/schema/CommonSchema.d.ts +4 -0
- package/types/schema/MaterialSchema.d.ts +0 -43
- package/types/schema/SceneSchema.d.ts +3 -3
- package/types/ShaderChunkLoader.d.ts +0 -9
package/dist/module.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { Utils, AssetPromise, AnimationClip, AnimationEvent, Loader, AnimationStringCurve, Keyframe, AnimationBoolCurve, AnimationRefCurve, AnimationQuaternionCurve, AnimationColorCurve, AnimationVector4Curve, AnimationVector3Curve, AnimationVector2Curve, AnimationFloatArrayCurve, AnimationArrayCurve, AnimationFloatCurve, ModelMesh, BlendShape, TextureFormat, Texture2D, TextureCube, TextureCubeFace, ReferResource, Entity, resourceLoader, AssetType, AnimatorController, AnimatorControllerLayer, AnimatorStateTransition, BufferAsset, GLCapabilityType, Logger, ContentRestorer, AmbientLight, DiffuseMode, TextureFilterMode, Font, SystemInfo, Animator, IndexFormat, VertexElementFormat, request, InterpolationType, SkinnedMeshRenderer, Transform, PBRMaterial, TextureCoordinate, RenderFace, VertexElement, Buffer, BufferBindFlag, BufferUsage, Camera, MeshRenderer, Skin, TextureWrapMode as TextureWrapMode$1, TextureUtils, AnimatorStateMachine, JSONAsset, Shader, Material, PrimitiveMesh, SpriteAtlas, Sprite, TextAsset, AudioClip, AudioManager,
|
|
1
|
+
import { Utils, AssetPromise, AnimationClip, AnimationEvent, Loader, AnimationStringCurve, Keyframe, AnimationBoolCurve, AnimationRefCurve, AnimationQuaternionCurve, AnimationColorCurve, AnimationVector4Curve, AnimationVector3Curve, AnimationVector2Curve, AnimationFloatArrayCurve, AnimationArrayCurve, AnimationFloatCurve, ModelMesh, BlendShape, TextureFormat, Texture2D, TextureCube, TextureCubeFace, ReferResource, Entity, resourceLoader, AssetType, AnimatorController, AnimatorControllerLayer, AnimatorStateTransition, BufferAsset, GLCapabilityType, Logger, ContentRestorer, AmbientLight, DiffuseMode, TextureFilterMode, Font, SystemInfo, Animator, IndexFormat, VertexElementFormat, request, InterpolationType, SkinnedMeshRenderer, Transform, PBRMaterial, TextureCoordinate, RenderFace, VertexElement, Buffer, BufferBindFlag, BufferUsage, Camera, MeshRenderer, Skin, TextureWrapMode as TextureWrapMode$1, TextureUtils, AnimatorStateMachine, JSONAsset, Shader, Material, PrimitiveMesh, SpriteAtlas, Sprite, TextAsset, AudioClip, AudioManager, PhysicsMaterial, RenderTarget, Scene, BackgroundMode, DirectLight, PointLight, SpotLight, UnlitMaterial } from '@galacean/engine-core';
|
|
2
2
|
import { Quaternion, Vector4, Color, Vector3, Vector2, MathUtil, SphericalHarmonics3, BoundingBox, Matrix, Rect } from '@galacean/engine-math';
|
|
3
3
|
import { GLCompressedTextureInternalFormat } from '@galacean/engine-rhi-webgl';
|
|
4
4
|
|
|
@@ -705,7 +705,7 @@ var ReflectionParser = /*#__PURE__*/ function() {
|
|
|
705
705
|
var _proto = ReflectionParser.prototype;
|
|
706
706
|
/**
|
|
707
707
|
* Apply v2 props to a component/object instance.
|
|
708
|
-
* Each prop value is resolved recursively (handling $ref, $type, $entity, $component, $signal).
|
|
708
|
+
* Each prop value is resolved recursively (handling $ref, $type, $class, $entity, $component, $signal).
|
|
709
709
|
*/ _proto.parseProps = function parseProps(instance, props) {
|
|
710
710
|
var promises = [];
|
|
711
711
|
if (props) {
|
|
@@ -773,10 +773,11 @@ var ReflectionParser = /*#__PURE__*/ function() {
|
|
|
773
773
|
* 2. Array → recurse each element
|
|
774
774
|
* 3. { $ref } → asset reference
|
|
775
775
|
* 4. { $type } → polymorphic type construct
|
|
776
|
-
* 5. { $
|
|
777
|
-
* 6. { $
|
|
778
|
-
* 7. { $
|
|
779
|
-
* 8.
|
|
776
|
+
* 5. { $class } → registered class constructor
|
|
777
|
+
* 6. { $entity } → entity reference by path (flat index + optional children descent)
|
|
778
|
+
* 7. { $component } → component reference
|
|
779
|
+
* 8. { $signal } → signal binding
|
|
780
|
+
* 9. plain object → recurse values (modify originValue in place if exists)
|
|
780
781
|
*/ _proto._resolveValue = function _resolveValue(value, originValue) {
|
|
781
782
|
var _this, _loop = function(key) {
|
|
782
783
|
promises.push(_this._resolveValue(obj[key], target[key]).then(function(v) {
|
|
@@ -812,14 +813,14 @@ var ReflectionParser = /*#__PURE__*/ function() {
|
|
|
812
813
|
var $type = obj.$type, rest = _object_without_properties_loose(obj, [
|
|
813
814
|
"$type"
|
|
814
815
|
]);
|
|
815
|
-
|
|
816
|
-
|
|
817
|
-
|
|
818
|
-
|
|
819
|
-
|
|
820
|
-
|
|
821
|
-
|
|
822
|
-
return
|
|
816
|
+
return this._resolveRegisteredClass($type, "$type").then(function(Class) {
|
|
817
|
+
var instance = new Class();
|
|
818
|
+
return Object.keys(rest).length > 0 ? _this1.parseProps(instance, rest) : instance;
|
|
819
|
+
});
|
|
820
|
+
}
|
|
821
|
+
// $class — registered class constructor for factory-style methods.
|
|
822
|
+
if ("$class" in obj) {
|
|
823
|
+
return this._resolveRegisteredClass(obj.$class, "$class");
|
|
823
824
|
}
|
|
824
825
|
// $entity — entity reference by path (first element = flat index, subsequent = children indices)
|
|
825
826
|
if ("$entity" in obj) {
|
|
@@ -841,6 +842,21 @@ var ReflectionParser = /*#__PURE__*/ function() {
|
|
|
841
842
|
return target;
|
|
842
843
|
});
|
|
843
844
|
};
|
|
845
|
+
_proto._getRegisteredClass = function _getRegisteredClass(value, sentinel) {
|
|
846
|
+
if (typeof value !== "string" || value.length === 0) {
|
|
847
|
+
throw new Error("" + sentinel + " must be a non-empty registered class name string");
|
|
848
|
+
}
|
|
849
|
+
var Class = Loader.getClass(value);
|
|
850
|
+
if (!Class) throw new Error('Loader.getClass: class "' + value + '" is not registered');
|
|
851
|
+
return Class;
|
|
852
|
+
};
|
|
853
|
+
/** Promise-adapt {@link _getRegisteredClass} so $type/$class branches can fold into the resolver chain. */ _proto._resolveRegisteredClass = function _resolveRegisteredClass(value, sentinel) {
|
|
854
|
+
try {
|
|
855
|
+
return Promise.resolve(this._getRegisteredClass(value, sentinel));
|
|
856
|
+
} catch (error) {
|
|
857
|
+
return Promise.reject(error);
|
|
858
|
+
}
|
|
859
|
+
};
|
|
844
860
|
_proto._resolveSignal = function _resolveSignal(signal, listeners) {
|
|
845
861
|
var _this = this;
|
|
846
862
|
if (!signal || typeof signal.on !== "function") {
|
|
@@ -1514,7 +1530,7 @@ function _instanceof(left, right) {
|
|
|
1514
1530
|
}
|
|
1515
1531
|
};
|
|
1516
1532
|
_proto._getRootIndices = function _getRootIndices() {
|
|
1517
|
-
return this.data.scene.
|
|
1533
|
+
return this.data.scene.rootEntities;
|
|
1518
1534
|
};
|
|
1519
1535
|
_proto._handleRootEntity = function _handleRootEntity(index) {
|
|
1520
1536
|
this.scene.addRootEntity(this.context.entityInstances[index]);
|
|
@@ -1527,8 +1543,8 @@ function _instanceof(left, right) {
|
|
|
1527
1543
|
}(HierarchyParser);
|
|
1528
1544
|
|
|
1529
1545
|
var SpecularMode = /*#__PURE__*/ function(SpecularMode) {
|
|
1530
|
-
SpecularMode["Sky"] = "Sky";
|
|
1531
|
-
SpecularMode["Custom"] = "Custom";
|
|
1546
|
+
SpecularMode[SpecularMode["Sky"] = 0] = "Sky";
|
|
1547
|
+
SpecularMode[SpecularMode["Custom"] = 1] = "Custom";
|
|
1532
1548
|
return SpecularMode;
|
|
1533
1549
|
}({});
|
|
1534
1550
|
|
|
@@ -5694,15 +5710,6 @@ var KTXContentRestorer = /*#__PURE__*/ function(ContentRestorer) {
|
|
|
5694
5710
|
return KTXContentRestorer;
|
|
5695
5711
|
}(ContentRestorer);
|
|
5696
5712
|
|
|
5697
|
-
function parseProperty(object, key, value) {
|
|
5698
|
-
if ((typeof value === "undefined" ? "undefined" : _type_of(value)) === "object") {
|
|
5699
|
-
for(var subKey in value){
|
|
5700
|
-
parseProperty(object[key], subKey, value[subKey]);
|
|
5701
|
-
}
|
|
5702
|
-
} else {
|
|
5703
|
-
object[key] = value;
|
|
5704
|
-
}
|
|
5705
|
-
}
|
|
5706
5713
|
var MaterialLoader = /*#__PURE__*/ function(Loader) {
|
|
5707
5714
|
_inherits(MaterialLoader, Loader);
|
|
5708
5715
|
function MaterialLoader() {
|
|
@@ -5763,7 +5770,7 @@ var MaterialLoader = /*#__PURE__*/ function(Loader) {
|
|
|
5763
5770
|
break;
|
|
5764
5771
|
}
|
|
5765
5772
|
};
|
|
5766
|
-
var name = materialSchema.name, shaderData = materialSchema.shaderData, macros = materialSchema.macros
|
|
5773
|
+
var name = materialSchema.name, shaderData = materialSchema.shaderData, macros = materialSchema.macros;
|
|
5767
5774
|
var material = new Material(engine, shader);
|
|
5768
5775
|
material.name = name;
|
|
5769
5776
|
var texturePromises = new Array();
|
|
@@ -5777,7 +5784,6 @@ var MaterialLoader = /*#__PURE__*/ function(Loader) {
|
|
|
5777
5784
|
materialShaderData.enableMacro(name1, value);
|
|
5778
5785
|
}
|
|
5779
5786
|
}
|
|
5780
|
-
parseProperty(material, "renderState", renderState);
|
|
5781
5787
|
return Promise.all(texturePromises).then(function() {
|
|
5782
5788
|
return material;
|
|
5783
5789
|
});
|
|
@@ -6319,51 +6325,6 @@ AudioLoader = __decorate([
|
|
|
6319
6325
|
])
|
|
6320
6326
|
], AudioLoader);
|
|
6321
6327
|
|
|
6322
|
-
var ShaderChunkLoader = /*#__PURE__*/ function(Loader) {
|
|
6323
|
-
_inherits(ShaderChunkLoader, Loader);
|
|
6324
|
-
function ShaderChunkLoader() {
|
|
6325
|
-
return Loader.apply(this, arguments) || this;
|
|
6326
|
-
}
|
|
6327
|
-
var _proto = ShaderChunkLoader.prototype;
|
|
6328
|
-
_proto.load = function load(item, resourceManager) {
|
|
6329
|
-
var url = item.url;
|
|
6330
|
-
// @ts-ignore
|
|
6331
|
-
return resourceManager._request(url, _extends({}, item, {
|
|
6332
|
-
type: "text"
|
|
6333
|
-
})).then(function(code) {
|
|
6334
|
-
ShaderFactory.registerInclude(url.substring(1), code);
|
|
6335
|
-
return ShaderChunkLoader._loadChunksInCode(code, url, resourceManager);
|
|
6336
|
-
});
|
|
6337
|
-
};
|
|
6338
|
-
/**
|
|
6339
|
-
* @internal
|
|
6340
|
-
*/ ShaderChunkLoader._loadChunksInCode = function _loadChunksInCode(code, basePath, resourceManager) {
|
|
6341
|
-
var shaderChunkPaths = new Array();
|
|
6342
|
-
var matches = code.matchAll(ShaderChunkLoader._shaderIncludeRegex);
|
|
6343
|
-
for(var _iterator = _create_for_of_iterator_helper_loose(matches), _step; !(_step = _iterator()).done;){
|
|
6344
|
-
var match = _step.value;
|
|
6345
|
-
var chunkPath = Utils.resolveAbsoluteUrl(basePath, match[1]);
|
|
6346
|
-
if (!ShaderLib[chunkPath.substring(1)]) {
|
|
6347
|
-
shaderChunkPaths.push(chunkPath);
|
|
6348
|
-
}
|
|
6349
|
-
}
|
|
6350
|
-
return Promise.all(shaderChunkPaths.map(function(chunkPath) {
|
|
6351
|
-
// @ts-ignore
|
|
6352
|
-
return resourceManager.load({
|
|
6353
|
-
type: "ShaderChunk",
|
|
6354
|
-
url: chunkPath
|
|
6355
|
-
});
|
|
6356
|
-
}));
|
|
6357
|
-
};
|
|
6358
|
-
return ShaderChunkLoader;
|
|
6359
|
-
}(Loader);
|
|
6360
|
-
ShaderChunkLoader._shaderIncludeRegex = /#include\s+"([./][^\\"]+)"/gm;
|
|
6361
|
-
ShaderChunkLoader = __decorate([
|
|
6362
|
-
resourceLoader("ShaderChunk", [
|
|
6363
|
-
"glsl"
|
|
6364
|
-
])
|
|
6365
|
-
], ShaderChunkLoader);
|
|
6366
|
-
|
|
6367
6328
|
var ShaderLoader = /*#__PURE__*/ function(Loader) {
|
|
6368
6329
|
_inherits(ShaderLoader, Loader);
|
|
6369
6330
|
function ShaderLoader() {
|
|
@@ -6373,7 +6334,7 @@ var ShaderLoader = /*#__PURE__*/ function(Loader) {
|
|
|
6373
6334
|
_proto.load = function load(item, resourceManager) {
|
|
6374
6335
|
var _this = this;
|
|
6375
6336
|
var url = item.url;
|
|
6376
|
-
if (url.endsWith(".
|
|
6337
|
+
if (url.endsWith(".shaderc")) {
|
|
6377
6338
|
// @ts-ignore
|
|
6378
6339
|
return resourceManager._request(url, _extends({}, item, {
|
|
6379
6340
|
type: "json"
|
|
@@ -6390,10 +6351,7 @@ var ShaderLoader = /*#__PURE__*/ function(Loader) {
|
|
|
6390
6351
|
if (builtinShader) {
|
|
6391
6352
|
return Shader.find(builtinShader);
|
|
6392
6353
|
}
|
|
6393
|
-
return
|
|
6394
|
-
var shader = Shader.create(code, undefined, url);
|
|
6395
|
-
return shader;
|
|
6396
|
-
});
|
|
6354
|
+
return Shader.create(code, undefined, url);
|
|
6397
6355
|
});
|
|
6398
6356
|
};
|
|
6399
6357
|
_proto._getBuiltinShader = function _getBuiltinShader(code) {
|
|
@@ -6405,7 +6363,8 @@ var ShaderLoader = /*#__PURE__*/ function(Loader) {
|
|
|
6405
6363
|
ShaderLoader._builtinRegex = /^\s*\/\/\s*@builtin\s+(\w+)/;
|
|
6406
6364
|
ShaderLoader = __decorate([
|
|
6407
6365
|
resourceLoader(AssetType.Shader, [
|
|
6408
|
-
"shader"
|
|
6366
|
+
"shader",
|
|
6367
|
+
"shaderc"
|
|
6409
6368
|
])
|
|
6410
6369
|
], ShaderLoader);
|
|
6411
6370
|
|