@galacean/engine 1.2.0-alpha.1 → 1.2.0-alpha.3

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 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 /^(?:http|blob|data:|\/)/.test(url);
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
- return baseUrl.substring(0, baseUrl.lastIndexOf("/") + 1) + this._formatRelativePath(relativeUrl);
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;geometry.viewDir=normalize(camera_Position-v_pos);\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
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
@@ -8267,7 +8277,11 @@
8267
8277
  }
8268
8278
  ShaderLib[includeName] = includeSource;
8269
8279
  };
8270
- ShaderFactory.parseIncludes = function parseIncludes(src) {
8280
+ /**
8281
+ * @param regex The default regex is for engine's builtin glsl `#include` syntax,
8282
+ * since `ShaderLab` use the same parsing function but different syntax for `#include` --- `/^[ \t]*#include +"([\w\d.]+)"/gm`
8283
+ */ ShaderFactory.parseIncludes = function parseIncludes(src, regex) {
8284
+ if (regex === void 0) regex = /^[ \t]*#include +<([\w\d.]+)>/gm;
8271
8285
  var replace = function replace(match, slice) {
8272
8286
  var replace = ShaderLib[slice];
8273
8287
  if (replace === undefined) {
@@ -8276,7 +8290,6 @@
8276
8290
  }
8277
8291
  return ShaderFactory.parseIncludes(replace);
8278
8292
  };
8279
- var regex = /^[ \t]*#include +<([\w\d.]+)>/gm;
8280
8293
  return src.replace(regex, replace);
8281
8294
  };
8282
8295
  /**
@@ -11229,7 +11242,7 @@
11229
11242
  _this._byteLength = byteLength;
11230
11243
  _this._platformBuffer = engine._hardwareRenderer.createPlatformBuffer(type, byteLength, bufferUsage, data);
11231
11244
  if (readable) {
11232
- var buffer = (data.constructor === ArrayBuffer ? data : data.buffer).slice(0, byteLength);
11245
+ var buffer = data.constructor === ArrayBuffer ? data.slice(0) : data.buffer.slice(data.byteOffset, data.byteOffset + byteLength);
11233
11246
  _this._data = new Uint8Array(buffer);
11234
11247
  }
11235
11248
  }
@@ -17678,6 +17691,9 @@
17678
17691
  var baseline = Math.ceil(context.measureText(TextUtils._measureBaseline).width);
17679
17692
  var height = baseline * TextUtils._heightMultiplier;
17680
17693
  baseline = TextUtils._baselineMultiplier * baseline | 0;
17694
+ var _extendHeight = TextUtils._extendHeight;
17695
+ height += _extendHeight;
17696
+ baseline += _extendHeight * 0.5;
17681
17697
  canvas.width = width;
17682
17698
  canvas.height = height;
17683
17699
  context.font = fontString;
@@ -17712,6 +17728,7 @@
17712
17728
  }
17713
17729
  if (top !== -1 && bottom !== -1) {
17714
17730
  ascent = baseline - top;
17731
+ // Baseline belong to descent
17715
17732
  descent = bottom - baseline + 1;
17716
17733
  size = ascent + descent;
17717
17734
  }
@@ -17788,9 +17805,8 @@
17788
17805
  ];
17789
17806
  })();
17790
17807
  (function() {
17791
- // _heightMultiplier used to measure the height of text, but in miniprogram performance is different from h5.
17792
- // so can set _heightMultiplier to adapt miniprogram, the larger the value, the worse the performance.
17793
- /** @internal */ TextUtils._heightMultiplier = 2;
17808
+ // _extendHeight used to extend the height of canvas, because in miniprogram performance is different from h5.
17809
+ /** @internal */ TextUtils._extendHeight = 0;
17794
17810
  })();
17795
17811
  (function() {
17796
17812
  /** These characters are all tall to help calculate the height required for text. */ TextUtils._measureString = "|\xc9q\xc5";
@@ -17798,6 +17814,9 @@
17798
17814
  (function() {
17799
17815
  TextUtils._measureBaseline = "M";
17800
17816
  })();
17817
+ (function() {
17818
+ TextUtils._heightMultiplier = 2;
17819
+ })();
17801
17820
  (function() {
17802
17821
  TextUtils._baselineMultiplier = 1.4;
17803
17822
  })();
@@ -19539,6 +19558,7 @@
19539
19558
  AssetType[/** Cube Compress Texture. */ "KTXCube"] = "KTXCube";
19540
19559
  AssetType[/** KTX2 Compress Texture */ "KTX2"] = "KTX2";
19541
19560
  AssetType[/** Sprite. */ "Sprite"] = "Sprite";
19561
+ AssetType[/** PrimitiveMesh. */ "PrimitiveMesh"] = "PrimitiveMesh";
19542
19562
  AssetType[/** Sprite Atlas. */ "SpriteAtlas"] = "SpriteAtlas";
19543
19563
  AssetType[/** Ambient light. */ "Env"] = "Environment";
19544
19564
  AssetType[/** Scene. */ "Scene"] = "Scene";
@@ -19920,6 +19940,7 @@
19920
19940
  this./** The number of retries after failing to load assets. */ retryCount = 1;
19921
19941
  this./** Retry delay time after failed to load assets, in milliseconds. */ retryInterval = 0;
19922
19942
  this./** The default timeout period for loading assets, in milliseconds. */ timeout = Infinity;
19943
+ this./** Base url for loading assets. */ baseUrl = null;
19923
19944
  this._loadingPromises = {};
19924
19945
  this._assetPool = Object.create(null);
19925
19946
  this._assetUrlPool = Object.create(null);
@@ -20122,6 +20143,8 @@
20122
20143
  // Check url mapping
20123
20144
  var itemURL = item.url;
20124
20145
  var url = this._virtualPathMap[itemURL] ? this._virtualPathMap[itemURL] : itemURL;
20146
+ // Not absolute and base url is set
20147
+ if (!Utils.isAbsoluteUrl(url) && this.baseUrl) url = Utils.resolveAbsoluteUrl(this.baseUrl, url);
20125
20148
  // Parse url
20126
20149
  var _this__parseURL = this._parseURL(url), assetBaseURL = _this__parseURL.assetBaseURL, queryPath = _this__parseURL.queryPath;
20127
20150
  var paths = queryPath ? this._parseQueryPath(queryPath) : [];
@@ -20805,7 +20828,7 @@
20805
20828
  * Keyboard Manager.
20806
20829
  * @internal
20807
20830
  */ var KeyboardManager = /*#__PURE__*/ function() {
20808
- var KeyboardManager = function KeyboardManager(engine) {
20831
+ var KeyboardManager = function KeyboardManager(engine, target) {
20809
20832
  /** @internal */ this._curHeldDownKeyToIndexMap = [];
20810
20833
  /** @internal */ this._upKeyToFrameCountMap = [];
20811
20834
  /** @internal */ this._downKeyToFrameCountMap = [];
@@ -20813,17 +20836,11 @@
20813
20836
  /** @internal */ this._curFrameDownList = new DisorderedArray();
20814
20837
  /** @internal */ this._curFrameUpList = new DisorderedArray();
20815
20838
  this._nativeEvents = [];
20816
- this._hadListener = false;
20817
- // @ts-ignore
20818
- var htmlCanvas = engine._canvas._webCanvas;
20819
20839
  this._engine = engine;
20820
- this._htmlCanvas = htmlCanvas;
20821
- // Need to set tabIndex to make the canvas focus.
20822
- htmlCanvas.tabIndex = htmlCanvas.tabIndex;
20840
+ this._onBlur = this._onBlur.bind(this);
20823
20841
  this._onKeyEvent = this._onKeyEvent.bind(this);
20824
- htmlCanvas.addEventListener("keydown", this._onKeyEvent);
20825
- htmlCanvas.addEventListener("keyup", this._onKeyEvent);
20826
- this._hadListener = true;
20842
+ this._target = target;
20843
+ this._addEventListener();
20827
20844
  };
20828
20845
  var _proto = KeyboardManager.prototype;
20829
20846
  /**
@@ -20875,35 +20892,8 @@
20875
20892
  };
20876
20893
  /**
20877
20894
  * @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
20895
  */ _proto._destroy = function _destroy() {
20902
- if (this._hadListener) {
20903
- this._htmlCanvas.removeEventListener("keydown", this._onKeyEvent);
20904
- this._htmlCanvas.removeEventListener("keyup", this._onKeyEvent);
20905
- this._hadListener = false;
20906
- }
20896
+ this._removeEventListener();
20907
20897
  this._curHeldDownKeyToIndexMap.length = 0;
20908
20898
  this._curHeldDownKeyToIndexMap = null;
20909
20899
  this._upKeyToFrameCountMap.length = 0;
@@ -20918,12 +20908,30 @@
20918
20908
  this._curFrameDownList = null;
20919
20909
  this._curFrameUpList.length = 0;
20920
20910
  this._curFrameUpList = null;
20921
- this._htmlCanvas = null;
20922
20911
  this._engine = null;
20923
20912
  };
20913
+ _proto._onBlur = function _onBlur() {
20914
+ this._curHeldDownKeyToIndexMap.length = 0;
20915
+ this._curFrameHeldDownList.length = 0;
20916
+ this._curFrameDownList.length = 0;
20917
+ this._curFrameUpList.length = 0;
20918
+ this._nativeEvents.length = 0;
20919
+ };
20924
20920
  _proto._onKeyEvent = function _onKeyEvent(evt) {
20925
20921
  this._nativeEvents.push(evt);
20926
20922
  };
20923
+ _proto._addEventListener = function _addEventListener() {
20924
+ var _this = this, target = _this._target;
20925
+ target.addEventListener("keydown", this._onKeyEvent);
20926
+ target.addEventListener("keyup", this._onKeyEvent);
20927
+ target.addEventListener("blur", this._onBlur);
20928
+ };
20929
+ _proto._removeEventListener = function _removeEventListener() {
20930
+ var _this = this, target = _this._target;
20931
+ target.removeEventListener("keydown", this._onKeyEvent);
20932
+ target.removeEventListener("keyup", this._onKeyEvent);
20933
+ target.removeEventListener("blur", this._onBlur);
20934
+ };
20927
20935
  return KeyboardManager;
20928
20936
  }();
20929
20937
  /**
@@ -22860,7 +22868,7 @@
22860
22868
  * Pointer Manager.
22861
22869
  * @internal
22862
22870
  */ var PointerManager = /*#__PURE__*/ function() {
22863
- var PointerManager = function PointerManager(engine) {
22871
+ var PointerManager = function PointerManager(engine, target) {
22864
22872
  /** @internal */ this._pointers = [];
22865
22873
  /** @internal */ this._multiPointerEnabled = true;
22866
22874
  /** @internal */ this._buttons = exports.PointerButton.None;
@@ -22869,16 +22877,18 @@
22869
22877
  /** @internal */ this._upList = new DisorderedArray();
22870
22878
  /** @internal */ this._downList = new DisorderedArray();
22871
22879
  this._nativeEvents = [];
22872
- this._hadListener = false;
22873
- // @ts-ignore
22874
- var htmlCanvas = engine._canvas._webCanvas;
22880
+ if (_instanceof1$2(target, Window)) {
22881
+ throw "Do not set window as target because window cannot listen to pointer leave event.";
22882
+ }
22875
22883
  this._engine = engine;
22884
+ this._target = target;
22876
22885
  this._canvas = engine.canvas;
22877
- this._htmlCanvas = htmlCanvas;
22878
- this._onPointerEvent = this._onPointerEvent.bind(this);
22879
- this._onFocus();
22886
+ // @ts-ignore
22887
+ this._htmlCanvas = engine._canvas._webCanvas;
22880
22888
  // If there are no compatibility issues, navigator.maxTouchPoints should be used here
22881
22889
  this._pointerPool = new Array(11);
22890
+ this._onPointerEvent = this._onPointerEvent.bind(this);
22891
+ this._addEventListener();
22882
22892
  };
22883
22893
  var _proto = PointerManager.prototype;
22884
22894
  /**
@@ -22948,7 +22958,8 @@
22948
22958
  var length = events.length;
22949
22959
  if (length > 0) {
22950
22960
  for(var i1 = 0; i1 < length; i1++){
22951
- switch(events[i1].type){
22961
+ var event = events[i1];
22962
+ switch(event.type){
22952
22963
  case "pointerdown":
22953
22964
  pointer.phase = exports.PointerPhase.Down;
22954
22965
  pointer._firePointerDown(rayCastEntity);
@@ -22970,66 +22981,14 @@
22970
22981
  };
22971
22982
  /**
22972
22983
  * @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
22984
  */ _proto._destroy = function _destroy() {
23003
- // @ts-ignore
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
- }
22985
+ this._removeEventListener();
23013
22986
  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
22987
  this._nativeEvents.length = 0;
23022
- this._nativeEvents = null;
23023
- this._upMap.length = 0;
23024
- this._upMap = null;
23025
22988
  this._downMap.length = 0;
23026
- this._downMap = null;
23027
- this._htmlCanvas = null;
23028
- this._canvas = null;
23029
- this._engine = null;
22989
+ this._upMap.length = 0;
23030
22990
  };
23031
22991
  _proto._onPointerEvent = function _onPointerEvent(evt) {
23032
- evt.type === "pointerdown" && this._htmlCanvas.focus();
23033
22992
  this._nativeEvents.push(evt);
23034
22993
  };
23035
22994
  _proto._getPointerByID = function _getPointerByID(pointerId) {
@@ -23112,6 +23071,26 @@
23112
23071
  }
23113
23072
  return null;
23114
23073
  };
23074
+ _proto._addEventListener = function _addEventListener() {
23075
+ var _this = this, target = _this._target, onPointerEvent = _this._onPointerEvent;
23076
+ target.addEventListener("pointerdown", onPointerEvent);
23077
+ target.addEventListener("pointerup", onPointerEvent);
23078
+ target.addEventListener("pointerleave", onPointerEvent);
23079
+ target.addEventListener("pointermove", onPointerEvent);
23080
+ target.addEventListener("pointercancel", onPointerEvent);
23081
+ };
23082
+ _proto._removeEventListener = function _removeEventListener() {
23083
+ var _this = this, target = _this._target, onPointerEvent = _this._onPointerEvent;
23084
+ target.removeEventListener("pointerdown", onPointerEvent);
23085
+ target.removeEventListener("pointerup", onPointerEvent);
23086
+ target.removeEventListener("pointerleave", onPointerEvent);
23087
+ target.removeEventListener("pointermove", onPointerEvent);
23088
+ target.removeEventListener("pointercancel", onPointerEvent);
23089
+ this._nativeEvents.length = 0;
23090
+ this._pointers.length = 0;
23091
+ this._downList.length = 0;
23092
+ this._upList.length = 0;
23093
+ };
23115
23094
  return PointerManager;
23116
23095
  }();
23117
23096
  (function() {
@@ -23127,15 +23106,12 @@
23127
23106
  * Wheel Manager.
23128
23107
  * @internal
23129
23108
  */ var WheelManager = /*#__PURE__*/ function() {
23130
- var WheelManager = function WheelManager(engine) {
23109
+ var WheelManager = function WheelManager(engine, target) {
23131
23110
  /** @internal */ this._delta = new Vector3();
23132
23111
  this._nativeEvents = [];
23133
- // @ts-ignore
23134
- var htmlCanvas = engine._canvas._webCanvas;
23135
23112
  this._onWheelEvent = this._onWheelEvent.bind(this);
23136
- htmlCanvas.addEventListener("wheel", this._onWheelEvent);
23137
- this._canvas = htmlCanvas;
23138
- this._hadListener = true;
23113
+ this._target = target;
23114
+ this._addEventListener();
23139
23115
  };
23140
23116
  var _proto = WheelManager.prototype;
23141
23117
  /**
@@ -23156,35 +23132,24 @@
23156
23132
  };
23157
23133
  /**
23158
23134
  * @internal
23159
- */ _proto._onFocus = function _onFocus() {
23160
- if (!this._hadListener) {
23161
- this._canvas.addEventListener("wheel", this._onWheelEvent);
23162
- this._hadListener = true;
23163
- }
23135
+ */ _proto._addEventListener = function _addEventListener() {
23136
+ this._target.addEventListener("wheel", this._onWheelEvent);
23164
23137
  };
23165
23138
  /**
23166
23139
  * @internal
23167
- */ _proto._onBlur = function _onBlur() {
23168
- if (this._hadListener) {
23169
- this._canvas.removeEventListener("wheel", this._onWheelEvent);
23170
- this._nativeEvents.length = 0;
23171
- this._delta.set(0, 0, 0);
23172
- this._hadListener = false;
23173
- }
23140
+ */ _proto._removeEventListener = function _removeEventListener() {
23141
+ this._target.removeEventListener("wheel", this._onWheelEvent);
23142
+ this._nativeEvents.length = 0;
23143
+ this._delta.set(0, 0, 0);
23174
23144
  };
23175
23145
  /**
23176
23146
  * @internal
23177
23147
  */ _proto._destroy = function _destroy() {
23178
- if (this._hadListener) {
23179
- this._canvas.removeEventListener("wheel", this._onWheelEvent);
23180
- this._hadListener = false;
23181
- }
23148
+ this._removeEventListener();
23182
23149
  this._nativeEvents = null;
23183
- this._canvas = null;
23184
23150
  this._delta = null;
23185
23151
  };
23186
23152
  _proto._onWheelEvent = function _onWheelEvent(evt) {
23187
- evt.cancelable && evt.preventDefault();
23188
23153
  this._nativeEvents.push(evt);
23189
23154
  };
23190
23155
  return WheelManager;
@@ -23192,19 +23157,19 @@
23192
23157
  /**
23193
23158
  * InputManager manages device input such as mouse, touch, keyboard, etc.
23194
23159
  */ var InputManager = /*#__PURE__*/ function() {
23195
- var InputManager = function InputManager(engine) {
23160
+ var InputManager = function InputManager(engine, inputOptions) {
23196
23161
  /** Sometimes the input module will not be initialized, such as off-screen rendering. */ this._initialized = false;
23197
23162
  this._engine = engine;
23198
23163
  // @ts-ignore
23199
23164
  var canvas = engine._canvas._webCanvas;
23200
23165
  if (typeof OffscreenCanvas === "undefined" || !_instanceof1$2(canvas, OffscreenCanvas)) {
23201
- this._wheelManager = new WheelManager(engine);
23202
- this._pointerManager = new PointerManager(engine);
23203
- this._keyboardManager = new KeyboardManager(engine);
23204
- this._onBlur = this._onBlur.bind(this);
23205
- window.addEventListener("blur", this._onBlur);
23206
- this._onFocus = this._onFocus.bind(this);
23207
- window.addEventListener("focus", this._onFocus);
23166
+ var _inputOptions, _inputOptions1, _inputOptions2;
23167
+ var _inputOptions_wheelTarget;
23168
+ this._wheelManager = new WheelManager(engine, (_inputOptions_wheelTarget = (_inputOptions = inputOptions) == null ? void 0 : _inputOptions.wheelTarget) != null ? _inputOptions_wheelTarget : canvas);
23169
+ var _inputOptions_pointerTarget;
23170
+ this._pointerManager = new PointerManager(engine, (_inputOptions_pointerTarget = (_inputOptions1 = inputOptions) == null ? void 0 : _inputOptions1.pointerTarget) != null ? _inputOptions_pointerTarget : canvas);
23171
+ var _inputOptions_keyboardTarget;
23172
+ this._keyboardManager = new KeyboardManager(engine, (_inputOptions_keyboardTarget = (_inputOptions2 = inputOptions) == null ? void 0 : _inputOptions2.keyboardTarget) != null ? _inputOptions_keyboardTarget : window);
23208
23173
  this._initialized = true;
23209
23174
  }
23210
23175
  };
@@ -23317,8 +23282,6 @@
23317
23282
  * @internal
23318
23283
  */ _proto._destroy = function _destroy() {
23319
23284
  if (this._initialized) {
23320
- window.removeEventListener("blur", this._onBlur);
23321
- window.removeEventListener("focus", this._onFocus);
23322
23285
  this._wheelManager._destroy();
23323
23286
  this._wheelManager = null;
23324
23287
  this._pointerManager._destroy();
@@ -23327,16 +23290,6 @@
23327
23290
  this._keyboardManager = null;
23328
23291
  }
23329
23292
  };
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
23293
  _create_class$2(InputManager, [
23341
23294
  {
23342
23295
  key: "pointers",
@@ -23686,8 +23639,9 @@
23686
23639
  }
23687
23640
  return;
23688
23641
  }
23642
+ ++hierarchy;
23689
23643
  for(var k1 in cacheMap){
23690
- this._recursiveDestroy(++hierarchy, cacheMap[k1]);
23644
+ this._recursiveDestroy(hierarchy, cacheMap[k1]);
23691
23645
  }
23692
23646
  };
23693
23647
  _proto._resizeCacheMapHierarchy = function _resizeCacheMapHierarchy(cacheMap, hierarchy, currentHierarchy, increaseHierarchy) {
@@ -23803,7 +23757,7 @@
23803
23757
  _this._spriteMaskDefaultMaterial = _this._createSpriteMaskMaterial();
23804
23758
  _this._textDefaultFont = Font.createFromOS(_assert_this_initialized(_this), "Arial");
23805
23759
  _this._textDefaultFont.isGCIgnored = true;
23806
- _this.inputManager = new InputManager(_assert_this_initialized(_this));
23760
+ _this.inputManager = new InputManager(_assert_this_initialized(_this), configuration.input);
23807
23761
  var xrDevice = configuration.xrDevice;
23808
23762
  if (xrDevice) {
23809
23763
  _this.xrManager = new XRManager();
@@ -26628,7 +26582,12 @@
26628
26582
  if (componentA.instanceId === componentB.instanceId) {
26629
26583
  return dataA.material._priority - dataB.material._priority || componentA._distanceForSort - componentB._distanceForSort;
26630
26584
  } else {
26631
- return componentA._distanceForSort - componentB._distanceForSort;
26585
+ var distanceDiff = componentA._distanceForSort - componentB._distanceForSort;
26586
+ if (distanceDiff === 0) {
26587
+ return componentA.instanceId - componentB.instanceId;
26588
+ } else {
26589
+ return distanceDiff;
26590
+ }
26632
26591
  }
26633
26592
  };
26634
26593
  /**
@@ -26646,7 +26605,12 @@
26646
26605
  if (componentA.instanceId === componentB.instanceId) {
26647
26606
  return dataA.material._priority - dataB.material._priority || componentB._distanceForSort - componentA._distanceForSort;
26648
26607
  } else {
26649
- return componentB._distanceForSort - componentA._distanceForSort;
26608
+ var distanceDiff = componentB._distanceForSort - componentA._distanceForSort;
26609
+ if (distanceDiff === 0) {
26610
+ return componentA.instanceId - componentB.instanceId;
26611
+ } else {
26612
+ return distanceDiff;
26613
+ }
26650
26614
  }
26651
26615
  };
26652
26616
  return RenderQueue;
@@ -27847,14 +27811,14 @@
27847
27811
  /** @internal */ _this._cameraIndex = -1;
27848
27812
  _this._priority = 0;
27849
27813
  _this._shaderData = new ShaderData(ShaderDataGroup.Camera);
27850
- _this._isProjMatSetting = false;
27814
+ _this._isCustomViewMatrix = false;
27815
+ _this._isCustomProjectionMatrix = false;
27851
27816
  _this._nearClipPlane = 0.1;
27852
27817
  _this._farClipPlane = 100;
27853
27818
  _this._fieldOfView = 45;
27854
27819
  _this._orthographicSize = 10;
27855
27820
  _this._isProjectionDirty = true;
27856
27821
  _this._isInvProjMatDirty = true;
27857
- _this._isFrustumProjectDirty = true;
27858
27822
  _this._customAspectRatio = undefined;
27859
27823
  _this._renderTarget = null;
27860
27824
  _this._depthBufferParams = new Vector4();
@@ -27866,7 +27830,7 @@
27866
27830
  _this._transform = transform;
27867
27831
  _this._isViewMatrixDirty = transform.registerWorldChangeFlag();
27868
27832
  _this._isInvViewProjDirty = transform.registerWorldChangeFlag();
27869
- _this._frustumViewChangeFlag = transform.registerWorldChangeFlag();
27833
+ _this._frustumChangeFlag = transform.registerWorldChangeFlag();
27870
27834
  _this._renderPipeline = new BasicRenderPipeline(_assert_this_initialized(_this));
27871
27835
  _this._addResourceReferCount(_this.shaderData, 1);
27872
27836
  _this._updatePixelViewport();
@@ -27879,16 +27843,22 @@
27879
27843
  _inherits$2(Camera1, Component1);
27880
27844
  var _proto = Camera1.prototype;
27881
27845
  /**
27846
+ * Restore the view matrix to the world matrix of the entity.
27847
+ */ _proto.resetViewMatrix = function resetViewMatrix() {
27848
+ this._isCustomViewMatrix = false;
27849
+ this._viewMatrixChange();
27850
+ };
27851
+ /**
27882
27852
  * Restore the automatic calculation of projection matrix through fieldOfView, nearClipPlane and farClipPlane.
27883
27853
  */ _proto.resetProjectionMatrix = function resetProjectionMatrix() {
27884
- this._isProjMatSetting = false;
27885
- this._projMatChange();
27854
+ this._isCustomProjectionMatrix = false;
27855
+ this._projectionMatrixChange();
27886
27856
  };
27887
27857
  /**
27888
27858
  * Restore the automatic calculation of the aspect ratio through the viewport aspect ratio.
27889
27859
  */ _proto.resetAspectRatio = function resetAspectRatio() {
27890
27860
  this._customAspectRatio = undefined;
27891
- this._projMatChange();
27861
+ this._projectionMatrixChange();
27892
27862
  };
27893
27863
  /**
27894
27864
  * Transform a point from world space to viewport space.
@@ -28018,10 +27988,9 @@
28018
27988
  context.replacementShader = this._replacementShader;
28019
27989
  context.replacementTag = this._replacementSubShaderTag;
28020
27990
  // compute cull frustum.
28021
- if (this.enableFrustumCulling && (this._frustumViewChangeFlag.flag || this._isFrustumProjectDirty)) {
27991
+ if (this.enableFrustumCulling && this._frustumChangeFlag.flag) {
28022
27992
  this._frustum.calculateFromMatrix(virtualCamera.viewProjectionMatrix);
28023
- this._frustumViewChangeFlag.flag = false;
28024
- this._isFrustumProjectDirty = false;
27993
+ this._frustumChangeFlag.flag = false;
28025
27994
  }
28026
27995
  this._updateShaderData();
28027
27996
  // union scene and camera macro.
@@ -28076,7 +28045,7 @@
28076
28045
  this._renderPipeline = null;
28077
28046
  this._virtualCamera = null;
28078
28047
  this._shaderData = null;
28079
- this._frustumViewChangeFlag = null;
28048
+ this._frustumChangeFlag = null;
28080
28049
  this._transform = null;
28081
28050
  this._isViewMatrixDirty = null;
28082
28051
  this._isInvViewProjDirty = null;
@@ -28098,11 +28067,16 @@
28098
28067
  var viewport = this._viewport;
28099
28068
  this._pixelViewport.set(viewport.x * width, viewport.y * height, viewport.z * width, viewport.w * height);
28100
28069
  };
28101
- _proto._projMatChange = function _projMatChange() {
28102
- this._isFrustumProjectDirty = true;
28070
+ _proto._viewMatrixChange = function _viewMatrixChange() {
28071
+ this._isViewMatrixDirty.flag = true;
28072
+ this._isInvViewProjDirty.flag = true;
28073
+ this._frustumChangeFlag.flag = true;
28074
+ };
28075
+ _proto._projectionMatrixChange = function _projectionMatrixChange() {
28103
28076
  this._isProjectionDirty = true;
28104
28077
  this._isInvProjMatDirty = true;
28105
28078
  this._isInvViewProjDirty.flag = true;
28079
+ this._frustumChangeFlag.flag = true;
28106
28080
  };
28107
28081
  _proto._innerViewportToWorldPoint = function _innerViewportToWorldPoint(x, y, z, invViewProjMat, out) {
28108
28082
  // Depth is a normalized value, 0 is nearPlane, 1 is farClipPlane.
@@ -28145,7 +28119,7 @@
28145
28119
  _proto._onPixelViewportChanged = function _onPixelViewportChanged() {
28146
28120
  this._updatePixelViewport();
28147
28121
  var _this__customAspectRatio;
28148
- (_this__customAspectRatio = this._customAspectRatio) != null ? _this__customAspectRatio : this._projMatChange();
28122
+ (_this__customAspectRatio = this._customAspectRatio) != null ? _this__customAspectRatio : this._projectionMatrixChange();
28149
28123
  };
28150
28124
  _create_class$2(Camera1, [
28151
28125
  {
@@ -28165,7 +28139,7 @@
28165
28139
  },
28166
28140
  set: function set(value) {
28167
28141
  this._nearClipPlane = value;
28168
- this._projMatChange();
28142
+ this._projectionMatrixChange();
28169
28143
  }
28170
28144
  },
28171
28145
  {
@@ -28177,7 +28151,7 @@
28177
28151
  },
28178
28152
  set: function set(value) {
28179
28153
  this._farClipPlane = value;
28180
- this._projMatChange();
28154
+ this._projectionMatrixChange();
28181
28155
  }
28182
28156
  },
28183
28157
  {
@@ -28189,7 +28163,7 @@
28189
28163
  },
28190
28164
  set: function set(value) {
28191
28165
  this._fieldOfView = value;
28192
- this._projMatChange();
28166
+ this._projectionMatrixChange();
28193
28167
  }
28194
28168
  },
28195
28169
  {
@@ -28204,7 +28178,7 @@
28204
28178
  },
28205
28179
  set: function set(value) {
28206
28180
  this._customAspectRatio = value;
28207
- this._projMatChange();
28181
+ this._projectionMatrixChange();
28208
28182
  }
28209
28183
  },
28210
28184
  {
@@ -28256,7 +28230,12 @@
28256
28230
  },
28257
28231
  set: function set(value) {
28258
28232
  this._virtualCamera.isOrthographic = value;
28259
- this._projMatChange();
28233
+ this._projectionMatrixChange();
28234
+ if (value) {
28235
+ this.shaderData.enableMacro("CAMERA_ORTHOGRAPHIC");
28236
+ } else {
28237
+ this.shaderData.disableMacro("CAMERA_ORTHOGRAPHIC");
28238
+ }
28260
28239
  }
28261
28240
  },
28262
28241
  {
@@ -28268,7 +28247,7 @@
28268
28247
  },
28269
28248
  set: function set(value) {
28270
28249
  this._orthographicSize = value;
28271
- this._projMatChange();
28250
+ this._projectionMatrixChange();
28272
28251
  }
28273
28252
  },
28274
28253
  {
@@ -28277,22 +28256,31 @@
28277
28256
  * View matrix.
28278
28257
  */ function get() {
28279
28258
  var viewMatrix = this._virtualCamera.viewMatrix;
28280
- if (this._isViewMatrixDirty.flag) {
28281
- this._isViewMatrixDirty.flag = false;
28282
- // Ignore scale.
28283
- var transform = this._transform;
28284
- Matrix.rotationTranslation(transform.worldRotationQuaternion, transform.worldPosition, viewMatrix);
28285
- viewMatrix.invert();
28286
- }
28259
+ if (!this._isViewMatrixDirty.flag || this._isCustomViewMatrix) {
28260
+ return viewMatrix;
28261
+ }
28262
+ this._isViewMatrixDirty.flag = false;
28263
+ // Ignore scale
28264
+ var transform = this._transform;
28265
+ Matrix.rotationTranslation(transform.worldRotationQuaternion, transform.worldPosition, viewMatrix);
28266
+ viewMatrix.invert();
28287
28267
  return viewMatrix;
28268
+ },
28269
+ set: function set(value) {
28270
+ this._virtualCamera.viewMatrix.copyFrom(value);
28271
+ this._isCustomViewMatrix = true;
28272
+ this._viewMatrixChange();
28288
28273
  }
28289
28274
  },
28290
28275
  {
28291
28276
  key: "projectionMatrix",
28292
- get: function get() {
28277
+ get: /**
28278
+ * The projection matrix is ​​calculated by the relevant parameters of the camera by default.
28279
+ * If it is manually set, the manual value will be maintained. Call resetProjectionMatrix() to restore it.
28280
+ */ function get() {
28293
28281
  var virtualCamera = this._virtualCamera;
28294
28282
  var projectionMatrix = virtualCamera.projectionMatrix;
28295
- if (!this._isProjectionDirty || this._isProjMatSetting) {
28283
+ if (!this._isProjectionDirty || this._isCustomProjectionMatrix) {
28296
28284
  return projectionMatrix;
28297
28285
  }
28298
28286
  this._isProjectionDirty = false;
@@ -28306,13 +28294,10 @@
28306
28294
  }
28307
28295
  return projectionMatrix;
28308
28296
  },
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) {
28297
+ set: function set(value) {
28313
28298
  this._virtualCamera.projectionMatrix.copyFrom(value);
28314
- this._isProjMatSetting = true;
28315
- this._projMatChange();
28299
+ this._isCustomProjectionMatrix = true;
28300
+ this._projectionMatrixChange();
28316
28301
  }
28317
28302
  },
28318
28303
  {
@@ -28373,7 +28358,7 @@
28373
28358
  ], exports.Camera.prototype, "_cameraIndex", void 0);
28374
28359
  __decorate$1([
28375
28360
  ignoreClone
28376
- ], exports.Camera.prototype, "_frustumViewChangeFlag", void 0);
28361
+ ], exports.Camera.prototype, "_frustumChangeFlag", void 0);
28377
28362
  __decorate$1([
28378
28363
  ignoreClone
28379
28364
  ], exports.Camera.prototype, "_transform", void 0);
@@ -43563,6 +43548,84 @@
43563
43548
  "mesh"
43564
43549
  ])
43565
43550
  ], MeshLoader);
43551
+ var PrimitiveMeshLoader = /*#__PURE__*/ function(Loader1) {
43552
+ var PrimitiveMeshLoader = function PrimitiveMeshLoader() {
43553
+ return Loader1.apply(this, arguments);
43554
+ };
43555
+ _inherits(PrimitiveMeshLoader, Loader1);
43556
+ var _proto = PrimitiveMeshLoader.prototype;
43557
+ _proto.load = function load(item, param) {
43558
+ var engine = param.engine;
43559
+ return this.request(item.url, _extends({}, item, {
43560
+ type: "json"
43561
+ })).then(function(data) {
43562
+ switch(data.type){
43563
+ case "sphere":
43564
+ return PrimitiveMesh.createSubdivisionSurfaceSphere(engine, data.sphereRadius, data.sphereStep);
43565
+ case "capsule":
43566
+ return PrimitiveMesh.createCapsule(engine, data.capsuleRadius, data.capsuleHeight, data.capsuleRadialSegments, data.capsuleHeightSegments);
43567
+ case "cone":
43568
+ return PrimitiveMesh.createCone(engine, data.coneRadius, data.coneHeight, data.coneRadialSegment, data.coneHeightSegment);
43569
+ case "cuboid":
43570
+ return PrimitiveMesh.createCuboid(engine, data.cuboidWidth, data.cuboidHeight, data.cuboidDepth);
43571
+ case "cylinder":
43572
+ return PrimitiveMesh.createCylinder(engine, data.cylinderRadiusTop, data.cylinderRadiusBottom, data.cylinderHeight, data.cylinderRadialSegment, data.cylinderHeightSegment);
43573
+ case "plane":
43574
+ return PrimitiveMesh.createPlane(engine, data.planeWidth, data.planeHeight, data.planeHorizontalSegments, data.planeVerticalSegments);
43575
+ case "torus":
43576
+ return PrimitiveMesh.createTorus(engine, data.torusRadius, data.torusTubeRadius, data.torusRadialSegments, data.torusTubularSegments, data.torusArc);
43577
+ }
43578
+ });
43579
+ };
43580
+ return PrimitiveMeshLoader;
43581
+ }(Loader);
43582
+ PrimitiveMeshLoader = __decorate([
43583
+ resourceLoader(exports.AssetType.PrimitiveMesh, [
43584
+ "mesh"
43585
+ ], false)
43586
+ ], PrimitiveMeshLoader);
43587
+ var /** @internal */ PrimitiveMeshType;
43588
+ (function(PrimitiveMeshType) {
43589
+ PrimitiveMeshType["Sphere"] = "sphere";
43590
+ PrimitiveMeshType["Cuboid"] = "cuboid";
43591
+ PrimitiveMeshType["Plane"] = "plane";
43592
+ PrimitiveMeshType["Cylinder"] = "cylinder";
43593
+ PrimitiveMeshType["Torus"] = "torus";
43594
+ PrimitiveMeshType["Cone"] = "cone";
43595
+ PrimitiveMeshType["Capsule"] = "capsule";
43596
+ })(PrimitiveMeshType || (PrimitiveMeshType = {}));
43597
+ var ProjectLoader = /*#__PURE__*/ function(Loader1) {
43598
+ var ProjectLoader = function ProjectLoader() {
43599
+ return Loader1.apply(this, arguments);
43600
+ };
43601
+ _inherits(ProjectLoader, Loader1);
43602
+ var _proto = ProjectLoader.prototype;
43603
+ _proto.load = function load(item, resourceManager) {
43604
+ var _this = this;
43605
+ var engine = resourceManager.engine;
43606
+ return new AssetPromise(function(resolve, reject) {
43607
+ _this.request(item.url, {
43608
+ type: "json"
43609
+ }).then(function(data) {
43610
+ // @ts-ignore
43611
+ engine.resourceManager.initVirtualResources(data.files);
43612
+ return resourceManager.load({
43613
+ type: exports.AssetType.Scene,
43614
+ url: data.scene
43615
+ }).then(function(scene) {
43616
+ engine.sceneManager.activeScene = scene;
43617
+ resolve();
43618
+ });
43619
+ }).catch(reject);
43620
+ });
43621
+ };
43622
+ return ProjectLoader;
43623
+ }(Loader);
43624
+ ProjectLoader = __decorate([
43625
+ resourceLoader(exports.AssetType.Project, [
43626
+ "proj"
43627
+ ], false)
43628
+ ], ProjectLoader);
43566
43629
  var SourceFontLoader = /*#__PURE__*/ function(Loader1) {
43567
43630
  var SourceFontLoader = function SourceFontLoader() {
43568
43631
  return Loader1.apply(this, arguments);
@@ -43891,38 +43954,6 @@
43891
43954
  ""
43892
43955
  ])
43893
43956
  ], 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
43957
  var SceneLoader = /*#__PURE__*/ function(Loader1) {
43927
43958
  var SceneLoader = function SceneLoader() {
43928
43959
  return Loader1.apply(this, arguments);
@@ -44400,7 +44431,7 @@
44400
44431
  ], KHR_materials_anisotropy);
44401
44432
 
44402
44433
  //@ts-ignore
44403
- var version = "1.2.0-alpha.1";
44434
+ var version = "1.2.0-alpha.3";
44404
44435
  console.log("Galacean engine version: " + version);
44405
44436
  for(var key in CoreObjects){
44406
44437
  Loader.registerClass(key, CoreObjects[key]);