@galacean/engine-physics-lite 0.9.0-beta.80 → 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.
- package/dist/browser.js +1 -1
- package/dist/browser.min.js +1 -1
- package/dist/main.js.map +1 -1
- package/dist/miniprogram.js +285 -116
- package/dist/module.js.map +1 -1
- package/package.json +10 -4
package/dist/miniprogram.js
CHANGED
|
@@ -2246,6 +2246,21 @@ var /** @internal */ PromiseState;
|
|
|
2246
2246
|
});
|
|
2247
2247
|
return AssetPromise.all(promises);
|
|
2248
2248
|
};
|
|
2249
|
+
/**
|
|
2250
|
+
* Get the resource from cache by asset url, return the resource object if it loaded, otherwise return null.
|
|
2251
|
+
* @param url - Resource url
|
|
2252
|
+
* @returns Resource object
|
|
2253
|
+
*/ _proto.getFromCache = function getFromCache(url) {
|
|
2254
|
+
var _this__assetUrlPool_url;
|
|
2255
|
+
return (_this__assetUrlPool_url = this._assetUrlPool[url]) != null ? _this__assetUrlPool_url : null;
|
|
2256
|
+
};
|
|
2257
|
+
/**
|
|
2258
|
+
* Get asset url from instanceId.
|
|
2259
|
+
* @param instanceId - Engine instance id
|
|
2260
|
+
* @returns Asset url
|
|
2261
|
+
*/ _proto.getAssetPath = function getAssetPath(instanceId) {
|
|
2262
|
+
return this._assetPool[instanceId];
|
|
2263
|
+
};
|
|
2249
2264
|
_proto.cancelNotLoaded = function cancelNotLoaded(url) {
|
|
2250
2265
|
var _this = this;
|
|
2251
2266
|
if (!url) {
|
|
@@ -2269,13 +2284,6 @@ var /** @internal */ PromiseState;
|
|
|
2269
2284
|
this._gc(false);
|
|
2270
2285
|
};
|
|
2271
2286
|
/**
|
|
2272
|
-
* Get asset url from instanceId.
|
|
2273
|
-
* @param instanceId - Engine instance id
|
|
2274
|
-
* @returns Asset url
|
|
2275
|
-
*/ _proto.getAssetPath = function getAssetPath(instanceId) {
|
|
2276
|
-
return this._assetPool[instanceId];
|
|
2277
|
-
};
|
|
2278
|
-
/**
|
|
2279
2287
|
* @internal
|
|
2280
2288
|
*/ _proto._addAsset = function _addAsset(path, asset) {
|
|
2281
2289
|
this._assetPool[asset.instanceId] = path;
|
|
@@ -7460,7 +7468,6 @@ var common = "#define GLSLIFY 1\n#define PI 3.14159265359\n#define RECIPROCAL_PI
|
|
|
7460
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
|
|
7461
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
|
|
7462
7470
|
var color_share = "#define GLSLIFY 1\n#ifdef O3_HAS_VERTEXCOLOR\nvarying vec4 v_color;\n#endif\n"; // eslint-disable-line
|
|
7463
|
-
var RendererFragmentDeclaration = "#define GLSLIFY 1\nuniform highp ivec4 oasis_RendererLayer;"; // eslint-disable-line
|
|
7464
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
|
|
7465
7472
|
var FogVertexDeclaration = "#define GLSLIFY 1\n#if OASIS_FOG_MODE != 0\nvarying vec3 v_positionVS;\n#endif\n"; // eslint-disable-line
|
|
7466
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
|
|
@@ -7478,7 +7485,7 @@ var skinning_vert = "#define GLSLIFY 1\n#ifdef O3_HAS_SKIN\n#ifdef O3_USE_JOINT_
|
|
|
7478
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
|
|
7479
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
|
|
7480
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
|
|
7481
|
-
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
|
|
7482
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
|
|
7483
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
|
|
7484
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
|
|
@@ -7535,7 +7542,6 @@ var ShaderLib = _extends$2({
|
|
|
7535
7542
|
normal_share: normal_share,
|
|
7536
7543
|
uv_share: uv_share,
|
|
7537
7544
|
worldpos_share: worldpos_share,
|
|
7538
|
-
RendererFragmentDeclaration: RendererFragmentDeclaration,
|
|
7539
7545
|
FogVertexDeclaration: FogVertexDeclaration,
|
|
7540
7546
|
FogFragmentDeclaration: FogFragmentDeclaration,
|
|
7541
7547
|
begin_normal_vert: begin_normal_vert,
|
|
@@ -15147,11 +15153,11 @@ Scene._fogParamsProperty = Shader.getPropertyByName("oasis_FogParams");
|
|
|
15147
15153
|
]);
|
|
15148
15154
|
return SceneManager;
|
|
15149
15155
|
}();
|
|
15150
|
-
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 <
|
|
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
|
|
15151
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
|
|
15152
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
|
|
15153
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
|
|
15154
|
-
var pbrFs = "#define GLSLIFY 1\n#define IS_METALLIC_WORKFLOW\n#include <common>\n#include <camera_declare>\n#include <
|
|
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
|
|
15155
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
|
|
15156
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
|
|
15157
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
|
|
@@ -18814,7 +18820,6 @@ exports.TextVerticalAlignment = void 0;
|
|
|
18814
18820
|
* @returns Cloned sprite
|
|
18815
18821
|
*/ _proto.clone = function clone() {
|
|
18816
18822
|
var cloneSprite = new Sprite(this._engine, this._texture, this._region, this._pivot, this._border, this.name);
|
|
18817
|
-
cloneSprite._assetID = this._assetID;
|
|
18818
18823
|
cloneSprite._atlasRotated = this._atlasRotated;
|
|
18819
18824
|
cloneSprite._atlasRegion.copyFrom(this._atlasRegion);
|
|
18820
18825
|
cloneSprite._atlasRegionOffset.copyFrom(this._atlasRegionOffset);
|
|
@@ -25842,6 +25847,8 @@ var MeshParser = /*#__PURE__*/ function(Parser1) {
|
|
|
25842
25847
|
var vertexElements = new Array();
|
|
25843
25848
|
var vertexCount;
|
|
25844
25849
|
var bufferBindIndex = 0;
|
|
25850
|
+
var positions;
|
|
25851
|
+
keepMeshData && (positions = new Array(vertexCount));
|
|
25845
25852
|
for(var attribute in attributes){
|
|
25846
25853
|
var accessor = accessors[attributes[attribute]];
|
|
25847
25854
|
var accessorBuffer = GLTFUtil.getAccessorBuffer(context, gltf, accessor);
|
|
@@ -25883,16 +25890,24 @@ var MeshParser = /*#__PURE__*/ function(Parser1) {
|
|
|
25883
25890
|
if (accessor.min && accessor.max) {
|
|
25884
25891
|
min.copyFromArray(accessor.min);
|
|
25885
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
|
+
}
|
|
25886
25900
|
} else {
|
|
25887
25901
|
var position = MeshParser._tempVector3;
|
|
25888
25902
|
min.set(Number.MAX_VALUE, Number.MAX_VALUE, Number.MAX_VALUE);
|
|
25889
25903
|
max.set(-Number.MAX_VALUE, -Number.MAX_VALUE, -Number.MAX_VALUE);
|
|
25890
|
-
var
|
|
25891
|
-
for(var
|
|
25892
|
-
var
|
|
25893
|
-
position.copyFromArray(vertices,
|
|
25904
|
+
var stride2 = vertices.length / attributeCount;
|
|
25905
|
+
for(var j1 = 0; j1 < attributeCount; j1++){
|
|
25906
|
+
var offset1 = j1 * stride2;
|
|
25907
|
+
position.copyFromArray(vertices, offset1);
|
|
25894
25908
|
miniprogram$1$2.Vector3.min(min, position, min);
|
|
25895
25909
|
miniprogram$1$2.Vector3.max(max, position, max);
|
|
25910
|
+
keepMeshData && (positions[j1] = position.clone());
|
|
25896
25911
|
}
|
|
25897
25912
|
}
|
|
25898
25913
|
if (accessor.normalized) {
|
|
@@ -25915,6 +25930,8 @@ var MeshParser = /*#__PURE__*/ function(Parser1) {
|
|
|
25915
25930
|
// BlendShapes
|
|
25916
25931
|
targets && this._createBlendShape(mesh, gltfMesh, targets, getBlendShapeData);
|
|
25917
25932
|
mesh.uploadData(!keepMeshData);
|
|
25933
|
+
//@ts-ignore
|
|
25934
|
+
mesh._positions = positions;
|
|
25918
25935
|
return Promise.resolve(mesh);
|
|
25919
25936
|
};
|
|
25920
25937
|
_proto._createBlendShape = function _createBlendShape(mesh, glTFMesh, glTFTargets, getBlendShapeData) {
|
|
@@ -28101,6 +28118,7 @@ var SpriteAtlasLoader = /*#__PURE__*/ function(Loader) {
|
|
|
28101
28118
|
_this = Loader.apply(this, arguments) || this;
|
|
28102
28119
|
_this._tempRect = new miniprogram$1$2.Rect();
|
|
28103
28120
|
_this._tempVec2 = new miniprogram$1$2.Vector2();
|
|
28121
|
+
_this._tempVec4 = new miniprogram$1$2.Vector4();
|
|
28104
28122
|
return _this;
|
|
28105
28123
|
};
|
|
28106
28124
|
_inherits$1(SpriteAtlasLoader, Loader);
|
|
@@ -28119,57 +28137,65 @@ var SpriteAtlasLoader = /*#__PURE__*/ function(Loader) {
|
|
|
28119
28137
|
}));
|
|
28120
28138
|
chainPromises.push(configPromise);
|
|
28121
28139
|
configPromise.then(function(atlasData) {
|
|
28122
|
-
var
|
|
28123
|
-
|
|
28124
|
-
|
|
28125
|
-
|
|
28126
|
-
|
|
28127
|
-
|
|
28128
|
-
|
|
28129
|
-
|
|
28130
|
-
|
|
28131
|
-
return imagePromises.then(function(imgs) {
|
|
28132
|
-
var engine = resourceManager.engine;
|
|
28133
|
-
// Generate a SpriteAtlas object.
|
|
28134
|
-
var tempRect = _this._tempRect, tempVec2 = _this._tempVec2;
|
|
28135
|
-
var spriteAtlas = new miniprogram$5.SpriteAtlas(engine);
|
|
28136
|
-
for(var i = 0; i < atlasItemsLen; i++){
|
|
28137
|
-
// Generate Texture2D according to configuration.
|
|
28138
|
-
var originalImg = imgs[i];
|
|
28139
|
-
var width = originalImg.width, height = originalImg.height;
|
|
28140
|
-
var texture = new miniprogram$5.Texture2D(engine, width, height, format);
|
|
28141
|
-
texture.setImageSource(originalImg);
|
|
28142
|
-
texture.generateMipmaps();
|
|
28143
|
-
// Generate all the sprites on this texture.
|
|
28144
|
-
var atlasItem = atlasItems[i];
|
|
28145
|
-
var sprites = atlasItem.sprites;
|
|
28146
|
-
var sourceWidthReciprocal = 1.0 / width;
|
|
28147
|
-
var sourceHeightReciprocal = 1.0 / height;
|
|
28148
|
-
for(var j = sprites.length - 1; j >= 0; j--){
|
|
28149
|
-
var atlasSprite = sprites[j];
|
|
28150
|
-
var region = atlasSprite.region, atlasRegionOffset = atlasSprite.atlasRegionOffset, atlasRegion = atlasSprite.atlasRegion, id = atlasSprite.id, pivot = atlasSprite.pivot;
|
|
28151
|
-
var sprite = new miniprogram$5.Sprite(engine, texture, region ? tempRect.set(region.x, region.y, region.w, region.h) : undefined, pivot ? tempVec2.set(pivot.x, pivot.y) : undefined, undefined, atlasSprite.name);
|
|
28152
|
-
sprite.atlasRegion.set(atlasRegion.x * sourceWidthReciprocal, atlasRegion.y * sourceHeightReciprocal, atlasRegion.w * sourceWidthReciprocal, atlasRegion.h * sourceHeightReciprocal);
|
|
28153
|
-
atlasSprite.atlasRotated && (sprite.atlasRotated = true);
|
|
28154
|
-
if (atlasRegionOffset) {
|
|
28155
|
-
var offsetLeft = atlasRegionOffset.x, offsetTop = atlasRegionOffset.y, offsetRight = atlasRegionOffset.z, offsetBottom = atlasRegionOffset.w;
|
|
28156
|
-
sprite.atlasRegionOffset.set(offsetLeft * sourceWidthReciprocal, offsetTop * sourceHeightReciprocal, offsetRight * sourceWidthReciprocal, offsetBottom * sourceHeightReciprocal);
|
|
28140
|
+
var _loop = function _loop(i) {
|
|
28141
|
+
var atlasItem = atlasItems[i];
|
|
28142
|
+
if (atlasItem.img) {
|
|
28143
|
+
chainPromises.push(resourceManager.load({
|
|
28144
|
+
url: atlasItem.img,
|
|
28145
|
+
type: miniprogram$5.AssetType.Texture2D,
|
|
28146
|
+
params: {
|
|
28147
|
+
format: format,
|
|
28148
|
+
mipmap: mipmap
|
|
28157
28149
|
}
|
|
28158
|
-
|
|
28150
|
+
}).then(function(texture) {
|
|
28151
|
+
anisoLevel && (texture.anisoLevel = anisoLevel);
|
|
28152
|
+
filterMode !== undefined && (texture.filterMode = filterMode);
|
|
28153
|
+
wrapModeU !== undefined && (texture.wrapModeU = wrapModeU);
|
|
28154
|
+
wrapModeV !== undefined && (texture.wrapModeV = wrapModeV);
|
|
28155
|
+
for(var _$i = 0; _$i < atlasItem.sprites.length; _$i++){
|
|
28159
28156
|
// @ts-ignore
|
|
28160
|
-
|
|
28157
|
+
spriteAtlas._addSprite(_this._makeSprite(engine, atlasItem.sprites[_$i], texture));
|
|
28161
28158
|
}
|
|
28159
|
+
}).catch(reject));
|
|
28160
|
+
} else {
|
|
28161
|
+
for(var i1 = 0; i1 < atlasItem.sprites.length; i1++){
|
|
28162
28162
|
// @ts-ignore
|
|
28163
|
-
spriteAtlas._addSprite(
|
|
28163
|
+
spriteAtlas._addSprite(_this._makeSprite(engine, atlasItem.sprites[i1]));
|
|
28164
28164
|
}
|
|
28165
28165
|
}
|
|
28166
|
+
};
|
|
28167
|
+
var atlasItems = atlasData.atlasItems, mipmap = atlasData.mipmap, anisoLevel = atlasData.anisoLevel, filterMode = atlasData.filterMode, wrapModeU = atlasData.wrapModeU, wrapModeV = atlasData.wrapModeV, format = atlasData.format;
|
|
28168
|
+
var atlasItemsLen = atlasItems ? atlasItems.length : 0;
|
|
28169
|
+
var engine = resourceManager.engine;
|
|
28170
|
+
var spriteAtlas = new miniprogram$5.SpriteAtlas(engine);
|
|
28171
|
+
if (atlasItemsLen < 0) {
|
|
28166
28172
|
resolve(spriteAtlas);
|
|
28167
|
-
|
|
28168
|
-
|
|
28169
|
-
|
|
28170
|
-
|
|
28173
|
+
return;
|
|
28174
|
+
}
|
|
28175
|
+
chainPromises.length = 0;
|
|
28176
|
+
for(var i = 0; i < atlasItems.length; i++)_loop(i);
|
|
28177
|
+
miniprogram$5.AssetPromise.all(chainPromises).then(function() {
|
|
28178
|
+
resolve(spriteAtlas);
|
|
28179
|
+
}).catch(reject);
|
|
28180
|
+
}).catch(reject);
|
|
28171
28181
|
});
|
|
28172
28182
|
};
|
|
28183
|
+
_proto._makeSprite = function _makeSprite(engine, config, texture) {
|
|
28184
|
+
// Generate a SpriteAtlas object.
|
|
28185
|
+
var region = config.region, atlasRegionOffset = config.atlasRegionOffset, atlasRegion = config.atlasRegion, pivot = config.pivot, border = config.border;
|
|
28186
|
+
var sprite = new miniprogram$5.Sprite(engine, texture, region ? this._tempRect.set(region.x, region.y, region.w, region.h) : undefined, pivot ? this._tempVec2.set(pivot.x, pivot.y) : undefined, border ? this._tempVec4.set(border.x, border.y, border.z, border.w) : undefined, config.name);
|
|
28187
|
+
if (texture) {
|
|
28188
|
+
var invW = 1 / texture.width;
|
|
28189
|
+
var invH = 1 / texture.height;
|
|
28190
|
+
sprite.atlasRegion.set(atlasRegion.x * invW, atlasRegion.y * invH, atlasRegion.w * invW, atlasRegion.h * invH);
|
|
28191
|
+
if (atlasRegionOffset) {
|
|
28192
|
+
var offsetLeft = atlasRegionOffset.x, offsetTop = atlasRegionOffset.y, offsetRight = atlasRegionOffset.z, offsetBottom = atlasRegionOffset.w;
|
|
28193
|
+
sprite.atlasRegionOffset.set(offsetLeft * invW, offsetTop * invH, offsetRight * invW, offsetBottom * invH);
|
|
28194
|
+
}
|
|
28195
|
+
config.atlasRotated && (sprite.atlasRotated = true);
|
|
28196
|
+
}
|
|
28197
|
+
return sprite;
|
|
28198
|
+
};
|
|
28173
28199
|
return SpriteAtlasLoader;
|
|
28174
28200
|
}(miniprogram$5.Loader);
|
|
28175
28201
|
SpriteAtlasLoader = __decorate([
|
|
@@ -28189,13 +28215,19 @@ var SpriteLoader = /*#__PURE__*/ function(Loader) {
|
|
|
28189
28215
|
_this.request(item.url, _extends$1({}, item, {
|
|
28190
28216
|
type: "json"
|
|
28191
28217
|
})).then(function(data) {
|
|
28192
|
-
|
|
28193
|
-
|
|
28194
|
-
|
|
28195
|
-
|
|
28196
|
-
|
|
28197
|
-
|
|
28198
|
-
|
|
28218
|
+
if (data.belongToAtlas) {
|
|
28219
|
+
resourceManager // @ts-ignore
|
|
28220
|
+
.getResourceByRef(data.belongToAtlas).then(function(atlas) {
|
|
28221
|
+
resolve(atlas.getSprite(data.fullPath));
|
|
28222
|
+
}).catch(reject);
|
|
28223
|
+
} else if (data.texture) {
|
|
28224
|
+
resourceManager // @ts-ignore
|
|
28225
|
+
.getResourceByRef(data.texture).then(function(texture) {
|
|
28226
|
+
resolve(new miniprogram$5.Sprite(resourceManager.engine, texture, data.region, data.pivot, data.border));
|
|
28227
|
+
}).catch(reject);
|
|
28228
|
+
} else {
|
|
28229
|
+
resolve(new miniprogram$5.Sprite(resourceManager.engine, null, data.region, data.pivot, data.border));
|
|
28230
|
+
}
|
|
28199
28231
|
}).catch(reject);
|
|
28200
28232
|
});
|
|
28201
28233
|
};
|
|
@@ -33372,6 +33404,36 @@ function _inherits(subClass, superClass) {
|
|
|
33372
33404
|
});
|
|
33373
33405
|
if (superClass) _setPrototypeOf(subClass, superClass);
|
|
33374
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);
|
|
33375
33437
|
function extends_() {
|
|
33376
33438
|
extends_ = Object.assign || function(target) {
|
|
33377
33439
|
for(var i = 1; i < arguments.length; i++){
|
|
@@ -33389,6 +33451,83 @@ function extends_() {
|
|
|
33389
33451
|
function _extends() {
|
|
33390
33452
|
return extends_.apply(this, arguments);
|
|
33391
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
|
+
}();
|
|
33392
33531
|
/**
|
|
33393
33532
|
* GL capability.
|
|
33394
33533
|
*/ var GLCapability = /*#__PURE__*/ function() {
|
|
@@ -33651,8 +33790,8 @@ function _extends() {
|
|
|
33651
33790
|
if (useVao) {
|
|
33652
33791
|
gl.drawElements(topology, count, _glIndexType, start * _glIndexByteCount);
|
|
33653
33792
|
} else {
|
|
33654
|
-
var
|
|
33655
|
-
gl.bindBuffer(gl.ELEMENT_ARRAY_BUFFER,
|
|
33793
|
+
var _glBuffer = _indexBufferBinding.buffer._platformBuffer._glBuffer;
|
|
33794
|
+
gl.bindBuffer(gl.ELEMENT_ARRAY_BUFFER, _glBuffer);
|
|
33656
33795
|
gl.drawElements(topology, count, _glIndexType, start * _glIndexByteCount);
|
|
33657
33796
|
gl.bindBuffer(gl.ELEMENT_ARRAY_BUFFER, null);
|
|
33658
33797
|
}
|
|
@@ -33665,8 +33804,8 @@ function _extends() {
|
|
|
33665
33804
|
if (useVao) {
|
|
33666
33805
|
gl.drawElementsInstanced(topology, count, _glIndexType, start * _glIndexByteCount, _instanceCount);
|
|
33667
33806
|
} else {
|
|
33668
|
-
var
|
|
33669
|
-
gl.bindBuffer(gl.ELEMENT_ARRAY_BUFFER,
|
|
33807
|
+
var _glBuffer1 = _indexBufferBinding.buffer._platformBuffer._glBuffer;
|
|
33808
|
+
gl.bindBuffer(gl.ELEMENT_ARRAY_BUFFER, _glBuffer1);
|
|
33670
33809
|
gl.drawElementsInstanced(topology, count, _glIndexType, start * _glIndexByteCount, _instanceCount);
|
|
33671
33810
|
gl.bindBuffer(gl.ELEMENT_ARRAY_BUFFER, null);
|
|
33672
33811
|
}
|
|
@@ -33706,7 +33845,7 @@ function _extends() {
|
|
|
33706
33845
|
var element = attributes[name];
|
|
33707
33846
|
if (element) {
|
|
33708
33847
|
var _vertexBufferBindings_element_bindingIndex = vertexBufferBindings[element.bindingIndex], buffer = _vertexBufferBindings_element_bindingIndex.buffer, stride = _vertexBufferBindings_element_bindingIndex.stride;
|
|
33709
|
-
vbo = buffer.
|
|
33848
|
+
vbo = buffer._platformBuffer._glBuffer;
|
|
33710
33849
|
// prevent binding the vbo which already bound at the last loop, e.g. a buffer with multiple attributes.
|
|
33711
33850
|
if (lastBoundVbo !== vbo) {
|
|
33712
33851
|
lastBoundVbo = vbo;
|
|
@@ -33738,7 +33877,7 @@ function _extends() {
|
|
|
33738
33877
|
// @ts-ignore
|
|
33739
33878
|
var _indexBufferBinding = this._primitive._indexBufferBinding;
|
|
33740
33879
|
if (_indexBufferBinding) {
|
|
33741
|
-
gl.bindBuffer(gl.ELEMENT_ARRAY_BUFFER, _indexBufferBinding.buffer.
|
|
33880
|
+
gl.bindBuffer(gl.ELEMENT_ARRAY_BUFFER, _indexBufferBinding.buffer._platformBuffer._glBuffer);
|
|
33742
33881
|
}
|
|
33743
33882
|
this._bindBufferAndAttrib(shaderProgram);
|
|
33744
33883
|
/** unbind */ gl.bindVertexArray(null);
|
|
@@ -34795,20 +34934,19 @@ exports.WebGLMode = void 0;
|
|
|
34795
34934
|
WebGLMode[WebGLMode[/** WebGL1.0, */ "WebGL1"] = 2] = "WebGL1";
|
|
34796
34935
|
})(exports.WebGLMode || (exports.WebGLMode = {}));
|
|
34797
34936
|
/**
|
|
34798
|
-
* WebGL
|
|
34799
|
-
*/ var
|
|
34800
|
-
var
|
|
34937
|
+
* WebGL graphic device, including WebGL1.0 and WebGL2.0.
|
|
34938
|
+
*/ var WebGLGraphicDevice = /*#__PURE__*/ function() {
|
|
34939
|
+
var WebGLGraphicDevice = function WebGLGraphicDevice(initializeOptions) {
|
|
34801
34940
|
if (initializeOptions === void 0) initializeOptions = {};
|
|
34941
|
+
/** @internal */ this._readFrameBuffer = null;
|
|
34802
34942
|
/** @internal */ this._enableGlobalDepthBias = false;
|
|
34803
34943
|
this._activeTextures = new Array(32);
|
|
34804
|
-
// cache value
|
|
34805
34944
|
this._lastViewport = new miniprogram$1.Vector4(null, null, null, null);
|
|
34806
34945
|
this._lastScissor = new miniprogram$1.Vector4(null, null, null, null);
|
|
34807
34946
|
this._lastClearColor = new miniprogram$1.Color(null, null, null, null);
|
|
34808
34947
|
this._scissorEnable = false;
|
|
34809
34948
|
var options = _extends({
|
|
34810
34949
|
webGLMode: 0,
|
|
34811
|
-
alpha: false,
|
|
34812
34950
|
stencil: true,
|
|
34813
34951
|
_forceFlush: false
|
|
34814
34952
|
}, initializeOptions);
|
|
@@ -34823,12 +34961,20 @@ exports.WebGLMode = void 0;
|
|
|
34823
34961
|
}
|
|
34824
34962
|
}
|
|
34825
34963
|
this._options = options;
|
|
34964
|
+
this._onWebGLContextLost = this._onWebGLContextLost.bind(this);
|
|
34965
|
+
this._onWebGLContextRestored = this._onWebGLContextRestored.bind(this);
|
|
34826
34966
|
};
|
|
34827
|
-
var _proto =
|
|
34828
|
-
_proto.init = function init(canvas) {
|
|
34967
|
+
var _proto = WebGLGraphicDevice.prototype;
|
|
34968
|
+
_proto.init = function init(canvas, onDeviceLost, onDeviceRestored) {
|
|
34829
34969
|
var options = this._options;
|
|
34830
|
-
var webCanvas =
|
|
34970
|
+
var webCanvas = canvas._webCanvas;
|
|
34831
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;
|
|
34832
34978
|
var gl;
|
|
34833
34979
|
if (webGLMode == 0 || webGLMode == 1) {
|
|
34834
34980
|
gl = webCanvas.getContext("webgl2", options);
|
|
@@ -34854,16 +35000,7 @@ exports.WebGLMode = void 0;
|
|
|
34854
35000
|
throw new Error("Get GL Context FAILED.");
|
|
34855
35001
|
}
|
|
34856
35002
|
this._gl = gl;
|
|
34857
|
-
this.
|
|
34858
|
-
this._renderStates = new GLRenderStates(gl);
|
|
34859
|
-
this._extensions = new GLExtensions(this);
|
|
34860
|
-
this._capability = new GLCapability(this);
|
|
34861
|
-
// Make sure the active texture in gl context is on default, because gl context may be used in other webgl renderer.
|
|
34862
|
-
gl.activeTexture(gl.TEXTURE0);
|
|
34863
|
-
var debugRenderInfo = gl.getExtension("WEBGL_debug_renderer_info");
|
|
34864
|
-
if (debugRenderInfo != null) {
|
|
34865
|
-
this._renderer = gl.getParameter(debugRenderInfo.UNMASKED_RENDERER_WEBGL);
|
|
34866
|
-
}
|
|
35003
|
+
this._initGLState(gl);
|
|
34867
35004
|
};
|
|
34868
35005
|
_proto.createPlatformPrimitive = function createPlatformPrimitive(primitive) {
|
|
34869
35006
|
return new GLPrimitive(this, primitive);
|
|
@@ -34880,6 +35017,10 @@ exports.WebGLMode = void 0;
|
|
|
34880
35017
|
_proto.createPlatformRenderTarget = function createPlatformRenderTarget(target) {
|
|
34881
35018
|
return new GLRenderTarget(this, target);
|
|
34882
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
|
+
};
|
|
34883
35024
|
_proto.requireExtension = function requireExtension(ext) {
|
|
34884
35025
|
return this._extensions.requireExtension(ext);
|
|
34885
35026
|
};
|
|
@@ -35007,8 +35148,57 @@ exports.WebGLMode = void 0;
|
|
|
35007
35148
|
_proto.flush = function flush() {
|
|
35008
35149
|
this._gl.flush();
|
|
35009
35150
|
};
|
|
35010
|
-
_proto.
|
|
35011
|
-
|
|
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, [
|
|
35012
35202
|
{
|
|
35013
35203
|
key: "isWebGL2",
|
|
35014
35204
|
get: function get() {
|
|
@@ -35049,32 +35239,11 @@ exports.WebGLMode = void 0;
|
|
|
35049
35239
|
}
|
|
35050
35240
|
}
|
|
35051
35241
|
]);
|
|
35052
|
-
return
|
|
35242
|
+
return WebGLGraphicDevice;
|
|
35053
35243
|
}();
|
|
35054
|
-
/**
|
|
35055
|
-
* WebGL platform engine,support includes WebGL1.0 and WebGL2.0.
|
|
35056
|
-
*/ var WebGLEngine = /*#__PURE__*/ function(Engine) {
|
|
35057
|
-
var WebGLEngine = function WebGLEngine(canvas, webGLRendererOptions) {
|
|
35058
|
-
var webCanvas = new WebCanvas(typeof canvas === "string" ? engineMiniprogramAdapter.document.getElementById(canvas) : canvas);
|
|
35059
|
-
var hardwareRenderer = new WebGLRenderer(webGLRendererOptions);
|
|
35060
|
-
return Engine.call(this, webCanvas, hardwareRenderer);
|
|
35061
|
-
};
|
|
35062
|
-
_inherits(WebGLEngine, Engine);
|
|
35063
|
-
_createClass(WebGLEngine, [
|
|
35064
|
-
{
|
|
35065
|
-
key: "canvas",
|
|
35066
|
-
get: /**
|
|
35067
|
-
* Web canvas.
|
|
35068
|
-
*/ function get() {
|
|
35069
|
-
return this._canvas;
|
|
35070
|
-
}
|
|
35071
|
-
}
|
|
35072
|
-
]);
|
|
35073
|
-
return WebGLEngine;
|
|
35074
|
-
}(miniprogram$1$1.Engine);
|
|
35075
35244
|
exports.WebCanvas = WebCanvas;
|
|
35076
35245
|
exports.WebGLEngine = WebGLEngine;
|
|
35077
|
-
exports.
|
|
35246
|
+
exports.WebGLGraphicDevice = WebGLGraphicDevice;
|
|
35078
35247
|
|
|
35079
35248
|
var miniprogram$3 = /*#__PURE__*/Object.freeze({
|
|
35080
35249
|
__proto__: null
|
|
@@ -35115,7 +35284,7 @@ function _interopNamespace(e) {
|
|
|
35115
35284
|
}
|
|
35116
35285
|
var CoreObjects__namespace = /*#__PURE__*/ _interopNamespace(CoreObjects);
|
|
35117
35286
|
//@ts-ignore
|
|
35118
|
-
var version = "0.9.0-beta.
|
|
35287
|
+
var version = "0.9.0-beta.82";
|
|
35119
35288
|
console.log("Galacean engine version: " + version);
|
|
35120
35289
|
for(var key in CoreObjects__namespace){
|
|
35121
35290
|
CoreObjects.Loader.registerClass(key, CoreObjects__namespace[key]);
|