Andrew V Butt Sr 5 лет назад
Родитель
Сommit
3627ad4001
1 измененных файлов с 24 добавлено и 32 удалено
  1. 24 32
      src/Materials/shaderMaterial.ts

+ 24 - 32
src/Materials/shaderMaterial.ts

@@ -540,47 +540,39 @@ export class ShaderMaterial extends Material {
 
         // Bones
         let numInfluencers = 0;
-        if (mesh) {
-            if (mesh.useBones && mesh.computeBonesUsingShaders && mesh.skeleton) {
-                attribs.push(VertexBuffer.MatricesIndicesKind);
-                attribs.push(VertexBuffer.MatricesWeightsKind);
-                if (mesh.numBoneInfluencers > 4) {
-                    attribs.push(VertexBuffer.MatricesIndicesExtraKind);
-                    attribs.push(VertexBuffer.MatricesWeightsExtraKind);
-                }
-
-                const skeleton = mesh.skeleton;
-
-                numInfluencers = mesh.numBoneInfluencers;
-                defines.push("#define NUM_BONE_INFLUENCERS " + numInfluencers);
-                fallbacks.addCPUSkinningFallback(0, mesh);
+        if (mesh && mesh.useBones && mesh.computeBonesUsingShaders && mesh.skeleton) {
+            attribs.push(VertexBuffer.MatricesIndicesKind);
+            attribs.push(VertexBuffer.MatricesWeightsKind);
+            if (mesh.numBoneInfluencers > 4) {
+                attribs.push(VertexBuffer.MatricesIndicesExtraKind);
+                attribs.push(VertexBuffer.MatricesWeightsExtraKind);
+            }
 
-                if (skeleton.isUsingTextureForMatrices) {
-                    defines.push("#define BONETEXTURE");
+            const skeleton = mesh.skeleton;
 
-                    if (this._options.uniforms.indexOf("boneTextureWidth") === -1) {
-                        this._options.uniforms.push("boneTextureWidth");
-                    }
+            numInfluencers = mesh.numBoneInfluencers;
+            defines.push("#define NUM_BONE_INFLUENCERS " + numInfluencers);
+            fallbacks.addCPUSkinningFallback(0, mesh);
 
-                    if (this._options.samplers.indexOf("boneSampler") === -1) {
-                        this._options.samplers.push("boneSampler");
-                    }
-                } else {
-                    defines.push("#define BonesPerMesh " + (skeleton.bones.length + 1));
+            if (skeleton.isUsingTextureForMatrices) {
+                defines.push("#define BONETEXTURE");
 
-                    if (this._options.uniforms.indexOf("mBones") === -1) {
-                        this._options.uniforms.push("mBones");
-                    }
+                if (this._options.uniforms.indexOf("boneTextureWidth") === -1) {
+                    this._options.uniforms.push("boneTextureWidth");
                 }
 
+                if (this._options.samplers.indexOf("boneSampler") === -1) {
+                    this._options.samplers.push("boneSampler");
+                }
             } else {
-                if (mesh && this.getClassName() == "BoneWeightShader" || this.getClassName() == "SkeletonMapShader") {
-                    numInfluencers = mesh.numBoneInfluencers;
-                    defines.push("#define NUM_BONE_INFLUENCERS " + numInfluencers);
-                }else {
-                    defines.push("#define NUM_BONE_INFLUENCERS 0");
+                defines.push("#define BonesPerMesh " + (skeleton.bones.length + 1));
+
+                if (this._options.uniforms.indexOf("mBones") === -1) {
+                    this._options.uniforms.push("mBones");
                 }
             }
+        } else {
+            defines.push("#define NUM_BONE_INFLUENCERS 0");
         }
 
         // Textures