@galacean/engine-core 1.4.9 → 1.4.10

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/module.js CHANGED
@@ -10351,7 +10351,7 @@ var Renderer = /*#__PURE__*/ function(Component) {
10351
10351
  };
10352
10352
  _proto._createInstanceMaterial = function _createInstanceMaterial(material, index) {
10353
10353
  var insMaterial = material.clone();
10354
- insMaterial.name = insMaterial.name + "(Instance)";
10354
+ insMaterial.name = material.name + "(Instance)";
10355
10355
  this._addResourceReferCount(material, -1);
10356
10356
  this._addResourceReferCount(insMaterial, 1);
10357
10357
  this._materialsInstanced[index] = true;
@@ -12330,6 +12330,7 @@ var BufferUtil = /*#__PURE__*/ function() {
12330
12330
  _this = ReferResource.call(this, engine) || this, /** @internal */ _this._renderStates = [] // todo: later will as a part of shaderData when shader effect frame is OK, that is more powerful and flexible.
12331
12331
  , _this._shaderData = new ShaderData(ShaderDataGroup.Material);
12332
12332
  _this.shader = shader;
12333
+ _this.name = shader.name;
12333
12334
  return _this;
12334
12335
  }
12335
12336
  var _proto = Material.prototype;
@@ -12337,7 +12338,7 @@ var BufferUtil = /*#__PURE__*/ function() {
12337
12338
  * Clone and return the instance.
12338
12339
  */ _proto.clone = function clone() {
12339
12340
  var dest = new Material(this._engine, this.shader);
12340
- this.cloneTo(dest);
12341
+ this._cloneToAndModifyName(dest);
12341
12342
  return dest;
12342
12343
  };
12343
12344
  /**
@@ -12354,6 +12355,10 @@ var BufferUtil = /*#__PURE__*/ function() {
12354
12355
  this.shaderData._addReferCount(value);
12355
12356
  this._shader._addReferCount(value);
12356
12357
  };
12358
+ _proto._cloneToAndModifyName = function _cloneToAndModifyName(target) {
12359
+ this.cloneTo(target);
12360
+ target.name = this.name + "(Clone)";
12361
+ };
12357
12362
  /**
12358
12363
  * @override
12359
12364
  */ _proto._onDestroy = function _onDestroy() {
@@ -12509,7 +12514,7 @@ var BaseMaterial = /*#__PURE__*/ function(Material) {
12509
12514
  * Clone and return the instance.
12510
12515
  */ _proto.clone = function clone() {
12511
12516
  var dest = new BaseMaterial(this._engine, this.shader);
12512
- this.cloneTo(dest);
12517
+ this._cloneToAndModifyName(dest);
12513
12518
  return dest;
12514
12519
  };
12515
12520
  /**
@@ -12691,7 +12696,7 @@ BaseMaterial._alphaCutoffMacro = ShaderMacro.getByName("MATERIAL_IS_ALPHA_CUTOFF
12691
12696
  var _proto = BlinnPhongMaterial.prototype;
12692
12697
  _proto.clone = function clone() {
12693
12698
  var dest = new BlinnPhongMaterial(this._engine);
12694
- this.cloneTo(dest);
12699
+ this._cloneToAndModifyName(dest);
12695
12700
  return dest;
12696
12701
  };
12697
12702
  _create_class(BlinnPhongMaterial, [
@@ -13151,7 +13156,7 @@ PBRBaseMaterial._clearCoatNormalTextureProp = ShaderProperty.getByName("material
13151
13156
  * @inheritdoc
13152
13157
  */ _proto.clone = function clone() {
13153
13158
  var dest = new PBRMaterial(this._engine);
13154
- this.cloneTo(dest);
13159
+ this._cloneToAndModifyName(dest);
13155
13160
  return dest;
13156
13161
  };
13157
13162
  _proto._onIridescenceRangeChanged = function _onIridescenceRangeChanged() {
@@ -13617,7 +13622,7 @@ PBRMaterial._thicknessTextureProp = ShaderProperty.getByName("material_Thickness
13617
13622
  * @inheritdoc
13618
13623
  */ _proto.clone = function clone() {
13619
13624
  var dest = new PBRSpecularMaterial(this._engine);
13620
- this.cloneTo(dest);
13625
+ this._cloneToAndModifyName(dest);
13621
13626
  return dest;
13622
13627
  };
13623
13628
  _create_class(PBRSpecularMaterial, [
@@ -13690,7 +13695,7 @@ PBRSpecularMaterial._specularGlossinessTextureMacro = ShaderMacro.getByName("MAT
13690
13695
  * @inheritdoc
13691
13696
  */ _proto.clone = function clone() {
13692
13697
  var dest = new UnlitMaterial(this._engine);
13693
- this.cloneTo(dest);
13698
+ this._cloneToAndModifyName(dest);
13694
13699
  return dest;
13695
13700
  };
13696
13701
  _create_class(UnlitMaterial, [
@@ -17350,7 +17355,7 @@ var ComponentCloner = /*#__PURE__*/ function() {
17350
17355
  var _this;
17351
17356
  _this = EngineObject.call(this, engine) || this, /** The layer the entity belongs to. */ _this.layer = Layer.Layer0, /** @internal */ _this._isActiveInHierarchy = false, /** @internal */ _this._isActiveInScene = false, /** @internal */ _this._components = [], /** @internal */ _this._scripts = new DisorderedArray(), /** @internal */ _this._children = [], /** @internal */ _this._isRoot = false, /** @internal */ _this._isActive = true, /** @internal */ _this._siblingIndex = -1, /** @internal */ _this._isTemplate = false, /** @internal */ _this._updateFlagManager = new UpdateFlagManager(), _this._parent = null, //--------------------------------------------------------------deprecated----------------------------------------------------------------
17352
17357
  _this._invModelMatrix = new Matrix();
17353
- _this.name = name;
17358
+ _this.name = name != null ? name : "Entity";
17354
17359
  for(var i = 0, n = components.length; i < n; i++){
17355
17360
  _this.addComponent(components[i]);
17356
17361
  }
@@ -17431,11 +17436,11 @@ var ComponentCloner = /*#__PURE__*/ function() {
17431
17436
  child = indexOrChild;
17432
17437
  }
17433
17438
  if (child._isRoot) {
17434
- child._scene._removeFromEntityList(child);
17439
+ var oldScene = child._scene;
17440
+ Entity._removeFromChildren(oldScene._rootEntities, child);
17435
17441
  child._isRoot = false;
17436
17442
  this._addToChildrenList(index, child);
17437
17443
  child._parent = this;
17438
- var oldScene = child._scene;
17439
17444
  var newScene = this._scene;
17440
17445
  var inActiveChangeFlag = ActiveChangeFlag.None;
17441
17446
  if (!this._isActiveInHierarchy) {
@@ -17640,14 +17645,8 @@ var ComponentCloner = /*#__PURE__*/ function() {
17640
17645
  */ _proto._removeFromParent = function _removeFromParent() {
17641
17646
  var oldParent = this._parent;
17642
17647
  if (oldParent != null) {
17643
- var oldSibling = oldParent._children;
17644
- var index = this._siblingIndex;
17645
- oldSibling.splice(index, 1);
17646
- for(var n = oldSibling.length; index < n; index++){
17647
- oldSibling[index]._siblingIndex--;
17648
- }
17648
+ Entity._removeFromChildren(oldParent._children, this);
17649
17649
  this._parent = null;
17650
- this._siblingIndex = -1;
17651
17650
  this._dispatchModify(EntityModifyFlags.Child, oldParent);
17652
17651
  }
17653
17652
  };
@@ -17693,21 +17692,7 @@ var ComponentCloner = /*#__PURE__*/ function() {
17693
17692
  (_this__modifyFlagManager = this._modifyFlagManager) == null ? void 0 : _this__modifyFlagManager.dispatch(flag, param);
17694
17693
  };
17695
17694
  _proto._addToChildrenList = function _addToChildrenList(index, child) {
17696
- var children = this._children;
17697
- var childCount = children.length;
17698
- if (index === undefined) {
17699
- child._siblingIndex = childCount;
17700
- children.push(child);
17701
- } else {
17702
- if (index < 0 || index > childCount) {
17703
- throw "The index " + index + " is out of child list bounds " + childCount;
17704
- }
17705
- child._siblingIndex = index;
17706
- children.splice(index, 0, child);
17707
- for(var i = index + 1, n = childCount + 1; i < n; i++){
17708
- children[i]._siblingIndex++;
17709
- }
17710
- }
17695
+ Entity._addToChildren(this._children, child, index);
17711
17696
  this._dispatchModify(EntityModifyFlags.Child, this);
17712
17697
  };
17713
17698
  _proto._setParent = function _setParent(parent, siblingIndex) {
@@ -17886,6 +17871,39 @@ var ComponentCloner = /*#__PURE__*/ function() {
17886
17871
  }
17887
17872
  return entity;
17888
17873
  };
17874
+ /**
17875
+ * @internal
17876
+ */ Entity._removeFromChildren = function _removeFromChildren(children, entity) {
17877
+ var count = children.length - 1;
17878
+ for(var i = entity._siblingIndex; i < count; i++){
17879
+ var child = children[i + 1];
17880
+ children[i] = child;
17881
+ child._siblingIndex = i;
17882
+ }
17883
+ children.length = count;
17884
+ entity._siblingIndex = -1;
17885
+ };
17886
+ /**
17887
+ * @internal
17888
+ */ Entity._addToChildren = function _addToChildren(children, entity, index) {
17889
+ var childCount = children.length;
17890
+ children.length = childCount + 1;
17891
+ if (index === undefined) {
17892
+ children[childCount] = entity;
17893
+ entity._siblingIndex = childCount;
17894
+ } else {
17895
+ if (index < 0 || index > childCount) {
17896
+ throw "The index " + index + " is out of child list bounds " + childCount;
17897
+ }
17898
+ for(var i = childCount; i > index; i--){
17899
+ var swapChild = children[i - 1];
17900
+ swapChild._siblingIndex = i;
17901
+ children[i] = swapChild;
17902
+ }
17903
+ entity._siblingIndex = index;
17904
+ children[index] = entity;
17905
+ }
17906
+ };
17889
17907
  _create_class(Entity, [
17890
17908
  {
17891
17909
  key: "transform",
@@ -26975,11 +26993,11 @@ PostProcessManager._tempVector3 = new Vector3();
26975
26993
  var oldScene = entity._scene;
26976
26994
  if (oldScene !== this) {
26977
26995
  if (oldScene && isRoot) {
26978
- oldScene._removeFromEntityList(entity);
26996
+ Entity._removeFromChildren(oldScene._rootEntities, entity);
26979
26997
  }
26980
- this._addToRootEntityList(index, entity);
26998
+ Entity._addToChildren(this._rootEntities, entity, index);
26981
26999
  } else if (!isRoot) {
26982
- this._addToRootEntityList(index, entity);
27000
+ Entity._addToChildren(this._rootEntities, entity, index);
26983
27001
  }
26984
27002
  // Process entity active/inActive
26985
27003
  var inActiveChangeFlag = ActiveChangeFlag.None;
@@ -27006,7 +27024,7 @@ PostProcessManager._tempVector3 = new Vector3();
27006
27024
  * @param entity - The root entity to remove
27007
27025
  */ _proto.removeRootEntity = function removeRootEntity(entity) {
27008
27026
  if (entity._isRoot && entity._scene == this) {
27009
- this._removeFromEntityList(entity);
27027
+ Entity._removeFromChildren(this._rootEntities, entity);
27010
27028
  entity._isRoot = false;
27011
27029
  var inActiveChangeFlag = ActiveChangeFlag.None;
27012
27030
  this._isActiveInEngine && entity._isActiveInHierarchy && (inActiveChangeFlag |= ActiveChangeFlag.Hierarchy);
@@ -27105,17 +27123,6 @@ PostProcessManager._tempVector3 = new Vector3();
27105
27123
  };
27106
27124
  /**
27107
27125
  * @internal
27108
- */ _proto._removeFromEntityList = function _removeFromEntityList(entity) {
27109
- var rootEntities = this._rootEntities;
27110
- var index = entity._siblingIndex;
27111
- rootEntities.splice(index, 1);
27112
- for(var n = rootEntities.length; index < n; index++){
27113
- rootEntities[index]._siblingIndex--;
27114
- }
27115
- entity._siblingIndex = -1;
27116
- };
27117
- /**
27118
- * @internal
27119
27126
  */ _proto._onDestroy = function _onDestroy() {
27120
27127
  EngineObject.prototype._onDestroy.call(this);
27121
27128
  // Remove from sceneManager
@@ -27132,23 +27139,6 @@ PostProcessManager._tempVector3 = new Vector3();
27132
27139
  var allCreatedScenes = sceneManager._allCreatedScenes;
27133
27140
  allCreatedScenes.splice(allCreatedScenes.indexOf(this), 1);
27134
27141
  };
27135
- _proto._addToRootEntityList = function _addToRootEntityList(index, rootEntity) {
27136
- var rootEntities = this._rootEntities;
27137
- var rootEntityCount = rootEntities.length;
27138
- if (index === undefined) {
27139
- rootEntity._siblingIndex = rootEntityCount;
27140
- rootEntities.push(rootEntity);
27141
- } else {
27142
- if (index < 0 || index > rootEntityCount) {
27143
- throw "The index " + index + " is out of child list bounds " + rootEntityCount;
27144
- }
27145
- rootEntity._siblingIndex = index;
27146
- rootEntities.splice(index, 0, rootEntity);
27147
- for(var i = index + 1, n = rootEntityCount + 1; i < n; i++){
27148
- rootEntities[i]._siblingIndex++;
27149
- }
27150
- }
27151
- };
27152
27142
  _proto._computeLinearFogParams = function _computeLinearFogParams(fogStart, fogEnd) {
27153
27143
  var fogRange = fogEnd - fogStart;
27154
27144
  var fogParams = this._fogParams;
@@ -31207,7 +31197,7 @@ function _assert_this_initialized(self) {
31207
31197
  var _proto = SkyBoxMaterial.prototype;
31208
31198
  _proto.clone = function clone() {
31209
31199
  var dest = new SkyBoxMaterial(this._engine);
31210
- this.cloneTo(dest);
31200
+ this._cloneToAndModifyName(dest);
31211
31201
  return dest;
31212
31202
  };
31213
31203
  _create_class(SkyBoxMaterial, [
@@ -31313,7 +31303,7 @@ SkyBoxMaterial._decodeSkyRGBMMacro = ShaderMacro.getByName("MATERIAL_IS_DECODE_S
31313
31303
  * @inheritDoc
31314
31304
  */ _proto.clone = function clone() {
31315
31305
  var dest = new SkyProceduralMaterial(this._engine);
31316
- this.cloneTo(dest);
31306
+ this._cloneToAndModifyName(dest);
31317
31307
  return dest;
31318
31308
  };
31319
31309
  _create_class(SkyProceduralMaterial, [
@@ -32214,6 +32204,13 @@ __decorate([
32214
32204
  return this.constant;
32215
32205
  case ParticleCurveMode.TwoConstants:
32216
32206
  return this.constantMin + (this.constantMax - this.constantMin) * lerpFactor;
32207
+ case ParticleCurveMode.Curve:
32208
+ var _this_curve;
32209
+ return (_this_curve = this.curve) == null ? void 0 : _this_curve._evaluate(time);
32210
+ case ParticleCurveMode.TwoCurves:
32211
+ var _this_curveMin, _this_curveMax;
32212
+ var min = (_this_curveMin = this.curveMin) == null ? void 0 : _this_curveMin._evaluate(time);
32213
+ return min + (((_this_curveMax = this.curveMax) == null ? void 0 : _this_curveMax._evaluate(time)) - min) * lerpFactor;
32217
32214
  }
32218
32215
  };
32219
32216
  /**
@@ -33052,9 +33049,10 @@ __decorate([
33052
33049
  * Remove a key from the curve.
33053
33050
  * @param index - The remove key index
33054
33051
  */ _proto.removeKey = function removeKey(index) {
33055
- this._keys.splice(index, 1);
33052
+ var keys = this._keys;
33053
+ var removeKey = keys[index];
33054
+ keys.splice(index, 1);
33056
33055
  this._typeArrayDirty = true;
33057
- var removeKey = this._keys[index];
33058
33056
  removeKey._unRegisterOnValueChanged(this._updateDispatch);
33059
33057
  this._updateDispatch();
33060
33058
  };
@@ -33070,6 +33068,29 @@ __decorate([
33070
33068
  };
33071
33069
  /**
33072
33070
  * @internal
33071
+ */ _proto._evaluate = function _evaluate(normalizedAge) {
33072
+ var keys = this.keys;
33073
+ var length = keys.length;
33074
+ for(var i = 0; i < length; i++){
33075
+ var key = keys[i];
33076
+ var time = key.time;
33077
+ if (normalizedAge <= time) {
33078
+ if (i === 0) {
33079
+ // Small than first key
33080
+ return key.value;
33081
+ } else {
33082
+ // Between two keys
33083
+ var _keys_ = keys[i - 1], lastTime = _keys_.time, lastValue = _keys_.value;
33084
+ var age = (normalizedAge - lastTime) / (time - lastTime);
33085
+ return lastValue + (key.value - lastValue) * age;
33086
+ }
33087
+ }
33088
+ }
33089
+ // Large than last key
33090
+ return keys[length - 1].value;
33091
+ };
33092
+ /**
33093
+ * @internal
33073
33094
  */ _proto._getTypeArray = function _getTypeArray() {
33074
33095
  var typeArray = this._typeArray || (this._typeArray = new Float32Array(4 * 2));
33075
33096
  if (this._typeArrayDirty) {
@@ -33681,7 +33702,7 @@ __decorate([
33681
33702
  };
33682
33703
  /**
33683
33704
  * @internal
33684
- */ _proto._emit = function _emit(time, count) {
33705
+ */ _proto._emit = function _emit(playTime, count) {
33685
33706
  if (this.emission.enabled) {
33686
33707
  // Wait the existing particles to be retired
33687
33708
  var notRetireParticleCount = this._getNotRetiredParticleCount();
@@ -33694,7 +33715,7 @@ __decorate([
33694
33715
  var shape = this.emission.shape;
33695
33716
  for(var i = 0; i < count; i++){
33696
33717
  if (shape == null ? void 0 : shape.enabled) {
33697
- shape._generatePositionAndDirection(this.emission._shapeRand, time, position, direction);
33718
+ shape._generatePositionAndDirection(this.emission._shapeRand, playTime, position, direction);
33698
33719
  var positionScale = this.main._getPositionScale();
33699
33720
  position.multiply(positionScale);
33700
33721
  direction.normalize().multiply(positionScale);
@@ -33702,7 +33723,7 @@ __decorate([
33702
33723
  position.set(0, 0, 0);
33703
33724
  direction.set(0, 0, -1);
33704
33725
  }
33705
- this._addNewParticle(position, direction, transform, time);
33726
+ this._addNewParticle(position, direction, transform, playTime);
33706
33727
  }
33707
33728
  }
33708
33729
  };
@@ -34017,7 +34038,7 @@ __decorate([
34017
34038
  this._transformedBoundsArray[previousFreeElement * ParticleBufferUtils.boundsFloatStride + boundsTimeOffset] = this._playTime;
34018
34039
  }
34019
34040
  };
34020
- _proto._addNewParticle = function _addNewParticle(position, direction, transform, time) {
34041
+ _proto._addNewParticle = function _addNewParticle(position, direction, transform, playTime) {
34021
34042
  var firstFreeElement = this._firstFreeElement;
34022
34043
  var nextFreeElement = firstFreeElement + 1;
34023
34044
  if (nextFreeElement >= this._currentParticleCount) {
@@ -34047,35 +34068,30 @@ __decorate([
34047
34068
  var instanceVertices = this._instanceVertices;
34048
34069
  var offset = firstFreeElement * ParticleBufferUtils.instanceVertexFloatStride;
34049
34070
  // Position
34050
- instanceVertices[offset] = position.x;
34051
- instanceVertices[offset + 1] = position.y;
34052
- instanceVertices[offset + 2] = position.z;
34071
+ position.copyToArray(instanceVertices, offset);
34053
34072
  // Start life time
34054
34073
  instanceVertices[offset + ParticleBufferUtils.startLifeTimeOffset] = main.startLifetime.evaluate(undefined, main._startLifeTimeRand.random());
34055
34074
  // Direction
34056
- instanceVertices[offset + 4] = direction.x;
34057
- instanceVertices[offset + 5] = direction.y;
34058
- instanceVertices[offset + 6] = direction.z;
34075
+ direction.copyToArray(instanceVertices, offset + 4);
34059
34076
  // Time
34060
- instanceVertices[offset + ParticleBufferUtils.timeOffset] = time;
34077
+ instanceVertices[offset + ParticleBufferUtils.timeOffset] = playTime;
34061
34078
  // Color
34062
34079
  var startColor = ParticleGenerator._tempColor0;
34063
34080
  main.startColor.evaluate(undefined, main._startColorRand.random(), startColor);
34064
34081
  if (this._renderer.engine.settings.colorSpace === ColorSpace.Linear) {
34065
34082
  startColor.toLinear(startColor);
34066
34083
  }
34067
- instanceVertices[offset + 8] = startColor.r;
34068
- instanceVertices[offset + 9] = startColor.g;
34069
- instanceVertices[offset + 10] = startColor.b;
34070
- instanceVertices[offset + 11] = startColor.a;
34084
+ startColor.copyToArray(instanceVertices, offset + 8);
34085
+ var duration = this.main.duration;
34086
+ var normalizedEmitAge = playTime % duration / duration;
34071
34087
  // Start size
34072
34088
  var startSizeRand = main._startSizeRand;
34073
34089
  if (main.startSize3D) {
34074
- instanceVertices[offset + 12] = main.startSizeX.evaluate(undefined, startSizeRand.random());
34075
- instanceVertices[offset + 13] = main.startSizeY.evaluate(undefined, startSizeRand.random());
34076
- instanceVertices[offset + 14] = main.startSizeZ.evaluate(undefined, startSizeRand.random());
34090
+ instanceVertices[offset + 12] = main.startSizeX.evaluate(normalizedEmitAge, startSizeRand.random());
34091
+ instanceVertices[offset + 13] = main.startSizeY.evaluate(normalizedEmitAge, startSizeRand.random());
34092
+ instanceVertices[offset + 14] = main.startSizeZ.evaluate(normalizedEmitAge, startSizeRand.random());
34077
34093
  } else {
34078
- var size = main.startSize.evaluate(undefined, startSizeRand.random());
34094
+ var size = main.startSize.evaluate(normalizedEmitAge, startSizeRand.random());
34079
34095
  instanceVertices[offset + 12] = size;
34080
34096
  instanceVertices[offset + 13] = size;
34081
34097
  instanceVertices[offset + 14] = size;
@@ -34128,14 +34144,9 @@ __decorate([
34128
34144
  }
34129
34145
  if (this.main.simulationSpace === ParticleSimulationSpace.World) {
34130
34146
  // Simulation world position
34131
- instanceVertices[offset + 27] = pos.x;
34132
- instanceVertices[offset + 28] = pos.y;
34133
- instanceVertices[offset + 29] = pos.z;
34147
+ pos.copyToArray(instanceVertices, offset + 27);
34134
34148
  // Simulation world position
34135
- instanceVertices[offset + 30] = rot.x;
34136
- instanceVertices[offset + 31] = rot.y;
34137
- instanceVertices[offset + 32] = rot.z;
34138
- instanceVertices[offset + 33] = rot.w;
34149
+ rot.copyToArray(instanceVertices, offset + 30);
34139
34150
  }
34140
34151
  // Simulation UV
34141
34152
  if (textureSheetAnimation.enabled) {
@@ -34505,7 +34516,7 @@ __decorate([
34505
34516
  * @inheritdoc
34506
34517
  */ _proto.clone = function clone() {
34507
34518
  var dest = new ParticleMaterial(this._engine);
34508
- this.cloneTo(dest);
34519
+ this._cloneToAndModifyName(dest);
34509
34520
  return dest;
34510
34521
  };
34511
34522
  _create_class(ParticleMaterial, [