Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions dist/preview release/what's new.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
- Added support for dual shock gamepads ([Deltakosh](https://github.com/deltakosh/))
- Support Vive Focus 3Dof controller ([TrevorDev](https://github.com/TrevorDev))
- Planar positioning support for GizmoManager ([Balupg](https://github.com/balupg))
- ScaleGizmo and AxisScaleGizmo sensitivity factor ([CedricGuillemet](https://github.com/CedricGuillemet))
- Individual gizmos can now be enabled/disabled ([Balupg](https://github.com/balupg))
- Unify preparation of instance attributes. Added `MaterialHelper.PushAttributesForInstances` ([MarkusBillharz](https://github.com/MarkusBillharz))
- Added support for PBR [irradiance map](https://doc.babylonjs.com/how_to/physically_based_rendering_master#irradiance-map)
Expand Down
6 changes: 5 additions & 1 deletion src/Gizmos/axisScaleGizmo.ts
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,10 @@ export class AxisScaleGizmo extends Gizmo {
* If the scaling operation should be done on all axis (default: false)
*/
public uniformScaling = false;
/**
* Custom sensitivity value for the drag strength
*/
public sensitivity = 1;

private _isEnabled: boolean = true;
private _parent: Nullable<ScaleGizmo> = null;
Expand Down Expand Up @@ -92,7 +96,7 @@ export class AxisScaleGizmo extends Gizmo {
this.dragBehavior.onDragObservable.add((event) => {
if (this.attachedMesh) {
// Drag strength is modified by the scale of the gizmo (eg. for small objects like boombox the strength will be increased to match the behavior of larger objects)
var dragStrength = event.dragDistance * ((this.scaleRatio * 3) / this._rootMesh.scaling.length());
var dragStrength = this.sensitivity * event.dragDistance * ((this.scaleRatio * 3) / this._rootMesh.scaling.length());

// Snapping logic
var snapped = false;
Expand Down
16 changes: 16 additions & 0 deletions src/Gizmos/scaleGizmo.ts
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ export class ScaleGizmo extends Gizmo {
private _scaleRatio: number;
private _uniformScalingMesh: Mesh;
private _octahedron: Mesh;
private _sensitivity: number = 1;

/** Fires an event when any of it's sub gizmos are dragged */
public onDragStartObservable = new Observable();
Expand Down Expand Up @@ -141,6 +142,21 @@ export class ScaleGizmo extends Gizmo {
return this._scaleRatio;
}

/**
* Sensitivity factor for dragging (Default: 1)
*/
public set sensitivity(value: number) {
this._sensitivity = value;
[this.xGizmo, this.yGizmo, this.zGizmo, this.uniformScaleGizmo].forEach((gizmo) => {
if (gizmo) {
gizmo.sensitivity = value;
}
});
}
public get sensitivity() {
return this._sensitivity;
}

/**
* Disposes of the gizmo
*/
Expand Down