فهرست منبع

Restore scaleChildren property

David Catuhe 7 سال پیش
والد
کامیت
813850e1a7
2فایلهای تغییر یافته به همراه21 افزوده شده و 41 حذف شده
  1. 1 0
      dist/preview release/what's new.md
  2. 20 41
      src/Bones/babylon.bone.ts

+ 1 - 0
dist/preview release/what's new.md

@@ -145,3 +145,4 @@
 - glTF 2.0 loader now creates a mesh for each primitive instead of merging the primitives together into one mesh. If a mesh only has one primitive, the behavior is the same as before. This change only affects meshes that have multiple primitives. ([bghgary](https://github.com/bghgary)]
 - Engine's onCanvasPointerOutObservable will now return a PointerEvent instead of the Engine. ([trevordev](https://github.com/trevordev))
 - Removed public references to default rendering pipeline's internal post process ([trevordev](https://github.com/trevordev))
+- `Bone.setScale` does not support scaleChildren property anymore. You can use `Bone.scale` to achieve the same effect ([deltakosh](https://github.com/deltakosh))

+ 20 - 41
src/Bones/babylon.bone.ts

@@ -232,7 +232,7 @@
         }
 
         public set scaling(newScaling: Vector3) {
-            this.setScale(newScaling, true);
+            this.setScale(newScaling);
         }
 
         /**
@@ -508,36 +508,6 @@
          * @param scaleChildren sets this to true if children of the bone should be scaled as well (false by default)
          */
         public scale(x: number, y: number, z: number, scaleChildren = false): void {
-            if (!scaleChildren) {
-                this._scaleOnlyLocally(x, y, z);
-                return;
-            }            
-
-            this._decompose();
-            this._localScaling.x *= x;
-            this._localScaling.y *= y;
-            this._localScaling.z *= z;
-            
-            this._markAsDirtyAndCompose();
-        }
-
-        /**
-         * Set the bone scaling in local space
-         * @param scale defines the scaling vector
-         * @param scaleChildren sets this to true if children of the bone should be scaled as well (false by default)
-         */
-        public setScale(scale: Vector3, scaleChildren = false): void {
-            if (!scaleChildren) {
-                this._scaleOnlyLocally(scale.x, scale.y, scale.z);
-                return;
-            }
-            
-            this._decompose();
-            this._localScaling.copyFrom(scale);
-            this._markAsDirtyAndCompose();
-        }    
-
-        private _scaleOnlyLocally(x: number, y: number, z: number): void {
             var locMat = this.getLocalMatrix();
 
             // Apply new scaling on top of current local matrix
@@ -545,25 +515,34 @@
             Matrix.ScalingToRef(x, y, z, scaleMat);
             scaleMat.multiplyToRef(locMat, locMat);
 
-            // Update the absolute transform
-            var parent = this.getParent();
-
-            if (parent) {
-                locMat.multiplyToRef(parent.getAbsoluteTransform(), this.getAbsoluteTransform());
-            } else {
-                this.getAbsoluteTransform().copyFrom(locMat);
-            }
-
             // Invert scaling matrix and apply the inverse to all children
             scaleMat.invert();
 
             for (var child of this.children) {
                 var cm = child.getLocalMatrix();
                 cm.multiplyToRef(scaleMat, cm);
+
+                child._markAsDirtyAndDecompose();
             }
 
-            this.markAsDirty();
+            this._markAsDirtyAndDecompose();
+
+            if (scaleChildren) {
+                for (var child of this.children) {
+                    child.scale(x, y, z, scaleChildren);
+                }
+            }
         }
+
+        /**
+         * Set the bone scaling in local space
+         * @param scale defines the scaling vector
+         */
+        public setScale(scale: Vector3): void {          
+            this._decompose();
+            this._localScaling.copyFrom(scale);
+            this._markAsDirtyAndCompose();
+        }    
         
         /**
          * Gets the current scaling in local space