From 635ab177dcb836ef1481e1b27614e67417c0f2a2 Mon Sep 17 00:00:00 2001 From: Kumi Date: Mon, 11 Mar 2024 19:49:48 +0100 Subject: [PATCH] Add iOS texture size limit Added a workaround to limit texture size on iOS devices to prevent issues with rendering performance. This change introduces a detection mechanism for iOS and caps the maximum texture size to 8192 when an iOS device is identified. --- assets/js/scene.js | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/assets/js/scene.js b/assets/js/scene.js index 13c7dd8..f0cc979 100644 --- a/assets/js/scene.js +++ b/assets/js/scene.js @@ -2,6 +2,10 @@ import { getScene } from "./api"; require("aframe"); +// Detect iOS devices +// There is probably a better way to handle issues there, but... +var iOS = /iPad|iPhone|iPod/.test(navigator.userAgent); + // Define the element class QuackscapeScene extends HTMLElement { @@ -20,9 +24,9 @@ class QuackscapeScene extends HTMLElement { } } -document.addEventListener("contextmenu", function(event) { +document.addEventListener("contextmenu", function (event) { event.preventDefault(); -}) +}); customElements.define("quackscape-scene", QuackscapeScene); @@ -42,6 +46,10 @@ async function loadScene(scene_id, x = -1, y = -1, z = -1, destination = null) { var maxTextureSize = gl.getParameter(gl.MAX_TEXTURE_SIZE); + if (iOS) { + maxTextureSize = Math.min(8192, maxTextureSize); + } + // Get scene information from API getScene(scene_id).then((response) => { var scene = response.obj; @@ -119,11 +127,11 @@ async function loadScene(scene_id, x = -1, y = -1, z = -1, destination = null) { destination.appendChild(a_scene); // Dispatch a signal for the editor to pick up - const loaded_event = new CustomEvent('loadedQuackscapeScene'); + const loaded_event = new CustomEvent("loadedQuackscapeScene"); document.dispatchEvent(loaded_event); }); } window.loadScene = loadScene; -export { loadScene }; \ No newline at end of file +export { loadScene };