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