Browse Source

Fixed ray creation when the devicePixelRatio is not equls to 1. This PR has been tested on IE11, IE11 mobile, Chrome Android and Safari (iOS8).

Yannick Comte 11 years ago
parent
commit
8e01e19969
2 changed files with 2 additions and 2 deletions
  1. 1 1
      Babylon/babylon.scene.js
  2. 1 1
      Babylon/babylon.scene.ts

+ 1 - 1
Babylon/babylon.scene.js

@@ -1183,7 +1183,7 @@
             x = x / this._engine.getHardwareScalingLevel() - viewport.x;
             x = x / this._engine.getHardwareScalingLevel() - viewport.x;
             y = y / this._engine.getHardwareScalingLevel() - (this._engine.getRenderHeight() - viewport.y - viewport.height);
             y = y / this._engine.getHardwareScalingLevel() - (this._engine.getRenderHeight() - viewport.y - viewport.height);
 
 
-            return BABYLON.Ray.CreateNew(x, y, viewport.width, viewport.height, world ? world : BABYLON.Matrix.Identity(), camera.getViewMatrix(), camera.getProjectionMatrix());
+            return BABYLON.Ray.CreateNew(x / window.devicePixelRatio, y / window.devicePixelRatio, viewport.width, viewport.height, world ? world : BABYLON.Matrix.Identity(), camera.getViewMatrix(), camera.getProjectionMatrix());
         };
         };
 
 
         Scene.prototype._internalPick = function (rayFunction, predicate, fastCheck) {
         Scene.prototype._internalPick = function (rayFunction, predicate, fastCheck) {

+ 1 - 1
Babylon/babylon.scene.ts

@@ -1269,7 +1269,7 @@
             x = x / this._engine.getHardwareScalingLevel() - viewport.x;
             x = x / this._engine.getHardwareScalingLevel() - viewport.x;
             y = y / this._engine.getHardwareScalingLevel() - (this._engine.getRenderHeight() - viewport.y - viewport.height);
             y = y / this._engine.getHardwareScalingLevel() - (this._engine.getRenderHeight() - viewport.y - viewport.height);
 
 
-            return BABYLON.Ray.CreateNew(x, y, viewport.width, viewport.height, world ? world : BABYLON.Matrix.Identity(), camera.getViewMatrix(), camera.getProjectionMatrix());
+            return BABYLON.Ray.CreateNew(x / window.devicePixelRatio, y / window.devicePixelRatio, viewport.width, viewport.height, world ? world : BABYLON.Matrix.Identity(), camera.getViewMatrix(), camera.getProjectionMatrix());
         }
         }
 
 
         private _internalPick(rayFunction: (world: Matrix) => Ray, predicate: (mesh: AbstractMesh) => boolean, fastCheck?: boolean): PickingInfo {
         private _internalPick(rayFunction: (world: Matrix) => Ray, predicate: (mesh: AbstractMesh) => boolean, fastCheck?: boolean): PickingInfo {