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:
parent
304cb8f63d
commit
635ab177dc
1 changed files with 12 additions and 4 deletions
|
@ -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 {
|
||||||
|
@ -22,7 +26,7 @@ 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);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue