@galacean/engine-loader 2.0.0-alpha.13 → 2.0.0-alpha.15
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 +77 -21
- package/dist/main.js.map +1 -1
- package/dist/module.js +78 -22
- package/dist/module.js.map +1 -1
- package/package.json +4 -4
- package/types/RenderTargetLoader.d.ts +1 -0
- package/types/index.d.ts +1 -0
- package/types/resource-deserialize/resources/parser/ReflectionParser.d.ts +4 -4
- package/types/resource-deserialize/resources/schema/BasicSchema.d.ts +8 -1
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, Entity, Transform, Texture2D, ReferResource, DiffuseMode, BackgroundMode, resourceLoader, AssetType, AnimatorController, AnimatorControllerLayer, AnimatorStateTransition, BufferAsset, GLCapabilityType, TextureCube, TextureCubeFace, Logger, TextureFormat, ContentRestorer, AmbientLight, TextureFilterMode, Font, SystemInfo, Animator, IndexFormat, VertexElementFormat, request, InterpolationType, SkinnedMeshRenderer, 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, ShaderFactory, ShaderLib, PhysicsMaterial, Scene, DirectLight, PointLight, SpotLight, UnlitMaterial } from '@galacean/engine-core';
|
|
1
|
+
import { Utils, AssetPromise, AnimationClip, AnimationEvent, Loader, AnimationStringCurve, Keyframe, AnimationBoolCurve, AnimationRefCurve, AnimationQuaternionCurve, AnimationColorCurve, AnimationVector4Curve, AnimationVector3Curve, AnimationVector2Curve, AnimationFloatArrayCurve, AnimationArrayCurve, AnimationFloatCurve, ModelMesh, BlendShape, Signal, Entity, Transform, Texture2D, ReferResource, DiffuseMode, BackgroundMode, resourceLoader, AssetType, AnimatorController, AnimatorControllerLayer, AnimatorStateTransition, BufferAsset, GLCapabilityType, TextureCube, TextureCubeFace, Logger, TextureFormat, ContentRestorer, AmbientLight, TextureFilterMode, Font, SystemInfo, Animator, IndexFormat, VertexElementFormat, request, InterpolationType, SkinnedMeshRenderer, 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, ShaderFactory, ShaderLib, PhysicsMaterial, RenderTarget, Scene, 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
|
|
|
@@ -780,9 +780,7 @@ var ReflectionParser = /*#__PURE__*/ function() {
|
|
|
780
780
|
for(var key in item.props)_this = this, _loop(key);
|
|
781
781
|
}
|
|
782
782
|
return Promise.all(promises).then(function() {
|
|
783
|
-
|
|
784
|
-
if (handle) return handle(instance, item);
|
|
785
|
-
else return instance;
|
|
783
|
+
return instance;
|
|
786
784
|
});
|
|
787
785
|
};
|
|
788
786
|
_proto.parseMethod = function parseMethod(instance, methodName, methodParams) {
|
|
@@ -801,6 +799,29 @@ var ReflectionParser = /*#__PURE__*/ function() {
|
|
|
801
799
|
}
|
|
802
800
|
});
|
|
803
801
|
};
|
|
802
|
+
_proto.parseSignal = function parseSignal(signalRef) {
|
|
803
|
+
var _this = this;
|
|
804
|
+
var signal = new Signal();
|
|
805
|
+
return Promise.all(signalRef.listeners.map(function(listener) {
|
|
806
|
+
return Promise.all([
|
|
807
|
+
_this.parseBasicType(listener.target),
|
|
808
|
+
listener.arguments ? Promise.all(listener.arguments.map(function(a) {
|
|
809
|
+
return _this.parseBasicType(a);
|
|
810
|
+
})) : Promise.resolve([])
|
|
811
|
+
]).then(function(param) {
|
|
812
|
+
var target = param[0], resolvedArgs = param[1];
|
|
813
|
+
if (target) {
|
|
814
|
+
var _signal;
|
|
815
|
+
(_signal = signal).on.apply(_signal, [].concat([
|
|
816
|
+
target,
|
|
817
|
+
listener.methodName
|
|
818
|
+
], resolvedArgs));
|
|
819
|
+
}
|
|
820
|
+
});
|
|
821
|
+
})).then(function() {
|
|
822
|
+
return signal;
|
|
823
|
+
});
|
|
824
|
+
};
|
|
804
825
|
_proto.parseBasicType = function parseBasicType(value, originValue) {
|
|
805
826
|
var _this = this;
|
|
806
827
|
if (Array.isArray(value)) {
|
|
@@ -830,6 +851,8 @@ var ReflectionParser = /*#__PURE__*/ function() {
|
|
|
830
851
|
} else if (ReflectionParser._isEntityRef(value)) {
|
|
831
852
|
// entity reference
|
|
832
853
|
return Promise.resolve(this._context.entityMap.get(value.entityId));
|
|
854
|
+
} else if (ReflectionParser._isSignalRef(value)) {
|
|
855
|
+
return this.parseSignal(value);
|
|
833
856
|
} else if (originValue) {
|
|
834
857
|
var _this2, _loop = function(key) {
|
|
835
858
|
if (key === "methods") {
|
|
@@ -885,9 +908,6 @@ var ReflectionParser = /*#__PURE__*/ function() {
|
|
|
885
908
|
return Promise.resolve(entity);
|
|
886
909
|
}
|
|
887
910
|
};
|
|
888
|
-
ReflectionParser.registerCustomParseComponent = function registerCustomParseComponent(componentType, handle) {
|
|
889
|
-
this.customParseComponentHandles[componentType] = handle;
|
|
890
|
-
};
|
|
891
911
|
ReflectionParser._isClass = function _isClass(value) {
|
|
892
912
|
return value["class"] !== undefined;
|
|
893
913
|
};
|
|
@@ -903,12 +923,14 @@ var ReflectionParser = /*#__PURE__*/ function() {
|
|
|
903
923
|
ReflectionParser._isComponentRef = function _isComponentRef(value) {
|
|
904
924
|
return value["ownerId"] !== undefined && value["componentId"] !== undefined;
|
|
905
925
|
};
|
|
926
|
+
ReflectionParser._isSignalRef = function _isSignalRef(value) {
|
|
927
|
+
return value["listeners"] !== undefined;
|
|
928
|
+
};
|
|
906
929
|
ReflectionParser._isMethodObject = function _isMethodObject(value) {
|
|
907
930
|
return Array.isArray(value == null ? void 0 : value.params);
|
|
908
931
|
};
|
|
909
932
|
return ReflectionParser;
|
|
910
933
|
}();
|
|
911
|
-
ReflectionParser.customParseComponentHandles = new Map();
|
|
912
934
|
|
|
913
935
|
var Texture2DDecoder = /*#__PURE__*/ function() {
|
|
914
936
|
function Texture2DDecoder() {}
|
|
@@ -6641,6 +6663,54 @@ PhysicsMaterialLoader = __decorate([
|
|
|
6641
6663
|
])
|
|
6642
6664
|
], PhysicsMaterialLoader);
|
|
6643
6665
|
|
|
6666
|
+
var RenderTargetLoader = /*#__PURE__*/ function(Loader) {
|
|
6667
|
+
_inherits(RenderTargetLoader, Loader);
|
|
6668
|
+
function RenderTargetLoader() {
|
|
6669
|
+
return Loader.apply(this, arguments) || this;
|
|
6670
|
+
}
|
|
6671
|
+
var _proto = RenderTargetLoader.prototype;
|
|
6672
|
+
_proto.load = function load(item, resourceManager) {
|
|
6673
|
+
var engine = resourceManager.engine;
|
|
6674
|
+
return resourceManager// @ts-ignore
|
|
6675
|
+
._request(item.url, _extends({}, item, {
|
|
6676
|
+
type: "json"
|
|
6677
|
+
})).then(function(data) {
|
|
6678
|
+
var width = data.width, height = data.height, colorFormats = data.colorFormats, depthFormat = data.depthFormat, antiAliasing = data.antiAliasing, autoGenerateMipmaps = data.autoGenerateMipmaps;
|
|
6679
|
+
var colorTextureProps = data.colorTextures;
|
|
6680
|
+
var colorTextures = colorFormats.map(function(format, i) {
|
|
6681
|
+
var props = colorTextureProps == null ? void 0 : colorTextureProps[i];
|
|
6682
|
+
var _props_mipmap;
|
|
6683
|
+
var mipmap = (_props_mipmap = props == null ? void 0 : props.mipmap) != null ? _props_mipmap : true;
|
|
6684
|
+
var _props_isSRGBColorSpace;
|
|
6685
|
+
var isSRGB = (_props_isSRGBColorSpace = props == null ? void 0 : props.isSRGBColorSpace) != null ? _props_isSRGBColorSpace : format === TextureFormat.R8G8B8A8;
|
|
6686
|
+
var texture = new Texture2D(engine, width, height, format, mipmap, isSRGB);
|
|
6687
|
+
if (props) {
|
|
6688
|
+
if (props.filterMode != null) texture.filterMode = props.filterMode;
|
|
6689
|
+
if (props.wrapModeU != null) texture.wrapModeU = props.wrapModeU;
|
|
6690
|
+
if (props.wrapModeV != null) texture.wrapModeV = props.wrapModeV;
|
|
6691
|
+
if (props.anisoLevel != null) texture.anisoLevel = props.anisoLevel;
|
|
6692
|
+
}
|
|
6693
|
+
return texture;
|
|
6694
|
+
});
|
|
6695
|
+
var depth = depthFormat === -1 ? null : depthFormat;
|
|
6696
|
+
var rt = new RenderTarget(engine, width, height, colorTextures, depth, antiAliasing);
|
|
6697
|
+
if (autoGenerateMipmaps != null) rt.autoGenerateMipmaps = autoGenerateMipmaps;
|
|
6698
|
+
// Notify pending sub-asset requests for colorTextures
|
|
6699
|
+
for(var i = 0, n = colorTextures.length; i < n; i++){
|
|
6700
|
+
// @ts-ignore
|
|
6701
|
+
resourceManager._onSubAssetSuccess(item.url, "colorTextures[" + i + "]", colorTextures[i]);
|
|
6702
|
+
}
|
|
6703
|
+
return rt;
|
|
6704
|
+
});
|
|
6705
|
+
};
|
|
6706
|
+
return RenderTargetLoader;
|
|
6707
|
+
}(Loader);
|
|
6708
|
+
RenderTargetLoader = __decorate([
|
|
6709
|
+
resourceLoader(AssetType.RenderTarget, [
|
|
6710
|
+
"renderTarget"
|
|
6711
|
+
])
|
|
6712
|
+
], RenderTargetLoader);
|
|
6713
|
+
|
|
6644
6714
|
var SceneLoader = /*#__PURE__*/ function(Loader) {
|
|
6645
6715
|
_inherits(SceneLoader, Loader);
|
|
6646
6716
|
function SceneLoader() {
|
|
@@ -6783,20 +6853,6 @@ SceneLoader = __decorate([
|
|
|
6783
6853
|
"scene"
|
|
6784
6854
|
], true)
|
|
6785
6855
|
], SceneLoader);
|
|
6786
|
-
ReflectionParser.registerCustomParseComponent("TextRenderer", /*#__PURE__*/ _async_to_generator(function(instance, item) {
|
|
6787
|
-
var props;
|
|
6788
|
-
return __generator(this, function(_state) {
|
|
6789
|
-
props = item.props;
|
|
6790
|
-
if (!props.font) {
|
|
6791
|
-
// @ts-ignore
|
|
6792
|
-
instance.font = Font.createFromOS(instance.engine, props.fontFamily || "Arial");
|
|
6793
|
-
}
|
|
6794
|
-
return [
|
|
6795
|
-
2,
|
|
6796
|
-
instance
|
|
6797
|
-
];
|
|
6798
|
-
});
|
|
6799
|
-
}));
|
|
6800
6856
|
|
|
6801
6857
|
var KHR_lights_punctual = /*#__PURE__*/ function(GLTFExtensionParser) {
|
|
6802
6858
|
_inherits(KHR_lights_punctual, GLTFExtensionParser);
|