@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
package/dist/main.js CHANGED
@@ -2765,6 +2765,8 @@ exports.DependentMode = void 0;
2765
2765
  function DisorderedArray(count) {
2766
2766
  if (count === void 0) count = 0;
2767
2767
  this.length = 0;
2768
+ this._isLooping = false;
2769
+ this._blankCount = 0;
2768
2770
  this._elements = new Array(count);
2769
2771
  }
2770
2772
  var _proto = DisorderedArray.prototype;
@@ -2793,21 +2795,49 @@ exports.DependentMode = void 0;
2793
2795
  }
2794
2796
  return this._elements[index];
2795
2797
  };
2798
+ _proto.startLoop = function startLoop() {
2799
+ this._isLooping = true;
2800
+ };
2796
2801
  /**
2797
2802
  * Delete the element at the specified index.
2798
2803
  * @param index - The index of the element to be deleted
2799
2804
  * @returns The replaced item is used to reset its index
2800
2805
  */ _proto.deleteByIndex = function deleteByIndex(index) {
2801
2806
  var elements = this._elements;
2802
- var end = null;
2803
- var lastIndex = this.length - 1;
2804
- if (index !== lastIndex) {
2805
- end = elements[lastIndex];
2806
- elements[index] = end;
2807
+ var end;
2808
+ if (this._isLooping) {
2809
+ this._elements[index] = null;
2810
+ this._blankCount++;
2811
+ } else {
2812
+ var endIndex = this.length - 1;
2813
+ if (index !== endIndex) {
2814
+ end = elements[endIndex];
2815
+ elements[index] = end;
2816
+ }
2817
+ elements[endIndex] = null;
2818
+ this.length--;
2807
2819
  }
2808
- this.length--;
2809
2820
  return end;
2810
2821
  };
2822
+ _proto.endLoop = function endLoop() {
2823
+ this._isLooping = false;
2824
+ if (this._blankCount) {
2825
+ var elements = this._elements;
2826
+ for(var i = 0, j = 0, n = this.length; i < n; i++){
2827
+ var element = elements[i];
2828
+ if (element) {
2829
+ elements[j++] = element;
2830
+ }
2831
+ }
2832
+ this.length -= this._blankCount;
2833
+ this._blankCount = 0;
2834
+ }
2835
+ };
2836
+ _proto.endLoopAndClear = function endLoopAndClear() {
2837
+ this._isLooping = false;
2838
+ this.length = 0;
2839
+ this._blankCount = 0;
2840
+ };
2811
2841
  _proto.garbageCollection = function garbageCollection() {
2812
2842
  this._elements.length = this.length;
2813
2843
  };
@@ -3286,6 +3316,23 @@ var rePropName$1 = RegExp(// Match anything that isn't a dot or bracket.
3286
3316
  scale.z < 0 && (isInvert = !isInvert);
3287
3317
  return isInvert;
3288
3318
  };
3319
+ _proto._onDestroy = function _onDestroy() {
3320
+ Component.prototype._onDestroy.call(this);
3321
+ //@ts-ignore
3322
+ this._worldPosition._onValueChanged = null;
3323
+ //@ts-ignore
3324
+ this._rotation._onValueChanged = null;
3325
+ //@ts-ignore
3326
+ this._worldRotation._onValueChanged = null;
3327
+ //@ts-ignore
3328
+ this._rotationQuaternion._onValueChanged = null;
3329
+ //@ts-ignore
3330
+ this._worldRotationQuaternion._onValueChanged = null;
3331
+ //@ts-ignore
3332
+ this._position._onValueChanged = null;
3333
+ //@ts-ignore
3334
+ this._scale._onValueChanged = null;
3335
+ };
3289
3336
  /**
3290
3337
  * Get worldMatrix: Will trigger the worldMatrix update of itself and all parent entities.
3291
3338
  * Get worldPosition: Will trigger the worldMatrix, local position update of itself and the worldMatrix update of all parent entities.
@@ -4027,11 +4074,13 @@ var ComponentCloner = /*#__PURE__*/ function() {
4027
4074
  if (!this._isActiveInHierarchy) {
4028
4075
  child._isActiveInHierarchy && (inActiveChangeFlag |= ActiveChangeFlag.Hierarchy);
4029
4076
  }
4030
- if (this._isActiveInScene) {
4031
- // cross scene should inActive first and then active
4032
- child._isActiveInScene && oldScene !== newScene && (inActiveChangeFlag |= ActiveChangeFlag.Scene);
4033
- } else {
4034
- child._isActiveInScene && (inActiveChangeFlag |= ActiveChangeFlag.Scene);
4077
+ if (child._isActiveInScene) {
4078
+ if (this._isActiveInScene) {
4079
+ // Cross scene should inActive first and then active
4080
+ oldScene !== newScene && (inActiveChangeFlag |= ActiveChangeFlag.Scene);
4081
+ } else {
4082
+ inActiveChangeFlag |= ActiveChangeFlag.Scene;
4083
+ }
4035
4084
  }
4036
4085
  inActiveChangeFlag && child._processInActive(inActiveChangeFlag);
4037
4086
  if (child._scene !== newScene) {
@@ -5004,7 +5053,7 @@ var begin_mobile_frag = "#define GLSLIFY 1\nvec4 ambient=vec4(0.0);vec4 emission
5004
5053
 
5005
5054
  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
5006
5055
 
5007
- 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
5056
+ 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
5008
5057
 
5009
5058
  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
5010
5059
 
@@ -5044,7 +5093,7 @@ var pbr_helper = "#define GLSLIFY 1\n#include <normal_get>\nfloat computeSpecula
5044
5093
 
5045
5094
  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
5046
5095
 
5047
- 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
5096
+ 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
5048
5097
 
5049
5098
  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
5050
5099
 
@@ -11539,19 +11588,20 @@ var PrimitiveType;
11539
11588
  /**
11540
11589
  * @internal
11541
11590
  */ _proto.update = function update() {
11542
- var skin = this._skin;
11543
- if (skin) {
11544
- var ibms = skin.inverseBindMatrices;
11545
- var worldToLocal = this._rootBone.getInvModelMatrix();
11546
- var _this = this, bones = _this._bones, jointMatrices = _this._jointMatrices;
11591
+ var _this = this, skin = _this._skin, bones = _this._bones;
11592
+ if (skin && bones) {
11547
11593
  // @todo: can optimize when share skin
11594
+ var jointMatrices = this._jointMatrices;
11595
+ var bindMatrices = skin.inverseBindMatrices;
11596
+ var _this__rootBone;
11597
+ var worldToLocal = ((_this__rootBone = this._rootBone) != null ? _this__rootBone : this.entity).getInvModelMatrix();
11548
11598
  for(var i = bones.length - 1; i >= 0; i--){
11549
11599
  var bone = bones[i];
11550
11600
  var offset = i * 16;
11551
11601
  if (bone) {
11552
- Utils._floatMatrixMultiply(bone.transform.worldMatrix, ibms[i].elements, 0, jointMatrices, offset);
11602
+ Utils._floatMatrixMultiply(bone.transform.worldMatrix, bindMatrices[i].elements, 0, jointMatrices, offset);
11553
11603
  } else {
11554
- jointMatrices.set(ibms[i].elements, offset);
11604
+ jointMatrices.set(bindMatrices[i].elements, offset);
11555
11605
  }
11556
11606
  Utils._floatMatrixMultiply(worldToLocal, jointMatrices, offset, jointMatrices, offset);
11557
11607
  }
@@ -12222,6 +12272,41 @@ var TextRenderData = /*#__PURE__*/ function(RenderData) {
12222
12272
  return TextRenderData;
12223
12273
  }(RenderData);
12224
12274
 
12275
+ /**
12276
+ * Asset Type.
12277
+ */ exports.AssetType = void 0;
12278
+ (function(AssetType) {
12279
+ AssetType[/**
12280
+ * Plain text.
12281
+ * @remarks Will not be cached based on url in ResourceManager.
12282
+ */ "Text"] = "Text";
12283
+ AssetType[/**
12284
+ * JSON.
12285
+ * @remarks Will not be cached based on url in ResourceManager.
12286
+ */ "JSON"] = "JSON";
12287
+ AssetType[/**
12288
+ * ArrayBuffer.
12289
+ * @remarks Will not be cached based on url in ResourceManager.
12290
+ */ "Buffer"] = "Buffer";
12291
+ AssetType[/** 2D Texture. */ "Texture2D"] = "Texture2D";
12292
+ AssetType[/** Cube Texture. */ "TextureCube"] = "TextureCube";
12293
+ AssetType[/** Material. */ "Material"] = "Material";
12294
+ AssetType[/** Mesh. */ "Mesh"] = "Mesh";
12295
+ AssetType[/** AnimationClip. */ "AnimationClip"] = "AnimationClip";
12296
+ AssetType[/** AnimatorController. */ "AnimatorController"] = "AnimatorController";
12297
+ AssetType[/** Prefab.*/ "GLTF"] = "GLTF";
12298
+ AssetType[/** Compress Texture. */ "KTX"] = "KTX";
12299
+ AssetType[/** Cube Compress Texture. */ "KTXCube"] = "KTXCube";
12300
+ AssetType[/** KTX2 Compress Texture */ "KTX2"] = "KTX2";
12301
+ AssetType[/** Sprite. */ "Sprite"] = "Sprite";
12302
+ AssetType[/** Sprite Atlas. */ "SpriteAtlas"] = "SpriteAtlas";
12303
+ AssetType[/** Ambient light. */ "Env"] = "Environment";
12304
+ AssetType[/** Scene. */ "Scene"] = "Scene";
12305
+ AssetType[/** HDR to cube. */ "HDR"] = "HDR";
12306
+ AssetType[/** Font. */ "Font"] = "Font";
12307
+ AssetType[/** Source Font, include ttf、 otf and woff. */ "SourceFont"] = "SourceFont";
12308
+ })(exports.AssetType || (exports.AssetType = {}));
12309
+
12225
12310
  var SafeLoopArray = /*#__PURE__*/ function() {
12226
12311
  function SafeLoopArray() {
12227
12312
  this._array = [];
@@ -12334,10 +12419,13 @@ var SafeLoopArray = /*#__PURE__*/ function() {
12334
12419
  */ _proto.loadScene = function loadScene(url, destroyOldScene) {
12335
12420
  if (destroyOldScene === void 0) destroyOldScene = true;
12336
12421
  var _this = this;
12337
- var scenePromise = this.engine.resourceManager.load(url);
12422
+ var scenePromise = this.engine.resourceManager.load({
12423
+ url: url,
12424
+ type: exports.AssetType.Scene
12425
+ });
12338
12426
  scenePromise.then(function(scene) {
12339
- var scenes = _this._scenes;
12340
12427
  if (destroyOldScene) {
12428
+ var scenes = _this._scenes.getArray();
12341
12429
  for(var i = 0, n = scenes.length; i < n; i++){
12342
12430
  scenes[i].destroy();
12343
12431
  }
@@ -12546,6 +12634,7 @@ var /** @internal */ PromiseState;
12546
12634
  this._referResourcePool = Object.create(null);
12547
12635
  this._graphicResourcePool = Object.create(null);
12548
12636
  this._contentRestorerPool = Object.create(null);
12637
+ this._subAssetPromiseCallbacks = {};
12549
12638
  this.//-----------------Editor temp solution-----------------
12550
12639
  /** @internal */ _objectPool = Object.create(null);
12551
12640
  this./** @internal */ _editorResourceConfig = Object.create(null);
@@ -12573,6 +12662,21 @@ var /** @internal */ PromiseState;
12573
12662
  return (_this__assetUrlPool_url = this._assetUrlPool[url]) != null ? _this__assetUrlPool_url : null;
12574
12663
  };
12575
12664
  /**
12665
+ * Find the resource by type.
12666
+ * @param type - Resource type
12667
+ * @returns - Resource collection
12668
+ */ _proto.findResourcesByType = function findResourcesByType(type) {
12669
+ var resources = new Array();
12670
+ var referResourcePool = this._referResourcePool;
12671
+ for(var k in referResourcePool){
12672
+ var resource = referResourcePool[k];
12673
+ if (_instanceof(resource, type)) {
12674
+ resources.push(resource);
12675
+ }
12676
+ }
12677
+ return resources;
12678
+ };
12679
+ /**
12576
12680
  * Get asset url from instanceId.
12577
12681
  * @param instanceId - Engine instance id
12578
12682
  * @returns Asset url
@@ -12610,6 +12714,20 @@ var /** @internal */ PromiseState;
12610
12714
  };
12611
12715
  /**
12612
12716
  * @internal
12717
+ */ _proto._onSubAssetSuccess = function _onSubAssetSuccess(assetURL, value) {
12718
+ var _this__subAssetPromiseCallbacks_assetURL;
12719
+ (_this__subAssetPromiseCallbacks_assetURL = this._subAssetPromiseCallbacks[assetURL]) == null ? void 0 : _this__subAssetPromiseCallbacks_assetURL.resolve(value);
12720
+ delete this._subAssetPromiseCallbacks[assetURL];
12721
+ };
12722
+ /**
12723
+ * @internal
12724
+ */ _proto._onSubAssetFail = function _onSubAssetFail(assetURL, value) {
12725
+ var _this__subAssetPromiseCallbacks_assetURL;
12726
+ (_this__subAssetPromiseCallbacks_assetURL = this._subAssetPromiseCallbacks[assetURL]) == null ? void 0 : _this__subAssetPromiseCallbacks_assetURL.reject(value);
12727
+ delete this._subAssetPromiseCallbacks[assetURL];
12728
+ };
12729
+ /**
12730
+ * @internal
12613
12731
  */ _proto._addAsset = function _addAsset(path, asset) {
12614
12732
  this._assetPool[asset.instanceId] = path;
12615
12733
  this._assetUrlPool[path] = asset;
@@ -12719,6 +12837,10 @@ var /** @internal */ PromiseState;
12719
12837
  var assetURL = assetBaseURL;
12720
12838
  if (queryPath) {
12721
12839
  assetURL += "?q=" + paths.shift();
12840
+ var index;
12841
+ while(index = paths.shift()){
12842
+ assetURL += "[" + index + "]";
12843
+ }
12722
12844
  }
12723
12845
  // Check is loading
12724
12846
  var loadingPromises = this._loadingPromises;
@@ -12726,7 +12848,7 @@ var /** @internal */ PromiseState;
12726
12848
  if (loadingPromise) {
12727
12849
  return new AssetPromise(function(resolve, reject) {
12728
12850
  loadingPromise.then(function(resource) {
12729
- resolve(_this._getResolveResource(resource, paths));
12851
+ resolve(resource);
12730
12852
  }).catch(function(error) {
12731
12853
  reject(error);
12732
12854
  });
@@ -12740,38 +12862,37 @@ var /** @internal */ PromiseState;
12740
12862
  // Load asset
12741
12863
  item.url = assetBaseURL;
12742
12864
  var promise = loader.load(item, this);
12743
- if (_instanceof(promise, AssetPromise)) {
12744
- loadingPromises[assetBaseURL] = promise;
12745
- promise.then(function(resource) {
12746
- if (loader.useCache) {
12747
- _this._addAsset(assetBaseURL, resource);
12748
- }
12749
- delete loadingPromises[assetBaseURL];
12865
+ loadingPromises[assetBaseURL] = promise;
12866
+ promise.then(function(resource) {
12867
+ if (loader.useCache) {
12868
+ _this._addAsset(assetBaseURL, resource);
12869
+ }
12870
+ delete loadingPromises[assetBaseURL];
12871
+ }, function() {
12872
+ return delete loadingPromises[assetBaseURL];
12873
+ });
12874
+ if (queryPath) {
12875
+ var subPromise = new AssetPromise(function(resolve, reject) {
12876
+ _this._pushSubAssetPromiseCallback(assetURL, resolve, reject);
12877
+ });
12878
+ loadingPromises[assetURL] = subPromise;
12879
+ subPromise.then(function() {
12880
+ delete loadingPromises[assetURL];
12750
12881
  }, function() {
12751
- return delete loadingPromises[assetBaseURL];
12882
+ return delete loadingPromises[assetURL];
12752
12883
  });
12753
- return promise;
12754
- } else {
12755
- var _loop = function(subURL) {
12756
- var subPromise = promise[subURL];
12757
- var isMaster = assetBaseURL === subURL;
12758
- loadingPromises[subURL] = subPromise;
12759
- subPromise.then(function(resource) {
12760
- if (isMaster) {
12761
- if (loader.useCache) {
12762
- _this._addAsset(subURL, resource);
12763
- for(var k in promise)delete loadingPromises[k];
12764
- }
12765
- }
12766
- }, function() {
12767
- for(var k in promise)delete loadingPromises[k];
12768
- });
12769
- };
12770
- for(var subURL in promise)_loop(subURL);
12771
- return promise[assetURL].then(function(resource) {
12772
- return _this._getResolveResource(resource, paths);
12884
+ promise.catch(function(e) {
12885
+ _this._onSubAssetFail(assetURL, e);
12773
12886
  });
12887
+ return subPromise;
12774
12888
  }
12889
+ return promise;
12890
+ };
12891
+ _proto._pushSubAssetPromiseCallback = function _pushSubAssetPromiseCallback(assetURL, resolve, reject) {
12892
+ this._subAssetPromiseCallbacks[assetURL] = {
12893
+ resolve: resolve,
12894
+ reject: reject
12895
+ };
12775
12896
  };
12776
12897
  _proto._gc = function _gc(forceDestroy) {
12777
12898
  var objects = Utils.objectValues(this._referResourcePool);
@@ -12934,17 +13055,21 @@ var rePropName = RegExp(// Match anything that isn't a dot or bracket.
12934
13055
  if (this._currentEnteredEntity !== rayCastEntity) {
12935
13056
  if (this._currentEnteredEntity) {
12936
13057
  var scripts = this._currentEnteredEntity._scripts;
12937
- for(var i = scripts.length - 1; i >= 0; i--){
12938
- var script = scripts.get(i);
12939
- script._waitHandlingInValid || script.onPointerExit(this);
13058
+ scripts.startLoop();
13059
+ for(var i = 0; i < scripts.length; i++){
13060
+ var _scripts_get;
13061
+ (_scripts_get = scripts.get(i)) == null ? void 0 : _scripts_get.onPointerExit(this);
12940
13062
  }
13063
+ scripts.endLoop();
12941
13064
  }
12942
13065
  if (rayCastEntity) {
12943
13066
  var scripts1 = rayCastEntity._scripts;
12944
- for(var i1 = scripts1.length - 1; i1 >= 0; i1--){
12945
- var script1 = scripts1.get(i1);
12946
- script1._waitHandlingInValid || script1.onPointerEnter(this);
13067
+ scripts1.startLoop();
13068
+ for(var i1 = 0; i1 < scripts1.length; i1++){
13069
+ var _scripts_get1;
13070
+ (_scripts_get1 = scripts1.get(i1)) == null ? void 0 : _scripts_get1.onPointerEnter(this);
12947
13071
  }
13072
+ scripts1.endLoop();
12948
13073
  }
12949
13074
  this._currentEnteredEntity = rayCastEntity;
12950
13075
  }
@@ -12954,10 +13079,12 @@ var rePropName = RegExp(// Match anything that isn't a dot or bracket.
12954
13079
  */ _proto._firePointerDown = function _firePointerDown(rayCastEntity) {
12955
13080
  if (rayCastEntity) {
12956
13081
  var scripts = rayCastEntity._scripts;
12957
- for(var i = scripts.length - 1; i >= 0; i--){
12958
- var script = scripts.get(i);
12959
- script._waitHandlingInValid || script.onPointerDown(this);
13082
+ scripts.startLoop();
13083
+ for(var i = 0; i < scripts.length; i++){
13084
+ var _scripts_get;
13085
+ (_scripts_get = scripts.get(i)) == null ? void 0 : _scripts_get.onPointerDown(this);
12960
13086
  }
13087
+ scripts.endLoop();
12961
13088
  }
12962
13089
  this._currentPressedEntity = rayCastEntity;
12963
13090
  };
@@ -12966,10 +13093,12 @@ var rePropName = RegExp(// Match anything that isn't a dot or bracket.
12966
13093
  */ _proto._firePointerDrag = function _firePointerDrag() {
12967
13094
  if (this._currentPressedEntity) {
12968
13095
  var scripts = this._currentPressedEntity._scripts;
12969
- for(var i = scripts.length - 1; i >= 0; i--){
12970
- var script = scripts.get(i);
12971
- script._waitHandlingInValid || script.onPointerDrag(this);
13096
+ scripts.startLoop();
13097
+ for(var i = 0; i < scripts.length; i++){
13098
+ var _scripts_get;
13099
+ (_scripts_get = scripts.get(i)) == null ? void 0 : _scripts_get.onPointerDrag(this);
12972
13100
  }
13101
+ scripts.endLoop();
12973
13102
  }
12974
13103
  };
12975
13104
  /**
@@ -12979,13 +13108,15 @@ var rePropName = RegExp(// Match anything that isn't a dot or bracket.
12979
13108
  if (pressedEntity) {
12980
13109
  var sameTarget = pressedEntity === rayCastEntity;
12981
13110
  var scripts = pressedEntity._scripts;
12982
- for(var i = scripts.length - 1; i >= 0; i--){
13111
+ scripts.startLoop();
13112
+ for(var i = 0; i < scripts.length; i++){
12983
13113
  var script = scripts.get(i);
12984
- if (!script._waitHandlingInValid) {
13114
+ if (script) {
12985
13115
  sameTarget && script.onPointerClick(this);
12986
13116
  script.onPointerUp(this);
12987
13117
  }
12988
13118
  }
13119
+ scripts.endLoop();
12989
13120
  this._currentPressedEntity = null;
12990
13121
  }
12991
13122
  };
@@ -13581,6 +13712,7 @@ var Collision = function Collision() {
13581
13712
  function PhysicsScene(scene) {
13582
13713
  var _this = this;
13583
13714
  this._restTime = 0;
13715
+ this._fixedTimeStep = 1 / 60;
13584
13716
  this._colliders = new DisorderedArray();
13585
13717
  this._gravity = new engineMath.Vector3(0, -9.81, 0);
13586
13718
  this._onContactEnter = function(obj1, obj2) {
@@ -13588,116 +13720,139 @@ var Collision = function Collision() {
13588
13720
  var shape1 = physicalObjectsMap[obj1];
13589
13721
  var shape2 = physicalObjectsMap[obj2];
13590
13722
  var scripts = shape1.collider.entity._scripts;
13591
- for(var i = 0, len = scripts.length; i < len; i++){
13723
+ scripts.startLoop();
13724
+ for(var i = 0; i < scripts.length; i++){
13592
13725
  var script = scripts.get(i);
13593
- if (!script._waitHandlingInValid) {
13726
+ if (script) {
13594
13727
  var collision = PhysicsScene._collision;
13595
13728
  collision.shape = shape2;
13596
13729
  script.onCollisionEnter(collision);
13597
13730
  }
13598
13731
  }
13732
+ scripts.endLoop();
13599
13733
  scripts = shape2.collider.entity._scripts;
13600
- for(var i1 = 0, len1 = scripts.length; i1 < len1; i1++){
13734
+ scripts.startLoop();
13735
+ for(var i1 = 0; i1 < scripts.length; i1++){
13601
13736
  var script1 = scripts.get(i1);
13602
- if (!script1._waitHandlingInValid) {
13737
+ if (script1) {
13603
13738
  var collision1 = PhysicsScene._collision;
13604
13739
  collision1.shape = shape1;
13605
13740
  script1.onCollisionEnter(collision1);
13606
13741
  }
13607
13742
  }
13743
+ scripts.endLoop();
13608
13744
  };
13609
13745
  this._onContactExit = function(obj1, obj2) {
13610
13746
  var physicalObjectsMap = _this._scene.engine._physicalObjectsMap;
13611
13747
  var shape1 = physicalObjectsMap[obj1];
13612
13748
  var shape2 = physicalObjectsMap[obj2];
13613
13749
  var scripts = shape1.collider.entity._scripts;
13614
- for(var i = 0, len = scripts.length; i < len; i++){
13750
+ scripts.startLoop();
13751
+ for(var i = 0; i < scripts.length; i++){
13615
13752
  var script = scripts.get(i);
13616
- if (!script._waitHandlingInValid) {
13753
+ if (script) {
13617
13754
  var collision = PhysicsScene._collision;
13618
13755
  collision.shape = shape2;
13619
13756
  script.onCollisionExit(collision);
13620
13757
  }
13621
13758
  }
13759
+ scripts.endLoop();
13622
13760
  scripts = shape2.collider.entity._scripts;
13623
- for(var i1 = 0, len1 = scripts.length; i1 < len1; i1++){
13761
+ scripts.startLoop();
13762
+ for(var i1 = 0; i1 < scripts.length; i1++){
13624
13763
  var script1 = scripts.get(i1);
13625
- if (!script1._waitHandlingInValid) {
13764
+ if (script1) {
13626
13765
  var collision1 = PhysicsScene._collision;
13627
13766
  collision1.shape = shape1;
13628
13767
  script1.onCollisionExit(collision1);
13629
13768
  }
13630
13769
  }
13770
+ scripts.endLoop();
13631
13771
  };
13632
13772
  this._onContactStay = function(obj1, obj2) {
13633
13773
  var physicalObjectsMap = _this._scene.engine._physicalObjectsMap;
13634
13774
  var shape1 = physicalObjectsMap[obj1];
13635
13775
  var shape2 = physicalObjectsMap[obj2];
13636
13776
  var scripts = shape1.collider.entity._scripts;
13637
- for(var i = 0, len = scripts.length; i < len; i++){
13777
+ scripts.startLoop();
13778
+ for(var i = 0; i < scripts.length; i++){
13638
13779
  var script = scripts.get(i);
13639
- if (!script._waitHandlingInValid) {
13780
+ if (script) {
13640
13781
  var collision = PhysicsScene._collision;
13641
13782
  collision.shape = shape2;
13642
13783
  script.onCollisionStay(collision);
13643
13784
  }
13644
13785
  }
13786
+ scripts.endLoop();
13645
13787
  scripts = shape2.collider.entity._scripts;
13646
- for(var i1 = 0, len1 = scripts.length; i1 < len1; i1++){
13788
+ scripts.startLoop();
13789
+ for(var i1 = 0; i1 < scripts.length; i1++){
13647
13790
  var script1 = scripts.get(i1);
13648
- if (!script1._waitHandlingInValid) {
13791
+ if (script1) {
13649
13792
  var collision1 = PhysicsScene._collision;
13650
13793
  collision1.shape = shape1;
13651
13794
  script1.onCollisionStay(collision1);
13652
13795
  }
13653
13796
  }
13797
+ scripts.endLoop();
13654
13798
  };
13655
13799
  this._onTriggerEnter = function(obj1, obj2) {
13656
13800
  var physicalObjectsMap = _this._scene.engine._physicalObjectsMap;
13657
13801
  var shape1 = physicalObjectsMap[obj1];
13658
13802
  var shape2 = physicalObjectsMap[obj2];
13659
13803
  var scripts = shape1.collider.entity._scripts;
13660
- for(var i = 0, len = scripts.length; i < len; i++){
13661
- var script = scripts.get(i);
13662
- script._waitHandlingInValid || script.onTriggerEnter(shape2);
13804
+ scripts.startLoop();
13805
+ for(var i = 0; i < scripts.length; i++){
13806
+ var _scripts_get;
13807
+ (_scripts_get = scripts.get(i)) == null ? void 0 : _scripts_get.onTriggerEnter(shape2);
13663
13808
  }
13809
+ scripts.endLoop();
13664
13810
  scripts = shape2.collider.entity._scripts;
13665
- for(var i1 = 0, len1 = scripts.length; i1 < len1; i1++){
13666
- var script1 = scripts.get(i1);
13667
- script1._waitHandlingInValid || script1.onTriggerEnter(shape1);
13811
+ scripts.startLoop();
13812
+ for(var i1 = 0; i1 < scripts.length; i1++){
13813
+ var _scripts_get1;
13814
+ (_scripts_get1 = scripts.get(i1)) == null ? void 0 : _scripts_get1.onTriggerEnter(shape1);
13668
13815
  }
13816
+ scripts.endLoop();
13669
13817
  };
13670
13818
  this._onTriggerExit = function(obj1, obj2) {
13671
13819
  var physicalObjectsMap = _this._scene.engine._physicalObjectsMap;
13672
13820
  var shape1 = physicalObjectsMap[obj1];
13673
13821
  var shape2 = physicalObjectsMap[obj2];
13674
13822
  var scripts = shape1.collider.entity._scripts;
13675
- for(var i = 0, n = scripts.length; i < n; i++){
13676
- var script = scripts.get(i);
13677
- script._waitHandlingInValid || script.onTriggerExit(shape2);
13823
+ scripts.startLoop();
13824
+ for(var i = 0; i < scripts.length; i++){
13825
+ var _scripts_get;
13826
+ (_scripts_get = scripts.get(i)) == null ? void 0 : _scripts_get.onTriggerExit(shape2);
13678
13827
  }
13828
+ scripts.endLoop();
13679
13829
  scripts = shape2.collider.entity._scripts;
13680
- for(var i1 = 0, n1 = scripts.length; i1 < n1; i1++){
13681
- var script1 = scripts.get(i1);
13682
- script1._waitHandlingInValid || script1.onTriggerExit(shape1);
13830
+ scripts.startLoop();
13831
+ for(var i1 = 0; i1 < scripts.length; i1++){
13832
+ var _scripts_get1;
13833
+ (_scripts_get1 = scripts.get(i1)) == null ? void 0 : _scripts_get1.onTriggerExit(shape1);
13683
13834
  }
13835
+ scripts.endLoop();
13684
13836
  };
13685
13837
  this._onTriggerStay = function(obj1, obj2) {
13686
13838
  var physicalObjectsMap = _this._scene.engine._physicalObjectsMap;
13687
13839
  var shape1 = physicalObjectsMap[obj1];
13688
13840
  var shape2 = physicalObjectsMap[obj2];
13689
13841
  var scripts = shape1.collider.entity._scripts;
13690
- for(var i = 0, len = scripts.length; i < len; i++){
13691
- var script = scripts.get(i);
13692
- script._waitHandlingInValid || script.onTriggerStay(shape2);
13842
+ scripts.startLoop();
13843
+ for(var i = 0; i < scripts.length; i++){
13844
+ var _scripts_get;
13845
+ (_scripts_get = scripts.get(i)) == null ? void 0 : _scripts_get.onTriggerStay(shape2);
13693
13846
  }
13847
+ scripts.endLoop();
13694
13848
  scripts = shape2.collider.entity._scripts;
13695
- for(var i1 = 0, len1 = scripts.length; i1 < len1; i1++){
13696
- var script1 = scripts.get(i1);
13697
- script1._waitHandlingInValid || script1.onTriggerStay(shape1);
13849
+ scripts.startLoop();
13850
+ for(var i1 = 0; i1 < scripts.length; i1++){
13851
+ var _scripts_get1;
13852
+ (_scripts_get1 = scripts.get(i1)) == null ? void 0 : _scripts_get1.onTriggerStay(shape1);
13698
13853
  }
13854
+ scripts.endLoop();
13699
13855
  };
13700
- /** The fixed time step in seconds at which physics are performed. */ this.fixedTimeStep = 1 / 60;
13701
13856
  this._scene = scene;
13702
13857
  this._setGravity = this._setGravity.bind(this);
13703
13858
  //@ts-ignore
@@ -13754,7 +13909,7 @@ var Collision = function Collision() {
13754
13909
  * Call on every frame to update pose of objects.
13755
13910
  * @internal
13756
13911
  */ _proto._update = function _update(deltaTime) {
13757
- var _this = this, fixedTimeStep = _this.fixedTimeStep, nativePhysicsManager = _this._nativePhysicsScene;
13912
+ var _this = this, fixedTimeStep = _this._fixedTimeStep, nativePhysicsManager = _this._nativePhysicsScene;
13758
13913
  var componentsManager = this._scene._componentsManager;
13759
13914
  var simulateTime = this._restTime + deltaTime;
13760
13915
  var step = Math.floor(simulateTime / fixedTimeStep);
@@ -13862,6 +14017,17 @@ var Collision = function Collision() {
13862
14017
  gravity.copyFrom(value);
13863
14018
  }
13864
14019
  }
14020
+ },
14021
+ {
14022
+ key: "fixedTimeStep",
14023
+ get: /**
14024
+ * The fixed time step in seconds at which physics are performed.
14025
+ */ function get() {
14026
+ return this._fixedTimeStep;
14027
+ },
14028
+ set: function set(value) {
14029
+ this._fixedTimeStep = Math.max(value, engineMath.MathUtil.zeroTolerance);
14030
+ }
13865
14031
  }
13866
14032
  ]);
13867
14033
  return PhysicsScene;
@@ -15735,6 +15901,7 @@ exports.Joint = __decorate([
15735
15901
  CloneManager.deepCloneObject(this.renderStates, target.renderStates);
15736
15902
  };
15737
15903
  _proto._addReferCount = function _addReferCount(value) {
15904
+ if (this._destroyed) return;
15738
15905
  ReferResource.prototype._addReferCount.call(this, value);
15739
15906
  this.shaderData._addReferCount(value);
15740
15907
  };
@@ -16822,7 +16989,6 @@ ShaderPool.init();
16822
16989
  this._onUpdateScripts = new DisorderedArray();
16823
16990
  this._onLateUpdateScripts = new DisorderedArray();
16824
16991
  this._onPhysicsUpdateScripts = new DisorderedArray();
16825
- this._disableScripts = [];
16826
16992
  this._pendingDestroyScripts = [];
16827
16993
  this._disposeDestroyScripts = [];
16828
16994
  // Animation
@@ -16900,102 +17066,110 @@ ShaderPool.init();
16900
17066
  replaced && (replaced._onUpdateIndex = renderer._onUpdateIndex);
16901
17067
  renderer._onUpdateIndex = -1;
16902
17068
  };
16903
- _proto.addDisableScript = function addDisableScript(component) {
16904
- this._disableScripts.push(component);
16905
- };
16906
17069
  _proto.addPendingDestroyScript = function addPendingDestroyScript(component) {
16907
17070
  this._pendingDestroyScripts.push(component);
16908
17071
  };
16909
17072
  _proto.callScriptOnStart = function callScriptOnStart() {
16910
17073
  var onStartScripts = this._onStartScripts;
16911
17074
  if (onStartScripts.length > 0) {
17075
+ onStartScripts.startLoop();
16912
17076
  var elements = onStartScripts._elements;
16913
17077
  // The 'onStartScripts.length' maybe add if you add some Script with addComponent() in some Script's onStart()
16914
17078
  for(var i = 0; i < onStartScripts.length; i++){
16915
17079
  var script = elements[i];
16916
- if (!script._waitHandlingInValid) {
17080
+ if (script) {
16917
17081
  script._started = true;
16918
- script._onStartIndex = -1;
17082
+ this.removeOnStartScript(script);
16919
17083
  script.onStart();
16920
17084
  }
16921
17085
  }
16922
- onStartScripts.length = 0;
17086
+ onStartScripts.endLoopAndClear();
16923
17087
  }
16924
17088
  };
16925
17089
  _proto.callScriptOnUpdate = function callScriptOnUpdate(deltaTime) {
16926
- var elements = this._onUpdateScripts._elements;
16927
- for(var i = this._onUpdateScripts.length - 1; i >= 0; --i){
17090
+ var onUpdateScripts = this._onUpdateScripts;
17091
+ onUpdateScripts.startLoop();
17092
+ var elements = onUpdateScripts._elements;
17093
+ for(var i = 0; i < onUpdateScripts.length; i++){
16928
17094
  var element = elements[i];
16929
- if (!element._waitHandlingInValid && element._started) {
17095
+ if (element == null ? void 0 : element._started) {
16930
17096
  element.onUpdate(deltaTime);
16931
17097
  }
16932
17098
  }
17099
+ onUpdateScripts.endLoop();
16933
17100
  };
16934
17101
  _proto.callScriptOnLateUpdate = function callScriptOnLateUpdate(deltaTime) {
16935
- var elements = this._onLateUpdateScripts._elements;
16936
- for(var i = this._onLateUpdateScripts.length - 1; i >= 0; --i){
17102
+ var onLateUpdateScripts = this._onLateUpdateScripts;
17103
+ onLateUpdateScripts.startLoop();
17104
+ var elements = onLateUpdateScripts._elements;
17105
+ for(var i = 0; i < onLateUpdateScripts.length; i++){
16937
17106
  var element = elements[i];
16938
- if (!element._waitHandlingInValid && element._started) {
17107
+ if (element == null ? void 0 : element._started) {
16939
17108
  element.onLateUpdate(deltaTime);
16940
17109
  }
16941
17110
  }
17111
+ onLateUpdateScripts.endLoop();
16942
17112
  };
16943
17113
  _proto.callScriptOnPhysicsUpdate = function callScriptOnPhysicsUpdate() {
16944
- var elements = this._onPhysicsUpdateScripts._elements;
16945
- for(var i = this._onPhysicsUpdateScripts.length - 1; i >= 0; --i){
17114
+ var onPhysicsUpdateScripts = this._onPhysicsUpdateScripts;
17115
+ onPhysicsUpdateScripts.startLoop();
17116
+ var elements = onPhysicsUpdateScripts._elements;
17117
+ for(var i = 0; i < onPhysicsUpdateScripts.length; i++){
16946
17118
  var element = elements[i];
16947
- if (!element._waitHandlingInValid && element._started) {
17119
+ if (element == null ? void 0 : element._started) {
16948
17120
  element.onPhysicsUpdate();
16949
17121
  }
16950
17122
  }
17123
+ onPhysicsUpdateScripts.endLoop();
16951
17124
  };
16952
17125
  _proto.callAnimationUpdate = function callAnimationUpdate(deltaTime) {
16953
- var elements = this._onUpdateAnimations._elements;
16954
- for(var i = this._onUpdateAnimations.length - 1; i >= 0; --i){
17126
+ var onUpdateAnimations = this._onUpdateAnimations;
17127
+ onUpdateAnimations.startLoop();
17128
+ var elements = onUpdateAnimations._elements;
17129
+ for(var i = 0; i < onUpdateAnimations.length; i++){
16955
17130
  //@ts-ignore
16956
17131
  elements[i].update(deltaTime);
16957
17132
  }
17133
+ onUpdateAnimations.endLoop();
16958
17134
  };
16959
17135
  _proto.callRendererOnUpdate = function callRendererOnUpdate(deltaTime) {
16960
- var elements = this._onUpdateRenderers._elements;
16961
- for(var i = this._onUpdateRenderers.length - 1; i >= 0; --i){
17136
+ var onUpdateRenderers = this._onUpdateRenderers;
17137
+ onUpdateRenderers.startLoop();
17138
+ var elements = onUpdateRenderers._elements;
17139
+ for(var i = 0; i < onUpdateRenderers.length; i++){
16962
17140
  elements[i].update(deltaTime);
16963
17141
  }
17142
+ onUpdateRenderers.endLoop();
16964
17143
  };
16965
17144
  _proto.handlingInvalidScripts = function handlingInvalidScripts() {
16966
- var _this = this, disableScripts = _this._disableScripts;
16967
- var length = disableScripts.length;
16968
- if (length > 0) {
16969
- for(var i = length - 1; i >= 0; i--){
16970
- var disableScript = disableScripts[i];
16971
- disableScript._waitHandlingInValid && disableScript._handlingInValid();
16972
- }
16973
- disableScripts.length = 0;
16974
- }
16975
- var _this1 = this, pendingDestroyScripts = _this1._disposeDestroyScripts, disposeDestroyScripts = _this1._pendingDestroyScripts;
17145
+ var _this = this, pendingDestroyScripts = _this._disposeDestroyScripts, disposeDestroyScripts = _this._pendingDestroyScripts;
16976
17146
  this._disposeDestroyScripts = disposeDestroyScripts;
16977
17147
  this._pendingDestroyScripts = pendingDestroyScripts;
16978
17148
  length = disposeDestroyScripts.length;
16979
17149
  if (length > 0) {
16980
- for(var i1 = length - 1; i1 >= 0; i1--){
16981
- disposeDestroyScripts[i1].onDestroy();
17150
+ for(var i = length - 1; i >= 0; i--){
17151
+ disposeDestroyScripts[i].onDestroy();
16982
17152
  }
16983
17153
  disposeDestroyScripts.length = 0;
16984
17154
  }
16985
17155
  };
16986
17156
  _proto.callCameraOnBeginRender = function callCameraOnBeginRender(camera) {
16987
17157
  var scripts = camera.entity._scripts;
16988
- for(var i = scripts.length - 1; i >= 0; --i){
16989
- var script = scripts.get(i);
16990
- script._waitHandlingInValid || script.onBeginRender(camera);
17158
+ scripts.startLoop();
17159
+ for(var i = 0; i < scripts.length; i++){
17160
+ var _scripts_get;
17161
+ (_scripts_get = scripts.get(i)) == null ? void 0 : _scripts_get.onBeginRender(camera);
16991
17162
  }
17163
+ scripts.endLoop();
16992
17164
  };
16993
17165
  _proto.callCameraOnEndRender = function callCameraOnEndRender(camera) {
16994
17166
  var scripts = camera.entity._scripts;
16995
- for(var i = scripts.length - 1; i >= 0; --i){
16996
- var script = scripts.get(i);
16997
- script._waitHandlingInValid || script.onEndRender(camera);
17167
+ scripts.startLoop();
17168
+ for(var i = 0; i < scripts.length; i++){
17169
+ var _scripts_get;
17170
+ (_scripts_get = scripts.get(i)) == null ? void 0 : _scripts_get.onEndRender(camera);
16998
17171
  }
17172
+ scripts.endLoop();
16999
17173
  };
17000
17174
  _proto.getActiveChangedTempList = function getActiveChangedTempList() {
17001
17175
  return this._componentsContainerPool.length ? this._componentsContainerPool.pop() : [];
@@ -17966,19 +18140,20 @@ __decorate([
17966
18140
  }
17967
18141
  // Process entity active/inActive
17968
18142
  var inActiveChangeFlag = ActiveChangeFlag.None;
17969
- if (this._isActiveInEngine) {
17970
- // Cross scene should inActive first and then active
17971
- entity._isActiveInHierarchy && oldScene !== this && (inActiveChangeFlag |= ActiveChangeFlag.Scene);
17972
- } else {
17973
- entity._isActiveInHierarchy && (inActiveChangeFlag |= ActiveChangeFlag.Hierarchy);
18143
+ if (entity._isActiveInHierarchy) {
18144
+ this._isActiveInEngine || (inActiveChangeFlag |= ActiveChangeFlag.Hierarchy);
17974
18145
  }
18146
+ // Cross scene should inActive first and then active
18147
+ entity._isActiveInScene && oldScene !== this && (inActiveChangeFlag |= ActiveChangeFlag.Scene);
17975
18148
  inActiveChangeFlag && entity._processInActive(inActiveChangeFlag);
17976
18149
  if (oldScene !== this) {
17977
18150
  Entity._traverseSetOwnerScene(entity, this);
17978
18151
  }
17979
18152
  var activeChangeFlag = ActiveChangeFlag.None;
17980
- if (this._isActiveInEngine && entity._isActive) {
17981
- !entity._isActiveInHierarchy && (activeChangeFlag |= ActiveChangeFlag.Hierarchy);
18153
+ if (entity._isActive) {
18154
+ if (this._isActiveInEngine) {
18155
+ !entity._isActiveInHierarchy && (activeChangeFlag |= ActiveChangeFlag.Hierarchy);
18156
+ }
17982
18157
  (!entity._isActiveInScene || oldScene !== this) && (activeChangeFlag |= ActiveChangeFlag.Scene);
17983
18158
  }
17984
18159
  activeChangeFlag && entity._processActive(activeChangeFlag);
@@ -18334,7 +18509,6 @@ __decorate([
18334
18509
  /** @internal */ _this._onPreRenderIndex = -1;
18335
18510
  /** @internal */ _this._onPostRenderIndex = -1;
18336
18511
  _this._entityScriptsIndex = -1;
18337
- _this._waitHandlingInValid = false;
18338
18512
  return _this;
18339
18513
  }
18340
18514
  var _proto = Script.prototype;
@@ -18443,37 +18617,30 @@ __decorate([
18443
18617
  /**
18444
18618
  * @internal
18445
18619
  */ _proto._onEnableInScene = function _onEnableInScene() {
18446
- if (this._waitHandlingInValid) {
18447
- this._waitHandlingInValid = false;
18448
- } else {
18449
- var _this_scene = this.scene, componentsManager = _this_scene._componentsManager;
18450
- var prototype = Script.prototype;
18451
- if (!this._started) {
18452
- componentsManager.addOnStartScript(this);
18453
- }
18454
- if (this.onUpdate !== prototype.onUpdate) {
18455
- componentsManager.addOnUpdateScript(this);
18456
- }
18457
- if (this.onLateUpdate !== prototype.onLateUpdate) {
18458
- componentsManager.addOnLateUpdateScript(this);
18459
- }
18460
- if (this.onPhysicsUpdate !== prototype.onPhysicsUpdate) {
18461
- componentsManager.addOnPhysicsUpdateScript(this);
18462
- }
18463
- this._entity._addScript(this);
18620
+ var _this_scene = this.scene, componentsManager = _this_scene._componentsManager;
18621
+ var prototype = Script.prototype;
18622
+ if (!this._started) {
18623
+ componentsManager.addOnStartScript(this);
18624
+ }
18625
+ if (this.onUpdate !== prototype.onUpdate) {
18626
+ componentsManager.addOnUpdateScript(this);
18627
+ }
18628
+ if (this.onLateUpdate !== prototype.onLateUpdate) {
18629
+ componentsManager.addOnLateUpdateScript(this);
18630
+ }
18631
+ if (this.onPhysicsUpdate !== prototype.onPhysicsUpdate) {
18632
+ componentsManager.addOnPhysicsUpdateScript(this);
18464
18633
  }
18634
+ this._entity._addScript(this);
18465
18635
  };
18466
18636
  /**
18467
18637
  * @internal
18468
18638
  */ _proto._onDisableInScene = function _onDisableInScene() {
18469
- this._waitHandlingInValid = true;
18470
- this.scene._componentsManager.addDisableScript(this);
18471
- };
18472
- /**
18473
- * @internal
18474
- */ _proto._handlingInValid = function _handlingInValid() {
18475
18639
  var componentsManager = this.scene._componentsManager;
18476
18640
  var prototype = Script.prototype;
18641
+ if (!this._started) {
18642
+ componentsManager.removeOnStartScript(this);
18643
+ }
18477
18644
  if (this.onUpdate !== prototype.onUpdate) {
18478
18645
  componentsManager.removeOnUpdateScript(this);
18479
18646
  }
@@ -18484,7 +18651,6 @@ __decorate([
18484
18651
  componentsManager.removeOnPhysicsUpdateScript(this);
18485
18652
  }
18486
18653
  this._entity._removeScript(this);
18487
- this._waitHandlingInValid = false;
18488
18654
  };
18489
18655
  /**
18490
18656
  * @internal
@@ -18518,9 +18684,6 @@ __decorate([
18518
18684
  __decorate([
18519
18685
  ignoreClone
18520
18686
  ], Script.prototype, "_entityScriptsIndex", void 0);
18521
- __decorate([
18522
- ignoreClone
18523
- ], Script.prototype, "_waitHandlingInValid", void 0);
18524
18687
 
18525
18688
  /**
18526
18689
  * Depth texture mode.
@@ -20835,41 +20998,6 @@ var MultiExecutor = /*#__PURE__*/ function() {
20835
20998
  Loader._engineObjects = {};
20836
20999
  })();
20837
21000
 
20838
- /**
20839
- * Asset Type.
20840
- */ exports.AssetType = void 0;
20841
- (function(AssetType) {
20842
- AssetType[/**
20843
- * Plain text.
20844
- * @remarks Will not be cached based on url in ResourceManager.
20845
- */ "Text"] = "Text";
20846
- AssetType[/**
20847
- * JSON.
20848
- * @remarks Will not be cached based on url in ResourceManager.
20849
- */ "JSON"] = "JSON";
20850
- AssetType[/**
20851
- * ArrayBuffer.
20852
- * @remarks Will not be cached based on url in ResourceManager.
20853
- */ "Buffer"] = "Buffer";
20854
- AssetType[/** 2D Texture. */ "Texture2D"] = "Texture2D";
20855
- AssetType[/** Cube Texture. */ "TextureCube"] = "TextureCube";
20856
- AssetType[/** Material. */ "Material"] = "Material";
20857
- AssetType[/** Mesh. */ "Mesh"] = "Mesh";
20858
- AssetType[/** AnimationClip. */ "AnimationClip"] = "AnimationClip";
20859
- AssetType[/** AnimatorController. */ "AnimatorController"] = "AnimatorController";
20860
- AssetType[/** Prefab.*/ "GLTF"] = "GLTF";
20861
- AssetType[/** Compress Texture. */ "KTX"] = "KTX";
20862
- AssetType[/** Cube Compress Texture. */ "KTXCube"] = "KTXCube";
20863
- AssetType[/** KTX2 Compress Texture */ "KTX2"] = "KTX2";
20864
- AssetType[/** Sprite. */ "Sprite"] = "Sprite";
20865
- AssetType[/** Sprite Atlas. */ "SpriteAtlas"] = "SpriteAtlas";
20866
- AssetType[/** Ambient light. */ "Env"] = "Environment";
20867
- AssetType[/** Scene. */ "Scene"] = "Scene";
20868
- AssetType[/** HDR to cube. */ "HDR"] = "HDR";
20869
- AssetType[/** Font. */ "Font"] = "Font";
20870
- AssetType[/** Source Font, include ttf、 otf and woff. */ "SourceFont"] = "SourceFont";
20871
- })(exports.AssetType || (exports.AssetType = {}));
20872
-
20873
21001
  /**
20874
21002
  * Alpha blend mode.
20875
21003
  */ exports.BlendMode = void 0;