ソースを参照

backward-compatability fix

Andrew V Butt Sr 5 年 前
コミット
e548d2edbd

+ 0 - 14
materialsLibrary/src/legacy/legacy-boneWeights.ts

@@ -1,14 +0,0 @@
-import * as MatLib from "../boneWeights";
-
-/**
- * This is the entry point for the UMD module.
- * The entry point for a future ESM package should be index.ts
- */
-var globalObject = (typeof global !== 'undefined') ? global : ((typeof window !== 'undefined') ? window : undefined);
-if (typeof globalObject !== "undefined") {
-    for (var key in MatLib) {
-        (<any>globalObject).BABYLON[key] = (<any>MatLib)[key];
-    }
-}
-
-export * from "../boneWeights";

+ 19 - 8
src/Debug/skeletonViewer.ts

@@ -387,16 +387,25 @@ export class SkeletonViewer {
         options.displayOptions.sphereScaleUnit = options.displayOptions.sphereScaleUnit ?? 2;
         options.displayOptions.sphereFactor = options.displayOptions.sphereFactor ?? 0.865;
         options.computeBonesUsingShaders = options.computeBonesUsingShaders ?? true;
+        options.useAllBones = options.useAllBones ?? true;
 
         const boneIndices = mesh.getVerticesData(VertexBuffer.MatricesIndicesKind);
         const boneWeights = mesh.getVerticesData(VertexBuffer.MatricesWeightsKind);
         this._boneIndices = new Set();
 
-        if (boneIndices && boneWeights) {
-            for (let i = 0; i < boneIndices.length; ++i) {
-                const index = boneIndices[i], weight = boneWeights[i];
-                if (weight !== 0) {
-                    this._boneIndices.add(index);
+        if (options.useAllBones) {
+            if (boneIndices) {
+                for (let i = 0; i < boneIndices.length; ++i) {
+                    this._boneIndices.add(boneIndices[i]);
+                }
+            }
+        }else {
+            if (boneIndices && boneWeights) {
+                for (let i = 0; i < boneIndices.length; ++i) {
+                    const index = boneIndices[i], weight = boneWeights[i];
+                    if (weight !== 0) {
+                        this._boneIndices.add(index);
+                    }
                 }
             }
         }
@@ -594,9 +603,11 @@ export class SkeletonViewer {
 
             for (let i = 0; i < bones.length; i++) {
                 let bone = bones[i];
-
-                if (bone._index === -1 || !this._boneIndices.has(bone.getIndex())) {
-                    continue;
+                
+                if(!this.options.useAllBones){
+                    if (bone._index === -1 || !this._boneIndices.has(bone.getIndex())) {
+                        continue;
+                    }
                 }
 
                 let boneAbsoluteRestTransform = new Matrix();