Переглянути джерело

fix axis drag gizmo with bones

Cedric Guillemet 4 роки тому
батько
коміт
cf8bacfacd
2 змінених файлів з 6 додано та 3 видалено
  1. 2 2
      src/Gizmos/axisDragGizmo.ts
  2. 4 1
      src/Gizmos/gizmo.ts

+ 2 - 2
src/Gizmos/axisDragGizmo.ts

@@ -133,7 +133,7 @@ export class AxisDragGizmo extends Gizmo {
                     }
 
                     // use _worldMatrix to not force a matrix update when calling GetWorldMatrix especialy with Cameras
-                    this.attachedNode._worldMatrix.addTranslationFromFloats(event.delta.x, event.delta.y, event.delta.z);
+                    this.attachedNode.getWorldMatrix().addTranslationFromFloats(event.delta.x, event.delta.y, event.delta.z);
                     this.attachedNode.updateCache();
                 } else {
                     currentSnapDragDistance += event.dragDistance;
@@ -142,7 +142,7 @@ export class AxisDragGizmo extends Gizmo {
                         currentSnapDragDistance = currentSnapDragDistance % this.snapDistance;
                         event.delta.normalizeToRef(tmpVector);
                         tmpVector.scaleInPlace(this.snapDistance * dragSteps);
-                        this.attachedNode._worldMatrix.addTranslationFromFloats(tmpVector.x, tmpVector.y, tmpVector.z);
+                        this.attachedNode.getWorldMatrix().addTranslationFromFloats(tmpVector.x, tmpVector.y, tmpVector.z);
                         this.attachedNode.updateCache();
                         tmpSnapEvent.snapDistance = this.snapDistance * dragSteps;
                         this.onSnapObservable.notifyObservers(tmpSnapEvent);

+ 4 - 1
src/Gizmos/gizmo.ts

@@ -291,8 +291,11 @@ export class Gizmo implements IDisposable {
                 bone.getWorldMatrix().multiplyToRef(invParent, boneLocalMatrix);
                 var lmat = bone.getLocalMatrix();
                 lmat.copyFrom(boneLocalMatrix);
-                bone.markAsDirty();
+            } else {
+                var lmat = bone.getLocalMatrix();
+                lmat.copyFrom(bone.getWorldMatrix());
             }
+            bone.markAsDirty();
         }
     }