@galacean/engine-core 1.1.0-alpha.1 → 1.1.0-alpha.3

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.
Files changed (148) hide show
  1. package/dist/main.js +334 -206
  2. package/dist/main.js.map +1 -1
  3. package/dist/miniprogram.js +334 -206
  4. package/dist/module.js +334 -206
  5. package/dist/module.js.map +1 -1
  6. package/package.json +3 -3
  7. package/types/ComponentsManager.d.ts +0 -2
  8. package/types/DisorderedArray.d.ts +6 -1
  9. package/types/RenderPipeline/MeshRenderElement.d.ts +1 -3
  10. package/types/RenderPipeline/RenderElementX.d.ts +12 -0
  11. package/types/RenderPipeline/SpriteElement.d.ts +1 -3
  12. package/types/RenderPipeline/SpriteMaskElement.d.ts +1 -3
  13. package/types/RenderPipeline/TextRenderElement.d.ts +1 -3
  14. package/types/SafeLoopArray.d.ts +37 -0
  15. package/types/Script.d.ts +0 -1
  16. package/types/Ticker.d.ts +30 -0
  17. package/types/Transform.d.ts +1 -0
  18. package/types/animation/internal/AnimationCurveOwnerLayerData.d.ts +1 -0
  19. package/types/asset/Loader.d.ts +1 -1
  20. package/types/asset/ResourceManager.d.ts +8 -0
  21. package/types/graphic/Primitive.d.ts +1 -0
  22. package/types/graphic/PrimitiveVertexBinding.d.ts +1 -0
  23. package/types/graphic/SubPrimitive.d.ts +9 -0
  24. package/types/index.d.ts +1 -1
  25. package/types/particle/ParticleBufferUtils.d.ts +1 -0
  26. package/types/particle/ParticleData.d.ts +1 -0
  27. package/types/particle/ParticleGenerator.d.ts +72 -0
  28. package/types/particle/ParticleMaterial.d.ts +28 -0
  29. package/types/particle/ParticleMesh.d.ts +289 -0
  30. package/types/particle/ParticleShaderDeclaration.d.ts +1 -0
  31. package/types/particle/ParticleShaderMacro.d.ts +1 -0
  32. package/types/particle/ParticleShaderProperty.d.ts +1 -0
  33. package/types/particle/ParticleSystem.d.ts +41 -0
  34. package/types/particle/ParticleVertexElements.d.ts +1 -0
  35. package/types/particle/ParticleVertexUtils.d.ts +1 -0
  36. package/types/particle/enum/ParticleAnimationRowMode.d.ts +9 -0
  37. package/types/particle/enum/ParticleAnimationType.d.ts +9 -0
  38. package/types/particle/enum/ParticleCurveMode.d.ts +13 -0
  39. package/types/particle/enum/ParticleGradientMode.d.ts +13 -0
  40. package/types/particle/enum/ParticleRenderMode.d.ts +17 -0
  41. package/types/particle/enum/ParticleScaleMode.d.ts +11 -0
  42. package/types/particle/enum/ParticleShapeMultiModeValue.d.ts +9 -0
  43. package/types/particle/enum/ParticleShapeType.d.ts +15 -0
  44. package/types/particle/enum/ParticleSimulationSpace.d.ts +9 -0
  45. package/types/particle/enum/index.d.ts +9 -0
  46. package/types/particle/enums/ParticleCurveMode.d.ts +9 -0
  47. package/types/particle/enums/ParticleGradientMode.d.ts +9 -0
  48. package/types/particle/enums/ParticleRandomSubSeeds.d.ts +1 -0
  49. package/types/particle/enums/ParticleRenderMode.d.ts +17 -0
  50. package/types/particle/enums/ParticleScaleMode.d.ts +11 -0
  51. package/types/particle/enums/ParticleSimulationSpace.d.ts +9 -0
  52. package/types/particle/enums/ParticleStopMode.d.ts +6 -0
  53. package/types/particle/enums/attributes/BillboardParticleVertexAttribute.d.ts +1 -0
  54. package/types/particle/enums/attributes/MeshParticleVertexAttribute.d.ts +5 -0
  55. package/types/particle/enums/attributes/ParticleInstanceVertexAttribute.d.ts +1 -0
  56. package/types/particle/module/Burst.d.ts +38 -0
  57. package/types/particle/module/ColorGradient.d.ts +75 -0
  58. package/types/particle/module/ColorOverLifetimeModule.d.ts +20 -0
  59. package/types/particle/module/EmissionModule.d.ts +63 -0
  60. package/types/particle/module/FrameOverTime.d.ts +73 -0
  61. package/types/particle/module/ParticleCurve.d.ts +37 -0
  62. package/types/particle/module/RotationOverLifetimeModule.d.ts +21 -0
  63. package/types/particle/module/RotationVelocityGradient.d.ts +184 -0
  64. package/types/particle/module/SizeGradient.d.ts +151 -0
  65. package/types/particle/module/SizeOverLifetimeModule.d.ts +21 -0
  66. package/types/particle/module/StartFrame.d.ts +46 -0
  67. package/types/particle/module/TextureSheetAnimationModule.d.ts +37 -0
  68. package/types/particle/module/VelocityGradient.d.ts +110 -0
  69. package/types/particle/module/VelocityOverLifetimeModule.d.ts +22 -0
  70. package/types/particle/module/index.d.ts +15 -0
  71. package/types/particle/module/shape/BaseShape.d.ts +26 -0
  72. package/types/particle/module/shape/BoxShape.d.ts +20 -0
  73. package/types/particle/module/shape/CircleShape.d.ts +27 -0
  74. package/types/particle/module/shape/ConeShape.d.ts +35 -0
  75. package/types/particle/module/shape/HemisphereShape.d.ts +23 -0
  76. package/types/particle/module/shape/ShapeUtils.d.ts +1 -0
  77. package/types/particle/module/shape/SphereShape.d.ts +23 -0
  78. package/types/particle/module/shape/index.d.ts +5 -0
  79. package/types/particle/modules/Burst.d.ts +14 -0
  80. package/types/particle/modules/ColorOverLifetimeModule.d.ts +20 -0
  81. package/types/particle/modules/EmissionModule.d.ts +45 -0
  82. package/types/particle/modules/MainModule.d.ts +68 -0
  83. package/types/particle/modules/ParticleCompositeCurve.d.ts +56 -0
  84. package/types/particle/modules/ParticleCompositeGradient.d.ts +55 -0
  85. package/types/particle/modules/ParticleCurve.d.ts +56 -0
  86. package/types/particle/modules/ParticleGeneratorModule.d.ts +12 -0
  87. package/types/particle/modules/ParticleGradient.d.ts +94 -0
  88. package/types/particle/modules/RotationOverLifetimeModule.d.ts +34 -0
  89. package/types/particle/modules/ShapeModule.d.ts +9 -0
  90. package/types/particle/modules/SizeOverLifetimeModule.d.ts +34 -0
  91. package/types/particle/modules/TextureSheetAnimationModule.d.ts +42 -0
  92. package/types/particle/modules/VelocityOverLifetimeModule.d.ts +34 -0
  93. package/types/particle/modules/shape/BaseShape.d.ts +12 -0
  94. package/types/particle/modules/shape/BoxShape.d.ts +11 -0
  95. package/types/particle/modules/shape/CircleShape.d.ts +17 -0
  96. package/types/particle/modules/shape/ConeShape.d.ts +28 -0
  97. package/types/particle/modules/shape/HemisphereShape.d.ts +9 -0
  98. package/types/particle/modules/shape/ShapeUtils.d.ts +1 -0
  99. package/types/particle/modules/shape/SphereShape.d.ts +9 -0
  100. package/types/particle/modules/shape/enums/ParticleShapeArcMode.d.ts +9 -0
  101. package/types/particle/modules/shape/enums/ParticleShapeMultiModeValue.d.ts +9 -0
  102. package/types/particle/modules/shape/enums/ParticleShapeType.d.ts +15 -0
  103. package/types/particle/modules/shape/index.d.ts +6 -0
  104. package/types/particle/moudules/Burst.d.ts +25 -0
  105. package/types/particle/moudules/Emission.d.ts +47 -0
  106. package/types/particle/moudules/EmissionModule.d.ts +49 -0
  107. package/types/particle/moudules/MainModule.d.ts +59 -0
  108. package/types/particle/moudules/ParticleCurve.d.ts +27 -0
  109. package/types/particle/moudules/ParticleGradient.d.ts +28 -0
  110. package/types/particle/moudules/ShapeModule.d.ts +7 -0
  111. package/types/particle/moudules/shape/BaseShape.d.ts +28 -0
  112. package/types/particle/moudules/shape/BoxShape.d.ts +20 -0
  113. package/types/particle/moudules/shape/CircleShape.d.ts +27 -0
  114. package/types/particle/moudules/shape/ConeShape.d.ts +35 -0
  115. package/types/particle/moudules/shape/HemisphereShape.d.ts +23 -0
  116. package/types/particle/moudules/shape/ShapeUtils.d.ts +1 -0
  117. package/types/particle/moudules/shape/SphereShape.d.ts +23 -0
  118. package/types/particle/moudules/shape/enums/ParticleShapeMultiModeValue.d.ts +9 -0
  119. package/types/particle/moudules/shape/enums/ParticleShapeType.d.ts +15 -0
  120. package/types/particle/moudules/shape/index.d.ts +5 -0
  121. package/types/physics/PhysicsScene.d.ts +6 -2
  122. package/types/shaderlib/particle/index.d.ts +14 -0
  123. package/types/shadow/PipelinePass.d.ts +16 -0
  124. package/types/utils/BoolUpdateFlag.d.ts +12 -0
  125. package/types/utils/DisorderedArray.d.ts +18 -0
  126. package/types/utils/UpdateFlag.d.ts +20 -0
  127. package/types/utils/UpdateFlagManager.d.ts +1 -0
  128. package/types/utils/Utils.d.ts +31 -0
  129. package/types/xr/XRManager.d.ts +31 -0
  130. package/types/xr/component/XRPoseDriver.d.ts +10 -0
  131. package/types/xr/data/XRCamera.d.ts +6 -0
  132. package/types/xr/data/XRDevice.d.ts +9 -0
  133. package/types/xr/data/XRHandle.d.ts +10 -0
  134. package/types/xr/enum/EnumXRButton.d.ts +5 -0
  135. package/types/xr/enum/EnumXRDevicePhase.d.ts +4 -0
  136. package/types/xr/enum/EnumXRFeature.d.ts +9 -0
  137. package/types/xr/enum/EnumXRInputSource.d.ts +8 -0
  138. package/types/xr/enum/EnumXRMode.d.ts +7 -0
  139. package/types/xr/enum/EnumXRSubsystem.d.ts +4 -0
  140. package/types/xr/enum/EnumXRTrackingMode.d.ts +7 -0
  141. package/types/xr/feature/XRCameraManager.d.ts +21 -0
  142. package/types/xr/feature/XRFeature.d.ts +29 -0
  143. package/types/xr/feature/XRImageTrackManager.d.ts +10 -0
  144. package/types/xr/feature/XRInputManager.d.ts +16 -0
  145. package/types/xr/index.d.ts +18 -0
  146. package/types/xr/provider/XRProvider.d.ts +19 -0
  147. package/types/xr/subsystem/XRInputSubsystem.d.ts +5 -0
  148. package/types/xr/subsystem/XRSubsystem.d.ts +30 -0
@@ -2766,6 +2766,8 @@ exports.DependentMode = void 0;
2766
2766
  function DisorderedArray(count) {
2767
2767
  if (count === void 0) count = 0;
2768
2768
  this.length = 0;
2769
+ this._isLooping = false;
2770
+ this._blankCount = 0;
2769
2771
  this._elements = new Array(count);
2770
2772
  }
2771
2773
  var _proto = DisorderedArray.prototype;
@@ -2794,21 +2796,49 @@ exports.DependentMode = void 0;
2794
2796
  }
2795
2797
  return this._elements[index];
2796
2798
  };
2799
+ _proto.startLoop = function startLoop() {
2800
+ this._isLooping = true;
2801
+ };
2797
2802
  /**
2798
2803
  * Delete the element at the specified index.
2799
2804
  * @param index - The index of the element to be deleted
2800
2805
  * @returns The replaced item is used to reset its index
2801
2806
  */ _proto.deleteByIndex = function deleteByIndex(index) {
2802
2807
  var elements = this._elements;
2803
- var end = null;
2804
- var lastIndex = this.length - 1;
2805
- if (index !== lastIndex) {
2806
- end = elements[lastIndex];
2807
- elements[index] = end;
2808
+ var end;
2809
+ if (this._isLooping) {
2810
+ this._elements[index] = null;
2811
+ this._blankCount++;
2812
+ } else {
2813
+ var endIndex = this.length - 1;
2814
+ if (index !== endIndex) {
2815
+ end = elements[endIndex];
2816
+ elements[index] = end;
2817
+ }
2818
+ elements[endIndex] = null;
2819
+ this.length--;
2808
2820
  }
2809
- this.length--;
2810
2821
  return end;
2811
2822
  };
2823
+ _proto.endLoop = function endLoop() {
2824
+ this._isLooping = false;
2825
+ if (this._blankCount) {
2826
+ var elements = this._elements;
2827
+ for(var i = 0, j = 0, n = this.length; i < n; i++){
2828
+ var element = elements[i];
2829
+ if (element) {
2830
+ elements[j++] = element;
2831
+ }
2832
+ }
2833
+ this.length -= this._blankCount;
2834
+ this._blankCount = 0;
2835
+ }
2836
+ };
2837
+ _proto.endLoopAndClear = function endLoopAndClear() {
2838
+ this._isLooping = false;
2839
+ this.length = 0;
2840
+ this._blankCount = 0;
2841
+ };
2812
2842
  _proto.garbageCollection = function garbageCollection() {
2813
2843
  this._elements.length = this.length;
2814
2844
  };
@@ -3287,6 +3317,23 @@ var rePropName$1 = RegExp(// Match anything that isn't a dot or bracket.
3287
3317
  scale.z < 0 && (isInvert = !isInvert);
3288
3318
  return isInvert;
3289
3319
  };
3320
+ _proto._onDestroy = function _onDestroy() {
3321
+ Component.prototype._onDestroy.call(this);
3322
+ //@ts-ignore
3323
+ this._worldPosition._onValueChanged = null;
3324
+ //@ts-ignore
3325
+ this._rotation._onValueChanged = null;
3326
+ //@ts-ignore
3327
+ this._worldRotation._onValueChanged = null;
3328
+ //@ts-ignore
3329
+ this._rotationQuaternion._onValueChanged = null;
3330
+ //@ts-ignore
3331
+ this._worldRotationQuaternion._onValueChanged = null;
3332
+ //@ts-ignore
3333
+ this._position._onValueChanged = null;
3334
+ //@ts-ignore
3335
+ this._scale._onValueChanged = null;
3336
+ };
3290
3337
  /**
3291
3338
  * Get worldMatrix: Will trigger the worldMatrix update of itself and all parent entities.
3292
3339
  * Get worldPosition: Will trigger the worldMatrix, local position update of itself and the worldMatrix update of all parent entities.
@@ -4028,11 +4075,13 @@ var ComponentCloner = /*#__PURE__*/ function() {
4028
4075
  if (!this._isActiveInHierarchy) {
4029
4076
  child._isActiveInHierarchy && (inActiveChangeFlag |= ActiveChangeFlag.Hierarchy);
4030
4077
  }
4031
- if (this._isActiveInScene) {
4032
- // cross scene should inActive first and then active
4033
- child._isActiveInScene && oldScene !== newScene && (inActiveChangeFlag |= ActiveChangeFlag.Scene);
4034
- } else {
4035
- child._isActiveInScene && (inActiveChangeFlag |= ActiveChangeFlag.Scene);
4078
+ if (child._isActiveInScene) {
4079
+ if (this._isActiveInScene) {
4080
+ // Cross scene should inActive first and then active
4081
+ oldScene !== newScene && (inActiveChangeFlag |= ActiveChangeFlag.Scene);
4082
+ } else {
4083
+ inActiveChangeFlag |= ActiveChangeFlag.Scene;
4084
+ }
4036
4085
  }
4037
4086
  inActiveChangeFlag && child._processInActive(inActiveChangeFlag);
4038
4087
  if (child._scene !== newScene) {
@@ -5005,7 +5054,7 @@ var begin_mobile_frag = "#define GLSLIFY 1\nvec4 ambient=vec4(0.0);vec4 emission
5005
5054
 
5006
5055
  var begin_viewdir_frag = "#define GLSLIFY 1\n#ifdef MATERIAL_NEED_WORLD_POS\nvec3 V=normalize(camera_Position-v_pos);\n#endif\n"; // eslint-disable-line
5007
5056
 
5008
- var mobile_blinnphong_frag = "#define GLSLIFY 1\n#ifdef MATERIAL_HAS_NORMALTEXTURE\nmat3 tbn=getTBN(gl_FrontFacing);vec3 N=getNormalByNormalTexture(tbn,material_NormalTexture,material_NormalIntensity,v_uv,gl_FrontFacing);\n#else\nvec3 N=getNormal(gl_FrontFacing);\n#endif\nvec3 lightDiffuse=vec3(0.0,0.0,0.0);vec3 lightSpecular=vec3(0.0,0.0,0.0);float shadowAttenuation=1.0;\n#ifdef SCENE_DIRECT_LIGHT_COUNT\nshadowAttenuation=1.0;\n#ifdef SCENE_IS_CALCULATE_SHADOWS\nshadowAttenuation*=sampleShadowMap();\n#endif\nDirectLight directionalLight;for(int i=0;i<SCENE_DIRECT_LIGHT_COUNT;i++){if(isRendererCulledByLight(renderer_Layer.xy,scene_DirectLightCullingMask[i]))continue;directionalLight.color=scene_DirectLightColor[i];\n#ifdef SCENE_IS_CALCULATE_SHADOWS\nif(i==0){directionalLight.color*=shadowAttenuation;}\n#endif\ndirectionalLight.direction=scene_DirectLightDirection[i];float d=max(dot(N,-directionalLight.direction),0.0);lightDiffuse+=directionalLight.color*d;vec3 halfDir=normalize(V-directionalLight.direction);float s=pow(clamp(dot(N,halfDir),0.0,1.0),material_Shininess);lightSpecular+=directionalLight.color*s;}\n#endif\n#ifdef SCENE_POINT_LIGHT_COUNT\nPointLight pointLight;for(int i=0;i<SCENE_POINT_LIGHT_COUNT;i++){if(isRendererCulledByLight(renderer_Layer.xy,scene_PointLightCullingMask[i]))continue;pointLight.color=scene_PointLightColor[i];pointLight.position=scene_PointLightPosition[i];pointLight.distance=scene_PointLightDistance[i];vec3 direction=v_pos-pointLight.position;float dist=length(direction);direction/=dist;float decay=clamp(1.0-pow(dist/pointLight.distance,4.0),0.0,1.0);float d=max(dot(N,-direction),0.0)*decay;lightDiffuse+=pointLight.color*d;vec3 halfDir=normalize(V-direction);float s=pow(clamp(dot(N,halfDir),0.0,1.0),material_Shininess)*decay;lightSpecular+=pointLight.color*s;}\n#endif\n#ifdef SCENE_SPOT_LIGHT_COUNT\nSpotLight spotLight;for(int i=0;i<SCENE_SPOT_LIGHT_COUNT;i++){if(isRendererCulledByLight(renderer_Layer.xy,scene_SpotLightCullingMask[i]))continue;spotLight.color=scene_SpotLightColor[i];spotLight.position=scene_SpotLightPosition[i];spotLight.direction=scene_SpotLightDirection[i];spotLight.distance=scene_SpotLightDistance[i];spotLight.angleCos=scene_SpotLightAngleCos[i];spotLight.penumbraCos=scene_SpotLightPenumbraCos[i];vec3 direction=spotLight.position-v_pos;float lightDistance=length(direction);direction/=lightDistance;float angleCos=dot(direction,-spotLight.direction);float decay=clamp(1.0-pow(lightDistance/spotLight.distance,4.0),0.0,1.0);float spotEffect=smoothstep(spotLight.penumbraCos,spotLight.angleCos,angleCos);float decayTotal=decay*spotEffect;float d=max(dot(N,direction),0.0)*decayTotal;lightDiffuse+=spotLight.color*d;vec3 halfDir=normalize(V+direction);float s=pow(clamp(dot(N,halfDir),0.0,1.0),material_Shininess)*decayTotal;lightSpecular+=spotLight.color*s;}\n#endif\ndiffuse*=vec4(lightDiffuse,1.0);specular*=vec4(lightSpecular,1.0);\n#ifdef MATERIAL_IS_ALPHA_CUTOFF\nif(diffuse.a<material_AlphaCutoff){discard;}\n#endif\n"; // eslint-disable-line
5057
+ var mobile_blinnphong_frag = "#define GLSLIFY 1\n#ifdef MATERIAL_HAS_NORMALTEXTURE\nmat3 tbn=getTBN(gl_FrontFacing);vec3 N=getNormalByNormalTexture(tbn,material_NormalTexture,material_NormalIntensity,v_uv,gl_FrontFacing);\n#else\nvec3 N=getNormal(gl_FrontFacing);\n#endif\nvec3 lightDiffuse=vec3(0.0,0.0,0.0);vec3 lightSpecular=vec3(0.0,0.0,0.0);float shadowAttenuation=1.0;\n#ifdef SCENE_DIRECT_LIGHT_COUNT\nshadowAttenuation=1.0;\n#ifdef SCENE_IS_CALCULATE_SHADOWS\nshadowAttenuation*=sampleShadowMap();\n#endif\nDirectLight directionalLight;for(int i=0;i<SCENE_DIRECT_LIGHT_COUNT;i++){if(!isRendererCulledByLight(renderer_Layer.xy,scene_DirectLightCullingMask[i])){directionalLight.color=scene_DirectLightColor[i];\n#ifdef SCENE_IS_CALCULATE_SHADOWS\nif(i==0){directionalLight.color*=shadowAttenuation;}\n#endif\ndirectionalLight.direction=scene_DirectLightDirection[i];float d=max(dot(N,-directionalLight.direction),0.0);lightDiffuse+=directionalLight.color*d;vec3 halfDir=normalize(V-directionalLight.direction);float s=pow(clamp(dot(N,halfDir),0.0,1.0),material_Shininess);lightSpecular+=directionalLight.color*s;}}\n#endif\n#ifdef SCENE_POINT_LIGHT_COUNT\nPointLight pointLight;for(int i=0;i<SCENE_POINT_LIGHT_COUNT;i++){if(!isRendererCulledByLight(renderer_Layer.xy,scene_PointLightCullingMask[i])){pointLight.color=scene_PointLightColor[i];pointLight.position=scene_PointLightPosition[i];pointLight.distance=scene_PointLightDistance[i];vec3 direction=v_pos-pointLight.position;float dist=length(direction);direction/=dist;float decay=clamp(1.0-pow(dist/pointLight.distance,4.0),0.0,1.0);float d=max(dot(N,-direction),0.0)*decay;lightDiffuse+=pointLight.color*d;vec3 halfDir=normalize(V-direction);float s=pow(clamp(dot(N,halfDir),0.0,1.0),material_Shininess)*decay;lightSpecular+=pointLight.color*s;}}\n#endif\n#ifdef SCENE_SPOT_LIGHT_COUNT\nSpotLight spotLight;for(int i=0;i<SCENE_SPOT_LIGHT_COUNT;i++){if(!isRendererCulledByLight(renderer_Layer.xy,scene_SpotLightCullingMask[i])){spotLight.color=scene_SpotLightColor[i];spotLight.position=scene_SpotLightPosition[i];spotLight.direction=scene_SpotLightDirection[i];spotLight.distance=scene_SpotLightDistance[i];spotLight.angleCos=scene_SpotLightAngleCos[i];spotLight.penumbraCos=scene_SpotLightPenumbraCos[i];vec3 direction=spotLight.position-v_pos;float lightDistance=length(direction);direction/=lightDistance;float angleCos=dot(direction,-spotLight.direction);float decay=clamp(1.0-pow(lightDistance/spotLight.distance,4.0),0.0,1.0);float spotEffect=smoothstep(spotLight.penumbraCos,spotLight.angleCos,angleCos);float decayTotal=decay*spotEffect;float d=max(dot(N,direction),0.0)*decayTotal;lightDiffuse+=spotLight.color*d;vec3 halfDir=normalize(V+direction);float s=pow(clamp(dot(N,halfDir),0.0,1.0),material_Shininess)*decayTotal;lightSpecular+=spotLight.color*s;}}\n#endif\ndiffuse*=vec4(lightDiffuse,1.0);specular*=vec4(lightSpecular,1.0);\n#ifdef MATERIAL_IS_ALPHA_CUTOFF\nif(diffuse.a<material_AlphaCutoff){discard;}\n#endif\n"; // eslint-disable-line
5009
5058
 
5010
5059
  var noise_cellular = "#define GLSLIFY 1\n#include <noise_cellular_2D>\n#include <noise_cellular_3D>\n#include <noise_cellular_2x2>\n#include <noise_cellular_2x2x2>\n"; // eslint-disable-line
5011
5060
 
@@ -5045,7 +5094,7 @@ var pbr_helper = "#define GLSLIFY 1\n#include <normal_get>\nfloat computeSpecula
5045
5094
 
5046
5095
  var brdf = "#define GLSLIFY 1\nfloat F_Schlick(float dotLH){return 0.04+0.96*(pow(1.0-dotLH,5.0));}vec3 F_Schlick(vec3 specularColor,float dotLH){float fresnel=exp2((-5.55473*dotLH-6.98316)*dotLH);return(1.0-specularColor)*fresnel+specularColor;}float G_GGX_SmithCorrelated(float alpha,float dotNL,float dotNV){float a2=pow2(alpha);float gv=dotNL*sqrt(a2+(1.0-a2)*pow2(dotNV));float gl=dotNV*sqrt(a2+(1.0-a2)*pow2(dotNL));return 0.5/max(gv+gl,EPSILON);}float D_GGX(float alpha,float dotNH){float a2=pow2(alpha);float denom=pow2(dotNH)*(a2-1.0)+1.0;return RECIPROCAL_PI*a2/pow2(denom);}vec3 BRDF_Specular_GGX(vec3 incidentDirection,vec3 viewDir,vec3 normal,vec3 specularColor,float roughness){float alpha=pow2(roughness);vec3 halfDir=normalize(incidentDirection+viewDir);float dotNL=saturate(dot(normal,incidentDirection));float dotNV=saturate(dot(normal,viewDir));float dotNH=saturate(dot(normal,halfDir));float dotLH=saturate(dot(incidentDirection,halfDir));vec3 F=F_Schlick(specularColor,dotLH);float G=G_GGX_SmithCorrelated(alpha,dotNL,dotNV);float D=D_GGX(alpha,dotNH);return F*(G*D);}vec3 BRDF_Diffuse_Lambert(vec3 diffuseColor){return RECIPROCAL_PI*diffuseColor;}"; // eslint-disable-line
5047
5096
 
5048
- var direct_irradiance_frag_define = "#define GLSLIFY 1\n#include <ShadowFragmentDeclaration>\nvoid addDirectRadiance(vec3 incidentDirection,vec3 color,Geometry geometry,Material material,inout ReflectedLight reflectedLight){float attenuation=1.0;\n#ifdef MATERIAL_ENABLE_CLEAR_COAT\nfloat clearCoatDotNL=saturate(dot(geometry.clearCoatNormal,incidentDirection));vec3 clearCoatIrradiance=clearCoatDotNL*color;reflectedLight.directSpecular+=material.clearCoat*clearCoatIrradiance*BRDF_Specular_GGX(incidentDirection,geometry.viewDir,geometry.clearCoatNormal,vec3(0.04),material.clearCoatRoughness);attenuation-=material.clearCoat*F_Schlick(geometry.clearCoatDotNV);\n#endif\nfloat dotNL=saturate(dot(geometry.normal,incidentDirection));vec3 irradiance=dotNL*color*PI;reflectedLight.directSpecular+=attenuation*irradiance*BRDF_Specular_GGX(incidentDirection,geometry.viewDir,geometry.normal,material.specularColor,material.roughness);reflectedLight.directDiffuse+=attenuation*irradiance*BRDF_Diffuse_Lambert(material.diffuseColor);}\n#ifdef SCENE_DIRECT_LIGHT_COUNT\nvoid addDirectionalDirectLightRadiance(DirectLight directionalLight,Geometry geometry,Material material,inout ReflectedLight reflectedLight){vec3 color=directionalLight.color;vec3 direction=-directionalLight.direction;addDirectRadiance(direction,color,geometry,material,reflectedLight);}\n#endif\n#ifdef SCENE_POINT_LIGHT_COUNT\nvoid addPointDirectLightRadiance(PointLight pointLight,Geometry geometry,Material material,inout ReflectedLight reflectedLight){vec3 lVector=pointLight.position-geometry.position;vec3 direction=normalize(lVector);float lightDistance=length(lVector);vec3 color=pointLight.color;color*=clamp(1.0-pow(lightDistance/pointLight.distance,4.0),0.0,1.0);addDirectRadiance(direction,color,geometry,material,reflectedLight);}\n#endif\n#ifdef SCENE_SPOT_LIGHT_COUNT\nvoid addSpotDirectLightRadiance(SpotLight spotLight,Geometry geometry,Material material,inout ReflectedLight reflectedLight){vec3 lVector=spotLight.position-geometry.position;vec3 direction=normalize(lVector);float lightDistance=length(lVector);float angleCos=dot(direction,-spotLight.direction);float spotEffect=smoothstep(spotLight.penumbraCos,spotLight.angleCos,angleCos);float decayEffect=clamp(1.0-pow(lightDistance/spotLight.distance,4.0),0.0,1.0);vec3 color=spotLight.color;color*=spotEffect*decayEffect;addDirectRadiance(direction,color,geometry,material,reflectedLight);}\n#endif\nvoid addTotalDirectRadiance(Geometry geometry,Material material,inout ReflectedLight reflectedLight){float shadowAttenuation=1.0;\n#ifdef SCENE_DIRECT_LIGHT_COUNT\nshadowAttenuation=1.0;\n#ifdef SCENE_IS_CALCULATE_SHADOWS\nshadowAttenuation*=sampleShadowMap();\n#endif\nDirectLight directionalLight;for(int i=0;i<SCENE_DIRECT_LIGHT_COUNT;i++){if(isRendererCulledByLight(renderer_Layer.xy,scene_DirectLightCullingMask[i]))continue;directionalLight.color=scene_DirectLightColor[i];\n#ifdef SCENE_IS_CALCULATE_SHADOWS\nif(i==0){directionalLight.color*=shadowAttenuation;}\n#endif\ndirectionalLight.direction=scene_DirectLightDirection[i];addDirectionalDirectLightRadiance(directionalLight,geometry,material,reflectedLight);}\n#endif\n#ifdef SCENE_POINT_LIGHT_COUNT\nPointLight pointLight;for(int i=0;i<SCENE_POINT_LIGHT_COUNT;i++){if(isRendererCulledByLight(renderer_Layer.xy,scene_PointLightCullingMask[i]))continue;pointLight.color=scene_PointLightColor[i];pointLight.position=scene_PointLightPosition[i];pointLight.distance=scene_PointLightDistance[i];addPointDirectLightRadiance(pointLight,geometry,material,reflectedLight);}\n#endif\n#ifdef SCENE_SPOT_LIGHT_COUNT\nSpotLight spotLight;for(int i=0;i<SCENE_SPOT_LIGHT_COUNT;i++){if(isRendererCulledByLight(renderer_Layer.xy,scene_SpotLightCullingMask[i]))continue;spotLight.color=scene_SpotLightColor[i];spotLight.position=scene_SpotLightPosition[i];spotLight.direction=scene_SpotLightDirection[i];spotLight.distance=scene_SpotLightDistance[i];spotLight.angleCos=scene_SpotLightAngleCos[i];spotLight.penumbraCos=scene_SpotLightPenumbraCos[i];addSpotDirectLightRadiance(spotLight,geometry,material,reflectedLight);}\n#endif\n}"; // eslint-disable-line
5097
+ var direct_irradiance_frag_define = "#define GLSLIFY 1\n#include <ShadowFragmentDeclaration>\nvoid addDirectRadiance(vec3 incidentDirection,vec3 color,Geometry geometry,Material material,inout ReflectedLight reflectedLight){float attenuation=1.0;\n#ifdef MATERIAL_ENABLE_CLEAR_COAT\nfloat clearCoatDotNL=saturate(dot(geometry.clearCoatNormal,incidentDirection));vec3 clearCoatIrradiance=clearCoatDotNL*color;reflectedLight.directSpecular+=material.clearCoat*clearCoatIrradiance*BRDF_Specular_GGX(incidentDirection,geometry.viewDir,geometry.clearCoatNormal,vec3(0.04),material.clearCoatRoughness);attenuation-=material.clearCoat*F_Schlick(geometry.clearCoatDotNV);\n#endif\nfloat dotNL=saturate(dot(geometry.normal,incidentDirection));vec3 irradiance=dotNL*color*PI;reflectedLight.directSpecular+=attenuation*irradiance*BRDF_Specular_GGX(incidentDirection,geometry.viewDir,geometry.normal,material.specularColor,material.roughness);reflectedLight.directDiffuse+=attenuation*irradiance*BRDF_Diffuse_Lambert(material.diffuseColor);}\n#ifdef SCENE_DIRECT_LIGHT_COUNT\nvoid addDirectionalDirectLightRadiance(DirectLight directionalLight,Geometry geometry,Material material,inout ReflectedLight reflectedLight){vec3 color=directionalLight.color;vec3 direction=-directionalLight.direction;addDirectRadiance(direction,color,geometry,material,reflectedLight);}\n#endif\n#ifdef SCENE_POINT_LIGHT_COUNT\nvoid addPointDirectLightRadiance(PointLight pointLight,Geometry geometry,Material material,inout ReflectedLight reflectedLight){vec3 lVector=pointLight.position-geometry.position;vec3 direction=normalize(lVector);float lightDistance=length(lVector);vec3 color=pointLight.color;color*=clamp(1.0-pow(lightDistance/pointLight.distance,4.0),0.0,1.0);addDirectRadiance(direction,color,geometry,material,reflectedLight);}\n#endif\n#ifdef SCENE_SPOT_LIGHT_COUNT\nvoid addSpotDirectLightRadiance(SpotLight spotLight,Geometry geometry,Material material,inout ReflectedLight reflectedLight){vec3 lVector=spotLight.position-geometry.position;vec3 direction=normalize(lVector);float lightDistance=length(lVector);float angleCos=dot(direction,-spotLight.direction);float spotEffect=smoothstep(spotLight.penumbraCos,spotLight.angleCos,angleCos);float decayEffect=clamp(1.0-pow(lightDistance/spotLight.distance,4.0),0.0,1.0);vec3 color=spotLight.color;color*=spotEffect*decayEffect;addDirectRadiance(direction,color,geometry,material,reflectedLight);}\n#endif\nvoid addTotalDirectRadiance(Geometry geometry,Material material,inout ReflectedLight reflectedLight){float shadowAttenuation=1.0;\n#ifdef SCENE_DIRECT_LIGHT_COUNT\nshadowAttenuation=1.0;\n#ifdef SCENE_IS_CALCULATE_SHADOWS\nshadowAttenuation*=sampleShadowMap();\n#endif\nDirectLight directionalLight;for(int i=0;i<SCENE_DIRECT_LIGHT_COUNT;i++){if(!isRendererCulledByLight(renderer_Layer.xy,scene_DirectLightCullingMask[i])){directionalLight.color=scene_DirectLightColor[i];\n#ifdef SCENE_IS_CALCULATE_SHADOWS\nif(i==0){directionalLight.color*=shadowAttenuation;}\n#endif\ndirectionalLight.direction=scene_DirectLightDirection[i];addDirectionalDirectLightRadiance(directionalLight,geometry,material,reflectedLight);}}\n#endif\n#ifdef SCENE_POINT_LIGHT_COUNT\nPointLight pointLight;for(int i=0;i<SCENE_POINT_LIGHT_COUNT;i++){if(!isRendererCulledByLight(renderer_Layer.xy,scene_PointLightCullingMask[i])){pointLight.color=scene_PointLightColor[i];pointLight.position=scene_PointLightPosition[i];pointLight.distance=scene_PointLightDistance[i];addPointDirectLightRadiance(pointLight,geometry,material,reflectedLight);}}\n#endif\n#ifdef SCENE_SPOT_LIGHT_COUNT\nSpotLight spotLight;for(int i=0;i<SCENE_SPOT_LIGHT_COUNT;i++){if(!isRendererCulledByLight(renderer_Layer.xy,scene_SpotLightCullingMask[i])){spotLight.color=scene_SpotLightColor[i];spotLight.position=scene_SpotLightPosition[i];spotLight.direction=scene_SpotLightDirection[i];spotLight.distance=scene_SpotLightDistance[i];spotLight.angleCos=scene_SpotLightAngleCos[i];spotLight.penumbraCos=scene_SpotLightPenumbraCos[i];addSpotDirectLightRadiance(spotLight,geometry,material,reflectedLight);}}\n#endif\n}"; // eslint-disable-line
5049
5098
 
5050
5099
  var ibl_frag_define = "#define GLSLIFY 1\nvec3 getLightProbeIrradiance(vec3 sh[9],vec3 normal){normal.x=-normal.x;vec3 result=sh[0]+sh[1]*(normal.y)+sh[2]*(normal.z)+sh[3]*(normal.x)+sh[4]*(normal.y*normal.x)+sh[5]*(normal.y*normal.z)+sh[6]*(3.0*normal.z*normal.z-1.0)+sh[7]*(normal.z*normal.x)+sh[8]*(normal.x*normal.x-normal.y*normal.y);return max(result,vec3(0.0));}vec3 envBRDFApprox(vec3 specularColor,float roughness,float dotNV){const vec4 c0=vec4(-1,-0.0275,-0.572,0.022);const vec4 c1=vec4(1,0.0425,1.04,-0.04);vec4 r=roughness*c0+c1;float a004=min(r.x*r.x,exp2(-9.28*dotNV))*r.x+r.y;vec2 AB=vec2(-1.04,1.04)*a004+r.zw;return specularColor*AB.x+AB.y;}float getSpecularMIPLevel(float roughness,int maxMIPLevel){return roughness*float(maxMIPLevel);}vec3 getLightProbeRadiance(vec3 viewDir,vec3 normal,float roughness,int maxMIPLevel,float specularIntensity){\n#ifndef SCENE_USE_SPECULAR_ENV\nreturn vec3(0);\n#else\nvec3 reflectVec=reflect(-viewDir,normal);reflectVec.x=-reflectVec.x;float specularMIPLevel=getSpecularMIPLevel(roughness,maxMIPLevel);\n#ifdef HAS_TEX_LOD\nvec4 envMapColor=textureCubeLodEXT(scene_EnvSpecularSampler,reflectVec,specularMIPLevel);\n#else\nvec4 envMapColor=textureCube(scene_EnvSpecularSampler,reflectVec,specularMIPLevel);\n#endif\n#ifdef SCENE_IS_DECODE_ENV_RGBM\nenvMapColor.rgb=RGBMToLinear(envMapColor,5.0).rgb;\n#ifdef ENGINE_IS_COLORSPACE_GAMMA\nenvMapColor=linearToGamma(envMapColor);\n#endif\n#else\n#ifndef ENGINE_IS_COLORSPACE_GAMMA\nenvMapColor=gammaToLinear(envMapColor);\n#endif\n#endif\nreturn envMapColor.rgb*specularIntensity;\n#endif\n}"; // eslint-disable-line
5051
5100
 
@@ -11540,19 +11589,20 @@ var PrimitiveType;
11540
11589
  /**
11541
11590
  * @internal
11542
11591
  */ _proto.update = function update() {
11543
- var skin = this._skin;
11544
- if (skin) {
11545
- var ibms = skin.inverseBindMatrices;
11546
- var worldToLocal = this._rootBone.getInvModelMatrix();
11547
- var _this = this, bones = _this._bones, jointMatrices = _this._jointMatrices;
11592
+ var _this = this, skin = _this._skin, bones = _this._bones;
11593
+ if (skin && bones) {
11548
11594
  // @todo: can optimize when share skin
11595
+ var jointMatrices = this._jointMatrices;
11596
+ var bindMatrices = skin.inverseBindMatrices;
11597
+ var _this__rootBone;
11598
+ var worldToLocal = ((_this__rootBone = this._rootBone) != null ? _this__rootBone : this.entity).getInvModelMatrix();
11549
11599
  for(var i = bones.length - 1; i >= 0; i--){
11550
11600
  var bone = bones[i];
11551
11601
  var offset = i * 16;
11552
11602
  if (bone) {
11553
- Utils._floatMatrixMultiply(bone.transform.worldMatrix, ibms[i].elements, 0, jointMatrices, offset);
11603
+ Utils._floatMatrixMultiply(bone.transform.worldMatrix, bindMatrices[i].elements, 0, jointMatrices, offset);
11554
11604
  } else {
11555
- jointMatrices.set(ibms[i].elements, offset);
11605
+ jointMatrices.set(bindMatrices[i].elements, offset);
11556
11606
  }
11557
11607
  Utils._floatMatrixMultiply(worldToLocal, jointMatrices, offset, jointMatrices, offset);
11558
11608
  }
@@ -12223,6 +12273,41 @@ var TextRenderData = /*#__PURE__*/ function(RenderData) {
12223
12273
  return TextRenderData;
12224
12274
  }(RenderData);
12225
12275
 
12276
+ /**
12277
+ * Asset Type.
12278
+ */ exports.AssetType = void 0;
12279
+ (function(AssetType) {
12280
+ AssetType[/**
12281
+ * Plain text.
12282
+ * @remarks Will not be cached based on url in ResourceManager.
12283
+ */ "Text"] = "Text";
12284
+ AssetType[/**
12285
+ * JSON.
12286
+ * @remarks Will not be cached based on url in ResourceManager.
12287
+ */ "JSON"] = "JSON";
12288
+ AssetType[/**
12289
+ * ArrayBuffer.
12290
+ * @remarks Will not be cached based on url in ResourceManager.
12291
+ */ "Buffer"] = "Buffer";
12292
+ AssetType[/** 2D Texture. */ "Texture2D"] = "Texture2D";
12293
+ AssetType[/** Cube Texture. */ "TextureCube"] = "TextureCube";
12294
+ AssetType[/** Material. */ "Material"] = "Material";
12295
+ AssetType[/** Mesh. */ "Mesh"] = "Mesh";
12296
+ AssetType[/** AnimationClip. */ "AnimationClip"] = "AnimationClip";
12297
+ AssetType[/** AnimatorController. */ "AnimatorController"] = "AnimatorController";
12298
+ AssetType[/** Prefab.*/ "GLTF"] = "GLTF";
12299
+ AssetType[/** Compress Texture. */ "KTX"] = "KTX";
12300
+ AssetType[/** Cube Compress Texture. */ "KTXCube"] = "KTXCube";
12301
+ AssetType[/** KTX2 Compress Texture */ "KTX2"] = "KTX2";
12302
+ AssetType[/** Sprite. */ "Sprite"] = "Sprite";
12303
+ AssetType[/** Sprite Atlas. */ "SpriteAtlas"] = "SpriteAtlas";
12304
+ AssetType[/** Ambient light. */ "Env"] = "Environment";
12305
+ AssetType[/** Scene. */ "Scene"] = "Scene";
12306
+ AssetType[/** HDR to cube. */ "HDR"] = "HDR";
12307
+ AssetType[/** Font. */ "Font"] = "Font";
12308
+ AssetType[/** Source Font, include ttf、 otf and woff. */ "SourceFont"] = "SourceFont";
12309
+ })(exports.AssetType || (exports.AssetType = {}));
12310
+
12226
12311
  var SafeLoopArray = /*#__PURE__*/ function() {
12227
12312
  function SafeLoopArray() {
12228
12313
  this._array = [];
@@ -12335,10 +12420,13 @@ var SafeLoopArray = /*#__PURE__*/ function() {
12335
12420
  */ _proto.loadScene = function loadScene(url, destroyOldScene) {
12336
12421
  if (destroyOldScene === void 0) destroyOldScene = true;
12337
12422
  var _this = this;
12338
- var scenePromise = this.engine.resourceManager.load(url);
12423
+ var scenePromise = this.engine.resourceManager.load({
12424
+ url: url,
12425
+ type: exports.AssetType.Scene
12426
+ });
12339
12427
  scenePromise.then(function(scene) {
12340
- var scenes = _this._scenes;
12341
12428
  if (destroyOldScene) {
12429
+ var scenes = _this._scenes.getArray();
12342
12430
  for(var i = 0, n = scenes.length; i < n; i++){
12343
12431
  scenes[i].destroy();
12344
12432
  }
@@ -12547,6 +12635,7 @@ var /** @internal */ PromiseState;
12547
12635
  this._referResourcePool = Object.create(null);
12548
12636
  this._graphicResourcePool = Object.create(null);
12549
12637
  this._contentRestorerPool = Object.create(null);
12638
+ this._subAssetPromiseCallbacks = {};
12550
12639
  this.//-----------------Editor temp solution-----------------
12551
12640
  /** @internal */ _objectPool = Object.create(null);
12552
12641
  this./** @internal */ _editorResourceConfig = Object.create(null);
@@ -12574,6 +12663,21 @@ var /** @internal */ PromiseState;
12574
12663
  return (_this__assetUrlPool_url = this._assetUrlPool[url]) != null ? _this__assetUrlPool_url : null;
12575
12664
  };
12576
12665
  /**
12666
+ * Find the resource by type.
12667
+ * @param type - Resource type
12668
+ * @returns - Resource collection
12669
+ */ _proto.findResourcesByType = function findResourcesByType(type) {
12670
+ var resources = new Array();
12671
+ var referResourcePool = this._referResourcePool;
12672
+ for(var k in referResourcePool){
12673
+ var resource = referResourcePool[k];
12674
+ if (_instanceof(resource, type)) {
12675
+ resources.push(resource);
12676
+ }
12677
+ }
12678
+ return resources;
12679
+ };
12680
+ /**
12577
12681
  * Get asset url from instanceId.
12578
12682
  * @param instanceId - Engine instance id
12579
12683
  * @returns Asset url
@@ -12611,6 +12715,20 @@ var /** @internal */ PromiseState;
12611
12715
  };
12612
12716
  /**
12613
12717
  * @internal
12718
+ */ _proto._onSubAssetSuccess = function _onSubAssetSuccess(assetURL, value) {
12719
+ var _this__subAssetPromiseCallbacks_assetURL;
12720
+ (_this__subAssetPromiseCallbacks_assetURL = this._subAssetPromiseCallbacks[assetURL]) == null ? void 0 : _this__subAssetPromiseCallbacks_assetURL.resolve(value);
12721
+ delete this._subAssetPromiseCallbacks[assetURL];
12722
+ };
12723
+ /**
12724
+ * @internal
12725
+ */ _proto._onSubAssetFail = function _onSubAssetFail(assetURL, value) {
12726
+ var _this__subAssetPromiseCallbacks_assetURL;
12727
+ (_this__subAssetPromiseCallbacks_assetURL = this._subAssetPromiseCallbacks[assetURL]) == null ? void 0 : _this__subAssetPromiseCallbacks_assetURL.reject(value);
12728
+ delete this._subAssetPromiseCallbacks[assetURL];
12729
+ };
12730
+ /**
12731
+ * @internal
12614
12732
  */ _proto._addAsset = function _addAsset(path, asset) {
12615
12733
  this._assetPool[asset.instanceId] = path;
12616
12734
  this._assetUrlPool[path] = asset;
@@ -12720,6 +12838,10 @@ var /** @internal */ PromiseState;
12720
12838
  var assetURL = assetBaseURL;
12721
12839
  if (queryPath) {
12722
12840
  assetURL += "?q=" + paths.shift();
12841
+ var index;
12842
+ while(index = paths.shift()){
12843
+ assetURL += "[" + index + "]";
12844
+ }
12723
12845
  }
12724
12846
  // Check is loading
12725
12847
  var loadingPromises = this._loadingPromises;
@@ -12727,7 +12849,7 @@ var /** @internal */ PromiseState;
12727
12849
  if (loadingPromise) {
12728
12850
  return new AssetPromise(function(resolve, reject) {
12729
12851
  loadingPromise.then(function(resource) {
12730
- resolve(_this._getResolveResource(resource, paths));
12852
+ resolve(resource);
12731
12853
  }).catch(function(error) {
12732
12854
  reject(error);
12733
12855
  });
@@ -12741,38 +12863,37 @@ var /** @internal */ PromiseState;
12741
12863
  // Load asset
12742
12864
  item.url = assetBaseURL;
12743
12865
  var promise = loader.load(item, this);
12744
- if (_instanceof(promise, AssetPromise)) {
12745
- loadingPromises[assetBaseURL] = promise;
12746
- promise.then(function(resource) {
12747
- if (loader.useCache) {
12748
- _this._addAsset(assetBaseURL, resource);
12749
- }
12750
- delete loadingPromises[assetBaseURL];
12866
+ loadingPromises[assetBaseURL] = promise;
12867
+ promise.then(function(resource) {
12868
+ if (loader.useCache) {
12869
+ _this._addAsset(assetBaseURL, resource);
12870
+ }
12871
+ delete loadingPromises[assetBaseURL];
12872
+ }, function() {
12873
+ return delete loadingPromises[assetBaseURL];
12874
+ });
12875
+ if (queryPath) {
12876
+ var subPromise = new AssetPromise(function(resolve, reject) {
12877
+ _this._pushSubAssetPromiseCallback(assetURL, resolve, reject);
12878
+ });
12879
+ loadingPromises[assetURL] = subPromise;
12880
+ subPromise.then(function() {
12881
+ delete loadingPromises[assetURL];
12751
12882
  }, function() {
12752
- return delete loadingPromises[assetBaseURL];
12883
+ return delete loadingPromises[assetURL];
12753
12884
  });
12754
- return promise;
12755
- } else {
12756
- var _loop = function(subURL) {
12757
- var subPromise = promise[subURL];
12758
- var isMaster = assetBaseURL === subURL;
12759
- loadingPromises[subURL] = subPromise;
12760
- subPromise.then(function(resource) {
12761
- if (isMaster) {
12762
- if (loader.useCache) {
12763
- _this._addAsset(subURL, resource);
12764
- for(var k in promise)delete loadingPromises[k];
12765
- }
12766
- }
12767
- }, function() {
12768
- for(var k in promise)delete loadingPromises[k];
12769
- });
12770
- };
12771
- for(var subURL in promise)_loop(subURL);
12772
- return promise[assetURL].then(function(resource) {
12773
- return _this._getResolveResource(resource, paths);
12885
+ promise.catch(function(e) {
12886
+ _this._onSubAssetFail(assetURL, e);
12774
12887
  });
12888
+ return subPromise;
12775
12889
  }
12890
+ return promise;
12891
+ };
12892
+ _proto._pushSubAssetPromiseCallback = function _pushSubAssetPromiseCallback(assetURL, resolve, reject) {
12893
+ this._subAssetPromiseCallbacks[assetURL] = {
12894
+ resolve: resolve,
12895
+ reject: reject
12896
+ };
12776
12897
  };
12777
12898
  _proto._gc = function _gc(forceDestroy) {
12778
12899
  var objects = Utils.objectValues(this._referResourcePool);
@@ -12935,17 +13056,21 @@ var rePropName = RegExp(// Match anything that isn't a dot or bracket.
12935
13056
  if (this._currentEnteredEntity !== rayCastEntity) {
12936
13057
  if (this._currentEnteredEntity) {
12937
13058
  var scripts = this._currentEnteredEntity._scripts;
12938
- for(var i = scripts.length - 1; i >= 0; i--){
12939
- var script = scripts.get(i);
12940
- script._waitHandlingInValid || script.onPointerExit(this);
13059
+ scripts.startLoop();
13060
+ for(var i = 0; i < scripts.length; i++){
13061
+ var _scripts_get;
13062
+ (_scripts_get = scripts.get(i)) == null ? void 0 : _scripts_get.onPointerExit(this);
12941
13063
  }
13064
+ scripts.endLoop();
12942
13065
  }
12943
13066
  if (rayCastEntity) {
12944
13067
  var scripts1 = rayCastEntity._scripts;
12945
- for(var i1 = scripts1.length - 1; i1 >= 0; i1--){
12946
- var script1 = scripts1.get(i1);
12947
- script1._waitHandlingInValid || script1.onPointerEnter(this);
13068
+ scripts1.startLoop();
13069
+ for(var i1 = 0; i1 < scripts1.length; i1++){
13070
+ var _scripts_get1;
13071
+ (_scripts_get1 = scripts1.get(i1)) == null ? void 0 : _scripts_get1.onPointerEnter(this);
12948
13072
  }
13073
+ scripts1.endLoop();
12949
13074
  }
12950
13075
  this._currentEnteredEntity = rayCastEntity;
12951
13076
  }
@@ -12955,10 +13080,12 @@ var rePropName = RegExp(// Match anything that isn't a dot or bracket.
12955
13080
  */ _proto._firePointerDown = function _firePointerDown(rayCastEntity) {
12956
13081
  if (rayCastEntity) {
12957
13082
  var scripts = rayCastEntity._scripts;
12958
- for(var i = scripts.length - 1; i >= 0; i--){
12959
- var script = scripts.get(i);
12960
- script._waitHandlingInValid || script.onPointerDown(this);
13083
+ scripts.startLoop();
13084
+ for(var i = 0; i < scripts.length; i++){
13085
+ var _scripts_get;
13086
+ (_scripts_get = scripts.get(i)) == null ? void 0 : _scripts_get.onPointerDown(this);
12961
13087
  }
13088
+ scripts.endLoop();
12962
13089
  }
12963
13090
  this._currentPressedEntity = rayCastEntity;
12964
13091
  };
@@ -12967,10 +13094,12 @@ var rePropName = RegExp(// Match anything that isn't a dot or bracket.
12967
13094
  */ _proto._firePointerDrag = function _firePointerDrag() {
12968
13095
  if (this._currentPressedEntity) {
12969
13096
  var scripts = this._currentPressedEntity._scripts;
12970
- for(var i = scripts.length - 1; i >= 0; i--){
12971
- var script = scripts.get(i);
12972
- script._waitHandlingInValid || script.onPointerDrag(this);
13097
+ scripts.startLoop();
13098
+ for(var i = 0; i < scripts.length; i++){
13099
+ var _scripts_get;
13100
+ (_scripts_get = scripts.get(i)) == null ? void 0 : _scripts_get.onPointerDrag(this);
12973
13101
  }
13102
+ scripts.endLoop();
12974
13103
  }
12975
13104
  };
12976
13105
  /**
@@ -12980,13 +13109,15 @@ var rePropName = RegExp(// Match anything that isn't a dot or bracket.
12980
13109
  if (pressedEntity) {
12981
13110
  var sameTarget = pressedEntity === rayCastEntity;
12982
13111
  var scripts = pressedEntity._scripts;
12983
- for(var i = scripts.length - 1; i >= 0; i--){
13112
+ scripts.startLoop();
13113
+ for(var i = 0; i < scripts.length; i++){
12984
13114
  var script = scripts.get(i);
12985
- if (!script._waitHandlingInValid) {
13115
+ if (script) {
12986
13116
  sameTarget && script.onPointerClick(this);
12987
13117
  script.onPointerUp(this);
12988
13118
  }
12989
13119
  }
13120
+ scripts.endLoop();
12990
13121
  this._currentPressedEntity = null;
12991
13122
  }
12992
13123
  };
@@ -13582,6 +13713,7 @@ var Collision = function Collision() {
13582
13713
  function PhysicsScene(scene) {
13583
13714
  var _this = this;
13584
13715
  this._restTime = 0;
13716
+ this._fixedTimeStep = 1 / 60;
13585
13717
  this._colliders = new DisorderedArray();
13586
13718
  this._gravity = new miniprogram.Vector3(0, -9.81, 0);
13587
13719
  this._onContactEnter = function(obj1, obj2) {
@@ -13589,116 +13721,139 @@ var Collision = function Collision() {
13589
13721
  var shape1 = physicalObjectsMap[obj1];
13590
13722
  var shape2 = physicalObjectsMap[obj2];
13591
13723
  var scripts = shape1.collider.entity._scripts;
13592
- for(var i = 0, len = scripts.length; i < len; i++){
13724
+ scripts.startLoop();
13725
+ for(var i = 0; i < scripts.length; i++){
13593
13726
  var script = scripts.get(i);
13594
- if (!script._waitHandlingInValid) {
13727
+ if (script) {
13595
13728
  var collision = PhysicsScene._collision;
13596
13729
  collision.shape = shape2;
13597
13730
  script.onCollisionEnter(collision);
13598
13731
  }
13599
13732
  }
13733
+ scripts.endLoop();
13600
13734
  scripts = shape2.collider.entity._scripts;
13601
- for(var i1 = 0, len1 = scripts.length; i1 < len1; i1++){
13735
+ scripts.startLoop();
13736
+ for(var i1 = 0; i1 < scripts.length; i1++){
13602
13737
  var script1 = scripts.get(i1);
13603
- if (!script1._waitHandlingInValid) {
13738
+ if (script1) {
13604
13739
  var collision1 = PhysicsScene._collision;
13605
13740
  collision1.shape = shape1;
13606
13741
  script1.onCollisionEnter(collision1);
13607
13742
  }
13608
13743
  }
13744
+ scripts.endLoop();
13609
13745
  };
13610
13746
  this._onContactExit = function(obj1, obj2) {
13611
13747
  var physicalObjectsMap = _this._scene.engine._physicalObjectsMap;
13612
13748
  var shape1 = physicalObjectsMap[obj1];
13613
13749
  var shape2 = physicalObjectsMap[obj2];
13614
13750
  var scripts = shape1.collider.entity._scripts;
13615
- for(var i = 0, len = scripts.length; i < len; i++){
13751
+ scripts.startLoop();
13752
+ for(var i = 0; i < scripts.length; i++){
13616
13753
  var script = scripts.get(i);
13617
- if (!script._waitHandlingInValid) {
13754
+ if (script) {
13618
13755
  var collision = PhysicsScene._collision;
13619
13756
  collision.shape = shape2;
13620
13757
  script.onCollisionExit(collision);
13621
13758
  }
13622
13759
  }
13760
+ scripts.endLoop();
13623
13761
  scripts = shape2.collider.entity._scripts;
13624
- for(var i1 = 0, len1 = scripts.length; i1 < len1; i1++){
13762
+ scripts.startLoop();
13763
+ for(var i1 = 0; i1 < scripts.length; i1++){
13625
13764
  var script1 = scripts.get(i1);
13626
- if (!script1._waitHandlingInValid) {
13765
+ if (script1) {
13627
13766
  var collision1 = PhysicsScene._collision;
13628
13767
  collision1.shape = shape1;
13629
13768
  script1.onCollisionExit(collision1);
13630
13769
  }
13631
13770
  }
13771
+ scripts.endLoop();
13632
13772
  };
13633
13773
  this._onContactStay = function(obj1, obj2) {
13634
13774
  var physicalObjectsMap = _this._scene.engine._physicalObjectsMap;
13635
13775
  var shape1 = physicalObjectsMap[obj1];
13636
13776
  var shape2 = physicalObjectsMap[obj2];
13637
13777
  var scripts = shape1.collider.entity._scripts;
13638
- for(var i = 0, len = scripts.length; i < len; i++){
13778
+ scripts.startLoop();
13779
+ for(var i = 0; i < scripts.length; i++){
13639
13780
  var script = scripts.get(i);
13640
- if (!script._waitHandlingInValid) {
13781
+ if (script) {
13641
13782
  var collision = PhysicsScene._collision;
13642
13783
  collision.shape = shape2;
13643
13784
  script.onCollisionStay(collision);
13644
13785
  }
13645
13786
  }
13787
+ scripts.endLoop();
13646
13788
  scripts = shape2.collider.entity._scripts;
13647
- for(var i1 = 0, len1 = scripts.length; i1 < len1; i1++){
13789
+ scripts.startLoop();
13790
+ for(var i1 = 0; i1 < scripts.length; i1++){
13648
13791
  var script1 = scripts.get(i1);
13649
- if (!script1._waitHandlingInValid) {
13792
+ if (script1) {
13650
13793
  var collision1 = PhysicsScene._collision;
13651
13794
  collision1.shape = shape1;
13652
13795
  script1.onCollisionStay(collision1);
13653
13796
  }
13654
13797
  }
13798
+ scripts.endLoop();
13655
13799
  };
13656
13800
  this._onTriggerEnter = function(obj1, obj2) {
13657
13801
  var physicalObjectsMap = _this._scene.engine._physicalObjectsMap;
13658
13802
  var shape1 = physicalObjectsMap[obj1];
13659
13803
  var shape2 = physicalObjectsMap[obj2];
13660
13804
  var scripts = shape1.collider.entity._scripts;
13661
- for(var i = 0, len = scripts.length; i < len; i++){
13662
- var script = scripts.get(i);
13663
- script._waitHandlingInValid || script.onTriggerEnter(shape2);
13805
+ scripts.startLoop();
13806
+ for(var i = 0; i < scripts.length; i++){
13807
+ var _scripts_get;
13808
+ (_scripts_get = scripts.get(i)) == null ? void 0 : _scripts_get.onTriggerEnter(shape2);
13664
13809
  }
13810
+ scripts.endLoop();
13665
13811
  scripts = shape2.collider.entity._scripts;
13666
- for(var i1 = 0, len1 = scripts.length; i1 < len1; i1++){
13667
- var script1 = scripts.get(i1);
13668
- script1._waitHandlingInValid || script1.onTriggerEnter(shape1);
13812
+ scripts.startLoop();
13813
+ for(var i1 = 0; i1 < scripts.length; i1++){
13814
+ var _scripts_get1;
13815
+ (_scripts_get1 = scripts.get(i1)) == null ? void 0 : _scripts_get1.onTriggerEnter(shape1);
13669
13816
  }
13817
+ scripts.endLoop();
13670
13818
  };
13671
13819
  this._onTriggerExit = function(obj1, obj2) {
13672
13820
  var physicalObjectsMap = _this._scene.engine._physicalObjectsMap;
13673
13821
  var shape1 = physicalObjectsMap[obj1];
13674
13822
  var shape2 = physicalObjectsMap[obj2];
13675
13823
  var scripts = shape1.collider.entity._scripts;
13676
- for(var i = 0, n = scripts.length; i < n; i++){
13677
- var script = scripts.get(i);
13678
- script._waitHandlingInValid || script.onTriggerExit(shape2);
13824
+ scripts.startLoop();
13825
+ for(var i = 0; i < scripts.length; i++){
13826
+ var _scripts_get;
13827
+ (_scripts_get = scripts.get(i)) == null ? void 0 : _scripts_get.onTriggerExit(shape2);
13679
13828
  }
13829
+ scripts.endLoop();
13680
13830
  scripts = shape2.collider.entity._scripts;
13681
- for(var i1 = 0, n1 = scripts.length; i1 < n1; i1++){
13682
- var script1 = scripts.get(i1);
13683
- script1._waitHandlingInValid || script1.onTriggerExit(shape1);
13831
+ scripts.startLoop();
13832
+ for(var i1 = 0; i1 < scripts.length; i1++){
13833
+ var _scripts_get1;
13834
+ (_scripts_get1 = scripts.get(i1)) == null ? void 0 : _scripts_get1.onTriggerExit(shape1);
13684
13835
  }
13836
+ scripts.endLoop();
13685
13837
  };
13686
13838
  this._onTriggerStay = function(obj1, obj2) {
13687
13839
  var physicalObjectsMap = _this._scene.engine._physicalObjectsMap;
13688
13840
  var shape1 = physicalObjectsMap[obj1];
13689
13841
  var shape2 = physicalObjectsMap[obj2];
13690
13842
  var scripts = shape1.collider.entity._scripts;
13691
- for(var i = 0, len = scripts.length; i < len; i++){
13692
- var script = scripts.get(i);
13693
- script._waitHandlingInValid || script.onTriggerStay(shape2);
13843
+ scripts.startLoop();
13844
+ for(var i = 0; i < scripts.length; i++){
13845
+ var _scripts_get;
13846
+ (_scripts_get = scripts.get(i)) == null ? void 0 : _scripts_get.onTriggerStay(shape2);
13694
13847
  }
13848
+ scripts.endLoop();
13695
13849
  scripts = shape2.collider.entity._scripts;
13696
- for(var i1 = 0, len1 = scripts.length; i1 < len1; i1++){
13697
- var script1 = scripts.get(i1);
13698
- script1._waitHandlingInValid || script1.onTriggerStay(shape1);
13850
+ scripts.startLoop();
13851
+ for(var i1 = 0; i1 < scripts.length; i1++){
13852
+ var _scripts_get1;
13853
+ (_scripts_get1 = scripts.get(i1)) == null ? void 0 : _scripts_get1.onTriggerStay(shape1);
13699
13854
  }
13855
+ scripts.endLoop();
13700
13856
  };
13701
- /** The fixed time step in seconds at which physics are performed. */ this.fixedTimeStep = 1 / 60;
13702
13857
  this._scene = scene;
13703
13858
  this._setGravity = this._setGravity.bind(this);
13704
13859
  //@ts-ignore
@@ -13755,7 +13910,7 @@ var Collision = function Collision() {
13755
13910
  * Call on every frame to update pose of objects.
13756
13911
  * @internal
13757
13912
  */ _proto._update = function _update(deltaTime) {
13758
- var _this = this, fixedTimeStep = _this.fixedTimeStep, nativePhysicsManager = _this._nativePhysicsScene;
13913
+ var _this = this, fixedTimeStep = _this._fixedTimeStep, nativePhysicsManager = _this._nativePhysicsScene;
13759
13914
  var componentsManager = this._scene._componentsManager;
13760
13915
  var simulateTime = this._restTime + deltaTime;
13761
13916
  var step = Math.floor(simulateTime / fixedTimeStep);
@@ -13863,6 +14018,17 @@ var Collision = function Collision() {
13863
14018
  gravity.copyFrom(value);
13864
14019
  }
13865
14020
  }
14021
+ },
14022
+ {
14023
+ key: "fixedTimeStep",
14024
+ get: /**
14025
+ * The fixed time step in seconds at which physics are performed.
14026
+ */ function get() {
14027
+ return this._fixedTimeStep;
14028
+ },
14029
+ set: function set(value) {
14030
+ this._fixedTimeStep = Math.max(value, miniprogram.MathUtil.zeroTolerance);
14031
+ }
13866
14032
  }
13867
14033
  ]);
13868
14034
  return PhysicsScene;
@@ -15736,6 +15902,7 @@ exports.Joint = __decorate([
15736
15902
  CloneManager.deepCloneObject(this.renderStates, target.renderStates);
15737
15903
  };
15738
15904
  _proto._addReferCount = function _addReferCount(value) {
15905
+ if (this._destroyed) return;
15739
15906
  ReferResource.prototype._addReferCount.call(this, value);
15740
15907
  this.shaderData._addReferCount(value);
15741
15908
  };
@@ -16823,7 +16990,6 @@ ShaderPool.init();
16823
16990
  this._onUpdateScripts = new DisorderedArray();
16824
16991
  this._onLateUpdateScripts = new DisorderedArray();
16825
16992
  this._onPhysicsUpdateScripts = new DisorderedArray();
16826
- this._disableScripts = [];
16827
16993
  this._pendingDestroyScripts = [];
16828
16994
  this._disposeDestroyScripts = [];
16829
16995
  // Animation
@@ -16901,102 +17067,110 @@ ShaderPool.init();
16901
17067
  replaced && (replaced._onUpdateIndex = renderer._onUpdateIndex);
16902
17068
  renderer._onUpdateIndex = -1;
16903
17069
  };
16904
- _proto.addDisableScript = function addDisableScript(component) {
16905
- this._disableScripts.push(component);
16906
- };
16907
17070
  _proto.addPendingDestroyScript = function addPendingDestroyScript(component) {
16908
17071
  this._pendingDestroyScripts.push(component);
16909
17072
  };
16910
17073
  _proto.callScriptOnStart = function callScriptOnStart() {
16911
17074
  var onStartScripts = this._onStartScripts;
16912
17075
  if (onStartScripts.length > 0) {
17076
+ onStartScripts.startLoop();
16913
17077
  var elements = onStartScripts._elements;
16914
17078
  // The 'onStartScripts.length' maybe add if you add some Script with addComponent() in some Script's onStart()
16915
17079
  for(var i = 0; i < onStartScripts.length; i++){
16916
17080
  var script = elements[i];
16917
- if (!script._waitHandlingInValid) {
17081
+ if (script) {
16918
17082
  script._started = true;
16919
- script._onStartIndex = -1;
17083
+ this.removeOnStartScript(script);
16920
17084
  script.onStart();
16921
17085
  }
16922
17086
  }
16923
- onStartScripts.length = 0;
17087
+ onStartScripts.endLoopAndClear();
16924
17088
  }
16925
17089
  };
16926
17090
  _proto.callScriptOnUpdate = function callScriptOnUpdate(deltaTime) {
16927
- var elements = this._onUpdateScripts._elements;
16928
- for(var i = this._onUpdateScripts.length - 1; i >= 0; --i){
17091
+ var onUpdateScripts = this._onUpdateScripts;
17092
+ onUpdateScripts.startLoop();
17093
+ var elements = onUpdateScripts._elements;
17094
+ for(var i = 0; i < onUpdateScripts.length; i++){
16929
17095
  var element = elements[i];
16930
- if (!element._waitHandlingInValid && element._started) {
17096
+ if (element == null ? void 0 : element._started) {
16931
17097
  element.onUpdate(deltaTime);
16932
17098
  }
16933
17099
  }
17100
+ onUpdateScripts.endLoop();
16934
17101
  };
16935
17102
  _proto.callScriptOnLateUpdate = function callScriptOnLateUpdate(deltaTime) {
16936
- var elements = this._onLateUpdateScripts._elements;
16937
- for(var i = this._onLateUpdateScripts.length - 1; i >= 0; --i){
17103
+ var onLateUpdateScripts = this._onLateUpdateScripts;
17104
+ onLateUpdateScripts.startLoop();
17105
+ var elements = onLateUpdateScripts._elements;
17106
+ for(var i = 0; i < onLateUpdateScripts.length; i++){
16938
17107
  var element = elements[i];
16939
- if (!element._waitHandlingInValid && element._started) {
17108
+ if (element == null ? void 0 : element._started) {
16940
17109
  element.onLateUpdate(deltaTime);
16941
17110
  }
16942
17111
  }
17112
+ onLateUpdateScripts.endLoop();
16943
17113
  };
16944
17114
  _proto.callScriptOnPhysicsUpdate = function callScriptOnPhysicsUpdate() {
16945
- var elements = this._onPhysicsUpdateScripts._elements;
16946
- for(var i = this._onPhysicsUpdateScripts.length - 1; i >= 0; --i){
17115
+ var onPhysicsUpdateScripts = this._onPhysicsUpdateScripts;
17116
+ onPhysicsUpdateScripts.startLoop();
17117
+ var elements = onPhysicsUpdateScripts._elements;
17118
+ for(var i = 0; i < onPhysicsUpdateScripts.length; i++){
16947
17119
  var element = elements[i];
16948
- if (!element._waitHandlingInValid && element._started) {
17120
+ if (element == null ? void 0 : element._started) {
16949
17121
  element.onPhysicsUpdate();
16950
17122
  }
16951
17123
  }
17124
+ onPhysicsUpdateScripts.endLoop();
16952
17125
  };
16953
17126
  _proto.callAnimationUpdate = function callAnimationUpdate(deltaTime) {
16954
- var elements = this._onUpdateAnimations._elements;
16955
- for(var i = this._onUpdateAnimations.length - 1; i >= 0; --i){
17127
+ var onUpdateAnimations = this._onUpdateAnimations;
17128
+ onUpdateAnimations.startLoop();
17129
+ var elements = onUpdateAnimations._elements;
17130
+ for(var i = 0; i < onUpdateAnimations.length; i++){
16956
17131
  //@ts-ignore
16957
17132
  elements[i].update(deltaTime);
16958
17133
  }
17134
+ onUpdateAnimations.endLoop();
16959
17135
  };
16960
17136
  _proto.callRendererOnUpdate = function callRendererOnUpdate(deltaTime) {
16961
- var elements = this._onUpdateRenderers._elements;
16962
- for(var i = this._onUpdateRenderers.length - 1; i >= 0; --i){
17137
+ var onUpdateRenderers = this._onUpdateRenderers;
17138
+ onUpdateRenderers.startLoop();
17139
+ var elements = onUpdateRenderers._elements;
17140
+ for(var i = 0; i < onUpdateRenderers.length; i++){
16963
17141
  elements[i].update(deltaTime);
16964
17142
  }
17143
+ onUpdateRenderers.endLoop();
16965
17144
  };
16966
17145
  _proto.handlingInvalidScripts = function handlingInvalidScripts() {
16967
- var _this = this, disableScripts = _this._disableScripts;
16968
- var length = disableScripts.length;
16969
- if (length > 0) {
16970
- for(var i = length - 1; i >= 0; i--){
16971
- var disableScript = disableScripts[i];
16972
- disableScript._waitHandlingInValid && disableScript._handlingInValid();
16973
- }
16974
- disableScripts.length = 0;
16975
- }
16976
- var _this1 = this, pendingDestroyScripts = _this1._disposeDestroyScripts, disposeDestroyScripts = _this1._pendingDestroyScripts;
17146
+ var _this = this, pendingDestroyScripts = _this._disposeDestroyScripts, disposeDestroyScripts = _this._pendingDestroyScripts;
16977
17147
  this._disposeDestroyScripts = disposeDestroyScripts;
16978
17148
  this._pendingDestroyScripts = pendingDestroyScripts;
16979
17149
  length = disposeDestroyScripts.length;
16980
17150
  if (length > 0) {
16981
- for(var i1 = length - 1; i1 >= 0; i1--){
16982
- disposeDestroyScripts[i1].onDestroy();
17151
+ for(var i = length - 1; i >= 0; i--){
17152
+ disposeDestroyScripts[i].onDestroy();
16983
17153
  }
16984
17154
  disposeDestroyScripts.length = 0;
16985
17155
  }
16986
17156
  };
16987
17157
  _proto.callCameraOnBeginRender = function callCameraOnBeginRender(camera) {
16988
17158
  var scripts = camera.entity._scripts;
16989
- for(var i = scripts.length - 1; i >= 0; --i){
16990
- var script = scripts.get(i);
16991
- script._waitHandlingInValid || script.onBeginRender(camera);
17159
+ scripts.startLoop();
17160
+ for(var i = 0; i < scripts.length; i++){
17161
+ var _scripts_get;
17162
+ (_scripts_get = scripts.get(i)) == null ? void 0 : _scripts_get.onBeginRender(camera);
16992
17163
  }
17164
+ scripts.endLoop();
16993
17165
  };
16994
17166
  _proto.callCameraOnEndRender = function callCameraOnEndRender(camera) {
16995
17167
  var scripts = camera.entity._scripts;
16996
- for(var i = scripts.length - 1; i >= 0; --i){
16997
- var script = scripts.get(i);
16998
- script._waitHandlingInValid || script.onEndRender(camera);
17168
+ scripts.startLoop();
17169
+ for(var i = 0; i < scripts.length; i++){
17170
+ var _scripts_get;
17171
+ (_scripts_get = scripts.get(i)) == null ? void 0 : _scripts_get.onEndRender(camera);
16999
17172
  }
17173
+ scripts.endLoop();
17000
17174
  };
17001
17175
  _proto.getActiveChangedTempList = function getActiveChangedTempList() {
17002
17176
  return this._componentsContainerPool.length ? this._componentsContainerPool.pop() : [];
@@ -17967,19 +18141,20 @@ __decorate([
17967
18141
  }
17968
18142
  // Process entity active/inActive
17969
18143
  var inActiveChangeFlag = ActiveChangeFlag.None;
17970
- if (this._isActiveInEngine) {
17971
- // Cross scene should inActive first and then active
17972
- entity._isActiveInHierarchy && oldScene !== this && (inActiveChangeFlag |= ActiveChangeFlag.Scene);
17973
- } else {
17974
- entity._isActiveInHierarchy && (inActiveChangeFlag |= ActiveChangeFlag.Hierarchy);
18144
+ if (entity._isActiveInHierarchy) {
18145
+ this._isActiveInEngine || (inActiveChangeFlag |= ActiveChangeFlag.Hierarchy);
17975
18146
  }
18147
+ // Cross scene should inActive first and then active
18148
+ entity._isActiveInScene && oldScene !== this && (inActiveChangeFlag |= ActiveChangeFlag.Scene);
17976
18149
  inActiveChangeFlag && entity._processInActive(inActiveChangeFlag);
17977
18150
  if (oldScene !== this) {
17978
18151
  Entity._traverseSetOwnerScene(entity, this);
17979
18152
  }
17980
18153
  var activeChangeFlag = ActiveChangeFlag.None;
17981
- if (this._isActiveInEngine && entity._isActive) {
17982
- !entity._isActiveInHierarchy && (activeChangeFlag |= ActiveChangeFlag.Hierarchy);
18154
+ if (entity._isActive) {
18155
+ if (this._isActiveInEngine) {
18156
+ !entity._isActiveInHierarchy && (activeChangeFlag |= ActiveChangeFlag.Hierarchy);
18157
+ }
17983
18158
  (!entity._isActiveInScene || oldScene !== this) && (activeChangeFlag |= ActiveChangeFlag.Scene);
17984
18159
  }
17985
18160
  activeChangeFlag && entity._processActive(activeChangeFlag);
@@ -18335,7 +18510,6 @@ __decorate([
18335
18510
  /** @internal */ _this._onPreRenderIndex = -1;
18336
18511
  /** @internal */ _this._onPostRenderIndex = -1;
18337
18512
  _this._entityScriptsIndex = -1;
18338
- _this._waitHandlingInValid = false;
18339
18513
  return _this;
18340
18514
  }
18341
18515
  var _proto = Script.prototype;
@@ -18444,37 +18618,30 @@ __decorate([
18444
18618
  /**
18445
18619
  * @internal
18446
18620
  */ _proto._onEnableInScene = function _onEnableInScene() {
18447
- if (this._waitHandlingInValid) {
18448
- this._waitHandlingInValid = false;
18449
- } else {
18450
- var _this_scene = this.scene, componentsManager = _this_scene._componentsManager;
18451
- var prototype = Script.prototype;
18452
- if (!this._started) {
18453
- componentsManager.addOnStartScript(this);
18454
- }
18455
- if (this.onUpdate !== prototype.onUpdate) {
18456
- componentsManager.addOnUpdateScript(this);
18457
- }
18458
- if (this.onLateUpdate !== prototype.onLateUpdate) {
18459
- componentsManager.addOnLateUpdateScript(this);
18460
- }
18461
- if (this.onPhysicsUpdate !== prototype.onPhysicsUpdate) {
18462
- componentsManager.addOnPhysicsUpdateScript(this);
18463
- }
18464
- this._entity._addScript(this);
18621
+ var _this_scene = this.scene, componentsManager = _this_scene._componentsManager;
18622
+ var prototype = Script.prototype;
18623
+ if (!this._started) {
18624
+ componentsManager.addOnStartScript(this);
18625
+ }
18626
+ if (this.onUpdate !== prototype.onUpdate) {
18627
+ componentsManager.addOnUpdateScript(this);
18628
+ }
18629
+ if (this.onLateUpdate !== prototype.onLateUpdate) {
18630
+ componentsManager.addOnLateUpdateScript(this);
18631
+ }
18632
+ if (this.onPhysicsUpdate !== prototype.onPhysicsUpdate) {
18633
+ componentsManager.addOnPhysicsUpdateScript(this);
18465
18634
  }
18635
+ this._entity._addScript(this);
18466
18636
  };
18467
18637
  /**
18468
18638
  * @internal
18469
18639
  */ _proto._onDisableInScene = function _onDisableInScene() {
18470
- this._waitHandlingInValid = true;
18471
- this.scene._componentsManager.addDisableScript(this);
18472
- };
18473
- /**
18474
- * @internal
18475
- */ _proto._handlingInValid = function _handlingInValid() {
18476
18640
  var componentsManager = this.scene._componentsManager;
18477
18641
  var prototype = Script.prototype;
18642
+ if (!this._started) {
18643
+ componentsManager.removeOnStartScript(this);
18644
+ }
18478
18645
  if (this.onUpdate !== prototype.onUpdate) {
18479
18646
  componentsManager.removeOnUpdateScript(this);
18480
18647
  }
@@ -18485,7 +18652,6 @@ __decorate([
18485
18652
  componentsManager.removeOnPhysicsUpdateScript(this);
18486
18653
  }
18487
18654
  this._entity._removeScript(this);
18488
- this._waitHandlingInValid = false;
18489
18655
  };
18490
18656
  /**
18491
18657
  * @internal
@@ -18519,9 +18685,6 @@ __decorate([
18519
18685
  __decorate([
18520
18686
  ignoreClone
18521
18687
  ], Script.prototype, "_entityScriptsIndex", void 0);
18522
- __decorate([
18523
- ignoreClone
18524
- ], Script.prototype, "_waitHandlingInValid", void 0);
18525
18688
 
18526
18689
  /**
18527
18690
  * Depth texture mode.
@@ -20836,41 +20999,6 @@ var MultiExecutor = /*#__PURE__*/ function() {
20836
20999
  Loader._engineObjects = {};
20837
21000
  })();
20838
21001
 
20839
- /**
20840
- * Asset Type.
20841
- */ exports.AssetType = void 0;
20842
- (function(AssetType) {
20843
- AssetType[/**
20844
- * Plain text.
20845
- * @remarks Will not be cached based on url in ResourceManager.
20846
- */ "Text"] = "Text";
20847
- AssetType[/**
20848
- * JSON.
20849
- * @remarks Will not be cached based on url in ResourceManager.
20850
- */ "JSON"] = "JSON";
20851
- AssetType[/**
20852
- * ArrayBuffer.
20853
- * @remarks Will not be cached based on url in ResourceManager.
20854
- */ "Buffer"] = "Buffer";
20855
- AssetType[/** 2D Texture. */ "Texture2D"] = "Texture2D";
20856
- AssetType[/** Cube Texture. */ "TextureCube"] = "TextureCube";
20857
- AssetType[/** Material. */ "Material"] = "Material";
20858
- AssetType[/** Mesh. */ "Mesh"] = "Mesh";
20859
- AssetType[/** AnimationClip. */ "AnimationClip"] = "AnimationClip";
20860
- AssetType[/** AnimatorController. */ "AnimatorController"] = "AnimatorController";
20861
- AssetType[/** Prefab.*/ "GLTF"] = "GLTF";
20862
- AssetType[/** Compress Texture. */ "KTX"] = "KTX";
20863
- AssetType[/** Cube Compress Texture. */ "KTXCube"] = "KTXCube";
20864
- AssetType[/** KTX2 Compress Texture */ "KTX2"] = "KTX2";
20865
- AssetType[/** Sprite. */ "Sprite"] = "Sprite";
20866
- AssetType[/** Sprite Atlas. */ "SpriteAtlas"] = "SpriteAtlas";
20867
- AssetType[/** Ambient light. */ "Env"] = "Environment";
20868
- AssetType[/** Scene. */ "Scene"] = "Scene";
20869
- AssetType[/** HDR to cube. */ "HDR"] = "HDR";
20870
- AssetType[/** Font. */ "Font"] = "Font";
20871
- AssetType[/** Source Font, include ttf、 otf and woff. */ "SourceFont"] = "SourceFont";
20872
- })(exports.AssetType || (exports.AssetType = {}));
20873
-
20874
21002
  /**
20875
21003
  * Alpha blend mode.
20876
21004
  */ exports.BlendMode = void 0;