@galacean/engine 1.4.8 → 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
@@ -13733,6 +13733,7 @@
13733
13733
  var blitMaterial = material || basicResources.blitMaterial;
13734
13734
  var rhi = engine._hardwareRenderer;
13735
13735
  var context = engine._renderContext;
13736
+ var camera = context.camera;
13736
13737
  // We not use projection matrix when blit, but we must modify flipProjection to make front face correct
13737
13738
  context.flipProjection = !!destination;
13738
13739
  rhi.activeRenderTarget(destination, viewport, context.flipProjection, 0);
@@ -13744,10 +13745,12 @@
13744
13745
  rendererShaderData.setVector4(Blitter._sourceScaleOffsetProperty, sourceScaleOffset != null ? sourceScaleOffset : Blitter._defaultScaleOffset);
13745
13746
  var pass = blitMaterial.shader.subShaders[0].passes[passIndex];
13746
13747
  var compileMacros = Shader._compileMacros;
13747
- ShaderMacroCollection.unionCollection(context.camera._globalShaderMacro, blitMaterial.shaderData._macroCollection, compileMacros);
13748
+ ShaderMacroCollection.unionCollection(camera._globalShaderMacro, blitMaterial.shaderData._macroCollection, compileMacros);
13748
13749
  var program = pass._getShaderProgram(engine, compileMacros);
13749
13750
  program.bind();
13750
13751
  program.groupingOtherUniformBlock();
13752
+ program.uploadAll(program.sceneUniformBlock, camera.scene.shaderData);
13753
+ program.uploadAll(program.cameraUniformBlock, camera.shaderData);
13751
13754
  program.uploadAll(program.rendererUniformBlock, rendererShaderData);
13752
13755
  program.uploadAll(program.materialUniformBlock, blitMaterial.shaderData);
13753
13756
  program.uploadUnGroupTextures();
@@ -15224,7 +15227,7 @@
15224
15227
  };
15225
15228
  _proto._createInstanceMaterial = function _createInstanceMaterial(material, index) {
15226
15229
  var insMaterial = material.clone();
15227
- insMaterial.name = insMaterial.name + "(Instance)";
15230
+ insMaterial.name = material.name + "(Instance)";
15228
15231
  this._addResourceReferCount(material, -1);
15229
15232
  this._addResourceReferCount(insMaterial, 1);
15230
15233
  this._materialsInstanced[index] = true;
@@ -17188,6 +17191,7 @@
17188
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.
17189
17192
  , _this._shaderData = new ShaderData(ShaderDataGroup.Material);
17190
17193
  _this.shader = shader;
17194
+ _this.name = shader.name;
17191
17195
  return _this;
17192
17196
  }
17193
17197
  var _proto = Material.prototype;
@@ -17195,7 +17199,7 @@
17195
17199
  * Clone and return the instance.
17196
17200
  */ _proto.clone = function clone() {
17197
17201
  var dest = new Material(this._engine, this.shader);
17198
- this.cloneTo(dest);
17202
+ this._cloneToAndModifyName(dest);
17199
17203
  return dest;
17200
17204
  };
17201
17205
  /**
@@ -17212,6 +17216,10 @@
17212
17216
  this.shaderData._addReferCount(value);
17213
17217
  this._shader._addReferCount(value);
17214
17218
  };
17219
+ _proto._cloneToAndModifyName = function _cloneToAndModifyName(target) {
17220
+ this.cloneTo(target);
17221
+ target.name = this.name + "(Clone)";
17222
+ };
17215
17223
  /**
17216
17224
  * @override
17217
17225
  */ _proto._onDestroy = function _onDestroy() {
@@ -17366,7 +17374,7 @@
17366
17374
  * Clone and return the instance.
17367
17375
  */ _proto.clone = function clone() {
17368
17376
  var dest = new BaseMaterial(this._engine, this.shader);
17369
- this.cloneTo(dest);
17377
+ this._cloneToAndModifyName(dest);
17370
17378
  return dest;
17371
17379
  };
17372
17380
  /**
@@ -17547,7 +17555,7 @@
17547
17555
  var _proto = BlinnPhongMaterial.prototype;
17548
17556
  _proto.clone = function clone() {
17549
17557
  var dest = new BlinnPhongMaterial(this._engine);
17550
- this.cloneTo(dest);
17558
+ this._cloneToAndModifyName(dest);
17551
17559
  return dest;
17552
17560
  };
17553
17561
  _create_class$2(BlinnPhongMaterial, [
@@ -18003,7 +18011,7 @@
18003
18011
  * @inheritdoc
18004
18012
  */ _proto.clone = function clone() {
18005
18013
  var dest = new PBRMaterial(this._engine);
18006
- this.cloneTo(dest);
18014
+ this._cloneToAndModifyName(dest);
18007
18015
  return dest;
18008
18016
  };
18009
18017
  _proto._onIridescenceRangeChanged = function _onIridescenceRangeChanged() {
@@ -18468,7 +18476,7 @@
18468
18476
  * @inheritdoc
18469
18477
  */ _proto.clone = function clone() {
18470
18478
  var dest = new PBRSpecularMaterial(this._engine);
18471
- this.cloneTo(dest);
18479
+ this._cloneToAndModifyName(dest);
18472
18480
  return dest;
18473
18481
  };
18474
18482
  _create_class$2(PBRSpecularMaterial, [
@@ -18540,7 +18548,7 @@
18540
18548
  * @inheritdoc
18541
18549
  */ _proto.clone = function clone() {
18542
18550
  var dest = new UnlitMaterial(this._engine);
18543
- this.cloneTo(dest);
18551
+ this._cloneToAndModifyName(dest);
18544
18552
  return dest;
18545
18553
  };
18546
18554
  _create_class$2(UnlitMaterial, [
@@ -22172,7 +22180,7 @@
22172
22180
  }
22173
22181
  var _this;
22174
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();
22175
- _this.name = name;
22183
+ _this.name = name != null ? name : "Entity";
22176
22184
  for(var i = 0, n = components.length; i < n; i++){
22177
22185
  _this.addComponent(components[i]);
22178
22186
  }
@@ -22253,11 +22261,11 @@
22253
22261
  child = indexOrChild;
22254
22262
  }
22255
22263
  if (child._isRoot) {
22256
- child._scene._removeFromEntityList(child);
22264
+ var oldScene = child._scene;
22265
+ Entity._removeFromChildren(oldScene._rootEntities, child);
22257
22266
  child._isRoot = false;
22258
22267
  this._addToChildrenList(index, child);
22259
22268
  child._parent = this;
22260
- var oldScene = child._scene;
22261
22269
  var newScene = this._scene;
22262
22270
  var inActiveChangeFlag = ActiveChangeFlag.None;
22263
22271
  if (!this._isActiveInHierarchy) {
@@ -22462,14 +22470,8 @@
22462
22470
  */ _proto._removeFromParent = function _removeFromParent() {
22463
22471
  var oldParent = this._parent;
22464
22472
  if (oldParent != null) {
22465
- var oldSibling = oldParent._children;
22466
- var index = this._siblingIndex;
22467
- oldSibling.splice(index, 1);
22468
- for(var n = oldSibling.length; index < n; index++){
22469
- oldSibling[index]._siblingIndex--;
22470
- }
22473
+ Entity._removeFromChildren(oldParent._children, this);
22471
22474
  this._parent = null;
22472
- this._siblingIndex = -1;
22473
22475
  this._dispatchModify(EntityModifyFlags.Child, oldParent);
22474
22476
  }
22475
22477
  };
@@ -22515,21 +22517,7 @@
22515
22517
  (_this__modifyFlagManager = this._modifyFlagManager) == null ? void 0 : _this__modifyFlagManager.dispatch(flag, param);
22516
22518
  };
22517
22519
  _proto._addToChildrenList = function _addToChildrenList(index, child) {
22518
- var children = this._children;
22519
- var childCount = children.length;
22520
- if (index === undefined) {
22521
- child._siblingIndex = childCount;
22522
- children.push(child);
22523
- } else {
22524
- if (index < 0 || index > childCount) {
22525
- throw "The index " + index + " is out of child list bounds " + childCount;
22526
- }
22527
- child._siblingIndex = index;
22528
- children.splice(index, 0, child);
22529
- for(var i = index + 1, n = childCount + 1; i < n; i++){
22530
- children[i]._siblingIndex++;
22531
- }
22532
- }
22520
+ Entity._addToChildren(this._children, child, index);
22533
22521
  this._dispatchModify(EntityModifyFlags.Child, this);
22534
22522
  };
22535
22523
  _proto._setParent = function _setParent(parent, siblingIndex) {
@@ -22708,6 +22696,39 @@
22708
22696
  }
22709
22697
  return entity;
22710
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
+ };
22711
22732
  _create_class$2(Entity, [
22712
22733
  {
22713
22734
  key: "transform",
@@ -29172,7 +29193,7 @@
29172
29193
  var blinnPhongFs = "#define GLSLIFY 1\n#include <common>\n#include <camera_declare>\n\n#include <uv_share>\n#include <normal_share>\n#include <color_share>\n#include <worldpos_share>\n\n#include <light_frag_define>\n#include <ShadowFragmentDeclaration>\n#include <mobile_material_frag>\n\n#include <FogFragmentDeclaration>\n#include <normal_get>\n\nvoid main() {\n\n #include <begin_mobile_frag>\n #include <begin_viewdir_frag>\n #include <mobile_blinnphong_frag>\n\n gl_FragColor = emission + ambient + diffuse + specular;\n\n #ifdef MATERIAL_IS_TRANSPARENT\n gl_FragColor.a = diffuse.a;\n #else\n gl_FragColor.a = 1.0;\n #endif\n\n #include <FogFragment>\n\n #ifndef ENGINE_IS_COLORSPACE_GAMMA\n gl_FragColor = linearToGamma(gl_FragColor);\n #endif\n}\n"; // eslint-disable-line
29173
29194
  var blinnPhongVs = "#define GLSLIFY 1\n#include <common>\n#include <common_vert>\n#include <blendShape_input>\n#include <uv_share>\n#include <color_share>\n#include <normal_share>\n#include <worldpos_share>\n\n#include <ShadowVertexDeclaration>\n#include <FogVertexDeclaration>\n\nvoid main() {\n\n #include <begin_position_vert>\n #include <begin_normal_vert>\n #include <blendShape_vert>\n #include <skinning_vert>\n #include <uv_vert>\n #include <color_vert>\n #include <normal_vert>\n #include <worldpos_vert>\n #include <position_vert>\n\n #include <ShadowVertex>\n #include <FogVertex>\n}\n"; // eslint-disable-line
29174
29195
  var depthOnlyFs = "#define GLSLIFY 1\nvoid main() {\n}"; // eslint-disable-line
29175
- var depthOnlyVs = "#define GLSLIFY 1\n#include <common>\n#include <common_vert>\n#include <blendShape_input>\nuniform mat4 camera_VPMat;\n\nvoid main() {\n\n #include <begin_position_vert>\n #include <blendShape_vert>\n #include <skinning_vert>\n #include <position_vert>\n\n}\n"; // eslint-disable-line
29196
+ var depthOnlyVs = "#define GLSLIFY 1\n#define MATERIAL_OMIT_NORMAL\n#include <common>\n#include <common_vert>\n#include <blendShape_input>\nuniform mat4 camera_VPMat;\n\nvoid main() {\n\n #include <begin_position_vert>\n #include <blendShape_vert>\n #include <skinning_vert>\n #include <position_vert>\n\n}\n"; // eslint-disable-line
29176
29197
  var particleFs = "#define GLSLIFY 1\n#include <common>\n\nvarying vec4 v_Color;\nvarying vec2 v_TextureCoordinate;\nuniform sampler2D material_BaseTexture;\nuniform vec4 material_BaseColor;\n\n#ifdef RENDERER_MODE_MESH\n\tvarying vec4 v_MeshColor;\n#endif\n\nvoid main() {\n\tvec4 color = material_BaseColor * v_Color;\n\n\t#ifdef RENDERER_MODE_MESH\n\t\tcolor *= v_MeshColor;\n\t#endif\n\n\t#ifdef MATERIAL_HAS_BASETEXTURE\n\t\tvec4 textureColor = texture2D(material_BaseTexture,v_TextureCoordinate);\n\t\t#ifndef ENGINE_IS_COLORSPACE_GAMMA\n textureColor = gammaToLinear(textureColor);\n #endif\n\t\tcolor *= textureColor;\n\t#endif\n\tgl_FragColor = color; \n\n\t #ifndef ENGINE_IS_COLORSPACE_GAMMA\n gl_FragColor = linearToGamma(gl_FragColor);\n #endif\n}"; // eslint-disable-line
29177
29198
  var particleVs = "#define GLSLIFY 1\n#if defined(RENDERER_MODE_SPHERE_BILLBOARD) || defined(RENDERER_MODE_STRETCHED_BILLBOARD) || defined(RENDERER_MODE_HORIZONTAL_BILLBOARD) || defined(RENDERER_MODE_VERTICAL_BILLBOARD)\n attribute vec4 a_CornerTextureCoordinate;\n#endif\n\n#ifdef RENDERER_MODE_MESH\n attribute vec3 a_MeshPosition;\n attribute vec4 a_MeshColor;\n attribute vec2 a_MeshTextureCoordinate;\n varying vec4 v_MeshColor;\n#endif\n\nattribute vec4 a_ShapePositionStartLifeTime;\nattribute vec4 a_DirectionTime;\nattribute vec4 a_StartColor;\nattribute vec3 a_StartSize;\nattribute vec3 a_StartRotation0;\nattribute float a_StartSpeed;\n\n//#if defined(COLOR_OVER_LIFETIME) || defined(RENDERER_COL_RANDOM_GRADIENTS) || defined(RENDERER_SOL_RANDOM_CURVES) || defined(RENDERER_SOL_RANDOM_CURVES_SEPARATE) || defined(ROTATION_OVER_LIFE_TIME_RANDOM_CONSTANTS) || defined(ROTATION_OVER_LIFETIME_RANDOM_CURVES)\n attribute vec4 a_Random0;\n//#endif\n\n#if defined(RENDERER_TSA_FRAME_RANDOM_CURVES) || defined(RENDERER_VOL_RANDOM_CONSTANT) || defined(RENDERER_VOL_RANDOM_CURVE)\n attribute vec4 a_Random1; // x:texture sheet animation random\n#endif\n\nattribute vec3 a_SimulationWorldPosition;\nattribute vec4 a_SimulationWorldRotation;\n\nvarying vec4 v_Color;\n#ifdef MATERIAL_HAS_BASETEXTURE\n attribute vec4 a_SimulationUV;\n varying vec2 v_TextureCoordinate;\n#endif\n\nuniform float renderer_CurrentTime;\nuniform vec3 renderer_Gravity;\nuniform vec2 u_DragConstant;\nuniform vec3 renderer_WorldPosition;\nuniform vec4 renderer_WorldRotation;\nuniform bool renderer_ThreeDStartRotation;\nuniform int renderer_ScalingMode;\nuniform vec3 renderer_PositionScale;\nuniform vec3 renderer_SizeScale;\nuniform vec3 renderer_PivotOffset;\n\nuniform mat4 camera_ViewMat;\nuniform mat4 camera_ProjMat;\n\n#ifdef RENDERER_MODE_STRETCHED_BILLBOARD\n uniform vec3 camera_Position;\n#endif\nuniform vec3 camera_Forward; // TODO:只有几种广告牌模式需要用\nuniform vec3 camera_Up;\n\nuniform float renderer_StretchedBillboardLengthScale;\nuniform float renderer_StretchedBillboardSpeedScale;\nuniform int renderer_SimulationSpace;\n\n#include <particle_common>\n#include <velocity_over_lifetime_module>\n#include <color_over_lifetime_module>\n#include <size_over_lifetime_module>\n#include <rotation_over_lifetime_module>\n#include <texture_sheet_animation_module>\n\nvoid main() {\n float age = renderer_CurrentTime - a_DirectionTime.w;\n float normalizedAge = age / a_ShapePositionStartLifeTime.w;\n vec3 lifeVelocity;\n if (normalizedAge < 1.0) {\n vec3 startVelocity = a_DirectionTime.xyz * a_StartSpeed;\n #if defined(RENDERER_VOL_CONSTANT) || defined(RENDERER_VOL_CURVE) || defined(RENDERER_VOL_RANDOM_CONSTANT) || defined(RENDERER_VOL_RANDOM_CURVE)\n lifeVelocity = computeParticleLifeVelocity(normalizedAge); \n #endif\n \n vec3 gravityVelocity = renderer_Gravity * a_Random0.x * age;\n\n vec4 worldRotation;\n if (renderer_SimulationSpace == 0) {\n worldRotation = renderer_WorldRotation;\n } else {\n worldRotation = a_SimulationWorldRotation;\n }\n\n //drag\n vec3 dragData = a_DirectionTime.xyz * mix(u_DragConstant.x, u_DragConstant.y, a_Random0.x);\n vec3 center = computeParticlePosition(startVelocity, lifeVelocity, age, normalizedAge, gravityVelocity, worldRotation, dragData); //计算粒子位置\n\n #include <sphere_billboard>\n #include <stretched_billboard>\n #include <horizontal_billboard>\n #include <vertical_billboard>\n #include <particle_mesh>\n\n gl_Position = camera_ProjMat * camera_ViewMat * vec4(center, 1.0);\n v_Color = computeParticleColor(a_StartColor, normalizedAge);\n\n #ifdef MATERIAL_HAS_BASETEXTURE\n vec2 simulateUV;\n #if defined(RENDERER_MODE_SPHERE_BILLBOARD) || defined(RENDERER_MODE_STRETCHED_BILLBOARD) || defined(RENDERER_MODE_HORIZONTAL_BILLBOARD) || defined(RENDERER_MODE_VERTICAL_BILLBOARD)\n simulateUV = a_CornerTextureCoordinate.zw * a_SimulationUV.xy + a_SimulationUV.zw;\n v_TextureCoordinate = computeParticleUV(simulateUV, normalizedAge);\n #endif\n #ifdef RENDERER_MODE_MESH\n simulateUV = a_SimulationUV.xy + a_MeshTextureCoordinate * a_SimulationUV.zw;\n v_TextureCoordinate = computeParticleUV(simulateUV, normalizedAge);\n #endif\n #endif\n } else {\n\t gl_Position = vec4(2.0, 2.0, 2.0, 1.0); // Discard use out of X(-1,1),Y(-1,1),Z(0,1)\n }\n}\n"; // eslint-disable-line
29178
29199
  var pbrSpecularFs = "#define GLSLIFY 1\n#include <common>\n#include <camera_declare>\n\n#include <FogFragmentDeclaration>\n\n#include <uv_share>\n#include <normal_share>\n#include <color_share>\n#include <worldpos_share>\n\n#include <light_frag_define>\n\n#include <pbr_frag_define>\n#include <pbr_helper>\n\nvoid main() {\n #include <pbr_frag>\n #include <FogFragment>\n\n #ifndef ENGINE_IS_COLORSPACE_GAMMA\n gl_FragColor = linearToGamma(gl_FragColor);\n #endif\n}\n"; // eslint-disable-line
@@ -31668,11 +31689,11 @@
31668
31689
  var oldScene = entity._scene;
31669
31690
  if (oldScene !== this) {
31670
31691
  if (oldScene && isRoot) {
31671
- oldScene._removeFromEntityList(entity);
31692
+ Entity._removeFromChildren(oldScene._rootEntities, entity);
31672
31693
  }
31673
- this._addToRootEntityList(index, entity);
31694
+ Entity._addToChildren(this._rootEntities, entity, index);
31674
31695
  } else if (!isRoot) {
31675
- this._addToRootEntityList(index, entity);
31696
+ Entity._addToChildren(this._rootEntities, entity, index);
31676
31697
  }
31677
31698
  // Process entity active/inActive
31678
31699
  var inActiveChangeFlag = ActiveChangeFlag.None;
@@ -31699,7 +31720,7 @@
31699
31720
  * @param entity - The root entity to remove
31700
31721
  */ _proto.removeRootEntity = function removeRootEntity(entity) {
31701
31722
  if (entity._isRoot && entity._scene == this) {
31702
- this._removeFromEntityList(entity);
31723
+ Entity._removeFromChildren(this._rootEntities, entity);
31703
31724
  entity._isRoot = false;
31704
31725
  var inActiveChangeFlag = ActiveChangeFlag.None;
31705
31726
  this._isActiveInEngine && entity._isActiveInHierarchy && (inActiveChangeFlag |= ActiveChangeFlag.Hierarchy);
@@ -31798,17 +31819,6 @@
31798
31819
  };
31799
31820
  /**
31800
31821
  * @internal
31801
- */ _proto._removeFromEntityList = function _removeFromEntityList(entity) {
31802
- var rootEntities = this._rootEntities;
31803
- var index = entity._siblingIndex;
31804
- rootEntities.splice(index, 1);
31805
- for(var n = rootEntities.length; index < n; index++){
31806
- rootEntities[index]._siblingIndex--;
31807
- }
31808
- entity._siblingIndex = -1;
31809
- };
31810
- /**
31811
- * @internal
31812
31822
  */ _proto._onDestroy = function _onDestroy() {
31813
31823
  EngineObject.prototype._onDestroy.call(this);
31814
31824
  // Remove from sceneManager
@@ -31825,23 +31835,6 @@
31825
31835
  var allCreatedScenes = sceneManager._allCreatedScenes;
31826
31836
  allCreatedScenes.splice(allCreatedScenes.indexOf(this), 1);
31827
31837
  };
31828
- _proto._addToRootEntityList = function _addToRootEntityList(index, rootEntity) {
31829
- var rootEntities = this._rootEntities;
31830
- var rootEntityCount = rootEntities.length;
31831
- if (index === undefined) {
31832
- rootEntity._siblingIndex = rootEntityCount;
31833
- rootEntities.push(rootEntity);
31834
- } else {
31835
- if (index < 0 || index > rootEntityCount) {
31836
- throw "The index " + index + " is out of child list bounds " + rootEntityCount;
31837
- }
31838
- rootEntity._siblingIndex = index;
31839
- rootEntities.splice(index, 0, rootEntity);
31840
- for(var i = index + 1, n = rootEntityCount + 1; i < n; i++){
31841
- rootEntities[i]._siblingIndex++;
31842
- }
31843
- }
31844
- };
31845
31838
  _proto._computeLinearFogParams = function _computeLinearFogParams(fogStart, fogEnd) {
31846
31839
  var fogRange = fogEnd - fogStart;
31847
31840
  var fogParams = this._fogParams;
@@ -35838,7 +35831,7 @@
35838
35831
  var _proto = SkyBoxMaterial.prototype;
35839
35832
  _proto.clone = function clone() {
35840
35833
  var dest = new SkyBoxMaterial(this._engine);
35841
- this.cloneTo(dest);
35834
+ this._cloneToAndModifyName(dest);
35842
35835
  return dest;
35843
35836
  };
35844
35837
  _create_class$2(SkyBoxMaterial, [
@@ -35943,7 +35936,7 @@
35943
35936
  * @inheritDoc
35944
35937
  */ _proto.clone = function clone() {
35945
35938
  var dest = new SkyProceduralMaterial(this._engine);
35946
- this.cloneTo(dest);
35939
+ this._cloneToAndModifyName(dest);
35947
35940
  return dest;
35948
35941
  };
35949
35942
  _create_class$2(SkyProceduralMaterial, [
@@ -36832,6 +36825,13 @@
36832
36825
  return this.constant;
36833
36826
  case ParticleCurveMode.TwoConstants:
36834
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;
36835
36835
  }
36836
36836
  };
36837
36837
  /**
@@ -37665,9 +37665,10 @@
37665
37665
  * Remove a key from the curve.
37666
37666
  * @param index - The remove key index
37667
37667
  */ _proto.removeKey = function removeKey(index) {
37668
- this._keys.splice(index, 1);
37668
+ var keys = this._keys;
37669
+ var removeKey = keys[index];
37670
+ keys.splice(index, 1);
37669
37671
  this._typeArrayDirty = true;
37670
- var removeKey = this._keys[index];
37671
37672
  removeKey._unRegisterOnValueChanged(this._updateDispatch);
37672
37673
  this._updateDispatch();
37673
37674
  };
@@ -37683,6 +37684,29 @@
37683
37684
  };
37684
37685
  /**
37685
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
37686
37710
  */ _proto._getTypeArray = function _getTypeArray() {
37687
37711
  var typeArray = this._typeArray || (this._typeArray = new Float32Array(4 * 2));
37688
37712
  if (this._typeArrayDirty) {
@@ -38290,7 +38314,7 @@
38290
38314
  };
38291
38315
  /**
38292
38316
  * @internal
38293
- */ _proto._emit = function _emit(time, count) {
38317
+ */ _proto._emit = function _emit(playTime, count) {
38294
38318
  if (this.emission.enabled) {
38295
38319
  // Wait the existing particles to be retired
38296
38320
  var notRetireParticleCount = this._getNotRetiredParticleCount();
@@ -38303,7 +38327,7 @@
38303
38327
  var shape = this.emission.shape;
38304
38328
  for(var i = 0; i < count; i++){
38305
38329
  if (shape == null ? void 0 : shape.enabled) {
38306
- shape._generatePositionAndDirection(this.emission._shapeRand, time, position, direction);
38330
+ shape._generatePositionAndDirection(this.emission._shapeRand, playTime, position, direction);
38307
38331
  var positionScale = this.main._getPositionScale();
38308
38332
  position.multiply(positionScale);
38309
38333
  direction.normalize().multiply(positionScale);
@@ -38311,7 +38335,7 @@
38311
38335
  position.set(0, 0, 0);
38312
38336
  direction.set(0, 0, -1);
38313
38337
  }
38314
- this._addNewParticle(position, direction, transform, time);
38338
+ this._addNewParticle(position, direction, transform, playTime);
38315
38339
  }
38316
38340
  }
38317
38341
  };
@@ -38626,7 +38650,7 @@
38626
38650
  this._transformedBoundsArray[previousFreeElement * ParticleBufferUtils.boundsFloatStride + boundsTimeOffset] = this._playTime;
38627
38651
  }
38628
38652
  };
38629
- _proto._addNewParticle = function _addNewParticle(position, direction, transform, time) {
38653
+ _proto._addNewParticle = function _addNewParticle(position, direction, transform, playTime) {
38630
38654
  var firstFreeElement = this._firstFreeElement;
38631
38655
  var nextFreeElement = firstFreeElement + 1;
38632
38656
  if (nextFreeElement >= this._currentParticleCount) {
@@ -38656,35 +38680,30 @@
38656
38680
  var instanceVertices = this._instanceVertices;
38657
38681
  var offset = firstFreeElement * ParticleBufferUtils.instanceVertexFloatStride;
38658
38682
  // Position
38659
- instanceVertices[offset] = position.x;
38660
- instanceVertices[offset + 1] = position.y;
38661
- instanceVertices[offset + 2] = position.z;
38683
+ position.copyToArray(instanceVertices, offset);
38662
38684
  // Start life time
38663
38685
  instanceVertices[offset + ParticleBufferUtils.startLifeTimeOffset] = main.startLifetime.evaluate(undefined, main._startLifeTimeRand.random());
38664
38686
  // Direction
38665
- instanceVertices[offset + 4] = direction.x;
38666
- instanceVertices[offset + 5] = direction.y;
38667
- instanceVertices[offset + 6] = direction.z;
38687
+ direction.copyToArray(instanceVertices, offset + 4);
38668
38688
  // Time
38669
- instanceVertices[offset + ParticleBufferUtils.timeOffset] = time;
38689
+ instanceVertices[offset + ParticleBufferUtils.timeOffset] = playTime;
38670
38690
  // Color
38671
38691
  var startColor = ParticleGenerator._tempColor0;
38672
38692
  main.startColor.evaluate(undefined, main._startColorRand.random(), startColor);
38673
38693
  if (this._renderer.engine.settings.colorSpace === ColorSpace.Linear) {
38674
38694
  startColor.toLinear(startColor);
38675
38695
  }
38676
- instanceVertices[offset + 8] = startColor.r;
38677
- instanceVertices[offset + 9] = startColor.g;
38678
- instanceVertices[offset + 10] = startColor.b;
38679
- instanceVertices[offset + 11] = startColor.a;
38696
+ startColor.copyToArray(instanceVertices, offset + 8);
38697
+ var duration = this.main.duration;
38698
+ var normalizedEmitAge = playTime % duration / duration;
38680
38699
  // Start size
38681
38700
  var startSizeRand = main._startSizeRand;
38682
38701
  if (main.startSize3D) {
38683
- instanceVertices[offset + 12] = main.startSizeX.evaluate(undefined, startSizeRand.random());
38684
- instanceVertices[offset + 13] = main.startSizeY.evaluate(undefined, startSizeRand.random());
38685
- 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());
38686
38705
  } else {
38687
- var size = main.startSize.evaluate(undefined, startSizeRand.random());
38706
+ var size = main.startSize.evaluate(normalizedEmitAge, startSizeRand.random());
38688
38707
  instanceVertices[offset + 12] = size;
38689
38708
  instanceVertices[offset + 13] = size;
38690
38709
  instanceVertices[offset + 14] = size;
@@ -38737,14 +38756,9 @@
38737
38756
  }
38738
38757
  if (this.main.simulationSpace === ParticleSimulationSpace.World) {
38739
38758
  // Simulation world position
38740
- instanceVertices[offset + 27] = pos.x;
38741
- instanceVertices[offset + 28] = pos.y;
38742
- instanceVertices[offset + 29] = pos.z;
38759
+ pos.copyToArray(instanceVertices, offset + 27);
38743
38760
  // Simulation world position
38744
- instanceVertices[offset + 30] = rot.x;
38745
- instanceVertices[offset + 31] = rot.y;
38746
- instanceVertices[offset + 32] = rot.z;
38747
- instanceVertices[offset + 33] = rot.w;
38761
+ rot.copyToArray(instanceVertices, offset + 30);
38748
38762
  }
38749
38763
  // Simulation UV
38750
38764
  if (textureSheetAnimation.enabled) {
@@ -39113,7 +39127,7 @@
39113
39127
  * @inheritdoc
39114
39128
  */ _proto.clone = function clone() {
39115
39129
  var dest = new ParticleMaterial(this._engine);
39116
- this.cloneTo(dest);
39130
+ this._cloneToAndModifyName(dest);
39117
39131
  return dest;
39118
39132
  };
39119
39133
  _create_class$2(ParticleMaterial, [
@@ -47127,7 +47141,7 @@
47127
47141
  */ GLTFMaterialParser._checkOtherTextureTransform = function _checkOtherTextureTransform(texture, textureName) {
47128
47142
  var _texture_extensions;
47129
47143
  if ((_texture_extensions = texture.extensions) == null ? void 0 : _texture_extensions.KHR_texture_transform) {
47130
- Logger.warn("" + textureName + " texture always use the KHR_texture_transform of the base texture.");
47144
+ Logger.warn("" + textureName + " texture ignore KHR_texture_transform extension.");
47131
47145
  }
47132
47146
  };
47133
47147
  /**
@@ -50039,7 +50053,7 @@
50039
50053
  ], EXT_texture_webp);
50040
50054
 
50041
50055
  //@ts-ignore
50042
- var version = "1.4.8";
50056
+ var version = "1.4.10";
50043
50057
  console.log("Galacean Engine Version: " + version);
50044
50058
  for(var key in CoreObjects){
50045
50059
  Loader.registerClass(key, CoreObjects[key]);