Skip to content

Commit

Permalink
fixed selection bug (#6637)
Browse files Browse the repository at this point in the history
  • Loading branch information
kpal81xd authored and marklundin committed May 31, 2024
1 parent 7bb07c3 commit 9bc5c1a
Showing 1 changed file with 6 additions and 7 deletions.
13 changes: 6 additions & 7 deletions examples/src/examples/misc/gizmos.selector.mjs
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import * as pc from 'playcanvas';

const EPSILON = 1;
class Selector extends pc.EventHandler {
/**
* @type {pc.CameraComponent}
Expand Down Expand Up @@ -64,17 +65,15 @@ class Selector extends pc.EventHandler {
* @private
*/
_onPointerUp(e) {
if (e.clientX !== this._start.x || e.clientY !== this._start.y) {
if (Math.abs(e.clientX - this._start.x) > EPSILON || Math.abs(e.clientY - this._start.y) > EPSILON) {
return;
}

if (this._picker) {
const device = this._picker.device;
this._picker.resize(device.canvas.width, device.canvas.height);
this._picker.prepare(this._camera, this._scene, this._layers);
}
const device = this._picker.device;
this._picker.resize(device.canvas.clientWidth, device.canvas.clientHeight);
this._picker.prepare(this._camera, this._scene, this._layers);

const selection = this._picker.getSelection(e.clientX, e.clientY, 2, 2);
const selection = this._picker.getSelection(e.clientX - 1, e.clientY - 1, 2, 2);

if (!selection[0]) {
this.fire('deselect');
Expand Down

0 comments on commit 9bc5c1a

Please sign in to comment.