فهرست منبع

OK!! Finally fixed this bug with touch and mouse simultaneously

David Catuhe 10 سال پیش
والد
کامیت
febc5ead2d

تفاوت فایلی نمایش داده نمی شود زیرا این فایل بسیار بزرگ است
+ 15 - 15
dist/preview release/babylon.core.js


تفاوت فایلی نمایش داده نمی شود زیرا این فایل بسیار بزرگ است
+ 1087 - 1083
dist/preview release/babylon.d.ts


تفاوت فایلی نمایش داده نمی شود زیرا این فایل بسیار بزرگ است
+ 23 - 23
dist/preview release/babylon.js


+ 17 - 4
dist/preview release/babylon.max.js

@@ -11329,6 +11329,8 @@ var BABYLON;
                 this._rigCameras[0].viewport = this._rigCameras[1].viewport = this.viewport;
             }
         };
+        Camera.prototype._setupInputs = function () {
+        };
         Camera.prototype.serialize = function () {
             var serializationObject = BABYLON.SerializationHelper.Serialize(this);
             // Type
@@ -11406,6 +11408,7 @@ var BABYLON;
             //If camera has an input manager, let it parse inputs settings
             if (camera.inputs) {
                 camera.inputs.parse(parsedCamera);
+                camera._setupInputs();
             }
             // Target
             if (parsedCamera.target) {
@@ -11634,7 +11637,9 @@ var BABYLON;
 var BABYLON;
 (function (BABYLON) {
     var FreeCameraMouseInput = (function () {
-        function FreeCameraMouseInput() {
+        function FreeCameraMouseInput(touchEnabled) {
+            if (touchEnabled === void 0) { touchEnabled = true; }
+            this.touchEnabled = touchEnabled;
             this.angularSensibility = 2000.0;
         }
         FreeCameraMouseInput.prototype.attachControl = function (element, noPreventDefault) {
@@ -11644,7 +11649,7 @@ var BABYLON;
                 var engine = this.camera.getEngine();
                 this._pointerInput = function (p, s) {
                     var evt = p.event;
-                    if (evt.pointerType === "touch") {
+                    if (!_this.touchEnabled && evt.pointerType === "touch") {
                         return;
                     }
                     if (p.type === BABYLON.PointerEventTypes.POINTERDOWN) {
@@ -13139,8 +13144,9 @@ var BABYLON;
             this.add(new BABYLON.FreeCameraKeyboardMoveInput());
             return this;
         };
-        FreeCameraInputsManager.prototype.addMouse = function () {
-            this.add(new BABYLON.FreeCameraMouseInput());
+        FreeCameraInputsManager.prototype.addMouse = function (touchEnabled) {
+            if (touchEnabled === void 0) { touchEnabled = true; }
+            this.add(new BABYLON.FreeCameraMouseInput(touchEnabled));
             return this;
         };
         FreeCameraInputsManager.prototype.addGamepad = function () {
@@ -13296,6 +13302,7 @@ var BABYLON;
         function TouchCamera(name, position, scene) {
             _super.call(this, name, position, scene);
             this.inputs.addTouch();
+            this._setupInputs();
         }
         Object.defineProperty(TouchCamera.prototype, "touchAngularSensibility", {
             //-- Begin properties for backward compatibility for inputs
@@ -13329,6 +13336,12 @@ var BABYLON;
         TouchCamera.prototype.getTypeName = function () {
             return "TouchCamera";
         };
+        TouchCamera.prototype._setupInputs = function () {
+            var mouse = this.inputs.attached["mouse"];
+            if (mouse) {
+                mouse.touchEnabled = false;
+            }
+        };
         return TouchCamera;
     })(BABYLON.FreeCamera);
     BABYLON.TouchCamera = TouchCamera;

تفاوت فایلی نمایش داده نمی شود زیرا این فایل بسیار بزرگ است
+ 23 - 23
dist/preview release/babylon.noworker.js


+ 4 - 2
src/Cameras/Inputs/babylon.freecamera.input.mouse.js

@@ -7,7 +7,9 @@ var __decorate = (this && this.__decorate) || function (decorators, target, key,
 var BABYLON;
 (function (BABYLON) {
     var FreeCameraMouseInput = (function () {
-        function FreeCameraMouseInput() {
+        function FreeCameraMouseInput(touchEnabled) {
+            if (touchEnabled === void 0) { touchEnabled = true; }
+            this.touchEnabled = touchEnabled;
             this.angularSensibility = 2000.0;
         }
         FreeCameraMouseInput.prototype.attachControl = function (element, noPreventDefault) {
@@ -17,7 +19,7 @@ var BABYLON;
                 var engine = this.camera.getEngine();
                 this._pointerInput = function (p, s) {
                     var evt = p.event;
-                    if (evt.pointerType === "touch") {
+                    if (!_this.touchEnabled && evt.pointerType === "touch") {
                         return;
                     }
                     if (p.type === BABYLON.PointerEventTypes.POINTERDOWN) {

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

@@ -10,6 +10,9 @@ module BABYLON {
 
         private previousPosition: { x: number, y: number };
 
+        constructor(public touchEnabled = true) {
+        }
+
         attachControl(element: HTMLElement, noPreventDefault?: boolean) {
 
             if (!this._pointerInput) {
@@ -18,7 +21,7 @@ module BABYLON {
                 this._pointerInput = (p, s) => {
                     var evt = <PointerEvent>p.event;
 
-                    if (evt.pointerType === "touch") {
+                    if (!this.touchEnabled && evt.pointerType === "touch") {
                         return;
                     }
 

+ 3 - 0
src/Cameras/babylon.camera.js

@@ -470,6 +470,8 @@ var BABYLON;
                 this._rigCameras[0].viewport = this._rigCameras[1].viewport = this.viewport;
             }
         };
+        Camera.prototype._setupInputs = function () {
+        };
         Camera.prototype.serialize = function () {
             var serializationObject = BABYLON.SerializationHelper.Serialize(this);
             // Type
@@ -547,6 +549,7 @@ var BABYLON;
             //If camera has an input manager, let it parse inputs settings
             if (camera.inputs) {
                 camera.inputs.parse(parsedCamera);
+                camera._setupInputs();
             }
             // Target
             if (parsedCamera.target) {

+ 5 - 0
src/Cameras/babylon.camera.ts

@@ -582,6 +582,9 @@
             }
         }
 
+        public _setupInputs() {
+        }
+
         public serialize(): any {
             var serializationObject = SerializationHelper.Serialize(this);
 
@@ -668,6 +671,8 @@
             //If camera has an input manager, let it parse inputs settings
             if (camera.inputs) {
                 camera.inputs.parse(parsedCamera);
+
+                camera._setupInputs();
             }
             
             // Target

+ 3 - 2
src/Cameras/babylon.freeCameraInputsManager.js

@@ -14,8 +14,9 @@ var BABYLON;
             this.add(new BABYLON.FreeCameraKeyboardMoveInput());
             return this;
         };
-        FreeCameraInputsManager.prototype.addMouse = function () {
-            this.add(new BABYLON.FreeCameraMouseInput());
+        FreeCameraInputsManager.prototype.addMouse = function (touchEnabled) {
+            if (touchEnabled === void 0) { touchEnabled = true; }
+            this.add(new BABYLON.FreeCameraMouseInput(touchEnabled));
             return this;
         };
         FreeCameraInputsManager.prototype.addGamepad = function () {

+ 2 - 2
src/Cameras/babylon.freeCameraInputsManager.ts

@@ -9,8 +9,8 @@ module BABYLON {
             return this;
         }
 
-        addMouse(): FreeCameraInputsManager {
-            this.add(new FreeCameraMouseInput());
+        addMouse(touchEnabled = true): FreeCameraInputsManager {
+            this.add(new FreeCameraMouseInput(touchEnabled));
             return this;
         }
 

+ 7 - 0
src/Cameras/babylon.touchCamera.js

@@ -12,6 +12,7 @@ var BABYLON;
         function TouchCamera(name, position, scene) {
             _super.call(this, name, position, scene);
             this.inputs.addTouch();
+            this._setupInputs();
         }
         Object.defineProperty(TouchCamera.prototype, "touchAngularSensibility", {
             //-- Begin properties for backward compatibility for inputs
@@ -45,6 +46,12 @@ var BABYLON;
         TouchCamera.prototype.getTypeName = function () {
             return "TouchCamera";
         };
+        TouchCamera.prototype._setupInputs = function () {
+            var mouse = this.inputs.attached["mouse"];
+            if (mouse) {
+                mouse.touchEnabled = false;
+            }
+        };
         return TouchCamera;
     })(BABYLON.FreeCamera);
     BABYLON.TouchCamera = TouchCamera;

+ 9 - 0
src/Cameras/babylon.touchCamera.ts

@@ -30,10 +30,19 @@ module BABYLON {
         constructor(name: string, position: Vector3, scene: Scene) {
             super(name, position, scene);
             this.inputs.addTouch();
+
+            this._setupInputs();
         }
 
         public getTypeName(): string {
             return "TouchCamera";
         }
+
+        public _setupInputs() {
+            var mouse = <FreeCameraMouseInput>this.inputs.attached["mouse"];
+            if (mouse) {
+                mouse.touchEnabled = false;
+            }
+        }
     }
 }