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");
|
||||
|
||||
// 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
|
||||
|
||||
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 };
|
||||
export { loadScene };
|
||||
|
|
Loading…
Reference in a new issue