@galacean/effects 2.0.0-alpha.2 → 2.0.0-alpha.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.js +2513 -1916
- 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 +2545 -1950
- package/dist/index.mjs.map +1 -1
- package/dist/player.d.ts +1 -1
- package/dist/weapp.js +1412 -815
- package/dist/weapp.js.map +1 -1
- package/dist/weapp.mjs +1444 -849
- 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
|
+
*/
|
|
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
|
|
6574
6581
|
*/
|
|
6575
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; },
|
|
@@ -7336,390 +7408,121 @@ function generateSerializableMember(type, sourceName) {
|
|
|
7336
7408
|
};
|
|
7337
7409
|
}
|
|
7338
7410
|
|
|
7411
|
+
exports.ShaderType = void 0;
|
|
7412
|
+
(function (ShaderType) {
|
|
7413
|
+
ShaderType[ShaderType["vertex"] = 0] = "vertex";
|
|
7414
|
+
ShaderType[ShaderType["fragment"] = 1] = "fragment";
|
|
7415
|
+
})(exports.ShaderType || (exports.ShaderType = {}));
|
|
7416
|
+
|
|
7339
7417
|
/**
|
|
7340
|
-
*
|
|
7341
|
-
*
|
|
7418
|
+
* Helper class to create a WebGL Context
|
|
7419
|
+
*
|
|
7420
|
+
* @param canvas
|
|
7421
|
+
* @param glType
|
|
7422
|
+
* @param options
|
|
7423
|
+
* @returns
|
|
7342
7424
|
*/
|
|
7343
|
-
|
|
7344
|
-
|
|
7345
|
-
|
|
7346
|
-
|
|
7347
|
-
|
|
7348
|
-
|
|
7425
|
+
function createGLContext(canvas, glType, options) {
|
|
7426
|
+
if (glType === void 0) { glType = 'webgl'; }
|
|
7427
|
+
var context;
|
|
7428
|
+
if (glType === 'webgl2') {
|
|
7429
|
+
context = canvas.getContext('webgl2', options);
|
|
7430
|
+
if (!context) {
|
|
7431
|
+
console.debug('WebGL2 context retrieval failed, falling back to WebGL context.');
|
|
7432
|
+
}
|
|
7349
7433
|
}
|
|
7350
|
-
|
|
7351
|
-
|
|
7352
|
-
}
|
|
7353
|
-
|
|
7354
|
-
|
|
7355
|
-
|
|
7356
|
-
|
|
7357
|
-
|
|
7358
|
-
|
|
7359
|
-
|
|
7360
|
-
|
|
7361
|
-
|
|
7362
|
-
|
|
7363
|
-
|
|
7364
|
-
|
|
7365
|
-
|
|
7366
|
-
|
|
7434
|
+
if (!context || glType === 'webgl') {
|
|
7435
|
+
context = canvas.getContext('webgl', options);
|
|
7436
|
+
}
|
|
7437
|
+
if (!context) {
|
|
7438
|
+
throw new Error('This browser does not support WebGL or the WebGL version is incorrect. Please check your WebGL version.');
|
|
7439
|
+
}
|
|
7440
|
+
return context;
|
|
7441
|
+
}
|
|
7442
|
+
|
|
7443
|
+
function gpuTimer(gl) {
|
|
7444
|
+
var _this = this;
|
|
7445
|
+
var ext = gl.getExtension('EXT_disjoint_timer_query_webgl2');
|
|
7446
|
+
if (ext) {
|
|
7447
|
+
var query_1 = gl.createQuery();
|
|
7448
|
+
var getTime_1 = function () { return __awaiter(_this, void 0, void 0, function () {
|
|
7449
|
+
return __generator(this, function (_a) {
|
|
7450
|
+
return [2 /*return*/, new Promise(function (resolve, reject) {
|
|
7451
|
+
if (query_1) {
|
|
7452
|
+
var available = gl.getQueryParameter(query_1, gl.QUERY_RESULT_AVAILABLE);
|
|
7453
|
+
var disjoint = gl.getParameter(ext.GPU_DISJOINT_EXT);
|
|
7454
|
+
if (available && !disjoint) {
|
|
7455
|
+
// See how much time the rendering of the object took in nanoseconds.
|
|
7456
|
+
var timeElapsed = gl.getQueryParameter(query_1, gl.QUERY_RESULT); // Do something useful with the time. Note that care should be
|
|
7457
|
+
// taken to use all significant bits of the result, not just the
|
|
7458
|
+
// least significant 32 bits.
|
|
7459
|
+
resolve(timeElapsed / 1000 / 1000);
|
|
7460
|
+
}
|
|
7461
|
+
if (available || disjoint) {
|
|
7462
|
+
// Clean up the query object.
|
|
7463
|
+
gl.deleteQuery(query_1); // Don't re-enter this polling loop.
|
|
7464
|
+
query_1 = null;
|
|
7465
|
+
}
|
|
7466
|
+
available !== null && query_1 && weapp.window.setTimeout(function () {
|
|
7467
|
+
getTime_1().then(resolve).catch;
|
|
7468
|
+
}, 1);
|
|
7469
|
+
}
|
|
7470
|
+
})];
|
|
7471
|
+
});
|
|
7472
|
+
}); };
|
|
7473
|
+
if (!query_1) {
|
|
7474
|
+
return;
|
|
7367
7475
|
}
|
|
7368
|
-
|
|
7369
|
-
|
|
7370
|
-
|
|
7371
|
-
|
|
7372
|
-
|
|
7373
|
-
|
|
7374
|
-
}
|
|
7476
|
+
return {
|
|
7477
|
+
begin: function () {
|
|
7478
|
+
query_1 && gl.beginQuery(ext.TIME_ELAPSED_EXT, query_1);
|
|
7479
|
+
},
|
|
7480
|
+
end: function () {
|
|
7481
|
+
gl.endQuery(ext.TIME_ELAPSED_EXT);
|
|
7482
|
+
},
|
|
7483
|
+
getTime: getTime_1,
|
|
7484
|
+
};
|
|
7485
|
+
}
|
|
7486
|
+
}
|
|
7375
7487
|
|
|
7376
|
-
|
|
7377
|
-
|
|
7378
|
-
|
|
7379
|
-
|
|
7380
|
-
|
|
7381
|
-
|
|
7382
|
-
|
|
7383
|
-
|
|
7488
|
+
var initErrors = [];
|
|
7489
|
+
// @ts-expect-error
|
|
7490
|
+
var glContext = {};
|
|
7491
|
+
if (!initErrors.length) {
|
|
7492
|
+
initGLContext();
|
|
7493
|
+
}
|
|
7494
|
+
function initGLContext() {
|
|
7495
|
+
// 重要:iOS 9/10 低版本需要拷贝 gl context 的 prototype,要不然会有属性值的缺失
|
|
7496
|
+
if (typeof WebGL2RenderingContext === 'function') {
|
|
7497
|
+
copy$1(WebGL2RenderingContext);
|
|
7384
7498
|
}
|
|
7385
|
-
|
|
7386
|
-
|
|
7387
|
-
|
|
7388
|
-
|
|
7389
|
-
|
|
7390
|
-
|
|
7391
|
-
|
|
7392
|
-
|
|
7393
|
-
|
|
7394
|
-
|
|
7395
|
-
|
|
7396
|
-
|
|
7397
|
-
|
|
7398
|
-
|
|
7399
|
-
|
|
7400
|
-
|
|
7401
|
-
|
|
7402
|
-
|
|
7403
|
-
|
|
7404
|
-
|
|
7405
|
-
|
|
7406
|
-
|
|
7499
|
+
else if (typeof weapp.WebGLRenderingContext !== 'undefined') {
|
|
7500
|
+
copy$1(weapp.WebGLRenderingContext);
|
|
7501
|
+
copy$1(weapp.WebGLRenderingContext.prototype);
|
|
7502
|
+
}
|
|
7503
|
+
else {
|
|
7504
|
+
initErrors.push(
|
|
7505
|
+
// iOS 16 lockdown mode
|
|
7506
|
+
'iOS16 lockdown mode, WebGL Constants not in global');
|
|
7507
|
+
}
|
|
7508
|
+
if (!initErrors.length && !('HALF_FLOAT' in glContext)) {
|
|
7509
|
+
// @ts-expect-error set default value
|
|
7510
|
+
glContext['HALF_FLOAT'] = 5131;
|
|
7511
|
+
}
|
|
7512
|
+
}
|
|
7513
|
+
function isWebGL2(gl) {
|
|
7514
|
+
return typeof WebGL2RenderingContext !== 'undefined' && gl.constructor.name === 'WebGL2RenderingContext';
|
|
7515
|
+
}
|
|
7516
|
+
function copy$1(target) {
|
|
7517
|
+
for (var name_1 in target) {
|
|
7518
|
+
if (/^[A-Z_]/.test(name_1)) {
|
|
7519
|
+
// @ts-expect-error safe to assign
|
|
7520
|
+
glContext[name_1] = target[name_1];
|
|
7407
7521
|
}
|
|
7408
|
-
};
|
|
7409
|
-
return Component;
|
|
7410
|
-
}(EffectsObject));
|
|
7411
|
-
/**
|
|
7412
|
-
* @since 2.0.0
|
|
7413
|
-
* @internal
|
|
7414
|
-
*/
|
|
7415
|
-
var Behaviour = /** @class */ (function (_super) {
|
|
7416
|
-
__extends(Behaviour, _super);
|
|
7417
|
-
function Behaviour() {
|
|
7418
|
-
var _this = _super !== null && _super.apply(this, arguments) || this;
|
|
7419
|
-
_this._enabled = true;
|
|
7420
|
-
return _this;
|
|
7421
7522
|
}
|
|
7422
|
-
Object.defineProperty(Behaviour.prototype, "isActiveAndEnabled", {
|
|
7423
|
-
/**
|
|
7424
|
-
* 组件是否可以更新,true 更新,false 不更新
|
|
7425
|
-
*/
|
|
7426
|
-
get: function () {
|
|
7427
|
-
return this.item.getVisible() && this.enabled;
|
|
7428
|
-
},
|
|
7429
|
-
enumerable: false,
|
|
7430
|
-
configurable: true
|
|
7431
|
-
});
|
|
7432
|
-
Object.defineProperty(Behaviour.prototype, "enabled", {
|
|
7433
|
-
get: function () {
|
|
7434
|
-
return this._enabled;
|
|
7435
|
-
},
|
|
7436
|
-
set: function (value) {
|
|
7437
|
-
this._enabled = value;
|
|
7438
|
-
if (value) {
|
|
7439
|
-
this.onBehaviourEnable();
|
|
7440
|
-
}
|
|
7441
|
-
},
|
|
7442
|
-
enumerable: false,
|
|
7443
|
-
configurable: true
|
|
7444
|
-
});
|
|
7445
|
-
Behaviour.prototype.onBehaviourEnable = function () { };
|
|
7446
|
-
Behaviour.prototype.fromData = function (data) {
|
|
7447
|
-
_super.prototype.fromData.call(this, data);
|
|
7448
|
-
};
|
|
7449
|
-
Behaviour.prototype.toData = function () {
|
|
7450
|
-
_super.prototype.toData.call(this);
|
|
7451
|
-
};
|
|
7452
|
-
__decorate([
|
|
7453
|
-
serialize()
|
|
7454
|
-
], Behaviour.prototype, "_enabled", void 0);
|
|
7455
|
-
return Behaviour;
|
|
7456
|
-
}(Component));
|
|
7457
|
-
/**
|
|
7458
|
-
* @since 2.0.0
|
|
7459
|
-
* @internal
|
|
7460
|
-
*/
|
|
7461
|
-
var ItemBehaviour = /** @class */ (function (_super) {
|
|
7462
|
-
__extends(ItemBehaviour, _super);
|
|
7463
|
-
function ItemBehaviour() {
|
|
7464
|
-
var _this = _super !== null && _super.apply(this, arguments) || this;
|
|
7465
|
-
_this.started = false;
|
|
7466
|
-
return _this;
|
|
7467
|
-
}
|
|
7468
|
-
// /**
|
|
7469
|
-
// * 生命周期函数,初始化后调用,生命周期内只调用一次
|
|
7470
|
-
// */
|
|
7471
|
-
// awake () {
|
|
7472
|
-
// // OVERRIDE
|
|
7473
|
-
// }
|
|
7474
|
-
/**
|
|
7475
|
-
* 在每次设置 enabled 为 true 时触发
|
|
7476
|
-
*/
|
|
7477
|
-
ItemBehaviour.prototype.onEnable = function () { };
|
|
7478
|
-
/**
|
|
7479
|
-
* 生命周期函数,在第一次 update 前调用,生命周期内只调用一次
|
|
7480
|
-
*/
|
|
7481
|
-
ItemBehaviour.prototype.start = function () {
|
|
7482
|
-
// OVERRIDE
|
|
7483
|
-
};
|
|
7484
|
-
/**
|
|
7485
|
-
* 生命周期函数,每帧调用一次
|
|
7486
|
-
*/
|
|
7487
|
-
ItemBehaviour.prototype.update = function (dt) {
|
|
7488
|
-
// OVERRIDE
|
|
7489
|
-
};
|
|
7490
|
-
/**
|
|
7491
|
-
* 生命周期函数,每帧调用一次,在 update 之后调用
|
|
7492
|
-
*/
|
|
7493
|
-
ItemBehaviour.prototype.lateUpdate = function (dt) {
|
|
7494
|
-
// OVERRIDE
|
|
7495
|
-
};
|
|
7496
|
-
ItemBehaviour.prototype.onAttached = function () {
|
|
7497
|
-
this.item.itemBehaviours.push(this);
|
|
7498
|
-
};
|
|
7499
|
-
ItemBehaviour.prototype.dispose = function () {
|
|
7500
|
-
if (this.item) {
|
|
7501
|
-
removeItem(this.item.itemBehaviours, this);
|
|
7502
|
-
}
|
|
7503
|
-
_super.prototype.dispose.call(this);
|
|
7504
|
-
};
|
|
7505
|
-
ItemBehaviour.prototype.onBehaviourEnable = function () {
|
|
7506
|
-
this.onEnable();
|
|
7507
|
-
if (!this.started) {
|
|
7508
|
-
this.start();
|
|
7509
|
-
this.started = true;
|
|
7510
|
-
}
|
|
7511
|
-
};
|
|
7512
|
-
return ItemBehaviour;
|
|
7513
|
-
}(Behaviour));
|
|
7514
|
-
|
|
7515
|
-
/**
|
|
7516
|
-
* 所有渲染组件的基类
|
|
7517
|
-
* @since 2.0.0
|
|
7518
|
-
*/
|
|
7519
|
-
var RendererComponent = /** @class */ (function (_super) {
|
|
7520
|
-
__extends(RendererComponent, _super);
|
|
7521
|
-
function RendererComponent() {
|
|
7522
|
-
var _this = _super !== null && _super.apply(this, arguments) || this;
|
|
7523
|
-
_this.started = false;
|
|
7524
|
-
_this.materials = [];
|
|
7525
|
-
_this._enabled = true;
|
|
7526
|
-
return _this;
|
|
7527
|
-
}
|
|
7528
|
-
Object.defineProperty(RendererComponent.prototype, "priority", {
|
|
7529
|
-
get: function () {
|
|
7530
|
-
return this._priority;
|
|
7531
|
-
},
|
|
7532
|
-
set: function (value) {
|
|
7533
|
-
this._priority = value;
|
|
7534
|
-
},
|
|
7535
|
-
enumerable: false,
|
|
7536
|
-
configurable: true
|
|
7537
|
-
});
|
|
7538
|
-
Object.defineProperty(RendererComponent.prototype, "enabled", {
|
|
7539
|
-
get: function () {
|
|
7540
|
-
return this._enabled;
|
|
7541
|
-
},
|
|
7542
|
-
set: function (value) {
|
|
7543
|
-
this._enabled = value;
|
|
7544
|
-
if (value) {
|
|
7545
|
-
this.onEnable();
|
|
7546
|
-
}
|
|
7547
|
-
},
|
|
7548
|
-
enumerable: false,
|
|
7549
|
-
configurable: true
|
|
7550
|
-
});
|
|
7551
|
-
Object.defineProperty(RendererComponent.prototype, "isActiveAndEnabled", {
|
|
7552
|
-
/**
|
|
7553
|
-
* 组件是否可以更新,true 更新,false 不更新
|
|
7554
|
-
*/
|
|
7555
|
-
get: function () {
|
|
7556
|
-
return this.item.getVisible() && this.enabled;
|
|
7557
|
-
},
|
|
7558
|
-
enumerable: false,
|
|
7559
|
-
configurable: true
|
|
7560
|
-
});
|
|
7561
|
-
Object.defineProperty(RendererComponent.prototype, "material", {
|
|
7562
|
-
get: function () {
|
|
7563
|
-
return this.materials[0];
|
|
7564
|
-
},
|
|
7565
|
-
set: function (material) {
|
|
7566
|
-
if (this.materials.length === 0) {
|
|
7567
|
-
this.materials.push(material);
|
|
7568
|
-
}
|
|
7569
|
-
else {
|
|
7570
|
-
this.materials[0] = material;
|
|
7571
|
-
}
|
|
7572
|
-
},
|
|
7573
|
-
enumerable: false,
|
|
7574
|
-
configurable: true
|
|
7575
|
-
});
|
|
7576
|
-
RendererComponent.prototype.onEnable = function () { };
|
|
7577
|
-
RendererComponent.prototype.start = function () { };
|
|
7578
|
-
RendererComponent.prototype.update = function (dt) { };
|
|
7579
|
-
RendererComponent.prototype.lateUpdate = function (dt) { };
|
|
7580
|
-
RendererComponent.prototype.render = function (renderer) { };
|
|
7581
|
-
RendererComponent.prototype.onAttached = function () {
|
|
7582
|
-
this.item.rendererComponents.push(this);
|
|
7583
|
-
};
|
|
7584
|
-
RendererComponent.prototype.fromData = function (data) {
|
|
7585
|
-
_super.prototype.fromData.call(this, data);
|
|
7586
|
-
};
|
|
7587
|
-
RendererComponent.prototype.toData = function () {
|
|
7588
|
-
_super.prototype.toData.call(this);
|
|
7589
|
-
};
|
|
7590
|
-
RendererComponent.prototype.dispose = function () {
|
|
7591
|
-
if (this.item) {
|
|
7592
|
-
removeItem(this.item.rendererComponents, this);
|
|
7593
|
-
}
|
|
7594
|
-
_super.prototype.dispose.call(this);
|
|
7595
|
-
};
|
|
7596
|
-
__decorate([
|
|
7597
|
-
serialize()
|
|
7598
|
-
], RendererComponent.prototype, "materials", void 0);
|
|
7599
|
-
__decorate([
|
|
7600
|
-
serialize()
|
|
7601
|
-
], RendererComponent.prototype, "_priority", void 0);
|
|
7602
|
-
__decorate([
|
|
7603
|
-
serialize()
|
|
7604
|
-
], RendererComponent.prototype, "_enabled", void 0);
|
|
7605
|
-
return RendererComponent;
|
|
7606
|
-
}(Component));
|
|
7607
|
-
|
|
7608
|
-
exports.ShaderType = void 0;
|
|
7609
|
-
(function (ShaderType) {
|
|
7610
|
-
ShaderType[ShaderType["vertex"] = 0] = "vertex";
|
|
7611
|
-
ShaderType[ShaderType["fragment"] = 1] = "fragment";
|
|
7612
|
-
})(exports.ShaderType || (exports.ShaderType = {}));
|
|
7613
|
-
|
|
7614
|
-
/**
|
|
7615
|
-
* Helper class to create a WebGL Context
|
|
7616
|
-
*
|
|
7617
|
-
* @param canvas
|
|
7618
|
-
* @param glType
|
|
7619
|
-
* @param options
|
|
7620
|
-
* @returns
|
|
7621
|
-
*/
|
|
7622
|
-
function createGLContext(canvas, glType, options) {
|
|
7623
|
-
if (glType === void 0) { glType = 'webgl'; }
|
|
7624
|
-
var context;
|
|
7625
|
-
if (glType === 'webgl2') {
|
|
7626
|
-
context = canvas.getContext('webgl2', options);
|
|
7627
|
-
if (!context) {
|
|
7628
|
-
console.debug('WebGL2 context retrieval failed, falling back to WebGL context.');
|
|
7629
|
-
}
|
|
7630
|
-
}
|
|
7631
|
-
if (!context || glType === 'webgl') {
|
|
7632
|
-
context = canvas.getContext('webgl', options);
|
|
7633
|
-
}
|
|
7634
|
-
if (!context) {
|
|
7635
|
-
throw new Error('This browser does not support WebGL or the WebGL version is incorrect. Please check your WebGL version.');
|
|
7636
|
-
}
|
|
7637
|
-
return context;
|
|
7638
7523
|
}
|
|
7639
7524
|
|
|
7640
|
-
|
|
7641
|
-
var _this = this;
|
|
7642
|
-
var ext = gl.getExtension('EXT_disjoint_timer_query_webgl2');
|
|
7643
|
-
if (ext) {
|
|
7644
|
-
var query_1 = gl.createQuery();
|
|
7645
|
-
var getTime_1 = function () { return __awaiter(_this, void 0, void 0, function () {
|
|
7646
|
-
return __generator(this, function (_a) {
|
|
7647
|
-
return [2 /*return*/, new Promise(function (resolve, reject) {
|
|
7648
|
-
if (query_1) {
|
|
7649
|
-
var available = gl.getQueryParameter(query_1, gl.QUERY_RESULT_AVAILABLE);
|
|
7650
|
-
var disjoint = gl.getParameter(ext.GPU_DISJOINT_EXT);
|
|
7651
|
-
if (available && !disjoint) {
|
|
7652
|
-
// See how much time the rendering of the object took in nanoseconds.
|
|
7653
|
-
var timeElapsed = gl.getQueryParameter(query_1, gl.QUERY_RESULT); // Do something useful with the time. Note that care should be
|
|
7654
|
-
// taken to use all significant bits of the result, not just the
|
|
7655
|
-
// least significant 32 bits.
|
|
7656
|
-
resolve(timeElapsed / 1000 / 1000);
|
|
7657
|
-
}
|
|
7658
|
-
if (available || disjoint) {
|
|
7659
|
-
// Clean up the query object.
|
|
7660
|
-
gl.deleteQuery(query_1); // Don't re-enter this polling loop.
|
|
7661
|
-
query_1 = null;
|
|
7662
|
-
}
|
|
7663
|
-
available !== null && query_1 && weapp.window.setTimeout(function () {
|
|
7664
|
-
getTime_1().then(resolve).catch;
|
|
7665
|
-
}, 1);
|
|
7666
|
-
}
|
|
7667
|
-
})];
|
|
7668
|
-
});
|
|
7669
|
-
}); };
|
|
7670
|
-
if (!query_1) {
|
|
7671
|
-
return;
|
|
7672
|
-
}
|
|
7673
|
-
return {
|
|
7674
|
-
begin: function () {
|
|
7675
|
-
query_1 && gl.beginQuery(ext.TIME_ELAPSED_EXT, query_1);
|
|
7676
|
-
},
|
|
7677
|
-
end: function () {
|
|
7678
|
-
gl.endQuery(ext.TIME_ELAPSED_EXT);
|
|
7679
|
-
},
|
|
7680
|
-
getTime: getTime_1,
|
|
7681
|
-
};
|
|
7682
|
-
}
|
|
7683
|
-
}
|
|
7684
|
-
|
|
7685
|
-
var initErrors = [];
|
|
7686
|
-
// @ts-expect-error
|
|
7687
|
-
var glContext = {};
|
|
7688
|
-
if (!initErrors.length) {
|
|
7689
|
-
initGLContext();
|
|
7690
|
-
}
|
|
7691
|
-
function initGLContext() {
|
|
7692
|
-
// 重要:iOS 9/10 低版本需要拷贝 gl context 的 prototype,要不然会有属性值的缺失
|
|
7693
|
-
if (typeof WebGL2RenderingContext === 'function') {
|
|
7694
|
-
copy$1(WebGL2RenderingContext);
|
|
7695
|
-
}
|
|
7696
|
-
else if (typeof weapp.WebGLRenderingContext !== 'undefined') {
|
|
7697
|
-
copy$1(weapp.WebGLRenderingContext);
|
|
7698
|
-
copy$1(weapp.WebGLRenderingContext.prototype);
|
|
7699
|
-
}
|
|
7700
|
-
else {
|
|
7701
|
-
initErrors.push(
|
|
7702
|
-
// iOS 16 lockdown mode
|
|
7703
|
-
'iOS16 lockdown mode, WebGL Constants not in global');
|
|
7704
|
-
}
|
|
7705
|
-
if (!initErrors.length && !('HALF_FLOAT' in glContext)) {
|
|
7706
|
-
// @ts-expect-error set default value
|
|
7707
|
-
glContext['HALF_FLOAT'] = 5131;
|
|
7708
|
-
}
|
|
7709
|
-
}
|
|
7710
|
-
function isWebGL2(gl) {
|
|
7711
|
-
return typeof WebGL2RenderingContext !== 'undefined' && gl.constructor.name === 'WebGL2RenderingContext';
|
|
7712
|
-
}
|
|
7713
|
-
function copy$1(target) {
|
|
7714
|
-
for (var name_1 in target) {
|
|
7715
|
-
if (/^[A-Z_]/.test(name_1)) {
|
|
7716
|
-
// @ts-expect-error safe to assign
|
|
7717
|
-
glContext[name_1] = target[name_1];
|
|
7718
|
-
}
|
|
7719
|
-
}
|
|
7720
|
-
}
|
|
7721
|
-
|
|
7722
|
-
var _a$9;
|
|
7525
|
+
var _a$a;
|
|
7723
7526
|
function valIfUndefined(val, def) {
|
|
7724
7527
|
if (val === undefined || val === null) {
|
|
7725
7528
|
return def;
|
|
@@ -7749,15 +7552,15 @@ function getPreMultiAlpha(blending) {
|
|
|
7749
7552
|
return 1;
|
|
7750
7553
|
}
|
|
7751
7554
|
}
|
|
7752
|
-
var downgradeKeywords = (_a$
|
|
7753
|
-
_a$
|
|
7555
|
+
var downgradeKeywords = (_a$a = {},
|
|
7556
|
+
_a$a[exports.ShaderType.vertex] = {
|
|
7754
7557
|
in: 'attribute',
|
|
7755
7558
|
out: 'varying',
|
|
7756
7559
|
},
|
|
7757
|
-
_a$
|
|
7560
|
+
_a$a[exports.ShaderType.fragment] = {
|
|
7758
7561
|
in: 'varying',
|
|
7759
7562
|
},
|
|
7760
|
-
_a$
|
|
7563
|
+
_a$a);
|
|
7761
7564
|
/**
|
|
7762
7565
|
* 生成 shader,检测到 WebGL1 上下文会降级
|
|
7763
7566
|
* @param marcos - 宏定义数组
|
|
@@ -8191,6 +7994,43 @@ function loadMipmapImage(pointer, bins) {
|
|
|
8191
7994
|
});
|
|
8192
7995
|
}
|
|
8193
7996
|
|
|
7997
|
+
/**
|
|
7998
|
+
* @since 2.0.0
|
|
7999
|
+
* @internal
|
|
8000
|
+
*/
|
|
8001
|
+
var EffectsObject = /** @class */ (function () {
|
|
8002
|
+
function EffectsObject(engine) {
|
|
8003
|
+
this.engine = engine;
|
|
8004
|
+
this.guid = generateGUID$1();
|
|
8005
|
+
this.taggedProperties = {};
|
|
8006
|
+
this.engine.addInstance(this);
|
|
8007
|
+
}
|
|
8008
|
+
EffectsObject.prototype.getInstanceId = function () {
|
|
8009
|
+
return this.guid;
|
|
8010
|
+
};
|
|
8011
|
+
EffectsObject.prototype.setInstanceId = function (guid) {
|
|
8012
|
+
this.engine.removeInstance(this.guid);
|
|
8013
|
+
this.guid = guid;
|
|
8014
|
+
this.engine.addInstance(this);
|
|
8015
|
+
};
|
|
8016
|
+
EffectsObject.prototype.toData = function () { };
|
|
8017
|
+
/**
|
|
8018
|
+
* 反序列化函数
|
|
8019
|
+
*
|
|
8020
|
+
* @param data - 对象的序列化的数据
|
|
8021
|
+
*/
|
|
8022
|
+
EffectsObject.prototype.fromData = function (data) {
|
|
8023
|
+
if (data.id) {
|
|
8024
|
+
this.setInstanceId(data.id);
|
|
8025
|
+
}
|
|
8026
|
+
};
|
|
8027
|
+
EffectsObject.prototype.dispose = function () { };
|
|
8028
|
+
__decorate([
|
|
8029
|
+
serialize()
|
|
8030
|
+
], EffectsObject.prototype, "guid", void 0);
|
|
8031
|
+
return EffectsObject;
|
|
8032
|
+
}());
|
|
8033
|
+
|
|
8194
8034
|
var seed$d = 1;
|
|
8195
8035
|
/**
|
|
8196
8036
|
* Texture 抽象类
|
|
@@ -8858,13 +8698,49 @@ exports.GLSLVersion = void 0;
|
|
|
8858
8698
|
GLSLVersion["GLSL1"] = "100";
|
|
8859
8699
|
GLSLVersion["GLSL3"] = "300 es";
|
|
8860
8700
|
})(exports.GLSLVersion || (exports.GLSLVersion = {}));
|
|
8861
|
-
var
|
|
8862
|
-
__extends(
|
|
8863
|
-
function
|
|
8701
|
+
var ShaderVariant = /** @class */ (function (_super) {
|
|
8702
|
+
__extends(ShaderVariant, _super);
|
|
8703
|
+
function ShaderVariant(engine, source) {
|
|
8864
8704
|
var _this = _super.call(this, engine) || this;
|
|
8865
8705
|
_this.source = source;
|
|
8866
8706
|
return _this;
|
|
8867
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);
|
|
8868
8744
|
return Shader;
|
|
8869
8745
|
}(EffectsObject));
|
|
8870
8746
|
|
|
@@ -8877,8 +8753,8 @@ function createCopyShader(level, writeDepth) {
|
|
|
8877
8753
|
var version = webgl2 ? '#version 300 es' : '';
|
|
8878
8754
|
return {
|
|
8879
8755
|
name: EFFECTS_COPY_MESH_NAME,
|
|
8880
|
-
vertex:
|
|
8881
|
-
fragment:
|
|
8756
|
+
vertex: version + '\n' + COPY_VERTEX_SHADER,
|
|
8757
|
+
fragment: version + '\n' + COPY_FRAGMENT_SHADER,
|
|
8882
8758
|
glslVersion: webgl2 ? exports.GLSLVersion.GLSL3 : exports.GLSLVersion.GLSL1,
|
|
8883
8759
|
marcos: [
|
|
8884
8760
|
['WEBGL2', !!webgl2],
|
|
@@ -8972,83 +8848,315 @@ var PassTextureCache = /** @class */ (function () {
|
|
|
8972
8848
|
this.textureRef = {};
|
|
8973
8849
|
this.engine = undefined;
|
|
8974
8850
|
};
|
|
8975
|
-
return PassTextureCache;
|
|
8976
|
-
}());
|
|
8977
|
-
|
|
8978
|
-
var SemanticMap = /** @class */ (function () {
|
|
8979
|
-
function SemanticMap(semantics) {
|
|
8980
|
-
if (semantics === void 0) { semantics = {}; }
|
|
8981
|
-
this.semantics = __assign$1({}, semantics);
|
|
8982
|
-
}
|
|
8983
|
-
SemanticMap.prototype.toObject = function () {
|
|
8984
|
-
return __assign$1({}, this.semantics);
|
|
8851
|
+
return PassTextureCache;
|
|
8852
|
+
}());
|
|
8853
|
+
|
|
8854
|
+
var SemanticMap = /** @class */ (function () {
|
|
8855
|
+
function SemanticMap(semantics) {
|
|
8856
|
+
if (semantics === void 0) { semantics = {}; }
|
|
8857
|
+
this.semantics = __assign$1({}, semantics);
|
|
8858
|
+
}
|
|
8859
|
+
SemanticMap.prototype.toObject = function () {
|
|
8860
|
+
return __assign$1({}, this.semantics);
|
|
8861
|
+
};
|
|
8862
|
+
SemanticMap.prototype.setSemantic = function (name, value) {
|
|
8863
|
+
if (value === undefined) {
|
|
8864
|
+
delete this.semantics[name];
|
|
8865
|
+
}
|
|
8866
|
+
else {
|
|
8867
|
+
this.semantics[name] = value;
|
|
8868
|
+
}
|
|
8869
|
+
};
|
|
8870
|
+
SemanticMap.prototype.getSemanticValue = function (name, state) {
|
|
8871
|
+
var ret = this.semantics[name];
|
|
8872
|
+
if (isFunction(ret)) {
|
|
8873
|
+
return ret(state);
|
|
8874
|
+
}
|
|
8875
|
+
return ret;
|
|
8876
|
+
};
|
|
8877
|
+
SemanticMap.prototype.hasSemanticValue = function (name) {
|
|
8878
|
+
return name in this.semantics;
|
|
8879
|
+
};
|
|
8880
|
+
SemanticMap.prototype.dispose = function () {
|
|
8881
|
+
var _this = this;
|
|
8882
|
+
Object.keys(this.semantics).forEach(function (name) {
|
|
8883
|
+
delete _this.semantics[name];
|
|
8884
|
+
});
|
|
8885
|
+
};
|
|
8886
|
+
return SemanticMap;
|
|
8887
|
+
}());
|
|
8888
|
+
|
|
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);
|
|
8896
|
+
/**
|
|
8897
|
+
* Geometry 抽象类
|
|
8898
|
+
*/
|
|
8899
|
+
var Geometry = /** @class */ (function (_super) {
|
|
8900
|
+
__extends(Geometry, _super);
|
|
8901
|
+
function Geometry() {
|
|
8902
|
+
return _super !== null && _super.apply(this, arguments) || this;
|
|
8903
|
+
}
|
|
8904
|
+
/**
|
|
8905
|
+
* 初始化 GPU 资源
|
|
8906
|
+
* @override
|
|
8907
|
+
*/
|
|
8908
|
+
Geometry.prototype.initialize = function () {
|
|
8909
|
+
// OVERRIDE
|
|
8910
|
+
};
|
|
8911
|
+
/**
|
|
8912
|
+
* 几何数据刷新
|
|
8913
|
+
*/
|
|
8914
|
+
Geometry.prototype.flush = function () {
|
|
8915
|
+
// OVERRIDE
|
|
8916
|
+
};
|
|
8917
|
+
return Geometry;
|
|
8918
|
+
}(EffectsObject));
|
|
8919
|
+
function generateEmptyTypedArray(type) {
|
|
8920
|
+
if (type === glContext.INT) {
|
|
8921
|
+
return new Int32Array(0);
|
|
8922
|
+
}
|
|
8923
|
+
if (type === glContext.SHORT) {
|
|
8924
|
+
return new Int16Array(0);
|
|
8925
|
+
}
|
|
8926
|
+
return new Float32Array(0);
|
|
8927
|
+
}
|
|
8928
|
+
|
|
8929
|
+
/**
|
|
8930
|
+
* @since 2.0.0
|
|
8931
|
+
* @internal
|
|
8932
|
+
*/
|
|
8933
|
+
var Component = /** @class */ (function (_super) {
|
|
8934
|
+
__extends(Component, _super);
|
|
8935
|
+
function Component() {
|
|
8936
|
+
return _super !== null && _super.apply(this, arguments) || this;
|
|
8937
|
+
}
|
|
8938
|
+
Object.defineProperty(Component.prototype, "transform", {
|
|
8939
|
+
/**
|
|
8940
|
+
* 附加到的 VFXItem 对象 Transform 组件
|
|
8941
|
+
*/
|
|
8942
|
+
get: function () {
|
|
8943
|
+
return this.item.transform;
|
|
8944
|
+
},
|
|
8945
|
+
enumerable: false,
|
|
8946
|
+
configurable: true
|
|
8947
|
+
});
|
|
8948
|
+
Component.prototype.onAttached = function () { };
|
|
8949
|
+
Component.prototype.onDestroy = function () { };
|
|
8950
|
+
Component.prototype.fromData = function (data) {
|
|
8951
|
+
_super.prototype.fromData.call(this, data);
|
|
8952
|
+
if (data.item) {
|
|
8953
|
+
this.item = data.item;
|
|
8954
|
+
}
|
|
8955
|
+
};
|
|
8956
|
+
Component.prototype.dispose = function () {
|
|
8957
|
+
this.onDestroy();
|
|
8958
|
+
if (this.item) {
|
|
8959
|
+
removeItem(this.item.components, this);
|
|
8960
|
+
}
|
|
8961
|
+
};
|
|
8962
|
+
return Component;
|
|
8963
|
+
}(EffectsObject));
|
|
8964
|
+
/**
|
|
8965
|
+
* @since 2.0.0
|
|
8966
|
+
* @internal
|
|
8967
|
+
*/
|
|
8968
|
+
var Behaviour = /** @class */ (function (_super) {
|
|
8969
|
+
__extends(Behaviour, _super);
|
|
8970
|
+
function Behaviour() {
|
|
8971
|
+
var _this = _super !== null && _super.apply(this, arguments) || this;
|
|
8972
|
+
_this._enabled = true;
|
|
8973
|
+
return _this;
|
|
8974
|
+
}
|
|
8975
|
+
Object.defineProperty(Behaviour.prototype, "isActiveAndEnabled", {
|
|
8976
|
+
/**
|
|
8977
|
+
* 组件是否可以更新,true 更新,false 不更新
|
|
8978
|
+
*/
|
|
8979
|
+
get: function () {
|
|
8980
|
+
return this.item.getVisible() && this.enabled;
|
|
8981
|
+
},
|
|
8982
|
+
enumerable: false,
|
|
8983
|
+
configurable: true
|
|
8984
|
+
});
|
|
8985
|
+
Object.defineProperty(Behaviour.prototype, "enabled", {
|
|
8986
|
+
get: function () {
|
|
8987
|
+
return this._enabled;
|
|
8988
|
+
},
|
|
8989
|
+
set: function (value) {
|
|
8990
|
+
this._enabled = value;
|
|
8991
|
+
if (value) {
|
|
8992
|
+
this.onBehaviourEnable();
|
|
8993
|
+
}
|
|
8994
|
+
},
|
|
8995
|
+
enumerable: false,
|
|
8996
|
+
configurable: true
|
|
8997
|
+
});
|
|
8998
|
+
Behaviour.prototype.onBehaviourEnable = function () { };
|
|
8999
|
+
Behaviour.prototype.fromData = function (data) {
|
|
9000
|
+
_super.prototype.fromData.call(this, data);
|
|
9001
|
+
};
|
|
9002
|
+
Behaviour.prototype.toData = function () {
|
|
9003
|
+
_super.prototype.toData.call(this);
|
|
9004
|
+
};
|
|
9005
|
+
__decorate([
|
|
9006
|
+
serialize()
|
|
9007
|
+
], Behaviour.prototype, "_enabled", void 0);
|
|
9008
|
+
return Behaviour;
|
|
9009
|
+
}(Component));
|
|
9010
|
+
/**
|
|
9011
|
+
* @since 2.0.0
|
|
9012
|
+
* @internal
|
|
9013
|
+
*/
|
|
9014
|
+
var ItemBehaviour = /** @class */ (function (_super) {
|
|
9015
|
+
__extends(ItemBehaviour, _super);
|
|
9016
|
+
function ItemBehaviour() {
|
|
9017
|
+
var _this = _super !== null && _super.apply(this, arguments) || this;
|
|
9018
|
+
_this.started = false;
|
|
9019
|
+
return _this;
|
|
9020
|
+
}
|
|
9021
|
+
// /**
|
|
9022
|
+
// * 生命周期函数,初始化后调用,生命周期内只调用一次
|
|
9023
|
+
// */
|
|
9024
|
+
// awake () {
|
|
9025
|
+
// // OVERRIDE
|
|
9026
|
+
// }
|
|
9027
|
+
/**
|
|
9028
|
+
* 在每次设置 enabled 为 true 时触发
|
|
9029
|
+
*/
|
|
9030
|
+
ItemBehaviour.prototype.onEnable = function () { };
|
|
9031
|
+
/**
|
|
9032
|
+
* 生命周期函数,在第一次 update 前调用,生命周期内只调用一次
|
|
9033
|
+
*/
|
|
9034
|
+
ItemBehaviour.prototype.start = function () {
|
|
9035
|
+
// OVERRIDE
|
|
9036
|
+
};
|
|
9037
|
+
/**
|
|
9038
|
+
* 生命周期函数,每帧调用一次
|
|
9039
|
+
*/
|
|
9040
|
+
ItemBehaviour.prototype.update = function (dt) {
|
|
9041
|
+
// OVERRIDE
|
|
9042
|
+
};
|
|
9043
|
+
/**
|
|
9044
|
+
* 生命周期函数,每帧调用一次,在 update 之后调用
|
|
9045
|
+
*/
|
|
9046
|
+
ItemBehaviour.prototype.lateUpdate = function (dt) {
|
|
9047
|
+
// OVERRIDE
|
|
9048
|
+
};
|
|
9049
|
+
ItemBehaviour.prototype.onAttached = function () {
|
|
9050
|
+
this.item.itemBehaviours.push(this);
|
|
9051
|
+
};
|
|
9052
|
+
ItemBehaviour.prototype.dispose = function () {
|
|
9053
|
+
if (this.item) {
|
|
9054
|
+
removeItem(this.item.itemBehaviours, this);
|
|
9055
|
+
}
|
|
9056
|
+
_super.prototype.dispose.call(this);
|
|
9057
|
+
};
|
|
9058
|
+
ItemBehaviour.prototype.onBehaviourEnable = function () {
|
|
9059
|
+
this.onEnable();
|
|
9060
|
+
if (!this.started) {
|
|
9061
|
+
this.start();
|
|
9062
|
+
this.started = true;
|
|
9063
|
+
}
|
|
9064
|
+
};
|
|
9065
|
+
return ItemBehaviour;
|
|
9066
|
+
}(Behaviour));
|
|
9067
|
+
|
|
9068
|
+
/**
|
|
9069
|
+
* 所有渲染组件的基类
|
|
9070
|
+
* @since 2.0.0
|
|
9071
|
+
*/
|
|
9072
|
+
var RendererComponent = /** @class */ (function (_super) {
|
|
9073
|
+
__extends(RendererComponent, _super);
|
|
9074
|
+
function RendererComponent() {
|
|
9075
|
+
var _this = _super !== null && _super.apply(this, arguments) || this;
|
|
9076
|
+
_this.started = false;
|
|
9077
|
+
_this.materials = [];
|
|
9078
|
+
_this._enabled = true;
|
|
9079
|
+
return _this;
|
|
9080
|
+
}
|
|
9081
|
+
Object.defineProperty(RendererComponent.prototype, "priority", {
|
|
9082
|
+
get: function () {
|
|
9083
|
+
return this._priority;
|
|
9084
|
+
},
|
|
9085
|
+
set: function (value) {
|
|
9086
|
+
this._priority = value;
|
|
9087
|
+
},
|
|
9088
|
+
enumerable: false,
|
|
9089
|
+
configurable: true
|
|
9090
|
+
});
|
|
9091
|
+
Object.defineProperty(RendererComponent.prototype, "enabled", {
|
|
9092
|
+
get: function () {
|
|
9093
|
+
return this._enabled;
|
|
9094
|
+
},
|
|
9095
|
+
set: function (value) {
|
|
9096
|
+
this._enabled = value;
|
|
9097
|
+
if (value) {
|
|
9098
|
+
this.onEnable();
|
|
9099
|
+
}
|
|
9100
|
+
},
|
|
9101
|
+
enumerable: false,
|
|
9102
|
+
configurable: true
|
|
9103
|
+
});
|
|
9104
|
+
Object.defineProperty(RendererComponent.prototype, "isActiveAndEnabled", {
|
|
9105
|
+
/**
|
|
9106
|
+
* 组件是否可以更新,true 更新,false 不更新
|
|
9107
|
+
*/
|
|
9108
|
+
get: function () {
|
|
9109
|
+
return this.item.getVisible() && this.enabled;
|
|
9110
|
+
},
|
|
9111
|
+
enumerable: false,
|
|
9112
|
+
configurable: true
|
|
9113
|
+
});
|
|
9114
|
+
Object.defineProperty(RendererComponent.prototype, "material", {
|
|
9115
|
+
get: function () {
|
|
9116
|
+
return this.materials[0];
|
|
9117
|
+
},
|
|
9118
|
+
set: function (material) {
|
|
9119
|
+
if (this.materials.length === 0) {
|
|
9120
|
+
this.materials.push(material);
|
|
9121
|
+
}
|
|
9122
|
+
else {
|
|
9123
|
+
this.materials[0] = material;
|
|
9124
|
+
}
|
|
9125
|
+
},
|
|
9126
|
+
enumerable: false,
|
|
9127
|
+
configurable: true
|
|
9128
|
+
});
|
|
9129
|
+
RendererComponent.prototype.onEnable = function () { };
|
|
9130
|
+
RendererComponent.prototype.start = function () { };
|
|
9131
|
+
RendererComponent.prototype.update = function (dt) { };
|
|
9132
|
+
RendererComponent.prototype.lateUpdate = function (dt) { };
|
|
9133
|
+
RendererComponent.prototype.render = function (renderer) { };
|
|
9134
|
+
RendererComponent.prototype.onAttached = function () {
|
|
9135
|
+
this.item.rendererComponents.push(this);
|
|
9136
|
+
};
|
|
9137
|
+
RendererComponent.prototype.fromData = function (data) {
|
|
9138
|
+
_super.prototype.fromData.call(this, data);
|
|
8985
9139
|
};
|
|
8986
|
-
|
|
8987
|
-
|
|
8988
|
-
delete this.semantics[name];
|
|
8989
|
-
}
|
|
8990
|
-
else {
|
|
8991
|
-
this.semantics[name] = value;
|
|
8992
|
-
}
|
|
9140
|
+
RendererComponent.prototype.toData = function () {
|
|
9141
|
+
_super.prototype.toData.call(this);
|
|
8993
9142
|
};
|
|
8994
|
-
|
|
8995
|
-
|
|
8996
|
-
|
|
8997
|
-
return ret(state);
|
|
9143
|
+
RendererComponent.prototype.dispose = function () {
|
|
9144
|
+
if (this.item) {
|
|
9145
|
+
removeItem(this.item.rendererComponents, this);
|
|
8998
9146
|
}
|
|
8999
|
-
|
|
9000
|
-
};
|
|
9001
|
-
SemanticMap.prototype.hasSemanticValue = function (name) {
|
|
9002
|
-
return name in this.semantics;
|
|
9003
|
-
};
|
|
9004
|
-
SemanticMap.prototype.dispose = function () {
|
|
9005
|
-
var _this = this;
|
|
9006
|
-
Object.keys(this.semantics).forEach(function (name) {
|
|
9007
|
-
delete _this.semantics[name];
|
|
9008
|
-
});
|
|
9009
|
-
};
|
|
9010
|
-
return SemanticMap;
|
|
9011
|
-
}());
|
|
9012
|
-
|
|
9013
|
-
var _a$8;
|
|
9014
|
-
var BYTES_TYPE_MAP = (_a$8 = {},
|
|
9015
|
-
_a$8[glContext.FLOAT] = Float32Array.BYTES_PER_ELEMENT,
|
|
9016
|
-
_a$8[glContext.INT] = Int32Array.BYTES_PER_ELEMENT,
|
|
9017
|
-
_a$8[glContext.SHORT] = Int16Array.BYTES_PER_ELEMENT,
|
|
9018
|
-
_a$8[glContext.BYTE] = Int8Array.BYTES_PER_ELEMENT,
|
|
9019
|
-
_a$8);
|
|
9020
|
-
/**
|
|
9021
|
-
* Geometry 抽象类
|
|
9022
|
-
*/
|
|
9023
|
-
var Geometry = /** @class */ (function (_super) {
|
|
9024
|
-
__extends(Geometry, _super);
|
|
9025
|
-
function Geometry() {
|
|
9026
|
-
return _super !== null && _super.apply(this, arguments) || this;
|
|
9027
|
-
}
|
|
9028
|
-
/**
|
|
9029
|
-
* 初始化 GPU 资源
|
|
9030
|
-
* @override
|
|
9031
|
-
*/
|
|
9032
|
-
Geometry.prototype.initialize = function () {
|
|
9033
|
-
// OVERRIDE
|
|
9034
|
-
};
|
|
9035
|
-
/**
|
|
9036
|
-
* 几何数据刷新
|
|
9037
|
-
*/
|
|
9038
|
-
Geometry.prototype.flush = function () {
|
|
9039
|
-
// OVERRIDE
|
|
9147
|
+
_super.prototype.dispose.call(this);
|
|
9040
9148
|
};
|
|
9041
|
-
|
|
9042
|
-
|
|
9043
|
-
|
|
9044
|
-
|
|
9045
|
-
|
|
9046
|
-
|
|
9047
|
-
|
|
9048
|
-
|
|
9049
|
-
|
|
9050
|
-
return
|
|
9051
|
-
}
|
|
9149
|
+
__decorate([
|
|
9150
|
+
serialize()
|
|
9151
|
+
], RendererComponent.prototype, "materials", void 0);
|
|
9152
|
+
__decorate([
|
|
9153
|
+
serialize()
|
|
9154
|
+
], RendererComponent.prototype, "_priority", void 0);
|
|
9155
|
+
__decorate([
|
|
9156
|
+
serialize()
|
|
9157
|
+
], RendererComponent.prototype, "_enabled", void 0);
|
|
9158
|
+
return RendererComponent;
|
|
9159
|
+
}(Component));
|
|
9052
9160
|
|
|
9053
9161
|
var seed$b = 1;
|
|
9054
9162
|
/**
|
|
@@ -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
|
};
|
|
@@ -11285,7 +11393,7 @@ var SerializationHelper = /** @class */ (function () {
|
|
|
11285
11393
|
};
|
|
11286
11394
|
SerializationHelper.deserializeProperty = function (property, engine, level) {
|
|
11287
11395
|
var e_11, _a, e_12, _b;
|
|
11288
|
-
if (level >
|
|
11396
|
+
if (level > 14) {
|
|
11289
11397
|
console.error('序列化数据的内嵌对象层数大于上限');
|
|
11290
11398
|
return;
|
|
11291
11399
|
}
|
|
@@ -11346,7 +11454,7 @@ var SerializationHelper = /** @class */ (function () {
|
|
|
11346
11454
|
return __generator(this, function (_j) {
|
|
11347
11455
|
switch (_j.label) {
|
|
11348
11456
|
case 0:
|
|
11349
|
-
if (level >
|
|
11457
|
+
if (level > 14) {
|
|
11350
11458
|
console.error('序列化数据的内嵌对象层数大于上限');
|
|
11351
11459
|
return [2 /*return*/];
|
|
11352
11460
|
}
|
|
@@ -11437,7 +11545,7 @@ var SerializationHelper = /** @class */ (function () {
|
|
|
11437
11545
|
};
|
|
11438
11546
|
SerializationHelper.serializeObjectProperty = function (objectProperty, serializedData, level) {
|
|
11439
11547
|
var e_15, _a;
|
|
11440
|
-
if (level >
|
|
11548
|
+
if (level > 14) {
|
|
11441
11549
|
console.error('序列化数据的内嵌对象层数大于上限');
|
|
11442
11550
|
return;
|
|
11443
11551
|
}
|
|
@@ -11482,7 +11590,7 @@ var SerializationHelper = /** @class */ (function () {
|
|
|
11482
11590
|
}
|
|
11483
11591
|
};
|
|
11484
11592
|
SerializationHelper.serializeArrayProperty = function (arrayProperty, serializedData, level) {
|
|
11485
|
-
if (level >
|
|
11593
|
+
if (level > 14) {
|
|
11486
11594
|
console.error('序列化数据的内嵌对象层数大于上限');
|
|
11487
11595
|
return;
|
|
11488
11596
|
}
|
|
@@ -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) {
|
|
@@ -11648,24 +11750,24 @@ var Database = /** @class */ (function () {
|
|
|
11648
11750
|
}());
|
|
11649
11751
|
exports.DataType = void 0;
|
|
11650
11752
|
(function (DataType) {
|
|
11651
|
-
DataType[
|
|
11652
|
-
DataType[
|
|
11653
|
-
DataType[
|
|
11654
|
-
DataType[
|
|
11655
|
-
DataType[
|
|
11656
|
-
DataType[
|
|
11657
|
-
DataType[
|
|
11658
|
-
DataType[
|
|
11659
|
-
DataType[
|
|
11660
|
-
DataType[
|
|
11661
|
-
DataType[
|
|
11753
|
+
DataType["VFXItemData"] = "VFXItemData";
|
|
11754
|
+
DataType["EffectComponent"] = "EffectComponent";
|
|
11755
|
+
DataType["Material"] = "Material";
|
|
11756
|
+
DataType["Shader"] = "Shader";
|
|
11757
|
+
DataType["SpriteComponent"] = "SpriteComponent";
|
|
11758
|
+
DataType["ParticleSystem"] = "ParticleSystem";
|
|
11759
|
+
DataType["InteractComponent"] = "InteractComponent";
|
|
11760
|
+
DataType["CameraController"] = "CameraController";
|
|
11761
|
+
DataType["Geometry"] = "Geometry";
|
|
11762
|
+
DataType["Texture"] = "Texture";
|
|
11763
|
+
DataType["TextComponent"] = "TextComponent";
|
|
11662
11764
|
// FIXME: 先完成ECS的场景转换,后面移到spec中
|
|
11663
|
-
DataType[
|
|
11664
|
-
DataType[
|
|
11665
|
-
DataType[
|
|
11666
|
-
DataType[
|
|
11667
|
-
DataType[
|
|
11668
|
-
DataType[
|
|
11765
|
+
DataType["MeshComponent"] = "MeshComponent";
|
|
11766
|
+
DataType["SkyboxComponent"] = "SkyboxComponent";
|
|
11767
|
+
DataType["LightComponent"] = "LightComponent";
|
|
11768
|
+
DataType["CameraComponent"] = "CameraComponent";
|
|
11769
|
+
DataType["ModelPluginComponent"] = "ModelPluginComponent";
|
|
11770
|
+
DataType["TreeComponent"] = "TreeComponent";
|
|
11669
11771
|
})(exports.DataType || (exports.DataType = {}));
|
|
11670
11772
|
|
|
11671
11773
|
/**
|
|
@@ -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,
|
|
@@ -13932,15 +14035,25 @@ var PlayableOutput = /** @class */ (function () {
|
|
|
13932
14035
|
};
|
|
13933
14036
|
return PlayableOutput;
|
|
13934
14037
|
}());
|
|
14038
|
+
var PlayableAsset = /** @class */ (function () {
|
|
14039
|
+
function PlayableAsset() {
|
|
14040
|
+
}
|
|
14041
|
+
PlayableAsset.prototype.fromData = function (data) {
|
|
14042
|
+
};
|
|
14043
|
+
return PlayableAsset;
|
|
14044
|
+
}());
|
|
13935
14045
|
|
|
13936
14046
|
/**
|
|
13937
14047
|
* @since 2.0.0
|
|
13938
14048
|
* @internal
|
|
13939
14049
|
*/
|
|
13940
|
-
var Track = /** @class */ (function () {
|
|
14050
|
+
var Track = /** @class */ (function (_super) {
|
|
14051
|
+
__extends(Track, _super);
|
|
13941
14052
|
function Track() {
|
|
13942
|
-
|
|
13943
|
-
|
|
14053
|
+
var _this = _super !== null && _super.apply(this, arguments) || this;
|
|
14054
|
+
_this.clips = [];
|
|
14055
|
+
_this.clipSeed = 0;
|
|
14056
|
+
return _this;
|
|
13944
14057
|
}
|
|
13945
14058
|
Track.prototype.createOutput = function () {
|
|
13946
14059
|
var output = new PlayableOutput();
|
|
@@ -13952,7 +14065,7 @@ var Track = /** @class */ (function () {
|
|
|
13952
14065
|
Track.prototype.createMixerPlayable = function () {
|
|
13953
14066
|
return new Playable();
|
|
13954
14067
|
};
|
|
13955
|
-
Track.prototype.
|
|
14068
|
+
Track.prototype.createPlayable = function () {
|
|
13956
14069
|
var e_1, _a;
|
|
13957
14070
|
var defaultMixPlayable = this.createMixerPlayable();
|
|
13958
14071
|
try {
|
|
@@ -14004,7 +14117,7 @@ var Track = /** @class */ (function () {
|
|
|
14004
14117
|
this.clips.push(clip);
|
|
14005
14118
|
};
|
|
14006
14119
|
return Track;
|
|
14007
|
-
}());
|
|
14120
|
+
}(PlayableAsset));
|
|
14008
14121
|
/**
|
|
14009
14122
|
* @since 2.0.0
|
|
14010
14123
|
* @internal
|
|
@@ -14060,12 +14173,12 @@ var tempPos = new Vector3();
|
|
|
14060
14173
|
* @since 2.0.0
|
|
14061
14174
|
* @internal
|
|
14062
14175
|
*/
|
|
14063
|
-
var
|
|
14064
|
-
__extends(
|
|
14065
|
-
function
|
|
14176
|
+
var TransformAnimationPlayable = /** @class */ (function (_super) {
|
|
14177
|
+
__extends(TransformAnimationPlayable, _super);
|
|
14178
|
+
function TransformAnimationPlayable() {
|
|
14066
14179
|
return _super !== null && _super.apply(this, arguments) || this;
|
|
14067
14180
|
}
|
|
14068
|
-
|
|
14181
|
+
TransformAnimationPlayable.prototype.processFrame = function (dt) {
|
|
14069
14182
|
if (this.bindingItem.composition) {
|
|
14070
14183
|
this.sampleAnimation();
|
|
14071
14184
|
}
|
|
@@ -14073,7 +14186,7 @@ var AnimationClipPlayable = /** @class */ (function (_super) {
|
|
|
14073
14186
|
/**
|
|
14074
14187
|
* 应用时间轴K帧数据到对象
|
|
14075
14188
|
*/
|
|
14076
|
-
|
|
14189
|
+
TransformAnimationPlayable.prototype.sampleAnimation = function () {
|
|
14077
14190
|
var _this = this;
|
|
14078
14191
|
var duration = this.bindingItem.duration;
|
|
14079
14192
|
var life = this.time / duration;
|
|
@@ -14118,7 +14231,7 @@ var AnimationClipPlayable = /** @class */ (function (_super) {
|
|
|
14118
14231
|
// this.animationStream.setCurveValue('transform', 'position.z', pos.z);
|
|
14119
14232
|
}
|
|
14120
14233
|
};
|
|
14121
|
-
|
|
14234
|
+
TransformAnimationPlayable.prototype.fromData = function (data) {
|
|
14122
14235
|
var _a;
|
|
14123
14236
|
var scale = this.bindingItem.transform.scale;
|
|
14124
14237
|
this.originalTransform = {
|
|
@@ -14189,30 +14302,45 @@ var AnimationClipPlayable = /** @class */ (function (_super) {
|
|
|
14189
14302
|
this.velocity = this.direction.clone();
|
|
14190
14303
|
this.velocity.multiply(this.startSpeed);
|
|
14191
14304
|
};
|
|
14192
|
-
return
|
|
14305
|
+
return TransformAnimationPlayable;
|
|
14193
14306
|
}(AnimationPlayable));
|
|
14307
|
+
var TransformAnimationPlayableAsset = /** @class */ (function (_super) {
|
|
14308
|
+
__extends(TransformAnimationPlayableAsset, _super);
|
|
14309
|
+
function TransformAnimationPlayableAsset() {
|
|
14310
|
+
return _super !== null && _super.apply(this, arguments) || this;
|
|
14311
|
+
}
|
|
14312
|
+
TransformAnimationPlayableAsset.prototype.createPlayable = function () {
|
|
14313
|
+
var transformAnimationPlayable = new TransformAnimationPlayable();
|
|
14314
|
+
transformAnimationPlayable.fromData(this.transformAnimationData);
|
|
14315
|
+
return transformAnimationPlayable;
|
|
14316
|
+
};
|
|
14317
|
+
TransformAnimationPlayableAsset.prototype.fromData = function (data) {
|
|
14318
|
+
this.transformAnimationData = data;
|
|
14319
|
+
};
|
|
14320
|
+
return TransformAnimationPlayableAsset;
|
|
14321
|
+
}(PlayableAsset));
|
|
14194
14322
|
/**
|
|
14195
14323
|
* @since 2.0.0
|
|
14196
14324
|
* @internal
|
|
14197
14325
|
*/
|
|
14198
|
-
var
|
|
14199
|
-
__extends(
|
|
14200
|
-
function
|
|
14326
|
+
var ActivationPlayable = /** @class */ (function (_super) {
|
|
14327
|
+
__extends(ActivationPlayable, _super);
|
|
14328
|
+
function ActivationPlayable() {
|
|
14201
14329
|
return _super !== null && _super.apply(this, arguments) || this;
|
|
14202
14330
|
}
|
|
14203
|
-
|
|
14331
|
+
ActivationPlayable.prototype.onGraphStart = function () {
|
|
14204
14332
|
this.bindingItem.transform.setValid(false);
|
|
14205
14333
|
this.hideRendererComponents();
|
|
14206
14334
|
};
|
|
14207
|
-
|
|
14335
|
+
ActivationPlayable.prototype.onPlayablePlay = function () {
|
|
14208
14336
|
this.bindingItem.transform.setValid(true);
|
|
14209
14337
|
this.showRendererComponents();
|
|
14210
14338
|
};
|
|
14211
|
-
|
|
14339
|
+
ActivationPlayable.prototype.onPlayableDestroy = function () {
|
|
14212
14340
|
this.bindingItem.transform.setValid(false);
|
|
14213
14341
|
this.hideRendererComponents();
|
|
14214
14342
|
};
|
|
14215
|
-
|
|
14343
|
+
ActivationPlayable.prototype.hideRendererComponents = function () {
|
|
14216
14344
|
var e_1, _a;
|
|
14217
14345
|
try {
|
|
14218
14346
|
for (var _b = __values$1(this.bindingItem.rendererComponents), _c = _b.next(); !_c.done; _c = _b.next()) {
|
|
@@ -14230,7 +14358,7 @@ var ActivationClipPlayable = /** @class */ (function (_super) {
|
|
|
14230
14358
|
finally { if (e_1) throw e_1.error; }
|
|
14231
14359
|
}
|
|
14232
14360
|
};
|
|
14233
|
-
|
|
14361
|
+
ActivationPlayable.prototype.showRendererComponents = function () {
|
|
14234
14362
|
var e_2, _a;
|
|
14235
14363
|
try {
|
|
14236
14364
|
for (var _b = __values$1(this.bindingItem.rendererComponents), _c = _b.next(); !_c.done; _c = _b.next()) {
|
|
@@ -14248,7 +14376,7 @@ var ActivationClipPlayable = /** @class */ (function (_super) {
|
|
|
14248
14376
|
finally { if (e_2) throw e_2.error; }
|
|
14249
14377
|
}
|
|
14250
14378
|
};
|
|
14251
|
-
return
|
|
14379
|
+
return ActivationPlayable;
|
|
14252
14380
|
}(Playable));
|
|
14253
14381
|
|
|
14254
14382
|
/**
|
|
@@ -14503,7 +14631,7 @@ var TimelineComponent = /** @class */ (function (_super) {
|
|
|
14503
14631
|
try {
|
|
14504
14632
|
for (var _b = __values$1(this.tracks), _c = _b.next(); !_c.done; _c = _b.next()) {
|
|
14505
14633
|
var track = _c.value;
|
|
14506
|
-
var trackMixPlayable = track.
|
|
14634
|
+
var trackMixPlayable = track.createPlayable();
|
|
14507
14635
|
var trackOutput = track.createOutput();
|
|
14508
14636
|
graph.addOutput(trackOutput);
|
|
14509
14637
|
trackOutput.setSourcePlayeble(trackMixPlayable);
|
|
@@ -14518,6 +14646,7 @@ var TimelineComponent = /** @class */ (function (_super) {
|
|
|
14518
14646
|
}
|
|
14519
14647
|
};
|
|
14520
14648
|
TimelineComponent.prototype.fromData = function (data) {
|
|
14649
|
+
var e_13, _a, e_14, _b;
|
|
14521
14650
|
_super.prototype.fromData.call(this, data);
|
|
14522
14651
|
this.options = {
|
|
14523
14652
|
start: this.item.start,
|
|
@@ -14528,7 +14657,47 @@ var TimelineComponent = /** @class */ (function (_super) {
|
|
|
14528
14657
|
this.id = this.item.id;
|
|
14529
14658
|
this.name = this.item.name;
|
|
14530
14659
|
var activationTrack = this.createTrack(Track, 'ActivationTrack');
|
|
14531
|
-
activationTrack.createClip(
|
|
14660
|
+
activationTrack.createClip(ActivationPlayable, 'ActivationTimelineClip');
|
|
14661
|
+
//@ts-expect-error
|
|
14662
|
+
if (data.tracks) {
|
|
14663
|
+
//@ts-expect-error
|
|
14664
|
+
var tracks = data.tracks;
|
|
14665
|
+
try {
|
|
14666
|
+
for (var tracks_1 = __values$1(tracks), tracks_1_1 = tracks_1.next(); !tracks_1_1.done; tracks_1_1 = tracks_1.next()) {
|
|
14667
|
+
var track = tracks_1_1.value;
|
|
14668
|
+
var newTrack = this.createTrack(Track);
|
|
14669
|
+
try {
|
|
14670
|
+
for (var _c = (e_14 = void 0, __values$1(track.clips)), _d = _c.next(); !_d.done; _d = _c.next()) {
|
|
14671
|
+
var clipAsset = _d.value;
|
|
14672
|
+
switch (clipAsset.dataType) {
|
|
14673
|
+
case 'TransformAnimationPlayableAsset':
|
|
14674
|
+
newTrack.name = 'AnimationTrack';
|
|
14675
|
+
newTrack.createClip(TransformAnimationPlayable, 'AnimationTimelineClip').playable.fromData(clipAsset.animationClip);
|
|
14676
|
+
break;
|
|
14677
|
+
case 'SpriteColorAnimationPlayableAsset':
|
|
14678
|
+
newTrack.name = 'SpriteColorTrack';
|
|
14679
|
+
newTrack.createClip(SpriteColorPlayable, 'SpriteColorClip').playable.fromData(clipAsset.animationClip);
|
|
14680
|
+
break;
|
|
14681
|
+
}
|
|
14682
|
+
}
|
|
14683
|
+
}
|
|
14684
|
+
catch (e_14_1) { e_14 = { error: e_14_1 }; }
|
|
14685
|
+
finally {
|
|
14686
|
+
try {
|
|
14687
|
+
if (_d && !_d.done && (_b = _c.return)) _b.call(_c);
|
|
14688
|
+
}
|
|
14689
|
+
finally { if (e_14) throw e_14.error; }
|
|
14690
|
+
}
|
|
14691
|
+
}
|
|
14692
|
+
}
|
|
14693
|
+
catch (e_13_1) { e_13 = { error: e_13_1 }; }
|
|
14694
|
+
finally {
|
|
14695
|
+
try {
|
|
14696
|
+
if (tracks_1_1 && !tracks_1_1.done && (_a = tracks_1.return)) _a.call(tracks_1);
|
|
14697
|
+
}
|
|
14698
|
+
finally { if (e_13) throw e_13.error; }
|
|
14699
|
+
}
|
|
14700
|
+
}
|
|
14532
14701
|
};
|
|
14533
14702
|
TimelineComponent.prototype.toData = function () {
|
|
14534
14703
|
_super.prototype.toData.call(this);
|
|
@@ -14942,9 +15111,6 @@ var SpriteComponent = /** @class */ (function (_super) {
|
|
|
14942
15111
|
this.material.setVector4('_Color', new Vector4$1().setFromArray(startColor));
|
|
14943
15112
|
this.material.setVector4('_TexOffset', new Vector4$1().setFromArray([0, 0, 1, 1]));
|
|
14944
15113
|
this.setItem();
|
|
14945
|
-
// 添加K帧动画
|
|
14946
|
-
var colorTrack = this.item.getComponent(TimelineComponent).createTrack(Track, 'SpriteColorTrack');
|
|
14947
|
-
colorTrack.createClip(SpriteColorPlayable, 'SpriteColorClip').playable.fromData({ colorOverLifetime: data.colorOverLifetime, startColor: data.options.startColor });
|
|
14948
15114
|
};
|
|
14949
15115
|
SpriteComponent.prototype.toData = function () {
|
|
14950
15116
|
_super.prototype.toData.call(this);
|
|
@@ -15111,8 +15277,8 @@ var ParticleMesh = /** @class */ (function () {
|
|
|
15111
15277
|
var originalVertex = "#define LOOKUP_TEXTURE_CURVE ".concat(vertex_lookup_texture, "\n").concat(particleVert);
|
|
15112
15278
|
var vertex = originalVertex;
|
|
15113
15279
|
var shader = {
|
|
15114
|
-
fragment:
|
|
15115
|
-
vertex:
|
|
15280
|
+
fragment: fragment,
|
|
15281
|
+
vertex: vertex,
|
|
15116
15282
|
glslVersion: level === 1 ? exports.GLSLVersion.GLSL1 : exports.GLSLVersion.GLSL3,
|
|
15117
15283
|
shared: true,
|
|
15118
15284
|
cacheId: shaderCache,
|
|
@@ -15667,8 +15833,8 @@ var TrailMesh = /** @class */ (function () {
|
|
|
15667
15833
|
else {
|
|
15668
15834
|
uniformValues.uVCurveValues = CurveValue.getAllData(keyFrameMeta);
|
|
15669
15835
|
}
|
|
15670
|
-
var vertex =
|
|
15671
|
-
var fragment =
|
|
15836
|
+
var vertex = trailVert;
|
|
15837
|
+
var fragment = particleFrag;
|
|
15672
15838
|
var mtl = ({
|
|
15673
15839
|
shader: {
|
|
15674
15840
|
vertex: vertex,
|
|
@@ -16355,7 +16521,7 @@ var TextureShape = /** @class */ (function () {
|
|
|
16355
16521
|
return TextureShape;
|
|
16356
16522
|
}());
|
|
16357
16523
|
|
|
16358
|
-
var _a$
|
|
16524
|
+
var _a$6;
|
|
16359
16525
|
var ShapeNone = /** @class */ (function () {
|
|
16360
16526
|
function ShapeNone() {
|
|
16361
16527
|
}
|
|
@@ -16367,18 +16533,18 @@ var ShapeNone = /** @class */ (function () {
|
|
|
16367
16533
|
};
|
|
16368
16534
|
return ShapeNone;
|
|
16369
16535
|
}());
|
|
16370
|
-
var map$1 = (_a$
|
|
16371
|
-
_a$
|
|
16372
|
-
_a$
|
|
16373
|
-
_a$
|
|
16374
|
-
_a$
|
|
16375
|
-
_a$
|
|
16376
|
-
_a$
|
|
16377
|
-
_a$
|
|
16378
|
-
_a$
|
|
16379
|
-
_a$
|
|
16380
|
-
_a$
|
|
16381
|
-
_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);
|
|
16382
16548
|
function createShape(shapeOptions) {
|
|
16383
16549
|
if (!shapeOptions) {
|
|
16384
16550
|
return new ShapeNone();
|
|
@@ -17707,7 +17873,7 @@ var ParticleSystem = /** @class */ (function (_super) {
|
|
|
17707
17873
|
}));
|
|
17708
17874
|
p.delay += meshTime;
|
|
17709
17875
|
cursor++;
|
|
17710
|
-
(_a = p.transform).translate.apply(_a, __spreadArray$
|
|
17876
|
+
(_a = p.transform).translate.apply(_a, __spreadArray$3([], __read$3(burstOffset), false));
|
|
17711
17877
|
this.addParticle(p, maxCount_1);
|
|
17712
17878
|
}
|
|
17713
17879
|
}
|
|
@@ -18479,7 +18645,9 @@ var TextStyle = /** @class */ (function () {
|
|
|
18479
18645
|
this.fontOffset = 0;
|
|
18480
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;
|
|
18481
18647
|
this.textColor = textColor;
|
|
18648
|
+
//@ts-expect-error
|
|
18482
18649
|
this.textWeight = fontWeight;
|
|
18650
|
+
//@ts-expect-error
|
|
18483
18651
|
this.fontStyle = fontStyle;
|
|
18484
18652
|
this.fontFamily = fontFamily;
|
|
18485
18653
|
this.fontSize = fontSize; // 暂时取消字号限制 Math.min(fontSize, this.maxFontSize);
|
|
@@ -20547,7 +20715,10 @@ var VFXItem = /** @class */ (function (_super) {
|
|
|
20547
20715
|
try {
|
|
20548
20716
|
for (var _e = __values$1(this.children), _f = _e.next(); !_f.done; _f = _e.next()) {
|
|
20549
20717
|
var child = _f.value;
|
|
20550
|
-
|
|
20718
|
+
var res = child.find(name);
|
|
20719
|
+
if (res) {
|
|
20720
|
+
return res;
|
|
20721
|
+
}
|
|
20551
20722
|
}
|
|
20552
20723
|
}
|
|
20553
20724
|
catch (e_4_1) { e_4 = { error: e_4_1 }; }
|
|
@@ -20564,6 +20735,7 @@ var VFXItem = /** @class */ (function (_super) {
|
|
|
20564
20735
|
_super.prototype.fromData.call(this, data);
|
|
20565
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;
|
|
20566
20737
|
this.props = data;
|
|
20738
|
+
//@ts-expect-error
|
|
20567
20739
|
this.type = data.type;
|
|
20568
20740
|
this.id = id.toString(); // TODO 老数据 id 是 number,需要转换
|
|
20569
20741
|
this.name = name;
|
|
@@ -20601,10 +20773,6 @@ var VFXItem = /** @class */ (function (_super) {
|
|
|
20601
20773
|
}
|
|
20602
20774
|
var timelineComponent = this.getComponent(TimelineComponent);
|
|
20603
20775
|
timelineComponent.fromData(data.content);
|
|
20604
|
-
if (this.type !== ItemType$1.particle) {
|
|
20605
|
-
var track = timelineComponent.createTrack(Track, 'AnimationTrack');
|
|
20606
|
-
track.createClip(AnimationClipPlayable, 'AnimationTimelineClip').playable.fromData(data.content);
|
|
20607
|
-
}
|
|
20608
20776
|
if (duration <= 0) {
|
|
20609
20777
|
throw Error("Item duration can't be less than 0, see ".concat(HELP_LINK$1['Item duration can\'t be less than 0']));
|
|
20610
20778
|
}
|
|
@@ -20663,10 +20831,10 @@ var VFXItem = /** @class */ (function (_super) {
|
|
|
20663
20831
|
};
|
|
20664
20832
|
VFXItem.prototype.translateByPixel = function (x, y) {
|
|
20665
20833
|
if (this.composition) {
|
|
20834
|
+
// @ts-expect-error
|
|
20835
|
+
var _a = this.composition.renderer.canvas.getBoundingClientRect(), width = _a.width, height = _a.height;
|
|
20666
20836
|
var z = this.transform.getWorldPosition().z;
|
|
20667
|
-
var
|
|
20668
|
-
var width = this.composition.renderer.getWidth() / 2;
|
|
20669
|
-
var height = this.composition.renderer.getHeight() / 2;
|
|
20837
|
+
var _b = this.composition.camera.getInverseVPRatio(z), rx = _b.x, ry = _b.y;
|
|
20670
20838
|
this.transform.translate(2 * x * rx / width, -2 * y * ry / height, 0);
|
|
20671
20839
|
}
|
|
20672
20840
|
};
|
|
@@ -20771,7 +20939,6 @@ function createVFXItem(props, composition) {
|
|
|
20771
20939
|
if (!pluginName) {
|
|
20772
20940
|
switch (type) {
|
|
20773
20941
|
case ItemType$1.null:
|
|
20774
|
-
case ItemType$1.base:
|
|
20775
20942
|
pluginName = 'cal';
|
|
20776
20943
|
break;
|
|
20777
20944
|
case ItemType$1.sprite:
|
|
@@ -20892,7 +21059,7 @@ var PluginSystem = /** @class */ (function () {
|
|
|
20892
21059
|
plugin = plugins[i];
|
|
20893
21060
|
ctrl = pluginLoaderMap[plugin.name];
|
|
20894
21061
|
if (name in ctrl) {
|
|
20895
|
-
pendings.push(Promise.resolve(ctrl[name].apply(ctrl, __spreadArray$
|
|
21062
|
+
pendings.push(Promise.resolve(ctrl[name].apply(ctrl, __spreadArray$3([], __read$3(args), false))));
|
|
20896
21063
|
}
|
|
20897
21064
|
}
|
|
20898
21065
|
return [2 /*return*/, Promise.all(pendings)];
|
|
@@ -20937,9 +21104,74 @@ function getPluginUsageInfo(name) {
|
|
|
20937
21104
|
* Name: @galacean/effects-specification
|
|
20938
21105
|
* Description: Galacean Effects JSON Specification
|
|
20939
21106
|
* Author: Ant Group CO., Ltd.
|
|
20940
|
-
* Version:
|
|
21107
|
+
* Version: v2.0.0-alpha.2
|
|
21108
|
+
*/
|
|
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
|
|
20941
21137
|
*/
|
|
20942
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
|
+
|
|
20943
21175
|
/*********************************************/
|
|
20944
21176
|
/* 元素属性参数类型 */
|
|
20945
21177
|
/*********************************************/
|
|
@@ -21202,6 +21434,10 @@ var ItemType;
|
|
|
21202
21434
|
* 天空盒元素
|
|
21203
21435
|
*/
|
|
21204
21436
|
ItemType["skybox"] = "skybox";
|
|
21437
|
+
/**
|
|
21438
|
+
* 特效元素
|
|
21439
|
+
*/
|
|
21440
|
+
ItemType["effect"] = "effect";
|
|
21205
21441
|
})(ItemType || (ItemType = {}));
|
|
21206
21442
|
/**
|
|
21207
21443
|
* 渲染模式
|
|
@@ -21314,6 +21550,10 @@ var CompositionEndBehavior;
|
|
|
21314
21550
|
* 销毁并保留最后一帧
|
|
21315
21551
|
*/
|
|
21316
21552
|
CompositionEndBehavior[CompositionEndBehavior["pause_destroy"] = END_BEHAVIOR_PAUSE_AND_DESTROY] = "pause_destroy";
|
|
21553
|
+
/**
|
|
21554
|
+
* 冻结
|
|
21555
|
+
*/
|
|
21556
|
+
CompositionEndBehavior[CompositionEndBehavior["freeze"] = END_BEHAVIOR_FREEZE] = "freeze";
|
|
21317
21557
|
})(CompositionEndBehavior || (CompositionEndBehavior = {}));
|
|
21318
21558
|
|
|
21319
21559
|
/*********************************************/
|
|
@@ -21441,14 +21681,34 @@ var ShapeArcMode;
|
|
|
21441
21681
|
*/
|
|
21442
21682
|
ShapeArcMode[ShapeArcMode["UNIDIRECTIONAL_CYCLE"] = 1] = "UNIDIRECTIONAL_CYCLE";
|
|
21443
21683
|
/**
|
|
21444
|
-
* 双向循环
|
|
21684
|
+
* 双向循环
|
|
21685
|
+
*/
|
|
21686
|
+
ShapeArcMode[ShapeArcMode["BIDIRECTIONAL_CYCLE"] = 2] = "BIDIRECTIONAL_CYCLE";
|
|
21687
|
+
/**
|
|
21688
|
+
* 均匀爆发
|
|
21689
|
+
*/
|
|
21690
|
+
ShapeArcMode[ShapeArcMode["UNIFORM_BURST"] = 3] = "UNIFORM_BURST";
|
|
21691
|
+
})(ShapeArcMode || (ShapeArcMode = {}));
|
|
21692
|
+
|
|
21693
|
+
var LightType;
|
|
21694
|
+
(function (LightType) {
|
|
21695
|
+
/**
|
|
21696
|
+
* 点光源
|
|
21697
|
+
*/
|
|
21698
|
+
LightType["point"] = "point";
|
|
21699
|
+
/**
|
|
21700
|
+
* 聚光灯
|
|
21701
|
+
*/
|
|
21702
|
+
LightType["spot"] = "spot";
|
|
21703
|
+
/**
|
|
21704
|
+
* 方向光
|
|
21445
21705
|
*/
|
|
21446
|
-
|
|
21706
|
+
LightType["directional"] = "directional";
|
|
21447
21707
|
/**
|
|
21448
|
-
*
|
|
21708
|
+
* 环境光
|
|
21449
21709
|
*/
|
|
21450
|
-
|
|
21451
|
-
})(
|
|
21710
|
+
LightType["ambient"] = "ambient";
|
|
21711
|
+
})(LightType || (LightType = {}));
|
|
21452
21712
|
|
|
21453
21713
|
var ModelBoundingType;
|
|
21454
21714
|
(function (ModelBoundingType) {
|
|
@@ -21456,6 +21716,12 @@ var ModelBoundingType;
|
|
|
21456
21716
|
ModelBoundingType[ModelBoundingType["sphere"] = 3] = "sphere";
|
|
21457
21717
|
})(ModelBoundingType || (ModelBoundingType = {}));
|
|
21458
21718
|
|
|
21719
|
+
var CameraType;
|
|
21720
|
+
(function (CameraType) {
|
|
21721
|
+
CameraType["orthographic"] = "orthographic";
|
|
21722
|
+
CameraType["perspective"] = "perspective";
|
|
21723
|
+
})(CameraType || (CameraType = {}));
|
|
21724
|
+
|
|
21459
21725
|
// 材质类型
|
|
21460
21726
|
var MaterialType;
|
|
21461
21727
|
(function (MaterialType) {
|
|
@@ -21601,6 +21867,28 @@ var FontStyle;
|
|
|
21601
21867
|
FontStyle["oblique"] = "oblique";
|
|
21602
21868
|
})(FontStyle || (FontStyle = {}));
|
|
21603
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
|
+
|
|
21604
21892
|
/******************************************************************************
|
|
21605
21893
|
Copyright (c) Microsoft Corporation.
|
|
21606
21894
|
|
|
@@ -21656,11 +21944,22 @@ function __read(o, n) {
|
|
|
21656
21944
|
return ar;
|
|
21657
21945
|
}
|
|
21658
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
|
+
|
|
21659
21957
|
typeof SuppressedError === "function" ? SuppressedError : function (error, suppressed, message) {
|
|
21660
21958
|
var e = new Error(message);
|
|
21661
21959
|
return e.name = "SuppressedError", e.error = error, e.suppressed = suppressed, e;
|
|
21662
21960
|
};
|
|
21663
21961
|
|
|
21962
|
+
var _a$5;
|
|
21664
21963
|
function arrAdd(arr, item) {
|
|
21665
21964
|
if (!arr.includes(item)) {
|
|
21666
21965
|
arr.push(item);
|
|
@@ -21896,6 +22195,34 @@ function rotationZYXFromQuat(out, quat) {
|
|
|
21896
22195
|
}
|
|
21897
22196
|
return out;
|
|
21898
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);
|
|
21899
22226
|
|
|
21900
22227
|
function getStandardParticleContent(particle) {
|
|
21901
22228
|
var _a;
|
|
@@ -22307,6 +22634,309 @@ function version22Migration(json) {
|
|
|
22307
22634
|
});
|
|
22308
22635
|
return json;
|
|
22309
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
|
+
}
|
|
22310
22940
|
|
|
22311
22941
|
var v0 = /^(\d+)\.(\d+)\.(\d+)(-(\w+)\.\d+)?$/;
|
|
22312
22942
|
var standardVersion = /^(\d+)\.(\d+)$/;
|
|
@@ -22316,16 +22946,16 @@ function getStandardJSON(json) {
|
|
|
22316
22946
|
if (!json || typeof json !== 'object') {
|
|
22317
22947
|
throw Error('expect a json object');
|
|
22318
22948
|
}
|
|
22319
|
-
// 修正老版本数据中,meshItem以及lightItem结束行为错误问题
|
|
22949
|
+
// 修正老版本数据中,meshItem 以及 lightItem 结束行为错误问题
|
|
22320
22950
|
version22Migration(json);
|
|
22321
22951
|
if (v0.test(json.version)) {
|
|
22322
22952
|
reverseParticle = ((_a = (/^(\d+)/).exec(json.version)) === null || _a === void 0 ? void 0 : _a[0]) === '0';
|
|
22323
|
-
return version21Migration(getStandardJSONFromV0(json));
|
|
22953
|
+
return version30Migration(version21Migration(getStandardJSONFromV0(json)));
|
|
22324
22954
|
}
|
|
22325
22955
|
var mainVersion = (_b = standardVersion.exec(json.version)) === null || _b === void 0 ? void 0 : _b[1];
|
|
22326
22956
|
if (mainVersion) {
|
|
22327
|
-
if (Number(mainVersion) <
|
|
22328
|
-
return version21Migration(json);
|
|
22957
|
+
if (Number(mainVersion) < 3) {
|
|
22958
|
+
return version30Migration(version21Migration(json));
|
|
22329
22959
|
}
|
|
22330
22960
|
return json;
|
|
22331
22961
|
}
|
|
@@ -22649,7 +23279,7 @@ function version3Migration(scene) {
|
|
|
22649
23279
|
try {
|
|
22650
23280
|
for (var _j = __values$1(ecScene.items), _k = _j.next(); !_k.done; _k = _j.next()) {
|
|
22651
23281
|
var item = _k.value;
|
|
22652
|
-
itemGuidMap[item.id] = generateGUID();
|
|
23282
|
+
itemGuidMap[item.id] = generateGUID$1();
|
|
22653
23283
|
// TODO: 编辑器测试用,上线后删除
|
|
22654
23284
|
//@ts-expect-error
|
|
22655
23285
|
item.oldId = item.id;
|
|
@@ -22705,7 +23335,7 @@ function version3Migration(scene) {
|
|
|
22705
23335
|
// texture 增加 id 和 dataType
|
|
22706
23336
|
for (var _q = __values$1(scene.textureOptions), _r = _q.next(); !_r.done; _r = _q.next()) {
|
|
22707
23337
|
var texture = _r.value;
|
|
22708
|
-
texture.id = generateGUID();
|
|
23338
|
+
texture.id = generateGUID$1();
|
|
22709
23339
|
texture.dataType = exports.DataType.Texture;
|
|
22710
23340
|
}
|
|
22711
23341
|
}
|
|
@@ -22725,23 +23355,15 @@ function version3Migration(scene) {
|
|
|
22725
23355
|
var item = _t.value;
|
|
22726
23356
|
// 原 texture 索引转为统一 guid 索引
|
|
22727
23357
|
if (item.content) {
|
|
22728
|
-
//@ts-expect-error
|
|
22729
23358
|
if (item.content.renderer) {
|
|
22730
|
-
//@ts-expect-error
|
|
22731
23359
|
if (item.content.renderer.texture !== undefined) {
|
|
22732
|
-
//@ts-expect-error
|
|
22733
23360
|
var oldTextureId = item.content.renderer.texture;
|
|
22734
|
-
//@ts-expect-error
|
|
22735
23361
|
item.content.renderer.texture = { id: scene.textureOptions[oldTextureId].id };
|
|
22736
23362
|
}
|
|
22737
23363
|
}
|
|
22738
|
-
//@ts-expect-error
|
|
22739
23364
|
if (item.content.trails) {
|
|
22740
|
-
//@ts-expect-error
|
|
22741
23365
|
if (item.content.trails.texture !== undefined) {
|
|
22742
|
-
//@ts-expect-error
|
|
22743
23366
|
var oldTextureId = item.content.trails.texture;
|
|
22744
|
-
//@ts-expect-error
|
|
22745
23367
|
item.content.trails.texture = { id: scene.textureOptions[oldTextureId].id };
|
|
22746
23368
|
}
|
|
22747
23369
|
}
|
|
@@ -22752,12 +23374,14 @@ function version3Migration(scene) {
|
|
|
22752
23374
|
var rotation = item.transform.rotation;
|
|
22753
23375
|
var scale = item.transform.scale;
|
|
22754
23376
|
if (!position) {
|
|
23377
|
+
//@ts-expect-error
|
|
22755
23378
|
position = [0, 0, 0];
|
|
22756
23379
|
}
|
|
22757
23380
|
if (!rotation) {
|
|
22758
23381
|
rotation = [0, 0, 0];
|
|
22759
23382
|
}
|
|
22760
23383
|
if (!scale) {
|
|
23384
|
+
//@ts-expect-error
|
|
22761
23385
|
scale = [1, 1, 1];
|
|
22762
23386
|
}
|
|
22763
23387
|
item.transform = {
|
|
@@ -22778,12 +23402,9 @@ function version3Migration(scene) {
|
|
|
22778
23402
|
// sprite 的 anchor 修正
|
|
22779
23403
|
if (item.type === ItemType$1.sprite) {
|
|
22780
23404
|
var content = item.content;
|
|
22781
|
-
//@ts-expect-error
|
|
22782
23405
|
if (!content.renderer) {
|
|
22783
|
-
//@ts-expect-error
|
|
22784
23406
|
content.renderer = {};
|
|
22785
23407
|
}
|
|
22786
|
-
//@ts-expect-error
|
|
22787
23408
|
var renderer = content.renderer;
|
|
22788
23409
|
var realAnchor = convertAnchor(renderer.anchor, renderer.particleOrigin);
|
|
22789
23410
|
//@ts-expect-error
|
|
@@ -22801,14 +23422,10 @@ function version3Migration(scene) {
|
|
|
22801
23422
|
}
|
|
22802
23423
|
if (item.type === ItemType$1.particle) {
|
|
22803
23424
|
var content = item.content;
|
|
22804
|
-
//@ts-expect-error
|
|
22805
23425
|
if (!content.renderer) {
|
|
22806
|
-
//@ts-expect-error
|
|
22807
23426
|
content.renderer = {};
|
|
22808
23427
|
}
|
|
22809
|
-
//@ts-expect-error
|
|
22810
23428
|
var renderer = content.renderer;
|
|
22811
|
-
//@ts-expect-error
|
|
22812
23429
|
content.renderer.anchor = convertAnchor(renderer.anchor, renderer.particleOrigin);
|
|
22813
23430
|
}
|
|
22814
23431
|
// item 的 endbehaviour 兼容
|
|
@@ -22816,164 +23433,138 @@ function version3Migration(scene) {
|
|
|
22816
23433
|
if (item.endBehavior === END_BEHAVIOR_PAUSE_AND_DESTROY$1 || item.endBehavior === END_BEHAVIOR_PAUSE$1) {
|
|
22817
23434
|
item.endBehavior = END_BEHAVIOR_FREEZE$1;
|
|
22818
23435
|
}
|
|
23436
|
+
// 动画数据转化 TODO: 动画数据移到 TimelineComponentData
|
|
23437
|
+
item.content.tracks = [];
|
|
23438
|
+
var tracks = item.content.tracks;
|
|
23439
|
+
if (item.type !== ItemType$1.particle) {
|
|
23440
|
+
tracks.push({
|
|
23441
|
+
clips: [
|
|
23442
|
+
{
|
|
23443
|
+
dataType: 'TransformAnimationPlayableAsset',
|
|
23444
|
+
animationClip: {
|
|
23445
|
+
sizeOverLifetime: item.content.sizeOverLifetime,
|
|
23446
|
+
rotationOverLifetime: item.content.rotationOverLifetime,
|
|
23447
|
+
positionOverLifetime: item.content.positionOverLifetime,
|
|
23448
|
+
},
|
|
23449
|
+
},
|
|
23450
|
+
],
|
|
23451
|
+
});
|
|
23452
|
+
}
|
|
23453
|
+
if (item.type === ItemType$1.sprite) {
|
|
23454
|
+
tracks.push({
|
|
23455
|
+
clips: [
|
|
23456
|
+
{
|
|
23457
|
+
dataType: 'SpriteColorAnimationPlayableAsset',
|
|
23458
|
+
animationClip: {
|
|
23459
|
+
colorOverLifetime: item.content.colorOverLifetime,
|
|
23460
|
+
startColor: item.content.options.startColor,
|
|
23461
|
+
},
|
|
23462
|
+
},
|
|
23463
|
+
],
|
|
23464
|
+
});
|
|
23465
|
+
}
|
|
23466
|
+
// gizmo 的 target id 转换为新的 item guid
|
|
23467
|
+
if (item.content && item.content.options && item.content.options.target) {
|
|
23468
|
+
item.content.options.target = itemGuidMap[item.content.options.target];
|
|
23469
|
+
}
|
|
22819
23470
|
// item 的 content 转为 component data 加入 JSONScene.components
|
|
22820
|
-
var uuid = v4().replace(/-/g, '');
|
|
23471
|
+
var uuid = v4$1().replace(/-/g, '');
|
|
22821
23472
|
if (item.type === ItemType$1.sprite) {
|
|
22822
|
-
//@ts-expect-error
|
|
22823
23473
|
item.components = [];
|
|
22824
|
-
//@ts-expect-error
|
|
22825
23474
|
components.push(item.content);
|
|
22826
|
-
//@ts-expect-error
|
|
22827
23475
|
item.content.id = uuid;
|
|
22828
|
-
//@ts-expect-error
|
|
22829
23476
|
item.content.dataType = exports.DataType.SpriteComponent;
|
|
22830
|
-
//@ts-expect-error
|
|
22831
23477
|
item.content.item = { id: item.id };
|
|
22832
|
-
//@ts-expect-error
|
|
22833
23478
|
item.dataType = exports.DataType.VFXItemData;
|
|
22834
23479
|
//@ts-expect-error
|
|
22835
23480
|
item.components.push({ id: item.content.id });
|
|
22836
23481
|
}
|
|
22837
23482
|
else if (item.type === ItemType$1.particle) {
|
|
22838
|
-
//@ts-expect-error
|
|
22839
23483
|
item.components = [];
|
|
22840
|
-
//@ts-expect-error
|
|
22841
23484
|
components.push(item.content);
|
|
22842
|
-
//@ts-expect-error
|
|
22843
23485
|
item.content.id = uuid;
|
|
22844
|
-
//@ts-expect-error
|
|
22845
23486
|
item.content.dataType = exports.DataType.ParticleSystem;
|
|
22846
|
-
//@ts-expect-error
|
|
22847
23487
|
item.content.item = { id: item.id };
|
|
22848
|
-
//@ts-expect-error
|
|
22849
23488
|
item.dataType = exports.DataType.VFXItemData;
|
|
22850
23489
|
//@ts-expect-error
|
|
22851
23490
|
item.components.push({ id: item.content.id });
|
|
22852
23491
|
}
|
|
22853
23492
|
else if (item.type === ItemType$1.mesh) {
|
|
22854
|
-
//@ts-expect-error
|
|
22855
23493
|
item.components = [];
|
|
22856
|
-
//@ts-expect-error
|
|
22857
23494
|
components.push(item.content);
|
|
22858
|
-
//@ts-expect-error
|
|
22859
23495
|
item.content.id = uuid;
|
|
22860
|
-
//@ts-expect-error
|
|
22861
23496
|
item.content.dataType = exports.DataType.MeshComponent;
|
|
22862
|
-
//@ts-expect-error
|
|
22863
23497
|
item.content.item = { id: item.id };
|
|
22864
|
-
//@ts-expect-error
|
|
22865
23498
|
item.dataType = exports.DataType.VFXItemData;
|
|
22866
23499
|
//@ts-expect-error
|
|
22867
23500
|
item.components.push({ id: item.content.id });
|
|
22868
23501
|
}
|
|
22869
23502
|
else if (item.type === ItemType$1.skybox) {
|
|
22870
|
-
//@ts-expect-error
|
|
22871
23503
|
item.components = [];
|
|
22872
|
-
//@ts-expect-error
|
|
22873
23504
|
components.push(item.content);
|
|
22874
|
-
//@ts-expect-error
|
|
22875
23505
|
item.content.id = uuid;
|
|
22876
|
-
//@ts-expect-error
|
|
22877
23506
|
item.content.dataType = exports.DataType.SkyboxComponent;
|
|
22878
|
-
//@ts-expect-error
|
|
22879
23507
|
item.content.item = { id: item.id };
|
|
22880
|
-
//@ts-expect-error
|
|
22881
23508
|
item.dataType = exports.DataType.VFXItemData;
|
|
22882
23509
|
//@ts-expect-error
|
|
22883
23510
|
item.components.push({ id: item.content.id });
|
|
22884
23511
|
}
|
|
22885
23512
|
else if (item.type === ItemType$1.light) {
|
|
22886
|
-
//@ts-expect-error
|
|
22887
23513
|
item.components = [];
|
|
22888
|
-
//@ts-expect-error
|
|
22889
23514
|
components.push(item.content);
|
|
22890
|
-
//@ts-expect-error
|
|
22891
23515
|
item.content.id = uuid;
|
|
22892
|
-
//@ts-expect-error
|
|
22893
23516
|
item.content.dataType = exports.DataType.LightComponent;
|
|
22894
|
-
//@ts-expect-error
|
|
22895
23517
|
item.content.item = { id: item.id };
|
|
22896
|
-
//@ts-expect-error
|
|
22897
23518
|
item.dataType = exports.DataType.VFXItemData;
|
|
22898
23519
|
//@ts-expect-error
|
|
22899
23520
|
item.components.push({ id: item.content.id });
|
|
22900
23521
|
}
|
|
22901
23522
|
else if (item.type === 'camera') {
|
|
22902
|
-
//@ts-expect-error
|
|
22903
23523
|
item.components = [];
|
|
22904
|
-
//@ts-expect-error
|
|
22905
23524
|
components.push(item.content);
|
|
22906
|
-
//@ts-expect-error
|
|
22907
23525
|
item.content.id = uuid;
|
|
22908
|
-
//@ts-expect-error
|
|
22909
23526
|
item.content.dataType = exports.DataType.CameraComponent;
|
|
22910
|
-
//@ts-expect-error
|
|
22911
23527
|
item.content.item = { id: item.id };
|
|
22912
|
-
//@ts-expect-error
|
|
22913
23528
|
item.dataType = exports.DataType.VFXItemData;
|
|
22914
23529
|
//@ts-expect-error
|
|
22915
23530
|
item.components.push({ id: item.content.id });
|
|
22916
23531
|
}
|
|
22917
23532
|
else if (item.type === ItemType$1.tree) {
|
|
22918
|
-
//@ts-expect-error
|
|
22919
23533
|
item.components = [];
|
|
22920
|
-
//@ts-expect-error
|
|
22921
23534
|
components.push(item.content);
|
|
22922
|
-
//@ts-expect-error
|
|
22923
23535
|
item.content.id = uuid;
|
|
22924
|
-
//@ts-expect-error
|
|
22925
23536
|
item.content.dataType = exports.DataType.TreeComponent;
|
|
22926
|
-
//@ts-expect-error
|
|
22927
23537
|
item.content.item = { id: item.id };
|
|
22928
|
-
//@ts-expect-error
|
|
22929
23538
|
item.dataType = exports.DataType.VFXItemData;
|
|
22930
23539
|
//@ts-expect-error
|
|
22931
23540
|
item.components.push({ id: item.content.id });
|
|
22932
23541
|
}
|
|
22933
23542
|
else if (item.type === ItemType$1.interact) {
|
|
22934
|
-
//@ts-expect-error
|
|
22935
23543
|
item.components = [];
|
|
22936
|
-
//@ts-expect-error
|
|
22937
23544
|
components.push(item.content);
|
|
22938
|
-
//@ts-expect-error
|
|
22939
23545
|
item.content.id = uuid;
|
|
22940
|
-
//@ts-expect-error
|
|
22941
23546
|
item.content.dataType = exports.DataType.InteractComponent;
|
|
22942
|
-
//@ts-expect-error
|
|
22943
23547
|
item.content.item = { id: item.id };
|
|
22944
|
-
//@ts-expect-error
|
|
22945
23548
|
item.dataType = exports.DataType.VFXItemData;
|
|
22946
23549
|
//@ts-expect-error
|
|
22947
23550
|
item.components.push({ id: item.content.id });
|
|
22948
23551
|
}
|
|
22949
23552
|
else if (item.type === ItemType$1.camera) {
|
|
22950
|
-
//@ts-expect-error
|
|
22951
23553
|
item.components = [];
|
|
22952
|
-
//@ts-expect-error
|
|
22953
23554
|
components.push(item.content);
|
|
22954
|
-
//@ts-expect-error
|
|
22955
23555
|
item.content.id = uuid;
|
|
22956
|
-
//@ts-expect-error
|
|
22957
23556
|
item.content.dataType = exports.DataType.CameraController;
|
|
22958
|
-
//@ts-expect-error
|
|
22959
23557
|
item.content.item = { id: item.id };
|
|
22960
|
-
//@ts-expect-error
|
|
22961
23558
|
item.dataType = exports.DataType.VFXItemData;
|
|
22962
23559
|
//@ts-expect-error
|
|
22963
23560
|
item.components.push({ id: item.content.id });
|
|
22964
23561
|
}
|
|
22965
23562
|
else if (item.type === ItemType$1.text) {
|
|
22966
|
-
//@ts-expect-error
|
|
22967
23563
|
item.components = [];
|
|
22968
|
-
//@ts-expect-error
|
|
22969
23564
|
components.push(item.content);
|
|
22970
|
-
//@ts-expect-error
|
|
22971
23565
|
item.content.id = uuid;
|
|
22972
|
-
//@ts-expect-error
|
|
22973
23566
|
item.content.dataType = exports.DataType.TextComponent;
|
|
22974
|
-
//@ts-expect-error
|
|
22975
23567
|
item.content.item = { id: item.id };
|
|
22976
|
-
//@ts-expect-error
|
|
22977
23568
|
item.dataType = exports.DataType.VFXItemData;
|
|
22978
23569
|
//@ts-expect-error
|
|
22979
23570
|
item.components.push({ id: item.content.id });
|
|
@@ -22997,7 +23588,7 @@ function convertAnchor(anchor, particleOrigin) {
|
|
|
22997
23588
|
return [anchor[0] - 0.5, 0.5 - anchor[1]];
|
|
22998
23589
|
}
|
|
22999
23590
|
else if (particleOrigin) {
|
|
23000
|
-
return particleOriginTranslateMap[particleOrigin];
|
|
23591
|
+
return particleOriginTranslateMap$1[particleOrigin];
|
|
23001
23592
|
}
|
|
23002
23593
|
else {
|
|
23003
23594
|
return [0, 0];
|
|
@@ -23275,16 +23866,17 @@ var AssetManager = /** @class */ (function () {
|
|
|
23275
23866
|
};
|
|
23276
23867
|
AssetManager.prototype.processBins = function (bins) {
|
|
23277
23868
|
return __awaiter(this, void 0, void 0, function () {
|
|
23278
|
-
var renderLevel, jobs;
|
|
23869
|
+
var renderLevel, baseUrl, jobs;
|
|
23279
23870
|
var _this = this;
|
|
23280
23871
|
return __generator(this, function (_a) {
|
|
23281
23872
|
renderLevel = this.options.renderLevel;
|
|
23873
|
+
baseUrl = this.baseUrl;
|
|
23282
23874
|
jobs = bins.map(function (bin) {
|
|
23283
23875
|
if (bin instanceof ArrayBuffer) {
|
|
23284
23876
|
return bin;
|
|
23285
23877
|
}
|
|
23286
23878
|
if (passRenderLevel(bin.renderLevel, renderLevel)) {
|
|
23287
|
-
return _this.loadBins(bin.url);
|
|
23879
|
+
return _this.loadBins(new weapp.URL(bin.url, baseUrl).href);
|
|
23288
23880
|
}
|
|
23289
23881
|
throw new Error("Invalid bins source: ".concat(JSON.stringify(bins)));
|
|
23290
23882
|
});
|
|
@@ -23302,13 +23894,14 @@ var AssetManager = /** @class */ (function () {
|
|
|
23302
23894
|
return [2 /*return*/];
|
|
23303
23895
|
}
|
|
23304
23896
|
jobs = fonts.map(function (font) { return __awaiter(_this, void 0, void 0, function () {
|
|
23305
|
-
var fontFace;
|
|
23897
|
+
var url, fontFace;
|
|
23306
23898
|
var _a;
|
|
23307
23899
|
return __generator(this, function (_b) {
|
|
23308
23900
|
switch (_b.label) {
|
|
23309
23901
|
case 0:
|
|
23310
23902
|
if (!(font.fontURL && !AssetManager.fonts.has(font.fontFamily))) return [3 /*break*/, 4];
|
|
23311
|
-
|
|
23903
|
+
url = new weapp.URL(font.fontURL, this.baseUrl).href;
|
|
23904
|
+
fontFace = new FontFace((_a = font.fontFamily) !== null && _a !== void 0 ? _a : '', 'url(' + url + ')');
|
|
23312
23905
|
_b.label = 1;
|
|
23313
23906
|
case 1:
|
|
23314
23907
|
_b.trys.push([1, 3, , 4]);
|
|
@@ -23321,7 +23914,7 @@ var AssetManager = /** @class */ (function () {
|
|
|
23321
23914
|
return [3 /*break*/, 4];
|
|
23322
23915
|
case 3:
|
|
23323
23916
|
_b.sent();
|
|
23324
|
-
logger.warn("Invalid fonts source: ".concat(JSON.stringify(
|
|
23917
|
+
logger.warn("Invalid fonts source: ".concat(JSON.stringify(url)));
|
|
23325
23918
|
return [3 /*break*/, 4];
|
|
23326
23919
|
case 4: return [2 /*return*/];
|
|
23327
23920
|
}
|
|
@@ -23570,7 +24163,7 @@ function createTextureOptionsBySource(image, sourceFrom) {
|
|
|
23570
24163
|
return image.source;
|
|
23571
24164
|
}
|
|
23572
24165
|
else if (image instanceof weapp.HTMLImageElement ||
|
|
23573
|
-
image
|
|
24166
|
+
isCanvas(image)) {
|
|
23574
24167
|
return {
|
|
23575
24168
|
image: image,
|
|
23576
24169
|
sourceType: exports.TextureSourceType.image,
|
|
@@ -23632,6 +24225,11 @@ function base64ToFile(base64, filename, contentType) {
|
|
|
23632
24225
|
var file = new File([blob], filename, { type: contentType });
|
|
23633
24226
|
return file;
|
|
23634
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
|
+
}
|
|
23635
24233
|
|
|
23636
24234
|
var tmpScale = new Vector3(1, 1, 1);
|
|
23637
24235
|
/**
|
|
@@ -23851,8 +24449,9 @@ var Camera = /** @class */ (function () {
|
|
|
23851
24449
|
Camera.prototype.getInverseVPRatio = function (z) {
|
|
23852
24450
|
var pos = new Vector3(0, 0, z);
|
|
23853
24451
|
var mat = this.getViewProjectionMatrix();
|
|
23854
|
-
var
|
|
23855
|
-
|
|
24452
|
+
var inverseVP = this.getInverseViewProjectionMatrix();
|
|
24453
|
+
var nz = mat.projectPoint(pos).z;
|
|
24454
|
+
return inverseVP.projectPoint(new Vector3(1, 1, nz));
|
|
23856
24455
|
};
|
|
23857
24456
|
/**
|
|
23858
24457
|
* 设置相机的旋转四元数
|
|
@@ -23864,7 +24463,6 @@ var Camera = /** @class */ (function () {
|
|
|
23864
24463
|
this.dirty = true;
|
|
23865
24464
|
}
|
|
23866
24465
|
else {
|
|
23867
|
-
this.options.quat;
|
|
23868
24466
|
if (!this.options.quat.equals(value)) {
|
|
23869
24467
|
this.options.quat.copyFrom(value);
|
|
23870
24468
|
this.dirty = true;
|
|
@@ -24032,8 +24630,7 @@ var CompositionComponent = /** @class */ (function (_super) {
|
|
|
24032
24630
|
}
|
|
24033
24631
|
item.getComponent(CompositionComponent).createContent();
|
|
24034
24632
|
}
|
|
24035
|
-
else if (itemData.type ===
|
|
24036
|
-
itemData.type === ItemType$1.sprite ||
|
|
24633
|
+
else if (itemData.type === ItemType$1.sprite ||
|
|
24037
24634
|
itemData.type === ItemType$1.text ||
|
|
24038
24635
|
itemData.type === ItemType$1.particle ||
|
|
24039
24636
|
itemData.type === ItemType$1.mesh ||
|
|
@@ -24051,20 +24648,7 @@ var CompositionComponent = /** @class */ (function (_super) {
|
|
|
24051
24648
|
item = new VFXItem(this.engine, itemData);
|
|
24052
24649
|
item.composition = this.item.composition;
|
|
24053
24650
|
// 兼容老的数据代码,json 更新后可移除
|
|
24054
|
-
|
|
24055
|
-
case ItemType$1.text: {
|
|
24056
|
-
// 添加文本组件
|
|
24057
|
-
var textItem = new TextComponent(this.engine, itemData.content);
|
|
24058
|
-
textItem.item = item;
|
|
24059
|
-
item.components.push(textItem);
|
|
24060
|
-
item.rendererComponents.push(textItem);
|
|
24061
|
-
item._content = textItem;
|
|
24062
|
-
break;
|
|
24063
|
-
}
|
|
24064
|
-
default: {
|
|
24065
|
-
item = createVFXItem(itemData, this.item.composition);
|
|
24066
|
-
}
|
|
24067
|
-
}
|
|
24651
|
+
item = createVFXItem(itemData, this.item.composition);
|
|
24068
24652
|
}
|
|
24069
24653
|
item.parent = this.item;
|
|
24070
24654
|
// 相机不跟随合成移动
|
|
@@ -25454,10 +26038,8 @@ var Engine = /** @class */ (function () {
|
|
|
25454
26038
|
Engine.prototype.addPackageDatas = function (scene) {
|
|
25455
26039
|
var e_1, _a, e_2, _b, e_3, _c, e_4, _d, e_5, _e, e_6, _f;
|
|
25456
26040
|
var jsonScene = scene.jsonScene;
|
|
25457
|
-
//@ts-expect-error
|
|
25458
26041
|
if (jsonScene.items) {
|
|
25459
26042
|
try {
|
|
25460
|
-
//@ts-expect-error
|
|
25461
26043
|
for (var _g = __values$1(jsonScene.items), _h = _g.next(); !_h.done; _h = _g.next()) {
|
|
25462
26044
|
var vfxItemData = _h.value;
|
|
25463
26045
|
this.addEffectsObjectData(vfxItemData);
|
|
@@ -25471,10 +26053,8 @@ var Engine = /** @class */ (function () {
|
|
|
25471
26053
|
finally { if (e_1) throw e_1.error; }
|
|
25472
26054
|
}
|
|
25473
26055
|
}
|
|
25474
|
-
//@ts-expect-error
|
|
25475
26056
|
if (jsonScene.materials) {
|
|
25476
26057
|
try {
|
|
25477
|
-
//@ts-expect-error
|
|
25478
26058
|
for (var _j = __values$1(jsonScene.materials), _k = _j.next(); !_k.done; _k = _j.next()) {
|
|
25479
26059
|
var materialData = _k.value;
|
|
25480
26060
|
this.addEffectsObjectData(materialData);
|
|
@@ -25488,10 +26068,8 @@ var Engine = /** @class */ (function () {
|
|
|
25488
26068
|
finally { if (e_2) throw e_2.error; }
|
|
25489
26069
|
}
|
|
25490
26070
|
}
|
|
25491
|
-
//@ts-expect-error
|
|
25492
26071
|
if (jsonScene.shaders) {
|
|
25493
26072
|
try {
|
|
25494
|
-
//@ts-expect-error
|
|
25495
26073
|
for (var _l = __values$1(jsonScene.shaders), _m = _l.next(); !_m.done; _m = _l.next()) {
|
|
25496
26074
|
var shaderData = _m.value;
|
|
25497
26075
|
this.addEffectsObjectData(shaderData);
|
|
@@ -25505,10 +26083,8 @@ var Engine = /** @class */ (function () {
|
|
|
25505
26083
|
finally { if (e_3) throw e_3.error; }
|
|
25506
26084
|
}
|
|
25507
26085
|
}
|
|
25508
|
-
//@ts-expect-error
|
|
25509
26086
|
if (jsonScene.geometries) {
|
|
25510
26087
|
try {
|
|
25511
|
-
//@ts-expect-error
|
|
25512
26088
|
for (var _o = __values$1(jsonScene.geometries), _p = _o.next(); !_p.done; _p = _o.next()) {
|
|
25513
26089
|
var geometryData = _p.value;
|
|
25514
26090
|
this.addEffectsObjectData(geometryData);
|
|
@@ -25522,10 +26098,8 @@ var Engine = /** @class */ (function () {
|
|
|
25522
26098
|
finally { if (e_4) throw e_4.error; }
|
|
25523
26099
|
}
|
|
25524
26100
|
}
|
|
25525
|
-
//@ts-expect-error
|
|
25526
26101
|
if (jsonScene.components) {
|
|
25527
26102
|
try {
|
|
25528
|
-
//@ts-expect-error
|
|
25529
26103
|
for (var _q = __values$1(jsonScene.components), _r = _q.next(); !_r.done; _r = _q.next()) {
|
|
25530
26104
|
var componentData = _r.value;
|
|
25531
26105
|
this.addEffectsObjectData(componentData);
|
|
@@ -26490,7 +27064,7 @@ var GLRendererInternal = /** @class */ (function () {
|
|
|
26490
27064
|
}
|
|
26491
27065
|
var glGeometry = geometry;
|
|
26492
27066
|
var glMaterial = material;
|
|
26493
|
-
var program = glMaterial.
|
|
27067
|
+
var program = glMaterial.shaderVariant.program;
|
|
26494
27068
|
if (!program) {
|
|
26495
27069
|
console.warn('Material ' + glMaterial.name + ' 的shader着色器程序未初始化。');
|
|
26496
27070
|
return;
|
|
@@ -27360,8 +27934,8 @@ var GLMaterialState = /** @class */ (function () {
|
|
|
27360
27934
|
var Vector4 = Vector4$1, Matrix4 = Matrix4$1;
|
|
27361
27935
|
var GLMaterial = /** @class */ (function (_super) {
|
|
27362
27936
|
__extends(GLMaterial, _super);
|
|
27363
|
-
function GLMaterial() {
|
|
27364
|
-
var _this = _super
|
|
27937
|
+
function GLMaterial(engine, props) {
|
|
27938
|
+
var _this = _super.call(this, engine, props) || this;
|
|
27365
27939
|
// material存放的uniform数据。
|
|
27366
27940
|
_this.floats = {};
|
|
27367
27941
|
_this.ints = {};
|
|
@@ -27379,7 +27953,13 @@ var GLMaterial = /** @class */ (function (_super) {
|
|
|
27379
27953
|
_this.samplers = []; // material存放的sampler名称。
|
|
27380
27954
|
_this.uniforms = []; // material存放的uniform名称(不包括sampler)。
|
|
27381
27955
|
_this.uniformDirtyFlag = true;
|
|
27956
|
+
_this.macrosDirtyFlag = true;
|
|
27957
|
+
_this.macros = {};
|
|
27382
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
|
+
}
|
|
27383
27963
|
return _this;
|
|
27384
27964
|
}
|
|
27385
27965
|
Object.defineProperty(GLMaterial.prototype, "blending", {
|
|
@@ -27602,14 +28182,20 @@ var GLMaterial = /** @class */ (function (_super) {
|
|
|
27602
28182
|
enumerable: false,
|
|
27603
28183
|
configurable: true
|
|
27604
28184
|
});
|
|
27605
|
-
GLMaterial.prototype.
|
|
27606
|
-
|
|
28185
|
+
GLMaterial.prototype.enableMacro = function (keyword) {
|
|
28186
|
+
if (!this.isMacroEnabled(keyword)) {
|
|
28187
|
+
this.macros[keyword] = true;
|
|
28188
|
+
this.macrosDirtyFlag = true;
|
|
28189
|
+
}
|
|
27607
28190
|
};
|
|
27608
|
-
GLMaterial.prototype.
|
|
27609
|
-
|
|
28191
|
+
GLMaterial.prototype.disableMacro = function (keyword) {
|
|
28192
|
+
if (this.isMacroEnabled(keyword)) {
|
|
28193
|
+
delete this.macros[keyword];
|
|
28194
|
+
this.macrosDirtyFlag = true;
|
|
28195
|
+
}
|
|
27610
28196
|
};
|
|
27611
|
-
GLMaterial.prototype.
|
|
27612
|
-
|
|
28197
|
+
GLMaterial.prototype.isMacroEnabled = function (keyword) {
|
|
28198
|
+
return this.macros[keyword] !== undefined;
|
|
27613
28199
|
};
|
|
27614
28200
|
// TODO 待废弃 兼容 model/spine 插件 改造后可移除
|
|
27615
28201
|
GLMaterial.prototype.createMaterialStates = function (states) {
|
|
@@ -27640,11 +28226,11 @@ var GLMaterial = /** @class */ (function (_super) {
|
|
|
27640
28226
|
}
|
|
27641
28227
|
var glEngine = this.engine;
|
|
27642
28228
|
glEngine.addMaterial(this);
|
|
27643
|
-
if (!this.shader) {
|
|
27644
|
-
|
|
27645
|
-
this.
|
|
28229
|
+
if (!this.shaderVariant || this.shaderVariant.shader !== this.shader || this.macrosDirtyFlag) {
|
|
28230
|
+
this.shaderVariant = this.shader.createVariant(this.macros);
|
|
28231
|
+
this.macrosDirtyFlag = false;
|
|
27646
28232
|
}
|
|
27647
|
-
this.
|
|
28233
|
+
this.shaderVariant.initialize(glEngine);
|
|
27648
28234
|
Object.keys(this.textures).forEach(function (key) {
|
|
27649
28235
|
var texture = _this.textures[key];
|
|
27650
28236
|
if (!isFunction(texture.initialize)) {
|
|
@@ -27662,7 +28248,7 @@ var GLMaterial = /** @class */ (function (_super) {
|
|
|
27662
28248
|
var e_1, _a, e_2, _b;
|
|
27663
28249
|
var engine = renderer.engine;
|
|
27664
28250
|
var pipelineContext = engine.getGLPipelineContext();
|
|
27665
|
-
this.
|
|
28251
|
+
this.shaderVariant.program.bind();
|
|
27666
28252
|
this.setupStates(pipelineContext);
|
|
27667
28253
|
var name;
|
|
27668
28254
|
if (globalUniforms) {
|
|
@@ -27699,19 +28285,19 @@ var GLMaterial = /** @class */ (function (_super) {
|
|
|
27699
28285
|
}
|
|
27700
28286
|
// 更新 cached uniform location
|
|
27701
28287
|
if (this.uniformDirtyFlag) {
|
|
27702
|
-
this.
|
|
28288
|
+
this.shaderVariant.fillShaderInformation(this.uniforms, this.samplers);
|
|
27703
28289
|
this.uniformDirtyFlag = false;
|
|
27704
28290
|
}
|
|
27705
28291
|
if (globalUniforms) {
|
|
27706
28292
|
// 设置全局 uniform
|
|
27707
28293
|
for (name in globalUniforms.floats) {
|
|
27708
|
-
this.
|
|
28294
|
+
this.shaderVariant.setFloat(name, globalUniforms.floats[name]);
|
|
27709
28295
|
}
|
|
27710
28296
|
for (name in globalUniforms.ints) {
|
|
27711
|
-
this.
|
|
28297
|
+
this.shaderVariant.setInt(name, globalUniforms.ints[name]);
|
|
27712
28298
|
}
|
|
27713
28299
|
for (name in globalUniforms.matrices) {
|
|
27714
|
-
this.
|
|
28300
|
+
this.shaderVariant.setMatrix(name, globalUniforms.matrices[name]);
|
|
27715
28301
|
}
|
|
27716
28302
|
}
|
|
27717
28303
|
// 检查贴图数据是否初始化。
|
|
@@ -27721,43 +28307,43 @@ var GLMaterial = /** @class */ (function (_super) {
|
|
|
27721
28307
|
}
|
|
27722
28308
|
}
|
|
27723
28309
|
for (name in this.floats) {
|
|
27724
|
-
this.
|
|
28310
|
+
this.shaderVariant.setFloat(name, this.floats[name]);
|
|
27725
28311
|
}
|
|
27726
28312
|
for (name in this.ints) {
|
|
27727
|
-
this.
|
|
28313
|
+
this.shaderVariant.setInt(name, this.ints[name]);
|
|
27728
28314
|
}
|
|
27729
28315
|
for (name in this.floatArrays) {
|
|
27730
|
-
this.
|
|
28316
|
+
this.shaderVariant.setFloats(name, this.floatArrays[name]);
|
|
27731
28317
|
}
|
|
27732
28318
|
for (name in this.textures) {
|
|
27733
|
-
this.
|
|
28319
|
+
this.shaderVariant.setTexture(name, this.textures[name]);
|
|
27734
28320
|
}
|
|
27735
28321
|
for (name in this.vector2s) {
|
|
27736
|
-
this.
|
|
28322
|
+
this.shaderVariant.setVector2(name, this.vector2s[name]);
|
|
27737
28323
|
}
|
|
27738
28324
|
for (name in this.vector3s) {
|
|
27739
|
-
this.
|
|
28325
|
+
this.shaderVariant.setVector3(name, this.vector3s[name]);
|
|
27740
28326
|
}
|
|
27741
28327
|
for (name in this.vector4s) {
|
|
27742
|
-
this.
|
|
28328
|
+
this.shaderVariant.setVector4(name, this.vector4s[name]);
|
|
27743
28329
|
}
|
|
27744
28330
|
for (name in this.colors) {
|
|
27745
|
-
this.
|
|
28331
|
+
this.shaderVariant.setColor(name, this.colors[name]);
|
|
27746
28332
|
}
|
|
27747
28333
|
for (name in this.quaternions) {
|
|
27748
|
-
this.
|
|
28334
|
+
this.shaderVariant.setQuaternion(name, this.quaternions[name]);
|
|
27749
28335
|
}
|
|
27750
28336
|
for (name in this.matrices) {
|
|
27751
|
-
this.
|
|
28337
|
+
this.shaderVariant.setMatrix(name, this.matrices[name]);
|
|
27752
28338
|
}
|
|
27753
28339
|
for (name in this.matrice3s) {
|
|
27754
|
-
this.
|
|
28340
|
+
this.shaderVariant.setMatrix3(name, this.matrice3s[name]);
|
|
27755
28341
|
}
|
|
27756
28342
|
for (name in this.vector4Arrays) {
|
|
27757
|
-
this.
|
|
28343
|
+
this.shaderVariant.setVector4Array(name, this.vector4Arrays[name]);
|
|
27758
28344
|
}
|
|
27759
28345
|
for (name in this.matrixArrays) {
|
|
27760
|
-
this.
|
|
28346
|
+
this.shaderVariant.setMatrixArray(name, this.matrixArrays[name]);
|
|
27761
28347
|
}
|
|
27762
28348
|
};
|
|
27763
28349
|
GLMaterial.prototype.getFloat = function (name) {
|
|
@@ -27921,7 +28507,7 @@ var GLMaterial = /** @class */ (function (_super) {
|
|
|
27921
28507
|
this.ints = {};
|
|
27922
28508
|
this.floatArrays = {};
|
|
27923
28509
|
this.vector4s = {};
|
|
27924
|
-
var propertiesData = __assign$1({
|
|
28510
|
+
var propertiesData = __assign$1({ blending: false, zTest: false, zWrite: false }, data);
|
|
27925
28511
|
this.blending = propertiesData.blending;
|
|
27926
28512
|
this.depthTest = propertiesData.zTest;
|
|
27927
28513
|
this.depthMask = propertiesData.zWrite;
|
|
@@ -27944,13 +28530,13 @@ var GLMaterial = /** @class */ (function (_super) {
|
|
|
27944
28530
|
this.setColor(name, new Color(colorValue.r, colorValue.g, colorValue.b, colorValue.a));
|
|
27945
28531
|
}
|
|
27946
28532
|
for (name in propertiesData.textures) {
|
|
27947
|
-
var
|
|
28533
|
+
var textureProperties = propertiesData.textures[name];
|
|
27948
28534
|
// TODO 纹理通过 id 加入场景数据
|
|
27949
|
-
this.setTexture(name, texture);
|
|
28535
|
+
this.setTexture(name, textureProperties.texture);
|
|
27950
28536
|
}
|
|
27951
28537
|
if (data.shader) {
|
|
27952
28538
|
this.shader = data.shader;
|
|
27953
|
-
this.shaderSource = this.shader.
|
|
28539
|
+
this.shaderSource = this.shader.shaderData;
|
|
27954
28540
|
}
|
|
27955
28541
|
this.initialized = false;
|
|
27956
28542
|
};
|
|
@@ -27963,6 +28549,7 @@ var GLMaterial = /** @class */ (function (_super) {
|
|
|
27963
28549
|
//@ts-expect-error
|
|
27964
28550
|
var materialData = this.taggedProperties;
|
|
27965
28551
|
if (this.shader) {
|
|
28552
|
+
//@ts-expect-error
|
|
27966
28553
|
materialData.shader = this.shader;
|
|
27967
28554
|
}
|
|
27968
28555
|
materialData.floats = {};
|
|
@@ -28056,7 +28643,7 @@ var GLMaterial = /** @class */ (function (_super) {
|
|
|
28056
28643
|
if (this.destroyed) {
|
|
28057
28644
|
return;
|
|
28058
28645
|
}
|
|
28059
|
-
(_a = this.
|
|
28646
|
+
(_a = this.shaderVariant) === null || _a === void 0 ? void 0 : _a.dispose();
|
|
28060
28647
|
if ((options === null || options === void 0 ? void 0 : options.textures) !== exports.DestroyOptions.keep) {
|
|
28061
28648
|
Object.keys(this.textures).forEach(function (key) {
|
|
28062
28649
|
var texture = _this.textures[key];
|
|
@@ -28175,8 +28762,8 @@ var ExtWrap = /** @class */ (function () {
|
|
|
28175
28762
|
shader: {
|
|
28176
28763
|
cacheId: copyShaderId,
|
|
28177
28764
|
name: name,
|
|
28178
|
-
vertex:
|
|
28179
|
-
fragment:
|
|
28765
|
+
vertex: vertexShader,
|
|
28766
|
+
fragment: fragmentShader,
|
|
28180
28767
|
glslVersion: level === 2 ? exports.GLSLVersion.GLSL3 : exports.GLSLVersion.GLSL1,
|
|
28181
28768
|
},
|
|
28182
28769
|
});
|
|
@@ -28987,9 +29574,9 @@ var GLProgram = /** @class */ (function () {
|
|
|
28987
29574
|
return GLProgram;
|
|
28988
29575
|
}());
|
|
28989
29576
|
|
|
28990
|
-
var
|
|
28991
|
-
__extends(
|
|
28992
|
-
function
|
|
29577
|
+
var GLShaderVariant = /** @class */ (function (_super) {
|
|
29578
|
+
__extends(GLShaderVariant, _super);
|
|
29579
|
+
function GLShaderVariant(engine, source) {
|
|
28993
29580
|
var _this = _super.call(this, engine, source) || this;
|
|
28994
29581
|
_this.initialized = false;
|
|
28995
29582
|
_this.uniformLocations = {};
|
|
@@ -28997,7 +29584,7 @@ var GLShader = /** @class */ (function (_super) {
|
|
|
28997
29584
|
return _this;
|
|
28998
29585
|
}
|
|
28999
29586
|
// shader 的 GPU 资源初始化方法,在绘制前调用
|
|
29000
|
-
|
|
29587
|
+
GLShaderVariant.prototype.initialize = function (engine) {
|
|
29001
29588
|
if (this.initialized) {
|
|
29002
29589
|
return;
|
|
29003
29590
|
}
|
|
@@ -29006,46 +29593,46 @@ var GLShader = /** @class */ (function (_super) {
|
|
|
29006
29593
|
var pipelineContext = engine.getGLPipelineContext();
|
|
29007
29594
|
pipelineContext.shaderLibrary.compileShader(this);
|
|
29008
29595
|
};
|
|
29009
|
-
|
|
29596
|
+
GLShaderVariant.prototype.setFloat = function (name, value) {
|
|
29010
29597
|
this.pipelineContext.setFloat(this.uniformLocations[name], value);
|
|
29011
29598
|
};
|
|
29012
|
-
|
|
29599
|
+
GLShaderVariant.prototype.setInt = function (name, value) {
|
|
29013
29600
|
this.pipelineContext.setInt(this.uniformLocations[name], value);
|
|
29014
29601
|
};
|
|
29015
|
-
|
|
29602
|
+
GLShaderVariant.prototype.setFloats = function (name, value) {
|
|
29016
29603
|
this.pipelineContext.setFloats(this.uniformLocations[name], value);
|
|
29017
29604
|
};
|
|
29018
|
-
|
|
29605
|
+
GLShaderVariant.prototype.setTexture = function (name, texture) {
|
|
29019
29606
|
this.pipelineContext.setTexture(this.uniformLocations[name], this.samplerChannels[name], texture);
|
|
29020
29607
|
};
|
|
29021
|
-
|
|
29608
|
+
GLShaderVariant.prototype.setVector2 = function (name, value) {
|
|
29022
29609
|
this.pipelineContext.setVector2(this.uniformLocations[name], value);
|
|
29023
29610
|
};
|
|
29024
|
-
|
|
29611
|
+
GLShaderVariant.prototype.setVector3 = function (name, value) {
|
|
29025
29612
|
this.pipelineContext.setVector3(this.uniformLocations[name], value);
|
|
29026
29613
|
};
|
|
29027
|
-
|
|
29614
|
+
GLShaderVariant.prototype.setVector4 = function (name, value) {
|
|
29028
29615
|
this.pipelineContext.setVector4(this.uniformLocations[name], value);
|
|
29029
29616
|
};
|
|
29030
|
-
|
|
29617
|
+
GLShaderVariant.prototype.setColor = function (name, value) {
|
|
29031
29618
|
this.pipelineContext.setColor(this.uniformLocations[name], value);
|
|
29032
29619
|
};
|
|
29033
|
-
|
|
29620
|
+
GLShaderVariant.prototype.setQuaternion = function (name, value) {
|
|
29034
29621
|
this.pipelineContext.setQuaternion(this.uniformLocations[name], value);
|
|
29035
29622
|
};
|
|
29036
|
-
|
|
29623
|
+
GLShaderVariant.prototype.setMatrix = function (name, value) {
|
|
29037
29624
|
this.pipelineContext.setMatrix(this.uniformLocations[name], value);
|
|
29038
29625
|
};
|
|
29039
|
-
|
|
29626
|
+
GLShaderVariant.prototype.setMatrix3 = function (name, value) {
|
|
29040
29627
|
this.pipelineContext.setMatrix3(this.uniformLocations[name], value);
|
|
29041
29628
|
};
|
|
29042
|
-
|
|
29629
|
+
GLShaderVariant.prototype.setVector4Array = function (name, array) {
|
|
29043
29630
|
this.pipelineContext.setVector4Array(this.uniformLocations[name], array);
|
|
29044
29631
|
};
|
|
29045
|
-
|
|
29632
|
+
GLShaderVariant.prototype.setMatrixArray = function (name, array) {
|
|
29046
29633
|
this.pipelineContext.setMatrixArray(this.uniformLocations[name], array);
|
|
29047
29634
|
};
|
|
29048
|
-
|
|
29635
|
+
GLShaderVariant.prototype.fillShaderInformation = function (uniformNames, samplers) {
|
|
29049
29636
|
// 避免修改原数组。
|
|
29050
29637
|
var samplerList = samplers.slice();
|
|
29051
29638
|
uniformNames = uniformNames.concat(samplerList);
|
|
@@ -29066,22 +29653,22 @@ var GLShader = /** @class */ (function (_super) {
|
|
|
29066
29653
|
this.samplerChannels[samplerName] = index;
|
|
29067
29654
|
}
|
|
29068
29655
|
};
|
|
29069
|
-
|
|
29656
|
+
GLShaderVariant.prototype.toData = function () {
|
|
29070
29657
|
var shaderData = this.taggedProperties;
|
|
29071
29658
|
shaderData.dataType = exports.DataType.Shader;
|
|
29072
29659
|
shaderData.id = this.guid;
|
|
29073
29660
|
shaderData.vertex = this.source.vertex;
|
|
29074
29661
|
shaderData.fragment = this.source.fragment;
|
|
29075
29662
|
};
|
|
29076
|
-
|
|
29663
|
+
GLShaderVariant.prototype.dispose = function () {
|
|
29077
29664
|
var _a;
|
|
29078
29665
|
if (this.compileResult && this.compileResult.shared) {
|
|
29079
29666
|
return;
|
|
29080
29667
|
}
|
|
29081
29668
|
(_a = this.program) === null || _a === void 0 ? void 0 : _a.dispose();
|
|
29082
29669
|
};
|
|
29083
|
-
return
|
|
29084
|
-
}(
|
|
29670
|
+
return GLShaderVariant;
|
|
29671
|
+
}(ShaderVariant));
|
|
29085
29672
|
|
|
29086
29673
|
var shaderSeed = 0;
|
|
29087
29674
|
var GLShaderLibrary = /** @class */ (function () {
|
|
@@ -29136,25 +29723,33 @@ var GLShaderLibrary = /** @class */ (function () {
|
|
|
29136
29723
|
}
|
|
29137
29724
|
};
|
|
29138
29725
|
// TODO 创建shader的ShaderWithSource和shader的source类型一样,待优化。
|
|
29139
|
-
GLShaderLibrary.prototype.addShader = function (shaderSource) {
|
|
29140
|
-
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);
|
|
29141
29736
|
if (this.cachedShaders[shaderCacheId]) {
|
|
29142
29737
|
return shaderCacheId;
|
|
29143
29738
|
}
|
|
29144
29739
|
this.shaderAllDone = false;
|
|
29145
|
-
var header =
|
|
29146
|
-
var vertex =
|
|
29147
|
-
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 : '';
|
|
29148
29743
|
var shared = false;
|
|
29149
|
-
if (
|
|
29744
|
+
if (shaderWithMacros.shared || shaderWithMacros.cacheId) {
|
|
29150
29745
|
shared = true;
|
|
29151
29746
|
}
|
|
29152
|
-
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 }));
|
|
29153
29748
|
this.cachedShaders[shaderCacheId].id = shaderCacheId;
|
|
29154
29749
|
return shaderCacheId;
|
|
29155
29750
|
};
|
|
29156
|
-
GLShaderLibrary.prototype.createShader = function (shaderSource) {
|
|
29157
|
-
var shaderCacheId = this.addShader(shaderSource);
|
|
29751
|
+
GLShaderLibrary.prototype.createShader = function (shaderSource, macros) {
|
|
29752
|
+
var shaderCacheId = this.addShader(shaderSource, macros);
|
|
29158
29753
|
return this.cachedShaders[shaderCacheId];
|
|
29159
29754
|
};
|
|
29160
29755
|
GLShaderLibrary.prototype.compileShader = function (shader, asyncCallback) {
|
|
@@ -29252,6 +29847,9 @@ var GLShaderLibrary = /** @class */ (function () {
|
|
|
29252
29847
|
delete result.program;
|
|
29253
29848
|
var linked = gl.getProgramParameter(program, gl.LINK_STATUS);
|
|
29254
29849
|
if (!linked) {
|
|
29850
|
+
// 链接失败,获取并打印错误信息
|
|
29851
|
+
var info = gl.getProgramInfoLog(program);
|
|
29852
|
+
console.error('Failed to link program: ' + info);
|
|
29255
29853
|
var vsCheckResult = checkShader(gl, vertexShader, 'vertex', vs);
|
|
29256
29854
|
var fsCheckResult = checkShader(gl, fragShader, 'fragment', fs);
|
|
29257
29855
|
result.status = exports.ShaderCompileResultStatus.fail;
|
|
@@ -30258,6 +30856,7 @@ var Player = /** @class */ (function () {
|
|
|
30258
30856
|
this.displayScale = 1;
|
|
30259
30857
|
this.resumePending = false;
|
|
30260
30858
|
this.disposed = false;
|
|
30859
|
+
this.assetManagers = [];
|
|
30261
30860
|
this.speed = 1;
|
|
30262
30861
|
this.baseCompositionIndex = 0;
|
|
30263
30862
|
/**
|
|
@@ -30540,7 +31139,7 @@ var Player = /** @class */ (function () {
|
|
|
30540
31139
|
Player.prototype.createComposition = function (url, options) {
|
|
30541
31140
|
if (options === void 0) { options = {}; }
|
|
30542
31141
|
return __awaiter(this, void 0, void 0, function () {
|
|
30543
|
-
var renderer, engine, last, opts, source, scene, i, compositionSourceManager, composition, firstFrameTime;
|
|
31142
|
+
var renderer, engine, last, opts, source, assetManager, scene, i, compositionSourceManager, composition, firstFrameTime;
|
|
30544
31143
|
var _this = this;
|
|
30545
31144
|
return __generator(this, function (_a) {
|
|
30546
31145
|
switch (_a.label) {
|
|
@@ -30556,15 +31155,11 @@ var Player = /** @class */ (function () {
|
|
|
30556
31155
|
else {
|
|
30557
31156
|
source = url;
|
|
30558
31157
|
}
|
|
30559
|
-
|
|
30560
|
-
this.assetManager.updateOptions(opts);
|
|
30561
|
-
}
|
|
30562
|
-
else {
|
|
30563
|
-
this.assetManager = new AssetManager(opts);
|
|
30564
|
-
}
|
|
31158
|
+
assetManager = new AssetManager(opts);
|
|
30565
31159
|
// TODO 多 json 之间目前不共用资源,如果后续需要多 json 共用,这边缓存机制需要额外处理
|
|
30566
31160
|
engine.clearResources(); // 在 assetManager.loadScene 前清除,避免 loadScene 创建的 EffectsObject 对象丢失
|
|
30567
|
-
|
|
31161
|
+
this.assetManagers.push(assetManager);
|
|
31162
|
+
return [4 /*yield*/, assetManager.loadScene(source, this.renderer, { env: this.env })];
|
|
30568
31163
|
case 1:
|
|
30569
31164
|
scene = _a.sent();
|
|
30570
31165
|
engine.addPackageDatas(scene);
|
|
@@ -30898,7 +31493,7 @@ var Player = /** @class */ (function () {
|
|
|
30898
31493
|
* @param keepCanvas - 是否保留 canvas 画面,默认不保留,canvas 不能再被使用
|
|
30899
31494
|
*/
|
|
30900
31495
|
Player.prototype.dispose = function (keepCanvas) {
|
|
30901
|
-
var _a
|
|
31496
|
+
var _a;
|
|
30902
31497
|
logger.info("call player destroy: ".concat(this.name));
|
|
30903
31498
|
if (this.disposed) {
|
|
30904
31499
|
return;
|
|
@@ -30906,7 +31501,7 @@ var Player = /** @class */ (function () {
|
|
|
30906
31501
|
playerMap.delete(this.canvas);
|
|
30907
31502
|
this.pause();
|
|
30908
31503
|
(_a = this.ticker) === null || _a === void 0 ? void 0 : _a.stop();
|
|
30909
|
-
(
|
|
31504
|
+
this.assetManagers.forEach(function (assetManager) { return assetManager.dispose(); });
|
|
30910
31505
|
this.compositions.forEach(function (comp) { return comp.dispose(); });
|
|
30911
31506
|
this.compositions.length = 0;
|
|
30912
31507
|
this.renderer.context.removeLostHandler({ lost: this.lost });
|
|
@@ -31112,12 +31707,11 @@ Renderer.create = function (canvas, framework, renderOptions) {
|
|
|
31112
31707
|
Engine.create = function (gl) {
|
|
31113
31708
|
return new GLEngine(gl);
|
|
31114
31709
|
};
|
|
31115
|
-
var version = "2.0.0-alpha.
|
|
31710
|
+
var version = "2.0.0-alpha.4";
|
|
31116
31711
|
logger.info('player version: ' + version);
|
|
31117
31712
|
|
|
31118
31713
|
exports.AbstractPlugin = AbstractPlugin;
|
|
31119
|
-
exports.
|
|
31120
|
-
exports.AnimationClipPlayable = AnimationClipPlayable;
|
|
31714
|
+
exports.ActivationPlayable = ActivationPlayable;
|
|
31121
31715
|
exports.AssetLoader = AssetLoader;
|
|
31122
31716
|
exports.AssetManager = AssetManager;
|
|
31123
31717
|
exports.BYTES_TYPE_MAP = BYTES_TYPE_MAP;
|
|
@@ -31206,6 +31800,7 @@ exports.SPRITE_VERTEX_STRIDE = SPRITE_VERTEX_STRIDE;
|
|
|
31206
31800
|
exports.SemanticMap = SemanticMap;
|
|
31207
31801
|
exports.SerializationHelper = SerializationHelper;
|
|
31208
31802
|
exports.Shader = Shader;
|
|
31803
|
+
exports.ShaderVariant = ShaderVariant;
|
|
31209
31804
|
exports.SpriteColorPlayable = SpriteColorPlayable;
|
|
31210
31805
|
exports.SpriteComponent = SpriteComponent;
|
|
31211
31806
|
exports.SpriteLoader = SpriteLoader;
|
|
@@ -31220,6 +31815,8 @@ exports.TimelineClip = TimelineClip;
|
|
|
31220
31815
|
exports.TimelineComponent = TimelineComponent;
|
|
31221
31816
|
exports.Track = Track;
|
|
31222
31817
|
exports.Transform = Transform;
|
|
31818
|
+
exports.TransformAnimationPlayable = TransformAnimationPlayable;
|
|
31819
|
+
exports.TransformAnimationPlayableAsset = TransformAnimationPlayableAsset;
|
|
31223
31820
|
exports.VFXItem = VFXItem;
|
|
31224
31821
|
exports.ValueGetter = ValueGetter;
|
|
31225
31822
|
exports.addByOrder = addByOrder;
|
|
@@ -31274,7 +31871,7 @@ exports.gaussianDownHFrag = gaussianDownHFrag;
|
|
|
31274
31871
|
exports.gaussianDownVFrag = gaussianDownVFrag;
|
|
31275
31872
|
exports.gaussianUpFrag = gaussianUpFrag;
|
|
31276
31873
|
exports.generateEmptyTypedArray = generateEmptyTypedArray;
|
|
31277
|
-
exports.generateGUID = generateGUID;
|
|
31874
|
+
exports.generateGUID = generateGUID$1;
|
|
31278
31875
|
exports.generateHalfFloatTexture = generateHalfFloatTexture;
|
|
31279
31876
|
exports.getActivePlayers = getActivePlayers;
|
|
31280
31877
|
exports.getBackgroundImage = getBackgroundImage;
|
|
@@ -31334,7 +31931,7 @@ exports.nearestPowerOfTwo = nearestPowerOfTwo;
|
|
|
31334
31931
|
exports.noop = noop;
|
|
31335
31932
|
exports.parsePercent = parsePercent$1;
|
|
31336
31933
|
exports.particleFrag = particleFrag;
|
|
31337
|
-
exports.particleOriginTranslateMap = particleOriginTranslateMap;
|
|
31934
|
+
exports.particleOriginTranslateMap = particleOriginTranslateMap$1;
|
|
31338
31935
|
exports.particleVert = particleVert;
|
|
31339
31936
|
exports.pluginLoaderMap = pluginLoaderMap;
|
|
31340
31937
|
exports.random = random;
|