@pmndrs/pointer-events
Advanced tools
Comparing version 6.4.10 to 6.4.11
import { Pointer } from './pointer.js'; | ||
import { PointerEvent } from './event.js'; | ||
import { CameraRayIntersector } from './intersections/ray.js'; | ||
import { ScreenRayIntersector } from './intersections/ray.js'; | ||
import { generateUniquePointerId } from './pointer/index.js'; | ||
@@ -49,3 +49,3 @@ function htmlEventToCoords(element, e, target) { | ||
} | ||
innerPointer = new Pointer(generateUniquePointerId(), `${pointerTypePrefix}${event.pointerType}`, event.pointerState, new CameraRayIntersector((nativeEvent, coords) => { | ||
innerPointer = new Pointer(generateUniquePointerId(), `${pointerTypePrefix}${event.pointerType}`, event.pointerState, new ScreenRayIntersector((nativeEvent, coords) => { | ||
toCoords(nativeEvent, coords); | ||
@@ -52,0 +52,0 @@ return getCamera(); |
@@ -1,2 +0,2 @@ | ||
import { Intersection as ThreeIntersection, Quaternion, Vector3 } from 'three'; | ||
import { Intersection as ThreeIntersection, Quaternion, Vector3, Vector2 } from 'three'; | ||
export type Intersection = ThreeIntersection & { | ||
@@ -16,4 +16,11 @@ pointerPosition: Vector3; | ||
} | { | ||
type: 'camera-ray'; | ||
type: 'screen-ray'; | ||
/** | ||
* distance to the near plane of the camera of the screen | ||
*/ | ||
distanceViewPlane: number; | ||
/** | ||
* point on the screen for x and y from -1 to 1 | ||
*/ | ||
screenPoint: Vector2; | ||
} | { | ||
@@ -20,0 +27,0 @@ type: 'ray'; |
@@ -27,3 +27,3 @@ import { Vector3, Object3D, Camera, Vector2 } from 'three'; | ||
} | ||
export declare class CameraRayIntersector implements Intersector { | ||
export declare class ScreenRayIntersector implements Intersector { | ||
private readonly prepareTransformation; | ||
@@ -30,0 +30,0 @@ private readonly options; |
@@ -106,3 +106,3 @@ import { Matrix4, Plane, Quaternion, Raycaster, Vector3, Vector2, Mesh, } from 'three'; | ||
} | ||
export class CameraRayIntersector { | ||
export class ScreenRayIntersector { | ||
prepareTransformation; | ||
@@ -126,3 +126,3 @@ options; | ||
const details = intersection.details; | ||
if (details.type != 'camera-ray') { | ||
if (details.type != 'screen-ray') { | ||
throw new Error(`unable to process a pointer capture of type "${intersection.details.type}" with a camera ray intersector`); | ||
@@ -179,3 +179,3 @@ } | ||
if (intersection == null) { | ||
return voidObjectIntersectionFromRay(scene, this.raycaster.ray, (distance) => ({ type: 'camera-ray', distanceViewPlane: distance }), pointerPosition, pointerQuaternion); | ||
return voidObjectIntersectionFromRay(scene, this.raycaster.ray, (distance) => ({ type: 'screen-ray', distanceViewPlane: distance, screenPoint: this.coords.clone() }), pointerPosition, pointerQuaternion); | ||
} | ||
@@ -186,4 +186,5 @@ intersection.object.updateWorldMatrix(true, false); | ||
details: { | ||
type: 'camera-ray', | ||
type: 'screen-ray', | ||
distanceViewPlane: this.viewPlane.distanceToPoint(intersection.point), | ||
screenPoint: this.coords.clone(), | ||
}, | ||
@@ -190,0 +191,0 @@ pointOnFace: intersection.point, |
@@ -5,3 +5,3 @@ { | ||
"license": "SEE LICENSE IN LICENSE", | ||
"version": "6.4.10", | ||
"version": "6.4.11", | ||
"homepage": "https://github.com/pmndrs/xr", | ||
@@ -8,0 +8,0 @@ "author": "Bela Bohlender", |
103962
2489