|
@@ -52,7 +52,7 @@ module BABYLON {
|
|
|
// Add drag behavior to handle events when the gizmo is dragged
|
|
|
this.dragBehavior = new PointerDragBehavior({dragPlaneNormal: planeNormal});
|
|
|
this.dragBehavior.moveAttached = false;
|
|
|
- this.dragBehavior.maxDragAngle = Math.PI*4/10;
|
|
|
+ this.dragBehavior.maxDragAngle = Math.PI*9/20;
|
|
|
this.dragBehavior._useAlternatePickedPointAboveMaxDragAngle = true;
|
|
|
this._rootMesh.addBehavior(this.dragBehavior);
|
|
|
|
|
@@ -73,7 +73,7 @@ module BABYLON {
|
|
|
this.dragBehavior.onDragObservable.add((event)=>{
|
|
|
if(this.attachedMesh){
|
|
|
if(!this.attachedMesh.rotationQuaternion){
|
|
|
- this.attachedMesh.rotationQuaternion = new BABYLON.Quaternion();
|
|
|
+ this.attachedMesh.rotationQuaternion = Quaternion.RotationYawPitchRoll(this.attachedMesh.rotation.y, this.attachedMesh.rotation.x, this.attachedMesh.rotation.z);
|
|
|
}
|
|
|
// Calc angle over full 360 degree (https://stackoverflow.com/questions/43493711/the-angle-between-two-3d-vectors-with-a-result-range-0-360)
|
|
|
var newVector = event.dragPlanePoint.subtract(this.attachedMesh.position).normalize();
|
|
@@ -115,8 +115,14 @@ module BABYLON {
|
|
|
var quaternionCoefficient = Math.sin(angle/2)
|
|
|
var amountToRotate = new BABYLON.Quaternion(planeNormalTowardsCamera.x*quaternionCoefficient,planeNormalTowardsCamera.y*quaternionCoefficient,planeNormalTowardsCamera.z*quaternionCoefficient,Math.cos(angle/2));
|
|
|
|
|
|
- // Rotate selected mesh quaternion over fixed axis
|
|
|
- this.attachedMesh.rotationQuaternion.multiplyToRef(amountToRotate,this.attachedMesh.rotationQuaternion);
|
|
|
+ if(this.updateGizmoRotationToMatchAttachedMesh){
|
|
|
+ // Rotate selected mesh quaternion over fixed axis
|
|
|
+ this.attachedMesh.rotationQuaternion.multiplyToRef(amountToRotate,this.attachedMesh.rotationQuaternion);
|
|
|
+ }else{
|
|
|
+ // Rotate selected mesh quaternion over rotated axis
|
|
|
+ amountToRotate.multiplyToRef(this.attachedMesh.rotationQuaternion,this.attachedMesh.rotationQuaternion);
|
|
|
+ }
|
|
|
+
|
|
|
|
|
|
lastDragPosition.copyFrom(event.dragPlanePoint);
|
|
|
if(snapped){
|