@galacean/effects-threejs 2.0.0-alpha.3 → 2.0.0-alpha.5
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 +724 -254
- 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 +760 -291
- package/dist/index.mjs.map +1 -1
- package/dist/material/three-material.d.ts +3 -3
- package/package.json +2 -2
package/dist/index.js
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
* Description: Galacean Effects runtime threejs plugin for the web
|
|
4
4
|
* Author: Ant Group CO., Ltd.
|
|
5
5
|
* Contributors: 燃然,飂兮,十弦,云垣,茂安,意绮
|
|
6
|
-
* Version: v2.0.0-alpha.
|
|
6
|
+
* Version: v2.0.0-alpha.5
|
|
7
7
|
*/
|
|
8
8
|
|
|
9
9
|
'use strict';
|
|
@@ -148,7 +148,7 @@ function __read$3(o, n) {
|
|
|
148
148
|
return ar;
|
|
149
149
|
}
|
|
150
150
|
|
|
151
|
-
function __spreadArray$
|
|
151
|
+
function __spreadArray$3(to, from, pack) {
|
|
152
152
|
if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {
|
|
153
153
|
if (ar || !(i in from)) {
|
|
154
154
|
if (!ar) ar = Array.prototype.slice.call(from, 0, i);
|
|
@@ -166,20 +166,20 @@ typeof SuppressedError === "function" ? SuppressedError : function (error, suppr
|
|
|
166
166
|
// Unique ID creation requires a high quality random # generator. In the browser we therefore
|
|
167
167
|
// require the crypto API and do not support built-in fallback to lower quality random number
|
|
168
168
|
// generators (like Math.random()).
|
|
169
|
-
let getRandomValues;
|
|
170
|
-
const rnds8 = new Uint8Array(16);
|
|
171
|
-
function rng() {
|
|
169
|
+
let getRandomValues$1;
|
|
170
|
+
const rnds8$1 = new Uint8Array(16);
|
|
171
|
+
function rng$1() {
|
|
172
172
|
// lazy load so that environments that need to polyfill have a chance to do so
|
|
173
|
-
if (!getRandomValues) {
|
|
173
|
+
if (!getRandomValues$1) {
|
|
174
174
|
// getRandomValues needs to be invoked in a context where "this" is a Crypto implementation.
|
|
175
|
-
getRandomValues = typeof crypto !== 'undefined' && crypto.getRandomValues && crypto.getRandomValues.bind(crypto);
|
|
175
|
+
getRandomValues$1 = typeof crypto !== 'undefined' && crypto.getRandomValues && crypto.getRandomValues.bind(crypto);
|
|
176
176
|
|
|
177
|
-
if (!getRandomValues) {
|
|
177
|
+
if (!getRandomValues$1) {
|
|
178
178
|
throw new Error('crypto.getRandomValues() not supported. See https://github.com/uuidjs/uuid#getrandomvalues-not-supported');
|
|
179
179
|
}
|
|
180
180
|
}
|
|
181
181
|
|
|
182
|
-
return getRandomValues(rnds8);
|
|
182
|
+
return getRandomValues$1(rnds8$1);
|
|
183
183
|
}
|
|
184
184
|
|
|
185
185
|
/**
|
|
@@ -187,30 +187,30 @@ function rng() {
|
|
|
187
187
|
* XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX
|
|
188
188
|
*/
|
|
189
189
|
|
|
190
|
-
const byteToHex = [];
|
|
190
|
+
const byteToHex$2 = [];
|
|
191
191
|
|
|
192
192
|
for (let i = 0; i < 256; ++i) {
|
|
193
|
-
byteToHex.push((i + 0x100).toString(16).slice(1));
|
|
193
|
+
byteToHex$2.push((i + 0x100).toString(16).slice(1));
|
|
194
194
|
}
|
|
195
195
|
|
|
196
|
-
function unsafeStringify(arr, offset = 0) {
|
|
196
|
+
function unsafeStringify$1(arr, offset = 0) {
|
|
197
197
|
// Note: Be careful editing this code! It's been tuned for performance
|
|
198
198
|
// and works in ways you may not expect. See https://github.com/uuidjs/uuid/pull/434
|
|
199
|
-
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]];
|
|
199
|
+
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]];
|
|
200
200
|
}
|
|
201
201
|
|
|
202
|
-
const randomUUID = typeof crypto !== 'undefined' && crypto.randomUUID && crypto.randomUUID.bind(crypto);
|
|
203
|
-
var native = {
|
|
204
|
-
randomUUID
|
|
202
|
+
const randomUUID$1 = typeof crypto !== 'undefined' && crypto.randomUUID && crypto.randomUUID.bind(crypto);
|
|
203
|
+
var native$1 = {
|
|
204
|
+
randomUUID: randomUUID$1
|
|
205
205
|
};
|
|
206
206
|
|
|
207
|
-
function v4(options, buf, offset) {
|
|
208
|
-
if (native.randomUUID && !buf && !options) {
|
|
209
|
-
return native.randomUUID();
|
|
207
|
+
function v4$1(options, buf, offset) {
|
|
208
|
+
if (native$1.randomUUID && !buf && !options) {
|
|
209
|
+
return native$1.randomUUID();
|
|
210
210
|
}
|
|
211
211
|
|
|
212
212
|
options = options || {};
|
|
213
|
-
const rnds = options.random || (options.rng || rng)(); // Per 4.4, set bits for version and `clock_seq_hi_and_reserved`
|
|
213
|
+
const rnds = options.random || (options.rng || rng$1)(); // Per 4.4, set bits for version and `clock_seq_hi_and_reserved`
|
|
214
214
|
|
|
215
215
|
rnds[6] = rnds[6] & 0x0f | 0x40;
|
|
216
216
|
rnds[8] = rnds[8] & 0x3f | 0x80; // Copy bytes to buffer, if provided
|
|
@@ -225,7 +225,7 @@ function v4(options, buf, offset) {
|
|
|
225
225
|
return buf;
|
|
226
226
|
}
|
|
227
227
|
|
|
228
|
-
return unsafeStringify(rnds);
|
|
228
|
+
return unsafeStringify$1(rnds);
|
|
229
229
|
}
|
|
230
230
|
|
|
231
231
|
function addItem(arr, value) {
|
|
@@ -2212,7 +2212,7 @@ var __read$2 = (undefined && undefined.__read) || function (o, n) {
|
|
|
2212
2212
|
}
|
|
2213
2213
|
return ar;
|
|
2214
2214
|
};
|
|
2215
|
-
var __spreadArray$
|
|
2215
|
+
var __spreadArray$2 = (undefined && undefined.__spreadArray) || function (to, from, pack) {
|
|
2216
2216
|
if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {
|
|
2217
2217
|
if (ar || !(i in from)) {
|
|
2218
2218
|
if (!ar) ar = Array.prototype.slice.call(from, 0, i);
|
|
@@ -2529,7 +2529,7 @@ var Matrix4 = /** @class */ (function () {
|
|
|
2529
2529
|
* @returns 复制结果
|
|
2530
2530
|
*/
|
|
2531
2531
|
Matrix4.prototype.copyFrom = function (m) {
|
|
2532
|
-
this.elements = __spreadArray$
|
|
2532
|
+
this.elements = __spreadArray$2([], __read$2(m.elements), false);
|
|
2533
2533
|
return this;
|
|
2534
2534
|
};
|
|
2535
2535
|
/**
|
|
@@ -3058,7 +3058,7 @@ var Matrix4 = /** @class */ (function () {
|
|
|
3058
3058
|
* @returns
|
|
3059
3059
|
*/
|
|
3060
3060
|
Matrix4.prototype.toArray = function () {
|
|
3061
|
-
return __spreadArray$
|
|
3061
|
+
return __spreadArray$2([], __read$2(this.elements), false);
|
|
3062
3062
|
};
|
|
3063
3063
|
Matrix4.prototype.fill = function (array, offset) {
|
|
3064
3064
|
if (offset === void 0) { offset = 0; }
|
|
@@ -4311,7 +4311,7 @@ var __read$1 = (undefined && undefined.__read) || function (o, n) {
|
|
|
4311
4311
|
}
|
|
4312
4312
|
return ar;
|
|
4313
4313
|
};
|
|
4314
|
-
var __spreadArray = (undefined && undefined.__spreadArray) || function (to, from, pack) {
|
|
4314
|
+
var __spreadArray$1 = (undefined && undefined.__spreadArray) || function (to, from, pack) {
|
|
4315
4315
|
if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {
|
|
4316
4316
|
if (ar || !(i in from)) {
|
|
4317
4317
|
if (!ar) ar = Array.prototype.slice.call(from, 0, i);
|
|
@@ -4498,7 +4498,7 @@ var Matrix3 = /** @class */ (function () {
|
|
|
4498
4498
|
* @returns 复制结果
|
|
4499
4499
|
*/
|
|
4500
4500
|
Matrix3.prototype.copyFrom = function (m) {
|
|
4501
|
-
this.elements = __spreadArray([], __read$1(m.elements), false);
|
|
4501
|
+
this.elements = __spreadArray$1([], __read$1(m.elements), false);
|
|
4502
4502
|
return this;
|
|
4503
4503
|
};
|
|
4504
4504
|
/**
|
|
@@ -4714,7 +4714,7 @@ var Matrix3 = /** @class */ (function () {
|
|
|
4714
4714
|
* @returns
|
|
4715
4715
|
*/
|
|
4716
4716
|
Matrix3.prototype.toArray = function () {
|
|
4717
|
-
return __spreadArray([], __read$1(this.elements), false);
|
|
4717
|
+
return __spreadArray$1([], __read$1(this.elements), false);
|
|
4718
4718
|
};
|
|
4719
4719
|
Matrix3.prototype.fill = function (array, offset) {
|
|
4720
4720
|
if (offset === void 0) { offset = 0; }
|
|
@@ -6472,7 +6472,7 @@ function error(message) {
|
|
|
6472
6472
|
for (var _i = 1; _i < arguments.length; _i++) {
|
|
6473
6473
|
args[_i - 1] = arguments[_i];
|
|
6474
6474
|
}
|
|
6475
|
-
console.error.apply(console, __spreadArray$
|
|
6475
|
+
console.error.apply(console, __spreadArray$3(__spreadArray$3([], __read$3(format(message)), false), [args], false));
|
|
6476
6476
|
localLogger === null || localLogger === void 0 ? void 0 : localLogger('error', message, args);
|
|
6477
6477
|
}
|
|
6478
6478
|
/**
|
|
@@ -6485,7 +6485,7 @@ function info(message) {
|
|
|
6485
6485
|
for (var _i = 1; _i < arguments.length; _i++) {
|
|
6486
6486
|
args[_i - 1] = arguments[_i];
|
|
6487
6487
|
}
|
|
6488
|
-
console.debug.apply(console, __spreadArray$
|
|
6488
|
+
console.debug.apply(console, __spreadArray$3([], __read$3(format(message)), false));
|
|
6489
6489
|
localLogger === null || localLogger === void 0 ? void 0 : localLogger('info', message, args);
|
|
6490
6490
|
}
|
|
6491
6491
|
function warn(message) {
|
|
@@ -6493,7 +6493,7 @@ function warn(message) {
|
|
|
6493
6493
|
for (var _i = 1; _i < arguments.length; _i++) {
|
|
6494
6494
|
args[_i - 1] = arguments[_i];
|
|
6495
6495
|
}
|
|
6496
|
-
console.warn.apply(console, __spreadArray$
|
|
6496
|
+
console.warn.apply(console, __spreadArray$3([], __read$3(format(message)), false));
|
|
6497
6497
|
localLogger === null || localLogger === void 0 ? void 0 : localLogger('warn', message, args);
|
|
6498
6498
|
}
|
|
6499
6499
|
/**
|
|
@@ -6590,17 +6590,30 @@ function random(min, max) {
|
|
|
6590
6590
|
function throwDestroyedError() {
|
|
6591
6591
|
throw Error('destroyed item cannot be used again');
|
|
6592
6592
|
}
|
|
6593
|
-
function generateGUID() {
|
|
6594
|
-
return v4().replace(/-/g, '');
|
|
6593
|
+
function generateGUID$1() {
|
|
6594
|
+
return v4$1().replace(/-/g, '');
|
|
6595
6595
|
}
|
|
6596
6596
|
|
|
6597
6597
|
/*!
|
|
6598
6598
|
* Name: @galacean/effects-specification
|
|
6599
6599
|
* Description: Galacean Effects JSON Specification
|
|
6600
6600
|
* Author: Ant Group CO., Ltd.
|
|
6601
|
-
* Version:
|
|
6601
|
+
* Version: v2.0.0-alpha.3
|
|
6602
|
+
*/
|
|
6603
|
+
|
|
6604
|
+
typeof crypto !== 'undefined' && crypto.randomUUID && crypto.randomUUID.bind(crypto);
|
|
6605
|
+
|
|
6606
|
+
/**
|
|
6607
|
+
* Convert array of 16 byte values to UUID string format of the form:
|
|
6608
|
+
* XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX
|
|
6602
6609
|
*/
|
|
6603
6610
|
|
|
6611
|
+
const byteToHex$1 = [];
|
|
6612
|
+
|
|
6613
|
+
for (let i = 0; i < 256; ++i) {
|
|
6614
|
+
byteToHex$1.push((i + 0x100).toString(16).slice(1));
|
|
6615
|
+
}
|
|
6616
|
+
|
|
6604
6617
|
/*********************************************/
|
|
6605
6618
|
/* 元素属性参数类型 */
|
|
6606
6619
|
/*********************************************/
|
|
@@ -6863,6 +6876,10 @@ var ItemType$1;
|
|
|
6863
6876
|
* 天空盒元素
|
|
6864
6877
|
*/
|
|
6865
6878
|
ItemType["skybox"] = "skybox";
|
|
6879
|
+
/**
|
|
6880
|
+
* 特效元素
|
|
6881
|
+
*/
|
|
6882
|
+
ItemType["effect"] = "effect";
|
|
6866
6883
|
})(ItemType$1 || (ItemType$1 = {}));
|
|
6867
6884
|
/**
|
|
6868
6885
|
* 渲染模式
|
|
@@ -6977,6 +6994,10 @@ var CompositionEndBehavior$1;
|
|
|
6977
6994
|
* 销毁并保留最后一帧
|
|
6978
6995
|
*/
|
|
6979
6996
|
CompositionEndBehavior[CompositionEndBehavior["pause_destroy"] = END_BEHAVIOR_PAUSE_AND_DESTROY$1] = "pause_destroy";
|
|
6997
|
+
/**
|
|
6998
|
+
* 冻结
|
|
6999
|
+
*/
|
|
7000
|
+
CompositionEndBehavior[CompositionEndBehavior["freeze"] = END_BEHAVIOR_FREEZE$1] = "freeze";
|
|
6980
7001
|
})(CompositionEndBehavior$1 || (CompositionEndBehavior$1 = {}));
|
|
6981
7002
|
|
|
6982
7003
|
/*********************************************/
|
|
@@ -7115,12 +7136,38 @@ var ShapeArcMode$1;
|
|
|
7115
7136
|
|
|
7116
7137
|
var BloomFilterThresholdAvgColor = 0;
|
|
7117
7138
|
|
|
7139
|
+
var LightType$1;
|
|
7140
|
+
(function (LightType) {
|
|
7141
|
+
/**
|
|
7142
|
+
* 点光源
|
|
7143
|
+
*/
|
|
7144
|
+
LightType["point"] = "point";
|
|
7145
|
+
/**
|
|
7146
|
+
* 聚光灯
|
|
7147
|
+
*/
|
|
7148
|
+
LightType["spot"] = "spot";
|
|
7149
|
+
/**
|
|
7150
|
+
* 方向光
|
|
7151
|
+
*/
|
|
7152
|
+
LightType["directional"] = "directional";
|
|
7153
|
+
/**
|
|
7154
|
+
* 环境光
|
|
7155
|
+
*/
|
|
7156
|
+
LightType["ambient"] = "ambient";
|
|
7157
|
+
})(LightType$1 || (LightType$1 = {}));
|
|
7158
|
+
|
|
7118
7159
|
var ModelBoundingType$1;
|
|
7119
7160
|
(function (ModelBoundingType) {
|
|
7120
7161
|
ModelBoundingType[ModelBoundingType["box"] = 2] = "box";
|
|
7121
7162
|
ModelBoundingType[ModelBoundingType["sphere"] = 3] = "sphere";
|
|
7122
7163
|
})(ModelBoundingType$1 || (ModelBoundingType$1 = {}));
|
|
7123
7164
|
|
|
7165
|
+
var CameraType$1;
|
|
7166
|
+
(function (CameraType) {
|
|
7167
|
+
CameraType["orthographic"] = "orthographic";
|
|
7168
|
+
CameraType["perspective"] = "perspective";
|
|
7169
|
+
})(CameraType$1 || (CameraType$1 = {}));
|
|
7170
|
+
|
|
7124
7171
|
// 材质类型
|
|
7125
7172
|
var MaterialType$1;
|
|
7126
7173
|
(function (MaterialType) {
|
|
@@ -7266,6 +7313,28 @@ var FontStyle$1;
|
|
|
7266
7313
|
FontStyle["oblique"] = "oblique";
|
|
7267
7314
|
})(FontStyle$1 || (FontStyle$1 = {}));
|
|
7268
7315
|
|
|
7316
|
+
var DataType$1;
|
|
7317
|
+
(function (DataType) {
|
|
7318
|
+
DataType["VFXItemData"] = "VFXItemData";
|
|
7319
|
+
DataType["EffectComponent"] = "EffectComponent";
|
|
7320
|
+
DataType["Material"] = "Material";
|
|
7321
|
+
DataType["Shader"] = "Shader";
|
|
7322
|
+
DataType["SpriteComponent"] = "SpriteComponent";
|
|
7323
|
+
DataType["ParticleSystem"] = "ParticleSystem";
|
|
7324
|
+
DataType["InteractComponent"] = "InteractComponent";
|
|
7325
|
+
DataType["CameraController"] = "CameraController";
|
|
7326
|
+
DataType["Geometry"] = "Geometry";
|
|
7327
|
+
DataType["Texture"] = "Texture";
|
|
7328
|
+
DataType["TextComponent"] = "TextComponent";
|
|
7329
|
+
// FIXME: 先完成ECS的场景转换,后面移到spec中
|
|
7330
|
+
DataType["MeshComponent"] = "MeshComponent";
|
|
7331
|
+
DataType["SkyboxComponent"] = "SkyboxComponent";
|
|
7332
|
+
DataType["LightComponent"] = "LightComponent";
|
|
7333
|
+
DataType["CameraComponent"] = "CameraComponent";
|
|
7334
|
+
DataType["ModelPluginComponent"] = "ModelPluginComponent";
|
|
7335
|
+
DataType["TreeComponent"] = "TreeComponent";
|
|
7336
|
+
})(DataType$1 || (DataType$1 = {}));
|
|
7337
|
+
|
|
7269
7338
|
var index = /*#__PURE__*/Object.freeze({
|
|
7270
7339
|
__proto__: null,
|
|
7271
7340
|
get BezierKeyframeType () { return BezierKeyframeType$1; },
|
|
@@ -7274,7 +7343,9 @@ var index = /*#__PURE__*/Object.freeze({
|
|
|
7274
7343
|
CAMERA_CLIP_MODE_NORMAL: CAMERA_CLIP_MODE_NORMAL$1,
|
|
7275
7344
|
CAMERA_CLIP_MODE_VERTICAL: CAMERA_CLIP_MODE_VERTICAL$1,
|
|
7276
7345
|
get CameraClipMode () { return CameraClipMode$1; },
|
|
7346
|
+
get CameraType () { return CameraType$1; },
|
|
7277
7347
|
get CompositionEndBehavior () { return CompositionEndBehavior$1; },
|
|
7348
|
+
get DataType () { return DataType$1; },
|
|
7278
7349
|
END_BEHAVIOR_DESTROY: END_BEHAVIOR_DESTROY$1,
|
|
7279
7350
|
END_BEHAVIOR_DESTROY_CHILDREN: END_BEHAVIOR_DESTROY_CHILDREN$1,
|
|
7280
7351
|
END_BEHAVIOR_FORWARD: END_BEHAVIOR_FORWARD$1,
|
|
@@ -7287,6 +7358,7 @@ var index = /*#__PURE__*/Object.freeze({
|
|
|
7287
7358
|
get InteractType () { return InteractType$1; },
|
|
7288
7359
|
get ItemEndBehavior () { return ItemEndBehavior$1; },
|
|
7289
7360
|
get ItemType () { return ItemType$1; },
|
|
7361
|
+
get LightType () { return LightType$1; },
|
|
7290
7362
|
MESSAGE_ITEM_PHRASE_BEGIN: MESSAGE_ITEM_PHRASE_BEGIN,
|
|
7291
7363
|
MESSAGE_ITEM_PHRASE_END: MESSAGE_ITEM_PHRASE_END,
|
|
7292
7364
|
get MaskMode () { return MaskMode$1; },
|
|
@@ -7478,7 +7550,7 @@ function copy$1(target) {
|
|
|
7478
7550
|
}
|
|
7479
7551
|
}
|
|
7480
7552
|
|
|
7481
|
-
var _a$
|
|
7553
|
+
var _a$7;
|
|
7482
7554
|
function valIfUndefined(val, def) {
|
|
7483
7555
|
if (val === undefined || val === null) {
|
|
7484
7556
|
return def;
|
|
@@ -7508,15 +7580,15 @@ function getPreMultiAlpha(blending) {
|
|
|
7508
7580
|
return 1;
|
|
7509
7581
|
}
|
|
7510
7582
|
}
|
|
7511
|
-
var downgradeKeywords = (_a$
|
|
7512
|
-
_a$
|
|
7583
|
+
var downgradeKeywords = (_a$7 = {},
|
|
7584
|
+
_a$7[exports.ShaderType.vertex] = {
|
|
7513
7585
|
in: 'attribute',
|
|
7514
7586
|
out: 'varying',
|
|
7515
7587
|
},
|
|
7516
|
-
_a$
|
|
7588
|
+
_a$7[exports.ShaderType.fragment] = {
|
|
7517
7589
|
in: 'varying',
|
|
7518
7590
|
},
|
|
7519
|
-
_a$
|
|
7591
|
+
_a$7);
|
|
7520
7592
|
/**
|
|
7521
7593
|
* 生成 shader,检测到 WebGL1 上下文会降级
|
|
7522
7594
|
* @param marcos - 宏定义数组
|
|
@@ -7957,7 +8029,7 @@ function loadMipmapImage(pointer, bins) {
|
|
|
7957
8029
|
var EffectsObject = /** @class */ (function () {
|
|
7958
8030
|
function EffectsObject(engine) {
|
|
7959
8031
|
this.engine = engine;
|
|
7960
|
-
this.guid = generateGUID();
|
|
8032
|
+
this.guid = generateGUID$1();
|
|
7961
8033
|
this.taggedProperties = {};
|
|
7962
8034
|
this.engine.addInstance(this);
|
|
7963
8035
|
}
|
|
@@ -8654,13 +8726,49 @@ exports.GLSLVersion = void 0;
|
|
|
8654
8726
|
GLSLVersion["GLSL1"] = "100";
|
|
8655
8727
|
GLSLVersion["GLSL3"] = "300 es";
|
|
8656
8728
|
})(exports.GLSLVersion || (exports.GLSLVersion = {}));
|
|
8657
|
-
var
|
|
8658
|
-
__extends(
|
|
8659
|
-
function
|
|
8729
|
+
var ShaderVariant = /** @class */ (function (_super) {
|
|
8730
|
+
__extends(ShaderVariant, _super);
|
|
8731
|
+
function ShaderVariant(engine, source) {
|
|
8660
8732
|
var _this = _super.call(this, engine) || this;
|
|
8661
8733
|
_this.source = source;
|
|
8662
8734
|
return _this;
|
|
8663
8735
|
}
|
|
8736
|
+
return ShaderVariant;
|
|
8737
|
+
}(EffectsObject));
|
|
8738
|
+
var Shader = /** @class */ (function (_super) {
|
|
8739
|
+
__extends(Shader, _super);
|
|
8740
|
+
function Shader() {
|
|
8741
|
+
return _super !== null && _super.apply(this, arguments) || this;
|
|
8742
|
+
}
|
|
8743
|
+
Shader.prototype.createVariant = function (macros) {
|
|
8744
|
+
var e_1, _a;
|
|
8745
|
+
var shaderMacros = [];
|
|
8746
|
+
if (macros) {
|
|
8747
|
+
try {
|
|
8748
|
+
for (var _b = __values$1(Object.keys(macros)), _c = _b.next(); !_c.done; _c = _b.next()) {
|
|
8749
|
+
var key = _c.value;
|
|
8750
|
+
shaderMacros.push([key, macros[key]]);
|
|
8751
|
+
}
|
|
8752
|
+
}
|
|
8753
|
+
catch (e_1_1) { e_1 = { error: e_1_1 }; }
|
|
8754
|
+
finally {
|
|
8755
|
+
try {
|
|
8756
|
+
if (_c && !_c.done && (_a = _b.return)) _a.call(_b);
|
|
8757
|
+
}
|
|
8758
|
+
finally { if (e_1) throw e_1.error; }
|
|
8759
|
+
}
|
|
8760
|
+
}
|
|
8761
|
+
var shaderVariant = this.engine.getShaderLibrary().createShader(this.shaderData, shaderMacros);
|
|
8762
|
+
shaderVariant.shader = this;
|
|
8763
|
+
return shaderVariant;
|
|
8764
|
+
};
|
|
8765
|
+
Shader.prototype.fromData = function (data) {
|
|
8766
|
+
_super.prototype.fromData.call(this, data);
|
|
8767
|
+
this.shaderData = data;
|
|
8768
|
+
};
|
|
8769
|
+
Shader = __decorate([
|
|
8770
|
+
effectsClass('Shader')
|
|
8771
|
+
], Shader);
|
|
8664
8772
|
return Shader;
|
|
8665
8773
|
}(EffectsObject));
|
|
8666
8774
|
|
|
@@ -8673,8 +8781,8 @@ function createCopyShader(level, writeDepth) {
|
|
|
8673
8781
|
var version = webgl2 ? '#version 300 es' : '';
|
|
8674
8782
|
return {
|
|
8675
8783
|
name: EFFECTS_COPY_MESH_NAME,
|
|
8676
|
-
vertex:
|
|
8677
|
-
fragment:
|
|
8784
|
+
vertex: version + '\n' + COPY_VERTEX_SHADER,
|
|
8785
|
+
fragment: version + '\n' + COPY_FRAGMENT_SHADER,
|
|
8678
8786
|
glslVersion: webgl2 ? exports.GLSLVersion.GLSL3 : exports.GLSLVersion.GLSL1,
|
|
8679
8787
|
marcos: [
|
|
8680
8788
|
['WEBGL2', !!webgl2],
|
|
@@ -8806,13 +8914,13 @@ var SemanticMap = /** @class */ (function () {
|
|
|
8806
8914
|
return SemanticMap;
|
|
8807
8915
|
}());
|
|
8808
8916
|
|
|
8809
|
-
var _a$
|
|
8810
|
-
var BYTES_TYPE_MAP = (_a$
|
|
8811
|
-
_a$
|
|
8812
|
-
_a$
|
|
8813
|
-
_a$
|
|
8814
|
-
_a$
|
|
8815
|
-
_a$
|
|
8917
|
+
var _a$6;
|
|
8918
|
+
var BYTES_TYPE_MAP = (_a$6 = {},
|
|
8919
|
+
_a$6[glContext.FLOAT] = Float32Array.BYTES_PER_ELEMENT,
|
|
8920
|
+
_a$6[glContext.INT] = Int32Array.BYTES_PER_ELEMENT,
|
|
8921
|
+
_a$6[glContext.SHORT] = Int16Array.BYTES_PER_ELEMENT,
|
|
8922
|
+
_a$6[glContext.BYTE] = Int8Array.BYTES_PER_ELEMENT,
|
|
8923
|
+
_a$6);
|
|
8816
8924
|
/**
|
|
8817
8925
|
* Geometry 抽象类
|
|
8818
8926
|
*/
|
|
@@ -9381,7 +9489,7 @@ var RenderPass = /** @class */ (function () {
|
|
|
9381
9489
|
RenderPass.prototype.setMeshes = function (meshes) {
|
|
9382
9490
|
var _a;
|
|
9383
9491
|
this.meshes.length = 0;
|
|
9384
|
-
(_a = this.meshes).splice.apply(_a, __spreadArray$
|
|
9492
|
+
(_a = this.meshes).splice.apply(_a, __spreadArray$3([0, 0], __read$3(meshes), false));
|
|
9385
9493
|
sortByOrder(this.meshes, this.meshOrder);
|
|
9386
9494
|
return this.meshes;
|
|
9387
9495
|
};
|
|
@@ -11575,9 +11683,6 @@ var AssetLoader = /** @class */ (function () {
|
|
|
11575
11683
|
case exports.DataType.Texture:
|
|
11576
11684
|
effectsObject = Texture.create(this.engine, effectsObjectData);
|
|
11577
11685
|
return effectsObject;
|
|
11578
|
-
case exports.DataType.Shader:
|
|
11579
|
-
effectsObject = this.engine.getShaderLibrary().createShader(effectsObjectData);
|
|
11580
|
-
break;
|
|
11581
11686
|
default: {
|
|
11582
11687
|
var classConstructor = AssetLoader.getClass(effectsObjectData.dataType);
|
|
11583
11688
|
if (classConstructor) {
|
|
@@ -11630,9 +11735,6 @@ var AssetLoader = /** @class */ (function () {
|
|
|
11630
11735
|
case exports.DataType.Texture:
|
|
11631
11736
|
effectsObject = Texture.create(this.engine, effectsObjectData);
|
|
11632
11737
|
return [2 /*return*/, effectsObject];
|
|
11633
|
-
case exports.DataType.Shader:
|
|
11634
|
-
effectsObject = this.engine.getShaderLibrary().createShader(effectsObjectData);
|
|
11635
|
-
break;
|
|
11636
11738
|
default: {
|
|
11637
11739
|
classConstructor = AssetLoader.getClass(effectsObjectData.dataType);
|
|
11638
11740
|
if (classConstructor) {
|
|
@@ -11845,7 +11947,7 @@ function calculateTranslation(out, target, acc, time, duration, posData, velData
|
|
|
11845
11947
|
return ret;
|
|
11846
11948
|
}
|
|
11847
11949
|
|
|
11848
|
-
var _a$
|
|
11950
|
+
var _a$5;
|
|
11849
11951
|
function ensureVec3(num) {
|
|
11850
11952
|
return Array.isArray(num) ? [num[0], num[1], num[2]] : [0, 0, 0];
|
|
11851
11953
|
}
|
|
@@ -11868,7 +11970,7 @@ function vecNormalize(out, a) {
|
|
|
11868
11970
|
out = [];
|
|
11869
11971
|
}
|
|
11870
11972
|
var ap = a;
|
|
11871
|
-
var sum = Math.hypot.apply(Math, __spreadArray$
|
|
11973
|
+
var sum = Math.hypot.apply(Math, __spreadArray$3([], __read$3(ap), false));
|
|
11872
11974
|
if (sum === 0) {
|
|
11873
11975
|
return vecAssign(out, ap, ap.length);
|
|
11874
11976
|
}
|
|
@@ -11899,17 +12001,17 @@ function vecMulCombine(out, a, b) {
|
|
|
11899
12001
|
}
|
|
11900
12002
|
return out;
|
|
11901
12003
|
}
|
|
11902
|
-
var particleOriginTranslateMap = (_a$
|
|
11903
|
-
_a$
|
|
11904
|
-
_a$
|
|
11905
|
-
_a$
|
|
11906
|
-
_a$
|
|
11907
|
-
_a$
|
|
11908
|
-
_a$
|
|
11909
|
-
_a$
|
|
11910
|
-
_a$
|
|
11911
|
-
_a$
|
|
11912
|
-
_a$
|
|
12004
|
+
var particleOriginTranslateMap$1 = (_a$5 = {},
|
|
12005
|
+
_a$5[ParticleOrigin$1.PARTICLE_ORIGIN_CENTER] = [0, 0],
|
|
12006
|
+
_a$5[ParticleOrigin$1.PARTICLE_ORIGIN_CENTER_BOTTOM] = [0, -0.5],
|
|
12007
|
+
_a$5[ParticleOrigin$1.PARTICLE_ORIGIN_CENTER_TOP] = [0, 0.5],
|
|
12008
|
+
_a$5[ParticleOrigin$1.PARTICLE_ORIGIN_LEFT_TOP] = [-0.5, 0.5],
|
|
12009
|
+
_a$5[ParticleOrigin$1.PARTICLE_ORIGIN_LEFT_CENTER] = [-0.5, 0],
|
|
12010
|
+
_a$5[ParticleOrigin$1.PARTICLE_ORIGIN_LEFT_BOTTOM] = [-0.5, -0.5],
|
|
12011
|
+
_a$5[ParticleOrigin$1.PARTICLE_ORIGIN_RIGHT_CENTER] = [0.5, 0],
|
|
12012
|
+
_a$5[ParticleOrigin$1.PARTICLE_ORIGIN_RIGHT_BOTTOM] = [0.5, -0.5],
|
|
12013
|
+
_a$5[ParticleOrigin$1.PARTICLE_ORIGIN_RIGHT_TOP] = [0.5, 0.5],
|
|
12014
|
+
_a$5);
|
|
11913
12015
|
function nearestPowerOfTwo(value) {
|
|
11914
12016
|
return Math.pow(2, Math.round(Math.log(value) / Math.LN2));
|
|
11915
12017
|
}
|
|
@@ -11934,7 +12036,7 @@ function trianglesFromRect(position, halfWidth, halfHeight) {
|
|
|
11934
12036
|
];
|
|
11935
12037
|
}
|
|
11936
12038
|
|
|
11937
|
-
var _a$
|
|
12039
|
+
var _a$4;
|
|
11938
12040
|
var NOT_IMPLEMENT = 'not_implement';
|
|
11939
12041
|
var ValueGetter = /** @class */ (function () {
|
|
11940
12042
|
function ValueGetter(arg) {
|
|
@@ -12442,50 +12544,50 @@ var BezierSegments = /** @class */ (function (_super) {
|
|
|
12442
12544
|
};
|
|
12443
12545
|
return BezierSegments;
|
|
12444
12546
|
}(PathSegments));
|
|
12445
|
-
var map$1 = (_a$
|
|
12446
|
-
_a$
|
|
12547
|
+
var map$1 = (_a$4 = {},
|
|
12548
|
+
_a$4[ValueType$1.RANDOM] = function (props) {
|
|
12447
12549
|
if (props[0] instanceof Array) {
|
|
12448
12550
|
return new RandomVectorValue(props);
|
|
12449
12551
|
}
|
|
12450
12552
|
return new RandomValue(props);
|
|
12451
12553
|
},
|
|
12452
|
-
_a$
|
|
12554
|
+
_a$4[ValueType$1.CONSTANT] = function (props) {
|
|
12453
12555
|
return new StaticValue(props);
|
|
12454
12556
|
},
|
|
12455
|
-
_a$
|
|
12557
|
+
_a$4[ValueType$1.CONSTANT_VEC2] = function (props) {
|
|
12456
12558
|
return new StaticValue(props);
|
|
12457
12559
|
},
|
|
12458
|
-
_a$
|
|
12560
|
+
_a$4[ValueType$1.CONSTANT_VEC3] = function (props) {
|
|
12459
12561
|
return new StaticValue(props);
|
|
12460
12562
|
},
|
|
12461
|
-
_a$
|
|
12563
|
+
_a$4[ValueType$1.CONSTANT_VEC4] = function (props) {
|
|
12462
12564
|
return new StaticValue(props);
|
|
12463
12565
|
},
|
|
12464
|
-
_a$
|
|
12566
|
+
_a$4[ValueType$1.CURVE] = function (props) {
|
|
12465
12567
|
return new CurveValue(props);
|
|
12466
12568
|
},
|
|
12467
|
-
_a$
|
|
12569
|
+
_a$4[ValueType$1.RGBA_COLOR] = function (props) {
|
|
12468
12570
|
return new StaticValue(props);
|
|
12469
12571
|
},
|
|
12470
|
-
_a$
|
|
12572
|
+
_a$4[ValueType$1.COLORS] = function (props) {
|
|
12471
12573
|
return new RandomSetValue(props.map(function (c) { return colorToArr$1(c, false); }));
|
|
12472
12574
|
},
|
|
12473
|
-
_a$
|
|
12575
|
+
_a$4[ValueType$1.LINE] = function (props) {
|
|
12474
12576
|
if (props.length === 2 && props[0][0] === 0 && props[1][0] === 1) {
|
|
12475
12577
|
return new LinearValue([props[0][1], props[1][1]]);
|
|
12476
12578
|
}
|
|
12477
12579
|
return new LineSegments(props);
|
|
12478
12580
|
},
|
|
12479
|
-
_a$
|
|
12581
|
+
_a$4[ValueType$1.GRADIENT_COLOR] = function (props) {
|
|
12480
12582
|
return new GradientValue(props);
|
|
12481
12583
|
},
|
|
12482
|
-
_a$
|
|
12584
|
+
_a$4[ValueType$1.LINEAR_PATH] = function (pros) {
|
|
12483
12585
|
return new PathSegments(pros);
|
|
12484
12586
|
},
|
|
12485
|
-
_a$
|
|
12587
|
+
_a$4[ValueType$1.BEZIER_PATH] = function (pros) {
|
|
12486
12588
|
return new BezierSegments(pros);
|
|
12487
12589
|
},
|
|
12488
|
-
_a$
|
|
12590
|
+
_a$4);
|
|
12489
12591
|
function createValueGetter(args) {
|
|
12490
12592
|
if (!args || !isNaN(+args)) {
|
|
12491
12593
|
return new StaticValue(args || 0);
|
|
@@ -13436,13 +13538,13 @@ var InteractMesh = /** @class */ (function () {
|
|
|
13436
13538
|
['ENV_EDITOR', ((_a = this.engine.renderer) === null || _a === void 0 ? void 0 : _a.env) === PLAYER_OPTIONS_ENV_EDITOR],
|
|
13437
13539
|
];
|
|
13438
13540
|
var color = createValueGetter(this.color).getValue(0);
|
|
13439
|
-
var level = this.engine.gpuCapability.level;
|
|
13440
13541
|
var materialProps = {
|
|
13441
13542
|
shader: {
|
|
13442
|
-
vertex:
|
|
13443
|
-
fragment:
|
|
13543
|
+
vertex: vertex,
|
|
13544
|
+
fragment: fragment,
|
|
13444
13545
|
glslVersion: exports.GLSLVersion.GLSL1,
|
|
13445
13546
|
cacheId: "".concat(rendererOptions.cachePrefix, "_effects_interact"),
|
|
13547
|
+
marcos: marcos,
|
|
13446
13548
|
},
|
|
13447
13549
|
uniformSemantics: {
|
|
13448
13550
|
effects_MatrixVP: 'VIEWPROJECTION',
|
|
@@ -13516,11 +13618,11 @@ var InteractComponent = /** @class */ (function (_super) {
|
|
|
13516
13618
|
}
|
|
13517
13619
|
InteractComponent_1 = InteractComponent;
|
|
13518
13620
|
InteractComponent.prototype.start = function () {
|
|
13519
|
-
var
|
|
13621
|
+
var _this = this;
|
|
13520
13622
|
var options = this.item.props.content.options;
|
|
13521
|
-
var env =
|
|
13623
|
+
var env = this.item.engine.renderer.env;
|
|
13522
13624
|
var composition = this.item.composition;
|
|
13523
|
-
var
|
|
13625
|
+
var _a = this.interactData.options, type = _a.type, showPreview = _a.showPreview;
|
|
13524
13626
|
if (type === InteractType$1.CLICK) {
|
|
13525
13627
|
this.clickable = true;
|
|
13526
13628
|
if (showPreview && env === PLAYER_OPTIONS_ENV_EDITOR) {
|
|
@@ -13528,7 +13630,8 @@ var InteractComponent = /** @class */ (function (_super) {
|
|
|
13528
13630
|
this.previewContent = new InteractMesh(this.item.props.content, rendererOptions, this.transform, this.engine);
|
|
13529
13631
|
}
|
|
13530
13632
|
}
|
|
13531
|
-
|
|
13633
|
+
composition.addInteractiveItem(this.item, options.type);
|
|
13634
|
+
this.item.onEnd = function () { return composition.removeInteractiveItem(_this.item, options.type); };
|
|
13532
13635
|
if (options.type === InteractType$1.DRAG) {
|
|
13533
13636
|
if (env !== PLAYER_OPTIONS_ENV_EDITOR || options.enableInEditor) {
|
|
13534
13637
|
composition.event && this.beginDragTarget(options, composition.event);
|
|
@@ -13721,8 +13824,8 @@ function spriteMeshShaderFromFilter(level, options) {
|
|
|
13721
13824
|
var fragment = wireframe ? itemFrameFrag : itemFrag.replace(/#pragma\s+FILTER_FRAG/, '');
|
|
13722
13825
|
var vertex = itemVert.replace(/#pragma\s+FILTER_VERT/, 'vec4 filterMain(float t,vec4 pos){return effects_MatrixVP * pos;}');
|
|
13723
13826
|
return {
|
|
13724
|
-
fragment:
|
|
13725
|
-
vertex:
|
|
13827
|
+
fragment: fragment,
|
|
13828
|
+
vertex: vertex,
|
|
13726
13829
|
glslVersion: level === 1 ? exports.GLSLVersion.GLSL1 : exports.GLSLVersion.GLSL3,
|
|
13727
13830
|
marcos: marcos,
|
|
13728
13831
|
shared: true,
|
|
@@ -15202,8 +15305,8 @@ var ParticleMesh = /** @class */ (function () {
|
|
|
15202
15305
|
var originalVertex = "#define LOOKUP_TEXTURE_CURVE ".concat(vertex_lookup_texture, "\n").concat(particleVert);
|
|
15203
15306
|
var vertex = originalVertex;
|
|
15204
15307
|
var shader = {
|
|
15205
|
-
fragment:
|
|
15206
|
-
vertex:
|
|
15308
|
+
fragment: fragment,
|
|
15309
|
+
vertex: vertex,
|
|
15207
15310
|
glslVersion: level === 1 ? exports.GLSLVersion.GLSL1 : exports.GLSLVersion.GLSL3,
|
|
15208
15311
|
shared: true,
|
|
15209
15312
|
cacheId: shaderCache,
|
|
@@ -15758,8 +15861,8 @@ var TrailMesh = /** @class */ (function () {
|
|
|
15758
15861
|
else {
|
|
15759
15862
|
uniformValues.uVCurveValues = CurveValue.getAllData(keyFrameMeta);
|
|
15760
15863
|
}
|
|
15761
|
-
var vertex =
|
|
15762
|
-
var fragment =
|
|
15864
|
+
var vertex = trailVert;
|
|
15865
|
+
var fragment = particleFrag;
|
|
15763
15866
|
var mtl = ({
|
|
15764
15867
|
shader: {
|
|
15765
15868
|
vertex: vertex,
|
|
@@ -16446,7 +16549,7 @@ var TextureShape = /** @class */ (function () {
|
|
|
16446
16549
|
return TextureShape;
|
|
16447
16550
|
}());
|
|
16448
16551
|
|
|
16449
|
-
var _a$
|
|
16552
|
+
var _a$3;
|
|
16450
16553
|
var ShapeNone = /** @class */ (function () {
|
|
16451
16554
|
function ShapeNone() {
|
|
16452
16555
|
}
|
|
@@ -16458,18 +16561,18 @@ var ShapeNone = /** @class */ (function () {
|
|
|
16458
16561
|
};
|
|
16459
16562
|
return ShapeNone;
|
|
16460
16563
|
}());
|
|
16461
|
-
var map = (_a$
|
|
16462
|
-
_a$
|
|
16463
|
-
_a$
|
|
16464
|
-
_a$
|
|
16465
|
-
_a$
|
|
16466
|
-
_a$
|
|
16467
|
-
_a$
|
|
16468
|
-
_a$
|
|
16469
|
-
_a$
|
|
16470
|
-
_a$
|
|
16471
|
-
_a$
|
|
16472
|
-
_a$
|
|
16564
|
+
var map = (_a$3 = {},
|
|
16565
|
+
_a$3[ShapeType$1.NONE] = ShapeNone,
|
|
16566
|
+
_a$3[ShapeType$1.CONE] = Cone,
|
|
16567
|
+
_a$3[ShapeType$1.SPHERE] = Sphere,
|
|
16568
|
+
_a$3[ShapeType$1.HEMISPHERE] = Hemisphere,
|
|
16569
|
+
_a$3[ShapeType$1.CIRCLE] = Circle,
|
|
16570
|
+
_a$3[ShapeType$1.DONUT] = Donut,
|
|
16571
|
+
_a$3[ShapeType$1.RECTANGLE] = Rectangle,
|
|
16572
|
+
_a$3[ShapeType$1.EDGE] = Edge,
|
|
16573
|
+
_a$3[ShapeType$1.RECTANGLE_EDGE] = RectangleEdge,
|
|
16574
|
+
_a$3[ShapeType$1.TEXTURE] = TextureShape,
|
|
16575
|
+
_a$3);
|
|
16473
16576
|
function createShape(shapeOptions) {
|
|
16474
16577
|
if (!shapeOptions) {
|
|
16475
16578
|
return new ShapeNone();
|
|
@@ -17798,7 +17901,7 @@ var ParticleSystem = /** @class */ (function (_super) {
|
|
|
17798
17901
|
}));
|
|
17799
17902
|
p.delay += meshTime;
|
|
17800
17903
|
cursor++;
|
|
17801
|
-
(_a = p.transform).translate.apply(_a, __spreadArray$
|
|
17904
|
+
(_a = p.transform).translate.apply(_a, __spreadArray$3([], __read$3(burstOffset), false));
|
|
17802
17905
|
this.addParticle(p, maxCount_1);
|
|
17803
17906
|
}
|
|
17804
17907
|
}
|
|
@@ -18570,7 +18673,9 @@ var TextStyle = /** @class */ (function () {
|
|
|
18570
18673
|
this.fontOffset = 0;
|
|
18571
18674
|
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;
|
|
18572
18675
|
this.textColor = textColor;
|
|
18676
|
+
//@ts-expect-error
|
|
18573
18677
|
this.textWeight = fontWeight;
|
|
18678
|
+
//@ts-expect-error
|
|
18574
18679
|
this.fontStyle = fontStyle;
|
|
18575
18680
|
this.fontFamily = fontFamily;
|
|
18576
18681
|
this.fontSize = fontSize; // 暂时取消字号限制 Math.min(fontSize, this.maxFontSize);
|
|
@@ -20638,7 +20743,10 @@ var VFXItem = /** @class */ (function (_super) {
|
|
|
20638
20743
|
try {
|
|
20639
20744
|
for (var _e = __values$1(this.children), _f = _e.next(); !_f.done; _f = _e.next()) {
|
|
20640
20745
|
var child = _f.value;
|
|
20641
|
-
|
|
20746
|
+
var res = child.find(name);
|
|
20747
|
+
if (res) {
|
|
20748
|
+
return res;
|
|
20749
|
+
}
|
|
20642
20750
|
}
|
|
20643
20751
|
}
|
|
20644
20752
|
catch (e_4_1) { e_4 = { error: e_4_1 }; }
|
|
@@ -20655,6 +20763,7 @@ var VFXItem = /** @class */ (function (_super) {
|
|
|
20655
20763
|
_super.prototype.fromData.call(this, data);
|
|
20656
20764
|
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;
|
|
20657
20765
|
this.props = data;
|
|
20766
|
+
//@ts-expect-error
|
|
20658
20767
|
this.type = data.type;
|
|
20659
20768
|
this.id = id.toString(); // TODO 老数据 id 是 number,需要转换
|
|
20660
20769
|
this.name = name;
|
|
@@ -20750,10 +20859,10 @@ var VFXItem = /** @class */ (function (_super) {
|
|
|
20750
20859
|
};
|
|
20751
20860
|
VFXItem.prototype.translateByPixel = function (x, y) {
|
|
20752
20861
|
if (this.composition) {
|
|
20862
|
+
// @ts-expect-error
|
|
20863
|
+
var _a = this.composition.renderer.canvas.getBoundingClientRect(), width = _a.width, height = _a.height;
|
|
20753
20864
|
var z = this.transform.getWorldPosition().z;
|
|
20754
|
-
var
|
|
20755
|
-
var width = this.composition.renderer.getWidth() / 2;
|
|
20756
|
-
var height = this.composition.renderer.getHeight() / 2;
|
|
20865
|
+
var _b = this.composition.camera.getInverseVPRatio(z), rx = _b.x, ry = _b.y;
|
|
20757
20866
|
this.transform.translate(2 * x * rx / width, -2 * y * ry / height, 0);
|
|
20758
20867
|
}
|
|
20759
20868
|
};
|
|
@@ -20858,7 +20967,6 @@ function createVFXItem(props, composition) {
|
|
|
20858
20967
|
if (!pluginName) {
|
|
20859
20968
|
switch (type) {
|
|
20860
20969
|
case ItemType$1.null:
|
|
20861
|
-
case ItemType$1.base:
|
|
20862
20970
|
pluginName = 'cal';
|
|
20863
20971
|
break;
|
|
20864
20972
|
case ItemType$1.sprite:
|
|
@@ -20979,7 +21087,7 @@ var PluginSystem = /** @class */ (function () {
|
|
|
20979
21087
|
plugin = plugins[i];
|
|
20980
21088
|
ctrl = pluginLoaderMap[plugin.name];
|
|
20981
21089
|
if (name in ctrl) {
|
|
20982
|
-
pendings.push(Promise.resolve(ctrl[name].apply(ctrl, __spreadArray$
|
|
21090
|
+
pendings.push(Promise.resolve(ctrl[name].apply(ctrl, __spreadArray$3([], __read$3(args), false))));
|
|
20983
21091
|
}
|
|
20984
21092
|
}
|
|
20985
21093
|
return [2 /*return*/, Promise.all(pendings)];
|
|
@@ -21024,9 +21132,74 @@ function getPluginUsageInfo(name) {
|
|
|
21024
21132
|
* Name: @galacean/effects-specification
|
|
21025
21133
|
* Description: Galacean Effects JSON Specification
|
|
21026
21134
|
* Author: Ant Group CO., Ltd.
|
|
21027
|
-
* Version:
|
|
21135
|
+
* Version: v2.0.0-alpha.3
|
|
21136
|
+
*/
|
|
21137
|
+
|
|
21138
|
+
const randomUUID = typeof crypto !== 'undefined' && crypto.randomUUID && crypto.randomUUID.bind(crypto);
|
|
21139
|
+
var native = {
|
|
21140
|
+
randomUUID
|
|
21141
|
+
};
|
|
21142
|
+
|
|
21143
|
+
// Unique ID creation requires a high quality random # generator. In the browser we therefore
|
|
21144
|
+
// require the crypto API and do not support built-in fallback to lower quality random number
|
|
21145
|
+
// generators (like Math.random()).
|
|
21146
|
+
let getRandomValues;
|
|
21147
|
+
const rnds8 = new Uint8Array(16);
|
|
21148
|
+
function rng() {
|
|
21149
|
+
// lazy load so that environments that need to polyfill have a chance to do so
|
|
21150
|
+
if (!getRandomValues) {
|
|
21151
|
+
// getRandomValues needs to be invoked in a context where "this" is a Crypto implementation.
|
|
21152
|
+
getRandomValues = typeof crypto !== 'undefined' && crypto.getRandomValues && crypto.getRandomValues.bind(crypto);
|
|
21153
|
+
|
|
21154
|
+
if (!getRandomValues) {
|
|
21155
|
+
throw new Error('crypto.getRandomValues() not supported. See https://github.com/uuidjs/uuid#getrandomvalues-not-supported');
|
|
21156
|
+
}
|
|
21157
|
+
}
|
|
21158
|
+
|
|
21159
|
+
return getRandomValues(rnds8);
|
|
21160
|
+
}
|
|
21161
|
+
|
|
21162
|
+
/**
|
|
21163
|
+
* Convert array of 16 byte values to UUID string format of the form:
|
|
21164
|
+
* XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX
|
|
21028
21165
|
*/
|
|
21029
21166
|
|
|
21167
|
+
const byteToHex = [];
|
|
21168
|
+
|
|
21169
|
+
for (let i = 0; i < 256; ++i) {
|
|
21170
|
+
byteToHex.push((i + 0x100).toString(16).slice(1));
|
|
21171
|
+
}
|
|
21172
|
+
|
|
21173
|
+
function unsafeStringify(arr, offset = 0) {
|
|
21174
|
+
// Note: Be careful editing this code! It's been tuned for performance
|
|
21175
|
+
// and works in ways you may not expect. See https://github.com/uuidjs/uuid/pull/434
|
|
21176
|
+
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]];
|
|
21177
|
+
}
|
|
21178
|
+
|
|
21179
|
+
function v4(options, buf, offset) {
|
|
21180
|
+
if (native.randomUUID && !buf && !options) {
|
|
21181
|
+
return native.randomUUID();
|
|
21182
|
+
}
|
|
21183
|
+
|
|
21184
|
+
options = options || {};
|
|
21185
|
+
const rnds = options.random || (options.rng || rng)(); // Per 4.4, set bits for version and `clock_seq_hi_and_reserved`
|
|
21186
|
+
|
|
21187
|
+
rnds[6] = rnds[6] & 0x0f | 0x40;
|
|
21188
|
+
rnds[8] = rnds[8] & 0x3f | 0x80; // Copy bytes to buffer, if provided
|
|
21189
|
+
|
|
21190
|
+
if (buf) {
|
|
21191
|
+
offset = offset || 0;
|
|
21192
|
+
|
|
21193
|
+
for (let i = 0; i < 16; ++i) {
|
|
21194
|
+
buf[offset + i] = rnds[i];
|
|
21195
|
+
}
|
|
21196
|
+
|
|
21197
|
+
return buf;
|
|
21198
|
+
}
|
|
21199
|
+
|
|
21200
|
+
return unsafeStringify(rnds);
|
|
21201
|
+
}
|
|
21202
|
+
|
|
21030
21203
|
/*********************************************/
|
|
21031
21204
|
/* 元素属性参数类型 */
|
|
21032
21205
|
/*********************************************/
|
|
@@ -21289,6 +21462,10 @@ var ItemType;
|
|
|
21289
21462
|
* 天空盒元素
|
|
21290
21463
|
*/
|
|
21291
21464
|
ItemType["skybox"] = "skybox";
|
|
21465
|
+
/**
|
|
21466
|
+
* 特效元素
|
|
21467
|
+
*/
|
|
21468
|
+
ItemType["effect"] = "effect";
|
|
21292
21469
|
})(ItemType || (ItemType = {}));
|
|
21293
21470
|
/**
|
|
21294
21471
|
* 渲染模式
|
|
@@ -21401,6 +21578,10 @@ var CompositionEndBehavior;
|
|
|
21401
21578
|
* 销毁并保留最后一帧
|
|
21402
21579
|
*/
|
|
21403
21580
|
CompositionEndBehavior[CompositionEndBehavior["pause_destroy"] = END_BEHAVIOR_PAUSE_AND_DESTROY] = "pause_destroy";
|
|
21581
|
+
/**
|
|
21582
|
+
* 冻结
|
|
21583
|
+
*/
|
|
21584
|
+
CompositionEndBehavior[CompositionEndBehavior["freeze"] = END_BEHAVIOR_FREEZE] = "freeze";
|
|
21404
21585
|
})(CompositionEndBehavior || (CompositionEndBehavior = {}));
|
|
21405
21586
|
|
|
21406
21587
|
/*********************************************/
|
|
@@ -21537,12 +21718,38 @@ var ShapeArcMode;
|
|
|
21537
21718
|
ShapeArcMode[ShapeArcMode["UNIFORM_BURST"] = 3] = "UNIFORM_BURST";
|
|
21538
21719
|
})(ShapeArcMode || (ShapeArcMode = {}));
|
|
21539
21720
|
|
|
21721
|
+
var LightType;
|
|
21722
|
+
(function (LightType) {
|
|
21723
|
+
/**
|
|
21724
|
+
* 点光源
|
|
21725
|
+
*/
|
|
21726
|
+
LightType["point"] = "point";
|
|
21727
|
+
/**
|
|
21728
|
+
* 聚光灯
|
|
21729
|
+
*/
|
|
21730
|
+
LightType["spot"] = "spot";
|
|
21731
|
+
/**
|
|
21732
|
+
* 方向光
|
|
21733
|
+
*/
|
|
21734
|
+
LightType["directional"] = "directional";
|
|
21735
|
+
/**
|
|
21736
|
+
* 环境光
|
|
21737
|
+
*/
|
|
21738
|
+
LightType["ambient"] = "ambient";
|
|
21739
|
+
})(LightType || (LightType = {}));
|
|
21740
|
+
|
|
21540
21741
|
var ModelBoundingType;
|
|
21541
21742
|
(function (ModelBoundingType) {
|
|
21542
21743
|
ModelBoundingType[ModelBoundingType["box"] = 2] = "box";
|
|
21543
21744
|
ModelBoundingType[ModelBoundingType["sphere"] = 3] = "sphere";
|
|
21544
21745
|
})(ModelBoundingType || (ModelBoundingType = {}));
|
|
21545
21746
|
|
|
21747
|
+
var CameraType;
|
|
21748
|
+
(function (CameraType) {
|
|
21749
|
+
CameraType["orthographic"] = "orthographic";
|
|
21750
|
+
CameraType["perspective"] = "perspective";
|
|
21751
|
+
})(CameraType || (CameraType = {}));
|
|
21752
|
+
|
|
21546
21753
|
// 材质类型
|
|
21547
21754
|
var MaterialType;
|
|
21548
21755
|
(function (MaterialType) {
|
|
@@ -21688,6 +21895,28 @@ var FontStyle;
|
|
|
21688
21895
|
FontStyle["oblique"] = "oblique";
|
|
21689
21896
|
})(FontStyle || (FontStyle = {}));
|
|
21690
21897
|
|
|
21898
|
+
var DataType;
|
|
21899
|
+
(function (DataType) {
|
|
21900
|
+
DataType["VFXItemData"] = "VFXItemData";
|
|
21901
|
+
DataType["EffectComponent"] = "EffectComponent";
|
|
21902
|
+
DataType["Material"] = "Material";
|
|
21903
|
+
DataType["Shader"] = "Shader";
|
|
21904
|
+
DataType["SpriteComponent"] = "SpriteComponent";
|
|
21905
|
+
DataType["ParticleSystem"] = "ParticleSystem";
|
|
21906
|
+
DataType["InteractComponent"] = "InteractComponent";
|
|
21907
|
+
DataType["CameraController"] = "CameraController";
|
|
21908
|
+
DataType["Geometry"] = "Geometry";
|
|
21909
|
+
DataType["Texture"] = "Texture";
|
|
21910
|
+
DataType["TextComponent"] = "TextComponent";
|
|
21911
|
+
// FIXME: 先完成ECS的场景转换,后面移到spec中
|
|
21912
|
+
DataType["MeshComponent"] = "MeshComponent";
|
|
21913
|
+
DataType["SkyboxComponent"] = "SkyboxComponent";
|
|
21914
|
+
DataType["LightComponent"] = "LightComponent";
|
|
21915
|
+
DataType["CameraComponent"] = "CameraComponent";
|
|
21916
|
+
DataType["ModelPluginComponent"] = "ModelPluginComponent";
|
|
21917
|
+
DataType["TreeComponent"] = "TreeComponent";
|
|
21918
|
+
})(DataType || (DataType = {}));
|
|
21919
|
+
|
|
21691
21920
|
/******************************************************************************
|
|
21692
21921
|
Copyright (c) Microsoft Corporation.
|
|
21693
21922
|
|
|
@@ -21743,11 +21972,22 @@ function __read(o, n) {
|
|
|
21743
21972
|
return ar;
|
|
21744
21973
|
}
|
|
21745
21974
|
|
|
21975
|
+
function __spreadArray(to, from, pack) {
|
|
21976
|
+
if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {
|
|
21977
|
+
if (ar || !(i in from)) {
|
|
21978
|
+
if (!ar) ar = Array.prototype.slice.call(from, 0, i);
|
|
21979
|
+
ar[i] = from[i];
|
|
21980
|
+
}
|
|
21981
|
+
}
|
|
21982
|
+
return to.concat(ar || Array.prototype.slice.call(from));
|
|
21983
|
+
}
|
|
21984
|
+
|
|
21746
21985
|
typeof SuppressedError === "function" ? SuppressedError : function (error, suppressed, message) {
|
|
21747
21986
|
var e = new Error(message);
|
|
21748
21987
|
return e.name = "SuppressedError", e.error = error, e.suppressed = suppressed, e;
|
|
21749
21988
|
};
|
|
21750
21989
|
|
|
21990
|
+
var _a$2;
|
|
21751
21991
|
function arrAdd(arr, item) {
|
|
21752
21992
|
if (!arr.includes(item)) {
|
|
21753
21993
|
arr.push(item);
|
|
@@ -21983,6 +22223,34 @@ function rotationZYXFromQuat(out, quat) {
|
|
|
21983
22223
|
}
|
|
21984
22224
|
return out;
|
|
21985
22225
|
}
|
|
22226
|
+
function generateGUID() {
|
|
22227
|
+
return v4().replace(/-/g, '');
|
|
22228
|
+
}
|
|
22229
|
+
/**
|
|
22230
|
+
* 提取并转换 JSON 数据中的 anchor 值
|
|
22231
|
+
*/
|
|
22232
|
+
function convertAnchor$1(anchor, particleOrigin) {
|
|
22233
|
+
if (anchor) {
|
|
22234
|
+
return [anchor[0] - 0.5, 0.5 - anchor[1]];
|
|
22235
|
+
}
|
|
22236
|
+
else if (particleOrigin) {
|
|
22237
|
+
return particleOriginTranslateMap[particleOrigin];
|
|
22238
|
+
}
|
|
22239
|
+
else {
|
|
22240
|
+
return [0, 0];
|
|
22241
|
+
}
|
|
22242
|
+
}
|
|
22243
|
+
var particleOriginTranslateMap = (_a$2 = {},
|
|
22244
|
+
_a$2[ParticleOrigin.PARTICLE_ORIGIN_CENTER] = [0, 0],
|
|
22245
|
+
_a$2[ParticleOrigin.PARTICLE_ORIGIN_CENTER_BOTTOM] = [0, -0.5],
|
|
22246
|
+
_a$2[ParticleOrigin.PARTICLE_ORIGIN_CENTER_TOP] = [0, 0.5],
|
|
22247
|
+
_a$2[ParticleOrigin.PARTICLE_ORIGIN_LEFT_TOP] = [-0.5, 0.5],
|
|
22248
|
+
_a$2[ParticleOrigin.PARTICLE_ORIGIN_LEFT_CENTER] = [-0.5, 0],
|
|
22249
|
+
_a$2[ParticleOrigin.PARTICLE_ORIGIN_LEFT_BOTTOM] = [-0.5, -0.5],
|
|
22250
|
+
_a$2[ParticleOrigin.PARTICLE_ORIGIN_RIGHT_CENTER] = [0.5, 0],
|
|
22251
|
+
_a$2[ParticleOrigin.PARTICLE_ORIGIN_RIGHT_BOTTOM] = [0.5, -0.5],
|
|
22252
|
+
_a$2[ParticleOrigin.PARTICLE_ORIGIN_RIGHT_TOP] = [0.5, 0.5],
|
|
22253
|
+
_a$2);
|
|
21986
22254
|
|
|
21987
22255
|
function getStandardParticleContent(particle) {
|
|
21988
22256
|
var _a;
|
|
@@ -22394,6 +22662,306 @@ function version22Migration(json) {
|
|
|
22394
22662
|
});
|
|
22395
22663
|
return json;
|
|
22396
22664
|
}
|
|
22665
|
+
/**
|
|
22666
|
+
* 3.0 以下版本数据适配(runtime 2.0及以上版本支持)
|
|
22667
|
+
*/
|
|
22668
|
+
function version30Migration(json) {
|
|
22669
|
+
var e_1, _a;
|
|
22670
|
+
var _b, _c, _d, _e, _f, _g, _h, _j;
|
|
22671
|
+
var result = Object.assign({}, json, {
|
|
22672
|
+
items: [],
|
|
22673
|
+
components: [],
|
|
22674
|
+
materials: [],
|
|
22675
|
+
shaders: [],
|
|
22676
|
+
geometries: [],
|
|
22677
|
+
});
|
|
22678
|
+
// 兼容老版本数据中不存在textures的情况
|
|
22679
|
+
(_b = result.textures) !== null && _b !== void 0 ? _b : (result.textures = []);
|
|
22680
|
+
result.textures.forEach(function (textureOptions) {
|
|
22681
|
+
Object.assign(textureOptions, {
|
|
22682
|
+
id: generateGUID(),
|
|
22683
|
+
dataType: DataType.Texture,
|
|
22684
|
+
});
|
|
22685
|
+
});
|
|
22686
|
+
if (result.textures.length < result.images.length) {
|
|
22687
|
+
for (var i = result.textures.length; i < result.images.length; i++) {
|
|
22688
|
+
result.textures.push({
|
|
22689
|
+
//@ts-expect-error
|
|
22690
|
+
id: generateGUID(),
|
|
22691
|
+
dataType: DataType.Texture,
|
|
22692
|
+
source: i,
|
|
22693
|
+
flipY: true,
|
|
22694
|
+
});
|
|
22695
|
+
}
|
|
22696
|
+
}
|
|
22697
|
+
var _loop_1 = function (composition) {
|
|
22698
|
+
var e_2, _m, e_3, _o;
|
|
22699
|
+
// composition 的 endbehaviour 兼容
|
|
22700
|
+
if (composition.endBehavior === END_BEHAVIOR_PAUSE_AND_DESTROY || composition.endBehavior === END_BEHAVIOR_PAUSE) {
|
|
22701
|
+
composition.endBehavior = END_BEHAVIOR_FREEZE;
|
|
22702
|
+
}
|
|
22703
|
+
var itemGuidMap = {};
|
|
22704
|
+
try {
|
|
22705
|
+
for (var _p = (e_2 = void 0, __values(composition.items)), _q = _p.next(); !_q.done; _q = _p.next()) {
|
|
22706
|
+
var item = _q.value;
|
|
22707
|
+
itemGuidMap[item.id] = generateGUID();
|
|
22708
|
+
// TODO: 编辑器测试用,上线后删除
|
|
22709
|
+
//@ts-expect-error
|
|
22710
|
+
item.oldId = item.id;
|
|
22711
|
+
item.id = itemGuidMap[item.id];
|
|
22712
|
+
}
|
|
22713
|
+
}
|
|
22714
|
+
catch (e_2_1) { e_2 = { error: e_2_1 }; }
|
|
22715
|
+
finally {
|
|
22716
|
+
try {
|
|
22717
|
+
if (_q && !_q.done && (_m = _p.return)) _m.call(_p);
|
|
22718
|
+
}
|
|
22719
|
+
finally { if (e_2) throw e_2.error; }
|
|
22720
|
+
}
|
|
22721
|
+
composition.items.forEach(function (item, index) {
|
|
22722
|
+
if (item.parentId) {
|
|
22723
|
+
if (item.parentId.includes('^')) {
|
|
22724
|
+
var parentId = (item.parentId).split('^')[0];
|
|
22725
|
+
var nodeId = (item.parentId).split('^')[1];
|
|
22726
|
+
item.parentId = itemGuidMap[parentId] + '^' + nodeId;
|
|
22727
|
+
}
|
|
22728
|
+
else {
|
|
22729
|
+
item.parentId = itemGuidMap[item.parentId];
|
|
22730
|
+
}
|
|
22731
|
+
}
|
|
22732
|
+
// @ts-expect-error fix item type
|
|
22733
|
+
result.items.push(item);
|
|
22734
|
+
// @ts-expect-error fix item type
|
|
22735
|
+
composition.items[index] = { id: item.id };
|
|
22736
|
+
});
|
|
22737
|
+
try {
|
|
22738
|
+
for (var _r = (e_3 = void 0, __values(result.items)), _s = _r.next(); !_s.done; _s = _r.next()) {
|
|
22739
|
+
var item = _s.value;
|
|
22740
|
+
// 原 texture 索引转为统一 guid 索引
|
|
22741
|
+
if (item.content) {
|
|
22742
|
+
if (item.content.renderer) {
|
|
22743
|
+
if (item.content.renderer.texture !== undefined) {
|
|
22744
|
+
var oldTextureId = item.content.renderer.texture;
|
|
22745
|
+
//@ts-expect-error
|
|
22746
|
+
item.content.renderer.texture = { id: result.textures[oldTextureId].id };
|
|
22747
|
+
}
|
|
22748
|
+
}
|
|
22749
|
+
if (item.content.trails) {
|
|
22750
|
+
if (item.content.trails.texture !== undefined) {
|
|
22751
|
+
var oldTextureId = item.content.trails.texture;
|
|
22752
|
+
//@ts-expect-error
|
|
22753
|
+
item.content.trails.texture = { id: result.textures[oldTextureId].id };
|
|
22754
|
+
}
|
|
22755
|
+
}
|
|
22756
|
+
}
|
|
22757
|
+
// item 的 transform 属性由数组转为 {x:n, y:n, z:n}
|
|
22758
|
+
if (item.transform) {
|
|
22759
|
+
//@ts-expect-error
|
|
22760
|
+
var position = __spreadArray([], __read((_c = item.transform.position) !== null && _c !== void 0 ? _c : [0, 0, 0]), false);
|
|
22761
|
+
//@ts-expect-error
|
|
22762
|
+
var rotation = __spreadArray([], __read((_d = item.transform.rotation) !== null && _d !== void 0 ? _d : [0, 0, 0]), false);
|
|
22763
|
+
//@ts-expect-error
|
|
22764
|
+
var scale = __spreadArray([], __read((_e = item.transform.scale) !== null && _e !== void 0 ? _e : [1, 1, 1]), false);
|
|
22765
|
+
Object.assign(item, {
|
|
22766
|
+
transform: {
|
|
22767
|
+
position: { x: position[0], y: position[1], z: position[2] },
|
|
22768
|
+
rotation: { x: rotation[0], y: rotation[1], z: rotation[2] },
|
|
22769
|
+
scale: { x: scale[0], y: scale[1], z: scale[0] },
|
|
22770
|
+
},
|
|
22771
|
+
});
|
|
22772
|
+
// sprite 的 scale 转为 size
|
|
22773
|
+
if (item.type === ItemType.sprite) {
|
|
22774
|
+
item.transform.size = { x: scale[0], y: scale[1] };
|
|
22775
|
+
item.transform.scale = { x: 1, y: 1, z: 1 };
|
|
22776
|
+
}
|
|
22777
|
+
// sprite 的 anchor 修正
|
|
22778
|
+
if (item.type === ItemType.sprite) {
|
|
22779
|
+
var content = item.content;
|
|
22780
|
+
if (!content.renderer) {
|
|
22781
|
+
content.renderer = {};
|
|
22782
|
+
}
|
|
22783
|
+
var renderer = content.renderer;
|
|
22784
|
+
var realAnchor = convertAnchor$1(renderer.anchor, renderer.particleOrigin);
|
|
22785
|
+
var startSize = item.transform.size;
|
|
22786
|
+
// 兼容旧JSON(anchor和particleOrigin可能同时存在)
|
|
22787
|
+
if (!renderer.anchor && renderer.particleOrigin !== undefined) {
|
|
22788
|
+
item.transform.position.x += -realAnchor[0] * ((_f = startSize === null || startSize === void 0 ? void 0 : startSize.x) !== null && _f !== void 0 ? _f : 1);
|
|
22789
|
+
item.transform.position.y += -realAnchor[1] * ((_g = startSize === null || startSize === void 0 ? void 0 : startSize.y) !== null && _g !== void 0 ? _g : 1);
|
|
22790
|
+
}
|
|
22791
|
+
item.transform.anchor = { x: realAnchor[0] * ((_h = startSize === null || startSize === void 0 ? void 0 : startSize.x) !== null && _h !== void 0 ? _h : 1), y: realAnchor[1] * ((_j = startSize === null || startSize === void 0 ? void 0 : startSize.y) !== null && _j !== void 0 ? _j : 1) };
|
|
22792
|
+
}
|
|
22793
|
+
}
|
|
22794
|
+
if (item.type === ItemType.particle) {
|
|
22795
|
+
var content = item.content;
|
|
22796
|
+
if (!content.renderer) {
|
|
22797
|
+
content.renderer = {};
|
|
22798
|
+
}
|
|
22799
|
+
var renderer = content.renderer;
|
|
22800
|
+
content.renderer.anchor = convertAnchor$1(renderer.anchor, renderer.particleOrigin);
|
|
22801
|
+
}
|
|
22802
|
+
// 动画数据转化 TODO: 动画数据移到 TimelineComponentData
|
|
22803
|
+
item.content.tracks = [];
|
|
22804
|
+
var tracks = item.content.tracks;
|
|
22805
|
+
if (item.type !== ItemType.particle) {
|
|
22806
|
+
tracks.push({
|
|
22807
|
+
clips: [
|
|
22808
|
+
{
|
|
22809
|
+
dataType: 'TransformAnimationPlayableAsset',
|
|
22810
|
+
animationClip: {
|
|
22811
|
+
sizeOverLifetime: item.content.sizeOverLifetime,
|
|
22812
|
+
rotationOverLifetime: item.content.rotationOverLifetime,
|
|
22813
|
+
positionOverLifetime: item.content.positionOverLifetime,
|
|
22814
|
+
},
|
|
22815
|
+
},
|
|
22816
|
+
],
|
|
22817
|
+
});
|
|
22818
|
+
}
|
|
22819
|
+
if (item.type === ItemType.sprite) {
|
|
22820
|
+
tracks.push({
|
|
22821
|
+
clips: [
|
|
22822
|
+
{
|
|
22823
|
+
dataType: 'SpriteColorAnimationPlayableAsset',
|
|
22824
|
+
animationClip: {
|
|
22825
|
+
colorOverLifetime: item.content.colorOverLifetime,
|
|
22826
|
+
startColor: item.content.options.startColor,
|
|
22827
|
+
},
|
|
22828
|
+
},
|
|
22829
|
+
],
|
|
22830
|
+
});
|
|
22831
|
+
}
|
|
22832
|
+
// gizmo 的 target id 转换为新的 item guid
|
|
22833
|
+
if (item.content.options.target) {
|
|
22834
|
+
item.content.options.target = itemGuidMap[item.content.options.target];
|
|
22835
|
+
}
|
|
22836
|
+
// item 的 content 转为 component data 加入 JSONScene.components
|
|
22837
|
+
var uuid = generateGUID();
|
|
22838
|
+
if (item.type === ItemType.sprite) {
|
|
22839
|
+
item.components = [];
|
|
22840
|
+
result.components.push(item.content);
|
|
22841
|
+
item.content.id = uuid;
|
|
22842
|
+
item.content.dataType = DataType.SpriteComponent;
|
|
22843
|
+
item.content.item = { id: item.id };
|
|
22844
|
+
item.dataType = DataType.VFXItemData;
|
|
22845
|
+
//@ts-expect-error
|
|
22846
|
+
item.components.push({ id: item.content.id });
|
|
22847
|
+
}
|
|
22848
|
+
else if (item.type === ItemType.particle) {
|
|
22849
|
+
item.components = [];
|
|
22850
|
+
result.components.push(item.content);
|
|
22851
|
+
item.content.id = uuid;
|
|
22852
|
+
item.content.dataType = DataType.ParticleSystem;
|
|
22853
|
+
item.content.item = { id: item.id };
|
|
22854
|
+
item.dataType = DataType.VFXItemData;
|
|
22855
|
+
//@ts-expect-error
|
|
22856
|
+
item.components.push({ id: item.content.id });
|
|
22857
|
+
}
|
|
22858
|
+
else if (item.type === ItemType.mesh) {
|
|
22859
|
+
item.components = [];
|
|
22860
|
+
result.components.push(item.content);
|
|
22861
|
+
item.content.id = uuid;
|
|
22862
|
+
item.content.dataType = DataType.MeshComponent;
|
|
22863
|
+
item.content.item = { id: item.id };
|
|
22864
|
+
item.dataType = DataType.VFXItemData;
|
|
22865
|
+
//@ts-expect-error
|
|
22866
|
+
item.components.push({ id: item.content.id });
|
|
22867
|
+
}
|
|
22868
|
+
else if (item.type === ItemType.skybox) {
|
|
22869
|
+
item.components = [];
|
|
22870
|
+
result.components.push(item.content);
|
|
22871
|
+
item.content.id = uuid;
|
|
22872
|
+
item.content.dataType = DataType.SkyboxComponent;
|
|
22873
|
+
item.content.item = { id: item.id };
|
|
22874
|
+
item.dataType = DataType.VFXItemData;
|
|
22875
|
+
//@ts-expect-error
|
|
22876
|
+
item.components.push({ id: item.content.id });
|
|
22877
|
+
}
|
|
22878
|
+
else if (item.type === ItemType.light) {
|
|
22879
|
+
item.components = [];
|
|
22880
|
+
result.components.push(item.content);
|
|
22881
|
+
item.content.id = uuid;
|
|
22882
|
+
item.content.dataType = DataType.LightComponent;
|
|
22883
|
+
item.content.item = { id: item.id };
|
|
22884
|
+
item.dataType = DataType.VFXItemData;
|
|
22885
|
+
//@ts-expect-error
|
|
22886
|
+
item.components.push({ id: item.content.id });
|
|
22887
|
+
}
|
|
22888
|
+
else if (item.type === 'camera') {
|
|
22889
|
+
item.components = [];
|
|
22890
|
+
result.components.push(item.content);
|
|
22891
|
+
item.content.id = uuid;
|
|
22892
|
+
item.content.dataType = DataType.CameraComponent;
|
|
22893
|
+
item.content.item = { id: item.id };
|
|
22894
|
+
item.dataType = DataType.VFXItemData;
|
|
22895
|
+
//@ts-expect-error
|
|
22896
|
+
item.components.push({ id: item.content.id });
|
|
22897
|
+
}
|
|
22898
|
+
else if (item.type === ItemType.tree) {
|
|
22899
|
+
item.components = [];
|
|
22900
|
+
result.components.push(item.content);
|
|
22901
|
+
item.content.id = uuid;
|
|
22902
|
+
item.content.dataType = DataType.TreeComponent;
|
|
22903
|
+
item.content.item = { id: item.id };
|
|
22904
|
+
item.dataType = DataType.VFXItemData;
|
|
22905
|
+
//@ts-expect-error
|
|
22906
|
+
item.components.push({ id: item.content.id });
|
|
22907
|
+
}
|
|
22908
|
+
else if (item.type === ItemType.interact) {
|
|
22909
|
+
item.components = [];
|
|
22910
|
+
result.components.push(item.content);
|
|
22911
|
+
item.content.id = uuid;
|
|
22912
|
+
item.content.dataType = DataType.InteractComponent;
|
|
22913
|
+
item.content.item = { id: item.id };
|
|
22914
|
+
item.dataType = DataType.VFXItemData;
|
|
22915
|
+
//@ts-expect-error
|
|
22916
|
+
item.components.push({ id: item.content.id });
|
|
22917
|
+
}
|
|
22918
|
+
else if (item.type === ItemType.camera) {
|
|
22919
|
+
item.components = [];
|
|
22920
|
+
result.components.push(item.content);
|
|
22921
|
+
item.content.id = uuid;
|
|
22922
|
+
item.content.dataType = DataType.CameraController;
|
|
22923
|
+
item.content.item = { id: item.id };
|
|
22924
|
+
item.dataType = DataType.VFXItemData;
|
|
22925
|
+
//@ts-expect-error
|
|
22926
|
+
item.components.push({ id: item.content.id });
|
|
22927
|
+
}
|
|
22928
|
+
else if (item.type === ItemType.text) {
|
|
22929
|
+
item.components = [];
|
|
22930
|
+
result.components.push(item.content);
|
|
22931
|
+
item.content.id = uuid;
|
|
22932
|
+
item.content.dataType = DataType.TextComponent;
|
|
22933
|
+
item.content.item = { id: item.id };
|
|
22934
|
+
item.dataType = DataType.VFXItemData;
|
|
22935
|
+
//@ts-expect-error
|
|
22936
|
+
item.components.push({ id: item.content.id });
|
|
22937
|
+
}
|
|
22938
|
+
}
|
|
22939
|
+
}
|
|
22940
|
+
catch (e_3_1) { e_3 = { error: e_3_1 }; }
|
|
22941
|
+
finally {
|
|
22942
|
+
try {
|
|
22943
|
+
if (_s && !_s.done && (_o = _r.return)) _o.call(_r);
|
|
22944
|
+
}
|
|
22945
|
+
finally { if (e_3) throw e_3.error; }
|
|
22946
|
+
}
|
|
22947
|
+
};
|
|
22948
|
+
try {
|
|
22949
|
+
// 更正Composition.endBehavior
|
|
22950
|
+
for (var _k = __values(json.compositions), _l = _k.next(); !_l.done; _l = _k.next()) {
|
|
22951
|
+
var composition = _l.value;
|
|
22952
|
+
_loop_1(composition);
|
|
22953
|
+
}
|
|
22954
|
+
}
|
|
22955
|
+
catch (e_1_1) { e_1 = { error: e_1_1 }; }
|
|
22956
|
+
finally {
|
|
22957
|
+
try {
|
|
22958
|
+
if (_l && !_l.done && (_a = _k.return)) _a.call(_k);
|
|
22959
|
+
}
|
|
22960
|
+
finally { if (e_1) throw e_1.error; }
|
|
22961
|
+
}
|
|
22962
|
+
result.version = '3.0';
|
|
22963
|
+
return result;
|
|
22964
|
+
}
|
|
22397
22965
|
|
|
22398
22966
|
var v0 = /^(\d+)\.(\d+)\.(\d+)(-(\w+)\.\d+)?$/;
|
|
22399
22967
|
var standardVersion = /^(\d+)\.(\d+)$/;
|
|
@@ -22403,16 +22971,16 @@ function getStandardJSON(json) {
|
|
|
22403
22971
|
if (!json || typeof json !== 'object') {
|
|
22404
22972
|
throw Error('expect a json object');
|
|
22405
22973
|
}
|
|
22406
|
-
// 修正老版本数据中,meshItem以及lightItem结束行为错误问题
|
|
22974
|
+
// 修正老版本数据中,meshItem 以及 lightItem 结束行为错误问题
|
|
22407
22975
|
version22Migration(json);
|
|
22408
22976
|
if (v0.test(json.version)) {
|
|
22409
22977
|
reverseParticle = ((_a = (/^(\d+)/).exec(json.version)) === null || _a === void 0 ? void 0 : _a[0]) === '0';
|
|
22410
|
-
return version21Migration(getStandardJSONFromV0(json));
|
|
22978
|
+
return version30Migration(version21Migration(getStandardJSONFromV0(json)));
|
|
22411
22979
|
}
|
|
22412
22980
|
var mainVersion = (_b = standardVersion.exec(json.version)) === null || _b === void 0 ? void 0 : _b[1];
|
|
22413
22981
|
if (mainVersion) {
|
|
22414
|
-
if (Number(mainVersion) <
|
|
22415
|
-
return version21Migration(json);
|
|
22982
|
+
if (Number(mainVersion) < 3) {
|
|
22983
|
+
return version30Migration(version21Migration(json));
|
|
22416
22984
|
}
|
|
22417
22985
|
return json;
|
|
22418
22986
|
}
|
|
@@ -22736,7 +23304,7 @@ function version3Migration(scene) {
|
|
|
22736
23304
|
try {
|
|
22737
23305
|
for (var _j = __values$1(ecScene.items), _k = _j.next(); !_k.done; _k = _j.next()) {
|
|
22738
23306
|
var item = _k.value;
|
|
22739
|
-
itemGuidMap[item.id] = generateGUID();
|
|
23307
|
+
itemGuidMap[item.id] = generateGUID$1();
|
|
22740
23308
|
// TODO: 编辑器测试用,上线后删除
|
|
22741
23309
|
//@ts-expect-error
|
|
22742
23310
|
item.oldId = item.id;
|
|
@@ -22792,7 +23360,7 @@ function version3Migration(scene) {
|
|
|
22792
23360
|
// texture 增加 id 和 dataType
|
|
22793
23361
|
for (var _q = __values$1(scene.textureOptions), _r = _q.next(); !_r.done; _r = _q.next()) {
|
|
22794
23362
|
var texture = _r.value;
|
|
22795
|
-
texture.id = generateGUID();
|
|
23363
|
+
texture.id = generateGUID$1();
|
|
22796
23364
|
texture.dataType = exports.DataType.Texture;
|
|
22797
23365
|
}
|
|
22798
23366
|
}
|
|
@@ -22812,23 +23380,15 @@ function version3Migration(scene) {
|
|
|
22812
23380
|
var item = _t.value;
|
|
22813
23381
|
// 原 texture 索引转为统一 guid 索引
|
|
22814
23382
|
if (item.content) {
|
|
22815
|
-
//@ts-expect-error
|
|
22816
23383
|
if (item.content.renderer) {
|
|
22817
|
-
//@ts-expect-error
|
|
22818
23384
|
if (item.content.renderer.texture !== undefined) {
|
|
22819
|
-
//@ts-expect-error
|
|
22820
23385
|
var oldTextureId = item.content.renderer.texture;
|
|
22821
|
-
//@ts-expect-error
|
|
22822
23386
|
item.content.renderer.texture = { id: scene.textureOptions[oldTextureId].id };
|
|
22823
23387
|
}
|
|
22824
23388
|
}
|
|
22825
|
-
//@ts-expect-error
|
|
22826
23389
|
if (item.content.trails) {
|
|
22827
|
-
//@ts-expect-error
|
|
22828
23390
|
if (item.content.trails.texture !== undefined) {
|
|
22829
|
-
//@ts-expect-error
|
|
22830
23391
|
var oldTextureId = item.content.trails.texture;
|
|
22831
|
-
//@ts-expect-error
|
|
22832
23392
|
item.content.trails.texture = { id: scene.textureOptions[oldTextureId].id };
|
|
22833
23393
|
}
|
|
22834
23394
|
}
|
|
@@ -22839,12 +23399,14 @@ function version3Migration(scene) {
|
|
|
22839
23399
|
var rotation = item.transform.rotation;
|
|
22840
23400
|
var scale = item.transform.scale;
|
|
22841
23401
|
if (!position) {
|
|
23402
|
+
//@ts-expect-error
|
|
22842
23403
|
position = [0, 0, 0];
|
|
22843
23404
|
}
|
|
22844
23405
|
if (!rotation) {
|
|
22845
23406
|
rotation = [0, 0, 0];
|
|
22846
23407
|
}
|
|
22847
23408
|
if (!scale) {
|
|
23409
|
+
//@ts-expect-error
|
|
22848
23410
|
scale = [1, 1, 1];
|
|
22849
23411
|
}
|
|
22850
23412
|
item.transform = {
|
|
@@ -22865,12 +23427,9 @@ function version3Migration(scene) {
|
|
|
22865
23427
|
// sprite 的 anchor 修正
|
|
22866
23428
|
if (item.type === ItemType$1.sprite) {
|
|
22867
23429
|
var content = item.content;
|
|
22868
|
-
//@ts-expect-error
|
|
22869
23430
|
if (!content.renderer) {
|
|
22870
|
-
//@ts-expect-error
|
|
22871
23431
|
content.renderer = {};
|
|
22872
23432
|
}
|
|
22873
|
-
//@ts-expect-error
|
|
22874
23433
|
var renderer = content.renderer;
|
|
22875
23434
|
var realAnchor = convertAnchor(renderer.anchor, renderer.particleOrigin);
|
|
22876
23435
|
//@ts-expect-error
|
|
@@ -22888,14 +23447,10 @@ function version3Migration(scene) {
|
|
|
22888
23447
|
}
|
|
22889
23448
|
if (item.type === ItemType$1.particle) {
|
|
22890
23449
|
var content = item.content;
|
|
22891
|
-
//@ts-expect-error
|
|
22892
23450
|
if (!content.renderer) {
|
|
22893
|
-
//@ts-expect-error
|
|
22894
23451
|
content.renderer = {};
|
|
22895
23452
|
}
|
|
22896
|
-
//@ts-expect-error
|
|
22897
23453
|
var renderer = content.renderer;
|
|
22898
|
-
//@ts-expect-error
|
|
22899
23454
|
content.renderer.anchor = convertAnchor(renderer.anchor, renderer.particleOrigin);
|
|
22900
23455
|
}
|
|
22901
23456
|
// item 的 endbehaviour 兼容
|
|
@@ -22904,9 +23459,7 @@ function version3Migration(scene) {
|
|
|
22904
23459
|
item.endBehavior = END_BEHAVIOR_FREEZE$1;
|
|
22905
23460
|
}
|
|
22906
23461
|
// 动画数据转化 TODO: 动画数据移到 TimelineComponentData
|
|
22907
|
-
//@ts-expect-error
|
|
22908
23462
|
item.content.tracks = [];
|
|
22909
|
-
//@ts-expect-error
|
|
22910
23463
|
var tracks = item.content.tracks;
|
|
22911
23464
|
if (item.type !== ItemType$1.particle) {
|
|
22912
23465
|
tracks.push({
|
|
@@ -22914,11 +23467,8 @@ function version3Migration(scene) {
|
|
|
22914
23467
|
{
|
|
22915
23468
|
dataType: 'TransformAnimationPlayableAsset',
|
|
22916
23469
|
animationClip: {
|
|
22917
|
-
//@ts-expect-error
|
|
22918
23470
|
sizeOverLifetime: item.content.sizeOverLifetime,
|
|
22919
|
-
//@ts-expect-error
|
|
22920
23471
|
rotationOverLifetime: item.content.rotationOverLifetime,
|
|
22921
|
-
//@ts-expect-error
|
|
22922
23472
|
positionOverLifetime: item.content.positionOverLifetime,
|
|
22923
23473
|
},
|
|
22924
23474
|
},
|
|
@@ -22931,9 +23481,7 @@ function version3Migration(scene) {
|
|
|
22931
23481
|
{
|
|
22932
23482
|
dataType: 'SpriteColorAnimationPlayableAsset',
|
|
22933
23483
|
animationClip: {
|
|
22934
|
-
//@ts-expect-error
|
|
22935
23484
|
colorOverLifetime: item.content.colorOverLifetime,
|
|
22936
|
-
//@ts-expect-error
|
|
22937
23485
|
startColor: item.content.options.startColor,
|
|
22938
23486
|
},
|
|
22939
23487
|
},
|
|
@@ -22941,169 +23489,107 @@ function version3Migration(scene) {
|
|
|
22941
23489
|
});
|
|
22942
23490
|
}
|
|
22943
23491
|
// gizmo 的 target id 转换为新的 item guid
|
|
22944
|
-
|
|
22945
|
-
if (item.content.options.target) {
|
|
22946
|
-
//@ts-expect-error
|
|
23492
|
+
if (item.content && item.content.options && item.content.options.target) {
|
|
22947
23493
|
item.content.options.target = itemGuidMap[item.content.options.target];
|
|
22948
23494
|
}
|
|
22949
23495
|
// item 的 content 转为 component data 加入 JSONScene.components
|
|
22950
|
-
var uuid = v4().replace(/-/g, '');
|
|
23496
|
+
var uuid = v4$1().replace(/-/g, '');
|
|
22951
23497
|
if (item.type === ItemType$1.sprite) {
|
|
22952
|
-
//@ts-expect-error
|
|
22953
23498
|
item.components = [];
|
|
22954
|
-
//@ts-expect-error
|
|
22955
23499
|
components.push(item.content);
|
|
22956
|
-
//@ts-expect-error
|
|
22957
23500
|
item.content.id = uuid;
|
|
22958
|
-
//@ts-expect-error
|
|
22959
23501
|
item.content.dataType = exports.DataType.SpriteComponent;
|
|
22960
|
-
//@ts-expect-error
|
|
22961
23502
|
item.content.item = { id: item.id };
|
|
22962
|
-
//@ts-expect-error
|
|
22963
23503
|
item.dataType = exports.DataType.VFXItemData;
|
|
22964
23504
|
//@ts-expect-error
|
|
22965
23505
|
item.components.push({ id: item.content.id });
|
|
22966
23506
|
}
|
|
22967
23507
|
else if (item.type === ItemType$1.particle) {
|
|
22968
|
-
//@ts-expect-error
|
|
22969
23508
|
item.components = [];
|
|
22970
|
-
//@ts-expect-error
|
|
22971
23509
|
components.push(item.content);
|
|
22972
|
-
//@ts-expect-error
|
|
22973
23510
|
item.content.id = uuid;
|
|
22974
|
-
//@ts-expect-error
|
|
22975
23511
|
item.content.dataType = exports.DataType.ParticleSystem;
|
|
22976
|
-
//@ts-expect-error
|
|
22977
23512
|
item.content.item = { id: item.id };
|
|
22978
|
-
//@ts-expect-error
|
|
22979
23513
|
item.dataType = exports.DataType.VFXItemData;
|
|
22980
23514
|
//@ts-expect-error
|
|
22981
23515
|
item.components.push({ id: item.content.id });
|
|
22982
23516
|
}
|
|
22983
23517
|
else if (item.type === ItemType$1.mesh) {
|
|
22984
|
-
//@ts-expect-error
|
|
22985
23518
|
item.components = [];
|
|
22986
|
-
//@ts-expect-error
|
|
22987
23519
|
components.push(item.content);
|
|
22988
|
-
//@ts-expect-error
|
|
22989
23520
|
item.content.id = uuid;
|
|
22990
|
-
//@ts-expect-error
|
|
22991
23521
|
item.content.dataType = exports.DataType.MeshComponent;
|
|
22992
|
-
//@ts-expect-error
|
|
22993
23522
|
item.content.item = { id: item.id };
|
|
22994
|
-
//@ts-expect-error
|
|
22995
23523
|
item.dataType = exports.DataType.VFXItemData;
|
|
22996
23524
|
//@ts-expect-error
|
|
22997
23525
|
item.components.push({ id: item.content.id });
|
|
22998
23526
|
}
|
|
22999
23527
|
else if (item.type === ItemType$1.skybox) {
|
|
23000
|
-
//@ts-expect-error
|
|
23001
23528
|
item.components = [];
|
|
23002
|
-
//@ts-expect-error
|
|
23003
23529
|
components.push(item.content);
|
|
23004
|
-
//@ts-expect-error
|
|
23005
23530
|
item.content.id = uuid;
|
|
23006
|
-
//@ts-expect-error
|
|
23007
23531
|
item.content.dataType = exports.DataType.SkyboxComponent;
|
|
23008
|
-
//@ts-expect-error
|
|
23009
23532
|
item.content.item = { id: item.id };
|
|
23010
|
-
//@ts-expect-error
|
|
23011
23533
|
item.dataType = exports.DataType.VFXItemData;
|
|
23012
23534
|
//@ts-expect-error
|
|
23013
23535
|
item.components.push({ id: item.content.id });
|
|
23014
23536
|
}
|
|
23015
23537
|
else if (item.type === ItemType$1.light) {
|
|
23016
|
-
//@ts-expect-error
|
|
23017
23538
|
item.components = [];
|
|
23018
|
-
//@ts-expect-error
|
|
23019
23539
|
components.push(item.content);
|
|
23020
|
-
//@ts-expect-error
|
|
23021
23540
|
item.content.id = uuid;
|
|
23022
|
-
//@ts-expect-error
|
|
23023
23541
|
item.content.dataType = exports.DataType.LightComponent;
|
|
23024
|
-
//@ts-expect-error
|
|
23025
23542
|
item.content.item = { id: item.id };
|
|
23026
|
-
//@ts-expect-error
|
|
23027
23543
|
item.dataType = exports.DataType.VFXItemData;
|
|
23028
23544
|
//@ts-expect-error
|
|
23029
23545
|
item.components.push({ id: item.content.id });
|
|
23030
23546
|
}
|
|
23031
23547
|
else if (item.type === 'camera') {
|
|
23032
|
-
//@ts-expect-error
|
|
23033
23548
|
item.components = [];
|
|
23034
|
-
//@ts-expect-error
|
|
23035
23549
|
components.push(item.content);
|
|
23036
|
-
//@ts-expect-error
|
|
23037
23550
|
item.content.id = uuid;
|
|
23038
|
-
//@ts-expect-error
|
|
23039
23551
|
item.content.dataType = exports.DataType.CameraComponent;
|
|
23040
|
-
//@ts-expect-error
|
|
23041
23552
|
item.content.item = { id: item.id };
|
|
23042
|
-
//@ts-expect-error
|
|
23043
23553
|
item.dataType = exports.DataType.VFXItemData;
|
|
23044
23554
|
//@ts-expect-error
|
|
23045
23555
|
item.components.push({ id: item.content.id });
|
|
23046
23556
|
}
|
|
23047
23557
|
else if (item.type === ItemType$1.tree) {
|
|
23048
|
-
//@ts-expect-error
|
|
23049
23558
|
item.components = [];
|
|
23050
|
-
//@ts-expect-error
|
|
23051
23559
|
components.push(item.content);
|
|
23052
|
-
//@ts-expect-error
|
|
23053
23560
|
item.content.id = uuid;
|
|
23054
|
-
//@ts-expect-error
|
|
23055
23561
|
item.content.dataType = exports.DataType.TreeComponent;
|
|
23056
|
-
//@ts-expect-error
|
|
23057
23562
|
item.content.item = { id: item.id };
|
|
23058
|
-
//@ts-expect-error
|
|
23059
23563
|
item.dataType = exports.DataType.VFXItemData;
|
|
23060
23564
|
//@ts-expect-error
|
|
23061
23565
|
item.components.push({ id: item.content.id });
|
|
23062
23566
|
}
|
|
23063
23567
|
else if (item.type === ItemType$1.interact) {
|
|
23064
|
-
//@ts-expect-error
|
|
23065
23568
|
item.components = [];
|
|
23066
|
-
//@ts-expect-error
|
|
23067
23569
|
components.push(item.content);
|
|
23068
|
-
//@ts-expect-error
|
|
23069
23570
|
item.content.id = uuid;
|
|
23070
|
-
//@ts-expect-error
|
|
23071
23571
|
item.content.dataType = exports.DataType.InteractComponent;
|
|
23072
|
-
//@ts-expect-error
|
|
23073
23572
|
item.content.item = { id: item.id };
|
|
23074
|
-
//@ts-expect-error
|
|
23075
23573
|
item.dataType = exports.DataType.VFXItemData;
|
|
23076
23574
|
//@ts-expect-error
|
|
23077
23575
|
item.components.push({ id: item.content.id });
|
|
23078
23576
|
}
|
|
23079
23577
|
else if (item.type === ItemType$1.camera) {
|
|
23080
|
-
//@ts-expect-error
|
|
23081
23578
|
item.components = [];
|
|
23082
|
-
//@ts-expect-error
|
|
23083
23579
|
components.push(item.content);
|
|
23084
|
-
//@ts-expect-error
|
|
23085
23580
|
item.content.id = uuid;
|
|
23086
|
-
//@ts-expect-error
|
|
23087
23581
|
item.content.dataType = exports.DataType.CameraController;
|
|
23088
|
-
//@ts-expect-error
|
|
23089
23582
|
item.content.item = { id: item.id };
|
|
23090
|
-
//@ts-expect-error
|
|
23091
23583
|
item.dataType = exports.DataType.VFXItemData;
|
|
23092
23584
|
//@ts-expect-error
|
|
23093
23585
|
item.components.push({ id: item.content.id });
|
|
23094
23586
|
}
|
|
23095
23587
|
else if (item.type === ItemType$1.text) {
|
|
23096
|
-
//@ts-expect-error
|
|
23097
23588
|
item.components = [];
|
|
23098
|
-
//@ts-expect-error
|
|
23099
23589
|
components.push(item.content);
|
|
23100
|
-
//@ts-expect-error
|
|
23101
23590
|
item.content.id = uuid;
|
|
23102
|
-
//@ts-expect-error
|
|
23103
23591
|
item.content.dataType = exports.DataType.TextComponent;
|
|
23104
|
-
//@ts-expect-error
|
|
23105
23592
|
item.content.item = { id: item.id };
|
|
23106
|
-
//@ts-expect-error
|
|
23107
23593
|
item.dataType = exports.DataType.VFXItemData;
|
|
23108
23594
|
//@ts-expect-error
|
|
23109
23595
|
item.components.push({ id: item.content.id });
|
|
@@ -23127,7 +23613,7 @@ function convertAnchor(anchor, particleOrigin) {
|
|
|
23127
23613
|
return [anchor[0] - 0.5, 0.5 - anchor[1]];
|
|
23128
23614
|
}
|
|
23129
23615
|
else if (particleOrigin) {
|
|
23130
|
-
return particleOriginTranslateMap[particleOrigin];
|
|
23616
|
+
return particleOriginTranslateMap$1[particleOrigin];
|
|
23131
23617
|
}
|
|
23132
23618
|
else {
|
|
23133
23619
|
return [0, 0];
|
|
@@ -23405,16 +23891,17 @@ var AssetManager = /** @class */ (function () {
|
|
|
23405
23891
|
};
|
|
23406
23892
|
AssetManager.prototype.processBins = function (bins) {
|
|
23407
23893
|
return __awaiter(this, void 0, void 0, function () {
|
|
23408
|
-
var renderLevel, jobs;
|
|
23894
|
+
var renderLevel, baseUrl, jobs;
|
|
23409
23895
|
var _this = this;
|
|
23410
23896
|
return __generator(this, function (_a) {
|
|
23411
23897
|
renderLevel = this.options.renderLevel;
|
|
23898
|
+
baseUrl = this.baseUrl;
|
|
23412
23899
|
jobs = bins.map(function (bin) {
|
|
23413
23900
|
if (bin instanceof ArrayBuffer) {
|
|
23414
23901
|
return bin;
|
|
23415
23902
|
}
|
|
23416
23903
|
if (passRenderLevel(bin.renderLevel, renderLevel)) {
|
|
23417
|
-
return _this.loadBins(bin.url);
|
|
23904
|
+
return _this.loadBins(new URL(bin.url, baseUrl).href);
|
|
23418
23905
|
}
|
|
23419
23906
|
throw new Error("Invalid bins source: ".concat(JSON.stringify(bins)));
|
|
23420
23907
|
});
|
|
@@ -23432,13 +23919,14 @@ var AssetManager = /** @class */ (function () {
|
|
|
23432
23919
|
return [2 /*return*/];
|
|
23433
23920
|
}
|
|
23434
23921
|
jobs = fonts.map(function (font) { return __awaiter(_this, void 0, void 0, function () {
|
|
23435
|
-
var fontFace;
|
|
23922
|
+
var url, fontFace;
|
|
23436
23923
|
var _a;
|
|
23437
23924
|
return __generator(this, function (_b) {
|
|
23438
23925
|
switch (_b.label) {
|
|
23439
23926
|
case 0:
|
|
23440
23927
|
if (!(font.fontURL && !AssetManager.fonts.has(font.fontFamily))) return [3 /*break*/, 4];
|
|
23441
|
-
|
|
23928
|
+
url = new URL(font.fontURL, this.baseUrl).href;
|
|
23929
|
+
fontFace = new FontFace((_a = font.fontFamily) !== null && _a !== void 0 ? _a : '', 'url(' + url + ')');
|
|
23442
23930
|
_b.label = 1;
|
|
23443
23931
|
case 1:
|
|
23444
23932
|
_b.trys.push([1, 3, , 4]);
|
|
@@ -23451,7 +23939,7 @@ var AssetManager = /** @class */ (function () {
|
|
|
23451
23939
|
return [3 /*break*/, 4];
|
|
23452
23940
|
case 3:
|
|
23453
23941
|
_b.sent();
|
|
23454
|
-
logger.warn("Invalid fonts source: ".concat(JSON.stringify(
|
|
23942
|
+
logger.warn("Invalid fonts source: ".concat(JSON.stringify(url)));
|
|
23455
23943
|
return [3 /*break*/, 4];
|
|
23456
23944
|
case 4: return [2 /*return*/];
|
|
23457
23945
|
}
|
|
@@ -23700,7 +24188,7 @@ function createTextureOptionsBySource(image, sourceFrom) {
|
|
|
23700
24188
|
return image.source;
|
|
23701
24189
|
}
|
|
23702
24190
|
else if (image instanceof HTMLImageElement ||
|
|
23703
|
-
image
|
|
24191
|
+
isCanvas(image)) {
|
|
23704
24192
|
return {
|
|
23705
24193
|
image: image,
|
|
23706
24194
|
sourceType: exports.TextureSourceType.image,
|
|
@@ -23762,6 +24250,11 @@ function base64ToFile(base64, filename, contentType) {
|
|
|
23762
24250
|
var file = new File([blob], filename, { type: contentType });
|
|
23763
24251
|
return file;
|
|
23764
24252
|
}
|
|
24253
|
+
function isCanvas(cavnas) {
|
|
24254
|
+
var _a;
|
|
24255
|
+
// 小程序 Canvas 无法使用 instanceof HTMLCanvasElement 判断
|
|
24256
|
+
return typeof cavnas === 'object' && cavnas !== null && ((_a = cavnas.tagName) === null || _a === void 0 ? void 0 : _a.toUpperCase()) === 'CANVAS';
|
|
24257
|
+
}
|
|
23765
24258
|
|
|
23766
24259
|
var tmpScale = new Vector3(1, 1, 1);
|
|
23767
24260
|
/**
|
|
@@ -23981,8 +24474,9 @@ var Camera = /** @class */ (function () {
|
|
|
23981
24474
|
Camera.prototype.getInverseVPRatio = function (z) {
|
|
23982
24475
|
var pos = new Vector3(0, 0, z);
|
|
23983
24476
|
var mat = this.getViewProjectionMatrix();
|
|
23984
|
-
var
|
|
23985
|
-
|
|
24477
|
+
var inverseVP = this.getInverseViewProjectionMatrix();
|
|
24478
|
+
var nz = mat.projectPoint(pos).z;
|
|
24479
|
+
return inverseVP.projectPoint(new Vector3(1, 1, nz));
|
|
23986
24480
|
};
|
|
23987
24481
|
/**
|
|
23988
24482
|
* 设置相机的旋转四元数
|
|
@@ -23994,7 +24488,6 @@ var Camera = /** @class */ (function () {
|
|
|
23994
24488
|
this.dirty = true;
|
|
23995
24489
|
}
|
|
23996
24490
|
else {
|
|
23997
|
-
this.options.quat;
|
|
23998
24491
|
if (!this.options.quat.equals(value)) {
|
|
23999
24492
|
this.options.quat.copyFrom(value);
|
|
24000
24493
|
this.dirty = true;
|
|
@@ -24162,8 +24655,7 @@ var CompositionComponent = /** @class */ (function (_super) {
|
|
|
24162
24655
|
}
|
|
24163
24656
|
item.getComponent(CompositionComponent).createContent();
|
|
24164
24657
|
}
|
|
24165
|
-
else if (itemData.type ===
|
|
24166
|
-
itemData.type === ItemType$1.sprite ||
|
|
24658
|
+
else if (itemData.type === ItemType$1.sprite ||
|
|
24167
24659
|
itemData.type === ItemType$1.text ||
|
|
24168
24660
|
itemData.type === ItemType$1.particle ||
|
|
24169
24661
|
itemData.type === ItemType$1.mesh ||
|
|
@@ -24181,20 +24673,7 @@ var CompositionComponent = /** @class */ (function (_super) {
|
|
|
24181
24673
|
item = new VFXItem(this.engine, itemData);
|
|
24182
24674
|
item.composition = this.item.composition;
|
|
24183
24675
|
// 兼容老的数据代码,json 更新后可移除
|
|
24184
|
-
|
|
24185
|
-
case ItemType$1.text: {
|
|
24186
|
-
// 添加文本组件
|
|
24187
|
-
var textItem = new TextComponent(this.engine, itemData.content);
|
|
24188
|
-
textItem.item = item;
|
|
24189
|
-
item.components.push(textItem);
|
|
24190
|
-
item.rendererComponents.push(textItem);
|
|
24191
|
-
item._content = textItem;
|
|
24192
|
-
break;
|
|
24193
|
-
}
|
|
24194
|
-
default: {
|
|
24195
|
-
item = createVFXItem(itemData, this.item.composition);
|
|
24196
|
-
}
|
|
24197
|
-
}
|
|
24676
|
+
item = createVFXItem(itemData, this.item.composition);
|
|
24198
24677
|
}
|
|
24199
24678
|
item.parent = this.item;
|
|
24200
24679
|
// 相机不跟随合成移动
|
|
@@ -25584,10 +26063,8 @@ var Engine = /** @class */ (function () {
|
|
|
25584
26063
|
Engine.prototype.addPackageDatas = function (scene) {
|
|
25585
26064
|
var e_1, _a, e_2, _b, e_3, _c, e_4, _d, e_5, _e, e_6, _f;
|
|
25586
26065
|
var jsonScene = scene.jsonScene;
|
|
25587
|
-
//@ts-expect-error
|
|
25588
26066
|
if (jsonScene.items) {
|
|
25589
26067
|
try {
|
|
25590
|
-
//@ts-expect-error
|
|
25591
26068
|
for (var _g = __values$1(jsonScene.items), _h = _g.next(); !_h.done; _h = _g.next()) {
|
|
25592
26069
|
var vfxItemData = _h.value;
|
|
25593
26070
|
this.addEffectsObjectData(vfxItemData);
|
|
@@ -25601,10 +26078,8 @@ var Engine = /** @class */ (function () {
|
|
|
25601
26078
|
finally { if (e_1) throw e_1.error; }
|
|
25602
26079
|
}
|
|
25603
26080
|
}
|
|
25604
|
-
//@ts-expect-error
|
|
25605
26081
|
if (jsonScene.materials) {
|
|
25606
26082
|
try {
|
|
25607
|
-
//@ts-expect-error
|
|
25608
26083
|
for (var _j = __values$1(jsonScene.materials), _k = _j.next(); !_k.done; _k = _j.next()) {
|
|
25609
26084
|
var materialData = _k.value;
|
|
25610
26085
|
this.addEffectsObjectData(materialData);
|
|
@@ -25618,10 +26093,8 @@ var Engine = /** @class */ (function () {
|
|
|
25618
26093
|
finally { if (e_2) throw e_2.error; }
|
|
25619
26094
|
}
|
|
25620
26095
|
}
|
|
25621
|
-
//@ts-expect-error
|
|
25622
26096
|
if (jsonScene.shaders) {
|
|
25623
26097
|
try {
|
|
25624
|
-
//@ts-expect-error
|
|
25625
26098
|
for (var _l = __values$1(jsonScene.shaders), _m = _l.next(); !_m.done; _m = _l.next()) {
|
|
25626
26099
|
var shaderData = _m.value;
|
|
25627
26100
|
this.addEffectsObjectData(shaderData);
|
|
@@ -25635,10 +26108,8 @@ var Engine = /** @class */ (function () {
|
|
|
25635
26108
|
finally { if (e_3) throw e_3.error; }
|
|
25636
26109
|
}
|
|
25637
26110
|
}
|
|
25638
|
-
//@ts-expect-error
|
|
25639
26111
|
if (jsonScene.geometries) {
|
|
25640
26112
|
try {
|
|
25641
|
-
//@ts-expect-error
|
|
25642
26113
|
for (var _o = __values$1(jsonScene.geometries), _p = _o.next(); !_p.done; _p = _o.next()) {
|
|
25643
26114
|
var geometryData = _p.value;
|
|
25644
26115
|
this.addEffectsObjectData(geometryData);
|
|
@@ -25652,10 +26123,8 @@ var Engine = /** @class */ (function () {
|
|
|
25652
26123
|
finally { if (e_4) throw e_4.error; }
|
|
25653
26124
|
}
|
|
25654
26125
|
}
|
|
25655
|
-
//@ts-expect-error
|
|
25656
26126
|
if (jsonScene.components) {
|
|
25657
26127
|
try {
|
|
25658
|
-
//@ts-expect-error
|
|
25659
26128
|
for (var _q = __values$1(jsonScene.components), _r = _q.next(); !_r.done; _r = _q.next()) {
|
|
25660
26129
|
var componentData = _r.value;
|
|
25661
26130
|
this.addEffectsObjectData(componentData);
|
|
@@ -26580,13 +27049,13 @@ var ThreeMaterial = /** @class */ (function (_super) {
|
|
|
26580
27049
|
this.uniforms[name] = this.material.uniforms[name] = uniform;
|
|
26581
27050
|
};
|
|
26582
27051
|
// 下列三个方法暂时不需要实现
|
|
26583
|
-
ThreeMaterial.prototype.
|
|
27052
|
+
ThreeMaterial.prototype.enableMacro = function (keyword) {
|
|
26584
27053
|
throw new Error('Method not implemented.');
|
|
26585
27054
|
};
|
|
26586
|
-
ThreeMaterial.prototype.
|
|
27055
|
+
ThreeMaterial.prototype.disableMacro = function (keyword) {
|
|
26587
27056
|
throw new Error('Method not implemented.');
|
|
26588
27057
|
};
|
|
26589
|
-
ThreeMaterial.prototype.
|
|
27058
|
+
ThreeMaterial.prototype.isMacroEnabled = function (keyword) {
|
|
26590
27059
|
throw new Error('Method not implemented.');
|
|
26591
27060
|
};
|
|
26592
27061
|
ThreeMaterial.prototype.clone = function (props) {
|
|
@@ -27644,7 +28113,7 @@ Geometry.create = function (engine, options) {
|
|
|
27644
28113
|
Mesh.create = function (engine, props) {
|
|
27645
28114
|
return new ThreeMesh(engine, props);
|
|
27646
28115
|
};
|
|
27647
|
-
var version = "2.0.0-alpha.
|
|
28116
|
+
var version = "2.0.0-alpha.5";
|
|
27648
28117
|
logger.info('THREEJS plugin version: ' + version);
|
|
27649
28118
|
|
|
27650
28119
|
exports.AbstractPlugin = AbstractPlugin;
|
|
@@ -27737,6 +28206,7 @@ exports.SPRITE_VERTEX_STRIDE = SPRITE_VERTEX_STRIDE;
|
|
|
27737
28206
|
exports.SemanticMap = SemanticMap;
|
|
27738
28207
|
exports.SerializationHelper = SerializationHelper;
|
|
27739
28208
|
exports.Shader = Shader;
|
|
28209
|
+
exports.ShaderVariant = ShaderVariant;
|
|
27740
28210
|
exports.SpriteColorPlayable = SpriteColorPlayable;
|
|
27741
28211
|
exports.SpriteComponent = SpriteComponent;
|
|
27742
28212
|
exports.SpriteLoader = SpriteLoader;
|
|
@@ -27813,7 +28283,7 @@ exports.gaussianDownHFrag = gaussianDownHFrag;
|
|
|
27813
28283
|
exports.gaussianDownVFrag = gaussianDownVFrag;
|
|
27814
28284
|
exports.gaussianUpFrag = gaussianUpFrag;
|
|
27815
28285
|
exports.generateEmptyTypedArray = generateEmptyTypedArray;
|
|
27816
|
-
exports.generateGUID = generateGUID;
|
|
28286
|
+
exports.generateGUID = generateGUID$1;
|
|
27817
28287
|
exports.generateHalfFloatTexture = generateHalfFloatTexture;
|
|
27818
28288
|
exports.getBackgroundImage = getBackgroundImage;
|
|
27819
28289
|
exports.getColorFromGradientStops = getColorFromGradientStops;
|
|
@@ -27870,7 +28340,7 @@ exports.nearestPowerOfTwo = nearestPowerOfTwo;
|
|
|
27870
28340
|
exports.noop = noop;
|
|
27871
28341
|
exports.parsePercent = parsePercent$1;
|
|
27872
28342
|
exports.particleFrag = particleFrag;
|
|
27873
|
-
exports.particleOriginTranslateMap = particleOriginTranslateMap;
|
|
28343
|
+
exports.particleOriginTranslateMap = particleOriginTranslateMap$1;
|
|
27874
28344
|
exports.particleVert = particleVert;
|
|
27875
28345
|
exports.pluginLoaderMap = pluginLoaderMap;
|
|
27876
28346
|
exports.random = random;
|