@galacean/engine-core 1.0.0-beta.15 → 1.0.0-beta.16
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 +123 -75
- package/dist/main.js.map +1 -1
- package/dist/miniprogram.js +123 -75
- package/dist/module.js +123 -75
- package/dist/module.js.map +1 -1
- package/package.json +3 -3
- package/types/2d/sprite/Sprite.d.ts +3 -0
- package/types/DisorderedArray.d.ts +4 -3
- package/types/lighting/AmbientLight.d.ts +4 -1
- package/types/lighting/LightManager.d.ts +1 -0
package/dist/miniprogram.js
CHANGED
|
@@ -3005,15 +3005,24 @@ exports.GLCapabilityType = void 0;
|
|
|
3005
3005
|
}
|
|
3006
3006
|
var _proto = DisorderedArray.prototype;
|
|
3007
3007
|
_proto.add = function add(element) {
|
|
3008
|
-
if (this.length === this._elements.length)
|
|
3009
|
-
|
|
3008
|
+
if (this.length === this._elements.length) {
|
|
3009
|
+
this._elements.push(element);
|
|
3010
|
+
} else {
|
|
3011
|
+
this._elements[this.length] = element;
|
|
3012
|
+
}
|
|
3010
3013
|
this.length++;
|
|
3011
3014
|
};
|
|
3012
3015
|
_proto.delete = function _delete(element) {
|
|
3013
|
-
//
|
|
3016
|
+
// @todo: It can be optimized for custom binary search and other algorithms, currently this._elements>=this.length wastes performance.
|
|
3014
3017
|
var index = this._elements.indexOf(element);
|
|
3015
3018
|
this.deleteByIndex(index);
|
|
3016
3019
|
};
|
|
3020
|
+
_proto.set = function set(index, element) {
|
|
3021
|
+
if (index >= this.length) {
|
|
3022
|
+
throw "Index is out of range.";
|
|
3023
|
+
}
|
|
3024
|
+
this._elements[index] = element;
|
|
3025
|
+
};
|
|
3017
3026
|
_proto.get = function get(index) {
|
|
3018
3027
|
if (index >= this.length) {
|
|
3019
3028
|
throw "Index is out of range.";
|
|
@@ -3021,9 +3030,9 @@ exports.GLCapabilityType = void 0;
|
|
|
3021
3030
|
return this._elements[index];
|
|
3022
3031
|
};
|
|
3023
3032
|
/**
|
|
3024
|
-
*
|
|
3025
|
-
* @param index
|
|
3026
|
-
* @returns The replaced item is used to reset its index
|
|
3033
|
+
* Delete the element at the specified index.
|
|
3034
|
+
* @param index - The index of the element to be deleted
|
|
3035
|
+
* @returns The replaced item is used to reset its index
|
|
3027
3036
|
*/ _proto.deleteByIndex = function deleteByIndex(index) {
|
|
3028
3037
|
var elements = this._elements;
|
|
3029
3038
|
var end = null;
|
|
@@ -8391,31 +8400,18 @@ __decorate([
|
|
|
8391
8400
|
};
|
|
8392
8401
|
/**
|
|
8393
8402
|
* @internal
|
|
8394
|
-
*/ _proto.
|
|
8403
|
+
*/ _proto._updateSunLightIndex = function _updateSunLightIndex() {
|
|
8395
8404
|
var directLights = this._directLights;
|
|
8396
|
-
var
|
|
8397
|
-
|
|
8398
|
-
|
|
8399
|
-
|
|
8400
|
-
var
|
|
8401
|
-
|
|
8402
|
-
|
|
8403
|
-
|
|
8404
|
-
|
|
8405
|
-
var intensity = directLight.intensity * directLight.color.getBrightness();
|
|
8406
|
-
if (hasShadowLight) {
|
|
8407
|
-
if (directLight.shadowType !== exports.ShadowType.None && maxIntensity < intensity) {
|
|
8408
|
-
maxIntensity = intensity;
|
|
8409
|
-
sunLightIndex = i;
|
|
8410
|
-
}
|
|
8411
|
-
} else {
|
|
8412
|
-
if (maxIntensity < intensity) {
|
|
8413
|
-
maxIntensity = intensity;
|
|
8414
|
-
sunLightIndex = i;
|
|
8415
|
-
}
|
|
8416
|
-
}
|
|
8405
|
+
var index = this._getSunLightIndex();
|
|
8406
|
+
// -1 means no sun light, 0 means the first direct light already is sun light
|
|
8407
|
+
if (index > 0) {
|
|
8408
|
+
var firstLight = directLights.get(0);
|
|
8409
|
+
var sunLight = directLights.get(index);
|
|
8410
|
+
directLights.set(0, sunLight);
|
|
8411
|
+
directLights.set(index, firstLight);
|
|
8412
|
+
sunLight._lightIndex = 0;
|
|
8413
|
+
firstLight._lightIndex = index;
|
|
8417
8414
|
}
|
|
8418
|
-
return sunLightIndex;
|
|
8419
8415
|
};
|
|
8420
8416
|
/**
|
|
8421
8417
|
* @internal
|
|
@@ -8464,6 +8460,32 @@ __decorate([
|
|
|
8464
8460
|
this._pointLights.garbageCollection();
|
|
8465
8461
|
this._directLights.garbageCollection();
|
|
8466
8462
|
};
|
|
8463
|
+
_proto._getSunLightIndex = function _getSunLightIndex() {
|
|
8464
|
+
var directLights = this._directLights;
|
|
8465
|
+
var sunLightIndex = -1;
|
|
8466
|
+
var maxIntensity = Number.NEGATIVE_INFINITY;
|
|
8467
|
+
var hasShadowLight = false;
|
|
8468
|
+
for(var i = 0, n = directLights.length; i < n; i++){
|
|
8469
|
+
var directLight = directLights.get(i);
|
|
8470
|
+
if (directLight.shadowType !== exports.ShadowType.None && !hasShadowLight) {
|
|
8471
|
+
maxIntensity = Number.NEGATIVE_INFINITY;
|
|
8472
|
+
hasShadowLight = true;
|
|
8473
|
+
}
|
|
8474
|
+
var intensity = directLight.intensity * directLight.color.getBrightness();
|
|
8475
|
+
if (hasShadowLight) {
|
|
8476
|
+
if (directLight.shadowType !== exports.ShadowType.None && maxIntensity < intensity) {
|
|
8477
|
+
maxIntensity = intensity;
|
|
8478
|
+
sunLightIndex = i;
|
|
8479
|
+
}
|
|
8480
|
+
} else {
|
|
8481
|
+
if (maxIntensity < intensity) {
|
|
8482
|
+
maxIntensity = intensity;
|
|
8483
|
+
sunLightIndex = i;
|
|
8484
|
+
}
|
|
8485
|
+
}
|
|
8486
|
+
}
|
|
8487
|
+
return sunLightIndex;
|
|
8488
|
+
};
|
|
8467
8489
|
return LightManager;
|
|
8468
8490
|
}();
|
|
8469
8491
|
|
|
@@ -9674,7 +9696,7 @@ var begin_mobile_frag = "#define GLSLIFY 1\nvec4 ambient=vec4(0.0);vec4 emission
|
|
|
9674
9696
|
|
|
9675
9697
|
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
|
|
9676
9698
|
|
|
9677
|
-
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()
|
|
9699
|
+
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
|
|
9678
9700
|
|
|
9679
9701
|
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
|
|
9680
9702
|
|
|
@@ -9714,7 +9736,7 @@ var pbr_helper = "#define GLSLIFY 1\n#include <normal_get>\nfloat computeSpecula
|
|
|
9714
9736
|
|
|
9715
9737
|
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
|
|
9716
9738
|
|
|
9717
|
-
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()
|
|
9739
|
+
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
|
|
9718
9740
|
|
|
9719
9741
|
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
|
|
9720
9742
|
|
|
@@ -16001,20 +16023,25 @@ var TextRenderData = /*#__PURE__*/ function(RenderData) {
|
|
|
16001
16023
|
|
|
16002
16024
|
/**
|
|
16003
16025
|
* Ambient light.
|
|
16004
|
-
*/ var AmbientLight = /*#__PURE__*/ function() {
|
|
16005
|
-
|
|
16006
|
-
|
|
16007
|
-
|
|
16008
|
-
|
|
16009
|
-
|
|
16010
|
-
|
|
16011
|
-
|
|
16012
|
-
|
|
16026
|
+
*/ var AmbientLight = /*#__PURE__*/ function(ReferResource) {
|
|
16027
|
+
_inherits(AmbientLight, ReferResource);
|
|
16028
|
+
function AmbientLight(engine) {
|
|
16029
|
+
var _this;
|
|
16030
|
+
_this = ReferResource.call(this, engine) || this;
|
|
16031
|
+
_this._diffuseSolidColor = new miniprogram.Color(0.212, 0.227, 0.259);
|
|
16032
|
+
_this._diffuseIntensity = 1.0;
|
|
16033
|
+
_this._specularIntensity = 1.0;
|
|
16034
|
+
_this._diffuseMode = exports.DiffuseMode.SolidColor;
|
|
16035
|
+
_this._shArray = new Float32Array(27);
|
|
16036
|
+
_this._scenes = [];
|
|
16037
|
+
_this._specularTextureDecodeRGBM = false;
|
|
16038
|
+
return _this;
|
|
16013
16039
|
}
|
|
16014
16040
|
var _proto = AmbientLight.prototype;
|
|
16015
16041
|
/**
|
|
16016
16042
|
* @internal
|
|
16017
16043
|
*/ _proto._addToScene = function _addToScene(scene) {
|
|
16044
|
+
this._addReferCount(1);
|
|
16018
16045
|
this._scenes.push(scene);
|
|
16019
16046
|
var shaderData = scene.shaderData;
|
|
16020
16047
|
shaderData.setColor(AmbientLight._diffuseColorProperty, this._diffuseSolidColor);
|
|
@@ -16028,9 +16055,13 @@ var TextRenderData = /*#__PURE__*/ function(RenderData) {
|
|
|
16028
16055
|
/**
|
|
16029
16056
|
* @internal
|
|
16030
16057
|
*/ _proto._removeFromScene = function _removeFromScene(scene) {
|
|
16058
|
+
this._addReferCount(-1);
|
|
16031
16059
|
var scenes = this._scenes;
|
|
16032
16060
|
var index = scenes.indexOf(scene);
|
|
16033
16061
|
scenes.splice(index, 1);
|
|
16062
|
+
var shaderData = scene.shaderData;
|
|
16063
|
+
shaderData.setTexture(AmbientLight._specularTextureProperty, null);
|
|
16064
|
+
shaderData.disableMacro(AmbientLight._specularMacro);
|
|
16034
16065
|
};
|
|
16035
16066
|
_proto._setDiffuseMode = function _setDiffuseMode(sceneShaderData) {
|
|
16036
16067
|
if (this._diffuseMode === exports.DiffuseMode.SphericalHarmonics) {
|
|
@@ -16218,7 +16249,7 @@ var TextRenderData = /*#__PURE__*/ function(RenderData) {
|
|
|
16218
16249
|
}
|
|
16219
16250
|
]);
|
|
16220
16251
|
return AmbientLight;
|
|
16221
|
-
}();
|
|
16252
|
+
}(ReferResource);
|
|
16222
16253
|
(function() {
|
|
16223
16254
|
AmbientLight._shMacro = ShaderMacro.getByName("SCENE_USE_SH");
|
|
16224
16255
|
})();
|
|
@@ -16275,7 +16306,7 @@ var TextRenderData = /*#__PURE__*/ function(RenderData) {
|
|
|
16275
16306
|
_this.name = name || "";
|
|
16276
16307
|
var shaderData = _this.shaderData;
|
|
16277
16308
|
shaderData._addReferCount(1);
|
|
16278
|
-
_this.ambientLight = new AmbientLight();
|
|
16309
|
+
_this.ambientLight = new AmbientLight(engine);
|
|
16279
16310
|
engine.sceneManager._allScenes.push(_assert_this_initialized(_this));
|
|
16280
16311
|
shaderData.enableMacro("SCENE_FOG_MODE", _this._fogMode.toString());
|
|
16281
16312
|
shaderData.enableMacro("SCENE_SHADOW_CASCADED_COUNT", _this.shadowCascades.toString());
|
|
@@ -16383,6 +16414,7 @@ var TextRenderData = /*#__PURE__*/ function(RenderData) {
|
|
|
16383
16414
|
if (this._destroyed) {
|
|
16384
16415
|
return;
|
|
16385
16416
|
}
|
|
16417
|
+
EngineObject.prototype.destroy.call(this);
|
|
16386
16418
|
this._destroy();
|
|
16387
16419
|
var allScenes = this.engine.sceneManager._allScenes;
|
|
16388
16420
|
allScenes.splice(allScenes.indexOf(this), 1);
|
|
@@ -16425,9 +16457,9 @@ var TextRenderData = /*#__PURE__*/ function(RenderData) {
|
|
|
16425
16457
|
var lightManager = engine._lightManager;
|
|
16426
16458
|
engine.time._updateSceneShaderData(shaderData);
|
|
16427
16459
|
lightManager._updateShaderData(this.shaderData);
|
|
16428
|
-
|
|
16429
|
-
if (
|
|
16430
|
-
var sunlight = lightManager._directLights.get(
|
|
16460
|
+
lightManager._updateSunLightIndex();
|
|
16461
|
+
if (lightManager._directLights.length > 0) {
|
|
16462
|
+
var sunlight = lightManager._directLights.get(0);
|
|
16431
16463
|
shaderData.setColor(Scene._sunlightColorProperty, sunlight._getLightIntensityColor());
|
|
16432
16464
|
shaderData.setVector3(Scene._sunlightDirectionProperty, sunlight.direction);
|
|
16433
16465
|
this._sunLight = sunlight;
|
|
@@ -16462,6 +16494,7 @@ var TextRenderData = /*#__PURE__*/ function(RenderData) {
|
|
|
16462
16494
|
}
|
|
16463
16495
|
this._activeCameras.length = 0;
|
|
16464
16496
|
this.background.destroy();
|
|
16497
|
+
this._ambientLight && this._ambientLight._removeFromScene(this);
|
|
16465
16498
|
this.shaderData._addReferCount(-1);
|
|
16466
16499
|
};
|
|
16467
16500
|
_proto._addToRootEntityList = function _addToRootEntityList(index, rootEntity) {
|
|
@@ -16689,10 +16722,9 @@ var TextRenderData = /*#__PURE__*/ function(RenderData) {
|
|
|
16689
16722
|
* @internal
|
|
16690
16723
|
*/ _proto._destroyAllScene = function _destroyAllScene() {
|
|
16691
16724
|
var allScenes = this._allScenes;
|
|
16692
|
-
|
|
16693
|
-
allScenes[
|
|
16725
|
+
while(allScenes[0]){
|
|
16726
|
+
allScenes[0].destroy();
|
|
16694
16727
|
}
|
|
16695
|
-
allScenes.length = 0;
|
|
16696
16728
|
};
|
|
16697
16729
|
_create_class(SceneManager, [
|
|
16698
16730
|
{
|
|
@@ -18465,9 +18497,8 @@ var /**
|
|
|
18465
18497
|
var lightUp = this._lightUp;
|
|
18466
18498
|
var lightSide = this._lightSide;
|
|
18467
18499
|
var lightForward = shadowSliceData.virtualCamera.forward;
|
|
18468
|
-
var
|
|
18469
|
-
if (
|
|
18470
|
-
var light = camera.scene._sunLight;
|
|
18500
|
+
var light = camera.scene._sunLight;
|
|
18501
|
+
if (light) {
|
|
18471
18502
|
var shadowFar = Math.min(camera.scene.shadowDistance, camera.farClipPlane);
|
|
18472
18503
|
this._getCascadesSplitDistance(shadowFar);
|
|
18473
18504
|
// prepare render target
|
|
@@ -18480,7 +18511,7 @@ var /**
|
|
|
18480
18511
|
rhi.clearRenderTarget(engine, exports.CameraClearFlags.All, CascadedShadowCasterPass._clearColor);
|
|
18481
18512
|
}
|
|
18482
18513
|
this._shadowInfos.x = light.shadowStrength;
|
|
18483
|
-
this._shadowInfos.z =
|
|
18514
|
+
this._shadowInfos.z = 0; // @todo: sun light index always 0
|
|
18484
18515
|
// prepare light and camera direction
|
|
18485
18516
|
miniprogram.Matrix.rotationQuaternion(light.entity.transform.worldRotationQuaternion, lightWorld);
|
|
18486
18517
|
lightSide.set(lightWorldE[0], lightWorldE[1], lightWorldE[2]);
|
|
@@ -20815,6 +20846,15 @@ exports.TextVerticalAlignment = void 0;
|
|
|
20815
20846
|
_this._dirtyUpdateFlag = 0x7;
|
|
20816
20847
|
/** @internal */ _this._updateFlagManager = new UpdateFlagManager();
|
|
20817
20848
|
_this._texture = texture;
|
|
20849
|
+
_this._onRegionChange = _this._onRegionChange.bind(_assert_this_initialized(_this));
|
|
20850
|
+
_this._onPivotChange = _this._onPivotChange.bind(_assert_this_initialized(_this));
|
|
20851
|
+
_this._onBorderChange = _this._onBorderChange.bind(_assert_this_initialized(_this));
|
|
20852
|
+
// @ts-ignore
|
|
20853
|
+
_this._region._onValueChanged = _this._onRegionChange;
|
|
20854
|
+
// @ts-ignore
|
|
20855
|
+
_this._pivot._onValueChanged = _this._onPivotChange;
|
|
20856
|
+
// @ts-ignore
|
|
20857
|
+
_this._border._onValueChanged = _this._onBorderChange;
|
|
20818
20858
|
region && _this._region.copyFrom(region);
|
|
20819
20859
|
pivot && _this._pivot.copyFrom(pivot);
|
|
20820
20860
|
border && _this._border.copyFrom(border);
|
|
@@ -20954,6 +20994,34 @@ exports.TextVerticalAlignment = void 0;
|
|
|
20954
20994
|
}
|
|
20955
20995
|
this._updateFlagManager.dispatch(type);
|
|
20956
20996
|
};
|
|
20997
|
+
_proto._onRegionChange = function _onRegionChange() {
|
|
20998
|
+
var _this = this, region = _this._region;
|
|
20999
|
+
// @ts-ignore
|
|
21000
|
+
region._onValueChanged = null;
|
|
21001
|
+
var x = miniprogram.MathUtil.clamp(region.x, 0, 1);
|
|
21002
|
+
var y = miniprogram.MathUtil.clamp(region.y, 0, 1);
|
|
21003
|
+
region.set(x, y, miniprogram.MathUtil.clamp(region.width, 0, 1 - x), miniprogram.MathUtil.clamp(region.height, 0, 1 - y));
|
|
21004
|
+
this._dispatchSpriteChange(SpriteModifyFlags.region);
|
|
21005
|
+
if (this._customWidth === undefined || this._customHeight === undefined) {
|
|
21006
|
+
this._dispatchSpriteChange(SpriteModifyFlags.size);
|
|
21007
|
+
}
|
|
21008
|
+
// @ts-ignore
|
|
21009
|
+
region._onValueChanged = this._onRegionChange;
|
|
21010
|
+
};
|
|
21011
|
+
_proto._onPivotChange = function _onPivotChange() {
|
|
21012
|
+
this._dispatchSpriteChange(SpriteModifyFlags.pivot);
|
|
21013
|
+
};
|
|
21014
|
+
_proto._onBorderChange = function _onBorderChange() {
|
|
21015
|
+
var _this = this, border = _this._border;
|
|
21016
|
+
// @ts-ignore
|
|
21017
|
+
border._onValueChanged = null;
|
|
21018
|
+
var x = miniprogram.MathUtil.clamp(border.x, 0, 1);
|
|
21019
|
+
var y = miniprogram.MathUtil.clamp(border.y, 0, 1);
|
|
21020
|
+
border.set(x, y, miniprogram.MathUtil.clamp(border.z, 0, 1 - x), miniprogram.MathUtil.clamp(border.w, 0, 1 - y));
|
|
21021
|
+
this._dispatchSpriteChange(SpriteModifyFlags.border);
|
|
21022
|
+
// @ts-ignore
|
|
21023
|
+
border._onValueChanged = this._onBorderChange;
|
|
21024
|
+
};
|
|
20957
21025
|
_create_class(Sprite, [
|
|
20958
21026
|
{
|
|
20959
21027
|
key: "texture",
|
|
@@ -21073,14 +21141,7 @@ exports.TextVerticalAlignment = void 0;
|
|
|
21073
21141
|
return this._region;
|
|
21074
21142
|
},
|
|
21075
21143
|
set: function set(value) {
|
|
21076
|
-
|
|
21077
|
-
var x = miniprogram.MathUtil.clamp(value.x, 0, 1);
|
|
21078
|
-
var y = miniprogram.MathUtil.clamp(value.y, 0, 1);
|
|
21079
|
-
region.set(x, y, miniprogram.MathUtil.clamp(value.width, 0, 1 - x), miniprogram.MathUtil.clamp(value.height, 0, 1 - y));
|
|
21080
|
-
this._dispatchSpriteChange(SpriteModifyFlags.region);
|
|
21081
|
-
if (this._customWidth === undefined || this._customHeight === undefined) {
|
|
21082
|
-
this._dispatchSpriteChange(SpriteModifyFlags.size);
|
|
21083
|
-
}
|
|
21144
|
+
this._region !== value && this._region.copyFrom(value);
|
|
21084
21145
|
}
|
|
21085
21146
|
},
|
|
21086
21147
|
{
|
|
@@ -21092,16 +21153,7 @@ exports.TextVerticalAlignment = void 0;
|
|
|
21092
21153
|
return this._pivot;
|
|
21093
21154
|
},
|
|
21094
21155
|
set: function set(value) {
|
|
21095
|
-
|
|
21096
|
-
if (pivot === value) {
|
|
21097
|
-
this._dispatchSpriteChange(SpriteModifyFlags.pivot);
|
|
21098
|
-
} else {
|
|
21099
|
-
var x = value.x, y = value.y;
|
|
21100
|
-
if (pivot.x !== x || pivot.y !== y) {
|
|
21101
|
-
pivot.set(x, y);
|
|
21102
|
-
this._dispatchSpriteChange(SpriteModifyFlags.pivot);
|
|
21103
|
-
}
|
|
21104
|
-
}
|
|
21156
|
+
this._pivot !== value && this._pivot.copyFrom(value);
|
|
21105
21157
|
}
|
|
21106
21158
|
},
|
|
21107
21159
|
{
|
|
@@ -21116,11 +21168,7 @@ exports.TextVerticalAlignment = void 0;
|
|
|
21116
21168
|
return this._border;
|
|
21117
21169
|
},
|
|
21118
21170
|
set: function set(value) {
|
|
21119
|
-
|
|
21120
|
-
var x = miniprogram.MathUtil.clamp(value.x, 0, 1);
|
|
21121
|
-
var y = miniprogram.MathUtil.clamp(value.y, 0, 1);
|
|
21122
|
-
border.set(x, y, miniprogram.MathUtil.clamp(value.z, 0, 1 - x), miniprogram.MathUtil.clamp(value.w, 0, 1 - y));
|
|
21123
|
-
this._dispatchSpriteChange(SpriteModifyFlags.border);
|
|
21171
|
+
this._border !== value && this._border.copyFrom(value);
|
|
21124
21172
|
}
|
|
21125
21173
|
}
|
|
21126
21174
|
]);
|