sebavan 6 年之前
父节点
当前提交
c964efe2c8

文件差异内容过多而无法显示
+ 51663 - 0
Playground/babylon.d.txt


文件差异内容过多而无法显示
+ 5753 - 5747
dist/preview release/babylon.d.ts


文件差异内容过多而无法显示
+ 1 - 1
dist/preview release/babylon.js


+ 11 - 0
dist/preview release/babylon.max.js

@@ -12844,6 +12844,9 @@ var BABYLON;
                     canvas.addEventListener("webglcontextlost", this._onContextLost, false);
                     canvas.addEventListener("webglcontextrestored", this._onContextRestored, false);
                 }
+                if (!options.doNotHandleTouchAction) {
+                    this._disableTouchAction();
+                }
             }
             else {
                 this._gl = canvasOrContext;
@@ -13133,6 +13136,14 @@ var BABYLON;
             enumerable: true,
             configurable: true
         });
+        Engine.prototype._disableTouchAction = function () {
+            if (!this._renderingCanvas) {
+                return;
+            }
+            this._renderingCanvas.setAttribute("touch-action", "none");
+            this._renderingCanvas.style.touchAction = "none";
+            this._renderingCanvas.style.msTouchAction = "none";
+        };
         Engine.prototype._rebuildInternalTextures = function () {
             var currentState = this._internalTexturesCache.slice(); // Do a copy because the rebuild will add proxies
             for (var _i = 0, currentState_1 = currentState; _i < currentState_1.length; _i++) {

文件差异内容过多而无法显示
+ 1 - 1
dist/preview release/viewer/babylon.viewer.js


文件差异内容过多而无法显示
+ 1 - 1
dist/preview release/viewer/babylon.viewer.max.js


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

@@ -153,6 +153,7 @@
 - Fix a bug when a call to `updateIndices` leads to changing the size of the index buffer by recreating the subMeshes in that case ([barroij](https://github.com/barroij))
 - Add option to disable gazeTracker color changes in vrExperienceHelper ([TrevorDev](https://github.com/TrevorDev))
 - PointerDragBehavior validateDrag predicate to stop dragging to specific points ([TrevorDev](https://github.com/TrevorDev))
+- Auto Update Touch Action [#5674](https://github.com/BabylonJS/Babylon.js/issues/5674)([Sebavan](https://github.com/Sebavan))
 
 ### Viewer
 

+ 19 - 0
src/Engines/engine.ts

@@ -235,6 +235,11 @@ declare type RenderTargetTexture = import("../Materials/Textures/renderTargetTex
          * If this event happens when this parameter is true, you will have to reload the page to restore rendering
          */
         doNotHandleContextLost?: boolean;
+        /**
+         * Defines that engine should ignore modifying touch action attribute and style
+         * If not handle, you might need to set it up on your side for expected touch devices behavior.
+         */
+        doNotHandleTouchAction?: boolean;
     }
 
     /**
@@ -1181,6 +1186,10 @@ declare type RenderTargetTexture = import("../Materials/Textures/renderTargetTex
                     canvas.addEventListener("webglcontextlost", this._onContextLost, false);
                     canvas.addEventListener("webglcontextrestored", this._onContextRestored, false);
                 }
+
+                if (!options.doNotHandleTouchAction) {
+                    this._disableTouchAction();
+                }
             } else {
                 this._gl = <WebGLRenderingContext>canvasOrContext;
                 this._renderingCanvas = this._gl.canvas;
@@ -1294,6 +1303,16 @@ declare type RenderTargetTexture = import("../Materials/Textures/renderTargetTex
             this.enableOfflineSupport = Engine.OfflineProviderFactory !== undefined;
         }
 
+        private _disableTouchAction(): void {
+            if (!this._renderingCanvas) {
+                return;
+            }
+
+            this._renderingCanvas.setAttribute("touch-action", "none");
+            this._renderingCanvas.style.touchAction = "none";
+            this._renderingCanvas.style.msTouchAction = "none";
+        }
+
         private _rebuildInternalTextures(): void {
             let currentState = this._internalTexturesCache.slice(); // Do a copy because the rebuild will add proxies