@galacean/engine-core 1.2.0-alpha.3 → 1.2.0-alpha.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/main.js +239 -203
- package/dist/main.js.map +1 -1
- package/dist/miniprogram.js +239 -203
- package/dist/module.js +238 -202
- package/dist/module.js.map +1 -1
- package/package.json +3 -3
- package/types/Scene.d.ts +5 -0
- package/types/asset/Loader.d.ts +7 -0
- package/types/particle/modules/MainModule.d.ts +2 -0
- package/types/particle/modules/shape/BaseShape.d.ts +1 -1
- package/types/particle/modules/shape/BoxShape.d.ts +2 -1
- package/types/particle/modules/shape/CircleShape.d.ts +2 -1
- package/types/particle/modules/shape/ConeShape.d.ts +2 -1
- package/types/particle/modules/shape/HemisphereShape.d.ts +2 -1
- package/types/particle/modules/shape/SphereShape.d.ts +2 -1
- package/types/particle/modules/shape/index.d.ts +1 -0
- package/types/shadow/CascadedShadowCasterPass.d.ts +0 -1
package/dist/miniprogram.js
CHANGED
|
@@ -3293,7 +3293,7 @@ var PBRShaderLib = {
|
|
|
3293
3293
|
|
|
3294
3294
|
var ShadowCoord = "#define GLSLIFY 1\nuniform mat4 scene_ShadowMatrices[SCENE_SHADOW_CASCADED_COUNT+1];uniform vec4 scene_ShadowSplitSpheres[4];mediump int computeCascadeIndex(vec3 positionWS){vec3 fromCenter0=positionWS-scene_ShadowSplitSpheres[0].xyz;vec3 fromCenter1=positionWS-scene_ShadowSplitSpheres[1].xyz;vec3 fromCenter2=positionWS-scene_ShadowSplitSpheres[2].xyz;vec3 fromCenter3=positionWS-scene_ShadowSplitSpheres[3].xyz;mediump vec4 comparison=vec4(dot(fromCenter0,fromCenter0)<scene_ShadowSplitSpheres[0].w,dot(fromCenter1,fromCenter1)<scene_ShadowSplitSpheres[1].w,dot(fromCenter2,fromCenter2)<scene_ShadowSplitSpheres[2].w,dot(fromCenter3,fromCenter3)<scene_ShadowSplitSpheres[3].w);comparison.yzw=clamp(comparison.yzw-comparison.xyz,0.0,1.0);mediump vec4 indexCoefficient=vec4(4.0,3.0,2.0,1.0);mediump int index=4-int(dot(comparison,indexCoefficient));return index;}vec3 getShadowCoord(){\n#if SCENE_SHADOW_CASCADED_COUNT == 1\nmediump int cascadeIndex=0;\n#else\nmediump int cascadeIndex=computeCascadeIndex(v_pos);\n#endif\n#ifdef GRAPHICS_API_WEBGL2\nmat4 shadowMatrix=scene_ShadowMatrices[cascadeIndex];\n#else\nmat4 shadowMatrix;\n#if SCENE_SHADOW_CASCADED_COUNT == 4\nif(cascadeIndex==0){shadowMatrix=scene_ShadowMatrices[0];}else if(cascadeIndex==1){shadowMatrix=scene_ShadowMatrices[1];}else if(cascadeIndex==2){shadowMatrix=scene_ShadowMatrices[2];}else if(cascadeIndex==3){shadowMatrix=scene_ShadowMatrices[3];}else{shadowMatrix=scene_ShadowMatrices[4];}\n#endif\n#if SCENE_SHADOW_CASCADED_COUNT == 2\nif(cascadeIndex==0){shadowMatrix=scene_ShadowMatrices[0];}else if(cascadeIndex==1){shadowMatrix=scene_ShadowMatrices[1];}else{shadowMatrix=scene_ShadowMatrices[2];}\n#endif\n#if SCENE_SHADOW_CASCADED_COUNT == 1\nif(cascadeIndex==0){shadowMatrix=scene_ShadowMatrices[0];}else{shadowMatrix=scene_ShadowMatrices[1];}\n#endif\n#endif\nvec4 shadowCoord=shadowMatrix*vec4(v_pos,1.0);return shadowCoord.xyz;}"; // eslint-disable-line
|
|
3295
3295
|
|
|
3296
|
-
var ShadowFragmentDeclaration = "#define GLSLIFY 1\n#if defined(SCENE_SHADOW_TYPE) && defined(RENDERER_IS_RECEIVE_SHADOWS)\n#define SCENE_IS_CALCULATE_SHADOWS\n#endif\n#ifdef SCENE_IS_CALCULATE_SHADOWS\n#if SCENE_SHADOW_CASCADED_COUNT == 1\nvarying vec3 v_shadowCoord;\n#else\n#include <ShadowCoord>\n#endif\nuniform
|
|
3296
|
+
var ShadowFragmentDeclaration = "#define GLSLIFY 1\n#if defined(SCENE_SHADOW_TYPE) && defined(RENDERER_IS_RECEIVE_SHADOWS)\n#define SCENE_IS_CALCULATE_SHADOWS\n#endif\n#ifdef SCENE_IS_CALCULATE_SHADOWS\n#if SCENE_SHADOW_CASCADED_COUNT == 1\nvarying vec3 v_shadowCoord;\n#else\n#include <ShadowCoord>\n#endif\nuniform vec4 scene_ShadowInfo;uniform vec4 scene_ShadowMapSize;\n#ifdef GRAPHICS_API_WEBGL2\nuniform mediump sampler2DShadow scene_ShadowMap;\n#define SAMPLE_TEXTURE2D_SHADOW(textureName, coord3) textureLod(textureName, coord3 , 0.0)\n#define TEXTURE2D_SHADOW_PARAM(shadowMap) mediump sampler2DShadow shadowMap\n#else\nuniform sampler2D scene_ShadowMap;\n#ifdef ENGINE_NO_DEPTH_TEXTURE\nconst vec4 bitShift=vec4(1.0,1.0/256.0,1.0/(256.0*256.0),1.0/(256.0*256.0*256.0));float unpack(const in vec4 rgbaDepth){return dot(rgbaDepth,bitShift);}\n#define SAMPLE_TEXTURE2D_SHADOW(textureName, coord3) (unpack(texture2D(textureName, coord3.xy)) < coord3.z ? 0.0 : 1.0)\n#else\n#define SAMPLE_TEXTURE2D_SHADOW(textureName, coord3) (texture2D(textureName, coord3.xy).r < coord3.z ? 0.0 : 1.0)\n#endif\n#define TEXTURE2D_SHADOW_PARAM(shadowMap) mediump sampler2D shadowMap\n#endif\n#if SCENE_SHADOW_TYPE == 2\nfloat sampleShadowMapFiltered4(TEXTURE2D_SHADOW_PARAM(shadowMap),vec3 shadowCoord,vec4 shadowMapSize){float attenuation;vec4 attenuation4;vec2 offset=shadowMapSize.xy/2.0;vec3 shadowCoord0=shadowCoord+vec3(-offset,0.0);vec3 shadowCoord1=shadowCoord+vec3(offset.x,-offset.y,0.0);vec3 shadowCoord2=shadowCoord+vec3(-offset.x,offset.y,0.0);vec3 shadowCoord3=shadowCoord+vec3(offset,0.0);attenuation4.x=SAMPLE_TEXTURE2D_SHADOW(shadowMap,shadowCoord0);attenuation4.y=SAMPLE_TEXTURE2D_SHADOW(shadowMap,shadowCoord1);attenuation4.z=SAMPLE_TEXTURE2D_SHADOW(shadowMap,shadowCoord2);attenuation4.w=SAMPLE_TEXTURE2D_SHADOW(shadowMap,shadowCoord3);attenuation=dot(attenuation4,vec4(0.25));return attenuation;}\n#endif\n#if SCENE_SHADOW_TYPE == 3\n#include <shadow_sample_tent>\nfloat sampleShadowMapFiltered9(TEXTURE2D_SHADOW_PARAM(shadowMap),vec3 shadowCoord,vec4 shadowmapSize){float attenuation;float fetchesWeights[9];vec2 fetchesUV[9];sampleShadowComputeSamplesTent5x5(shadowmapSize,shadowCoord.xy,fetchesWeights,fetchesUV);attenuation=fetchesWeights[0]*SAMPLE_TEXTURE2D_SHADOW(shadowMap,vec3(fetchesUV[0].xy,shadowCoord.z));attenuation+=fetchesWeights[1]*SAMPLE_TEXTURE2D_SHADOW(shadowMap,vec3(fetchesUV[1].xy,shadowCoord.z));attenuation+=fetchesWeights[2]*SAMPLE_TEXTURE2D_SHADOW(shadowMap,vec3(fetchesUV[2].xy,shadowCoord.z));attenuation+=fetchesWeights[3]*SAMPLE_TEXTURE2D_SHADOW(shadowMap,vec3(fetchesUV[3].xy,shadowCoord.z));attenuation+=fetchesWeights[4]*SAMPLE_TEXTURE2D_SHADOW(shadowMap,vec3(fetchesUV[4].xy,shadowCoord.z));attenuation+=fetchesWeights[5]*SAMPLE_TEXTURE2D_SHADOW(shadowMap,vec3(fetchesUV[5].xy,shadowCoord.z));attenuation+=fetchesWeights[6]*SAMPLE_TEXTURE2D_SHADOW(shadowMap,vec3(fetchesUV[6].xy,shadowCoord.z));attenuation+=fetchesWeights[7]*SAMPLE_TEXTURE2D_SHADOW(shadowMap,vec3(fetchesUV[7].xy,shadowCoord.z));attenuation+=fetchesWeights[8]*SAMPLE_TEXTURE2D_SHADOW(shadowMap,vec3(fetchesUV[8].xy,shadowCoord.z));return attenuation;}\n#endif\nfloat getShadowFade(vec3 positionWS){vec3 camToPixel=positionWS-camera_Position;float distanceCamToPixel2=dot(camToPixel,camToPixel);return saturate(distanceCamToPixel2*scene_ShadowInfo.z+scene_ShadowInfo.w);}float sampleShadowMap(){\n#if SCENE_SHADOW_CASCADED_COUNT == 1\nvec3 shadowCoord=v_shadowCoord;\n#else\nvec3 shadowCoord=getShadowCoord();\n#endif\nfloat attenuation=1.0;if(shadowCoord.z>0.0&&shadowCoord.z<1.0){\n#if SCENE_SHADOW_TYPE == 1\nattenuation=SAMPLE_TEXTURE2D_SHADOW(scene_ShadowMap,shadowCoord);\n#endif\n#if SCENE_SHADOW_TYPE == 2\nattenuation=sampleShadowMapFiltered4(scene_ShadowMap,shadowCoord,scene_ShadowMapSize);\n#endif\n#if SCENE_SHADOW_TYPE == 3\nattenuation=sampleShadowMapFiltered9(scene_ShadowMap,shadowCoord,scene_ShadowMapSize);\n#endif\nfloat shadowFade=getShadowFade(v_pos);attenuation=mix(1.0,mix(attenuation,1.0,shadowFade),scene_ShadowInfo.x);}return attenuation;}\n#endif\n"; // eslint-disable-line
|
|
3297
3297
|
|
|
3298
3298
|
var shadow_sample_tent = "#define GLSLIFY 1\nfloat sampleShadowGetIRTriangleTexelArea(float triangleHeight){return triangleHeight-0.5;}void sampleShadowGetTexelAreasTent3x3(float offset,out vec4 computedArea,out vec4 computedAreaUncut){float a=offset+0.5;float offsetSquaredHalved=a*a*0.5;computedAreaUncut.x=computedArea.x=offsetSquaredHalved-offset;computedAreaUncut.w=computedArea.w=offsetSquaredHalved;computedAreaUncut.y=sampleShadowGetIRTriangleTexelArea(1.5-offset);float clampedOffsetLeft=min(offset,0.0);float areaOfSmallLeftTriangle=clampedOffsetLeft*clampedOffsetLeft;computedArea.y=computedAreaUncut.y-areaOfSmallLeftTriangle;computedAreaUncut.z=sampleShadowGetIRTriangleTexelArea(1.5+offset);float clampedOffsetRight=max(offset,0.0);float areaOfSmallRightTriangle=clampedOffsetRight*clampedOffsetRight;computedArea.z=computedAreaUncut.z-areaOfSmallRightTriangle;}void sampleShadowGetTexelWeightsTent5x5(float offset,out vec3 texelsWeightsA,out vec3 texelsWeightsB){vec4 areaFrom3texelTriangle;vec4 areaUncutFrom3texelTriangle;sampleShadowGetTexelAreasTent3x3(offset,areaFrom3texelTriangle,areaUncutFrom3texelTriangle);texelsWeightsA.x=0.16*(areaFrom3texelTriangle.x);texelsWeightsA.y=0.16*(areaUncutFrom3texelTriangle.y);texelsWeightsA.z=0.16*(areaFrom3texelTriangle.y+1.0);texelsWeightsB.x=0.16*(areaFrom3texelTriangle.z+1.0);texelsWeightsB.y=0.16*(areaUncutFrom3texelTriangle.z);texelsWeightsB.z=0.16*(areaFrom3texelTriangle.w);}void sampleShadowComputeSamplesTent5x5(vec4 shadowMapTextureTexelSize,vec2 coord,out float fetchesWeights[9],out vec2 fetchesUV[9]){vec2 tentCenterInTexelSpace=coord.xy*shadowMapTextureTexelSize.zw;vec2 centerOfFetchesInTexelSpace=floor(tentCenterInTexelSpace+0.5);vec2 offsetFromTentCenterToCenterOfFetches=tentCenterInTexelSpace-centerOfFetchesInTexelSpace;vec3 texelsWeightsUA,texelsWeightsUB;vec3 texelsWeightsVA,texelsWeightsVB;sampleShadowGetTexelWeightsTent5x5(offsetFromTentCenterToCenterOfFetches.x,texelsWeightsUA,texelsWeightsUB);sampleShadowGetTexelWeightsTent5x5(offsetFromTentCenterToCenterOfFetches.y,texelsWeightsVA,texelsWeightsVB);vec3 fetchesWeightsU=vec3(texelsWeightsUA.xz,texelsWeightsUB.y)+vec3(texelsWeightsUA.y,texelsWeightsUB.xz);vec3 fetchesWeightsV=vec3(texelsWeightsVA.xz,texelsWeightsVB.y)+vec3(texelsWeightsVA.y,texelsWeightsVB.xz);vec3 fetchesOffsetsU=vec3(texelsWeightsUA.y,texelsWeightsUB.xz)/fetchesWeightsU.xyz+vec3(-2.5,-0.5,1.5);vec3 fetchesOffsetsV=vec3(texelsWeightsVA.y,texelsWeightsVB.xz)/fetchesWeightsV.xyz+vec3(-2.5,-0.5,1.5);fetchesOffsetsU*=shadowMapTextureTexelSize.xxx;fetchesOffsetsV*=shadowMapTextureTexelSize.yyy;vec2 bilinearFetchOrigin=centerOfFetchesInTexelSpace*shadowMapTextureTexelSize.xy;fetchesUV[0]=bilinearFetchOrigin+vec2(fetchesOffsetsU.x,fetchesOffsetsV.x);fetchesUV[1]=bilinearFetchOrigin+vec2(fetchesOffsetsU.y,fetchesOffsetsV.x);fetchesUV[2]=bilinearFetchOrigin+vec2(fetchesOffsetsU.z,fetchesOffsetsV.x);fetchesUV[3]=bilinearFetchOrigin+vec2(fetchesOffsetsU.x,fetchesOffsetsV.y);fetchesUV[4]=bilinearFetchOrigin+vec2(fetchesOffsetsU.y,fetchesOffsetsV.y);fetchesUV[5]=bilinearFetchOrigin+vec2(fetchesOffsetsU.z,fetchesOffsetsV.y);fetchesUV[6]=bilinearFetchOrigin+vec2(fetchesOffsetsU.x,fetchesOffsetsV.z);fetchesUV[7]=bilinearFetchOrigin+vec2(fetchesOffsetsU.y,fetchesOffsetsV.z);fetchesUV[8]=bilinearFetchOrigin+vec2(fetchesOffsetsU.z,fetchesOffsetsV.z);fetchesWeights[0]=fetchesWeightsU.x*fetchesWeightsV.x;fetchesWeights[1]=fetchesWeightsU.y*fetchesWeightsV.x;fetchesWeights[2]=fetchesWeightsU.z*fetchesWeightsV.x;fetchesWeights[3]=fetchesWeightsU.x*fetchesWeightsV.y;fetchesWeights[4]=fetchesWeightsU.y*fetchesWeightsV.y;fetchesWeights[5]=fetchesWeightsU.z*fetchesWeightsV.y;fetchesWeights[6]=fetchesWeightsU.x*fetchesWeightsV.z;fetchesWeights[7]=fetchesWeightsU.y*fetchesWeightsV.z;fetchesWeights[8]=fetchesWeightsU.z*fetchesWeightsV.z;}"; // eslint-disable-line
|
|
3299
3299
|
|
|
@@ -20963,6 +20963,10 @@ __decorate([
|
|
|
20963
20963
|
/** The splits of two cascade distribution. */ _this.shadowTwoCascadeSplits = 1.0 / 3.0;
|
|
20964
20964
|
/** The splits of four cascade distribution. */ _this.shadowFourCascadeSplits = new miniprogram.Vector3(1.0 / 15, 3.0 / 15.0, 7.0 / 15.0);
|
|
20965
20965
|
/** Max Shadow distance. */ _this.shadowDistance = 50;
|
|
20966
|
+
/**
|
|
20967
|
+
* Last shadow fade distance in percentage, range [0,1].
|
|
20968
|
+
* @remarks Value 0 is used for no shadow fade.
|
|
20969
|
+
*/ _this.shadowFadeBorder = 0.1;
|
|
20966
20970
|
/* @internal */ _this._lightManager = new LightManager();
|
|
20967
20971
|
/* @internal */ _this._componentsManager = new ComponentsManager();
|
|
20968
20972
|
/** @internal */ _this._isActiveInEngine = false;
|
|
@@ -21587,47 +21591,66 @@ __decorate([
|
|
|
21587
21591
|
DepthTextureMode[DepthTextureMode[/* Generate depth texture by pre-pass rendering. */ "PrePass"] = 1] = "PrePass";
|
|
21588
21592
|
})(exports.DepthTextureMode || (exports.DepthTextureMode = {}));
|
|
21589
21593
|
|
|
21590
|
-
var passNum = 0;
|
|
21591
21594
|
/**
|
|
21592
|
-
*
|
|
21593
|
-
*/ var
|
|
21594
|
-
|
|
21595
|
-
|
|
21596
|
-
|
|
21597
|
-
|
|
21598
|
-
|
|
21599
|
-
|
|
21600
|
-
|
|
21601
|
-
this.enabled = true;
|
|
21602
|
-
this.priority = priority;
|
|
21603
|
-
this.renderTarget = renderTarget;
|
|
21604
|
-
this.replaceMaterial = replaceMaterial;
|
|
21605
|
-
this.mask = mask || exports.Layer.Everything;
|
|
21606
|
-
this.renderOverride = false; // If renderOverride is set to true, you need to implement the render method
|
|
21607
|
-
}
|
|
21608
|
-
var _proto = RenderPass.prototype;
|
|
21609
|
-
/**
|
|
21610
|
-
* Rendering callback, will be executed if renderOverride is set to true.
|
|
21611
|
-
* @param camera - Camera
|
|
21612
|
-
* @param opaqueQueue - Opaque queue
|
|
21613
|
-
* @param alphaTestQueue - Alpha test queue
|
|
21614
|
-
* @param transparentQueue - Transparent queue
|
|
21615
|
-
*/ _proto.render = function render(camera, opaqueQueue, alphaTestQueue, transparentQueue) {};
|
|
21595
|
+
* PipelinePass is a base class for all pipeline passes.
|
|
21596
|
+
*/ var PipelinePass = function PipelinePass(engine) {
|
|
21597
|
+
this._engine = engine;
|
|
21598
|
+
};
|
|
21599
|
+
|
|
21600
|
+
/**
|
|
21601
|
+
* @internal
|
|
21602
|
+
*/ var PipelineUtils = /*#__PURE__*/ function() {
|
|
21603
|
+
function PipelineUtils() {}
|
|
21616
21604
|
/**
|
|
21617
|
-
*
|
|
21618
|
-
* @param
|
|
21619
|
-
* @param
|
|
21620
|
-
* @param
|
|
21621
|
-
* @param
|
|
21622
|
-
|
|
21605
|
+
* Recreate texture if needed.
|
|
21606
|
+
* @param engine - Engine
|
|
21607
|
+
* @param currentTexture - Current texture
|
|
21608
|
+
* @param width - Need texture width
|
|
21609
|
+
* @param height - Need texture height
|
|
21610
|
+
* @param format - Need texture format
|
|
21611
|
+
* @param mipmap - Need texture mipmap
|
|
21612
|
+
* @returns Texture
|
|
21613
|
+
*/ PipelineUtils.recreateTextureIfNeeded = function recreateTextureIfNeeded(engine, currentTexture, width, height, format, mipmap) {
|
|
21614
|
+
if (currentTexture) {
|
|
21615
|
+
if (currentTexture.width !== width || currentTexture.height !== height || currentTexture.format !== format || currentTexture.mipmapCount > 1 !== mipmap) {
|
|
21616
|
+
currentTexture.destroy();
|
|
21617
|
+
var texture = new Texture2D(engine, width, height, format, mipmap);
|
|
21618
|
+
texture.isGCIgnored = true;
|
|
21619
|
+
return texture;
|
|
21620
|
+
} else {
|
|
21621
|
+
return currentTexture;
|
|
21622
|
+
}
|
|
21623
|
+
} else {
|
|
21624
|
+
var texture1 = new Texture2D(engine, width, height, format, mipmap);
|
|
21625
|
+
texture1.isGCIgnored = true;
|
|
21626
|
+
return texture1;
|
|
21627
|
+
}
|
|
21628
|
+
};
|
|
21623
21629
|
/**
|
|
21624
|
-
*
|
|
21625
|
-
* @param
|
|
21626
|
-
* @param
|
|
21627
|
-
* @param
|
|
21628
|
-
* @param
|
|
21629
|
-
|
|
21630
|
-
|
|
21630
|
+
* Recreate render target if needed.
|
|
21631
|
+
* @param engine - Engine
|
|
21632
|
+
* @param currentRenderTarget - Current render target
|
|
21633
|
+
* @param width - Need render target width
|
|
21634
|
+
* @param height - Need render target height
|
|
21635
|
+
* @param colorFormat - Need render target color format
|
|
21636
|
+
* @param depthFormat - Need render target depth format
|
|
21637
|
+
* @param mipmap - Need render target mipmap
|
|
21638
|
+
* @returns Render target
|
|
21639
|
+
*/ PipelineUtils.recreateRenderTargetIfNeeded = function recreateRenderTargetIfNeeded(engine, currentRenderTarget, width, height, colorFormat, depthFormat, mipmap) {
|
|
21640
|
+
var _currentRenderTarget, _currentRenderTarget1;
|
|
21641
|
+
var currentColorTexture = (_currentRenderTarget = currentRenderTarget) == null ? void 0 : _currentRenderTarget.getColorTexture(0);
|
|
21642
|
+
var currentDepthTexture = (_currentRenderTarget1 = currentRenderTarget) == null ? void 0 : _currentRenderTarget1.depthTexture;
|
|
21643
|
+
var colorTexture = colorFormat ? PipelineUtils.recreateTextureIfNeeded(engine, currentColorTexture, width, height, colorFormat, mipmap) : null;
|
|
21644
|
+
var depthTexture = depthFormat ? PipelineUtils.recreateTextureIfNeeded(engine, currentDepthTexture, width, height, depthFormat, mipmap) : null;
|
|
21645
|
+
if (currentColorTexture !== colorTexture || currentDepthTexture !== depthTexture) {
|
|
21646
|
+
var _currentRenderTarget2;
|
|
21647
|
+
(_currentRenderTarget2 = currentRenderTarget) == null ? void 0 : _currentRenderTarget2.destroy();
|
|
21648
|
+
currentRenderTarget = new RenderTarget(engine, width, height, colorTexture, depthTexture);
|
|
21649
|
+
currentRenderTarget.isGCIgnored = true;
|
|
21650
|
+
}
|
|
21651
|
+
return currentRenderTarget;
|
|
21652
|
+
};
|
|
21653
|
+
return PipelineUtils;
|
|
21631
21654
|
}();
|
|
21632
21655
|
|
|
21633
21656
|
/**
|
|
@@ -21934,60 +21957,47 @@ var passNum = 0;
|
|
|
21934
21957
|
return RenderQueue;
|
|
21935
21958
|
}();
|
|
21936
21959
|
|
|
21960
|
+
var passNum = 0;
|
|
21937
21961
|
/**
|
|
21938
|
-
*
|
|
21939
|
-
*/ var
|
|
21940
|
-
function
|
|
21962
|
+
* RenderPass.
|
|
21963
|
+
*/ var RenderPass = /*#__PURE__*/ function() {
|
|
21964
|
+
function RenderPass(name, priority, renderTarget, replaceMaterial, mask) {
|
|
21965
|
+
if (name === void 0) name = "RENDER_PASS" + passNum++;
|
|
21966
|
+
if (priority === void 0) priority = 0;
|
|
21967
|
+
if (renderTarget === void 0) renderTarget = null;
|
|
21968
|
+
if (replaceMaterial === void 0) replaceMaterial = null;
|
|
21969
|
+
if (mask === void 0) mask = null;
|
|
21970
|
+
this.name = name;
|
|
21971
|
+
this.enabled = true;
|
|
21972
|
+
this.priority = priority;
|
|
21973
|
+
this.renderTarget = renderTarget;
|
|
21974
|
+
this.replaceMaterial = replaceMaterial;
|
|
21975
|
+
this.mask = mask || exports.Layer.Everything;
|
|
21976
|
+
this.renderOverride = false; // If renderOverride is set to true, you need to implement the render method
|
|
21977
|
+
}
|
|
21978
|
+
var _proto = RenderPass.prototype;
|
|
21941
21979
|
/**
|
|
21942
|
-
*
|
|
21943
|
-
* @param
|
|
21944
|
-
* @param
|
|
21945
|
-
* @param
|
|
21946
|
-
* @param
|
|
21947
|
-
|
|
21948
|
-
* @param mipmap - Need texture mipmap
|
|
21949
|
-
* @returns Texture
|
|
21950
|
-
*/ PipelineUtils.recreateTextureIfNeeded = function recreateTextureIfNeeded(engine, currentTexture, width, height, format, mipmap) {
|
|
21951
|
-
if (currentTexture) {
|
|
21952
|
-
if (currentTexture.width !== width || currentTexture.height !== height || currentTexture.format !== format || currentTexture.mipmapCount > 1 !== mipmap) {
|
|
21953
|
-
currentTexture.destroy();
|
|
21954
|
-
var texture = new Texture2D(engine, width, height, format, mipmap);
|
|
21955
|
-
texture.isGCIgnored = true;
|
|
21956
|
-
return texture;
|
|
21957
|
-
} else {
|
|
21958
|
-
return currentTexture;
|
|
21959
|
-
}
|
|
21960
|
-
} else {
|
|
21961
|
-
var texture1 = new Texture2D(engine, width, height, format, mipmap);
|
|
21962
|
-
texture1.isGCIgnored = true;
|
|
21963
|
-
return texture1;
|
|
21964
|
-
}
|
|
21965
|
-
};
|
|
21980
|
+
* Rendering callback, will be executed if renderOverride is set to true.
|
|
21981
|
+
* @param camera - Camera
|
|
21982
|
+
* @param opaqueQueue - Opaque queue
|
|
21983
|
+
* @param alphaTestQueue - Alpha test queue
|
|
21984
|
+
* @param transparentQueue - Transparent queue
|
|
21985
|
+
*/ _proto.render = function render(camera, opaqueQueue, alphaTestQueue, transparentQueue) {};
|
|
21966
21986
|
/**
|
|
21967
|
-
*
|
|
21968
|
-
* @param
|
|
21969
|
-
* @param
|
|
21970
|
-
* @param
|
|
21971
|
-
* @param
|
|
21972
|
-
|
|
21973
|
-
|
|
21974
|
-
*
|
|
21975
|
-
* @
|
|
21976
|
-
|
|
21977
|
-
|
|
21978
|
-
|
|
21979
|
-
|
|
21980
|
-
|
|
21981
|
-
var depthTexture = depthFormat ? PipelineUtils.recreateTextureIfNeeded(engine, currentDepthTexture, width, height, depthFormat, mipmap) : null;
|
|
21982
|
-
if (currentColorTexture !== colorTexture || currentDepthTexture !== depthTexture) {
|
|
21983
|
-
var _currentRenderTarget2;
|
|
21984
|
-
(_currentRenderTarget2 = currentRenderTarget) == null ? void 0 : _currentRenderTarget2.destroy();
|
|
21985
|
-
currentRenderTarget = new RenderTarget(engine, width, height, colorTexture, depthTexture);
|
|
21986
|
-
currentRenderTarget.isGCIgnored = true;
|
|
21987
|
-
}
|
|
21988
|
-
return currentRenderTarget;
|
|
21989
|
-
};
|
|
21990
|
-
return PipelineUtils;
|
|
21987
|
+
* Post rendering callback.
|
|
21988
|
+
* @param camera - Camera
|
|
21989
|
+
* @param opaqueQueue - Opaque queue
|
|
21990
|
+
* @param alphaTestQueue - Alpha test queue
|
|
21991
|
+
* @param transparentQueue - Transparent queue
|
|
21992
|
+
*/ _proto.preRender = function preRender(camera, opaqueQueue, alphaTestQueue, transparentQueue) {};
|
|
21993
|
+
/**
|
|
21994
|
+
* Post rendering callback.
|
|
21995
|
+
* @param camera - Camera
|
|
21996
|
+
* @param opaqueQueue - Opaque queue
|
|
21997
|
+
* @param alphaTestQueue - Alpha test queue
|
|
21998
|
+
* @param transparentQueue - Transparent queue
|
|
21999
|
+
*/ _proto.postRender = function postRender(camera, opaqueQueue, alphaTestQueue, transparentQueue) {};
|
|
22000
|
+
return RenderPass;
|
|
21991
22001
|
}();
|
|
21992
22002
|
|
|
21993
22003
|
/**
|
|
@@ -22255,6 +22265,26 @@ var /**
|
|
|
22255
22265
|
var offset = cascadeIndex * 16;
|
|
22256
22266
|
Utils._floatMatrixMultiply(sliceMatrix, outShadowMatrices, offset, outShadowMatrices, offset);
|
|
22257
22267
|
};
|
|
22268
|
+
/**
|
|
22269
|
+
* Extract scale and bias from a fade distance to achieve a linear fading of the fade distance.
|
|
22270
|
+
*/ ShadowUtils.getScaleAndBiasForLinearDistanceFade = function getScaleAndBiasForLinearDistanceFade(fadeDistance, border, outInfo) {
|
|
22271
|
+
// (P^2-N^2)/(F^2-N^2)
|
|
22272
|
+
// To avoid division from zero
|
|
22273
|
+
// This values ensure that fade within cascade will be 0 and outside 1
|
|
22274
|
+
if (border < 0.0001) {
|
|
22275
|
+
var multiplier = 1000; // To avoid blending if difference is in fractions
|
|
22276
|
+
outInfo.z = multiplier;
|
|
22277
|
+
outInfo.w = -fadeDistance * multiplier;
|
|
22278
|
+
return;
|
|
22279
|
+
}
|
|
22280
|
+
border = 1 - border;
|
|
22281
|
+
border *= border;
|
|
22282
|
+
// Fade with distance calculation is just a linear fade from 90% of fade distance to fade distance. 90% arbitrarily chosen but should work well enough.
|
|
22283
|
+
var distanceFadeNear = border * fadeDistance;
|
|
22284
|
+
var fadeRange = fadeDistance - distanceFadeNear;
|
|
22285
|
+
outInfo.z = 1.0 / fadeRange;
|
|
22286
|
+
outInfo.w = -distanceFadeNear / fadeRange;
|
|
22287
|
+
};
|
|
22258
22288
|
return ShadowUtils;
|
|
22259
22289
|
}();
|
|
22260
22290
|
(function() {
|
|
@@ -22499,12 +22529,6 @@ var /**
|
|
|
22499
22529
|
ShadowUtils.atlasBorderSize = 4.0;
|
|
22500
22530
|
})();
|
|
22501
22531
|
|
|
22502
|
-
/**
|
|
22503
|
-
* PipelinePass is a base class for all pipeline passes.
|
|
22504
|
-
*/ var PipelinePass = function PipelinePass(engine) {
|
|
22505
|
-
this._engine = engine;
|
|
22506
|
-
};
|
|
22507
|
-
|
|
22508
22532
|
/**
|
|
22509
22533
|
* Cascade shadow caster pass.
|
|
22510
22534
|
*/ var CascadedShadowCasterPass = /*#__PURE__*/ function(PipelinePass1) {
|
|
@@ -22517,11 +22541,10 @@ var /**
|
|
|
22517
22541
|
_this._shadowSliceData = new ShadowSliceData();
|
|
22518
22542
|
_this._lightUp = new miniprogram.Vector3();
|
|
22519
22543
|
_this._lightSide = new miniprogram.Vector3();
|
|
22520
|
-
_this._existShadowMap = false;
|
|
22521
22544
|
_this._splitBoundSpheres = new Float32Array(CascadedShadowCasterPass._maxCascades * 4);
|
|
22522
22545
|
/** The end is project precision problem in shader. */ _this._shadowMatrices = new Float32Array((CascadedShadowCasterPass._maxCascades + 1) * 16);
|
|
22523
|
-
//
|
|
22524
|
-
_this._shadowInfos = new miniprogram.
|
|
22546
|
+
// intensity, null, fadeScale, fadeBias
|
|
22547
|
+
_this._shadowInfos = new miniprogram.Vector4();
|
|
22525
22548
|
_this._viewportOffsets = [
|
|
22526
22549
|
new miniprogram.Vector2(),
|
|
22527
22550
|
new miniprogram.Vector2(),
|
|
@@ -22537,14 +22560,12 @@ var /**
|
|
|
22537
22560
|
/**
|
|
22538
22561
|
* @internal
|
|
22539
22562
|
*/ _proto.onRender = function onRender(context) {
|
|
22563
|
+
var light = this._camera.scene._lightManager._sunlight;
|
|
22540
22564
|
this._updateShadowSettings();
|
|
22541
|
-
this.
|
|
22542
|
-
this.
|
|
22543
|
-
if (this._existShadowMap) {
|
|
22544
|
-
this._updateReceiversShaderData();
|
|
22545
|
-
}
|
|
22565
|
+
this._renderDirectShadowMap(context, light);
|
|
22566
|
+
this._updateReceiversShaderData(light);
|
|
22546
22567
|
};
|
|
22547
|
-
_proto._renderDirectShadowMap = function _renderDirectShadowMap(context) {
|
|
22568
|
+
_proto._renderDirectShadowMap = function _renderDirectShadowMap(context, light) {
|
|
22548
22569
|
var _this = this, engine = _this._engine, camera = _this._camera, viewports = _this._viewportOffsets, shadowSliceData = _this._shadowSliceData, splitBoundSpheres = _this._splitBoundSpheres, shadowMatrices = _this._shadowMatrices;
|
|
22549
22570
|
var _camera__renderPipeline__cullingResults = camera._renderPipeline._cullingResults, opaqueQueue = _camera__renderPipeline__cullingResults.opaqueQueue, alphaTestQueue = _camera__renderPipeline__cullingResults.alphaTestQueue, transparentQueue = _camera__renderPipeline__cullingResults.transparentQueue;
|
|
22550
22571
|
var scene = camera.scene;
|
|
@@ -22558,91 +22579,87 @@ var /**
|
|
|
22558
22579
|
var lightUp = this._lightUp;
|
|
22559
22580
|
var lightSide = this._lightSide;
|
|
22560
22581
|
var lightForward = shadowSliceData.virtualCamera.forward;
|
|
22561
|
-
|
|
22562
|
-
|
|
22563
|
-
|
|
22564
|
-
|
|
22565
|
-
|
|
22566
|
-
|
|
22567
|
-
|
|
22568
|
-
|
|
22569
|
-
|
|
22570
|
-
|
|
22571
|
-
|
|
22572
|
-
|
|
22573
|
-
|
|
22574
|
-
|
|
22575
|
-
|
|
22576
|
-
|
|
22577
|
-
|
|
22578
|
-
|
|
22579
|
-
|
|
22580
|
-
|
|
22581
|
-
|
|
22582
|
-
|
|
22583
|
-
|
|
22584
|
-
rhi.
|
|
22585
|
-
|
|
22586
|
-
|
|
22587
|
-
|
|
22588
|
-
|
|
22589
|
-
|
|
22590
|
-
|
|
22591
|
-
|
|
22592
|
-
|
|
22593
|
-
|
|
22594
|
-
|
|
22595
|
-
|
|
22596
|
-
|
|
22597
|
-
|
|
22598
|
-
|
|
22599
|
-
|
|
22600
|
-
|
|
22601
|
-
|
|
22602
|
-
|
|
22603
|
-
|
|
22604
|
-
|
|
22605
|
-
|
|
22606
|
-
|
|
22607
|
-
|
|
22608
|
-
|
|
22609
|
-
|
|
22610
|
-
|
|
22611
|
-
|
|
22612
|
-
|
|
22613
|
-
|
|
22614
|
-
|
|
22615
|
-
|
|
22616
|
-
|
|
22617
|
-
|
|
22618
|
-
|
|
22619
|
-
|
|
22620
|
-
|
|
22621
|
-
|
|
22622
|
-
|
|
22623
|
-
|
|
22624
|
-
|
|
22625
|
-
|
|
22626
|
-
|
|
22627
|
-
|
|
22628
|
-
|
|
22629
|
-
|
|
22630
|
-
|
|
22631
|
-
|
|
22632
|
-
|
|
22633
|
-
|
|
22634
|
-
|
|
22635
|
-
|
|
22636
|
-
}
|
|
22637
|
-
}
|
|
22638
|
-
this._existShadowMap = true;
|
|
22639
|
-
}
|
|
22640
|
-
};
|
|
22641
|
-
_proto._updateReceiversShaderData = function _updateReceiversShaderData() {
|
|
22642
|
-
var scene = this._camera.scene;
|
|
22582
|
+
// Prepare render target
|
|
22583
|
+
var _this__shadowMapSize = this._shadowMapSize, width = _this__shadowMapSize.z, height = _this__shadowMapSize.w;
|
|
22584
|
+
var format = this._shadowMapFormat;
|
|
22585
|
+
var renderTarget;
|
|
22586
|
+
var shadowTexture;
|
|
22587
|
+
if (this._supportDepthTexture) {
|
|
22588
|
+
renderTarget = PipelineUtils.recreateRenderTargetIfNeeded(engine, this._renderTarget, width, height, null, format, false);
|
|
22589
|
+
shadowTexture = renderTarget.depthTexture;
|
|
22590
|
+
} else {
|
|
22591
|
+
renderTarget = PipelineUtils.recreateRenderTargetIfNeeded(engine, this._renderTarget, width, height, format, null, false);
|
|
22592
|
+
shadowTexture = renderTarget.getColorTexture(0);
|
|
22593
|
+
}
|
|
22594
|
+
shadowTexture.wrapModeU = shadowTexture.wrapModeV = exports.TextureWrapMode.Clamp;
|
|
22595
|
+
if (engine._hardwareRenderer._isWebGL2) {
|
|
22596
|
+
shadowTexture.depthCompareFunction = exports.TextureDepthCompareFunction.Less;
|
|
22597
|
+
}
|
|
22598
|
+
this._renderTarget = renderTarget;
|
|
22599
|
+
this._depthTexture = shadowTexture;
|
|
22600
|
+
// @todo: shouldn't set viewport and scissor in activeRenderTarget
|
|
22601
|
+
rhi.activeRenderTarget(renderTarget, CascadedShadowCasterPass._viewport, 0);
|
|
22602
|
+
if (this._supportDepthTexture) {
|
|
22603
|
+
rhi.clearRenderTarget(engine, exports.CameraClearFlags.Depth, null);
|
|
22604
|
+
} else {
|
|
22605
|
+
rhi.clearRenderTarget(engine, exports.CameraClearFlags.All, CascadedShadowCasterPass._clearColor);
|
|
22606
|
+
}
|
|
22607
|
+
// prepare light and camera direction
|
|
22608
|
+
miniprogram.Matrix.rotationQuaternion(light.entity.transform.worldRotationQuaternion, lightWorld);
|
|
22609
|
+
lightSide.set(lightWorldE[0], lightWorldE[1], lightWorldE[2]);
|
|
22610
|
+
lightUp.set(lightWorldE[4], lightWorldE[5], lightWorldE[6]);
|
|
22611
|
+
lightForward.set(-lightWorldE[8], -lightWorldE[9], -lightWorldE[10]);
|
|
22612
|
+
var cameraForward = CascadedShadowCasterPass._tempVector;
|
|
22613
|
+
cameraForward.copyFrom(camera.entity.transform.worldForward);
|
|
22614
|
+
var shadowTileResolution = this._shadowTileResolution;
|
|
22615
|
+
for(var j = 0; j < shadowCascades; j++){
|
|
22616
|
+
ShadowUtils.getBoundSphereByFrustum(splitDistance[j], splitDistance[j + 1], camera, cameraForward, shadowSliceData);
|
|
22617
|
+
ShadowUtils.getDirectionLightShadowCullPlanes(camera._frustum, splitDistance[j], camera.nearClipPlane, lightForward, shadowSliceData);
|
|
22618
|
+
ShadowUtils.getDirectionalLightMatrices(lightUp, lightSide, lightForward, j, light.shadowNearPlane, shadowTileResolution, shadowSliceData, shadowMatrices);
|
|
22619
|
+
if (shadowCascades > 1) {
|
|
22620
|
+
ShadowUtils.applySliceTransform(shadowTileResolution, width, height, j, this._viewportOffsets[j], shadowMatrices);
|
|
22621
|
+
}
|
|
22622
|
+
this._updateSingleShadowCasterShaderData(light, shadowSliceData, context);
|
|
22623
|
+
// upload pre-cascade infos.
|
|
22624
|
+
var center = boundSphere.center;
|
|
22625
|
+
var radius = boundSphere.radius;
|
|
22626
|
+
var offset = j * 4;
|
|
22627
|
+
splitBoundSpheres[offset] = center.x;
|
|
22628
|
+
splitBoundSpheres[offset + 1] = center.y;
|
|
22629
|
+
splitBoundSpheres[offset + 2] = center.z;
|
|
22630
|
+
splitBoundSpheres[offset + 3] = radius * radius;
|
|
22631
|
+
opaqueQueue.clear();
|
|
22632
|
+
alphaTestQueue.clear();
|
|
22633
|
+
transparentQueue.clear();
|
|
22634
|
+
var renderers = componentsManager._renderers;
|
|
22635
|
+
var elements = renderers._elements;
|
|
22636
|
+
for(var k = renderers.length - 1; k >= 0; --k){
|
|
22637
|
+
ShadowUtils.shadowCullFrustum(context, light, elements[k], shadowSliceData);
|
|
22638
|
+
}
|
|
22639
|
+
if (opaqueQueue.elements.length || alphaTestQueue.elements.length) {
|
|
22640
|
+
opaqueQueue.sort(RenderQueue._compareFromNearToFar);
|
|
22641
|
+
alphaTestQueue.sort(RenderQueue._compareFromNearToFar);
|
|
22642
|
+
var _viewports_j = viewports[j], x = _viewports_j.x, y = _viewports_j.y;
|
|
22643
|
+
rhi.setGlobalDepthBias(1.0, 1.0);
|
|
22644
|
+
rhi.viewport(x, y, shadowTileResolution, shadowTileResolution);
|
|
22645
|
+
// for no cascade is for the edge,for cascade is for the beyond maxCascade pixel can use (0,0,0) trick sample the shadowMap
|
|
22646
|
+
rhi.scissor(x + 1, y + 1, shadowTileResolution - 2, shadowTileResolution - 2);
|
|
22647
|
+
engine._renderCount++;
|
|
22648
|
+
opaqueQueue.render(camera, exports.Layer.Everything, exports.PipelineStage.ShadowCaster);
|
|
22649
|
+
alphaTestQueue.render(camera, exports.Layer.Everything, exports.PipelineStage.ShadowCaster);
|
|
22650
|
+
rhi.setGlobalDepthBias(0, 0);
|
|
22651
|
+
}
|
|
22652
|
+
}
|
|
22653
|
+
};
|
|
22654
|
+
_proto._updateReceiversShaderData = function _updateReceiversShaderData(light) {
|
|
22655
|
+
var camera = this._camera;
|
|
22656
|
+
var scene = camera.scene;
|
|
22643
22657
|
var splitBoundSpheres = this._splitBoundSpheres;
|
|
22644
22658
|
var shadowMatrices = this._shadowMatrices;
|
|
22645
22659
|
var shadowCascades = scene.shadowCascades;
|
|
22660
|
+
var shadowFar = Math.min(scene.shadowDistance, camera.farClipPlane);
|
|
22661
|
+
ShadowUtils.getScaleAndBiasForLinearDistanceFade(Math.pow(shadowFar, 2), scene.shadowFadeBorder, this._shadowInfos);
|
|
22662
|
+
this._shadowInfos.x = light.shadowStrength;
|
|
22646
22663
|
// set zero matrix to project the index out of max cascade
|
|
22647
22664
|
if (shadowCascades > 1) {
|
|
22648
22665
|
for(var i = shadowCascades * 4, n = splitBoundSpheres.length; i < n; i++){
|
|
@@ -22655,7 +22672,7 @@ var /**
|
|
|
22655
22672
|
}
|
|
22656
22673
|
var shaderData = scene.shaderData;
|
|
22657
22674
|
shaderData.setFloatArray(CascadedShadowCasterPass._shadowMatricesProperty, this._shadowMatrices);
|
|
22658
|
-
shaderData.
|
|
22675
|
+
shaderData.setVector4(CascadedShadowCasterPass._shadowInfosProperty, this._shadowInfos);
|
|
22659
22676
|
shaderData.setTexture(CascadedShadowCasterPass._shadowMapsProperty, this._depthTexture);
|
|
22660
22677
|
shaderData.setFloatArray(CascadedShadowCasterPass._shadowSplitSpheresProperty, this._splitBoundSpheres);
|
|
22661
22678
|
shaderData.setVector4(CascadedShadowCasterPass._shadowMapSize, this._shadowMapSize);
|
|
@@ -22691,10 +22708,13 @@ var /**
|
|
|
22691
22708
|
return Math.sqrt(radius * radius / denominator);
|
|
22692
22709
|
};
|
|
22693
22710
|
_proto._updateShadowSettings = function _updateShadowSettings() {
|
|
22694
|
-
var
|
|
22711
|
+
var camera = this._camera;
|
|
22712
|
+
var scene = camera.scene;
|
|
22695
22713
|
var shadowFormat = ShadowUtils.shadowDepthFormat(scene.shadowResolution, this._supportDepthTexture);
|
|
22696
22714
|
var shadowResolution = ShadowUtils.shadowResolution(scene.shadowResolution);
|
|
22697
22715
|
var shadowCascades = scene.shadowCascades;
|
|
22716
|
+
var shadowFar = Math.min(scene.shadowDistance, camera.farClipPlane);
|
|
22717
|
+
this._getCascadesSplitDistance(shadowFar);
|
|
22698
22718
|
if (shadowFormat !== this._shadowMapFormat || shadowResolution !== this._shadowMapResolution || shadowCascades !== this._shadowCascadeMode) {
|
|
22699
22719
|
this._shadowMapFormat = shadowFormat;
|
|
22700
22720
|
this._shadowMapResolution = shadowResolution;
|
|
@@ -23875,6 +23895,7 @@ var MultiExecutor = /*#__PURE__*/ function() {
|
|
|
23875
23895
|
* @param obj - class object
|
|
23876
23896
|
*/ Loader.registerClass = function registerClass(className, classDefine) {
|
|
23877
23897
|
this._engineObjects[className] = classDefine;
|
|
23898
|
+
this._classNameMap.set(classDefine, className);
|
|
23878
23899
|
};
|
|
23879
23900
|
/**
|
|
23880
23901
|
* Get the class object by class name.
|
|
@@ -23883,11 +23904,21 @@ var MultiExecutor = /*#__PURE__*/ function() {
|
|
|
23883
23904
|
*/ Loader.getClass = function getClass(className) {
|
|
23884
23905
|
return this._engineObjects[className];
|
|
23885
23906
|
};
|
|
23907
|
+
/**
|
|
23908
|
+
* Get the class name by class object.
|
|
23909
|
+
* @param obj - class object
|
|
23910
|
+
* @returns class name
|
|
23911
|
+
*/ Loader.getClassName = function getClassName(obj) {
|
|
23912
|
+
return this._classNameMap.get(obj);
|
|
23913
|
+
};
|
|
23886
23914
|
return Loader;
|
|
23887
23915
|
}();
|
|
23888
23916
|
(function() {
|
|
23889
23917
|
Loader._engineObjects = {};
|
|
23890
23918
|
})();
|
|
23919
|
+
(function() {
|
|
23920
|
+
Loader._classNameMap = new Map();
|
|
23921
|
+
})();
|
|
23891
23922
|
|
|
23892
23923
|
/**
|
|
23893
23924
|
* Alpha blend mode.
|
|
@@ -27657,7 +27688,7 @@ __decorate([
|
|
|
27657
27688
|
this._clip = clip;
|
|
27658
27689
|
this._clipEndTime = Math.min(this._clipEndTime, 1);
|
|
27659
27690
|
this._onClipChanged();
|
|
27660
|
-
clip._updateFlagManager.addListener(this._onClipChanged);
|
|
27691
|
+
clip && clip._updateFlagManager.addListener(this._onClipChanged);
|
|
27661
27692
|
}
|
|
27662
27693
|
},
|
|
27663
27694
|
{
|
|
@@ -28364,6 +28395,7 @@ __decorate([
|
|
|
28364
28395
|
ParticleRandomSubSeeds[ParticleRandomSubSeeds["RotationOverLifetime"] = 0x40eb95e4] = "RotationOverLifetime";
|
|
28365
28396
|
ParticleRandomSubSeeds[ParticleRandomSubSeeds["TextureSheetAnimation"] = 0xbc524e5] = "TextureSheetAnimation";
|
|
28366
28397
|
ParticleRandomSubSeeds[ParticleRandomSubSeeds["Shape"] = 0xaf502044] = "Shape";
|
|
28398
|
+
ParticleRandomSubSeeds[ParticleRandomSubSeeds["GravityModifier"] = 0xa47b8c4d] = "GravityModifier";
|
|
28367
28399
|
})(ParticleRandomSubSeeds || (ParticleRandomSubSeeds = {}));
|
|
28368
28400
|
|
|
28369
28401
|
/**
|
|
@@ -29077,6 +29109,7 @@ var MainModule = /*#__PURE__*/ function() {
|
|
|
29077
29109
|
/** @internal */ this._startColorRand = new miniprogram.Rand(0, ParticleRandomSubSeeds.StartColor);
|
|
29078
29110
|
/** @internal */ this._startSizeRand = new miniprogram.Rand(0, ParticleRandomSubSeeds.StartSize);
|
|
29079
29111
|
/** @internal */ this._startRotationRand = new miniprogram.Rand(0, ParticleRandomSubSeeds.StartRotation);
|
|
29112
|
+
this._gravityModifierRand = new miniprogram.Rand(0, ParticleRandomSubSeeds.GravityModifier);
|
|
29080
29113
|
this._gravity = new miniprogram.Vector3();
|
|
29081
29114
|
this._generator = generator;
|
|
29082
29115
|
}
|
|
@@ -29137,7 +29170,7 @@ var MainModule = /*#__PURE__*/ function() {
|
|
|
29137
29170
|
break;
|
|
29138
29171
|
}
|
|
29139
29172
|
var particleGravity = this._gravity;
|
|
29140
|
-
var gravityModifierValue = this.gravityModifier.evaluate(undefined,
|
|
29173
|
+
var gravityModifierValue = this.gravityModifier.evaluate(undefined, this._gravityModifierRand.random());
|
|
29141
29174
|
miniprogram.Vector3.scale(renderer.scene.physics.gravity, gravityModifierValue, particleGravity);
|
|
29142
29175
|
shaderData.setVector3(MainModule._gravity, particleGravity);
|
|
29143
29176
|
shaderData.setInt(MainModule._simulationSpace, this.simulationSpace);
|
|
@@ -29256,6 +29289,9 @@ __decorate([
|
|
|
29256
29289
|
__decorate([
|
|
29257
29290
|
ignoreClone
|
|
29258
29291
|
], MainModule.prototype, "_startRotationRand", void 0);
|
|
29292
|
+
__decorate([
|
|
29293
|
+
ignoreClone
|
|
29294
|
+
], MainModule.prototype, "_gravityModifierRand", void 0);
|
|
29259
29295
|
__decorate([
|
|
29260
29296
|
ignoreClone
|
|
29261
29297
|
], MainModule.prototype, "_generator", void 0);
|
|
@@ -30570,14 +30606,14 @@ __decorate([
|
|
|
30570
30606
|
|
|
30571
30607
|
/**
|
|
30572
30608
|
* The emission shape.
|
|
30573
|
-
*/
|
|
30609
|
+
*/ exports.ParticleShapeType = void 0;
|
|
30574
30610
|
(function(ParticleShapeType) {
|
|
30575
30611
|
ParticleShapeType[ParticleShapeType[/** Emit from the volume of a box. */ "Box"] = 0] = "Box";
|
|
30576
30612
|
ParticleShapeType[ParticleShapeType[/** Emit from a circle. */ "Circle"] = 1] = "Circle";
|
|
30577
30613
|
ParticleShapeType[ParticleShapeType[/** Emit from the base of a cone. */ "Cone"] = 2] = "Cone";
|
|
30578
30614
|
ParticleShapeType[ParticleShapeType[/** Emit from a half-sphere. */ "Hemisphere"] = 3] = "Hemisphere";
|
|
30579
30615
|
ParticleShapeType[ParticleShapeType[/** Emit from a sphere. */ "Sphere"] = 4] = "Sphere";
|
|
30580
|
-
})(ParticleShapeType || (ParticleShapeType = {}));
|
|
30616
|
+
})(exports.ParticleShapeType || (exports.ParticleShapeType = {}));
|
|
30581
30617
|
|
|
30582
30618
|
/**
|
|
30583
30619
|
* Particle shape that emits particles from a box.
|
|
@@ -30585,9 +30621,9 @@ __decorate([
|
|
|
30585
30621
|
_inherits(BoxShape, BaseShape1);
|
|
30586
30622
|
function BoxShape() {
|
|
30587
30623
|
var _this;
|
|
30588
|
-
_this = BaseShape1.
|
|
30624
|
+
_this = BaseShape1.apply(this, arguments) || this;
|
|
30625
|
+
_this.shapeType = exports.ParticleShapeType.Box;
|
|
30589
30626
|
/** The size of the box. */ _this.size = new miniprogram.Vector3(1, 1, 1);
|
|
30590
|
-
_this.shapeType = ParticleShapeType.Box;
|
|
30591
30627
|
return _this;
|
|
30592
30628
|
}
|
|
30593
30629
|
var _proto = BoxShape.prototype;
|
|
@@ -30624,12 +30660,12 @@ __decorate([
|
|
|
30624
30660
|
_inherits(CircleShape, BaseShape1);
|
|
30625
30661
|
function CircleShape() {
|
|
30626
30662
|
var _this;
|
|
30627
|
-
_this = BaseShape1.
|
|
30663
|
+
_this = BaseShape1.apply(this, arguments) || this;
|
|
30664
|
+
_this.shapeType = exports.ParticleShapeType.Circle;
|
|
30628
30665
|
/** Radius of the shape to emit particles from. */ _this.radius = 1.0;
|
|
30629
30666
|
/** Angle of the circle arc to emit particles from. */ _this.arc = 360.0;
|
|
30630
30667
|
/** The mode to generate particles around the arc. */ _this.arcMode = exports.ParticleShapeArcMode.Random;
|
|
30631
30668
|
/** The speed of complete 360 degree rotation. */ _this.arcSpeed = 1.0;
|
|
30632
|
-
_this.shapeType = ParticleShapeType.Circle;
|
|
30633
30669
|
return _this;
|
|
30634
30670
|
}
|
|
30635
30671
|
var _proto = CircleShape.prototype;
|
|
@@ -30665,12 +30701,12 @@ __decorate([
|
|
|
30665
30701
|
_inherits(ConeShape, BaseShape1);
|
|
30666
30702
|
function ConeShape() {
|
|
30667
30703
|
var _this;
|
|
30668
|
-
_this = BaseShape1.
|
|
30704
|
+
_this = BaseShape1.apply(this, arguments) || this;
|
|
30705
|
+
_this.shapeType = exports.ParticleShapeType.Cone;
|
|
30669
30706
|
/** Angle of the cone to emit particles from. */ _this.angle = 25.0;
|
|
30670
30707
|
/** Radius of the shape to emit particles from. */ _this.radius = 1.0;
|
|
30671
30708
|
/** Length of the cone to emit particles from. */ _this.length = 5.0;
|
|
30672
30709
|
/** Cone emitter type. */ _this.emitType = /** Emit particles from the base of the cone. */ 0;
|
|
30673
|
-
_this.shapeType = ParticleShapeType.Cone;
|
|
30674
30710
|
return _this;
|
|
30675
30711
|
}
|
|
30676
30712
|
var _proto = ConeShape.prototype;
|
|
@@ -30730,9 +30766,9 @@ exports.ConeEmitType = void 0;
|
|
|
30730
30766
|
_inherits(HemisphereShape, BaseShape1);
|
|
30731
30767
|
function HemisphereShape() {
|
|
30732
30768
|
var _this;
|
|
30733
|
-
_this = BaseShape1.
|
|
30769
|
+
_this = BaseShape1.apply(this, arguments) || this;
|
|
30770
|
+
_this.shapeType = exports.ParticleShapeType.Hemisphere;
|
|
30734
30771
|
/** Radius of the shape to emit particles from. */ _this.radius = 1.0;
|
|
30735
|
-
_this.shapeType = ParticleShapeType.Hemisphere;
|
|
30736
30772
|
return _this;
|
|
30737
30773
|
}
|
|
30738
30774
|
var _proto = HemisphereShape.prototype;
|
|
@@ -30755,9 +30791,9 @@ exports.ConeEmitType = void 0;
|
|
|
30755
30791
|
_inherits(SphereShape, BaseShape1);
|
|
30756
30792
|
function SphereShape() {
|
|
30757
30793
|
var _this;
|
|
30758
|
-
_this = BaseShape1.
|
|
30794
|
+
_this = BaseShape1.apply(this, arguments) || this;
|
|
30795
|
+
_this.shapeType = exports.ParticleShapeType.Sphere;
|
|
30759
30796
|
/** Radius of the shape to emit particles from. */ _this.radius = 1.0;
|
|
30760
|
-
_this.shapeType = ParticleShapeType.Sphere;
|
|
30761
30797
|
return _this;
|
|
30762
30798
|
}
|
|
30763
30799
|
var _proto = SphereShape.prototype;
|