@galacean/engine-physics-physx 0.9.0 → 0.9.2

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.
@@ -12989,6 +12989,7 @@ var rePropName = RegExp("[^.[\\]]+" + "|" + // Or match property names within br
12989
12989
  var SkinnedMeshRenderer = function SkinnedMeshRenderer(entity) {
12990
12990
  var _this;
12991
12991
  _this = MeshRenderer.call(this, entity) || this;
12992
+ _this._supportSkinning = false;
12992
12993
  _this._hasInitSkin = false;
12993
12994
  _this._jointDataCreateCache = new miniprogram$7.Vector2(-1, -1);
12994
12995
  _this._localBounds = new miniprogram$7.BoundingBox();
@@ -12998,7 +12999,7 @@ var rePropName = RegExp("[^.[\\]]+" + "|" + // Or match property names within br
12998
12999
  // Limit size to 256 to avoid some problem:
12999
13000
  // 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!
13000
13001
  // 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.
13001
- maxVertexUniformVectors = Math.min(maxVertexUniformVectors, 256);
13002
+ maxVertexUniformVectors = Math.min(maxVertexUniformVectors, rhi._options._maxAllowSkinUniformVectorCount);
13002
13003
  _this._maxVertexUniformVectors = maxVertexUniformVectors;
13003
13004
  _this._onLocalBoundsChanged = _this._onLocalBoundsChanged.bind(_assert_this_initialized(_this));
13004
13005
  var localBounds = _this._localBounds;
@@ -13017,9 +13018,8 @@ var rePropName = RegExp("[^.[\\]]+" + "|" + // Or match property names within br
13017
13018
  this._initSkin();
13018
13019
  this._hasInitSkin = true;
13019
13020
  }
13020
- var skin = this._skin;
13021
- if (skin) {
13022
- var ibms = skin.inverseBindMatrices;
13021
+ if (this._supportSkinning) {
13022
+ var ibms = this._skin.inverseBindMatrices;
13023
13023
  var worldToLocal = this._rootBone.getInvModelMatrix();
13024
13024
  var _this = this, joints = _this._jointEntities, jointMatrices = _this._jointMatrices;
13025
13025
  for(var i = joints.length - 1; i >= 0; i--){
@@ -13038,8 +13038,6 @@ var rePropName = RegExp("[^.[\\]]+" + "|" + // Or match property names within br
13038
13038
  * @override
13039
13039
  */ _proto._updateShaderData = function _updateShaderData(context) {
13040
13040
  var entity = this.entity;
13041
- var worldMatrix = this._rootBone ? this._rootBone.transform.worldMatrix : entity.transform.worldMatrix;
13042
- this._updateTransformShaderData(context, worldMatrix);
13043
13041
  var shaderData = this.shaderData;
13044
13042
  var mesh = this.mesh;
13045
13043
  var blendShapeManager = mesh._blendShapeManager;
@@ -13066,12 +13064,18 @@ var rePropName = RegExp("[^.[\\]]+" + "|" + // Or match property names within br
13066
13064
  shaderData.disableMacro("O3_JOINTS_NUM");
13067
13065
  shaderData.enableMacro("O3_USE_JOINT_TEXTURE");
13068
13066
  shaderData.setTexture(SkinnedMeshRenderer._jointSamplerProperty, this._jointTexture);
13067
+ this._supportSkinning = true;
13069
13068
  } else {
13070
- 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);
13069
+ var _this__jointTexture1;
13070
+ this._supportSkinning = false;
13071
+ (_this__jointTexture1 = this._jointTexture) == null ? void 0 : _this__jointTexture1.destroy();
13072
+ shaderData.disableMacro("O3_HAS_SKIN");
13073
+ 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);
13071
13074
  }
13072
13075
  } else {
13073
- var _this__jointTexture1;
13074
- (_this__jointTexture1 = this._jointTexture) == null ? void 0 : _this__jointTexture1.destroy();
13076
+ var _this__jointTexture2;
13077
+ this._supportSkinning = true;
13078
+ (_this__jointTexture2 = this._jointTexture) == null ? void 0 : _this__jointTexture2.destroy();
13075
13079
  shaderData.disableMacro("O3_USE_JOINT_TEXTURE");
13076
13080
  shaderData.enableMacro("O3_JOINTS_NUM", remainUniformJointCount.toString());
13077
13081
  shaderData.setFloatArray(SkinnedMeshRenderer._jointMatrixProperty, this._jointMatrices);
@@ -13082,6 +13086,8 @@ var rePropName = RegExp("[^.[\\]]+" + "|" + // Or match property names within br
13082
13086
  this._jointTexture.setPixelBuffer(this._jointMatrices);
13083
13087
  }
13084
13088
  }
13089
+ var worldMatrix = this._supportSkinning && this._rootBone ? this._rootBone.transform.worldMatrix : entity.transform.worldMatrix;
13090
+ this._updateTransformShaderData(context, worldMatrix);
13085
13091
  var layer = entity.layer;
13086
13092
  this._rendererLayer.set(layer & 65535, layer >>> 16 & 65535, 0, 0);
13087
13093
  };
@@ -13276,6 +13282,9 @@ var rePropName = RegExp("[^.[\\]]+" + "|" + // Or match property names within br
13276
13282
  (function() {
13277
13283
  SkinnedMeshRenderer._jointMatrixProperty = Shader.getPropertyByName("u_jointMatrix");
13278
13284
  })();
13285
+ __decorate$1([
13286
+ ignoreClone
13287
+ ], SkinnedMeshRenderer.prototype, "_supportSkinning", void 0);
13279
13288
  __decorate$1([
13280
13289
  ignoreClone
13281
13290
  ], SkinnedMeshRenderer.prototype, "_hasInitSkin", void 0);
@@ -26229,21 +26238,31 @@ var MeshParser = /*#__PURE__*/ function(Parser1) {
26229
26238
  var vertexCount;
26230
26239
  var bufferBindIndex = 0;
26231
26240
  var positions;
26232
- keepMeshData && (positions = new Array(vertexCount));
26241
+ var boneIndices;
26242
+ var boneWeights;
26243
+ if (keepMeshData) {
26244
+ positions = new Array(vertexCount);
26245
+ boneIndices = new Array(vertexCount);
26246
+ boneWeights = new Array(vertexCount);
26247
+ }
26233
26248
  for(var attribute in attributes){
26234
26249
  var accessor = accessors[attributes[attribute]];
26235
26250
  var accessorBuffer = GLTFUtil.getAccessorBuffer(context, gltf, accessor);
26236
- var dataElmentSize = GLTFUtil.getAccessorTypeSize(accessor.type);
26237
- var attributeCount = accessor.count;
26251
+ var dataElementSize = GLTFUtil.getAccessorTypeSize(accessor.type);
26252
+ var accessorCount = accessor.count;
26238
26253
  var vertices = accessorBuffer.data;
26239
26254
  var vertexElement = void 0;
26240
26255
  var meshId = mesh.instanceId;
26241
26256
  var vertexBindingInfos = accessorBuffer.vertexBindingInfos;
26242
- var elementFormat = GLTFUtil.getElementFormat(accessor.componentType, dataElmentSize, accessor.normalized);
26257
+ var elementNormalized = accessor.normalized;
26258
+ var elementFormat = GLTFUtil.getElementFormat(accessor.componentType, dataElementSize, elementNormalized);
26259
+ var scaleFactor = void 0;
26260
+ elementNormalized && (scaleFactor = GLTFUtil.getNormalizedComponentScale(accessor.componentType));
26261
+ var elementOffset = void 0;
26243
26262
  if (accessorBuffer.interleaved) {
26244
26263
  var byteOffset = accessor.byteOffset || 0;
26245
26264
  var stride = accessorBuffer.stride;
26246
- var elementOffset = byteOffset % stride;
26265
+ elementOffset = byteOffset % stride;
26247
26266
  if (vertexBindingInfos[meshId] === undefined) {
26248
26267
  vertexElement = new miniprogram$5.VertexElement(attribute, elementOffset, elementFormat, bufferBindIndex);
26249
26268
  var vertexBuffer = accessorBuffer.vertexBuffer;
@@ -26258,7 +26277,8 @@ var MeshParser = /*#__PURE__*/ function(Parser1) {
26258
26277
  vertexElement = new miniprogram$5.VertexElement(attribute, elementOffset, elementFormat, vertexBindingInfos[meshId]);
26259
26278
  }
26260
26279
  } else {
26261
- vertexElement = new miniprogram$5.VertexElement(attribute, 0, elementFormat, bufferBindIndex);
26280
+ elementOffset = 0;
26281
+ vertexElement = new miniprogram$5.VertexElement(attribute, elementOffset, elementFormat, bufferBindIndex);
26262
26282
  var vertexBuffer1 = new miniprogram$5.Buffer(engine, miniprogram$5.BufferBindFlag.VertexBuffer, vertices.byteLength, miniprogram$5.BufferUsage.Static);
26263
26283
  vertexBuffer1.setData(vertices);
26264
26284
  mesh.setVertexBufferBinding(vertexBuffer1, accessorBuffer.stride, bufferBindIndex);
@@ -26266,35 +26286,60 @@ var MeshParser = /*#__PURE__*/ function(Parser1) {
26266
26286
  }
26267
26287
  vertexElements.push(vertexElement);
26268
26288
  if (attribute === "POSITION") {
26269
- vertexCount = attributeCount;
26289
+ vertexCount = accessorCount;
26270
26290
  var _mesh_bounds = mesh.bounds, min = _mesh_bounds.min, max = _mesh_bounds.max;
26271
26291
  if (accessor.min && accessor.max) {
26272
26292
  min.copyFromArray(accessor.min);
26273
26293
  max.copyFromArray(accessor.max);
26274
26294
  if (keepMeshData) {
26275
- var stride1 = vertices.length / attributeCount;
26276
- for(var j = 0; j < attributeCount; j++){
26277
- var offset = j * stride1;
26278
- positions[j] = new miniprogram$1$2.Vector3(vertices[offset], vertices[offset + 1], vertices[offset + 2]);
26295
+ var baseOffset = elementOffset / vertices.BYTES_PER_ELEMENT;
26296
+ var stride1 = vertices.length / accessorCount;
26297
+ for(var j = 0; j < accessorCount; j++){
26298
+ var offset = baseOffset + j * stride1;
26299
+ var position = new miniprogram$1$2.Vector3(vertices[offset], vertices[offset + 1], vertices[offset + 2]);
26300
+ elementNormalized && position.scale(scaleFactor);
26301
+ positions[j] = position;
26279
26302
  }
26280
26303
  }
26281
26304
  } else {
26282
- var position = MeshParser._tempVector3;
26305
+ var position1 = MeshParser._tempVector3;
26283
26306
  min.set(Number.MAX_VALUE, Number.MAX_VALUE, Number.MAX_VALUE);
26284
26307
  max.set(-Number.MAX_VALUE, -Number.MAX_VALUE, -Number.MAX_VALUE);
26285
- var stride2 = vertices.length / attributeCount;
26286
- for(var j1 = 0; j1 < attributeCount; j1++){
26287
- var offset1 = j1 * stride2;
26288
- position.copyFromArray(vertices, offset1);
26289
- miniprogram$1$2.Vector3.min(min, position, min);
26290
- miniprogram$1$2.Vector3.max(max, position, max);
26291
- keepMeshData && (positions[j1] = position.clone());
26308
+ var baseOffset1 = elementOffset / vertices.BYTES_PER_ELEMENT;
26309
+ var stride2 = vertices.length / accessorCount;
26310
+ for(var j1 = 0; j1 < accessorCount; j1++){
26311
+ var offset1 = baseOffset1 + j1 * stride2;
26312
+ position1.copyFromArray(vertices, offset1);
26313
+ miniprogram$1$2.Vector3.min(min, position1, min);
26314
+ miniprogram$1$2.Vector3.max(max, position1, max);
26315
+ if (keepMeshData) {
26316
+ var clonePosition = position1.clone();
26317
+ elementNormalized && clonePosition.scale(scaleFactor);
26318
+ positions[j1] = clonePosition;
26319
+ }
26292
26320
  }
26293
26321
  }
26294
- if (accessor.normalized) {
26295
- var sacleFactor = GLTFUtil.getNormalizedComponentScale(accessor.componentType);
26296
- min.scale(sacleFactor);
26297
- max.scale(sacleFactor);
26322
+ if (elementNormalized) {
26323
+ min.scale(scaleFactor);
26324
+ max.scale(scaleFactor);
26325
+ }
26326
+ } else if (attribute === "JOINTS_0" && keepMeshData) {
26327
+ var baseOffset2 = elementOffset / vertices.BYTES_PER_ELEMENT;
26328
+ var stride3 = vertices.length / accessorCount;
26329
+ for(var j2 = 0; j2 < accessorCount; j2++){
26330
+ var offset2 = baseOffset2 + j2 * stride3;
26331
+ var boneIndex = new miniprogram$1$2.Vector4(vertices[offset2], vertices[offset2 + 1], vertices[offset2 + 2], vertices[offset2 + 3]);
26332
+ elementNormalized && boneIndex.scale(scaleFactor);
26333
+ boneIndices[j2] = boneIndex;
26334
+ }
26335
+ } else if (attribute === "WEIGHTS_0" && keepMeshData) {
26336
+ var baseOffset3 = elementOffset / vertices.BYTES_PER_ELEMENT;
26337
+ var stride4 = vertices.length / accessorCount;
26338
+ for(var j3 = 0; j3 < accessorCount; j3++){
26339
+ var offset3 = baseOffset3 + j3 * stride4;
26340
+ var boneWeight = new miniprogram$1$2.Vector4(vertices[offset3], vertices[offset3 + 1], vertices[offset3 + 2], vertices[offset3 + 3]);
26341
+ elementNormalized && boneWeight.scale(scaleFactor);
26342
+ boneWeights[j3] = boneWeight;
26298
26343
  }
26299
26344
  }
26300
26345
  }
@@ -26313,6 +26358,10 @@ var MeshParser = /*#__PURE__*/ function(Parser1) {
26313
26358
  mesh.uploadData(!keepMeshData);
26314
26359
  //@ts-ignore
26315
26360
  mesh._positions = positions;
26361
+ //@ts-ignore
26362
+ mesh._boneIndices = boneIndices;
26363
+ //@ts-ignore
26364
+ mesh._boneWeights = boneWeights;
26316
26365
  return Promise.resolve(mesh);
26317
26366
  };
26318
26367
  _proto._createBlendShape = function _createBlendShape(mesh, glTFMesh, glTFTargets, getBlendShapeData) {
@@ -35299,7 +35348,8 @@ exports.WebGLMode = void 0;
35299
35348
  webGLMode: 0,
35300
35349
  alpha: false,
35301
35350
  stencil: true,
35302
- _forceFlush: false
35351
+ _forceFlush: false,
35352
+ _maxAllowSkinUniformVectorCount: 256
35303
35353
  }, initializeOptions);
35304
35354
  if (miniprogram$1$1.SystemInfo.platform === miniprogram$1$1.Platform.IPhone || miniprogram$1$1.SystemInfo.platform === miniprogram$1$1.Platform.IPad) {
35305
35355
  var version = miniprogram$1$1.SystemInfo.operatingSystem.match(/(\d+).?(\d+)?.?(\d+)?/);
@@ -35604,7 +35654,7 @@ function _interopNamespace(e) {
35604
35654
  }
35605
35655
  var CoreObjects__namespace = /*#__PURE__*/ _interopNamespace(CoreObjects);
35606
35656
  //@ts-ignore
35607
- var version = "0.9.0";
35657
+ var version = "0.9.2";
35608
35658
  console.log("Galacean engine version: " + version);
35609
35659
  for(var key in CoreObjects__namespace){
35610
35660
  CoreObjects.Loader.registerClass(key, CoreObjects__namespace[key]);