@galacean/engine 1.2.0-alpha.11 → 1.2.0-alpha.13

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/.DS_Store ADDED
Binary file
package/dist/browser.js CHANGED
@@ -8123,7 +8123,7 @@
8123
8123
  };
8124
8124
  return _extends$2.apply(this, arguments);
8125
8125
  }
8126
- var camera_declare = "#define GLSLIFY 1\nuniform vec3 camera_Position;uniform vec3 camera_Forward;"; // eslint-disable-line
8126
+ var camera_declare = "#define GLSLIFY 1\nuniform vec3 camera_Position;uniform vec3 camera_Forward;uniform vec4 camera_ProjectionParams;"; // eslint-disable-line
8127
8127
  var common = "#define GLSLIFY 1\n#define PI 3.14159265359\n#define RECIPROCAL_PI 0.31830988618\n#define EPSILON 1e-6\n#define LOG2 1.442695\n#define saturate( a ) clamp( a, 0.0, 1.0 )\nfloat pow2(float x){return x*x;}vec4 RGBMToLinear(vec4 value,float maxRange){return vec4(value.rgb*value.a*maxRange,1.0);}vec4 gammaToLinear(vec4 srgbIn){return vec4(pow(srgbIn.rgb,vec3(2.2)),srgbIn.a);}vec4 linearToGamma(vec4 linearIn){return vec4(pow(linearIn.rgb,vec3(1.0/2.2)),linearIn.a);}uniform vec4 camera_DepthBufferParams;float remapDepthBufferLinear01(float z){return 1.0/(camera_DepthBufferParams.x*z+camera_DepthBufferParams.y);}\n#ifdef GRAPHICS_API_WEBGL2\n#define INVERSE_MAT(mat) inverse(mat)\n#else\nmat2 inverseMat(mat2 m){return mat2(m[1][1],-m[0][1],-m[1][0],m[0][0])/(m[0][0]*m[1][1]-m[0][1]*m[1][0]);}mat3 inverseMat(mat3 m){float a00=m[0][0],a01=m[0][1],a02=m[0][2];float a10=m[1][0],a11=m[1][1],a12=m[1][2];float a20=m[2][0],a21=m[2][1],a22=m[2][2];float b01=a22*a11-a12*a21;float b11=-a22*a10+a12*a20;float b21=a21*a10-a11*a20;float det=a00*b01+a01*b11+a02*b21;return mat3(b01,(-a22*a01+a02*a21),(a12*a01-a02*a11),b11,(a22*a00-a02*a20),(-a12*a00+a02*a10),b21,(-a21*a00+a01*a20),(a11*a00-a01*a10))/det;}mat4 inverseMat(mat4 m){float a00=m[0][0],a01=m[0][1],a02=m[0][2],a03=m[0][3],a10=m[1][0],a11=m[1][1],a12=m[1][2],a13=m[1][3],a20=m[2][0],a21=m[2][1],a22=m[2][2],a23=m[2][3],a30=m[3][0],a31=m[3][1],a32=m[3][2],a33=m[3][3],b00=a00*a11-a01*a10,b01=a00*a12-a02*a10,b02=a00*a13-a03*a10,b03=a01*a12-a02*a11,b04=a01*a13-a03*a11,b05=a02*a13-a03*a12,b06=a20*a31-a21*a30,b07=a20*a32-a22*a30,b08=a20*a33-a23*a30,b09=a21*a32-a22*a31,b10=a21*a33-a23*a31,b11=a22*a33-a23*a32,det=b00*b11-b01*b10+b02*b09+b03*b08-b04*b07+b05*b06;return mat4(a11*b11-a12*b10+a13*b09,a02*b10-a01*b11-a03*b09,a31*b05-a32*b04+a33*b03,a22*b04-a21*b05-a23*b03,a12*b08-a10*b11-a13*b07,a00*b11-a02*b08+a03*b07,a32*b02-a30*b05-a33*b01,a20*b05-a22*b02+a23*b01,a10*b10-a11*b08+a13*b06,a01*b08-a00*b10-a03*b06,a30*b04-a31*b02+a33*b00,a21*b02-a20*b04-a23*b00,a11*b07-a10*b09-a12*b06,a00*b09-a01*b07+a02*b06,a31*b01-a30*b03-a32*b00,a20*b03-a21*b01+a22*b00)/det;}\n#define INVERSE_MAT(mat) inverseMat(mat)\n#endif\n"; // eslint-disable-line
8128
8128
  var common_vert = "#define GLSLIFY 1\nattribute vec3 POSITION;\n#ifdef RENDERER_HAS_UV\nattribute vec2 TEXCOORD_0;\n#endif\n#ifdef RENDERER_HAS_UV1\nattribute vec2 TEXCOORD_1;\n#endif\n#ifdef RENDERER_HAS_SKIN\nattribute vec4 JOINTS_0;attribute vec4 WEIGHTS_0;\n#ifdef RENDERER_USE_JOINT_TEXTURE\nuniform sampler2D renderer_JointSampler;uniform float renderer_JointCount;mat4 getJointMatrix(sampler2D smp,float index){float base=index/renderer_JointCount;float hf=0.5/renderer_JointCount;float v=base+hf;vec4 m0=texture2D(smp,vec2(0.125,v));vec4 m1=texture2D(smp,vec2(0.375,v));vec4 m2=texture2D(smp,vec2(0.625,v));vec4 m3=texture2D(smp,vec2(0.875,v));return mat4(m0,m1,m2,m3);}\n#else\nuniform mat4 renderer_JointMatrix[RENDERER_JOINTS_NUM];\n#endif\n#endif\n#ifdef RENDERER_ENABLE_VERTEXCOLOR\nattribute vec4 COLOR_0;\n#endif\n#include <transform_declare>\n#include <camera_declare>\nuniform vec4 material_TilingOffset;\n#ifndef MATERIAL_OMIT_NORMAL\n#ifdef RENDERER_HAS_NORMAL\nattribute vec3 NORMAL;\n#endif\n#ifdef RENDERER_HAS_TANGENT\nattribute vec4 TANGENT;\n#endif\n#endif\n"; // eslint-disable-line
8129
8129
  var transform_declare = "#define GLSLIFY 1\nuniform mat4 renderer_LocalMat;uniform mat4 renderer_ModelMat;uniform mat4 camera_ViewMat;uniform mat4 camera_ProjMat;uniform mat4 renderer_MVMat;uniform mat4 renderer_MVPMat;uniform mat4 renderer_NormalMat;"; // eslint-disable-line
@@ -8216,7 +8216,7 @@
8216
8216
  horizontal_billboard: horizontal_billboard,
8217
8217
  particle_mesh: particle_mesh
8218
8218
  };
8219
- var normal_get = "#define GLSLIFY 1\nvec3 getNormal(bool isFrontFacing){\n#ifdef RENDERER_HAS_NORMAL\nvec3 normal=normalize(v_normal);\n#elif defined(HAS_DERIVATIVES)\nvec3 pos_dx=dFdx(v_pos);vec3 pos_dy=dFdy(v_pos);vec3 normal=normalize(cross(pos_dx,pos_dy));\n#else\nvec3 normal=vec3(0,0,1);\n#endif\nnormal*=float(isFrontFacing)*2.0-1.0;return normal;}vec3 getNormalByNormalTexture(mat3 tbn,sampler2D normalTexture,float normalIntensity,vec2 uv,bool isFrontFacing){vec3 normal=texture2D(normalTexture,uv).rgb;normal=normalize(tbn*((2.0*normal-1.0)*vec3(normalIntensity,normalIntensity,1.0)));normal*=float(isFrontFacing)*2.0-1.0;return normal;}mat3 getTBN(bool isFrontFacing){\n#if defined(RENDERER_HAS_NORMAL) && defined(RENDERER_HAS_TANGENT) && ( defined(MATERIAL_HAS_NORMALTEXTURE) || defined(MATERIAL_HAS_CLEAR_COAT_NORMAL_TEXTURE) || defined(MATERIAL_ENABLE_ANISOTROPY) )\nmat3 tbn=v_TBN;\n#else\nvec3 normal=getNormal(isFrontFacing);vec3 position=v_pos;vec2 uv=isFrontFacing? v_uv:-v_uv;\n#ifdef HAS_DERIVATIVES\nvec3 dp1=dFdx(position);vec3 dp2=dFdy(position);vec2 duv1=dFdx(uv);vec2 duv2=dFdy(uv);vec3 dp2perp=cross(dp2,normal);vec3 dp1perp=cross(normal,dp1);vec3 tangent=dp2perp*duv1.x+dp1perp*duv2.x;vec3 bitangent=dp2perp*duv1.y+dp1perp*duv2.y;float invmax=inversesqrt(max(dot(tangent,tangent),dot(bitangent,bitangent)));mat3 tbn=mat3(tangent*invmax,bitangent*invmax,normal);\n#else\nmat3 tbn=mat3(vec3(0.0),vec3(0.0),normal);\n#endif\n#endif\nreturn tbn;}"; // eslint-disable-line
8219
+ var normal_get = "#define GLSLIFY 1\nvec3 getNormal(bool isFrontFacing){\n#ifdef RENDERER_HAS_NORMAL\nvec3 normal=normalize(v_normal);\n#elif defined(HAS_DERIVATIVES)\nvec3 pos_dx=dFdx(v_pos);vec3 pos_dy=dFdy(v_pos);vec3 normal=normalize(cross(pos_dx,pos_dy));normal*=camera_ProjectionParams.x;\n#else\nvec3 normal=vec3(0,0,1);\n#endif\nnormal*=float(isFrontFacing)*2.0-1.0;return normal;}vec3 getNormalByNormalTexture(mat3 tbn,sampler2D normalTexture,float normalIntensity,vec2 uv,bool isFrontFacing){vec3 normal=texture2D(normalTexture,uv).rgb;normal=normalize(tbn*((2.0*normal-1.0)*vec3(normalIntensity,normalIntensity,1.0)));normal*=float(isFrontFacing)*2.0-1.0;return normal;}mat3 getTBN(bool isFrontFacing){\n#if defined(RENDERER_HAS_NORMAL) && defined(RENDERER_HAS_TANGENT) && ( defined(MATERIAL_HAS_NORMALTEXTURE) || defined(MATERIAL_HAS_CLEAR_COAT_NORMAL_TEXTURE) || defined(MATERIAL_ENABLE_ANISOTROPY) )\nmat3 tbn=v_TBN;\n#else\nvec3 normal=getNormal(isFrontFacing);vec3 position=v_pos;vec2 uv=isFrontFacing? v_uv:-v_uv;\n#ifdef HAS_DERIVATIVES\nvec3 dp1=dFdx(position);vec3 dp2=dFdy(position);vec2 duv1=dFdx(uv);vec2 duv2=dFdy(uv);vec3 dp2perp=cross(dp2,normal);vec3 dp1perp=cross(normal,dp1);vec3 tangent=dp2perp*duv1.x+dp1perp*duv2.x;vec3 bitangent=dp2perp*duv1.y+dp1perp*duv2.y;float denom=max(dot(tangent,tangent),dot(bitangent,bitangent));float invmax=(denom==0.0)? 0.0 : camera_ProjectionParams.x/sqrt(denom);mat3 tbn=mat3(tangent*invmax,bitangent*invmax,normal);\n#else\nmat3 tbn=mat3(vec3(0.0),vec3(0.0),normal);\n#endif\n#endif\nreturn tbn;}"; // eslint-disable-line
8220
8220
  var ShaderLib = _extends$2({
8221
8221
  common: common,
8222
8222
  common_vert: common_vert,
@@ -9685,10 +9685,11 @@
9685
9685
  renderStateDataMap && this._applyShaderDataValue(renderStateDataMap, shaderData);
9686
9686
  var hardwareRenderer = engine._hardwareRenderer;
9687
9687
  var lastRenderState = engine._lastRenderState;
9688
+ var context = engine._renderContext;
9688
9689
  this.blendState._apply(hardwareRenderer, lastRenderState);
9689
9690
  this.depthState._apply(hardwareRenderer, lastRenderState);
9690
9691
  this.stencilState._apply(hardwareRenderer, lastRenderState);
9691
- this.rasterState._apply(hardwareRenderer, lastRenderState, frontFaceInvert);
9692
+ this.rasterState._apply(hardwareRenderer, lastRenderState, context.flipProjection ? !frontFaceInvert : frontFaceInvert);
9692
9693
  };
9693
9694
  return RenderState;
9694
9695
  }();
@@ -10684,22 +10685,26 @@
10684
10685
  * @internal
10685
10686
  */ _proto._updateTransformShaderData = function _updateTransformShaderData(context, worldMatrix) {
10686
10687
  var shaderData = this.shaderData;
10687
- var virtualCamera = context.virtualCamera;
10688
10688
  var mvMatrix = this._mvMatrix;
10689
- var mvpMatrix = this._mvpMatrix;
10690
10689
  var mvInvMatrix = this._mvInvMatrix;
10691
10690
  var normalMatrix = this._normalMatrix;
10692
- Matrix.multiply(virtualCamera.viewMatrix, worldMatrix, mvMatrix);
10693
- Matrix.multiply(virtualCamera.viewProjectionMatrix, worldMatrix, mvpMatrix);
10691
+ Matrix.multiply(context.viewMatrix, worldMatrix, mvMatrix);
10694
10692
  Matrix.invert(mvMatrix, mvInvMatrix);
10695
10693
  Matrix.invert(worldMatrix, normalMatrix);
10696
10694
  normalMatrix.transpose();
10697
10695
  shaderData.setMatrix(exports.Renderer._localMatrixProperty, this.entity.transform.localMatrix);
10698
10696
  shaderData.setMatrix(exports.Renderer._worldMatrixProperty, worldMatrix);
10699
10697
  shaderData.setMatrix(exports.Renderer._mvMatrixProperty, mvMatrix);
10700
- shaderData.setMatrix(exports.Renderer._mvpMatrixProperty, mvpMatrix);
10701
10698
  shaderData.setMatrix(exports.Renderer._mvInvMatrixProperty, mvInvMatrix);
10702
10699
  shaderData.setMatrix(exports.Renderer._normalMatrixProperty, normalMatrix);
10700
+ this._updateMVPShaderData(context, worldMatrix);
10701
+ };
10702
+ /**
10703
+ * @internal
10704
+ */ _proto._updateMVPShaderData = function _updateMVPShaderData(context, worldMatrix) {
10705
+ var mvpMatrix = this._mvpMatrix;
10706
+ Matrix.multiply(context.viewProjectionMatrix, worldMatrix, mvpMatrix);
10707
+ this.shaderData.setMatrix(exports.Renderer._mvpMatrixProperty, mvpMatrix);
10703
10708
  };
10704
10709
  /**
10705
10710
  * @internal
@@ -19304,14 +19309,31 @@
19304
19309
  * @internal
19305
19310
  * Rendering context.
19306
19311
  */ var RenderContext = /*#__PURE__*/ function() {
19307
- var RenderContext = function RenderContext() {};
19312
+ var RenderContext = function RenderContext() {
19313
+ this._projectionParams = new Vector4();
19314
+ this.flipProjection = false;
19315
+ };
19308
19316
  var _proto = RenderContext.prototype;
19309
- _proto.applyVirtualCamera = function applyVirtualCamera(virtualCamera) {
19317
+ _proto.applyVirtualCamera = function applyVirtualCamera(virtualCamera, flipProjection) {
19310
19318
  this.virtualCamera = virtualCamera;
19319
+ this.flipProjection = flipProjection;
19311
19320
  var shaderData = this.camera.shaderData;
19312
- shaderData.setMatrix(RenderContext._viewMatrixProperty, virtualCamera.viewMatrix);
19313
- shaderData.setMatrix(RenderContext._projectionMatrixProperty, virtualCamera.projectionMatrix);
19314
- shaderData.setMatrix(RenderContext.vpMatrixProperty, virtualCamera.viewProjectionMatrix);
19321
+ var viewMatrix = virtualCamera.viewMatrix, projectionMatrix = virtualCamera.projectionMatrix, viewProjectionMatrix = virtualCamera.viewProjectionMatrix;
19322
+ if (flipProjection) {
19323
+ Matrix.multiply(RenderContext._flipYMatrix, projectionMatrix, RenderContext._flipYProjectionMatrix);
19324
+ Matrix.multiply(RenderContext._flipYProjectionMatrix, viewMatrix, RenderContext._flipYViewProjectionMatrix);
19325
+ projectionMatrix = RenderContext._flipYProjectionMatrix;
19326
+ viewProjectionMatrix = RenderContext._flipYViewProjectionMatrix;
19327
+ }
19328
+ this.viewMatrix = viewMatrix;
19329
+ this.projectionMatrix = projectionMatrix;
19330
+ this.viewProjectionMatrix = viewProjectionMatrix;
19331
+ shaderData.setMatrix(RenderContext._viewMatrixProperty, viewMatrix);
19332
+ shaderData.setMatrix(RenderContext._projectionMatrixProperty, projectionMatrix);
19333
+ shaderData.setMatrix(RenderContext.vpMatrixProperty, viewProjectionMatrix);
19334
+ var projectionParams = this._projectionParams;
19335
+ projectionParams.set(flipProjection ? -1 : 1, virtualCamera.nearClipPlane, virtualCamera.farClipPlane, 0);
19336
+ shaderData.setVector4(RenderContext._cameraProjectionProperty, projectionParams);
19315
19337
  };
19316
19338
  return RenderContext;
19317
19339
  }();
@@ -19321,12 +19343,24 @@
19321
19343
  (function() {
19322
19344
  RenderContext.pipelineStageKey = ShaderTagKey.getByName("pipelineStage");
19323
19345
  })();
19346
+ (function() {
19347
+ /** @internal */ RenderContext._flipYMatrix = new Matrix(1, 0, 0, 0, 0, -1);
19348
+ })();
19349
+ (function() {
19350
+ RenderContext._cameraProjectionProperty = ShaderProperty.getByName("camera_ProjectionParams");
19351
+ })();
19324
19352
  (function() {
19325
19353
  RenderContext._viewMatrixProperty = ShaderProperty.getByName("camera_ViewMat");
19326
19354
  })();
19327
19355
  (function() {
19328
19356
  RenderContext._projectionMatrixProperty = ShaderProperty.getByName("camera_ProjMat");
19329
19357
  })();
19358
+ (function() {
19359
+ RenderContext._flipYProjectionMatrix = new Matrix();
19360
+ })();
19361
+ (function() {
19362
+ RenderContext._flipYViewProjectionMatrix = new Matrix();
19363
+ })();
19330
19364
  var RenderData = /*#__PURE__*/ function() {
19331
19365
  var RenderData = function RenderData() {};
19332
19366
  var _proto = RenderData.prototype;
@@ -24438,6 +24472,9 @@
24438
24472
  // view-proj matrix
24439
24473
  Matrix.multiply(projectionMatrix, viewProjMatrix, viewProjMatrix);
24440
24474
  var originViewProjMatrix = cameraShaderData.getMatrix(RenderContext.vpMatrixProperty);
24475
+ if (context.flipProjection) {
24476
+ Matrix.multiply(RenderContext._flipYMatrix, viewProjMatrix, viewProjMatrix);
24477
+ }
24441
24478
  cameraShaderData.setMatrix(RenderContext.vpMatrixProperty, viewProjMatrix);
24442
24479
  var compileMacros = Shader._compileMacros;
24443
24480
  ShaderMacroCollection.unionCollection(context.camera._globalShaderMacro, materialShaderData._macroCollection, compileMacros);
@@ -26743,6 +26780,8 @@
26743
26780
  this.viewMatrix = new Matrix();
26744
26781
  this.projectionMatrix = new Matrix();
26745
26782
  this.viewProjectionMatrix = new Matrix();
26783
+ this.nearClipPlane = 0.1;
26784
+ this.farClipPlane = 100;
26746
26785
  /** Only orth mode use. */ this.forward = new Vector3();
26747
26786
  };
26748
26787
  /**
@@ -27025,7 +27064,7 @@
27025
27064
  })();
27026
27065
  (function() {
27027
27066
  // prettier-ignore
27028
- /** @internal */ ShadowUtils._shadowMapCoordMatrix = new Matrix(0.5, 0.0, 0.0, 0.0, 0.0, 0.5, 0.0, 0.0, 0.0, 0.0, 0.5, 0.0, 0.5, 0.5, 0.5, 1.0);
27067
+ /** @internal */ ShadowUtils._shadowMapCoordMatrix = new Matrix(0.5, 0.0, 0.0, 0.0, 0.0, -0.5, 0.0, 0.0, 0.0, 0.0, 0.5, 0.0, 0.5, 0.5, 0.5, 1.0);
27029
27068
  })();
27030
27069
  (function() {
27031
27070
  ShadowUtils._frustumCorners = [
@@ -27376,6 +27415,7 @@
27376
27415
  rhi.viewport(x, y, shadowTileResolution, shadowTileResolution);
27377
27416
  // for no cascade is for the edge,for cascade is for the beyond maxCascade pixel can use (0,0,0) trick sample the shadowMap
27378
27417
  rhi.scissor(x + 1, y + 1, shadowTileResolution - 2, shadowTileResolution - 2);
27418
+ // @todo: It is more appropriate to prevent duplication based on `virtualCamera` at `RenderQueue#render`.
27379
27419
  engine._renderCount++;
27380
27420
  opaqueQueue.render(camera, exports.Layer.Everything, exports.PipelineStage.ShadowCaster);
27381
27421
  alphaTestQueue.render(camera, exports.Layer.Everything, exports.PipelineStage.ShadowCaster);
@@ -27486,7 +27526,7 @@
27486
27526
  var sceneShaderData = this._camera.scene.shaderData;
27487
27527
  sceneShaderData.setVector2(CascadedShadowCasterPass._lightShadowBiasProperty, this._shadowBias);
27488
27528
  sceneShaderData.setVector3(CascadedShadowCasterPass._lightDirectionProperty, light.direction);
27489
- context.applyVirtualCamera(virtualCamera);
27529
+ context.applyVirtualCamera(virtualCamera, true);
27490
27530
  };
27491
27531
  return CascadedShadowCasterPass;
27492
27532
  }(PipelinePass);
@@ -27672,19 +27712,25 @@
27672
27712
  var scene = camera.scene;
27673
27713
  var cullingResults = this._cullingResults;
27674
27714
  var sunlight = scene._lightManager._sunlight;
27715
+ var depthOnlyPass = this._depthOnlyPass;
27716
+ var depthPassEnabled = camera.depthTextureMode === exports.DepthTextureMode.PrePass && depthOnlyPass._supportDepthTexture;
27717
+ var rt2DEnabled = camera.renderTarget && cubeFace == undefined;
27675
27718
  camera.engine._spriteMaskManager.clear();
27676
27719
  if (scene.castShadows && sunlight && sunlight.shadowType !== exports.ShadowType.None) {
27677
27720
  this._cascadedShadowCaster.onRender(context);
27678
27721
  }
27679
27722
  cullingResults.reset();
27680
27723
  this._allSpriteMasks.length = 0;
27681
- context.applyVirtualCamera(camera._virtualCamera);
27682
- this._callRender(context);
27724
+ context.applyVirtualCamera(camera._virtualCamera, depthPassEnabled || rt2DEnabled);
27725
+ this._prepareRender(context);
27683
27726
  cullingResults.sort();
27684
- var depthOnlyPass = this._depthOnlyPass;
27685
- if (camera.depthTextureMode === exports.DepthTextureMode.PrePass && depthOnlyPass._supportDepthTexture) {
27727
+ if (depthPassEnabled) {
27686
27728
  depthOnlyPass.onConfig(camera);
27687
27729
  depthOnlyPass.onRender(context, cullingResults);
27730
+ if (!rt2DEnabled) {
27731
+ context.applyVirtualCamera(camera._virtualCamera, false);
27732
+ this._updateMVPShaderData(context);
27733
+ }
27688
27734
  } else {
27689
27735
  camera.shaderData.setTexture(exports.Camera._cameraDepthTextureProperty, camera.engine._whiteTexture2D);
27690
27736
  }
@@ -27801,9 +27847,9 @@
27801
27847
  (pass._renderState || material.renderState)._apply(engine, false, pass._renderStateDataMap, material.shaderData);
27802
27848
  rhi.drawPrimitive(mesh._primitive, mesh.subMesh, program);
27803
27849
  };
27804
- _proto._callRender = function _callRender(context) {
27805
- var engine = context.camera.engine;
27850
+ _proto._prepareRender = function _prepareRender(context) {
27806
27851
  var camera = context.camera;
27852
+ var engine = camera.engine;
27807
27853
  var renderers = camera.scene._componentsManager._renderers;
27808
27854
  var elements = renderers._elements;
27809
27855
  for(var i = renderers.length - 1; i >= 0; --i){
@@ -27822,6 +27868,15 @@
27822
27868
  renderer._prepareRender(context);
27823
27869
  }
27824
27870
  };
27871
+ _proto._updateMVPShaderData = function _updateMVPShaderData(context) {
27872
+ var camera = context.camera;
27873
+ var renderers = camera.scene._componentsManager._renderers;
27874
+ var elements = renderers._elements;
27875
+ for(var i = renderers.length - 1; i >= 0; --i){
27876
+ var renderer = elements[i];
27877
+ renderer._updateMVPShaderData(context, renderer.entity.transform.worldMatrix);
27878
+ }
27879
+ };
27825
27880
  _create_class$2(BasicRenderPipeline, [
27826
27881
  {
27827
27882
  key: "defaultRenderPass",
@@ -27889,8 +27944,6 @@
27889
27944
  _this._shaderData = new ShaderData(ShaderDataGroup.Camera);
27890
27945
  _this._isCustomViewMatrix = false;
27891
27946
  _this._isCustomProjectionMatrix = false;
27892
- _this._nearClipPlane = 0.1;
27893
- _this._farClipPlane = 100;
27894
27947
  _this._fieldOfView = 45;
27895
27948
  _this._orthographicSize = 10;
27896
27949
  _this._isProjectionDirty = true;
@@ -28115,9 +28168,6 @@
28115
28168
  //@ts-ignore
28116
28169
  this._viewport._onValueChanged = null;
28117
28170
  this.engine.canvas._sizeUpdateFlagManager.removeListener(this._onPixelViewportChanged);
28118
- //@ts-ignore
28119
- this._viewport._onValueChanged = null;
28120
- this.engine.canvas._sizeUpdateFlagManager.removeListener(this._onPixelViewportChanged);
28121
28171
  this._entity = null;
28122
28172
  this._globalShaderMacro = null;
28123
28173
  this._frustum = null;
@@ -28173,7 +28223,7 @@
28173
28223
  shaderData.setVector3(exports.Camera._cameraForwardProperty, transform.worldForward);
28174
28224
  shaderData.setVector3(exports.Camera._cameraUpProperty, transform.worldUp);
28175
28225
  var depthBufferParams = this._depthBufferParams;
28176
- var farDivideNear = this._farClipPlane / this._nearClipPlane;
28226
+ var farDivideNear = this.farClipPlane / this.nearClipPlane;
28177
28227
  depthBufferParams.set(1.0 - farDivideNear, farDivideNear, 0, 0);
28178
28228
  shaderData.setVector4(exports.Camera._cameraDepthBufferParamsProperty, depthBufferParams);
28179
28229
  };
@@ -28214,10 +28264,10 @@
28214
28264
  get: /**
28215
28265
  * Near clip plane - the closest point to the camera when rendering occurs.
28216
28266
  */ function get() {
28217
- return this._nearClipPlane;
28267
+ return this._virtualCamera.nearClipPlane;
28218
28268
  },
28219
28269
  set: function set(value) {
28220
- this._nearClipPlane = value;
28270
+ this._virtualCamera.nearClipPlane = value;
28221
28271
  this._projectionMatrixChange();
28222
28272
  }
28223
28273
  },
@@ -28226,10 +28276,10 @@
28226
28276
  get: /**
28227
28277
  * Far clip plane - the furthest point to the camera when rendering occurs.
28228
28278
  */ function get() {
28229
- return this._farClipPlane;
28279
+ return this._virtualCamera.farClipPlane;
28230
28280
  },
28231
28281
  set: function set(value) {
28232
- this._farClipPlane = value;
28282
+ this._virtualCamera.farClipPlane = value;
28233
28283
  this._projectionMatrixChange();
28234
28284
  }
28235
28285
  },
@@ -28365,11 +28415,11 @@
28365
28415
  this._isProjectionDirty = false;
28366
28416
  var aspectRatio = this.aspectRatio;
28367
28417
  if (!virtualCamera.isOrthographic) {
28368
- Matrix.perspective(MathUtil.degreeToRadian(this._fieldOfView), aspectRatio, this._nearClipPlane, this._farClipPlane, projectionMatrix);
28418
+ Matrix.perspective(MathUtil.degreeToRadian(this._fieldOfView), aspectRatio, this.nearClipPlane, this.farClipPlane, projectionMatrix);
28369
28419
  } else {
28370
28420
  var width = this._orthographicSize * aspectRatio;
28371
28421
  var height = this._orthographicSize;
28372
- Matrix.ortho(-width, width, -height, height, this._nearClipPlane, this._farClipPlane, projectionMatrix);
28422
+ Matrix.ortho(-width, width, -height, height, this.nearClipPlane, this.farClipPlane, projectionMatrix);
28373
28423
  }
28374
28424
  return projectionMatrix;
28375
28425
  },
@@ -35969,6 +36019,7 @@
35969
36019
  Shader: Shader,
35970
36020
  ShaderData: ShaderData,
35971
36021
  ShaderFactory: ShaderFactory,
36022
+ ShaderLib: ShaderLib,
35972
36023
  ShaderMacro: ShaderMacro,
35973
36024
  ShaderMacroCollection: ShaderMacroCollection,
35974
36025
  ShaderPass: ShaderPass,
@@ -40233,7 +40284,9 @@
40233
40284
  };
40234
40285
  GLTFUtils.getAccessorBuffer = function getAccessorBuffer(context, bufferViews, accessor) {
40235
40286
  var componentType = accessor.componentType;
40236
- var bufferView = bufferViews[accessor.bufferView];
40287
+ var _accessor_bufferView;
40288
+ var bufferViewIndex = (_accessor_bufferView = accessor.bufferView) != null ? _accessor_bufferView : 0;
40289
+ var bufferView = bufferViews[bufferViewIndex];
40237
40290
  return context.get(exports.GLTFParserType.BufferView, accessor.bufferView).then(function(bufferViewData) {
40238
40291
  var bufferIndex = bufferView.buffer;
40239
40292
  var _bufferViewData_byteOffset;
@@ -40250,7 +40303,7 @@
40250
40303
  // According to the glTF official documentation only byteStride not undefined is allowed
40251
40304
  if (bufferStride !== undefined && bufferStride !== elementStride) {
40252
40305
  var bufferSlice = Math.floor(byteOffset / bufferStride);
40253
- var bufferCacheKey = accessor.bufferView + ":" + componentType + ":" + bufferSlice + ":" + accessorCount;
40306
+ var bufferCacheKey = bufferViewIndex + ":" + componentType + ":" + bufferSlice + ":" + accessorCount;
40254
40307
  var accessorBufferCache = context.accessorBufferCache;
40255
40308
  bufferInfo = accessorBufferCache[bufferCacheKey];
40256
40309
  if (!bufferInfo) {
@@ -40291,7 +40344,8 @@
40291
40344
  * Get accessor data.
40292
40345
  */ GLTFUtils.getAccessorData = function getAccessorData(glTF, accessor, buffers) {
40293
40346
  var bufferViews = glTF.bufferViews;
40294
- var bufferView = bufferViews[accessor.bufferView];
40347
+ var _accessor_bufferView;
40348
+ var bufferView = bufferViews[(_accessor_bufferView = accessor.bufferView) != null ? _accessor_bufferView : 0];
40295
40349
  var arrayBuffer = buffers[bufferView.buffer];
40296
40350
  var accessorByteOffset = accessor.hasOwnProperty("byteOffset") ? accessor.byteOffset : 0;
40297
40351
  var bufferViewByteOffset = bufferView.hasOwnProperty("byteOffset") ? bufferView.byteOffset : 0;
@@ -41985,13 +42039,13 @@
41985
42039
  break;
41986
42040
  }
41987
42041
  input[input.length - 1];
41988
- sampleDataCollection.push({
42042
+ sampleDataCollection[j] = {
41989
42043
  type: outputAccessor.type,
41990
42044
  interpolation: samplerInterpolation,
41991
42045
  input: input,
41992
42046
  output: output,
41993
42047
  outputSize: outputStride
41994
- });
42048
+ };
41995
42049
  });
41996
42050
  promises.push(promise);
41997
42051
  };
@@ -41999,11 +42053,12 @@
41999
42053
  var glTF = context.glTF;
42000
42054
  var accessors = glTF.accessors, bufferViews = glTF.bufferViews;
42001
42055
  var channels = animationInfo.channels, samplers = animationInfo.samplers;
42002
- var sampleDataCollection = new Array();
42056
+ var len = samplers.length;
42057
+ var sampleDataCollection = new Array(len);
42003
42058
  var entities = context.get(exports.GLTFParserType.Entity);
42004
42059
  var promises = new Array();
42005
42060
  // parse samplers
42006
- for(var j = 0, m = samplers.length; j < m; j++)_loop(j);
42061
+ for(var j = 0, m = len; j < m; j++)_loop(j);
42007
42062
  promises.push(context.get(exports.GLTFParserType.Scene));
42008
42063
  return Promise.all(promises).then(function() {
42009
42064
  for(var j = 0, m = channels.length; j < m; j++){
@@ -44760,7 +44815,7 @@
44760
44815
  ], KHR_materials_anisotropy);
44761
44816
 
44762
44817
  //@ts-ignore
44763
- var version = "1.2.0-alpha.11";
44818
+ var version = "1.2.0-alpha.13";
44764
44819
  console.log("Galacean engine version: " + version);
44765
44820
  for(var key in CoreObjects){
44766
44821
  Loader.registerClass(key, CoreObjects[key]);
@@ -44890,6 +44945,7 @@
44890
44945
  exports.Shader = Shader;
44891
44946
  exports.ShaderData = ShaderData;
44892
44947
  exports.ShaderFactory = ShaderFactory;
44948
+ exports.ShaderLib = ShaderLib;
44893
44949
  exports.ShaderMacro = ShaderMacro;
44894
44950
  exports.ShaderMacroCollection = ShaderMacroCollection;
44895
44951
  exports.ShaderPass = ShaderPass;