@galacean/engine 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 CHANGED
@@ -1,7 +1,7 @@
1
1
  (function (global, factory) {
2
2
  typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports) :
3
3
  typeof define === 'function' && define.amd ? define(['exports'], factory) :
4
- (global = typeof globalThis !== 'undefined' ? globalThis : global || self, factory(global["@galacean/engine"] = {}));
4
+ (global = typeof globalThis !== 'undefined' ? globalThis : global || self, factory(global.Galacean = {}));
5
5
  })(this, (function (exports) { 'use strict';
6
6
 
7
7
  function _instanceof(left, right) {
@@ -6930,6 +6930,21 @@
6930
6930
  });
6931
6931
  return AssetPromise.all(promises);
6932
6932
  };
6933
+ /**
6934
+ * Get the resource from cache by asset url, return the resource object if it loaded, otherwise return null.
6935
+ * @param url - Resource url
6936
+ * @returns Resource object
6937
+ */ _proto.getFromCache = function getFromCache(url) {
6938
+ var _this__assetUrlPool_url;
6939
+ return (_this__assetUrlPool_url = this._assetUrlPool[url]) != null ? _this__assetUrlPool_url : null;
6940
+ };
6941
+ /**
6942
+ * Get asset url from instanceId.
6943
+ * @param instanceId - Engine instance id
6944
+ * @returns Asset url
6945
+ */ _proto.getAssetPath = function getAssetPath(instanceId) {
6946
+ return this._assetPool[instanceId];
6947
+ };
6933
6948
  _proto.cancelNotLoaded = function cancelNotLoaded(url) {
6934
6949
  var _this = this;
6935
6950
  if (!url) {
@@ -6953,13 +6968,6 @@
6953
6968
  this._gc(false);
6954
6969
  };
6955
6970
  /**
6956
- * Get asset url from instanceId.
6957
- * @param instanceId - Engine instance id
6958
- * @returns Asset url
6959
- */ _proto.getAssetPath = function getAssetPath(instanceId) {
6960
- return this._assetPool[instanceId];
6961
- };
6962
- /**
6963
6971
  * @internal
6964
6972
  */ _proto._addAsset = function _addAsset(path, asset) {
6965
6973
  this._assetPool[asset.instanceId] = path;
@@ -12144,7 +12152,6 @@
12144
12152
  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
12145
12153
  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
12146
12154
  var color_share = "#define GLSLIFY 1\n#ifdef O3_HAS_VERTEXCOLOR\nvarying vec4 v_color;\n#endif\n"; // eslint-disable-line
12147
- var RendererFragmentDeclaration = "#define GLSLIFY 1\nuniform highp ivec4 oasis_RendererLayer;"; // eslint-disable-line
12148
12155
  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
12149
12156
  var FogVertexDeclaration = "#define GLSLIFY 1\n#if OASIS_FOG_MODE != 0\nvarying vec3 v_positionVS;\n#endif\n"; // eslint-disable-line
12150
12157
  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
@@ -12162,7 +12169,7 @@
12162
12169
  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
12163
12170
  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
12164
12171
  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
12165
- 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
12172
+ 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
12166
12173
  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
12167
12174
  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
12168
12175
  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
@@ -12219,7 +12226,6 @@
12219
12226
  normal_share: normal_share,
12220
12227
  uv_share: uv_share,
12221
12228
  worldpos_share: worldpos_share,
12222
- RendererFragmentDeclaration: RendererFragmentDeclaration,
12223
12229
  FogVertexDeclaration: FogVertexDeclaration,
12224
12230
  FogFragmentDeclaration: FogFragmentDeclaration,
12225
12231
  begin_normal_vert: begin_normal_vert,
@@ -19831,11 +19837,11 @@
19831
19837
  ]);
19832
19838
  return SceneManager;
19833
19839
  }();
19834
- 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
19840
+ 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
19835
19841
  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
19836
19842
  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
19837
19843
  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
19838
- 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
19844
+ 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
19839
19845
  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
19840
19846
  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
19841
19847
  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
@@ -23498,7 +23504,6 @@
23498
23504
  * @returns Cloned sprite
23499
23505
  */ _proto.clone = function clone() {
23500
23506
  var cloneSprite = new Sprite(this._engine, this._texture, this._region, this._pivot, this._border, this.name);
23501
- cloneSprite._assetID = this._assetID;
23502
23507
  cloneSprite._atlasRotated = this._atlasRotated;
23503
23508
  cloneSprite._atlasRegion.copyFrom(this._atlasRegion);
23504
23509
  cloneSprite._atlasRegionOffset.copyFrom(this._atlasRegionOffset);
@@ -32694,6 +32699,8 @@
32694
32699
  var vertexElements = new Array();
32695
32700
  var vertexCount;
32696
32701
  var bufferBindIndex = 0;
32702
+ var positions;
32703
+ keepMeshData && (positions = new Array(vertexCount));
32697
32704
  for(var attribute in attributes){
32698
32705
  var accessor = accessors[attributes[attribute]];
32699
32706
  var accessorBuffer = GLTFUtil.getAccessorBuffer(context, gltf, accessor);
@@ -32735,16 +32742,24 @@
32735
32742
  if (accessor.min && accessor.max) {
32736
32743
  min.copyFromArray(accessor.min);
32737
32744
  max.copyFromArray(accessor.max);
32745
+ if (keepMeshData) {
32746
+ var stride1 = vertices.length / attributeCount;
32747
+ for(var j = 0; j < attributeCount; j++){
32748
+ var offset = j * stride1;
32749
+ positions[j] = new Vector3(vertices[offset], vertices[offset + 1], vertices[offset + 2]);
32750
+ }
32751
+ }
32738
32752
  } else {
32739
32753
  var position = MeshParser._tempVector3;
32740
32754
  min.set(Number.MAX_VALUE, Number.MAX_VALUE, Number.MAX_VALUE);
32741
32755
  max.set(-Number.MAX_VALUE, -Number.MAX_VALUE, -Number.MAX_VALUE);
32742
- var stride1 = vertices.length / attributeCount;
32743
- for(var j = 0; j < attributeCount; j++){
32744
- var offset = j * stride1;
32745
- position.copyFromArray(vertices, offset);
32756
+ var stride2 = vertices.length / attributeCount;
32757
+ for(var j1 = 0; j1 < attributeCount; j1++){
32758
+ var offset1 = j1 * stride2;
32759
+ position.copyFromArray(vertices, offset1);
32746
32760
  Vector3.min(min, position, min);
32747
32761
  Vector3.max(max, position, max);
32762
+ keepMeshData && (positions[j1] = position.clone());
32748
32763
  }
32749
32764
  }
32750
32765
  if (accessor.normalized) {
@@ -32767,6 +32782,8 @@
32767
32782
  // BlendShapes
32768
32783
  targets && this._createBlendShape(mesh, gltfMesh, targets, getBlendShapeData);
32769
32784
  mesh.uploadData(!keepMeshData);
32785
+ //@ts-ignore
32786
+ mesh._positions = positions;
32770
32787
  return Promise.resolve(mesh);
32771
32788
  };
32772
32789
  _proto._createBlendShape = function _createBlendShape(mesh, glTFMesh, glTFTargets, getBlendShapeData) {
@@ -34953,6 +34970,7 @@
34953
34970
  _this = Loader.apply(this, arguments) || this;
34954
34971
  _this._tempRect = new Rect();
34955
34972
  _this._tempVec2 = new Vector2();
34973
+ _this._tempVec4 = new Vector4();
34956
34974
  return _this;
34957
34975
  };
34958
34976
  _inherits(SpriteAtlasLoader, Loader);
@@ -34971,57 +34989,65 @@
34971
34989
  }));
34972
34990
  chainPromises.push(configPromise);
34973
34991
  configPromise.then(function(atlasData) {
34974
- var atlasItems = atlasData.atlasItems, format = atlasData.format;
34975
- var atlasItemsLen = atlasItems.length;
34976
- var imagePromises = AssetPromise.all(atlasItems.map(function(param) {
34977
- var img = param.img;
34978
- return _this.request(GLTFUtil.parseRelativeUrl(item.url, img), _extends({}, item, {
34979
- type: "image"
34980
- }));
34981
- }));
34982
- chainPromises.push(imagePromises);
34983
- return imagePromises.then(function(imgs) {
34984
- var engine = resourceManager.engine;
34985
- // Generate a SpriteAtlas object.
34986
- var tempRect = _this._tempRect, tempVec2 = _this._tempVec2;
34987
- var spriteAtlas = new SpriteAtlas(engine);
34988
- for(var i = 0; i < atlasItemsLen; i++){
34989
- // Generate Texture2D according to configuration.
34990
- var originalImg = imgs[i];
34991
- var width = originalImg.width, height = originalImg.height;
34992
- var texture = new Texture2D(engine, width, height, format);
34993
- texture.setImageSource(originalImg);
34994
- texture.generateMipmaps();
34995
- // Generate all the sprites on this texture.
34996
- var atlasItem = atlasItems[i];
34997
- var sprites = atlasItem.sprites;
34998
- var sourceWidthReciprocal = 1.0 / width;
34999
- var sourceHeightReciprocal = 1.0 / height;
35000
- for(var j = sprites.length - 1; j >= 0; j--){
35001
- var atlasSprite = sprites[j];
35002
- var region = atlasSprite.region, atlasRegionOffset = atlasSprite.atlasRegionOffset, atlasRegion = atlasSprite.atlasRegion, id = atlasSprite.id, pivot = atlasSprite.pivot;
35003
- var sprite = new 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);
35004
- sprite.atlasRegion.set(atlasRegion.x * sourceWidthReciprocal, atlasRegion.y * sourceHeightReciprocal, atlasRegion.w * sourceWidthReciprocal, atlasRegion.h * sourceHeightReciprocal);
35005
- atlasSprite.atlasRotated && (sprite.atlasRotated = true);
35006
- if (atlasRegionOffset) {
35007
- var offsetLeft = atlasRegionOffset.x, offsetTop = atlasRegionOffset.y, offsetRight = atlasRegionOffset.z, offsetBottom = atlasRegionOffset.w;
35008
- sprite.atlasRegionOffset.set(offsetLeft * sourceWidthReciprocal, offsetTop * sourceHeightReciprocal, offsetRight * sourceWidthReciprocal, offsetBottom * sourceHeightReciprocal);
34992
+ var _loop = function _loop(i) {
34993
+ var atlasItem = atlasItems[i];
34994
+ if (atlasItem.img) {
34995
+ chainPromises.push(resourceManager.load({
34996
+ url: atlasItem.img,
34997
+ type: exports.AssetType.Texture2D,
34998
+ params: {
34999
+ format: format,
35000
+ mipmap: mipmap
35009
35001
  }
35010
- if (id !== undefined) {
35002
+ }).then(function(texture) {
35003
+ anisoLevel && (texture.anisoLevel = anisoLevel);
35004
+ filterMode !== undefined && (texture.filterMode = filterMode);
35005
+ wrapModeU !== undefined && (texture.wrapModeU = wrapModeU);
35006
+ wrapModeV !== undefined && (texture.wrapModeV = wrapModeV);
35007
+ for(var _$i = 0; _$i < atlasItem.sprites.length; _$i++){
35011
35008
  // @ts-ignore
35012
- sprite._assetID = id;
35009
+ spriteAtlas._addSprite(_this._makeSprite(engine, atlasItem.sprites[_$i], texture));
35013
35010
  }
35011
+ }).catch(reject));
35012
+ } else {
35013
+ for(var i1 = 0; i1 < atlasItem.sprites.length; i1++){
35014
35014
  // @ts-ignore
35015
- spriteAtlas._addSprite(sprite);
35015
+ spriteAtlas._addSprite(_this._makeSprite(engine, atlasItem.sprites[i1]));
35016
35016
  }
35017
35017
  }
35018
+ };
35019
+ var atlasItems = atlasData.atlasItems, mipmap = atlasData.mipmap, anisoLevel = atlasData.anisoLevel, filterMode = atlasData.filterMode, wrapModeU = atlasData.wrapModeU, wrapModeV = atlasData.wrapModeV, format = atlasData.format;
35020
+ var atlasItemsLen = atlasItems ? atlasItems.length : 0;
35021
+ var engine = resourceManager.engine;
35022
+ var spriteAtlas = new SpriteAtlas(engine);
35023
+ if (atlasItemsLen < 0) {
35018
35024
  resolve(spriteAtlas);
35019
- });
35020
- }).catch(function(e) {
35021
- reject(e);
35022
- });
35025
+ return;
35026
+ }
35027
+ chainPromises.length = 0;
35028
+ for(var i = 0; i < atlasItems.length; i++)_loop(i);
35029
+ AssetPromise.all(chainPromises).then(function() {
35030
+ resolve(spriteAtlas);
35031
+ }).catch(reject);
35032
+ }).catch(reject);
35023
35033
  });
35024
35034
  };
35035
+ _proto._makeSprite = function _makeSprite(engine, config, texture) {
35036
+ // Generate a SpriteAtlas object.
35037
+ var region = config.region, atlasRegionOffset = config.atlasRegionOffset, atlasRegion = config.atlasRegion, pivot = config.pivot, border = config.border;
35038
+ var sprite = new 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);
35039
+ if (texture) {
35040
+ var invW = 1 / texture.width;
35041
+ var invH = 1 / texture.height;
35042
+ sprite.atlasRegion.set(atlasRegion.x * invW, atlasRegion.y * invH, atlasRegion.w * invW, atlasRegion.h * invH);
35043
+ if (atlasRegionOffset) {
35044
+ var offsetLeft = atlasRegionOffset.x, offsetTop = atlasRegionOffset.y, offsetRight = atlasRegionOffset.z, offsetBottom = atlasRegionOffset.w;
35045
+ sprite.atlasRegionOffset.set(offsetLeft * invW, offsetTop * invH, offsetRight * invW, offsetBottom * invH);
35046
+ }
35047
+ config.atlasRotated && (sprite.atlasRotated = true);
35048
+ }
35049
+ return sprite;
35050
+ };
35025
35051
  return SpriteAtlasLoader;
35026
35052
  }(Loader);
35027
35053
  SpriteAtlasLoader = __decorate([
@@ -35041,13 +35067,19 @@
35041
35067
  _this.request(item.url, _extends({}, item, {
35042
35068
  type: "json"
35043
35069
  })).then(function(data) {
35044
- // @ts-ignore
35045
- resourceManager.getResourceByRef(data.texture).then(function(texture) {
35046
- var sprite = new Sprite(resourceManager.engine, texture);
35047
- sprite.region = data.region;
35048
- sprite.pivot = data.pivot;
35049
- resolve(sprite);
35050
- });
35070
+ if (data.belongToAtlas) {
35071
+ resourceManager // @ts-ignore
35072
+ .getResourceByRef(data.belongToAtlas).then(function(atlas) {
35073
+ resolve(atlas.getSprite(data.fullPath));
35074
+ }).catch(reject);
35075
+ } else if (data.texture) {
35076
+ resourceManager // @ts-ignore
35077
+ .getResourceByRef(data.texture).then(function(texture) {
35078
+ resolve(new Sprite(resourceManager.engine, texture, data.region, data.pivot, data.border));
35079
+ }).catch(reject);
35080
+ } else {
35081
+ resolve(new Sprite(resourceManager.engine, null, data.region, data.pivot, data.border));
35082
+ }
35051
35083
  }).catch(reject);
35052
35084
  });
35053
35085
  };
@@ -35235,7 +35267,7 @@
35235
35267
  }));
35236
35268
 
35237
35269
  //@ts-ignore
35238
- var version = "0.9.0-beta.80";
35270
+ var version = "0.9.0-beta.82";
35239
35271
  console.log("Galacean engine version: " + version);
35240
35272
  for(var key in CoreObjects){
35241
35273
  Loader.registerClass(key, CoreObjects[key]);