@galacean/engine-physics-lite 0.9.0-beta.81 → 0.9.0-beta.82

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.
@@ -7468,7 +7468,6 @@ var common = "#define GLSLIFY 1\n#define PI 3.14159265359\n#define RECIPROCAL_PI
7468
7468
  var common_vert = "#define GLSLIFY 1\nattribute vec3 POSITION;\n#ifdef O3_HAS_UV\nattribute vec2 TEXCOORD_0;\n#endif\n#ifdef O3_HAS_UV1\nattribute vec2 TEXCOORD_1;\n#endif\n#ifdef O3_HAS_SKIN\nattribute vec4 JOINTS_0;attribute vec4 WEIGHTS_0;\n#ifdef O3_USE_JOINT_TEXTURE\nuniform sampler2D u_jointSampler;uniform float u_jointCount;mat4 getJointMatrix(sampler2D smp,float index){float base=index/u_jointCount;float hf=0.5/u_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 u_jointMatrix[O3_JOINTS_NUM];\n#endif\n#endif\n#ifdef O3_HAS_VERTEXCOLOR\nattribute vec4 COLOR_0;\n#endif\n#include <transform_declare>\n#include <camera_declare>\nuniform vec4 u_tilingOffset;\n#ifndef OMIT_NORMAL\n#ifdef O3_HAS_NORMAL\nattribute vec3 NORMAL;\n#endif\n#ifdef O3_HAS_TANGENT\nattribute vec4 TANGENT;\n#endif\n#endif\n"; // eslint-disable-line
7469
7469
  var transform_declare = "#define GLSLIFY 1\nuniform mat4 u_localMat;uniform mat4 u_modelMat;uniform mat4 u_viewMat;uniform mat4 u_projMat;uniform mat4 u_MVMat;uniform mat4 u_MVPMat;uniform mat4 u_normalMat;"; // eslint-disable-line
7470
7470
  var color_share = "#define GLSLIFY 1\n#ifdef O3_HAS_VERTEXCOLOR\nvarying vec4 v_color;\n#endif\n"; // eslint-disable-line
7471
- var RendererFragmentDeclaration = "#define GLSLIFY 1\nuniform highp ivec4 oasis_RendererLayer;"; // eslint-disable-line
7472
7471
  var FogFragmentDeclaration = "#define GLSLIFY 1\n#if OASIS_FOG_MODE != 0\nvarying vec3 v_positionVS;uniform vec4 oasis_FogColor;uniform vec4 oasis_FogParams;float ComputeFogIntensity(float fogDepth){\n#if OASIS_FOG_MODE == 1\nreturn clamp(fogDepth*oasis_FogParams.x+oasis_FogParams.y,0.0,1.0);\n#elif OASIS_FOG_MODE == 2\nreturn clamp(exp2(-fogDepth*oasis_FogParams.z),0.0,1.0);\n#elif OASIS_FOG_MODE == 3\nfloat factor=fogDepth*oasis_FogParams.w;return clamp(exp2(-factor*factor),0.0,1.0);\n#endif\n}\n#endif\n"; // eslint-disable-line
7473
7472
  var FogVertexDeclaration = "#define GLSLIFY 1\n#if OASIS_FOG_MODE != 0\nvarying vec3 v_positionVS;\n#endif\n"; // eslint-disable-line
7474
7473
  var normal_share = "#define GLSLIFY 1\n#ifndef OMIT_NORMAL\n#ifdef O3_HAS_NORMAL\nvarying vec3 v_normal;\n#if defined(O3_HAS_TANGENT) && ( defined(NORMALTEXTURE) || defined(HAS_CLEARCOATNORMALTEXTURE) )\nvarying mat3 v_TBN;\n#endif\n#endif\n#endif\n"; // eslint-disable-line
@@ -7486,7 +7485,7 @@ var skinning_vert = "#define GLSLIFY 1\n#ifdef O3_HAS_SKIN\n#ifdef O3_USE_JOINT_
7486
7485
  var uv_vert = "#define GLSLIFY 1\n#ifdef O3_HAS_UV\nv_uv=TEXCOORD_0;\n#else\nv_uv=vec2(0.,0.);\n#endif\n#ifdef O3_HAS_UV1\nv_uv1=TEXCOORD_1;\n#endif\n#ifdef O3_NEED_TILINGOFFSET\nv_uv=v_uv*u_tilingOffset.xy+u_tilingOffset.zw;\n#endif\n"; // eslint-disable-line
7487
7486
  var worldpos_vert = "#define GLSLIFY 1\n#ifdef O3_NEED_WORLDPOS\nvec4 temp_pos=u_modelMat*position;v_pos=temp_pos.xyz/temp_pos.w;\n#endif\n"; // eslint-disable-line
7488
7487
  var FogFragment = "#define GLSLIFY 1\n#if OASIS_FOG_MODE != 0\nfloat fogIntensity=ComputeFogIntensity(length(v_positionVS));gl_FragColor.rgb=mix(oasis_FogColor.rgb,gl_FragColor.rgb,fogIntensity);\n#endif\n"; // eslint-disable-line
7489
- var light_frag_define = "#define GLSLIFY 1\n#ifdef O3_DIRECT_LIGHT_COUNT\nstruct DirectLight{vec3 color;vec3 direction;};uniform ivec2 u_directLightCullingMask[O3_DIRECT_LIGHT_COUNT];uniform vec3 u_directLightColor[O3_DIRECT_LIGHT_COUNT];uniform vec3 u_directLightDirection[O3_DIRECT_LIGHT_COUNT];\n#endif\n#ifdef O3_POINT_LIGHT_COUNT\nstruct PointLight{vec3 color;vec3 position;float distance;};uniform ivec2 u_pointLightCullingMask[O3_POINT_LIGHT_COUNT];uniform vec3 u_pointLightColor[O3_POINT_LIGHT_COUNT];uniform vec3 u_pointLightPosition[O3_POINT_LIGHT_COUNT];uniform float u_pointLightDistance[O3_POINT_LIGHT_COUNT];\n#endif\n#ifdef O3_SPOT_LIGHT_COUNT\nstruct SpotLight{vec3 color;vec3 position;vec3 direction;float distance;float angleCos;float penumbraCos;};uniform ivec2 u_spotLightCullingMask[O3_SPOT_LIGHT_COUNT];uniform vec3 u_spotLightColor[O3_SPOT_LIGHT_COUNT];uniform vec3 u_spotLightPosition[O3_SPOT_LIGHT_COUNT];uniform vec3 u_spotLightDirection[O3_SPOT_LIGHT_COUNT];uniform float u_spotLightDistance[O3_SPOT_LIGHT_COUNT];uniform float u_spotLightAngleCos[O3_SPOT_LIGHT_COUNT];uniform float u_spotLightPenumbraCos[O3_SPOT_LIGHT_COUNT];\n#endif\nstruct EnvMapLight{vec3 diffuse;float mipMapLevel;float diffuseIntensity;float specularIntensity;};uniform EnvMapLight u_envMapLight;\n#ifdef O3_USE_SH\nuniform vec3 u_env_sh[9];\n#endif\n#ifdef O3_USE_SPECULAR_ENV\nuniform samplerCube u_env_specularSampler;\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
7488
+ var light_frag_define = "#define GLSLIFY 1\n#ifdef O3_DIRECT_LIGHT_COUNT\nstruct DirectLight{vec3 color;vec3 direction;};uniform ivec2 u_directLightCullingMask[O3_DIRECT_LIGHT_COUNT];uniform vec3 u_directLightColor[O3_DIRECT_LIGHT_COUNT];uniform vec3 u_directLightDirection[O3_DIRECT_LIGHT_COUNT];\n#endif\n#ifdef O3_POINT_LIGHT_COUNT\nstruct PointLight{vec3 color;vec3 position;float distance;};uniform ivec2 u_pointLightCullingMask[O3_POINT_LIGHT_COUNT];uniform vec3 u_pointLightColor[O3_POINT_LIGHT_COUNT];uniform vec3 u_pointLightPosition[O3_POINT_LIGHT_COUNT];uniform float u_pointLightDistance[O3_POINT_LIGHT_COUNT];\n#endif\n#ifdef O3_SPOT_LIGHT_COUNT\nstruct SpotLight{vec3 color;vec3 position;vec3 direction;float distance;float angleCos;float penumbraCos;};uniform ivec2 u_spotLightCullingMask[O3_SPOT_LIGHT_COUNT];uniform vec3 u_spotLightColor[O3_SPOT_LIGHT_COUNT];uniform vec3 u_spotLightPosition[O3_SPOT_LIGHT_COUNT];uniform vec3 u_spotLightDirection[O3_SPOT_LIGHT_COUNT];uniform float u_spotLightDistance[O3_SPOT_LIGHT_COUNT];uniform float u_spotLightAngleCos[O3_SPOT_LIGHT_COUNT];uniform float u_spotLightPenumbraCos[O3_SPOT_LIGHT_COUNT];\n#endif\nstruct EnvMapLight{vec3 diffuse;float mipMapLevel;float diffuseIntensity;float specularIntensity;};uniform EnvMapLight u_envMapLight;uniform ivec4 oasis_RendererLayer;\n#ifdef O3_USE_SH\nuniform vec3 u_env_sh[9];\n#endif\n#ifdef O3_USE_SPECULAR_ENV\nuniform samplerCube u_env_specularSampler;\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
7490
7489
  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
7491
7490
  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
7492
7491
  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
@@ -7543,7 +7542,6 @@ var ShaderLib = _extends$2({
7543
7542
  normal_share: normal_share,
7544
7543
  uv_share: uv_share,
7545
7544
  worldpos_share: worldpos_share,
7546
- RendererFragmentDeclaration: RendererFragmentDeclaration,
7547
7545
  FogVertexDeclaration: FogVertexDeclaration,
7548
7546
  FogFragmentDeclaration: FogFragmentDeclaration,
7549
7547
  begin_normal_vert: begin_normal_vert,
@@ -15155,11 +15153,11 @@ Scene._fogParamsProperty = Shader.getPropertyByName("oasis_FogParams");
15155
15153
  ]);
15156
15154
  return SceneManager;
15157
15155
  }();
15158
- var blinnPhongFs = "#define GLSLIFY 1\n#include <common>\n#include <camera_declare>\n#include <uv_share>\n#include <normal_share>\n#include <color_share>\n#include <worldpos_share>\n#include <light_frag_define>\n#include <ShadowFragmentDeclaration>\n#include <mobile_material_frag>\n#include <RendererFragmentDeclaration>\n#include <FogFragmentDeclaration>\n#include <normal_get>\nvoid main(){\n#include <begin_mobile_frag>\n#include <begin_viewdir_frag>\n#include <mobile_blinnphong_frag>\ngl_FragColor=emission+ambient+diffuse+specular;\n#ifdef OASIS_TRANSPARENT\ngl_FragColor.a=diffuse.a;\n#else\ngl_FragColor.a=1.0;\n#endif\n#include <FogFragment>\n#ifndef OASIS_COLORSPACE_GAMMA\ngl_FragColor=linearToGamma(gl_FragColor);\n#endif\n}"; // eslint-disable-line
15156
+ var blinnPhongFs = "#define GLSLIFY 1\n#include <common>\n#include <camera_declare>\n#include <uv_share>\n#include <normal_share>\n#include <color_share>\n#include <worldpos_share>\n#include <light_frag_define>\n#include <ShadowFragmentDeclaration>\n#include <mobile_material_frag>\n#include <FogFragmentDeclaration>\n#include <normal_get>\nvoid main(){\n#include <begin_mobile_frag>\n#include <begin_viewdir_frag>\n#include <mobile_blinnphong_frag>\ngl_FragColor=emission+ambient+diffuse+specular;\n#ifdef OASIS_TRANSPARENT\ngl_FragColor.a=diffuse.a;\n#else\ngl_FragColor.a=1.0;\n#endif\n#include <FogFragment>\n#ifndef OASIS_COLORSPACE_GAMMA\ngl_FragColor=linearToGamma(gl_FragColor);\n#endif\n}"; // eslint-disable-line
15159
15157
  var blinnPhongVs = "#define GLSLIFY 1\n#include <common>\n#include <common_vert>\n#include <blendShape_input>\n#include <uv_share>\n#include <color_share>\n#include <normal_share>\n#include <worldpos_share>\n#include <ShadowVertexDeclaration>\n#include <FogVertexDeclaration>\nvoid main(){\n#include <begin_position_vert>\n#include <begin_normal_vert>\n#include <blendShape_vert>\n#include <skinning_vert>\n#include <uv_vert>\n#include <color_vert>\n#include <normal_vert>\n#include <worldpos_vert>\n#include <position_vert>\n#include <ShadowVertex>\n#include <FogVertex>\n}"; // eslint-disable-line
15160
15158
  var particleFs = "#define GLSLIFY 1\nvarying vec4 v_color;varying float v_lifeLeft;varying vec2 v_uv;uniform sampler2D u_texture;void main(){if(v_lifeLeft==1.0){discard;}float alphaFactor=1.0;\n#ifdef fadeIn\nfloat fadeInFactor=step(0.5,v_lifeLeft);alphaFactor=2.0*fadeInFactor*(1.0-v_lifeLeft)+(1.0-fadeInFactor);\n#endif\n#ifdef fadeOut\nfloat fadeOutFactor=step(0.5,v_lifeLeft);alphaFactor=alphaFactor*2.0*(1.0-fadeOutFactor)*v_lifeLeft+alphaFactor*fadeOutFactor;\n#endif\n#ifdef particleTexture\nvec4 tex=texture2D(u_texture,v_uv);\n#ifdef useOriginColor\ngl_FragColor=vec4(tex.rgb,alphaFactor*tex.a*v_color.w);\n#else\ngl_FragColor=vec4(v_color.xyz*tex.rgb,alphaFactor*tex.a*v_color.w);\n#endif\n#else\ngl_FragColor=vec4(v_color.xyz,alphaFactor*v_color.w);\n#endif\n}"; // eslint-disable-line
15161
15159
  var particleVs = "#define GLSLIFY 1\nattribute vec3 a_position;attribute vec3 a_velocity;attribute vec3 a_acceleration;attribute vec4 a_color;attribute vec4 a_lifeAndSize;attribute vec2 a_rotation;attribute vec3 a_uv;attribute vec2 a_normalizedUv;uniform float u_time;uniform bool u_once;uniform mat4 u_MVPMat;varying vec4 v_color;varying float v_lifeLeft;varying vec2 v_uv;\n#ifdef is2d\nuniform mat4 u_viewInvMat;uniform mat4 u_projMat;uniform mat4 u_viewMat;uniform mat4 u_modelMat;\n#endif\nmat2 rotation2d(float angle){float s=sin(angle);float c=cos(angle);return mat2(c,-s,s,c);}void main(){v_color=a_color;v_uv=a_uv.xy;float life=a_lifeAndSize.y;float startTime=a_lifeAndSize.x;float deltaTime=max(mod(u_time-startTime,life),0.0);if((u_once&&u_time>life+startTime)){deltaTime=0.0;}v_lifeLeft=1.0-deltaTime/life;float scale=a_lifeAndSize.z;vec3 position=a_position+(a_velocity+a_acceleration*deltaTime*0.5)*deltaTime;\n#ifdef isScaleByLifetime\nscale*=v_lifeLeft;\n#else\nscale*=pow(a_lifeAndSize.w,deltaTime);\n#endif\n#ifdef rotateToVelocity\nvec3 v=a_velocity+a_acceleration*deltaTime;float angle=atan(v.z,v.x)*2.0;\n#else\nfloat deltaAngle=deltaTime*a_rotation.y;float angle=a_rotation.x+deltaAngle;\n#endif\n#ifdef is2d\nvec2 rotatedPoint=rotation2d(angle)*vec2(a_normalizedUv.x,a_normalizedUv.y*a_uv.z);vec3 basisX=u_viewInvMat[0].xyz;vec3 basisZ=u_viewInvMat[1].xyz;vec3 localPosition=vec3(basisX*rotatedPoint.x+basisZ*rotatedPoint.y)*scale+position;gl_Position=u_projMat*u_viewMat*vec4(localPosition+u_modelMat[3].xyz,1.);\n#else\n#ifdef rotateToVelocity\nfloat s=sin(angle);float c=cos(angle);\n#else\nfloat s=sin(angle);float c=cos(angle);\n#endif\nvec4 rotatedPoint=vec4((a_normalizedUv.x*c+a_normalizedUv.y*a_uv.z*s)*scale,0.,(a_normalizedUv.x*s-a_normalizedUv.y*a_uv.z*c)*scale,1.);vec4 orientation=vec4(0,0,0,1);vec4 q2=orientation+orientation;vec4 qx=orientation.xxxw*q2.xyzx;vec4 qy=orientation.xyyw*q2.xyzy;vec4 qz=orientation.xxzw*q2.xxzz;mat4 localMatrix=mat4((1.0-qy.y)-qz.z,qx.y+qz.w,qx.z-qy.w,0,qx.y-qz.w,(1.0-qx.x)-qz.z,qy.z+qx.w,0,qx.z+qy.w,qy.z-qx.w,(1.0-qx.x)-qy.y,0,position.x,position.y,position.z,1);rotatedPoint=localMatrix*rotatedPoint;gl_Position=u_MVPMat*rotatedPoint;\n#endif\n}"; // eslint-disable-line
15162
- var pbrFs = "#define GLSLIFY 1\n#define IS_METALLIC_WORKFLOW\n#include <common>\n#include <camera_declare>\n#include <RendererFragmentDeclaration>\n#include <FogFragmentDeclaration>\n#include <uv_share>\n#include <normal_share>\n#include <color_share>\n#include <worldpos_share>\n#include <light_frag_define>\n#include <pbr_frag_define>\n#include <pbr_helper>\nvoid main(){\n#include <pbr_frag>\n#include <FogFragment>\n#ifndef OASIS_COLORSPACE_GAMMA\ngl_FragColor=linearToGamma(gl_FragColor);\n#endif\n}"; // eslint-disable-line
15160
+ var pbrFs = "#define GLSLIFY 1\n#define IS_METALLIC_WORKFLOW\n#include <common>\n#include <camera_declare>\n#include <FogFragmentDeclaration>\n#include <uv_share>\n#include <normal_share>\n#include <color_share>\n#include <worldpos_share>\n#include <light_frag_define>\n#include <pbr_frag_define>\n#include <pbr_helper>\nvoid main(){\n#include <pbr_frag>\n#include <FogFragment>\n#ifndef OASIS_COLORSPACE_GAMMA\ngl_FragColor=linearToGamma(gl_FragColor);\n#endif\n}"; // eslint-disable-line
15163
15161
  var pbrSpecularFs = "#define GLSLIFY 1\n#include <common>\n#include <camera_declare>\n#include <FogFragmentDeclaration>\n#include <uv_share>\n#include <normal_share>\n#include <color_share>\n#include <worldpos_share>\n#include <light_frag_define>\n#include <pbr_frag_define>\n#include <pbr_helper>\nvoid main(){\n#include <pbr_frag>\n#include <FogFragment>\n#ifndef OASIS_COLORSPACE_GAMMA\ngl_FragColor=linearToGamma(gl_FragColor);\n#endif\n}"; // eslint-disable-line
15164
15162
  var pbrVs = "#define GLSLIFY 1\n#include <common>\n#include <common_vert>\n#include <blendShape_input>\n#include <uv_share>\n#include <color_share>\n#include <normal_share>\n#include <worldpos_share>\n#include <ShadowVertexDeclaration>\n#include <FogVertexDeclaration>\nvoid main(){\n#include <begin_position_vert>\n#include <begin_normal_vert>\n#include <blendShape_vert>\n#include <skinning_vert>\n#include <uv_vert>\n#include <color_vert>\n#include <normal_vert>\n#include <worldpos_vert>\n#include <position_vert>\n#include <ShadowVertex>\n#include <FogVertex>\n}"; // eslint-disable-line
15165
15163
  var shadowMapFs = "#define GLSLIFY 1\n#ifdef OASIS_NO_DEPTH_TEXTURE\nvec4 pack(float depth){const vec4 bitShift=vec4(1.0,256.0,256.0*256.0,256.0*256.0*256.0);const vec4 bitMask=vec4(1.0/256.0,1.0/256.0,1.0/256.0,0.0);vec4 rgbaDepth=fract(depth*bitShift);rgbaDepth-=rgbaDepth.gbaa*bitMask;return rgbaDepth;}\n#endif\nvoid main(){\n#ifdef OASIS_NO_DEPTH_TEXTURE\ngl_FragColor=pack(gl_FragCoord.z);\n#else\ngl_FragColor=vec4(0.0,0.0,0.0,0.0);\n#endif\n}"; // eslint-disable-line
@@ -25849,6 +25847,8 @@ var MeshParser = /*#__PURE__*/ function(Parser1) {
25849
25847
  var vertexElements = new Array();
25850
25848
  var vertexCount;
25851
25849
  var bufferBindIndex = 0;
25850
+ var positions;
25851
+ keepMeshData && (positions = new Array(vertexCount));
25852
25852
  for(var attribute in attributes){
25853
25853
  var accessor = accessors[attributes[attribute]];
25854
25854
  var accessorBuffer = GLTFUtil.getAccessorBuffer(context, gltf, accessor);
@@ -25890,16 +25890,24 @@ var MeshParser = /*#__PURE__*/ function(Parser1) {
25890
25890
  if (accessor.min && accessor.max) {
25891
25891
  min.copyFromArray(accessor.min);
25892
25892
  max.copyFromArray(accessor.max);
25893
+ if (keepMeshData) {
25894
+ var stride1 = vertices.length / attributeCount;
25895
+ for(var j = 0; j < attributeCount; j++){
25896
+ var offset = j * stride1;
25897
+ positions[j] = new miniprogram$1$2.Vector3(vertices[offset], vertices[offset + 1], vertices[offset + 2]);
25898
+ }
25899
+ }
25893
25900
  } else {
25894
25901
  var position = MeshParser._tempVector3;
25895
25902
  min.set(Number.MAX_VALUE, Number.MAX_VALUE, Number.MAX_VALUE);
25896
25903
  max.set(-Number.MAX_VALUE, -Number.MAX_VALUE, -Number.MAX_VALUE);
25897
- var stride1 = vertices.length / attributeCount;
25898
- for(var j = 0; j < attributeCount; j++){
25899
- var offset = j * stride1;
25900
- position.copyFromArray(vertices, offset);
25904
+ var stride2 = vertices.length / attributeCount;
25905
+ for(var j1 = 0; j1 < attributeCount; j1++){
25906
+ var offset1 = j1 * stride2;
25907
+ position.copyFromArray(vertices, offset1);
25901
25908
  miniprogram$1$2.Vector3.min(min, position, min);
25902
25909
  miniprogram$1$2.Vector3.max(max, position, max);
25910
+ keepMeshData && (positions[j1] = position.clone());
25903
25911
  }
25904
25912
  }
25905
25913
  if (accessor.normalized) {
@@ -25922,6 +25930,8 @@ var MeshParser = /*#__PURE__*/ function(Parser1) {
25922
25930
  // BlendShapes
25923
25931
  targets && this._createBlendShape(mesh, gltfMesh, targets, getBlendShapeData);
25924
25932
  mesh.uploadData(!keepMeshData);
25933
+ //@ts-ignore
25934
+ mesh._positions = positions;
25925
25935
  return Promise.resolve(mesh);
25926
25936
  };
25927
25937
  _proto._createBlendShape = function _createBlendShape(mesh, glTFMesh, glTFTargets, getBlendShapeData) {
@@ -33394,6 +33404,36 @@ function _inherits(subClass, superClass) {
33394
33404
  });
33395
33405
  if (superClass) _setPrototypeOf(subClass, superClass);
33396
33406
  }
33407
+ /**
33408
+ * WebGL platform engine,support includes WebGL1.0 and WebGL2.0.
33409
+ */ var WebGLEngine = /*#__PURE__*/ function(Engine) {
33410
+ var WebGLEngine = function WebGLEngine() {
33411
+ return Engine.apply(this, arguments);
33412
+ };
33413
+ _inherits(WebGLEngine, Engine);
33414
+ /**
33415
+ * Create a WebGL engine.
33416
+ * @param configuration - WebGL engine configuration
33417
+ * @returns A promise that will resolve when the engine is created
33418
+ */ WebGLEngine.create = function create(configuration) {
33419
+ var canvas = configuration.canvas;
33420
+ var webCanvas = new WebCanvas(typeof canvas === "string" ? engineMiniprogramAdapter.document.getElementById(canvas) : canvas);
33421
+ var webGLRenderer = new WebGLGraphicDevice(configuration.graphicDeviceOptions);
33422
+ var engine = new WebGLEngine(webCanvas, webGLRenderer, configuration);
33423
+ return engine._initialize(configuration);
33424
+ };
33425
+ _createClass(WebGLEngine, [
33426
+ {
33427
+ key: "canvas",
33428
+ get: /**
33429
+ * Web canvas.
33430
+ */ function get() {
33431
+ return this._canvas;
33432
+ }
33433
+ }
33434
+ ]);
33435
+ return WebGLEngine;
33436
+ }(miniprogram$1$1.Engine);
33397
33437
  function extends_() {
33398
33438
  extends_ = Object.assign || function(target) {
33399
33439
  for(var i = 1; i < arguments.length; i++){
@@ -33411,6 +33451,83 @@ function extends_() {
33411
33451
  function _extends() {
33412
33452
  return extends_.apply(this, arguments);
33413
33453
  }
33454
+ var GLBuffer = /*#__PURE__*/ function() {
33455
+ var GLBuffer = function GLBuffer(rhi, type, byteLength, bufferUsage, data) {
33456
+ if (bufferUsage === void 0) bufferUsage = miniprogram$1$1.BufferUsage.Static;
33457
+ var gl = rhi.gl;
33458
+ var glBuffer = gl.createBuffer();
33459
+ var glBufferUsage = this._getGLBufferUsage(gl, bufferUsage);
33460
+ var glBindTarget = type === miniprogram$1$1.BufferBindFlag.VertexBuffer ? gl.ARRAY_BUFFER : gl.ELEMENT_ARRAY_BUFFER;
33461
+ this._gl = gl;
33462
+ this._glBuffer = glBuffer;
33463
+ this._glBufferUsage = glBufferUsage;
33464
+ this._glBindTarget = glBindTarget;
33465
+ this._isWebGL2 = rhi.isWebGL2;
33466
+ this.bind();
33467
+ if (data) {
33468
+ gl.bufferData(glBindTarget, data, glBufferUsage);
33469
+ } else {
33470
+ gl.bufferData(glBindTarget, byteLength, glBufferUsage);
33471
+ }
33472
+ gl.bindBuffer(glBindTarget, null);
33473
+ };
33474
+ var _proto = GLBuffer.prototype;
33475
+ _proto.bind = function bind() {
33476
+ this._gl.bindBuffer(this._glBindTarget, this._glBuffer);
33477
+ };
33478
+ _proto.setData = function setData(byteLength, data, bufferByteOffset, dataOffset, dataLength, options) {
33479
+ var gl = this._gl;
33480
+ var glBindTarget = this._glBindTarget;
33481
+ this.bind();
33482
+ if (options === miniprogram$1$1.SetDataOptions.Discard) {
33483
+ gl.bufferData(glBindTarget, byteLength, this._glBufferUsage);
33484
+ }
33485
+ // TypeArray is BYTES_PER_ELEMENT, unTypeArray is 1
33486
+ var byteSize = data.BYTES_PER_ELEMENT || 1;
33487
+ var dataByteLength = dataLength ? byteSize * dataLength : data.byteLength;
33488
+ if (dataOffset !== 0 || dataByteLength < data.byteLength) {
33489
+ var isArrayBufferView = data.byteOffset !== undefined;
33490
+ if (this._isWebGL2 && isArrayBufferView) {
33491
+ gl.bufferSubData(glBindTarget, bufferByteOffset, data, dataOffset, dataByteLength / byteSize);
33492
+ } else {
33493
+ var subData = new Uint8Array(isArrayBufferView ? data.buffer : data, dataOffset * byteSize, dataByteLength);
33494
+ gl.bufferSubData(glBindTarget, bufferByteOffset, subData);
33495
+ }
33496
+ } else {
33497
+ gl.bufferSubData(glBindTarget, bufferByteOffset, data);
33498
+ }
33499
+ gl.bindBuffer(glBindTarget, null);
33500
+ };
33501
+ _proto.getData = function getData(data, bufferByteOffset, dataOffset, dataLength) {
33502
+ if (this._isWebGL2) {
33503
+ var gl = this._gl;
33504
+ this.bind();
33505
+ gl.getBufferSubData(this._glBindTarget, bufferByteOffset, data, dataOffset, dataLength);
33506
+ } else {
33507
+ throw "Buffer is write-only on WebGL1.0 platforms.";
33508
+ }
33509
+ };
33510
+ _proto.resize = function resize(byteLength) {
33511
+ this.bind();
33512
+ this._gl.bufferData(this._glBindTarget, byteLength, this._glBufferUsage);
33513
+ };
33514
+ _proto.destroy = function destroy() {
33515
+ this._gl.deleteBuffer(this._glBuffer);
33516
+ this._gl = null;
33517
+ this._glBuffer = null;
33518
+ };
33519
+ _proto._getGLBufferUsage = function _getGLBufferUsage(gl, bufferUsage) {
33520
+ switch(bufferUsage){
33521
+ case miniprogram$1$1.BufferUsage.Static:
33522
+ return gl.STATIC_DRAW;
33523
+ case miniprogram$1$1.BufferUsage.Dynamic:
33524
+ return gl.DYNAMIC_DRAW;
33525
+ case miniprogram$1$1.BufferUsage.Stream:
33526
+ return gl.STREAM_DRAW;
33527
+ }
33528
+ };
33529
+ return GLBuffer;
33530
+ }();
33414
33531
  /**
33415
33532
  * GL capability.
33416
33533
  */ var GLCapability = /*#__PURE__*/ function() {
@@ -33673,8 +33790,8 @@ function _extends() {
33673
33790
  if (useVao) {
33674
33791
  gl.drawElements(topology, count, _glIndexType, start * _glIndexByteCount);
33675
33792
  } else {
33676
- var _nativeBuffer = _indexBufferBinding.buffer._nativeBuffer;
33677
- gl.bindBuffer(gl.ELEMENT_ARRAY_BUFFER, _nativeBuffer);
33793
+ var _glBuffer = _indexBufferBinding.buffer._platformBuffer._glBuffer;
33794
+ gl.bindBuffer(gl.ELEMENT_ARRAY_BUFFER, _glBuffer);
33678
33795
  gl.drawElements(topology, count, _glIndexType, start * _glIndexByteCount);
33679
33796
  gl.bindBuffer(gl.ELEMENT_ARRAY_BUFFER, null);
33680
33797
  }
@@ -33687,8 +33804,8 @@ function _extends() {
33687
33804
  if (useVao) {
33688
33805
  gl.drawElementsInstanced(topology, count, _glIndexType, start * _glIndexByteCount, _instanceCount);
33689
33806
  } else {
33690
- var _nativeBuffer1 = _indexBufferBinding.buffer._nativeBuffer;
33691
- gl.bindBuffer(gl.ELEMENT_ARRAY_BUFFER, _nativeBuffer1);
33807
+ var _glBuffer1 = _indexBufferBinding.buffer._platformBuffer._glBuffer;
33808
+ gl.bindBuffer(gl.ELEMENT_ARRAY_BUFFER, _glBuffer1);
33692
33809
  gl.drawElementsInstanced(topology, count, _glIndexType, start * _glIndexByteCount, _instanceCount);
33693
33810
  gl.bindBuffer(gl.ELEMENT_ARRAY_BUFFER, null);
33694
33811
  }
@@ -33728,7 +33845,7 @@ function _extends() {
33728
33845
  var element = attributes[name];
33729
33846
  if (element) {
33730
33847
  var _vertexBufferBindings_element_bindingIndex = vertexBufferBindings[element.bindingIndex], buffer = _vertexBufferBindings_element_bindingIndex.buffer, stride = _vertexBufferBindings_element_bindingIndex.stride;
33731
- vbo = buffer._nativeBuffer;
33848
+ vbo = buffer._platformBuffer._glBuffer;
33732
33849
  // prevent binding the vbo which already bound at the last loop, e.g. a buffer with multiple attributes.
33733
33850
  if (lastBoundVbo !== vbo) {
33734
33851
  lastBoundVbo = vbo;
@@ -33760,7 +33877,7 @@ function _extends() {
33760
33877
  // @ts-ignore
33761
33878
  var _indexBufferBinding = this._primitive._indexBufferBinding;
33762
33879
  if (_indexBufferBinding) {
33763
- gl.bindBuffer(gl.ELEMENT_ARRAY_BUFFER, _indexBufferBinding.buffer._nativeBuffer);
33880
+ gl.bindBuffer(gl.ELEMENT_ARRAY_BUFFER, _indexBufferBinding.buffer._platformBuffer._glBuffer);
33764
33881
  }
33765
33882
  this._bindBufferAndAttrib(shaderProgram);
33766
33883
  /** unbind */ gl.bindVertexArray(null);
@@ -34817,20 +34934,19 @@ exports.WebGLMode = void 0;
34817
34934
  WebGLMode[WebGLMode[/** WebGL1.0, */ "WebGL1"] = 2] = "WebGL1";
34818
34935
  })(exports.WebGLMode || (exports.WebGLMode = {}));
34819
34936
  /**
34820
- * WebGL renderer, including WebGL1.0 and WebGL2.0.
34821
- */ var WebGLRenderer = /*#__PURE__*/ function() {
34822
- var WebGLRenderer = function WebGLRenderer(initializeOptions) {
34937
+ * WebGL graphic device, including WebGL1.0 and WebGL2.0.
34938
+ */ var WebGLGraphicDevice = /*#__PURE__*/ function() {
34939
+ var WebGLGraphicDevice = function WebGLGraphicDevice(initializeOptions) {
34823
34940
  if (initializeOptions === void 0) initializeOptions = {};
34941
+ /** @internal */ this._readFrameBuffer = null;
34824
34942
  /** @internal */ this._enableGlobalDepthBias = false;
34825
34943
  this._activeTextures = new Array(32);
34826
- // cache value
34827
34944
  this._lastViewport = new miniprogram$1.Vector4(null, null, null, null);
34828
34945
  this._lastScissor = new miniprogram$1.Vector4(null, null, null, null);
34829
34946
  this._lastClearColor = new miniprogram$1.Color(null, null, null, null);
34830
34947
  this._scissorEnable = false;
34831
34948
  var options = _extends({
34832
34949
  webGLMode: 0,
34833
- alpha: false,
34834
34950
  stencil: true,
34835
34951
  _forceFlush: false
34836
34952
  }, initializeOptions);
@@ -34845,12 +34961,20 @@ exports.WebGLMode = void 0;
34845
34961
  }
34846
34962
  }
34847
34963
  this._options = options;
34964
+ this._onWebGLContextLost = this._onWebGLContextLost.bind(this);
34965
+ this._onWebGLContextRestored = this._onWebGLContextRestored.bind(this);
34848
34966
  };
34849
- var _proto = WebGLRenderer.prototype;
34850
- _proto.init = function init(canvas) {
34967
+ var _proto = WebGLGraphicDevice.prototype;
34968
+ _proto.init = function init(canvas, onDeviceLost, onDeviceRestored) {
34851
34969
  var options = this._options;
34852
- var webCanvas = this._webCanvas = canvas._webCanvas;
34970
+ var webCanvas = canvas._webCanvas;
34853
34971
  var webGLMode = options.webGLMode;
34972
+ this._onDeviceLost = onDeviceLost;
34973
+ this._onDeviceRestored = onDeviceRestored;
34974
+ webCanvas.addEventListener("webglcontextlost", this._onWebGLContextLost, false);
34975
+ webCanvas.addEventListener("webglcontextrestored", this._onWebGLContextRestored, false);
34976
+ webCanvas.addEventListener("webglcontextcreationerror", this._onContextCreationError, false);
34977
+ this._webCanvas = webCanvas;
34854
34978
  var gl;
34855
34979
  if (webGLMode == 0 || webGLMode == 1) {
34856
34980
  gl = webCanvas.getContext("webgl2", options);
@@ -34876,16 +35000,7 @@ exports.WebGLMode = void 0;
34876
35000
  throw new Error("Get GL Context FAILED.");
34877
35001
  }
34878
35002
  this._gl = gl;
34879
- this._activeTextureID = gl.TEXTURE0;
34880
- this._renderStates = new GLRenderStates(gl);
34881
- this._extensions = new GLExtensions(this);
34882
- this._capability = new GLCapability(this);
34883
- // Make sure the active texture in gl context is on default, because gl context may be used in other webgl renderer.
34884
- gl.activeTexture(gl.TEXTURE0);
34885
- var debugRenderInfo = gl.getExtension("WEBGL_debug_renderer_info");
34886
- if (debugRenderInfo != null) {
34887
- this._renderer = gl.getParameter(debugRenderInfo.UNMASKED_RENDERER_WEBGL);
34888
- }
35003
+ this._initGLState(gl);
34889
35004
  };
34890
35005
  _proto.createPlatformPrimitive = function createPlatformPrimitive(primitive) {
34891
35006
  return new GLPrimitive(this, primitive);
@@ -34902,6 +35017,10 @@ exports.WebGLMode = void 0;
34902
35017
  _proto.createPlatformRenderTarget = function createPlatformRenderTarget(target) {
34903
35018
  return new GLRenderTarget(this, target);
34904
35019
  };
35020
+ _proto.createPlatformBuffer = function createPlatformBuffer(type, byteLength, bufferUsage, data) {
35021
+ if (bufferUsage === void 0) bufferUsage = miniprogram$1$1.BufferUsage.Static;
35022
+ return new GLBuffer(this, type, byteLength, bufferUsage, data);
35023
+ };
34905
35024
  _proto.requireExtension = function requireExtension(ext) {
34906
35025
  return this._extensions.requireExtension(ext);
34907
35026
  };
@@ -35029,8 +35148,57 @@ exports.WebGLMode = void 0;
35029
35148
  _proto.flush = function flush() {
35030
35149
  this._gl.flush();
35031
35150
  };
35032
- _proto.destroy = function destroy() {};
35033
- _createClass(WebGLRenderer, [
35151
+ _proto.forceLoseDevice = function forceLoseDevice() {
35152
+ var extension = this.requireExtension(miniprogram$1$1.GLCapabilityType.WEBGL_lose_context);
35153
+ extension.loseContext();
35154
+ };
35155
+ _proto.forceRestoreDevice = function forceRestoreDevice() {
35156
+ var extension = this.requireExtension(miniprogram$1$1.GLCapabilityType.WEBGL_lose_context);
35157
+ extension.restoreContext();
35158
+ };
35159
+ _proto.resetState = function resetState() {
35160
+ this._readFrameBuffer = null;
35161
+ this._enableGlobalDepthBias = false;
35162
+ this._currentBindShaderProgram = null;
35163
+ var activeTextures = this._activeTextures;
35164
+ for(var i = 0, n = activeTextures.length; i < n; i++){
35165
+ activeTextures[i] = null;
35166
+ }
35167
+ this._lastViewport.set(null, null, null, null);
35168
+ this._lastScissor.set(null, null, null, null);
35169
+ this._lastClearColor.set(null, null, null, null);
35170
+ this._scissorEnable = false;
35171
+ this._initGLState(this._gl);
35172
+ };
35173
+ _proto._initGLState = function _initGLState(gl) {
35174
+ this._activeTextureID = gl.TEXTURE0;
35175
+ this._renderStates = new GLRenderStates(gl);
35176
+ this._extensions = new GLExtensions(this);
35177
+ this._capability = new GLCapability(this);
35178
+ // Make sure the active texture in gl context is on default, because gl context may be used in other webgl renderer.
35179
+ gl.activeTexture(gl.TEXTURE0);
35180
+ var debugRenderInfo = gl.getExtension("WEBGL_debug_renderer_info");
35181
+ if (debugRenderInfo != null) {
35182
+ this._renderer = gl.getParameter(debugRenderInfo.UNMASKED_RENDERER_WEBGL);
35183
+ }
35184
+ };
35185
+ _proto.destroy = function destroy() {
35186
+ var webCanvas = this._webCanvas;
35187
+ webCanvas.removeEventListener("webglcontextcreationerror", this._onContextCreationError, false);
35188
+ webCanvas.removeEventListener("webglcontextlost", this._onWebGLContextLost, false);
35189
+ webCanvas.removeEventListener("webglcontextrestored", this._onWebGLContextRestored, false);
35190
+ };
35191
+ _proto._onContextCreationError = function _onContextCreationError(event) {
35192
+ console.error("WebGLRenderer: WebGL context could not be created. Reason: ", event.statusMessage);
35193
+ };
35194
+ _proto._onWebGLContextLost = function _onWebGLContextLost(event) {
35195
+ event.preventDefault();
35196
+ this._onDeviceLost();
35197
+ };
35198
+ _proto._onWebGLContextRestored = function _onWebGLContextRestored(event) {
35199
+ this._onDeviceRestored();
35200
+ };
35201
+ _createClass(WebGLGraphicDevice, [
35034
35202
  {
35035
35203
  key: "isWebGL2",
35036
35204
  get: function get() {
@@ -35071,32 +35239,11 @@ exports.WebGLMode = void 0;
35071
35239
  }
35072
35240
  }
35073
35241
  ]);
35074
- return WebGLRenderer;
35242
+ return WebGLGraphicDevice;
35075
35243
  }();
35076
- /**
35077
- * WebGL platform engine,support includes WebGL1.0 and WebGL2.0.
35078
- */ var WebGLEngine = /*#__PURE__*/ function(Engine) {
35079
- var WebGLEngine = function WebGLEngine(canvas, webGLRendererOptions) {
35080
- var webCanvas = new WebCanvas(typeof canvas === "string" ? engineMiniprogramAdapter.document.getElementById(canvas) : canvas);
35081
- var hardwareRenderer = new WebGLRenderer(webGLRendererOptions);
35082
- return Engine.call(this, webCanvas, hardwareRenderer);
35083
- };
35084
- _inherits(WebGLEngine, Engine);
35085
- _createClass(WebGLEngine, [
35086
- {
35087
- key: "canvas",
35088
- get: /**
35089
- * Web canvas.
35090
- */ function get() {
35091
- return this._canvas;
35092
- }
35093
- }
35094
- ]);
35095
- return WebGLEngine;
35096
- }(miniprogram$1$1.Engine);
35097
35244
  exports.WebCanvas = WebCanvas;
35098
35245
  exports.WebGLEngine = WebGLEngine;
35099
- exports.WebGLRenderer = WebGLRenderer;
35246
+ exports.WebGLGraphicDevice = WebGLGraphicDevice;
35100
35247
 
35101
35248
  var miniprogram$3 = /*#__PURE__*/Object.freeze({
35102
35249
  __proto__: null
@@ -35137,7 +35284,7 @@ function _interopNamespace(e) {
35137
35284
  }
35138
35285
  var CoreObjects__namespace = /*#__PURE__*/ _interopNamespace(CoreObjects);
35139
35286
  //@ts-ignore
35140
- var version = "0.9.0-beta.81";
35287
+ var version = "0.9.0-beta.82";
35141
35288
  console.log("Galacean engine version: " + version);
35142
35289
  for(var key in CoreObjects__namespace){
35143
35290
  CoreObjects.Loader.registerClass(key, CoreObjects__namespace[key]);