Преглед изворни кода

fixing linting and doc issues

Raanan Weber пре 5 година
родитељ
комит
82421ee04a

+ 7 - 1
src/Cameras/XR/features/WebXRAnchorSystem.ts

@@ -119,6 +119,8 @@ export class WebXRAnchorSystem implements WebXRFeature {
     /**
      * attach this feature
      * Will usually be called by the features manager
+     *
+     * @returns true if successful.
      */
     attach(): boolean {
         this._observerTracked = this.xrSessionManager.onXRFrameObservable.add(() => {
@@ -168,6 +170,8 @@ export class WebXRAnchorSystem implements WebXRFeature {
     /**
      * detach this feature.
      * Will usually be called by the features manager
+     *
+     * @returns true if successful.
      */
     detach(): boolean {
         this._attached = false;
@@ -215,11 +219,13 @@ export class WebXRAnchorSystem implements WebXRFeature {
     }
 
     /**
+     * Add anchor at a specific XR point.
      *
      * @param xrRigidTransformation xr-coordinates where a new anchor should be added
      * @param anchorCreator the object o use to create an anchor with. either a session or a plane
+     * @returns a promise the fulfills when the anchor was created
      */
-    public addAnchorAtRigidTransformation(xrRigidTransformation: XRRigidTransform, anchorCreator?: XRAnchorCreator) {
+    public addAnchorAtRigidTransformation(xrRigidTransformation: XRRigidTransform, anchorCreator?: XRAnchorCreator): Promise<XRAnchor> {
         const creator = anchorCreator || this.xrSessionManager.session;
         return creator.createAnchor(xrRigidTransformation, this.xrSessionManager.referenceSpace);
     }

+ 4 - 0
src/Cameras/XR/features/WebXRBackgroundRemover.ts

@@ -70,6 +70,8 @@ export class WebXRBackgroundRemover implements WebXRFeature {
     /**
      * attach this feature
      * Will usually be called by the features manager
+     *
+     * @returns true if successful.
      */
     attach(): boolean {
         this.setBackgroundState(false);
@@ -80,6 +82,8 @@ export class WebXRBackgroundRemover implements WebXRFeature {
     /**
      * detach this feature.
      * Will usually be called by the features manager
+     *
+     * @returns true if successful.
      */
     detach(): boolean {
         this.setBackgroundState(true);

+ 8 - 2
src/Cameras/XR/features/WebXRHitTestLegacy.ts

@@ -6,9 +6,9 @@ import { TransformNode } from '../../../Meshes/transformNode';
 import { Nullable } from '../../../types';
 
 /**
- * exported name of module (can be reused with other versions)
+ * name of module (can be reused with other versions)
  */
-export const WebXRHitTestModuleName = "xr-hit-test";
+const WebXRHitTestModuleName = "xr-hit-test";
 
 // the plugin is registered at the end of the file
 
@@ -62,6 +62,7 @@ export class WebXRHitTestLegacy implements WebXRFeature {
      * Execute a hit test on the current running session using a select event returned from a transient input (such as touch)
      * @param event the (select) event to use to select with
      * @param referenceSpace the reference space to use for this hit test
+     * @returns a promise that resolves with an array of native XR hit result in xr coordinates system
      */
     public static XRHitTestWithSelectEvent(event: XRInputSourceEvent, referenceSpace: XRReferenceSpace): Promise<XRHitResult[]> {
         let targetRayPose = event.frame.getPose(event.inputSource.targetRaySpace, referenceSpace);
@@ -74,6 +75,7 @@ export class WebXRHitTestLegacy implements WebXRFeature {
     }
 
     /**
+     * execute a hit test with an XR Ray
      *
      * @param xrSession a native xrSession that will execute this hit test
      * @param xrRay the ray (position and direction) to use for raycasting
@@ -116,6 +118,8 @@ export class WebXRHitTestLegacy implements WebXRFeature {
     /**
      * attach this feature
      * Will usually be called by the features manager
+     *
+     * @returns true if successful.
      */
     attach(): boolean {
         if (this.options.testOnPointerDownOnly) {
@@ -153,6 +157,8 @@ export class WebXRHitTestLegacy implements WebXRFeature {
     /**
      * detach this feature.
      * Will usually be called by the features manager
+     *
+     * @returns true if successful.
      */
     detach(): boolean {
         // disable select

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

@@ -11,6 +11,9 @@ const Name = "xr-plane-detector";
  * Options used in the plane detector module
  */
 export interface WebXRPlaneDetectorOptions {
+    /**
+     * The node to use to transform the local results to world coordinates
+     */
     worldParentNode?: TransformNode;
 }
 
@@ -78,7 +81,7 @@ export class WebXRPlaneDetector implements WebXRFeature {
     private _observerTracked: Nullable<Observer<XRFrame>>;
 
     /**
-     *
+     * construct a new Plane Detector
      * @param xrSessionManager an instance of xr Session manager
      * @param options configuration to use when constructing this feature
      */
@@ -97,6 +100,8 @@ export class WebXRPlaneDetector implements WebXRFeature {
     /**
      * attach this feature
      * Will usually be called by the features manager
+     *
+     * @returns true if successful.
      */
     attach(): boolean {
 
@@ -144,6 +149,8 @@ export class WebXRPlaneDetector implements WebXRFeature {
     /**
      * detach this feature.
      * Will usually be called by the features manager
+     *
+     * @returns true if successful.
      */
     detach(): boolean {
         this._attached = false;

+ 1 - 0
src/Cameras/XR/webXRExperienceHelper.ts

@@ -43,6 +43,7 @@ export class WebXRExperienceHelper implements IDisposable {
     /** Session manager used to keep track of xr session */
     public sessionManager: WebXRSessionManager;
 
+    /** A features manager for this xr session */
     public featuresManager: WebXRFeaturesManager;
 
     private _nonVRCamera: Nullable<Camera> = null;

+ 7 - 4
src/Cameras/XR/webXRFeaturesManager.ts

@@ -8,11 +8,15 @@ export interface WebXRFeature extends IDisposable {
     /**
      * Attach the feature to the session
      * Will usually be called by the features manager
+     *
+     * @returns true if successful.
      */
     attach(): boolean;
     /**
      * Detach the feature from the session
      * Will usually be called by the features manager
+     *
+     * @returns true if successful.
      */
     detach(): boolean;
 }
@@ -81,7 +85,6 @@ export class WebXRFeaturesManager implements IDisposable {
      * Return the latest unstable version of this feature
      * @param featureName the name of the feature to search
      * @returns the version number. if not found will return -1
-     * @static
      */
     public static GetLatestVersionOfFeature(featureName: string): number {
         return (this._AvailableFeatures[featureName] && this._AvailableFeatures[featureName].latest) || -1;
@@ -91,7 +94,6 @@ export class WebXRFeaturesManager implements IDisposable {
      * Return the latest stable version of this feature
      * @param featureName the name of the feature to search
      * @returns the version number. if not found will return -1
-     * @static
      */
     public static GetStableVersionOfFeature(featureName: string): number {
         return (this._AvailableFeatures[featureName] && this._AvailableFeatures[featureName].stable) || -1;
@@ -100,7 +102,6 @@ export class WebXRFeaturesManager implements IDisposable {
     /**
      * Can be used to return the list of features currently registered
      *
-     * @static
      * @returns an Array of available features
      */
     public static GetAvailableFeatures() {
@@ -213,6 +214,7 @@ export class WebXRFeaturesManager implements IDisposable {
     /**
      * Used to disable an already-enabled feature
      * @param featureName the feature to disable
+     * @returns true if disable was successful
      */
     public disableFeature(featureName: string | { Name: string }): boolean {
         const name = typeof featureName === 'string' ? featureName : featureName.Name;
@@ -261,8 +263,9 @@ export class WebXRFeaturesManager implements IDisposable {
     /**
      * get the implementation of an enabled feature.
      * @param featureName the name of the feature to load
+     * @returns the feature class, if found
      */
-    public getEnabledFeature(featureName: string) {
+    public getEnabledFeature(featureName: string): WebXRFeature {
         return this._features[featureName] && this._features[featureName].featureImplementation;
     }
 

+ 1 - 0
src/Cameras/XR/webXRSessionManager.ts

@@ -56,6 +56,7 @@ export class WebXRSessionManager implements IDisposable {
      */
     public currentFrame: Nullable<XRFrame>;
 
+    /** WebXR timestamp updated every frame */
     public currentTimestamp: number = -1;
 
     private _xrNavigator: any;

+ 7 - 7
src/LibDeclarations/webxr.d.ts

@@ -69,8 +69,8 @@ interface XRSession extends XRAnchorCreator {
     requestHitTest(ray: XRRay, referenceSpace: XRReferenceSpace): Promise<XRHitResult[]>;
 
     updateWorldTrackingState(options: {
-        planeDetectionState?: { enabled: boolean }
-    })
+        planeDetectionState?: { enabled: boolean; }
+    }): void;
 }
 
 interface XRReferenceSpace extends XRSpace {
@@ -91,7 +91,7 @@ interface XRFrame {
     // Planes
     worldInformation: {
         detectedPlanes?: XRPlaneSet;
-    }
+    };
 }
 
 interface XRViewerPose extends XRPose {
@@ -123,8 +123,8 @@ interface XRWebGLLayer {
     getViewport: Function;
 }
 
-class XRRigidTransform {
-    constructor(matrix: Float32Array): XRRigidTransform;
+declare class XRRigidTransform {
+    constructor(matrix: Float32Array);
     position: DOMPointReadOnly;
     orientation: DOMPointReadOnly;
     matrix: Float32Array;
@@ -149,8 +149,8 @@ interface XRInputSourceEvent extends Event {
 }
 
 // Experimental(er) features
-class XRRay {
-    constructor(transformOrOrigin: XRRigidTransform | DOMPointReadOnly, direction?: DOMPointReadOnly): XRRay;
+declare class XRRay {
+    constructor(transformOrOrigin: XRRigidTransform | DOMPointReadOnly, direction?: DOMPointReadOnly);
     origin: DOMPointReadOnly;
     direction: DOMPointReadOnly;
     matrix: Float32Array;