소스 검색

Apply suggestions from code review

Co-authored-by: Ryan Tremblay <ryantrem@msn.com>
Alex-MSFT 5 년 전
부모
커밋
c0f10cb06b
2개의 변경된 파일18개의 추가작업 그리고 9개의 파일을 삭제
  1. 8 4
      src/LibDeclarations/NativeExtensions/FeaturePoints.md
  2. 10 5
      src/XR/features/WebXRFeaturePointSystem.ts

+ 8 - 4
src/LibDeclarations/NativeExtensions/FeaturePoints.md

@@ -3,7 +3,8 @@
 This document proposes an API for exposing Feature Point Clouds for WebXR.
 
 ## Overview
-The API is synchronous, and on demand.  When served a new XRFrame the consuming app may query for the current feature point cloud for a given frame. As feature points comprise a large set of raw data it is best not to expose this to the JS application unless needed for app processing, so feature points must be requested handled in an on-demand fashion in order to reduce the amount of data presented to the consuming app, which must set its own frequency for updating its world understanding.
+The API is synchronous, and on demand.  When served a new XRFrame the consuming app may query for the current feature point cloud for a given frame. As feature points comprise a large set of raw data it is best not to expose this to the JS application unless needed for app processing, so feature points must be requested in an on-demand fashion in order to reduce the amount of data presented to the consuming app, which must set its own frequency for updating its world understanding.
+
 
 The returned array will contain the feature point cloud tracked in the current frame, including points that may not be currently visible.  Feature points will be presented in a flat array of numbers where each point is presented as a set of 5 entries representing the X, Y, Z position in world space, the confidence value, and an ID that is durable across frames.
 
@@ -25,9 +26,11 @@ interface XRFrame {
 ## BabylonJS Integration proposal
 As a native extension of for Babylon.js that is not yet available or proposed for browsers this will be exposed through a new webxr.nativeextensions.d.ts file that will extend the interface to include the new attribute to separate the non-normative WebXR features from experimental native features.
 
-A new WebXRFeaturePointSystem class extending WebXRAbstractFeature will be added to the list of available features.
+A new `WebXRFeaturePointSystem` class extending `WebXRAbstractFeature` will be added to the list of available features.
+
+
+The `WebXRFeaturePoints` class exposes the feature:
 
-The WebXRFeaturePoints class exposes the feature:
 ```typescript
 class WebXRFeaturePointSystem extends WebXRAbstractFeature {
   public static readonly Name = WebXRFeatureName.FEATURE_POINTS;
@@ -50,7 +53,8 @@ class WebXRFeaturePointSystem extends WebXRAbstractFeature {
 }
 ```
 
-The IWebXRFeaturePoint interface describes a given feature point.
+The `IWebXRFeaturePoint` interface describes a given feature point.
+
 ```typescript
  interface IWebXRFeaturePoint {
   point : Vector3;

+ 10 - 5
src/XR/features/WebXRFeaturePointSystem.ts

@@ -46,7 +46,8 @@ export class WebXRFeaturePointSystem extends WebXRAbstractFeature {
      * Observers registered here will be executed whenever new feature points are available (on XRFrame while the session is tracking).
      * Will notify the observers about which feature points have been updated.
      */
-    public onFeaturePointsUpdatedObservable: Observable<number[]> = new Observable();
+    public readonly onFeaturePointsUpdatedObservable: Observable<number[]> = new Observable();
+
     /**
      * The currrent feature point cloud maintained across frames.
      */
@@ -99,15 +100,19 @@ export class WebXRFeaturePointSystem extends WebXRAbstractFeature {
         if (!this.attached || !this._enabled || !frame) {
             return;
         }
-        let featurePointRawData : number[] | undefined = frame.featurePointCloud;
+        const featurePointRawData: Nullable<number[]> = frame.featurePointCloud;
+
         if (!featurePointRawData || featurePointRawData.length == 0) {
             return;
         } else {
-            let numberOfFeaturePoints : number = featurePointRawData.length / 5;
+            const numberOfFeaturePoints : number = featurePointRawData.length / 5;
+
             let updatedFeaturePoints = new Array(numberOfFeaturePoints);
             for (var i = 0; i < numberOfFeaturePoints; i++) {
-                let rawIndex : number = i * 5;
-                let id = featurePointRawData[rawIndex + 4];
+                const rawIndex: number = i * 5;
+
+                const id = featurePointRawData[rawIndex + 4];
+
                 updatedFeaturePoints[i] = id;
 
                 // IDs should be durable across frames and strictly increasing from 0 up, so use them as indexing into the feature point array.