Skip to content

Fix container point out of map #2433

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

Merged
merged 3 commits into from
Sep 29, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
3 changes: 1 addition & 2 deletions src/geometry/ext/Geometry.Drag.ts
Original file line number Diff line number Diff line change
Expand Up @@ -210,8 +210,7 @@ class GeometryDragHandler extends Handler {
if (domEvent.touches && domEvent.touches.length > 1) {
return;
}
const visualHeight = map._getVisualHeight(map.options['maxVisualPitch']);
if (e.containerPoint.y < map.height - visualHeight) {
if (map._isContainerPointOutOfMap(e.containerPoint)) {
return;
}
if (!this._moved) {
Expand Down
24 changes: 11 additions & 13 deletions src/map/Map.DomEvents.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ import {
import Map from './Map';
import { Coordinate, Point } from '../geo';
import Ray from '../core/math/Ray';
import * as vec3 from '../core/util/vec3';

declare module "./Map" {
interface Map {
Expand Down Expand Up @@ -374,31 +373,30 @@ Map.include(/** @lends Map.prototype */ {
const from: Vector3 = [0, 0, 0];
const to: Vector3 = [0, 0, 0];
const ray = new Ray(from, to);
const target: Vector3 = [0, 0, 0];
const fromGround : Vector3 = [0, 0, 0];
// const fromGround : Vector3 = [0, 0, 0];
const rayOnGround: Vector3 = [0, 0, 0];

return function (containerPoint: Point) {
const pitch = this.getPitch();
if (pitch > PITCH_TO_CHECK[0] && pitch < PITCH_TO_CHECK[1]) {
this.getContainerPointRay(from, to, containerPoint, 0, 0.5);
ray.setFromTo(from, to);
const intersection = ray.intersectGround(target);
if (intersection === null) {
const intersection = ray.intersectGround(rayOnGround);
if (!intersection) {
return true;
}
const t = ray.distanceToGround();
if (t <= 0) {
return true;
}
const dir = ray.direction;
vec3.set(fromGround, from[0], from[1], 0);
vec3.sub(rayOnGround, fromGround, rayOnGround);
vec3.normalize(rayOnGround, rayOnGround);
const dot = vec3.dot(dir, rayOnGround);
const angle = Math.abs(Math.acos(dot));
// 如果鼠标射线与地面的角度小于设定度数,则认为
return angle <= 30 * Math.PI / 180;
// const dir = ray.direction;
// vec3.set(fromGround, from[0], from[1], 0);
// vec3.sub(rayOnGround, fromGround, rayOnGround);
// vec3.normalize(rayOnGround, rayOnGround);
// const dot = vec3.dot(dir, rayOnGround);
// const angle = Math.abs(Math.acos(dot));
// // 如果鼠标射线与地面的角度小于设定度数,则认为
// return Math.PI - angle < 1 * Math.PI / 180;
}
return false;
}
Expand Down