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