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