소스 검색

updating hit test

Raanan Weber 5 년 전
부모
커밋
7eeb95281e
3개의 변경된 파일5개의 추가작업 그리고 4개의 파일을 삭제
  1. 5 2
      src/Cameras/XR/features/WebXRHitTest.ts
  2. 0 1
      src/Cameras/XR/features/WebXRPlaneDetector.ts
  3. 0 1
      src/LibDeclarations/webxr.d.ts

+ 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 {