@galacean/engine 0.0.0-experimental-2.0-game.12 → 0.0.0-experimental-2.0-game.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/browser.js CHANGED
@@ -12744,7 +12744,13 @@
12744
12744
  };
12745
12745
  ShaderFactory._has300OutInFragReg = /\bout\s+(?:\w+\s+)?vec4\s+\w+\s*;/;
12746
12746
  ShaderFactory._precisionStr = "\n#ifdef GL_FRAGMENT_PRECISION_HIGH\n precision highp float;\n precision highp int;\n#else\n precision mediump float;\n precision mediump int;\n#endif\n";
12747
- ShaderFactory._derivedDefines = "#define renderer_MVMat (camera_ViewMat * renderer_ModelMat)\n#define renderer_MVPMat (camera_VPMat * renderer_ModelMat)\n#define renderer_NormalMat mat4(transpose(inverse(mat3(renderer_ModelMat))))";
12747
+ // Derived built-ins re-exposed on top of `renderer_ModelMat`.
12748
+ // `renderer_NormalMat` uses the cofactor (cross-product) form, which algebraically equals
12749
+ // `det(M) · transpose(inverse(M))`. After `normalize()` it's directionally identical to the
12750
+ // classic `transpose(inverse(M))`, but stays NaN-free when `M` is singular (e.g. any scale
12751
+ // axis is 0 — common in animations that pop / hide via scale). `sign(det)` (`s` below)
12752
+ // keeps mirrored matrices facing the right way
12753
+ ShaderFactory._derivedDefines = "mat3 _normalMatFromModel(mat3 m) {\n vec3 c0 = cross(m[1], m[2]);\n vec3 c1 = cross(m[2], m[0]);\n vec3 c2 = cross(m[0], m[1]);\n float s = (dot(m[0], c0) < 0.0) ? -1.0 : 1.0;\n return mat3(c0 * s, c1 * s, c2 * s);\n}\n#define renderer_MVMat (camera_ViewMat * renderer_ModelMat)\n#define renderer_MVPMat (camera_VPMat * renderer_ModelMat)\n#define renderer_NormalMat mat4(_normalMatFromModel(mat3(renderer_ModelMat)))";
12748
12754
  // Built-in renderer uniforms. value=true means derived (remove but not added to UBO)
12749
12755
  ShaderFactory._builtinRendererUniforms = {
12750
12756
  renderer_ModelMat: false,
@@ -23980,7 +23986,7 @@
23980
23986
  /** Scene. */ AssetType["Scene"] = "Scene";
23981
23987
  /** Font. */ AssetType["Font"] = "Font";
23982
23988
  /** Source Font, include ttf, otf and woff. */ AssetType["SourceFont"] = "SourceFont";
23983
- /** AudioClip, include ogg, wav and mp3. */ AssetType["Audio"] = "Audio";
23989
+ /** AudioClip, include ogg, wav, mp3, m4a, aac and flac. */ AssetType["Audio"] = "Audio";
23984
23990
  /** Project asset. */ AssetType["Project"] = "project";
23985
23991
  /** PhysicsMaterial. */ AssetType["PhysicsMaterial"] = "PhysicsMaterial";
23986
23992
  /** RenderTarget. */ AssetType["RenderTarget"] = "RenderTarget";
@@ -26860,8 +26866,7 @@
26860
26866
  * You need to obtain the actual number of contact points from the function's return value.
26861
26867
  */ _proto.getContacts = function getContacts(outContacts) {
26862
26868
  var nativeCollision = this._nativeCollision;
26863
- var smallerShapeId = Math.min(nativeCollision.shape0Id, nativeCollision.shape1Id);
26864
- var factor = this.shape.id === smallerShapeId ? 1 : -1;
26869
+ var factor = this.shape.id === nativeCollision.shape1Id ? 1 : -1;
26865
26870
  var nativeContactPoints = nativeCollision.getContacts();
26866
26871
  var length = nativeContactPoints.size();
26867
26872
  for(var i = 0; i < length; i++){
@@ -38341,8 +38346,8 @@
38341
38346
  if (this._tryCrossFadeInterrupt(layerData, transitionDuration, destState, deltaTime, aniUpdate)) {
38342
38347
  return;
38343
38348
  }
38344
- var srcPlaySpeed = srcState.speed * speed;
38345
- var dstPlaySpeed = destState.speed * speed;
38349
+ var srcPlaySpeed = srcPlayData.speed * speed;
38350
+ var dstPlaySpeed = destPlayData.speed * speed;
38346
38351
  var dstPlayDeltaTime = dstPlaySpeed * deltaTime;
38347
38352
  srcPlayData && srcPlayData.updateOrientation(srcPlaySpeed * deltaTime);
38348
38353
  destPlayData && destPlayData.updateOrientation(dstPlayDeltaTime);
@@ -53859,32 +53864,10 @@
53859
53864
  if (rootBoneIndex !== -1) {
53860
53865
  BoundingBox.transform(mesh.bounds, inverseBindMatrices[rootBoneIndex], skinnedMeshRenderer.localBounds);
53861
53866
  } else {
53862
- // Root bone is not in joints list, we can only compute approximate inverse bind matrix
53863
- // Average all root bone's children inverse bind matrix
53864
- var approximateBindMatrix = new Matrix(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0);
53865
- var subRootBoneCount = this._computeApproximateBindMatrix(bones, inverseBindMatrices, rootBone, approximateBindMatrix);
53866
- if (subRootBoneCount !== 0) {
53867
- Matrix.multiplyScalar(approximateBindMatrix, 1.0 / subRootBoneCount, approximateBindMatrix);
53868
- BoundingBox.transform(mesh.bounds, approximateBindMatrix, skinnedMeshRenderer.localBounds);
53869
- } else {
53870
- skinnedMeshRenderer.localBounds.copyFrom(mesh.bounds);
53871
- }
53872
- }
53873
- };
53874
- _proto._computeApproximateBindMatrix = function _computeApproximateBindMatrix(jointEntities, inverseBindMatrices, rootEntity, approximateBindMatrix) {
53875
- var subRootBoneCount = 0;
53876
- var children = rootEntity.children;
53877
- for(var i = 0, n = children.length; i < n; i++){
53878
- var rootChild = children[i];
53879
- var index = jointEntities.indexOf(rootChild);
53880
- if (index !== -1) {
53881
- Matrix.add(approximateBindMatrix, inverseBindMatrices[index], approximateBindMatrix);
53882
- subRootBoneCount++;
53883
- } else {
53884
- subRootBoneCount += this._computeApproximateBindMatrix(jointEntities, inverseBindMatrices, rootChild, approximateBindMatrix);
53885
- }
53867
+ var inverseRootBoneWorld = new Matrix();
53868
+ Matrix.invert(rootBone.transform.worldMatrix, inverseRootBoneWorld);
53869
+ BoundingBox.transform(mesh.bounds, inverseRootBoneWorld, skinnedMeshRenderer.localBounds);
53886
53870
  }
53887
- return subRootBoneCount;
53888
53871
  };
53889
53872
  return GLTFSceneParser;
53890
53873
  }(GLTFParser);
@@ -53926,8 +53909,7 @@
53926
53909
  var rootBone = entities[skeleton];
53927
53910
  skin.rootBone = rootBone;
53928
53911
  } else {
53929
- var _this__findSceneRootBone;
53930
- var rootBone1 = (_this__findSceneRootBone = _this._findSceneRootBone(context, joints, entities)) != null ? _this__findSceneRootBone : _this._findSkeletonRootBone(joints, entities);
53912
+ var rootBone1 = _this._findSkinRootBoneByLCA(index, joints, entities, glTF.nodes);
53931
53913
  if (rootBone1) {
53932
53914
  skin.rootBone = rootBone1;
53933
53915
  } else {
@@ -53938,46 +53920,20 @@
53938
53920
  });
53939
53921
  return AssetPromise.resolve(skinPromise);
53940
53922
  };
53941
- _proto._findSceneRootBone = function _findSceneRootBone(context, joints, entities) {
53942
- var glTF = context.glTF, glTFResource = context.glTFResource;
53943
- var scenes = glTF.scenes;
53944
- var sceneRoots = glTFResource._sceneRoots;
53945
- if (!(scenes == null ? void 0 : scenes.length) || !(sceneRoots == null ? void 0 : sceneRoots.length)) {
53946
- return null;
53947
- }
53948
- for(var i = 0, n = scenes.length; i < n; i++){
53949
- var _scenes_i_nodes;
53950
- var sceneNodes = (_scenes_i_nodes = scenes[i].nodes) != null ? _scenes_i_nodes : [];
53951
- if (sceneNodes.length <= 1) {
53952
- continue;
53953
- }
53954
- var sceneRoot = sceneRoots[i];
53955
- if (!sceneRoot) {
53956
- continue;
53957
- }
53958
- var sceneRootChildren = new Set(sceneNodes.map(function(nodeIndex) {
53959
- return entities[nodeIndex];
53960
- }));
53961
- var allJointsUnderSceneRoot = true;
53962
- for(var j = 0, m = joints.length; j < m; j++){
53963
- var entity = entities[joints[j]];
53964
- while(entity == null ? void 0 : entity.parent){
53965
- entity = entity.parent;
53966
- }
53967
- if (!sceneRootChildren.has(entity)) {
53968
- allJointsUnderSceneRoot = false;
53969
- break;
53970
- }
53971
- }
53972
- if (allJointsUnderSceneRoot) {
53973
- return sceneRoot;
53923
+ _proto._findSkinRootBoneByLCA = function _findSkinRootBoneByLCA(skinIndex, joints, entities, nodes) {
53924
+ if (nodes === void 0) nodes = [];
53925
+ var nodeIndices = joints.slice();
53926
+ for(var i = 0, n = nodes.length; i < n; i++){
53927
+ var _nodes_i;
53928
+ if (((_nodes_i = nodes[i]) == null ? void 0 : _nodes_i.skin) === skinIndex) {
53929
+ nodeIndices.push(i);
53974
53930
  }
53975
53931
  }
53976
- return null;
53932
+ return this._findRootBoneByLCA(nodeIndices, entities);
53977
53933
  };
53978
- _proto._findSkeletonRootBone = function _findSkeletonRootBone(joints, entities) {
53979
- var paths = {};
53980
- for(var _iterator = _create_for_of_iterator_helper_loose(joints), _step; !(_step = _iterator()).done;){
53934
+ _proto._findRootBoneByLCA = function _findRootBoneByLCA(nodeIndices, entities) {
53935
+ var paths = [];
53936
+ for(var _iterator = _create_for_of_iterator_helper_loose(nodeIndices), _step; !(_step = _iterator()).done;){
53981
53937
  var index = _step.value;
53982
53938
  var path = new Array();
53983
53939
  var entity = entities[index];
@@ -53985,17 +53941,22 @@
53985
53941
  path.unshift(entity);
53986
53942
  entity = entity.parent;
53987
53943
  }
53988
- paths[index] = path;
53944
+ if (path.length) {
53945
+ paths.push(path);
53946
+ }
53947
+ }
53948
+ if (!paths.length) {
53949
+ return null;
53989
53950
  }
53990
53951
  var rootNode = null;
53991
53952
  for(var i = 0;; i++){
53992
- var path1 = paths[joints[0]];
53953
+ var path1 = paths[0];
53993
53954
  if (i >= path1.length) {
53994
53955
  return rootNode;
53995
53956
  }
53996
53957
  var entity1 = path1[i];
53997
- for(var j = 1, m = joints.length; j < m; j++){
53998
- path1 = paths[joints[j]];
53958
+ for(var j = 1, m = paths.length; j < m; j++){
53959
+ path1 = paths[j];
53999
53960
  if (i >= path1.length || entity1 !== path1[i]) {
54000
53961
  return rootNode;
54001
53962
  }
@@ -55540,7 +55501,10 @@
55540
55501
  "mp3",
55541
55502
  "ogg",
55542
55503
  "wav",
55543
- "audio"
55504
+ "audio",
55505
+ "m4a",
55506
+ "aac",
55507
+ "flac"
55544
55508
  ])
55545
55509
  ], AudioLoader);
55546
55510
  var ShaderChunkLoader = /*#__PURE__*/ function(Loader) {
@@ -56330,7 +56294,7 @@
56330
56294
  ], EXT_texture_webp);
56331
56295
 
56332
56296
  //@ts-ignore
56333
- var version = "0.0.0-experimental-2.0-game.12";
56297
+ var version = "0.0.0-experimental-2.0-game.13";
56334
56298
  console.log("Galacean Engine Version: " + version);
56335
56299
  for(var key in CoreObjects){
56336
56300
  Loader.registerClass(key, CoreObjects[key]);