@galacean/effects-threejs 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 +727 -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 +763 -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.4
|
|
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.2
|
|
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.2
|
|
21028
21136
|
*/
|
|
21029
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
|
|
21165
|
+
*/
|
|
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,309 @@ 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;
|
|
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, _h, e_3, _j;
|
|
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 _k = (e_2 = void 0, __values(composition.items)), _l = _k.next(); !_l.done; _l = _k.next()) {
|
|
22706
|
+
var item = _l.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 (_l && !_l.done && (_h = _k.return)) _h.call(_k);
|
|
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 _m = (e_3 = void 0, __values(result.items)), _o = _m.next(); !_o.done; _o = _m.next()) {
|
|
22739
|
+
var item = _o.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
|
+
//@ts-expect-error
|
|
22789
|
+
item.transform.position.x += -realAnchor[0] * startSize.x;
|
|
22790
|
+
//@ts-expect-error
|
|
22791
|
+
item.transform.position.y += -realAnchor[1] * startSize.y;
|
|
22792
|
+
}
|
|
22793
|
+
//@ts-expect-error
|
|
22794
|
+
item.transform.anchor = { x: realAnchor[0] * startSize.x, y: realAnchor[1] * startSize.y };
|
|
22795
|
+
}
|
|
22796
|
+
}
|
|
22797
|
+
if (item.type === ItemType.particle) {
|
|
22798
|
+
var content = item.content;
|
|
22799
|
+
if (!content.renderer) {
|
|
22800
|
+
content.renderer = {};
|
|
22801
|
+
}
|
|
22802
|
+
var renderer = content.renderer;
|
|
22803
|
+
content.renderer.anchor = convertAnchor$1(renderer.anchor, renderer.particleOrigin);
|
|
22804
|
+
}
|
|
22805
|
+
// 动画数据转化 TODO: 动画数据移到 TimelineComponentData
|
|
22806
|
+
item.content.tracks = [];
|
|
22807
|
+
var tracks = item.content.tracks;
|
|
22808
|
+
if (item.type !== ItemType.particle) {
|
|
22809
|
+
tracks.push({
|
|
22810
|
+
clips: [
|
|
22811
|
+
{
|
|
22812
|
+
dataType: 'TransformAnimationPlayableAsset',
|
|
22813
|
+
animationClip: {
|
|
22814
|
+
sizeOverLifetime: item.content.sizeOverLifetime,
|
|
22815
|
+
rotationOverLifetime: item.content.rotationOverLifetime,
|
|
22816
|
+
positionOverLifetime: item.content.positionOverLifetime,
|
|
22817
|
+
},
|
|
22818
|
+
},
|
|
22819
|
+
],
|
|
22820
|
+
});
|
|
22821
|
+
}
|
|
22822
|
+
if (item.type === ItemType.sprite) {
|
|
22823
|
+
tracks.push({
|
|
22824
|
+
clips: [
|
|
22825
|
+
{
|
|
22826
|
+
dataType: 'SpriteColorAnimationPlayableAsset',
|
|
22827
|
+
animationClip: {
|
|
22828
|
+
colorOverLifetime: item.content.colorOverLifetime,
|
|
22829
|
+
startColor: item.content.options.startColor,
|
|
22830
|
+
},
|
|
22831
|
+
},
|
|
22832
|
+
],
|
|
22833
|
+
});
|
|
22834
|
+
}
|
|
22835
|
+
// gizmo 的 target id 转换为新的 item guid
|
|
22836
|
+
if (item.content.options.target) {
|
|
22837
|
+
item.content.options.target = itemGuidMap[item.content.options.target];
|
|
22838
|
+
}
|
|
22839
|
+
// item 的 content 转为 component data 加入 JSONScene.components
|
|
22840
|
+
var uuid = generateGUID();
|
|
22841
|
+
if (item.type === ItemType.sprite) {
|
|
22842
|
+
item.components = [];
|
|
22843
|
+
result.components.push(item.content);
|
|
22844
|
+
item.content.id = uuid;
|
|
22845
|
+
item.content.dataType = DataType.SpriteComponent;
|
|
22846
|
+
item.content.item = { id: item.id };
|
|
22847
|
+
item.dataType = DataType.VFXItemData;
|
|
22848
|
+
//@ts-expect-error
|
|
22849
|
+
item.components.push({ id: item.content.id });
|
|
22850
|
+
}
|
|
22851
|
+
else if (item.type === ItemType.particle) {
|
|
22852
|
+
item.components = [];
|
|
22853
|
+
result.components.push(item.content);
|
|
22854
|
+
item.content.id = uuid;
|
|
22855
|
+
item.content.dataType = DataType.ParticleSystem;
|
|
22856
|
+
item.content.item = { id: item.id };
|
|
22857
|
+
item.dataType = DataType.VFXItemData;
|
|
22858
|
+
//@ts-expect-error
|
|
22859
|
+
item.components.push({ id: item.content.id });
|
|
22860
|
+
}
|
|
22861
|
+
else if (item.type === ItemType.mesh) {
|
|
22862
|
+
item.components = [];
|
|
22863
|
+
result.components.push(item.content);
|
|
22864
|
+
item.content.id = uuid;
|
|
22865
|
+
item.content.dataType = DataType.MeshComponent;
|
|
22866
|
+
item.content.item = { id: item.id };
|
|
22867
|
+
item.dataType = DataType.VFXItemData;
|
|
22868
|
+
//@ts-expect-error
|
|
22869
|
+
item.components.push({ id: item.content.id });
|
|
22870
|
+
}
|
|
22871
|
+
else if (item.type === ItemType.skybox) {
|
|
22872
|
+
item.components = [];
|
|
22873
|
+
result.components.push(item.content);
|
|
22874
|
+
item.content.id = uuid;
|
|
22875
|
+
item.content.dataType = DataType.SkyboxComponent;
|
|
22876
|
+
item.content.item = { id: item.id };
|
|
22877
|
+
item.dataType = DataType.VFXItemData;
|
|
22878
|
+
//@ts-expect-error
|
|
22879
|
+
item.components.push({ id: item.content.id });
|
|
22880
|
+
}
|
|
22881
|
+
else if (item.type === ItemType.light) {
|
|
22882
|
+
item.components = [];
|
|
22883
|
+
result.components.push(item.content);
|
|
22884
|
+
item.content.id = uuid;
|
|
22885
|
+
item.content.dataType = DataType.LightComponent;
|
|
22886
|
+
item.content.item = { id: item.id };
|
|
22887
|
+
item.dataType = DataType.VFXItemData;
|
|
22888
|
+
//@ts-expect-error
|
|
22889
|
+
item.components.push({ id: item.content.id });
|
|
22890
|
+
}
|
|
22891
|
+
else if (item.type === 'camera') {
|
|
22892
|
+
item.components = [];
|
|
22893
|
+
result.components.push(item.content);
|
|
22894
|
+
item.content.id = uuid;
|
|
22895
|
+
item.content.dataType = DataType.CameraComponent;
|
|
22896
|
+
item.content.item = { id: item.id };
|
|
22897
|
+
item.dataType = DataType.VFXItemData;
|
|
22898
|
+
//@ts-expect-error
|
|
22899
|
+
item.components.push({ id: item.content.id });
|
|
22900
|
+
}
|
|
22901
|
+
else if (item.type === ItemType.tree) {
|
|
22902
|
+
item.components = [];
|
|
22903
|
+
result.components.push(item.content);
|
|
22904
|
+
item.content.id = uuid;
|
|
22905
|
+
item.content.dataType = DataType.TreeComponent;
|
|
22906
|
+
item.content.item = { id: item.id };
|
|
22907
|
+
item.dataType = DataType.VFXItemData;
|
|
22908
|
+
//@ts-expect-error
|
|
22909
|
+
item.components.push({ id: item.content.id });
|
|
22910
|
+
}
|
|
22911
|
+
else if (item.type === ItemType.interact) {
|
|
22912
|
+
item.components = [];
|
|
22913
|
+
result.components.push(item.content);
|
|
22914
|
+
item.content.id = uuid;
|
|
22915
|
+
item.content.dataType = DataType.InteractComponent;
|
|
22916
|
+
item.content.item = { id: item.id };
|
|
22917
|
+
item.dataType = DataType.VFXItemData;
|
|
22918
|
+
//@ts-expect-error
|
|
22919
|
+
item.components.push({ id: item.content.id });
|
|
22920
|
+
}
|
|
22921
|
+
else if (item.type === ItemType.camera) {
|
|
22922
|
+
item.components = [];
|
|
22923
|
+
result.components.push(item.content);
|
|
22924
|
+
item.content.id = uuid;
|
|
22925
|
+
item.content.dataType = DataType.CameraController;
|
|
22926
|
+
item.content.item = { id: item.id };
|
|
22927
|
+
item.dataType = DataType.VFXItemData;
|
|
22928
|
+
//@ts-expect-error
|
|
22929
|
+
item.components.push({ id: item.content.id });
|
|
22930
|
+
}
|
|
22931
|
+
else if (item.type === ItemType.text) {
|
|
22932
|
+
item.components = [];
|
|
22933
|
+
result.components.push(item.content);
|
|
22934
|
+
item.content.id = uuid;
|
|
22935
|
+
item.content.dataType = DataType.TextComponent;
|
|
22936
|
+
item.content.item = { id: item.id };
|
|
22937
|
+
item.dataType = DataType.VFXItemData;
|
|
22938
|
+
//@ts-expect-error
|
|
22939
|
+
item.components.push({ id: item.content.id });
|
|
22940
|
+
}
|
|
22941
|
+
}
|
|
22942
|
+
}
|
|
22943
|
+
catch (e_3_1) { e_3 = { error: e_3_1 }; }
|
|
22944
|
+
finally {
|
|
22945
|
+
try {
|
|
22946
|
+
if (_o && !_o.done && (_j = _m.return)) _j.call(_m);
|
|
22947
|
+
}
|
|
22948
|
+
finally { if (e_3) throw e_3.error; }
|
|
22949
|
+
}
|
|
22950
|
+
};
|
|
22951
|
+
try {
|
|
22952
|
+
// 更正Composition.endBehavior
|
|
22953
|
+
for (var _f = __values(json.compositions), _g = _f.next(); !_g.done; _g = _f.next()) {
|
|
22954
|
+
var composition = _g.value;
|
|
22955
|
+
_loop_1(composition);
|
|
22956
|
+
}
|
|
22957
|
+
}
|
|
22958
|
+
catch (e_1_1) { e_1 = { error: e_1_1 }; }
|
|
22959
|
+
finally {
|
|
22960
|
+
try {
|
|
22961
|
+
if (_g && !_g.done && (_a = _f.return)) _a.call(_f);
|
|
22962
|
+
}
|
|
22963
|
+
finally { if (e_1) throw e_1.error; }
|
|
22964
|
+
}
|
|
22965
|
+
result.version = '3.0';
|
|
22966
|
+
return result;
|
|
22967
|
+
}
|
|
22397
22968
|
|
|
22398
22969
|
var v0 = /^(\d+)\.(\d+)\.(\d+)(-(\w+)\.\d+)?$/;
|
|
22399
22970
|
var standardVersion = /^(\d+)\.(\d+)$/;
|
|
@@ -22403,16 +22974,16 @@ function getStandardJSON(json) {
|
|
|
22403
22974
|
if (!json || typeof json !== 'object') {
|
|
22404
22975
|
throw Error('expect a json object');
|
|
22405
22976
|
}
|
|
22406
|
-
// 修正老版本数据中,meshItem以及lightItem结束行为错误问题
|
|
22977
|
+
// 修正老版本数据中,meshItem 以及 lightItem 结束行为错误问题
|
|
22407
22978
|
version22Migration(json);
|
|
22408
22979
|
if (v0.test(json.version)) {
|
|
22409
22980
|
reverseParticle = ((_a = (/^(\d+)/).exec(json.version)) === null || _a === void 0 ? void 0 : _a[0]) === '0';
|
|
22410
|
-
return version21Migration(getStandardJSONFromV0(json));
|
|
22981
|
+
return version30Migration(version21Migration(getStandardJSONFromV0(json)));
|
|
22411
22982
|
}
|
|
22412
22983
|
var mainVersion = (_b = standardVersion.exec(json.version)) === null || _b === void 0 ? void 0 : _b[1];
|
|
22413
22984
|
if (mainVersion) {
|
|
22414
|
-
if (Number(mainVersion) <
|
|
22415
|
-
return version21Migration(json);
|
|
22985
|
+
if (Number(mainVersion) < 3) {
|
|
22986
|
+
return version30Migration(version21Migration(json));
|
|
22416
22987
|
}
|
|
22417
22988
|
return json;
|
|
22418
22989
|
}
|
|
@@ -22736,7 +23307,7 @@ function version3Migration(scene) {
|
|
|
22736
23307
|
try {
|
|
22737
23308
|
for (var _j = __values$1(ecScene.items), _k = _j.next(); !_k.done; _k = _j.next()) {
|
|
22738
23309
|
var item = _k.value;
|
|
22739
|
-
itemGuidMap[item.id] = generateGUID();
|
|
23310
|
+
itemGuidMap[item.id] = generateGUID$1();
|
|
22740
23311
|
// TODO: 编辑器测试用,上线后删除
|
|
22741
23312
|
//@ts-expect-error
|
|
22742
23313
|
item.oldId = item.id;
|
|
@@ -22792,7 +23363,7 @@ function version3Migration(scene) {
|
|
|
22792
23363
|
// texture 增加 id 和 dataType
|
|
22793
23364
|
for (var _q = __values$1(scene.textureOptions), _r = _q.next(); !_r.done; _r = _q.next()) {
|
|
22794
23365
|
var texture = _r.value;
|
|
22795
|
-
texture.id = generateGUID();
|
|
23366
|
+
texture.id = generateGUID$1();
|
|
22796
23367
|
texture.dataType = exports.DataType.Texture;
|
|
22797
23368
|
}
|
|
22798
23369
|
}
|
|
@@ -22812,23 +23383,15 @@ function version3Migration(scene) {
|
|
|
22812
23383
|
var item = _t.value;
|
|
22813
23384
|
// 原 texture 索引转为统一 guid 索引
|
|
22814
23385
|
if (item.content) {
|
|
22815
|
-
//@ts-expect-error
|
|
22816
23386
|
if (item.content.renderer) {
|
|
22817
|
-
//@ts-expect-error
|
|
22818
23387
|
if (item.content.renderer.texture !== undefined) {
|
|
22819
|
-
//@ts-expect-error
|
|
22820
23388
|
var oldTextureId = item.content.renderer.texture;
|
|
22821
|
-
//@ts-expect-error
|
|
22822
23389
|
item.content.renderer.texture = { id: scene.textureOptions[oldTextureId].id };
|
|
22823
23390
|
}
|
|
22824
23391
|
}
|
|
22825
|
-
//@ts-expect-error
|
|
22826
23392
|
if (item.content.trails) {
|
|
22827
|
-
//@ts-expect-error
|
|
22828
23393
|
if (item.content.trails.texture !== undefined) {
|
|
22829
|
-
//@ts-expect-error
|
|
22830
23394
|
var oldTextureId = item.content.trails.texture;
|
|
22831
|
-
//@ts-expect-error
|
|
22832
23395
|
item.content.trails.texture = { id: scene.textureOptions[oldTextureId].id };
|
|
22833
23396
|
}
|
|
22834
23397
|
}
|
|
@@ -22839,12 +23402,14 @@ function version3Migration(scene) {
|
|
|
22839
23402
|
var rotation = item.transform.rotation;
|
|
22840
23403
|
var scale = item.transform.scale;
|
|
22841
23404
|
if (!position) {
|
|
23405
|
+
//@ts-expect-error
|
|
22842
23406
|
position = [0, 0, 0];
|
|
22843
23407
|
}
|
|
22844
23408
|
if (!rotation) {
|
|
22845
23409
|
rotation = [0, 0, 0];
|
|
22846
23410
|
}
|
|
22847
23411
|
if (!scale) {
|
|
23412
|
+
//@ts-expect-error
|
|
22848
23413
|
scale = [1, 1, 1];
|
|
22849
23414
|
}
|
|
22850
23415
|
item.transform = {
|
|
@@ -22865,12 +23430,9 @@ function version3Migration(scene) {
|
|
|
22865
23430
|
// sprite 的 anchor 修正
|
|
22866
23431
|
if (item.type === ItemType$1.sprite) {
|
|
22867
23432
|
var content = item.content;
|
|
22868
|
-
//@ts-expect-error
|
|
22869
23433
|
if (!content.renderer) {
|
|
22870
|
-
//@ts-expect-error
|
|
22871
23434
|
content.renderer = {};
|
|
22872
23435
|
}
|
|
22873
|
-
//@ts-expect-error
|
|
22874
23436
|
var renderer = content.renderer;
|
|
22875
23437
|
var realAnchor = convertAnchor(renderer.anchor, renderer.particleOrigin);
|
|
22876
23438
|
//@ts-expect-error
|
|
@@ -22888,14 +23450,10 @@ function version3Migration(scene) {
|
|
|
22888
23450
|
}
|
|
22889
23451
|
if (item.type === ItemType$1.particle) {
|
|
22890
23452
|
var content = item.content;
|
|
22891
|
-
//@ts-expect-error
|
|
22892
23453
|
if (!content.renderer) {
|
|
22893
|
-
//@ts-expect-error
|
|
22894
23454
|
content.renderer = {};
|
|
22895
23455
|
}
|
|
22896
|
-
//@ts-expect-error
|
|
22897
23456
|
var renderer = content.renderer;
|
|
22898
|
-
//@ts-expect-error
|
|
22899
23457
|
content.renderer.anchor = convertAnchor(renderer.anchor, renderer.particleOrigin);
|
|
22900
23458
|
}
|
|
22901
23459
|
// item 的 endbehaviour 兼容
|
|
@@ -22904,9 +23462,7 @@ function version3Migration(scene) {
|
|
|
22904
23462
|
item.endBehavior = END_BEHAVIOR_FREEZE$1;
|
|
22905
23463
|
}
|
|
22906
23464
|
// 动画数据转化 TODO: 动画数据移到 TimelineComponentData
|
|
22907
|
-
//@ts-expect-error
|
|
22908
23465
|
item.content.tracks = [];
|
|
22909
|
-
//@ts-expect-error
|
|
22910
23466
|
var tracks = item.content.tracks;
|
|
22911
23467
|
if (item.type !== ItemType$1.particle) {
|
|
22912
23468
|
tracks.push({
|
|
@@ -22914,11 +23470,8 @@ function version3Migration(scene) {
|
|
|
22914
23470
|
{
|
|
22915
23471
|
dataType: 'TransformAnimationPlayableAsset',
|
|
22916
23472
|
animationClip: {
|
|
22917
|
-
//@ts-expect-error
|
|
22918
23473
|
sizeOverLifetime: item.content.sizeOverLifetime,
|
|
22919
|
-
//@ts-expect-error
|
|
22920
23474
|
rotationOverLifetime: item.content.rotationOverLifetime,
|
|
22921
|
-
//@ts-expect-error
|
|
22922
23475
|
positionOverLifetime: item.content.positionOverLifetime,
|
|
22923
23476
|
},
|
|
22924
23477
|
},
|
|
@@ -22931,9 +23484,7 @@ function version3Migration(scene) {
|
|
|
22931
23484
|
{
|
|
22932
23485
|
dataType: 'SpriteColorAnimationPlayableAsset',
|
|
22933
23486
|
animationClip: {
|
|
22934
|
-
//@ts-expect-error
|
|
22935
23487
|
colorOverLifetime: item.content.colorOverLifetime,
|
|
22936
|
-
//@ts-expect-error
|
|
22937
23488
|
startColor: item.content.options.startColor,
|
|
22938
23489
|
},
|
|
22939
23490
|
},
|
|
@@ -22941,169 +23492,107 @@ function version3Migration(scene) {
|
|
|
22941
23492
|
});
|
|
22942
23493
|
}
|
|
22943
23494
|
// gizmo 的 target id 转换为新的 item guid
|
|
22944
|
-
|
|
22945
|
-
if (item.content.options.target) {
|
|
22946
|
-
//@ts-expect-error
|
|
23495
|
+
if (item.content && item.content.options && item.content.options.target) {
|
|
22947
23496
|
item.content.options.target = itemGuidMap[item.content.options.target];
|
|
22948
23497
|
}
|
|
22949
23498
|
// item 的 content 转为 component data 加入 JSONScene.components
|
|
22950
|
-
var uuid = v4().replace(/-/g, '');
|
|
23499
|
+
var uuid = v4$1().replace(/-/g, '');
|
|
22951
23500
|
if (item.type === ItemType$1.sprite) {
|
|
22952
|
-
//@ts-expect-error
|
|
22953
23501
|
item.components = [];
|
|
22954
|
-
//@ts-expect-error
|
|
22955
23502
|
components.push(item.content);
|
|
22956
|
-
//@ts-expect-error
|
|
22957
23503
|
item.content.id = uuid;
|
|
22958
|
-
//@ts-expect-error
|
|
22959
23504
|
item.content.dataType = exports.DataType.SpriteComponent;
|
|
22960
|
-
//@ts-expect-error
|
|
22961
23505
|
item.content.item = { id: item.id };
|
|
22962
|
-
//@ts-expect-error
|
|
22963
23506
|
item.dataType = exports.DataType.VFXItemData;
|
|
22964
23507
|
//@ts-expect-error
|
|
22965
23508
|
item.components.push({ id: item.content.id });
|
|
22966
23509
|
}
|
|
22967
23510
|
else if (item.type === ItemType$1.particle) {
|
|
22968
|
-
//@ts-expect-error
|
|
22969
23511
|
item.components = [];
|
|
22970
|
-
//@ts-expect-error
|
|
22971
23512
|
components.push(item.content);
|
|
22972
|
-
//@ts-expect-error
|
|
22973
23513
|
item.content.id = uuid;
|
|
22974
|
-
//@ts-expect-error
|
|
22975
23514
|
item.content.dataType = exports.DataType.ParticleSystem;
|
|
22976
|
-
//@ts-expect-error
|
|
22977
23515
|
item.content.item = { id: item.id };
|
|
22978
|
-
//@ts-expect-error
|
|
22979
23516
|
item.dataType = exports.DataType.VFXItemData;
|
|
22980
23517
|
//@ts-expect-error
|
|
22981
23518
|
item.components.push({ id: item.content.id });
|
|
22982
23519
|
}
|
|
22983
23520
|
else if (item.type === ItemType$1.mesh) {
|
|
22984
|
-
//@ts-expect-error
|
|
22985
23521
|
item.components = [];
|
|
22986
|
-
//@ts-expect-error
|
|
22987
23522
|
components.push(item.content);
|
|
22988
|
-
//@ts-expect-error
|
|
22989
23523
|
item.content.id = uuid;
|
|
22990
|
-
//@ts-expect-error
|
|
22991
23524
|
item.content.dataType = exports.DataType.MeshComponent;
|
|
22992
|
-
//@ts-expect-error
|
|
22993
23525
|
item.content.item = { id: item.id };
|
|
22994
|
-
//@ts-expect-error
|
|
22995
23526
|
item.dataType = exports.DataType.VFXItemData;
|
|
22996
23527
|
//@ts-expect-error
|
|
22997
23528
|
item.components.push({ id: item.content.id });
|
|
22998
23529
|
}
|
|
22999
23530
|
else if (item.type === ItemType$1.skybox) {
|
|
23000
|
-
//@ts-expect-error
|
|
23001
23531
|
item.components = [];
|
|
23002
|
-
//@ts-expect-error
|
|
23003
23532
|
components.push(item.content);
|
|
23004
|
-
//@ts-expect-error
|
|
23005
23533
|
item.content.id = uuid;
|
|
23006
|
-
//@ts-expect-error
|
|
23007
23534
|
item.content.dataType = exports.DataType.SkyboxComponent;
|
|
23008
|
-
//@ts-expect-error
|
|
23009
23535
|
item.content.item = { id: item.id };
|
|
23010
|
-
//@ts-expect-error
|
|
23011
23536
|
item.dataType = exports.DataType.VFXItemData;
|
|
23012
23537
|
//@ts-expect-error
|
|
23013
23538
|
item.components.push({ id: item.content.id });
|
|
23014
23539
|
}
|
|
23015
23540
|
else if (item.type === ItemType$1.light) {
|
|
23016
|
-
//@ts-expect-error
|
|
23017
23541
|
item.components = [];
|
|
23018
|
-
//@ts-expect-error
|
|
23019
23542
|
components.push(item.content);
|
|
23020
|
-
//@ts-expect-error
|
|
23021
23543
|
item.content.id = uuid;
|
|
23022
|
-
//@ts-expect-error
|
|
23023
23544
|
item.content.dataType = exports.DataType.LightComponent;
|
|
23024
|
-
//@ts-expect-error
|
|
23025
23545
|
item.content.item = { id: item.id };
|
|
23026
|
-
//@ts-expect-error
|
|
23027
23546
|
item.dataType = exports.DataType.VFXItemData;
|
|
23028
23547
|
//@ts-expect-error
|
|
23029
23548
|
item.components.push({ id: item.content.id });
|
|
23030
23549
|
}
|
|
23031
23550
|
else if (item.type === 'camera') {
|
|
23032
|
-
//@ts-expect-error
|
|
23033
23551
|
item.components = [];
|
|
23034
|
-
//@ts-expect-error
|
|
23035
23552
|
components.push(item.content);
|
|
23036
|
-
//@ts-expect-error
|
|
23037
23553
|
item.content.id = uuid;
|
|
23038
|
-
//@ts-expect-error
|
|
23039
23554
|
item.content.dataType = exports.DataType.CameraComponent;
|
|
23040
|
-
//@ts-expect-error
|
|
23041
23555
|
item.content.item = { id: item.id };
|
|
23042
|
-
//@ts-expect-error
|
|
23043
23556
|
item.dataType = exports.DataType.VFXItemData;
|
|
23044
23557
|
//@ts-expect-error
|
|
23045
23558
|
item.components.push({ id: item.content.id });
|
|
23046
23559
|
}
|
|
23047
23560
|
else if (item.type === ItemType$1.tree) {
|
|
23048
|
-
//@ts-expect-error
|
|
23049
23561
|
item.components = [];
|
|
23050
|
-
//@ts-expect-error
|
|
23051
23562
|
components.push(item.content);
|
|
23052
|
-
//@ts-expect-error
|
|
23053
23563
|
item.content.id = uuid;
|
|
23054
|
-
//@ts-expect-error
|
|
23055
23564
|
item.content.dataType = exports.DataType.TreeComponent;
|
|
23056
|
-
//@ts-expect-error
|
|
23057
23565
|
item.content.item = { id: item.id };
|
|
23058
|
-
//@ts-expect-error
|
|
23059
23566
|
item.dataType = exports.DataType.VFXItemData;
|
|
23060
23567
|
//@ts-expect-error
|
|
23061
23568
|
item.components.push({ id: item.content.id });
|
|
23062
23569
|
}
|
|
23063
23570
|
else if (item.type === ItemType$1.interact) {
|
|
23064
|
-
//@ts-expect-error
|
|
23065
23571
|
item.components = [];
|
|
23066
|
-
//@ts-expect-error
|
|
23067
23572
|
components.push(item.content);
|
|
23068
|
-
//@ts-expect-error
|
|
23069
23573
|
item.content.id = uuid;
|
|
23070
|
-
//@ts-expect-error
|
|
23071
23574
|
item.content.dataType = exports.DataType.InteractComponent;
|
|
23072
|
-
//@ts-expect-error
|
|
23073
23575
|
item.content.item = { id: item.id };
|
|
23074
|
-
//@ts-expect-error
|
|
23075
23576
|
item.dataType = exports.DataType.VFXItemData;
|
|
23076
23577
|
//@ts-expect-error
|
|
23077
23578
|
item.components.push({ id: item.content.id });
|
|
23078
23579
|
}
|
|
23079
23580
|
else if (item.type === ItemType$1.camera) {
|
|
23080
|
-
//@ts-expect-error
|
|
23081
23581
|
item.components = [];
|
|
23082
|
-
//@ts-expect-error
|
|
23083
23582
|
components.push(item.content);
|
|
23084
|
-
//@ts-expect-error
|
|
23085
23583
|
item.content.id = uuid;
|
|
23086
|
-
//@ts-expect-error
|
|
23087
23584
|
item.content.dataType = exports.DataType.CameraController;
|
|
23088
|
-
//@ts-expect-error
|
|
23089
23585
|
item.content.item = { id: item.id };
|
|
23090
|
-
//@ts-expect-error
|
|
23091
23586
|
item.dataType = exports.DataType.VFXItemData;
|
|
23092
23587
|
//@ts-expect-error
|
|
23093
23588
|
item.components.push({ id: item.content.id });
|
|
23094
23589
|
}
|
|
23095
23590
|
else if (item.type === ItemType$1.text) {
|
|
23096
|
-
//@ts-expect-error
|
|
23097
23591
|
item.components = [];
|
|
23098
|
-
//@ts-expect-error
|
|
23099
23592
|
components.push(item.content);
|
|
23100
|
-
//@ts-expect-error
|
|
23101
23593
|
item.content.id = uuid;
|
|
23102
|
-
//@ts-expect-error
|
|
23103
23594
|
item.content.dataType = exports.DataType.TextComponent;
|
|
23104
|
-
//@ts-expect-error
|
|
23105
23595
|
item.content.item = { id: item.id };
|
|
23106
|
-
//@ts-expect-error
|
|
23107
23596
|
item.dataType = exports.DataType.VFXItemData;
|
|
23108
23597
|
//@ts-expect-error
|
|
23109
23598
|
item.components.push({ id: item.content.id });
|
|
@@ -23127,7 +23616,7 @@ function convertAnchor(anchor, particleOrigin) {
|
|
|
23127
23616
|
return [anchor[0] - 0.5, 0.5 - anchor[1]];
|
|
23128
23617
|
}
|
|
23129
23618
|
else if (particleOrigin) {
|
|
23130
|
-
return particleOriginTranslateMap[particleOrigin];
|
|
23619
|
+
return particleOriginTranslateMap$1[particleOrigin];
|
|
23131
23620
|
}
|
|
23132
23621
|
else {
|
|
23133
23622
|
return [0, 0];
|
|
@@ -23405,16 +23894,17 @@ var AssetManager = /** @class */ (function () {
|
|
|
23405
23894
|
};
|
|
23406
23895
|
AssetManager.prototype.processBins = function (bins) {
|
|
23407
23896
|
return __awaiter(this, void 0, void 0, function () {
|
|
23408
|
-
var renderLevel, jobs;
|
|
23897
|
+
var renderLevel, baseUrl, jobs;
|
|
23409
23898
|
var _this = this;
|
|
23410
23899
|
return __generator(this, function (_a) {
|
|
23411
23900
|
renderLevel = this.options.renderLevel;
|
|
23901
|
+
baseUrl = this.baseUrl;
|
|
23412
23902
|
jobs = bins.map(function (bin) {
|
|
23413
23903
|
if (bin instanceof ArrayBuffer) {
|
|
23414
23904
|
return bin;
|
|
23415
23905
|
}
|
|
23416
23906
|
if (passRenderLevel(bin.renderLevel, renderLevel)) {
|
|
23417
|
-
return _this.loadBins(bin.url);
|
|
23907
|
+
return _this.loadBins(new URL(bin.url, baseUrl).href);
|
|
23418
23908
|
}
|
|
23419
23909
|
throw new Error("Invalid bins source: ".concat(JSON.stringify(bins)));
|
|
23420
23910
|
});
|
|
@@ -23432,13 +23922,14 @@ var AssetManager = /** @class */ (function () {
|
|
|
23432
23922
|
return [2 /*return*/];
|
|
23433
23923
|
}
|
|
23434
23924
|
jobs = fonts.map(function (font) { return __awaiter(_this, void 0, void 0, function () {
|
|
23435
|
-
var fontFace;
|
|
23925
|
+
var url, fontFace;
|
|
23436
23926
|
var _a;
|
|
23437
23927
|
return __generator(this, function (_b) {
|
|
23438
23928
|
switch (_b.label) {
|
|
23439
23929
|
case 0:
|
|
23440
23930
|
if (!(font.fontURL && !AssetManager.fonts.has(font.fontFamily))) return [3 /*break*/, 4];
|
|
23441
|
-
|
|
23931
|
+
url = new URL(font.fontURL, this.baseUrl).href;
|
|
23932
|
+
fontFace = new FontFace((_a = font.fontFamily) !== null && _a !== void 0 ? _a : '', 'url(' + url + ')');
|
|
23442
23933
|
_b.label = 1;
|
|
23443
23934
|
case 1:
|
|
23444
23935
|
_b.trys.push([1, 3, , 4]);
|
|
@@ -23451,7 +23942,7 @@ var AssetManager = /** @class */ (function () {
|
|
|
23451
23942
|
return [3 /*break*/, 4];
|
|
23452
23943
|
case 3:
|
|
23453
23944
|
_b.sent();
|
|
23454
|
-
logger.warn("Invalid fonts source: ".concat(JSON.stringify(
|
|
23945
|
+
logger.warn("Invalid fonts source: ".concat(JSON.stringify(url)));
|
|
23455
23946
|
return [3 /*break*/, 4];
|
|
23456
23947
|
case 4: return [2 /*return*/];
|
|
23457
23948
|
}
|
|
@@ -23700,7 +24191,7 @@ function createTextureOptionsBySource(image, sourceFrom) {
|
|
|
23700
24191
|
return image.source;
|
|
23701
24192
|
}
|
|
23702
24193
|
else if (image instanceof HTMLImageElement ||
|
|
23703
|
-
image
|
|
24194
|
+
isCanvas(image)) {
|
|
23704
24195
|
return {
|
|
23705
24196
|
image: image,
|
|
23706
24197
|
sourceType: exports.TextureSourceType.image,
|
|
@@ -23762,6 +24253,11 @@ function base64ToFile(base64, filename, contentType) {
|
|
|
23762
24253
|
var file = new File([blob], filename, { type: contentType });
|
|
23763
24254
|
return file;
|
|
23764
24255
|
}
|
|
24256
|
+
function isCanvas(cavnas) {
|
|
24257
|
+
var _a;
|
|
24258
|
+
// 小程序 Canvas 无法使用 instanceof HTMLCanvasElement 判断
|
|
24259
|
+
return typeof cavnas === 'object' && cavnas !== null && ((_a = cavnas.tagName) === null || _a === void 0 ? void 0 : _a.toUpperCase()) === 'CANVAS';
|
|
24260
|
+
}
|
|
23765
24261
|
|
|
23766
24262
|
var tmpScale = new Vector3(1, 1, 1);
|
|
23767
24263
|
/**
|
|
@@ -23981,8 +24477,9 @@ var Camera = /** @class */ (function () {
|
|
|
23981
24477
|
Camera.prototype.getInverseVPRatio = function (z) {
|
|
23982
24478
|
var pos = new Vector3(0, 0, z);
|
|
23983
24479
|
var mat = this.getViewProjectionMatrix();
|
|
23984
|
-
var
|
|
23985
|
-
|
|
24480
|
+
var inverseVP = this.getInverseViewProjectionMatrix();
|
|
24481
|
+
var nz = mat.projectPoint(pos).z;
|
|
24482
|
+
return inverseVP.projectPoint(new Vector3(1, 1, nz));
|
|
23986
24483
|
};
|
|
23987
24484
|
/**
|
|
23988
24485
|
* 设置相机的旋转四元数
|
|
@@ -23994,7 +24491,6 @@ var Camera = /** @class */ (function () {
|
|
|
23994
24491
|
this.dirty = true;
|
|
23995
24492
|
}
|
|
23996
24493
|
else {
|
|
23997
|
-
this.options.quat;
|
|
23998
24494
|
if (!this.options.quat.equals(value)) {
|
|
23999
24495
|
this.options.quat.copyFrom(value);
|
|
24000
24496
|
this.dirty = true;
|
|
@@ -24162,8 +24658,7 @@ var CompositionComponent = /** @class */ (function (_super) {
|
|
|
24162
24658
|
}
|
|
24163
24659
|
item.getComponent(CompositionComponent).createContent();
|
|
24164
24660
|
}
|
|
24165
|
-
else if (itemData.type ===
|
|
24166
|
-
itemData.type === ItemType$1.sprite ||
|
|
24661
|
+
else if (itemData.type === ItemType$1.sprite ||
|
|
24167
24662
|
itemData.type === ItemType$1.text ||
|
|
24168
24663
|
itemData.type === ItemType$1.particle ||
|
|
24169
24664
|
itemData.type === ItemType$1.mesh ||
|
|
@@ -24181,20 +24676,7 @@ var CompositionComponent = /** @class */ (function (_super) {
|
|
|
24181
24676
|
item = new VFXItem(this.engine, itemData);
|
|
24182
24677
|
item.composition = this.item.composition;
|
|
24183
24678
|
// 兼容老的数据代码,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
|
-
}
|
|
24679
|
+
item = createVFXItem(itemData, this.item.composition);
|
|
24198
24680
|
}
|
|
24199
24681
|
item.parent = this.item;
|
|
24200
24682
|
// 相机不跟随合成移动
|
|
@@ -25584,10 +26066,8 @@ var Engine = /** @class */ (function () {
|
|
|
25584
26066
|
Engine.prototype.addPackageDatas = function (scene) {
|
|
25585
26067
|
var e_1, _a, e_2, _b, e_3, _c, e_4, _d, e_5, _e, e_6, _f;
|
|
25586
26068
|
var jsonScene = scene.jsonScene;
|
|
25587
|
-
//@ts-expect-error
|
|
25588
26069
|
if (jsonScene.items) {
|
|
25589
26070
|
try {
|
|
25590
|
-
//@ts-expect-error
|
|
25591
26071
|
for (var _g = __values$1(jsonScene.items), _h = _g.next(); !_h.done; _h = _g.next()) {
|
|
25592
26072
|
var vfxItemData = _h.value;
|
|
25593
26073
|
this.addEffectsObjectData(vfxItemData);
|
|
@@ -25601,10 +26081,8 @@ var Engine = /** @class */ (function () {
|
|
|
25601
26081
|
finally { if (e_1) throw e_1.error; }
|
|
25602
26082
|
}
|
|
25603
26083
|
}
|
|
25604
|
-
//@ts-expect-error
|
|
25605
26084
|
if (jsonScene.materials) {
|
|
25606
26085
|
try {
|
|
25607
|
-
//@ts-expect-error
|
|
25608
26086
|
for (var _j = __values$1(jsonScene.materials), _k = _j.next(); !_k.done; _k = _j.next()) {
|
|
25609
26087
|
var materialData = _k.value;
|
|
25610
26088
|
this.addEffectsObjectData(materialData);
|
|
@@ -25618,10 +26096,8 @@ var Engine = /** @class */ (function () {
|
|
|
25618
26096
|
finally { if (e_2) throw e_2.error; }
|
|
25619
26097
|
}
|
|
25620
26098
|
}
|
|
25621
|
-
//@ts-expect-error
|
|
25622
26099
|
if (jsonScene.shaders) {
|
|
25623
26100
|
try {
|
|
25624
|
-
//@ts-expect-error
|
|
25625
26101
|
for (var _l = __values$1(jsonScene.shaders), _m = _l.next(); !_m.done; _m = _l.next()) {
|
|
25626
26102
|
var shaderData = _m.value;
|
|
25627
26103
|
this.addEffectsObjectData(shaderData);
|
|
@@ -25635,10 +26111,8 @@ var Engine = /** @class */ (function () {
|
|
|
25635
26111
|
finally { if (e_3) throw e_3.error; }
|
|
25636
26112
|
}
|
|
25637
26113
|
}
|
|
25638
|
-
//@ts-expect-error
|
|
25639
26114
|
if (jsonScene.geometries) {
|
|
25640
26115
|
try {
|
|
25641
|
-
//@ts-expect-error
|
|
25642
26116
|
for (var _o = __values$1(jsonScene.geometries), _p = _o.next(); !_p.done; _p = _o.next()) {
|
|
25643
26117
|
var geometryData = _p.value;
|
|
25644
26118
|
this.addEffectsObjectData(geometryData);
|
|
@@ -25652,10 +26126,8 @@ var Engine = /** @class */ (function () {
|
|
|
25652
26126
|
finally { if (e_4) throw e_4.error; }
|
|
25653
26127
|
}
|
|
25654
26128
|
}
|
|
25655
|
-
//@ts-expect-error
|
|
25656
26129
|
if (jsonScene.components) {
|
|
25657
26130
|
try {
|
|
25658
|
-
//@ts-expect-error
|
|
25659
26131
|
for (var _q = __values$1(jsonScene.components), _r = _q.next(); !_r.done; _r = _q.next()) {
|
|
25660
26132
|
var componentData = _r.value;
|
|
25661
26133
|
this.addEffectsObjectData(componentData);
|
|
@@ -26580,13 +27052,13 @@ var ThreeMaterial = /** @class */ (function (_super) {
|
|
|
26580
27052
|
this.uniforms[name] = this.material.uniforms[name] = uniform;
|
|
26581
27053
|
};
|
|
26582
27054
|
// 下列三个方法暂时不需要实现
|
|
26583
|
-
ThreeMaterial.prototype.
|
|
27055
|
+
ThreeMaterial.prototype.enableMacro = function (keyword) {
|
|
26584
27056
|
throw new Error('Method not implemented.');
|
|
26585
27057
|
};
|
|
26586
|
-
ThreeMaterial.prototype.
|
|
27058
|
+
ThreeMaterial.prototype.disableMacro = function (keyword) {
|
|
26587
27059
|
throw new Error('Method not implemented.');
|
|
26588
27060
|
};
|
|
26589
|
-
ThreeMaterial.prototype.
|
|
27061
|
+
ThreeMaterial.prototype.isMacroEnabled = function (keyword) {
|
|
26590
27062
|
throw new Error('Method not implemented.');
|
|
26591
27063
|
};
|
|
26592
27064
|
ThreeMaterial.prototype.clone = function (props) {
|
|
@@ -27644,7 +28116,7 @@ Geometry.create = function (engine, options) {
|
|
|
27644
28116
|
Mesh.create = function (engine, props) {
|
|
27645
28117
|
return new ThreeMesh(engine, props);
|
|
27646
28118
|
};
|
|
27647
|
-
var version = "2.0.0-alpha.
|
|
28119
|
+
var version = "2.0.0-alpha.4";
|
|
27648
28120
|
logger.info('THREEJS plugin version: ' + version);
|
|
27649
28121
|
|
|
27650
28122
|
exports.AbstractPlugin = AbstractPlugin;
|
|
@@ -27737,6 +28209,7 @@ exports.SPRITE_VERTEX_STRIDE = SPRITE_VERTEX_STRIDE;
|
|
|
27737
28209
|
exports.SemanticMap = SemanticMap;
|
|
27738
28210
|
exports.SerializationHelper = SerializationHelper;
|
|
27739
28211
|
exports.Shader = Shader;
|
|
28212
|
+
exports.ShaderVariant = ShaderVariant;
|
|
27740
28213
|
exports.SpriteColorPlayable = SpriteColorPlayable;
|
|
27741
28214
|
exports.SpriteComponent = SpriteComponent;
|
|
27742
28215
|
exports.SpriteLoader = SpriteLoader;
|
|
@@ -27813,7 +28286,7 @@ exports.gaussianDownHFrag = gaussianDownHFrag;
|
|
|
27813
28286
|
exports.gaussianDownVFrag = gaussianDownVFrag;
|
|
27814
28287
|
exports.gaussianUpFrag = gaussianUpFrag;
|
|
27815
28288
|
exports.generateEmptyTypedArray = generateEmptyTypedArray;
|
|
27816
|
-
exports.generateGUID = generateGUID;
|
|
28289
|
+
exports.generateGUID = generateGUID$1;
|
|
27817
28290
|
exports.generateHalfFloatTexture = generateHalfFloatTexture;
|
|
27818
28291
|
exports.getBackgroundImage = getBackgroundImage;
|
|
27819
28292
|
exports.getColorFromGradientStops = getColorFromGradientStops;
|
|
@@ -27870,7 +28343,7 @@ exports.nearestPowerOfTwo = nearestPowerOfTwo;
|
|
|
27870
28343
|
exports.noop = noop;
|
|
27871
28344
|
exports.parsePercent = parsePercent$1;
|
|
27872
28345
|
exports.particleFrag = particleFrag;
|
|
27873
|
-
exports.particleOriginTranslateMap = particleOriginTranslateMap;
|
|
28346
|
+
exports.particleOriginTranslateMap = particleOriginTranslateMap$1;
|
|
27874
28347
|
exports.particleVert = particleVert;
|
|
27875
28348
|
exports.pluginLoaderMap = pluginLoaderMap;
|
|
27876
28349
|
exports.random = random;
|