浏览代码

whitespace and whats new

Trevor Baron 6 年之前
父节点
当前提交
029c17dfe2
共有 3 个文件被更改,包括 25 次插入24 次删除
  1. 1 0
      dist/preview release/what's new.md
  2. 23 23
      src/Cameras/XR/babylon.webXRInput.ts
  3. 1 1
      src/babylon.mixins.ts

+ 1 - 0
dist/preview release/what's new.md

@@ -12,6 +12,7 @@
   - webXRSessionManager to bridge xrSession to babylon's engine/camera ([TrevorDev](https://github.com/TrevorDev))
   - webXRExperienceHelper to setup a default XR experience ([TrevorDev](https://github.com/TrevorDev))
   - WebXREnterExitUI and WebXRManagedOutputCanvas classes to configure the XR experience ([TrevorDev](https://github.com/TrevorDev))
+  - WebXRInput manage controllers for the XR experience ([TrevorDev](https://github.com/TrevorDev))
 
 ## Updates
 

+ 23 - 23
src/Cameras/XR/babylon.webXRInput.ts

@@ -6,25 +6,25 @@ module BABYLON {
         /**
          * Represents the part of the controller that is held. This may not exist if the controller is the head mounted display itself, if thats the case only the pointer from the head will be availible
          */
-        public grip?: BABYLON.AbstractMesh
+        public grip?: BABYLON.AbstractMesh;
         /**
          * Pointer which can be used to select objects or attach a visible laser to
          */
-        public pointer: BABYLON.AbstractMesh
+        public pointer: BABYLON.AbstractMesh;
 
         /**
          * Creates the controller
          * @see https://doc.babylonjs.com/how_to/webxr
          * @param scene the scene which the controller should be associated to
          */
-        constructor(scene: BABYLON.Scene){
+        constructor(scene: BABYLON.Scene) {
             this.pointer = new BABYLON.AbstractMesh("controllerPointer", scene);
         }
         /**
          * Disposes of the object
          */
-        dispose(){
-            if(this.grip){
+        dispose() {
+            if (this.grip) {
                 this.grip.dispose();
             }
             this.pointer.dispose();
@@ -38,41 +38,41 @@ module BABYLON {
         /**
          * XR controllers being tracked
          */
-        public controllers:Array<WebXRController> = []
+        public controllers: Array<WebXRController> = [];
         private _tmpMatrix = new BABYLON.Matrix();
-        private _frameObserver:Nullable<Observer<any>>;
+        private _frameObserver: Nullable<Observer<any>>;
 
         /**
          * Initializes the WebXRInput
          * @param helper experience helper which the input should be created for
          */
         public constructor(private helper: WebXRExperienceHelper) {
-            this._frameObserver = helper._sessionManager.onXRFrameObservable.add(()=>{
+            this._frameObserver = helper._sessionManager.onXRFrameObservable.add(() => {
                 if (!helper._sessionManager._currentXRFrame || !helper._sessionManager._currentXRFrame.getDevicePose) {
                     return false;
                 }
 
                 var xrFrame = helper._sessionManager._currentXRFrame;
-                var inputSources = helper._sessionManager._xrSession.getInputSources()
+                var inputSources = helper._sessionManager._xrSession.getInputSources();
 
-                inputSources.forEach((input, i)=>{
+                inputSources.forEach((input, i) => {
                     let inputPose = xrFrame.getInputPose(input, helper._sessionManager._frameOfReference);
-                    if(inputPose){
-                        if(this.controllers.length <= i){
+                    if (inputPose) {
+                        if (this.controllers.length <= i) {
                             this.controllers.push(new WebXRController(helper.container.getScene()));
                         }
                         var controller = this.controllers[i];
-                        
+
                         // Manage the grip if it exists
-                        if(inputPose.gripMatrix){
-                            if(!controller.grip){
+                        if (inputPose.gripMatrix) {
+                            if (!controller.grip) {
                                 controller.grip = new BABYLON.AbstractMesh("controllerGrip", helper.container.getScene());
                             }
                             BABYLON.Matrix.FromFloat32ArrayToRefScaled(inputPose.gripMatrix, 0, 1, this._tmpMatrix);
-                            if(!controller.grip.getScene().useRightHandedSystem){
+                            if (!controller.grip.getScene().useRightHandedSystem) {
                                 this._tmpMatrix.toggleModelMatrixHandInPlace();
                             }
-                            if(!controller.grip.rotationQuaternion){
+                            if (!controller.grip.rotationQuaternion) {
                                 controller.grip.rotationQuaternion = new BABYLON.Quaternion();
                             }
                             this._tmpMatrix.decompose(controller.grip.scaling, controller.grip.rotationQuaternion, controller.grip.position);
@@ -80,24 +80,24 @@ module BABYLON {
 
                         // Manager pointer of controller
                         BABYLON.Matrix.FromFloat32ArrayToRefScaled(inputPose.targetRay.transformMatrix, 0, 1, this._tmpMatrix);
-                        if(!controller.pointer.getScene().useRightHandedSystem){
+                        if (!controller.pointer.getScene().useRightHandedSystem) {
                             this._tmpMatrix.toggleModelMatrixHandInPlace();
                         }
-                        if(!controller.pointer.rotationQuaternion){
+                        if (!controller.pointer.rotationQuaternion) {
                             controller.pointer.rotationQuaternion = new BABYLON.Quaternion();
                         }
                         this._tmpMatrix.decompose(controller.pointer.scaling, controller.pointer.rotationQuaternion, controller.pointer.position);
                     }
-                })
-            })
+                });
+            });
         }
         /**
          * Disposes of the object
          */
         public dispose() {
-            this.controllers.forEach((c)=>{
+            this.controllers.forEach((c) => {
                 c.dispose();
-            })
+            });
             this.helper._sessionManager.onXRFrameObservable.remove(this._frameObserver);
         }
     }

+ 1 - 1
src/babylon.mixins.ts

@@ -184,7 +184,7 @@ interface XRDevice {
     supportsSession(options: XRSessionCreationOptions): Promise<void>;
 }
 interface XRSession {
-    getInputSources():Array<any>;
+    getInputSources(): Array<any>;
     baseLayer: XRWebGLLayer;
     requestFrameOfReference(type: string): Promise<void>;
     requestHitTest(origin: Float32Array, direction: Float32Array, frameOfReference: any): any;