@galacean/effects-core 2.0.0-alpha.2 → 2.0.0-alpha.4

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 core for the web
4
4
  * Author: Ant Group CO., Ltd.
5
5
  * Contributors: 燃然,飂兮,十弦,云垣,茂安,意绮
6
- * Version: v2.0.0-alpha.2
6
+ * Version: v2.0.0-alpha.4
7
7
  */
8
8
 
9
9
  /******************************************************************************
@@ -122,7 +122,7 @@ function __read$3(o, n) {
122
122
  return ar;
123
123
  }
124
124
 
125
- function __spreadArray$2(to, from, pack) {
125
+ function __spreadArray$3(to, from, pack) {
126
126
  if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {
127
127
  if (ar || !(i in from)) {
128
128
  if (!ar) ar = Array.prototype.slice.call(from, 0, i);
@@ -140,20 +140,20 @@ typeof SuppressedError === "function" ? SuppressedError : function (error, suppr
140
140
  // Unique ID creation requires a high quality random # generator. In the browser we therefore
141
141
  // require the crypto API and do not support built-in fallback to lower quality random number
142
142
  // generators (like Math.random()).
143
- let getRandomValues;
144
- const rnds8 = new Uint8Array(16);
145
- function rng() {
143
+ let getRandomValues$1;
144
+ const rnds8$1 = new Uint8Array(16);
145
+ function rng$1() {
146
146
  // lazy load so that environments that need to polyfill have a chance to do so
147
- if (!getRandomValues) {
147
+ if (!getRandomValues$1) {
148
148
  // getRandomValues needs to be invoked in a context where "this" is a Crypto implementation.
149
- getRandomValues = typeof crypto !== 'undefined' && crypto.getRandomValues && crypto.getRandomValues.bind(crypto);
149
+ getRandomValues$1 = typeof crypto !== 'undefined' && crypto.getRandomValues && crypto.getRandomValues.bind(crypto);
150
150
 
151
- if (!getRandomValues) {
151
+ if (!getRandomValues$1) {
152
152
  throw new Error('crypto.getRandomValues() not supported. See https://github.com/uuidjs/uuid#getrandomvalues-not-supported');
153
153
  }
154
154
  }
155
155
 
156
- return getRandomValues(rnds8);
156
+ return getRandomValues$1(rnds8$1);
157
157
  }
158
158
 
159
159
  /**
@@ -161,30 +161,30 @@ function rng() {
161
161
  * XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX
162
162
  */
163
163
 
164
- const byteToHex = [];
164
+ const byteToHex$2 = [];
165
165
 
166
166
  for (let i = 0; i < 256; ++i) {
167
- byteToHex.push((i + 0x100).toString(16).slice(1));
167
+ byteToHex$2.push((i + 0x100).toString(16).slice(1));
168
168
  }
169
169
 
170
- function unsafeStringify(arr, offset = 0) {
170
+ function unsafeStringify$1(arr, offset = 0) {
171
171
  // Note: Be careful editing this code! It's been tuned for performance
172
172
  // and works in ways you may not expect. See https://github.com/uuidjs/uuid/pull/434
173
- 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]];
173
+ 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]];
174
174
  }
175
175
 
176
- const randomUUID = typeof crypto !== 'undefined' && crypto.randomUUID && crypto.randomUUID.bind(crypto);
177
- var native = {
178
- randomUUID
176
+ const randomUUID$1 = typeof crypto !== 'undefined' && crypto.randomUUID && crypto.randomUUID.bind(crypto);
177
+ var native$1 = {
178
+ randomUUID: randomUUID$1
179
179
  };
180
180
 
181
- function v4(options, buf, offset) {
182
- if (native.randomUUID && !buf && !options) {
183
- return native.randomUUID();
181
+ function v4$1(options, buf, offset) {
182
+ if (native$1.randomUUID && !buf && !options) {
183
+ return native$1.randomUUID();
184
184
  }
185
185
 
186
186
  options = options || {};
187
- const rnds = options.random || (options.rng || rng)(); // Per 4.4, set bits for version and `clock_seq_hi_and_reserved`
187
+ const rnds = options.random || (options.rng || rng$1)(); // Per 4.4, set bits for version and `clock_seq_hi_and_reserved`
188
188
 
189
189
  rnds[6] = rnds[6] & 0x0f | 0x40;
190
190
  rnds[8] = rnds[8] & 0x3f | 0x80; // Copy bytes to buffer, if provided
@@ -199,7 +199,7 @@ function v4(options, buf, offset) {
199
199
  return buf;
200
200
  }
201
201
 
202
- return unsafeStringify(rnds);
202
+ return unsafeStringify$1(rnds);
203
203
  }
204
204
 
205
205
  function addItem(arr, value) {
@@ -2186,7 +2186,7 @@ var __read$2 = (undefined && undefined.__read) || function (o, n) {
2186
2186
  }
2187
2187
  return ar;
2188
2188
  };
2189
- var __spreadArray$1 = (undefined && undefined.__spreadArray) || function (to, from, pack) {
2189
+ var __spreadArray$2 = (undefined && undefined.__spreadArray) || function (to, from, pack) {
2190
2190
  if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {
2191
2191
  if (ar || !(i in from)) {
2192
2192
  if (!ar) ar = Array.prototype.slice.call(from, 0, i);
@@ -2503,7 +2503,7 @@ var Matrix4 = /** @class */ (function () {
2503
2503
  * @returns 复制结果
2504
2504
  */
2505
2505
  Matrix4.prototype.copyFrom = function (m) {
2506
- this.elements = __spreadArray$1([], __read$2(m.elements), false);
2506
+ this.elements = __spreadArray$2([], __read$2(m.elements), false);
2507
2507
  return this;
2508
2508
  };
2509
2509
  /**
@@ -3032,7 +3032,7 @@ var Matrix4 = /** @class */ (function () {
3032
3032
  * @returns
3033
3033
  */
3034
3034
  Matrix4.prototype.toArray = function () {
3035
- return __spreadArray$1([], __read$2(this.elements), false);
3035
+ return __spreadArray$2([], __read$2(this.elements), false);
3036
3036
  };
3037
3037
  Matrix4.prototype.fill = function (array, offset) {
3038
3038
  if (offset === void 0) { offset = 0; }
@@ -4285,7 +4285,7 @@ var __read$1 = (undefined && undefined.__read) || function (o, n) {
4285
4285
  }
4286
4286
  return ar;
4287
4287
  };
4288
- var __spreadArray = (undefined && undefined.__spreadArray) || function (to, from, pack) {
4288
+ var __spreadArray$1 = (undefined && undefined.__spreadArray) || function (to, from, pack) {
4289
4289
  if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {
4290
4290
  if (ar || !(i in from)) {
4291
4291
  if (!ar) ar = Array.prototype.slice.call(from, 0, i);
@@ -4472,7 +4472,7 @@ var Matrix3 = /** @class */ (function () {
4472
4472
  * @returns 复制结果
4473
4473
  */
4474
4474
  Matrix3.prototype.copyFrom = function (m) {
4475
- this.elements = __spreadArray([], __read$1(m.elements), false);
4475
+ this.elements = __spreadArray$1([], __read$1(m.elements), false);
4476
4476
  return this;
4477
4477
  };
4478
4478
  /**
@@ -4688,7 +4688,7 @@ var Matrix3 = /** @class */ (function () {
4688
4688
  * @returns
4689
4689
  */
4690
4690
  Matrix3.prototype.toArray = function () {
4691
- return __spreadArray([], __read$1(this.elements), false);
4691
+ return __spreadArray$1([], __read$1(this.elements), false);
4692
4692
  };
4693
4693
  Matrix3.prototype.fill = function (array, offset) {
4694
4694
  if (offset === void 0) { offset = 0; }
@@ -6446,7 +6446,7 @@ function error(message) {
6446
6446
  for (var _i = 1; _i < arguments.length; _i++) {
6447
6447
  args[_i - 1] = arguments[_i];
6448
6448
  }
6449
- console.error.apply(console, __spreadArray$2(__spreadArray$2([], __read$3(format(message)), false), [args], false));
6449
+ console.error.apply(console, __spreadArray$3(__spreadArray$3([], __read$3(format(message)), false), [args], false));
6450
6450
  localLogger === null || localLogger === void 0 ? void 0 : localLogger('error', message, args);
6451
6451
  }
6452
6452
  /**
@@ -6459,7 +6459,7 @@ function info(message) {
6459
6459
  for (var _i = 1; _i < arguments.length; _i++) {
6460
6460
  args[_i - 1] = arguments[_i];
6461
6461
  }
6462
- console.debug.apply(console, __spreadArray$2([], __read$3(format(message)), false));
6462
+ console.debug.apply(console, __spreadArray$3([], __read$3(format(message)), false));
6463
6463
  localLogger === null || localLogger === void 0 ? void 0 : localLogger('info', message, args);
6464
6464
  }
6465
6465
  function warn(message) {
@@ -6467,7 +6467,7 @@ function warn(message) {
6467
6467
  for (var _i = 1; _i < arguments.length; _i++) {
6468
6468
  args[_i - 1] = arguments[_i];
6469
6469
  }
6470
- console.warn.apply(console, __spreadArray$2([], __read$3(format(message)), false));
6470
+ console.warn.apply(console, __spreadArray$3([], __read$3(format(message)), false));
6471
6471
  localLogger === null || localLogger === void 0 ? void 0 : localLogger('warn', message, args);
6472
6472
  }
6473
6473
  /**
@@ -6564,17 +6564,30 @@ function random(min, max) {
6564
6564
  function throwDestroyedError() {
6565
6565
  throw Error('destroyed item cannot be used again');
6566
6566
  }
6567
- function generateGUID() {
6568
- return v4().replace(/-/g, '');
6567
+ function generateGUID$1() {
6568
+ return v4$1().replace(/-/g, '');
6569
6569
  }
6570
6570
 
6571
6571
  /*!
6572
6572
  * Name: @galacean/effects-specification
6573
6573
  * Description: Galacean Effects JSON Specification
6574
6574
  * Author: Ant Group CO., Ltd.
6575
- * Version: v1.0.1
6575
+ * Version: v2.0.0-alpha.2
6576
+ */
6577
+
6578
+ typeof crypto !== 'undefined' && crypto.randomUUID && crypto.randomUUID.bind(crypto);
6579
+
6580
+ /**
6581
+ * Convert array of 16 byte values to UUID string format of the form:
6582
+ * XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX
6576
6583
  */
6577
6584
 
6585
+ const byteToHex$1 = [];
6586
+
6587
+ for (let i = 0; i < 256; ++i) {
6588
+ byteToHex$1.push((i + 0x100).toString(16).slice(1));
6589
+ }
6590
+
6578
6591
  /*********************************************/
6579
6592
  /* 元素属性参数类型 */
6580
6593
  /*********************************************/
@@ -6837,6 +6850,10 @@ var ItemType$1;
6837
6850
  * 天空盒元素
6838
6851
  */
6839
6852
  ItemType["skybox"] = "skybox";
6853
+ /**
6854
+ * 特效元素
6855
+ */
6856
+ ItemType["effect"] = "effect";
6840
6857
  })(ItemType$1 || (ItemType$1 = {}));
6841
6858
  /**
6842
6859
  * 渲染模式
@@ -6951,6 +6968,10 @@ var CompositionEndBehavior$1;
6951
6968
  * 销毁并保留最后一帧
6952
6969
  */
6953
6970
  CompositionEndBehavior[CompositionEndBehavior["pause_destroy"] = END_BEHAVIOR_PAUSE_AND_DESTROY$1] = "pause_destroy";
6971
+ /**
6972
+ * 冻结
6973
+ */
6974
+ CompositionEndBehavior[CompositionEndBehavior["freeze"] = END_BEHAVIOR_FREEZE$1] = "freeze";
6954
6975
  })(CompositionEndBehavior$1 || (CompositionEndBehavior$1 = {}));
6955
6976
 
6956
6977
  /*********************************************/
@@ -7089,12 +7110,38 @@ var ShapeArcMode$1;
7089
7110
 
7090
7111
  var BloomFilterThresholdAvgColor = 0;
7091
7112
 
7113
+ var LightType$1;
7114
+ (function (LightType) {
7115
+ /**
7116
+ * 点光源
7117
+ */
7118
+ LightType["point"] = "point";
7119
+ /**
7120
+ * 聚光灯
7121
+ */
7122
+ LightType["spot"] = "spot";
7123
+ /**
7124
+ * 方向光
7125
+ */
7126
+ LightType["directional"] = "directional";
7127
+ /**
7128
+ * 环境光
7129
+ */
7130
+ LightType["ambient"] = "ambient";
7131
+ })(LightType$1 || (LightType$1 = {}));
7132
+
7092
7133
  var ModelBoundingType$1;
7093
7134
  (function (ModelBoundingType) {
7094
7135
  ModelBoundingType[ModelBoundingType["box"] = 2] = "box";
7095
7136
  ModelBoundingType[ModelBoundingType["sphere"] = 3] = "sphere";
7096
7137
  })(ModelBoundingType$1 || (ModelBoundingType$1 = {}));
7097
7138
 
7139
+ var CameraType$1;
7140
+ (function (CameraType) {
7141
+ CameraType["orthographic"] = "orthographic";
7142
+ CameraType["perspective"] = "perspective";
7143
+ })(CameraType$1 || (CameraType$1 = {}));
7144
+
7098
7145
  // 材质类型
7099
7146
  var MaterialType$1;
7100
7147
  (function (MaterialType) {
@@ -7240,6 +7287,28 @@ var FontStyle$1;
7240
7287
  FontStyle["oblique"] = "oblique";
7241
7288
  })(FontStyle$1 || (FontStyle$1 = {}));
7242
7289
 
7290
+ var DataType$2;
7291
+ (function (DataType) {
7292
+ DataType["VFXItemData"] = "VFXItemData";
7293
+ DataType["EffectComponent"] = "EffectComponent";
7294
+ DataType["Material"] = "Material";
7295
+ DataType["Shader"] = "Shader";
7296
+ DataType["SpriteComponent"] = "SpriteComponent";
7297
+ DataType["ParticleSystem"] = "ParticleSystem";
7298
+ DataType["InteractComponent"] = "InteractComponent";
7299
+ DataType["CameraController"] = "CameraController";
7300
+ DataType["Geometry"] = "Geometry";
7301
+ DataType["Texture"] = "Texture";
7302
+ DataType["TextComponent"] = "TextComponent";
7303
+ // FIXME: 先完成ECS的场景转换,后面移到spec中
7304
+ DataType["MeshComponent"] = "MeshComponent";
7305
+ DataType["SkyboxComponent"] = "SkyboxComponent";
7306
+ DataType["LightComponent"] = "LightComponent";
7307
+ DataType["CameraComponent"] = "CameraComponent";
7308
+ DataType["ModelPluginComponent"] = "ModelPluginComponent";
7309
+ DataType["TreeComponent"] = "TreeComponent";
7310
+ })(DataType$2 || (DataType$2 = {}));
7311
+
7243
7312
  var index = /*#__PURE__*/Object.freeze({
7244
7313
  __proto__: null,
7245
7314
  get BezierKeyframeType () { return BezierKeyframeType$1; },
@@ -7248,7 +7317,9 @@ var index = /*#__PURE__*/Object.freeze({
7248
7317
  CAMERA_CLIP_MODE_NORMAL: CAMERA_CLIP_MODE_NORMAL$1,
7249
7318
  CAMERA_CLIP_MODE_VERTICAL: CAMERA_CLIP_MODE_VERTICAL$1,
7250
7319
  get CameraClipMode () { return CameraClipMode$1; },
7320
+ get CameraType () { return CameraType$1; },
7251
7321
  get CompositionEndBehavior () { return CompositionEndBehavior$1; },
7322
+ get DataType () { return DataType$2; },
7252
7323
  END_BEHAVIOR_DESTROY: END_BEHAVIOR_DESTROY$1,
7253
7324
  END_BEHAVIOR_DESTROY_CHILDREN: END_BEHAVIOR_DESTROY_CHILDREN$1,
7254
7325
  END_BEHAVIOR_FORWARD: END_BEHAVIOR_FORWARD$1,
@@ -7261,6 +7332,7 @@ var index = /*#__PURE__*/Object.freeze({
7261
7332
  get InteractType () { return InteractType$1; },
7262
7333
  get ItemEndBehavior () { return ItemEndBehavior$1; },
7263
7334
  get ItemType () { return ItemType$1; },
7335
+ get LightType () { return LightType$1; },
7264
7336
  MESSAGE_ITEM_PHRASE_BEGIN: MESSAGE_ITEM_PHRASE_BEGIN,
7265
7337
  MESSAGE_ITEM_PHRASE_END: MESSAGE_ITEM_PHRASE_END,
7266
7338
  get MaskMode () { return MaskMode$1; },
@@ -7338,390 +7410,121 @@ function generateSerializableMember(type, sourceName) {
7338
7410
  };
7339
7411
  }
7340
7412
 
7413
+ var ShaderType;
7414
+ (function (ShaderType) {
7415
+ ShaderType[ShaderType["vertex"] = 0] = "vertex";
7416
+ ShaderType[ShaderType["fragment"] = 1] = "fragment";
7417
+ })(ShaderType || (ShaderType = {}));
7418
+
7341
7419
  /**
7342
- * @since 2.0.0
7343
- * @internal
7420
+ * Helper class to create a WebGL Context
7421
+ *
7422
+ * @param canvas
7423
+ * @param glType
7424
+ * @param options
7425
+ * @returns
7344
7426
  */
7345
- var EffectsObject = /** @class */ (function () {
7346
- function EffectsObject(engine) {
7347
- this.engine = engine;
7348
- this.guid = generateGUID();
7349
- this.taggedProperties = {};
7350
- this.engine.addInstance(this);
7427
+ function createGLContext(canvas, glType, options) {
7428
+ if (glType === void 0) { glType = 'webgl'; }
7429
+ var context;
7430
+ if (glType === 'webgl2') {
7431
+ context = canvas.getContext('webgl2', options);
7432
+ if (!context) {
7433
+ console.debug('WebGL2 context retrieval failed, falling back to WebGL context.');
7434
+ }
7351
7435
  }
7352
- EffectsObject.prototype.getInstanceId = function () {
7353
- return this.guid;
7354
- };
7355
- EffectsObject.prototype.setInstanceId = function (guid) {
7356
- this.engine.removeInstance(this.guid);
7357
- this.guid = guid;
7358
- this.engine.addInstance(this);
7359
- };
7360
- EffectsObject.prototype.toData = function () { };
7361
- /**
7362
- * 反序列化函数
7363
- *
7364
- * @param data - 对象的序列化的数据
7365
- */
7366
- EffectsObject.prototype.fromData = function (data) {
7367
- if (data.id) {
7368
- this.setInstanceId(data.id);
7436
+ if (!context || glType === 'webgl') {
7437
+ context = canvas.getContext('webgl', options);
7438
+ }
7439
+ if (!context) {
7440
+ throw new Error('This browser does not support WebGL or the WebGL version is incorrect. Please check your WebGL version.');
7441
+ }
7442
+ return context;
7443
+ }
7444
+
7445
+ function gpuTimer(gl) {
7446
+ var _this = this;
7447
+ var ext = gl.getExtension('EXT_disjoint_timer_query_webgl2');
7448
+ if (ext) {
7449
+ var query_1 = gl.createQuery();
7450
+ var getTime_1 = function () { return __awaiter(_this, void 0, void 0, function () {
7451
+ return __generator(this, function (_a) {
7452
+ return [2 /*return*/, new Promise(function (resolve, reject) {
7453
+ if (query_1) {
7454
+ var available = gl.getQueryParameter(query_1, gl.QUERY_RESULT_AVAILABLE);
7455
+ var disjoint = gl.getParameter(ext.GPU_DISJOINT_EXT);
7456
+ if (available && !disjoint) {
7457
+ // See how much time the rendering of the object took in nanoseconds.
7458
+ var timeElapsed = gl.getQueryParameter(query_1, gl.QUERY_RESULT); // Do something useful with the time. Note that care should be
7459
+ // taken to use all significant bits of the result, not just the
7460
+ // least significant 32 bits.
7461
+ resolve(timeElapsed / 1000 / 1000);
7462
+ }
7463
+ if (available || disjoint) {
7464
+ // Clean up the query object.
7465
+ gl.deleteQuery(query_1); // Don't re-enter this polling loop.
7466
+ query_1 = null;
7467
+ }
7468
+ available !== null && query_1 && window.setTimeout(function () {
7469
+ getTime_1().then(resolve).catch;
7470
+ }, 1);
7471
+ }
7472
+ })];
7473
+ });
7474
+ }); };
7475
+ if (!query_1) {
7476
+ return;
7369
7477
  }
7370
- };
7371
- EffectsObject.prototype.dispose = function () { };
7372
- __decorate([
7373
- serialize()
7374
- ], EffectsObject.prototype, "guid", void 0);
7375
- return EffectsObject;
7376
- }());
7478
+ return {
7479
+ begin: function () {
7480
+ query_1 && gl.beginQuery(ext.TIME_ELAPSED_EXT, query_1);
7481
+ },
7482
+ end: function () {
7483
+ gl.endQuery(ext.TIME_ELAPSED_EXT);
7484
+ },
7485
+ getTime: getTime_1,
7486
+ };
7487
+ }
7488
+ }
7377
7489
 
7378
- /**
7379
- * @since 2.0.0
7380
- * @internal
7381
- */
7382
- var Component = /** @class */ (function (_super) {
7383
- __extends(Component, _super);
7384
- function Component() {
7385
- return _super !== null && _super.apply(this, arguments) || this;
7490
+ var initErrors = [];
7491
+ // @ts-expect-error
7492
+ var glContext = {};
7493
+ if (!initErrors.length) {
7494
+ initGLContext();
7495
+ }
7496
+ function initGLContext() {
7497
+ // 重要:iOS 9/10 低版本需要拷贝 gl context prototype,要不然会有属性值的缺失
7498
+ if (typeof WebGL2RenderingContext === 'function') {
7499
+ copy$1(WebGL2RenderingContext);
7386
7500
  }
7387
- Object.defineProperty(Component.prototype, "transform", {
7388
- /**
7389
- * 附加到的 VFXItem 对象 Transform 组件
7390
- */
7391
- get: function () {
7392
- return this.item.transform;
7393
- },
7394
- enumerable: false,
7395
- configurable: true
7396
- });
7397
- Component.prototype.onAttached = function () { };
7398
- Component.prototype.onDestroy = function () { };
7399
- Component.prototype.fromData = function (data) {
7400
- _super.prototype.fromData.call(this, data);
7401
- if (data.item) {
7402
- this.item = data.item;
7403
- }
7404
- };
7405
- Component.prototype.dispose = function () {
7406
- this.onDestroy();
7407
- if (this.item) {
7408
- removeItem(this.item.components, this);
7501
+ else if (typeof WebGLRenderingContext !== 'undefined') {
7502
+ copy$1(WebGLRenderingContext);
7503
+ copy$1(WebGLRenderingContext.prototype);
7504
+ }
7505
+ else {
7506
+ initErrors.push(
7507
+ // iOS 16 lockdown mode
7508
+ 'iOS16 lockdown mode, WebGL Constants not in global');
7509
+ }
7510
+ if (!initErrors.length && !('HALF_FLOAT' in glContext)) {
7511
+ // @ts-expect-error set default value
7512
+ glContext['HALF_FLOAT'] = 5131;
7513
+ }
7514
+ }
7515
+ function isWebGL2(gl) {
7516
+ return typeof WebGL2RenderingContext !== 'undefined' && gl.constructor.name === 'WebGL2RenderingContext';
7517
+ }
7518
+ function copy$1(target) {
7519
+ for (var name_1 in target) {
7520
+ if (/^[A-Z_]/.test(name_1)) {
7521
+ // @ts-expect-error safe to assign
7522
+ glContext[name_1] = target[name_1];
7409
7523
  }
7410
- };
7411
- return Component;
7412
- }(EffectsObject));
7413
- /**
7414
- * @since 2.0.0
7415
- * @internal
7416
- */
7417
- var Behaviour = /** @class */ (function (_super) {
7418
- __extends(Behaviour, _super);
7419
- function Behaviour() {
7420
- var _this = _super !== null && _super.apply(this, arguments) || this;
7421
- _this._enabled = true;
7422
- return _this;
7423
- }
7424
- Object.defineProperty(Behaviour.prototype, "isActiveAndEnabled", {
7425
- /**
7426
- * 组件是否可以更新,true 更新,false 不更新
7427
- */
7428
- get: function () {
7429
- return this.item.getVisible() && this.enabled;
7430
- },
7431
- enumerable: false,
7432
- configurable: true
7433
- });
7434
- Object.defineProperty(Behaviour.prototype, "enabled", {
7435
- get: function () {
7436
- return this._enabled;
7437
- },
7438
- set: function (value) {
7439
- this._enabled = value;
7440
- if (value) {
7441
- this.onBehaviourEnable();
7442
- }
7443
- },
7444
- enumerable: false,
7445
- configurable: true
7446
- });
7447
- Behaviour.prototype.onBehaviourEnable = function () { };
7448
- Behaviour.prototype.fromData = function (data) {
7449
- _super.prototype.fromData.call(this, data);
7450
- };
7451
- Behaviour.prototype.toData = function () {
7452
- _super.prototype.toData.call(this);
7453
- };
7454
- __decorate([
7455
- serialize()
7456
- ], Behaviour.prototype, "_enabled", void 0);
7457
- return Behaviour;
7458
- }(Component));
7459
- /**
7460
- * @since 2.0.0
7461
- * @internal
7462
- */
7463
- var ItemBehaviour = /** @class */ (function (_super) {
7464
- __extends(ItemBehaviour, _super);
7465
- function ItemBehaviour() {
7466
- var _this = _super !== null && _super.apply(this, arguments) || this;
7467
- _this.started = false;
7468
- return _this;
7469
- }
7470
- // /**
7471
- // * 生命周期函数,初始化后调用,生命周期内只调用一次
7472
- // */
7473
- // awake () {
7474
- // // OVERRIDE
7475
- // }
7476
- /**
7477
- * 在每次设置 enabled 为 true 时触发
7478
- */
7479
- ItemBehaviour.prototype.onEnable = function () { };
7480
- /**
7481
- * 生命周期函数,在第一次 update 前调用,生命周期内只调用一次
7482
- */
7483
- ItemBehaviour.prototype.start = function () {
7484
- // OVERRIDE
7485
- };
7486
- /**
7487
- * 生命周期函数,每帧调用一次
7488
- */
7489
- ItemBehaviour.prototype.update = function (dt) {
7490
- // OVERRIDE
7491
- };
7492
- /**
7493
- * 生命周期函数,每帧调用一次,在 update 之后调用
7494
- */
7495
- ItemBehaviour.prototype.lateUpdate = function (dt) {
7496
- // OVERRIDE
7497
- };
7498
- ItemBehaviour.prototype.onAttached = function () {
7499
- this.item.itemBehaviours.push(this);
7500
- };
7501
- ItemBehaviour.prototype.dispose = function () {
7502
- if (this.item) {
7503
- removeItem(this.item.itemBehaviours, this);
7504
- }
7505
- _super.prototype.dispose.call(this);
7506
- };
7507
- ItemBehaviour.prototype.onBehaviourEnable = function () {
7508
- this.onEnable();
7509
- if (!this.started) {
7510
- this.start();
7511
- this.started = true;
7512
- }
7513
- };
7514
- return ItemBehaviour;
7515
- }(Behaviour));
7516
-
7517
- /**
7518
- * 所有渲染组件的基类
7519
- * @since 2.0.0
7520
- */
7521
- var RendererComponent = /** @class */ (function (_super) {
7522
- __extends(RendererComponent, _super);
7523
- function RendererComponent() {
7524
- var _this = _super !== null && _super.apply(this, arguments) || this;
7525
- _this.started = false;
7526
- _this.materials = [];
7527
- _this._enabled = true;
7528
- return _this;
7529
- }
7530
- Object.defineProperty(RendererComponent.prototype, "priority", {
7531
- get: function () {
7532
- return this._priority;
7533
- },
7534
- set: function (value) {
7535
- this._priority = value;
7536
- },
7537
- enumerable: false,
7538
- configurable: true
7539
- });
7540
- Object.defineProperty(RendererComponent.prototype, "enabled", {
7541
- get: function () {
7542
- return this._enabled;
7543
- },
7544
- set: function (value) {
7545
- this._enabled = value;
7546
- if (value) {
7547
- this.onEnable();
7548
- }
7549
- },
7550
- enumerable: false,
7551
- configurable: true
7552
- });
7553
- Object.defineProperty(RendererComponent.prototype, "isActiveAndEnabled", {
7554
- /**
7555
- * 组件是否可以更新,true 更新,false 不更新
7556
- */
7557
- get: function () {
7558
- return this.item.getVisible() && this.enabled;
7559
- },
7560
- enumerable: false,
7561
- configurable: true
7562
- });
7563
- Object.defineProperty(RendererComponent.prototype, "material", {
7564
- get: function () {
7565
- return this.materials[0];
7566
- },
7567
- set: function (material) {
7568
- if (this.materials.length === 0) {
7569
- this.materials.push(material);
7570
- }
7571
- else {
7572
- this.materials[0] = material;
7573
- }
7574
- },
7575
- enumerable: false,
7576
- configurable: true
7577
- });
7578
- RendererComponent.prototype.onEnable = function () { };
7579
- RendererComponent.prototype.start = function () { };
7580
- RendererComponent.prototype.update = function (dt) { };
7581
- RendererComponent.prototype.lateUpdate = function (dt) { };
7582
- RendererComponent.prototype.render = function (renderer) { };
7583
- RendererComponent.prototype.onAttached = function () {
7584
- this.item.rendererComponents.push(this);
7585
- };
7586
- RendererComponent.prototype.fromData = function (data) {
7587
- _super.prototype.fromData.call(this, data);
7588
- };
7589
- RendererComponent.prototype.toData = function () {
7590
- _super.prototype.toData.call(this);
7591
- };
7592
- RendererComponent.prototype.dispose = function () {
7593
- if (this.item) {
7594
- removeItem(this.item.rendererComponents, this);
7595
- }
7596
- _super.prototype.dispose.call(this);
7597
- };
7598
- __decorate([
7599
- serialize()
7600
- ], RendererComponent.prototype, "materials", void 0);
7601
- __decorate([
7602
- serialize()
7603
- ], RendererComponent.prototype, "_priority", void 0);
7604
- __decorate([
7605
- serialize()
7606
- ], RendererComponent.prototype, "_enabled", void 0);
7607
- return RendererComponent;
7608
- }(Component));
7609
-
7610
- var ShaderType;
7611
- (function (ShaderType) {
7612
- ShaderType[ShaderType["vertex"] = 0] = "vertex";
7613
- ShaderType[ShaderType["fragment"] = 1] = "fragment";
7614
- })(ShaderType || (ShaderType = {}));
7615
-
7616
- /**
7617
- * Helper class to create a WebGL Context
7618
- *
7619
- * @param canvas
7620
- * @param glType
7621
- * @param options
7622
- * @returns
7623
- */
7624
- function createGLContext(canvas, glType, options) {
7625
- if (glType === void 0) { glType = 'webgl'; }
7626
- var context;
7627
- if (glType === 'webgl2') {
7628
- context = canvas.getContext('webgl2', options);
7629
- if (!context) {
7630
- console.debug('WebGL2 context retrieval failed, falling back to WebGL context.');
7631
- }
7632
- }
7633
- if (!context || glType === 'webgl') {
7634
- context = canvas.getContext('webgl', options);
7635
- }
7636
- if (!context) {
7637
- throw new Error('This browser does not support WebGL or the WebGL version is incorrect. Please check your WebGL version.');
7638
- }
7639
- return context;
7640
- }
7641
-
7642
- function gpuTimer(gl) {
7643
- var _this = this;
7644
- var ext = gl.getExtension('EXT_disjoint_timer_query_webgl2');
7645
- if (ext) {
7646
- var query_1 = gl.createQuery();
7647
- var getTime_1 = function () { return __awaiter(_this, void 0, void 0, function () {
7648
- return __generator(this, function (_a) {
7649
- return [2 /*return*/, new Promise(function (resolve, reject) {
7650
- if (query_1) {
7651
- var available = gl.getQueryParameter(query_1, gl.QUERY_RESULT_AVAILABLE);
7652
- var disjoint = gl.getParameter(ext.GPU_DISJOINT_EXT);
7653
- if (available && !disjoint) {
7654
- // See how much time the rendering of the object took in nanoseconds.
7655
- var timeElapsed = gl.getQueryParameter(query_1, gl.QUERY_RESULT); // Do something useful with the time. Note that care should be
7656
- // taken to use all significant bits of the result, not just the
7657
- // least significant 32 bits.
7658
- resolve(timeElapsed / 1000 / 1000);
7659
- }
7660
- if (available || disjoint) {
7661
- // Clean up the query object.
7662
- gl.deleteQuery(query_1); // Don't re-enter this polling loop.
7663
- query_1 = null;
7664
- }
7665
- available !== null && query_1 && window.setTimeout(function () {
7666
- getTime_1().then(resolve).catch;
7667
- }, 1);
7668
- }
7669
- })];
7670
- });
7671
- }); };
7672
- if (!query_1) {
7673
- return;
7674
- }
7675
- return {
7676
- begin: function () {
7677
- query_1 && gl.beginQuery(ext.TIME_ELAPSED_EXT, query_1);
7678
- },
7679
- end: function () {
7680
- gl.endQuery(ext.TIME_ELAPSED_EXT);
7681
- },
7682
- getTime: getTime_1,
7683
- };
7684
7524
  }
7685
7525
  }
7686
7526
 
7687
- var initErrors = [];
7688
- // @ts-expect-error
7689
- var glContext = {};
7690
- if (!initErrors.length) {
7691
- initGLContext();
7692
- }
7693
- function initGLContext() {
7694
- // 重要:iOS 9/10 低版本需要拷贝 gl context 的 prototype,要不然会有属性值的缺失
7695
- if (typeof WebGL2RenderingContext === 'function') {
7696
- copy$1(WebGL2RenderingContext);
7697
- }
7698
- else if (typeof WebGLRenderingContext !== 'undefined') {
7699
- copy$1(WebGLRenderingContext);
7700
- copy$1(WebGLRenderingContext.prototype);
7701
- }
7702
- else {
7703
- initErrors.push(
7704
- // iOS 16 lockdown mode
7705
- 'iOS16 lockdown mode, WebGL Constants not in global');
7706
- }
7707
- if (!initErrors.length && !('HALF_FLOAT' in glContext)) {
7708
- // @ts-expect-error set default value
7709
- glContext['HALF_FLOAT'] = 5131;
7710
- }
7711
- }
7712
- function isWebGL2(gl) {
7713
- return typeof WebGL2RenderingContext !== 'undefined' && gl.constructor.name === 'WebGL2RenderingContext';
7714
- }
7715
- function copy$1(target) {
7716
- for (var name_1 in target) {
7717
- if (/^[A-Z_]/.test(name_1)) {
7718
- // @ts-expect-error safe to assign
7719
- glContext[name_1] = target[name_1];
7720
- }
7721
- }
7722
- }
7723
-
7724
- var _a$5;
7527
+ var _a$6;
7725
7528
  function valIfUndefined(val, def) {
7726
7529
  if (val === undefined || val === null) {
7727
7530
  return def;
@@ -7751,15 +7554,15 @@ function getPreMultiAlpha(blending) {
7751
7554
  return 1;
7752
7555
  }
7753
7556
  }
7754
- var downgradeKeywords = (_a$5 = {},
7755
- _a$5[ShaderType.vertex] = {
7557
+ var downgradeKeywords = (_a$6 = {},
7558
+ _a$6[ShaderType.vertex] = {
7756
7559
  in: 'attribute',
7757
7560
  out: 'varying',
7758
7561
  },
7759
- _a$5[ShaderType.fragment] = {
7562
+ _a$6[ShaderType.fragment] = {
7760
7563
  in: 'varying',
7761
7564
  },
7762
- _a$5);
7565
+ _a$6);
7763
7566
  /**
7764
7567
  * 生成 shader,检测到 WebGL1 上下文会降级
7765
7568
  * @param marcos - 宏定义数组
@@ -8193,6 +7996,43 @@ function loadMipmapImage(pointer, bins) {
8193
7996
  });
8194
7997
  }
8195
7998
 
7999
+ /**
8000
+ * @since 2.0.0
8001
+ * @internal
8002
+ */
8003
+ var EffectsObject = /** @class */ (function () {
8004
+ function EffectsObject(engine) {
8005
+ this.engine = engine;
8006
+ this.guid = generateGUID$1();
8007
+ this.taggedProperties = {};
8008
+ this.engine.addInstance(this);
8009
+ }
8010
+ EffectsObject.prototype.getInstanceId = function () {
8011
+ return this.guid;
8012
+ };
8013
+ EffectsObject.prototype.setInstanceId = function (guid) {
8014
+ this.engine.removeInstance(this.guid);
8015
+ this.guid = guid;
8016
+ this.engine.addInstance(this);
8017
+ };
8018
+ EffectsObject.prototype.toData = function () { };
8019
+ /**
8020
+ * 反序列化函数
8021
+ *
8022
+ * @param data - 对象的序列化的数据
8023
+ */
8024
+ EffectsObject.prototype.fromData = function (data) {
8025
+ if (data.id) {
8026
+ this.setInstanceId(data.id);
8027
+ }
8028
+ };
8029
+ EffectsObject.prototype.dispose = function () { };
8030
+ __decorate([
8031
+ serialize()
8032
+ ], EffectsObject.prototype, "guid", void 0);
8033
+ return EffectsObject;
8034
+ }());
8035
+
8196
8036
  var seed$9 = 1;
8197
8037
  /**
8198
8038
  * Texture 抽象类
@@ -8860,13 +8700,49 @@ var GLSLVersion;
8860
8700
  GLSLVersion["GLSL1"] = "100";
8861
8701
  GLSLVersion["GLSL3"] = "300 es";
8862
8702
  })(GLSLVersion || (GLSLVersion = {}));
8863
- var Shader = /** @class */ (function (_super) {
8864
- __extends(Shader, _super);
8865
- function Shader(engine, source) {
8703
+ var ShaderVariant = /** @class */ (function (_super) {
8704
+ __extends(ShaderVariant, _super);
8705
+ function ShaderVariant(engine, source) {
8866
8706
  var _this = _super.call(this, engine) || this;
8867
8707
  _this.source = source;
8868
8708
  return _this;
8869
8709
  }
8710
+ return ShaderVariant;
8711
+ }(EffectsObject));
8712
+ var Shader = /** @class */ (function (_super) {
8713
+ __extends(Shader, _super);
8714
+ function Shader() {
8715
+ return _super !== null && _super.apply(this, arguments) || this;
8716
+ }
8717
+ Shader.prototype.createVariant = function (macros) {
8718
+ var e_1, _a;
8719
+ var shaderMacros = [];
8720
+ if (macros) {
8721
+ try {
8722
+ for (var _b = __values$1(Object.keys(macros)), _c = _b.next(); !_c.done; _c = _b.next()) {
8723
+ var key = _c.value;
8724
+ shaderMacros.push([key, macros[key]]);
8725
+ }
8726
+ }
8727
+ catch (e_1_1) { e_1 = { error: e_1_1 }; }
8728
+ finally {
8729
+ try {
8730
+ if (_c && !_c.done && (_a = _b.return)) _a.call(_b);
8731
+ }
8732
+ finally { if (e_1) throw e_1.error; }
8733
+ }
8734
+ }
8735
+ var shaderVariant = this.engine.getShaderLibrary().createShader(this.shaderData, shaderMacros);
8736
+ shaderVariant.shader = this;
8737
+ return shaderVariant;
8738
+ };
8739
+ Shader.prototype.fromData = function (data) {
8740
+ _super.prototype.fromData.call(this, data);
8741
+ this.shaderData = data;
8742
+ };
8743
+ Shader = __decorate([
8744
+ effectsClass('Shader')
8745
+ ], Shader);
8870
8746
  return Shader;
8871
8747
  }(EffectsObject));
8872
8748
 
@@ -8879,8 +8755,8 @@ function createCopyShader(level, writeDepth) {
8879
8755
  var version = webgl2 ? '#version 300 es' : '';
8880
8756
  return {
8881
8757
  name: EFFECTS_COPY_MESH_NAME,
8882
- vertex: createShaderWithMarcos([], version + '\n' + COPY_VERTEX_SHADER, ShaderType.vertex, level),
8883
- fragment: createShaderWithMarcos([], version + '\n' + COPY_FRAGMENT_SHADER, ShaderType.fragment, level),
8758
+ vertex: version + '\n' + COPY_VERTEX_SHADER,
8759
+ fragment: version + '\n' + COPY_FRAGMENT_SHADER,
8884
8760
  glslVersion: webgl2 ? GLSLVersion.GLSL3 : GLSLVersion.GLSL1,
8885
8761
  marcos: [
8886
8762
  ['WEBGL2', !!webgl2],
@@ -9012,13 +8888,13 @@ var SemanticMap = /** @class */ (function () {
9012
8888
  return SemanticMap;
9013
8889
  }());
9014
8890
 
9015
- var _a$4;
9016
- var BYTES_TYPE_MAP = (_a$4 = {},
9017
- _a$4[glContext.FLOAT] = Float32Array.BYTES_PER_ELEMENT,
9018
- _a$4[glContext.INT] = Int32Array.BYTES_PER_ELEMENT,
9019
- _a$4[glContext.SHORT] = Int16Array.BYTES_PER_ELEMENT,
9020
- _a$4[glContext.BYTE] = Int8Array.BYTES_PER_ELEMENT,
9021
- _a$4);
8891
+ var _a$5;
8892
+ var BYTES_TYPE_MAP = (_a$5 = {},
8893
+ _a$5[glContext.FLOAT] = Float32Array.BYTES_PER_ELEMENT,
8894
+ _a$5[glContext.INT] = Int32Array.BYTES_PER_ELEMENT,
8895
+ _a$5[glContext.SHORT] = Int16Array.BYTES_PER_ELEMENT,
8896
+ _a$5[glContext.BYTE] = Int8Array.BYTES_PER_ELEMENT,
8897
+ _a$5);
9022
8898
  /**
9023
8899
  * Geometry 抽象类
9024
8900
  */
@@ -9028,29 +8904,261 @@ var Geometry = /** @class */ (function (_super) {
9028
8904
  return _super !== null && _super.apply(this, arguments) || this;
9029
8905
  }
9030
8906
  /**
9031
- * 初始化 GPU 资源
9032
- * @override
8907
+ * 初始化 GPU 资源
8908
+ * @override
8909
+ */
8910
+ Geometry.prototype.initialize = function () {
8911
+ // OVERRIDE
8912
+ };
8913
+ /**
8914
+ * 几何数据刷新
8915
+ */
8916
+ Geometry.prototype.flush = function () {
8917
+ // OVERRIDE
8918
+ };
8919
+ return Geometry;
8920
+ }(EffectsObject));
8921
+ function generateEmptyTypedArray(type) {
8922
+ if (type === glContext.INT) {
8923
+ return new Int32Array(0);
8924
+ }
8925
+ if (type === glContext.SHORT) {
8926
+ return new Int16Array(0);
8927
+ }
8928
+ return new Float32Array(0);
8929
+ }
8930
+
8931
+ /**
8932
+ * @since 2.0.0
8933
+ * @internal
8934
+ */
8935
+ var Component = /** @class */ (function (_super) {
8936
+ __extends(Component, _super);
8937
+ function Component() {
8938
+ return _super !== null && _super.apply(this, arguments) || this;
8939
+ }
8940
+ Object.defineProperty(Component.prototype, "transform", {
8941
+ /**
8942
+ * 附加到的 VFXItem 对象 Transform 组件
8943
+ */
8944
+ get: function () {
8945
+ return this.item.transform;
8946
+ },
8947
+ enumerable: false,
8948
+ configurable: true
8949
+ });
8950
+ Component.prototype.onAttached = function () { };
8951
+ Component.prototype.onDestroy = function () { };
8952
+ Component.prototype.fromData = function (data) {
8953
+ _super.prototype.fromData.call(this, data);
8954
+ if (data.item) {
8955
+ this.item = data.item;
8956
+ }
8957
+ };
8958
+ Component.prototype.dispose = function () {
8959
+ this.onDestroy();
8960
+ if (this.item) {
8961
+ removeItem(this.item.components, this);
8962
+ }
8963
+ };
8964
+ return Component;
8965
+ }(EffectsObject));
8966
+ /**
8967
+ * @since 2.0.0
8968
+ * @internal
8969
+ */
8970
+ var Behaviour = /** @class */ (function (_super) {
8971
+ __extends(Behaviour, _super);
8972
+ function Behaviour() {
8973
+ var _this = _super !== null && _super.apply(this, arguments) || this;
8974
+ _this._enabled = true;
8975
+ return _this;
8976
+ }
8977
+ Object.defineProperty(Behaviour.prototype, "isActiveAndEnabled", {
8978
+ /**
8979
+ * 组件是否可以更新,true 更新,false 不更新
8980
+ */
8981
+ get: function () {
8982
+ return this.item.getVisible() && this.enabled;
8983
+ },
8984
+ enumerable: false,
8985
+ configurable: true
8986
+ });
8987
+ Object.defineProperty(Behaviour.prototype, "enabled", {
8988
+ get: function () {
8989
+ return this._enabled;
8990
+ },
8991
+ set: function (value) {
8992
+ this._enabled = value;
8993
+ if (value) {
8994
+ this.onBehaviourEnable();
8995
+ }
8996
+ },
8997
+ enumerable: false,
8998
+ configurable: true
8999
+ });
9000
+ Behaviour.prototype.onBehaviourEnable = function () { };
9001
+ Behaviour.prototype.fromData = function (data) {
9002
+ _super.prototype.fromData.call(this, data);
9003
+ };
9004
+ Behaviour.prototype.toData = function () {
9005
+ _super.prototype.toData.call(this);
9006
+ };
9007
+ __decorate([
9008
+ serialize()
9009
+ ], Behaviour.prototype, "_enabled", void 0);
9010
+ return Behaviour;
9011
+ }(Component));
9012
+ /**
9013
+ * @since 2.0.0
9014
+ * @internal
9015
+ */
9016
+ var ItemBehaviour = /** @class */ (function (_super) {
9017
+ __extends(ItemBehaviour, _super);
9018
+ function ItemBehaviour() {
9019
+ var _this = _super !== null && _super.apply(this, arguments) || this;
9020
+ _this.started = false;
9021
+ return _this;
9022
+ }
9023
+ // /**
9024
+ // * 生命周期函数,初始化后调用,生命周期内只调用一次
9025
+ // */
9026
+ // awake () {
9027
+ // // OVERRIDE
9028
+ // }
9029
+ /**
9030
+ * 在每次设置 enabled 为 true 时触发
9031
+ */
9032
+ ItemBehaviour.prototype.onEnable = function () { };
9033
+ /**
9034
+ * 生命周期函数,在第一次 update 前调用,生命周期内只调用一次
9035
+ */
9036
+ ItemBehaviour.prototype.start = function () {
9037
+ // OVERRIDE
9038
+ };
9039
+ /**
9040
+ * 生命周期函数,每帧调用一次
9033
9041
  */
9034
- Geometry.prototype.initialize = function () {
9042
+ ItemBehaviour.prototype.update = function (dt) {
9035
9043
  // OVERRIDE
9036
9044
  };
9037
9045
  /**
9038
- * 几何数据刷新
9046
+ * 生命周期函数,每帧调用一次,在 update 之后调用
9039
9047
  */
9040
- Geometry.prototype.flush = function () {
9048
+ ItemBehaviour.prototype.lateUpdate = function (dt) {
9041
9049
  // OVERRIDE
9042
9050
  };
9043
- return Geometry;
9044
- }(EffectsObject));
9045
- function generateEmptyTypedArray(type) {
9046
- if (type === glContext.INT) {
9047
- return new Int32Array(0);
9048
- }
9049
- if (type === glContext.SHORT) {
9050
- return new Int16Array(0);
9051
+ ItemBehaviour.prototype.onAttached = function () {
9052
+ this.item.itemBehaviours.push(this);
9053
+ };
9054
+ ItemBehaviour.prototype.dispose = function () {
9055
+ if (this.item) {
9056
+ removeItem(this.item.itemBehaviours, this);
9057
+ }
9058
+ _super.prototype.dispose.call(this);
9059
+ };
9060
+ ItemBehaviour.prototype.onBehaviourEnable = function () {
9061
+ this.onEnable();
9062
+ if (!this.started) {
9063
+ this.start();
9064
+ this.started = true;
9065
+ }
9066
+ };
9067
+ return ItemBehaviour;
9068
+ }(Behaviour));
9069
+
9070
+ /**
9071
+ * 所有渲染组件的基类
9072
+ * @since 2.0.0
9073
+ */
9074
+ var RendererComponent = /** @class */ (function (_super) {
9075
+ __extends(RendererComponent, _super);
9076
+ function RendererComponent() {
9077
+ var _this = _super !== null && _super.apply(this, arguments) || this;
9078
+ _this.started = false;
9079
+ _this.materials = [];
9080
+ _this._enabled = true;
9081
+ return _this;
9051
9082
  }
9052
- return new Float32Array(0);
9053
- }
9083
+ Object.defineProperty(RendererComponent.prototype, "priority", {
9084
+ get: function () {
9085
+ return this._priority;
9086
+ },
9087
+ set: function (value) {
9088
+ this._priority = value;
9089
+ },
9090
+ enumerable: false,
9091
+ configurable: true
9092
+ });
9093
+ Object.defineProperty(RendererComponent.prototype, "enabled", {
9094
+ get: function () {
9095
+ return this._enabled;
9096
+ },
9097
+ set: function (value) {
9098
+ this._enabled = value;
9099
+ if (value) {
9100
+ this.onEnable();
9101
+ }
9102
+ },
9103
+ enumerable: false,
9104
+ configurable: true
9105
+ });
9106
+ Object.defineProperty(RendererComponent.prototype, "isActiveAndEnabled", {
9107
+ /**
9108
+ * 组件是否可以更新,true 更新,false 不更新
9109
+ */
9110
+ get: function () {
9111
+ return this.item.getVisible() && this.enabled;
9112
+ },
9113
+ enumerable: false,
9114
+ configurable: true
9115
+ });
9116
+ Object.defineProperty(RendererComponent.prototype, "material", {
9117
+ get: function () {
9118
+ return this.materials[0];
9119
+ },
9120
+ set: function (material) {
9121
+ if (this.materials.length === 0) {
9122
+ this.materials.push(material);
9123
+ }
9124
+ else {
9125
+ this.materials[0] = material;
9126
+ }
9127
+ },
9128
+ enumerable: false,
9129
+ configurable: true
9130
+ });
9131
+ RendererComponent.prototype.onEnable = function () { };
9132
+ RendererComponent.prototype.start = function () { };
9133
+ RendererComponent.prototype.update = function (dt) { };
9134
+ RendererComponent.prototype.lateUpdate = function (dt) { };
9135
+ RendererComponent.prototype.render = function (renderer) { };
9136
+ RendererComponent.prototype.onAttached = function () {
9137
+ this.item.rendererComponents.push(this);
9138
+ };
9139
+ RendererComponent.prototype.fromData = function (data) {
9140
+ _super.prototype.fromData.call(this, data);
9141
+ };
9142
+ RendererComponent.prototype.toData = function () {
9143
+ _super.prototype.toData.call(this);
9144
+ };
9145
+ RendererComponent.prototype.dispose = function () {
9146
+ if (this.item) {
9147
+ removeItem(this.item.rendererComponents, this);
9148
+ }
9149
+ _super.prototype.dispose.call(this);
9150
+ };
9151
+ __decorate([
9152
+ serialize()
9153
+ ], RendererComponent.prototype, "materials", void 0);
9154
+ __decorate([
9155
+ serialize()
9156
+ ], RendererComponent.prototype, "_priority", void 0);
9157
+ __decorate([
9158
+ serialize()
9159
+ ], RendererComponent.prototype, "_enabled", void 0);
9160
+ return RendererComponent;
9161
+ }(Component));
9054
9162
 
9055
9163
  var seed$7 = 1;
9056
9164
  /**
@@ -9355,7 +9463,7 @@ var RenderPass = /** @class */ (function () {
9355
9463
  RenderPass.prototype.setMeshes = function (meshes) {
9356
9464
  var _a;
9357
9465
  this.meshes.length = 0;
9358
- (_a = this.meshes).splice.apply(_a, __spreadArray$2([0, 0], __read$3(meshes), false));
9466
+ (_a = this.meshes).splice.apply(_a, __spreadArray$3([0, 0], __read$3(meshes), false));
9359
9467
  sortByOrder(this.meshes, this.meshOrder);
9360
9468
  return this.meshes;
9361
9469
  };
@@ -11287,7 +11395,7 @@ var SerializationHelper = /** @class */ (function () {
11287
11395
  };
11288
11396
  SerializationHelper.deserializeProperty = function (property, engine, level) {
11289
11397
  var e_11, _a, e_12, _b;
11290
- if (level > 10) {
11398
+ if (level > 14) {
11291
11399
  console.error('序列化数据的内嵌对象层数大于上限');
11292
11400
  return;
11293
11401
  }
@@ -11348,7 +11456,7 @@ var SerializationHelper = /** @class */ (function () {
11348
11456
  return __generator(this, function (_j) {
11349
11457
  switch (_j.label) {
11350
11458
  case 0:
11351
- if (level > 10) {
11459
+ if (level > 14) {
11352
11460
  console.error('序列化数据的内嵌对象层数大于上限');
11353
11461
  return [2 /*return*/];
11354
11462
  }
@@ -11439,7 +11547,7 @@ var SerializationHelper = /** @class */ (function () {
11439
11547
  };
11440
11548
  SerializationHelper.serializeObjectProperty = function (objectProperty, serializedData, level) {
11441
11549
  var e_15, _a;
11442
- if (level > 10) {
11550
+ if (level > 14) {
11443
11551
  console.error('序列化数据的内嵌对象层数大于上限');
11444
11552
  return;
11445
11553
  }
@@ -11484,7 +11592,7 @@ var SerializationHelper = /** @class */ (function () {
11484
11592
  }
11485
11593
  };
11486
11594
  SerializationHelper.serializeArrayProperty = function (arrayProperty, serializedData, level) {
11487
- if (level > 10) {
11595
+ if (level > 14) {
11488
11596
  console.error('序列化数据的内嵌对象层数大于上限');
11489
11597
  return;
11490
11598
  }
@@ -11540,18 +11648,15 @@ var AssetLoader = /** @class */ (function () {
11540
11648
  return undefined;
11541
11649
  }
11542
11650
  switch (effectsObjectData.dataType) {
11543
- case DataType.Material:
11651
+ case DataType$1.Material:
11544
11652
  effectsObject = Material.create(this.engine);
11545
11653
  break;
11546
- case DataType.Geometry:
11654
+ case DataType$1.Geometry:
11547
11655
  effectsObject = Geometry.create(this.engine);
11548
11656
  break;
11549
- case DataType.Texture:
11657
+ case DataType$1.Texture:
11550
11658
  effectsObject = Texture.create(this.engine, effectsObjectData);
11551
11659
  return effectsObject;
11552
- case DataType.Shader:
11553
- effectsObject = this.engine.getShaderLibrary().createShader(effectsObjectData);
11554
- break;
11555
11660
  default: {
11556
11661
  var classConstructor = AssetLoader.getClass(effectsObjectData.dataType);
11557
11662
  if (classConstructor) {
@@ -11595,18 +11700,15 @@ var AssetLoader = /** @class */ (function () {
11595
11700
  return [2 /*return*/, effectsObject];
11596
11701
  case 2:
11597
11702
  switch (effectsObjectData.dataType) {
11598
- case DataType.Material:
11703
+ case DataType$1.Material:
11599
11704
  effectsObject = Material.create(this.engine);
11600
11705
  break;
11601
- case DataType.Geometry:
11706
+ case DataType$1.Geometry:
11602
11707
  effectsObject = Geometry.create(this.engine);
11603
11708
  break;
11604
- case DataType.Texture:
11709
+ case DataType$1.Texture:
11605
11710
  effectsObject = Texture.create(this.engine, effectsObjectData);
11606
11711
  return [2 /*return*/, effectsObject];
11607
- case DataType.Shader:
11608
- effectsObject = this.engine.getShaderLibrary().createShader(effectsObjectData);
11609
- break;
11610
11712
  default: {
11611
11713
  classConstructor = AssetLoader.getClass(effectsObjectData.dataType);
11612
11714
  if (classConstructor) {
@@ -11648,27 +11750,27 @@ var Database = /** @class */ (function () {
11648
11750
  };
11649
11751
  return Database;
11650
11752
  }());
11651
- var DataType;
11753
+ var DataType$1;
11652
11754
  (function (DataType) {
11653
- DataType[DataType["VFXItemData"] = 0] = "VFXItemData";
11654
- DataType[DataType["EffectComponent"] = 1] = "EffectComponent";
11655
- DataType[DataType["Material"] = 2] = "Material";
11656
- DataType[DataType["Shader"] = 3] = "Shader";
11657
- DataType[DataType["SpriteComponent"] = 4] = "SpriteComponent";
11658
- DataType[DataType["ParticleSystem"] = 5] = "ParticleSystem";
11659
- DataType[DataType["InteractComponent"] = 6] = "InteractComponent";
11660
- DataType[DataType["CameraController"] = 7] = "CameraController";
11661
- DataType[DataType["Geometry"] = 8] = "Geometry";
11662
- DataType[DataType["Texture"] = 9] = "Texture";
11663
- DataType[DataType["TextComponent"] = 10] = "TextComponent";
11755
+ DataType["VFXItemData"] = "VFXItemData";
11756
+ DataType["EffectComponent"] = "EffectComponent";
11757
+ DataType["Material"] = "Material";
11758
+ DataType["Shader"] = "Shader";
11759
+ DataType["SpriteComponent"] = "SpriteComponent";
11760
+ DataType["ParticleSystem"] = "ParticleSystem";
11761
+ DataType["InteractComponent"] = "InteractComponent";
11762
+ DataType["CameraController"] = "CameraController";
11763
+ DataType["Geometry"] = "Geometry";
11764
+ DataType["Texture"] = "Texture";
11765
+ DataType["TextComponent"] = "TextComponent";
11664
11766
  // FIXME: 先完成ECS的场景转换,后面移到spec中
11665
- DataType[DataType["MeshComponent"] = 10000] = "MeshComponent";
11666
- DataType[DataType["SkyboxComponent"] = 10001] = "SkyboxComponent";
11667
- DataType[DataType["LightComponent"] = 10002] = "LightComponent";
11668
- DataType[DataType["CameraComponent"] = 10003] = "CameraComponent";
11669
- DataType[DataType["ModelPluginComponent"] = 10004] = "ModelPluginComponent";
11670
- DataType[DataType["TreeComponent"] = 10005] = "TreeComponent";
11671
- })(DataType || (DataType = {}));
11767
+ DataType["MeshComponent"] = "MeshComponent";
11768
+ DataType["SkyboxComponent"] = "SkyboxComponent";
11769
+ DataType["LightComponent"] = "LightComponent";
11770
+ DataType["CameraComponent"] = "CameraComponent";
11771
+ DataType["ModelPluginComponent"] = "ModelPluginComponent";
11772
+ DataType["TreeComponent"] = "TreeComponent";
11773
+ })(DataType$1 || (DataType$1 = {}));
11672
11774
 
11673
11775
  /**
11674
11776
  * 抽象插件类
@@ -11819,7 +11921,7 @@ function calculateTranslation(out, target, acc, time, duration, posData, velData
11819
11921
  return ret;
11820
11922
  }
11821
11923
 
11822
- var _a$3;
11924
+ var _a$4;
11823
11925
  function ensureVec3(num) {
11824
11926
  return Array.isArray(num) ? [num[0], num[1], num[2]] : [0, 0, 0];
11825
11927
  }
@@ -11842,7 +11944,7 @@ function vecNormalize(out, a) {
11842
11944
  out = [];
11843
11945
  }
11844
11946
  var ap = a;
11845
- var sum = Math.hypot.apply(Math, __spreadArray$2([], __read$3(ap), false));
11947
+ var sum = Math.hypot.apply(Math, __spreadArray$3([], __read$3(ap), false));
11846
11948
  if (sum === 0) {
11847
11949
  return vecAssign(out, ap, ap.length);
11848
11950
  }
@@ -11873,17 +11975,17 @@ function vecMulCombine(out, a, b) {
11873
11975
  }
11874
11976
  return out;
11875
11977
  }
11876
- var particleOriginTranslateMap = (_a$3 = {},
11877
- _a$3[ParticleOrigin$1.PARTICLE_ORIGIN_CENTER] = [0, 0],
11878
- _a$3[ParticleOrigin$1.PARTICLE_ORIGIN_CENTER_BOTTOM] = [0, -0.5],
11879
- _a$3[ParticleOrigin$1.PARTICLE_ORIGIN_CENTER_TOP] = [0, 0.5],
11880
- _a$3[ParticleOrigin$1.PARTICLE_ORIGIN_LEFT_TOP] = [-0.5, 0.5],
11881
- _a$3[ParticleOrigin$1.PARTICLE_ORIGIN_LEFT_CENTER] = [-0.5, 0],
11882
- _a$3[ParticleOrigin$1.PARTICLE_ORIGIN_LEFT_BOTTOM] = [-0.5, -0.5],
11883
- _a$3[ParticleOrigin$1.PARTICLE_ORIGIN_RIGHT_CENTER] = [0.5, 0],
11884
- _a$3[ParticleOrigin$1.PARTICLE_ORIGIN_RIGHT_BOTTOM] = [0.5, -0.5],
11885
- _a$3[ParticleOrigin$1.PARTICLE_ORIGIN_RIGHT_TOP] = [0.5, 0.5],
11886
- _a$3);
11978
+ var particleOriginTranslateMap$1 = (_a$4 = {},
11979
+ _a$4[ParticleOrigin$1.PARTICLE_ORIGIN_CENTER] = [0, 0],
11980
+ _a$4[ParticleOrigin$1.PARTICLE_ORIGIN_CENTER_BOTTOM] = [0, -0.5],
11981
+ _a$4[ParticleOrigin$1.PARTICLE_ORIGIN_CENTER_TOP] = [0, 0.5],
11982
+ _a$4[ParticleOrigin$1.PARTICLE_ORIGIN_LEFT_TOP] = [-0.5, 0.5],
11983
+ _a$4[ParticleOrigin$1.PARTICLE_ORIGIN_LEFT_CENTER] = [-0.5, 0],
11984
+ _a$4[ParticleOrigin$1.PARTICLE_ORIGIN_LEFT_BOTTOM] = [-0.5, -0.5],
11985
+ _a$4[ParticleOrigin$1.PARTICLE_ORIGIN_RIGHT_CENTER] = [0.5, 0],
11986
+ _a$4[ParticleOrigin$1.PARTICLE_ORIGIN_RIGHT_BOTTOM] = [0.5, -0.5],
11987
+ _a$4[ParticleOrigin$1.PARTICLE_ORIGIN_RIGHT_TOP] = [0.5, 0.5],
11988
+ _a$4);
11887
11989
  function nearestPowerOfTwo(value) {
11888
11990
  return Math.pow(2, Math.round(Math.log(value) / Math.LN2));
11889
11991
  }
@@ -11908,7 +12010,7 @@ function trianglesFromRect(position, halfWidth, halfHeight) {
11908
12010
  ];
11909
12011
  }
11910
12012
 
11911
- var _a$2;
12013
+ var _a$3;
11912
12014
  var NOT_IMPLEMENT = 'not_implement';
11913
12015
  var ValueGetter = /** @class */ (function () {
11914
12016
  function ValueGetter(arg) {
@@ -12416,50 +12518,50 @@ var BezierSegments = /** @class */ (function (_super) {
12416
12518
  };
12417
12519
  return BezierSegments;
12418
12520
  }(PathSegments));
12419
- var map$1 = (_a$2 = {},
12420
- _a$2[ValueType$1.RANDOM] = function (props) {
12521
+ var map$1 = (_a$3 = {},
12522
+ _a$3[ValueType$1.RANDOM] = function (props) {
12421
12523
  if (props[0] instanceof Array) {
12422
12524
  return new RandomVectorValue(props);
12423
12525
  }
12424
12526
  return new RandomValue(props);
12425
12527
  },
12426
- _a$2[ValueType$1.CONSTANT] = function (props) {
12528
+ _a$3[ValueType$1.CONSTANT] = function (props) {
12427
12529
  return new StaticValue(props);
12428
12530
  },
12429
- _a$2[ValueType$1.CONSTANT_VEC2] = function (props) {
12531
+ _a$3[ValueType$1.CONSTANT_VEC2] = function (props) {
12430
12532
  return new StaticValue(props);
12431
12533
  },
12432
- _a$2[ValueType$1.CONSTANT_VEC3] = function (props) {
12534
+ _a$3[ValueType$1.CONSTANT_VEC3] = function (props) {
12433
12535
  return new StaticValue(props);
12434
12536
  },
12435
- _a$2[ValueType$1.CONSTANT_VEC4] = function (props) {
12537
+ _a$3[ValueType$1.CONSTANT_VEC4] = function (props) {
12436
12538
  return new StaticValue(props);
12437
12539
  },
12438
- _a$2[ValueType$1.CURVE] = function (props) {
12540
+ _a$3[ValueType$1.CURVE] = function (props) {
12439
12541
  return new CurveValue(props);
12440
12542
  },
12441
- _a$2[ValueType$1.RGBA_COLOR] = function (props) {
12543
+ _a$3[ValueType$1.RGBA_COLOR] = function (props) {
12442
12544
  return new StaticValue(props);
12443
12545
  },
12444
- _a$2[ValueType$1.COLORS] = function (props) {
12546
+ _a$3[ValueType$1.COLORS] = function (props) {
12445
12547
  return new RandomSetValue(props.map(function (c) { return colorToArr$1(c, false); }));
12446
12548
  },
12447
- _a$2[ValueType$1.LINE] = function (props) {
12549
+ _a$3[ValueType$1.LINE] = function (props) {
12448
12550
  if (props.length === 2 && props[0][0] === 0 && props[1][0] === 1) {
12449
12551
  return new LinearValue([props[0][1], props[1][1]]);
12450
12552
  }
12451
12553
  return new LineSegments(props);
12452
12554
  },
12453
- _a$2[ValueType$1.GRADIENT_COLOR] = function (props) {
12555
+ _a$3[ValueType$1.GRADIENT_COLOR] = function (props) {
12454
12556
  return new GradientValue(props);
12455
12557
  },
12456
- _a$2[ValueType$1.LINEAR_PATH] = function (pros) {
12558
+ _a$3[ValueType$1.LINEAR_PATH] = function (pros) {
12457
12559
  return new PathSegments(pros);
12458
12560
  },
12459
- _a$2[ValueType$1.BEZIER_PATH] = function (pros) {
12561
+ _a$3[ValueType$1.BEZIER_PATH] = function (pros) {
12460
12562
  return new BezierSegments(pros);
12461
12563
  },
12462
- _a$2);
12564
+ _a$3);
12463
12565
  function createValueGetter(args) {
12464
12566
  if (!args || !isNaN(+args)) {
12465
12567
  return new StaticValue(args || 0);
@@ -13189,7 +13291,7 @@ var CameraController = /** @class */ (function (_super) {
13189
13291
  }
13190
13292
  };
13191
13293
  CameraController = __decorate([
13192
- effectsClass(DataType.CameraController)
13294
+ effectsClass(DataType$1.CameraController)
13193
13295
  ], CameraController);
13194
13296
  return CameraController;
13195
13297
  }(ItemBehaviour));
@@ -13410,13 +13512,13 @@ var InteractMesh = /** @class */ (function () {
13410
13512
  ['ENV_EDITOR', ((_a = this.engine.renderer) === null || _a === void 0 ? void 0 : _a.env) === PLAYER_OPTIONS_ENV_EDITOR],
13411
13513
  ];
13412
13514
  var color = createValueGetter(this.color).getValue(0);
13413
- var level = this.engine.gpuCapability.level;
13414
13515
  var materialProps = {
13415
13516
  shader: {
13416
- vertex: createShaderWithMarcos(marcos, vertex, ShaderType.vertex, level),
13417
- fragment: createShaderWithMarcos(marcos, fragment, ShaderType.fragment, level),
13517
+ vertex: vertex,
13518
+ fragment: fragment,
13418
13519
  glslVersion: GLSLVersion.GLSL1,
13419
13520
  cacheId: "".concat(rendererOptions.cachePrefix, "_effects_interact"),
13521
+ marcos: marcos,
13420
13522
  },
13421
13523
  uniformSemantics: {
13422
13524
  effects_MatrixVP: 'VIEWPROJECTION',
@@ -13490,11 +13592,11 @@ var InteractComponent = /** @class */ (function (_super) {
13490
13592
  }
13491
13593
  InteractComponent_1 = InteractComponent;
13492
13594
  InteractComponent.prototype.start = function () {
13493
- var _a, _b, _c;
13595
+ var _this = this;
13494
13596
  var options = this.item.props.content.options;
13495
- var env = ((_b = (_a = this.item.engine) === null || _a === void 0 ? void 0 : _a.renderer) !== null && _b !== void 0 ? _b : {}).env;
13597
+ var env = this.item.engine.renderer.env;
13496
13598
  var composition = this.item.composition;
13497
- var _d = this.interactData.options, type = _d.type, showPreview = _d.showPreview;
13599
+ var _a = this.interactData.options, type = _a.type, showPreview = _a.showPreview;
13498
13600
  if (type === InteractType$1.CLICK) {
13499
13601
  this.clickable = true;
13500
13602
  if (showPreview && env === PLAYER_OPTIONS_ENV_EDITOR) {
@@ -13502,7 +13604,8 @@ var InteractComponent = /** @class */ (function (_super) {
13502
13604
  this.previewContent = new InteractMesh(this.item.props.content, rendererOptions, this.transform, this.engine);
13503
13605
  }
13504
13606
  }
13505
- (_c = this.item.composition) === null || _c === void 0 ? void 0 : _c.addInteractiveItem(this.item, options.type);
13607
+ composition.addInteractiveItem(this.item, options.type);
13608
+ this.item.onEnd = function () { return composition.removeInteractiveItem(_this.item, options.type); };
13506
13609
  if (options.type === InteractType$1.DRAG) {
13507
13610
  if (env !== PLAYER_OPTIONS_ENV_EDITOR || options.enableInEditor) {
13508
13611
  composition.event && this.beginDragTarget(options, composition.event);
@@ -13646,7 +13749,7 @@ var InteractComponent = /** @class */ (function (_super) {
13646
13749
  };
13647
13750
  var InteractComponent_1;
13648
13751
  InteractComponent = InteractComponent_1 = __decorate([
13649
- effectsClass(DataType.InteractComponent)
13752
+ effectsClass(DataType$1.InteractComponent)
13650
13753
  ], InteractComponent);
13651
13754
  return InteractComponent;
13652
13755
  }(RendererComponent));
@@ -13695,8 +13798,8 @@ function spriteMeshShaderFromFilter(level, options) {
13695
13798
  var fragment = wireframe ? itemFrameFrag : itemFrag.replace(/#pragma\s+FILTER_FRAG/, '');
13696
13799
  var vertex = itemVert.replace(/#pragma\s+FILTER_VERT/, 'vec4 filterMain(float t,vec4 pos){return effects_MatrixVP * pos;}');
13697
13800
  return {
13698
- fragment: createShaderWithMarcos(marcos, fragment, ShaderType.fragment, level),
13699
- vertex: createShaderWithMarcos(marcos, vertex, ShaderType.vertex, level),
13801
+ fragment: fragment,
13802
+ vertex: vertex,
13700
13803
  glslVersion: level === 1 ? GLSLVersion.GLSL1 : GLSLVersion.GLSL3,
13701
13804
  marcos: marcos,
13702
13805
  shared: true,
@@ -13934,15 +14037,25 @@ var PlayableOutput = /** @class */ (function () {
13934
14037
  };
13935
14038
  return PlayableOutput;
13936
14039
  }());
14040
+ var PlayableAsset = /** @class */ (function () {
14041
+ function PlayableAsset() {
14042
+ }
14043
+ PlayableAsset.prototype.fromData = function (data) {
14044
+ };
14045
+ return PlayableAsset;
14046
+ }());
13937
14047
 
13938
14048
  /**
13939
14049
  * @since 2.0.0
13940
14050
  * @internal
13941
14051
  */
13942
- var Track = /** @class */ (function () {
14052
+ var Track = /** @class */ (function (_super) {
14053
+ __extends(Track, _super);
13943
14054
  function Track() {
13944
- this.clips = [];
13945
- this.clipSeed = 0;
14055
+ var _this = _super !== null && _super.apply(this, arguments) || this;
14056
+ _this.clips = [];
14057
+ _this.clipSeed = 0;
14058
+ return _this;
13946
14059
  }
13947
14060
  Track.prototype.createOutput = function () {
13948
14061
  var output = new PlayableOutput();
@@ -13954,7 +14067,7 @@ var Track = /** @class */ (function () {
13954
14067
  Track.prototype.createMixerPlayable = function () {
13955
14068
  return new Playable();
13956
14069
  };
13957
- Track.prototype.createPlayebleTree = function () {
14070
+ Track.prototype.createPlayable = function () {
13958
14071
  var e_1, _a;
13959
14072
  var defaultMixPlayable = this.createMixerPlayable();
13960
14073
  try {
@@ -14006,7 +14119,7 @@ var Track = /** @class */ (function () {
14006
14119
  this.clips.push(clip);
14007
14120
  };
14008
14121
  return Track;
14009
- }());
14122
+ }(PlayableAsset));
14010
14123
  /**
14011
14124
  * @since 2.0.0
14012
14125
  * @internal
@@ -14062,12 +14175,12 @@ var tempPos = new Vector3();
14062
14175
  * @since 2.0.0
14063
14176
  * @internal
14064
14177
  */
14065
- var AnimationClipPlayable = /** @class */ (function (_super) {
14066
- __extends(AnimationClipPlayable, _super);
14067
- function AnimationClipPlayable() {
14178
+ var TransformAnimationPlayable = /** @class */ (function (_super) {
14179
+ __extends(TransformAnimationPlayable, _super);
14180
+ function TransformAnimationPlayable() {
14068
14181
  return _super !== null && _super.apply(this, arguments) || this;
14069
14182
  }
14070
- AnimationClipPlayable.prototype.processFrame = function (dt) {
14183
+ TransformAnimationPlayable.prototype.processFrame = function (dt) {
14071
14184
  if (this.bindingItem.composition) {
14072
14185
  this.sampleAnimation();
14073
14186
  }
@@ -14075,7 +14188,7 @@ var AnimationClipPlayable = /** @class */ (function (_super) {
14075
14188
  /**
14076
14189
  * 应用时间轴K帧数据到对象
14077
14190
  */
14078
- AnimationClipPlayable.prototype.sampleAnimation = function () {
14191
+ TransformAnimationPlayable.prototype.sampleAnimation = function () {
14079
14192
  var _this = this;
14080
14193
  var duration = this.bindingItem.duration;
14081
14194
  var life = this.time / duration;
@@ -14120,7 +14233,7 @@ var AnimationClipPlayable = /** @class */ (function (_super) {
14120
14233
  // this.animationStream.setCurveValue('transform', 'position.z', pos.z);
14121
14234
  }
14122
14235
  };
14123
- AnimationClipPlayable.prototype.fromData = function (data) {
14236
+ TransformAnimationPlayable.prototype.fromData = function (data) {
14124
14237
  var _a;
14125
14238
  var scale = this.bindingItem.transform.scale;
14126
14239
  this.originalTransform = {
@@ -14191,30 +14304,45 @@ var AnimationClipPlayable = /** @class */ (function (_super) {
14191
14304
  this.velocity = this.direction.clone();
14192
14305
  this.velocity.multiply(this.startSpeed);
14193
14306
  };
14194
- return AnimationClipPlayable;
14307
+ return TransformAnimationPlayable;
14195
14308
  }(AnimationPlayable));
14309
+ var TransformAnimationPlayableAsset = /** @class */ (function (_super) {
14310
+ __extends(TransformAnimationPlayableAsset, _super);
14311
+ function TransformAnimationPlayableAsset() {
14312
+ return _super !== null && _super.apply(this, arguments) || this;
14313
+ }
14314
+ TransformAnimationPlayableAsset.prototype.createPlayable = function () {
14315
+ var transformAnimationPlayable = new TransformAnimationPlayable();
14316
+ transformAnimationPlayable.fromData(this.transformAnimationData);
14317
+ return transformAnimationPlayable;
14318
+ };
14319
+ TransformAnimationPlayableAsset.prototype.fromData = function (data) {
14320
+ this.transformAnimationData = data;
14321
+ };
14322
+ return TransformAnimationPlayableAsset;
14323
+ }(PlayableAsset));
14196
14324
  /**
14197
14325
  * @since 2.0.0
14198
14326
  * @internal
14199
14327
  */
14200
- var ActivationClipPlayable = /** @class */ (function (_super) {
14201
- __extends(ActivationClipPlayable, _super);
14202
- function ActivationClipPlayable() {
14328
+ var ActivationPlayable = /** @class */ (function (_super) {
14329
+ __extends(ActivationPlayable, _super);
14330
+ function ActivationPlayable() {
14203
14331
  return _super !== null && _super.apply(this, arguments) || this;
14204
14332
  }
14205
- ActivationClipPlayable.prototype.onGraphStart = function () {
14333
+ ActivationPlayable.prototype.onGraphStart = function () {
14206
14334
  this.bindingItem.transform.setValid(false);
14207
14335
  this.hideRendererComponents();
14208
14336
  };
14209
- ActivationClipPlayable.prototype.onPlayablePlay = function () {
14337
+ ActivationPlayable.prototype.onPlayablePlay = function () {
14210
14338
  this.bindingItem.transform.setValid(true);
14211
14339
  this.showRendererComponents();
14212
14340
  };
14213
- ActivationClipPlayable.prototype.onPlayableDestroy = function () {
14341
+ ActivationPlayable.prototype.onPlayableDestroy = function () {
14214
14342
  this.bindingItem.transform.setValid(false);
14215
14343
  this.hideRendererComponents();
14216
14344
  };
14217
- ActivationClipPlayable.prototype.hideRendererComponents = function () {
14345
+ ActivationPlayable.prototype.hideRendererComponents = function () {
14218
14346
  var e_1, _a;
14219
14347
  try {
14220
14348
  for (var _b = __values$1(this.bindingItem.rendererComponents), _c = _b.next(); !_c.done; _c = _b.next()) {
@@ -14232,7 +14360,7 @@ var ActivationClipPlayable = /** @class */ (function (_super) {
14232
14360
  finally { if (e_1) throw e_1.error; }
14233
14361
  }
14234
14362
  };
14235
- ActivationClipPlayable.prototype.showRendererComponents = function () {
14363
+ ActivationPlayable.prototype.showRendererComponents = function () {
14236
14364
  var e_2, _a;
14237
14365
  try {
14238
14366
  for (var _b = __values$1(this.bindingItem.rendererComponents), _c = _b.next(); !_c.done; _c = _b.next()) {
@@ -14250,7 +14378,7 @@ var ActivationClipPlayable = /** @class */ (function (_super) {
14250
14378
  finally { if (e_2) throw e_2.error; }
14251
14379
  }
14252
14380
  };
14253
- return ActivationClipPlayable;
14381
+ return ActivationPlayable;
14254
14382
  }(Playable));
14255
14383
 
14256
14384
  /**
@@ -14505,7 +14633,7 @@ var TimelineComponent = /** @class */ (function (_super) {
14505
14633
  try {
14506
14634
  for (var _b = __values$1(this.tracks), _c = _b.next(); !_c.done; _c = _b.next()) {
14507
14635
  var track = _c.value;
14508
- var trackMixPlayable = track.createPlayebleTree();
14636
+ var trackMixPlayable = track.createPlayable();
14509
14637
  var trackOutput = track.createOutput();
14510
14638
  graph.addOutput(trackOutput);
14511
14639
  trackOutput.setSourcePlayeble(trackMixPlayable);
@@ -14520,6 +14648,7 @@ var TimelineComponent = /** @class */ (function (_super) {
14520
14648
  }
14521
14649
  };
14522
14650
  TimelineComponent.prototype.fromData = function (data) {
14651
+ var e_13, _a, e_14, _b;
14523
14652
  _super.prototype.fromData.call(this, data);
14524
14653
  this.options = {
14525
14654
  start: this.item.start,
@@ -14530,7 +14659,47 @@ var TimelineComponent = /** @class */ (function (_super) {
14530
14659
  this.id = this.item.id;
14531
14660
  this.name = this.item.name;
14532
14661
  var activationTrack = this.createTrack(Track, 'ActivationTrack');
14533
- activationTrack.createClip(ActivationClipPlayable, 'ActivationTimelineClip');
14662
+ activationTrack.createClip(ActivationPlayable, 'ActivationTimelineClip');
14663
+ //@ts-expect-error
14664
+ if (data.tracks) {
14665
+ //@ts-expect-error
14666
+ var tracks = data.tracks;
14667
+ try {
14668
+ for (var tracks_1 = __values$1(tracks), tracks_1_1 = tracks_1.next(); !tracks_1_1.done; tracks_1_1 = tracks_1.next()) {
14669
+ var track = tracks_1_1.value;
14670
+ var newTrack = this.createTrack(Track);
14671
+ try {
14672
+ for (var _c = (e_14 = void 0, __values$1(track.clips)), _d = _c.next(); !_d.done; _d = _c.next()) {
14673
+ var clipAsset = _d.value;
14674
+ switch (clipAsset.dataType) {
14675
+ case 'TransformAnimationPlayableAsset':
14676
+ newTrack.name = 'AnimationTrack';
14677
+ newTrack.createClip(TransformAnimationPlayable, 'AnimationTimelineClip').playable.fromData(clipAsset.animationClip);
14678
+ break;
14679
+ case 'SpriteColorAnimationPlayableAsset':
14680
+ newTrack.name = 'SpriteColorTrack';
14681
+ newTrack.createClip(SpriteColorPlayable, 'SpriteColorClip').playable.fromData(clipAsset.animationClip);
14682
+ break;
14683
+ }
14684
+ }
14685
+ }
14686
+ catch (e_14_1) { e_14 = { error: e_14_1 }; }
14687
+ finally {
14688
+ try {
14689
+ if (_d && !_d.done && (_b = _c.return)) _b.call(_c);
14690
+ }
14691
+ finally { if (e_14) throw e_14.error; }
14692
+ }
14693
+ }
14694
+ }
14695
+ catch (e_13_1) { e_13 = { error: e_13_1 }; }
14696
+ finally {
14697
+ try {
14698
+ if (tracks_1_1 && !tracks_1_1.done && (_a = tracks_1.return)) _a.call(tracks_1);
14699
+ }
14700
+ finally { if (e_13) throw e_13.error; }
14701
+ }
14702
+ }
14534
14703
  };
14535
14704
  TimelineComponent.prototype.toData = function () {
14536
14705
  _super.prototype.toData.call(this);
@@ -14944,15 +15113,12 @@ var SpriteComponent = /** @class */ (function (_super) {
14944
15113
  this.material.setVector4('_Color', new Vector4().setFromArray(startColor));
14945
15114
  this.material.setVector4('_TexOffset', new Vector4().setFromArray([0, 0, 1, 1]));
14946
15115
  this.setItem();
14947
- // 添加K帧动画
14948
- var colorTrack = this.item.getComponent(TimelineComponent).createTrack(Track, 'SpriteColorTrack');
14949
- colorTrack.createClip(SpriteColorPlayable, 'SpriteColorClip').playable.fromData({ colorOverLifetime: data.colorOverLifetime, startColor: data.options.startColor });
14950
15116
  };
14951
15117
  SpriteComponent.prototype.toData = function () {
14952
15118
  _super.prototype.toData.call(this);
14953
15119
  };
14954
15120
  SpriteComponent = __decorate([
14955
- effectsClass(DataType.SpriteComponent)
15121
+ effectsClass(DataType$1.SpriteComponent)
14956
15122
  ], SpriteComponent);
14957
15123
  return SpriteComponent;
14958
15124
  }(RendererComponent));
@@ -15113,8 +15279,8 @@ var ParticleMesh = /** @class */ (function () {
15113
15279
  var originalVertex = "#define LOOKUP_TEXTURE_CURVE ".concat(vertex_lookup_texture, "\n").concat(particleVert);
15114
15280
  var vertex = originalVertex;
15115
15281
  var shader = {
15116
- fragment: createShaderWithMarcos(marcos, fragment, ShaderType.fragment, level),
15117
- vertex: createShaderWithMarcos(marcos, vertex, ShaderType.vertex, level),
15282
+ fragment: fragment,
15283
+ vertex: vertex,
15118
15284
  glslVersion: level === 1 ? GLSLVersion.GLSL1 : GLSLVersion.GLSL3,
15119
15285
  shared: true,
15120
15286
  cacheId: shaderCache,
@@ -15669,8 +15835,8 @@ var TrailMesh = /** @class */ (function () {
15669
15835
  else {
15670
15836
  uniformValues.uVCurveValues = CurveValue.getAllData(keyFrameMeta);
15671
15837
  }
15672
- var vertex = createShaderWithMarcos(marcos, trailVert, ShaderType.vertex, level);
15673
- var fragment = createShaderWithMarcos(marcos, particleFrag, ShaderType.fragment, level);
15838
+ var vertex = trailVert;
15839
+ var fragment = particleFrag;
15674
15840
  var mtl = ({
15675
15841
  shader: {
15676
15842
  vertex: vertex,
@@ -16357,7 +16523,7 @@ var TextureShape = /** @class */ (function () {
16357
16523
  return TextureShape;
16358
16524
  }());
16359
16525
 
16360
- var _a$1;
16526
+ var _a$2;
16361
16527
  var ShapeNone = /** @class */ (function () {
16362
16528
  function ShapeNone() {
16363
16529
  }
@@ -16369,18 +16535,18 @@ var ShapeNone = /** @class */ (function () {
16369
16535
  };
16370
16536
  return ShapeNone;
16371
16537
  }());
16372
- var map = (_a$1 = {},
16373
- _a$1[ShapeType$1.NONE] = ShapeNone,
16374
- _a$1[ShapeType$1.CONE] = Cone,
16375
- _a$1[ShapeType$1.SPHERE] = Sphere,
16376
- _a$1[ShapeType$1.HEMISPHERE] = Hemisphere,
16377
- _a$1[ShapeType$1.CIRCLE] = Circle,
16378
- _a$1[ShapeType$1.DONUT] = Donut,
16379
- _a$1[ShapeType$1.RECTANGLE] = Rectangle,
16380
- _a$1[ShapeType$1.EDGE] = Edge,
16381
- _a$1[ShapeType$1.RECTANGLE_EDGE] = RectangleEdge,
16382
- _a$1[ShapeType$1.TEXTURE] = TextureShape,
16383
- _a$1);
16538
+ var map = (_a$2 = {},
16539
+ _a$2[ShapeType$1.NONE] = ShapeNone,
16540
+ _a$2[ShapeType$1.CONE] = Cone,
16541
+ _a$2[ShapeType$1.SPHERE] = Sphere,
16542
+ _a$2[ShapeType$1.HEMISPHERE] = Hemisphere,
16543
+ _a$2[ShapeType$1.CIRCLE] = Circle,
16544
+ _a$2[ShapeType$1.DONUT] = Donut,
16545
+ _a$2[ShapeType$1.RECTANGLE] = Rectangle,
16546
+ _a$2[ShapeType$1.EDGE] = Edge,
16547
+ _a$2[ShapeType$1.RECTANGLE_EDGE] = RectangleEdge,
16548
+ _a$2[ShapeType$1.TEXTURE] = TextureShape,
16549
+ _a$2);
16384
16550
  function createShape(shapeOptions) {
16385
16551
  if (!shapeOptions) {
16386
16552
  return new ShapeNone();
@@ -17709,7 +17875,7 @@ var ParticleSystem = /** @class */ (function (_super) {
17709
17875
  }));
17710
17876
  p.delay += meshTime;
17711
17877
  cursor++;
17712
- (_a = p.transform).translate.apply(_a, __spreadArray$2([], __read$3(burstOffset), false));
17878
+ (_a = p.transform).translate.apply(_a, __spreadArray$3([], __read$3(burstOffset), false));
17713
17879
  this.addParticle(p, maxCount_1);
17714
17880
  }
17715
17881
  }
@@ -18298,7 +18464,7 @@ var ParticleSystem = /** @class */ (function (_super) {
18298
18464
  timeline.createTrack(Track).createClip(ParticleBehaviourPlayable);
18299
18465
  };
18300
18466
  ParticleSystem = __decorate([
18301
- effectsClass(DataType.ParticleSystem)
18467
+ effectsClass(DataType$1.ParticleSystem)
18302
18468
  ], ParticleSystem);
18303
18469
  return ParticleSystem;
18304
18470
  }(Component));
@@ -18481,7 +18647,9 @@ var TextStyle = /** @class */ (function () {
18481
18647
  this.fontOffset = 0;
18482
18648
  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;
18483
18649
  this.textColor = textColor;
18650
+ //@ts-expect-error
18484
18651
  this.textWeight = fontWeight;
18652
+ //@ts-expect-error
18485
18653
  this.fontStyle = fontStyle;
18486
18654
  this.fontFamily = fontFamily;
18487
18655
  this.fontSize = fontSize; // 暂时取消字号限制 Math.min(fontSize, this.maxFontSize);
@@ -19991,7 +20159,7 @@ var TextComponent = /** @class */ (function (_super) {
19991
20159
  context.shadowOffsetY = -style.shadowOffsetY;
19992
20160
  };
19993
20161
  TextComponent = __decorate([
19994
- effectsClass(DataType.TextComponent)
20162
+ effectsClass(DataType$1.TextComponent)
19995
20163
  ], TextComponent);
19996
20164
  return TextComponent;
19997
20165
  }(SpriteComponent));
@@ -20147,7 +20315,7 @@ var EffectComponent = /** @class */ (function (_super) {
20147
20315
  serialize()
20148
20316
  ], EffectComponent.prototype, "geometry", void 0);
20149
20317
  EffectComponent = __decorate([
20150
- effectsClass(DataType.EffectComponent)
20318
+ effectsClass(DataType$1.EffectComponent)
20151
20319
  ], EffectComponent);
20152
20320
  return EffectComponent;
20153
20321
  }(RendererComponent));
@@ -20549,7 +20717,10 @@ var VFXItem = /** @class */ (function (_super) {
20549
20717
  try {
20550
20718
  for (var _e = __values$1(this.children), _f = _e.next(); !_f.done; _f = _e.next()) {
20551
20719
  var child = _f.value;
20552
- return child.find(name);
20720
+ var res = child.find(name);
20721
+ if (res) {
20722
+ return res;
20723
+ }
20553
20724
  }
20554
20725
  }
20555
20726
  catch (e_4_1) { e_4 = { error: e_4_1 }; }
@@ -20566,6 +20737,7 @@ var VFXItem = /** @class */ (function (_super) {
20566
20737
  _super.prototype.fromData.call(this, data);
20567
20738
  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;
20568
20739
  this.props = data;
20740
+ //@ts-expect-error
20569
20741
  this.type = data.type;
20570
20742
  this.id = id.toString(); // TODO 老数据 id 是 number,需要转换
20571
20743
  this.name = name;
@@ -20603,10 +20775,6 @@ var VFXItem = /** @class */ (function (_super) {
20603
20775
  }
20604
20776
  var timelineComponent = this.getComponent(TimelineComponent);
20605
20777
  timelineComponent.fromData(data.content);
20606
- if (this.type !== ItemType$1.particle) {
20607
- var track = timelineComponent.createTrack(Track, 'AnimationTrack');
20608
- track.createClip(AnimationClipPlayable, 'AnimationTimelineClip').playable.fromData(data.content);
20609
- }
20610
20778
  if (duration <= 0) {
20611
20779
  throw Error("Item duration can't be less than 0, see ".concat(HELP_LINK['Item duration can\'t be less than 0']));
20612
20780
  }
@@ -20638,7 +20806,7 @@ var VFXItem = /** @class */ (function (_super) {
20638
20806
  var _b, _c;
20639
20807
  this.taggedProperties.id = this.guid;
20640
20808
  this.taggedProperties.transform = this.transform.toData();
20641
- this.taggedProperties.dataType = DataType.VFXItemData;
20809
+ this.taggedProperties.dataType = DataType$1.VFXItemData;
20642
20810
  if (((_b = this.parent) === null || _b === void 0 ? void 0 : _b.name) !== 'rootItem') {
20643
20811
  this.taggedProperties.parentId = (_c = this.parent) === null || _c === void 0 ? void 0 : _c.guid;
20644
20812
  }
@@ -20665,10 +20833,10 @@ var VFXItem = /** @class */ (function (_super) {
20665
20833
  };
20666
20834
  VFXItem.prototype.translateByPixel = function (x, y) {
20667
20835
  if (this.composition) {
20836
+ // @ts-expect-error
20837
+ var _a = this.composition.renderer.canvas.getBoundingClientRect(), width = _a.width, height = _a.height;
20668
20838
  var z = this.transform.getWorldPosition().z;
20669
- var _a = this.composition.camera.getInverseVPRatio(z), rx = _a.x, ry = _a.y;
20670
- var width = this.composition.renderer.getWidth() / 2;
20671
- var height = this.composition.renderer.getHeight() / 2;
20839
+ var _b = this.composition.camera.getInverseVPRatio(z), rx = _b.x, ry = _b.y;
20672
20840
  this.transform.translate(2 * x * rx / width, -2 * y * ry / height, 0);
20673
20841
  }
20674
20842
  };
@@ -20735,7 +20903,7 @@ var VFXItem = /** @class */ (function (_super) {
20735
20903
  };
20736
20904
  var VFXItem_1;
20737
20905
  VFXItem = VFXItem_1 = __decorate([
20738
- effectsClass(DataType.VFXItemData)
20906
+ effectsClass(DataType$1.VFXItemData)
20739
20907
  ], VFXItem);
20740
20908
  return VFXItem;
20741
20909
  }(EffectsObject));
@@ -20773,7 +20941,6 @@ function createVFXItem(props, composition) {
20773
20941
  if (!pluginName) {
20774
20942
  switch (type) {
20775
20943
  case ItemType$1.null:
20776
- case ItemType$1.base:
20777
20944
  pluginName = 'cal';
20778
20945
  break;
20779
20946
  case ItemType$1.sprite:
@@ -20894,7 +21061,7 @@ var PluginSystem = /** @class */ (function () {
20894
21061
  plugin = plugins[i];
20895
21062
  ctrl = pluginLoaderMap[plugin.name];
20896
21063
  if (name in ctrl) {
20897
- pendings.push(Promise.resolve(ctrl[name].apply(ctrl, __spreadArray$2([], __read$3(args), false))));
21064
+ pendings.push(Promise.resolve(ctrl[name].apply(ctrl, __spreadArray$3([], __read$3(args), false))));
20898
21065
  }
20899
21066
  }
20900
21067
  return [2 /*return*/, Promise.all(pendings)];
@@ -20939,9 +21106,74 @@ function getPluginUsageInfo(name) {
20939
21106
  * Name: @galacean/effects-specification
20940
21107
  * Description: Galacean Effects JSON Specification
20941
21108
  * Author: Ant Group CO., Ltd.
20942
- * Version: v1.0.1
21109
+ * Version: v2.0.0-alpha.2
21110
+ */
21111
+
21112
+ const randomUUID = typeof crypto !== 'undefined' && crypto.randomUUID && crypto.randomUUID.bind(crypto);
21113
+ var native = {
21114
+ randomUUID
21115
+ };
21116
+
21117
+ // Unique ID creation requires a high quality random # generator. In the browser we therefore
21118
+ // require the crypto API and do not support built-in fallback to lower quality random number
21119
+ // generators (like Math.random()).
21120
+ let getRandomValues;
21121
+ const rnds8 = new Uint8Array(16);
21122
+ function rng() {
21123
+ // lazy load so that environments that need to polyfill have a chance to do so
21124
+ if (!getRandomValues) {
21125
+ // getRandomValues needs to be invoked in a context where "this" is a Crypto implementation.
21126
+ getRandomValues = typeof crypto !== 'undefined' && crypto.getRandomValues && crypto.getRandomValues.bind(crypto);
21127
+
21128
+ if (!getRandomValues) {
21129
+ throw new Error('crypto.getRandomValues() not supported. See https://github.com/uuidjs/uuid#getrandomvalues-not-supported');
21130
+ }
21131
+ }
21132
+
21133
+ return getRandomValues(rnds8);
21134
+ }
21135
+
21136
+ /**
21137
+ * Convert array of 16 byte values to UUID string format of the form:
21138
+ * XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX
20943
21139
  */
20944
21140
 
21141
+ const byteToHex = [];
21142
+
21143
+ for (let i = 0; i < 256; ++i) {
21144
+ byteToHex.push((i + 0x100).toString(16).slice(1));
21145
+ }
21146
+
21147
+ function unsafeStringify(arr, offset = 0) {
21148
+ // Note: Be careful editing this code! It's been tuned for performance
21149
+ // and works in ways you may not expect. See https://github.com/uuidjs/uuid/pull/434
21150
+ 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]];
21151
+ }
21152
+
21153
+ function v4(options, buf, offset) {
21154
+ if (native.randomUUID && !buf && !options) {
21155
+ return native.randomUUID();
21156
+ }
21157
+
21158
+ options = options || {};
21159
+ const rnds = options.random || (options.rng || rng)(); // Per 4.4, set bits for version and `clock_seq_hi_and_reserved`
21160
+
21161
+ rnds[6] = rnds[6] & 0x0f | 0x40;
21162
+ rnds[8] = rnds[8] & 0x3f | 0x80; // Copy bytes to buffer, if provided
21163
+
21164
+ if (buf) {
21165
+ offset = offset || 0;
21166
+
21167
+ for (let i = 0; i < 16; ++i) {
21168
+ buf[offset + i] = rnds[i];
21169
+ }
21170
+
21171
+ return buf;
21172
+ }
21173
+
21174
+ return unsafeStringify(rnds);
21175
+ }
21176
+
20945
21177
  /*********************************************/
20946
21178
  /* 元素属性参数类型 */
20947
21179
  /*********************************************/
@@ -21204,6 +21436,10 @@ var ItemType;
21204
21436
  * 天空盒元素
21205
21437
  */
21206
21438
  ItemType["skybox"] = "skybox";
21439
+ /**
21440
+ * 特效元素
21441
+ */
21442
+ ItemType["effect"] = "effect";
21207
21443
  })(ItemType || (ItemType = {}));
21208
21444
  /**
21209
21445
  * 渲染模式
@@ -21316,6 +21552,10 @@ var CompositionEndBehavior;
21316
21552
  * 销毁并保留最后一帧
21317
21553
  */
21318
21554
  CompositionEndBehavior[CompositionEndBehavior["pause_destroy"] = END_BEHAVIOR_PAUSE_AND_DESTROY] = "pause_destroy";
21555
+ /**
21556
+ * 冻结
21557
+ */
21558
+ CompositionEndBehavior[CompositionEndBehavior["freeze"] = END_BEHAVIOR_FREEZE] = "freeze";
21319
21559
  })(CompositionEndBehavior || (CompositionEndBehavior = {}));
21320
21560
 
21321
21561
  /*********************************************/
@@ -21452,12 +21692,38 @@ var ShapeArcMode;
21452
21692
  ShapeArcMode[ShapeArcMode["UNIFORM_BURST"] = 3] = "UNIFORM_BURST";
21453
21693
  })(ShapeArcMode || (ShapeArcMode = {}));
21454
21694
 
21695
+ var LightType;
21696
+ (function (LightType) {
21697
+ /**
21698
+ * 点光源
21699
+ */
21700
+ LightType["point"] = "point";
21701
+ /**
21702
+ * 聚光灯
21703
+ */
21704
+ LightType["spot"] = "spot";
21705
+ /**
21706
+ * 方向光
21707
+ */
21708
+ LightType["directional"] = "directional";
21709
+ /**
21710
+ * 环境光
21711
+ */
21712
+ LightType["ambient"] = "ambient";
21713
+ })(LightType || (LightType = {}));
21714
+
21455
21715
  var ModelBoundingType;
21456
21716
  (function (ModelBoundingType) {
21457
21717
  ModelBoundingType[ModelBoundingType["box"] = 2] = "box";
21458
21718
  ModelBoundingType[ModelBoundingType["sphere"] = 3] = "sphere";
21459
21719
  })(ModelBoundingType || (ModelBoundingType = {}));
21460
21720
 
21721
+ var CameraType;
21722
+ (function (CameraType) {
21723
+ CameraType["orthographic"] = "orthographic";
21724
+ CameraType["perspective"] = "perspective";
21725
+ })(CameraType || (CameraType = {}));
21726
+
21461
21727
  // 材质类型
21462
21728
  var MaterialType;
21463
21729
  (function (MaterialType) {
@@ -21603,6 +21869,28 @@ var FontStyle;
21603
21869
  FontStyle["oblique"] = "oblique";
21604
21870
  })(FontStyle || (FontStyle = {}));
21605
21871
 
21872
+ var DataType;
21873
+ (function (DataType) {
21874
+ DataType["VFXItemData"] = "VFXItemData";
21875
+ DataType["EffectComponent"] = "EffectComponent";
21876
+ DataType["Material"] = "Material";
21877
+ DataType["Shader"] = "Shader";
21878
+ DataType["SpriteComponent"] = "SpriteComponent";
21879
+ DataType["ParticleSystem"] = "ParticleSystem";
21880
+ DataType["InteractComponent"] = "InteractComponent";
21881
+ DataType["CameraController"] = "CameraController";
21882
+ DataType["Geometry"] = "Geometry";
21883
+ DataType["Texture"] = "Texture";
21884
+ DataType["TextComponent"] = "TextComponent";
21885
+ // FIXME: 先完成ECS的场景转换,后面移到spec中
21886
+ DataType["MeshComponent"] = "MeshComponent";
21887
+ DataType["SkyboxComponent"] = "SkyboxComponent";
21888
+ DataType["LightComponent"] = "LightComponent";
21889
+ DataType["CameraComponent"] = "CameraComponent";
21890
+ DataType["ModelPluginComponent"] = "ModelPluginComponent";
21891
+ DataType["TreeComponent"] = "TreeComponent";
21892
+ })(DataType || (DataType = {}));
21893
+
21606
21894
  /******************************************************************************
21607
21895
  Copyright (c) Microsoft Corporation.
21608
21896
 
@@ -21658,11 +21946,22 @@ function __read(o, n) {
21658
21946
  return ar;
21659
21947
  }
21660
21948
 
21949
+ function __spreadArray(to, from, pack) {
21950
+ if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {
21951
+ if (ar || !(i in from)) {
21952
+ if (!ar) ar = Array.prototype.slice.call(from, 0, i);
21953
+ ar[i] = from[i];
21954
+ }
21955
+ }
21956
+ return to.concat(ar || Array.prototype.slice.call(from));
21957
+ }
21958
+
21661
21959
  typeof SuppressedError === "function" ? SuppressedError : function (error, suppressed, message) {
21662
21960
  var e = new Error(message);
21663
21961
  return e.name = "SuppressedError", e.error = error, e.suppressed = suppressed, e;
21664
21962
  };
21665
21963
 
21964
+ var _a$1;
21666
21965
  function arrAdd(arr, item) {
21667
21966
  if (!arr.includes(item)) {
21668
21967
  arr.push(item);
@@ -21898,6 +22197,34 @@ function rotationZYXFromQuat(out, quat) {
21898
22197
  }
21899
22198
  return out;
21900
22199
  }
22200
+ function generateGUID() {
22201
+ return v4().replace(/-/g, '');
22202
+ }
22203
+ /**
22204
+ * 提取并转换 JSON 数据中的 anchor 值
22205
+ */
22206
+ function convertAnchor$1(anchor, particleOrigin) {
22207
+ if (anchor) {
22208
+ return [anchor[0] - 0.5, 0.5 - anchor[1]];
22209
+ }
22210
+ else if (particleOrigin) {
22211
+ return particleOriginTranslateMap[particleOrigin];
22212
+ }
22213
+ else {
22214
+ return [0, 0];
22215
+ }
22216
+ }
22217
+ var particleOriginTranslateMap = (_a$1 = {},
22218
+ _a$1[ParticleOrigin.PARTICLE_ORIGIN_CENTER] = [0, 0],
22219
+ _a$1[ParticleOrigin.PARTICLE_ORIGIN_CENTER_BOTTOM] = [0, -0.5],
22220
+ _a$1[ParticleOrigin.PARTICLE_ORIGIN_CENTER_TOP] = [0, 0.5],
22221
+ _a$1[ParticleOrigin.PARTICLE_ORIGIN_LEFT_TOP] = [-0.5, 0.5],
22222
+ _a$1[ParticleOrigin.PARTICLE_ORIGIN_LEFT_CENTER] = [-0.5, 0],
22223
+ _a$1[ParticleOrigin.PARTICLE_ORIGIN_LEFT_BOTTOM] = [-0.5, -0.5],
22224
+ _a$1[ParticleOrigin.PARTICLE_ORIGIN_RIGHT_CENTER] = [0.5, 0],
22225
+ _a$1[ParticleOrigin.PARTICLE_ORIGIN_RIGHT_BOTTOM] = [0.5, -0.5],
22226
+ _a$1[ParticleOrigin.PARTICLE_ORIGIN_RIGHT_TOP] = [0.5, 0.5],
22227
+ _a$1);
21901
22228
 
21902
22229
  function getStandardParticleContent(particle) {
21903
22230
  var _a;
@@ -22309,6 +22636,309 @@ function version22Migration(json) {
22309
22636
  });
22310
22637
  return json;
22311
22638
  }
22639
+ /**
22640
+ * 3.0 以下版本数据适配(runtime 2.0及以上版本支持)
22641
+ */
22642
+ function version30Migration(json) {
22643
+ var e_1, _a;
22644
+ var _b, _c, _d, _e;
22645
+ var result = Object.assign({}, json, {
22646
+ items: [],
22647
+ components: [],
22648
+ materials: [],
22649
+ shaders: [],
22650
+ geometries: [],
22651
+ });
22652
+ // 兼容老版本数据中不存在textures的情况
22653
+ (_b = result.textures) !== null && _b !== void 0 ? _b : (result.textures = []);
22654
+ result.textures.forEach(function (textureOptions) {
22655
+ Object.assign(textureOptions, {
22656
+ id: generateGUID(),
22657
+ dataType: DataType.Texture,
22658
+ });
22659
+ });
22660
+ if (result.textures.length < result.images.length) {
22661
+ for (var i = result.textures.length; i < result.images.length; i++) {
22662
+ result.textures.push({
22663
+ //@ts-expect-error
22664
+ id: generateGUID(),
22665
+ dataType: DataType.Texture,
22666
+ source: i,
22667
+ flipY: true,
22668
+ });
22669
+ }
22670
+ }
22671
+ var _loop_1 = function (composition) {
22672
+ var e_2, _h, e_3, _j;
22673
+ // composition 的 endbehaviour 兼容
22674
+ if (composition.endBehavior === END_BEHAVIOR_PAUSE_AND_DESTROY || composition.endBehavior === END_BEHAVIOR_PAUSE) {
22675
+ composition.endBehavior = END_BEHAVIOR_FREEZE;
22676
+ }
22677
+ var itemGuidMap = {};
22678
+ try {
22679
+ for (var _k = (e_2 = void 0, __values(composition.items)), _l = _k.next(); !_l.done; _l = _k.next()) {
22680
+ var item = _l.value;
22681
+ itemGuidMap[item.id] = generateGUID();
22682
+ // TODO: 编辑器测试用,上线后删除
22683
+ //@ts-expect-error
22684
+ item.oldId = item.id;
22685
+ item.id = itemGuidMap[item.id];
22686
+ }
22687
+ }
22688
+ catch (e_2_1) { e_2 = { error: e_2_1 }; }
22689
+ finally {
22690
+ try {
22691
+ if (_l && !_l.done && (_h = _k.return)) _h.call(_k);
22692
+ }
22693
+ finally { if (e_2) throw e_2.error; }
22694
+ }
22695
+ composition.items.forEach(function (item, index) {
22696
+ if (item.parentId) {
22697
+ if (item.parentId.includes('^')) {
22698
+ var parentId = (item.parentId).split('^')[0];
22699
+ var nodeId = (item.parentId).split('^')[1];
22700
+ item.parentId = itemGuidMap[parentId] + '^' + nodeId;
22701
+ }
22702
+ else {
22703
+ item.parentId = itemGuidMap[item.parentId];
22704
+ }
22705
+ }
22706
+ // @ts-expect-error fix item type
22707
+ result.items.push(item);
22708
+ // @ts-expect-error fix item type
22709
+ composition.items[index] = { id: item.id };
22710
+ });
22711
+ try {
22712
+ for (var _m = (e_3 = void 0, __values(result.items)), _o = _m.next(); !_o.done; _o = _m.next()) {
22713
+ var item = _o.value;
22714
+ // 原 texture 索引转为统一 guid 索引
22715
+ if (item.content) {
22716
+ if (item.content.renderer) {
22717
+ if (item.content.renderer.texture !== undefined) {
22718
+ var oldTextureId = item.content.renderer.texture;
22719
+ //@ts-expect-error
22720
+ item.content.renderer.texture = { id: result.textures[oldTextureId].id };
22721
+ }
22722
+ }
22723
+ if (item.content.trails) {
22724
+ if (item.content.trails.texture !== undefined) {
22725
+ var oldTextureId = item.content.trails.texture;
22726
+ //@ts-expect-error
22727
+ item.content.trails.texture = { id: result.textures[oldTextureId].id };
22728
+ }
22729
+ }
22730
+ }
22731
+ // item 的 transform 属性由数组转为 {x:n, y:n, z:n}
22732
+ if (item.transform) {
22733
+ //@ts-expect-error
22734
+ var position = __spreadArray([], __read((_c = item.transform.position) !== null && _c !== void 0 ? _c : [0, 0, 0]), false);
22735
+ //@ts-expect-error
22736
+ var rotation = __spreadArray([], __read((_d = item.transform.rotation) !== null && _d !== void 0 ? _d : [0, 0, 0]), false);
22737
+ //@ts-expect-error
22738
+ var scale = __spreadArray([], __read((_e = item.transform.scale) !== null && _e !== void 0 ? _e : [1, 1, 1]), false);
22739
+ Object.assign(item, {
22740
+ transform: {
22741
+ position: { x: position[0], y: position[1], z: position[2] },
22742
+ rotation: { x: rotation[0], y: rotation[1], z: rotation[2] },
22743
+ scale: { x: scale[0], y: scale[1], z: scale[0] },
22744
+ },
22745
+ });
22746
+ // sprite 的 scale 转为 size
22747
+ if (item.type === ItemType.sprite) {
22748
+ item.transform.size = { x: scale[0], y: scale[1] };
22749
+ item.transform.scale = { x: 1, y: 1, z: 1 };
22750
+ }
22751
+ // sprite 的 anchor 修正
22752
+ if (item.type === ItemType.sprite) {
22753
+ var content = item.content;
22754
+ if (!content.renderer) {
22755
+ content.renderer = {};
22756
+ }
22757
+ var renderer = content.renderer;
22758
+ var realAnchor = convertAnchor$1(renderer.anchor, renderer.particleOrigin);
22759
+ var startSize = item.transform.size;
22760
+ // 兼容旧JSON(anchor和particleOrigin可能同时存在)
22761
+ if (!renderer.anchor && renderer.particleOrigin !== undefined) {
22762
+ //@ts-expect-error
22763
+ item.transform.position.x += -realAnchor[0] * startSize.x;
22764
+ //@ts-expect-error
22765
+ item.transform.position.y += -realAnchor[1] * startSize.y;
22766
+ }
22767
+ //@ts-expect-error
22768
+ item.transform.anchor = { x: realAnchor[0] * startSize.x, y: realAnchor[1] * startSize.y };
22769
+ }
22770
+ }
22771
+ if (item.type === ItemType.particle) {
22772
+ var content = item.content;
22773
+ if (!content.renderer) {
22774
+ content.renderer = {};
22775
+ }
22776
+ var renderer = content.renderer;
22777
+ content.renderer.anchor = convertAnchor$1(renderer.anchor, renderer.particleOrigin);
22778
+ }
22779
+ // 动画数据转化 TODO: 动画数据移到 TimelineComponentData
22780
+ item.content.tracks = [];
22781
+ var tracks = item.content.tracks;
22782
+ if (item.type !== ItemType.particle) {
22783
+ tracks.push({
22784
+ clips: [
22785
+ {
22786
+ dataType: 'TransformAnimationPlayableAsset',
22787
+ animationClip: {
22788
+ sizeOverLifetime: item.content.sizeOverLifetime,
22789
+ rotationOverLifetime: item.content.rotationOverLifetime,
22790
+ positionOverLifetime: item.content.positionOverLifetime,
22791
+ },
22792
+ },
22793
+ ],
22794
+ });
22795
+ }
22796
+ if (item.type === ItemType.sprite) {
22797
+ tracks.push({
22798
+ clips: [
22799
+ {
22800
+ dataType: 'SpriteColorAnimationPlayableAsset',
22801
+ animationClip: {
22802
+ colorOverLifetime: item.content.colorOverLifetime,
22803
+ startColor: item.content.options.startColor,
22804
+ },
22805
+ },
22806
+ ],
22807
+ });
22808
+ }
22809
+ // gizmo 的 target id 转换为新的 item guid
22810
+ if (item.content.options.target) {
22811
+ item.content.options.target = itemGuidMap[item.content.options.target];
22812
+ }
22813
+ // item 的 content 转为 component data 加入 JSONScene.components
22814
+ var uuid = generateGUID();
22815
+ if (item.type === ItemType.sprite) {
22816
+ item.components = [];
22817
+ result.components.push(item.content);
22818
+ item.content.id = uuid;
22819
+ item.content.dataType = DataType.SpriteComponent;
22820
+ item.content.item = { id: item.id };
22821
+ item.dataType = DataType.VFXItemData;
22822
+ //@ts-expect-error
22823
+ item.components.push({ id: item.content.id });
22824
+ }
22825
+ else if (item.type === ItemType.particle) {
22826
+ item.components = [];
22827
+ result.components.push(item.content);
22828
+ item.content.id = uuid;
22829
+ item.content.dataType = DataType.ParticleSystem;
22830
+ item.content.item = { id: item.id };
22831
+ item.dataType = DataType.VFXItemData;
22832
+ //@ts-expect-error
22833
+ item.components.push({ id: item.content.id });
22834
+ }
22835
+ else if (item.type === ItemType.mesh) {
22836
+ item.components = [];
22837
+ result.components.push(item.content);
22838
+ item.content.id = uuid;
22839
+ item.content.dataType = DataType.MeshComponent;
22840
+ item.content.item = { id: item.id };
22841
+ item.dataType = DataType.VFXItemData;
22842
+ //@ts-expect-error
22843
+ item.components.push({ id: item.content.id });
22844
+ }
22845
+ else if (item.type === ItemType.skybox) {
22846
+ item.components = [];
22847
+ result.components.push(item.content);
22848
+ item.content.id = uuid;
22849
+ item.content.dataType = DataType.SkyboxComponent;
22850
+ item.content.item = { id: item.id };
22851
+ item.dataType = DataType.VFXItemData;
22852
+ //@ts-expect-error
22853
+ item.components.push({ id: item.content.id });
22854
+ }
22855
+ else if (item.type === ItemType.light) {
22856
+ item.components = [];
22857
+ result.components.push(item.content);
22858
+ item.content.id = uuid;
22859
+ item.content.dataType = DataType.LightComponent;
22860
+ item.content.item = { id: item.id };
22861
+ item.dataType = DataType.VFXItemData;
22862
+ //@ts-expect-error
22863
+ item.components.push({ id: item.content.id });
22864
+ }
22865
+ else if (item.type === 'camera') {
22866
+ item.components = [];
22867
+ result.components.push(item.content);
22868
+ item.content.id = uuid;
22869
+ item.content.dataType = DataType.CameraComponent;
22870
+ item.content.item = { id: item.id };
22871
+ item.dataType = DataType.VFXItemData;
22872
+ //@ts-expect-error
22873
+ item.components.push({ id: item.content.id });
22874
+ }
22875
+ else if (item.type === ItemType.tree) {
22876
+ item.components = [];
22877
+ result.components.push(item.content);
22878
+ item.content.id = uuid;
22879
+ item.content.dataType = DataType.TreeComponent;
22880
+ item.content.item = { id: item.id };
22881
+ item.dataType = DataType.VFXItemData;
22882
+ //@ts-expect-error
22883
+ item.components.push({ id: item.content.id });
22884
+ }
22885
+ else if (item.type === ItemType.interact) {
22886
+ item.components = [];
22887
+ result.components.push(item.content);
22888
+ item.content.id = uuid;
22889
+ item.content.dataType = DataType.InteractComponent;
22890
+ item.content.item = { id: item.id };
22891
+ item.dataType = DataType.VFXItemData;
22892
+ //@ts-expect-error
22893
+ item.components.push({ id: item.content.id });
22894
+ }
22895
+ else if (item.type === ItemType.camera) {
22896
+ item.components = [];
22897
+ result.components.push(item.content);
22898
+ item.content.id = uuid;
22899
+ item.content.dataType = DataType.CameraController;
22900
+ item.content.item = { id: item.id };
22901
+ item.dataType = DataType.VFXItemData;
22902
+ //@ts-expect-error
22903
+ item.components.push({ id: item.content.id });
22904
+ }
22905
+ else if (item.type === ItemType.text) {
22906
+ item.components = [];
22907
+ result.components.push(item.content);
22908
+ item.content.id = uuid;
22909
+ item.content.dataType = DataType.TextComponent;
22910
+ item.content.item = { id: item.id };
22911
+ item.dataType = DataType.VFXItemData;
22912
+ //@ts-expect-error
22913
+ item.components.push({ id: item.content.id });
22914
+ }
22915
+ }
22916
+ }
22917
+ catch (e_3_1) { e_3 = { error: e_3_1 }; }
22918
+ finally {
22919
+ try {
22920
+ if (_o && !_o.done && (_j = _m.return)) _j.call(_m);
22921
+ }
22922
+ finally { if (e_3) throw e_3.error; }
22923
+ }
22924
+ };
22925
+ try {
22926
+ // 更正Composition.endBehavior
22927
+ for (var _f = __values(json.compositions), _g = _f.next(); !_g.done; _g = _f.next()) {
22928
+ var composition = _g.value;
22929
+ _loop_1(composition);
22930
+ }
22931
+ }
22932
+ catch (e_1_1) { e_1 = { error: e_1_1 }; }
22933
+ finally {
22934
+ try {
22935
+ if (_g && !_g.done && (_a = _f.return)) _a.call(_f);
22936
+ }
22937
+ finally { if (e_1) throw e_1.error; }
22938
+ }
22939
+ result.version = '3.0';
22940
+ return result;
22941
+ }
22312
22942
 
22313
22943
  var v0 = /^(\d+)\.(\d+)\.(\d+)(-(\w+)\.\d+)?$/;
22314
22944
  var standardVersion = /^(\d+)\.(\d+)$/;
@@ -22318,16 +22948,16 @@ function getStandardJSON(json) {
22318
22948
  if (!json || typeof json !== 'object') {
22319
22949
  throw Error('expect a json object');
22320
22950
  }
22321
- // 修正老版本数据中,meshItem以及lightItem结束行为错误问题
22951
+ // 修正老版本数据中,meshItem 以及 lightItem 结束行为错误问题
22322
22952
  version22Migration(json);
22323
22953
  if (v0.test(json.version)) {
22324
22954
  reverseParticle = ((_a = (/^(\d+)/).exec(json.version)) === null || _a === void 0 ? void 0 : _a[0]) === '0';
22325
- return version21Migration(getStandardJSONFromV0(json));
22955
+ return version30Migration(version21Migration(getStandardJSONFromV0(json)));
22326
22956
  }
22327
22957
  var mainVersion = (_b = standardVersion.exec(json.version)) === null || _b === void 0 ? void 0 : _b[1];
22328
22958
  if (mainVersion) {
22329
- if (Number(mainVersion) < 2) {
22330
- return version21Migration(json);
22959
+ if (Number(mainVersion) < 3) {
22960
+ return version30Migration(version21Migration(json));
22331
22961
  }
22332
22962
  return json;
22333
22963
  }
@@ -22651,7 +23281,7 @@ function version3Migration(scene) {
22651
23281
  try {
22652
23282
  for (var _j = __values$1(ecScene.items), _k = _j.next(); !_k.done; _k = _j.next()) {
22653
23283
  var item = _k.value;
22654
- itemGuidMap[item.id] = generateGUID();
23284
+ itemGuidMap[item.id] = generateGUID$1();
22655
23285
  // TODO: 编辑器测试用,上线后删除
22656
23286
  //@ts-expect-error
22657
23287
  item.oldId = item.id;
@@ -22707,8 +23337,8 @@ function version3Migration(scene) {
22707
23337
  // texture 增加 id 和 dataType
22708
23338
  for (var _q = __values$1(scene.textureOptions), _r = _q.next(); !_r.done; _r = _q.next()) {
22709
23339
  var texture = _r.value;
22710
- texture.id = generateGUID();
22711
- texture.dataType = DataType.Texture;
23340
+ texture.id = generateGUID$1();
23341
+ texture.dataType = DataType$1.Texture;
22712
23342
  }
22713
23343
  }
22714
23344
  catch (e_5_1) { e_5 = { error: e_5_1 }; }
@@ -22727,23 +23357,15 @@ function version3Migration(scene) {
22727
23357
  var item = _t.value;
22728
23358
  // 原 texture 索引转为统一 guid 索引
22729
23359
  if (item.content) {
22730
- //@ts-expect-error
22731
23360
  if (item.content.renderer) {
22732
- //@ts-expect-error
22733
23361
  if (item.content.renderer.texture !== undefined) {
22734
- //@ts-expect-error
22735
23362
  var oldTextureId = item.content.renderer.texture;
22736
- //@ts-expect-error
22737
23363
  item.content.renderer.texture = { id: scene.textureOptions[oldTextureId].id };
22738
23364
  }
22739
23365
  }
22740
- //@ts-expect-error
22741
23366
  if (item.content.trails) {
22742
- //@ts-expect-error
22743
23367
  if (item.content.trails.texture !== undefined) {
22744
- //@ts-expect-error
22745
23368
  var oldTextureId = item.content.trails.texture;
22746
- //@ts-expect-error
22747
23369
  item.content.trails.texture = { id: scene.textureOptions[oldTextureId].id };
22748
23370
  }
22749
23371
  }
@@ -22754,12 +23376,14 @@ function version3Migration(scene) {
22754
23376
  var rotation = item.transform.rotation;
22755
23377
  var scale = item.transform.scale;
22756
23378
  if (!position) {
23379
+ //@ts-expect-error
22757
23380
  position = [0, 0, 0];
22758
23381
  }
22759
23382
  if (!rotation) {
22760
23383
  rotation = [0, 0, 0];
22761
23384
  }
22762
23385
  if (!scale) {
23386
+ //@ts-expect-error
22763
23387
  scale = [1, 1, 1];
22764
23388
  }
22765
23389
  item.transform = {
@@ -22780,12 +23404,9 @@ function version3Migration(scene) {
22780
23404
  // sprite 的 anchor 修正
22781
23405
  if (item.type === ItemType$1.sprite) {
22782
23406
  var content = item.content;
22783
- //@ts-expect-error
22784
23407
  if (!content.renderer) {
22785
- //@ts-expect-error
22786
23408
  content.renderer = {};
22787
23409
  }
22788
- //@ts-expect-error
22789
23410
  var renderer = content.renderer;
22790
23411
  var realAnchor = convertAnchor(renderer.anchor, renderer.particleOrigin);
22791
23412
  //@ts-expect-error
@@ -22803,14 +23424,10 @@ function version3Migration(scene) {
22803
23424
  }
22804
23425
  if (item.type === ItemType$1.particle) {
22805
23426
  var content = item.content;
22806
- //@ts-expect-error
22807
23427
  if (!content.renderer) {
22808
- //@ts-expect-error
22809
23428
  content.renderer = {};
22810
23429
  }
22811
- //@ts-expect-error
22812
23430
  var renderer = content.renderer;
22813
- //@ts-expect-error
22814
23431
  content.renderer.anchor = convertAnchor(renderer.anchor, renderer.particleOrigin);
22815
23432
  }
22816
23433
  // item 的 endbehaviour 兼容
@@ -22818,165 +23435,139 @@ function version3Migration(scene) {
22818
23435
  if (item.endBehavior === END_BEHAVIOR_PAUSE_AND_DESTROY$1 || item.endBehavior === END_BEHAVIOR_PAUSE$1) {
22819
23436
  item.endBehavior = END_BEHAVIOR_FREEZE$1;
22820
23437
  }
23438
+ // 动画数据转化 TODO: 动画数据移到 TimelineComponentData
23439
+ item.content.tracks = [];
23440
+ var tracks = item.content.tracks;
23441
+ if (item.type !== ItemType$1.particle) {
23442
+ tracks.push({
23443
+ clips: [
23444
+ {
23445
+ dataType: 'TransformAnimationPlayableAsset',
23446
+ animationClip: {
23447
+ sizeOverLifetime: item.content.sizeOverLifetime,
23448
+ rotationOverLifetime: item.content.rotationOverLifetime,
23449
+ positionOverLifetime: item.content.positionOverLifetime,
23450
+ },
23451
+ },
23452
+ ],
23453
+ });
23454
+ }
23455
+ if (item.type === ItemType$1.sprite) {
23456
+ tracks.push({
23457
+ clips: [
23458
+ {
23459
+ dataType: 'SpriteColorAnimationPlayableAsset',
23460
+ animationClip: {
23461
+ colorOverLifetime: item.content.colorOverLifetime,
23462
+ startColor: item.content.options.startColor,
23463
+ },
23464
+ },
23465
+ ],
23466
+ });
23467
+ }
23468
+ // gizmo 的 target id 转换为新的 item guid
23469
+ if (item.content && item.content.options && item.content.options.target) {
23470
+ item.content.options.target = itemGuidMap[item.content.options.target];
23471
+ }
22821
23472
  // item 的 content 转为 component data 加入 JSONScene.components
22822
- var uuid = v4().replace(/-/g, '');
23473
+ var uuid = v4$1().replace(/-/g, '');
22823
23474
  if (item.type === ItemType$1.sprite) {
22824
- //@ts-expect-error
22825
23475
  item.components = [];
22826
- //@ts-expect-error
22827
23476
  components.push(item.content);
22828
- //@ts-expect-error
22829
23477
  item.content.id = uuid;
22830
- //@ts-expect-error
22831
- item.content.dataType = DataType.SpriteComponent;
22832
- //@ts-expect-error
23478
+ item.content.dataType = DataType$1.SpriteComponent;
22833
23479
  item.content.item = { id: item.id };
22834
- //@ts-expect-error
22835
- item.dataType = DataType.VFXItemData;
23480
+ item.dataType = DataType$1.VFXItemData;
22836
23481
  //@ts-expect-error
22837
23482
  item.components.push({ id: item.content.id });
22838
23483
  }
22839
23484
  else if (item.type === ItemType$1.particle) {
22840
- //@ts-expect-error
22841
23485
  item.components = [];
22842
- //@ts-expect-error
22843
23486
  components.push(item.content);
22844
- //@ts-expect-error
22845
23487
  item.content.id = uuid;
22846
- //@ts-expect-error
22847
- item.content.dataType = DataType.ParticleSystem;
22848
- //@ts-expect-error
23488
+ item.content.dataType = DataType$1.ParticleSystem;
22849
23489
  item.content.item = { id: item.id };
22850
- //@ts-expect-error
22851
- item.dataType = DataType.VFXItemData;
23490
+ item.dataType = DataType$1.VFXItemData;
22852
23491
  //@ts-expect-error
22853
23492
  item.components.push({ id: item.content.id });
22854
23493
  }
22855
23494
  else if (item.type === ItemType$1.mesh) {
22856
- //@ts-expect-error
22857
23495
  item.components = [];
22858
- //@ts-expect-error
22859
23496
  components.push(item.content);
22860
- //@ts-expect-error
22861
23497
  item.content.id = uuid;
22862
- //@ts-expect-error
22863
- item.content.dataType = DataType.MeshComponent;
22864
- //@ts-expect-error
23498
+ item.content.dataType = DataType$1.MeshComponent;
22865
23499
  item.content.item = { id: item.id };
22866
- //@ts-expect-error
22867
- item.dataType = DataType.VFXItemData;
23500
+ item.dataType = DataType$1.VFXItemData;
22868
23501
  //@ts-expect-error
22869
23502
  item.components.push({ id: item.content.id });
22870
23503
  }
22871
23504
  else if (item.type === ItemType$1.skybox) {
22872
- //@ts-expect-error
22873
23505
  item.components = [];
22874
- //@ts-expect-error
22875
23506
  components.push(item.content);
22876
- //@ts-expect-error
22877
23507
  item.content.id = uuid;
22878
- //@ts-expect-error
22879
- item.content.dataType = DataType.SkyboxComponent;
22880
- //@ts-expect-error
23508
+ item.content.dataType = DataType$1.SkyboxComponent;
22881
23509
  item.content.item = { id: item.id };
22882
- //@ts-expect-error
22883
- item.dataType = DataType.VFXItemData;
23510
+ item.dataType = DataType$1.VFXItemData;
22884
23511
  //@ts-expect-error
22885
23512
  item.components.push({ id: item.content.id });
22886
23513
  }
22887
23514
  else if (item.type === ItemType$1.light) {
22888
- //@ts-expect-error
22889
23515
  item.components = [];
22890
- //@ts-expect-error
22891
23516
  components.push(item.content);
22892
- //@ts-expect-error
22893
23517
  item.content.id = uuid;
22894
- //@ts-expect-error
22895
- item.content.dataType = DataType.LightComponent;
22896
- //@ts-expect-error
23518
+ item.content.dataType = DataType$1.LightComponent;
22897
23519
  item.content.item = { id: item.id };
22898
- //@ts-expect-error
22899
- item.dataType = DataType.VFXItemData;
23520
+ item.dataType = DataType$1.VFXItemData;
22900
23521
  //@ts-expect-error
22901
23522
  item.components.push({ id: item.content.id });
22902
23523
  }
22903
23524
  else if (item.type === 'camera') {
22904
- //@ts-expect-error
22905
23525
  item.components = [];
22906
- //@ts-expect-error
22907
23526
  components.push(item.content);
22908
- //@ts-expect-error
22909
23527
  item.content.id = uuid;
22910
- //@ts-expect-error
22911
- item.content.dataType = DataType.CameraComponent;
22912
- //@ts-expect-error
23528
+ item.content.dataType = DataType$1.CameraComponent;
22913
23529
  item.content.item = { id: item.id };
22914
- //@ts-expect-error
22915
- item.dataType = DataType.VFXItemData;
23530
+ item.dataType = DataType$1.VFXItemData;
22916
23531
  //@ts-expect-error
22917
23532
  item.components.push({ id: item.content.id });
22918
23533
  }
22919
23534
  else if (item.type === ItemType$1.tree) {
22920
- //@ts-expect-error
22921
23535
  item.components = [];
22922
- //@ts-expect-error
22923
23536
  components.push(item.content);
22924
- //@ts-expect-error
22925
23537
  item.content.id = uuid;
22926
- //@ts-expect-error
22927
- item.content.dataType = DataType.TreeComponent;
22928
- //@ts-expect-error
23538
+ item.content.dataType = DataType$1.TreeComponent;
22929
23539
  item.content.item = { id: item.id };
22930
- //@ts-expect-error
22931
- item.dataType = DataType.VFXItemData;
23540
+ item.dataType = DataType$1.VFXItemData;
22932
23541
  //@ts-expect-error
22933
23542
  item.components.push({ id: item.content.id });
22934
23543
  }
22935
23544
  else if (item.type === ItemType$1.interact) {
22936
- //@ts-expect-error
22937
23545
  item.components = [];
22938
- //@ts-expect-error
22939
23546
  components.push(item.content);
22940
- //@ts-expect-error
22941
23547
  item.content.id = uuid;
22942
- //@ts-expect-error
22943
- item.content.dataType = DataType.InteractComponent;
22944
- //@ts-expect-error
23548
+ item.content.dataType = DataType$1.InteractComponent;
22945
23549
  item.content.item = { id: item.id };
22946
- //@ts-expect-error
22947
- item.dataType = DataType.VFXItemData;
23550
+ item.dataType = DataType$1.VFXItemData;
22948
23551
  //@ts-expect-error
22949
23552
  item.components.push({ id: item.content.id });
22950
23553
  }
22951
23554
  else if (item.type === ItemType$1.camera) {
22952
- //@ts-expect-error
22953
23555
  item.components = [];
22954
- //@ts-expect-error
22955
23556
  components.push(item.content);
22956
- //@ts-expect-error
22957
23557
  item.content.id = uuid;
22958
- //@ts-expect-error
22959
- item.content.dataType = DataType.CameraController;
22960
- //@ts-expect-error
23558
+ item.content.dataType = DataType$1.CameraController;
22961
23559
  item.content.item = { id: item.id };
22962
- //@ts-expect-error
22963
- item.dataType = DataType.VFXItemData;
23560
+ item.dataType = DataType$1.VFXItemData;
22964
23561
  //@ts-expect-error
22965
23562
  item.components.push({ id: item.content.id });
22966
23563
  }
22967
23564
  else if (item.type === ItemType$1.text) {
22968
- //@ts-expect-error
22969
23565
  item.components = [];
22970
- //@ts-expect-error
22971
23566
  components.push(item.content);
22972
- //@ts-expect-error
22973
23567
  item.content.id = uuid;
22974
- //@ts-expect-error
22975
- item.content.dataType = DataType.TextComponent;
22976
- //@ts-expect-error
23568
+ item.content.dataType = DataType$1.TextComponent;
22977
23569
  item.content.item = { id: item.id };
22978
- //@ts-expect-error
22979
- item.dataType = DataType.VFXItemData;
23570
+ item.dataType = DataType$1.VFXItemData;
22980
23571
  //@ts-expect-error
22981
23572
  item.components.push({ id: item.content.id });
22982
23573
  }
@@ -22999,7 +23590,7 @@ function convertAnchor(anchor, particleOrigin) {
22999
23590
  return [anchor[0] - 0.5, 0.5 - anchor[1]];
23000
23591
  }
23001
23592
  else if (particleOrigin) {
23002
- return particleOriginTranslateMap[particleOrigin];
23593
+ return particleOriginTranslateMap$1[particleOrigin];
23003
23594
  }
23004
23595
  else {
23005
23596
  return [0, 0];
@@ -23277,16 +23868,17 @@ var AssetManager = /** @class */ (function () {
23277
23868
  };
23278
23869
  AssetManager.prototype.processBins = function (bins) {
23279
23870
  return __awaiter(this, void 0, void 0, function () {
23280
- var renderLevel, jobs;
23871
+ var renderLevel, baseUrl, jobs;
23281
23872
  var _this = this;
23282
23873
  return __generator(this, function (_a) {
23283
23874
  renderLevel = this.options.renderLevel;
23875
+ baseUrl = this.baseUrl;
23284
23876
  jobs = bins.map(function (bin) {
23285
23877
  if (bin instanceof ArrayBuffer) {
23286
23878
  return bin;
23287
23879
  }
23288
23880
  if (passRenderLevel(bin.renderLevel, renderLevel)) {
23289
- return _this.loadBins(bin.url);
23881
+ return _this.loadBins(new URL(bin.url, baseUrl).href);
23290
23882
  }
23291
23883
  throw new Error("Invalid bins source: ".concat(JSON.stringify(bins)));
23292
23884
  });
@@ -23304,13 +23896,14 @@ var AssetManager = /** @class */ (function () {
23304
23896
  return [2 /*return*/];
23305
23897
  }
23306
23898
  jobs = fonts.map(function (font) { return __awaiter(_this, void 0, void 0, function () {
23307
- var fontFace;
23899
+ var url, fontFace;
23308
23900
  var _a;
23309
23901
  return __generator(this, function (_b) {
23310
23902
  switch (_b.label) {
23311
23903
  case 0:
23312
23904
  if (!(font.fontURL && !AssetManager.fonts.has(font.fontFamily))) return [3 /*break*/, 4];
23313
- fontFace = new FontFace((_a = font.fontFamily) !== null && _a !== void 0 ? _a : '', 'url(' + font.fontURL + ')');
23905
+ url = new URL(font.fontURL, this.baseUrl).href;
23906
+ fontFace = new FontFace((_a = font.fontFamily) !== null && _a !== void 0 ? _a : '', 'url(' + url + ')');
23314
23907
  _b.label = 1;
23315
23908
  case 1:
23316
23909
  _b.trys.push([1, 3, , 4]);
@@ -23323,7 +23916,7 @@ var AssetManager = /** @class */ (function () {
23323
23916
  return [3 /*break*/, 4];
23324
23917
  case 3:
23325
23918
  _b.sent();
23326
- logger.warn("Invalid fonts source: ".concat(JSON.stringify(font.fontURL)));
23919
+ logger.warn("Invalid fonts source: ".concat(JSON.stringify(url)));
23327
23920
  return [3 /*break*/, 4];
23328
23921
  case 4: return [2 /*return*/];
23329
23922
  }
@@ -23572,7 +24165,7 @@ function createTextureOptionsBySource(image, sourceFrom) {
23572
24165
  return image.source;
23573
24166
  }
23574
24167
  else if (image instanceof HTMLImageElement ||
23575
- image instanceof HTMLCanvasElement) {
24168
+ isCanvas(image)) {
23576
24169
  return {
23577
24170
  image: image,
23578
24171
  sourceType: TextureSourceType.image,
@@ -23634,6 +24227,11 @@ function base64ToFile(base64, filename, contentType) {
23634
24227
  var file = new File([blob], filename, { type: contentType });
23635
24228
  return file;
23636
24229
  }
24230
+ function isCanvas(cavnas) {
24231
+ var _a;
24232
+ // 小程序 Canvas 无法使用 instanceof HTMLCanvasElement 判断
24233
+ return typeof cavnas === 'object' && cavnas !== null && ((_a = cavnas.tagName) === null || _a === void 0 ? void 0 : _a.toUpperCase()) === 'CANVAS';
24234
+ }
23637
24235
 
23638
24236
  var tmpScale = new Vector3(1, 1, 1);
23639
24237
  /**
@@ -23853,8 +24451,9 @@ var Camera = /** @class */ (function () {
23853
24451
  Camera.prototype.getInverseVPRatio = function (z) {
23854
24452
  var pos = new Vector3(0, 0, z);
23855
24453
  var mat = this.getViewProjectionMatrix();
23856
- var nz = pos.applyMatrix(mat).z;
23857
- return new Vector3(1, 1, nz).applyMatrix(mat);
24454
+ var inverseVP = this.getInverseViewProjectionMatrix();
24455
+ var nz = mat.projectPoint(pos).z;
24456
+ return inverseVP.projectPoint(new Vector3(1, 1, nz));
23858
24457
  };
23859
24458
  /**
23860
24459
  * 设置相机的旋转四元数
@@ -23866,7 +24465,6 @@ var Camera = /** @class */ (function () {
23866
24465
  this.dirty = true;
23867
24466
  }
23868
24467
  else {
23869
- this.options.quat;
23870
24468
  if (!this.options.quat.equals(value)) {
23871
24469
  this.options.quat.copyFrom(value);
23872
24470
  this.dirty = true;
@@ -24034,8 +24632,7 @@ var CompositionComponent = /** @class */ (function (_super) {
24034
24632
  }
24035
24633
  item.getComponent(CompositionComponent).createContent();
24036
24634
  }
24037
- else if (itemData.type === 'ECS' ||
24038
- itemData.type === ItemType$1.sprite ||
24635
+ else if (itemData.type === ItemType$1.sprite ||
24039
24636
  itemData.type === ItemType$1.text ||
24040
24637
  itemData.type === ItemType$1.particle ||
24041
24638
  itemData.type === ItemType$1.mesh ||
@@ -24053,20 +24650,7 @@ var CompositionComponent = /** @class */ (function (_super) {
24053
24650
  item = new VFXItem(this.engine, itemData);
24054
24651
  item.composition = this.item.composition;
24055
24652
  // 兼容老的数据代码,json 更新后可移除
24056
- switch (itemData.type) {
24057
- case ItemType$1.text: {
24058
- // 添加文本组件
24059
- var textItem = new TextComponent(this.engine, itemData.content);
24060
- textItem.item = item;
24061
- item.components.push(textItem);
24062
- item.rendererComponents.push(textItem);
24063
- item._content = textItem;
24064
- break;
24065
- }
24066
- default: {
24067
- item = createVFXItem(itemData, this.item.composition);
24068
- }
24069
- }
24653
+ item = createVFXItem(itemData, this.item.composition);
24070
24654
  }
24071
24655
  item.parent = this.item;
24072
24656
  // 相机不跟随合成移动
@@ -25456,10 +26040,8 @@ var Engine = /** @class */ (function () {
25456
26040
  Engine.prototype.addPackageDatas = function (scene) {
25457
26041
  var e_1, _a, e_2, _b, e_3, _c, e_4, _d, e_5, _e, e_6, _f;
25458
26042
  var jsonScene = scene.jsonScene;
25459
- //@ts-expect-error
25460
26043
  if (jsonScene.items) {
25461
26044
  try {
25462
- //@ts-expect-error
25463
26045
  for (var _g = __values$1(jsonScene.items), _h = _g.next(); !_h.done; _h = _g.next()) {
25464
26046
  var vfxItemData = _h.value;
25465
26047
  this.addEffectsObjectData(vfxItemData);
@@ -25473,10 +26055,8 @@ var Engine = /** @class */ (function () {
25473
26055
  finally { if (e_1) throw e_1.error; }
25474
26056
  }
25475
26057
  }
25476
- //@ts-expect-error
25477
26058
  if (jsonScene.materials) {
25478
26059
  try {
25479
- //@ts-expect-error
25480
26060
  for (var _j = __values$1(jsonScene.materials), _k = _j.next(); !_k.done; _k = _j.next()) {
25481
26061
  var materialData = _k.value;
25482
26062
  this.addEffectsObjectData(materialData);
@@ -25490,10 +26070,8 @@ var Engine = /** @class */ (function () {
25490
26070
  finally { if (e_2) throw e_2.error; }
25491
26071
  }
25492
26072
  }
25493
- //@ts-expect-error
25494
26073
  if (jsonScene.shaders) {
25495
26074
  try {
25496
- //@ts-expect-error
25497
26075
  for (var _l = __values$1(jsonScene.shaders), _m = _l.next(); !_m.done; _m = _l.next()) {
25498
26076
  var shaderData = _m.value;
25499
26077
  this.addEffectsObjectData(shaderData);
@@ -25507,10 +26085,8 @@ var Engine = /** @class */ (function () {
25507
26085
  finally { if (e_3) throw e_3.error; }
25508
26086
  }
25509
26087
  }
25510
- //@ts-expect-error
25511
26088
  if (jsonScene.geometries) {
25512
26089
  try {
25513
- //@ts-expect-error
25514
26090
  for (var _o = __values$1(jsonScene.geometries), _p = _o.next(); !_p.done; _p = _o.next()) {
25515
26091
  var geometryData = _p.value;
25516
26092
  this.addEffectsObjectData(geometryData);
@@ -25524,10 +26100,8 @@ var Engine = /** @class */ (function () {
25524
26100
  finally { if (e_4) throw e_4.error; }
25525
26101
  }
25526
26102
  }
25527
- //@ts-expect-error
25528
26103
  if (jsonScene.components) {
25529
26104
  try {
25530
- //@ts-expect-error
25531
26105
  for (var _q = __values$1(jsonScene.components), _r = _q.next(); !_r.done; _r = _q.next()) {
25532
26106
  var componentData = _r.value;
25533
26107
  this.addEffectsObjectData(componentData);
@@ -25881,5 +26455,5 @@ registerPlugin('cal', CalculateLoader, VFXItem, true);
25881
26455
  registerPlugin('interact', InteractLoader, VFXItem, true);
25882
26456
  // registerFilters(filters);
25883
26457
 
25884
- export { AbstractPlugin, ActivationClipPlayable, AnimationClipPlayable, AssetLoader, AssetManager, BYTES_TYPE_MAP, Behaviour, BezierSegments, COMPRESSED_TEXTURE, COPY_FRAGMENT_SHADER, COPY_MESH_SHADER_ID, COPY_VERTEX_SHADER, CalculateLoader, Camera, CameraController, CameraVFXItemLoader, Component, Composition, CompositionComponent, CompositionSourceManager, CurveValue, DEFAULT_FONTS, DataType, Database, DestroyOptions, Downloader, EFFECTS_COPY_MESH_NAME, EVENT_TYPE_CLICK, EVENT_TYPE_TOUCH_END, EVENT_TYPE_TOUCH_MOVE, EVENT_TYPE_TOUCH_START, EffectComponent, EffectsObject, Engine, EventSystem, FILTER_NAME_NONE, FilterMode, Float16ArrayWrapper, FrameBuffer, GLSLVersion, GPUCapability, Geometry, GlobalUniforms, GradientValue, HELP_LINK, HitTestType, InteractBehavior$1 as InteractBehavior, InteractComponent, InteractLoader, InteractMesh, Item, ItemBehaviour, KTXTexture, LineSegments, LinearValue, Material, MaterialDataBlock, MaterialRenderType, Mesh, OrderType, PLAYER_OPTIONS_ENV_EDITOR, POST_PROCESS_SETTINGS, ParticleBehaviourPlayable, ParticleLoader, ParticleMesh, ParticleSystem, ParticleSystemRenderer, 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, RendererComponent, 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, SerializationHelper, Shader, ShaderCompileResultStatus, ShaderType, SpriteColorPlayable, SpriteComponent, SpriteLoader, StaticValue, TEMPLATE_USE_OFFSCREEN_CANVAS, TextComponent, TextLoader, Texture, TextureFactory, TextureLoadAction, TextureSourceType, TextureStoreAction, Ticker, TimelineClip, TimelineComponent, Track, Transform, VFXItem, ValueGetter, addByOrder, addItem, addItemWithOrder, alphaFrame_frag as alphaFrameFrag, alphaMask_frag as alphaMaskFrag, assertExist, asserts, blend, bloomMix_frag as bloomMixVert, bloomThreshold_frag as bloomThresholdVert, calculateTranslation, cameraMove_frag as cameraMoveFrag, cameraMove_vert as cameraMoveVert, canvasPool, colorGradingFrag, colorStopsFromGradient, colorToArr$1 as colorToArr, combineImageTemplate, combineImageTemplate1, combineImageTemplate1Async, combineImageTemplate2, combineImageTemplate2Async, combineImageTemplateAsync, compatible_frag as compatibleFrag, compatible_vert as compatibleVert, copy as copyFrag, createCopyShader, createGLContext, createKeyFrameMeta, createShaderWithMarcos, createShape, createVFXItem, createValueGetter, deepClone, defaultGlobalVolume, defaultPlugins, delay_frag as delayFrag, deserializeMipmapTexture, distortion_frag as distortionFrag, distortion_vert as distortionVert, earcut, effectsClass, effectsClassStore, enlargeBuffer, ensureVec3, findPreviousRenderPass, gaussianDown_frag as gaussianDownFrag, gaussianDownHFrag, gaussianDownVFrag, gaussianUpFrag, generateEmptyTypedArray, generateGUID, generateHalfFloatTexture, getBackgroundImage, getColorFromGradientStops, getConfig, getDefaultTemplateCanvasPool, getDefaultTextureFactory, getGeometryByShape, getGeometryTriangles, getImageItemRenderInfo, getKTXTextureOptions, getKeyFrameMetaByRawValue, getMergedStore, 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, loadVideo, loadWebPOptional, logger, index$1 as math, maxSpriteMeshItemCount, maxSpriteTextureCount, modifyMaxKeyframeShader, nearestPowerOfTwo, noop, parsePercent$1 as parsePercent, particleFrag, particleOriginTranslateMap, particleVert, pluginLoaderMap, random, registerPlugin, removeItem, requestAsync, rotateVec2, screenMeshVert, serialize, setBlendMode, setConfig, setDefaultTextureFactory, setMaskMode, setMaxSpriteMeshItemCount, setRayFromCamera, setSideMode, setSpriteMeshMaxFragmentTextures, setSpriteMeshMaxItemCountByGPU, sortByOrder, index as spec, spriteMeshShaderFromFilter, spriteMeshShaderFromRenderInfo, spriteMeshShaderIdFromRenderInfo, thresholdFrag, throwDestroyedError, trailVert, translatePoint, trianglesFromRect, unregisterPlugin, valIfUndefined, value, valueDefine, vecAssign, vecFill, vecMulCombine, vecNormalize };
26458
+ export { AbstractPlugin, ActivationPlayable, AssetLoader, AssetManager, BYTES_TYPE_MAP, Behaviour, BezierSegments, COMPRESSED_TEXTURE, COPY_FRAGMENT_SHADER, COPY_MESH_SHADER_ID, COPY_VERTEX_SHADER, CalculateLoader, Camera, CameraController, CameraVFXItemLoader, Component, Composition, CompositionComponent, CompositionSourceManager, CurveValue, DEFAULT_FONTS, DataType$1 as DataType, Database, DestroyOptions, Downloader, EFFECTS_COPY_MESH_NAME, EVENT_TYPE_CLICK, EVENT_TYPE_TOUCH_END, EVENT_TYPE_TOUCH_MOVE, EVENT_TYPE_TOUCH_START, EffectComponent, EffectsObject, Engine, EventSystem, FILTER_NAME_NONE, FilterMode, Float16ArrayWrapper, FrameBuffer, GLSLVersion, GPUCapability, Geometry, GlobalUniforms, GradientValue, HELP_LINK, HitTestType, InteractBehavior$1 as InteractBehavior, InteractComponent, InteractLoader, InteractMesh, Item, ItemBehaviour, KTXTexture, LineSegments, LinearValue, Material, MaterialDataBlock, MaterialRenderType, Mesh, OrderType, PLAYER_OPTIONS_ENV_EDITOR, POST_PROCESS_SETTINGS, ParticleBehaviourPlayable, ParticleLoader, ParticleMesh, ParticleSystem, ParticleSystemRenderer, 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, RendererComponent, 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, SerializationHelper, Shader, ShaderCompileResultStatus, ShaderType, ShaderVariant, SpriteColorPlayable, SpriteComponent, SpriteLoader, StaticValue, TEMPLATE_USE_OFFSCREEN_CANVAS, TextComponent, TextLoader, Texture, TextureFactory, TextureLoadAction, TextureSourceType, TextureStoreAction, Ticker, TimelineClip, TimelineComponent, Track, Transform, TransformAnimationPlayable, TransformAnimationPlayableAsset, VFXItem, ValueGetter, addByOrder, addItem, addItemWithOrder, alphaFrame_frag as alphaFrameFrag, alphaMask_frag as alphaMaskFrag, assertExist, asserts, blend, bloomMix_frag as bloomMixVert, bloomThreshold_frag as bloomThresholdVert, calculateTranslation, cameraMove_frag as cameraMoveFrag, cameraMove_vert as cameraMoveVert, canvasPool, colorGradingFrag, colorStopsFromGradient, colorToArr$1 as colorToArr, combineImageTemplate, combineImageTemplate1, combineImageTemplate1Async, combineImageTemplate2, combineImageTemplate2Async, combineImageTemplateAsync, compatible_frag as compatibleFrag, compatible_vert as compatibleVert, copy as copyFrag, createCopyShader, createGLContext, createKeyFrameMeta, createShaderWithMarcos, createShape, createVFXItem, createValueGetter, deepClone, defaultGlobalVolume, defaultPlugins, delay_frag as delayFrag, deserializeMipmapTexture, distortion_frag as distortionFrag, distortion_vert as distortionVert, earcut, effectsClass, effectsClassStore, enlargeBuffer, ensureVec3, findPreviousRenderPass, gaussianDown_frag as gaussianDownFrag, gaussianDownHFrag, gaussianDownVFrag, gaussianUpFrag, generateEmptyTypedArray, generateGUID$1 as generateGUID, generateHalfFloatTexture, getBackgroundImage, getColorFromGradientStops, getConfig, getDefaultTemplateCanvasPool, getDefaultTextureFactory, getGeometryByShape, getGeometryTriangles, getImageItemRenderInfo, getKTXTextureOptions, getKeyFrameMetaByRawValue, getMergedStore, 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, loadVideo, loadWebPOptional, logger, index$1 as math, maxSpriteMeshItemCount, maxSpriteTextureCount, modifyMaxKeyframeShader, nearestPowerOfTwo, noop, parsePercent$1 as parsePercent, particleFrag, particleOriginTranslateMap$1 as particleOriginTranslateMap, particleVert, pluginLoaderMap, random, registerPlugin, removeItem, requestAsync, rotateVec2, screenMeshVert, serialize, setBlendMode, setConfig, setDefaultTextureFactory, setMaskMode, setMaxSpriteMeshItemCount, setRayFromCamera, setSideMode, setSpriteMeshMaxFragmentTextures, setSpriteMeshMaxItemCountByGPU, sortByOrder, index as spec, spriteMeshShaderFromFilter, spriteMeshShaderFromRenderInfo, spriteMeshShaderIdFromRenderInfo, thresholdFrag, throwDestroyedError, trailVert, translatePoint, trianglesFromRect, unregisterPlugin, valIfUndefined, value, valueDefine, vecAssign, vecFill, vecMulCombine, vecNormalize };
25885
26459
  //# sourceMappingURL=index.mjs.map