@galacean/engine-core 1.0.0-beta.6 → 1.0.0-beta.8
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 +208 -86
- package/dist/main.js.map +1 -1
- package/dist/miniprogram.js +208 -86
- package/dist/module.js +208 -86
- package/dist/module.js.map +1 -1
- package/package.json +3 -3
- package/types/2d/sprite/Sprite.d.ts +12 -2
- package/types/2d/sprite/SpriteMask.d.ts +15 -4
- package/types/2d/sprite/SpriteRenderer.d.ts +15 -4
- package/types/mesh/MeshRenderer.d.ts +7 -1
package/dist/miniprogram.js
CHANGED
|
@@ -9518,11 +9518,11 @@ var camera_declare = "#define GLSLIFY 1\nuniform vec3 camera_Position;"; // esli
|
|
|
9518
9518
|
|
|
9519
9519
|
var common = "#define GLSLIFY 1\n#define PI 3.14159265359\n#define RECIPROCAL_PI 0.31830988618\n#define EPSILON 1e-6\n#define LOG2 1.442695\n#define saturate( a ) clamp( a, 0.0, 1.0 )\nfloat pow2(float x){return x*x;}vec4 RGBMToLinear(vec4 value,float maxRange){return vec4(value.rgb*value.a*maxRange,1.0);}vec4 gammaToLinear(vec4 srgbIn){return vec4(pow(srgbIn.rgb,vec3(2.2)),srgbIn.a);}vec4 linearToGamma(vec4 linearIn){return vec4(pow(linearIn.rgb,vec3(1.0/2.2)),linearIn.a);}\n#ifdef GRAPHICS_API_WEBGL2\n#define INVERSE_MAT(mat) inverse(mat)\n#else\nmat2 inverseMat(mat2 m){return mat2(m[1][1],-m[0][1],-m[1][0],m[0][0])/(m[0][0]*m[1][1]-m[0][1]*m[1][0]);}mat3 inverseMat(mat3 m){float a00=m[0][0],a01=m[0][1],a02=m[0][2];float a10=m[1][0],a11=m[1][1],a12=m[1][2];float a20=m[2][0],a21=m[2][1],a22=m[2][2];float b01=a22*a11-a12*a21;float b11=-a22*a10+a12*a20;float b21=a21*a10-a11*a20;float det=a00*b01+a01*b11+a02*b21;return mat3(b01,(-a22*a01+a02*a21),(a12*a01-a02*a11),b11,(a22*a00-a02*a20),(-a12*a00+a02*a10),b21,(-a21*a00+a01*a20),(a11*a00-a01*a10))/det;}mat4 inverseMat(mat4 m){float a00=m[0][0],a01=m[0][1],a02=m[0][2],a03=m[0][3],a10=m[1][0],a11=m[1][1],a12=m[1][2],a13=m[1][3],a20=m[2][0],a21=m[2][1],a22=m[2][2],a23=m[2][3],a30=m[3][0],a31=m[3][1],a32=m[3][2],a33=m[3][3],b00=a00*a11-a01*a10,b01=a00*a12-a02*a10,b02=a00*a13-a03*a10,b03=a01*a12-a02*a11,b04=a01*a13-a03*a11,b05=a02*a13-a03*a12,b06=a20*a31-a21*a30,b07=a20*a32-a22*a30,b08=a20*a33-a23*a30,b09=a21*a32-a22*a31,b10=a21*a33-a23*a31,b11=a22*a33-a23*a32,det=b00*b11-b01*b10+b02*b09+b03*b08-b04*b07+b05*b06;return mat4(a11*b11-a12*b10+a13*b09,a02*b10-a01*b11-a03*b09,a31*b05-a32*b04+a33*b03,a22*b04-a21*b05-a23*b03,a12*b08-a10*b11-a13*b07,a00*b11-a02*b08+a03*b07,a32*b02-a30*b05-a33*b01,a20*b05-a22*b02+a23*b01,a10*b10-a11*b08+a13*b06,a01*b08-a00*b10-a03*b06,a30*b04-a31*b02+a33*b00,a21*b02-a20*b04-a23*b00,a11*b07-a10*b09-a12*b06,a00*b09-a01*b07+a02*b06,a31*b01-a30*b03-a32*b00,a20*b03-a21*b01+a22*b00)/det;}\n#define INVERSE_MAT(mat) inverseMat(mat)\n#endif\n"; // eslint-disable-line
|
|
9520
9520
|
|
|
9521
|
-
var common_vert = "#define GLSLIFY 1\nattribute vec3 POSITION;\n#ifdef RENDERER_HAS_UV\nattribute vec2 TEXCOORD_0;\n#endif\n#ifdef RENDERER_HAS_UV1\nattribute vec2 TEXCOORD_1;\n#endif\n#ifdef RENDERER_HAS_SKIN\nattribute vec4 JOINTS_0;attribute vec4 WEIGHTS_0;\n#ifdef RENDERER_USE_JOINT_TEXTURE\nuniform sampler2D renderer_JointSampler;uniform float renderer_JointCount;mat4 getJointMatrix(sampler2D smp,float index){float base=index/renderer_JointCount;float hf=0.5/renderer_JointCount;float v=base+hf;vec4 m0=texture2D(smp,vec2(0.125,v));vec4 m1=texture2D(smp,vec2(0.375,v));vec4 m2=texture2D(smp,vec2(0.625,v));vec4 m3=texture2D(smp,vec2(0.875,v));return mat4(m0,m1,m2,m3);}\n#else\nuniform mat4 renderer_JointMatrix[RENDERER_JOINTS_NUM];\n#endif\n#endif\n#ifdef
|
|
9521
|
+
var common_vert = "#define GLSLIFY 1\nattribute vec3 POSITION;\n#ifdef RENDERER_HAS_UV\nattribute vec2 TEXCOORD_0;\n#endif\n#ifdef RENDERER_HAS_UV1\nattribute vec2 TEXCOORD_1;\n#endif\n#ifdef RENDERER_HAS_SKIN\nattribute vec4 JOINTS_0;attribute vec4 WEIGHTS_0;\n#ifdef RENDERER_USE_JOINT_TEXTURE\nuniform sampler2D renderer_JointSampler;uniform float renderer_JointCount;mat4 getJointMatrix(sampler2D smp,float index){float base=index/renderer_JointCount;float hf=0.5/renderer_JointCount;float v=base+hf;vec4 m0=texture2D(smp,vec2(0.125,v));vec4 m1=texture2D(smp,vec2(0.375,v));vec4 m2=texture2D(smp,vec2(0.625,v));vec4 m3=texture2D(smp,vec2(0.875,v));return mat4(m0,m1,m2,m3);}\n#else\nuniform mat4 renderer_JointMatrix[RENDERER_JOINTS_NUM];\n#endif\n#endif\n#ifdef RENDERER_ENABLE_VERTEXCOLOR\nattribute vec4 COLOR_0;\n#endif\n#include <transform_declare>\n#include <camera_declare>\nuniform vec4 material_TilingOffset;\n#ifndef MATERIAL_OMIT_NORMAL\n#ifdef RENDERER_HAS_NORMAL\nattribute vec3 NORMAL;\n#endif\n#ifdef RENDERER_HAS_TANGENT\nattribute vec4 TANGENT;\n#endif\n#endif\n"; // eslint-disable-line
|
|
9522
9522
|
|
|
9523
9523
|
var transform_declare = "#define GLSLIFY 1\nuniform mat4 renderer_LocalMat;uniform mat4 renderer_ModelMat;uniform mat4 camera_ViewMat;uniform mat4 camera_ProjMat;uniform mat4 renderer_MVMat;uniform mat4 renderer_MVPMat;uniform mat4 renderer_NormalMat;"; // eslint-disable-line
|
|
9524
9524
|
|
|
9525
|
-
var color_share = "#define GLSLIFY 1\n#ifdef
|
|
9525
|
+
var color_share = "#define GLSLIFY 1\n#ifdef RENDERER_ENABLE_VERTEXCOLOR\nvarying vec4 v_color;\n#endif\n"; // eslint-disable-line
|
|
9526
9526
|
|
|
9527
9527
|
var FogFragmentDeclaration = "#define GLSLIFY 1\n#if SCENE_FOG_MODE != 0\nvarying vec3 v_positionVS;uniform vec4 scene_FogColor;uniform vec4 scene_FogParams;float ComputeFogIntensity(float fogDepth){\n#if SCENE_FOG_MODE == 1\nreturn clamp(fogDepth*scene_FogParams.x+scene_FogParams.y,0.0,1.0);\n#elif SCENE_FOG_MODE == 2\nreturn clamp(exp2(-fogDepth*scene_FogParams.z),0.0,1.0);\n#elif SCENE_FOG_MODE == 3\nfloat factor=fogDepth*scene_FogParams.w;return clamp(exp2(-factor*factor),0.0,1.0);\n#endif\n}\n#endif\n"; // eslint-disable-line
|
|
9528
9528
|
|
|
@@ -9542,7 +9542,7 @@ var blendShape_input = "#define GLSLIFY 1\n#ifdef RENDERER_HAS_BLENDSHAPE\n#ifde
|
|
|
9542
9542
|
|
|
9543
9543
|
var blendShape_vert = "#define GLSLIFY 1\n#ifdef RENDERER_HAS_BLENDSHAPE\n#ifdef RENDERER_BLENDSHAPE_USE_TEXTURE\nint vertexOffset=gl_VertexID*renderer_BlendShapeTextureInfo.x;for(int i=0;i<RENDERER_BLENDSHAPE_COUNT;i++){int vertexElementOffset=vertexOffset;float weight=renderer_BlendShapeWeights[i];position.xyz+=getBlendShapeVertexElement(i,vertexElementOffset)*weight;\n#ifndef MATERIAL_OMIT_NORMAL\n#if defined( RENDERER_HAS_NORMAL ) && defined( RENDERER_BLENDSHAPE_HAS_NORMAL )\nvertexElementOffset+=1;normal+=getBlendShapeVertexElement(i,vertexElementOffset)*weight;\n#endif\n#if defined( RENDERER_HAS_TANGENT ) && defined(RENDERER_BLENDSHAPE_HAS_TANGENT) && ( defined(MATERIAL_HAS_NORMALTEXTURE) || defined(MATERIAL_HAS_CLEAR_COAT_NORMAL_TEXTURE) )\nvertexElementOffset+=1;tangent.xyz+=getBlendShapeVertexElement(i,vertexElementOffset)*weight;\n#endif\n#endif\n}\n#else\nposition.xyz+=POSITION_BS0*renderer_BlendShapeWeights[0];position.xyz+=POSITION_BS1*renderer_BlendShapeWeights[1];\n#if defined( RENDERER_BLENDSHAPE_HAS_NORMAL ) && defined( RENDERER_BLENDSHAPE_HAS_TANGENT )\n#ifndef MATERIAL_OMIT_NORMAL\n#ifdef RENDERER_HAS_NORMAL\nnormal+=NORMAL_BS0*renderer_BlendShapeWeights[0];normal+=NORMAL_BS1*renderer_BlendShapeWeights[1];\n#endif\n#if defined( RENDERER_HAS_TANGENT ) && ( defined(MATERIAL_HAS_NORMALTEXTURE) || defined(MATERIAL_HAS_CLEAR_COAT_NORMAL_TEXTURE) )\ntangent.xyz+=TANGENT_BS0*renderer_BlendShapeWeights[0];tangent.xyz+=TANGENT_BS1*renderer_BlendShapeWeights[1];\n#endif\n#endif\n#else\n#if defined( RENDERER_BLENDSHAPE_HAS_NORMAL ) || defined( RENDERER_BLENDSHAPE_HAS_TANGENT )\n#ifndef MATERIAL_OMIT_NORMAL\nposition.xyz+=POSITION_BS2*renderer_BlendShapeWeights[2];position.xyz+=POSITION_BS3*renderer_BlendShapeWeights[3];\n#if defined( RENDERER_BLENDSHAPE_HAS_NORMAL ) && defined( RENDERER_HAS_NORMAL )\nnormal+=NORMAL_BS0*renderer_BlendShapeWeights[0];normal+=NORMAL_BS1*renderer_BlendShapeWeights[1];normal+=NORMAL_BS2*renderer_BlendShapeWeights[2];normal+=NORMAL_BS3*renderer_BlendShapeWeights[3];\n#endif\n#if defined(RENDERER_BLENDSHAPE_HAS_TANGENT) && defined( RENDERER_HAS_TANGENT ) && ( defined(MATERIAL_HAS_NORMALTEXTURE) || defined(MATERIAL_HAS_CLEAR_COAT_NORMAL_TEXTURE) )\ntangent.xyz+=TANGENT_BS0*renderer_BlendShapeWeights[0];tangent.xyz+=TANGENT_BS1*renderer_BlendShapeWeights[1];tangent.xyz+=TANGENT_BS2*renderer_BlendShapeWeights[2];tangent.xyz+=TANGENT_BS3*renderer_BlendShapeWeights[3];\n#endif\n#endif\n#else\nposition.xyz+=POSITION_BS2*renderer_BlendShapeWeights[2];position.xyz+=POSITION_BS3*renderer_BlendShapeWeights[3];position.xyz+=POSITION_BS4*renderer_BlendShapeWeights[4];position.xyz+=POSITION_BS5*renderer_BlendShapeWeights[5];position.xyz+=POSITION_BS6*renderer_BlendShapeWeights[6];position.xyz+=POSITION_BS7*renderer_BlendShapeWeights[7];\n#endif\n#endif\n#endif\n#endif\n"; // eslint-disable-line
|
|
9544
9544
|
|
|
9545
|
-
var color_vert = "#define GLSLIFY 1\n#ifdef
|
|
9545
|
+
var color_vert = "#define GLSLIFY 1\n#ifdef RENDERER_ENABLE_VERTEXCOLOR\nv_color=COLOR_0;\n#endif\n"; // eslint-disable-line
|
|
9546
9546
|
|
|
9547
9547
|
var FogVertex = "#define GLSLIFY 1\n#if SCENE_FOG_MODE != 0\nvec4 positionVS=renderer_MVMat*position;v_positionVS=positionVS.xyz/positionVS.w;\n#endif\n"; // eslint-disable-line
|
|
9548
9548
|
|
|
@@ -9562,7 +9562,7 @@ var light_frag_define = "#define GLSLIFY 1\n#ifdef SCENE_DIRECT_LIGHT_COUNT\nstr
|
|
|
9562
9562
|
|
|
9563
9563
|
var mobile_material_frag = "#define GLSLIFY 1\nuniform vec4 material_EmissiveColor;uniform vec4 material_BaseColor;uniform vec4 material_SpecularColor;uniform float material_Shininess;uniform float material_NormalIntensity;uniform float material_AlphaCutoff;\n#ifdef MATERIAL_HAS_EMISSIVETEXTURE\nuniform sampler2D material_EmissiveTexture;\n#endif\n#ifdef MATERIAL_HAS_BASETEXTURE\nuniform sampler2D material_BaseTexture;\n#endif\n#ifdef MATERIAL_HAS_SPECULAR_TEXTURE\nuniform sampler2D material_SpecularTexture;\n#endif\n#ifdef MATERIAL_HAS_NORMALTEXTURE\nuniform sampler2D material_NormalTexture;\n#endif\n"; // eslint-disable-line
|
|
9564
9564
|
|
|
9565
|
-
var begin_mobile_frag = "#define GLSLIFY 1\nvec4 ambient=vec4(0.0);vec4 emission=material_EmissiveColor;vec4 diffuse=material_BaseColor;vec4 specular=material_SpecularColor;\n#ifdef MATERIAL_HAS_EMISSIVETEXTURE\nvec4 emissiveTextureColor=texture2D(material_EmissiveTexture,v_uv);\n#ifndef ENGINE_IS_COLORSPACE_GAMMA\nemissiveTextureColor=gammaToLinear(emissiveTextureColor);\n#endif\nemission*=emissiveTextureColor;\n#endif\n#ifdef MATERIAL_HAS_BASETEXTURE\nvec4 diffuseTextureColor=texture2D(material_BaseTexture,v_uv);\n#ifndef ENGINE_IS_COLORSPACE_GAMMA\ndiffuseTextureColor=gammaToLinear(diffuseTextureColor);\n#endif\ndiffuse*=diffuseTextureColor;\n#endif\n#ifdef
|
|
9565
|
+
var begin_mobile_frag = "#define GLSLIFY 1\nvec4 ambient=vec4(0.0);vec4 emission=material_EmissiveColor;vec4 diffuse=material_BaseColor;vec4 specular=material_SpecularColor;\n#ifdef MATERIAL_HAS_EMISSIVETEXTURE\nvec4 emissiveTextureColor=texture2D(material_EmissiveTexture,v_uv);\n#ifndef ENGINE_IS_COLORSPACE_GAMMA\nemissiveTextureColor=gammaToLinear(emissiveTextureColor);\n#endif\nemission*=emissiveTextureColor;\n#endif\n#ifdef MATERIAL_HAS_BASETEXTURE\nvec4 diffuseTextureColor=texture2D(material_BaseTexture,v_uv);\n#ifndef ENGINE_IS_COLORSPACE_GAMMA\ndiffuseTextureColor=gammaToLinear(diffuseTextureColor);\n#endif\ndiffuse*=diffuseTextureColor;\n#endif\n#ifdef RENDERER_ENABLE_VERTEXCOLOR\ndiffuse*=v_color;\n#endif\n#ifdef MATERIAL_HAS_SPECULAR_TEXTURE\nvec4 specularTextureColor=texture2D(material_SpecularTexture,v_uv);\n#ifndef ENGINE_IS_COLORSPACE_GAMMA\nspecularTextureColor=gammaToLinear(specularTextureColor);\n#endif\nspecular*=specularTextureColor;\n#endif\nambient=vec4(scene_EnvMapLight.diffuse*scene_EnvMapLight.diffuseIntensity,1.0)*diffuse;"; // eslint-disable-line
|
|
9566
9566
|
|
|
9567
9567
|
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
|
|
9568
9568
|
|
|
@@ -9602,7 +9602,7 @@ var noise_simplex_4D = "#define GLSLIFY 1\nvec4 grad4(float j,vec4 ip){const vec
|
|
|
9602
9602
|
|
|
9603
9603
|
var pbr_frag_define = "#define GLSLIFY 1\nuniform float material_AlphaCutoff;uniform vec4 material_BaseColor;uniform float material_Metal;uniform float material_Roughness;uniform float material_IOR;uniform vec3 material_PBRSpecularColor;uniform float material_Glossiness;uniform vec3 material_EmissiveColor;\n#ifdef MATERIAL_ENABLE_CLEAR_COAT\nuniform float material_ClearCoat;uniform float material_ClearCoatRoughness;\n#endif\nuniform float material_NormalIntensity;uniform float material_OcclusionIntensity;uniform float material_OcclusionTextureCoord;\n#ifdef MATERIAL_HAS_BASETEXTURE\nuniform sampler2D material_BaseTexture;\n#endif\n#ifdef MATERIAL_HAS_NORMALTEXTURE\nuniform sampler2D material_NormalTexture;\n#endif\n#ifdef MATERIAL_HAS_EMISSIVETEXTURE\nuniform sampler2D material_EmissiveTexture;\n#endif\n#ifdef MATERIAL_HAS_ROUGHNESS_METALLIC_TEXTURE\nuniform sampler2D material_RoughnessMetallicTexture;\n#endif\n#ifdef MATERIAL_HAS_SPECULAR_GLOSSINESS_TEXTURE\nuniform sampler2D material_SpecularGlossinessTexture;\n#endif\n#ifdef MATERIAL_HAS_OCCLUSION_TEXTURE\nuniform sampler2D material_OcclusionTexture;\n#endif\n#ifdef MATERIAL_HAS_CLEAR_COAT_TEXTURE\nuniform sampler2D material_ClearCoatTexture;\n#endif\n#ifdef MATERIAL_HAS_CLEAR_COAT_ROUGHNESS_TEXTURE\nuniform sampler2D material_ClearCoatRoughnessTexture;\n#endif\n#ifdef MATERIAL_HAS_CLEAR_COAT_NORMAL_TEXTURE\nuniform sampler2D material_ClearCoatNormalTexture;\n#endif\nstruct ReflectedLight{vec3 directDiffuse;vec3 directSpecular;vec3 indirectDiffuse;vec3 indirectSpecular;};struct Geometry{vec3 position;vec3 normal;vec3 viewDir;float dotNV;\n#ifdef MATERIAL_ENABLE_CLEAR_COAT\nvec3 clearCoatNormal;float clearCoatDotNV;\n#endif\n};struct Material{vec3 diffuseColor;float roughness;vec3 specularColor;float opacity;\n#ifdef MATERIAL_ENABLE_CLEAR_COAT\nfloat clearCoat;float clearCoatRoughness;\n#endif\n};"; // eslint-disable-line
|
|
9604
9604
|
|
|
9605
|
-
var pbr_helper = "#define GLSLIFY 1\n#include <normal_get>\nfloat computeSpecularOcclusion(float ambientOcclusion,float roughness,float dotNV){return saturate(pow(dotNV+ambientOcclusion,exp2(-16.0*roughness-1.0))-1.0+ambientOcclusion);}float getAARoughnessFactor(vec3 normal){\n#ifdef HAS_DERIVATIVES\nvec3 dxy=max(abs(dFdx(normal)),abs(dFdy(normal)));return 0.04+max(max(dxy.x,dxy.y),dxy.z);\n#else\nreturn 0.04;\n#endif\n}void initGeometry(out Geometry geometry){geometry.position=v_pos;geometry.viewDir=normalize(camera_Position-v_pos);\n#if defined(MATERIAL_HAS_NORMALTEXTURE) || defined(MATERIAL_HAS_CLEAR_COAT_NORMAL_TEXTURE)\nmat3 tbn=getTBN();\n#endif\n#ifdef MATERIAL_HAS_NORMALTEXTURE\ngeometry.normal=getNormalByNormalTexture(tbn,material_NormalTexture,material_NormalIntensity,v_uv);\n#else\ngeometry.normal=getNormal();\n#endif\ngeometry.dotNV=saturate(dot(geometry.normal,geometry.viewDir));\n#ifdef MATERIAL_ENABLE_CLEAR_COAT\n#ifdef MATERIAL_HAS_CLEAR_COAT_NORMAL_TEXTURE\ngeometry.clearCoatNormal=getNormalByNormalTexture(tbn,material_ClearCoatNormalTexture,material_NormalIntensity,v_uv);\n#else\ngeometry.clearCoatNormal=getNormal();\n#endif\ngeometry.clearCoatDotNV=saturate(dot(geometry.clearCoatNormal,geometry.viewDir));\n#endif\n}void initMaterial(out Material material,const in Geometry geometry){vec4 baseColor=material_BaseColor;float metal=material_Metal;float roughness=material_Roughness;vec3 specularColor=material_PBRSpecularColor;float glossiness=material_Glossiness;float alphaCutoff=material_AlphaCutoff;float F0=pow2((material_IOR-1.0)/(material_IOR+1.0));\n#ifdef MATERIAL_HAS_BASETEXTURE\nvec4 baseTextureColor=texture2D(material_BaseTexture,v_uv);\n#ifndef ENGINE_IS_COLORSPACE_GAMMA\nbaseTextureColor=gammaToLinear(baseTextureColor);\n#endif\nbaseColor*=baseTextureColor;\n#endif\n#ifdef
|
|
9605
|
+
var pbr_helper = "#define GLSLIFY 1\n#include <normal_get>\nfloat computeSpecularOcclusion(float ambientOcclusion,float roughness,float dotNV){return saturate(pow(dotNV+ambientOcclusion,exp2(-16.0*roughness-1.0))-1.0+ambientOcclusion);}float getAARoughnessFactor(vec3 normal){\n#ifdef HAS_DERIVATIVES\nvec3 dxy=max(abs(dFdx(normal)),abs(dFdy(normal)));return 0.04+max(max(dxy.x,dxy.y),dxy.z);\n#else\nreturn 0.04;\n#endif\n}void initGeometry(out Geometry geometry){geometry.position=v_pos;geometry.viewDir=normalize(camera_Position-v_pos);\n#if defined(MATERIAL_HAS_NORMALTEXTURE) || defined(MATERIAL_HAS_CLEAR_COAT_NORMAL_TEXTURE)\nmat3 tbn=getTBN();\n#endif\n#ifdef MATERIAL_HAS_NORMALTEXTURE\ngeometry.normal=getNormalByNormalTexture(tbn,material_NormalTexture,material_NormalIntensity,v_uv);\n#else\ngeometry.normal=getNormal();\n#endif\ngeometry.dotNV=saturate(dot(geometry.normal,geometry.viewDir));\n#ifdef MATERIAL_ENABLE_CLEAR_COAT\n#ifdef MATERIAL_HAS_CLEAR_COAT_NORMAL_TEXTURE\ngeometry.clearCoatNormal=getNormalByNormalTexture(tbn,material_ClearCoatNormalTexture,material_NormalIntensity,v_uv);\n#else\ngeometry.clearCoatNormal=getNormal();\n#endif\ngeometry.clearCoatDotNV=saturate(dot(geometry.clearCoatNormal,geometry.viewDir));\n#endif\n}void initMaterial(out Material material,const in Geometry geometry){vec4 baseColor=material_BaseColor;float metal=material_Metal;float roughness=material_Roughness;vec3 specularColor=material_PBRSpecularColor;float glossiness=material_Glossiness;float alphaCutoff=material_AlphaCutoff;float F0=pow2((material_IOR-1.0)/(material_IOR+1.0));\n#ifdef MATERIAL_HAS_BASETEXTURE\nvec4 baseTextureColor=texture2D(material_BaseTexture,v_uv);\n#ifndef ENGINE_IS_COLORSPACE_GAMMA\nbaseTextureColor=gammaToLinear(baseTextureColor);\n#endif\nbaseColor*=baseTextureColor;\n#endif\n#ifdef RENDERER_ENABLE_VERTEXCOLOR\nbaseColor*=v_color;\n#endif\n#ifdef MATERIAL_IS_ALPHA_CUTOFF\nif(baseColor.a<alphaCutoff){discard;}\n#endif\n#ifdef MATERIAL_HAS_ROUGHNESS_METALLIC_TEXTURE\nvec4 metalRoughMapColor=texture2D(material_RoughnessMetallicTexture,v_uv);roughness*=metalRoughMapColor.g;metal*=metalRoughMapColor.b;\n#endif\n#ifdef MATERIAL_HAS_SPECULAR_GLOSSINESS_TEXTURE\nvec4 specularGlossinessColor=texture2D(material_SpecularGlossinessTexture,v_uv);\n#ifndef ENGINE_IS_COLORSPACE_GAMMA\nspecularGlossinessColor=gammaToLinear(specularGlossinessColor);\n#endif\nspecularColor*=specularGlossinessColor.rgb;glossiness*=specularGlossinessColor.a;\n#endif\n#ifdef IS_METALLIC_WORKFLOW\nmaterial.diffuseColor=baseColor.rgb*(1.0-metal);material.specularColor=mix(vec3(F0),baseColor.rgb,metal);material.roughness=roughness;\n#else\nfloat specularStrength=max(max(specularColor.r,specularColor.g),specularColor.b);material.diffuseColor=baseColor.rgb*(1.0-specularStrength);material.specularColor=specularColor;material.roughness=1.0-glossiness;\n#endif\nmaterial.roughness=max(material.roughness,getAARoughnessFactor(geometry.normal));\n#ifdef MATERIAL_ENABLE_CLEAR_COAT\nmaterial.clearCoat=material_ClearCoat;material.clearCoatRoughness=material_ClearCoatRoughness;\n#ifdef MATERIAL_HAS_CLEAR_COAT_TEXTURE\nmaterial.clearCoat*=texture2D(material_ClearCoatTexture,v_uv).r;\n#endif\n#ifdef MATERIAL_HAS_CLEAR_COAT_ROUGHNESS_TEXTURE\nmaterial.clearCoatRoughness*=texture2D(material_ClearCoatRoughnessTexture,v_uv).g;\n#endif\nmaterial.clearCoat=saturate(material.clearCoat);material.clearCoatRoughness=max(material.clearCoatRoughness,getAARoughnessFactor(geometry.clearCoatNormal));\n#endif\n#ifdef MATERIAL_IS_TRANSPARENT\nmaterial.opacity=baseColor.a;\n#else\nmaterial.opacity=1.0;\n#endif\n}\n#include <brdf>\n#include <direct_irradiance_frag_define>\n#include <ibl_frag_define>\n"; // eslint-disable-line
|
|
9606
9606
|
|
|
9607
9607
|
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
|
|
9608
9608
|
|
|
@@ -11177,8 +11177,10 @@ SimpleSpriteAssembler = __decorate([
|
|
|
11177
11177
|
_this = Renderer.call(this, entity) || this;
|
|
11178
11178
|
/** The mask layers the sprite mask influence to. */ _this.influenceLayers = exports.SpriteMaskLayer.Everything;
|
|
11179
11179
|
_this._sprite = null;
|
|
11180
|
-
_this.
|
|
11181
|
-
_this.
|
|
11180
|
+
_this._automaticWidth = 0;
|
|
11181
|
+
_this._automaticHeight = 0;
|
|
11182
|
+
_this._customWidth = undefined;
|
|
11183
|
+
_this._customHeight = undefined;
|
|
11182
11184
|
_this._flipX = false;
|
|
11183
11185
|
_this._flipY = false;
|
|
11184
11186
|
_this._alphaCutoff = 0.5;
|
|
@@ -11198,12 +11200,11 @@ SimpleSpriteAssembler = __decorate([
|
|
|
11198
11200
|
/**
|
|
11199
11201
|
* @internal
|
|
11200
11202
|
*/ _proto._updateBounds = function _updateBounds(worldBounds) {
|
|
11201
|
-
|
|
11202
|
-
|
|
11203
|
+
if (this.sprite) {
|
|
11204
|
+
SimpleSpriteAssembler.updatePositions(this);
|
|
11205
|
+
} else {
|
|
11203
11206
|
worldBounds.min.set(0, 0, 0);
|
|
11204
11207
|
worldBounds.max.set(0, 0, 0);
|
|
11205
|
-
} else {
|
|
11206
|
-
SimpleSpriteAssembler.updatePositions(this);
|
|
11207
11208
|
}
|
|
11208
11209
|
};
|
|
11209
11210
|
/**
|
|
@@ -11214,12 +11215,12 @@ SimpleSpriteAssembler = __decorate([
|
|
|
11214
11215
|
if (!((_this_sprite = this.sprite) == null ? void 0 : _this_sprite.texture) || !this.width || !this.height) {
|
|
11215
11216
|
return;
|
|
11216
11217
|
}
|
|
11217
|
-
// Update position
|
|
11218
|
+
// Update position
|
|
11218
11219
|
if (this._dirtyUpdateFlag & RendererUpdateFlags.WorldVolume) {
|
|
11219
11220
|
SimpleSpriteAssembler.updatePositions(this);
|
|
11220
11221
|
this._dirtyUpdateFlag &= ~RendererUpdateFlags.WorldVolume;
|
|
11221
11222
|
}
|
|
11222
|
-
// Update uv
|
|
11223
|
+
// Update uv
|
|
11223
11224
|
if (this._dirtyUpdateFlag & 0x2) {
|
|
11224
11225
|
SimpleSpriteAssembler.updateUVs(this);
|
|
11225
11226
|
this._dirtyUpdateFlag &= ~0x2;
|
|
@@ -11242,11 +11243,27 @@ SimpleSpriteAssembler = __decorate([
|
|
|
11242
11243
|
this._sprite = null;
|
|
11243
11244
|
this._verticesData = null;
|
|
11244
11245
|
};
|
|
11246
|
+
_proto._calDefaultSize = function _calDefaultSize() {
|
|
11247
|
+
var sprite = this._sprite;
|
|
11248
|
+
if (sprite) {
|
|
11249
|
+
this._automaticWidth = sprite.width;
|
|
11250
|
+
this._automaticHeight = sprite.height;
|
|
11251
|
+
} else {
|
|
11252
|
+
this._automaticWidth = this._automaticHeight = 0;
|
|
11253
|
+
}
|
|
11254
|
+
this._dirtyUpdateFlag &= ~0x4;
|
|
11255
|
+
};
|
|
11245
11256
|
_proto._onSpriteChange = function _onSpriteChange(type) {
|
|
11246
11257
|
switch(type){
|
|
11247
11258
|
case SpriteModifyFlags.texture:
|
|
11248
11259
|
this.shaderData.setTexture(SpriteMask._textureProperty, this.sprite.texture);
|
|
11249
11260
|
break;
|
|
11261
|
+
case SpriteModifyFlags.size:
|
|
11262
|
+
this._dirtyUpdateFlag |= 0x4;
|
|
11263
|
+
if (this._customWidth === undefined || this._customHeight === undefined) {
|
|
11264
|
+
this._dirtyUpdateFlag |= RendererUpdateFlags.WorldVolume;
|
|
11265
|
+
}
|
|
11266
|
+
break;
|
|
11250
11267
|
case SpriteModifyFlags.region:
|
|
11251
11268
|
case SpriteModifyFlags.atlasRegionOffset:
|
|
11252
11269
|
this._dirtyUpdateFlag |= 0x3;
|
|
@@ -11254,22 +11271,31 @@ SimpleSpriteAssembler = __decorate([
|
|
|
11254
11271
|
case SpriteModifyFlags.atlasRegion:
|
|
11255
11272
|
this._dirtyUpdateFlag |= 0x2;
|
|
11256
11273
|
break;
|
|
11274
|
+
case SpriteModifyFlags.pivot:
|
|
11275
|
+
this._dirtyUpdateFlag |= RendererUpdateFlags.WorldVolume;
|
|
11276
|
+
break;
|
|
11257
11277
|
}
|
|
11258
11278
|
};
|
|
11259
11279
|
_create_class(SpriteMask, [
|
|
11260
11280
|
{
|
|
11261
11281
|
key: "width",
|
|
11262
11282
|
get: /**
|
|
11263
|
-
* Render width.
|
|
11283
|
+
* Render width (in world coordinates).
|
|
11284
|
+
*
|
|
11285
|
+
* @remarks
|
|
11286
|
+
* If width is set, return the set value,
|
|
11287
|
+
* otherwise return `SpriteMask.sprite.width`.
|
|
11264
11288
|
*/ function get() {
|
|
11265
|
-
if (this.
|
|
11266
|
-
|
|
11289
|
+
if (this._customWidth !== undefined) {
|
|
11290
|
+
return this._customWidth;
|
|
11291
|
+
} else {
|
|
11292
|
+
this._dirtyUpdateFlag & 0x4 && this._calDefaultSize();
|
|
11293
|
+
return this._automaticWidth;
|
|
11267
11294
|
}
|
|
11268
|
-
return this._width;
|
|
11269
11295
|
},
|
|
11270
11296
|
set: function set(value) {
|
|
11271
|
-
if (this.
|
|
11272
|
-
this.
|
|
11297
|
+
if (this._customWidth !== value) {
|
|
11298
|
+
this._customWidth = value;
|
|
11273
11299
|
this._dirtyUpdateFlag |= RendererUpdateFlags.WorldVolume;
|
|
11274
11300
|
}
|
|
11275
11301
|
}
|
|
@@ -11277,16 +11303,22 @@ SimpleSpriteAssembler = __decorate([
|
|
|
11277
11303
|
{
|
|
11278
11304
|
key: "height",
|
|
11279
11305
|
get: /**
|
|
11280
|
-
* Render height.
|
|
11306
|
+
* Render height (in world coordinates).
|
|
11307
|
+
*
|
|
11308
|
+
* @remarks
|
|
11309
|
+
* If height is set, return the set value,
|
|
11310
|
+
* otherwise return `SpriteMask.sprite.height`.
|
|
11281
11311
|
*/ function get() {
|
|
11282
|
-
if (this.
|
|
11283
|
-
|
|
11312
|
+
if (this._customHeight !== undefined) {
|
|
11313
|
+
return this._customHeight;
|
|
11314
|
+
} else {
|
|
11315
|
+
this._dirtyUpdateFlag & 0x4 && this._calDefaultSize();
|
|
11316
|
+
return this._automaticHeight;
|
|
11284
11317
|
}
|
|
11285
|
-
return this._height;
|
|
11286
11318
|
},
|
|
11287
11319
|
set: function set(value) {
|
|
11288
|
-
if (this.
|
|
11289
|
-
this.
|
|
11320
|
+
if (this._customHeight !== value) {
|
|
11321
|
+
this._customHeight = value;
|
|
11290
11322
|
this._dirtyUpdateFlag |= RendererUpdateFlags.WorldVolume;
|
|
11291
11323
|
}
|
|
11292
11324
|
}
|
|
@@ -11330,9 +11362,9 @@ SimpleSpriteAssembler = __decorate([
|
|
|
11330
11362
|
var lastSprite = this._sprite;
|
|
11331
11363
|
if (lastSprite !== value) {
|
|
11332
11364
|
lastSprite && lastSprite._updateFlagManager.removeListener(this._onSpriteChange);
|
|
11365
|
+
this._dirtyUpdateFlag |= 0x7;
|
|
11333
11366
|
if (value) {
|
|
11334
11367
|
value._updateFlagManager.addListener(this._onSpriteChange);
|
|
11335
|
-
this._dirtyUpdateFlag |= 0x3;
|
|
11336
11368
|
this.shaderData.setTexture(SpriteMask._textureProperty, value.texture);
|
|
11337
11369
|
} else {
|
|
11338
11370
|
this.shaderData.setTexture(SpriteMask._textureProperty, null);
|
|
@@ -11372,10 +11404,16 @@ __decorate([
|
|
|
11372
11404
|
], SpriteMask.prototype, "_sprite", void 0);
|
|
11373
11405
|
__decorate([
|
|
11374
11406
|
ignoreClone
|
|
11375
|
-
], SpriteMask.prototype, "
|
|
11407
|
+
], SpriteMask.prototype, "_automaticWidth", void 0);
|
|
11376
11408
|
__decorate([
|
|
11377
11409
|
ignoreClone
|
|
11378
|
-
], SpriteMask.prototype, "
|
|
11410
|
+
], SpriteMask.prototype, "_automaticHeight", void 0);
|
|
11411
|
+
__decorate([
|
|
11412
|
+
assignmentClone
|
|
11413
|
+
], SpriteMask.prototype, "_customWidth", void 0);
|
|
11414
|
+
__decorate([
|
|
11415
|
+
assignmentClone
|
|
11416
|
+
], SpriteMask.prototype, "_customHeight", void 0);
|
|
11379
11417
|
__decorate([
|
|
11380
11418
|
assignmentClone
|
|
11381
11419
|
], SpriteMask.prototype, "_flipX", void 0);
|
|
@@ -11393,7 +11431,9 @@ var /**
|
|
|
11393
11431
|
*/ SpriteMaskUpdateFlags;
|
|
11394
11432
|
(function(SpriteMaskUpdateFlags) {
|
|
11395
11433
|
SpriteMaskUpdateFlags[SpriteMaskUpdateFlags[/** UV. */ "UV"] = 0x2] = "UV";
|
|
11396
|
-
SpriteMaskUpdateFlags[SpriteMaskUpdateFlags[/**
|
|
11434
|
+
SpriteMaskUpdateFlags[SpriteMaskUpdateFlags[/** WorldVolume and UV . */ "RenderData"] = 0x3] = "RenderData";
|
|
11435
|
+
SpriteMaskUpdateFlags[SpriteMaskUpdateFlags[/** Automatic Size. */ "AutomaticSize"] = 0x4] = "AutomaticSize";
|
|
11436
|
+
SpriteMaskUpdateFlags[SpriteMaskUpdateFlags[/** All. */ "All"] = 0x7] = "All";
|
|
11397
11437
|
})(SpriteMaskUpdateFlags || (SpriteMaskUpdateFlags = {}));
|
|
11398
11438
|
|
|
11399
11439
|
/**
|
|
@@ -12200,6 +12240,7 @@ var MeshModifyFlags;
|
|
|
12200
12240
|
var subDataDirtyFlags = this._subDataDirtyFlags;
|
|
12201
12241
|
var blendShapeFloatStride = this._vertexElementCount * 3;
|
|
12202
12242
|
var blendShapeByteStride = blendShapeFloatStride * 4;
|
|
12243
|
+
var bufferOffset = this._bufferBindingOffset;
|
|
12203
12244
|
// @todo: should fix bug when dataChangedFlag is true
|
|
12204
12245
|
for(var i = 0, n = blendShapes.length; i < n; i++){
|
|
12205
12246
|
var dataChangedFlag = subDataDirtyFlags[i];
|
|
@@ -12217,7 +12258,7 @@ var MeshModifyFlags;
|
|
|
12217
12258
|
var offset = indexInBuffer * blendShapeFloatStride;
|
|
12218
12259
|
var storeInfo = storeInfos[i];
|
|
12219
12260
|
storeInfo || (storeInfos[i] = storeInfo = new miniprogram.Vector2());
|
|
12220
|
-
storeInfo.set(
|
|
12261
|
+
storeInfo.set(bufferOffset + bufferIndex, indexInBuffer * blendShapeByteStride); // BufferOffset is mesh vertexBuffer offset
|
|
12221
12262
|
var deltaPositions = endFrame.deltaPositions;
|
|
12222
12263
|
for(var j = 0; j < vertexCount; j++){
|
|
12223
12264
|
var start = offset + bufferFloatStride * j;
|
|
@@ -13494,6 +13535,7 @@ var VertexChangedFlags;
|
|
|
13494
13535
|
function MeshRenderer(entity) {
|
|
13495
13536
|
var _this;
|
|
13496
13537
|
_this = Renderer.call(this, entity) || this;
|
|
13538
|
+
_this._enableVertexColor = false;
|
|
13497
13539
|
_this._onMeshChanged = _this._onMeshChanged.bind(_assert_this_initialized(_this));
|
|
13498
13540
|
return _this;
|
|
13499
13541
|
}
|
|
@@ -13538,7 +13580,7 @@ var VertexChangedFlags;
|
|
|
13538
13580
|
shaderData.disableMacro(MeshRenderer._uv1Macro);
|
|
13539
13581
|
shaderData.disableMacro(MeshRenderer._normalMacro);
|
|
13540
13582
|
shaderData.disableMacro(MeshRenderer._tangentMacro);
|
|
13541
|
-
shaderData.disableMacro(MeshRenderer.
|
|
13583
|
+
shaderData.disableMacro(MeshRenderer._enableVertexColorMacro);
|
|
13542
13584
|
for(var i = 0, n = vertexElements.length; i < n; i++){
|
|
13543
13585
|
switch(vertexElements[i].semantic){
|
|
13544
13586
|
case "TEXCOORD_0":
|
|
@@ -13554,7 +13596,7 @@ var VertexChangedFlags;
|
|
|
13554
13596
|
shaderData.enableMacro(MeshRenderer._tangentMacro);
|
|
13555
13597
|
break;
|
|
13556
13598
|
case "COLOR_0":
|
|
13557
|
-
shaderData.enableMacro(MeshRenderer.
|
|
13599
|
+
this._enableVertexColor && shaderData.enableMacro(MeshRenderer._enableVertexColorMacro);
|
|
13558
13600
|
break;
|
|
13559
13601
|
}
|
|
13560
13602
|
}
|
|
@@ -13605,6 +13647,20 @@ var VertexChangedFlags;
|
|
|
13605
13647
|
this._setMesh(value);
|
|
13606
13648
|
}
|
|
13607
13649
|
}
|
|
13650
|
+
},
|
|
13651
|
+
{
|
|
13652
|
+
key: "enableVertexColor",
|
|
13653
|
+
get: /**
|
|
13654
|
+
* Whether enable vertex color.
|
|
13655
|
+
*/ function get() {
|
|
13656
|
+
return this._enableVertexColor;
|
|
13657
|
+
},
|
|
13658
|
+
set: function set(value) {
|
|
13659
|
+
if (value !== this._enableVertexColor) {
|
|
13660
|
+
this._dirtyUpdateFlag |= 0x2;
|
|
13661
|
+
this._enableVertexColor = value;
|
|
13662
|
+
}
|
|
13663
|
+
}
|
|
13608
13664
|
}
|
|
13609
13665
|
]);
|
|
13610
13666
|
return MeshRenderer;
|
|
@@ -13622,7 +13678,7 @@ var VertexChangedFlags;
|
|
|
13622
13678
|
MeshRenderer._tangentMacro = ShaderMacro.getByName("RENDERER_HAS_TANGENT");
|
|
13623
13679
|
})();
|
|
13624
13680
|
(function() {
|
|
13625
|
-
MeshRenderer.
|
|
13681
|
+
MeshRenderer._enableVertexColorMacro = ShaderMacro.getByName("RENDERER_ENABLE_VERTEXCOLOR");
|
|
13626
13682
|
})();
|
|
13627
13683
|
__decorate([
|
|
13628
13684
|
ignoreClone
|
|
@@ -15211,7 +15267,7 @@ var Basic2DBatcher = /*#__PURE__*/ function() {
|
|
|
15211
15267
|
// vertices
|
|
15212
15268
|
this._vertexBuffers[index] = new Buffer(engine, exports.BufferBindFlag.VertexBuffer, MAX_VERTEX_COUNT * 4 * vertexStride, exports.BufferUsage.Dynamic);
|
|
15213
15269
|
// indices
|
|
15214
|
-
this._indiceBuffers[index] = new Buffer(engine, exports.BufferBindFlag.IndexBuffer, MAX_VERTEX_COUNT * 3, exports.BufferUsage.Dynamic);
|
|
15270
|
+
this._indiceBuffers[index] = new Buffer(engine, exports.BufferBindFlag.IndexBuffer, MAX_VERTEX_COUNT * 2 * 3, exports.BufferUsage.Dynamic);
|
|
15215
15271
|
mesh.setVertexBufferBinding(this._vertexBuffers[index], vertexStride);
|
|
15216
15272
|
mesh.setIndexBufferBinding(this._indiceBuffers[index], exports.IndexFormat.UInt16);
|
|
15217
15273
|
mesh.setVertexElements(vertexElements);
|
|
@@ -18330,7 +18386,7 @@ var /**
|
|
|
18330
18386
|
CascadedShadowCasterPass._cascadesSplitDistance = new Array(CascadedShadowCasterPass._maxCascades + 1);
|
|
18331
18387
|
})();
|
|
18332
18388
|
(function() {
|
|
18333
|
-
CascadedShadowCasterPass._viewport = new miniprogram.
|
|
18389
|
+
CascadedShadowCasterPass._viewport = new miniprogram.Vector4(0, 0, 1, 1);
|
|
18334
18390
|
})();
|
|
18335
18391
|
(function() {
|
|
18336
18392
|
CascadedShadowCasterPass._clearColor = new miniprogram.Color(1, 1, 1, 1);
|
|
@@ -20398,8 +20454,10 @@ exports.TextVerticalAlignment = void 0;
|
|
|
20398
20454
|
if (name === void 0) name = null;
|
|
20399
20455
|
var _this;
|
|
20400
20456
|
_this = ReferResource.call(this, engine) || this;
|
|
20401
|
-
_this.
|
|
20402
|
-
_this.
|
|
20457
|
+
_this._automaticWidth = 0;
|
|
20458
|
+
_this._automaticHeight = 0;
|
|
20459
|
+
_this._customWidth = undefined;
|
|
20460
|
+
_this._customHeight = undefined;
|
|
20403
20461
|
_this._positions = [
|
|
20404
20462
|
new miniprogram.Vector2(),
|
|
20405
20463
|
new miniprogram.Vector2(),
|
|
@@ -20420,7 +20478,7 @@ exports.TextVerticalAlignment = void 0;
|
|
|
20420
20478
|
_this._region = new miniprogram.Rect(0, 0, 1, 1);
|
|
20421
20479
|
_this._pivot = new miniprogram.Vector2(0.5, 0.5);
|
|
20422
20480
|
_this._border = new miniprogram.Vector4(0, 0, 0, 0);
|
|
20423
|
-
_this._dirtyUpdateFlag =
|
|
20481
|
+
_this._dirtyUpdateFlag = 0x7;
|
|
20424
20482
|
/** @internal */ _this._updateFlagManager = new UpdateFlagManager();
|
|
20425
20483
|
_this._texture = texture;
|
|
20426
20484
|
region && _this._region.copyFrom(region);
|
|
@@ -20468,9 +20526,12 @@ exports.TextVerticalAlignment = void 0;
|
|
|
20468
20526
|
if (this._texture) {
|
|
20469
20527
|
var _this = this, _texture = _this._texture, _atlasRegion = _this._atlasRegion, _atlasRegionOffset = _this._atlasRegionOffset, _region = _this._region;
|
|
20470
20528
|
var pixelsPerUnitReciprocal = 1.0 / Engine._pixelsPerUnit;
|
|
20471
|
-
this.
|
|
20472
|
-
this.
|
|
20529
|
+
this._automaticWidth = _texture.width * _atlasRegion.width / (1 - _atlasRegionOffset.x - _atlasRegionOffset.z) * _region.width * pixelsPerUnitReciprocal;
|
|
20530
|
+
this._automaticHeight = _texture.height * _atlasRegion.height / (1 - _atlasRegionOffset.y - _atlasRegionOffset.w) * _region.height * pixelsPerUnitReciprocal;
|
|
20531
|
+
} else {
|
|
20532
|
+
this._automaticWidth = this._automaticHeight = 0;
|
|
20473
20533
|
}
|
|
20534
|
+
this._dirtyUpdateFlag &= ~0x4;
|
|
20474
20535
|
};
|
|
20475
20536
|
_proto._updatePositions = function _updatePositions() {
|
|
20476
20537
|
var blank = this._atlasRegionOffset;
|
|
@@ -20524,11 +20585,16 @@ exports.TextVerticalAlignment = void 0;
|
|
|
20524
20585
|
};
|
|
20525
20586
|
_proto._dispatchSpriteChange = function _dispatchSpriteChange(type) {
|
|
20526
20587
|
switch(type){
|
|
20588
|
+
case SpriteModifyFlags.texture:
|
|
20589
|
+
this._dirtyUpdateFlag |= 0x4;
|
|
20590
|
+
break;
|
|
20527
20591
|
case SpriteModifyFlags.atlasRegionOffset:
|
|
20528
20592
|
case SpriteModifyFlags.region:
|
|
20529
|
-
this._dirtyUpdateFlag |=
|
|
20593
|
+
this._dirtyUpdateFlag |= 0x7;
|
|
20530
20594
|
break;
|
|
20531
20595
|
case SpriteModifyFlags.atlasRegion:
|
|
20596
|
+
this._dirtyUpdateFlag |= 0x4 | 0x2;
|
|
20597
|
+
break;
|
|
20532
20598
|
case SpriteModifyFlags.border:
|
|
20533
20599
|
this._dirtyUpdateFlag |= 0x2;
|
|
20534
20600
|
break;
|
|
@@ -20547,7 +20613,9 @@ exports.TextVerticalAlignment = void 0;
|
|
|
20547
20613
|
if (this._texture !== value) {
|
|
20548
20614
|
this._texture = value;
|
|
20549
20615
|
this._dispatchSpriteChange(SpriteModifyFlags.texture);
|
|
20550
|
-
(this.
|
|
20616
|
+
if (this._customWidth === undefined || this._customHeight === undefined) {
|
|
20617
|
+
this._dispatchSpriteChange(SpriteModifyFlags.size);
|
|
20618
|
+
}
|
|
20551
20619
|
}
|
|
20552
20620
|
}
|
|
20553
20621
|
},
|
|
@@ -20555,13 +20623,21 @@ exports.TextVerticalAlignment = void 0;
|
|
|
20555
20623
|
key: "width",
|
|
20556
20624
|
get: /**
|
|
20557
20625
|
* The width of the sprite (in world coordinates).
|
|
20626
|
+
*
|
|
20627
|
+
* @remarks
|
|
20628
|
+
* If width is set, return the set value,
|
|
20629
|
+
* otherwise return the width calculated according to `Texture.width`, `Sprite.region`, `Sprite.atlasRegion`, `Sprite.atlasRegionOffset` and `Engine._pixelsPerUnit`.
|
|
20558
20630
|
*/ function get() {
|
|
20559
|
-
this.
|
|
20560
|
-
|
|
20631
|
+
if (this._customWidth !== undefined) {
|
|
20632
|
+
return this._customWidth;
|
|
20633
|
+
} else {
|
|
20634
|
+
this._dirtyUpdateFlag & 0x4 && this._calDefaultSize();
|
|
20635
|
+
return this._automaticWidth;
|
|
20636
|
+
}
|
|
20561
20637
|
},
|
|
20562
20638
|
set: function set(value) {
|
|
20563
|
-
if (this.
|
|
20564
|
-
this.
|
|
20639
|
+
if (this._customWidth !== value) {
|
|
20640
|
+
this._customWidth = value;
|
|
20565
20641
|
this._dispatchSpriteChange(SpriteModifyFlags.size);
|
|
20566
20642
|
}
|
|
20567
20643
|
}
|
|
@@ -20570,13 +20646,21 @@ exports.TextVerticalAlignment = void 0;
|
|
|
20570
20646
|
key: "height",
|
|
20571
20647
|
get: /**
|
|
20572
20648
|
* The height of the sprite (in world coordinates).
|
|
20649
|
+
*
|
|
20650
|
+
* @remarks
|
|
20651
|
+
* If height is set, return the set value,
|
|
20652
|
+
* otherwise return the height calculated according to `Texture.height`, `Sprite.region`, `Sprite.atlasRegion`, `Sprite.atlasRegionOffset` and `Engine._pixelsPerUnit`.
|
|
20573
20653
|
*/ function get() {
|
|
20574
|
-
this.
|
|
20575
|
-
|
|
20654
|
+
if (this._customHeight !== undefined) {
|
|
20655
|
+
return this._customHeight;
|
|
20656
|
+
} else {
|
|
20657
|
+
this._dirtyUpdateFlag & 0x4 && this._calDefaultSize();
|
|
20658
|
+
return this._automaticHeight;
|
|
20659
|
+
}
|
|
20576
20660
|
},
|
|
20577
20661
|
set: function set(value) {
|
|
20578
|
-
if (this.
|
|
20579
|
-
this.
|
|
20662
|
+
if (this._customHeight !== value) {
|
|
20663
|
+
this._customHeight = value;
|
|
20580
20664
|
this._dispatchSpriteChange(SpriteModifyFlags.size);
|
|
20581
20665
|
}
|
|
20582
20666
|
}
|
|
@@ -20606,7 +20690,9 @@ exports.TextVerticalAlignment = void 0;
|
|
|
20606
20690
|
var y = miniprogram.MathUtil.clamp(value.y, 0, 1);
|
|
20607
20691
|
this._atlasRegion.set(x, y, miniprogram.MathUtil.clamp(value.width, 0, 1 - x), miniprogram.MathUtil.clamp(value.height, 0, 1 - y));
|
|
20608
20692
|
this._dispatchSpriteChange(SpriteModifyFlags.atlasRegion);
|
|
20609
|
-
(this.
|
|
20693
|
+
if (this._customWidth === undefined || this._customHeight === undefined) {
|
|
20694
|
+
this._dispatchSpriteChange(SpriteModifyFlags.size);
|
|
20695
|
+
}
|
|
20610
20696
|
}
|
|
20611
20697
|
},
|
|
20612
20698
|
{
|
|
@@ -20621,7 +20707,9 @@ exports.TextVerticalAlignment = void 0;
|
|
|
20621
20707
|
var y = miniprogram.MathUtil.clamp(value.y, 0, 1);
|
|
20622
20708
|
this._atlasRegionOffset.set(x, y, miniprogram.MathUtil.clamp(value.z, 0, 1 - x), miniprogram.MathUtil.clamp(value.w, 0, 1 - y));
|
|
20623
20709
|
this._dispatchSpriteChange(SpriteModifyFlags.atlasRegionOffset);
|
|
20624
|
-
(this.
|
|
20710
|
+
if (this._customWidth === undefined || this._customHeight === undefined) {
|
|
20711
|
+
this._dispatchSpriteChange(SpriteModifyFlags.size);
|
|
20712
|
+
}
|
|
20625
20713
|
}
|
|
20626
20714
|
},
|
|
20627
20715
|
{
|
|
@@ -20637,7 +20725,9 @@ exports.TextVerticalAlignment = void 0;
|
|
|
20637
20725
|
var y = miniprogram.MathUtil.clamp(value.y, 0, 1);
|
|
20638
20726
|
region.set(x, y, miniprogram.MathUtil.clamp(value.width, 0, 1 - x), miniprogram.MathUtil.clamp(value.height, 0, 1 - y));
|
|
20639
20727
|
this._dispatchSpriteChange(SpriteModifyFlags.region);
|
|
20640
|
-
(this.
|
|
20728
|
+
if (this._customWidth === undefined || this._customHeight === undefined) {
|
|
20729
|
+
this._dispatchSpriteChange(SpriteModifyFlags.size);
|
|
20730
|
+
}
|
|
20641
20731
|
}
|
|
20642
20732
|
},
|
|
20643
20733
|
{
|
|
@@ -20687,7 +20777,8 @@ var SpriteUpdateFlags;
|
|
|
20687
20777
|
(function(SpriteUpdateFlags) {
|
|
20688
20778
|
SpriteUpdateFlags[SpriteUpdateFlags["positions"] = 0x1] = "positions";
|
|
20689
20779
|
SpriteUpdateFlags[SpriteUpdateFlags["uvs"] = 0x2] = "uvs";
|
|
20690
|
-
SpriteUpdateFlags[SpriteUpdateFlags["
|
|
20780
|
+
SpriteUpdateFlags[SpriteUpdateFlags["automaticSize"] = 0x4] = "automaticSize";
|
|
20781
|
+
SpriteUpdateFlags[SpriteUpdateFlags["all"] = 0x7] = "all";
|
|
20691
20782
|
})(SpriteUpdateFlags || (SpriteUpdateFlags = {}));
|
|
20692
20783
|
|
|
20693
20784
|
var _SlicedSpriteAssembler;
|
|
@@ -21179,8 +21270,10 @@ var TiledType;
|
|
|
21179
21270
|
_this._tiledAdaptiveThreshold = 0.5;
|
|
21180
21271
|
_this._color = new miniprogram.Color(1, 1, 1, 1);
|
|
21181
21272
|
_this._sprite = null;
|
|
21182
|
-
_this.
|
|
21183
|
-
_this.
|
|
21273
|
+
_this._automaticWidth = 0;
|
|
21274
|
+
_this._automaticHeight = 0;
|
|
21275
|
+
_this._customWidth = undefined;
|
|
21276
|
+
_this._customHeight = undefined;
|
|
21184
21277
|
_this._flipX = false;
|
|
21185
21278
|
_this._flipY = false;
|
|
21186
21279
|
_this._maskLayer = exports.SpriteMaskLayer.Layer0;
|
|
@@ -21197,6 +21290,7 @@ var TiledType;
|
|
|
21197
21290
|
*/ _proto._cloneTo = function _cloneTo(target) {
|
|
21198
21291
|
target._assembler.resetData(target);
|
|
21199
21292
|
target.sprite = this._sprite;
|
|
21293
|
+
target.drawMode = this._drawMode;
|
|
21200
21294
|
};
|
|
21201
21295
|
/**
|
|
21202
21296
|
* @internal
|
|
@@ -21207,12 +21301,11 @@ var TiledType;
|
|
|
21207
21301
|
/**
|
|
21208
21302
|
* @internal
|
|
21209
21303
|
*/ _proto._updateBounds = function _updateBounds(worldBounds) {
|
|
21210
|
-
|
|
21211
|
-
|
|
21304
|
+
if (this.sprite) {
|
|
21305
|
+
this._assembler.updatePositions(this);
|
|
21306
|
+
} else {
|
|
21212
21307
|
worldBounds.min.set(0, 0, 0);
|
|
21213
21308
|
worldBounds.max.set(0, 0, 0);
|
|
21214
|
-
} else {
|
|
21215
|
-
this._assembler.updatePositions(this);
|
|
21216
21309
|
}
|
|
21217
21310
|
};
|
|
21218
21311
|
/**
|
|
@@ -21222,17 +21315,17 @@ var TiledType;
|
|
|
21222
21315
|
if (!((_this_sprite = this.sprite) == null ? void 0 : _this_sprite.texture) || !this.width || !this.height) {
|
|
21223
21316
|
return;
|
|
21224
21317
|
}
|
|
21225
|
-
// Update position
|
|
21318
|
+
// Update position
|
|
21226
21319
|
if (this._dirtyUpdateFlag & RendererUpdateFlags.WorldVolume) {
|
|
21227
21320
|
this._assembler.updatePositions(this);
|
|
21228
21321
|
this._dirtyUpdateFlag &= ~RendererUpdateFlags.WorldVolume;
|
|
21229
21322
|
}
|
|
21230
|
-
// Update uv
|
|
21323
|
+
// Update uv
|
|
21231
21324
|
if (this._dirtyUpdateFlag & 0x2) {
|
|
21232
21325
|
this._assembler.updateUVs(this);
|
|
21233
21326
|
this._dirtyUpdateFlag &= ~0x2;
|
|
21234
21327
|
}
|
|
21235
|
-
// Push
|
|
21328
|
+
// Push primitive
|
|
21236
21329
|
var material = this.getMaterial();
|
|
21237
21330
|
var texture = this.sprite.texture;
|
|
21238
21331
|
var renderData = this._engine._spriteRenderDataPool.getFromPool();
|
|
@@ -21250,6 +21343,16 @@ var TiledType;
|
|
|
21250
21343
|
this._assembler = null;
|
|
21251
21344
|
this._verticesData = null;
|
|
21252
21345
|
};
|
|
21346
|
+
_proto._calDefaultSize = function _calDefaultSize() {
|
|
21347
|
+
var sprite = this._sprite;
|
|
21348
|
+
if (sprite) {
|
|
21349
|
+
this._automaticWidth = sprite.width;
|
|
21350
|
+
this._automaticHeight = sprite.height;
|
|
21351
|
+
} else {
|
|
21352
|
+
this._automaticWidth = this._automaticHeight = 0;
|
|
21353
|
+
}
|
|
21354
|
+
this._dirtyUpdateFlag &= ~0x4;
|
|
21355
|
+
};
|
|
21253
21356
|
_proto._updateStencilState = function _updateStencilState() {
|
|
21254
21357
|
// Update stencil.
|
|
21255
21358
|
var material = this.getInstanceMaterial();
|
|
@@ -21276,22 +21379,21 @@ var TiledType;
|
|
|
21276
21379
|
break;
|
|
21277
21380
|
case SpriteModifyFlags.size:
|
|
21278
21381
|
var _this = this, drawMode = _this._drawMode;
|
|
21279
|
-
|
|
21382
|
+
this._dirtyUpdateFlag |= 0x4;
|
|
21383
|
+
if (this._drawMode === exports.SpriteDrawMode.Sliced) {
|
|
21280
21384
|
this._dirtyUpdateFlag |= RendererUpdateFlags.WorldVolume;
|
|
21281
21385
|
} else if (drawMode === exports.SpriteDrawMode.Tiled) {
|
|
21282
21386
|
this._dirtyUpdateFlag |= 0x3;
|
|
21283
21387
|
} else {
|
|
21284
21388
|
// When the width and height of `SpriteRenderer` are `undefined`,
|
|
21285
21389
|
// the `size` of `Sprite` will affect the position of `SpriteRenderer`.
|
|
21286
|
-
if (this.
|
|
21390
|
+
if (this._customWidth === undefined || this._customHeight === undefined) {
|
|
21287
21391
|
this._dirtyUpdateFlag |= RendererUpdateFlags.WorldVolume;
|
|
21288
21392
|
}
|
|
21289
21393
|
}
|
|
21290
21394
|
break;
|
|
21291
21395
|
case SpriteModifyFlags.border:
|
|
21292
|
-
|
|
21293
|
-
this._dirtyUpdateFlag |= 0x3;
|
|
21294
|
-
}
|
|
21396
|
+
this._drawMode === exports.SpriteDrawMode.Sliced && (this._dirtyUpdateFlag |= 0x3);
|
|
21295
21397
|
break;
|
|
21296
21398
|
case SpriteModifyFlags.region:
|
|
21297
21399
|
case SpriteModifyFlags.atlasRegionOffset:
|
|
@@ -21376,9 +21478,9 @@ var TiledType;
|
|
|
21376
21478
|
var lastSprite = this._sprite;
|
|
21377
21479
|
if (lastSprite !== value) {
|
|
21378
21480
|
lastSprite && lastSprite._updateFlagManager.removeListener(this._onSpriteChange);
|
|
21481
|
+
this._dirtyUpdateFlag |= 0x7;
|
|
21379
21482
|
if (value) {
|
|
21380
21483
|
value._updateFlagManager.addListener(this._onSpriteChange);
|
|
21381
|
-
this._dirtyUpdateFlag |= 0x3;
|
|
21382
21484
|
this.shaderData.setTexture(SpriteRenderer._textureProperty, value.texture);
|
|
21383
21485
|
} else {
|
|
21384
21486
|
this.shaderData.setTexture(SpriteRenderer._textureProperty, null);
|
|
@@ -21403,16 +21505,22 @@ var TiledType;
|
|
|
21403
21505
|
{
|
|
21404
21506
|
key: "width",
|
|
21405
21507
|
get: /**
|
|
21406
|
-
* Render width.
|
|
21508
|
+
* Render width (in world coordinates).
|
|
21509
|
+
*
|
|
21510
|
+
* @remarks
|
|
21511
|
+
* If width is set, return the set value,
|
|
21512
|
+
* otherwise return `SpriteRenderer.sprite.width`.
|
|
21407
21513
|
*/ function get() {
|
|
21408
|
-
|
|
21409
|
-
|
|
21514
|
+
if (this._customWidth !== undefined) {
|
|
21515
|
+
return this._customWidth;
|
|
21516
|
+
} else {
|
|
21517
|
+
this._dirtyUpdateFlag & 0x4 && this._calDefaultSize();
|
|
21518
|
+
return this._automaticWidth;
|
|
21519
|
+
}
|
|
21410
21520
|
},
|
|
21411
21521
|
set: function set(value) {
|
|
21412
|
-
|
|
21413
|
-
|
|
21414
|
-
if (this._width !== value) {
|
|
21415
|
-
this._width = value;
|
|
21522
|
+
if (this._customWidth !== value) {
|
|
21523
|
+
this._customWidth = value;
|
|
21416
21524
|
this._dirtyUpdateFlag |= RendererUpdateFlags.WorldVolume;
|
|
21417
21525
|
}
|
|
21418
21526
|
}
|
|
@@ -21420,16 +21528,22 @@ var TiledType;
|
|
|
21420
21528
|
{
|
|
21421
21529
|
key: "height",
|
|
21422
21530
|
get: /**
|
|
21423
|
-
* Render height.
|
|
21531
|
+
* Render height (in world coordinates).
|
|
21532
|
+
*
|
|
21533
|
+
* @remarks
|
|
21534
|
+
* If height is set, return the set value,
|
|
21535
|
+
* otherwise return `SpriteRenderer.sprite.height`.
|
|
21424
21536
|
*/ function get() {
|
|
21425
|
-
|
|
21426
|
-
|
|
21537
|
+
if (this._customHeight !== undefined) {
|
|
21538
|
+
return this._customHeight;
|
|
21539
|
+
} else {
|
|
21540
|
+
this._dirtyUpdateFlag & 0x4 && this._calDefaultSize();
|
|
21541
|
+
return this._automaticHeight;
|
|
21542
|
+
}
|
|
21427
21543
|
},
|
|
21428
21544
|
set: function set(value) {
|
|
21429
|
-
|
|
21430
|
-
|
|
21431
|
-
if (this._height !== value) {
|
|
21432
|
-
this._height = value;
|
|
21545
|
+
if (this._customHeight !== value) {
|
|
21546
|
+
this._customHeight = value;
|
|
21433
21547
|
this._dirtyUpdateFlag |= RendererUpdateFlags.WorldVolume;
|
|
21434
21548
|
}
|
|
21435
21549
|
}
|
|
@@ -21516,10 +21630,16 @@ __decorate([
|
|
|
21516
21630
|
], SpriteRenderer.prototype, "_sprite", void 0);
|
|
21517
21631
|
__decorate([
|
|
21518
21632
|
ignoreClone
|
|
21519
|
-
], SpriteRenderer.prototype, "
|
|
21633
|
+
], SpriteRenderer.prototype, "_automaticWidth", void 0);
|
|
21520
21634
|
__decorate([
|
|
21521
21635
|
ignoreClone
|
|
21522
|
-
], SpriteRenderer.prototype, "
|
|
21636
|
+
], SpriteRenderer.prototype, "_automaticHeight", void 0);
|
|
21637
|
+
__decorate([
|
|
21638
|
+
assignmentClone
|
|
21639
|
+
], SpriteRenderer.prototype, "_customWidth", void 0);
|
|
21640
|
+
__decorate([
|
|
21641
|
+
assignmentClone
|
|
21642
|
+
], SpriteRenderer.prototype, "_customHeight", void 0);
|
|
21523
21643
|
__decorate([
|
|
21524
21644
|
assignmentClone
|
|
21525
21645
|
], SpriteRenderer.prototype, "_flipX", void 0);
|
|
@@ -21540,7 +21660,9 @@ var /**
|
|
|
21540
21660
|
*/ SpriteRendererUpdateFlags;
|
|
21541
21661
|
(function(SpriteRendererUpdateFlags) {
|
|
21542
21662
|
SpriteRendererUpdateFlags[SpriteRendererUpdateFlags[/** UV. */ "UV"] = 0x2] = "UV";
|
|
21543
|
-
SpriteRendererUpdateFlags[SpriteRendererUpdateFlags[/**
|
|
21663
|
+
SpriteRendererUpdateFlags[SpriteRendererUpdateFlags[/** WorldVolume and UV . */ "RenderData"] = 0x3] = "RenderData";
|
|
21664
|
+
SpriteRendererUpdateFlags[SpriteRendererUpdateFlags[/** Automatic Size. */ "AutomaticSize"] = 0x4] = "AutomaticSize";
|
|
21665
|
+
SpriteRendererUpdateFlags[SpriteRendererUpdateFlags[/** All. */ "All"] = 0x7] = "All";
|
|
21544
21666
|
})(SpriteRendererUpdateFlags || (SpriteRendererUpdateFlags = {}));
|
|
21545
21667
|
|
|
21546
21668
|
/**
|