浏览代码

updating hit test

Raanan Weber 5 年之前
父节点
当前提交
7eeb95281e

+ 5 - 2
src/Cameras/XR/features/WebXRHitTest.ts

@@ -38,8 +38,11 @@ export class WebXRHitTest implements WebXRFeature {
         return this.XRHitTestWithRay(event.frame.session, targetRay, referenceSpace);
     }
 
-    public static XRHitTestWithRay(xrSession: XRSession, xrRay: XRRay, referenceSpace: XRReferenceSpace): Promise<XRHitResult[]> {
-        return xrSession.requestHitTest(xrRay, referenceSpace);
+    public static XRHitTestWithRay(xrSession: XRSession, xrRay: XRRay, referenceSpace: XRReferenceSpace, filter?: (result: XRHitResult) => boolean): Promise<XRHitResult[]> {
+        return xrSession.requestHitTest(xrRay, referenceSpace).then((results) => {
+            const filterFunction = filter || ((result) => !!result.hitMatrix);
+            return results.filter(filterFunction);
+        });
     }
 
     public onHitTestResultObservable: Observable<WebXRHitResults> = new Observable();

+ 0 - 1
src/Cameras/XR/features/WebXRPlaneDetector.ts

@@ -13,7 +13,6 @@ WebXRFeaturesManager.AddWebXRFeature(Name, (xrSessionManager, options) => {
 
 export interface WebXRPlaneDetectorOptions {
     worldParentNode?: TransformNode;
-    // coordinatesSpace?: Space;
 }
 
 export interface WebXRPlane {

+ 0 - 1
src/LibDeclarations/webxr.d.ts

@@ -158,7 +158,6 @@ class XRRay {
 
 interface XRHitResult {
     hitMatrix: Float32Array;
-    plane?: XRPlane;
 }
 
 interface XRAnchor {