@galacean/effects 1.2.1 → 1.2.3

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/player.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- import type { Disposable, JSONValue, LostHandler, RestoreHandler, SceneLoadOptions, Scene, math, GPUCapability } from '@galacean/effects-core';
1
+ import type { Disposable, LostHandler, RestoreHandler, SceneLoadOptions, SceneType, math, GPUCapability } from '@galacean/effects-core';
2
2
  import { Ticker, Composition, Renderer } from '@galacean/effects-core';
3
3
  /**
4
4
  * `onItemClicked` 点击回调函数的传入参数
@@ -119,7 +119,6 @@ export interface PlayerConfig {
119
119
  reportGPUTime?: (time: number) => void;
120
120
  [key: string]: any;
121
121
  }
122
- export type SceneType = string | JSONValue | Scene;
123
122
  export type SceneWithOptionsType = {
124
123
  scene: SceneType;
125
124
  options: SceneLoadOptions;
package/dist/weapp.js CHANGED
@@ -19966,9 +19966,10 @@ var TextItem = /** @class */ (function (_super) {
19966
19966
  if (this.textStyle.fontSize === value) {
19967
19967
  return;
19968
19968
  }
19969
+ // 保证字号变化后位置正常
19970
+ var diff = this.textStyle.fontSize - value;
19971
+ this.textLayout.lineHeight += diff;
19969
19972
  this.textStyle.fontSize = value;
19970
- // 1.5175 = 31.43 / 20
19971
- this.textLayout.lineHeight = this.textStyle.fontSize * 1.5175;
19972
19973
  this.isDirty = true;
19973
19974
  };
19974
19975
  /**
@@ -23463,6 +23464,26 @@ var AssetManager = /** @class */ (function () {
23463
23464
  var _a = options.timeout, timeout = _a === void 0 ? 10 : _a;
23464
23465
  this.timeout = timeout;
23465
23466
  };
23467
+ /**
23468
+ * 根据用户传入的参数修改场景数据
23469
+ */
23470
+ AssetManager.prototype.updateSceneData = function (compositions) {
23471
+ var variables = this.options.variables;
23472
+ if (!variables || Object.keys(variables).length <= 0) {
23473
+ return compositions;
23474
+ }
23475
+ compositions.forEach(function (composition) {
23476
+ composition.items.forEach(function (item) {
23477
+ if (item.type === ItemType$1.text) {
23478
+ var textVariable = variables[item.name];
23479
+ if (textVariable) {
23480
+ item.content.options.text = textVariable;
23481
+ }
23482
+ }
23483
+ });
23484
+ });
23485
+ return compositions;
23486
+ };
23466
23487
  /**
23467
23488
  * 场景创建,通过 json 创建出场景对象,并进行提前编译等工作
23468
23489
  * @param url - json 的 URL 链接或者 json 对象
@@ -23554,6 +23575,7 @@ var AssetManager = /** @class */ (function () {
23554
23575
  for (i = 0; i < scene.images.length; i++) {
23555
23576
  scene.textureOptions[i].image = scene.images[i];
23556
23577
  }
23578
+ scene.jsonScene.compositions = this.updateSceneData(scene.jsonScene.compositions);
23557
23579
  _e.label = 5;
23558
23580
  case 5: return [3 /*break*/, 12];
23559
23581
  case 6: return [4 /*yield*/, hookTimeInfo('processJSON', function () { return _this.processJSON(rawJSON); })];
@@ -23573,6 +23595,7 @@ var AssetManager = /** @class */ (function () {
23573
23595
  return [4 /*yield*/, hookTimeInfo('processTextures', function () { return _this.processTextures(loadedImages_1, loadedBins_1, jsonScene_1); })];
23574
23596
  case 10:
23575
23597
  loadedTextures = _e.sent();
23598
+ jsonScene_1.compositions = this.updateSceneData(jsonScene_1.compositions);
23576
23599
  scene = {
23577
23600
  url: url,
23578
23601
  renderLevel: this.options.renderLevel,
@@ -30287,7 +30310,7 @@ var Player = /** @class */ (function () {
30287
30310
  }());
30288
30311
  function isSceneWithOptions(scene) {
30289
30312
  // TODO: 判断不太优雅,后期试情况优化
30290
- return isObject(scene) && 'scene' in scene;
30313
+ return isObject(scene) && 'scene' in scene && 'options' in scene;
30291
30314
  }
30292
30315
  /**
30293
30316
  * 禁止/允许创建新的播放器,已创建的不受影响
@@ -30417,7 +30440,7 @@ Renderer.create = function (canvas, framework, renderOptions) {
30417
30440
  Engine.create = function (gl) {
30418
30441
  return new GLEngine(gl);
30419
30442
  };
30420
- var version = "1.2.1";
30443
+ var version = "1.2.3";
30421
30444
  logger.info('player version: ' + version);
30422
30445
 
30423
30446
  exports.AbstractPlugin = AbstractPlugin;