@galacean/effects-core 2.0.0-alpha.3 → 2.0.0-alpha.5

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.js CHANGED
@@ -3,7 +3,7 @@
3
3
  * Description: Galacean Effects runtime core for the web
4
4
  * Author: Ant Group CO., Ltd.
5
5
  * Contributors: 燃然,飂兮,十弦,云垣,茂安,意绮
6
- * Version: v2.0.0-alpha.3
6
+ * Version: v2.0.0-alpha.5
7
7
  */
8
8
 
9
9
  'use strict';
@@ -126,7 +126,7 @@ function __read$3(o, n) {
126
126
  return ar;
127
127
  }
128
128
 
129
- function __spreadArray$2(to, from, pack) {
129
+ function __spreadArray$3(to, from, pack) {
130
130
  if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {
131
131
  if (ar || !(i in from)) {
132
132
  if (!ar) ar = Array.prototype.slice.call(from, 0, i);
@@ -144,20 +144,20 @@ typeof SuppressedError === "function" ? SuppressedError : function (error, suppr
144
144
  // Unique ID creation requires a high quality random # generator. In the browser we therefore
145
145
  // require the crypto API and do not support built-in fallback to lower quality random number
146
146
  // generators (like Math.random()).
147
- let getRandomValues;
148
- const rnds8 = new Uint8Array(16);
149
- function rng() {
147
+ let getRandomValues$1;
148
+ const rnds8$1 = new Uint8Array(16);
149
+ function rng$1() {
150
150
  // lazy load so that environments that need to polyfill have a chance to do so
151
- if (!getRandomValues) {
151
+ if (!getRandomValues$1) {
152
152
  // getRandomValues needs to be invoked in a context where "this" is a Crypto implementation.
153
- getRandomValues = typeof crypto !== 'undefined' && crypto.getRandomValues && crypto.getRandomValues.bind(crypto);
153
+ getRandomValues$1 = typeof crypto !== 'undefined' && crypto.getRandomValues && crypto.getRandomValues.bind(crypto);
154
154
 
155
- if (!getRandomValues) {
155
+ if (!getRandomValues$1) {
156
156
  throw new Error('crypto.getRandomValues() not supported. See https://github.com/uuidjs/uuid#getrandomvalues-not-supported');
157
157
  }
158
158
  }
159
159
 
160
- return getRandomValues(rnds8);
160
+ return getRandomValues$1(rnds8$1);
161
161
  }
162
162
 
163
163
  /**
@@ -165,30 +165,30 @@ function rng() {
165
165
  * XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX
166
166
  */
167
167
 
168
- const byteToHex = [];
168
+ const byteToHex$2 = [];
169
169
 
170
170
  for (let i = 0; i < 256; ++i) {
171
- byteToHex.push((i + 0x100).toString(16).slice(1));
171
+ byteToHex$2.push((i + 0x100).toString(16).slice(1));
172
172
  }
173
173
 
174
- function unsafeStringify(arr, offset = 0) {
174
+ function unsafeStringify$1(arr, offset = 0) {
175
175
  // Note: Be careful editing this code! It's been tuned for performance
176
176
  // and works in ways you may not expect. See https://github.com/uuidjs/uuid/pull/434
177
- return byteToHex[arr[offset + 0]] + byteToHex[arr[offset + 1]] + byteToHex[arr[offset + 2]] + byteToHex[arr[offset + 3]] + '-' + byteToHex[arr[offset + 4]] + byteToHex[arr[offset + 5]] + '-' + byteToHex[arr[offset + 6]] + byteToHex[arr[offset + 7]] + '-' + byteToHex[arr[offset + 8]] + byteToHex[arr[offset + 9]] + '-' + byteToHex[arr[offset + 10]] + byteToHex[arr[offset + 11]] + byteToHex[arr[offset + 12]] + byteToHex[arr[offset + 13]] + byteToHex[arr[offset + 14]] + byteToHex[arr[offset + 15]];
177
+ return byteToHex$2[arr[offset + 0]] + byteToHex$2[arr[offset + 1]] + byteToHex$2[arr[offset + 2]] + byteToHex$2[arr[offset + 3]] + '-' + byteToHex$2[arr[offset + 4]] + byteToHex$2[arr[offset + 5]] + '-' + byteToHex$2[arr[offset + 6]] + byteToHex$2[arr[offset + 7]] + '-' + byteToHex$2[arr[offset + 8]] + byteToHex$2[arr[offset + 9]] + '-' + byteToHex$2[arr[offset + 10]] + byteToHex$2[arr[offset + 11]] + byteToHex$2[arr[offset + 12]] + byteToHex$2[arr[offset + 13]] + byteToHex$2[arr[offset + 14]] + byteToHex$2[arr[offset + 15]];
178
178
  }
179
179
 
180
- const randomUUID = typeof crypto !== 'undefined' && crypto.randomUUID && crypto.randomUUID.bind(crypto);
181
- var native = {
182
- randomUUID
180
+ const randomUUID$1 = typeof crypto !== 'undefined' && crypto.randomUUID && crypto.randomUUID.bind(crypto);
181
+ var native$1 = {
182
+ randomUUID: randomUUID$1
183
183
  };
184
184
 
185
- function v4(options, buf, offset) {
186
- if (native.randomUUID && !buf && !options) {
187
- return native.randomUUID();
185
+ function v4$1(options, buf, offset) {
186
+ if (native$1.randomUUID && !buf && !options) {
187
+ return native$1.randomUUID();
188
188
  }
189
189
 
190
190
  options = options || {};
191
- const rnds = options.random || (options.rng || rng)(); // Per 4.4, set bits for version and `clock_seq_hi_and_reserved`
191
+ const rnds = options.random || (options.rng || rng$1)(); // Per 4.4, set bits for version and `clock_seq_hi_and_reserved`
192
192
 
193
193
  rnds[6] = rnds[6] & 0x0f | 0x40;
194
194
  rnds[8] = rnds[8] & 0x3f | 0x80; // Copy bytes to buffer, if provided
@@ -203,7 +203,7 @@ function v4(options, buf, offset) {
203
203
  return buf;
204
204
  }
205
205
 
206
- return unsafeStringify(rnds);
206
+ return unsafeStringify$1(rnds);
207
207
  }
208
208
 
209
209
  function addItem(arr, value) {
@@ -2190,7 +2190,7 @@ var __read$2 = (undefined && undefined.__read) || function (o, n) {
2190
2190
  }
2191
2191
  return ar;
2192
2192
  };
2193
- var __spreadArray$1 = (undefined && undefined.__spreadArray) || function (to, from, pack) {
2193
+ var __spreadArray$2 = (undefined && undefined.__spreadArray) || function (to, from, pack) {
2194
2194
  if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {
2195
2195
  if (ar || !(i in from)) {
2196
2196
  if (!ar) ar = Array.prototype.slice.call(from, 0, i);
@@ -2507,7 +2507,7 @@ var Matrix4 = /** @class */ (function () {
2507
2507
  * @returns 复制结果
2508
2508
  */
2509
2509
  Matrix4.prototype.copyFrom = function (m) {
2510
- this.elements = __spreadArray$1([], __read$2(m.elements), false);
2510
+ this.elements = __spreadArray$2([], __read$2(m.elements), false);
2511
2511
  return this;
2512
2512
  };
2513
2513
  /**
@@ -3036,7 +3036,7 @@ var Matrix4 = /** @class */ (function () {
3036
3036
  * @returns
3037
3037
  */
3038
3038
  Matrix4.prototype.toArray = function () {
3039
- return __spreadArray$1([], __read$2(this.elements), false);
3039
+ return __spreadArray$2([], __read$2(this.elements), false);
3040
3040
  };
3041
3041
  Matrix4.prototype.fill = function (array, offset) {
3042
3042
  if (offset === void 0) { offset = 0; }
@@ -4289,7 +4289,7 @@ var __read$1 = (undefined && undefined.__read) || function (o, n) {
4289
4289
  }
4290
4290
  return ar;
4291
4291
  };
4292
- var __spreadArray = (undefined && undefined.__spreadArray) || function (to, from, pack) {
4292
+ var __spreadArray$1 = (undefined && undefined.__spreadArray) || function (to, from, pack) {
4293
4293
  if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {
4294
4294
  if (ar || !(i in from)) {
4295
4295
  if (!ar) ar = Array.prototype.slice.call(from, 0, i);
@@ -4476,7 +4476,7 @@ var Matrix3 = /** @class */ (function () {
4476
4476
  * @returns 复制结果
4477
4477
  */
4478
4478
  Matrix3.prototype.copyFrom = function (m) {
4479
- this.elements = __spreadArray([], __read$1(m.elements), false);
4479
+ this.elements = __spreadArray$1([], __read$1(m.elements), false);
4480
4480
  return this;
4481
4481
  };
4482
4482
  /**
@@ -4692,7 +4692,7 @@ var Matrix3 = /** @class */ (function () {
4692
4692
  * @returns
4693
4693
  */
4694
4694
  Matrix3.prototype.toArray = function () {
4695
- return __spreadArray([], __read$1(this.elements), false);
4695
+ return __spreadArray$1([], __read$1(this.elements), false);
4696
4696
  };
4697
4697
  Matrix3.prototype.fill = function (array, offset) {
4698
4698
  if (offset === void 0) { offset = 0; }
@@ -6450,7 +6450,7 @@ function error(message) {
6450
6450
  for (var _i = 1; _i < arguments.length; _i++) {
6451
6451
  args[_i - 1] = arguments[_i];
6452
6452
  }
6453
- console.error.apply(console, __spreadArray$2(__spreadArray$2([], __read$3(format(message)), false), [args], false));
6453
+ console.error.apply(console, __spreadArray$3(__spreadArray$3([], __read$3(format(message)), false), [args], false));
6454
6454
  localLogger === null || localLogger === void 0 ? void 0 : localLogger('error', message, args);
6455
6455
  }
6456
6456
  /**
@@ -6463,7 +6463,7 @@ function info(message) {
6463
6463
  for (var _i = 1; _i < arguments.length; _i++) {
6464
6464
  args[_i - 1] = arguments[_i];
6465
6465
  }
6466
- console.debug.apply(console, __spreadArray$2([], __read$3(format(message)), false));
6466
+ console.debug.apply(console, __spreadArray$3([], __read$3(format(message)), false));
6467
6467
  localLogger === null || localLogger === void 0 ? void 0 : localLogger('info', message, args);
6468
6468
  }
6469
6469
  function warn(message) {
@@ -6471,7 +6471,7 @@ function warn(message) {
6471
6471
  for (var _i = 1; _i < arguments.length; _i++) {
6472
6472
  args[_i - 1] = arguments[_i];
6473
6473
  }
6474
- console.warn.apply(console, __spreadArray$2([], __read$3(format(message)), false));
6474
+ console.warn.apply(console, __spreadArray$3([], __read$3(format(message)), false));
6475
6475
  localLogger === null || localLogger === void 0 ? void 0 : localLogger('warn', message, args);
6476
6476
  }
6477
6477
  /**
@@ -6568,17 +6568,30 @@ function random(min, max) {
6568
6568
  function throwDestroyedError() {
6569
6569
  throw Error('destroyed item cannot be used again');
6570
6570
  }
6571
- function generateGUID() {
6572
- return v4().replace(/-/g, '');
6571
+ function generateGUID$1() {
6572
+ return v4$1().replace(/-/g, '');
6573
6573
  }
6574
6574
 
6575
6575
  /*!
6576
6576
  * Name: @galacean/effects-specification
6577
6577
  * Description: Galacean Effects JSON Specification
6578
6578
  * Author: Ant Group CO., Ltd.
6579
- * Version: v1.0.1
6579
+ * Version: v2.0.0-alpha.3
6580
+ */
6581
+
6582
+ typeof crypto !== 'undefined' && crypto.randomUUID && crypto.randomUUID.bind(crypto);
6583
+
6584
+ /**
6585
+ * Convert array of 16 byte values to UUID string format of the form:
6586
+ * XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX
6580
6587
  */
6581
6588
 
6589
+ const byteToHex$1 = [];
6590
+
6591
+ for (let i = 0; i < 256; ++i) {
6592
+ byteToHex$1.push((i + 0x100).toString(16).slice(1));
6593
+ }
6594
+
6582
6595
  /*********************************************/
6583
6596
  /* 元素属性参数类型 */
6584
6597
  /*********************************************/
@@ -6841,6 +6854,10 @@ var ItemType$1;
6841
6854
  * 天空盒元素
6842
6855
  */
6843
6856
  ItemType["skybox"] = "skybox";
6857
+ /**
6858
+ * 特效元素
6859
+ */
6860
+ ItemType["effect"] = "effect";
6844
6861
  })(ItemType$1 || (ItemType$1 = {}));
6845
6862
  /**
6846
6863
  * 渲染模式
@@ -6955,6 +6972,10 @@ var CompositionEndBehavior$1;
6955
6972
  * 销毁并保留最后一帧
6956
6973
  */
6957
6974
  CompositionEndBehavior[CompositionEndBehavior["pause_destroy"] = END_BEHAVIOR_PAUSE_AND_DESTROY$1] = "pause_destroy";
6975
+ /**
6976
+ * 冻结
6977
+ */
6978
+ CompositionEndBehavior[CompositionEndBehavior["freeze"] = END_BEHAVIOR_FREEZE$1] = "freeze";
6958
6979
  })(CompositionEndBehavior$1 || (CompositionEndBehavior$1 = {}));
6959
6980
 
6960
6981
  /*********************************************/
@@ -7093,12 +7114,38 @@ var ShapeArcMode$1;
7093
7114
 
7094
7115
  var BloomFilterThresholdAvgColor = 0;
7095
7116
 
7117
+ var LightType$1;
7118
+ (function (LightType) {
7119
+ /**
7120
+ * 点光源
7121
+ */
7122
+ LightType["point"] = "point";
7123
+ /**
7124
+ * 聚光灯
7125
+ */
7126
+ LightType["spot"] = "spot";
7127
+ /**
7128
+ * 方向光
7129
+ */
7130
+ LightType["directional"] = "directional";
7131
+ /**
7132
+ * 环境光
7133
+ */
7134
+ LightType["ambient"] = "ambient";
7135
+ })(LightType$1 || (LightType$1 = {}));
7136
+
7096
7137
  var ModelBoundingType$1;
7097
7138
  (function (ModelBoundingType) {
7098
7139
  ModelBoundingType[ModelBoundingType["box"] = 2] = "box";
7099
7140
  ModelBoundingType[ModelBoundingType["sphere"] = 3] = "sphere";
7100
7141
  })(ModelBoundingType$1 || (ModelBoundingType$1 = {}));
7101
7142
 
7143
+ var CameraType$1;
7144
+ (function (CameraType) {
7145
+ CameraType["orthographic"] = "orthographic";
7146
+ CameraType["perspective"] = "perspective";
7147
+ })(CameraType$1 || (CameraType$1 = {}));
7148
+
7102
7149
  // 材质类型
7103
7150
  var MaterialType$1;
7104
7151
  (function (MaterialType) {
@@ -7244,6 +7291,28 @@ var FontStyle$1;
7244
7291
  FontStyle["oblique"] = "oblique";
7245
7292
  })(FontStyle$1 || (FontStyle$1 = {}));
7246
7293
 
7294
+ var DataType$1;
7295
+ (function (DataType) {
7296
+ DataType["VFXItemData"] = "VFXItemData";
7297
+ DataType["EffectComponent"] = "EffectComponent";
7298
+ DataType["Material"] = "Material";
7299
+ DataType["Shader"] = "Shader";
7300
+ DataType["SpriteComponent"] = "SpriteComponent";
7301
+ DataType["ParticleSystem"] = "ParticleSystem";
7302
+ DataType["InteractComponent"] = "InteractComponent";
7303
+ DataType["CameraController"] = "CameraController";
7304
+ DataType["Geometry"] = "Geometry";
7305
+ DataType["Texture"] = "Texture";
7306
+ DataType["TextComponent"] = "TextComponent";
7307
+ // FIXME: 先完成ECS的场景转换,后面移到spec中
7308
+ DataType["MeshComponent"] = "MeshComponent";
7309
+ DataType["SkyboxComponent"] = "SkyboxComponent";
7310
+ DataType["LightComponent"] = "LightComponent";
7311
+ DataType["CameraComponent"] = "CameraComponent";
7312
+ DataType["ModelPluginComponent"] = "ModelPluginComponent";
7313
+ DataType["TreeComponent"] = "TreeComponent";
7314
+ })(DataType$1 || (DataType$1 = {}));
7315
+
7247
7316
  var index = /*#__PURE__*/Object.freeze({
7248
7317
  __proto__: null,
7249
7318
  get BezierKeyframeType () { return BezierKeyframeType$1; },
@@ -7252,7 +7321,9 @@ var index = /*#__PURE__*/Object.freeze({
7252
7321
  CAMERA_CLIP_MODE_NORMAL: CAMERA_CLIP_MODE_NORMAL$1,
7253
7322
  CAMERA_CLIP_MODE_VERTICAL: CAMERA_CLIP_MODE_VERTICAL$1,
7254
7323
  get CameraClipMode () { return CameraClipMode$1; },
7324
+ get CameraType () { return CameraType$1; },
7255
7325
  get CompositionEndBehavior () { return CompositionEndBehavior$1; },
7326
+ get DataType () { return DataType$1; },
7256
7327
  END_BEHAVIOR_DESTROY: END_BEHAVIOR_DESTROY$1,
7257
7328
  END_BEHAVIOR_DESTROY_CHILDREN: END_BEHAVIOR_DESTROY_CHILDREN$1,
7258
7329
  END_BEHAVIOR_FORWARD: END_BEHAVIOR_FORWARD$1,
@@ -7265,6 +7336,7 @@ var index = /*#__PURE__*/Object.freeze({
7265
7336
  get InteractType () { return InteractType$1; },
7266
7337
  get ItemEndBehavior () { return ItemEndBehavior$1; },
7267
7338
  get ItemType () { return ItemType$1; },
7339
+ get LightType () { return LightType$1; },
7268
7340
  MESSAGE_ITEM_PHRASE_BEGIN: MESSAGE_ITEM_PHRASE_BEGIN,
7269
7341
  MESSAGE_ITEM_PHRASE_END: MESSAGE_ITEM_PHRASE_END,
7270
7342
  get MaskMode () { return MaskMode$1; },
@@ -7456,7 +7528,7 @@ function copy$1(target) {
7456
7528
  }
7457
7529
  }
7458
7530
 
7459
- var _a$5;
7531
+ var _a$6;
7460
7532
  function valIfUndefined(val, def) {
7461
7533
  if (val === undefined || val === null) {
7462
7534
  return def;
@@ -7486,15 +7558,15 @@ function getPreMultiAlpha(blending) {
7486
7558
  return 1;
7487
7559
  }
7488
7560
  }
7489
- var downgradeKeywords = (_a$5 = {},
7490
- _a$5[exports.ShaderType.vertex] = {
7561
+ var downgradeKeywords = (_a$6 = {},
7562
+ _a$6[exports.ShaderType.vertex] = {
7491
7563
  in: 'attribute',
7492
7564
  out: 'varying',
7493
7565
  },
7494
- _a$5[exports.ShaderType.fragment] = {
7566
+ _a$6[exports.ShaderType.fragment] = {
7495
7567
  in: 'varying',
7496
7568
  },
7497
- _a$5);
7569
+ _a$6);
7498
7570
  /**
7499
7571
  * 生成 shader,检测到 WebGL1 上下文会降级
7500
7572
  * @param marcos - 宏定义数组
@@ -7935,7 +8007,7 @@ function loadMipmapImage(pointer, bins) {
7935
8007
  var EffectsObject = /** @class */ (function () {
7936
8008
  function EffectsObject(engine) {
7937
8009
  this.engine = engine;
7938
- this.guid = generateGUID();
8010
+ this.guid = generateGUID$1();
7939
8011
  this.taggedProperties = {};
7940
8012
  this.engine.addInstance(this);
7941
8013
  }
@@ -8632,13 +8704,49 @@ exports.GLSLVersion = void 0;
8632
8704
  GLSLVersion["GLSL1"] = "100";
8633
8705
  GLSLVersion["GLSL3"] = "300 es";
8634
8706
  })(exports.GLSLVersion || (exports.GLSLVersion = {}));
8635
- var Shader = /** @class */ (function (_super) {
8636
- __extends(Shader, _super);
8637
- function Shader(engine, source) {
8707
+ var ShaderVariant = /** @class */ (function (_super) {
8708
+ __extends(ShaderVariant, _super);
8709
+ function ShaderVariant(engine, source) {
8638
8710
  var _this = _super.call(this, engine) || this;
8639
8711
  _this.source = source;
8640
8712
  return _this;
8641
8713
  }
8714
+ return ShaderVariant;
8715
+ }(EffectsObject));
8716
+ var Shader = /** @class */ (function (_super) {
8717
+ __extends(Shader, _super);
8718
+ function Shader() {
8719
+ return _super !== null && _super.apply(this, arguments) || this;
8720
+ }
8721
+ Shader.prototype.createVariant = function (macros) {
8722
+ var e_1, _a;
8723
+ var shaderMacros = [];
8724
+ if (macros) {
8725
+ try {
8726
+ for (var _b = __values$1(Object.keys(macros)), _c = _b.next(); !_c.done; _c = _b.next()) {
8727
+ var key = _c.value;
8728
+ shaderMacros.push([key, macros[key]]);
8729
+ }
8730
+ }
8731
+ catch (e_1_1) { e_1 = { error: e_1_1 }; }
8732
+ finally {
8733
+ try {
8734
+ if (_c && !_c.done && (_a = _b.return)) _a.call(_b);
8735
+ }
8736
+ finally { if (e_1) throw e_1.error; }
8737
+ }
8738
+ }
8739
+ var shaderVariant = this.engine.getShaderLibrary().createShader(this.shaderData, shaderMacros);
8740
+ shaderVariant.shader = this;
8741
+ return shaderVariant;
8742
+ };
8743
+ Shader.prototype.fromData = function (data) {
8744
+ _super.prototype.fromData.call(this, data);
8745
+ this.shaderData = data;
8746
+ };
8747
+ Shader = __decorate([
8748
+ effectsClass('Shader')
8749
+ ], Shader);
8642
8750
  return Shader;
8643
8751
  }(EffectsObject));
8644
8752
 
@@ -8651,8 +8759,8 @@ function createCopyShader(level, writeDepth) {
8651
8759
  var version = webgl2 ? '#version 300 es' : '';
8652
8760
  return {
8653
8761
  name: EFFECTS_COPY_MESH_NAME,
8654
- vertex: createShaderWithMarcos([], version + '\n' + COPY_VERTEX_SHADER, exports.ShaderType.vertex, level),
8655
- fragment: createShaderWithMarcos([], version + '\n' + COPY_FRAGMENT_SHADER, exports.ShaderType.fragment, level),
8762
+ vertex: version + '\n' + COPY_VERTEX_SHADER,
8763
+ fragment: version + '\n' + COPY_FRAGMENT_SHADER,
8656
8764
  glslVersion: webgl2 ? exports.GLSLVersion.GLSL3 : exports.GLSLVersion.GLSL1,
8657
8765
  marcos: [
8658
8766
  ['WEBGL2', !!webgl2],
@@ -8784,13 +8892,13 @@ var SemanticMap = /** @class */ (function () {
8784
8892
  return SemanticMap;
8785
8893
  }());
8786
8894
 
8787
- var _a$4;
8788
- var BYTES_TYPE_MAP = (_a$4 = {},
8789
- _a$4[glContext.FLOAT] = Float32Array.BYTES_PER_ELEMENT,
8790
- _a$4[glContext.INT] = Int32Array.BYTES_PER_ELEMENT,
8791
- _a$4[glContext.SHORT] = Int16Array.BYTES_PER_ELEMENT,
8792
- _a$4[glContext.BYTE] = Int8Array.BYTES_PER_ELEMENT,
8793
- _a$4);
8895
+ var _a$5;
8896
+ var BYTES_TYPE_MAP = (_a$5 = {},
8897
+ _a$5[glContext.FLOAT] = Float32Array.BYTES_PER_ELEMENT,
8898
+ _a$5[glContext.INT] = Int32Array.BYTES_PER_ELEMENT,
8899
+ _a$5[glContext.SHORT] = Int16Array.BYTES_PER_ELEMENT,
8900
+ _a$5[glContext.BYTE] = Int8Array.BYTES_PER_ELEMENT,
8901
+ _a$5);
8794
8902
  /**
8795
8903
  * Geometry 抽象类
8796
8904
  */
@@ -9359,7 +9467,7 @@ var RenderPass = /** @class */ (function () {
9359
9467
  RenderPass.prototype.setMeshes = function (meshes) {
9360
9468
  var _a;
9361
9469
  this.meshes.length = 0;
9362
- (_a = this.meshes).splice.apply(_a, __spreadArray$2([0, 0], __read$3(meshes), false));
9470
+ (_a = this.meshes).splice.apply(_a, __spreadArray$3([0, 0], __read$3(meshes), false));
9363
9471
  sortByOrder(this.meshes, this.meshOrder);
9364
9472
  return this.meshes;
9365
9473
  };
@@ -11553,9 +11661,6 @@ var AssetLoader = /** @class */ (function () {
11553
11661
  case exports.DataType.Texture:
11554
11662
  effectsObject = Texture.create(this.engine, effectsObjectData);
11555
11663
  return effectsObject;
11556
- case exports.DataType.Shader:
11557
- effectsObject = this.engine.getShaderLibrary().createShader(effectsObjectData);
11558
- break;
11559
11664
  default: {
11560
11665
  var classConstructor = AssetLoader.getClass(effectsObjectData.dataType);
11561
11666
  if (classConstructor) {
@@ -11608,9 +11713,6 @@ var AssetLoader = /** @class */ (function () {
11608
11713
  case exports.DataType.Texture:
11609
11714
  effectsObject = Texture.create(this.engine, effectsObjectData);
11610
11715
  return [2 /*return*/, effectsObject];
11611
- case exports.DataType.Shader:
11612
- effectsObject = this.engine.getShaderLibrary().createShader(effectsObjectData);
11613
- break;
11614
11716
  default: {
11615
11717
  classConstructor = AssetLoader.getClass(effectsObjectData.dataType);
11616
11718
  if (classConstructor) {
@@ -11823,7 +11925,7 @@ function calculateTranslation(out, target, acc, time, duration, posData, velData
11823
11925
  return ret;
11824
11926
  }
11825
11927
 
11826
- var _a$3;
11928
+ var _a$4;
11827
11929
  function ensureVec3(num) {
11828
11930
  return Array.isArray(num) ? [num[0], num[1], num[2]] : [0, 0, 0];
11829
11931
  }
@@ -11846,7 +11948,7 @@ function vecNormalize(out, a) {
11846
11948
  out = [];
11847
11949
  }
11848
11950
  var ap = a;
11849
- var sum = Math.hypot.apply(Math, __spreadArray$2([], __read$3(ap), false));
11951
+ var sum = Math.hypot.apply(Math, __spreadArray$3([], __read$3(ap), false));
11850
11952
  if (sum === 0) {
11851
11953
  return vecAssign(out, ap, ap.length);
11852
11954
  }
@@ -11877,17 +11979,17 @@ function vecMulCombine(out, a, b) {
11877
11979
  }
11878
11980
  return out;
11879
11981
  }
11880
- var particleOriginTranslateMap = (_a$3 = {},
11881
- _a$3[ParticleOrigin$1.PARTICLE_ORIGIN_CENTER] = [0, 0],
11882
- _a$3[ParticleOrigin$1.PARTICLE_ORIGIN_CENTER_BOTTOM] = [0, -0.5],
11883
- _a$3[ParticleOrigin$1.PARTICLE_ORIGIN_CENTER_TOP] = [0, 0.5],
11884
- _a$3[ParticleOrigin$1.PARTICLE_ORIGIN_LEFT_TOP] = [-0.5, 0.5],
11885
- _a$3[ParticleOrigin$1.PARTICLE_ORIGIN_LEFT_CENTER] = [-0.5, 0],
11886
- _a$3[ParticleOrigin$1.PARTICLE_ORIGIN_LEFT_BOTTOM] = [-0.5, -0.5],
11887
- _a$3[ParticleOrigin$1.PARTICLE_ORIGIN_RIGHT_CENTER] = [0.5, 0],
11888
- _a$3[ParticleOrigin$1.PARTICLE_ORIGIN_RIGHT_BOTTOM] = [0.5, -0.5],
11889
- _a$3[ParticleOrigin$1.PARTICLE_ORIGIN_RIGHT_TOP] = [0.5, 0.5],
11890
- _a$3);
11982
+ var particleOriginTranslateMap$1 = (_a$4 = {},
11983
+ _a$4[ParticleOrigin$1.PARTICLE_ORIGIN_CENTER] = [0, 0],
11984
+ _a$4[ParticleOrigin$1.PARTICLE_ORIGIN_CENTER_BOTTOM] = [0, -0.5],
11985
+ _a$4[ParticleOrigin$1.PARTICLE_ORIGIN_CENTER_TOP] = [0, 0.5],
11986
+ _a$4[ParticleOrigin$1.PARTICLE_ORIGIN_LEFT_TOP] = [-0.5, 0.5],
11987
+ _a$4[ParticleOrigin$1.PARTICLE_ORIGIN_LEFT_CENTER] = [-0.5, 0],
11988
+ _a$4[ParticleOrigin$1.PARTICLE_ORIGIN_LEFT_BOTTOM] = [-0.5, -0.5],
11989
+ _a$4[ParticleOrigin$1.PARTICLE_ORIGIN_RIGHT_CENTER] = [0.5, 0],
11990
+ _a$4[ParticleOrigin$1.PARTICLE_ORIGIN_RIGHT_BOTTOM] = [0.5, -0.5],
11991
+ _a$4[ParticleOrigin$1.PARTICLE_ORIGIN_RIGHT_TOP] = [0.5, 0.5],
11992
+ _a$4);
11891
11993
  function nearestPowerOfTwo(value) {
11892
11994
  return Math.pow(2, Math.round(Math.log(value) / Math.LN2));
11893
11995
  }
@@ -11912,7 +12014,7 @@ function trianglesFromRect(position, halfWidth, halfHeight) {
11912
12014
  ];
11913
12015
  }
11914
12016
 
11915
- var _a$2;
12017
+ var _a$3;
11916
12018
  var NOT_IMPLEMENT = 'not_implement';
11917
12019
  var ValueGetter = /** @class */ (function () {
11918
12020
  function ValueGetter(arg) {
@@ -12420,50 +12522,50 @@ var BezierSegments = /** @class */ (function (_super) {
12420
12522
  };
12421
12523
  return BezierSegments;
12422
12524
  }(PathSegments));
12423
- var map$1 = (_a$2 = {},
12424
- _a$2[ValueType$1.RANDOM] = function (props) {
12525
+ var map$1 = (_a$3 = {},
12526
+ _a$3[ValueType$1.RANDOM] = function (props) {
12425
12527
  if (props[0] instanceof Array) {
12426
12528
  return new RandomVectorValue(props);
12427
12529
  }
12428
12530
  return new RandomValue(props);
12429
12531
  },
12430
- _a$2[ValueType$1.CONSTANT] = function (props) {
12532
+ _a$3[ValueType$1.CONSTANT] = function (props) {
12431
12533
  return new StaticValue(props);
12432
12534
  },
12433
- _a$2[ValueType$1.CONSTANT_VEC2] = function (props) {
12535
+ _a$3[ValueType$1.CONSTANT_VEC2] = function (props) {
12434
12536
  return new StaticValue(props);
12435
12537
  },
12436
- _a$2[ValueType$1.CONSTANT_VEC3] = function (props) {
12538
+ _a$3[ValueType$1.CONSTANT_VEC3] = function (props) {
12437
12539
  return new StaticValue(props);
12438
12540
  },
12439
- _a$2[ValueType$1.CONSTANT_VEC4] = function (props) {
12541
+ _a$3[ValueType$1.CONSTANT_VEC4] = function (props) {
12440
12542
  return new StaticValue(props);
12441
12543
  },
12442
- _a$2[ValueType$1.CURVE] = function (props) {
12544
+ _a$3[ValueType$1.CURVE] = function (props) {
12443
12545
  return new CurveValue(props);
12444
12546
  },
12445
- _a$2[ValueType$1.RGBA_COLOR] = function (props) {
12547
+ _a$3[ValueType$1.RGBA_COLOR] = function (props) {
12446
12548
  return new StaticValue(props);
12447
12549
  },
12448
- _a$2[ValueType$1.COLORS] = function (props) {
12550
+ _a$3[ValueType$1.COLORS] = function (props) {
12449
12551
  return new RandomSetValue(props.map(function (c) { return colorToArr$1(c, false); }));
12450
12552
  },
12451
- _a$2[ValueType$1.LINE] = function (props) {
12553
+ _a$3[ValueType$1.LINE] = function (props) {
12452
12554
  if (props.length === 2 && props[0][0] === 0 && props[1][0] === 1) {
12453
12555
  return new LinearValue([props[0][1], props[1][1]]);
12454
12556
  }
12455
12557
  return new LineSegments(props);
12456
12558
  },
12457
- _a$2[ValueType$1.GRADIENT_COLOR] = function (props) {
12559
+ _a$3[ValueType$1.GRADIENT_COLOR] = function (props) {
12458
12560
  return new GradientValue(props);
12459
12561
  },
12460
- _a$2[ValueType$1.LINEAR_PATH] = function (pros) {
12562
+ _a$3[ValueType$1.LINEAR_PATH] = function (pros) {
12461
12563
  return new PathSegments(pros);
12462
12564
  },
12463
- _a$2[ValueType$1.BEZIER_PATH] = function (pros) {
12565
+ _a$3[ValueType$1.BEZIER_PATH] = function (pros) {
12464
12566
  return new BezierSegments(pros);
12465
12567
  },
12466
- _a$2);
12568
+ _a$3);
12467
12569
  function createValueGetter(args) {
12468
12570
  if (!args || !isNaN(+args)) {
12469
12571
  return new StaticValue(args || 0);
@@ -13414,13 +13516,13 @@ var InteractMesh = /** @class */ (function () {
13414
13516
  ['ENV_EDITOR', ((_a = this.engine.renderer) === null || _a === void 0 ? void 0 : _a.env) === PLAYER_OPTIONS_ENV_EDITOR],
13415
13517
  ];
13416
13518
  var color = createValueGetter(this.color).getValue(0);
13417
- var level = this.engine.gpuCapability.level;
13418
13519
  var materialProps = {
13419
13520
  shader: {
13420
- vertex: createShaderWithMarcos(marcos, vertex, exports.ShaderType.vertex, level),
13421
- fragment: createShaderWithMarcos(marcos, fragment, exports.ShaderType.fragment, level),
13521
+ vertex: vertex,
13522
+ fragment: fragment,
13422
13523
  glslVersion: exports.GLSLVersion.GLSL1,
13423
13524
  cacheId: "".concat(rendererOptions.cachePrefix, "_effects_interact"),
13525
+ marcos: marcos,
13424
13526
  },
13425
13527
  uniformSemantics: {
13426
13528
  effects_MatrixVP: 'VIEWPROJECTION',
@@ -13494,11 +13596,11 @@ var InteractComponent = /** @class */ (function (_super) {
13494
13596
  }
13495
13597
  InteractComponent_1 = InteractComponent;
13496
13598
  InteractComponent.prototype.start = function () {
13497
- var _a, _b, _c;
13599
+ var _this = this;
13498
13600
  var options = this.item.props.content.options;
13499
- var env = ((_b = (_a = this.item.engine) === null || _a === void 0 ? void 0 : _a.renderer) !== null && _b !== void 0 ? _b : {}).env;
13601
+ var env = this.item.engine.renderer.env;
13500
13602
  var composition = this.item.composition;
13501
- var _d = this.interactData.options, type = _d.type, showPreview = _d.showPreview;
13603
+ var _a = this.interactData.options, type = _a.type, showPreview = _a.showPreview;
13502
13604
  if (type === InteractType$1.CLICK) {
13503
13605
  this.clickable = true;
13504
13606
  if (showPreview && env === PLAYER_OPTIONS_ENV_EDITOR) {
@@ -13506,7 +13608,8 @@ var InteractComponent = /** @class */ (function (_super) {
13506
13608
  this.previewContent = new InteractMesh(this.item.props.content, rendererOptions, this.transform, this.engine);
13507
13609
  }
13508
13610
  }
13509
- (_c = this.item.composition) === null || _c === void 0 ? void 0 : _c.addInteractiveItem(this.item, options.type);
13611
+ composition.addInteractiveItem(this.item, options.type);
13612
+ this.item.onEnd = function () { return composition.removeInteractiveItem(_this.item, options.type); };
13510
13613
  if (options.type === InteractType$1.DRAG) {
13511
13614
  if (env !== PLAYER_OPTIONS_ENV_EDITOR || options.enableInEditor) {
13512
13615
  composition.event && this.beginDragTarget(options, composition.event);
@@ -13699,8 +13802,8 @@ function spriteMeshShaderFromFilter(level, options) {
13699
13802
  var fragment = wireframe ? itemFrameFrag : itemFrag.replace(/#pragma\s+FILTER_FRAG/, '');
13700
13803
  var vertex = itemVert.replace(/#pragma\s+FILTER_VERT/, 'vec4 filterMain(float t,vec4 pos){return effects_MatrixVP * pos;}');
13701
13804
  return {
13702
- fragment: createShaderWithMarcos(marcos, fragment, exports.ShaderType.fragment, level),
13703
- vertex: createShaderWithMarcos(marcos, vertex, exports.ShaderType.vertex, level),
13805
+ fragment: fragment,
13806
+ vertex: vertex,
13704
13807
  glslVersion: level === 1 ? exports.GLSLVersion.GLSL1 : exports.GLSLVersion.GLSL3,
13705
13808
  marcos: marcos,
13706
13809
  shared: true,
@@ -15180,8 +15283,8 @@ var ParticleMesh = /** @class */ (function () {
15180
15283
  var originalVertex = "#define LOOKUP_TEXTURE_CURVE ".concat(vertex_lookup_texture, "\n").concat(particleVert);
15181
15284
  var vertex = originalVertex;
15182
15285
  var shader = {
15183
- fragment: createShaderWithMarcos(marcos, fragment, exports.ShaderType.fragment, level),
15184
- vertex: createShaderWithMarcos(marcos, vertex, exports.ShaderType.vertex, level),
15286
+ fragment: fragment,
15287
+ vertex: vertex,
15185
15288
  glslVersion: level === 1 ? exports.GLSLVersion.GLSL1 : exports.GLSLVersion.GLSL3,
15186
15289
  shared: true,
15187
15290
  cacheId: shaderCache,
@@ -15736,8 +15839,8 @@ var TrailMesh = /** @class */ (function () {
15736
15839
  else {
15737
15840
  uniformValues.uVCurveValues = CurveValue.getAllData(keyFrameMeta);
15738
15841
  }
15739
- var vertex = createShaderWithMarcos(marcos, trailVert, exports.ShaderType.vertex, level);
15740
- var fragment = createShaderWithMarcos(marcos, particleFrag, exports.ShaderType.fragment, level);
15842
+ var vertex = trailVert;
15843
+ var fragment = particleFrag;
15741
15844
  var mtl = ({
15742
15845
  shader: {
15743
15846
  vertex: vertex,
@@ -16424,7 +16527,7 @@ var TextureShape = /** @class */ (function () {
16424
16527
  return TextureShape;
16425
16528
  }());
16426
16529
 
16427
- var _a$1;
16530
+ var _a$2;
16428
16531
  var ShapeNone = /** @class */ (function () {
16429
16532
  function ShapeNone() {
16430
16533
  }
@@ -16436,18 +16539,18 @@ var ShapeNone = /** @class */ (function () {
16436
16539
  };
16437
16540
  return ShapeNone;
16438
16541
  }());
16439
- var map = (_a$1 = {},
16440
- _a$1[ShapeType$1.NONE] = ShapeNone,
16441
- _a$1[ShapeType$1.CONE] = Cone,
16442
- _a$1[ShapeType$1.SPHERE] = Sphere,
16443
- _a$1[ShapeType$1.HEMISPHERE] = Hemisphere,
16444
- _a$1[ShapeType$1.CIRCLE] = Circle,
16445
- _a$1[ShapeType$1.DONUT] = Donut,
16446
- _a$1[ShapeType$1.RECTANGLE] = Rectangle,
16447
- _a$1[ShapeType$1.EDGE] = Edge,
16448
- _a$1[ShapeType$1.RECTANGLE_EDGE] = RectangleEdge,
16449
- _a$1[ShapeType$1.TEXTURE] = TextureShape,
16450
- _a$1);
16542
+ var map = (_a$2 = {},
16543
+ _a$2[ShapeType$1.NONE] = ShapeNone,
16544
+ _a$2[ShapeType$1.CONE] = Cone,
16545
+ _a$2[ShapeType$1.SPHERE] = Sphere,
16546
+ _a$2[ShapeType$1.HEMISPHERE] = Hemisphere,
16547
+ _a$2[ShapeType$1.CIRCLE] = Circle,
16548
+ _a$2[ShapeType$1.DONUT] = Donut,
16549
+ _a$2[ShapeType$1.RECTANGLE] = Rectangle,
16550
+ _a$2[ShapeType$1.EDGE] = Edge,
16551
+ _a$2[ShapeType$1.RECTANGLE_EDGE] = RectangleEdge,
16552
+ _a$2[ShapeType$1.TEXTURE] = TextureShape,
16553
+ _a$2);
16451
16554
  function createShape(shapeOptions) {
16452
16555
  if (!shapeOptions) {
16453
16556
  return new ShapeNone();
@@ -17776,7 +17879,7 @@ var ParticleSystem = /** @class */ (function (_super) {
17776
17879
  }));
17777
17880
  p.delay += meshTime;
17778
17881
  cursor++;
17779
- (_a = p.transform).translate.apply(_a, __spreadArray$2([], __read$3(burstOffset), false));
17882
+ (_a = p.transform).translate.apply(_a, __spreadArray$3([], __read$3(burstOffset), false));
17780
17883
  this.addParticle(p, maxCount_1);
17781
17884
  }
17782
17885
  }
@@ -18548,7 +18651,9 @@ var TextStyle = /** @class */ (function () {
18548
18651
  this.fontOffset = 0;
18549
18652
  var _g = options.textColor, textColor = _g === void 0 ? [1, 1, 1, 1] : _g, _h = options.fontSize, fontSize = _h === void 0 ? 40 : _h, outline = options.outline, shadow = options.shadow, _j = options.fontWeight, fontWeight = _j === void 0 ? 'normal' : _j, _k = options.fontStyle, fontStyle = _k === void 0 ? 'normal' : _k, _l = options.fontFamily, fontFamily = _l === void 0 ? 'sans-serif' : _l;
18550
18653
  this.textColor = textColor;
18654
+ //@ts-expect-error
18551
18655
  this.textWeight = fontWeight;
18656
+ //@ts-expect-error
18552
18657
  this.fontStyle = fontStyle;
18553
18658
  this.fontFamily = fontFamily;
18554
18659
  this.fontSize = fontSize; // 暂时取消字号限制 Math.min(fontSize, this.maxFontSize);
@@ -20616,7 +20721,10 @@ var VFXItem = /** @class */ (function (_super) {
20616
20721
  try {
20617
20722
  for (var _e = __values$1(this.children), _f = _e.next(); !_f.done; _f = _e.next()) {
20618
20723
  var child = _f.value;
20619
- return child.find(name);
20724
+ var res = child.find(name);
20725
+ if (res) {
20726
+ return res;
20727
+ }
20620
20728
  }
20621
20729
  }
20622
20730
  catch (e_4_1) { e_4 = { error: e_4_1 }; }
@@ -20633,6 +20741,7 @@ var VFXItem = /** @class */ (function (_super) {
20633
20741
  _super.prototype.fromData.call(this, data);
20634
20742
  var id = data.id, name = data.name, delay = data.delay, parentId = data.parentId, endBehavior = data.endBehavior, transform = data.transform, _b = data.listIndex, listIndex = _b === void 0 ? 0 : _b, _c = data.duration, duration = _c === void 0 ? 0 : _c;
20635
20743
  this.props = data;
20744
+ //@ts-expect-error
20636
20745
  this.type = data.type;
20637
20746
  this.id = id.toString(); // TODO 老数据 id 是 number,需要转换
20638
20747
  this.name = name;
@@ -20728,10 +20837,10 @@ var VFXItem = /** @class */ (function (_super) {
20728
20837
  };
20729
20838
  VFXItem.prototype.translateByPixel = function (x, y) {
20730
20839
  if (this.composition) {
20840
+ // @ts-expect-error
20841
+ var _a = this.composition.renderer.canvas.getBoundingClientRect(), width = _a.width, height = _a.height;
20731
20842
  var z = this.transform.getWorldPosition().z;
20732
- var _a = this.composition.camera.getInverseVPRatio(z), rx = _a.x, ry = _a.y;
20733
- var width = this.composition.renderer.getWidth() / 2;
20734
- var height = this.composition.renderer.getHeight() / 2;
20843
+ var _b = this.composition.camera.getInverseVPRatio(z), rx = _b.x, ry = _b.y;
20735
20844
  this.transform.translate(2 * x * rx / width, -2 * y * ry / height, 0);
20736
20845
  }
20737
20846
  };
@@ -20836,7 +20945,6 @@ function createVFXItem(props, composition) {
20836
20945
  if (!pluginName) {
20837
20946
  switch (type) {
20838
20947
  case ItemType$1.null:
20839
- case ItemType$1.base:
20840
20948
  pluginName = 'cal';
20841
20949
  break;
20842
20950
  case ItemType$1.sprite:
@@ -20957,7 +21065,7 @@ var PluginSystem = /** @class */ (function () {
20957
21065
  plugin = plugins[i];
20958
21066
  ctrl = pluginLoaderMap[plugin.name];
20959
21067
  if (name in ctrl) {
20960
- pendings.push(Promise.resolve(ctrl[name].apply(ctrl, __spreadArray$2([], __read$3(args), false))));
21068
+ pendings.push(Promise.resolve(ctrl[name].apply(ctrl, __spreadArray$3([], __read$3(args), false))));
20961
21069
  }
20962
21070
  }
20963
21071
  return [2 /*return*/, Promise.all(pendings)];
@@ -21002,9 +21110,74 @@ function getPluginUsageInfo(name) {
21002
21110
  * Name: @galacean/effects-specification
21003
21111
  * Description: Galacean Effects JSON Specification
21004
21112
  * Author: Ant Group CO., Ltd.
21005
- * Version: v1.0.1
21113
+ * Version: v2.0.0-alpha.3
21114
+ */
21115
+
21116
+ const randomUUID = typeof crypto !== 'undefined' && crypto.randomUUID && crypto.randomUUID.bind(crypto);
21117
+ var native = {
21118
+ randomUUID
21119
+ };
21120
+
21121
+ // Unique ID creation requires a high quality random # generator. In the browser we therefore
21122
+ // require the crypto API and do not support built-in fallback to lower quality random number
21123
+ // generators (like Math.random()).
21124
+ let getRandomValues;
21125
+ const rnds8 = new Uint8Array(16);
21126
+ function rng() {
21127
+ // lazy load so that environments that need to polyfill have a chance to do so
21128
+ if (!getRandomValues) {
21129
+ // getRandomValues needs to be invoked in a context where "this" is a Crypto implementation.
21130
+ getRandomValues = typeof crypto !== 'undefined' && crypto.getRandomValues && crypto.getRandomValues.bind(crypto);
21131
+
21132
+ if (!getRandomValues) {
21133
+ throw new Error('crypto.getRandomValues() not supported. See https://github.com/uuidjs/uuid#getrandomvalues-not-supported');
21134
+ }
21135
+ }
21136
+
21137
+ return getRandomValues(rnds8);
21138
+ }
21139
+
21140
+ /**
21141
+ * Convert array of 16 byte values to UUID string format of the form:
21142
+ * XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX
21006
21143
  */
21007
21144
 
21145
+ const byteToHex = [];
21146
+
21147
+ for (let i = 0; i < 256; ++i) {
21148
+ byteToHex.push((i + 0x100).toString(16).slice(1));
21149
+ }
21150
+
21151
+ function unsafeStringify(arr, offset = 0) {
21152
+ // Note: Be careful editing this code! It's been tuned for performance
21153
+ // and works in ways you may not expect. See https://github.com/uuidjs/uuid/pull/434
21154
+ return byteToHex[arr[offset + 0]] + byteToHex[arr[offset + 1]] + byteToHex[arr[offset + 2]] + byteToHex[arr[offset + 3]] + '-' + byteToHex[arr[offset + 4]] + byteToHex[arr[offset + 5]] + '-' + byteToHex[arr[offset + 6]] + byteToHex[arr[offset + 7]] + '-' + byteToHex[arr[offset + 8]] + byteToHex[arr[offset + 9]] + '-' + byteToHex[arr[offset + 10]] + byteToHex[arr[offset + 11]] + byteToHex[arr[offset + 12]] + byteToHex[arr[offset + 13]] + byteToHex[arr[offset + 14]] + byteToHex[arr[offset + 15]];
21155
+ }
21156
+
21157
+ function v4(options, buf, offset) {
21158
+ if (native.randomUUID && !buf && !options) {
21159
+ return native.randomUUID();
21160
+ }
21161
+
21162
+ options = options || {};
21163
+ const rnds = options.random || (options.rng || rng)(); // Per 4.4, set bits for version and `clock_seq_hi_and_reserved`
21164
+
21165
+ rnds[6] = rnds[6] & 0x0f | 0x40;
21166
+ rnds[8] = rnds[8] & 0x3f | 0x80; // Copy bytes to buffer, if provided
21167
+
21168
+ if (buf) {
21169
+ offset = offset || 0;
21170
+
21171
+ for (let i = 0; i < 16; ++i) {
21172
+ buf[offset + i] = rnds[i];
21173
+ }
21174
+
21175
+ return buf;
21176
+ }
21177
+
21178
+ return unsafeStringify(rnds);
21179
+ }
21180
+
21008
21181
  /*********************************************/
21009
21182
  /* 元素属性参数类型 */
21010
21183
  /*********************************************/
@@ -21267,6 +21440,10 @@ var ItemType;
21267
21440
  * 天空盒元素
21268
21441
  */
21269
21442
  ItemType["skybox"] = "skybox";
21443
+ /**
21444
+ * 特效元素
21445
+ */
21446
+ ItemType["effect"] = "effect";
21270
21447
  })(ItemType || (ItemType = {}));
21271
21448
  /**
21272
21449
  * 渲染模式
@@ -21379,6 +21556,10 @@ var CompositionEndBehavior;
21379
21556
  * 销毁并保留最后一帧
21380
21557
  */
21381
21558
  CompositionEndBehavior[CompositionEndBehavior["pause_destroy"] = END_BEHAVIOR_PAUSE_AND_DESTROY] = "pause_destroy";
21559
+ /**
21560
+ * 冻结
21561
+ */
21562
+ CompositionEndBehavior[CompositionEndBehavior["freeze"] = END_BEHAVIOR_FREEZE] = "freeze";
21382
21563
  })(CompositionEndBehavior || (CompositionEndBehavior = {}));
21383
21564
 
21384
21565
  /*********************************************/
@@ -21515,12 +21696,38 @@ var ShapeArcMode;
21515
21696
  ShapeArcMode[ShapeArcMode["UNIFORM_BURST"] = 3] = "UNIFORM_BURST";
21516
21697
  })(ShapeArcMode || (ShapeArcMode = {}));
21517
21698
 
21699
+ var LightType;
21700
+ (function (LightType) {
21701
+ /**
21702
+ * 点光源
21703
+ */
21704
+ LightType["point"] = "point";
21705
+ /**
21706
+ * 聚光灯
21707
+ */
21708
+ LightType["spot"] = "spot";
21709
+ /**
21710
+ * 方向光
21711
+ */
21712
+ LightType["directional"] = "directional";
21713
+ /**
21714
+ * 环境光
21715
+ */
21716
+ LightType["ambient"] = "ambient";
21717
+ })(LightType || (LightType = {}));
21718
+
21518
21719
  var ModelBoundingType;
21519
21720
  (function (ModelBoundingType) {
21520
21721
  ModelBoundingType[ModelBoundingType["box"] = 2] = "box";
21521
21722
  ModelBoundingType[ModelBoundingType["sphere"] = 3] = "sphere";
21522
21723
  })(ModelBoundingType || (ModelBoundingType = {}));
21523
21724
 
21725
+ var CameraType;
21726
+ (function (CameraType) {
21727
+ CameraType["orthographic"] = "orthographic";
21728
+ CameraType["perspective"] = "perspective";
21729
+ })(CameraType || (CameraType = {}));
21730
+
21524
21731
  // 材质类型
21525
21732
  var MaterialType;
21526
21733
  (function (MaterialType) {
@@ -21666,6 +21873,28 @@ var FontStyle;
21666
21873
  FontStyle["oblique"] = "oblique";
21667
21874
  })(FontStyle || (FontStyle = {}));
21668
21875
 
21876
+ var DataType;
21877
+ (function (DataType) {
21878
+ DataType["VFXItemData"] = "VFXItemData";
21879
+ DataType["EffectComponent"] = "EffectComponent";
21880
+ DataType["Material"] = "Material";
21881
+ DataType["Shader"] = "Shader";
21882
+ DataType["SpriteComponent"] = "SpriteComponent";
21883
+ DataType["ParticleSystem"] = "ParticleSystem";
21884
+ DataType["InteractComponent"] = "InteractComponent";
21885
+ DataType["CameraController"] = "CameraController";
21886
+ DataType["Geometry"] = "Geometry";
21887
+ DataType["Texture"] = "Texture";
21888
+ DataType["TextComponent"] = "TextComponent";
21889
+ // FIXME: 先完成ECS的场景转换,后面移到spec中
21890
+ DataType["MeshComponent"] = "MeshComponent";
21891
+ DataType["SkyboxComponent"] = "SkyboxComponent";
21892
+ DataType["LightComponent"] = "LightComponent";
21893
+ DataType["CameraComponent"] = "CameraComponent";
21894
+ DataType["ModelPluginComponent"] = "ModelPluginComponent";
21895
+ DataType["TreeComponent"] = "TreeComponent";
21896
+ })(DataType || (DataType = {}));
21897
+
21669
21898
  /******************************************************************************
21670
21899
  Copyright (c) Microsoft Corporation.
21671
21900
 
@@ -21721,11 +21950,22 @@ function __read(o, n) {
21721
21950
  return ar;
21722
21951
  }
21723
21952
 
21953
+ function __spreadArray(to, from, pack) {
21954
+ if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {
21955
+ if (ar || !(i in from)) {
21956
+ if (!ar) ar = Array.prototype.slice.call(from, 0, i);
21957
+ ar[i] = from[i];
21958
+ }
21959
+ }
21960
+ return to.concat(ar || Array.prototype.slice.call(from));
21961
+ }
21962
+
21724
21963
  typeof SuppressedError === "function" ? SuppressedError : function (error, suppressed, message) {
21725
21964
  var e = new Error(message);
21726
21965
  return e.name = "SuppressedError", e.error = error, e.suppressed = suppressed, e;
21727
21966
  };
21728
21967
 
21968
+ var _a$1;
21729
21969
  function arrAdd(arr, item) {
21730
21970
  if (!arr.includes(item)) {
21731
21971
  arr.push(item);
@@ -21961,6 +22201,34 @@ function rotationZYXFromQuat(out, quat) {
21961
22201
  }
21962
22202
  return out;
21963
22203
  }
22204
+ function generateGUID() {
22205
+ return v4().replace(/-/g, '');
22206
+ }
22207
+ /**
22208
+ * 提取并转换 JSON 数据中的 anchor 值
22209
+ */
22210
+ function convertAnchor$1(anchor, particleOrigin) {
22211
+ if (anchor) {
22212
+ return [anchor[0] - 0.5, 0.5 - anchor[1]];
22213
+ }
22214
+ else if (particleOrigin) {
22215
+ return particleOriginTranslateMap[particleOrigin];
22216
+ }
22217
+ else {
22218
+ return [0, 0];
22219
+ }
22220
+ }
22221
+ var particleOriginTranslateMap = (_a$1 = {},
22222
+ _a$1[ParticleOrigin.PARTICLE_ORIGIN_CENTER] = [0, 0],
22223
+ _a$1[ParticleOrigin.PARTICLE_ORIGIN_CENTER_BOTTOM] = [0, -0.5],
22224
+ _a$1[ParticleOrigin.PARTICLE_ORIGIN_CENTER_TOP] = [0, 0.5],
22225
+ _a$1[ParticleOrigin.PARTICLE_ORIGIN_LEFT_TOP] = [-0.5, 0.5],
22226
+ _a$1[ParticleOrigin.PARTICLE_ORIGIN_LEFT_CENTER] = [-0.5, 0],
22227
+ _a$1[ParticleOrigin.PARTICLE_ORIGIN_LEFT_BOTTOM] = [-0.5, -0.5],
22228
+ _a$1[ParticleOrigin.PARTICLE_ORIGIN_RIGHT_CENTER] = [0.5, 0],
22229
+ _a$1[ParticleOrigin.PARTICLE_ORIGIN_RIGHT_BOTTOM] = [0.5, -0.5],
22230
+ _a$1[ParticleOrigin.PARTICLE_ORIGIN_RIGHT_TOP] = [0.5, 0.5],
22231
+ _a$1);
21964
22232
 
21965
22233
  function getStandardParticleContent(particle) {
21966
22234
  var _a;
@@ -22372,6 +22640,306 @@ function version22Migration(json) {
22372
22640
  });
22373
22641
  return json;
22374
22642
  }
22643
+ /**
22644
+ * 3.0 以下版本数据适配(runtime 2.0及以上版本支持)
22645
+ */
22646
+ function version30Migration(json) {
22647
+ var e_1, _a;
22648
+ var _b, _c, _d, _e, _f, _g, _h, _j;
22649
+ var result = Object.assign({}, json, {
22650
+ items: [],
22651
+ components: [],
22652
+ materials: [],
22653
+ shaders: [],
22654
+ geometries: [],
22655
+ });
22656
+ // 兼容老版本数据中不存在textures的情况
22657
+ (_b = result.textures) !== null && _b !== void 0 ? _b : (result.textures = []);
22658
+ result.textures.forEach(function (textureOptions) {
22659
+ Object.assign(textureOptions, {
22660
+ id: generateGUID(),
22661
+ dataType: DataType.Texture,
22662
+ });
22663
+ });
22664
+ if (result.textures.length < result.images.length) {
22665
+ for (var i = result.textures.length; i < result.images.length; i++) {
22666
+ result.textures.push({
22667
+ //@ts-expect-error
22668
+ id: generateGUID(),
22669
+ dataType: DataType.Texture,
22670
+ source: i,
22671
+ flipY: true,
22672
+ });
22673
+ }
22674
+ }
22675
+ var _loop_1 = function (composition) {
22676
+ var e_2, _m, e_3, _o;
22677
+ // composition 的 endbehaviour 兼容
22678
+ if (composition.endBehavior === END_BEHAVIOR_PAUSE_AND_DESTROY || composition.endBehavior === END_BEHAVIOR_PAUSE) {
22679
+ composition.endBehavior = END_BEHAVIOR_FREEZE;
22680
+ }
22681
+ var itemGuidMap = {};
22682
+ try {
22683
+ for (var _p = (e_2 = void 0, __values(composition.items)), _q = _p.next(); !_q.done; _q = _p.next()) {
22684
+ var item = _q.value;
22685
+ itemGuidMap[item.id] = generateGUID();
22686
+ // TODO: 编辑器测试用,上线后删除
22687
+ //@ts-expect-error
22688
+ item.oldId = item.id;
22689
+ item.id = itemGuidMap[item.id];
22690
+ }
22691
+ }
22692
+ catch (e_2_1) { e_2 = { error: e_2_1 }; }
22693
+ finally {
22694
+ try {
22695
+ if (_q && !_q.done && (_m = _p.return)) _m.call(_p);
22696
+ }
22697
+ finally { if (e_2) throw e_2.error; }
22698
+ }
22699
+ composition.items.forEach(function (item, index) {
22700
+ if (item.parentId) {
22701
+ if (item.parentId.includes('^')) {
22702
+ var parentId = (item.parentId).split('^')[0];
22703
+ var nodeId = (item.parentId).split('^')[1];
22704
+ item.parentId = itemGuidMap[parentId] + '^' + nodeId;
22705
+ }
22706
+ else {
22707
+ item.parentId = itemGuidMap[item.parentId];
22708
+ }
22709
+ }
22710
+ // @ts-expect-error fix item type
22711
+ result.items.push(item);
22712
+ // @ts-expect-error fix item type
22713
+ composition.items[index] = { id: item.id };
22714
+ });
22715
+ try {
22716
+ for (var _r = (e_3 = void 0, __values(result.items)), _s = _r.next(); !_s.done; _s = _r.next()) {
22717
+ var item = _s.value;
22718
+ // 原 texture 索引转为统一 guid 索引
22719
+ if (item.content) {
22720
+ if (item.content.renderer) {
22721
+ if (item.content.renderer.texture !== undefined) {
22722
+ var oldTextureId = item.content.renderer.texture;
22723
+ //@ts-expect-error
22724
+ item.content.renderer.texture = { id: result.textures[oldTextureId].id };
22725
+ }
22726
+ }
22727
+ if (item.content.trails) {
22728
+ if (item.content.trails.texture !== undefined) {
22729
+ var oldTextureId = item.content.trails.texture;
22730
+ //@ts-expect-error
22731
+ item.content.trails.texture = { id: result.textures[oldTextureId].id };
22732
+ }
22733
+ }
22734
+ }
22735
+ // item 的 transform 属性由数组转为 {x:n, y:n, z:n}
22736
+ if (item.transform) {
22737
+ //@ts-expect-error
22738
+ var position = __spreadArray([], __read((_c = item.transform.position) !== null && _c !== void 0 ? _c : [0, 0, 0]), false);
22739
+ //@ts-expect-error
22740
+ var rotation = __spreadArray([], __read((_d = item.transform.rotation) !== null && _d !== void 0 ? _d : [0, 0, 0]), false);
22741
+ //@ts-expect-error
22742
+ var scale = __spreadArray([], __read((_e = item.transform.scale) !== null && _e !== void 0 ? _e : [1, 1, 1]), false);
22743
+ Object.assign(item, {
22744
+ transform: {
22745
+ position: { x: position[0], y: position[1], z: position[2] },
22746
+ rotation: { x: rotation[0], y: rotation[1], z: rotation[2] },
22747
+ scale: { x: scale[0], y: scale[1], z: scale[0] },
22748
+ },
22749
+ });
22750
+ // sprite 的 scale 转为 size
22751
+ if (item.type === ItemType.sprite) {
22752
+ item.transform.size = { x: scale[0], y: scale[1] };
22753
+ item.transform.scale = { x: 1, y: 1, z: 1 };
22754
+ }
22755
+ // sprite 的 anchor 修正
22756
+ if (item.type === ItemType.sprite) {
22757
+ var content = item.content;
22758
+ if (!content.renderer) {
22759
+ content.renderer = {};
22760
+ }
22761
+ var renderer = content.renderer;
22762
+ var realAnchor = convertAnchor$1(renderer.anchor, renderer.particleOrigin);
22763
+ var startSize = item.transform.size;
22764
+ // 兼容旧JSON(anchor和particleOrigin可能同时存在)
22765
+ if (!renderer.anchor && renderer.particleOrigin !== undefined) {
22766
+ item.transform.position.x += -realAnchor[0] * ((_f = startSize === null || startSize === void 0 ? void 0 : startSize.x) !== null && _f !== void 0 ? _f : 1);
22767
+ item.transform.position.y += -realAnchor[1] * ((_g = startSize === null || startSize === void 0 ? void 0 : startSize.y) !== null && _g !== void 0 ? _g : 1);
22768
+ }
22769
+ item.transform.anchor = { x: realAnchor[0] * ((_h = startSize === null || startSize === void 0 ? void 0 : startSize.x) !== null && _h !== void 0 ? _h : 1), y: realAnchor[1] * ((_j = startSize === null || startSize === void 0 ? void 0 : startSize.y) !== null && _j !== void 0 ? _j : 1) };
22770
+ }
22771
+ }
22772
+ if (item.type === ItemType.particle) {
22773
+ var content = item.content;
22774
+ if (!content.renderer) {
22775
+ content.renderer = {};
22776
+ }
22777
+ var renderer = content.renderer;
22778
+ content.renderer.anchor = convertAnchor$1(renderer.anchor, renderer.particleOrigin);
22779
+ }
22780
+ // 动画数据转化 TODO: 动画数据移到 TimelineComponentData
22781
+ item.content.tracks = [];
22782
+ var tracks = item.content.tracks;
22783
+ if (item.type !== ItemType.particle) {
22784
+ tracks.push({
22785
+ clips: [
22786
+ {
22787
+ dataType: 'TransformAnimationPlayableAsset',
22788
+ animationClip: {
22789
+ sizeOverLifetime: item.content.sizeOverLifetime,
22790
+ rotationOverLifetime: item.content.rotationOverLifetime,
22791
+ positionOverLifetime: item.content.positionOverLifetime,
22792
+ },
22793
+ },
22794
+ ],
22795
+ });
22796
+ }
22797
+ if (item.type === ItemType.sprite) {
22798
+ tracks.push({
22799
+ clips: [
22800
+ {
22801
+ dataType: 'SpriteColorAnimationPlayableAsset',
22802
+ animationClip: {
22803
+ colorOverLifetime: item.content.colorOverLifetime,
22804
+ startColor: item.content.options.startColor,
22805
+ },
22806
+ },
22807
+ ],
22808
+ });
22809
+ }
22810
+ // gizmo 的 target id 转换为新的 item guid
22811
+ if (item.content.options.target) {
22812
+ item.content.options.target = itemGuidMap[item.content.options.target];
22813
+ }
22814
+ // item 的 content 转为 component data 加入 JSONScene.components
22815
+ var uuid = generateGUID();
22816
+ if (item.type === ItemType.sprite) {
22817
+ item.components = [];
22818
+ result.components.push(item.content);
22819
+ item.content.id = uuid;
22820
+ item.content.dataType = DataType.SpriteComponent;
22821
+ item.content.item = { id: item.id };
22822
+ item.dataType = DataType.VFXItemData;
22823
+ //@ts-expect-error
22824
+ item.components.push({ id: item.content.id });
22825
+ }
22826
+ else if (item.type === ItemType.particle) {
22827
+ item.components = [];
22828
+ result.components.push(item.content);
22829
+ item.content.id = uuid;
22830
+ item.content.dataType = DataType.ParticleSystem;
22831
+ item.content.item = { id: item.id };
22832
+ item.dataType = DataType.VFXItemData;
22833
+ //@ts-expect-error
22834
+ item.components.push({ id: item.content.id });
22835
+ }
22836
+ else if (item.type === ItemType.mesh) {
22837
+ item.components = [];
22838
+ result.components.push(item.content);
22839
+ item.content.id = uuid;
22840
+ item.content.dataType = DataType.MeshComponent;
22841
+ item.content.item = { id: item.id };
22842
+ item.dataType = DataType.VFXItemData;
22843
+ //@ts-expect-error
22844
+ item.components.push({ id: item.content.id });
22845
+ }
22846
+ else if (item.type === ItemType.skybox) {
22847
+ item.components = [];
22848
+ result.components.push(item.content);
22849
+ item.content.id = uuid;
22850
+ item.content.dataType = DataType.SkyboxComponent;
22851
+ item.content.item = { id: item.id };
22852
+ item.dataType = DataType.VFXItemData;
22853
+ //@ts-expect-error
22854
+ item.components.push({ id: item.content.id });
22855
+ }
22856
+ else if (item.type === ItemType.light) {
22857
+ item.components = [];
22858
+ result.components.push(item.content);
22859
+ item.content.id = uuid;
22860
+ item.content.dataType = DataType.LightComponent;
22861
+ item.content.item = { id: item.id };
22862
+ item.dataType = DataType.VFXItemData;
22863
+ //@ts-expect-error
22864
+ item.components.push({ id: item.content.id });
22865
+ }
22866
+ else if (item.type === 'camera') {
22867
+ item.components = [];
22868
+ result.components.push(item.content);
22869
+ item.content.id = uuid;
22870
+ item.content.dataType = DataType.CameraComponent;
22871
+ item.content.item = { id: item.id };
22872
+ item.dataType = DataType.VFXItemData;
22873
+ //@ts-expect-error
22874
+ item.components.push({ id: item.content.id });
22875
+ }
22876
+ else if (item.type === ItemType.tree) {
22877
+ item.components = [];
22878
+ result.components.push(item.content);
22879
+ item.content.id = uuid;
22880
+ item.content.dataType = DataType.TreeComponent;
22881
+ item.content.item = { id: item.id };
22882
+ item.dataType = DataType.VFXItemData;
22883
+ //@ts-expect-error
22884
+ item.components.push({ id: item.content.id });
22885
+ }
22886
+ else if (item.type === ItemType.interact) {
22887
+ item.components = [];
22888
+ result.components.push(item.content);
22889
+ item.content.id = uuid;
22890
+ item.content.dataType = DataType.InteractComponent;
22891
+ item.content.item = { id: item.id };
22892
+ item.dataType = DataType.VFXItemData;
22893
+ //@ts-expect-error
22894
+ item.components.push({ id: item.content.id });
22895
+ }
22896
+ else if (item.type === ItemType.camera) {
22897
+ item.components = [];
22898
+ result.components.push(item.content);
22899
+ item.content.id = uuid;
22900
+ item.content.dataType = DataType.CameraController;
22901
+ item.content.item = { id: item.id };
22902
+ item.dataType = DataType.VFXItemData;
22903
+ //@ts-expect-error
22904
+ item.components.push({ id: item.content.id });
22905
+ }
22906
+ else if (item.type === ItemType.text) {
22907
+ item.components = [];
22908
+ result.components.push(item.content);
22909
+ item.content.id = uuid;
22910
+ item.content.dataType = DataType.TextComponent;
22911
+ item.content.item = { id: item.id };
22912
+ item.dataType = DataType.VFXItemData;
22913
+ //@ts-expect-error
22914
+ item.components.push({ id: item.content.id });
22915
+ }
22916
+ }
22917
+ }
22918
+ catch (e_3_1) { e_3 = { error: e_3_1 }; }
22919
+ finally {
22920
+ try {
22921
+ if (_s && !_s.done && (_o = _r.return)) _o.call(_r);
22922
+ }
22923
+ finally { if (e_3) throw e_3.error; }
22924
+ }
22925
+ };
22926
+ try {
22927
+ // 更正Composition.endBehavior
22928
+ for (var _k = __values(json.compositions), _l = _k.next(); !_l.done; _l = _k.next()) {
22929
+ var composition = _l.value;
22930
+ _loop_1(composition);
22931
+ }
22932
+ }
22933
+ catch (e_1_1) { e_1 = { error: e_1_1 }; }
22934
+ finally {
22935
+ try {
22936
+ if (_l && !_l.done && (_a = _k.return)) _a.call(_k);
22937
+ }
22938
+ finally { if (e_1) throw e_1.error; }
22939
+ }
22940
+ result.version = '3.0';
22941
+ return result;
22942
+ }
22375
22943
 
22376
22944
  var v0 = /^(\d+)\.(\d+)\.(\d+)(-(\w+)\.\d+)?$/;
22377
22945
  var standardVersion = /^(\d+)\.(\d+)$/;
@@ -22381,16 +22949,16 @@ function getStandardJSON(json) {
22381
22949
  if (!json || typeof json !== 'object') {
22382
22950
  throw Error('expect a json object');
22383
22951
  }
22384
- // 修正老版本数据中,meshItem以及lightItem结束行为错误问题
22952
+ // 修正老版本数据中,meshItem 以及 lightItem 结束行为错误问题
22385
22953
  version22Migration(json);
22386
22954
  if (v0.test(json.version)) {
22387
22955
  reverseParticle = ((_a = (/^(\d+)/).exec(json.version)) === null || _a === void 0 ? void 0 : _a[0]) === '0';
22388
- return version21Migration(getStandardJSONFromV0(json));
22956
+ return version30Migration(version21Migration(getStandardJSONFromV0(json)));
22389
22957
  }
22390
22958
  var mainVersion = (_b = standardVersion.exec(json.version)) === null || _b === void 0 ? void 0 : _b[1];
22391
22959
  if (mainVersion) {
22392
- if (Number(mainVersion) < 2) {
22393
- return version21Migration(json);
22960
+ if (Number(mainVersion) < 3) {
22961
+ return version30Migration(version21Migration(json));
22394
22962
  }
22395
22963
  return json;
22396
22964
  }
@@ -22714,7 +23282,7 @@ function version3Migration(scene) {
22714
23282
  try {
22715
23283
  for (var _j = __values$1(ecScene.items), _k = _j.next(); !_k.done; _k = _j.next()) {
22716
23284
  var item = _k.value;
22717
- itemGuidMap[item.id] = generateGUID();
23285
+ itemGuidMap[item.id] = generateGUID$1();
22718
23286
  // TODO: 编辑器测试用,上线后删除
22719
23287
  //@ts-expect-error
22720
23288
  item.oldId = item.id;
@@ -22770,7 +23338,7 @@ function version3Migration(scene) {
22770
23338
  // texture 增加 id 和 dataType
22771
23339
  for (var _q = __values$1(scene.textureOptions), _r = _q.next(); !_r.done; _r = _q.next()) {
22772
23340
  var texture = _r.value;
22773
- texture.id = generateGUID();
23341
+ texture.id = generateGUID$1();
22774
23342
  texture.dataType = exports.DataType.Texture;
22775
23343
  }
22776
23344
  }
@@ -22790,23 +23358,15 @@ function version3Migration(scene) {
22790
23358
  var item = _t.value;
22791
23359
  // 原 texture 索引转为统一 guid 索引
22792
23360
  if (item.content) {
22793
- //@ts-expect-error
22794
23361
  if (item.content.renderer) {
22795
- //@ts-expect-error
22796
23362
  if (item.content.renderer.texture !== undefined) {
22797
- //@ts-expect-error
22798
23363
  var oldTextureId = item.content.renderer.texture;
22799
- //@ts-expect-error
22800
23364
  item.content.renderer.texture = { id: scene.textureOptions[oldTextureId].id };
22801
23365
  }
22802
23366
  }
22803
- //@ts-expect-error
22804
23367
  if (item.content.trails) {
22805
- //@ts-expect-error
22806
23368
  if (item.content.trails.texture !== undefined) {
22807
- //@ts-expect-error
22808
23369
  var oldTextureId = item.content.trails.texture;
22809
- //@ts-expect-error
22810
23370
  item.content.trails.texture = { id: scene.textureOptions[oldTextureId].id };
22811
23371
  }
22812
23372
  }
@@ -22817,12 +23377,14 @@ function version3Migration(scene) {
22817
23377
  var rotation = item.transform.rotation;
22818
23378
  var scale = item.transform.scale;
22819
23379
  if (!position) {
23380
+ //@ts-expect-error
22820
23381
  position = [0, 0, 0];
22821
23382
  }
22822
23383
  if (!rotation) {
22823
23384
  rotation = [0, 0, 0];
22824
23385
  }
22825
23386
  if (!scale) {
23387
+ //@ts-expect-error
22826
23388
  scale = [1, 1, 1];
22827
23389
  }
22828
23390
  item.transform = {
@@ -22843,12 +23405,9 @@ function version3Migration(scene) {
22843
23405
  // sprite 的 anchor 修正
22844
23406
  if (item.type === ItemType$1.sprite) {
22845
23407
  var content = item.content;
22846
- //@ts-expect-error
22847
23408
  if (!content.renderer) {
22848
- //@ts-expect-error
22849
23409
  content.renderer = {};
22850
23410
  }
22851
- //@ts-expect-error
22852
23411
  var renderer = content.renderer;
22853
23412
  var realAnchor = convertAnchor(renderer.anchor, renderer.particleOrigin);
22854
23413
  //@ts-expect-error
@@ -22866,14 +23425,10 @@ function version3Migration(scene) {
22866
23425
  }
22867
23426
  if (item.type === ItemType$1.particle) {
22868
23427
  var content = item.content;
22869
- //@ts-expect-error
22870
23428
  if (!content.renderer) {
22871
- //@ts-expect-error
22872
23429
  content.renderer = {};
22873
23430
  }
22874
- //@ts-expect-error
22875
23431
  var renderer = content.renderer;
22876
- //@ts-expect-error
22877
23432
  content.renderer.anchor = convertAnchor(renderer.anchor, renderer.particleOrigin);
22878
23433
  }
22879
23434
  // item 的 endbehaviour 兼容
@@ -22882,9 +23437,7 @@ function version3Migration(scene) {
22882
23437
  item.endBehavior = END_BEHAVIOR_FREEZE$1;
22883
23438
  }
22884
23439
  // 动画数据转化 TODO: 动画数据移到 TimelineComponentData
22885
- //@ts-expect-error
22886
23440
  item.content.tracks = [];
22887
- //@ts-expect-error
22888
23441
  var tracks = item.content.tracks;
22889
23442
  if (item.type !== ItemType$1.particle) {
22890
23443
  tracks.push({
@@ -22892,11 +23445,8 @@ function version3Migration(scene) {
22892
23445
  {
22893
23446
  dataType: 'TransformAnimationPlayableAsset',
22894
23447
  animationClip: {
22895
- //@ts-expect-error
22896
23448
  sizeOverLifetime: item.content.sizeOverLifetime,
22897
- //@ts-expect-error
22898
23449
  rotationOverLifetime: item.content.rotationOverLifetime,
22899
- //@ts-expect-error
22900
23450
  positionOverLifetime: item.content.positionOverLifetime,
22901
23451
  },
22902
23452
  },
@@ -22909,9 +23459,7 @@ function version3Migration(scene) {
22909
23459
  {
22910
23460
  dataType: 'SpriteColorAnimationPlayableAsset',
22911
23461
  animationClip: {
22912
- //@ts-expect-error
22913
23462
  colorOverLifetime: item.content.colorOverLifetime,
22914
- //@ts-expect-error
22915
23463
  startColor: item.content.options.startColor,
22916
23464
  },
22917
23465
  },
@@ -22919,169 +23467,107 @@ function version3Migration(scene) {
22919
23467
  });
22920
23468
  }
22921
23469
  // gizmo 的 target id 转换为新的 item guid
22922
- //@ts-expect-error
22923
- if (item.content.options.target) {
22924
- //@ts-expect-error
23470
+ if (item.content && item.content.options && item.content.options.target) {
22925
23471
  item.content.options.target = itemGuidMap[item.content.options.target];
22926
23472
  }
22927
23473
  // item 的 content 转为 component data 加入 JSONScene.components
22928
- var uuid = v4().replace(/-/g, '');
23474
+ var uuid = v4$1().replace(/-/g, '');
22929
23475
  if (item.type === ItemType$1.sprite) {
22930
- //@ts-expect-error
22931
23476
  item.components = [];
22932
- //@ts-expect-error
22933
23477
  components.push(item.content);
22934
- //@ts-expect-error
22935
23478
  item.content.id = uuid;
22936
- //@ts-expect-error
22937
23479
  item.content.dataType = exports.DataType.SpriteComponent;
22938
- //@ts-expect-error
22939
23480
  item.content.item = { id: item.id };
22940
- //@ts-expect-error
22941
23481
  item.dataType = exports.DataType.VFXItemData;
22942
23482
  //@ts-expect-error
22943
23483
  item.components.push({ id: item.content.id });
22944
23484
  }
22945
23485
  else if (item.type === ItemType$1.particle) {
22946
- //@ts-expect-error
22947
23486
  item.components = [];
22948
- //@ts-expect-error
22949
23487
  components.push(item.content);
22950
- //@ts-expect-error
22951
23488
  item.content.id = uuid;
22952
- //@ts-expect-error
22953
23489
  item.content.dataType = exports.DataType.ParticleSystem;
22954
- //@ts-expect-error
22955
23490
  item.content.item = { id: item.id };
22956
- //@ts-expect-error
22957
23491
  item.dataType = exports.DataType.VFXItemData;
22958
23492
  //@ts-expect-error
22959
23493
  item.components.push({ id: item.content.id });
22960
23494
  }
22961
23495
  else if (item.type === ItemType$1.mesh) {
22962
- //@ts-expect-error
22963
23496
  item.components = [];
22964
- //@ts-expect-error
22965
23497
  components.push(item.content);
22966
- //@ts-expect-error
22967
23498
  item.content.id = uuid;
22968
- //@ts-expect-error
22969
23499
  item.content.dataType = exports.DataType.MeshComponent;
22970
- //@ts-expect-error
22971
23500
  item.content.item = { id: item.id };
22972
- //@ts-expect-error
22973
23501
  item.dataType = exports.DataType.VFXItemData;
22974
23502
  //@ts-expect-error
22975
23503
  item.components.push({ id: item.content.id });
22976
23504
  }
22977
23505
  else if (item.type === ItemType$1.skybox) {
22978
- //@ts-expect-error
22979
23506
  item.components = [];
22980
- //@ts-expect-error
22981
23507
  components.push(item.content);
22982
- //@ts-expect-error
22983
23508
  item.content.id = uuid;
22984
- //@ts-expect-error
22985
23509
  item.content.dataType = exports.DataType.SkyboxComponent;
22986
- //@ts-expect-error
22987
23510
  item.content.item = { id: item.id };
22988
- //@ts-expect-error
22989
23511
  item.dataType = exports.DataType.VFXItemData;
22990
23512
  //@ts-expect-error
22991
23513
  item.components.push({ id: item.content.id });
22992
23514
  }
22993
23515
  else if (item.type === ItemType$1.light) {
22994
- //@ts-expect-error
22995
23516
  item.components = [];
22996
- //@ts-expect-error
22997
23517
  components.push(item.content);
22998
- //@ts-expect-error
22999
23518
  item.content.id = uuid;
23000
- //@ts-expect-error
23001
23519
  item.content.dataType = exports.DataType.LightComponent;
23002
- //@ts-expect-error
23003
23520
  item.content.item = { id: item.id };
23004
- //@ts-expect-error
23005
23521
  item.dataType = exports.DataType.VFXItemData;
23006
23522
  //@ts-expect-error
23007
23523
  item.components.push({ id: item.content.id });
23008
23524
  }
23009
23525
  else if (item.type === 'camera') {
23010
- //@ts-expect-error
23011
23526
  item.components = [];
23012
- //@ts-expect-error
23013
23527
  components.push(item.content);
23014
- //@ts-expect-error
23015
23528
  item.content.id = uuid;
23016
- //@ts-expect-error
23017
23529
  item.content.dataType = exports.DataType.CameraComponent;
23018
- //@ts-expect-error
23019
23530
  item.content.item = { id: item.id };
23020
- //@ts-expect-error
23021
23531
  item.dataType = exports.DataType.VFXItemData;
23022
23532
  //@ts-expect-error
23023
23533
  item.components.push({ id: item.content.id });
23024
23534
  }
23025
23535
  else if (item.type === ItemType$1.tree) {
23026
- //@ts-expect-error
23027
23536
  item.components = [];
23028
- //@ts-expect-error
23029
23537
  components.push(item.content);
23030
- //@ts-expect-error
23031
23538
  item.content.id = uuid;
23032
- //@ts-expect-error
23033
23539
  item.content.dataType = exports.DataType.TreeComponent;
23034
- //@ts-expect-error
23035
23540
  item.content.item = { id: item.id };
23036
- //@ts-expect-error
23037
23541
  item.dataType = exports.DataType.VFXItemData;
23038
23542
  //@ts-expect-error
23039
23543
  item.components.push({ id: item.content.id });
23040
23544
  }
23041
23545
  else if (item.type === ItemType$1.interact) {
23042
- //@ts-expect-error
23043
23546
  item.components = [];
23044
- //@ts-expect-error
23045
23547
  components.push(item.content);
23046
- //@ts-expect-error
23047
23548
  item.content.id = uuid;
23048
- //@ts-expect-error
23049
23549
  item.content.dataType = exports.DataType.InteractComponent;
23050
- //@ts-expect-error
23051
23550
  item.content.item = { id: item.id };
23052
- //@ts-expect-error
23053
23551
  item.dataType = exports.DataType.VFXItemData;
23054
23552
  //@ts-expect-error
23055
23553
  item.components.push({ id: item.content.id });
23056
23554
  }
23057
23555
  else if (item.type === ItemType$1.camera) {
23058
- //@ts-expect-error
23059
23556
  item.components = [];
23060
- //@ts-expect-error
23061
23557
  components.push(item.content);
23062
- //@ts-expect-error
23063
23558
  item.content.id = uuid;
23064
- //@ts-expect-error
23065
23559
  item.content.dataType = exports.DataType.CameraController;
23066
- //@ts-expect-error
23067
23560
  item.content.item = { id: item.id };
23068
- //@ts-expect-error
23069
23561
  item.dataType = exports.DataType.VFXItemData;
23070
23562
  //@ts-expect-error
23071
23563
  item.components.push({ id: item.content.id });
23072
23564
  }
23073
23565
  else if (item.type === ItemType$1.text) {
23074
- //@ts-expect-error
23075
23566
  item.components = [];
23076
- //@ts-expect-error
23077
23567
  components.push(item.content);
23078
- //@ts-expect-error
23079
23568
  item.content.id = uuid;
23080
- //@ts-expect-error
23081
23569
  item.content.dataType = exports.DataType.TextComponent;
23082
- //@ts-expect-error
23083
23570
  item.content.item = { id: item.id };
23084
- //@ts-expect-error
23085
23571
  item.dataType = exports.DataType.VFXItemData;
23086
23572
  //@ts-expect-error
23087
23573
  item.components.push({ id: item.content.id });
@@ -23105,7 +23591,7 @@ function convertAnchor(anchor, particleOrigin) {
23105
23591
  return [anchor[0] - 0.5, 0.5 - anchor[1]];
23106
23592
  }
23107
23593
  else if (particleOrigin) {
23108
- return particleOriginTranslateMap[particleOrigin];
23594
+ return particleOriginTranslateMap$1[particleOrigin];
23109
23595
  }
23110
23596
  else {
23111
23597
  return [0, 0];
@@ -23383,16 +23869,17 @@ var AssetManager = /** @class */ (function () {
23383
23869
  };
23384
23870
  AssetManager.prototype.processBins = function (bins) {
23385
23871
  return __awaiter(this, void 0, void 0, function () {
23386
- var renderLevel, jobs;
23872
+ var renderLevel, baseUrl, jobs;
23387
23873
  var _this = this;
23388
23874
  return __generator(this, function (_a) {
23389
23875
  renderLevel = this.options.renderLevel;
23876
+ baseUrl = this.baseUrl;
23390
23877
  jobs = bins.map(function (bin) {
23391
23878
  if (bin instanceof ArrayBuffer) {
23392
23879
  return bin;
23393
23880
  }
23394
23881
  if (passRenderLevel(bin.renderLevel, renderLevel)) {
23395
- return _this.loadBins(bin.url);
23882
+ return _this.loadBins(new URL(bin.url, baseUrl).href);
23396
23883
  }
23397
23884
  throw new Error("Invalid bins source: ".concat(JSON.stringify(bins)));
23398
23885
  });
@@ -23410,13 +23897,14 @@ var AssetManager = /** @class */ (function () {
23410
23897
  return [2 /*return*/];
23411
23898
  }
23412
23899
  jobs = fonts.map(function (font) { return __awaiter(_this, void 0, void 0, function () {
23413
- var fontFace;
23900
+ var url, fontFace;
23414
23901
  var _a;
23415
23902
  return __generator(this, function (_b) {
23416
23903
  switch (_b.label) {
23417
23904
  case 0:
23418
23905
  if (!(font.fontURL && !AssetManager.fonts.has(font.fontFamily))) return [3 /*break*/, 4];
23419
- fontFace = new FontFace((_a = font.fontFamily) !== null && _a !== void 0 ? _a : '', 'url(' + font.fontURL + ')');
23906
+ url = new URL(font.fontURL, this.baseUrl).href;
23907
+ fontFace = new FontFace((_a = font.fontFamily) !== null && _a !== void 0 ? _a : '', 'url(' + url + ')');
23420
23908
  _b.label = 1;
23421
23909
  case 1:
23422
23910
  _b.trys.push([1, 3, , 4]);
@@ -23429,7 +23917,7 @@ var AssetManager = /** @class */ (function () {
23429
23917
  return [3 /*break*/, 4];
23430
23918
  case 3:
23431
23919
  _b.sent();
23432
- logger.warn("Invalid fonts source: ".concat(JSON.stringify(font.fontURL)));
23920
+ logger.warn("Invalid fonts source: ".concat(JSON.stringify(url)));
23433
23921
  return [3 /*break*/, 4];
23434
23922
  case 4: return [2 /*return*/];
23435
23923
  }
@@ -23678,7 +24166,7 @@ function createTextureOptionsBySource(image, sourceFrom) {
23678
24166
  return image.source;
23679
24167
  }
23680
24168
  else if (image instanceof HTMLImageElement ||
23681
- image instanceof HTMLCanvasElement) {
24169
+ isCanvas(image)) {
23682
24170
  return {
23683
24171
  image: image,
23684
24172
  sourceType: exports.TextureSourceType.image,
@@ -23740,6 +24228,11 @@ function base64ToFile(base64, filename, contentType) {
23740
24228
  var file = new File([blob], filename, { type: contentType });
23741
24229
  return file;
23742
24230
  }
24231
+ function isCanvas(cavnas) {
24232
+ var _a;
24233
+ // 小程序 Canvas 无法使用 instanceof HTMLCanvasElement 判断
24234
+ return typeof cavnas === 'object' && cavnas !== null && ((_a = cavnas.tagName) === null || _a === void 0 ? void 0 : _a.toUpperCase()) === 'CANVAS';
24235
+ }
23743
24236
 
23744
24237
  var tmpScale = new Vector3(1, 1, 1);
23745
24238
  /**
@@ -23959,8 +24452,9 @@ var Camera = /** @class */ (function () {
23959
24452
  Camera.prototype.getInverseVPRatio = function (z) {
23960
24453
  var pos = new Vector3(0, 0, z);
23961
24454
  var mat = this.getViewProjectionMatrix();
23962
- var nz = pos.applyMatrix(mat).z;
23963
- return new Vector3(1, 1, nz).applyMatrix(mat);
24455
+ var inverseVP = this.getInverseViewProjectionMatrix();
24456
+ var nz = mat.projectPoint(pos).z;
24457
+ return inverseVP.projectPoint(new Vector3(1, 1, nz));
23964
24458
  };
23965
24459
  /**
23966
24460
  * 设置相机的旋转四元数
@@ -23972,7 +24466,6 @@ var Camera = /** @class */ (function () {
23972
24466
  this.dirty = true;
23973
24467
  }
23974
24468
  else {
23975
- this.options.quat;
23976
24469
  if (!this.options.quat.equals(value)) {
23977
24470
  this.options.quat.copyFrom(value);
23978
24471
  this.dirty = true;
@@ -24140,8 +24633,7 @@ var CompositionComponent = /** @class */ (function (_super) {
24140
24633
  }
24141
24634
  item.getComponent(CompositionComponent).createContent();
24142
24635
  }
24143
- else if (itemData.type === 'ECS' ||
24144
- itemData.type === ItemType$1.sprite ||
24636
+ else if (itemData.type === ItemType$1.sprite ||
24145
24637
  itemData.type === ItemType$1.text ||
24146
24638
  itemData.type === ItemType$1.particle ||
24147
24639
  itemData.type === ItemType$1.mesh ||
@@ -24159,20 +24651,7 @@ var CompositionComponent = /** @class */ (function (_super) {
24159
24651
  item = new VFXItem(this.engine, itemData);
24160
24652
  item.composition = this.item.composition;
24161
24653
  // 兼容老的数据代码,json 更新后可移除
24162
- switch (itemData.type) {
24163
- case ItemType$1.text: {
24164
- // 添加文本组件
24165
- var textItem = new TextComponent(this.engine, itemData.content);
24166
- textItem.item = item;
24167
- item.components.push(textItem);
24168
- item.rendererComponents.push(textItem);
24169
- item._content = textItem;
24170
- break;
24171
- }
24172
- default: {
24173
- item = createVFXItem(itemData, this.item.composition);
24174
- }
24175
- }
24654
+ item = createVFXItem(itemData, this.item.composition);
24176
24655
  }
24177
24656
  item.parent = this.item;
24178
24657
  // 相机不跟随合成移动
@@ -25562,10 +26041,8 @@ var Engine = /** @class */ (function () {
25562
26041
  Engine.prototype.addPackageDatas = function (scene) {
25563
26042
  var e_1, _a, e_2, _b, e_3, _c, e_4, _d, e_5, _e, e_6, _f;
25564
26043
  var jsonScene = scene.jsonScene;
25565
- //@ts-expect-error
25566
26044
  if (jsonScene.items) {
25567
26045
  try {
25568
- //@ts-expect-error
25569
26046
  for (var _g = __values$1(jsonScene.items), _h = _g.next(); !_h.done; _h = _g.next()) {
25570
26047
  var vfxItemData = _h.value;
25571
26048
  this.addEffectsObjectData(vfxItemData);
@@ -25579,10 +26056,8 @@ var Engine = /** @class */ (function () {
25579
26056
  finally { if (e_1) throw e_1.error; }
25580
26057
  }
25581
26058
  }
25582
- //@ts-expect-error
25583
26059
  if (jsonScene.materials) {
25584
26060
  try {
25585
- //@ts-expect-error
25586
26061
  for (var _j = __values$1(jsonScene.materials), _k = _j.next(); !_k.done; _k = _j.next()) {
25587
26062
  var materialData = _k.value;
25588
26063
  this.addEffectsObjectData(materialData);
@@ -25596,10 +26071,8 @@ var Engine = /** @class */ (function () {
25596
26071
  finally { if (e_2) throw e_2.error; }
25597
26072
  }
25598
26073
  }
25599
- //@ts-expect-error
25600
26074
  if (jsonScene.shaders) {
25601
26075
  try {
25602
- //@ts-expect-error
25603
26076
  for (var _l = __values$1(jsonScene.shaders), _m = _l.next(); !_m.done; _m = _l.next()) {
25604
26077
  var shaderData = _m.value;
25605
26078
  this.addEffectsObjectData(shaderData);
@@ -25613,10 +26086,8 @@ var Engine = /** @class */ (function () {
25613
26086
  finally { if (e_3) throw e_3.error; }
25614
26087
  }
25615
26088
  }
25616
- //@ts-expect-error
25617
26089
  if (jsonScene.geometries) {
25618
26090
  try {
25619
- //@ts-expect-error
25620
26091
  for (var _o = __values$1(jsonScene.geometries), _p = _o.next(); !_p.done; _p = _o.next()) {
25621
26092
  var geometryData = _p.value;
25622
26093
  this.addEffectsObjectData(geometryData);
@@ -25630,10 +26101,8 @@ var Engine = /** @class */ (function () {
25630
26101
  finally { if (e_4) throw e_4.error; }
25631
26102
  }
25632
26103
  }
25633
- //@ts-expect-error
25634
26104
  if (jsonScene.components) {
25635
26105
  try {
25636
- //@ts-expect-error
25637
26106
  for (var _q = __values$1(jsonScene.components), _r = _q.next(); !_r.done; _r = _q.next()) {
25638
26107
  var componentData = _r.value;
25639
26108
  this.addEffectsObjectData(componentData);
@@ -26073,6 +26542,7 @@ exports.SPRITE_VERTEX_STRIDE = SPRITE_VERTEX_STRIDE;
26073
26542
  exports.SemanticMap = SemanticMap;
26074
26543
  exports.SerializationHelper = SerializationHelper;
26075
26544
  exports.Shader = Shader;
26545
+ exports.ShaderVariant = ShaderVariant;
26076
26546
  exports.SpriteColorPlayable = SpriteColorPlayable;
26077
26547
  exports.SpriteComponent = SpriteComponent;
26078
26548
  exports.SpriteLoader = SpriteLoader;
@@ -26142,7 +26612,7 @@ exports.gaussianDownHFrag = gaussianDownHFrag;
26142
26612
  exports.gaussianDownVFrag = gaussianDownVFrag;
26143
26613
  exports.gaussianUpFrag = gaussianUpFrag;
26144
26614
  exports.generateEmptyTypedArray = generateEmptyTypedArray;
26145
- exports.generateGUID = generateGUID;
26615
+ exports.generateGUID = generateGUID$1;
26146
26616
  exports.generateHalfFloatTexture = generateHalfFloatTexture;
26147
26617
  exports.getBackgroundImage = getBackgroundImage;
26148
26618
  exports.getColorFromGradientStops = getColorFromGradientStops;
@@ -26198,7 +26668,7 @@ exports.nearestPowerOfTwo = nearestPowerOfTwo;
26198
26668
  exports.noop = noop;
26199
26669
  exports.parsePercent = parsePercent$1;
26200
26670
  exports.particleFrag = particleFrag;
26201
- exports.particleOriginTranslateMap = particleOriginTranslateMap;
26671
+ exports.particleOriginTranslateMap = particleOriginTranslateMap$1;
26202
26672
  exports.particleVert = particleVert;
26203
26673
  exports.pluginLoaderMap = pluginLoaderMap;
26204
26674
  exports.random = random;