@galacean/engine 0.9.1 → 0.9.3

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
@@ -17507,6 +17507,7 @@
17507
17507
  var MeshRenderer = function MeshRenderer(entity) {
17508
17508
  var _this;
17509
17509
  _this = Renderer.call(this, entity) || this;
17510
+ _this._enableVertexColor = false;
17510
17511
  _this._onMeshChanged = _this._onMeshChanged.bind(_assert_this_initialized(_this));
17511
17512
  return _this;
17512
17513
  };
@@ -17569,7 +17570,7 @@
17569
17570
  shaderData.enableMacro(MeshRenderer._tangentMacro);
17570
17571
  break;
17571
17572
  case "COLOR_0":
17572
- shaderData.enableMacro(MeshRenderer._vertexColorMacro);
17573
+ this.enableVertexColor && shaderData.enableMacro(MeshRenderer._vertexColorMacro);
17573
17574
  break;
17574
17575
  }
17575
17576
  }
@@ -17624,6 +17625,20 @@
17624
17625
  this._setMesh(value);
17625
17626
  }
17626
17627
  }
17628
+ },
17629
+ {
17630
+ key: "enableVertexColor",
17631
+ get: /**
17632
+ * Whether enable vertex color.
17633
+ */ function get() {
17634
+ return this._enableVertexColor;
17635
+ },
17636
+ set: function set(value) {
17637
+ if (value !== this._enableVertexColor) {
17638
+ this._dirtyUpdateFlag |= 0x2;
17639
+ this._enableVertexColor = value;
17640
+ }
17641
+ }
17627
17642
  }
17628
17643
  ]);
17629
17644
  return MeshRenderer;
@@ -17730,6 +17745,7 @@
17730
17745
  var SkinnedMeshRenderer = function SkinnedMeshRenderer(entity) {
17731
17746
  var _this;
17732
17747
  _this = MeshRenderer.call(this, entity) || this;
17748
+ _this._supportSkinning = false;
17733
17749
  _this._hasInitSkin = false;
17734
17750
  _this._jointDataCreateCache = new Vector2(-1, -1);
17735
17751
  _this._localBounds = new BoundingBox();
@@ -17739,7 +17755,7 @@
17739
17755
  // Limit size to 256 to avoid some problem:
17740
17756
  // For renderer is "Apple GPU", when uniform is large than 256 the skeleton matrix array access in shader very slow in Safari or WKWebview. This may be a apple bug, Chrome and Firefox is OK!
17741
17757
  // For renderer is "ANGLE (AMD, AMD Radeon(TM) Graphics Direct3011 vs_5_0 ps_5_0, D3011)", compile shader si very slow because of max uniform is 4096.
17742
- maxVertexUniformVectors = Math.min(maxVertexUniformVectors, 256);
17758
+ maxVertexUniformVectors = Math.min(maxVertexUniformVectors, rhi._options._maxAllowSkinUniformVectorCount);
17743
17759
  _this._maxVertexUniformVectors = maxVertexUniformVectors;
17744
17760
  _this._onLocalBoundsChanged = _this._onLocalBoundsChanged.bind(_assert_this_initialized(_this));
17745
17761
  var localBounds = _this._localBounds;
@@ -17758,9 +17774,8 @@
17758
17774
  this._initSkin();
17759
17775
  this._hasInitSkin = true;
17760
17776
  }
17761
- var skin = this._skin;
17762
- if (skin) {
17763
- var ibms = skin.inverseBindMatrices;
17777
+ if (this._supportSkinning) {
17778
+ var ibms = this._skin.inverseBindMatrices;
17764
17779
  var worldToLocal = this._rootBone.getInvModelMatrix();
17765
17780
  var _this = this, joints = _this._jointEntities, jointMatrices = _this._jointMatrices;
17766
17781
  for(var i = joints.length - 1; i >= 0; i--){
@@ -17779,8 +17794,6 @@
17779
17794
  * @override
17780
17795
  */ _proto._updateShaderData = function _updateShaderData(context) {
17781
17796
  var entity = this.entity;
17782
- var worldMatrix = this._rootBone ? this._rootBone.transform.worldMatrix : entity.transform.worldMatrix;
17783
- this._updateTransformShaderData(context, worldMatrix);
17784
17797
  var shaderData = this.shaderData;
17785
17798
  var mesh = this.mesh;
17786
17799
  var blendShapeManager = mesh._blendShapeManager;
@@ -17807,12 +17820,18 @@
17807
17820
  shaderData.disableMacro("O3_JOINTS_NUM");
17808
17821
  shaderData.enableMacro("O3_USE_JOINT_TEXTURE");
17809
17822
  shaderData.setTexture(SkinnedMeshRenderer._jointSamplerProperty, this._jointTexture);
17823
+ this._supportSkinning = true;
17810
17824
  } else {
17811
- Logger.error("component's joints count(" + jointCount + ") greater than device's MAX_VERTEX_UNIFORM_VECTORS number " + this._maxVertexUniformVectors + ", and don't support jointTexture in this device. suggest joint count less than " + remainUniformJointCount + ".", this);
17825
+ var _this__jointTexture1;
17826
+ this._supportSkinning = false;
17827
+ (_this__jointTexture1 = this._jointTexture) == null ? void 0 : _this__jointTexture1.destroy();
17828
+ shaderData.disableMacro("O3_HAS_SKIN");
17829
+ Logger.warn("component's joints count(" + jointCount + ") greater than device's MAX_VERTEX_UNIFORM_VECTORS number " + this._maxVertexUniformVectors + ", and don't support jointTexture in this device. suggest joint count less than " + remainUniformJointCount + ".", this);
17812
17830
  }
17813
17831
  } else {
17814
- var _this__jointTexture1;
17815
- (_this__jointTexture1 = this._jointTexture) == null ? void 0 : _this__jointTexture1.destroy();
17832
+ var _this__jointTexture2;
17833
+ this._supportSkinning = true;
17834
+ (_this__jointTexture2 = this._jointTexture) == null ? void 0 : _this__jointTexture2.destroy();
17816
17835
  shaderData.disableMacro("O3_USE_JOINT_TEXTURE");
17817
17836
  shaderData.enableMacro("O3_JOINTS_NUM", remainUniformJointCount.toString());
17818
17837
  shaderData.setFloatArray(SkinnedMeshRenderer._jointMatrixProperty, this._jointMatrices);
@@ -17823,6 +17842,8 @@
17823
17842
  this._jointTexture.setPixelBuffer(this._jointMatrices);
17824
17843
  }
17825
17844
  }
17845
+ var worldMatrix = this._supportSkinning && this._rootBone ? this._rootBone.transform.worldMatrix : entity.transform.worldMatrix;
17846
+ this._updateTransformShaderData(context, worldMatrix);
17826
17847
  var layer = entity.layer;
17827
17848
  this._rendererLayer.set(layer & 65535, layer >>> 16 & 65535, 0, 0);
17828
17849
  };
@@ -18017,6 +18038,9 @@
18017
18038
  (function() {
18018
18039
  SkinnedMeshRenderer._jointMatrixProperty = Shader.getPropertyByName("u_jointMatrix");
18019
18040
  })();
18041
+ __decorate$1([
18042
+ ignoreClone
18043
+ ], SkinnedMeshRenderer.prototype, "_supportSkinning", void 0);
18020
18044
  __decorate$1([
18021
18045
  ignoreClone
18022
18046
  ], SkinnedMeshRenderer.prototype, "_hasInitSkin", void 0);
@@ -31040,7 +31064,8 @@
31040
31064
  webGLMode: 0,
31041
31065
  alpha: false,
31042
31066
  stencil: true,
31043
- _forceFlush: false
31067
+ _forceFlush: false,
31068
+ _maxAllowSkinUniformVectorCount: 256
31044
31069
  }, initializeOptions);
31045
31070
  if (SystemInfo.platform === exports.Platform.IPhone || SystemInfo.platform === exports.Platform.IPad) {
31046
31071
  var version = SystemInfo.operatingSystem.match(/(\d+).?(\d+)?.?(\d+)?/);
@@ -33474,6 +33499,12 @@
33474
33499
  } else {
33475
33500
  var material = (materials == null ? void 0 : materials[materialIndex]) || SceneParser._getDefaultMaterial(engine);
33476
33501
  renderer.setMaterial(material);
33502
+ // Enable vertex color if mesh has COLOR_0 vertex element
33503
+ mesh.vertexElements.forEach(function(element) {
33504
+ if (element.semantic === "COLOR_0") {
33505
+ renderer.enableVertexColor = true;
33506
+ }
33507
+ });
33477
33508
  }
33478
33509
  var _gltfMeshPrimitives_i = gltfMeshPrimitives[i], _gltfMeshPrimitives_i_extensions = _gltfMeshPrimitives_i.extensions, extensions = _gltfMeshPrimitives_i_extensions === void 0 ? {} : _gltfMeshPrimitives_i_extensions;
33479
33510
  var KHR_materials_variants = extensions.KHR_materials_variants;
@@ -35777,7 +35808,7 @@
35777
35808
  }));
35778
35809
 
35779
35810
  //@ts-ignore
35780
- var version = "0.9.1";
35811
+ var version = "0.9.3";
35781
35812
  console.log("Galacean engine version: " + version);
35782
35813
  for(var key in CoreObjects){
35783
35814
  Loader.registerClass(key, CoreObjects[key]);