@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 CHANGED
@@ -784,9 +784,7 @@ var ReflectionParser = /*#__PURE__*/ function() {
784
784
  for(var key in item.props)_this = this, _loop(key);
785
785
  }
786
786
  return Promise.all(promises).then(function() {
787
- var handle = ReflectionParser.customParseComponentHandles[instance.constructor.name];
788
- if (handle) return handle(instance, item);
789
- else return instance;
787
+ return instance;
790
788
  });
791
789
  };
792
790
  _proto.parseMethod = function parseMethod(instance, methodName, methodParams) {
@@ -805,6 +803,29 @@ var ReflectionParser = /*#__PURE__*/ function() {
805
803
  }
806
804
  });
807
805
  };
806
+ _proto.parseSignal = function parseSignal(signalRef) {
807
+ var _this = this;
808
+ var signal = new engineCore.Signal();
809
+ return Promise.all(signalRef.listeners.map(function(listener) {
810
+ return Promise.all([
811
+ _this.parseBasicType(listener.target),
812
+ listener.arguments ? Promise.all(listener.arguments.map(function(a) {
813
+ return _this.parseBasicType(a);
814
+ })) : Promise.resolve([])
815
+ ]).then(function(param) {
816
+ var target = param[0], resolvedArgs = param[1];
817
+ if (target) {
818
+ var _signal;
819
+ (_signal = signal).on.apply(_signal, [].concat([
820
+ target,
821
+ listener.methodName
822
+ ], resolvedArgs));
823
+ }
824
+ });
825
+ })).then(function() {
826
+ return signal;
827
+ });
828
+ };
808
829
  _proto.parseBasicType = function parseBasicType(value, originValue) {
809
830
  var _this = this;
810
831
  if (Array.isArray(value)) {
@@ -834,6 +855,8 @@ var ReflectionParser = /*#__PURE__*/ function() {
834
855
  } else if (ReflectionParser._isEntityRef(value)) {
835
856
  // entity reference
836
857
  return Promise.resolve(this._context.entityMap.get(value.entityId));
858
+ } else if (ReflectionParser._isSignalRef(value)) {
859
+ return this.parseSignal(value);
837
860
  } else if (originValue) {
838
861
  var _this2, _loop = function(key) {
839
862
  if (key === "methods") {
@@ -889,9 +912,6 @@ var ReflectionParser = /*#__PURE__*/ function() {
889
912
  return Promise.resolve(entity);
890
913
  }
891
914
  };
892
- ReflectionParser.registerCustomParseComponent = function registerCustomParseComponent(componentType, handle) {
893
- this.customParseComponentHandles[componentType] = handle;
894
- };
895
915
  ReflectionParser._isClass = function _isClass(value) {
896
916
  return value["class"] !== undefined;
897
917
  };
@@ -907,12 +927,14 @@ var ReflectionParser = /*#__PURE__*/ function() {
907
927
  ReflectionParser._isComponentRef = function _isComponentRef(value) {
908
928
  return value["ownerId"] !== undefined && value["componentId"] !== undefined;
909
929
  };
930
+ ReflectionParser._isSignalRef = function _isSignalRef(value) {
931
+ return value["listeners"] !== undefined;
932
+ };
910
933
  ReflectionParser._isMethodObject = function _isMethodObject(value) {
911
934
  return Array.isArray(value == null ? void 0 : value.params);
912
935
  };
913
936
  return ReflectionParser;
914
937
  }();
915
- ReflectionParser.customParseComponentHandles = new Map();
916
938
 
917
939
  exports.Texture2DDecoder = /*#__PURE__*/ function() {
918
940
  function Texture2DDecoder() {}
@@ -6645,6 +6667,54 @@ PhysicsMaterialLoader = __decorate([
6645
6667
  ])
6646
6668
  ], PhysicsMaterialLoader);
6647
6669
 
6670
+ var RenderTargetLoader = /*#__PURE__*/ function(Loader) {
6671
+ _inherits(RenderTargetLoader, Loader);
6672
+ function RenderTargetLoader() {
6673
+ return Loader.apply(this, arguments) || this;
6674
+ }
6675
+ var _proto = RenderTargetLoader.prototype;
6676
+ _proto.load = function load(item, resourceManager) {
6677
+ var engine = resourceManager.engine;
6678
+ return resourceManager// @ts-ignore
6679
+ ._request(item.url, _extends({}, item, {
6680
+ type: "json"
6681
+ })).then(function(data) {
6682
+ var width = data.width, height = data.height, colorFormats = data.colorFormats, depthFormat = data.depthFormat, antiAliasing = data.antiAliasing, autoGenerateMipmaps = data.autoGenerateMipmaps;
6683
+ var colorTextureProps = data.colorTextures;
6684
+ var colorTextures = colorFormats.map(function(format, i) {
6685
+ var props = colorTextureProps == null ? void 0 : colorTextureProps[i];
6686
+ var _props_mipmap;
6687
+ var mipmap = (_props_mipmap = props == null ? void 0 : props.mipmap) != null ? _props_mipmap : true;
6688
+ var _props_isSRGBColorSpace;
6689
+ var isSRGB = (_props_isSRGBColorSpace = props == null ? void 0 : props.isSRGBColorSpace) != null ? _props_isSRGBColorSpace : format === engineCore.TextureFormat.R8G8B8A8;
6690
+ var texture = new engineCore.Texture2D(engine, width, height, format, mipmap, isSRGB);
6691
+ if (props) {
6692
+ if (props.filterMode != null) texture.filterMode = props.filterMode;
6693
+ if (props.wrapModeU != null) texture.wrapModeU = props.wrapModeU;
6694
+ if (props.wrapModeV != null) texture.wrapModeV = props.wrapModeV;
6695
+ if (props.anisoLevel != null) texture.anisoLevel = props.anisoLevel;
6696
+ }
6697
+ return texture;
6698
+ });
6699
+ var depth = depthFormat === -1 ? null : depthFormat;
6700
+ var rt = new engineCore.RenderTarget(engine, width, height, colorTextures, depth, antiAliasing);
6701
+ if (autoGenerateMipmaps != null) rt.autoGenerateMipmaps = autoGenerateMipmaps;
6702
+ // Notify pending sub-asset requests for colorTextures
6703
+ for(var i = 0, n = colorTextures.length; i < n; i++){
6704
+ // @ts-ignore
6705
+ resourceManager._onSubAssetSuccess(item.url, "colorTextures[" + i + "]", colorTextures[i]);
6706
+ }
6707
+ return rt;
6708
+ });
6709
+ };
6710
+ return RenderTargetLoader;
6711
+ }(engineCore.Loader);
6712
+ RenderTargetLoader = __decorate([
6713
+ engineCore.resourceLoader(engineCore.AssetType.RenderTarget, [
6714
+ "renderTarget"
6715
+ ])
6716
+ ], RenderTargetLoader);
6717
+
6648
6718
  var SceneLoader = /*#__PURE__*/ function(Loader) {
6649
6719
  _inherits(SceneLoader, Loader);
6650
6720
  function SceneLoader() {
@@ -6787,20 +6857,6 @@ SceneLoader = __decorate([
6787
6857
  "scene"
6788
6858
  ], true)
6789
6859
  ], SceneLoader);
6790
- ReflectionParser.registerCustomParseComponent("TextRenderer", /*#__PURE__*/ _async_to_generator(function(instance, item) {
6791
- var props;
6792
- return __generator(this, function(_state) {
6793
- props = item.props;
6794
- if (!props.font) {
6795
- // @ts-ignore
6796
- instance.font = engineCore.Font.createFromOS(instance.engine, props.fontFamily || "Arial");
6797
- }
6798
- return [
6799
- 2,
6800
- instance
6801
- ];
6802
- });
6803
- }));
6804
6860
 
6805
6861
  var KHR_lights_punctual = /*#__PURE__*/ function(GLTFExtensionParser) {
6806
6862
  _inherits(KHR_lights_punctual, GLTFExtensionParser);