@galacean/effects-plugin-spine 2.0.0-alpha.27 → 2.0.0-alpha.29

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/alipay.js CHANGED
@@ -11080,9 +11080,9 @@ var SlotGroup = /*#__PURE__*/ function() {
11080
11080
  var Vector2 = EFFECTS.math.Vector2, Vector3 = EFFECTS.math.Vector3;
11081
11081
  exports.SpineComponent = /*#__PURE__*/ function(RendererComponent) {
11082
11082
  _inherits(SpineComponent, RendererComponent);
11083
- function SpineComponent() {
11083
+ function SpineComponent(engine) {
11084
11084
  var _this;
11085
- _this = RendererComponent.apply(this, arguments) || this;
11085
+ _this = RendererComponent.call(this, engine) || this;
11086
11086
  /**
11087
11087
  * aabb 包围盒与 skeleton 原点的距离
11088
11088
  */ _this.offset = new Vector2();
@@ -11092,9 +11092,21 @@ exports.SpineComponent = /*#__PURE__*/ function(RendererComponent) {
11092
11092
  return _this;
11093
11093
  }
11094
11094
  var _proto = SpineComponent.prototype;
11095
+ // TODO 发包后修改
11096
+ // override fromData (data: spec.SpineComponent<TextureAtlas, SkeletonData>)
11095
11097
  _proto.fromData = function fromData(data) {
11096
11098
  RendererComponent.prototype.fromData.call(this, data);
11097
- var _this_resource = this.resource, textures = _this_resource.images, skeletonType = _this_resource.skeletonType, atlasOptions = _this_resource.atlas, skeletonOptions = _this_resource.skeleton;
11099
+ this.options = data.options;
11100
+ this.item.getHitTestParams = this.getHitTestParams.bind(this);
11101
+ // 兼容编辑器逻辑
11102
+ if (!this.resource || !Object.keys(this.resource).length) {
11103
+ return;
11104
+ }
11105
+ var _this_resource = this.resource, textures = _this_resource.images, skeletonType = _this_resource.skeletonType, atlasOptions = _this_resource.atlas, skeletonOptions = _this_resource.skeleton, editorResourceID = _this_resource.editorResourceID;
11106
+ // 编辑器缓存解析资源,不再解析
11107
+ if (this.cache) {
11108
+ return;
11109
+ }
11098
11110
  var _atlasOptions_source = atlasOptions.source, start = _atlasOptions_source[0], bufferLength = _atlasOptions_source[1];
11099
11111
  var atlasBuffer = bufferLength ? new Uint8Array(atlasOptions.bins.buffer, start, bufferLength) : new Uint8Array(atlasOptions.bins.buffer, start);
11100
11112
  var atlas = readAtlasData(atlasBuffer, textures);
@@ -11103,21 +11115,25 @@ exports.SpineComponent = /*#__PURE__*/ function(RendererComponent) {
11103
11115
  var skeletonBuffer = skelBufferLength ? skBuffer.slice(skelStart, skelStart + skelBufferLength) : skBuffer.slice(skelStart);
11104
11116
  var skeletonFile = getSkeletonFromBuffer(skeletonBuffer, skeletonType);
11105
11117
  var skeletonData = createSkeletonData(atlas, skeletonFile, skeletonType);
11106
- this.spineDataCache = {
11118
+ this.cache = {
11107
11119
  atlas: atlas,
11108
11120
  skeletonData: skeletonData
11109
11121
  };
11110
- this.options = data.options;
11111
- this.item.getHitTestParams = this.getHitTestParams.bind(this);
11122
+ if (editorResourceID) {
11123
+ this.cache.editorResourceID = editorResourceID;
11124
+ }
11112
11125
  };
11113
11126
  _proto.start = function start() {
11114
11127
  RendererComponent.prototype.start.call(this);
11115
- this.initContent(this.spineDataCache.atlas, this.spineDataCache.skeletonData, this.options);
11128
+ if (!this.cache) {
11129
+ return;
11130
+ }
11131
+ this.initContent(this.cache.atlas, this.cache.skeletonData, this.options);
11116
11132
  // @ts-expect-error
11117
11133
  this.startSize = this.options.startSize;
11118
11134
  // @ts-expect-error
11119
11135
  this.renderer = this.options.renderer;
11120
- if (!this.state) {
11136
+ if (!(this.state && this.skeleton)) {
11121
11137
  return;
11122
11138
  }
11123
11139
  this.state.apply(this.skeleton);
@@ -11170,8 +11186,7 @@ exports.SpineComponent = /*#__PURE__*/ function(RendererComponent) {
11170
11186
  } else {
11171
11187
  this.setAnimationList(activeAnimation, spineOptions.speed);
11172
11188
  }
11173
- this.spineDataCache = _extends({}, this.spineDataCache, {
11174
- skeletonInstance: this.skeleton,
11189
+ this.cache = _extends({}, this.cache, {
11175
11190
  skinList: this.skinList,
11176
11191
  animationList: this.animationList
11177
11192
  });
@@ -11436,15 +11451,30 @@ exports.SpineComponent = /*#__PURE__*/ function(RendererComponent) {
11436
11451
  var scale = this.transform.scale;
11437
11452
  var scaleFactor;
11438
11453
  if (this.resizeRule) {
11454
+ var camera = this.item.composition.camera;
11439
11455
  var z = this.transform.getWorldPosition().z;
11440
- var _this_item_composition_camera_getInverseVPRatio = this.item.composition.camera.getInverseVPRatio(z), rx = _this_item_composition_camera_getInverseVPRatio.x;
11441
- scaleFactor = rx / 1500;
11456
+ var _camera_getInverseVPRatio = camera.getInverseVPRatio(z), rx = _camera_getInverseVPRatio.x, ry = _camera_getInverseVPRatio.y;
11457
+ if (camera.clipMode === EFFECTS.spec.CameraClipMode.portrait) {
11458
+ scaleFactor = rx / 1500;
11459
+ } else {
11460
+ scaleFactor = ry / 3248;
11461
+ }
11442
11462
  } else {
11443
11463
  scaleFactor = 1 / width;
11444
11464
  }
11445
11465
  this.scaleFactor = scaleFactor;
11446
11466
  this.transform.setScale(this.startSize * scaleFactor, this.startSize * scaleFactor, scale.z);
11447
11467
  };
11468
+ // 转换当前大小为旧缩放规则下的大小
11469
+ _proto.convertSizeToOldRule = function convertSizeToOldRule() {
11470
+ var res = this.getBounds();
11471
+ if (!res || !this.item.composition || !this.resizeRule) {
11472
+ return 1;
11473
+ }
11474
+ var width = res.width;
11475
+ var scaleFactor = this.scaleFactor;
11476
+ return this.startSize * scaleFactor * width;
11477
+ };
11448
11478
  _proto.getBounds = function getBounds() {
11449
11479
  if (!(this.state && this.skeleton)) {
11450
11480
  return;
@@ -11463,6 +11493,9 @@ exports.SpineComponent = /*#__PURE__*/ function(RendererComponent) {
11463
11493
  __decorate([
11464
11494
  EFFECTS.serialize()
11465
11495
  ], exports.SpineComponent.prototype, "resource", void 0);
11496
+ __decorate([
11497
+ EFFECTS.serialize()
11498
+ ], exports.SpineComponent.prototype, "cache", void 0);
11466
11499
  exports.SpineComponent = __decorate([
11467
11500
  EFFECTS.effectsClass("SpineComponent")
11468
11501
  ], exports.SpineComponent);
@@ -11474,7 +11507,7 @@ EFFECTS.registerPlugin("spine", /*#__PURE__*/ function(AbstractPlugin) {
11474
11507
  }
11475
11508
  return SpineLoader;
11476
11509
  }(EFFECTS.AbstractPlugin), EFFECTS.VFXItem);
11477
- var version = "2.0.0-alpha.27";
11510
+ var version = "2.0.0-alpha.29";
11478
11511
  EFFECTS.logger.info("Plugin spine version: " + version + ".");
11479
11512
  if (version !== EFFECTS__namespace.version) {
11480
11513
  console.error("注意:请统一 Spine 插件与 Player 版本,不统一的版本混用会有不可预知的后果!", "\nAttention: Please ensure the Spine plugin is synchronized with the Player version. Mixing and matching incompatible versions may result in unpredictable consequences!");