@galacean/engine-physics-lite 0.0.0-experimental-0.9-plus.2 → 0.0.0-experimental-0.9-plus.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/main.js.map +1 -1
- package/dist/miniprogram.js +62 -197
- package/dist/module.js.map +1 -1
- package/package.json +4 -4
package/dist/miniprogram.js
CHANGED
|
@@ -1409,7 +1409,7 @@ var light_frag_define = "#define GLSLIFY 1\n#ifdef O3_DIRECT_LIGHT_COUNT\nstruct
|
|
|
1409
1409
|
var mobile_material_frag = "#define GLSLIFY 1\nuniform vec4 u_emissiveColor;uniform vec4 u_baseColor;uniform vec4 u_specularColor;uniform float u_shininess;uniform float u_normalIntensity;uniform float u_alphaCutoff;\n#ifdef EMISSIVETEXTURE\nuniform sampler2D u_emissiveTexture;\n#endif\n#ifdef BASETEXTURE\nuniform sampler2D u_baseTexture;\n#endif\n#ifdef O3_SPECULAR_TEXTURE\nuniform sampler2D u_specularTexture;\n#endif\n#ifdef NORMALTEXTURE\nuniform sampler2D u_normalTexture;\n#endif\n"; // eslint-disable-line
|
|
1410
1410
|
var begin_mobile_frag = "#define GLSLIFY 1\nvec4 ambient=vec4(0.0);vec4 emission=u_emissiveColor;vec4 diffuse=u_baseColor;vec4 specular=u_specularColor;\n#ifdef EMISSIVETEXTURE\nvec4 emissiveTextureColor=texture2D(u_emissiveTexture,v_uv);\n#ifndef OASIS_COLORSPACE_GAMMA\nemissiveTextureColor=gammaToLinear(emissiveTextureColor);\n#endif\nemission*=emissiveTextureColor;\n#endif\n#ifdef BASETEXTURE\nvec4 diffuseTextureColor=texture2D(u_baseTexture,v_uv);\n#ifndef OASIS_COLORSPACE_GAMMA\ndiffuseTextureColor=gammaToLinear(diffuseTextureColor);\n#endif\ndiffuse*=diffuseTextureColor;\n#endif\n#ifdef O3_HAS_VERTEXCOLOR\ndiffuse*=v_color;\n#endif\n#ifdef O3_SPECULAR_TEXTURE\nvec4 specularTextureColor=texture2D(u_specularTexture,v_uv);\n#ifndef OASIS_COLORSPACE_GAMMA\nspecularTextureColor=gammaToLinear(specularTextureColor);\n#endif\nspecular*=specularTextureColor;\n#endif\nambient=vec4(u_envMapLight.diffuse*u_envMapLight.diffuseIntensity,1.0)*diffuse;"; // eslint-disable-line
|
|
1411
1411
|
var begin_viewdir_frag = "#define GLSLIFY 1\n#ifdef O3_NEED_WORLDPOS\nvec3 V=normalize(u_cameraPos-v_pos);\n#endif\n"; // eslint-disable-line
|
|
1412
|
-
var mobile_blinnphong_frag = "#define GLSLIFY 1\n#ifdef NORMALTEXTURE\nmat3 tbn=getTBN();vec3 N=getNormalByNormalTexture(tbn,u_normalTexture,u_normalIntensity,v_uv);\n#else\nvec3 N=getNormal();\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 O3_DIRECT_LIGHT_COUNT\nshadowAttenuation=1.0;\n#ifdef OASIS_CALCULATE_SHADOWS\nshadowAttenuation*=sampleShadowMap();int sunIndex=int(u_shadowInfo.z);\n#endif\nDirectLight directionalLight;for(int i=0;i<O3_DIRECT_LIGHT_COUNT;i++){if(isRendererCulledByLight(oasis_RendererLayer.xy,u_directLightCullingMask[i]))continue;directionalLight.color=u_directLightColor[i];\n#ifdef OASIS_CALCULATE_SHADOWS\nif(i==sunIndex){directionalLight.color*=shadowAttenuation;}\n#endif\ndirectionalLight.direction=u_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),u_shininess);lightSpecular+=directionalLight.color*s;}\n#endif\n#ifdef O3_POINT_LIGHT_COUNT\nPointLight pointLight;for(int i=0;i<O3_POINT_LIGHT_COUNT;i++){if(isRendererCulledByLight(oasis_RendererLayer.xy,u_pointLightCullingMask[i]))continue;pointLight.color=u_pointLightColor[i];pointLight.position=u_pointLightPosition[i];pointLight.distance=u_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),u_shininess)*decay;lightSpecular+=pointLight.color*s;}\n#endif\n#ifdef O3_SPOT_LIGHT_COUNT\nSpotLight spotLight;for(int i=0;i<O3_SPOT_LIGHT_COUNT;i++){if(isRendererCulledByLight(oasis_RendererLayer.xy,u_spotLightCullingMask[i]))continue;spotLight.color=u_spotLightColor[i];spotLight.position=u_spotLightPosition[i];spotLight.direction=u_spotLightDirection[i];spotLight.distance=u_spotLightDistance[i];spotLight.angleCos=u_spotLightAngleCos[i];spotLight.penumbraCos=u_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),u_shininess)*decayTotal;lightSpecular+=spotLight.color*s;}\n#endif\ndiffuse*=vec4(lightDiffuse,1.0);specular*=vec4(lightSpecular,1.0);\n#ifdef ALPHA_CUTOFF\nif(diffuse.a<u_alphaCutoff){discard;}\n#endif\n"; // eslint-disable-line
|
|
1412
|
+
var mobile_blinnphong_frag = "#define GLSLIFY 1\n#ifdef NORMALTEXTURE\nmat3 tbn=getTBN(gl_FrontFacing);vec3 N=getNormalByNormalTexture(tbn,u_normalTexture,u_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 O3_DIRECT_LIGHT_COUNT\nshadowAttenuation=1.0;\n#ifdef OASIS_CALCULATE_SHADOWS\nshadowAttenuation*=sampleShadowMap();int sunIndex=int(u_shadowInfo.z);\n#endif\nDirectLight directionalLight;for(int i=0;i<O3_DIRECT_LIGHT_COUNT;i++){if(isRendererCulledByLight(oasis_RendererLayer.xy,u_directLightCullingMask[i]))continue;directionalLight.color=u_directLightColor[i];\n#ifdef OASIS_CALCULATE_SHADOWS\nif(i==sunIndex){directionalLight.color*=shadowAttenuation;}\n#endif\ndirectionalLight.direction=u_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),u_shininess);lightSpecular+=directionalLight.color*s;}\n#endif\n#ifdef O3_POINT_LIGHT_COUNT\nPointLight pointLight;for(int i=0;i<O3_POINT_LIGHT_COUNT;i++){if(isRendererCulledByLight(oasis_RendererLayer.xy,u_pointLightCullingMask[i]))continue;pointLight.color=u_pointLightColor[i];pointLight.position=u_pointLightPosition[i];pointLight.distance=u_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),u_shininess)*decay;lightSpecular+=pointLight.color*s;}\n#endif\n#ifdef O3_SPOT_LIGHT_COUNT\nSpotLight spotLight;for(int i=0;i<O3_SPOT_LIGHT_COUNT;i++){if(isRendererCulledByLight(oasis_RendererLayer.xy,u_spotLightCullingMask[i]))continue;spotLight.color=u_spotLightColor[i];spotLight.position=u_spotLightPosition[i];spotLight.direction=u_spotLightDirection[i];spotLight.distance=u_spotLightDistance[i];spotLight.angleCos=u_spotLightAngleCos[i];spotLight.penumbraCos=u_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),u_shininess)*decayTotal;lightSpecular+=spotLight.color*s;}\n#endif\ndiffuse*=vec4(lightDiffuse,1.0);specular*=vec4(lightSpecular,1.0);\n#ifdef ALPHA_CUTOFF\nif(diffuse.a<u_alphaCutoff){discard;}\n#endif\n"; // eslint-disable-line
|
|
1413
1413
|
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
|
|
1414
1414
|
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
|
|
1415
1415
|
var noise_cellular_2x2 = "#define GLSLIFY 1\nvec2 cellular2x2(vec2 P){vec2 Pi=mod289(floor(P));vec2 Pf=fract(P);vec4 Pfx=Pf.x+vec4(-0.5,-1.5,-0.5,-1.5);vec4 Pfy=Pf.y+vec4(-0.5,-0.5,-1.5,-1.5);vec4 p=permute(Pi.x+vec4(0.0,1.0,0.0,1.0));p=permute(p+Pi.y+vec4(0.0,0.0,1.0,1.0));vec4 ox=mod7(p)*K+Kd2;vec4 oy=mod7(floor(p*K))*K+Kd2;vec4 dx=Pfx+jitter1*ox;vec4 dy=Pfy+jitter1*oy;vec4 d=dx*dx+dy*dy;d.xy=(d.x<d.y)? d.xy : d.yx;d.xz=(d.x<d.z)? d.xz : d.zx;d.xw=(d.x<d.w)? d.xw : d.wx;d.y=min(d.y,d.z);d.y=min(d.y,d.w);return sqrt(d.xy);}"; // eslint-disable-line
|
|
@@ -1427,11 +1427,11 @@ var noise_simplex_3D = "#define GLSLIFY 1\nfloat simplex(vec3 v){const vec2 C=ve
|
|
|
1427
1427
|
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
|
|
1428
1428
|
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
|
|
1429
1429
|
var pbr_frag_define = "#define GLSLIFY 1\nuniform float u_alphaCutoff;uniform vec4 u_baseColor;uniform float u_metal;uniform float u_roughness;uniform vec3 u_PBRSpecularColor;uniform float u_glossiness;uniform vec3 u_emissiveColor;\n#ifdef CLEARCOAT\nuniform float u_clearCoat;uniform float u_clearCoatRoughness;\n#endif\nuniform float u_normalIntensity;uniform float u_occlusionIntensity;uniform float u_occlusionTextureCoord;\n#ifdef BASETEXTURE\nuniform sampler2D u_baseTexture;\n#endif\n#ifdef NORMALTEXTURE\nuniform sampler2D u_normalTexture;\n#endif\n#ifdef EMISSIVETEXTURE\nuniform sampler2D u_emissiveTexture;\n#endif\n#ifdef ROUGHNESSMETALLICTEXTURE\nuniform sampler2D u_roughnessMetallicTexture;\n#endif\n#ifdef SPECULARGLOSSINESSTEXTURE\nuniform sampler2D u_specularGlossinessTexture;\n#endif\n#ifdef OCCLUSIONTEXTURE\nuniform sampler2D u_occlusionTexture;\n#endif\n#ifdef HAS_CLEARCOATTEXTURE\nuniform sampler2D u_clearCoatTexture;\n#endif\n#ifdef HAS_CLEARCOATROUGHNESSTEXTURE\nuniform sampler2D u_clearCoatRoughnessTexture;\n#endif\n#ifdef HAS_CLEARCOATNORMALTEXTURE\nuniform sampler2D u_clearCoatNormalTexture;\n#endif\nstruct ReflectedLight{vec3 directDiffuse;vec3 directSpecular;vec3 indirectDiffuse;vec3 indirectSpecular;};struct Geometry{vec3 position;vec3 normal;vec3 viewDir;float dotNV;\n#ifdef CLEARCOAT\nvec3 clearCoatNormal;float clearCoatDotNV;\n#endif\n};struct Material{vec3 diffuseColor;float roughness;vec3 specularColor;float opacity;\n#ifdef CLEARCOAT\nfloat clearCoat;float clearCoatRoughness;\n#endif\n};uniform float material_IOR;"; // eslint-disable-line
|
|
1430
|
-
var pbr_helper = "#define GLSLIFY 1\n#include <normal_get>\nfloat computeSpecularOcclusion(float ambientOcclusion,float roughness,float dotNV){return saturate(pow(dotNV+ambientOcclusion,exp2(-16.0*roughness-1.0))-1.0+ambientOcclusion);}float getAARoughnessFactor(vec3 normal){\n#ifdef HAS_DERIVATIVES\nvec3 dxy=max(abs(dFdx(normal)),abs(dFdy(normal)));return 0.04+max(max(dxy.x,dxy.y),dxy.z);\n#else\nreturn 0.04;\n#endif\n}void initGeometry(out Geometry geometry){geometry.position=v_pos;geometry.viewDir=normalize(u_cameraPos-v_pos);\n#if defined(NORMALTEXTURE) || defined(HAS_CLEARCOATNORMALTEXTURE)\nmat3 tbn=getTBN();\n#endif\n#ifdef NORMALTEXTURE\ngeometry.normal=getNormalByNormalTexture(tbn,u_normalTexture,u_normalIntensity,v_uv);\n#else\ngeometry.normal=getNormal();\n#endif\ngeometry.dotNV=saturate(dot(geometry.normal,geometry.viewDir));\n#ifdef CLEARCOAT\n#ifdef HAS_CLEARCOATNORMALTEXTURE\ngeometry.clearCoatNormal=getNormalByNormalTexture(tbn,u_clearCoatNormalTexture,u_normalIntensity,v_uv);\n#else\ngeometry.clearCoatNormal=getNormal();\n#endif\ngeometry.clearCoatDotNV=saturate(dot(geometry.clearCoatNormal,geometry.viewDir));\n#endif\n}void initMaterial(out Material material,const in Geometry geometry){vec4 baseColor=u_baseColor;float metal=u_metal;float roughness=u_roughness;vec3 specularColor=u_PBRSpecularColor;float glossiness=u_glossiness;float alphaCutoff=u_alphaCutoff;float F0=pow2((material_IOR-1.0)/(material_IOR+1.0));\n#ifdef BASETEXTURE\nvec4 baseTextureColor=texture2D(u_baseTexture,v_uv);\n#ifndef OASIS_COLORSPACE_GAMMA\nbaseTextureColor=gammaToLinear(baseTextureColor);\n#endif\nbaseColor*=baseTextureColor;\n#endif\n#ifdef O3_HAS_VERTEXCOLOR\nbaseColor*=v_color;\n#endif\n#ifdef ALPHA_CUTOFF\nif(baseColor.a<alphaCutoff){discard;}\n#endif\n#ifdef ROUGHNESSMETALLICTEXTURE\nvec4 metalRoughMapColor=texture2D(u_roughnessMetallicTexture,v_uv);roughness*=metalRoughMapColor.g;metal*=metalRoughMapColor.b;\n#endif\n#ifdef SPECULARGLOSSINESSTEXTURE\nvec4 specularGlossinessColor=texture2D(u_specularGlossinessTexture,v_uv);\n#ifndef OASIS_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 CLEARCOAT\nmaterial.clearCoat=u_clearCoat;material.clearCoatRoughness=u_clearCoatRoughness;\n#ifdef HAS_CLEARCOATTEXTURE\nmaterial.clearCoat*=texture2D(u_clearCoatTexture,v_uv).r;\n#endif\n#ifdef HAS_CLEARCOATROUGHNESSTEXTURE\nmaterial.clearCoatRoughness*=texture2D(u_clearCoatRoughnessTexture,v_uv).g;\n#endif\nmaterial.clearCoat=saturate(material.clearCoat);material.clearCoatRoughness=max(material.clearCoatRoughness,getAARoughnessFactor(geometry.clearCoatNormal));\n#endif\n#ifdef OASIS_TRANSPARENT\nmaterial.opacity=baseColor.a;\n#else\nmaterial.opacity=1.0;\n#endif\n}\n#include <brdf>\n#include <direct_irradiance_frag_define>\n#include <ibl_frag_define>\n"; // eslint-disable-line
|
|
1430
|
+
var pbr_helper = "#define GLSLIFY 1\n#include <normal_get>\nfloat computeSpecularOcclusion(float ambientOcclusion,float roughness,float dotNV){return saturate(pow(dotNV+ambientOcclusion,exp2(-16.0*roughness-1.0))-1.0+ambientOcclusion);}float getAARoughnessFactor(vec3 normal){\n#ifdef HAS_DERIVATIVES\nvec3 dxy=max(abs(dFdx(normal)),abs(dFdy(normal)));return 0.04+max(max(dxy.x,dxy.y),dxy.z);\n#else\nreturn 0.04;\n#endif\n}void initGeometry(out Geometry geometry,bool isFrontFacing){geometry.position=v_pos;geometry.viewDir=normalize(u_cameraPos-v_pos);\n#if defined(NORMALTEXTURE) || defined(HAS_CLEARCOATNORMALTEXTURE)\nmat3 tbn=getTBN(isFrontFacing);\n#endif\n#ifdef NORMALTEXTURE\ngeometry.normal=getNormalByNormalTexture(tbn,u_normalTexture,u_normalIntensity,v_uv,isFrontFacing);\n#else\ngeometry.normal=getNormal(isFrontFacing);\n#endif\ngeometry.dotNV=saturate(dot(geometry.normal,geometry.viewDir));\n#ifdef CLEARCOAT\n#ifdef HAS_CLEARCOATNORMALTEXTURE\ngeometry.clearCoatNormal=getNormalByNormalTexture(tbn,u_clearCoatNormalTexture,u_normalIntensity,v_uv,isFrontFacing);\n#else\ngeometry.clearCoatNormal=getNormal(isFrontFacing);\n#endif\ngeometry.clearCoatDotNV=saturate(dot(geometry.clearCoatNormal,geometry.viewDir));\n#endif\n}void initMaterial(out Material material,const in Geometry geometry){vec4 baseColor=u_baseColor;float metal=u_metal;float roughness=u_roughness;vec3 specularColor=u_PBRSpecularColor;float glossiness=u_glossiness;float alphaCutoff=u_alphaCutoff;float F0=pow2((material_IOR-1.0)/(material_IOR+1.0));\n#ifdef BASETEXTURE\nvec4 baseTextureColor=texture2D(u_baseTexture,v_uv);\n#ifndef OASIS_COLORSPACE_GAMMA\nbaseTextureColor=gammaToLinear(baseTextureColor);\n#endif\nbaseColor*=baseTextureColor;\n#endif\n#ifdef O3_HAS_VERTEXCOLOR\nbaseColor*=v_color;\n#endif\n#ifdef ALPHA_CUTOFF\nif(baseColor.a<alphaCutoff){discard;}\n#endif\n#ifdef ROUGHNESSMETALLICTEXTURE\nvec4 metalRoughMapColor=texture2D(u_roughnessMetallicTexture,v_uv);roughness*=metalRoughMapColor.g;metal*=metalRoughMapColor.b;\n#endif\n#ifdef SPECULARGLOSSINESSTEXTURE\nvec4 specularGlossinessColor=texture2D(u_specularGlossinessTexture,v_uv);\n#ifndef OASIS_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 CLEARCOAT\nmaterial.clearCoat=u_clearCoat;material.clearCoatRoughness=u_clearCoatRoughness;\n#ifdef HAS_CLEARCOATTEXTURE\nmaterial.clearCoat*=texture2D(u_clearCoatTexture,v_uv).r;\n#endif\n#ifdef HAS_CLEARCOATROUGHNESSTEXTURE\nmaterial.clearCoatRoughness*=texture2D(u_clearCoatRoughnessTexture,v_uv).g;\n#endif\nmaterial.clearCoat=saturate(material.clearCoat);material.clearCoatRoughness=max(material.clearCoatRoughness,getAARoughnessFactor(geometry.clearCoatNormal));\n#endif\n#ifdef OASIS_TRANSPARENT\nmaterial.opacity=baseColor.a;\n#else\nmaterial.opacity=1.0;\n#endif\n}\n#include <brdf>\n#include <direct_irradiance_frag_define>\n#include <ibl_frag_define>\n"; // eslint-disable-line
|
|
1431
1431
|
var brdf = "#define GLSLIFY 1\nfloat F_Schlick(float dotLH){return 0.04+0.96*(pow(1.0-dotLH,5.0));}vec3 F_Schlick(vec3 specularColor,float dotLH){float fresnel=exp2((-5.55473*dotLH-6.98316)*dotLH);return(1.0-specularColor)*fresnel+specularColor;}float G_GGX_SmithCorrelated(float alpha,float dotNL,float dotNV){float a2=pow2(alpha);float gv=dotNL*sqrt(a2+(1.0-a2)*pow2(dotNV));float gl=dotNV*sqrt(a2+(1.0-a2)*pow2(dotNL));return 0.5/max(gv+gl,EPSILON);}float D_GGX(float alpha,float dotNH){float a2=pow2(alpha);float denom=pow2(dotNH)*(a2-1.0)+1.0;return RECIPROCAL_PI*a2/pow2(denom);}vec3 BRDF_Specular_GGX(vec3 incidentDirection,vec3 viewDir,vec3 normal,vec3 specularColor,float roughness){float alpha=pow2(roughness);vec3 halfDir=normalize(incidentDirection+viewDir);float dotNL=saturate(dot(normal,incidentDirection));float dotNV=saturate(dot(normal,viewDir));float dotNH=saturate(dot(normal,halfDir));float dotLH=saturate(dot(incidentDirection,halfDir));vec3 F=F_Schlick(specularColor,dotLH);float G=G_GGX_SmithCorrelated(alpha,dotNL,dotNV);float D=D_GGX(alpha,dotNH);return F*(G*D);}vec3 BRDF_Diffuse_Lambert(vec3 diffuseColor){return RECIPROCAL_PI*diffuseColor;}"; // eslint-disable-line
|
|
1432
1432
|
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 CLEARCOAT\nfloat clearCoatDotNL=saturate(dot(geometry.clearCoatNormal,incidentDirection));vec3 clearCoatIrradiance=clearCoatDotNL*color;reflectedLight.directSpecular+=material.clearCoat*clearCoatIrradiance*BRDF_Specular_GGX(incidentDirection,geometry.viewDir,geometry.clearCoatNormal,vec3(0.04),material.clearCoatRoughness);attenuation-=material.clearCoat*F_Schlick(geometry.clearCoatDotNV);\n#endif\nfloat dotNL=saturate(dot(geometry.normal,incidentDirection));vec3 irradiance=dotNL*color*PI;reflectedLight.directSpecular+=attenuation*irradiance*BRDF_Specular_GGX(incidentDirection,geometry.viewDir,geometry.normal,material.specularColor,material.roughness);reflectedLight.directDiffuse+=attenuation*irradiance*BRDF_Diffuse_Lambert(material.diffuseColor);}\n#ifdef O3_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 O3_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 O3_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 O3_DIRECT_LIGHT_COUNT\nshadowAttenuation=1.0;\n#ifdef OASIS_CALCULATE_SHADOWS\nshadowAttenuation*=sampleShadowMap();int sunIndex=int(u_shadowInfo.z);\n#endif\nDirectLight directionalLight;for(int i=0;i<O3_DIRECT_LIGHT_COUNT;i++){if(isRendererCulledByLight(oasis_RendererLayer.xy,u_directLightCullingMask[i]))continue;directionalLight.color=u_directLightColor[i];\n#ifdef OASIS_CALCULATE_SHADOWS\nif(i==sunIndex){directionalLight.color*=shadowAttenuation;}\n#endif\ndirectionalLight.direction=u_directLightDirection[i];addDirectionalDirectLightRadiance(directionalLight,geometry,material,reflectedLight);}\n#endif\n#ifdef O3_POINT_LIGHT_COUNT\nPointLight pointLight;for(int i=0;i<O3_POINT_LIGHT_COUNT;i++){if(isRendererCulledByLight(oasis_RendererLayer.xy,u_pointLightCullingMask[i]))continue;pointLight.color=u_pointLightColor[i];pointLight.position=u_pointLightPosition[i];pointLight.distance=u_pointLightDistance[i];addPointDirectLightRadiance(pointLight,geometry,material,reflectedLight);}\n#endif\n#ifdef O3_SPOT_LIGHT_COUNT\nSpotLight spotLight;for(int i=0;i<O3_SPOT_LIGHT_COUNT;i++){if(isRendererCulledByLight(oasis_RendererLayer.xy,u_spotLightCullingMask[i]))continue;spotLight.color=u_spotLightColor[i];spotLight.position=u_spotLightPosition[i];spotLight.direction=u_spotLightDirection[i];spotLight.distance=u_spotLightDistance[i];spotLight.angleCos=u_spotLightAngleCos[i];spotLight.penumbraCos=u_spotLightPenumbraCos[i];addSpotDirectLightRadiance(spotLight,geometry,material,reflectedLight);}\n#endif\n}"; // eslint-disable-line
|
|
1433
1433
|
var ibl_frag_define = "#define GLSLIFY 1\nvec3 getLightProbeIrradiance(vec3 sh[9],vec3 normal){normal.x=-normal.x;vec3 result=sh[0]+sh[1]*(normal.y)+sh[2]*(normal.z)+sh[3]*(normal.x)+sh[4]*(normal.y*normal.x)+sh[5]*(normal.y*normal.z)+sh[6]*(3.0*normal.z*normal.z-1.0)+sh[7]*(normal.z*normal.x)+sh[8]*(normal.x*normal.x-normal.y*normal.y);return max(result,vec3(0.0));}vec3 envBRDFApprox(vec3 specularColor,float roughness,float dotNV){const vec4 c0=vec4(-1,-0.0275,-0.572,0.022);const vec4 c1=vec4(1,0.0425,1.04,-0.04);vec4 r=roughness*c0+c1;float a004=min(r.x*r.x,exp2(-9.28*dotNV))*r.x+r.y;vec2 AB=vec2(-1.04,1.04)*a004+r.zw;return specularColor*AB.x+AB.y;}float getSpecularMIPLevel(float roughness,int maxMIPLevel){return roughness*float(maxMIPLevel);}vec3 getLightProbeRadiance(vec3 viewDir,vec3 normal,float roughness,int maxMIPLevel,float specularIntensity){\n#ifndef O3_USE_SPECULAR_ENV\nreturn vec3(0);\n#else\nvec3 reflectVec=reflect(-viewDir,normal);reflectVec.x=-reflectVec.x;float specularMIPLevel=getSpecularMIPLevel(roughness,maxMIPLevel);\n#ifdef HAS_TEX_LOD\nvec4 envMapColor=textureCubeLodEXT(u_env_specularSampler,reflectVec,specularMIPLevel);\n#else\nvec4 envMapColor=textureCube(u_env_specularSampler,reflectVec,specularMIPLevel);\n#endif\n#ifdef O3_DECODE_ENV_RGBM\nenvMapColor.rgb=RGBMToLinear(envMapColor,5.0).rgb;\n#ifdef OASIS_COLORSPACE_GAMMA\nenvMapColor=linearToGamma(envMapColor);\n#endif\n#else\n#ifndef OASIS_COLORSPACE_GAMMA\nenvMapColor=gammaToLinear(envMapColor);\n#endif\n#endif\nreturn envMapColor.rgb*specularIntensity;\n#endif\n}"; // eslint-disable-line
|
|
1434
|
-
var pbr_frag = "#define GLSLIFY 1\nGeometry geometry;Material material;ReflectedLight reflectedLight=ReflectedLight(vec3(0.0),vec3(0.0),vec3(0.0),vec3(0.0));initGeometry(geometry);initMaterial(material,geometry);addTotalDirectRadiance(geometry,material,reflectedLight);\n#ifdef O3_USE_SH\nvec3 irradiance=getLightProbeIrradiance(u_env_sh,geometry.normal);\n#ifdef OASIS_COLORSPACE_GAMMA\nirradiance=linearToGamma(vec4(irradiance,1.0)).rgb;\n#endif\nirradiance*=u_envMapLight.diffuseIntensity;\n#else\nvec3 irradiance=u_envMapLight.diffuse*u_envMapLight.diffuseIntensity;irradiance*=PI;\n#endif\nreflectedLight.indirectDiffuse+=irradiance*BRDF_Diffuse_Lambert(material.diffuseColor);vec3 radiance=getLightProbeRadiance(geometry.viewDir,geometry.normal,material.roughness,int(u_envMapLight.mipMapLevel),u_envMapLight.specularIntensity);float radianceAttenuation=1.0;\n#ifdef CLEARCOAT\nvec3 clearCoatRadiance=getLightProbeRadiance(geometry.viewDir,geometry.clearCoatNormal,material.clearCoatRoughness,int(u_envMapLight.mipMapLevel),u_envMapLight.specularIntensity);reflectedLight.indirectSpecular+=clearCoatRadiance*material.clearCoat*envBRDFApprox(vec3(0.04),material.clearCoatRoughness,geometry.clearCoatDotNV);radianceAttenuation-=material.clearCoat*F_Schlick(geometry.clearCoatDotNV);\n#endif\nreflectedLight.indirectSpecular+=radianceAttenuation*radiance*envBRDFApprox(material.specularColor,material.roughness,geometry.dotNV);\n#ifdef OCCLUSIONTEXTURE\nvec2 aoUV=v_uv;\n#ifdef O3_HAS_UV1\nif(u_occlusionTextureCoord==1.0){aoUV=v_uv1;}\n#endif\nfloat ambientOcclusion=(texture2D(u_occlusionTexture,aoUV).r-1.0)*u_occlusionIntensity+1.0;reflectedLight.indirectDiffuse*=ambientOcclusion;\n#ifdef O3_USE_SPECULAR_ENV\nreflectedLight.indirectSpecular*=computeSpecularOcclusion(ambientOcclusion,material.roughness,geometry.dotNV);\n#endif\n#endif\nvec3 emissiveRadiance=u_emissiveColor;\n#ifdef EMISSIVETEXTURE\nvec4 emissiveColor=texture2D(u_emissiveTexture,v_uv);\n#ifndef OASIS_COLORSPACE_GAMMA\nemissiveColor=gammaToLinear(emissiveColor);\n#endif\nemissiveRadiance*=emissiveColor.rgb;\n#endif\nvec3 totalRadiance=reflectedLight.directDiffuse+reflectedLight.indirectDiffuse+reflectedLight.directSpecular+reflectedLight.indirectSpecular+emissiveRadiance;vec4 targetColor=vec4(totalRadiance,material.opacity);gl_FragColor=targetColor;"; // eslint-disable-line
|
|
1434
|
+
var pbr_frag = "#define GLSLIFY 1\nGeometry geometry;Material material;ReflectedLight reflectedLight=ReflectedLight(vec3(0.0),vec3(0.0),vec3(0.0),vec3(0.0));initGeometry(geometry,gl_FrontFacing);initMaterial(material,geometry);addTotalDirectRadiance(geometry,material,reflectedLight);\n#ifdef O3_USE_SH\nvec3 irradiance=getLightProbeIrradiance(u_env_sh,geometry.normal);\n#ifdef OASIS_COLORSPACE_GAMMA\nirradiance=linearToGamma(vec4(irradiance,1.0)).rgb;\n#endif\nirradiance*=u_envMapLight.diffuseIntensity;\n#else\nvec3 irradiance=u_envMapLight.diffuse*u_envMapLight.diffuseIntensity;irradiance*=PI;\n#endif\nreflectedLight.indirectDiffuse+=irradiance*BRDF_Diffuse_Lambert(material.diffuseColor);vec3 radiance=getLightProbeRadiance(geometry.viewDir,geometry.normal,material.roughness,int(u_envMapLight.mipMapLevel),u_envMapLight.specularIntensity);float radianceAttenuation=1.0;\n#ifdef CLEARCOAT\nvec3 clearCoatRadiance=getLightProbeRadiance(geometry.viewDir,geometry.clearCoatNormal,material.clearCoatRoughness,int(u_envMapLight.mipMapLevel),u_envMapLight.specularIntensity);reflectedLight.indirectSpecular+=clearCoatRadiance*material.clearCoat*envBRDFApprox(vec3(0.04),material.clearCoatRoughness,geometry.clearCoatDotNV);radianceAttenuation-=material.clearCoat*F_Schlick(geometry.clearCoatDotNV);\n#endif\nreflectedLight.indirectSpecular+=radianceAttenuation*radiance*envBRDFApprox(material.specularColor,material.roughness,geometry.dotNV);\n#ifdef OCCLUSIONTEXTURE\nvec2 aoUV=v_uv;\n#ifdef O3_HAS_UV1\nif(u_occlusionTextureCoord==1.0){aoUV=v_uv1;}\n#endif\nfloat ambientOcclusion=(texture2D(u_occlusionTexture,aoUV).r-1.0)*u_occlusionIntensity+1.0;reflectedLight.indirectDiffuse*=ambientOcclusion;\n#ifdef O3_USE_SPECULAR_ENV\nreflectedLight.indirectSpecular*=computeSpecularOcclusion(ambientOcclusion,material.roughness,geometry.dotNV);\n#endif\n#endif\nvec3 emissiveRadiance=u_emissiveColor;\n#ifdef EMISSIVETEXTURE\nvec4 emissiveColor=texture2D(u_emissiveTexture,v_uv);\n#ifndef OASIS_COLORSPACE_GAMMA\nemissiveColor=gammaToLinear(emissiveColor);\n#endif\nemissiveRadiance*=emissiveColor.rgb;\n#endif\nvec3 totalRadiance=reflectedLight.directDiffuse+reflectedLight.indirectDiffuse+reflectedLight.directSpecular+reflectedLight.indirectSpecular+emissiveRadiance;vec4 targetColor=vec4(totalRadiance,material.opacity);gl_FragColor=targetColor;"; // eslint-disable-line
|
|
1435
1435
|
var PBRShaderLib = {
|
|
1436
1436
|
pbr_frag_define: pbr_frag_define,
|
|
1437
1437
|
pbr_helper: pbr_helper,
|
|
@@ -1452,7 +1452,7 @@ var ShadowLib = {
|
|
|
1452
1452
|
ShadowVertexDeclaration: ShadowVertexDeclaration,
|
|
1453
1453
|
ShadowVertex: ShadowVertex
|
|
1454
1454
|
};
|
|
1455
|
-
var normal_get = "#define GLSLIFY 1\nvec3 getNormal(){\n#ifdef O3_HAS_NORMAL\nvec3 normal=normalize(v_normal);\n#elif defined(HAS_DERIVATIVES)\nvec3 pos_dx=dFdx(v_pos);vec3 pos_dy=dFdy(v_pos);vec3 normal=normalize(cross(pos_dx,pos_dy));\n#else\nvec3 normal=vec3(0,0,1);\n#endif\nnormal*=float(
|
|
1455
|
+
var normal_get = "#define GLSLIFY 1\nvec3 getNormal(bool isFrontFacing){\n#ifdef O3_HAS_NORMAL\nvec3 normal=normalize(v_normal);\n#elif defined(HAS_DERIVATIVES)\nvec3 pos_dx=dFdx(v_pos);vec3 pos_dy=dFdy(v_pos);vec3 normal=normalize(cross(pos_dx,pos_dy));\n#else\nvec3 normal=vec3(0,0,1);\n#endif\nnormal*=float(isFrontFacing)*2.0-1.0;return normal;}vec3 getNormalByNormalTexture(mat3 tbn,sampler2D normalTexture,float normalIntensity,vec2 uv,bool isFrontFacing){vec3 normal=texture2D(normalTexture,uv).rgb;normal=normalize(tbn*((2.0*normal-1.0)*vec3(normalIntensity,normalIntensity,1.0)));normal*=float(isFrontFacing)*2.0-1.0;return normal;}mat3 getTBN(bool isFrontFacing){\n#if defined(O3_HAS_NORMAL) && defined(O3_HAS_TANGENT) && ( defined(NORMALTEXTURE) || defined(HAS_CLEARCOATNORMALTEXTURE) )\nmat3 tbn=v_TBN;\n#else\nvec3 normal=getNormal(isFrontFacing);vec3 position=v_pos;vec2 uv=isFrontFacing? v_uv:-v_uv;\n#ifdef HAS_DERIVATIVES\nvec3 dp1=dFdx(position);vec3 dp2=dFdy(position);vec2 duv1=dFdx(uv);vec2 duv2=dFdy(uv);vec3 dp2perp=cross(dp2,normal);vec3 dp1perp=cross(normal,dp1);vec3 tangent=dp2perp*duv1.x+dp1perp*duv2.x;vec3 binormal=dp2perp*duv1.y+dp1perp*duv2.y;float invmax=inversesqrt(max(dot(tangent,tangent),dot(binormal,binormal)));mat3 tbn=mat3(tangent*invmax,binormal*invmax,normal);\n#else\nmat3 tbn=mat3(vec3(0.0),vec3(0.0),normal);\n#endif\n#endif\nreturn tbn;}"; // eslint-disable-line
|
|
1456
1456
|
var ShaderLib = _extends$2({
|
|
1457
1457
|
common: common,
|
|
1458
1458
|
common_vert: common_vert,
|
|
@@ -11501,6 +11501,7 @@ var MeshModifyFlags;
|
|
|
11501
11501
|
var subDataDirtyFlags = this._subDataDirtyFlags;
|
|
11502
11502
|
var blendShapeFloatStride = this._vertexElementCount * 3;
|
|
11503
11503
|
var blendShapeByteStride = blendShapeFloatStride * 4;
|
|
11504
|
+
var bufferOffset = this._bufferBindingOffset;
|
|
11504
11505
|
// @todo: should fix bug when dataChangedFlag is true
|
|
11505
11506
|
for(var i = 0, n = blendShapes.length; i < n; i++){
|
|
11506
11507
|
var dataChangedFlag = subDataDirtyFlags[i];
|
|
@@ -11518,7 +11519,7 @@ var MeshModifyFlags;
|
|
|
11518
11519
|
var offset = indexInBuffer * blendShapeFloatStride;
|
|
11519
11520
|
var storeInfo = storeInfos[i];
|
|
11520
11521
|
storeInfo || (storeInfos[i] = storeInfo = new miniprogram$7.Vector2());
|
|
11521
|
-
storeInfo.set(
|
|
11522
|
+
storeInfo.set(bufferOffset + bufferIndex, indexInBuffer * blendShapeByteStride); // BufferOffset is mesh vertexBuffer offset
|
|
11522
11523
|
var deltaPositions = endFrame.deltaPositions;
|
|
11523
11524
|
for(var j = 0; j < vertexCount; j++){
|
|
11524
11525
|
var start = offset + bufferFloatStride * j;
|
|
@@ -28542,7 +28543,7 @@ var SpriteAtlasLoader = /*#__PURE__*/ function(Loader) {
|
|
|
28542
28543
|
var atlasItem = atlasItems[i];
|
|
28543
28544
|
if (atlasItem.img) {
|
|
28544
28545
|
chainPromises.push(resourceManager.load({
|
|
28545
|
-
url: atlasItem.img,
|
|
28546
|
+
url: GLTFUtil.parseRelativeUrl(item.url, atlasItem.img),
|
|
28546
28547
|
type: miniprogram$5.AssetType.Texture2D,
|
|
28547
28548
|
params: {
|
|
28548
28549
|
format: format,
|
|
@@ -29087,7 +29088,9 @@ var KHR_materials_ior = /*#__PURE__*/ function(GLTFExtensionParser) {
|
|
|
29087
29088
|
};
|
|
29088
29089
|
_inherits$1(KHR_materials_ior, GLTFExtensionParser);
|
|
29089
29090
|
var _proto = KHR_materials_ior.prototype;
|
|
29090
|
-
|
|
29091
|
+
/**
|
|
29092
|
+
* @override
|
|
29093
|
+
*/ _proto.additiveParse = function additiveParse(context, material, schema) {
|
|
29091
29094
|
var _schema_ior = schema.ior, ior = _schema_ior === void 0 ? 1.5 : _schema_ior;
|
|
29092
29095
|
material.ior = ior;
|
|
29093
29096
|
};
|
|
@@ -34257,38 +34260,6 @@ function _inherits(subClass, superClass) {
|
|
|
34257
34260
|
});
|
|
34258
34261
|
if (superClass) _set_prototype_of(subClass, superClass);
|
|
34259
34262
|
}
|
|
34260
|
-
/**
|
|
34261
|
-
* WebGL platform engine,support includes WebGL1.0 and WebGL2.0.
|
|
34262
|
-
*/ var WebGLEngine = /*#__PURE__*/ function(Engine) {
|
|
34263
|
-
var WebGLEngine = function WebGLEngine() {
|
|
34264
|
-
return Engine.apply(this, arguments);
|
|
34265
|
-
};
|
|
34266
|
-
_inherits(WebGLEngine, Engine);
|
|
34267
|
-
/**
|
|
34268
|
-
* Create a WebGL engine.
|
|
34269
|
-
* @param configuration - WebGL engine configuration
|
|
34270
|
-
* @returns A promise that will resolve when the engine is created
|
|
34271
|
-
*/ WebGLEngine.create = function create(configuration) {
|
|
34272
|
-
var canvas = configuration.canvas;
|
|
34273
|
-
var webCanvas = new WebCanvas(typeof canvas === "string" ? engineMiniprogramAdapter.document.getElementById(canvas) : canvas);
|
|
34274
|
-
var webGLGraphicDevice = new WebGLGraphicDevice(configuration.graphicDeviceOptions);
|
|
34275
|
-
var engine = new WebGLEngine(webCanvas, webGLGraphicDevice, configuration);
|
|
34276
|
-
// @ts-ignore
|
|
34277
|
-
return engine._initialize(configuration);
|
|
34278
|
-
};
|
|
34279
|
-
_create_class(WebGLEngine, [
|
|
34280
|
-
{
|
|
34281
|
-
key: "canvas",
|
|
34282
|
-
get: /**
|
|
34283
|
-
* Web canvas.
|
|
34284
|
-
*/ function get() {
|
|
34285
|
-
// @ts-ignore
|
|
34286
|
-
return this._canvas;
|
|
34287
|
-
}
|
|
34288
|
-
}
|
|
34289
|
-
]);
|
|
34290
|
-
return WebGLEngine;
|
|
34291
|
-
}(miniprogram$1$1.Engine);
|
|
34292
34263
|
function _extends() {
|
|
34293
34264
|
_extends = Object.assign || function assign(target) {
|
|
34294
34265
|
for(var i = 1; i < arguments.length; i++){
|
|
@@ -34299,83 +34270,6 @@ function _extends() {
|
|
|
34299
34270
|
};
|
|
34300
34271
|
return _extends.apply(this, arguments);
|
|
34301
34272
|
}
|
|
34302
|
-
var GLBuffer = /*#__PURE__*/ function() {
|
|
34303
|
-
var GLBuffer = function GLBuffer(rhi, type, byteLength, bufferUsage, data) {
|
|
34304
|
-
if (bufferUsage === void 0) bufferUsage = miniprogram$1$1.BufferUsage.Static;
|
|
34305
|
-
var gl = rhi.gl;
|
|
34306
|
-
var glBuffer = gl.createBuffer();
|
|
34307
|
-
var glBufferUsage = this._getGLBufferUsage(gl, bufferUsage);
|
|
34308
|
-
var glBindTarget = type === miniprogram$1$1.BufferBindFlag.VertexBuffer ? gl.ARRAY_BUFFER : gl.ELEMENT_ARRAY_BUFFER;
|
|
34309
|
-
this._gl = gl;
|
|
34310
|
-
this._glBuffer = glBuffer;
|
|
34311
|
-
this._glBufferUsage = glBufferUsage;
|
|
34312
|
-
this._glBindTarget = glBindTarget;
|
|
34313
|
-
this._isWebGL2 = rhi.isWebGL2;
|
|
34314
|
-
this.bind();
|
|
34315
|
-
if (data) {
|
|
34316
|
-
gl.bufferData(glBindTarget, data, glBufferUsage);
|
|
34317
|
-
} else {
|
|
34318
|
-
gl.bufferData(glBindTarget, byteLength, glBufferUsage);
|
|
34319
|
-
}
|
|
34320
|
-
gl.bindBuffer(glBindTarget, null);
|
|
34321
|
-
};
|
|
34322
|
-
var _proto = GLBuffer.prototype;
|
|
34323
|
-
_proto.bind = function bind() {
|
|
34324
|
-
this._gl.bindBuffer(this._glBindTarget, this._glBuffer);
|
|
34325
|
-
};
|
|
34326
|
-
_proto.setData = function setData(byteLength, data, bufferByteOffset, dataOffset, dataLength, options) {
|
|
34327
|
-
var gl = this._gl;
|
|
34328
|
-
var glBindTarget = this._glBindTarget;
|
|
34329
|
-
this.bind();
|
|
34330
|
-
if (options === miniprogram$1$1.SetDataOptions.Discard) {
|
|
34331
|
-
gl.bufferData(glBindTarget, byteLength, this._glBufferUsage);
|
|
34332
|
-
}
|
|
34333
|
-
// TypeArray is BYTES_PER_ELEMENT, unTypeArray is 1
|
|
34334
|
-
var byteSize = data.BYTES_PER_ELEMENT || 1;
|
|
34335
|
-
var dataByteLength = dataLength ? byteSize * dataLength : data.byteLength;
|
|
34336
|
-
if (dataOffset !== 0 || dataByteLength < data.byteLength) {
|
|
34337
|
-
var isArrayBufferView = data.byteOffset !== undefined;
|
|
34338
|
-
if (this._isWebGL2 && isArrayBufferView) {
|
|
34339
|
-
gl.bufferSubData(glBindTarget, bufferByteOffset, data, dataOffset, dataByteLength / byteSize);
|
|
34340
|
-
} else {
|
|
34341
|
-
var subData = new Uint8Array(isArrayBufferView ? data.buffer : data, dataOffset * byteSize, dataByteLength);
|
|
34342
|
-
gl.bufferSubData(glBindTarget, bufferByteOffset, subData);
|
|
34343
|
-
}
|
|
34344
|
-
} else {
|
|
34345
|
-
gl.bufferSubData(glBindTarget, bufferByteOffset, data);
|
|
34346
|
-
}
|
|
34347
|
-
gl.bindBuffer(glBindTarget, null);
|
|
34348
|
-
};
|
|
34349
|
-
_proto.getData = function getData(data, bufferByteOffset, dataOffset, dataLength) {
|
|
34350
|
-
if (this._isWebGL2) {
|
|
34351
|
-
var gl = this._gl;
|
|
34352
|
-
this.bind();
|
|
34353
|
-
gl.getBufferSubData(this._glBindTarget, bufferByteOffset, data, dataOffset, dataLength);
|
|
34354
|
-
} else {
|
|
34355
|
-
throw "Buffer is write-only on WebGL1.0 platforms.";
|
|
34356
|
-
}
|
|
34357
|
-
};
|
|
34358
|
-
_proto.resize = function resize(byteLength) {
|
|
34359
|
-
this.bind();
|
|
34360
|
-
this._gl.bufferData(this._glBindTarget, byteLength, this._glBufferUsage);
|
|
34361
|
-
};
|
|
34362
|
-
_proto.destroy = function destroy() {
|
|
34363
|
-
this._gl.deleteBuffer(this._glBuffer);
|
|
34364
|
-
this._gl = null;
|
|
34365
|
-
this._glBuffer = null;
|
|
34366
|
-
};
|
|
34367
|
-
_proto._getGLBufferUsage = function _getGLBufferUsage(gl, bufferUsage) {
|
|
34368
|
-
switch(bufferUsage){
|
|
34369
|
-
case miniprogram$1$1.BufferUsage.Static:
|
|
34370
|
-
return gl.STATIC_DRAW;
|
|
34371
|
-
case miniprogram$1$1.BufferUsage.Dynamic:
|
|
34372
|
-
return gl.DYNAMIC_DRAW;
|
|
34373
|
-
case miniprogram$1$1.BufferUsage.Stream:
|
|
34374
|
-
return gl.STREAM_DRAW;
|
|
34375
|
-
}
|
|
34376
|
-
};
|
|
34377
|
-
return GLBuffer;
|
|
34378
|
-
}();
|
|
34379
34273
|
/**
|
|
34380
34274
|
* GL capability.
|
|
34381
34275
|
*/ var GLCapability = /*#__PURE__*/ function() {
|
|
@@ -34638,8 +34532,8 @@ var GLBuffer = /*#__PURE__*/ function() {
|
|
|
34638
34532
|
if (useVao) {
|
|
34639
34533
|
gl.drawElements(topology, count, _glIndexType, start * _glIndexByteCount);
|
|
34640
34534
|
} else {
|
|
34641
|
-
var
|
|
34642
|
-
gl.bindBuffer(gl.ELEMENT_ARRAY_BUFFER,
|
|
34535
|
+
var _nativeBuffer = _indexBufferBinding.buffer._nativeBuffer;
|
|
34536
|
+
gl.bindBuffer(gl.ELEMENT_ARRAY_BUFFER, _nativeBuffer);
|
|
34643
34537
|
gl.drawElements(topology, count, _glIndexType, start * _glIndexByteCount);
|
|
34644
34538
|
gl.bindBuffer(gl.ELEMENT_ARRAY_BUFFER, null);
|
|
34645
34539
|
}
|
|
@@ -34652,8 +34546,8 @@ var GLBuffer = /*#__PURE__*/ function() {
|
|
|
34652
34546
|
if (useVao) {
|
|
34653
34547
|
gl.drawElementsInstanced(topology, count, _glIndexType, start * _glIndexByteCount, _instanceCount);
|
|
34654
34548
|
} else {
|
|
34655
|
-
var
|
|
34656
|
-
gl.bindBuffer(gl.ELEMENT_ARRAY_BUFFER,
|
|
34549
|
+
var _nativeBuffer1 = _indexBufferBinding.buffer._nativeBuffer;
|
|
34550
|
+
gl.bindBuffer(gl.ELEMENT_ARRAY_BUFFER, _nativeBuffer1);
|
|
34657
34551
|
gl.drawElementsInstanced(topology, count, _glIndexType, start * _glIndexByteCount, _instanceCount);
|
|
34658
34552
|
gl.bindBuffer(gl.ELEMENT_ARRAY_BUFFER, null);
|
|
34659
34553
|
}
|
|
@@ -34693,7 +34587,7 @@ var GLBuffer = /*#__PURE__*/ function() {
|
|
|
34693
34587
|
var element = attributes[name];
|
|
34694
34588
|
if (element) {
|
|
34695
34589
|
var _vertexBufferBindings_element_bindingIndex = vertexBufferBindings[element.bindingIndex], buffer = _vertexBufferBindings_element_bindingIndex.buffer, stride = _vertexBufferBindings_element_bindingIndex.stride;
|
|
34696
|
-
vbo = buffer.
|
|
34590
|
+
vbo = buffer._nativeBuffer;
|
|
34697
34591
|
// prevent binding the vbo which already bound at the last loop, e.g. a buffer with multiple attributes.
|
|
34698
34592
|
if (lastBoundVbo !== vbo) {
|
|
34699
34593
|
lastBoundVbo = vbo;
|
|
@@ -34725,7 +34619,7 @@ var GLBuffer = /*#__PURE__*/ function() {
|
|
|
34725
34619
|
// @ts-ignore
|
|
34726
34620
|
var _indexBufferBinding = this._primitive._indexBufferBinding;
|
|
34727
34621
|
if (_indexBufferBinding) {
|
|
34728
|
-
gl.bindBuffer(gl.ELEMENT_ARRAY_BUFFER, _indexBufferBinding.buffer.
|
|
34622
|
+
gl.bindBuffer(gl.ELEMENT_ARRAY_BUFFER, _indexBufferBinding.buffer._nativeBuffer);
|
|
34729
34623
|
}
|
|
34730
34624
|
this._bindBufferAndAttrib(shaderProgram);
|
|
34731
34625
|
/** unbind */ gl.bindVertexArray(null);
|
|
@@ -35782,21 +35676,23 @@ exports.WebGLMode = void 0;
|
|
|
35782
35676
|
WebGLMode[WebGLMode[/** WebGL1.0, */ "WebGL1"] = 2] = "WebGL1";
|
|
35783
35677
|
})(exports.WebGLMode || (exports.WebGLMode = {}));
|
|
35784
35678
|
/**
|
|
35785
|
-
* WebGL
|
|
35786
|
-
*/ var
|
|
35787
|
-
var
|
|
35679
|
+
* WebGL renderer, including WebGL1.0 and WebGL2.0.
|
|
35680
|
+
*/ var WebGLRenderer = /*#__PURE__*/ function() {
|
|
35681
|
+
var WebGLRenderer = function WebGLRenderer(initializeOptions) {
|
|
35788
35682
|
if (initializeOptions === void 0) initializeOptions = {};
|
|
35789
|
-
/** @internal */ this._readFrameBuffer = null;
|
|
35790
35683
|
/** @internal */ this._enableGlobalDepthBias = false;
|
|
35791
35684
|
this._activeTextures = new Array(32);
|
|
35685
|
+
// cache value
|
|
35792
35686
|
this._lastViewport = new miniprogram$1.Vector4(null, null, null, null);
|
|
35793
35687
|
this._lastScissor = new miniprogram$1.Vector4(null, null, null, null);
|
|
35794
35688
|
this._lastClearColor = new miniprogram$1.Color(null, null, null, null);
|
|
35795
35689
|
this._scissorEnable = false;
|
|
35796
35690
|
var options = _extends({
|
|
35797
35691
|
webGLMode: 0,
|
|
35692
|
+
alpha: false,
|
|
35798
35693
|
stencil: true,
|
|
35799
|
-
_forceFlush: false
|
|
35694
|
+
_forceFlush: false,
|
|
35695
|
+
_maxAllowSkinUniformVectorCount: 256
|
|
35800
35696
|
}, initializeOptions);
|
|
35801
35697
|
if (miniprogram$1$1.SystemInfo.platform === miniprogram$1$1.Platform.IPhone || miniprogram$1$1.SystemInfo.platform === miniprogram$1$1.Platform.IPad) {
|
|
35802
35698
|
var version = miniprogram$1$1.SystemInfo.operatingSystem.match(/(\d+).?(\d+)?.?(\d+)?/);
|
|
@@ -35809,20 +35705,12 @@ exports.WebGLMode = void 0;
|
|
|
35809
35705
|
}
|
|
35810
35706
|
}
|
|
35811
35707
|
this._options = options;
|
|
35812
|
-
this._onWebGLContextLost = this._onWebGLContextLost.bind(this);
|
|
35813
|
-
this._onWebGLContextRestored = this._onWebGLContextRestored.bind(this);
|
|
35814
35708
|
};
|
|
35815
|
-
var _proto =
|
|
35816
|
-
_proto.init = function init(canvas
|
|
35709
|
+
var _proto = WebGLRenderer.prototype;
|
|
35710
|
+
_proto.init = function init(canvas) {
|
|
35817
35711
|
var options = this._options;
|
|
35818
|
-
var webCanvas = canvas._webCanvas;
|
|
35712
|
+
var webCanvas = this._webCanvas = canvas._webCanvas;
|
|
35819
35713
|
var webGLMode = options.webGLMode;
|
|
35820
|
-
this._onDeviceLost = onDeviceLost;
|
|
35821
|
-
this._onDeviceRestored = onDeviceRestored;
|
|
35822
|
-
webCanvas.addEventListener("webglcontextlost", this._onWebGLContextLost, false);
|
|
35823
|
-
webCanvas.addEventListener("webglcontextrestored", this._onWebGLContextRestored, false);
|
|
35824
|
-
webCanvas.addEventListener("webglcontextcreationerror", this._onContextCreationError, false);
|
|
35825
|
-
this._webCanvas = webCanvas;
|
|
35826
35714
|
var gl;
|
|
35827
35715
|
if (webGLMode == 0 || webGLMode == 1) {
|
|
35828
35716
|
gl = webCanvas.getContext("webgl2", options);
|
|
@@ -35848,7 +35736,16 @@ exports.WebGLMode = void 0;
|
|
|
35848
35736
|
throw new Error("Get GL Context FAILED.");
|
|
35849
35737
|
}
|
|
35850
35738
|
this._gl = gl;
|
|
35851
|
-
this.
|
|
35739
|
+
this._activeTextureID = gl.TEXTURE0;
|
|
35740
|
+
this._renderStates = new GLRenderStates(gl);
|
|
35741
|
+
this._extensions = new GLExtensions(this);
|
|
35742
|
+
this._capability = new GLCapability(this);
|
|
35743
|
+
// Make sure the active texture in gl context is on default, because gl context may be used in other webgl renderer.
|
|
35744
|
+
gl.activeTexture(gl.TEXTURE0);
|
|
35745
|
+
var debugRenderInfo = gl.getExtension("WEBGL_debug_renderer_info");
|
|
35746
|
+
if (debugRenderInfo != null) {
|
|
35747
|
+
this._renderer = gl.getParameter(debugRenderInfo.UNMASKED_RENDERER_WEBGL);
|
|
35748
|
+
}
|
|
35852
35749
|
};
|
|
35853
35750
|
_proto.createPlatformPrimitive = function createPlatformPrimitive(primitive) {
|
|
35854
35751
|
return new GLPrimitive(this, primitive);
|
|
@@ -35865,10 +35762,6 @@ exports.WebGLMode = void 0;
|
|
|
35865
35762
|
_proto.createPlatformRenderTarget = function createPlatformRenderTarget(target) {
|
|
35866
35763
|
return new GLRenderTarget(this, target);
|
|
35867
35764
|
};
|
|
35868
|
-
_proto.createPlatformBuffer = function createPlatformBuffer(type, byteLength, bufferUsage, data) {
|
|
35869
|
-
if (bufferUsage === void 0) bufferUsage = miniprogram$1$1.BufferUsage.Static;
|
|
35870
|
-
return new GLBuffer(this, type, byteLength, bufferUsage, data);
|
|
35871
|
-
};
|
|
35872
35765
|
_proto.requireExtension = function requireExtension(ext) {
|
|
35873
35766
|
return this._extensions.requireExtension(ext);
|
|
35874
35767
|
};
|
|
@@ -35996,57 +35889,8 @@ exports.WebGLMode = void 0;
|
|
|
35996
35889
|
_proto.flush = function flush() {
|
|
35997
35890
|
this._gl.flush();
|
|
35998
35891
|
};
|
|
35999
|
-
_proto.
|
|
36000
|
-
|
|
36001
|
-
extension.loseContext();
|
|
36002
|
-
};
|
|
36003
|
-
_proto.forceRestoreDevice = function forceRestoreDevice() {
|
|
36004
|
-
var extension = this.requireExtension(miniprogram$1$1.GLCapabilityType.WEBGL_lose_context);
|
|
36005
|
-
extension.restoreContext();
|
|
36006
|
-
};
|
|
36007
|
-
_proto.resetState = function resetState() {
|
|
36008
|
-
this._readFrameBuffer = null;
|
|
36009
|
-
this._enableGlobalDepthBias = false;
|
|
36010
|
-
this._currentBindShaderProgram = null;
|
|
36011
|
-
var activeTextures = this._activeTextures;
|
|
36012
|
-
for(var i = 0, n = activeTextures.length; i < n; i++){
|
|
36013
|
-
activeTextures[i] = null;
|
|
36014
|
-
}
|
|
36015
|
-
this._lastViewport.set(null, null, null, null);
|
|
36016
|
-
this._lastScissor.set(null, null, null, null);
|
|
36017
|
-
this._lastClearColor.set(null, null, null, null);
|
|
36018
|
-
this._scissorEnable = false;
|
|
36019
|
-
this._initGLState(this._gl);
|
|
36020
|
-
};
|
|
36021
|
-
_proto._initGLState = function _initGLState(gl) {
|
|
36022
|
-
this._activeTextureID = gl.TEXTURE0;
|
|
36023
|
-
this._renderStates = new GLRenderStates(gl);
|
|
36024
|
-
this._extensions = new GLExtensions(this);
|
|
36025
|
-
this._capability = new GLCapability(this);
|
|
36026
|
-
// Make sure the active texture in gl context is on default, because gl context may be used in other webgl renderer.
|
|
36027
|
-
gl.activeTexture(gl.TEXTURE0);
|
|
36028
|
-
var debugRenderInfo = gl.getExtension("WEBGL_debug_renderer_info");
|
|
36029
|
-
if (debugRenderInfo != null) {
|
|
36030
|
-
this._renderer = gl.getParameter(debugRenderInfo.UNMASKED_RENDERER_WEBGL);
|
|
36031
|
-
}
|
|
36032
|
-
};
|
|
36033
|
-
_proto.destroy = function destroy() {
|
|
36034
|
-
var webCanvas = this._webCanvas;
|
|
36035
|
-
webCanvas.removeEventListener("webglcontextcreationerror", this._onContextCreationError, false);
|
|
36036
|
-
webCanvas.removeEventListener("webglcontextlost", this._onWebGLContextLost, false);
|
|
36037
|
-
webCanvas.removeEventListener("webglcontextrestored", this._onWebGLContextRestored, false);
|
|
36038
|
-
};
|
|
36039
|
-
_proto._onContextCreationError = function _onContextCreationError(event) {
|
|
36040
|
-
console.error("WebGLRenderer: WebGL context could not be created. Reason: ", event.statusMessage);
|
|
36041
|
-
};
|
|
36042
|
-
_proto._onWebGLContextLost = function _onWebGLContextLost(event) {
|
|
36043
|
-
event.preventDefault();
|
|
36044
|
-
this._onDeviceLost();
|
|
36045
|
-
};
|
|
36046
|
-
_proto._onWebGLContextRestored = function _onWebGLContextRestored(event) {
|
|
36047
|
-
this._onDeviceRestored();
|
|
36048
|
-
};
|
|
36049
|
-
_create_class(WebGLGraphicDevice, [
|
|
35892
|
+
_proto.destroy = function destroy() {};
|
|
35893
|
+
_create_class(WebGLRenderer, [
|
|
36050
35894
|
{
|
|
36051
35895
|
key: "isWebGL2",
|
|
36052
35896
|
get: function get() {
|
|
@@ -36087,11 +35931,32 @@ exports.WebGLMode = void 0;
|
|
|
36087
35931
|
}
|
|
36088
35932
|
}
|
|
36089
35933
|
]);
|
|
36090
|
-
return
|
|
35934
|
+
return WebGLRenderer;
|
|
36091
35935
|
}();
|
|
35936
|
+
/**
|
|
35937
|
+
* WebGL platform engine,support includes WebGL1.0 and WebGL2.0.
|
|
35938
|
+
*/ var WebGLEngine = /*#__PURE__*/ function(Engine) {
|
|
35939
|
+
var WebGLEngine = function WebGLEngine(canvas, webGLRendererOptions) {
|
|
35940
|
+
var webCanvas = new WebCanvas(typeof canvas === "string" ? engineMiniprogramAdapter.document.getElementById(canvas) : canvas);
|
|
35941
|
+
var hardwareRenderer = new WebGLRenderer(webGLRendererOptions);
|
|
35942
|
+
return Engine.call(this, webCanvas, hardwareRenderer);
|
|
35943
|
+
};
|
|
35944
|
+
_inherits(WebGLEngine, Engine);
|
|
35945
|
+
_create_class(WebGLEngine, [
|
|
35946
|
+
{
|
|
35947
|
+
key: "canvas",
|
|
35948
|
+
get: /**
|
|
35949
|
+
* Web canvas.
|
|
35950
|
+
*/ function get() {
|
|
35951
|
+
return this._canvas;
|
|
35952
|
+
}
|
|
35953
|
+
}
|
|
35954
|
+
]);
|
|
35955
|
+
return WebGLEngine;
|
|
35956
|
+
}(miniprogram$1$1.Engine);
|
|
36092
35957
|
exports.WebCanvas = WebCanvas;
|
|
36093
35958
|
exports.WebGLEngine = WebGLEngine;
|
|
36094
|
-
exports.
|
|
35959
|
+
exports.WebGLRenderer = WebGLRenderer;
|
|
36095
35960
|
|
|
36096
35961
|
var miniprogram$3 = /*#__PURE__*/Object.freeze({
|
|
36097
35962
|
__proto__: null
|
|
@@ -36132,7 +35997,7 @@ function _interopNamespace(e) {
|
|
|
36132
35997
|
}
|
|
36133
35998
|
var CoreObjects__namespace = /*#__PURE__*/ _interopNamespace(CoreObjects);
|
|
36134
35999
|
//@ts-ignore
|
|
36135
|
-
var version = "0.0.0-experimental-0.9-plus.
|
|
36000
|
+
var version = "0.0.0-experimental-0.9-plus.4";
|
|
36136
36001
|
console.log("Galacean engine version: " + version);
|
|
36137
36002
|
for(var key in CoreObjects__namespace){
|
|
36138
36003
|
CoreObjects.Loader.registerClass(key, CoreObjects__namespace[key]);
|