@galacean/effects 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/index.js +822 -328
- package/dist/index.js.map +1 -1
- package/dist/index.min.js +6 -6
- package/dist/index.min.js.map +1 -1
- package/dist/index.mjs +859 -366
- package/dist/index.mjs.map +1 -1
- package/dist/player.d.ts +1 -1
- package/dist/weapp.js +821 -327
- package/dist/weapp.js.map +1 -1
- package/dist/weapp.mjs +858 -365
- package/dist/weapp.mjs.map +1 -1
- package/package.json +3 -3
package/dist/weapp.js
CHANGED
|
@@ -120,7 +120,7 @@ function __read$3(o, n) {
|
|
|
120
120
|
return ar;
|
|
121
121
|
}
|
|
122
122
|
|
|
123
|
-
function __spreadArray$
|
|
123
|
+
function __spreadArray$3(to, from, pack) {
|
|
124
124
|
if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {
|
|
125
125
|
if (ar || !(i in from)) {
|
|
126
126
|
if (!ar) ar = Array.prototype.slice.call(from, 0, i);
|
|
@@ -138,20 +138,20 @@ typeof SuppressedError === "function" ? SuppressedError : function (error, suppr
|
|
|
138
138
|
// Unique ID creation requires a high quality random # generator. In the browser we therefore
|
|
139
139
|
// require the crypto API and do not support built-in fallback to lower quality random number
|
|
140
140
|
// generators (like Math.random()).
|
|
141
|
-
let getRandomValues;
|
|
142
|
-
const rnds8 = new Uint8Array(16);
|
|
143
|
-
function rng() {
|
|
141
|
+
let getRandomValues$1;
|
|
142
|
+
const rnds8$1 = new Uint8Array(16);
|
|
143
|
+
function rng$1() {
|
|
144
144
|
// lazy load so that environments that need to polyfill have a chance to do so
|
|
145
|
-
if (!getRandomValues) {
|
|
145
|
+
if (!getRandomValues$1) {
|
|
146
146
|
// getRandomValues needs to be invoked in a context where "this" is a Crypto implementation.
|
|
147
|
-
getRandomValues = typeof crypto !== 'undefined' && crypto.getRandomValues && crypto.getRandomValues.bind(crypto);
|
|
147
|
+
getRandomValues$1 = typeof crypto !== 'undefined' && crypto.getRandomValues && crypto.getRandomValues.bind(crypto);
|
|
148
148
|
|
|
149
|
-
if (!getRandomValues) {
|
|
149
|
+
if (!getRandomValues$1) {
|
|
150
150
|
throw new Error('crypto.getRandomValues() not supported. See https://github.com/uuidjs/uuid#getrandomvalues-not-supported');
|
|
151
151
|
}
|
|
152
152
|
}
|
|
153
153
|
|
|
154
|
-
return getRandomValues(rnds8);
|
|
154
|
+
return getRandomValues$1(rnds8$1);
|
|
155
155
|
}
|
|
156
156
|
|
|
157
157
|
/**
|
|
@@ -159,30 +159,30 @@ function rng() {
|
|
|
159
159
|
* XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX
|
|
160
160
|
*/
|
|
161
161
|
|
|
162
|
-
const byteToHex = [];
|
|
162
|
+
const byteToHex$2 = [];
|
|
163
163
|
|
|
164
164
|
for (let i = 0; i < 256; ++i) {
|
|
165
|
-
byteToHex.push((i + 0x100).toString(16).slice(1));
|
|
165
|
+
byteToHex$2.push((i + 0x100).toString(16).slice(1));
|
|
166
166
|
}
|
|
167
167
|
|
|
168
|
-
function unsafeStringify(arr, offset = 0) {
|
|
168
|
+
function unsafeStringify$1(arr, offset = 0) {
|
|
169
169
|
// Note: Be careful editing this code! It's been tuned for performance
|
|
170
170
|
// and works in ways you may not expect. See https://github.com/uuidjs/uuid/pull/434
|
|
171
|
-
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]];
|
|
171
|
+
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]];
|
|
172
172
|
}
|
|
173
173
|
|
|
174
|
-
const randomUUID = typeof crypto !== 'undefined' && crypto.randomUUID && crypto.randomUUID.bind(crypto);
|
|
175
|
-
var native = {
|
|
176
|
-
randomUUID
|
|
174
|
+
const randomUUID$1 = typeof crypto !== 'undefined' && crypto.randomUUID && crypto.randomUUID.bind(crypto);
|
|
175
|
+
var native$1 = {
|
|
176
|
+
randomUUID: randomUUID$1
|
|
177
177
|
};
|
|
178
178
|
|
|
179
|
-
function v4(options, buf, offset) {
|
|
180
|
-
if (native.randomUUID && !buf && !options) {
|
|
181
|
-
return native.randomUUID();
|
|
179
|
+
function v4$1(options, buf, offset) {
|
|
180
|
+
if (native$1.randomUUID && !buf && !options) {
|
|
181
|
+
return native$1.randomUUID();
|
|
182
182
|
}
|
|
183
183
|
|
|
184
184
|
options = options || {};
|
|
185
|
-
const rnds = options.random || (options.rng || rng)(); // Per 4.4, set bits for version and `clock_seq_hi_and_reserved`
|
|
185
|
+
const rnds = options.random || (options.rng || rng$1)(); // Per 4.4, set bits for version and `clock_seq_hi_and_reserved`
|
|
186
186
|
|
|
187
187
|
rnds[6] = rnds[6] & 0x0f | 0x40;
|
|
188
188
|
rnds[8] = rnds[8] & 0x3f | 0x80; // Copy bytes to buffer, if provided
|
|
@@ -197,7 +197,7 @@ function v4(options, buf, offset) {
|
|
|
197
197
|
return buf;
|
|
198
198
|
}
|
|
199
199
|
|
|
200
|
-
return unsafeStringify(rnds);
|
|
200
|
+
return unsafeStringify$1(rnds);
|
|
201
201
|
}
|
|
202
202
|
|
|
203
203
|
function addItem(arr, value) {
|
|
@@ -2184,7 +2184,7 @@ var __read$2 = (undefined && undefined.__read) || function (o, n) {
|
|
|
2184
2184
|
}
|
|
2185
2185
|
return ar;
|
|
2186
2186
|
};
|
|
2187
|
-
var __spreadArray$
|
|
2187
|
+
var __spreadArray$2 = (undefined && undefined.__spreadArray) || function (to, from, pack) {
|
|
2188
2188
|
if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {
|
|
2189
2189
|
if (ar || !(i in from)) {
|
|
2190
2190
|
if (!ar) ar = Array.prototype.slice.call(from, 0, i);
|
|
@@ -2501,7 +2501,7 @@ var Matrix4$1 = /** @class */ (function () {
|
|
|
2501
2501
|
* @returns 复制结果
|
|
2502
2502
|
*/
|
|
2503
2503
|
Matrix4.prototype.copyFrom = function (m) {
|
|
2504
|
-
this.elements = __spreadArray$
|
|
2504
|
+
this.elements = __spreadArray$2([], __read$2(m.elements), false);
|
|
2505
2505
|
return this;
|
|
2506
2506
|
};
|
|
2507
2507
|
/**
|
|
@@ -3030,7 +3030,7 @@ var Matrix4$1 = /** @class */ (function () {
|
|
|
3030
3030
|
* @returns
|
|
3031
3031
|
*/
|
|
3032
3032
|
Matrix4.prototype.toArray = function () {
|
|
3033
|
-
return __spreadArray$
|
|
3033
|
+
return __spreadArray$2([], __read$2(this.elements), false);
|
|
3034
3034
|
};
|
|
3035
3035
|
Matrix4.prototype.fill = function (array, offset) {
|
|
3036
3036
|
if (offset === void 0) { offset = 0; }
|
|
@@ -4283,7 +4283,7 @@ var __read$1 = (undefined && undefined.__read) || function (o, n) {
|
|
|
4283
4283
|
}
|
|
4284
4284
|
return ar;
|
|
4285
4285
|
};
|
|
4286
|
-
var __spreadArray = (undefined && undefined.__spreadArray) || function (to, from, pack) {
|
|
4286
|
+
var __spreadArray$1 = (undefined && undefined.__spreadArray) || function (to, from, pack) {
|
|
4287
4287
|
if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {
|
|
4288
4288
|
if (ar || !(i in from)) {
|
|
4289
4289
|
if (!ar) ar = Array.prototype.slice.call(from, 0, i);
|
|
@@ -4470,7 +4470,7 @@ var Matrix3 = /** @class */ (function () {
|
|
|
4470
4470
|
* @returns 复制结果
|
|
4471
4471
|
*/
|
|
4472
4472
|
Matrix3.prototype.copyFrom = function (m) {
|
|
4473
|
-
this.elements = __spreadArray([], __read$1(m.elements), false);
|
|
4473
|
+
this.elements = __spreadArray$1([], __read$1(m.elements), false);
|
|
4474
4474
|
return this;
|
|
4475
4475
|
};
|
|
4476
4476
|
/**
|
|
@@ -4686,7 +4686,7 @@ var Matrix3 = /** @class */ (function () {
|
|
|
4686
4686
|
* @returns
|
|
4687
4687
|
*/
|
|
4688
4688
|
Matrix3.prototype.toArray = function () {
|
|
4689
|
-
return __spreadArray([], __read$1(this.elements), false);
|
|
4689
|
+
return __spreadArray$1([], __read$1(this.elements), false);
|
|
4690
4690
|
};
|
|
4691
4691
|
Matrix3.prototype.fill = function (array, offset) {
|
|
4692
4692
|
if (offset === void 0) { offset = 0; }
|
|
@@ -6444,7 +6444,7 @@ function error(message) {
|
|
|
6444
6444
|
for (var _i = 1; _i < arguments.length; _i++) {
|
|
6445
6445
|
args[_i - 1] = arguments[_i];
|
|
6446
6446
|
}
|
|
6447
|
-
console.error.apply(console, __spreadArray$
|
|
6447
|
+
console.error.apply(console, __spreadArray$3(__spreadArray$3([], __read$3(format(message)), false), [args], false));
|
|
6448
6448
|
localLogger === null || localLogger === void 0 ? void 0 : localLogger('error', message, args);
|
|
6449
6449
|
}
|
|
6450
6450
|
/**
|
|
@@ -6457,7 +6457,7 @@ function info(message) {
|
|
|
6457
6457
|
for (var _i = 1; _i < arguments.length; _i++) {
|
|
6458
6458
|
args[_i - 1] = arguments[_i];
|
|
6459
6459
|
}
|
|
6460
|
-
console.debug.apply(console, __spreadArray$
|
|
6460
|
+
console.debug.apply(console, __spreadArray$3([], __read$3(format(message)), false));
|
|
6461
6461
|
localLogger === null || localLogger === void 0 ? void 0 : localLogger('info', message, args);
|
|
6462
6462
|
}
|
|
6463
6463
|
function warn(message) {
|
|
@@ -6465,7 +6465,7 @@ function warn(message) {
|
|
|
6465
6465
|
for (var _i = 1; _i < arguments.length; _i++) {
|
|
6466
6466
|
args[_i - 1] = arguments[_i];
|
|
6467
6467
|
}
|
|
6468
|
-
console.warn.apply(console, __spreadArray$
|
|
6468
|
+
console.warn.apply(console, __spreadArray$3([], __read$3(format(message)), false));
|
|
6469
6469
|
localLogger === null || localLogger === void 0 ? void 0 : localLogger('warn', message, args);
|
|
6470
6470
|
}
|
|
6471
6471
|
/**
|
|
@@ -6562,17 +6562,30 @@ function random(min, max) {
|
|
|
6562
6562
|
function throwDestroyedError$1() {
|
|
6563
6563
|
throw Error('destroyed item cannot be used again');
|
|
6564
6564
|
}
|
|
6565
|
-
function generateGUID() {
|
|
6566
|
-
return v4().replace(/-/g, '');
|
|
6565
|
+
function generateGUID$1() {
|
|
6566
|
+
return v4$1().replace(/-/g, '');
|
|
6567
6567
|
}
|
|
6568
6568
|
|
|
6569
6569
|
/*!
|
|
6570
6570
|
* Name: @galacean/effects-specification
|
|
6571
6571
|
* Description: Galacean Effects JSON Specification
|
|
6572
6572
|
* Author: Ant Group CO., Ltd.
|
|
6573
|
-
* Version:
|
|
6573
|
+
* Version: v2.0.0-alpha.2
|
|
6574
6574
|
*/
|
|
6575
6575
|
|
|
6576
|
+
typeof crypto !== 'undefined' && crypto.randomUUID && crypto.randomUUID.bind(crypto);
|
|
6577
|
+
|
|
6578
|
+
/**
|
|
6579
|
+
* Convert array of 16 byte values to UUID string format of the form:
|
|
6580
|
+
* XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX
|
|
6581
|
+
*/
|
|
6582
|
+
|
|
6583
|
+
const byteToHex$1 = [];
|
|
6584
|
+
|
|
6585
|
+
for (let i = 0; i < 256; ++i) {
|
|
6586
|
+
byteToHex$1.push((i + 0x100).toString(16).slice(1));
|
|
6587
|
+
}
|
|
6588
|
+
|
|
6576
6589
|
/*********************************************/
|
|
6577
6590
|
/* 元素属性参数类型 */
|
|
6578
6591
|
/*********************************************/
|
|
@@ -6835,6 +6848,10 @@ var ItemType$1;
|
|
|
6835
6848
|
* 天空盒元素
|
|
6836
6849
|
*/
|
|
6837
6850
|
ItemType["skybox"] = "skybox";
|
|
6851
|
+
/**
|
|
6852
|
+
* 特效元素
|
|
6853
|
+
*/
|
|
6854
|
+
ItemType["effect"] = "effect";
|
|
6838
6855
|
})(ItemType$1 || (ItemType$1 = {}));
|
|
6839
6856
|
/**
|
|
6840
6857
|
* 渲染模式
|
|
@@ -6949,6 +6966,10 @@ var CompositionEndBehavior$1;
|
|
|
6949
6966
|
* 销毁并保留最后一帧
|
|
6950
6967
|
*/
|
|
6951
6968
|
CompositionEndBehavior[CompositionEndBehavior["pause_destroy"] = END_BEHAVIOR_PAUSE_AND_DESTROY$1] = "pause_destroy";
|
|
6969
|
+
/**
|
|
6970
|
+
* 冻结
|
|
6971
|
+
*/
|
|
6972
|
+
CompositionEndBehavior[CompositionEndBehavior["freeze"] = END_BEHAVIOR_FREEZE$1] = "freeze";
|
|
6952
6973
|
})(CompositionEndBehavior$1 || (CompositionEndBehavior$1 = {}));
|
|
6953
6974
|
|
|
6954
6975
|
/*********************************************/
|
|
@@ -7087,12 +7108,38 @@ var ShapeArcMode$1;
|
|
|
7087
7108
|
|
|
7088
7109
|
var BloomFilterThresholdAvgColor = 0;
|
|
7089
7110
|
|
|
7111
|
+
var LightType$1;
|
|
7112
|
+
(function (LightType) {
|
|
7113
|
+
/**
|
|
7114
|
+
* 点光源
|
|
7115
|
+
*/
|
|
7116
|
+
LightType["point"] = "point";
|
|
7117
|
+
/**
|
|
7118
|
+
* 聚光灯
|
|
7119
|
+
*/
|
|
7120
|
+
LightType["spot"] = "spot";
|
|
7121
|
+
/**
|
|
7122
|
+
* 方向光
|
|
7123
|
+
*/
|
|
7124
|
+
LightType["directional"] = "directional";
|
|
7125
|
+
/**
|
|
7126
|
+
* 环境光
|
|
7127
|
+
*/
|
|
7128
|
+
LightType["ambient"] = "ambient";
|
|
7129
|
+
})(LightType$1 || (LightType$1 = {}));
|
|
7130
|
+
|
|
7090
7131
|
var ModelBoundingType$1;
|
|
7091
7132
|
(function (ModelBoundingType) {
|
|
7092
7133
|
ModelBoundingType[ModelBoundingType["box"] = 2] = "box";
|
|
7093
7134
|
ModelBoundingType[ModelBoundingType["sphere"] = 3] = "sphere";
|
|
7094
7135
|
})(ModelBoundingType$1 || (ModelBoundingType$1 = {}));
|
|
7095
7136
|
|
|
7137
|
+
var CameraType$1;
|
|
7138
|
+
(function (CameraType) {
|
|
7139
|
+
CameraType["orthographic"] = "orthographic";
|
|
7140
|
+
CameraType["perspective"] = "perspective";
|
|
7141
|
+
})(CameraType$1 || (CameraType$1 = {}));
|
|
7142
|
+
|
|
7096
7143
|
// 材质类型
|
|
7097
7144
|
var MaterialType$1;
|
|
7098
7145
|
(function (MaterialType) {
|
|
@@ -7238,6 +7285,28 @@ var FontStyle$1;
|
|
|
7238
7285
|
FontStyle["oblique"] = "oblique";
|
|
7239
7286
|
})(FontStyle$1 || (FontStyle$1 = {}));
|
|
7240
7287
|
|
|
7288
|
+
var DataType$1;
|
|
7289
|
+
(function (DataType) {
|
|
7290
|
+
DataType["VFXItemData"] = "VFXItemData";
|
|
7291
|
+
DataType["EffectComponent"] = "EffectComponent";
|
|
7292
|
+
DataType["Material"] = "Material";
|
|
7293
|
+
DataType["Shader"] = "Shader";
|
|
7294
|
+
DataType["SpriteComponent"] = "SpriteComponent";
|
|
7295
|
+
DataType["ParticleSystem"] = "ParticleSystem";
|
|
7296
|
+
DataType["InteractComponent"] = "InteractComponent";
|
|
7297
|
+
DataType["CameraController"] = "CameraController";
|
|
7298
|
+
DataType["Geometry"] = "Geometry";
|
|
7299
|
+
DataType["Texture"] = "Texture";
|
|
7300
|
+
DataType["TextComponent"] = "TextComponent";
|
|
7301
|
+
// FIXME: 先完成ECS的场景转换,后面移到spec中
|
|
7302
|
+
DataType["MeshComponent"] = "MeshComponent";
|
|
7303
|
+
DataType["SkyboxComponent"] = "SkyboxComponent";
|
|
7304
|
+
DataType["LightComponent"] = "LightComponent";
|
|
7305
|
+
DataType["CameraComponent"] = "CameraComponent";
|
|
7306
|
+
DataType["ModelPluginComponent"] = "ModelPluginComponent";
|
|
7307
|
+
DataType["TreeComponent"] = "TreeComponent";
|
|
7308
|
+
})(DataType$1 || (DataType$1 = {}));
|
|
7309
|
+
|
|
7241
7310
|
var index = /*#__PURE__*/Object.freeze({
|
|
7242
7311
|
__proto__: null,
|
|
7243
7312
|
get BezierKeyframeType () { return BezierKeyframeType$1; },
|
|
@@ -7246,7 +7315,9 @@ var index = /*#__PURE__*/Object.freeze({
|
|
|
7246
7315
|
CAMERA_CLIP_MODE_NORMAL: CAMERA_CLIP_MODE_NORMAL$1,
|
|
7247
7316
|
CAMERA_CLIP_MODE_VERTICAL: CAMERA_CLIP_MODE_VERTICAL$1,
|
|
7248
7317
|
get CameraClipMode () { return CameraClipMode$1; },
|
|
7318
|
+
get CameraType () { return CameraType$1; },
|
|
7249
7319
|
get CompositionEndBehavior () { return CompositionEndBehavior$1; },
|
|
7320
|
+
get DataType () { return DataType$1; },
|
|
7250
7321
|
END_BEHAVIOR_DESTROY: END_BEHAVIOR_DESTROY$1,
|
|
7251
7322
|
END_BEHAVIOR_DESTROY_CHILDREN: END_BEHAVIOR_DESTROY_CHILDREN$1,
|
|
7252
7323
|
END_BEHAVIOR_FORWARD: END_BEHAVIOR_FORWARD$1,
|
|
@@ -7259,6 +7330,7 @@ var index = /*#__PURE__*/Object.freeze({
|
|
|
7259
7330
|
get InteractType () { return InteractType$1; },
|
|
7260
7331
|
get ItemEndBehavior () { return ItemEndBehavior$1; },
|
|
7261
7332
|
get ItemType () { return ItemType$1; },
|
|
7333
|
+
get LightType () { return LightType$1; },
|
|
7262
7334
|
MESSAGE_ITEM_PHRASE_BEGIN: MESSAGE_ITEM_PHRASE_BEGIN,
|
|
7263
7335
|
MESSAGE_ITEM_PHRASE_END: MESSAGE_ITEM_PHRASE_END,
|
|
7264
7336
|
get MaskMode () { return MaskMode$1; },
|
|
@@ -7450,7 +7522,7 @@ function copy$1(target) {
|
|
|
7450
7522
|
}
|
|
7451
7523
|
}
|
|
7452
7524
|
|
|
7453
|
-
var _a$
|
|
7525
|
+
var _a$a;
|
|
7454
7526
|
function valIfUndefined(val, def) {
|
|
7455
7527
|
if (val === undefined || val === null) {
|
|
7456
7528
|
return def;
|
|
@@ -7480,15 +7552,15 @@ function getPreMultiAlpha(blending) {
|
|
|
7480
7552
|
return 1;
|
|
7481
7553
|
}
|
|
7482
7554
|
}
|
|
7483
|
-
var downgradeKeywords = (_a$
|
|
7484
|
-
_a$
|
|
7555
|
+
var downgradeKeywords = (_a$a = {},
|
|
7556
|
+
_a$a[exports.ShaderType.vertex] = {
|
|
7485
7557
|
in: 'attribute',
|
|
7486
7558
|
out: 'varying',
|
|
7487
7559
|
},
|
|
7488
|
-
_a$
|
|
7560
|
+
_a$a[exports.ShaderType.fragment] = {
|
|
7489
7561
|
in: 'varying',
|
|
7490
7562
|
},
|
|
7491
|
-
_a$
|
|
7563
|
+
_a$a);
|
|
7492
7564
|
/**
|
|
7493
7565
|
* 生成 shader,检测到 WebGL1 上下文会降级
|
|
7494
7566
|
* @param marcos - 宏定义数组
|
|
@@ -7929,7 +8001,7 @@ function loadMipmapImage(pointer, bins) {
|
|
|
7929
8001
|
var EffectsObject = /** @class */ (function () {
|
|
7930
8002
|
function EffectsObject(engine) {
|
|
7931
8003
|
this.engine = engine;
|
|
7932
|
-
this.guid = generateGUID();
|
|
8004
|
+
this.guid = generateGUID$1();
|
|
7933
8005
|
this.taggedProperties = {};
|
|
7934
8006
|
this.engine.addInstance(this);
|
|
7935
8007
|
}
|
|
@@ -8626,13 +8698,49 @@ exports.GLSLVersion = void 0;
|
|
|
8626
8698
|
GLSLVersion["GLSL1"] = "100";
|
|
8627
8699
|
GLSLVersion["GLSL3"] = "300 es";
|
|
8628
8700
|
})(exports.GLSLVersion || (exports.GLSLVersion = {}));
|
|
8629
|
-
var
|
|
8630
|
-
__extends(
|
|
8631
|
-
function
|
|
8701
|
+
var ShaderVariant = /** @class */ (function (_super) {
|
|
8702
|
+
__extends(ShaderVariant, _super);
|
|
8703
|
+
function ShaderVariant(engine, source) {
|
|
8632
8704
|
var _this = _super.call(this, engine) || this;
|
|
8633
8705
|
_this.source = source;
|
|
8634
8706
|
return _this;
|
|
8635
8707
|
}
|
|
8708
|
+
return ShaderVariant;
|
|
8709
|
+
}(EffectsObject));
|
|
8710
|
+
var Shader = /** @class */ (function (_super) {
|
|
8711
|
+
__extends(Shader, _super);
|
|
8712
|
+
function Shader() {
|
|
8713
|
+
return _super !== null && _super.apply(this, arguments) || this;
|
|
8714
|
+
}
|
|
8715
|
+
Shader.prototype.createVariant = function (macros) {
|
|
8716
|
+
var e_1, _a;
|
|
8717
|
+
var shaderMacros = [];
|
|
8718
|
+
if (macros) {
|
|
8719
|
+
try {
|
|
8720
|
+
for (var _b = __values$1(Object.keys(macros)), _c = _b.next(); !_c.done; _c = _b.next()) {
|
|
8721
|
+
var key = _c.value;
|
|
8722
|
+
shaderMacros.push([key, macros[key]]);
|
|
8723
|
+
}
|
|
8724
|
+
}
|
|
8725
|
+
catch (e_1_1) { e_1 = { error: e_1_1 }; }
|
|
8726
|
+
finally {
|
|
8727
|
+
try {
|
|
8728
|
+
if (_c && !_c.done && (_a = _b.return)) _a.call(_b);
|
|
8729
|
+
}
|
|
8730
|
+
finally { if (e_1) throw e_1.error; }
|
|
8731
|
+
}
|
|
8732
|
+
}
|
|
8733
|
+
var shaderVariant = this.engine.getShaderLibrary().createShader(this.shaderData, shaderMacros);
|
|
8734
|
+
shaderVariant.shader = this;
|
|
8735
|
+
return shaderVariant;
|
|
8736
|
+
};
|
|
8737
|
+
Shader.prototype.fromData = function (data) {
|
|
8738
|
+
_super.prototype.fromData.call(this, data);
|
|
8739
|
+
this.shaderData = data;
|
|
8740
|
+
};
|
|
8741
|
+
Shader = __decorate([
|
|
8742
|
+
effectsClass('Shader')
|
|
8743
|
+
], Shader);
|
|
8636
8744
|
return Shader;
|
|
8637
8745
|
}(EffectsObject));
|
|
8638
8746
|
|
|
@@ -8645,8 +8753,8 @@ function createCopyShader(level, writeDepth) {
|
|
|
8645
8753
|
var version = webgl2 ? '#version 300 es' : '';
|
|
8646
8754
|
return {
|
|
8647
8755
|
name: EFFECTS_COPY_MESH_NAME,
|
|
8648
|
-
vertex:
|
|
8649
|
-
fragment:
|
|
8756
|
+
vertex: version + '\n' + COPY_VERTEX_SHADER,
|
|
8757
|
+
fragment: version + '\n' + COPY_FRAGMENT_SHADER,
|
|
8650
8758
|
glslVersion: webgl2 ? exports.GLSLVersion.GLSL3 : exports.GLSLVersion.GLSL1,
|
|
8651
8759
|
marcos: [
|
|
8652
8760
|
['WEBGL2', !!webgl2],
|
|
@@ -8778,13 +8886,13 @@ var SemanticMap = /** @class */ (function () {
|
|
|
8778
8886
|
return SemanticMap;
|
|
8779
8887
|
}());
|
|
8780
8888
|
|
|
8781
|
-
var _a$
|
|
8782
|
-
var BYTES_TYPE_MAP = (_a$
|
|
8783
|
-
_a$
|
|
8784
|
-
_a$
|
|
8785
|
-
_a$
|
|
8786
|
-
_a$
|
|
8787
|
-
_a$
|
|
8889
|
+
var _a$9;
|
|
8890
|
+
var BYTES_TYPE_MAP = (_a$9 = {},
|
|
8891
|
+
_a$9[glContext.FLOAT] = Float32Array.BYTES_PER_ELEMENT,
|
|
8892
|
+
_a$9[glContext.INT] = Int32Array.BYTES_PER_ELEMENT,
|
|
8893
|
+
_a$9[glContext.SHORT] = Int16Array.BYTES_PER_ELEMENT,
|
|
8894
|
+
_a$9[glContext.BYTE] = Int8Array.BYTES_PER_ELEMENT,
|
|
8895
|
+
_a$9);
|
|
8788
8896
|
/**
|
|
8789
8897
|
* Geometry 抽象类
|
|
8790
8898
|
*/
|
|
@@ -9353,7 +9461,7 @@ var RenderPass = /** @class */ (function () {
|
|
|
9353
9461
|
RenderPass.prototype.setMeshes = function (meshes) {
|
|
9354
9462
|
var _a;
|
|
9355
9463
|
this.meshes.length = 0;
|
|
9356
|
-
(_a = this.meshes).splice.apply(_a, __spreadArray$
|
|
9464
|
+
(_a = this.meshes).splice.apply(_a, __spreadArray$3([0, 0], __read$3(meshes), false));
|
|
9357
9465
|
sortByOrder(this.meshes, this.meshOrder);
|
|
9358
9466
|
return this.meshes;
|
|
9359
9467
|
};
|
|
@@ -11547,9 +11655,6 @@ var AssetLoader = /** @class */ (function () {
|
|
|
11547
11655
|
case exports.DataType.Texture:
|
|
11548
11656
|
effectsObject = Texture.create(this.engine, effectsObjectData);
|
|
11549
11657
|
return effectsObject;
|
|
11550
|
-
case exports.DataType.Shader:
|
|
11551
|
-
effectsObject = this.engine.getShaderLibrary().createShader(effectsObjectData);
|
|
11552
|
-
break;
|
|
11553
11658
|
default: {
|
|
11554
11659
|
var classConstructor = AssetLoader.getClass(effectsObjectData.dataType);
|
|
11555
11660
|
if (classConstructor) {
|
|
@@ -11602,9 +11707,6 @@ var AssetLoader = /** @class */ (function () {
|
|
|
11602
11707
|
case exports.DataType.Texture:
|
|
11603
11708
|
effectsObject = Texture.create(this.engine, effectsObjectData);
|
|
11604
11709
|
return [2 /*return*/, effectsObject];
|
|
11605
|
-
case exports.DataType.Shader:
|
|
11606
|
-
effectsObject = this.engine.getShaderLibrary().createShader(effectsObjectData);
|
|
11607
|
-
break;
|
|
11608
11710
|
default: {
|
|
11609
11711
|
classConstructor = AssetLoader.getClass(effectsObjectData.dataType);
|
|
11610
11712
|
if (classConstructor) {
|
|
@@ -11817,7 +11919,7 @@ function calculateTranslation(out, target, acc, time, duration, posData, velData
|
|
|
11817
11919
|
return ret;
|
|
11818
11920
|
}
|
|
11819
11921
|
|
|
11820
|
-
var _a$
|
|
11922
|
+
var _a$8;
|
|
11821
11923
|
function ensureVec3(num) {
|
|
11822
11924
|
return Array.isArray(num) ? [num[0], num[1], num[2]] : [0, 0, 0];
|
|
11823
11925
|
}
|
|
@@ -11840,7 +11942,7 @@ function vecNormalize(out, a) {
|
|
|
11840
11942
|
out = [];
|
|
11841
11943
|
}
|
|
11842
11944
|
var ap = a;
|
|
11843
|
-
var sum = Math.hypot.apply(Math, __spreadArray$
|
|
11945
|
+
var sum = Math.hypot.apply(Math, __spreadArray$3([], __read$3(ap), false));
|
|
11844
11946
|
if (sum === 0) {
|
|
11845
11947
|
return vecAssign(out, ap, ap.length);
|
|
11846
11948
|
}
|
|
@@ -11871,17 +11973,17 @@ function vecMulCombine(out, a, b) {
|
|
|
11871
11973
|
}
|
|
11872
11974
|
return out;
|
|
11873
11975
|
}
|
|
11874
|
-
var particleOriginTranslateMap = (_a$
|
|
11875
|
-
_a$
|
|
11876
|
-
_a$
|
|
11877
|
-
_a$
|
|
11878
|
-
_a$
|
|
11879
|
-
_a$
|
|
11880
|
-
_a$
|
|
11881
|
-
_a$
|
|
11882
|
-
_a$
|
|
11883
|
-
_a$
|
|
11884
|
-
_a$
|
|
11976
|
+
var particleOriginTranslateMap$1 = (_a$8 = {},
|
|
11977
|
+
_a$8[ParticleOrigin$1.PARTICLE_ORIGIN_CENTER] = [0, 0],
|
|
11978
|
+
_a$8[ParticleOrigin$1.PARTICLE_ORIGIN_CENTER_BOTTOM] = [0, -0.5],
|
|
11979
|
+
_a$8[ParticleOrigin$1.PARTICLE_ORIGIN_CENTER_TOP] = [0, 0.5],
|
|
11980
|
+
_a$8[ParticleOrigin$1.PARTICLE_ORIGIN_LEFT_TOP] = [-0.5, 0.5],
|
|
11981
|
+
_a$8[ParticleOrigin$1.PARTICLE_ORIGIN_LEFT_CENTER] = [-0.5, 0],
|
|
11982
|
+
_a$8[ParticleOrigin$1.PARTICLE_ORIGIN_LEFT_BOTTOM] = [-0.5, -0.5],
|
|
11983
|
+
_a$8[ParticleOrigin$1.PARTICLE_ORIGIN_RIGHT_CENTER] = [0.5, 0],
|
|
11984
|
+
_a$8[ParticleOrigin$1.PARTICLE_ORIGIN_RIGHT_BOTTOM] = [0.5, -0.5],
|
|
11985
|
+
_a$8[ParticleOrigin$1.PARTICLE_ORIGIN_RIGHT_TOP] = [0.5, 0.5],
|
|
11986
|
+
_a$8);
|
|
11885
11987
|
function nearestPowerOfTwo(value) {
|
|
11886
11988
|
return Math.pow(2, Math.round(Math.log(value) / Math.LN2));
|
|
11887
11989
|
}
|
|
@@ -11906,7 +12008,7 @@ function trianglesFromRect(position, halfWidth, halfHeight) {
|
|
|
11906
12008
|
];
|
|
11907
12009
|
}
|
|
11908
12010
|
|
|
11909
|
-
var _a$
|
|
12011
|
+
var _a$7;
|
|
11910
12012
|
var NOT_IMPLEMENT = 'not_implement';
|
|
11911
12013
|
var ValueGetter = /** @class */ (function () {
|
|
11912
12014
|
function ValueGetter(arg) {
|
|
@@ -12414,50 +12516,50 @@ var BezierSegments = /** @class */ (function (_super) {
|
|
|
12414
12516
|
};
|
|
12415
12517
|
return BezierSegments;
|
|
12416
12518
|
}(PathSegments));
|
|
12417
|
-
var map$2 = (_a$
|
|
12418
|
-
_a$
|
|
12519
|
+
var map$2 = (_a$7 = {},
|
|
12520
|
+
_a$7[ValueType$1.RANDOM] = function (props) {
|
|
12419
12521
|
if (props[0] instanceof Array) {
|
|
12420
12522
|
return new RandomVectorValue(props);
|
|
12421
12523
|
}
|
|
12422
12524
|
return new RandomValue(props);
|
|
12423
12525
|
},
|
|
12424
|
-
_a$
|
|
12526
|
+
_a$7[ValueType$1.CONSTANT] = function (props) {
|
|
12425
12527
|
return new StaticValue(props);
|
|
12426
12528
|
},
|
|
12427
|
-
_a$
|
|
12529
|
+
_a$7[ValueType$1.CONSTANT_VEC2] = function (props) {
|
|
12428
12530
|
return new StaticValue(props);
|
|
12429
12531
|
},
|
|
12430
|
-
_a$
|
|
12532
|
+
_a$7[ValueType$1.CONSTANT_VEC3] = function (props) {
|
|
12431
12533
|
return new StaticValue(props);
|
|
12432
12534
|
},
|
|
12433
|
-
_a$
|
|
12535
|
+
_a$7[ValueType$1.CONSTANT_VEC4] = function (props) {
|
|
12434
12536
|
return new StaticValue(props);
|
|
12435
12537
|
},
|
|
12436
|
-
_a$
|
|
12538
|
+
_a$7[ValueType$1.CURVE] = function (props) {
|
|
12437
12539
|
return new CurveValue(props);
|
|
12438
12540
|
},
|
|
12439
|
-
_a$
|
|
12541
|
+
_a$7[ValueType$1.RGBA_COLOR] = function (props) {
|
|
12440
12542
|
return new StaticValue(props);
|
|
12441
12543
|
},
|
|
12442
|
-
_a$
|
|
12544
|
+
_a$7[ValueType$1.COLORS] = function (props) {
|
|
12443
12545
|
return new RandomSetValue(props.map(function (c) { return colorToArr$1(c, false); }));
|
|
12444
12546
|
},
|
|
12445
|
-
_a$
|
|
12547
|
+
_a$7[ValueType$1.LINE] = function (props) {
|
|
12446
12548
|
if (props.length === 2 && props[0][0] === 0 && props[1][0] === 1) {
|
|
12447
12549
|
return new LinearValue([props[0][1], props[1][1]]);
|
|
12448
12550
|
}
|
|
12449
12551
|
return new LineSegments(props);
|
|
12450
12552
|
},
|
|
12451
|
-
_a$
|
|
12553
|
+
_a$7[ValueType$1.GRADIENT_COLOR] = function (props) {
|
|
12452
12554
|
return new GradientValue(props);
|
|
12453
12555
|
},
|
|
12454
|
-
_a$
|
|
12556
|
+
_a$7[ValueType$1.LINEAR_PATH] = function (pros) {
|
|
12455
12557
|
return new PathSegments(pros);
|
|
12456
12558
|
},
|
|
12457
|
-
_a$
|
|
12559
|
+
_a$7[ValueType$1.BEZIER_PATH] = function (pros) {
|
|
12458
12560
|
return new BezierSegments(pros);
|
|
12459
12561
|
},
|
|
12460
|
-
_a$
|
|
12562
|
+
_a$7);
|
|
12461
12563
|
function createValueGetter(args) {
|
|
12462
12564
|
if (!args || !isNaN(+args)) {
|
|
12463
12565
|
return new StaticValue(args || 0);
|
|
@@ -13408,13 +13510,13 @@ var InteractMesh = /** @class */ (function () {
|
|
|
13408
13510
|
['ENV_EDITOR', ((_a = this.engine.renderer) === null || _a === void 0 ? void 0 : _a.env) === PLAYER_OPTIONS_ENV_EDITOR],
|
|
13409
13511
|
];
|
|
13410
13512
|
var color = createValueGetter(this.color).getValue(0);
|
|
13411
|
-
var level = this.engine.gpuCapability.level;
|
|
13412
13513
|
var materialProps = {
|
|
13413
13514
|
shader: {
|
|
13414
|
-
vertex:
|
|
13415
|
-
fragment:
|
|
13515
|
+
vertex: vertex,
|
|
13516
|
+
fragment: fragment,
|
|
13416
13517
|
glslVersion: exports.GLSLVersion.GLSL1,
|
|
13417
13518
|
cacheId: "".concat(rendererOptions.cachePrefix, "_effects_interact"),
|
|
13519
|
+
marcos: marcos,
|
|
13418
13520
|
},
|
|
13419
13521
|
uniformSemantics: {
|
|
13420
13522
|
effects_MatrixVP: 'VIEWPROJECTION',
|
|
@@ -13488,11 +13590,11 @@ var InteractComponent = /** @class */ (function (_super) {
|
|
|
13488
13590
|
}
|
|
13489
13591
|
InteractComponent_1 = InteractComponent;
|
|
13490
13592
|
InteractComponent.prototype.start = function () {
|
|
13491
|
-
var
|
|
13593
|
+
var _this = this;
|
|
13492
13594
|
var options = this.item.props.content.options;
|
|
13493
|
-
var env =
|
|
13595
|
+
var env = this.item.engine.renderer.env;
|
|
13494
13596
|
var composition = this.item.composition;
|
|
13495
|
-
var
|
|
13597
|
+
var _a = this.interactData.options, type = _a.type, showPreview = _a.showPreview;
|
|
13496
13598
|
if (type === InteractType$1.CLICK) {
|
|
13497
13599
|
this.clickable = true;
|
|
13498
13600
|
if (showPreview && env === PLAYER_OPTIONS_ENV_EDITOR) {
|
|
@@ -13500,7 +13602,8 @@ var InteractComponent = /** @class */ (function (_super) {
|
|
|
13500
13602
|
this.previewContent = new InteractMesh(this.item.props.content, rendererOptions, this.transform, this.engine);
|
|
13501
13603
|
}
|
|
13502
13604
|
}
|
|
13503
|
-
|
|
13605
|
+
composition.addInteractiveItem(this.item, options.type);
|
|
13606
|
+
this.item.onEnd = function () { return composition.removeInteractiveItem(_this.item, options.type); };
|
|
13504
13607
|
if (options.type === InteractType$1.DRAG) {
|
|
13505
13608
|
if (env !== PLAYER_OPTIONS_ENV_EDITOR || options.enableInEditor) {
|
|
13506
13609
|
composition.event && this.beginDragTarget(options, composition.event);
|
|
@@ -13693,8 +13796,8 @@ function spriteMeshShaderFromFilter(level, options) {
|
|
|
13693
13796
|
var fragment = wireframe ? itemFrameFrag : itemFrag.replace(/#pragma\s+FILTER_FRAG/, '');
|
|
13694
13797
|
var vertex = itemVert.replace(/#pragma\s+FILTER_VERT/, 'vec4 filterMain(float t,vec4 pos){return effects_MatrixVP * pos;}');
|
|
13695
13798
|
return {
|
|
13696
|
-
fragment:
|
|
13697
|
-
vertex:
|
|
13799
|
+
fragment: fragment,
|
|
13800
|
+
vertex: vertex,
|
|
13698
13801
|
glslVersion: level === 1 ? exports.GLSLVersion.GLSL1 : exports.GLSLVersion.GLSL3,
|
|
13699
13802
|
marcos: marcos,
|
|
13700
13803
|
shared: true,
|
|
@@ -15174,8 +15277,8 @@ var ParticleMesh = /** @class */ (function () {
|
|
|
15174
15277
|
var originalVertex = "#define LOOKUP_TEXTURE_CURVE ".concat(vertex_lookup_texture, "\n").concat(particleVert);
|
|
15175
15278
|
var vertex = originalVertex;
|
|
15176
15279
|
var shader = {
|
|
15177
|
-
fragment:
|
|
15178
|
-
vertex:
|
|
15280
|
+
fragment: fragment,
|
|
15281
|
+
vertex: vertex,
|
|
15179
15282
|
glslVersion: level === 1 ? exports.GLSLVersion.GLSL1 : exports.GLSLVersion.GLSL3,
|
|
15180
15283
|
shared: true,
|
|
15181
15284
|
cacheId: shaderCache,
|
|
@@ -15730,8 +15833,8 @@ var TrailMesh = /** @class */ (function () {
|
|
|
15730
15833
|
else {
|
|
15731
15834
|
uniformValues.uVCurveValues = CurveValue.getAllData(keyFrameMeta);
|
|
15732
15835
|
}
|
|
15733
|
-
var vertex =
|
|
15734
|
-
var fragment =
|
|
15836
|
+
var vertex = trailVert;
|
|
15837
|
+
var fragment = particleFrag;
|
|
15735
15838
|
var mtl = ({
|
|
15736
15839
|
shader: {
|
|
15737
15840
|
vertex: vertex,
|
|
@@ -16418,7 +16521,7 @@ var TextureShape = /** @class */ (function () {
|
|
|
16418
16521
|
return TextureShape;
|
|
16419
16522
|
}());
|
|
16420
16523
|
|
|
16421
|
-
var _a$
|
|
16524
|
+
var _a$6;
|
|
16422
16525
|
var ShapeNone = /** @class */ (function () {
|
|
16423
16526
|
function ShapeNone() {
|
|
16424
16527
|
}
|
|
@@ -16430,18 +16533,18 @@ var ShapeNone = /** @class */ (function () {
|
|
|
16430
16533
|
};
|
|
16431
16534
|
return ShapeNone;
|
|
16432
16535
|
}());
|
|
16433
|
-
var map$1 = (_a$
|
|
16434
|
-
_a$
|
|
16435
|
-
_a$
|
|
16436
|
-
_a$
|
|
16437
|
-
_a$
|
|
16438
|
-
_a$
|
|
16439
|
-
_a$
|
|
16440
|
-
_a$
|
|
16441
|
-
_a$
|
|
16442
|
-
_a$
|
|
16443
|
-
_a$
|
|
16444
|
-
_a$
|
|
16536
|
+
var map$1 = (_a$6 = {},
|
|
16537
|
+
_a$6[ShapeType$1.NONE] = ShapeNone,
|
|
16538
|
+
_a$6[ShapeType$1.CONE] = Cone,
|
|
16539
|
+
_a$6[ShapeType$1.SPHERE] = Sphere,
|
|
16540
|
+
_a$6[ShapeType$1.HEMISPHERE] = Hemisphere,
|
|
16541
|
+
_a$6[ShapeType$1.CIRCLE] = Circle,
|
|
16542
|
+
_a$6[ShapeType$1.DONUT] = Donut,
|
|
16543
|
+
_a$6[ShapeType$1.RECTANGLE] = Rectangle,
|
|
16544
|
+
_a$6[ShapeType$1.EDGE] = Edge,
|
|
16545
|
+
_a$6[ShapeType$1.RECTANGLE_EDGE] = RectangleEdge,
|
|
16546
|
+
_a$6[ShapeType$1.TEXTURE] = TextureShape,
|
|
16547
|
+
_a$6);
|
|
16445
16548
|
function createShape(shapeOptions) {
|
|
16446
16549
|
if (!shapeOptions) {
|
|
16447
16550
|
return new ShapeNone();
|
|
@@ -17770,7 +17873,7 @@ var ParticleSystem = /** @class */ (function (_super) {
|
|
|
17770
17873
|
}));
|
|
17771
17874
|
p.delay += meshTime;
|
|
17772
17875
|
cursor++;
|
|
17773
|
-
(_a = p.transform).translate.apply(_a, __spreadArray$
|
|
17876
|
+
(_a = p.transform).translate.apply(_a, __spreadArray$3([], __read$3(burstOffset), false));
|
|
17774
17877
|
this.addParticle(p, maxCount_1);
|
|
17775
17878
|
}
|
|
17776
17879
|
}
|
|
@@ -18542,7 +18645,9 @@ var TextStyle = /** @class */ (function () {
|
|
|
18542
18645
|
this.fontOffset = 0;
|
|
18543
18646
|
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;
|
|
18544
18647
|
this.textColor = textColor;
|
|
18648
|
+
//@ts-expect-error
|
|
18545
18649
|
this.textWeight = fontWeight;
|
|
18650
|
+
//@ts-expect-error
|
|
18546
18651
|
this.fontStyle = fontStyle;
|
|
18547
18652
|
this.fontFamily = fontFamily;
|
|
18548
18653
|
this.fontSize = fontSize; // 暂时取消字号限制 Math.min(fontSize, this.maxFontSize);
|
|
@@ -20610,7 +20715,10 @@ var VFXItem = /** @class */ (function (_super) {
|
|
|
20610
20715
|
try {
|
|
20611
20716
|
for (var _e = __values$1(this.children), _f = _e.next(); !_f.done; _f = _e.next()) {
|
|
20612
20717
|
var child = _f.value;
|
|
20613
|
-
|
|
20718
|
+
var res = child.find(name);
|
|
20719
|
+
if (res) {
|
|
20720
|
+
return res;
|
|
20721
|
+
}
|
|
20614
20722
|
}
|
|
20615
20723
|
}
|
|
20616
20724
|
catch (e_4_1) { e_4 = { error: e_4_1 }; }
|
|
@@ -20627,6 +20735,7 @@ var VFXItem = /** @class */ (function (_super) {
|
|
|
20627
20735
|
_super.prototype.fromData.call(this, data);
|
|
20628
20736
|
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;
|
|
20629
20737
|
this.props = data;
|
|
20738
|
+
//@ts-expect-error
|
|
20630
20739
|
this.type = data.type;
|
|
20631
20740
|
this.id = id.toString(); // TODO 老数据 id 是 number,需要转换
|
|
20632
20741
|
this.name = name;
|
|
@@ -20722,10 +20831,10 @@ var VFXItem = /** @class */ (function (_super) {
|
|
|
20722
20831
|
};
|
|
20723
20832
|
VFXItem.prototype.translateByPixel = function (x, y) {
|
|
20724
20833
|
if (this.composition) {
|
|
20834
|
+
// @ts-expect-error
|
|
20835
|
+
var _a = this.composition.renderer.canvas.getBoundingClientRect(), width = _a.width, height = _a.height;
|
|
20725
20836
|
var z = this.transform.getWorldPosition().z;
|
|
20726
|
-
var
|
|
20727
|
-
var width = this.composition.renderer.getWidth() / 2;
|
|
20728
|
-
var height = this.composition.renderer.getHeight() / 2;
|
|
20837
|
+
var _b = this.composition.camera.getInverseVPRatio(z), rx = _b.x, ry = _b.y;
|
|
20729
20838
|
this.transform.translate(2 * x * rx / width, -2 * y * ry / height, 0);
|
|
20730
20839
|
}
|
|
20731
20840
|
};
|
|
@@ -20830,7 +20939,6 @@ function createVFXItem(props, composition) {
|
|
|
20830
20939
|
if (!pluginName) {
|
|
20831
20940
|
switch (type) {
|
|
20832
20941
|
case ItemType$1.null:
|
|
20833
|
-
case ItemType$1.base:
|
|
20834
20942
|
pluginName = 'cal';
|
|
20835
20943
|
break;
|
|
20836
20944
|
case ItemType$1.sprite:
|
|
@@ -20951,7 +21059,7 @@ var PluginSystem = /** @class */ (function () {
|
|
|
20951
21059
|
plugin = plugins[i];
|
|
20952
21060
|
ctrl = pluginLoaderMap[plugin.name];
|
|
20953
21061
|
if (name in ctrl) {
|
|
20954
|
-
pendings.push(Promise.resolve(ctrl[name].apply(ctrl, __spreadArray$
|
|
21062
|
+
pendings.push(Promise.resolve(ctrl[name].apply(ctrl, __spreadArray$3([], __read$3(args), false))));
|
|
20955
21063
|
}
|
|
20956
21064
|
}
|
|
20957
21065
|
return [2 /*return*/, Promise.all(pendings)];
|
|
@@ -20996,9 +21104,74 @@ function getPluginUsageInfo(name) {
|
|
|
20996
21104
|
* Name: @galacean/effects-specification
|
|
20997
21105
|
* Description: Galacean Effects JSON Specification
|
|
20998
21106
|
* Author: Ant Group CO., Ltd.
|
|
20999
|
-
* Version:
|
|
21107
|
+
* Version: v2.0.0-alpha.2
|
|
21000
21108
|
*/
|
|
21001
21109
|
|
|
21110
|
+
const randomUUID = typeof crypto !== 'undefined' && crypto.randomUUID && crypto.randomUUID.bind(crypto);
|
|
21111
|
+
var native = {
|
|
21112
|
+
randomUUID
|
|
21113
|
+
};
|
|
21114
|
+
|
|
21115
|
+
// Unique ID creation requires a high quality random # generator. In the browser we therefore
|
|
21116
|
+
// require the crypto API and do not support built-in fallback to lower quality random number
|
|
21117
|
+
// generators (like Math.random()).
|
|
21118
|
+
let getRandomValues;
|
|
21119
|
+
const rnds8 = new Uint8Array(16);
|
|
21120
|
+
function rng() {
|
|
21121
|
+
// lazy load so that environments that need to polyfill have a chance to do so
|
|
21122
|
+
if (!getRandomValues) {
|
|
21123
|
+
// getRandomValues needs to be invoked in a context where "this" is a Crypto implementation.
|
|
21124
|
+
getRandomValues = typeof crypto !== 'undefined' && crypto.getRandomValues && crypto.getRandomValues.bind(crypto);
|
|
21125
|
+
|
|
21126
|
+
if (!getRandomValues) {
|
|
21127
|
+
throw new Error('crypto.getRandomValues() not supported. See https://github.com/uuidjs/uuid#getrandomvalues-not-supported');
|
|
21128
|
+
}
|
|
21129
|
+
}
|
|
21130
|
+
|
|
21131
|
+
return getRandomValues(rnds8);
|
|
21132
|
+
}
|
|
21133
|
+
|
|
21134
|
+
/**
|
|
21135
|
+
* Convert array of 16 byte values to UUID string format of the form:
|
|
21136
|
+
* XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX
|
|
21137
|
+
*/
|
|
21138
|
+
|
|
21139
|
+
const byteToHex = [];
|
|
21140
|
+
|
|
21141
|
+
for (let i = 0; i < 256; ++i) {
|
|
21142
|
+
byteToHex.push((i + 0x100).toString(16).slice(1));
|
|
21143
|
+
}
|
|
21144
|
+
|
|
21145
|
+
function unsafeStringify(arr, offset = 0) {
|
|
21146
|
+
// Note: Be careful editing this code! It's been tuned for performance
|
|
21147
|
+
// and works in ways you may not expect. See https://github.com/uuidjs/uuid/pull/434
|
|
21148
|
+
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]];
|
|
21149
|
+
}
|
|
21150
|
+
|
|
21151
|
+
function v4(options, buf, offset) {
|
|
21152
|
+
if (native.randomUUID && !buf && !options) {
|
|
21153
|
+
return native.randomUUID();
|
|
21154
|
+
}
|
|
21155
|
+
|
|
21156
|
+
options = options || {};
|
|
21157
|
+
const rnds = options.random || (options.rng || rng)(); // Per 4.4, set bits for version and `clock_seq_hi_and_reserved`
|
|
21158
|
+
|
|
21159
|
+
rnds[6] = rnds[6] & 0x0f | 0x40;
|
|
21160
|
+
rnds[8] = rnds[8] & 0x3f | 0x80; // Copy bytes to buffer, if provided
|
|
21161
|
+
|
|
21162
|
+
if (buf) {
|
|
21163
|
+
offset = offset || 0;
|
|
21164
|
+
|
|
21165
|
+
for (let i = 0; i < 16; ++i) {
|
|
21166
|
+
buf[offset + i] = rnds[i];
|
|
21167
|
+
}
|
|
21168
|
+
|
|
21169
|
+
return buf;
|
|
21170
|
+
}
|
|
21171
|
+
|
|
21172
|
+
return unsafeStringify(rnds);
|
|
21173
|
+
}
|
|
21174
|
+
|
|
21002
21175
|
/*********************************************/
|
|
21003
21176
|
/* 元素属性参数类型 */
|
|
21004
21177
|
/*********************************************/
|
|
@@ -21261,6 +21434,10 @@ var ItemType;
|
|
|
21261
21434
|
* 天空盒元素
|
|
21262
21435
|
*/
|
|
21263
21436
|
ItemType["skybox"] = "skybox";
|
|
21437
|
+
/**
|
|
21438
|
+
* 特效元素
|
|
21439
|
+
*/
|
|
21440
|
+
ItemType["effect"] = "effect";
|
|
21264
21441
|
})(ItemType || (ItemType = {}));
|
|
21265
21442
|
/**
|
|
21266
21443
|
* 渲染模式
|
|
@@ -21373,6 +21550,10 @@ var CompositionEndBehavior;
|
|
|
21373
21550
|
* 销毁并保留最后一帧
|
|
21374
21551
|
*/
|
|
21375
21552
|
CompositionEndBehavior[CompositionEndBehavior["pause_destroy"] = END_BEHAVIOR_PAUSE_AND_DESTROY] = "pause_destroy";
|
|
21553
|
+
/**
|
|
21554
|
+
* 冻结
|
|
21555
|
+
*/
|
|
21556
|
+
CompositionEndBehavior[CompositionEndBehavior["freeze"] = END_BEHAVIOR_FREEZE] = "freeze";
|
|
21376
21557
|
})(CompositionEndBehavior || (CompositionEndBehavior = {}));
|
|
21377
21558
|
|
|
21378
21559
|
/*********************************************/
|
|
@@ -21509,12 +21690,38 @@ var ShapeArcMode;
|
|
|
21509
21690
|
ShapeArcMode[ShapeArcMode["UNIFORM_BURST"] = 3] = "UNIFORM_BURST";
|
|
21510
21691
|
})(ShapeArcMode || (ShapeArcMode = {}));
|
|
21511
21692
|
|
|
21693
|
+
var LightType;
|
|
21694
|
+
(function (LightType) {
|
|
21695
|
+
/**
|
|
21696
|
+
* 点光源
|
|
21697
|
+
*/
|
|
21698
|
+
LightType["point"] = "point";
|
|
21699
|
+
/**
|
|
21700
|
+
* 聚光灯
|
|
21701
|
+
*/
|
|
21702
|
+
LightType["spot"] = "spot";
|
|
21703
|
+
/**
|
|
21704
|
+
* 方向光
|
|
21705
|
+
*/
|
|
21706
|
+
LightType["directional"] = "directional";
|
|
21707
|
+
/**
|
|
21708
|
+
* 环境光
|
|
21709
|
+
*/
|
|
21710
|
+
LightType["ambient"] = "ambient";
|
|
21711
|
+
})(LightType || (LightType = {}));
|
|
21712
|
+
|
|
21512
21713
|
var ModelBoundingType;
|
|
21513
21714
|
(function (ModelBoundingType) {
|
|
21514
21715
|
ModelBoundingType[ModelBoundingType["box"] = 2] = "box";
|
|
21515
21716
|
ModelBoundingType[ModelBoundingType["sphere"] = 3] = "sphere";
|
|
21516
21717
|
})(ModelBoundingType || (ModelBoundingType = {}));
|
|
21517
21718
|
|
|
21719
|
+
var CameraType;
|
|
21720
|
+
(function (CameraType) {
|
|
21721
|
+
CameraType["orthographic"] = "orthographic";
|
|
21722
|
+
CameraType["perspective"] = "perspective";
|
|
21723
|
+
})(CameraType || (CameraType = {}));
|
|
21724
|
+
|
|
21518
21725
|
// 材质类型
|
|
21519
21726
|
var MaterialType;
|
|
21520
21727
|
(function (MaterialType) {
|
|
@@ -21660,6 +21867,28 @@ var FontStyle;
|
|
|
21660
21867
|
FontStyle["oblique"] = "oblique";
|
|
21661
21868
|
})(FontStyle || (FontStyle = {}));
|
|
21662
21869
|
|
|
21870
|
+
var DataType;
|
|
21871
|
+
(function (DataType) {
|
|
21872
|
+
DataType["VFXItemData"] = "VFXItemData";
|
|
21873
|
+
DataType["EffectComponent"] = "EffectComponent";
|
|
21874
|
+
DataType["Material"] = "Material";
|
|
21875
|
+
DataType["Shader"] = "Shader";
|
|
21876
|
+
DataType["SpriteComponent"] = "SpriteComponent";
|
|
21877
|
+
DataType["ParticleSystem"] = "ParticleSystem";
|
|
21878
|
+
DataType["InteractComponent"] = "InteractComponent";
|
|
21879
|
+
DataType["CameraController"] = "CameraController";
|
|
21880
|
+
DataType["Geometry"] = "Geometry";
|
|
21881
|
+
DataType["Texture"] = "Texture";
|
|
21882
|
+
DataType["TextComponent"] = "TextComponent";
|
|
21883
|
+
// FIXME: 先完成ECS的场景转换,后面移到spec中
|
|
21884
|
+
DataType["MeshComponent"] = "MeshComponent";
|
|
21885
|
+
DataType["SkyboxComponent"] = "SkyboxComponent";
|
|
21886
|
+
DataType["LightComponent"] = "LightComponent";
|
|
21887
|
+
DataType["CameraComponent"] = "CameraComponent";
|
|
21888
|
+
DataType["ModelPluginComponent"] = "ModelPluginComponent";
|
|
21889
|
+
DataType["TreeComponent"] = "TreeComponent";
|
|
21890
|
+
})(DataType || (DataType = {}));
|
|
21891
|
+
|
|
21663
21892
|
/******************************************************************************
|
|
21664
21893
|
Copyright (c) Microsoft Corporation.
|
|
21665
21894
|
|
|
@@ -21715,11 +21944,22 @@ function __read(o, n) {
|
|
|
21715
21944
|
return ar;
|
|
21716
21945
|
}
|
|
21717
21946
|
|
|
21947
|
+
function __spreadArray(to, from, pack) {
|
|
21948
|
+
if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {
|
|
21949
|
+
if (ar || !(i in from)) {
|
|
21950
|
+
if (!ar) ar = Array.prototype.slice.call(from, 0, i);
|
|
21951
|
+
ar[i] = from[i];
|
|
21952
|
+
}
|
|
21953
|
+
}
|
|
21954
|
+
return to.concat(ar || Array.prototype.slice.call(from));
|
|
21955
|
+
}
|
|
21956
|
+
|
|
21718
21957
|
typeof SuppressedError === "function" ? SuppressedError : function (error, suppressed, message) {
|
|
21719
21958
|
var e = new Error(message);
|
|
21720
21959
|
return e.name = "SuppressedError", e.error = error, e.suppressed = suppressed, e;
|
|
21721
21960
|
};
|
|
21722
21961
|
|
|
21962
|
+
var _a$5;
|
|
21723
21963
|
function arrAdd(arr, item) {
|
|
21724
21964
|
if (!arr.includes(item)) {
|
|
21725
21965
|
arr.push(item);
|
|
@@ -21955,6 +22195,34 @@ function rotationZYXFromQuat(out, quat) {
|
|
|
21955
22195
|
}
|
|
21956
22196
|
return out;
|
|
21957
22197
|
}
|
|
22198
|
+
function generateGUID() {
|
|
22199
|
+
return v4().replace(/-/g, '');
|
|
22200
|
+
}
|
|
22201
|
+
/**
|
|
22202
|
+
* 提取并转换 JSON 数据中的 anchor 值
|
|
22203
|
+
*/
|
|
22204
|
+
function convertAnchor$1(anchor, particleOrigin) {
|
|
22205
|
+
if (anchor) {
|
|
22206
|
+
return [anchor[0] - 0.5, 0.5 - anchor[1]];
|
|
22207
|
+
}
|
|
22208
|
+
else if (particleOrigin) {
|
|
22209
|
+
return particleOriginTranslateMap[particleOrigin];
|
|
22210
|
+
}
|
|
22211
|
+
else {
|
|
22212
|
+
return [0, 0];
|
|
22213
|
+
}
|
|
22214
|
+
}
|
|
22215
|
+
var particleOriginTranslateMap = (_a$5 = {},
|
|
22216
|
+
_a$5[ParticleOrigin.PARTICLE_ORIGIN_CENTER] = [0, 0],
|
|
22217
|
+
_a$5[ParticleOrigin.PARTICLE_ORIGIN_CENTER_BOTTOM] = [0, -0.5],
|
|
22218
|
+
_a$5[ParticleOrigin.PARTICLE_ORIGIN_CENTER_TOP] = [0, 0.5],
|
|
22219
|
+
_a$5[ParticleOrigin.PARTICLE_ORIGIN_LEFT_TOP] = [-0.5, 0.5],
|
|
22220
|
+
_a$5[ParticleOrigin.PARTICLE_ORIGIN_LEFT_CENTER] = [-0.5, 0],
|
|
22221
|
+
_a$5[ParticleOrigin.PARTICLE_ORIGIN_LEFT_BOTTOM] = [-0.5, -0.5],
|
|
22222
|
+
_a$5[ParticleOrigin.PARTICLE_ORIGIN_RIGHT_CENTER] = [0.5, 0],
|
|
22223
|
+
_a$5[ParticleOrigin.PARTICLE_ORIGIN_RIGHT_BOTTOM] = [0.5, -0.5],
|
|
22224
|
+
_a$5[ParticleOrigin.PARTICLE_ORIGIN_RIGHT_TOP] = [0.5, 0.5],
|
|
22225
|
+
_a$5);
|
|
21958
22226
|
|
|
21959
22227
|
function getStandardParticleContent(particle) {
|
|
21960
22228
|
var _a;
|
|
@@ -22366,6 +22634,309 @@ function version22Migration(json) {
|
|
|
22366
22634
|
});
|
|
22367
22635
|
return json;
|
|
22368
22636
|
}
|
|
22637
|
+
/**
|
|
22638
|
+
* 3.0 以下版本数据适配(runtime 2.0及以上版本支持)
|
|
22639
|
+
*/
|
|
22640
|
+
function version30Migration(json) {
|
|
22641
|
+
var e_1, _a;
|
|
22642
|
+
var _b, _c, _d, _e;
|
|
22643
|
+
var result = Object.assign({}, json, {
|
|
22644
|
+
items: [],
|
|
22645
|
+
components: [],
|
|
22646
|
+
materials: [],
|
|
22647
|
+
shaders: [],
|
|
22648
|
+
geometries: [],
|
|
22649
|
+
});
|
|
22650
|
+
// 兼容老版本数据中不存在textures的情况
|
|
22651
|
+
(_b = result.textures) !== null && _b !== void 0 ? _b : (result.textures = []);
|
|
22652
|
+
result.textures.forEach(function (textureOptions) {
|
|
22653
|
+
Object.assign(textureOptions, {
|
|
22654
|
+
id: generateGUID(),
|
|
22655
|
+
dataType: DataType.Texture,
|
|
22656
|
+
});
|
|
22657
|
+
});
|
|
22658
|
+
if (result.textures.length < result.images.length) {
|
|
22659
|
+
for (var i = result.textures.length; i < result.images.length; i++) {
|
|
22660
|
+
result.textures.push({
|
|
22661
|
+
//@ts-expect-error
|
|
22662
|
+
id: generateGUID(),
|
|
22663
|
+
dataType: DataType.Texture,
|
|
22664
|
+
source: i,
|
|
22665
|
+
flipY: true,
|
|
22666
|
+
});
|
|
22667
|
+
}
|
|
22668
|
+
}
|
|
22669
|
+
var _loop_1 = function (composition) {
|
|
22670
|
+
var e_2, _h, e_3, _j;
|
|
22671
|
+
// composition 的 endbehaviour 兼容
|
|
22672
|
+
if (composition.endBehavior === END_BEHAVIOR_PAUSE_AND_DESTROY || composition.endBehavior === END_BEHAVIOR_PAUSE) {
|
|
22673
|
+
composition.endBehavior = END_BEHAVIOR_FREEZE;
|
|
22674
|
+
}
|
|
22675
|
+
var itemGuidMap = {};
|
|
22676
|
+
try {
|
|
22677
|
+
for (var _k = (e_2 = void 0, __values(composition.items)), _l = _k.next(); !_l.done; _l = _k.next()) {
|
|
22678
|
+
var item = _l.value;
|
|
22679
|
+
itemGuidMap[item.id] = generateGUID();
|
|
22680
|
+
// TODO: 编辑器测试用,上线后删除
|
|
22681
|
+
//@ts-expect-error
|
|
22682
|
+
item.oldId = item.id;
|
|
22683
|
+
item.id = itemGuidMap[item.id];
|
|
22684
|
+
}
|
|
22685
|
+
}
|
|
22686
|
+
catch (e_2_1) { e_2 = { error: e_2_1 }; }
|
|
22687
|
+
finally {
|
|
22688
|
+
try {
|
|
22689
|
+
if (_l && !_l.done && (_h = _k.return)) _h.call(_k);
|
|
22690
|
+
}
|
|
22691
|
+
finally { if (e_2) throw e_2.error; }
|
|
22692
|
+
}
|
|
22693
|
+
composition.items.forEach(function (item, index) {
|
|
22694
|
+
if (item.parentId) {
|
|
22695
|
+
if (item.parentId.includes('^')) {
|
|
22696
|
+
var parentId = (item.parentId).split('^')[0];
|
|
22697
|
+
var nodeId = (item.parentId).split('^')[1];
|
|
22698
|
+
item.parentId = itemGuidMap[parentId] + '^' + nodeId;
|
|
22699
|
+
}
|
|
22700
|
+
else {
|
|
22701
|
+
item.parentId = itemGuidMap[item.parentId];
|
|
22702
|
+
}
|
|
22703
|
+
}
|
|
22704
|
+
// @ts-expect-error fix item type
|
|
22705
|
+
result.items.push(item);
|
|
22706
|
+
// @ts-expect-error fix item type
|
|
22707
|
+
composition.items[index] = { id: item.id };
|
|
22708
|
+
});
|
|
22709
|
+
try {
|
|
22710
|
+
for (var _m = (e_3 = void 0, __values(result.items)), _o = _m.next(); !_o.done; _o = _m.next()) {
|
|
22711
|
+
var item = _o.value;
|
|
22712
|
+
// 原 texture 索引转为统一 guid 索引
|
|
22713
|
+
if (item.content) {
|
|
22714
|
+
if (item.content.renderer) {
|
|
22715
|
+
if (item.content.renderer.texture !== undefined) {
|
|
22716
|
+
var oldTextureId = item.content.renderer.texture;
|
|
22717
|
+
//@ts-expect-error
|
|
22718
|
+
item.content.renderer.texture = { id: result.textures[oldTextureId].id };
|
|
22719
|
+
}
|
|
22720
|
+
}
|
|
22721
|
+
if (item.content.trails) {
|
|
22722
|
+
if (item.content.trails.texture !== undefined) {
|
|
22723
|
+
var oldTextureId = item.content.trails.texture;
|
|
22724
|
+
//@ts-expect-error
|
|
22725
|
+
item.content.trails.texture = { id: result.textures[oldTextureId].id };
|
|
22726
|
+
}
|
|
22727
|
+
}
|
|
22728
|
+
}
|
|
22729
|
+
// item 的 transform 属性由数组转为 {x:n, y:n, z:n}
|
|
22730
|
+
if (item.transform) {
|
|
22731
|
+
//@ts-expect-error
|
|
22732
|
+
var position = __spreadArray([], __read((_c = item.transform.position) !== null && _c !== void 0 ? _c : [0, 0, 0]), false);
|
|
22733
|
+
//@ts-expect-error
|
|
22734
|
+
var rotation = __spreadArray([], __read((_d = item.transform.rotation) !== null && _d !== void 0 ? _d : [0, 0, 0]), false);
|
|
22735
|
+
//@ts-expect-error
|
|
22736
|
+
var scale = __spreadArray([], __read((_e = item.transform.scale) !== null && _e !== void 0 ? _e : [1, 1, 1]), false);
|
|
22737
|
+
Object.assign(item, {
|
|
22738
|
+
transform: {
|
|
22739
|
+
position: { x: position[0], y: position[1], z: position[2] },
|
|
22740
|
+
rotation: { x: rotation[0], y: rotation[1], z: rotation[2] },
|
|
22741
|
+
scale: { x: scale[0], y: scale[1], z: scale[0] },
|
|
22742
|
+
},
|
|
22743
|
+
});
|
|
22744
|
+
// sprite 的 scale 转为 size
|
|
22745
|
+
if (item.type === ItemType.sprite) {
|
|
22746
|
+
item.transform.size = { x: scale[0], y: scale[1] };
|
|
22747
|
+
item.transform.scale = { x: 1, y: 1, z: 1 };
|
|
22748
|
+
}
|
|
22749
|
+
// sprite 的 anchor 修正
|
|
22750
|
+
if (item.type === ItemType.sprite) {
|
|
22751
|
+
var content = item.content;
|
|
22752
|
+
if (!content.renderer) {
|
|
22753
|
+
content.renderer = {};
|
|
22754
|
+
}
|
|
22755
|
+
var renderer = content.renderer;
|
|
22756
|
+
var realAnchor = convertAnchor$1(renderer.anchor, renderer.particleOrigin);
|
|
22757
|
+
var startSize = item.transform.size;
|
|
22758
|
+
// 兼容旧JSON(anchor和particleOrigin可能同时存在)
|
|
22759
|
+
if (!renderer.anchor && renderer.particleOrigin !== undefined) {
|
|
22760
|
+
//@ts-expect-error
|
|
22761
|
+
item.transform.position.x += -realAnchor[0] * startSize.x;
|
|
22762
|
+
//@ts-expect-error
|
|
22763
|
+
item.transform.position.y += -realAnchor[1] * startSize.y;
|
|
22764
|
+
}
|
|
22765
|
+
//@ts-expect-error
|
|
22766
|
+
item.transform.anchor = { x: realAnchor[0] * startSize.x, y: realAnchor[1] * startSize.y };
|
|
22767
|
+
}
|
|
22768
|
+
}
|
|
22769
|
+
if (item.type === ItemType.particle) {
|
|
22770
|
+
var content = item.content;
|
|
22771
|
+
if (!content.renderer) {
|
|
22772
|
+
content.renderer = {};
|
|
22773
|
+
}
|
|
22774
|
+
var renderer = content.renderer;
|
|
22775
|
+
content.renderer.anchor = convertAnchor$1(renderer.anchor, renderer.particleOrigin);
|
|
22776
|
+
}
|
|
22777
|
+
// 动画数据转化 TODO: 动画数据移到 TimelineComponentData
|
|
22778
|
+
item.content.tracks = [];
|
|
22779
|
+
var tracks = item.content.tracks;
|
|
22780
|
+
if (item.type !== ItemType.particle) {
|
|
22781
|
+
tracks.push({
|
|
22782
|
+
clips: [
|
|
22783
|
+
{
|
|
22784
|
+
dataType: 'TransformAnimationPlayableAsset',
|
|
22785
|
+
animationClip: {
|
|
22786
|
+
sizeOverLifetime: item.content.sizeOverLifetime,
|
|
22787
|
+
rotationOverLifetime: item.content.rotationOverLifetime,
|
|
22788
|
+
positionOverLifetime: item.content.positionOverLifetime,
|
|
22789
|
+
},
|
|
22790
|
+
},
|
|
22791
|
+
],
|
|
22792
|
+
});
|
|
22793
|
+
}
|
|
22794
|
+
if (item.type === ItemType.sprite) {
|
|
22795
|
+
tracks.push({
|
|
22796
|
+
clips: [
|
|
22797
|
+
{
|
|
22798
|
+
dataType: 'SpriteColorAnimationPlayableAsset',
|
|
22799
|
+
animationClip: {
|
|
22800
|
+
colorOverLifetime: item.content.colorOverLifetime,
|
|
22801
|
+
startColor: item.content.options.startColor,
|
|
22802
|
+
},
|
|
22803
|
+
},
|
|
22804
|
+
],
|
|
22805
|
+
});
|
|
22806
|
+
}
|
|
22807
|
+
// gizmo 的 target id 转换为新的 item guid
|
|
22808
|
+
if (item.content.options.target) {
|
|
22809
|
+
item.content.options.target = itemGuidMap[item.content.options.target];
|
|
22810
|
+
}
|
|
22811
|
+
// item 的 content 转为 component data 加入 JSONScene.components
|
|
22812
|
+
var uuid = generateGUID();
|
|
22813
|
+
if (item.type === ItemType.sprite) {
|
|
22814
|
+
item.components = [];
|
|
22815
|
+
result.components.push(item.content);
|
|
22816
|
+
item.content.id = uuid;
|
|
22817
|
+
item.content.dataType = DataType.SpriteComponent;
|
|
22818
|
+
item.content.item = { id: item.id };
|
|
22819
|
+
item.dataType = DataType.VFXItemData;
|
|
22820
|
+
//@ts-expect-error
|
|
22821
|
+
item.components.push({ id: item.content.id });
|
|
22822
|
+
}
|
|
22823
|
+
else if (item.type === ItemType.particle) {
|
|
22824
|
+
item.components = [];
|
|
22825
|
+
result.components.push(item.content);
|
|
22826
|
+
item.content.id = uuid;
|
|
22827
|
+
item.content.dataType = DataType.ParticleSystem;
|
|
22828
|
+
item.content.item = { id: item.id };
|
|
22829
|
+
item.dataType = DataType.VFXItemData;
|
|
22830
|
+
//@ts-expect-error
|
|
22831
|
+
item.components.push({ id: item.content.id });
|
|
22832
|
+
}
|
|
22833
|
+
else if (item.type === ItemType.mesh) {
|
|
22834
|
+
item.components = [];
|
|
22835
|
+
result.components.push(item.content);
|
|
22836
|
+
item.content.id = uuid;
|
|
22837
|
+
item.content.dataType = DataType.MeshComponent;
|
|
22838
|
+
item.content.item = { id: item.id };
|
|
22839
|
+
item.dataType = DataType.VFXItemData;
|
|
22840
|
+
//@ts-expect-error
|
|
22841
|
+
item.components.push({ id: item.content.id });
|
|
22842
|
+
}
|
|
22843
|
+
else if (item.type === ItemType.skybox) {
|
|
22844
|
+
item.components = [];
|
|
22845
|
+
result.components.push(item.content);
|
|
22846
|
+
item.content.id = uuid;
|
|
22847
|
+
item.content.dataType = DataType.SkyboxComponent;
|
|
22848
|
+
item.content.item = { id: item.id };
|
|
22849
|
+
item.dataType = DataType.VFXItemData;
|
|
22850
|
+
//@ts-expect-error
|
|
22851
|
+
item.components.push({ id: item.content.id });
|
|
22852
|
+
}
|
|
22853
|
+
else if (item.type === ItemType.light) {
|
|
22854
|
+
item.components = [];
|
|
22855
|
+
result.components.push(item.content);
|
|
22856
|
+
item.content.id = uuid;
|
|
22857
|
+
item.content.dataType = DataType.LightComponent;
|
|
22858
|
+
item.content.item = { id: item.id };
|
|
22859
|
+
item.dataType = DataType.VFXItemData;
|
|
22860
|
+
//@ts-expect-error
|
|
22861
|
+
item.components.push({ id: item.content.id });
|
|
22862
|
+
}
|
|
22863
|
+
else if (item.type === 'camera') {
|
|
22864
|
+
item.components = [];
|
|
22865
|
+
result.components.push(item.content);
|
|
22866
|
+
item.content.id = uuid;
|
|
22867
|
+
item.content.dataType = DataType.CameraComponent;
|
|
22868
|
+
item.content.item = { id: item.id };
|
|
22869
|
+
item.dataType = DataType.VFXItemData;
|
|
22870
|
+
//@ts-expect-error
|
|
22871
|
+
item.components.push({ id: item.content.id });
|
|
22872
|
+
}
|
|
22873
|
+
else if (item.type === ItemType.tree) {
|
|
22874
|
+
item.components = [];
|
|
22875
|
+
result.components.push(item.content);
|
|
22876
|
+
item.content.id = uuid;
|
|
22877
|
+
item.content.dataType = DataType.TreeComponent;
|
|
22878
|
+
item.content.item = { id: item.id };
|
|
22879
|
+
item.dataType = DataType.VFXItemData;
|
|
22880
|
+
//@ts-expect-error
|
|
22881
|
+
item.components.push({ id: item.content.id });
|
|
22882
|
+
}
|
|
22883
|
+
else if (item.type === ItemType.interact) {
|
|
22884
|
+
item.components = [];
|
|
22885
|
+
result.components.push(item.content);
|
|
22886
|
+
item.content.id = uuid;
|
|
22887
|
+
item.content.dataType = DataType.InteractComponent;
|
|
22888
|
+
item.content.item = { id: item.id };
|
|
22889
|
+
item.dataType = DataType.VFXItemData;
|
|
22890
|
+
//@ts-expect-error
|
|
22891
|
+
item.components.push({ id: item.content.id });
|
|
22892
|
+
}
|
|
22893
|
+
else if (item.type === ItemType.camera) {
|
|
22894
|
+
item.components = [];
|
|
22895
|
+
result.components.push(item.content);
|
|
22896
|
+
item.content.id = uuid;
|
|
22897
|
+
item.content.dataType = DataType.CameraController;
|
|
22898
|
+
item.content.item = { id: item.id };
|
|
22899
|
+
item.dataType = DataType.VFXItemData;
|
|
22900
|
+
//@ts-expect-error
|
|
22901
|
+
item.components.push({ id: item.content.id });
|
|
22902
|
+
}
|
|
22903
|
+
else if (item.type === ItemType.text) {
|
|
22904
|
+
item.components = [];
|
|
22905
|
+
result.components.push(item.content);
|
|
22906
|
+
item.content.id = uuid;
|
|
22907
|
+
item.content.dataType = DataType.TextComponent;
|
|
22908
|
+
item.content.item = { id: item.id };
|
|
22909
|
+
item.dataType = DataType.VFXItemData;
|
|
22910
|
+
//@ts-expect-error
|
|
22911
|
+
item.components.push({ id: item.content.id });
|
|
22912
|
+
}
|
|
22913
|
+
}
|
|
22914
|
+
}
|
|
22915
|
+
catch (e_3_1) { e_3 = { error: e_3_1 }; }
|
|
22916
|
+
finally {
|
|
22917
|
+
try {
|
|
22918
|
+
if (_o && !_o.done && (_j = _m.return)) _j.call(_m);
|
|
22919
|
+
}
|
|
22920
|
+
finally { if (e_3) throw e_3.error; }
|
|
22921
|
+
}
|
|
22922
|
+
};
|
|
22923
|
+
try {
|
|
22924
|
+
// 更正Composition.endBehavior
|
|
22925
|
+
for (var _f = __values(json.compositions), _g = _f.next(); !_g.done; _g = _f.next()) {
|
|
22926
|
+
var composition = _g.value;
|
|
22927
|
+
_loop_1(composition);
|
|
22928
|
+
}
|
|
22929
|
+
}
|
|
22930
|
+
catch (e_1_1) { e_1 = { error: e_1_1 }; }
|
|
22931
|
+
finally {
|
|
22932
|
+
try {
|
|
22933
|
+
if (_g && !_g.done && (_a = _f.return)) _a.call(_f);
|
|
22934
|
+
}
|
|
22935
|
+
finally { if (e_1) throw e_1.error; }
|
|
22936
|
+
}
|
|
22937
|
+
result.version = '3.0';
|
|
22938
|
+
return result;
|
|
22939
|
+
}
|
|
22369
22940
|
|
|
22370
22941
|
var v0 = /^(\d+)\.(\d+)\.(\d+)(-(\w+)\.\d+)?$/;
|
|
22371
22942
|
var standardVersion = /^(\d+)\.(\d+)$/;
|
|
@@ -22375,16 +22946,16 @@ function getStandardJSON(json) {
|
|
|
22375
22946
|
if (!json || typeof json !== 'object') {
|
|
22376
22947
|
throw Error('expect a json object');
|
|
22377
22948
|
}
|
|
22378
|
-
// 修正老版本数据中,meshItem以及lightItem结束行为错误问题
|
|
22949
|
+
// 修正老版本数据中,meshItem 以及 lightItem 结束行为错误问题
|
|
22379
22950
|
version22Migration(json);
|
|
22380
22951
|
if (v0.test(json.version)) {
|
|
22381
22952
|
reverseParticle = ((_a = (/^(\d+)/).exec(json.version)) === null || _a === void 0 ? void 0 : _a[0]) === '0';
|
|
22382
|
-
return version21Migration(getStandardJSONFromV0(json));
|
|
22953
|
+
return version30Migration(version21Migration(getStandardJSONFromV0(json)));
|
|
22383
22954
|
}
|
|
22384
22955
|
var mainVersion = (_b = standardVersion.exec(json.version)) === null || _b === void 0 ? void 0 : _b[1];
|
|
22385
22956
|
if (mainVersion) {
|
|
22386
|
-
if (Number(mainVersion) <
|
|
22387
|
-
return version21Migration(json);
|
|
22957
|
+
if (Number(mainVersion) < 3) {
|
|
22958
|
+
return version30Migration(version21Migration(json));
|
|
22388
22959
|
}
|
|
22389
22960
|
return json;
|
|
22390
22961
|
}
|
|
@@ -22708,7 +23279,7 @@ function version3Migration(scene) {
|
|
|
22708
23279
|
try {
|
|
22709
23280
|
for (var _j = __values$1(ecScene.items), _k = _j.next(); !_k.done; _k = _j.next()) {
|
|
22710
23281
|
var item = _k.value;
|
|
22711
|
-
itemGuidMap[item.id] = generateGUID();
|
|
23282
|
+
itemGuidMap[item.id] = generateGUID$1();
|
|
22712
23283
|
// TODO: 编辑器测试用,上线后删除
|
|
22713
23284
|
//@ts-expect-error
|
|
22714
23285
|
item.oldId = item.id;
|
|
@@ -22764,7 +23335,7 @@ function version3Migration(scene) {
|
|
|
22764
23335
|
// texture 增加 id 和 dataType
|
|
22765
23336
|
for (var _q = __values$1(scene.textureOptions), _r = _q.next(); !_r.done; _r = _q.next()) {
|
|
22766
23337
|
var texture = _r.value;
|
|
22767
|
-
texture.id = generateGUID();
|
|
23338
|
+
texture.id = generateGUID$1();
|
|
22768
23339
|
texture.dataType = exports.DataType.Texture;
|
|
22769
23340
|
}
|
|
22770
23341
|
}
|
|
@@ -22784,23 +23355,15 @@ function version3Migration(scene) {
|
|
|
22784
23355
|
var item = _t.value;
|
|
22785
23356
|
// 原 texture 索引转为统一 guid 索引
|
|
22786
23357
|
if (item.content) {
|
|
22787
|
-
//@ts-expect-error
|
|
22788
23358
|
if (item.content.renderer) {
|
|
22789
|
-
//@ts-expect-error
|
|
22790
23359
|
if (item.content.renderer.texture !== undefined) {
|
|
22791
|
-
//@ts-expect-error
|
|
22792
23360
|
var oldTextureId = item.content.renderer.texture;
|
|
22793
|
-
//@ts-expect-error
|
|
22794
23361
|
item.content.renderer.texture = { id: scene.textureOptions[oldTextureId].id };
|
|
22795
23362
|
}
|
|
22796
23363
|
}
|
|
22797
|
-
//@ts-expect-error
|
|
22798
23364
|
if (item.content.trails) {
|
|
22799
|
-
//@ts-expect-error
|
|
22800
23365
|
if (item.content.trails.texture !== undefined) {
|
|
22801
|
-
//@ts-expect-error
|
|
22802
23366
|
var oldTextureId = item.content.trails.texture;
|
|
22803
|
-
//@ts-expect-error
|
|
22804
23367
|
item.content.trails.texture = { id: scene.textureOptions[oldTextureId].id };
|
|
22805
23368
|
}
|
|
22806
23369
|
}
|
|
@@ -22811,12 +23374,14 @@ function version3Migration(scene) {
|
|
|
22811
23374
|
var rotation = item.transform.rotation;
|
|
22812
23375
|
var scale = item.transform.scale;
|
|
22813
23376
|
if (!position) {
|
|
23377
|
+
//@ts-expect-error
|
|
22814
23378
|
position = [0, 0, 0];
|
|
22815
23379
|
}
|
|
22816
23380
|
if (!rotation) {
|
|
22817
23381
|
rotation = [0, 0, 0];
|
|
22818
23382
|
}
|
|
22819
23383
|
if (!scale) {
|
|
23384
|
+
//@ts-expect-error
|
|
22820
23385
|
scale = [1, 1, 1];
|
|
22821
23386
|
}
|
|
22822
23387
|
item.transform = {
|
|
@@ -22837,12 +23402,9 @@ function version3Migration(scene) {
|
|
|
22837
23402
|
// sprite 的 anchor 修正
|
|
22838
23403
|
if (item.type === ItemType$1.sprite) {
|
|
22839
23404
|
var content = item.content;
|
|
22840
|
-
//@ts-expect-error
|
|
22841
23405
|
if (!content.renderer) {
|
|
22842
|
-
//@ts-expect-error
|
|
22843
23406
|
content.renderer = {};
|
|
22844
23407
|
}
|
|
22845
|
-
//@ts-expect-error
|
|
22846
23408
|
var renderer = content.renderer;
|
|
22847
23409
|
var realAnchor = convertAnchor(renderer.anchor, renderer.particleOrigin);
|
|
22848
23410
|
//@ts-expect-error
|
|
@@ -22860,14 +23422,10 @@ function version3Migration(scene) {
|
|
|
22860
23422
|
}
|
|
22861
23423
|
if (item.type === ItemType$1.particle) {
|
|
22862
23424
|
var content = item.content;
|
|
22863
|
-
//@ts-expect-error
|
|
22864
23425
|
if (!content.renderer) {
|
|
22865
|
-
//@ts-expect-error
|
|
22866
23426
|
content.renderer = {};
|
|
22867
23427
|
}
|
|
22868
|
-
//@ts-expect-error
|
|
22869
23428
|
var renderer = content.renderer;
|
|
22870
|
-
//@ts-expect-error
|
|
22871
23429
|
content.renderer.anchor = convertAnchor(renderer.anchor, renderer.particleOrigin);
|
|
22872
23430
|
}
|
|
22873
23431
|
// item 的 endbehaviour 兼容
|
|
@@ -22876,9 +23434,7 @@ function version3Migration(scene) {
|
|
|
22876
23434
|
item.endBehavior = END_BEHAVIOR_FREEZE$1;
|
|
22877
23435
|
}
|
|
22878
23436
|
// 动画数据转化 TODO: 动画数据移到 TimelineComponentData
|
|
22879
|
-
//@ts-expect-error
|
|
22880
23437
|
item.content.tracks = [];
|
|
22881
|
-
//@ts-expect-error
|
|
22882
23438
|
var tracks = item.content.tracks;
|
|
22883
23439
|
if (item.type !== ItemType$1.particle) {
|
|
22884
23440
|
tracks.push({
|
|
@@ -22886,11 +23442,8 @@ function version3Migration(scene) {
|
|
|
22886
23442
|
{
|
|
22887
23443
|
dataType: 'TransformAnimationPlayableAsset',
|
|
22888
23444
|
animationClip: {
|
|
22889
|
-
//@ts-expect-error
|
|
22890
23445
|
sizeOverLifetime: item.content.sizeOverLifetime,
|
|
22891
|
-
//@ts-expect-error
|
|
22892
23446
|
rotationOverLifetime: item.content.rotationOverLifetime,
|
|
22893
|
-
//@ts-expect-error
|
|
22894
23447
|
positionOverLifetime: item.content.positionOverLifetime,
|
|
22895
23448
|
},
|
|
22896
23449
|
},
|
|
@@ -22903,9 +23456,7 @@ function version3Migration(scene) {
|
|
|
22903
23456
|
{
|
|
22904
23457
|
dataType: 'SpriteColorAnimationPlayableAsset',
|
|
22905
23458
|
animationClip: {
|
|
22906
|
-
//@ts-expect-error
|
|
22907
23459
|
colorOverLifetime: item.content.colorOverLifetime,
|
|
22908
|
-
//@ts-expect-error
|
|
22909
23460
|
startColor: item.content.options.startColor,
|
|
22910
23461
|
},
|
|
22911
23462
|
},
|
|
@@ -22913,169 +23464,107 @@ function version3Migration(scene) {
|
|
|
22913
23464
|
});
|
|
22914
23465
|
}
|
|
22915
23466
|
// gizmo 的 target id 转换为新的 item guid
|
|
22916
|
-
|
|
22917
|
-
if (item.content.options.target) {
|
|
22918
|
-
//@ts-expect-error
|
|
23467
|
+
if (item.content && item.content.options && item.content.options.target) {
|
|
22919
23468
|
item.content.options.target = itemGuidMap[item.content.options.target];
|
|
22920
23469
|
}
|
|
22921
23470
|
// item 的 content 转为 component data 加入 JSONScene.components
|
|
22922
|
-
var uuid = v4().replace(/-/g, '');
|
|
23471
|
+
var uuid = v4$1().replace(/-/g, '');
|
|
22923
23472
|
if (item.type === ItemType$1.sprite) {
|
|
22924
|
-
//@ts-expect-error
|
|
22925
23473
|
item.components = [];
|
|
22926
|
-
//@ts-expect-error
|
|
22927
23474
|
components.push(item.content);
|
|
22928
|
-
//@ts-expect-error
|
|
22929
23475
|
item.content.id = uuid;
|
|
22930
|
-
//@ts-expect-error
|
|
22931
23476
|
item.content.dataType = exports.DataType.SpriteComponent;
|
|
22932
|
-
//@ts-expect-error
|
|
22933
23477
|
item.content.item = { id: item.id };
|
|
22934
|
-
//@ts-expect-error
|
|
22935
23478
|
item.dataType = exports.DataType.VFXItemData;
|
|
22936
23479
|
//@ts-expect-error
|
|
22937
23480
|
item.components.push({ id: item.content.id });
|
|
22938
23481
|
}
|
|
22939
23482
|
else if (item.type === ItemType$1.particle) {
|
|
22940
|
-
//@ts-expect-error
|
|
22941
23483
|
item.components = [];
|
|
22942
|
-
//@ts-expect-error
|
|
22943
23484
|
components.push(item.content);
|
|
22944
|
-
//@ts-expect-error
|
|
22945
23485
|
item.content.id = uuid;
|
|
22946
|
-
//@ts-expect-error
|
|
22947
23486
|
item.content.dataType = exports.DataType.ParticleSystem;
|
|
22948
|
-
//@ts-expect-error
|
|
22949
23487
|
item.content.item = { id: item.id };
|
|
22950
|
-
//@ts-expect-error
|
|
22951
23488
|
item.dataType = exports.DataType.VFXItemData;
|
|
22952
23489
|
//@ts-expect-error
|
|
22953
23490
|
item.components.push({ id: item.content.id });
|
|
22954
23491
|
}
|
|
22955
23492
|
else if (item.type === ItemType$1.mesh) {
|
|
22956
|
-
//@ts-expect-error
|
|
22957
23493
|
item.components = [];
|
|
22958
|
-
//@ts-expect-error
|
|
22959
23494
|
components.push(item.content);
|
|
22960
|
-
//@ts-expect-error
|
|
22961
23495
|
item.content.id = uuid;
|
|
22962
|
-
//@ts-expect-error
|
|
22963
23496
|
item.content.dataType = exports.DataType.MeshComponent;
|
|
22964
|
-
//@ts-expect-error
|
|
22965
23497
|
item.content.item = { id: item.id };
|
|
22966
|
-
//@ts-expect-error
|
|
22967
23498
|
item.dataType = exports.DataType.VFXItemData;
|
|
22968
23499
|
//@ts-expect-error
|
|
22969
23500
|
item.components.push({ id: item.content.id });
|
|
22970
23501
|
}
|
|
22971
23502
|
else if (item.type === ItemType$1.skybox) {
|
|
22972
|
-
//@ts-expect-error
|
|
22973
23503
|
item.components = [];
|
|
22974
|
-
//@ts-expect-error
|
|
22975
23504
|
components.push(item.content);
|
|
22976
|
-
//@ts-expect-error
|
|
22977
23505
|
item.content.id = uuid;
|
|
22978
|
-
//@ts-expect-error
|
|
22979
23506
|
item.content.dataType = exports.DataType.SkyboxComponent;
|
|
22980
|
-
//@ts-expect-error
|
|
22981
23507
|
item.content.item = { id: item.id };
|
|
22982
|
-
//@ts-expect-error
|
|
22983
23508
|
item.dataType = exports.DataType.VFXItemData;
|
|
22984
23509
|
//@ts-expect-error
|
|
22985
23510
|
item.components.push({ id: item.content.id });
|
|
22986
23511
|
}
|
|
22987
23512
|
else if (item.type === ItemType$1.light) {
|
|
22988
|
-
//@ts-expect-error
|
|
22989
23513
|
item.components = [];
|
|
22990
|
-
//@ts-expect-error
|
|
22991
23514
|
components.push(item.content);
|
|
22992
|
-
//@ts-expect-error
|
|
22993
23515
|
item.content.id = uuid;
|
|
22994
|
-
//@ts-expect-error
|
|
22995
23516
|
item.content.dataType = exports.DataType.LightComponent;
|
|
22996
|
-
//@ts-expect-error
|
|
22997
23517
|
item.content.item = { id: item.id };
|
|
22998
|
-
//@ts-expect-error
|
|
22999
23518
|
item.dataType = exports.DataType.VFXItemData;
|
|
23000
23519
|
//@ts-expect-error
|
|
23001
23520
|
item.components.push({ id: item.content.id });
|
|
23002
23521
|
}
|
|
23003
23522
|
else if (item.type === 'camera') {
|
|
23004
|
-
//@ts-expect-error
|
|
23005
23523
|
item.components = [];
|
|
23006
|
-
//@ts-expect-error
|
|
23007
23524
|
components.push(item.content);
|
|
23008
|
-
//@ts-expect-error
|
|
23009
23525
|
item.content.id = uuid;
|
|
23010
|
-
//@ts-expect-error
|
|
23011
23526
|
item.content.dataType = exports.DataType.CameraComponent;
|
|
23012
|
-
//@ts-expect-error
|
|
23013
23527
|
item.content.item = { id: item.id };
|
|
23014
|
-
//@ts-expect-error
|
|
23015
23528
|
item.dataType = exports.DataType.VFXItemData;
|
|
23016
23529
|
//@ts-expect-error
|
|
23017
23530
|
item.components.push({ id: item.content.id });
|
|
23018
23531
|
}
|
|
23019
23532
|
else if (item.type === ItemType$1.tree) {
|
|
23020
|
-
//@ts-expect-error
|
|
23021
23533
|
item.components = [];
|
|
23022
|
-
//@ts-expect-error
|
|
23023
23534
|
components.push(item.content);
|
|
23024
|
-
//@ts-expect-error
|
|
23025
23535
|
item.content.id = uuid;
|
|
23026
|
-
//@ts-expect-error
|
|
23027
23536
|
item.content.dataType = exports.DataType.TreeComponent;
|
|
23028
|
-
//@ts-expect-error
|
|
23029
23537
|
item.content.item = { id: item.id };
|
|
23030
|
-
//@ts-expect-error
|
|
23031
23538
|
item.dataType = exports.DataType.VFXItemData;
|
|
23032
23539
|
//@ts-expect-error
|
|
23033
23540
|
item.components.push({ id: item.content.id });
|
|
23034
23541
|
}
|
|
23035
23542
|
else if (item.type === ItemType$1.interact) {
|
|
23036
|
-
//@ts-expect-error
|
|
23037
23543
|
item.components = [];
|
|
23038
|
-
//@ts-expect-error
|
|
23039
23544
|
components.push(item.content);
|
|
23040
|
-
//@ts-expect-error
|
|
23041
23545
|
item.content.id = uuid;
|
|
23042
|
-
//@ts-expect-error
|
|
23043
23546
|
item.content.dataType = exports.DataType.InteractComponent;
|
|
23044
|
-
//@ts-expect-error
|
|
23045
23547
|
item.content.item = { id: item.id };
|
|
23046
|
-
//@ts-expect-error
|
|
23047
23548
|
item.dataType = exports.DataType.VFXItemData;
|
|
23048
23549
|
//@ts-expect-error
|
|
23049
23550
|
item.components.push({ id: item.content.id });
|
|
23050
23551
|
}
|
|
23051
23552
|
else if (item.type === ItemType$1.camera) {
|
|
23052
|
-
//@ts-expect-error
|
|
23053
23553
|
item.components = [];
|
|
23054
|
-
//@ts-expect-error
|
|
23055
23554
|
components.push(item.content);
|
|
23056
|
-
//@ts-expect-error
|
|
23057
23555
|
item.content.id = uuid;
|
|
23058
|
-
//@ts-expect-error
|
|
23059
23556
|
item.content.dataType = exports.DataType.CameraController;
|
|
23060
|
-
//@ts-expect-error
|
|
23061
23557
|
item.content.item = { id: item.id };
|
|
23062
|
-
//@ts-expect-error
|
|
23063
23558
|
item.dataType = exports.DataType.VFXItemData;
|
|
23064
23559
|
//@ts-expect-error
|
|
23065
23560
|
item.components.push({ id: item.content.id });
|
|
23066
23561
|
}
|
|
23067
23562
|
else if (item.type === ItemType$1.text) {
|
|
23068
|
-
//@ts-expect-error
|
|
23069
23563
|
item.components = [];
|
|
23070
|
-
//@ts-expect-error
|
|
23071
23564
|
components.push(item.content);
|
|
23072
|
-
//@ts-expect-error
|
|
23073
23565
|
item.content.id = uuid;
|
|
23074
|
-
//@ts-expect-error
|
|
23075
23566
|
item.content.dataType = exports.DataType.TextComponent;
|
|
23076
|
-
//@ts-expect-error
|
|
23077
23567
|
item.content.item = { id: item.id };
|
|
23078
|
-
//@ts-expect-error
|
|
23079
23568
|
item.dataType = exports.DataType.VFXItemData;
|
|
23080
23569
|
//@ts-expect-error
|
|
23081
23570
|
item.components.push({ id: item.content.id });
|
|
@@ -23099,7 +23588,7 @@ function convertAnchor(anchor, particleOrigin) {
|
|
|
23099
23588
|
return [anchor[0] - 0.5, 0.5 - anchor[1]];
|
|
23100
23589
|
}
|
|
23101
23590
|
else if (particleOrigin) {
|
|
23102
|
-
return particleOriginTranslateMap[particleOrigin];
|
|
23591
|
+
return particleOriginTranslateMap$1[particleOrigin];
|
|
23103
23592
|
}
|
|
23104
23593
|
else {
|
|
23105
23594
|
return [0, 0];
|
|
@@ -23377,16 +23866,17 @@ var AssetManager = /** @class */ (function () {
|
|
|
23377
23866
|
};
|
|
23378
23867
|
AssetManager.prototype.processBins = function (bins) {
|
|
23379
23868
|
return __awaiter(this, void 0, void 0, function () {
|
|
23380
|
-
var renderLevel, jobs;
|
|
23869
|
+
var renderLevel, baseUrl, jobs;
|
|
23381
23870
|
var _this = this;
|
|
23382
23871
|
return __generator(this, function (_a) {
|
|
23383
23872
|
renderLevel = this.options.renderLevel;
|
|
23873
|
+
baseUrl = this.baseUrl;
|
|
23384
23874
|
jobs = bins.map(function (bin) {
|
|
23385
23875
|
if (bin instanceof ArrayBuffer) {
|
|
23386
23876
|
return bin;
|
|
23387
23877
|
}
|
|
23388
23878
|
if (passRenderLevel(bin.renderLevel, renderLevel)) {
|
|
23389
|
-
return _this.loadBins(bin.url);
|
|
23879
|
+
return _this.loadBins(new weapp.URL(bin.url, baseUrl).href);
|
|
23390
23880
|
}
|
|
23391
23881
|
throw new Error("Invalid bins source: ".concat(JSON.stringify(bins)));
|
|
23392
23882
|
});
|
|
@@ -23404,13 +23894,14 @@ var AssetManager = /** @class */ (function () {
|
|
|
23404
23894
|
return [2 /*return*/];
|
|
23405
23895
|
}
|
|
23406
23896
|
jobs = fonts.map(function (font) { return __awaiter(_this, void 0, void 0, function () {
|
|
23407
|
-
var fontFace;
|
|
23897
|
+
var url, fontFace;
|
|
23408
23898
|
var _a;
|
|
23409
23899
|
return __generator(this, function (_b) {
|
|
23410
23900
|
switch (_b.label) {
|
|
23411
23901
|
case 0:
|
|
23412
23902
|
if (!(font.fontURL && !AssetManager.fonts.has(font.fontFamily))) return [3 /*break*/, 4];
|
|
23413
|
-
|
|
23903
|
+
url = new weapp.URL(font.fontURL, this.baseUrl).href;
|
|
23904
|
+
fontFace = new FontFace((_a = font.fontFamily) !== null && _a !== void 0 ? _a : '', 'url(' + url + ')');
|
|
23414
23905
|
_b.label = 1;
|
|
23415
23906
|
case 1:
|
|
23416
23907
|
_b.trys.push([1, 3, , 4]);
|
|
@@ -23423,7 +23914,7 @@ var AssetManager = /** @class */ (function () {
|
|
|
23423
23914
|
return [3 /*break*/, 4];
|
|
23424
23915
|
case 3:
|
|
23425
23916
|
_b.sent();
|
|
23426
|
-
logger.warn("Invalid fonts source: ".concat(JSON.stringify(
|
|
23917
|
+
logger.warn("Invalid fonts source: ".concat(JSON.stringify(url)));
|
|
23427
23918
|
return [3 /*break*/, 4];
|
|
23428
23919
|
case 4: return [2 /*return*/];
|
|
23429
23920
|
}
|
|
@@ -23672,7 +24163,7 @@ function createTextureOptionsBySource(image, sourceFrom) {
|
|
|
23672
24163
|
return image.source;
|
|
23673
24164
|
}
|
|
23674
24165
|
else if (image instanceof weapp.HTMLImageElement ||
|
|
23675
|
-
image
|
|
24166
|
+
isCanvas(image)) {
|
|
23676
24167
|
return {
|
|
23677
24168
|
image: image,
|
|
23678
24169
|
sourceType: exports.TextureSourceType.image,
|
|
@@ -23734,6 +24225,11 @@ function base64ToFile(base64, filename, contentType) {
|
|
|
23734
24225
|
var file = new File([blob], filename, { type: contentType });
|
|
23735
24226
|
return file;
|
|
23736
24227
|
}
|
|
24228
|
+
function isCanvas(cavnas) {
|
|
24229
|
+
var _a;
|
|
24230
|
+
// 小程序 Canvas 无法使用 instanceof HTMLCanvasElement 判断
|
|
24231
|
+
return typeof cavnas === 'object' && cavnas !== null && ((_a = cavnas.tagName) === null || _a === void 0 ? void 0 : _a.toUpperCase()) === 'CANVAS';
|
|
24232
|
+
}
|
|
23737
24233
|
|
|
23738
24234
|
var tmpScale = new Vector3(1, 1, 1);
|
|
23739
24235
|
/**
|
|
@@ -23953,8 +24449,9 @@ var Camera = /** @class */ (function () {
|
|
|
23953
24449
|
Camera.prototype.getInverseVPRatio = function (z) {
|
|
23954
24450
|
var pos = new Vector3(0, 0, z);
|
|
23955
24451
|
var mat = this.getViewProjectionMatrix();
|
|
23956
|
-
var
|
|
23957
|
-
|
|
24452
|
+
var inverseVP = this.getInverseViewProjectionMatrix();
|
|
24453
|
+
var nz = mat.projectPoint(pos).z;
|
|
24454
|
+
return inverseVP.projectPoint(new Vector3(1, 1, nz));
|
|
23958
24455
|
};
|
|
23959
24456
|
/**
|
|
23960
24457
|
* 设置相机的旋转四元数
|
|
@@ -23966,7 +24463,6 @@ var Camera = /** @class */ (function () {
|
|
|
23966
24463
|
this.dirty = true;
|
|
23967
24464
|
}
|
|
23968
24465
|
else {
|
|
23969
|
-
this.options.quat;
|
|
23970
24466
|
if (!this.options.quat.equals(value)) {
|
|
23971
24467
|
this.options.quat.copyFrom(value);
|
|
23972
24468
|
this.dirty = true;
|
|
@@ -24134,8 +24630,7 @@ var CompositionComponent = /** @class */ (function (_super) {
|
|
|
24134
24630
|
}
|
|
24135
24631
|
item.getComponent(CompositionComponent).createContent();
|
|
24136
24632
|
}
|
|
24137
|
-
else if (itemData.type ===
|
|
24138
|
-
itemData.type === ItemType$1.sprite ||
|
|
24633
|
+
else if (itemData.type === ItemType$1.sprite ||
|
|
24139
24634
|
itemData.type === ItemType$1.text ||
|
|
24140
24635
|
itemData.type === ItemType$1.particle ||
|
|
24141
24636
|
itemData.type === ItemType$1.mesh ||
|
|
@@ -24153,20 +24648,7 @@ var CompositionComponent = /** @class */ (function (_super) {
|
|
|
24153
24648
|
item = new VFXItem(this.engine, itemData);
|
|
24154
24649
|
item.composition = this.item.composition;
|
|
24155
24650
|
// 兼容老的数据代码,json 更新后可移除
|
|
24156
|
-
|
|
24157
|
-
case ItemType$1.text: {
|
|
24158
|
-
// 添加文本组件
|
|
24159
|
-
var textItem = new TextComponent(this.engine, itemData.content);
|
|
24160
|
-
textItem.item = item;
|
|
24161
|
-
item.components.push(textItem);
|
|
24162
|
-
item.rendererComponents.push(textItem);
|
|
24163
|
-
item._content = textItem;
|
|
24164
|
-
break;
|
|
24165
|
-
}
|
|
24166
|
-
default: {
|
|
24167
|
-
item = createVFXItem(itemData, this.item.composition);
|
|
24168
|
-
}
|
|
24169
|
-
}
|
|
24651
|
+
item = createVFXItem(itemData, this.item.composition);
|
|
24170
24652
|
}
|
|
24171
24653
|
item.parent = this.item;
|
|
24172
24654
|
// 相机不跟随合成移动
|
|
@@ -25556,10 +26038,8 @@ var Engine = /** @class */ (function () {
|
|
|
25556
26038
|
Engine.prototype.addPackageDatas = function (scene) {
|
|
25557
26039
|
var e_1, _a, e_2, _b, e_3, _c, e_4, _d, e_5, _e, e_6, _f;
|
|
25558
26040
|
var jsonScene = scene.jsonScene;
|
|
25559
|
-
//@ts-expect-error
|
|
25560
26041
|
if (jsonScene.items) {
|
|
25561
26042
|
try {
|
|
25562
|
-
//@ts-expect-error
|
|
25563
26043
|
for (var _g = __values$1(jsonScene.items), _h = _g.next(); !_h.done; _h = _g.next()) {
|
|
25564
26044
|
var vfxItemData = _h.value;
|
|
25565
26045
|
this.addEffectsObjectData(vfxItemData);
|
|
@@ -25573,10 +26053,8 @@ var Engine = /** @class */ (function () {
|
|
|
25573
26053
|
finally { if (e_1) throw e_1.error; }
|
|
25574
26054
|
}
|
|
25575
26055
|
}
|
|
25576
|
-
//@ts-expect-error
|
|
25577
26056
|
if (jsonScene.materials) {
|
|
25578
26057
|
try {
|
|
25579
|
-
//@ts-expect-error
|
|
25580
26058
|
for (var _j = __values$1(jsonScene.materials), _k = _j.next(); !_k.done; _k = _j.next()) {
|
|
25581
26059
|
var materialData = _k.value;
|
|
25582
26060
|
this.addEffectsObjectData(materialData);
|
|
@@ -25590,10 +26068,8 @@ var Engine = /** @class */ (function () {
|
|
|
25590
26068
|
finally { if (e_2) throw e_2.error; }
|
|
25591
26069
|
}
|
|
25592
26070
|
}
|
|
25593
|
-
//@ts-expect-error
|
|
25594
26071
|
if (jsonScene.shaders) {
|
|
25595
26072
|
try {
|
|
25596
|
-
//@ts-expect-error
|
|
25597
26073
|
for (var _l = __values$1(jsonScene.shaders), _m = _l.next(); !_m.done; _m = _l.next()) {
|
|
25598
26074
|
var shaderData = _m.value;
|
|
25599
26075
|
this.addEffectsObjectData(shaderData);
|
|
@@ -25607,10 +26083,8 @@ var Engine = /** @class */ (function () {
|
|
|
25607
26083
|
finally { if (e_3) throw e_3.error; }
|
|
25608
26084
|
}
|
|
25609
26085
|
}
|
|
25610
|
-
//@ts-expect-error
|
|
25611
26086
|
if (jsonScene.geometries) {
|
|
25612
26087
|
try {
|
|
25613
|
-
//@ts-expect-error
|
|
25614
26088
|
for (var _o = __values$1(jsonScene.geometries), _p = _o.next(); !_p.done; _p = _o.next()) {
|
|
25615
26089
|
var geometryData = _p.value;
|
|
25616
26090
|
this.addEffectsObjectData(geometryData);
|
|
@@ -25624,10 +26098,8 @@ var Engine = /** @class */ (function () {
|
|
|
25624
26098
|
finally { if (e_4) throw e_4.error; }
|
|
25625
26099
|
}
|
|
25626
26100
|
}
|
|
25627
|
-
//@ts-expect-error
|
|
25628
26101
|
if (jsonScene.components) {
|
|
25629
26102
|
try {
|
|
25630
|
-
//@ts-expect-error
|
|
25631
26103
|
for (var _q = __values$1(jsonScene.components), _r = _q.next(); !_r.done; _r = _q.next()) {
|
|
25632
26104
|
var componentData = _r.value;
|
|
25633
26105
|
this.addEffectsObjectData(componentData);
|
|
@@ -26592,7 +27064,7 @@ var GLRendererInternal = /** @class */ (function () {
|
|
|
26592
27064
|
}
|
|
26593
27065
|
var glGeometry = geometry;
|
|
26594
27066
|
var glMaterial = material;
|
|
26595
|
-
var program = glMaterial.
|
|
27067
|
+
var program = glMaterial.shaderVariant.program;
|
|
26596
27068
|
if (!program) {
|
|
26597
27069
|
console.warn('Material ' + glMaterial.name + ' 的shader着色器程序未初始化。');
|
|
26598
27070
|
return;
|
|
@@ -27462,8 +27934,8 @@ var GLMaterialState = /** @class */ (function () {
|
|
|
27462
27934
|
var Vector4 = Vector4$1, Matrix4 = Matrix4$1;
|
|
27463
27935
|
var GLMaterial = /** @class */ (function (_super) {
|
|
27464
27936
|
__extends(GLMaterial, _super);
|
|
27465
|
-
function GLMaterial() {
|
|
27466
|
-
var _this = _super
|
|
27937
|
+
function GLMaterial(engine, props) {
|
|
27938
|
+
var _this = _super.call(this, engine, props) || this;
|
|
27467
27939
|
// material存放的uniform数据。
|
|
27468
27940
|
_this.floats = {};
|
|
27469
27941
|
_this.ints = {};
|
|
@@ -27481,7 +27953,13 @@ var GLMaterial = /** @class */ (function (_super) {
|
|
|
27481
27953
|
_this.samplers = []; // material存放的sampler名称。
|
|
27482
27954
|
_this.uniforms = []; // material存放的uniform名称(不包括sampler)。
|
|
27483
27955
|
_this.uniformDirtyFlag = true;
|
|
27956
|
+
_this.macrosDirtyFlag = true;
|
|
27957
|
+
_this.macros = {};
|
|
27484
27958
|
_this.glMaterialState = new GLMaterialState();
|
|
27959
|
+
if (props) {
|
|
27960
|
+
_this.shader = new Shader(engine);
|
|
27961
|
+
_this.shader.shaderData = __assign$1(__assign$1({}, props.shader), { id: generateGUID$1(), dataType: exports.DataType.Shader });
|
|
27962
|
+
}
|
|
27485
27963
|
return _this;
|
|
27486
27964
|
}
|
|
27487
27965
|
Object.defineProperty(GLMaterial.prototype, "blending", {
|
|
@@ -27704,14 +28182,20 @@ var GLMaterial = /** @class */ (function (_super) {
|
|
|
27704
28182
|
enumerable: false,
|
|
27705
28183
|
configurable: true
|
|
27706
28184
|
});
|
|
27707
|
-
GLMaterial.prototype.
|
|
27708
|
-
|
|
28185
|
+
GLMaterial.prototype.enableMacro = function (keyword) {
|
|
28186
|
+
if (!this.isMacroEnabled(keyword)) {
|
|
28187
|
+
this.macros[keyword] = true;
|
|
28188
|
+
this.macrosDirtyFlag = true;
|
|
28189
|
+
}
|
|
27709
28190
|
};
|
|
27710
|
-
GLMaterial.prototype.
|
|
27711
|
-
|
|
28191
|
+
GLMaterial.prototype.disableMacro = function (keyword) {
|
|
28192
|
+
if (this.isMacroEnabled(keyword)) {
|
|
28193
|
+
delete this.macros[keyword];
|
|
28194
|
+
this.macrosDirtyFlag = true;
|
|
28195
|
+
}
|
|
27712
28196
|
};
|
|
27713
|
-
GLMaterial.prototype.
|
|
27714
|
-
|
|
28197
|
+
GLMaterial.prototype.isMacroEnabled = function (keyword) {
|
|
28198
|
+
return this.macros[keyword] !== undefined;
|
|
27715
28199
|
};
|
|
27716
28200
|
// TODO 待废弃 兼容 model/spine 插件 改造后可移除
|
|
27717
28201
|
GLMaterial.prototype.createMaterialStates = function (states) {
|
|
@@ -27742,11 +28226,11 @@ var GLMaterial = /** @class */ (function (_super) {
|
|
|
27742
28226
|
}
|
|
27743
28227
|
var glEngine = this.engine;
|
|
27744
28228
|
glEngine.addMaterial(this);
|
|
27745
|
-
if (!this.shader) {
|
|
27746
|
-
|
|
27747
|
-
this.
|
|
28229
|
+
if (!this.shaderVariant || this.shaderVariant.shader !== this.shader || this.macrosDirtyFlag) {
|
|
28230
|
+
this.shaderVariant = this.shader.createVariant(this.macros);
|
|
28231
|
+
this.macrosDirtyFlag = false;
|
|
27748
28232
|
}
|
|
27749
|
-
this.
|
|
28233
|
+
this.shaderVariant.initialize(glEngine);
|
|
27750
28234
|
Object.keys(this.textures).forEach(function (key) {
|
|
27751
28235
|
var texture = _this.textures[key];
|
|
27752
28236
|
if (!isFunction(texture.initialize)) {
|
|
@@ -27764,7 +28248,7 @@ var GLMaterial = /** @class */ (function (_super) {
|
|
|
27764
28248
|
var e_1, _a, e_2, _b;
|
|
27765
28249
|
var engine = renderer.engine;
|
|
27766
28250
|
var pipelineContext = engine.getGLPipelineContext();
|
|
27767
|
-
this.
|
|
28251
|
+
this.shaderVariant.program.bind();
|
|
27768
28252
|
this.setupStates(pipelineContext);
|
|
27769
28253
|
var name;
|
|
27770
28254
|
if (globalUniforms) {
|
|
@@ -27801,19 +28285,19 @@ var GLMaterial = /** @class */ (function (_super) {
|
|
|
27801
28285
|
}
|
|
27802
28286
|
// 更新 cached uniform location
|
|
27803
28287
|
if (this.uniformDirtyFlag) {
|
|
27804
|
-
this.
|
|
28288
|
+
this.shaderVariant.fillShaderInformation(this.uniforms, this.samplers);
|
|
27805
28289
|
this.uniformDirtyFlag = false;
|
|
27806
28290
|
}
|
|
27807
28291
|
if (globalUniforms) {
|
|
27808
28292
|
// 设置全局 uniform
|
|
27809
28293
|
for (name in globalUniforms.floats) {
|
|
27810
|
-
this.
|
|
28294
|
+
this.shaderVariant.setFloat(name, globalUniforms.floats[name]);
|
|
27811
28295
|
}
|
|
27812
28296
|
for (name in globalUniforms.ints) {
|
|
27813
|
-
this.
|
|
28297
|
+
this.shaderVariant.setInt(name, globalUniforms.ints[name]);
|
|
27814
28298
|
}
|
|
27815
28299
|
for (name in globalUniforms.matrices) {
|
|
27816
|
-
this.
|
|
28300
|
+
this.shaderVariant.setMatrix(name, globalUniforms.matrices[name]);
|
|
27817
28301
|
}
|
|
27818
28302
|
}
|
|
27819
28303
|
// 检查贴图数据是否初始化。
|
|
@@ -27823,43 +28307,43 @@ var GLMaterial = /** @class */ (function (_super) {
|
|
|
27823
28307
|
}
|
|
27824
28308
|
}
|
|
27825
28309
|
for (name in this.floats) {
|
|
27826
|
-
this.
|
|
28310
|
+
this.shaderVariant.setFloat(name, this.floats[name]);
|
|
27827
28311
|
}
|
|
27828
28312
|
for (name in this.ints) {
|
|
27829
|
-
this.
|
|
28313
|
+
this.shaderVariant.setInt(name, this.ints[name]);
|
|
27830
28314
|
}
|
|
27831
28315
|
for (name in this.floatArrays) {
|
|
27832
|
-
this.
|
|
28316
|
+
this.shaderVariant.setFloats(name, this.floatArrays[name]);
|
|
27833
28317
|
}
|
|
27834
28318
|
for (name in this.textures) {
|
|
27835
|
-
this.
|
|
28319
|
+
this.shaderVariant.setTexture(name, this.textures[name]);
|
|
27836
28320
|
}
|
|
27837
28321
|
for (name in this.vector2s) {
|
|
27838
|
-
this.
|
|
28322
|
+
this.shaderVariant.setVector2(name, this.vector2s[name]);
|
|
27839
28323
|
}
|
|
27840
28324
|
for (name in this.vector3s) {
|
|
27841
|
-
this.
|
|
28325
|
+
this.shaderVariant.setVector3(name, this.vector3s[name]);
|
|
27842
28326
|
}
|
|
27843
28327
|
for (name in this.vector4s) {
|
|
27844
|
-
this.
|
|
28328
|
+
this.shaderVariant.setVector4(name, this.vector4s[name]);
|
|
27845
28329
|
}
|
|
27846
28330
|
for (name in this.colors) {
|
|
27847
|
-
this.
|
|
28331
|
+
this.shaderVariant.setColor(name, this.colors[name]);
|
|
27848
28332
|
}
|
|
27849
28333
|
for (name in this.quaternions) {
|
|
27850
|
-
this.
|
|
28334
|
+
this.shaderVariant.setQuaternion(name, this.quaternions[name]);
|
|
27851
28335
|
}
|
|
27852
28336
|
for (name in this.matrices) {
|
|
27853
|
-
this.
|
|
28337
|
+
this.shaderVariant.setMatrix(name, this.matrices[name]);
|
|
27854
28338
|
}
|
|
27855
28339
|
for (name in this.matrice3s) {
|
|
27856
|
-
this.
|
|
28340
|
+
this.shaderVariant.setMatrix3(name, this.matrice3s[name]);
|
|
27857
28341
|
}
|
|
27858
28342
|
for (name in this.vector4Arrays) {
|
|
27859
|
-
this.
|
|
28343
|
+
this.shaderVariant.setVector4Array(name, this.vector4Arrays[name]);
|
|
27860
28344
|
}
|
|
27861
28345
|
for (name in this.matrixArrays) {
|
|
27862
|
-
this.
|
|
28346
|
+
this.shaderVariant.setMatrixArray(name, this.matrixArrays[name]);
|
|
27863
28347
|
}
|
|
27864
28348
|
};
|
|
27865
28349
|
GLMaterial.prototype.getFloat = function (name) {
|
|
@@ -28023,7 +28507,7 @@ var GLMaterial = /** @class */ (function (_super) {
|
|
|
28023
28507
|
this.ints = {};
|
|
28024
28508
|
this.floatArrays = {};
|
|
28025
28509
|
this.vector4s = {};
|
|
28026
|
-
var propertiesData = __assign$1({
|
|
28510
|
+
var propertiesData = __assign$1({ blending: false, zTest: false, zWrite: false }, data);
|
|
28027
28511
|
this.blending = propertiesData.blending;
|
|
28028
28512
|
this.depthTest = propertiesData.zTest;
|
|
28029
28513
|
this.depthMask = propertiesData.zWrite;
|
|
@@ -28052,7 +28536,7 @@ var GLMaterial = /** @class */ (function (_super) {
|
|
|
28052
28536
|
}
|
|
28053
28537
|
if (data.shader) {
|
|
28054
28538
|
this.shader = data.shader;
|
|
28055
|
-
this.shaderSource = this.shader.
|
|
28539
|
+
this.shaderSource = this.shader.shaderData;
|
|
28056
28540
|
}
|
|
28057
28541
|
this.initialized = false;
|
|
28058
28542
|
};
|
|
@@ -28065,6 +28549,7 @@ var GLMaterial = /** @class */ (function (_super) {
|
|
|
28065
28549
|
//@ts-expect-error
|
|
28066
28550
|
var materialData = this.taggedProperties;
|
|
28067
28551
|
if (this.shader) {
|
|
28552
|
+
//@ts-expect-error
|
|
28068
28553
|
materialData.shader = this.shader;
|
|
28069
28554
|
}
|
|
28070
28555
|
materialData.floats = {};
|
|
@@ -28158,7 +28643,7 @@ var GLMaterial = /** @class */ (function (_super) {
|
|
|
28158
28643
|
if (this.destroyed) {
|
|
28159
28644
|
return;
|
|
28160
28645
|
}
|
|
28161
|
-
(_a = this.
|
|
28646
|
+
(_a = this.shaderVariant) === null || _a === void 0 ? void 0 : _a.dispose();
|
|
28162
28647
|
if ((options === null || options === void 0 ? void 0 : options.textures) !== exports.DestroyOptions.keep) {
|
|
28163
28648
|
Object.keys(this.textures).forEach(function (key) {
|
|
28164
28649
|
var texture = _this.textures[key];
|
|
@@ -28277,8 +28762,8 @@ var ExtWrap = /** @class */ (function () {
|
|
|
28277
28762
|
shader: {
|
|
28278
28763
|
cacheId: copyShaderId,
|
|
28279
28764
|
name: name,
|
|
28280
|
-
vertex:
|
|
28281
|
-
fragment:
|
|
28765
|
+
vertex: vertexShader,
|
|
28766
|
+
fragment: fragmentShader,
|
|
28282
28767
|
glslVersion: level === 2 ? exports.GLSLVersion.GLSL3 : exports.GLSLVersion.GLSL1,
|
|
28283
28768
|
},
|
|
28284
28769
|
});
|
|
@@ -29089,9 +29574,9 @@ var GLProgram = /** @class */ (function () {
|
|
|
29089
29574
|
return GLProgram;
|
|
29090
29575
|
}());
|
|
29091
29576
|
|
|
29092
|
-
var
|
|
29093
|
-
__extends(
|
|
29094
|
-
function
|
|
29577
|
+
var GLShaderVariant = /** @class */ (function (_super) {
|
|
29578
|
+
__extends(GLShaderVariant, _super);
|
|
29579
|
+
function GLShaderVariant(engine, source) {
|
|
29095
29580
|
var _this = _super.call(this, engine, source) || this;
|
|
29096
29581
|
_this.initialized = false;
|
|
29097
29582
|
_this.uniformLocations = {};
|
|
@@ -29099,7 +29584,7 @@ var GLShader = /** @class */ (function (_super) {
|
|
|
29099
29584
|
return _this;
|
|
29100
29585
|
}
|
|
29101
29586
|
// shader 的 GPU 资源初始化方法,在绘制前调用
|
|
29102
|
-
|
|
29587
|
+
GLShaderVariant.prototype.initialize = function (engine) {
|
|
29103
29588
|
if (this.initialized) {
|
|
29104
29589
|
return;
|
|
29105
29590
|
}
|
|
@@ -29108,46 +29593,46 @@ var GLShader = /** @class */ (function (_super) {
|
|
|
29108
29593
|
var pipelineContext = engine.getGLPipelineContext();
|
|
29109
29594
|
pipelineContext.shaderLibrary.compileShader(this);
|
|
29110
29595
|
};
|
|
29111
|
-
|
|
29596
|
+
GLShaderVariant.prototype.setFloat = function (name, value) {
|
|
29112
29597
|
this.pipelineContext.setFloat(this.uniformLocations[name], value);
|
|
29113
29598
|
};
|
|
29114
|
-
|
|
29599
|
+
GLShaderVariant.prototype.setInt = function (name, value) {
|
|
29115
29600
|
this.pipelineContext.setInt(this.uniformLocations[name], value);
|
|
29116
29601
|
};
|
|
29117
|
-
|
|
29602
|
+
GLShaderVariant.prototype.setFloats = function (name, value) {
|
|
29118
29603
|
this.pipelineContext.setFloats(this.uniformLocations[name], value);
|
|
29119
29604
|
};
|
|
29120
|
-
|
|
29605
|
+
GLShaderVariant.prototype.setTexture = function (name, texture) {
|
|
29121
29606
|
this.pipelineContext.setTexture(this.uniformLocations[name], this.samplerChannels[name], texture);
|
|
29122
29607
|
};
|
|
29123
|
-
|
|
29608
|
+
GLShaderVariant.prototype.setVector2 = function (name, value) {
|
|
29124
29609
|
this.pipelineContext.setVector2(this.uniformLocations[name], value);
|
|
29125
29610
|
};
|
|
29126
|
-
|
|
29611
|
+
GLShaderVariant.prototype.setVector3 = function (name, value) {
|
|
29127
29612
|
this.pipelineContext.setVector3(this.uniformLocations[name], value);
|
|
29128
29613
|
};
|
|
29129
|
-
|
|
29614
|
+
GLShaderVariant.prototype.setVector4 = function (name, value) {
|
|
29130
29615
|
this.pipelineContext.setVector4(this.uniformLocations[name], value);
|
|
29131
29616
|
};
|
|
29132
|
-
|
|
29617
|
+
GLShaderVariant.prototype.setColor = function (name, value) {
|
|
29133
29618
|
this.pipelineContext.setColor(this.uniformLocations[name], value);
|
|
29134
29619
|
};
|
|
29135
|
-
|
|
29620
|
+
GLShaderVariant.prototype.setQuaternion = function (name, value) {
|
|
29136
29621
|
this.pipelineContext.setQuaternion(this.uniformLocations[name], value);
|
|
29137
29622
|
};
|
|
29138
|
-
|
|
29623
|
+
GLShaderVariant.prototype.setMatrix = function (name, value) {
|
|
29139
29624
|
this.pipelineContext.setMatrix(this.uniformLocations[name], value);
|
|
29140
29625
|
};
|
|
29141
|
-
|
|
29626
|
+
GLShaderVariant.prototype.setMatrix3 = function (name, value) {
|
|
29142
29627
|
this.pipelineContext.setMatrix3(this.uniformLocations[name], value);
|
|
29143
29628
|
};
|
|
29144
|
-
|
|
29629
|
+
GLShaderVariant.prototype.setVector4Array = function (name, array) {
|
|
29145
29630
|
this.pipelineContext.setVector4Array(this.uniformLocations[name], array);
|
|
29146
29631
|
};
|
|
29147
|
-
|
|
29632
|
+
GLShaderVariant.prototype.setMatrixArray = function (name, array) {
|
|
29148
29633
|
this.pipelineContext.setMatrixArray(this.uniformLocations[name], array);
|
|
29149
29634
|
};
|
|
29150
|
-
|
|
29635
|
+
GLShaderVariant.prototype.fillShaderInformation = function (uniformNames, samplers) {
|
|
29151
29636
|
// 避免修改原数组。
|
|
29152
29637
|
var samplerList = samplers.slice();
|
|
29153
29638
|
uniformNames = uniformNames.concat(samplerList);
|
|
@@ -29168,22 +29653,22 @@ var GLShader = /** @class */ (function (_super) {
|
|
|
29168
29653
|
this.samplerChannels[samplerName] = index;
|
|
29169
29654
|
}
|
|
29170
29655
|
};
|
|
29171
|
-
|
|
29656
|
+
GLShaderVariant.prototype.toData = function () {
|
|
29172
29657
|
var shaderData = this.taggedProperties;
|
|
29173
29658
|
shaderData.dataType = exports.DataType.Shader;
|
|
29174
29659
|
shaderData.id = this.guid;
|
|
29175
29660
|
shaderData.vertex = this.source.vertex;
|
|
29176
29661
|
shaderData.fragment = this.source.fragment;
|
|
29177
29662
|
};
|
|
29178
|
-
|
|
29663
|
+
GLShaderVariant.prototype.dispose = function () {
|
|
29179
29664
|
var _a;
|
|
29180
29665
|
if (this.compileResult && this.compileResult.shared) {
|
|
29181
29666
|
return;
|
|
29182
29667
|
}
|
|
29183
29668
|
(_a = this.program) === null || _a === void 0 ? void 0 : _a.dispose();
|
|
29184
29669
|
};
|
|
29185
|
-
return
|
|
29186
|
-
}(
|
|
29670
|
+
return GLShaderVariant;
|
|
29671
|
+
}(ShaderVariant));
|
|
29187
29672
|
|
|
29188
29673
|
var shaderSeed = 0;
|
|
29189
29674
|
var GLShaderLibrary = /** @class */ (function () {
|
|
@@ -29238,25 +29723,33 @@ var GLShaderLibrary = /** @class */ (function () {
|
|
|
29238
29723
|
}
|
|
29239
29724
|
};
|
|
29240
29725
|
// TODO 创建shader的ShaderWithSource和shader的source类型一样,待优化。
|
|
29241
|
-
GLShaderLibrary.prototype.addShader = function (shaderSource) {
|
|
29242
|
-
var
|
|
29726
|
+
GLShaderLibrary.prototype.addShader = function (shaderSource, macros) {
|
|
29727
|
+
var mergedMacros = [];
|
|
29728
|
+
if (shaderSource.marcos) {
|
|
29729
|
+
mergedMacros.push.apply(mergedMacros, __spreadArray$3([], __read$3(shaderSource.marcos), false));
|
|
29730
|
+
}
|
|
29731
|
+
if (macros) {
|
|
29732
|
+
mergedMacros.push.apply(mergedMacros, __spreadArray$3([], __read$3(macros), false));
|
|
29733
|
+
}
|
|
29734
|
+
var shaderWithMacros = __assign$1(__assign$1({}, shaderSource), { vertex: createShaderWithMarcos(mergedMacros, shaderSource.vertex, exports.ShaderType.vertex, this.engine.gpuCapability.level), fragment: createShaderWithMarcos(mergedMacros, shaderSource.fragment, exports.ShaderType.fragment, this.engine.gpuCapability.level) });
|
|
29735
|
+
var shaderCacheId = this.computeShaderCacheId(shaderWithMacros);
|
|
29243
29736
|
if (this.cachedShaders[shaderCacheId]) {
|
|
29244
29737
|
return shaderCacheId;
|
|
29245
29738
|
}
|
|
29246
29739
|
this.shaderAllDone = false;
|
|
29247
|
-
var header =
|
|
29248
|
-
var vertex =
|
|
29249
|
-
var fragment =
|
|
29740
|
+
var header = shaderWithMacros.glslVersion === exports.GLSLVersion.GLSL3 ? '#version 300 es\n' : '';
|
|
29741
|
+
var vertex = shaderWithMacros.vertex ? header + shaderWithMacros.vertex : '';
|
|
29742
|
+
var fragment = shaderWithMacros.fragment ? header + shaderWithMacros.fragment : '';
|
|
29250
29743
|
var shared = false;
|
|
29251
|
-
if (
|
|
29744
|
+
if (shaderWithMacros.shared || shaderWithMacros.cacheId) {
|
|
29252
29745
|
shared = true;
|
|
29253
29746
|
}
|
|
29254
|
-
this.cachedShaders[shaderCacheId] = new
|
|
29747
|
+
this.cachedShaders[shaderCacheId] = new GLShaderVariant(this.engine, __assign$1(__assign$1({}, shaderWithMacros), { vertex: vertex, fragment: fragment, name: shaderWithMacros.name || shaderCacheId, shared: shared }));
|
|
29255
29748
|
this.cachedShaders[shaderCacheId].id = shaderCacheId;
|
|
29256
29749
|
return shaderCacheId;
|
|
29257
29750
|
};
|
|
29258
|
-
GLShaderLibrary.prototype.createShader = function (shaderSource) {
|
|
29259
|
-
var shaderCacheId = this.addShader(shaderSource);
|
|
29751
|
+
GLShaderLibrary.prototype.createShader = function (shaderSource, macros) {
|
|
29752
|
+
var shaderCacheId = this.addShader(shaderSource, macros);
|
|
29260
29753
|
return this.cachedShaders[shaderCacheId];
|
|
29261
29754
|
};
|
|
29262
29755
|
GLShaderLibrary.prototype.compileShader = function (shader, asyncCallback) {
|
|
@@ -29354,6 +29847,9 @@ var GLShaderLibrary = /** @class */ (function () {
|
|
|
29354
29847
|
delete result.program;
|
|
29355
29848
|
var linked = gl.getProgramParameter(program, gl.LINK_STATUS);
|
|
29356
29849
|
if (!linked) {
|
|
29850
|
+
// 链接失败,获取并打印错误信息
|
|
29851
|
+
var info = gl.getProgramInfoLog(program);
|
|
29852
|
+
console.error('Failed to link program: ' + info);
|
|
29357
29853
|
var vsCheckResult = checkShader(gl, vertexShader, 'vertex', vs);
|
|
29358
29854
|
var fsCheckResult = checkShader(gl, fragShader, 'fragment', fs);
|
|
29359
29855
|
result.status = exports.ShaderCompileResultStatus.fail;
|
|
@@ -30360,6 +30856,7 @@ var Player = /** @class */ (function () {
|
|
|
30360
30856
|
this.displayScale = 1;
|
|
30361
30857
|
this.resumePending = false;
|
|
30362
30858
|
this.disposed = false;
|
|
30859
|
+
this.assetManagers = [];
|
|
30363
30860
|
this.speed = 1;
|
|
30364
30861
|
this.baseCompositionIndex = 0;
|
|
30365
30862
|
/**
|
|
@@ -30642,7 +31139,7 @@ var Player = /** @class */ (function () {
|
|
|
30642
31139
|
Player.prototype.createComposition = function (url, options) {
|
|
30643
31140
|
if (options === void 0) { options = {}; }
|
|
30644
31141
|
return __awaiter(this, void 0, void 0, function () {
|
|
30645
|
-
var renderer, engine, last, opts, source, scene, i, compositionSourceManager, composition, firstFrameTime;
|
|
31142
|
+
var renderer, engine, last, opts, source, assetManager, scene, i, compositionSourceManager, composition, firstFrameTime;
|
|
30646
31143
|
var _this = this;
|
|
30647
31144
|
return __generator(this, function (_a) {
|
|
30648
31145
|
switch (_a.label) {
|
|
@@ -30658,15 +31155,11 @@ var Player = /** @class */ (function () {
|
|
|
30658
31155
|
else {
|
|
30659
31156
|
source = url;
|
|
30660
31157
|
}
|
|
30661
|
-
|
|
30662
|
-
this.assetManager.updateOptions(opts);
|
|
30663
|
-
}
|
|
30664
|
-
else {
|
|
30665
|
-
this.assetManager = new AssetManager(opts);
|
|
30666
|
-
}
|
|
31158
|
+
assetManager = new AssetManager(opts);
|
|
30667
31159
|
// TODO 多 json 之间目前不共用资源,如果后续需要多 json 共用,这边缓存机制需要额外处理
|
|
30668
31160
|
engine.clearResources(); // 在 assetManager.loadScene 前清除,避免 loadScene 创建的 EffectsObject 对象丢失
|
|
30669
|
-
|
|
31161
|
+
this.assetManagers.push(assetManager);
|
|
31162
|
+
return [4 /*yield*/, assetManager.loadScene(source, this.renderer, { env: this.env })];
|
|
30670
31163
|
case 1:
|
|
30671
31164
|
scene = _a.sent();
|
|
30672
31165
|
engine.addPackageDatas(scene);
|
|
@@ -31000,7 +31493,7 @@ var Player = /** @class */ (function () {
|
|
|
31000
31493
|
* @param keepCanvas - 是否保留 canvas 画面,默认不保留,canvas 不能再被使用
|
|
31001
31494
|
*/
|
|
31002
31495
|
Player.prototype.dispose = function (keepCanvas) {
|
|
31003
|
-
var _a
|
|
31496
|
+
var _a;
|
|
31004
31497
|
logger.info("call player destroy: ".concat(this.name));
|
|
31005
31498
|
if (this.disposed) {
|
|
31006
31499
|
return;
|
|
@@ -31008,7 +31501,7 @@ var Player = /** @class */ (function () {
|
|
|
31008
31501
|
playerMap.delete(this.canvas);
|
|
31009
31502
|
this.pause();
|
|
31010
31503
|
(_a = this.ticker) === null || _a === void 0 ? void 0 : _a.stop();
|
|
31011
|
-
(
|
|
31504
|
+
this.assetManagers.forEach(function (assetManager) { return assetManager.dispose(); });
|
|
31012
31505
|
this.compositions.forEach(function (comp) { return comp.dispose(); });
|
|
31013
31506
|
this.compositions.length = 0;
|
|
31014
31507
|
this.renderer.context.removeLostHandler({ lost: this.lost });
|
|
@@ -31214,7 +31707,7 @@ Renderer.create = function (canvas, framework, renderOptions) {
|
|
|
31214
31707
|
Engine.create = function (gl) {
|
|
31215
31708
|
return new GLEngine(gl);
|
|
31216
31709
|
};
|
|
31217
|
-
var version = "2.0.0-alpha.
|
|
31710
|
+
var version = "2.0.0-alpha.4";
|
|
31218
31711
|
logger.info('player version: ' + version);
|
|
31219
31712
|
|
|
31220
31713
|
exports.AbstractPlugin = AbstractPlugin;
|
|
@@ -31307,6 +31800,7 @@ exports.SPRITE_VERTEX_STRIDE = SPRITE_VERTEX_STRIDE;
|
|
|
31307
31800
|
exports.SemanticMap = SemanticMap;
|
|
31308
31801
|
exports.SerializationHelper = SerializationHelper;
|
|
31309
31802
|
exports.Shader = Shader;
|
|
31803
|
+
exports.ShaderVariant = ShaderVariant;
|
|
31310
31804
|
exports.SpriteColorPlayable = SpriteColorPlayable;
|
|
31311
31805
|
exports.SpriteComponent = SpriteComponent;
|
|
31312
31806
|
exports.SpriteLoader = SpriteLoader;
|
|
@@ -31377,7 +31871,7 @@ exports.gaussianDownHFrag = gaussianDownHFrag;
|
|
|
31377
31871
|
exports.gaussianDownVFrag = gaussianDownVFrag;
|
|
31378
31872
|
exports.gaussianUpFrag = gaussianUpFrag;
|
|
31379
31873
|
exports.generateEmptyTypedArray = generateEmptyTypedArray;
|
|
31380
|
-
exports.generateGUID = generateGUID;
|
|
31874
|
+
exports.generateGUID = generateGUID$1;
|
|
31381
31875
|
exports.generateHalfFloatTexture = generateHalfFloatTexture;
|
|
31382
31876
|
exports.getActivePlayers = getActivePlayers;
|
|
31383
31877
|
exports.getBackgroundImage = getBackgroundImage;
|
|
@@ -31437,7 +31931,7 @@ exports.nearestPowerOfTwo = nearestPowerOfTwo;
|
|
|
31437
31931
|
exports.noop = noop;
|
|
31438
31932
|
exports.parsePercent = parsePercent$1;
|
|
31439
31933
|
exports.particleFrag = particleFrag;
|
|
31440
|
-
exports.particleOriginTranslateMap = particleOriginTranslateMap;
|
|
31934
|
+
exports.particleOriginTranslateMap = particleOriginTranslateMap$1;
|
|
31441
31935
|
exports.particleVert = particleVert;
|
|
31442
31936
|
exports.pluginLoaderMap = pluginLoaderMap;
|
|
31443
31937
|
exports.random = random;
|