Bläddra i källkod

Merge pull request #9062 from CedricGuillemet/fixGizmoBillboardMesh

Disable gizmo rotation when in billboard mode
Raanan Weber 4 år sedan
förälder
incheckning
308eb597df
2 ändrade filer med 16 tillägg och 4 borttagningar
  1. 6 4
      src/Gizmos/gizmo.ts
  2. 10 0
      src/Gizmos/rotationGizmo.ts

+ 6 - 4
src/Gizmos/gizmo.ts

@@ -252,10 +252,12 @@ export class Gizmo implements IDisposable {
             } else {
                 this._attachedNode._worldMatrix.decompose(transform.scaling, this._tempQuaternion, transform.position);
             }
-            if (transform.rotationQuaternion) {
-                transform.rotationQuaternion.copyFrom(this._tempQuaternion);
-            } else {
-                transform.rotation = this._tempQuaternion.toEulerAngles();
+            if (!transform.billboardMode) {
+                if (transform.rotationQuaternion) {
+                    transform.rotationQuaternion.copyFrom(this._tempQuaternion);
+                } else {
+                    transform.rotation = this._tempQuaternion.toEulerAngles();
+                }
             }
         } else if (this._attachedNode.getClassName() === "Bone") {
             var bone = this._attachedNode as Bone;

+ 10 - 0
src/Gizmos/rotationGizmo.ts

@@ -9,6 +9,8 @@ import { Gizmo } from "./gizmo";
 import { PlaneRotationGizmo } from "./planeRotationGizmo";
 import { UtilityLayerRenderer } from "../Rendering/utilityLayerRenderer";
 import { Node } from "../node";
+import { TransformNode } from "../Meshes/transformNode";
+
 /**
  * Gizmo that enables rotating a mesh along 3 axis
  */
@@ -40,6 +42,7 @@ export class RotationGizmo extends Gizmo {
     public set attachedMesh(mesh: Nullable<AbstractMesh>) {
         this._meshAttached = mesh;
         this._nodeAttached = mesh;
+        this._checkBillboardTransform();
         [this.xGizmo, this.yGizmo, this.zGizmo].forEach((gizmo) => {
             if (gizmo.isEnabled) {
                 gizmo.attachedMesh = mesh;
@@ -56,6 +59,7 @@ export class RotationGizmo extends Gizmo {
     public set attachedNode(node: Nullable<Node>) {
         this._meshAttached = null;
         this._nodeAttached = node;
+        this._checkBillboardTransform();
         [this.xGizmo, this.yGizmo, this.zGizmo].forEach((gizmo) => {
             if (gizmo.isEnabled) {
                 gizmo.attachedNode = node;
@@ -66,6 +70,12 @@ export class RotationGizmo extends Gizmo {
         });
     }
 
+    protected _checkBillboardTransform() {
+        if (this._nodeAttached && (<TransformNode>this._nodeAttached).billboardMode) {
+            console.log("Rotation Gizmo will not work with transforms in billboard mode.");
+        }
+    }
+
     /**
      * True when the mouse pointer is hovering a gizmo mesh
      */