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.
This commit is contained in:
Kumi 2024-03-11 19:49:48 +01:00
parent 304cb8f63d
commit 635ab177dc
Signed by: kumi
GPG key ID: ECBCC9082395383F

View file

@ -2,6 +2,10 @@ import { getScene } from "./api";
require("aframe"); 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 <quackscape-scene> element // Define the <quackscape-scene> element
class QuackscapeScene extends HTMLElement { class QuackscapeScene extends HTMLElement {
@ -20,9 +24,9 @@ class QuackscapeScene extends HTMLElement {
} }
} }
document.addEventListener("contextmenu", function(event) { document.addEventListener("contextmenu", function (event) {
event.preventDefault(); event.preventDefault();
}) });
customElements.define("quackscape-scene", QuackscapeScene); 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); var maxTextureSize = gl.getParameter(gl.MAX_TEXTURE_SIZE);
if (iOS) {
maxTextureSize = Math.min(8192, maxTextureSize);
}
// Get scene information from API // Get scene information from API
getScene(scene_id).then((response) => { getScene(scene_id).then((response) => {
var scene = response.obj; var scene = response.obj;
@ -119,7 +127,7 @@ async function loadScene(scene_id, x = -1, y = -1, z = -1, destination = null) {
destination.appendChild(a_scene); destination.appendChild(a_scene);
// Dispatch a signal for the editor to pick up // 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); document.dispatchEvent(loaded_event);
}); });
} }