@galacean/effects-threejs 2.1.0-alpha.2 → 2.1.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 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.1.0-alpha.2
6
+ * Version: v2.1.0-alpha.4
7
7
  */
8
8
 
9
9
  'use strict';
@@ -4277,6 +4277,9 @@ var MaterialBlending;
4277
4277
  /**
4278
4278
  * 自发光
4279
4279
  */ RenderMode3D["emissive"] = "emissive";
4280
+ /**
4281
+ * 漫反射
4282
+ */ RenderMode3D["diffuse"] = "diffuse";
4280
4283
  })(RenderMode3D || (RenderMode3D = {}));
4281
4284
 
4282
4285
  var TextOverflow;
@@ -10329,10 +10332,11 @@ var BezierCurve = /*#__PURE__*/ function(ValueGetter) {
10329
10332
  timeEnd: Number(e.x)
10330
10333
  };
10331
10334
  }
10335
+ this.keyTimeData = Object.keys(this.curveMap);
10332
10336
  };
10333
10337
  _proto.getValue = function getValue(time) {
10334
10338
  var result = 0;
10335
- var keyTimeData = Object.keys(this.curveMap);
10339
+ var keyTimeData = this.keyTimeData;
10336
10340
  var keyTimeStart = this.curveMap[keyTimeData[0]].timeStart;
10337
10341
  var keyTimeEnd = this.curveMap[keyTimeData[keyTimeData.length - 1]].timeEnd;
10338
10342
  // const keyTimeStart = Number(keyTimeData[0].split('&')[0]);
@@ -13627,25 +13631,25 @@ function _assert_this_initialized(self) {
13627
13631
  }
13628
13632
  var _proto = PlayableGraph.prototype;
13629
13633
  _proto.evaluate = function evaluate(dt) {
13630
- // 初始化节点状态
13631
- for(var _iterator = _create_for_of_iterator_helper_loose(this.playables), _step; !(_step = _iterator()).done;){
13632
- var playable = _step.value;
13633
- this.updatePlayableTime(playable, dt);
13634
- }
13635
13634
  // 初始化输出节点状态
13636
- for(var _iterator1 = _create_for_of_iterator_helper_loose(this.playableOutputs), _step1; !(_step1 = _iterator1()).done;){
13637
- var playableOutput = _step1.value;
13635
+ for(var _iterator = _create_for_of_iterator_helper_loose(this.playableOutputs), _step; !(_step = _iterator()).done;){
13636
+ var playableOutput = _step.value;
13638
13637
  playableOutput.context.deltaTime = dt;
13639
13638
  }
13640
13639
  // 执行生命周期函数
13641
- for(var _iterator2 = _create_for_of_iterator_helper_loose(this.playableOutputs), _step2; !(_step2 = _iterator2()).done;){
13642
- var playableOutput1 = _step2.value;
13640
+ for(var _iterator1 = _create_for_of_iterator_helper_loose(this.playableOutputs), _step1; !(_step1 = _iterator1()).done;){
13641
+ var playableOutput1 = _step1.value;
13643
13642
  this.prepareFrameWithRoot(playableOutput1);
13644
13643
  }
13645
- for(var _iterator3 = _create_for_of_iterator_helper_loose(this.playableOutputs), _step3; !(_step3 = _iterator3()).done;){
13646
- var playableOutput2 = _step3.value;
13644
+ for(var _iterator2 = _create_for_of_iterator_helper_loose(this.playableOutputs), _step2; !(_step2 = _iterator2()).done;){
13645
+ var playableOutput2 = _step2.value;
13647
13646
  this.processFrameWithRoot(playableOutput2);
13648
13647
  }
13648
+ // 更新节点时间
13649
+ for(var _iterator3 = _create_for_of_iterator_helper_loose(this.playables), _step3; !(_step3 = _iterator3()).done;){
13650
+ var playable = _step3.value;
13651
+ this.updatePlayableTime(playable, dt);
13652
+ }
13649
13653
  };
13650
13654
  _proto.connect = function connect(source, sourceOutputPort, destination, destinationInputPort) {
13651
13655
  destination.connectInput(destinationInputPort, source, sourceOutputPort);
@@ -13668,11 +13672,7 @@ function _assert_this_initialized(self) {
13668
13672
  if (playable.getPlayState() !== 0) {
13669
13673
  return;
13670
13674
  }
13671
- if (playable.overrideTimeNextEvaluation) {
13672
- playable.overrideTimeNextEvaluation = false;
13673
- } else {
13674
- playable.setTime(playable.getTime() + deltaTime);
13675
- }
13675
+ playable.setTime(playable.getTime() + deltaTime);
13676
13676
  };
13677
13677
  return PlayableGraph;
13678
13678
  }();
@@ -13684,7 +13684,6 @@ function _assert_this_initialized(self) {
13684
13684
  if (inputCount === void 0) inputCount = 0;
13685
13685
  this.onPlayablePlayFlag = true;
13686
13686
  this.onPlayablePauseFlag = false;
13687
- this.overrideTimeNextEvaluation = false;
13688
13687
  this.destroyed = false;
13689
13688
  this.inputs = [];
13690
13689
  this.inputOuputPorts = [];
@@ -13773,7 +13772,6 @@ function _assert_this_initialized(self) {
13773
13772
  };
13774
13773
  _proto.setTime = function setTime(time) {
13775
13774
  this.time = time;
13776
- this.overrideTimeNextEvaluation = true;
13777
13775
  };
13778
13776
  _proto.getTime = function getTime() {
13779
13777
  return this.time;
@@ -16576,8 +16574,9 @@ function getTrailMeshShader(trails, particleMaxCount, name, gpuCapability, env)
16576
16574
  };
16577
16575
  _proto.onUpdate = function onUpdate(dt) {
16578
16576
  var time = this.particleMesh.time;
16579
- this.particleMesh.mesh.material.setVector4("uParams", new Vector4(time, this.item.duration, 0, 0));
16580
- this.particleMesh.onUpdate(dt);
16577
+ var _this_particleMesh_mesh_material_getVector4;
16578
+ var uParams = (_this_particleMesh_mesh_material_getVector4 = this.particleMesh.mesh.material.getVector4("uParams")) != null ? _this_particleMesh_mesh_material_getVector4 : new Vector4();
16579
+ this.particleMesh.mesh.material.setVector4("uParams", uParams.set(time, this.item.duration, 0, 0));
16581
16580
  };
16582
16581
  _proto.render = function render(renderer) {
16583
16582
  for(var _iterator = _create_for_of_iterator_helper_loose(this.meshes), _step; !(_step = _iterator()).done;){
@@ -16592,7 +16591,7 @@ function getTrailMeshShader(trails, particleMaxCount, name, gpuCapability, env)
16592
16591
  };
16593
16592
  _proto.updateTime = function updateTime(now, delta) {
16594
16593
  this.particleMesh.time = now;
16595
- // this.particleMesh.onUpdate(delta);
16594
+ this.particleMesh.onUpdate(delta);
16596
16595
  if (this.trailMesh) {
16597
16596
  this.trailMesh.time = now;
16598
16597
  this.trailMesh.onUpdate(delta);
@@ -16886,7 +16885,7 @@ exports.ParticleSystem = /*#__PURE__*/ function(Component) {
16886
16885
  break;
16887
16886
  }
16888
16887
  var burst = bursts[j];
16889
- var opts = burst.getGeneratorOptions(timePassed, lifetime);
16888
+ var opts = !burst.disabled && burst.getGeneratorOptions(timePassed, lifetime);
16890
16889
  if (opts) {
16891
16890
  var originVec = [
16892
16891
  0,
@@ -16895,6 +16894,9 @@ exports.ParticleSystem = /*#__PURE__*/ function(Component) {
16895
16894
  ];
16896
16895
  var offsets = emission.burstOffsets[j];
16897
16896
  var burstOffset = offsets && offsets[opts.cycleIndex] || originVec;
16897
+ if (burst.once) {
16898
+ this.removeBurst(j);
16899
+ }
16898
16900
  for(var i1 = 0; i1 < opts.count && cursor < maxCount; i1++){
16899
16901
  var _p_transform;
16900
16902
  if (shouldSkipGenerate()) {
@@ -17699,12 +17701,10 @@ var particleUniformTypeMap = {
17699
17701
  var ParticleMesh = /*#__PURE__*/ function() {
17700
17702
  function ParticleMesh(engine, props) {
17701
17703
  this.particleCount = 0;
17702
- this.cachedVelocity = new Vector3();
17703
17704
  this.cachedRotationVector3 = new Vector3();
17704
17705
  this.cachedRotationMatrix = new Matrix3();
17705
17706
  this.cachedLinearMove = new Vector3();
17706
17707
  this.tempMatrix3 = new Matrix3();
17707
- this.tempVector3 = new Vector3();
17708
17708
  this.VERT_MAX_KEY_FRAME_COUNT = 0;
17709
17709
  var _engine_renderer;
17710
17710
  var env = ((_engine_renderer = engine.renderer) != null ? _engine_renderer : {}).env;
@@ -18100,72 +18100,10 @@ var ParticleMesh = /*#__PURE__*/ function() {
18100
18100
  };
18101
18101
  _proto.onUpdate = function onUpdate(dt) {
18102
18102
  var aPosArray = this.geometry.getAttributeData("aPos"); // vector3
18103
- var aVelArray = this.geometry.getAttributeData("aVel"); // vector3
18104
- var aOffsetArray = this.geometry.getAttributeData("aOffset");
18105
- var aRotArray = this.geometry.getAttributeData("aRot"); // vector3
18106
- var aSeedArray = this.geometry.getAttributeData("aSeed"); // float
18107
- // const uParams = this.mesh.material.getVector4('uParams');
18108
- // if (!uParams) {
18109
- // return;
18110
- // }
18111
- var localTime = this.time;
18112
- var particleCount = Math.ceil(aPosArray.length / 12);
18113
- // calculate particle translation
18114
- var aTranslationArray = this.geometry.getAttributeData("aTranslation");
18115
- if (aTranslationArray.length < particleCount * 3) {
18116
- aTranslationArray = this.expandArray(aTranslationArray, particleCount * 3);
18117
- }
18118
- var velocity = this.cachedVelocity;
18119
- for(var i = 0; i < particleCount; i++){
18120
- var velOffset = i * 12 + 3;
18121
- velocity.set(aVelArray[velOffset], aVelArray[velOffset + 1], aVelArray[velOffset + 2]);
18122
- this.calculateTranslation(velocity, aOffsetArray[i * 4 + 2], localTime, aOffsetArray[i * 4 + 3]);
18123
- var aTranslationOffset = i * 3;
18124
- if (aOffsetArray[i * 4 + 2] < localTime) {
18125
- var translation = velocity.multiply(dt / 1000);
18126
- aTranslationArray[aTranslationOffset] += translation.x;
18127
- aTranslationArray[aTranslationOffset + 1] += translation.y;
18128
- aTranslationArray[aTranslationOffset + 2] += translation.z;
18129
- }
18130
- }
18131
- this.geometry.setAttributeData("aTranslation", aTranslationArray);
18132
- // calculate particle rotation
18133
- var aRotationArray = this.geometry.getAttributeData("aRotation0");
18134
- if (aRotationArray.length < particleCount * 9) {
18135
- aRotationArray = this.expandArray(aRotationArray, particleCount * 9);
18136
- }
18137
- for(var i1 = 0; i1 < particleCount; i1++){
18138
- var time = localTime - aOffsetArray[i1 * 4 + 2];
18139
- var duration = aOffsetArray[i1 * 4 + 3];
18140
- var life = clamp$1(time / duration, 0.0, 1.0);
18141
- var aRotOffset = i1 * 8;
18142
- var aRot = this.cachedRotationVector3.set(aRotArray[aRotOffset], aRotArray[aRotOffset + 1], aRotArray[aRotOffset + 2]);
18143
- var aSeed = aSeedArray[i1 * 8 + 3];
18144
- var aRotation = this.transformFromRotation(aRot, life, duration, aSeed, this.cachedRotationMatrix);
18145
- var aRotationOffset = i1 * 9;
18146
- var matrixArray = aRotation.toArray();
18147
- aRotationArray.set(matrixArray, aRotationOffset);
18148
- }
18149
- this.geometry.setAttributeData("aRotation0", aRotationArray);
18150
- // calculate linear movement
18151
- var aLinearMoveArray = this.geometry.getAttributeData("aLinearMove");
18152
- if (aLinearMoveArray.length < particleCount * 3) {
18153
- aLinearMoveArray = this.expandArray(aLinearMoveArray, particleCount * 3);
18154
- }
18155
- var linearMove = this.cachedLinearMove;
18156
- for(var i2 = 0; i2 < particleCount; i2++){
18157
- var time1 = localTime - aOffsetArray[i2 * 4 + 2];
18158
- var duration1 = aOffsetArray[i2 * 4 + 3];
18159
- // const life = math.clamp(time / duration, 0.0, 1.0);
18160
- var aSeed1 = aSeedArray[i2 * 8 + 3];
18161
- linearMove.setZero();
18162
- this.calLinearMov(time1, duration1, aSeed1, linearMove);
18163
- var aLinearMoveOffset = i2 * 3;
18164
- aLinearMoveArray[aLinearMoveOffset] = linearMove.x;
18165
- aLinearMoveArray[aLinearMoveOffset + 1] = linearMove.y;
18166
- aLinearMoveArray[aLinearMoveOffset + 2] = linearMove.z;
18167
- }
18168
- this.geometry.setAttributeData("aLinearMove", aLinearMoveArray);
18103
+ var vertexCount = Math.ceil(aPosArray.length / 12);
18104
+ this.applyTranslation(vertexCount, dt);
18105
+ this.applyRotation(vertexCount, dt);
18106
+ this.applyLinearMove(vertexCount, dt);
18169
18107
  };
18170
18108
  _proto.minusTime = function minusTime(time) {
18171
18109
  var aOffset = this.geometry.getAttributeData("aOffset");
@@ -18175,153 +18113,6 @@ var ParticleMesh = /*#__PURE__*/ function() {
18175
18113
  this.geometry.setAttributeData("aOffset", aOffset);
18176
18114
  this.time -= time;
18177
18115
  };
18178
- _proto.calculateTranslation = function calculateTranslation(velocity, t0, t1, duration) {
18179
- var uAcceleration = this.mesh.material.getVector4("uAcceleration");
18180
- var uGravityModifierValue = this.mesh.material.getVector4("uGravityModifierValue");
18181
- if (!uAcceleration || !uGravityModifierValue) {
18182
- return velocity;
18183
- }
18184
- var dt = t1 - t0; // 相对delay的时间
18185
- var d = this.gravityModifier.getIntegrateValue(0, dt, duration);
18186
- var acc = this.tempVector3.set(uAcceleration.x * d, uAcceleration.y * d, uAcceleration.z * d);
18187
- // speedIntegrate = speedOverLifetime.getIntegrateValue(0, time, duration);
18188
- if (this.speedOverLifetime) {
18189
- // dt / dur 归一化
18190
- var speed = this.speedOverLifetime.getValue(dt / duration);
18191
- return velocity.multiply(speed).add(acc);
18192
- }
18193
- return velocity.add(acc);
18194
- };
18195
- _proto.transformFromRotation = function transformFromRotation(rot, life, dur, aSeed, result) {
18196
- var rotation = rot;
18197
- if (!this.rotationOverLifetime) {
18198
- return result.setZero();
18199
- }
18200
- if (this.rotationOverLifetime.asRotation) {
18201
- // Adjust rotation based on the specified lifetime components
18202
- if (this.rotationOverLifetime.x) {
18203
- if (_instanceof1(this.rotationOverLifetime.x, RandomValue)) {
18204
- rotation.x += this.rotationOverLifetime.x.getValue(life, aSeed);
18205
- } else {
18206
- rotation.x += this.rotationOverLifetime.x.getValue(life);
18207
- }
18208
- }
18209
- if (this.rotationOverLifetime.y) {
18210
- if (_instanceof1(this.rotationOverLifetime.y, RandomValue)) {
18211
- rotation.y += this.rotationOverLifetime.y.getValue(life, aSeed);
18212
- } else {
18213
- rotation.y += this.rotationOverLifetime.y.getValue(life);
18214
- }
18215
- }
18216
- if (this.rotationOverLifetime.z) {
18217
- if (_instanceof1(this.rotationOverLifetime.z, RandomValue)) {
18218
- rotation.z += this.rotationOverLifetime.z.getValue(life, aSeed);
18219
- } else {
18220
- rotation.z += this.rotationOverLifetime.z.getValue(life);
18221
- }
18222
- }
18223
- } else {
18224
- // Adjust rotation based on the specified lifetime components
18225
- if (this.rotationOverLifetime.x) {
18226
- if (_instanceof1(this.rotationOverLifetime.x, RandomValue)) {
18227
- rotation.x += this.rotationOverLifetime.x.getIntegrateValue(0.0, life, aSeed) * dur;
18228
- } else {
18229
- rotation.x += this.rotationOverLifetime.x.getIntegrateValue(0.0, life, dur) * dur;
18230
- }
18231
- }
18232
- if (this.rotationOverLifetime.y) {
18233
- if (_instanceof1(this.rotationOverLifetime.y, RandomValue)) {
18234
- rotation.y += this.rotationOverLifetime.y.getIntegrateValue(0.0, life, aSeed) * dur;
18235
- } else {
18236
- rotation.y += this.rotationOverLifetime.y.getIntegrateValue(0.0, life, dur) * dur;
18237
- }
18238
- }
18239
- if (this.rotationOverLifetime.z) {
18240
- if (_instanceof1(this.rotationOverLifetime.z, RandomValue)) {
18241
- rotation.z += this.rotationOverLifetime.z.getIntegrateValue(0.0, life, aSeed) * dur;
18242
- } else {
18243
- rotation.z += this.rotationOverLifetime.z.getIntegrateValue(0.0, life, dur) * dur;
18244
- }
18245
- }
18246
- }
18247
- // If the rotation vector is zero, return the identity matrix
18248
- if (rotation.dot(rotation) === 0.0) {
18249
- return result.identity();
18250
- }
18251
- // Return the rotation matrix derived from the rotation vector
18252
- return this.mat3FromRotation(rotation, result);
18253
- };
18254
- _proto.mat3FromRotation = function mat3FromRotation(rotation, result) {
18255
- var d2r = Math.PI / 180;
18256
- var rotationXD2r = rotation.x * d2r;
18257
- var rotationYD2r = rotation.y * d2r;
18258
- var rotationZD2r = rotation.z * d2r;
18259
- var sinRX = Math.sin(rotationXD2r);
18260
- var sinRY = Math.sin(rotationYD2r);
18261
- var sinRZ = Math.sin(rotationZD2r);
18262
- var cosRX = Math.cos(rotationXD2r);
18263
- var cosRY = Math.cos(rotationYD2r);
18264
- var cosRZ = Math.cos(rotationZD2r);
18265
- // rotZ * rotY * rotX
18266
- result.set(cosRZ, -sinRZ, 0., sinRZ, cosRZ, 0., 0., 0., 1.); //rotZ
18267
- result.multiply(this.tempMatrix3.set(cosRY, 0., sinRY, 0., 1., 0., -sinRY, 0, cosRY)); //rotY
18268
- result.multiply(this.tempMatrix3.set(1., 0., 0., 0, cosRX, -sinRX, 0., sinRX, cosRX)); //rotX
18269
- return result;
18270
- };
18271
- _proto.calLinearMov = function calLinearMov(time, duration, aSeed, result) {
18272
- var mov = result;
18273
- var lifetime = time / duration;
18274
- if (!this.linearVelOverLifetime || !this.linearVelOverLifetime.enabled) {
18275
- return mov;
18276
- }
18277
- if (this.linearVelOverLifetime.asMovement) {
18278
- if (this.linearVelOverLifetime.x) {
18279
- if (_instanceof1(this.linearVelOverLifetime.x, RandomValue)) {
18280
- mov.x = this.linearVelOverLifetime.x.getValue(lifetime, aSeed);
18281
- } else {
18282
- mov.x = this.linearVelOverLifetime.x.getValue(lifetime);
18283
- }
18284
- }
18285
- if (this.linearVelOverLifetime.y) {
18286
- if (_instanceof1(this.linearVelOverLifetime.y, RandomValue)) {
18287
- mov.y = this.linearVelOverLifetime.y.getValue(lifetime, aSeed);
18288
- } else {
18289
- mov.y = this.linearVelOverLifetime.y.getValue(lifetime);
18290
- }
18291
- }
18292
- if (this.linearVelOverLifetime.z) {
18293
- if (_instanceof1(this.linearVelOverLifetime.z, RandomValue)) {
18294
- mov.z = this.linearVelOverLifetime.z.getValue(lifetime, aSeed);
18295
- } else {
18296
- mov.z = this.linearVelOverLifetime.z.getValue(lifetime);
18297
- }
18298
- }
18299
- } else {
18300
- // Adjust rotation based on the specified lifetime components
18301
- if (this.linearVelOverLifetime.x) {
18302
- if (_instanceof1(this.linearVelOverLifetime.x, RandomValue)) {
18303
- mov.x = this.linearVelOverLifetime.x.getIntegrateValue(0.0, time, aSeed);
18304
- } else {
18305
- mov.x = this.linearVelOverLifetime.x.getIntegrateValue(0.0, time, duration);
18306
- }
18307
- }
18308
- if (this.linearVelOverLifetime.y) {
18309
- if (_instanceof1(this.linearVelOverLifetime.y, RandomValue)) {
18310
- mov.y = this.linearVelOverLifetime.y.getIntegrateValue(0.0, time, aSeed);
18311
- } else {
18312
- mov.y = this.linearVelOverLifetime.y.getIntegrateValue(0.0, time, duration);
18313
- }
18314
- }
18315
- if (this.linearVelOverLifetime.z) {
18316
- if (_instanceof1(this.linearVelOverLifetime.z, RandomValue)) {
18317
- mov.z = this.linearVelOverLifetime.z.getIntegrateValue(0.0, time, aSeed);
18318
- } else {
18319
- mov.z = this.linearVelOverLifetime.z.getIntegrateValue(0.0, time, duration);
18320
- }
18321
- }
18322
- }
18323
- return mov;
18324
- };
18325
18116
  _proto.removePoint = function removePoint(index) {
18326
18117
  if (index < this.particleCount) {
18327
18118
  this.geometry.setAttributeSubData("aOffset", index * 16, new Float32Array(16));
@@ -18455,6 +18246,247 @@ var ParticleMesh = /*#__PURE__*/ function() {
18455
18246
  geometry.setDrawCount(this.particleCount * 6);
18456
18247
  }
18457
18248
  };
18249
+ _proto.applyTranslation = function applyTranslation(vertexCount, deltaTime) {
18250
+ var localTime = this.time;
18251
+ var aTranslationArray = this.geometry.getAttributeData("aTranslation");
18252
+ var aVelArray = this.geometry.getAttributeData("aVel"); // vector3
18253
+ var aOffsetArray = this.geometry.getAttributeData("aOffset");
18254
+ if (aTranslationArray.length < vertexCount * 3) {
18255
+ aTranslationArray = this.expandArray(aTranslationArray, vertexCount * 3);
18256
+ }
18257
+ // const velocity = this.cachedVelocity;
18258
+ var velocityX = 0;
18259
+ var velocityY = 0;
18260
+ var velocityZ = 0;
18261
+ var uAcceleration = this.mesh.material.getVector4("uAcceleration");
18262
+ var uGravityModifierValue = this.mesh.material.getVector4("uGravityModifierValue");
18263
+ for(var i = 0; i < vertexCount; i += 4){
18264
+ var velOffset = i * 12 + 3;
18265
+ velocityX = aVelArray[velOffset];
18266
+ velocityY = aVelArray[velOffset + 1];
18267
+ velocityZ = aVelArray[velOffset + 2];
18268
+ // velocity.set(aVelArray[velOffset], aVelArray[velOffset + 1], aVelArray[velOffset + 2]);
18269
+ var dt = localTime - aOffsetArray[i * 4 + 2]; // 相对delay的时间
18270
+ var duration = aOffsetArray[i * 4 + 3];
18271
+ if (uAcceleration && uGravityModifierValue) {
18272
+ var d = this.gravityModifier.getIntegrateValue(0, dt, duration);
18273
+ // const acc = this.tempVector3.set(uAcceleration.x * d, uAcceleration.y * d, uAcceleration.z * d);
18274
+ var accX = uAcceleration.x * d;
18275
+ var accY = uAcceleration.y * d;
18276
+ var accZ = uAcceleration.z * d;
18277
+ // speedIntegrate = speedOverLifetime.getIntegrateValue(0, time, duration);
18278
+ if (this.speedOverLifetime) {
18279
+ // dt / dur 归一化
18280
+ var speed = this.speedOverLifetime.getValue(dt / duration);
18281
+ velocityX = velocityX * speed + accX;
18282
+ velocityY = velocityY * speed + accY;
18283
+ velocityZ = velocityZ * speed + accZ;
18284
+ // velocity.multiply(speed).add(acc);
18285
+ } else {
18286
+ velocityX = velocityX + accX;
18287
+ velocityY = velocityY + accY;
18288
+ velocityZ = velocityZ + accZ;
18289
+ // velocity.add(acc);
18290
+ }
18291
+ }
18292
+ var aTranslationOffset = i * 3;
18293
+ if (aOffsetArray[i * 4 + 2] < localTime) {
18294
+ // const translation = velocity.multiply(deltaTime / 1000);
18295
+ var aTranslationX = velocityX * (deltaTime / 1000);
18296
+ var aTranslationY = velocityY * (deltaTime / 1000);
18297
+ var aTranslationZ = velocityZ * (deltaTime / 1000);
18298
+ aTranslationArray[aTranslationOffset] += aTranslationX;
18299
+ aTranslationArray[aTranslationOffset + 1] += aTranslationY;
18300
+ aTranslationArray[aTranslationOffset + 2] += aTranslationZ;
18301
+ aTranslationArray[aTranslationOffset + 3] += aTranslationX;
18302
+ aTranslationArray[aTranslationOffset + 4] += aTranslationY;
18303
+ aTranslationArray[aTranslationOffset + 5] += aTranslationZ;
18304
+ aTranslationArray[aTranslationOffset + 6] += aTranslationX;
18305
+ aTranslationArray[aTranslationOffset + 7] += aTranslationY;
18306
+ aTranslationArray[aTranslationOffset + 8] += aTranslationZ;
18307
+ aTranslationArray[aTranslationOffset + 9] += aTranslationX;
18308
+ aTranslationArray[aTranslationOffset + 10] += aTranslationY;
18309
+ aTranslationArray[aTranslationOffset + 11] += aTranslationZ;
18310
+ }
18311
+ }
18312
+ this.geometry.setAttributeData("aTranslation", aTranslationArray);
18313
+ };
18314
+ _proto.applyRotation = function applyRotation(vertexCount, deltaTime) {
18315
+ var aRotationArray = this.geometry.getAttributeData("aRotation0");
18316
+ var aOffsetArray = this.geometry.getAttributeData("aOffset");
18317
+ var aRotArray = this.geometry.getAttributeData("aRot"); // vector3
18318
+ var aSeedArray = this.geometry.getAttributeData("aSeed"); // float
18319
+ var localTime = this.time;
18320
+ var aRotationMatrix = this.cachedRotationMatrix;
18321
+ if (aRotationArray.length < vertexCount * 9) {
18322
+ aRotationArray = this.expandArray(aRotationArray, vertexCount * 9);
18323
+ }
18324
+ for(var i = 0; i < vertexCount; i += 4){
18325
+ var time = localTime - aOffsetArray[i * 4 + 2];
18326
+ var duration = aOffsetArray[i * 4 + 3];
18327
+ var life = clamp$1(time / duration, 0.0, 1.0);
18328
+ var aRotOffset = i * 8;
18329
+ var aRot = this.cachedRotationVector3.set(aRotArray[aRotOffset], aRotArray[aRotOffset + 1], aRotArray[aRotOffset + 2]);
18330
+ var aSeed = aSeedArray[i * 8 + 3];
18331
+ var rotation = aRot;
18332
+ if (!this.rotationOverLifetime) {
18333
+ aRotationMatrix.setZero();
18334
+ } else if (this.rotationOverLifetime.asRotation) {
18335
+ // Adjust rotation based on the specified lifetime components
18336
+ if (this.rotationOverLifetime.x) {
18337
+ if (_instanceof1(this.rotationOverLifetime.x, RandomValue)) {
18338
+ rotation.x += this.rotationOverLifetime.x.getValue(life, aSeed);
18339
+ } else {
18340
+ rotation.x += this.rotationOverLifetime.x.getValue(life);
18341
+ }
18342
+ }
18343
+ if (this.rotationOverLifetime.y) {
18344
+ if (_instanceof1(this.rotationOverLifetime.y, RandomValue)) {
18345
+ rotation.y += this.rotationOverLifetime.y.getValue(life, aSeed);
18346
+ } else {
18347
+ rotation.y += this.rotationOverLifetime.y.getValue(life);
18348
+ }
18349
+ }
18350
+ if (this.rotationOverLifetime.z) {
18351
+ if (_instanceof1(this.rotationOverLifetime.z, RandomValue)) {
18352
+ rotation.z += this.rotationOverLifetime.z.getValue(life, aSeed);
18353
+ } else {
18354
+ rotation.z += this.rotationOverLifetime.z.getValue(life);
18355
+ }
18356
+ }
18357
+ } else {
18358
+ // Adjust rotation based on the specified lifetime components
18359
+ if (this.rotationOverLifetime.x) {
18360
+ if (_instanceof1(this.rotationOverLifetime.x, RandomValue)) {
18361
+ rotation.x += this.rotationOverLifetime.x.getIntegrateValue(0.0, life, aSeed) * duration;
18362
+ } else {
18363
+ rotation.x += this.rotationOverLifetime.x.getIntegrateValue(0.0, life, duration) * duration;
18364
+ }
18365
+ }
18366
+ if (this.rotationOverLifetime.y) {
18367
+ if (_instanceof1(this.rotationOverLifetime.y, RandomValue)) {
18368
+ rotation.y += this.rotationOverLifetime.y.getIntegrateValue(0.0, life, aSeed) * duration;
18369
+ } else {
18370
+ rotation.y += this.rotationOverLifetime.y.getIntegrateValue(0.0, life, duration) * duration;
18371
+ }
18372
+ }
18373
+ if (this.rotationOverLifetime.z) {
18374
+ if (_instanceof1(this.rotationOverLifetime.z, RandomValue)) {
18375
+ rotation.z += this.rotationOverLifetime.z.getIntegrateValue(0.0, life, aSeed) * duration;
18376
+ } else {
18377
+ rotation.z += this.rotationOverLifetime.z.getIntegrateValue(0.0, life, duration) * duration;
18378
+ }
18379
+ }
18380
+ }
18381
+ // If the rotation vector is zero, return the identity matrix
18382
+ if (rotation.dot(rotation) === 0.0) {
18383
+ aRotationMatrix.identity();
18384
+ }
18385
+ var d2r = Math.PI / 180;
18386
+ var rotationXD2r = rotation.x * d2r;
18387
+ var rotationYD2r = rotation.y * d2r;
18388
+ var rotationZD2r = rotation.z * d2r;
18389
+ var sinRX = Math.sin(rotationXD2r);
18390
+ var sinRY = Math.sin(rotationYD2r);
18391
+ var sinRZ = Math.sin(rotationZD2r);
18392
+ var cosRX = Math.cos(rotationXD2r);
18393
+ var cosRY = Math.cos(rotationYD2r);
18394
+ var cosRZ = Math.cos(rotationZD2r);
18395
+ // rotZ * rotY * rotX
18396
+ aRotationMatrix.set(cosRZ, -sinRZ, 0., sinRZ, cosRZ, 0., 0., 0., 1.); //rotZ
18397
+ aRotationMatrix.multiply(this.tempMatrix3.set(cosRY, 0., sinRY, 0., 1., 0., -sinRY, 0, cosRY)); //rotY
18398
+ aRotationMatrix.multiply(this.tempMatrix3.set(1., 0., 0., 0, cosRX, -sinRX, 0., sinRX, cosRX)); //rotX
18399
+ var aRotationOffset = i * 9;
18400
+ var matrixArray = aRotationMatrix.elements;
18401
+ aRotationArray.set(matrixArray, aRotationOffset);
18402
+ if (i + 4 <= vertexCount) {
18403
+ aRotationArray.set(matrixArray, aRotationOffset + 9);
18404
+ aRotationArray.set(matrixArray, aRotationOffset + 18);
18405
+ aRotationArray.set(matrixArray, aRotationOffset + 27);
18406
+ }
18407
+ }
18408
+ this.geometry.setAttributeData("aRotation0", aRotationArray);
18409
+ };
18410
+ _proto.applyLinearMove = function applyLinearMove(vertexCount, deltaTime) {
18411
+ var aLinearMoveArray = this.geometry.getAttributeData("aLinearMove");
18412
+ var aOffsetArray = this.geometry.getAttributeData("aOffset");
18413
+ var aSeedArray = this.geometry.getAttributeData("aSeed"); // float
18414
+ var localTime = this.time;
18415
+ if (aLinearMoveArray.length < vertexCount * 3) {
18416
+ aLinearMoveArray = this.expandArray(aLinearMoveArray, vertexCount * 3);
18417
+ }
18418
+ var linearMove = this.cachedLinearMove;
18419
+ if (this.linearVelOverLifetime && this.linearVelOverLifetime.enabled) {
18420
+ for(var i = 0; i < vertexCount; i += 4){
18421
+ var time = localTime - aOffsetArray[i * 4 + 2];
18422
+ var duration = aOffsetArray[i * 4 + 3];
18423
+ // const life = math.clamp(time / duration, 0.0, 1.0);
18424
+ var lifetime = time / duration;
18425
+ var aSeed = aSeedArray[i * 8 + 3];
18426
+ linearMove.setZero();
18427
+ if (this.linearVelOverLifetime.asMovement) {
18428
+ if (this.linearVelOverLifetime.x) {
18429
+ if (_instanceof1(this.linearVelOverLifetime.x, RandomValue)) {
18430
+ linearMove.x = this.linearVelOverLifetime.x.getValue(lifetime, aSeed);
18431
+ } else {
18432
+ linearMove.x = this.linearVelOverLifetime.x.getValue(lifetime);
18433
+ }
18434
+ }
18435
+ if (this.linearVelOverLifetime.y) {
18436
+ if (_instanceof1(this.linearVelOverLifetime.y, RandomValue)) {
18437
+ linearMove.y = this.linearVelOverLifetime.y.getValue(lifetime, aSeed);
18438
+ } else {
18439
+ linearMove.y = this.linearVelOverLifetime.y.getValue(lifetime);
18440
+ }
18441
+ }
18442
+ if (this.linearVelOverLifetime.z) {
18443
+ if (_instanceof1(this.linearVelOverLifetime.z, RandomValue)) {
18444
+ linearMove.z = this.linearVelOverLifetime.z.getValue(lifetime, aSeed);
18445
+ } else {
18446
+ linearMove.z = this.linearVelOverLifetime.z.getValue(lifetime);
18447
+ }
18448
+ }
18449
+ } else {
18450
+ // Adjust rotation based on the specified lifetime components
18451
+ if (this.linearVelOverLifetime.x) {
18452
+ if (_instanceof1(this.linearVelOverLifetime.x, RandomValue)) {
18453
+ linearMove.x = this.linearVelOverLifetime.x.getIntegrateValue(0.0, time, aSeed);
18454
+ } else {
18455
+ linearMove.x = this.linearVelOverLifetime.x.getIntegrateValue(0.0, time, duration);
18456
+ }
18457
+ }
18458
+ if (this.linearVelOverLifetime.y) {
18459
+ if (_instanceof1(this.linearVelOverLifetime.y, RandomValue)) {
18460
+ linearMove.y = this.linearVelOverLifetime.y.getIntegrateValue(0.0, time, aSeed);
18461
+ } else {
18462
+ linearMove.y = this.linearVelOverLifetime.y.getIntegrateValue(0.0, time, duration);
18463
+ }
18464
+ }
18465
+ if (this.linearVelOverLifetime.z) {
18466
+ if (_instanceof1(this.linearVelOverLifetime.z, RandomValue)) {
18467
+ linearMove.z = this.linearVelOverLifetime.z.getIntegrateValue(0.0, time, aSeed);
18468
+ } else {
18469
+ linearMove.z = this.linearVelOverLifetime.z.getIntegrateValue(0.0, time, duration);
18470
+ }
18471
+ }
18472
+ }
18473
+ var aLinearMoveOffset = i * 3;
18474
+ aLinearMoveArray[aLinearMoveOffset] = linearMove.x;
18475
+ aLinearMoveArray[aLinearMoveOffset + 1] = linearMove.y;
18476
+ aLinearMoveArray[aLinearMoveOffset + 2] = linearMove.z;
18477
+ aLinearMoveArray[aLinearMoveOffset + 3] = linearMove.x;
18478
+ aLinearMoveArray[aLinearMoveOffset + 4] = linearMove.y;
18479
+ aLinearMoveArray[aLinearMoveOffset + 5] = linearMove.z;
18480
+ aLinearMoveArray[aLinearMoveOffset + 6] = linearMove.x;
18481
+ aLinearMoveArray[aLinearMoveOffset + 7] = linearMove.y;
18482
+ aLinearMoveArray[aLinearMoveOffset + 8] = linearMove.z;
18483
+ aLinearMoveArray[aLinearMoveOffset + 9] = linearMove.x;
18484
+ aLinearMoveArray[aLinearMoveOffset + 10] = linearMove.y;
18485
+ aLinearMoveArray[aLinearMoveOffset + 11] = linearMove.z;
18486
+ }
18487
+ }
18488
+ this.geometry.setAttributeData("aLinearMove", aLinearMoveArray);
18489
+ };
18458
18490
  _proto.expandArray = function expandArray(array, newSize) {
18459
18491
  var newArr = new Float32Array(newSize);
18460
18492
  newArr.set(array);
@@ -19091,7 +19123,13 @@ exports.TransformPlayableAsset = __decorate([
19091
19123
  return Playable.apply(this, arguments);
19092
19124
  }
19093
19125
  var _proto = ActivationPlayable.prototype;
19094
- _proto.processFrame = function processFrame(context) {};
19126
+ _proto.processFrame = function processFrame(context) {
19127
+ var vfxItem = context.output.getUserData();
19128
+ if (!_instanceof1(vfxItem, exports.VFXItem)) {
19129
+ return;
19130
+ }
19131
+ vfxItem.time = this.time;
19132
+ };
19095
19133
  return ActivationPlayable;
19096
19134
  }(Playable);
19097
19135
  exports.ActivationPlayableAsset = /*#__PURE__*/ function(PlayableAsset) {
@@ -19244,7 +19282,7 @@ var AnimationClipPlayable = /*#__PURE__*/ function(Playable) {
19244
19282
  _proto.toLocalTime = function toLocalTime(time) {
19245
19283
  var localTime = time - this.start;
19246
19284
  var duration = this.duration;
19247
- if (localTime - duration > 0.001) {
19285
+ if (localTime - duration > 0) {
19248
19286
  if (this.endBehavior === EndBehavior.restart) {
19249
19287
  localTime = localTime % duration;
19250
19288
  } else if (this.endBehavior === EndBehavior.freeze) {
@@ -19373,7 +19411,7 @@ var RuntimeClip = /*#__PURE__*/ function() {
19373
19411
  var ended = false;
19374
19412
  var started = false;
19375
19413
  var boundObject = this.track.binding;
19376
- if (localTime > clip.start + clip.duration + 0.001 && clip.endBehavior === EndBehavior.destroy) {
19414
+ if (localTime >= clip.start + clip.duration && clip.endBehavior === EndBehavior.destroy) {
19377
19415
  if (_instanceof1(boundObject, exports.VFXItem) && exports.VFXItem.isParticle(boundObject) && this.particleSystem && !this.particleSystem.destroyed) {
19378
19416
  weight = 1.0;
19379
19417
  } else {
@@ -20603,6 +20641,12 @@ exports.EffectComponent = /*#__PURE__*/ function(RendererComponent) {
20603
20641
  _proto.onStart = function onStart() {
20604
20642
  this.item.getHitTestParams = this.getHitTestParams;
20605
20643
  };
20644
+ _proto.onUpdate = function onUpdate(dt) {
20645
+ var time = this.item.time;
20646
+ var _this_material_getVector4;
20647
+ var _Time = (_this_material_getVector4 = this.material.getVector4("_Time")) != null ? _this_material_getVector4 : new Vector4();
20648
+ this.material.setVector4("_Time", _Time.set(time / 20, time, time * 2, time * 3));
20649
+ };
20606
20650
  _proto.render = function render(renderer) {
20607
20651
  if (renderer.renderingData.currentFrame.globalUniforms) {
20608
20652
  renderer.setGlobalMatrix("effects_ObjectToWorld", this.transform.getWorldMatrix());
@@ -20856,6 +20900,9 @@ exports.VFXItem = /*#__PURE__*/ function(EffectsObject) {
20856
20900
  * 元素的变换包含位置、旋转、缩放。
20857
20901
  */ _this.transform = new Transform();
20858
20902
  /**
20903
+ * 元素动画的当前时间
20904
+ */ _this.time = 0;
20905
+ /**
20859
20906
  * 元素动画的持续时间
20860
20907
  */ _this.duration = 0;
20861
20908
  /**
@@ -21188,6 +21235,7 @@ exports.VFXItem = /*#__PURE__*/ function(EffectsObject) {
21188
21235
  var component = _step.value;
21189
21236
  if (component.enabled && !component.isStartCalled) {
21190
21237
  component.onStart();
21238
+ component.isStartCalled = true;
21191
21239
  }
21192
21240
  }
21193
21241
  for(var _iterator1 = _create_for_of_iterator_helper_loose(this.components), _step1; !(_step1 = _iterator1()).done;){
@@ -28110,7 +28158,7 @@ registerPlugin("sprite", SpriteLoader, exports.VFXItem, true);
28110
28158
  registerPlugin("particle", ParticleLoader, exports.VFXItem, true);
28111
28159
  registerPlugin("cal", CalculateLoader, exports.VFXItem, true);
28112
28160
  registerPlugin("interact", InteractLoader, exports.VFXItem, true);
28113
- var version$1 = "2.1.0-alpha.2";
28161
+ var version$1 = "2.1.0-alpha.4";
28114
28162
  logger.info("Core version: " + version$1 + ".");
28115
28163
 
28116
28164
  var _obj;
@@ -29791,7 +29839,7 @@ setMaxSpriteMeshItemCount(8);
29791
29839
  */ Mesh.create = function(engine, props) {
29792
29840
  return new ThreeMesh(engine, props);
29793
29841
  };
29794
- var version = "2.1.0-alpha.2";
29842
+ var version = "2.1.0-alpha.4";
29795
29843
  logger.info("THREEJS plugin version: " + version + ".");
29796
29844
 
29797
29845
  exports.AbstractPlugin = AbstractPlugin;