Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Implement Lazy Picking for POINTERMOVE #13044

Merged
merged 29 commits into from
Oct 17, 2022
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
29 commits
Select commit Hold shift + click to select a range
bf65e33
Lazy Pick on Move
PolygonalSun Sep 8, 2022
07785a7
Change to account for undefined
PolygonalSun Sep 8, 2022
757a531
cameras using DSM
PolygonalSun Sep 8, 2022
5c4cd98
Check for reasons to pick before picking
PolygonalSun Sep 8, 2022
ec05176
Addressed some feedback (missing meshUnderPointer)
PolygonalSun Sep 15, 2022
2fbd9db
Modified get meshUnderPointer
PolygonalSun Sep 16, 2022
166a60c
Add frame awareness picking for move
PolygonalSun Sep 17, 2022
a81875c
Merge branch 'master' into input-perf-test
PolygonalSun Sep 20, 2022
fa70f57
Caching Test
PolygonalSun Sep 27, 2022
d7d0986
Merge branch 'master' into input-perf-test
PolygonalSun Sep 27, 2022
b4db311
format
PolygonalSun Sep 27, 2022
0502afa
Merge branch 'input-perf-test' of https://github.com/PolygonalSun/Bab…
PolygonalSun Sep 27, 2022
fdf4934
Merge branch 'master' into input-perf-test
PolygonalSun Sep 28, 2022
568d43a
import fix
PolygonalSun Sep 28, 2022
5dd409d
Removed test code
PolygonalSun Sep 28, 2022
85c814f
PR Feedback
PolygonalSun Oct 6, 2022
0ccc7a2
fixed import
PolygonalSun Oct 6, 2022
a0ffe9c
removed gesture recognizer and reverted inputs
PolygonalSun Oct 7, 2022
51ee8cd
Revert videoDome because it uses picking info
PolygonalSun Oct 7, 2022
a9801ee
formatting
PolygonalSun Oct 7, 2022
3aab516
Changed to just MOVE Lazy Picking
PolygonalSun Oct 12, 2022
ee240e5
Format
PolygonalSun Oct 12, 2022
a3e5370
Removed comment
PolygonalSun Oct 12, 2022
f032d99
PR Feedback
PolygonalSun Oct 14, 2022
4a29d5a
Re-added meshunderpointer code back
PolygonalSun Oct 14, 2022
7b42a02
More feedback
PolygonalSun Oct 14, 2022
4d5dc2c
Comment
PolygonalSun Oct 14, 2022
eba0051
PR Feedback part 1
PolygonalSun Oct 17, 2022
dc3c171
comment
PolygonalSun Oct 17, 2022
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
Prev Previous commit
Next Next commit
removed gesture recognizer and reverted inputs
  • Loading branch information
PolygonalSun committed Oct 7, 2022
commit a0ffe9c429bae513babda1040557823e9aafdaea
54 changes: 15 additions & 39 deletions packages/dev/core/src/Cameras/Inputs/BaseCameraMouseWheelInput.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,11 @@ import type { Observer } from "../../Misc/observable";
import { Observable } from "../../Misc/observable";
import type { Camera } from "../../Cameras/camera";
import type { ICameraInput } from "../../Cameras/cameraInputsManager";
import type { IPointerEvent, IWheelEvent } from "../../Events/deviceInputEvents";
import type { PointerInfo } from "../../Events/pointerEvents";
import { PointerEventTypes } from "../../Events/pointerEvents";
import type { IWheelEvent } from "../../Events/deviceInputEvents";
import { EventConstants } from "../../Events/deviceInputEvents";
import { Tools } from "../../Misc/tools";
import type { DeviceSourceType } from "../../DeviceInput/internalDeviceSourceManager";
import { DeviceType } from "../../DeviceInput/InputDevices/deviceEnums";
import { GestureRecognizer } from "../../DeviceInput/gestureRecognizer";
import { PointerEventTypes } from "../../Events/pointerEvents";
import { Logger } from "../../Misc/logger";

/**
* Base class for mouse wheel input..
Expand Down Expand Up @@ -50,10 +47,8 @@ export abstract class BaseCameraMouseWheelInput implements ICameraInput<Camera>
*/
public onChangedObservable = new Observable<{ wheelDeltaX: number; wheelDeltaY: number; wheelDeltaZ: number }>();

private _wheel: (event: IWheelEvent) => void;
private _observer: Nullable<Observer<IPointerEvent | IWheelEvent>>;
private _connectedObserver: Nullable<Observer<DeviceSourceType>>;
private _disconnectedObserver: Nullable<Observer<DeviceSourceType>>;
private _wheel: Nullable<(pointer: PointerInfo) => void>;
private _observer: Nullable<Observer<PointerInfo>>;

/**
* Attach the input controls to a specific dom element to get the input from.
Expand All @@ -62,34 +57,16 @@ export abstract class BaseCameraMouseWheelInput implements ICameraInput<Camera>
* (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
*/
public attachControl(noPreventDefault?: boolean): void {
const deviceSourceManager = this.camera._deviceSourceManager;
// If the user tries to attach this control without having general camera controls active, warn and return.
if (!deviceSourceManager) {
Logger.Warn("Cannot attach control to camera. Camera controls not present");
return;
}

noPreventDefault = Tools.BackCompatCameraNoPreventDefault(arguments);

this._connectedObserver = deviceSourceManager.onDeviceConnectedObservable.add((deviceSource) => {
if (deviceSource.deviceType === DeviceType.Mouse) {
this._observer = deviceSource.onInputChangedObservable.add((eventData) => {
const type = GestureRecognizer.DeterminePointerEventType(deviceSource, eventData);
if (type & PointerEventTypes.POINTERWHEEL) {
this._wheel(eventData as IWheelEvent);
}
});
this._wheel = (pointer) => {
// sanity check - this should be a PointerWheel event.
if (pointer.type !== PointerEventTypes.POINTERWHEEL) {
return;
}
});

this._disconnectedObserver = deviceSourceManager.onDeviceDisconnectedObservable.add((deviceSource) => {
if (deviceSource.deviceType === DeviceType.Mouse) {
deviceSource.onInputChangedObservable.remove(this._observer);
this._observer = null;
}
});
const event = <IWheelEvent>pointer.event;

this._wheel = (event) => {
const platformScale = event.deltaMode === EventConstants.DOM_DELTA_LINE ? this._ffMultiplier : 1; // If this happens to be set to DOM_DELTA_LINE, adjust accordingly

this._wheelDeltaX += (this.wheelPrecisionX * platformScale * event.deltaX) / this._normalize;
Expand All @@ -102,19 +79,18 @@ export abstract class BaseCameraMouseWheelInput implements ICameraInput<Camera>
}
}
};

this._observer = this.camera._addPointerObserver(this._wheel, PointerEventTypes.POINTERWHEEL);
}

/**
* Detach the current controls from the specified dom element.
*/
public detachControl(): void {
const deviceSourceManager = this.camera._deviceSourceManager;
if (deviceSourceManager && this._observer) {
deviceSourceManager.onDeviceConnectedObservable.remove(this._connectedObserver);
deviceSourceManager.onDeviceDisconnectedObservable.remove(this._disconnectedObserver);
const mouse = deviceSourceManager.getDeviceSource(DeviceType.Mouse);
mouse?.onInputChangedObservable.remove(this._observer);
if (this._observer) {
this.camera.getScene().onPointerObservable.remove(this._observer);
this._observer = null;
this._wheel = null;
}
if (this.onChangedObservable) {
this.onChangedObservable.clear();
Expand Down
Loading