@galacean/engine 1.2.0-alpha.1 → 1.2.0-alpha.11
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/browser.js +1058 -698
- package/dist/browser.min.js +1 -1
- package/dist/main.js +1 -1
- package/dist/main.js.map +1 -1
- package/dist/miniprogram.js +1 -1
- package/dist/module.js +1 -1
- package/dist/module.js.map +1 -1
- package/package.json +5 -5
- package/dist/.DS_Store +0 -0
package/dist/browser.js
CHANGED
|
@@ -5571,7 +5571,14 @@
|
|
|
5571
5571
|
* @param url - The url to be judged.
|
|
5572
5572
|
* @returns Whether the url is absolute url.
|
|
5573
5573
|
*/ Utils.isAbsoluteUrl = function isAbsoluteUrl(url) {
|
|
5574
|
-
return /^(
|
|
5574
|
+
return /^([a-z][a-z\d\+\-\.]*:)?\/\//i.test(url);
|
|
5575
|
+
};
|
|
5576
|
+
/**
|
|
5577
|
+
* Judge whether the url is base64 url.
|
|
5578
|
+
* @param url - The url to be judged.
|
|
5579
|
+
* @returns Whether the url is base64 url.
|
|
5580
|
+
*/ Utils.isBase64Url = function isBase64Url(url) {
|
|
5581
|
+
return /^data:.*,.*$/i.test(url);
|
|
5575
5582
|
};
|
|
5576
5583
|
/**
|
|
5577
5584
|
* Get the values of an object.
|
|
@@ -5589,7 +5596,10 @@
|
|
|
5589
5596
|
if (Utils.isAbsoluteUrl(relativeUrl)) {
|
|
5590
5597
|
return relativeUrl;
|
|
5591
5598
|
}
|
|
5592
|
-
|
|
5599
|
+
if (Utils.isBase64Url(relativeUrl)) {
|
|
5600
|
+
return relativeUrl;
|
|
5601
|
+
}
|
|
5602
|
+
return relativeUrl ? baseUrl.replace(/\/+$/, "") + "/" + relativeUrl.replace(/^\/+/, "") : baseUrl;
|
|
5593
5603
|
};
|
|
5594
5604
|
/**
|
|
5595
5605
|
* @internal
|
|
@@ -8113,7 +8123,7 @@
|
|
|
8113
8123
|
};
|
|
8114
8124
|
return _extends$2.apply(this, arguments);
|
|
8115
8125
|
}
|
|
8116
|
-
var camera_declare = "#define GLSLIFY 1\nuniform vec3 camera_Position;"; // eslint-disable-line
|
|
8126
|
+
var camera_declare = "#define GLSLIFY 1\nuniform vec3 camera_Position;uniform vec3 camera_Forward;"; // eslint-disable-line
|
|
8117
8127
|
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);}uniform vec4 camera_DepthBufferParams;float remapDepthBufferLinear01(float z){return 1.0/(camera_DepthBufferParams.x*z+camera_DepthBufferParams.y);}\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
|
|
8118
8128
|
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
|
|
8119
8129
|
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
|
|
@@ -8138,7 +8148,7 @@
|
|
|
8138
8148
|
var light_frag_define = "#define GLSLIFY 1\n#ifdef SCENE_DIRECT_LIGHT_COUNT\nstruct DirectLight{vec3 color;vec3 direction;};uniform ivec2 scene_DirectLightCullingMask[SCENE_DIRECT_LIGHT_COUNT];uniform vec3 scene_DirectLightColor[SCENE_DIRECT_LIGHT_COUNT];uniform vec3 scene_DirectLightDirection[SCENE_DIRECT_LIGHT_COUNT];\n#endif\n#ifdef SCENE_POINT_LIGHT_COUNT\nstruct PointLight{vec3 color;vec3 position;float distance;};uniform ivec2 scene_PointLightCullingMask[SCENE_POINT_LIGHT_COUNT];uniform vec3 scene_PointLightColor[SCENE_POINT_LIGHT_COUNT];uniform vec3 scene_PointLightPosition[SCENE_POINT_LIGHT_COUNT];uniform float scene_PointLightDistance[SCENE_POINT_LIGHT_COUNT];\n#endif\n#ifdef SCENE_SPOT_LIGHT_COUNT\nstruct SpotLight{vec3 color;vec3 position;vec3 direction;float distance;float angleCos;float penumbraCos;};uniform ivec2 scene_SpotLightCullingMask[SCENE_SPOT_LIGHT_COUNT];uniform vec3 scene_SpotLightColor[SCENE_SPOT_LIGHT_COUNT];uniform vec3 scene_SpotLightPosition[SCENE_SPOT_LIGHT_COUNT];uniform vec3 scene_SpotLightDirection[SCENE_SPOT_LIGHT_COUNT];uniform float scene_SpotLightDistance[SCENE_SPOT_LIGHT_COUNT];uniform float scene_SpotLightAngleCos[SCENE_SPOT_LIGHT_COUNT];uniform float scene_SpotLightPenumbraCos[SCENE_SPOT_LIGHT_COUNT];\n#endif\nstruct EnvMapLight{vec3 diffuse;float mipMapLevel;float diffuseIntensity;float specularIntensity;};uniform EnvMapLight scene_EnvMapLight;uniform ivec4 renderer_Layer;\n#ifdef SCENE_USE_SH\nuniform vec3 scene_EnvSH[9];\n#endif\n#ifdef SCENE_USE_SPECULAR_ENV\nuniform samplerCube scene_EnvSpecularSampler;\n#endif\n#ifndef GRAPHICS_API_WEBGL2\nbool isBitSet(float value,float mask,float bitIndex){return mod(floor(value/pow(2.0,bitIndex)),2.0)==1.0&&mod(floor(mask/pow(2.0,bitIndex)),2.0)==1.0;}\n#endif\nbool isRendererCulledByLight(ivec2 rendererLayer,ivec2 lightCullingMask){\n#ifdef GRAPHICS_API_WEBGL2\nreturn!((rendererLayer.x&lightCullingMask.x)!=0||(rendererLayer.y&lightCullingMask.y)!=0);\n#else\nfor(int i=0;i<16;i++){if(isBitSet(float(rendererLayer.x),float(lightCullingMask.x),float(i))||isBitSet(float(rendererLayer.y),float(lightCullingMask.y),float(i))){return false;}}return true;\n#endif\n}"; // eslint-disable-line
|
|
8139
8149
|
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
|
|
8140
8150
|
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
|
|
8141
|
-
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
|
|
8151
|
+
var begin_viewdir_frag = "#define GLSLIFY 1\n#ifdef CAMERA_ORTHOGRAPHIC\nvec3 V=-camera_Forward;\n#else\n#ifdef MATERIAL_NEED_WORLD_POS\nvec3 V=normalize(camera_Position-v_pos);\n#endif\n#endif\n"; // eslint-disable-line
|
|
8142
8152
|
var mobile_blinnphong_frag = "#define GLSLIFY 1\n#ifdef MATERIAL_HAS_NORMALTEXTURE\nmat3 tbn=getTBN(gl_FrontFacing);vec3 N=getNormalByNormalTexture(tbn,material_NormalTexture,material_NormalIntensity,v_uv,gl_FrontFacing);\n#else\nvec3 N=getNormal(gl_FrontFacing);\n#endif\nvec3 lightDiffuse=vec3(0.0,0.0,0.0);vec3 lightSpecular=vec3(0.0,0.0,0.0);float shadowAttenuation=1.0;\n#ifdef SCENE_DIRECT_LIGHT_COUNT\nshadowAttenuation=1.0;\n#ifdef SCENE_IS_CALCULATE_SHADOWS\nshadowAttenuation*=sampleShadowMap();\n#endif\nDirectLight directionalLight;for(int i=0;i<SCENE_DIRECT_LIGHT_COUNT;i++){if(!isRendererCulledByLight(renderer_Layer.xy,scene_DirectLightCullingMask[i])){directionalLight.color=scene_DirectLightColor[i];\n#ifdef SCENE_IS_CALCULATE_SHADOWS\nif(i==0){directionalLight.color*=shadowAttenuation;}\n#endif\ndirectionalLight.direction=scene_DirectLightDirection[i];float d=max(dot(N,-directionalLight.direction),0.0);lightDiffuse+=directionalLight.color*d;vec3 halfDir=normalize(V-directionalLight.direction);float s=pow(clamp(dot(N,halfDir),0.0,1.0),material_Shininess);lightSpecular+=directionalLight.color*s;}}\n#endif\n#ifdef SCENE_POINT_LIGHT_COUNT\nPointLight pointLight;for(int i=0;i<SCENE_POINT_LIGHT_COUNT;i++){if(!isRendererCulledByLight(renderer_Layer.xy,scene_PointLightCullingMask[i])){pointLight.color=scene_PointLightColor[i];pointLight.position=scene_PointLightPosition[i];pointLight.distance=scene_PointLightDistance[i];vec3 direction=v_pos-pointLight.position;float dist=length(direction);direction/=dist;float decay=clamp(1.0-pow(dist/pointLight.distance,4.0),0.0,1.0);float d=max(dot(N,-direction),0.0)*decay;lightDiffuse+=pointLight.color*d;vec3 halfDir=normalize(V-direction);float s=pow(clamp(dot(N,halfDir),0.0,1.0),material_Shininess)*decay;lightSpecular+=pointLight.color*s;}}\n#endif\n#ifdef SCENE_SPOT_LIGHT_COUNT\nSpotLight spotLight;for(int i=0;i<SCENE_SPOT_LIGHT_COUNT;i++){if(!isRendererCulledByLight(renderer_Layer.xy,scene_SpotLightCullingMask[i])){spotLight.color=scene_SpotLightColor[i];spotLight.position=scene_SpotLightPosition[i];spotLight.direction=scene_SpotLightDirection[i];spotLight.distance=scene_SpotLightDistance[i];spotLight.angleCos=scene_SpotLightAngleCos[i];spotLight.penumbraCos=scene_SpotLightPenumbraCos[i];vec3 direction=spotLight.position-v_pos;float lightDistance=length(direction);direction/=lightDistance;float angleCos=dot(direction,-spotLight.direction);float decay=clamp(1.0-pow(lightDistance/spotLight.distance,4.0),0.0,1.0);float spotEffect=smoothstep(spotLight.penumbraCos,spotLight.angleCos,angleCos);float decayTotal=decay*spotEffect;float d=max(dot(N,direction),0.0)*decayTotal;lightDiffuse+=spotLight.color*d;vec3 halfDir=normalize(V+direction);float s=pow(clamp(dot(N,halfDir),0.0,1.0),material_Shininess)*decayTotal;lightSpecular+=spotLight.color*s;}}\n#endif\ndiffuse*=vec4(lightDiffuse,1.0);specular*=vec4(lightSpecular,1.0);\n#ifdef MATERIAL_IS_ALPHA_CUTOFF\nif(diffuse.a<material_AlphaCutoff){discard;}\n#endif\n"; // eslint-disable-line
|
|
8143
8153
|
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
|
|
8144
8154
|
var noise_cellular_2D = "#define GLSLIFY 1\nvec2 cellular(vec2 P){vec2 Pi=mod289(floor(P));vec2 Pf=fract(P);vec3 oi=vec3(-1.0,0.0,1.0);vec3 of=vec3(-0.5,0.5,1.5);vec3 px=permute(Pi.x+oi);vec3 p=permute(px.x+Pi.y+oi);vec3 ox=fract(p*K)-Ko;vec3 oy=mod7(floor(p*K))*K-Ko;vec3 dx=Pf.x+0.5+jitter*ox;vec3 dy=Pf.y-of+jitter*oy;vec3 d1=dx*dx+dy*dy;p=permute(px.y+Pi.y+oi);ox=fract(p*K)-Ko;oy=mod7(floor(p*K))*K-Ko;dx=Pf.x-0.5+jitter*ox;dy=Pf.y-of+jitter*oy;vec3 d2=dx*dx+dy*dy;p=permute(px.z+Pi.y+oi);ox=fract(p*K)-Ko;oy=mod7(floor(p*K))*K-Ko;dx=Pf.x-1.5+jitter*ox;dy=Pf.y-of+jitter*oy;vec3 d3=dx*dx+dy*dy;vec3 d1a=min(d1,d2);d2=max(d1,d2);d2=min(d2,d3);d1=min(d1a,d2);d2=max(d1a,d2);d1.xy=(d1.x<d1.y)? d1.xy : d1.yx;d1.xz=(d1.x<d1.z)? d1.xz : d1.zx;d1.yz=min(d1.yz,d2.yz);d1.y=min(d1.y,d1.z);d1.y=min(d1.y,d2.x);return sqrt(d1.xy);}"; // eslint-disable-line
|
|
@@ -8157,7 +8167,7 @@
|
|
|
8157
8167
|
var noise_simplex_3D_grad = "#define GLSLIFY 1\nfloat simplex(vec3 v,out vec3 gradient){const vec2 C=vec2(1.0/6.0,1.0/3.0);const vec4 D=vec4(0.0,0.5,1.0,2.0);vec3 i=floor(v+dot(v,C.yyy));vec3 x0=v-i+dot(i,C.xxx);vec3 g=step(x0.yzx,x0.xyz);vec3 l=1.0-g;vec3 i1=min(g.xyz,l.zxy);vec3 i2=max(g.xyz,l.zxy);vec3 x1=x0-i1+C.xxx;vec3 x2=x0-i2+C.yyy;vec3 x3=x0-D.yyy;i=mod289(i);vec4 p=permute(permute(permute(i.z+vec4(0.0,i1.z,i2.z,1.0))+i.y+vec4(0.0,i1.y,i2.y,1.0))+i.x+vec4(0.0,i1.x,i2.x,1.0));float n_=0.142857142857;vec3 ns=n_*D.wyz-D.xzx;vec4 j=p-49.0*floor(p*ns.z*ns.z);vec4 x_=floor(j*ns.z);vec4 y_=floor(j-7.0*x_);vec4 x=x_*ns.x+ns.yyyy;vec4 y=y_*ns.x+ns.yyyy;vec4 h=1.0-abs(x)-abs(y);vec4 b0=vec4(x.xy,y.xy);vec4 b1=vec4(x.zw,y.zw);vec4 s0=floor(b0)*2.0+1.0;vec4 s1=floor(b1)*2.0+1.0;vec4 sh=-step(h,vec4(0.0));vec4 a0=b0.xzyw+s0.xzyw*sh.xxyy;vec4 a1=b1.xzyw+s1.xzyw*sh.zzww;vec3 p0=vec3(a0.xy,h.x);vec3 p1=vec3(a0.zw,h.y);vec3 p2=vec3(a1.xy,h.z);vec3 p3=vec3(a1.zw,h.w);vec4 norm=taylorInvSqrt(vec4(dot(p0,p0),dot(p1,p1),dot(p2,p2),dot(p3,p3)));p0*=norm.x;p1*=norm.y;p2*=norm.z;p3*=norm.w;vec4 m=max(0.6-vec4(dot(x0,x0),dot(x1,x1),dot(x2,x2),dot(x3,x3)),0.0);vec4 m2=m*m;vec4 m4=m2*m2;vec4 pdotx=vec4(dot(p0,x0),dot(p1,x1),dot(p2,x2),dot(p3,x3));vec4 temp=m2*m*pdotx;gradient=-8.0*(temp.x*x0+temp.y*x1+temp.z*x2+temp.w*x3);gradient+=m4.x*p0+m4.y*p1+m4.z*p2+m4.w*p3;gradient*=42.0;return 42.0*dot(m4,pdotx);}"; // eslint-disable-line
|
|
8158
8168
|
var noise_simplex_4D = "#define GLSLIFY 1\nvec4 grad4(float j,vec4 ip){const vec4 ones=vec4(1.0,1.0,1.0,-1.0);vec4 p,s;p.xyz=floor(fract(vec3(j)*ip.xyz)*7.0)*ip.z-1.0;p.w=1.5-dot(abs(p.xyz),ones.xyz);s=vec4(lessThan(p,vec4(0.0)));p.xyz=p.xyz+(s.xyz*2.0-1.0)*s.www;return p;}\n#define F4 0.309016994374947451\nfloat simplex(vec4 v){const vec4 C=vec4(0.138196601125011,0.276393202250021,0.414589803375032,-0.447213595499958);vec4 i=floor(v+dot(v,vec4(F4)));vec4 x0=v-i+dot(i,C.xxxx);vec4 i0;vec3 isX=step(x0.yzw,x0.xxx);vec3 isYZ=step(x0.zww,x0.yyz);i0.x=isX.x+isX.y+isX.z;i0.yzw=1.0-isX;i0.y+=isYZ.x+isYZ.y;i0.zw+=1.0-isYZ.xy;i0.z+=isYZ.z;i0.w+=1.0-isYZ.z;vec4 i3=clamp(i0,0.0,1.0);vec4 i2=clamp(i0-1.0,0.0,1.0);vec4 i1=clamp(i0-2.0,0.0,1.0);vec4 x1=x0-i1+C.xxxx;vec4 x2=x0-i2+C.yyyy;vec4 x3=x0-i3+C.zzzz;vec4 x4=x0+C.wwww;i=mod289(i);float j0=permute(permute(permute(permute(i.w)+i.z)+i.y)+i.x);vec4 j1=permute(permute(permute(permute(i.w+vec4(i1.w,i2.w,i3.w,1.0))+i.z+vec4(i1.z,i2.z,i3.z,1.0))+i.y+vec4(i1.y,i2.y,i3.y,1.0))+i.x+vec4(i1.x,i2.x,i3.x,1.0));vec4 ip=vec4(1.0/294.0,1.0/49.0,1.0/7.0,0.0);vec4 p0=grad4(j0,ip);vec4 p1=grad4(j1.x,ip);vec4 p2=grad4(j1.y,ip);vec4 p3=grad4(j1.z,ip);vec4 p4=grad4(j1.w,ip);vec4 norm=taylorInvSqrt(vec4(dot(p0,p0),dot(p1,p1),dot(p2,p2),dot(p3,p3)));p0*=norm.x;p1*=norm.y;p2*=norm.z;p3*=norm.w;p4*=taylorInvSqrt(dot(p4,p4));vec3 m0=max(0.6-vec3(dot(x0,x0),dot(x1,x1),dot(x2,x2)),0.0);vec2 m1=max(0.6-vec2(dot(x3,x3),dot(x4,x4)),0.0);m0=m0*m0;m1=m1*m1;return 49.0*(dot(m0*m0,vec3(dot(p0,x0),dot(p1,x1),dot(p2,x2)))+dot(m1*m1,vec2(dot(p3,x3),dot(p4,x4))));}"; // eslint-disable-line
|
|
8159
8169
|
var pbr_frag_define = "#define GLSLIFY 1\n#define MIN_PERCEPTUAL_ROUGHNESS 0.045\n#define MIN_ROUGHNESS 0.002025\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;uniform float material_NormalIntensity;uniform float material_OcclusionIntensity;uniform float material_OcclusionTextureCoord;\n#ifdef MATERIAL_ENABLE_CLEAR_COAT\nuniform float material_ClearCoat;uniform float material_ClearCoatRoughness;\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\n#endif\n#ifdef MATERIAL_ENABLE_ANISOTROPY\nuniform vec3 material_AnisotropyInfo;\n#ifdef MATERIAL_HAS_ANISOTROPY_TEXTURE\nuniform sampler2D material_AnisotropyTexture;\n#endif\n#endif\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\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#ifdef MATERIAL_ENABLE_ANISOTROPY\nvec3 anisotropicT;vec3 anisotropicB;vec3 anisotropicN;float anisotropy;\n#endif\n};struct Material{vec3 diffuseColor;float roughness;vec3 specularColor;float opacity;float f0;\n#ifdef MATERIAL_ENABLE_CLEAR_COAT\nfloat clearCoat;float clearCoatRoughness;\n#endif\n};"; // eslint-disable-line
|
|
8160
|
-
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 MIN_PERCEPTUAL_ROUGHNESS+max(max(dxy.x,dxy.y),dxy.z);\n#else\nreturn MIN_PERCEPTUAL_ROUGHNESS;\n#endif\n}\n#ifdef MATERIAL_ENABLE_ANISOTROPY\nvec3 getAnisotropicBentNormal(Geometry geometry,vec3 n,float roughness){vec3 anisotropyDirection=geometry.anisotropy>=0.0 ? geometry.anisotropicB : geometry.anisotropicT;vec3 anisotropicTangent=cross(anisotropyDirection,geometry.viewDir);vec3 anisotropicNormal=cross(anisotropicTangent,anisotropyDirection);vec3 bentNormal=normalize(mix(n,anisotropicNormal,abs(geometry.anisotropy)*saturate(5.0*roughness)));return bentNormal;}\n#endif\nvoid initGeometry(out Geometry geometry,bool isFrontFacing){geometry.position=v_pos
|
|
8170
|
+
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 MIN_PERCEPTUAL_ROUGHNESS+max(max(dxy.x,dxy.y),dxy.z);\n#else\nreturn MIN_PERCEPTUAL_ROUGHNESS;\n#endif\n}\n#ifdef MATERIAL_ENABLE_ANISOTROPY\nvec3 getAnisotropicBentNormal(Geometry geometry,vec3 n,float roughness){vec3 anisotropyDirection=geometry.anisotropy>=0.0 ? geometry.anisotropicB : geometry.anisotropicT;vec3 anisotropicTangent=cross(anisotropyDirection,geometry.viewDir);vec3 anisotropicNormal=cross(anisotropicTangent,anisotropyDirection);vec3 bentNormal=normalize(mix(n,anisotropicNormal,abs(geometry.anisotropy)*saturate(5.0*roughness)));return bentNormal;}\n#endif\nvoid initGeometry(out Geometry geometry,bool isFrontFacing){geometry.position=v_pos;\n#ifdef CAMERA_ORTHOGRAPHIC\ngeometry.viewDir=-camera_Forward;\n#else\ngeometry.viewDir=normalize(camera_Position-v_pos);\n#endif\n#if defined(MATERIAL_HAS_NORMALTEXTURE) || defined(MATERIAL_HAS_CLEAR_COAT_NORMAL_TEXTURE) || defined(MATERIAL_ENABLE_ANISOTROPY)\nmat3 tbn=getTBN(isFrontFacing);\n#endif\n#ifdef MATERIAL_HAS_NORMALTEXTURE\ngeometry.normal=getNormalByNormalTexture(tbn,material_NormalTexture,material_NormalIntensity,v_uv,isFrontFacing);\n#else\ngeometry.normal=getNormal(isFrontFacing);\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,isFrontFacing);\n#else\ngeometry.clearCoatNormal=getNormal(isFrontFacing);\n#endif\ngeometry.clearCoatDotNV=saturate(dot(geometry.clearCoatNormal,geometry.viewDir));\n#endif\n#ifdef MATERIAL_ENABLE_ANISOTROPY\nfloat anisotropy=material_AnisotropyInfo.z;vec3 anisotropicDirection=vec3(material_AnisotropyInfo.xy,0.0);\n#ifdef MATERIAL_HAS_ANISOTROPY_TEXTURE\nvec3 anisotropyTextureInfo=texture2D(material_AnisotropyTexture,v_uv).rgb;anisotropy*=anisotropyTextureInfo.b;anisotropicDirection.xy*=anisotropyTextureInfo.rg*2.0-1.0;\n#endif\ngeometry.anisotropy=anisotropy;geometry.anisotropicT=normalize(tbn*anisotropicDirection);geometry.anisotropicB=normalize(cross(geometry.normal,geometry.anisotropicT));\n#endif\n}void initMaterial(out Material material,inout 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));material.f0=f0;\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#ifdef MATERIAL_ENABLE_ANISOTROPY\ngeometry.anisotropicN=getAnisotropicBentNormal(geometry,geometry.normal,material.roughness);\n#endif\n}\n#include <brdf>\n#include <direct_irradiance_frag_define>\n#include <ibl_frag_define>\n"; // eslint-disable-line
|
|
8161
8171
|
var brdf = "#define GLSLIFY 1\nfloat F_Schlick(float f0,float dotLH){return f0+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);}\n#ifdef MATERIAL_ENABLE_ANISOTROPY\nfloat G_GGX_SmithCorrelated_Anisotropic(float at,float ab,float ToV,float BoV,float ToL,float BoL,float NoV,float NoL){float lambdaV=NoL*length(vec3(at*ToV,ab*BoV,NoV));float lambdaL=NoV*length(vec3(at*ToL,ab*BoL,NoL));return 0.5/max(lambdaV+lambdaL,EPSILON);}\n#endif\nfloat 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);}\n#ifdef MATERIAL_ENABLE_ANISOTROPY\nfloat D_GGX_Anisotropic(float at,float ab,float ToH,float BoH,float NoH){float a2=at*ab;highp vec3 d=vec3(ab*ToH,at*BoH,a2*NoH);highp float d2=dot(d,d);float b2=a2/d2;return a2*b2*b2*RECIPROCAL_PI;}\n#endif\nvec3 isotropicLobe(vec3 specularColor,float alpha,float dotNV,float dotNL,float dotNH,float dotLH){vec3 F=F_Schlick(specularColor,dotLH);float D=D_GGX(alpha,dotNH);float G=G_GGX_SmithCorrelated(alpha,dotNL,dotNV);return F*(G*D);}\n#ifdef MATERIAL_ENABLE_ANISOTROPY\nvec3 anisotropicLobe(vec3 h,vec3 l,Geometry geometry,vec3 specularColor,float alpha,float dotNV,float dotNL,float dotNH,float dotLH){vec3 t=geometry.anisotropicT;vec3 b=geometry.anisotropicB;vec3 v=geometry.viewDir;float dotTV=dot(t,v);float dotBV=dot(b,v);float dotTL=dot(t,l);float dotBL=dot(b,l);float dotTH=dot(t,h);float dotBH=dot(b,h);float at=max(alpha*(1.0+geometry.anisotropy),MIN_ROUGHNESS);float ab=max(alpha*(1.0-geometry.anisotropy),MIN_ROUGHNESS);vec3 F=F_Schlick(specularColor,dotLH);float D=D_GGX_Anisotropic(at,ab,dotTH,dotBH,dotNH);float G=G_GGX_SmithCorrelated_Anisotropic(at,ab,dotTV,dotBV,dotTL,dotBL,dotNV,dotNL);return F*(G*D);}\n#endif\nvec3 BRDF_Specular_GGX(vec3 incidentDirection,Geometry geometry,vec3 normal,vec3 specularColor,float roughness){float alpha=pow2(roughness);vec3 halfDir=normalize(incidentDirection+geometry.viewDir);float dotNL=saturate(dot(normal,incidentDirection));float dotNV=saturate(dot(normal,geometry.viewDir));float dotNH=saturate(dot(normal,halfDir));float dotLH=saturate(dot(incidentDirection,halfDir));\n#ifdef MATERIAL_ENABLE_ANISOTROPY\nreturn anisotropicLobe(halfDir,incidentDirection,geometry,specularColor,alpha,dotNV,dotNL,dotNH,dotLH);\n#else\nreturn isotropicLobe(specularColor,alpha,dotNV,dotNL,dotNH,dotLH);\n#endif\n}vec3 BRDF_Diffuse_Lambert(vec3 diffuseColor){return RECIPROCAL_PI*diffuseColor;}"; // eslint-disable-line
|
|
8162
8172
|
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,geometry.clearCoatNormal,vec3(0.04),material.clearCoatRoughness);attenuation-=material.clearCoat*F_Schlick(material.f0,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,geometry.normal,material.specularColor,material.roughness);reflectedLight.directDiffuse+=attenuation*irradiance*BRDF_Diffuse_Lambert(material.diffuseColor);}\n#ifdef SCENE_DIRECT_LIGHT_COUNT\nvoid addDirectionalDirectLightRadiance(DirectLight directionalLight,Geometry geometry,Material material,inout ReflectedLight reflectedLight){vec3 color=directionalLight.color;vec3 direction=-directionalLight.direction;addDirectRadiance(direction,color,geometry,material,reflectedLight);}\n#endif\n#ifdef SCENE_POINT_LIGHT_COUNT\nvoid addPointDirectLightRadiance(PointLight pointLight,Geometry geometry,Material material,inout ReflectedLight reflectedLight){vec3 lVector=pointLight.position-geometry.position;vec3 direction=normalize(lVector);float lightDistance=length(lVector);vec3 color=pointLight.color;color*=clamp(1.0-pow(lightDistance/pointLight.distance,4.0),0.0,1.0);addDirectRadiance(direction,color,geometry,material,reflectedLight);}\n#endif\n#ifdef SCENE_SPOT_LIGHT_COUNT\nvoid addSpotDirectLightRadiance(SpotLight spotLight,Geometry geometry,Material material,inout ReflectedLight reflectedLight){vec3 lVector=spotLight.position-geometry.position;vec3 direction=normalize(lVector);float lightDistance=length(lVector);float angleCos=dot(direction,-spotLight.direction);float spotEffect=smoothstep(spotLight.penumbraCos,spotLight.angleCos,angleCos);float decayEffect=clamp(1.0-pow(lightDistance/spotLight.distance,4.0),0.0,1.0);vec3 color=spotLight.color;color*=spotEffect*decayEffect;addDirectRadiance(direction,color,geometry,material,reflectedLight);}\n#endif\nvoid addTotalDirectRadiance(Geometry geometry,Material material,inout ReflectedLight reflectedLight){float shadowAttenuation=1.0;\n#ifdef SCENE_DIRECT_LIGHT_COUNT\nshadowAttenuation=1.0;\n#ifdef SCENE_IS_CALCULATE_SHADOWS\nshadowAttenuation*=sampleShadowMap();\n#endif\nDirectLight directionalLight;for(int i=0;i<SCENE_DIRECT_LIGHT_COUNT;i++){if(!isRendererCulledByLight(renderer_Layer.xy,scene_DirectLightCullingMask[i])){directionalLight.color=scene_DirectLightColor[i];\n#ifdef SCENE_IS_CALCULATE_SHADOWS\nif(i==0){directionalLight.color*=shadowAttenuation;}\n#endif\ndirectionalLight.direction=scene_DirectLightDirection[i];addDirectionalDirectLightRadiance(directionalLight,geometry,material,reflectedLight);}}\n#endif\n#ifdef SCENE_POINT_LIGHT_COUNT\nPointLight pointLight;for(int i=0;i<SCENE_POINT_LIGHT_COUNT;i++){if(!isRendererCulledByLight(renderer_Layer.xy,scene_PointLightCullingMask[i])){pointLight.color=scene_PointLightColor[i];pointLight.position=scene_PointLightPosition[i];pointLight.distance=scene_PointLightDistance[i];addPointDirectLightRadiance(pointLight,geometry,material,reflectedLight);}}\n#endif\n#ifdef SCENE_SPOT_LIGHT_COUNT\nSpotLight spotLight;for(int i=0;i<SCENE_SPOT_LIGHT_COUNT;i++){if(!isRendererCulledByLight(renderer_Layer.xy,scene_SpotLightCullingMask[i])){spotLight.color=scene_SpotLightColor[i];spotLight.position=scene_SpotLightPosition[i];spotLight.direction=scene_SpotLightDirection[i];spotLight.distance=scene_SpotLightDistance[i];spotLight.angleCos=scene_SpotLightAngleCos[i];spotLight.penumbraCos=scene_SpotLightPenumbraCos[i];addSpotDirectLightRadiance(spotLight,geometry,material,reflectedLight);}}\n#endif\n}"; // eslint-disable-line
|
|
8163
8173
|
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 getReflectedVector(Geometry geometry,vec3 n){\n#ifdef MATERIAL_ENABLE_ANISOTROPY\nvec3 r=reflect(-geometry.viewDir,geometry.anisotropicN);\n#else\nvec3 r=reflect(-geometry.viewDir,n);\n#endif\nreturn r;}vec3 getLightProbeRadiance(Geometry geometry,vec3 normal,float roughness,int maxMIPLevel,float specularIntensity){\n#ifndef SCENE_USE_SPECULAR_ENV\nreturn vec3(0);\n#else\nvec3 reflectVec=getReflectedVector(geometry,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
|
|
@@ -8171,7 +8181,7 @@
|
|
|
8171
8181
|
pbr_frag: pbr_frag
|
|
8172
8182
|
};
|
|
8173
8183
|
var ShadowCoord = "#define GLSLIFY 1\nuniform mat4 scene_ShadowMatrices[SCENE_SHADOW_CASCADED_COUNT+1];uniform vec4 scene_ShadowSplitSpheres[4];mediump int computeCascadeIndex(vec3 positionWS){vec3 fromCenter0=positionWS-scene_ShadowSplitSpheres[0].xyz;vec3 fromCenter1=positionWS-scene_ShadowSplitSpheres[1].xyz;vec3 fromCenter2=positionWS-scene_ShadowSplitSpheres[2].xyz;vec3 fromCenter3=positionWS-scene_ShadowSplitSpheres[3].xyz;mediump vec4 comparison=vec4(dot(fromCenter0,fromCenter0)<scene_ShadowSplitSpheres[0].w,dot(fromCenter1,fromCenter1)<scene_ShadowSplitSpheres[1].w,dot(fromCenter2,fromCenter2)<scene_ShadowSplitSpheres[2].w,dot(fromCenter3,fromCenter3)<scene_ShadowSplitSpheres[3].w);comparison.yzw=clamp(comparison.yzw-comparison.xyz,0.0,1.0);mediump vec4 indexCoefficient=vec4(4.0,3.0,2.0,1.0);mediump int index=4-int(dot(comparison,indexCoefficient));return index;}vec3 getShadowCoord(){\n#if SCENE_SHADOW_CASCADED_COUNT == 1\nmediump int cascadeIndex=0;\n#else\nmediump int cascadeIndex=computeCascadeIndex(v_pos);\n#endif\n#ifdef GRAPHICS_API_WEBGL2\nmat4 shadowMatrix=scene_ShadowMatrices[cascadeIndex];\n#else\nmat4 shadowMatrix;\n#if SCENE_SHADOW_CASCADED_COUNT == 4\nif(cascadeIndex==0){shadowMatrix=scene_ShadowMatrices[0];}else if(cascadeIndex==1){shadowMatrix=scene_ShadowMatrices[1];}else if(cascadeIndex==2){shadowMatrix=scene_ShadowMatrices[2];}else if(cascadeIndex==3){shadowMatrix=scene_ShadowMatrices[3];}else{shadowMatrix=scene_ShadowMatrices[4];}\n#endif\n#if SCENE_SHADOW_CASCADED_COUNT == 2\nif(cascadeIndex==0){shadowMatrix=scene_ShadowMatrices[0];}else if(cascadeIndex==1){shadowMatrix=scene_ShadowMatrices[1];}else{shadowMatrix=scene_ShadowMatrices[2];}\n#endif\n#if SCENE_SHADOW_CASCADED_COUNT == 1\nif(cascadeIndex==0){shadowMatrix=scene_ShadowMatrices[0];}else{shadowMatrix=scene_ShadowMatrices[1];}\n#endif\n#endif\nvec4 shadowCoord=shadowMatrix*vec4(v_pos,1.0);return shadowCoord.xyz;}"; // eslint-disable-line
|
|
8174
|
-
var ShadowFragmentDeclaration = "#define GLSLIFY 1\n#if defined(SCENE_SHADOW_TYPE) && defined(RENDERER_IS_RECEIVE_SHADOWS)\n#define SCENE_IS_CALCULATE_SHADOWS\n#endif\n#ifdef SCENE_IS_CALCULATE_SHADOWS\n#if SCENE_SHADOW_CASCADED_COUNT == 1\nvarying vec3 v_shadowCoord;\n#else\n#include <ShadowCoord>\n#endif\nuniform
|
|
8184
|
+
var ShadowFragmentDeclaration = "#define GLSLIFY 1\n#if defined(SCENE_SHADOW_TYPE) && defined(RENDERER_IS_RECEIVE_SHADOWS)\n#define SCENE_IS_CALCULATE_SHADOWS\n#endif\n#ifdef SCENE_IS_CALCULATE_SHADOWS\n#if SCENE_SHADOW_CASCADED_COUNT == 1\nvarying vec3 v_shadowCoord;\n#else\n#include <ShadowCoord>\n#endif\nuniform vec4 scene_ShadowInfo;uniform vec4 scene_ShadowMapSize;\n#ifdef GRAPHICS_API_WEBGL2\nuniform mediump sampler2DShadow scene_ShadowMap;\n#define SAMPLE_TEXTURE2D_SHADOW(textureName, coord3) textureLod(textureName, coord3 , 0.0)\n#define TEXTURE2D_SHADOW_PARAM(shadowMap) mediump sampler2DShadow shadowMap\n#else\nuniform sampler2D scene_ShadowMap;\n#ifdef ENGINE_NO_DEPTH_TEXTURE\nconst vec4 bitShift=vec4(1.0,1.0/256.0,1.0/(256.0*256.0),1.0/(256.0*256.0*256.0));float unpack(const in vec4 rgbaDepth){return dot(rgbaDepth,bitShift);}\n#define SAMPLE_TEXTURE2D_SHADOW(textureName, coord3) (unpack(texture2D(textureName, coord3.xy)) < coord3.z ? 0.0 : 1.0)\n#else\n#define SAMPLE_TEXTURE2D_SHADOW(textureName, coord3) (texture2D(textureName, coord3.xy).r < coord3.z ? 0.0 : 1.0)\n#endif\n#define TEXTURE2D_SHADOW_PARAM(shadowMap) mediump sampler2D shadowMap\n#endif\n#if SCENE_SHADOW_TYPE == 2\nfloat sampleShadowMapFiltered4(TEXTURE2D_SHADOW_PARAM(shadowMap),vec3 shadowCoord,vec4 shadowMapSize){float attenuation;vec4 attenuation4;vec2 offset=shadowMapSize.xy/2.0;vec3 shadowCoord0=shadowCoord+vec3(-offset,0.0);vec3 shadowCoord1=shadowCoord+vec3(offset.x,-offset.y,0.0);vec3 shadowCoord2=shadowCoord+vec3(-offset.x,offset.y,0.0);vec3 shadowCoord3=shadowCoord+vec3(offset,0.0);attenuation4.x=SAMPLE_TEXTURE2D_SHADOW(shadowMap,shadowCoord0);attenuation4.y=SAMPLE_TEXTURE2D_SHADOW(shadowMap,shadowCoord1);attenuation4.z=SAMPLE_TEXTURE2D_SHADOW(shadowMap,shadowCoord2);attenuation4.w=SAMPLE_TEXTURE2D_SHADOW(shadowMap,shadowCoord3);attenuation=dot(attenuation4,vec4(0.25));return attenuation;}\n#endif\n#if SCENE_SHADOW_TYPE == 3\n#include <shadow_sample_tent>\nfloat sampleShadowMapFiltered9(TEXTURE2D_SHADOW_PARAM(shadowMap),vec3 shadowCoord,vec4 shadowmapSize){float attenuation;float fetchesWeights[9];vec2 fetchesUV[9];sampleShadowComputeSamplesTent5x5(shadowmapSize,shadowCoord.xy,fetchesWeights,fetchesUV);attenuation=fetchesWeights[0]*SAMPLE_TEXTURE2D_SHADOW(shadowMap,vec3(fetchesUV[0].xy,shadowCoord.z));attenuation+=fetchesWeights[1]*SAMPLE_TEXTURE2D_SHADOW(shadowMap,vec3(fetchesUV[1].xy,shadowCoord.z));attenuation+=fetchesWeights[2]*SAMPLE_TEXTURE2D_SHADOW(shadowMap,vec3(fetchesUV[2].xy,shadowCoord.z));attenuation+=fetchesWeights[3]*SAMPLE_TEXTURE2D_SHADOW(shadowMap,vec3(fetchesUV[3].xy,shadowCoord.z));attenuation+=fetchesWeights[4]*SAMPLE_TEXTURE2D_SHADOW(shadowMap,vec3(fetchesUV[4].xy,shadowCoord.z));attenuation+=fetchesWeights[5]*SAMPLE_TEXTURE2D_SHADOW(shadowMap,vec3(fetchesUV[5].xy,shadowCoord.z));attenuation+=fetchesWeights[6]*SAMPLE_TEXTURE2D_SHADOW(shadowMap,vec3(fetchesUV[6].xy,shadowCoord.z));attenuation+=fetchesWeights[7]*SAMPLE_TEXTURE2D_SHADOW(shadowMap,vec3(fetchesUV[7].xy,shadowCoord.z));attenuation+=fetchesWeights[8]*SAMPLE_TEXTURE2D_SHADOW(shadowMap,vec3(fetchesUV[8].xy,shadowCoord.z));return attenuation;}\n#endif\nfloat getShadowFade(vec3 positionWS){vec3 camToPixel=positionWS-camera_Position;float distanceCamToPixel2=dot(camToPixel,camToPixel);return saturate(distanceCamToPixel2*scene_ShadowInfo.z+scene_ShadowInfo.w);}float sampleShadowMap(){\n#if SCENE_SHADOW_CASCADED_COUNT == 1\nvec3 shadowCoord=v_shadowCoord;\n#else\nvec3 shadowCoord=getShadowCoord();\n#endif\nfloat attenuation=1.0;if(shadowCoord.z>0.0&&shadowCoord.z<1.0){\n#if SCENE_SHADOW_TYPE == 1\nattenuation=SAMPLE_TEXTURE2D_SHADOW(scene_ShadowMap,shadowCoord);\n#endif\n#if SCENE_SHADOW_TYPE == 2\nattenuation=sampleShadowMapFiltered4(scene_ShadowMap,shadowCoord,scene_ShadowMapSize);\n#endif\n#if SCENE_SHADOW_TYPE == 3\nattenuation=sampleShadowMapFiltered9(scene_ShadowMap,shadowCoord,scene_ShadowMapSize);\n#endif\nfloat shadowFade=getShadowFade(v_pos);attenuation=mix(1.0,mix(attenuation,1.0,shadowFade),scene_ShadowInfo.x);}return attenuation;}\n#endif\n"; // eslint-disable-line
|
|
8175
8185
|
var shadow_sample_tent = "#define GLSLIFY 1\nfloat sampleShadowGetIRTriangleTexelArea(float triangleHeight){return triangleHeight-0.5;}void sampleShadowGetTexelAreasTent3x3(float offset,out vec4 computedArea,out vec4 computedAreaUncut){float a=offset+0.5;float offsetSquaredHalved=a*a*0.5;computedAreaUncut.x=computedArea.x=offsetSquaredHalved-offset;computedAreaUncut.w=computedArea.w=offsetSquaredHalved;computedAreaUncut.y=sampleShadowGetIRTriangleTexelArea(1.5-offset);float clampedOffsetLeft=min(offset,0.0);float areaOfSmallLeftTriangle=clampedOffsetLeft*clampedOffsetLeft;computedArea.y=computedAreaUncut.y-areaOfSmallLeftTriangle;computedAreaUncut.z=sampleShadowGetIRTriangleTexelArea(1.5+offset);float clampedOffsetRight=max(offset,0.0);float areaOfSmallRightTriangle=clampedOffsetRight*clampedOffsetRight;computedArea.z=computedAreaUncut.z-areaOfSmallRightTriangle;}void sampleShadowGetTexelWeightsTent5x5(float offset,out vec3 texelsWeightsA,out vec3 texelsWeightsB){vec4 areaFrom3texelTriangle;vec4 areaUncutFrom3texelTriangle;sampleShadowGetTexelAreasTent3x3(offset,areaFrom3texelTriangle,areaUncutFrom3texelTriangle);texelsWeightsA.x=0.16*(areaFrom3texelTriangle.x);texelsWeightsA.y=0.16*(areaUncutFrom3texelTriangle.y);texelsWeightsA.z=0.16*(areaFrom3texelTriangle.y+1.0);texelsWeightsB.x=0.16*(areaFrom3texelTriangle.z+1.0);texelsWeightsB.y=0.16*(areaUncutFrom3texelTriangle.z);texelsWeightsB.z=0.16*(areaFrom3texelTriangle.w);}void sampleShadowComputeSamplesTent5x5(vec4 shadowMapTextureTexelSize,vec2 coord,out float fetchesWeights[9],out vec2 fetchesUV[9]){vec2 tentCenterInTexelSpace=coord.xy*shadowMapTextureTexelSize.zw;vec2 centerOfFetchesInTexelSpace=floor(tentCenterInTexelSpace+0.5);vec2 offsetFromTentCenterToCenterOfFetches=tentCenterInTexelSpace-centerOfFetchesInTexelSpace;vec3 texelsWeightsUA,texelsWeightsUB;vec3 texelsWeightsVA,texelsWeightsVB;sampleShadowGetTexelWeightsTent5x5(offsetFromTentCenterToCenterOfFetches.x,texelsWeightsUA,texelsWeightsUB);sampleShadowGetTexelWeightsTent5x5(offsetFromTentCenterToCenterOfFetches.y,texelsWeightsVA,texelsWeightsVB);vec3 fetchesWeightsU=vec3(texelsWeightsUA.xz,texelsWeightsUB.y)+vec3(texelsWeightsUA.y,texelsWeightsUB.xz);vec3 fetchesWeightsV=vec3(texelsWeightsVA.xz,texelsWeightsVB.y)+vec3(texelsWeightsVA.y,texelsWeightsVB.xz);vec3 fetchesOffsetsU=vec3(texelsWeightsUA.y,texelsWeightsUB.xz)/fetchesWeightsU.xyz+vec3(-2.5,-0.5,1.5);vec3 fetchesOffsetsV=vec3(texelsWeightsVA.y,texelsWeightsVB.xz)/fetchesWeightsV.xyz+vec3(-2.5,-0.5,1.5);fetchesOffsetsU*=shadowMapTextureTexelSize.xxx;fetchesOffsetsV*=shadowMapTextureTexelSize.yyy;vec2 bilinearFetchOrigin=centerOfFetchesInTexelSpace*shadowMapTextureTexelSize.xy;fetchesUV[0]=bilinearFetchOrigin+vec2(fetchesOffsetsU.x,fetchesOffsetsV.x);fetchesUV[1]=bilinearFetchOrigin+vec2(fetchesOffsetsU.y,fetchesOffsetsV.x);fetchesUV[2]=bilinearFetchOrigin+vec2(fetchesOffsetsU.z,fetchesOffsetsV.x);fetchesUV[3]=bilinearFetchOrigin+vec2(fetchesOffsetsU.x,fetchesOffsetsV.y);fetchesUV[4]=bilinearFetchOrigin+vec2(fetchesOffsetsU.y,fetchesOffsetsV.y);fetchesUV[5]=bilinearFetchOrigin+vec2(fetchesOffsetsU.z,fetchesOffsetsV.y);fetchesUV[6]=bilinearFetchOrigin+vec2(fetchesOffsetsU.x,fetchesOffsetsV.z);fetchesUV[7]=bilinearFetchOrigin+vec2(fetchesOffsetsU.y,fetchesOffsetsV.z);fetchesUV[8]=bilinearFetchOrigin+vec2(fetchesOffsetsU.z,fetchesOffsetsV.z);fetchesWeights[0]=fetchesWeightsU.x*fetchesWeightsV.x;fetchesWeights[1]=fetchesWeightsU.y*fetchesWeightsV.x;fetchesWeights[2]=fetchesWeightsU.z*fetchesWeightsV.x;fetchesWeights[3]=fetchesWeightsU.x*fetchesWeightsV.y;fetchesWeights[4]=fetchesWeightsU.y*fetchesWeightsV.y;fetchesWeights[5]=fetchesWeightsU.z*fetchesWeightsV.y;fetchesWeights[6]=fetchesWeightsU.x*fetchesWeightsV.z;fetchesWeights[7]=fetchesWeightsU.y*fetchesWeightsV.z;fetchesWeights[8]=fetchesWeightsU.z*fetchesWeightsV.z;}"; // eslint-disable-line
|
|
8176
8186
|
var ShadowVertexDeclaration = "#define GLSLIFY 1\n#if defined(SCENE_SHADOW_TYPE) && defined(RENDERER_IS_RECEIVE_SHADOWS)\n#define SCENE_IS_CALCULATE_SHADOWS\n#endif\n#ifdef SCENE_IS_CALCULATE_SHADOWS\n#if SCENE_SHADOW_CASCADED_COUNT==1\n#include <ShadowCoord>\nvarying vec3 v_shadowCoord;\n#endif\n#endif\n"; // eslint-disable-line
|
|
8177
8187
|
var ShadowVertex = "#define GLSLIFY 1\n#ifdef SCENE_IS_CALCULATE_SHADOWS\n#if SCENE_SHADOW_CASCADED_COUNT == 1\nv_shadowCoord=getShadowCoord();\n#endif\n#endif\n"; // eslint-disable-line
|
|
@@ -8267,16 +8277,22 @@
|
|
|
8267
8277
|
}
|
|
8268
8278
|
ShaderLib[includeName] = includeSource;
|
|
8269
8279
|
};
|
|
8270
|
-
ShaderFactory.
|
|
8280
|
+
ShaderFactory.unRegisterInclude = function unRegisterInclude(includeName) {
|
|
8281
|
+
delete ShaderLib[includeName];
|
|
8282
|
+
};
|
|
8283
|
+
/**
|
|
8284
|
+
* @param regex The default regex is for engine's builtin glsl `#include` syntax,
|
|
8285
|
+
* since `ShaderLab` use the same parsing function but different syntax for `#include` --- `/^[ \t]*#include +"([\w\d.]+)"/gm`
|
|
8286
|
+
*/ ShaderFactory.parseIncludes = function parseIncludes(src, regex) {
|
|
8287
|
+
if (regex === void 0) regex = /^[ \t]*#include +<([\w\d.]+)>/gm;
|
|
8271
8288
|
var replace = function replace(match, slice) {
|
|
8272
8289
|
var replace = ShaderLib[slice];
|
|
8273
8290
|
if (replace === undefined) {
|
|
8274
8291
|
Logger.error('Shader slice "' + match.trim() + '" not founded.');
|
|
8275
8292
|
return "";
|
|
8276
8293
|
}
|
|
8277
|
-
return ShaderFactory.parseIncludes(replace);
|
|
8294
|
+
return ShaderFactory.parseIncludes(replace, regex);
|
|
8278
8295
|
};
|
|
8279
|
-
var regex = /^[ \t]*#include +<([\w\d.]+)>/gm;
|
|
8280
8296
|
return src.replace(regex, replace);
|
|
8281
8297
|
};
|
|
8282
8298
|
/**
|
|
@@ -8384,15 +8400,6 @@
|
|
|
8384
8400
|
]);
|
|
8385
8401
|
return ShaderPart;
|
|
8386
8402
|
}();
|
|
8387
|
-
/**
|
|
8388
|
-
* Shader data grouping.
|
|
8389
|
-
*/ var ShaderDataGroup;
|
|
8390
|
-
(function(ShaderDataGroup) {
|
|
8391
|
-
ShaderDataGroup[ShaderDataGroup[/** Scene group. */ "Scene"] = 0] = "Scene";
|
|
8392
|
-
ShaderDataGroup[ShaderDataGroup[/** Camera group. */ "Camera"] = 1] = "Camera";
|
|
8393
|
-
ShaderDataGroup[ShaderDataGroup[/** Renderer group. */ "Renderer"] = 2] = "Renderer";
|
|
8394
|
-
ShaderDataGroup[ShaderDataGroup[/** material group. */ "Material"] = 3] = "Material";
|
|
8395
|
-
})(ShaderDataGroup || (ShaderDataGroup = {}));
|
|
8396
8403
|
/**
|
|
8397
8404
|
* Color Space.
|
|
8398
8405
|
*/ exports.ColorSpace = void 0;
|
|
@@ -8599,6 +8606,15 @@
|
|
|
8599
8606
|
this.constUniforms = [];
|
|
8600
8607
|
this.textureUniforms = [];
|
|
8601
8608
|
};
|
|
8609
|
+
/**
|
|
8610
|
+
* Shader data grouping.
|
|
8611
|
+
*/ var ShaderDataGroup;
|
|
8612
|
+
(function(ShaderDataGroup) {
|
|
8613
|
+
ShaderDataGroup[ShaderDataGroup[/** Scene group. */ "Scene"] = 0] = "Scene";
|
|
8614
|
+
ShaderDataGroup[ShaderDataGroup[/** Camera group. */ "Camera"] = 1] = "Camera";
|
|
8615
|
+
ShaderDataGroup[ShaderDataGroup[/** Renderer group. */ "Renderer"] = 2] = "Renderer";
|
|
8616
|
+
ShaderDataGroup[ShaderDataGroup[/** material group. */ "Material"] = 3] = "Material";
|
|
8617
|
+
})(ShaderDataGroup || (ShaderDataGroup = {}));
|
|
8602
8618
|
/**
|
|
8603
8619
|
* Shader program, corresponding to the GPU shader program.
|
|
8604
8620
|
* @internal
|
|
@@ -8894,6 +8910,7 @@
|
|
|
8894
8910
|
break;
|
|
8895
8911
|
case gl.SAMPLER_2D:
|
|
8896
8912
|
case gl.SAMPLER_CUBE:
|
|
8913
|
+
case gl.UNSIGNED_INT_SAMPLER_2D:
|
|
8897
8914
|
case gl.SAMPLER_2D_ARRAY:
|
|
8898
8915
|
case gl.SAMPLER_2D_SHADOW:
|
|
8899
8916
|
var defaultTexture;
|
|
@@ -8904,6 +8921,9 @@
|
|
|
8904
8921
|
case gl.SAMPLER_CUBE:
|
|
8905
8922
|
defaultTexture = _this._engine._magentaTextureCube;
|
|
8906
8923
|
break;
|
|
8924
|
+
case gl.UNSIGNED_INT_SAMPLER_2D:
|
|
8925
|
+
defaultTexture = _this._engine._uintMagentaTexture2D;
|
|
8926
|
+
break;
|
|
8907
8927
|
case gl.SAMPLER_2D_ARRAY:
|
|
8908
8928
|
defaultTexture = _this._engine._magentaTexture2DArray;
|
|
8909
8929
|
break;
|
|
@@ -9982,6 +10002,55 @@
|
|
|
9982
10002
|
]);
|
|
9983
10003
|
return GraphicsResource;
|
|
9984
10004
|
}(ReferResource);
|
|
10005
|
+
/**
|
|
10006
|
+
* The filter mode of the texture.
|
|
10007
|
+
*/ exports.TextureFilterMode = void 0;
|
|
10008
|
+
(function(TextureFilterMode) {
|
|
10009
|
+
TextureFilterMode[TextureFilterMode[/** Point filtering. */ "Point"] = 0] = "Point";
|
|
10010
|
+
TextureFilterMode[TextureFilterMode[/** Bilinear filtering. */ "Bilinear"] = 1] = "Bilinear";
|
|
10011
|
+
TextureFilterMode[TextureFilterMode[/** Trilinear filtering. */ "Trilinear"] = 2] = "Trilinear";
|
|
10012
|
+
})(exports.TextureFilterMode || (exports.TextureFilterMode = {}));
|
|
10013
|
+
/**
|
|
10014
|
+
* Texture format enumeration.
|
|
10015
|
+
*/ exports.TextureFormat = void 0;
|
|
10016
|
+
(function(TextureFormat) {
|
|
10017
|
+
TextureFormat[TextureFormat[/** RGB format, 8 bits per channel. */ "R8G8B8"] = 0] = "R8G8B8";
|
|
10018
|
+
TextureFormat[TextureFormat[/** RGBA format, 8 bits per channel. */ "R8G8B8A8"] = 1] = "R8G8B8A8";
|
|
10019
|
+
TextureFormat[TextureFormat[/** RGBA format, 4 bits per channel. */ "R4G4B4A4"] = 2] = "R4G4B4A4";
|
|
10020
|
+
TextureFormat[TextureFormat[/** RGBA format, 5 bits in R channel, 5 bits in G channel, 5 bits in B channel, 1 bit in A channel. */ "R5G5B5A1"] = 3] = "R5G5B5A1";
|
|
10021
|
+
TextureFormat[TextureFormat[/** RGB format, 5 bits in R channel, 6 bits in G channel, 5 bits in B channel. */ "R5G6B5"] = 4] = "R5G6B5";
|
|
10022
|
+
TextureFormat[TextureFormat[/** Transparent format, 8 bits. */ "Alpha8"] = 5] = "Alpha8";
|
|
10023
|
+
TextureFormat[TextureFormat[/** Luminance/alpha in RGB channel, alpha in A channel. */ "LuminanceAlpha"] = 6] = "LuminanceAlpha";
|
|
10024
|
+
TextureFormat[TextureFormat[/** RGBA format, 16 bits per channel. */ "R16G16B16A16"] = 7] = "R16G16B16A16";
|
|
10025
|
+
TextureFormat[TextureFormat[/** RGBA format, 32 bits per channel. */ "R32G32B32A32"] = 8] = "R32G32B32A32";
|
|
10026
|
+
TextureFormat[TextureFormat[/** RGBA unsigned integer format, 32 bits per channel. */ "R32G32B32A32_UInt"] = 9] = "R32G32B32A32_UInt";
|
|
10027
|
+
TextureFormat[TextureFormat[/** RGB compressed format, 4 bits per pixel. */ "BC1"] = 10] = "BC1";
|
|
10028
|
+
TextureFormat[TextureFormat[/** RGBA compressed format, 8 bits per pixel. */ "BC3"] = 11] = "BC3";
|
|
10029
|
+
TextureFormat[TextureFormat[/** RGB(A) compressed format, 128 bits per 4x4 pixel block. */ "BC7"] = 12] = "BC7";
|
|
10030
|
+
TextureFormat[TextureFormat[/** RGB compressed format, 4 bits per pixel. */ "ETC1_RGB"] = 13] = "ETC1_RGB";
|
|
10031
|
+
TextureFormat[TextureFormat[/** RGB compressed format, 4 bits per pixel. */ "ETC2_RGB"] = 14] = "ETC2_RGB";
|
|
10032
|
+
TextureFormat[TextureFormat[/** RGBA compressed format, 5 bits per pixel, 4 bit in RGB, 1 bit in A. */ "ETC2_RGBA5"] = 15] = "ETC2_RGBA5";
|
|
10033
|
+
TextureFormat[TextureFormat[/** RGB compressed format, 8 bits per pixel. */ "ETC2_RGBA8"] = 16] = "ETC2_RGBA8";
|
|
10034
|
+
TextureFormat[TextureFormat[/** RGB compressed format, 2 bits per pixel. */ "PVRTC_RGB2"] = 17] = "PVRTC_RGB2";
|
|
10035
|
+
TextureFormat[TextureFormat[/** RGBA compressed format, 2 bits per pixel. */ "PVRTC_RGBA2"] = 18] = "PVRTC_RGBA2";
|
|
10036
|
+
TextureFormat[TextureFormat[/** RGB compressed format, 4 bits per pixel. */ "PVRTC_RGB4"] = 19] = "PVRTC_RGB4";
|
|
10037
|
+
TextureFormat[TextureFormat[/** RGBA compressed format, 4 bits per pixel. */ "PVRTC_RGBA4"] = 20] = "PVRTC_RGBA4";
|
|
10038
|
+
TextureFormat[TextureFormat[/** RGB(A) compressed format, 128 bits per 4x4 pixel block. */ "ASTC_4x4"] = 21] = "ASTC_4x4";
|
|
10039
|
+
TextureFormat[TextureFormat[/** RGB(A) compressed format, 128 bits per 5x5 pixel block. */ "ASTC_5x5"] = 22] = "ASTC_5x5";
|
|
10040
|
+
TextureFormat[TextureFormat[/** RGB(A) compressed format, 128 bits per 6x6 pixel block. */ "ASTC_6x6"] = 23] = "ASTC_6x6";
|
|
10041
|
+
TextureFormat[TextureFormat[/** RGB(A) compressed format, 128 bits per 8x8 pixel block. */ "ASTC_8x8"] = 24] = "ASTC_8x8";
|
|
10042
|
+
TextureFormat[TextureFormat[/** RGB(A) compressed format, 128 bits per 10x10 pixel block. */ "ASTC_10x10"] = 25] = "ASTC_10x10";
|
|
10043
|
+
TextureFormat[TextureFormat[/** RGB(A) compressed format, 128 bits per 12x12 pixel block. */ "ASTC_12x12"] = 26] = "ASTC_12x12";
|
|
10044
|
+
TextureFormat[TextureFormat[/** Automatic depth format, engine will automatically select the supported precision. */ "Depth"] = 27] = "Depth";
|
|
10045
|
+
TextureFormat[TextureFormat[/** Automatic depth stencil format, engine will automatically select the supported precision. */ "DepthStencil"] = 28] = "DepthStencil";
|
|
10046
|
+
TextureFormat[TextureFormat[/** 16-bit depth format. */ "Depth16"] = 29] = "Depth16";
|
|
10047
|
+
TextureFormat[TextureFormat[/** 24-bit depth format. */ "Depth24"] = 30] = "Depth24";
|
|
10048
|
+
TextureFormat[TextureFormat[/** 32-bit depth format. */ "Depth32"] = 31] = "Depth32";
|
|
10049
|
+
TextureFormat[TextureFormat[/** 16-bit depth + 8-bit stencil format. */ "Depth24Stencil8"] = 32] = "Depth24Stencil8";
|
|
10050
|
+
TextureFormat[TextureFormat[/** 32-bit depth + 8-bit stencil format. */ "Depth32Stencil8"] = 33] = "Depth32Stencil8";
|
|
10051
|
+
TextureFormat[TextureFormat[/** @deprecated Use `TextureFormat.BC1` instead. */ "DXT1"] = 34] = "DXT1";
|
|
10052
|
+
TextureFormat[TextureFormat[/** @deprecated Use `TextureFormat.BC3` instead. */ "DXT5"] = 35] = "DXT5";
|
|
10053
|
+
})(exports.TextureFormat || (exports.TextureFormat = {}));
|
|
9985
10054
|
/**
|
|
9986
10055
|
* The base class of texture, contains some common functions of texture-related classes.
|
|
9987
10056
|
*/ var Texture = /*#__PURE__*/ function(GraphicsResource1) {
|
|
@@ -10038,6 +10107,12 @@
|
|
|
10038
10107
|
_proto._getMipmapCount = function _getMipmapCount() {
|
|
10039
10108
|
return this._mipmap ? Math.floor(Math.log2(Math.max(this._width, this._height))) + 1 : 1;
|
|
10040
10109
|
};
|
|
10110
|
+
_proto._isIntFormat = function _isIntFormat() {
|
|
10111
|
+
if (exports.TextureFormat.R32G32B32A32_UInt === this._format) {
|
|
10112
|
+
return true;
|
|
10113
|
+
}
|
|
10114
|
+
return false;
|
|
10115
|
+
};
|
|
10041
10116
|
_create_class$2(Texture, [
|
|
10042
10117
|
{
|
|
10043
10118
|
key: "format",
|
|
@@ -10114,6 +10189,11 @@
|
|
|
10114
10189
|
},
|
|
10115
10190
|
set: function set(value) {
|
|
10116
10191
|
if (value === this._filterMode) return;
|
|
10192
|
+
if (value !== exports.TextureFilterMode.Point && this._isIntFormat()) {
|
|
10193
|
+
value = exports.TextureFilterMode.Point;
|
|
10194
|
+
Logger.warn("Int or UInt format texture only support TextureFilterMode.Point");
|
|
10195
|
+
return;
|
|
10196
|
+
}
|
|
10117
10197
|
this._filterMode = value;
|
|
10118
10198
|
this._platformTexture.filterMode = value;
|
|
10119
10199
|
}
|
|
@@ -11229,7 +11309,7 @@
|
|
|
11229
11309
|
_this._byteLength = byteLength;
|
|
11230
11310
|
_this._platformBuffer = engine._hardwareRenderer.createPlatformBuffer(type, byteLength, bufferUsage, data);
|
|
11231
11311
|
if (readable) {
|
|
11232
|
-
var buffer =
|
|
11312
|
+
var buffer = data.constructor === ArrayBuffer ? data.slice(0) : data.buffer.slice(data.byteOffset, data.byteOffset + byteLength);
|
|
11233
11313
|
_this._data = new Uint8Array(buffer);
|
|
11234
11314
|
}
|
|
11235
11315
|
}
|
|
@@ -12388,54 +12468,6 @@
|
|
|
12388
12468
|
TextureDepthCompareFunction[TextureDepthCompareFunction[/** pass if the compare value is greater than or equal to the sample value. */ "GreaterEqual"] = 6] = "GreaterEqual";
|
|
12389
12469
|
TextureDepthCompareFunction[TextureDepthCompareFunction[/** always pass. */ "Always"] = 7] = "Always";
|
|
12390
12470
|
})(exports.TextureDepthCompareFunction || (exports.TextureDepthCompareFunction = {}));
|
|
12391
|
-
/**
|
|
12392
|
-
* The filter mode of the texture.
|
|
12393
|
-
*/ exports.TextureFilterMode = void 0;
|
|
12394
|
-
(function(TextureFilterMode) {
|
|
12395
|
-
TextureFilterMode[TextureFilterMode[/** Point filtering. */ "Point"] = 0] = "Point";
|
|
12396
|
-
TextureFilterMode[TextureFilterMode[/** Bilinear filtering. */ "Bilinear"] = 1] = "Bilinear";
|
|
12397
|
-
TextureFilterMode[TextureFilterMode[/** Trilinear filtering. */ "Trilinear"] = 2] = "Trilinear";
|
|
12398
|
-
})(exports.TextureFilterMode || (exports.TextureFilterMode = {}));
|
|
12399
|
-
/**
|
|
12400
|
-
* Texture format enumeration.
|
|
12401
|
-
*/ exports.TextureFormat = void 0;
|
|
12402
|
-
(function(TextureFormat) {
|
|
12403
|
-
TextureFormat[TextureFormat[/** RGB format, 8 bits per channel. */ "R8G8B8"] = 0] = "R8G8B8";
|
|
12404
|
-
TextureFormat[TextureFormat[/** RGBA format, 8 bits per channel. */ "R8G8B8A8"] = 1] = "R8G8B8A8";
|
|
12405
|
-
TextureFormat[TextureFormat[/** RGBA format, 4 bits per channel. */ "R4G4B4A4"] = 2] = "R4G4B4A4";
|
|
12406
|
-
TextureFormat[TextureFormat[/** RGBA format, 5 bits in R channel, 5 bits in G channel, 5 bits in B channel, 1 bit in A channel. */ "R5G5B5A1"] = 3] = "R5G5B5A1";
|
|
12407
|
-
TextureFormat[TextureFormat[/** RGB format, 5 bits in R channel, 6 bits in G channel, 5 bits in B channel. */ "R5G6B5"] = 4] = "R5G6B5";
|
|
12408
|
-
TextureFormat[TextureFormat[/** Transparent format, 8 bits. */ "Alpha8"] = 5] = "Alpha8";
|
|
12409
|
-
TextureFormat[TextureFormat[/** Luminance/alpha in RGB channel, alpha in A channel. */ "LuminanceAlpha"] = 6] = "LuminanceAlpha";
|
|
12410
|
-
TextureFormat[TextureFormat[/** RGBA format, 16 bits per channel. */ "R16G16B16A16"] = 7] = "R16G16B16A16";
|
|
12411
|
-
TextureFormat[TextureFormat[/** RGBA format, 32 bits per channel. */ "R32G32B32A32"] = 8] = "R32G32B32A32";
|
|
12412
|
-
TextureFormat[TextureFormat[/** RGB compressed format, 4 bits per pixel. */ "BC1"] = 9] = "BC1";
|
|
12413
|
-
TextureFormat[TextureFormat[/** RGBA compressed format, 8 bits per pixel. */ "BC3"] = 10] = "BC3";
|
|
12414
|
-
TextureFormat[TextureFormat[/** RGB(A) compressed format, 128 bits per 4x4 pixel block. */ "BC7"] = 11] = "BC7";
|
|
12415
|
-
TextureFormat[TextureFormat[/** RGB compressed format, 4 bits per pixel. */ "ETC1_RGB"] = 12] = "ETC1_RGB";
|
|
12416
|
-
TextureFormat[TextureFormat[/** RGB compressed format, 4 bits per pixel. */ "ETC2_RGB"] = 13] = "ETC2_RGB";
|
|
12417
|
-
TextureFormat[TextureFormat[/** RGBA compressed format, 5 bits per pixel, 4 bit in RGB, 1 bit in A. */ "ETC2_RGBA5"] = 14] = "ETC2_RGBA5";
|
|
12418
|
-
TextureFormat[TextureFormat[/** RGB compressed format, 8 bits per pixel. */ "ETC2_RGBA8"] = 15] = "ETC2_RGBA8";
|
|
12419
|
-
TextureFormat[TextureFormat[/** RGB compressed format, 2 bits per pixel. */ "PVRTC_RGB2"] = 16] = "PVRTC_RGB2";
|
|
12420
|
-
TextureFormat[TextureFormat[/** RGBA compressed format, 2 bits per pixel. */ "PVRTC_RGBA2"] = 17] = "PVRTC_RGBA2";
|
|
12421
|
-
TextureFormat[TextureFormat[/** RGB compressed format, 4 bits per pixel. */ "PVRTC_RGB4"] = 18] = "PVRTC_RGB4";
|
|
12422
|
-
TextureFormat[TextureFormat[/** RGBA compressed format, 4 bits per pixel. */ "PVRTC_RGBA4"] = 19] = "PVRTC_RGBA4";
|
|
12423
|
-
TextureFormat[TextureFormat[/** RGB(A) compressed format, 128 bits per 4x4 pixel block. */ "ASTC_4x4"] = 20] = "ASTC_4x4";
|
|
12424
|
-
TextureFormat[TextureFormat[/** RGB(A) compressed format, 128 bits per 5x5 pixel block. */ "ASTC_5x5"] = 21] = "ASTC_5x5";
|
|
12425
|
-
TextureFormat[TextureFormat[/** RGB(A) compressed format, 128 bits per 6x6 pixel block. */ "ASTC_6x6"] = 22] = "ASTC_6x6";
|
|
12426
|
-
TextureFormat[TextureFormat[/** RGB(A) compressed format, 128 bits per 8x8 pixel block. */ "ASTC_8x8"] = 23] = "ASTC_8x8";
|
|
12427
|
-
TextureFormat[TextureFormat[/** RGB(A) compressed format, 128 bits per 10x10 pixel block. */ "ASTC_10x10"] = 24] = "ASTC_10x10";
|
|
12428
|
-
TextureFormat[TextureFormat[/** RGB(A) compressed format, 128 bits per 12x12 pixel block. */ "ASTC_12x12"] = 25] = "ASTC_12x12";
|
|
12429
|
-
TextureFormat[TextureFormat[/** Automatic depth format, engine will automatically select the supported precision. */ "Depth"] = 26] = "Depth";
|
|
12430
|
-
TextureFormat[TextureFormat[/** Automatic depth stencil format, engine will automatically select the supported precision. */ "DepthStencil"] = 27] = "DepthStencil";
|
|
12431
|
-
TextureFormat[TextureFormat[/** 16-bit depth format. */ "Depth16"] = 28] = "Depth16";
|
|
12432
|
-
TextureFormat[TextureFormat[/** 24-bit depth format. */ "Depth24"] = 29] = "Depth24";
|
|
12433
|
-
TextureFormat[TextureFormat[/** 32-bit depth format. */ "Depth32"] = 30] = "Depth32";
|
|
12434
|
-
TextureFormat[TextureFormat[/** 16-bit depth + 8-bit stencil format. */ "Depth24Stencil8"] = 31] = "Depth24Stencil8";
|
|
12435
|
-
TextureFormat[TextureFormat[/** 32-bit depth + 8-bit stencil format. */ "Depth32Stencil8"] = 32] = "Depth32Stencil8";
|
|
12436
|
-
TextureFormat[TextureFormat[/** @deprecated Use `TextureFormat.BC1` instead. */ "DXT1"] = 33] = "DXT1";
|
|
12437
|
-
TextureFormat[TextureFormat[/** @deprecated Use `TextureFormat.BC3` instead. */ "DXT5"] = 34] = "DXT5";
|
|
12438
|
-
})(exports.TextureFormat || (exports.TextureFormat = {}));
|
|
12439
12471
|
/**
|
|
12440
12472
|
* Texture usage.
|
|
12441
12473
|
*/ exports.TextureUsage = void 0;
|
|
@@ -12615,7 +12647,7 @@
|
|
|
12615
12647
|
_this._mipmapCount = _this._getMipmapCount();
|
|
12616
12648
|
_this._isDepthTexture = format == exports.TextureFormat.Depth || format == exports.TextureFormat.DepthStencil || format == exports.TextureFormat.Depth16 || format == exports.TextureFormat.Depth24 || format == exports.TextureFormat.Depth32 || format == exports.TextureFormat.Depth24Stencil8 || format == exports.TextureFormat.Depth32Stencil8;
|
|
12617
12649
|
_this._platformTexture = engine._hardwareRenderer.createPlatformTexture2D(_assert_this_initialized(_this));
|
|
12618
|
-
_this.filterMode = exports.TextureFilterMode.Bilinear;
|
|
12650
|
+
_this.filterMode = _this._isIntFormat() ? exports.TextureFilterMode.Point : exports.TextureFilterMode.Bilinear;
|
|
12619
12651
|
_this.wrapModeU = _this.wrapModeV = exports.TextureWrapMode.Repeat;
|
|
12620
12652
|
return _this;
|
|
12621
12653
|
};
|
|
@@ -15413,7 +15445,7 @@
|
|
|
15413
15445
|
var theta = thetaStart + u * thetaRange;
|
|
15414
15446
|
var sinTheta = Math.sin(theta);
|
|
15415
15447
|
var cosTheta = Math.cos(theta);
|
|
15416
|
-
var curRadius = radius -
|
|
15448
|
+
var curRadius = radius - v * radius;
|
|
15417
15449
|
var posX = curRadius * sinTheta;
|
|
15418
15450
|
var posY = y * unitHeight - halfHeight;
|
|
15419
15451
|
var posZ = curRadius * cosTheta;
|
|
@@ -15547,8 +15579,8 @@
|
|
|
15547
15579
|
indices[indicesOffset++] = d;
|
|
15548
15580
|
indices[indicesOffset++] = c;
|
|
15549
15581
|
}
|
|
15550
|
-
PrimitiveMesh._createCapsuleCap(radius, height, radialSegments, thetaRange, torsoVertexCount, 1, vertices, indices, indicesOffset);
|
|
15551
|
-
PrimitiveMesh._createCapsuleCap(radius, height, radialSegments, -thetaRange, torsoVertexCount + capVertexCount, -1, vertices, indices, indicesOffset + 6 * capRectangleCount);
|
|
15582
|
+
PrimitiveMesh._createCapsuleCap(radius, height, radialSegments, thetaStart, thetaRange, torsoVertexCount, 1, vertices, indices, indicesOffset);
|
|
15583
|
+
PrimitiveMesh._createCapsuleCap(radius, height, radialSegments, thetaStart, -thetaRange, torsoVertexCount + capVertexCount, -1, vertices, indices, indicesOffset + 6 * capRectangleCount);
|
|
15552
15584
|
if (!isRestoreMode) {
|
|
15553
15585
|
var bounds = capsuleMesh.bounds;
|
|
15554
15586
|
bounds.min.set(-radius, -radius - halfHeight, -radius);
|
|
@@ -15589,7 +15621,7 @@
|
|
|
15589
15621
|
}
|
|
15590
15622
|
return indices;
|
|
15591
15623
|
};
|
|
15592
|
-
PrimitiveMesh._createCapsuleCap = function _createCapsuleCap(radius, height, radialSegments,
|
|
15624
|
+
PrimitiveMesh._createCapsuleCap = function _createCapsuleCap(radius, height, radialSegments, thetaStart, thetaRange, offset, posIndex, vertices, indices, indicesOffset) {
|
|
15593
15625
|
var radialCount = radialSegments + 1;
|
|
15594
15626
|
var halfHeight = height * 0.5 * posIndex;
|
|
15595
15627
|
var capVertexCount = radialCount * radialCount;
|
|
@@ -15602,12 +15634,12 @@
|
|
|
15602
15634
|
var y = i * radialCountReciprocal | 0;
|
|
15603
15635
|
var u = x * radialSegmentsReciprocal;
|
|
15604
15636
|
var v = y * radialSegmentsReciprocal;
|
|
15605
|
-
var
|
|
15606
|
-
var
|
|
15607
|
-
var
|
|
15608
|
-
var posX =
|
|
15609
|
-
var posY = radius * Math.cos(
|
|
15610
|
-
var posZ = radius * Math.
|
|
15637
|
+
var theta = thetaStart + u * thetaRange;
|
|
15638
|
+
var alpha = v * Math.PI * 0.5;
|
|
15639
|
+
var sinAlpha = Math.sin(alpha);
|
|
15640
|
+
var posX = radius * Math.sin(theta) * sinAlpha;
|
|
15641
|
+
var posY = radius * Math.cos(alpha) * posIndex + halfHeight;
|
|
15642
|
+
var posZ = radius * Math.cos(theta) * sinAlpha;
|
|
15611
15643
|
var index = (i + offset) * vertexFloatCount;
|
|
15612
15644
|
// Position
|
|
15613
15645
|
vertices[index++] = posX;
|
|
@@ -16162,7 +16194,9 @@
|
|
|
16162
16194
|
this._batchedQueue = null;
|
|
16163
16195
|
var _this = this, meshes = _this._meshes, vertexBuffers = _this._vertexBuffers, indiceBuffers = _this._indiceBuffers;
|
|
16164
16196
|
for(var i = 0, n = meshes.length; i < n; ++i){
|
|
16165
|
-
meshes[i]
|
|
16197
|
+
var mesh = meshes[i];
|
|
16198
|
+
mesh._addReferCount(-1);
|
|
16199
|
+
mesh.destroy();
|
|
16166
16200
|
}
|
|
16167
16201
|
this._meshes = null;
|
|
16168
16202
|
for(var i1 = 0, n1 = vertexBuffers.length; i1 < n1; ++i1){
|
|
@@ -16185,7 +16219,7 @@
|
|
|
16185
16219
|
_proto._createMesh = function _createMesh(engine, index) {
|
|
16186
16220
|
var MAX_VERTEX_COUNT = Basic2DBatcher.MAX_VERTEX_COUNT;
|
|
16187
16221
|
var mesh = new BufferMesh(engine, "BufferMesh" + index);
|
|
16188
|
-
mesh.
|
|
16222
|
+
mesh._addReferCount(1);
|
|
16189
16223
|
var vertexElements = [];
|
|
16190
16224
|
var vertexStride = this.createVertexElements(vertexElements);
|
|
16191
16225
|
// vertices
|
|
@@ -17678,6 +17712,9 @@
|
|
|
17678
17712
|
var baseline = Math.ceil(context.measureText(TextUtils._measureBaseline).width);
|
|
17679
17713
|
var height = baseline * TextUtils._heightMultiplier;
|
|
17680
17714
|
baseline = TextUtils._baselineMultiplier * baseline | 0;
|
|
17715
|
+
var _extendHeight = TextUtils._extendHeight;
|
|
17716
|
+
height += _extendHeight;
|
|
17717
|
+
baseline += _extendHeight * 0.5;
|
|
17681
17718
|
canvas.width = width;
|
|
17682
17719
|
canvas.height = height;
|
|
17683
17720
|
context.font = fontString;
|
|
@@ -17712,6 +17749,7 @@
|
|
|
17712
17749
|
}
|
|
17713
17750
|
if (top !== -1 && bottom !== -1) {
|
|
17714
17751
|
ascent = baseline - top;
|
|
17752
|
+
// Baseline belong to descent
|
|
17715
17753
|
descent = bottom - baseline + 1;
|
|
17716
17754
|
size = ascent + descent;
|
|
17717
17755
|
}
|
|
@@ -17788,9 +17826,8 @@
|
|
|
17788
17826
|
];
|
|
17789
17827
|
})();
|
|
17790
17828
|
(function() {
|
|
17791
|
-
//
|
|
17792
|
-
|
|
17793
|
-
/** @internal */ TextUtils._heightMultiplier = 2;
|
|
17829
|
+
// _extendHeight used to extend the height of canvas, because in miniprogram performance is different from h5.
|
|
17830
|
+
/** @internal */ TextUtils._extendHeight = 0;
|
|
17794
17831
|
})();
|
|
17795
17832
|
(function() {
|
|
17796
17833
|
/** These characters are all tall to help calculate the height required for text. */ TextUtils._measureString = "|\xc9q\xc5";
|
|
@@ -17798,6 +17835,9 @@
|
|
|
17798
17835
|
(function() {
|
|
17799
17836
|
TextUtils._measureBaseline = "M";
|
|
17800
17837
|
})();
|
|
17838
|
+
(function() {
|
|
17839
|
+
TextUtils._heightMultiplier = 2;
|
|
17840
|
+
})();
|
|
17801
17841
|
(function() {
|
|
17802
17842
|
TextUtils._baselineMultiplier = 1.4;
|
|
17803
17843
|
})();
|
|
@@ -19539,6 +19579,7 @@
|
|
|
19539
19579
|
AssetType[/** Cube Compress Texture. */ "KTXCube"] = "KTXCube";
|
|
19540
19580
|
AssetType[/** KTX2 Compress Texture */ "KTX2"] = "KTX2";
|
|
19541
19581
|
AssetType[/** Sprite. */ "Sprite"] = "Sprite";
|
|
19582
|
+
AssetType[/** PrimitiveMesh. */ "PrimitiveMesh"] = "PrimitiveMesh";
|
|
19542
19583
|
AssetType[/** Sprite Atlas. */ "SpriteAtlas"] = "SpriteAtlas";
|
|
19543
19584
|
AssetType[/** Ambient light. */ "Env"] = "Environment";
|
|
19544
19585
|
AssetType[/** Scene. */ "Scene"] = "Scene";
|
|
@@ -19920,6 +19961,7 @@
|
|
|
19920
19961
|
this./** The number of retries after failing to load assets. */ retryCount = 1;
|
|
19921
19962
|
this./** Retry delay time after failed to load assets, in milliseconds. */ retryInterval = 0;
|
|
19922
19963
|
this./** The default timeout period for loading assets, in milliseconds. */ timeout = Infinity;
|
|
19964
|
+
this./** Base url for loading assets. */ baseUrl = null;
|
|
19923
19965
|
this._loadingPromises = {};
|
|
19924
19966
|
this._assetPool = Object.create(null);
|
|
19925
19967
|
this._assetUrlPool = Object.create(null);
|
|
@@ -20122,6 +20164,8 @@
|
|
|
20122
20164
|
// Check url mapping
|
|
20123
20165
|
var itemURL = item.url;
|
|
20124
20166
|
var url = this._virtualPathMap[itemURL] ? this._virtualPathMap[itemURL] : itemURL;
|
|
20167
|
+
// Not absolute and base url is set
|
|
20168
|
+
if (!Utils.isAbsoluteUrl(url) && this.baseUrl) url = Utils.resolveAbsoluteUrl(this.baseUrl, url);
|
|
20125
20169
|
// Parse url
|
|
20126
20170
|
var _this__parseURL = this._parseURL(url), assetBaseURL = _this__parseURL.assetBaseURL, queryPath = _this__parseURL.queryPath;
|
|
20127
20171
|
var paths = queryPath ? this._parseQueryPath(queryPath) : [];
|
|
@@ -20214,10 +20258,20 @@
|
|
|
20214
20258
|
};
|
|
20215
20259
|
_proto._parseURL = function _parseURL(path) {
|
|
20216
20260
|
var _path_split = path.split("?"), baseUrl = _path_split[0], searchStr = _path_split[1];
|
|
20217
|
-
var
|
|
20218
|
-
var
|
|
20219
|
-
|
|
20220
|
-
|
|
20261
|
+
var queryPath = undefined;
|
|
20262
|
+
var assetBaseURL = baseUrl;
|
|
20263
|
+
if (searchStr) {
|
|
20264
|
+
var params = searchStr.split("&");
|
|
20265
|
+
for(var i = 0; i < params.length; i++){
|
|
20266
|
+
var param = params[i];
|
|
20267
|
+
if (param.startsWith("q=")) {
|
|
20268
|
+
queryPath = decodeURIComponent(param.split("=")[1]);
|
|
20269
|
+
params.splice(i, 1);
|
|
20270
|
+
break;
|
|
20271
|
+
}
|
|
20272
|
+
}
|
|
20273
|
+
assetBaseURL = params.length > 0 ? baseUrl + "?" + params.join("&") : baseUrl;
|
|
20274
|
+
}
|
|
20221
20275
|
return {
|
|
20222
20276
|
assetBaseURL: assetBaseURL,
|
|
20223
20277
|
queryPath: queryPath
|
|
@@ -20805,7 +20859,7 @@
|
|
|
20805
20859
|
* Keyboard Manager.
|
|
20806
20860
|
* @internal
|
|
20807
20861
|
*/ var KeyboardManager = /*#__PURE__*/ function() {
|
|
20808
|
-
var KeyboardManager = function KeyboardManager(engine) {
|
|
20862
|
+
var KeyboardManager = function KeyboardManager(engine, target) {
|
|
20809
20863
|
/** @internal */ this._curHeldDownKeyToIndexMap = [];
|
|
20810
20864
|
/** @internal */ this._upKeyToFrameCountMap = [];
|
|
20811
20865
|
/** @internal */ this._downKeyToFrameCountMap = [];
|
|
@@ -20813,17 +20867,11 @@
|
|
|
20813
20867
|
/** @internal */ this._curFrameDownList = new DisorderedArray();
|
|
20814
20868
|
/** @internal */ this._curFrameUpList = new DisorderedArray();
|
|
20815
20869
|
this._nativeEvents = [];
|
|
20816
|
-
this._hadListener = false;
|
|
20817
|
-
// @ts-ignore
|
|
20818
|
-
var htmlCanvas = engine._canvas._webCanvas;
|
|
20819
20870
|
this._engine = engine;
|
|
20820
|
-
this.
|
|
20821
|
-
// Need to set tabIndex to make the canvas focus.
|
|
20822
|
-
htmlCanvas.tabIndex = htmlCanvas.tabIndex;
|
|
20871
|
+
this._onBlur = this._onBlur.bind(this);
|
|
20823
20872
|
this._onKeyEvent = this._onKeyEvent.bind(this);
|
|
20824
|
-
|
|
20825
|
-
|
|
20826
|
-
this._hadListener = true;
|
|
20873
|
+
this._target = target;
|
|
20874
|
+
this._addEventListener();
|
|
20827
20875
|
};
|
|
20828
20876
|
var _proto = KeyboardManager.prototype;
|
|
20829
20877
|
/**
|
|
@@ -20875,35 +20923,8 @@
|
|
|
20875
20923
|
};
|
|
20876
20924
|
/**
|
|
20877
20925
|
* @internal
|
|
20878
|
-
*/ _proto._onFocus = function _onFocus() {
|
|
20879
|
-
if (!this._hadListener) {
|
|
20880
|
-
this._htmlCanvas.addEventListener("keydown", this._onKeyEvent);
|
|
20881
|
-
this._htmlCanvas.addEventListener("keyup", this._onKeyEvent);
|
|
20882
|
-
this._hadListener = true;
|
|
20883
|
-
}
|
|
20884
|
-
};
|
|
20885
|
-
/**
|
|
20886
|
-
* @internal
|
|
20887
|
-
*/ _proto._onBlur = function _onBlur() {
|
|
20888
|
-
if (this._hadListener) {
|
|
20889
|
-
this._htmlCanvas.removeEventListener("keydown", this._onKeyEvent);
|
|
20890
|
-
this._htmlCanvas.removeEventListener("keyup", this._onKeyEvent);
|
|
20891
|
-
this._curHeldDownKeyToIndexMap.length = 0;
|
|
20892
|
-
this._curFrameHeldDownList.length = 0;
|
|
20893
|
-
this._curFrameDownList.length = 0;
|
|
20894
|
-
this._curFrameUpList.length = 0;
|
|
20895
|
-
this._nativeEvents.length = 0;
|
|
20896
|
-
this._hadListener = false;
|
|
20897
|
-
}
|
|
20898
|
-
};
|
|
20899
|
-
/**
|
|
20900
|
-
* @internal
|
|
20901
20926
|
*/ _proto._destroy = function _destroy() {
|
|
20902
|
-
|
|
20903
|
-
this._htmlCanvas.removeEventListener("keydown", this._onKeyEvent);
|
|
20904
|
-
this._htmlCanvas.removeEventListener("keyup", this._onKeyEvent);
|
|
20905
|
-
this._hadListener = false;
|
|
20906
|
-
}
|
|
20927
|
+
this._removeEventListener();
|
|
20907
20928
|
this._curHeldDownKeyToIndexMap.length = 0;
|
|
20908
20929
|
this._curHeldDownKeyToIndexMap = null;
|
|
20909
20930
|
this._upKeyToFrameCountMap.length = 0;
|
|
@@ -20918,12 +20939,30 @@
|
|
|
20918
20939
|
this._curFrameDownList = null;
|
|
20919
20940
|
this._curFrameUpList.length = 0;
|
|
20920
20941
|
this._curFrameUpList = null;
|
|
20921
|
-
this._htmlCanvas = null;
|
|
20922
20942
|
this._engine = null;
|
|
20923
20943
|
};
|
|
20944
|
+
_proto._onBlur = function _onBlur() {
|
|
20945
|
+
this._curHeldDownKeyToIndexMap.length = 0;
|
|
20946
|
+
this._curFrameHeldDownList.length = 0;
|
|
20947
|
+
this._curFrameDownList.length = 0;
|
|
20948
|
+
this._curFrameUpList.length = 0;
|
|
20949
|
+
this._nativeEvents.length = 0;
|
|
20950
|
+
};
|
|
20924
20951
|
_proto._onKeyEvent = function _onKeyEvent(evt) {
|
|
20925
20952
|
this._nativeEvents.push(evt);
|
|
20926
20953
|
};
|
|
20954
|
+
_proto._addEventListener = function _addEventListener() {
|
|
20955
|
+
var _this = this, target = _this._target;
|
|
20956
|
+
target.addEventListener("keydown", this._onKeyEvent);
|
|
20957
|
+
target.addEventListener("keyup", this._onKeyEvent);
|
|
20958
|
+
target.addEventListener("blur", this._onBlur);
|
|
20959
|
+
};
|
|
20960
|
+
_proto._removeEventListener = function _removeEventListener() {
|
|
20961
|
+
var _this = this, target = _this._target;
|
|
20962
|
+
target.removeEventListener("keydown", this._onKeyEvent);
|
|
20963
|
+
target.removeEventListener("keyup", this._onKeyEvent);
|
|
20964
|
+
target.removeEventListener("blur", this._onBlur);
|
|
20965
|
+
};
|
|
20927
20966
|
return KeyboardManager;
|
|
20928
20967
|
}();
|
|
20929
20968
|
/**
|
|
@@ -21221,7 +21260,9 @@
|
|
|
21221
21260
|
};
|
|
21222
21261
|
if (hitResult != undefined) {
|
|
21223
21262
|
var result = this._nativePhysicsScene.raycast(ray, distance, onRaycast, function(idx, distance, position, normal) {
|
|
21224
|
-
|
|
21263
|
+
var hitShape = _this._scene.engine._physicalObjectsMap[idx];
|
|
21264
|
+
hitResult.entity = hitShape._collider.entity;
|
|
21265
|
+
hitResult.shape = hitShape;
|
|
21225
21266
|
hitResult.distance = distance;
|
|
21226
21267
|
hitResult.normal.copyFrom(normal);
|
|
21227
21268
|
hitResult.point.copyFrom(position);
|
|
@@ -21230,6 +21271,7 @@
|
|
|
21230
21271
|
return true;
|
|
21231
21272
|
} else {
|
|
21232
21273
|
hitResult.entity = null;
|
|
21274
|
+
hitResult.shape = null;
|
|
21233
21275
|
hitResult.distance = 0;
|
|
21234
21276
|
hitResult.point.set(0, 0, 0);
|
|
21235
21277
|
hitResult.normal.set(0, 0, 0);
|
|
@@ -21887,6 +21929,7 @@
|
|
|
21887
21929
|
/** The distance from the ray's origin to the impact point. */ this.distance = 0;
|
|
21888
21930
|
/** The impact point in world space where the ray hit the collider. */ this.point = new Vector3();
|
|
21889
21931
|
/** The normal of the surface the ray hit. */ this.normal = new Vector3();
|
|
21932
|
+
/** The shape of the collider that was hit. */ this.shape = null;
|
|
21890
21933
|
};
|
|
21891
21934
|
/**
|
|
21892
21935
|
* Describes how physics materials of the colliding objects are combined.
|
|
@@ -22860,7 +22903,7 @@
|
|
|
22860
22903
|
* Pointer Manager.
|
|
22861
22904
|
* @internal
|
|
22862
22905
|
*/ var PointerManager = /*#__PURE__*/ function() {
|
|
22863
|
-
var PointerManager = function PointerManager(engine) {
|
|
22906
|
+
var PointerManager = function PointerManager(engine, target) {
|
|
22864
22907
|
/** @internal */ this._pointers = [];
|
|
22865
22908
|
/** @internal */ this._multiPointerEnabled = true;
|
|
22866
22909
|
/** @internal */ this._buttons = exports.PointerButton.None;
|
|
@@ -22869,16 +22912,18 @@
|
|
|
22869
22912
|
/** @internal */ this._upList = new DisorderedArray();
|
|
22870
22913
|
/** @internal */ this._downList = new DisorderedArray();
|
|
22871
22914
|
this._nativeEvents = [];
|
|
22872
|
-
|
|
22873
|
-
|
|
22874
|
-
|
|
22915
|
+
if (_instanceof1$2(target, Window)) {
|
|
22916
|
+
throw "Do not set window as target because window cannot listen to pointer leave event.";
|
|
22917
|
+
}
|
|
22875
22918
|
this._engine = engine;
|
|
22919
|
+
this._target = target;
|
|
22876
22920
|
this._canvas = engine.canvas;
|
|
22877
|
-
|
|
22878
|
-
this.
|
|
22879
|
-
this._onFocus();
|
|
22921
|
+
// @ts-ignore
|
|
22922
|
+
this._htmlCanvas = engine._canvas._webCanvas;
|
|
22880
22923
|
// If there are no compatibility issues, navigator.maxTouchPoints should be used here
|
|
22881
22924
|
this._pointerPool = new Array(11);
|
|
22925
|
+
this._onPointerEvent = this._onPointerEvent.bind(this);
|
|
22926
|
+
this._addEventListener();
|
|
22882
22927
|
};
|
|
22883
22928
|
var _proto = PointerManager.prototype;
|
|
22884
22929
|
/**
|
|
@@ -22948,7 +22993,8 @@
|
|
|
22948
22993
|
var length = events.length;
|
|
22949
22994
|
if (length > 0) {
|
|
22950
22995
|
for(var i1 = 0; i1 < length; i1++){
|
|
22951
|
-
|
|
22996
|
+
var event = events[i1];
|
|
22997
|
+
switch(event.type){
|
|
22952
22998
|
case "pointerdown":
|
|
22953
22999
|
pointer.phase = exports.PointerPhase.Down;
|
|
22954
23000
|
pointer._firePointerDown(rayCastEntity);
|
|
@@ -22970,66 +23016,14 @@
|
|
|
22970
23016
|
};
|
|
22971
23017
|
/**
|
|
22972
23018
|
* @internal
|
|
22973
|
-
*/ _proto._onFocus = function _onFocus() {
|
|
22974
|
-
if (!this._hadListener) {
|
|
22975
|
-
var _this = this, htmlCanvas = _this._htmlCanvas, onPointerEvent = _this._onPointerEvent;
|
|
22976
|
-
htmlCanvas.addEventListener("pointerdown", onPointerEvent);
|
|
22977
|
-
htmlCanvas.addEventListener("pointerup", onPointerEvent);
|
|
22978
|
-
htmlCanvas.addEventListener("pointerleave", onPointerEvent);
|
|
22979
|
-
htmlCanvas.addEventListener("pointermove", onPointerEvent);
|
|
22980
|
-
htmlCanvas.addEventListener("pointercancel", onPointerEvent);
|
|
22981
|
-
this._hadListener = true;
|
|
22982
|
-
}
|
|
22983
|
-
};
|
|
22984
|
-
/**
|
|
22985
|
-
* @internal
|
|
22986
|
-
*/ _proto._onBlur = function _onBlur() {
|
|
22987
|
-
if (this._hadListener) {
|
|
22988
|
-
var _this = this, htmlCanvas = _this._htmlCanvas, onPointerEvent = _this._onPointerEvent;
|
|
22989
|
-
htmlCanvas.removeEventListener("pointerdown", onPointerEvent);
|
|
22990
|
-
htmlCanvas.removeEventListener("pointerup", onPointerEvent);
|
|
22991
|
-
htmlCanvas.removeEventListener("pointerleave", onPointerEvent);
|
|
22992
|
-
htmlCanvas.removeEventListener("pointermove", onPointerEvent);
|
|
22993
|
-
htmlCanvas.removeEventListener("pointercancel", onPointerEvent);
|
|
22994
|
-
this._hadListener = false;
|
|
22995
|
-
this._pointers.length = 0;
|
|
22996
|
-
this._downList.length = 0;
|
|
22997
|
-
this._upList.length = 0;
|
|
22998
|
-
}
|
|
22999
|
-
};
|
|
23000
|
-
/**
|
|
23001
|
-
* @internal
|
|
23002
23019
|
*/ _proto._destroy = function _destroy() {
|
|
23003
|
-
|
|
23004
|
-
if (this._hadListener) {
|
|
23005
|
-
var _this = this, htmlCanvas = _this._htmlCanvas, onPointerEvent = _this._onPointerEvent;
|
|
23006
|
-
htmlCanvas.removeEventListener("pointerdown", onPointerEvent);
|
|
23007
|
-
htmlCanvas.removeEventListener("pointerup", onPointerEvent);
|
|
23008
|
-
htmlCanvas.removeEventListener("pointerleave", onPointerEvent);
|
|
23009
|
-
htmlCanvas.removeEventListener("pointermove", onPointerEvent);
|
|
23010
|
-
htmlCanvas.removeEventListener("pointercancel", onPointerEvent);
|
|
23011
|
-
this._hadListener = false;
|
|
23012
|
-
}
|
|
23020
|
+
this._removeEventListener();
|
|
23013
23021
|
this._pointerPool.length = 0;
|
|
23014
|
-
this._pointerPool = null;
|
|
23015
|
-
this._pointers.length = 0;
|
|
23016
|
-
this._pointers = null;
|
|
23017
|
-
this._downList.length = 0;
|
|
23018
|
-
this._downList = null;
|
|
23019
|
-
this._upList.length = 0;
|
|
23020
|
-
this._upList = null;
|
|
23021
23022
|
this._nativeEvents.length = 0;
|
|
23022
|
-
this._nativeEvents = null;
|
|
23023
|
-
this._upMap.length = 0;
|
|
23024
|
-
this._upMap = null;
|
|
23025
23023
|
this._downMap.length = 0;
|
|
23026
|
-
this.
|
|
23027
|
-
this._htmlCanvas = null;
|
|
23028
|
-
this._canvas = null;
|
|
23029
|
-
this._engine = null;
|
|
23024
|
+
this._upMap.length = 0;
|
|
23030
23025
|
};
|
|
23031
23026
|
_proto._onPointerEvent = function _onPointerEvent(evt) {
|
|
23032
|
-
evt.type === "pointerdown" && this._htmlCanvas.focus();
|
|
23033
23027
|
this._nativeEvents.push(evt);
|
|
23034
23028
|
};
|
|
23035
23029
|
_proto._getPointerByID = function _getPointerByID(pointerId) {
|
|
@@ -23112,6 +23106,26 @@
|
|
|
23112
23106
|
}
|
|
23113
23107
|
return null;
|
|
23114
23108
|
};
|
|
23109
|
+
_proto._addEventListener = function _addEventListener() {
|
|
23110
|
+
var _this = this, target = _this._target, onPointerEvent = _this._onPointerEvent;
|
|
23111
|
+
target.addEventListener("pointerdown", onPointerEvent);
|
|
23112
|
+
target.addEventListener("pointerup", onPointerEvent);
|
|
23113
|
+
target.addEventListener("pointerleave", onPointerEvent);
|
|
23114
|
+
target.addEventListener("pointermove", onPointerEvent);
|
|
23115
|
+
target.addEventListener("pointercancel", onPointerEvent);
|
|
23116
|
+
};
|
|
23117
|
+
_proto._removeEventListener = function _removeEventListener() {
|
|
23118
|
+
var _this = this, target = _this._target, onPointerEvent = _this._onPointerEvent;
|
|
23119
|
+
target.removeEventListener("pointerdown", onPointerEvent);
|
|
23120
|
+
target.removeEventListener("pointerup", onPointerEvent);
|
|
23121
|
+
target.removeEventListener("pointerleave", onPointerEvent);
|
|
23122
|
+
target.removeEventListener("pointermove", onPointerEvent);
|
|
23123
|
+
target.removeEventListener("pointercancel", onPointerEvent);
|
|
23124
|
+
this._nativeEvents.length = 0;
|
|
23125
|
+
this._pointers.length = 0;
|
|
23126
|
+
this._downList.length = 0;
|
|
23127
|
+
this._upList.length = 0;
|
|
23128
|
+
};
|
|
23115
23129
|
return PointerManager;
|
|
23116
23130
|
}();
|
|
23117
23131
|
(function() {
|
|
@@ -23127,15 +23141,12 @@
|
|
|
23127
23141
|
* Wheel Manager.
|
|
23128
23142
|
* @internal
|
|
23129
23143
|
*/ var WheelManager = /*#__PURE__*/ function() {
|
|
23130
|
-
var WheelManager = function WheelManager(engine) {
|
|
23144
|
+
var WheelManager = function WheelManager(engine, target) {
|
|
23131
23145
|
/** @internal */ this._delta = new Vector3();
|
|
23132
23146
|
this._nativeEvents = [];
|
|
23133
|
-
// @ts-ignore
|
|
23134
|
-
var htmlCanvas = engine._canvas._webCanvas;
|
|
23135
23147
|
this._onWheelEvent = this._onWheelEvent.bind(this);
|
|
23136
|
-
|
|
23137
|
-
this.
|
|
23138
|
-
this._hadListener = true;
|
|
23148
|
+
this._target = target;
|
|
23149
|
+
this._addEventListener();
|
|
23139
23150
|
};
|
|
23140
23151
|
var _proto = WheelManager.prototype;
|
|
23141
23152
|
/**
|
|
@@ -23156,35 +23167,24 @@
|
|
|
23156
23167
|
};
|
|
23157
23168
|
/**
|
|
23158
23169
|
* @internal
|
|
23159
|
-
*/ _proto.
|
|
23160
|
-
|
|
23161
|
-
this._canvas.addEventListener("wheel", this._onWheelEvent);
|
|
23162
|
-
this._hadListener = true;
|
|
23163
|
-
}
|
|
23170
|
+
*/ _proto._addEventListener = function _addEventListener() {
|
|
23171
|
+
this._target.addEventListener("wheel", this._onWheelEvent);
|
|
23164
23172
|
};
|
|
23165
23173
|
/**
|
|
23166
23174
|
* @internal
|
|
23167
|
-
*/ _proto.
|
|
23168
|
-
|
|
23169
|
-
|
|
23170
|
-
|
|
23171
|
-
this._delta.set(0, 0, 0);
|
|
23172
|
-
this._hadListener = false;
|
|
23173
|
-
}
|
|
23175
|
+
*/ _proto._removeEventListener = function _removeEventListener() {
|
|
23176
|
+
this._target.removeEventListener("wheel", this._onWheelEvent);
|
|
23177
|
+
this._nativeEvents.length = 0;
|
|
23178
|
+
this._delta.set(0, 0, 0);
|
|
23174
23179
|
};
|
|
23175
23180
|
/**
|
|
23176
23181
|
* @internal
|
|
23177
23182
|
*/ _proto._destroy = function _destroy() {
|
|
23178
|
-
|
|
23179
|
-
this._canvas.removeEventListener("wheel", this._onWheelEvent);
|
|
23180
|
-
this._hadListener = false;
|
|
23181
|
-
}
|
|
23183
|
+
this._removeEventListener();
|
|
23182
23184
|
this._nativeEvents = null;
|
|
23183
|
-
this._canvas = null;
|
|
23184
23185
|
this._delta = null;
|
|
23185
23186
|
};
|
|
23186
23187
|
_proto._onWheelEvent = function _onWheelEvent(evt) {
|
|
23187
|
-
evt.cancelable && evt.preventDefault();
|
|
23188
23188
|
this._nativeEvents.push(evt);
|
|
23189
23189
|
};
|
|
23190
23190
|
return WheelManager;
|
|
@@ -23192,19 +23192,19 @@
|
|
|
23192
23192
|
/**
|
|
23193
23193
|
* InputManager manages device input such as mouse, touch, keyboard, etc.
|
|
23194
23194
|
*/ var InputManager = /*#__PURE__*/ function() {
|
|
23195
|
-
var InputManager = function InputManager(engine) {
|
|
23195
|
+
var InputManager = function InputManager(engine, inputOptions) {
|
|
23196
23196
|
/** Sometimes the input module will not be initialized, such as off-screen rendering. */ this._initialized = false;
|
|
23197
23197
|
this._engine = engine;
|
|
23198
23198
|
// @ts-ignore
|
|
23199
23199
|
var canvas = engine._canvas._webCanvas;
|
|
23200
23200
|
if (typeof OffscreenCanvas === "undefined" || !_instanceof1$2(canvas, OffscreenCanvas)) {
|
|
23201
|
-
|
|
23202
|
-
|
|
23203
|
-
this.
|
|
23204
|
-
|
|
23205
|
-
|
|
23206
|
-
|
|
23207
|
-
|
|
23201
|
+
var _inputOptions, _inputOptions1, _inputOptions2;
|
|
23202
|
+
var _inputOptions_wheelTarget;
|
|
23203
|
+
this._wheelManager = new WheelManager(engine, (_inputOptions_wheelTarget = (_inputOptions = inputOptions) == null ? void 0 : _inputOptions.wheelTarget) != null ? _inputOptions_wheelTarget : canvas);
|
|
23204
|
+
var _inputOptions_pointerTarget;
|
|
23205
|
+
this._pointerManager = new PointerManager(engine, (_inputOptions_pointerTarget = (_inputOptions1 = inputOptions) == null ? void 0 : _inputOptions1.pointerTarget) != null ? _inputOptions_pointerTarget : canvas);
|
|
23206
|
+
var _inputOptions_keyboardTarget;
|
|
23207
|
+
this._keyboardManager = new KeyboardManager(engine, (_inputOptions_keyboardTarget = (_inputOptions2 = inputOptions) == null ? void 0 : _inputOptions2.keyboardTarget) != null ? _inputOptions_keyboardTarget : window);
|
|
23208
23208
|
this._initialized = true;
|
|
23209
23209
|
}
|
|
23210
23210
|
};
|
|
@@ -23317,8 +23317,6 @@
|
|
|
23317
23317
|
* @internal
|
|
23318
23318
|
*/ _proto._destroy = function _destroy() {
|
|
23319
23319
|
if (this._initialized) {
|
|
23320
|
-
window.removeEventListener("blur", this._onBlur);
|
|
23321
|
-
window.removeEventListener("focus", this._onFocus);
|
|
23322
23320
|
this._wheelManager._destroy();
|
|
23323
23321
|
this._wheelManager = null;
|
|
23324
23322
|
this._pointerManager._destroy();
|
|
@@ -23327,16 +23325,6 @@
|
|
|
23327
23325
|
this._keyboardManager = null;
|
|
23328
23326
|
}
|
|
23329
23327
|
};
|
|
23330
|
-
_proto._onBlur = function _onBlur() {
|
|
23331
|
-
this._wheelManager._onBlur();
|
|
23332
|
-
this._pointerManager._onBlur();
|
|
23333
|
-
this._keyboardManager._onBlur();
|
|
23334
|
-
};
|
|
23335
|
-
_proto._onFocus = function _onFocus() {
|
|
23336
|
-
this._wheelManager._onFocus();
|
|
23337
|
-
this._pointerManager._onFocus();
|
|
23338
|
-
this._keyboardManager._onFocus();
|
|
23339
|
-
};
|
|
23340
23328
|
_create_class$2(InputManager, [
|
|
23341
23329
|
{
|
|
23342
23330
|
key: "pointers",
|
|
@@ -23686,8 +23674,9 @@
|
|
|
23686
23674
|
}
|
|
23687
23675
|
return;
|
|
23688
23676
|
}
|
|
23677
|
+
++hierarchy;
|
|
23689
23678
|
for(var k1 in cacheMap){
|
|
23690
|
-
this._recursiveDestroy(
|
|
23679
|
+
this._recursiveDestroy(hierarchy, cacheMap[k1]);
|
|
23691
23680
|
}
|
|
23692
23681
|
};
|
|
23693
23682
|
_proto._resizeCacheMapHierarchy = function _resizeCacheMapHierarchy(cacheMap, hierarchy, currentHierarchy, increaseHierarchy) {
|
|
@@ -23803,7 +23792,7 @@
|
|
|
23803
23792
|
_this._spriteMaskDefaultMaterial = _this._createSpriteMaskMaterial();
|
|
23804
23793
|
_this._textDefaultFont = Font.createFromOS(_assert_this_initialized(_this), "Arial");
|
|
23805
23794
|
_this._textDefaultFont.isGCIgnored = true;
|
|
23806
|
-
_this.inputManager = new InputManager(_assert_this_initialized(_this));
|
|
23795
|
+
_this.inputManager = new InputManager(_assert_this_initialized(_this), configuration.input);
|
|
23807
23796
|
var xrDevice = configuration.xrDevice;
|
|
23808
23797
|
if (xrDevice) {
|
|
23809
23798
|
_this.xrManager = new XRManager();
|
|
@@ -24097,6 +24086,26 @@
|
|
|
24097
24086
|
this._magentaTexture2D = magentaTexture2D;
|
|
24098
24087
|
this._magentaTextureCube = magentaTextureCube;
|
|
24099
24088
|
if (hardwareRenderer.isWebGL2) {
|
|
24089
|
+
var magentaPixel32 = new Uint32Array([
|
|
24090
|
+
255,
|
|
24091
|
+
0,
|
|
24092
|
+
255,
|
|
24093
|
+
255
|
|
24094
|
+
]);
|
|
24095
|
+
var uintMagentaTexture2D = new Texture2D(this, 1, 1, exports.TextureFormat.R32G32B32A32_UInt, false);
|
|
24096
|
+
uintMagentaTexture2D.setPixelBuffer(magentaPixel32);
|
|
24097
|
+
uintMagentaTexture2D.isGCIgnored = true;
|
|
24098
|
+
this.resourceManager.addContentRestorer(new /*#__PURE__*/ (function(ContentRestorer) {
|
|
24099
|
+
var _class = function _class() {
|
|
24100
|
+
return ContentRestorer.call(this, uintMagentaTexture2D);
|
|
24101
|
+
};
|
|
24102
|
+
_inherits$2(_class, ContentRestorer);
|
|
24103
|
+
var _proto = _class.prototype;
|
|
24104
|
+
_proto.restoreContent = function restoreContent() {
|
|
24105
|
+
this.resource.setPixelBuffer(magentaPixel32);
|
|
24106
|
+
};
|
|
24107
|
+
return _class;
|
|
24108
|
+
}(ContentRestorer))());
|
|
24100
24109
|
var magentaTexture2DArray = new Texture2DArray(this, 1, 1, 1, exports.TextureFormat.R8G8B8A8, false);
|
|
24101
24110
|
magentaTexture2DArray.setPixelBuffer(0, magentaPixel);
|
|
24102
24111
|
magentaTexture2DArray.isGCIgnored = true;
|
|
@@ -24111,6 +24120,7 @@
|
|
|
24111
24120
|
};
|
|
24112
24121
|
return _class;
|
|
24113
24122
|
}(ContentRestorer))());
|
|
24123
|
+
this._uintMagentaTexture2D = uintMagentaTexture2D;
|
|
24114
24124
|
this._magentaTexture2DArray = magentaTexture2DArray;
|
|
24115
24125
|
}
|
|
24116
24126
|
};
|
|
@@ -24342,8 +24352,8 @@
|
|
|
24342
24352
|
set: function set(value) {
|
|
24343
24353
|
if (this._width !== value) {
|
|
24344
24354
|
this._width = value;
|
|
24355
|
+
this._onWidthChanged(value);
|
|
24345
24356
|
this._sizeUpdateFlagManager.dispatch();
|
|
24346
|
-
this._onSizeChanged(value, this._width);
|
|
24347
24357
|
}
|
|
24348
24358
|
}
|
|
24349
24359
|
},
|
|
@@ -24357,8 +24367,8 @@
|
|
|
24357
24367
|
set: function set(value) {
|
|
24358
24368
|
if (this._height !== value) {
|
|
24359
24369
|
this._height = value;
|
|
24370
|
+
this._onHeightChange(value);
|
|
24360
24371
|
this._sizeUpdateFlagManager.dispatch();
|
|
24361
|
-
this._onSizeChanged(this._width, value);
|
|
24362
24372
|
}
|
|
24363
24373
|
}
|
|
24364
24374
|
}
|
|
@@ -25696,6 +25706,10 @@
|
|
|
25696
25706
|
/** The splits of two cascade distribution. */ _this.shadowTwoCascadeSplits = 1.0 / 3.0;
|
|
25697
25707
|
/** The splits of four cascade distribution. */ _this.shadowFourCascadeSplits = new Vector3(1.0 / 15, 3.0 / 15.0, 7.0 / 15.0);
|
|
25698
25708
|
/** Max Shadow distance. */ _this.shadowDistance = 50;
|
|
25709
|
+
/**
|
|
25710
|
+
* Last shadow fade distance in percentage, range [0,1].
|
|
25711
|
+
* @remarks Value 0 is used for no shadow fade.
|
|
25712
|
+
*/ _this.shadowFadeBorder = 0.1;
|
|
25699
25713
|
/* @internal */ _this._lightManager = new LightManager();
|
|
25700
25714
|
/* @internal */ _this._componentsManager = new ComponentsManager();
|
|
25701
25715
|
/** @internal */ _this._isActiveInEngine = false;
|
|
@@ -26317,47 +26331,65 @@
|
|
|
26317
26331
|
DepthTextureMode[DepthTextureMode[/* No depth texture. */ "None"] = 0] = "None";
|
|
26318
26332
|
DepthTextureMode[DepthTextureMode[/* Generate depth texture by pre-pass rendering. */ "PrePass"] = 1] = "PrePass";
|
|
26319
26333
|
})(exports.DepthTextureMode || (exports.DepthTextureMode = {}));
|
|
26320
|
-
var passNum = 0;
|
|
26321
26334
|
/**
|
|
26322
|
-
*
|
|
26323
|
-
*/ var
|
|
26324
|
-
|
|
26325
|
-
|
|
26326
|
-
|
|
26327
|
-
|
|
26328
|
-
|
|
26329
|
-
|
|
26330
|
-
this.name = name1;
|
|
26331
|
-
this.enabled = true;
|
|
26332
|
-
this.priority = priority;
|
|
26333
|
-
this.renderTarget = renderTarget;
|
|
26334
|
-
this.replaceMaterial = replaceMaterial;
|
|
26335
|
-
this.mask = mask || exports.Layer.Everything;
|
|
26336
|
-
this.renderOverride = false; // If renderOverride is set to true, you need to implement the render method
|
|
26337
|
-
};
|
|
26338
|
-
var _proto = RenderPass.prototype;
|
|
26339
|
-
/**
|
|
26340
|
-
* Rendering callback, will be executed if renderOverride is set to true.
|
|
26341
|
-
* @param camera - Camera
|
|
26342
|
-
* @param opaqueQueue - Opaque queue
|
|
26343
|
-
* @param alphaTestQueue - Alpha test queue
|
|
26344
|
-
* @param transparentQueue - Transparent queue
|
|
26345
|
-
*/ _proto.render = function render(camera, opaqueQueue, alphaTestQueue, transparentQueue) {};
|
|
26335
|
+
* PipelinePass is a base class for all pipeline passes.
|
|
26336
|
+
*/ var PipelinePass = function PipelinePass(engine) {
|
|
26337
|
+
this._engine = engine;
|
|
26338
|
+
};
|
|
26339
|
+
/**
|
|
26340
|
+
* @internal
|
|
26341
|
+
*/ var PipelineUtils = /*#__PURE__*/ function() {
|
|
26342
|
+
var PipelineUtils = function PipelineUtils() {};
|
|
26346
26343
|
/**
|
|
26347
|
-
*
|
|
26348
|
-
* @param
|
|
26349
|
-
* @param
|
|
26350
|
-
* @param
|
|
26351
|
-
* @param
|
|
26352
|
-
|
|
26344
|
+
* Recreate texture if needed.
|
|
26345
|
+
* @param engine - Engine
|
|
26346
|
+
* @param currentTexture - Current texture
|
|
26347
|
+
* @param width - Need texture width
|
|
26348
|
+
* @param height - Need texture height
|
|
26349
|
+
* @param format - Need texture format
|
|
26350
|
+
* @param mipmap - Need texture mipmap
|
|
26351
|
+
* @returns Texture
|
|
26352
|
+
*/ PipelineUtils.recreateTextureIfNeeded = function recreateTextureIfNeeded(engine, currentTexture, width, height, format, mipmap) {
|
|
26353
|
+
if (currentTexture) {
|
|
26354
|
+
if (currentTexture.width !== width || currentTexture.height !== height || currentTexture.format !== format || currentTexture.mipmapCount > 1 !== mipmap) {
|
|
26355
|
+
currentTexture.destroy();
|
|
26356
|
+
var texture = new Texture2D(engine, width, height, format, mipmap);
|
|
26357
|
+
texture.isGCIgnored = true;
|
|
26358
|
+
return texture;
|
|
26359
|
+
} else {
|
|
26360
|
+
return currentTexture;
|
|
26361
|
+
}
|
|
26362
|
+
} else {
|
|
26363
|
+
var texture1 = new Texture2D(engine, width, height, format, mipmap);
|
|
26364
|
+
texture1.isGCIgnored = true;
|
|
26365
|
+
return texture1;
|
|
26366
|
+
}
|
|
26367
|
+
};
|
|
26353
26368
|
/**
|
|
26354
|
-
*
|
|
26355
|
-
* @param
|
|
26356
|
-
* @param
|
|
26357
|
-
* @param
|
|
26358
|
-
* @param
|
|
26359
|
-
|
|
26360
|
-
|
|
26369
|
+
* Recreate render target if needed.
|
|
26370
|
+
* @param engine - Engine
|
|
26371
|
+
* @param currentRenderTarget - Current render target
|
|
26372
|
+
* @param width - Need render target width
|
|
26373
|
+
* @param height - Need render target height
|
|
26374
|
+
* @param colorFormat - Need render target color format
|
|
26375
|
+
* @param depthFormat - Need render target depth format
|
|
26376
|
+
* @param mipmap - Need render target mipmap
|
|
26377
|
+
* @returns Render target
|
|
26378
|
+
*/ PipelineUtils.recreateRenderTargetIfNeeded = function recreateRenderTargetIfNeeded(engine, currentRenderTarget, width, height, colorFormat, depthFormat, mipmap) {
|
|
26379
|
+
var _currentRenderTarget, _currentRenderTarget1;
|
|
26380
|
+
var currentColorTexture = (_currentRenderTarget = currentRenderTarget) == null ? void 0 : _currentRenderTarget.getColorTexture(0);
|
|
26381
|
+
var currentDepthTexture = (_currentRenderTarget1 = currentRenderTarget) == null ? void 0 : _currentRenderTarget1.depthTexture;
|
|
26382
|
+
var colorTexture = colorFormat ? PipelineUtils.recreateTextureIfNeeded(engine, currentColorTexture, width, height, colorFormat, mipmap) : null;
|
|
26383
|
+
var depthTexture = depthFormat ? PipelineUtils.recreateTextureIfNeeded(engine, currentDepthTexture, width, height, depthFormat, mipmap) : null;
|
|
26384
|
+
if (currentColorTexture !== colorTexture || currentDepthTexture !== depthTexture) {
|
|
26385
|
+
var _currentRenderTarget2;
|
|
26386
|
+
(_currentRenderTarget2 = currentRenderTarget) == null ? void 0 : _currentRenderTarget2.destroy();
|
|
26387
|
+
currentRenderTarget = new RenderTarget(engine, width, height, colorTexture, depthTexture);
|
|
26388
|
+
currentRenderTarget.isGCIgnored = true;
|
|
26389
|
+
}
|
|
26390
|
+
return currentRenderTarget;
|
|
26391
|
+
};
|
|
26392
|
+
return PipelineUtils;
|
|
26361
26393
|
}();
|
|
26362
26394
|
/**
|
|
26363
26395
|
* @internal
|
|
@@ -26626,9 +26658,14 @@
|
|
|
26626
26658
|
}
|
|
26627
26659
|
// make suer from the same renderer.
|
|
26628
26660
|
if (componentA.instanceId === componentB.instanceId) {
|
|
26629
|
-
return dataA.material._priority - dataB.material._priority
|
|
26661
|
+
return dataA.material._priority - dataB.material._priority;
|
|
26630
26662
|
} else {
|
|
26631
|
-
|
|
26663
|
+
var distanceDiff = componentA._distanceForSort - componentB._distanceForSort;
|
|
26664
|
+
if (distanceDiff === 0) {
|
|
26665
|
+
return componentA.instanceId - componentB.instanceId;
|
|
26666
|
+
} else {
|
|
26667
|
+
return distanceDiff;
|
|
26668
|
+
}
|
|
26632
26669
|
}
|
|
26633
26670
|
};
|
|
26634
26671
|
/**
|
|
@@ -26644,67 +26681,59 @@
|
|
|
26644
26681
|
}
|
|
26645
26682
|
// make suer from the same renderer.
|
|
26646
26683
|
if (componentA.instanceId === componentB.instanceId) {
|
|
26647
|
-
return dataA.material._priority - dataB.material._priority
|
|
26684
|
+
return dataA.material._priority - dataB.material._priority;
|
|
26648
26685
|
} else {
|
|
26649
|
-
|
|
26686
|
+
var distanceDiff = componentB._distanceForSort - componentA._distanceForSort;
|
|
26687
|
+
if (distanceDiff === 0) {
|
|
26688
|
+
return componentA.instanceId - componentB.instanceId;
|
|
26689
|
+
} else {
|
|
26690
|
+
return distanceDiff;
|
|
26691
|
+
}
|
|
26650
26692
|
}
|
|
26651
26693
|
};
|
|
26652
26694
|
return RenderQueue;
|
|
26653
26695
|
}();
|
|
26696
|
+
var passNum = 0;
|
|
26654
26697
|
/**
|
|
26655
|
-
*
|
|
26656
|
-
*/ var
|
|
26657
|
-
var
|
|
26658
|
-
|
|
26659
|
-
|
|
26660
|
-
|
|
26661
|
-
|
|
26662
|
-
|
|
26663
|
-
|
|
26664
|
-
|
|
26665
|
-
|
|
26666
|
-
|
|
26667
|
-
|
|
26668
|
-
|
|
26669
|
-
|
|
26670
|
-
currentTexture.destroy();
|
|
26671
|
-
var texture = new Texture2D(engine, width, height, format, mipmap);
|
|
26672
|
-
texture.isGCIgnored = true;
|
|
26673
|
-
return texture;
|
|
26674
|
-
} else {
|
|
26675
|
-
return currentTexture;
|
|
26676
|
-
}
|
|
26677
|
-
} else {
|
|
26678
|
-
var texture1 = new Texture2D(engine, width, height, format, mipmap);
|
|
26679
|
-
texture1.isGCIgnored = true;
|
|
26680
|
-
return texture1;
|
|
26681
|
-
}
|
|
26698
|
+
* RenderPass.
|
|
26699
|
+
*/ var RenderPass = /*#__PURE__*/ function() {
|
|
26700
|
+
var RenderPass = function RenderPass(name1, priority, renderTarget, replaceMaterial, mask) {
|
|
26701
|
+
if (name1 === void 0) name1 = "RENDER_PASS" + passNum++;
|
|
26702
|
+
if (priority === void 0) priority = 0;
|
|
26703
|
+
if (renderTarget === void 0) renderTarget = null;
|
|
26704
|
+
if (replaceMaterial === void 0) replaceMaterial = null;
|
|
26705
|
+
if (mask === void 0) mask = null;
|
|
26706
|
+
this.name = name1;
|
|
26707
|
+
this.enabled = true;
|
|
26708
|
+
this.priority = priority;
|
|
26709
|
+
this.renderTarget = renderTarget;
|
|
26710
|
+
this.replaceMaterial = replaceMaterial;
|
|
26711
|
+
this.mask = mask || exports.Layer.Everything;
|
|
26712
|
+
this.renderOverride = false; // If renderOverride is set to true, you need to implement the render method
|
|
26682
26713
|
};
|
|
26714
|
+
var _proto = RenderPass.prototype;
|
|
26683
26715
|
/**
|
|
26684
|
-
*
|
|
26685
|
-
* @param
|
|
26686
|
-
* @param
|
|
26687
|
-
* @param
|
|
26688
|
-
* @param
|
|
26689
|
-
|
|
26690
|
-
|
|
26691
|
-
*
|
|
26692
|
-
* @
|
|
26693
|
-
|
|
26694
|
-
|
|
26695
|
-
|
|
26696
|
-
|
|
26697
|
-
|
|
26698
|
-
|
|
26699
|
-
|
|
26700
|
-
|
|
26701
|
-
|
|
26702
|
-
|
|
26703
|
-
|
|
26704
|
-
|
|
26705
|
-
return currentRenderTarget;
|
|
26706
|
-
};
|
|
26707
|
-
return PipelineUtils;
|
|
26716
|
+
* Rendering callback, will be executed if renderOverride is set to true.
|
|
26717
|
+
* @param camera - Camera
|
|
26718
|
+
* @param opaqueQueue - Opaque queue
|
|
26719
|
+
* @param alphaTestQueue - Alpha test queue
|
|
26720
|
+
* @param transparentQueue - Transparent queue
|
|
26721
|
+
*/ _proto.render = function render(camera, opaqueQueue, alphaTestQueue, transparentQueue) {};
|
|
26722
|
+
/**
|
|
26723
|
+
* Post rendering callback.
|
|
26724
|
+
* @param camera - Camera
|
|
26725
|
+
* @param opaqueQueue - Opaque queue
|
|
26726
|
+
* @param alphaTestQueue - Alpha test queue
|
|
26727
|
+
* @param transparentQueue - Transparent queue
|
|
26728
|
+
*/ _proto.preRender = function preRender(camera, opaqueQueue, alphaTestQueue, transparentQueue) {};
|
|
26729
|
+
/**
|
|
26730
|
+
* Post rendering callback.
|
|
26731
|
+
* @param camera - Camera
|
|
26732
|
+
* @param opaqueQueue - Opaque queue
|
|
26733
|
+
* @param alphaTestQueue - Alpha test queue
|
|
26734
|
+
* @param transparentQueue - Transparent queue
|
|
26735
|
+
*/ _proto.postRender = function postRender(camera, opaqueQueue, alphaTestQueue, transparentQueue) {};
|
|
26736
|
+
return RenderPass;
|
|
26708
26737
|
}();
|
|
26709
26738
|
/**
|
|
26710
26739
|
* @internal
|
|
@@ -26969,6 +26998,26 @@
|
|
|
26969
26998
|
var offset = cascadeIndex * 16;
|
|
26970
26999
|
Utils._floatMatrixMultiply(sliceMatrix, outShadowMatrices, offset, outShadowMatrices, offset);
|
|
26971
27000
|
};
|
|
27001
|
+
/**
|
|
27002
|
+
* Extract scale and bias from a fade distance to achieve a linear fading of the fade distance.
|
|
27003
|
+
*/ ShadowUtils.getScaleAndBiasForLinearDistanceFade = function getScaleAndBiasForLinearDistanceFade(fadeDistance, border, outInfo) {
|
|
27004
|
+
// (P^2-N^2)/(F^2-N^2)
|
|
27005
|
+
// To avoid division from zero
|
|
27006
|
+
// This values ensure that fade within cascade will be 0 and outside 1
|
|
27007
|
+
if (border < 0.0001) {
|
|
27008
|
+
var multiplier = 1000; // To avoid blending if difference is in fractions
|
|
27009
|
+
outInfo.z = multiplier;
|
|
27010
|
+
outInfo.w = -fadeDistance * multiplier;
|
|
27011
|
+
return;
|
|
27012
|
+
}
|
|
27013
|
+
border = 1 - border;
|
|
27014
|
+
border *= border;
|
|
27015
|
+
// Fade with distance calculation is just a linear fade from 90% of fade distance to fade distance. 90% arbitrarily chosen but should work well enough.
|
|
27016
|
+
var distanceFadeNear = border * fadeDistance;
|
|
27017
|
+
var fadeRange = fadeDistance - distanceFadeNear;
|
|
27018
|
+
outInfo.z = 1.0 / fadeRange;
|
|
27019
|
+
outInfo.w = -distanceFadeNear / fadeRange;
|
|
27020
|
+
};
|
|
26972
27021
|
return ShadowUtils;
|
|
26973
27022
|
}();
|
|
26974
27023
|
(function() {
|
|
@@ -27212,11 +27261,6 @@
|
|
|
27212
27261
|
//now max shadow sample tent is 5x5, atlas borderSize at least 3=ceil(2.5),and +1 pixel is for global border for no cascade mode.
|
|
27213
27262
|
ShadowUtils.atlasBorderSize = 4.0;
|
|
27214
27263
|
})();
|
|
27215
|
-
/**
|
|
27216
|
-
* PipelinePass is a base class for all pipeline passes.
|
|
27217
|
-
*/ var PipelinePass = function PipelinePass(engine) {
|
|
27218
|
-
this._engine = engine;
|
|
27219
|
-
};
|
|
27220
27264
|
/**
|
|
27221
27265
|
* Cascade shadow caster pass.
|
|
27222
27266
|
*/ var CascadedShadowCasterPass = /*#__PURE__*/ function(PipelinePass1) {
|
|
@@ -27229,11 +27273,10 @@
|
|
|
27229
27273
|
_this._shadowSliceData = new ShadowSliceData();
|
|
27230
27274
|
_this._lightUp = new Vector3();
|
|
27231
27275
|
_this._lightSide = new Vector3();
|
|
27232
|
-
_this._existShadowMap = false;
|
|
27233
27276
|
_this._splitBoundSpheres = new Float32Array(CascadedShadowCasterPass._maxCascades * 4);
|
|
27234
27277
|
/** The end is project precision problem in shader. */ _this._shadowMatrices = new Float32Array((CascadedShadowCasterPass._maxCascades + 1) * 16);
|
|
27235
|
-
//
|
|
27236
|
-
_this._shadowInfos = new
|
|
27278
|
+
// intensity, null, fadeScale, fadeBias
|
|
27279
|
+
_this._shadowInfos = new Vector4();
|
|
27237
27280
|
_this._viewportOffsets = [
|
|
27238
27281
|
new Vector2(),
|
|
27239
27282
|
new Vector2(),
|
|
@@ -27249,14 +27292,12 @@
|
|
|
27249
27292
|
/**
|
|
27250
27293
|
* @internal
|
|
27251
27294
|
*/ _proto.onRender = function onRender(context) {
|
|
27295
|
+
var light = this._camera.scene._lightManager._sunlight;
|
|
27252
27296
|
this._updateShadowSettings();
|
|
27253
|
-
this.
|
|
27254
|
-
this.
|
|
27255
|
-
if (this._existShadowMap) {
|
|
27256
|
-
this._updateReceiversShaderData();
|
|
27257
|
-
}
|
|
27297
|
+
this._renderDirectShadowMap(context, light);
|
|
27298
|
+
this._updateReceiversShaderData(light);
|
|
27258
27299
|
};
|
|
27259
|
-
_proto._renderDirectShadowMap = function _renderDirectShadowMap(context) {
|
|
27300
|
+
_proto._renderDirectShadowMap = function _renderDirectShadowMap(context, light) {
|
|
27260
27301
|
var _this = this, engine = _this._engine, camera = _this._camera, viewports = _this._viewportOffsets, shadowSliceData = _this._shadowSliceData, splitBoundSpheres = _this._splitBoundSpheres, shadowMatrices = _this._shadowMatrices;
|
|
27261
27302
|
var _camera__renderPipeline__cullingResults = camera._renderPipeline._cullingResults, opaqueQueue = _camera__renderPipeline__cullingResults.opaqueQueue, alphaTestQueue = _camera__renderPipeline__cullingResults.alphaTestQueue, transparentQueue = _camera__renderPipeline__cullingResults.transparentQueue;
|
|
27262
27303
|
var scene = camera.scene;
|
|
@@ -27270,91 +27311,87 @@
|
|
|
27270
27311
|
var lightUp = this._lightUp;
|
|
27271
27312
|
var lightSide = this._lightSide;
|
|
27272
27313
|
var lightForward = shadowSliceData.virtualCamera.forward;
|
|
27273
|
-
|
|
27274
|
-
|
|
27275
|
-
|
|
27276
|
-
|
|
27277
|
-
|
|
27278
|
-
|
|
27279
|
-
|
|
27280
|
-
|
|
27281
|
-
|
|
27282
|
-
|
|
27283
|
-
|
|
27284
|
-
|
|
27285
|
-
|
|
27286
|
-
|
|
27287
|
-
|
|
27288
|
-
|
|
27289
|
-
|
|
27290
|
-
|
|
27291
|
-
|
|
27292
|
-
|
|
27293
|
-
|
|
27294
|
-
|
|
27295
|
-
|
|
27296
|
-
rhi.
|
|
27297
|
-
|
|
27298
|
-
|
|
27299
|
-
|
|
27300
|
-
|
|
27301
|
-
|
|
27302
|
-
|
|
27303
|
-
|
|
27304
|
-
|
|
27305
|
-
|
|
27306
|
-
|
|
27307
|
-
|
|
27308
|
-
|
|
27309
|
-
|
|
27310
|
-
|
|
27311
|
-
|
|
27312
|
-
|
|
27313
|
-
|
|
27314
|
-
|
|
27315
|
-
|
|
27316
|
-
|
|
27317
|
-
|
|
27318
|
-
|
|
27319
|
-
|
|
27320
|
-
|
|
27321
|
-
|
|
27322
|
-
|
|
27323
|
-
|
|
27324
|
-
|
|
27325
|
-
|
|
27326
|
-
|
|
27327
|
-
|
|
27328
|
-
|
|
27329
|
-
|
|
27330
|
-
|
|
27331
|
-
|
|
27332
|
-
|
|
27333
|
-
|
|
27334
|
-
|
|
27335
|
-
|
|
27336
|
-
|
|
27337
|
-
|
|
27338
|
-
|
|
27339
|
-
|
|
27340
|
-
|
|
27341
|
-
|
|
27342
|
-
|
|
27343
|
-
|
|
27344
|
-
|
|
27345
|
-
|
|
27346
|
-
|
|
27347
|
-
|
|
27348
|
-
}
|
|
27349
|
-
}
|
|
27350
|
-
this._existShadowMap = true;
|
|
27351
|
-
}
|
|
27352
|
-
};
|
|
27353
|
-
_proto._updateReceiversShaderData = function _updateReceiversShaderData() {
|
|
27354
|
-
var scene = this._camera.scene;
|
|
27314
|
+
// Prepare render target
|
|
27315
|
+
var _this__shadowMapSize = this._shadowMapSize, width = _this__shadowMapSize.z, height = _this__shadowMapSize.w;
|
|
27316
|
+
var format = this._shadowMapFormat;
|
|
27317
|
+
var renderTarget;
|
|
27318
|
+
var shadowTexture;
|
|
27319
|
+
if (this._supportDepthTexture) {
|
|
27320
|
+
renderTarget = PipelineUtils.recreateRenderTargetIfNeeded(engine, this._renderTarget, width, height, null, format, false);
|
|
27321
|
+
shadowTexture = renderTarget.depthTexture;
|
|
27322
|
+
} else {
|
|
27323
|
+
renderTarget = PipelineUtils.recreateRenderTargetIfNeeded(engine, this._renderTarget, width, height, format, null, false);
|
|
27324
|
+
shadowTexture = renderTarget.getColorTexture(0);
|
|
27325
|
+
}
|
|
27326
|
+
shadowTexture.wrapModeU = shadowTexture.wrapModeV = exports.TextureWrapMode.Clamp;
|
|
27327
|
+
if (engine._hardwareRenderer._isWebGL2) {
|
|
27328
|
+
shadowTexture.depthCompareFunction = exports.TextureDepthCompareFunction.Less;
|
|
27329
|
+
}
|
|
27330
|
+
this._renderTarget = renderTarget;
|
|
27331
|
+
this._depthTexture = shadowTexture;
|
|
27332
|
+
// @todo: shouldn't set viewport and scissor in activeRenderTarget
|
|
27333
|
+
rhi.activeRenderTarget(renderTarget, CascadedShadowCasterPass._viewport, 0);
|
|
27334
|
+
if (this._supportDepthTexture) {
|
|
27335
|
+
rhi.clearRenderTarget(engine, exports.CameraClearFlags.Depth, null);
|
|
27336
|
+
} else {
|
|
27337
|
+
rhi.clearRenderTarget(engine, exports.CameraClearFlags.All, CascadedShadowCasterPass._clearColor);
|
|
27338
|
+
}
|
|
27339
|
+
// prepare light and camera direction
|
|
27340
|
+
Matrix.rotationQuaternion(light.entity.transform.worldRotationQuaternion, lightWorld);
|
|
27341
|
+
lightSide.set(lightWorldE[0], lightWorldE[1], lightWorldE[2]);
|
|
27342
|
+
lightUp.set(lightWorldE[4], lightWorldE[5], lightWorldE[6]);
|
|
27343
|
+
lightForward.set(-lightWorldE[8], -lightWorldE[9], -lightWorldE[10]);
|
|
27344
|
+
var cameraForward = CascadedShadowCasterPass._tempVector;
|
|
27345
|
+
cameraForward.copyFrom(camera.entity.transform.worldForward);
|
|
27346
|
+
var shadowTileResolution = this._shadowTileResolution;
|
|
27347
|
+
for(var j = 0; j < shadowCascades; j++){
|
|
27348
|
+
ShadowUtils.getBoundSphereByFrustum(splitDistance[j], splitDistance[j + 1], camera, cameraForward, shadowSliceData);
|
|
27349
|
+
ShadowUtils.getDirectionLightShadowCullPlanes(camera._frustum, splitDistance[j], camera.nearClipPlane, lightForward, shadowSliceData);
|
|
27350
|
+
ShadowUtils.getDirectionalLightMatrices(lightUp, lightSide, lightForward, j, light.shadowNearPlane, shadowTileResolution, shadowSliceData, shadowMatrices);
|
|
27351
|
+
if (shadowCascades > 1) {
|
|
27352
|
+
ShadowUtils.applySliceTransform(shadowTileResolution, width, height, j, this._viewportOffsets[j], shadowMatrices);
|
|
27353
|
+
}
|
|
27354
|
+
this._updateSingleShadowCasterShaderData(light, shadowSliceData, context);
|
|
27355
|
+
// upload pre-cascade infos.
|
|
27356
|
+
var center = boundSphere.center;
|
|
27357
|
+
var radius = boundSphere.radius;
|
|
27358
|
+
var offset = j * 4;
|
|
27359
|
+
splitBoundSpheres[offset] = center.x;
|
|
27360
|
+
splitBoundSpheres[offset + 1] = center.y;
|
|
27361
|
+
splitBoundSpheres[offset + 2] = center.z;
|
|
27362
|
+
splitBoundSpheres[offset + 3] = radius * radius;
|
|
27363
|
+
opaqueQueue.clear();
|
|
27364
|
+
alphaTestQueue.clear();
|
|
27365
|
+
transparentQueue.clear();
|
|
27366
|
+
var renderers = componentsManager._renderers;
|
|
27367
|
+
var elements = renderers._elements;
|
|
27368
|
+
for(var k = renderers.length - 1; k >= 0; --k){
|
|
27369
|
+
ShadowUtils.shadowCullFrustum(context, light, elements[k], shadowSliceData);
|
|
27370
|
+
}
|
|
27371
|
+
if (opaqueQueue.elements.length || alphaTestQueue.elements.length) {
|
|
27372
|
+
opaqueQueue.sort(RenderQueue._compareFromNearToFar);
|
|
27373
|
+
alphaTestQueue.sort(RenderQueue._compareFromNearToFar);
|
|
27374
|
+
var _viewports_j = viewports[j], x = _viewports_j.x, y = _viewports_j.y;
|
|
27375
|
+
rhi.setGlobalDepthBias(1.0, 1.0);
|
|
27376
|
+
rhi.viewport(x, y, shadowTileResolution, shadowTileResolution);
|
|
27377
|
+
// for no cascade is for the edge,for cascade is for the beyond maxCascade pixel can use (0,0,0) trick sample the shadowMap
|
|
27378
|
+
rhi.scissor(x + 1, y + 1, shadowTileResolution - 2, shadowTileResolution - 2);
|
|
27379
|
+
engine._renderCount++;
|
|
27380
|
+
opaqueQueue.render(camera, exports.Layer.Everything, exports.PipelineStage.ShadowCaster);
|
|
27381
|
+
alphaTestQueue.render(camera, exports.Layer.Everything, exports.PipelineStage.ShadowCaster);
|
|
27382
|
+
rhi.setGlobalDepthBias(0, 0);
|
|
27383
|
+
}
|
|
27384
|
+
}
|
|
27385
|
+
};
|
|
27386
|
+
_proto._updateReceiversShaderData = function _updateReceiversShaderData(light) {
|
|
27387
|
+
var camera = this._camera;
|
|
27388
|
+
var scene = camera.scene;
|
|
27355
27389
|
var splitBoundSpheres = this._splitBoundSpheres;
|
|
27356
27390
|
var shadowMatrices = this._shadowMatrices;
|
|
27357
27391
|
var shadowCascades = scene.shadowCascades;
|
|
27392
|
+
var shadowFar = Math.min(scene.shadowDistance, camera.farClipPlane);
|
|
27393
|
+
ShadowUtils.getScaleAndBiasForLinearDistanceFade(Math.pow(shadowFar, 2), scene.shadowFadeBorder, this._shadowInfos);
|
|
27394
|
+
this._shadowInfos.x = light.shadowStrength;
|
|
27358
27395
|
// set zero matrix to project the index out of max cascade
|
|
27359
27396
|
if (shadowCascades > 1) {
|
|
27360
27397
|
for(var i = shadowCascades * 4, n = splitBoundSpheres.length; i < n; i++){
|
|
@@ -27367,7 +27404,7 @@
|
|
|
27367
27404
|
}
|
|
27368
27405
|
var shaderData = scene.shaderData;
|
|
27369
27406
|
shaderData.setFloatArray(CascadedShadowCasterPass._shadowMatricesProperty, this._shadowMatrices);
|
|
27370
|
-
shaderData.
|
|
27407
|
+
shaderData.setVector4(CascadedShadowCasterPass._shadowInfosProperty, this._shadowInfos);
|
|
27371
27408
|
shaderData.setTexture(CascadedShadowCasterPass._shadowMapsProperty, this._depthTexture);
|
|
27372
27409
|
shaderData.setFloatArray(CascadedShadowCasterPass._shadowSplitSpheresProperty, this._splitBoundSpheres);
|
|
27373
27410
|
shaderData.setVector4(CascadedShadowCasterPass._shadowMapSize, this._shadowMapSize);
|
|
@@ -27403,10 +27440,13 @@
|
|
|
27403
27440
|
return Math.sqrt(radius * radius / denominator);
|
|
27404
27441
|
};
|
|
27405
27442
|
_proto._updateShadowSettings = function _updateShadowSettings() {
|
|
27406
|
-
var
|
|
27443
|
+
var camera = this._camera;
|
|
27444
|
+
var scene = camera.scene;
|
|
27407
27445
|
var shadowFormat = ShadowUtils.shadowDepthFormat(scene.shadowResolution, this._supportDepthTexture);
|
|
27408
27446
|
var shadowResolution = ShadowUtils.shadowResolution(scene.shadowResolution);
|
|
27409
27447
|
var shadowCascades = scene.shadowCascades;
|
|
27448
|
+
var shadowFar = Math.min(scene.shadowDistance, camera.farClipPlane);
|
|
27449
|
+
this._getCascadesSplitDistance(shadowFar);
|
|
27410
27450
|
if (shadowFormat !== this._shadowMapFormat || shadowResolution !== this._shadowMapResolution || shadowCascades !== this._shadowCascadeMode) {
|
|
27411
27451
|
this._shadowMapFormat = shadowFormat;
|
|
27412
27452
|
this._shadowMapResolution = shadowResolution;
|
|
@@ -27847,14 +27887,14 @@
|
|
|
27847
27887
|
/** @internal */ _this._cameraIndex = -1;
|
|
27848
27888
|
_this._priority = 0;
|
|
27849
27889
|
_this._shaderData = new ShaderData(ShaderDataGroup.Camera);
|
|
27850
|
-
_this.
|
|
27890
|
+
_this._isCustomViewMatrix = false;
|
|
27891
|
+
_this._isCustomProjectionMatrix = false;
|
|
27851
27892
|
_this._nearClipPlane = 0.1;
|
|
27852
27893
|
_this._farClipPlane = 100;
|
|
27853
27894
|
_this._fieldOfView = 45;
|
|
27854
27895
|
_this._orthographicSize = 10;
|
|
27855
27896
|
_this._isProjectionDirty = true;
|
|
27856
27897
|
_this._isInvProjMatDirty = true;
|
|
27857
|
-
_this._isFrustumProjectDirty = true;
|
|
27858
27898
|
_this._customAspectRatio = undefined;
|
|
27859
27899
|
_this._renderTarget = null;
|
|
27860
27900
|
_this._depthBufferParams = new Vector4();
|
|
@@ -27866,7 +27906,7 @@
|
|
|
27866
27906
|
_this._transform = transform;
|
|
27867
27907
|
_this._isViewMatrixDirty = transform.registerWorldChangeFlag();
|
|
27868
27908
|
_this._isInvViewProjDirty = transform.registerWorldChangeFlag();
|
|
27869
|
-
_this.
|
|
27909
|
+
_this._frustumChangeFlag = transform.registerWorldChangeFlag();
|
|
27870
27910
|
_this._renderPipeline = new BasicRenderPipeline(_assert_this_initialized(_this));
|
|
27871
27911
|
_this._addResourceReferCount(_this.shaderData, 1);
|
|
27872
27912
|
_this._updatePixelViewport();
|
|
@@ -27879,16 +27919,22 @@
|
|
|
27879
27919
|
_inherits$2(Camera1, Component1);
|
|
27880
27920
|
var _proto = Camera1.prototype;
|
|
27881
27921
|
/**
|
|
27922
|
+
* Restore the view matrix to the world matrix of the entity.
|
|
27923
|
+
*/ _proto.resetViewMatrix = function resetViewMatrix() {
|
|
27924
|
+
this._isCustomViewMatrix = false;
|
|
27925
|
+
this._viewMatrixChange();
|
|
27926
|
+
};
|
|
27927
|
+
/**
|
|
27882
27928
|
* Restore the automatic calculation of projection matrix through fieldOfView, nearClipPlane and farClipPlane.
|
|
27883
27929
|
*/ _proto.resetProjectionMatrix = function resetProjectionMatrix() {
|
|
27884
|
-
this.
|
|
27885
|
-
this.
|
|
27930
|
+
this._isCustomProjectionMatrix = false;
|
|
27931
|
+
this._projectionMatrixChange();
|
|
27886
27932
|
};
|
|
27887
27933
|
/**
|
|
27888
27934
|
* Restore the automatic calculation of the aspect ratio through the viewport aspect ratio.
|
|
27889
27935
|
*/ _proto.resetAspectRatio = function resetAspectRatio() {
|
|
27890
27936
|
this._customAspectRatio = undefined;
|
|
27891
|
-
this.
|
|
27937
|
+
this._projectionMatrixChange();
|
|
27892
27938
|
};
|
|
27893
27939
|
/**
|
|
27894
27940
|
* Transform a point from world space to viewport space.
|
|
@@ -28018,10 +28064,9 @@
|
|
|
28018
28064
|
context.replacementShader = this._replacementShader;
|
|
28019
28065
|
context.replacementTag = this._replacementSubShaderTag;
|
|
28020
28066
|
// compute cull frustum.
|
|
28021
|
-
if (this.enableFrustumCulling &&
|
|
28067
|
+
if (this.enableFrustumCulling && this._frustumChangeFlag.flag) {
|
|
28022
28068
|
this._frustum.calculateFromMatrix(virtualCamera.viewProjectionMatrix);
|
|
28023
|
-
this.
|
|
28024
|
-
this._isFrustumProjectDirty = false;
|
|
28069
|
+
this._frustumChangeFlag.flag = false;
|
|
28025
28070
|
}
|
|
28026
28071
|
this._updateShaderData();
|
|
28027
28072
|
// union scene and camera macro.
|
|
@@ -28070,13 +28115,16 @@
|
|
|
28070
28115
|
//@ts-ignore
|
|
28071
28116
|
this._viewport._onValueChanged = null;
|
|
28072
28117
|
this.engine.canvas._sizeUpdateFlagManager.removeListener(this._onPixelViewportChanged);
|
|
28118
|
+
//@ts-ignore
|
|
28119
|
+
this._viewport._onValueChanged = null;
|
|
28120
|
+
this.engine.canvas._sizeUpdateFlagManager.removeListener(this._onPixelViewportChanged);
|
|
28073
28121
|
this._entity = null;
|
|
28074
28122
|
this._globalShaderMacro = null;
|
|
28075
28123
|
this._frustum = null;
|
|
28076
28124
|
this._renderPipeline = null;
|
|
28077
28125
|
this._virtualCamera = null;
|
|
28078
28126
|
this._shaderData = null;
|
|
28079
|
-
this.
|
|
28127
|
+
this._frustumChangeFlag = null;
|
|
28080
28128
|
this._transform = null;
|
|
28081
28129
|
this._isViewMatrixDirty = null;
|
|
28082
28130
|
this._isInvViewProjDirty = null;
|
|
@@ -28098,11 +28146,16 @@
|
|
|
28098
28146
|
var viewport = this._viewport;
|
|
28099
28147
|
this._pixelViewport.set(viewport.x * width, viewport.y * height, viewport.z * width, viewport.w * height);
|
|
28100
28148
|
};
|
|
28101
|
-
_proto.
|
|
28102
|
-
this.
|
|
28149
|
+
_proto._viewMatrixChange = function _viewMatrixChange() {
|
|
28150
|
+
this._isViewMatrixDirty.flag = true;
|
|
28151
|
+
this._isInvViewProjDirty.flag = true;
|
|
28152
|
+
this._frustumChangeFlag.flag = true;
|
|
28153
|
+
};
|
|
28154
|
+
_proto._projectionMatrixChange = function _projectionMatrixChange() {
|
|
28103
28155
|
this._isProjectionDirty = true;
|
|
28104
28156
|
this._isInvProjMatDirty = true;
|
|
28105
28157
|
this._isInvViewProjDirty.flag = true;
|
|
28158
|
+
this._frustumChangeFlag.flag = true;
|
|
28106
28159
|
};
|
|
28107
28160
|
_proto._innerViewportToWorldPoint = function _innerViewportToWorldPoint(x, y, z, invViewProjMat, out) {
|
|
28108
28161
|
// Depth is a normalized value, 0 is nearPlane, 1 is farClipPlane.
|
|
@@ -28145,7 +28198,7 @@
|
|
|
28145
28198
|
_proto._onPixelViewportChanged = function _onPixelViewportChanged() {
|
|
28146
28199
|
this._updatePixelViewport();
|
|
28147
28200
|
var _this__customAspectRatio;
|
|
28148
|
-
(_this__customAspectRatio = this._customAspectRatio) != null ? _this__customAspectRatio : this.
|
|
28201
|
+
(_this__customAspectRatio = this._customAspectRatio) != null ? _this__customAspectRatio : this._projectionMatrixChange();
|
|
28149
28202
|
};
|
|
28150
28203
|
_create_class$2(Camera1, [
|
|
28151
28204
|
{
|
|
@@ -28165,7 +28218,7 @@
|
|
|
28165
28218
|
},
|
|
28166
28219
|
set: function set(value) {
|
|
28167
28220
|
this._nearClipPlane = value;
|
|
28168
|
-
this.
|
|
28221
|
+
this._projectionMatrixChange();
|
|
28169
28222
|
}
|
|
28170
28223
|
},
|
|
28171
28224
|
{
|
|
@@ -28177,7 +28230,7 @@
|
|
|
28177
28230
|
},
|
|
28178
28231
|
set: function set(value) {
|
|
28179
28232
|
this._farClipPlane = value;
|
|
28180
|
-
this.
|
|
28233
|
+
this._projectionMatrixChange();
|
|
28181
28234
|
}
|
|
28182
28235
|
},
|
|
28183
28236
|
{
|
|
@@ -28189,7 +28242,7 @@
|
|
|
28189
28242
|
},
|
|
28190
28243
|
set: function set(value) {
|
|
28191
28244
|
this._fieldOfView = value;
|
|
28192
|
-
this.
|
|
28245
|
+
this._projectionMatrixChange();
|
|
28193
28246
|
}
|
|
28194
28247
|
},
|
|
28195
28248
|
{
|
|
@@ -28204,7 +28257,7 @@
|
|
|
28204
28257
|
},
|
|
28205
28258
|
set: function set(value) {
|
|
28206
28259
|
this._customAspectRatio = value;
|
|
28207
|
-
this.
|
|
28260
|
+
this._projectionMatrixChange();
|
|
28208
28261
|
}
|
|
28209
28262
|
},
|
|
28210
28263
|
{
|
|
@@ -28256,7 +28309,12 @@
|
|
|
28256
28309
|
},
|
|
28257
28310
|
set: function set(value) {
|
|
28258
28311
|
this._virtualCamera.isOrthographic = value;
|
|
28259
|
-
this.
|
|
28312
|
+
this._projectionMatrixChange();
|
|
28313
|
+
if (value) {
|
|
28314
|
+
this.shaderData.enableMacro("CAMERA_ORTHOGRAPHIC");
|
|
28315
|
+
} else {
|
|
28316
|
+
this.shaderData.disableMacro("CAMERA_ORTHOGRAPHIC");
|
|
28317
|
+
}
|
|
28260
28318
|
}
|
|
28261
28319
|
},
|
|
28262
28320
|
{
|
|
@@ -28268,7 +28326,7 @@
|
|
|
28268
28326
|
},
|
|
28269
28327
|
set: function set(value) {
|
|
28270
28328
|
this._orthographicSize = value;
|
|
28271
|
-
this.
|
|
28329
|
+
this._projectionMatrixChange();
|
|
28272
28330
|
}
|
|
28273
28331
|
},
|
|
28274
28332
|
{
|
|
@@ -28277,22 +28335,31 @@
|
|
|
28277
28335
|
* View matrix.
|
|
28278
28336
|
*/ function get() {
|
|
28279
28337
|
var viewMatrix = this._virtualCamera.viewMatrix;
|
|
28280
|
-
if (this._isViewMatrixDirty.flag) {
|
|
28281
|
-
|
|
28282
|
-
|
|
28283
|
-
|
|
28284
|
-
|
|
28285
|
-
|
|
28286
|
-
|
|
28338
|
+
if (!this._isViewMatrixDirty.flag || this._isCustomViewMatrix) {
|
|
28339
|
+
return viewMatrix;
|
|
28340
|
+
}
|
|
28341
|
+
this._isViewMatrixDirty.flag = false;
|
|
28342
|
+
// Ignore scale
|
|
28343
|
+
var transform = this._transform;
|
|
28344
|
+
Matrix.rotationTranslation(transform.worldRotationQuaternion, transform.worldPosition, viewMatrix);
|
|
28345
|
+
viewMatrix.invert();
|
|
28287
28346
|
return viewMatrix;
|
|
28347
|
+
},
|
|
28348
|
+
set: function set(value) {
|
|
28349
|
+
this._virtualCamera.viewMatrix.copyFrom(value);
|
|
28350
|
+
this._isCustomViewMatrix = true;
|
|
28351
|
+
this._viewMatrixChange();
|
|
28288
28352
|
}
|
|
28289
28353
|
},
|
|
28290
28354
|
{
|
|
28291
28355
|
key: "projectionMatrix",
|
|
28292
|
-
get:
|
|
28356
|
+
get: /**
|
|
28357
|
+
* The projection matrix is calculated by the relevant parameters of the camera by default.
|
|
28358
|
+
* If it is manually set, the manual value will be maintained. Call resetProjectionMatrix() to restore it.
|
|
28359
|
+
*/ function get() {
|
|
28293
28360
|
var virtualCamera = this._virtualCamera;
|
|
28294
28361
|
var projectionMatrix = virtualCamera.projectionMatrix;
|
|
28295
|
-
if (!this._isProjectionDirty || this.
|
|
28362
|
+
if (!this._isProjectionDirty || this._isCustomProjectionMatrix) {
|
|
28296
28363
|
return projectionMatrix;
|
|
28297
28364
|
}
|
|
28298
28365
|
this._isProjectionDirty = false;
|
|
@@ -28306,13 +28373,10 @@
|
|
|
28306
28373
|
}
|
|
28307
28374
|
return projectionMatrix;
|
|
28308
28375
|
},
|
|
28309
|
-
set:
|
|
28310
|
-
* The projection matrix is calculated by the relevant parameters of the camera by default.
|
|
28311
|
-
* If it is manually set, the manual value will be maintained. Call resetProjectionMatrix() to restore it.
|
|
28312
|
-
*/ function set(value) {
|
|
28376
|
+
set: function set(value) {
|
|
28313
28377
|
this._virtualCamera.projectionMatrix.copyFrom(value);
|
|
28314
|
-
this.
|
|
28315
|
-
this.
|
|
28378
|
+
this._isCustomProjectionMatrix = true;
|
|
28379
|
+
this._projectionMatrixChange();
|
|
28316
28380
|
}
|
|
28317
28381
|
},
|
|
28318
28382
|
{
|
|
@@ -28373,7 +28437,7 @@
|
|
|
28373
28437
|
], exports.Camera.prototype, "_cameraIndex", void 0);
|
|
28374
28438
|
__decorate$1([
|
|
28375
28439
|
ignoreClone
|
|
28376
|
-
], exports.Camera.prototype, "
|
|
28440
|
+
], exports.Camera.prototype, "_frustumChangeFlag", void 0);
|
|
28377
28441
|
__decorate$1([
|
|
28378
28442
|
ignoreClone
|
|
28379
28443
|
], exports.Camera.prototype, "_transform", void 0);
|
|
@@ -28558,6 +28622,7 @@
|
|
|
28558
28622
|
* @param obj - class object
|
|
28559
28623
|
*/ Loader.registerClass = function registerClass(className, classDefine) {
|
|
28560
28624
|
this._engineObjects[className] = classDefine;
|
|
28625
|
+
this._classNameMap.set(classDefine, className);
|
|
28561
28626
|
};
|
|
28562
28627
|
/**
|
|
28563
28628
|
* Get the class object by class name.
|
|
@@ -28566,11 +28631,21 @@
|
|
|
28566
28631
|
*/ Loader.getClass = function getClass(className) {
|
|
28567
28632
|
return this._engineObjects[className];
|
|
28568
28633
|
};
|
|
28634
|
+
/**
|
|
28635
|
+
* Get the class name by class object.
|
|
28636
|
+
* @param obj - class object
|
|
28637
|
+
* @returns class name
|
|
28638
|
+
*/ Loader.getClassName = function getClassName(obj) {
|
|
28639
|
+
return this._classNameMap.get(obj);
|
|
28640
|
+
};
|
|
28569
28641
|
return Loader;
|
|
28570
28642
|
}();
|
|
28571
28643
|
(function() {
|
|
28572
28644
|
Loader._engineObjects = {};
|
|
28573
28645
|
})();
|
|
28646
|
+
(function() {
|
|
28647
|
+
Loader._classNameMap = new Map();
|
|
28648
|
+
})();
|
|
28574
28649
|
/**
|
|
28575
28650
|
* Alpha blend mode.
|
|
28576
28651
|
*/ exports.BlendMode = void 0;
|
|
@@ -32291,7 +32366,7 @@
|
|
|
32291
32366
|
this._clip = clip;
|
|
32292
32367
|
this._clipEndTime = Math.min(this._clipEndTime, 1);
|
|
32293
32368
|
this._onClipChanged();
|
|
32294
|
-
clip._updateFlagManager.addListener(this._onClipChanged);
|
|
32369
|
+
clip && clip._updateFlagManager.addListener(this._onClipChanged);
|
|
32295
32370
|
}
|
|
32296
32371
|
},
|
|
32297
32372
|
{
|
|
@@ -32980,6 +33055,7 @@
|
|
|
32980
33055
|
ParticleRandomSubSeeds[ParticleRandomSubSeeds["RotationOverLifetime"] = 0x40eb95e4] = "RotationOverLifetime";
|
|
32981
33056
|
ParticleRandomSubSeeds[ParticleRandomSubSeeds["TextureSheetAnimation"] = 0xbc524e5] = "TextureSheetAnimation";
|
|
32982
33057
|
ParticleRandomSubSeeds[ParticleRandomSubSeeds["Shape"] = 0xaf502044] = "Shape";
|
|
33058
|
+
ParticleRandomSubSeeds[ParticleRandomSubSeeds["GravityModifier"] = 0xa47b8c4d] = "GravityModifier";
|
|
32983
33059
|
})(ParticleRandomSubSeeds || (ParticleRandomSubSeeds = {}));
|
|
32984
33060
|
/**
|
|
32985
33061
|
* Particle gradient.
|
|
@@ -33685,6 +33761,7 @@
|
|
|
33685
33761
|
/** @internal */ this._startColorRand = new Rand(0, ParticleRandomSubSeeds.StartColor);
|
|
33686
33762
|
/** @internal */ this._startSizeRand = new Rand(0, ParticleRandomSubSeeds.StartSize);
|
|
33687
33763
|
/** @internal */ this._startRotationRand = new Rand(0, ParticleRandomSubSeeds.StartRotation);
|
|
33764
|
+
this._gravityModifierRand = new Rand(0, ParticleRandomSubSeeds.GravityModifier);
|
|
33688
33765
|
this._gravity = new Vector3();
|
|
33689
33766
|
this._generator = generator;
|
|
33690
33767
|
};
|
|
@@ -33745,7 +33822,7 @@
|
|
|
33745
33822
|
break;
|
|
33746
33823
|
}
|
|
33747
33824
|
var particleGravity = this._gravity;
|
|
33748
|
-
var gravityModifierValue = this.gravityModifier.evaluate(undefined,
|
|
33825
|
+
var gravityModifierValue = this.gravityModifier.evaluate(undefined, this._gravityModifierRand.random());
|
|
33749
33826
|
Vector3.scale(renderer.scene.physics.gravity, gravityModifierValue, particleGravity);
|
|
33750
33827
|
shaderData.setVector3(MainModule._gravity, particleGravity);
|
|
33751
33828
|
shaderData.setInt(MainModule._simulationSpace, this.simulationSpace);
|
|
@@ -33864,6 +33941,9 @@
|
|
|
33864
33941
|
__decorate$1([
|
|
33865
33942
|
ignoreClone
|
|
33866
33943
|
], MainModule.prototype, "_startRotationRand", void 0);
|
|
33944
|
+
__decorate$1([
|
|
33945
|
+
ignoreClone
|
|
33946
|
+
], MainModule.prototype, "_gravityModifierRand", void 0);
|
|
33867
33947
|
__decorate$1([
|
|
33868
33948
|
ignoreClone
|
|
33869
33949
|
], MainModule.prototype, "_generator", void 0);
|
|
@@ -34528,7 +34608,8 @@
|
|
|
34528
34608
|
var transform = this._renderer.entity.transform;
|
|
34529
34609
|
var shape = this.emission.shape;
|
|
34530
34610
|
for(var i = 0; i < count; i++){
|
|
34531
|
-
|
|
34611
|
+
var _shape;
|
|
34612
|
+
if ((_shape = shape) == null ? void 0 : _shape.enabled) {
|
|
34532
34613
|
shape._generatePositionAndDirection(this.emission._shapeRand, time, position, direction);
|
|
34533
34614
|
var positionScale = this.main._getPositionScale();
|
|
34534
34615
|
position.multiply(positionScale);
|
|
@@ -35105,7 +35186,7 @@
|
|
|
35105
35186
|
* Base class for all particle shapes.
|
|
35106
35187
|
*/ var BaseShape = /*#__PURE__*/ function() {
|
|
35107
35188
|
var BaseShape = function BaseShape() {
|
|
35108
|
-
/** Specifies whether the ShapeModule is enabled or disabled. */ this.
|
|
35189
|
+
/** Specifies whether the ShapeModule is enabled or disabled. */ this.enabled = true;
|
|
35109
35190
|
/** Randomizes the starting direction of particles. */ this.randomDirectionAmount = 0;
|
|
35110
35191
|
};
|
|
35111
35192
|
var _proto = BaseShape.prototype;
|
|
@@ -35167,22 +35248,22 @@
|
|
|
35167
35248
|
}();
|
|
35168
35249
|
/**
|
|
35169
35250
|
* The emission shape.
|
|
35170
|
-
*/
|
|
35251
|
+
*/ exports.ParticleShapeType = void 0;
|
|
35171
35252
|
(function(ParticleShapeType) {
|
|
35172
35253
|
ParticleShapeType[ParticleShapeType[/** Emit from the volume of a box. */ "Box"] = 0] = "Box";
|
|
35173
35254
|
ParticleShapeType[ParticleShapeType[/** Emit from a circle. */ "Circle"] = 1] = "Circle";
|
|
35174
35255
|
ParticleShapeType[ParticleShapeType[/** Emit from the base of a cone. */ "Cone"] = 2] = "Cone";
|
|
35175
35256
|
ParticleShapeType[ParticleShapeType[/** Emit from a half-sphere. */ "Hemisphere"] = 3] = "Hemisphere";
|
|
35176
35257
|
ParticleShapeType[ParticleShapeType[/** Emit from a sphere. */ "Sphere"] = 4] = "Sphere";
|
|
35177
|
-
})(ParticleShapeType || (ParticleShapeType = {}));
|
|
35258
|
+
})(exports.ParticleShapeType || (exports.ParticleShapeType = {}));
|
|
35178
35259
|
/**
|
|
35179
35260
|
* Particle shape that emits particles from a box.
|
|
35180
35261
|
*/ var BoxShape = /*#__PURE__*/ function(BaseShape1) {
|
|
35181
35262
|
var BoxShape = function BoxShape() {
|
|
35182
35263
|
var _this;
|
|
35183
|
-
_this = BaseShape1.
|
|
35264
|
+
_this = BaseShape1.apply(this, arguments) || this;
|
|
35265
|
+
_this.shapeType = exports.ParticleShapeType.Box;
|
|
35184
35266
|
/** The size of the box. */ _this.size = new Vector3(1, 1, 1);
|
|
35185
|
-
_this.shapeType = ParticleShapeType.Box;
|
|
35186
35267
|
return _this;
|
|
35187
35268
|
};
|
|
35188
35269
|
_inherits$2(BoxShape, BaseShape1);
|
|
@@ -35217,12 +35298,12 @@
|
|
|
35217
35298
|
*/ var CircleShape = /*#__PURE__*/ function(BaseShape1) {
|
|
35218
35299
|
var CircleShape = function CircleShape() {
|
|
35219
35300
|
var _this;
|
|
35220
|
-
_this = BaseShape1.
|
|
35301
|
+
_this = BaseShape1.apply(this, arguments) || this;
|
|
35302
|
+
_this.shapeType = exports.ParticleShapeType.Circle;
|
|
35221
35303
|
/** Radius of the shape to emit particles from. */ _this.radius = 1.0;
|
|
35222
35304
|
/** Angle of the circle arc to emit particles from. */ _this.arc = 360.0;
|
|
35223
35305
|
/** The mode to generate particles around the arc. */ _this.arcMode = exports.ParticleShapeArcMode.Random;
|
|
35224
35306
|
/** The speed of complete 360 degree rotation. */ _this.arcSpeed = 1.0;
|
|
35225
|
-
_this.shapeType = ParticleShapeType.Circle;
|
|
35226
35307
|
return _this;
|
|
35227
35308
|
};
|
|
35228
35309
|
_inherits$2(CircleShape, BaseShape1);
|
|
@@ -35257,12 +35338,12 @@
|
|
|
35257
35338
|
*/ var ConeShape = /*#__PURE__*/ function(BaseShape1) {
|
|
35258
35339
|
var ConeShape = function ConeShape() {
|
|
35259
35340
|
var _this;
|
|
35260
|
-
_this = BaseShape1.
|
|
35341
|
+
_this = BaseShape1.apply(this, arguments) || this;
|
|
35342
|
+
_this.shapeType = exports.ParticleShapeType.Cone;
|
|
35261
35343
|
/** Angle of the cone to emit particles from. */ _this.angle = 25.0;
|
|
35262
35344
|
/** Radius of the shape to emit particles from. */ _this.radius = 1.0;
|
|
35263
35345
|
/** Length of the cone to emit particles from. */ _this.length = 5.0;
|
|
35264
35346
|
/** Cone emitter type. */ _this.emitType = /** Emit particles from the base of the cone. */ 0;
|
|
35265
|
-
_this.shapeType = ParticleShapeType.Cone;
|
|
35266
35347
|
return _this;
|
|
35267
35348
|
};
|
|
35268
35349
|
_inherits$2(ConeShape, BaseShape1);
|
|
@@ -35321,9 +35402,9 @@
|
|
|
35321
35402
|
*/ var HemisphereShape = /*#__PURE__*/ function(BaseShape1) {
|
|
35322
35403
|
var HemisphereShape = function HemisphereShape() {
|
|
35323
35404
|
var _this;
|
|
35324
|
-
_this = BaseShape1.
|
|
35405
|
+
_this = BaseShape1.apply(this, arguments) || this;
|
|
35406
|
+
_this.shapeType = exports.ParticleShapeType.Hemisphere;
|
|
35325
35407
|
/** Radius of the shape to emit particles from. */ _this.radius = 1.0;
|
|
35326
|
-
_this.shapeType = ParticleShapeType.Hemisphere;
|
|
35327
35408
|
return _this;
|
|
35328
35409
|
};
|
|
35329
35410
|
_inherits$2(HemisphereShape, BaseShape1);
|
|
@@ -35345,9 +35426,9 @@
|
|
|
35345
35426
|
*/ var SphereShape = /*#__PURE__*/ function(BaseShape1) {
|
|
35346
35427
|
var SphereShape = function SphereShape() {
|
|
35347
35428
|
var _this;
|
|
35348
|
-
_this = BaseShape1.
|
|
35429
|
+
_this = BaseShape1.apply(this, arguments) || this;
|
|
35430
|
+
_this.shapeType = exports.ParticleShapeType.Sphere;
|
|
35349
35431
|
/** Radius of the shape to emit particles from. */ _this.radius = 1.0;
|
|
35350
|
-
_this.shapeType = ParticleShapeType.Sphere;
|
|
35351
35432
|
return _this;
|
|
35352
35433
|
};
|
|
35353
35434
|
_inherits$2(SphereShape, BaseShape1);
|
|
@@ -35851,6 +35932,7 @@
|
|
|
35851
35932
|
ParticleRenderer: ParticleRenderer,
|
|
35852
35933
|
get ParticleScaleMode () { return exports.ParticleScaleMode; },
|
|
35853
35934
|
get ParticleShapeArcMode () { return exports.ParticleShapeArcMode; },
|
|
35935
|
+
get ParticleShapeType () { return exports.ParticleShapeType; },
|
|
35854
35936
|
get ParticleSimulationSpace () { return exports.ParticleSimulationSpace; },
|
|
35855
35937
|
get ParticleStopMode () { return exports.ParticleStopMode; },
|
|
35856
35938
|
PhysicsMaterial: PhysicsMaterial,
|
|
@@ -36078,8 +36160,10 @@
|
|
|
36078
36160
|
if (pixelRatio === void 0) pixelRatio = window.devicePixelRatio;
|
|
36079
36161
|
var webCanvas = this._webCanvas;
|
|
36080
36162
|
if (typeof OffscreenCanvas === "undefined" || !_instanceof1$1(webCanvas, OffscreenCanvas)) {
|
|
36081
|
-
|
|
36082
|
-
|
|
36163
|
+
var exportWidth = webCanvas.clientWidth * pixelRatio;
|
|
36164
|
+
var exportHeight = webCanvas.clientHeight * pixelRatio;
|
|
36165
|
+
this.width = exportWidth;
|
|
36166
|
+
this.height = exportHeight;
|
|
36083
36167
|
}
|
|
36084
36168
|
};
|
|
36085
36169
|
/**
|
|
@@ -36090,9 +36174,11 @@
|
|
|
36090
36174
|
this._scale.set(x, y);
|
|
36091
36175
|
this.scale = this._scale;
|
|
36092
36176
|
};
|
|
36093
|
-
_proto.
|
|
36094
|
-
this._webCanvas.width =
|
|
36095
|
-
|
|
36177
|
+
_proto._onWidthChanged = function _onWidthChanged(value) {
|
|
36178
|
+
this._webCanvas.width = value;
|
|
36179
|
+
};
|
|
36180
|
+
_proto._onHeightChange = function _onHeightChange(value) {
|
|
36181
|
+
this._webCanvas.height = value;
|
|
36096
36182
|
};
|
|
36097
36183
|
_create_class$1(WebCanvas, [
|
|
36098
36184
|
{
|
|
@@ -36277,7 +36363,7 @@
|
|
|
36277
36363
|
var cap = this.capabilityList;
|
|
36278
36364
|
var isWebGL2 = this.rhi.isWebGL2;
|
|
36279
36365
|
var requireExtension = this.rhi.requireExtension.bind(this.rhi);
|
|
36280
|
-
var shaderVertexID = exports.GLCapabilityType.shaderVertexID, standardDerivatives = exports.GLCapabilityType.standardDerivatives, shaderTextureLod = exports.GLCapabilityType.shaderTextureLod, elementIndexUint = exports.GLCapabilityType.elementIndexUint, depthTexture = exports.GLCapabilityType.depthTexture, vertexArrayObject = exports.GLCapabilityType.vertexArrayObject, instancedArrays = exports.GLCapabilityType.instancedArrays, multipleSample = exports.GLCapabilityType.multipleSample, drawBuffers = exports.GLCapabilityType.drawBuffers, astc = exports.GLCapabilityType.astc, astc_webkit = exports.GLCapabilityType.astc_webkit, etc = exports.GLCapabilityType.etc, etc_webkit = exports.GLCapabilityType.etc_webkit, etc1 = exports.GLCapabilityType.etc1, etc1_webkit = exports.GLCapabilityType.etc1_webkit, pvrtc = exports.GLCapabilityType.pvrtc, pvrtc_webkit = exports.GLCapabilityType.pvrtc_webkit, s3tc = exports.GLCapabilityType.s3tc, s3tc_webkit = exports.GLCapabilityType.s3tc_webkit, bptc = exports.GLCapabilityType.bptc, textureFloat = exports.GLCapabilityType.textureFloat, textureHalfFloat = exports.GLCapabilityType.textureHalfFloat, textureFloatLinear = exports.GLCapabilityType.textureFloatLinear, textureHalfFloatLinear = exports.GLCapabilityType.textureHalfFloatLinear, WEBGL_colorBufferFloat = exports.GLCapabilityType.WEBGL_colorBufferFloat, colorBufferFloat = exports.GLCapabilityType.colorBufferFloat, colorBufferHalfFloat = exports.GLCapabilityType.colorBufferHalfFloat, textureFilterAnisotropic = exports.GLCapabilityType.textureFilterAnisotropic;
|
|
36366
|
+
var shaderVertexID = exports.GLCapabilityType.shaderVertexID, standardDerivatives = exports.GLCapabilityType.standardDerivatives, shaderTextureLod = exports.GLCapabilityType.shaderTextureLod, elementIndexUint = exports.GLCapabilityType.elementIndexUint, depthTexture = exports.GLCapabilityType.depthTexture, vertexArrayObject = exports.GLCapabilityType.vertexArrayObject, instancedArrays = exports.GLCapabilityType.instancedArrays, multipleSample = exports.GLCapabilityType.multipleSample, drawBuffers = exports.GLCapabilityType.drawBuffers, blendMinMax = exports.GLCapabilityType.blendMinMax, astc = exports.GLCapabilityType.astc, astc_webkit = exports.GLCapabilityType.astc_webkit, etc = exports.GLCapabilityType.etc, etc_webkit = exports.GLCapabilityType.etc_webkit, etc1 = exports.GLCapabilityType.etc1, etc1_webkit = exports.GLCapabilityType.etc1_webkit, pvrtc = exports.GLCapabilityType.pvrtc, pvrtc_webkit = exports.GLCapabilityType.pvrtc_webkit, s3tc = exports.GLCapabilityType.s3tc, s3tc_webkit = exports.GLCapabilityType.s3tc_webkit, bptc = exports.GLCapabilityType.bptc, textureFloat = exports.GLCapabilityType.textureFloat, textureHalfFloat = exports.GLCapabilityType.textureHalfFloat, textureFloatLinear = exports.GLCapabilityType.textureFloatLinear, textureHalfFloatLinear = exports.GLCapabilityType.textureHalfFloatLinear, WEBGL_colorBufferFloat = exports.GLCapabilityType.WEBGL_colorBufferFloat, colorBufferFloat = exports.GLCapabilityType.colorBufferFloat, colorBufferHalfFloat = exports.GLCapabilityType.colorBufferHalfFloat, textureFilterAnisotropic = exports.GLCapabilityType.textureFilterAnisotropic;
|
|
36281
36367
|
cap.set(shaderVertexID, isWebGL2);
|
|
36282
36368
|
cap.set(standardDerivatives, isWebGL2 || !!requireExtension(standardDerivatives));
|
|
36283
36369
|
cap.set(shaderTextureLod, isWebGL2 || !!requireExtension(shaderTextureLod));
|
|
@@ -36287,6 +36373,7 @@
|
|
|
36287
36373
|
cap.set(instancedArrays, isWebGL2 || !!requireExtension(instancedArrays));
|
|
36288
36374
|
cap.set(multipleSample, isWebGL2);
|
|
36289
36375
|
cap.set(drawBuffers, isWebGL2 || !!requireExtension(drawBuffers));
|
|
36376
|
+
cap.set(blendMinMax, isWebGL2 || !!requireExtension(blendMinMax));
|
|
36290
36377
|
cap.set(textureFloat, isWebGL2 || !!requireExtension(textureFloat));
|
|
36291
36378
|
cap.set(textureHalfFloat, isWebGL2 || !!requireExtension(textureHalfFloat));
|
|
36292
36379
|
cap.set(textureFloatLinear, !!requireExtension(textureFloatLinear));
|
|
@@ -36327,9 +36414,13 @@
|
|
|
36327
36414
|
}
|
|
36328
36415
|
};
|
|
36329
36416
|
_proto._compatibleAllInterface = function _compatibleAllInterface() {
|
|
36330
|
-
var depthTexture = exports.GLCapabilityType.depthTexture, vertexArrayObject = exports.GLCapabilityType.vertexArrayObject, instancedArrays = exports.GLCapabilityType.instancedArrays, drawBuffers = exports.GLCapabilityType.drawBuffers, textureFilterAnisotropic = exports.GLCapabilityType.textureFilterAnisotropic, textureHalfFloat = exports.GLCapabilityType.textureHalfFloat, colorBufferHalfFloat = exports.GLCapabilityType.colorBufferHalfFloat, WEBGL_colorBufferFloat = exports.GLCapabilityType.WEBGL_colorBufferFloat;
|
|
36417
|
+
var depthTexture = exports.GLCapabilityType.depthTexture, vertexArrayObject = exports.GLCapabilityType.vertexArrayObject, instancedArrays = exports.GLCapabilityType.instancedArrays, drawBuffers = exports.GLCapabilityType.drawBuffers, textureFilterAnisotropic = exports.GLCapabilityType.textureFilterAnisotropic, textureHalfFloat = exports.GLCapabilityType.textureHalfFloat, colorBufferHalfFloat = exports.GLCapabilityType.colorBufferHalfFloat, WEBGL_colorBufferFloat = exports.GLCapabilityType.WEBGL_colorBufferFloat, blendMinMax = exports.GLCapabilityType.blendMinMax;
|
|
36331
36418
|
var isWebGL2 = this.rhi.isWebGL2;
|
|
36332
36419
|
if (!isWebGL2) {
|
|
36420
|
+
this._compatibleInterface(blendMinMax, {
|
|
36421
|
+
MIN: "MIN_EXT",
|
|
36422
|
+
MAX: "MAX_EXT"
|
|
36423
|
+
});
|
|
36333
36424
|
this._compatibleInterface(depthTexture, {
|
|
36334
36425
|
UNSIGNED_INT_24_8: "UNSIGNED_INT_24_8_WEBGL"
|
|
36335
36426
|
});
|
|
@@ -36838,6 +36929,13 @@
|
|
|
36838
36929
|
dataType: gl.FLOAT,
|
|
36839
36930
|
isCompressed: false
|
|
36840
36931
|
};
|
|
36932
|
+
case exports.TextureFormat.R32G32B32A32_UInt:
|
|
36933
|
+
return {
|
|
36934
|
+
internalFormat: isWebGL2 ? gl.RGBA32UI : gl.NONE,
|
|
36935
|
+
baseFormat: gl.RGBA_INTEGER,
|
|
36936
|
+
dataType: gl.UNSIGNED_INT,
|
|
36937
|
+
isCompressed: false
|
|
36938
|
+
};
|
|
36841
36939
|
case exports.TextureFormat.BC1:
|
|
36842
36940
|
return {
|
|
36843
36941
|
internalFormat: exports.GLCompressedTextureInternalFormat.RGB_S3TC_DXT1_EXT,
|
|
@@ -37079,6 +37177,7 @@
|
|
|
37079
37177
|
return false;
|
|
37080
37178
|
}
|
|
37081
37179
|
break;
|
|
37180
|
+
case exports.TextureFormat.R32G32B32A32_UInt:
|
|
37082
37181
|
case exports.TextureFormat.Depth24:
|
|
37083
37182
|
case exports.TextureFormat.Depth32:
|
|
37084
37183
|
case exports.TextureFormat.Depth32Stencil8:
|
|
@@ -38642,8 +38741,7 @@
|
|
|
38642
38741
|
var assetRefId = entityConfig.assetRefId;
|
|
38643
38742
|
var engine = this._context.engine;
|
|
38644
38743
|
if (assetRefId) {
|
|
38645
|
-
return engine.resourceManager
|
|
38646
|
-
.getResourceByRef({
|
|
38744
|
+
return engine.resourceManager.getResourceByRef({
|
|
38647
38745
|
refId: assetRefId,
|
|
38648
38746
|
key: entityConfig.key,
|
|
38649
38747
|
isClone: entityConfig.isClone
|
|
@@ -38673,36 +38771,362 @@
|
|
|
38673
38771
|
(function() {
|
|
38674
38772
|
ReflectionParser.customParseComponentHandles = new Map();
|
|
38675
38773
|
})();
|
|
38676
|
-
|
|
38677
|
-
|
|
38678
|
-
|
|
38679
|
-
|
|
38774
|
+
/**
|
|
38775
|
+
* Parser context
|
|
38776
|
+
* @export
|
|
38777
|
+
* @abstract
|
|
38778
|
+
* @class ParserContext
|
|
38779
|
+
* @template T
|
|
38780
|
+
* @template I
|
|
38781
|
+
*/ var ParserContext = /*#__PURE__*/ function() {
|
|
38782
|
+
var ParserContext = function ParserContext(originalData, engine, target) {
|
|
38783
|
+
this.originalData = originalData;
|
|
38784
|
+
this.engine = engine;
|
|
38785
|
+
this.target = target;
|
|
38786
|
+
this.entityMap = new Map();
|
|
38787
|
+
this.components = new Map();
|
|
38788
|
+
this.assets = new Map();
|
|
38789
|
+
this.entityConfigMap = new Map();
|
|
38790
|
+
this.rootIds = [];
|
|
38791
|
+
this.strippedIds = [];
|
|
38792
|
+
this.resourceManager = engine.resourceManager;
|
|
38793
|
+
};
|
|
38794
|
+
var _proto = ParserContext.prototype;
|
|
38795
|
+
/**
|
|
38796
|
+
* Destroy the context.
|
|
38797
|
+
* @abstract
|
|
38798
|
+
* @memberof ParserContext
|
|
38799
|
+
*/ _proto.destroy = function destroy() {
|
|
38800
|
+
this.entityMap.clear();
|
|
38801
|
+
this.components.clear();
|
|
38802
|
+
this.assets.clear();
|
|
38803
|
+
this.entityConfigMap.clear();
|
|
38804
|
+
this.rootIds.length = 0;
|
|
38805
|
+
};
|
|
38806
|
+
return ParserContext;
|
|
38807
|
+
}();
|
|
38808
|
+
var PrefabParserContext = /*#__PURE__*/ function(ParserContext1) {
|
|
38809
|
+
var PrefabParserContext = function PrefabParserContext() {
|
|
38810
|
+
return ParserContext1.apply(this, arguments);
|
|
38811
|
+
};
|
|
38812
|
+
_inherits(PrefabParserContext, ParserContext1);
|
|
38813
|
+
return PrefabParserContext;
|
|
38814
|
+
}(ParserContext);
|
|
38815
|
+
function _array_like_to_array(arr, len) {
|
|
38816
|
+
if (len == null || len > arr.length) len = arr.length;
|
|
38817
|
+
for(var i = 0, arr2 = new Array(len); i < len; i++)arr2[i] = arr[i];
|
|
38818
|
+
return arr2;
|
|
38819
|
+
}
|
|
38820
|
+
function _unsupported_iterable_to_array(o, minLen) {
|
|
38821
|
+
if (!o) return;
|
|
38822
|
+
if (typeof o === "string") return _array_like_to_array(o, minLen);
|
|
38823
|
+
var n = Object.prototype.toString.call(o).slice(8, -1);
|
|
38824
|
+
if (n === "Object" && o.constructor) n = o.constructor.name;
|
|
38825
|
+
if (n === "Map" || n === "Set") return Array.from(n);
|
|
38826
|
+
if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _array_like_to_array(o, minLen);
|
|
38827
|
+
}
|
|
38828
|
+
function _create_for_of_iterator_helper_loose(o, allowArrayLike) {
|
|
38829
|
+
var it = typeof Symbol !== "undefined" && o[Symbol.iterator] || o["@@iterator"];
|
|
38830
|
+
if (it) return (it = it.call(o)).next.bind(it);
|
|
38831
|
+
// Fallback for engines without symbol support
|
|
38832
|
+
if (Array.isArray(o) || (it = _unsupported_iterable_to_array(o)) || allowArrayLike && o && typeof o.length === "number") {
|
|
38833
|
+
if (it) o = it;
|
|
38834
|
+
var i = 0;
|
|
38835
|
+
return function() {
|
|
38836
|
+
if (i >= o.length) return {
|
|
38837
|
+
done: true
|
|
38838
|
+
};
|
|
38839
|
+
return {
|
|
38840
|
+
done: false,
|
|
38841
|
+
value: o[i++]
|
|
38842
|
+
};
|
|
38843
|
+
};
|
|
38844
|
+
}
|
|
38845
|
+
throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
|
|
38846
|
+
}
|
|
38847
|
+
var HierarchyParser = /*#__PURE__*/ function() {
|
|
38848
|
+
var HierarchyParser = function HierarchyParser(context) {
|
|
38849
|
+
var _this = this;
|
|
38850
|
+
this.context = context;
|
|
38851
|
+
this.prefabContextMap = new WeakMap();
|
|
38852
|
+
this.prefabPromiseMap = new Map();
|
|
38853
|
+
this._engine = this.context.engine;
|
|
38854
|
+
this._organizeEntities = this._organizeEntities.bind(this);
|
|
38855
|
+
this._parseComponents = this._parseComponents.bind(this);
|
|
38856
|
+
this._parsePrefabModification = this._parsePrefabModification.bind(this);
|
|
38857
|
+
this._parsePrefabRemovedEntities = this._parsePrefabRemovedEntities.bind(this);
|
|
38858
|
+
this._parsePrefabRemovedComponents = this._parsePrefabRemovedComponents.bind(this);
|
|
38859
|
+
this._clearAndResolve = this._clearAndResolve.bind(this);
|
|
38860
|
+
this.promise = new Promise(function(resolve, reject) {
|
|
38861
|
+
_this._reject = reject;
|
|
38862
|
+
_this._resolve = resolve;
|
|
38863
|
+
});
|
|
38864
|
+
this._reflectionParser = new ReflectionParser(context);
|
|
38865
|
+
};
|
|
38866
|
+
var _proto = HierarchyParser.prototype;
|
|
38867
|
+
/** start parse the scene or prefab or others */ _proto.start = function start() {
|
|
38868
|
+
this._parseEntities().then(this._organizeEntities).then(this._parseComponents).then(this._parsePrefabModification).then(this._parsePrefabRemovedEntities).then(this._parsePrefabRemovedComponents).then(this._clearAndResolve).then(this._resolve).catch(this._reject);
|
|
38869
|
+
};
|
|
38870
|
+
_proto._parseEntities = function _parseEntities() {
|
|
38871
|
+
var _this = this;
|
|
38872
|
+
var entitiesConfig = this.context.originalData.entities;
|
|
38873
|
+
var entityConfigMap = this.context.entityConfigMap;
|
|
38874
|
+
var entityMap = this.context.entityMap;
|
|
38875
|
+
var engine = this._engine;
|
|
38876
|
+
var promises = entitiesConfig.map(function(entityConfig) {
|
|
38877
|
+
var _entityConfig_strippedId;
|
|
38878
|
+
var id = (_entityConfig_strippedId = entityConfig.strippedId) != null ? _entityConfig_strippedId : entityConfig.id;
|
|
38879
|
+
entityConfig.id = id;
|
|
38880
|
+
entityConfigMap.set(id, entityConfig);
|
|
38881
|
+
return _this._getEntityByConfig(entityConfig, engine);
|
|
38882
|
+
});
|
|
38883
|
+
return Promise.all(promises).then(function(entities) {
|
|
38884
|
+
for(var i = 0, l = entities.length; i < l; i++){
|
|
38885
|
+
entityMap.set(entitiesConfig[i].id, entities[i]);
|
|
38886
|
+
}
|
|
38887
|
+
return entities;
|
|
38888
|
+
});
|
|
38889
|
+
};
|
|
38890
|
+
_proto._parseComponents = function _parseComponents() {
|
|
38891
|
+
var entitiesConfig = this.context.originalData.entities;
|
|
38892
|
+
var entityMap = this.context.entityMap;
|
|
38893
|
+
var components = this.context.components;
|
|
38894
|
+
var promises = [];
|
|
38895
|
+
for(var i = 0, l = entitiesConfig.length; i < l; i++){
|
|
38896
|
+
var entityConfig = entitiesConfig[i];
|
|
38897
|
+
var entity = entityMap.get(entityConfig.id);
|
|
38898
|
+
for(var i1 = 0; i1 < entityConfig.components.length; i1++){
|
|
38899
|
+
var componentConfig = entityConfig.components[i1];
|
|
38900
|
+
var key = !componentConfig.refId ? componentConfig.class : componentConfig.refId;
|
|
38901
|
+
var component = entity.addComponent(Loader.getClass(key));
|
|
38902
|
+
components.set(componentConfig.id, component);
|
|
38903
|
+
var promise = this._reflectionParser.parsePropsAndMethods(component, componentConfig);
|
|
38904
|
+
promises.push(promise);
|
|
38905
|
+
}
|
|
38906
|
+
}
|
|
38907
|
+
return Promise.all(promises);
|
|
38908
|
+
};
|
|
38909
|
+
_proto._parsePrefabModification = function _parsePrefabModification() {
|
|
38910
|
+
var _loop = function _loop(i, l) {
|
|
38911
|
+
var _modifications;
|
|
38912
|
+
var entityConfig = entitiesConfig[i];
|
|
38913
|
+
var id = entityConfig.id, modifications = entityConfig.modifications;
|
|
38914
|
+
if ((_modifications = modifications) == null ? void 0 : _modifications.length) {
|
|
38915
|
+
var _promises;
|
|
38916
|
+
var rootEntity = entityMap.get(id);
|
|
38917
|
+
(_promises = promises).push.apply(_promises, [].concat(modifications.map(function(modification) {
|
|
38918
|
+
var target = modification.target, props = modification.props, methods = modification.methods;
|
|
38919
|
+
var entityId = target.entityId, componentId = target.componentId;
|
|
38920
|
+
var context = _this.prefabContextMap.get(rootEntity);
|
|
38921
|
+
var targetEntity = context.entityMap.get(entityId);
|
|
38922
|
+
var targetComponent = context.components.get(componentId);
|
|
38923
|
+
if (targetComponent) {
|
|
38924
|
+
return _this._reflectionParser.parsePropsAndMethods(targetComponent, {
|
|
38925
|
+
props: props,
|
|
38926
|
+
methods: methods
|
|
38927
|
+
});
|
|
38928
|
+
} else if (targetEntity) {
|
|
38929
|
+
return Promise.resolve(_this._applyEntityData(targetEntity, props));
|
|
38930
|
+
}
|
|
38931
|
+
})));
|
|
38932
|
+
}
|
|
38933
|
+
};
|
|
38934
|
+
var _this = this;
|
|
38935
|
+
var entitiesConfig = this.context.originalData.entities;
|
|
38936
|
+
var entityMap = this.context.entityMap;
|
|
38937
|
+
var promises = [];
|
|
38938
|
+
for(var i = 0, l = entitiesConfig.length; i < l; i++)_loop(i);
|
|
38939
|
+
return Promise.all(promises);
|
|
38940
|
+
};
|
|
38941
|
+
_proto._parsePrefabRemovedEntities = function _parsePrefabRemovedEntities() {
|
|
38942
|
+
var _loop = function _loop(i, l) {
|
|
38943
|
+
var _removedEntities;
|
|
38944
|
+
var entityConfig = entitiesConfig[i];
|
|
38945
|
+
var id = entityConfig.id, removedEntities = entityConfig.removedEntities;
|
|
38946
|
+
if ((_removedEntities = removedEntities) == null ? void 0 : _removedEntities.length) {
|
|
38947
|
+
var _promises;
|
|
38948
|
+
var rootEntity = entityMap.get(id);
|
|
38949
|
+
(_promises = promises).push.apply(_promises, [].concat(removedEntities.map(function(target) {
|
|
38950
|
+
var entityId = target.entityId;
|
|
38951
|
+
var context = _this.prefabContextMap.get(rootEntity);
|
|
38952
|
+
var targetEntity = context.entityMap.get(entityId);
|
|
38953
|
+
if (targetEntity) {
|
|
38954
|
+
targetEntity.destroy();
|
|
38955
|
+
}
|
|
38956
|
+
})));
|
|
38957
|
+
}
|
|
38958
|
+
};
|
|
38959
|
+
var _this = this;
|
|
38960
|
+
var entitiesConfig = this.context.originalData.entities;
|
|
38961
|
+
var entityMap = this.context.entityMap;
|
|
38962
|
+
var promises = [];
|
|
38963
|
+
for(var i = 0, l = entitiesConfig.length; i < l; i++)_loop(i);
|
|
38964
|
+
return Promise.all(promises);
|
|
38965
|
+
};
|
|
38966
|
+
_proto._parsePrefabRemovedComponents = function _parsePrefabRemovedComponents() {
|
|
38967
|
+
var _loop = function _loop(i, l) {
|
|
38968
|
+
var _removedComponents;
|
|
38969
|
+
var entityConfig = entitiesConfig[i];
|
|
38970
|
+
var id = entityConfig.id, removedComponents = entityConfig.removedComponents;
|
|
38971
|
+
if ((_removedComponents = removedComponents) == null ? void 0 : _removedComponents.length) {
|
|
38972
|
+
var _promises;
|
|
38973
|
+
var rootEntity = entityMap.get(id);
|
|
38974
|
+
(_promises = promises).concat.apply(_promises, [].concat(removedComponents.map(function(target) {
|
|
38975
|
+
var componentId = target.componentId;
|
|
38976
|
+
var context = _this.prefabContextMap.get(rootEntity);
|
|
38977
|
+
var targetComponent = context.components.get(componentId);
|
|
38978
|
+
if (targetComponent) {
|
|
38979
|
+
targetComponent.destroy();
|
|
38980
|
+
}
|
|
38981
|
+
})));
|
|
38982
|
+
}
|
|
38983
|
+
};
|
|
38984
|
+
var _this = this;
|
|
38985
|
+
var entitiesConfig = this.context.originalData.entities;
|
|
38986
|
+
var entityMap = this.context.entityMap;
|
|
38987
|
+
var promises = [];
|
|
38988
|
+
for(var i = 0, l = entitiesConfig.length; i < l; i++)_loop(i);
|
|
38989
|
+
return Promise.all(promises);
|
|
38990
|
+
};
|
|
38991
|
+
_proto._clearAndResolve = function _clearAndResolve() {
|
|
38992
|
+
var target = this.context.target;
|
|
38993
|
+
return target;
|
|
38994
|
+
};
|
|
38995
|
+
_proto._organizeEntities = function _organizeEntities() {
|
|
38996
|
+
var _this_context = this.context, rootIds = _this_context.rootIds, strippedIds = _this_context.strippedIds;
|
|
38997
|
+
var parentIds = rootIds.concat(strippedIds);
|
|
38998
|
+
for(var _iterator = _create_for_of_iterator_helper_loose(parentIds), _step; !(_step = _iterator()).done;){
|
|
38999
|
+
var parentId = _step.value;
|
|
39000
|
+
this._parseChildren(parentId);
|
|
39001
|
+
}
|
|
39002
|
+
for(var i = 0; i < rootIds.length; i++){
|
|
39003
|
+
this.handleRootEntity(rootIds[i]);
|
|
39004
|
+
}
|
|
39005
|
+
};
|
|
39006
|
+
_proto._getEntityByConfig = function _getEntityByConfig(entityConfig, engine) {
|
|
39007
|
+
var _this = this;
|
|
39008
|
+
var entityPromise;
|
|
39009
|
+
if (entityConfig.assetRefId) {
|
|
39010
|
+
entityPromise = this._parseGLTF(entityConfig, engine);
|
|
39011
|
+
} else if (entityConfig.strippedId) {
|
|
39012
|
+
entityPromise = this._parseStrippedEntity(entityConfig);
|
|
39013
|
+
} else {
|
|
39014
|
+
entityPromise = this._parseEntity(entityConfig, engine);
|
|
39015
|
+
}
|
|
39016
|
+
return entityPromise.then(function(entity) {
|
|
39017
|
+
return _this._applyEntityData(entity, entityConfig);
|
|
39018
|
+
});
|
|
39019
|
+
};
|
|
39020
|
+
_proto._parseEntity = function _parseEntity(entityConfig, engine) {
|
|
39021
|
+
var entity = new Entity(engine, entityConfig.name);
|
|
39022
|
+
if (!entityConfig.parent) this.context.rootIds.push(entityConfig.id);
|
|
39023
|
+
return Promise.resolve(entity);
|
|
39024
|
+
};
|
|
39025
|
+
_proto._parseGLTF = function _parseGLTF(entityConfig, engine) {
|
|
39026
|
+
var _this = this;
|
|
39027
|
+
var assetRefId = entityConfig.assetRefId;
|
|
39028
|
+
var context = new ParserContext(null, engine);
|
|
39029
|
+
return engine.resourceManager // @ts-ignore
|
|
39030
|
+
.getResourceByRef({
|
|
39031
|
+
refId: assetRefId
|
|
39032
|
+
}).then(function(glTFResource) {
|
|
39033
|
+
var entity = glTFResource.instantiateSceneRoot();
|
|
39034
|
+
if (!entityConfig.parent) _this.context.rootIds.push(entityConfig.id);
|
|
39035
|
+
_this._traverseAddEntityToMap(entity, context, "");
|
|
39036
|
+
_this.prefabContextMap.set(entity, context);
|
|
39037
|
+
var cbArray = _this.prefabPromiseMap.get(entityConfig.id);
|
|
39038
|
+
cbArray && cbArray.forEach(function(cb) {
|
|
39039
|
+
cb.resolve(context);
|
|
39040
|
+
});
|
|
39041
|
+
return entity;
|
|
39042
|
+
});
|
|
39043
|
+
};
|
|
39044
|
+
_proto._parseStrippedEntity = function _parseStrippedEntity(entityConfig) {
|
|
39045
|
+
var _this = this;
|
|
39046
|
+
this.context.strippedIds.push(entityConfig.id);
|
|
39047
|
+
return new Promise(function(resolve, reject) {
|
|
39048
|
+
var _this_prefabPromiseMap_get;
|
|
39049
|
+
var cbArray = (_this_prefabPromiseMap_get = _this.prefabPromiseMap.get(entityConfig.prefabInstanceId)) != null ? _this_prefabPromiseMap_get : [];
|
|
39050
|
+
cbArray.push({
|
|
39051
|
+
resolve: resolve,
|
|
39052
|
+
reject: reject
|
|
39053
|
+
});
|
|
39054
|
+
_this.prefabPromiseMap.set(entityConfig.prefabInstanceId, cbArray);
|
|
39055
|
+
}).then(function(context) {
|
|
39056
|
+
var entityId = entityConfig.prefabSource.entityId;
|
|
39057
|
+
return context.entityMap.get(entityId);
|
|
39058
|
+
});
|
|
39059
|
+
};
|
|
39060
|
+
_proto._parseChildren = function _parseChildren(parentId) {
|
|
39061
|
+
var _this_context = this.context, entityConfigMap = _this_context.entityConfigMap, entityMap = _this_context.entityMap;
|
|
39062
|
+
var children = entityConfigMap.get(parentId).children;
|
|
38680
39063
|
if (children && children.length > 0) {
|
|
38681
|
-
var parent =
|
|
39064
|
+
var parent = entityMap.get(parentId);
|
|
38682
39065
|
for(var i = 0; i < children.length; i++){
|
|
38683
39066
|
var childId = children[i];
|
|
38684
|
-
var entity =
|
|
39067
|
+
var entity = entityMap.get(childId);
|
|
38685
39068
|
parent.addChild(entity);
|
|
38686
|
-
this.
|
|
39069
|
+
this._parseChildren(childId);
|
|
38687
39070
|
}
|
|
38688
39071
|
}
|
|
38689
39072
|
};
|
|
38690
|
-
|
|
39073
|
+
_proto._applyEntityData = function _applyEntityData(entity, entityConfig) {
|
|
39074
|
+
if (entityConfig === void 0) entityConfig = {};
|
|
39075
|
+
var _entityConfig_isActive;
|
|
39076
|
+
entity.isActive = (_entityConfig_isActive = entityConfig.isActive) != null ? _entityConfig_isActive : entity.isActive;
|
|
39077
|
+
var _entityConfig_name;
|
|
39078
|
+
entity.name = (_entityConfig_name = entityConfig.name) != null ? _entityConfig_name : entity.name;
|
|
39079
|
+
var position = entityConfig.position, rotation = entityConfig.rotation, scale = entityConfig.scale;
|
|
39080
|
+
if (position) entity.transform.position.copyFrom(position);
|
|
39081
|
+
if (rotation) entity.transform.rotation.copyFrom(rotation);
|
|
39082
|
+
if (scale) entity.transform.scale.copyFrom(scale);
|
|
39083
|
+
return entity;
|
|
39084
|
+
};
|
|
39085
|
+
_proto._traverseAddEntityToMap = function _traverseAddEntityToMap(entity, context, path) {
|
|
39086
|
+
var entityMap = context.entityMap, components = context.components;
|
|
39087
|
+
var componentsMap = {};
|
|
39088
|
+
var componentIndexMap = {};
|
|
39089
|
+
entityMap.set(path, entity);
|
|
39090
|
+
// @ts-ignore
|
|
39091
|
+
entity._components.forEach(function(component) {
|
|
39092
|
+
// @ts-ignore
|
|
39093
|
+
var name = Loader.getClassName(component.constructor);
|
|
39094
|
+
if (!componentsMap[name]) {
|
|
39095
|
+
componentsMap[name] = entity.getComponents(component.constructor, []);
|
|
39096
|
+
componentIndexMap[name] = 0;
|
|
39097
|
+
}
|
|
39098
|
+
components.set(path + ":" + name + "/" + componentIndexMap[name]++, component);
|
|
39099
|
+
});
|
|
39100
|
+
for(var i = 0, n = entity.children.length; i < n; i++){
|
|
39101
|
+
var child = entity.children[i];
|
|
39102
|
+
var childPath = path ? path + "/" + i : "" + i;
|
|
39103
|
+
this._traverseAddEntityToMap(child, context, childPath);
|
|
39104
|
+
}
|
|
39105
|
+
};
|
|
39106
|
+
return HierarchyParser;
|
|
38691
39107
|
}();
|
|
38692
|
-
var
|
|
38693
|
-
|
|
38694
|
-
|
|
38695
|
-
|
|
38696
|
-
|
|
38697
|
-
|
|
38698
|
-
|
|
38699
|
-
|
|
38700
|
-
|
|
38701
|
-
|
|
38702
|
-
|
|
38703
|
-
|
|
38704
|
-
|
|
38705
|
-
|
|
39108
|
+
var PrefabParser = /*#__PURE__*/ function(HierarchyParser1) {
|
|
39109
|
+
var PrefabParser = function PrefabParser() {
|
|
39110
|
+
return HierarchyParser1.apply(this, arguments);
|
|
39111
|
+
};
|
|
39112
|
+
_inherits(PrefabParser, HierarchyParser1);
|
|
39113
|
+
var _proto = PrefabParser.prototype;
|
|
39114
|
+
_proto.handleRootEntity = function handleRootEntity(id) {
|
|
39115
|
+
this.context.target = this.context.entityMap.get(id);
|
|
39116
|
+
};
|
|
39117
|
+
/**
|
|
39118
|
+
* Parse prefab data.
|
|
39119
|
+
* @param engine - the engine of the parser context
|
|
39120
|
+
* @param prefabData - prefab data which is exported by editor
|
|
39121
|
+
* @returns a promise of prefab
|
|
39122
|
+
*/ PrefabParser.parse = function parse(engine, prefabData) {
|
|
39123
|
+
var context = new PrefabParserContext(prefabData, engine);
|
|
39124
|
+
var parser = new PrefabParser(context);
|
|
39125
|
+
parser.start();
|
|
39126
|
+
return parser;
|
|
39127
|
+
};
|
|
39128
|
+
return PrefabParser;
|
|
39129
|
+
}(HierarchyParser);
|
|
38706
39130
|
exports.InterpolableValueType = void 0;
|
|
38707
39131
|
(function(InterpolableValueType) {
|
|
38708
39132
|
InterpolableValueType[InterpolableValueType["Float"] = 0] = "Float";
|
|
@@ -38735,7 +39159,7 @@
|
|
|
38735
39159
|
for(var i1 = 0; i1 < curveBindingsLen; ++i1){
|
|
38736
39160
|
var relativePath = bufferReader.nextStr();
|
|
38737
39161
|
var componentStr = bufferReader.nextStr();
|
|
38738
|
-
var componentType =
|
|
39162
|
+
var componentType = Loader.getClass(componentStr);
|
|
38739
39163
|
var property = bufferReader.nextStr();
|
|
38740
39164
|
var getProperty = bufferReader.nextStr();
|
|
38741
39165
|
var curve = void 0;
|
|
@@ -38912,137 +39336,27 @@
|
|
|
38912
39336
|
SpecularMode["Sky"] = "Sky";
|
|
38913
39337
|
SpecularMode["Custom"] = "Custom";
|
|
38914
39338
|
})(exports.SpecularMode || (exports.SpecularMode = {}));
|
|
38915
|
-
function
|
|
38916
|
-
|
|
38917
|
-
|
|
38918
|
-
|
|
38919
|
-
|
|
38920
|
-
|
|
38921
|
-
|
|
38922
|
-
|
|
38923
|
-
var n = Object.prototype.toString.call(o).slice(8, -1);
|
|
38924
|
-
if (n === "Object" && o.constructor) n = o.constructor.name;
|
|
38925
|
-
if (n === "Map" || n === "Set") return Array.from(n);
|
|
38926
|
-
if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _array_like_to_array(o, minLen);
|
|
38927
|
-
}
|
|
38928
|
-
function _create_for_of_iterator_helper_loose(o, allowArrayLike) {
|
|
38929
|
-
var it = typeof Symbol !== "undefined" && o[Symbol.iterator] || o["@@iterator"];
|
|
38930
|
-
if (it) return (it = it.call(o)).next.bind(it);
|
|
38931
|
-
// Fallback for engines without symbol support
|
|
38932
|
-
if (Array.isArray(o) || (it = _unsupported_iterable_to_array(o)) || allowArrayLike && o && typeof o.length === "number") {
|
|
38933
|
-
if (it) o = it;
|
|
38934
|
-
var i = 0;
|
|
38935
|
-
return function() {
|
|
38936
|
-
if (i >= o.length) return {
|
|
38937
|
-
done: true
|
|
38938
|
-
};
|
|
38939
|
-
return {
|
|
38940
|
-
done: false,
|
|
38941
|
-
value: o[i++]
|
|
38942
|
-
};
|
|
38943
|
-
};
|
|
38944
|
-
}
|
|
38945
|
-
throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
|
|
38946
|
-
}
|
|
38947
|
-
var SceneParserContext = /*#__PURE__*/ function() {
|
|
38948
|
-
var SceneParserContext = function SceneParserContext(originalData, scene) {
|
|
38949
|
-
this.originalData = originalData;
|
|
38950
|
-
this.scene = scene;
|
|
38951
|
-
this.entityMap = new Map();
|
|
38952
|
-
this.components = new Map();
|
|
38953
|
-
this.assets = new Map();
|
|
38954
|
-
this.entityConfigMap = new Map();
|
|
38955
|
-
this.rootIds = [];
|
|
38956
|
-
this.engine = scene.engine;
|
|
38957
|
-
this.resourceManager = scene.engine.resourceManager;
|
|
38958
|
-
};
|
|
38959
|
-
var _proto = SceneParserContext.prototype;
|
|
38960
|
-
_proto.destroy = function destroy() {
|
|
38961
|
-
this.entityMap.clear();
|
|
38962
|
-
this.components.clear();
|
|
38963
|
-
this.assets.clear();
|
|
38964
|
-
this.entityConfigMap.clear();
|
|
38965
|
-
this.rootIds.length = 0;
|
|
39339
|
+
var SceneParserContext = /*#__PURE__*/ function(ParserContext1) {
|
|
39340
|
+
var SceneParserContext = function SceneParserContext(originalData, engine, scene) {
|
|
39341
|
+
var _this;
|
|
39342
|
+
_this = ParserContext1.call(this, originalData, engine, scene) || this;
|
|
39343
|
+
_this.originalData = originalData;
|
|
39344
|
+
_this.engine = engine;
|
|
39345
|
+
_this.scene = scene;
|
|
39346
|
+
return _this;
|
|
38966
39347
|
};
|
|
39348
|
+
_inherits(SceneParserContext, ParserContext1);
|
|
38967
39349
|
return SceneParserContext;
|
|
38968
|
-
}();
|
|
38969
|
-
/** @Internal */ var SceneParser = /*#__PURE__*/ function() {
|
|
38970
|
-
var SceneParser = function SceneParser(
|
|
38971
|
-
|
|
38972
|
-
this.context = context;
|
|
38973
|
-
this._engine = context.scene.engine;
|
|
38974
|
-
this._organizeEntities = this._organizeEntities.bind(this);
|
|
38975
|
-
this._parseComponents = this._parseComponents.bind(this);
|
|
38976
|
-
this._clearAndResolveScene = this._clearAndResolveScene.bind(this);
|
|
38977
|
-
this.promise = new Promise(function(resolve, reject) {
|
|
38978
|
-
_this._reject = reject;
|
|
38979
|
-
_this._resolve = resolve;
|
|
38980
|
-
});
|
|
38981
|
-
this._reflectionParser = new ReflectionParser(context);
|
|
39350
|
+
}(ParserContext);
|
|
39351
|
+
/** @Internal */ var SceneParser = /*#__PURE__*/ function(HierarchyParser1) {
|
|
39352
|
+
var SceneParser = function SceneParser() {
|
|
39353
|
+
return HierarchyParser1.apply(this, arguments);
|
|
38982
39354
|
};
|
|
39355
|
+
_inherits(SceneParser, HierarchyParser1);
|
|
38983
39356
|
var _proto = SceneParser.prototype;
|
|
38984
|
-
|
|
38985
|
-
this.
|
|
38986
|
-
|
|
38987
|
-
_proto._parseEntities = function _parseEntities() {
|
|
38988
|
-
var _this = this;
|
|
38989
|
-
var entitiesConfig = this.context.originalData.entities;
|
|
38990
|
-
var entityConfigMap = this.context.entityConfigMap;
|
|
38991
|
-
var entitiesMap = this.context.entityMap;
|
|
38992
|
-
var rootIds = this.context.rootIds;
|
|
38993
|
-
this._engine;
|
|
38994
|
-
var promises = entitiesConfig.map(function(entityConfig) {
|
|
38995
|
-
entityConfigMap.set(entityConfig.id, entityConfig);
|
|
38996
|
-
// record root entities
|
|
38997
|
-
if (!entityConfig.parent) rootIds.push(entityConfig.id);
|
|
38998
|
-
return _this._reflectionParser.parseEntity(entityConfig);
|
|
38999
|
-
});
|
|
39000
|
-
return Promise.all(promises).then(function(entities) {
|
|
39001
|
-
for(var i = 0, l = entities.length; i < l; i++){
|
|
39002
|
-
entitiesMap.set(entitiesConfig[i].id, entities[i]);
|
|
39003
|
-
}
|
|
39004
|
-
return entities;
|
|
39005
|
-
});
|
|
39006
|
-
};
|
|
39007
|
-
_proto._organizeEntities = function _organizeEntities() {
|
|
39008
|
-
var _this_context = this.context, entityConfigMap = _this_context.entityConfigMap, entityMap = _this_context.entityMap, scene = _this_context.scene, rootIds = _this_context.rootIds;
|
|
39009
|
-
for(var _iterator = _create_for_of_iterator_helper_loose(rootIds), _step; !(_step = _iterator()).done;){
|
|
39010
|
-
var rootId = _step.value;
|
|
39011
|
-
PrefabParser.parseChildren(entityConfigMap, entityMap, rootId);
|
|
39012
|
-
}
|
|
39013
|
-
var rootEntities = rootIds.map(function(id) {
|
|
39014
|
-
return entityMap.get(id);
|
|
39015
|
-
});
|
|
39016
|
-
for(var i = 0; i < rootEntities.length; i++){
|
|
39017
|
-
scene.addRootEntity(rootEntities[i]);
|
|
39018
|
-
}
|
|
39019
|
-
};
|
|
39020
|
-
_proto._parseComponents = function _parseComponents() {
|
|
39021
|
-
var entitiesConfig = this.context.originalData.entities;
|
|
39022
|
-
var entityMap = this.context.entityMap;
|
|
39023
|
-
var promises = [];
|
|
39024
|
-
for(var i = 0, l = entitiesConfig.length; i < l; i++){
|
|
39025
|
-
var entityConfig = entitiesConfig[i];
|
|
39026
|
-
var entity = entityMap.get(entityConfig.id);
|
|
39027
|
-
for(var i1 = 0; i1 < entityConfig.components.length; i1++){
|
|
39028
|
-
var componentConfig = entityConfig.components[i1];
|
|
39029
|
-
var key = !componentConfig.refId ? componentConfig.class : componentConfig.refId;
|
|
39030
|
-
var component = void 0;
|
|
39031
|
-
// TODO: remove hack code when support additional edit
|
|
39032
|
-
if (key === "Animator") {
|
|
39033
|
-
component = entity.getComponent(Loader.getClass(key));
|
|
39034
|
-
}
|
|
39035
|
-
component = component || entity.addComponent(Loader.getClass(key));
|
|
39036
|
-
var promise = this._reflectionParser.parsePropsAndMethods(component, componentConfig);
|
|
39037
|
-
promises.push(promise);
|
|
39038
|
-
}
|
|
39039
|
-
}
|
|
39040
|
-
return Promise.all(promises);
|
|
39041
|
-
};
|
|
39042
|
-
_proto._clearAndResolveScene = function _clearAndResolveScene() {
|
|
39043
|
-
var scene = this.context.scene;
|
|
39044
|
-
this.context.destroy();
|
|
39045
|
-
return scene;
|
|
39357
|
+
_proto.handleRootEntity = function handleRootEntity(id) {
|
|
39358
|
+
var _this_context = this.context, target = _this_context.target, entityMap = _this_context.entityMap;
|
|
39359
|
+
target.addRootEntity(entityMap.get(id));
|
|
39046
39360
|
};
|
|
39047
39361
|
/**
|
|
39048
39362
|
* Parse scene data.
|
|
@@ -39051,13 +39365,13 @@
|
|
|
39051
39365
|
* @returns a promise of scene
|
|
39052
39366
|
*/ SceneParser.parse = function parse(engine, sceneData) {
|
|
39053
39367
|
var scene = new Scene(engine);
|
|
39054
|
-
var context = new SceneParserContext(sceneData, scene);
|
|
39368
|
+
var context = new SceneParserContext(sceneData, engine, scene);
|
|
39055
39369
|
var parser = new SceneParser(context);
|
|
39056
39370
|
parser.start();
|
|
39057
39371
|
return parser.promise;
|
|
39058
39372
|
};
|
|
39059
39373
|
return SceneParser;
|
|
39060
|
-
}();
|
|
39374
|
+
}(HierarchyParser);
|
|
39061
39375
|
exports.MeshLoader = /*#__PURE__*/ function(Loader1) {
|
|
39062
39376
|
var MeshLoader = function MeshLoader() {
|
|
39063
39377
|
return Loader1.apply(this, arguments);
|
|
@@ -39158,7 +39472,7 @@
|
|
|
39158
39472
|
resourceManager // @ts-ignore
|
|
39159
39473
|
.getResourceByRef(value).then(function(asset) {
|
|
39160
39474
|
keyframe.value = asset;
|
|
39161
|
-
resolve(keyframe);
|
|
39475
|
+
resolve(keyframe.value);
|
|
39162
39476
|
});
|
|
39163
39477
|
});
|
|
39164
39478
|
} else {
|
|
@@ -40157,7 +40471,7 @@
|
|
|
40157
40471
|
};
|
|
40158
40472
|
/**
|
|
40159
40473
|
* Parse the glb format.
|
|
40160
|
-
*/ GLTFUtils.parseGLB = function parseGLB(context,
|
|
40474
|
+
*/ GLTFUtils.parseGLB = function parseGLB(context, originBuffer) {
|
|
40161
40475
|
var UINT32_LENGTH = 4;
|
|
40162
40476
|
var GLB_HEADER_MAGIC = 0x46546c67; // 'glTF'
|
|
40163
40477
|
var GLB_HEADER_LENGTH = 12;
|
|
@@ -40165,7 +40479,7 @@
|
|
|
40165
40479
|
JSON: 0x4e4f534a,
|
|
40166
40480
|
BIN: 0x004e4942
|
|
40167
40481
|
};
|
|
40168
|
-
var dataView = new DataView(
|
|
40482
|
+
var dataView = new DataView(originBuffer);
|
|
40169
40483
|
// read header
|
|
40170
40484
|
var header = {
|
|
40171
40485
|
magic: dataView.getUint32(0, true),
|
|
@@ -40173,8 +40487,9 @@
|
|
|
40173
40487
|
length: dataView.getUint32(2 * UINT32_LENGTH, true)
|
|
40174
40488
|
};
|
|
40175
40489
|
if (header.magic !== GLB_HEADER_MAGIC) {
|
|
40176
|
-
|
|
40177
|
-
|
|
40490
|
+
return {
|
|
40491
|
+
originBuffer: originBuffer
|
|
40492
|
+
};
|
|
40178
40493
|
}
|
|
40179
40494
|
// read main data
|
|
40180
40495
|
var chunkLength = dataView.getUint32(GLB_HEADER_LENGTH, true);
|
|
@@ -40184,7 +40499,7 @@
|
|
|
40184
40499
|
console.error("Invalid glb chunk type. Expected 0x4E4F534A, found 0x" + chunkType.toString(16));
|
|
40185
40500
|
return null;
|
|
40186
40501
|
}
|
|
40187
|
-
var glTFData = new Uint8Array(
|
|
40502
|
+
var glTFData = new Uint8Array(originBuffer, GLB_HEADER_LENGTH + 2 * UINT32_LENGTH, chunkLength);
|
|
40188
40503
|
var glTF = JSON.parse(Utils.decodeText(glTFData));
|
|
40189
40504
|
// read all buffers
|
|
40190
40505
|
var buffers = [];
|
|
@@ -40198,7 +40513,7 @@
|
|
|
40198
40513
|
return null;
|
|
40199
40514
|
}
|
|
40200
40515
|
var currentOffset = byteOffset + 2 * UINT32_LENGTH;
|
|
40201
|
-
var buffer =
|
|
40516
|
+
var buffer = originBuffer.slice(currentOffset, currentOffset + chunkLength);
|
|
40202
40517
|
buffers.push(buffer);
|
|
40203
40518
|
restoreGLBBufferSlice.push(new Vector2(currentOffset, chunkLength));
|
|
40204
40519
|
byteOffset += chunkLength + 2 * UINT32_LENGTH;
|
|
@@ -41598,23 +41913,20 @@
|
|
|
41598
41913
|
var requestConfig = {
|
|
41599
41914
|
type: "arraybuffer"
|
|
41600
41915
|
};
|
|
41601
|
-
|
|
41602
|
-
contentRestorer.isGLB = isGLB;
|
|
41603
|
-
var promise = isGLB ? request(url, requestConfig).onProgress(undefined, context._onTaskDetail).then(function(glb) {
|
|
41916
|
+
return request(url, requestConfig).onProgress(undefined, context._onTaskDetail).then(function(buffer) {
|
|
41604
41917
|
restoreBufferRequests.push(new BufferRequestInfo(url, requestConfig));
|
|
41605
|
-
return GLTFUtils.parseGLB(context,
|
|
41606
|
-
}).then(function(
|
|
41607
|
-
var
|
|
41608
|
-
|
|
41609
|
-
|
|
41610
|
-
|
|
41611
|
-
|
|
41612
|
-
|
|
41613
|
-
|
|
41614
|
-
|
|
41615
|
-
|
|
41616
|
-
|
|
41617
|
-
return url.substring(index + 1, index + 4) === "glb";
|
|
41918
|
+
return GLTFUtils.parseGLB(context, buffer);
|
|
41919
|
+
}).then(function(result) {
|
|
41920
|
+
var _result;
|
|
41921
|
+
if ((_result = result) == null ? void 0 : _result.glTF) {
|
|
41922
|
+
contentRestorer.isGLB = true;
|
|
41923
|
+
context.buffers = result.buffers;
|
|
41924
|
+
return result.glTF;
|
|
41925
|
+
} else {
|
|
41926
|
+
contentRestorer.isGLB = false;
|
|
41927
|
+
return JSON.parse(Utils.decodeText(new Uint8Array(result.originBuffer)));
|
|
41928
|
+
}
|
|
41929
|
+
});
|
|
41618
41930
|
};
|
|
41619
41931
|
return GLTFSchemaParser;
|
|
41620
41932
|
}(GLTFParser);
|
|
@@ -43563,6 +43875,84 @@
|
|
|
43563
43875
|
"mesh"
|
|
43564
43876
|
])
|
|
43565
43877
|
], MeshLoader);
|
|
43878
|
+
var PrimitiveMeshLoader = /*#__PURE__*/ function(Loader1) {
|
|
43879
|
+
var PrimitiveMeshLoader = function PrimitiveMeshLoader() {
|
|
43880
|
+
return Loader1.apply(this, arguments);
|
|
43881
|
+
};
|
|
43882
|
+
_inherits(PrimitiveMeshLoader, Loader1);
|
|
43883
|
+
var _proto = PrimitiveMeshLoader.prototype;
|
|
43884
|
+
_proto.load = function load(item, param) {
|
|
43885
|
+
var engine = param.engine;
|
|
43886
|
+
return this.request(item.url, _extends({}, item, {
|
|
43887
|
+
type: "json"
|
|
43888
|
+
})).then(function(data) {
|
|
43889
|
+
switch(data.type){
|
|
43890
|
+
case "sphere":
|
|
43891
|
+
return PrimitiveMesh.createSubdivisionSurfaceSphere(engine, data.sphereRadius, data.sphereStep);
|
|
43892
|
+
case "capsule":
|
|
43893
|
+
return PrimitiveMesh.createCapsule(engine, data.capsuleRadius, data.capsuleHeight, data.capsuleRadialSegments, data.capsuleHeightSegments);
|
|
43894
|
+
case "cone":
|
|
43895
|
+
return PrimitiveMesh.createCone(engine, data.coneRadius, data.coneHeight, data.coneRadialSegment, data.coneHeightSegment);
|
|
43896
|
+
case "cuboid":
|
|
43897
|
+
return PrimitiveMesh.createCuboid(engine, data.cuboidWidth, data.cuboidHeight, data.cuboidDepth);
|
|
43898
|
+
case "cylinder":
|
|
43899
|
+
return PrimitiveMesh.createCylinder(engine, data.cylinderRadiusTop, data.cylinderRadiusBottom, data.cylinderHeight, data.cylinderRadialSegment, data.cylinderHeightSegment);
|
|
43900
|
+
case "plane":
|
|
43901
|
+
return PrimitiveMesh.createPlane(engine, data.planeWidth, data.planeHeight, data.planeHorizontalSegments, data.planeVerticalSegments);
|
|
43902
|
+
case "torus":
|
|
43903
|
+
return PrimitiveMesh.createTorus(engine, data.torusRadius, data.torusTubeRadius, data.torusRadialSegments, data.torusTubularSegments, data.torusArc);
|
|
43904
|
+
}
|
|
43905
|
+
});
|
|
43906
|
+
};
|
|
43907
|
+
return PrimitiveMeshLoader;
|
|
43908
|
+
}(Loader);
|
|
43909
|
+
PrimitiveMeshLoader = __decorate([
|
|
43910
|
+
resourceLoader(exports.AssetType.PrimitiveMesh, [
|
|
43911
|
+
"mesh"
|
|
43912
|
+
], false)
|
|
43913
|
+
], PrimitiveMeshLoader);
|
|
43914
|
+
var /** @internal */ PrimitiveMeshType;
|
|
43915
|
+
(function(PrimitiveMeshType) {
|
|
43916
|
+
PrimitiveMeshType["Sphere"] = "sphere";
|
|
43917
|
+
PrimitiveMeshType["Cuboid"] = "cuboid";
|
|
43918
|
+
PrimitiveMeshType["Plane"] = "plane";
|
|
43919
|
+
PrimitiveMeshType["Cylinder"] = "cylinder";
|
|
43920
|
+
PrimitiveMeshType["Torus"] = "torus";
|
|
43921
|
+
PrimitiveMeshType["Cone"] = "cone";
|
|
43922
|
+
PrimitiveMeshType["Capsule"] = "capsule";
|
|
43923
|
+
})(PrimitiveMeshType || (PrimitiveMeshType = {}));
|
|
43924
|
+
var ProjectLoader = /*#__PURE__*/ function(Loader1) {
|
|
43925
|
+
var ProjectLoader = function ProjectLoader() {
|
|
43926
|
+
return Loader1.apply(this, arguments);
|
|
43927
|
+
};
|
|
43928
|
+
_inherits(ProjectLoader, Loader1);
|
|
43929
|
+
var _proto = ProjectLoader.prototype;
|
|
43930
|
+
_proto.load = function load(item, resourceManager) {
|
|
43931
|
+
var _this = this;
|
|
43932
|
+
var engine = resourceManager.engine;
|
|
43933
|
+
return new AssetPromise(function(resolve, reject) {
|
|
43934
|
+
_this.request(item.url, {
|
|
43935
|
+
type: "json"
|
|
43936
|
+
}).then(function(data) {
|
|
43937
|
+
// @ts-ignore
|
|
43938
|
+
engine.resourceManager.initVirtualResources(data.files);
|
|
43939
|
+
return resourceManager.load({
|
|
43940
|
+
type: exports.AssetType.Scene,
|
|
43941
|
+
url: data.scene
|
|
43942
|
+
}).then(function(scene) {
|
|
43943
|
+
engine.sceneManager.activeScene = scene;
|
|
43944
|
+
resolve();
|
|
43945
|
+
});
|
|
43946
|
+
}).catch(reject);
|
|
43947
|
+
});
|
|
43948
|
+
};
|
|
43949
|
+
return ProjectLoader;
|
|
43950
|
+
}(Loader);
|
|
43951
|
+
ProjectLoader = __decorate([
|
|
43952
|
+
resourceLoader(exports.AssetType.Project, [
|
|
43953
|
+
"proj"
|
|
43954
|
+
], false)
|
|
43955
|
+
], ProjectLoader);
|
|
43566
43956
|
var SourceFontLoader = /*#__PURE__*/ function(Loader1) {
|
|
43567
43957
|
var SourceFontLoader = function SourceFontLoader() {
|
|
43568
43958
|
return Loader1.apply(this, arguments);
|
|
@@ -43891,38 +44281,6 @@
|
|
|
43891
44281
|
""
|
|
43892
44282
|
])
|
|
43893
44283
|
], TextureCubeLoader);
|
|
43894
|
-
var ProjectLoader = /*#__PURE__*/ function(Loader1) {
|
|
43895
|
-
var ProjectLoader = function ProjectLoader() {
|
|
43896
|
-
return Loader1.apply(this, arguments);
|
|
43897
|
-
};
|
|
43898
|
-
_inherits(ProjectLoader, Loader1);
|
|
43899
|
-
var _proto = ProjectLoader.prototype;
|
|
43900
|
-
_proto.load = function load(item, resourceManager) {
|
|
43901
|
-
var _this = this;
|
|
43902
|
-
var engine = resourceManager.engine;
|
|
43903
|
-
return new AssetPromise(function(resolve, reject) {
|
|
43904
|
-
_this.request(item.url, {
|
|
43905
|
-
type: "json"
|
|
43906
|
-
}).then(function(data) {
|
|
43907
|
-
// @ts-ignore
|
|
43908
|
-
engine.resourceManager.initVirtualResources(data.files);
|
|
43909
|
-
return resourceManager.load({
|
|
43910
|
-
type: exports.AssetType.Scene,
|
|
43911
|
-
url: data.scene
|
|
43912
|
-
}).then(function(scene) {
|
|
43913
|
-
engine.sceneManager.activeScene = scene;
|
|
43914
|
-
resolve();
|
|
43915
|
-
});
|
|
43916
|
-
}).catch(reject);
|
|
43917
|
-
});
|
|
43918
|
-
};
|
|
43919
|
-
return ProjectLoader;
|
|
43920
|
-
}(Loader);
|
|
43921
|
-
ProjectLoader = __decorate([
|
|
43922
|
-
resourceLoader(exports.AssetType.Project, [
|
|
43923
|
-
"proj"
|
|
43924
|
-
], false)
|
|
43925
|
-
], ProjectLoader);
|
|
43926
44284
|
var SceneLoader = /*#__PURE__*/ function(Loader1) {
|
|
43927
44285
|
var SceneLoader = function SceneLoader() {
|
|
43928
44286
|
return Loader1.apply(this, arguments);
|
|
@@ -43941,7 +44299,7 @@
|
|
|
43941
44299
|
// parse ambient light
|
|
43942
44300
|
var ambient = data.scene.ambient;
|
|
43943
44301
|
if (ambient) {
|
|
43944
|
-
var useCustomAmbient = ambient.specularMode ===
|
|
44302
|
+
var useCustomAmbient = ambient.specularMode === exports.SpecularMode.Custom;
|
|
43945
44303
|
var useSH = ambient.diffuseMode === exports.DiffuseMode.SphericalHarmonics;
|
|
43946
44304
|
scene.ambientLight.diffuseIntensity = ambient.diffuseIntensity;
|
|
43947
44305
|
scene.ambientLight.specularIntensity = ambient.specularIntensity;
|
|
@@ -44010,6 +44368,8 @@
|
|
|
44010
44368
|
var _shadow_shadowTwoCascadeSplits;
|
|
44011
44369
|
scene.shadowTwoCascadeSplits = (_shadow_shadowTwoCascadeSplits = shadow.shadowTwoCascadeSplits) != null ? _shadow_shadowTwoCascadeSplits : scene.shadowTwoCascadeSplits;
|
|
44012
44370
|
shadow.shadowFourCascadeSplits && scene.shadowFourCascadeSplits.copyFrom(shadow.shadowFourCascadeSplits);
|
|
44371
|
+
var _shadow_shadowFadeBorder;
|
|
44372
|
+
scene.shadowFadeBorder = (_shadow_shadowFadeBorder = shadow.shadowFadeBorder) != null ? _shadow_shadowFadeBorder : scene.shadowFadeBorder;
|
|
44013
44373
|
}
|
|
44014
44374
|
return Promise.all(promises).then(function() {
|
|
44015
44375
|
resolve(scene);
|
|
@@ -44400,7 +44760,7 @@
|
|
|
44400
44760
|
], KHR_materials_anisotropy);
|
|
44401
44761
|
|
|
44402
44762
|
//@ts-ignore
|
|
44403
|
-
var version = "1.2.0-alpha.
|
|
44763
|
+
var version = "1.2.0-alpha.11";
|
|
44404
44764
|
console.log("Galacean engine version: " + version);
|
|
44405
44765
|
for(var key in CoreObjects){
|
|
44406
44766
|
Loader.registerClass(key, CoreObjects[key]);
|
|
@@ -44448,7 +44808,6 @@
|
|
|
44448
44808
|
exports.Color = Color;
|
|
44449
44809
|
exports.ColorOverLifetimeModule = ColorOverLifetimeModule;
|
|
44450
44810
|
exports.Component = Component;
|
|
44451
|
-
exports.ComponentMap = ComponentMap;
|
|
44452
44811
|
exports.ConeShape = ConeShape;
|
|
44453
44812
|
exports.ContentRestorer = ContentRestorer;
|
|
44454
44813
|
exports.CubeProbe = CubeProbe;
|
|
@@ -44492,6 +44851,7 @@
|
|
|
44492
44851
|
exports.PBRBaseMaterial = PBRBaseMaterial;
|
|
44493
44852
|
exports.PBRMaterial = PBRMaterial;
|
|
44494
44853
|
exports.PBRSpecularMaterial = PBRSpecularMaterial;
|
|
44854
|
+
exports.ParserContext = ParserContext;
|
|
44495
44855
|
exports.ParticleCompositeCurve = ParticleCompositeCurve;
|
|
44496
44856
|
exports.ParticleCompositeGradient = ParticleCompositeGradient;
|
|
44497
44857
|
exports.ParticleCurve = ParticleCurve;
|