@galacean/effects-threejs 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/index.mjs CHANGED
@@ -3,7 +3,7 @@
3
3
  * Description: Galacean Effects runtime threejs plugin for the web
4
4
  * Author: Ant Group CO., Ltd.
5
5
  * Contributors: 燃然,飂兮,十弦,云垣,茂安,意绮
6
- * Version: v1.3.0-alpha.0
6
+ * Version: v1.3.0
7
7
  */
8
8
 
9
9
  import * as THREE from 'three';
@@ -684,7 +684,7 @@ function asserts(condition, msg) {
684
684
  * Name: @galacean/effects-specification
685
685
  * Description: Galacean Effects JSON Specification
686
686
  * Author: Ant Group CO., Ltd.
687
- * Version: v1.1.0-alpha.0
687
+ * Version: v1.1.0
688
688
  */
689
689
 
690
690
  /*********************************************/
@@ -7128,9 +7128,9 @@ var Float16ArrayWrapper = /** @class */ (function () {
7128
7128
  this.data = new Uint16Array(num);
7129
7129
  }
7130
7130
  else if (num && typeof num === 'object' && Number.isInteger(num.length)) {
7131
- var data = this.data = new Uint16Array(num.length);
7132
- for (var i = 0; i < data.length; i++) {
7133
- data[i] = toHalf(num[i]);
7131
+ var data_1 = this.data = new Uint16Array(num.length);
7132
+ for (var i = 0; i < data_1.length; i++) {
7133
+ data_1[i] = toHalf(num[i]);
7134
7134
  }
7135
7135
  }
7136
7136
  }
@@ -7503,9 +7503,9 @@ var CurveValue = /** @class */ (function (_super) {
7503
7503
  CurveValue.getAllData = function (meta, halfFloat) {
7504
7504
  var ret = new (halfFloat ? Float16ArrayWrapper : Float32Array)(meta.index * 4);
7505
7505
  for (var i = 0, cursor = 0, curves = meta.curves; i < curves.length; i++) {
7506
- var data = curves[i].toData();
7507
- ret.set(data, cursor);
7508
- cursor += data.length;
7506
+ var data_1 = curves[i].toData();
7507
+ ret.set(data_1, cursor);
7508
+ cursor += data_1.length;
7509
7509
  }
7510
7510
  return halfFloat ? ret.data : ret;
7511
7511
  };
@@ -7514,17 +7514,17 @@ var CurveValue = /** @class */ (function (_super) {
7514
7514
  var max = -Infinity;
7515
7515
  //formatted number
7516
7516
  if (Number.isFinite(props[0]) && Number.isFinite(props[1])) {
7517
- var keys = [];
7517
+ var keys_1 = [];
7518
7518
  for (var i = 2; i < props.length; i++) {
7519
7519
  // FIXME
7520
- keys.push(props[i].slice(0, 4));
7520
+ keys_1.push(props[i].slice(0, 4));
7521
7521
  }
7522
- this.keys = keys;
7522
+ this.keys = keys_1;
7523
7523
  this.min = props[0];
7524
7524
  this.dist = props[1] - props[0];
7525
7525
  }
7526
7526
  else {
7527
- var keys = props.map(function (item) {
7527
+ var keys_2 = props.map(function (item) {
7528
7528
  if (isArray(item)) {
7529
7529
  min = Math.min(min, item[1]);
7530
7530
  max = Math.max(max, item[1]);
@@ -7539,22 +7539,22 @@ var CurveValue = /** @class */ (function (_super) {
7539
7539
  throw new Error('invalid keyframe');
7540
7540
  });
7541
7541
  var dist = max - min;
7542
- this.keys = keys;
7542
+ this.keys = keys_2;
7543
7543
  if (dist !== 0) {
7544
- for (var i = 0; i < keys.length; i++) {
7545
- var key = keys[i];
7544
+ for (var i = 0; i < keys_2.length; i++) {
7545
+ var key = keys_2[i];
7546
7546
  key[1] = (key[1] - min) / dist;
7547
7547
  }
7548
7548
  }
7549
- var key0 = keys[0];
7549
+ var key0 = keys_2[0];
7550
7550
  if (key0[0] > 0) {
7551
7551
  key0[2] = 0;
7552
- keys.unshift([0, key0[1], 0, 0]);
7552
+ keys_2.unshift([0, key0[1], 0, 0]);
7553
7553
  }
7554
- var key1 = keys[keys.length - 1];
7554
+ var key1 = keys_2[keys_2.length - 1];
7555
7555
  if (key1[0] < 1) {
7556
7556
  key1[3] = 0;
7557
- keys.push([1, key1[1], 0, 0]);
7557
+ keys_2.push([1, key1[1], 0, 0]);
7558
7558
  }
7559
7559
  this.min = min;
7560
7560
  this.dist = dist;
@@ -7929,14 +7929,14 @@ function curveValueIntegrateByTime(t1, keyframe0, keyframe1) {
7929
7929
  function getKeyFrameMetaByRawValue(meta, value) {
7930
7930
  if (value) {
7931
7931
  var type = value[0];
7932
- var keys = value[1];
7932
+ var keys_3 = value[1];
7933
7933
  if (type === ValueType$1.CURVE) {
7934
- meta.curves.push(keys);
7935
- var keyLen = keys.length;
7936
- if (keys[0][0] > 0) {
7934
+ meta.curves.push(keys_3);
7935
+ var keyLen = keys_3.length;
7936
+ if (keys_3[0][0] > 0) {
7937
7937
  keyLen++;
7938
7938
  }
7939
- if (keys[keys.length - 1][0] < 1) {
7939
+ if (keys_3[keys_3.length - 1][0] < 1) {
7940
7940
  keyLen++;
7941
7941
  }
7942
7942
  meta.index += keyLen;
@@ -7944,19 +7944,19 @@ function getKeyFrameMetaByRawValue(meta, value) {
7944
7944
  meta.curveCount += keyLen;
7945
7945
  }
7946
7946
  else if (type === ValueType$1.LINE) {
7947
- var keyLen = keys.length;
7948
- if (keyLen === 2 && keys[0][0] === 0 && keys[1][0] === 1) {
7947
+ var keyLen = keys_3.length;
7948
+ if (keyLen === 2 && keys_3[0][0] === 0 && keys_3[1][0] === 1) {
7949
7949
  return;
7950
7950
  }
7951
- if (keys[0][0] > 0) {
7951
+ if (keys_3[0][0] > 0) {
7952
7952
  keyLen++;
7953
7953
  }
7954
- if (keys[keys.length - 1][0] < 1) {
7954
+ if (keys_3[keys_3.length - 1][0] < 1) {
7955
7955
  keyLen++;
7956
7956
  }
7957
7957
  var uniformCount = Math.ceil(keyLen / 2);
7958
7958
  meta.lineSegCount += uniformCount;
7959
- meta.curves.push(keys);
7959
+ meta.curves.push(keys_3);
7960
7960
  meta.index += uniformCount;
7961
7961
  meta.max = Math.max(meta.max, uniformCount);
7962
7962
  }
@@ -9256,10 +9256,10 @@ var VFXItem = /** @class */ (function () {
9256
9256
  };
9257
9257
  VFXItem.prototype.translateByPixel = function (x, y) {
9258
9258
  if (this.composition) {
9259
+ // @ts-expect-error
9260
+ var _a = this.composition.renderer.canvas.getBoundingClientRect(), width = _a.width, height = _a.height;
9259
9261
  var z = this.transform.getWorldPosition().z;
9260
- var _a = this.composition.camera.getInverseVPRatio(z), rx = _a.x, ry = _a.y;
9261
- var width = this.composition.renderer.getWidth() / 2;
9262
- var height = this.composition.renderer.getHeight() / 2;
9262
+ var _b = this.composition.camera.getInverseVPRatio(z), rx = _b.x, ry = _b.y;
9263
9263
  this.transform.translate(2 * x * rx / width, -2 * y * ry / height, 0);
9264
9264
  }
9265
9265
  };
@@ -10437,9 +10437,9 @@ var KTXTexture = /** @class */ (function () {
10437
10437
  for (var level = 0; level < mipmapCount; level++) {
10438
10438
  var imageSize = new Int32Array(this.arrayBuffer, this.baseOffset + dataOffset, 1)[0]; // size per face, since not supporting array cubemaps
10439
10439
  for (var face = 0; face < this.numberOfFaces; face++) {
10440
- var data = new Uint8Array(this.arrayBuffer, this.baseOffset + dataOffset + 4, imageSize);
10440
+ var data_1 = new Uint8Array(this.arrayBuffer, this.baseOffset + dataOffset + 4, imageSize);
10441
10441
  mipmaps.push({
10442
- data: data,
10442
+ data: data_1,
10443
10443
  width: width,
10444
10444
  height: height,
10445
10445
  });
@@ -13150,9 +13150,13 @@ var InteractVFXItem = /** @class */ (function (_super) {
13150
13150
  this.handleDragMove(this.dragEvent, this.bouncingArg);
13151
13151
  }
13152
13152
  };
13153
- InteractVFXItem.prototype.onItemRemoved = function (composition) {
13153
+ InteractVFXItem.prototype.onEnd = function () {
13154
+ if (this.composition) {
13155
+ this.composition.removeInteractiveItem(this, this.ui.options.type);
13156
+ }
13157
+ };
13158
+ InteractVFXItem.prototype.onItemRemoved = function () {
13154
13159
  var _a;
13155
- composition.removeInteractiveItem(this, this.ui.options.type);
13156
13160
  this.clickable = false;
13157
13161
  (_a = this.previewContent) === null || _a === void 0 ? void 0 : _a.mesh.dispose();
13158
13162
  this.endDragTarget();
@@ -13264,16 +13268,16 @@ var InteractVFXItem = /** @class */ (function (_super) {
13264
13268
  var nx = position[0] - width;
13265
13269
  var ny = position[1] - height;
13266
13270
  if (options.dxRange) {
13267
- var _d = __read$3(options.dxRange, 2), min = _d[0], max = _d[1];
13268
- nx = clamp$1(nx, min, max);
13269
- if (nx !== min && nx !== max && min !== max) {
13271
+ var _d = __read$3(options.dxRange, 2), min_1 = _d[0], max_1 = _d[1];
13272
+ nx = clamp$1(nx, min_1, max_1);
13273
+ if (nx !== min_1 && nx !== max_1 && min_1 !== max_1) {
13270
13274
  (_a = event.origin) === null || _a === void 0 ? void 0 : _a.preventDefault();
13271
13275
  }
13272
13276
  }
13273
13277
  if (options.dyRange) {
13274
- var _e = __read$3(options.dyRange, 2), min = _e[0], max = _e[1];
13275
- ny = clamp$1(ny, min, max);
13276
- if (ny !== min && ny !== max && min !== max) {
13278
+ var _e = __read$3(options.dyRange, 2), min_2 = _e[0], max_2 = _e[1];
13279
+ ny = clamp$1(ny, min_2, max_2);
13280
+ if (ny !== min_2 && ny !== max_2 && min_2 !== max_2) {
13277
13281
  (_b = event.origin) === null || _b === void 0 ? void 0 : _b.preventDefault();
13278
13282
  }
13279
13283
  }
@@ -13387,11 +13391,11 @@ var SpriteMesh = /** @class */ (function () {
13387
13391
  var item = items[i];
13388
13392
  var texture = item === null || item === void 0 ? void 0 : item.renderer.texture;
13389
13393
  var textureIndex = texture ? textures.indexOf(texture) : -1;
13390
- var data = this.getItemInitData(item, i, pointCount, textureIndex);
13391
- aPointLen += data.aPoint.length;
13392
- indexLen += data.index.length;
13393
- datas.push(data);
13394
- pointCount += data.aPoint.length / 6;
13394
+ var data_1 = this.getItemInitData(item, i, pointCount, textureIndex);
13395
+ aPointLen += data_1.aPoint.length;
13396
+ indexLen += data_1.index.length;
13397
+ datas.push(data_1);
13398
+ pointCount += data_1.aPoint.length / 6;
13395
13399
  this.updateItem(item, true);
13396
13400
  }
13397
13401
  var bundle = {
@@ -13403,10 +13407,10 @@ var SpriteMesh = /** @class */ (function () {
13403
13407
  index: 0,
13404
13408
  };
13405
13409
  var _loop_1 = function (i) {
13406
- var data = datas[i];
13410
+ var data_2 = datas[i];
13407
13411
  Object.keys(bundle).forEach(function (name) {
13408
13412
  var arr = bundle[name];
13409
- var ta = data[name];
13413
+ var ta = data_2[name];
13410
13414
  arr.set(ta, cursor[name]);
13411
13415
  cursor[name] += ta.length;
13412
13416
  });
@@ -13673,14 +13677,14 @@ var SpriteMesh = /** @class */ (function () {
13673
13677
  for (var y = 0; y < row; y++) {
13674
13678
  var base = (y * 2 + x) * 4;
13675
13679
  // @ts-expect-error
13676
- var split = textureSheetAnimation ? [0, 0, 1, 1, splits[0][4]] : splits[y * 2 + x];
13677
- var texOffset = split[4] ? [0, 0, 1, 0, 0, 1, 1, 1] : [0, 1, 0, 0, 1, 1, 1, 0];
13680
+ var split_1 = textureSheetAnimation ? [0, 0, 1, 1, splits[0][4]] : splits[y * 2 + x];
13681
+ var texOffset = split_1[4] ? [0, 0, 1, 0, 0, 1, 1, 1] : [0, 1, 0, 0, 1, 1, 1, 0];
13678
13682
  var dw = ((x + x + 1) / col - 1) / 2;
13679
13683
  var dh = ((y + y + 1) / row - 1) / 2;
13680
- var tox = split[0];
13681
- var toy = split[1];
13682
- var tsx = split[4] ? split[3] : split[2];
13683
- var tsy = split[4] ? split[2] : split[3];
13684
+ var tox = split_1[0];
13685
+ var toy = split_1[1];
13686
+ var tsx = split_1[4] ? split_1[3] : split_1[2];
13687
+ var tsy = split_1[4] ? split_1[2] : split_1[3];
13684
13688
  var origin_1 = [
13685
13689
  originData[0] / col + dw,
13686
13690
  originData[1] / row + dh,
@@ -13777,13 +13781,13 @@ function generateFeatureTexture(engine, feather) {
13777
13781
  }
13778
13782
  else {
13779
13783
  var len = 128;
13780
- var data = new Uint8Array(len);
13784
+ var data_3 = new Uint8Array(len);
13781
13785
  for (var i = 0, s = len - 1; i < len; i++) {
13782
13786
  var p = i / s;
13783
13787
  var val = feather.getValue(p);
13784
- data[i] = Math.round(val * 255);
13788
+ data_3[i] = Math.round(val * 255);
13785
13789
  }
13786
- tex = Texture.createWithData(engine, { width: len, height: 1, data: data }, {
13790
+ tex = Texture.createWithData(engine, { width: len, height: 1, data: data_3 }, {
13787
13791
  name: 'feather',
13788
13792
  format: glContext.LUMINANCE,
13789
13793
  minFilter: glContext.LINEAR,
@@ -13941,22 +13945,22 @@ var SpriteGroup = /** @class */ (function () {
13941
13945
  * 需要则添加到meshToModify数组
13942
13946
  */
13943
13947
  for (var i = 0; i < splits.length; i++) {
13944
- var split = splits[i];
13948
+ var split_1 = splits[i];
13945
13949
  // @ts-expect-error
13946
- var spriteMesh = split.spriteMesh;
13947
- if (split.items.length === 0) {
13950
+ var spriteMesh = split_1.spriteMesh;
13951
+ if (split_1.items.length === 0) {
13948
13952
  throw new Error('split not combined');
13949
13953
  }
13950
- if (split.dirty) {
13951
- var priority = split.indexStart;
13954
+ if (split_1.dirty) {
13955
+ var priority = split_1.indexStart;
13952
13956
  if (spriteMesh.mesh.priority !== priority) {
13953
13957
  spriteMesh.mesh.priority = priority;
13954
13958
  meshToModify.push(spriteMesh.mesh);
13955
13959
  }
13956
- spriteMesh.setItems(split.items.map(function (item) { return item.content; }));
13960
+ spriteMesh.setItems(split_1.items.map(function (item) { return item.content; }));
13957
13961
  }
13958
13962
  spriteMesh.applyChange();
13959
- split.dirty = false;
13963
+ split_1.dirty = false;
13960
13964
  }
13961
13965
  /**
13962
13966
  * 有需要移除的meshSplit 则废弃对应的mesh 保留material
@@ -13964,8 +13968,8 @@ var SpriteGroup = /** @class */ (function () {
13964
13968
  */
13965
13969
  if (splitsToRemove.length) {
13966
13970
  for (var i = 0; i < splitsToRemove.length; i++) {
13967
- var split = splitsToRemove[i];
13968
- var sp = split.spriteMesh;
13971
+ var split_2 = splitsToRemove[i];
13972
+ var sp = split_2.spriteMesh;
13969
13973
  // @ts-expect-error
13970
13974
  var mesh = sp.mesh;
13971
13975
  mesh.dispose({ material: { textures: DestroyOptions.keep } });
@@ -14082,7 +14086,7 @@ var SpriteGroup = /** @class */ (function () {
14082
14086
  addItemWithOrder(items, item, itemSortProperty);
14083
14087
  if (isSprite(item)) {
14084
14088
  var content = item.createContent();
14085
- var split = {
14089
+ var split_4 = {
14086
14090
  indexStart: item.listIndex,
14087
14091
  indexEnd: item.listIndex,
14088
14092
  items: [item],
@@ -14090,21 +14094,21 @@ var SpriteGroup = /** @class */ (function () {
14090
14094
  cacheId: content.renderInfo.cacheId,
14091
14095
  textures: [item.content.renderer.texture],
14092
14096
  };
14093
- splits.unshift(split);
14094
- return [split];
14097
+ splits.unshift(split_4);
14098
+ return [split_4];
14095
14099
  }
14096
14100
  return [];
14097
14101
  }
14098
14102
  var _loop_2 = function (i) {
14099
- var split = splits[i];
14103
+ var split_5 = splits[i];
14100
14104
  var listIndex = item.listIndex;
14101
14105
  if (isSprite(item)) {
14102
14106
  // @ts-expect-error
14103
- if (listIndex <= split.indexEnd) {
14107
+ if (listIndex <= split_5.indexEnd) {
14104
14108
  addItemWithOrder(items, item, itemSortProperty);
14105
14109
  var itemIndex_1 = items.indexOf(item);
14106
- var indexStart = Math.min(itemIndex_1, items.indexOf(split.items[0]));
14107
- var indexEnd = Math.max(itemIndex_1, items.indexOf(split.items[split.items.length - 1]));
14110
+ var indexStart = Math.min(itemIndex_1, items.indexOf(split_5.items[0]));
14111
+ var indexEnd = Math.max(itemIndex_1, items.indexOf(split_5.items[split_5.items.length - 1]));
14108
14112
  var neoSplits_1 = this_2.getMeshSplits(items, indexStart, indexEnd);
14109
14113
  var neoSplitIndex_1 = neoSplits_1.findIndex(function (split) { return split.items.includes(item); });
14110
14114
  if (neoSplits_1.length === 2) {
@@ -14112,14 +14116,14 @@ var SpriteGroup = /** @class */ (function () {
14112
14116
  //1 or 0
14113
14117
  Object.keys(neoSplits_1[1 - neoSplitIndex_1]).forEach(function (key) {
14114
14118
  // @ts-expect-error
14115
- split[key] = neoSplits_1[1 - neoSplitIndex_1][key];
14119
+ split_5[key] = neoSplits_1[1 - neoSplitIndex_1][key];
14116
14120
  });
14117
14121
  return { value: [neoSplits_1[neoSplitIndex_1]] };
14118
14122
  }
14119
14123
  else if (neoSplits_1.length === 3) {
14120
14124
  Object.keys(neoSplits_1[0]).forEach(function (key) {
14121
14125
  // @ts-expect-error
14122
- split[key] = neoSplits_1[0][key];
14126
+ split_5[key] = neoSplits_1[0][key];
14123
14127
  });
14124
14128
  splits.splice(i + 1, 0, neoSplits_1[1], neoSplits_1[2]);
14125
14129
  if (neoSplitIndex_1 !== 1) {
@@ -14133,25 +14137,25 @@ var SpriteGroup = /** @class */ (function () {
14133
14137
  //todo add case
14134
14138
  Object.keys(neoSplits_1[0]).forEach(function (key) {
14135
14139
  // @ts-expect-error
14136
- split[key] = neoSplits_1[0][key];
14140
+ split_5[key] = neoSplits_1[0][key];
14137
14141
  });
14138
14142
  return { value: [] };
14139
14143
  }
14140
14144
  }
14141
14145
  else {
14142
- if (listIndex < split.indexStart || listIndex === split.indexEnd) {
14146
+ if (listIndex < split_5.indexStart || listIndex === split_5.indexEnd) {
14143
14147
  addItemWithOrder(items, item, itemSortProperty);
14144
14148
  return { value: [] };
14145
14149
  // @ts-expect-error
14146
14150
  }
14147
- else if (listIndex < split.indexEnd) {
14151
+ else if (listIndex < split_5.indexEnd) {
14148
14152
  addItemWithOrder(items, item, itemSortProperty);
14149
- var lastItem = split.items[split.items.length - 1];
14153
+ var lastItem = split_5.items[split_5.items.length - 1];
14150
14154
  var endIndex = items.indexOf(lastItem);
14151
- var neoSplits_2 = this_2.getMeshSplits(items, items.indexOf(split.items[0]), endIndex);
14155
+ var neoSplits_2 = this_2.getMeshSplits(items, items.indexOf(split_5.items[0]), endIndex);
14152
14156
  Object.keys(neoSplits_2[0]).forEach(function (key) {
14153
14157
  // @ts-expect-error
14154
- split[key] = neoSplits_2[0][key];
14158
+ split_5[key] = neoSplits_2[0][key];
14155
14159
  });
14156
14160
  if (neoSplits_2.length === 2) {
14157
14161
  splits.splice(i + 1, 0, neoSplits_2[1]);
@@ -14212,10 +14216,10 @@ var SpriteGroup = /** @class */ (function () {
14212
14216
  * 遍历this.meshSplits,找到元素的listIndex在split的indexStart和indexEnd范围内的第一个meshSplit
14213
14217
  */
14214
14218
  for (var i = 0; i < splits.length; i++) {
14215
- var split = splits[i];
14219
+ var split_6 = splits[i];
14216
14220
  // @ts-expect-error
14217
- if (split.indexStart <= item.listIndex && split.indexEnd >= item.listIndex) {
14218
- targetSplit = split;
14221
+ if (split_6.indexStart <= item.listIndex && split_6.indexEnd >= item.listIndex) {
14222
+ targetSplit = split_6;
14219
14223
  targetSplitIndex = i;
14220
14224
  break;
14221
14225
  }
@@ -14325,8 +14329,8 @@ var SpriteGroup = /** @class */ (function () {
14325
14329
  // FIXME: 可选性
14326
14330
  var targetSplitIndex = void 0;
14327
14331
  for (var i = 0; i < splits.length; i++) {
14328
- var split = splits[i];
14329
- if (split.items.includes(item)) {
14332
+ var split_7 = splits[i];
14333
+ if (split_7.items.includes(item)) {
14330
14334
  targetSplitIndex = i;
14331
14335
  break;
14332
14336
  }
@@ -14944,7 +14948,6 @@ var SpriteItem = /** @class */ (function (_super) {
14944
14948
  ret.texOffset = [0, 0, 1, 1];
14945
14949
  }
14946
14950
  ret.visible = this.vfxItem.contentVisible;
14947
- // 图层元素作为父节点时,除了k的大小变换,自身的尺寸也需要传递给子元素,子元素可以通过startSize读取
14948
14951
  ret.startSize = this.startSize;
14949
14952
  return ret;
14950
14953
  };
@@ -15042,7 +15045,9 @@ var SpriteVFXItem = /** @class */ (function (_super) {
15042
15045
  };
15043
15046
  SpriteVFXItem.prototype.doCreateContent = function (composition) {
15044
15047
  var emptyTexture = composition.getRendererOptions().emptyTexture;
15045
- return new SpriteItem(this.sprite, { emptyTexture: emptyTexture }, this);
15048
+ var content = new SpriteItem(this.sprite, { emptyTexture: emptyTexture }, this);
15049
+ content.getRenderData(0, true);
15050
+ return content;
15046
15051
  };
15047
15052
  SpriteVFXItem.prototype.createWireframeMesh = function (item, color) {
15048
15053
  var spMesh = new SpriteMesh(this.composition.getEngine(), __assign$1({ wireframe: true }, item.renderInfo), this.composition);
@@ -15476,10 +15481,10 @@ var ParticleMesh = /** @class */ (function () {
15476
15481
  var index = geometry.getIndexData();
15477
15482
  for (var i = 0; i < names.length; i++) {
15478
15483
  var name_1 = names[i];
15479
- var data = geometry.getAttributeData(name_1);
15480
- if (data) {
15484
+ var data_1 = geometry.getAttributeData(name_1);
15485
+ if (data_1) {
15481
15486
  // @ts-expect-error
15482
- geometry.setAttributeData(name_1, new data.constructor(0));
15487
+ geometry.setAttributeData(name_1, new data_1.constructor(0));
15483
15488
  }
15484
15489
  }
15485
15490
  // @ts-expect-error
@@ -16854,10 +16859,10 @@ function getGeometryTriangles(geometry, options) {
16854
16859
  var segment = segments[i];
16855
16860
  var p0 = points[i];
16856
16861
  var p1 = points[i + 1] || points[0];
16857
- var keys = segment;
16862
+ var keys_1 = segment;
16858
16863
  var point = [0, 0];
16859
- for (var j = 0; j < keys.length - 1; j++) {
16860
- var key = keys[j];
16864
+ for (var j = 0; j < keys_1.length - 1; j++) {
16865
+ var key = keys_1[j];
16861
16866
  getBezier2DValue(point, key, p0, p1, p0[4], p0[5], p1[2], p1[3]);
16862
16867
  setPoint(point[0], point[1]);
16863
16868
  }
@@ -16916,11 +16921,11 @@ function getGeometryByShape(shape, uvTransform) {
16916
16921
  var index = 0;
16917
16922
  for (var i = 0; i < geometries.length; i++) {
16918
16923
  var geometry = geometries[i];
16919
- var data = getGeometryTriangles(geometry, { indexBase: indexBase, uvTransform: uvTransform });
16920
- indexBase += data.aPoint.length / 5;
16921
- datas.push(data);
16922
- aPoint += data.aPoint.length;
16923
- index += data.index.length;
16924
+ var data_1 = getGeometryTriangles(geometry, { indexBase: indexBase, uvTransform: uvTransform });
16925
+ indexBase += data_1.aPoint.length / 5;
16926
+ datas.push(data_1);
16927
+ aPoint += data_1.aPoint.length;
16928
+ index += data_1.index.length;
16924
16929
  }
16925
16930
  if (datas.length === 1) {
16926
16931
  return datas[0];
@@ -16929,11 +16934,11 @@ function getGeometryByShape(shape, uvTransform) {
16929
16934
  var indexData = new Uint16Array(index);
16930
16935
  // @ts-expect-error
16931
16936
  for (var i = 0, pointIndex = 0, idx = 0; i < datas[i]; i++) {
16932
- var data = datas[i];
16933
- aPointData.set(data.aPoint, pointIndex);
16934
- pointIndex += data.aPoint.length;
16935
- indexData.set(data.index, idx);
16936
- idx += data.index.length;
16937
+ var data_2 = datas[i];
16938
+ aPointData.set(data_2.aPoint, pointIndex);
16939
+ pointIndex += data_2.aPoint.length;
16940
+ indexData.set(data_2.index, idx);
16941
+ idx += data_2.index.length;
16937
16942
  }
16938
16943
  return {
16939
16944
  aPoint: aPointData,
@@ -17244,10 +17249,10 @@ var TrailMesh = /** @class */ (function () {
17244
17249
  var pointCountPerTrail = this.pointCountPerTrail;
17245
17250
  if (index >= 0 && index < pointCountPerTrail) {
17246
17251
  var startIndex = (trail * pointCountPerTrail + index) * 24 + 8;
17247
- var data = this.geometry.getAttributeData('aColor');
17248
- out.x = data[startIndex];
17249
- out.y = data[1 + startIndex];
17250
- out.z = data[2 + startIndex];
17252
+ var data_1 = this.geometry.getAttributeData('aColor');
17253
+ out.x = data_1[startIndex];
17254
+ out.y = data_1[1 + startIndex];
17255
+ out.z = data_1[2 + startIndex];
17251
17256
  return out;
17252
17257
  }
17253
17258
  };
@@ -18653,14 +18658,14 @@ var TextMesh = /** @class */ (function (_super) {
18653
18658
  for (var y_1 = 0; y_1 < row; y_1++) {
18654
18659
  var base = (y_1 * 2 + x_1) * 4;
18655
18660
  // @ts-expect-error
18656
- var split = textureSheetAnimation ? [0, 0, 1, 1, splits[0][4]] : splits[y_1 * 2 + x_1];
18657
- var texOffset = split[4] ? [0, 0, 1, 0, 0, 1, 1, 1] : [0, 1, 0, 0, 1, 1, 1, 0];
18661
+ var split_1 = textureSheetAnimation ? [0, 0, 1, 1, splits[0][4]] : splits[y_1 * 2 + x_1];
18662
+ var texOffset = split_1[4] ? [0, 0, 1, 0, 0, 1, 1, 1] : [0, 1, 0, 0, 1, 1, 1, 0];
18658
18663
  var dw = ((x_1 + x_1 + 1) / col - 1) / 2;
18659
18664
  var dh = ((y_1 + y_1 + 1) / row - 1) / 2;
18660
- var tox = split[0];
18661
- var toy = split[1];
18662
- var tsx = split[4] ? split[3] : split[2];
18663
- var tsy = split[4] ? split[2] : split[3];
18665
+ var tox = split_1[0];
18666
+ var toy = split_1[1];
18667
+ var tsx = split_1[4] ? split_1[3] : split_1[2];
18668
+ var tsy = split_1[4] ? split_1[2] : split_1[3];
18664
18669
  var origin_1 = [
18665
18670
  originData[0] / col + dw,
18666
18671
  originData[1] / row + dh,
@@ -21380,8 +21385,9 @@ var Camera = /** @class */ (function () {
21380
21385
  Camera.prototype.getInverseVPRatio = function (z) {
21381
21386
  var pos = new Vector3(0, 0, z);
21382
21387
  var mat = this.getViewProjectionMatrix();
21383
- var nz = pos.applyMatrix(mat).z;
21384
- return new Vector3(1, 1, nz).applyMatrix(mat);
21388
+ var inverseVP = this.getInverseViewProjectionMatrix();
21389
+ var nz = mat.projectPoint(pos).z;
21390
+ return inverseVP.projectPoint(new Vector3(1, 1, nz));
21385
21391
  };
21386
21392
  /**
21387
21393
  * 设置相机的旋转四元数
@@ -21393,7 +21399,6 @@ var Camera = /** @class */ (function () {
21393
21399
  this.dirty = true;
21394
21400
  }
21395
21401
  else {
21396
- this.options.quat;
21397
21402
  if (!this.options.quat.equals(value)) {
21398
21403
  this.options.quat.copyFrom(value);
21399
21404
  this.dirty = true;
@@ -21570,7 +21575,7 @@ var filters = {
21570
21575
  * Name: @galacean/effects-specification
21571
21576
  * Description: Galacean Effects JSON Specification
21572
21577
  * Author: Ant Group CO., Ltd.
21573
- * Version: v1.1.0-alpha.0
21578
+ * Version: v1.1.0
21574
21579
  */
21575
21580
 
21576
21581
  /*********************************************/
@@ -23340,13 +23345,13 @@ var CompositionSourceManager = /** @class */ (function () {
23340
23345
  if (renderContent.renderer) {
23341
23346
  renderContent.renderer = _this.changeTex(renderContent.renderer);
23342
23347
  _this.processMask(renderContent.renderer);
23343
- var split = renderContent.splits && !renderContent.textureSheetAnimation && renderContent.splits[0];
23348
+ var split_1 = renderContent.splits && !renderContent.textureSheetAnimation && renderContent.splits[0];
23344
23349
  if (Number.isInteger(renderContent.renderer.shape)) {
23345
23350
  // TODO: scene.shapes 类型问题?
23346
- renderContent.renderer.shape = getGeometryByShape((_a = _this.jsonScene) === null || _a === void 0 ? void 0 : _a.shapes[renderContent.renderer.shape], split);
23351
+ renderContent.renderer.shape = getGeometryByShape((_a = _this.jsonScene) === null || _a === void 0 ? void 0 : _a.shapes[renderContent.renderer.shape], split_1);
23347
23352
  }
23348
23353
  else if (renderContent.renderer.shape && isObject(renderContent.renderer.shape)) {
23349
- renderContent.renderer.shape = getGeometryByShape(renderContent.renderer.shape, split);
23354
+ renderContent.renderer.shape = getGeometryByShape(renderContent.renderer.shape, split_1);
23350
23355
  }
23351
23356
  }
23352
23357
  else {
@@ -23358,14 +23363,14 @@ var CompositionSourceManager = /** @class */ (function () {
23358
23363
  if (renderContent.filter) {
23359
23364
  renderContent.filter = __assign$1({}, renderContent.filter);
23360
23365
  }
23361
- 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;
23366
+ 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;
23362
23367
  // FIXME: specification 下定义的 Item 不存在 refCount 类型定义
23363
23368
  // @ts-expect-error
23364
23369
  var refCount = item.refCount;
23365
23370
  var _c = _this.jsonScene.plugins, plugins = _c === void 0 ? [] : _c;
23366
23371
  option.name = name_1;
23367
23372
  option.delay = delay;
23368
- option.id = id;
23373
+ option.id = id_1;
23369
23374
  if (parentId) {
23370
23375
  option.parentId = parentId;
23371
23376
  }
@@ -23733,16 +23738,17 @@ var AssetManager = /** @class */ (function () {
23733
23738
  };
23734
23739
  AssetManager.prototype.processBins = function (bins) {
23735
23740
  return __awaiter(this, void 0, void 0, function () {
23736
- var renderLevel, jobs;
23741
+ var renderLevel, baseUrl, jobs;
23737
23742
  var _this = this;
23738
23743
  return __generator(this, function (_a) {
23739
23744
  renderLevel = this.options.renderLevel;
23745
+ baseUrl = this.baseUrl;
23740
23746
  jobs = bins.map(function (bin) {
23741
23747
  if (bin instanceof ArrayBuffer) {
23742
23748
  return bin;
23743
23749
  }
23744
23750
  if (passRenderLevel(bin.renderLevel, renderLevel)) {
23745
- return _this.loadBins(bin.url);
23751
+ return _this.loadBins(new URL(bin.url, baseUrl).href);
23746
23752
  }
23747
23753
  throw new Error("Invalid bins source: ".concat(JSON.stringify(bins)));
23748
23754
  });
@@ -23760,13 +23766,14 @@ var AssetManager = /** @class */ (function () {
23760
23766
  return [2 /*return*/];
23761
23767
  }
23762
23768
  jobs = fonts.map(function (font) { return __awaiter(_this, void 0, void 0, function () {
23763
- var fontFace;
23769
+ var url, fontFace;
23764
23770
  var _a;
23765
23771
  return __generator(this, function (_b) {
23766
23772
  switch (_b.label) {
23767
23773
  case 0:
23768
23774
  if (!(font.fontURL && !AssetManager.fonts.has(font.fontFamily))) return [3 /*break*/, 4];
23769
- fontFace = new FontFace((_a = font.fontFamily) !== null && _a !== void 0 ? _a : '', 'url(' + font.fontURL + ')');
23775
+ url = new URL(font.fontURL, this.baseUrl).href;
23776
+ fontFace = new FontFace((_a = font.fontFamily) !== null && _a !== void 0 ? _a : '', 'url(' + url + ')');
23770
23777
  _b.label = 1;
23771
23778
  case 1:
23772
23779
  _b.trys.push([1, 3, , 4]);
@@ -23779,7 +23786,7 @@ var AssetManager = /** @class */ (function () {
23779
23786
  return [3 /*break*/, 4];
23780
23787
  case 3:
23781
23788
  _b.sent();
23782
- logger.warn("Invalid fonts source: ".concat(JSON.stringify(font.fontURL)));
23789
+ logger.warn("Invalid fonts source: ".concat(JSON.stringify(url)));
23783
23790
  return [3 /*break*/, 4];
23784
23791
  case 4: return [2 /*return*/];
23785
23792
  }
@@ -23974,14 +23981,14 @@ var AssetManager = /** @class */ (function () {
23974
23981
  }());
23975
23982
  function fixOldImageUsage(usedImages, compositions, imgUsage, images, renderLevel) {
23976
23983
  for (var i = 0; i < compositions.length; i++) {
23977
- var id = compositions[i].id;
23978
- var ids = imgUsage[id];
23984
+ var id_1 = compositions[i].id;
23985
+ var ids = imgUsage[id_1];
23979
23986
  if (ids) {
23980
23987
  for (var j = 0; j < ids.length; j++) {
23981
- var id_1 = ids[j];
23982
- var tag = images[id_1].renderLevel;
23988
+ var id_2 = ids[j];
23989
+ var tag = images[id_2].renderLevel;
23983
23990
  if (passRenderLevel(tag, renderLevel)) {
23984
- usedImages[id_1] = true;
23991
+ usedImages[id_2] = true;
23985
23992
  }
23986
23993
  }
23987
23994
  }
@@ -23992,7 +23999,7 @@ function createTextureOptionsBySource(image, sourceFrom) {
23992
23999
  return image.source;
23993
24000
  }
23994
24001
  else if (image instanceof HTMLImageElement ||
23995
- image instanceof HTMLCanvasElement) {
24002
+ isCanvas(image)) {
23996
24003
  return {
23997
24004
  image: image,
23998
24005
  sourceType: TextureSourceType.image,
@@ -24029,6 +24036,11 @@ function createTextureOptionsBySource(image, sourceFrom) {
24029
24036
  }
24030
24037
  throw new Error('Invalid texture options');
24031
24038
  }
24039
+ function isCanvas(canvas) {
24040
+ var _a;
24041
+ // 小程序 Canvas 无法使用 instanceof HTMLCanvasElement 判断
24042
+ return typeof canvas === 'object' && canvas !== null && ((_a = canvas.tagName) === null || _a === void 0 ? void 0 : _a.toUpperCase()) === 'CANVAS';
24043
+ }
24032
24044
 
24033
24045
  var CompVFXItem = /** @class */ (function (_super) {
24034
24046
  __extends(CompVFXItem, _super);
@@ -26257,10 +26269,10 @@ var ThreeTexture = /** @class */ (function (_super) {
26257
26269
  var texture = undefined;
26258
26270
  this.sourceType = sourceType;
26259
26271
  if (sourceType === TextureSourceType.data) {
26260
- var data = options.data;
26261
- texture = new THREE.DataTexture(data.data, data.width, data.height, format, type, mapping, wrapS, wrapT, magFilter, minFilter);
26262
- this.width = data.width;
26263
- this.height = data.height;
26272
+ var data_1 = options.data;
26273
+ texture = new THREE.DataTexture(data_1.data, data_1.width, data_1.height, format, type, mapping, wrapS, wrapT, magFilter, minFilter);
26274
+ this.width = data_1.width;
26275
+ this.height = data_1.height;
26264
26276
  }
26265
26277
  else if (sourceType === TextureSourceType.image) {
26266
26278
  var image = options.image;
@@ -26292,10 +26304,10 @@ var ThreeTexture = /** @class */ (function (_super) {
26292
26304
  texture = new THREE.VideoTexture(options.video, mapping, wrapS, wrapT, magFilter, minFilter, format, type);
26293
26305
  }
26294
26306
  else if (sourceType === TextureSourceType.framebuffer) {
26295
- var data = options.data;
26296
- if (data) {
26297
- var width = (_a = data.width) !== null && _a !== void 0 ? _a : 0;
26298
- var height = (_b = data.height) !== null && _b !== void 0 ? _b : 0;
26307
+ var data_2 = options.data;
26308
+ if (data_2) {
26309
+ var width = (_a = data_2.width) !== null && _a !== void 0 ? _a : 0;
26310
+ var height = (_b = data_2.height) !== null && _b !== void 0 ? _b : 0;
26299
26311
  texture = new THREE.FramebufferTexture(width, height, format);
26300
26312
  this.width = width;
26301
26313
  this.height = height;
@@ -26431,11 +26443,11 @@ var ThreeGeometry = /** @class */ (function (_super) {
26431
26443
  if (attributes[dataSource] === undefined) {
26432
26444
  _this.setAttributeType(dataSource, attr, geometry, attributes, props.maxVertex);
26433
26445
  }
26434
- var size = attr.size, offset = attr.offset, normalize = attr.normalize;
26446
+ var size = attr.size, offset = attr.offset, normalize_1 = attr.normalize;
26435
26447
  var dataSourceAttribute = attributes[dataSource];
26436
26448
  var buffer = dataSourceAttribute.buffer;
26437
26449
  var dataLength = dataSourceAttribute.dataLength;
26438
- var attribute = new THREE.InterleavedBufferAttribute(buffer, size, (offset !== null && offset !== void 0 ? offset : 0) / dataLength, normalize);
26450
+ var attribute = new THREE.InterleavedBufferAttribute(buffer, size, (offset !== null && offset !== void 0 ? offset : 0) / dataLength, normalize_1);
26439
26451
  geometry.setAttribute(name, attribute);
26440
26452
  attributes[name] = {
26441
26453
  buffer: buffer,
@@ -26926,7 +26938,7 @@ Geometry.create = function (engine, options) {
26926
26938
  Mesh.create = function (engine, props) {
26927
26939
  return new ThreeMesh(engine, props);
26928
26940
  };
26929
- var version = "1.3.0-alpha.0";
26941
+ var version = "1.3.0";
26930
26942
  logger.info('THREEJS plugin version: ' + version);
26931
26943
 
26932
26944
  export { AbstractPlugin, AssetManager, BYTES_TYPE_MAP, BezierSegments, COMPRESSED_TEXTURE, CONSTANT_MAP_BLEND, CONSTANT_MAP_DEPTH, CONSTANT_MAP_STENCIL_FUNC, CONSTANT_MAP_STENCIL_OP, COPY_FRAGMENT_SHADER, COPY_MESH_SHADER_ID, COPY_VERTEX_SHADER, CalculateItem, CalculateLoader, CalculateVFXItem, Camera, CameraController, CameraVFXItem, CameraVFXItemLoader, Composition, CompositionSourceManager, CurveValue, DEFAULT_FONTS, DestroyOptions, Downloader, EFFECTS_COPY_MESH_NAME, EVENT_TYPE_CLICK, EVENT_TYPE_TOUCH_END, EVENT_TYPE_TOUCH_MOVE, EVENT_TYPE_TOUCH_START, Engine, EventSystem, FILTER_NAME_NONE, FilterMode, FilterSpriteVFXItem, Float16ArrayWrapper, FrameBuffer, GLSLVersion, GPUCapability, Geometry, GlobalUniforms, GradientValue, HELP_LINK, HitTestType, InteractBehavior$1 as InteractBehavior, InteractItem, InteractLoader, InteractMesh, InteractVFXItem, Item, KTXTexture, LineSegments, LinearValue, Material, MaterialDataBlock, MaterialRenderType, Mesh, OrderType, PLAYER_OPTIONS_ENV_EDITOR, POST_PROCESS_SETTINGS, ParticleLoader, ParticleMesh, ParticleSystem, ParticleVFXItem, PassTextureCache, PathSegments, PluginSystem, QCanvasViewer, QText, QTextWrapMode, RENDER_PASS_NAME_PREFIX, RENDER_PREFER_LOOKUP_TEXTURE, RUNTIME_ENV, RandomSetValue, RandomValue, RandomVectorValue, RenderBuffer, RenderFrame, RenderPass, RenderPassAttachmentStorageType, RenderPassDestroyAttachmentType, RenderPassPriorityNormal, RenderPassPriorityPostprocess, RenderPassPriorityPrepare, RenderTargetHandle, RenderTextureFormat, Renderer, SEMANTIC_MAIN_PRE_COLOR_ATTACHMENT_0, SEMANTIC_MAIN_PRE_COLOR_ATTACHMENT_SIZE_0, SEMANTIC_PRE_COLOR_ATTACHMENT_0, SEMANTIC_PRE_COLOR_ATTACHMENT_SIZE_0, SPRITE_VERTEX_STRIDE, SemanticMap, Shader, ShaderCompileResultStatus, ShaderType, SpriteItem, SpriteLoader, SpriteMesh, SpriteVFXItem, StaticValue, TEMPLATE_USE_OFFSCREEN_CANVAS, TEXTURE_UNIFORM_MAP, TextItem, TextLoader, TextMesh, TextVFXItem, Texture, TextureFactory, TextureLoadAction, TextureSourceType, TextureStoreAction, ThreeComposition, ThreeDisplayObject, ThreeMaterial, ThreeTexture, Ticker, TimelineComponent, Transform, VFXItem, ValueGetter, addByOrder, addItem, addItemWithOrder, alphaFrameFrag, alphaMaskFrag, assertExist, asserts, blend, bloomMixVert, bloomThresholdVert, calculateTranslation, cameraMove_frag as cameraMoveFrag, cameraMoveVert, canvasPool, colorGradingFrag, colorStopsFromGradient, colorToArr$1 as colorToArr, combineImageTemplate, combineImageTemplate1, combineImageTemplate1Async, combineImageTemplate2, combineImageTemplate2Async, combineImageTemplateAsync, compatible_frag as compatibleFrag, compatible_vert as compatibleVert, convertAnchor, copyFrag, createCopyShader, createFilter, createFilterShaders, createGLContext, createKeyFrameMeta, createShaderWithMarcos, createShape, createVFXItem, createValueGetter, deepClone, defaultGlobalVolume, defaultPlugins, delayFrag, deserializeMipmapTexture, distortionFrag, distortionVert, earcut, enlargeBuffer, ensureVec3, filters, findPreviousRenderPass, gaussianDown_frag as gaussianDownFrag, gaussianDownHFrag, gaussianDownVFrag, gaussianUpFrag, generateEmptyTypedArray, generateHalfFloatTexture, getBackgroundImage, getColorFromGradientStops, getConfig, getDefaultTemplateCanvasPool, getDefaultTextureFactory, getGeometryByShape, getGeometryTriangles, getImageItemRenderInfo, getKTXTextureOptions, getKeyFrameMetaByRawValue, getParticleMeshShader, getPixelRatio, getPreMultiAlpha, getStandardComposition, getStandardImage, getStandardItem, getStandardJSON, getTextureSize, glContext, gpuTimer, imageDataFromColor, imageDataFromGradient, initErrors, initGLContext, integrate, interpolateColor, isAndroid, isArray, isFunction, isIOS, isObject, isScene, isSimulatorCellPhone, isString, isUniformStruct, isUniformStructArray, isWebGL2, item_define as itemDefine, itemFrag, itemFrameFrag, itemVert, loadBinary, loadBlob, loadImage, loadMedia, loadVideo, loadWebPOptional, logger, index as math, maxSpriteMeshItemCount, maxSpriteTextureCount, modifyMaxKeyframeShader, nearestPowerOfTwo, noop, parsePercent$1 as parsePercent, particleFrag, particleOriginTranslateMap, particleVert, pluginLoaderMap, random, registerFilter, registerFilters, registerPlugin, removeItem, requestAsync, rotateVec2, screenMeshVert, setBlendMode, setConfig, setDefaultTextureFactory, setMaskMode, setMaxSpriteMeshItemCount, setRayFromCamera, setSideMode, setSpriteMeshMaxFragmentTextures, setSpriteMeshMaxItemCountByGPU, setUniformValue, sortByOrder, index$1 as spec, spriteMeshShaderFromFilter, spriteMeshShaderFromRenderInfo, spriteMeshShaderIdFromRenderInfo, thresholdFrag, throwDestroyedError, trailVert, translatePoint, trianglesFromRect, unregisterPlugin, valIfUndefined, value, valueDefine, vecAssign, vecFill, vecMulCombine, vecNormalize, version };