@galacean/effects 1.3.0-alpha.0 → 1.3.0

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/weapp.js CHANGED
@@ -680,7 +680,7 @@ function asserts(condition, msg) {
680
680
  * Name: @galacean/effects-specification
681
681
  * Description: Galacean Effects JSON Specification
682
682
  * Author: Ant Group CO., Ltd.
683
- * Version: v1.1.0-alpha.0
683
+ * Version: v1.1.0
684
684
  */
685
685
 
686
686
  /*********************************************/
@@ -7124,9 +7124,9 @@ var Float16ArrayWrapper = /** @class */ (function () {
7124
7124
  this.data = new Uint16Array(num);
7125
7125
  }
7126
7126
  else if (num && typeof num === 'object' && Number.isInteger(num.length)) {
7127
- var data = this.data = new Uint16Array(num.length);
7128
- for (var i = 0; i < data.length; i++) {
7129
- data[i] = toHalf(num[i]);
7127
+ var data_1 = this.data = new Uint16Array(num.length);
7128
+ for (var i = 0; i < data_1.length; i++) {
7129
+ data_1[i] = toHalf(num[i]);
7130
7130
  }
7131
7131
  }
7132
7132
  }
@@ -7499,9 +7499,9 @@ var CurveValue = /** @class */ (function (_super) {
7499
7499
  CurveValue.getAllData = function (meta, halfFloat) {
7500
7500
  var ret = new (halfFloat ? Float16ArrayWrapper : Float32Array)(meta.index * 4);
7501
7501
  for (var i = 0, cursor = 0, curves = meta.curves; i < curves.length; i++) {
7502
- var data = curves[i].toData();
7503
- ret.set(data, cursor);
7504
- cursor += data.length;
7502
+ var data_1 = curves[i].toData();
7503
+ ret.set(data_1, cursor);
7504
+ cursor += data_1.length;
7505
7505
  }
7506
7506
  return halfFloat ? ret.data : ret;
7507
7507
  };
@@ -7510,17 +7510,17 @@ var CurveValue = /** @class */ (function (_super) {
7510
7510
  var max = -Infinity;
7511
7511
  //formatted number
7512
7512
  if (Number.isFinite(props[0]) && Number.isFinite(props[1])) {
7513
- var keys = [];
7513
+ var keys_1 = [];
7514
7514
  for (var i = 2; i < props.length; i++) {
7515
7515
  // FIXME
7516
- keys.push(props[i].slice(0, 4));
7516
+ keys_1.push(props[i].slice(0, 4));
7517
7517
  }
7518
- this.keys = keys;
7518
+ this.keys = keys_1;
7519
7519
  this.min = props[0];
7520
7520
  this.dist = props[1] - props[0];
7521
7521
  }
7522
7522
  else {
7523
- var keys = props.map(function (item) {
7523
+ var keys_2 = props.map(function (item) {
7524
7524
  if (isArray(item)) {
7525
7525
  min = Math.min(min, item[1]);
7526
7526
  max = Math.max(max, item[1]);
@@ -7535,22 +7535,22 @@ var CurveValue = /** @class */ (function (_super) {
7535
7535
  throw new Error('invalid keyframe');
7536
7536
  });
7537
7537
  var dist = max - min;
7538
- this.keys = keys;
7538
+ this.keys = keys_2;
7539
7539
  if (dist !== 0) {
7540
- for (var i = 0; i < keys.length; i++) {
7541
- var key = keys[i];
7540
+ for (var i = 0; i < keys_2.length; i++) {
7541
+ var key = keys_2[i];
7542
7542
  key[1] = (key[1] - min) / dist;
7543
7543
  }
7544
7544
  }
7545
- var key0 = keys[0];
7545
+ var key0 = keys_2[0];
7546
7546
  if (key0[0] > 0) {
7547
7547
  key0[2] = 0;
7548
- keys.unshift([0, key0[1], 0, 0]);
7548
+ keys_2.unshift([0, key0[1], 0, 0]);
7549
7549
  }
7550
- var key1 = keys[keys.length - 1];
7550
+ var key1 = keys_2[keys_2.length - 1];
7551
7551
  if (key1[0] < 1) {
7552
7552
  key1[3] = 0;
7553
- keys.push([1, key1[1], 0, 0]);
7553
+ keys_2.push([1, key1[1], 0, 0]);
7554
7554
  }
7555
7555
  this.min = min;
7556
7556
  this.dist = dist;
@@ -7925,14 +7925,14 @@ function curveValueIntegrateByTime(t1, keyframe0, keyframe1) {
7925
7925
  function getKeyFrameMetaByRawValue(meta, value) {
7926
7926
  if (value) {
7927
7927
  var type = value[0];
7928
- var keys = value[1];
7928
+ var keys_3 = value[1];
7929
7929
  if (type === ValueType$1.CURVE) {
7930
- meta.curves.push(keys);
7931
- var keyLen = keys.length;
7932
- if (keys[0][0] > 0) {
7930
+ meta.curves.push(keys_3);
7931
+ var keyLen = keys_3.length;
7932
+ if (keys_3[0][0] > 0) {
7933
7933
  keyLen++;
7934
7934
  }
7935
- if (keys[keys.length - 1][0] < 1) {
7935
+ if (keys_3[keys_3.length - 1][0] < 1) {
7936
7936
  keyLen++;
7937
7937
  }
7938
7938
  meta.index += keyLen;
@@ -7940,19 +7940,19 @@ function getKeyFrameMetaByRawValue(meta, value) {
7940
7940
  meta.curveCount += keyLen;
7941
7941
  }
7942
7942
  else if (type === ValueType$1.LINE) {
7943
- var keyLen = keys.length;
7944
- if (keyLen === 2 && keys[0][0] === 0 && keys[1][0] === 1) {
7943
+ var keyLen = keys_3.length;
7944
+ if (keyLen === 2 && keys_3[0][0] === 0 && keys_3[1][0] === 1) {
7945
7945
  return;
7946
7946
  }
7947
- if (keys[0][0] > 0) {
7947
+ if (keys_3[0][0] > 0) {
7948
7948
  keyLen++;
7949
7949
  }
7950
- if (keys[keys.length - 1][0] < 1) {
7950
+ if (keys_3[keys_3.length - 1][0] < 1) {
7951
7951
  keyLen++;
7952
7952
  }
7953
7953
  var uniformCount = Math.ceil(keyLen / 2);
7954
7954
  meta.lineSegCount += uniformCount;
7955
- meta.curves.push(keys);
7955
+ meta.curves.push(keys_3);
7956
7956
  meta.index += uniformCount;
7957
7957
  meta.max = Math.max(meta.max, uniformCount);
7958
7958
  }
@@ -9252,10 +9252,10 @@ var VFXItem = /** @class */ (function () {
9252
9252
  };
9253
9253
  VFXItem.prototype.translateByPixel = function (x, y) {
9254
9254
  if (this.composition) {
9255
+ // @ts-expect-error
9256
+ var _a = this.composition.renderer.canvas.getBoundingClientRect(), width = _a.width, height = _a.height;
9255
9257
  var z = this.transform.getWorldPosition().z;
9256
- var _a = this.composition.camera.getInverseVPRatio(z), rx = _a.x, ry = _a.y;
9257
- var width = this.composition.renderer.getWidth() / 2;
9258
- var height = this.composition.renderer.getHeight() / 2;
9258
+ var _b = this.composition.camera.getInverseVPRatio(z), rx = _b.x, ry = _b.y;
9259
9259
  this.transform.translate(2 * x * rx / width, -2 * y * ry / height, 0);
9260
9260
  }
9261
9261
  };
@@ -10433,9 +10433,9 @@ var KTXTexture = /** @class */ (function () {
10433
10433
  for (var level = 0; level < mipmapCount; level++) {
10434
10434
  var imageSize = new Int32Array(this.arrayBuffer, this.baseOffset + dataOffset, 1)[0]; // size per face, since not supporting array cubemaps
10435
10435
  for (var face = 0; face < this.numberOfFaces; face++) {
10436
- var data = new Uint8Array(this.arrayBuffer, this.baseOffset + dataOffset + 4, imageSize);
10436
+ var data_1 = new Uint8Array(this.arrayBuffer, this.baseOffset + dataOffset + 4, imageSize);
10437
10437
  mipmaps.push({
10438
- data: data,
10438
+ data: data_1,
10439
10439
  width: width,
10440
10440
  height: height,
10441
10441
  });
@@ -13146,9 +13146,13 @@ var InteractVFXItem = /** @class */ (function (_super) {
13146
13146
  this.handleDragMove(this.dragEvent, this.bouncingArg);
13147
13147
  }
13148
13148
  };
13149
- InteractVFXItem.prototype.onItemRemoved = function (composition) {
13149
+ InteractVFXItem.prototype.onEnd = function () {
13150
+ if (this.composition) {
13151
+ this.composition.removeInteractiveItem(this, this.ui.options.type);
13152
+ }
13153
+ };
13154
+ InteractVFXItem.prototype.onItemRemoved = function () {
13150
13155
  var _a;
13151
- composition.removeInteractiveItem(this, this.ui.options.type);
13152
13156
  this.clickable = false;
13153
13157
  (_a = this.previewContent) === null || _a === void 0 ? void 0 : _a.mesh.dispose();
13154
13158
  this.endDragTarget();
@@ -13260,16 +13264,16 @@ var InteractVFXItem = /** @class */ (function (_super) {
13260
13264
  var nx = position[0] - width;
13261
13265
  var ny = position[1] - height;
13262
13266
  if (options.dxRange) {
13263
- var _d = __read$3(options.dxRange, 2), min = _d[0], max = _d[1];
13264
- nx = clamp$1(nx, min, max);
13265
- if (nx !== min && nx !== max && min !== max) {
13267
+ var _d = __read$3(options.dxRange, 2), min_1 = _d[0], max_1 = _d[1];
13268
+ nx = clamp$1(nx, min_1, max_1);
13269
+ if (nx !== min_1 && nx !== max_1 && min_1 !== max_1) {
13266
13270
  (_a = event.origin) === null || _a === void 0 ? void 0 : _a.preventDefault();
13267
13271
  }
13268
13272
  }
13269
13273
  if (options.dyRange) {
13270
- var _e = __read$3(options.dyRange, 2), min = _e[0], max = _e[1];
13271
- ny = clamp$1(ny, min, max);
13272
- if (ny !== min && ny !== max && min !== max) {
13274
+ var _e = __read$3(options.dyRange, 2), min_2 = _e[0], max_2 = _e[1];
13275
+ ny = clamp$1(ny, min_2, max_2);
13276
+ if (ny !== min_2 && ny !== max_2 && min_2 !== max_2) {
13273
13277
  (_b = event.origin) === null || _b === void 0 ? void 0 : _b.preventDefault();
13274
13278
  }
13275
13279
  }
@@ -13383,11 +13387,11 @@ var SpriteMesh = /** @class */ (function () {
13383
13387
  var item = items[i];
13384
13388
  var texture = item === null || item === void 0 ? void 0 : item.renderer.texture;
13385
13389
  var textureIndex = texture ? textures.indexOf(texture) : -1;
13386
- var data = this.getItemInitData(item, i, pointCount, textureIndex);
13387
- aPointLen += data.aPoint.length;
13388
- indexLen += data.index.length;
13389
- datas.push(data);
13390
- pointCount += data.aPoint.length / 6;
13390
+ var data_1 = this.getItemInitData(item, i, pointCount, textureIndex);
13391
+ aPointLen += data_1.aPoint.length;
13392
+ indexLen += data_1.index.length;
13393
+ datas.push(data_1);
13394
+ pointCount += data_1.aPoint.length / 6;
13391
13395
  this.updateItem(item, true);
13392
13396
  }
13393
13397
  var bundle = {
@@ -13399,10 +13403,10 @@ var SpriteMesh = /** @class */ (function () {
13399
13403
  index: 0,
13400
13404
  };
13401
13405
  var _loop_1 = function (i) {
13402
- var data = datas[i];
13406
+ var data_2 = datas[i];
13403
13407
  Object.keys(bundle).forEach(function (name) {
13404
13408
  var arr = bundle[name];
13405
- var ta = data[name];
13409
+ var ta = data_2[name];
13406
13410
  arr.set(ta, cursor[name]);
13407
13411
  cursor[name] += ta.length;
13408
13412
  });
@@ -13669,14 +13673,14 @@ var SpriteMesh = /** @class */ (function () {
13669
13673
  for (var y = 0; y < row; y++) {
13670
13674
  var base = (y * 2 + x) * 4;
13671
13675
  // @ts-expect-error
13672
- var split = textureSheetAnimation ? [0, 0, 1, 1, splits[0][4]] : splits[y * 2 + x];
13673
- var texOffset = split[4] ? [0, 0, 1, 0, 0, 1, 1, 1] : [0, 1, 0, 0, 1, 1, 1, 0];
13676
+ var split_1 = textureSheetAnimation ? [0, 0, 1, 1, splits[0][4]] : splits[y * 2 + x];
13677
+ var texOffset = split_1[4] ? [0, 0, 1, 0, 0, 1, 1, 1] : [0, 1, 0, 0, 1, 1, 1, 0];
13674
13678
  var dw = ((x + x + 1) / col - 1) / 2;
13675
13679
  var dh = ((y + y + 1) / row - 1) / 2;
13676
- var tox = split[0];
13677
- var toy = split[1];
13678
- var tsx = split[4] ? split[3] : split[2];
13679
- var tsy = split[4] ? split[2] : split[3];
13680
+ var tox = split_1[0];
13681
+ var toy = split_1[1];
13682
+ var tsx = split_1[4] ? split_1[3] : split_1[2];
13683
+ var tsy = split_1[4] ? split_1[2] : split_1[3];
13680
13684
  var origin_1 = [
13681
13685
  originData[0] / col + dw,
13682
13686
  originData[1] / row + dh,
@@ -13773,13 +13777,13 @@ function generateFeatureTexture(engine, feather) {
13773
13777
  }
13774
13778
  else {
13775
13779
  var len = 128;
13776
- var data = new Uint8Array(len);
13780
+ var data_3 = new Uint8Array(len);
13777
13781
  for (var i = 0, s = len - 1; i < len; i++) {
13778
13782
  var p = i / s;
13779
13783
  var val = feather.getValue(p);
13780
- data[i] = Math.round(val * 255);
13784
+ data_3[i] = Math.round(val * 255);
13781
13785
  }
13782
- tex = Texture.createWithData(engine, { width: len, height: 1, data: data }, {
13786
+ tex = Texture.createWithData(engine, { width: len, height: 1, data: data_3 }, {
13783
13787
  name: 'feather',
13784
13788
  format: glContext.LUMINANCE,
13785
13789
  minFilter: glContext.LINEAR,
@@ -13937,22 +13941,22 @@ var SpriteGroup = /** @class */ (function () {
13937
13941
  * 需要则添加到meshToModify数组
13938
13942
  */
13939
13943
  for (var i = 0; i < splits.length; i++) {
13940
- var split = splits[i];
13944
+ var split_1 = splits[i];
13941
13945
  // @ts-expect-error
13942
- var spriteMesh = split.spriteMesh;
13943
- if (split.items.length === 0) {
13946
+ var spriteMesh = split_1.spriteMesh;
13947
+ if (split_1.items.length === 0) {
13944
13948
  throw new Error('split not combined');
13945
13949
  }
13946
- if (split.dirty) {
13947
- var priority = split.indexStart;
13950
+ if (split_1.dirty) {
13951
+ var priority = split_1.indexStart;
13948
13952
  if (spriteMesh.mesh.priority !== priority) {
13949
13953
  spriteMesh.mesh.priority = priority;
13950
13954
  meshToModify.push(spriteMesh.mesh);
13951
13955
  }
13952
- spriteMesh.setItems(split.items.map(function (item) { return item.content; }));
13956
+ spriteMesh.setItems(split_1.items.map(function (item) { return item.content; }));
13953
13957
  }
13954
13958
  spriteMesh.applyChange();
13955
- split.dirty = false;
13959
+ split_1.dirty = false;
13956
13960
  }
13957
13961
  /**
13958
13962
  * 有需要移除的meshSplit 则废弃对应的mesh 保留material
@@ -13960,8 +13964,8 @@ var SpriteGroup = /** @class */ (function () {
13960
13964
  */
13961
13965
  if (splitsToRemove.length) {
13962
13966
  for (var i = 0; i < splitsToRemove.length; i++) {
13963
- var split = splitsToRemove[i];
13964
- var sp = split.spriteMesh;
13967
+ var split_2 = splitsToRemove[i];
13968
+ var sp = split_2.spriteMesh;
13965
13969
  // @ts-expect-error
13966
13970
  var mesh = sp.mesh;
13967
13971
  mesh.dispose({ material: { textures: exports.DestroyOptions.keep } });
@@ -14078,7 +14082,7 @@ var SpriteGroup = /** @class */ (function () {
14078
14082
  addItemWithOrder(items, item, itemSortProperty);
14079
14083
  if (isSprite(item)) {
14080
14084
  var content = item.createContent();
14081
- var split = {
14085
+ var split_4 = {
14082
14086
  indexStart: item.listIndex,
14083
14087
  indexEnd: item.listIndex,
14084
14088
  items: [item],
@@ -14086,21 +14090,21 @@ var SpriteGroup = /** @class */ (function () {
14086
14090
  cacheId: content.renderInfo.cacheId,
14087
14091
  textures: [item.content.renderer.texture],
14088
14092
  };
14089
- splits.unshift(split);
14090
- return [split];
14093
+ splits.unshift(split_4);
14094
+ return [split_4];
14091
14095
  }
14092
14096
  return [];
14093
14097
  }
14094
14098
  var _loop_2 = function (i) {
14095
- var split = splits[i];
14099
+ var split_5 = splits[i];
14096
14100
  var listIndex = item.listIndex;
14097
14101
  if (isSprite(item)) {
14098
14102
  // @ts-expect-error
14099
- if (listIndex <= split.indexEnd) {
14103
+ if (listIndex <= split_5.indexEnd) {
14100
14104
  addItemWithOrder(items, item, itemSortProperty);
14101
14105
  var itemIndex_1 = items.indexOf(item);
14102
- var indexStart = Math.min(itemIndex_1, items.indexOf(split.items[0]));
14103
- var indexEnd = Math.max(itemIndex_1, items.indexOf(split.items[split.items.length - 1]));
14106
+ var indexStart = Math.min(itemIndex_1, items.indexOf(split_5.items[0]));
14107
+ var indexEnd = Math.max(itemIndex_1, items.indexOf(split_5.items[split_5.items.length - 1]));
14104
14108
  var neoSplits_1 = this_2.getMeshSplits(items, indexStart, indexEnd);
14105
14109
  var neoSplitIndex_1 = neoSplits_1.findIndex(function (split) { return split.items.includes(item); });
14106
14110
  if (neoSplits_1.length === 2) {
@@ -14108,14 +14112,14 @@ var SpriteGroup = /** @class */ (function () {
14108
14112
  //1 or 0
14109
14113
  Object.keys(neoSplits_1[1 - neoSplitIndex_1]).forEach(function (key) {
14110
14114
  // @ts-expect-error
14111
- split[key] = neoSplits_1[1 - neoSplitIndex_1][key];
14115
+ split_5[key] = neoSplits_1[1 - neoSplitIndex_1][key];
14112
14116
  });
14113
14117
  return { value: [neoSplits_1[neoSplitIndex_1]] };
14114
14118
  }
14115
14119
  else if (neoSplits_1.length === 3) {
14116
14120
  Object.keys(neoSplits_1[0]).forEach(function (key) {
14117
14121
  // @ts-expect-error
14118
- split[key] = neoSplits_1[0][key];
14122
+ split_5[key] = neoSplits_1[0][key];
14119
14123
  });
14120
14124
  splits.splice(i + 1, 0, neoSplits_1[1], neoSplits_1[2]);
14121
14125
  if (neoSplitIndex_1 !== 1) {
@@ -14129,25 +14133,25 @@ var SpriteGroup = /** @class */ (function () {
14129
14133
  //todo add case
14130
14134
  Object.keys(neoSplits_1[0]).forEach(function (key) {
14131
14135
  // @ts-expect-error
14132
- split[key] = neoSplits_1[0][key];
14136
+ split_5[key] = neoSplits_1[0][key];
14133
14137
  });
14134
14138
  return { value: [] };
14135
14139
  }
14136
14140
  }
14137
14141
  else {
14138
- if (listIndex < split.indexStart || listIndex === split.indexEnd) {
14142
+ if (listIndex < split_5.indexStart || listIndex === split_5.indexEnd) {
14139
14143
  addItemWithOrder(items, item, itemSortProperty);
14140
14144
  return { value: [] };
14141
14145
  // @ts-expect-error
14142
14146
  }
14143
- else if (listIndex < split.indexEnd) {
14147
+ else if (listIndex < split_5.indexEnd) {
14144
14148
  addItemWithOrder(items, item, itemSortProperty);
14145
- var lastItem = split.items[split.items.length - 1];
14149
+ var lastItem = split_5.items[split_5.items.length - 1];
14146
14150
  var endIndex = items.indexOf(lastItem);
14147
- var neoSplits_2 = this_2.getMeshSplits(items, items.indexOf(split.items[0]), endIndex);
14151
+ var neoSplits_2 = this_2.getMeshSplits(items, items.indexOf(split_5.items[0]), endIndex);
14148
14152
  Object.keys(neoSplits_2[0]).forEach(function (key) {
14149
14153
  // @ts-expect-error
14150
- split[key] = neoSplits_2[0][key];
14154
+ split_5[key] = neoSplits_2[0][key];
14151
14155
  });
14152
14156
  if (neoSplits_2.length === 2) {
14153
14157
  splits.splice(i + 1, 0, neoSplits_2[1]);
@@ -14208,10 +14212,10 @@ var SpriteGroup = /** @class */ (function () {
14208
14212
  * 遍历this.meshSplits,找到元素的listIndex在split的indexStart和indexEnd范围内的第一个meshSplit
14209
14213
  */
14210
14214
  for (var i = 0; i < splits.length; i++) {
14211
- var split = splits[i];
14215
+ var split_6 = splits[i];
14212
14216
  // @ts-expect-error
14213
- if (split.indexStart <= item.listIndex && split.indexEnd >= item.listIndex) {
14214
- targetSplit = split;
14217
+ if (split_6.indexStart <= item.listIndex && split_6.indexEnd >= item.listIndex) {
14218
+ targetSplit = split_6;
14215
14219
  targetSplitIndex = i;
14216
14220
  break;
14217
14221
  }
@@ -14321,8 +14325,8 @@ var SpriteGroup = /** @class */ (function () {
14321
14325
  // FIXME: 可选性
14322
14326
  var targetSplitIndex = void 0;
14323
14327
  for (var i = 0; i < splits.length; i++) {
14324
- var split = splits[i];
14325
- if (split.items.includes(item)) {
14328
+ var split_7 = splits[i];
14329
+ if (split_7.items.includes(item)) {
14326
14330
  targetSplitIndex = i;
14327
14331
  break;
14328
14332
  }
@@ -14940,7 +14944,6 @@ var SpriteItem = /** @class */ (function (_super) {
14940
14944
  ret.texOffset = [0, 0, 1, 1];
14941
14945
  }
14942
14946
  ret.visible = this.vfxItem.contentVisible;
14943
- // 图层元素作为父节点时,除了k的大小变换,自身的尺寸也需要传递给子元素,子元素可以通过startSize读取
14944
14947
  ret.startSize = this.startSize;
14945
14948
  return ret;
14946
14949
  };
@@ -15038,7 +15041,9 @@ var SpriteVFXItem = /** @class */ (function (_super) {
15038
15041
  };
15039
15042
  SpriteVFXItem.prototype.doCreateContent = function (composition) {
15040
15043
  var emptyTexture = composition.getRendererOptions().emptyTexture;
15041
- return new SpriteItem(this.sprite, { emptyTexture: emptyTexture }, this);
15044
+ var content = new SpriteItem(this.sprite, { emptyTexture: emptyTexture }, this);
15045
+ content.getRenderData(0, true);
15046
+ return content;
15042
15047
  };
15043
15048
  SpriteVFXItem.prototype.createWireframeMesh = function (item, color) {
15044
15049
  var spMesh = new SpriteMesh(this.composition.getEngine(), __assign$1({ wireframe: true }, item.renderInfo), this.composition);
@@ -15472,10 +15477,10 @@ var ParticleMesh = /** @class */ (function () {
15472
15477
  var index = geometry.getIndexData();
15473
15478
  for (var i = 0; i < names.length; i++) {
15474
15479
  var name_1 = names[i];
15475
- var data = geometry.getAttributeData(name_1);
15476
- if (data) {
15480
+ var data_1 = geometry.getAttributeData(name_1);
15481
+ if (data_1) {
15477
15482
  // @ts-expect-error
15478
- geometry.setAttributeData(name_1, new data.constructor(0));
15483
+ geometry.setAttributeData(name_1, new data_1.constructor(0));
15479
15484
  }
15480
15485
  }
15481
15486
  // @ts-expect-error
@@ -16850,10 +16855,10 @@ function getGeometryTriangles(geometry, options) {
16850
16855
  var segment = segments[i];
16851
16856
  var p0 = points[i];
16852
16857
  var p1 = points[i + 1] || points[0];
16853
- var keys = segment;
16858
+ var keys_1 = segment;
16854
16859
  var point = [0, 0];
16855
- for (var j = 0; j < keys.length - 1; j++) {
16856
- var key = keys[j];
16860
+ for (var j = 0; j < keys_1.length - 1; j++) {
16861
+ var key = keys_1[j];
16857
16862
  getBezier2DValue(point, key, p0, p1, p0[4], p0[5], p1[2], p1[3]);
16858
16863
  setPoint(point[0], point[1]);
16859
16864
  }
@@ -16912,11 +16917,11 @@ function getGeometryByShape(shape, uvTransform) {
16912
16917
  var index = 0;
16913
16918
  for (var i = 0; i < geometries.length; i++) {
16914
16919
  var geometry = geometries[i];
16915
- var data = getGeometryTriangles(geometry, { indexBase: indexBase, uvTransform: uvTransform });
16916
- indexBase += data.aPoint.length / 5;
16917
- datas.push(data);
16918
- aPoint += data.aPoint.length;
16919
- index += data.index.length;
16920
+ var data_1 = getGeometryTriangles(geometry, { indexBase: indexBase, uvTransform: uvTransform });
16921
+ indexBase += data_1.aPoint.length / 5;
16922
+ datas.push(data_1);
16923
+ aPoint += data_1.aPoint.length;
16924
+ index += data_1.index.length;
16920
16925
  }
16921
16926
  if (datas.length === 1) {
16922
16927
  return datas[0];
@@ -16925,11 +16930,11 @@ function getGeometryByShape(shape, uvTransform) {
16925
16930
  var indexData = new Uint16Array(index);
16926
16931
  // @ts-expect-error
16927
16932
  for (var i = 0, pointIndex = 0, idx = 0; i < datas[i]; i++) {
16928
- var data = datas[i];
16929
- aPointData.set(data.aPoint, pointIndex);
16930
- pointIndex += data.aPoint.length;
16931
- indexData.set(data.index, idx);
16932
- idx += data.index.length;
16933
+ var data_2 = datas[i];
16934
+ aPointData.set(data_2.aPoint, pointIndex);
16935
+ pointIndex += data_2.aPoint.length;
16936
+ indexData.set(data_2.index, idx);
16937
+ idx += data_2.index.length;
16933
16938
  }
16934
16939
  return {
16935
16940
  aPoint: aPointData,
@@ -17240,10 +17245,10 @@ var TrailMesh = /** @class */ (function () {
17240
17245
  var pointCountPerTrail = this.pointCountPerTrail;
17241
17246
  if (index >= 0 && index < pointCountPerTrail) {
17242
17247
  var startIndex = (trail * pointCountPerTrail + index) * 24 + 8;
17243
- var data = this.geometry.getAttributeData('aColor');
17244
- out.x = data[startIndex];
17245
- out.y = data[1 + startIndex];
17246
- out.z = data[2 + startIndex];
17248
+ var data_1 = this.geometry.getAttributeData('aColor');
17249
+ out.x = data_1[startIndex];
17250
+ out.y = data_1[1 + startIndex];
17251
+ out.z = data_1[2 + startIndex];
17247
17252
  return out;
17248
17253
  }
17249
17254
  };
@@ -18649,14 +18654,14 @@ var TextMesh = /** @class */ (function (_super) {
18649
18654
  for (var y_1 = 0; y_1 < row; y_1++) {
18650
18655
  var base = (y_1 * 2 + x_1) * 4;
18651
18656
  // @ts-expect-error
18652
- var split = textureSheetAnimation ? [0, 0, 1, 1, splits[0][4]] : splits[y_1 * 2 + x_1];
18653
- var texOffset = split[4] ? [0, 0, 1, 0, 0, 1, 1, 1] : [0, 1, 0, 0, 1, 1, 1, 0];
18657
+ var split_1 = textureSheetAnimation ? [0, 0, 1, 1, splits[0][4]] : splits[y_1 * 2 + x_1];
18658
+ var texOffset = split_1[4] ? [0, 0, 1, 0, 0, 1, 1, 1] : [0, 1, 0, 0, 1, 1, 1, 0];
18654
18659
  var dw = ((x_1 + x_1 + 1) / col - 1) / 2;
18655
18660
  var dh = ((y_1 + y_1 + 1) / row - 1) / 2;
18656
- var tox = split[0];
18657
- var toy = split[1];
18658
- var tsx = split[4] ? split[3] : split[2];
18659
- var tsy = split[4] ? split[2] : split[3];
18661
+ var tox = split_1[0];
18662
+ var toy = split_1[1];
18663
+ var tsx = split_1[4] ? split_1[3] : split_1[2];
18664
+ var tsy = split_1[4] ? split_1[2] : split_1[3];
18660
18665
  var origin_1 = [
18661
18666
  originData[0] / col + dw,
18662
18667
  originData[1] / row + dh,
@@ -21376,8 +21381,9 @@ var Camera = /** @class */ (function () {
21376
21381
  Camera.prototype.getInverseVPRatio = function (z) {
21377
21382
  var pos = new Vector3(0, 0, z);
21378
21383
  var mat = this.getViewProjectionMatrix();
21379
- var nz = pos.applyMatrix(mat).z;
21380
- return new Vector3(1, 1, nz).applyMatrix(mat);
21384
+ var inverseVP = this.getInverseViewProjectionMatrix();
21385
+ var nz = mat.projectPoint(pos).z;
21386
+ return inverseVP.projectPoint(new Vector3(1, 1, nz));
21381
21387
  };
21382
21388
  /**
21383
21389
  * 设置相机的旋转四元数
@@ -21389,7 +21395,6 @@ var Camera = /** @class */ (function () {
21389
21395
  this.dirty = true;
21390
21396
  }
21391
21397
  else {
21392
- this.options.quat;
21393
21398
  if (!this.options.quat.equals(value)) {
21394
21399
  this.options.quat.copyFrom(value);
21395
21400
  this.dirty = true;
@@ -21566,7 +21571,7 @@ var filters = {
21566
21571
  * Name: @galacean/effects-specification
21567
21572
  * Description: Galacean Effects JSON Specification
21568
21573
  * Author: Ant Group CO., Ltd.
21569
- * Version: v1.1.0-alpha.0
21574
+ * Version: v1.1.0
21570
21575
  */
21571
21576
 
21572
21577
  /*********************************************/
@@ -23336,13 +23341,13 @@ var CompositionSourceManager = /** @class */ (function () {
23336
23341
  if (renderContent.renderer) {
23337
23342
  renderContent.renderer = _this.changeTex(renderContent.renderer);
23338
23343
  _this.processMask(renderContent.renderer);
23339
- var split = renderContent.splits && !renderContent.textureSheetAnimation && renderContent.splits[0];
23344
+ var split_1 = renderContent.splits && !renderContent.textureSheetAnimation && renderContent.splits[0];
23340
23345
  if (Number.isInteger(renderContent.renderer.shape)) {
23341
23346
  // TODO: scene.shapes 类型问题?
23342
- renderContent.renderer.shape = getGeometryByShape((_a = _this.jsonScene) === null || _a === void 0 ? void 0 : _a.shapes[renderContent.renderer.shape], split);
23347
+ renderContent.renderer.shape = getGeometryByShape((_a = _this.jsonScene) === null || _a === void 0 ? void 0 : _a.shapes[renderContent.renderer.shape], split_1);
23343
23348
  }
23344
23349
  else if (renderContent.renderer.shape && isObject(renderContent.renderer.shape)) {
23345
- renderContent.renderer.shape = getGeometryByShape(renderContent.renderer.shape, split);
23350
+ renderContent.renderer.shape = getGeometryByShape(renderContent.renderer.shape, split_1);
23346
23351
  }
23347
23352
  }
23348
23353
  else {
@@ -23354,14 +23359,14 @@ var CompositionSourceManager = /** @class */ (function () {
23354
23359
  if (renderContent.filter) {
23355
23360
  renderContent.filter = __assign$1({}, renderContent.filter);
23356
23361
  }
23357
- var name_1 = item.name, _b = item.delay, delay = _b === void 0 ? 0 : _b, id = item.id, parentId = item.parentId, duration = item.duration, endBehavior = item.endBehavior, pluginName = item.pluginName, pn = item.pn, transform = item.transform;
23362
+ var name_1 = item.name, _b = item.delay, delay = _b === void 0 ? 0 : _b, id_1 = item.id, parentId = item.parentId, duration = item.duration, endBehavior = item.endBehavior, pluginName = item.pluginName, pn = item.pn, transform = item.transform;
23358
23363
  // FIXME: specification 下定义的 Item 不存在 refCount 类型定义
23359
23364
  // @ts-expect-error
23360
23365
  var refCount = item.refCount;
23361
23366
  var _c = _this.jsonScene.plugins, plugins = _c === void 0 ? [] : _c;
23362
23367
  option.name = name_1;
23363
23368
  option.delay = delay;
23364
- option.id = id;
23369
+ option.id = id_1;
23365
23370
  if (parentId) {
23366
23371
  option.parentId = parentId;
23367
23372
  }
@@ -23729,16 +23734,17 @@ var AssetManager = /** @class */ (function () {
23729
23734
  };
23730
23735
  AssetManager.prototype.processBins = function (bins) {
23731
23736
  return __awaiter(this, void 0, void 0, function () {
23732
- var renderLevel, jobs;
23737
+ var renderLevel, baseUrl, jobs;
23733
23738
  var _this = this;
23734
23739
  return __generator(this, function (_a) {
23735
23740
  renderLevel = this.options.renderLevel;
23741
+ baseUrl = this.baseUrl;
23736
23742
  jobs = bins.map(function (bin) {
23737
23743
  if (bin instanceof ArrayBuffer) {
23738
23744
  return bin;
23739
23745
  }
23740
23746
  if (passRenderLevel(bin.renderLevel, renderLevel)) {
23741
- return _this.loadBins(bin.url);
23747
+ return _this.loadBins(new weapp.URL(bin.url, baseUrl).href);
23742
23748
  }
23743
23749
  throw new Error("Invalid bins source: ".concat(JSON.stringify(bins)));
23744
23750
  });
@@ -23756,13 +23762,14 @@ var AssetManager = /** @class */ (function () {
23756
23762
  return [2 /*return*/];
23757
23763
  }
23758
23764
  jobs = fonts.map(function (font) { return __awaiter(_this, void 0, void 0, function () {
23759
- var fontFace;
23765
+ var url, fontFace;
23760
23766
  var _a;
23761
23767
  return __generator(this, function (_b) {
23762
23768
  switch (_b.label) {
23763
23769
  case 0:
23764
23770
  if (!(font.fontURL && !AssetManager.fonts.has(font.fontFamily))) return [3 /*break*/, 4];
23765
- fontFace = new FontFace((_a = font.fontFamily) !== null && _a !== void 0 ? _a : '', 'url(' + font.fontURL + ')');
23771
+ url = new weapp.URL(font.fontURL, this.baseUrl).href;
23772
+ fontFace = new FontFace((_a = font.fontFamily) !== null && _a !== void 0 ? _a : '', 'url(' + url + ')');
23766
23773
  _b.label = 1;
23767
23774
  case 1:
23768
23775
  _b.trys.push([1, 3, , 4]);
@@ -23775,7 +23782,7 @@ var AssetManager = /** @class */ (function () {
23775
23782
  return [3 /*break*/, 4];
23776
23783
  case 3:
23777
23784
  _b.sent();
23778
- logger.warn("Invalid fonts source: ".concat(JSON.stringify(font.fontURL)));
23785
+ logger.warn("Invalid fonts source: ".concat(JSON.stringify(url)));
23779
23786
  return [3 /*break*/, 4];
23780
23787
  case 4: return [2 /*return*/];
23781
23788
  }
@@ -23970,14 +23977,14 @@ var AssetManager = /** @class */ (function () {
23970
23977
  }());
23971
23978
  function fixOldImageUsage(usedImages, compositions, imgUsage, images, renderLevel) {
23972
23979
  for (var i = 0; i < compositions.length; i++) {
23973
- var id = compositions[i].id;
23974
- var ids = imgUsage[id];
23980
+ var id_1 = compositions[i].id;
23981
+ var ids = imgUsage[id_1];
23975
23982
  if (ids) {
23976
23983
  for (var j = 0; j < ids.length; j++) {
23977
- var id_1 = ids[j];
23978
- var tag = images[id_1].renderLevel;
23984
+ var id_2 = ids[j];
23985
+ var tag = images[id_2].renderLevel;
23979
23986
  if (passRenderLevel(tag, renderLevel)) {
23980
- usedImages[id_1] = true;
23987
+ usedImages[id_2] = true;
23981
23988
  }
23982
23989
  }
23983
23990
  }
@@ -23988,7 +23995,7 @@ function createTextureOptionsBySource(image, sourceFrom) {
23988
23995
  return image.source;
23989
23996
  }
23990
23997
  else if (image instanceof weapp.HTMLImageElement ||
23991
- image instanceof weapp.HTMLCanvasElement) {
23998
+ isCanvas(image)) {
23992
23999
  return {
23993
24000
  image: image,
23994
24001
  sourceType: exports.TextureSourceType.image,
@@ -24025,6 +24032,11 @@ function createTextureOptionsBySource(image, sourceFrom) {
24025
24032
  }
24026
24033
  throw new Error('Invalid texture options');
24027
24034
  }
24035
+ function isCanvas(canvas) {
24036
+ var _a;
24037
+ // 小程序 Canvas 无法使用 instanceof HTMLCanvasElement 判断
24038
+ return typeof canvas === 'object' && canvas !== null && ((_a = canvas.tagName) === null || _a === void 0 ? void 0 : _a.toUpperCase()) === 'CANVAS';
24039
+ }
24028
24040
 
24029
24041
  var CompVFXItem = /** @class */ (function (_super) {
24030
24042
  __extends(CompVFXItem, _super);
@@ -25743,10 +25755,10 @@ var GLTexture = /** @class */ (function (_super) {
25743
25755
  var target = this.target;
25744
25756
  var gl = this.pipelineContext.gl;
25745
25757
  if (gl && this.textureBuffer) {
25746
- var data = new Uint8Array([255]);
25758
+ var data_1 = new Uint8Array([255]);
25747
25759
  this.bind();
25748
25760
  if (target === gl.TEXTURE_2D) {
25749
- gl.texImage2D(target, 0, gl.LUMINANCE, 1, 1, 0, gl.LUMINANCE, gl.UNSIGNED_BYTE, data);
25761
+ gl.texImage2D(target, 0, gl.LUMINANCE, 1, 1, 0, gl.LUMINANCE, gl.UNSIGNED_BYTE, data_1);
25750
25762
  }
25751
25763
  else if (target === gl.TEXTURE_CUBE_MAP) {
25752
25764
  var faces = [
@@ -25758,7 +25770,7 @@ var GLTexture = /** @class */ (function (_super) {
25758
25770
  gl.TEXTURE_CUBE_MAP_POSITIVE_Z,
25759
25771
  ];
25760
25772
  for (var i = 0; i < faces.length; i++) {
25761
- gl.texImage2D(faces[i], 0, gl.LUMINANCE, 1, 1, 0, gl.LUMINANCE, gl.UNSIGNED_BYTE, data);
25773
+ gl.texImage2D(faces[i], 0, gl.LUMINANCE, 1, 1, 0, gl.LUMINANCE, gl.UNSIGNED_BYTE, data_1);
25762
25774
  }
25763
25775
  }
25764
25776
  // rewrite mipmap
@@ -29608,6 +29620,7 @@ var Player = /** @class */ (function () {
29608
29620
  this.displayScale = 1;
29609
29621
  this.resumePending = false;
29610
29622
  this.disposed = false;
29623
+ this.assetManagers = [];
29611
29624
  this.speed = 1;
29612
29625
  this.baseCompositionIndex = 0;
29613
29626
  /**
@@ -29742,10 +29755,10 @@ var Player = /** @class */ (function () {
29742
29755
  }
29743
29756
  else if (gl) {
29744
29757
  this.canvas = gl.canvas;
29745
- var version = gl instanceof weapp.WebGLRenderingContext ? 'webgl' : 'webgl2';
29746
- if (framework !== version) {
29747
- logger.error("The gl context(".concat(version, ") is inconsistent with renderFramework or default version(").concat(framework, ")"));
29748
- framework = version;
29758
+ var version_1 = gl instanceof weapp.WebGLRenderingContext ? 'webgl' : 'webgl2';
29759
+ if (framework !== version_1) {
29760
+ logger.error("The gl context(".concat(version_1, ") is inconsistent with renderFramework or default version(").concat(framework, ")"));
29761
+ framework = version_1;
29749
29762
  }
29750
29763
  }
29751
29764
  else {
@@ -29890,7 +29903,7 @@ var Player = /** @class */ (function () {
29890
29903
  Player.prototype.createComposition = function (url, options) {
29891
29904
  if (options === void 0) { options = {}; }
29892
29905
  return __awaiter(this, void 0, void 0, function () {
29893
- var renderer, last, opts, source, scene, composition, firstFrameTime;
29906
+ var renderer, last, opts, source, assetManager, scene, composition, firstFrameTime;
29894
29907
  var _this = this;
29895
29908
  return __generator(this, function (_a) {
29896
29909
  switch (_a.label) {
@@ -29905,13 +29918,9 @@ var Player = /** @class */ (function () {
29905
29918
  else {
29906
29919
  source = url;
29907
29920
  }
29908
- if (this.assetManager) {
29909
- this.assetManager.updateOptions(opts);
29910
- }
29911
- else {
29912
- this.assetManager = new AssetManager(opts);
29913
- }
29914
- return [4 /*yield*/, this.assetManager.loadScene(source, this.renderer, { env: this.env })];
29921
+ assetManager = new AssetManager(opts);
29922
+ this.assetManagers.push(assetManager);
29923
+ return [4 /*yield*/, assetManager.loadScene(source, this.renderer, { env: this.env })];
29915
29924
  case 1:
29916
29925
  scene = _a.sent();
29917
29926
  // 加载期间 player 销毁
@@ -30241,7 +30250,7 @@ var Player = /** @class */ (function () {
30241
30250
  * @param keepCanvas - 是否保留 canvas 画面,默认不保留,canvas 不能再被使用
30242
30251
  */
30243
30252
  Player.prototype.dispose = function (keepCanvas) {
30244
- var _a, _b;
30253
+ var _a;
30245
30254
  logger.info("call player destroy: ".concat(this.name));
30246
30255
  if (this.disposed) {
30247
30256
  return;
@@ -30249,7 +30258,7 @@ var Player = /** @class */ (function () {
30249
30258
  playerMap.delete(this.canvas);
30250
30259
  this.pause();
30251
30260
  (_a = this.ticker) === null || _a === void 0 ? void 0 : _a.stop();
30252
- (_b = this.assetManager) === null || _b === void 0 ? void 0 : _b.dispose();
30261
+ this.assetManagers.forEach(function (assetManager) { return assetManager.dispose(); });
30253
30262
  this.compositions.forEach(function (comp) { return comp.dispose(); });
30254
30263
  this.compositions.length = 0;
30255
30264
  this.renderer.context.removeLostHandler({ lost: this.lost });
@@ -30455,7 +30464,7 @@ Renderer.create = function (canvas, framework, renderOptions) {
30455
30464
  Engine.create = function (gl) {
30456
30465
  return new GLEngine(gl);
30457
30466
  };
30458
- var version = "1.3.0-alpha.0";
30467
+ var version = "1.3.0";
30459
30468
  logger.info('player version: ' + version);
30460
30469
 
30461
30470
  exports.AbstractPlugin = AbstractPlugin;