@galacean/engine 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/browser.js CHANGED
@@ -15227,7 +15227,7 @@
15227
15227
  };
15228
15228
  _proto._createInstanceMaterial = function _createInstanceMaterial(material, index) {
15229
15229
  var insMaterial = material.clone();
15230
- insMaterial.name = insMaterial.name + "(Instance)";
15230
+ insMaterial.name = material.name + "(Instance)";
15231
15231
  this._addResourceReferCount(material, -1);
15232
15232
  this._addResourceReferCount(insMaterial, 1);
15233
15233
  this._materialsInstanced[index] = true;
@@ -17191,6 +17191,7 @@
17191
17191
  _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.
17192
17192
  , _this._shaderData = new ShaderData(ShaderDataGroup.Material);
17193
17193
  _this.shader = shader;
17194
+ _this.name = shader.name;
17194
17195
  return _this;
17195
17196
  }
17196
17197
  var _proto = Material.prototype;
@@ -17198,7 +17199,7 @@
17198
17199
  * Clone and return the instance.
17199
17200
  */ _proto.clone = function clone() {
17200
17201
  var dest = new Material(this._engine, this.shader);
17201
- this.cloneTo(dest);
17202
+ this._cloneToAndModifyName(dest);
17202
17203
  return dest;
17203
17204
  };
17204
17205
  /**
@@ -17215,6 +17216,10 @@
17215
17216
  this.shaderData._addReferCount(value);
17216
17217
  this._shader._addReferCount(value);
17217
17218
  };
17219
+ _proto._cloneToAndModifyName = function _cloneToAndModifyName(target) {
17220
+ this.cloneTo(target);
17221
+ target.name = this.name + "(Clone)";
17222
+ };
17218
17223
  /**
17219
17224
  * @override
17220
17225
  */ _proto._onDestroy = function _onDestroy() {
@@ -17369,7 +17374,7 @@
17369
17374
  * Clone and return the instance.
17370
17375
  */ _proto.clone = function clone() {
17371
17376
  var dest = new BaseMaterial(this._engine, this.shader);
17372
- this.cloneTo(dest);
17377
+ this._cloneToAndModifyName(dest);
17373
17378
  return dest;
17374
17379
  };
17375
17380
  /**
@@ -17550,7 +17555,7 @@
17550
17555
  var _proto = BlinnPhongMaterial.prototype;
17551
17556
  _proto.clone = function clone() {
17552
17557
  var dest = new BlinnPhongMaterial(this._engine);
17553
- this.cloneTo(dest);
17558
+ this._cloneToAndModifyName(dest);
17554
17559
  return dest;
17555
17560
  };
17556
17561
  _create_class$2(BlinnPhongMaterial, [
@@ -18006,7 +18011,7 @@
18006
18011
  * @inheritdoc
18007
18012
  */ _proto.clone = function clone() {
18008
18013
  var dest = new PBRMaterial(this._engine);
18009
- this.cloneTo(dest);
18014
+ this._cloneToAndModifyName(dest);
18010
18015
  return dest;
18011
18016
  };
18012
18017
  _proto._onIridescenceRangeChanged = function _onIridescenceRangeChanged() {
@@ -18471,7 +18476,7 @@
18471
18476
  * @inheritdoc
18472
18477
  */ _proto.clone = function clone() {
18473
18478
  var dest = new PBRSpecularMaterial(this._engine);
18474
- this.cloneTo(dest);
18479
+ this._cloneToAndModifyName(dest);
18475
18480
  return dest;
18476
18481
  };
18477
18482
  _create_class$2(PBRSpecularMaterial, [
@@ -18543,7 +18548,7 @@
18543
18548
  * @inheritdoc
18544
18549
  */ _proto.clone = function clone() {
18545
18550
  var dest = new UnlitMaterial(this._engine);
18546
- this.cloneTo(dest);
18551
+ this._cloneToAndModifyName(dest);
18547
18552
  return dest;
18548
18553
  };
18549
18554
  _create_class$2(UnlitMaterial, [
@@ -22175,7 +22180,7 @@
22175
22180
  }
22176
22181
  var _this;
22177
22182
  _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, _this._invModelMatrix = new Matrix();
22178
- _this.name = name;
22183
+ _this.name = name != null ? name : "Entity";
22179
22184
  for(var i = 0, n = components.length; i < n; i++){
22180
22185
  _this.addComponent(components[i]);
22181
22186
  }
@@ -22256,11 +22261,11 @@
22256
22261
  child = indexOrChild;
22257
22262
  }
22258
22263
  if (child._isRoot) {
22259
- child._scene._removeFromEntityList(child);
22264
+ var oldScene = child._scene;
22265
+ Entity._removeFromChildren(oldScene._rootEntities, child);
22260
22266
  child._isRoot = false;
22261
22267
  this._addToChildrenList(index, child);
22262
22268
  child._parent = this;
22263
- var oldScene = child._scene;
22264
22269
  var newScene = this._scene;
22265
22270
  var inActiveChangeFlag = ActiveChangeFlag.None;
22266
22271
  if (!this._isActiveInHierarchy) {
@@ -22465,14 +22470,8 @@
22465
22470
  */ _proto._removeFromParent = function _removeFromParent() {
22466
22471
  var oldParent = this._parent;
22467
22472
  if (oldParent != null) {
22468
- var oldSibling = oldParent._children;
22469
- var index = this._siblingIndex;
22470
- oldSibling.splice(index, 1);
22471
- for(var n = oldSibling.length; index < n; index++){
22472
- oldSibling[index]._siblingIndex--;
22473
- }
22473
+ Entity._removeFromChildren(oldParent._children, this);
22474
22474
  this._parent = null;
22475
- this._siblingIndex = -1;
22476
22475
  this._dispatchModify(EntityModifyFlags.Child, oldParent);
22477
22476
  }
22478
22477
  };
@@ -22518,21 +22517,7 @@
22518
22517
  (_this__modifyFlagManager = this._modifyFlagManager) == null ? void 0 : _this__modifyFlagManager.dispatch(flag, param);
22519
22518
  };
22520
22519
  _proto._addToChildrenList = function _addToChildrenList(index, child) {
22521
- var children = this._children;
22522
- var childCount = children.length;
22523
- if (index === undefined) {
22524
- child._siblingIndex = childCount;
22525
- children.push(child);
22526
- } else {
22527
- if (index < 0 || index > childCount) {
22528
- throw "The index " + index + " is out of child list bounds " + childCount;
22529
- }
22530
- child._siblingIndex = index;
22531
- children.splice(index, 0, child);
22532
- for(var i = index + 1, n = childCount + 1; i < n; i++){
22533
- children[i]._siblingIndex++;
22534
- }
22535
- }
22520
+ Entity._addToChildren(this._children, child, index);
22536
22521
  this._dispatchModify(EntityModifyFlags.Child, this);
22537
22522
  };
22538
22523
  _proto._setParent = function _setParent(parent, siblingIndex) {
@@ -22711,6 +22696,39 @@
22711
22696
  }
22712
22697
  return entity;
22713
22698
  };
22699
+ /**
22700
+ * @internal
22701
+ */ Entity._removeFromChildren = function _removeFromChildren(children, entity) {
22702
+ var count = children.length - 1;
22703
+ for(var i = entity._siblingIndex; i < count; i++){
22704
+ var child = children[i + 1];
22705
+ children[i] = child;
22706
+ child._siblingIndex = i;
22707
+ }
22708
+ children.length = count;
22709
+ entity._siblingIndex = -1;
22710
+ };
22711
+ /**
22712
+ * @internal
22713
+ */ Entity._addToChildren = function _addToChildren(children, entity, index) {
22714
+ var childCount = children.length;
22715
+ children.length = childCount + 1;
22716
+ if (index === undefined) {
22717
+ children[childCount] = entity;
22718
+ entity._siblingIndex = childCount;
22719
+ } else {
22720
+ if (index < 0 || index > childCount) {
22721
+ throw "The index " + index + " is out of child list bounds " + childCount;
22722
+ }
22723
+ for(var i = childCount; i > index; i--){
22724
+ var swapChild = children[i - 1];
22725
+ swapChild._siblingIndex = i;
22726
+ children[i] = swapChild;
22727
+ }
22728
+ entity._siblingIndex = index;
22729
+ children[index] = entity;
22730
+ }
22731
+ };
22714
22732
  _create_class$2(Entity, [
22715
22733
  {
22716
22734
  key: "transform",
@@ -31671,11 +31689,11 @@
31671
31689
  var oldScene = entity._scene;
31672
31690
  if (oldScene !== this) {
31673
31691
  if (oldScene && isRoot) {
31674
- oldScene._removeFromEntityList(entity);
31692
+ Entity._removeFromChildren(oldScene._rootEntities, entity);
31675
31693
  }
31676
- this._addToRootEntityList(index, entity);
31694
+ Entity._addToChildren(this._rootEntities, entity, index);
31677
31695
  } else if (!isRoot) {
31678
- this._addToRootEntityList(index, entity);
31696
+ Entity._addToChildren(this._rootEntities, entity, index);
31679
31697
  }
31680
31698
  // Process entity active/inActive
31681
31699
  var inActiveChangeFlag = ActiveChangeFlag.None;
@@ -31702,7 +31720,7 @@
31702
31720
  * @param entity - The root entity to remove
31703
31721
  */ _proto.removeRootEntity = function removeRootEntity(entity) {
31704
31722
  if (entity._isRoot && entity._scene == this) {
31705
- this._removeFromEntityList(entity);
31723
+ Entity._removeFromChildren(this._rootEntities, entity);
31706
31724
  entity._isRoot = false;
31707
31725
  var inActiveChangeFlag = ActiveChangeFlag.None;
31708
31726
  this._isActiveInEngine && entity._isActiveInHierarchy && (inActiveChangeFlag |= ActiveChangeFlag.Hierarchy);
@@ -31801,17 +31819,6 @@
31801
31819
  };
31802
31820
  /**
31803
31821
  * @internal
31804
- */ _proto._removeFromEntityList = function _removeFromEntityList(entity) {
31805
- var rootEntities = this._rootEntities;
31806
- var index = entity._siblingIndex;
31807
- rootEntities.splice(index, 1);
31808
- for(var n = rootEntities.length; index < n; index++){
31809
- rootEntities[index]._siblingIndex--;
31810
- }
31811
- entity._siblingIndex = -1;
31812
- };
31813
- /**
31814
- * @internal
31815
31822
  */ _proto._onDestroy = function _onDestroy() {
31816
31823
  EngineObject.prototype._onDestroy.call(this);
31817
31824
  // Remove from sceneManager
@@ -31828,23 +31835,6 @@
31828
31835
  var allCreatedScenes = sceneManager._allCreatedScenes;
31829
31836
  allCreatedScenes.splice(allCreatedScenes.indexOf(this), 1);
31830
31837
  };
31831
- _proto._addToRootEntityList = function _addToRootEntityList(index, rootEntity) {
31832
- var rootEntities = this._rootEntities;
31833
- var rootEntityCount = rootEntities.length;
31834
- if (index === undefined) {
31835
- rootEntity._siblingIndex = rootEntityCount;
31836
- rootEntities.push(rootEntity);
31837
- } else {
31838
- if (index < 0 || index > rootEntityCount) {
31839
- throw "The index " + index + " is out of child list bounds " + rootEntityCount;
31840
- }
31841
- rootEntity._siblingIndex = index;
31842
- rootEntities.splice(index, 0, rootEntity);
31843
- for(var i = index + 1, n = rootEntityCount + 1; i < n; i++){
31844
- rootEntities[i]._siblingIndex++;
31845
- }
31846
- }
31847
- };
31848
31838
  _proto._computeLinearFogParams = function _computeLinearFogParams(fogStart, fogEnd) {
31849
31839
  var fogRange = fogEnd - fogStart;
31850
31840
  var fogParams = this._fogParams;
@@ -35841,7 +35831,7 @@
35841
35831
  var _proto = SkyBoxMaterial.prototype;
35842
35832
  _proto.clone = function clone() {
35843
35833
  var dest = new SkyBoxMaterial(this._engine);
35844
- this.cloneTo(dest);
35834
+ this._cloneToAndModifyName(dest);
35845
35835
  return dest;
35846
35836
  };
35847
35837
  _create_class$2(SkyBoxMaterial, [
@@ -35946,7 +35936,7 @@
35946
35936
  * @inheritDoc
35947
35937
  */ _proto.clone = function clone() {
35948
35938
  var dest = new SkyProceduralMaterial(this._engine);
35949
- this.cloneTo(dest);
35939
+ this._cloneToAndModifyName(dest);
35950
35940
  return dest;
35951
35941
  };
35952
35942
  _create_class$2(SkyProceduralMaterial, [
@@ -36835,6 +36825,13 @@
36835
36825
  return this.constant;
36836
36826
  case ParticleCurveMode.TwoConstants:
36837
36827
  return this.constantMin + (this.constantMax - this.constantMin) * lerpFactor;
36828
+ case ParticleCurveMode.Curve:
36829
+ var _this_curve;
36830
+ return (_this_curve = this.curve) == null ? void 0 : _this_curve._evaluate(time);
36831
+ case ParticleCurveMode.TwoCurves:
36832
+ var _this_curveMin, _this_curveMax;
36833
+ var min = (_this_curveMin = this.curveMin) == null ? void 0 : _this_curveMin._evaluate(time);
36834
+ return min + (((_this_curveMax = this.curveMax) == null ? void 0 : _this_curveMax._evaluate(time)) - min) * lerpFactor;
36838
36835
  }
36839
36836
  };
36840
36837
  /**
@@ -37668,9 +37665,10 @@
37668
37665
  * Remove a key from the curve.
37669
37666
  * @param index - The remove key index
37670
37667
  */ _proto.removeKey = function removeKey(index) {
37671
- this._keys.splice(index, 1);
37668
+ var keys = this._keys;
37669
+ var removeKey = keys[index];
37670
+ keys.splice(index, 1);
37672
37671
  this._typeArrayDirty = true;
37673
- var removeKey = this._keys[index];
37674
37672
  removeKey._unRegisterOnValueChanged(this._updateDispatch);
37675
37673
  this._updateDispatch();
37676
37674
  };
@@ -37686,6 +37684,29 @@
37686
37684
  };
37687
37685
  /**
37688
37686
  * @internal
37687
+ */ _proto._evaluate = function _evaluate(normalizedAge) {
37688
+ var keys = this.keys;
37689
+ var length = keys.length;
37690
+ for(var i = 0; i < length; i++){
37691
+ var key = keys[i];
37692
+ var time = key.time;
37693
+ if (normalizedAge <= time) {
37694
+ if (i === 0) {
37695
+ // Small than first key
37696
+ return key.value;
37697
+ } else {
37698
+ // Between two keys
37699
+ var _keys_ = keys[i - 1], lastTime = _keys_.time, lastValue = _keys_.value;
37700
+ var age = (normalizedAge - lastTime) / (time - lastTime);
37701
+ return lastValue + (key.value - lastValue) * age;
37702
+ }
37703
+ }
37704
+ }
37705
+ // Large than last key
37706
+ return keys[length - 1].value;
37707
+ };
37708
+ /**
37709
+ * @internal
37689
37710
  */ _proto._getTypeArray = function _getTypeArray() {
37690
37711
  var typeArray = this._typeArray || (this._typeArray = new Float32Array(4 * 2));
37691
37712
  if (this._typeArrayDirty) {
@@ -38293,7 +38314,7 @@
38293
38314
  };
38294
38315
  /**
38295
38316
  * @internal
38296
- */ _proto._emit = function _emit(time, count) {
38317
+ */ _proto._emit = function _emit(playTime, count) {
38297
38318
  if (this.emission.enabled) {
38298
38319
  // Wait the existing particles to be retired
38299
38320
  var notRetireParticleCount = this._getNotRetiredParticleCount();
@@ -38306,7 +38327,7 @@
38306
38327
  var shape = this.emission.shape;
38307
38328
  for(var i = 0; i < count; i++){
38308
38329
  if (shape == null ? void 0 : shape.enabled) {
38309
- shape._generatePositionAndDirection(this.emission._shapeRand, time, position, direction);
38330
+ shape._generatePositionAndDirection(this.emission._shapeRand, playTime, position, direction);
38310
38331
  var positionScale = this.main._getPositionScale();
38311
38332
  position.multiply(positionScale);
38312
38333
  direction.normalize().multiply(positionScale);
@@ -38314,7 +38335,7 @@
38314
38335
  position.set(0, 0, 0);
38315
38336
  direction.set(0, 0, -1);
38316
38337
  }
38317
- this._addNewParticle(position, direction, transform, time);
38338
+ this._addNewParticle(position, direction, transform, playTime);
38318
38339
  }
38319
38340
  }
38320
38341
  };
@@ -38629,7 +38650,7 @@
38629
38650
  this._transformedBoundsArray[previousFreeElement * ParticleBufferUtils.boundsFloatStride + boundsTimeOffset] = this._playTime;
38630
38651
  }
38631
38652
  };
38632
- _proto._addNewParticle = function _addNewParticle(position, direction, transform, time) {
38653
+ _proto._addNewParticle = function _addNewParticle(position, direction, transform, playTime) {
38633
38654
  var firstFreeElement = this._firstFreeElement;
38634
38655
  var nextFreeElement = firstFreeElement + 1;
38635
38656
  if (nextFreeElement >= this._currentParticleCount) {
@@ -38659,35 +38680,30 @@
38659
38680
  var instanceVertices = this._instanceVertices;
38660
38681
  var offset = firstFreeElement * ParticleBufferUtils.instanceVertexFloatStride;
38661
38682
  // Position
38662
- instanceVertices[offset] = position.x;
38663
- instanceVertices[offset + 1] = position.y;
38664
- instanceVertices[offset + 2] = position.z;
38683
+ position.copyToArray(instanceVertices, offset);
38665
38684
  // Start life time
38666
38685
  instanceVertices[offset + ParticleBufferUtils.startLifeTimeOffset] = main.startLifetime.evaluate(undefined, main._startLifeTimeRand.random());
38667
38686
  // Direction
38668
- instanceVertices[offset + 4] = direction.x;
38669
- instanceVertices[offset + 5] = direction.y;
38670
- instanceVertices[offset + 6] = direction.z;
38687
+ direction.copyToArray(instanceVertices, offset + 4);
38671
38688
  // Time
38672
- instanceVertices[offset + ParticleBufferUtils.timeOffset] = time;
38689
+ instanceVertices[offset + ParticleBufferUtils.timeOffset] = playTime;
38673
38690
  // Color
38674
38691
  var startColor = ParticleGenerator._tempColor0;
38675
38692
  main.startColor.evaluate(undefined, main._startColorRand.random(), startColor);
38676
38693
  if (this._renderer.engine.settings.colorSpace === ColorSpace.Linear) {
38677
38694
  startColor.toLinear(startColor);
38678
38695
  }
38679
- instanceVertices[offset + 8] = startColor.r;
38680
- instanceVertices[offset + 9] = startColor.g;
38681
- instanceVertices[offset + 10] = startColor.b;
38682
- instanceVertices[offset + 11] = startColor.a;
38696
+ startColor.copyToArray(instanceVertices, offset + 8);
38697
+ var duration = this.main.duration;
38698
+ var normalizedEmitAge = playTime % duration / duration;
38683
38699
  // Start size
38684
38700
  var startSizeRand = main._startSizeRand;
38685
38701
  if (main.startSize3D) {
38686
- instanceVertices[offset + 12] = main.startSizeX.evaluate(undefined, startSizeRand.random());
38687
- instanceVertices[offset + 13] = main.startSizeY.evaluate(undefined, startSizeRand.random());
38688
- instanceVertices[offset + 14] = main.startSizeZ.evaluate(undefined, startSizeRand.random());
38702
+ instanceVertices[offset + 12] = main.startSizeX.evaluate(normalizedEmitAge, startSizeRand.random());
38703
+ instanceVertices[offset + 13] = main.startSizeY.evaluate(normalizedEmitAge, startSizeRand.random());
38704
+ instanceVertices[offset + 14] = main.startSizeZ.evaluate(normalizedEmitAge, startSizeRand.random());
38689
38705
  } else {
38690
- var size = main.startSize.evaluate(undefined, startSizeRand.random());
38706
+ var size = main.startSize.evaluate(normalizedEmitAge, startSizeRand.random());
38691
38707
  instanceVertices[offset + 12] = size;
38692
38708
  instanceVertices[offset + 13] = size;
38693
38709
  instanceVertices[offset + 14] = size;
@@ -38740,14 +38756,9 @@
38740
38756
  }
38741
38757
  if (this.main.simulationSpace === ParticleSimulationSpace.World) {
38742
38758
  // Simulation world position
38743
- instanceVertices[offset + 27] = pos.x;
38744
- instanceVertices[offset + 28] = pos.y;
38745
- instanceVertices[offset + 29] = pos.z;
38759
+ pos.copyToArray(instanceVertices, offset + 27);
38746
38760
  // Simulation world position
38747
- instanceVertices[offset + 30] = rot.x;
38748
- instanceVertices[offset + 31] = rot.y;
38749
- instanceVertices[offset + 32] = rot.z;
38750
- instanceVertices[offset + 33] = rot.w;
38761
+ rot.copyToArray(instanceVertices, offset + 30);
38751
38762
  }
38752
38763
  // Simulation UV
38753
38764
  if (textureSheetAnimation.enabled) {
@@ -39116,7 +39127,7 @@
39116
39127
  * @inheritdoc
39117
39128
  */ _proto.clone = function clone() {
39118
39129
  var dest = new ParticleMaterial(this._engine);
39119
- this.cloneTo(dest);
39130
+ this._cloneToAndModifyName(dest);
39120
39131
  return dest;
39121
39132
  };
39122
39133
  _create_class$2(ParticleMaterial, [
@@ -47130,7 +47141,7 @@
47130
47141
  */ GLTFMaterialParser._checkOtherTextureTransform = function _checkOtherTextureTransform(texture, textureName) {
47131
47142
  var _texture_extensions;
47132
47143
  if ((_texture_extensions = texture.extensions) == null ? void 0 : _texture_extensions.KHR_texture_transform) {
47133
- Logger.warn("" + textureName + " texture always use the KHR_texture_transform of the base texture.");
47144
+ Logger.warn("" + textureName + " texture ignore KHR_texture_transform extension.");
47134
47145
  }
47135
47146
  };
47136
47147
  /**
@@ -50042,7 +50053,7 @@
50042
50053
  ], EXT_texture_webp);
50043
50054
 
50044
50055
  //@ts-ignore
50045
- var version = "1.4.9";
50056
+ var version = "1.4.10";
50046
50057
  console.log("Galacean Engine Version: " + version);
50047
50058
  for(var key in CoreObjects){
50048
50059
  Loader.registerClass(key, CoreObjects[key]);