@galacean/effects 2.0.0-alpha.3 → 2.0.0-alpha.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.js +822 -328
- package/dist/index.js.map +1 -1
- package/dist/index.min.js +6 -6
- package/dist/index.min.js.map +1 -1
- package/dist/index.mjs +859 -366
- package/dist/index.mjs.map +1 -1
- package/dist/player.d.ts +1 -1
- package/dist/weapp.js +821 -327
- package/dist/weapp.js.map +1 -1
- package/dist/weapp.mjs +858 -365
- package/dist/weapp.mjs.map +1 -1
- package/package.json +3 -3
package/dist/weapp.mjs
CHANGED
|
@@ -116,7 +116,7 @@ function __read$3(o, n) {
|
|
|
116
116
|
return ar;
|
|
117
117
|
}
|
|
118
118
|
|
|
119
|
-
function __spreadArray$
|
|
119
|
+
function __spreadArray$3(to, from, pack) {
|
|
120
120
|
if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {
|
|
121
121
|
if (ar || !(i in from)) {
|
|
122
122
|
if (!ar) ar = Array.prototype.slice.call(from, 0, i);
|
|
@@ -134,20 +134,20 @@ typeof SuppressedError === "function" ? SuppressedError : function (error, suppr
|
|
|
134
134
|
// Unique ID creation requires a high quality random # generator. In the browser we therefore
|
|
135
135
|
// require the crypto API and do not support built-in fallback to lower quality random number
|
|
136
136
|
// generators (like Math.random()).
|
|
137
|
-
let getRandomValues;
|
|
138
|
-
const rnds8 = new Uint8Array(16);
|
|
139
|
-
function rng() {
|
|
137
|
+
let getRandomValues$1;
|
|
138
|
+
const rnds8$1 = new Uint8Array(16);
|
|
139
|
+
function rng$1() {
|
|
140
140
|
// lazy load so that environments that need to polyfill have a chance to do so
|
|
141
|
-
if (!getRandomValues) {
|
|
141
|
+
if (!getRandomValues$1) {
|
|
142
142
|
// getRandomValues needs to be invoked in a context where "this" is a Crypto implementation.
|
|
143
|
-
getRandomValues = typeof crypto !== 'undefined' && crypto.getRandomValues && crypto.getRandomValues.bind(crypto);
|
|
143
|
+
getRandomValues$1 = typeof crypto !== 'undefined' && crypto.getRandomValues && crypto.getRandomValues.bind(crypto);
|
|
144
144
|
|
|
145
|
-
if (!getRandomValues) {
|
|
145
|
+
if (!getRandomValues$1) {
|
|
146
146
|
throw new Error('crypto.getRandomValues() not supported. See https://github.com/uuidjs/uuid#getrandomvalues-not-supported');
|
|
147
147
|
}
|
|
148
148
|
}
|
|
149
149
|
|
|
150
|
-
return getRandomValues(rnds8);
|
|
150
|
+
return getRandomValues$1(rnds8$1);
|
|
151
151
|
}
|
|
152
152
|
|
|
153
153
|
/**
|
|
@@ -155,30 +155,30 @@ function rng() {
|
|
|
155
155
|
* XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX
|
|
156
156
|
*/
|
|
157
157
|
|
|
158
|
-
const byteToHex = [];
|
|
158
|
+
const byteToHex$2 = [];
|
|
159
159
|
|
|
160
160
|
for (let i = 0; i < 256; ++i) {
|
|
161
|
-
byteToHex.push((i + 0x100).toString(16).slice(1));
|
|
161
|
+
byteToHex$2.push((i + 0x100).toString(16).slice(1));
|
|
162
162
|
}
|
|
163
163
|
|
|
164
|
-
function unsafeStringify(arr, offset = 0) {
|
|
164
|
+
function unsafeStringify$1(arr, offset = 0) {
|
|
165
165
|
// Note: Be careful editing this code! It's been tuned for performance
|
|
166
166
|
// and works in ways you may not expect. See https://github.com/uuidjs/uuid/pull/434
|
|
167
|
-
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]];
|
|
167
|
+
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]];
|
|
168
168
|
}
|
|
169
169
|
|
|
170
|
-
const randomUUID = typeof crypto !== 'undefined' && crypto.randomUUID && crypto.randomUUID.bind(crypto);
|
|
171
|
-
var native = {
|
|
172
|
-
randomUUID
|
|
170
|
+
const randomUUID$1 = typeof crypto !== 'undefined' && crypto.randomUUID && crypto.randomUUID.bind(crypto);
|
|
171
|
+
var native$1 = {
|
|
172
|
+
randomUUID: randomUUID$1
|
|
173
173
|
};
|
|
174
174
|
|
|
175
|
-
function v4(options, buf, offset) {
|
|
176
|
-
if (native.randomUUID && !buf && !options) {
|
|
177
|
-
return native.randomUUID();
|
|
175
|
+
function v4$1(options, buf, offset) {
|
|
176
|
+
if (native$1.randomUUID && !buf && !options) {
|
|
177
|
+
return native$1.randomUUID();
|
|
178
178
|
}
|
|
179
179
|
|
|
180
180
|
options = options || {};
|
|
181
|
-
const rnds = options.random || (options.rng || rng)(); // Per 4.4, set bits for version and `clock_seq_hi_and_reserved`
|
|
181
|
+
const rnds = options.random || (options.rng || rng$1)(); // Per 4.4, set bits for version and `clock_seq_hi_and_reserved`
|
|
182
182
|
|
|
183
183
|
rnds[6] = rnds[6] & 0x0f | 0x40;
|
|
184
184
|
rnds[8] = rnds[8] & 0x3f | 0x80; // Copy bytes to buffer, if provided
|
|
@@ -193,7 +193,7 @@ function v4(options, buf, offset) {
|
|
|
193
193
|
return buf;
|
|
194
194
|
}
|
|
195
195
|
|
|
196
|
-
return unsafeStringify(rnds);
|
|
196
|
+
return unsafeStringify$1(rnds);
|
|
197
197
|
}
|
|
198
198
|
|
|
199
199
|
function addItem(arr, value) {
|
|
@@ -2180,7 +2180,7 @@ var __read$2 = (undefined && undefined.__read) || function (o, n) {
|
|
|
2180
2180
|
}
|
|
2181
2181
|
return ar;
|
|
2182
2182
|
};
|
|
2183
|
-
var __spreadArray$
|
|
2183
|
+
var __spreadArray$2 = (undefined && undefined.__spreadArray) || function (to, from, pack) {
|
|
2184
2184
|
if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {
|
|
2185
2185
|
if (ar || !(i in from)) {
|
|
2186
2186
|
if (!ar) ar = Array.prototype.slice.call(from, 0, i);
|
|
@@ -2497,7 +2497,7 @@ var Matrix4$1 = /** @class */ (function () {
|
|
|
2497
2497
|
* @returns 复制结果
|
|
2498
2498
|
*/
|
|
2499
2499
|
Matrix4.prototype.copyFrom = function (m) {
|
|
2500
|
-
this.elements = __spreadArray$
|
|
2500
|
+
this.elements = __spreadArray$2([], __read$2(m.elements), false);
|
|
2501
2501
|
return this;
|
|
2502
2502
|
};
|
|
2503
2503
|
/**
|
|
@@ -3026,7 +3026,7 @@ var Matrix4$1 = /** @class */ (function () {
|
|
|
3026
3026
|
* @returns
|
|
3027
3027
|
*/
|
|
3028
3028
|
Matrix4.prototype.toArray = function () {
|
|
3029
|
-
return __spreadArray$
|
|
3029
|
+
return __spreadArray$2([], __read$2(this.elements), false);
|
|
3030
3030
|
};
|
|
3031
3031
|
Matrix4.prototype.fill = function (array, offset) {
|
|
3032
3032
|
if (offset === void 0) { offset = 0; }
|
|
@@ -4279,7 +4279,7 @@ var __read$1 = (undefined && undefined.__read) || function (o, n) {
|
|
|
4279
4279
|
}
|
|
4280
4280
|
return ar;
|
|
4281
4281
|
};
|
|
4282
|
-
var __spreadArray = (undefined && undefined.__spreadArray) || function (to, from, pack) {
|
|
4282
|
+
var __spreadArray$1 = (undefined && undefined.__spreadArray) || function (to, from, pack) {
|
|
4283
4283
|
if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {
|
|
4284
4284
|
if (ar || !(i in from)) {
|
|
4285
4285
|
if (!ar) ar = Array.prototype.slice.call(from, 0, i);
|
|
@@ -4466,7 +4466,7 @@ var Matrix3 = /** @class */ (function () {
|
|
|
4466
4466
|
* @returns 复制结果
|
|
4467
4467
|
*/
|
|
4468
4468
|
Matrix3.prototype.copyFrom = function (m) {
|
|
4469
|
-
this.elements = __spreadArray([], __read$1(m.elements), false);
|
|
4469
|
+
this.elements = __spreadArray$1([], __read$1(m.elements), false);
|
|
4470
4470
|
return this;
|
|
4471
4471
|
};
|
|
4472
4472
|
/**
|
|
@@ -4682,7 +4682,7 @@ var Matrix3 = /** @class */ (function () {
|
|
|
4682
4682
|
* @returns
|
|
4683
4683
|
*/
|
|
4684
4684
|
Matrix3.prototype.toArray = function () {
|
|
4685
|
-
return __spreadArray([], __read$1(this.elements), false);
|
|
4685
|
+
return __spreadArray$1([], __read$1(this.elements), false);
|
|
4686
4686
|
};
|
|
4687
4687
|
Matrix3.prototype.fill = function (array, offset) {
|
|
4688
4688
|
if (offset === void 0) { offset = 0; }
|
|
@@ -6440,7 +6440,7 @@ function error(message) {
|
|
|
6440
6440
|
for (var _i = 1; _i < arguments.length; _i++) {
|
|
6441
6441
|
args[_i - 1] = arguments[_i];
|
|
6442
6442
|
}
|
|
6443
|
-
console.error.apply(console, __spreadArray$
|
|
6443
|
+
console.error.apply(console, __spreadArray$3(__spreadArray$3([], __read$3(format(message)), false), [args], false));
|
|
6444
6444
|
localLogger === null || localLogger === void 0 ? void 0 : localLogger('error', message, args);
|
|
6445
6445
|
}
|
|
6446
6446
|
/**
|
|
@@ -6453,7 +6453,7 @@ function info(message) {
|
|
|
6453
6453
|
for (var _i = 1; _i < arguments.length; _i++) {
|
|
6454
6454
|
args[_i - 1] = arguments[_i];
|
|
6455
6455
|
}
|
|
6456
|
-
console.debug.apply(console, __spreadArray$
|
|
6456
|
+
console.debug.apply(console, __spreadArray$3([], __read$3(format(message)), false));
|
|
6457
6457
|
localLogger === null || localLogger === void 0 ? void 0 : localLogger('info', message, args);
|
|
6458
6458
|
}
|
|
6459
6459
|
function warn(message) {
|
|
@@ -6461,7 +6461,7 @@ function warn(message) {
|
|
|
6461
6461
|
for (var _i = 1; _i < arguments.length; _i++) {
|
|
6462
6462
|
args[_i - 1] = arguments[_i];
|
|
6463
6463
|
}
|
|
6464
|
-
console.warn.apply(console, __spreadArray$
|
|
6464
|
+
console.warn.apply(console, __spreadArray$3([], __read$3(format(message)), false));
|
|
6465
6465
|
localLogger === null || localLogger === void 0 ? void 0 : localLogger('warn', message, args);
|
|
6466
6466
|
}
|
|
6467
6467
|
/**
|
|
@@ -6558,17 +6558,30 @@ function random(min, max) {
|
|
|
6558
6558
|
function throwDestroyedError$1() {
|
|
6559
6559
|
throw Error('destroyed item cannot be used again');
|
|
6560
6560
|
}
|
|
6561
|
-
function generateGUID() {
|
|
6562
|
-
return v4().replace(/-/g, '');
|
|
6561
|
+
function generateGUID$1() {
|
|
6562
|
+
return v4$1().replace(/-/g, '');
|
|
6563
6563
|
}
|
|
6564
6564
|
|
|
6565
6565
|
/*!
|
|
6566
6566
|
* Name: @galacean/effects-specification
|
|
6567
6567
|
* Description: Galacean Effects JSON Specification
|
|
6568
6568
|
* Author: Ant Group CO., Ltd.
|
|
6569
|
-
* Version:
|
|
6569
|
+
* Version: v2.0.0-alpha.2
|
|
6570
6570
|
*/
|
|
6571
6571
|
|
|
6572
|
+
typeof crypto !== 'undefined' && crypto.randomUUID && crypto.randomUUID.bind(crypto);
|
|
6573
|
+
|
|
6574
|
+
/**
|
|
6575
|
+
* Convert array of 16 byte values to UUID string format of the form:
|
|
6576
|
+
* XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX
|
|
6577
|
+
*/
|
|
6578
|
+
|
|
6579
|
+
const byteToHex$1 = [];
|
|
6580
|
+
|
|
6581
|
+
for (let i = 0; i < 256; ++i) {
|
|
6582
|
+
byteToHex$1.push((i + 0x100).toString(16).slice(1));
|
|
6583
|
+
}
|
|
6584
|
+
|
|
6572
6585
|
/*********************************************/
|
|
6573
6586
|
/* 元素属性参数类型 */
|
|
6574
6587
|
/*********************************************/
|
|
@@ -6831,6 +6844,10 @@ var ItemType$1;
|
|
|
6831
6844
|
* 天空盒元素
|
|
6832
6845
|
*/
|
|
6833
6846
|
ItemType["skybox"] = "skybox";
|
|
6847
|
+
/**
|
|
6848
|
+
* 特效元素
|
|
6849
|
+
*/
|
|
6850
|
+
ItemType["effect"] = "effect";
|
|
6834
6851
|
})(ItemType$1 || (ItemType$1 = {}));
|
|
6835
6852
|
/**
|
|
6836
6853
|
* 渲染模式
|
|
@@ -6945,6 +6962,10 @@ var CompositionEndBehavior$1;
|
|
|
6945
6962
|
* 销毁并保留最后一帧
|
|
6946
6963
|
*/
|
|
6947
6964
|
CompositionEndBehavior[CompositionEndBehavior["pause_destroy"] = END_BEHAVIOR_PAUSE_AND_DESTROY$1] = "pause_destroy";
|
|
6965
|
+
/**
|
|
6966
|
+
* 冻结
|
|
6967
|
+
*/
|
|
6968
|
+
CompositionEndBehavior[CompositionEndBehavior["freeze"] = END_BEHAVIOR_FREEZE$1] = "freeze";
|
|
6948
6969
|
})(CompositionEndBehavior$1 || (CompositionEndBehavior$1 = {}));
|
|
6949
6970
|
|
|
6950
6971
|
/*********************************************/
|
|
@@ -7083,12 +7104,38 @@ var ShapeArcMode$1;
|
|
|
7083
7104
|
|
|
7084
7105
|
var BloomFilterThresholdAvgColor = 0;
|
|
7085
7106
|
|
|
7107
|
+
var LightType$1;
|
|
7108
|
+
(function (LightType) {
|
|
7109
|
+
/**
|
|
7110
|
+
* 点光源
|
|
7111
|
+
*/
|
|
7112
|
+
LightType["point"] = "point";
|
|
7113
|
+
/**
|
|
7114
|
+
* 聚光灯
|
|
7115
|
+
*/
|
|
7116
|
+
LightType["spot"] = "spot";
|
|
7117
|
+
/**
|
|
7118
|
+
* 方向光
|
|
7119
|
+
*/
|
|
7120
|
+
LightType["directional"] = "directional";
|
|
7121
|
+
/**
|
|
7122
|
+
* 环境光
|
|
7123
|
+
*/
|
|
7124
|
+
LightType["ambient"] = "ambient";
|
|
7125
|
+
})(LightType$1 || (LightType$1 = {}));
|
|
7126
|
+
|
|
7086
7127
|
var ModelBoundingType$1;
|
|
7087
7128
|
(function (ModelBoundingType) {
|
|
7088
7129
|
ModelBoundingType[ModelBoundingType["box"] = 2] = "box";
|
|
7089
7130
|
ModelBoundingType[ModelBoundingType["sphere"] = 3] = "sphere";
|
|
7090
7131
|
})(ModelBoundingType$1 || (ModelBoundingType$1 = {}));
|
|
7091
7132
|
|
|
7133
|
+
var CameraType$1;
|
|
7134
|
+
(function (CameraType) {
|
|
7135
|
+
CameraType["orthographic"] = "orthographic";
|
|
7136
|
+
CameraType["perspective"] = "perspective";
|
|
7137
|
+
})(CameraType$1 || (CameraType$1 = {}));
|
|
7138
|
+
|
|
7092
7139
|
// 材质类型
|
|
7093
7140
|
var MaterialType$1;
|
|
7094
7141
|
(function (MaterialType) {
|
|
@@ -7234,6 +7281,28 @@ var FontStyle$1;
|
|
|
7234
7281
|
FontStyle["oblique"] = "oblique";
|
|
7235
7282
|
})(FontStyle$1 || (FontStyle$1 = {}));
|
|
7236
7283
|
|
|
7284
|
+
var DataType$2;
|
|
7285
|
+
(function (DataType) {
|
|
7286
|
+
DataType["VFXItemData"] = "VFXItemData";
|
|
7287
|
+
DataType["EffectComponent"] = "EffectComponent";
|
|
7288
|
+
DataType["Material"] = "Material";
|
|
7289
|
+
DataType["Shader"] = "Shader";
|
|
7290
|
+
DataType["SpriteComponent"] = "SpriteComponent";
|
|
7291
|
+
DataType["ParticleSystem"] = "ParticleSystem";
|
|
7292
|
+
DataType["InteractComponent"] = "InteractComponent";
|
|
7293
|
+
DataType["CameraController"] = "CameraController";
|
|
7294
|
+
DataType["Geometry"] = "Geometry";
|
|
7295
|
+
DataType["Texture"] = "Texture";
|
|
7296
|
+
DataType["TextComponent"] = "TextComponent";
|
|
7297
|
+
// FIXME: 先完成ECS的场景转换,后面移到spec中
|
|
7298
|
+
DataType["MeshComponent"] = "MeshComponent";
|
|
7299
|
+
DataType["SkyboxComponent"] = "SkyboxComponent";
|
|
7300
|
+
DataType["LightComponent"] = "LightComponent";
|
|
7301
|
+
DataType["CameraComponent"] = "CameraComponent";
|
|
7302
|
+
DataType["ModelPluginComponent"] = "ModelPluginComponent";
|
|
7303
|
+
DataType["TreeComponent"] = "TreeComponent";
|
|
7304
|
+
})(DataType$2 || (DataType$2 = {}));
|
|
7305
|
+
|
|
7237
7306
|
var index = /*#__PURE__*/Object.freeze({
|
|
7238
7307
|
__proto__: null,
|
|
7239
7308
|
get BezierKeyframeType () { return BezierKeyframeType$1; },
|
|
@@ -7242,7 +7311,9 @@ var index = /*#__PURE__*/Object.freeze({
|
|
|
7242
7311
|
CAMERA_CLIP_MODE_NORMAL: CAMERA_CLIP_MODE_NORMAL$1,
|
|
7243
7312
|
CAMERA_CLIP_MODE_VERTICAL: CAMERA_CLIP_MODE_VERTICAL$1,
|
|
7244
7313
|
get CameraClipMode () { return CameraClipMode$1; },
|
|
7314
|
+
get CameraType () { return CameraType$1; },
|
|
7245
7315
|
get CompositionEndBehavior () { return CompositionEndBehavior$1; },
|
|
7316
|
+
get DataType () { return DataType$2; },
|
|
7246
7317
|
END_BEHAVIOR_DESTROY: END_BEHAVIOR_DESTROY$1,
|
|
7247
7318
|
END_BEHAVIOR_DESTROY_CHILDREN: END_BEHAVIOR_DESTROY_CHILDREN$1,
|
|
7248
7319
|
END_BEHAVIOR_FORWARD: END_BEHAVIOR_FORWARD$1,
|
|
@@ -7255,6 +7326,7 @@ var index = /*#__PURE__*/Object.freeze({
|
|
|
7255
7326
|
get InteractType () { return InteractType$1; },
|
|
7256
7327
|
get ItemEndBehavior () { return ItemEndBehavior$1; },
|
|
7257
7328
|
get ItemType () { return ItemType$1; },
|
|
7329
|
+
get LightType () { return LightType$1; },
|
|
7258
7330
|
MESSAGE_ITEM_PHRASE_BEGIN: MESSAGE_ITEM_PHRASE_BEGIN,
|
|
7259
7331
|
MESSAGE_ITEM_PHRASE_END: MESSAGE_ITEM_PHRASE_END,
|
|
7260
7332
|
get MaskMode () { return MaskMode$1; },
|
|
@@ -7446,7 +7518,7 @@ function copy$1(target) {
|
|
|
7446
7518
|
}
|
|
7447
7519
|
}
|
|
7448
7520
|
|
|
7449
|
-
var _a$
|
|
7521
|
+
var _a$a;
|
|
7450
7522
|
function valIfUndefined(val, def) {
|
|
7451
7523
|
if (val === undefined || val === null) {
|
|
7452
7524
|
return def;
|
|
@@ -7476,15 +7548,15 @@ function getPreMultiAlpha(blending) {
|
|
|
7476
7548
|
return 1;
|
|
7477
7549
|
}
|
|
7478
7550
|
}
|
|
7479
|
-
var downgradeKeywords = (_a$
|
|
7480
|
-
_a$
|
|
7551
|
+
var downgradeKeywords = (_a$a = {},
|
|
7552
|
+
_a$a[ShaderType.vertex] = {
|
|
7481
7553
|
in: 'attribute',
|
|
7482
7554
|
out: 'varying',
|
|
7483
7555
|
},
|
|
7484
|
-
_a$
|
|
7556
|
+
_a$a[ShaderType.fragment] = {
|
|
7485
7557
|
in: 'varying',
|
|
7486
7558
|
},
|
|
7487
|
-
_a$
|
|
7559
|
+
_a$a);
|
|
7488
7560
|
/**
|
|
7489
7561
|
* 生成 shader,检测到 WebGL1 上下文会降级
|
|
7490
7562
|
* @param marcos - 宏定义数组
|
|
@@ -7925,7 +7997,7 @@ function loadMipmapImage(pointer, bins) {
|
|
|
7925
7997
|
var EffectsObject = /** @class */ (function () {
|
|
7926
7998
|
function EffectsObject(engine) {
|
|
7927
7999
|
this.engine = engine;
|
|
7928
|
-
this.guid = generateGUID();
|
|
8000
|
+
this.guid = generateGUID$1();
|
|
7929
8001
|
this.taggedProperties = {};
|
|
7930
8002
|
this.engine.addInstance(this);
|
|
7931
8003
|
}
|
|
@@ -8622,13 +8694,49 @@ var GLSLVersion;
|
|
|
8622
8694
|
GLSLVersion["GLSL1"] = "100";
|
|
8623
8695
|
GLSLVersion["GLSL3"] = "300 es";
|
|
8624
8696
|
})(GLSLVersion || (GLSLVersion = {}));
|
|
8625
|
-
var
|
|
8626
|
-
__extends(
|
|
8627
|
-
function
|
|
8697
|
+
var ShaderVariant = /** @class */ (function (_super) {
|
|
8698
|
+
__extends(ShaderVariant, _super);
|
|
8699
|
+
function ShaderVariant(engine, source) {
|
|
8628
8700
|
var _this = _super.call(this, engine) || this;
|
|
8629
8701
|
_this.source = source;
|
|
8630
8702
|
return _this;
|
|
8631
8703
|
}
|
|
8704
|
+
return ShaderVariant;
|
|
8705
|
+
}(EffectsObject));
|
|
8706
|
+
var Shader = /** @class */ (function (_super) {
|
|
8707
|
+
__extends(Shader, _super);
|
|
8708
|
+
function Shader() {
|
|
8709
|
+
return _super !== null && _super.apply(this, arguments) || this;
|
|
8710
|
+
}
|
|
8711
|
+
Shader.prototype.createVariant = function (macros) {
|
|
8712
|
+
var e_1, _a;
|
|
8713
|
+
var shaderMacros = [];
|
|
8714
|
+
if (macros) {
|
|
8715
|
+
try {
|
|
8716
|
+
for (var _b = __values$1(Object.keys(macros)), _c = _b.next(); !_c.done; _c = _b.next()) {
|
|
8717
|
+
var key = _c.value;
|
|
8718
|
+
shaderMacros.push([key, macros[key]]);
|
|
8719
|
+
}
|
|
8720
|
+
}
|
|
8721
|
+
catch (e_1_1) { e_1 = { error: e_1_1 }; }
|
|
8722
|
+
finally {
|
|
8723
|
+
try {
|
|
8724
|
+
if (_c && !_c.done && (_a = _b.return)) _a.call(_b);
|
|
8725
|
+
}
|
|
8726
|
+
finally { if (e_1) throw e_1.error; }
|
|
8727
|
+
}
|
|
8728
|
+
}
|
|
8729
|
+
var shaderVariant = this.engine.getShaderLibrary().createShader(this.shaderData, shaderMacros);
|
|
8730
|
+
shaderVariant.shader = this;
|
|
8731
|
+
return shaderVariant;
|
|
8732
|
+
};
|
|
8733
|
+
Shader.prototype.fromData = function (data) {
|
|
8734
|
+
_super.prototype.fromData.call(this, data);
|
|
8735
|
+
this.shaderData = data;
|
|
8736
|
+
};
|
|
8737
|
+
Shader = __decorate([
|
|
8738
|
+
effectsClass('Shader')
|
|
8739
|
+
], Shader);
|
|
8632
8740
|
return Shader;
|
|
8633
8741
|
}(EffectsObject));
|
|
8634
8742
|
|
|
@@ -8641,8 +8749,8 @@ function createCopyShader(level, writeDepth) {
|
|
|
8641
8749
|
var version = webgl2 ? '#version 300 es' : '';
|
|
8642
8750
|
return {
|
|
8643
8751
|
name: EFFECTS_COPY_MESH_NAME,
|
|
8644
|
-
vertex:
|
|
8645
|
-
fragment:
|
|
8752
|
+
vertex: version + '\n' + COPY_VERTEX_SHADER,
|
|
8753
|
+
fragment: version + '\n' + COPY_FRAGMENT_SHADER,
|
|
8646
8754
|
glslVersion: webgl2 ? GLSLVersion.GLSL3 : GLSLVersion.GLSL1,
|
|
8647
8755
|
marcos: [
|
|
8648
8756
|
['WEBGL2', !!webgl2],
|
|
@@ -8774,13 +8882,13 @@ var SemanticMap = /** @class */ (function () {
|
|
|
8774
8882
|
return SemanticMap;
|
|
8775
8883
|
}());
|
|
8776
8884
|
|
|
8777
|
-
var _a$
|
|
8778
|
-
var BYTES_TYPE_MAP = (_a$
|
|
8779
|
-
_a$
|
|
8780
|
-
_a$
|
|
8781
|
-
_a$
|
|
8782
|
-
_a$
|
|
8783
|
-
_a$
|
|
8885
|
+
var _a$9;
|
|
8886
|
+
var BYTES_TYPE_MAP = (_a$9 = {},
|
|
8887
|
+
_a$9[glContext.FLOAT] = Float32Array.BYTES_PER_ELEMENT,
|
|
8888
|
+
_a$9[glContext.INT] = Int32Array.BYTES_PER_ELEMENT,
|
|
8889
|
+
_a$9[glContext.SHORT] = Int16Array.BYTES_PER_ELEMENT,
|
|
8890
|
+
_a$9[glContext.BYTE] = Int8Array.BYTES_PER_ELEMENT,
|
|
8891
|
+
_a$9);
|
|
8784
8892
|
/**
|
|
8785
8893
|
* Geometry 抽象类
|
|
8786
8894
|
*/
|
|
@@ -9349,7 +9457,7 @@ var RenderPass = /** @class */ (function () {
|
|
|
9349
9457
|
RenderPass.prototype.setMeshes = function (meshes) {
|
|
9350
9458
|
var _a;
|
|
9351
9459
|
this.meshes.length = 0;
|
|
9352
|
-
(_a = this.meshes).splice.apply(_a, __spreadArray$
|
|
9460
|
+
(_a = this.meshes).splice.apply(_a, __spreadArray$3([0, 0], __read$3(meshes), false));
|
|
9353
9461
|
sortByOrder(this.meshes, this.meshOrder);
|
|
9354
9462
|
return this.meshes;
|
|
9355
9463
|
};
|
|
@@ -11534,18 +11642,15 @@ var AssetLoader = /** @class */ (function () {
|
|
|
11534
11642
|
return undefined;
|
|
11535
11643
|
}
|
|
11536
11644
|
switch (effectsObjectData.dataType) {
|
|
11537
|
-
case DataType.Material:
|
|
11645
|
+
case DataType$1.Material:
|
|
11538
11646
|
effectsObject = Material.create(this.engine);
|
|
11539
11647
|
break;
|
|
11540
|
-
case DataType.Geometry:
|
|
11648
|
+
case DataType$1.Geometry:
|
|
11541
11649
|
effectsObject = Geometry.create(this.engine);
|
|
11542
11650
|
break;
|
|
11543
|
-
case DataType.Texture:
|
|
11651
|
+
case DataType$1.Texture:
|
|
11544
11652
|
effectsObject = Texture.create(this.engine, effectsObjectData);
|
|
11545
11653
|
return effectsObject;
|
|
11546
|
-
case DataType.Shader:
|
|
11547
|
-
effectsObject = this.engine.getShaderLibrary().createShader(effectsObjectData);
|
|
11548
|
-
break;
|
|
11549
11654
|
default: {
|
|
11550
11655
|
var classConstructor = AssetLoader.getClass(effectsObjectData.dataType);
|
|
11551
11656
|
if (classConstructor) {
|
|
@@ -11589,18 +11694,15 @@ var AssetLoader = /** @class */ (function () {
|
|
|
11589
11694
|
return [2 /*return*/, effectsObject];
|
|
11590
11695
|
case 2:
|
|
11591
11696
|
switch (effectsObjectData.dataType) {
|
|
11592
|
-
case DataType.Material:
|
|
11697
|
+
case DataType$1.Material:
|
|
11593
11698
|
effectsObject = Material.create(this.engine);
|
|
11594
11699
|
break;
|
|
11595
|
-
case DataType.Geometry:
|
|
11700
|
+
case DataType$1.Geometry:
|
|
11596
11701
|
effectsObject = Geometry.create(this.engine);
|
|
11597
11702
|
break;
|
|
11598
|
-
case DataType.Texture:
|
|
11703
|
+
case DataType$1.Texture:
|
|
11599
11704
|
effectsObject = Texture.create(this.engine, effectsObjectData);
|
|
11600
11705
|
return [2 /*return*/, effectsObject];
|
|
11601
|
-
case DataType.Shader:
|
|
11602
|
-
effectsObject = this.engine.getShaderLibrary().createShader(effectsObjectData);
|
|
11603
|
-
break;
|
|
11604
11706
|
default: {
|
|
11605
11707
|
classConstructor = AssetLoader.getClass(effectsObjectData.dataType);
|
|
11606
11708
|
if (classConstructor) {
|
|
@@ -11642,7 +11744,7 @@ var Database = /** @class */ (function () {
|
|
|
11642
11744
|
};
|
|
11643
11745
|
return Database;
|
|
11644
11746
|
}());
|
|
11645
|
-
var DataType;
|
|
11747
|
+
var DataType$1;
|
|
11646
11748
|
(function (DataType) {
|
|
11647
11749
|
DataType["VFXItemData"] = "VFXItemData";
|
|
11648
11750
|
DataType["EffectComponent"] = "EffectComponent";
|
|
@@ -11662,7 +11764,7 @@ var DataType;
|
|
|
11662
11764
|
DataType["CameraComponent"] = "CameraComponent";
|
|
11663
11765
|
DataType["ModelPluginComponent"] = "ModelPluginComponent";
|
|
11664
11766
|
DataType["TreeComponent"] = "TreeComponent";
|
|
11665
|
-
})(DataType || (DataType = {}));
|
|
11767
|
+
})(DataType$1 || (DataType$1 = {}));
|
|
11666
11768
|
|
|
11667
11769
|
/**
|
|
11668
11770
|
* 抽象插件类
|
|
@@ -11813,7 +11915,7 @@ function calculateTranslation(out, target, acc, time, duration, posData, velData
|
|
|
11813
11915
|
return ret;
|
|
11814
11916
|
}
|
|
11815
11917
|
|
|
11816
|
-
var _a$
|
|
11918
|
+
var _a$8;
|
|
11817
11919
|
function ensureVec3(num) {
|
|
11818
11920
|
return Array.isArray(num) ? [num[0], num[1], num[2]] : [0, 0, 0];
|
|
11819
11921
|
}
|
|
@@ -11836,7 +11938,7 @@ function vecNormalize(out, a) {
|
|
|
11836
11938
|
out = [];
|
|
11837
11939
|
}
|
|
11838
11940
|
var ap = a;
|
|
11839
|
-
var sum = Math.hypot.apply(Math, __spreadArray$
|
|
11941
|
+
var sum = Math.hypot.apply(Math, __spreadArray$3([], __read$3(ap), false));
|
|
11840
11942
|
if (sum === 0) {
|
|
11841
11943
|
return vecAssign(out, ap, ap.length);
|
|
11842
11944
|
}
|
|
@@ -11867,17 +11969,17 @@ function vecMulCombine(out, a, b) {
|
|
|
11867
11969
|
}
|
|
11868
11970
|
return out;
|
|
11869
11971
|
}
|
|
11870
|
-
var particleOriginTranslateMap = (_a$
|
|
11871
|
-
_a$
|
|
11872
|
-
_a$
|
|
11873
|
-
_a$
|
|
11874
|
-
_a$
|
|
11875
|
-
_a$
|
|
11876
|
-
_a$
|
|
11877
|
-
_a$
|
|
11878
|
-
_a$
|
|
11879
|
-
_a$
|
|
11880
|
-
_a$
|
|
11972
|
+
var particleOriginTranslateMap$1 = (_a$8 = {},
|
|
11973
|
+
_a$8[ParticleOrigin$1.PARTICLE_ORIGIN_CENTER] = [0, 0],
|
|
11974
|
+
_a$8[ParticleOrigin$1.PARTICLE_ORIGIN_CENTER_BOTTOM] = [0, -0.5],
|
|
11975
|
+
_a$8[ParticleOrigin$1.PARTICLE_ORIGIN_CENTER_TOP] = [0, 0.5],
|
|
11976
|
+
_a$8[ParticleOrigin$1.PARTICLE_ORIGIN_LEFT_TOP] = [-0.5, 0.5],
|
|
11977
|
+
_a$8[ParticleOrigin$1.PARTICLE_ORIGIN_LEFT_CENTER] = [-0.5, 0],
|
|
11978
|
+
_a$8[ParticleOrigin$1.PARTICLE_ORIGIN_LEFT_BOTTOM] = [-0.5, -0.5],
|
|
11979
|
+
_a$8[ParticleOrigin$1.PARTICLE_ORIGIN_RIGHT_CENTER] = [0.5, 0],
|
|
11980
|
+
_a$8[ParticleOrigin$1.PARTICLE_ORIGIN_RIGHT_BOTTOM] = [0.5, -0.5],
|
|
11981
|
+
_a$8[ParticleOrigin$1.PARTICLE_ORIGIN_RIGHT_TOP] = [0.5, 0.5],
|
|
11982
|
+
_a$8);
|
|
11881
11983
|
function nearestPowerOfTwo(value) {
|
|
11882
11984
|
return Math.pow(2, Math.round(Math.log(value) / Math.LN2));
|
|
11883
11985
|
}
|
|
@@ -11902,7 +12004,7 @@ function trianglesFromRect(position, halfWidth, halfHeight) {
|
|
|
11902
12004
|
];
|
|
11903
12005
|
}
|
|
11904
12006
|
|
|
11905
|
-
var _a$
|
|
12007
|
+
var _a$7;
|
|
11906
12008
|
var NOT_IMPLEMENT = 'not_implement';
|
|
11907
12009
|
var ValueGetter = /** @class */ (function () {
|
|
11908
12010
|
function ValueGetter(arg) {
|
|
@@ -12410,50 +12512,50 @@ var BezierSegments = /** @class */ (function (_super) {
|
|
|
12410
12512
|
};
|
|
12411
12513
|
return BezierSegments;
|
|
12412
12514
|
}(PathSegments));
|
|
12413
|
-
var map$2 = (_a$
|
|
12414
|
-
_a$
|
|
12515
|
+
var map$2 = (_a$7 = {},
|
|
12516
|
+
_a$7[ValueType$1.RANDOM] = function (props) {
|
|
12415
12517
|
if (props[0] instanceof Array) {
|
|
12416
12518
|
return new RandomVectorValue(props);
|
|
12417
12519
|
}
|
|
12418
12520
|
return new RandomValue(props);
|
|
12419
12521
|
},
|
|
12420
|
-
_a$
|
|
12522
|
+
_a$7[ValueType$1.CONSTANT] = function (props) {
|
|
12421
12523
|
return new StaticValue(props);
|
|
12422
12524
|
},
|
|
12423
|
-
_a$
|
|
12525
|
+
_a$7[ValueType$1.CONSTANT_VEC2] = function (props) {
|
|
12424
12526
|
return new StaticValue(props);
|
|
12425
12527
|
},
|
|
12426
|
-
_a$
|
|
12528
|
+
_a$7[ValueType$1.CONSTANT_VEC3] = function (props) {
|
|
12427
12529
|
return new StaticValue(props);
|
|
12428
12530
|
},
|
|
12429
|
-
_a$
|
|
12531
|
+
_a$7[ValueType$1.CONSTANT_VEC4] = function (props) {
|
|
12430
12532
|
return new StaticValue(props);
|
|
12431
12533
|
},
|
|
12432
|
-
_a$
|
|
12534
|
+
_a$7[ValueType$1.CURVE] = function (props) {
|
|
12433
12535
|
return new CurveValue(props);
|
|
12434
12536
|
},
|
|
12435
|
-
_a$
|
|
12537
|
+
_a$7[ValueType$1.RGBA_COLOR] = function (props) {
|
|
12436
12538
|
return new StaticValue(props);
|
|
12437
12539
|
},
|
|
12438
|
-
_a$
|
|
12540
|
+
_a$7[ValueType$1.COLORS] = function (props) {
|
|
12439
12541
|
return new RandomSetValue(props.map(function (c) { return colorToArr$1(c, false); }));
|
|
12440
12542
|
},
|
|
12441
|
-
_a$
|
|
12543
|
+
_a$7[ValueType$1.LINE] = function (props) {
|
|
12442
12544
|
if (props.length === 2 && props[0][0] === 0 && props[1][0] === 1) {
|
|
12443
12545
|
return new LinearValue([props[0][1], props[1][1]]);
|
|
12444
12546
|
}
|
|
12445
12547
|
return new LineSegments(props);
|
|
12446
12548
|
},
|
|
12447
|
-
_a$
|
|
12549
|
+
_a$7[ValueType$1.GRADIENT_COLOR] = function (props) {
|
|
12448
12550
|
return new GradientValue(props);
|
|
12449
12551
|
},
|
|
12450
|
-
_a$
|
|
12552
|
+
_a$7[ValueType$1.LINEAR_PATH] = function (pros) {
|
|
12451
12553
|
return new PathSegments(pros);
|
|
12452
12554
|
},
|
|
12453
|
-
_a$
|
|
12555
|
+
_a$7[ValueType$1.BEZIER_PATH] = function (pros) {
|
|
12454
12556
|
return new BezierSegments(pros);
|
|
12455
12557
|
},
|
|
12456
|
-
_a$
|
|
12558
|
+
_a$7);
|
|
12457
12559
|
function createValueGetter(args) {
|
|
12458
12560
|
if (!args || !isNaN(+args)) {
|
|
12459
12561
|
return new StaticValue(args || 0);
|
|
@@ -13183,7 +13285,7 @@ var CameraController = /** @class */ (function (_super) {
|
|
|
13183
13285
|
}
|
|
13184
13286
|
};
|
|
13185
13287
|
CameraController = __decorate([
|
|
13186
|
-
effectsClass(DataType.CameraController)
|
|
13288
|
+
effectsClass(DataType$1.CameraController)
|
|
13187
13289
|
], CameraController);
|
|
13188
13290
|
return CameraController;
|
|
13189
13291
|
}(ItemBehaviour));
|
|
@@ -13404,13 +13506,13 @@ var InteractMesh = /** @class */ (function () {
|
|
|
13404
13506
|
['ENV_EDITOR', ((_a = this.engine.renderer) === null || _a === void 0 ? void 0 : _a.env) === PLAYER_OPTIONS_ENV_EDITOR],
|
|
13405
13507
|
];
|
|
13406
13508
|
var color = createValueGetter(this.color).getValue(0);
|
|
13407
|
-
var level = this.engine.gpuCapability.level;
|
|
13408
13509
|
var materialProps = {
|
|
13409
13510
|
shader: {
|
|
13410
|
-
vertex:
|
|
13411
|
-
fragment:
|
|
13511
|
+
vertex: vertex,
|
|
13512
|
+
fragment: fragment,
|
|
13412
13513
|
glslVersion: GLSLVersion.GLSL1,
|
|
13413
13514
|
cacheId: "".concat(rendererOptions.cachePrefix, "_effects_interact"),
|
|
13515
|
+
marcos: marcos,
|
|
13414
13516
|
},
|
|
13415
13517
|
uniformSemantics: {
|
|
13416
13518
|
effects_MatrixVP: 'VIEWPROJECTION',
|
|
@@ -13484,11 +13586,11 @@ var InteractComponent = /** @class */ (function (_super) {
|
|
|
13484
13586
|
}
|
|
13485
13587
|
InteractComponent_1 = InteractComponent;
|
|
13486
13588
|
InteractComponent.prototype.start = function () {
|
|
13487
|
-
var
|
|
13589
|
+
var _this = this;
|
|
13488
13590
|
var options = this.item.props.content.options;
|
|
13489
|
-
var env =
|
|
13591
|
+
var env = this.item.engine.renderer.env;
|
|
13490
13592
|
var composition = this.item.composition;
|
|
13491
|
-
var
|
|
13593
|
+
var _a = this.interactData.options, type = _a.type, showPreview = _a.showPreview;
|
|
13492
13594
|
if (type === InteractType$1.CLICK) {
|
|
13493
13595
|
this.clickable = true;
|
|
13494
13596
|
if (showPreview && env === PLAYER_OPTIONS_ENV_EDITOR) {
|
|
@@ -13496,7 +13598,8 @@ var InteractComponent = /** @class */ (function (_super) {
|
|
|
13496
13598
|
this.previewContent = new InteractMesh(this.item.props.content, rendererOptions, this.transform, this.engine);
|
|
13497
13599
|
}
|
|
13498
13600
|
}
|
|
13499
|
-
|
|
13601
|
+
composition.addInteractiveItem(this.item, options.type);
|
|
13602
|
+
this.item.onEnd = function () { return composition.removeInteractiveItem(_this.item, options.type); };
|
|
13500
13603
|
if (options.type === InteractType$1.DRAG) {
|
|
13501
13604
|
if (env !== PLAYER_OPTIONS_ENV_EDITOR || options.enableInEditor) {
|
|
13502
13605
|
composition.event && this.beginDragTarget(options, composition.event);
|
|
@@ -13640,7 +13743,7 @@ var InteractComponent = /** @class */ (function (_super) {
|
|
|
13640
13743
|
};
|
|
13641
13744
|
var InteractComponent_1;
|
|
13642
13745
|
InteractComponent = InteractComponent_1 = __decorate([
|
|
13643
|
-
effectsClass(DataType.InteractComponent)
|
|
13746
|
+
effectsClass(DataType$1.InteractComponent)
|
|
13644
13747
|
], InteractComponent);
|
|
13645
13748
|
return InteractComponent;
|
|
13646
13749
|
}(RendererComponent));
|
|
@@ -13689,8 +13792,8 @@ function spriteMeshShaderFromFilter(level, options) {
|
|
|
13689
13792
|
var fragment = wireframe ? itemFrameFrag : itemFrag.replace(/#pragma\s+FILTER_FRAG/, '');
|
|
13690
13793
|
var vertex = itemVert.replace(/#pragma\s+FILTER_VERT/, 'vec4 filterMain(float t,vec4 pos){return effects_MatrixVP * pos;}');
|
|
13691
13794
|
return {
|
|
13692
|
-
fragment:
|
|
13693
|
-
vertex:
|
|
13795
|
+
fragment: fragment,
|
|
13796
|
+
vertex: vertex,
|
|
13694
13797
|
glslVersion: level === 1 ? GLSLVersion.GLSL1 : GLSLVersion.GLSL3,
|
|
13695
13798
|
marcos: marcos,
|
|
13696
13799
|
shared: true,
|
|
@@ -15009,7 +15112,7 @@ var SpriteComponent = /** @class */ (function (_super) {
|
|
|
15009
15112
|
_super.prototype.toData.call(this);
|
|
15010
15113
|
};
|
|
15011
15114
|
SpriteComponent = __decorate([
|
|
15012
|
-
effectsClass(DataType.SpriteComponent)
|
|
15115
|
+
effectsClass(DataType$1.SpriteComponent)
|
|
15013
15116
|
], SpriteComponent);
|
|
15014
15117
|
return SpriteComponent;
|
|
15015
15118
|
}(RendererComponent));
|
|
@@ -15170,8 +15273,8 @@ var ParticleMesh = /** @class */ (function () {
|
|
|
15170
15273
|
var originalVertex = "#define LOOKUP_TEXTURE_CURVE ".concat(vertex_lookup_texture, "\n").concat(particleVert);
|
|
15171
15274
|
var vertex = originalVertex;
|
|
15172
15275
|
var shader = {
|
|
15173
|
-
fragment:
|
|
15174
|
-
vertex:
|
|
15276
|
+
fragment: fragment,
|
|
15277
|
+
vertex: vertex,
|
|
15175
15278
|
glslVersion: level === 1 ? GLSLVersion.GLSL1 : GLSLVersion.GLSL3,
|
|
15176
15279
|
shared: true,
|
|
15177
15280
|
cacheId: shaderCache,
|
|
@@ -15726,8 +15829,8 @@ var TrailMesh = /** @class */ (function () {
|
|
|
15726
15829
|
else {
|
|
15727
15830
|
uniformValues.uVCurveValues = CurveValue.getAllData(keyFrameMeta);
|
|
15728
15831
|
}
|
|
15729
|
-
var vertex =
|
|
15730
|
-
var fragment =
|
|
15832
|
+
var vertex = trailVert;
|
|
15833
|
+
var fragment = particleFrag;
|
|
15731
15834
|
var mtl = ({
|
|
15732
15835
|
shader: {
|
|
15733
15836
|
vertex: vertex,
|
|
@@ -16414,7 +16517,7 @@ var TextureShape = /** @class */ (function () {
|
|
|
16414
16517
|
return TextureShape;
|
|
16415
16518
|
}());
|
|
16416
16519
|
|
|
16417
|
-
var _a$
|
|
16520
|
+
var _a$6;
|
|
16418
16521
|
var ShapeNone = /** @class */ (function () {
|
|
16419
16522
|
function ShapeNone() {
|
|
16420
16523
|
}
|
|
@@ -16426,18 +16529,18 @@ var ShapeNone = /** @class */ (function () {
|
|
|
16426
16529
|
};
|
|
16427
16530
|
return ShapeNone;
|
|
16428
16531
|
}());
|
|
16429
|
-
var map$1 = (_a$
|
|
16430
|
-
_a$
|
|
16431
|
-
_a$
|
|
16432
|
-
_a$
|
|
16433
|
-
_a$
|
|
16434
|
-
_a$
|
|
16435
|
-
_a$
|
|
16436
|
-
_a$
|
|
16437
|
-
_a$
|
|
16438
|
-
_a$
|
|
16439
|
-
_a$
|
|
16440
|
-
_a$
|
|
16532
|
+
var map$1 = (_a$6 = {},
|
|
16533
|
+
_a$6[ShapeType$1.NONE] = ShapeNone,
|
|
16534
|
+
_a$6[ShapeType$1.CONE] = Cone,
|
|
16535
|
+
_a$6[ShapeType$1.SPHERE] = Sphere,
|
|
16536
|
+
_a$6[ShapeType$1.HEMISPHERE] = Hemisphere,
|
|
16537
|
+
_a$6[ShapeType$1.CIRCLE] = Circle,
|
|
16538
|
+
_a$6[ShapeType$1.DONUT] = Donut,
|
|
16539
|
+
_a$6[ShapeType$1.RECTANGLE] = Rectangle,
|
|
16540
|
+
_a$6[ShapeType$1.EDGE] = Edge,
|
|
16541
|
+
_a$6[ShapeType$1.RECTANGLE_EDGE] = RectangleEdge,
|
|
16542
|
+
_a$6[ShapeType$1.TEXTURE] = TextureShape,
|
|
16543
|
+
_a$6);
|
|
16441
16544
|
function createShape(shapeOptions) {
|
|
16442
16545
|
if (!shapeOptions) {
|
|
16443
16546
|
return new ShapeNone();
|
|
@@ -17766,7 +17869,7 @@ var ParticleSystem = /** @class */ (function (_super) {
|
|
|
17766
17869
|
}));
|
|
17767
17870
|
p.delay += meshTime;
|
|
17768
17871
|
cursor++;
|
|
17769
|
-
(_a = p.transform).translate.apply(_a, __spreadArray$
|
|
17872
|
+
(_a = p.transform).translate.apply(_a, __spreadArray$3([], __read$3(burstOffset), false));
|
|
17770
17873
|
this.addParticle(p, maxCount_1);
|
|
17771
17874
|
}
|
|
17772
17875
|
}
|
|
@@ -18355,7 +18458,7 @@ var ParticleSystem = /** @class */ (function (_super) {
|
|
|
18355
18458
|
timeline.createTrack(Track).createClip(ParticleBehaviourPlayable);
|
|
18356
18459
|
};
|
|
18357
18460
|
ParticleSystem = __decorate([
|
|
18358
|
-
effectsClass(DataType.ParticleSystem)
|
|
18461
|
+
effectsClass(DataType$1.ParticleSystem)
|
|
18359
18462
|
], ParticleSystem);
|
|
18360
18463
|
return ParticleSystem;
|
|
18361
18464
|
}(Component));
|
|
@@ -18538,7 +18641,9 @@ var TextStyle = /** @class */ (function () {
|
|
|
18538
18641
|
this.fontOffset = 0;
|
|
18539
18642
|
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;
|
|
18540
18643
|
this.textColor = textColor;
|
|
18644
|
+
//@ts-expect-error
|
|
18541
18645
|
this.textWeight = fontWeight;
|
|
18646
|
+
//@ts-expect-error
|
|
18542
18647
|
this.fontStyle = fontStyle;
|
|
18543
18648
|
this.fontFamily = fontFamily;
|
|
18544
18649
|
this.fontSize = fontSize; // 暂时取消字号限制 Math.min(fontSize, this.maxFontSize);
|
|
@@ -20048,7 +20153,7 @@ var TextComponent = /** @class */ (function (_super) {
|
|
|
20048
20153
|
context.shadowOffsetY = -style.shadowOffsetY;
|
|
20049
20154
|
};
|
|
20050
20155
|
TextComponent = __decorate([
|
|
20051
|
-
effectsClass(DataType.TextComponent)
|
|
20156
|
+
effectsClass(DataType$1.TextComponent)
|
|
20052
20157
|
], TextComponent);
|
|
20053
20158
|
return TextComponent;
|
|
20054
20159
|
}(SpriteComponent));
|
|
@@ -20204,7 +20309,7 @@ var EffectComponent = /** @class */ (function (_super) {
|
|
|
20204
20309
|
serialize()
|
|
20205
20310
|
], EffectComponent.prototype, "geometry", void 0);
|
|
20206
20311
|
EffectComponent = __decorate([
|
|
20207
|
-
effectsClass(DataType.EffectComponent)
|
|
20312
|
+
effectsClass(DataType$1.EffectComponent)
|
|
20208
20313
|
], EffectComponent);
|
|
20209
20314
|
return EffectComponent;
|
|
20210
20315
|
}(RendererComponent));
|
|
@@ -20606,7 +20711,10 @@ var VFXItem = /** @class */ (function (_super) {
|
|
|
20606
20711
|
try {
|
|
20607
20712
|
for (var _e = __values$1(this.children), _f = _e.next(); !_f.done; _f = _e.next()) {
|
|
20608
20713
|
var child = _f.value;
|
|
20609
|
-
|
|
20714
|
+
var res = child.find(name);
|
|
20715
|
+
if (res) {
|
|
20716
|
+
return res;
|
|
20717
|
+
}
|
|
20610
20718
|
}
|
|
20611
20719
|
}
|
|
20612
20720
|
catch (e_4_1) { e_4 = { error: e_4_1 }; }
|
|
@@ -20623,6 +20731,7 @@ var VFXItem = /** @class */ (function (_super) {
|
|
|
20623
20731
|
_super.prototype.fromData.call(this, data);
|
|
20624
20732
|
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;
|
|
20625
20733
|
this.props = data;
|
|
20734
|
+
//@ts-expect-error
|
|
20626
20735
|
this.type = data.type;
|
|
20627
20736
|
this.id = id.toString(); // TODO 老数据 id 是 number,需要转换
|
|
20628
20737
|
this.name = name;
|
|
@@ -20691,7 +20800,7 @@ var VFXItem = /** @class */ (function (_super) {
|
|
|
20691
20800
|
var _b, _c;
|
|
20692
20801
|
this.taggedProperties.id = this.guid;
|
|
20693
20802
|
this.taggedProperties.transform = this.transform.toData();
|
|
20694
|
-
this.taggedProperties.dataType = DataType.VFXItemData;
|
|
20803
|
+
this.taggedProperties.dataType = DataType$1.VFXItemData;
|
|
20695
20804
|
if (((_b = this.parent) === null || _b === void 0 ? void 0 : _b.name) !== 'rootItem') {
|
|
20696
20805
|
this.taggedProperties.parentId = (_c = this.parent) === null || _c === void 0 ? void 0 : _c.guid;
|
|
20697
20806
|
}
|
|
@@ -20718,10 +20827,10 @@ var VFXItem = /** @class */ (function (_super) {
|
|
|
20718
20827
|
};
|
|
20719
20828
|
VFXItem.prototype.translateByPixel = function (x, y) {
|
|
20720
20829
|
if (this.composition) {
|
|
20830
|
+
// @ts-expect-error
|
|
20831
|
+
var _a = this.composition.renderer.canvas.getBoundingClientRect(), width = _a.width, height = _a.height;
|
|
20721
20832
|
var z = this.transform.getWorldPosition().z;
|
|
20722
|
-
var
|
|
20723
|
-
var width = this.composition.renderer.getWidth() / 2;
|
|
20724
|
-
var height = this.composition.renderer.getHeight() / 2;
|
|
20833
|
+
var _b = this.composition.camera.getInverseVPRatio(z), rx = _b.x, ry = _b.y;
|
|
20725
20834
|
this.transform.translate(2 * x * rx / width, -2 * y * ry / height, 0);
|
|
20726
20835
|
}
|
|
20727
20836
|
};
|
|
@@ -20788,7 +20897,7 @@ var VFXItem = /** @class */ (function (_super) {
|
|
|
20788
20897
|
};
|
|
20789
20898
|
var VFXItem_1;
|
|
20790
20899
|
VFXItem = VFXItem_1 = __decorate([
|
|
20791
|
-
effectsClass(DataType.VFXItemData)
|
|
20900
|
+
effectsClass(DataType$1.VFXItemData)
|
|
20792
20901
|
], VFXItem);
|
|
20793
20902
|
return VFXItem;
|
|
20794
20903
|
}(EffectsObject));
|
|
@@ -20826,7 +20935,6 @@ function createVFXItem(props, composition) {
|
|
|
20826
20935
|
if (!pluginName) {
|
|
20827
20936
|
switch (type) {
|
|
20828
20937
|
case ItemType$1.null:
|
|
20829
|
-
case ItemType$1.base:
|
|
20830
20938
|
pluginName = 'cal';
|
|
20831
20939
|
break;
|
|
20832
20940
|
case ItemType$1.sprite:
|
|
@@ -20947,7 +21055,7 @@ var PluginSystem = /** @class */ (function () {
|
|
|
20947
21055
|
plugin = plugins[i];
|
|
20948
21056
|
ctrl = pluginLoaderMap[plugin.name];
|
|
20949
21057
|
if (name in ctrl) {
|
|
20950
|
-
pendings.push(Promise.resolve(ctrl[name].apply(ctrl, __spreadArray$
|
|
21058
|
+
pendings.push(Promise.resolve(ctrl[name].apply(ctrl, __spreadArray$3([], __read$3(args), false))));
|
|
20951
21059
|
}
|
|
20952
21060
|
}
|
|
20953
21061
|
return [2 /*return*/, Promise.all(pendings)];
|
|
@@ -20992,9 +21100,74 @@ function getPluginUsageInfo(name) {
|
|
|
20992
21100
|
* Name: @galacean/effects-specification
|
|
20993
21101
|
* Description: Galacean Effects JSON Specification
|
|
20994
21102
|
* Author: Ant Group CO., Ltd.
|
|
20995
|
-
* Version:
|
|
21103
|
+
* Version: v2.0.0-alpha.2
|
|
21104
|
+
*/
|
|
21105
|
+
|
|
21106
|
+
const randomUUID = typeof crypto !== 'undefined' && crypto.randomUUID && crypto.randomUUID.bind(crypto);
|
|
21107
|
+
var native = {
|
|
21108
|
+
randomUUID
|
|
21109
|
+
};
|
|
21110
|
+
|
|
21111
|
+
// Unique ID creation requires a high quality random # generator. In the browser we therefore
|
|
21112
|
+
// require the crypto API and do not support built-in fallback to lower quality random number
|
|
21113
|
+
// generators (like Math.random()).
|
|
21114
|
+
let getRandomValues;
|
|
21115
|
+
const rnds8 = new Uint8Array(16);
|
|
21116
|
+
function rng() {
|
|
21117
|
+
// lazy load so that environments that need to polyfill have a chance to do so
|
|
21118
|
+
if (!getRandomValues) {
|
|
21119
|
+
// getRandomValues needs to be invoked in a context where "this" is a Crypto implementation.
|
|
21120
|
+
getRandomValues = typeof crypto !== 'undefined' && crypto.getRandomValues && crypto.getRandomValues.bind(crypto);
|
|
21121
|
+
|
|
21122
|
+
if (!getRandomValues) {
|
|
21123
|
+
throw new Error('crypto.getRandomValues() not supported. See https://github.com/uuidjs/uuid#getrandomvalues-not-supported');
|
|
21124
|
+
}
|
|
21125
|
+
}
|
|
21126
|
+
|
|
21127
|
+
return getRandomValues(rnds8);
|
|
21128
|
+
}
|
|
21129
|
+
|
|
21130
|
+
/**
|
|
21131
|
+
* Convert array of 16 byte values to UUID string format of the form:
|
|
21132
|
+
* XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX
|
|
20996
21133
|
*/
|
|
20997
21134
|
|
|
21135
|
+
const byteToHex = [];
|
|
21136
|
+
|
|
21137
|
+
for (let i = 0; i < 256; ++i) {
|
|
21138
|
+
byteToHex.push((i + 0x100).toString(16).slice(1));
|
|
21139
|
+
}
|
|
21140
|
+
|
|
21141
|
+
function unsafeStringify(arr, offset = 0) {
|
|
21142
|
+
// Note: Be careful editing this code! It's been tuned for performance
|
|
21143
|
+
// and works in ways you may not expect. See https://github.com/uuidjs/uuid/pull/434
|
|
21144
|
+
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]];
|
|
21145
|
+
}
|
|
21146
|
+
|
|
21147
|
+
function v4(options, buf, offset) {
|
|
21148
|
+
if (native.randomUUID && !buf && !options) {
|
|
21149
|
+
return native.randomUUID();
|
|
21150
|
+
}
|
|
21151
|
+
|
|
21152
|
+
options = options || {};
|
|
21153
|
+
const rnds = options.random || (options.rng || rng)(); // Per 4.4, set bits for version and `clock_seq_hi_and_reserved`
|
|
21154
|
+
|
|
21155
|
+
rnds[6] = rnds[6] & 0x0f | 0x40;
|
|
21156
|
+
rnds[8] = rnds[8] & 0x3f | 0x80; // Copy bytes to buffer, if provided
|
|
21157
|
+
|
|
21158
|
+
if (buf) {
|
|
21159
|
+
offset = offset || 0;
|
|
21160
|
+
|
|
21161
|
+
for (let i = 0; i < 16; ++i) {
|
|
21162
|
+
buf[offset + i] = rnds[i];
|
|
21163
|
+
}
|
|
21164
|
+
|
|
21165
|
+
return buf;
|
|
21166
|
+
}
|
|
21167
|
+
|
|
21168
|
+
return unsafeStringify(rnds);
|
|
21169
|
+
}
|
|
21170
|
+
|
|
20998
21171
|
/*********************************************/
|
|
20999
21172
|
/* 元素属性参数类型 */
|
|
21000
21173
|
/*********************************************/
|
|
@@ -21257,6 +21430,10 @@ var ItemType;
|
|
|
21257
21430
|
* 天空盒元素
|
|
21258
21431
|
*/
|
|
21259
21432
|
ItemType["skybox"] = "skybox";
|
|
21433
|
+
/**
|
|
21434
|
+
* 特效元素
|
|
21435
|
+
*/
|
|
21436
|
+
ItemType["effect"] = "effect";
|
|
21260
21437
|
})(ItemType || (ItemType = {}));
|
|
21261
21438
|
/**
|
|
21262
21439
|
* 渲染模式
|
|
@@ -21369,6 +21546,10 @@ var CompositionEndBehavior;
|
|
|
21369
21546
|
* 销毁并保留最后一帧
|
|
21370
21547
|
*/
|
|
21371
21548
|
CompositionEndBehavior[CompositionEndBehavior["pause_destroy"] = END_BEHAVIOR_PAUSE_AND_DESTROY] = "pause_destroy";
|
|
21549
|
+
/**
|
|
21550
|
+
* 冻结
|
|
21551
|
+
*/
|
|
21552
|
+
CompositionEndBehavior[CompositionEndBehavior["freeze"] = END_BEHAVIOR_FREEZE] = "freeze";
|
|
21372
21553
|
})(CompositionEndBehavior || (CompositionEndBehavior = {}));
|
|
21373
21554
|
|
|
21374
21555
|
/*********************************************/
|
|
@@ -21505,12 +21686,38 @@ var ShapeArcMode;
|
|
|
21505
21686
|
ShapeArcMode[ShapeArcMode["UNIFORM_BURST"] = 3] = "UNIFORM_BURST";
|
|
21506
21687
|
})(ShapeArcMode || (ShapeArcMode = {}));
|
|
21507
21688
|
|
|
21689
|
+
var LightType;
|
|
21690
|
+
(function (LightType) {
|
|
21691
|
+
/**
|
|
21692
|
+
* 点光源
|
|
21693
|
+
*/
|
|
21694
|
+
LightType["point"] = "point";
|
|
21695
|
+
/**
|
|
21696
|
+
* 聚光灯
|
|
21697
|
+
*/
|
|
21698
|
+
LightType["spot"] = "spot";
|
|
21699
|
+
/**
|
|
21700
|
+
* 方向光
|
|
21701
|
+
*/
|
|
21702
|
+
LightType["directional"] = "directional";
|
|
21703
|
+
/**
|
|
21704
|
+
* 环境光
|
|
21705
|
+
*/
|
|
21706
|
+
LightType["ambient"] = "ambient";
|
|
21707
|
+
})(LightType || (LightType = {}));
|
|
21708
|
+
|
|
21508
21709
|
var ModelBoundingType;
|
|
21509
21710
|
(function (ModelBoundingType) {
|
|
21510
21711
|
ModelBoundingType[ModelBoundingType["box"] = 2] = "box";
|
|
21511
21712
|
ModelBoundingType[ModelBoundingType["sphere"] = 3] = "sphere";
|
|
21512
21713
|
})(ModelBoundingType || (ModelBoundingType = {}));
|
|
21513
21714
|
|
|
21715
|
+
var CameraType;
|
|
21716
|
+
(function (CameraType) {
|
|
21717
|
+
CameraType["orthographic"] = "orthographic";
|
|
21718
|
+
CameraType["perspective"] = "perspective";
|
|
21719
|
+
})(CameraType || (CameraType = {}));
|
|
21720
|
+
|
|
21514
21721
|
// 材质类型
|
|
21515
21722
|
var MaterialType;
|
|
21516
21723
|
(function (MaterialType) {
|
|
@@ -21656,6 +21863,28 @@ var FontStyle;
|
|
|
21656
21863
|
FontStyle["oblique"] = "oblique";
|
|
21657
21864
|
})(FontStyle || (FontStyle = {}));
|
|
21658
21865
|
|
|
21866
|
+
var DataType;
|
|
21867
|
+
(function (DataType) {
|
|
21868
|
+
DataType["VFXItemData"] = "VFXItemData";
|
|
21869
|
+
DataType["EffectComponent"] = "EffectComponent";
|
|
21870
|
+
DataType["Material"] = "Material";
|
|
21871
|
+
DataType["Shader"] = "Shader";
|
|
21872
|
+
DataType["SpriteComponent"] = "SpriteComponent";
|
|
21873
|
+
DataType["ParticleSystem"] = "ParticleSystem";
|
|
21874
|
+
DataType["InteractComponent"] = "InteractComponent";
|
|
21875
|
+
DataType["CameraController"] = "CameraController";
|
|
21876
|
+
DataType["Geometry"] = "Geometry";
|
|
21877
|
+
DataType["Texture"] = "Texture";
|
|
21878
|
+
DataType["TextComponent"] = "TextComponent";
|
|
21879
|
+
// FIXME: 先完成ECS的场景转换,后面移到spec中
|
|
21880
|
+
DataType["MeshComponent"] = "MeshComponent";
|
|
21881
|
+
DataType["SkyboxComponent"] = "SkyboxComponent";
|
|
21882
|
+
DataType["LightComponent"] = "LightComponent";
|
|
21883
|
+
DataType["CameraComponent"] = "CameraComponent";
|
|
21884
|
+
DataType["ModelPluginComponent"] = "ModelPluginComponent";
|
|
21885
|
+
DataType["TreeComponent"] = "TreeComponent";
|
|
21886
|
+
})(DataType || (DataType = {}));
|
|
21887
|
+
|
|
21659
21888
|
/******************************************************************************
|
|
21660
21889
|
Copyright (c) Microsoft Corporation.
|
|
21661
21890
|
|
|
@@ -21711,11 +21940,22 @@ function __read(o, n) {
|
|
|
21711
21940
|
return ar;
|
|
21712
21941
|
}
|
|
21713
21942
|
|
|
21943
|
+
function __spreadArray(to, from, pack) {
|
|
21944
|
+
if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {
|
|
21945
|
+
if (ar || !(i in from)) {
|
|
21946
|
+
if (!ar) ar = Array.prototype.slice.call(from, 0, i);
|
|
21947
|
+
ar[i] = from[i];
|
|
21948
|
+
}
|
|
21949
|
+
}
|
|
21950
|
+
return to.concat(ar || Array.prototype.slice.call(from));
|
|
21951
|
+
}
|
|
21952
|
+
|
|
21714
21953
|
typeof SuppressedError === "function" ? SuppressedError : function (error, suppressed, message) {
|
|
21715
21954
|
var e = new Error(message);
|
|
21716
21955
|
return e.name = "SuppressedError", e.error = error, e.suppressed = suppressed, e;
|
|
21717
21956
|
};
|
|
21718
21957
|
|
|
21958
|
+
var _a$5;
|
|
21719
21959
|
function arrAdd(arr, item) {
|
|
21720
21960
|
if (!arr.includes(item)) {
|
|
21721
21961
|
arr.push(item);
|
|
@@ -21951,6 +22191,34 @@ function rotationZYXFromQuat(out, quat) {
|
|
|
21951
22191
|
}
|
|
21952
22192
|
return out;
|
|
21953
22193
|
}
|
|
22194
|
+
function generateGUID() {
|
|
22195
|
+
return v4().replace(/-/g, '');
|
|
22196
|
+
}
|
|
22197
|
+
/**
|
|
22198
|
+
* 提取并转换 JSON 数据中的 anchor 值
|
|
22199
|
+
*/
|
|
22200
|
+
function convertAnchor$1(anchor, particleOrigin) {
|
|
22201
|
+
if (anchor) {
|
|
22202
|
+
return [anchor[0] - 0.5, 0.5 - anchor[1]];
|
|
22203
|
+
}
|
|
22204
|
+
else if (particleOrigin) {
|
|
22205
|
+
return particleOriginTranslateMap[particleOrigin];
|
|
22206
|
+
}
|
|
22207
|
+
else {
|
|
22208
|
+
return [0, 0];
|
|
22209
|
+
}
|
|
22210
|
+
}
|
|
22211
|
+
var particleOriginTranslateMap = (_a$5 = {},
|
|
22212
|
+
_a$5[ParticleOrigin.PARTICLE_ORIGIN_CENTER] = [0, 0],
|
|
22213
|
+
_a$5[ParticleOrigin.PARTICLE_ORIGIN_CENTER_BOTTOM] = [0, -0.5],
|
|
22214
|
+
_a$5[ParticleOrigin.PARTICLE_ORIGIN_CENTER_TOP] = [0, 0.5],
|
|
22215
|
+
_a$5[ParticleOrigin.PARTICLE_ORIGIN_LEFT_TOP] = [-0.5, 0.5],
|
|
22216
|
+
_a$5[ParticleOrigin.PARTICLE_ORIGIN_LEFT_CENTER] = [-0.5, 0],
|
|
22217
|
+
_a$5[ParticleOrigin.PARTICLE_ORIGIN_LEFT_BOTTOM] = [-0.5, -0.5],
|
|
22218
|
+
_a$5[ParticleOrigin.PARTICLE_ORIGIN_RIGHT_CENTER] = [0.5, 0],
|
|
22219
|
+
_a$5[ParticleOrigin.PARTICLE_ORIGIN_RIGHT_BOTTOM] = [0.5, -0.5],
|
|
22220
|
+
_a$5[ParticleOrigin.PARTICLE_ORIGIN_RIGHT_TOP] = [0.5, 0.5],
|
|
22221
|
+
_a$5);
|
|
21954
22222
|
|
|
21955
22223
|
function getStandardParticleContent(particle) {
|
|
21956
22224
|
var _a;
|
|
@@ -22362,6 +22630,309 @@ function version22Migration(json) {
|
|
|
22362
22630
|
});
|
|
22363
22631
|
return json;
|
|
22364
22632
|
}
|
|
22633
|
+
/**
|
|
22634
|
+
* 3.0 以下版本数据适配(runtime 2.0及以上版本支持)
|
|
22635
|
+
*/
|
|
22636
|
+
function version30Migration(json) {
|
|
22637
|
+
var e_1, _a;
|
|
22638
|
+
var _b, _c, _d, _e;
|
|
22639
|
+
var result = Object.assign({}, json, {
|
|
22640
|
+
items: [],
|
|
22641
|
+
components: [],
|
|
22642
|
+
materials: [],
|
|
22643
|
+
shaders: [],
|
|
22644
|
+
geometries: [],
|
|
22645
|
+
});
|
|
22646
|
+
// 兼容老版本数据中不存在textures的情况
|
|
22647
|
+
(_b = result.textures) !== null && _b !== void 0 ? _b : (result.textures = []);
|
|
22648
|
+
result.textures.forEach(function (textureOptions) {
|
|
22649
|
+
Object.assign(textureOptions, {
|
|
22650
|
+
id: generateGUID(),
|
|
22651
|
+
dataType: DataType.Texture,
|
|
22652
|
+
});
|
|
22653
|
+
});
|
|
22654
|
+
if (result.textures.length < result.images.length) {
|
|
22655
|
+
for (var i = result.textures.length; i < result.images.length; i++) {
|
|
22656
|
+
result.textures.push({
|
|
22657
|
+
//@ts-expect-error
|
|
22658
|
+
id: generateGUID(),
|
|
22659
|
+
dataType: DataType.Texture,
|
|
22660
|
+
source: i,
|
|
22661
|
+
flipY: true,
|
|
22662
|
+
});
|
|
22663
|
+
}
|
|
22664
|
+
}
|
|
22665
|
+
var _loop_1 = function (composition) {
|
|
22666
|
+
var e_2, _h, e_3, _j;
|
|
22667
|
+
// composition 的 endbehaviour 兼容
|
|
22668
|
+
if (composition.endBehavior === END_BEHAVIOR_PAUSE_AND_DESTROY || composition.endBehavior === END_BEHAVIOR_PAUSE) {
|
|
22669
|
+
composition.endBehavior = END_BEHAVIOR_FREEZE;
|
|
22670
|
+
}
|
|
22671
|
+
var itemGuidMap = {};
|
|
22672
|
+
try {
|
|
22673
|
+
for (var _k = (e_2 = void 0, __values(composition.items)), _l = _k.next(); !_l.done; _l = _k.next()) {
|
|
22674
|
+
var item = _l.value;
|
|
22675
|
+
itemGuidMap[item.id] = generateGUID();
|
|
22676
|
+
// TODO: 编辑器测试用,上线后删除
|
|
22677
|
+
//@ts-expect-error
|
|
22678
|
+
item.oldId = item.id;
|
|
22679
|
+
item.id = itemGuidMap[item.id];
|
|
22680
|
+
}
|
|
22681
|
+
}
|
|
22682
|
+
catch (e_2_1) { e_2 = { error: e_2_1 }; }
|
|
22683
|
+
finally {
|
|
22684
|
+
try {
|
|
22685
|
+
if (_l && !_l.done && (_h = _k.return)) _h.call(_k);
|
|
22686
|
+
}
|
|
22687
|
+
finally { if (e_2) throw e_2.error; }
|
|
22688
|
+
}
|
|
22689
|
+
composition.items.forEach(function (item, index) {
|
|
22690
|
+
if (item.parentId) {
|
|
22691
|
+
if (item.parentId.includes('^')) {
|
|
22692
|
+
var parentId = (item.parentId).split('^')[0];
|
|
22693
|
+
var nodeId = (item.parentId).split('^')[1];
|
|
22694
|
+
item.parentId = itemGuidMap[parentId] + '^' + nodeId;
|
|
22695
|
+
}
|
|
22696
|
+
else {
|
|
22697
|
+
item.parentId = itemGuidMap[item.parentId];
|
|
22698
|
+
}
|
|
22699
|
+
}
|
|
22700
|
+
// @ts-expect-error fix item type
|
|
22701
|
+
result.items.push(item);
|
|
22702
|
+
// @ts-expect-error fix item type
|
|
22703
|
+
composition.items[index] = { id: item.id };
|
|
22704
|
+
});
|
|
22705
|
+
try {
|
|
22706
|
+
for (var _m = (e_3 = void 0, __values(result.items)), _o = _m.next(); !_o.done; _o = _m.next()) {
|
|
22707
|
+
var item = _o.value;
|
|
22708
|
+
// 原 texture 索引转为统一 guid 索引
|
|
22709
|
+
if (item.content) {
|
|
22710
|
+
if (item.content.renderer) {
|
|
22711
|
+
if (item.content.renderer.texture !== undefined) {
|
|
22712
|
+
var oldTextureId = item.content.renderer.texture;
|
|
22713
|
+
//@ts-expect-error
|
|
22714
|
+
item.content.renderer.texture = { id: result.textures[oldTextureId].id };
|
|
22715
|
+
}
|
|
22716
|
+
}
|
|
22717
|
+
if (item.content.trails) {
|
|
22718
|
+
if (item.content.trails.texture !== undefined) {
|
|
22719
|
+
var oldTextureId = item.content.trails.texture;
|
|
22720
|
+
//@ts-expect-error
|
|
22721
|
+
item.content.trails.texture = { id: result.textures[oldTextureId].id };
|
|
22722
|
+
}
|
|
22723
|
+
}
|
|
22724
|
+
}
|
|
22725
|
+
// item 的 transform 属性由数组转为 {x:n, y:n, z:n}
|
|
22726
|
+
if (item.transform) {
|
|
22727
|
+
//@ts-expect-error
|
|
22728
|
+
var position = __spreadArray([], __read((_c = item.transform.position) !== null && _c !== void 0 ? _c : [0, 0, 0]), false);
|
|
22729
|
+
//@ts-expect-error
|
|
22730
|
+
var rotation = __spreadArray([], __read((_d = item.transform.rotation) !== null && _d !== void 0 ? _d : [0, 0, 0]), false);
|
|
22731
|
+
//@ts-expect-error
|
|
22732
|
+
var scale = __spreadArray([], __read((_e = item.transform.scale) !== null && _e !== void 0 ? _e : [1, 1, 1]), false);
|
|
22733
|
+
Object.assign(item, {
|
|
22734
|
+
transform: {
|
|
22735
|
+
position: { x: position[0], y: position[1], z: position[2] },
|
|
22736
|
+
rotation: { x: rotation[0], y: rotation[1], z: rotation[2] },
|
|
22737
|
+
scale: { x: scale[0], y: scale[1], z: scale[0] },
|
|
22738
|
+
},
|
|
22739
|
+
});
|
|
22740
|
+
// sprite 的 scale 转为 size
|
|
22741
|
+
if (item.type === ItemType.sprite) {
|
|
22742
|
+
item.transform.size = { x: scale[0], y: scale[1] };
|
|
22743
|
+
item.transform.scale = { x: 1, y: 1, z: 1 };
|
|
22744
|
+
}
|
|
22745
|
+
// sprite 的 anchor 修正
|
|
22746
|
+
if (item.type === ItemType.sprite) {
|
|
22747
|
+
var content = item.content;
|
|
22748
|
+
if (!content.renderer) {
|
|
22749
|
+
content.renderer = {};
|
|
22750
|
+
}
|
|
22751
|
+
var renderer = content.renderer;
|
|
22752
|
+
var realAnchor = convertAnchor$1(renderer.anchor, renderer.particleOrigin);
|
|
22753
|
+
var startSize = item.transform.size;
|
|
22754
|
+
// 兼容旧JSON(anchor和particleOrigin可能同时存在)
|
|
22755
|
+
if (!renderer.anchor && renderer.particleOrigin !== undefined) {
|
|
22756
|
+
//@ts-expect-error
|
|
22757
|
+
item.transform.position.x += -realAnchor[0] * startSize.x;
|
|
22758
|
+
//@ts-expect-error
|
|
22759
|
+
item.transform.position.y += -realAnchor[1] * startSize.y;
|
|
22760
|
+
}
|
|
22761
|
+
//@ts-expect-error
|
|
22762
|
+
item.transform.anchor = { x: realAnchor[0] * startSize.x, y: realAnchor[1] * startSize.y };
|
|
22763
|
+
}
|
|
22764
|
+
}
|
|
22765
|
+
if (item.type === ItemType.particle) {
|
|
22766
|
+
var content = item.content;
|
|
22767
|
+
if (!content.renderer) {
|
|
22768
|
+
content.renderer = {};
|
|
22769
|
+
}
|
|
22770
|
+
var renderer = content.renderer;
|
|
22771
|
+
content.renderer.anchor = convertAnchor$1(renderer.anchor, renderer.particleOrigin);
|
|
22772
|
+
}
|
|
22773
|
+
// 动画数据转化 TODO: 动画数据移到 TimelineComponentData
|
|
22774
|
+
item.content.tracks = [];
|
|
22775
|
+
var tracks = item.content.tracks;
|
|
22776
|
+
if (item.type !== ItemType.particle) {
|
|
22777
|
+
tracks.push({
|
|
22778
|
+
clips: [
|
|
22779
|
+
{
|
|
22780
|
+
dataType: 'TransformAnimationPlayableAsset',
|
|
22781
|
+
animationClip: {
|
|
22782
|
+
sizeOverLifetime: item.content.sizeOverLifetime,
|
|
22783
|
+
rotationOverLifetime: item.content.rotationOverLifetime,
|
|
22784
|
+
positionOverLifetime: item.content.positionOverLifetime,
|
|
22785
|
+
},
|
|
22786
|
+
},
|
|
22787
|
+
],
|
|
22788
|
+
});
|
|
22789
|
+
}
|
|
22790
|
+
if (item.type === ItemType.sprite) {
|
|
22791
|
+
tracks.push({
|
|
22792
|
+
clips: [
|
|
22793
|
+
{
|
|
22794
|
+
dataType: 'SpriteColorAnimationPlayableAsset',
|
|
22795
|
+
animationClip: {
|
|
22796
|
+
colorOverLifetime: item.content.colorOverLifetime,
|
|
22797
|
+
startColor: item.content.options.startColor,
|
|
22798
|
+
},
|
|
22799
|
+
},
|
|
22800
|
+
],
|
|
22801
|
+
});
|
|
22802
|
+
}
|
|
22803
|
+
// gizmo 的 target id 转换为新的 item guid
|
|
22804
|
+
if (item.content.options.target) {
|
|
22805
|
+
item.content.options.target = itemGuidMap[item.content.options.target];
|
|
22806
|
+
}
|
|
22807
|
+
// item 的 content 转为 component data 加入 JSONScene.components
|
|
22808
|
+
var uuid = generateGUID();
|
|
22809
|
+
if (item.type === ItemType.sprite) {
|
|
22810
|
+
item.components = [];
|
|
22811
|
+
result.components.push(item.content);
|
|
22812
|
+
item.content.id = uuid;
|
|
22813
|
+
item.content.dataType = DataType.SpriteComponent;
|
|
22814
|
+
item.content.item = { id: item.id };
|
|
22815
|
+
item.dataType = DataType.VFXItemData;
|
|
22816
|
+
//@ts-expect-error
|
|
22817
|
+
item.components.push({ id: item.content.id });
|
|
22818
|
+
}
|
|
22819
|
+
else if (item.type === ItemType.particle) {
|
|
22820
|
+
item.components = [];
|
|
22821
|
+
result.components.push(item.content);
|
|
22822
|
+
item.content.id = uuid;
|
|
22823
|
+
item.content.dataType = DataType.ParticleSystem;
|
|
22824
|
+
item.content.item = { id: item.id };
|
|
22825
|
+
item.dataType = DataType.VFXItemData;
|
|
22826
|
+
//@ts-expect-error
|
|
22827
|
+
item.components.push({ id: item.content.id });
|
|
22828
|
+
}
|
|
22829
|
+
else if (item.type === ItemType.mesh) {
|
|
22830
|
+
item.components = [];
|
|
22831
|
+
result.components.push(item.content);
|
|
22832
|
+
item.content.id = uuid;
|
|
22833
|
+
item.content.dataType = DataType.MeshComponent;
|
|
22834
|
+
item.content.item = { id: item.id };
|
|
22835
|
+
item.dataType = DataType.VFXItemData;
|
|
22836
|
+
//@ts-expect-error
|
|
22837
|
+
item.components.push({ id: item.content.id });
|
|
22838
|
+
}
|
|
22839
|
+
else if (item.type === ItemType.skybox) {
|
|
22840
|
+
item.components = [];
|
|
22841
|
+
result.components.push(item.content);
|
|
22842
|
+
item.content.id = uuid;
|
|
22843
|
+
item.content.dataType = DataType.SkyboxComponent;
|
|
22844
|
+
item.content.item = { id: item.id };
|
|
22845
|
+
item.dataType = DataType.VFXItemData;
|
|
22846
|
+
//@ts-expect-error
|
|
22847
|
+
item.components.push({ id: item.content.id });
|
|
22848
|
+
}
|
|
22849
|
+
else if (item.type === ItemType.light) {
|
|
22850
|
+
item.components = [];
|
|
22851
|
+
result.components.push(item.content);
|
|
22852
|
+
item.content.id = uuid;
|
|
22853
|
+
item.content.dataType = DataType.LightComponent;
|
|
22854
|
+
item.content.item = { id: item.id };
|
|
22855
|
+
item.dataType = DataType.VFXItemData;
|
|
22856
|
+
//@ts-expect-error
|
|
22857
|
+
item.components.push({ id: item.content.id });
|
|
22858
|
+
}
|
|
22859
|
+
else if (item.type === 'camera') {
|
|
22860
|
+
item.components = [];
|
|
22861
|
+
result.components.push(item.content);
|
|
22862
|
+
item.content.id = uuid;
|
|
22863
|
+
item.content.dataType = DataType.CameraComponent;
|
|
22864
|
+
item.content.item = { id: item.id };
|
|
22865
|
+
item.dataType = DataType.VFXItemData;
|
|
22866
|
+
//@ts-expect-error
|
|
22867
|
+
item.components.push({ id: item.content.id });
|
|
22868
|
+
}
|
|
22869
|
+
else if (item.type === ItemType.tree) {
|
|
22870
|
+
item.components = [];
|
|
22871
|
+
result.components.push(item.content);
|
|
22872
|
+
item.content.id = uuid;
|
|
22873
|
+
item.content.dataType = DataType.TreeComponent;
|
|
22874
|
+
item.content.item = { id: item.id };
|
|
22875
|
+
item.dataType = DataType.VFXItemData;
|
|
22876
|
+
//@ts-expect-error
|
|
22877
|
+
item.components.push({ id: item.content.id });
|
|
22878
|
+
}
|
|
22879
|
+
else if (item.type === ItemType.interact) {
|
|
22880
|
+
item.components = [];
|
|
22881
|
+
result.components.push(item.content);
|
|
22882
|
+
item.content.id = uuid;
|
|
22883
|
+
item.content.dataType = DataType.InteractComponent;
|
|
22884
|
+
item.content.item = { id: item.id };
|
|
22885
|
+
item.dataType = DataType.VFXItemData;
|
|
22886
|
+
//@ts-expect-error
|
|
22887
|
+
item.components.push({ id: item.content.id });
|
|
22888
|
+
}
|
|
22889
|
+
else if (item.type === ItemType.camera) {
|
|
22890
|
+
item.components = [];
|
|
22891
|
+
result.components.push(item.content);
|
|
22892
|
+
item.content.id = uuid;
|
|
22893
|
+
item.content.dataType = DataType.CameraController;
|
|
22894
|
+
item.content.item = { id: item.id };
|
|
22895
|
+
item.dataType = DataType.VFXItemData;
|
|
22896
|
+
//@ts-expect-error
|
|
22897
|
+
item.components.push({ id: item.content.id });
|
|
22898
|
+
}
|
|
22899
|
+
else if (item.type === ItemType.text) {
|
|
22900
|
+
item.components = [];
|
|
22901
|
+
result.components.push(item.content);
|
|
22902
|
+
item.content.id = uuid;
|
|
22903
|
+
item.content.dataType = DataType.TextComponent;
|
|
22904
|
+
item.content.item = { id: item.id };
|
|
22905
|
+
item.dataType = DataType.VFXItemData;
|
|
22906
|
+
//@ts-expect-error
|
|
22907
|
+
item.components.push({ id: item.content.id });
|
|
22908
|
+
}
|
|
22909
|
+
}
|
|
22910
|
+
}
|
|
22911
|
+
catch (e_3_1) { e_3 = { error: e_3_1 }; }
|
|
22912
|
+
finally {
|
|
22913
|
+
try {
|
|
22914
|
+
if (_o && !_o.done && (_j = _m.return)) _j.call(_m);
|
|
22915
|
+
}
|
|
22916
|
+
finally { if (e_3) throw e_3.error; }
|
|
22917
|
+
}
|
|
22918
|
+
};
|
|
22919
|
+
try {
|
|
22920
|
+
// 更正Composition.endBehavior
|
|
22921
|
+
for (var _f = __values(json.compositions), _g = _f.next(); !_g.done; _g = _f.next()) {
|
|
22922
|
+
var composition = _g.value;
|
|
22923
|
+
_loop_1(composition);
|
|
22924
|
+
}
|
|
22925
|
+
}
|
|
22926
|
+
catch (e_1_1) { e_1 = { error: e_1_1 }; }
|
|
22927
|
+
finally {
|
|
22928
|
+
try {
|
|
22929
|
+
if (_g && !_g.done && (_a = _f.return)) _a.call(_f);
|
|
22930
|
+
}
|
|
22931
|
+
finally { if (e_1) throw e_1.error; }
|
|
22932
|
+
}
|
|
22933
|
+
result.version = '3.0';
|
|
22934
|
+
return result;
|
|
22935
|
+
}
|
|
22365
22936
|
|
|
22366
22937
|
var v0 = /^(\d+)\.(\d+)\.(\d+)(-(\w+)\.\d+)?$/;
|
|
22367
22938
|
var standardVersion = /^(\d+)\.(\d+)$/;
|
|
@@ -22371,16 +22942,16 @@ function getStandardJSON(json) {
|
|
|
22371
22942
|
if (!json || typeof json !== 'object') {
|
|
22372
22943
|
throw Error('expect a json object');
|
|
22373
22944
|
}
|
|
22374
|
-
// 修正老版本数据中,meshItem以及lightItem结束行为错误问题
|
|
22945
|
+
// 修正老版本数据中,meshItem 以及 lightItem 结束行为错误问题
|
|
22375
22946
|
version22Migration(json);
|
|
22376
22947
|
if (v0.test(json.version)) {
|
|
22377
22948
|
reverseParticle = ((_a = (/^(\d+)/).exec(json.version)) === null || _a === void 0 ? void 0 : _a[0]) === '0';
|
|
22378
|
-
return version21Migration(getStandardJSONFromV0(json));
|
|
22949
|
+
return version30Migration(version21Migration(getStandardJSONFromV0(json)));
|
|
22379
22950
|
}
|
|
22380
22951
|
var mainVersion = (_b = standardVersion.exec(json.version)) === null || _b === void 0 ? void 0 : _b[1];
|
|
22381
22952
|
if (mainVersion) {
|
|
22382
|
-
if (Number(mainVersion) <
|
|
22383
|
-
return version21Migration(json);
|
|
22953
|
+
if (Number(mainVersion) < 3) {
|
|
22954
|
+
return version30Migration(version21Migration(json));
|
|
22384
22955
|
}
|
|
22385
22956
|
return json;
|
|
22386
22957
|
}
|
|
@@ -22704,7 +23275,7 @@ function version3Migration(scene) {
|
|
|
22704
23275
|
try {
|
|
22705
23276
|
for (var _j = __values$1(ecScene.items), _k = _j.next(); !_k.done; _k = _j.next()) {
|
|
22706
23277
|
var item = _k.value;
|
|
22707
|
-
itemGuidMap[item.id] = generateGUID();
|
|
23278
|
+
itemGuidMap[item.id] = generateGUID$1();
|
|
22708
23279
|
// TODO: 编辑器测试用,上线后删除
|
|
22709
23280
|
//@ts-expect-error
|
|
22710
23281
|
item.oldId = item.id;
|
|
@@ -22760,8 +23331,8 @@ function version3Migration(scene) {
|
|
|
22760
23331
|
// texture 增加 id 和 dataType
|
|
22761
23332
|
for (var _q = __values$1(scene.textureOptions), _r = _q.next(); !_r.done; _r = _q.next()) {
|
|
22762
23333
|
var texture = _r.value;
|
|
22763
|
-
texture.id = generateGUID();
|
|
22764
|
-
texture.dataType = DataType.Texture;
|
|
23334
|
+
texture.id = generateGUID$1();
|
|
23335
|
+
texture.dataType = DataType$1.Texture;
|
|
22765
23336
|
}
|
|
22766
23337
|
}
|
|
22767
23338
|
catch (e_5_1) { e_5 = { error: e_5_1 }; }
|
|
@@ -22780,23 +23351,15 @@ function version3Migration(scene) {
|
|
|
22780
23351
|
var item = _t.value;
|
|
22781
23352
|
// 原 texture 索引转为统一 guid 索引
|
|
22782
23353
|
if (item.content) {
|
|
22783
|
-
//@ts-expect-error
|
|
22784
23354
|
if (item.content.renderer) {
|
|
22785
|
-
//@ts-expect-error
|
|
22786
23355
|
if (item.content.renderer.texture !== undefined) {
|
|
22787
|
-
//@ts-expect-error
|
|
22788
23356
|
var oldTextureId = item.content.renderer.texture;
|
|
22789
|
-
//@ts-expect-error
|
|
22790
23357
|
item.content.renderer.texture = { id: scene.textureOptions[oldTextureId].id };
|
|
22791
23358
|
}
|
|
22792
23359
|
}
|
|
22793
|
-
//@ts-expect-error
|
|
22794
23360
|
if (item.content.trails) {
|
|
22795
|
-
//@ts-expect-error
|
|
22796
23361
|
if (item.content.trails.texture !== undefined) {
|
|
22797
|
-
//@ts-expect-error
|
|
22798
23362
|
var oldTextureId = item.content.trails.texture;
|
|
22799
|
-
//@ts-expect-error
|
|
22800
23363
|
item.content.trails.texture = { id: scene.textureOptions[oldTextureId].id };
|
|
22801
23364
|
}
|
|
22802
23365
|
}
|
|
@@ -22807,12 +23370,14 @@ function version3Migration(scene) {
|
|
|
22807
23370
|
var rotation = item.transform.rotation;
|
|
22808
23371
|
var scale = item.transform.scale;
|
|
22809
23372
|
if (!position) {
|
|
23373
|
+
//@ts-expect-error
|
|
22810
23374
|
position = [0, 0, 0];
|
|
22811
23375
|
}
|
|
22812
23376
|
if (!rotation) {
|
|
22813
23377
|
rotation = [0, 0, 0];
|
|
22814
23378
|
}
|
|
22815
23379
|
if (!scale) {
|
|
23380
|
+
//@ts-expect-error
|
|
22816
23381
|
scale = [1, 1, 1];
|
|
22817
23382
|
}
|
|
22818
23383
|
item.transform = {
|
|
@@ -22833,12 +23398,9 @@ function version3Migration(scene) {
|
|
|
22833
23398
|
// sprite 的 anchor 修正
|
|
22834
23399
|
if (item.type === ItemType$1.sprite) {
|
|
22835
23400
|
var content = item.content;
|
|
22836
|
-
//@ts-expect-error
|
|
22837
23401
|
if (!content.renderer) {
|
|
22838
|
-
//@ts-expect-error
|
|
22839
23402
|
content.renderer = {};
|
|
22840
23403
|
}
|
|
22841
|
-
//@ts-expect-error
|
|
22842
23404
|
var renderer = content.renderer;
|
|
22843
23405
|
var realAnchor = convertAnchor(renderer.anchor, renderer.particleOrigin);
|
|
22844
23406
|
//@ts-expect-error
|
|
@@ -22856,14 +23418,10 @@ function version3Migration(scene) {
|
|
|
22856
23418
|
}
|
|
22857
23419
|
if (item.type === ItemType$1.particle) {
|
|
22858
23420
|
var content = item.content;
|
|
22859
|
-
//@ts-expect-error
|
|
22860
23421
|
if (!content.renderer) {
|
|
22861
|
-
//@ts-expect-error
|
|
22862
23422
|
content.renderer = {};
|
|
22863
23423
|
}
|
|
22864
|
-
//@ts-expect-error
|
|
22865
23424
|
var renderer = content.renderer;
|
|
22866
|
-
//@ts-expect-error
|
|
22867
23425
|
content.renderer.anchor = convertAnchor(renderer.anchor, renderer.particleOrigin);
|
|
22868
23426
|
}
|
|
22869
23427
|
// item 的 endbehaviour 兼容
|
|
@@ -22872,9 +23430,7 @@ function version3Migration(scene) {
|
|
|
22872
23430
|
item.endBehavior = END_BEHAVIOR_FREEZE$1;
|
|
22873
23431
|
}
|
|
22874
23432
|
// 动画数据转化 TODO: 动画数据移到 TimelineComponentData
|
|
22875
|
-
//@ts-expect-error
|
|
22876
23433
|
item.content.tracks = [];
|
|
22877
|
-
//@ts-expect-error
|
|
22878
23434
|
var tracks = item.content.tracks;
|
|
22879
23435
|
if (item.type !== ItemType$1.particle) {
|
|
22880
23436
|
tracks.push({
|
|
@@ -22882,11 +23438,8 @@ function version3Migration(scene) {
|
|
|
22882
23438
|
{
|
|
22883
23439
|
dataType: 'TransformAnimationPlayableAsset',
|
|
22884
23440
|
animationClip: {
|
|
22885
|
-
//@ts-expect-error
|
|
22886
23441
|
sizeOverLifetime: item.content.sizeOverLifetime,
|
|
22887
|
-
//@ts-expect-error
|
|
22888
23442
|
rotationOverLifetime: item.content.rotationOverLifetime,
|
|
22889
|
-
//@ts-expect-error
|
|
22890
23443
|
positionOverLifetime: item.content.positionOverLifetime,
|
|
22891
23444
|
},
|
|
22892
23445
|
},
|
|
@@ -22899,9 +23452,7 @@ function version3Migration(scene) {
|
|
|
22899
23452
|
{
|
|
22900
23453
|
dataType: 'SpriteColorAnimationPlayableAsset',
|
|
22901
23454
|
animationClip: {
|
|
22902
|
-
//@ts-expect-error
|
|
22903
23455
|
colorOverLifetime: item.content.colorOverLifetime,
|
|
22904
|
-
//@ts-expect-error
|
|
22905
23456
|
startColor: item.content.options.startColor,
|
|
22906
23457
|
},
|
|
22907
23458
|
},
|
|
@@ -22909,170 +23460,108 @@ function version3Migration(scene) {
|
|
|
22909
23460
|
});
|
|
22910
23461
|
}
|
|
22911
23462
|
// gizmo 的 target id 转换为新的 item guid
|
|
22912
|
-
|
|
22913
|
-
if (item.content.options.target) {
|
|
22914
|
-
//@ts-expect-error
|
|
23463
|
+
if (item.content && item.content.options && item.content.options.target) {
|
|
22915
23464
|
item.content.options.target = itemGuidMap[item.content.options.target];
|
|
22916
23465
|
}
|
|
22917
23466
|
// item 的 content 转为 component data 加入 JSONScene.components
|
|
22918
|
-
var uuid = v4().replace(/-/g, '');
|
|
23467
|
+
var uuid = v4$1().replace(/-/g, '');
|
|
22919
23468
|
if (item.type === ItemType$1.sprite) {
|
|
22920
|
-
//@ts-expect-error
|
|
22921
23469
|
item.components = [];
|
|
22922
|
-
//@ts-expect-error
|
|
22923
23470
|
components.push(item.content);
|
|
22924
|
-
//@ts-expect-error
|
|
22925
23471
|
item.content.id = uuid;
|
|
22926
|
-
|
|
22927
|
-
item.content.dataType = DataType.SpriteComponent;
|
|
22928
|
-
//@ts-expect-error
|
|
23472
|
+
item.content.dataType = DataType$1.SpriteComponent;
|
|
22929
23473
|
item.content.item = { id: item.id };
|
|
22930
|
-
|
|
22931
|
-
item.dataType = DataType.VFXItemData;
|
|
23474
|
+
item.dataType = DataType$1.VFXItemData;
|
|
22932
23475
|
//@ts-expect-error
|
|
22933
23476
|
item.components.push({ id: item.content.id });
|
|
22934
23477
|
}
|
|
22935
23478
|
else if (item.type === ItemType$1.particle) {
|
|
22936
|
-
//@ts-expect-error
|
|
22937
23479
|
item.components = [];
|
|
22938
|
-
//@ts-expect-error
|
|
22939
23480
|
components.push(item.content);
|
|
22940
|
-
//@ts-expect-error
|
|
22941
23481
|
item.content.id = uuid;
|
|
22942
|
-
|
|
22943
|
-
item.content.dataType = DataType.ParticleSystem;
|
|
22944
|
-
//@ts-expect-error
|
|
23482
|
+
item.content.dataType = DataType$1.ParticleSystem;
|
|
22945
23483
|
item.content.item = { id: item.id };
|
|
22946
|
-
|
|
22947
|
-
item.dataType = DataType.VFXItemData;
|
|
23484
|
+
item.dataType = DataType$1.VFXItemData;
|
|
22948
23485
|
//@ts-expect-error
|
|
22949
23486
|
item.components.push({ id: item.content.id });
|
|
22950
23487
|
}
|
|
22951
23488
|
else if (item.type === ItemType$1.mesh) {
|
|
22952
|
-
//@ts-expect-error
|
|
22953
23489
|
item.components = [];
|
|
22954
|
-
//@ts-expect-error
|
|
22955
23490
|
components.push(item.content);
|
|
22956
|
-
//@ts-expect-error
|
|
22957
23491
|
item.content.id = uuid;
|
|
22958
|
-
|
|
22959
|
-
item.content.dataType = DataType.MeshComponent;
|
|
22960
|
-
//@ts-expect-error
|
|
23492
|
+
item.content.dataType = DataType$1.MeshComponent;
|
|
22961
23493
|
item.content.item = { id: item.id };
|
|
22962
|
-
|
|
22963
|
-
item.dataType = DataType.VFXItemData;
|
|
23494
|
+
item.dataType = DataType$1.VFXItemData;
|
|
22964
23495
|
//@ts-expect-error
|
|
22965
23496
|
item.components.push({ id: item.content.id });
|
|
22966
23497
|
}
|
|
22967
23498
|
else if (item.type === ItemType$1.skybox) {
|
|
22968
|
-
//@ts-expect-error
|
|
22969
23499
|
item.components = [];
|
|
22970
|
-
//@ts-expect-error
|
|
22971
23500
|
components.push(item.content);
|
|
22972
|
-
//@ts-expect-error
|
|
22973
23501
|
item.content.id = uuid;
|
|
22974
|
-
|
|
22975
|
-
item.content.dataType = DataType.SkyboxComponent;
|
|
22976
|
-
//@ts-expect-error
|
|
23502
|
+
item.content.dataType = DataType$1.SkyboxComponent;
|
|
22977
23503
|
item.content.item = { id: item.id };
|
|
22978
|
-
|
|
22979
|
-
item.dataType = DataType.VFXItemData;
|
|
23504
|
+
item.dataType = DataType$1.VFXItemData;
|
|
22980
23505
|
//@ts-expect-error
|
|
22981
23506
|
item.components.push({ id: item.content.id });
|
|
22982
23507
|
}
|
|
22983
23508
|
else if (item.type === ItemType$1.light) {
|
|
22984
|
-
//@ts-expect-error
|
|
22985
23509
|
item.components = [];
|
|
22986
|
-
//@ts-expect-error
|
|
22987
23510
|
components.push(item.content);
|
|
22988
|
-
//@ts-expect-error
|
|
22989
23511
|
item.content.id = uuid;
|
|
22990
|
-
|
|
22991
|
-
item.content.dataType = DataType.LightComponent;
|
|
22992
|
-
//@ts-expect-error
|
|
23512
|
+
item.content.dataType = DataType$1.LightComponent;
|
|
22993
23513
|
item.content.item = { id: item.id };
|
|
22994
|
-
|
|
22995
|
-
item.dataType = DataType.VFXItemData;
|
|
23514
|
+
item.dataType = DataType$1.VFXItemData;
|
|
22996
23515
|
//@ts-expect-error
|
|
22997
23516
|
item.components.push({ id: item.content.id });
|
|
22998
23517
|
}
|
|
22999
23518
|
else if (item.type === 'camera') {
|
|
23000
|
-
//@ts-expect-error
|
|
23001
23519
|
item.components = [];
|
|
23002
|
-
//@ts-expect-error
|
|
23003
23520
|
components.push(item.content);
|
|
23004
|
-
//@ts-expect-error
|
|
23005
23521
|
item.content.id = uuid;
|
|
23006
|
-
|
|
23007
|
-
item.content.dataType = DataType.CameraComponent;
|
|
23008
|
-
//@ts-expect-error
|
|
23522
|
+
item.content.dataType = DataType$1.CameraComponent;
|
|
23009
23523
|
item.content.item = { id: item.id };
|
|
23010
|
-
|
|
23011
|
-
item.dataType = DataType.VFXItemData;
|
|
23524
|
+
item.dataType = DataType$1.VFXItemData;
|
|
23012
23525
|
//@ts-expect-error
|
|
23013
23526
|
item.components.push({ id: item.content.id });
|
|
23014
23527
|
}
|
|
23015
23528
|
else if (item.type === ItemType$1.tree) {
|
|
23016
|
-
//@ts-expect-error
|
|
23017
23529
|
item.components = [];
|
|
23018
|
-
//@ts-expect-error
|
|
23019
23530
|
components.push(item.content);
|
|
23020
|
-
//@ts-expect-error
|
|
23021
23531
|
item.content.id = uuid;
|
|
23022
|
-
|
|
23023
|
-
item.content.dataType = DataType.TreeComponent;
|
|
23024
|
-
//@ts-expect-error
|
|
23532
|
+
item.content.dataType = DataType$1.TreeComponent;
|
|
23025
23533
|
item.content.item = { id: item.id };
|
|
23026
|
-
|
|
23027
|
-
item.dataType = DataType.VFXItemData;
|
|
23534
|
+
item.dataType = DataType$1.VFXItemData;
|
|
23028
23535
|
//@ts-expect-error
|
|
23029
23536
|
item.components.push({ id: item.content.id });
|
|
23030
23537
|
}
|
|
23031
23538
|
else if (item.type === ItemType$1.interact) {
|
|
23032
|
-
//@ts-expect-error
|
|
23033
23539
|
item.components = [];
|
|
23034
|
-
//@ts-expect-error
|
|
23035
23540
|
components.push(item.content);
|
|
23036
|
-
//@ts-expect-error
|
|
23037
23541
|
item.content.id = uuid;
|
|
23038
|
-
|
|
23039
|
-
item.content.dataType = DataType.InteractComponent;
|
|
23040
|
-
//@ts-expect-error
|
|
23542
|
+
item.content.dataType = DataType$1.InteractComponent;
|
|
23041
23543
|
item.content.item = { id: item.id };
|
|
23042
|
-
|
|
23043
|
-
item.dataType = DataType.VFXItemData;
|
|
23544
|
+
item.dataType = DataType$1.VFXItemData;
|
|
23044
23545
|
//@ts-expect-error
|
|
23045
23546
|
item.components.push({ id: item.content.id });
|
|
23046
23547
|
}
|
|
23047
23548
|
else if (item.type === ItemType$1.camera) {
|
|
23048
|
-
//@ts-expect-error
|
|
23049
23549
|
item.components = [];
|
|
23050
|
-
//@ts-expect-error
|
|
23051
23550
|
components.push(item.content);
|
|
23052
|
-
//@ts-expect-error
|
|
23053
23551
|
item.content.id = uuid;
|
|
23054
|
-
|
|
23055
|
-
item.content.dataType = DataType.CameraController;
|
|
23056
|
-
//@ts-expect-error
|
|
23552
|
+
item.content.dataType = DataType$1.CameraController;
|
|
23057
23553
|
item.content.item = { id: item.id };
|
|
23058
|
-
|
|
23059
|
-
item.dataType = DataType.VFXItemData;
|
|
23554
|
+
item.dataType = DataType$1.VFXItemData;
|
|
23060
23555
|
//@ts-expect-error
|
|
23061
23556
|
item.components.push({ id: item.content.id });
|
|
23062
23557
|
}
|
|
23063
23558
|
else if (item.type === ItemType$1.text) {
|
|
23064
|
-
//@ts-expect-error
|
|
23065
23559
|
item.components = [];
|
|
23066
|
-
//@ts-expect-error
|
|
23067
23560
|
components.push(item.content);
|
|
23068
|
-
//@ts-expect-error
|
|
23069
23561
|
item.content.id = uuid;
|
|
23070
|
-
|
|
23071
|
-
item.content.dataType = DataType.TextComponent;
|
|
23072
|
-
//@ts-expect-error
|
|
23562
|
+
item.content.dataType = DataType$1.TextComponent;
|
|
23073
23563
|
item.content.item = { id: item.id };
|
|
23074
|
-
|
|
23075
|
-
item.dataType = DataType.VFXItemData;
|
|
23564
|
+
item.dataType = DataType$1.VFXItemData;
|
|
23076
23565
|
//@ts-expect-error
|
|
23077
23566
|
item.components.push({ id: item.content.id });
|
|
23078
23567
|
}
|
|
@@ -23095,7 +23584,7 @@ function convertAnchor(anchor, particleOrigin) {
|
|
|
23095
23584
|
return [anchor[0] - 0.5, 0.5 - anchor[1]];
|
|
23096
23585
|
}
|
|
23097
23586
|
else if (particleOrigin) {
|
|
23098
|
-
return particleOriginTranslateMap[particleOrigin];
|
|
23587
|
+
return particleOriginTranslateMap$1[particleOrigin];
|
|
23099
23588
|
}
|
|
23100
23589
|
else {
|
|
23101
23590
|
return [0, 0];
|
|
@@ -23373,16 +23862,17 @@ var AssetManager = /** @class */ (function () {
|
|
|
23373
23862
|
};
|
|
23374
23863
|
AssetManager.prototype.processBins = function (bins) {
|
|
23375
23864
|
return __awaiter(this, void 0, void 0, function () {
|
|
23376
|
-
var renderLevel, jobs;
|
|
23865
|
+
var renderLevel, baseUrl, jobs;
|
|
23377
23866
|
var _this = this;
|
|
23378
23867
|
return __generator(this, function (_a) {
|
|
23379
23868
|
renderLevel = this.options.renderLevel;
|
|
23869
|
+
baseUrl = this.baseUrl;
|
|
23380
23870
|
jobs = bins.map(function (bin) {
|
|
23381
23871
|
if (bin instanceof ArrayBuffer) {
|
|
23382
23872
|
return bin;
|
|
23383
23873
|
}
|
|
23384
23874
|
if (passRenderLevel(bin.renderLevel, renderLevel)) {
|
|
23385
|
-
return _this.loadBins(bin.url);
|
|
23875
|
+
return _this.loadBins(new URL(bin.url, baseUrl).href);
|
|
23386
23876
|
}
|
|
23387
23877
|
throw new Error("Invalid bins source: ".concat(JSON.stringify(bins)));
|
|
23388
23878
|
});
|
|
@@ -23400,13 +23890,14 @@ var AssetManager = /** @class */ (function () {
|
|
|
23400
23890
|
return [2 /*return*/];
|
|
23401
23891
|
}
|
|
23402
23892
|
jobs = fonts.map(function (font) { return __awaiter(_this, void 0, void 0, function () {
|
|
23403
|
-
var fontFace;
|
|
23893
|
+
var url, fontFace;
|
|
23404
23894
|
var _a;
|
|
23405
23895
|
return __generator(this, function (_b) {
|
|
23406
23896
|
switch (_b.label) {
|
|
23407
23897
|
case 0:
|
|
23408
23898
|
if (!(font.fontURL && !AssetManager.fonts.has(font.fontFamily))) return [3 /*break*/, 4];
|
|
23409
|
-
|
|
23899
|
+
url = new URL(font.fontURL, this.baseUrl).href;
|
|
23900
|
+
fontFace = new FontFace((_a = font.fontFamily) !== null && _a !== void 0 ? _a : '', 'url(' + url + ')');
|
|
23410
23901
|
_b.label = 1;
|
|
23411
23902
|
case 1:
|
|
23412
23903
|
_b.trys.push([1, 3, , 4]);
|
|
@@ -23419,7 +23910,7 @@ var AssetManager = /** @class */ (function () {
|
|
|
23419
23910
|
return [3 /*break*/, 4];
|
|
23420
23911
|
case 3:
|
|
23421
23912
|
_b.sent();
|
|
23422
|
-
logger.warn("Invalid fonts source: ".concat(JSON.stringify(
|
|
23913
|
+
logger.warn("Invalid fonts source: ".concat(JSON.stringify(url)));
|
|
23423
23914
|
return [3 /*break*/, 4];
|
|
23424
23915
|
case 4: return [2 /*return*/];
|
|
23425
23916
|
}
|
|
@@ -23668,7 +24159,7 @@ function createTextureOptionsBySource(image, sourceFrom) {
|
|
|
23668
24159
|
return image.source;
|
|
23669
24160
|
}
|
|
23670
24161
|
else if (image instanceof HTMLImageElement ||
|
|
23671
|
-
image
|
|
24162
|
+
isCanvas(image)) {
|
|
23672
24163
|
return {
|
|
23673
24164
|
image: image,
|
|
23674
24165
|
sourceType: TextureSourceType.image,
|
|
@@ -23730,6 +24221,11 @@ function base64ToFile(base64, filename, contentType) {
|
|
|
23730
24221
|
var file = new File([blob], filename, { type: contentType });
|
|
23731
24222
|
return file;
|
|
23732
24223
|
}
|
|
24224
|
+
function isCanvas(cavnas) {
|
|
24225
|
+
var _a;
|
|
24226
|
+
// 小程序 Canvas 无法使用 instanceof HTMLCanvasElement 判断
|
|
24227
|
+
return typeof cavnas === 'object' && cavnas !== null && ((_a = cavnas.tagName) === null || _a === void 0 ? void 0 : _a.toUpperCase()) === 'CANVAS';
|
|
24228
|
+
}
|
|
23733
24229
|
|
|
23734
24230
|
var tmpScale = new Vector3(1, 1, 1);
|
|
23735
24231
|
/**
|
|
@@ -23949,8 +24445,9 @@ var Camera = /** @class */ (function () {
|
|
|
23949
24445
|
Camera.prototype.getInverseVPRatio = function (z) {
|
|
23950
24446
|
var pos = new Vector3(0, 0, z);
|
|
23951
24447
|
var mat = this.getViewProjectionMatrix();
|
|
23952
|
-
var
|
|
23953
|
-
|
|
24448
|
+
var inverseVP = this.getInverseViewProjectionMatrix();
|
|
24449
|
+
var nz = mat.projectPoint(pos).z;
|
|
24450
|
+
return inverseVP.projectPoint(new Vector3(1, 1, nz));
|
|
23954
24451
|
};
|
|
23955
24452
|
/**
|
|
23956
24453
|
* 设置相机的旋转四元数
|
|
@@ -23962,7 +24459,6 @@ var Camera = /** @class */ (function () {
|
|
|
23962
24459
|
this.dirty = true;
|
|
23963
24460
|
}
|
|
23964
24461
|
else {
|
|
23965
|
-
this.options.quat;
|
|
23966
24462
|
if (!this.options.quat.equals(value)) {
|
|
23967
24463
|
this.options.quat.copyFrom(value);
|
|
23968
24464
|
this.dirty = true;
|
|
@@ -24130,8 +24626,7 @@ var CompositionComponent = /** @class */ (function (_super) {
|
|
|
24130
24626
|
}
|
|
24131
24627
|
item.getComponent(CompositionComponent).createContent();
|
|
24132
24628
|
}
|
|
24133
|
-
else if (itemData.type ===
|
|
24134
|
-
itemData.type === ItemType$1.sprite ||
|
|
24629
|
+
else if (itemData.type === ItemType$1.sprite ||
|
|
24135
24630
|
itemData.type === ItemType$1.text ||
|
|
24136
24631
|
itemData.type === ItemType$1.particle ||
|
|
24137
24632
|
itemData.type === ItemType$1.mesh ||
|
|
@@ -24149,20 +24644,7 @@ var CompositionComponent = /** @class */ (function (_super) {
|
|
|
24149
24644
|
item = new VFXItem(this.engine, itemData);
|
|
24150
24645
|
item.composition = this.item.composition;
|
|
24151
24646
|
// 兼容老的数据代码,json 更新后可移除
|
|
24152
|
-
|
|
24153
|
-
case ItemType$1.text: {
|
|
24154
|
-
// 添加文本组件
|
|
24155
|
-
var textItem = new TextComponent(this.engine, itemData.content);
|
|
24156
|
-
textItem.item = item;
|
|
24157
|
-
item.components.push(textItem);
|
|
24158
|
-
item.rendererComponents.push(textItem);
|
|
24159
|
-
item._content = textItem;
|
|
24160
|
-
break;
|
|
24161
|
-
}
|
|
24162
|
-
default: {
|
|
24163
|
-
item = createVFXItem(itemData, this.item.composition);
|
|
24164
|
-
}
|
|
24165
|
-
}
|
|
24647
|
+
item = createVFXItem(itemData, this.item.composition);
|
|
24166
24648
|
}
|
|
24167
24649
|
item.parent = this.item;
|
|
24168
24650
|
// 相机不跟随合成移动
|
|
@@ -25552,10 +26034,8 @@ var Engine = /** @class */ (function () {
|
|
|
25552
26034
|
Engine.prototype.addPackageDatas = function (scene) {
|
|
25553
26035
|
var e_1, _a, e_2, _b, e_3, _c, e_4, _d, e_5, _e, e_6, _f;
|
|
25554
26036
|
var jsonScene = scene.jsonScene;
|
|
25555
|
-
//@ts-expect-error
|
|
25556
26037
|
if (jsonScene.items) {
|
|
25557
26038
|
try {
|
|
25558
|
-
//@ts-expect-error
|
|
25559
26039
|
for (var _g = __values$1(jsonScene.items), _h = _g.next(); !_h.done; _h = _g.next()) {
|
|
25560
26040
|
var vfxItemData = _h.value;
|
|
25561
26041
|
this.addEffectsObjectData(vfxItemData);
|
|
@@ -25569,10 +26049,8 @@ var Engine = /** @class */ (function () {
|
|
|
25569
26049
|
finally { if (e_1) throw e_1.error; }
|
|
25570
26050
|
}
|
|
25571
26051
|
}
|
|
25572
|
-
//@ts-expect-error
|
|
25573
26052
|
if (jsonScene.materials) {
|
|
25574
26053
|
try {
|
|
25575
|
-
//@ts-expect-error
|
|
25576
26054
|
for (var _j = __values$1(jsonScene.materials), _k = _j.next(); !_k.done; _k = _j.next()) {
|
|
25577
26055
|
var materialData = _k.value;
|
|
25578
26056
|
this.addEffectsObjectData(materialData);
|
|
@@ -25586,10 +26064,8 @@ var Engine = /** @class */ (function () {
|
|
|
25586
26064
|
finally { if (e_2) throw e_2.error; }
|
|
25587
26065
|
}
|
|
25588
26066
|
}
|
|
25589
|
-
//@ts-expect-error
|
|
25590
26067
|
if (jsonScene.shaders) {
|
|
25591
26068
|
try {
|
|
25592
|
-
//@ts-expect-error
|
|
25593
26069
|
for (var _l = __values$1(jsonScene.shaders), _m = _l.next(); !_m.done; _m = _l.next()) {
|
|
25594
26070
|
var shaderData = _m.value;
|
|
25595
26071
|
this.addEffectsObjectData(shaderData);
|
|
@@ -25603,10 +26079,8 @@ var Engine = /** @class */ (function () {
|
|
|
25603
26079
|
finally { if (e_3) throw e_3.error; }
|
|
25604
26080
|
}
|
|
25605
26081
|
}
|
|
25606
|
-
//@ts-expect-error
|
|
25607
26082
|
if (jsonScene.geometries) {
|
|
25608
26083
|
try {
|
|
25609
|
-
//@ts-expect-error
|
|
25610
26084
|
for (var _o = __values$1(jsonScene.geometries), _p = _o.next(); !_p.done; _p = _o.next()) {
|
|
25611
26085
|
var geometryData = _p.value;
|
|
25612
26086
|
this.addEffectsObjectData(geometryData);
|
|
@@ -25620,10 +26094,8 @@ var Engine = /** @class */ (function () {
|
|
|
25620
26094
|
finally { if (e_4) throw e_4.error; }
|
|
25621
26095
|
}
|
|
25622
26096
|
}
|
|
25623
|
-
//@ts-expect-error
|
|
25624
26097
|
if (jsonScene.components) {
|
|
25625
26098
|
try {
|
|
25626
|
-
//@ts-expect-error
|
|
25627
26099
|
for (var _q = __values$1(jsonScene.components), _r = _q.next(); !_r.done; _r = _q.next()) {
|
|
25628
26100
|
var componentData = _r.value;
|
|
25629
26101
|
this.addEffectsObjectData(componentData);
|
|
@@ -26588,7 +27060,7 @@ var GLRendererInternal = /** @class */ (function () {
|
|
|
26588
27060
|
}
|
|
26589
27061
|
var glGeometry = geometry;
|
|
26590
27062
|
var glMaterial = material;
|
|
26591
|
-
var program = glMaterial.
|
|
27063
|
+
var program = glMaterial.shaderVariant.program;
|
|
26592
27064
|
if (!program) {
|
|
26593
27065
|
console.warn('Material ' + glMaterial.name + ' 的shader着色器程序未初始化。');
|
|
26594
27066
|
return;
|
|
@@ -27458,8 +27930,8 @@ var GLMaterialState = /** @class */ (function () {
|
|
|
27458
27930
|
var Vector4 = Vector4$1, Matrix4 = Matrix4$1;
|
|
27459
27931
|
var GLMaterial = /** @class */ (function (_super) {
|
|
27460
27932
|
__extends(GLMaterial, _super);
|
|
27461
|
-
function GLMaterial() {
|
|
27462
|
-
var _this = _super
|
|
27933
|
+
function GLMaterial(engine, props) {
|
|
27934
|
+
var _this = _super.call(this, engine, props) || this;
|
|
27463
27935
|
// material存放的uniform数据。
|
|
27464
27936
|
_this.floats = {};
|
|
27465
27937
|
_this.ints = {};
|
|
@@ -27477,7 +27949,13 @@ var GLMaterial = /** @class */ (function (_super) {
|
|
|
27477
27949
|
_this.samplers = []; // material存放的sampler名称。
|
|
27478
27950
|
_this.uniforms = []; // material存放的uniform名称(不包括sampler)。
|
|
27479
27951
|
_this.uniformDirtyFlag = true;
|
|
27952
|
+
_this.macrosDirtyFlag = true;
|
|
27953
|
+
_this.macros = {};
|
|
27480
27954
|
_this.glMaterialState = new GLMaterialState();
|
|
27955
|
+
if (props) {
|
|
27956
|
+
_this.shader = new Shader(engine);
|
|
27957
|
+
_this.shader.shaderData = __assign$1(__assign$1({}, props.shader), { id: generateGUID$1(), dataType: DataType$1.Shader });
|
|
27958
|
+
}
|
|
27481
27959
|
return _this;
|
|
27482
27960
|
}
|
|
27483
27961
|
Object.defineProperty(GLMaterial.prototype, "blending", {
|
|
@@ -27700,14 +28178,20 @@ var GLMaterial = /** @class */ (function (_super) {
|
|
|
27700
28178
|
enumerable: false,
|
|
27701
28179
|
configurable: true
|
|
27702
28180
|
});
|
|
27703
|
-
GLMaterial.prototype.
|
|
27704
|
-
|
|
28181
|
+
GLMaterial.prototype.enableMacro = function (keyword) {
|
|
28182
|
+
if (!this.isMacroEnabled(keyword)) {
|
|
28183
|
+
this.macros[keyword] = true;
|
|
28184
|
+
this.macrosDirtyFlag = true;
|
|
28185
|
+
}
|
|
27705
28186
|
};
|
|
27706
|
-
GLMaterial.prototype.
|
|
27707
|
-
|
|
28187
|
+
GLMaterial.prototype.disableMacro = function (keyword) {
|
|
28188
|
+
if (this.isMacroEnabled(keyword)) {
|
|
28189
|
+
delete this.macros[keyword];
|
|
28190
|
+
this.macrosDirtyFlag = true;
|
|
28191
|
+
}
|
|
27708
28192
|
};
|
|
27709
|
-
GLMaterial.prototype.
|
|
27710
|
-
|
|
28193
|
+
GLMaterial.prototype.isMacroEnabled = function (keyword) {
|
|
28194
|
+
return this.macros[keyword] !== undefined;
|
|
27711
28195
|
};
|
|
27712
28196
|
// TODO 待废弃 兼容 model/spine 插件 改造后可移除
|
|
27713
28197
|
GLMaterial.prototype.createMaterialStates = function (states) {
|
|
@@ -27738,11 +28222,11 @@ var GLMaterial = /** @class */ (function (_super) {
|
|
|
27738
28222
|
}
|
|
27739
28223
|
var glEngine = this.engine;
|
|
27740
28224
|
glEngine.addMaterial(this);
|
|
27741
|
-
if (!this.shader) {
|
|
27742
|
-
|
|
27743
|
-
this.
|
|
28225
|
+
if (!this.shaderVariant || this.shaderVariant.shader !== this.shader || this.macrosDirtyFlag) {
|
|
28226
|
+
this.shaderVariant = this.shader.createVariant(this.macros);
|
|
28227
|
+
this.macrosDirtyFlag = false;
|
|
27744
28228
|
}
|
|
27745
|
-
this.
|
|
28229
|
+
this.shaderVariant.initialize(glEngine);
|
|
27746
28230
|
Object.keys(this.textures).forEach(function (key) {
|
|
27747
28231
|
var texture = _this.textures[key];
|
|
27748
28232
|
if (!isFunction(texture.initialize)) {
|
|
@@ -27760,7 +28244,7 @@ var GLMaterial = /** @class */ (function (_super) {
|
|
|
27760
28244
|
var e_1, _a, e_2, _b;
|
|
27761
28245
|
var engine = renderer.engine;
|
|
27762
28246
|
var pipelineContext = engine.getGLPipelineContext();
|
|
27763
|
-
this.
|
|
28247
|
+
this.shaderVariant.program.bind();
|
|
27764
28248
|
this.setupStates(pipelineContext);
|
|
27765
28249
|
var name;
|
|
27766
28250
|
if (globalUniforms) {
|
|
@@ -27797,19 +28281,19 @@ var GLMaterial = /** @class */ (function (_super) {
|
|
|
27797
28281
|
}
|
|
27798
28282
|
// 更新 cached uniform location
|
|
27799
28283
|
if (this.uniformDirtyFlag) {
|
|
27800
|
-
this.
|
|
28284
|
+
this.shaderVariant.fillShaderInformation(this.uniforms, this.samplers);
|
|
27801
28285
|
this.uniformDirtyFlag = false;
|
|
27802
28286
|
}
|
|
27803
28287
|
if (globalUniforms) {
|
|
27804
28288
|
// 设置全局 uniform
|
|
27805
28289
|
for (name in globalUniforms.floats) {
|
|
27806
|
-
this.
|
|
28290
|
+
this.shaderVariant.setFloat(name, globalUniforms.floats[name]);
|
|
27807
28291
|
}
|
|
27808
28292
|
for (name in globalUniforms.ints) {
|
|
27809
|
-
this.
|
|
28293
|
+
this.shaderVariant.setInt(name, globalUniforms.ints[name]);
|
|
27810
28294
|
}
|
|
27811
28295
|
for (name in globalUniforms.matrices) {
|
|
27812
|
-
this.
|
|
28296
|
+
this.shaderVariant.setMatrix(name, globalUniforms.matrices[name]);
|
|
27813
28297
|
}
|
|
27814
28298
|
}
|
|
27815
28299
|
// 检查贴图数据是否初始化。
|
|
@@ -27819,43 +28303,43 @@ var GLMaterial = /** @class */ (function (_super) {
|
|
|
27819
28303
|
}
|
|
27820
28304
|
}
|
|
27821
28305
|
for (name in this.floats) {
|
|
27822
|
-
this.
|
|
28306
|
+
this.shaderVariant.setFloat(name, this.floats[name]);
|
|
27823
28307
|
}
|
|
27824
28308
|
for (name in this.ints) {
|
|
27825
|
-
this.
|
|
28309
|
+
this.shaderVariant.setInt(name, this.ints[name]);
|
|
27826
28310
|
}
|
|
27827
28311
|
for (name in this.floatArrays) {
|
|
27828
|
-
this.
|
|
28312
|
+
this.shaderVariant.setFloats(name, this.floatArrays[name]);
|
|
27829
28313
|
}
|
|
27830
28314
|
for (name in this.textures) {
|
|
27831
|
-
this.
|
|
28315
|
+
this.shaderVariant.setTexture(name, this.textures[name]);
|
|
27832
28316
|
}
|
|
27833
28317
|
for (name in this.vector2s) {
|
|
27834
|
-
this.
|
|
28318
|
+
this.shaderVariant.setVector2(name, this.vector2s[name]);
|
|
27835
28319
|
}
|
|
27836
28320
|
for (name in this.vector3s) {
|
|
27837
|
-
this.
|
|
28321
|
+
this.shaderVariant.setVector3(name, this.vector3s[name]);
|
|
27838
28322
|
}
|
|
27839
28323
|
for (name in this.vector4s) {
|
|
27840
|
-
this.
|
|
28324
|
+
this.shaderVariant.setVector4(name, this.vector4s[name]);
|
|
27841
28325
|
}
|
|
27842
28326
|
for (name in this.colors) {
|
|
27843
|
-
this.
|
|
28327
|
+
this.shaderVariant.setColor(name, this.colors[name]);
|
|
27844
28328
|
}
|
|
27845
28329
|
for (name in this.quaternions) {
|
|
27846
|
-
this.
|
|
28330
|
+
this.shaderVariant.setQuaternion(name, this.quaternions[name]);
|
|
27847
28331
|
}
|
|
27848
28332
|
for (name in this.matrices) {
|
|
27849
|
-
this.
|
|
28333
|
+
this.shaderVariant.setMatrix(name, this.matrices[name]);
|
|
27850
28334
|
}
|
|
27851
28335
|
for (name in this.matrice3s) {
|
|
27852
|
-
this.
|
|
28336
|
+
this.shaderVariant.setMatrix3(name, this.matrice3s[name]);
|
|
27853
28337
|
}
|
|
27854
28338
|
for (name in this.vector4Arrays) {
|
|
27855
|
-
this.
|
|
28339
|
+
this.shaderVariant.setVector4Array(name, this.vector4Arrays[name]);
|
|
27856
28340
|
}
|
|
27857
28341
|
for (name in this.matrixArrays) {
|
|
27858
|
-
this.
|
|
28342
|
+
this.shaderVariant.setMatrixArray(name, this.matrixArrays[name]);
|
|
27859
28343
|
}
|
|
27860
28344
|
};
|
|
27861
28345
|
GLMaterial.prototype.getFloat = function (name) {
|
|
@@ -28019,7 +28503,7 @@ var GLMaterial = /** @class */ (function (_super) {
|
|
|
28019
28503
|
this.ints = {};
|
|
28020
28504
|
this.floatArrays = {};
|
|
28021
28505
|
this.vector4s = {};
|
|
28022
|
-
var propertiesData = __assign$1({
|
|
28506
|
+
var propertiesData = __assign$1({ blending: false, zTest: false, zWrite: false }, data);
|
|
28023
28507
|
this.blending = propertiesData.blending;
|
|
28024
28508
|
this.depthTest = propertiesData.zTest;
|
|
28025
28509
|
this.depthMask = propertiesData.zWrite;
|
|
@@ -28048,7 +28532,7 @@ var GLMaterial = /** @class */ (function (_super) {
|
|
|
28048
28532
|
}
|
|
28049
28533
|
if (data.shader) {
|
|
28050
28534
|
this.shader = data.shader;
|
|
28051
|
-
this.shaderSource = this.shader.
|
|
28535
|
+
this.shaderSource = this.shader.shaderData;
|
|
28052
28536
|
}
|
|
28053
28537
|
this.initialized = false;
|
|
28054
28538
|
};
|
|
@@ -28061,12 +28545,13 @@ var GLMaterial = /** @class */ (function (_super) {
|
|
|
28061
28545
|
//@ts-expect-error
|
|
28062
28546
|
var materialData = this.taggedProperties;
|
|
28063
28547
|
if (this.shader) {
|
|
28548
|
+
//@ts-expect-error
|
|
28064
28549
|
materialData.shader = this.shader;
|
|
28065
28550
|
}
|
|
28066
28551
|
materialData.floats = {};
|
|
28067
28552
|
materialData.ints = {};
|
|
28068
28553
|
materialData.vector4s = {};
|
|
28069
|
-
materialData.dataType = DataType.Material;
|
|
28554
|
+
materialData.dataType = DataType$1.Material;
|
|
28070
28555
|
if (this.blending) {
|
|
28071
28556
|
materialData.blending = this.blending;
|
|
28072
28557
|
}
|
|
@@ -28154,7 +28639,7 @@ var GLMaterial = /** @class */ (function (_super) {
|
|
|
28154
28639
|
if (this.destroyed) {
|
|
28155
28640
|
return;
|
|
28156
28641
|
}
|
|
28157
|
-
(_a = this.
|
|
28642
|
+
(_a = this.shaderVariant) === null || _a === void 0 ? void 0 : _a.dispose();
|
|
28158
28643
|
if ((options === null || options === void 0 ? void 0 : options.textures) !== DestroyOptions.keep) {
|
|
28159
28644
|
Object.keys(this.textures).forEach(function (key) {
|
|
28160
28645
|
var texture = _this.textures[key];
|
|
@@ -28273,8 +28758,8 @@ var ExtWrap = /** @class */ (function () {
|
|
|
28273
28758
|
shader: {
|
|
28274
28759
|
cacheId: copyShaderId,
|
|
28275
28760
|
name: name,
|
|
28276
|
-
vertex:
|
|
28277
|
-
fragment:
|
|
28761
|
+
vertex: vertexShader,
|
|
28762
|
+
fragment: fragmentShader,
|
|
28278
28763
|
glslVersion: level === 2 ? GLSLVersion.GLSL3 : GLSLVersion.GLSL1,
|
|
28279
28764
|
},
|
|
28280
28765
|
});
|
|
@@ -29085,9 +29570,9 @@ var GLProgram = /** @class */ (function () {
|
|
|
29085
29570
|
return GLProgram;
|
|
29086
29571
|
}());
|
|
29087
29572
|
|
|
29088
|
-
var
|
|
29089
|
-
__extends(
|
|
29090
|
-
function
|
|
29573
|
+
var GLShaderVariant = /** @class */ (function (_super) {
|
|
29574
|
+
__extends(GLShaderVariant, _super);
|
|
29575
|
+
function GLShaderVariant(engine, source) {
|
|
29091
29576
|
var _this = _super.call(this, engine, source) || this;
|
|
29092
29577
|
_this.initialized = false;
|
|
29093
29578
|
_this.uniformLocations = {};
|
|
@@ -29095,7 +29580,7 @@ var GLShader = /** @class */ (function (_super) {
|
|
|
29095
29580
|
return _this;
|
|
29096
29581
|
}
|
|
29097
29582
|
// shader 的 GPU 资源初始化方法,在绘制前调用
|
|
29098
|
-
|
|
29583
|
+
GLShaderVariant.prototype.initialize = function (engine) {
|
|
29099
29584
|
if (this.initialized) {
|
|
29100
29585
|
return;
|
|
29101
29586
|
}
|
|
@@ -29104,46 +29589,46 @@ var GLShader = /** @class */ (function (_super) {
|
|
|
29104
29589
|
var pipelineContext = engine.getGLPipelineContext();
|
|
29105
29590
|
pipelineContext.shaderLibrary.compileShader(this);
|
|
29106
29591
|
};
|
|
29107
|
-
|
|
29592
|
+
GLShaderVariant.prototype.setFloat = function (name, value) {
|
|
29108
29593
|
this.pipelineContext.setFloat(this.uniformLocations[name], value);
|
|
29109
29594
|
};
|
|
29110
|
-
|
|
29595
|
+
GLShaderVariant.prototype.setInt = function (name, value) {
|
|
29111
29596
|
this.pipelineContext.setInt(this.uniformLocations[name], value);
|
|
29112
29597
|
};
|
|
29113
|
-
|
|
29598
|
+
GLShaderVariant.prototype.setFloats = function (name, value) {
|
|
29114
29599
|
this.pipelineContext.setFloats(this.uniformLocations[name], value);
|
|
29115
29600
|
};
|
|
29116
|
-
|
|
29601
|
+
GLShaderVariant.prototype.setTexture = function (name, texture) {
|
|
29117
29602
|
this.pipelineContext.setTexture(this.uniformLocations[name], this.samplerChannels[name], texture);
|
|
29118
29603
|
};
|
|
29119
|
-
|
|
29604
|
+
GLShaderVariant.prototype.setVector2 = function (name, value) {
|
|
29120
29605
|
this.pipelineContext.setVector2(this.uniformLocations[name], value);
|
|
29121
29606
|
};
|
|
29122
|
-
|
|
29607
|
+
GLShaderVariant.prototype.setVector3 = function (name, value) {
|
|
29123
29608
|
this.pipelineContext.setVector3(this.uniformLocations[name], value);
|
|
29124
29609
|
};
|
|
29125
|
-
|
|
29610
|
+
GLShaderVariant.prototype.setVector4 = function (name, value) {
|
|
29126
29611
|
this.pipelineContext.setVector4(this.uniformLocations[name], value);
|
|
29127
29612
|
};
|
|
29128
|
-
|
|
29613
|
+
GLShaderVariant.prototype.setColor = function (name, value) {
|
|
29129
29614
|
this.pipelineContext.setColor(this.uniformLocations[name], value);
|
|
29130
29615
|
};
|
|
29131
|
-
|
|
29616
|
+
GLShaderVariant.prototype.setQuaternion = function (name, value) {
|
|
29132
29617
|
this.pipelineContext.setQuaternion(this.uniformLocations[name], value);
|
|
29133
29618
|
};
|
|
29134
|
-
|
|
29619
|
+
GLShaderVariant.prototype.setMatrix = function (name, value) {
|
|
29135
29620
|
this.pipelineContext.setMatrix(this.uniformLocations[name], value);
|
|
29136
29621
|
};
|
|
29137
|
-
|
|
29622
|
+
GLShaderVariant.prototype.setMatrix3 = function (name, value) {
|
|
29138
29623
|
this.pipelineContext.setMatrix3(this.uniformLocations[name], value);
|
|
29139
29624
|
};
|
|
29140
|
-
|
|
29625
|
+
GLShaderVariant.prototype.setVector4Array = function (name, array) {
|
|
29141
29626
|
this.pipelineContext.setVector4Array(this.uniformLocations[name], array);
|
|
29142
29627
|
};
|
|
29143
|
-
|
|
29628
|
+
GLShaderVariant.prototype.setMatrixArray = function (name, array) {
|
|
29144
29629
|
this.pipelineContext.setMatrixArray(this.uniformLocations[name], array);
|
|
29145
29630
|
};
|
|
29146
|
-
|
|
29631
|
+
GLShaderVariant.prototype.fillShaderInformation = function (uniformNames, samplers) {
|
|
29147
29632
|
// 避免修改原数组。
|
|
29148
29633
|
var samplerList = samplers.slice();
|
|
29149
29634
|
uniformNames = uniformNames.concat(samplerList);
|
|
@@ -29164,22 +29649,22 @@ var GLShader = /** @class */ (function (_super) {
|
|
|
29164
29649
|
this.samplerChannels[samplerName] = index;
|
|
29165
29650
|
}
|
|
29166
29651
|
};
|
|
29167
|
-
|
|
29652
|
+
GLShaderVariant.prototype.toData = function () {
|
|
29168
29653
|
var shaderData = this.taggedProperties;
|
|
29169
|
-
shaderData.dataType = DataType.Shader;
|
|
29654
|
+
shaderData.dataType = DataType$1.Shader;
|
|
29170
29655
|
shaderData.id = this.guid;
|
|
29171
29656
|
shaderData.vertex = this.source.vertex;
|
|
29172
29657
|
shaderData.fragment = this.source.fragment;
|
|
29173
29658
|
};
|
|
29174
|
-
|
|
29659
|
+
GLShaderVariant.prototype.dispose = function () {
|
|
29175
29660
|
var _a;
|
|
29176
29661
|
if (this.compileResult && this.compileResult.shared) {
|
|
29177
29662
|
return;
|
|
29178
29663
|
}
|
|
29179
29664
|
(_a = this.program) === null || _a === void 0 ? void 0 : _a.dispose();
|
|
29180
29665
|
};
|
|
29181
|
-
return
|
|
29182
|
-
}(
|
|
29666
|
+
return GLShaderVariant;
|
|
29667
|
+
}(ShaderVariant));
|
|
29183
29668
|
|
|
29184
29669
|
var shaderSeed = 0;
|
|
29185
29670
|
var GLShaderLibrary = /** @class */ (function () {
|
|
@@ -29234,25 +29719,33 @@ var GLShaderLibrary = /** @class */ (function () {
|
|
|
29234
29719
|
}
|
|
29235
29720
|
};
|
|
29236
29721
|
// TODO 创建shader的ShaderWithSource和shader的source类型一样,待优化。
|
|
29237
|
-
GLShaderLibrary.prototype.addShader = function (shaderSource) {
|
|
29238
|
-
var
|
|
29722
|
+
GLShaderLibrary.prototype.addShader = function (shaderSource, macros) {
|
|
29723
|
+
var mergedMacros = [];
|
|
29724
|
+
if (shaderSource.marcos) {
|
|
29725
|
+
mergedMacros.push.apply(mergedMacros, __spreadArray$3([], __read$3(shaderSource.marcos), false));
|
|
29726
|
+
}
|
|
29727
|
+
if (macros) {
|
|
29728
|
+
mergedMacros.push.apply(mergedMacros, __spreadArray$3([], __read$3(macros), false));
|
|
29729
|
+
}
|
|
29730
|
+
var shaderWithMacros = __assign$1(__assign$1({}, shaderSource), { vertex: createShaderWithMarcos(mergedMacros, shaderSource.vertex, ShaderType.vertex, this.engine.gpuCapability.level), fragment: createShaderWithMarcos(mergedMacros, shaderSource.fragment, ShaderType.fragment, this.engine.gpuCapability.level) });
|
|
29731
|
+
var shaderCacheId = this.computeShaderCacheId(shaderWithMacros);
|
|
29239
29732
|
if (this.cachedShaders[shaderCacheId]) {
|
|
29240
29733
|
return shaderCacheId;
|
|
29241
29734
|
}
|
|
29242
29735
|
this.shaderAllDone = false;
|
|
29243
|
-
var header =
|
|
29244
|
-
var vertex =
|
|
29245
|
-
var fragment =
|
|
29736
|
+
var header = shaderWithMacros.glslVersion === GLSLVersion.GLSL3 ? '#version 300 es\n' : '';
|
|
29737
|
+
var vertex = shaderWithMacros.vertex ? header + shaderWithMacros.vertex : '';
|
|
29738
|
+
var fragment = shaderWithMacros.fragment ? header + shaderWithMacros.fragment : '';
|
|
29246
29739
|
var shared = false;
|
|
29247
|
-
if (
|
|
29740
|
+
if (shaderWithMacros.shared || shaderWithMacros.cacheId) {
|
|
29248
29741
|
shared = true;
|
|
29249
29742
|
}
|
|
29250
|
-
this.cachedShaders[shaderCacheId] = new
|
|
29743
|
+
this.cachedShaders[shaderCacheId] = new GLShaderVariant(this.engine, __assign$1(__assign$1({}, shaderWithMacros), { vertex: vertex, fragment: fragment, name: shaderWithMacros.name || shaderCacheId, shared: shared }));
|
|
29251
29744
|
this.cachedShaders[shaderCacheId].id = shaderCacheId;
|
|
29252
29745
|
return shaderCacheId;
|
|
29253
29746
|
};
|
|
29254
|
-
GLShaderLibrary.prototype.createShader = function (shaderSource) {
|
|
29255
|
-
var shaderCacheId = this.addShader(shaderSource);
|
|
29747
|
+
GLShaderLibrary.prototype.createShader = function (shaderSource, macros) {
|
|
29748
|
+
var shaderCacheId = this.addShader(shaderSource, macros);
|
|
29256
29749
|
return this.cachedShaders[shaderCacheId];
|
|
29257
29750
|
};
|
|
29258
29751
|
GLShaderLibrary.prototype.compileShader = function (shader, asyncCallback) {
|
|
@@ -29350,6 +29843,9 @@ var GLShaderLibrary = /** @class */ (function () {
|
|
|
29350
29843
|
delete result.program;
|
|
29351
29844
|
var linked = gl.getProgramParameter(program, gl.LINK_STATUS);
|
|
29352
29845
|
if (!linked) {
|
|
29846
|
+
// 链接失败,获取并打印错误信息
|
|
29847
|
+
var info = gl.getProgramInfoLog(program);
|
|
29848
|
+
console.error('Failed to link program: ' + info);
|
|
29353
29849
|
var vsCheckResult = checkShader(gl, vertexShader, 'vertex', vs);
|
|
29354
29850
|
var fsCheckResult = checkShader(gl, fragShader, 'fragment', fs);
|
|
29355
29851
|
result.status = ShaderCompileResultStatus.fail;
|
|
@@ -30356,6 +30852,7 @@ var Player = /** @class */ (function () {
|
|
|
30356
30852
|
this.displayScale = 1;
|
|
30357
30853
|
this.resumePending = false;
|
|
30358
30854
|
this.disposed = false;
|
|
30855
|
+
this.assetManagers = [];
|
|
30359
30856
|
this.speed = 1;
|
|
30360
30857
|
this.baseCompositionIndex = 0;
|
|
30361
30858
|
/**
|
|
@@ -30638,7 +31135,7 @@ var Player = /** @class */ (function () {
|
|
|
30638
31135
|
Player.prototype.createComposition = function (url, options) {
|
|
30639
31136
|
if (options === void 0) { options = {}; }
|
|
30640
31137
|
return __awaiter(this, void 0, void 0, function () {
|
|
30641
|
-
var renderer, engine, last, opts, source, scene, i, compositionSourceManager, composition, firstFrameTime;
|
|
31138
|
+
var renderer, engine, last, opts, source, assetManager, scene, i, compositionSourceManager, composition, firstFrameTime;
|
|
30642
31139
|
var _this = this;
|
|
30643
31140
|
return __generator(this, function (_a) {
|
|
30644
31141
|
switch (_a.label) {
|
|
@@ -30654,15 +31151,11 @@ var Player = /** @class */ (function () {
|
|
|
30654
31151
|
else {
|
|
30655
31152
|
source = url;
|
|
30656
31153
|
}
|
|
30657
|
-
|
|
30658
|
-
this.assetManager.updateOptions(opts);
|
|
30659
|
-
}
|
|
30660
|
-
else {
|
|
30661
|
-
this.assetManager = new AssetManager(opts);
|
|
30662
|
-
}
|
|
31154
|
+
assetManager = new AssetManager(opts);
|
|
30663
31155
|
// TODO 多 json 之间目前不共用资源,如果后续需要多 json 共用,这边缓存机制需要额外处理
|
|
30664
31156
|
engine.clearResources(); // 在 assetManager.loadScene 前清除,避免 loadScene 创建的 EffectsObject 对象丢失
|
|
30665
|
-
|
|
31157
|
+
this.assetManagers.push(assetManager);
|
|
31158
|
+
return [4 /*yield*/, assetManager.loadScene(source, this.renderer, { env: this.env })];
|
|
30666
31159
|
case 1:
|
|
30667
31160
|
scene = _a.sent();
|
|
30668
31161
|
engine.addPackageDatas(scene);
|
|
@@ -30996,7 +31489,7 @@ var Player = /** @class */ (function () {
|
|
|
30996
31489
|
* @param keepCanvas - 是否保留 canvas 画面,默认不保留,canvas 不能再被使用
|
|
30997
31490
|
*/
|
|
30998
31491
|
Player.prototype.dispose = function (keepCanvas) {
|
|
30999
|
-
var _a
|
|
31492
|
+
var _a;
|
|
31000
31493
|
logger.info("call player destroy: ".concat(this.name));
|
|
31001
31494
|
if (this.disposed) {
|
|
31002
31495
|
return;
|
|
@@ -31004,7 +31497,7 @@ var Player = /** @class */ (function () {
|
|
|
31004
31497
|
playerMap.delete(this.canvas);
|
|
31005
31498
|
this.pause();
|
|
31006
31499
|
(_a = this.ticker) === null || _a === void 0 ? void 0 : _a.stop();
|
|
31007
|
-
(
|
|
31500
|
+
this.assetManagers.forEach(function (assetManager) { return assetManager.dispose(); });
|
|
31008
31501
|
this.compositions.forEach(function (comp) { return comp.dispose(); });
|
|
31009
31502
|
this.compositions.length = 0;
|
|
31010
31503
|
this.renderer.context.removeLostHandler({ lost: this.lost });
|
|
@@ -31210,8 +31703,8 @@ Renderer.create = function (canvas, framework, renderOptions) {
|
|
|
31210
31703
|
Engine.create = function (gl) {
|
|
31211
31704
|
return new GLEngine(gl);
|
|
31212
31705
|
};
|
|
31213
|
-
var version = "2.0.0-alpha.
|
|
31706
|
+
var version = "2.0.0-alpha.4";
|
|
31214
31707
|
logger.info('player version: ' + version);
|
|
31215
31708
|
|
|
31216
|
-
export { AbstractPlugin, ActivationPlayable, AssetLoader, AssetManager, BYTES_TYPE_MAP, Behaviour, BezierSegments, COMPRESSED_TEXTURE, COPY_FRAGMENT_SHADER, COPY_MESH_SHADER_ID, COPY_VERTEX_SHADER, CalculateLoader, Camera, CameraController, CameraVFXItemLoader, Component, Composition, CompositionComponent, CompositionSourceManager, CurveValue, DEFAULT_FONTS, DataType, Database, DestroyOptions, Downloader, EFFECTS_COPY_MESH_NAME, EVENT_TYPE_CLICK, EVENT_TYPE_TOUCH_END, EVENT_TYPE_TOUCH_MOVE, EVENT_TYPE_TOUCH_START, EffectComponent, EffectsObject, Engine, EventSystem, FILTER_NAME_NONE, FilterMode, Float16ArrayWrapper, FrameBuffer, GLEngine, GLGeometry, GLRenderer, GLSLVersion, GPUCapability, Geometry, GlobalUniforms, GradientValue, HELP_LINK$1 as HELP_LINK, HitTestType, InteractBehavior$1 as InteractBehavior, InteractComponent, InteractLoader, InteractMesh, Item, ItemBehaviour, KTXTexture, LineSegments, LinearValue, Material, MaterialDataBlock, MaterialRenderType, Mesh, OrderType, PLAYER_OPTIONS_ENV_EDITOR, POST_PROCESS_SETTINGS, ParticleBehaviourPlayable, ParticleLoader, ParticleMesh, ParticleSystem, ParticleSystemRenderer, PassTextureCache, PathSegments, Player, PluginSystem, QCanvasViewer, QText, QTextWrapMode, RENDER_PASS_NAME_PREFIX, RENDER_PREFER_LOOKUP_TEXTURE, RUNTIME_ENV, RandomSetValue, RandomValue, RandomVectorValue, RenderBuffer, RenderFrame, RenderPass, RenderPassAttachmentStorageType, RenderPassDestroyAttachmentType, RenderPassPriorityNormal, RenderPassPriorityPostprocess, RenderPassPriorityPrepare, RenderTargetHandle, RenderTextureFormat, Renderer, RendererComponent, SEMANTIC_MAIN_PRE_COLOR_ATTACHMENT_0, SEMANTIC_MAIN_PRE_COLOR_ATTACHMENT_SIZE_0, SEMANTIC_PRE_COLOR_ATTACHMENT_0, SEMANTIC_PRE_COLOR_ATTACHMENT_SIZE_0, SPRITE_VERTEX_STRIDE, SemanticMap, SerializationHelper, Shader, ShaderCompileResultStatus, ShaderType, SpriteColorPlayable, SpriteComponent, SpriteLoader, StaticValue, TEMPLATE_USE_OFFSCREEN_CANVAS, TextComponent, TextLoader, Texture, TextureFactory, TextureLoadAction, TextureSourceType, TextureStoreAction, Ticker, TimelineClip, TimelineComponent, Track, Transform, TransformAnimationPlayable, TransformAnimationPlayableAsset, VFXItem, ValueGetter, addByOrder, addItem, addItemWithOrder, alphaFrame_frag as alphaFrameFrag, alphaMask_frag as alphaMaskFrag, assertExist, asserts, blend, bloomMix_frag as bloomMixVert, bloomThreshold_frag as bloomThresholdVert, calculateTranslation, cameraMove_frag as cameraMoveFrag, cameraMove_vert as cameraMoveVert, canvasPool, colorGradingFrag, colorStopsFromGradient, colorToArr$1 as colorToArr, combineImageTemplate, combineImageTemplate1, combineImageTemplate1Async, combineImageTemplate2, combineImageTemplate2Async, combineImageTemplateAsync, compatible_frag as compatibleFrag, compatible_vert as compatibleVert, copy as copyFrag, createCopyShader, createGLContext, createKeyFrameMeta, createShaderWithMarcos, createShape, createVFXItem, createValueGetter, deepClone, defaultGlobalVolume, defaultPlugins, delay_frag as delayFrag, deserializeMipmapTexture, disableAllPlayer, distortion_frag as distortionFrag, distortion_vert as distortionVert, earcut, effectsClass, effectsClassStore, enlargeBuffer, ensureVec3, findPreviousRenderPass, gaussianDown_frag as gaussianDownFrag, gaussianDownHFrag, gaussianDownVFrag, gaussianUpFrag, generateEmptyTypedArray, generateGUID, generateHalfFloatTexture, getActivePlayers, getBackgroundImage, getColorFromGradientStops, getConfig, getDefaultTemplateCanvasPool, getDefaultTextureFactory, getGeometryByShape, getGeometryTriangles, getImageItemRenderInfo, getKTXTextureOptions, getKeyFrameMetaByRawValue, getMergedStore, getParticleMeshShader, getPixelRatio, getPlayerByCanvas, getPreMultiAlpha, getStandardComposition, getStandardImage, getStandardItem, getStandardJSON, getTextureSize, glContext, gpuTimer, imageDataFromColor, imageDataFromGradient, initErrors, initGLContext, integrate, interpolateColor, isAndroid, isArray, isCanvasUsedByPlayer, isFunction, isIOS, isObject, isScene, isSceneWithOptions, isSimulatorCellPhone, isString, isUniformStruct, isUniformStructArray, isWebGL2, item_define as itemDefine, itemFrag, itemFrameFrag, itemVert, loadBinary, loadBlob, loadImage, loadVideo, loadWebPOptional, logger, index$1 as math, maxSpriteMeshItemCount, maxSpriteTextureCount, modifyMaxKeyframeShader, nearestPowerOfTwo, noop, parsePercent$1 as parsePercent, particleFrag, particleOriginTranslateMap, particleVert, pluginLoaderMap, random, registerPlugin, removeItem, requestAsync, rotateVec2, screenMeshVert, serialize, setBlendMode, setConfig, setDefaultTextureFactory, setMaskMode, setMaxSpriteMeshItemCount, setRayFromCamera, setSideMode, setSpriteMeshMaxFragmentTextures, setSpriteMeshMaxItemCountByGPU, sortByOrder, index as spec, spriteMeshShaderFromFilter, spriteMeshShaderFromRenderInfo, spriteMeshShaderIdFromRenderInfo, thresholdFrag, throwDestroyedError$1 as throwDestroyedError, trailVert, translatePoint, trianglesFromRect, unregisterPlugin, valIfUndefined, value, valueDefine, vecAssign, vecFill, vecMulCombine, vecNormalize, version };
|
|
31709
|
+
export { AbstractPlugin, ActivationPlayable, AssetLoader, AssetManager, BYTES_TYPE_MAP, Behaviour, BezierSegments, COMPRESSED_TEXTURE, COPY_FRAGMENT_SHADER, COPY_MESH_SHADER_ID, COPY_VERTEX_SHADER, CalculateLoader, Camera, CameraController, CameraVFXItemLoader, Component, Composition, CompositionComponent, CompositionSourceManager, CurveValue, DEFAULT_FONTS, DataType$1 as DataType, Database, DestroyOptions, Downloader, EFFECTS_COPY_MESH_NAME, EVENT_TYPE_CLICK, EVENT_TYPE_TOUCH_END, EVENT_TYPE_TOUCH_MOVE, EVENT_TYPE_TOUCH_START, EffectComponent, EffectsObject, Engine, EventSystem, FILTER_NAME_NONE, FilterMode, Float16ArrayWrapper, FrameBuffer, GLEngine, GLGeometry, GLRenderer, GLSLVersion, GPUCapability, Geometry, GlobalUniforms, GradientValue, HELP_LINK$1 as HELP_LINK, HitTestType, InteractBehavior$1 as InteractBehavior, InteractComponent, InteractLoader, InteractMesh, Item, ItemBehaviour, KTXTexture, LineSegments, LinearValue, Material, MaterialDataBlock, MaterialRenderType, Mesh, OrderType, PLAYER_OPTIONS_ENV_EDITOR, POST_PROCESS_SETTINGS, ParticleBehaviourPlayable, ParticleLoader, ParticleMesh, ParticleSystem, ParticleSystemRenderer, PassTextureCache, PathSegments, Player, PluginSystem, QCanvasViewer, QText, QTextWrapMode, RENDER_PASS_NAME_PREFIX, RENDER_PREFER_LOOKUP_TEXTURE, RUNTIME_ENV, RandomSetValue, RandomValue, RandomVectorValue, RenderBuffer, RenderFrame, RenderPass, RenderPassAttachmentStorageType, RenderPassDestroyAttachmentType, RenderPassPriorityNormal, RenderPassPriorityPostprocess, RenderPassPriorityPrepare, RenderTargetHandle, RenderTextureFormat, Renderer, RendererComponent, SEMANTIC_MAIN_PRE_COLOR_ATTACHMENT_0, SEMANTIC_MAIN_PRE_COLOR_ATTACHMENT_SIZE_0, SEMANTIC_PRE_COLOR_ATTACHMENT_0, SEMANTIC_PRE_COLOR_ATTACHMENT_SIZE_0, SPRITE_VERTEX_STRIDE, SemanticMap, SerializationHelper, Shader, ShaderCompileResultStatus, ShaderType, ShaderVariant, SpriteColorPlayable, SpriteComponent, SpriteLoader, StaticValue, TEMPLATE_USE_OFFSCREEN_CANVAS, TextComponent, TextLoader, Texture, TextureFactory, TextureLoadAction, TextureSourceType, TextureStoreAction, Ticker, TimelineClip, TimelineComponent, Track, Transform, TransformAnimationPlayable, TransformAnimationPlayableAsset, VFXItem, ValueGetter, addByOrder, addItem, addItemWithOrder, alphaFrame_frag as alphaFrameFrag, alphaMask_frag as alphaMaskFrag, assertExist, asserts, blend, bloomMix_frag as bloomMixVert, bloomThreshold_frag as bloomThresholdVert, calculateTranslation, cameraMove_frag as cameraMoveFrag, cameraMove_vert as cameraMoveVert, canvasPool, colorGradingFrag, colorStopsFromGradient, colorToArr$1 as colorToArr, combineImageTemplate, combineImageTemplate1, combineImageTemplate1Async, combineImageTemplate2, combineImageTemplate2Async, combineImageTemplateAsync, compatible_frag as compatibleFrag, compatible_vert as compatibleVert, copy as copyFrag, createCopyShader, createGLContext, createKeyFrameMeta, createShaderWithMarcos, createShape, createVFXItem, createValueGetter, deepClone, defaultGlobalVolume, defaultPlugins, delay_frag as delayFrag, deserializeMipmapTexture, disableAllPlayer, distortion_frag as distortionFrag, distortion_vert as distortionVert, earcut, effectsClass, effectsClassStore, enlargeBuffer, ensureVec3, findPreviousRenderPass, gaussianDown_frag as gaussianDownFrag, gaussianDownHFrag, gaussianDownVFrag, gaussianUpFrag, generateEmptyTypedArray, generateGUID$1 as generateGUID, generateHalfFloatTexture, getActivePlayers, getBackgroundImage, getColorFromGradientStops, getConfig, getDefaultTemplateCanvasPool, getDefaultTextureFactory, getGeometryByShape, getGeometryTriangles, getImageItemRenderInfo, getKTXTextureOptions, getKeyFrameMetaByRawValue, getMergedStore, getParticleMeshShader, getPixelRatio, getPlayerByCanvas, getPreMultiAlpha, getStandardComposition, getStandardImage, getStandardItem, getStandardJSON, getTextureSize, glContext, gpuTimer, imageDataFromColor, imageDataFromGradient, initErrors, initGLContext, integrate, interpolateColor, isAndroid, isArray, isCanvasUsedByPlayer, isFunction, isIOS, isObject, isScene, isSceneWithOptions, isSimulatorCellPhone, isString, isUniformStruct, isUniformStructArray, isWebGL2, item_define as itemDefine, itemFrag, itemFrameFrag, itemVert, loadBinary, loadBlob, loadImage, loadVideo, loadWebPOptional, logger, index$1 as math, maxSpriteMeshItemCount, maxSpriteTextureCount, modifyMaxKeyframeShader, nearestPowerOfTwo, noop, parsePercent$1 as parsePercent, particleFrag, particleOriginTranslateMap$1 as particleOriginTranslateMap, particleVert, pluginLoaderMap, random, registerPlugin, removeItem, requestAsync, rotateVec2, screenMeshVert, serialize, setBlendMode, setConfig, setDefaultTextureFactory, setMaskMode, setMaxSpriteMeshItemCount, setRayFromCamera, setSideMode, setSpriteMeshMaxFragmentTextures, setSpriteMeshMaxItemCountByGPU, sortByOrder, index as spec, spriteMeshShaderFromFilter, spriteMeshShaderFromRenderInfo, spriteMeshShaderIdFromRenderInfo, thresholdFrag, throwDestroyedError$1 as throwDestroyedError, trailVert, translatePoint, trianglesFromRect, unregisterPlugin, valIfUndefined, value, valueDefine, vecAssign, vecFill, vecMulCombine, vecNormalize, version };
|
|
31217
31710
|
//# sourceMappingURL=weapp.mjs.map
|