@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/module.js CHANGED
@@ -2761,6 +2761,8 @@ var DependentMode;
2761
2761
  function DisorderedArray(count) {
2762
2762
  if (count === void 0) count = 0;
2763
2763
  this.length = 0;
2764
+ this._isLooping = false;
2765
+ this._blankCount = 0;
2764
2766
  this._elements = new Array(count);
2765
2767
  }
2766
2768
  var _proto = DisorderedArray.prototype;
@@ -2789,21 +2791,49 @@ var DependentMode;
2789
2791
  }
2790
2792
  return this._elements[index];
2791
2793
  };
2794
+ _proto.startLoop = function startLoop() {
2795
+ this._isLooping = true;
2796
+ };
2792
2797
  /**
2793
2798
  * Delete the element at the specified index.
2794
2799
  * @param index - The index of the element to be deleted
2795
2800
  * @returns The replaced item is used to reset its index
2796
2801
  */ _proto.deleteByIndex = function deleteByIndex(index) {
2797
2802
  var elements = this._elements;
2798
- var end = null;
2799
- var lastIndex = this.length - 1;
2800
- if (index !== lastIndex) {
2801
- end = elements[lastIndex];
2802
- elements[index] = end;
2803
+ var end;
2804
+ if (this._isLooping) {
2805
+ this._elements[index] = null;
2806
+ this._blankCount++;
2807
+ } else {
2808
+ var endIndex = this.length - 1;
2809
+ if (index !== endIndex) {
2810
+ end = elements[endIndex];
2811
+ elements[index] = end;
2812
+ }
2813
+ elements[endIndex] = null;
2814
+ this.length--;
2803
2815
  }
2804
- this.length--;
2805
2816
  return end;
2806
2817
  };
2818
+ _proto.endLoop = function endLoop() {
2819
+ this._isLooping = false;
2820
+ if (this._blankCount) {
2821
+ var elements = this._elements;
2822
+ for(var i = 0, j = 0, n = this.length; i < n; i++){
2823
+ var element = elements[i];
2824
+ if (element) {
2825
+ elements[j++] = element;
2826
+ }
2827
+ }
2828
+ this.length -= this._blankCount;
2829
+ this._blankCount = 0;
2830
+ }
2831
+ };
2832
+ _proto.endLoopAndClear = function endLoopAndClear() {
2833
+ this._isLooping = false;
2834
+ this.length = 0;
2835
+ this._blankCount = 0;
2836
+ };
2807
2837
  _proto.garbageCollection = function garbageCollection() {
2808
2838
  this._elements.length = this.length;
2809
2839
  };
@@ -3282,6 +3312,23 @@ var rePropName$1 = RegExp(// Match anything that isn't a dot or bracket.
3282
3312
  scale.z < 0 && (isInvert = !isInvert);
3283
3313
  return isInvert;
3284
3314
  };
3315
+ _proto._onDestroy = function _onDestroy() {
3316
+ Component.prototype._onDestroy.call(this);
3317
+ //@ts-ignore
3318
+ this._worldPosition._onValueChanged = null;
3319
+ //@ts-ignore
3320
+ this._rotation._onValueChanged = null;
3321
+ //@ts-ignore
3322
+ this._worldRotation._onValueChanged = null;
3323
+ //@ts-ignore
3324
+ this._rotationQuaternion._onValueChanged = null;
3325
+ //@ts-ignore
3326
+ this._worldRotationQuaternion._onValueChanged = null;
3327
+ //@ts-ignore
3328
+ this._position._onValueChanged = null;
3329
+ //@ts-ignore
3330
+ this._scale._onValueChanged = null;
3331
+ };
3285
3332
  /**
3286
3333
  * Get worldMatrix: Will trigger the worldMatrix update of itself and all parent entities.
3287
3334
  * Get worldPosition: Will trigger the worldMatrix, local position update of itself and the worldMatrix update of all parent entities.
@@ -4023,11 +4070,13 @@ var ComponentCloner = /*#__PURE__*/ function() {
4023
4070
  if (!this._isActiveInHierarchy) {
4024
4071
  child._isActiveInHierarchy && (inActiveChangeFlag |= ActiveChangeFlag.Hierarchy);
4025
4072
  }
4026
- if (this._isActiveInScene) {
4027
- // cross scene should inActive first and then active
4028
- child._isActiveInScene && oldScene !== newScene && (inActiveChangeFlag |= ActiveChangeFlag.Scene);
4029
- } else {
4030
- child._isActiveInScene && (inActiveChangeFlag |= ActiveChangeFlag.Scene);
4073
+ if (child._isActiveInScene) {
4074
+ if (this._isActiveInScene) {
4075
+ // Cross scene should inActive first and then active
4076
+ oldScene !== newScene && (inActiveChangeFlag |= ActiveChangeFlag.Scene);
4077
+ } else {
4078
+ inActiveChangeFlag |= ActiveChangeFlag.Scene;
4079
+ }
4031
4080
  }
4032
4081
  inActiveChangeFlag && child._processInActive(inActiveChangeFlag);
4033
4082
  if (child._scene !== newScene) {
@@ -5000,7 +5049,7 @@ var begin_mobile_frag = "#define GLSLIFY 1\nvec4 ambient=vec4(0.0);vec4 emission
5000
5049
 
5001
5050
  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
5002
5051
 
5003
- 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
5052
+ 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
5004
5053
 
5005
5054
  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
5006
5055
 
@@ -5040,7 +5089,7 @@ var pbr_helper = "#define GLSLIFY 1\n#include <normal_get>\nfloat computeSpecula
5040
5089
 
5041
5090
  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
5042
5091
 
5043
- 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
5092
+ 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
5044
5093
 
5045
5094
  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
5046
5095
 
@@ -11535,19 +11584,20 @@ var PrimitiveType;
11535
11584
  /**
11536
11585
  * @internal
11537
11586
  */ _proto.update = function update() {
11538
- var skin = this._skin;
11539
- if (skin) {
11540
- var ibms = skin.inverseBindMatrices;
11541
- var worldToLocal = this._rootBone.getInvModelMatrix();
11542
- var _this = this, bones = _this._bones, jointMatrices = _this._jointMatrices;
11587
+ var _this = this, skin = _this._skin, bones = _this._bones;
11588
+ if (skin && bones) {
11543
11589
  // @todo: can optimize when share skin
11590
+ var jointMatrices = this._jointMatrices;
11591
+ var bindMatrices = skin.inverseBindMatrices;
11592
+ var _this__rootBone;
11593
+ var worldToLocal = ((_this__rootBone = this._rootBone) != null ? _this__rootBone : this.entity).getInvModelMatrix();
11544
11594
  for(var i = bones.length - 1; i >= 0; i--){
11545
11595
  var bone = bones[i];
11546
11596
  var offset = i * 16;
11547
11597
  if (bone) {
11548
- Utils._floatMatrixMultiply(bone.transform.worldMatrix, ibms[i].elements, 0, jointMatrices, offset);
11598
+ Utils._floatMatrixMultiply(bone.transform.worldMatrix, bindMatrices[i].elements, 0, jointMatrices, offset);
11549
11599
  } else {
11550
- jointMatrices.set(ibms[i].elements, offset);
11600
+ jointMatrices.set(bindMatrices[i].elements, offset);
11551
11601
  }
11552
11602
  Utils._floatMatrixMultiply(worldToLocal, jointMatrices, offset, jointMatrices, offset);
11553
11603
  }
@@ -12218,6 +12268,41 @@ var TextRenderData = /*#__PURE__*/ function(RenderData) {
12218
12268
  return TextRenderData;
12219
12269
  }(RenderData);
12220
12270
 
12271
+ /**
12272
+ * Asset Type.
12273
+ */ var AssetType;
12274
+ (function(AssetType) {
12275
+ AssetType[/**
12276
+ * Plain text.
12277
+ * @remarks Will not be cached based on url in ResourceManager.
12278
+ */ "Text"] = "Text";
12279
+ AssetType[/**
12280
+ * JSON.
12281
+ * @remarks Will not be cached based on url in ResourceManager.
12282
+ */ "JSON"] = "JSON";
12283
+ AssetType[/**
12284
+ * ArrayBuffer.
12285
+ * @remarks Will not be cached based on url in ResourceManager.
12286
+ */ "Buffer"] = "Buffer";
12287
+ AssetType[/** 2D Texture. */ "Texture2D"] = "Texture2D";
12288
+ AssetType[/** Cube Texture. */ "TextureCube"] = "TextureCube";
12289
+ AssetType[/** Material. */ "Material"] = "Material";
12290
+ AssetType[/** Mesh. */ "Mesh"] = "Mesh";
12291
+ AssetType[/** AnimationClip. */ "AnimationClip"] = "AnimationClip";
12292
+ AssetType[/** AnimatorController. */ "AnimatorController"] = "AnimatorController";
12293
+ AssetType[/** Prefab.*/ "GLTF"] = "GLTF";
12294
+ AssetType[/** Compress Texture. */ "KTX"] = "KTX";
12295
+ AssetType[/** Cube Compress Texture. */ "KTXCube"] = "KTXCube";
12296
+ AssetType[/** KTX2 Compress Texture */ "KTX2"] = "KTX2";
12297
+ AssetType[/** Sprite. */ "Sprite"] = "Sprite";
12298
+ AssetType[/** Sprite Atlas. */ "SpriteAtlas"] = "SpriteAtlas";
12299
+ AssetType[/** Ambient light. */ "Env"] = "Environment";
12300
+ AssetType[/** Scene. */ "Scene"] = "Scene";
12301
+ AssetType[/** HDR to cube. */ "HDR"] = "HDR";
12302
+ AssetType[/** Font. */ "Font"] = "Font";
12303
+ AssetType[/** Source Font, include ttf、 otf and woff. */ "SourceFont"] = "SourceFont";
12304
+ })(AssetType || (AssetType = {}));
12305
+
12221
12306
  var SafeLoopArray = /*#__PURE__*/ function() {
12222
12307
  function SafeLoopArray() {
12223
12308
  this._array = [];
@@ -12330,10 +12415,13 @@ var SafeLoopArray = /*#__PURE__*/ function() {
12330
12415
  */ _proto.loadScene = function loadScene(url, destroyOldScene) {
12331
12416
  if (destroyOldScene === void 0) destroyOldScene = true;
12332
12417
  var _this = this;
12333
- var scenePromise = this.engine.resourceManager.load(url);
12418
+ var scenePromise = this.engine.resourceManager.load({
12419
+ url: url,
12420
+ type: AssetType.Scene
12421
+ });
12334
12422
  scenePromise.then(function(scene) {
12335
- var scenes = _this._scenes;
12336
12423
  if (destroyOldScene) {
12424
+ var scenes = _this._scenes.getArray();
12337
12425
  for(var i = 0, n = scenes.length; i < n; i++){
12338
12426
  scenes[i].destroy();
12339
12427
  }
@@ -12542,6 +12630,7 @@ var /** @internal */ PromiseState;
12542
12630
  this._referResourcePool = Object.create(null);
12543
12631
  this._graphicResourcePool = Object.create(null);
12544
12632
  this._contentRestorerPool = Object.create(null);
12633
+ this._subAssetPromiseCallbacks = {};
12545
12634
  this.//-----------------Editor temp solution-----------------
12546
12635
  /** @internal */ _objectPool = Object.create(null);
12547
12636
  this./** @internal */ _editorResourceConfig = Object.create(null);
@@ -12569,6 +12658,21 @@ var /** @internal */ PromiseState;
12569
12658
  return (_this__assetUrlPool_url = this._assetUrlPool[url]) != null ? _this__assetUrlPool_url : null;
12570
12659
  };
12571
12660
  /**
12661
+ * Find the resource by type.
12662
+ * @param type - Resource type
12663
+ * @returns - Resource collection
12664
+ */ _proto.findResourcesByType = function findResourcesByType(type) {
12665
+ var resources = new Array();
12666
+ var referResourcePool = this._referResourcePool;
12667
+ for(var k in referResourcePool){
12668
+ var resource = referResourcePool[k];
12669
+ if (_instanceof(resource, type)) {
12670
+ resources.push(resource);
12671
+ }
12672
+ }
12673
+ return resources;
12674
+ };
12675
+ /**
12572
12676
  * Get asset url from instanceId.
12573
12677
  * @param instanceId - Engine instance id
12574
12678
  * @returns Asset url
@@ -12606,6 +12710,20 @@ var /** @internal */ PromiseState;
12606
12710
  };
12607
12711
  /**
12608
12712
  * @internal
12713
+ */ _proto._onSubAssetSuccess = function _onSubAssetSuccess(assetURL, value) {
12714
+ var _this__subAssetPromiseCallbacks_assetURL;
12715
+ (_this__subAssetPromiseCallbacks_assetURL = this._subAssetPromiseCallbacks[assetURL]) == null ? void 0 : _this__subAssetPromiseCallbacks_assetURL.resolve(value);
12716
+ delete this._subAssetPromiseCallbacks[assetURL];
12717
+ };
12718
+ /**
12719
+ * @internal
12720
+ */ _proto._onSubAssetFail = function _onSubAssetFail(assetURL, value) {
12721
+ var _this__subAssetPromiseCallbacks_assetURL;
12722
+ (_this__subAssetPromiseCallbacks_assetURL = this._subAssetPromiseCallbacks[assetURL]) == null ? void 0 : _this__subAssetPromiseCallbacks_assetURL.reject(value);
12723
+ delete this._subAssetPromiseCallbacks[assetURL];
12724
+ };
12725
+ /**
12726
+ * @internal
12609
12727
  */ _proto._addAsset = function _addAsset(path, asset) {
12610
12728
  this._assetPool[asset.instanceId] = path;
12611
12729
  this._assetUrlPool[path] = asset;
@@ -12715,6 +12833,10 @@ var /** @internal */ PromiseState;
12715
12833
  var assetURL = assetBaseURL;
12716
12834
  if (queryPath) {
12717
12835
  assetURL += "?q=" + paths.shift();
12836
+ var index;
12837
+ while(index = paths.shift()){
12838
+ assetURL += "[" + index + "]";
12839
+ }
12718
12840
  }
12719
12841
  // Check is loading
12720
12842
  var loadingPromises = this._loadingPromises;
@@ -12722,7 +12844,7 @@ var /** @internal */ PromiseState;
12722
12844
  if (loadingPromise) {
12723
12845
  return new AssetPromise(function(resolve, reject) {
12724
12846
  loadingPromise.then(function(resource) {
12725
- resolve(_this._getResolveResource(resource, paths));
12847
+ resolve(resource);
12726
12848
  }).catch(function(error) {
12727
12849
  reject(error);
12728
12850
  });
@@ -12736,38 +12858,37 @@ var /** @internal */ PromiseState;
12736
12858
  // Load asset
12737
12859
  item.url = assetBaseURL;
12738
12860
  var promise = loader.load(item, this);
12739
- if (_instanceof(promise, AssetPromise)) {
12740
- loadingPromises[assetBaseURL] = promise;
12741
- promise.then(function(resource) {
12742
- if (loader.useCache) {
12743
- _this._addAsset(assetBaseURL, resource);
12744
- }
12745
- delete loadingPromises[assetBaseURL];
12861
+ loadingPromises[assetBaseURL] = promise;
12862
+ promise.then(function(resource) {
12863
+ if (loader.useCache) {
12864
+ _this._addAsset(assetBaseURL, resource);
12865
+ }
12866
+ delete loadingPromises[assetBaseURL];
12867
+ }, function() {
12868
+ return delete loadingPromises[assetBaseURL];
12869
+ });
12870
+ if (queryPath) {
12871
+ var subPromise = new AssetPromise(function(resolve, reject) {
12872
+ _this._pushSubAssetPromiseCallback(assetURL, resolve, reject);
12873
+ });
12874
+ loadingPromises[assetURL] = subPromise;
12875
+ subPromise.then(function() {
12876
+ delete loadingPromises[assetURL];
12746
12877
  }, function() {
12747
- return delete loadingPromises[assetBaseURL];
12878
+ return delete loadingPromises[assetURL];
12748
12879
  });
12749
- return promise;
12750
- } else {
12751
- var _loop = function(subURL) {
12752
- var subPromise = promise[subURL];
12753
- var isMaster = assetBaseURL === subURL;
12754
- loadingPromises[subURL] = subPromise;
12755
- subPromise.then(function(resource) {
12756
- if (isMaster) {
12757
- if (loader.useCache) {
12758
- _this._addAsset(subURL, resource);
12759
- for(var k in promise)delete loadingPromises[k];
12760
- }
12761
- }
12762
- }, function() {
12763
- for(var k in promise)delete loadingPromises[k];
12764
- });
12765
- };
12766
- for(var subURL in promise)_loop(subURL);
12767
- return promise[assetURL].then(function(resource) {
12768
- return _this._getResolveResource(resource, paths);
12880
+ promise.catch(function(e) {
12881
+ _this._onSubAssetFail(assetURL, e);
12769
12882
  });
12883
+ return subPromise;
12770
12884
  }
12885
+ return promise;
12886
+ };
12887
+ _proto._pushSubAssetPromiseCallback = function _pushSubAssetPromiseCallback(assetURL, resolve, reject) {
12888
+ this._subAssetPromiseCallbacks[assetURL] = {
12889
+ resolve: resolve,
12890
+ reject: reject
12891
+ };
12771
12892
  };
12772
12893
  _proto._gc = function _gc(forceDestroy) {
12773
12894
  var objects = Utils.objectValues(this._referResourcePool);
@@ -12930,17 +13051,21 @@ var rePropName = RegExp(// Match anything that isn't a dot or bracket.
12930
13051
  if (this._currentEnteredEntity !== rayCastEntity) {
12931
13052
  if (this._currentEnteredEntity) {
12932
13053
  var scripts = this._currentEnteredEntity._scripts;
12933
- for(var i = scripts.length - 1; i >= 0; i--){
12934
- var script = scripts.get(i);
12935
- script._waitHandlingInValid || script.onPointerExit(this);
13054
+ scripts.startLoop();
13055
+ for(var i = 0; i < scripts.length; i++){
13056
+ var _scripts_get;
13057
+ (_scripts_get = scripts.get(i)) == null ? void 0 : _scripts_get.onPointerExit(this);
12936
13058
  }
13059
+ scripts.endLoop();
12937
13060
  }
12938
13061
  if (rayCastEntity) {
12939
13062
  var scripts1 = rayCastEntity._scripts;
12940
- for(var i1 = scripts1.length - 1; i1 >= 0; i1--){
12941
- var script1 = scripts1.get(i1);
12942
- script1._waitHandlingInValid || script1.onPointerEnter(this);
13063
+ scripts1.startLoop();
13064
+ for(var i1 = 0; i1 < scripts1.length; i1++){
13065
+ var _scripts_get1;
13066
+ (_scripts_get1 = scripts1.get(i1)) == null ? void 0 : _scripts_get1.onPointerEnter(this);
12943
13067
  }
13068
+ scripts1.endLoop();
12944
13069
  }
12945
13070
  this._currentEnteredEntity = rayCastEntity;
12946
13071
  }
@@ -12950,10 +13075,12 @@ var rePropName = RegExp(// Match anything that isn't a dot or bracket.
12950
13075
  */ _proto._firePointerDown = function _firePointerDown(rayCastEntity) {
12951
13076
  if (rayCastEntity) {
12952
13077
  var scripts = rayCastEntity._scripts;
12953
- for(var i = scripts.length - 1; i >= 0; i--){
12954
- var script = scripts.get(i);
12955
- script._waitHandlingInValid || script.onPointerDown(this);
13078
+ scripts.startLoop();
13079
+ for(var i = 0; i < scripts.length; i++){
13080
+ var _scripts_get;
13081
+ (_scripts_get = scripts.get(i)) == null ? void 0 : _scripts_get.onPointerDown(this);
12956
13082
  }
13083
+ scripts.endLoop();
12957
13084
  }
12958
13085
  this._currentPressedEntity = rayCastEntity;
12959
13086
  };
@@ -12962,10 +13089,12 @@ var rePropName = RegExp(// Match anything that isn't a dot or bracket.
12962
13089
  */ _proto._firePointerDrag = function _firePointerDrag() {
12963
13090
  if (this._currentPressedEntity) {
12964
13091
  var scripts = this._currentPressedEntity._scripts;
12965
- for(var i = scripts.length - 1; i >= 0; i--){
12966
- var script = scripts.get(i);
12967
- script._waitHandlingInValid || script.onPointerDrag(this);
13092
+ scripts.startLoop();
13093
+ for(var i = 0; i < scripts.length; i++){
13094
+ var _scripts_get;
13095
+ (_scripts_get = scripts.get(i)) == null ? void 0 : _scripts_get.onPointerDrag(this);
12968
13096
  }
13097
+ scripts.endLoop();
12969
13098
  }
12970
13099
  };
12971
13100
  /**
@@ -12975,13 +13104,15 @@ var rePropName = RegExp(// Match anything that isn't a dot or bracket.
12975
13104
  if (pressedEntity) {
12976
13105
  var sameTarget = pressedEntity === rayCastEntity;
12977
13106
  var scripts = pressedEntity._scripts;
12978
- for(var i = scripts.length - 1; i >= 0; i--){
13107
+ scripts.startLoop();
13108
+ for(var i = 0; i < scripts.length; i++){
12979
13109
  var script = scripts.get(i);
12980
- if (!script._waitHandlingInValid) {
13110
+ if (script) {
12981
13111
  sameTarget && script.onPointerClick(this);
12982
13112
  script.onPointerUp(this);
12983
13113
  }
12984
13114
  }
13115
+ scripts.endLoop();
12985
13116
  this._currentPressedEntity = null;
12986
13117
  }
12987
13118
  };
@@ -13577,6 +13708,7 @@ var Collision = function Collision() {
13577
13708
  function PhysicsScene(scene) {
13578
13709
  var _this = this;
13579
13710
  this._restTime = 0;
13711
+ this._fixedTimeStep = 1 / 60;
13580
13712
  this._colliders = new DisorderedArray();
13581
13713
  this._gravity = new Vector3(0, -9.81, 0);
13582
13714
  this._onContactEnter = function(obj1, obj2) {
@@ -13584,116 +13716,139 @@ var Collision = function Collision() {
13584
13716
  var shape1 = physicalObjectsMap[obj1];
13585
13717
  var shape2 = physicalObjectsMap[obj2];
13586
13718
  var scripts = shape1.collider.entity._scripts;
13587
- for(var i = 0, len = scripts.length; i < len; i++){
13719
+ scripts.startLoop();
13720
+ for(var i = 0; i < scripts.length; i++){
13588
13721
  var script = scripts.get(i);
13589
- if (!script._waitHandlingInValid) {
13722
+ if (script) {
13590
13723
  var collision = PhysicsScene._collision;
13591
13724
  collision.shape = shape2;
13592
13725
  script.onCollisionEnter(collision);
13593
13726
  }
13594
13727
  }
13728
+ scripts.endLoop();
13595
13729
  scripts = shape2.collider.entity._scripts;
13596
- for(var i1 = 0, len1 = scripts.length; i1 < len1; i1++){
13730
+ scripts.startLoop();
13731
+ for(var i1 = 0; i1 < scripts.length; i1++){
13597
13732
  var script1 = scripts.get(i1);
13598
- if (!script1._waitHandlingInValid) {
13733
+ if (script1) {
13599
13734
  var collision1 = PhysicsScene._collision;
13600
13735
  collision1.shape = shape1;
13601
13736
  script1.onCollisionEnter(collision1);
13602
13737
  }
13603
13738
  }
13739
+ scripts.endLoop();
13604
13740
  };
13605
13741
  this._onContactExit = function(obj1, obj2) {
13606
13742
  var physicalObjectsMap = _this._scene.engine._physicalObjectsMap;
13607
13743
  var shape1 = physicalObjectsMap[obj1];
13608
13744
  var shape2 = physicalObjectsMap[obj2];
13609
13745
  var scripts = shape1.collider.entity._scripts;
13610
- for(var i = 0, len = scripts.length; i < len; i++){
13746
+ scripts.startLoop();
13747
+ for(var i = 0; i < scripts.length; i++){
13611
13748
  var script = scripts.get(i);
13612
- if (!script._waitHandlingInValid) {
13749
+ if (script) {
13613
13750
  var collision = PhysicsScene._collision;
13614
13751
  collision.shape = shape2;
13615
13752
  script.onCollisionExit(collision);
13616
13753
  }
13617
13754
  }
13755
+ scripts.endLoop();
13618
13756
  scripts = shape2.collider.entity._scripts;
13619
- for(var i1 = 0, len1 = scripts.length; i1 < len1; i1++){
13757
+ scripts.startLoop();
13758
+ for(var i1 = 0; i1 < scripts.length; i1++){
13620
13759
  var script1 = scripts.get(i1);
13621
- if (!script1._waitHandlingInValid) {
13760
+ if (script1) {
13622
13761
  var collision1 = PhysicsScene._collision;
13623
13762
  collision1.shape = shape1;
13624
13763
  script1.onCollisionExit(collision1);
13625
13764
  }
13626
13765
  }
13766
+ scripts.endLoop();
13627
13767
  };
13628
13768
  this._onContactStay = function(obj1, obj2) {
13629
13769
  var physicalObjectsMap = _this._scene.engine._physicalObjectsMap;
13630
13770
  var shape1 = physicalObjectsMap[obj1];
13631
13771
  var shape2 = physicalObjectsMap[obj2];
13632
13772
  var scripts = shape1.collider.entity._scripts;
13633
- for(var i = 0, len = scripts.length; i < len; i++){
13773
+ scripts.startLoop();
13774
+ for(var i = 0; i < scripts.length; i++){
13634
13775
  var script = scripts.get(i);
13635
- if (!script._waitHandlingInValid) {
13776
+ if (script) {
13636
13777
  var collision = PhysicsScene._collision;
13637
13778
  collision.shape = shape2;
13638
13779
  script.onCollisionStay(collision);
13639
13780
  }
13640
13781
  }
13782
+ scripts.endLoop();
13641
13783
  scripts = shape2.collider.entity._scripts;
13642
- for(var i1 = 0, len1 = scripts.length; i1 < len1; i1++){
13784
+ scripts.startLoop();
13785
+ for(var i1 = 0; i1 < scripts.length; i1++){
13643
13786
  var script1 = scripts.get(i1);
13644
- if (!script1._waitHandlingInValid) {
13787
+ if (script1) {
13645
13788
  var collision1 = PhysicsScene._collision;
13646
13789
  collision1.shape = shape1;
13647
13790
  script1.onCollisionStay(collision1);
13648
13791
  }
13649
13792
  }
13793
+ scripts.endLoop();
13650
13794
  };
13651
13795
  this._onTriggerEnter = function(obj1, obj2) {
13652
13796
  var physicalObjectsMap = _this._scene.engine._physicalObjectsMap;
13653
13797
  var shape1 = physicalObjectsMap[obj1];
13654
13798
  var shape2 = physicalObjectsMap[obj2];
13655
13799
  var scripts = shape1.collider.entity._scripts;
13656
- for(var i = 0, len = scripts.length; i < len; i++){
13657
- var script = scripts.get(i);
13658
- script._waitHandlingInValid || script.onTriggerEnter(shape2);
13800
+ scripts.startLoop();
13801
+ for(var i = 0; i < scripts.length; i++){
13802
+ var _scripts_get;
13803
+ (_scripts_get = scripts.get(i)) == null ? void 0 : _scripts_get.onTriggerEnter(shape2);
13659
13804
  }
13805
+ scripts.endLoop();
13660
13806
  scripts = shape2.collider.entity._scripts;
13661
- for(var i1 = 0, len1 = scripts.length; i1 < len1; i1++){
13662
- var script1 = scripts.get(i1);
13663
- script1._waitHandlingInValid || script1.onTriggerEnter(shape1);
13807
+ scripts.startLoop();
13808
+ for(var i1 = 0; i1 < scripts.length; i1++){
13809
+ var _scripts_get1;
13810
+ (_scripts_get1 = scripts.get(i1)) == null ? void 0 : _scripts_get1.onTriggerEnter(shape1);
13664
13811
  }
13812
+ scripts.endLoop();
13665
13813
  };
13666
13814
  this._onTriggerExit = function(obj1, obj2) {
13667
13815
  var physicalObjectsMap = _this._scene.engine._physicalObjectsMap;
13668
13816
  var shape1 = physicalObjectsMap[obj1];
13669
13817
  var shape2 = physicalObjectsMap[obj2];
13670
13818
  var scripts = shape1.collider.entity._scripts;
13671
- for(var i = 0, n = scripts.length; i < n; i++){
13672
- var script = scripts.get(i);
13673
- script._waitHandlingInValid || script.onTriggerExit(shape2);
13819
+ scripts.startLoop();
13820
+ for(var i = 0; i < scripts.length; i++){
13821
+ var _scripts_get;
13822
+ (_scripts_get = scripts.get(i)) == null ? void 0 : _scripts_get.onTriggerExit(shape2);
13674
13823
  }
13824
+ scripts.endLoop();
13675
13825
  scripts = shape2.collider.entity._scripts;
13676
- for(var i1 = 0, n1 = scripts.length; i1 < n1; i1++){
13677
- var script1 = scripts.get(i1);
13678
- script1._waitHandlingInValid || script1.onTriggerExit(shape1);
13826
+ scripts.startLoop();
13827
+ for(var i1 = 0; i1 < scripts.length; i1++){
13828
+ var _scripts_get1;
13829
+ (_scripts_get1 = scripts.get(i1)) == null ? void 0 : _scripts_get1.onTriggerExit(shape1);
13679
13830
  }
13831
+ scripts.endLoop();
13680
13832
  };
13681
13833
  this._onTriggerStay = function(obj1, obj2) {
13682
13834
  var physicalObjectsMap = _this._scene.engine._physicalObjectsMap;
13683
13835
  var shape1 = physicalObjectsMap[obj1];
13684
13836
  var shape2 = physicalObjectsMap[obj2];
13685
13837
  var scripts = shape1.collider.entity._scripts;
13686
- for(var i = 0, len = scripts.length; i < len; i++){
13687
- var script = scripts.get(i);
13688
- script._waitHandlingInValid || script.onTriggerStay(shape2);
13838
+ scripts.startLoop();
13839
+ for(var i = 0; i < scripts.length; i++){
13840
+ var _scripts_get;
13841
+ (_scripts_get = scripts.get(i)) == null ? void 0 : _scripts_get.onTriggerStay(shape2);
13689
13842
  }
13843
+ scripts.endLoop();
13690
13844
  scripts = shape2.collider.entity._scripts;
13691
- for(var i1 = 0, len1 = scripts.length; i1 < len1; i1++){
13692
- var script1 = scripts.get(i1);
13693
- script1._waitHandlingInValid || script1.onTriggerStay(shape1);
13845
+ scripts.startLoop();
13846
+ for(var i1 = 0; i1 < scripts.length; i1++){
13847
+ var _scripts_get1;
13848
+ (_scripts_get1 = scripts.get(i1)) == null ? void 0 : _scripts_get1.onTriggerStay(shape1);
13694
13849
  }
13850
+ scripts.endLoop();
13695
13851
  };
13696
- /** The fixed time step in seconds at which physics are performed. */ this.fixedTimeStep = 1 / 60;
13697
13852
  this._scene = scene;
13698
13853
  this._setGravity = this._setGravity.bind(this);
13699
13854
  //@ts-ignore
@@ -13750,7 +13905,7 @@ var Collision = function Collision() {
13750
13905
  * Call on every frame to update pose of objects.
13751
13906
  * @internal
13752
13907
  */ _proto._update = function _update(deltaTime) {
13753
- var _this = this, fixedTimeStep = _this.fixedTimeStep, nativePhysicsManager = _this._nativePhysicsScene;
13908
+ var _this = this, fixedTimeStep = _this._fixedTimeStep, nativePhysicsManager = _this._nativePhysicsScene;
13754
13909
  var componentsManager = this._scene._componentsManager;
13755
13910
  var simulateTime = this._restTime + deltaTime;
13756
13911
  var step = Math.floor(simulateTime / fixedTimeStep);
@@ -13858,6 +14013,17 @@ var Collision = function Collision() {
13858
14013
  gravity.copyFrom(value);
13859
14014
  }
13860
14015
  }
14016
+ },
14017
+ {
14018
+ key: "fixedTimeStep",
14019
+ get: /**
14020
+ * The fixed time step in seconds at which physics are performed.
14021
+ */ function get() {
14022
+ return this._fixedTimeStep;
14023
+ },
14024
+ set: function set(value) {
14025
+ this._fixedTimeStep = Math.max(value, MathUtil$1.zeroTolerance);
14026
+ }
13861
14027
  }
13862
14028
  ]);
13863
14029
  return PhysicsScene;
@@ -15731,6 +15897,7 @@ Joint = __decorate([
15731
15897
  CloneManager.deepCloneObject(this.renderStates, target.renderStates);
15732
15898
  };
15733
15899
  _proto._addReferCount = function _addReferCount(value) {
15900
+ if (this._destroyed) return;
15734
15901
  ReferResource.prototype._addReferCount.call(this, value);
15735
15902
  this.shaderData._addReferCount(value);
15736
15903
  };
@@ -16818,7 +16985,6 @@ ShaderPool.init();
16818
16985
  this._onUpdateScripts = new DisorderedArray();
16819
16986
  this._onLateUpdateScripts = new DisorderedArray();
16820
16987
  this._onPhysicsUpdateScripts = new DisorderedArray();
16821
- this._disableScripts = [];
16822
16988
  this._pendingDestroyScripts = [];
16823
16989
  this._disposeDestroyScripts = [];
16824
16990
  // Animation
@@ -16896,102 +17062,110 @@ ShaderPool.init();
16896
17062
  replaced && (replaced._onUpdateIndex = renderer._onUpdateIndex);
16897
17063
  renderer._onUpdateIndex = -1;
16898
17064
  };
16899
- _proto.addDisableScript = function addDisableScript(component) {
16900
- this._disableScripts.push(component);
16901
- };
16902
17065
  _proto.addPendingDestroyScript = function addPendingDestroyScript(component) {
16903
17066
  this._pendingDestroyScripts.push(component);
16904
17067
  };
16905
17068
  _proto.callScriptOnStart = function callScriptOnStart() {
16906
17069
  var onStartScripts = this._onStartScripts;
16907
17070
  if (onStartScripts.length > 0) {
17071
+ onStartScripts.startLoop();
16908
17072
  var elements = onStartScripts._elements;
16909
17073
  // The 'onStartScripts.length' maybe add if you add some Script with addComponent() in some Script's onStart()
16910
17074
  for(var i = 0; i < onStartScripts.length; i++){
16911
17075
  var script = elements[i];
16912
- if (!script._waitHandlingInValid) {
17076
+ if (script) {
16913
17077
  script._started = true;
16914
- script._onStartIndex = -1;
17078
+ this.removeOnStartScript(script);
16915
17079
  script.onStart();
16916
17080
  }
16917
17081
  }
16918
- onStartScripts.length = 0;
17082
+ onStartScripts.endLoopAndClear();
16919
17083
  }
16920
17084
  };
16921
17085
  _proto.callScriptOnUpdate = function callScriptOnUpdate(deltaTime) {
16922
- var elements = this._onUpdateScripts._elements;
16923
- for(var i = this._onUpdateScripts.length - 1; i >= 0; --i){
17086
+ var onUpdateScripts = this._onUpdateScripts;
17087
+ onUpdateScripts.startLoop();
17088
+ var elements = onUpdateScripts._elements;
17089
+ for(var i = 0; i < onUpdateScripts.length; i++){
16924
17090
  var element = elements[i];
16925
- if (!element._waitHandlingInValid && element._started) {
17091
+ if (element == null ? void 0 : element._started) {
16926
17092
  element.onUpdate(deltaTime);
16927
17093
  }
16928
17094
  }
17095
+ onUpdateScripts.endLoop();
16929
17096
  };
16930
17097
  _proto.callScriptOnLateUpdate = function callScriptOnLateUpdate(deltaTime) {
16931
- var elements = this._onLateUpdateScripts._elements;
16932
- for(var i = this._onLateUpdateScripts.length - 1; i >= 0; --i){
17098
+ var onLateUpdateScripts = this._onLateUpdateScripts;
17099
+ onLateUpdateScripts.startLoop();
17100
+ var elements = onLateUpdateScripts._elements;
17101
+ for(var i = 0; i < onLateUpdateScripts.length; i++){
16933
17102
  var element = elements[i];
16934
- if (!element._waitHandlingInValid && element._started) {
17103
+ if (element == null ? void 0 : element._started) {
16935
17104
  element.onLateUpdate(deltaTime);
16936
17105
  }
16937
17106
  }
17107
+ onLateUpdateScripts.endLoop();
16938
17108
  };
16939
17109
  _proto.callScriptOnPhysicsUpdate = function callScriptOnPhysicsUpdate() {
16940
- var elements = this._onPhysicsUpdateScripts._elements;
16941
- for(var i = this._onPhysicsUpdateScripts.length - 1; i >= 0; --i){
17110
+ var onPhysicsUpdateScripts = this._onPhysicsUpdateScripts;
17111
+ onPhysicsUpdateScripts.startLoop();
17112
+ var elements = onPhysicsUpdateScripts._elements;
17113
+ for(var i = 0; i < onPhysicsUpdateScripts.length; i++){
16942
17114
  var element = elements[i];
16943
- if (!element._waitHandlingInValid && element._started) {
17115
+ if (element == null ? void 0 : element._started) {
16944
17116
  element.onPhysicsUpdate();
16945
17117
  }
16946
17118
  }
17119
+ onPhysicsUpdateScripts.endLoop();
16947
17120
  };
16948
17121
  _proto.callAnimationUpdate = function callAnimationUpdate(deltaTime) {
16949
- var elements = this._onUpdateAnimations._elements;
16950
- for(var i = this._onUpdateAnimations.length - 1; i >= 0; --i){
17122
+ var onUpdateAnimations = this._onUpdateAnimations;
17123
+ onUpdateAnimations.startLoop();
17124
+ var elements = onUpdateAnimations._elements;
17125
+ for(var i = 0; i < onUpdateAnimations.length; i++){
16951
17126
  //@ts-ignore
16952
17127
  elements[i].update(deltaTime);
16953
17128
  }
17129
+ onUpdateAnimations.endLoop();
16954
17130
  };
16955
17131
  _proto.callRendererOnUpdate = function callRendererOnUpdate(deltaTime) {
16956
- var elements = this._onUpdateRenderers._elements;
16957
- for(var i = this._onUpdateRenderers.length - 1; i >= 0; --i){
17132
+ var onUpdateRenderers = this._onUpdateRenderers;
17133
+ onUpdateRenderers.startLoop();
17134
+ var elements = onUpdateRenderers._elements;
17135
+ for(var i = 0; i < onUpdateRenderers.length; i++){
16958
17136
  elements[i].update(deltaTime);
16959
17137
  }
17138
+ onUpdateRenderers.endLoop();
16960
17139
  };
16961
17140
  _proto.handlingInvalidScripts = function handlingInvalidScripts() {
16962
- var _this = this, disableScripts = _this._disableScripts;
16963
- var length = disableScripts.length;
16964
- if (length > 0) {
16965
- for(var i = length - 1; i >= 0; i--){
16966
- var disableScript = disableScripts[i];
16967
- disableScript._waitHandlingInValid && disableScript._handlingInValid();
16968
- }
16969
- disableScripts.length = 0;
16970
- }
16971
- var _this1 = this, pendingDestroyScripts = _this1._disposeDestroyScripts, disposeDestroyScripts = _this1._pendingDestroyScripts;
17141
+ var _this = this, pendingDestroyScripts = _this._disposeDestroyScripts, disposeDestroyScripts = _this._pendingDestroyScripts;
16972
17142
  this._disposeDestroyScripts = disposeDestroyScripts;
16973
17143
  this._pendingDestroyScripts = pendingDestroyScripts;
16974
17144
  length = disposeDestroyScripts.length;
16975
17145
  if (length > 0) {
16976
- for(var i1 = length - 1; i1 >= 0; i1--){
16977
- disposeDestroyScripts[i1].onDestroy();
17146
+ for(var i = length - 1; i >= 0; i--){
17147
+ disposeDestroyScripts[i].onDestroy();
16978
17148
  }
16979
17149
  disposeDestroyScripts.length = 0;
16980
17150
  }
16981
17151
  };
16982
17152
  _proto.callCameraOnBeginRender = function callCameraOnBeginRender(camera) {
16983
17153
  var scripts = camera.entity._scripts;
16984
- for(var i = scripts.length - 1; i >= 0; --i){
16985
- var script = scripts.get(i);
16986
- script._waitHandlingInValid || script.onBeginRender(camera);
17154
+ scripts.startLoop();
17155
+ for(var i = 0; i < scripts.length; i++){
17156
+ var _scripts_get;
17157
+ (_scripts_get = scripts.get(i)) == null ? void 0 : _scripts_get.onBeginRender(camera);
16987
17158
  }
17159
+ scripts.endLoop();
16988
17160
  };
16989
17161
  _proto.callCameraOnEndRender = function callCameraOnEndRender(camera) {
16990
17162
  var scripts = camera.entity._scripts;
16991
- for(var i = scripts.length - 1; i >= 0; --i){
16992
- var script = scripts.get(i);
16993
- script._waitHandlingInValid || script.onEndRender(camera);
17163
+ scripts.startLoop();
17164
+ for(var i = 0; i < scripts.length; i++){
17165
+ var _scripts_get;
17166
+ (_scripts_get = scripts.get(i)) == null ? void 0 : _scripts_get.onEndRender(camera);
16994
17167
  }
17168
+ scripts.endLoop();
16995
17169
  };
16996
17170
  _proto.getActiveChangedTempList = function getActiveChangedTempList() {
16997
17171
  return this._componentsContainerPool.length ? this._componentsContainerPool.pop() : [];
@@ -17962,19 +18136,20 @@ __decorate([
17962
18136
  }
17963
18137
  // Process entity active/inActive
17964
18138
  var inActiveChangeFlag = ActiveChangeFlag.None;
17965
- if (this._isActiveInEngine) {
17966
- // Cross scene should inActive first and then active
17967
- entity._isActiveInHierarchy && oldScene !== this && (inActiveChangeFlag |= ActiveChangeFlag.Scene);
17968
- } else {
17969
- entity._isActiveInHierarchy && (inActiveChangeFlag |= ActiveChangeFlag.Hierarchy);
18139
+ if (entity._isActiveInHierarchy) {
18140
+ this._isActiveInEngine || (inActiveChangeFlag |= ActiveChangeFlag.Hierarchy);
17970
18141
  }
18142
+ // Cross scene should inActive first and then active
18143
+ entity._isActiveInScene && oldScene !== this && (inActiveChangeFlag |= ActiveChangeFlag.Scene);
17971
18144
  inActiveChangeFlag && entity._processInActive(inActiveChangeFlag);
17972
18145
  if (oldScene !== this) {
17973
18146
  Entity._traverseSetOwnerScene(entity, this);
17974
18147
  }
17975
18148
  var activeChangeFlag = ActiveChangeFlag.None;
17976
- if (this._isActiveInEngine && entity._isActive) {
17977
- !entity._isActiveInHierarchy && (activeChangeFlag |= ActiveChangeFlag.Hierarchy);
18149
+ if (entity._isActive) {
18150
+ if (this._isActiveInEngine) {
18151
+ !entity._isActiveInHierarchy && (activeChangeFlag |= ActiveChangeFlag.Hierarchy);
18152
+ }
17978
18153
  (!entity._isActiveInScene || oldScene !== this) && (activeChangeFlag |= ActiveChangeFlag.Scene);
17979
18154
  }
17980
18155
  activeChangeFlag && entity._processActive(activeChangeFlag);
@@ -18330,7 +18505,6 @@ __decorate([
18330
18505
  /** @internal */ _this._onPreRenderIndex = -1;
18331
18506
  /** @internal */ _this._onPostRenderIndex = -1;
18332
18507
  _this._entityScriptsIndex = -1;
18333
- _this._waitHandlingInValid = false;
18334
18508
  return _this;
18335
18509
  }
18336
18510
  var _proto = Script.prototype;
@@ -18439,37 +18613,30 @@ __decorate([
18439
18613
  /**
18440
18614
  * @internal
18441
18615
  */ _proto._onEnableInScene = function _onEnableInScene() {
18442
- if (this._waitHandlingInValid) {
18443
- this._waitHandlingInValid = false;
18444
- } else {
18445
- var _this_scene = this.scene, componentsManager = _this_scene._componentsManager;
18446
- var prototype = Script.prototype;
18447
- if (!this._started) {
18448
- componentsManager.addOnStartScript(this);
18449
- }
18450
- if (this.onUpdate !== prototype.onUpdate) {
18451
- componentsManager.addOnUpdateScript(this);
18452
- }
18453
- if (this.onLateUpdate !== prototype.onLateUpdate) {
18454
- componentsManager.addOnLateUpdateScript(this);
18455
- }
18456
- if (this.onPhysicsUpdate !== prototype.onPhysicsUpdate) {
18457
- componentsManager.addOnPhysicsUpdateScript(this);
18458
- }
18459
- this._entity._addScript(this);
18616
+ var _this_scene = this.scene, componentsManager = _this_scene._componentsManager;
18617
+ var prototype = Script.prototype;
18618
+ if (!this._started) {
18619
+ componentsManager.addOnStartScript(this);
18620
+ }
18621
+ if (this.onUpdate !== prototype.onUpdate) {
18622
+ componentsManager.addOnUpdateScript(this);
18623
+ }
18624
+ if (this.onLateUpdate !== prototype.onLateUpdate) {
18625
+ componentsManager.addOnLateUpdateScript(this);
18626
+ }
18627
+ if (this.onPhysicsUpdate !== prototype.onPhysicsUpdate) {
18628
+ componentsManager.addOnPhysicsUpdateScript(this);
18460
18629
  }
18630
+ this._entity._addScript(this);
18461
18631
  };
18462
18632
  /**
18463
18633
  * @internal
18464
18634
  */ _proto._onDisableInScene = function _onDisableInScene() {
18465
- this._waitHandlingInValid = true;
18466
- this.scene._componentsManager.addDisableScript(this);
18467
- };
18468
- /**
18469
- * @internal
18470
- */ _proto._handlingInValid = function _handlingInValid() {
18471
18635
  var componentsManager = this.scene._componentsManager;
18472
18636
  var prototype = Script.prototype;
18637
+ if (!this._started) {
18638
+ componentsManager.removeOnStartScript(this);
18639
+ }
18473
18640
  if (this.onUpdate !== prototype.onUpdate) {
18474
18641
  componentsManager.removeOnUpdateScript(this);
18475
18642
  }
@@ -18480,7 +18647,6 @@ __decorate([
18480
18647
  componentsManager.removeOnPhysicsUpdateScript(this);
18481
18648
  }
18482
18649
  this._entity._removeScript(this);
18483
- this._waitHandlingInValid = false;
18484
18650
  };
18485
18651
  /**
18486
18652
  * @internal
@@ -18514,9 +18680,6 @@ __decorate([
18514
18680
  __decorate([
18515
18681
  ignoreClone
18516
18682
  ], Script.prototype, "_entityScriptsIndex", void 0);
18517
- __decorate([
18518
- ignoreClone
18519
- ], Script.prototype, "_waitHandlingInValid", void 0);
18520
18683
 
18521
18684
  /**
18522
18685
  * Depth texture mode.
@@ -20831,41 +20994,6 @@ var MultiExecutor = /*#__PURE__*/ function() {
20831
20994
  Loader._engineObjects = {};
20832
20995
  })();
20833
20996
 
20834
- /**
20835
- * Asset Type.
20836
- */ var AssetType;
20837
- (function(AssetType) {
20838
- AssetType[/**
20839
- * Plain text.
20840
- * @remarks Will not be cached based on url in ResourceManager.
20841
- */ "Text"] = "Text";
20842
- AssetType[/**
20843
- * JSON.
20844
- * @remarks Will not be cached based on url in ResourceManager.
20845
- */ "JSON"] = "JSON";
20846
- AssetType[/**
20847
- * ArrayBuffer.
20848
- * @remarks Will not be cached based on url in ResourceManager.
20849
- */ "Buffer"] = "Buffer";
20850
- AssetType[/** 2D Texture. */ "Texture2D"] = "Texture2D";
20851
- AssetType[/** Cube Texture. */ "TextureCube"] = "TextureCube";
20852
- AssetType[/** Material. */ "Material"] = "Material";
20853
- AssetType[/** Mesh. */ "Mesh"] = "Mesh";
20854
- AssetType[/** AnimationClip. */ "AnimationClip"] = "AnimationClip";
20855
- AssetType[/** AnimatorController. */ "AnimatorController"] = "AnimatorController";
20856
- AssetType[/** Prefab.*/ "GLTF"] = "GLTF";
20857
- AssetType[/** Compress Texture. */ "KTX"] = "KTX";
20858
- AssetType[/** Cube Compress Texture. */ "KTXCube"] = "KTXCube";
20859
- AssetType[/** KTX2 Compress Texture */ "KTX2"] = "KTX2";
20860
- AssetType[/** Sprite. */ "Sprite"] = "Sprite";
20861
- AssetType[/** Sprite Atlas. */ "SpriteAtlas"] = "SpriteAtlas";
20862
- AssetType[/** Ambient light. */ "Env"] = "Environment";
20863
- AssetType[/** Scene. */ "Scene"] = "Scene";
20864
- AssetType[/** HDR to cube. */ "HDR"] = "HDR";
20865
- AssetType[/** Font. */ "Font"] = "Font";
20866
- AssetType[/** Source Font, include ttf、 otf and woff. */ "SourceFont"] = "SourceFont";
20867
- })(AssetType || (AssetType = {}));
20868
-
20869
20997
  /**
20870
20998
  * Alpha blend mode.
20871
20999
  */ var BlendMode;