@galacean/effects-threejs 1.1.1 → 1.1.3
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 +49 -40
- package/dist/index.js.map +1 -1
- package/dist/index.min.js +4 -4
- package/dist/index.min.js.map +1 -1
- package/dist/index.mjs +49 -40
- package/dist/index.mjs.map +1 -1
- package/package.json +2 -2
package/dist/index.mjs
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: v1.1.
|
|
6
|
+
* Version: v1.1.3
|
|
7
7
|
*/
|
|
8
8
|
|
|
9
9
|
import * as THREE from 'three';
|
|
@@ -9325,11 +9325,9 @@ var Matrix4 = /** @class */ (function () {
|
|
|
9325
9325
|
var vX = Matrix4.tempVec0;
|
|
9326
9326
|
var vY = Matrix4.tempVec1;
|
|
9327
9327
|
var vZ = Matrix4.tempVec2;
|
|
9328
|
-
vZ.subtractVectors(
|
|
9328
|
+
vZ.subtractVectors(eye, target);
|
|
9329
9329
|
vZ.normalize();
|
|
9330
|
-
|
|
9331
|
-
vY.normalize();
|
|
9332
|
-
vX.crossVectors(vY, vZ);
|
|
9330
|
+
vX.crossVectors(up, vZ);
|
|
9333
9331
|
vX.normalize();
|
|
9334
9332
|
vY.crossVectors(vZ, vX);
|
|
9335
9333
|
var te = this.elements;
|
|
@@ -16018,7 +16016,7 @@ function loadImage(source) {
|
|
|
16018
16016
|
}
|
|
16019
16017
|
// 2. 非法类型
|
|
16020
16018
|
if (!url) {
|
|
16021
|
-
throw new Error("Invalid url type: ".concat(source));
|
|
16019
|
+
throw new Error("Invalid url type: ".concat(JSON.stringify(source)));
|
|
16022
16020
|
}
|
|
16023
16021
|
return [2 /*return*/, new Promise(function (resolve, reject) {
|
|
16024
16022
|
var img = new Image();
|
|
@@ -16037,7 +16035,7 @@ function loadImage(source) {
|
|
|
16037
16035
|
if (revokeURL) {
|
|
16038
16036
|
URL.revokeObjectURL(url);
|
|
16039
16037
|
}
|
|
16040
|
-
return reject("Load image fail: ".concat(e));
|
|
16038
|
+
return reject("Load image fail: ".concat(JSON.stringify(e)));
|
|
16041
16039
|
};
|
|
16042
16040
|
img.src = url;
|
|
16043
16041
|
})];
|
|
@@ -19368,18 +19366,19 @@ var SpriteMesh = /** @class */ (function () {
|
|
|
19368
19366
|
var uSizeStart = start + 4;
|
|
19369
19367
|
var uQuatStart = start + 8;
|
|
19370
19368
|
var uColorStart = start + 12;
|
|
19371
|
-
if (!selfData.visible && !init) {
|
|
19372
|
-
mainDataArray[uSizeStart + 2] = -1;
|
|
19373
|
-
return;
|
|
19374
|
-
}
|
|
19375
|
-
var uColor = selfData.color || [mainDataArray[uColorStart], mainDataArray[uColorStart + 1], mainDataArray[uColorStart + 2], mainDataArray[uColorStart + 3]];
|
|
19376
|
-
// if (selfData.startSize) {
|
|
19377
|
-
// selfData.transform.scaleBy(1 / selfData.startSize[0], 1 / selfData.startSize[1], 1);
|
|
19378
|
-
// }
|
|
19379
19369
|
var tempPos = new Vector3();
|
|
19380
19370
|
var tempQuat = new Quaternion();
|
|
19381
19371
|
var tempScale = new Vector3();
|
|
19382
|
-
selfData.
|
|
19372
|
+
var uColor = selfData.color || [mainDataArray[uColorStart], mainDataArray[uColorStart + 1], mainDataArray[uColorStart + 2], mainDataArray[uColorStart + 3]];
|
|
19373
|
+
if (selfData.visible) {
|
|
19374
|
+
selfData.transform.assignWorldTRS(tempPos, tempQuat, tempScale);
|
|
19375
|
+
}
|
|
19376
|
+
else {
|
|
19377
|
+
if (!init) {
|
|
19378
|
+
mainDataArray[uSizeStart + 2] = -1;
|
|
19379
|
+
return;
|
|
19380
|
+
}
|
|
19381
|
+
}
|
|
19383
19382
|
var uPos = __spreadArray$2(__spreadArray$2([], __read$3(tempPos.toArray()), false), [0], false);
|
|
19384
19383
|
var uSize = __spreadArray$2(__spreadArray$2([], __read$3(tempScale.toArray()), false), [0], false);
|
|
19385
19384
|
var uQuat = tempQuat.toArray();
|
|
@@ -29170,6 +29169,7 @@ var CompositionSourceManager = /** @class */ (function () {
|
|
|
29170
29169
|
var e_1, _a;
|
|
29171
29170
|
this.refCompositions = new Map();
|
|
29172
29171
|
this.refCompositionProps = new Map();
|
|
29172
|
+
this.mask = 0;
|
|
29173
29173
|
// 资源
|
|
29174
29174
|
var jsonScene = scene.jsonScene, renderLevel = scene.renderLevel, textureOptions = scene.textureOptions, pluginSystem = scene.pluginSystem, totalTime = scene.totalTime;
|
|
29175
29175
|
var compositions = jsonScene.compositions, imgUsage = jsonScene.imgUsage, compositionId = jsonScene.compositionId;
|
|
@@ -29208,7 +29208,6 @@ var CompositionSourceManager = /** @class */ (function () {
|
|
|
29208
29208
|
this.totalTime = totalTime !== null && totalTime !== void 0 ? totalTime : 0;
|
|
29209
29209
|
this.imgUsage = imgUsage !== null && imgUsage !== void 0 ? imgUsage : {};
|
|
29210
29210
|
this.textures = cachedTextures;
|
|
29211
|
-
this.mask = 0;
|
|
29212
29211
|
listOrder = 0;
|
|
29213
29212
|
this.textureOptions = textureOptions;
|
|
29214
29213
|
this.sourceContent = this.getContent(this.composition);
|
|
@@ -29233,10 +29232,6 @@ var CompositionSourceManager = /** @class */ (function () {
|
|
|
29233
29232
|
CompositionSourceManager.prototype.assembleItems = function (composition) {
|
|
29234
29233
|
var _this = this;
|
|
29235
29234
|
var items = [];
|
|
29236
|
-
var mask = this.mask;
|
|
29237
|
-
if (isNaN(mask)) {
|
|
29238
|
-
mask = 0;
|
|
29239
|
-
}
|
|
29240
29235
|
composition.items.forEach(function (item) {
|
|
29241
29236
|
var _a;
|
|
29242
29237
|
var option = {};
|
|
@@ -29252,15 +29247,7 @@ var CompositionSourceManager = /** @class */ (function () {
|
|
|
29252
29247
|
option.type = type;
|
|
29253
29248
|
if (renderContent.renderer) {
|
|
29254
29249
|
renderContent.renderer = _this.changeTex(renderContent.renderer);
|
|
29255
|
-
|
|
29256
|
-
var maskMode = renderContent.renderer.maskMode;
|
|
29257
|
-
if (maskMode === MaskMode$1.MASK) {
|
|
29258
|
-
renderContent.renderer.mask = ++mask;
|
|
29259
|
-
}
|
|
29260
|
-
else if (maskMode === MaskMode$1.OBSCURED || maskMode === MaskMode$1.REVERSE_OBSCURED) {
|
|
29261
|
-
renderContent.renderer.mask = mask;
|
|
29262
|
-
}
|
|
29263
|
-
}
|
|
29250
|
+
_this.processMask(renderContent.renderer);
|
|
29264
29251
|
var split = renderContent.splits && !renderContent.textureSheetAnimation && renderContent.splits[0];
|
|
29265
29252
|
if (Number.isInteger(renderContent.renderer.shape)) {
|
|
29266
29253
|
// TODO: scene.shapes 类型问题?
|
|
@@ -29305,16 +29292,18 @@ var CompositionSourceManager = /** @class */ (function () {
|
|
|
29305
29292
|
}
|
|
29306
29293
|
// 处理预合成的渲染顺序
|
|
29307
29294
|
if (option.type === ItemType$1.composition) {
|
|
29295
|
+
++_this.mask;
|
|
29308
29296
|
var refId = item.content.options.refId;
|
|
29309
29297
|
if (!_this.refCompositions.get(refId)) {
|
|
29310
29298
|
throw new Error('Invalid Ref Composition id: ' + refId);
|
|
29311
29299
|
}
|
|
29300
|
+
var ref = _this.getContent(_this.refCompositions.get(refId));
|
|
29312
29301
|
if (!_this.refCompositionProps.has(refId)) {
|
|
29313
|
-
_this.refCompositionProps.set(refId,
|
|
29302
|
+
_this.refCompositionProps.set(refId, ref);
|
|
29314
29303
|
}
|
|
29315
|
-
var ref = _this.refCompositionProps.get(refId);
|
|
29316
29304
|
ref.items.forEach(function (item) {
|
|
29317
29305
|
item.listIndex = listOrder++;
|
|
29306
|
+
_this.processMask(item.content);
|
|
29318
29307
|
});
|
|
29319
29308
|
option.items = ref.items;
|
|
29320
29309
|
}
|
|
@@ -29350,6 +29339,23 @@ var CompositionSourceManager = /** @class */ (function () {
|
|
|
29350
29339
|
}
|
|
29351
29340
|
}
|
|
29352
29341
|
};
|
|
29342
|
+
/**
|
|
29343
|
+
* 处理蒙版和遮挡关系写入 stencil 的 ref 值
|
|
29344
|
+
*/
|
|
29345
|
+
CompositionSourceManager.prototype.processMask = function (renderer) {
|
|
29346
|
+
if (renderer.maskMode === MaskMode$1.NONE) {
|
|
29347
|
+
return;
|
|
29348
|
+
}
|
|
29349
|
+
if (!renderer.mask) {
|
|
29350
|
+
var maskMode = renderer.maskMode;
|
|
29351
|
+
if (maskMode === MaskMode$1.MASK) {
|
|
29352
|
+
renderer.mask = ++this.mask;
|
|
29353
|
+
}
|
|
29354
|
+
else if (maskMode === MaskMode$1.OBSCURED || maskMode === MaskMode$1.REVERSE_OBSCURED) {
|
|
29355
|
+
renderer.mask = this.mask;
|
|
29356
|
+
}
|
|
29357
|
+
}
|
|
29358
|
+
};
|
|
29353
29359
|
CompositionSourceManager.prototype.dispose = function () {
|
|
29354
29360
|
this.textureOptions = [];
|
|
29355
29361
|
this.textures = [];
|
|
@@ -29424,7 +29430,7 @@ var AssetManager = /** @class */ (function () {
|
|
|
29424
29430
|
waitPromise = new Promise(function (resolve, reject) {
|
|
29425
29431
|
return loadTimer = window.setTimeout(function () {
|
|
29426
29432
|
cancelLoading = true;
|
|
29427
|
-
reject("Load time out: ".concat(url));
|
|
29433
|
+
reject("Load time out: ".concat(JSON.stringify(url)));
|
|
29428
29434
|
}, _this.timeout * 1000);
|
|
29429
29435
|
});
|
|
29430
29436
|
hookTimeInfo = function (label, func) { return __awaiter(_this, void 0, void 0, function () {
|
|
@@ -29589,7 +29595,7 @@ var AssetManager = /** @class */ (function () {
|
|
|
29589
29595
|
if (passRenderLevel(bin.renderLevel, renderLevel)) {
|
|
29590
29596
|
return _this.loadBins(bin.url);
|
|
29591
29597
|
}
|
|
29592
|
-
throw new Error("Invalid bins source: ".concat(bins));
|
|
29598
|
+
throw new Error("Invalid bins source: ".concat(JSON.stringify(bins)));
|
|
29593
29599
|
});
|
|
29594
29600
|
return [2 /*return*/, Promise.all(jobs)];
|
|
29595
29601
|
});
|
|
@@ -29625,7 +29631,7 @@ var AssetManager = /** @class */ (function () {
|
|
|
29625
29631
|
case 3:
|
|
29626
29632
|
_b.sent();
|
|
29627
29633
|
console.warn({
|
|
29628
|
-
content: "Invalid fonts source: ".concat(font.fontURL),
|
|
29634
|
+
content: "Invalid fonts source: ".concat(JSON.stringify(font.fontURL)),
|
|
29629
29635
|
type: LOG_TYPE,
|
|
29630
29636
|
});
|
|
29631
29637
|
return [3 /*break*/, 4];
|
|
@@ -29794,7 +29800,7 @@ var AssetManager = /** @class */ (function () {
|
|
|
29794
29800
|
return __generator(this, function (_a) {
|
|
29795
29801
|
return [2 /*return*/, new Promise(function (resolve, reject) {
|
|
29796
29802
|
_this.downloader.downloadJSON(url, resolve, function (status, responseText) {
|
|
29797
|
-
reject("Couldn't load JSON ".concat(url, ": status ").concat(status, ", ").concat(responseText));
|
|
29803
|
+
reject("Couldn't load JSON ".concat(JSON.stringify(url), ": status ").concat(status, ", ").concat(responseText));
|
|
29798
29804
|
});
|
|
29799
29805
|
})];
|
|
29800
29806
|
});
|
|
@@ -29806,7 +29812,7 @@ var AssetManager = /** @class */ (function () {
|
|
|
29806
29812
|
return __generator(this, function (_a) {
|
|
29807
29813
|
return [2 /*return*/, new Promise(function (resolve, reject) {
|
|
29808
29814
|
_this.downloader.downloadBinary(url, resolve, function (status, responseText) {
|
|
29809
|
-
reject("Couldn't load bins ".concat(url, ": status ").concat(status, ", ").concat(responseText));
|
|
29815
|
+
reject("Couldn't load bins ".concat(JSON.stringify(url), ": status ").concat(status, ", ").concat(responseText));
|
|
29810
29816
|
});
|
|
29811
29817
|
})];
|
|
29812
29818
|
});
|
|
@@ -31152,7 +31158,10 @@ var Ticker = /** @class */ (function () {
|
|
|
31152
31158
|
};
|
|
31153
31159
|
Ticker.prototype.setFPS = function (fps) {
|
|
31154
31160
|
this.targetFPS = clamp$1(fps, 1, 120);
|
|
31155
|
-
|
|
31161
|
+
// 注意:-2 的原因是保证帧率稳定
|
|
31162
|
+
// interval 在 fps 为 60 的时候设成 15 累计误差会很大,设成 14 较稳定
|
|
31163
|
+
// requestanimationFrame 在不同的刷新率下时间间隔不一样,120hz 的误差在 8 以内,60hz 的误差在 16 以内
|
|
31164
|
+
this.interval = Math.floor(1000 / fps) - 2;
|
|
31156
31165
|
};
|
|
31157
31166
|
/**
|
|
31158
31167
|
* 获取定时器暂停标志位
|
|
@@ -32752,9 +32761,9 @@ Geometry.create = function (engine, options) {
|
|
|
32752
32761
|
Mesh.create = function (engine, props) {
|
|
32753
32762
|
return new ThreeMesh(engine, props);
|
|
32754
32763
|
};
|
|
32755
|
-
var version = "1.1.
|
|
32764
|
+
var version = "1.1.3";
|
|
32756
32765
|
console.info({
|
|
32757
|
-
content: '[Galacean Effects THREEJS] version: ' + "1.1.
|
|
32766
|
+
content: '[Galacean Effects THREEJS] version: ' + "1.1.3",
|
|
32758
32767
|
type: LOG_TYPE,
|
|
32759
32768
|
});
|
|
32760
32769
|
|