Skip to content

Commit 75d87dc

Browse files
authored
Pass through eventState with eventData (#17073)
My last PR (#17055) passed through the `eventData`, but I forgot about the `eventState`. This PR unpacks the `eventState` when notifying gizmo drag observers, along with the `eventData`.
1 parent 748afe1 commit 75d87dc

File tree

3 files changed

+30
-12
lines changed

3 files changed

+30
-12
lines changed

packages/dev/core/src/Gizmos/positionGizmo.ts

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import { Logger } from "../Misc/logger";
2-
import type { Observer } from "../Misc/observable";
2+
import type { EventState, Observer } from "../Misc/observable";
33
import { Observable } from "../Misc/observable";
44
import type { Nullable } from "../types";
55
import { Vector3 } from "../Maths/math.vector";
@@ -210,9 +210,15 @@ export class PositionGizmo extends Gizmo implements IPositionGizmo {
210210
// Relay drag events
211211
const gizmos = [this.xGizmo, this.yGizmo, this.zGizmo, this.xPlaneGizmo, this.yPlaneGizmo, this.zPlaneGizmo];
212212
for (const gizmo of gizmos) {
213-
gizmo.dragBehavior.onDragStartObservable.add(this.onDragStartObservable.notifyObservers.bind(this.onDragStartObservable));
214-
gizmo.dragBehavior.onDragObservable.add(this.onDragObservable.notifyObservers.bind(this.onDragObservable));
215-
gizmo.dragBehavior.onDragEndObservable.add(this.onDragEndObservable.notifyObservers.bind(this.onDragEndObservable));
213+
gizmo.dragBehavior.onDragStartObservable.add((eventData: DragStartEndEvent, eventState: EventState) =>
214+
this.onDragStartObservable.notifyObservers(eventData, eventState.mask, eventState.target, eventState.currentTarget, eventState.userInfo)
215+
);
216+
gizmo.dragBehavior.onDragObservable.add((eventData: DragEvent, eventState: EventState) =>
217+
this.onDragObservable.notifyObservers(eventData, eventState.mask, eventState.target, eventState.currentTarget, eventState.userInfo)
218+
);
219+
gizmo.dragBehavior.onDragEndObservable.add((eventData: DragStartEndEvent, eventState: EventState) =>
220+
this.onDragEndObservable.notifyObservers(eventData, eventState.mask, eventState.target, eventState.currentTarget, eventState.userInfo)
221+
);
216222
}
217223

218224
this.attachedMesh = null;

packages/dev/core/src/Gizmos/rotationGizmo.ts

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import { Logger } from "../Misc/logger";
2-
import type { Observer } from "../Misc/observable";
2+
import type { EventState, Observer } from "../Misc/observable";
33
import { Observable } from "../Misc/observable";
44
import type { Nullable } from "../types";
55
import { Vector3 } from "../Maths/math.vector";
@@ -244,9 +244,15 @@ export class RotationGizmo extends Gizmo implements IRotationGizmo {
244244
if (options && options.updateScale != undefined) {
245245
gizmo.updateScale = options.updateScale;
246246
}
247-
gizmo.dragBehavior.onDragStartObservable.add(this.onDragStartObservable.notifyObservers.bind(this.onDragStartObservable));
248-
gizmo.dragBehavior.onDragObservable.add(this.onDragObservable.notifyObservers.bind(this.onDragObservable));
249-
gizmo.dragBehavior.onDragEndObservable.add(this.onDragEndObservable.notifyObservers.bind(this.onDragEndObservable));
247+
gizmo.dragBehavior.onDragStartObservable.add((eventData: DragStartEndEvent, eventState: EventState) =>
248+
this.onDragStartObservable.notifyObservers(eventData, eventState.mask, eventState.target, eventState.currentTarget, eventState.userInfo)
249+
);
250+
gizmo.dragBehavior.onDragObservable.add((eventData: DragEvent, eventState: EventState) =>
251+
this.onDragObservable.notifyObservers(eventData, eventState.mask, eventState.target, eventState.currentTarget, eventState.userInfo)
252+
);
253+
gizmo.dragBehavior.onDragEndObservable.add((eventData: DragStartEndEvent, eventState: EventState) =>
254+
this.onDragEndObservable.notifyObservers(eventData, eventState.mask, eventState.target, eventState.currentTarget, eventState.userInfo)
255+
);
250256
}
251257

252258
this.attachedMesh = null;

packages/dev/core/src/Gizmos/scaleGizmo.ts

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import { Logger } from "../Misc/logger";
2-
import type { Observer } from "../Misc/observable";
2+
import type { EventState, Observer } from "../Misc/observable";
33
import { Observable } from "../Misc/observable";
44
import type { Nullable } from "../types";
55
import { Vector3 } from "../Maths/math.vector";
@@ -221,9 +221,15 @@ export class ScaleGizmo extends Gizmo implements IScaleGizmo {
221221
// Relay drag events
222222
const gizmos = [this.xGizmo, this.yGizmo, this.zGizmo, this.uniformScaleGizmo];
223223
for (const gizmo of gizmos) {
224-
gizmo.dragBehavior.onDragStartObservable.add(this.onDragStartObservable.notifyObservers.bind(this.onDragStartObservable));
225-
gizmo.dragBehavior.onDragObservable.add(this.onDragObservable.notifyObservers.bind(this.onDragObservable));
226-
gizmo.dragBehavior.onDragEndObservable.add(this.onDragEndObservable.notifyObservers.bind(this.onDragEndObservable));
224+
gizmo.dragBehavior.onDragStartObservable.add((eventData: DragStartEndEvent, eventState: EventState) =>
225+
this.onDragStartObservable.notifyObservers(eventData, eventState.mask, eventState.target, eventState.currentTarget, eventState.userInfo)
226+
);
227+
gizmo.dragBehavior.onDragObservable.add((eventData: DragEvent, eventState: EventState) =>
228+
this.onDragObservable.notifyObservers(eventData, eventState.mask, eventState.target, eventState.currentTarget, eventState.userInfo)
229+
);
230+
gizmo.dragBehavior.onDragEndObservable.add((eventData: DragStartEndEvent, eventState: EventState) =>
231+
this.onDragEndObservable.notifyObservers(eventData, eventState.mask, eventState.target, eventState.currentTarget, eventState.userInfo)
232+
);
227233
}
228234

229235
this.attachedMesh = null;

0 commit comments

Comments
 (0)