Sfoglia il codice sorgente

Merge pull request #1388 from RaananW/freeCamera-mouseInputs

Bug fixed, refereces changed
David Catuhe 9 anni fa
parent
commit
674c9e0790
1 ha cambiato i file con 12 aggiunte e 12 eliminazioni
  1. 12 12
      src/Cameras/Inputs/babylon.freecamera.input.mouse.ts

+ 12 - 12
src/Cameras/Inputs/babylon.freecamera.input.mouse.ts

@@ -10,14 +10,14 @@ module BABYLON {
         private _observer: Observer<PointerInfo>;
 
         private previousPosition: { x: number, y: number };
-        
+
         constructor(public touchEnabled = true) {
         }
 
         attachControl(element: HTMLElement, noPreventDefault?: boolean) {
+            var engine = this.camera.getEngine();
+
             if (!this._pointerInput) {
-                var camera = this.camera;
-                var engine = this.camera.getEngine();
                 this._pointerInput = (p, s) => {
                     var evt = <PointerEvent>p.event;
 
@@ -62,14 +62,14 @@ module BABYLON {
 
                         var offsetX = evt.clientX - this.previousPosition.x;
                         var offsetY = evt.clientY - this.previousPosition.y;
-                        
+
                         if (this.camera.getScene().useRightHandedSystem) {
-                            camera.cameraRotation.y -= offsetX / this.angularSensibility;
+                            this.camera.cameraRotation.y -= offsetX / this.angularSensibility;
                         } else {
-                            camera.cameraRotation.y += offsetX / this.angularSensibility;                            
+                            this.camera.cameraRotation.y += offsetX / this.angularSensibility;
                         }
 
-                        camera.cameraRotation.x += offsetY / this.angularSensibility;
+                        this.camera.cameraRotation.x += offsetY / this.angularSensibility;
 
                         this.previousPosition = {
                             x: evt.clientX,
@@ -92,15 +92,15 @@ module BABYLON {
                 var offsetY = evt.movementY || evt.mozMovementY || evt.webkitMovementY || evt.msMovementY || 0;
 
                 if (this.camera.getScene().useRightHandedSystem) {
-                    camera.cameraRotation.y -= offsetX / this.angularSensibility;
+                    this.camera.cameraRotation.y -= offsetX / this.angularSensibility;
                 } else {
-                    camera.cameraRotation.y += offsetX / this.angularSensibility;                            
+                    this.camera.cameraRotation.y += offsetX / this.angularSensibility;
                 }
-                
-                camera.cameraRotation.x += offsetY / this.angularSensibility;
+
+                this.camera.cameraRotation.x += offsetY / this.angularSensibility;
 
                 this.previousPosition = null;
-                
+
                 if (!noPreventDefault) {
                     evt.preventDefault();
                 }