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

advancedDynamicTexture picking fixes #10972

Merged
merged 2 commits into from Sep 1, 2021
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
14 changes: 7 additions & 7 deletions gui/src/2D/advancedDynamicTexture.ts
Expand Up @@ -333,7 +333,7 @@ export class AdvancedDynamicTexture extends DynamicTexture {
if (!scene || !this._texture) {
return;
}
this._rootElement = scene.getEngine()!.getInputElement()!;
this._rootElement = scene.getEngine().getInputElement();
this._renderObserver = scene.onBeforeCameraRenderObservable.add((camera: Camera) => this._checkUpdate(camera));
this._preKeyboardObserver = scene.onPreKeyboardObservable.add((info) => {
if (!this._focusedControl) {
Expand Down Expand Up @@ -660,7 +660,10 @@ export class AdvancedDynamicTexture extends DynamicTexture {
var textureSize = this.getSize();
if (this._isFullscreen) {
let camera = scene.cameraToUseForPointers || scene.activeCamera;
let viewport = camera!.viewport;
if (!camera) {
return;
}
let viewport = camera.viewport;
x = x * (textureSize.width / (engine.getRenderWidth() * viewport.width));
y = y * (textureSize.height / (engine.getRenderHeight() * viewport.height));
}
Expand Down Expand Up @@ -706,15 +709,15 @@ export class AdvancedDynamicTexture extends DynamicTexture {
}
/** Attach to all scene events required to support pointer events */
public attach(): void {
var scene = this.getScene();
const scene = this.getScene();
if (!scene) {
return;
}

let tempViewport = new Viewport(0, 0, 0, 0);

this._pointerMoveObserver = scene.onPrePointerObservable.add((pi, state) => {
if (scene!.isPointerCaptured((<IPointerEvent>(pi.event)).pointerId)) {
if (scene.isPointerCaptured((<IPointerEvent>(pi.event)).pointerId)) {
return;
}
if (pi.type !== PointerEventTypes.POINTERMOVE
Expand All @@ -723,9 +726,6 @@ export class AdvancedDynamicTexture extends DynamicTexture {
&& pi.type !== PointerEventTypes.POINTERWHEEL) {
return;
}
if (!scene) {
return;
}

if (pi.type === PointerEventTypes.POINTERMOVE && (pi.event as IPointerEvent).pointerId) {
this._defaultMousePointerId = (pi.event as IPointerEvent).pointerId; // This is required to make sure we have the correct pointer ID for wheel
Expand Down