|
@@ -45,8 +45,9 @@ export class PlaneRotationGizmo extends Gizmo {
|
|
* @param planeNormal The normal of the plane which the gizmo will be able to rotate on
|
|
* @param planeNormal The normal of the plane which the gizmo will be able to rotate on
|
|
* @param color The color of the gizmo
|
|
* @param color The color of the gizmo
|
|
* @param tessellation Amount of tessellation to be used when creating rotation circles
|
|
* @param tessellation Amount of tessellation to be used when creating rotation circles
|
|
|
|
+ * @param useEulerRotation Use and update Euler angle instead of quaternion
|
|
*/
|
|
*/
|
|
- constructor(planeNormal: Vector3, color: Color3 = Color3.Gray(), gizmoLayer: UtilityLayerRenderer = UtilityLayerRenderer.DefaultUtilityLayer, tessellation = 32, parent: Nullable<RotationGizmo> = null) {
|
|
|
|
|
|
+ constructor(planeNormal: Vector3, color: Color3 = Color3.Gray(), gizmoLayer: UtilityLayerRenderer = UtilityLayerRenderer.DefaultUtilityLayer, tessellation = 32, parent: Nullable<RotationGizmo> = null, useEulerRotation = false) {
|
|
super(gizmoLayer);
|
|
super(gizmoLayer);
|
|
this._parent = parent;
|
|
this._parent = parent;
|
|
// Create Material
|
|
// Create Material
|
|
@@ -100,7 +101,7 @@ export class PlaneRotationGizmo extends Gizmo {
|
|
var amountToRotate = new Quaternion();
|
|
var amountToRotate = new Quaternion();
|
|
this.dragBehavior.onDragObservable.add((event) => {
|
|
this.dragBehavior.onDragObservable.add((event) => {
|
|
if (this.attachedMesh) {
|
|
if (this.attachedMesh) {
|
|
- if (!this.attachedMesh.rotationQuaternion) {
|
|
|
|
|
|
+ if (!this.attachedMesh.rotationQuaternion || useEulerRotation) {
|
|
this.attachedMesh.rotationQuaternion = Quaternion.RotationYawPitchRoll(this.attachedMesh.rotation.y, this.attachedMesh.rotation.x, this.attachedMesh.rotation.z);
|
|
this.attachedMesh.rotationQuaternion = Quaternion.RotationYawPitchRoll(this.attachedMesh.rotation.y, this.attachedMesh.rotation.x, this.attachedMesh.rotation.z);
|
|
}
|
|
}
|
|
|
|
|
|
@@ -176,6 +177,12 @@ export class PlaneRotationGizmo extends Gizmo {
|
|
amountToRotate.multiplyToRef(this.attachedMesh.rotationQuaternion, this.attachedMesh.rotationQuaternion);
|
|
amountToRotate.multiplyToRef(this.attachedMesh.rotationQuaternion, this.attachedMesh.rotationQuaternion);
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+ if (useEulerRotation) {
|
|
|
|
+ this.attachedMesh.rotationQuaternion.toEulerAnglesToRef(tmpVector);
|
|
|
|
+ this.attachedMesh.rotationQuaternion = null;
|
|
|
|
+ this.attachedMesh.rotation.copyFrom(tmpVector);
|
|
|
|
+ }
|
|
|
|
+
|
|
lastDragPosition.copyFrom(event.dragPlanePoint);
|
|
lastDragPosition.copyFrom(event.dragPlanePoint);
|
|
if (snapped) {
|
|
if (snapped) {
|
|
tmpSnapEvent.snapDistance = angle;
|
|
tmpSnapEvent.snapDistance = angle;
|