Parcourir la source

Fixed issue with panning with ArcRotateCameraPointersInput

David Catuhe il y a 9 ans
Parent
commit
e585f04174

Fichier diff supprimé car celui-ci est trop grand
+ 13 - 13
dist/preview release/babylon.core.js


Fichier diff supprimé car celui-ci est trop grand
+ 1000 - 998
dist/preview release/babylon.d.ts


Fichier diff supprimé car celui-ci est trop grand
+ 20 - 20
dist/preview release/babylon.js


+ 37 - 22
dist/preview release/babylon.max.js

@@ -12190,6 +12190,8 @@ var BABYLON;
             element.addEventListener("MSPointerDown", this._onGestureStart, false);
             element.addEventListener("MSGestureChange", this._onGesture, false);
             BABYLON.Tools.RegisterTopRootEvents([
+                { name: "keydown", handler: this._onKeyDown },
+                { name: "keyup", handler: this._onKeyUp },
                 { name: "blur", handler: this._onLostFocus }
             ]);
         };
@@ -12219,6 +12221,8 @@ var BABYLON;
                 this._onContextMenu = null;
             }
             BABYLON.Tools.UnregisterTopRootEvents([
+                { name: "keydown", handler: this._onKeyDown },
+                { name: "keyup", handler: this._onKeyUp },
                 { name: "blur", handler: this._onLostFocus }
             ]);
         };
@@ -20328,14 +20332,14 @@ var BABYLON;
     var VideoTexture = (function (_super) {
         __extends(VideoTexture, _super);
         /**
-        * Creates a video texture.
-        * Sample : https://doc.babylonjs.com/tutorials/01._Advanced_Texturing
-        * @param {Array} urlsOrVideo can be used to provide an array of urls or an already setup HTML video element.
-        * @param {BABYLON.Scene} scene is obviously the current scene.
-        * @param {boolean} generateMipMaps can be used to turn on mipmaps (Can be expensive for videoTextures because they are often updated).
-        * @param {boolean} invertY is false by default but can be used to invert video on Y axis
-        * @param {number} samplingMode controls the sampling method and is set to TRILINEAR_SAMPLINGMODE by default
-        */
+         * Creates a video texture.
+         * Sample : https://doc.babylonjs.com/tutorials/01._Advanced_Texturing
+         * @param {Array} urlsOrVideo can be used to provide an array of urls or an already setup HTML video element.
+         * @param {BABYLON.Scene} scene is obviously the current scene.
+         * @param {boolean} generateMipMaps can be used to turn on mipmaps (Can be expensive for videoTextures because they are often updated).
+         * @param {boolean} invertY is false by default but can be used to invert video on Y axis
+         * @param {number} samplingMode controls the sampling method and is set to TRILINEAR_SAMPLINGMODE by default
+         */
         function VideoTexture(name, urlsOrVideo, scene, generateMipMaps, invertY, samplingMode) {
             var _this = this;
             if (generateMipMaps === void 0) { generateMipMaps = false; }
@@ -20354,28 +20358,36 @@ var BABYLON;
                 this.video.autoplay = false;
                 this.video.loop = true;
             }
-            this.video.addEventListener("canplaythrough", function () {
-                if (BABYLON.Tools.IsExponentOfTwo(_this.video.videoWidth) && BABYLON.Tools.IsExponentOfTwo(_this.video.videoHeight)) {
-                    _this.wrapU = BABYLON.Texture.WRAP_ADDRESSMODE;
-                    _this.wrapV = BABYLON.Texture.WRAP_ADDRESSMODE;
-                }
-                else {
-                    _this.wrapU = BABYLON.Texture.CLAMP_ADDRESSMODE;
-                    _this.wrapV = BABYLON.Texture.CLAMP_ADDRESSMODE;
-                    generateMipMaps = false;
-                }
-                _this._texture = scene.getEngine().createDynamicTexture(_this.video.videoWidth, _this.video.videoHeight, generateMipMaps, samplingMode, false);
-                _this._texture.isReady = true;
-            });
+            this._generateMipMaps = generateMipMaps;
+            this._samplingMode = samplingMode;
+            if (BABYLON.Tools.IsExponentOfTwo(this.video.videoWidth) && BABYLON.Tools.IsExponentOfTwo(this.video.videoHeight)) {
+                this.wrapU = BABYLON.Texture.WRAP_ADDRESSMODE;
+                this.wrapV = BABYLON.Texture.WRAP_ADDRESSMODE;
+            }
+            else {
+                this.wrapU = BABYLON.Texture.CLAMP_ADDRESSMODE;
+                this.wrapV = BABYLON.Texture.CLAMP_ADDRESSMODE;
+                this._generateMipMaps = false;
+            }
             if (urls) {
+                this.video.addEventListener("canplaythrough", function () {
+                    _this._createTexture();
+                });
                 urls.forEach(function (url) {
                     var source = document.createElement("source");
                     source.src = url;
                     _this.video.appendChild(source);
                 });
             }
+            else {
+                this._createTexture();
+            }
             this._lastUpdate = BABYLON.Tools.Now;
         }
+        VideoTexture.prototype._createTexture = function () {
+            this._texture = this.getScene().getEngine().createDynamicTexture(this.video.videoWidth, this.video.videoHeight, this._generateMipMaps, this._samplingMode, false);
+            this._texture.isReady = true;
+        };
         VideoTexture.prototype.update = function () {
             if (this._autoLaunch) {
                 this._autoLaunch = false;
@@ -38801,11 +38813,14 @@ var BABYLON;
             };
         }
         DepthRenderer.prototype.isReady = function (subMesh, useInstances) {
+            var material = subMesh.getMaterial();
+            if (material.disableDepthWrite) {
+                return false;
+            }
             var defines = [];
             var attribs = [BABYLON.VertexBuffer.PositionKind];
             var mesh = subMesh.getMesh();
             var scene = mesh.getScene();
-            var material = subMesh.getMaterial();
             // Alpha test
             if (material && material.needAlphaTesting()) {
                 defines.push("#define ALPHATEST");

Fichier diff supprimé car celui-ci est trop grand
+ 28 - 28
dist/preview release/babylon.noworker.js


+ 4 - 0
src/Cameras/Inputs/babylon.arcrotatecamera.input.pointers.js

@@ -145,6 +145,8 @@ var BABYLON;
             element.addEventListener("MSPointerDown", this._onGestureStart, false);
             element.addEventListener("MSGestureChange", this._onGesture, false);
             BABYLON.Tools.RegisterTopRootEvents([
+                { name: "keydown", handler: this._onKeyDown },
+                { name: "keyup", handler: this._onKeyUp },
                 { name: "blur", handler: this._onLostFocus }
             ]);
         };
@@ -174,6 +176,8 @@ var BABYLON;
                 this._onContextMenu = null;
             }
             BABYLON.Tools.UnregisterTopRootEvents([
+                { name: "keydown", handler: this._onKeyDown },
+                { name: "keyup", handler: this._onKeyUp },
                 { name: "blur", handler: this._onLostFocus }
             ]);
         };

+ 6 - 3
src/Cameras/Inputs/babylon.arcrotatecamera.input.pointers.ts

@@ -176,8 +176,7 @@ module BABYLON {
                     }
                 }
             };
-
-
+        
             element.addEventListener(eventPrefix + "down", this._onPointerDown, false);
             element.addEventListener(eventPrefix + "up", this._onPointerUp, false);
             element.addEventListener(eventPrefix + "out", this._onPointerUp, false);
@@ -187,12 +186,14 @@ module BABYLON {
             element.addEventListener("MSGestureChange", this._onGesture, false);
 
             Tools.RegisterTopRootEvents([
+                { name: "keydown", handler: this._onKeyDown },
+                { name: "keyup", handler: this._onKeyUp },
                 { name: "blur", handler: this._onLostFocus }
             ]);
         }
 
         public detachControl(element: HTMLElement) {
-            if (element && this._onPointerDown){
+            if (element && this._onPointerDown) {
                 element.removeEventListener("contextmenu", this._onContextMenu);
                 element.removeEventListener(eventPrefix + "down", this._onPointerDown);
                 element.removeEventListener(eventPrefix + "up", this._onPointerUp);
@@ -221,6 +222,8 @@ module BABYLON {
             }
             
             Tools.UnregisterTopRootEvents([
+                { name: "keydown", handler: this._onKeyDown },
+                { name: "keyup", handler: this._onKeyUp },
                 { name: "blur", handler: this._onLostFocus }
             ]);
         }

+ 29 - 21
src/Materials/Textures/babylon.videoTexture.js

@@ -8,14 +8,14 @@ var BABYLON;
     var VideoTexture = (function (_super) {
         __extends(VideoTexture, _super);
         /**
-        * Creates a video texture.
-        * Sample : https://doc.babylonjs.com/tutorials/01._Advanced_Texturing
-        * @param {Array} urlsOrVideo can be used to provide an array of urls or an already setup HTML video element.
-        * @param {BABYLON.Scene} scene is obviously the current scene.
-        * @param {boolean} generateMipMaps can be used to turn on mipmaps (Can be expensive for videoTextures because they are often updated).
-        * @param {boolean} invertY is false by default but can be used to invert video on Y axis
-        * @param {number} samplingMode controls the sampling method and is set to TRILINEAR_SAMPLINGMODE by default
-        */
+         * Creates a video texture.
+         * Sample : https://doc.babylonjs.com/tutorials/01._Advanced_Texturing
+         * @param {Array} urlsOrVideo can be used to provide an array of urls or an already setup HTML video element.
+         * @param {BABYLON.Scene} scene is obviously the current scene.
+         * @param {boolean} generateMipMaps can be used to turn on mipmaps (Can be expensive for videoTextures because they are often updated).
+         * @param {boolean} invertY is false by default but can be used to invert video on Y axis
+         * @param {number} samplingMode controls the sampling method and is set to TRILINEAR_SAMPLINGMODE by default
+         */
         function VideoTexture(name, urlsOrVideo, scene, generateMipMaps, invertY, samplingMode) {
             var _this = this;
             if (generateMipMaps === void 0) { generateMipMaps = false; }
@@ -34,28 +34,36 @@ var BABYLON;
                 this.video.autoplay = false;
                 this.video.loop = true;
             }
-            this.video.addEventListener("canplaythrough", function () {
-                if (BABYLON.Tools.IsExponentOfTwo(_this.video.videoWidth) && BABYLON.Tools.IsExponentOfTwo(_this.video.videoHeight)) {
-                    _this.wrapU = BABYLON.Texture.WRAP_ADDRESSMODE;
-                    _this.wrapV = BABYLON.Texture.WRAP_ADDRESSMODE;
-                }
-                else {
-                    _this.wrapU = BABYLON.Texture.CLAMP_ADDRESSMODE;
-                    _this.wrapV = BABYLON.Texture.CLAMP_ADDRESSMODE;
-                    generateMipMaps = false;
-                }
-                _this._texture = scene.getEngine().createDynamicTexture(_this.video.videoWidth, _this.video.videoHeight, generateMipMaps, samplingMode, false);
-                _this._texture.isReady = true;
-            });
+            this._generateMipMaps = generateMipMaps;
+            this._samplingMode = samplingMode;
+            if (BABYLON.Tools.IsExponentOfTwo(this.video.videoWidth) && BABYLON.Tools.IsExponentOfTwo(this.video.videoHeight)) {
+                this.wrapU = BABYLON.Texture.WRAP_ADDRESSMODE;
+                this.wrapV = BABYLON.Texture.WRAP_ADDRESSMODE;
+            }
+            else {
+                this.wrapU = BABYLON.Texture.CLAMP_ADDRESSMODE;
+                this.wrapV = BABYLON.Texture.CLAMP_ADDRESSMODE;
+                this._generateMipMaps = false;
+            }
             if (urls) {
+                this.video.addEventListener("canplaythrough", function () {
+                    _this._createTexture();
+                });
                 urls.forEach(function (url) {
                     var source = document.createElement("source");
                     source.src = url;
                     _this.video.appendChild(source);
                 });
             }
+            else {
+                this._createTexture();
+            }
             this._lastUpdate = BABYLON.Tools.Now;
         }
+        VideoTexture.prototype._createTexture = function () {
+            this._texture = this.getScene().getEngine().createDynamicTexture(this.video.videoWidth, this.video.videoHeight, this._generateMipMaps, this._samplingMode, false);
+            this._texture.isReady = true;
+        };
         VideoTexture.prototype.update = function () {
             if (this._autoLaunch) {
                 this._autoLaunch = false;

+ 13 - 8
src/Materials/Textures/babylon.videoTexture.ts

@@ -1,9 +1,10 @@
-module BABYLON {
+module BABYLON {
     export class VideoTexture extends Texture {
         public video: HTMLVideoElement;
 
         private _autoLaunch = true;
         private _lastUpdate: number;
+        private _generateMipMaps: boolean
 
         /**
          * Creates a video texture.
@@ -30,19 +31,21 @@ module BABYLON {
                 this.video.loop = true;
             }
 
+            this._generateMipMaps = generateMipMaps;
+            this._samplingMode = samplingMode;
+
             if (Tools.IsExponentOfTwo(this.video.videoWidth) && Tools.IsExponentOfTwo(this.video.videoHeight)) {
                 this.wrapU = Texture.WRAP_ADDRESSMODE;
                 this.wrapV = Texture.WRAP_ADDRESSMODE;
             } else {
                 this.wrapU = Texture.CLAMP_ADDRESSMODE;
                 this.wrapV = Texture.CLAMP_ADDRESSMODE;
-                generateMipMaps = false;
+                this._generateMipMaps = false;
             }
 
             if (urls) {
                 this.video.addEventListener("canplaythrough", () => {
-                    this._texture = scene.getEngine().createDynamicTexture(this.video.videoWidth, this.video.videoHeight, generateMipMaps, samplingMode, false);
-                    this._texture.isReady = true;
+                    this._createTexture();
                 });
                 urls.forEach(url => {
                     var source = document.createElement("source");
@@ -50,13 +53,15 @@ module BABYLON {
                     this.video.appendChild(source);
                 });
             } else {
-
-                this._texture = scene.getEngine().createDynamicTexture(this.video.videoWidth, this.video.videoHeight, generateMipMaps, samplingMode, false);
-                this._texture.isReady = true;
+                this._createTexture();
             }
 
             this._lastUpdate = Tools.Now;
+        }
 
+        private _createTexture(): void {
+            this._texture = this.getScene().getEngine().createDynamicTexture(this.video.videoWidth, this.video.videoHeight, this._generateMipMaps, this._samplingMode, false);
+            this._texture.isReady = true;
         }
 
         public update(): boolean {
@@ -76,4 +81,4 @@ module BABYLON {
             return true;
         }
     }
-}
+}

+ 4 - 1
src/Rendering/babylon.depthRenderer.js

@@ -65,11 +65,14 @@ var BABYLON;
             };
         }
         DepthRenderer.prototype.isReady = function (subMesh, useInstances) {
+            var material = subMesh.getMaterial();
+            if (material.disableDepthWrite) {
+                return false;
+            }
             var defines = [];
             var attribs = [BABYLON.VertexBuffer.PositionKind];
             var mesh = subMesh.getMesh();
             var scene = mesh.getScene();
-            var material = subMesh.getMaterial();
             // Alpha test
             if (material && material.needAlphaTesting()) {
                 defines.push("#define ALPHATEST");

+ 5 - 1
src/Rendering/babylon.depthRenderer.ts

@@ -87,13 +87,17 @@
         }
 
         public isReady(subMesh: SubMesh, useInstances: boolean): boolean {
+            var material: any = subMesh.getMaterial();
+            if (material.disableDepthWrite) {
+                return false;
+            }
+
             var defines = [];
 
             var attribs = [VertexBuffer.PositionKind];
 
             var mesh = subMesh.getMesh();
             var scene = mesh.getScene();
-            var material = subMesh.getMaterial();
 
             // Alpha test
             if (material && material.needAlphaTesting()) {