@galacean/effects-threejs 2.0.0-alpha.32 → 2.0.0-alpha.33
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 +62 -82
- package/dist/index.js.map +1 -1
- package/dist/index.min.js +2 -2
- package/dist/index.min.js.map +1 -1
- package/dist/index.mjs +62 -82
- package/dist/index.mjs.map +1 -1
- 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.33
|
|
7
7
|
*/
|
|
8
8
|
|
|
9
9
|
'use strict';
|
|
@@ -16029,6 +16029,17 @@ var Link = /*#__PURE__*/ function() {
|
|
|
16029
16029
|
}while (node = node.pre);
|
|
16030
16030
|
}
|
|
16031
16031
|
};
|
|
16032
|
+
_proto.getNodeByIndex = function getNodeByIndex(index) {
|
|
16033
|
+
var i = 0, res = this.first;
|
|
16034
|
+
if (!res || index >= this.length || index < 0) {
|
|
16035
|
+
return null;
|
|
16036
|
+
}
|
|
16037
|
+
while(i < index){
|
|
16038
|
+
res = res.next;
|
|
16039
|
+
i++;
|
|
16040
|
+
}
|
|
16041
|
+
return res;
|
|
16042
|
+
};
|
|
16032
16043
|
return Link;
|
|
16033
16044
|
}();
|
|
16034
16045
|
|
|
@@ -16865,10 +16876,8 @@ exports.ParticleSystem = /*#__PURE__*/ function(Component) {
|
|
|
16865
16876
|
content[3].delay -= duration;
|
|
16866
16877
|
});
|
|
16867
16878
|
this.renderer.minusTimeForLoop(duration);
|
|
16868
|
-
this.onIterate(this);
|
|
16869
16879
|
} else {
|
|
16870
16880
|
this.ended = true;
|
|
16871
|
-
this.onEnd(this);
|
|
16872
16881
|
var endBehavior = this.item.endBehavior;
|
|
16873
16882
|
if (endBehavior === EndBehavior.freeze) {
|
|
16874
16883
|
this.frozen = true;
|
|
@@ -17016,7 +17025,21 @@ exports.ParticleSystem = /*#__PURE__*/ function(Component) {
|
|
|
17016
17025
|
time: startTime
|
|
17017
17026
|
});
|
|
17018
17027
|
};
|
|
17019
|
-
|
|
17028
|
+
/**
|
|
17029
|
+
* 通过索引获取指定index粒子当前时刻的位置
|
|
17030
|
+
* @params index - 粒子索引
|
|
17031
|
+
*/ _proto.getPointPositionByIndex = function getPointPositionByIndex(index) {
|
|
17032
|
+
var point = this.particleLink.getNodeByIndex(index);
|
|
17033
|
+
if (!point) {
|
|
17034
|
+
console.error("Get point error.");
|
|
17035
|
+
return null;
|
|
17036
|
+
} else {
|
|
17037
|
+
return this.getPointPosition(point.content[3]);
|
|
17038
|
+
}
|
|
17039
|
+
};
|
|
17040
|
+
/**
|
|
17041
|
+
* 通过粒子参数获取当前时刻粒子的位置
|
|
17042
|
+
*/ _proto.getPointPosition = function getPointPosition(point) {
|
|
17020
17043
|
var transform = point.transform, vel = point.vel, lifetime = point.lifetime, delay = point.delay, _point_gravity = point.gravity, gravity = _point_gravity === void 0 ? [] : _point_gravity;
|
|
17021
17044
|
var forceTarget = this.options.forceTarget;
|
|
17022
17045
|
var time = this.lastUpdate - delay;
|
|
@@ -17038,8 +17061,6 @@ exports.ParticleSystem = /*#__PURE__*/ function(Component) {
|
|
|
17038
17061
|
}
|
|
17039
17062
|
return ret;
|
|
17040
17063
|
};
|
|
17041
|
-
_proto.onEnd = function onEnd(particle) {};
|
|
17042
|
-
_proto.onIterate = function onIterate(particle) {};
|
|
17043
17064
|
_proto.initPoint = function initPoint(data) {
|
|
17044
17065
|
var options = this.options;
|
|
17045
17066
|
var lifetime = this.lifetime;
|
|
@@ -17998,31 +18019,6 @@ var ParticleMesh = /*#__PURE__*/ function() {
|
|
|
17998
18019
|
data[i + 3]
|
|
17999
18020
|
];
|
|
18000
18021
|
};
|
|
18001
|
-
/**
|
|
18002
|
-
* 待废弃
|
|
18003
|
-
* @deprecated - 使用 `particle-system.getPointPosition` 替代
|
|
18004
|
-
*/ _proto.getPointPosition = function getPointPosition(index) {
|
|
18005
|
-
var geo = this.geometry;
|
|
18006
|
-
var posIndex = index * 48;
|
|
18007
|
-
var posData = geo.getAttributeData("aPos");
|
|
18008
|
-
var offsetData = geo.getAttributeData("aOffset");
|
|
18009
|
-
var time = this.time - offsetData[index * 16 + 2];
|
|
18010
|
-
var pointDur = offsetData[index * 16 + 3];
|
|
18011
|
-
var mtl = this.mesh.material;
|
|
18012
|
-
var acc = mtl.getVector4("uAcceleration").toVector3();
|
|
18013
|
-
var pos = Vector3.fromArray(posData, posIndex);
|
|
18014
|
-
var vel = Vector3.fromArray(posData, posIndex + 3);
|
|
18015
|
-
var ret = calculateTranslation(new Vector3(), this, acc, time, pointDur, pos, vel);
|
|
18016
|
-
if (this.forceTarget) {
|
|
18017
|
-
var target = mtl.getVector3("uFinalTarget");
|
|
18018
|
-
var life = this.forceTarget.curve.getValue(time / pointDur);
|
|
18019
|
-
var dl = 1 - life;
|
|
18020
|
-
ret.x = ret.x * dl + target.x * life;
|
|
18021
|
-
ret.y = ret.y * dl + target.y * life;
|
|
18022
|
-
ret.z = ret.z * dl + target.z * life;
|
|
18023
|
-
}
|
|
18024
|
-
return ret;
|
|
18025
|
-
};
|
|
18026
18022
|
_proto.clearPoints = function clearPoints() {
|
|
18027
18023
|
this.resetGeometryData(this.geometry);
|
|
18028
18024
|
this.particleCount = 0;
|
|
@@ -19377,9 +19373,6 @@ function compareTracks(a, b) {
|
|
|
19377
19373
|
_this.startTime = 0;
|
|
19378
19374
|
_this.items = [] // 场景的所有元素
|
|
19379
19375
|
;
|
|
19380
|
-
/**
|
|
19381
|
-
* 合成是否冻结标志位
|
|
19382
|
-
*/ _this.fezzed = false;
|
|
19383
19376
|
_this.reusable = false;
|
|
19384
19377
|
_this.sceneBindings = [];
|
|
19385
19378
|
_this.graph = new PlayableGraph();
|
|
@@ -25047,28 +25040,6 @@ var listOrder = 0;
|
|
|
25047
25040
|
}
|
|
25048
25041
|
};
|
|
25049
25042
|
/**
|
|
25050
|
-
* 是否合成需要重新播放
|
|
25051
|
-
* @returns 重新播放合成标志位
|
|
25052
|
-
*/ _proto.shouldRestart = function shouldRestart() {
|
|
25053
|
-
var _this_rootItem = this.rootItem, duration = _this_rootItem.duration, endBehavior = _this_rootItem.endBehavior;
|
|
25054
|
-
var time = this.rootComposition.time;
|
|
25055
|
-
return endBehavior === EndBehavior.restart && duration - time < 0.02;
|
|
25056
|
-
};
|
|
25057
|
-
/**
|
|
25058
|
-
* 是否合成需要销毁
|
|
25059
|
-
* @returns 销毁合成标志位
|
|
25060
|
-
*/ _proto.shouldDispose = function shouldDispose() {
|
|
25061
|
-
if (this.reusable) {
|
|
25062
|
-
return false;
|
|
25063
|
-
}
|
|
25064
|
-
var endBehavior = this.rootItem.endBehavior;
|
|
25065
|
-
if (this.rootItem.isEnded(this.time)) {
|
|
25066
|
-
this.rootItem.ended = true;
|
|
25067
|
-
}
|
|
25068
|
-
// TODO: 合成结束行为
|
|
25069
|
-
return this.rootItem.ended && endBehavior === EndBehavior.destroy;
|
|
25070
|
-
};
|
|
25071
|
-
/**
|
|
25072
25043
|
* 合成更新,针对所有 item 的更新
|
|
25073
25044
|
* @param deltaTime - 更新的时间步长
|
|
25074
25045
|
* @param skipRender - 是否需要渲染
|
|
@@ -25079,49 +25050,56 @@ var listOrder = 0;
|
|
|
25079
25050
|
var time = this.getUpdateTime(deltaTime * this.speed);
|
|
25080
25051
|
this.globalTime += time;
|
|
25081
25052
|
this.updateRootComposition();
|
|
25082
|
-
if (this.shouldRestart()) {
|
|
25083
|
-
this.emit("end", {
|
|
25084
|
-
composition: this
|
|
25085
|
-
});
|
|
25086
|
-
this.restart();
|
|
25087
|
-
// restart then tick to avoid flicker
|
|
25088
|
-
}
|
|
25089
25053
|
this.updateVideo();
|
|
25090
25054
|
// 更新 model-tree-plugin
|
|
25091
25055
|
this.updatePluginLoaders(deltaTime);
|
|
25056
|
+
// scene VFXItem components lifetime function.
|
|
25092
25057
|
this.callStart(this.rootItem);
|
|
25093
25058
|
this.callUpdate(this.rootItem, time);
|
|
25094
25059
|
this.callLateUpdate(this.rootItem, time);
|
|
25095
25060
|
this.updateCamera();
|
|
25061
|
+
this.prepareRender();
|
|
25096
25062
|
if (this.shouldDispose()) {
|
|
25097
|
-
this.emit("end", {
|
|
25098
|
-
composition: this
|
|
25099
|
-
});
|
|
25100
25063
|
this.dispose();
|
|
25101
|
-
} else {
|
|
25102
|
-
this.prepareRender();
|
|
25103
25064
|
}
|
|
25104
25065
|
};
|
|
25105
25066
|
_proto.toLocalTime = function toLocalTime(time) {
|
|
25106
25067
|
var localTime = time - this.rootItem.start;
|
|
25107
25068
|
var duration = this.rootItem.duration;
|
|
25108
25069
|
if (localTime - duration > 0.001) {
|
|
25109
|
-
if (this.rootItem.
|
|
25110
|
-
|
|
25111
|
-
|
|
25112
|
-
|
|
25113
|
-
|
|
25114
|
-
|
|
25115
|
-
|
|
25116
|
-
|
|
25117
|
-
|
|
25118
|
-
|
|
25070
|
+
if (!this.rootItem.ended) {
|
|
25071
|
+
this.rootItem.ended = true;
|
|
25072
|
+
this.emit("end", {
|
|
25073
|
+
composition: this
|
|
25074
|
+
});
|
|
25075
|
+
}
|
|
25076
|
+
switch(this.rootItem.endBehavior){
|
|
25077
|
+
case EndBehavior.restart:
|
|
25078
|
+
{
|
|
25079
|
+
localTime = localTime % duration;
|
|
25080
|
+
this.restart();
|
|
25081
|
+
break;
|
|
25082
|
+
}
|
|
25083
|
+
case EndBehavior.freeze:
|
|
25084
|
+
{
|
|
25085
|
+
localTime = Math.min(duration, localTime);
|
|
25086
|
+
break;
|
|
25087
|
+
}
|
|
25088
|
+
case EndBehavior.forward:
|
|
25089
|
+
{
|
|
25090
|
+
break;
|
|
25091
|
+
}
|
|
25092
|
+
case EndBehavior.destroy:
|
|
25093
|
+
{
|
|
25094
|
+
break;
|
|
25119
25095
|
}
|
|
25120
|
-
}
|
|
25121
25096
|
}
|
|
25122
25097
|
}
|
|
25123
25098
|
return localTime;
|
|
25124
25099
|
};
|
|
25100
|
+
_proto.shouldDispose = function shouldDispose() {
|
|
25101
|
+
return this.rootItem.ended && this.rootItem.endBehavior === EndBehavior.destroy && !this.reusable;
|
|
25102
|
+
};
|
|
25125
25103
|
_proto.getUpdateTime = function getUpdateTime(t) {
|
|
25126
25104
|
var startTimeInMs = this.startTime * 1000;
|
|
25127
25105
|
var now = this.rootComposition.time * 1000;
|
|
@@ -25452,7 +25430,9 @@ var listOrder = 0;
|
|
|
25452
25430
|
(_this_rendererOptions = this.rendererOptions) == null ? void 0 : _this_rendererOptions.emptyTexture.dispose();
|
|
25453
25431
|
(_this_pluginSystem = this.pluginSystem) == null ? void 0 : _this_pluginSystem.destroyComposition(this);
|
|
25454
25432
|
this.update = function() {
|
|
25455
|
-
|
|
25433
|
+
{
|
|
25434
|
+
logger.error("Update disposed composition: " + _this.name + ".");
|
|
25435
|
+
}
|
|
25456
25436
|
};
|
|
25457
25437
|
this.dispose = noop;
|
|
25458
25438
|
if (textures && this.keepResource) {
|
|
@@ -27615,7 +27595,7 @@ registerPlugin("sprite", SpriteLoader, exports.VFXItem, true);
|
|
|
27615
27595
|
registerPlugin("particle", ParticleLoader, exports.VFXItem, true);
|
|
27616
27596
|
registerPlugin("cal", CalculateLoader, exports.VFXItem, true);
|
|
27617
27597
|
registerPlugin("interact", InteractLoader, exports.VFXItem, true);
|
|
27618
|
-
var version$1 = "2.0.0-alpha.
|
|
27598
|
+
var version$1 = "2.0.0-alpha.33";
|
|
27619
27599
|
logger.info("Core version: " + version$1 + ".");
|
|
27620
27600
|
|
|
27621
27601
|
var _obj;
|
|
@@ -29282,7 +29262,7 @@ setMaxSpriteMeshItemCount(8);
|
|
|
29282
29262
|
*/ Mesh.create = function(engine, props) {
|
|
29283
29263
|
return new ThreeMesh(engine, props);
|
|
29284
29264
|
};
|
|
29285
|
-
var version = "2.0.0-alpha.
|
|
29265
|
+
var version = "2.0.0-alpha.33";
|
|
29286
29266
|
logger.info("THREEJS plugin version: " + version + ".");
|
|
29287
29267
|
|
|
29288
29268
|
exports.AbstractPlugin = AbstractPlugin;
|