| 605 | * }; |
| 606 | */ |
| 607 | export function globalToLocal(x: number, y: number, v?: Vector2d): Vector2d { |
| 608 | v = v || vector2dPool.get(); |
| 609 | const rect = device.getElementBounds(_app.renderer.getCanvas()); |
| 610 | const pixelRatio = globalThis.devicePixelRatio || 1; |
| 611 | x -= rect.left + (globalThis.pageXOffset || 0); |
| 612 | y -= rect.top + (globalThis.pageYOffset || 0); |
| 613 | const scale = _app.renderer.scaleRatio; |
| 614 | if (scale.x !== 1.0 || scale.y !== 1.0) { |
| 615 | x /= scale.x; |
| 616 | y /= scale.y; |
| 617 | } |
| 618 | return v.set(x * pixelRatio, y * pixelRatio); |
| 619 | } |
| 620 | |
| 621 | /** |
| 622 | * enable/disable all gestures on the given element.<br> |